@webqit/oohtml 4.1.14 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bindings-api.js +1 -1
- package/dist/bindings-api.js.map +2 -2
- package/dist/context-api.js +1 -1
- package/dist/context-api.js.map +2 -2
- package/dist/data-binding.js +4 -4
- package/dist/data-binding.js.map +2 -2
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +2 -2
- package/dist/main.js +5 -5
- package/dist/main.js.map +2 -2
- package/dist/main.lite.js +7 -7
- package/dist/main.lite.js.map +2 -2
- package/dist/namespaced-html.js +1 -1
- package/dist/namespaced-html.js.map +2 -2
- package/dist/scoped-css.js +1 -1
- package/dist/scoped-css.js.map +2 -2
- package/dist/scoped-js.js +1 -1
- package/dist/scoped-js.js.map +2 -2
- package/package.json +3 -3
- package/src/data-binding/index.js +16 -6
- package/src/namespaced-html/index.js +1 -1
- package/src/scoped-js/index.js +2 -2
package/dist/main.js
CHANGED
|
@@ -8,11 +8,11 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
|
|
|
8
8
|
`,a):(e.write("/*"),sa(e,a.value,i,r),e.write("*/"+r))}}function na(e){let t=e;for(;t!=null;){let{type:i}=t;if(i[0]==="C"&&i[1]==="a")return!0;if(i[0]==="M"&&i[1]==="e"&&i[2]==="m")t=t.object;else return!1}}function Ji(e,t){let{generator:i}=e,{declarations:r}=t;e.write(t.kind+" ");let{length:s}=r;if(s>0){i.VariableDeclarator(r[0],e);for(let n=1;n<s;n++)e.write(", "),i.VariableDeclarator(r[n],e)}}var gs,xs,ys,bs,ws,vs,aa={Program(e,t){let i=t.indent.repeat(t.indentLevel),{lineEnd:r,writeComments:s}=t;s&&e.comments!=null&&tt(t,e.comments,i,r);let n=e.body,{length:a}=n;for(let o=0;o<a;o++){let u=n[o];s&&u.comments!=null&&tt(t,u.comments,i,r),t.write(i),this[u.type](u,t),t.write(r)}s&&e.trailingComments!=null&&tt(t,e.trailingComments,i,r)},BlockStatement:vs=function(e,t){let i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:s}=t,n=i+t.indent;t.write("{");let a=e.body;if(a!=null&&a.length>0){t.write(r),s&&e.comments!=null&&tt(t,e.comments,n,r);let{length:o}=a;for(let u=0;u<o;u++){let c=a[u];s&&c.comments!=null&&tt(t,c.comments,n,r),t.write(n),this[c.type](c,t),t.write(r)}t.write(i)}else s&&e.comments!=null&&(t.write(r),tt(t,e.comments,n,r),t.write(i));s&&e.trailingComments!=null&&tt(t,e.trailingComments,n,r),t.write("}"),t.indentLevel--},ClassBody:vs,StaticBlock(e,t){t.write("static "),this.BlockStatement(e,t)},EmptyStatement(e,t){t.write(";")},ExpressionStatement(e,t){let i=t.expressionsPrecedence[e.expression.type];i===dt||i===3&&e.expression.left.type[0]==="O"?(t.write("("),this[e.expression.type](e.expression,t),t.write(")")):this[e.expression.type](e.expression,t),t.write(";")},IfStatement(e,t){t.write("if ("),this[e.test.type](e.test,t),t.write(") "),this[e.consequent.type](e.consequent,t),e.alternate!=null&&(t.write(" else "),this[e.alternate.type](e.alternate,t))},LabeledStatement(e,t){this[e.label.type](e.label,t),t.write(": "),this[e.body.type](e.body,t)},BreakStatement(e,t){t.write("break"),e.label!=null&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},ContinueStatement(e,t){t.write("continue"),e.label!=null&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},WithStatement(e,t){t.write("with ("),this[e.object.type](e.object,t),t.write(") "),this[e.body.type](e.body,t)},SwitchStatement(e,t){let i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:s}=t;t.indentLevel++;let n=i+t.indent,a=n+t.indent;t.write("switch ("),this[e.discriminant.type](e.discriminant,t),t.write(") {"+r);let{cases:o}=e,{length:u}=o;for(let c=0;c<u;c++){let l=o[c];s&&l.comments!=null&&tt(t,l.comments,n,r),l.test?(t.write(n+"case "),this[l.test.type](l.test,t),t.write(":"+r)):t.write(n+"default:"+r);let{consequent:f}=l,{length:p}=f;for(let m=0;m<p;m++){let g=f[m];s&&g.comments!=null&&tt(t,g.comments,a,r),t.write(a),this[g.type](g,t),t.write(r)}}t.indentLevel-=2,t.write(i+"}")},ReturnStatement(e,t){t.write("return"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t)),t.write(";")},ThrowStatement(e,t){t.write("throw "),this[e.argument.type](e.argument,t),t.write(";")},TryStatement(e,t){if(t.write("try "),this[e.block.type](e.block,t),e.handler){let{handler:i}=e;i.param==null?t.write(" catch "):(t.write(" catch ("),this[i.param.type](i.param,t),t.write(") ")),this[i.body.type](i.body,t)}e.finalizer&&(t.write(" finally "),this[e.finalizer.type](e.finalizer,t))},WhileStatement(e,t){t.write("while ("),this[e.test.type](e.test,t),t.write(") "),this[e.body.type](e.body,t)},DoWhileStatement(e,t){t.write("do "),this[e.body.type](e.body,t),t.write(" while ("),this[e.test.type](e.test,t),t.write(");")},ForStatement(e,t){if(t.write("for ("),e.init!=null){let{init:i}=e;i.type[0]==="V"?Ji(t,i):this[i.type](i,t)}t.write("; "),e.test&&this[e.test.type](e.test,t),t.write("; "),e.update&&this[e.update.type](e.update,t),t.write(") "),this[e.body.type](e.body,t)},ForInStatement:gs=function(e,t){t.write(`for ${e.await?"await ":""}(`);let{left:i}=e;i.type[0]==="V"?Ji(t,i):this[i.type](i,t),t.write(e.type[3]==="I"?" in ":" of "),this[e.right.type](e.right,t),t.write(") "),this[e.body.type](e.body,t)},ForOfStatement:gs,DebuggerStatement(e,t){t.write("debugger;",e)},FunctionDeclaration:xs=function(e,t){t.write((e.async?"async ":"")+(e.generator?"function* ":"function ")+(e.id?e.id.name:""),e),oe(t,e.params),t.write(" "),this[e.body.type](e.body,t)},FunctionExpression:xs,VariableDeclaration(e,t){Ji(t,e),t.write(";")},VariableDeclarator(e,t){this[e.id.type](e.id,t),e.init!=null&&(t.write(" = "),this[e.init.type](e.init,t))},ClassDeclaration(e,t){if(t.write("class "+(e.id?`${e.id.name} `:""),e),e.superClass){t.write("extends ");let{superClass:i}=e,{type:r}=i,s=t.expressionsPrecedence[r];(r[0]!=="C"||r[1]!=="l"||r[5]!=="E")&&(s===dt||s<t.expressionsPrecedence.ClassExpression)?(t.write("("),this[e.superClass.type](i,t),t.write(")")):this[i.type](i,t),t.write(" ")}this.ClassBody(e.body,t)},ImportDeclaration(e,t){t.write("import ");let{specifiers:i}=e,{length:r}=i,s=0;if(r>0){for(;s<r;){s>0&&t.write(", ");let n=i[s],a=n.type[6];if(a==="D")t.write(n.local.name,n),s++;else if(a==="N")t.write("* as "+n.local.name,n),s++;else break}if(s<r){for(t.write("{");;){let n=i[s],{name:a}=n.imported;if(t.write(a,n),a!==n.local.name&&t.write(" as "+n.local.name),++s<r)t.write(", ");else break}t.write("}")}t.write(" from ")}this.Literal(e.source,t),t.write(";")},ImportExpression(e,t){t.write("import("),this[e.source.type](e.source,t),t.write(")")},ExportDefaultDeclaration(e,t){t.write("export default "),this[e.declaration.type](e.declaration,t),t.expressionsPrecedence[e.declaration.type]!=null&&e.declaration.type[0]!=="F"&&t.write(";")},ExportNamedDeclaration(e,t){if(t.write("export "),e.declaration)this[e.declaration.type](e.declaration,t);else{t.write("{");let{specifiers:i}=e,{length:r}=i;if(r>0)for(let s=0;;){let n=i[s],{name:a}=n.local;if(t.write(a,n),a!==n.exported.name&&t.write(" as "+n.exported.name),++s<r)t.write(", ");else break}t.write("}"),e.source&&(t.write(" from "),this.Literal(e.source,t)),t.write(";")}},ExportAllDeclaration(e,t){e.exported!=null?t.write("export * as "+e.exported.name+" from "):t.write("export * from "),this.Literal(e.source,t),t.write(";")},MethodDefinition(e,t){e.static&&t.write("static ");let i=e.kind[0];(i==="g"||i==="s")&&t.write(e.kind+" "),e.value.async&&t.write("async "),e.value.generator&&t.write("*"),e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),oe(t,e.value.params),t.write(" "),this[e.value.body.type](e.value.body,t)},ClassExpression(e,t){this.ClassDeclaration(e,t)},ArrowFunctionExpression(e,t){t.write(e.async?"async ":"",e);let{params:i}=e;i!=null&&(i.length===1&&i[0].type[0]==="I"?t.write(i[0].name,i[0]):oe(t,e.params)),t.write(" => "),e.body.type[0]==="O"?(t.write("("),this.ObjectExpression(e.body,t),t.write(")")):this[e.body.type](e.body,t)},ThisExpression(e,t){t.write("this",e)},Super(e,t){t.write("super",e)},RestElement:ys=function(e,t){t.write("..."),this[e.argument.type](e.argument,t)},SpreadElement:ys,YieldExpression(e,t){t.write(e.delegate?"yield*":"yield"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t))},AwaitExpression(e,t){t.write("await ",e),ci(t,e.argument,e)},TemplateLiteral(e,t){let{quasis:i,expressions:r}=e;t.write("`");let{length:s}=r;for(let a=0;a<s;a++){let o=r[a],u=i[a];t.write(u.value.raw,u),t.write("${"),this[o.type](o,t),t.write("}")}let n=i[i.length-1];t.write(n.value.raw,n),t.write("`")},TemplateElement(e,t){t.write(e.value.raw,e)},TaggedTemplateExpression(e,t){ci(t,e.tag,e),this[e.quasi.type](e.quasi,t)},ArrayExpression:ws=function(e,t){if(t.write("["),e.elements.length>0){let{elements:i}=e,{length:r}=i;for(let s=0;;){let n=i[s];if(n!=null&&this[n.type](n,t),++s<r)t.write(", ");else{n==null&&t.write(", ");break}}}t.write("]")},ArrayPattern:ws,ObjectExpression(e,t){let i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:s}=t,n=i+t.indent;if(t.write("{"),e.properties.length>0){t.write(r),s&&e.comments!=null&&tt(t,e.comments,n,r);let a=","+r,{properties:o}=e,{length:u}=o;for(let c=0;;){let l=o[c];if(s&&l.comments!=null&&tt(t,l.comments,n,r),t.write(n),this[l.type](l,t),++c<u)t.write(a);else break}t.write(r),s&&e.trailingComments!=null&&tt(t,e.trailingComments,n,r),t.write(i+"}")}else s?e.comments!=null?(t.write(r),tt(t,e.comments,n,r),e.trailingComments!=null&&tt(t,e.trailingComments,n,r),t.write(i+"}")):e.trailingComments!=null?(t.write(r),tt(t,e.trailingComments,n,r),t.write(i+"}")):t.write("}"):t.write("}");t.indentLevel--},Property(e,t){e.method||e.kind[0]!=="i"?this.MethodDefinition(e,t):(e.shorthand||(e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),t.write(": ")),this[e.value.type](e.value,t))},PropertyDefinition(e,t){if(e.static&&t.write("static "),e.computed&&t.write("["),this[e.key.type](e.key,t),e.computed&&t.write("]"),e.value==null){e.key.type[0]!=="F"&&t.write(";");return}t.write(" = "),this[e.value.type](e.value,t),t.write(";")},ObjectPattern(e,t){if(t.write("{"),e.properties.length>0){let{properties:i}=e,{length:r}=i;for(let s=0;this[i[s].type](i[s],t),++s<r;)t.write(", ")}t.write("}")},SequenceExpression(e,t){oe(t,e.expressions)},UnaryExpression(e,t){if(e.prefix){let{operator:i,argument:r,argument:{type:s}}=e;t.write(i);let n=Ss(t,r,e);!n&&(i.length>1||s[0]==="U"&&(s[1]==="n"||s[1]==="p")&&r.prefix&&r.operator[0]===i&&(i==="+"||i==="-"))&&t.write(" "),n?(t.write(i.length>1?" (":"("),this[s](r,t),t.write(")")):this[s](r,t)}else this[e.argument.type](e.argument,t),t.write(e.operator)},UpdateExpression(e,t){e.prefix?(t.write(e.operator),this[e.argument.type](e.argument,t)):(this[e.argument.type](e.argument,t),t.write(e.operator))},AssignmentExpression(e,t){this[e.left.type](e.left,t),t.write(" "+e.operator+" "),this[e.right.type](e.right,t)},AssignmentPattern(e,t){this[e.left.type](e.left,t),t.write(" = "),this[e.right.type](e.right,t)},BinaryExpression:bs=function(e,t){let i=e.operator==="in";i&&t.write("("),ci(t,e.left,e,!1),t.write(" "+e.operator+" "),ci(t,e.right,e,!0),i&&t.write(")")},LogicalExpression:bs,ConditionalExpression(e,t){let{test:i}=e,r=t.expressionsPrecedence[i.type];r===dt||r<=t.expressionsPrecedence.ConditionalExpression?(t.write("("),this[i.type](i,t),t.write(")")):this[i.type](i,t),t.write(" ? "),this[e.consequent.type](e.consequent,t),t.write(" : "),this[e.alternate.type](e.alternate,t)},NewExpression(e,t){t.write("new ");let i=t.expressionsPrecedence[e.callee.type];i===dt||i<t.expressionsPrecedence.CallExpression||na(e.callee)?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),oe(t,e.arguments)},CallExpression(e,t){let i=t.expressionsPrecedence[e.callee.type];i===dt||i<t.expressionsPrecedence.CallExpression?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),e.optional&&t.write("?."),oe(t,e.arguments)},ChainExpression(e,t){this[e.expression.type](e.expression,t)},MemberExpression(e,t){let i=t.expressionsPrecedence[e.object.type];i===dt||i<t.expressionsPrecedence.MemberExpression?(t.write("("),this[e.object.type](e.object,t),t.write(")")):this[e.object.type](e.object,t),e.computed?(e.optional&&t.write("?."),t.write("["),this[e.property.type](e.property,t),t.write("]")):(e.optional?t.write("?."):t.write("."),this[e.property.type](e.property,t))},MetaProperty(e,t){t.write(e.meta.name+"."+e.property.name,e)},Identifier(e,t){t.write(e.name,e)},PrivateIdentifier(e,t){t.write(`#${e.name}`,e)},Literal(e,t){e.raw!=null?t.write(e.raw,e):e.regex!=null?this.RegExpLiteral(e,t):e.bigint!=null?t.write(e.bigint+"n",e):t.write(ia(e.value),e)},RegExpLiteral(e,t){let{regex:i}=e;t.write(`/${i.pattern}/${i.flags}`,e)}},oa={};var Zi=class{constructor(t){let i=t??oa;this.output="",i.output!=null?(this.output=i.output,this.write=this.writeToStream):this.output="",this.generator=i.generator!=null?i.generator:aa,this.expressionsPrecedence=i.expressionsPrecedence!=null?i.expressionsPrecedence:ra,this.indent=i.indent!=null?i.indent:" ",this.lineEnd=i.lineEnd!=null?i.lineEnd:`
|
|
9
9
|
`,this.indentLevel=i.startingIndentLevel!=null?i.startingIndentLevel:0,this.writeComments=i.comments?i.comments:!1,i.sourceMap!=null&&(this.write=i.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=i.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
|
|
10
10
|
`).length-1,this.mapping={original:null,generated:this,name:void 0,source:i.sourceMap.file||i.sourceMap._file})}write(t){this.output+=t}writeToStream(t){this.output.write(t)}writeAndMap(t,i){this.output+=t,this.map(t,i)}writeToStreamAndMap(t,i){this.output.write(t),this.map(t,i)}map(t,i){if(i!=null){let{type:n}=i;if(n[0]==="L"&&n[2]==="n"){this.column=0,this.line++;return}if(i.loc!=null){let{mapping:a}=this;a.original=i.loc.start,a.name=i.name,this.sourceMap.addMapping(a)}if(n[0]==="T"&&n[8]==="E"||n[0]==="L"&&n[1]==="i"&&typeof i.value=="string"){let{length:a}=t,{column:o,line:u}=this;for(let c=0;c<a;c++)t[c]===`
|
|
11
|
-
`?(o=0,u++):o++;this.column=o,this.line=u;return}}let{length:r}=t,{lineEnd:s}=this;r>0&&(this.lineEndSize>0&&(s.length===1?t[r-1]===s:t.endsWith(s))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}};function _s(e,t){let i=new Zi(t);return i.generator[e.type](e,i),i.output}var It=class{type="Identifier";whitelist=[];blacklist=[];constructor(t){this.whitelist[0]=t}get name(){return this.whitelist[0]}noConflict(t){let i=this.whitelist.indexOf(t);if(i===-1)return!1;this.blacklist.push(this.whitelist.splice(i,1)),this.whitelist.length||(this.whitelist=this.blacklist.map(r=>{let s;do{let n=String.fromCharCode(0|Math.random()*26+97);s=`${r}${n}`}while(this.blacklist.includes(s));return s}))}};var d={throwStmt(e){return{type:"ThrowStatement",argument:e}},tryStmt(e,t,i,r){return{type:"TryStatement",block:e,handler:t,finalizer:i,guardedHandlers:r}},catchClause(e,t){return{type:"CatchClause",param:e,body:t}},exprStmt(e){return{type:"ExpressionStatement",expression:e}},blockStmt(e){return{type:"BlockStatement",body:e}},labeledStmt(e,t){return{type:"LabeledStatement",label:e,body:t}},withStmt(e,t){return{type:"WithStatement",object:e,body:t}},ifStmt(e,t,i){return this.conditionalExpr(e,t,i,"IfStatement")},switchStmt(e,t,i=!1){return{type:"SwitchStatement",discriminant:e,cases:t}},switchCase(e,t){return{type:"SwitchCase",test:e,consequent:t}},whileStmt(e,t){return{type:"WhileStatement",test:e,body:t}},doWhileStmt(e,t){return{type:"DoWhileStatement",test:e,body:t}},forStmt(e,t,i,r){return{type:"ForStatement",init:e,test:t,update:i,body:r}},forInStmt(e,t,i){return{type:"ForInStatement",left:e,right:t,body:i}},forOfStmt(e,t,i){return{type:"ForOfStatement",left:e,right:t,body:i}},breakStmt(e=null){return{type:"BreakStatement",label:e}},continueStmt(e=null){return{type:"ContinueStatement",label:e}},returnStmt(e){return{type:"ReturnStatement",argument:e}},yieldExpr(e,t=!1){return{type:"YieldExpression",argument:e,delegate:t}},awaitExpr(e){return{type:"AwaitExpression",argument:e}},varDeclaration(e,t){return{type:"VariableDeclaration",kind:e,declarations:t}},varDeclarator(e,t=null){return{type:"VariableDeclarator",id:e,init:t}},funcDeclaration(e,t,i,r=!1,s=!1,n=!1){return this.func("FunctionDeclaration",...arguments)},sequenceExpr(e){return{type:"SequenceExpression",expressions:e}},parensExpr(e){return{type:"ParenthesizedExpression",expression:e}},logicalExpr(e,t,i){return{type:"LogicalExpression",operator:e,left:t,right:i}},binaryExpr(e,t,i){return{type:"BinaryExpression",operator:e,left:t,right:i}},unaryExpr(e,t,i=!0){return{type:"UnaryExpression",operator:e,argument:t,prefix:i}},updateExpr(e,t,i=!1){return{type:"UpdateExpression",operator:e,argument:t,prefix:i}},assignmentExpr(e,t,i="="){return{type:"AssignmentExpression",operator:i,left:e,right:t}},assignmentPattern(e,t){return{type:"AssignmentPattern",left:e,right:t}},thisExpr(){return{type:"ThisExpression"}},conditionalExpr(e,t,i,r="ConditionalExpression"){return{type:r,test:e,consequent:t,alternate:i}},arrayExpr(e){return{type:"ArrayExpression",elements:e}},arrayPattern(e){return{type:"ArrayPattern",elements:e}},objectExpr(e){return{type:"ObjectExpression",properties:e}},objectPattern(e){return{type:"ObjectPattern",properties:e}},chainExpr(e){return{type:"ChainExpression",expression:e}},callExpr(e,t,i=!1){return{type:"CallExpression",callee:e,arguments:t,optional:i}},newExpr(e,t){return{type:"NewExpression",callee:e,arguments:t}},taggedTemplateExpr(e,t){return{type:"TaggedTemplateExpression",tag:e,quasi:t}},memberExpr(e,t,i=!1,r=!1){return{type:"MemberExpression",object:e,property:t,computed:i,optional:r}},funcExpr(e,t,i,r=!1,s=!1,n=!1){return this.func("FunctionExpression",...arguments)},arrowFuncExpr(e,t,i,r=!1,s=!1,n=!1){return this.func("ArrowFunctionExpression",...arguments)},func(e,t,i,r,s=!1,n=!1,a=!1){return{type:e,id:t,params:i,body:r,async:s,expression:n,generator:a}},identifier(e){return{type:"Identifier",name:e}},property(e,t,i="init",r=!1,s=!1,n=!1){return{type:"Property",key:e,value:t,kind:i,shorthand:r,computed:s,method:n}},classDeclaration(e,t,i=null){return this.class("ClassDeclaration",...arguments)},classExpression(e,t,i=null){return this.class("ClassExpression",...arguments)},class(e,t,i,r=null){return{type:e,id:t,body:i,superClass:r}},methodDefinition(e,t,i="method",r=!1,s=!1){return{type:"MethodDefinition",key:e,value:t,kind:i,static:r,computed:s}},propertyDefinition(e,t,i=!1,r=!1){return{type:"PropertyDefinition",key:e,value:t,static:i,computed:r}},spreadElement(e){return{type:"SpreadElement",argument:e}},literal(e){if(typeof e=="object"&&!("name"in e)&&!("value"in e))throw new Error('Objects that convert to literals must have a "name" or "value" property.');return typeof e=="object"?{type:"Literal",get value(){return"name"in e?e.name:e.value}}:{type:"Literal",value:e}},templateLiteral(e,t){return{type:"TemplateLiteral",quasis:e,expressions:t}},comments(e){let t={};return Object.defineProperty(t,"toString",{value:()=>e}),Object.defineProperty(t,"trim",{value:function(){return this.toString()}}),[{type:"Line",value:t}]},withLoc(e,...t){return["start","end"].forEach(i=>{let r=i==="start"?t[0]:t[t.length-1];e[i]=r[i],r.loc&&(e.loc=e.loc||{},e.loc[i]=r.loc?.[i])}),e},invert(e){return this.unaryExpr("!",e)},clone(e){return e={...e},delete e.start,delete e.end,e}};var ue=class{type="BlockStatement";$body=[];constructor(t){this.body=t}get body(){return this.$body}set body(t){this.$body=t,d.withLoc(this,...t)}};var Ne=class{constructor(t,{type:i}){this.context=t,Object.assign(this,{type:i}),this.vars=new Set,this.$qIdentifiers=new Map,this.$qIdentifiersCursors={...this.context?.$qIdentifiersCursors||{}},this.locations=[]}index(t,i=!1){if(!this.type.includes("Function")&&this.context)return this.context.index(...arguments);let r=["start","end"].map(s=>{let n=[d.literal(t[s])];return i&&t.loc&&(n.push(d.literal(t.loc[s].line)),n.push(d.literal(t.loc[s].column))),d.arrayExpr(n)});return this.locations.push(d.arrayExpr(r)),d.literal(this.locations.length-1)}get$qIdentifier(t,i=!0,r=!1){let s=this.$qIdentifiers.get(t);if(!s){if(i&&this.context)return this.context.get$qIdentifier(t,i);r&&(typeof this.$qIdentifiersCursors[t]>"u"&&(this.$qIdentifiersCursors[t]=0),t+=this.$qIdentifiersCursors[t]++),this.$qIdentifiers.set(t,s=new It(t))}return s}getRandomIdentifier(t,i=!0){return this.get$qIdentifier(t,i,!0)}$qIdentifiersNoConflict(t){for(let[,i]of this.$qIdentifiers)i.noConflict(t);this.context&&this.context.$qIdentifiersNoConflict(t)}push(t,i,r=!1){let s;return["var","update"].includes(i)&&(s=this.find(t,!1))&&s.type!=="const"?s.willUpdate=!0:(i!=="update"||!this.context)&&(t instanceof It||this.$qIdentifiersNoConflict(t.name+""),this.vars.add({identifier:t,type:i,willUpdate:r||i==="update"})),this.context&&(i==="update"||i==="var"&&!this.type.includes("Function"))?this.context.push(t,i):!0}find(t,i=!0){let r;for(let s of this.vars)if(s.identifier.name+""==t.name+""){r=s;break}return!r&&i?this.context?.find(t,i):r}};var $e=class{history=[];scopes=[];functionTypes=["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression"];loopTypes=["DoWhileStatement","WhileStatement","ForStatement","ForOfStatement","ForInStatement"];labeledTypes=["SwitchStatement","LabeledStatement"];topLevelAwait=!1;topLevelArgsKeyword=!1;constructor(t={}){this.params=t}pushScope(t,i){let r=new Ne(this.currentScope,t);this.scopes.unshift(r);let s=i();return this.scopes.shift(),s}get currentScope(){return this.scopes[0]}pushHistory(t,i){this.history.unshift(t);let r=i();return this.history.shift(),r}get currentEntry(){return this.history[0]}serialize(t,i={}){return _s(t,{comments:!0,...i})}transform(t){if(t.type!=="Program")throw new Error('AST must be of type "Program".');return this.pushScope(t,()=>{let i=this.transformNodes(t.body,{static:!t.isQuantumProgram}),r={...t,body:i};r.body.length&&(r.body[0].comments=d.comments("Program body"));let s=d.exprStmt(d.assignmentExpr(this.$path("locations"),d.arrayExpr(this.currentScope.locations)));if(s.comments=d.comments("Location data"),r.body.unshift(s),this.exports.size){this.exports.forEach(c=>{r.body.push(d.exprStmt(this.$call("export",...c)))});let u=d.memberExpr(d.identifier("Promise"),d.identifier("all"));r.body.push(d.exprStmt(d.awaitExpr(d.callExpr(u,[this.$path("$promises.exports")]))))}let n=this.currentScope.get$qIdentifier("$q").name,a=this.serialize(r,{startingIndentLevel:this.params.startingIndentLevel}),o=this.params.base64?btoa(this.params.base64.replace("%0",n+"").replace("%1",a)):"";return{identifier:n,compiledSource:a,compiledSourceBase64:o,originalSource:t.originalSource,isQuantumProgram:t.isQuantumProgram,topLevelAwait:this.topLevelAwait,toString(u=void 0){return u==="base64"?this.compiledSourceBase64:this.compiledSource}}})}transformNodes(t,i={}){let r=t.length,[s,n,a]=t.reduce(([o,u,c],l)=>l.type==="ImportDeclaration"?[o.concat(l),u,c]:l.type==="FunctionDeclaration"?[o,u.concat(l),c]:[o,u,c.concat(l)],[[],[],[]]);return t=[...s,...n,...a],function o(u,c){if(c===r)return u;let[l,f]=this.transformNode(t[c],i,!0);if(u=u.concat(l||[]),c===s.length-1){let p=d.memberExpr(d.identifier("Promise"),d.identifier("all"));u=u.concat(d.exprStmt(d.awaitExpr(d.callExpr(p,[this.$path("$promises.imports")]))))}if(["ReturnStatement","BreakStatement","ContinueStatement"].includes(t[c].type))return u;if(f.flowControl?.size&&f.node.type==="IfStatement"){let p=t.slice(c+1);if(p.length){let m=new ue(p);return u.concat(this.transformNode(m))}}return o.call(this,u,c+1)}.call(this,[],0)}transformNode(t,i={},r=!1){if(typeof t!="object"||!t)return t;let s={static:this.currentEntry?.static,mode:this.currentEntry?.mode,...i,parentNode:this.currentEntry?.node,node:t,hoistedAwaitKeyword:!1,flowControl:new Map},n=this.pushHistory(s,()=>this[`transform${t.type}`]?this[`transform${t.type}`].call(this,t):Object.keys(t).reduce((a,o)=>{let u=Array.isArray(t[o])?this.transformNodes(t[o],i):this.transformNode(t[o],i);return{...a,[o]:u}},{}));return r?[n,s]:n}$serial(t){return this.currentScope.index(t,this.params.locations)}$path(t){return t.split(".").reduce((i,r)=>d.memberExpr(i,d.identifier(r)),this.currentScope.get$qIdentifier("$q"))}$trail(){return this.currentEntry.trail?[d.literal(this.currentEntry.trail)]:[]}$call(t,...i){return d.callExpr(this.$path(t),i)}$typed(t,i,r=null){let s=r?[d.literal(r)]:[];return this.$call("typed",d.literal(t),i,...s)}$obj(t){let i=Object.entries(t).map(([r,s])=>d.property(d.identifier(r),Array.isArray(s)?d.arrayExpr(s):s));return d.objectExpr(i)}$closure(...t){let i=t.pop(),r=t.pop()||[];return d.arrowFuncExpr(null,r,i,this.currentEntry.hoistedAwaitKeyword)}$var(t,i,r,s,...n){let a=s?this.$closure([this.currentScope.get$qIdentifier("$q")],s):d.identifier("undefined"),o=this.$call(t,d.literal(r),i,a,...n);return a.async&&(o=d.awaitExpr(o)),d.exprStmt(o)}$update(t,i,...r){let s=this.$closure(i);return this.$call("update",d.literal(t.name),s,...r)}$autorun(t,...i){let r=i.pop(),s=i.pop(),n=i.pop()||{},a=Object.keys(n).length?[this.$obj(n)]:[],o=this.$closure([this.currentScope.get$qIdentifier("$q")],r),u=this.$call("autorun",d.literal(t),...a,s,o);return o.async&&(u=d.awaitExpr(u)),d.exprStmt(u)}$iteration(t,i,r){let s=d.literal(t),n=this.currentEntry.parentNode.label?d.literal(this.currentEntry.parentNode.label.name):d.identifier("null"),a={kind:s,label:n},o=d.blockStmt(r);return this.$autorun("iteration",a,i,o)}hoistAwaitKeyword(){for(let t of this.history)if(t.hoistedAwaitKeyword=!0,t.node.type.includes("Function"))return;this.topLevelAwait=!0}hoistArgumentsKeyword(){let t=["FunctionDeclaration","FunctionExpression"];if(!this.history.some(i=>t.includes(i.node.type)))return this.topLevelArgsKeyword=!0,!0}hoistExitStatement(t,i={}){for(let r of this.history){let s=()=>r.node?.type==="SwitchStatement"&&t.value==="break"&&i.name==="null",n=()=>r.parentNode?.type==="LabeledStatement"&&this.loopTypes.includes(r.parentNode.body.type)&&i.value===r.parentNode.label.name,a=()=>this.loopTypes.includes(r.node.type)&&i.name==="null";if(s())return r.node;if(n()||a())return r.flowControl.set(t,{...i,endpoint:!0}),r.node;if(r.node.type.includes("Function"))return;r.flowControl.set(t,i)}}transformFunctionDeclaration(t){return this.transformFunction(d.funcDeclaration,...arguments)}transformFunctionExpression(t){return this.transformFunction(d.funcExpr,...arguments)}transformArrowFunctionExpression(t){return this.transformFunction(d.arrowFuncExpr,...arguments)}transformFunction(t,i){if(i.generator&&i.isQuantumFunction)throw new Error("Generator functions cannot be quantum functions.");let r=this.$serial(i),{id:s,params:n,body:a}=i;[s,n,a]=this.pushScope(i,()=>{let g=[];s&&this.currentScope.push(s,"self");let b=n.map(w=>{if(w.type==="AssignmentPattern"&&i.isQuantumFunction){let C=this.currentScope.getRandomIdentifier("$rand",!1),E=this.transformSignal(C,"param"),y=d.varDeclarator(w.left,d.withLoc(d.logicalExpr("||",C,w.right),w));return g.push(...this.transformNode(d.varDeclaration("let",[d.withLoc(y,w)]),{static:!i.isQuantumFunction})),E}return this.transformSignal(w,"param")}),v=this.transformNode(a,{static:!i.isQuantumFunction});g.push(...v.type==="BlockStatement"?v.body:[d.returnStmt(v)]),g.length&&(g[0].comments=d.comments("Function body"));let x=d.exprStmt(d.assignmentExpr(this.$path("locations"),d.arrayExpr(this.currentScope.locations)));return x.comments=d.comments("Location data"),g.unshift(x),[s,b,d.blockStmt(g)]});let o=this.currentScope.get$qIdentifier("$q"),u=this.$closure([o],a),c=d.identifier(i.isQuantumFunction||!1),l=d.identifier(i.type==="FunctionDeclaration"),f=d.blockStmt([d.returnStmt(this.$call("runtime.spawn",c,d.thisExpr(),u))]),p=g=>this.$call("function",l,c,r,g),m=t.call(d,s,n,f,i.async,i.expresion,i.generator);if(i.type==="FunctionDeclaration"){if(this.currentScope.push(s,"static"),m=[m,d.exprStmt(p(s))],this.currentEntry.isExport){let g=[d.literal(s),r];this.currentEntry.isExport==="as-default"&&g.push(d.literal("default")),this.exports.add([d.arrayExpr(g)])}}else this.currentEntry.isMethod||(m=p(m));return m}transformClassDeclaration(t){return this.transformClass(d.classDeclaration,...arguments)}transformClassExpression(t){return this.transformClass(d.classExpression,...arguments)}transformClass(t,i){let{id:r,body:s,superClass:n}=i;n&&(n=this.transformNode(n));let a=new Set;s=this.pushScope(i,()=>(r&&this.currentScope.push(r,"self"),this.transformNode(s,{methods:a})));let o=d.identifier(i.type==="ClassDeclaration"),u=l=>{let f=d.arrayExpr([...a].map(p=>this.$obj(p)));return this.$call("class",o,l,f)},c=t.call(d,r,s,n);if(i.type==="ClassDeclaration"){if(this.currentScope.push(r,"static"),c=[c,d.exprStmt(u(r))],this.currentEntry.isExport){let l=[d.literal(r),this.$serial(i)];this.currentEntry.isExport==="as-default"&&l.push(d.literal("default")),this.exports.add([d.arrayExpr(l)])}}else c=u(c);return c}transformMethodDefinition(t){let{key:i,value:r}=t;t.computed&&(i=this.transformNode(i));let s=this.transformNode(r,{static:!0,isMethod:!0});return this.currentEntry.methods.add({name:t.computed?i:d.literal(i),static:d.identifier(t.static),isQuantumFunction:d.identifier(r.isQuantumFunction||!1),serial:this.$serial(t)}),d.methodDefinition(i,s,t.kind,t.static,t.computed)}transformPropertyDefinition(t){let{key:i,value:r}=t;return t.computed&&(i=this.transformNode(i)),r=this.transformNode(r),d.exprStmt(d.propertyDefinition(i,r,t.static,t.computed))}exports=new Set;transformExportDefaultDeclaration(t){return this.handleExports(...arguments)}transformExportNamedDeclaration(t){return this.handleExports(...arguments)}transformExportAllDeclaration(t){return this.handleExports(...arguments)}handleExports(t){if(t.type==="ExportAllDeclaration"){let r=[d.literal("*"),this.$serial(t.exported||t),d.literal(t.exported?.name||t.exported?.value||"")];this.exports.add([d.arrayExpr(r),this.$obj({source:t.source,serial:this.$serial(t)})]);return}let i=r=>r.map(s=>{let n=[d.literal(s.local.name),this.$serial(s)],a=s.exported.name||s.exported.value;return a!==s.local.name&&n.push(d.literal(a)),d.arrayExpr(n)});if(t.source){this.exports.add(i(t.specifiers).concat(this.$obj({source:t.source,serial:this.$serial(t)})));return}if(t.type==="ExportNamedDeclaration"&&t.specifiers.length){this.exports.add(i(t.specifiers));return}if(t.type==="ExportDefaultDeclaration"&&["Identifier","ThisExpression"].includes(t.declaration.type)){let r=[d.literal(t.declaration.name||"this"),this.$serial(t),d.literal("default")];this.exports.add([d.arrayExpr(r)]);return}return this.transformNode(t.declaration,{isExport:t.type==="ExportDefaultDeclaration"?"as-default":!0})}transformImportDeclaration(t){let i=t.specifiers.map(r=>{let{imported:s,local:n}=r;this.transformSignal(n,"import"),r.type==="ImportNamespaceSpecifier"?s=d.identifier("*"):r.type==="ImportDefaultSpecifier"&&(s=d.identifier("default"));let a=s.name||s.value||"",o=[d.literal(a),this.$serial(r)];return a!==r.local.name&&o.push(d.literal(r.local.name)),d.arrayExpr(o)});return d.exprStmt(this.$call("import",...i.concat(this.$obj({source:t.source,serial:this.$serial(t)}))))}transformImportExpression(t){return this.$call("import",this.$obj({source:t.source,isDynamic:d.identifier("true"),serial:this.$serial(t)}))}transformSignal(t,i,r=null){return t.type==="Identifier"?(this.currentScope.push(t,i,["let","param"].includes(i)),r?.add(t),t):this.transformNode(t,{mode:i,static:!0,signals:r})}transformThisExpression(t){return this.transformIdentifier(...arguments)}transformIdentifier(t){let i=this.currentScope.find(t);!i&&t.name&&this.currentScope.$qIdentifiersNoConflict(t.name);let r=[];return t.hint?r.push(this.$obj({[t.hint]:d.identifier(!0)})):this.currentEntry.mode,t.type==="ThisExpression"||["param","self"].includes(i?.type)||["arguments"].includes(t.name)?this.currentEntry.trail?this.$call("obj",t,...this.$trail(),...r):t:(this.history.forEach(s=>s.refs?.add(t)),this.$call("ref",d.literal(t),...this.$trail(),...r))}transformMemberExpression(t){let{object:i,property:r,computed:s,optional:n}=t;s&&(r=this.transformNode(r));let a=this.transformNode(i,{trail:(this.currentEntry.trail||0)+1});return i.typed&&(a=this.$typed(i.typed,a,d.literal(r))),d.memberExpr(a,r,s,n)}transformVariableDeclaration(t){let i=this.currentEntry.isExport;return t.declarations.reduce((s,n)=>["ObjectPattern","ArrayPattern"].includes(n.id.type)?s.concat(this.expandPattern(n.id,n.init)):s.concat(n),[]).reduce((s,n)=>{let a=this.$serial(n),o=this.transformNode(n.init);this.transformSignal(n.id,t.kind,this.currentEntry.signals);let u=[];n.restOf&&(o=this.$typed(n.init.typed,o),u.push(this.$obj({restOf:n.restOf,type:d.literal(n.init.typed==="iterable"?"array":"object")})));let c=s.concat(this.$var(t.kind,a,n.id,o,...u));if(i&&!(n.id instanceof It)){let l=[d.literal(n.id),a];this.exports.add([d.arrayExpr(l)])}return c},[])}transformAssignmentExpression(t){let r=!this.currentEntry.static&&this.history[1].node.type==="ExpressionStatement",{left:s,right:n}=t,a=(u,c)=>(c=this.transformNode(c),u=this.transformNode(u),d.assignmentExpr(u,c,t.operator));if(["MemberExpression","ChainExpression"].includes(s.type))return a(s,n);if(["ObjectPattern","ArrayPattern"].includes(s.type)){let u=n,c=this.expandPattern(s,n,r).reduce((l,f)=>{if(f.id.originalB&&(u=f.id),f.type==="AssignmentExpression")return l.concat(a(f.left,f.right));let p=this.transformNode(f.init);if(f.id instanceof It){let g=this.$serial(f);return l.concat(this.$var("let",g,f.id,p))}this.transformSignal(f.id,"update",this.currentEntry.signals);let m=[];return f.restOf&&(p=this.$typed(f.init.typed,p),m.push(this.$obj({restOf:f.restOf,type:d.literal(f.init.typed==="iterable"?"array":"object")}))),l.concat(this.$update(f.id,p,...m))},[]);return r?c:d.sequenceExpr(c.concat(u))}n=this.transformNode(n),this.transformSignal(s,"update",this.currentEntry.signals);let o=this.currentScope.getRandomIdentifier("$current",!1);return this.$call("update",d.literal(s),this.$closure([o],d.assignmentExpr(o,n,t.operator.replace("====",""))))}transformAssignmentPattern(t){let{left:i,right:r}=t;return r=this.transformNode(r),["MemberExpression","ChainExpression"].includes(i.type)?i=this.transformNode(i,{static:!0}):i=this.transformSignal(i,this.currentEntry.mode,this.currentEntry.signals),d.assignmentPattern(i,r)}expandPattern(t,i,r=!0){let s=[],n=this;if(!["Identifier","Literal"].includes(i.type)&&r){let a=d.withLoc(n.currentScope.getRandomIdentifier("$rand",!1),i);a.originalB=!0,i.typed=t.type==="ObjectPattern"?"desctructurable":"iterable",s.push(d.withLoc(d.varDeclarator(a,i),i)),i=a}return function a(o,u,c){u.typed=c?"desctructurable":"iterable";let l=[];for(let f=0;f<o.length;f++){let p=o[f],m=f,g=p;if(p===null){l.push(f);continue}if(p.type==="RestElement"){let w=d.withLoc(d.varDeclarator(p.argument,u),p);w.restOf=l.map(C=>d.literal(C)),s.push(w);continue}c?{key:m,value:g}=p:m=d.literal(m);let b,v;g.type==="AssignmentPattern"?(b=g.right,g.left.type==="Identifier"?v=g.left:g=g.left):g.type==="Identifier"&&(v=g);let x=d.memberExpr(u,m,c?p.computed:!0);if(b&&(x=d.logicalExpr("||",x,b)),v)s.push(d.withLoc(d.varDeclarator(v,x),p)),l.push(m);else if(g.type==="MemberExpression"||g.type==="ChainExpression"&&(g=g.expression))s.push(d.withLoc(d.assignmentExpr(g,x),p));else if(g.elements||g.properties){let w=(g.properties?g.properties:g.elements).length>1;if(r&&w){let C=n.currentScope.getRandomIdentifier("$rand",!1);s.push(d.withLoc(d.varDeclarator(C,x),p)),x=C}a(g.elements||g.properties,x,g.properties&&!0)}}}(t.elements||t.properties,i,t.properties&&!0),s}transformUpdateExpression(t){if(t.argument.type==="Identifier"){this.transformSignal(t.argument,"update",this.currentEntry.signals);let i=this.currentScope.getRandomIdentifier("$current",!1),r=d.binaryExpr(t.operator==="--"?"-":"+",i,d.literal(1),!0),s=(t.prefix?"pre":"post")+(t.operator==="--"?"dec":"inc");return this.$call("update",d.literal(t.argument.name),this.$closure([i],r),this.$obj({kind:d.literal(s)}))}return d.updateExpr(t.operator,this.transformNode(t.argument),t.prefix)}transformUnaryExpression(t){return t.operator==="typeof"&&t.argument.type==="Identifier"&&(t.argument.hint="isTypeCheck"),d.unaryExpr(t.operator,this.transformNode(t.argument))}transformIfStatement(t){let i=this.$serial(t),{test:r,consequent:s,alternate:n}=t;r=this.transformNode(t.test),s=this.pushScope(t,()=>this.transformNodes([t.consequent])),s[0].type!=="BlockStatement"&&s.length>1?s=d.blockStmt(s):s=s[0],n&&(n=this.pushScope(t,()=>this.transformNodes([t.alternate])),n[0]&&n[0].type!=="BlockStatement"&&n.length>1?n=d.blockStmt(n):n=n[0],n.type==="BlockStatement"&&(n=this.$autorun("block",this.$serial(t.alternate),n)));let a=d.ifStmt(r,s,n);return this.currentEntry.static?a:this.$autorun("block",i,d.blockStmt([a]))}transformSwitchStatement(t){let i=this.$serial(t);return this.pushScope(t,()=>{let r=this.transformNode(t.discriminant),s=t.cases.map(a=>{let o=this.transformNode(a.test),u=this.transformNodes(a.consequent);return d.switchCase(o,u)}),n=d.switchStmt(r,s);return this.currentEntry.static?n:this.$autorun("block",$loc,d.blockStmt([n]))})}transformWhileStatement(t){return this.transformLoopStmtA(d.whileStmt,...arguments)}transformDoWhileStatement(t){return this.transformLoopStmtA(d.doWhileStmt,...arguments)}transformForStatement(t){return this.transformLoopStmtA(d.forStmt,...arguments)}transformLoopStmtA(t,i){let r=i.type==="WhileStatement"?"while":i.type==="DoWhileStatement"?"do-while":"for",s=this.$serial(i);return this.pushScope(i,()=>{let n=this.currentScope.get$qIdentifier("$q"),a,o={kind:d.literal(r),label:this.currentEntry.parentNode.label?d.literal(this.currentEntry.parentNode.label.name):d.identifier("null")};if(r==="for"){let c=d.blockStmt(this.transformNode(i.init));o.init=this.$closure([n],c);let l=this.transformNode(i.test);o.test=this.$closure([n],l);let f=this.transformNode(i.update);o.advance=this.$closure([n],f),a=p=>t.call(d,c,l,f,p)}else{let c=this.transformNode(i.test);o.test=this.$closure([n],c),a=l=>t.call(d,c,l)}let u=this.transformNode(i.body);return this.currentEntry.static?a(u):this.$autorun("iteration",o,s,u)})}transformForOfStatement(t){return this.transformLoopStmtB(d.forOfStmt,...arguments)}transformForInStatement(t){return this.transformLoopStmtB(d.forInStmt,...arguments)}transformLoopStmtB(t,i){let r=i.type==="ForInStatement"?"for-in":"for-of",s=this.$serial(i),n=this.transformNode(i.right);return this.pushScope(i,()=>{if(this.currentEntry.static){let[f,p]=this.transformNodes([i.left,i.body]);return t.call(d,f,n,p)}let a=this.currentScope.get$qIdentifier("$q"),o=this.currentScope.get$qIdentifier(r==="for-of"?"$val":"$key",!1),u={kind:d.literal(r),label:this.currentEntry.parentNode.label?d.literal(this.currentEntry.parentNode.label.name):d.identifier("null"),parameters:this.$closure([a],d.arrayExpr([d.literal(o),n]))},c;if(i.left.type==="VariableDeclaration"){let f=d.withLoc(d.varDeclarator(i.left.declarations[0].id,o),i.left);c=d.varDeclaration(i.left.kind,[f])}else c=d.withLoc(d.assignmentExpr(i.left,o),i.left);let l=d.blockStmt(this.transformNodes([c].concat(i.body.body)));return this.$autorun("iteration",u,s,l)})}transformBreakStatement(t){return this.transformExitStmt(d.breakStmt,...arguments)}transformContinueStatement(t){return this.transformExitStmt(d.continueStmt,...arguments)}transformExitStmt(t,i){let r=i.type==="BreakStatement"?"break":"continue",s=d.literal(r),n=i.label?d.literal(i.label.name):d.identifier("null");return this.hoistExitStatement(s,n)?.type==="SwitchStatement"?t.call(d):d.exprStmt(this.$call(r,n))}transformReturnStatement(t){let i=new Set,r=this.transformNode(t.argument,{refs:i});if(this.currentEntry.static)return d.returnStmt(r);let s=d.literal("return"),n=r?[s,r]:[s];this.hoistExitStatement(...n);let a=this.$call("return",...n.slice(1));if(!i.size)return d.exprStmt(a);let o=this.$serial(t);return this.$autorun("return",o,a)}transformBlockStatement(t){if(t instanceof ue){let r=this.$serial(t),s=this.transformNodes(t.body);return this.$autorun("downstream",r,d.blockStmt(s))}let i=this.pushScope(t,()=>this.transformNodes(t.body));return d.blockStmt(i)}transformLabeledStatement(t){this.currentScope.push(t.label,"const");let i=[].concat(this.transformNode(t.body));return[d.labeledStmt(t.label,i.shift()),...i]}transformExpressionStatement(t){let i=this.$serial(t);return[].concat(this.transformNode(t.expression)||[]).reduce((s,n)=>n.type==="VariableDeclaration"||n.type.endsWith("Statement")?s.concat(n):this.currentEntry.static?d.exprStmt(n):s.concat(this.$autorun("stmt",i,n)),[])}transformAwaitExpression(t){this.hoistAwaitKeyword();let i=this.transformNode(t.argument);return d.awaitExpr(i)}transformSequenceExpression(t){let i=t.expressions.reduce((r,s,n)=>r.concat(this.transformNode(s,{trail:n===t.expressions.length-1?this.currentEntry.trail:void 0})),[]);return this.history[1].node.type==="ExpressionStatement"?i:d.sequenceExpr(i)}transformConditionalExpression(t){let{test:i,consequent:r,alternate:s}=t;return i=this.transformNode(i),r=this.transformNode(r,{trail:this.currentEntry.trail}),s=this.transformNode(s,{trail:this.currentEntry.trail}),d.conditionalExpr(i,r,s)}transformLogicalExpression(t){let{left:i,right:r}=t;return i=this.transformNode(i,{trail:this.currentEntry.trail}),r=this.transformNode(r,{trail:this.currentEntry.trail}),d.logicalExpr(t.operator,i,r)}transformBinaryExpression(t){let{left:i,right:r}=t;i=this.transformNode(i),r=this.transformNode(r);let s=d.binaryExpr(t.operator,i,r);return this.currentEntry.trail?this.$call("obj",s,...this.$trail()):s}transformCallExpression(t){return this.transformCallExpr(d.callExpr,...arguments)}transformNewExpression(t){return this.transformCallExpr(d.newExpr,...arguments)}transformCallExpr(t,i){let r=this.transformNode(i.callee,{mode:"callee"}),s=i.arguments.map(a=>this.transformNode(a)),n=t.call(d,r,s,i.optional);return this.currentEntry.trail?this.$call("obj",n,...this.$trail()):n}transformObjectExpression(t){let i=d.objectExpr(t.properties.map(r=>this.transformNode(r)));return this.currentEntry.trail?this.$call("obj",i,...this.$trail()):i}transformProperty(t){let{key:i,value:r}=t;return t.computed&&(i=this.transformNode(i)),r=this.transformNode(r),d.property(i,r,t.kind,!1,t.computed,!1)}transformArrayExpression(t){let i=d.arrayExpr(t.elements.map(r=>this.transformNode(r)));return this.currentEntry.trail?this.$call("obj",i,...this.$trail()):i}transformTaggedTemplateExpression(t){let[i,r]=this.transformNodes([t.tag,t.quasi]),s=d.taggedTemplateExpr(i,r);return this.currentEntry.trail?this.$call("obj",s,...this.$trail()):s}transformTemplateLiteral(t){let i=t.expressions.map(s=>this.transformNode(s)),r=d.templateLiteral(t.quasis,i);return this.currentEntry.trail?this.$call("obj",r,...this.$trail()):r}};var Es=new Map;function Cs(e,t={}){let i=`${e}${JSON.stringify(t)}`,r=Es.get(i);if(!r){try{r=ms.parse(e,t)}catch(s){let n=`${s.message||s}`,{pos:a,loc:{line:o,column:u}={}}=s,l=[{expr:e.slice(Math.max(0,a-15),a+15),line:o,column:u},{source:e}];throw t.inBrowser&&console.error(l),new(globalThis[s.name]||Error)(n,{cause:l})}Es.set(i,r)}return r}function ks(e,t={}){return new $e(t).transform(e)}function li(...e){let t,i={runtimeParams:la,compilerParams:ca,parserParams:ua};for(;t=e.shift();){let{runtimeParams:r={},compilerParams:{globalsNoObserve:s=[],globalsOnlyPathsExcept:n=[],...a}={},parserParams:o={}}=t;i={runtimeParams:{...i.runtimeParams,...r},compilerParams:{...i.compilerParams,globalsNoObserve:[...i.compilerParams.globalsNoObserve,...s],globalsOnlyPathsExcept:[...i.compilerParams.globalsOnlyPathsExcept,...n],...a},parserParams:{...i.parserParams,...o}},e.devMode}return i}var ua={ecmaVersion:"latest",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!1,allowSuperOutsideMethod:!1,preserveParens:!1,locations:!0},ca={globalsNoObserve:["arguments","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},la={apiVersion:3};var Le=Object.create(null);var Bt=class extends EventTarget{managedAlways=new Set;managedOnce=new Set;constructor(){super(),Ir.setMaxListeners?.(0,this)}fire(t){return this.dispatchEvent(new Event(t,{cancelable:!0}))}on(...t){return this.addEventListener(...t),()=>this.removeEventListener(...t)}abort(t=!1){this.managedAlways.forEach(i=>i.abort?i.abort(t):i(t)),this.managedOnce.forEach(i=>i.abort?i.abort(t):i(t)),this.managedOnce.clear(),this.fire("abort")}manage(t){this.managedAlways.add(t)}once(t){this.managedOnce.add(t)}};var Ht=class extends Bt{subscribers=new Set;signals=new Map;constructor(t,i,r){super(),this.context=t,this.context?.once(()=>this.abort()),this.once(()=>this.watchMode(!1)),this.type=i,this.state=r}get name(){return[...this.context?.signals.keys()||[]].find(t=>this.context.signals.get(t)===this)}signal(t,i="prop"){let r=this.signals.get(t);return r||(r=new Ht(this,i,i==="object"?t:Mi(this.state)?R.get(this.state,t):void 0),this.signals.set(t,r),this.signals.size===1&&this.watchMode(),r.once(()=>{this.signals.delete(t),this.signals.size||this.watchMode(!1)})),r}subscribe(t){this.subscribers.add(t),t.once(()=>{this.subscribers.delete(t),this.subscribers.size||this.abort()})}watchMode(t=!0){this.mutationsWatch?.abort(),!(!t||!this.signals.size||!Mi(this.state))&&(this.mutationsWatch=R.observe(this.state,i=>{let r={map:new Map,add(n,a){for(let o of n)o.spec.beforeSchedule?.(a)!==!1&&(this.map.has(o.runtime)||this.map.set(o.runtime,new Set),this.map.get(o.runtime).add(o))}};for(let n of i){let a=this.signals.get(n.key);!a||(r.add(a.subscribers,n),a.refresh(n.value))}let s=r.map.size?[...r.map].sort((n,a)=>n.$serial>a.$serial?-1:1):r.map;for(let[n,a]of s)n.state!=="aborted"&&n.schedule(...a)},{recursions:"force-sync"}))}refresh(t){this.state=t;for(let[i,r]of this.signals)r.refresh(R.get(this.state??{},i));this.watchMode()}};var et=class extends Ht{symbols=new Map;constructor(t,i,r=void 0){super(t,i,r||Object.create(null))}};var bt=class extends Bt{state;constructor(t,i,r,s,n,a){super(),t?.once(this),this.context=t,this.type=i,this.spec=r,this.scope=n,t?.scope!==n&&this.manage(n),this.serial=s,a&&(this.closure=a),t?.type==="iteration"?this.path=t.path.concat(this.spec.index):t?.type==="round"?this.path=t.path.concat(this.serial):this.path=(t?.path||[]).slice(0,-1).concat(this.serial),this.flowControl=new Map}get runtime(){return this.context.runtime}contains(t){return this===t.context||t.context&&this.contains(t.context)}order(t){if(!t)return this;let[i,r]=t.path.length<this.path.length?[t,this]:[this,t];return i.path.reduce((s,n,a)=>s&&n<=r.path[a],!0)&&i||r}beforeExecute(){this.state="running";let t=this.flowControl;return this.flowControl=new Map,t}execute(t=null){try{return this.runtime.thread.unshift(this),nt(this.beforeExecute(),i=>Ri(this.closure,this,this,r=>(this.spec.complete&&(r=this.spec.complete(r,this)),this.afterExecute(i),this.runtime.thread.shift(),t?t(r,this):r)))}catch(i){if(i.cause)throw i;let r=`${i.message||i}`;this.runtime.throw(r,[this.serial,this.context?.serial],globalThis[i.name])}}afterExecute(t){this.state="complete";let i=this.flowControl;this.handleDownstream(i.size,t.size),this.handleRightstream(i.size,t.size);for(let r of["break","continue","return"])i.has(r)&&!i.get(r).endpoint?this.hoistFlowControl(r,i.get(r).arg):t.has(r)&&!t.get(r).endpoint&&this.hoistFlowControl(r,t.get(r).arg,!0)}typed(t,i,r=void 0){let s=Array.isArray(i)?"array":i===null?"null":typeof i;if(s===t||t==="iterable"&&i?.[Symbol.iterator]||t==="desctructurable"&&!["undefined","null"].includes(s))return i;throw t==="iterable"?new Error("value is not iterable."):t==="desctructurable"?new Error((r?`Cannot access ${r}; `:"")+"object not desctructurable."):new Error(`value must be of type ${t}.`)}let(t,i,r,s={}){return this.var(t,i,r,{...s,kind:"let"})}const(t,i,r,s={}){return this.var(t,i,r,{...s,kind:"const"})}var(t,i,r,s={}){s={kind:"var",...s},r||(r=()=>{});let n=s.restOf?(...o)=>{try{return r(...o)}catch(u){throw new Error(`Cannot declare ${t}; ${u.message}`)}}:r,a=(o,u)=>{let c=u.scope;if(s.kind==="var")for(;!["module","function"].includes(c.type)&&!R.has(c.state,t)&&c.context;)c=c.context;else c.type==="this"&&c.context&&(c=c.context);let l=c.symbols.get(t);if(l&&(l.kind!==s.kind||s.kind==="let"&&l.serial!==i))throw new Error(`Identifier "${t}" has already been declared.`);l?.reader?.abort(),l={serial:i,kind:s.kind};let f=o;return s.restOf&&(s.type==="array"?f=[]:f={},l.reader=R.map(o,f,{except:s.restOf,spread:s.type==="array"}),u.once(l.reader)),c.symbols.set(t,l),R.set(c.state,t,f),f};return this.autorun(s.kind,{complete:a,...s},i,n)}update(t,i,r={}){let s=this.scope;for(;s&&!R.has(s.state,t);)s=s.context;if(!s)throw new ReferenceError(`${t} is not defined.`);let n=s.symbols.get(t);if(n?.kind==="const")throw new ReferenceError(`Assignment to constant variable "${t}".`);let a=R.get(s.state,t),o=r.restOf?(...u)=>{try{return i(...u)}catch(c){throw new Error(`Cannot update ${t}; ${c.message}`)}}:i;return Ri(o,void 0,a,u=>{n?.reader?.abort();let c=u;return r.restOf&&(n=n||{},r.type==="array"?c=[]:c={},n.reader=R.map(u,c,{except:r.restOf,spread:r.type==="array"}),this.once(n.reader)),R.set(s.state,t,c),["postinc","postdec"].includes(r.kind)?a:c})}ref(t,...i){let r=0,s={};typeof i[0]=="number"?(r=i.shift(),s=i.shift()||{}):typeof i[0]=="object"&&(s=i.shift());let n=this.scope;for(;n&&!R.has(n.state,t);)n=n.context;if(!n){if(s.isTypeCheck)return;throw new Error(`${t} is not defined.`)}let a=n.symbols.get(t)?.kind,o=n.signal(t,a);return s.typed&&this.typed(s.typed,o.state,t),this.autobind(o,r,s)}obj(t,...i){let r=0,s={};return typeof i[0]=="number"?(r=i.shift(),s=i.shift()||{}):typeof i[0]=="object"&&(s=i.shift()),this.autobind(this.runtime.$objects.signal(t,"object"),r,s)}autobind(t,i,r){let s=this.runtime.$params.quantumMode,n=t.type==="const",a=this===this.runtime,o=this.state==="aborted",u=this;return function c(l,f){if(s&&!n&&!a&&!o&&l.subscribe(u),!f||!l.state||typeof l.state!="object"){let m=l.state;return typeof l.state=="function"&&(m=R.proxy(l.state,{membrane:l})),m}let p;return R.proxy(l.state,{},m=>({...m,get(g,b,v=null){return p?m.get(g,b,v):(p=!0,c(l.signal(b),f-1))}}))}(t,i)}autorun(t,...i){let r=i.pop(),s=i.pop(),n=i.pop()||{},a=bt,o=this.scope;if(t==="iteration"){let c=this.runtime.constructor;a=r.constructor.name==="AsyncFunction"?c.AutoAsyncIterator:c.AutoIterator}["block","iteration"].includes(t)&&(o=new et(o,t));let u=new a(this,t,n,s,o,r);if(!(t==="downstream"&&(this.downstream=u,this.flowControlApplied())))return u.execute()}function(t,i,r,s){t&&R.set(this.scope.state,s.name,s);let n=this;return Object.defineProperty(s,"toString",{value:function(a=!1){if(a&&i)return Function.prototype.toString.call(s);let o=n.runtime.extractSource(r);return o.startsWith("static ")?o.replace("static ",""):o}}),s}class(t,i,r){return t&&R.set(this.scope.state,i.name,i),r.forEach(({name:s,static:n,isQuantumFunction:a,serial:o})=>{this.function(!1,a,o,n?i[s]:i.prototype[s])}),i}async import(...t){return this.runtime.import(...t)}async export(...t){return this.runtime.export(...t)}continue(t){return this.applyFlowControl("continue",t)}break(t){return this.applyFlowControl("break",t)}return(t){return this.applyFlowControl("return",t)}applyFlowControl(t,i,r=!1){let s=this.flowControl.size;if(r?this.flowControl.delete(t):this.flowControl.set(t,{arg:i}),this.type==="round"&&(this.context.breakpoint=this),this.type==="round"&&["break","continue"].includes(t)&&i===this.context?.spec.label){r||(this.flowControl.get(t).endpoint=!0),this.state!=="running"&&this.handleRightstream(this.flowControl.size,s);return}this.state!=="running"&&(this.handleDownstream(this.flowControl.size,s),this.hoistFlowControl(...arguments))}hoistFlowControl(...t){return this.context?.applyFlowControl(...t)}flowControlApplied(t,i){return arguments.length?arguments.length===1?this.flowControl.has(t):this.flowControl.get(t)?.arg===i:this.flowControl.size||!1}handleDownstream(t,i){let r;this.type!=="block"||!(r=this.context?.downstream)||(t?r.abort():i&&(r.state="resuming",this.runtime.schedule(r)))}handleRightstream(t,i){if(this.type!=="round")return;let r=this,s=new Set;for(;r=r.nextRound;)t?r.abort():i&&r.state!=="inert"&&(r.state="resuming",s.add(r));s.size&&this.runtime.schedule(...s),!t&&i&&this.runtime.on("reflection",()=>{this.context.iterating||this.context.iterate()},{once:!0})}abort(t=!1){return t&&(this.context?.breakpoint===this&&delete this.context.breakpoint,this.flowControl.clear()),this.state=t?"inert":"aborted",super.abort(t)}};var Ut=class extends bt{rounds=new Map;constructor(t,i,r,s,n,a){r.$closure=a,super(t,i,r,s,n),this.manage(()=>{delete this.breakpoint,this.rounds.clear()})}pseudorun(t){return this.runtime.iThread.unshift(this),nt(t(),i=>(this.runtime.iThread.pop(),i))}createIterator(){return this.spec.kind==="for-in"?function*(){for(let t in this.iteratee)yield t}.call(this):this.spec.kind==="for-of"?function*(){for(let t of this.iteratee)yield t}.call(this):{next:()=>({done:!this.pseudorun(()=>this.spec.test(this))})}}closure(){["for-of","for-in"].includes(this.spec.kind)?([this.production,this.iteratee]=this.spec.parameters(this),this.iterator=this.createIterator(),this.iterator.original=!0,this.watchMode()):(this.spec.kind==="for"&&this.spec.init(this),this.iterator=this.createIterator()),this.iterate()}terminated(){return this.breakpoint&&!this.breakpoint.flowControlApplied("continue",this.spec.label)&&this.breakpoint.flowControlApplied()}advance(){this.spec.kind==="for"&&this.pseudorun(()=>this.spec.advance(this))}iterate(){this.iterating=!0;let t=()=>!this.terminated()&&!(this.cursor=this.iterator.next()).done,i=()=>{this.createRound(this.cursor.value).execute(),this.advance()};if(this.spec.kind==="do-while")do i();while(t());else for(;t();)i();this.iterating=!1}createRound(t){let i=this.rounds.size,r={index:i},s=["for-in","for-of"].includes(this.spec.kind)?{[this.production]:t}:{...this.scope.state},n=new et(this.scope,"round",s);this.scope.symbols.forEach((u,c)=>{n.symbols.set(c,u)});let a=new bt(this,"round",r,this.serial,n,this.spec.$closure),o=this.spec.kind==="for-in"?t:i;return this.rounds.set(o,a),this.lastRound&&(this.lastRound.nextRound=a,a.prevRound=this.lastRound),this.lastRound=a,a}watchMode(){let t=(i,r)=>{let s=new Set,n=new Set;for(let a of i){if(Array.isArray(this.iteratee)&&a.key==="length")continue;let o=this.spec.kind==="for-in"?a.key:a.value,u=this.spec.kind==="for-in"?a.key:parseInt(a.key),c=this.rounds.get(u);if(c)R.set(c.scope.state,this.production,o),a.type==="delete"&&(this.rounds.set(u,void 0),c.prevRound&&(c.prevRound.nextRound=c.nextRound),c.nextRound&&(c.nextRound.prevRound=c.prevRound),s.add(c));else if(a.type!=="delete"&&!a.isUpdate){if(this.spec.kind==="for-of"&&this.iterator.original&&!r.done)continue;n.add(o)}}this.runtime.on("reflection",()=>{s.forEach(a=>a.abort(!0))},{once:!0}),n.size&&(this.iterator=function*(a){yield*a,yield*n}(this.iterator),r.done&&this.iterate())};this.once(R.observe(this.iteratee,i=>{nt(this.cursor,r=>t(i,r))}))}};var Re=class extends Ut{async createIterator(){return this.spec.kind==="for-in"?function*(){for(let t in this.iteratee)yield t}.call(this):this.spec.kind==="for-of"?function*(){for(let t of this.iteratee)yield t}.call(this):{next:async()=>({done:!await this.pseudorun(()=>this.spec.test(this))})}}async closure(){["for-of","for-in"].includes(this.spec.kind)?([this.production,this.iteratee]=await this.spec.parameters(this),this.iterator=await this.createIterator(),this.iterator.original=!0,this.watchMode()):(this.spec.kind==="for"&&await this.spec.init(this),this.iterator=await this.createIterator()),await this.iterate()}async iterate(){let t;this.iterating=!0;let i=async()=>!this.terminated()&&(this.cursor=this.iterator.next())&&(t=await this.cursor)&&!t.done,r=async()=>{await this.createRound(t.value).execute(),await this.advance()};if(this.spec.kind==="do-while")do await r();while(await i());else for(;await i();)await r();this.iterating=!1}};var Wt=class{constructor(t){Object.defineProperty(this,"runtime",{value:t});let i={statechange:()=>{R.defineProperty(this,"value",{value:t.flowControl.get("return")?.arg,enumerable:!0,configurable:!0})}};for(let r in i)t.on(r,i[r]),i[r]();t.$params.sourceType==="module"&&Object.defineProperty(this,"exports",{value:t.exports})}dispose(){return this.runtime.abort(!0)}};var zt=class extends bt{locations=[];queue=new Set;thread=[];iThread=[];constructor(t,i,r,s,n){super(t,i,{},-1,s,n);let{$serial:a=0,...o}=r;this.$serial=a,this.$params=o,this.$objects=new et(void 0,"objects"),this.manage(this.$objects),this.exports=Object.create(null),this.$promises={imports:[],exports:[]},this.manage(()=>{R.deleteProperties(this.exports,Object.keys(this.exports)),this.$promises.imports.splice(0),this.$promises.exports.splice(0)})}extractSource(t,i=!1){let[[r,s,n],[a]]=this.locations[t],o=this.$params.originalSource.slice(r,a);return i?{expr:o,line:s,column:n}:o}throw(t,i,r=null,s=null){let n,a=s!==null?`[${s}]: ${t}`:t,o=i.map(c=>c!==-1&&this.extractSource(c,!0)).filter(c=>c);o.push({source:this.$params.originalSource}),n=new(r||Error)(a,{cause:o});let u=this.$params.sourceType==="module"&&this.$params.experimentalFeatures!==!1&&this.$params.exportNamespace||this.$params.fileName;throw u&&(n.fileName=u),s&&(n.code=s),n}get runtime(){return this}get nowRunning(){return this.thread[0]}schedule(...t){let i=this.queue.size;for(let r of t)this.queue.add(r);if(!i)return this.flowControlDirty=!1,function r(s,n){let a;for(let o of this.queue){if(n&&n.order(o)!==n||["aborted","running"].includes(o.state)||this.iThread[0]?.contains(o)){this.queue.delete(o);continue}a=a?a.order(o):o,n||(n=a)}return a?(a.abort(),a.execute(o=>(this.queue.delete(a),r.call(this,o,a)))):(this.fire("reflection"),this.flowControlApplied()&&this.fire("statechange"),s)}.call(this,void 0,this.nowRunning)}execute(t=null){return super.execute(i=>{let r=this.$params.quantumMode?new Wt(this):i;return t?t(r,this):r})}spawn(t,i,r){let s=this.nowRunning||this,n={...this.$params,$serial:this.$serial+1,quantumMode:t},a=new et(s.scope,"function",{this:i});return new this.constructor(s,"function",n,a,r).execute()}async import(...t){let i=t.pop(),r=typeof i=="string"?{source:i}:i,s=a=>{if(r.forExport||r.isDynamic)return a;this.assignModules(t,this.scope.state,a,i.serial)};if(this.$params.experimentalFeatures!==!1&&Le[r.source])return s(Le[r.source]);let n=(async()=>{let a=this.$params.sourceType==="module"&&this.$params.experimentalFeatures!==!1&&this.$params.exportNamespace||this.$params.fileName;try{return s(await import(r.source))}catch(o){throw o.code==="ERR_MODULE_NOT_FOUND"&&this.throw(`Cannot find package "${r.source}"${a?` imported at "${a}"`:""}.`,[r.serial],null,o.code),o}})();return r.isDynamic||this.$promises[r.forExport?"exports":"imports"].push(n),n}async export(...t){let i=Array.isArray(t[t.length-1])?null:t.pop(),r=i?await this.import({...i,forExport:!0}):this.scope.state;this.assignModules(t,this.exports,r,i?.serial)}assignModules(t,i,r,s=null){let n=[];for(let[a,o,u]of t){if(a==="*"&&u){(this.$params.quantumMode?R:Reflect).set(i,u,r);continue}R.has(r,a)||this.throw(`The requested module does not provide an export named "${a}".`,[o,s]),(this.$params.quantumMode?R:Reflect).set(i,u||a,R.get(r,a)),n.push([a,o,u])}!n.length||!this.$params.quantumMode||this.once(R.observe(r,a=>{for(let[o,,u]of n)for(let c of a)o==="*"?R.set(i,c.key,c.value):c.key===o&&R.set(i,u||o,c.value)}))}afterExecute(...t){return this.$params.sourceType==="module"&&this.$params.experimentalFeatures!==!1&&this.$params.exportNamespace&&(Le[this.$params.exportNamespace]=this.exports,this.once(()=>{delete Le[this.$params.exportNamespace]})),super.afterExecute(...t)}};G(zt,"AutoAsyncIterator",Re),G(zt,"AutoIterator",Ut);function Me(e,t,i,r){let{env:s,functionParams:n=[],exportNamespace:a,fileName:o}=r,{parserParams:u,compilerParams:c,runtimeParams:l}=li(r),f=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1,p=["async-script","module"].includes(e);if(e==="module")u.sourceType=e,u.allowAwaitOutsideFunction=!0;else if(["function","async-function"].includes(e)){let g=" "+i.split(`
|
|
11
|
+
`?(o=0,u++):o++;this.column=o,this.line=u;return}}let{length:r}=t,{lineEnd:s}=this;r>0&&(this.lineEndSize>0&&(s.length===1?t[r-1]===s:t.endsWith(s))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}};function _s(e,t){let i=new Zi(t);return i.generator[e.type](e,i),i.output}var It=class{type="Identifier";whitelist=[];blacklist=[];constructor(t){this.whitelist[0]=t}get name(){return this.whitelist[0]}noConflict(t){let i=this.whitelist.indexOf(t);if(i===-1)return!1;this.blacklist.push(this.whitelist.splice(i,1)),this.whitelist.length||(this.whitelist=this.blacklist.map(r=>{let s;do{let n=String.fromCharCode(0|Math.random()*26+97);s=`${r}${n}`}while(this.blacklist.includes(s));return s}))}};var d={throwStmt(e){return{type:"ThrowStatement",argument:e}},tryStmt(e,t,i,r){return{type:"TryStatement",block:e,handler:t,finalizer:i,guardedHandlers:r}},catchClause(e,t){return{type:"CatchClause",param:e,body:t}},exprStmt(e){return{type:"ExpressionStatement",expression:e}},blockStmt(e){return{type:"BlockStatement",body:e}},labeledStmt(e,t){return{type:"LabeledStatement",label:e,body:t}},withStmt(e,t){return{type:"WithStatement",object:e,body:t}},ifStmt(e,t,i){return this.conditionalExpr(e,t,i,"IfStatement")},switchStmt(e,t,i=!1){return{type:"SwitchStatement",discriminant:e,cases:t}},switchCase(e,t){return{type:"SwitchCase",test:e,consequent:t}},whileStmt(e,t){return{type:"WhileStatement",test:e,body:t}},doWhileStmt(e,t){return{type:"DoWhileStatement",test:e,body:t}},forStmt(e,t,i,r){return{type:"ForStatement",init:e,test:t,update:i,body:r}},forInStmt(e,t,i){return{type:"ForInStatement",left:e,right:t,body:i}},forOfStmt(e,t,i){return{type:"ForOfStatement",left:e,right:t,body:i}},breakStmt(e=null){return{type:"BreakStatement",label:e}},continueStmt(e=null){return{type:"ContinueStatement",label:e}},returnStmt(e){return{type:"ReturnStatement",argument:e}},yieldExpr(e,t=!1){return{type:"YieldExpression",argument:e,delegate:t}},awaitExpr(e){return{type:"AwaitExpression",argument:e}},varDeclaration(e,t){return{type:"VariableDeclaration",kind:e,declarations:t}},varDeclarator(e,t=null){return{type:"VariableDeclarator",id:e,init:t}},funcDeclaration(e,t,i,r=!1,s=!1,n=!1){return this.func("FunctionDeclaration",...arguments)},sequenceExpr(e){return{type:"SequenceExpression",expressions:e}},parensExpr(e){return{type:"ParenthesizedExpression",expression:e}},logicalExpr(e,t,i){return{type:"LogicalExpression",operator:e,left:t,right:i}},binaryExpr(e,t,i){return{type:"BinaryExpression",operator:e,left:t,right:i}},unaryExpr(e,t,i=!0){return{type:"UnaryExpression",operator:e,argument:t,prefix:i}},updateExpr(e,t,i=!1){return{type:"UpdateExpression",operator:e,argument:t,prefix:i}},assignmentExpr(e,t,i="="){return{type:"AssignmentExpression",operator:i,left:e,right:t}},assignmentPattern(e,t){return{type:"AssignmentPattern",left:e,right:t}},thisExpr(){return{type:"ThisExpression"}},conditionalExpr(e,t,i,r="ConditionalExpression"){return{type:r,test:e,consequent:t,alternate:i}},arrayExpr(e){return{type:"ArrayExpression",elements:e}},arrayPattern(e){return{type:"ArrayPattern",elements:e}},objectExpr(e){return{type:"ObjectExpression",properties:e}},objectPattern(e){return{type:"ObjectPattern",properties:e}},chainExpr(e){return{type:"ChainExpression",expression:e}},callExpr(e,t,i=!1){return{type:"CallExpression",callee:e,arguments:t,optional:i}},newExpr(e,t){return{type:"NewExpression",callee:e,arguments:t}},taggedTemplateExpr(e,t){return{type:"TaggedTemplateExpression",tag:e,quasi:t}},memberExpr(e,t,i=!1,r=!1){return{type:"MemberExpression",object:e,property:t,computed:i,optional:r}},funcExpr(e,t,i,r=!1,s=!1,n=!1){return this.func("FunctionExpression",...arguments)},arrowFuncExpr(e,t,i,r=!1,s=!1,n=!1){return this.func("ArrowFunctionExpression",...arguments)},func(e,t,i,r,s=!1,n=!1,a=!1){return{type:e,id:t,params:i,body:r,async:s,expression:n,generator:a}},identifier(e){return{type:"Identifier",name:e}},property(e,t,i="init",r=!1,s=!1,n=!1){return{type:"Property",key:e,value:t,kind:i,shorthand:r,computed:s,method:n}},classDeclaration(e,t,i=null){return this.class("ClassDeclaration",...arguments)},classExpression(e,t,i=null){return this.class("ClassExpression",...arguments)},class(e,t,i,r=null){return{type:e,id:t,body:i,superClass:r}},methodDefinition(e,t,i="method",r=!1,s=!1){return{type:"MethodDefinition",key:e,value:t,kind:i,static:r,computed:s}},propertyDefinition(e,t,i=!1,r=!1){return{type:"PropertyDefinition",key:e,value:t,static:i,computed:r}},spreadElement(e){return{type:"SpreadElement",argument:e}},literal(e){if(typeof e=="object"&&!("name"in e)&&!("value"in e))throw new Error('Objects that convert to literals must have a "name" or "value" property.');return typeof e=="object"?{type:"Literal",get value(){return"name"in e?e.name:e.value}}:{type:"Literal",value:e}},templateLiteral(e,t){return{type:"TemplateLiteral",quasis:e,expressions:t}},comments(e){let t={};return Object.defineProperty(t,"toString",{value:()=>e}),Object.defineProperty(t,"trim",{value:function(){return this.toString()}}),[{type:"Line",value:t}]},withLoc(e,...t){return["start","end"].forEach(i=>{let r=i==="start"?t[0]:t[t.length-1];e[i]=r[i],r.loc&&(e.loc=e.loc||{},e.loc[i]=r.loc?.[i])}),e},invert(e){return this.unaryExpr("!",e)},clone(e){return e={...e},delete e.start,delete e.end,e}};var ue=class{type="BlockStatement";$body=[];constructor(t){this.body=t}get body(){return this.$body}set body(t){this.$body=t,d.withLoc(this,...t)}};var Ne=class{constructor(t,{type:i}){this.context=t,Object.assign(this,{type:i}),this.vars=new Set,this.$qIdentifiers=new Map,this.$qIdentifiersCursors={...this.context?.$qIdentifiersCursors||{}},this.locations=[]}index(t,i=!1){if(!this.type.includes("Function")&&this.context)return this.context.index(...arguments);let r=["start","end"].map(s=>{let n=[d.literal(t[s])];return i&&t.loc&&(n.push(d.literal(t.loc[s].line)),n.push(d.literal(t.loc[s].column))),d.arrayExpr(n)});return this.locations.push(d.arrayExpr(r)),d.literal(this.locations.length-1)}get$qIdentifier(t,i=!0,r=!1){let s=this.$qIdentifiers.get(t);if(!s){if(i&&this.context)return this.context.get$qIdentifier(t,i);r&&(typeof this.$qIdentifiersCursors[t]>"u"&&(this.$qIdentifiersCursors[t]=0),t+=this.$qIdentifiersCursors[t]++),this.$qIdentifiers.set(t,s=new It(t))}return s}getRandomIdentifier(t,i=!0){return this.get$qIdentifier(t,i,!0)}$qIdentifiersNoConflict(t){for(let[,i]of this.$qIdentifiers)i.noConflict(t);this.context&&this.context.$qIdentifiersNoConflict(t)}push(t,i,r=!1){let s;return["var","update"].includes(i)&&(s=this.find(t,!1))&&s.type!=="const"?s.willUpdate=!0:(i!=="update"||!this.context)&&(t instanceof It||this.$qIdentifiersNoConflict(t.name+""),this.vars.add({identifier:t,type:i,willUpdate:r||i==="update"})),this.context&&(i==="update"||i==="var"&&!this.type.includes("Function"))?this.context.push(t,i):!0}find(t,i=!0){let r;for(let s of this.vars)if(s.identifier.name+""==t.name+""){r=s;break}return!r&&i?this.context?.find(t,i):r}};var $e=class{history=[];scopes=[];functionTypes=["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression"];loopTypes=["DoWhileStatement","WhileStatement","ForStatement","ForOfStatement","ForInStatement"];labeledTypes=["SwitchStatement","LabeledStatement"];topLevelAwait=!1;topLevelArgsKeyword=!1;constructor(t={}){this.params=t}pushScope(t,i){let r=new Ne(this.currentScope,t);this.scopes.unshift(r);let s=i();return this.scopes.shift(),s}get currentScope(){return this.scopes[0]}pushHistory(t,i){this.history.unshift(t);let r=i();return this.history.shift(),r}get currentEntry(){return this.history[0]}serialize(t,i={}){return _s(t,{comments:!0,...i})}transform(t){if(t.type!=="Program")throw new Error('AST must be of type "Program".');return this.pushScope(t,()=>{let i=this.transformNodes(t.body,{static:!t.isQuantumProgram}),r={...t,body:i};r.body.length&&(r.body[0].comments=d.comments("Program body"));let s=d.exprStmt(d.assignmentExpr(this.$path("locations"),d.arrayExpr(this.currentScope.locations)));if(s.comments=d.comments("Location data"),r.body.unshift(s),this.exports.size){this.exports.forEach(c=>{r.body.push(d.exprStmt(this.$call("export",...c)))});let u=d.memberExpr(d.identifier("Promise"),d.identifier("all"));r.body.push(d.exprStmt(d.awaitExpr(d.callExpr(u,[this.$path("$promises.exports")]))))}let n=this.currentScope.get$qIdentifier("$q").name,a=this.serialize(r,{startingIndentLevel:this.params.startingIndentLevel}),o=this.params.base64?btoa(this.params.base64.replace("%0",n+"").replace("%1",a)):"";return{identifier:n,compiledSource:a,compiledSourceBase64:o,originalSource:t.originalSource,isQuantumProgram:t.isQuantumProgram,topLevelAwait:this.topLevelAwait,toString(u=void 0){return u==="base64"?this.compiledSourceBase64:this.compiledSource}}})}transformNodes(t,i={}){let r=(t=t.filter(o=>o)).length,[s,n,a]=t.reduce(([o,u,c],l)=>l?.type==="ImportDeclaration"?[o.concat(l),u,c]:l?.type==="FunctionDeclaration"?[o,u.concat(l),c]:[o,u,c.concat(l)],[[],[],[]]);return t=[...s,...n,...a],function o(u,c){if(c===r)return u;let[l,f]=this.transformNode(t[c],i,!0);if(u=u.concat(l||[]),c===s.length-1){let p=d.memberExpr(d.identifier("Promise"),d.identifier("all"));u=u.concat(d.exprStmt(d.awaitExpr(d.callExpr(p,[this.$path("$promises.imports")]))))}if(["ReturnStatement","BreakStatement","ContinueStatement"].includes(t[c].type))return u;if(f.flowControl?.size&&f.node.type==="IfStatement"){let p=t.slice(c+1);if(p.length){let m=new ue(p);return u.concat(this.transformNode(m))}}return o.call(this,u,c+1)}.call(this,[],0)}transformNode(t,i={},r=!1){if(typeof t!="object"||!t)return t;let s={static:this.currentEntry?.static,mode:this.currentEntry?.mode,...i,parentNode:this.currentEntry?.node,node:t,hoistedAwaitKeyword:!1,flowControl:new Map},n=this.pushHistory(s,()=>this[`transform${t.type}`]?this[`transform${t.type}`].call(this,t):Object.keys(t).reduce((a,o)=>{let u=Array.isArray(t[o])?this.transformNodes(t[o],i):this.transformNode(t[o],i);return{...a,[o]:u}},{}));return r?[n,s]:n}$serial(t){return this.currentScope.index(t,this.params.locations)}$path(t){return t.split(".").reduce((i,r)=>d.memberExpr(i,d.identifier(r)),this.currentScope.get$qIdentifier("$q"))}$trail(){return this.currentEntry.trail?[d.literal(this.currentEntry.trail)]:[]}$call(t,...i){return d.callExpr(this.$path(t),i)}$typed(t,i,r=null){let s=r?[d.literal(r)]:[];return this.$call("typed",d.literal(t),i,...s)}$obj(t){let i=Object.entries(t).map(([r,s])=>d.property(d.identifier(r),Array.isArray(s)?d.arrayExpr(s):s));return d.objectExpr(i)}$closure(...t){let i=t.pop(),r=t.pop()||[];return i.type==="EmptyStatement"&&(i=d.blockStmt([])),d.arrowFuncExpr(null,r,i,this.currentEntry.hoistedAwaitKeyword)}$var(t,i,r,s,...n){let a=s?this.$closure([this.currentScope.get$qIdentifier("$q")],s):d.identifier("undefined"),o=this.$call(t,d.literal(r),i,a,...n);return a.async&&(o=d.awaitExpr(o)),d.exprStmt(o)}$update(t,i,...r){let s=this.$closure(i);return this.$call("update",d.literal(t.name),s,...r)}$autorun(t,...i){let r=i.pop(),s=i.pop(),n=i.pop()||{},a=Object.keys(n).length?[this.$obj(n)]:[],o=this.$closure([this.currentScope.get$qIdentifier("$q")],r),u=this.$call("autorun",d.literal(t),...a,s,o);return o.async&&(u=d.awaitExpr(u)),d.exprStmt(u)}$iteration(t,i,r){let s=d.literal(t),n=this.currentEntry.parentNode?.label?d.literal(this.currentEntry.parentNode.label.name):d.identifier("null"),a={kind:s,label:n},o=d.blockStmt(r);return this.$autorun("iteration",a,i,o)}hoistAwaitKeyword(){for(let t of this.history)if(t.hoistedAwaitKeyword=!0,t.node.type.includes("Function"))return;this.topLevelAwait=!0}hoistArgumentsKeyword(){let t=["FunctionDeclaration","FunctionExpression"];if(!this.history.some(i=>t.includes(i.node.type)))return this.topLevelArgsKeyword=!0,!0}hoistExitStatement(t,i={}){for(let r of this.history){let s=()=>r.node?.type==="SwitchStatement"&&t.value==="break"&&i.name==="null",n=()=>r.parentNode?.type==="LabeledStatement"&&this.loopTypes.includes(r.parentNode.body.type)&&i.value===r.parentNode.label.name,a=()=>this.loopTypes.includes(r.node.type)&&i.name==="null";if(s())return r.node;if(n()||a())return r.flowControl.set(t,{...i,endpoint:!0}),r.node;if(r.node.type.includes("Function"))return;r.flowControl.set(t,i)}}transformFunctionDeclaration(t){return this.transformFunction(d.funcDeclaration,...arguments)}transformFunctionExpression(t){return this.transformFunction(d.funcExpr,...arguments)}transformArrowFunctionExpression(t){return this.transformFunction(d.arrowFuncExpr,...arguments)}transformFunction(t,i){if(i.generator&&i.isQuantumFunction)throw new Error("Generator functions cannot be quantum functions.");let r=this.$serial(i),{id:s,params:n,body:a}=i;[s,n,a]=this.pushScope(i,()=>{let g=[];s&&this.currentScope.push(s,"self");let b=n.map(w=>{if(w.type==="AssignmentPattern"&&i.isQuantumFunction){let C=this.currentScope.getRandomIdentifier("$rand",!1),E=this.transformSignal(C,"param"),y=d.varDeclarator(w.left,d.withLoc(d.logicalExpr("||",C,w.right),w));return g.push(...this.transformNode(d.varDeclaration("let",[d.withLoc(y,w)]),{static:!i.isQuantumFunction})),E}return this.transformSignal(w,"param")}),v=this.transformNode(a,{static:!i.isQuantumFunction});g.push(...v.type==="BlockStatement"?v.body:[d.returnStmt(v)]),g.length&&(g[0].comments=d.comments("Function body"));let x=d.exprStmt(d.assignmentExpr(this.$path("locations"),d.arrayExpr(this.currentScope.locations)));return x.comments=d.comments("Location data"),g.unshift(x),[s,b,d.blockStmt(g)]});let o=this.currentScope.get$qIdentifier("$q"),u=this.$closure([o],a),c=d.identifier(i.isQuantumFunction||!1),l=d.identifier(i.type==="FunctionDeclaration"),f=d.blockStmt([d.returnStmt(this.$call("runtime.spawn",c,d.thisExpr(),u))]),p=g=>this.$call("function",l,c,r,g),m=t.call(d,s,n,f,i.async,i.expresion,i.generator);if(i.type==="FunctionDeclaration"){if(this.currentScope.push(s,"static"),m=[m,d.exprStmt(p(s))],this.currentEntry.isExport){let g=[d.literal(s),r];this.currentEntry.isExport==="as-default"&&g.push(d.literal("default")),this.exports.add([d.arrayExpr(g)])}}else this.currentEntry.isMethod||(m=p(m));return m}transformClassDeclaration(t){return this.transformClass(d.classDeclaration,...arguments)}transformClassExpression(t){return this.transformClass(d.classExpression,...arguments)}transformClass(t,i){let{id:r,body:s,superClass:n}=i;n&&(n=this.transformNode(n));let a=new Set;s=this.pushScope(i,()=>(r&&this.currentScope.push(r,"self"),this.transformNode(s,{methods:a})));let o=d.identifier(i.type==="ClassDeclaration"),u=l=>{let f=d.arrayExpr([...a].map(p=>this.$obj(p)));return this.$call("class",o,l,f)},c=t.call(d,r,s,n);if(i.type==="ClassDeclaration"){if(this.currentScope.push(r,"static"),c=[c,d.exprStmt(u(r))],this.currentEntry.isExport){let l=[d.literal(r),this.$serial(i)];this.currentEntry.isExport==="as-default"&&l.push(d.literal("default")),this.exports.add([d.arrayExpr(l)])}}else c=u(c);return c}transformMethodDefinition(t){let{key:i,value:r}=t;t.computed&&(i=this.transformNode(i));let s=this.transformNode(r,{static:!0,isMethod:!0});return this.currentEntry.methods.add({name:t.computed?i:d.literal(i),static:d.identifier(t.static),isQuantumFunction:d.identifier(r.isQuantumFunction||!1),serial:this.$serial(t)}),d.methodDefinition(i,s,t.kind,t.static,t.computed)}transformPropertyDefinition(t){let{key:i,value:r}=t;return t.computed&&(i=this.transformNode(i)),r=this.transformNode(r),d.exprStmt(d.propertyDefinition(i,r,t.static,t.computed))}exports=new Set;transformExportDefaultDeclaration(t){return this.handleExports(...arguments)}transformExportNamedDeclaration(t){return this.handleExports(...arguments)}transformExportAllDeclaration(t){return this.handleExports(...arguments)}handleExports(t){if(t.type==="ExportAllDeclaration"){let r=[d.literal("*"),this.$serial(t.exported||t),d.literal(t.exported?.name||t.exported?.value||"")];this.exports.add([d.arrayExpr(r),this.$obj({source:t.source,serial:this.$serial(t)})]);return}let i=r=>r.map(s=>{let n=[d.literal(s.local.name),this.$serial(s)],a=s.exported.name||s.exported.value;return a!==s.local.name&&n.push(d.literal(a)),d.arrayExpr(n)});if(t.source){this.exports.add(i(t.specifiers).concat(this.$obj({source:t.source,serial:this.$serial(t)})));return}if(t.type==="ExportNamedDeclaration"&&t.specifiers.length){this.exports.add(i(t.specifiers));return}if(t.type==="ExportDefaultDeclaration"&&["Identifier","ThisExpression"].includes(t.declaration.type)){let r=[d.literal(t.declaration.name||"this"),this.$serial(t),d.literal("default")];this.exports.add([d.arrayExpr(r)]);return}return this.transformNode(t.declaration,{isExport:t.type==="ExportDefaultDeclaration"?"as-default":!0})}transformImportDeclaration(t){let i=t.specifiers.map(r=>{let{imported:s,local:n}=r;this.transformSignal(n,"import"),r.type==="ImportNamespaceSpecifier"?s=d.identifier("*"):r.type==="ImportDefaultSpecifier"&&(s=d.identifier("default"));let a=s.name||s.value||"",o=[d.literal(a),this.$serial(r)];return a!==r.local.name&&o.push(d.literal(r.local.name)),d.arrayExpr(o)});return d.exprStmt(this.$call("import",...i.concat(this.$obj({source:t.source,serial:this.$serial(t)}))))}transformImportExpression(t){return this.$call("import",this.$obj({source:t.source,isDynamic:d.identifier("true"),serial:this.$serial(t)}))}transformSignal(t,i,r=null){return t.type==="Identifier"?(this.currentScope.push(t,i,["let","param"].includes(i)),r?.add(t),t):this.transformNode(t,{mode:i,static:!0,signals:r})}transformThisExpression(t){return this.transformIdentifier(...arguments)}transformIdentifier(t){let i=this.currentScope.find(t);!i&&t.name&&this.currentScope.$qIdentifiersNoConflict(t.name);let r=[];return t.hint?r.push(this.$obj({[t.hint]:d.identifier(!0)})):this.currentEntry.mode,t.type==="ThisExpression"||["param","self"].includes(i?.type)||["arguments"].includes(t.name)?this.currentEntry.trail?this.$call("obj",t,...this.$trail(),...r):t:(this.history.forEach(s=>s.refs?.add(t)),this.$call("ref",d.literal(t),...this.$trail(),...r))}transformMemberExpression(t){let{object:i,property:r,computed:s,optional:n}=t;s&&(r=this.transformNode(r));let a=this.transformNode(i,{trail:(this.currentEntry.trail||0)+1});return i.typed&&(a=this.$typed(i.typed,a,d.literal(r))),d.memberExpr(a,r,s,n)}transformVariableDeclaration(t){let i=this.currentEntry.isExport;return t.declarations.reduce((s,n)=>["ObjectPattern","ArrayPattern"].includes(n.id.type)?s.concat(this.expandPattern(n.id,n.init)):s.concat(n),[]).reduce((s,n)=>{let a=this.$serial(n),o=this.transformNode(n.init);this.transformSignal(n.id,t.kind,this.currentEntry.signals);let u=[];n.restOf&&(o=this.$typed(n.init.typed,o),u.push(this.$obj({restOf:n.restOf,type:d.literal(n.init.typed==="iterable"?"array":"object")})));let c=s.concat(this.$var(t.kind,a,n.id,o,...u));if(i&&!(n.id instanceof It)){let l=[d.literal(n.id),a];this.exports.add([d.arrayExpr(l)])}return c},[])}transformAssignmentExpression(t){let r=!this.currentEntry.static&&this.history[1].node.type==="ExpressionStatement",{left:s,right:n}=t,a=(u,c)=>(c=this.transformNode(c),u=this.transformNode(u),d.assignmentExpr(u,c,t.operator));if(["MemberExpression","ChainExpression"].includes(s.type))return a(s,n);if(["ObjectPattern","ArrayPattern"].includes(s.type)){let u=n,c=this.expandPattern(s,n,r).reduce((l,f)=>{if(f.id.originalB&&(u=f.id),f.type==="AssignmentExpression")return l.concat(a(f.left,f.right));let p=this.transformNode(f.init);if(f.id instanceof It){let g=this.$serial(f);return l.concat(this.$var("let",g,f.id,p))}this.transformSignal(f.id,"update",this.currentEntry.signals);let m=[];return f.restOf&&(p=this.$typed(f.init.typed,p),m.push(this.$obj({restOf:f.restOf,type:d.literal(f.init.typed==="iterable"?"array":"object")}))),l.concat(this.$update(f.id,p,...m))},[]);return r?c:d.sequenceExpr(c.concat(u))}n=this.transformNode(n),this.transformSignal(s,"update",this.currentEntry.signals);let o=this.currentScope.getRandomIdentifier("$current",!1);return this.$call("update",d.literal(s),this.$closure([o],d.assignmentExpr(o,n,t.operator.replace("====",""))))}transformAssignmentPattern(t){let{left:i,right:r}=t;return r=this.transformNode(r),["MemberExpression","ChainExpression"].includes(i.type)?i=this.transformNode(i,{static:!0}):i=this.transformSignal(i,this.currentEntry.mode,this.currentEntry.signals),d.assignmentPattern(i,r)}expandPattern(t,i,r=!0){let s=[],n=this;if(!["Identifier","Literal"].includes(i.type)&&r){let a=d.withLoc(n.currentScope.getRandomIdentifier("$rand",!1),i);a.originalB=!0,i.typed=t.type==="ObjectPattern"?"desctructurable":"iterable",s.push(d.withLoc(d.varDeclarator(a,i),i)),i=a}return function a(o,u,c){u.typed=c?"desctructurable":"iterable";let l=[];for(let f=0;f<o.length;f++){let p=o[f],m=f,g=p;if(p===null){l.push(f);continue}if(p.type==="RestElement"){let w=d.withLoc(d.varDeclarator(p.argument,u),p);w.restOf=l.map(C=>d.literal(C)),s.push(w);continue}c?{key:m,value:g}=p:m=d.literal(m);let b,v;g.type==="AssignmentPattern"?(b=g.right,g.left.type==="Identifier"?v=g.left:g=g.left):g.type==="Identifier"&&(v=g);let x=d.memberExpr(u,m,c?p.computed:!0);if(b&&(x=d.logicalExpr("||",x,b)),v)s.push(d.withLoc(d.varDeclarator(v,x),p)),l.push(m);else if(g.type==="MemberExpression"||g.type==="ChainExpression"&&(g=g.expression))s.push(d.withLoc(d.assignmentExpr(g,x),p));else if(g.elements||g.properties){let w=(g.properties?g.properties:g.elements).length>1;if(r&&w){let C=n.currentScope.getRandomIdentifier("$rand",!1);s.push(d.withLoc(d.varDeclarator(C,x),p)),x=C}a(g.elements||g.properties,x,g.properties&&!0)}}}(t.elements||t.properties,i,t.properties&&!0),s}transformUpdateExpression(t){if(t.argument.type==="Identifier"){this.transformSignal(t.argument,"update",this.currentEntry.signals);let i=this.currentScope.getRandomIdentifier("$current",!1),r=d.binaryExpr(t.operator==="--"?"-":"+",i,d.literal(1),!0),s=(t.prefix?"pre":"post")+(t.operator==="--"?"dec":"inc");return this.$call("update",d.literal(t.argument.name),this.$closure([i],r),this.$obj({kind:d.literal(s)}))}return d.updateExpr(t.operator,this.transformNode(t.argument),t.prefix)}transformUnaryExpression(t){return t.operator==="typeof"&&t.argument.type==="Identifier"&&(t.argument.hint="isTypeCheck"),d.unaryExpr(t.operator,this.transformNode(t.argument))}transformIfStatement(t){let i=this.$serial(t),{test:r,consequent:s,alternate:n}=t;r=this.transformNode(t.test),s=this.pushScope(t,()=>this.transformNodes([t.consequent])),s[0].type!=="BlockStatement"&&s.length>1?s=d.blockStmt(s):s=s[0],n&&(n=this.pushScope(t,()=>this.transformNodes([t.alternate])),n[0]&&n[0].type!=="BlockStatement"&&n.length>1?n=d.blockStmt(n):n=n[0],n.type==="BlockStatement"&&(n=this.$autorun("block",this.$serial(t.alternate),n)));let a=d.ifStmt(r,s,n);return this.currentEntry.static?a:this.$autorun("block",i,d.blockStmt([a]))}transformSwitchStatement(t){let i=this.$serial(t);return this.pushScope(t,()=>{let r=this.transformNode(t.discriminant),s=t.cases.map(a=>{let o=this.transformNode(a.test),u=this.transformNodes(a.consequent);return d.switchCase(o,u)}),n=d.switchStmt(r,s);return this.currentEntry.static?n:this.$autorun("block",i,d.blockStmt([n]))})}transformWhileStatement(t){return this.transformLoopStmtA(d.whileStmt,...arguments)}transformDoWhileStatement(t){return this.transformLoopStmtA(d.doWhileStmt,...arguments)}transformForStatement(t){return this.transformLoopStmtA(d.forStmt,...arguments)}transformLoopStmtA(t,i){let r=i.type==="WhileStatement"?"while":i.type==="DoWhileStatement"?"do-while":"for",s=this.$serial(i);return this.pushScope(i,()=>{let n=this.currentScope.get$qIdentifier("$q"),a,o={kind:d.literal(r),label:this.currentEntry.parentNode?.label?d.literal(this.currentEntry.parentNode.label.name):d.identifier("null")};if(r==="for"){let c=d.blockStmt([].concat(this.transformNode(i.init)||[]));o.init=this.$closure([n],c);let l=this.transformNode(i.test);o.test=this.$closure([n],l);let f=this.transformNode(i.update);o.advance=this.$closure([n],f),a=p=>t.call(d,c,l,f,p)}else{let c=this.transformNode(i.test);o.test=this.$closure([n],c),a=l=>t.call(d,c,l)}let u=this.transformNode(i.body);return this.$autorun("iteration",o,s,u)})}transformForOfStatement(t){return this.transformLoopStmtB(d.forOfStmt,...arguments)}transformForInStatement(t){return this.transformLoopStmtB(d.forInStmt,...arguments)}transformLoopStmtB(t,i){let r=i.type==="ForInStatement"?"for-in":"for-of",s=this.$serial(i),n=this.transformNode(i.right);return this.pushScope(i,()=>{let a=this.currentScope.get$qIdentifier("$q"),o=this.currentScope.get$qIdentifier(r==="for-of"?"$val":"$key",!1),u={kind:d.literal(r),label:this.currentEntry.parentNode?.label?d.literal(this.currentEntry.parentNode.label.name):d.identifier("null"),parameters:this.$closure([a],d.arrayExpr([d.literal(o),n]))},c;if(i.left.type==="VariableDeclaration"){let f=d.withLoc(d.varDeclarator(i.left.declarations[0].id,o),i.left);c=d.varDeclaration(i.left.kind,[f])}else c=d.withLoc(d.assignmentExpr(i.left,o),i.left);let l=d.blockStmt(this.transformNodes([c].concat(i.body.body)));return this.$autorun("iteration",u,s,l)})}transformBreakStatement(t){return this.transformExitStmt(d.breakStmt,...arguments)}transformContinueStatement(t){return this.transformExitStmt(d.continueStmt,...arguments)}transformExitStmt(t,i){let r=i.type==="BreakStatement"?"break":"continue",s=d.literal(r),n=i.label?d.literal(i.label.name):d.identifier("null");return this.hoistExitStatement(s,n)?.type==="SwitchStatement"?t.call(d):d.exprStmt(this.$call(r,n))}transformReturnStatement(t){let i=new Set,r=this.transformNode(t.argument,{refs:i});if(this.currentEntry.static)return d.returnStmt(r);let s=d.literal("return"),n=r?[s,r]:[s];this.hoistExitStatement(...n);let a=this.$call("return",...n.slice(1));if(!i.size)return d.exprStmt(a);let o=this.$serial(t);return this.$autorun("return",o,a)}transformBlockStatement(t){if(t instanceof ue){let r=this.$serial(t),s=this.transformNodes(t.body);return this.$autorun("downstream",r,d.blockStmt(s))}let i=this.pushScope(t,()=>this.transformNodes(t.body));return d.blockStmt(i)}transformLabeledStatement(t){this.currentScope.push(t.label,"const");let i=[].concat(this.transformNode(t.body));return[d.labeledStmt(t.label,i.shift()),...i]}transformExpressionStatement(t){let i=this.$serial(t);return[].concat(this.transformNode(t.expression)||[]).reduce((s,n)=>n.type==="VariableDeclaration"||n.type.endsWith("Statement")?s.concat(n):this.currentEntry.static?d.exprStmt(n):s.concat(this.$autorun("stmt",i,n)),[])}transformAwaitExpression(t){this.hoistAwaitKeyword();let i=this.transformNode(t.argument);return d.awaitExpr(i)}transformSequenceExpression(t){let i=t.expressions.reduce((r,s,n)=>r.concat(this.transformNode(s,{trail:n===t.expressions.length-1?this.currentEntry.trail:void 0})),[]);return this.history[1].node.type==="ExpressionStatement"?i:d.sequenceExpr(i)}transformConditionalExpression(t){let{test:i,consequent:r,alternate:s}=t;return i=this.transformNode(i),r=this.transformNode(r,{trail:this.currentEntry.trail}),s=this.transformNode(s,{trail:this.currentEntry.trail}),d.conditionalExpr(i,r,s)}transformLogicalExpression(t){let{left:i,right:r}=t;return i=this.transformNode(i,{trail:this.currentEntry.trail}),r=this.transformNode(r,{trail:this.currentEntry.trail}),d.logicalExpr(t.operator,i,r)}transformBinaryExpression(t){let{left:i,right:r}=t;i=this.transformNode(i),r=this.transformNode(r);let s=d.binaryExpr(t.operator,i,r);return this.currentEntry.trail?this.$call("obj",s,...this.$trail()):s}transformCallExpression(t){return this.transformCallExpr(d.callExpr,...arguments)}transformNewExpression(t){return this.transformCallExpr(d.newExpr,...arguments)}transformCallExpr(t,i){let r=this.transformNode(i.callee,{mode:"callee"}),s=i.arguments.map(a=>this.transformNode(a)),n=t.call(d,r,s,i.optional);return this.currentEntry.trail?this.$call("obj",n,...this.$trail()):n}transformObjectExpression(t){let i=d.objectExpr(t.properties.map(r=>this.transformNode(r)));return this.currentEntry.trail?this.$call("obj",i,...this.$trail()):i}transformProperty(t){let{key:i,value:r}=t;return t.computed&&(i=this.transformNode(i)),r=this.transformNode(r),d.property(i,r,t.kind,!1,t.computed,!1)}transformArrayExpression(t){let i=d.arrayExpr(t.elements.map(r=>this.transformNode(r)));return this.currentEntry.trail?this.$call("obj",i,...this.$trail()):i}transformTaggedTemplateExpression(t){let[i,r]=this.transformNodes([t.tag,t.quasi]),s=d.taggedTemplateExpr(i,r);return this.currentEntry.trail?this.$call("obj",s,...this.$trail()):s}transformTemplateLiteral(t){let i=t.expressions.map(s=>this.transformNode(s)),r=d.templateLiteral(t.quasis,i);return this.currentEntry.trail?this.$call("obj",r,...this.$trail()):r}};var Es=new Map;function Cs(e,t={}){let i=`${e}${JSON.stringify(t)}`,r=Es.get(i);if(!r){try{r=ms.parse(e,t)}catch(s){let n=`${s.message||s}`,{pos:a,loc:{line:o,column:u}={}}=s,l=[{expr:e.slice(Math.max(0,a-15),a+15),line:o,column:u},{source:e}];throw t.inBrowser&&console.error(l),new(globalThis[s.name]||Error)(n,{cause:l})}Es.set(i,r)}return r}function ks(e,t={}){return new $e(t).transform(e)}function li(...e){let t,i={runtimeParams:la,compilerParams:ca,parserParams:ua};for(;t=e.shift();){let{runtimeParams:r={},compilerParams:{globalsNoObserve:s=[],globalsOnlyPathsExcept:n=[],...a}={},parserParams:o={}}=t;i={runtimeParams:{...i.runtimeParams,...r},compilerParams:{...i.compilerParams,globalsNoObserve:[...i.compilerParams.globalsNoObserve,...s],globalsOnlyPathsExcept:[...i.compilerParams.globalsOnlyPathsExcept,...n],...a},parserParams:{...i.parserParams,...o}},e.devMode}return i}var ua={ecmaVersion:"latest",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!1,allowSuperOutsideMethod:!1,preserveParens:!1,locations:!0},ca={globalsNoObserve:["arguments","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},la={apiVersion:3};var Le=Object.create(null);var Bt=class extends EventTarget{managedAlways=new Set;managedOnce=new Set;constructor(){super(),Ir.setMaxListeners?.(0,this)}fire(t){return this.dispatchEvent(new Event(t,{cancelable:!0}))}on(...t){return this.addEventListener(...t),()=>this.removeEventListener(...t)}abort(t=!1){this.managedAlways.forEach(i=>i.abort?i.abort(t):i(t)),this.managedOnce.forEach(i=>i.abort?i.abort(t):i(t)),this.managedOnce.clear(),this.fire("abort")}manage(t){this.managedAlways.add(t)}once(t){this.managedOnce.add(t)}};var Ht=class extends Bt{subscribers=new Set;signals=new Map;constructor(t,i,r){super(),this.context=t,this.context?.once(()=>this.abort()),this.once(()=>this.watchMode(!1)),this.type=i,this.state=r}get name(){return[...this.context?.signals.keys()||[]].find(t=>this.context.signals.get(t)===this)}signal(t,i="prop"){let r=this.signals.get(t);return r||(r=new Ht(this,i,i==="object"?t:Mi(this.state)?R.get(this.state,t):void 0),this.signals.set(t,r),this.signals.size===1&&this.watchMode(),r.once(()=>{this.signals.delete(t),this.signals.size||this.watchMode(!1)})),r}subscribe(t){this.subscribers.add(t),t.once(()=>{this.subscribers.delete(t),this.subscribers.size||this.abort()})}watchMode(t=!0){this.mutationsWatch?.abort(),!(!t||!this.signals.size||!Mi(this.state))&&(this.mutationsWatch=R.observe(this.state,i=>{let r={map:new Map,add(n,a){for(let o of n)o.spec.beforeSchedule?.(a)!==!1&&(this.map.has(o.runtime)||this.map.set(o.runtime,new Set),this.map.get(o.runtime).add(o))}};for(let n of i){let a=this.signals.get(n.key);!a||(r.add(a.subscribers,n),a.refresh(n.value))}let s=r.map.size?[...r.map].sort((n,a)=>n.$serial>a.$serial?-1:1):r.map;for(let[n,a]of s)n.state!=="aborted"&&n.schedule(...a)},{recursions:"force-sync"}))}refresh(t){this.state=t;for(let[i,r]of this.signals)r.refresh(R.get(this.state??{},i));this.watchMode()}};var et=class extends Ht{symbols=new Map;constructor(t,i,r=void 0){super(t,i,r||Object.create(null))}};var bt=class extends Bt{state;constructor(t,i,r,s,n,a){super(),t?.once(this),this.context=t,this.type=i,this.spec=r,this.scope=n,t?.scope!==n&&this.manage(n),this.serial=s,a&&(this.closure=a),t?.type==="iteration"?this.path=t.path.concat(this.spec.index):t?.type==="round"?this.path=t.path.concat(this.serial):this.path=(t?.path||[]).slice(0,-1).concat(this.serial),this.flowControl=new Map}get runtime(){return this.context.runtime}contains(t){return this===t.context||t.context&&this.contains(t.context)}order(t){if(!t)return this;let[i,r]=t.path.length<this.path.length?[t,this]:[this,t];return i.path.reduce((s,n,a)=>s&&n<=r.path[a],!0)&&i||r}beforeExecute(){this.state="running";let t=this.flowControl;return this.flowControl=new Map,t}execute(t=null){try{return this.runtime.thread.unshift(this),nt(this.beforeExecute(),i=>Ri(this.closure,this,this,r=>(this.spec.complete&&(r=this.spec.complete(r,this)),this.afterExecute(i),this.runtime.thread.shift(),t?t(r,this):r)))}catch(i){if(i.cause)throw i;let r=`${i.message||i}`;this.runtime.throw(r,[this.serial,this.context?.serial],globalThis[i.name])}}afterExecute(t){this.state="complete";let i=this.flowControl;this.handleDownstream(i.size,t.size),this.handleRightstream(i.size,t.size);for(let r of["break","continue","return"])i.has(r)&&!i.get(r).endpoint?this.hoistFlowControl(r,i.get(r).arg):t.has(r)&&!t.get(r).endpoint&&this.hoistFlowControl(r,t.get(r).arg,!0)}typed(t,i,r=void 0){let s=Array.isArray(i)?"array":i===null?"null":typeof i;if(s===t||t==="iterable"&&i?.[Symbol.iterator]||t==="desctructurable"&&!["undefined","null"].includes(s))return i;throw t==="iterable"?new Error("value is not iterable."):t==="desctructurable"?new Error((r?`Cannot access ${r}; `:"")+"object not desctructurable."):new Error(`value must be of type ${t}.`)}let(t,i,r,s={}){return this.var(t,i,r,{...s,kind:"let"})}const(t,i,r,s={}){return this.var(t,i,r,{...s,kind:"const"})}var(t,i,r,s={}){s={kind:"var",...s},r||(r=()=>{});let n=s.restOf?(...o)=>{try{return r(...o)}catch(u){throw new Error(`Cannot declare ${t}; ${u.message}`)}}:r,a=(o,u)=>{let c=u.scope;if(s.kind==="var")for(;!["module","function"].includes(c.type)&&!R.has(c.state,t)&&c.context;)c=c.context;else c.type==="this"&&c.context&&(c=c.context);let l=c.symbols.get(t);if(l&&(l.kind!==s.kind||s.kind==="let"&&l.serial!==i))throw new Error(`Identifier "${t}" has already been declared.`);l?.reader?.abort(),l={serial:i,kind:s.kind};let f=o;return s.restOf&&(s.type==="array"?f=[]:f={},l.reader=R.map(o,f,{except:s.restOf,spread:s.type==="array"}),u.once(l.reader)),c.symbols.set(t,l),R.set(c.state,t,f),f};return this.autorun(s.kind,{complete:a,...s},i,n)}update(t,i,r={}){let s=this.scope;for(;s&&!R.has(s.state,t);)s=s.context;if(!s)throw new ReferenceError(`${t} is not defined.`);let n=s.symbols.get(t);if(n?.kind==="const")throw new ReferenceError(`Assignment to constant variable "${t}".`);let a=R.get(s.state,t),o=r.restOf?(...u)=>{try{return i(...u)}catch(c){throw new Error(`Cannot update ${t}; ${c.message}`)}}:i;return Ri(o,void 0,a,u=>{n?.reader?.abort();let c=u;return r.restOf&&(n=n||{},r.type==="array"?c=[]:c={},n.reader=R.map(u,c,{except:r.restOf,spread:r.type==="array"}),this.once(n.reader)),R.set(s.state,t,c),["postinc","postdec"].includes(r.kind)?a:c})}ref(t,...i){let r=0,s={};typeof i[0]=="number"?(r=i.shift(),s=i.shift()||{}):typeof i[0]=="object"&&(s=i.shift());let n=this.scope;for(;n&&!R.has(n.state,t);)n=n.context;if(!n){if(s.isTypeCheck)return;throw new Error(`${t} is not defined.`)}let a=n.symbols.get(t)?.kind,o=n.signal(t,a);return s.typed&&this.typed(s.typed,o.state,t),this.autobind(o,r,s)}obj(t,...i){let r=0,s={};return typeof i[0]=="number"?(r=i.shift(),s=i.shift()||{}):typeof i[0]=="object"&&(s=i.shift()),this.autobind(this.runtime.$objects.signal(t,"object"),r,s)}autobind(t,i,r){let s=this.runtime.$params.quantumMode,n=t.type==="const",a=this===this.runtime,o=this.state==="aborted",u=this;return function c(l,f){if(s&&!n&&!a&&!o&&l.subscribe(u),!f||!l.state||typeof l.state!="object"){let m=l.state;return typeof l.state=="function"&&(m=R.proxy(l.state,{membrane:l})),m}let p;return R.proxy(l.state,{},m=>({...m,get(g,b,v=null){return p?m.get(g,b,v):(p=!0,c(l.signal(b),f-1))}}))}(t,i)}autorun(t,...i){let r=i.pop(),s=i.pop(),n=i.pop()||{},a=bt,o=this.scope;if(t==="iteration"){let c=this.runtime.constructor;a=r.constructor.name==="AsyncFunction"?c.AutoAsyncIterator:c.AutoIterator}["block","iteration"].includes(t)&&(o=new et(o,t));let u=new a(this,t,n,s,o,r);if(!(t==="downstream"&&(this.downstream=u,this.flowControlApplied())))return u.execute()}function(t,i,r,s){t&&R.set(this.scope.state,s.name,s);let n=this;return Object.defineProperty(s,"toString",{value:function(a=!1){if(a&&i)return Function.prototype.toString.call(s);let o=n.runtime.extractSource(r);return o.startsWith("static ")?o.replace("static ",""):o}}),s}class(t,i,r){return t&&R.set(this.scope.state,i.name,i),r.forEach(({name:s,static:n,isQuantumFunction:a,serial:o})=>{this.function(!1,a,o,n?i[s]:i.prototype[s])}),i}async import(...t){return this.runtime.import(...t)}async export(...t){return this.runtime.export(...t)}continue(t){return this.applyFlowControl("continue",t)}break(t){return this.applyFlowControl("break",t)}return(t){return this.applyFlowControl("return",t)}applyFlowControl(t,i,r=!1){let s=this.flowControl.size;if(r?this.flowControl.delete(t):this.flowControl.set(t,{arg:i}),this.type==="round"&&(this.context.breakpoint=this),this.type==="round"&&["break","continue"].includes(t)&&i===this.context?.spec.label){r||(this.flowControl.get(t).endpoint=!0),this.state!=="running"&&this.handleRightstream(this.flowControl.size,s);return}this.state!=="running"&&(this.handleDownstream(this.flowControl.size,s),this.hoistFlowControl(...arguments))}hoistFlowControl(...t){return this.context?.applyFlowControl(...t)}flowControlApplied(t,i){return arguments.length?arguments.length===1?this.flowControl.has(t):this.flowControl.get(t)?.arg===i:this.flowControl.size||!1}handleDownstream(t,i){let r;this.type!=="block"||!(r=this.context?.downstream)||(t?r.abort():i&&(r.state="resuming",this.runtime.schedule(r)))}handleRightstream(t,i){if(this.type!=="round")return;let r=this,s=new Set;for(;r=r.nextRound;)t?r.abort():i&&r.state!=="inert"&&(r.state="resuming",s.add(r));s.size&&this.runtime.schedule(...s),!t&&i&&this.runtime.on("reflection",()=>{this.context.iterating||this.context.iterate()},{once:!0})}abort(t=!1){return t&&(this.context?.breakpoint===this&&delete this.context.breakpoint,this.flowControl.clear()),this.state=t?"inert":"aborted",super.abort(t)}};var Ut=class extends bt{rounds=new Map;constructor(t,i,r,s,n,a){r.$closure=a,super(t,i,r,s,n),this.manage(()=>{delete this.breakpoint,this.rounds.clear()})}pseudorun(t){return this.runtime.iThread.unshift(this),nt(t(),i=>(this.runtime.iThread.pop(),i))}createIterator(){return this.spec.kind==="for-in"?function*(){for(let t in this.iteratee)yield t}.call(this):this.spec.kind==="for-of"?function*(){for(let t of this.iteratee)yield t}.call(this):{next:()=>({done:!this.pseudorun(()=>this.spec.test(this))})}}closure(){["for-of","for-in"].includes(this.spec.kind)?([this.production,this.iteratee]=this.spec.parameters(this),this.iterator=this.createIterator(),this.iterator.original=!0,this.watchMode()):(this.spec.kind==="for"&&this.spec.init(this),this.iterator=this.createIterator()),this.iterate()}terminated(){return this.breakpoint&&!this.breakpoint.flowControlApplied("continue",this.spec.label)&&this.breakpoint.flowControlApplied()}advance(){this.spec.kind==="for"&&this.pseudorun(()=>this.spec.advance(this))}iterate(){this.iterating=!0;let t=()=>!this.terminated()&&!(this.cursor=this.iterator.next()).done,i=()=>{this.createRound(this.cursor.value).execute(),this.advance()};if(this.spec.kind==="do-while")do i();while(t());else for(;t();)i();this.iterating=!1}createRound(t){let i=this.rounds.size,r={index:i},s=["for-in","for-of"].includes(this.spec.kind)?{[this.production]:t}:{...this.scope.state},n=new et(this.scope,"round",s);this.scope.symbols.forEach((u,c)=>{n.symbols.set(c,u)});let a=new bt(this,"round",r,this.serial,n,this.spec.$closure),o=this.spec.kind==="for-in"?t:i;return this.rounds.set(o,a),this.lastRound&&(this.lastRound.nextRound=a,a.prevRound=this.lastRound),this.lastRound=a,a}watchMode(){let t=(i,r)=>{let s=new Set,n=new Set;for(let a of i){if(Array.isArray(this.iteratee)&&a.key==="length")continue;let o=this.spec.kind==="for-in"?a.key:a.value,u=this.spec.kind==="for-in"?a.key:parseInt(a.key),c=this.rounds.get(u);if(c)R.set(c.scope.state,this.production,o),a.type==="delete"&&(this.rounds.set(u,void 0),c.prevRound&&(c.prevRound.nextRound=c.nextRound),c.nextRound&&(c.nextRound.prevRound=c.prevRound),s.add(c));else if(a.type!=="delete"&&!a.isUpdate){if(this.spec.kind==="for-of"&&this.iterator.original&&!r.done)continue;n.add(o)}}this.runtime.on("reflection",()=>{s.forEach(a=>a.abort(!0))},{once:!0}),n.size&&(this.iterator=function*(a){yield*a,yield*n}(this.iterator),r.done&&this.iterate())};this.once(R.observe(this.iteratee,i=>{nt(this.cursor,r=>t(i,r))}))}};var Re=class extends Ut{async createIterator(){return this.spec.kind==="for-in"?function*(){for(let t in this.iteratee)yield t}.call(this):this.spec.kind==="for-of"?function*(){for(let t of this.iteratee)yield t}.call(this):{next:async()=>({done:!await this.pseudorun(()=>this.spec.test(this))})}}async closure(){["for-of","for-in"].includes(this.spec.kind)?([this.production,this.iteratee]=await this.spec.parameters(this),this.iterator=await this.createIterator(),this.iterator.original=!0,this.watchMode()):(this.spec.kind==="for"&&await this.spec.init(this),this.iterator=await this.createIterator()),await this.iterate()}async iterate(){let t;this.iterating=!0;let i=async()=>!this.terminated()&&(this.cursor=this.iterator.next())&&(t=await this.cursor)&&!t.done,r=async()=>{await this.createRound(t.value).execute(),await this.advance()};if(this.spec.kind==="do-while")do await r();while(await i());else for(;await i();)await r();this.iterating=!1}};var Wt=class{constructor(t){Object.defineProperty(this,"runtime",{value:t});let i={statechange:()=>{R.defineProperty(this,"value",{value:t.flowControl.get("return")?.arg,enumerable:!0,configurable:!0})}};for(let r in i)t.on(r,i[r]),i[r]();t.$params.sourceType==="module"&&Object.defineProperty(this,"exports",{value:t.exports})}dispose(){return this.runtime.abort(!0)}};var zt=class extends bt{locations=[];queue=new Set;thread=[];iThread=[];constructor(t,i,r,s,n){super(t,i,{},-1,s,n);let{$serial:a=0,...o}=r;this.$serial=a,this.$params=o,this.$objects=new et(void 0,"objects"),this.manage(this.$objects),this.exports=Object.create(null),this.$promises={imports:[],exports:[]},this.manage(()=>{R.deleteProperties(this.exports,Object.keys(this.exports)),this.$promises.imports.splice(0),this.$promises.exports.splice(0)})}extractSource(t,i=!1){let[[r,s,n],[a]]=this.locations[t],o=this.$params.originalSource.slice(r,a);return i?{expr:o,line:s,column:n}:o}throw(t,i,r=null,s=null){let n,a=s!==null?`[${s}]: ${t}`:t,o=i.map(c=>c!==-1&&this.extractSource(c,!0)).filter(c=>c);o.push({source:this.$params.originalSource}),n=new(r||Error)(a,{cause:o});let u=this.$params.sourceType==="module"&&this.$params.experimentalFeatures!==!1&&this.$params.exportNamespace||this.$params.fileName;throw u&&(n.fileName=u),s&&(n.code=s),n}get runtime(){return this}get nowRunning(){return this.thread[0]}schedule(...t){let i=this.queue.size;for(let r of t)this.queue.add(r);if(!i)return this.flowControlDirty=!1,function r(s,n){let a;for(let o of this.queue){if(n&&n.order(o)!==n||["aborted","running"].includes(o.state)||this.iThread[0]?.contains(o)){this.queue.delete(o);continue}a=a?a.order(o):o,n||(n=a)}return a?(a.abort(),a.execute(o=>(this.queue.delete(a),r.call(this,o,a)))):(this.fire("reflection"),this.flowControlApplied()&&this.fire("statechange"),s)}.call(this,void 0,this.nowRunning)}execute(t=null){return super.execute(i=>{let r=this.$params.quantumMode?new Wt(this):i;return t?t(r,this):r})}spawn(t,i,r){let s=this.nowRunning||this,n={...this.$params,$serial:this.$serial+1,quantumMode:t},a=new et(s.scope,"function",{this:i});return new this.constructor(s,"function",n,a,r).execute()}async import(...t){let i=t.pop(),r=typeof i=="string"?{source:i}:i,s=a=>{if(r.forExport||r.isDynamic)return a;this.assignModules(t,this.scope.state,a,i.serial)};if(this.$params.experimentalFeatures!==!1&&Le[r.source])return s(Le[r.source]);let n=(async()=>{let a=this.$params.sourceType==="module"&&this.$params.experimentalFeatures!==!1&&this.$params.exportNamespace||this.$params.fileName;try{return s(await import(r.source))}catch(o){throw o.code==="ERR_MODULE_NOT_FOUND"&&this.throw(`Cannot find package "${r.source}"${a?` imported at "${a}"`:""}.`,[r.serial],null,o.code),o}})();return r.isDynamic||this.$promises[r.forExport?"exports":"imports"].push(n),n}async export(...t){let i=Array.isArray(t[t.length-1])?null:t.pop(),r=i?await this.import({...i,forExport:!0}):this.scope.state;this.assignModules(t,this.exports,r,i?.serial)}assignModules(t,i,r,s=null){let n=[];for(let[a,o,u]of t){if(a==="*"&&u){(this.$params.quantumMode?R:Reflect).set(i,u,r);continue}R.has(r,a)||this.throw(`The requested module does not provide an export named "${a}".`,[o,s]),(this.$params.quantumMode?R:Reflect).set(i,u||a,R.get(r,a)),n.push([a,o,u])}!n.length||!this.$params.quantumMode||this.once(R.observe(r,a=>{for(let[o,,u]of n)for(let c of a)o==="*"?R.set(i,c.key,c.value):c.key===o&&R.set(i,u||o,c.value)}))}afterExecute(...t){return this.$params.sourceType==="module"&&this.$params.experimentalFeatures!==!1&&this.$params.exportNamespace&&(Le[this.$params.exportNamespace]=this.exports,this.once(()=>{delete Le[this.$params.exportNamespace]})),super.afterExecute(...t)}};G(zt,"AutoAsyncIterator",Re),G(zt,"AutoIterator",Ut);function Me(e,t,i,r){let{env:s,functionParams:n=[],exportNamespace:a,fileName:o}=r,{parserParams:u,compilerParams:c,runtimeParams:l}=li(r),f=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1,p=["async-script","module"].includes(e);if(e==="module")u.sourceType=e,u.allowAwaitOutsideFunction=!0;else if(["function","async-function"].includes(e)){let g=" "+i.split(`
|
|
12
12
|
`).join(`
|
|
13
13
|
`);i=`return ${e==="async-function"?"async ":""}function**(${n.join(", ")}) {
|
|
14
14
|
${g}
|
|
15
|
-
}`,u.quantumMode=!1}else if(!["script","async-script"].includes(e))throw new Error(`Unrecognized sourceType specified: "${e}".`);c.sourceType=e,u.inBrowser=f,c.base64=p&&f&&"export default async function(%0) {%1}";let m=t(i,{parserParams:u,compilerParams:c});if(m instanceof Promise&&!["async-function","async-script","module"].includes(e))throw new Error("Parse-compile can only return a Promise for sourceTypes: async-function, async-script, module.");return l.sourceType=e,l.inBrowser=f,l.exportNamespace=a,l.fileName=o,nt(m,g=>{let b=["function","async-function"].includes(e);return nt(((x,w)=>{if(l.compileFunction)return l.compileFunction(w.toString(),[x]);if(c.base64){let C=`data:text/javascript;base64,${w.toString("base64")}`;return(()=>import(C).then(y=>y.default))()}return new(p?async function(){}.constructor:Function)(x,w.toString())})(g.identifier+"",g),x=>{let w=(C,E=s)=>{let y=x;C&&(y=y.bind(C));let _="global",S=new et(void 0,_,globalThis);return(e.endsWith("script")||E)&&(_="env",S=new et(S,_,E)),e==="module"&&(_="module",S=new et(S,_)),typeof C<"u"&&(S=new et(S,"this",{this:C})),new zt(void 0,_,{...l,originalSource:g.originalSource,quantumMode:g.isQuantumProgram},S,y)};return b?w().execute():{createRuntime:w,compilation:g}})})}var Qt=class{constructor(...t){let i=this.constructor,r=typeof t[t.length-1]=="object"?t.pop():{},s=t.pop()||"";this.$program=Me(i.sourceType,i.parseCompileCallback,s,r)}execute(){return nt(this.$program,({createRuntime:t})=>t().execute())}bind(t,i=void 0){return nt(this.$program,({createRuntime:r})=>r(t,i))}toString(t=!1){return nt(this.$program,({compilation:i})=>t?i+"":i.originalSource)}};function ha(...e){let{source:t,params:i}=Di(e);return Me("function",Fe,t,i)}function As(...e){let{source:t,params:i}=Di(e);return Me("async-function",Fe,t,i)}var fa=As,De=class extends Qt{};G(De,"sourceType","script"),G(De,"parseCompileCallback",Fe);var ce=class extends Qt{};G(ce,"sourceType","async-script"),G(ce,"parseCompileCallback",Fe);var pa=ce,Ve=class extends Qt{};G(Ve,"sourceType","module"),G(Ve,"parseCompileCallback",Fe);function Fe(e,t){let i=Cs(e,t.parserParams);return ks(i,t.compilerParams)}function qe(e,t,i={},r={}){t=W(t).slice();for(var s=e;!_t(s)&&!ge(s)&&t.length;){var n=t.shift();if(!(i.get?i.get(s,n):q(s)?n in s:s[n])){r.exists=!1;return}s=i.get?i.get(s,n):s[n]}return r.exists=!0,s}function er(e,t,i,r={},s={}){let n=(l,f,p)=>s.set?s.set(l,f,p):(at(t[o])&&L(l)?l.push(p):l[f]=p,!0);t=W(t);for(var a=e,o=0;o<t.length;o++)if(o<t.length-1){if(!a||!q(a)&&!F(a))return!1;var u=qe(a,t[o],s);if(!q(u)){if(s.buildTree===!1)return!1;u=F(s.buildTree)?s.buildTree(o):at(t[o+1])?[]:{};var c=n(a,t[o],u);if(!c)return!1}a=u}else return n(a,t[o],i)}var je=class{constructor(t,i=!1){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!i&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let i=await t();return this._synthesis--,i}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,i=!1){if(i)return new Promise(r=>{this.synthesis?r(t()):this.readCallbacks.add(()=>{r(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,i=!1){if(i)return new Promise(r=>{this.synthesis?r(t()):this.writeCallbacks.add(()=>{r(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,i,r){this.onread(()=>{let s=t(r),n=a=>{a!==void 0&&this.onwrite(()=>{let o=i(a,r),u=c=>{c!==void 0&&this.cycle(t,i,c)};o instanceof Promise?o.then(u):u(o)})};s instanceof Promise?s.then(n):n(s)})}};function Ps(e){return(e=e.trim())&&e.startsWith("(")&&e.endsWith(")")}function le(e,t,i,r=!0){i=(Array.isArray(i)?i:[i]).map(a=>(a+"").replace("(",r?"(.//":"(./")).join("|");let s=[],n;try{let a=e.document.evaluate(i,t,null,e.XPathResult.ANY_TYPE);for(;n=a.iterateNext();)s.push(n)}catch{}return s}function Is(e,t,i){i=(Array.isArray(i)?i:[i]).map(r=>(r+"").replace("(","(self::")).join("|");try{return e.document.evaluate(`${i}`,t,null,e.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function Be(e,t,i,r=!1){let s=t.getRootNode(),n=i.getRootNode();return s===n?t.contains(i):r&&n instanceof e.ShadowRoot?Be(e,t,n.host,r):!1}function Os(e,t="|"){return[...e].reduce(([i,r,s,n],a)=>!i&&r===0&&(Array.isArray(t)?t:[t]).includes(a)?[i,r,[""].concat(s)]:(!i&&["(","[","{"].includes(a)&&!s[0].endsWith("\\")&&r++,!i&&[")","]","}"].includes(a)&&!s[0].endsWith("\\")&&r--,['"',"'","`"].includes(a)&&!s[0].endsWith("\\")&&(i=i===a?null:i||a),s[0]+=a,[i,r,s]),[null,0,[""]])[2].reverse()}var ht=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Ps(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Os(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var Gt=class{constructor(t,i,r){this.context=t,this.namespace=i,this.window=t.defaultView||t.ownerDocument?.defaultView||r,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(F(t[0])?t=[[],...t]:V(t[0])&&!(t[0]instanceof ht)&&t.length===1?t=[[],void 0,t[0]]:V(t[1])&&t.length===2?t=[W(t[0],!1),void 0,t[1]]:t[0]=W(t[0],!1),t[0].filter(i=>typeof i!="string"&&!(i instanceof ht)&&!(i instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(i=>i instanceof ht?i:new ht(i)),t}registry(...t){return K("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,i,r){let{window:s}=this,n=Array.isArray(i)?i:[i],a=new Set;for(let[o,u]of this.registry(t))for(let[c,l]of u){let f=n.filter(p=>Be(s,c,p.target,o==="cross-roots")?["subtree","cross-roots"].includes(o)||p.target===c:!1);if(!!f.length){Array.isArray(i)||(f=f[0]);for(let p of l)a.add([p,f,c])}}for(let[o,u,c]of[...a].reverse())r.call(s,o,u,c)}disconnectables(t,...i){let r={disconnect(){i.forEach(s=>s&&F(s.disconnect)&&s.disconnect()||F(s)&&s()||V(s)&&(s.disconnected=!0))}};return t&&t.addEventListener("abort",()=>r.disconnect()),r}};var Mt=class extends Gt{constructor(t,...i){super(t,"attr",...i)}get(t,i=void 0,r={}){let s=typeof t=="string"||t instanceof ht;[t=[],i=void 0,r={}]=this.resolveArgs(arguments);let{context:n}=this,a=Ls(n,t);if(!i)return a;let o=r.lifecycleSignals&&this.createSignalGenerator();if(s)for(let u of a){let c=o?.generate()||{};i(u,c,n)}else{let u=o?.generate()||{};i(a,u,n)}if(r.live){o&&(r={...r,signalGenerator:o});let u=this.observe(s?t[0]:t,i,{newValue:!0,...r});return this.disconnectables(r.signal,u)}}observe(t,i,r={}){let s=typeof t=="string"||t instanceof ht;if([t=[],i,r={}]=this.resolveArgs(arguments),["sync","intercept"].includes(r.timing))return this.observeSync(s?t[0]:t,i,r);if(r.timing&&r.timing!=="async")throw new Error(`Timing option "${r.timing}" invalid.`);let{context:n,window:a,webqit:o}=this;r.eventDetails&&!o.realdom.attrInterceptionHooks?.intercepting&&Ns.call(a,"intercept",()=>{});let u=new a.MutationObserver(p=>{p=$s(p).map(m=>Rs.call(a,m)),Ts.call(a,f,p,n)}),c={attributes:!0,attributeOldValue:r.oldValue,subtree:r.subtree&&!0};t.length&&(c.attributeFilter=t.map(p=>p+"")),u.observe(n,c);let l=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),f={context:n,spec:t,callback:i,params:r,atomics:new Map,originalFilterIsString:s,signalGenerator:l,disconnectable:u};return this.disconnectables(r.signal,u,l)}observeSync(t,i,r={}){let s=typeof t=="string"||t instanceof ht;[t,i,r={}]=this.resolveArgs(arguments);let{context:n,window:a}=this;if(r.timing&&!["sync","intercept"].includes(r.timing))throw new Error(`Timing option "${r.timing}" invalid.`);let o=r.timing==="intercept"?"intercept":"sync",u=r.subtree==="cross-roots"?"cross-roots":r.subtree?"subtree":"children";this.registry(o).size||Ns.call(a,o,g=>{this.forEachMatchingContext(o,g,Ts)});let c={disconnect(){m.delete(f),m.size||p.delete(n)}},l=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),f={context:n,spec:t,callback:i,params:r,atomics:new Map,originalFilterIsString:s,signalGenerator:l,disconnectable:c},p=this.registry(o,u);p.has(n)||p.set(n,new Set);let m=p.get(n);return m.add(f),this.disconnectables(r.signal,c,l)}};function $s(e){return e.reduce((t,i,r)=>t[r-1]?.attributeName===i.attributeName||K(i.target,"internalAttrInteractions").get(i.attributeName)?t:t.concat(i),[])}function Ts(e,t){let{context:i,spec:r,callback:s,params:n,atomics:a,originalFilterIsString:o,signalGenerator:u}=e,c=r.map(p=>p+"");if(n.atomic&&!a.size?t=Ls(i,r,t):n.timing!=="async"&&r.length&&(t=t.filter(p=>c.includes(p.name))),!t.length)return;n.newValue===null&&n.oldValue===null&&n.eventDetails||(t=t.map(p=>{let m;return n.eventDetails||({event:m,...p}=p),!n.oldValue&&"oldValue"in p&&({oldValue:m,...p}=p),!n.newValue&&"value"in p?{value:m,...p}=p:n.newValue&&typeof p.value>"u"&&(p={...p,value:fi(p.target,p.name,()=>p.target.getAttribute(p.name))}),p})),n.atomic&&(t.forEach(p=>a.set(p.name,p)),t=Array.from(a.entries()).map(([,p])=>p));let l=o?t[0]:t,f=u?.generate()||{};s(l,f,i)}function fi(e,t,i){let r=K(e,"internalAttrInteractions").get(t);K(e,"internalAttrInteractions").set(t,!0);let s=i();return K(e,"internalAttrInteractions").set(t,r),s}function Ls(e,t,i=[]){let r={event:null,type:"attribute"};return t.length?t.map(n=>(n=n+"",i.find(a=>a.name===n)||{target:e,name:n,value:fi(e,n,()=>e.getAttribute(n)),...r})):Array.from(e.attributes).map(n=>i.find(a=>a.name===n.nodeName)||{target:e,name:n.nodeName,value:fi(e,n.nodeName,()=>n.nodeValue),...r})}function Rs({target:e,attributeName:t,value:i,oldValue:r}){let a=(this.webqit.realdom.attrInterceptionRecords?.get(e)||{})[t]?.[0]||"mutation";return{target:e,name:t,value:i,oldValue:r,type:"observation",event:a}}function Ns(e,t){let i=this,{webqit:r,document:s,Element:n}=i;r.realdom.attrInterceptionHooks||Object.defineProperty(r.realdom,"attrInterceptionHooks",{value:new Map}),r.realdom.attrInterceptionHooks.has(e)||r.realdom.attrInterceptionHooks.set(e,new Set),r.realdom.attrInterceptionHooks.get(e).add(t);let a=()=>r.realdom.attrInterceptionHooks.get(e).delete(t);if(r.realdom.attrInterceptionHooks?.intercepting)return a;console.warn("Attr mutation APIs are now being intercepted."),r.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(r.realdom,"attrInterceptionRecords",{value:new Map});let o=(l,f)=>{r.realdom.attrInterceptionRecords.has(l.target)||r.realdom.attrInterceptionRecords.set(l.target,{});let p=r.realdom.attrInterceptionRecords.get(l.target);if(p[l.name]=p[l.name]||[],p[l.name].unshift(l.event),K(l.target,"internalAttrInteractions").get(l.name))return f();r.realdom.attrInterceptionHooks.get("intercept")?.forEach(g=>g([l]));let m=f();return r.realdom.attrInterceptionHooks.get("sync")?.forEach(g=>g([l])),m};new i.MutationObserver(l=>{l=l.filter(f=>!(i.webqit.realdom.attrInterceptionRecords?.get(f.target)||{})[f.attributeName]?.shift()),l=$s(l).map(f=>Rs.call(i,f)),l.length&&(r.realdom.attrInterceptionHooks.get("intercept")?.forEach(f=>f(l)),r.realdom.attrInterceptionHooks.get("sync")?.forEach(f=>f(l)))}).observe(s,{attributes:!0,subtree:!0,attributeOldValue:!0});let c=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{c[l]=n.prototype[l],n.prototype[l]=function(...f){let p,m=fi(this,f[0],()=>this.getAttribute(f[0]));["setAttribute","toggleAttribute"].includes(l)&&(p=f[1]),l==="toggleAttribute"&&p===void 0&&(p=m===null);let g={target:this,name:f[0],value:p,oldValue:m,type:"interception",event:[this,l]};return o(g,()=>c[l].call(this,...f))}}),a}var He=class extends Gt{constructor(t,...i){super(t,"tree",...i)}attr(t,i=void 0,r={}){let{context:s,window:n}=this;return new Mt(s,n).get(...arguments)}query(t,i=void 0,r={}){[t,i=void 0,r={}]=this.resolveArgs(arguments);let{context:s}=this,n=new Map,a=c=>(n.has(c)||n.set(c,{target:c,entrants:[],exits:[],type:"query",event:null}),n.get(c));if(!r.generation||r.generation==="entrants"){if(!t.length)[...s.children].forEach(c=>a(s).entrants.push(c));else if(t.every(c=>c.type==="selector")){let[c,l]=t.reduce(([p,m],g)=>g.kind==="xpath"?[p,m.concat(g)]:[p.concat(g),m],[[],[]]),f=[];r.subtree?(c.length&&f.push(...s.querySelectorAll(c.join(","))),l.length&&f.push(...le(this.window,s,l))):(c.length&&f.push(...[...s.children].filter(p=>p.matches(c))),l.length&&f.push(...le(this.window,s,l,!1))),f.forEach(p=>a(p.parentNode||s).entrants.push(p))}}if(!i)return n;let o={disconnected:!1},u=i&&r.lifecycleSignals&&this.createSignalGenerator();for(let[,c]of n){if(o.disconnected)break;let l=u?.generate()||{};i(c,l,s)}if(r.live){u&&(r={...r,signalGenerator:u});let c=this.observe(t,i,r);return this.disconnectables(r.signal,o,c)}return this.disconnectables(r.signal,o,u)}children(t,i=void 0,r={}){return[t,i=void 0,r={}]=this.resolveArgs(arguments),this.query(t,i,{...r,subtree:!1})}subtree(t,i=void 0,r={}){return[t,i=void 0,r={}]=this.resolveArgs(arguments),this.query(t,i,{...r,subtree:!0})}observe(t,i,r={}){if([t,i,r={}]=this.resolveArgs(arguments),["sync","intercept"].includes(r.timing))return this.observeSync(t,i,r);if(r.timing&&r.timing!=="async")throw new Error(`Timing option "${r.timing}" invalid.`);let{context:s,window:n,webqit:a,document:o}=this;r.eventDetails&&(a.realdom.domInterceptionRecordsAlwaysOn=!0),(o.readyState==="loading"||a.realdom.domInterceptionRecordsAlwaysOn)&&!a.realdom.domInterceptionHooks?.intercepting&&Vs.call(n,"sync",()=>{});let u=new n.MutationObserver(f=>f.forEach(p=>{rr.call(n,l,Ds.call(n,p),s)}));u.observe(s,{childList:!0,subtree:r.subtree&&!0});let c=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),l={context:s,spec:t,callback:i,params:r,signalGenerator:c,disconnectable:u};if(r.staticSensitivity){let f=Ms.call(n,l);return this.disconnectables(r.signal,u,c,f)}return this.disconnectables(r.signal,u,c)}observeSync(t,i,r={}){[t,i,r={}]=this.resolveArgs(arguments);let{context:s,window:n}=this;if(r.timing&&!["sync","intercept"].includes(r.timing))throw new Error(`Timing option "${r.timing}" invalid.`);let a=r.timing==="intercept"?"intercept":"sync",o=r.subtree==="cross-roots"?"cross-roots":r.subtree?"subtree":"children";this.registry(a).size||Vs.call(n,a,g=>{this.forEachMatchingContext(a,g,rr)});let u=new n.MutationObserver(g=>g.forEach(b=>{Array.isArray((b=Ds.call(n,b)).event)||rr.call(n,f,b,s)}));u.observe(s,{childList:!0,subtree:r.subtree&&!0});let c={disconnect(){u.disconnect(),m.delete(f),m.size||p.delete(s)}},l=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),f={context:s,spec:t,callback:i,params:r,signalGenerator:l,disconnectable:c},p=this.registry(a,o);p.has(s)||p.set(s,new Set);let m=p.get(s);if(m.add(f),r.staticSensitivity){let g=Ms.call(n,f);return this.disconnectables(r.signal,c,l,g)}return this.disconnectables(r.signal,c,l)}track(t,i,r={}){return r={subtree:!0,...r},this.observe(t,s=>{s.entrants.length&&i(!0,Array.isArray(t)?s.entrants:s.entrants[0]),s.exits.length&&i(!1,Array.isArray(t)?s.exits:s.exits[0])},r)}};function Ms(e){let t=this,{context:i,spec:r,callback:s,params:n,signalGenerator:a}=e,o=r.filter(m=>m.kind==="css"),u=m=>m.match(/\.([\w-]+)/g)?.length?["class"]:[],c=m=>m.match(/#([\w-]+)/g)?.length?["id"]:[],l=m=>[...m.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(g=>g[1]).concat(u(m)).concat(c(m));if(!(e.$attrs=Array.from(new Set(o.filter(m=>(m+"").includes("[")).reduce((m,g)=>m.concat(l(g+"")),[])))).length)return;let f=new Set,p=new Set;return f.push=m=>(p.delete(m),f.add(m)),p.push=m=>(f.delete(m),p.add(m)),e.$deliveryCache={entrants:f,exits:p},new Mt(i,t).observe(e.$attrs,m=>{let g=new Map,b=w=>(g.has(w)||g.set(w,{target:w,entrants:[],exits:[],type:"static",event:null}),g.get(w)),v=new WeakMap,x=w=>(v.has(w)||v.set(w,o.some(C=>w.matches(C+""))),v.get(w));for(let w of m)["entrants","exits"].forEach(C=>{n.generation&&C!==n.generation||e.$deliveryCache[C].has(w.target)||(C==="entrants"?!x(w.target):x(w.target))||(e.$deliveryCache[C].push(w.target),b(w.target)[C].push(w.target),b(w.target).event=w.event)});for(let[,w]of g){let C=a?.generate()||{};s(w,C,i)}},{subtree:n.subtree,timing:n.timing,eventDetails:n.eventDetails})}function rr(e,t){let{context:i,spec:r,callback:s,params:n,signalGenerator:a,$deliveryCache:o}=e,u={...t,entrants:[],exits:[]};if(n.eventDetails||delete u.event,["entrants","exits"].forEach(l=>{if(!(n.generation&&l!==n.generation)&&(r.length?u[l]=xa.call(this,r,n.subtree==="cross-roots",t[l],t.event!=="parse"):u[l]=[...t[l]],!!o))for(let f of u[l])o[l].push(f)}),!u.entrants.length&&!u.exits.length)return;let c=a?.generate()||{};s(u,c,i)}function xa(e,t,i,r){i=Array.isArray(i)?i:[...i];let s=(n,a)=>{if(a.type==="selector"){let o=a.isXpathAttr?[]:n.filter(u=>a.kind==="xpath"?Is(this,u,a+""):u.matches&&u.matches(a+""));if((r||a.isXpathAttr)&&(o=n.reduce((u,c)=>a.kind==="xpath"?[...u,...le(this,c,a,r)]:c.querySelectorAll?[...u,...c.querySelectorAll(a+"")]:u,o)),o.length)return o}else if(n.includes(a.content)||r&&n.some(o=>Be(this,o,a.content,t)))return[a.content]};return i.$$searchCache||(i.$$searchCache=new Map),e.reduce((n,a)=>{let o;return i.$$searchCache.has(a.content)?o=i.$$searchCache.get(a.content):(o=s(i,a)||[],a.type==="instance"&&i.$$searchCache.set(a.content,o)),n.concat(o)},[])}function Ds({target:e,addedNodes:t,removedNodes:i}){let r=this,s;return s=W(t).reduce((n,a)=>n||r.webqit.realdom.domInterceptionRecords?.get(a),null),s=W(i).reduce((n,a)=>n||r.webqit.realdom.domInterceptionRecords?.get(a),s),s=s||r.document.readyState==="loading"&&"parse"||"mutation",{target:e,entrants:t,exits:i,type:"observation",event:s}}function Vs(e,t){let i=this,{webqit:r,document:s,Node:n,CharacterData:a,Element:o,HTMLElement:u,HTMLTemplateElement:c,DocumentFragment:l}=i;r.realdom.domInterceptionHooks||Object.defineProperty(r.realdom,"domInterceptionHooks",{value:new Map}),r.realdom.domInterceptionNoRecurse||Object.defineProperty(r.realdom,"domInterceptionNoRecurse",{value:new Map}),r.realdom.domInterceptionHooks.has(e)||r.realdom.domInterceptionHooks.set(e,new Set),r.realdom.domInterceptionHooks.get(e).add(t);let f=()=>r.realdom.domInterceptionHooks.get(e).delete(t);if(r.realdom.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),r.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(r.realdom,"domInterceptionRecords",{value:new Map});let p=(x,w,C)=>{r.realdom.domInterceptionNoRecurse.set(x,w);let E=C();return r.realdom.domInterceptionNoRecurse.delete(x),E},m=(x,w)=>{x.entrants.concat(x.exits).forEach(E=>{clearTimeout(r.realdom.domInterceptionRecords.get(E)?.timeout),r.realdom.domInterceptionRecords.set(E,x.event);let y=setTimeout(()=>{r.realdom.domInterceptionRecords.delete(E)},0);Object.defineProperty(x.event,"timeout",{value:y,configurable:!0})}),r.realdom.domInterceptionHooks.get("intercept")?.forEach(E=>E(x));let C=w();return r.realdom.domInterceptionHooks.get("sync")?.forEach(E=>E(x)),C},g={ShadowRoot:["innerHTML"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTML","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},b={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(g).reduce((x,w)=>x.concat(w),[])).forEach(x=>{Object.keys(g).forEach(E=>{if(!g[E].includes(x))return;let y=Object.getOwnPropertyDescriptor(i[E].prototype,x);!y||(Object.defineProperty(i[E].prototype,x,"value"in y?{...y,value:w}:{...y,set:C}),b[E][x]=y)});function w(...E){let y=Object.keys(b).find(Y=>this instanceof i[Y]&&x in b[Y]),_=b[y],S=()=>_[x].value.call(this,...E);if(r.realdom.domInterceptionNoRecurse.get(this)===x)return S();let O=[],P=[],D=this;["insertBefore"].includes(x)?P=[E[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(x)?(P=[E[1]],["beforebegin","afterend"].includes(E[0])&&(D=this.parentNode)):["setHTML","replaceChildren"].includes(x)?(O=[...this.childNodes],P=x==="replaceChildren"?[...E]:[E[0]]):["replaceWith","remove"].includes(x)?(O=[this],P=x==="replaceWith"?[...E]:[],D=this.parentNode):["replaceChild"].includes(x)?(O=[E[1]],P=[E[0]]):["removeChild"].includes(x)?O=[...E]:(P=[...E],["before","after"].includes(x)&&(D=this.parentNode));let H=x;if(["insertAdjacentHTML","setHTML"].includes(x)){let Y=this.nodeName;if(x==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(E[0])){if(!this.parentNode)return _[x].value.call(this,...E);Y=this.parentNode.nodeName}let X=s.createElement(Y);_.setHTML.value.call(X,P[0],x==="setHTML"?E[1]:{}),P=[...X.childNodes],x==="insertAdjacentHTML"?(H="insertAdjacentElement",E[1]=new l,p(E[1],"append",()=>E[1].append(...X.childNodes))):(H="replaceChildren",E=[...X.childNodes])}return m({target:D,entrants:P,exits:O,type:"interception",event:[this,x]},()=>_[H].value.call(this,...E))}function C(E){let y=Object.keys(b).find(Q=>this instanceof i[Q]&&x in b[Q]),_=b[y],S=()=>_[x].set.call(this,E);if(this instanceof HTMLScriptElement||r.realdom.domInterceptionNoRecurse.get(this)===x)return S();let O=[],P=[],D=this;if(["outerHTML","outerText"].includes(x)?(O=[this],D=this.parentNode):this instanceof c?(D=this.content,O=[...this.content.childNodes]):O=[...this.childNodes],["outerHTML","innerHTML"].includes(x)){let Q=this.nodeName;if(x==="outerHTML"){if(!this.parentNode)return S();Q=this.parentNode.nodeName}let Y=s.createElement(Q.includes("-")?"div":Q);if(p(Y,x,()=>Y[x]=E),P=this instanceof c?[...Y.content.childNodes]:[...Y.childNodes],this instanceof c&&this.hasAttribute("src")){let X=Jt=>Jt.reduce((vt,St)=>St instanceof HTMLScriptElement?vt.concat(St):St instanceof c?vt.concat(X([St.content])):(vt=vt.concat(X([...St.querySelectorAll?.("template")||[]].map(rn=>rn.content))),vt.concat(...St.querySelectorAll?.("script")||[])),[]);for(let Jt of X(P)){let vt=s.createElement("script");[...Jt.attributes].forEach(St=>vt.setAttribute(St.name,St.value)),vt.textContent=Jt.textContent,p(Jt,"replaceWith",()=>Jt.replaceWith(vt))}}x==="outerHTML"?(E=new l,p(E,"append",()=>E.append(...P)),S=()=>p(this,"replaceWith",()=>o.prototype.replaceWith.call(this,E))):this instanceof c?S=()=>p(this.content,"replaceChildren",()=>this.content.replaceChildren(...P)):S=()=>p(this,"replaceChildren",()=>o.prototype.replaceChildren.call(this,...P))}return m({target:D,entrants:P,exits:O,type:"interception",event:[this,x]},S)}}),f}function Fs(){ya.call(this),ba.call(this),wa.call(this)}function ya(){let e=this;e.CSS||(e.CSS={}),e.CSS.escape||(e.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function ba(){let e=this;"isConnected"in e.Node.prototype||Object.defineProperty(e.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function wa(){let e=this;e.Element.prototype.matches||(e.Element.prototype.matches=e.Element.prototype.matchesSelector||e.Element.prototype.mozMatchesSelector||e.Element.prototype.msMatchesSelector||e.Element.prototype.oMatchesSelector||e.Element.prototype.webkitMatchesSelector||function(t){for(var i=(this.document||this.ownerDocument).querySelectorAll(t),r=i.length;--r>=0&&i.item(r)!==this;);return r>-1})}function qs(){let e=this;if(e.webqit||(e.webqit={}),e.webqit.realdom)return e.webqit.realdom;e.webqit.realdom={},Fs.call(e),e.webqit.realdom.meta=(...i)=>va.call(e,...i),e.webqit.realdom.ready=(...i)=>sr.call(e,...i),e.webqit.realdom.realtime=(i,r="dom")=>{if(r==="dom")return new He(i,e);if(r==="attr")return new Mt(i,e)};let t=new je(e);return e.webqit.realdom.schedule=(i,...r)=>t[`on${i}`](...r),e.webqit.realdom.synthesizeWhile=(...i)=>t.synthesizeWhile(...i),e.webqit.realdom}function sr(...e){let t="interactive",i;ee(e[0])?(t=e[0],F(e[1])&&(i=e[1])):F(e[0])&&(i=e[0]);let r={interactive:["interactive","complete"],complete:["complete"]};if(!r[t])throw new Error(`Invalid ready-state timing: ${t}.`);let s=this;if(!i)return s.webqit.realdom.readyStatePromises||(s.webqit.realdom.readyStatePromises={interactive:new Promise(n=>sr.call(this,"interactive",n)),complete:new Promise(n=>sr.call(this,"complete",n))}),s.webqit.realdom.readyStatePromises[t];if(r[t].includes(s.document.readyState))return i(s);s.webqit.realdom.readyStateCallbacks||(s.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},s.document.addEventListener("readystatechange",()=>{let n=s.document.readyState;for(let a of s.webqit.realdom.readyStateCallbacks[n].splice(0))a(s)},!1)),s.webqit.realdom.readyStateCallbacks[t].push(i)}function va(e){let t=this,i={},r;return(r=t.document.querySelector(`meta[name="${e}"]`))&&(i=(r.content||"").split(";").filter(s=>s).reduce((s,n)=>{let a=n.split("=").map(o=>o.trim());return er(s,a[0].split("."),a[1]==="true"?!0:a[1]==="false"?!1:at(a[1])?parseInt(a[1]):a[1]),s},{})),{get name(){return e},get content(){return r.content},json(){return JSON.parse(JSON.stringify(i))}}}function pi(e,t){return typeof e!="string"?e:e.replace(/\w\S*/g,function(i){return i.charAt(0).toUpperCase()+(typeof t!==void 0&&t?i.substr(1).toLowerCase():i.substr(1))})}var A=(...e)=>K("oohtml",...e),U={};function rt(e,t,i){let r=this,s=qs.call(r);U.window=r,r.webqitConfig||(r.webqitConfig=s.meta("webqit").json()),r.webqit||(r.webqit={}),r.webqit.oohtml||(r.webqit.oohtml={}),r.webqit.oohtml.configs||(r.webqit.oohtml.configs={});let n=e.toUpperCase().replace("-","_");if(!r.webqit.oohtml.configs[n]){r.webqit.oohtml.configs[n]={};let a=r.webqit.oohtml.configs[n];ye(2,a,i,t,s.meta(e).json()),r.webqitConfig.prefix&&Object.keys(a).forEach(o=>{Object.keys(a[o]).forEach(u=>{o==="api"&&typeof a[o][u]=="string"?a[o][u]=`${r.webqitConfig.prefix}${pi(a[o][u])}`:["attr","elements"].includes(o)&&a[o][u]?.startsWith("data-")===!1&&(a[o][u]=`${r.webqitConfig.prefix}-${a[o][u]}`)})})}return{config:r.webqit.oohtml.configs[n],realdom:s,window:r}}function ar(e,t){return K(e,"internalAttrInteractions").get(t)}function Bs(e,t,i){let r=K(e,"internalAttrInteractions").get(t);K(e,"internalAttrInteractions").set(t,!0);let s=i();return K(e,"internalAttrInteractions").set(t,r),s}function he(e,t){return[...e].reduce(([i,r,s],n)=>!i&&r===0&&(Array.isArray(t)?t:[t]).includes(n)?[i,r,[""].concat(s)]:(!i&&["(","[","{"].includes(n)&&!s[0].endsWith("\\")&&r++,!i&&[")","]","}"].includes(n)&&!s[0].endsWith("\\")&&r--,['"',"'","`"].includes(n)&&!s[0].endsWith("\\")&&(i=i===n?null:i||n),s[0]+=n,[i,r,s]),[null,0,[""]])[2].reverse()}var Ea=()=>(0|Math.random()*9e6).toString(36),nr=new Map;function Kt(e){let t;return(t=nr.get(e))||(t=Ea(),nr.set(e,t)),t}function di(e){let t;return nr.forEach((i,r)=>{i===e&&(t=r)}),t}function mi(){let{window:e}=U,{webqit:t}=e;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class i extends e.Event{constructor(...s){let n=s.pop();if(typeof n!="function")throw new Error("Callback must be provided.");let a=s.pop();if(!a?.kind)throw new Error('"options.kind" must be specified.');let o=["contextrequest","contextclaim"],u=s.pop()||o[0];if(!o.includes(u))throw new Error(`Invalid event type. Must be one of: ${o.join(",")}`);let{kind:c,detail:l,targetContext:f,live:p,signal:m,diff:g,...b}=a;super(u,{...b,bubbles:b.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>n}),Object.defineProperty(this,"kind",{get:()=>c}),Object.defineProperty(this,"targetContext",{get:()=>f}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>p}),Object.defineProperty(this,"signal",{get:()=>m}),Object.defineProperty(this,"diff",{get:()=>g}),Object.defineProperty(this,"options",{get:()=>b}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(s){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===s)return;Object.defineProperty(this,"_prevValue",{value:s,configurable:!0})}return this.callback(s)}}return t.DOMContextRequestEvent=i,i}var Xt=class extends AbortController{constructor(t){super(),t(i=>{let{window:{webqit:{Observer:r}}}=U;r.defineProperty(this,"value",{value:i,configurable:!0,enumerable:!0})},this)}};var Yt=class extends Error{};var Ue=new Map,Dt=class{static instance(t){return A(t).get("contexts::instance")||new this(t)}constructor(t){A(t).get("contexts::instance")?.dispose(),A(t).set("contexts::instance",this);let i={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>i})}get[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(i=>typeof t[0]=="function"?t[0](i):i.constructor.kind===t[0]&&(t.length===1||i.detail===t[1]))}attach(t){if(!(t instanceof st))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new Yt(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new Xt((i,r)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(i):t[t.length-1]=i);let s;(s=t.find(u=>typeof u=="object"&&u))&&s.live&&(s.signal&&s.signal.addEventListener("abort",()=>r.abort()),t[t.indexOf(s)]={...s,signal:r.signal});let n=new(mi())(...t);n.meta.target=this["#"].host;let a=this["#"].host.getRootNode(),o=u=>{if(u.stopImmediatePropagation(),u.meta.target=u.target,!u.answered){if(Ue.get(a)||Ue.set(a,new Set),u.type==="contextrequest"&&u.live)Ue.get(a).add(u);else if(u.type==="contextclaim"){let c=new Set;return Ue.get(a).forEach(l=>{!this["#"].host.contains(l.target)||!u.detail.matchEvent(l)||(Ue.get(a).delete(l),c.add(l))}),u.respondWith(c)}}};a.addEventListener(n.type,o),this["#"].host.dispatchEvent(n),a.removeEventListener(n.type,o)})}};var or=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=U;return t}get name(){return[U.window.Document,U.window.ShadowRoot].some(t=>this.host instanceof t)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(!(t.detail instanceof or)||t.target===this.host)return;let i=new Set;if(this.subscriptions.forEach(r=>{!t.target.contains(r.target)||!t.detail.matchEvent(r)||(this.subscriptions.delete(r),this.unsubscribed(r),i.add(r))}),i.size)return t.respondWith(i)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:i}=Dt.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return i?.forEach(r=>{this.subscriptions.add(r),this.subscribed(r),this.handle(r)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(i=>{this.subscriptions.delete(i),this.unsubscribed(i);let{target:r}=i;r.dispatchEvent(i)}),this}},st=or;G(st,"kind");var fe=class extends st{static createRequest(t=null){let i=super.createRequest();if(t?.startsWith("@")){let[r,...s]=s.slice(1).split("/").map(n=>n.trim());i.targetContext=r,i.detail=s.join("/")}else i.detail=t;return i}get namespaceObj(){return this.host[this.configs.NAMESPACED_HTML.api.namespace]}handle(t){let{window:{webqit:{Observer:i}}}=U;if(t.meta.controller?.abort(),!(t.detail||"").trim())return t.respondWith(i.unproxy(this.namespaceObj));let r=(t.detail||"").split("/").map(s=>s.trim()).filter(s=>s);if(!r.length)return t.respondWith();r=r.join(`/${this.configs.NAMESPACED_HTML.api.namespace}/`)?.split("/")||[],t.meta.controller=i.reduce(this.namespaceObj,r,i.get,s=>{this.disposed||t.respondWith(s.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};G(fe,"kind","namespace");function ur(e={}){let{config:t,window:i}=rt.call(this,"namespaced-html",e,{attr:{namespace:"namespace",lid:"id"},api:{namespace:"namespace"},tokens:{lidrefPrefix:"~",lidrefSeparator:":"},target:{className:":target",eventName:":target",scrolling:!0}});t.lidSelector=`[${i.CSS.escape(t.attr.lid)}]`,t.namespaceSelector=`[${i.CSS.escape(t.attr.namespace)}]`,i.webqit.DOMNamingContext=fe,Ca.call(i,t),ka.call(i,t)}function Hs(e){let{lidrefPrefix:t,lidrefSeparator:i}=e.tokens;return{escape(r,s=1){return[...r].map(n=>/\w/.test(n)?n:s===2?`\\\\${n}`:`\\${n}`).join("")},lidrefPrefix(r=0){return r?this.escape(t,r):t},lidrefSeparator(r=0){return r?this.escape(i,r):i},isUuid(r,s=0){return r.startsWith(this.lidrefPrefix(s))&&r.includes(this.lidrefSeparator(s))},isLidref(r,s=0){return r.startsWith(this.lidrefPrefix(s))&&!r.includes(this.lidrefSeparator(s))},toUuid(r,s,n=0){return r.endsWith("-root")?s:`${this.lidrefPrefix(n)}${r}${this.lidrefSeparator(n)}${s}`},uuidToId(r,s=0){return this.isUuid(r)?r.split(this.lidrefSeparator(s))[1]:r},uuidToLidref(r,s=0){return this.isUuid(r)?`${this.lidrefPrefix(s)}${r.split(this.lidrefSeparator(s))[1]}`:r}}}function cr(e,t,i=null,r=0){let s=this,{webqit:{oohtml:{configs:{NAMESPACED_HTML:n}}}}=s,a=Hs(n),o=new RegExp(`${i?":scope|":""}#(${a.lidrefPrefix(r+1)})?([\\w]+${a.lidrefSeparator(r+1)})?((?:[\\w-]|\\\\.)+)`,"g"),[u,c]=he(e,",").reduce(([f,p],m)=>{let g,b;return m=m.replace(o,(v,x,w,C,E)=>{if(g||(g=[...m.matchAll(/(["'])(?:(?=(\\?))\2.)*?\1/g)]),g.some(O=>E>O.index&&E+v.length<O.index+O[0].length))return v;if(v===":scope")return b=!0,i;let y=x&&!w;if(x&&w)return`#${a.escape(v.replace("#",""),1)}`;if(y&&n.attr.lid==="id"&&t&&!t.endsWith("-root"))return`#${a.toUuid(t,C,1)}`;let S;return n.attr.lid==="id"?S=`:is(#${C},[id^="${a.lidrefPrefix(r)}"][id$="${a.lidrefSeparator(r)}${C}"])`:S=`:is(#${C},[${s.CSS.escape(n.attr.lid)}="${C}"])`,y?`:is(${S}):not(${i?i+" ":""}${n.namespaceSelector} *)`:S}),b?[f,p.concat(m)]:[f.concat(m),p]},[[],[]]),l;return i&&u.length?l=[u.length>1?`${i} :is(${u.join(", ")})`:`${i} ${u[0]}`,c.join(", ")].filter(f=>f).join(", "):l=[...u,...c].join(", "),l}function gi(e){let t=this;if(!A(e).has("namespace")){let i=Object.create(null);A(e).set("namespace",i);let r=[t.Document,t.ShadowRoot].some(s=>e instanceof s);Object.defineProperty(i,Symbol.toStringTag,{get(){return r?"RootNamespaceRegistry":"NamespaceRegistry"}})}return A(e).get("namespace")}function pe(e,t=!1){let i=this,{webqit:{oohtml:{configs:{NAMESPACED_HTML:r}}}}=i,s=[i.Document,i.ShadowRoot].some(n=>e instanceof n);return gi.call(i,s?e:(t?e.parentNode:e)?.closest?.(r.namespaceSelector)||e.getRootNode())}function xi(e){let t=Object.prototype.toString.call(e)==="[object RootNamespaceRegistry]";return(di(e)||Kt(e))+(t?"-root":"")}function Ca(e){let t=this,{webqit:{Observer:i}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let s=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.namespace in r)throw new Error(`The ${s} prototype already has a "${e.api.namespace}" API!`);Object.defineProperty(r,e.api.namespace,{get:function(){return i.proxy(gi.call(t,this))}})})}function ka(e){let t=this,{webqit:{Observer:i,realdom:r,oohtml:{configs:s},DOMNamingContext:n}}=t,a=["aria-owns","aria-controls","aria-labelledby","aria-describedby","aria-flowto"],o=["for","list","form","aria-activedescendant","aria-details","aria-errormessage"],u=[e.attr.lid,...a,...o],c={id:"id",for:"htmlFor","aria-owns":"ariaOwns","aria-controls":"ariaControls","aria-labelledby":"ariaLabelledBy","aria-describedby":"ariaDescribedBy","aria-flowto":"ariaFlowto","aria-activedescendant":"ariaActiveDescendant","aria-details":"ariaDetails","aria-errormessage":"ariaErrorMessage"},l=Hs(e),f=(y,_,S)=>{if(!ar(y,_)&&A(y,"attrOriginals").has(_))return A(y,"attrOriginals").get(_);let O=S();return ar(y,_)?O:O&&O.split(" ").map(P=>(P=P.trim())&&(_===e.attr.lid?l.uuidToId:l.uuidToLidref).call(l,P)).join(" ")},p=Object.getOwnPropertyDescriptor(t.Document.prototype,"getElementById");Object.defineProperty(t.Document.prototype,"getElementById",{...p,value(y){return this.querySelector(`#${y}`)}});for(let y of["querySelector","querySelectorAll"])for(nodeApi of[t.Document,t.Element]){let _=Object.getOwnPropertyDescriptor(nodeApi.prototype,y);Object.defineProperty(nodeApi.prototype,y,{..._,value(S){return _.value.call(this,cr.call(t,S,xi(gi.call(t,this))))}})}let m=Object.getOwnPropertyDescriptor(t.Element.prototype,"getAttribute");Object.defineProperty(t.Element.prototype,"getAttribute",{...m,value(y){let _=()=>m.value.call(this,y);return u.includes(y)&&!A(this,"lock").get(y)?f(this,y,_):_()}});let g=Object.getOwnPropertyDescriptor(t.Attr.prototype,"value");Object.defineProperty(t.Attr.prototype,"value",{...g,get(){let y=()=>g.get.call(this);return u.includes(this.name)?f(this.ownerElement,this.name,y):y()}});let b=Object.getOwnPropertyDescriptor(t.Node.prototype,"nodeValue");Object.defineProperty(t.Node.prototype,"nodeValue",{...b,get(){let y=()=>b.get.call(this);return this instanceof t.Attr&&u.includes(this.name)?f(this.ownerElement,this.name,y):y()}});for(let y of u){if(!(y in c))continue;let _=y==="for"?[t.HTMLLabelElement,t.HTMLOutputElement]:[t.Element];for(let S of _){let O=Object.getOwnPropertyDescriptor(S.prototype,c[y]);!O||Object.defineProperty(S.prototype,c[y],{...O,get(){return f(this,y,()=>O.get.call(this,y))}})}}e.attr.lid!=="id"&&Object.defineProperty(t.Element.prototype,e.attr.lid,{configurable:!0,enumerable:!0,get(){return this.getAttribute(e.attr.lid)},set(y){return this.setAttribute(e.attr.lid,y)}});let v=(y,_,S,O)=>Bs(y,_,()=>(typeof S=="function"&&(S=S()),O(S))),x=(y,_,S,O=null)=>{v(y,_,S,P=>{let D=_===e.attr.lid,H=O||pe.call(t,y,D),Q=xi(H);if(D){let Y=l.uuidToId(P);if(i.get(H,Y)!==y){let X=l.toUuid(Q,Y);X!==P&&y.setAttribute("id",X),i.set(H,Y,y)}}else{A(y,"attrOriginals").set(_,P);let Y=P.split(" ").map(X=>(X=X.trim())&&!l.isLidref(X)?X:l.toUuid(Q,X.replace(l.lidrefPrefix(),""))).join(" ");y.setAttribute(_,Y),A(H).set("idrefs",A(H).get("idrefs")||new Set),A(H).get("idrefs").add(y)}})},w=(y,_,S,O=null)=>{v(y,_,S,P=>{let D=_===e.attr.lid,H=O||pe.call(t,y,D);if(D){let Q=l.uuidToId(P);i.get(H,Q)===y&&i.deleteProperty(H,Q)}else{let Q=A(y,"attrOriginals").get(_);y.setAttribute(_,Q),A(H).get("idrefs").delete(y)}})};r.realtime(t.document).query(e.namespaceSelector,y=>{let _=(S,O,P,D)=>{if(!S.hasAttribute(O))return;let H=()=>S.getAttribute(O);w(S,O,H,P),S.isConnected&&x(S,O,A(S,"attrOriginals").get(O)||H,D)};y.exits.forEach(S=>{if(S.isConnected){let D=gi.call(t,S);for(let H of new Set([...Object.values(D),...A(D).get("idrefs")||[]]))for(let Q of u)_(H,Q,D)}let O=S[s.CONTEXT_API.api.contexts],P=O.find(n.kind);P&&O.detach(P)}),y.entrants.forEach(S=>{let O,P=pe.call(t,S,!0);for(let H of new Set([...Object.values(P),...A(P).get("idrefs")||[]]))if((O=pe.call(t,H,!0))!==P)for(let Q of u)_(H,Q,P,O);let D=S[s.CONTEXT_API.api.contexts];D.find(n.kind)||D.attach(new n)})},{live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(`[${u.map(y=>t.CSS.escape(y)).join("],[")}]`,y=>{let _={forID:new Map,forOther:new Map};for(let S of u){let O=S===e.attr.lid?_.forID:_.forOther;y.exits.forEach(P=>{if(!P.hasAttribute(S))return;let D=O.get(P);typeof D>"u"&&(D=(S===e.attr.lid?P.parentNode:P)?.closest?.(e.namespaceSelector)||P.getRootNode().host,O.set(P,D)),!(D&&!D.isConnected)&&w(P,S,()=>P.getAttribute(S))}),y.entrants.forEach(P=>{!P.hasAttribute(S)||x(P,S,()=>P.getAttribute(S))})}_.forID.clear(),_.forOther.clear()},{live:!0,subtree:"cross-roots",timing:"sync"}),r.realtime(t.document,"attr").observe(u,y=>{for(let _ of y)_.oldValue&&w(_.target,_.name,_.oldValue),_.value&&x(_.target,_.name,_.value)},{subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0});let C,E=()=>{if(!t.location.hash?.startsWith(`#${l.lidrefPrefix()}`))return;let y=t.location.hash?.substring(`#${l.lidrefPrefix()}`.length).split("/").map(S=>S.trim()).filter(S=>S)||[],_=y.reduce((S,O)=>S&&S[e.api.namespace][O],t.document);C&&e.target.className&&C.classList.toggle(e.target.className,!1),_&&_!==t.document&&(e.target.className&&_.classList.toggle(e.target.className,!0),e.target.eventName&&_.dispatchEvent(new t.CustomEvent(e.target.eventName)),e.target.scrolling&&y.length>1&&_.scrollIntoView(),C=_)};t.addEventListener("hashchange",E),r.ready(E)}function lr({advanced:e={},...t}){let{config:i,window:r}=rt.call(this,"scoped-js",t,{script:{retention:"retain",mimeTypes:"module|text/javascript|application/javascript",timing:"auto"},api:{scripts:"scripts"},advanced:li(e)});i.scriptSelector=(Array.isArray(i.script.mimeTypes)?i.script.mimeTypes:i.script.mimeTypes.split("|")).concat("").reduce((s,n)=>{let a=n?`[type="${r.CSS.escape(n)}"]`:":not([type])";return s.concat(`script${a}`)},[]).join(","),r.webqit.oohtml.Script={compileCache:[new Map,new Map],execute:Pa.bind(r,i)},Aa.call(r,i),Ia.call(r,i)}function Aa(e){let t=this,i=new Map;if(e.api.scripts in t.Element.prototype)throw new Error(`The "Element" class already has a "${e.api.scripts}" property!`);Object.defineProperty(t.Element.prototype,e.api.scripts,{get:function(){return i.has(this)||i.set(this,[]),i.get(this)}}),Object.defineProperties(t.HTMLScriptElement.prototype,{scoped:{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}},quantum:{configurable:!0,get(){return this.hasAttribute("quantum")},set(r){this.toggleAttribute("quantum",r)}}})}async function Pa(e,t){let i=this,{realdom:r}=i.webqit,s=di(t);if(!s)throw new Error("Argument must be a valid exec hash.");let{script:n,compiledScript:a,thisContext:o}=s;e.script.retention==="dispose"?n.remove():e.script.retention==="hidden"?n.textContent='"source hidden"':n.textContent=await a.toString();let u=n.scoped?o:n.getRootNode();A(u).has("scriptEnv")||A(u).set("scriptEnv",Object.create(null));let c=(await a.bind(o,A(u).get("scriptEnv"))).execute();n.quantum&&Object.defineProperty(n,"state",{value:c}),r.realtime(i.document).observe(n,()=>{n.quantum&&c.dispose(),o instanceof i.Element&&o[e.api.scripts]?.splice(o[e.api.scripts].indexOf(n,1))},{subtree:"cross-roots",timing:"sync",generation:"exits"})}function Ia(e){let t=this,{webqit:{oohtml:i,realdom:r}}=t;t.HTMLScriptElement.supports||(t.HTMLScriptElement.supports=n=>["text/javascript","application/javascript"].includes(n));let s=new WeakSet;r.realtime(t.document).query(e.scriptSelector,n=>{n.entrants.forEach(a=>{if(s.has(a))return;let o=Us.call(t,e,a);if(!o)return;s.add(a);let u=a.scoped?a.parentNode||n.target:a.type==="module"?void 0:t;a.scoped&&u[e.api.scripts].push(a);let c=Kt({script:a,compiledScript:o,thisContext:u});n.type==="query"||a.type&&!t.HTMLScriptElement.supports(a.type)||e.script.timing==="manual"?i.Script.execute(c):a.textContent=`webqit.oohtml.Script.execute( '${c}' );`})},{live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants",eventDetails:!0})}function Us(e,t){let i=this,{webqit:{oohtml:r,QuantumScript:s,AsyncQuantumScript:n,QuantumModule:a}}=i,o=(t._=t.textContent.trim())&&t._.startsWith("/*@oohtml*/if(false){")&&t._.endsWith("}/*@oohtml*/")?t._.slice(21,-12):t.textContent;if(!t.scoped&&!t.quantum&&!o.includes("quantum"))return;let u=Kt(o),c=r.Script.compileCache[t.quantum?0:1],l;if(!(l=c.get(u))){let{parserParams:f,compilerParams:p,runtimeParams:m}=e.advanced;l=new(t.type==="module"?a:s||n)(o,{exportNamespace:`#${t.id}`,fileName:`${i.document.url?.split("#")?.[0]||""}#${t.id}`,parserParams:{...f,quantumMode:t.quantum},compilerParams:p,runtimeParams:m}),c.set(u,l)}return l}function Ws(e){let t=this,{webqit:{oohtml:{configs:{SCOPED_JS:i}}}}=t;[...e?.querySelectorAll(i.scriptSelector)||[]].forEach(r=>{Us.call(t,i,r)})}function pr(e={}){let{config:t,window:i}=rt.call(this,"data-binding",e,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"}});({CONTEXT_API:t.CONTEXT_API,BINDINGS_API:t.BINDINGS_API,HTML_IMPORTS:t.HTML_IMPORTS}=i.webqit.oohtml.configs),t.attrSelector=`[${i.CSS.escape(t.attr.render)}]`;let r=(s,n)=>{let a=`starts-with(., "${s}")`,o=`substring(., string-length(.) - string-length("${n}") + 1) = "${n}"`;return`${a} and ${o}`};t.discreteBindingsSelector=`comment()[${r(t.tokens.tagStart,t.tokens.tagEnd)}]`,Oa.call(i,t)}function Oa(e){let t=this,{webqit:{realdom:i}}=t;i.realtime(t.document).query(`(${e.discreteBindingsSelector})`,r=>{zs.call(this,...r.exits),Ta.call(t,e,...r.entrants)},{live:!0,subtree:"cross-roots",timing:"sync"}),i.realtime(t.document).query(e.attrSelector,r=>{zs.call(this,...r.exits),Na.call(t,e,...r.entrants)},{live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0,staticSensitivity:!0})}function Qs(e,t){let{webqit:{realdom:i,Observer:r,DOMBindingsContext:s}}=this;if(A(t).has("data-binding"))return A(t).get("data-binding");let n=Object.create(null),a=new AbortController;n.$exec__=(u,c,...l)=>{let f=()=>{try{u[c](...l)}catch(p){console.error(`${p.message} at ${p.cause}`)}};i.schedule("write",f)},n.$assign__=(u,c,l)=>{let f=()=>{try{u[c]=l}catch(p){console.error(`${p.message} at ${p.cause}`)}};i.schedule("write",f)},r.intercept(n,{get:(u,c,l)=>{if(!(u.key in n)){let f={...s.createRequest(u.key),live:!0,signal:a.signal};t[e.CONTEXT_API.api.contexts].request(f,p=>{r.set(n,u.key,p)})}return l(n[u.key]??(u.key in globalThis?globalThis[u.key]:void 0))},has:(u,c,l)=>l(!0)});let o={scope:n,abortController:a,bindings:new Map};return A(t).set("data-binding",o),o}function zs(...e){for(let t of e){let i=t.nodeName==="#text"?t.parentNode:t,{bindings:r,abortController:s}=A(i).get("data-binding")||{};if(!r?.has(t))return;r.get(t).state.dispose(),r.get(t).signals?.forEach(n=>n.abort()),r.delete(t),r.size||(s.abort(),A(i).delete("data-binding"))}}function Gs(e,t){let i=e.tokens.tagStart.split("").map(c=>`\\${c}`).join(""),r=e.tokens.tagEnd.split("").map(c=>`\\${c}`).join(""),s=e.tokens.stateStart.split("").map(c=>c===" "?"(?:\\s+)?":`\\${c}`).join(""),n=e.tokens.stateEnd.split("").map(c=>`\\${c}`).join(""),a=`^${i}(.*?)(?:${s}(\\d+)${n}(?:\\s+)?)?${r}$`,[,o,u]=t.match(new RegExp(a));return{raw:t,expr:o,span:parseInt(u??0)}}async function Ta(e,...t){let i=this,r=t.reduce((s,n)=>{if(n.isBound)return s;let a=Gs(e,n.nodeValue),o=n;if(a.span){if(o=n.nextSibling,o?.nodeName!=="#text"||o.nodeValue.length<a.span)return s;o.nodeValue.length>a.span&&o.splitText(a.span)}else o=n.ownerDocument.createTextNode(""),n.after(o);o.isBound=!0;let u=n;return i.webqit.env!=="server"&&(u.remove(),u=null),s.concat({textNode:o,template:a,anchorNode:u})},[]);for(let{textNode:s,template:n,anchorNode:a}of r){let o=Ks.call(i,e,n.expr),{scope:u,bindings:c}=Qs.call(this,e,s.parentNode);Object.defineProperty(s,"$oohtml_internal_databinding_anchorNode",{value:a,configurable:!0});try{c.set(s,{state:await(await o.bind(s,u)).execute()})}catch(l){console.log(l)}}}var hr=new Map;function Ks(e,t){if(hr.has(t))return hr.get(t);let i=`let content = ((${t}) ?? '') + '';`;i+="$assign__(this, 'nodeValue', content);",i+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${e.tokens.tagStart}${de(t)}${e.tokens.stateStart}" + content.length + "${e.tokens.stateEnd} ${e.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:r}}=this,s=new r(i);return hr.set(t,s),s}async function Na(e,...t){for(let i of t){let r=Xs.call(this,e,i.getAttribute(e.attr.render)),{scope:s,bindings:n}=Qs.call(this,e,i),a=[];Object.defineProperty(i,"$oohtml_internal_databinding_signals",{value:a,configurable:!0});try{n.set(i,{signals:a,state:await(await r.bind(i,s)).execute()})}catch(o){console.log(o)}}}var fr=new Map;function Xs(e,t){if(fr.has(t))return fr.get(t);let i={},r=he(t,";").map(a=>{let[o,u]=he(a,":").map(m=>m.trim()),c=o[0],l=o.slice(1).trim(),f=`(${u})`,p=`(${f} ?? '')`;if(c==="&")return l.startsWith("--")?`$exec__(this.style, 'setProperty', "${de(l)}", ${p});`:`$assign__(this.style, "${de(l)}", ${p});`;if(c==="%")return`$exec__(this.classList, 'toggle', "${de(l)}", !!${f});`;if(c==="~")return l.startsWith("?")?`$exec__(this, 'toggleAttribute', "${de(l.substring(1).trim())}", !!${f});`:`$exec__(this, 'setAttribute', "${de(l)}", ${p});`;if(c==="@"){if(i[l])throw new Error(`Duplicate binding: ${o}.`);if(i[l]=!0,l==="text")return`$assign__(this, 'textContent', ${p});`;if(l==="html")return`$exec__(this, 'setHTML', ${p});`;if(l==="items"){let[m,g]=he(u,"/");if(!g)throw new Error(`Invalid ${c}items spec: ${a}; no import specifier.`);let[b,v,x,w]=m.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!b)throw new Error(`Invalid ${c}items spec: ${a}.`);if(v.startsWith("(")?v=v.trim().slice(1,-1).split(",").map(E=>E.trim()):v=[v],v.length>(x==="in"?3:2))throw new Error(`Invalid ${c}items spec: ${a}.`);let C=x==="in"?v[2]:v[1]||"$index__";return`
|
|
15
|
+
}`,u.quantumMode=!1}else if(!["script","async-script"].includes(e))throw new Error(`Unrecognized sourceType specified: "${e}".`);c.sourceType=e,u.inBrowser=f,c.base64=p&&f&&"export default async function(%0) {%1}";let m=t(i,{parserParams:u,compilerParams:c});if(m instanceof Promise&&!["async-function","async-script","module"].includes(e))throw new Error("Parse-compile can only return a Promise for sourceTypes: async-function, async-script, module.");return l.sourceType=e,l.inBrowser=f,l.exportNamespace=a,l.fileName=o,nt(m,g=>{let b=["function","async-function"].includes(e);return nt(((x,w)=>{if(l.compileFunction)return l.compileFunction(w.toString(),[x]);if(c.base64){let C=`data:text/javascript;base64,${w.toString("base64")}`;return(()=>import(C).then(y=>y.default))()}return new(p?async function(){}.constructor:Function)(x,w.toString())})(g.identifier+"",g),x=>{let w=(C,E=s)=>{let y=x;C&&(y=y.bind(C));let _="global",S=new et(void 0,_,globalThis);return(e.endsWith("script")||E)&&(_="env",S=new et(S,_,E)),e==="module"&&(_="module",S=new et(S,_)),typeof C<"u"&&(S=new et(S,"this",{this:C})),new zt(void 0,_,{...l,originalSource:g.originalSource,quantumMode:g.isQuantumProgram},S,y)};return b?w().execute():{createRuntime:w,compilation:g}})})}var Qt=class{constructor(...t){let i=this.constructor,r=typeof t[t.length-1]=="object"?t.pop():{},s=t.pop()||"";this.$program=Me(i.sourceType,i.parseCompileCallback,s,r)}execute(){return nt(this.$program,({createRuntime:t})=>t().execute())}bind(t,i=void 0){return nt(this.$program,({createRuntime:r})=>r(t,i))}toString(t=!1){return nt(this.$program,({compilation:i})=>t?i+"":i.originalSource)}};function ha(...e){let{source:t,params:i}=Di(e);return Me("function",Fe,t,i)}function As(...e){let{source:t,params:i}=Di(e);return Me("async-function",Fe,t,i)}var fa=As,De=class extends Qt{};G(De,"sourceType","script"),G(De,"parseCompileCallback",Fe);var ce=class extends Qt{};G(ce,"sourceType","async-script"),G(ce,"parseCompileCallback",Fe);var pa=ce,Ve=class extends Qt{};G(Ve,"sourceType","module"),G(Ve,"parseCompileCallback",Fe);function Fe(e,t){let i=Cs(e,t.parserParams);return ks(i,t.compilerParams)}function qe(e,t,i={},r={}){t=W(t).slice();for(var s=e;!_t(s)&&!ge(s)&&t.length;){var n=t.shift();if(!(i.get?i.get(s,n):q(s)?n in s:s[n])){r.exists=!1;return}s=i.get?i.get(s,n):s[n]}return r.exists=!0,s}function er(e,t,i,r={},s={}){let n=(l,f,p)=>s.set?s.set(l,f,p):(at(t[o])&&L(l)?l.push(p):l[f]=p,!0);t=W(t);for(var a=e,o=0;o<t.length;o++)if(o<t.length-1){if(!a||!q(a)&&!F(a))return!1;var u=qe(a,t[o],s);if(!q(u)){if(s.buildTree===!1)return!1;u=F(s.buildTree)?s.buildTree(o):at(t[o+1])?[]:{};var c=n(a,t[o],u);if(!c)return!1}a=u}else return n(a,t[o],i)}var je=class{constructor(t,i=!1){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!i&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let i=await t();return this._synthesis--,i}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,i=!1){if(i)return new Promise(r=>{this.synthesis?r(t()):this.readCallbacks.add(()=>{r(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,i=!1){if(i)return new Promise(r=>{this.synthesis?r(t()):this.writeCallbacks.add(()=>{r(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,i,r){this.onread(()=>{let s=t(r),n=a=>{a!==void 0&&this.onwrite(()=>{let o=i(a,r),u=c=>{c!==void 0&&this.cycle(t,i,c)};o instanceof Promise?o.then(u):u(o)})};s instanceof Promise?s.then(n):n(s)})}};function Ps(e){return(e=e.trim())&&e.startsWith("(")&&e.endsWith(")")}function le(e,t,i,r=!0){i=(Array.isArray(i)?i:[i]).map(a=>(a+"").replace("(",r?"(.//":"(./")).join("|");let s=[],n;try{let a=e.document.evaluate(i,t,null,e.XPathResult.ANY_TYPE);for(;n=a.iterateNext();)s.push(n)}catch{}return s}function Is(e,t,i){i=(Array.isArray(i)?i:[i]).map(r=>(r+"").replace("(","(self::")).join("|");try{return e.document.evaluate(`${i}`,t,null,e.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function Be(e,t,i,r=!1){let s=t.getRootNode(),n=i.getRootNode();return s===n?t.contains(i):r&&n instanceof e.ShadowRoot?Be(e,t,n.host,r):!1}function Os(e,t="|"){return[...e].reduce(([i,r,s,n],a)=>!i&&r===0&&(Array.isArray(t)?t:[t]).includes(a)?[i,r,[""].concat(s)]:(!i&&["(","[","{"].includes(a)&&!s[0].endsWith("\\")&&r++,!i&&[")","]","}"].includes(a)&&!s[0].endsWith("\\")&&r--,['"',"'","`"].includes(a)&&!s[0].endsWith("\\")&&(i=i===a?null:i||a),s[0]+=a,[i,r,s]),[null,0,[""]])[2].reverse()}var ht=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Ps(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Os(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var Gt=class{constructor(t,i,r){this.context=t,this.namespace=i,this.window=t.defaultView||t.ownerDocument?.defaultView||r,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(F(t[0])?t=[[],...t]:V(t[0])&&!(t[0]instanceof ht)&&t.length===1?t=[[],void 0,t[0]]:V(t[1])&&t.length===2?t=[W(t[0],!1),void 0,t[1]]:t[0]=W(t[0],!1),t[0].filter(i=>typeof i!="string"&&!(i instanceof ht)&&!(i instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(i=>i instanceof ht?i:new ht(i)),t}registry(...t){return K("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,i,r){let{window:s}=this,n=Array.isArray(i)?i:[i],a=new Set;for(let[o,u]of this.registry(t))for(let[c,l]of u){let f=n.filter(p=>Be(s,c,p.target,o==="cross-roots")?["subtree","cross-roots"].includes(o)||p.target===c:!1);if(!!f.length){Array.isArray(i)||(f=f[0]);for(let p of l)a.add([p,f,c])}}for(let[o,u,c]of[...a].reverse())r.call(s,o,u,c)}disconnectables(t,...i){let r={disconnect(){i.forEach(s=>s&&F(s.disconnect)&&s.disconnect()||F(s)&&s()||V(s)&&(s.disconnected=!0))}};return t&&t.addEventListener("abort",()=>r.disconnect()),r}};var Mt=class extends Gt{constructor(t,...i){super(t,"attr",...i)}get(t,i=void 0,r={}){let s=typeof t=="string"||t instanceof ht;[t=[],i=void 0,r={}]=this.resolveArgs(arguments);let{context:n}=this,a=Ls(n,t);if(!i)return a;let o=r.lifecycleSignals&&this.createSignalGenerator();if(s)for(let u of a){let c=o?.generate()||{};i(u,c,n)}else{let u=o?.generate()||{};i(a,u,n)}if(r.live){o&&(r={...r,signalGenerator:o});let u=this.observe(s?t[0]:t,i,{newValue:!0,...r});return this.disconnectables(r.signal,u)}}observe(t,i,r={}){let s=typeof t=="string"||t instanceof ht;if([t=[],i,r={}]=this.resolveArgs(arguments),["sync","intercept"].includes(r.timing))return this.observeSync(s?t[0]:t,i,r);if(r.timing&&r.timing!=="async")throw new Error(`Timing option "${r.timing}" invalid.`);let{context:n,window:a,webqit:o}=this;r.eventDetails&&!o.realdom.attrInterceptionHooks?.intercepting&&Ns.call(a,"intercept",()=>{});let u=new a.MutationObserver(p=>{p=$s(p).map(m=>Rs.call(a,m)),Ts.call(a,f,p,n)}),c={attributes:!0,attributeOldValue:r.oldValue,subtree:r.subtree&&!0};t.length&&(c.attributeFilter=t.map(p=>p+"")),u.observe(n,c);let l=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),f={context:n,spec:t,callback:i,params:r,atomics:new Map,originalFilterIsString:s,signalGenerator:l,disconnectable:u};return this.disconnectables(r.signal,u,l)}observeSync(t,i,r={}){let s=typeof t=="string"||t instanceof ht;[t,i,r={}]=this.resolveArgs(arguments);let{context:n,window:a}=this;if(r.timing&&!["sync","intercept"].includes(r.timing))throw new Error(`Timing option "${r.timing}" invalid.`);let o=r.timing==="intercept"?"intercept":"sync",u=r.subtree==="cross-roots"?"cross-roots":r.subtree?"subtree":"children";this.registry(o).size||Ns.call(a,o,g=>{this.forEachMatchingContext(o,g,Ts)});let c={disconnect(){m.delete(f),m.size||p.delete(n)}},l=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),f={context:n,spec:t,callback:i,params:r,atomics:new Map,originalFilterIsString:s,signalGenerator:l,disconnectable:c},p=this.registry(o,u);p.has(n)||p.set(n,new Set);let m=p.get(n);return m.add(f),this.disconnectables(r.signal,c,l)}};function $s(e){return e.reduce((t,i,r)=>t[r-1]?.attributeName===i.attributeName||K(i.target,"internalAttrInteractions").get(i.attributeName)?t:t.concat(i),[])}function Ts(e,t){let{context:i,spec:r,callback:s,params:n,atomics:a,originalFilterIsString:o,signalGenerator:u}=e,c=r.map(p=>p+"");if(n.atomic&&!a.size?t=Ls(i,r,t):n.timing!=="async"&&r.length&&(t=t.filter(p=>c.includes(p.name))),!t.length)return;n.newValue===null&&n.oldValue===null&&n.eventDetails||(t=t.map(p=>{let m;return n.eventDetails||({event:m,...p}=p),!n.oldValue&&"oldValue"in p&&({oldValue:m,...p}=p),!n.newValue&&"value"in p?{value:m,...p}=p:n.newValue&&typeof p.value>"u"&&(p={...p,value:fi(p.target,p.name,()=>p.target.getAttribute(p.name))}),p})),n.atomic&&(t.forEach(p=>a.set(p.name,p)),t=Array.from(a.entries()).map(([,p])=>p));let l=o?t[0]:t,f=u?.generate()||{};s(l,f,i)}function fi(e,t,i){let r=K(e,"internalAttrInteractions").get(t);K(e,"internalAttrInteractions").set(t,!0);let s=i();return K(e,"internalAttrInteractions").set(t,r),s}function Ls(e,t,i=[]){let r={event:null,type:"attribute"};return t.length?t.map(n=>(n=n+"",i.find(a=>a.name===n)||{target:e,name:n,value:fi(e,n,()=>e.getAttribute(n)),...r})):Array.from(e.attributes).map(n=>i.find(a=>a.name===n.nodeName)||{target:e,name:n.nodeName,value:fi(e,n.nodeName,()=>n.nodeValue),...r})}function Rs({target:e,attributeName:t,value:i,oldValue:r}){let a=(this.webqit.realdom.attrInterceptionRecords?.get(e)||{})[t]?.[0]||"mutation";return{target:e,name:t,value:i,oldValue:r,type:"observation",event:a}}function Ns(e,t){let i=this,{webqit:r,document:s,Element:n}=i;r.realdom.attrInterceptionHooks||Object.defineProperty(r.realdom,"attrInterceptionHooks",{value:new Map}),r.realdom.attrInterceptionHooks.has(e)||r.realdom.attrInterceptionHooks.set(e,new Set),r.realdom.attrInterceptionHooks.get(e).add(t);let a=()=>r.realdom.attrInterceptionHooks.get(e).delete(t);if(r.realdom.attrInterceptionHooks?.intercepting)return a;console.warn("Attr mutation APIs are now being intercepted."),r.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(r.realdom,"attrInterceptionRecords",{value:new Map});let o=(l,f)=>{r.realdom.attrInterceptionRecords.has(l.target)||r.realdom.attrInterceptionRecords.set(l.target,{});let p=r.realdom.attrInterceptionRecords.get(l.target);if(p[l.name]=p[l.name]||[],p[l.name].unshift(l.event),K(l.target,"internalAttrInteractions").get(l.name))return f();r.realdom.attrInterceptionHooks.get("intercept")?.forEach(g=>g([l]));let m=f();return r.realdom.attrInterceptionHooks.get("sync")?.forEach(g=>g([l])),m};new i.MutationObserver(l=>{l=l.filter(f=>!(i.webqit.realdom.attrInterceptionRecords?.get(f.target)||{})[f.attributeName]?.shift()),l=$s(l).map(f=>Rs.call(i,f)),l.length&&(r.realdom.attrInterceptionHooks.get("intercept")?.forEach(f=>f(l)),r.realdom.attrInterceptionHooks.get("sync")?.forEach(f=>f(l)))}).observe(s,{attributes:!0,subtree:!0,attributeOldValue:!0});let c=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{c[l]=n.prototype[l],n.prototype[l]=function(...f){let p,m=fi(this,f[0],()=>this.getAttribute(f[0]));["setAttribute","toggleAttribute"].includes(l)&&(p=f[1]),l==="toggleAttribute"&&p===void 0&&(p=m===null);let g={target:this,name:f[0],value:p,oldValue:m,type:"interception",event:[this,l]};return o(g,()=>c[l].call(this,...f))}}),a}var He=class extends Gt{constructor(t,...i){super(t,"tree",...i)}attr(t,i=void 0,r={}){let{context:s,window:n}=this;return new Mt(s,n).get(...arguments)}query(t,i=void 0,r={}){[t,i=void 0,r={}]=this.resolveArgs(arguments);let{context:s}=this,n=new Map,a=c=>(n.has(c)||n.set(c,{target:c,entrants:[],exits:[],type:"query",event:null}),n.get(c));if(!r.generation||r.generation==="entrants"){if(!t.length)[...s.children].forEach(c=>a(s).entrants.push(c));else if(t.every(c=>c.type==="selector")){let[c,l]=t.reduce(([p,m],g)=>g.kind==="xpath"?[p,m.concat(g)]:[p.concat(g),m],[[],[]]),f=[];r.subtree?(c.length&&f.push(...s.querySelectorAll(c.join(","))),l.length&&f.push(...le(this.window,s,l))):(c.length&&f.push(...[...s.children].filter(p=>p.matches(c))),l.length&&f.push(...le(this.window,s,l,!1))),f.forEach(p=>a(p.parentNode||s).entrants.push(p))}}if(!i)return n;let o={disconnected:!1},u=i&&r.lifecycleSignals&&this.createSignalGenerator();for(let[,c]of n){if(o.disconnected)break;let l=u?.generate()||{};i(c,l,s)}if(r.live){u&&(r={...r,signalGenerator:u});let c=this.observe(t,i,r);return this.disconnectables(r.signal,o,c)}return this.disconnectables(r.signal,o,u)}children(t,i=void 0,r={}){return[t,i=void 0,r={}]=this.resolveArgs(arguments),this.query(t,i,{...r,subtree:!1})}subtree(t,i=void 0,r={}){return[t,i=void 0,r={}]=this.resolveArgs(arguments),this.query(t,i,{...r,subtree:!0})}observe(t,i,r={}){if([t,i,r={}]=this.resolveArgs(arguments),["sync","intercept"].includes(r.timing))return this.observeSync(t,i,r);if(r.timing&&r.timing!=="async")throw new Error(`Timing option "${r.timing}" invalid.`);let{context:s,window:n,webqit:a,document:o}=this;r.eventDetails&&(a.realdom.domInterceptionRecordsAlwaysOn=!0),(o.readyState==="loading"||a.realdom.domInterceptionRecordsAlwaysOn)&&!a.realdom.domInterceptionHooks?.intercepting&&Vs.call(n,"sync",()=>{});let u=new n.MutationObserver(f=>f.forEach(p=>{rr.call(n,l,Ds.call(n,p),s)}));u.observe(s,{childList:!0,subtree:r.subtree&&!0});let c=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),l={context:s,spec:t,callback:i,params:r,signalGenerator:c,disconnectable:u};if(r.staticSensitivity){let f=Ms.call(n,l);return this.disconnectables(r.signal,u,c,f)}return this.disconnectables(r.signal,u,c)}observeSync(t,i,r={}){[t,i,r={}]=this.resolveArgs(arguments);let{context:s,window:n}=this;if(r.timing&&!["sync","intercept"].includes(r.timing))throw new Error(`Timing option "${r.timing}" invalid.`);let a=r.timing==="intercept"?"intercept":"sync",o=r.subtree==="cross-roots"?"cross-roots":r.subtree?"subtree":"children";this.registry(a).size||Vs.call(n,a,g=>{this.forEachMatchingContext(a,g,rr)});let u=new n.MutationObserver(g=>g.forEach(b=>{Array.isArray((b=Ds.call(n,b)).event)||rr.call(n,f,b,s)}));u.observe(s,{childList:!0,subtree:r.subtree&&!0});let c={disconnect(){u.disconnect(),m.delete(f),m.size||p.delete(s)}},l=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),f={context:s,spec:t,callback:i,params:r,signalGenerator:l,disconnectable:c},p=this.registry(a,o);p.has(s)||p.set(s,new Set);let m=p.get(s);if(m.add(f),r.staticSensitivity){let g=Ms.call(n,f);return this.disconnectables(r.signal,c,l,g)}return this.disconnectables(r.signal,c,l)}track(t,i,r={}){return r={subtree:!0,...r},this.observe(t,s=>{s.entrants.length&&i(!0,Array.isArray(t)?s.entrants:s.entrants[0]),s.exits.length&&i(!1,Array.isArray(t)?s.exits:s.exits[0])},r)}};function Ms(e){let t=this,{context:i,spec:r,callback:s,params:n,signalGenerator:a}=e,o=r.filter(m=>m.kind==="css"),u=m=>m.match(/\.([\w-]+)/g)?.length?["class"]:[],c=m=>m.match(/#([\w-]+)/g)?.length?["id"]:[],l=m=>[...m.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(g=>g[1]).concat(u(m)).concat(c(m));if(!(e.$attrs=Array.from(new Set(o.filter(m=>(m+"").includes("[")).reduce((m,g)=>m.concat(l(g+"")),[])))).length)return;let f=new Set,p=new Set;return f.push=m=>(p.delete(m),f.add(m)),p.push=m=>(f.delete(m),p.add(m)),e.$deliveryCache={entrants:f,exits:p},new Mt(i,t).observe(e.$attrs,m=>{let g=new Map,b=w=>(g.has(w)||g.set(w,{target:w,entrants:[],exits:[],type:"static",event:null}),g.get(w)),v=new WeakMap,x=w=>(v.has(w)||v.set(w,o.some(C=>w.matches(C+""))),v.get(w));for(let w of m)["entrants","exits"].forEach(C=>{n.generation&&C!==n.generation||e.$deliveryCache[C].has(w.target)||(C==="entrants"?!x(w.target):x(w.target))||(e.$deliveryCache[C].push(w.target),b(w.target)[C].push(w.target),b(w.target).event=w.event)});for(let[,w]of g){let C=a?.generate()||{};s(w,C,i)}},{subtree:n.subtree,timing:n.timing,eventDetails:n.eventDetails})}function rr(e,t){let{context:i,spec:r,callback:s,params:n,signalGenerator:a,$deliveryCache:o}=e,u={...t,entrants:[],exits:[]};if(n.eventDetails||delete u.event,["entrants","exits"].forEach(l=>{if(!(n.generation&&l!==n.generation)&&(r.length?u[l]=xa.call(this,r,n.subtree==="cross-roots",t[l],t.event!=="parse"):u[l]=[...t[l]],!!o))for(let f of u[l])o[l].push(f)}),!u.entrants.length&&!u.exits.length)return;let c=a?.generate()||{};s(u,c,i)}function xa(e,t,i,r){i=Array.isArray(i)?i:[...i];let s=(n,a)=>{if(a.type==="selector"){let o=a.isXpathAttr?[]:n.filter(u=>a.kind==="xpath"?Is(this,u,a+""):u.matches&&u.matches(a+""));if((r||a.isXpathAttr)&&(o=n.reduce((u,c)=>a.kind==="xpath"?[...u,...le(this,c,a,r)]:c.querySelectorAll?[...u,...c.querySelectorAll(a+"")]:u,o)),o.length)return o}else if(n.includes(a.content)||r&&n.some(o=>Be(this,o,a.content,t)))return[a.content]};return i.$$searchCache||(i.$$searchCache=new Map),e.reduce((n,a)=>{let o;return i.$$searchCache.has(a.content)?o=i.$$searchCache.get(a.content):(o=s(i,a)||[],a.type==="instance"&&i.$$searchCache.set(a.content,o)),n.concat(o)},[])}function Ds({target:e,addedNodes:t,removedNodes:i}){let r=this,s;return s=W(t).reduce((n,a)=>n||r.webqit.realdom.domInterceptionRecords?.get(a),null),s=W(i).reduce((n,a)=>n||r.webqit.realdom.domInterceptionRecords?.get(a),s),s=s||r.document.readyState==="loading"&&"parse"||"mutation",{target:e,entrants:t,exits:i,type:"observation",event:s}}function Vs(e,t){let i=this,{webqit:r,document:s,Node:n,CharacterData:a,Element:o,HTMLElement:u,HTMLTemplateElement:c,DocumentFragment:l}=i;r.realdom.domInterceptionHooks||Object.defineProperty(r.realdom,"domInterceptionHooks",{value:new Map}),r.realdom.domInterceptionNoRecurse||Object.defineProperty(r.realdom,"domInterceptionNoRecurse",{value:new Map}),r.realdom.domInterceptionHooks.has(e)||r.realdom.domInterceptionHooks.set(e,new Set),r.realdom.domInterceptionHooks.get(e).add(t);let f=()=>r.realdom.domInterceptionHooks.get(e).delete(t);if(r.realdom.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),r.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(r.realdom,"domInterceptionRecords",{value:new Map});let p=(x,w,C)=>{r.realdom.domInterceptionNoRecurse.set(x,w);let E=C();return r.realdom.domInterceptionNoRecurse.delete(x),E},m=(x,w)=>{x.entrants.concat(x.exits).forEach(E=>{clearTimeout(r.realdom.domInterceptionRecords.get(E)?.timeout),r.realdom.domInterceptionRecords.set(E,x.event);let y=setTimeout(()=>{r.realdom.domInterceptionRecords.delete(E)},0);Object.defineProperty(x.event,"timeout",{value:y,configurable:!0})}),r.realdom.domInterceptionHooks.get("intercept")?.forEach(E=>E(x));let C=w();return r.realdom.domInterceptionHooks.get("sync")?.forEach(E=>E(x)),C},g={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},b={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(g).reduce((x,w)=>x.concat(w),[])).forEach(x=>{Object.keys(g).forEach(E=>{if(!g[E].includes(x))return;let y=Object.getOwnPropertyDescriptor(i[E].prototype,x);!y||(Object.defineProperty(i[E].prototype,x,"value"in y?{...y,value:w}:{...y,set:C}),b[E][x]=y)});function w(...E){let y=Object.keys(b).find(Y=>this instanceof i[Y]&&x in b[Y]),_=b[y],S=()=>_[x].value.call(this,...E);if(r.realdom.domInterceptionNoRecurse.get(this)===x)return S();let O=[],P=[],D=this;["insertBefore"].includes(x)?P=[E[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(x)?(P=[E[1]],["beforebegin","afterend"].includes(E[0])&&(D=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(x)?(O=[...this.childNodes],P=x==="replaceChildren"?[...E]:[E[0]]):["replaceWith","remove"].includes(x)?(O=[this],P=x==="replaceWith"?[...E]:[],D=this.parentNode):["replaceChild"].includes(x)?(O=[E[1]],P=[E[0]]):["removeChild"].includes(x)?O=[...E]:(P=[...E],["before","after"].includes(x)&&(D=this.parentNode));let H=x;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(x)){let Y=this.nodeName;if(x==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(E[0])){if(!this.parentNode)return _[x].value.call(this,...E);Y=this.parentNode.nodeName}let X=s.createElement(Y);_.setHTMLUnsafe.value.call(X,P[0],x==="setHTMLUnsafe"?E[1]:{}),P=[...X.childNodes],x==="insertAdjacentHTML"?(H="insertAdjacentElement",E[1]=new l,p(E[1],"append",()=>E[1].append(...X.childNodes))):(H="replaceChildren",E=[...X.childNodes])}return m({target:D,entrants:P,exits:O,type:"interception",event:[this,x]},()=>_[H].value.call(this,...E))}function C(E){let y=Object.keys(b).find(Q=>this instanceof i[Q]&&x in b[Q]),_=b[y],S=()=>_[x].set.call(this,E);if(this instanceof HTMLScriptElement||r.realdom.domInterceptionNoRecurse.get(this)===x)return S();let O=[],P=[],D=this;if(["outerHTML","outerText"].includes(x)?(O=[this],D=this.parentNode):this instanceof c?(D=this.content,O=[...this.content.childNodes]):O=[...this.childNodes],["outerHTML","innerHTML"].includes(x)){let Q=this.nodeName;if(x==="outerHTML"){if(!this.parentNode)return S();Q=this.parentNode.nodeName}let Y=s.createElement(Q.includes("-")?"div":Q);if(p(Y,x,()=>Y[x]=E),P=this instanceof c?[...Y.content.childNodes]:[...Y.childNodes],this instanceof c&&this.hasAttribute("src")){let X=Jt=>Jt.reduce((vt,St)=>St instanceof HTMLScriptElement?vt.concat(St):St instanceof c?vt.concat(X([St.content])):(vt=vt.concat(X([...St.querySelectorAll?.("template")||[]].map(rn=>rn.content))),vt.concat(...St.querySelectorAll?.("script")||[])),[]);for(let Jt of X(P)){let vt=s.createElement("script");[...Jt.attributes].forEach(St=>vt.setAttribute(St.name,St.value)),vt.textContent=Jt.textContent,p(Jt,"replaceWith",()=>Jt.replaceWith(vt))}}x==="outerHTML"?(E=new l,p(E,"append",()=>E.append(...P)),S=()=>p(this,"replaceWith",()=>o.prototype.replaceWith.call(this,E))):this instanceof c?S=()=>p(this.content,"replaceChildren",()=>this.content.replaceChildren(...P)):S=()=>p(this,"replaceChildren",()=>o.prototype.replaceChildren.call(this,...P))}return m({target:D,entrants:P,exits:O,type:"interception",event:[this,x]},S)}}),f}function Fs(){ya.call(this),ba.call(this),wa.call(this)}function ya(){let e=this;e.CSS||(e.CSS={}),e.CSS.escape||(e.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function ba(){let e=this;"isConnected"in e.Node.prototype||Object.defineProperty(e.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function wa(){let e=this;e.Element.prototype.matches||(e.Element.prototype.matches=e.Element.prototype.matchesSelector||e.Element.prototype.mozMatchesSelector||e.Element.prototype.msMatchesSelector||e.Element.prototype.oMatchesSelector||e.Element.prototype.webkitMatchesSelector||function(t){for(var i=(this.document||this.ownerDocument).querySelectorAll(t),r=i.length;--r>=0&&i.item(r)!==this;);return r>-1})}function qs(){let e=this;if(e.webqit||(e.webqit={}),e.webqit.realdom)return e.webqit.realdom;e.webqit.realdom={},Fs.call(e),e.webqit.realdom.meta=(...i)=>va.call(e,...i),e.webqit.realdom.ready=(...i)=>sr.call(e,...i),e.webqit.realdom.realtime=(i,r="dom")=>{if(r==="dom")return new He(i,e);if(r==="attr")return new Mt(i,e)};let t=new je(e);return e.webqit.realdom.schedule=(i,...r)=>t[`on${i}`](...r),e.webqit.realdom.synthesizeWhile=(...i)=>t.synthesizeWhile(...i),e.webqit.realdom}function sr(...e){let t="interactive",i;ee(e[0])?(t=e[0],F(e[1])&&(i=e[1])):F(e[0])&&(i=e[0]);let r={interactive:["interactive","complete"],complete:["complete"]};if(!r[t])throw new Error(`Invalid ready-state timing: ${t}.`);let s=this;if(!i)return s.webqit.realdom.readyStatePromises||(s.webqit.realdom.readyStatePromises={interactive:new Promise(n=>sr.call(this,"interactive",n)),complete:new Promise(n=>sr.call(this,"complete",n))}),s.webqit.realdom.readyStatePromises[t];if(r[t].includes(s.document.readyState))return i(s);s.webqit.realdom.readyStateCallbacks||(s.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},s.document.addEventListener("readystatechange",()=>{let n=s.document.readyState;for(let a of s.webqit.realdom.readyStateCallbacks[n].splice(0))a(s)},!1)),s.webqit.realdom.readyStateCallbacks[t].push(i)}function va(e){let t=this,i={},r;return(r=t.document.querySelector(`meta[name="${e}"]`))&&(i=(r.content||"").split(";").filter(s=>s).reduce((s,n)=>{let a=n.split("=").map(o=>o.trim());return er(s,a[0].split("."),a[1]==="true"?!0:a[1]==="false"?!1:at(a[1])?parseInt(a[1]):a[1]),s},{})),{get name(){return e},get content(){return r.content},json(){return JSON.parse(JSON.stringify(i))}}}function pi(e,t){return typeof e!="string"?e:e.replace(/\w\S*/g,function(i){return i.charAt(0).toUpperCase()+(typeof t!==void 0&&t?i.substr(1).toLowerCase():i.substr(1))})}var A=(...e)=>K("oohtml",...e),U={};function rt(e,t,i){let r=this,s=qs.call(r);U.window=r,r.webqitConfig||(r.webqitConfig=s.meta("webqit").json()),r.webqit||(r.webqit={}),r.webqit.oohtml||(r.webqit.oohtml={}),r.webqit.oohtml.configs||(r.webqit.oohtml.configs={});let n=e.toUpperCase().replace("-","_");if(!r.webqit.oohtml.configs[n]){r.webqit.oohtml.configs[n]={};let a=r.webqit.oohtml.configs[n];ye(2,a,i,t,s.meta(e).json()),r.webqitConfig.prefix&&Object.keys(a).forEach(o=>{Object.keys(a[o]).forEach(u=>{o==="api"&&typeof a[o][u]=="string"?a[o][u]=`${r.webqitConfig.prefix}${pi(a[o][u])}`:["attr","elements"].includes(o)&&a[o][u]?.startsWith("data-")===!1&&(a[o][u]=`${r.webqitConfig.prefix}-${a[o][u]}`)})})}return{config:r.webqit.oohtml.configs[n],realdom:s,window:r}}function ar(e,t){return K(e,"internalAttrInteractions").get(t)}function Bs(e,t,i){let r=K(e,"internalAttrInteractions").get(t);K(e,"internalAttrInteractions").set(t,!0);let s=i();return K(e,"internalAttrInteractions").set(t,r),s}function he(e,t){return[...e].reduce(([i,r,s],n)=>!i&&r===0&&(Array.isArray(t)?t:[t]).includes(n)?[i,r,[""].concat(s)]:(!i&&["(","[","{"].includes(n)&&!s[0].endsWith("\\")&&r++,!i&&[")","]","}"].includes(n)&&!s[0].endsWith("\\")&&r--,['"',"'","`"].includes(n)&&!s[0].endsWith("\\")&&(i=i===n?null:i||n),s[0]+=n,[i,r,s]),[null,0,[""]])[2].reverse()}var Ea=()=>(0|Math.random()*9e6).toString(36),nr=new Map;function Kt(e){let t;return(t=nr.get(e))||(t=Ea(),nr.set(e,t)),t}function di(e){let t;return nr.forEach((i,r)=>{i===e&&(t=r)}),t}function mi(){let{window:e}=U,{webqit:t}=e;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class i extends e.Event{constructor(...s){let n=s.pop();if(typeof n!="function")throw new Error("Callback must be provided.");let a=s.pop();if(!a?.kind)throw new Error('"options.kind" must be specified.');let o=["contextrequest","contextclaim"],u=s.pop()||o[0];if(!o.includes(u))throw new Error(`Invalid event type. Must be one of: ${o.join(",")}`);let{kind:c,detail:l,targetContext:f,live:p,signal:m,diff:g,...b}=a;super(u,{...b,bubbles:b.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>n}),Object.defineProperty(this,"kind",{get:()=>c}),Object.defineProperty(this,"targetContext",{get:()=>f}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>p}),Object.defineProperty(this,"signal",{get:()=>m}),Object.defineProperty(this,"diff",{get:()=>g}),Object.defineProperty(this,"options",{get:()=>b}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(s){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===s)return;Object.defineProperty(this,"_prevValue",{value:s,configurable:!0})}return this.callback(s)}}return t.DOMContextRequestEvent=i,i}var Xt=class extends AbortController{constructor(t){super(),t(i=>{let{window:{webqit:{Observer:r}}}=U;r.defineProperty(this,"value",{value:i,configurable:!0,enumerable:!0})},this)}};var Yt=class extends Error{};var Ue=new Map,Dt=class{static instance(t){return A(t).get("contexts::instance")||new this(t)}constructor(t){A(t).get("contexts::instance")?.dispose(),A(t).set("contexts::instance",this);let i={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>i})}get[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(i=>typeof t[0]=="function"?t[0](i):i.constructor.kind===t[0]&&(t.length===1||i.detail===t[1]))}attach(t){if(!(t instanceof st))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new Yt(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new Xt((i,r)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(i):t[t.length-1]=i);let s;(s=t.find(u=>typeof u=="object"&&u))&&s.live&&(s.signal&&s.signal.addEventListener("abort",()=>r.abort()),t[t.indexOf(s)]={...s,signal:r.signal});let n=new(mi())(...t);n.meta.target=this["#"].host;let a=this["#"].host.getRootNode(),o=u=>{if(u.stopImmediatePropagation(),u.meta.target=u.target,!u.answered){if(Ue.get(a)||Ue.set(a,new Set),u.type==="contextrequest"&&u.live)Ue.get(a).add(u);else if(u.type==="contextclaim"){let c=new Set;return Ue.get(a).forEach(l=>{!this["#"].host.contains(l.target)||!u.detail.matchEvent(l)||(Ue.get(a).delete(l),c.add(l))}),u.respondWith(c)}}};a.addEventListener(n.type,o),this["#"].host.dispatchEvent(n),a.removeEventListener(n.type,o)})}};var or=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=U;return t}get name(){return[U.window.Document,U.window.ShadowRoot].some(t=>this.host instanceof t)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(!(t.detail instanceof or)||t.target===this.host)return;let i=new Set;if(this.subscriptions.forEach(r=>{!t.target.contains(r.target)||!t.detail.matchEvent(r)||(this.subscriptions.delete(r),this.unsubscribed(r),i.add(r))}),i.size)return t.respondWith(i)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:i}=Dt.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return i?.forEach(r=>{this.subscriptions.add(r),this.subscribed(r),this.handle(r)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(i=>{this.subscriptions.delete(i),this.unsubscribed(i);let{target:r}=i;r.dispatchEvent(i)}),this}},st=or;G(st,"kind");var fe=class extends st{static createRequest(t=null){let i=super.createRequest();if(t?.startsWith("@")){let[r,...s]=s.slice(1).split("/").map(n=>n.trim());i.targetContext=r,i.detail=s.join("/")}else i.detail=t;return i}get namespaceObj(){return this.host[this.configs.NAMESPACED_HTML.api.namespace]}handle(t){let{window:{webqit:{Observer:i}}}=U;if(t.meta.controller?.abort(),!(t.detail||"").trim())return t.respondWith(i.unproxy(this.namespaceObj));let r=(t.detail||"").split("/").map(s=>s.trim()).filter(s=>s);if(!r.length)return t.respondWith();r=r.join(`/${this.configs.NAMESPACED_HTML.api.namespace}/`)?.split("/")||[],t.meta.controller=i.reduce(this.namespaceObj,r,i.get,s=>{this.disposed||t.respondWith(s.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};G(fe,"kind","namespace");function ur(e={}){let{config:t,window:i}=rt.call(this,"namespaced-html",e,{attr:{namespace:"namespace",lid:"id"},api:{namespace:"namespace"},tokens:{lidrefPrefix:"~",lidrefSeparator:":"},target:{className:":target",eventName:":target",scrolling:!0}});t.lidSelector=`[${i.CSS.escape(t.attr.lid)}]`,t.namespaceSelector=`[${i.CSS.escape(t.attr.namespace)}]`,i.webqit.DOMNamingContext=fe,Ca.call(i,t),ka.call(i,t)}function Hs(e){let{lidrefPrefix:t,lidrefSeparator:i}=e.tokens;return{escape(r,s=1){return[...r].map(n=>/\w/.test(n)?n:s===2?`\\\\${n}`:`\\${n}`).join("")},lidrefPrefix(r=0){return r?this.escape(t,r):t},lidrefSeparator(r=0){return r?this.escape(i,r):i},isUuid(r,s=0){return r.startsWith(this.lidrefPrefix(s))&&r.includes(this.lidrefSeparator(s))},isLidref(r,s=0){return r.startsWith(this.lidrefPrefix(s))&&!r.includes(this.lidrefSeparator(s))},toUuid(r,s,n=0){return r.endsWith("-root")?s:`${this.lidrefPrefix(n)}${r}${this.lidrefSeparator(n)}${s}`},uuidToId(r,s=0){return this.isUuid(r)?r.split(this.lidrefSeparator(s))[1]:r},uuidToLidref(r,s=0){return this.isUuid(r)?`${this.lidrefPrefix(s)}${r.split(this.lidrefSeparator(s))[1]}`:r}}}function cr(e,t,i=null,r=0){let s=this,{webqit:{oohtml:{configs:{NAMESPACED_HTML:n}}}}=s,a=Hs(n),o=new RegExp(`${i?":scope|":""}#(${a.lidrefPrefix(r+1)})?([\\w]+${a.lidrefSeparator(r+1)})?((?:[\\w-]|\\\\.)+)`,"g"),[u,c]=he(e,",").reduce(([f,p],m)=>{let g,b;return m=m.replace(o,(v,x,w,C,E)=>{if(g||(g=[...m.matchAll(/(["'])(?:(?=(\\?))\2.)*?\1/g)]),g.some(O=>E>O.index&&E+v.length<O.index+O[0].length))return v;if(v===":scope")return b=!0,i;let y=x&&!w;if(x&&w)return`#${a.escape(v.replace("#",""),1)}`;if(y&&n.attr.lid==="id"&&t&&!t.endsWith("-root"))return`#${a.toUuid(t,C,1)}`;let S;return n.attr.lid==="id"?S=`:is(#${C},[id^="${a.lidrefPrefix(r)}"][id$="${a.lidrefSeparator(r)}${C}"])`:S=`:is(#${C},[${s.CSS.escape(n.attr.lid)}="${C}"])`,y?`:is(${S}):not(${i?i+" ":""}${n.namespaceSelector} *)`:S}),b?[f,p.concat(m)]:[f.concat(m),p]},[[],[]]),l;return i&&u.length?l=[u.length>1?`${i} :is(${u.join(", ")})`:`${i} ${u[0]}`,c.join(", ")].filter(f=>f).join(", "):l=[...u,...c].join(", "),l}function gi(e){let t=this;if(!A(e).has("namespace")){let i=Object.create(null);A(e).set("namespace",i);let r=[t.Document,t.ShadowRoot].some(s=>e instanceof s);Object.defineProperty(i,Symbol.toStringTag,{get(){return r?"RootNamespaceRegistry":"NamespaceRegistry"}})}return A(e).get("namespace")}function pe(e,t=!1){let i=this,{webqit:{oohtml:{configs:{NAMESPACED_HTML:r}}}}=i,s=[i.Document,i.ShadowRoot].some(n=>e instanceof n);return gi.call(i,s?e:(t?e.parentNode:e)?.closest?.(r.namespaceSelector)||e.getRootNode())}function xi(e){let t=Object.prototype.toString.call(e)==="[object RootNamespaceRegistry]";return(di(e)||Kt(e))+(t?"-root":"")}function Ca(e){let t=this,{webqit:{Observer:i}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let s=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.namespace in r)throw new Error(`The ${s} prototype already has a "${e.api.namespace}" API!`);Object.defineProperty(r,e.api.namespace,{get:function(){return i.proxy(gi.call(t,this))}})})}function ka(e){let t=this,{webqit:{Observer:i,realdom:r,oohtml:{configs:s},DOMNamingContext:n}}=t,a=["aria-owns","aria-controls","aria-labelledby","aria-describedby","aria-flowto"],o=["for","list","form","aria-activedescendant","aria-details","aria-errormessage"],u=[e.attr.lid,...a,...o],c={id:"id",for:"htmlFor","aria-owns":"ariaOwns","aria-controls":"ariaControls","aria-labelledby":"ariaLabelledBy","aria-describedby":"ariaDescribedBy","aria-flowto":"ariaFlowto","aria-activedescendant":"ariaActiveDescendant","aria-details":"ariaDetails","aria-errormessage":"ariaErrorMessage"},l=Hs(e),f=(y,_,S)=>{if(!ar(y,_)&&A(y,"attrOriginals").has(_))return A(y,"attrOriginals").get(_);let O=S();return ar(y,_)?O:O&&O.split(" ").map(P=>(P=P.trim())&&(_===e.attr.lid?l.uuidToId:l.uuidToLidref).call(l,P)).join(" ")},p=Object.getOwnPropertyDescriptor(t.Document.prototype,"getElementById");Object.defineProperty(t.Document.prototype,"getElementById",{...p,value(y){return this.querySelector(`#${y}`)}});for(let y of["querySelector","querySelectorAll"])for(nodeApi of[t.Document,t.Element]){let _=Object.getOwnPropertyDescriptor(nodeApi.prototype,y);Object.defineProperty(nodeApi.prototype,y,{..._,value(S){return _.value.call(this,cr.call(t,S,xi(gi.call(t,this))))}})}let m=Object.getOwnPropertyDescriptor(t.Element.prototype,"getAttribute");Object.defineProperty(t.Element.prototype,"getAttribute",{...m,value(y){let _=()=>m.value.call(this,y);return u.includes(y)&&!A(this,"lock").get(y)?f(this,y,_):_()}});let g=Object.getOwnPropertyDescriptor(t.Attr.prototype,"value");Object.defineProperty(t.Attr.prototype,"value",{...g,get(){let y=()=>g.get.call(this);return u.includes(this.name)?f(this.ownerElement,this.name,y):y()}});let b=Object.getOwnPropertyDescriptor(t.Node.prototype,"nodeValue");Object.defineProperty(t.Node.prototype,"nodeValue",{...b,get(){let y=()=>b.get.call(this);return this instanceof t.Attr&&u.includes(this.name)?f(this.ownerElement,this.name,y):y()}});for(let y of u){if(!(y in c))continue;let _=y==="for"?[t.HTMLLabelElement,t.HTMLOutputElement]:[t.Element];for(let S of _){let O=Object.getOwnPropertyDescriptor(S.prototype,c[y]);!O||Object.defineProperty(S.prototype,c[y],{...O,get(){return f(this,y,()=>O.get.call(this,y))}})}}e.attr.lid!=="id"&&Object.defineProperty(t.Element.prototype,e.attr.lid,{configurable:!0,enumerable:!0,get(){return this.getAttribute(e.attr.lid)},set(y){return this.setAttribute(e.attr.lid,y)}});let v=(y,_,S,O)=>Bs(y,_,()=>(typeof S=="function"&&(S=S()),O(S))),x=(y,_,S,O=null)=>{v(y,_,S,P=>{let D=_===e.attr.lid,H=O||pe.call(t,y,D),Q=xi(H);if(D){let Y=l.uuidToId(P);if(i.get(H,Y)!==y){let X=l.toUuid(Q,Y);X!==P&&y.setAttribute("id",X),i.set(H,Y,y)}}else{A(y,"attrOriginals").set(_,P);let Y=P.split(" ").map(X=>(X=X.trim())&&!l.isLidref(X)?X:l.toUuid(Q,X.replace(l.lidrefPrefix(),""))).join(" ");y.setAttribute(_,Y),A(H).set("idrefs",A(H).get("idrefs")||new Set),A(H).get("idrefs").add(y)}})},w=(y,_,S,O=null)=>{v(y,_,S,P=>{let D=_===e.attr.lid,H=O||pe.call(t,y,D);if(D){let Q=l.uuidToId(P);i.get(H,Q)===y&&i.deleteProperty(H,Q)}else{let Q=A(y,"attrOriginals").get(_);y.setAttribute(_,Q),A(H).get("idrefs")?.delete(y)}})};r.realtime(t.document).query(e.namespaceSelector,y=>{let _=(S,O,P,D)=>{if(!S.hasAttribute(O))return;let H=()=>S.getAttribute(O);w(S,O,H,P),S.isConnected&&x(S,O,A(S,"attrOriginals").get(O)||H,D)};y.exits.forEach(S=>{if(S.isConnected){let D=gi.call(t,S);for(let H of new Set([...Object.values(D),...A(D).get("idrefs")||[]]))for(let Q of u)_(H,Q,D)}let O=S[s.CONTEXT_API.api.contexts],P=O.find(n.kind);P&&O.detach(P)}),y.entrants.forEach(S=>{let O,P=pe.call(t,S,!0);for(let H of new Set([...Object.values(P),...A(P).get("idrefs")||[]]))if((O=pe.call(t,H,!0))!==P)for(let Q of u)_(H,Q,P,O);let D=S[s.CONTEXT_API.api.contexts];D.find(n.kind)||D.attach(new n)})},{live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(`[${u.map(y=>t.CSS.escape(y)).join("],[")}]`,y=>{let _={forID:new Map,forOther:new Map};for(let S of u){let O=S===e.attr.lid?_.forID:_.forOther;y.exits.forEach(P=>{if(!P.hasAttribute(S))return;let D=O.get(P);typeof D>"u"&&(D=(S===e.attr.lid?P.parentNode:P)?.closest?.(e.namespaceSelector)||P.getRootNode().host,O.set(P,D)),!(D&&!D.isConnected)&&w(P,S,()=>P.getAttribute(S))}),y.entrants.forEach(P=>{!P.hasAttribute(S)||x(P,S,()=>P.getAttribute(S))})}_.forID.clear(),_.forOther.clear()},{live:!0,subtree:"cross-roots",timing:"sync"}),r.realtime(t.document,"attr").observe(u,y=>{for(let _ of y)_.oldValue&&w(_.target,_.name,_.oldValue),_.value&&x(_.target,_.name,_.value)},{subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0});let C,E=()=>{if(!t.location.hash?.startsWith(`#${l.lidrefPrefix()}`))return;let y=t.location.hash?.substring(`#${l.lidrefPrefix()}`.length).split("/").map(S=>S.trim()).filter(S=>S)||[],_=y.reduce((S,O)=>S&&S[e.api.namespace][O],t.document);C&&e.target.className&&C.classList.toggle(e.target.className,!1),_&&_!==t.document&&(e.target.className&&_.classList.toggle(e.target.className,!0),e.target.eventName&&_.dispatchEvent(new t.CustomEvent(e.target.eventName)),e.target.scrolling&&y.length>1&&_.scrollIntoView(),C=_)};t.addEventListener("hashchange",E),r.ready(E)}function lr({advanced:e={},...t}){let{config:i,window:r}=rt.call(this,"scoped-js",t,{script:{retention:"retain",mimeTypes:"module|text/javascript|application/javascript",timing:"auto"},api:{scripts:"scripts"},advanced:li(e)});i.scriptSelector=(Array.isArray(i.script.mimeTypes)?i.script.mimeTypes:i.script.mimeTypes.split("|")).concat("").reduce((s,n)=>{let a=n?`[type="${r.CSS.escape(n)}"]`:":not([type])";return s.concat(`script${a}`)},[]).join(","),r.webqit.oohtml.Script={compileCache:[new Map,new Map],execute:Pa.bind(r,i)},Aa.call(r,i),Ia.call(r,i)}function Aa(e){let t=this,i=new Map;if(e.api.scripts in t.Element.prototype)throw new Error(`The "Element" class already has a "${e.api.scripts}" property!`);Object.defineProperty(t.Element.prototype,e.api.scripts,{get:function(){return i.has(this)||i.set(this,[]),i.get(this)}}),Object.defineProperties(t.HTMLScriptElement.prototype,{scoped:{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}},quantum:{configurable:!0,get(){return this.hasAttribute("quantum")},set(r){this.toggleAttribute("quantum",r)}}})}async function Pa(e,t){let i=this,{realdom:r}=i.webqit,s=di(t);if(!s)throw new Error("Argument must be a valid exec hash.");let{script:n,compiledScript:a,thisContext:o}=s;e.script.retention==="dispose"?n.remove():e.script.retention==="hidden"?n.textContent='"source hidden"':n.textContent=await a.toString();let u=n.scoped?o:n.getRootNode();A(u).has("scriptEnv")||A(u).set("scriptEnv",Object.create(null));let c=await(await a.bind(o,A(u).get("scriptEnv"))).execute();n.quantum&&Object.defineProperty(n,"state",{value:c}),r.realtime(i.document).observe(n,()=>{n.quantum&&c.dispose(),o instanceof i.Element&&o[e.api.scripts]?.splice(o[e.api.scripts].indexOf(n,1))},{subtree:"cross-roots",timing:"sync",generation:"exits"})}function Ia(e){let t=this,{webqit:{oohtml:i,realdom:r}}=t;t.HTMLScriptElement.supports||(t.HTMLScriptElement.supports=n=>["text/javascript","application/javascript"].includes(n));let s=new WeakSet;r.realtime(t.document).query(e.scriptSelector,n=>{n.entrants.forEach(a=>{if(s.has(a))return;let o=Us.call(t,e,a);if(!o)return;s.add(a);let u=a.scoped?a.parentNode||n.target:a.type==="module"?void 0:t;a.scoped&&u[e.api.scripts].push(a);let c=Kt({script:a,compiledScript:o,thisContext:u});n.type==="query"||a.type&&!t.HTMLScriptElement.supports(a.type)||e.script.timing==="manual"?i.Script.execute(c):a.textContent=`webqit.oohtml.Script.execute( '${c}' );`})},{live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants",eventDetails:!0})}function Us(e,t){let i=this,{webqit:{oohtml:r,QuantumScript:s,AsyncQuantumScript:n,QuantumModule:a}}=i,o=(t._=t.textContent.trim())&&t._.startsWith("/*@oohtml*/if(false){")&&t._.endsWith("}/*@oohtml*/")?t._.slice(21,-12):t.textContent;if(!o.trim().length)return;let u=Kt(o),c=r.Script.compileCache[t.quantum?0:1],l;if(!(l=c.get(u))){let{parserParams:f,compilerParams:p,runtimeParams:m}=e.advanced;l=new(t.type==="module"?a:s||n)(o,{exportNamespace:`#${t.id}`,fileName:`${i.document.url?.split("#")?.[0]||""}#${t.id}`,parserParams:{...f,quantumMode:t.quantum},compilerParams:p,runtimeParams:m}),c.set(u,l)}return l}function Ws(e){let t=this,{webqit:{oohtml:{configs:{SCOPED_JS:i}}}}=t;[...e?.querySelectorAll(i.scriptSelector)||[]].forEach(r=>{Us.call(t,i,r)})}function pr(e={}){let{config:t,window:i}=rt.call(this,"data-binding",e,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"}});({CONTEXT_API:t.CONTEXT_API,BINDINGS_API:t.BINDINGS_API,HTML_IMPORTS:t.HTML_IMPORTS}=i.webqit.oohtml.configs),t.attrSelector=`[${i.CSS.escape(t.attr.render)}]`;let r=(s,n)=>{let a=`starts-with(., "${s}")`,o=`substring(., string-length(.) - string-length("${n}") + 1) = "${n}"`;return`${a} and ${o}`};t.discreteBindingsSelector=`comment()[${r(t.tokens.tagStart,t.tokens.tagEnd)}]`,Oa.call(i,t)}function Oa(e){let t=this,{webqit:{realdom:i}}=t;i.realtime(t.document).query(`(${e.discreteBindingsSelector})`,r=>{zs.call(this,...r.exits),Ta.call(t,e,...r.entrants)},{live:!0,subtree:"cross-roots",timing:"sync"}),i.realtime(t.document).query(e.attrSelector,r=>{zs.call(this,...r.exits),Na.call(t,e,...r.entrants)},{live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0,staticSensitivity:!0})}function Qs(e,t){let{webqit:{realdom:i,Observer:r,DOMBindingsContext:s}}=this;if(A(t).has("data-binding"))return A(t).get("data-binding");let n=Object.create(null),a=new AbortController;n.$exec__=(u,c,...l)=>{let f=()=>{u[c](...l);try{}catch(p){console.error(`${p.message} at ${p.cause}`)}};i.schedule("write",f)},n.$assign__=(u,c,l)=>{let f=()=>{try{u[c]=l}catch(p){console.error(`${p.message} at ${p.cause}`)}};i.schedule("write",f)},r.intercept(n,{get:(u,c,l)=>{if(!(u.key in n)){let f={...s.createRequest(u.key),live:!0,signal:a.signal};t[e.CONTEXT_API.api.contexts].request(f,p=>{r.set(n,u.key,p)})}return l(n[u.key]??(u.key in globalThis?globalThis[u.key]:void 0))},has:(u,c,l)=>l(!0)});let o={scope:n,abortController:a,bindings:new Map};return A(t).set("data-binding",o),o}function zs(...e){for(let t of e){let i=t.nodeName==="#text"?t.parentNode:t,{bindings:r,abortController:s}=A(i).get("data-binding")||{};if(!r?.has(t))return;r.get(t).state.dispose(),r.get(t).signals?.forEach(n=>n.abort()),r.delete(t),r.size||(s.abort(),A(i).delete("data-binding"))}}function Gs(e,t){let i=e.tokens.tagStart.split("").map(c=>`\\${c}`).join(""),r=e.tokens.tagEnd.split("").map(c=>`\\${c}`).join(""),s=e.tokens.stateStart.split("").map(c=>c===" "?"(?:\\s+)?":`\\${c}`).join(""),n=e.tokens.stateEnd.split("").map(c=>`\\${c}`).join(""),a=`^${i}(.*?)(?:${s}(\\d+)${n}(?:\\s+)?)?${r}$`,[,o,u]=t.match(new RegExp(a));return{raw:t,expr:o,span:parseInt(u??0)}}async function Ta(e,...t){let i=this,r=t.reduce((s,n)=>{if(n.isBound)return s;let a=Gs(e,n.nodeValue),o=n;if(a.span){if(o=n.nextSibling,o?.nodeName!=="#text"||o.nodeValue.length<a.span)return s;o.nodeValue.length>a.span&&o.splitText(a.span)}else o=n.ownerDocument.createTextNode(""),n.after(o);o.isBound=!0;let u=n;return i.webqit.env!=="server"&&(u.remove(),u=null),s.concat({textNode:o,template:a,anchorNode:u})},[]);for(let{textNode:s,template:n,anchorNode:a}of r){let o=Ks.call(i,e,n.expr),{scope:u,bindings:c}=Qs.call(this,e,s.parentNode);Object.defineProperty(s,"$oohtml_internal_databinding_anchorNode",{value:a,configurable:!0});try{c.set(s,{state:await(await o.bind(s,u)).execute()})}catch(l){console.log(l)}}}var hr=new Map;function Ks(e,t){if(hr.has(t))return hr.get(t);let i=`let content = ((${t}) ?? '') + '';`;i+="$assign__(this, 'nodeValue', content);",i+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${e.tokens.tagStart}${de(t)}${e.tokens.stateStart}" + content.length + "${e.tokens.stateEnd} ${e.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:r}}=this,s=new r(i);return hr.set(t,s),s}async function Na(e,...t){for(let i of t){let r=Xs.call(this,e,i.getAttribute(e.attr.render)),{scope:s,bindings:n}=Qs.call(this,e,i),a=[];Object.defineProperty(i,"$oohtml_internal_databinding_signals",{value:a,configurable:!0});try{n.set(i,{signals:a,state:await(await r.bind(i,s)).execute()})}catch(o){console.log(o)}}}var fr=new Map;function Xs(e,t){if(fr.has(t))return fr.get(t);let i={},r=he(t,";").map(a=>{let[o,u]=he(a,":").map(m=>m.trim()),c=o[0],l=o.slice(1).trim(),f=`(${u})`,p=`(${f} ?? '')`;if(c==="&")return l.startsWith("--")?`$exec__(this.style, 'setProperty', "${de(l)}", ${p});`:`$assign__(this.style, "${de(l)}", ${p});`;if(c==="%")return`$exec__(this.classList, 'toggle', "${de(l)}", !!${f});`;if(c==="~")return l.startsWith("?")?`$exec__(this, 'toggleAttribute', "${de(l.substring(1).trim())}", !!${f});`:`$exec__(this, 'setAttribute', "${de(l)}", ${p});`;if(c==="#"){if(i[l])throw new Error(`Duplicate binding: ${o}.`);if(i[l]=!0,l==="text")return`$assign__(this, 'textContent', ${p});`;if(l==="html")return`$exec__(this, 'setHTMLUnsafe', ${p});`;if(l==="items"){let[m,g]=he(u,"/");if(!g)throw new Error(`Invalid ${c}items spec: ${a}; no import specifier.`);let[b,v,x,w]=m.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!b)throw new Error(`Invalid ${c}items spec: ${a}.`);if(v.startsWith("(")?v=v.trim().slice(1,-1).split(",").map(E=>E.trim()):v=[v],v.length>(x==="in"?3:2))throw new Error(`Invalid ${c}items spec: ${a}.`);let C=x==="in"?v[2]:v[1]||"$index__";return`
|
|
16
16
|
let $iteratee__ = ${w};
|
|
17
17
|
let $import__ = this.${e.HTML_IMPORTS.api.import}( ${g.trim()}, true );
|
|
18
18
|
this.$oohtml_internal_databinding_signals?.push( $import__ );
|
|
@@ -44,12 +44,12 @@ ${g}
|
|
|
44
44
|
}
|
|
45
45
|
$existing__.forEach( x => x.remove() );
|
|
46
46
|
$existing__.clear();
|
|
47
|
-
}`}return`
|
|
48
|
-
const handler =
|
|
47
|
+
}`}}if(c==="@")return`
|
|
48
|
+
const handler = event => ${u.startsWith("{")?u:f};
|
|
49
49
|
this.addEventListener( '${l}', handler );
|
|
50
50
|
const abort = () => this.removeEventListener( '${l}', handler );
|
|
51
51
|
this.$oohtml_internal_databinding_signals?.push( { abort } );
|
|
52
|
-
|
|
52
|
+
`;if(c==="$")return`$exec__(this, '${l}', ${f});`;if(a.trim())throw new Error(`Invalid binding: ${a}.`)}).join(`
|
|
53
53
|
`),{webqit:{QuantumModule:s}}=this,n=new s(r);return fr.set(t,n),n}var de=e=>e.replace(/"/g,'\\"');function Ys(e){let t=this,{webqit:{oohtml:{configs:{DATA_BINDING:i}}}}=t;le(t,e,`(${i.discreteBindingsSelector})`).forEach(r=>{let s=Gs(i,r.nodeValue);Ks.call(t,i,s.expr)}),(e?.matches(i.attrSelector)?[e]:[]).concat([...e?.querySelectorAll(i.attrSelector)||[]]).forEach(r=>{Xs.call(t,i,r.getAttribute(i.attr.render))})}var Ot=class extends st{static createRequest(t=null){let i=super.createRequest();if(t?.startsWith("@")){let[r,...s]=s.slice(1).split(".").map(n=>n.trim());i.targetContext=r,i.detail=s.join(".")}else i.detail=t;return i}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:i}}}=U;t.meta.controller=i.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],i.get,r=>{this.disposed||t.respondWith(r.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};G(Ot,"kind","bindings");function dr(e={}){let{config:t,window:i}=rt.call(this,"bindings-api",e,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});i.webqit.DOMBindingsContext=Ot,$a.call(i,t)}function Js(e,t){let i=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:s}}}}=i;if(!A(t).has("bindings")){let n=Object.create(null);A(t).set("bindings",n),r.observe(n,a=>{let o=Object.keys(n),u=t instanceof i.Document?t.documentElement:t,c=e.attr.bindingsreflection;o.length&&c&&u.setAttribute?u.setAttribute(e.attr.bindingsreflection,o.join(" ")):c&&u.setAttribute&&u.toggleAttribute(e.attr.bindingsreflection,!1);let l=t[s.api.contexts];for(let f of a)if(f.type==="delete"){let p=l.find(Ot.kind,f.key);p&&l.detach(p)}else l.find(Ot.kind,f.key)||l.attach(new Ot(f.key))})}return A(t).get("bindings")}function $a(e){let t=this,{webqit:{Observer:i}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let s=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.bind in r)throw new Error(`The ${s} prototype already has a "${e.api.bind}" API!`);if(e.api.bindings in r)throw new Error(`The ${s} prototype already has a "${e.api.bindings}" API!`);Object.defineProperty(r,e.api.bind,{value:function(n,a={}){return La.call(t,e,this,n,a)}}),Object.defineProperty(r,e.api.bindings,{get:function(){return i.proxy(Js.call(t,e,this))}})})}function La(e,t,i,{merge:r,diff:s,namespace:n}={}){let a=this,{webqit:{Observer:o}}=a,u=Js.call(this,e,t),c={diff:s,namespace:n},l=r?[]:o.ownKeys(u,c).filter(f=>!(f in i));return o.batch(u,()=>(l.length&&o.deleteProperties(u,l,c),o.set(u,i,c)),c)}var wt=class{static instance(t){return A(t).get("defsmanager::instance")||new this(t)}constructor(t,i=null,r=0){let{window:s}=U,{webqit:{realdom:n,oohtml:{configs:a}}}=s;A(t).get("defsmanager::instance")?.dispose(),A(t).set("defsmanager::instance",this),this.window=s,this.host=t,this.config=a.HTML_IMPORTS,this.parent=i,this.level=r,this.defs=Tt(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=n.realtime(this.host.content).children(o=>{this.expose(o.entrants,!0),this.expose(o.exits,!1)},{live:!0,timing:"sync"}),this.realtimeB=n.realtime(this.host).attr(["src","loading"],(...o)=>this.evaluateLoading(...o),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(t){if(["@","/","*","#"].some(i=>t.includes(i)))throw new Error(`The export ID "${t}" contains an invalid character.`)}expose(t,i){let{window:r}=U,{webqit:{Observer:s}}=r,n,a=this.defs["#"]||[];t.forEach(o=>{if(o.nodeType!==1)return;let u=o.matches(this.config.templateSelector),c=(o.getAttribute(u?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();i?(u&&c?new wt(o,this.host,this.level+1):(a.push(o),n=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(l=>l.call(this.window,o))})),c&&(this.validateDefId(c),s.set(this.defs,(!u&&"#"||"")+c,o))):(u&&c?wt.instance(o).dispose():(a=a.filter(l=>l!==o),n=!0),c&&s.deleteProperty(this.defs,(!u&&"#"||"")+c))}),n&&s.set(this.defs,"#",a)}evaluateLoading([t,i],{signal:r}){let{window:{webqit:{Observer:s}}}=U,n=(t.value||"").trim();if(!n)return;let a,o=l=>{if(!l)return a;a=l.then(()=>c.remove())},u=(i.value||"").trim(),c=s.intercept(this.defs,"get",async(l,f,p)=>(u==="lazy"&&o(this.load(n,!0)),await o(),p()),{signal:r});u!=="lazy"&&o(this.load(n))}load(t){let{window:i}=U;if(this.host.content.children.length)return Promise.resolve();if(this.fetchInFlight?.src===t)return this.fetchInFlight.request;this.fetchInFlight?.controller.abort();let r=new AbortController,s=(a,o)=>this.host.dispatchEvent(new i.CustomEvent(a,{detail:o})),n=i.fetch(t,{signal:r.signal,element:this.host}).then(a=>a.ok?a.text():Promise.reject(a.statusText)).then(a=>(this.host.innerHTML=a.trim(),s("load"),this.host)).catch(a=>(console.error(`Error fetching the bundle at "${t}": ${a.message}`),this.fetchInFlight=null,s("loaderror"),this.host));return this.fetchInFlight={src:t,request:n,controller:r},n}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=U,i=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim(),s=o=>{o.forEach(u=>{t.get(this.defs,u.key)===u.oldValue&&(["get","set","def"].includes(u.type)?t[u.type.replace("get","set")](this.defs,u.key,u.value):u.type==="delete"&&t.deleteProperty(this.defs,u.key))})},n=[],a=Tt(this.parent);return i&&n.push(t.reduce(a,[i,this.config.api.defs,1/0],t.get,s,{live:!0})),(r=r.split(" ").map(o=>o.trim()).filter(o=>o)).length&&n.push(t.get(a,r,s,{live:!0})),n}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(t=>t instanceof Promise?t.then(i=>i.abort()):t.abort()),Object.entries(this.defs).forEach(([t,i])=>{t.startsWith("#")||wt.instance(i).dispose()})}};var Nt=class extends st{static createRequest(t=null){let i=super.createRequest();if(t?.startsWith("/"))i.detail=t,i.targetContext=1/0;else if(t?.startsWith("@")){let[r,...s]=s.slice(1).split(/(?<=\w)(?=\/|#)/).map(n=>n.trim());i.targetContext=r,i.detail=s.join("")}else i.detail=t;return i}get localModules(){return Tt(this.host)}handle(t){let{window:{webqit:{Observer:i}}}=U;if(t.meta.controller?.abort(),(t.detail||"").trim()==="/")return t.respondWith(this.localModules);let r=(t.detail||"").split(/\/|(?<=\w)(?=#)/g).map(n=>n.trim()).filter(n=>n);if(!r.length)return t.respondWith();r=r.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/")||[];let s={live:t.live,signal:t.signal,descripted:!0};t.meta.controller=i.reduce(this.localModules,r,i.get,(n,{signal:a}={})=>{let o=Array.isArray(n)?n:n.value,u=Array.isArray(n)?n.length:n.value;if(!(!u&&this.host.isConnected===!1))return u||!this.contextModules?(t._isValidLocalResult=u,t.respondWith(o)):i.reduce(this.contextModules,r,i.get,c=>(t._currentSource="context",t.respondWith(Array.isArray(c)?c:c.value)),{...s,signal:a})},{lifecycleSignals:!0,...s})}unsubscribed(t){t.meta.controller?.abort()}realtimeSources(t){this.host=t;let i=()=>{for(let a of this.subscriptions)a._isValidLocalResult||this.handle(a)},r=this.configs.HTML_IMPORTS;if(!this.host.matches||!r.attr.importscontext)return;this.refdSourceController?.disconnect();let s=this.host.ownerDocument.defaultView.webqit.realdom,n;this.refdSourceController=s.realtime(this.host).attr(r.attr.importscontext,(a,{signal:o})=>{if(a.value===n)return;if(n=a.value,!a.value)return this.contextModules=void 0,i();let u={...this.constructor.createRequest(a.value.trim()),live:!0,signal:o,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(u,c=>{this.contextModules=c&&Object.getPrototypeOf(c)?Tt(c):c,i()})},{live:!0,timing:"sync",lifecycleSignals:!0})}initialize(t){return this.realtimeSources(t),super.initialize(t)}dispose(t){return this.refdSourceController?.disconnect(),super.dispose(t)}};G(Nt,"kind","html-imports");function Zs(){let{window:e}=U,{webqit:t}=e,{realdom:i,oohtml:{configs:r}}=t;if(t.HTMLImportElement)return t.HTMLImportElement;let s=r.HTML_IMPORTS.elements.import.includes("-")?e.HTMLElement:class{};class n extends s{static instance(o){return r.HTML_IMPORTS.elements.import.includes("-")&&o instanceof this?o:A(o).get("import::instance")||new this(o)}constructor(...o){super();let u=o[0]||this;A(u).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>u,configurable:!1});let c={};Object.defineProperty(this,"#",{get:()=>c,configurable:!1}),c.slottedElements=new Set,c.setAnchorNode=l=>(c.anchorNode=l,l),c.live=l=>{if(c.liveImportsRealtime)throw new Error("Import element already in live mode.");let f=this.el.isConnected?this.el.parentNode:c.anchorNode.parentNode;c.liveImportsRealtime=i.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(p,{signal:m})=>{c.moduleRef=p.value;let g=c.moduleRef.includes("#")?c.moduleRef:`${c.moduleRef}#`,b={...Nt.createRequest(g),live:m&&!0,signal:m,diff:!g.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(b,v=>{l((v instanceof e.HTMLTemplateElement?[...v.content.children]:Array.isArray(v)?v:v&&[v])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),c.autoDestroyRealtime=i.realtime(e.document).track(f,()=>{c.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},c.die=()=>{c.autoDestroyRealtime?.disconnect(),c.liveImportsRealtime?.disconnect(),c.liveImportsRealtime=null},c.hydrate=(l,f)=>{l.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.live(p=>{if(c.originalsRemapped)return this.fill(p);let m=p.map((g,b)=>({el:g,fragmentDef:g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:g.tagName,i:b}));f.forEach((g,b)=>{let v=g.tagName,x=g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",w=(b++,m.find(C=>C.tagName===v&&C.fragmentDef===x&&C.i===b));w&&A(g).set("original@imports",w.el),A(g).set("slot@imports",this.el),c.slottedElements.add(g)}),c.originalsRemapped=!0})},c.autoRestore=(l=null)=>{c.autoRestoreRealtime?.disconnect(),l&&l();let f=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),this.el.slottingAction=!0,c.anchorNode.replaceWith(this.el),this.el.slottingAction=!1,c.setAnchorNode(null))};if(!c.slottedElements.size)return f();let p=i.realtime(c.anchorNode.parentNode).observe([...c.slottedElements],m=>{if(m.exits.forEach(g=>{A(g).delete("slot@imports"),c.slottedElements.delete(g)}),!c.slottedElements.size){if(p.disconnect(),!m.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});c.autoRestoreRealtime=p},c.connectedCallback=()=>{this.el.slottingAction||c.live(l=>this.fill(l))},c.disconnectedCallback=()=>{this.el.slottingAction||c.die()}}createAnchorNode(){if(e.webqit.env!=="server")return e.document.createTextNode("");let o=e.document.createElement("div");o.textContent=this.el.outerHTML;let u=e.document.createComment(o.innerHTML);return A(u).set("isAnchorNode",!0),u}fill(o,u){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(o)&&(o=new Set(o)),this.el.setAttribute("data-nodecount",o.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(c=>{let l=A(c).get("original@imports");o.has(l)?o.delete(l):(this["#"].slottedElements.delete(c),c.remove())}),o.size&&this.el.isConnected){let c=this["#"].setAnchorNode(this.createAnchorNode());this.el.slottingAction=!0,this.el.replaceWith(c),this.el.slottingAction=!1}o.forEach(c=>{let l=c.cloneNode(!0);l.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||l.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),A(l).set("original@imports",c),A(l).set("slot@imports",this.el),this["#"].slottedElements.add(l),this["#"].anchorNode.before(l)})}))}empty(){this["#"].slottedElements.forEach(o=>o.remove())}get anchorNode(){return this["#"].anchorNode}get moduleRef(){return this["#"].moduleRef}get slottedElements(){return this["#"].slottedElements}}return r.HTML_IMPORTS.elements.import.includes("-")&&customElements.define(r.HTML_IMPORTS.elements.import,n),t.HTMLImportElement=n,n}function mr(e={}){let{config:t,window:i}=rt.call(this,"html-imports",e,{elements:{import:"import"},attr:{def:"def",extends:"extends",inherits:"inherits",ref:"ref",importscontext:"importscontext"},api:{def:"def",defs:"defs",import:"import"}});t.attr.fragmentdef||(t.attr.fragmentdef=t.attr.def),t.templateSelector=`template[${i.CSS.escape(t.attr.def)}]`,t.importsContextSelector=`[${i.CSS.escape(t.attr.importscontext)}]`,t.slottedElementsSelector=`[${i.CSS.escape(t.attr.fragmentdef)}]:not(template)`;let r=(s,n)=>{let a=`starts-with(., "${s}")`,o=`substring(., string-length(.) - string-length("${n}") + 1) = "${n}"`;return`${a} and ${o}`};t.anchorNodeSelector=`comment()[${r(`<${t.elements.import}`,`</${t.elements.import}>`)}]`,i.webqit.HTMLImportsContext=Nt,i.webqit.HTMLImportElement=Zs(),Ra.call(i,t),Ma.call(i,t)}function Tt(e,t=!0){if(!A(e).has("defs")&&t){let i=Object.create(null);A(e).set("defs",i)}return A(e).get("defs")}function Ra(e){let t=this,{webqit:{oohtml:{configs:i}}}=t;if(e.api.def in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${e.api.def}" API!`);if(e.api.defs in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${e.api.defs}" API!`);Object.defineProperty(t.HTMLTemplateElement.prototype,e.api.def,{get:function(){return this.getAttribute(e.attr.def)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,e.api.defs,{get:function(){return Tt(this)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(s){this.toggleAttribute("scoped",s)}}),[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(s=>{let n=s===t.Document.prototype?"Document":s===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.import in s)throw new Error(`The ${n} prototype already has a "${e.api.import}" API!`);Object.defineProperty(s,e.api.import,{value:function(a,o=!1,u=null){return r(this,...arguments)}})});function r(s,n,a=!1,o=null){let u={};typeof a=="function"?(o=a,a=!1):typeof a=="object"&&a?u={...a,...u}:u={live:a};let c={...Nt.createRequest(n),...u};return s[i.CONTEXT_API.api.contexts].request(c,o)}}function Ma(e){let t=this,{webqit:{Observer:i,realdom:r,oohtml:{configs:s},HTMLImportElement:n,HTMLImportsContext:a}}=t,o=l=>{let f=l[s.CONTEXT_API.api.contexts];f.find(a.kind)||f.attach(new a)},u=l=>{let f=l[s.CONTEXT_API.api.contexts],p=f.find(a.kind);p&&(!l.isConnected||!l.matches?.(e.importsContextSelector)&&!Object.keys(p.localModules).length)&&f.detach(p)};r.realtime(t.document).query([e.templateSelector,e.importsContextSelector],l=>{l.entrants.forEach(f=>{if(f.matches(e.templateSelector)){let p=wt.instance(f);p.ownerContext=f.scoped?f.parentNode:f.getRootNode();let m=Tt(p.ownerContext);p.defId&&i.set(m,p.defId,f),o(p.ownerContext)}else o(f)}),l.exits.forEach(f=>{if(f.matches(e.templateSelector)){let p=wt.instance(f),m=Tt(p.ownerContext);p.defId&&p.ownerContext.isConnected&&i.deleteProperty(m,p.defId),u(p.ownerContext)}else u(f)})},{live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(e.elements.import,l=>{l.entrants.forEach(f=>c(f,!0,l)),l.exits.forEach(f=>c(f,!1,l))},{live:!0,subtree:"cross-roots",timing:"sync"});function c(l,f){let p=n.instance(l);f?p["#"].connectedCallback():p["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${e.anchorNodeSelector})`,l=>{l.entrants.forEach(f=>{if(A(f).get("isAnchorNode"))return;let p=t.document.createElement("div");p.innerHTML=f.nodeValue,p.innerHTML=p.firstChild.textContent;let m=p.firstChild,g=parseInt(m.getAttribute("data-nodecount")),b=new Set,v=f;for(;(v=v.previousElementSibling)&&v.matches(e.slottedElementsSelector)&&g--;)b.add(v);n.instance(m)["#"].hydrate(f,b)})},{live:!0,subtree:"cross-roots",timing:"sync"})}function gr(e={}){let{config:t,window:i}=rt.call(this,"context-api",e,{attr:{contextname:"contextname"},api:{contexts:"contexts"}});i.webqit.DOMContexts=Dt,i.webqit.DOMContext=st,i.webqit.DOMContextRequestEvent=mi(),i.webqit.DOMContextResponse=Xt,i.webqit.DuplicateContextError=Yt,Da.call(i,t)}function Da(e){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(i=>{let r=i===t.Document.prototype?"Document":i===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.contexts in i)throw new Error(`The ${r} prototype already has a "${e.api.contexts}" API!`);Object.defineProperty(i,e.api.contexts,{get:function(){return Dt.instance(this)}})})}function yr({advanced:e={},...t}){let{config:i,window:r}=rt.call(this,"scoped-css",t,{api:{styleSheets:"styleSheets"},style:{retention:"retain",mimeTypes:"text/css",strategy:null}});i.styleSelector=(Array.isArray(i.style.mimeTypes)?i.style.mimeTypes:i.style.mimeTypes.split("|")).concat("").reduce((s,n)=>{let a=n?`[type="${r.CSS.escape(n)}"]`:":not([type])";return s.concat(`style${a}`)},[]).join(","),r.webqit.oohtml.Style={compileCache:new Map},Va.call(r,i),Fa.call(r,i)}function Va(e){let t=this,i=new Map;[t.Element.prototype].forEach(r=>{let s="Element";if(e.api.styleSheets in r)throw new Error(`The ${s} prototype already has a "${e.api.styleSheets}" API!`);Object.defineProperty(r,e.api.styleSheets,{get:function(){return i.has(this)||i.set(this,[]),i.get(this)}})}),Object.defineProperty(t.HTMLStyleElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}})}function Fa(e){let t=this,{webqit:{oohtml:i,realdom:r}}=t,s=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1;t.CSS.supports||(t.CSS.supports=()=>!1);let n=new WeakSet;r.realtime(t.document).query(e.styleSelector,a=>{a.entrants.forEach(o=>{if(n.has(o))return;n.add(o);let u=Kt(o.textContent),c=CSS.supports("selector(:has(a,b))"),l=o.scoped&&(c?`:has(> style[rand-${u}])`:`[rand-${u}]`),f=o.scoped&&t.CSSScopeRule&&!1,p=o.scoped&&o.parentNode||o.getRootNode();if(p instanceof t.Element){if(p[e.api.styleSheets].push(o),!s)return;(c?o:p).toggleAttribute(`rand-${u}`,!0)}if(!!s)if(o.scoped&&o.hasAttribute("shared")){let m;(m=i.Style.compileCache.get(u))||(m=qa.call(t,o,null,f,l),i.Style.compileCache.set(u,m)),Object.defineProperty(o,"sheet",{value:m,configurable:!0}),o.textContent=`
|
|
54
54
|
/*[ Shared style sheet ]*/
|
|
55
55
|
`}else{let m=()=>{let g=xi(pe.call(t,p));xr.call(this,o.sheet,g,!f&&l)};o.isConnected?m():setTimeout(()=>{m()},0)}})},{live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants"})}function qa(e,t,i,r){let s=this,n=e.textContent,a,o=i&&r?`@scope (${r}) {
|