@webqit/oohtml 4.3.17 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- (()=>{var ee=Object.defineProperty;var re=(n,t,r)=>t in n?ee(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var ct=(n,t,r)=>(re(n,typeof t!="symbol"?t+"":t,r),r);function w(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function yt(n,t,r=null){return g(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function C(n,...t){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 e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new J,i.set(e,r));return r}var J=class extends Map{constructor(...t){super(...t),this.observers=new Set}set(t,r){let e=super.set(t,r);return this.fire("set",t,r,t),e}delete(t){let r=super.delete(t);return this.fire("delete",t),r}has(t){return this.fire("has",t),super.has(t)}get(t){return this.fire("get",t),super.get(t)}keyNames(){return Array.from(super.keys())}observe(t,r,e){let i={type:t,key:r,callback:e};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(t,r,e){if(Array.isArray(t)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(ut([t,"*"],i.type)&&ut([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(ut([t,"*"],i.type)&&ut([r,"*"],i.key))||i.callback(...e)}},ut=(n,t)=>Array.isArray(t)?yt(n,t).length:n.includes(t);function X(n){return typeof n=="function"}function Y(n){return n===null||n===""}function H(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||X(n)}function bt(n){return Y(n)||H(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function b(n){return X(n)||n&&{}.toString.call(n)==="[object function]"}function Z(n){return n instanceof Number||typeof n=="number"}function S(n){return Z(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function Q(n){return n instanceof String||typeof n=="string"&&n!==null}function _t(n){return!Q(n)&&!H(n.length)}function at(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function wt(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function xt(n,t){var r=[];return wt(n,t).forEach(e=>{at(r,...Object.getOwnPropertyNames(e))}),r}function j(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((S(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((f,c)=>{!A(f)&&!b(f)||(r?xt(f):Object.keys(f)).forEach(l=>{if(!!t(l,s,f,c)){var u=s[l],m=f[l];if((g(u)&&g(m)||w(u)&&w(m))&&(o===!0||o>0))s[l]=g(u)&&g(m)?[]:{},j([S(o)?o-1:o,s[l],u,m],t,r,e,i);else if(g(s)&&g(f))e?s[l]=m:s.push(m);else try{i?Object.defineProperty(s,l,Object.getOwnPropertyDescriptor(f,l)):s[l]=f[l]}catch{}}})}),s}function K(...n){return j(n,(t,r,e)=>!0,!1,!1,!1)}function E(n,t=!0){return g(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&&bt(n)?[]:_t(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function tt(n,t,r={},e={}){t=E(t).slice();for(var i=n;!H(i)&&!Y(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):A(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function vt(n,t,r,e={},i={}){let o=(u,m,a)=>i.set?i.set(u,m,a):(S(t[f])&&g(u)?u.push(a):u[m]=a,!0);t=E(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!A(s)&&!b(s))return!1;var c=tt(s,t[f],i);if(!A(c)){if(i.buildTree===!1)return!1;c=b(i.buildTree)?i.buildTree(f):S(t[f+1])?[]:{};var l=o(s,t[f],c);if(!l)return!1}s=c}else return o(s,t[f],r)}var et=class{constructor(t,r=!1){Object.defineProperty(this,"window",{value:t}),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(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),c=l=>{l!==void 0&&this.cycle(t,r,l)};f instanceof Promise?f.then(c):c(f)})};i instanceof Promise?i.then(o):o(i)})}};function $t(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function dt(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",e?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function Dt(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function rt(n,t,r,e=!1,i=null){let o=i?.get(t)?.get(r);if(typeof o<"u")return o;let s=l=>(i?.has(t)||i?.set(t,new WeakMap),i?.get(t)?.set(r,l),l),f=t.getRootNode(),c=r.getRootNode();return f===c?s(t.contains(r)):e&&c instanceof n.ShadowRoot?s(rt(n,t,c.host,e,i)):s(!1)}function Rt(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,e,i]),[null,0,[""]])[2].reverse()}var T=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:$t(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Rt(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var G=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(b(t[0])?t=[[],...t]:w(t[0])&&!(t[0]instanceof T)&&t.length===1?t=[[],void 0,t[0]]:w(t[1])&&t.length===2?t=[E(t[0],!1),void 0,t[1]]:t[0]=E(t[0],!1),t[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 t[0]=t[0].map(r=>r instanceof T?r:new T(r)),t}registry(...t){return C("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=new Set,s=new WeakMap;for(let[f,c]of this.registry(t)){let l=[].concat(r).filter(m=>rt(i,f.context,m.target,f.params.subtree==="cross-roots",s));if(!l.length)continue;let u=[f,Array.isArray(r)?l:l[0]];c?o.add(u):e.call(i,...u)}for(let f of o)e.call(i,...f);o.clear()}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&b(i.disconnect)&&i.disconnect()||b(i)&&i()||w(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var F=class extends G{type="attr";constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof T;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Vt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of s){let l=f?f.generate():{};r(c,l,o)}else{let c=f?.generate()||{};r(s,c,o)}if(e.live){f&&(e={...e,signalGenerator:f});let c=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,c)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof T;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Wt.call(s,"intercept",()=>{});let c=new s.MutationObserver(a=>{a=Ut(a).map(p=>Bt.call(s,p)),Ft.call(s,m,a,o)}),l={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(l.attributeFilter=t.map(a=>a+"")),c.observe(o,l);let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:c};return this.disconnectables(e.signal,c,u)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof T;[t,r,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync";this.registry(f).size||Wt.call(s,f,a=>{this.forEachMatchingContext(f,a,Ft)});let c={disconnect(){m.delete(u)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:c},m=this.registry(f);return m.set(u,!!u.params.deferred),this.disconnectables(e.signal,c,l)}};function Ut(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||C(r.target,"internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Ft(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:c}=n;if(o.subtree||(t=t.filter(a=>a.target===r)),!t.length)return;let l=e.map(a=>a+"");if(o.atomic&&!s.size?t=Vt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(a=>l.includes(a.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(a=>{let p;return o.eventDetails||({event:p,...a}=a),!o.oldValue&&"oldValue"in a&&({oldValue:p,...a}=a),!o.newValue&&"value"in a?{value:p,...a}=a:o.newValue&&typeof a.value>"u"&&(a={...a,value:pt(a.target,a.name,()=>a.target.getAttribute(a.name))}),a})),o.atomic&&(t.forEach(a=>s.set(a.name,a)),t=Array.from(s.entries()).map(([,a])=>a));let u=f?t[0]:t,m=c?c.generate():{};i(u,m,r)}function pt(n,t,r){let e=C(n,"internalAttrInteractions").get(t);C(n,"internalAttrInteractions").set(t,!0);let i=r();return C(n,"internalAttrInteractions").set(t,e),i}function Vt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:pt(n,o,()=>n.getAttribute(o)),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:pt(n,o.nodeName,()=>o.nodeValue),...e})}function Bt({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function Wt(n,t){let r=this,{webqit:e,document:i,Element:o}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(u,m)=>{e.realdom.attrInterceptionRecords.has(u.target)||e.realdom.attrInterceptionRecords.set(u.target,{});let a=e.realdom.attrInterceptionRecords.get(u.target);if(a[u.name]=a[u.name]||[],a[u.name].unshift(u.event),C(u.target,"internalAttrInteractions").get(u.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([u]));let p=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([u])),p};new r.MutationObserver(u=>{u=u.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),u=Ut(u).map(m=>Bt.call(r,m)),u.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(u)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(u)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let l=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(u=>{l[u]=o.prototype[u],o.prototype[u]=function(...m){let a,p=pt(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(u)&&(a=m[1]),u==="toggleAttribute"&&a===void 0&&(a=p===null);let _={target:this,name:m[0],value:a,oldValue:p,type:"interception",event:[this,u]};return f(_,()=>l[u].call(this,...m))}}),s}var nt=class extends G{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new F(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=l=>(o.has(l)||o.set(l,{target:l,entrants:[],exits:[],type:"query",event:null}),o.get(l));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(l=>s(i).entrants.push(l));else if(t.every(l=>l.type==="selector")){let[l,u]=t.reduce(([a,p],_)=>_.kind==="xpath"?[a,p.concat(_)]:[a.concat(_),p],[[],[]]),m=[];e.subtree?(l.length&&m.push(...i.querySelectorAll(l.join(","))),u.length&&m.push(...dt(this.window,i,u))):(l.length&&m.push(...[...i.children].filter(a=>a.matches(l))),u.length&&m.push(...dt(this.window,i,u,!1))),m.forEach(a=>s(a.parentNode||i).entrants.push(a))}}if(!r)return o;let f={disconnected:!1},c=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,l]of o){if(f.disconnected)break;let u=c?.generate()||{};r(l,u,i)}if(e.live){c&&(e={...e,signalGenerator:c});let l=this.observe(t,r,e);return this.disconnectables(e.signal,f,l)}return this.disconnectables(e.signal,f,c)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Xt.call(o,"sync",()=>{});let c=new o.MutationObserver(m=>m.forEach(a=>{Ct.call(o,u,zt.call(o,a),i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c};if(e.staticSensitivity){let m=Gt.call(o,u);return this.disconnectables(e.signal,c,l,m)}return this.disconnectables(e.signal,c,l)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync";this.registry(s).size||Xt.call(o,s,a=>{this.forEachMatchingContext(s,a,Ct)});let f=new o.MutationObserver(a=>a.forEach(p=>{Array.isArray((p=zt.call(o,p)).event)||Ct.call(o,u,p,i)}));f.observe(i,{childList:!0,subtree:e.subtree&&!0});let c={disconnect(){m.delete(u),f.disconnect()}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c},m=this.registry(s);if(m.set(u,!!u.params.deferred),e.staticSensitivity){let a=Gt.call(o,u);return this.disconnectables(e.signal,c,l,a)}return this.disconnectables(e.signal,c,l)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function Gt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),c=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],l=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],u=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(_=>_[1]).concat(c(p)).concat(l(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(u(_+"")),[])))).length)return;let m=new Set,a=new Set;return m.push=p=>(a.delete(p),m.add(p)),a.push=p=>(m.delete(p),a.add(p)),n.$deliveryCache={entrants:m,exits:a},new F(r,t).observe(n.$attrs,p=>{let _=new Map,O=y=>(_.has(y)||_.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),_.get(y)),ft=new WeakMap,d=y=>(ft.has(y)||ft.set(y,f.some(v=>y.matches(v+""))),ft.get(y));for(let y of p)["entrants","exits"].forEach(v=>{o.generation&&v!==o.generation||n.$deliveryCache[v].has(y.target)||(v==="entrants"?!d(y.target):d(y.target))||(n.$deliveryCache[v].push(y.target),O(y.target)[v].push(y.target),O(y.target).event=y.event)});for(let[,y]of _){let v=s?.generate()||{};i(y,v,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function Ct(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,c={...t,entrants:[],exits:[]};if(o.eventDetails||delete c.event,["entrants","exits"].forEach(u=>{if(!(o.generation&&u!==o.generation)&&(e.length?c[u]=ye.call(this,e,o.subtree==="cross-roots",t[u],t.event!=="parse"):c[u]=[...t[u]],!!f))for(let m of c[u])f[u].push(m)}),!c.entrants.length&&!c.exits.length)return;let l=s?.generate()||{};i(c,l,r)}function ye(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(c=>s.kind==="xpath"?Dt(this,c,s+""):c.matches&&c.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((c,l)=>s.kind==="xpath"?[...c,...dt(this,l,s,e)]:l.querySelectorAll?[...c,...l.querySelectorAll(s+"")]:c,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>rt(this,f,s.content,t)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let f;return r.$$searchCache.has(s.content)?f=r.$$searchCache.get(s.content):(f=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,f)),o.concat(f)},[])}function zt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=E(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=E(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Xt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:c,HTMLTemplateElement:l,DocumentFragment:u}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let m=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let a=(d,y,v)=>{e.realdom.domInterceptionNoRecurse.set(d,y);let h=v();return e.realdom.domInterceptionNoRecurse.delete(d),h},p=(d,y)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let P=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:P,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let v=y();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),v},_={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"]},O={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 P=Object.getOwnPropertyDescriptor(r[h].prototype,d);!P||(Object.defineProperty(r[h].prototype,d,"value"in P?{...P,value:y}:{...P,set:v}),O[h][d]=P)});function y(...h){let P=Object.keys(O).find(q=>this instanceof r[q]&&d in O[q]),z=O[P],$=()=>z[d].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===d)return $();let k=[],x=[],D=this;["insertBefore"].includes(d)?x=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(x=[h[1]],["beforebegin","afterend"].includes(h[0])&&(D=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(k=[...this.childNodes],x=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(k=[this],x=d==="replaceWith"?[...h]:[],D=this.parentNode):["replaceChild"].includes(d)?(k=[h[1]],x=[h[0]]):["removeChild"].includes(d)?k=[...h]:(x=[...h],["before","after"].includes(d)&&(D=this.parentNode));let lt=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let q=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return z[d].value.call(this,...h);q=this.parentNode.nodeName}let R=i.createElement(q.includes("-")?"div":q);z.setHTMLUnsafe.value.call(R,x[0],d==="setHTMLUnsafe"?h[1]:{}),x=[...R.childNodes],d==="insertAdjacentHTML"?(lt="insertAdjacentElement",h[1]=new u,a(h[1],"append",()=>h[1].append(...R.childNodes))):(lt="replaceChildren",h=[...R.childNodes])}return p({target:D,entrants:x,exits:k,type:"interception",event:[this,d]},()=>z[lt].value.call(this,...h))}function v(h){let P=Object.keys(O).find(V=>this instanceof r[V]&&d in O[V]),z=O[P],$=()=>z[d].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===d)return $();let k=[],x=[],D=this;if(["outerHTML","outerText"].includes(d)?(k=[this],D=this.parentNode):this instanceof l?(D=this.content,k=[...this.content.childNodes]):k=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let V=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return $();V=this.parentNode.nodeName}let q=i.createElement(V.includes("-")?"div":V);if(a(q,d,()=>q[d]=h),x=this instanceof l?[...q.content.childNodes]:[...q.childNodes],this instanceof l&&this.hasAttribute("src")||this instanceof ShadowRoot){let R=B=>B.reduce((L,N)=>N instanceof HTMLScriptElement?L.concat(N):N instanceof l?L.concat(R([N.content])):(L=L.concat(R([...N.querySelectorAll?.("template")||[]].map(te=>te.content))),L.concat(...N.querySelectorAll?.("script")||[])),[]);for(let B of R(x)){if(this instanceof ShadowRoot){B.setAttribute("data-handling","manual");continue}let L=i.createElement("script");[...B.attributes].forEach(N=>L.setAttribute(N.name,N.value)),L.textContent=B.textContent,a(B,"replaceWith",()=>B.replaceWith(L))}}d==="outerHTML"?(h=new u,a(h,"append",()=>h.append(...x)),$=()=>a(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof l?$=()=>a(this.content,"replaceChildren",()=>this.content.replaceChildren(...x)):$=()=>a(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...x))}return p({target:D,entrants:x,exits:k,type:"interception",event:[this,d]},$)}}),m}function Qt(){be.call(this),_e.call(this),we.call(this)}function be(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function _e(){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 we(){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(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Jt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Qt.call(n),n.webqit.realdom.meta=(...r)=>xe.call(n,...r),n.webqit.realdom.ready=(...r)=>St.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new nt(r,n);if(e==="attr")return new F(r,n)};let t=new et(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function St(...n){let t="interactive",r;Q(n[0])?(t=n[0],b(n[1])&&(r=n[1])):b(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>St.call(this,"interactive",o)),complete:new Promise(o=>St.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[t];if(e[t].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[t].push(r)}function xe(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return vt(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:S(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function ht(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var W=(...n)=>C("oohtml",...n),M={};function Zt(n,t,r){let e=this,i=Jt.call(e);M.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[o]){e.webqit.oohtml.configs[o]={};let s=e.webqit.oohtml.configs[o];K(2,s,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(c=>{f==="api"&&typeof s[f][c]=="string"?s[f][c]=`${e.webqitConfig.prefix}${ht(s[f][c])}`:["attr","elements"].includes(f)&&s[f][c]?.startsWith("data-")===!1&&(s[f][c]=`${e.webqitConfig.prefix}-${s[f][c]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function Tt(n,t){return[...n].reduce(([r,e,i],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}function Kt(){let{window:n}=M,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let o=i.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let s=i.pop();if(!s?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],c=i.pop()||f[0];if(!f.includes(c))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:l,detail:u,targetContext:m,live:a,signal:p,diff:_,...O}=s;super(c,{...O,bubbles:O.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>l}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>u}),Object.defineProperty(this,"live",{get:()=>a}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>_}),Object.defineProperty(this,"options",{get:()=>O}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(i){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===i)return;Object.defineProperty(this,"_prevValue",{value:i,configurable:!0})}return this.callback(i)}}return t.DOMContextRequestEvent=r,r}var it=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=M;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var ot=class extends Error{};var st=class{static instance(t){return W(t).get("contexts::instance")||new this(t)}constructor(t){W(t).get("contexts::instance")?.dispose(),W(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]()}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(r=>typeof t[0]=="function"?t[0](r):r.constructor.kind===t[0]&&(!t[1]||r.detail===t[1]))}attach(t){if(!(t instanceof U))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new ot(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new it((r,e)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(r):t[t.length-1]=r);let i;(i=t.find(s=>typeof s=="object"&&s))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let o=new(Kt())(...t);this["#"].host.dispatchEvent(o)})}};var It=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=M;return t}get name(){return[M.window.Document,M.window.ShadowRoot].some(t=>this.host instanceof t)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(!(t.detail instanceof It)||t.target===this.host)return;let r=new Set;if(this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(this.subscriptions.delete(e),this.unsubscribed(e),r.add(e))}),r.size)return t.respondWith(r)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:r}=st.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return r?.forEach(e=>{this.subscriptions.add(e),this.subscribed(e),this.handle(e)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:e}=r;r.meta.answered=!1,e.dispatchEvent(r)}),this}},U=It;ct(U,"kind");var I=class extends U{static createRequest(t=null){let r=super.createRequest();if(t?.startsWith("@")){let[e,...i]=i.slice(1).split(".").map(o=>o.trim());r.targetContext=e,r.detail=i.join(".")}else r.detail=t;return r}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:r}}}=M;t.meta.controller=r.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],r.get,e=>{this.disposed||t.respondWith(e.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};ct(I,"kind","bindings");function Pt(n={}){let{config:t,window:r}=Zt.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=I,Ae.call(r,t),Ce.call(r,t)}function qt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!W(t).has("bindings")){let o=Object.create(null);W(t).set("bindings",o),e.observe(o,s=>{if(t instanceof r.Element){let f=gt(t.getAttribute(n.attr.bindingsreflection)||""),c=new Map(f);for(let l of s)l.detail?.publish!==!1&&(l.type==="delete"?f.delete(l.key):f.set(l.key,void 0));f.size&&f.size!==c.size?t.setAttribute(n.attr.bindingsreflection,`{ ${[...f.entries()].map(([l,u])=>u===void 0?l:`${l}: ${u}`).join(", ")} }`):f.size||t.toggleAttribute(n.attr.bindingsreflection,!1)}else{let f=t[i.api.contexts];for(let c of s)if(c.type==="delete"){let l=f.find(I.kind,c.key);l&&f.detach(l)}else f.find(I.kind,c.key)||f.attach(new I(c.key))}})}return W(t).get("bindings")}function Ae(n){let t=this,{webqit:{Observer:r}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let i=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.bind in e)throw new Error(`The ${i} prototype already has a "${n.api.bind}" API!`);if(n.api.bindings in e)throw new Error(`The ${i} prototype already has a "${n.api.bindings}" API!`);Object.defineProperty(e,n.api.bind,{value:function(o,s={}){return Ee.call(t,n,this,o,s)}}),Object.defineProperty(e,n.api.bindings,{get:function(){return r.proxy(qt.call(t,n,this))}})})}function Ee(n,t,r,{merge:e,diff:i,publish:o,namespace:s}={}){let f=this,{webqit:{Observer:c}}=f,l=qt.call(this,n,t),u={diff:i,namespace:s,detail:{publish:o}},m=e?[]:c.ownKeys(l,u).filter(a=>!(a in r));return c.batch(l,()=>(m.length&&c.deleteProperties(l,m,u),c.set(l,r,u)),u)}function Ce(n){let t=this,{webqit:{realdom:r,Observer:e,oohtml:{configs:i}}}=t,o=(f,c)=>{let l=f[i.CONTEXT_API.api.contexts];l.find(I.kind,c)||l.attach(new I(c))},s=(f,c)=>{let l,u=f[i.CONTEXT_API.api.contexts];for(;l=u.find(I.kind,c);)u.detach(l)};r.realtime(t.document).query(`[${t.CSS.escape(n.attr.bindingsreflection)}]`,f=>{f.exits.forEach(c=>s(c)),f.entrants.forEach(c=>{let l=gt(c.getAttribute(n.attr.bindingsreflection)||""),u=[...l.entries()].filter(([m,a])=>a!==void 0);u.length&&c[n.api.bind](Object.fromEntries(u),{merge:!0,publish:!1});for(let[m]of l)o(c,m)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),r.realtime(t.document,"attr").observe(n.attr.bindingsreflection,f=>{let c=qt.call(t,n,f.target),l=gt(f.value||""),u=gt(f.oldValue||"");for(let m of new Set([...l.keys(),...u.keys()]))u.has(m)?l.has(m)?l.get(m)!==u.get(m)&&e.set(c,m,l.get(m),{detail:{publish:!1}}):(u.get(m)!==void 0&&e.deleteProperty(c,m,{detail:{publish:!1}}),s(f.target,m)):(l.get(m)!==void 0&&e.set(c,m,l.get(m),{detail:{publish:!1}}),o(f.target,m))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var gt=n=>(n=n.trim(),new Map(Tt(n.slice(1,-1),",").filter(t=>t.trim()).map(t=>Tt(t,":").map(r=>r.trim()))));Pt.call(window);})();
1
+ (()=>{var Kt=Object.defineProperty;var te=(n,t,r)=>t in n?Kt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var ft=(n,t,r)=>(te(n,typeof t!="symbol"?t+"":t,r),r);function b(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function z(n){return typeof n=="function"}function Q(n){return n===null||n===""}function H(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||z(n)}function gt(n){return Q(n)||H(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function _(n){return z(n)||n&&{}.toString.call(n)==="[object function]"}function J(n){return n instanceof Number||typeof n=="number"}function S(n){return J(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function X(n){return n instanceof String||typeof n=="string"&&n!==null}function yt(n){return!X(n)&&!H(n.length)}function lt(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function _t(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function wt(n,t){var r=[];return _t(n,t).forEach(e=>{lt(r,...Object.getOwnPropertyNames(e))}),r}function j(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((S(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((f,c)=>{!A(f)&&!_(f)||(r?wt(f):Object.keys(f)).forEach(l=>{if(!!t(l,s,f,c)){var u=s[l],m=f[l];if((g(u)&&g(m)||b(u)&&b(m))&&(o===!0||o>0))s[l]=g(u)&&g(m)?[]:{},j([S(o)?o-1:o,s[l],u,m],t,r,e,i);else if(g(s)&&g(f))e?s[l]=m:s.push(m);else try{i?Object.defineProperty(s,l,Object.getOwnPropertyDescriptor(f,l)):s[l]=f[l]}catch{}}})}),s}function Y(...n){return j(n,(t,r,e)=>!0,!1,!1,!1)}function C(n,...t){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 ct,Object.defineProperty(n,Symbol.for("wq"),{value:r,enumerable:!1,configurable:!1,writable:!1})),!t.length)return r;let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new ct,i.set(e,r));return r}var ct=class extends Map{};function E(n,t=!0){return g(n)?n:!t&&b(n)?[n]:n!==!1&&n!==0&&gt(n)?[]:yt(n)?Array.prototype.slice.call(n):b(n)?Object.values(n):[n]}function Z(n,t,r={},e={}){t=E(t).slice();for(var i=n;!H(i)&&!Q(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):A(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function xt(n,t,r,e={},i={}){let o=(u,m,a)=>i.set?i.set(u,m,a):(S(t[f])&&g(u)?u.push(a):u[m]=a,!0);t=E(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!A(s)&&!_(s))return!1;var c=Z(s,t[f],i);if(!A(c)){if(i.buildTree===!1)return!1;c=_(i.buildTree)?i.buildTree(f):S(t[f+1])?[]:{};var l=o(s,t[f],c);if(!l)return!1}s=c}else return o(s,t[f],r)}var K=class{constructor(t,r=!1){Object.defineProperty(this,"window",{value:t}),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(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),c=l=>{l!==void 0&&this.cycle(t,r,l)};f instanceof Promise?f.then(c):c(f)})};i instanceof Promise?i.then(o):o(i)})}};function Nt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function at(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",e?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function Ht(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function tt(n,t,r,e=!1,i=null){let o=i?.get(t)?.get(r);if(typeof o<"u")return o;let s=l=>(i?.has(t)||i?.set(t,new WeakMap),i?.get(t)?.set(r,l),l),f=t.getRootNode(),c=r.getRootNode();return f===c?s(t.contains(r)):e&&c instanceof n.ShadowRoot?s(tt(n,t,c.host,e,i)):s(!1)}function $t(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,e,i]),[null,0,[""]])[2].reverse()}var q=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Nt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=$t(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var B=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(_(t[0])?t=[[],...t]:b(t[0])&&!(t[0]instanceof q)&&t.length===1?t=[[],void 0,t[0]]:b(t[1])&&t.length===2?t=[E(t[0],!1),void 0,t[1]]:t[0]=E(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof q)&&!(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 t[0]=t[0].map(r=>r instanceof q?r:new q(r)),t}registry(...t){return C(this.window,"realdom",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=new Set,s=new WeakMap;for(let[f,c]of this.registry(t)){let l=[].concat(r).filter(m=>tt(i,f.context,m.target,f.params.subtree==="cross-roots",s));if(!l.length)continue;let u=[f,Array.isArray(r)?l:l[0]];c?o.add(u):e.call(i,...u)}for(let f of o)e.call(i,...f);o.clear()}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&_(i.disconnect)&&i.disconnect()||_(i)&&i()||b(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var F=class extends B{type="attr";constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof q;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Wt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of s){let l=f?f.generate():{};r(c,l,o)}else{let c=f?.generate()||{};r(s,c,o)}if(e.live){f&&(e={...e,signalGenerator:f});let c=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,c)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof q;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Rt.call(s,"intercept",()=>{});let c=new s.MutationObserver(a=>{a=Ft(a).map(p=>Ut.call(s,p)),Dt.call(s,m,a,o)}),l={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(l.attributeFilter=t.map(a=>a+"")),c.observe(o,l);let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:c};return this.disconnectables(e.signal,c,u)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof q;[t,r,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync";this.registry(f).size||Rt.call(s,f,a=>{this.forEachMatchingContext(f,a,Dt)});let c={disconnect(){m.delete(u)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:c},m=this.registry(f);return m.set(u,!!u.params.deferred),this.disconnectables(e.signal,c,l)}};function Ft(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||C(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Dt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:c}=n;if(o.subtree||(t=t.filter(a=>a.target===r)),!t.length)return;let l=e.map(a=>a+"");if(o.atomic&&!s.size?t=Wt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(a=>l.includes(a.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(a=>{let p;return o.eventDetails||({event:p,...a}=a),!o.oldValue&&"oldValue"in a&&({oldValue:p,...a}=a),!o.newValue&&"value"in a?{value:p,...a}=a:o.newValue&&typeof a.value>"u"&&(a={...a,value:mt(a.target,a.name,()=>a.target.getAttribute(a.name))}),a})),o.atomic&&(t.forEach(a=>s.set(a.name,a)),t=Array.from(s.entries()).map(([,a])=>a));let u=f?t[0]:t,m=c?c.generate():{};i(u,m,r)}function mt(n,t,r){let e=C(n,"realdom","internalAttrInteractions").get(t);C(n,"realdom","internalAttrInteractions").set(t,!0);let i=r();return C(n,"realdom","internalAttrInteractions").set(t,e),i}function Wt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:mt(n,o,()=>n.getAttribute(o)),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:mt(n,o.nodeName,()=>o.nodeValue),...e})}function Ut({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function Rt(n,t){let r=this,{webqit:e,document:i,Element:o}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(u,m)=>{e.realdom.attrInterceptionRecords.has(u.target)||e.realdom.attrInterceptionRecords.set(u.target,{});let a=e.realdom.attrInterceptionRecords.get(u.target);if(a[u.name]=a[u.name]||[],a[u.name].unshift(u.event),C(u.target,"realdom","internalAttrInteractions").get(u.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(w=>w([u]));let p=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(w=>w([u])),p};new r.MutationObserver(u=>{u=u.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),u=Ft(u).map(m=>Ut.call(r,m)),u.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(u)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(u)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let l=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(u=>{l[u]=o.prototype[u],o.prototype[u]=function(...m){let a,p=mt(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(u)&&(a=m[1]),u==="toggleAttribute"&&a===void 0&&(a=p===null);let w={target:this,name:m[0],value:a,oldValue:p,type:"interception",event:[this,u]};return f(w,()=>l[u].call(this,...m))}}),s}var et=class extends B{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new F(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=l=>(o.has(l)||o.set(l,{target:l,entrants:[],exits:[],type:"query",event:null}),o.get(l));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(l=>s(i).entrants.push(l));else if(t.every(l=>l.type==="selector")){let[l,u]=t.reduce(([a,p],w)=>w.kind==="xpath"?[a,p.concat(w)]:[a.concat(w),p],[[],[]]),m=[];e.subtree?(l.length&&m.push(...i.querySelectorAll(l.join(","))),u.length&&m.push(...at(this.window,i,u))):(l.length&&m.push(...[...i.children].filter(a=>a.matches(l))),u.length&&m.push(...at(this.window,i,u,!1))),m.forEach(a=>s(a.parentNode||i).entrants.push(a))}}if(!r)return o;let f={disconnected:!1},c=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,l]of o){if(f.disconnected)break;let u=c?.generate()||{};r(l,u,i)}if(e.live){c&&(e={...e,signalGenerator:c});let l=this.observe(t,r,e);return this.disconnectables(e.signal,f,l)}return this.disconnectables(e.signal,f,c)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Gt.call(o,"sync",()=>{});let c=new o.MutationObserver(m=>m.forEach(a=>{At.call(o,u,Bt.call(o,a),i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c};if(e.staticSensitivity){let m=Vt.call(o,u);return this.disconnectables(e.signal,c,l,m)}return this.disconnectables(e.signal,c,l)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync";this.registry(s).size||Gt.call(o,s,a=>{this.forEachMatchingContext(s,a,At)});let f=new o.MutationObserver(a=>a.forEach(p=>{Array.isArray((p=Bt.call(o,p)).event)||At.call(o,u,p,i)}));f.observe(i,{childList:!0,subtree:e.subtree&&!0});let c={disconnect(){m.delete(u),f.disconnect()}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c},m=this.registry(s);if(m.set(u,!!u.params.deferred),e.staticSensitivity){let a=Vt.call(o,u);return this.disconnectables(e.signal,c,l,a)}return this.disconnectables(e.signal,c,l)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function Vt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),c=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],l=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],u=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(w=>w[1]).concat(c(p)).concat(l(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,w)=>p.concat(u(w+"")),[])))).length)return;let m=new Set,a=new Set;return m.push=p=>(a.delete(p),m.add(p)),a.push=p=>(m.delete(p),a.add(p)),n.$deliveryCache={entrants:m,exits:a},new F(r,t).observe(n.$attrs,p=>{let w=new Map,O=y=>(w.has(y)||w.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),w.get(y)),ot=new WeakMap,d=y=>(ot.has(y)||ot.set(y,f.some(v=>y.matches(v+""))),ot.get(y));for(let y of p)["entrants","exits"].forEach(v=>{o.generation&&v!==o.generation||n.$deliveryCache[v].has(y.target)||(v==="entrants"?!d(y.target):d(y.target))||(n.$deliveryCache[v].push(y.target),O(y.target)[v].push(y.target),O(y.target).event=y.event)});for(let[,y]of w){let v=s?.generate()||{};i(y,v,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function At(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,c={...t,entrants:[],exits:[]};if(o.eventDetails||delete c.event,["entrants","exits"].forEach(u=>{if(!(o.generation&&u!==o.generation)&&(e.length?c[u]=ge.call(this,e,o.subtree==="cross-roots",t[u],t.event!=="parse"):c[u]=[...t[u]],!!f))for(let m of c[u])f[u].push(m)}),!c.entrants.length&&!c.exits.length)return;let l=s?.generate()||{};i(c,l,r)}function ge(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(c=>s.kind==="xpath"?Ht(this,c,s+""):c.matches&&c.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((c,l)=>s.kind==="xpath"?[...c,...at(this,l,s,e)]:l.querySelectorAll?[...c,...l.querySelectorAll(s+"")]:c,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>tt(this,f,s.content,t)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let f;return r.$$searchCache.has(s.content)?f=r.$$searchCache.get(s.content):(f=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,f)),o.concat(f)},[])}function Bt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=E(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=E(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Gt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:c,HTMLTemplateElement:l,DocumentFragment:u}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let m=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let a=(d,y,v)=>{e.realdom.domInterceptionNoRecurse.set(d,y);let h=v();return e.realdom.domInterceptionNoRecurse.delete(d),h},p=(d,y)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let I=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:I,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let v=y();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),v},w={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"]},O={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(w).reduce((d,y)=>d.concat(y),[])).forEach(d=>{Object.keys(w).forEach(h=>{if(!w[h].includes(d))return;let I=Object.getOwnPropertyDescriptor(r[h].prototype,d);!I||(Object.defineProperty(r[h].prototype,d,"value"in I?{...I,value:y}:{...I,set:v}),O[h][d]=I)});function y(...h){let I=Object.keys(O).find(P=>this instanceof r[P]&&d in O[P]),G=O[I],$=()=>G[d].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===d)return $();let k=[],x=[],D=this;["insertBefore"].includes(d)?x=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(x=[h[1]],["beforebegin","afterend"].includes(h[0])&&(D=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(k=[...this.childNodes],x=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(k=[this],x=d==="replaceWith"?[...h]:[],D=this.parentNode):["replaceChild"].includes(d)?(k=[h[1]],x=[h[0]]):["removeChild"].includes(d)?k=[...h]:(x=[...h],["before","after"].includes(d)&&(D=this.parentNode));let st=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let P=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return G[d].value.call(this,...h);P=this.parentNode.nodeName}let R=i.createElement(P.includes("-")?"div":P);G.setHTMLUnsafe.value.call(R,x[0],d==="setHTMLUnsafe"?h[1]:{}),x=[...R.childNodes],d==="insertAdjacentHTML"?(st="insertAdjacentElement",h[1]=new u,a(h[1],"append",()=>h[1].append(...R.childNodes))):(st="replaceChildren",h=[...R.childNodes])}return p({target:D,entrants:x,exits:k,type:"interception",event:[this,d]},()=>G[st].value.call(this,...h))}function v(h){let I=Object.keys(O).find(U=>this instanceof r[U]&&d in O[U]),G=O[I],$=()=>G[d].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===d)return $();let k=[],x=[],D=this;if(["outerHTML","outerText"].includes(d)?(k=[this],D=this.parentNode):this instanceof l?(D=this.content,k=[...this.content.childNodes]):k=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let U=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return $();U=this.parentNode.nodeName}let P=i.createElement(U.includes("-")?"div":U);if(a(P,d,()=>P[d]=h),x=this instanceof l?[...P.content.childNodes]:[...P.childNodes],this instanceof l&&this.hasAttribute("src")||this instanceof ShadowRoot){let R=V=>V.reduce((L,N)=>N instanceof HTMLScriptElement?L.concat(N):N instanceof l?L.concat(R([N.content])):(L=L.concat(R([...N.querySelectorAll?.("template")||[]].map(Zt=>Zt.content))),L.concat(...N.querySelectorAll?.("script")||[])),[]);for(let V of R(x)){if(this instanceof ShadowRoot){V.setAttribute("data-handling","manual");continue}let L=i.createElement("script");[...V.attributes].forEach(N=>L.setAttribute(N.name,N.value)),L.textContent=V.textContent,a(V,"replaceWith",()=>V.replaceWith(L))}}d==="outerHTML"?(h=new u,a(h,"append",()=>h.append(...x)),$=()=>a(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof l?$=()=>a(this.content,"replaceChildren",()=>this.content.replaceChildren(...x)):$=()=>a(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...x))}return p({target:D,entrants:x,exits:k,type:"interception",event:[this,d]},$)}}),m}function zt(){ye.call(this),_e.call(this),we.call(this)}function ye(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function _e(){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 we(){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(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Xt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},zt.call(n),n.webqit.realdom.meta=(...r)=>be.call(n,...r),n.webqit.realdom.ready=(...r)=>Et.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new et(r,n);if(e==="attr")return new F(r,n)};let t=new K(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function Et(...n){let t="interactive",r;X(n[0])?(t=n[0],_(n[1])&&(r=n[1])):_(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>Et.call(this,"interactive",o)),complete:new Promise(o=>Et.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[t];if(e[t].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[t].push(r)}function be(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return xt(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:S(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function dt(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var pt=(n,...t)=>C(n,"oohtml",...t),M={};function Jt(n,t,r){let e=this,i=Xt.call(e);M.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[o]){e.webqit.oohtml.configs[o]={};let s=e.webqit.oohtml.configs[o];Y(2,s,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(c=>{f==="api"&&typeof s[f][c]=="string"?s[f][c]=`${e.webqitConfig.prefix}${dt(s[f][c])}`:["attr","elements"].includes(f)&&s[f][c]?.startsWith("data-")===!1&&(s[f][c]=`${e.webqitConfig.prefix}-${s[f][c]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function St(n,t){return[...n].reduce(([r,e,i],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}function Yt(){let{window:n}=M,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let o=i.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let s=i.pop();if(!s?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],c=i.pop()||f[0];if(!f.includes(c))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:l,detail:u,targetContext:m,live:a,signal:p,diff:w,...O}=s;super(c,{...O,bubbles:O.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>l}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>u}),Object.defineProperty(this,"live",{get:()=>a}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>w}),Object.defineProperty(this,"options",{get:()=>O}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(i){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===i)return;Object.defineProperty(this,"_prevValue",{value:i,configurable:!0})}return this.callback(i)}}return t.DOMContextRequestEvent=r,r}var rt=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=M;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var nt=class extends Error{};var it=class{static instance(t){return _wq(t).get("contexts::instance")||new this(t)}constructor(t){_wq(t).get("contexts::instance")?.dispose(),_wq(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]()}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(r=>typeof t[0]=="function"?t[0](r):r.constructor.kind===t[0]&&(!t[1]||r.detail===t[1]))}attach(t){if(!(t instanceof W))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new nt(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new rt((r,e)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(r):t[t.length-1]=r);let i;(i=t.find(s=>typeof s=="object"&&s))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let o=new(Yt())(...t);this["#"].host.dispatchEvent(o)})}};var Ct=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=M;return t}get name(){return[M.window.Document,M.window.ShadowRoot].some(t=>this.host instanceof t)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(!(t.detail instanceof Ct)||t.target===this.host)return;let r=new Set;if(this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(this.subscriptions.delete(e),this.unsubscribed(e),r.add(e))}),r.size)return t.respondWith(r)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:r}=it.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return r?.forEach(e=>{this.subscriptions.add(e),this.subscribed(e),this.handle(e)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:e}=r;r.meta.answered=!1,e.dispatchEvent(r)}),this}},W=Ct;ft(W,"kind");var T=class extends W{static createRequest(t=null){let r=super.createRequest();if(t?.startsWith("@")){let[e,...i]=i.slice(1).split(".").map(o=>o.trim());r.targetContext=e,r.detail=i.join(".")}else r.detail=t;return r}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:r}}}=M;t.meta.controller=r.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],r.get,e=>{this.disposed||t.respondWith(e.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};ft(T,"kind","bindings");function qt(n={}){let{config:t,window:r}=Jt.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=T,ve.call(r,t),Ee.call(r,t)}function Tt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!pt(t).has("bindings")){let o=Object.create(null);pt(t).set("bindings",o),e.observe(o,s=>{if(t instanceof r.Element){let f=ht(t.getAttribute(n.attr.bindingsreflection)||""),c=new Map(f);for(let l of s)l.detail?.publish!==!1&&(l.type==="delete"?f.delete(l.key):f.set(l.key,void 0));f.size&&f.size!==c.size?t.setAttribute(n.attr.bindingsreflection,`{ ${[...f.entries()].map(([l,u])=>u===void 0?l:`${l}: ${u}`).join(", ")} }`):f.size||t.toggleAttribute(n.attr.bindingsreflection,!1)}else{let f=t[i.api.contexts];for(let c of s)if(c.type==="delete"){let l=f.find(T.kind,c.key);l&&f.detach(l)}else f.find(T.kind,c.key)||f.attach(new T(c.key))}})}return pt(t).get("bindings")}function ve(n){let t=this,{webqit:{Observer:r}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let i=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.bind in e)throw new Error(`The ${i} prototype already has a "${n.api.bind}" API!`);if(n.api.bindings in e)throw new Error(`The ${i} prototype already has a "${n.api.bindings}" API!`);Object.defineProperty(e,n.api.bind,{value:function(o,s={}){return Ae.call(t,n,this,o,s)}}),Object.defineProperty(e,n.api.bindings,{get:function(){return r.proxy(Tt.call(t,n,this))}})})}function Ae(n,t,r,{merge:e,diff:i,publish:o,namespace:s}={}){let f=this,{webqit:{Observer:c}}=f,l=Tt.call(this,n,t),u={diff:i,namespace:s,detail:{publish:o}},m=e?[]:c.ownKeys(l,u).filter(a=>!(a in r));return c.batch(l,()=>(m.length&&c.deleteProperties(l,m,u),c.set(l,r,u)),u)}function Ee(n){let t=this,{webqit:{realdom:r,Observer:e,oohtml:{configs:i}}}=t,o=(f,c)=>{let l=f[i.CONTEXT_API.api.contexts];l.find(T.kind,c)||l.attach(new T(c))},s=(f,c)=>{let l,u=f[i.CONTEXT_API.api.contexts];for(;l=u.find(T.kind,c);)u.detach(l)};r.realtime(t.document).query(`[${t.CSS.escape(n.attr.bindingsreflection)}]`,f=>{f.exits.forEach(c=>s(c)),f.entrants.forEach(c=>{let l=ht(c.getAttribute(n.attr.bindingsreflection)||""),u=[...l.entries()].filter(([m,a])=>a!==void 0);u.length&&c[n.api.bind](Object.fromEntries(u),{merge:!0,publish:!1});for(let[m]of l)o(c,m)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),r.realtime(t.document,"attr").observe(n.attr.bindingsreflection,f=>{let c=Tt.call(t,n,f.target),l=ht(f.value||""),u=ht(f.oldValue||"");for(let m of new Set([...l.keys(),...u.keys()]))u.has(m)?l.has(m)?l.get(m)!==u.get(m)&&e.set(c,m,l.get(m),{detail:{publish:!1}}):(u.get(m)!==void 0&&e.deleteProperty(c,m,{detail:{publish:!1}}),s(f.target,m)):(l.get(m)!==void 0&&e.set(c,m,l.get(m),{detail:{publish:!1}}),o(f.target,m))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var ht=n=>(n=n.trim(),new Map(St(n.slice(1,-1),",").filter(t=>t.trim()).map(t=>St(t,":").map(r=>r.trim()))));qt.call(window);})();
2
2
  //# sourceMappingURL=bindings-api.js.map