@webqit/oohtml 5.0.6 → 5.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/scoped-js.js CHANGED
@@ -1,2 +1,1517 @@
1
- function be(...n){let e,r={runtimeParams:Xe,transformerParams:Be,parserParams:Ge};for(;e=n.shift();){let{runtimeParams:t={},transformerParams:{globalsNoObserve:i=[],globalsOnlyPathsExcept:o=[],...s}={},parserParams:f={}}=e;r={runtimeParams:{...r.runtimeParams,...t},transformerParams:{...r.transformerParams,globalsNoObserve:[...r.transformerParams.globalsNoObserve,...i],globalsOnlyPathsExcept:[...r.transformerParams.globalsOnlyPathsExcept,...o],...s},parserParams:{...r.parserParams,...f}},n.devMode}return r}var Ge={ecmaVersion:"latest",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!1,allowSuperOutsideMethod:!1,preserveParens:!1,locations:!0},Be={globalsNoObserve:["arguments","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},Xe={apiVersion:3};function x(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function V(n){return typeof n=="function"}function B(n){return n===null||n===""}function F(n){return arguments.length&&(n===void 0||typeof n>"u")}function O(n){return Array.isArray(n)||typeof n=="object"&&n||V(n)}function le(n){return B(n)||F(n)||n===!1||n===0||O(n)&&!Object.keys(n).length}function _(n){return V(n)||n&&{}.toString.call(n)==="[object function]"}function X(n){return n instanceof Number||typeof n=="number"}function S(n){return X(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function G(n){return n instanceof String||typeof n=="string"&&n!==null}function ce(n){return!G(n)&&!F(n.length)}function te(n,...e){return e.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function ae(t,e){e=e||Object.prototype,e=e&&!g(e)?[e]:e;for(var r=[],t=t;t&&(!e||e.indexOf(t)<0)&&t.name!=="default";)r.push(t),t=t?Object.getPrototypeOf(t):null;return r}function ue(n,e){var r=[];return ae(n,e).forEach(t=>{te(r,...Object.getOwnPropertyNames(t))}),r}function M(n,e,r=!1,t=!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,a)=>{!O(f)&&!_(f)||(r?ue(f):Object.keys(f)).forEach(c=>{if(!!e(c,s,f,a)){var l=s[c],m=f[c];if((g(l)&&g(m)||x(l)&&x(m))&&(o===!0||o>0))s[c]=g(l)&&g(m)?[]:{},M([S(o)?o-1:o,s[c],l,m],e,r,t,i);else if(g(s)&&g(f))t?s[c]=m:s.push(m);else try{i?Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(f,c)):s[c]=f[c]}catch{}}})}),s}function z(...n){return M(n,(e,r,t)=>!0,!1,!1,!1)}function E(n,...e){if(!n||!["object","function"].includes(typeof n))throw new Error("Argument #1 must be of type object");let r=n[Symbol.for("wq")];if(r||(r=new re,Object.defineProperty(n,Symbol.for("wq"),{value:r,enumerable:!1,configurable:!1,writable:!1})),!e.length)return r;let t,i;for(;t=e.shift();)(i=r)&&!(r=r.get(t))&&(r=new re,i.set(t,r));return r}var re=class extends Map{};function A(n,e=!0){return g(n)?n:!e&&x(n)?[n]:n!==!1&&n!==0&&le(n)?[]:ce(n)?Array.prototype.slice.call(n):x(n)?Object.values(n):[n]}function J(n,e,r={},t={}){e=A(e).slice();for(var i=n;!F(i)&&!B(i)&&e.length;){var o=e.shift();if(!(r.get?r.get(i,o):O(i)?o in i:i[o])){t.exists=!1;return}i=r.get?r.get(i,o):i[o]}return t.exists=!0,i}function pe(n,e,r,t={},i={}){let o=(l,m,u)=>i.set?i.set(l,m,u):(S(e[f])&&g(l)?l.push(u):l[m]=u,!0);e=A(e);for(var s=n,f=0;f<e.length;f++)if(f<e.length-1){if(!s||!O(s)&&!_(s))return!1;var a=J(s,e[f],i);if(!O(a)){if(i.buildTree===!1)return!1;a=_(i.buildTree)?i.buildTree(f):S(e[f+1])?[]:{};var c=o(s,e[f],a);if(!c)return!1}s=a}else return o(s,e[f],r)}var Q=class{constructor(e,r=!1){Object.defineProperty(this,"window",{value:e}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(e){this._synthesis++,this._fulfill();let r=await e();return this._synthesis--,r}_fulfill(){for(let e of this.readCallbacks)e(),this.readCallbacks.delete(e);for(let e of this.writeCallbacks)e(),this.writeCallbacks.delete(e)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(e,r=!1){if(r)return new Promise(t=>{this.synthesis?t(e()):this.readCallbacks.add(()=>{t(e())})});this.synthesis?Promise.resolve().then(e):this.readCallbacks.add(e)}onwrite(e,r=!1){if(r)return new Promise(t=>{this.synthesis?t(e()):this.writeCallbacks.add(()=>{t(e())})});this.synthesis?Promise.resolve().then(e):this.writeCallbacks.add(e)}cycle(e,r,t){this.onread(()=>{let i=e(t),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,t),a=c=>{c!==void 0&&this.cycle(e,r,c)};f instanceof Promise?f.then(a):a(f)})};i instanceof Promise?i.then(o):o(i)})}};function Pe(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function ie(n,e,r,t=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",t?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,e,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function Te(n,e,r){r=(Array.isArray(r)?r:[r]).map(t=>(t+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,e,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function Y(n,e,r,t=!1,i=null){let o=i?.get(e)?.get(r);if(typeof o<"u")return o;let s=c=>(i?.has(e)||i?.set(e,new WeakMap),i?.get(e)?.set(r,c),c),f=e.getRootNode(),a=r.getRootNode();return f===a?s(e.contains(r)):t&&a instanceof n.ShadowRoot?s(Y(n,e,a.host,t,i)):s(!1)}function qe(n,e="|"){return[...n].reduce(([r,t,i,o],s)=>!r&&t===0&&(Array.isArray(e)?e:[e]).includes(s)?[r,t,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&t++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&t--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,t,i]),[null,0,[""]])[2].reverse()}var C=class{constructor(e){this.content=e,this.type=typeof e=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Pe(e)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=qe(e.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var R=class{constructor(e,r,t){this.context=e,this.namespace=r,this.window=e.defaultView||e.ownerDocument?.defaultView||t,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(e){if(_(e[0])?e=[[],...e]:x(e[0])&&!(e[0]instanceof C)&&e.length===1?e=[[],void 0,e[0]]:x(e[1])&&e.length===2?e=[A(e[0],!1),void 0,e[1]]:e[0]=A(e[0],!1),e[0].filter(r=>typeof r!="string"&&!(r instanceof C)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return e[0]=e[0].map(r=>r instanceof C?r:new C(r)),e}registry(...e){return E(this.window,"realdom",this.namespace,...e)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(e,r,t){let{window:i}=this,o=new Set,s=new WeakMap;for(let[f,a]of this.registry(e)){let c=[].concat(r).filter(m=>Y(i,f.context,m.target,f.params.subtree==="cross-roots",s));if(!c.length)continue;let l=[f,Array.isArray(r)?c:c[0]];a?o.add(l):t.call(i,...l)}for(let f of o)t.call(i,...f);o.clear()}disconnectables(e,...r){let t={disconnect(){r.forEach(i=>i&&_(i.disconnect)&&i.disconnect()||_(i)&&i()||x(i)&&(i.disconnected=!0))}};return e&&e.addEventListener("abort",()=>t.disconnect()),t}};var k=class extends R{type="attr";constructor(e,...r){super(e,"attr",...r)}get(e,r=void 0,t={}){let i=typeof e=="string"||e instanceof C;[e=[],r=void 0,t={}]=this.resolveArgs(arguments);let{context:o}=this,s=Ne(o,e);if(!r)return s;let f=t.lifecycleSignals&&this.createSignalGenerator();if(i)for(let a of s){let c=f?f.generate():{};r(a,c,o)}else{let a=f?.generate()||{};r(s,a,o)}if(t.live){f&&(t={...t,signalGenerator:f});let a=this.observe(i?e[0]:e,r,{newValue:!0,...t});return this.disconnectables(t.signal,a)}}observe(e,r,t={}){let i=typeof e=="string"||e instanceof C;if([e=[],r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(i?e[0]:e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:o,window:s,webqit:f}=this;t.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Me.call(s,"intercept",()=>{});let a=new s.MutationObserver(u=>{u=He(u).map(d=>Le.call(s,d)),Ie.call(s,m,u,o)}),c={attributes:!0,attributeOldValue:t.oldValue,subtree:t.subtree&&!0};e.length&&(c.attributeFilter=e.map(u=>u+"")),a.observe(o,c);let l=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:e,callback:r,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:a};return this.disconnectables(t.signal,a,l)}observeSync(e,r,t={}){let i=typeof e=="string"||e instanceof C;[e,r,t={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let f=t.timing==="intercept"?"intercept":"sync";this.registry(f).size||Me.call(s,f,u=>{this.forEachMatchingContext(f,u,Ie)});let a={disconnect(){m.delete(l)}},c=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),l={context:o,spec:e,callback:r,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:a},m=this.registry(f);return m.set(l,!!l.params.deferred),this.disconnectables(t.signal,a,c)}};function He(n){return n.reduce((e,r,t)=>e[t-1]?.attributeName===r.attributeName||E(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?e:e.concat(r),[])}function Ie(n,e){let{context:r,spec:t,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:a}=n;if(o.subtree||(e=e.filter(u=>u.target===r)),!e.length)return;let c=t.map(u=>u+"");if(o.atomic&&!s.size?e=Ne(r,t,e):o.timing!=="async"&&t.length&&(e=e.filter(u=>c.includes(u.name))),!e.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(e=e.map(u=>{let d;return o.eventDetails||({event:d,...u}=u),!o.oldValue&&"oldValue"in u&&({oldValue:d,...u}=u),!o.newValue&&"value"in u?{value:d,...u}=u:o.newValue&&typeof u.value>"u"&&(u={...u,value:oe(u.target,u.name,()=>u.target.getAttribute(u.name))}),u})),o.atomic&&(e.forEach(u=>s.set(u.name,u)),e=Array.from(s.entries()).map(([,u])=>u));let l=f?e[0]:e,m=a?a.generate():{};i(l,m,r)}function oe(n,e,r){let t=E(n,"realdom","internalAttrInteractions").get(e);E(n,"realdom","internalAttrInteractions").set(e,!0);let i=r();return E(n,"realdom","internalAttrInteractions").set(e,t),i}function Ne(n,e,r=[]){let t={event:null,type:"attribute"};return e.length?e.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:oe(n,o,()=>n.getAttribute(o)),...t})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:oe(n,o.nodeName,()=>o.nodeValue),...t})}function Le({target:n,attributeName:e,value:r,oldValue:t}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[e]?.[0]||"mutation";return{target:n,name:e,value:r,oldValue:t,type:"observation",event:s}}function Me(n,e){let r=this,{webqit:t,document:i,Element:o}=r;t.realdom.attrInterceptionHooks||Object.defineProperty(t.realdom,"attrInterceptionHooks",{value:new Map}),t.realdom.attrInterceptionHooks.has(n)||t.realdom.attrInterceptionHooks.set(n,new Set),t.realdom.attrInterceptionHooks.get(n).add(e);let s=()=>t.realdom.attrInterceptionHooks.get(n).delete(e);if(t.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),t.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(t.realdom,"attrInterceptionRecords",{value:new Map});let f=(l,m)=>{t.realdom.attrInterceptionRecords.has(l.target)||t.realdom.attrInterceptionRecords.set(l.target,{});let u=t.realdom.attrInterceptionRecords.get(l.target);if(u[l.name]=u[l.name]||[],u[l.name].unshift(l.event),E(l.target,"realdom","internalAttrInteractions").get(l.name))return m();t.realdom.attrInterceptionHooks.get("intercept")?.forEach(w=>w([l]));let d=m();return t.realdom.attrInterceptionHooks.get("sync")?.forEach(w=>w([l])),d};new r.MutationObserver(l=>{l=l.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),l=He(l).map(m=>Le.call(r,m)),l.length&&(t.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(l)),t.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(l)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let c=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{c[l]=o.prototype[l],o.prototype[l]=function(...m){let u,d=oe(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(l)&&(u=m[1]),l==="toggleAttribute"&&u===void 0&&(u=d===null);let w={target:this,name:m[0],value:u,oldValue:d,type:"interception",event:[this,l]};return f(w,()=>c[l].call(this,...m))}}),s}var Z=class extends R{constructor(e,...r){super(e,"tree",...r)}attr(e,r=void 0,t={}){let{context:i,window:o}=this;return new k(i,o).get(...arguments)}query(e,r=void 0,t={}){[e,r=void 0,t={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=c=>(o.has(c)||o.set(c,{target:c,entrants:[],exits:[],type:"query",event:null}),o.get(c));if(!t.generation||t.generation==="entrants"){if(!e.length)[...i.children].forEach(c=>s(i).entrants.push(c));else if(e.every(c=>c.type==="selector")){let[c,l]=e.reduce(([u,d],w)=>w.kind==="xpath"?[u,d.concat(w)]:[u.concat(w),d],[[],[]]),m=[];t.subtree?(c.length&&m.push(...i.querySelectorAll(c.join(","))),l.length&&m.push(...ie(this.window,i,l))):(c.length&&m.push(...[...i.children].filter(u=>u.matches(c))),l.length&&m.push(...ie(this.window,i,l,!1))),m.forEach(u=>s(u.parentNode||i).entrants.push(u))}}if(!r)return o;let f={disconnected:!1},a=r&&t.lifecycleSignals&&this.createSignalGenerator();for(let[,c]of o){if(f.disconnected)break;let l=a?.generate()||{};r(c,l,i)}if(t.live){a&&(t={...t,signalGenerator:a});let c=this.observe(e,r,t);return this.disconnectables(t.signal,f,c)}return this.disconnectables(t.signal,f,a)}children(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!1})}subtree(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!0})}observe(e,r,t={}){if([e,r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;t.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&$e.call(o,"sync",()=>{});let a=new o.MutationObserver(m=>m.forEach(u=>{ge.call(o,l,Fe.call(o,u),i)}));a.observe(i,{childList:!0,subtree:t.subtree&&!0});let c=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:e,callback:r,params:t,signalGenerator:c,disconnectable:a};if(t.staticSensitivity){let m=je.call(o,l);return this.disconnectables(t.signal,a,c,m)}return this.disconnectables(t.signal,a,c)}observeSync(e,r,t={}){[e,r,t={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let s=t.timing==="intercept"?"intercept":"sync";this.registry(s).size||$e.call(o,s,u=>{this.forEachMatchingContext(s,u,ge)});let f=new o.MutationObserver(u=>u.forEach(d=>{Array.isArray((d=Fe.call(o,d)).event)||ge.call(o,l,d,i)}));f.observe(i,{childList:!0,subtree:t.subtree&&!0});let a={disconnect(){m.delete(l),f.disconnect()}},c=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:e,callback:r,params:t,signalGenerator:c,disconnectable:a},m=this.registry(s);if(m.set(l,!!l.params.deferred),t.staticSensitivity){let u=je.call(o,l);return this.disconnectables(t.signal,a,c,u)}return this.disconnectables(t.signal,a,c)}track(e,r,t={}){return t={subtree:!0,...t},this.observe(e,i=>{i.entrants.length&&r(!0,Array.isArray(e)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(e)?i.exits:i.exits[0])},t)}};function je(n){let e=this,{context:r,spec:t,callback:i,params:o,signalGenerator:s}=n,f=t.filter(d=>d.kind==="css"),a=d=>d.match(/\.([\w-]+)/g)?.length?["class"]:[],c=d=>d.match(/#([\w-]+)/g)?.length?["id"]:[],l=d=>[...d.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(w=>w[1]).concat(a(d)).concat(c(d));if(!(n.$attrs=Array.from(new Set(f.filter(d=>(d+"").includes("[")).reduce((d,w)=>d.concat(l(w+"")),[])))).length)return;let m=new Set,u=new Set;return m.push=d=>(u.delete(d),m.add(d)),u.push=d=>(m.delete(d),u.add(d)),n.$deliveryCache={entrants:m,exits:u},new k(r,e).observe(n.$attrs,d=>{let w=new Map,P=y=>(w.has(y)||w.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),w.get(y)),K=new WeakMap,p=y=>(K.has(y)||K.set(y,f.some(v=>y.matches(v+""))),K.get(y));for(let y of d)["entrants","exits"].forEach(v=>{o.generation&&v!==o.generation||n.$deliveryCache[v].has(y.target)||(v==="entrants"?!p(y.target):p(y.target))||(n.$deliveryCache[v].push(y.target),P(y.target)[v].push(y.target),P(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 ge(n,e){let{context:r,spec:t,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,a={...e,entrants:[],exits:[]};if(o.eventDetails||delete a.event,["entrants","exits"].forEach(l=>{if(!(o.generation&&l!==o.generation)&&(t.length?a[l]=ct.call(this,t,o.subtree==="cross-roots",e[l],e.event!=="parse"):a[l]=[...e[l]],!!f))for(let m of a[l])f[l].push(m)}),!a.entrants.length&&!a.exits.length)return;let c=s?.generate()||{};i(a,c,r)}function ct(n,e,r,t){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(a=>s.kind==="xpath"?Te(this,a,s+""):a.matches&&a.matches(s+""));if((t||s.isXpathAttr)&&(f=o.reduce((a,c)=>s.kind==="xpath"?[...a,...ie(this,c,s,t)]:c.querySelectorAll?[...a,...c.querySelectorAll(s+"")]:a,f)),f.length)return f}else if(o.includes(s.content)||t&&o.some(f=>Y(this,f,s.content,e)))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 Fe({target:n,addedNodes:e,removedNodes:r}){let t=this,i;return i=A(e).reduce((o,s)=>o||t.webqit.realdom.domInterceptionRecords?.get(s),null),i=A(r).reduce((o,s)=>o||t.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||t.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:e,exits:r,type:"observation",event:i}}function $e(n,e){let r=this,{webqit:t,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:a,HTMLTemplateElement:c,DocumentFragment:l}=r;t.realdom.domInterceptionHooks||Object.defineProperty(t.realdom,"domInterceptionHooks",{value:new Map}),t.realdom.domInterceptionNoRecurse||Object.defineProperty(t.realdom,"domInterceptionNoRecurse",{value:new Map}),t.realdom.domInterceptionHooks.has(n)||t.realdom.domInterceptionHooks.set(n,new Set),t.realdom.domInterceptionHooks.get(n).add(e);let m=()=>t.realdom.domInterceptionHooks.get(n).delete(e);if(t.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),t.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(t.realdom,"domInterceptionRecords",{value:new Map});let u=(p,y,v)=>{t.realdom.domInterceptionNoRecurse.set(p,y);let h=v();return t.realdom.domInterceptionNoRecurse.delete(p),h},d=(p,y)=>{p.entrants.concat(p.exits).forEach(h=>{clearTimeout(t.realdom.domInterceptionRecords.get(h)?.timeout),t.realdom.domInterceptionRecords.set(h,p.event);let T=setTimeout(()=>{t.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(p.event,"timeout",{value:T,configurable:!0})}),t.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(p));let v=y();return t.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(p)),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"]},P={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((p,y)=>p.concat(y),[])).forEach(p=>{Object.keys(w).forEach(h=>{if(!w[h].includes(p))return;let T=Object.getOwnPropertyDescriptor(r[h].prototype,p);!T||(Object.defineProperty(r[h].prototype,p,"value"in T?{...T,value:y}:{...T,set:v}),P[h][p]=T)});function y(...h){let T=Object.keys(P).find(q=>this instanceof r[q]&&p in P[q]),U=P[T],H=()=>U[p].value.call(this,...h);if(t.realdom.domInterceptionNoRecurse.get(this)===p)return H();let I=[],b=[],N=this;["insertBefore"].includes(p)?b=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(p)?(b=[h[1]],["beforebegin","afterend"].includes(h[0])&&(N=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(p)?(I=[...this.childNodes],b=p==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(p)?(I=[this],b=p==="replaceWith"?[...h]:[],N=this.parentNode):["replaceChild"].includes(p)?(I=[h[1]],b=[h[0]]):["removeChild"].includes(p)?I=[...h]:(b=[...h],["before","after"].includes(p)&&(N=this.parentNode));let ee=p;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(p)){let q=this.nodeName;if(p==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return U[p].value.call(this,...h);q=this.parentNode.nodeName}let $=i.createElement(q.includes("-")?"div":q);U.setHTMLUnsafe.value.call($,b[0],p==="setHTMLUnsafe"?h[1]:{}),b=[...$.childNodes],p==="insertAdjacentHTML"?(ee="insertAdjacentElement",h[1]=new l,u(h[1],"append",()=>h[1].append(...$.childNodes))):(ee="replaceChildren",h=[...$.childNodes])}return N?d({target:N,entrants:b,exits:I,type:"interception",event:[this,p]},()=>U[ee].value.call(this,...h)):H()}function v(h){let T=Object.keys(P).find(D=>this instanceof r[D]&&p in P[D]),U=P[T],H=()=>U[p].set.call(this,h);if(this instanceof HTMLScriptElement||t.realdom.domInterceptionNoRecurse.get(this)===p)return H();let I=[],b=[],N=this;if(["outerHTML","outerText"].includes(p)?(I=[this],N=this.parentNode):this instanceof c?(N=this.content,I=[...this.content.childNodes]):I=[...this.childNodes],["outerHTML","innerHTML"].includes(p)){let D=this.nodeName;if(p==="outerHTML"){if(!this.parentNode)return H();D=this.parentNode.nodeName}let q=i.createElement(D.includes("-")?"div":D);if(u(q,p,()=>q[p]=h),b=this instanceof c?[...q.content.childNodes]:[...q.childNodes],this instanceof c&&this.hasAttribute("src")||this instanceof ShadowRoot){let $=W=>W.reduce((L,j)=>j instanceof HTMLScriptElement?L.concat(j):j instanceof c?L.concat($([j.content])):(L=L.concat($([...j.querySelectorAll?.("template")||[]].map(Ve=>Ve.content))),L.concat(...j.querySelectorAll?.("script")||[])),[]);for(let W of $(b)){if(this instanceof ShadowRoot){W.setAttribute("data-handling","manual");continue}let L=i.createElement("script");[...W.attributes].forEach(j=>L.setAttribute(j.name,j.value)),L.textContent=W.textContent,u(W,"replaceWith",()=>W.replaceWith(L))}}p==="outerHTML"?(h=new l,u(h,"append",()=>h.append(...b)),H=()=>u(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof c?H=()=>u(this.content,"replaceChildren",()=>this.content.replaceChildren(...b)):H=()=>u(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...b))}return d({target:N,entrants:b,exits:I,type:"interception",event:[this,p]},H)}}),m}function ke(){at.call(this),ut.call(this),mt.call(this)}function at(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=e=>e.replace(/([\:@\~\$\&])/g,"\\$1"))}function ut(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function mt(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(e){for(var r=(this.document||this.ownerDocument).querySelectorAll(e),t=r.length;--t>=0&&r.item(t)!==this;);return t>-1})}function De(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},ke.call(n),n.webqit.realdom.meta=(...r)=>pt.call(n,...r),n.webqit.realdom.ready=(...r)=>ye.call(n,...r),n.webqit.realdom.realtime=(r,t="dom")=>{if(t==="dom")return new Z(r,n);if(t==="attr")return new k(r,n)};let e=new Q(n);return n.webqit.realdom.schedule=(r,...t)=>e[`on${r}`](...t),n.webqit.realdom.synthesizeWhile=(...r)=>e.synthesizeWhile(...r),n.webqit.realdom}function ye(...n){let e="interactive",r;G(n[0])?(e=n[0],_(n[1])&&(r=n[1])):_(n[0])&&(r=n[0]);let t={interactive:["interactive","complete"],complete:["complete"]};if(!t[e])throw new Error(`Invalid ready-state timing: ${e}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>ye.call(this,"interactive",o)),complete:new Promise(o=>ye.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[e];if(t[e].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[e].push(r)}function pt(n){let e=this,r={},t;return(t=e.document.querySelector(`meta[name="${n}"]`))&&(r=(t.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return pe(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 t.content},json(){return JSON.parse(JSON.stringify(r))}}}function se(n,e){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof e!==void 0&&e?r.substr(1).toLowerCase():r.substr(1))})}var fe=(n,...e)=>E(n,"oohtml",...e),gt={};function Re(n,e,r){let t=this,i=De.call(t);gt.window=t,t.webqitConfig||(t.webqitConfig=i.meta("webqit").json()),t.webqit||(t.webqit={}),t.webqit.oohtml||(t.webqit.oohtml={}),t.webqit.oohtml.configs||(t.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!t.webqit.oohtml.configs[o]){t.webqit.oohtml.configs[o]={};let s=t.webqit.oohtml.configs[o];z(2,s,r,e,i.meta(n).json()),t.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(a=>{f==="api"&&typeof s[f][a]=="string"?s[f][a]=`${t.webqitConfig.prefix}${se(s[f][a])}`:["attr","elements"].includes(f)&&s[f][a]?.startsWith("data-")===!1&&(s[f][a]=`${t.webqitConfig.prefix}-${s[f][a]}`)})})}return{config:t.webqit.oohtml.configs[o],realdom:i,window:t}}var yt=()=>(0|Math.random()*9e6).toString(36),_e=new Map;function we(n){let e;return(e=_e.get(n))||(e=yt(),_e.set(n,e)),e}function Ue(n){let e;return _e.forEach((r,t)=>{r===n&&(e=t)}),e}function xe({advanced:n={},...e}){let{config:r,window:t}=Re.call(this,"scoped-js",e,{script:{retention:"retain",mimeTypes:"module|text/javascript|application/javascript",timing:"auto"},api:{scripts:"scripts"},advanced:be(n)}),i=Array.isArray(r.script.mimeTypes)?r.script.mimeTypes:r.script.mimeTypes.split("|").filter(o=>o);r.scriptSelector=i.map(o=>`script[type="${t.CSS.escape(o)}"]:not([oohtmlignore])`).concat("script:not([type])").join(","),t.webqit.oohtml.Script={compileCache:[new Map,new Map],execute:wt.bind(t,r)},_t.call(t,r),xt.call(t,r)}function _t(n){let e=this,{webqit:{nextKeyword:r,matchPrologDirective:t}}=e,i=new Map;if(n.api.scripts in e.Element.prototype)throw new Error(`The "Element" class already has a "${n.api.scripts}" property!`);[e.ShadowRoot.prototype,e.Element.prototype].forEach(o=>{Object.defineProperty(o,n.api.scripts,{get:function(){return i.has(this)||i.set(this,[]),i.get(this)}})}),Object.defineProperties(e.HTMLScriptElement.prototype,{scoped:{configurable:!0,get(){return this.hasAttribute("scoped")},set(o){this.toggleAttribute("scoped",o)}},live:{configurable:!0,get(){if(this.liveProgramHandle)return!0;let o=r(this.oohtml__textContent||this.textContent||"",0,0);return t(o,!0)}}})}async function wt(n,e){let r=this,{realdom:t}=r.webqit,i=Ue(e);if(!i)throw new Error("Argument must be a valid exec hash.");let{script:o,compiledScript:s,thisContext:f}=i;n.script.retention==="dispose"?o.remove():n.script.retention==="hidden"?o.textContent='"source hidden"':setTimeout(async()=>{o.textContent=await s.toString()},0);let a=o.scoped?f:o.getRootNode();fe(a).has("scriptEnv")||fe(a).set("scriptEnv",Object.create(null));let c=await(await s.bind(f,fe(a).get("scriptEnv"))).execute();o.live&&Object.defineProperty(o,"liveProgramHandle",{value:c}),t.realtime(r.document).observe(o,()=>{o.live&&c.abort(),f instanceof r.Element&&f[n.api.scripts]?.splice(f[n.api.scripts].indexOf(o,1))},{id:"scoped-js:script-exits",subtree:"cross-roots",timing:"sync",generation:"exits"})}function xt(n){let e=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1,r=this,{webqit:{oohtml:t,realdom:i}}=r;r.HTMLScriptElement.supports||(r.HTMLScriptElement.supports=s=>["text/javascript","application/javascript"].includes(s));let o=new WeakSet;i.realtime(r.document).query(n.scriptSelector,s=>{s.entrants.forEach(f=>{if(o.has(f)||f.hasAttribute("oohtmlno")||!e&&!f.hasAttribute("ssr"))return;let a=bt.call(r,n,f);if(!a)return;o.add(f);let c=f.scoped?f.parentNode||s.target:f.type==="module"?void 0:r;f.scoped&&c[n.api.scripts].push(f);let l=we({script:f,compiledScript:a,thisContext:c});s.type==="query"||f.type&&!r.HTMLScriptElement.supports(f.type)||f.getAttribute("data-handling")==="manual"||n.script.timing==="manual"?t.Script.execute(l):f.textContent=`webqit.oohtml.Script.execute( '${l}' );`})},{id:"scoped-js:script-entries",live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants",eventDetails:!0})}function bt(n,e){let r=this,{webqit:{oohtml:t,LiveScript:i,AsyncLiveScript:o,LiveModule:s}}=r,f=e.textContent.trim();if(f.startsWith("/*@oohtml*/if(false){")&&f.endsWith("}/*@oohtml*/")&&(f=f.slice(21,-12),Object.defineProperty(e,"oohtml__textContent",{value:f})),!f.trim().length)return;let a=we(f),c=t.Script.compileCache[e.live?0:1],l;if(!(l=c.get(a))){let{parserParams:m,compilerParams:u,runtimeParams:d}=n.advanced;l=new(e.type==="module"?s:i||o)(f,{liveMode:e.live,exportNamespace:`#${e.id}`,fileName:`${r.document.url?.split("#")?.[0]||""}#${e.id}`,parserParams:m,compilerParams:u,runtimeParams:d}),c.set(a,l)}return l}xe.call(window);
1
+ // node_modules/@webqit/use-live/src/params.js
2
+ function resolveParams(...extensions) {
3
+ let extension, params = { runtimeParams, transformerParams, parserParams };
4
+ while (extension = extensions.shift()) {
5
+ const {
6
+ runtimeParams: _runtimeParams = {},
7
+ transformerParams: { globalsNoObserve: _globalsNoObserve = [], globalsOnlyPathsExcept: _globalsOnlyPathsExcept = [], ..._transformerParams } = {},
8
+ parserParams: _parserParams = {}
9
+ } = extension;
10
+ params = {
11
+ runtimeParams: { ...params.runtimeParams, ..._runtimeParams },
12
+ transformerParams: { ...params.transformerParams, globalsNoObserve: [...params.transformerParams.globalsNoObserve, ..._globalsNoObserve], globalsOnlyPathsExcept: [...params.transformerParams.globalsOnlyPathsExcept, ..._globalsOnlyPathsExcept], ..._transformerParams },
13
+ parserParams: { ...params.parserParams, ..._parserParams }
14
+ };
15
+ if (extensions.devMode) {
16
+ }
17
+ }
18
+ return params;
19
+ }
20
+ var parserParams = {
21
+ ecmaVersion: "latest",
22
+ allowReturnOutsideFunction: true,
23
+ allowAwaitOutsideFunction: false,
24
+ allowSuperOutsideMethod: false,
25
+ preserveParens: false,
26
+ locations: true
27
+ };
28
+ var transformerParams = {
29
+ globalsNoObserve: ["arguments", "debugger"],
30
+ globalsOnlyPathsExcept: [],
31
+ originalSource: true,
32
+ locations: true,
33
+ compact: 2
34
+ };
35
+ var runtimeParams = {
36
+ apiVersion: 3
37
+ };
38
+
39
+ // node_modules/@webqit/util/js/isObject.js
40
+ function isObject_default(val) {
41
+ return !Array.isArray(val) && typeof val === "object" && val;
42
+ }
43
+
44
+ // node_modules/@webqit/util/js/isArray.js
45
+ function isArray_default(val) {
46
+ return Array.isArray(val);
47
+ }
48
+
49
+ // node_modules/@webqit/util/js/isTypeFunction.js
50
+ function isTypeFunction_default(val) {
51
+ return typeof val === "function";
52
+ }
53
+
54
+ // node_modules/@webqit/util/js/isNull.js
55
+ function isNull_default(val) {
56
+ return val === null || val === "";
57
+ }
58
+
59
+ // node_modules/@webqit/util/js/isUndefined.js
60
+ function isUndefined_default(val) {
61
+ return arguments.length && (val === void 0 || typeof val === "undefined");
62
+ }
63
+
64
+ // node_modules/@webqit/util/js/isTypeObject.js
65
+ function isTypeObject_default(val) {
66
+ return Array.isArray(val) || typeof val === "object" && val || isTypeFunction_default(val);
67
+ }
68
+
69
+ // node_modules/@webqit/util/js/isEmpty.js
70
+ function isEmpty_default(val) {
71
+ return isNull_default(val) || isUndefined_default(val) || val === false || val === 0 || isTypeObject_default(val) && !Object.keys(val).length;
72
+ }
73
+
74
+ // node_modules/@webqit/util/js/isFunction.js
75
+ function isFunction_default(val) {
76
+ return isTypeFunction_default(val) || val && {}.toString.call(val) === "[object function]";
77
+ }
78
+
79
+ // node_modules/@webqit/util/js/isNumber.js
80
+ function isNumber_default(val) {
81
+ return val instanceof Number || typeof val === "number";
82
+ }
83
+
84
+ // node_modules/@webqit/util/js/isNumeric.js
85
+ function isNumeric_default(val) {
86
+ return isNumber_default(val) || val !== true && val !== false && val !== null && val !== "" && !isNaN(val * 1);
87
+ }
88
+
89
+ // node_modules/@webqit/util/js/isString.js
90
+ function isString_default(val) {
91
+ return val instanceof String || typeof val === "string" && val !== null;
92
+ }
93
+
94
+ // node_modules/@webqit/util/js/isTypeArray.js
95
+ function isTypeArray_default(val) {
96
+ return !isString_default(val) && !isUndefined_default(val.length);
97
+ }
98
+
99
+ // node_modules/@webqit/util/arr/pushUnique.js
100
+ function pushUnique_default(arr, ...items) {
101
+ items.forEach((itm) => {
102
+ if (arr.indexOf(itm) < 0) {
103
+ arr.push(itm);
104
+ }
105
+ });
106
+ return arr;
107
+ }
108
+
109
+ // node_modules/@webqit/util/obj/getPrototypeChain.js
110
+ function getPrototypeChain_default(obj, until) {
111
+ until = until || Object.prototype;
112
+ until = until && !isArray_default(until) ? [until] : until;
113
+ var prototypalChain = [];
114
+ var obj = obj;
115
+ while (obj && (!until || until.indexOf(obj) < 0) && obj.name !== "default") {
116
+ prototypalChain.push(obj);
117
+ obj = obj ? Object.getPrototypeOf(obj) : null;
118
+ }
119
+ return prototypalChain;
120
+ }
121
+
122
+ // node_modules/@webqit/util/obj/getAllPropertyNames.js
123
+ function getAllPropertyNames_default(obj, until) {
124
+ var keysAll = [];
125
+ getPrototypeChain_default(obj, until).forEach((obj2) => {
126
+ pushUnique_default(keysAll, ...Object.getOwnPropertyNames(obj2));
127
+ });
128
+ return keysAll;
129
+ }
130
+
131
+ // node_modules/@webqit/util/obj/mergeCallback.js
132
+ function mergeCallback(objs, callback, deepProps = false, isReplace = false, withSymbols = false) {
133
+ var depth = 0;
134
+ var obj1 = objs.shift();
135
+ if (isNumeric_default(obj1) || obj1 === true || obj1 === false) {
136
+ depth = obj1;
137
+ obj1 = objs.shift();
138
+ }
139
+ if (!objs.length) {
140
+ throw new Error("_merge() requires two or more array/objects.");
141
+ }
142
+ objs.forEach((obj2, i) => {
143
+ if (!isTypeObject_default(obj2) && !isFunction_default(obj2)) {
144
+ return;
145
+ }
146
+ (deepProps ? getAllPropertyNames_default(obj2) : Object.keys(obj2)).forEach((key) => {
147
+ if (!callback(key, obj1, obj2, i)) {
148
+ return;
149
+ }
150
+ var valAtObj1 = obj1[key];
151
+ var valAtObj2 = obj2[key];
152
+ if ((isArray_default(valAtObj1) && isArray_default(valAtObj2) || isObject_default(valAtObj1) && isObject_default(valAtObj2)) && (depth === true || depth > 0)) {
153
+ obj1[key] = isArray_default(valAtObj1) && isArray_default(valAtObj2) ? [] : {};
154
+ mergeCallback([isNumeric_default(depth) ? depth - 1 : depth, obj1[key], valAtObj1, valAtObj2], callback, deepProps, isReplace, withSymbols);
155
+ } else {
156
+ if (isArray_default(obj1) && isArray_default(obj2)) {
157
+ if (isReplace) {
158
+ obj1[key] = valAtObj2;
159
+ } else {
160
+ obj1.push(valAtObj2);
161
+ }
162
+ } else {
163
+ try {
164
+ if (withSymbols) {
165
+ Object.defineProperty(obj1, key, Object.getOwnPropertyDescriptor(obj2, key));
166
+ } else {
167
+ obj1[key] = obj2[key];
168
+ }
169
+ } catch (e) {
170
+ }
171
+ }
172
+ }
173
+ });
174
+ });
175
+ return obj1;
176
+ }
177
+
178
+ // node_modules/@webqit/util/obj/merge.js
179
+ function merge_default(...objs) {
180
+ return mergeCallback(objs, (k, obj1, obj2) => {
181
+ return true;
182
+ }, false, false, false);
183
+ }
184
+
185
+ // node_modules/@webqit/util/js/wq.js
186
+ function wq(obj, ...namespaces) {
187
+ if (!obj || !["object", "function"].includes(typeof obj)) {
188
+ throw new Error(`Argument #1 must be of type object`);
189
+ }
190
+ let wq2 = obj[Symbol.for("wq")];
191
+ if (!wq2) {
192
+ wq2 = new WQInternals();
193
+ Object.defineProperty(obj, Symbol.for("wq"), {
194
+ value: wq2,
195
+ enumerable: false,
196
+ configurable: false,
197
+ writable: false
198
+ });
199
+ }
200
+ if (!namespaces.length) {
201
+ return wq2;
202
+ }
203
+ let _ns, _wq2;
204
+ while (_ns = namespaces.shift()) {
205
+ if ((_wq2 = wq2) && !(wq2 = wq2.get(_ns))) {
206
+ wq2 = new WQInternals();
207
+ _wq2.set(_ns, wq2);
208
+ }
209
+ }
210
+ return wq2;
211
+ }
212
+ var WQInternals = class extends Map {
213
+ };
214
+
215
+ // node_modules/@webqit/util/arr/from.js
216
+ function from_default(val, castObject = true) {
217
+ if (isArray_default(val)) {
218
+ return val;
219
+ }
220
+ ;
221
+ if (!castObject && isObject_default(val)) {
222
+ return [val];
223
+ }
224
+ ;
225
+ if (val !== false && val !== 0 && isEmpty_default(val)) {
226
+ return [];
227
+ }
228
+ ;
229
+ if (isTypeArray_default(val)) {
230
+ return Array.prototype.slice.call(val);
231
+ }
232
+ ;
233
+ if (isObject_default(val)) {
234
+ return Object.values(val);
235
+ }
236
+ ;
237
+ return [val];
238
+ }
239
+
240
+ // node_modules/@webqit/util/obj/get.js
241
+ function get_default(ctxt, path, trap = {}, reciever = {}) {
242
+ path = from_default(path).slice();
243
+ var _ctxt = ctxt;
244
+ while (!isUndefined_default(_ctxt) && !isNull_default(_ctxt) && path.length) {
245
+ var _key = path.shift();
246
+ if (!(trap.get ? trap.get(_ctxt, _key) : isTypeObject_default(_ctxt) ? _key in _ctxt : _ctxt[_key])) {
247
+ reciever.exists = false;
248
+ return;
249
+ }
250
+ _ctxt = trap.get ? trap.get(_ctxt, _key) : _ctxt[_key];
251
+ }
252
+ reciever.exists = true;
253
+ return _ctxt;
254
+ }
255
+
256
+ // node_modules/@webqit/util/obj/set.js
257
+ function set_default(obj, path, val, buildTree = {}, trap = {}) {
258
+ const _set = (target2, key, val2) => {
259
+ if (trap.set) {
260
+ return trap.set(target2, key, val2);
261
+ } else {
262
+ if (isNumeric_default(path[i]) && isArray_default(target2)) {
263
+ target2.push(val2);
264
+ } else {
265
+ target2[key] = val2;
266
+ }
267
+ return true;
268
+ }
269
+ };
270
+ path = from_default(path);
271
+ var target = obj;
272
+ for (var i = 0; i < path.length; i++) {
273
+ if (i < path.length - 1) {
274
+ if (!target || !isTypeObject_default(target) && !isFunction_default(target)) {
275
+ return false;
276
+ }
277
+ var branch = get_default(target, path[i], trap);
278
+ if (!isTypeObject_default(branch)) {
279
+ if (trap.buildTree === false) {
280
+ return false;
281
+ }
282
+ branch = isFunction_default(trap.buildTree) ? trap.buildTree(i) : isNumeric_default(path[i + 1]) ? [] : {};
283
+ var branchSuccess = _set(target, path[i], branch);
284
+ if (!branchSuccess) {
285
+ return false;
286
+ }
287
+ }
288
+ target = branch;
289
+ } else {
290
+ return _set(target, path[i], val);
291
+ }
292
+ }
293
+ }
294
+
295
+ // node_modules/@webqit/realdom/src/Scheduler.js
296
+ var Scheduler = class {
297
+ constructor(window2, synthesis = false) {
298
+ Object.defineProperty(this, "window", { value: window2 });
299
+ Object.defineProperty(this, "readCallbacks", { value: /* @__PURE__ */ new Set() });
300
+ Object.defineProperty(this, "writeCallbacks", { value: /* @__PURE__ */ new Set() });
301
+ Object.defineProperty(this, "_synthesis", { value: 0, writable: true });
302
+ if (!synthesis && this.window.requestAnimationFrame) {
303
+ this._loop();
304
+ } else {
305
+ this._synthesis++;
306
+ }
307
+ }
308
+ get synthesis() {
309
+ return this._synthesis;
310
+ }
311
+ async synthesizeWhile(callback) {
312
+ this._synthesis++;
313
+ this._fulfill();
314
+ const returnValue = await callback();
315
+ this._synthesis--;
316
+ return returnValue;
317
+ }
318
+ _fulfill() {
319
+ for (const callback of this.readCallbacks) {
320
+ callback();
321
+ this.readCallbacks.delete(callback);
322
+ }
323
+ for (const callback of this.writeCallbacks) {
324
+ callback();
325
+ this.writeCallbacks.delete(callback);
326
+ }
327
+ }
328
+ _loop() {
329
+ this.window.requestAnimationFrame(() => {
330
+ this._fulfill();
331
+ this._loop();
332
+ });
333
+ }
334
+ onread(callback, withPromise = false) {
335
+ if (withPromise) {
336
+ return new Promise((resolve) => {
337
+ if (this.synthesis) {
338
+ resolve(callback());
339
+ } else {
340
+ this.readCallbacks.add(() => {
341
+ resolve(callback());
342
+ });
343
+ }
344
+ });
345
+ }
346
+ if (this.synthesis) {
347
+ Promise.resolve().then(callback);
348
+ } else {
349
+ this.readCallbacks.add(callback);
350
+ }
351
+ }
352
+ onwrite(callback, withPromise = false) {
353
+ if (withPromise) {
354
+ return new Promise((resolve) => {
355
+ if (this.synthesis) {
356
+ resolve(callback());
357
+ } else {
358
+ this.writeCallbacks.add(() => {
359
+ resolve(callback());
360
+ });
361
+ }
362
+ });
363
+ }
364
+ if (this.synthesis) {
365
+ Promise.resolve().then(callback);
366
+ } else {
367
+ this.writeCallbacks.add(callback);
368
+ }
369
+ }
370
+ cycle(onread, onwrite, prevTransaction) {
371
+ this.onread(() => {
372
+ const readReturn = onread(prevTransaction);
373
+ const callWrite = (readReturn2) => {
374
+ if (readReturn2 === void 0)
375
+ return;
376
+ this.onwrite(() => {
377
+ const writeReturn = onwrite(readReturn2, prevTransaction);
378
+ const repeatTransaction = (writeReturn2) => {
379
+ if (writeReturn2 === void 0)
380
+ return;
381
+ this.cycle(onread, onwrite, writeReturn2);
382
+ };
383
+ if (writeReturn instanceof Promise) {
384
+ writeReturn.then(repeatTransaction);
385
+ } else {
386
+ repeatTransaction(writeReturn);
387
+ }
388
+ });
389
+ };
390
+ if (readReturn instanceof Promise) {
391
+ readReturn.then(callWrite);
392
+ } else {
393
+ callWrite(readReturn);
394
+ }
395
+ });
396
+ }
397
+ };
398
+
399
+ // node_modules/@webqit/realdom/src/realtime/Util.js
400
+ function isXpath(expr) {
401
+ return (expr = expr.trim()) && expr.startsWith("(") && expr.endsWith(")");
402
+ }
403
+ function xpathQuery(window2, context, expr, subtree = true) {
404
+ expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", subtree ? "(.//" : "(./")).join("|");
405
+ let nodes = [], node;
406
+ try {
407
+ const result = window2.document.evaluate(expr, context, null, window2.XPathResult.ANY_TYPE);
408
+ while (node = result.iterateNext())
409
+ nodes.push(node);
410
+ } catch (e) {
411
+ }
412
+ return nodes;
413
+ }
414
+ function xpathMatch(window2, node, expr) {
415
+ expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", "(self::")).join("|");
416
+ try {
417
+ return window2.document.evaluate(`${expr}`, node, null, window2.XPathResult.BOOLEAN_TYPE).booleanValue;
418
+ } catch (e) {
419
+ }
420
+ }
421
+ function containsNode(window2, a, b, crossRoots = false, testCache = null) {
422
+ const prevTest = testCache?.get(a)?.get(b);
423
+ if (typeof prevTest !== "undefined")
424
+ return prevTest;
425
+ const response = (val) => {
426
+ if (!testCache?.has(a))
427
+ testCache?.set(a, /* @__PURE__ */ new WeakMap());
428
+ testCache?.get(a)?.set(b, val);
429
+ return val;
430
+ };
431
+ const rootNodeA = a.getRootNode();
432
+ const rootNodeB = b.getRootNode();
433
+ if (rootNodeA === rootNodeB)
434
+ return response(a.contains(b));
435
+ if (crossRoots && rootNodeB instanceof window2.ShadowRoot)
436
+ return response(containsNode(window2, a, rootNodeB.host, crossRoots, testCache));
437
+ return response(false);
438
+ }
439
+ function splitOuter(str, delim = "|") {
440
+ return [...str].reduce(([quote, depth, splits, skip], x) => {
441
+ if (!quote && depth === 0 && (Array.isArray(delim) ? delim : [delim]).includes(x)) {
442
+ return [quote, depth, [""].concat(splits)];
443
+ }
444
+ if (!quote && ["(", "[", "{"].includes(x) && !splits[0].endsWith("\\"))
445
+ depth++;
446
+ if (!quote && [")", "]", "}"].includes(x) && !splits[0].endsWith("\\"))
447
+ depth--;
448
+ if (['"', "'", "`"].includes(x) && !splits[0].endsWith("\\")) {
449
+ quote = quote === x ? null : quote || x;
450
+ }
451
+ splits[0] += x;
452
+ return [quote, depth, splits];
453
+ }, [null, 0, [""]])[2].reverse();
454
+ }
455
+
456
+ // node_modules/@webqit/realdom/src/realtime/DOMSpec.js
457
+ var DOMSpec = class {
458
+ constructor(content) {
459
+ this.content = content;
460
+ this.type = typeof content === "string" ? "selector" : "instance";
461
+ this.kind = this.type === "instance" ? null : isXpath(content) ? "xpath" : "css";
462
+ if (this.kind === "xpath") {
463
+ this.isXpathAttr = splitOuter(content.trim().slice(1, -1), "@").length > 1;
464
+ }
465
+ }
466
+ toString() {
467
+ return this.content;
468
+ }
469
+ };
470
+
471
+ // node_modules/@webqit/realdom/src/realtime/Realtime.js
472
+ var Realtime = class {
473
+ constructor(context, namespace, window2) {
474
+ this.context = context;
475
+ this.namespace = namespace;
476
+ this.window = context.defaultView || context.ownerDocument?.defaultView || window2;
477
+ this.document = this.window.document;
478
+ this.webqit = this.window.webqit;
479
+ Object.defineProperty(this, "#", { value: {} });
480
+ }
481
+ resolveArgs(args) {
482
+ if (isFunction_default(args[0])) {
483
+ args = [[], ...args];
484
+ } else if (isObject_default(args[0]) && !(args[0] instanceof DOMSpec) && args.length === 1) {
485
+ args = [[], void 0, args[0]];
486
+ } else if (isObject_default(args[1]) && args.length === 2) {
487
+ args = [from_default(args[0], false), void 0, args[1]];
488
+ } else {
489
+ args[0] = from_default(args[0], false);
490
+ }
491
+ if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !(x instanceof this.window.Node)).length) {
492
+ throw new Error(`Argument #2 must be either a string or a Node object, or a list of those.`);
493
+ }
494
+ args[0] = args[0].map((s) => s instanceof DOMSpec ? s : new DOMSpec(s));
495
+ return args;
496
+ }
497
+ registry(...args) {
498
+ return wq(this.window, "realdom", this.namespace, ...args);
499
+ }
500
+ createSignalGenerator() {
501
+ return {
502
+ generate() {
503
+ this.lastController?.abort();
504
+ this.lastController = new AbortController();
505
+ const flags = { signal: this.lastController.signal };
506
+ return flags;
507
+ },
508
+ disconnect() {
509
+ this.lastController?.abort();
510
+ }
511
+ };
512
+ }
513
+ forEachMatchingContext(interceptionTiming, record_s, callback) {
514
+ const { window: window2 } = this, deferreds = /* @__PURE__ */ new Set(), testCache = /* @__PURE__ */ new WeakMap();
515
+ for (const [registration, deferred] of this.registry(interceptionTiming)) {
516
+ let $records = [].concat(record_s).filter((record) => containsNode(window2, registration.context, record.target, registration.params.subtree === "cross-roots", testCache));
517
+ if (!$records.length)
518
+ continue;
519
+ const args = [registration, Array.isArray(record_s) ? $records : $records[0]];
520
+ if (deferred)
521
+ deferreds.add(args);
522
+ else
523
+ callback.call(window2, ...args);
524
+ }
525
+ for (const args of deferreds)
526
+ callback.call(window2, ...args);
527
+ deferreds.clear();
528
+ }
529
+ disconnectables(signal, ...objects) {
530
+ const disconnectable = { disconnect() {
531
+ objects.forEach((d) => d && isFunction_default(d.disconnect) && d.disconnect() || isFunction_default(d) && d() || isObject_default(d) && (d.disconnected = true));
532
+ } };
533
+ if (signal)
534
+ signal.addEventListener("abort", () => disconnectable.disconnect());
535
+ return disconnectable;
536
+ }
537
+ };
538
+
539
+ // node_modules/@webqit/realdom/src/realtime/AttrRealtime.js
540
+ var AttrRealtime = class extends Realtime {
541
+ type = "attr";
542
+ constructor(context, ...args) {
543
+ super(context, "attr", ...args);
544
+ }
545
+ get(spec, callback = void 0, params = {}) {
546
+ const originalFilterIsString = typeof spec === "string" || spec instanceof DOMSpec;
547
+ [spec = [], callback = void 0, params = {}] = this.resolveArgs(arguments);
548
+ const { context } = this;
549
+ const records = attrIntersection(context, spec);
550
+ if (!callback)
551
+ return records;
552
+ const signalGenerator = params.lifecycleSignals && this.createSignalGenerator();
553
+ if (!originalFilterIsString) {
554
+ const flags = signalGenerator?.generate() || {};
555
+ callback(records, flags, context);
556
+ } else {
557
+ for (const record of records) {
558
+ const flags = signalGenerator ? signalGenerator.generate() : {};
559
+ callback(record, flags, context);
560
+ }
561
+ }
562
+ if (params.live) {
563
+ if (signalGenerator) {
564
+ params = { ...params, signalGenerator };
565
+ }
566
+ const disconnectable_live = this.observe(originalFilterIsString ? spec[0] : spec, callback, { newValue: true, ...params });
567
+ return this.disconnectables(params.signal, disconnectable_live);
568
+ }
569
+ }
570
+ observe(spec, callback, params = {}) {
571
+ const originalFilterIsString = typeof spec === "string" || spec instanceof DOMSpec;
572
+ [spec = [], callback, params = {}] = this.resolveArgs(arguments);
573
+ if (["sync", "intercept"].includes(params.timing))
574
+ return this.observeSync(originalFilterIsString ? spec[0] : spec, callback, params);
575
+ if (params.timing && params.timing !== "async")
576
+ throw new Error(`Timing option "${params.timing}" invalid.`);
577
+ const { context, window: window2, webqit } = this;
578
+ if (params.eventDetails && !webqit.realdom.attrInterceptionHooks?.intercepting) {
579
+ attrInterception.call(window2, "intercept", () => {
580
+ });
581
+ }
582
+ const disconnectable = new window2.MutationObserver((records) => {
583
+ records = dedupAndIgnoreInternals(records).map((rcd) => withAttrEventDetails.call(window2, rcd));
584
+ dispatch.call(window2, registration, records, context);
585
+ });
586
+ const $params = { attributes: true, attributeOldValue: params.oldValue, subtree: params.subtree && true };
587
+ if (spec.length) {
588
+ $params.attributeFilter = spec.map((a) => a + "");
589
+ }
590
+ disconnectable.observe(context, $params);
591
+ const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
592
+ const registration = { context, spec, callback, params, atomics: /* @__PURE__ */ new Map(), originalFilterIsString, signalGenerator, disconnectable };
593
+ return this.disconnectables(params.signal, disconnectable, signalGenerator);
594
+ }
595
+ observeSync(spec, callback, params = {}) {
596
+ const originalFilterIsString = typeof spec === "string" || spec instanceof DOMSpec;
597
+ [spec, callback, params = {}] = this.resolveArgs(arguments);
598
+ const { context, window: window2 } = this;
599
+ if (params.timing && !["sync", "intercept"].includes(params.timing))
600
+ throw new Error(`Timing option "${params.timing}" invalid.`);
601
+ const interceptionTiming = params.timing === "intercept" ? "intercept" : "sync";
602
+ if (!this.registry(interceptionTiming).size) {
603
+ attrInterception.call(window2, interceptionTiming, (records) => {
604
+ this.forEachMatchingContext(interceptionTiming, records, dispatch);
605
+ });
606
+ }
607
+ const disconnectable = { disconnect() {
608
+ registry.delete(registration);
609
+ } };
610
+ const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
611
+ const registration = { context, spec, callback, params, atomics: /* @__PURE__ */ new Map(), originalFilterIsString, signalGenerator, disconnectable };
612
+ const registry = this.registry(interceptionTiming);
613
+ registry.set(registration, !!registration.params.deferred);
614
+ return this.disconnectables(params.signal, disconnectable, signalGenerator);
615
+ }
616
+ };
617
+ function dedupAndIgnoreInternals(records) {
618
+ return records.reduce((rcds, rcd, i) => {
619
+ if (rcds[i - 1]?.attributeName === rcd.attributeName)
620
+ return rcds;
621
+ if (wq(rcd.target, "realdom", "internalAttrInteractions").get(rcd.attributeName))
622
+ return rcds;
623
+ return rcds.concat(rcd);
624
+ }, []);
625
+ }
626
+ function dispatch(registration, records) {
627
+ const { context, spec, callback, params, atomics, originalFilterIsString, signalGenerator } = registration;
628
+ if (!params.subtree) {
629
+ records = records.filter((r) => {
630
+ return r.target === context;
631
+ });
632
+ }
633
+ if (!records.length)
634
+ return;
635
+ const $spec = spec.map((a) => a + "");
636
+ if (params.atomic && !atomics.size) {
637
+ records = attrIntersection(context, spec, records);
638
+ } else if (params.timing !== "async" && spec.length) {
639
+ records = records.filter((r) => $spec.includes(r.name));
640
+ }
641
+ if (!records.length)
642
+ return;
643
+ if (!(params.newValue === null && params.oldValue === null && params.eventDetails)) {
644
+ records = records.map((rcd) => {
645
+ let exclusion;
646
+ if (!params.eventDetails) {
647
+ ({ event: exclusion, ...rcd } = rcd);
648
+ }
649
+ if (!params.oldValue && "oldValue" in rcd) {
650
+ ({ oldValue: exclusion, ...rcd } = rcd);
651
+ }
652
+ if (!params.newValue && "value" in rcd) {
653
+ ({ value: exclusion, ...rcd } = rcd);
654
+ } else if (params.newValue && typeof rcd.value === "undefined") {
655
+ rcd = { ...rcd, value: internalAttrInteraction(rcd.target, rcd.name, () => rcd.target.getAttribute(rcd.name)) };
656
+ }
657
+ return rcd;
658
+ });
659
+ }
660
+ if (params.atomic) {
661
+ records.forEach((record) => atomics.set(record.name, record));
662
+ records = Array.from(atomics.entries()).map(([, value]) => value);
663
+ }
664
+ const record_s = originalFilterIsString ? records[0] : records;
665
+ const flags = signalGenerator ? signalGenerator.generate() : {};
666
+ callback(record_s, flags, context);
667
+ }
668
+ function internalAttrInteraction(node, attrName, callback) {
669
+ const savedAttrLocking = wq(node, "realdom", "internalAttrInteractions").get(attrName);
670
+ wq(node, "realdom", "internalAttrInteractions").set(attrName, true);
671
+ const value = callback();
672
+ wq(node, "realdom", "internalAttrInteractions").set(attrName, savedAttrLocking);
673
+ return value;
674
+ }
675
+ function attrIntersection(context, spec, records = []) {
676
+ const _type = { event: null, type: "attribute" };
677
+ if (spec.length) {
678
+ return spec.map((attrName) => {
679
+ attrName = attrName + "";
680
+ return records.find((r) => r.name === attrName) || { target: context, name: attrName, value: internalAttrInteraction(context, attrName, () => context.getAttribute(attrName)), ..._type };
681
+ });
682
+ }
683
+ const attrs = Array.from(context.attributes);
684
+ return attrs.map((attr) => {
685
+ return records.find((r) => r.name === attr.nodeName) || { target: context, name: attr.nodeName, value: internalAttrInteraction(context, attr.nodeName, () => attr.nodeValue), ..._type };
686
+ });
687
+ }
688
+ function withAttrEventDetails({ target, attributeName, value, oldValue }) {
689
+ const window2 = this, registry = window2.webqit.realdom.attrInterceptionRecords?.get(target) || {};
690
+ const event = registry[attributeName]?.[0] || "mutation";
691
+ const record = { target, name: attributeName, value, oldValue, type: "observation", event };
692
+ return record;
693
+ }
694
+ function attrInterception(timing, callback) {
695
+ const window2 = this;
696
+ const { webqit, document, Element } = window2;
697
+ if (!webqit.realdom.attrInterceptionHooks) {
698
+ Object.defineProperty(webqit.realdom, "attrInterceptionHooks", { value: /* @__PURE__ */ new Map() });
699
+ }
700
+ if (!webqit.realdom.attrInterceptionHooks.has(timing)) {
701
+ webqit.realdom.attrInterceptionHooks.set(timing, /* @__PURE__ */ new Set());
702
+ }
703
+ webqit.realdom.attrInterceptionHooks.get(timing).add(callback);
704
+ const rm = () => webqit.realdom.attrInterceptionHooks.get(timing).delete(callback);
705
+ if (webqit.realdom.attrInterceptionHooks?.intercepting)
706
+ return rm;
707
+ console.warn(`Attr mutation APIs are now being intercepted.`);
708
+ webqit.realdom.attrInterceptionHooks.intercepting = true;
709
+ Object.defineProperty(webqit.realdom, "attrInterceptionRecords", { value: /* @__PURE__ */ new Map() });
710
+ const attrIntercept = (record, defaultAction) => {
711
+ if (!webqit.realdom.attrInterceptionRecords.has(record.target)) {
712
+ webqit.realdom.attrInterceptionRecords.set(record.target, {});
713
+ }
714
+ const registry = webqit.realdom.attrInterceptionRecords.get(record.target);
715
+ registry[record.name] = registry[record.name] || [];
716
+ registry[record.name].unshift(record.event);
717
+ if (wq(record.target, "realdom", "internalAttrInteractions").get(record.name))
718
+ return defaultAction();
719
+ webqit.realdom.attrInterceptionHooks.get("intercept")?.forEach((callback2) => callback2([record]));
720
+ const returnValue = defaultAction();
721
+ webqit.realdom.attrInterceptionHooks.get("sync")?.forEach((callback2) => callback2([record]));
722
+ return returnValue;
723
+ };
724
+ const mo = new window2.MutationObserver((records) => {
725
+ records = records.filter((rcd) => {
726
+ const registry = window2.webqit.realdom.attrInterceptionRecords?.get(rcd.target) || {};
727
+ return !registry[rcd.attributeName]?.shift();
728
+ });
729
+ records = dedupAndIgnoreInternals(records).map((rcd) => withAttrEventDetails.call(window2, rcd));
730
+ if (!records.length)
731
+ return;
732
+ webqit.realdom.attrInterceptionHooks.get("intercept")?.forEach((callback2) => callback2(records));
733
+ webqit.realdom.attrInterceptionHooks.get("sync")?.forEach((callback2) => callback2(records));
734
+ });
735
+ mo.observe(document, { attributes: true, subtree: true, attributeOldValue: true });
736
+ const originalApis = /* @__PURE__ */ Object.create(null);
737
+ ["setAttribute", "removeAttribute", "toggleAttribute"].forEach((apiName) => {
738
+ originalApis[apiName] = Element.prototype[apiName];
739
+ Element.prototype[apiName] = function(...args) {
740
+ let value, oldValue = internalAttrInteraction(this, args[0], () => this.getAttribute(args[0]));
741
+ if (["setAttribute", "toggleAttribute"].includes(apiName)) {
742
+ value = args[1];
743
+ }
744
+ if (apiName === "toggleAttribute" && value === void 0) {
745
+ value = oldValue === null ? true : false;
746
+ }
747
+ const record = { target: this, name: args[0], value, oldValue, type: "interception", event: [this, apiName] };
748
+ const exec = () => originalApis[apiName].call(this, ...args);
749
+ return attrIntercept(record, exec);
750
+ };
751
+ });
752
+ return rm;
753
+ }
754
+
755
+ // node_modules/@webqit/realdom/src/realtime/DOMRealtime.js
756
+ var DOMRealtime = class extends Realtime {
757
+ constructor(context, ...args) {
758
+ super(context, "tree", ...args);
759
+ }
760
+ attr(filter, callback = void 0, params = {}) {
761
+ const { context, window: window2 } = this;
762
+ return new AttrRealtime(context, window2).get(...arguments);
763
+ }
764
+ query(spec, callback = void 0, params = {}) {
765
+ [spec, callback = void 0, params = {}] = this.resolveArgs(arguments);
766
+ const { context } = this;
767
+ const records = /* @__PURE__ */ new Map(), getRecord = (target) => {
768
+ if (!records.has(target)) {
769
+ records.set(target, { target, entrants: [], exits: [], type: "query", event: null });
770
+ }
771
+ return records.get(target);
772
+ };
773
+ if (!params.generation || params.generation === "entrants") {
774
+ if (!spec.length) {
775
+ [...context.children].forEach((node) => getRecord(context).entrants.push(node));
776
+ } else if (spec.every((s) => s.type === "selector")) {
777
+ const [cssSelectors, xpathQueries] = spec.reduce(([css, xpath], s) => {
778
+ return s.kind === "xpath" ? [css, xpath.concat(s)] : [css.concat(s), xpath];
779
+ }, [[], []]);
780
+ const matches = [];
781
+ if (params.subtree) {
782
+ if (cssSelectors.length) {
783
+ matches.push(...context.querySelectorAll(cssSelectors.join(",")));
784
+ }
785
+ if (xpathQueries.length) {
786
+ matches.push(...xpathQuery(this.window, context, xpathQueries));
787
+ }
788
+ } else {
789
+ if (cssSelectors.length) {
790
+ matches.push(...[...context.children].filter((node) => node.matches(cssSelectors)));
791
+ }
792
+ if (xpathQueries.length) {
793
+ matches.push(...xpathQuery(this.window, context, xpathQueries, false));
794
+ }
795
+ }
796
+ matches.forEach((node) => getRecord(node.parentNode || context).entrants.push(node));
797
+ }
798
+ }
799
+ if (!callback)
800
+ return records;
801
+ const disconnectable = { disconnected: false };
802
+ const signalGenerator = callback && params.lifecycleSignals && this.createSignalGenerator();
803
+ for (const [, record] of records) {
804
+ if (disconnectable.disconnected)
805
+ break;
806
+ const flags = signalGenerator?.generate() || {};
807
+ callback(record, flags, context);
808
+ }
809
+ if (params.live) {
810
+ if (signalGenerator) {
811
+ params = { ...params, signalGenerator };
812
+ }
813
+ const disconnectable_live = this.observe(spec, callback, params);
814
+ return this.disconnectables(params.signal, disconnectable, disconnectable_live);
815
+ }
816
+ return this.disconnectables(params.signal, disconnectable, signalGenerator);
817
+ }
818
+ children(spec, callback = void 0, params = {}) {
819
+ [spec, callback = void 0, params = {}] = this.resolveArgs(arguments);
820
+ return this.query(spec, callback, { ...params, subtree: false });
821
+ }
822
+ subtree(spec, callback = void 0, params = {}) {
823
+ [spec, callback = void 0, params = {}] = this.resolveArgs(arguments);
824
+ return this.query(spec, callback, { ...params, subtree: true });
825
+ }
826
+ observe(spec, callback, params = {}) {
827
+ [spec, callback, params = {}] = this.resolveArgs(arguments);
828
+ if (["sync", "intercept"].includes(params.timing))
829
+ return this.observeSync(spec, callback, params);
830
+ if (params.timing && params.timing !== "async")
831
+ throw new Error(`Timing option "${params.timing}" invalid.`);
832
+ const { context, window: window2, webqit, document } = this;
833
+ if (params.eventDetails) {
834
+ webqit.realdom.domInterceptionRecordsAlwaysOn = true;
835
+ }
836
+ if ((document.readyState === "loading" || webqit.realdom.domInterceptionRecordsAlwaysOn) && !webqit.realdom.domInterceptionHooks?.intercepting) {
837
+ domInterception.call(window2, "sync", () => {
838
+ });
839
+ }
840
+ const disconnectable = new window2.MutationObserver((records) => records.forEach((record) => {
841
+ dispatch2.call(window2, registration, withEventDetails.call(window2, record), context);
842
+ }));
843
+ disconnectable.observe(context, { childList: true, subtree: params.subtree && true });
844
+ const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
845
+ const registration = { context, spec, callback, params, signalGenerator, disconnectable };
846
+ if (params.staticSensitivity) {
847
+ const disconnectable_attr = staticSensitivity.call(window2, registration);
848
+ return this.disconnectables(params.signal, disconnectable, signalGenerator, disconnectable_attr);
849
+ }
850
+ return this.disconnectables(params.signal, disconnectable, signalGenerator);
851
+ }
852
+ observeSync(spec, callback, params = {}) {
853
+ [spec, callback, params = {}] = this.resolveArgs(arguments);
854
+ const { context, window: window2 } = this;
855
+ if (params.timing && !["sync", "intercept"].includes(params.timing))
856
+ throw new Error(`Timing option "${params.timing}" invalid.`);
857
+ const interceptionTiming = params.timing === "intercept" ? "intercept" : "sync";
858
+ if (!this.registry(interceptionTiming).size) {
859
+ domInterception.call(window2, interceptionTiming, (record) => {
860
+ this.forEachMatchingContext(interceptionTiming, record, dispatch2);
861
+ });
862
+ }
863
+ const mo = new window2.MutationObserver((records) => records.forEach((record) => {
864
+ if (Array.isArray((record = withEventDetails.call(window2, record)).event))
865
+ return;
866
+ dispatch2.call(window2, registration, record, context);
867
+ }));
868
+ mo.observe(context, { childList: true, subtree: params.subtree && true });
869
+ const disconnectable = { disconnect() {
870
+ registry.delete(registration);
871
+ mo.disconnect();
872
+ } };
873
+ const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
874
+ const registration = { context, spec, callback, params, signalGenerator, disconnectable };
875
+ const registry = this.registry(interceptionTiming);
876
+ registry.set(registration, !!registration.params.deferred);
877
+ if (params.staticSensitivity) {
878
+ const disconnectable_attr = staticSensitivity.call(window2, registration);
879
+ return this.disconnectables(params.signal, disconnectable, signalGenerator, disconnectable_attr);
880
+ }
881
+ return this.disconnectables(params.signal, disconnectable, signalGenerator);
882
+ }
883
+ track(elements, callback, params = {}) {
884
+ params = { subtree: true, ...params };
885
+ return this.observe(elements, (record) => {
886
+ if (record.entrants.length)
887
+ callback(true, Array.isArray(elements) ? record.entrants : record.entrants[0]);
888
+ if (record.exits.length)
889
+ callback(false, Array.isArray(elements) ? record.exits : record.exits[0]);
890
+ }, params);
891
+ }
892
+ };
893
+ function staticSensitivity(registration) {
894
+ const window2 = this;
895
+ const { context, spec, callback, params, signalGenerator } = registration;
896
+ const cssSelectors = spec.filter((s) => s.kind === "css");
897
+ const parseDot = (selector) => selector.match(/\.([\w-]+)/g)?.length ? ["class"] : [];
898
+ const parseHash = (selector) => selector.match(/#([\w-]+)/g)?.length ? ["id"] : [];
899
+ const parse = (selector) => [...selector.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map((x) => x[1]).concat(parseDot(selector)).concat(parseHash(selector));
900
+ if (!(registration.$attrs = Array.from(new Set(cssSelectors.filter((s) => (s + "").includes("[")).reduce((attrs, selector) => attrs.concat(parse(selector + "")), [])))).length)
901
+ return;
902
+ const entrants = /* @__PURE__ */ new Set(), exits = /* @__PURE__ */ new Set();
903
+ entrants.push = (val) => (exits.delete(val), entrants.add(val));
904
+ exits.push = (val) => (entrants.delete(val), exits.add(val));
905
+ registration.$deliveryCache = { entrants, exits };
906
+ return new AttrRealtime(context, window2).observe(registration.$attrs, (_records) => {
907
+ const records = /* @__PURE__ */ new Map(), getRecord = (target) => {
908
+ if (!records.has(target)) {
909
+ records.set(target, { target, entrants: [], exits: [], type: "static", event: null });
910
+ }
911
+ return records.get(target);
912
+ };
913
+ const matchesCache = /* @__PURE__ */ new WeakMap();
914
+ const matches = (node) => {
915
+ if (!matchesCache.has(node)) {
916
+ matchesCache.set(node, cssSelectors.some((s) => node.matches(s + "")));
917
+ }
918
+ return matchesCache.get(node);
919
+ };
920
+ for (const _record of _records) {
921
+ ["entrants", "exits"].forEach((generation) => {
922
+ if (params.generation && generation !== params.generation)
923
+ return;
924
+ if (registration.$deliveryCache[generation].has(_record.target) || (generation === "entrants" ? !matches(_record.target) : matches(_record.target)))
925
+ return;
926
+ registration.$deliveryCache[generation].push(_record.target);
927
+ getRecord(_record.target)[generation].push(_record.target);
928
+ getRecord(_record.target).event = _record.event;
929
+ });
930
+ }
931
+ for (const [, record] of records) {
932
+ const flags = signalGenerator?.generate() || {};
933
+ callback(record, flags, context);
934
+ }
935
+ }, { subtree: params.subtree, timing: params.timing, eventDetails: params.eventDetails });
936
+ }
937
+ function dispatch2(registration, _record) {
938
+ const { context, spec, callback, params, signalGenerator, $deliveryCache } = registration;
939
+ const record = { ..._record, entrants: [], exits: [] };
940
+ if (!params.eventDetails) {
941
+ delete record.event;
942
+ }
943
+ ["entrants", "exits"].forEach((generation) => {
944
+ if (params.generation && generation !== params.generation)
945
+ return;
946
+ if (spec.length) {
947
+ record[generation] = nodesIntersection.call(this, spec, params.subtree === "cross-roots", _record[generation], _record.event !== "parse");
948
+ } else {
949
+ record[generation] = [..._record[generation]];
950
+ }
951
+ if (!$deliveryCache)
952
+ return;
953
+ for (const node of record[generation]) {
954
+ $deliveryCache[generation].push(node);
955
+ }
956
+ });
957
+ if (!record.entrants.length && !record.exits.length)
958
+ return;
959
+ const flags = signalGenerator?.generate() || {};
960
+ callback(record, flags, context);
961
+ }
962
+ function nodesIntersection(spec, crossRoots, sources, deepIntersect) {
963
+ sources = Array.isArray(sources) ? sources : [...sources];
964
+ const match = (sources2, s) => {
965
+ if (s.type === "selector") {
966
+ let matches = s.isXpathAttr ? [] : sources2.filter((source) => s.kind === "xpath" ? xpathMatch(this, source, s + "") : source.matches && source.matches(s + ""));
967
+ if (deepIntersect || s.isXpathAttr) {
968
+ matches = sources2.reduce((collection, source) => {
969
+ if (s.kind === "xpath") {
970
+ return [...collection, ...xpathQuery(this, source, s, deepIntersect)];
971
+ }
972
+ return source.querySelectorAll ? [...collection, ...source.querySelectorAll(s + "")] : collection;
973
+ }, matches);
974
+ }
975
+ if (matches.length)
976
+ return matches;
977
+ } else {
978
+ if (sources2.includes(s.content) || deepIntersect && sources2.some((source) => containsNode(this, source, s.content, crossRoots))) {
979
+ return [s.content];
980
+ }
981
+ }
982
+ };
983
+ if (!sources.$$searchCache) {
984
+ sources.$$searchCache = /* @__PURE__ */ new Map();
985
+ }
986
+ return spec.reduce((matches, s) => {
987
+ let _matches;
988
+ if (sources.$$searchCache.has(s.content)) {
989
+ _matches = sources.$$searchCache.get(s.content);
990
+ } else {
991
+ _matches = match(sources, s) || [];
992
+ if (s.type === "instance") {
993
+ sources.$$searchCache.set(s.content, _matches);
994
+ }
995
+ }
996
+ return matches.concat(_matches);
997
+ }, []);
998
+ }
999
+ function withEventDetails({ target, addedNodes, removedNodes }) {
1000
+ let window2 = this, event;
1001
+ event = from_default(addedNodes).reduce((prev, node) => prev || window2.webqit.realdom.domInterceptionRecords?.get(node), null);
1002
+ event = from_default(removedNodes).reduce((prev, node) => prev || window2.webqit.realdom.domInterceptionRecords?.get(node), event);
1003
+ event = event || window2.document.readyState === "loading" && "parse" || "mutation";
1004
+ return { target, entrants: addedNodes, exits: removedNodes, type: "observation", event };
1005
+ }
1006
+ function domInterception(timing, callback) {
1007
+ const window2 = this;
1008
+ const { webqit, document, Node, CharacterData, Element, HTMLElement, HTMLTemplateElement, DocumentFragment } = window2;
1009
+ if (!webqit.realdom.domInterceptionHooks) {
1010
+ Object.defineProperty(webqit.realdom, "domInterceptionHooks", { value: /* @__PURE__ */ new Map() });
1011
+ }
1012
+ if (!webqit.realdom.domInterceptionNoRecurse) {
1013
+ Object.defineProperty(webqit.realdom, "domInterceptionNoRecurse", { value: /* @__PURE__ */ new Map() });
1014
+ }
1015
+ if (!webqit.realdom.domInterceptionHooks.has(timing)) {
1016
+ webqit.realdom.domInterceptionHooks.set(timing, /* @__PURE__ */ new Set());
1017
+ }
1018
+ webqit.realdom.domInterceptionHooks.get(timing).add(callback);
1019
+ const rm = () => webqit.realdom.domInterceptionHooks.get(timing).delete(callback);
1020
+ if (webqit.realdom.domInterceptionHooks?.intercepting)
1021
+ return rm;
1022
+ console.warn(`DOM mutation APIs are now being intercepted.`);
1023
+ webqit.realdom.domInterceptionHooks.intercepting = true;
1024
+ Object.defineProperty(webqit.realdom, "domInterceptionRecords", { value: /* @__PURE__ */ new Map() });
1025
+ const noRecurse = (node, method, callback2) => {
1026
+ webqit.realdom.domInterceptionNoRecurse.set(node, method);
1027
+ const returnValue = callback2();
1028
+ webqit.realdom.domInterceptionNoRecurse.delete(node);
1029
+ return returnValue;
1030
+ };
1031
+ const intercept = (record, defaultAction) => {
1032
+ record.entrants.concat(record.exits).forEach((node) => {
1033
+ clearTimeout(webqit.realdom.domInterceptionRecords.get(node)?.timeout);
1034
+ webqit.realdom.domInterceptionRecords.set(node, record.event);
1035
+ const timeout = setTimeout(() => {
1036
+ webqit.realdom.domInterceptionRecords.delete(node);
1037
+ }, 0);
1038
+ Object.defineProperty(record.event, "timeout", { value: timeout, configurable: true });
1039
+ });
1040
+ webqit.realdom.domInterceptionHooks.get("intercept")?.forEach((callback2) => callback2(record));
1041
+ const returnValue = defaultAction();
1042
+ webqit.realdom.domInterceptionHooks.get("sync")?.forEach((callback2) => callback2(record));
1043
+ return returnValue;
1044
+ };
1045
+ const _apiNames = {
1046
+ ShadowRoot: ["innerHTML", "setHTMLUnsafe"],
1047
+ DocumentFragment: ["replaceChildren", "append", "prepend"],
1048
+ Document: ["replaceChildren", "append", "prepend"],
1049
+ HTMLElement: ["outerText", "innerText"],
1050
+ Element: ["append", "prepend", "before", "after", "insertAdjacentElement", "insertAdjacentHTML", "remove", "replaceChildren", "replaceWith", "setHTMLUnsafe", "innerHTML", "outerHTML"],
1051
+ CharacterData: ["before", "after", "remove", "replaceWith"],
1052
+ Node: ["insertBefore", "replaceChild", "removeChild", "appendChild", "textContent", "nodeValue"]
1053
+ };
1054
+ const _apiOriginals = {
1055
+ ShadowRoot: /* @__PURE__ */ Object.create(null),
1056
+ DocumentFragment: /* @__PURE__ */ Object.create(null),
1057
+ Document: /* @__PURE__ */ Object.create(null),
1058
+ HTMLElement: /* @__PURE__ */ Object.create(null),
1059
+ Element: /* @__PURE__ */ Object.create(null),
1060
+ CharacterData: /* @__PURE__ */ Object.create(null),
1061
+ Node: /* @__PURE__ */ Object.create(null)
1062
+ };
1063
+ const _apiNamesUnique = new Set(Object.values(_apiNames).reduce((all, apis) => all.concat(apis), []));
1064
+ _apiNamesUnique.forEach((apiName) => {
1065
+ Object.keys(_apiNames).forEach((DOMClassName) => {
1066
+ if (!_apiNames[DOMClassName].includes(apiName))
1067
+ return;
1068
+ const _apiOriginal = Object.getOwnPropertyDescriptor(window2[DOMClassName].prototype, apiName);
1069
+ if (!_apiOriginal)
1070
+ return;
1071
+ Object.defineProperty(window2[DOMClassName].prototype, apiName, "value" in _apiOriginal ? { ..._apiOriginal, value: method } : { ..._apiOriginal, set: setter });
1072
+ _apiOriginals[DOMClassName][apiName] = _apiOriginal;
1073
+ });
1074
+ function method(...args) {
1075
+ const DOMClassName = Object.keys(_apiOriginals).find((name) => this instanceof window2[name] && apiName in _apiOriginals[name]);
1076
+ const $apiOriginals = _apiOriginals[DOMClassName];
1077
+ let exec = () => $apiOriginals[apiName].value.call(this, ...args);
1078
+ if (webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
1079
+ return exec();
1080
+ let exits = [], entrants = [], target = this;
1081
+ if (["insertBefore"].includes(apiName)) {
1082
+ entrants = [args[0]];
1083
+ } else if (["insertAdjacentElement", "insertAdjacentHTML"].includes(apiName)) {
1084
+ entrants = [args[1]];
1085
+ if (["beforebegin", "afterend"].includes(args[0])) {
1086
+ target = this.parentNode;
1087
+ }
1088
+ } else if (["setHTMLUnsafe", "replaceChildren"].includes(apiName)) {
1089
+ exits = [...this.childNodes];
1090
+ entrants = apiName === "replaceChildren" ? [...args] : [args[0]];
1091
+ } else if (["replaceWith", "remove"].includes(apiName)) {
1092
+ exits = [this];
1093
+ entrants = apiName === "replaceWith" ? [...args] : [];
1094
+ target = this.parentNode;
1095
+ } else if (["replaceChild"].includes(apiName)) {
1096
+ exits = [args[1]];
1097
+ entrants = [args[0]];
1098
+ } else if (["removeChild"].includes(apiName)) {
1099
+ exits = [...args];
1100
+ } else {
1101
+ entrants = [...args];
1102
+ if (["before", "after"].includes(apiName)) {
1103
+ target = this.parentNode;
1104
+ }
1105
+ }
1106
+ let apiNameFinal = apiName;
1107
+ if (["insertAdjacentHTML", "setHTMLUnsafe"].includes(apiName)) {
1108
+ let tempNodeName = this.nodeName;
1109
+ if (apiName === "insertAdjacentHTML" && ["beforebegin", "afterend"].includes(args[0])) {
1110
+ if (!this.parentNode)
1111
+ return $apiOriginals[apiName].value.call(this, ...args);
1112
+ tempNodeName = this.parentNode.nodeName;
1113
+ }
1114
+ const temp = document.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
1115
+ $apiOriginals.setHTMLUnsafe.value.call(temp, entrants[0], apiName === "setHTMLUnsafe" ? args[1] : {});
1116
+ entrants = [...temp.childNodes];
1117
+ if (apiName === "insertAdjacentHTML") {
1118
+ apiNameFinal = "insertAdjacentElement";
1119
+ args[1] = new DocumentFragment();
1120
+ noRecurse(args[1], "append", () => args[1].append(...temp.childNodes));
1121
+ } else {
1122
+ apiNameFinal = "replaceChildren";
1123
+ args = [...temp.childNodes];
1124
+ }
1125
+ }
1126
+ if (!target)
1127
+ return exec();
1128
+ const record = { target, entrants, exits, type: "interception", event: [this, apiName] };
1129
+ return intercept(record, () => {
1130
+ return $apiOriginals[apiNameFinal].value.call(this, ...args);
1131
+ });
1132
+ }
1133
+ function setter(value) {
1134
+ const DOMClassName = Object.keys(_apiOriginals).find((name) => this instanceof window2[name] && apiName in _apiOriginals[name]);
1135
+ const $apiOriginals = _apiOriginals[DOMClassName];
1136
+ let exec = () => $apiOriginals[apiName].set.call(this, value);
1137
+ if (this instanceof HTMLScriptElement || webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
1138
+ return exec();
1139
+ let exits = [], entrants = [], target = this;
1140
+ if (["outerHTML", "outerText"].includes(apiName)) {
1141
+ exits = [this];
1142
+ target = this.parentNode;
1143
+ } else {
1144
+ if (this instanceof HTMLTemplateElement) {
1145
+ target = this.content;
1146
+ exits = [...this.content.childNodes];
1147
+ } else {
1148
+ exits = [...this.childNodes];
1149
+ }
1150
+ }
1151
+ if (["outerHTML", "innerHTML"].includes(apiName)) {
1152
+ let tempNodeName = this.nodeName;
1153
+ if (apiName === "outerHTML") {
1154
+ if (!this.parentNode)
1155
+ return exec();
1156
+ tempNodeName = this.parentNode.nodeName;
1157
+ }
1158
+ const temp = document.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
1159
+ noRecurse(temp, apiName, () => temp[apiName] = value);
1160
+ entrants = this instanceof HTMLTemplateElement ? [...temp.content.childNodes] : [...temp.childNodes];
1161
+ if (this instanceof HTMLTemplateElement && this.hasAttribute("src") || this instanceof ShadowRoot) {
1162
+ const getScripts = (nodes) => nodes.reduce((scripts, el) => {
1163
+ if (el instanceof HTMLScriptElement)
1164
+ return scripts.concat(el);
1165
+ if (el instanceof HTMLTemplateElement)
1166
+ return scripts.concat(getScripts([el.content]));
1167
+ scripts = scripts.concat(getScripts([...el.querySelectorAll?.("template") || []].map((t) => t.content)));
1168
+ return scripts.concat(...el.querySelectorAll?.("script") || []);
1169
+ }, []);
1170
+ for (const script of getScripts(entrants)) {
1171
+ if (this instanceof ShadowRoot) {
1172
+ script.setAttribute("data-handling", "manual");
1173
+ continue;
1174
+ }
1175
+ const $script = document.createElement("script");
1176
+ [...script.attributes].forEach((attr) => $script.setAttribute(attr.name, attr.value));
1177
+ $script.textContent = script.textContent;
1178
+ noRecurse(script, "replaceWith", () => script.replaceWith($script));
1179
+ }
1180
+ }
1181
+ if (apiName === "outerHTML") {
1182
+ value = new DocumentFragment();
1183
+ noRecurse(value, "append", () => value.append(...entrants));
1184
+ exec = () => noRecurse(this, "replaceWith", () => Element.prototype.replaceWith.call(this, value));
1185
+ } else {
1186
+ if (this instanceof HTMLTemplateElement) {
1187
+ exec = () => noRecurse(this.content, "replaceChildren", () => this.content.replaceChildren(...entrants));
1188
+ } else {
1189
+ exec = () => noRecurse(this, "replaceChildren", () => Element.prototype.replaceChildren.call(this, ...entrants));
1190
+ }
1191
+ }
1192
+ }
1193
+ const record = { target, entrants, exits, type: "interception", event: [this, apiName] };
1194
+ return intercept(record, exec);
1195
+ }
1196
+ });
1197
+ return rm;
1198
+ }
1199
+
1200
+ // node_modules/@webqit/realdom/src/polyfills.js
1201
+ function polyfills_default() {
1202
+ CSS_escape.call(this);
1203
+ Node_isConnected.call(this);
1204
+ Element_matches.call(this);
1205
+ }
1206
+ function CSS_escape() {
1207
+ const window2 = this;
1208
+ if (!window2.CSS) {
1209
+ window2.CSS = {};
1210
+ }
1211
+ if (!window2.CSS.escape) {
1212
+ window2.CSS.escape = (str) => str.replace(/([\:@\~\$\&])/g, "\\$1");
1213
+ }
1214
+ }
1215
+ function Node_isConnected() {
1216
+ const window2 = this;
1217
+ if (!("isConnected" in window2.Node.prototype)) {
1218
+ Object.defineProperty(window2.Node.prototype, "isConnected", { get: function() {
1219
+ return !this.ownerDocument || !(this.ownerDocument.compareDocumentPosition(this) & this.DOCUMENT_POSITION_DISCONNECTED);
1220
+ } });
1221
+ }
1222
+ }
1223
+ function Element_matches() {
1224
+ const window2 = this;
1225
+ if (!window2.Element.prototype.matches) {
1226
+ window2.Element.prototype.matches = window2.Element.prototype.matchesSelector || window2.Element.prototype.mozMatchesSelector || window2.Element.prototype.msMatchesSelector || window2.Element.prototype.oMatchesSelector || window2.Element.prototype.webkitMatchesSelector || function(s) {
1227
+ var matches = (this.document || this.ownerDocument).querySelectorAll(s), i = matches.length;
1228
+ while (--i >= 0 && matches.item(i) !== this) {
1229
+ }
1230
+ return i > -1;
1231
+ };
1232
+ }
1233
+ }
1234
+
1235
+ // node_modules/@webqit/realdom/src/index.js
1236
+ function src_default() {
1237
+ const window2 = this;
1238
+ if (!window2.webqit)
1239
+ window2.webqit = {};
1240
+ if (window2.webqit.realdom)
1241
+ return window2.webqit.realdom;
1242
+ window2.webqit.realdom = {};
1243
+ polyfills_default.call(window2);
1244
+ window2.webqit.realdom.meta = (...args) => meta.call(window2, ...args);
1245
+ window2.webqit.realdom.ready = (...args) => ready.call(window2, ...args);
1246
+ window2.webqit.realdom.realtime = (context, namespace = "dom") => {
1247
+ if (namespace === "dom")
1248
+ return new DOMRealtime(context, window2);
1249
+ if (namespace === "attr")
1250
+ return new AttrRealtime(context, window2);
1251
+ };
1252
+ const scheduler = new Scheduler(window2);
1253
+ window2.webqit.realdom.schedule = (type, ...args) => {
1254
+ return scheduler[`on${type}`](...args);
1255
+ };
1256
+ window2.webqit.realdom.synthesizeWhile = (...args) => {
1257
+ return scheduler.synthesizeWhile(...args);
1258
+ };
1259
+ return window2.webqit.realdom;
1260
+ }
1261
+ function ready(...args) {
1262
+ let timing = "interactive", callback;
1263
+ if (isString_default(args[0])) {
1264
+ timing = args[0];
1265
+ if (isFunction_default(args[1])) {
1266
+ callback = args[1];
1267
+ }
1268
+ } else if (isFunction_default(args[0])) {
1269
+ callback = args[0];
1270
+ }
1271
+ const timings = { interactive: ["interactive", "complete"], complete: ["complete"] };
1272
+ if (!timings[timing])
1273
+ throw new Error(`Invalid ready-state timing: ${timing}.`);
1274
+ const window2 = this;
1275
+ if (!callback) {
1276
+ if (!window2.webqit.realdom.readyStatePromises) {
1277
+ window2.webqit.realdom.readyStatePromises = {
1278
+ interactive: new Promise((res) => ready.call(this, "interactive", res)),
1279
+ complete: new Promise((res) => ready.call(this, "complete", res))
1280
+ };
1281
+ }
1282
+ return window2.webqit.realdom.readyStatePromises[timing];
1283
+ }
1284
+ if (timings[timing].includes(window2.document.readyState))
1285
+ return callback(window2);
1286
+ if (!window2.webqit.realdom.readyStateCallbacks) {
1287
+ window2.webqit.realdom.readyStateCallbacks = { interactive: [], complete: [] };
1288
+ window2.document.addEventListener("readystatechange", () => {
1289
+ const state = window2.document.readyState;
1290
+ for (const callback2 of window2.webqit.realdom.readyStateCallbacks[state].splice(0)) {
1291
+ callback2(window2);
1292
+ }
1293
+ }, false);
1294
+ }
1295
+ window2.webqit.realdom.readyStateCallbacks[timing].push(callback);
1296
+ }
1297
+ function meta(name) {
1298
+ const window2 = this;
1299
+ let _content = {}, _el;
1300
+ if (_el = window2.document.querySelector(`meta[name="${name}"]`)) {
1301
+ _content = (_el.content || "").split(";").filter((v) => v).reduce((_metaVars, directive) => {
1302
+ const directiveSplit = directive.split("=").map((d) => d.trim());
1303
+ set_default(_metaVars, directiveSplit[0].split("."), directiveSplit[1] === "true" ? true : directiveSplit[1] === "false" ? false : isNumeric_default(directiveSplit[1]) ? parseInt(directiveSplit[1]) : directiveSplit[1]);
1304
+ return _metaVars;
1305
+ }, {});
1306
+ }
1307
+ return { get name() {
1308
+ return name;
1309
+ }, get content() {
1310
+ return _el.content;
1311
+ }, json() {
1312
+ return JSON.parse(JSON.stringify(_content));
1313
+ } };
1314
+ }
1315
+
1316
+ // node_modules/@webqit/util/str/toTitle.js
1317
+ function toTitle_default(str, strict) {
1318
+ if (typeof str !== "string") {
1319
+ return str;
1320
+ }
1321
+ return str.replace(/\w\S*/g, function(txt) {
1322
+ return txt.charAt(0).toUpperCase() + (typeof strict !== void 0 && strict ? txt.substr(1).toLowerCase() : txt.substr(1));
1323
+ });
1324
+ }
1325
+
1326
+ // src/util.js
1327
+ var _wq = (target, ...args) => wq(target, "oohtml", ...args);
1328
+ var env = {};
1329
+ function _init(name, $config, $defaults) {
1330
+ const window2 = this, realdom = src_default.call(window2);
1331
+ env.window = window2;
1332
+ if (!window2.webqitConfig) {
1333
+ window2.webqitConfig = realdom.meta("webqit").json();
1334
+ }
1335
+ window2.webqit || (window2.webqit = {});
1336
+ window2.webqit.oohtml || (window2.webqit.oohtml = {});
1337
+ window2.webqit.oohtml.configs || (window2.webqit.oohtml.configs = {});
1338
+ const configKey = name.toUpperCase().replace("-", "_");
1339
+ if (!window2.webqit.oohtml.configs[configKey]) {
1340
+ window2.webqit.oohtml.configs[configKey] = {};
1341
+ const config = window2.webqit.oohtml.configs[configKey];
1342
+ merge_default(2, config, $defaults, $config, realdom.meta(name).json());
1343
+ if (window2.webqitConfig.prefix) {
1344
+ Object.keys(config).forEach((main) => {
1345
+ Object.keys(config[main]).forEach((key) => {
1346
+ if (main === "api" && typeof config[main][key] === "string") {
1347
+ config[main][key] = `${window2.webqitConfig.prefix}${toTitle_default(config[main][key])}`;
1348
+ } else if (["attr", "elements"].includes(main) && config[main][key]?.startsWith("data-") === false) {
1349
+ config[main][key] = `${window2.webqitConfig.prefix}-${config[main][key]}`;
1350
+ }
1351
+ });
1352
+ });
1353
+ }
1354
+ }
1355
+ return { config: window2.webqit.oohtml.configs[configKey], realdom, window: window2 };
1356
+ }
1357
+ var _uniqId = () => (0 | Math.random() * 9e6).toString(36);
1358
+ var hashTable = /* @__PURE__ */ new Map();
1359
+ function _toHash(val) {
1360
+ let hash;
1361
+ if (!(hash = hashTable.get(val))) {
1362
+ hash = _uniqId();
1363
+ hashTable.set(val, hash);
1364
+ }
1365
+ return hash;
1366
+ }
1367
+ function _fromHash(hash) {
1368
+ let val;
1369
+ hashTable.forEach((_hash, _val) => {
1370
+ if (_hash === hash)
1371
+ val = _val;
1372
+ });
1373
+ return val;
1374
+ }
1375
+
1376
+ // src/scoped-js/index.js
1377
+ function init({ advanced = {}, ...$config }) {
1378
+ const { config, window: window2 } = _init.call(this, "scoped-js", $config, {
1379
+ script: { retention: "retain", mimeTypes: "module|text/javascript|application/javascript", timing: "auto" },
1380
+ api: { scripts: "scripts" },
1381
+ advanced: resolveParams(advanced)
1382
+ });
1383
+ const customTypes = Array.isArray(config.script.mimeTypes) ? config.script.mimeTypes : config.script.mimeTypes.split("|").filter((t) => t);
1384
+ config.scriptSelector = customTypes.map((t) => `script[type="${window2.CSS.escape(t)}"]:not([oohtmlignore])`).concat(`script:not([type])`).join(",");
1385
+ window2.webqit.oohtml.Script = {
1386
+ compileCache: [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()],
1387
+ execute: execute.bind(window2, config)
1388
+ };
1389
+ exposeAPIs.call(window2, config);
1390
+ realtime.call(window2, config);
1391
+ }
1392
+ function exposeAPIs(config) {
1393
+ const window2 = this, { webqit: { nextKeyword, matchPrologDirective } } = window2;
1394
+ const scriptsMap = /* @__PURE__ */ new Map();
1395
+ if (config.api.scripts in window2.Element.prototype) {
1396
+ throw new Error(`The "Element" class already has a "${config.api.scripts}" property!`);
1397
+ }
1398
+ [window2.ShadowRoot.prototype, window2.Element.prototype].forEach((proto) => {
1399
+ Object.defineProperty(proto, config.api.scripts, { get: function() {
1400
+ if (!scriptsMap.has(this)) {
1401
+ scriptsMap.set(this, []);
1402
+ }
1403
+ return scriptsMap.get(this);
1404
+ } });
1405
+ });
1406
+ Object.defineProperties(window2.HTMLScriptElement.prototype, {
1407
+ scoped: {
1408
+ configurable: true,
1409
+ get() {
1410
+ return this.hasAttribute("scoped");
1411
+ },
1412
+ set(value) {
1413
+ this.toggleAttribute("scoped", value);
1414
+ }
1415
+ },
1416
+ live: {
1417
+ configurable: true,
1418
+ get() {
1419
+ if (this.liveProgramHandle)
1420
+ return true;
1421
+ const scriptContents = nextKeyword(this.oohtml__textContent || this.textContent || "", 0, 0);
1422
+ return matchPrologDirective(scriptContents, true);
1423
+ }
1424
+ }
1425
+ });
1426
+ }
1427
+ async function execute(config, execHash) {
1428
+ const window2 = this, { realdom } = window2.webqit;
1429
+ const exec = _fromHash(execHash);
1430
+ if (!exec)
1431
+ throw new Error(`Argument must be a valid exec hash.`);
1432
+ const { script, compiledScript, thisContext } = exec;
1433
+ if (config.script.retention === "dispose") {
1434
+ script.remove();
1435
+ } else if (config.script.retention === "hidden") {
1436
+ script.textContent = `"source hidden"`;
1437
+ } else {
1438
+ setTimeout(async () => {
1439
+ script.textContent = await compiledScript.toString();
1440
+ }, 0);
1441
+ }
1442
+ const varScope = script.scoped ? thisContext : script.getRootNode();
1443
+ if (!_wq(varScope).has("scriptEnv")) {
1444
+ _wq(varScope).set("scriptEnv", /* @__PURE__ */ Object.create(null));
1445
+ }
1446
+ const liveProgramHandle = await (await compiledScript.bind(thisContext, _wq(varScope).get("scriptEnv"))).execute();
1447
+ if (script.live) {
1448
+ Object.defineProperty(script, "liveProgramHandle", { value: liveProgramHandle });
1449
+ }
1450
+ realdom.realtime(window2.document).observe(script, () => {
1451
+ if (script.live) {
1452
+ liveProgramHandle.abort();
1453
+ }
1454
+ if (thisContext instanceof window2.Element) {
1455
+ thisContext[config.api.scripts]?.splice(thisContext[config.api.scripts].indexOf(script, 1));
1456
+ }
1457
+ }, { id: "scoped-js:script-exits", subtree: "cross-roots", timing: "sync", generation: "exits" });
1458
+ }
1459
+ function realtime(config) {
1460
+ const inBrowser = Object.getOwnPropertyDescriptor(globalThis, "window")?.get?.toString().includes("[native code]") ?? false;
1461
+ const window2 = this, { webqit: { oohtml, realdom } } = window2;
1462
+ if (!window2.HTMLScriptElement.supports) {
1463
+ window2.HTMLScriptElement.supports = (type) => ["text/javascript", "application/javascript"].includes(type);
1464
+ }
1465
+ const handled = /* @__PURE__ */ new WeakSet();
1466
+ realdom.realtime(window2.document).query(config.scriptSelector, (record) => {
1467
+ record.entrants.forEach((script) => {
1468
+ if (handled.has(script) || script.hasAttribute("oohtmlno") || !inBrowser && !script.hasAttribute("ssr"))
1469
+ return;
1470
+ const compiledScript = compileScript.call(window2, config, script);
1471
+ if (!compiledScript)
1472
+ return;
1473
+ handled.add(script);
1474
+ const thisContext = script.scoped ? script.parentNode || record.target : script.type === "module" ? void 0 : window2;
1475
+ if (script.scoped) {
1476
+ thisContext[config.api.scripts].push(script);
1477
+ }
1478
+ const execHash = _toHash({ script, compiledScript, thisContext });
1479
+ const manualHandling = record.type === "query" || script.type && !window2.HTMLScriptElement.supports(script.type) || script.getAttribute("data-handling") === "manual";
1480
+ if (manualHandling || config.script.timing === "manual") {
1481
+ oohtml.Script.execute(execHash);
1482
+ } else {
1483
+ script.textContent = `webqit.oohtml.Script.execute( '${execHash}' );`;
1484
+ }
1485
+ });
1486
+ }, { id: "scoped-js:script-entries", live: true, subtree: "cross-roots", timing: "intercept", generation: "entrants", eventDetails: true });
1487
+ }
1488
+ function compileScript(config, script) {
1489
+ const window2 = this, { webqit: { oohtml, LiveScript, AsyncLiveScript, LiveModule } } = window2;
1490
+ let textContent = script.textContent.trim();
1491
+ if (textContent.startsWith("/*@oohtml*/if(false){") && textContent.endsWith("}/*@oohtml*/")) {
1492
+ textContent = textContent.slice(21, -12);
1493
+ Object.defineProperty(script, "oohtml__textContent", { value: textContent });
1494
+ }
1495
+ if (!textContent.trim().length)
1496
+ return;
1497
+ const sourceHash = _toHash(textContent);
1498
+ const compileCache = oohtml.Script.compileCache[script.live ? 0 : 1];
1499
+ let compiledScript;
1500
+ if (!(compiledScript = compileCache.get(sourceHash))) {
1501
+ const { parserParams: parserParams2, compilerParams, runtimeParams: runtimeParams2 } = config.advanced;
1502
+ compiledScript = new (script.type === "module" ? LiveModule : LiveScript || AsyncLiveScript)(textContent, {
1503
+ liveMode: script.live,
1504
+ exportNamespace: `#${script.id}`,
1505
+ fileName: `${window2.document.url?.split("#")?.[0] || ""}#${script.id}`,
1506
+ parserParams: parserParams2,
1507
+ compilerParams,
1508
+ runtimeParams: runtimeParams2
1509
+ });
1510
+ compileCache.set(sourceHash, compiledScript);
1511
+ }
1512
+ return compiledScript;
1513
+ }
1514
+
1515
+ // src/scoped-js/targets.browser.js
1516
+ init.call(window);
2
1517
  //# sourceMappingURL=scoped-js.js.map