@webqit/oohtml 4.4.0 → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- (()=>{var Xt=Object.defineProperty;var Qt=(n,t,r)=>t in n?Xt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var Et=(n,t,r)=>(Qt(n,typeof t!="symbol"?t+"":t,r),r);function x(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function Q(n){return typeof n=="function"}function Y(n){return n===null||n===""}function k(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||Q(n)}function dt(n){return Y(n)||k(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function _(n){return Q(n)||n&&{}.toString.call(n)==="[object function]"}function Z(n){return n instanceof Number||typeof n=="number"}function C(n){return Z(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function J(n){return n instanceof String||typeof n=="string"&&n!==null}function pt(n){return!J(n)&&!k(n.length)}function st(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function ht(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 gt(n,t){var r=[];return ht(n,t).forEach(e=>{st(r,...Object.getOwnPropertyNames(e))}),r}function P(n,t,r=!1,e=!1,i=!1){var s=0,o=n.shift();if((C(o)||o===!0||o===!1)&&(s=o,o=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,a)=>{!A(f)&&!_(f)||(r?gt(f):Object.keys(f)).forEach(u=>{if(!!t(u,o,f,a)){var l=o[u],m=f[u];if((g(l)&&g(m)||x(l)&&x(m))&&(s===!0||s>0))o[u]=g(l)&&g(m)?[]:{},P([C(s)?s-1:s,o[u],l,m],t,r,e,i);else if(g(o)&&g(f))e?o[u]=m:o.push(m);else try{i?Object.defineProperty(o,u,Object.getOwnPropertyDescriptor(f,u)):o[u]=f[u]}catch{}}})}),o}function K(...n){return P(n,(t,r,e)=>!0,!1,!1,!1)}function I(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 ft,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 ft,i.set(e,r));return r}var ft=class extends Map{};function E(n,t=!0){return g(n)?n:!t&&x(n)?[n]:n!==!1&&n!==0&&dt(n)?[]:pt(n)?Array.prototype.slice.call(n):x(n)?Object.values(n):[n]}function tt(n,t,r={},e={}){t=E(t).slice();for(var i=n;!k(i)&&!Y(i)&&t.length;){var s=t.shift();if(!(r.get?r.get(i,s):A(i)?s in i:i[s])){e.exists=!1;return}i=r.get?r.get(i,s):i[s]}return e.exists=!0,i}function _t(n,t,r,e={},i={}){let s=(l,m,c)=>i.set?i.set(l,m,c):(C(t[f])&&g(l)?l.push(c):l[m]=c,!0);t=E(t);for(var o=n,f=0;f<t.length;f++)if(f<t.length-1){if(!o||!A(o)&&!_(o))return!1;var a=tt(o,t[f],i);if(!A(a)){if(i.buildTree===!1)return!1;a=_(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var u=s(o,t[f],a);if(!u)return!1}o=a}else return s(o,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),s=o=>{o!==void 0&&this.onwrite(()=>{let f=r(o,e),a=u=>{u!==void 0&&this.cycle(t,r,u)};f instanceof Promise?f.then(a):a(f)})};i instanceof Promise?i.then(s):s(i)})}};function Pt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function ct(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(o=>(o+"").replace("(",e?"(.//":"(./")).join("|");let i=[],s;try{let o=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;s=o.iterateNext();)i.push(s)}catch{}return i}function Lt(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 s=i?.get(t)?.get(r);if(typeof s<"u")return s;let o=u=>(i?.has(t)||i?.set(t,new WeakMap),i?.get(t)?.set(r,u),u),f=t.getRootNode(),a=r.getRootNode();return f===a?o(t.contains(r)):e&&a instanceof n.ShadowRoot?o(rt(n,t,a.host,e,i)):o(!1)}function jt(n,t="|"){return[...n].reduce(([r,e,i,s],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()}var S=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Pt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=jt(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(_(t[0])?t=[[],...t]:x(t[0])&&!(t[0]instanceof S)&&t.length===1?t=[[],void 0,t[0]]:x(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 S)&&!(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 S?r:new S(r)),t}registry(...t){return I(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,s=new Set,o=new WeakMap;for(let[f,a]of this.registry(t)){let u=[].concat(r).filter(m=>rt(i,f.context,m.target,f.params.subtree==="cross-roots",o));if(!u.length)continue;let l=[f,Array.isArray(r)?u:u[0]];a?s.add(l):e.call(i,...l)}for(let f of s)e.call(i,...f);s.clear()}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&_(i.disconnect)&&i.disconnect()||_(i)&&i()||x(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var $=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 S;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:s}=this,o=Dt(s,t);if(!r)return o;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let a of o){let u=f?f.generate():{};r(a,u,s)}else{let a=f?.generate()||{};r(o,a,s)}if(e.live){f&&(e={...e,signalGenerator:f});let a=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,a)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof S;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:s,window:o,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Ht.call(o,"intercept",()=>{});let a=new o.MutationObserver(c=>{c=Nt(c).map(p=>Rt.call(o,p)),kt.call(o,m,c,s)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(u.attributeFilter=t.map(c=>c+"")),a.observe(s,u);let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:a};return this.disconnectables(e.signal,a,l)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof S;[t,r,e={}]=this.resolveArgs(arguments);let{context:s,window:o}=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||Ht.call(o,f,c=>{this.forEachMatchingContext(f,c,kt)});let a={disconnect(){m.delete(l)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:a},m=this.registry(f);return m.set(l,!!l.params.deferred),this.disconnectables(e.signal,a,u)}};function Nt(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||I(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function kt(n,t){let{context:r,spec:e,callback:i,params:s,atomics:o,originalFilterIsString:f,signalGenerator:a}=n;if(s.subtree||(t=t.filter(c=>c.target===r)),!t.length)return;let u=e.map(c=>c+"");if(s.atomic&&!o.size?t=Dt(r,e,t):s.timing!=="async"&&e.length&&(t=t.filter(c=>u.includes(c.name))),!t.length)return;s.newValue===null&&s.oldValue===null&&s.eventDetails||(t=t.map(c=>{let p;return s.eventDetails||({event:p,...c}=c),!s.oldValue&&"oldValue"in c&&({oldValue:p,...c}=c),!s.newValue&&"value"in c?{value:p,...c}=c:s.newValue&&typeof c.value>"u"&&(c={...c,value:ut(c.target,c.name,()=>c.target.getAttribute(c.name))}),c})),s.atomic&&(t.forEach(c=>o.set(c.name,c)),t=Array.from(o.entries()).map(([,c])=>c));let l=f?t[0]:t,m=a?a.generate():{};i(l,m,r)}function ut(n,t,r){let e=I(n,"realdom","internalAttrInteractions").get(t);I(n,"realdom","internalAttrInteractions").set(t,!0);let i=r();return I(n,"realdom","internalAttrInteractions").set(t,e),i}function Dt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(s=>(s=s+"",r.find(o=>o.name===s)||{target:n,name:s,value:ut(n,s,()=>n.getAttribute(s)),...e})):Array.from(n.attributes).map(s=>r.find(o=>o.name===s.nodeName)||{target:n,name:s.nodeName,value:ut(n,s.nodeName,()=>s.nodeValue),...e})}function Rt({target:n,attributeName:t,value:r,oldValue:e}){let o=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:o}}function Ht(n,t){let r=this,{webqit:e,document:i,Element:s}=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 o=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return o;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(l,m)=>{e.realdom.attrInterceptionRecords.has(l.target)||e.realdom.attrInterceptionRecords.set(l.target,{});let c=e.realdom.attrInterceptionRecords.get(l.target);if(c[l.name]=c[l.name]||[],c[l.name].unshift(l.event),I(l.target,"realdom","internalAttrInteractions").get(l.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(w=>w([l]));let p=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(w=>w([l])),p};new r.MutationObserver(l=>{l=l.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),l=Nt(l).map(m=>Rt.call(r,m)),l.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(l)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(l)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{u[l]=s.prototype[l],s.prototype[l]=function(...m){let c,p=ut(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(l)&&(c=m[1]),l==="toggleAttribute"&&c===void 0&&(c=p===null);let w={target:this,name:m[0],value:c,oldValue:p,type:"interception",event:[this,l]};return f(w,()=>u[l].call(this,...m))}}),o}var nt=class extends G{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:s}=this;return new $(i,s).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,s=new Map,o=u=>(s.has(u)||s.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),s.get(u));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(u=>o(i).entrants.push(u));else if(t.every(u=>u.type==="selector")){let[u,l]=t.reduce(([c,p],w)=>w.kind==="xpath"?[c,p.concat(w)]:[c.concat(w),p],[[],[]]),m=[];e.subtree?(u.length&&m.push(...i.querySelectorAll(u.join(","))),l.length&&m.push(...ct(this.window,i,l))):(u.length&&m.push(...[...i.children].filter(c=>c.matches(u))),l.length&&m.push(...ct(this.window,i,l,!1))),m.forEach(c=>o(c.parentNode||i).entrants.push(c))}}if(!r)return s;let f={disconnected:!1},a=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of s){if(f.disconnected)break;let l=a?.generate()||{};r(u,l,i)}if(e.live){a&&(e={...e,signalGenerator:a});let u=this.observe(t,r,e);return this.disconnectables(e.signal,f,u)}return this.disconnectables(e.signal,f,a)}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:s,webqit:o,document:f}=this;e.eventDetails&&(o.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||o.realdom.domInterceptionRecordsAlwaysOn)&&!o.realdom.domInterceptionHooks?.intercepting&&Wt.call(s,"sync",()=>{});let a=new s.MutationObserver(m=>m.forEach(c=>{bt.call(s,l,Ft.call(s,c),i)}));a.observe(i,{childList:!0,subtree:e.subtree&&!0});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:a};if(e.staticSensitivity){let m=$t.call(s,l);return this.disconnectables(e.signal,a,u,m)}return this.disconnectables(e.signal,a,u)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let o=e.timing==="intercept"?"intercept":"sync";this.registry(o).size||Wt.call(s,o,c=>{this.forEachMatchingContext(o,c,bt)});let f=new s.MutationObserver(c=>c.forEach(p=>{Array.isArray((p=Ft.call(s,p)).event)||bt.call(s,l,p,i)}));f.observe(i,{childList:!0,subtree:e.subtree&&!0});let a={disconnect(){m.delete(l),f.disconnect()}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:a},m=this.registry(o);if(m.set(l,!!l.params.deferred),e.staticSensitivity){let c=$t.call(s,l);return this.disconnectables(e.signal,a,u,c)}return this.disconnectables(e.signal,a,u)}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 $t(n){let t=this,{context:r,spec:e,callback:i,params:s,signalGenerator:o}=n,f=e.filter(p=>p.kind==="css"),a=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],u=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],l=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(w=>w[1]).concat(a(p)).concat(u(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,w)=>p.concat(l(w+"")),[])))).length)return;let m=new Set,c=new Set;return m.push=p=>(c.delete(p),m.add(p)),c.push=p=>(m.delete(p),c.add(p)),n.$deliveryCache={entrants:m,exits:c},new $(r,t).observe(n.$attrs,p=>{let w=new Map,v=y=>(w.has(y)||w.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),w.get(y)),it=new WeakMap,d=y=>(it.has(y)||it.set(y,f.some(O=>y.matches(O+""))),it.get(y));for(let y of p)["entrants","exits"].forEach(O=>{s.generation&&O!==s.generation||n.$deliveryCache[O].has(y.target)||(O==="entrants"?!d(y.target):d(y.target))||(n.$deliveryCache[O].push(y.target),v(y.target)[O].push(y.target),v(y.target).event=y.event)});for(let[,y]of w){let O=o?.generate()||{};i(y,O,r)}},{subtree:s.subtree,timing:s.timing,eventDetails:s.eventDetails})}function bt(n,t){let{context:r,spec:e,callback:i,params:s,signalGenerator:o,$deliveryCache:f}=n,a={...t,entrants:[],exits:[]};if(s.eventDetails||delete a.event,["entrants","exits"].forEach(l=>{if(!(s.generation&&l!==s.generation)&&(e.length?a[l]=ae.call(this,e,s.subtree==="cross-roots",t[l],t.event!=="parse"):a[l]=[...t[l]],!!f))for(let m of a[l])f[l].push(m)}),!a.entrants.length&&!a.exits.length)return;let u=o?.generate()||{};i(a,u,r)}function ae(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(s,o)=>{if(o.type==="selector"){let f=o.isXpathAttr?[]:s.filter(a=>o.kind==="xpath"?Lt(this,a,o+""):a.matches&&a.matches(o+""));if((e||o.isXpathAttr)&&(f=s.reduce((a,u)=>o.kind==="xpath"?[...a,...ct(this,u,o,e)]:u.querySelectorAll?[...a,...u.querySelectorAll(o+"")]:a,f)),f.length)return f}else if(s.includes(o.content)||e&&s.some(f=>rt(this,f,o.content,t)))return[o.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((s,o)=>{let f;return r.$$searchCache.has(o.content)?f=r.$$searchCache.get(o.content):(f=i(r,o)||[],o.type==="instance"&&r.$$searchCache.set(o.content,f)),s.concat(f)},[])}function Ft({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=E(t).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),null),i=E(r).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Wt(n,t){let r=this,{webqit:e,document:i,Node:s,CharacterData:o,Element:f,HTMLElement:a,HTMLTemplateElement:u,DocumentFragment:l}=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 c=(d,y,O)=>{e.realdom.domInterceptionNoRecurse.set(d,y);let h=O();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 q=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:q,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let O=y();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),O},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"]},v={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(w).reduce((d,y)=>d.concat(y),[])).forEach(d=>{Object.keys(w).forEach(h=>{if(!w[h].includes(d))return;let q=Object.getOwnPropertyDescriptor(r[h].prototype,d);!q||(Object.defineProperty(r[h].prototype,d,"value"in q?{...q,value:y}:{...q,set:O}),v[h][d]=q)});function y(...h){let q=Object.keys(v).find(T=>this instanceof r[T]&&d in v[T]),X=v[q],N=()=>X[d].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===d)return N();let M=[],b=[],D=this;["insertBefore"].includes(d)?b=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(b=[h[1]],["beforebegin","afterend"].includes(h[0])&&(D=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(M=[...this.childNodes],b=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(M=[this],b=d==="replaceWith"?[...h]:[],D=this.parentNode):["replaceChild"].includes(d)?(M=[h[1]],b=[h[0]]):["removeChild"].includes(d)?M=[...h]:(b=[...h],["before","after"].includes(d)&&(D=this.parentNode));let ot=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let T=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return X[d].value.call(this,...h);T=this.parentNode.nodeName}let R=i.createElement(T.includes("-")?"div":T);X.setHTMLUnsafe.value.call(R,b[0],d==="setHTMLUnsafe"?h[1]:{}),b=[...R.childNodes],d==="insertAdjacentHTML"?(ot="insertAdjacentElement",h[1]=new l,c(h[1],"append",()=>h[1].append(...R.childNodes))):(ot="replaceChildren",h=[...R.childNodes])}return p({target:D,entrants:b,exits:M,type:"interception",event:[this,d]},()=>X[ot].value.call(this,...h))}function O(h){let q=Object.keys(v).find(U=>this instanceof r[U]&&d in v[U]),X=v[q],N=()=>X[d].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===d)return N();let M=[],b=[],D=this;if(["outerHTML","outerText"].includes(d)?(M=[this],D=this.parentNode):this instanceof u?(D=this.content,M=[...this.content.childNodes]):M=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let U=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return N();U=this.parentNode.nodeName}let T=i.createElement(U.includes("-")?"div":U);if(c(T,d,()=>T[d]=h),b=this instanceof u?[...T.content.childNodes]:[...T.childNodes],this instanceof u&&this.hasAttribute("src")||this instanceof ShadowRoot){let R=V=>V.reduce((L,j)=>j instanceof HTMLScriptElement?L.concat(j):j instanceof u?L.concat(R([j.content])):(L=L.concat(R([...j.querySelectorAll?.("template")||[]].map(zt=>zt.content))),L.concat(...j.querySelectorAll?.("script")||[])),[]);for(let V of R(b)){if(this instanceof ShadowRoot){V.setAttribute("data-handling","manual");continue}let L=i.createElement("script");[...V.attributes].forEach(j=>L.setAttribute(j.name,j.value)),L.textContent=V.textContent,c(V,"replaceWith",()=>V.replaceWith(L))}}d==="outerHTML"?(h=new l,c(h,"append",()=>h.append(...b)),N=()=>c(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof u?N=()=>c(this.content,"replaceChildren",()=>this.content.replaceChildren(...b)):N=()=>c(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...b))}return p({target:D,entrants:b,exits:M,type:"interception",event:[this,d]},N)}}),m}function Ut(){me.call(this),de.call(this),pe.call(this)}function me(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function de(){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 pe(){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 Vt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Ut.call(n),n.webqit.realdom.meta=(...r)=>he.call(n,...r),n.webqit.realdom.ready=(...r)=>vt.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new nt(r,n);if(e==="attr")return new $(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 vt(...n){let t="interactive",r;J(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(s=>vt.call(this,"interactive",s)),complete:new Promise(s=>vt.call(this,"complete",s))}),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 s=i.document.readyState;for(let o of i.webqit.realdom.readyStateCallbacks[s].splice(0))o(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function he(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,s)=>{let o=s.split("=").map(f=>f.trim());return _t(i,o[0].split("."),o[1]==="true"?!0:o[1]==="false"?!1:C(o[1])?parseInt(o[1]):o[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function at(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 H={};function Bt(n,t,r){let e=this,i=Vt.call(e);H.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 s=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[s]){e.webqit.oohtml.configs[s]={};let o=e.webqit.oohtml.configs[s];K(2,o,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(o).forEach(f=>{Object.keys(o[f]).forEach(a=>{f==="api"&&typeof o[f][a]=="string"?o[f][a]=`${e.webqitConfig.prefix}${at(o[f][a])}`:["attr","elements"].includes(f)&&o[f][a]?.startsWith("data-")===!1&&(o[f][a]=`${e.webqitConfig.prefix}-${o[f][a]}`)})})}return{config:e.webqit.oohtml.configs[s],realdom:i,window:e}}function mt(){let{window:n}=H,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let s=i.pop();if(typeof s!="function")throw new Error("Callback must be provided.");let o=i.pop();if(!o?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],a=i.pop()||f[0];if(!f.includes(a))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:u,detail:l,targetContext:m,live:c,signal:p,diff:w,...v}=o;super(a,{...v,bubbles:v.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>s}),Object.defineProperty(this,"kind",{get:()=>u}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>c}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>w}),Object.defineProperty(this,"options",{get:()=>v}),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 B=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=H;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var Ot=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}}}}=H;return t}get name(){return[H.window.Document,H.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 Ot)||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}=W.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}},F=Ot;Et(F,"kind");var z=class extends Error{};var W=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 F))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new z(`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 B((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(o=>typeof o=="object"&&o))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let s=new(mt())(...t);this["#"].host.dispatchEvent(s)})}};function At(n={}){let{config:t,window:r}=Bt.call(this,"context-api",n,{elements:{roots:"root,webflo-embedded"},attr:{contextname:"contextname"},api:{contexts:"contexts"}}),e=new Map,i=r.EventTarget.prototype.dispatchEvent;Object.defineProperty(r.EventTarget.prototype,"dispatchEvent",{value:function(...s){let o=s[0],f=this?.closest?.(t.elements.roots)||this.getRootNode?.();if(["contextclaim","contextrequest"].includes(o.type)&&f){o.meta&&(o.meta.target=this);let a=l=>{if(l.stopImmediatePropagation(),l.meta&&(l.meta.target=l.target),!l.answered){if(e.get(f)||e.set(f,new Set),l.type==="contextrequest"&&l.live)e.get(f).add(l);else if(l.type==="contextclaim"){let m=new Set;return e.get(f).forEach(c=>{!l.target.contains(c.target)||!l.detail?.matchEvent?.(c)||(e.get(f).delete(c),m.add(c))}),e.get(f).size||e.delete(f),l.respondWith?.(m)}}};f.addEventListener(o.type,a);let u=i.call(this,...s);return f.removeEventListener(o.type,a),u}return i.call(this,...s)}}),r.webqit.DOMContexts=W,r.webqit.DOMContext=F,r.webqit.DOMContextRequestEvent=mt(),r.webqit.DOMContextResponse=B,r.webqit.DuplicateContextError=z,_e.call(r,t)}function _e(n){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let e=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.contexts in r)throw new Error(`The ${e} prototype already has a "${n.api.contexts}" API!`);Object.defineProperty(r,n.api.contexts,{get:function(){return W.instance(this)}})})}At.call(window);})();
1
+ (()=>{var Qt=Object.defineProperty;var Jt=(n,t,r)=>t in n?Qt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var Ct=(n,t,r)=>(Jt(n,typeof t!="symbol"?t+"":t,r),r);function x(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function Q(n){return typeof n=="function"}function Y(n){return n===null||n===""}function k(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||Q(n)}function pt(n){return Y(n)||k(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function _(n){return Q(n)||n&&{}.toString.call(n)==="[object function]"}function Z(n){return n instanceof Number||typeof n=="number"}function C(n){return Z(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function J(n){return n instanceof String||typeof n=="string"&&n!==null}function ht(n){return!J(n)&&!k(n.length)}function st(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function gt(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 yt(n,t){var r=[];return gt(n,t).forEach(e=>{st(r,...Object.getOwnPropertyNames(e))}),r}function P(n,t,r=!1,e=!1,i=!1){var s=0,o=n.shift();if((C(o)||o===!0||o===!1)&&(s=o,o=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,a)=>{!A(f)&&!_(f)||(r?yt(f):Object.keys(f)).forEach(u=>{if(!!t(u,o,f,a)){var l=o[u],m=f[u];if((g(l)&&g(m)||x(l)&&x(m))&&(s===!0||s>0))o[u]=g(l)&&g(m)?[]:{},P([C(s)?s-1:s,o[u],l,m],t,r,e,i);else if(g(o)&&g(f))e?o[u]=m:o.push(m);else try{i?Object.defineProperty(o,u,Object.getOwnPropertyDescriptor(f,u)):o[u]=f[u]}catch{}}})}),o}function K(...n){return P(n,(t,r,e)=>!0,!1,!1,!1)}function S(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 ft,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 ft,i.set(e,r));return r}var ft=class extends Map{};function E(n,t=!0){return g(n)?n:!t&&x(n)?[n]:n!==!1&&n!==0&&pt(n)?[]:ht(n)?Array.prototype.slice.call(n):x(n)?Object.values(n):[n]}function tt(n,t,r={},e={}){t=E(t).slice();for(var i=n;!k(i)&&!Y(i)&&t.length;){var s=t.shift();if(!(r.get?r.get(i,s):A(i)?s in i:i[s])){e.exists=!1;return}i=r.get?r.get(i,s):i[s]}return e.exists=!0,i}function wt(n,t,r,e={},i={}){let s=(l,m,c)=>i.set?i.set(l,m,c):(C(t[f])&&g(l)?l.push(c):l[m]=c,!0);t=E(t);for(var o=n,f=0;f<t.length;f++)if(f<t.length-1){if(!o||!A(o)&&!_(o))return!1;var a=tt(o,t[f],i);if(!A(a)){if(i.buildTree===!1)return!1;a=_(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var u=s(o,t[f],a);if(!u)return!1}o=a}else return s(o,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),s=o=>{o!==void 0&&this.onwrite(()=>{let f=r(o,e),a=u=>{u!==void 0&&this.cycle(t,r,u)};f instanceof Promise?f.then(a):a(f)})};i instanceof Promise?i.then(s):s(i)})}};function Lt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function ct(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(o=>(o+"").replace("(",e?"(.//":"(./")).join("|");let i=[],s;try{let o=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;s=o.iterateNext();)i.push(s)}catch{}return i}function jt(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 s=i?.get(t)?.get(r);if(typeof s<"u")return s;let o=u=>(i?.has(t)||i?.set(t,new WeakMap),i?.get(t)?.set(r,u),u),f=t.getRootNode(),a=r.getRootNode();return f===a?o(t.contains(r)):e&&a instanceof n.ShadowRoot?o(rt(n,t,a.host,e,i)):o(!1)}function kt(n,t="|"){return[...n].reduce(([r,e,i,s],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()}var q=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Lt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=kt(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(_(t[0])?t=[[],...t]:x(t[0])&&!(t[0]instanceof q)&&t.length===1?t=[[],void 0,t[0]]:x(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 S(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,s=new Set,o=new WeakMap;for(let[f,a]of this.registry(t)){let u=[].concat(r).filter(m=>rt(i,f.context,m.target,f.params.subtree==="cross-roots",o));if(!u.length)continue;let l=[f,Array.isArray(r)?u:u[0]];a?s.add(l):e.call(i,...l)}for(let f of s)e.call(i,...f);s.clear()}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&_(i.disconnect)&&i.disconnect()||_(i)&&i()||x(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var $=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 q;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:s}=this,o=Rt(s,t);if(!r)return o;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let a of o){let u=f?f.generate():{};r(a,u,s)}else{let a=f?.generate()||{};r(o,a,s)}if(e.live){f&&(e={...e,signalGenerator:f});let a=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,a)}}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:s,window:o,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Nt.call(o,"intercept",()=>{});let a=new o.MutationObserver(c=>{c=Dt(c).map(p=>$t.call(o,p)),Ht.call(o,m,c,s)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(u.attributeFilter=t.map(c=>c+"")),a.observe(s,u);let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:a};return this.disconnectables(e.signal,a,l)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof q;[t,r,e={}]=this.resolveArgs(arguments);let{context:s,window:o}=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||Nt.call(o,f,c=>{this.forEachMatchingContext(f,c,Ht)});let a={disconnect(){m.delete(l)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:a},m=this.registry(f);return m.set(l,!!l.params.deferred),this.disconnectables(e.signal,a,u)}};function Dt(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||S(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Ht(n,t){let{context:r,spec:e,callback:i,params:s,atomics:o,originalFilterIsString:f,signalGenerator:a}=n;if(s.subtree||(t=t.filter(c=>c.target===r)),!t.length)return;let u=e.map(c=>c+"");if(s.atomic&&!o.size?t=Rt(r,e,t):s.timing!=="async"&&e.length&&(t=t.filter(c=>u.includes(c.name))),!t.length)return;s.newValue===null&&s.oldValue===null&&s.eventDetails||(t=t.map(c=>{let p;return s.eventDetails||({event:p,...c}=c),!s.oldValue&&"oldValue"in c&&({oldValue:p,...c}=c),!s.newValue&&"value"in c?{value:p,...c}=c:s.newValue&&typeof c.value>"u"&&(c={...c,value:ut(c.target,c.name,()=>c.target.getAttribute(c.name))}),c})),s.atomic&&(t.forEach(c=>o.set(c.name,c)),t=Array.from(o.entries()).map(([,c])=>c));let l=f?t[0]:t,m=a?a.generate():{};i(l,m,r)}function ut(n,t,r){let e=S(n,"realdom","internalAttrInteractions").get(t);S(n,"realdom","internalAttrInteractions").set(t,!0);let i=r();return S(n,"realdom","internalAttrInteractions").set(t,e),i}function Rt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(s=>(s=s+"",r.find(o=>o.name===s)||{target:n,name:s,value:ut(n,s,()=>n.getAttribute(s)),...e})):Array.from(n.attributes).map(s=>r.find(o=>o.name===s.nodeName)||{target:n,name:s.nodeName,value:ut(n,s.nodeName,()=>s.nodeValue),...e})}function $t({target:n,attributeName:t,value:r,oldValue:e}){let o=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:o}}function Nt(n,t){let r=this,{webqit:e,document:i,Element:s}=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 o=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return o;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(l,m)=>{e.realdom.attrInterceptionRecords.has(l.target)||e.realdom.attrInterceptionRecords.set(l.target,{});let c=e.realdom.attrInterceptionRecords.get(l.target);if(c[l.name]=c[l.name]||[],c[l.name].unshift(l.event),S(l.target,"realdom","internalAttrInteractions").get(l.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(w=>w([l]));let p=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(w=>w([l])),p};new r.MutationObserver(l=>{l=l.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),l=Dt(l).map(m=>$t.call(r,m)),l.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(l)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(l)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{u[l]=s.prototype[l],s.prototype[l]=function(...m){let c,p=ut(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(l)&&(c=m[1]),l==="toggleAttribute"&&c===void 0&&(c=p===null);let w={target:this,name:m[0],value:c,oldValue:p,type:"interception",event:[this,l]};return f(w,()=>u[l].call(this,...m))}}),o}var nt=class extends G{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:s}=this;return new $(i,s).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,s=new Map,o=u=>(s.has(u)||s.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),s.get(u));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(u=>o(i).entrants.push(u));else if(t.every(u=>u.type==="selector")){let[u,l]=t.reduce(([c,p],w)=>w.kind==="xpath"?[c,p.concat(w)]:[c.concat(w),p],[[],[]]),m=[];e.subtree?(u.length&&m.push(...i.querySelectorAll(u.join(","))),l.length&&m.push(...ct(this.window,i,l))):(u.length&&m.push(...[...i.children].filter(c=>c.matches(u))),l.length&&m.push(...ct(this.window,i,l,!1))),m.forEach(c=>o(c.parentNode||i).entrants.push(c))}}if(!r)return s;let f={disconnected:!1},a=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of s){if(f.disconnected)break;let l=a?.generate()||{};r(u,l,i)}if(e.live){a&&(e={...e,signalGenerator:a});let u=this.observe(t,r,e);return this.disconnectables(e.signal,f,u)}return this.disconnectables(e.signal,f,a)}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:s,webqit:o,document:f}=this;e.eventDetails&&(o.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||o.realdom.domInterceptionRecordsAlwaysOn)&&!o.realdom.domInterceptionHooks?.intercepting&&Ut.call(s,"sync",()=>{});let a=new s.MutationObserver(m=>m.forEach(c=>{vt.call(s,l,Wt.call(s,c),i)}));a.observe(i,{childList:!0,subtree:e.subtree&&!0});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:a};if(e.staticSensitivity){let m=Ft.call(s,l);return this.disconnectables(e.signal,a,u,m)}return this.disconnectables(e.signal,a,u)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let o=e.timing==="intercept"?"intercept":"sync";this.registry(o).size||Ut.call(s,o,c=>{this.forEachMatchingContext(o,c,vt)});let f=new s.MutationObserver(c=>c.forEach(p=>{Array.isArray((p=Wt.call(s,p)).event)||vt.call(s,l,p,i)}));f.observe(i,{childList:!0,subtree:e.subtree&&!0});let a={disconnect(){m.delete(l),f.disconnect()}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:a},m=this.registry(o);if(m.set(l,!!l.params.deferred),e.staticSensitivity){let c=Ft.call(s,l);return this.disconnectables(e.signal,a,u,c)}return this.disconnectables(e.signal,a,u)}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 Ft(n){let t=this,{context:r,spec:e,callback:i,params:s,signalGenerator:o}=n,f=e.filter(p=>p.kind==="css"),a=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],u=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],l=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(w=>w[1]).concat(a(p)).concat(u(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,w)=>p.concat(l(w+"")),[])))).length)return;let m=new Set,c=new Set;return m.push=p=>(c.delete(p),m.add(p)),c.push=p=>(m.delete(p),c.add(p)),n.$deliveryCache={entrants:m,exits:c},new $(r,t).observe(n.$attrs,p=>{let w=new Map,v=y=>(w.has(y)||w.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),w.get(y)),it=new WeakMap,d=y=>(it.has(y)||it.set(y,f.some(O=>y.matches(O+""))),it.get(y));for(let y of p)["entrants","exits"].forEach(O=>{s.generation&&O!==s.generation||n.$deliveryCache[O].has(y.target)||(O==="entrants"?!d(y.target):d(y.target))||(n.$deliveryCache[O].push(y.target),v(y.target)[O].push(y.target),v(y.target).event=y.event)});for(let[,y]of w){let O=o?.generate()||{};i(y,O,r)}},{subtree:s.subtree,timing:s.timing,eventDetails:s.eventDetails})}function vt(n,t){let{context:r,spec:e,callback:i,params:s,signalGenerator:o,$deliveryCache:f}=n,a={...t,entrants:[],exits:[]};if(s.eventDetails||delete a.event,["entrants","exits"].forEach(l=>{if(!(s.generation&&l!==s.generation)&&(e.length?a[l]=me.call(this,e,s.subtree==="cross-roots",t[l],t.event!=="parse"):a[l]=[...t[l]],!!f))for(let m of a[l])f[l].push(m)}),!a.entrants.length&&!a.exits.length)return;let u=o?.generate()||{};i(a,u,r)}function me(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(s,o)=>{if(o.type==="selector"){let f=o.isXpathAttr?[]:s.filter(a=>o.kind==="xpath"?jt(this,a,o+""):a.matches&&a.matches(o+""));if((e||o.isXpathAttr)&&(f=s.reduce((a,u)=>o.kind==="xpath"?[...a,...ct(this,u,o,e)]:u.querySelectorAll?[...a,...u.querySelectorAll(o+"")]:a,f)),f.length)return f}else if(s.includes(o.content)||e&&s.some(f=>rt(this,f,o.content,t)))return[o.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((s,o)=>{let f;return r.$$searchCache.has(o.content)?f=r.$$searchCache.get(o.content):(f=i(r,o)||[],o.type==="instance"&&r.$$searchCache.set(o.content,f)),s.concat(f)},[])}function Wt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=E(t).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),null),i=E(r).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Ut(n,t){let r=this,{webqit:e,document:i,Node:s,CharacterData:o,Element:f,HTMLElement:a,HTMLTemplateElement:u,DocumentFragment:l}=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 c=(d,y,O)=>{e.realdom.domInterceptionNoRecurse.set(d,y);let h=O();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 T=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:T,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let O=y();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),O},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"]},v={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(w).reduce((d,y)=>d.concat(y),[])).forEach(d=>{Object.keys(w).forEach(h=>{if(!w[h].includes(d))return;let T=Object.getOwnPropertyDescriptor(r[h].prototype,d);!T||(Object.defineProperty(r[h].prototype,d,"value"in T?{...T,value:y}:{...T,set:O}),v[h][d]=T)});function y(...h){let T=Object.keys(v).find(I=>this instanceof r[I]&&d in v[I]),X=v[T],N=()=>X[d].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===d)return N();let M=[],b=[],D=this;["insertBefore"].includes(d)?b=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(b=[h[1]],["beforebegin","afterend"].includes(h[0])&&(D=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(M=[...this.childNodes],b=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(M=[this],b=d==="replaceWith"?[...h]:[],D=this.parentNode):["replaceChild"].includes(d)?(M=[h[1]],b=[h[0]]):["removeChild"].includes(d)?M=[...h]:(b=[...h],["before","after"].includes(d)&&(D=this.parentNode));let ot=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let I=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return X[d].value.call(this,...h);I=this.parentNode.nodeName}let R=i.createElement(I.includes("-")?"div":I);X.setHTMLUnsafe.value.call(R,b[0],d==="setHTMLUnsafe"?h[1]:{}),b=[...R.childNodes],d==="insertAdjacentHTML"?(ot="insertAdjacentElement",h[1]=new l,c(h[1],"append",()=>h[1].append(...R.childNodes))):(ot="replaceChildren",h=[...R.childNodes])}return p({target:D,entrants:b,exits:M,type:"interception",event:[this,d]},()=>X[ot].value.call(this,...h))}function O(h){let T=Object.keys(v).find(U=>this instanceof r[U]&&d in v[U]),X=v[T],N=()=>X[d].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===d)return N();let M=[],b=[],D=this;if(["outerHTML","outerText"].includes(d)?(M=[this],D=this.parentNode):this instanceof u?(D=this.content,M=[...this.content.childNodes]):M=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let U=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return N();U=this.parentNode.nodeName}let I=i.createElement(U.includes("-")?"div":U);if(c(I,d,()=>I[d]=h),b=this instanceof u?[...I.content.childNodes]:[...I.childNodes],this instanceof u&&this.hasAttribute("src")||this instanceof ShadowRoot){let R=V=>V.reduce((L,j)=>j instanceof HTMLScriptElement?L.concat(j):j instanceof u?L.concat(R([j.content])):(L=L.concat(R([...j.querySelectorAll?.("template")||[]].map(Xt=>Xt.content))),L.concat(...j.querySelectorAll?.("script")||[])),[]);for(let V of R(b)){if(this instanceof ShadowRoot){V.setAttribute("data-handling","manual");continue}let L=i.createElement("script");[...V.attributes].forEach(j=>L.setAttribute(j.name,j.value)),L.textContent=V.textContent,c(V,"replaceWith",()=>V.replaceWith(L))}}d==="outerHTML"?(h=new l,c(h,"append",()=>h.append(...b)),N=()=>c(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof u?N=()=>c(this.content,"replaceChildren",()=>this.content.replaceChildren(...b)):N=()=>c(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...b))}return p({target:D,entrants:b,exits:M,type:"interception",event:[this,d]},N)}}),m}function Vt(){de.call(this),pe.call(this),he.call(this)}function de(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function pe(){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 he(){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 Gt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Vt.call(n),n.webqit.realdom.meta=(...r)=>ge.call(n,...r),n.webqit.realdom.ready=(...r)=>Ot.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new nt(r,n);if(e==="attr")return new $(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 Ot(...n){let t="interactive",r;J(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(s=>Ot.call(this,"interactive",s)),complete:new Promise(s=>Ot.call(this,"complete",s))}),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 s=i.document.readyState;for(let o of i.webqit.realdom.readyStateCallbacks[s].splice(0))o(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function ge(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,s)=>{let o=s.split("=").map(f=>f.trim());return wt(i,o[0].split("."),o[1]==="true"?!0:o[1]==="false"?!1:C(o[1])?parseInt(o[1]):o[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function at(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 mt=(n,...t)=>S(n,"oohtml",...t),H={};function zt(n,t,r){let e=this,i=Gt.call(e);H.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 s=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[s]){e.webqit.oohtml.configs[s]={};let o=e.webqit.oohtml.configs[s];K(2,o,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(o).forEach(f=>{Object.keys(o[f]).forEach(a=>{f==="api"&&typeof o[f][a]=="string"?o[f][a]=`${e.webqitConfig.prefix}${at(o[f][a])}`:["attr","elements"].includes(f)&&o[f][a]?.startsWith("data-")===!1&&(o[f][a]=`${e.webqitConfig.prefix}-${o[f][a]}`)})})}return{config:e.webqit.oohtml.configs[s],realdom:i,window:e}}function dt(){let{window:n}=H,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let s=i.pop();if(typeof s!="function")throw new Error("Callback must be provided.");let o=i.pop();if(!o?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],a=i.pop()||f[0];if(!f.includes(a))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:u,detail:l,targetContext:m,live:c,signal:p,diff:w,...v}=o;super(a,{...v,bubbles:v.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>s}),Object.defineProperty(this,"kind",{get:()=>u}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>c}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>w}),Object.defineProperty(this,"options",{get:()=>v}),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 B=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=H;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var At=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}}}}=H;return t}get name(){return[H.window.Document,H.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 At)||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}=W.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}},F=At;Ct(F,"kind");var z=class extends Error{};var W=class{static instance(t){return mt(t).get("contexts::instance")||new this(t)}constructor(t){mt(t).get("contexts::instance")?.dispose(),mt(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 F))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new z(`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 B((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(o=>typeof o=="object"&&o))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let s=new(dt())(...t);this["#"].host.dispatchEvent(s)})}};function Et(n={}){let{config:t,window:r}=zt.call(this,"context-api",n,{elements:{roots:"root,webflo-embedded"},attr:{contextname:"contextname"},api:{contexts:"contexts"}}),e=new Map,i=r.EventTarget.prototype.dispatchEvent;Object.defineProperty(r.EventTarget.prototype,"dispatchEvent",{value:function(...s){let o=s[0],f=this?.closest?.(t.elements.roots)||this.getRootNode?.();if(["contextclaim","contextrequest"].includes(o.type)&&f){o.meta&&(o.meta.target=this);let a=l=>{if(l.stopImmediatePropagation(),l.meta&&(l.meta.target=l.target),!l.answered){if(e.get(f)||e.set(f,new Set),l.type==="contextrequest"&&l.live)e.get(f).add(l);else if(l.type==="contextclaim"){let m=new Set;return e.get(f).forEach(c=>{!l.target.contains(c.target)||!l.detail?.matchEvent?.(c)||(e.get(f).delete(c),m.add(c))}),e.get(f).size||e.delete(f),l.respondWith?.(m)}}};f.addEventListener(o.type,a);let u=i.call(this,...s);return f.removeEventListener(o.type,a),u}return i.call(this,...s)}}),r.webqit.DOMContexts=W,r.webqit.DOMContext=F,r.webqit.DOMContextRequestEvent=dt(),r.webqit.DOMContextResponse=B,r.webqit.DuplicateContextError=z,we.call(r,t)}function we(n){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let e=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.contexts in r)throw new Error(`The ${e} prototype already has a "${n.api.contexts}" API!`);Object.defineProperty(r,n.api.contexts,{get:function(){return W.instance(this)}})})}Et.call(window);})();
2
2
  //# sourceMappingURL=context-api.js.map