/**
 * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1.
 * Original file: /npm/tutuca@0.15.0/dist/tutuca-dev.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var Ds=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},te=[],Y=[],bc=typeof Uint8Array<"u"?Uint8Array:Array,wn=!1;function ks(){wn=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,n=e.length;t<n;++t)te[t]=e[t],Y[e.charCodeAt(t)]=t;Y[45]=62,Y[95]=63}function vc(e){wn||ks();var t,n,r,s,i,o,a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i=e[a-2]==="="?2:e[a-1]==="="?1:0,o=new bc(a*3/4-i),r=i>0?a-4:a;var l=0;for(t=0,n=0;t<r;t+=4,n+=3)s=Y[e.charCodeAt(t)]<<18|Y[e.charCodeAt(t+1)]<<12|Y[e.charCodeAt(t+2)]<<6|Y[e.charCodeAt(t+3)],o[l++]=s>>16&255,o[l++]=s>>8&255,o[l++]=s&255;return i===2?(s=Y[e.charCodeAt(t)]<<2|Y[e.charCodeAt(t+1)]>>4,o[l++]=s&255):i===1&&(s=Y[e.charCodeAt(t)]<<10|Y[e.charCodeAt(t+1)]<<4|Y[e.charCodeAt(t+2)]>>2,o[l++]=s>>8&255,o[l++]=s&255),o}function Ec(e){return te[e>>18&63]+te[e>>12&63]+te[e>>6&63]+te[e&63]}function _c(e,t,n){for(var r,s=[],i=t;i<n;i+=3)r=(e[i]<<16)+(e[i+1]<<8)+e[i+2],s.push(Ec(r));return s.join("")}function Ls(e){wn||ks();for(var t,n=e.length,r=n%3,s="",i=[],o=16383,a=0,l=n-r;a<l;a+=o)i.push(_c(e,a,a+o>l?l:a+o));return r===1?(t=e[n-1],s+=te[t>>2],s+=te[t<<4&63],s+="=="):r===2&&(t=(e[n-2]<<8)+e[n-1],s+=te[t>>10],s+=te[t>>4&63],s+=te[t<<2&63],s+="="),i.push(s),i.join("")}function Et(e,t,n,r,s){var i,o,a=s*8-r-1,l=(1<<a)-1,c=l>>1,f=-7,p=n?s-1:0,g=n?-1:1,y=e[t+p];for(p+=g,i=y&(1<<-f)-1,y>>=-f,f+=a;f>0;i=i*256+e[t+p],p+=g,f-=8);for(o=i&(1<<-f)-1,i>>=-f,f+=r;f>0;o=o*256+e[t+p],p+=g,f-=8);if(i===0)i=1-c;else{if(i===l)return o?NaN:(y?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-c}return(y?-1:1)*o*Math.pow(2,i-r)}function Rs(e,t,n,r,s,i){var o,a,l,c=i*8-s-1,f=(1<<c)-1,p=f>>1,g=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=r?0:i-1,E=r?1:-1,S=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=f):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+p>=1?t+=g/l:t+=g*Math.pow(2,1-p),t*l>=2&&(o++,l/=2),o+p>=f?(a=0,o=f):o+p>=1?(a=(t*l-1)*Math.pow(2,s),o=o+p):(a=t*Math.pow(2,p-1)*Math.pow(2,s),o=0));s>=8;e[n+y]=a&255,y+=E,a/=256,s-=8);for(o=o<<s|a,c+=s;c>0;e[n+y]=o&255,y+=E,o/=256,c-=8);e[n+y-E]|=S*128}var Sc={}.toString,$s=Array.isArray||function(e){return Sc.call(e)=="[object Array]"};var Tc=50;b.TYPED_ARRAY_SUPPORT=Ds.TYPED_ARRAY_SUPPORT!==void 0?Ds.TYPED_ARRAY_SUPPORT:!0,_t();function _t(){return b.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function oe(e,t){if(_t()<t)throw new RangeError("Invalid typed array length");return b.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=b.prototype):(e===null&&(e=new b(t)),e.length=t),e}function b(e,t,n){if(!b.TYPED_ARRAY_SUPPORT&&!(this instanceof b))return new b(e,t,n);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return yn(this,e)}return Fs(this,e,t,n)}b.poolSize=8192,b._augment=function(e){return e.__proto__=b.prototype,e};function Fs(e,t,n,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?xc(e,t,n,r):typeof t=="string"?Ac(e,t,n):Ic(e,t)}b.from=function(e,t,n){return Fs(null,e,t,n)},b.TYPED_ARRAY_SUPPORT&&(b.prototype.__proto__=Uint8Array.prototype,b.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&b[Symbol.species]);function Bs(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Nc(e,t,n,r){return Bs(t),t<=0?oe(e,t):n!==void 0?typeof r=="string"?oe(e,t).fill(n,r):oe(e,t).fill(n):oe(e,t)}b.alloc=function(e,t,n){return Nc(null,e,t,n)};function yn(e,t){if(Bs(t),e=oe(e,t<0?0:vn(t)|0),!b.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}b.allocUnsafe=function(e){return yn(null,e)},b.allocUnsafeSlow=function(e){return yn(null,e)};function Ac(e,t,n){if((typeof n!="string"||n==="")&&(n="utf8"),!b.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=Vs(t,n)|0;e=oe(e,r);var s=e.write(t,n);return s!==r&&(e=e.slice(0,s)),e}function bn(e,t){var n=t.length<0?0:vn(t.length)|0;e=oe(e,n);for(var r=0;r<n;r+=1)e[r]=t[r]&255;return e}function xc(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return n===void 0&&r===void 0?t=new Uint8Array(t):r===void 0?t=new Uint8Array(t,n):t=new Uint8Array(t,n,r),b.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=b.prototype):e=bn(e,t),e}function Ic(e,t){if(ne(t)){var n=vn(t.length)|0;return e=oe(e,n),e.length===0||t.copy(e,0,0,n),e}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||Kc(t.length)?oe(e,0):bn(e,t);if(t.type==="Buffer"&&$s(t.data))return bn(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function vn(e){if(e>=_t())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_t().toString(16)+" bytes");return e|0}b.isBuffer=zc;function ne(e){return!!(e!=null&&e._isBuffer)}b.compare=function(t,n){if(!ne(t)||!ne(n))throw new TypeError("Arguments must be Buffers");if(t===n)return 0;for(var r=t.length,s=n.length,i=0,o=Math.min(r,s);i<o;++i)if(t[i]!==n[i]){r=t[i],s=n[i];break}return r<s?-1:s<r?1:0},b.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},b.concat=function(t,n){if(!$s(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return b.alloc(0);var r;if(n===void 0)for(n=0,r=0;r<t.length;++r)n+=t[r].length;var s=b.allocUnsafe(n),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!ne(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(s,i),i+=o.length}return s};function Vs(e,t){if(ne(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var n=e.length;if(n===0)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Nt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Ys(e).length;default:if(r)return Nt(e).length;t=(""+t).toLowerCase(),r=!0}}b.byteLength=Vs;function Oc(e,t,n){var r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Bc(this,t,n);case"utf8":case"utf-8":return Hs(this,t,n);case"ascii":return $c(this,t,n);case"latin1":case"binary":return Fc(this,t,n);case"base64":return Lc(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vc(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}b.prototype._isBuffer=!0;function ge(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}b.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<t;n+=2)ge(this,n,n+1);return this},b.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<t;n+=4)ge(this,n,n+3),ge(this,n+1,n+2);return this},b.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<t;n+=8)ge(this,n,n+7),ge(this,n+1,n+6),ge(this,n+2,n+5),ge(this,n+3,n+4);return this},b.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Hs(this,0,t):Oc.apply(this,arguments)},b.prototype.equals=function(t){if(!ne(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:b.compare(this,t)===0},b.prototype.inspect=function(){var t="",n=Tc;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},b.prototype.compare=function(t,n,r,s,i){if(!ne(t))throw new TypeError("Argument must be a Buffer");if(n===void 0&&(n=0),r===void 0&&(r=t?t.length:0),s===void 0&&(s=0),i===void 0&&(i=this.length),n<0||r>t.length||s<0||i>this.length)throw new RangeError("out of range index");if(s>=i&&n>=r)return 0;if(s>=i)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,s>>>=0,i>>>=0,this===t)return 0;for(var o=i-s,a=r-n,l=Math.min(o,a),c=this.slice(s,i),f=t.slice(n,r),p=0;p<l;++p)if(c[p]!==f[p]){o=c[p],a=f[p];break}return o<a?-1:a<o?1:0};function Us(e,t,n,r,s){if(e.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=s?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(s)return-1;n=e.length-1}else if(n<0)if(s)n=0;else return-1;if(typeof t=="string"&&(t=b.from(t,r)),ne(t))return t.length===0?-1:js(e,t,n,r,s);if(typeof t=="number")return t=t&255,b.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):js(e,[t],n,r,s);throw new TypeError("val must be string, number or Buffer")}function js(e,t,n,r,s){var i=1,o=e.length,a=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(e.length<2||t.length<2)return-1;i=2,o/=2,a/=2,n/=2}function l(y,E){return i===1?y[E]:y.readUInt16BE(E*i)}var c;if(s){var f=-1;for(c=n;c<o;c++)if(l(e,c)===l(t,f===-1?0:c-f)){if(f===-1&&(f=c),c-f+1===a)return f*i}else f!==-1&&(c-=c-f),f=-1}else for(n+a>o&&(n=o-a),c=n;c>=0;c--){for(var p=!0,g=0;g<a;g++)if(l(e,c+g)!==l(t,g)){p=!1;break}if(p)return c}return-1}b.prototype.includes=function(t,n,r){return this.indexOf(t,n,r)!==-1},b.prototype.indexOf=function(t,n,r){return Us(this,t,n,r,!0)},b.prototype.lastIndexOf=function(t,n,r){return Us(this,t,n,r,!1)};function Pc(e,t,n,r){n=Number(n)||0;var s=e.length-n;r?(r=Number(r),r>s&&(r=s)):r=s;var i=t.length;if(i%2!==0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(o*2,2),16);if(isNaN(a))return o;e[n+o]=a}return o}function Mc(e,t,n,r){return At(Nt(t,e.length-n),e,n,r)}function qs(e,t,n,r){return At(Gc(t),e,n,r)}function Cc(e,t,n,r){return qs(e,t,n,r)}function Dc(e,t,n,r){return At(Ys(t),e,n,r)}function kc(e,t,n,r){return At(Wc(t,e.length-n),e,n,r)}b.prototype.write=function(t,n,r,s){if(n===void 0)s="utf8",r=this.length,n=0;else if(r===void 0&&typeof n=="string")s=n,r=this.length,n=0;else if(isFinite(n))n=n|0,isFinite(r)?(r=r|0,s===void 0&&(s="utf8")):(s=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-n;if((r===void 0||r>i)&&(r=i),t.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var o=!1;;)switch(s){case"hex":return Pc(this,t,n,r);case"utf8":case"utf-8":return Mc(this,t,n,r);case"ascii":return qs(this,t,n,r);case"latin1":case"binary":return Cc(this,t,n,r);case"base64":return Dc(this,t,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return kc(this,t,n,r);default:if(o)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),o=!0}},b.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Lc(e,t,n){return t===0&&n===e.length?Ls(e):Ls(e.slice(t,n))}function Hs(e,t,n){n=Math.min(e.length,n);for(var r=[],s=t;s<n;){var i=e[s],o=null,a=i>239?4:i>223?3:i>191?2:1;if(s+a<=n){var l,c,f,p;switch(a){case 1:i<128&&(o=i);break;case 2:l=e[s+1],(l&192)===128&&(p=(i&31)<<6|l&63,p>127&&(o=p));break;case 3:l=e[s+1],c=e[s+2],(l&192)===128&&(c&192)===128&&(p=(i&15)<<12|(l&63)<<6|c&63,p>2047&&(p<55296||p>57343)&&(o=p));break;case 4:l=e[s+1],c=e[s+2],f=e[s+3],(l&192)===128&&(c&192)===128&&(f&192)===128&&(p=(i&15)<<18|(l&63)<<12|(c&63)<<6|f&63,p>65535&&p<1114112&&(o=p))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|o&1023),r.push(o),s+=a}return Rc(r)}var Gs=4096;function Rc(e){var t=e.length;if(t<=Gs)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Gs));return n}function $c(e,t,n){var r="";n=Math.min(e.length,n);for(var s=t;s<n;++s)r+=String.fromCharCode(e[s]&127);return r}function Fc(e,t,n){var r="";n=Math.min(e.length,n);for(var s=t;s<n;++s)r+=String.fromCharCode(e[s]);return r}function Bc(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var s="",i=t;i<n;++i)s+=Hc(e[i]);return s}function Vc(e,t,n){for(var r=e.slice(t,n),s="",i=0;i<r.length;i+=2)s+=String.fromCharCode(r[i]+r[i+1]*256);return s}b.prototype.slice=function(t,n){var r=this.length;t=~~t,n=n===void 0?r:~~n,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n<t&&(n=t);var s;if(b.TYPED_ARRAY_SUPPORT)s=this.subarray(t,n),s.__proto__=b.prototype;else{var i=n-t;s=new b(i,void 0);for(var o=0;o<i;++o)s[o]=this[o+t]}return s};function F(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}b.prototype.readUIntLE=function(t,n,r){t=t|0,n=n|0,r||F(t,n,this.length);for(var s=this[t],i=1,o=0;++o<n&&(i*=256);)s+=this[t+o]*i;return s},b.prototype.readUIntBE=function(t,n,r){t=t|0,n=n|0,r||F(t,n,this.length);for(var s=this[t+--n],i=1;n>0&&(i*=256);)s+=this[t+--n]*i;return s},b.prototype.readUInt8=function(t,n){return n||F(t,1,this.length),this[t]},b.prototype.readUInt16LE=function(t,n){return n||F(t,2,this.length),this[t]|this[t+1]<<8},b.prototype.readUInt16BE=function(t,n){return n||F(t,2,this.length),this[t]<<8|this[t+1]},b.prototype.readUInt32LE=function(t,n){return n||F(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},b.prototype.readUInt32BE=function(t,n){return n||F(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},b.prototype.readIntLE=function(t,n,r){t=t|0,n=n|0,r||F(t,n,this.length);for(var s=this[t],i=1,o=0;++o<n&&(i*=256);)s+=this[t+o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*n)),s},b.prototype.readIntBE=function(t,n,r){t=t|0,n=n|0,r||F(t,n,this.length);for(var s=n,i=1,o=this[t+--s];s>0&&(i*=256);)o+=this[t+--s]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*n)),o},b.prototype.readInt8=function(t,n){return n||F(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},b.prototype.readInt16LE=function(t,n){n||F(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r},b.prototype.readInt16BE=function(t,n){n||F(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r},b.prototype.readInt32LE=function(t,n){return n||F(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},b.prototype.readInt32BE=function(t,n){return n||F(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},b.prototype.readFloatLE=function(t,n){return n||F(t,4,this.length),Et(this,t,!0,23,4)},b.prototype.readFloatBE=function(t,n){return n||F(t,4,this.length),Et(this,t,!1,23,4)},b.prototype.readDoubleLE=function(t,n){return n||F(t,8,this.length),Et(this,t,!0,52,8)},b.prototype.readDoubleBE=function(t,n){return n||F(t,8,this.length),Et(this,t,!1,52,8)};function q(e,t,n,r,s,i){if(!ne(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}b.prototype.writeUIntLE=function(t,n,r,s){if(t=+t,n=n|0,r=r|0,!s){var i=Math.pow(2,8*r)-1;q(this,t,n,r,i,0)}var o=1,a=0;for(this[n]=t&255;++a<r&&(o*=256);)this[n+a]=t/o&255;return n+r},b.prototype.writeUIntBE=function(t,n,r,s){if(t=+t,n=n|0,r=r|0,!s){var i=Math.pow(2,8*r)-1;q(this,t,n,r,i,0)}var o=r-1,a=1;for(this[n+o]=t&255;--o>=0&&(a*=256);)this[n+o]=t/a&255;return n+r},b.prototype.writeUInt8=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,1,255,0),b.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[n]=t&255,n+1};function St(e,t,n,r){t<0&&(t=65535+t+1);for(var s=0,i=Math.min(e.length-n,2);s<i;++s)e[n+s]=(t&255<<8*(r?s:1-s))>>>(r?s:1-s)*8}b.prototype.writeUInt16LE=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,2,65535,0),b.TYPED_ARRAY_SUPPORT?(this[n]=t&255,this[n+1]=t>>>8):St(this,t,n,!0),n+2},b.prototype.writeUInt16BE=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,2,65535,0),b.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=t&255):St(this,t,n,!1),n+2};function Tt(e,t,n,r){t<0&&(t=4294967295+t+1);for(var s=0,i=Math.min(e.length-n,4);s<i;++s)e[n+s]=t>>>(r?s:3-s)*8&255}b.prototype.writeUInt32LE=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,4,4294967295,0),b.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255):Tt(this,t,n,!0),n+4},b.prototype.writeUInt32BE=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,4,4294967295,0),b.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255):Tt(this,t,n,!1),n+4},b.prototype.writeIntLE=function(t,n,r,s){if(t=+t,n=n|0,!s){var i=Math.pow(2,8*r-1);q(this,t,n,r,i-1,-i)}var o=0,a=1,l=0;for(this[n]=t&255;++o<r&&(a*=256);)t<0&&l===0&&this[n+o-1]!==0&&(l=1),this[n+o]=(t/a>>0)-l&255;return n+r},b.prototype.writeIntBE=function(t,n,r,s){if(t=+t,n=n|0,!s){var i=Math.pow(2,8*r-1);q(this,t,n,r,i-1,-i)}var o=r-1,a=1,l=0;for(this[n+o]=t&255;--o>=0&&(a*=256);)t<0&&l===0&&this[n+o+1]!==0&&(l=1),this[n+o]=(t/a>>0)-l&255;return n+r},b.prototype.writeInt8=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,1,127,-128),b.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[n]=t&255,n+1},b.prototype.writeInt16LE=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,2,32767,-32768),b.TYPED_ARRAY_SUPPORT?(this[n]=t&255,this[n+1]=t>>>8):St(this,t,n,!0),n+2},b.prototype.writeInt16BE=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,2,32767,-32768),b.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=t&255):St(this,t,n,!1),n+2},b.prototype.writeInt32LE=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,4,2147483647,-2147483648),b.TYPED_ARRAY_SUPPORT?(this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):Tt(this,t,n,!0),n+4},b.prototype.writeInt32BE=function(t,n,r){return t=+t,n=n|0,r||q(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),b.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255):Tt(this,t,n,!1),n+4};function Ws(e,t,n,r,s,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ks(e,t,n,r,s){return s||Ws(e,t,n,4),Rs(e,t,n,r,23,4),n+4}b.prototype.writeFloatLE=function(t,n,r){return Ks(this,t,n,!0,r)},b.prototype.writeFloatBE=function(t,n,r){return Ks(this,t,n,!1,r)};function zs(e,t,n,r,s){return s||Ws(e,t,n,8),Rs(e,t,n,r,52,8),n+8}b.prototype.writeDoubleLE=function(t,n,r){return zs(this,t,n,!0,r)},b.prototype.writeDoubleBE=function(t,n,r){return zs(this,t,n,!1,r)},b.prototype.copy=function(t,n,r,s){if(r||(r=0),!s&&s!==0&&(s=this.length),n>=t.length&&(n=t.length),n||(n=0),s>0&&s<r&&(s=r),s===r||t.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-n<s-r&&(s=t.length-n+r);var i=s-r,o;if(this===t&&r<n&&n<s)for(o=i-1;o>=0;--o)t[o+n]=this[o+r];else if(i<1e3||!b.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+n]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),n);return i},b.prototype.fill=function(t,n,r,s){if(typeof t=="string"){if(typeof n=="string"?(s=n,n=0,r=this.length):typeof r=="string"&&(s=r,r=this.length),t.length===1){var i=t.charCodeAt(0);i<256&&(t=i)}if(s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!b.isEncoding(s))throw new TypeError("Unknown encoding: "+s)}else typeof t=="number"&&(t=t&255);if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n=n>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var o;if(typeof t=="number")for(o=n;o<r;++o)this[o]=t;else{var a=ne(t)?t:Nt(new b(t,s).toString()),l=a.length;for(o=0;o<r-n;++o)this[o+n]=a[o%l]}return this};var Uc=/[^+\/0-9A-Za-z-_]/g;function jc(e){if(e=qc(e).replace(Uc,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function qc(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function Hc(e){return e<16?"0"+e.toString(16):e.toString(16)}function Nt(e,t){t=t||1/0;for(var n,r=e.length,s=null,i=[],o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!s){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&i.push(239,191,189);continue}s=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),s=n;continue}n=(s-55296<<10|n-56320)+65536}else s&&(t-=3)>-1&&i.push(239,191,189);if(s=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return i}function Gc(e){for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function Wc(e,t){for(var n,r,s,i=[],o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,s=n%256,i.push(s),i.push(r);return i}function Ys(e){return vc(jc(e))}function At(e,t,n,r){for(var s=0;s<r&&!(s+n>=t.length||s>=e.length);++s)t[s+n]=e[s];return s}function Kc(e){return e!==e}function zc(e){return e!=null&&(!!e._isBuffer||Xs(e)||Yc(e))}function Xs(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function Yc(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Xs(e.slice(0,0))}var En=Object.defineProperty,Xc=(e,t,n)=>t in e?En(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>En(e,"name",{value:t,configurable:!0}),_n=(e,t)=>{for(var n in t)En(e,n,{get:t[n],enumerable:!0})},Js=(e,t,n)=>Xc(e,typeof t!="symbol"?t+"":t,n),xt={};_n(xt,{addChainableMethod:()=>Qn,addLengthGuard:()=>Je,addMethod:()=>Yn,addProperty:()=>zn,checkError:()=>K,compareByInspect:()=>kt,eql:()=>Pi,events:()=>Dt,expectTypes:()=>ii,flag:()=>N,getActual:()=>Ot,getMessage:()=>Dn,getName:()=>Rt,getOperator:()=>nr,getOwnEnumerableProperties:()=>tr,getOwnEnumerablePropertySymbols:()=>er,getPathInfo:()=>Wn,hasProperty:()=>Ct,inspect:()=>I,isNaN:()=>Lt,isNumeric:()=>B,isProxyEnabled:()=>Xe,isRegExp:()=>$t,objDisplay:()=>we,overwriteChainableMethod:()=>Zn,overwriteMethod:()=>Jn,overwriteProperty:()=>Xn,proxify:()=>Ce,test:()=>Sn,transferFlags:()=>Z,type:()=>P});var K={};_n(K,{compatibleConstructor:()=>ei,compatibleInstance:()=>Zs,compatibleMessage:()=>ti,getConstructorName:()=>ni,getMessage:()=>ri});function It(e){return e instanceof Error||Object.prototype.toString.call(e)==="[object Error]"}m(It,"isErrorInstance");function Qs(e){return Object.prototype.toString.call(e)==="[object RegExp]"}m(Qs,"isRegExp");function Zs(e,t){return It(t)&&e===t}m(Zs,"compatibleInstance");function ei(e,t){return It(t)?e.constructor===t.constructor||e instanceof t.constructor:(typeof t=="object"||typeof t=="function")&&t.prototype?e.constructor===t||e instanceof t:!1}m(ei,"compatibleConstructor");function ti(e,t){const n=typeof e=="string"?e:e.message;return Qs(t)?t.test(n):typeof t=="string"?n.indexOf(t)!==-1:!1}m(ti,"compatibleMessage");function ni(e){let t=e;return It(e)?t=e.constructor.name:typeof e=="function"&&(t=e.name,t===""&&(t=new e().name||t)),t}m(ni,"getConstructorName");function ri(e){let t="";return e&&e.message?t=e.message:typeof e=="string"&&(t=e),t}m(ri,"getMessage");function N(e,t,n){let r=e.__flags||(e.__flags=Object.create(null));if(arguments.length===3)r[t]=n;else return r[t]}m(N,"flag");function Sn(e,t){let n=N(e,"negate"),r=t[0];return n?!r:r}m(Sn,"test");function P(e){if(typeof e>"u")return"undefined";if(e===null)return"null";const t=e[Symbol.toStringTag];return typeof t=="string"?t:Object.prototype.toString.call(e).slice(8,-1)}m(P,"type");var Jc="captureStackTrace"in Error,si=class lc extends Error{constructor(t="Unspecified AssertionError",n,r){super(t),Js(this,"message"),this.message=t,Jc&&Error.captureStackTrace(this,r||lc);for(const s in n)s in this||(this[s]=n[s])}get name(){return"AssertionError"}get ok(){return!1}toJSON(t){return{...this,name:this.name,message:this.message,ok:!1,stack:t!==!1?this.stack:void 0}}};m(si,"AssertionError");var O=si;function ii(e,t){let n=N(e,"message"),r=N(e,"ssfi");n=n?n+": ":"",e=N(e,"object"),t=t.map(function(o){return o.toLowerCase()}),t.sort();let s=t.map(function(o,a){let l=~["a","e","i","o","u"].indexOf(o.charAt(0))?"an":"a";return(t.length>1&&a===t.length-1?"or ":"")+l+" "+o}).join(", "),i=P(e).toLowerCase();if(!t.some(function(o){return i===o}))throw new O(n+"object tested must be "+s+", but "+i+" given",void 0,r)}m(ii,"expectTypes");function Ot(e,t){return t.length>4?t[4]:e._obj}m(Ot,"getActual");var oi={bold:["1","22"],dim:["2","22"],italic:["3","23"],underline:["4","24"],inverse:["7","27"],hidden:["8","28"],strike:["9","29"],black:["30","39"],red:["31","39"],green:["32","39"],yellow:["33","39"],blue:["34","39"],magenta:["35","39"],cyan:["36","39"],white:["37","39"],brightblack:["30;1","39"],brightred:["31;1","39"],brightgreen:["32;1","39"],brightyellow:["33;1","39"],brightblue:["34;1","39"],brightmagenta:["35;1","39"],brightcyan:["36;1","39"],brightwhite:["37;1","39"],grey:["90","39"]},Qc={special:"cyan",number:"yellow",bigint:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",symbol:"green",date:"magenta",regexp:"red"},Pe="\u2026";function ai(e,t){const n=oi[Qc[t]]||oi[t]||"";return n?`\x1B[${n[0]}m${String(e)}\x1B[${n[1]}m`:String(e)}m(ai,"colorise");function li({showHidden:e=!1,depth:t=2,colors:n=!1,customInspect:r=!0,showProxy:s=!1,maxArrayLength:i=1/0,breakLength:o=1/0,seen:a=[],truncate:l=1/0,stylize:c=String}={},f){const p={showHidden:!!e,depth:Number(t),colors:!!n,customInspect:!!r,showProxy:!!s,maxArrayLength:Number(i),breakLength:Number(o),truncate:Number(l),seen:a,inspect:f,stylize:c};return p.colors&&(p.stylize=ai),p}m(li,"normaliseOptions");function ci(e){return e>="\uD800"&&e<="\uDBFF"}m(ci,"isHighSurrogate");function ae(e,t,n=Pe){e=String(e);const r=n.length,s=e.length;if(r>t&&s>r)return n;if(s>t&&s>r){let i=t-r;return i>0&&ci(e[i-1])&&(i=i-1),`${e.slice(0,i)}${n}`}return e}m(ae,"truncate");function X(e,t,n,r=", "){n=n||t.inspect;const s=e.length;if(s===0)return"";const i=t.truncate;let o="",a="",l="";for(let c=0;c<s;c+=1){const f=c+1===e.length,p=c+2===e.length;l=`${Pe}(${e.length-c})`;const g=e[c];t.truncate=i-o.length-(f?0:r.length);const y=a||n(g,t)+(f?"":r),E=o.length+y.length,S=E+l.length;if(f&&E>i&&o.length+l.length<=i||!f&&!p&&S>i||(a=f?"":n(e[c+1],t)+(p?"":r),!f&&p&&S>i&&E+a.length>i))break;if(o+=y,!f&&!p&&E+a.length>=i){l=`${Pe}(${e.length-c-1})`;break}l=""}return`${o}${l}`}m(X,"inspectList");function ui(e){return e.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)?e:JSON.stringify(e).replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'")}m(ui,"quoteComplexKey");function Me([e,t],n){return n.truncate-=2,typeof e=="string"?e=ui(e):typeof e!="number"&&(e=`[${n.inspect(e,n)}]`),n.truncate-=e.length,t=n.inspect(t,n),`${e}: ${t}`}m(Me,"inspectProperty");function hi(e,t){const n=Object.keys(e).slice(e.length);if(!e.length&&!n.length)return"[]";t.truncate-=4;const r=X(e,t);t.truncate-=r.length;let s="";return n.length&&(s=X(n.map(i=>[i,e[i]]),t,Me)),`[ ${r}${s?`, ${s}`:""} ]`}m(hi,"inspectArray");var Zc=m(e=>typeof b=="function"&&e instanceof b?"Buffer":e[Symbol.toStringTag]?e[Symbol.toStringTag]:e.constructor.name,"getArrayName");function re(e,t){const n=Zc(e);t.truncate-=n.length+4;const r=Object.keys(e).slice(e.length);if(!e.length&&!r.length)return`${n}[]`;let s="";for(let o=0;o<e.length;o++){const a=`${t.stylize(ae(e[o],t.truncate),"number")}${o===e.length-1?"":", "}`;if(t.truncate-=a.length,e[o]!==e.length&&t.truncate<=3){s+=`${Pe}(${e.length-e[o]+1})`;break}s+=a}let i="";return r.length&&(i=X(r.map(o=>[o,e[o]]),t,Me)),`${n}[ ${s}${i?`, ${i}`:""} ]`}m(re,"inspectTypedArray");function fi(e,t){const n=e.toJSON();if(n===null)return"Invalid Date";const r=n.split("T"),s=r[0];return t.stylize(`${s}T${ae(r[1],t.truncate-s.length-1)}`,"date")}m(fi,"inspectDate");function Tn(e,t){const n=e[Symbol.toStringTag]||"Function",r=e.name;return r?t.stylize(`[${n} ${ae(r,t.truncate-11)}]`,"special"):t.stylize(`[${n}]`,"special")}m(Tn,"inspectFunction");function di([e,t],n){return n.truncate-=4,e=n.inspect(e,n),n.truncate-=e.length,t=n.inspect(t,n),`${e} => ${t}`}m(di,"inspectMapEntry");function pi(e){const t=[];return e.forEach((n,r)=>{t.push([r,n])}),t}m(pi,"mapToEntries");function mi(e,t){return e.size===0?"Map{}":(t.truncate-=7,`Map{ ${X(pi(e),t,di)} }`)}m(mi,"inspectMap");var eu=Number.isNaN||(e=>e!==e);function Nn(e,t){return eu(e)?t.stylize("NaN","number"):e===1/0?t.stylize("Infinity","number"):e===-1/0?t.stylize("-Infinity","number"):e===0?t.stylize(1/e===1/0?"+0":"-0","number"):t.stylize(ae(String(e),t.truncate),"number")}m(Nn,"inspectNumber");function An(e,t){let n=ae(e.toString(),t.truncate-1);return n!==Pe&&(n+="n"),t.stylize(n,"bigint")}m(An,"inspectBigInt");function gi(e,t){const n=e.toString().split("/")[2],r=t.truncate-(2+n.length),s=e.source;return t.stylize(`/${ae(s,r)}/${n}`,"regexp")}m(gi,"inspectRegExp");function wi(e){const t=[];return e.forEach(n=>{t.push(n)}),t}m(wi,"arrayFromSet");function yi(e,t){return e.size===0?"Set{}":(t.truncate-=7,`Set{ ${X(wi(e),t)} }`)}m(yi,"inspectSet");var bi=new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]","g"),tu={"\b":"\\b","	":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","'":"\\'","\\":"\\\\"},nu=16;function vi(e){return tu[e]||`\\u${`0000${e.charCodeAt(0).toString(nu)}`.slice(-4)}`}m(vi,"escape");function xn(e,t){return bi.test(e)&&(e=e.replace(bi,vi)),t.stylize(`'${ae(e,t.truncate-2)}'`,"string")}m(xn,"inspectString");function In(e){return"description"in Symbol.prototype?e.description?`Symbol(${e.description})`:"Symbol()":e.toString()}m(In,"inspectSymbol");var ru=m(()=>"Promise{\u2026}","getPromiseValue"),su=ru;function We(e,t){const n=Object.getOwnPropertyNames(e),r=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[];if(n.length===0&&r.length===0)return"{}";if(t.truncate-=4,t.seen=t.seen||[],t.seen.includes(e))return"[Circular]";t.seen.push(e);const s=X(n.map(a=>[a,e[a]]),t,Me),i=X(r.map(a=>[a,e[a]]),t,Me);t.seen.pop();let o="";return s&&i&&(o=", "),`{ ${s}${o}${i} }`}m(We,"inspectObject");var On=typeof Symbol<"u"&&Symbol.toStringTag?Symbol.toStringTag:!1;function Ei(e,t){let n="";return On&&On in e&&(n=e[On]),n=n||e.constructor.name,(!n||n==="_class")&&(n="<Anonymous Class>"),t.truncate-=n.length,`${n}${We(e,t)}`}m(Ei,"inspectClass");function _i(e,t){return e.length===0?"Arguments[]":(t.truncate-=13,`Arguments[ ${X(e,t)} ]`)}m(_i,"inspectArguments");var iu=["stack","line","column","name","message","fileName","lineNumber","columnNumber","number","description","cause"];function Si(e,t){const n=Object.getOwnPropertyNames(e).filter(o=>iu.indexOf(o)===-1),r=e.name;t.truncate-=r.length;let s="";if(typeof e.message=="string"?s=ae(e.message,t.truncate):n.unshift("message"),s=s?`: ${s}`:"",t.truncate-=s.length+5,t.seen=t.seen||[],t.seen.includes(e))return"[Circular]";t.seen.push(e);const i=X(n.map(o=>[o,e[o]]),t,Me);return`${r}${s}${i?` { ${i} }`:""}`}m(Si,"inspectObject");function Ti([e,t],n){return n.truncate-=3,t?`${n.stylize(String(e),"yellow")}=${n.stylize(`"${t}"`,"string")}`:`${n.stylize(String(e),"yellow")}`}m(Ti,"inspectAttribute");function Pt(e,t){return X(e,t,Ni,`
`)}m(Pt,"inspectNodeCollection");function Ni(e,t){switch(e.nodeType){case 1:return Pn(e,t);case 3:return t.inspect(e.data,t);default:return t.inspect(e,t)}}m(Ni,"inspectNode");function Pn(e,t){const n=e.getAttributeNames(),r=e.tagName.toLowerCase(),s=t.stylize(`<${r}`,"special"),i=t.stylize(">","special"),o=t.stylize(`</${r}>`,"special");t.truncate-=r.length*2+5;let a="";n.length>0&&(a+=" ",a+=X(n.map(f=>[f,e.getAttribute(f)]),t,Ti," ")),t.truncate-=a.length;const l=t.truncate;let c=Pt(e.children,t);return c&&c.length>l&&(c=`${Pe}(${e.children.length})`),`${s}${a}${i}${c}${o}`}m(Pn,"inspectHTML");var ou=typeof Symbol=="function"&&typeof Symbol.for=="function",Mn=ou?Symbol.for("chai/inspect"):"@@chai/inspect",Cn=Symbol.for("nodejs.util.inspect.custom"),Ai=new WeakMap,xi={},Ii={undefined:m((e,t)=>t.stylize("undefined","undefined"),"undefined"),null:m((e,t)=>t.stylize("null","null"),"null"),boolean:m((e,t)=>t.stylize(String(e),"boolean"),"boolean"),Boolean:m((e,t)=>t.stylize(String(e),"boolean"),"Boolean"),number:Nn,Number:Nn,bigint:An,BigInt:An,string:xn,String:xn,function:Tn,Function:Tn,symbol:In,Symbol:In,Array:hi,Date:fi,Map:mi,Set:yi,RegExp:gi,Promise:su,WeakSet:m((e,t)=>t.stylize("WeakSet{\u2026}","special"),"WeakSet"),WeakMap:m((e,t)=>t.stylize("WeakMap{\u2026}","special"),"WeakMap"),Arguments:_i,Int8Array:re,Uint8Array:re,Uint8ClampedArray:re,Int16Array:re,Uint16Array:re,Int32Array:re,Uint32Array:re,Float32Array:re,Float64Array:re,Generator:m(()=>"","Generator"),DataView:m(()=>"","DataView"),ArrayBuffer:m(()=>"","ArrayBuffer"),Error:Si,HTMLCollection:Pt,NodeList:Pt},au=m((e,t,n,r)=>Mn in e&&typeof e[Mn]=="function"?e[Mn](t):Cn in e&&typeof e[Cn]=="function"?e[Cn](t.depth,t,r):"inspect"in e&&typeof e.inspect=="function"?e.inspect(t.depth,t):"constructor"in e&&Ai.has(e.constructor)?Ai.get(e.constructor)(e,t):xi[n]?xi[n](e,t):"","inspectCustom"),lu=Object.prototype.toString;function Ke(e,t={}){const n=li(t,Ke),{customInspect:r}=n;let s=e===null?"null":typeof e;if(s==="object"&&(s=lu.call(e).slice(8,-1)),s in Ii)return Ii[s](e,n);if(r&&e){const o=au(e,n,s,Ke);if(o)return typeof o=="string"?o:Ke(o,n)}const i=e?Object.getPrototypeOf(e):!1;return i===Object.prototype||i===null?We(e,n):e&&typeof HTMLElement=="function"&&e instanceof HTMLElement?Pn(e,n):"constructor"in e?e.constructor!==Object?Ei(e,n):We(e,n):e===Object(e)?We(e,n):n.stylize(String(e),s)}m(Ke,"inspect");var j={includeStack:!1,showDiff:!0,truncateThreshold:40,useProxy:!0,proxyExcludedKeys:["then","catch","inspect","toJSON"],deepEqual:null};function I(e,t,n,r){let s={colors:r,depth:typeof n>"u"?2:n,showHidden:t,truncate:j.truncateThreshold?j.truncateThreshold:1/0};return Ke(e,s)}m(I,"inspect");function we(e){let t=I(e),n=Object.prototype.toString.call(e);if(j.truncateThreshold&&t.length>=j.truncateThreshold){if(n==="[object Function]")return!e.name||e.name===""?"[Function]":"[Function: "+e.name+"]";if(n==="[object Array]")return"[ Array("+e.length+") ]";if(n==="[object Object]"){let r=Object.keys(e);return"{ Object ("+(r.length>2?r.splice(0,2).join(", ")+", ...":r.join(", "))+") }"}else return t}else return t}m(we,"objDisplay");function Dn(e,t){let n=N(e,"negate"),r=N(e,"object"),s=t[3],i=Ot(e,t),o=n?t[2]:t[1],a=N(e,"message");return typeof o=="function"&&(o=o()),o=o||"",o=o.replace(/#\{this\}/g,function(){return we(r)}).replace(/#\{act\}/g,function(){return we(i)}).replace(/#\{exp\}/g,function(){return we(s)}),a?a+": "+o:o}m(Dn,"getMessage");function Z(e,t,n){let r=e.__flags||(e.__flags=Object.create(null));t.__flags||(t.__flags=Object.create(null)),n=arguments.length===3?n:!0;for(let s in r)(n||s!=="object"&&s!=="ssfi"&&s!=="lockSsfi"&&s!="message")&&(t.__flags[s]=r[s])}m(Z,"transferFlags");function kn(e){if(typeof e>"u")return"undefined";if(e===null)return"null";const t=e[Symbol.toStringTag];return typeof t=="string"?t:Object.prototype.toString.call(e).slice(8,-1)}m(kn,"type");function Ln(){this._key="chai/deep-eql__"+Math.random()+Date.now()}m(Ln,"FakeMap"),Ln.prototype={get:m(function(t){return t[this._key]},"get"),set:m(function(t,n){Object.isExtensible(t)&&Object.defineProperty(t,this._key,{value:n,configurable:!0})},"set")};var Oi=typeof WeakMap=="function"?WeakMap:Ln;function Rn(e,t,n){if(!n||ye(e)||ye(t))return null;var r=n.get(e);if(r){var s=r.get(t);if(typeof s=="boolean")return s}return null}m(Rn,"memoizeCompare");function ze(e,t,n,r){if(!(!n||ye(e)||ye(t))){var s=n.get(e);s?s.set(t,r):(s=new Oi,s.set(t,r),n.set(e,s))}}m(ze,"memoizeSet");var Pi=Ye;function Ye(e,t,n){if(n&&n.comparator)return Fn(e,t,n);var r=$n(e,t);return r!==null?r:Fn(e,t,n)}m(Ye,"deepEqual");function $n(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t?!0:ye(e)||ye(t)?!1:null}m($n,"simpleEqual");function Fn(e,t,n){n=n||{},n.memoize=n.memoize===!1?!1:n.memoize||new Oi;var r=n&&n.comparator,s=Rn(e,t,n.memoize);if(s!==null)return s;var i=Rn(t,e,n.memoize);if(i!==null)return i;if(r){var o=r(e,t);if(o===!1||o===!0)return ze(e,t,n.memoize,o),o;var a=$n(e,t);if(a!==null)return a}var l=kn(e);if(l!==kn(t))return ze(e,t,n.memoize,!1),!1;ze(e,t,n.memoize,!0);var c=Mi(e,t,l,n);return ze(e,t,n.memoize,c),c}m(Fn,"extensiveDeepEqual");function Mi(e,t,n,r){switch(n){case"String":case"Number":case"Boolean":case"Date":return Ye(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return qn(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return ue(e,t,r);case"RegExp":return Ci(e,t);case"Generator":return Di(e,t,r);case"DataView":return ue(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return ue(new Uint8Array(e),new Uint8Array(t),r);case"Set":return Bn(e,t,r);case"Map":return Bn(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return Li(e,t,r)}}m(Mi,"extensiveDeepEqualByType");function Ci(e,t){return e.toString()===t.toString()}m(Ci,"regexpEqual");function Bn(e,t,n){try{if(e.size!==t.size)return!1;if(e.size===0)return!0}catch{return!1}var r=[],s=[];return e.forEach(m(function(o,a){r.push([o,a])},"gatherEntries")),t.forEach(m(function(o,a){s.push([o,a])},"gatherEntries")),ue(r.sort(),s.sort(),n)}m(Bn,"entriesEqual");function ue(e,t,n){var r=e.length;if(r!==t.length)return!1;if(r===0)return!0;for(var s=-1;++s<r;)if(Ye(e[s],t[s],n)===!1)return!1;return!0}m(ue,"iterableEqual");function Di(e,t,n){return ue(Mt(e),Mt(t),n)}m(Di,"generatorEqual");function ki(e){return typeof Symbol<"u"&&typeof e=="object"&&typeof Symbol.iterator<"u"&&typeof e[Symbol.iterator]=="function"}m(ki,"hasIteratorFunction");function Vn(e){if(ki(e))try{return Mt(e[Symbol.iterator]())}catch{return[]}return[]}m(Vn,"getIteratorEntries");function Mt(e){for(var t=e.next(),n=[t.value];t.done===!1;)t=e.next(),n.push(t.value);return n}m(Mt,"getGeneratorEntries");function Un(e){var t=[];for(var n in e)t.push(n);return t}m(Un,"getEnumerableKeys");function jn(e){for(var t=[],n=Object.getOwnPropertySymbols(e),r=0;r<n.length;r+=1){var s=n[r];Object.getOwnPropertyDescriptor(e,s).enumerable&&t.push(s)}return t}m(jn,"getEnumerableSymbols");function qn(e,t,n,r){var s=n.length;if(s===0)return!0;for(var i=0;i<s;i+=1)if(Ye(e[n[i]],t[n[i]],r)===!1)return!1;return!0}m(qn,"keysEqual");function Li(e,t,n){var r=Un(e),s=Un(t),i=jn(e),o=jn(t);if(r=r.concat(i),s=s.concat(o),r.length&&r.length===s.length)return ue(Hn(r).sort(),Hn(s).sort())===!1?!1:qn(e,t,r,n);var a=Vn(e),l=Vn(t);return a.length&&a.length===l.length?(a.sort(),l.sort(),ue(a,l,n)):r.length===0&&a.length===0&&s.length===0&&l.length===0}m(Li,"objectEqual");function ye(e){return e===null||typeof e!="object"}m(ye,"isPrimitive");function Hn(e){return e.map(m(function(n){return typeof n=="symbol"?n.toString():n},"mapSymbol"))}m(Hn,"mapSymbols");function Ct(e,t){return typeof e>"u"||e===null?!1:t in Object(e)}m(Ct,"hasProperty");function Ri(e){return e.replace(/([^\\])\[/g,"$1.[").match(/(\\\.|[^.]+?)+/g).map(r=>{if(r==="constructor"||r==="__proto__"||r==="prototype")return{};const i=/^\[(\d+)\]$/.exec(r);let o=null;return i?o={i:parseFloat(i[1])}:o={p:r.replace(/\\([.[\]])/g,"$1")},o})}m(Ri,"parsePath");function Gn(e,t,n){let r=e,s=null;n=typeof n>"u"?t.length:n;for(let i=0;i<n;i++){const o=t[i];r&&(typeof o.p>"u"?r=r[o.i]:r=r[o.p],i===n-1&&(s=r))}return s}m(Gn,"internalGetPathValue");function Wn(e,t){const n=Ri(t),r=n[n.length-1],s={parent:n.length>1?Gn(e,n,n.length-1):e,name:r.p||r.i,value:Gn(e,n)};return s.exists=Ct(s.parent,s.name),s}m(Wn,"getPathInfo");var $i=class cc{constructor(t,n,r,s){return Js(this,"__flags",{}),N(this,"ssfi",r||cc),N(this,"lockSsfi",s),N(this,"object",t),N(this,"message",n),N(this,"eql",j.deepEqual||Pi),Ce(this)}static get includeStack(){return console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead."),j.includeStack}static set includeStack(t){console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead."),j.includeStack=t}static get showDiff(){return console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead."),j.showDiff}static set showDiff(t){console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead."),j.showDiff=t}static addProperty(t,n){zn(this.prototype,t,n)}static addMethod(t,n){Yn(this.prototype,t,n)}static addChainableMethod(t,n,r){Qn(this.prototype,t,n,r)}static overwriteProperty(t,n){Xn(this.prototype,t,n)}static overwriteMethod(t,n){Jn(this.prototype,t,n)}static overwriteChainableMethod(t,n,r){Zn(this.prototype,t,n,r)}assert(t,n,r,s,i,o){const a=Sn(this,arguments);if(o!==!1&&(o=!0),s===void 0&&i===void 0&&(o=!1),j.showDiff!==!0&&(o=!1),!a){n=Dn(this,arguments);const c={actual:Ot(this,arguments),expected:s,showDiff:o},f=nr(this,arguments);throw f&&(c.operator=f),new O(n,c,j.includeStack?this.assert:N(this,"ssfi"))}}get _obj(){return N(this,"object")}set _obj(t){N(this,"object",t)}};m($i,"Assertion");var h=$i,Dt=new EventTarget,Fi=class extends Event{constructor(t,n,r){super(t),this.name=String(n),this.fn=r}};m(Fi,"PluginEvent");var Kn=Fi;function Xe(){return j.useProxy&&typeof Proxy<"u"&&typeof Reflect<"u"}m(Xe,"isProxyEnabled");function zn(e,t,n){n=n===void 0?function(){}:n,Object.defineProperty(e,t,{get:m(function r(){!Xe()&&!N(this,"lockSsfi")&&N(this,"ssfi",r);let s=n.call(this);if(s!==void 0)return s;let i=new h;return Z(this,i),i},"propertyGetter"),configurable:!0}),Dt.dispatchEvent(new Kn("addProperty",t,n))}m(zn,"addProperty");var cu=Object.getOwnPropertyDescriptor(function(){},"length");function Je(e,t,n){return cu.configurable&&Object.defineProperty(e,"length",{get:m(function(){throw Error(n?"Invalid Chai property: "+t+'.length. Due to a compatibility issue, "length" cannot directly follow "'+t+'". Use "'+t+'.lengthOf" instead.':"Invalid Chai property: "+t+'.length. See docs for proper usage of "'+t+'".')},"get")}),e}m(Je,"addLengthGuard");function Bi(e){let t=Object.getOwnPropertyNames(e);function n(s){t.indexOf(s)===-1&&t.push(s)}m(n,"addProperty");let r=Object.getPrototypeOf(e);for(;r!==null;)Object.getOwnPropertyNames(r).forEach(n),r=Object.getPrototypeOf(r);return t}m(Bi,"getProperties");var Vi=["__flags","__methods","_obj","assert"];function Ce(e,t){return Xe()?new Proxy(e,{get:m(function n(r,s){if(typeof s=="string"&&j.proxyExcludedKeys.indexOf(s)===-1&&!Reflect.has(r,s)){if(t)throw Error("Invalid Chai property: "+t+"."+s+'. See docs for proper usage of "'+t+'".');let i=null,o=4;throw Bi(r).forEach(function(a){if(!Object.prototype.hasOwnProperty(a)&&Vi.indexOf(a)===-1){let l=Ui(s,a,o);l<o&&(i=a,o=l)}}),Error(i!==null?"Invalid Chai property: "+s+'. Did you mean "'+i+'"?':"Invalid Chai property: "+s)}return Vi.indexOf(s)===-1&&!N(r,"lockSsfi")&&N(r,"ssfi",n),Reflect.get(r,s)},"proxyGetter")}):e}m(Ce,"proxify");function Ui(e,t,n){if(Math.abs(e.length-t.length)>=n)return n;let r=[];for(let s=0;s<=e.length;s++)r[s]=Array(t.length+1).fill(0),r[s][0]=s;for(let s=0;s<t.length;s++)r[0][s]=s;for(let s=1;s<=e.length;s++){let i=e.charCodeAt(s-1);for(let o=1;o<=t.length;o++){if(Math.abs(s-o)>=n){r[s][o]=n;continue}r[s][o]=Math.min(r[s-1][o]+1,r[s][o-1]+1,r[s-1][o-1]+(i===t.charCodeAt(o-1)?0:1))}}return r[e.length][t.length]}m(Ui,"stringDistanceCapped");function Yn(e,t,n){let r=m(function(){N(this,"lockSsfi")||N(this,"ssfi",r);let s=n.apply(this,arguments);if(s!==void 0)return s;let i=new h;return Z(this,i),i},"methodWrapper");Je(r,t,!1),e[t]=Ce(r,t),Dt.dispatchEvent(new Kn("addMethod",t,n))}m(Yn,"addMethod");function Xn(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t),s=m(function(){},"_super");r&&typeof r.get=="function"&&(s=r.get),Object.defineProperty(e,t,{get:m(function i(){!Xe()&&!N(this,"lockSsfi")&&N(this,"ssfi",i);let o=N(this,"lockSsfi");N(this,"lockSsfi",!0);let a=n(s).call(this);if(N(this,"lockSsfi",o),a!==void 0)return a;let l=new h;return Z(this,l),l},"overwritingPropertyGetter"),configurable:!0})}m(Xn,"overwriteProperty");function Jn(e,t,n){let r=e[t],s=m(function(){throw new Error(t+" is not a function")},"_super");r&&typeof r=="function"&&(s=r);let i=m(function(){N(this,"lockSsfi")||N(this,"ssfi",i);let o=N(this,"lockSsfi");N(this,"lockSsfi",!0);let a=n(s).apply(this,arguments);if(N(this,"lockSsfi",o),a!==void 0)return a;let l=new h;return Z(this,l),l},"overwritingMethodWrapper");Je(i,t,!1),e[t]=Ce(i,t)}m(Jn,"overwriteMethod");var uu=typeof Object.setPrototypeOf=="function",ji=m(function(){},"testFn"),hu=Object.getOwnPropertyNames(ji).filter(function(e){let t=Object.getOwnPropertyDescriptor(ji,e);return typeof t!="object"?!0:!t.configurable}),fu=Function.prototype.call,du=Function.prototype.apply,qi=class extends Kn{constructor(t,n,r,s){super(t,n,r),this.chainingBehavior=s}};m(qi,"PluginAddChainableMethodEvent");var pu=qi;function Qn(e,t,n,r){typeof r!="function"&&(r=m(function(){},"chainingBehavior"));let s={method:n,chainingBehavior:r};e.__methods||(e.__methods={}),e.__methods[t]=s,Object.defineProperty(e,t,{get:m(function(){s.chainingBehavior.call(this);let o=m(function(){N(this,"lockSsfi")||N(this,"ssfi",o);let a=s.method.apply(this,arguments);if(a!==void 0)return a;let l=new h;return Z(this,l),l},"chainableMethodWrapper");if(Je(o,t,!0),uu){let a=Object.create(this);a.call=fu,a.apply=du,Object.setPrototypeOf(o,a)}else Object.getOwnPropertyNames(e).forEach(function(l){if(hu.indexOf(l)!==-1)return;let c=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(o,l,c)});return Z(this,o),Ce(o)},"chainableMethodGetter"),configurable:!0}),Dt.dispatchEvent(new pu("addChainableMethod",t,n,r))}m(Qn,"addChainableMethod");function Zn(e,t,n,r){let s=e.__methods[t],i=s.chainingBehavior;s.chainingBehavior=m(function(){let l=r(i).call(this);if(l!==void 0)return l;let c=new h;return Z(this,c),c},"overwritingChainableMethodGetter");let o=s.method;s.method=m(function(){let l=n(o).apply(this,arguments);if(l!==void 0)return l;let c=new h;return Z(this,c),c},"overwritingChainableMethodWrapper")}m(Zn,"overwriteChainableMethod");function kt(e,t){return I(e)<I(t)?-1:1}m(kt,"compareByInspect");function er(e){return typeof Object.getOwnPropertySymbols!="function"?[]:Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}m(er,"getOwnEnumerablePropertySymbols");function tr(e){return Object.keys(e).concat(er(e))}m(tr,"getOwnEnumerableProperties");var Lt=Number.isNaN;function Hi(e){let t=P(e);return["Array","Object","Function"].indexOf(t)!==-1}m(Hi,"isObjectType");function nr(e,t){let n=N(e,"operator"),r=N(e,"negate"),s=t[3],i=r?t[2]:t[1];if(n)return n;if(typeof i=="function"&&(i=i()),i=i||"",!i||/\shave\s/.test(i))return;let o=Hi(s);return/\snot\s/.test(i)?o?"notDeepStrictEqual":"notStrictEqual":o?"deepStrictEqual":"strictEqual"}m(nr,"getOperator");function Rt(e){return e.name}m(Rt,"getName");function $t(e){return Object.prototype.toString.call(e)==="[object RegExp]"}m($t,"isRegExp");function B(e){return["Number","BigInt"].includes(P(e))}m(B,"isNumeric");var{flag:d}=xt;["to","be","been","is","and","has","have","with","that","which","at","of","same","but","does","still","also"].forEach(function(e){h.addProperty(e)}),h.addProperty("not",function(){d(this,"negate",!0)}),h.addProperty("deep",function(){d(this,"deep",!0)}),h.addProperty("nested",function(){d(this,"nested",!0)}),h.addProperty("own",function(){d(this,"own",!0)}),h.addProperty("ordered",function(){d(this,"ordered",!0)}),h.addProperty("any",function(){d(this,"any",!0),d(this,"all",!1)}),h.addProperty("all",function(){d(this,"all",!0),d(this,"any",!1)});var Gi={function:["function","asyncfunction","generatorfunction","asyncgeneratorfunction"],asyncfunction:["asyncfunction","asyncgeneratorfunction"],generatorfunction:["generatorfunction","asyncgeneratorfunction"],asyncgeneratorfunction:["asyncgeneratorfunction"]};function rr(e,t){t&&d(this,"message",t),e=e.toLowerCase();let n=d(this,"object"),r=~["a","e","i","o","u"].indexOf(e.charAt(0))?"an ":"a ";const s=P(n).toLowerCase();Gi.function.includes(e)?this.assert(Gi[e].includes(s),"expected #{this} to be "+r+e,"expected #{this} not to be "+r+e):this.assert(e===s,"expected #{this} to be "+r+e,"expected #{this} not to be "+r+e)}m(rr,"an"),h.addChainableMethod("an",rr),h.addChainableMethod("a",rr);function Wi(e,t){return Lt(e)&&Lt(t)||e===t}m(Wi,"SameValueZero");function Qe(){d(this,"contains",!0)}m(Qe,"includeChainingBehavior");function Ze(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=P(n).toLowerCase(),s=d(this,"message"),i=d(this,"negate"),o=d(this,"ssfi"),a=d(this,"deep"),l=a?"deep ":"",c=a?d(this,"eql"):Wi;s=s?s+": ":"";let f=!1;switch(r){case"string":f=n.indexOf(e)!==-1;break;case"weakset":if(a)throw new O(s+"unable to use .deep.include with WeakSet",void 0,o);f=n.has(e);break;case"map":n.forEach(function(p){f=f||c(p,e)});break;case"set":a?n.forEach(function(p){f=f||c(p,e)}):f=n.has(e);break;case"array":a?f=n.some(function(p){return c(p,e)}):f=n.indexOf(e)!==-1;break;default:{if(e!==Object(e))throw new O(s+"the given combination of arguments ("+r+" and "+P(e).toLowerCase()+") is invalid for this assertion. You can use an array, a map, an object, a set, a string, or a weakset instead of a "+P(e).toLowerCase(),void 0,o);let p=Object.keys(e),g=null,y=0;if(p.forEach(function(E){let S=new h(n);if(Z(this,S,!0),d(S,"lockSsfi",!0),!i||p.length===1){S.property(E,e[E]);return}try{S.property(E,e[E])}catch(M){if(!K.compatibleConstructor(M,O))throw M;g===null&&(g=M),y++}},this),i&&p.length>1&&y===p.length)throw g;return}}this.assert(f,"expected #{this} to "+l+"include "+I(e),"expected #{this} to not "+l+"include "+I(e))}m(Ze,"include"),h.addChainableMethod("include",Ze,Qe),h.addChainableMethod("contain",Ze,Qe),h.addChainableMethod("contains",Ze,Qe),h.addChainableMethod("includes",Ze,Qe),h.addProperty("ok",function(){this.assert(d(this,"object"),"expected #{this} to be truthy","expected #{this} to be falsy")}),h.addProperty("true",function(){this.assert(d(this,"object")===!0,"expected #{this} to be true","expected #{this} to be false",!d(this,"negate"))}),h.addProperty("numeric",function(){const e=d(this,"object");this.assert(["Number","BigInt"].includes(P(e)),"expected #{this} to be numeric","expected #{this} to not be numeric",!d(this,"negate"))}),h.addProperty("callable",function(){const e=d(this,"object"),t=d(this,"ssfi"),n=d(this,"message"),r=n?`${n}: `:"",s=d(this,"negate"),i=s?`${r}expected ${I(e)} not to be a callable function`:`${r}expected ${I(e)} to be a callable function`,o=["Function","AsyncFunction","GeneratorFunction","AsyncGeneratorFunction"].includes(P(e));if(o&&s||!o&&!s)throw new O(i,void 0,t)}),h.addProperty("false",function(){this.assert(d(this,"object")===!1,"expected #{this} to be false","expected #{this} to be true",!!d(this,"negate"))}),h.addProperty("null",function(){this.assert(d(this,"object")===null,"expected #{this} to be null","expected #{this} not to be null")}),h.addProperty("undefined",function(){this.assert(d(this,"object")===void 0,"expected #{this} to be undefined","expected #{this} not to be undefined")}),h.addProperty("NaN",function(){this.assert(Lt(d(this,"object")),"expected #{this} to be NaN","expected #{this} not to be NaN")});function sr(){let e=d(this,"object");this.assert(e!=null,"expected #{this} to exist","expected #{this} to not exist")}m(sr,"assertExist"),h.addProperty("exist",sr),h.addProperty("exists",sr),h.addProperty("empty",function(){let e=d(this,"object"),t=d(this,"ssfi"),n=d(this,"message"),r;switch(n=n?n+": ":"",P(e).toLowerCase()){case"array":case"string":r=e.length;break;case"map":case"set":r=e.size;break;case"weakmap":case"weakset":throw new O(n+".empty was passed a weak collection",void 0,t);case"function":{const s=n+".empty was passed a function "+Rt(e);throw new O(s.trim(),void 0,t)}default:if(e!==Object(e))throw new O(n+".empty was passed non-string primitive "+I(e),void 0,t);r=Object.keys(e).length}this.assert(r===0,"expected #{this} to be empty","expected #{this} not to be empty")});function ir(){let e=d(this,"object"),t=P(e);this.assert(t==="Arguments","expected #{this} to be arguments but got "+t,"expected #{this} to not be arguments")}m(ir,"checkArguments"),h.addProperty("arguments",ir),h.addProperty("Arguments",ir);function Ft(e,t){t&&d(this,"message",t);let n=d(this,"object");if(d(this,"deep")){let r=d(this,"lockSsfi");d(this,"lockSsfi",!0),this.eql(e),d(this,"lockSsfi",r)}else this.assert(e===n,"expected #{this} to equal #{exp}","expected #{this} to not equal #{exp}",e,this._obj,!0)}m(Ft,"assertEqual"),h.addMethod("equal",Ft),h.addMethod("equals",Ft),h.addMethod("eq",Ft);function or(e,t){t&&d(this,"message",t);let n=d(this,"eql");this.assert(n(e,d(this,"object")),"expected #{this} to deeply equal #{exp}","expected #{this} to not deeply equal #{exp}",e,this._obj,!0)}m(or,"assertEql"),h.addMethod("eql",or),h.addMethod("eqls",or);function Bt(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=d(this,"doLength"),s=d(this,"message"),i=s?s+": ":"",o=d(this,"ssfi"),a=P(n).toLowerCase(),l=P(e).toLowerCase();if(r&&a!=="map"&&a!=="set"&&new h(n,s,o,!0).to.have.property("length"),!r&&a==="date"&&l!=="date")throw new O(i+"the argument to above must be a date",void 0,o);if(!B(e)&&(r||B(n)))throw new O(i+"the argument to above must be a number",void 0,o);if(!r&&a!=="date"&&!B(n)){let c=a==="string"?"'"+n+"'":n;throw new O(i+"expected "+c+" to be a number or a date",void 0,o)}if(r){let c="length",f;a==="map"||a==="set"?(c="size",f=n.size):f=n.length,this.assert(f>e,"expected #{this} to have a "+c+" above #{exp} but got #{act}","expected #{this} to not have a "+c+" above #{exp}",e,f)}else this.assert(n>e,"expected #{this} to be above #{exp}","expected #{this} to be at most #{exp}",e)}m(Bt,"assertAbove"),h.addMethod("above",Bt),h.addMethod("gt",Bt),h.addMethod("greaterThan",Bt);function Vt(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=d(this,"doLength"),s=d(this,"message"),i=s?s+": ":"",o=d(this,"ssfi"),a=P(n).toLowerCase(),l=P(e).toLowerCase(),c,f=!0;if(r&&a!=="map"&&a!=="set"&&new h(n,s,o,!0).to.have.property("length"),!r&&a==="date"&&l!=="date")c=i+"the argument to least must be a date";else if(!B(e)&&(r||B(n)))c=i+"the argument to least must be a number";else if(!r&&a!=="date"&&!B(n)){let p=a==="string"?"'"+n+"'":n;c=i+"expected "+p+" to be a number or a date"}else f=!1;if(f)throw new O(c,void 0,o);if(r){let p="length",g;a==="map"||a==="set"?(p="size",g=n.size):g=n.length,this.assert(g>=e,"expected #{this} to have a "+p+" at least #{exp} but got #{act}","expected #{this} to have a "+p+" below #{exp}",e,g)}else this.assert(n>=e,"expected #{this} to be at least #{exp}","expected #{this} to be below #{exp}",e)}m(Vt,"assertLeast"),h.addMethod("least",Vt),h.addMethod("gte",Vt),h.addMethod("greaterThanOrEqual",Vt);function Ut(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=d(this,"doLength"),s=d(this,"message"),i=s?s+": ":"",o=d(this,"ssfi"),a=P(n).toLowerCase(),l=P(e).toLowerCase(),c,f=!0;if(r&&a!=="map"&&a!=="set"&&new h(n,s,o,!0).to.have.property("length"),!r&&a==="date"&&l!=="date")c=i+"the argument to below must be a date";else if(!B(e)&&(r||B(n)))c=i+"the argument to below must be a number";else if(!r&&a!=="date"&&!B(n)){let p=a==="string"?"'"+n+"'":n;c=i+"expected "+p+" to be a number or a date"}else f=!1;if(f)throw new O(c,void 0,o);if(r){let p="length",g;a==="map"||a==="set"?(p="size",g=n.size):g=n.length,this.assert(g<e,"expected #{this} to have a "+p+" below #{exp} but got #{act}","expected #{this} to not have a "+p+" below #{exp}",e,g)}else this.assert(n<e,"expected #{this} to be below #{exp}","expected #{this} to be at least #{exp}",e)}m(Ut,"assertBelow"),h.addMethod("below",Ut),h.addMethod("lt",Ut),h.addMethod("lessThan",Ut);function jt(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=d(this,"doLength"),s=d(this,"message"),i=s?s+": ":"",o=d(this,"ssfi"),a=P(n).toLowerCase(),l=P(e).toLowerCase(),c,f=!0;if(r&&a!=="map"&&a!=="set"&&new h(n,s,o,!0).to.have.property("length"),!r&&a==="date"&&l!=="date")c=i+"the argument to most must be a date";else if(!B(e)&&(r||B(n)))c=i+"the argument to most must be a number";else if(!r&&a!=="date"&&!B(n)){let p=a==="string"?"'"+n+"'":n;c=i+"expected "+p+" to be a number or a date"}else f=!1;if(f)throw new O(c,void 0,o);if(r){let p="length",g;a==="map"||a==="set"?(p="size",g=n.size):g=n.length,this.assert(g<=e,"expected #{this} to have a "+p+" at most #{exp} but got #{act}","expected #{this} to have a "+p+" above #{exp}",e,g)}else this.assert(n<=e,"expected #{this} to be at most #{exp}","expected #{this} to be above #{exp}",e)}m(jt,"assertMost"),h.addMethod("most",jt),h.addMethod("lte",jt),h.addMethod("lessThanOrEqual",jt),h.addMethod("within",function(e,t,n){n&&d(this,"message",n);let r=d(this,"object"),s=d(this,"doLength"),i=d(this,"message"),o=i?i+": ":"",a=d(this,"ssfi"),l=P(r).toLowerCase(),c=P(e).toLowerCase(),f=P(t).toLowerCase(),p,g=!0,y=c==="date"&&f==="date"?e.toISOString()+".."+t.toISOString():e+".."+t;if(s&&l!=="map"&&l!=="set"&&new h(r,i,a,!0).to.have.property("length"),!s&&l==="date"&&(c!=="date"||f!=="date"))p=o+"the arguments to within must be dates";else if((!B(e)||!B(t))&&(s||B(r)))p=o+"the arguments to within must be numbers";else if(!s&&l!=="date"&&!B(r)){let E=l==="string"?"'"+r+"'":r;p=o+"expected "+E+" to be a number or a date"}else g=!1;if(g)throw new O(p,void 0,a);if(s){let E="length",S;l==="map"||l==="set"?(E="size",S=r.size):S=r.length,this.assert(S>=e&&S<=t,"expected #{this} to have a "+E+" within "+y,"expected #{this} to not have a "+E+" within "+y)}else this.assert(r>=e&&r<=t,"expected #{this} to be within "+y,"expected #{this} to not be within "+y)});function ar(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=d(this,"ssfi"),s=d(this,"message"),i;try{i=n instanceof e}catch(a){throw a instanceof TypeError?(s=s?s+": ":"",new O(s+"The instanceof assertion needs a constructor but "+P(e)+" was given.",void 0,r)):a}let o=Rt(e);o==null&&(o="an unnamed constructor"),this.assert(i,"expected #{this} to be an instance of "+o,"expected #{this} to not be an instance of "+o)}m(ar,"assertInstanceOf"),h.addMethod("instanceof",ar),h.addMethod("instanceOf",ar);function lr(e,t,n){n&&d(this,"message",n);let r=d(this,"nested"),s=d(this,"own"),i=d(this,"message"),o=d(this,"object"),a=d(this,"ssfi"),l=typeof e;if(i=i?i+": ":"",r){if(l!=="string")throw new O(i+"the argument to property must be a string when using nested syntax",void 0,a)}else if(l!=="string"&&l!=="number"&&l!=="symbol")throw new O(i+"the argument to property must be a string, number, or symbol",void 0,a);if(r&&s)throw new O(i+'The "nested" and "own" flags cannot be combined.',void 0,a);if(o==null)throw new O(i+"Target cannot be null or undefined.",void 0,a);let c=d(this,"deep"),f=d(this,"negate"),p=r?Wn(o,e):null,g=r?p.value:o[e],y=c?d(this,"eql"):(M,x)=>M===x,E="";c&&(E+="deep "),s&&(E+="own "),r&&(E+="nested "),E+="property ";let S;s?S=Object.prototype.hasOwnProperty.call(o,e):r?S=p.exists:S=Ct(o,e),(!f||arguments.length===1)&&this.assert(S,"expected #{this} to have "+E+I(e),"expected #{this} to not have "+E+I(e)),arguments.length>1&&this.assert(S&&y(t,g),"expected #{this} to have "+E+I(e)+" of #{exp}, but got #{act}","expected #{this} to not have "+E+I(e)+" of #{act}",t,g),d(this,"object",g)}m(lr,"assertProperty"),h.addMethod("property",lr);function cr(e,t,n){d(this,"own",!0),lr.apply(this,arguments)}m(cr,"assertOwnProperty"),h.addMethod("ownProperty",cr),h.addMethod("haveOwnProperty",cr);function ur(e,t,n){typeof t=="string"&&(n=t,t=null),n&&d(this,"message",n);let r=d(this,"object"),s=Object.getOwnPropertyDescriptor(Object(r),e),i=d(this,"eql");s&&t?this.assert(i(t,s),"expected the own property descriptor for "+I(e)+" on #{this} to match "+I(t)+", got "+I(s),"expected the own property descriptor for "+I(e)+" on #{this} to not match "+I(t),t,s,!0):this.assert(s,"expected #{this} to have an own property descriptor for "+I(e),"expected #{this} to not have an own property descriptor for "+I(e)),d(this,"object",s)}m(ur,"assertOwnPropertyDescriptor"),h.addMethod("ownPropertyDescriptor",ur),h.addMethod("haveOwnPropertyDescriptor",ur);function hr(){d(this,"doLength",!0)}m(hr,"assertLengthChain");function fr(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=P(n).toLowerCase(),s=d(this,"message"),i=d(this,"ssfi"),o="length",a;switch(r){case"map":case"set":o="size",a=n.size;break;default:new h(n,s,i,!0).to.have.property("length"),a=n.length}this.assert(a==e,"expected #{this} to have a "+o+" of #{exp} but got #{act}","expected #{this} to not have a "+o+" of #{act}",e,a)}m(fr,"assertLength"),h.addChainableMethod("length",fr,hr),h.addChainableMethod("lengthOf",fr,hr);function dr(e,t){t&&d(this,"message",t);let n=d(this,"object");this.assert(e.exec(n),"expected #{this} to match "+e,"expected #{this} not to match "+e)}m(dr,"assertMatch"),h.addMethod("match",dr),h.addMethod("matches",dr),h.addMethod("string",function(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=d(this,"message"),s=d(this,"ssfi");new h(n,r,s,!0).is.a("string"),this.assert(~n.indexOf(e),"expected #{this} to contain "+I(e),"expected #{this} to not contain "+I(e))});function pr(e){let t=d(this,"object"),n=P(t),r=P(e),s=d(this,"ssfi"),i=d(this,"deep"),o,a="",l,c=!0,f=d(this,"message");f=f?f+": ":"";let p=f+"when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments";if(n==="Map"||n==="Set")a=i?"deeply ":"",l=[],t.forEach(function(x,C){l.push(C)}),r!=="Array"&&(e=Array.prototype.slice.call(arguments));else{switch(l=tr(t),r){case"Array":if(arguments.length>1)throw new O(p,void 0,s);break;case"Object":if(arguments.length>1)throw new O(p,void 0,s);e=Object.keys(e);break;default:e=Array.prototype.slice.call(arguments)}e=e.map(function(x){return typeof x=="symbol"?x:String(x)})}if(!e.length)throw new O(f+"keys required",void 0,s);let g=e.length,y=d(this,"any"),E=d(this,"all"),S=e,M=i?d(this,"eql"):(x,C)=>x===C;if(!y&&!E&&(E=!0),y&&(c=S.some(function(x){return l.some(function(C){return M(x,C)})})),E&&(c=S.every(function(x){return l.some(function(C){return M(x,C)})}),d(this,"contains")||(c=c&&e.length==l.length)),g>1){e=e.map(function(C){return I(C)});let x=e.pop();E&&(o=e.join(", ")+", and "+x),y&&(o=e.join(", ")+", or "+x)}else o=I(e[0]);o=(g>1?"keys ":"key ")+o,o=(d(this,"contains")?"contain ":"have ")+o,this.assert(c,"expected #{this} to "+a+o,"expected #{this} to not "+a+o,S.slice(0).sort(kt),l.sort(kt),!0)}m(pr,"assertKeys"),h.addMethod("keys",pr),h.addMethod("key",pr);function qt(e,t,n){n&&d(this,"message",n);let r=d(this,"object"),s=d(this,"ssfi"),i=d(this,"message"),o=d(this,"negate")||!1;new h(r,i,s,!0).is.a("function"),($t(e)||typeof e=="string")&&(t=e,e=null);let a,l=!1;try{r()}catch(y){l=!0,a=y}let c=e===void 0&&t===void 0,f=!!(e&&t),p=!1,g=!1;if(c||!c&&!o){let y="an error";e instanceof Error?y="#{exp}":e&&(y=K.getConstructorName(e));let E=a;if(a instanceof Error)E=a.toString();else if(typeof a=="string")E=a;else if(a&&(typeof a=="object"||typeof a=="function"))try{E=K.getConstructorName(a)}catch{}this.assert(l,"expected #{this} to throw "+y,"expected #{this} to not throw an error but #{act} was thrown",e&&e.toString(),E)}if(e&&a&&(e instanceof Error&&K.compatibleInstance(a,e)===o&&(f&&o?p=!0:this.assert(o,"expected #{this} to throw #{exp} but #{act} was thrown","expected #{this} to not throw #{exp}"+(a&&!o?" but #{act} was thrown":""),e.toString(),a.toString())),K.compatibleConstructor(a,e)===o&&(f&&o?p=!0:this.assert(o,"expected #{this} to throw #{exp} but #{act} was thrown","expected #{this} to not throw #{exp}"+(a?" but #{act} was thrown":""),e instanceof Error?e.toString():e&&K.getConstructorName(e),a instanceof Error?a.toString():a&&K.getConstructorName(a)))),a&&t!==void 0&&t!==null){let y="including";$t(t)&&(y="matching"),K.compatibleMessage(a,t)===o&&(f&&o?g=!0:this.assert(o,"expected #{this} to throw error "+y+" #{exp} but got #{act}","expected #{this} to throw error not "+y+" #{exp}",t,K.getMessage(a)))}p&&g&&this.assert(o,"expected #{this} to throw #{exp} but #{act} was thrown","expected #{this} to not throw #{exp}"+(a?" but #{act} was thrown":""),e instanceof Error?e.toString():e&&K.getConstructorName(e),a instanceof Error?a.toString():a&&K.getConstructorName(a)),d(this,"object",a)}m(qt,"assertThrows"),h.addMethod("throw",qt),h.addMethod("throws",qt),h.addMethod("Throw",qt);function mr(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=d(this,"itself"),s=typeof n=="function"&&!r?n.prototype[e]:n[e];this.assert(typeof s=="function","expected #{this} to respond to "+I(e),"expected #{this} to not respond to "+I(e))}m(mr,"respondTo"),h.addMethod("respondTo",mr),h.addMethod("respondsTo",mr),h.addProperty("itself",function(){d(this,"itself",!0)});function gr(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=e(n);this.assert(r,"expected #{this} to satisfy "+we(e),"expected #{this} to not satisfy"+we(e),!d(this,"negate"),r)}m(gr,"satisfy"),h.addMethod("satisfy",gr),h.addMethod("satisfies",gr);function wr(e,t,n){n&&d(this,"message",n);let r=d(this,"object"),s=d(this,"message"),i=d(this,"ssfi");new h(r,s,i,!0).is.numeric;let o="A `delta` value is required for `closeTo`";if(t==null)throw new O(s?`${s}: ${o}`:o,void 0,i);if(new h(t,s,i,!0).is.numeric,o="A `expected` value is required for `closeTo`",e==null)throw new O(s?`${s}: ${o}`:o,void 0,i);new h(e,s,i,!0).is.numeric;const a=m(c=>c<0?-c:c,"abs"),l=m(c=>parseFloat(parseFloat(c).toPrecision(12)),"strip");this.assert(l(a(r-e))<=t,"expected #{this} to be close to "+e+" +/- "+t,"expected #{this} not to be close to "+e+" +/- "+t)}m(wr,"closeTo"),h.addMethod("closeTo",wr),h.addMethod("approximately",wr);function Ki(e,t,n,r,s){let i=Array.from(t),o=Array.from(e);if(!r){if(o.length!==i.length)return!1;i=i.slice()}return o.every(function(a,l){if(s)return n?n(a,i[l]):a===i[l];if(!n){let c=i.indexOf(a);return c===-1?!1:(r||i.splice(c,1),!0)}return i.some(function(c,f){return n(a,c)?(r||i.splice(f,1),!0):!1})})}m(Ki,"isSubsetOf"),h.addMethod("members",function(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=d(this,"message"),s=d(this,"ssfi");new h(n,r,s,!0).to.be.iterable,new h(e,r,s,!0).to.be.iterable;let i=d(this,"contains"),o=d(this,"ordered"),a,l,c;i?(a=o?"an ordered superset":"a superset",l="expected #{this} to be "+a+" of #{exp}",c="expected #{this} to not be "+a+" of #{exp}"):(a=o?"ordered members":"members",l="expected #{this} to have the same "+a+" as #{exp}",c="expected #{this} to not have the same "+a+" as #{exp}");let f=d(this,"deep")?d(this,"eql"):void 0;this.assert(Ki(e,n,f,i,o),l,c,e,n,!0)}),h.addProperty("iterable",function(e){e&&d(this,"message",e);let t=d(this,"object");this.assert(t!=null&&t[Symbol.iterator],"expected #{this} to be an iterable","expected #{this} to not be an iterable",t)});function zi(e,t){t&&d(this,"message",t);let n=d(this,"object"),r=d(this,"message"),s=d(this,"ssfi"),i=d(this,"contains"),o=d(this,"deep"),a=d(this,"eql");new h(e,r,s,!0).to.be.an("array"),i?this.assert(e.some(function(l){return n.indexOf(l)>-1}),"expected #{this} to contain one of #{exp}","expected #{this} to not contain one of #{exp}",e,n):o?this.assert(e.some(function(l){return a(n,l)}),"expected #{this} to deeply equal one of #{exp}","expected #{this} to deeply equal one of #{exp}",e,n):this.assert(e.indexOf(n)>-1,"expected #{this} to be one of #{exp}","expected #{this} to not be one of #{exp}",e,n)}m(zi,"oneOf"),h.addMethod("oneOf",zi);function yr(e,t,n){n&&d(this,"message",n);let r=d(this,"object"),s=d(this,"message"),i=d(this,"ssfi");new h(r,s,i,!0).is.a("function");let o;t?(new h(e,s,i,!0).to.have.property(t),o=e[t]):(new h(e,s,i,!0).is.a("function"),o=e()),r();let a=t==null?e():e[t],l=t==null?o:"."+t;d(this,"deltaMsgObj",l),d(this,"initialDeltaValue",o),d(this,"finalDeltaValue",a),d(this,"deltaBehavior","change"),d(this,"realDelta",a!==o),this.assert(o!==a,"expected "+l+" to change","expected "+l+" to not change")}m(yr,"assertChanges"),h.addMethod("change",yr),h.addMethod("changes",yr);function br(e,t,n){n&&d(this,"message",n);let r=d(this,"object"),s=d(this,"message"),i=d(this,"ssfi");new h(r,s,i,!0).is.a("function");let o;t?(new h(e,s,i,!0).to.have.property(t),o=e[t]):(new h(e,s,i,!0).is.a("function"),o=e()),new h(o,s,i,!0).is.a("number"),r();let a=t==null?e():e[t],l=t==null?o:"."+t;d(this,"deltaMsgObj",l),d(this,"initialDeltaValue",o),d(this,"finalDeltaValue",a),d(this,"deltaBehavior","increase"),d(this,"realDelta",a-o),this.assert(a-o>0,"expected "+l+" to increase","expected "+l+" to not increase")}m(br,"assertIncreases"),h.addMethod("increase",br),h.addMethod("increases",br);function vr(e,t,n){n&&d(this,"message",n);let r=d(this,"object"),s=d(this,"message"),i=d(this,"ssfi");new h(r,s,i,!0).is.a("function");let o;t?(new h(e,s,i,!0).to.have.property(t),o=e[t]):(new h(e,s,i,!0).is.a("function"),o=e()),new h(o,s,i,!0).is.a("number"),r();let a=t==null?e():e[t],l=t==null?o:"."+t;d(this,"deltaMsgObj",l),d(this,"initialDeltaValue",o),d(this,"finalDeltaValue",a),d(this,"deltaBehavior","decrease"),d(this,"realDelta",o-a),this.assert(a-o<0,"expected "+l+" to decrease","expected "+l+" to not decrease")}m(vr,"assertDecreases"),h.addMethod("decrease",vr),h.addMethod("decreases",vr);function Yi(e,t){t&&d(this,"message",t);let n=d(this,"deltaMsgObj"),r=d(this,"initialDeltaValue"),s=d(this,"finalDeltaValue"),i=d(this,"deltaBehavior"),o=d(this,"realDelta"),a;i==="change"?a=Math.abs(s-r)===Math.abs(e):a=o===Math.abs(e),this.assert(a,"expected "+n+" to "+i+" by "+e,"expected "+n+" to not "+i+" by "+e)}m(Yi,"assertDelta"),h.addMethod("by",Yi),h.addProperty("extensible",function(){let e=d(this,"object"),t=e===Object(e)&&Object.isExtensible(e);this.assert(t,"expected #{this} to be extensible","expected #{this} to not be extensible")}),h.addProperty("sealed",function(){let e=d(this,"object"),t=e===Object(e)?Object.isSealed(e):!0;this.assert(t,"expected #{this} to be sealed","expected #{this} to not be sealed")}),h.addProperty("frozen",function(){let e=d(this,"object"),t=e===Object(e)?Object.isFrozen(e):!0;this.assert(t,"expected #{this} to be frozen","expected #{this} to not be frozen")}),h.addProperty("finite",function(e){let t=d(this,"object");this.assert(typeof t=="number"&&isFinite(t),"expected #{this} to be a finite number","expected #{this} to not be a finite number")});function Ht(e,t){return e===t?!0:typeof t!=typeof e?!1:typeof e!="object"||e===null?e===t:t?Array.isArray(e)?Array.isArray(t)?e.every(function(n){return t.some(function(r){return Ht(n,r)})}):!1:e instanceof Date?t instanceof Date?e.getTime()===t.getTime():!1:Object.keys(e).every(function(n){let r=e[n],s=t[n];return typeof r=="object"&&r!==null&&s!==null?Ht(r,s):typeof r=="function"?r(s):s===r}):!1}m(Ht,"compareSubset"),h.addMethod("containSubset",function(e){const t=N(this,"object"),n=j.showDiff;this.assert(Ht(e,t),"expected #{act} to contain subset #{exp}","expected #{act} to not contain subset #{exp}",e,t,n)});function De(e,t){return new h(e,t)}m(De,"expect"),De.fail=function(e,t,n,r){throw arguments.length<2&&(n=e,e=void 0),n=n||"expect.fail()",new O(n,{actual:e,expected:t,operator:r},De.fail)};var Xi={};_n(Xi,{Should:()=>gu,should:()=>mu});function Er(){function e(){return this instanceof String||this instanceof Number||this instanceof Boolean||typeof Symbol=="function"&&this instanceof Symbol||typeof BigInt=="function"&&this instanceof BigInt?new h(this.valueOf(),null,e):new h(this,null,e)}m(e,"shouldGetter");function t(r){Object.defineProperty(this,"should",{value:r,enumerable:!0,configurable:!0,writable:!0})}m(t,"shouldSetter"),Object.defineProperty(Object.prototype,"should",{set:t,get:e,configurable:!0});let n={};return n.fail=function(r,s,i,o){throw arguments.length<2&&(i=r,r=void 0),i=i||"should.fail()",new O(i,{actual:r,expected:s,operator:o},n.fail)},n.equal=function(r,s,i){new h(r,i).to.equal(s)},n.Throw=function(r,s,i,o){new h(r,o).to.Throw(s,i)},n.exist=function(r,s){new h(r,s).to.exist},n.not={},n.not.equal=function(r,s,i){new h(r,i).to.not.equal(s)},n.not.Throw=function(r,s,i,o){new h(r,o).to.not.Throw(s,i)},n.not.exist=function(r,s){new h(r,s).to.not.exist},n.throw=n.Throw,n.not.throw=n.not.Throw,n}m(Er,"loadShould");var mu=Er,gu=Er;function u(e,t){new h(null,null,u,!0).assert(e,t,"[ negation message unavailable ]")}m(u,"assert"),u.fail=function(e,t,n,r){throw arguments.length<2&&(n=e,e=void 0),n=n||"assert.fail()",new O(n,{actual:e,expected:t,operator:r},u.fail)},u.isOk=function(e,t){new h(e,t,u.isOk,!0).is.ok},u.isNotOk=function(e,t){new h(e,t,u.isNotOk,!0).is.not.ok},u.equal=function(e,t,n){let r=new h(e,n,u.equal,!0);r.assert(t==N(r,"object"),"expected #{this} to equal #{exp}","expected #{this} to not equal #{act}",t,e,!0)},u.notEqual=function(e,t,n){let r=new h(e,n,u.notEqual,!0);r.assert(t!=N(r,"object"),"expected #{this} to not equal #{exp}","expected #{this} to equal #{act}",t,e,!0)},u.strictEqual=function(e,t,n){new h(e,n,u.strictEqual,!0).to.equal(t)},u.notStrictEqual=function(e,t,n){new h(e,n,u.notStrictEqual,!0).to.not.equal(t)},u.deepEqual=u.deepStrictEqual=function(e,t,n){new h(e,n,u.deepEqual,!0).to.eql(t)},u.notDeepEqual=function(e,t,n){new h(e,n,u.notDeepEqual,!0).to.not.eql(t)},u.isAbove=function(e,t,n){new h(e,n,u.isAbove,!0).to.be.above(t)},u.isAtLeast=function(e,t,n){new h(e,n,u.isAtLeast,!0).to.be.least(t)},u.isBelow=function(e,t,n){new h(e,n,u.isBelow,!0).to.be.below(t)},u.isAtMost=function(e,t,n){new h(e,n,u.isAtMost,!0).to.be.most(t)},u.isTrue=function(e,t){new h(e,t,u.isTrue,!0).is.true},u.isNotTrue=function(e,t){new h(e,t,u.isNotTrue,!0).to.not.equal(!0)},u.isFalse=function(e,t){new h(e,t,u.isFalse,!0).is.false},u.isNotFalse=function(e,t){new h(e,t,u.isNotFalse,!0).to.not.equal(!1)},u.isNull=function(e,t){new h(e,t,u.isNull,!0).to.equal(null)},u.isNotNull=function(e,t){new h(e,t,u.isNotNull,!0).to.not.equal(null)},u.isNaN=function(e,t){new h(e,t,u.isNaN,!0).to.be.NaN},u.isNotNaN=function(e,t){new h(e,t,u.isNotNaN,!0).not.to.be.NaN},u.exists=function(e,t){new h(e,t,u.exists,!0).to.exist},u.notExists=function(e,t){new h(e,t,u.notExists,!0).to.not.exist},u.isUndefined=function(e,t){new h(e,t,u.isUndefined,!0).to.equal(void 0)},u.isDefined=function(e,t){new h(e,t,u.isDefined,!0).to.not.equal(void 0)},u.isCallable=function(e,t){new h(e,t,u.isCallable,!0).is.callable},u.isNotCallable=function(e,t){new h(e,t,u.isNotCallable,!0).is.not.callable},u.isObject=function(e,t){new h(e,t,u.isObject,!0).to.be.a("object")},u.isNotObject=function(e,t){new h(e,t,u.isNotObject,!0).to.not.be.a("object")},u.isArray=function(e,t){new h(e,t,u.isArray,!0).to.be.an("array")},u.isNotArray=function(e,t){new h(e,t,u.isNotArray,!0).to.not.be.an("array")},u.isString=function(e,t){new h(e,t,u.isString,!0).to.be.a("string")},u.isNotString=function(e,t){new h(e,t,u.isNotString,!0).to.not.be.a("string")},u.isNumber=function(e,t){new h(e,t,u.isNumber,!0).to.be.a("number")},u.isNotNumber=function(e,t){new h(e,t,u.isNotNumber,!0).to.not.be.a("number")},u.isNumeric=function(e,t){new h(e,t,u.isNumeric,!0).is.numeric},u.isNotNumeric=function(e,t){new h(e,t,u.isNotNumeric,!0).is.not.numeric},u.isFinite=function(e,t){new h(e,t,u.isFinite,!0).to.be.finite},u.isBoolean=function(e,t){new h(e,t,u.isBoolean,!0).to.be.a("boolean")},u.isNotBoolean=function(e,t){new h(e,t,u.isNotBoolean,!0).to.not.be.a("boolean")},u.typeOf=function(e,t,n){new h(e,n,u.typeOf,!0).to.be.a(t)},u.notTypeOf=function(e,t,n){new h(e,n,u.notTypeOf,!0).to.not.be.a(t)},u.instanceOf=function(e,t,n){new h(e,n,u.instanceOf,!0).to.be.instanceOf(t)},u.notInstanceOf=function(e,t,n){new h(e,n,u.notInstanceOf,!0).to.not.be.instanceOf(t)},u.include=function(e,t,n){new h(e,n,u.include,!0).include(t)},u.notInclude=function(e,t,n){new h(e,n,u.notInclude,!0).not.include(t)},u.deepInclude=function(e,t,n){new h(e,n,u.deepInclude,!0).deep.include(t)},u.notDeepInclude=function(e,t,n){new h(e,n,u.notDeepInclude,!0).not.deep.include(t)},u.nestedInclude=function(e,t,n){new h(e,n,u.nestedInclude,!0).nested.include(t)},u.notNestedInclude=function(e,t,n){new h(e,n,u.notNestedInclude,!0).not.nested.include(t)},u.deepNestedInclude=function(e,t,n){new h(e,n,u.deepNestedInclude,!0).deep.nested.include(t)},u.notDeepNestedInclude=function(e,t,n){new h(e,n,u.notDeepNestedInclude,!0).not.deep.nested.include(t)},u.ownInclude=function(e,t,n){new h(e,n,u.ownInclude,!0).own.include(t)},u.notOwnInclude=function(e,t,n){new h(e,n,u.notOwnInclude,!0).not.own.include(t)},u.deepOwnInclude=function(e,t,n){new h(e,n,u.deepOwnInclude,!0).deep.own.include(t)},u.notDeepOwnInclude=function(e,t,n){new h(e,n,u.notDeepOwnInclude,!0).not.deep.own.include(t)},u.match=function(e,t,n){new h(e,n,u.match,!0).to.match(t)},u.notMatch=function(e,t,n){new h(e,n,u.notMatch,!0).to.not.match(t)},u.property=function(e,t,n){new h(e,n,u.property,!0).to.have.property(t)},u.notProperty=function(e,t,n){new h(e,n,u.notProperty,!0).to.not.have.property(t)},u.propertyVal=function(e,t,n,r){new h(e,r,u.propertyVal,!0).to.have.property(t,n)},u.notPropertyVal=function(e,t,n,r){new h(e,r,u.notPropertyVal,!0).to.not.have.property(t,n)},u.deepPropertyVal=function(e,t,n,r){new h(e,r,u.deepPropertyVal,!0).to.have.deep.property(t,n)},u.notDeepPropertyVal=function(e,t,n,r){new h(e,r,u.notDeepPropertyVal,!0).to.not.have.deep.property(t,n)},u.ownProperty=function(e,t,n){new h(e,n,u.ownProperty,!0).to.have.own.property(t)},u.notOwnProperty=function(e,t,n){new h(e,n,u.notOwnProperty,!0).to.not.have.own.property(t)},u.ownPropertyVal=function(e,t,n,r){new h(e,r,u.ownPropertyVal,!0).to.have.own.property(t,n)},u.notOwnPropertyVal=function(e,t,n,r){new h(e,r,u.notOwnPropertyVal,!0).to.not.have.own.property(t,n)},u.deepOwnPropertyVal=function(e,t,n,r){new h(e,r,u.deepOwnPropertyVal,!0).to.have.deep.own.property(t,n)},u.notDeepOwnPropertyVal=function(e,t,n,r){new h(e,r,u.notDeepOwnPropertyVal,!0).to.not.have.deep.own.property(t,n)},u.nestedProperty=function(e,t,n){new h(e,n,u.nestedProperty,!0).to.have.nested.property(t)},u.notNestedProperty=function(e,t,n){new h(e,n,u.notNestedProperty,!0).to.not.have.nested.property(t)},u.nestedPropertyVal=function(e,t,n,r){new h(e,r,u.nestedPropertyVal,!0).to.have.nested.property(t,n)},u.notNestedPropertyVal=function(e,t,n,r){new h(e,r,u.notNestedPropertyVal,!0).to.not.have.nested.property(t,n)},u.deepNestedPropertyVal=function(e,t,n,r){new h(e,r,u.deepNestedPropertyVal,!0).to.have.deep.nested.property(t,n)},u.notDeepNestedPropertyVal=function(e,t,n,r){new h(e,r,u.notDeepNestedPropertyVal,!0).to.not.have.deep.nested.property(t,n)},u.lengthOf=function(e,t,n){new h(e,n,u.lengthOf,!0).to.have.lengthOf(t)},u.hasAnyKeys=function(e,t,n){new h(e,n,u.hasAnyKeys,!0).to.have.any.keys(t)},u.hasAllKeys=function(e,t,n){new h(e,n,u.hasAllKeys,!0).to.have.all.keys(t)},u.containsAllKeys=function(e,t,n){new h(e,n,u.containsAllKeys,!0).to.contain.all.keys(t)},u.doesNotHaveAnyKeys=function(e,t,n){new h(e,n,u.doesNotHaveAnyKeys,!0).to.not.have.any.keys(t)},u.doesNotHaveAllKeys=function(e,t,n){new h(e,n,u.doesNotHaveAllKeys,!0).to.not.have.all.keys(t)},u.hasAnyDeepKeys=function(e,t,n){new h(e,n,u.hasAnyDeepKeys,!0).to.have.any.deep.keys(t)},u.hasAllDeepKeys=function(e,t,n){new h(e,n,u.hasAllDeepKeys,!0).to.have.all.deep.keys(t)},u.containsAllDeepKeys=function(e,t,n){new h(e,n,u.containsAllDeepKeys,!0).to.contain.all.deep.keys(t)},u.doesNotHaveAnyDeepKeys=function(e,t,n){new h(e,n,u.doesNotHaveAnyDeepKeys,!0).to.not.have.any.deep.keys(t)},u.doesNotHaveAllDeepKeys=function(e,t,n){new h(e,n,u.doesNotHaveAllDeepKeys,!0).to.not.have.all.deep.keys(t)},u.throws=function(e,t,n,r){(typeof t=="string"||t instanceof RegExp)&&(n=t,t=null);let s=new h(e,r,u.throws,!0).to.throw(t,n);return N(s,"object")},u.doesNotThrow=function(e,t,n,r){(typeof t=="string"||t instanceof RegExp)&&(n=t,t=null),new h(e,r,u.doesNotThrow,!0).to.not.throw(t,n)},u.operator=function(e,t,n,r){let s;switch(t){case"==":s=e==n;break;case"===":s=e===n;break;case">":s=e>n;break;case">=":s=e>=n;break;case"<":s=e<n;break;case"<=":s=e<=n;break;case"!=":s=e!=n;break;case"!==":s=e!==n;break;default:throw r=r&&r+": ",new O(r+'Invalid operator "'+t+'"',void 0,u.operator)}let i=new h(s,r,u.operator,!0);i.assert(N(i,"object")===!0,"expected "+I(e)+" to be "+t+" "+I(n),"expected "+I(e)+" to not be "+t+" "+I(n))},u.closeTo=function(e,t,n,r){new h(e,r,u.closeTo,!0).to.be.closeTo(t,n)},u.approximately=function(e,t,n,r){new h(e,r,u.approximately,!0).to.be.approximately(t,n)},u.sameMembers=function(e,t,n){new h(e,n,u.sameMembers,!0).to.have.same.members(t)},u.notSameMembers=function(e,t,n){new h(e,n,u.notSameMembers,!0).to.not.have.same.members(t)},u.sameDeepMembers=function(e,t,n){new h(e,n,u.sameDeepMembers,!0).to.have.same.deep.members(t)},u.notSameDeepMembers=function(e,t,n){new h(e,n,u.notSameDeepMembers,!0).to.not.have.same.deep.members(t)},u.sameOrderedMembers=function(e,t,n){new h(e,n,u.sameOrderedMembers,!0).to.have.same.ordered.members(t)},u.notSameOrderedMembers=function(e,t,n){new h(e,n,u.notSameOrderedMembers,!0).to.not.have.same.ordered.members(t)},u.sameDeepOrderedMembers=function(e,t,n){new h(e,n,u.sameDeepOrderedMembers,!0).to.have.same.deep.ordered.members(t)},u.notSameDeepOrderedMembers=function(e,t,n){new h(e,n,u.notSameDeepOrderedMembers,!0).to.not.have.same.deep.ordered.members(t)},u.includeMembers=function(e,t,n){new h(e,n,u.includeMembers,!0).to.include.members(t)},u.notIncludeMembers=function(e,t,n){new h(e,n,u.notIncludeMembers,!0).to.not.include.members(t)},u.includeDeepMembers=function(e,t,n){new h(e,n,u.includeDeepMembers,!0).to.include.deep.members(t)},u.notIncludeDeepMembers=function(e,t,n){new h(e,n,u.notIncludeDeepMembers,!0).to.not.include.deep.members(t)},u.includeOrderedMembers=function(e,t,n){new h(e,n,u.includeOrderedMembers,!0).to.include.ordered.members(t)},u.notIncludeOrderedMembers=function(e,t,n){new h(e,n,u.notIncludeOrderedMembers,!0).to.not.include.ordered.members(t)},u.includeDeepOrderedMembers=function(e,t,n){new h(e,n,u.includeDeepOrderedMembers,!0).to.include.deep.ordered.members(t)},u.notIncludeDeepOrderedMembers=function(e,t,n){new h(e,n,u.notIncludeDeepOrderedMembers,!0).to.not.include.deep.ordered.members(t)},u.oneOf=function(e,t,n){new h(e,n,u.oneOf,!0).to.be.oneOf(t)},u.isIterable=function(e,t){if(e==null||!e[Symbol.iterator])throw t=t?`${t} expected ${I(e)} to be an iterable`:`expected ${I(e)} to be an iterable`,new O(t,void 0,u.isIterable)},u.changes=function(e,t,n,r){arguments.length===3&&typeof t=="function"&&(r=n,n=null),new h(e,r,u.changes,!0).to.change(t,n)},u.changesBy=function(e,t,n,r,s){if(arguments.length===4&&typeof t=="function"){let i=r;r=n,s=i}else arguments.length===3&&(r=n,n=null);new h(e,s,u.changesBy,!0).to.change(t,n).by(r)},u.doesNotChange=function(e,t,n,r){return arguments.length===3&&typeof t=="function"&&(r=n,n=null),new h(e,r,u.doesNotChange,!0).to.not.change(t,n)},u.changesButNotBy=function(e,t,n,r,s){if(arguments.length===4&&typeof t=="function"){let i=r;r=n,s=i}else arguments.length===3&&(r=n,n=null);new h(e,s,u.changesButNotBy,!0).to.change(t,n).but.not.by(r)},u.increases=function(e,t,n,r){return arguments.length===3&&typeof t=="function"&&(r=n,n=null),new h(e,r,u.increases,!0).to.increase(t,n)},u.increasesBy=function(e,t,n,r,s){if(arguments.length===4&&typeof t=="function"){let i=r;r=n,s=i}else arguments.length===3&&(r=n,n=null);new h(e,s,u.increasesBy,!0).to.increase(t,n).by(r)},u.doesNotIncrease=function(e,t,n,r){return arguments.length===3&&typeof t=="function"&&(r=n,n=null),new h(e,r,u.doesNotIncrease,!0).to.not.increase(t,n)},u.increasesButNotBy=function(e,t,n,r,s){if(arguments.length===4&&typeof t=="function"){let i=r;r=n,s=i}else arguments.length===3&&(r=n,n=null);new h(e,s,u.increasesButNotBy,!0).to.increase(t,n).but.not.by(r)},u.decreases=function(e,t,n,r){return arguments.length===3&&typeof t=="function"&&(r=n,n=null),new h(e,r,u.decreases,!0).to.decrease(t,n)},u.decreasesBy=function(e,t,n,r,s){if(arguments.length===4&&typeof t=="function"){let i=r;r=n,s=i}else arguments.length===3&&(r=n,n=null);new h(e,s,u.decreasesBy,!0).to.decrease(t,n).by(r)},u.doesNotDecrease=function(e,t,n,r){return arguments.length===3&&typeof t=="function"&&(r=n,n=null),new h(e,r,u.doesNotDecrease,!0).to.not.decrease(t,n)},u.doesNotDecreaseBy=function(e,t,n,r,s){if(arguments.length===4&&typeof t=="function"){let i=r;r=n,s=i}else arguments.length===3&&(r=n,n=null);return new h(e,s,u.doesNotDecreaseBy,!0).to.not.decrease(t,n).by(r)},u.decreasesButNotBy=function(e,t,n,r,s){if(arguments.length===4&&typeof t=="function"){let i=r;r=n,s=i}else arguments.length===3&&(r=n,n=null);new h(e,s,u.decreasesButNotBy,!0).to.decrease(t,n).but.not.by(r)},u.ifError=function(e){if(e)throw e},u.isExtensible=function(e,t){new h(e,t,u.isExtensible,!0).to.be.extensible},u.isNotExtensible=function(e,t){new h(e,t,u.isNotExtensible,!0).to.not.be.extensible},u.isSealed=function(e,t){new h(e,t,u.isSealed,!0).to.be.sealed},u.isNotSealed=function(e,t){new h(e,t,u.isNotSealed,!0).to.not.be.sealed},u.isFrozen=function(e,t){new h(e,t,u.isFrozen,!0).to.be.frozen},u.isNotFrozen=function(e,t){new h(e,t,u.isNotFrozen,!0).to.not.be.frozen},u.isEmpty=function(e,t){new h(e,t,u.isEmpty,!0).to.be.empty},u.isNotEmpty=function(e,t){new h(e,t,u.isNotEmpty,!0).to.not.be.empty},u.containsSubset=function(e,t,n){new h(e,n).to.containSubset(t)},u.doesNotContainSubset=function(e,t,n){new h(e,n).to.not.containSubset(t)};var wu=[["isOk","ok"],["isNotOk","notOk"],["throws","throw"],["throws","Throw"],["isExtensible","extensible"],["isNotExtensible","notExtensible"],["isSealed","sealed"],["isNotSealed","notSealed"],["isFrozen","frozen"],["isNotFrozen","notFrozen"],["isEmpty","empty"],["isNotEmpty","notEmpty"],["isCallable","isFunction"],["isNotCallable","isNotFunction"],["containsSubset","containSubset"]];for(const[e,t]of wu)u[t]=u[e];var Ji=[];function _r(e){const t={use:_r,AssertionError:O,util:xt,config:j,expect:De,assert:u,Assertion:h,...Xi};return~Ji.indexOf(e)||(e(t,xt),Ji.push(e)),t}m(_r,"use");function yu(e,t){const n=e.Assertion,r=(i,o)=>n.addMethod(i,o);r("toBe",function(i){this.assert(Object.is(this._obj,i),"expected #{this} to be #{exp}","expected #{this} not to be #{exp}",i,this._obj)}),r("toEqual",function(i){this.assert(t.eql(this._obj,i),"expected #{this} to deeply equal #{exp}","expected #{this} not to deeply equal #{exp}",i,this._obj,!0)}),r("toBeTruthy",function(){this.assert(!!this._obj,"expected #{this} to be truthy","expected #{this} not to be truthy")}),r("toBeFalsy",function(){this.assert(!this._obj,"expected #{this} to be falsy","expected #{this} not to be falsy")}),r("toBeNull",function(){this.assert(this._obj===null,"expected #{this} to be null","expected #{this} not to be null")}),r("toBeUndefined",function(){this.assert(this._obj===void 0,"expected #{this} to be undefined","expected #{this} not to be undefined")}),r("toBeDefined",function(){this.assert(this._obj!==void 0,"expected #{this} to be defined","expected #{this} to be undefined")}),r("toBeNaN",function(){this.assert(Number.isNaN(this._obj),"expected #{this} to be NaN","expected #{this} not to be NaN")});const s=(i,o,a)=>r(i,function(l){this.assert(o(this._obj,l),`expected #{this} to be ${a} #{exp}`,`expected #{this} not to be ${a} #{exp}`,l)});s("toBeGreaterThan",(i,o)=>i>o,"greater than"),s("toBeGreaterThanOrEqual",(i,o)=>i>=o,"greater than or equal to"),s("toBeLessThan",(i,o)=>i<o,"less than"),s("toBeLessThanOrEqual",(i,o)=>i<=o,"less than or equal to"),r("toBeCloseTo",function(i,o=2){const a=Math.abs(i-this._obj)<10**-o/2;this.assert(a,`expected #{this} to be close to #{exp} (${o} digits)`,`expected #{this} not to be close to #{exp} (${o} digits)`,i)}),r("toContain",function(i){const o=this._obj,a=typeof o=="string"?o.includes(i):Array.from(o).includes(i);this.assert(a,"expected #{this} to contain #{exp}","expected #{this} not to contain #{exp}",i)}),r("toHaveLength",function(i){const o=this._obj==null?void 0:this._obj.length;this.assert(o===i,"expected #{this} to have length #{exp}","expected #{this} not to have length #{exp}",i,o)}),r("toMatch",function(i){const o=this._obj,a=i instanceof RegExp?i.test(o):String(o).includes(i);this.assert(a,"expected #{this} to match #{exp}","expected #{this} not to match #{exp}",i)}),r("toHaveProperty",function(i,...o){const a=Array.isArray(i)?i:String(i).split(".");let l=this._obj,c=!0;for(const p of a)if(l!=null&&p in Object(l))l=l[p];else{c=!1;break}const f=c&&(o.length===0||t.eql(l,o[0]));this.assert(f,"expected #{this} to have property #{exp}","expected #{this} not to have property #{exp}",i)}),r("toBeInstanceOf",function(i){this.assert(this._obj instanceof i,"expected #{this} to be an instance of #{exp}","expected #{this} not to be an instance of #{exp}",i.name??i)}),r("toThrow",function(i){const o=new e.Assertion(this._obj);t.flag(this,"negate")?i===void 0?o.to.not.throw():o.to.not.throw(i):i===void 0?o.to.throw():o.to.throw(i)})}_r(yu);var he=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Qi=e=>e==null?0:typeof e.length=="number"?e.length:typeof e.size=="number"?e.size:he(e)?Object.keys(e).length:0,H=(e,t,n=null)=>e==null?n:e instanceof Map?e.has(t)?e.get(t):n:e instanceof Set?e.has(t)?t:n:Object.hasOwn(e,t)?e[t]:typeof e.get=="function"?e.get(t,n):n,Zi=e=>Array.isArray(e),bu=e=>e instanceof Map||he(e),vu=e=>e instanceof Set;function*Eu(e){if(e instanceof Map)yield*e.entries();else if(e instanceof Set)for(const t of e)yield[t,t];else if(he(e))yield*Object.entries(e);else if(Array.isArray(e))for(let t=0;t<e.length;t++)yield[t,e[t]]}var eo=Symbol.for("immer-nothing"),Sr=Symbol.for("immer-draftable"),z=Symbol.for("immer-state"),_u=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function G(e,...t){{const n=_u[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}}var et=Object.getPrototypeOf;function ke(e){return!!e&&!!e[z]}function be(e){return e?no(e)||Array.isArray(e)||!!e[Sr]||!!e.constructor?.[Sr]||tt(e)||Kt(e):!1}var Su=Object.prototype.constructor.toString(),to=new WeakMap;function no(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=to.get(n);return r===void 0&&(r=Function.toString.call(n),to.set(n,r)),r===Su}function Gt(e,t,n=!0){Wt(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(s=>{t(s,e[s],e)}):e.forEach((r,s)=>t(s,r,e))}function Wt(e){const t=e[z];return t?t.type_:Array.isArray(e)?1:tt(e)?2:Kt(e)?3:0}function Tr(e,t){return Wt(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ro(e,t,n){const r=Wt(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function Tu(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function tt(e){return e instanceof Map}function Kt(e){return e instanceof Set}function ve(e){return e.copy_||e.base_}function Nr(e,t){if(tt(e))return new Map(e);if(Kt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=no(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[z];let s=Reflect.ownKeys(r);for(let i=0;i<s.length;i++){const o=s[i],a=r[o];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[o]})}return Object.create(et(e),r)}else{const r=et(e);if(r!==null&&n)return{...e};const s=Object.create(r);return Object.assign(s,e)}}function zt(e,t=!1){return Xt(e)||ke(e)||!be(e)||(Wt(e)>1&&Object.defineProperties(e,{set:Yt,add:Yt,clear:Yt,delete:Yt}),Object.freeze(e),t&&Object.values(e).forEach(n=>zt(n,!0))),e}function Nu(){G(2)}var Yt={value:Nu};function Xt(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var Au={};function Ee(e){const t=Au[e];return t||G(0,e),t}var nt;function so(){return nt}function xu(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function io(e,t){t&&(Ee("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ar(e){xr(e),e.drafts_.forEach(Iu),e.drafts_=null}function xr(e){e===nt&&(nt=e.parent_)}function oo(e){return nt=xu(nt,e)}function Iu(e){const t=e[z];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ao(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[z].modified_&&(Ar(t),G(4)),be(e)&&(e=Jt(t,e),t.parent_||Qt(t,e)),t.patches_&&Ee("Patches").generateReplacementPatches_(n[z].base_,e,t.patches_,t.inversePatches_)):e=Jt(t,n,[]),Ar(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==eo?e:void 0}function Jt(e,t,n){if(Xt(t))return t;const r=e.immer_.shouldUseStrictIteration(),s=t[z];if(!s)return Gt(t,(i,o)=>lo(e,s,t,i,o,n),r),t;if(s.scope_!==e)return t;if(!s.modified_)return Qt(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const i=s.copy_;let o=i,a=!1;s.type_===3&&(o=new Set(i),i.clear(),a=!0),Gt(o,(l,c)=>lo(e,s,i,l,c,n,a),r),Qt(e,i,!1),n&&e.patches_&&Ee("Patches").generatePatches_(s,n,e.patches_,e.inversePatches_)}return s.copy_}function lo(e,t,n,r,s,i,o){if(s==null||typeof s!="object"&&!o)return;const a=Xt(s);if(!(a&&!o)){if(s===n&&G(5),ke(s)){const l=i&&t&&t.type_!==3&&!Tr(t.assigned_,r)?i.concat(r):void 0,c=Jt(e,s,l);if(ro(n,r,c),ke(c))e.canAutoFreeze_=!1;else return}else o&&n.add(s);if(be(s)&&!a){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===s&&a)return;Jt(e,s),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(tt(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Qt(e,s)}}}function Qt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&zt(t,n)}function Ou(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:so(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,i=Ir;n&&(s=[r],i=rt);const{revoke:o,proxy:a}=Proxy.revocable(s,i);return r.draft_=a,r.revoke_=o,a}var Ir={get(e,t){if(t===z)return e;const n=ve(e);if(!Tr(n,t))return Pu(e,n,t);const r=n[t];return e.finalized_||!be(r)?r:r===Or(e.base_,t)?(Mr(e),e.copy_[t]=Cr(r,e)):r},has(e,t){return t in ve(e)},ownKeys(e){return Reflect.ownKeys(ve(e))},set(e,t,n){const r=co(ve(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const s=Or(ve(e),t),i=s?.[z];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(Tu(n,s)&&(n!==void 0||Tr(e.base_,t)))return!0;Mr(e),Pr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Or(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Mr(e),Pr(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ve(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){G(11)},getPrototypeOf(e){return et(e.base_)},setPrototypeOf(){G(12)}},rt={};Gt(Ir,(e,t)=>{rt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),rt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&G(13),rt.set.call(this,e,t,void 0)},rt.set=function(e,t,n){return t!=="length"&&isNaN(parseInt(t))&&G(14),Ir.set.call(this,e[0],t,n,e[0])};function Or(e,t){const n=e[z];return(n?ve(n):e)[t]}function Pu(e,t,n){const r=co(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}function co(e,t){if(!(t in e))return;let n=et(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=et(n)}}function Pr(e){e.modified_||(e.modified_=!0,e.parent_&&Pr(e.parent_))}function Mr(e){e.copy_||(e.copy_=Nr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Mu=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const o=this;return function(l=i,...c){return o.produce(l,f=>n.call(this,f,...c))}}typeof n!="function"&&G(6),r!==void 0&&typeof r!="function"&&G(7);let s;if(be(t)){const i=oo(this),o=Cr(t,void 0);let a=!0;try{s=n(o),a=!1}finally{a?Ar(i):xr(i)}return io(i,r),ao(s,i)}else if(!t||typeof t!="object"){if(s=n(t),s===void 0&&(s=t),s===eo&&(s=void 0),this.autoFreeze_&&zt(s,!0),r){const i=[],o=[];Ee("Patches").generateReplacementPatches_(t,s,i,o),r(i,o)}return s}else G(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...a)=>this.produceWithPatches(o,l=>t(l,...a));let r,s;return[this.produce(t,n,(o,a)=>{r=o,s=a}),r,s]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof e?.useStrictIteration=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){be(e)||G(8),ke(e)&&(e=Cu(e));const t=oo(this),n=Cr(e,void 0);return n[z].isManual_=!0,xr(t),n}finishDraft(e,t){const n=e&&e[z];(!n||!n.isManual_)&&G(9);const{scope_:r}=n;return io(r,t),ao(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const s=t[n];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}n>-1&&(t=t.slice(n+1));const r=Ee("Patches").applyPatches_;return ke(e)?r(e,t):this.produce(e,s=>r(s,t))}};function Cr(e,t){const n=tt(e)?Ee("MapSet").proxyMap_(e,t):Kt(e)?Ee("MapSet").proxySet_(e,t):Ou(e,t);return(t?t.scope_:so()).drafts_.push(n),n}function Cu(e){return ke(e)||G(10,e),uo(e)}function uo(e){if(!be(e)||Xt(e))return e;const t=e[z];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Nr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Nr(e,!0);return Gt(n,(s,i)=>{ro(n,s,uo(i))},r),t&&(t.finalized_=!1),n}var Du=new Mu,ho=Du.produce,L=Symbol("NONE"),fo=(e,t,n)=>{e instanceof Map?e.set(t,n):e instanceof Set?(e.delete(t),e.add(n)):e[t]=n},po=(e,t,n)=>!(e instanceof Map||e instanceof Set||Array.isArray(e))&&!Object.hasOwn(e,t)&&typeof e?.set=="function"?e.set(t,n):fo(e,t,n),st=class{setDraftValue(e,t){}enterFrame(e,t,n){return e.enter(t,{},!0,n)}toAbstractPathStep(){return this}pinKey(e){return this}toKey(){return null}},ku=class extends st{constructor(e){super(),this.binds=e}lookup(e){return e}enterFrame(e,t,n){return e.enter(t,{...this.binds},!1,n)}toAbstractPathStep(){return null}},Lu=class extends ku{constructor(e,t={}){super(t),this.val=e}enterFrame(e,t,n){const r=this.val.evalAsHandler(e)?.call(e.it)??{};return e.enter(t,{...this.binds,...r},!1,n)}},it=class extends st{constructor(e){super(),this.field=e}lookup(e){return H(e,this.field,L)}setDraftValue(e,t){fo(e,this.field,t)}toKey(){return{field:this.field}}},se=class extends st{constructor(e,t){super(),this.field=e,this.key=t}lookup(e){return H(H(e,this.field,null),this.key,L)}setDraftValue(e,t){const n=H(e,this.field,null);n!=null&&po(n,this.key,t)}enterFrame(e,t,n){return e.enter(t,{key:this.key},!0,n)}toKey(){return{field:this.field,key:this.key}}},Dr=class extends st{constructor(e,t){super(),this.seqField=e,this.keyField=t}lookup(e){const t=H(e,this.seqField,L),n=H(e,this.keyField,L);return n!==L&&t!==L?H(t,n,L):L}setDraftValue(e,t){const n=H(e,this.seqField,L),r=H(e,this.keyField,L);n!==L&&r!==L&&po(n,r,t)}pinKey(e){const t=H(e,this.keyField,L);return t===L?this:new se(this.seqField,t)}toKey(){return{field:this.seqField}}},Ru=class extends st{constructor(e,t){super(),this.eachNode=e,this.key=t}lookup(e){return e}enterFrame(e,t,n){return e.enter(t,this.eachNode.enrichBinds(e,this.key),!1,n)}toAbstractPathStep(){return null}},$u=class extends se{enterFrame(e,t,n){return e.enter(t,{key:this.key,value:t},!1,n).enter(t,{},!0,n)}toAbstractPathStep(){return new se(this.field,this.key)}};function Fu(e){return e instanceof se?{f:e.field,k:e.key}:e instanceof it?{f:e.field}:e instanceof Dr?{f:e.seqField,a:e.keyField}:null}function Bu(e){return e==null||typeof e.f!="string"?null:e.k!==void 0?new se(e.f,e.k):e.a!==void 0?new Dr(e.f,e.a):new it(e.f)}function mo(e){const t=[];for(const n of e.steps){const r=Fu(n);if(r===null)return null;t.push(r)}return t}function go(e){if(!Array.isArray(e))return null;const t=[];for(const n of e){const r=Bu(n);if(r===null)return null;t.push(r)}return new ot(t)}var ot=class mn{constructor(t=[]){this.steps=t}concat(t){return new mn(this.steps.concat(t))}compact(){const t=[];for(const n of this.steps){const r=n.toAbstractPathStep();r!==null&&t.push(r)}return new mn(t)}pinKeys(t){let n=t,r=null;for(let s=0;s<this.steps.length;s++){const i=this.steps[s],o=i.pinKey(n);if(o!==i&&((r??=this.steps.slice())[s]=o),n=i.lookup(n),n===L)break}return r?new mn(r):this}lookup(t,n=null){let r=t;for(const s of this.steps)if(r=s.lookup(r),r===L)return n;return r}resolveChain(t){const n=[t];let r=t;for(const s of this.steps){if(r=s.lookup(r),r===L)break;n.push(r)}return n}toKeys(){const t=[];for(const n of this.steps){const r=n.toKey();r!==null&&t.push(r)}return t}setValue(t,n){return this.steps.length===0?n:ho(t,r=>{let s=r;for(let i=0;i<this.steps.length-1;i++)if(s=this.steps[i].lookup(s),s===L)return;this.steps.at(-1).setDraftValue(s,n)})}};function Vu(e,t,n,r){let s=e.it;for(const i of t){const o=i.lookup(s);if(o===L)return console.warn("bad PathItem",{root:e.it,step:i,path:r}),null;n=n.pushItem(i),e=i.enterFrame(e,o,n),s=o}return[e,n]}var wo=new ot([]),at=class me{constructor(t=[{base:wo,items:[]}]){this.frames=t}static ofSteps(t){return new me([{base:wo,items:t.slice()}])}get top(){return this.frames[this.frames.length-1]}_withTopItems(t){const n=this.frames.slice();return n[n.length-1]={base:this.top.base,items:t},new me(n)}concat(t){return this._withTopItems(this.top.items.concat(t))}pushItem(t){return this.concat([t])}pushFrame(t){return new me(this.frames.concat({base:t,items:[]}))}canPop(){return this.frames.length>1||this.frames[0].items.length>0}popStep(){const{top:t}=this;return t.items.length>0?this._withTopItems(t.items.slice(0,-1)):this.frames.length>1?new me(this.frames.slice(0,-1)):this}compact(){return new me(this.frames.map(({base:t,items:n})=>({base:t,items:new ot(n).compact().steps})))}get addressKey(){return this._addressKey??=ju(this.toTransactionPath().compact()),this._addressKey}toTransactionPath(){const{base:t,items:n}=this.top;return t.concat(n)}buildStack(t){let n=new me;for(let r=0;r<this.frames.length;r++){const{base:s,items:i}=this.frames[r];if(r>0||s.steps.length>0){const a=s.lookup(t.root,L);if(a===L)return console.warn("bad frame base",{base:s,path:this}),null;n=n.pushFrame(s),t=t.enter(a,{},!0,n)}const o=Vu(t,i,n,this);if(o===null)return null;[t,n]=o}return t}static fromNodeAndEventName(t,n,r,s,i=!0){const o=[],a=zu.has(n);let l=[],c=null,f=[],p=!0;const g=(E,S)=>{const M=s.getComponentForId(E);let x=!0;if(c===null&&(p||a))if(c=Gu(M,l,S,n),c===null){if(p&&i&&!a)return!1}else p||(o.length=0,x=!1);if(p=!1,x){const C=Ku(M,f,S);C&&o.push(C)}return l=[],f=[],!0};for(;t&&t!==r;){if(t?.dataset){const{eid:E,cid:S,vid:M,rp:x}=t.dataset;E!==void 0&&l.push(E);const C=Hu(t.previousSibling);let D=!1;for(const k of C)if(k.$==="Comp"){if(D=!0,!g(k.cid,k.vid))return yo;f.push({nid:k.nid,base:go(k.base)})}else f.push({nid:k.nid,si:k.si,sk:k.sk});if(!D&&S!==void 0){if(!g(+S,M))return yo;if(x!==void 0){const k=qu(x);k!==null&&f.push({base:k})}}}t=t.parentNode}o.reverse();let y=new me;for(const E of o)y=E.base!==void 0?y.pushFrame(E.base):y.pushItem(E.step);return[y,c]}};function Uu(e,t){const n=e.steps,r=n[n.length-1];return r instanceof se||r instanceof it?new ot(n.slice(0,-1).concat(new se(r.field,t))):null}function ju(e){return JSON.stringify(mo(e))}function qu(e){try{return go(JSON.parse(e))}catch(t){return console.warn("bad render path",t,e),null}}function Hu(e){const t=[];for(;e?.nodeType===8&&e.textContent[0]==="\xA7";){try{t.push(JSON.parse(e.textContent.slice(1,-1)))}catch(n){console.warn(n,e)}e=e.previousSibling}return t}function Gu(e,t,n,r){for(const s of t){const i=e.getEventForId(+s,n).getHandlersFor(r);if(i!==null)return i}return null}var Wu=class uc{constructor(t,n,r,s){this.comp=t,this.nodeIds=n,this.idx=r,this.vid=s}get meta(){return this.nodeIds[this.idx]}get key(){const t=this.meta;return t.si!==void 0?+t.si:t.sk}get hasKey(){const t=this.meta;return t.si!==void 0||t.sk!==void 0}next(){const{idx:t,nodeIds:n}=this;return t+1<n.length?new uc(this.comp,n,t+1,this.vid):null}resolveNode(){return this.comp.getNodeForId(+this.meta.nid,this.vid)}};function Ku(e,t,n){for(let r=0;r<t.length;r++){const s=t[r];if(s.base!=null)return{base:s.base};if(s.nid===void 0||s.nid===null)continue;const i=new Wu(e,t,r,n),o=i.resolveNode()?.toPathStep(i)??null;if(o!==null)return{step:o}}return null}var yo=[null,null],zu=new Set(["drop"]),Yu=()=>new bo,bo=class{constructor(){this.pathChanges=[]}toPath(){return new ot(this.pathChanges)}add(e){return this.pathChanges.push(e),this}field(e){return this.add(new it(e))}index(e,t){return this.add(new se(e,t))}key(e,t){return this.add(new se(e,t))}},Xu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ju=/^[a-zA-Z][a-zA-Z0-9_]*\??$/,kr=e=>Ju.test(e),Qu=/^-?[0-9]+(\.[0-9]+)?$/,Zu=/(\{[^}]+\})/g,lt=(e,t)=>kr(e)?new t(e):null,eh=/\$'(?:[^'\\]|\\.)*'|'(?:[^'\\]|\\.)*'|\S+/g,Zt=e=>e.match(eh)??[],vo=e=>e.replace(/\\(['\\])/g,"$1"),ct=1,Lr=2,_e=4,Rr=8,ut=16,en=32,ht=256,Le=1024,Eo=2048,$r=_e|Le|Rr|ut|ct,th=$r|Lr,nh=_e|ht|ut,rh=_e|ut,sh=_e|ht,ih=_e|Le|ct|ht,_o=_e|Le|Rr|ut|en|ct,oh=_o&~en|Eo,ah=_o|Lr|ht;function So(e){if(e==null)return null;const t=e.size;if(typeof t=="number")return t;const n=e.length;return typeof n=="number"?n:he(e)?Object.keys(e).length:null}var To=e=>Number.isNaN(e)?null:e;function Fr(e){return e.target.type==="checkbox"?e.target.checked:(e instanceof CustomEvent?e.detail:e.target.value)??null}var No=e=>{const t=So(e);return t===null?!!e:t>0},lh={"empty?":{name:"empty?",arity:1,fn:e=>e==null||So(e)===0},"truthy?":{name:"truthy?",arity:1,fn:No},"falsy?":{name:"falsy?",arity:1,fn:e=>!No(e)},"null?":{name:"null?",arity:1,fn:e=>e==null},"equals?":{name:"equals?",arity:2,fn:(e,t)=>Object.is(e,t)}};function fe(e,t){const n=e.charCodeAt(0);if(n===39)return e.length>=2&&e.charCodeAt(e.length-1)===39?new V(vo(e.slice(1,-1))):null;if(n===36&&e.charCodeAt(1)===39)return e.length>=3&&e.charCodeAt(e.length-1)===39?yh.parse(e.slice(2,-1),t):null;if(e.indexOf("[")!==-1||e.indexOf("]")!==-1)return ch(e,t);if(e.indexOf("{")!==-1||e.indexOf("}")!==-1)return null;switch(n){case 94:{const s=e.slice(1),i=t.frame.macroVars?.[s];if(i!==void 0){const o=Zt(i.trim());if(o.length!==1)return null;const a=fe(o[0],t);return a instanceof V&&(a.fromMacroVar=!0),a}return t.onParseIssue("bad-value",{role:"macro-var",name:s,value:e}),null}case 36:return lt(e.slice(1),Th);case 64:{const s=e.indexOf(".",1);if(s===-1)return lt(e.slice(1),Oo);const i=e.slice(1,s),o=e.slice(s+1);return kr(i)&&kr(o)?new Sh(i,o):null}case 42:return lt(e.slice(1),dt);case 46:return lt(e.slice(1),nn)}const r=Qu.test(e)?parseFloat(e):null;return Number.isFinite(r)?new V(r):e==="true"||e==="false"?new V(e==="true"):n===101&&/^e(\.[a-zA-Z][a-zA-Z0-9_]*)+$/.exec(e)!==null?new _h(e.split(".").slice(1)):n>=97&&n<=122?lt(e,Io):null}function ch(e,t){const n=e.indexOf("["),r=e.indexOf("]");if(n<1||r!==e.length-1||r<n||e.indexOf("[",n+1)!==-1)return null;const s=fe(e.slice(0,n),t),i=fe(e.slice(n+1,r),t);return s instanceof nn&&i instanceof nn?new Nh(s,i):null}function Re(e,t,n){const r=Zt(e.trim());if(r.length!==1)return null;const s=fe(r[0],t);return s!==null&&ft(s)&n?s:null}function $e(e,t){const n=e.trim(),r=Zt(n);if(r.length!==1)return r.length===0?null:gh(n,r,t);const s=fe(r[0],t);return s!==null&&ft(s)&$r?s:null}var de=(e,t)=>Re(e,t,th),uh=(e,t)=>Re(e,t,nh),Ao=(e,t)=>Re(e,t,rh),hh=(e,t)=>Re(e,t,ih),fh=(e,t)=>Re(e,t,sh),dh=(e,t)=>Re(e,t,ah),ph=(e,t)=>xo(e,t,"receive",!0,!0,!1),mh=(e,t)=>xo(e,t,"alter",!1,!1,!0)?.handlerVal??null;function xo(e,t,n,r,s,i){const o=Zt(e.trim()),a=o[0]??"",l=a===""?null:fe(a,t),c=ft(l);let f;if(c&Le&&i)f=l;else{if(c&Le)return s&&t.onParseIssue("event-method-handler",{name:l.name,role:"handler-name",value:a}),null;if(c&en)f=new bh(l.name,n);else return s&&t.onParseIssue("bad-value",{role:"handler-name",value:a}),null}if(!r)return o.length===1?{handlerVal:f,args:[]}:null;const p=new Array(o.length-1);for(let g=1;g<o.length;g++){const y=fe(o[g],t);y!==null&&ft(y)&oh?p[g-1]=y:(s&&t.onParseIssue("bad-value",{role:"handler-arg",value:o[g]}),p[g-1]=Br)}return{handlerVal:f,args:p}}function gh(e,t,n){const r=t[0],s=lh[r];if(s===void 0)return n.onParseIssue("bad-value",{role:"predicate",value:r}),null;const i=t.length-1;if(i!==s.arity)return n.onParseIssue("bad-value",{role:"predicate-arity",value:e,predicate:r}),null;const o=new Array(i);for(let a=0;a<i;a++){const l=t[a+1],c=fe(l,n);if(c===null||!(ft(c)&$r))return n.onParseIssue("bad-value",{role:"predicate-arg",value:l}),null;o[a]=c}return new wh(s,o)}var ft=e=>e?.kind??0,Se=class{kind=0;eval(e){}toPathItem(){return null}evalAsHandler(e){return this.eval(e)}},V=class extends Se{constructor(e,t=ct){super(),this.val=e,this.kind=t}eval(e){return this.val}toString(){const e=this.val;return typeof e=="string"?`'${e.replace(/(['\\])/g,"\\$1")}'`:`${e}`}},Br=new V(null),wh=class extends Se{constructor(e,t){super(),this.pred=e,this.args=t}eval(e){const t=this.args.length,n=new Array(t);for(let r=0;r<t;r++)n[r]=this.args[r].eval(e);return this.pred.fn(...n)}toString(){return`${this.pred.name} ${this.args.map(String).join(" ")}`}},yh=class hc extends Se{constructor(t){super(),this.vals=t,this.kind=this.isLiteral()?ct:Lr}isLiteral(){for(const t of this.vals)if(!(t instanceof V)||t.fromMacroVar)return!1;return!0}eval(t){const n=new Array(this.vals.length);for(let r=0;r<this.vals.length;r++)n[r]=this.vals[r]?.eval(t,"");return n.join("")}toLiteralSource(){if(!this.isLiteral())return null;let t="";for(const n of this.vals)t+=n.val;return new V(t).toString()}static parse(t,n){const r=vo(t).split(Zu),s=new Array(r.length);for(let l=0;l<r.length;l++){const c=r[l],f=c[0]==="{"&&c.at(-1)==="}";s[l]=f?de(c.slice(1,-1),n):new V(c)}let i=0,o=s.length;const a=l=>l instanceof V&&l.val===""&&!l.fromMacroVar;for(;i<o&&a(s[i]);)i++;for(;o>i&&a(s[o-1]);)o--;return new hc(i===0&&o===s.length?s:s.slice(i,o))}},Io=class extends Se{kind=en;constructor(e){super(),this.name=e}toString(){return this.name}},bh=class extends Io{constructor(e,t){super(e),this.namespace=t}eval(e){return e.getHandlerFor(this.name,this.namespace)??vh(e,this.namespace,this.name)}},vh=(e,t,n)=>function(...r){const s=e?.ctx?.transactor;return s?s.refuse("NO_HANDLER",{namespace:t,name:n,argCount:r.length}):console.warn("handler not found",{type:t,name:n}),this},Fe=e=>t=>t.key===e,Vr=e=>Xu&&e.metaKey||e.ctrlKey,Ur=e=>(t,n)=>{const r=n.lookupDragInfo();return r==null?null:e(r)},Eh={value:e=>Fr(e),valueAsInt:e=>To(parseInt(Fr(e),10)),valueAsFloat:e=>To(parseFloat(Fr(e))),isAlt:e=>e.altKey,isShift:e=>e.shiftKey,isCtrl:Vr,isCmd:Vr,isUpKey:Fe("ArrowUp"),isDownKey:Fe("ArrowDown"),isSend:Fe("Enter"),isCancel:Fe("Escape"),isTabKey:Fe("Tab"),dragInfo:(e,t)=>t.lookupDragInfo(),dragType:Ur(e=>e.type),dragValue:Ur(e=>e.val),dragKey:Ur(e=>e.lookupBind("key"))},_h=class extends Se{kind=Eo;constructor(e){super(),this.members=e}eval(e){const t=e.lookupEvent();if(t==null)return null;if(this.members.length===1){const r=Eh[this.members[0]];if(r!==void 0)return r(t,e)}let n=t;for(const r of this.members){if(n==null)return null;n=n[r]}return n??null}toString(){return`e.${this.members.join(".")}`}},tn=class extends Se{constructor(e){super(),this.name=e}toString(){return this.sigil+this.name}},Oo=class extends tn{kind=Rr;sigil="@";eval(e){return e.lookupBind(this.name)}},Sh=class extends Oo{constructor(e,t){super(e),this.member=t}eval(e){const t=e.lookupBind(this.name);return H(t,this.member,null)}toString(){return`@${this.name}.${this.member}`}},dt=class extends tn{kind=ut;sigil="*";eval(e){return e.lookupDynamic(this.name)}},nn=class extends tn{kind=_e;sigil=".";eval(e){return e.lookupFieldRaw(this.name)}toPathItem(){return new it(this.name)}},Th=class extends tn{kind=Le;sigil="$";eval(e){return e.lookupMethod(this.name)}evalAsHandler(e){return e.lookupFieldRaw(this.name)}},Nh=class extends Se{kind=ht;constructor(e,t){super(),this.seqVal=e,this.keyVal=t}toPathItem(){return new Dr(this.seqVal.name,this.keyVal.name)}eval(e){const t=this.keyVal.eval(e);return H(this.seqVal.eval(e),t,null)}toString(){return`${this.seqVal}[${this.keyVal}]`}},Po=class{constructor(e){this.items=e}isConstant(){return!1}},Ah="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected",xh=new Set(Ah.split(","));function Te(e,t,n,r){const s=r(n,e);return s===null&&e.onParseIssue("bad-value",{role:"directive",directive:t,value:n}),s}var Ih={when:"whenVal","loop-with":"loopWithVal","enrich-with":"enrichWithVal"},Mo=(e,t,n)=>Te(e,t,n,mh);function Oh(e,t){const n=r=>{const s=e.getNamedItem(`@${r}`);return s?Mo(t,r,s.value):null};return{whenVal:n("when"),loopWithVal:n("loop-with")}}var Co=class{constructor(e){this.px=e,this.attrs=null,this.hasDynamic=!1,this.wrapperAttrs=null,this.textChild=null,this.eachAttr=null,this.ifAttr=null,this.events=null}parseAttr(e,t,n=!1){const r=n?dh(t,this.px):de(t,this.px);r!==null?(this.attrs??=[],this.attrs.push(new jr(e,r)),this.hasDynamic||=!(r instanceof V)):this.px.onParseIssue("bad-value",{role:"attr",attr:e,value:t})}pushWrapper(e,t,n){const r={name:e,val:n,raw:t};return this.wrapperAttrs??=[],this.wrapperAttrs.push(r),r}parseIf(e,t){const n=$e(t,this.px);if(n)this.ifAttr=new Dh(e.slice(3),n),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0;else{const r={role:"if",attr:e.slice(3),value:t};this.px.onParseIssue("bad-value",r)}}parseBranch(e,t,n){if(this.ifAttr===null)return this._orphan(t,n,"if");this.ifAttr[e]=de(n,this.px)??rn}parseIter(e,t){const n=Mo(this.px,e,t);this.eachAttr!==null?this.eachAttr[Ih[e]]=n:e==="enrich-with"?this.pushWrapper("scope",t,n):this._orphan(e,t,"each")}_orphan(e,t,n){this.px.onParseIssue("orphan-directive",{name:e,value:t,needs:n})}parseEvent(e,t){const[n,...r]=e.slice(3).split("+"),s=kh.parse(t,this.px);s&&(this.events===null&&(this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new qr("data-eid",new V(this.events.id)))),this.events.add(n,s,r))}parseDirective(e,t){switch(t){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new Ch(Te(this.px,t,e,de))),this.hasDynamic=!0;return;case"push-view":this.pushWrapper("push-view",e,Te(this.px,t,e,de));return;case"text":this.textChild=Te(this.px,t,e,de);return;case"show":this.pushWrapper("show",e,Te(this.px,t,e,$e));return;case"hide":this.pushWrapper("hide",e,Te(this.px,t,e,$e));return;case"each":{const n=Te(this.px,t,e,Ao);this.eachAttr=this.pushWrapper("each",e,n);return}case"when":case"loop-with":case"enrich-with":this.parseIter(t,e);return;case"then":this.parseBranch("thenVal",t,e);return;case"else":this.parseBranch("elseVal",t,e);return}if(t.startsWith("on."))this.parseEvent(t,e);else if(t.startsWith("if."))this.parseIf(t,e);else if(t.startsWith("then."))this.parseBranch("thenVal",t,e);else if(t.startsWith("else."))this.parseBranch("elseVal",t,e);else{const n={name:t,value:e};this.px.onParseIssue("unknown-directive",n)}}parse(e,t=!1){for(const{name:i,value:o}of e){const a=i.charCodeAt(0);if(a===58)this.parseAttr(i===":viewbox"?"viewBox":i.slice(1),o,t);else if(a===64)this.parseDirective(o,i.slice(1));else{this.attrs??=[];const l=o===""&&xh.has(i)?!0:o;this.attrs.push(new qr(i,new V(l)))}}const{attrs:n,hasDynamic:r}=this;return[r?new Mh(n):Ph.fromAttrs(n??[]),this.wrapperAttrs,this.textChild]}},Ph=class fc extends Po{eval(t){return this.items}static fromAttrs(t){const n={};for(const r of t)n[r.name]=r.val.eval(null);return new fc(n)}setDataAttr(t,n){this.items[t]=n}toMacroVars(){const t={};for(const n in this.items)t[n]=new V(`${this.items[n]}`).toString();return t}isConstant(){return!0}},Mh=class extends Po{eval(e){const t={};for(let n=0;n<this.items.length;n++){const r=this.items[n];t[r.name]=r.eval(e)}return t}setDataAttr(e,t){this.items.push(new qr(e,new V(t)))}toMacroVars(){const e={};for(const t of this.items)e[t.name]=t.val.toString();return e}},Do=class{constructor(e){this.name=e}},jr=class extends Do{constructor(e,t){super(e),this.val=t}eval(e){return this.val.eval(e)}},qr=class extends jr{},Ch=class extends jr{constructor(e){super("dangerouslySetInnerHTML",e??Br)}eval(e){return{__html:`${this.val.eval(e)}`}}},rn=Br,Dh=class extends Do{constructor(e,t){super(e),this.condVal=t,this.thenVal=this.elseVal=rn}get anyBranchIsSet(){return this.thenVal!==rn||this.elseVal!==rn}eval(e){return this.condVal.eval(e)?this.thenVal.eval(e):this.elseVal.eval(e)}},kh=class dc{constructor(t,n=[]){this.handlerVal=t,this.args=n}getHandlerAndArgs(t,n){const r=new Array(this.args.length);for(let s=0;s<r.length;s++)r[s]=this.args[s].eval(t);return[this.handlerVal.evalAsHandler(t),r]}static parse(t,n){const r=ph(t,n);return r===null?null:new dc(r.handlerVal,r.args)}},ko=Symbol.for("tutuca.seqInfo"),Lo=(e,t,n)=>{let r=e==null?0:e<0?n+e:e,s=t==null?n:t<0?n+t:t;return r=r<0?0:r>n?n:r,s=s<0?0:s>n?n:s,[r,s<r?r:s]},Lh=(e,t,n,r)=>{const[s,i]=Lo(n,r,Qi(e));for(let o=s;o<i;o++)t(o,e[o],"si")},Rh=(e,t,n,r)=>{const[s,i]=Lo(n,r,Qi(e));let o=0;for(const[a,l]of Eu(e)){if(o>=i)break;o>=s&&t(a,l,"sk"),o++}},$h=()=>{},Fh=e=>Zi(e)?Lh:bu(e)||vu(e)?Rh:e?.[ko]??$h,Ro=(e,t,n)=>!0,$o=e=>({iterData:{seq:e}}),Fo=(e,t)=>{const n=e??{};return{iterData:n.iterData??{seq:t},start:n.start,end:n.end,keys:n.keys}},Bo=(e,t)=>({lookup:n=>e.lookupBind(n),filter:(n,r,s)=>t.call(e.it,n,r,s)}),Vo=(e,t,n,r,s,i)=>{e.call(t,n,r,s,i),console.assert(n.key===r&&n.value===s,"@enrich-with handlers must not overwrite binds.key or binds.value"),n.key=r,n.value=s};function Bh({seq:e,it:t,loopWith:n,enricher:r,ctx:s},i){const o=H(e,i,null),a={key:i,value:o};if(r){const{iterData:l}=Fo(n.call(t,e,s),e);Vo(r,t,a,i,o,l)}return a}var Vh=(e,t,n)=>{const r=Zi(e)?"si":"sk";for(const s of t)n(s,H(e,s),r)};function Uo({seq:e,it:t,filter:n,loopWith:r,enricher:s,ctx:i},o){const{iterData:a,start:l,end:c,keys:f}=Fo(r.call(t,e,i),e),p=(g,y,E)=>{const S={key:g,value:y};s&&Vo(s,t,S,g,y,a),o(g,y,E,S)};f?Vh(e,f,p):Fh(e)(e,(g,y,E)=>{n.call(t,g,y,a)&&p(g,y,E)},l,c)}var jo="http://www.w3.org/1999/xhtml",qo="http://www.w3.org/2000/svg",Uh="http://www.w3.org/1998/Math/MathML",Hr=e=>{const t=e.namespaceURI;return t!==null&&t!==jo},jh=e=>e.length===13&&e.toLowerCase()==="foreignobject",Ho=(e,t)=>e.namespace??t.namespace??null;function Go(e,t,n){const r=t===qo&&jh(e.tag)?null:t;return r===(n.namespace??null)?n:{...n,namespace:r}}var qh=new Set("width height href list form tabIndex download rowSpan colSpan role popover".split(" ")),Hh={className:"class",htmlFor:"for"};function Wo(e,t){const n=Hr(e);for(const r in t)Gr(e,r,t[r],n)}function Gr(e,t,n,r){if(t==="dangerouslySetInnerHTML"){if(n===void 0)e.replaceChildren();else{const i=n.__html??"";i!==e.innerHTML&&(e.innerHTML=i)}return}if(typeof n=="function")return;const s=!r&&!qh.has(t)&&t in e;if(s&&n!=null)try{e[t]=n;return}catch{}if(n==null||n===!1&&t[4]!=="-")if(s){try{e[t]=""}catch{}e.removeAttribute(Hh[t]??t)}else e.removeAttribute(t);else e.setAttribute(t,n)}function Ko(e,t){e.tagName==="PROGRESS"&&(t==null||t===0)?e.removeAttribute("value"):Gr(e,"value",t,Hr(e))}var pt=class{},mt=e=>e instanceof sn?e.key:void 0,Gh=e=>e!=null&&typeof e!="string"&&typeof e[Symbol.iterator]=="function";function zo(e,t){if(e===t)return!0;for(let n=0;n<e.length;n++)if(!e[n].isEqualTo(t[n]))return!1;return!0}function Wr(e,t,n){for(const r of t)e.appendChild(r.toDom(n))}function Kr(e,t){if(t!=null)if(Gh(t))for(const n of t)Kr(e,n);else t instanceof pt?t instanceof pe?e.push(...t.childs):e.push(t):e.push(new Wh(t))}var Wh=class pc extends pt{constructor(t){super(),this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof pc&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}},zr=class mc extends pt{constructor(t){super(),this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof mc&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}},pe=class gc extends pt{constructor(t){super(),this.childs=[],Kr(this.childs,t)}get nodeType(){return 11}isEqualTo(t){return!(t instanceof gc)||this.childs.length!==t.childs.length?!1:zo(this.childs,t.childs)}toDom(t){const n=t.document.createDocumentFragment();return Wr(n,this.childs,t),n}},sn=class wc extends pt{constructor(t,n,r,s,i){super(),this.tag=t,this.attrs=n??{},this.childs=r??[],this.key=s!=null?String(s):void 0,this.namespace=typeof i=="string"?i:null}get nodeType(){return 1}isSameKind(t){return this.tag===t.tag&&this.namespace===t.namespace&&this.key===t.key}isEqualTo(t){if(this===t)return!0;if(!(t instanceof wc)||!this.isSameKind(t)||this.childs.length!==t.childs.length)return!1;if(this.attrs!==t.attrs){for(const n in this.attrs)if(this.attrs[n]!==t.attrs[n])return!1;for(const n in t.attrs)if(!Object.hasOwn(this.attrs,n))return!1}return zo(this.childs,t.childs)}toDom(t){const n=t.document,r=Ho(this,t),s=r!==null&&this.tag===this.tag.toUpperCase()?this.tag.toLowerCase():this.tag,i=this.attrs,o=i.is!=null?{is:i.is}:void 0,a=r===null?n.createElement(s,o):n.createElementNS(r,s,o),l=Go(this,r,t);return Yo(a,i,()=>Wr(a,this.childs,l)),a}};function Yo(e,t,n){const r="value"in t,s="checked"in t;if(r||s){const{value:i,checked:o,...a}=t;Wo(e,a)}else Wo(e,t);n(),r&&Ko(e,t.value),s&&Gr(e,"checked",t.checked,Hr(e))}function Kh(e,t){if(e===t)return null;let n=null;for(const r in e)Object.hasOwn(t,r)?e[r]!==t[r]&&(n??={},n[r]=t[r]):(n??={},n[r]=void 0);for(const r in t)Object.hasOwn(e,r)||(n??={},n[r]=t[r]);return n}function Yr(e,t,n,r){if(t===n||t.isEqualTo(n))return e;const s=t.nodeType;if(s===n.nodeType){if(s===3||s===8)return e.data=n.text,e;if(s===1&&t.isSameKind(n)){const o=Kh(t.attrs,n.attrs),a=()=>{if(n.attrs.dangerouslySetInnerHTML)return;const l=Ho(n,r);Xo(e,t.childs,n.childs,Go(n,l,r))};return o?Yo(e,o,a):a(),!(o&&"value"in o)&&t.tag==="SELECT"&&n.attrs.value!==void 0&&Ko(e,n.attrs.value),e}if(s===11)return Xo(e,t.childs,n.childs,r),e}const i=n.toDom(r);return e.parentNode?.replaceChild(i,e),i}function Xo(e,t,n,r){if(t.length===0){Wr(e,n,r);return}if(n.length===0){e.replaceChildren();return}if(t.length===n.length){let l=!1;for(let c=0;c<t.length;c++)if(mt(t[c])!=null||mt(n[c])!=null){l=!0;break}if(!l){let c=e.firstChild;for(let f=0;f<t.length;f++){const p=c.nextSibling;Yr(c,t[f],n[f],r),c=p}return}}const s=Array.from(e.childNodes),i=Object.create(null);for(let l=0;l<t.length;l++){const c=mt(t[l]);c!=null&&(i[c]=l)}const o=new Uint8Array(t.length);let a=0;for(let l=0;l<n.length;l++){const c=n[l],f=mt(c);let p=-1;if(f!=null)f in i&&!o[i[f]]&&(p=i[f]);else for(;a<t.length;){if(!o[a]&&mt(t[a])==null){p=a++;break}a++}if(p>=0){o[p]=1;const g=Yr(s[p],t[p],c,r),y=e.childNodes[l]??null;g!==y&&e.insertBefore(g,y)}else{const g=e.childNodes[l]??null;e.insertBefore(c.toDom(r),g)}}for(let l=t.length-1;l>=0;l--)!o[l]&&s[l].parentNode===e&&e.removeChild(s[l])}function zh(e,t,n,r){if(e==null)return t.replaceChildren(),{vnode:null,dom:null};const s=e instanceof pe;if(r&&r.vnode instanceof pe===s){const o=s?t:r.dom,a=Yr(o,r.vnode,e,n);return{vnode:e,dom:s?t:a}}const i=e.toDom(n);return t.replaceChildren(i),{vnode:e,dom:s?t:i}}function Yh(e,t,n,r){const s={};let i;if(t)for(const c in t){const f=t[c];c==="key"?i=f:c==="namespace"?r=r??f:s[c]=f}if(r==null){const c=e.toLowerCase();c==="svg"?(r=qo,e="svg"):c==="math"&&(r=Uh,e="math")}const o=e.charCodeAt(0),a=r==null&&o>=97&&o<=122&&e===e.toLowerCase()?e.toUpperCase():e,l=[];return Kr(l,n),new sn(a,s,l,i,r)}function Xh(e,t){if(e instanceof dt){const s=t.lookupDynamicLocated(e.name);return s?.path==null?[s?.value??null,t.renderPath,null]:[s.value,t.renderPath.pushFrame(s.path),s.path]}const n=e.toPathItem?.()??null;if(n===null)return[e.eval(t),t.renderPath,null];const r=t.renderPath.pushItem(n);return[e.eval(t),r,t.pendingFrame?r.toTransactionPath():null]}var gt=class{render(e,t){return null}setDataAttr(e,t){}isConstant(){return!1}isWhiteSpace(){return!1}optimize(){}},Xr=class extends gt{constructor(e){super(),this.val=e}render(e,t){return this.val}isWhiteSpace(){for(let e=0;e<this.val.length;e++){const t=this.val.charCodeAt(e);if(!(t===32||t===10||t===9||t===13))return!1}return!0}hasNewLine(){for(let e=0;e<this.val.length;e++){const t=this.val.charCodeAt(e);if(t===10||t===13)return!0}return!1}condenseWhiteSpace(e=""){this.val=e}isConstant(){return!0}},Ne=class extends Xr{render(e,t){return t.renderComment(this.val)}};function on(e){return e.isConstant()?new af(e):(e.optimize(),e)}var Jo=class extends gt{constructor(e){super(),this.childs=e}isConstant(){return this.childs.every(e=>e.isConstant())}optimize(){const{childs:e}=this;for(let t=0;t<e.length;t++)e[t]=on(e[t])}},Qo=class extends Jo{constructor(e,t,n,r=null){super(n),this.tagName=e,this.attrs=t,this.namespace=r}render(e,t){const n=new Array(this.childs.length);for(let r=0;r<n.length;r++)n[r]=this.childs[r].render(e,t);return t.renderTag(this.tagName,this.attrs.eval(e),n,this.namespace)}setDataAttr(e,t){this.attrs.setDataAttr(e,t)}isConstant(){return this.attrs.isConstant()&&super.isConstant()}},Jr=class extends Jo{render(e,t){return t.renderFragment(this.childs.map(n=>n.render(e,t)))}setDataAttr(e,t){for(const n of this.childs)n.setDataAttr(e,t)}},Be=e=>e.length===1?e[0]:new Jr(e),Jh=/^[a-zA-Z][a-zA-Z0-9-]*$/,Ve=class gn extends gt{constructor(t,n){super(),this.nodeId=t,this.val=n}toPathStep(t){return this.val?.toPathItem?.()??null}static parse(t,n){const r=n.parseHTML(t);if(r.length===0)return new Ne("Empty View in ANode.parse");if(r.length===1)return gn.fromDOM(r[0],n);const s=[];for(let o=0;o<r.length;o++){const a=gn.fromDOM(r[o],n);a!==null&&s.push(a)}const i=ia(s);return i.length===0?new Ne("Empty View in ANode.parse"):Be(i)}static fromDOM(t,n){if(t.nodeType===3)return new Xr(t.textContent);if(t.nodeType===8)return new Ne(t.textContent);const{childNodes:r,attributes:s,tagName:i}=t,o=[];for(let l=0;l<r.length;l++){const c=gn.fromDOM(r[l],n);c!==null&&o.push(c)}const a=n.currentTag;n.currentTag=i;try{const l=s[0]?.name==="@x";if(i==="X"||l)return Qh(s,o,l?1:0,n);if(i.charCodeAt(1)===58&&(i.charCodeAt(0)===88||i.charCodeAt(0)===120)){const c=i.slice(2).toLowerCase();if(c==="slot"){const g=s.getNamedItem("name")?.value??"_";return n.frame.macroSlots[g]??Be(o)}const[f,p]=new Co(n).parse(s,!0);return n.onAttributes(f,p,null,!0,i),Zo(n.newMacroNode(c,f.toMacroVars(),o),n,p)}else if(Jh.test(i)){const[c,f,p]=new Co(n).parse(s);n.onAttributes(c,f,p,!1,i),p&&o.unshift(new na(null,p));const g=i!=="PRE"?ia(o):o,y=t.namespaceURI,E=y&&y!==jo?y:null;return Zo(new Qo(i,c,g,E),n,f)}return new Ne(`Error: InvalidTagName ${i}`)}finally{n.currentTag=a}}};function Qh(e,t,n,r){if(e.length<=n)return Be(t);const{name:s,value:i}=e[n];ts[s]?.ignoresChildren&&wf(t)&&r.onParseIssue("x-op-ignores-children",{op:s});const o=e.getNamedItem("as")?.value??null,a=o===null?null:Zh(o,r);let l;switch(s){case"slot":l=new cf(null,new V(i),Be(t));break;case"text":l=r.addNodeIf(na,wt(s,i,r,de));break;case"render":l=r.addNodeIf(sf,wt(s,i,r,uh),a);break;case"render-it":l=r.addNode(ta,a);break;case"render-each":l=of(r,i,a,e);break;case"show":{const c=wt(s,i,r,$e);l=r.addNodeIf(Qr,c,Be(t));break}case"hide":{const c=wt(s,i,r,$e);l=r.addNodeIf(Zr,c,Be(t));break}default:return r.onParseIssue("unknown-x-op",{name:s,value:i}),new Ne(`Error: InvalidSpecialTagOp ${s}=${i}`)}return ef(l,e,s,n+1,r)}function wt(e,t,n,r){const s=r(t,n);return s===null&&n.onParseIssue("bad-value",{role:"x-op",op:e,value:t}),s}function Zh(e,t){return de(e,t)??new V(e)}function ef(e,t,n,r,s){const{consumed:i,wrappable:o}=ts[n],a=[];for(let l=r;l<t.length;l++){const c=t[l],f=c.name;if(i.has(f))continue;if(o&&f.charCodeAt(0)===64){const g=ts[f.slice(1)]?.wrapper;if(g){a.push([g,$e(c.value,s)]);continue}}const p={op:n,name:f,value:c.value};s.onParseIssue("unknown-x-attr",p)}for(let l=a.length-1;l>=0;l--){const[c,f]=a[l],p=s.addNodeIf(c,f,e);p!==null&&(e=p)}return e}function Zo(e,t,n){if(n)for(let r=n.length-1;r>=0;r--){const s=tf(n[r],t);s&&(s.wrapNode(e),e=s)}return e}function tf(e,t){const n=ff[e.name],r=n.register?t.addNodeIf(n,e.val):e.val&&new n(null,e.val);return r!==null&&e.name==="each"&&(r.iterInfo.enrichWithVal=e.enrichWithVal??null,r.iterInfo.whenVal=e.whenVal??null,r.iterInfo.loopWithVal=e.loopWithVal??null),r}var nf=class extends gt{constructor(e,t,n,r){super(),this.name=e,this.attrs=t,this.slots=n,this.px=r,this.node=null,this.dataAttrs={}}compile(e){const{name:t,attrs:n,slots:r}=this;if(this.px.isInsideMacro(t))throw new Error(`Recursive macro expansion: ${t}`);const s=e.lookupMacro(t);if(s===null)this.node=new Ne(`bad macro: ${t}`);else{const i={...s.defaults,...n};this.node=s.expand(this.px.enterMacro(t,i,r));for(const o in this.dataAttrs)this.node.setDataAttr(o,this.dataAttrs[o])}}render(e,t){return this.node.render(e,t)}setDataAttr(e,t){this.dataAttrs[e]=t}isConstant(){return this.node.isConstant()}optimize(){this.node=on(this.node)}},rf=class{constructor(e,t){this.defaults=e,this.rawView=t}expand(e){return Ve.parse(this.rawView,e)}},ea=class extends Ve{constructor(e,t,n){super(e,t),this.viewVal=n}evalViewName(e){return this.viewVal?this.viewVal.eval(e):null}},sf=class extends ea{render(e,t){const[n,r,s]=Xh(this.val,e),i=e.enter(n,{},!0,r,!1);return t.renderIt(i,this,this.evalViewName(e),s)}toPathStep(e){return this.val instanceof dt?null:super.toPathStep(e)}},ta=class extends ea{render(e,t){const n=e.pendingFrame?e.renderPath.toTransactionPath():null,r=e.enter(e.it,{},!0,e.renderPath,!1);return t.renderIt(r,this,this.evalViewName(e),n)}toPathStep(e){const t=e.next();if(t===null)return null;const n=t.resolveNode();return n instanceof es&&t.hasKey?n.val instanceof dt?null:new $u(n.val.name,t.key):null}};function of(e,t,n,r){const s=wt("render-each",t,e,Ao);if(s===null)return null;const i=e.addNode(ta,n),{whenVal:o,loopWithVal:a}=Oh(r,e),l=e.addNodeIf(es,s);return l.iterInfo.whenVal=o,l.iterInfo.loopWithVal=a,l.fromRenderEach=!0,l.wrapNode(i),l}var na=class extends Ve{render(e,t){return this.val.eval(e)}},af=class extends gt{constructor(e){super(),this.node=e,this._render=(t,n)=>{const r=e.render(t,n);return this._render=(s,i)=>r,r}}render(e,t){return this._render(e,t)}},Ue=class extends Ve{constructor(e,t,n=null){super(e,t),this.node=n}wrapNode(e){this.node=e}setDataAttr(e,t){this.node.setDataAttr(e,t)}optimize(){this.node=on(this.node)}static register=!1},Qr=class extends Ue{render(e,t){return this.val.eval(e)?this.node.render(e,t):null}},Zr=class extends Ue{render(e,t){return this.val.eval(e)?null:this.node.render(e,t)}},lf=class extends Ue{render(e,t){return this.node.render(e.pushViewName(this.val.eval(e)),t)}},cf=class extends Ue{isSlotNode=!0;optimize(){this.node.optimize()}},uf=class extends Ue{render(e,t){const n=this.val.evalAsHandler(e)?.call(e.it)??{},r=this.node.render(e.enter(e.it,n,!1),t);return t.renderScopeMeta(this.nodeId,r)}toPathStep(e){return new Lu(this.val)}wrapNode(e){this.node=e,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0},es=class extends Ue{constructor(e,t){super(e,t),this.iterInfo=new hf}render(e,t){return t.renderEachWhen(e,this)}evalIter(e){const{whenVal:t,loopWithVal:n,enrichWithVal:r}=this.iterInfo;return{seq:this.val.eval(e)??[],filter:t?.evalAsHandler(e)??Ro,loopWith:n?.evalAsHandler(e)??$o,enricher:r?.evalAsHandler(e)??null}}enrichBinds(e,t){const{seq:n,filter:r,loopWith:s,enricher:i}=this.evalIter(e),o=Bo(e,r);return Bh({seq:n,it:e.it,loopWith:s,enricher:i,ctx:o},t)}toPathStep(e){return e.hasKey?new Ru(this,e.key):null}itemStep(e){return this.val instanceof nn?new se(this.val.name,e):null}static register=!0},hf=class{constructor(){this.whenVal=null,this.loopWithVal=null,this.enrichWithVal=null}};function Ae(e=[],{wrappable:t=!1,wrapper:n=null,ignoresChildren:r=!1}={}){return{consumed:new Set(e),wrappable:t,wrapper:n,ignoresChildren:r}}var ts={slot:Ae(),text:Ae([],{wrappable:!0,ignoresChildren:!0}),render:Ae(["as"],{wrappable:!0,ignoresChildren:!0}),"render-it":Ae(["as"],{wrappable:!0,ignoresChildren:!0}),"render-each":Ae(["as","@when","@loop-with"],{wrappable:!0,ignoresChildren:!0}),show:Ae([],{wrapper:Qr}),hide:Ae([],{wrapper:Zr})},ff={show:Qr,hide:Zr,each:es,scope:uf,"push-view":lf},ns=class{constructor(e=globalThis.document){this.document=e,this.nodes=[],this.events=[],this.macroNodes=[],this.parent=null,this.frame={},this.currentTag=null}isInsideMacro(e){return this.frame.macroName===e||this.parent?.isInsideMacro(e)}enterMacro(e,t,n){const r=Object.create(Object.getPrototypeOf(this));return Object.assign(r,this,{frame:{macroName:e,macroVars:t,macroSlots:n},parent:this,currentTag:null})}parseHTML(e){const t=this.document.createElement("template");return t.innerHTML=e,t.content.childNodes}addNodeIf(e,t,n){if(t!==null){const r=this.nodes.length,s=new e(r,t,n);return this.nodes.push(s),s}return null}addNode(e,t){const n=this.nodes.length,r=new e(n,null,t);return this.nodes.push(r),r}registerEvents(){const e=this.events.length,t=new yf(e);return this.events.push(t),t}newMacroNode(e,t,n){const r=[],s={_:new Jr(r)};for(const o of n)o.isSlotNode?s[o.val.val]=o.node:o.isWhiteSpace()||r.push(o);const i=new nf(e,t,s,this);return this.macroNodes.push(i),i}compile(e){for(let t=0;t<this.macroNodes.length;t++)this.macroNodes[t].compile(e)}*genEventNames(){for(const e of this.events)yield*e.genEventNames()}getEventForId(e){return this.events[e]??null}getNodeForId(e){return this.nodes[e]??null}onAttributes(e,t,n,r,s){}onParseIssue(e,t){console.warn(`tutuca parse issue [${e}]`,t)}},df="ADDRESS,ARTICLE,ASIDE,BLOCKQUOTE,CAPTION,COL,COLGROUP,DETAILS,DIALOG,DIV,DD,DL,DT,FIELDSET,FIGCAPTION,FIGURE,FOOTER,FORM,H1,H2,H3,H4,H5,H6,HEADER,HGROUP,HR,LEGEND,LI,MAIN,MENU,NAV,OL,P,PRE,SECTION,SUMMARY,TABLE,TBODY,TD,TFOOT,TH,THEAD,TR,UL",pf=new Set(df.split(",")),ra=e=>{const t=e instanceof Jr?e.childs[0]:e;return t instanceof Qo&&pf.has(t.tagName)},mf=e=>e instanceof Xr&&e.val==="",gf=e=>e instanceof Ne||e.isWhiteSpace(),wf=e=>e.some(t=>!gf(t));function sa(e){return e.isWhiteSpace()?(e.condenseWhiteSpace(),!0):!1}function ia(e){if(e.length===0)return e;const t=e.length-1;let n=sa(e[0]);t>0&&sa(e[t])&&(n=!0);for(let r=1;r<t;r++){const s=e[r];if(!(s.isWhiteSpace()&&s.hasNewLine()))continue;const i=ra(e[r-1])&&ra(e[r+1]);s.condenseWhiteSpace(i?"":" "),i&&(n=!0)}return n?e.filter(r=>!mf(r)):e}var oa=class{constructor(e,t="No View Defined",n=""){this.name=e,this.rawView=t,this.style=n,this.anode=null,this.ctx=null}compile(e,t,n){this.ctx=e,this.anode=Ve.parse(this.rawView,e),this.anode.setDataAttr("data-cid",n),this.anode.setDataAttr("data-vid",this.name),this.ctx.compile(t),this.anode=on(this.anode)}render(e,t){if(this.anode===null)throw new Error(`tutuca: view "${this.name}" was rendered before it was compiled \u2014 its component is not registered in this app/scope. Source: ${String(this.rawView).slice(0,80).replace(/\s+/g," ")}\u2026`);return this.anode.render(e,t)}},yf=class{constructor(e){this.id=e,this.handlers=[]}add(e,t,n){this.handlers.push(new bf(e,t,n))}*genEventNames(){for(const e of this.handlers)yield e.name}getHandlersFor(e){let t=null;for(const n of this.handlers)n.name===e&&(t??=[],t.push(n));return t}},bf=class{constructor(e,t,n){this.name=e,this.handlerCall=t,this.modifierWrapper=Nf(e,n),this.modifiers=n}getHandlerAndArgs(e,t){const n=this.handlerCall.getHandlerAndArgs(e,t);return n[0]=this.modifierWrapper(n[0],t),n}},vf=e=>t=>(n,r,s,i)=>e(i)?t(n,r,s,i):n,an=e=>vf(({e:t})=>e(t)),aa=e=>an(Fe(e)),la=an(Vr),Ef=an(e=>e.metaKey),_f=an(e=>e.altKey),ca={ctrl:la,cmd:la,meta:Ef,alt:_f},ua={keydown:{send:aa("Enter"),cancel:aa("Escape")}},ha={prevent:e=>e.preventDefault?.(),stop:e=>e.stopPropagation?.()},Sf={},Tf=(e,t)=>e;function Nf(e,t){if(t.length===0)return Tf;const n=ua[e]??Sf,r=[];for(const i of t){const o=ha[i];o!==void 0&&r.push(o)}let s=r.length===0?(i,o,a,l)=>o.apply(i,a):(i,o,a,l)=>{for(const c of r)c(l.e);return o.apply(i,a)};for(const i of t){const o=n[i]??ca[i];o!==void 0&&(s=o(s))}return(i,o)=>function(...a){return s(this,i,a,o)}}var fa=Symbol("STOP"),rs=Symbol("NEXT"),ss=["dyn","lex"],je=e=>{const t=e.charCodeAt(0);return t>=65&&t<=90};function is(e,t,n=null){let r=e;for(;r!==null;){const s=r[0].lookup(t);if(s===fa)return n;if(s!==rs)return s;r=r[1]}return n}var da=class{constructor(e,t,n){this.it=e,this.binds=t,this.isFrame=n}lookup(e){const t=this.binds[e];return t===void 0?this.isFrame?fa:rs:t}},pa=class{constructor(e,t){this.binds=e,this.types=t}lookup(e){const t=(je(e)?this.types:this.binds)[e];return t===void 0?rs:t}};function Af(e){let t="",n=e;for(;n!==null;)t+=n[0],n=n[1];return t==="main"?"":t}var os=class Cs{constructor(t){Object.assign(this,t)}_with(t){return new Cs({...this,...t})}_pushProvides(){const t=this.comps.getCompFor(this.it);if(t==null)return this;const{provide:n,provideType:r}=t,s={},i={};let o=!1;const a=this._publishBase();for(const l in n){const c=n[l].toPathItem?.()??null;if(c===null)continue;const f=n[l].eval(this);s[l]={value:f,path:a===null?null:a.concat([c])},o=!0}for(const l in r)i[l]=r[l],o=!0;return o?this._with({dynBinds:[new pa(s,i),this.dynBinds]}):this}_publishBase(){const t=this.renderPath.toTransactionPath().compact();return t.lookup(this.root,as)===this.it?t:null}static root(t,n,r=null){return new Cs({comps:t,root:n,it:n,binds:[new da(n,{},!0),null],dynBinds:[new pa({},{}),null],views:["main",null],viewsId:"",renderPath:new at,pendingFrame:!1,ctx:r})._pushProvides()}enter(t,n={},r=!0,s=this.renderPath,i=null){const o=this._with({it:t,binds:[new da(t,n,r),this.binds],renderPath:s,pendingFrame:i??(r?!1:this.pendingFrame)});return r?o._pushProvides():o}pushViewName(t){const n=[t,this.views];return this._with({views:n,viewsId:Af(n)})}_pushDynBindValuesToArray(t,n){for(const r in n.provide)t.push(this.lookupDynamic(r));for(const r in n.lookup)t.push(this.lookupDynamic(r))}lookupDynamicLocated(t){if(je(t))return null;const n=is(this.dynBinds,t);if(n!=null)return n;const r=this.comps.getCompFor(this.it);if(r==null)return null;const s=r.scope?.lookupPath?.(t)??null;if(s!==null){const l=s.lookup(this.root,as);if(l!==as)return{value:l,path:s}}const i=r.lookup[t]??null;if(i===null)return null;const o=i.toPathItem?.()??null,a=i.eval(this);return o===null?{value:a,path:null}:{value:a,path:this.renderPath.toTransactionPath().concat([o])}}lookupDynamic(t){return je(t)?is(this.dynBinds,t):this.lookupDynamicLocated(t)?.value??null}lookupBind(t){return is(this.binds,t)}lookupFieldRaw(t){return this.it[t]??null}lookupMethod(t){const n=this.it[t];return n instanceof Function?n.call(this.it):null}lookupEvent(){return this.ctx?.e??null}lookupDragInfo(){return this.ctx?.dragInfo??null}getHandlerFor(t,n){return this.comps.getHandlerFor(this.it,t,n)}lookupBestView(t,n){let r=this.views;for(;r!==null;){const s=t[r[0]];if(s!==void 0)return s;r=r[1]}return t[n]}},as=Symbol("NOT_FOUND"),xe=Symbol.for("tutuca.component"),ma=class{constructor(){this.byId=new Map}registerComponent(e){this.byId.set(e.id,e)}getComponentForId(e){return this.byId.get(e)??null}getCompFor(e){const t=e?.constructor;return t?.[xe]?t:null}getHandlerFor(e,t,n){return this.getCompFor(e)?.[n][t]??null}getIntentChainFor(e,t){return this.getCompFor(e)?.scope.lookupIntentChain(t)??[]}compileStyles(){const e=[];for(const t of this.byId.values())e.push(t.compileStyle());return e.join(`
`)}},ga=class yc{constructor(t=new ma,n=null){this.comps=t,this.parent=n,this.byName={},this.intentsByName={},this.macros={},this.paths={}}enter(){return new yc(this.comps,this)}registerComponents(t,n){const{aliases:r={},paths:s}=n??{};s&&this.registerPaths(s);for(let i=0;i<t.length;i++){const o=t[i];o.scope=this.enter(),this.comps.registerComponent(o),this.byName[o.name]=o}for(const i in r){const o=this.byName[r[i]];console.assert(this.byName[i]===void 0,"alias overrides component",i),o!==void 0?this.byName[i]=o:console.warn("alias",i,"to inexistent component",r[i])}}registerPaths(t){for(const n in t){if(je(n)){console.warn("registerPaths: a type name has no path",n);continue}this.paths[n]=t[n].toPath()}}lookupPath(t){return this.paths[t]??this.parent?.lookupPath(t)??null}registerMacros(t){for(const n in t){const r=n.toLowerCase();console.assert(this.macros[r]===void 0,"macro key collision",r),this.macros[r]=t[n]}}getCompFor(t){return this.comps.getCompFor(t)}registerIntentHandlers(t){for(const n in t){const r=t[n];this.intentsByName[n]=Array.isArray(r)?r:[r]}}lookupIntentChain(t){const n=this.intentsByName[t]??[],r=this.parent?.lookupIntentChain(t)??[];return r.length===0?n:n.concat(r)}lookupComponent(t){return this.byName[t]??this.parent?.lookupComponent(t)??null}hasProvider(t){for(const n in this.byName)if(this.byName[n].provide?.[t]!==void 0)return!0;return this.parent?.hasProvider(t)??!1}lookupMacro(t){return this.macros[t]??this.parent?.lookupMacro(t)??null}},ln=e=>typeof e=="string",xf="name view style commonStyle globalStyle receive intent alter views provide lookup fields methods statics",If=new Set(xf.split(" ")),Of=0;function Pf(e,t){e[xe]=e,e.id=Of++,e.views={main:new oa("main",t.view,t.style)},e.commonStyle=t.commonStyle??"",e.globalStyle=t.globalStyle??"",e.receive=t.receive??{},e.intent=t.intent??{},e.alter=t.alter??{};for(const n in t.views??{}){const r=t.views[n],{view:s,style:i}=ln(r)?{view:r}:r;e.views[n]=new oa(n,s,i)}e._rawProvide=t.provide??{},e._rawLookup=t.lookup??[],e.provide={},e.provideType={},e.lookup={},e.scope=null,e.spec=t,e.extra={};for(const n of Object.keys(t))If.has(n)||(e.extra[n]=t[n]);return Object.assign(e,wa)}var wa={compile(e){for(const n in this.views)this.views[n].compile(new e,this.scope,this.id);const t=this.views.main.ctx;for(const n in this._rawProvide){if(je(n)){this._rawProvide[n]==="self"&&(this.provideType[n]=this);continue}const r=fh(this._rawProvide[n],t);r&&(this.provide[n]=r)}for(const n of this._rawLookup){const r=ln(n)?n:ln(n?.name)?n.name:null;if(r===null)continue;const s=ln(n?.default)?n.default:null;this.lookup[r]=s===null?null:hh(s,t)}for(const n in this.lookup)this.provide[n]!==void 0&&console.warn("name declared in both provide and lookup",this.name,n)},getView(e){return this.views[e]??this.views.main},getEventForId(e,t){return this.getView(t).ctx.getEventForId(e)},getNodeForId(e,t){return this.getView(t).ctx.getNodeForId(e)},compileStyle(){const{id:e,commonStyle:t,globalStyle:n,views:r}=this,s=t?[`[data-cid="${e}"]{${t}}`]:[];n!==""&&s.push(n);for(const i in r){const{style:o}=r[i];o!==""&&s.push(`[data-cid="${e}"][data-vid="${i}"]{${o}}`)}return s.join(`
`)}},ya=class extends ns{constructor(...e){super(...e),this.classes=new Set}_addClasses(e){for(const t of e.split(/\s+/))this.classes.add(t)}onAttributes(e,t,n,r,s){if(Array.isArray(e.items))for(const i of e.items){if(i.name!=="class")continue;const{val:o,thenVal:a,elseVal:l}=i;a!==void 0?(this._maybeAddVal(a),this._maybeAddVal(l)):this._maybeAddVal(o)}else{const i=e.items.class;i&&this._addClasses(i)}}_maybeAddVal(e){!this._maybeAddStrTpl(e)&&typeof e?.val=="string"&&this._addClasses(e.val)}_maybeAddStrTpl(e){if(e?.vals!==void 0){for(const t of e.vals)t instanceof V&&t.val!==""&&this._addClasses(t.val);return!0}return!1}};function Mf(e){const t=new Set;for(const n of e.comps.byId.values())for(const r in n.views){const s=n.views[r];for(const i of s.ctx.classes)t.add(i)}return t}var T={Tab:9,NewLine:10,FormFeed:12,CarriageReturn:13,Space:32,ExclamationMark:33,SingleQuote:39,DoubleQuote:34,Dash:45,Slash:47,Lt:60,Eq:61,Gt:62,Questionmark:63,UpperA:65,LowerA:97,UpperZ:90,LowerZ:122,OpeningSquareBracket:91},w={Text:1,BeforeTagName:2,InTagName:3,InSelfClosingTag:4,BeforeClosingTagName:5,InClosingTagName:6,AfterClosingTagName:7,BeforeAttributeName:8,InAttributeName:9,AfterAttributeName:10,BeforeAttributeValue:11,InAttributeValueDq:12,InAttributeValueSq:13,InAttributeValueNq:14,BeforeDeclaration:15,InDeclaration:16,InProcessingInstruction:17,BeforeComment:18,CDATASequence:19,DeclarationSequence:20,InSpecialComment:21,InCommentLike:22,SpecialStartSequence:23,InSpecialTag:24,InPlainText:25};function Ie(e){return e===T.Space||e===T.NewLine||e===T.Tab||e===T.FormFeed||e===T.CarriageReturn}function qe(e){return e===T.Slash||e===T.Gt||Ie(e)}function Cf(e){return e>=T.LowerA&&e<=T.LowerZ||e>=T.UpperA&&e<=T.UpperZ}var Oe={NoValue:0,Unquoted:1,Single:2,Double:3},A={Empty:new Uint8Array(0),Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,33,62]),Doctype:new Uint8Array([100,111,99,116,121,112,101]),IframeEnd:new Uint8Array([60,47,105,102,114,97,109,101]),NoembedEnd:new Uint8Array([60,47,110,111,101,109,98,101,100]),NoframesEnd:new Uint8Array([60,47,110,111,102,114,97,109,101,115]),Plaintext:new Uint8Array([60,47,112,108,97,105,110,116,101,120,116]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101]),TextareaEnd:new Uint8Array([60,47,116,101,120,116,97,114,101,97]),XmpEnd:new Uint8Array([60,47,120,109,112])},Df=new Map([[A.IframeEnd[2],A.IframeEnd],[A.NoembedEnd[2],A.NoembedEnd],[A.Plaintext[2],A.Plaintext],[A.ScriptEnd[2],A.ScriptEnd],[A.TitleEnd[2],A.TitleEnd],[A.XmpEnd[2],A.XmpEnd]]),kf=class{constructor({xmlMode:e=!1,recognizeSelfClosing:t=e}={},n){this.cbs=n,this.xmlMode=e,this.recognizeSelfClosing=t,this.state=w.Text,this.buffer="",this.sectionStart=0,this.index=0,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=A.Empty,this.sequenceIndex=0}reset(){this.state=w.Text,this.buffer="",this.sectionStart=0,this.index=0,this.isSpecial=!1,this.currentSequence=A.Empty,this.sequenceIndex=0,this.running=!0,this.offset=0}write(e){this.offset+=this.buffer.length,this.buffer=e,this.parse()}end(){this.running&&this.finish()}pause(){this.running=!1}resume(){this.running=!0,this.index<this.buffer.length+this.offset&&this.parse()}stateText(e){(e===T.Lt||this.fastForwardTo(T.Lt))&&(this.index>this.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=w.BeforeTagName,this.sectionStart=this.index)}enterTagBody(){this.currentSequence===A.Plaintext?(this.currentSequence=A.Empty,this.state=w.InPlainText):this.isSpecial?(this.state=w.InSpecialTag,this.sequenceIndex=0):this.state=w.Text}stateSpecialStartSequence(e){const t=e|32;if(this.sequenceIndex<this.currentSequence.length){if(t===this.currentSequence[this.sequenceIndex]){this.sequenceIndex++;return}if(this.sequenceIndex===3){if(this.currentSequence===A.ScriptEnd&&t===A.StyleEnd[3]){this.currentSequence=A.StyleEnd,this.sequenceIndex=4;return}if(this.currentSequence===A.TitleEnd&&t===A.TextareaEnd[3]){this.currentSequence=A.TextareaEnd,this.sequenceIndex=4;return}}else if(this.sequenceIndex===4&&this.currentSequence===A.NoembedEnd&&t===A.NoframesEnd[4]){this.currentSequence=A.NoframesEnd,this.sequenceIndex=5;return}}else if(qe(e)){this.sequenceIndex=0,this.state=w.InTagName,this.stateInTagName(e);return}this.isSpecial=!1,this.currentSequence=A.Empty,this.sequenceIndex=0,this.state=w.InTagName,this.stateInTagName(e)}stateCDATASequence(e){e===A.Cdata[this.sequenceIndex]?++this.sequenceIndex===A.Cdata.length&&(this.state=w.InCommentLike,this.currentSequence=A.CdataEnd,this.sequenceIndex=0,this.sectionStart=this.index+1):(this.sequenceIndex=0,this.xmlMode?(this.state=w.InDeclaration,this.stateInDeclaration(e)):(this.state=w.InSpecialComment,this.stateInSpecialComment(e)))}fastForwardTo(e){for(;++this.index<this.buffer.length+this.offset;)if(this.buffer.charCodeAt(this.index-this.offset)===e)return!0;return this.index=this.buffer.length+this.offset-1,!1}emitComment(e){this.cbs.oncomment(this.sectionStart,this.index,e),this.sequenceIndex=0,this.sectionStart=this.index+1,this.state=w.Text}stateInCommentLike(e){!this.xmlMode&&this.currentSequence===A.CommentEnd&&this.sequenceIndex<=1&&this.index===this.sectionStart+this.sequenceIndex&&e===T.Gt?this.emitComment(this.sequenceIndex):this.currentSequence===A.CommentEnd&&this.sequenceIndex===2&&e===T.Gt?this.emitComment(2):this.currentSequence===A.CommentEnd&&this.sequenceIndex===this.currentSequence.length-1&&e!==T.Gt?this.sequenceIndex=+(e===T.Dash):e===this.currentSequence[this.sequenceIndex]?++this.sequenceIndex===this.currentSequence.length&&(this.currentSequence===A.CdataEnd?this.cbs.oncdata(this.sectionStart,this.index,2):this.cbs.oncomment(this.sectionStart,this.index,3),this.sequenceIndex=0,this.sectionStart=this.index+1,this.state=w.Text):this.sequenceIndex===0?this.fastForwardTo(this.currentSequence[0])&&(this.sequenceIndex=1):e!==this.currentSequence[this.sequenceIndex-1]&&(this.sequenceIndex=0)}isTagStartChar(e){return this.xmlMode?!qe(e):Cf(e)}stateInSpecialTag(e){if(this.sequenceIndex===this.currentSequence.length){if(qe(e)){const t=this.index-this.currentSequence.length;if(this.sectionStart<t){const n=this.index;this.index=t,this.cbs.ontext(this.sectionStart,t),this.index=n}this.isSpecial=!1,this.sectionStart=t+2,this.stateInClosingTagName(e);return}this.sequenceIndex=0}(e|32)===this.currentSequence[this.sequenceIndex]?this.sequenceIndex+=1:this.sequenceIndex===0?this.fastForwardTo(T.Lt)&&(this.sequenceIndex=1):this.sequenceIndex=+(e===T.Lt)}stateBeforeTagName(e){if(e===T.ExclamationMark)this.state=w.BeforeDeclaration,this.sectionStart=this.index+1;else if(e===T.Questionmark)this.xmlMode?(this.state=w.InProcessingInstruction,this.sequenceIndex=0,this.sectionStart=this.index+1):(this.state=w.InSpecialComment,this.sectionStart=this.index);else if(this.isTagStartChar(e)){this.sectionStart=this.index;const t=this.xmlMode||this.cbs.isInForeignContext?.()?void 0:Df.get(e|32);t===void 0?this.state=w.InTagName:(this.isSpecial=!0,this.currentSequence=t,this.sequenceIndex=3,this.state=w.SpecialStartSequence)}else e===T.Slash?this.state=w.BeforeClosingTagName:(this.state=w.Text,this.stateText(e))}stateInTagName(e){qe(e)&&(this.cbs.onopentagname(this.sectionStart,this.index),this.sectionStart=-1,this.state=w.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateBeforeClosingTagName(e){Ie(e)?this.xmlMode||(this.state=w.InSpecialComment,this.sectionStart=this.index):e===T.Gt?(this.state=w.Text,this.xmlMode||(this.sectionStart=this.index+1)):(this.state=this.isTagStartChar(e)?w.InClosingTagName:w.InSpecialComment,this.sectionStart=this.index)}stateInClosingTagName(e){qe(e)&&(this.cbs.onclosetag(this.sectionStart,this.index),this.sectionStart=-1,this.state=w.AfterClosingTagName,this.stateAfterClosingTagName(e))}stateAfterClosingTagName(e){(e===T.Gt||this.fastForwardTo(T.Gt))&&(this.state=w.Text,this.sectionStart=this.index+1)}stateBeforeAttributeName(e){e===T.Gt?(this.cbs.onopentagend(this.index),this.enterTagBody(),this.sectionStart=this.index+1):e===T.Slash?this.state=w.InSelfClosingTag:Ie(e)||(this.state=w.InAttributeName,this.sectionStart=this.index)}stateInSelfClosingTag(e){if(e===T.Gt){if(this.cbs.onselfclosingtag(this.index),this.sectionStart=this.index+1,!this.recognizeSelfClosing){this.enterTagBody();return}this.state=w.Text,this.isSpecial=!1,this.currentSequence=A.Empty}else Ie(e)||(this.state=w.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateInAttributeName(e){(e===T.Eq||qe(e))&&(this.cbs.onattribname(this.sectionStart,this.index),this.sectionStart=this.index,this.state=w.AfterAttributeName,this.stateAfterAttributeName(e))}stateAfterAttributeName(e){e===T.Eq?this.state=w.BeforeAttributeValue:e===T.Slash||e===T.Gt?(this.cbs.onattribend(Oe.NoValue,this.sectionStart),this.sectionStart=-1,this.state=w.BeforeAttributeName,this.stateBeforeAttributeName(e)):Ie(e)||(this.cbs.onattribend(Oe.NoValue,this.sectionStart),this.state=w.InAttributeName,this.sectionStart=this.index)}stateBeforeAttributeValue(e){e===T.DoubleQuote?(this.state=w.InAttributeValueDq,this.sectionStart=this.index+1):e===T.SingleQuote?(this.state=w.InAttributeValueSq,this.sectionStart=this.index+1):Ie(e)||(this.sectionStart=this.index,this.state=w.InAttributeValueNq,this.stateInAttributeValueNoQuotes(e))}handleInAttributeValue(e,t){(e===t||this.fastForwardTo(t))&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(t===T.DoubleQuote?Oe.Double:Oe.Single,this.index+1),this.state=w.BeforeAttributeName)}stateInAttributeValueDoubleQuotes(e){this.handleInAttributeValue(e,T.DoubleQuote)}stateInAttributeValueSingleQuotes(e){this.handleInAttributeValue(e,T.SingleQuote)}stateInAttributeValueNoQuotes(e){(Ie(e)||e===T.Gt)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(Oe.Unquoted,this.index),this.state=w.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateBeforeDeclaration(e){e===T.OpeningSquareBracket?(this.state=w.CDATASequence,this.sequenceIndex=0):this.xmlMode?this.state=e===T.Dash?w.BeforeComment:w.InDeclaration:(e|32)===A.Doctype[0]?(this.state=w.DeclarationSequence,this.currentSequence=A.Doctype,this.sequenceIndex=1):e===T.Gt?(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=w.Text,this.sectionStart=this.index+1):e===T.Dash?this.state=w.BeforeComment:this.state=w.InSpecialComment}stateDeclarationSequence(e){this.sequenceIndex===this.currentSequence.length?(this.state=w.InDeclaration,this.stateInDeclaration(e)):(e|32)===this.currentSequence[this.sequenceIndex]?this.sequenceIndex+=1:e===T.Gt?(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=w.Text,this.sectionStart=this.index+1):this.state=w.InSpecialComment}stateInDeclaration(e){(e===T.Gt||this.fastForwardTo(T.Gt))&&(this.cbs.ondeclaration(this.sectionStart,this.index),this.state=w.Text,this.sectionStart=this.index+1)}stateInProcessingInstruction(e){e===T.Questionmark?this.sequenceIndex=1:e===T.Gt&&this.sequenceIndex===1?(this.cbs.onprocessinginstruction(this.sectionStart,this.index-1),this.sequenceIndex=0,this.state=w.Text,this.sectionStart=this.index+1):this.sequenceIndex=Number(this.fastForwardTo(T.Questionmark))}stateBeforeComment(e){e===T.Dash?(this.state=w.InCommentLike,this.currentSequence=A.CommentEnd,this.sequenceIndex=0,this.sectionStart=this.index+1):this.xmlMode?this.state=w.InDeclaration:e===T.Gt?(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=w.Text,this.sectionStart=this.index+1):this.state=w.InSpecialComment}stateInSpecialComment(e){(e===T.Gt||this.fastForwardTo(T.Gt))&&(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=w.Text,this.sectionStart=this.index+1)}cleanup(){this.running&&this.sectionStart!==this.index&&(this.state===w.Text||this.state===w.InPlainText||this.state===w.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===w.InAttributeValueDq||this.state===w.InAttributeValueSq||this.state===w.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))}shouldContinue(){return this.index<this.buffer.length+this.offset&&this.running}parse(){for(;this.shouldContinue();){const e=this.buffer.charCodeAt(this.index-this.offset);switch(this.state){case w.Text:this.stateText(e);break;case w.InPlainText:this.index=this.buffer.length+this.offset-1;break;case w.SpecialStartSequence:this.stateSpecialStartSequence(e);break;case w.InSpecialTag:this.stateInSpecialTag(e);break;case w.CDATASequence:this.stateCDATASequence(e);break;case w.DeclarationSequence:this.stateDeclarationSequence(e);break;case w.InAttributeValueDq:this.stateInAttributeValueDoubleQuotes(e);break;case w.InAttributeName:this.stateInAttributeName(e);break;case w.InCommentLike:this.stateInCommentLike(e);break;case w.InSpecialComment:this.stateInSpecialComment(e);break;case w.BeforeAttributeName:this.stateBeforeAttributeName(e);break;case w.InTagName:this.stateInTagName(e);break;case w.InClosingTagName:this.stateInClosingTagName(e);break;case w.BeforeTagName:this.stateBeforeTagName(e);break;case w.AfterAttributeName:this.stateAfterAttributeName(e);break;case w.InAttributeValueSq:this.stateInAttributeValueSingleQuotes(e);break;case w.BeforeAttributeValue:this.stateBeforeAttributeValue(e);break;case w.BeforeClosingTagName:this.stateBeforeClosingTagName(e);break;case w.AfterClosingTagName:this.stateAfterClosingTagName(e);break;case w.InAttributeValueNq:this.stateInAttributeValueNoQuotes(e);break;case w.InSelfClosingTag:this.stateInSelfClosingTag(e);break;case w.InDeclaration:this.stateInDeclaration(e);break;case w.BeforeDeclaration:this.stateBeforeDeclaration(e);break;case w.BeforeComment:this.stateBeforeComment(e);break;case w.InProcessingInstruction:this.stateInProcessingInstruction(e);break}this.index++}this.cleanup()}finish(){this.handleTrailingData(),this.cbs.onend()}handleTrailingCommentLikeData(e){if(this.state!==w.InCommentLike)return!1;if(this.currentSequence===A.CdataEnd)if(this.xmlMode)this.sectionStart<e&&this.cbs.oncdata(this.sectionStart,e,0);else{const t=this.sectionStart-A.Cdata.length-1;this.cbs.oncomment(t,e,0)}else{const t=this.xmlMode?0:Math.min(this.sequenceIndex,A.CommentEnd.length-1);this.cbs.oncomment(this.sectionStart,e,t)}return!0}handleTrailingMarkupDeclaration(e){if(this.xmlMode)switch(this.state){case w.InSpecialComment:case w.BeforeComment:case w.CDATASequence:case w.DeclarationSequence:case w.InDeclaration:return this.cbs.ontext(this.sectionStart,e),!0;default:return!1}switch(this.state){case w.BeforeDeclaration:case w.InSpecialComment:case w.BeforeComment:case w.CDATASequence:return this.cbs.oncomment(this.sectionStart,e,0),!0;case w.DeclarationSequence:return this.sequenceIndex!==A.Doctype.length&&this.cbs.oncomment(this.sectionStart,e,0),!0;case w.InDeclaration:return!0;default:return!1}}handleTrailingData(){const e=this.buffer.length+this.offset;if(!(this.handleTrailingCommentLikeData(e)||this.handleTrailingMarkupDeclaration(e))&&!(this.sectionStart>=e))switch(this.state){case w.InTagName:case w.BeforeAttributeName:case w.BeforeAttributeValue:case w.AfterAttributeName:case w.InAttributeName:case w.InAttributeValueSq:case w.InAttributeValueDq:case w.InAttributeValueNq:case w.InClosingTagName:break;default:this.cbs.ontext(this.sectionStart,e)}}},Lf=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Rf=new Set(["script","style","iframe","noembed","noframes","noscript","xmp","plaintext"]),ls=new Set(["address","applet","area","article","aside","base","basefont","bgsound","blockquote","br","button","caption","center","col","colgroup","dd","details","dir","div","dl","dt","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","iframe","img","input","keygen","li","link","listing","main","marquee","menu","meta","nav","noembed","noframes","noscript","object","ol","p","param","plaintext","pre","script","search","section","select","source","style","summary","table","tbody","td","template","textarea","tfoot","th","thead","title","tr","track","ul","wbr","xmp"]),ba=new Set(["a","b","big","code","em","font","i","nobr","s","small","strike","strong","tt","u"]),cs=new Set(["applet","caption","html","table","td","th","marquee","object","select","template"]),va=new Set(["mi","mo","mn","ms","mtext"]),Ea=new Set(["foreignobject","desc","title"]),$f=new Set([...cs,"ol","ul"]),Ff=new Set([...cs,"button"]),Bf=cs,Vf=new Set(["html","table","template"]),Uf=new Set(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"]),jf=new Set(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","xChannelSelector","yChannelSelector","zoomAndPan"]),qf=new Set(["definitionURL"]),_a=new Map;for(const e of jf)_a.set(e.toLowerCase(),e);var Sa=new Map;for(const e of qf)Sa.set(e.toLowerCase(),e);var Hf=new Set(["b","big","blockquote","body","br","center","code","dd","div","dl","dt","em","embed","h1","h2","h3","h4","h5","h6","head","hr","i","img","li","listing","menu","meta","nobr","ol","p","pre","ruby","s","small","span","strong","strike","sub","sup","table","tt","u","ul","var"]),Gf=new Set(["input","keygen","textarea","select"]),_=Object.freeze({inBody:"inBody",inTable:"inTable",inCaption:"inCaption",inColumnGroup:"inColumnGroup",inTableBody:"inTableBody",inRow:"inRow",inCell:"inCell",inSelect:"inSelect",inSelectInTable:"inSelectInTable",inTemplate:"inTemplate"}),v=Object.freeze({html:"html",svg:"svg",math:"math"}),Ta=Object.freeze({template:{mode:_.inTemplate,ns:v.html},body:{mode:_.inBody,ns:v.html},div:{mode:_.inBody,ns:v.html},table:{mode:_.inTable,ns:v.html},tbody:{mode:_.inTableBody,ns:v.html},thead:{mode:_.inTableBody,ns:v.html},tfoot:{mode:_.inTableBody,ns:v.html},caption:{mode:_.inCaption,ns:v.html},colgroup:{mode:_.inColumnGroup,ns:v.html},tr:{mode:_.inRow,ns:v.html},td:{mode:_.inCell,ns:v.html},th:{mode:_.inCell,ns:v.html},select:{mode:_.inSelect,ns:v.html},svg:{mode:_.inBody,ns:v.svg},math:{mode:_.inBody,ns:v.math}}),Wf="HTML_TAG_NAME_HAS_UPPERCASE",Kf="HTML_SVG_TAG_WILL_LOWERCASE",zf="HTML_SVG_ATTR_WILL_LOWERCASE",Yf="HTML_MATHML_ATTR_WILL_LOWERCASE",W="HTML_TAG_NOT_ALLOWED_IN_PARENT",Xf="HTML_TEXT_NOT_ALLOWED_IN_PARENT",Jf="HTML_VOID_ELEMENT_HAS_CLOSE_TAG",Qf="HTML_DUPLICATE_FORM",Na="HTML_NESTED_INTERACTIVE",Zf="HTML_MISNESTED_FORMATTING",us="HTML_UNEXPECTED_END_TAG",ed="HTML_DUPLICATE_ATTRIBUTE",Aa="HTML_ATTRIBUTES_ON_END_TAG",td="HTML_SELF_CLOSING_END_TAG",nd="HTML_MISSING_ATTRIBUTE_VALUE",rd="HTML_CDATA_IN_HTML_NAMESPACE",sd="HTML_BOGUS_COMMENT",id="HTML_UNCLOSED_BEFORE_END",U="error",$="warn",cn=new Set(["caption","colgroup","thead","tbody","tfoot","tr","td","th","table"]),xa=new Set(["td","th"]),Ia=new Set(["dd","dt","li","optgroup","option","p","rb","rp","rt","rtc"]);function od(e,t,n={}){const r=n.TokenizerClass??kf,s=new ad(e,t,n),i=new r({xmlMode:!1,decodeEntities:!1,recognizeSelfClosing:!0},s);return s.tokenizer=i,i.write(e),i.end(),s.findingCount}var ad=class{constructor(e,t,n){this.html=e,this.onFinding=t,this.findingCount=0,this.lineStarts=ld(e);const r=n.fragmentContext??"template",s=Ta[r]??Ta.template;this.openElements=[],r==="tr"?(this.openElements.push({name:"table",ns:v.html,start:-1}),this.openElements.push({name:"tbody",ns:v.html,start:-1})):r==="tbody"||r==="thead"||r==="tfoot"?this.openElements.push({name:"table",ns:v.html,start:-1}):r==="td"||r==="th"?(this.openElements.push({name:"table",ns:v.html,start:-1}),this.openElements.push({name:"tbody",ns:v.html,start:-1}),this.openElements.push({name:"tr",ns:v.html,start:-1})):r==="caption"?this.openElements.push({name:"table",ns:v.html,start:-1}):r==="colgroup"?this.openElements.push({name:"table",ns:v.html,start:-1}):r==="svg"?this.openElements.push({name:"svg",ns:v.svg,start:-1}):r==="math"?this.openElements.push({name:"math",ns:v.math,start:-1}):r==="select"&&this.openElements.push({name:"select",ns:v.html,start:-1}),this.insertionMode=s.mode,this.templateInsertionModes=r==="template"?[_.inTemplate]:[],this.activeFormatting=[],this.framesetOk=!0,this.svgCamelElements=n.svgCamelElements??Uf,this.transparentTagPrefixes=(n.transparentTagPrefixes??[]).map(i=>i.toLowerCase()),this.currentTagName="",this.currentTagRawName="",this.currentTagStart=0,this.currentAttrs=[],this.currentAttr=null,this.tokenizer=null}onopentagname(e,t){const n=this.html.slice(e,t);this.currentTagRawName=n,this.currentTagName=n.toLowerCase(),this.currentTagStart=e,this.currentAttrs=[],this.currentAttr=null}onattribname(e,t){const n=this.html.slice(e,t);this.currentAttr={name:n.toLowerCase(),rawName:n,nameStart:e,value:null,valueStart:-1,valueEnd:-1,quote:Oe.NoValue}}onattribdata(e,t){this.currentAttr&&(this.currentAttr.valueStart=e,this.currentAttr.valueEnd=t,this.currentAttr.value=this.html.slice(e,t))}onattribend(e,t){const n=this.currentAttr;if(!n)return;n.quote=e;const r=this.currentAttrs.find(s=>s.name===n.name);r?this.report(ed,$,n.nameStart,{name:n.name,firstAt:r.nameStart},{kind:"remove",what:`the duplicate '${n.name}' attribute`}):this.currentAttrs.push(n),n.quote===Oe.Unquoted&&n.value===""&&this.report(nd,$,n.nameStart,{name:n.name}),this.currentAttr=null}onattribentity(e){}ontextentity(e,t){}getAttr(e){const t=this.currentAttrs.find(n=>n.name===e);return t?t.value:null}hasAttr(e){return this.currentAttrs.some(t=>t.name===e)}onopentagend(e){this.handleStartTag(!1,e)}onselfclosingtag(e){this.handleStartTag(!0,e)}onclosetag(e,t){const r=this.html.slice(e,t).toLowerCase();let s=t,i=-1;for(;s<this.html.length;){const o=this.html.charCodeAt(s);if(o===62)break;o!==32&&o!==9&&o!==10&&o!==13&&o!==12&&(i=s),s++}if(i>=0)if(this.html.charCodeAt(i)===47&&i===s-1){let o=-1;for(let a=t;a<i;a++){const l=this.html.charCodeAt(a);if(l!==32&&l!==9&&l!==10&&l!==13&&l!==12){o=a;break}}o<0?this.report(td,$,e,{tag:r},{kind:"rewrite",from:`</${r}/>`,to:`</${r}>`}):this.report(Aa,$,e,{tag:r},{kind:"remove",what:`attributes from </${r}>`})}else this.report(Aa,$,e,{tag:r},{kind:"remove",what:`attributes from </${r}>`});this.handleEndTag(r,e)}ontext(e,t){if(e>=t)return;const n=this.currentNode();n&&n.ns!==v.html&&!this.isIntegrationPoint(n)||this.handleText(e,t)}oncomment(e,t,n){n===0&&this.report(sd,$,e,{mode:this.insertionMode})}oncdata(e,t,n){this.currentNamespace()===v.html&&this.report(rd,$,e,{mode:this.insertionMode})}ondeclaration(e,t){}onprocessinginstruction(e,t){}isInForeignContext(){return this.currentNamespace()!==v.html}onend(){}report(e,t,n,r,s=null){this.findingCount++;const{line:i,column:o}=cd(this.lineStarts,n);this.onFinding({id:e,level:t,info:r,location:{start:n,end:n+(r.tag?.length??0),line:i,column:o},suggestion:s})}currentNode(){return this.openElements[this.openElements.length-1]??null}currentNamespace(){const e=this.currentNode();return e?e.ns:v.html}push(e,t,n){this.openElements.push({name:e,ns:t,start:n})}pop(){return this.openElements.pop()}hasInScope(e,t){for(let n=this.openElements.length-1;n>=0;n--){const r=this.openElements[n];if(r.name===e&&r.ns===v.html)return!0;if(r.ns===v.html){if(t.has(r.name))return!1}else if(this.isScopeBoundary(r))return!1}return!1}isScopeBoundary(e){return e.ns===v.math?va.has(e.name)||e.name==="annotation-xml":e.ns===v.svg?Ea.has(e.name):!1}isIntegrationPoint(e){return e.ns===v.math?!!(va.has(e.name)||e.name==="annotation-xml"&&e.htmlIntegration):e.ns===v.svg?Ea.has(e.name):!1}hasInDefaultScope(e){return this.hasInScope(e,Bf)}hasInButtonScope(e){return this.hasInScope(e,Ff)}hasInListItemScope(e){return this.hasInScope(e,$f)}hasInTableScope(e){return this.hasInScope(e,Vf)}hasInSelectScope(e){for(let t=this.openElements.length-1;t>=0;t--){const n=this.openElements[t];if(n.ns!==v.html)return!1;if(n.name===e)return!0;if(n.name!=="optgroup"&&n.name!=="option")return!1}return!1}popUntilName(e){for(;this.openElements.length;){const t=this.openElements.pop();if(t.name===e)return t}return null}generateImpliedEndTags(e=null){const t=new Set(["dd","dt","li","optgroup","option","p","rb","rp","rt","rtc"]);for(;this.openElements.length;){const n=this.currentNode();if(n.ns!==v.html||!t.has(n.name)||n.name===e)break;this.openElements.pop()}}isTransparentTag(e){for(const t of this.transparentTagPrefixes)if(e===t||e.startsWith(`${t}:`))return!0;return!1}handleStartTag(e,t){const n=this.currentTagName,r=this.currentTagRawName,s=this.currentTagStart,i=this.currentNamespace();i===v.html?r!==n&&this.report(Wf,U,s,{raw:r,lowercased:n},{kind:"rewrite",from:`<${r}>`,to:`<${n}>`}):i===v.svg&&r!==r.toLowerCase()&&!this.svgCamelElements.has(r)&&this.report(Kf,U,s,{raw:r,lowercased:n},{kind:"rewrite",from:`<${r}>`,to:`<${n}>`});const o=i!==v.html?i:n==="svg"?v.svg:n==="math"?v.math:v.html;if(o===v.svg)for(const c of this.currentAttrs){const f=_a.get(c.name);f&&c.rawName!==f&&this.report(zf,U,c.nameStart,{raw:c.rawName,canonical:f},{kind:"rewrite",from:c.rawName,to:f})}else if(o===v.math)for(const c of this.currentAttrs){const f=Sa.get(c.name);f&&c.rawName!==f&&this.report(Yf,U,c.nameStart,{raw:c.rawName,canonical:f},{kind:"rewrite",from:c.rawName,to:f})}if(this.isTransparentTag(n))return;const a=this.currentNode(),l=i!==v.html&&!(a&&this.isIntegrationPoint(a));if(l&&!this.shouldBreakoutFromForeign(n)){this.startTagInForeign(n,r,e,s);return}if(l&&this.shouldBreakoutFromForeign(n))for(this.report(W,$,s,{tag:r,parent:this.currentNode()?.name??"(root)",mode:this.insertionMode,action:"foreign-breakout"});this.openElements.length&&this.currentNode()?.ns!==v.html;)this.openElements.pop();this.dispatchStartTag(n,r,e,s,t)}shouldBreakoutFromForeign(e){return Hf.has(e)?!0:e==="font"?this.hasAttr("color")||this.hasAttr("face")||this.hasAttr("size"):!1}startTagInForeign(e,t,n,r){const s=e==="svg"?v.svg:e==="math"?v.math:this.currentNamespace(),i=this.currentNode();if(i&&this.isIntegrationPoint(i)&&e!=="mglyph"&&e!=="malignmark"){this.dispatchStartTag(e,t,n,r,r+t.length);return}if(n)return;const o={name:e,ns:s,start:r};if(s===v.math&&e==="annotation-xml"){const a=(this.getAttr("encoding")??"").toLowerCase();(a==="text/html"||a==="application/xhtml+xml")&&(o.htmlIntegration=!0)}this.openElements.push(o)}dispatchStartTag(e,t,n,r,s){switch(this.insertionMode){case _.inTemplate:return this.startInTemplate(e,t,n,r,s);case _.inBody:return this.startInBody(e,t,n,r,s);case _.inTable:return this.startInTable(e,t,n,r,s);case _.inCaption:return this.startInCaption(e,t,n,r,s);case _.inColumnGroup:return this.startInColumnGroup(e,t,n,r,s);case _.inTableBody:return this.startInTableBody(e,t,n,r,s);case _.inRow:return this.startInRow(e,t,n,r,s);case _.inCell:return this.startInCell(e,t,n,r,s);case _.inSelect:return this.startInSelect(e,t,n,r,s);case _.inSelectInTable:return this.startInSelectInTable(e,t,n,r,s)}}startInBody(e,t,n,r,s){if(e==="html"||e==="head"||e==="body"||e==="frame"||e==="frameset"){this.report(W,$,r,{tag:t,mode:this.insertionMode,action:"ignored"});return}if(e==="address"||e==="article"||e==="aside"||e==="blockquote"||e==="center"||e==="details"||e==="dialog"||e==="dir"||e==="div"||e==="dl"||e==="fieldset"||e==="figcaption"||e==="figure"||e==="footer"||e==="header"||e==="hgroup"||e==="main"||e==="menu"||e==="nav"||e==="ol"||e==="p"||e==="search"||e==="section"||e==="summary"||e==="ul"){this.hasInButtonScope("p")&&this.implicitlyClose("p",r,t),this.push(t,v.html,r);return}if(e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6"){this.hasInButtonScope("p")&&this.implicitlyClose("p",r,t);const i=this.currentNode();i&&/^h[1-6]$/.test(i.name)&&(this.report(W,U,r,{tag:t,parent:i.name,mode:this.insertionMode,action:"auto-close-implicit"}),this.openElements.pop()),this.push(t,v.html,r);return}if(e==="pre"||e==="listing"){this.hasInButtonScope("p")&&this.implicitlyClose("p",r,t),this.push(t,v.html,r),this.framesetOk=!1;return}if(e==="form"){if(this.openElementsHas("form")&&!this.openElementsHas("template")){this.report(Qf,U,r,{tag:t,mode:this.insertionMode},{kind:"remove",what:"the inner <form>"});return}this.hasInButtonScope("p")&&this.implicitlyClose("p",r,t),this.push(t,v.html,r);return}if(e==="li"){this.framesetOk=!1;for(let i=this.openElements.length-1;i>=0;i--){const o=this.openElements[i];if(o.ns!==v.html)break;if(o.name==="li"){for(this.generateImpliedEndTags("li");this.openElements.length&&this.openElements.pop().name!=="li";);break}if(ls.has(o.name)&&o.name!=="address"&&o.name!=="div"&&o.name!=="p")break}this.hasInButtonScope("p")&&this.implicitlyClose("p",r,t),this.push(t,v.html,r);return}if(e==="dd"||e==="dt"){this.framesetOk=!1;for(let i=this.openElements.length-1;i>=0;i--){const o=this.openElements[i];if(o.ns!==v.html)break;if(o.name==="dd"||o.name==="dt"){for(this.generateImpliedEndTags(o.name);this.openElements.length&&this.openElements.pop().name!==o.name;);break}if(ls.has(o.name)&&o.name!=="address"&&o.name!=="div"&&o.name!=="p")break}this.hasInButtonScope("p")&&this.implicitlyClose("p",r,t),this.push(t,v.html,r);return}if(e==="plaintext"){this.hasInButtonScope("p")&&this.implicitlyClose("p",r,t),this.push(t,v.html,r);return}if(e==="button"){this.hasInDefaultScope("button")&&(this.report(W,U,r,{tag:t,parent:"button",mode:this.insertionMode,action:"auto-close-implicit"}),this.generateImpliedEndTags(),this.popUntilName("button")),this.push(t,v.html,r),this.framesetOk=!1;return}if(e==="a"){this.activeFormattingHas("a")&&(this.report(Na,$,r,{tag:t,mode:this.insertionMode}),this.runAdoptionAgency("a")),this.push(t,v.html,r),this.activeFormatting.push(this.currentNode());return}if(ba.has(e)){this.push(t,v.html,r),this.activeFormatting.push(this.currentNode());return}if(e==="nobr"){this.activeFormattingHas("nobr")&&(this.report(Na,$,r,{tag:t,mode:this.insertionMode}),this.runAdoptionAgency("nobr")),this.push(t,v.html,r),this.activeFormatting.push(this.currentNode());return}if(e==="table"){this.hasInButtonScope("p")&&this.implicitlyClose("p",r,t),this.push(t,v.html,r),this.framesetOk=!1,this.insertionMode=_.inTable;return}if(e==="area"||e==="br"||e==="embed"||e==="img"||e==="keygen"||e==="wbr"||e==="input"||e==="param"||e==="source"||e==="track"||e==="hr"||e==="meta"||e==="link"||e==="col"||e==="base"){this.framesetOk=!1;return}if(e==="select"){this.hasInButtonScope("p")&&this.implicitlyClose("p",r,t),this.push(t,v.html,r),this.framesetOk=!1,this.insertionMode=_.inSelect;return}if(e==="option"||e==="optgroup"){this.currentNode()?.name==="option"&&this.openElements.pop(),this.push(t,v.html,r);return}if(e==="textarea"||e==="title"||Rf.has(e)){this.push(t,v.html,r);return}if(e==="math"||e==="svg"){this.push(t,e==="svg"?v.svg:v.math,r),this.framesetOk=!1;return}if(e==="caption"||e==="col"||e==="colgroup"||e==="frame"||e==="tbody"||e==="td"||e==="tfoot"||e==="th"||e==="thead"||e==="tr"){this.report(W,U,r,{tag:t,parent:this.currentNode()?.name??"(root)",mode:this.insertionMode,action:"ignored"});return}n||this.push(t,v.html,r)}openElementsHas(e){for(let t=this.openElements.length-1;t>=0;t--){const n=this.openElements[t];if(n.ns===v.html&&n.name===e)return!0}return!1}activeFormattingHas(e){for(let t=this.activeFormatting.length-1;t>=0;t--){const n=this.activeFormatting[t];if(n===null)return!1;if(n.name===e)return!0}return!1}runAdoptionAgency(e){for(let t=this.activeFormatting.length-1;t>=0;t--){const n=this.activeFormatting[t];if(n===null)break;if(n.name===e){const r=this.openElements.indexOf(n);r>=0&&this.openElements.splice(r,1);return}}}implicitlyClose(e,t,n){for(;this.openElements.length&&this.openElements.pop().name!==e;);}startInTemplate(e,t,n,r,s){let i;if(e==="caption"||e==="colgroup"||e==="tbody"||e==="tfoot"||e==="thead")i=_.inTable;else if(e==="col")i=_.inColumnGroup;else if(e==="tr")i=_.inTableBody;else if(e==="td"||e==="th")i=_.inRow;else return this.popTemplateMode(),this.pushTemplateMode(_.inBody),this.insertionMode=_.inBody,this.startInBody(e,t,n,r,s);return this.popTemplateMode(),this.pushTemplateMode(i),this.insertionMode=i,this.dispatchStartTag(e,t,n,r,s)}popTemplateMode(){this.templateInsertionModes.length&&this.templateInsertionModes.pop()}pushTemplateMode(e){this.templateInsertionModes.push(e)}startInTable(e,t,n,r,s){if(e==="caption"){this.clearStackBackToTable(),this.activeFormatting.push(null),this.push(t,v.html,r),this.insertionMode=_.inCaption;return}if(e==="colgroup"){this.clearStackBackToTable(),this.push(t,v.html,r),this.insertionMode=_.inColumnGroup;return}if(e==="col")return this.clearStackBackToTable(),this.push("colgroup",v.html,r),this.insertionMode=_.inColumnGroup,this.dispatchStartTag(e,t,n,r,s);if(e==="tbody"||e==="thead"||e==="tfoot"){this.clearStackBackToTable(),this.push(t,v.html,r),this.insertionMode=_.inTableBody;return}if(e==="td"||e==="th"||e==="tr")return this.clearStackBackToTable(),this.push("tbody",v.html,r),this.insertionMode=_.inTableBody,this.dispatchStartTag(e,t,n,r,s);if(e==="table")return this.report(W,U,r,{tag:t,parent:"table",mode:this.insertionMode,action:"auto-close-implicit"}),this.hasInTableScope("table")?(this.popUntilName("table"),this.resetInsertionModeAppropriately(),this.dispatchStartTag(e,t,n,r,s)):void 0;if(e==="style"||e==="script"||e==="template")return this.startInBody(e,t,n,r,s);if(e==="input"){if((this.getAttr("type")??"").toLowerCase()==="hidden")return;this.report(W,$,r,{tag:t,parent:"table",mode:this.insertionMode,action:"foster-parent"});return}if(e==="form"){this.report(W,U,r,{tag:t,parent:"table",mode:this.insertionMode,action:"ignored"});return}return this.report(W,U,r,{tag:t,parent:this.currentNode()?.name??"table",mode:this.insertionMode,action:"foster-parent"}),this.startInBody(e,t,n,r,s)}clearStackBackToTable(){for(;this.openElements.length;){const e=this.currentNode();if(!e||e.name==="table"||e.name==="template")break;this.openElements.pop()}}startInCaption(e,t,n,r,s){return e==="caption"||e==="col"||e==="colgroup"||e==="tbody"||e==="td"||e==="tfoot"||e==="th"||e==="thead"||e==="tr"?this.hasInTableScope("caption")?(this.generateImpliedEndTags(),this.popUntilName("caption"),this.clearActiveFormattingToMarker(),this.insertionMode=_.inTable,this.dispatchStartTag(e,t,n,r,s)):void 0:this.startInBody(e,t,n,r,s)}clearActiveFormattingToMarker(){for(;this.activeFormatting.length;)if(this.activeFormatting.pop()===null)return}startInColumnGroup(e,t,n,r,s){if(e!=="col"){if(e==="template")return this.startInBody(e,t,n,r,s);if(this.currentNode()?.name==="colgroup")return this.openElements.pop(),this.insertionMode=_.inTable,this.dispatchStartTag(e,t,n,r,s);this.report(W,U,r,{tag:t,parent:"colgroup",mode:this.insertionMode,action:"ignored"})}}startInTableBody(e,t,n,r,s){if(e==="tr"){this.clearStackBackToTableBody(),this.push(t,v.html,r),this.insertionMode=_.inRow;return}return xa.has(e)?(this.report(W,$,r,{tag:t,parent:this.currentNode()?.name??"tbody",mode:this.insertionMode,action:"auto-close-implicit"}),this.clearStackBackToTableBody(),this.push("tr",v.html,r),this.insertionMode=_.inRow,this.dispatchStartTag(e,t,n,r,s)):e==="caption"||e==="col"||e==="colgroup"||e==="tbody"||e==="tfoot"||e==="thead"?this.hasInTableScope("tbody")||this.hasInTableScope("thead")||this.hasInTableScope("tfoot")?(this.clearStackBackToTableBody(),this.openElements.pop(),this.insertionMode=_.inTable,this.dispatchStartTag(e,t,n,r,s)):void 0:this.startInTable(e,t,n,r,s)}clearStackBackToTableBody(){for(;this.openElements.length;){const e=this.currentNode();if(!e||e.name==="tbody"||e.name==="thead"||e.name==="tfoot"||e.name==="template"||e.name==="table")break;this.openElements.pop()}}startInRow(e,t,n,r,s){if(xa.has(e)){this.clearStackBackToTableRow(),this.push(t,v.html,r),this.insertionMode=_.inCell,this.activeFormatting.push(null);return}return e==="caption"||e==="col"||e==="colgroup"||e==="tbody"||e==="tfoot"||e==="thead"||e==="tr"?this.hasInTableScope("tr")?(this.clearStackBackToTableRow(),this.openElements.pop(),this.insertionMode=_.inTableBody,this.dispatchStartTag(e,t,n,r,s)):void 0:this.startInTable(e,t,n,r,s)}clearStackBackToTableRow(){for(;this.openElements.length;){const e=this.currentNode();if(!e||e.name==="tr"||e.name==="template"||e.name==="table")break;this.openElements.pop()}}startInCell(e,t,n,r,s){return e==="caption"||e==="col"||e==="colgroup"||e==="tbody"||e==="td"||e==="tfoot"||e==="th"||e==="thead"||e==="tr"?this.hasInTableScope("td")||this.hasInTableScope("th")?(this.closeCell(),this.dispatchStartTag(e,t,n,r,s)):void 0:this.startInBody(e,t,n,r,s)}closeCell(){for(this.generateImpliedEndTags();this.openElements.length;){const e=this.openElements.pop();if(e.name==="td"||e.name==="th")break}this.clearActiveFormattingToMarker(),this.insertionMode=_.inRow}startInSelect(e,t,n,r,s){if(e==="option"){this.currentNode()?.name==="option"&&this.openElements.pop(),this.push(t,v.html,r);return}if(e==="optgroup"){this.currentNode()?.name==="option"&&this.openElements.pop(),this.currentNode()?.name==="optgroup"&&this.openElements.pop(),this.push(t,v.html,r);return}if(e!=="hr"){if(Gf.has(e))return this.report(W,U,r,{tag:t,parent:"select",mode:this.insertionMode,action:"auto-close-implicit"}),this.hasInSelectScope("select")&&(this.popUntilName("select"),this.resetInsertionModeAppropriately()),e==="select"?void 0:this.dispatchStartTag(e,t,!1,r,s);if(e==="script"||e==="template")return this.startInBody(e,t,!1,r,s);this.report(W,U,r,{tag:t,parent:"select",mode:this.insertionMode,action:"ignored"})}}startInSelectInTable(e,t,n,r,s){return e==="caption"||e==="table"||e==="tbody"||e==="tfoot"||e==="thead"||e==="tr"||e==="td"||e==="th"?(this.report(W,U,r,{tag:t,parent:"select",mode:this.insertionMode,action:"auto-close-implicit"}),this.popUntilName("select"),this.resetInsertionModeAppropriately(),this.dispatchStartTag(e,t,n,r,s)):this.startInSelect(e,t,n,r,s)}resetInsertionModeAppropriately(){for(let e=this.openElements.length-1;e>=0;e--){const t=this.openElements[e];if(t.ns!==v.html)continue;const n=e===0;switch(t.name){case"select":this.insertionMode=_.inSelect;return;case"td":case"th":if(!n){this.insertionMode=_.inCell;return}break;case"tr":this.insertionMode=_.inRow;return;case"tbody":case"thead":case"tfoot":this.insertionMode=_.inTableBody;return;case"caption":this.insertionMode=_.inCaption;return;case"colgroup":this.insertionMode=_.inColumnGroup;return;case"table":this.insertionMode=_.inTable;return;case"template":this.insertionMode=this.templateInsertionModes[this.templateInsertionModes.length-1]??_.inBody;return}}this.insertionMode=_.inBody}handleEndTag(e,t){if(this.isTransparentTag(e))return;if(this.currentNamespace()!==v.html){let s=this.openElements.length-1,i=!0;for(;s>0;){const o=this.openElements[s];if(!i&&o.ns===v.html)break;if(o.ns!==v.html&&o.name.toLowerCase()===e){this.openElements.length=s;return}i&&(this.report(us,$,t,{tag:e,mode:this.insertionMode}),i=!1),s--}}if(Lf.has(e)){this.report(Jf,$,t,{tag:e,mode:this.insertionMode},{kind:"remove",what:`the </${e}>`});return}if(ba.has(e)){const s=this.currentNode();if(s&&s.ns===v.html&&s.name===e){this.openElements.pop(),this.removeFromActiveFormattingByRef(s);return}if(this.activeFormattingHas(e)||this.openElementsHas(e)){this.report(Zf,$,t,{tag:e,mode:this.insertionMode}),this.runAdoptionAgency(e);return}this.report(us,$,t,{tag:e,mode:this.insertionMode});return}const r=cn.has(e);for(let s=this.openElements.length-1;s>=0;s--){const i=this.openElements[s];if(i.ns===v.html&&i.name===e){for(let o=this.openElements.length-1;o>s;o--){const a=this.openElements[o];if(a.ns===v.html&&a.name!==e&&!Ia.has(a.name)&&!(r&&cn.has(a.name))){this.report(id,$,t,{tag:e,unclosed:a.name,mode:this.insertionMode});break}}this.openElements.length=s,(cn.has(e)||e==="select"||e==="template")&&this.resetInsertionModeAppropriately();return}if(i.ns===v.html&&ls.has(i.name)&&!Ia.has(i.name)&&!(r&&cn.has(i.name))){this.report(us,$,t,{tag:e,mode:this.insertionMode});return}}}removeFromActiveFormattingByRef(e){const t=this.activeFormatting.indexOf(e);t>=0&&this.activeFormatting.splice(t,1)}handleText(e,t){if(this.insertionMode===_.inTable||this.insertionMode===_.inTableBody||this.insertionMode===_.inRow){const n=this.html.slice(e,t);/\S/.test(n)&&this.report(Xf,U,e,{mode:this.insertionMode,snippet:n.length>40?`${n.slice(0,40)}\u2026`:n});return}if(this.insertionMode===_.inColumnGroup){const n=this.html.slice(e,t);return/\S/.test(n)&&this.currentNode()?.name==="colgroup"?(this.openElements.pop(),this.insertionMode=_.inTable,this.handleText(e,t)):void 0}this.insertionMode===_.inSelect||(this.insertionMode,_.inSelectInTable)}};function ld(e){const t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function cd(e,t){let n=0,r=e.length-1;for(;n<r;){const s=n+r+1>>>1;e[s]<=t?n=s:r=s-1}return{line:n+1,column:t-e[n]+1}}function ud(e,t){if(e===t)return 0;const n=e.length,r=t.length;if(n===0)return r;if(r===0)return n;const s=new Array(r+1),i=new Array(r+1),o=new Array(r+1);for(let a=0;a<=r;a++)i[a]=a;for(let a=1;a<=n;a++){o[0]=a;const l=e.charCodeAt(a-1);for(let c=1;c<=r;c++){const f=t.charCodeAt(c-1),p=l===f?0:1;let g=Math.min(o[c-1]+1,i[c]+1,i[c-1]+p);a>1&&c>1&&l===t.charCodeAt(c-2)&&e.charCodeAt(a-2)===f&&(g=Math.min(g,s[c-2]+1)),o[c]=g}for(let c=0;c<=r;c++)s[c]=i[c],i[c]=o[c]}return i[r]}function Oa(e,t,n=2){if(!e)return null;const r=e.toLowerCase();let s=null,i=n+1;for(const o of t){if(o===e)return null;if(o.toLowerCase()===r)return o;const a=ud(e,o);a<i&&(s=o,i=a)}return i<=n?s:null}var hd=new Set("name view style commonStyle globalStyle receive intent alter views provide lookup fields methods statics".split(" ")),fd=new Set,Pa=new Set(["intentOverridesField"]),dd=new Set(["dangerouslysetinnerhtml","slot","push-view","text","show","hide","each","enrich-with","when","loop-with","then","else"]),yt=e=>{const t=e.charCodeAt(0);return t>=65&&t<=90},Ma="ALT_HANDLER_NOT_DEFINED",Ca="ALT_HANDLER_NOT_REFERENCED",Da="DYN_VAL_NOT_DEFINED",ka="DYN_ALIAS_NOT_REFERENCED",La="PROVIDE_NOT_ADDRESSABLE",Ra="PROVIDE_TYPE_BAD_SHAPE",He="LOOKUP_BAD_SHAPE",hs="LOOKUP_NO_PROVIDER",$a="RENDER_IT_OUTSIDE_OF_LOOP",Fa="UNKNOWN_EVENT_MODIFIER",Ba="RECEIVE_HANDLER_NOT_IMPLEMENTED",fs="EVENT_HANDLER_METHOD_NOT_ALLOWED",ds="HANDLER_NAME_COLLISION",Va="FIELD_VAL_NOT_DEFINED",Ua="FIELD_VAL_IS_METHOD",ja="METHOD_VAL_NOT_DEFINED",qa="METHOD_VAL_IS_FIELD",Ha="DUPLICATE_ATTR_DEFINITION",Ga="IF_NO_BRANCH_SET",Wa="UNKNOWN_COMPONENT_NAME",Ka="UNKNOWN_MACRO_ARG",za="UNKNOWN_DIRECTIVE",Ya="ORPHAN_DIRECTIVE",Xa="UNKNOWN_X_OP",Ja="UNKNOWN_X_ATTR",Qa="X_OP_IGNORES_CHILDREN",Za="MAYBE_DROP_AT_PREFIX",el="MAYBE_ADD_AT_PREFIX",tl="BAD_VALUE",nl="UNSUPPORTED_EXPR_SYNTAX",rl="BINDING_MEMBER_TOO_DEEP",sl="SUGGEST_BINDING_MEMBER",il="REDUNDANT_TEMPLATE_STRING",ol="PLACEHOLDERLESS_TEMPLATE_STRING",un="CONSTANT_CONDITION",al="UNKNOWN_COMPONENT_SPEC_KEY",ps="COMP_FIELD_BAD_SHAPE",ll="ASYNC_HANDLER",cl="TOP_LEVEL_AT_RULE_IN_SCOPED_STYLE",ul="GLOBAL_SELECTOR_IN_SCOPED_STYLE",hl="FIELD_METHOD_NAME_COLLISION",fl=new Set(["slot","text","render","render-it","render-each","show","hide"]),dl=new Set(["as","when","loop-with","show","hide"]),pd=new Set(["when","enrich-with","loop-with","show","hide"]),md="warn",pl="error",gd="hint",wd={"unknown-directive":{id:za,candidates:dd},"orphan-directive":{id:Ya},"unknown-x-op":{id:Xa,candidates:fl,atPrefix:fl},"unknown-x-attr":{id:Ja,candidates:dl,atPrefix:dl},"bad-value":{id:tl},"event-method-handler":{id:fs}};function ms(e,t){return ml(e,t)!==null}function ml(e,t){let n=e;for(;n&&n!==Object.prototype;){const r=Object.getOwnPropertyDescriptor(n,t);if(r!==void 0)return typeof r.value=="function"?r.value:null;n=Object.getPrototypeOf(n)}return null}function yd(e){const t=[];let n=e;for(;n&&n!==Object.prototype;){for(const r of Object.getOwnPropertyNames(n))r!=="constructor"&&t.push(r);n=Object.getPrototypeOf(n)}return t}function bd(e,t){const n=[];for(let r=e;r;r=r.parent){const s=r[t];if(s)for(const i of Object.keys(s))n.push(i)}return n}function bt(e,t){const n=Oa(e,t);return n?{kind:"replace-name",from:e,to:n}:null}function vd(e){if(typeof e!="string")return null;const t=e.trim();return t===""?null:/\s\?\s.+\s:\s/.test(t)?"ternary":/===|!==|==|!=|<=|>=|\s<\s|\s>\s/.test(t)?"comparison":/&&|\|\|/.test(t)?"logical":/^[.$][A-Za-z_]\w*\s+\S/.test(t)?"call-with-args":/^\.[A-Za-z_]\w*\??(\.[A-Za-z_]\w*\??)+$/.test(t)?"field-path":null}var Ed=/^@[a-zA-Z]\w*\??(\.[a-zA-Z]\w*\??){2,}$/,_d={ternary:"Ternary expressions aren't supported in dynamic attributes. Define a method or computed value on the component that returns the value, then reference it as '$methodName'.",comparison:"Comparisons aren't supported in dynamic attributes. Define a method like 'isFooSelected' that returns the boolean, then reference it as '$isFooSelected'.",logical:"Logical operators aren't supported in dynamic attributes. Combine the conditions in a method on the component and reference it as '$methodName'.","call-with-args":"Method calls with arguments aren't supported here. Reference a no-arg method ('$methodName') and read what you need from component state, or split into per-case methods.","field-path":"Fields can't be read through a dotted path. Define a method that returns the value, render a child component for the nested data, or \u2014 inside a loop \u2014 read one member off a binding ('@value.member')."};function gl(e,t=new bl,{wellKnownExtras:n=fd}={}){return t.push({componentName:e.name},()=>{Gd(t,e,n),Wd(t,e),Kd(t,e),np(t,e),rp(t,e),ip(t,e),ap(t,e),op(t,e),Jd(t,e),Hd(t,e),tp(t,e);const r=new Set,s=new Set,i=new Set;Ld(t,e,s),qd(t,e,r,i);for(const o in e.views)t.push({viewName:o},()=>Sd(t,e.views[o],e,r,i));return zd(t,e,r),lp(t,e,i),t})}function Sd(e,t,n,r,s){Ad(e,t),Id(e,t),Pd(e,t,n),Dd(e,t),kd(e,t,n,r,s),xd(e,t,n),Nd(e,t)}var Td={fragmentContext:"template",transparentTagPrefixes:["x"]};function Nd(e,t){typeof t.rawView!="string"||!t.rawView||od(t.rawView,n=>e.report(n.id,{...n.info,location:n.location},n.level,n.suggestion??null),Td)}function Ad(e,t){const n=t.ctx.parseIssues;if(n)for(const{kind:r,info:s}of n){if(r==="x-op-ignores-children"){e.warn(Qa,s,{kind:"remove",what:"the ignored children"});continue}if(r==="event-method-handler"){e.error(fs,s,{kind:"rephrase",from:s.value,text:`Move '${s.name}' to receive and reference it as '${s.name}'.`});continue}const i=wd[r];if(!i)continue;const o=i.id;if(r==="bad-value"){if(typeof s.value=="string"&&Ed.test(s.value.trim())){e.error(rl,s,{kind:"rephrase",from:s.value,text:"Read one level off the binding and compute the rest in a method or an '@enrich-with' handler."});continue}const f=vd(s.value);if(f){e.error(nl,{...s,detected:f},{kind:"rephrase",from:s.value,text:_d[f]});continue}}const a=i.atPrefix,l=a&&s.name?.startsWith("@")&&a.has(s.name.slice(1));let c=null;l?c={kind:"drop-prefix",from:s.name,to:s.name.slice(1)}:i.candidates&&(c=bt(s.name,i.candidates)),e.error(o,s,c),l&&e.hint(Za,{...s,suggestion:s.name.slice(1)},{kind:"drop-prefix",from:s.name,to:s.name.slice(1)})}}function xd(e,t,n){const{scope:r}=n;for(const s of t.ctx.macroNodes){const i=r.lookupMacro(s.name);if(i===null)continue;const{defaults:o}=i;for(const a in s.attrs)a in o||e.error(Ka,{name:a,macroName:s.name,tag:`x:${s.name}`},bt(a,Object.keys(o)))}}function Id(e,t){let n=!1;for(const r of t.ctx.nodes)if(r.constructor.name==="RenderItNode"){n=!0;break}n&&hn(e,t.anode,0)}function Od(e){const t=Function.prototype.toString.call(e),n=t.match(/^[^(]*\(([^)]*)\)\s*(?:=>)?\s*/);if(!n)return null;const r=n[1].split(",").map(f=>f.trim()),[s,,i]=r;if(!/^\w+$/.test(s??"")||!/^\w+$/.test(i??""))return null;let o=t.slice(n[0].length).trim();if(o.startsWith("{")){if(!o.endsWith("}"))return null;o=o.slice(1,-1)}const a=o.split(/[;\n]/).map(f=>f.trim()).filter(f=>f!==""&&!f.startsWith("//"));if(a.length===0)return null;const l=new RegExp(`^${s}\\.(\\w+)\\s*=\\s*${i}(?:\\.(\\w+)|\\.get\\((['"])(\\w+)\\3\\))$`),c=[];for(const f of a){const p=f.match(l);if(!p)return null;c.push({bind:p[1],member:p[2]??p[4]})}return c}function Pd(e,t,n){for(const r of t.ctx.nodes){if(r.constructor.name!=="EachNode")continue;const s=r.iterInfo?.enrichWithVal;if(!s?.name)continue;const i=s.constructor.name==="MethodVal"?ml(n.prototype??Object.getPrototypeOf(n),s.name):n.alter?.[s.name];if(typeof i!="function")continue;const o=Od(i);if(o===null)continue;const a=o.map(({bind:l,member:c})=>`'@${l}' -> '@value.${c}'`);e.hint(sl,{name:s.name,members:o},{kind:"rephrase",text:`Replace ${a.join(", ")} in the view, then remove the '@enrich-with' and the '${s.name}' alter handler.`})}}function hn(e,t,n){if(t!=null)switch(t.constructor.name){case"RenderItNode":n===0&&e.error($a,{node:t},{kind:"wrap",from:"<x render-it>",to:"<x render-each>"});return;case"EachNode":hn(e,t.node,n+1);return;case"ShowNode":case"HideNode":case"ScopeNode":case"SlotNode":case"PushViewNameNode":case"MacroNode":case"RenderOnceNode":hn(e,t.node,n);return;case"DomNode":case"FragmentNode":for(const r of t.childs)hn(e,r,n);return;default:return}}var Md={},Cd=[...Object.keys(ca),...Object.keys(ha)];function Dd(e,t){for(const n of t.ctx.events)for(const r of n.handlers){const{name:s,modifiers:i}=r,o=[...Object.keys(ua[s]??Md),...Cd];for(const a of i)if(!o.includes(a)){const l=Oa(a,o);e.error(Fa,{name:s,modifier:a,handler:r,event:n,originAttr:`@on.${s}+${i.join("+")}`},l?{kind:"replace-name",from:`+${a}`,to:`+${l}`}:null)}}}function kd(e,t,n,r,s){const i=wl(n,r,s);for(const o of t.ctx.events)for(const a of o.handlers){const{args:l,handlerVal:c}=a.handlerCall,f=c?.name,p=a.name,g={eventName:p,handlerName:f,originAttr:`@on.${p}`};for(let y=0;y<l.length;y++)J(e,l[y],i,!1,{...g,argIndex:y})}}function wl(e,t,n){const{scope:r,alter:s,provide:i,lookup:o,fields:a}=e,l=e.prototype??Object.getPrototypeOf(e),c={...i,...o};return{fields:a,proto:l,scope:r,alter:s,referencedAlters:t,dynamicMap:c,referencedDynamics:n}}function Ld(e,t,n){const{receive:r,views:s}=t,i=t.prototype??Object.getPrototypeOf(t);for(const o in s)e.push({viewName:o},()=>{const a=s[o];for(const l of a.ctx.events)for(const c of l.handlers){const{handlerVal:f}=c.handlerCall,p=c.name,g=`@on.${p}`;if(f?.constructor.name==="HandlerNameVal"){n?.add(f.name);const{name:y}=f;if(r[y]===void 0){const E=ms(i,y)?{kind:"rephrase",from:y,text:`Move '${y}' from methods to receive; event handlers are receive handlers.`}:bt(y,Object.keys(r));e.error(Ba,{name:y,handler:c,event:l,eventName:p,originAttr:g},E)}}}})}var fn=(e,t)=>({kind:"rewrite",from:e,to:t});function vt(e,t,n,r,s){e.error(t,{...s,name:n},bt(n,r))}var Rd=new Set(["@show","@hide","<x show>","<x hide>"]),gs=e=>e!=null&&(Rd.has(e.originAttr)||e.branch==="@if"),$d={ConstVal({lx:e,val:t,errCtx:n,isRoot:r}){r&&gs(n)&&typeof t.val!="boolean"&&e.warn(un,{...n,literal:String(t)})},FieldVal({lx:e,val:t,env:n,errCtx:r}){const{fields:s,proto:i}=n,{name:o}=t;s[o]===void 0&&(ms(i,o)?e.error(Ua,{...r,val:t,name:o},fn(`.${o}`,`$${o}`)):vt(e,Va,o,Object.keys(s),{...r,val:t}))},MethodVal({lx:e,val:t,env:n,errCtx:r}){const{fields:s,proto:i}=n,{name:o}=t;ms(i,o)||(s[o]!==void 0?e.error(qa,{...r,val:t,name:o},fn(`$${o}`,`.${o}`)):vt(e,ja,o,yd(i),{...r,val:t}))},SeqAccessVal({val:e,recurse:t}){t(e.seqVal),t(e.keyVal)},StrTplVal({lx:e,val:t,errCtx:n,recurse:r,isRoot:s}){const i=t.vals,o=t.toLiteralSource();if(o!==null){s&&gs(n)?e.warn(un,{...n,literal:o}):e.hint(ol,{...n,literal:o},fn(`$${o}`,o));return}else if(i.length===1){const a=String(i[0]);e.warn(il,{...n,simpler:a},fn(`$'{${a}}'`,a))}for(const a of i)r(a)},HandlerNameVal({lx:e,val:t,env:n,errCtx:r}){n.referencedAlters?.add(t.name),n.alter[t.name]===void 0&&vt(e,Ma,t.name,Object.keys(n.alter),r)},PredicateVal({lx:e,val:t,errCtx:n,recurse:r}){const s=i=>i.constructor.name==="ConstVal"||i.constructor.name==="StrTplVal"&&i.toLiteralSource()!==null;gs(n)&&t.args.every(s)&&e.warn(un,{...n,literal:String(t)});for(const i of t.args)r(i)},DynVal({lx:e,val:t,env:n,errCtx:r}){n.referencedDynamics?.add(t.name),n.dynamicMap[t.name]===void 0&&vt(e,Da,t.name,Object.keys(n.dynamicMap),r)}};function J(e,t,n,r=!1,s=null,i=!0){const o=$d[t?.constructor.name];if(o===void 0)return;o({lx:e,val:t,env:n,errCtx:s,skipNameVal:r,recurse:l=>J(e,l,n,r,s,!1),isRoot:i})}var Fd={RenderTextNode:{originAttr:"<x text>"},RenderNode:{originAttr:"<x render>"},RenderItNode:{originAttr:"<x render-it>"},ShowNode:{originAttr:"<x show>"},HideNode:{originAttr:"<x hide>"},PushViewNameNode:{originAttr:"<x push-view>"}};function Bd(e){return Fd[e]??null}function Vd(e){const t=e.constructor.name;return t==="ConstAttr"?"literal":t==="IfAttr"?`@if.${e.name}`:t==="RawHtmlAttr"?"@dangerouslysetinnerhtml":`:${e.name}`}function Ud(e){const t=e.constructor.name;return t==="IfAttr"?`@if.${e.name}`:t==="RawHtmlAttr"?"@dangerouslysetinnerhtml":`:${e.name}`}function jd(e,t,n,r){if(r||!t)return;const s=t.constructor.name;let i;if(s==="ConstAttrs")i=Object.keys(t.items);else if(s==="DynAttrs")i=t.items.map(o=>o?.name);else return;for(const o of i)pd.has(o)&&e.hint(el,{name:o,tag:n,suggestion:`@${o}`},{kind:"add-prefix",from:o,to:`@${o}`})}function qd(e,t,n,r){const{views:s}=t,i=wl(t,n,r);for(const o in s)e.push({viewName:o},()=>{const a=s[o];for(const l of a.ctx.attrs){const{attrs:c,wrapperAttrs:f,textChild:p,isMacroCall:g,tag:y}=l;if(jd(e,c,y,g),c?.constructor.name==="DynAttrs"){const E=new Map;for(const S of c.items){const M=S?.name;if(M!==void 0&&M!=="data-eid"){const x=E.get(M),C=Vd(S);x?x.push(C):E.set(M,[C])}if(S?.constructor.name==="IfAttr"){S.anyBranchIsSet||e.error(Ga,{attr:S.name,tag:y});const x=[["@if",S.condVal],["@then",S.thenVal],["@else",S.elseVal]];for(const[C,D]of x)J(e,D,i,g,{tag:y,originAttr:`@if.${S.name}`,branch:C})}else S?.val!==void 0&&J(e,S.val,i,g,{tag:y,originAttr:Ud(S)})}for(const[S,M]of E)M.length>1&&e.error(Ha,{name:S,sources:M,tag:y})}if(f!==null)for(const E of f)if(E.name==="each")E.whenVal&&J(e,E.whenVal,i,!1,{tag:y,originAttr:"@when"}),E.enrichWithVal&&J(e,E.enrichWithVal,i,!1,{tag:y,originAttr:"@enrich-with"}),E.loopWithVal&&J(e,E.loopWithVal,i,!1,{tag:y,originAttr:"@loop-with"});else{const S=E.name==="scope"?"@enrich-with":`@${E.name}`;J(e,E.val,i,!1,{tag:y,originAttr:S})}p&&J(e,p,i,!1,{tag:y,originAttr:"@text"})}for(const l of a.ctx.nodes){const c=l.constructor.name;if(c==="ScopeNode")continue;const f=Bd(c);if(l.val&&J(e,l.val,i,!1,f),c==="EachNode"&&l.fromRenderEach){const p=l.iterInfo;p.whenVal&&J(e,p.whenVal,i,!1,{originAttr:"<x render-each @when>"}),p.loopWithVal&&J(e,p.loopWithVal,i,!1,{originAttr:"<x render-each @loop-with>"})}}})}function Hd(e,t){const n=t.receive??{},r=t.intent??{};for(const s in r)n[s]!==void 0&&e.error(ds,{name:s,problem:`"${s}" is declared in both \`receive\` and \`intent\``,fix:"one is addressed and one is routed; give them different names so a reader can tell which a call site meant"});for(const s in n)for(const i of["Ok","Error","Unhandled"])n[s+i]!==void 0&&r[s]===void 0&&e.warn(ds,{name:s,problem:`\`receive\` declares both "${s}" and its answer name "${s+i}"`,fix:`an intent named "${s}" would dispatch its answer to "${s+i}" - rename one unless that is what you meant`})}function Gd(e,t,n){const r=t.extra;if(!r)return;let s=null;for(const i of Object.keys(r))Pa.has(i)||n.has(i)||(s??=[...hd,...Pa,...n],e.warn(al,{key:i},bt(i,s)))}function Wd(e,t){const n=t[xe]?.fields;if(n)for(const r in n){const s=n[r];Object.hasOwn(s,"args")&&(typeof s.type!="string"&&e.error(ps,{fieldName:r,kind:"component-not-string",got:typeof s.type,gotName:s.type?.name??null}),(s.args==null||s.args.constructor!==Object)&&e.error(ps,{fieldName:r,kind:"args-not-object",got:s.args===null?"null":typeof s.args}))}}function Kd(e,t){const n=t[xe];if(n)for(const r in n.fields)Object.hasOwn(n.methods,r)&&e.error(hl,{name:r})}function zd(e,t,n){for(const r in t.alter)n.has(r)||e.hint(Ca,{name:r})}var Yd=["receive","intent","alter"],Xd='Move the async work into a scope-registered intent handler and trigger it with ctx.intent("name", args, { route: ["lex"] }), then read the outcome in the synchronous `receive` arms named after it: <name>Ok, <name>Error and <name>Unhandled. To coordinate other components, keep the handler synchronous and use ctx.send to address one, or ctx.intent to let a route find one.';function Jd(e,t){for(const n of Yd){const r=t[n];if(r)for(const s in r){const i=r[s];typeof i=="function"&&i.constructor?.name==="AsyncFunction"&&e.error(ll,{name:s,channel:n},{kind:"rephrase",from:s,text:Xd})}}}var ws=/(?:^|[\s;{}])@(?:-[a-z]+-)?(charset|import|namespace|font-face|keyframes|page|property|counter-style|font-feature-values|font-palette-values|view-transition)\b/gi,ys=/(?:^|[{}])\s*(html|body|:root)\b[^{};]*\{/gi,bs=/\/\*\s*tutuca-lint-ignore\s*\*\//g,vs=e=>e.replace(/[^\n]/g," ");function Qd(e){return e.replace(/\/\*[\s\S]*?\*\//g,vs).replace(/"(?:[^"\\\n]|\\.)*"/g,vs).replace(/'(?:[^'\\\n]|\\.)*'/g,vs)}function Es(e,t){let n=1,r=0;for(let s=0;s<t;s++)e[s]===`
`&&(n++,r=s+1);return{line:n,column:t-r+1}}function Zd(e){const t=new Set;bs.lastIndex=0;for(let n=bs.exec(e);n!==null;n=bs.exec(e))t.add(Es(e,n.index).line);return t}var ep="Move it to the component's 'globalStyle' key, which is injected without the component-scoping wrapper. To suppress a false positive, put a /* tutuca-lint-ignore */ comment on the same line.";function yl(e,t,n){if(!t)return;const r=Zd(t),s=Qd(t),i=(o,a)=>{r.has(a.location.line)||e.error(o,{key:n,...a},{kind:"rephrase",text:ep})};ws.lastIndex=0;for(let o=ws.exec(s);o!==null;o=ws.exec(s)){const a=o.index+o[0].indexOf("@");i(cl,{atRule:o[1].toLowerCase(),location:Es(s,a)})}ys.lastIndex=0;for(let o=ys.exec(s);o!==null;o=ys.exec(s)){const a=o.index+o[0].indexOf(o[1]);i(ul,{selector:o[1].toLowerCase(),location:Es(s,a)})}}function tp(e,t){yl(e,t.commonStyle,"commonStyle");for(const n in t.views){const{style:r}=t.views[n];r&&e.push({viewName:n},()=>yl(e,r,"style"))}}function np(e,t){for(const n in t._rawProvide)yt(n)||t.provide[n]===void 0&&e.error(La,{name:n,value:t._rawProvide[n]})}function rp(e,t){for(const n in t._rawProvide){if(!yt(n))continue;const r=t._rawProvide[n];r!=="self"&&e.error(Ra,{name:n,value:r})}}var sp=new Set(["name","default"]);function ip(e,t){const n=t._rawLookup;if(!Array.isArray(n)){n!==void 0&&Object.keys(n).length>0&&e.error(He,{name:"lookup",problem:"must be a list of names"});return}for(const r of n){if(typeof r=="string")continue;if(r===null||typeof r!="object"||Array.isArray(r)){e.error(He,{name:String(r),problem:'must be a "name" string or a { name, default } object'});continue}const s=Object.keys(r).filter(i=>!sp.has(i));if(s.length>0){e.error(He,{name:String(r.name),problem:`unknown key(s): ${s.join(", ")}`});continue}if(typeof r.name!="string"||r.name===""){e.error(He,{name:String(r.name),problem:"'name' is required and must be a string"});continue}r.default!==void 0&&typeof r.default!="string"&&e.error(He,{name:r.name,problem:"'default' must be a string"})}}function op(e,t){const n=t.scope;if(n)for(const r in t.lookup){if(yt(r)||n.hasProvider?.(r)||n.lookupPath?.(r))continue;const s={name:r,hasDefault:t.lookup[r]!=null};s.hasDefault?e.hint(hs,s):e.error(hs,s)}}function ap(e,t){if(t.scope)for(const n in t.lookup)yt(n)&&t.scope.lookupComponent(n)===null&&vt(e,Wa,n,bd(t.scope,"byName"),{})}function lp(e,t,n){for(const r in t.lookup)yt(r)||n.has(r)||e.hint(ka,{name:r})}var bl=class{constructor(){this.reports=[],this.frame={}}push(e,t){const n=this.frame;this.frame={...n,...e};try{return t()}finally{this.frame=n}}error(e,t,n=null){this.report(e,t,pl,n)}warn(e,t,n=null){this.report(e,t,md,n)}hint(e,t,n=null){this.report(e,t,gd,n)}report(e,t={},n=pl,r=null){this.reports.push({id:e,info:t,level:n,context:{...this.frame},suggestion:r})}},vl=class extends ya{constructor(e){super(e),this.attrs=[],this.parseIssues=[]}onAttributes(e,t,n,r=!1,s=null){super.onAttributes(e,t,n,r,s),this.attrs.push({attrs:e,wrapperAttrs:t,textChild:n,isMacroCall:r,tag:s})}onParseIssue(e,t){const n=this.currentTag;this.parseIssues.push({kind:e,info:n&&t.tag===void 0?{...t,tag:n}:t})}},cp=["send","intent"];function El(e){const t=[];for(const n of cp)for(const r of e[n]??[])t.push({type:n,...r});for(const n of e.do??[])t.push(n);return t}function _l(e,t){return typeof e=="function"?e(t)??[]:e??[]}function Sl(e,t,n,r){if(n)for(const s of El(n)){const i=_l(s.args,r);switch(s.type){case"send":e.sendAtPath(t,s.name,i);break;case"intent":e.intentAtPath(t,s.name,i,s.opts);break}}}var Tl=Symbol("BadValue"),_s=e=>null,up=e=>e instanceof Map?new Map(e):Array.isArray(e)||he(e)?new Map(Array.isArray(e)?e:Object.entries(e)):null,Nl={any:[e=>!0,_s,()=>null],text:[e=>typeof e=="string",e=>e?.toString?.()??"",()=>""],int:[Number.isInteger,e=>Number.isFinite(e)?Math.trunc(e):null,()=>0],float:[Number.isFinite,_s,()=>0],bool:[e=>typeof e=="boolean",e=>!!e,()=>!1],list:[Array.isArray,e=>Array.isArray(e)?[...e]:null,()=>[]],object:[he,e=>he(e)?{...e}:null,()=>({})],map:[e=>e instanceof Map,up,()=>new Map],set:[e=>e instanceof Set,e=>e instanceof Set||Array.isArray(e)?new Set(e):null,()=>new Set]},ee=class{constructor(e,t,n,[r,s,i]=Nl[e]){this.type=e,this.name=t,this.typeCheck=r,this.coercer=s,this.defaultValue=n===void 0?i():n}isValid(e){return this.typeCheck(e)}coerceOr(e,t=null){if(this.isValid(e))return e;const n=this.coercer(e);return this.isValid(n)?n:t}coerceOrDefault(e){return this.coerceOr(e,this.defaultValue)}},Al=e=>e?.constructor?.getMetaClass?.(),hp=e=>Al(e)?.name??null,Ss=class extends ee{constructor(e,t,n){super(e,t,null,[r=>hp(r)===e,_s,()=>null]),this.args=n}};function xl(e,t,n){const r=t?.lookupComponent(e.type)??null;return r===null&&console.warn(t?`component field "${e.name}": component "${e.type}" not found in scope`:`component field "${e.name}": cannot resolve component "${e.type}" \u2014 built without a registered scope (use ${e.type}.make({}) as the default, or build via a registered component)`),r?.make({...e.args,...n},{scope:t})??null}function fp(e,t){const n=typeof t;if(n==="string")return new ee("text",e,t);if(n==="number")return new ee("float",e,t);if(n==="boolean")return new ee("bool",e,t);if(Array.isArray(t))return new ee("list",e,[...t]);if(t instanceof Set)return new ee("set",e,new Set(t));if(t instanceof Map)return new ee("map",e,new Map(t));if(t?.type&&Object.hasOwn(t,"defaultValue")){const r=t.type in Nl?t.type:"any",s=new ee(r,e);return new ee(r,e,s.coerceOr(t.defaultValue,s.defaultValue))}return t?.component&&t?.args!==void 0?new Ss(t.component,e,t.args):he(t)?new ee("object",e,{...t}):new ee("any",e,t)}function dp(e,{fields:t={},methods:n={},statics:r={}}){const s={};for(const a in t)s[a]=fp(a,t[a]);const i=Object.fromEntries(Object.entries(s).map(([a,l])=>[a,l.defaultValue])),o={[e]:class{constructor(a={}){Object.assign(this,i,a)}}}[e];return o[Sr]=!0,Object.assign(o.prototype,n),Object.assign(o,{fields:s,methods:n,getMetaClass:()=>o,make(a={},l={}){const c={},f=l.scope??this.scope;for(const p in a){const g=s[p];g===void 0?console.warn("extra argument to constructor:",e,p,a):g instanceof Ss?c[p]=xl(g,f,a[p]):c[p]=g.coerceOrDefault(a[p])}for(const p in s)s[p]instanceof Ss&&c[p]===void 0&&(c[p]=xl(s[p],f,void 0));return zt(new this(c),!0)}},r),o}function pp(e,t){const n=Al(e);if(n)for(const[r,s]of Object.entries(n.fields)){const i=t[r];if(s.isValid(i))continue;const o=s.coerceOr(i,Tl);o!==Tl?t[r]=o:(console.warn(`invalid value for ${n.name}.${r}`,i),t[r]=e[r])}}var mp=new Set([..."name id fields methods views receive intent alter provide provideType lookup spec extra commonStyle globalStyle scope _rawProvide _rawLookup make getMetaClass".split(" "),...Object.keys(wa)]);function gp(e={}){for(const t in e)if(mp.has(t))throw new TypeError(`component static "${t}" is reserved by the framework`)}function wp(e){return gp(e.statics),Pf(dp(e.name??"UnkComp",e),e)}var yp=class{constructor(e){this.val=e,this.changeSubs=[]}onChange(e){this.changeSubs.push(e)}set(e,t){const n=this.val;this.val=e;for(const r of this.changeSubs)r({val:e,old:n,info:t,timestamp:Date.now()})}},Il=class{constructor(e,t){this.comps=e,this.transactions=[],this.state=new yp(t),this.onTransactionPushed=()=>{},this._observers=[],this.refusals=[],this._refusalObservers=[],this._inflight=new Set}pushTransaction(e){this.transactions.push(e),this.onTransactionPushed(e)}observe(e){return Ol(this._observers,e)}refuse(e,t={}){const n={kind:e,info:t,timestamp:Date.now()};this.refusals.push(n),this.refusals.length>_p&&this.refusals.shift(),console.warn(`tutuca refusal [${e}]`,t);for(const r of this._refusalObservers)r(n);return n}observeRefusals(e){return Ol(this._refusalObservers,e)}_emitRecord(e,{kind:t,name:n,args:r,path:s,targetPath:i,handler:o,handlerName:a,matched:l,before:c,after:f,parent:p}){if(this._observers.length===0)return;const g=s.pinKeys(e),y={kind:t,name:n,args:r??null,path:g,pathKeys:g.toKeys(),targetPath:i,handler:o??null,handlerName:a??(o?.name||null),matched:l??null,before:c,after:f,parent:p,timestamp:Date.now()};for(const E of this._observers)E(y)}_emitTransaction(e,t){this._observers.length!==0&&this._emitRecord(t,{kind:e.observeKind,name:e.observeName,args:e.args,path:e.getTransactionPath(),targetPath:e.targetPath??e.path,handler:e._resolvedHandler,matched:e._matched,before:e._before,after:e._after,parent:e.parentTransaction})}pushSend(e,t,n=[],r=null,s=null,i=null){const o=new Dl(e,this,t,n,r);return o.txnPath=i,o.origin=s,o.originPinned=s===null?null:s.toTransactionPath().pinKeys(this.state.val),this.pushTransaction(o),r&&o.completion.carry(r.completion.track()),o}pushIntent(e,t,n=[],r={},s=null){const i=s?s.completion.track():null,o=new Tp(this,e,t,n,r,s,i);return o.advance(),o}async settle(e=1e4){for(;(this.hasPendingTransactions||this._inflight.size)&&e-- >0;){for(;this.hasPendingTransactions;)this.transactNext();this._inflight.size&&await Promise.allSettled([...this._inflight])}}get hasPendingTransactions(){return this.transactions.length>0}transactNext(){this.transact(this.transactions.shift())}transact(e){try{const t=this.state.val,n=e.run(t,this.comps);n!==void 0?(this.state.set(n,{transaction:e}),e.afterTransaction(),this._emitTransaction(e,t)):console.warn("undefined new state",{curState:t,transaction:e})}finally{e.ensureWalkAdvanced?.(),e._completion?.finish()}}transactInputNow(e,t,n,r){this.transact(new vp(e,t,n,this,r))}};function bp(){return this}function Ol(e,t){return e.push(t),()=>{const n=e.indexOf(t);n!==-1&&e.splice(n,1)}}function Pl(e,t){return console.warn(`unknown ${e} route leg`,t,'- expected "dyn" or "lex"'),null}var Ml=class{constructor(e,t,n=null){this.path=e,this.txnPath=null,this.transactor=t,this.parentTransaction=n,this._completion=null}get completion(){return this._completion??=new Np,this._completion}whenSettled(){return this.completion.whenSettled()}whenSubtreeSettled(){return this.completion.whenSubtreeSettled()}callHandler(e,t,n,r){const[s,i]=this.getHandlerAndArgs(e,t,r);return this._resolvedHandler=s,s.apply(t,[n,...i])}forward(e){this._forward=e??{}}afterTransaction(){const e=this._forward;if(e===void 0)return;this._forward=void 0;const t=this._forwardName();if(t===void 0){this.transactor.refuse("FORWARD_NO_NAME",{});return}const{args:n=this._forwardArgs(),...r}=e;this.transactor.pushIntent(this._forwardPath(),t,n,r,this)}getTransactionPath(){return this.txnPath??this.path.toTransactionPath()}run(e,t){const n=this.getTransactionPath(),r=n.lookup(e),s=ho(r,i=>{const o=this.callHandler(e,r,i,t);return(o===void 0||o===i)&&pp(r,i),o});return this._before=r,this._after=s,this._completion?.markSelfSettled({value:s,old:r}),r!==s?n.setValue(e,s):e}},vp=class extends Ml{constructor(e,t,n,r,s){super(e,r),this.e=t,this.handler=n,this.dragInfo=s,this._dispatchPath=null}get dispatchPath(){return this._dispatchPath??=this.path.compact(),this._dispatchPath}getTransactionPath(){return this.dispatchPath.toTransactionPath()}get observeKind(){return"receive"}get observeName(){return this.e?.type??null}_forwardName(){return(this.handler?.handlerCall?.handlerVal??this.handler?.handlerVal)?.name}_forwardArgs(){return this._handlerArgs??[]}_forwardPath(){return this.dispatchPath}getHandlerAndArgs(e,t,n){const r=this.path.buildStack(os.root(n,e,this)),[s,i]=this.handler.getHandlerAndArgs(r,this);this._handlerArgs=[...i];const o=this.dispatchPath;return i.push(new Ll(o,this.transactor,this)),[s,i]}},Cl=class extends Ml{constructor(e,t,n,r,s){super(e,t,s),this.name=n,this.args=r,this.targetPath=e}handlerProp=null;get observeKind(){return this.handlerProp}get observeName(){return this.name}_forwardName(){return this.name}_forwardArgs(){return this.args}_forwardPath(){return this.path}getHandlerForName(e){const t=e?.[this.handlerProp],n=t?.[this.name];if(n)return this._matched="exact",n;const r=t?.$unknown;return r?(this._matched="unknown",r):(this._matched="none",bp)}getHandlerAndArgs(e,t,n){return[this.getHandlerForName(n.getCompFor(t)),[...this.args,new Ll(this.path,this.transactor,this)]]}},Dl=class extends Cl{handlerProp="receive";get observeKind(){return this._isAnswer?"answer":"receive"}},Ep=class extends Cl{handlerProp="intent";constructor(e,t,n){super(e,t,n.name,n.args,n.parent),this.walk=n,this.targetPath=n.origin}forward(e){this.walk.amend(e,this.path)}afterTransaction(){this.ensureWalkAdvanced()}ensureWalkAdvanced(){this._advanced||(this._advanced=!0,this.walk.advance())}},kl=Symbol.for("tutuca.intent.pass"),_p=200,Sp=64,Tp=class{constructor(e,t,n,r,s,i,o){this.transactor=e,this.name=n,this.args=r,this.route=s?.route??ss,this.parent=i,this.release=o,this.origin=t,this.answerPath=s?.livePath?null:t.toTransactionPath().pinKeys(e.state.val),this.legIndex=0,this.dynAt=t,this.hops=0,this.ended=!1}advance(){if(!this.ended){if(this.hops++>=Sp)return this.exhaust("intentDepth");for(;this.legIndex<this.route.length;){const e=this.route[this.legIndex];if(e==="dyn"){if(!this.dynAt.canPop()){this.legIndex++;continue}this.dynAt=this.dynAt.popStep(),this.transactor.pushTransaction(new Ep(this.dynAt,this.transactor,this));return}if(e==="lex")return this.legIndex++,this._tryLex();Pl("intent",e),this.legIndex++}this.exhaust("noHandler")}}_tryLex(){const e=this.transactor.state.val,t=this.origin.toTransactionPath(),n=t.lookup(e),r=this.transactor.comps.getIntentChainFor(n,this.name);if(this.transactor._emitRecord(e,{kind:"intent",name:this.name,args:this.args,path:t,targetPath:this.origin,handler:r[0],handlerName:r[0]?.name||this.name,matched:r.length>0?"exact":"none",before:n,after:void 0,parent:this.parent}),r.length===0)return this.advance();const s=this._runLex(r,0);this.transactor._inflight.add(s),s.finally(()=>this.transactor._inflight.delete(s))}async _runLex(e,t){if(this.ended)return;if(t>=e.length)return this.advance();const n=new Ts(this.origin,this.transactor,this.parent);try{const r=await e[t].apply(null,[...this.args,n]);if(r===kl)return this._runLex(e,t+1);this.answer("Ok",r)}catch(r){this.answer("Error",r)}}answer(e,t){this.finish(`${this.name}${e}`,[t])}amend(e,t){e?.args!==void 0&&(this.args=e.args),e?.route!==void 0&&(this.route=e.route,this.legIndex=0,this.dynAt=t??this.dynAt)}exhaust(e){if(this.ended)return;const{name:t,args:n}=this,r=this.transactor.comps.getCompFor(this.origin.toTransactionPath().lookup(this.transactor.state.val)),s=i=>r?.receive?.[i]!==void 0;s(`${t}Unhandled`)?this.finish(`${t}Unhandled`,n):s(`${t}Error`)?this.finish(`${t}Error`,[e]):(s(`${t}Ok`)&&console.warn(`intent "${t}" was not answered (${e}) and this component declares only "${t}Ok" - add "${t}Unhandled" or "${t}Error" to handle it`),this.finish(null,null))}finish(e,t){if(this.ended)return;if(this.ended=!0,e===null)return this.release?.();const n=new Dl(this.origin,this.transactor,e,t,this.parent);n.txnPath=this.answerPath,n._isAnswer=!0,this.transactor.pushTransaction(n),this.release&&n.completion.carry(this.release)}},Np=class{constructor(){this.val=void 0,this.selfSettled=!1,this.subtreeSettled=!1,this.pending=0,this._selfResolve=null,this._selfPromise=null,this._subtreeResolve=null,this._subtreePromise=null,this._releaseSelf=this.track()}whenSettled(){return this.selfSettled?Promise.resolve(this.val):(this._selfPromise??=new Promise(e=>{this._selfResolve=e}),this._selfPromise)}whenSubtreeSettled(){return this.subtreeSettled?Promise.resolve(this.val):(this._subtreePromise??=new Promise(e=>{this._subtreeResolve=e}),this._subtreePromise)}markSelfSettled(e){this.selfSettled||(this.selfSettled=!0,this.val=e,this._selfResolve?.(e))}finish(){this.markSelfSettled(this.val),this._releaseSelf()}track(){this.pending++;let e=!1;return()=>{e||(e=!0,--this.pending===0&&(this.subtreeSettled=!0,this._subtreeResolve?.(this.val)))}}carry(e){this.whenSubtreeSettled().then(e)}},Ts=class{constructor(e,t,n){this.path=e,this.transactor=t,this.parent=n,this.root=t.state.val}walkPath(e){const t=this.transactor.comps,n=this.path.toTransactionPath().resolveChain(this.root);for(let r=n.length-1;r>=0;r--){const s=t.getCompFor(n[r]);if(s&&e(s,n[r])===!1)return}}get at(){return new Ap(this)}_stack(){return this._stackMemo??=this.path.buildStack(os.root(this.transactor.comps,this.root,this.parent)),this._stackMemo}lookup(e,t){for(const n of t?.route??ss){const r=n==="dyn"?this._stack()?.lookupDynamic(e)??null:n==="lex"?this._lookupLex(e):Pl("lookup",n);if(r!=null)return r}return null}_lookupLex(e){let t=null;this.walkPath(r=>(t=r,!1));const n=t?.scope;return n==null?null:je(e)?n.lookupComponent(e)??null:n.lookupPath(e)?.lookup(this.root)??null}lookupType(e,t){const n=t?.route??ss,r=this.lookup(e,{route:n});return r==null?(this.transactor.refuse("TYPE_NOT_FOUND",{name:e,route:n}),null):r?.[xe]==null?(this.transactor.refuse("TYPE_NOT_COMPONENT",{name:e,got:typeof r}),null):r}send(e,t){return this.sendAtPath(this.path,e,t)}sendAtPath(e,t,n){return this.transactor.pushSend(e,t,n,this.parent,this.path)}intent(e,t,n){return this.intentAtPath(this.path,e,t,n)}intentAtPath(e,t,n,r){return this.transactor.pushIntent(e,t,n,r,this.parent)}},Ll=class extends Ts{get name(){return this.parent?.name??null}get targetPath(){return this.parent.targetPath}reply(e){return this.parent.walk===void 0?Ns("reply"):this.parent.walk.answer("Ok",e)}fail(e){return this.parent.walk===void 0?Ns("fail"):this.parent.walk.answer("Error",e)}sendReply(e,t){const n=this.parent?.origin??null;return n==null?(this.transactor.refuse("NO_SENDER",{name:e}),null):this.transactor.pushSend(n,e,t,this.parent,this.path,this.parent.originPinned)}stop(){return this.parent.walk===void 0?Ns("stop"):this.parent.walk.finish(null,null)}forward(e){return this.parent.forward(e)}};function Ns(e){console.warn(`ctx.${e}() is only meaningful in an "intent" handler - ignored`)}var Ap=class extends bo{constructor(e){super(),this.dispatcher=e}send(e,t){return this.dispatcher.sendAtPath(this.buildPath(),e,t)}intent(e,t,n){return this.dispatcher.intentAtPath(this.buildPath(),e,t,n)}buildPath(){return this.dispatcher.path.concat(this.pathChanges)}};function Rl(e){return new Ts(new at,e,null)}var xp=class{constructor({path:e=null,present:t=new Set,counts:n={},warnings:r=[]}){this.path=e,this.present=t,this.counts=n,this.warnings=r}},Ip=class{constructor({name:e,views:t,fields:n}){this.name=e,this.views=t,this.fields=n}},Op=class{constructor({items:e,total:t=null,truncated:n=!1}){this.items=e,this.total=t??e.length,this.truncated=n}},Pp=class{constructor({sections:e,total:t=null,truncated:n=!1}){this.sections=e,this.total=t??e.reduce((r,s)=>r+(s.items?.length??0),0),this.truncated=n}},$l=class{constructor({items:e}){this.items=e}},Mp=class{constructor({id:e,level:t,info:n,context:r={},suggestion:s=null}){this.id=e,this.level=t,this.info=n,this.context=r,this.suggestion=s}},Cp=class{constructor({componentName:e,findings:t}){this.componentName=e,this.findings=t}get errorCount(){return this.findings.filter(e=>e.level==="error").length}get warnCount(){return this.findings.filter(e=>e.level==="warn").length}},Dp=class{constructor({components:e}){this.components=e}get hasErrors(){return this.components.some(e=>e.errorCount>0)}get totalErrors(){return this.components.reduce((e,t)=>e+t.errorCount,0)}get totalWarnings(){return this.components.reduce((e,t)=>e+t.warnCount,0)}},kp=class{constructor({title:e,description:t=null,componentName:n,view:r,html:s,error:i=null}){this.title=e,this.description=t,this.componentName=n,this.view=r,this.html=s,this.error=i}},Lp=class{constructor({title:e,description:t=null,items:n}){this.title=e,this.description=t,this.items=n}},Rp=class{constructor({sections:e}){this.sections=e}get hasErrors(){return this.sections.some(e=>e.items.some(t=>t.error!==null))}},dn=class{constructor({title:e,fullPath:t,componentName:n=null,status:r,durationMs:s=0,error:i=null}){this.title=e,this.fullPath=t,this.componentName=n,this.status=r,this.durationMs=s,this.error=i}},Fl=class{constructor({title:e,componentName:t=null,children:n=[]}){this.title=e,this.componentName=t,this.children=n}},As=class{constructor({path:e=null,suites:t=[],counts:n={pass:0,fail:0,skip:0,total:0}}){this.path=e,this.suites=t,this.counts=n}},xs=class{constructor({modules:e=[]}){this.modules=e}get totals(){return this.modules.reduce((e,t)=>({pass:e.pass+t.counts.pass,fail:e.fail+t.counts.fail,skip:e.skip+t.counts.skip,total:e.total+t.counts.total}),{pass:0,fail:0,skip:0,total:0})}get hasFailures(){return this.modules.some(e=>e.counts.fail>0)}},Bl=class{constructor({title:e,componentName:t=null,parent:n=null}){this.title=e,this.componentName=t,this.parent=n,this.children=[]}},Is=class{constructor({title:e,fn:t,componentName:n=null,parent:r=null}){this.title=e,this.fn=t,this.componentName=n,this.parent=r}},Vl=class{constructor({path:e=null,suites:t=[]}={}){this.path=e,this.suites=t}};function Ul(e){return e===null?!1:typeof e=="function"?e[xe]!=null:typeof e.name=="string"&&typeof e.Class=="function"}function jl(e,t){if(Ul(e))return e.name;if(typeof e=="function"){for(const n of t)if(n===e)return n.name}return null}function ql(e){return typeof e=="string"?e:Ul(e)?e.name:typeof e=="function"?e.name||"(anonymous)":String(e)}function Hl({path:e=null,components:t=[]}={}){const n=new Vl({path:e,suites:[]}),r=[];function s(...o){let a,l=null,c;if(o.length===2)[a,c]=o;else if(o.length===3)[a,l,c]=o;else throw new Error(`describe() expects 2 or 3 arguments, got ${o.length}`);if(typeof c!="function")throw new Error(`describe(${JSON.stringify(ql(a))}): final argument must be a function`);let f=null;if(typeof a!="string"&&(f=jl(a,t)),f===null&&l&&l.component!=null&&(f=jl(l.component,t)),f===null){const y=r.length?r[r.length-1]:null;y&&(f=y.componentName)}const p=r.length?r[r.length-1]:null,g=new Bl({title:ql(a),componentName:f,parent:p});p?p.children.push(g):n.suites.push(g),r.push(g);try{c()}finally{r.pop()}}function i(o,a){if(typeof o!="string")throw new Error("test(title, fn): title must be a string");if(typeof a!="function")throw new Error(`test(${JSON.stringify(o)}): fn must be a function`);const l=r.length?r[r.length-1]:null;if(!l)throw new Error(`test(${JSON.stringify(o)}) must be called inside a describe()`);l.children.push(new Is({title:o,fn:a,componentName:l.componentName,parent:l}))}return{describe:s,test:i,moduleTests:n}}function $p(e){const t=[];let n=e;for(;n;)t.unshift(n.title),n=n.parent;return t.join(" > ")}function Fp(e){const t={message:e.message,stack:e.stack};return"expected"in e&&(t.expected=e.expected),"actual"in e&&(t.actual=e.actual),t}function Gl({components:e=[],macros:t=null,intentHandlers:n=null}={}){const r=new ga;return r.registerComponents(e),t&&r.registerMacros(t),n&&r.registerIntentHandlers(n),r}async function Wl(e,t,n,r={}){const s=new Il(e.comps,t);return r.onMessage&&s.state.onChange(({val:i,old:o,info:a})=>{const l=a?.transaction;r.onMessage({kind:l?.handlerProp??"receive",name:l?.name,args:l?.args,path:l?.path},o,i)}),Sl(Rl(s),new at,n,t),await s.settle(),s.state.val}async function Bp(e,t,n,r={}){return Wl(Gl(e),t,n,r)}async function Kl({getTests:e,components:t=[],path:n=null,expect:r,name:s=null,grep:i=null,bail:o=!1,intentHandlers:a=null,macros:l=null}={}){const c={pass:0,fail:0,skip:0,total:0};if(typeof e!="function")return new xs({modules:[new As({path:n,suites:[],counts:c})]});if(typeof r!="function")throw new Error("runTests: expect must be provided (e.g. chai's expect)");const{describe:f,test:p,moduleTests:g}=Hl({path:n,components:t});let y=null;const E=()=>y??=Gl({components:t,macros:l,intentHandlers:a});await e({describe:f,test:p,expect:r,drive:(D,k,Q={})=>Wl(E(),D,k,Q)});let M=!1;async function x(D){if(D instanceof Is){if(s!==null&&D.componentName!==s)return null;const Q=$p(D);if(i!==null&&!Q.includes(i))return null;if(c.total++,M)return c.skip++,new dn({title:D.title,fullPath:Q,componentName:D.componentName,status:"skip"});const ce=performance.now();try{return await D.fn(),c.pass++,new dn({title:D.title,fullPath:Q,componentName:D.componentName,status:"pass",durationMs:performance.now()-ce})}catch(Ge){return c.fail++,o&&(M=!0),new dn({title:D.title,fullPath:Q,componentName:D.componentName,status:"fail",durationMs:performance.now()-ce,error:Fp(Ge)})}}const k=[];for(const Q of D.children){const ce=await x(Q);ce!==null&&k.push(ce)}return k.length===0?null:new Fl({title:D.title,componentName:D.componentName,children:k})}const C=[];for(const D of g.suites){const k=await x(D);k!==null&&C.push(k)}return new xs({modules:[new As({path:n,suites:C,counts:c})]})}var zl="color: #0a0; font-weight: bold",Yl="color: #c00; font-weight: bold",Vp="color: #888",Os="color: #888",Ps="color: inherit; font-weight: normal";function Xl(e){if(e.children){const n=e.componentName?`${e.title} [${e.componentName}]`:e.title;console.group(n);for(const r of e.children)Xl(r);console.groupEnd();return}const t=e.status==="skip"?"":` (${Math.round(e.durationMs)}ms)`;e.status==="pass"?console.log(`%c\u2713%c ${e.title}%c${t}`,zl,Ps,Os):e.status==="skip"?console.log(`%c\u25CB ${e.title}%c (skipped)`,Vp,Ps):(console.group(`%c\u2717%c ${e.title}%c${t}`,Yl,Ps,Os),console.error(e.error?.message??"(no error message)"),e.error&&("expected"in e.error||"actual"in e.error)&&(console.log("expected:",e.error.expected),console.log("actual:  ",e.error.actual)),e.error?.stack&&console.log(e.error.stack),console.groupEnd())}function Jl(e){for(const t of e.modules){const n=`tutuca tests${t.path?` \u2014 ${t.path}`:""}`;if(console.group(n),t.suites.length===0)console.log("(no tests)");else for(const i of t.suites)Xl(i);const r=t.counts,s=`${r.pass} passed, ${r.fail} failed, ${r.skip} skipped (${r.total} total)`;r.fail>0?console.error(`%c${s}`,Yl):r.total===0?console.log(`%c${s}`,Os):console.log(`%c${s}`,zl),console.groupEnd()}return e}var Up={ternary:"ternary expression",comparison:"comparison",logical:"logical expression","call-with-args":"method call with arguments","field-path":"dotted field path"};function jp(e){const t=JSON.stringify(e.value),n=Up[e.detected]??"expression";switch(e.role){case"attr":return`Unsupported ${n} ${t} in dynamic attribute ':${e.attr}'`;case"directive":return`Unsupported ${n} ${t} in directive '@${e.directive}'`;case"if":return`Unsupported ${n} ${t} in '@if.${e.attr}' condition`;case"x-op":return`Unsupported ${n} ${t} in <x ${e.op}>`;default:return`Unsupported ${n} ${t}`}}function qp(e){const t=JSON.stringify(e.value);switch(e.role){case"attr":return`Cannot parse value ${t} for attribute ':${e.attr}'`;case"directive":return`Cannot parse value ${t} for directive '@${e.directive}'`;case"if":return`Cannot parse condition ${t} for '@if.${e.attr}'`;case"x-op":return`Cannot parse value ${t} for <x ${e.op}>`;case"handler-name":return`Cannot parse handler name ${t}`;case"handler-arg":return`Cannot parse handler argument ${t}`;case"macro-var":return`Macro parameter '^${e.name}' is not defined`;default:return`Cannot parse value ${t}`}}function Ql(e){return e?String(e).toLowerCase():null}function le(e){const t=Ql(e?.tag);return t&&t!=="x"?` on <${t}>`:""}function ie(e){if(!e)return"";const t=[];if(e.originAttr){const r=e.branch?`[${e.branch}]`:"";t.push(`in ${e.originAttr}${r}`)}e.handlerName&&t.push(`handler '${e.handlerName}'${e.argIndex!==void 0?` arg ${e.argIndex}`:""}`);const n=Ql(e.tag);return n&&n!=="x"&&t.push(`on <${n}>`),t.length?` (${t.join(", ")})`:""}function Hp(e){return e?.originAttr?` in ${e.originAttr}`:e?.eventName?` in @on.${e.eventName}`:""}function Zl(e,t){switch(e){case"RENDER_IT_OUTSIDE_OF_LOOP":return"<x render-it> used outside of a loop";case"UNKNOWN_EVENT_MODIFIER":{const n=t.handler?.modifiers??[t.modifier],r=`@on.${t.name}+${n.join("+")}`;return`Unknown modifier '+${t.modifier}' in '${r}'`}case"HANDLER_NAME_COLLISION":return`${t.problem} \u2014 ${t.fix}`;case"RECEIVE_HANDLER_NOT_IMPLEMENTED":return`Receive handler '${t.name}' is not implemented${Hp(t)}`;case"EVENT_HANDLER_METHOD_NOT_ALLOWED":return`Event handler '$${t.name}' is a method reference \u2014 move it to receive and use '${t.name}'`;case"FIELD_METHOD_NAME_COLLISION":return`Field '${t.name}' shadows a method with the same name \u2014 rename either the field or method`;case"FIELD_VAL_NOT_DEFINED":return`Field '.${t.name}' is not defined${ie(t)}`;case"FIELD_VAL_IS_METHOD":return`'.${t.name}' reads a field, but '${t.name}' is defined as a method \u2014 use '$${t.name}'${ie(t)}`;case"METHOD_VAL_NOT_DEFINED":return`Method '$${t.name}' is not defined${ie(t)}`;case"METHOD_VAL_IS_FIELD":return`'$${t.name}' calls a method, but '${t.name}' is defined as a field \u2014 use '.${t.name}'${ie(t)}`;case"DUPLICATE_ATTR_DEFINITION":{const n=t.sources?.length?` (${t.sources.join(", ")})`:"",r=t.tag?` on <${String(t.tag).toLowerCase()}>`:"";return`Attribute '${t.name}' is set ${t.sources?.length??"multiple"} times${n}${r}`}case"IF_NO_BRANCH_SET":return`'@if.${t.attr}' has no '@then' or '@else' branch \u2014 add '@then="\u2026"' or '@else="\u2026"' (or both)${le(t)}`;case"UNKNOWN_COMPONENT_NAME":return`Unknown component '${t.name}'${ie(t)}`;case"ALT_HANDLER_NOT_DEFINED":return`Alter handler '${t.name}' is not defined${ie(t)}`;case"ALT_HANDLER_NOT_REFERENCED":return`Alter handler '${t.name}' is defined but never used \u2014 remove it or reference it from @when, @enrich-with, or @loop-with`;case"DYN_VAL_NOT_DEFINED":return`Dynamic binding '*${t.name}' is not defined${ie(t)}`;case"DYN_ALIAS_NOT_REFERENCED":return`Lookup '${t.name}' is defined but never used \u2014 remove it or reference it as '*${t.name}' in a view`;case"PROVIDE_NOT_ADDRESSABLE":return`Provide '${t.name}' value '${t.value}' must be a field ('.f') or seq-access ('.s[.k]') \u2014 a provide doubles as the path '<x render="*${t.name}">' resumes at, so this one is dropped and '*${t.name}' resolves to nothing`;case"LOOKUP_BAD_SHAPE":return`Lookup '${t.name}' has an invalid shape: ${t.problem}`;case"LOOKUP_NO_PROVIDER":return t.hasDefault?`Lookup '${t.name}' is provided by no component in scope and matches no registered path, so it always resolves to its default`:`Lookup '${t.name}' is provided by no component in scope and matches no registered path \u2014 add a 'provide' for it, register a path under that name, or give this lookup a default`;case"PROVIDE_TYPE_BAD_SHAPE":return`Provide '${t.name}' starts uppercase, so it publishes a component type \u2014 its value must be 'self', not '${t.value}'`;case"UNKNOWN_MACRO_ARG":return`Argument '${t.name}' is not declared in macro '${t.macroName}'`;case"UNKNOWN_DIRECTIVE":return`Unknown directive '@${t.name}=${JSON.stringify(t.value)}'${le(t)}`;case"ORPHAN_DIRECTIVE":return`'@${t.name}=${JSON.stringify(t.value)}' needs an '@${t.needs}' on the same element \u2014 it was ignored${le(t)}`;case"UNKNOWN_X_OP":return`Unknown <x> op '${t.name}=${JSON.stringify(t.value)}'${le(t)}`;case"UNKNOWN_X_ATTR":return`Unknown attribute '${t.name}=${JSON.stringify(t.value)}' on <x ${t.op}>${le(t)}`;case"X_OP_IGNORES_CHILDREN":return`<x ${t.op}> has child content, but the '${t.op}' op ignores its children \u2014 they are silently dropped when the template is parsed; remove them${le(t)}`;case"MAYBE_DROP_AT_PREFIX":return`'${t.value!==void 0?`${t.name}=${JSON.stringify(t.value)}`:t.name}' on <x> looks like a directive but is actually an x op/attr written with a leading '@'`;case"MAYBE_ADD_AT_PREFIX":return`'${t.name}' on <${(t.tag??"").toLowerCase()}> is a plain attribute, but '@${t.name}' is a directive \u2014 add the leading '@'`;case"BAD_VALUE":return`${qp(t)}${le(t)}`;case"UNSUPPORTED_EXPR_SYNTAX":return`${jp(t)}${le(t)}`;case"BINDING_MEMBER_TOO_DEEP":return`Binding member read ${JSON.stringify(t.value)} goes more than one level deep \u2014 only one member is allowed (like '@value.title')${le(t)}`;case"SUGGEST_BINDING_MEMBER":{const n=(t.members??[]).map(({member:r})=>`'@value.${r}'`).join(", ");return`Enrich handler '${t.name}' only copies members of the loop value \u2014 read them directly${n?` (${n})`:""} and remove the '@enrich-with'`}case"REDUNDANT_TEMPLATE_STRING":return`Redundant string template \u2014 '{${t.simpler}}' should be just '${t.simpler}'${ie(t)}`;case"PLACEHOLDERLESS_TEMPLATE_STRING":return`String template has no dynamic parts \u2014 use the string literal ${t.literal} instead${ie(t)}`;case"CONSTANT_CONDITION":return`Condition is the constant literal ${t.literal} \u2014 it never changes; reference a field ('.name') or a method ('$name') instead${ie(t)}`;case"UNKNOWN_COMPONENT_SPEC_KEY":return`Unknown component spec key '${t.key}' \u2014 value will be ignored at runtime`;case"COMP_FIELD_BAD_SHAPE":return t.kind==="args-not-object"?`Field '${t.fieldName}': in { component, args }, 'args' must be a plain object, got ${t.got}`:`Field '${t.fieldName}': in { component, args }, 'component' must be the component name as a string, got ${t.gotName?`the ${t.gotName} class`:t.got}`;case"HTML_TAG_NAME_HAS_UPPERCASE":return`Tag <${t.raw}> will be lowercased to <${t.lowercased}>${R(t)}`;case"HTML_SVG_TAG_WILL_LOWERCASE":return`SVG tag <${t.raw}> is not in the WHATWG case-correction list \u2014 will be lowercased to <${t.lowercased}>${R(t)}`;case"HTML_TAG_NOT_ALLOWED_IN_PARENT":return`<${t.tag}> not allowed under <${t.parent??"?"}> in ${t.mode} \u2014 ${Gp(t.action,t.tag,t.parent)}${R(t)}`;case"HTML_TEXT_NOT_ALLOWED_IN_PARENT":return`Non-whitespace text not allowed in ${t.mode}: ${JSON.stringify(t.snippet)}${R(t)}`;case"HTML_VOID_ELEMENT_HAS_CLOSE_TAG":return`Void element <${t.tag}> has an explicit close tag${R(t)}`;case"HTML_DUPLICATE_FORM":return`Nested <form> \u2014 the inner form will be dropped by the parser${R(t)}`;case"HTML_NESTED_INTERACTIVE":return`<${t.tag}> nested inside another <${t.tag}> \u2014 adoption agency will reorder${R(t)}`;case"HTML_MISNESTED_FORMATTING":return`Misnested formatting tag </${t.tag}> \u2014 adoption agency will reorder nodes${R(t)}`;case"HTML_UNEXPECTED_END_TAG":return`Unexpected end tag </${t.tag}>${R(t)}`;case"HTML_UNCLOSED_BEFORE_END":return`<${t.unclosed}> still open when </${t.tag}> was seen \u2014 implicitly closed${R(t)}`;case"HTML_DUPLICATE_ATTRIBUTE":return`Duplicate attribute '${t.name}' \u2014 second occurrence dropped${R(t)}`;case"HTML_ATTRIBUTES_ON_END_TAG":return`Attributes on end tag </${t.tag}> \u2014 dropped by the parser${R(t)}`;case"HTML_SELF_CLOSING_END_TAG":return`Self-closing end tag </${t.tag}/> \u2014 trailing '/' is meaningless${R(t)}`;case"HTML_MISSING_ATTRIBUTE_VALUE":return`Attribute '${t.name}' is missing a value${R(t)}`;case"HTML_CDATA_IN_HTML_NAMESPACE":return`CDATA section in HTML namespace \u2014 reinterpreted as a bogus comment${R(t)}`;case"HTML_BOGUS_COMMENT":return`Bogus comment \u2014 content dropped by the parser${R(t)}`;case"HTML_SVG_ATTR_WILL_LOWERCASE":return`SVG attribute '${t.raw}' will be rewritten to '${t.canonical}'${R(t)}`;case"HTML_MATHML_ATTR_WILL_LOWERCASE":return`MathML attribute '${t.raw}' will be rewritten to '${t.canonical}'${R(t)}`;case"ASYNC_HANDLER":return`Handler '${t.name}' in '${t.channel}' is an async function \u2014 handlers must be synchronous and return the updated state (an async function returns a Promise the framework won't await)`;case"TOP_LEVEL_AT_RULE_IN_SCOPED_STYLE":return`'@${t.atRule}' is a top-level-only at-rule, but '${t.key}' is wrapped in a component-scoped selector ([data-cid=\u2026]{\u2026}) where it is invalid and silently dropped \u2014 move it to 'globalStyle'${R(t)}`;case"GLOBAL_SELECTOR_IN_SCOPED_STYLE":return`Selector '${t.selector}' targets the document root, but '${t.key}' is wrapped in a component-scoped selector, so it becomes a descendant selector that never matches \u2014 move it to 'globalStyle'${R(t)}`;case"LINT_ERROR":return t.message;default:return e}}function ec(e){if(!e)return null;switch(e.kind){case"replace-name":return`did you mean '${e.to}'?`;case"drop-prefix":return`did you mean '${e.to}'? (drop the leading '${e.from.slice(0,e.from.length-e.to.length)}')`;case"add-prefix":return`did you mean '${e.to}'? (add the leading '${e.to.slice(0,e.to.length-e.from.length)}')`;case"remove":return`remove ${e.what}`;case"rewrite":return`use '${e.to}' instead of '${e.from}'`;case"wrap":return`wrap it in ${e.to}`;case"rephrase":return e.text??null;default:return null}}function R(e){const t=e?.location;return t?` at line ${t.line}, col ${t.column}`:""}function Gp(e,t,n){switch(e){case"ignored":return`the parser will drop this <${t}>`;case"drop":return`the parser will drop this <${t}>`;case"auto-close-implicit":return`the parser will close <${n??"?"}> first, then place <${t}> as a sibling`;case"foster-parent":return`the parser will move <${t}> outside <${n??"?"}> (foster-parenting)`;case"foreign-breakout":return`the parser will exit foreign content and re-process <${t}> in HTML mode`;default:return`parser action: ${e}`}}var Wp="dragstart dragover dragend touchstart touchmove touchend touchcancel".split(" "),Kp=class{constructor(e,t,n,r){this.rootNode=e,this.comps=t,this.compStack=new ga(t),this.transactor=new Il(t,null),this.ParseContext=r,this.renderer=n,this._transactNextBatchId=this._evictCacheId=null,this._eventNames=new Set(Wp),this.dragInfo=this.curDragOver=null,this._touch=null,this.transactor.onTransactionPushed=s=>{this._transactNextBatchId===null&&this._scheduleNextTransactionBatchExecution()},this._compiled=!1,this._renderOpts={document:e.ownerDocument},this._renderState=null,this.rootViewName=null}get state(){return this.transactor.state}handleEvent(e){const{type:t}=e;if(t[0]==="t"&&t.startsWith("touch")){this._handleTouchEvent(e);return}this._dispatchEvent(e)}_dispatchEvent(e){const{type:t}=e,n=t==="dragover"||t==="dragstart"||t==="dragend"||t==="drop",{rootNode:r,comps:s,transactor:i}=this,[o,a]=at.fromNodeAndEventName(e.target,t,r,s,!n);if(n&&this._handleDragEvent(e,t,o),o!==null&&a!==null)for(const l of a)i.transactInputNow(o,e,l,this.dragInfo)}_handleTouchEvent(e){const{type:t}=e;if(t==="touchstart"){if(this._touch!==null||e.touches.length!==1)return;const l=e.touches[0],c=l.target?.closest?.('[draggable="true"]');if(!c)return;this._touch=Xp(l.identifier,l.clientX,l.clientY,c,!1);return}if(this._touch===null)return;const n=Yp(e,this._touch.id);if(n===null)return;const{rootNode:r,_touch:s}=this,{clientX:i,clientY:o}=n,a=(l,c)=>{const f={type:l,target:c,clientX:i,clientY:o,preventDefault:zp};this._dispatchEvent(f)};if(t==="touchmove"){if(s.active)e.preventDefault(),a("dragover",nc(r,i,o));else{const l=i-s.startX,c=o-s.startY;if(l*l+c*c<100)return;s.active=!0,e.preventDefault(),a("dragstart",s.target)}return}(t==="touchend"||t==="touchcancel")&&(s.active&&(t==="touchend"&&a("drop",nc(r,i,o)),a("dragend",s.target)),this._touch=null)}_handleDragEvent(e,t,n){if(t==="dragover"){const r=Jp(e.target,this.rootNode,1/0);r!==null&&(e.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=r,r.dataset.draggingover=this.dragInfo?.type??"_external")}else if(t==="dragstart"){e.target.dataset.dragging=1;const r=this.state.val,i=n.compact().toTransactionPath().lookup(r),o=e.target.dataset.dragtype??"?",a=n.buildStack(this.makeStack(r));this.dragInfo=new Qp(a,i,o,e.target)}else t==="drop"?(e.preventDefault(),this._cleanDragOverAttrs()):(this.dragInfo!==null&&(delete this.dragInfo.node.dataset.dragging,this.dragInfo=null),this._cleanDragOverAttrs())}makeStack(e){return os.root(this.comps,e)}_cleanDragOverAttrs(){this.curDragOver!==null&&(delete this.curDragOver.dataset.draggingover,this.curDragOver=null)}render(){const e=this.state.val,t=this.makeStack(e),{renderer:n,rootNode:r,_renderOpts:s,_renderState:i}=this,o=zh(n.renderRoot(t,e,this.rootViewName),r,s,i);return this._renderState=o,o.dom}onChange(e){this.transactor.state.onChange(e)}observe(e){return this.transactor.observe(e)}compile(){for(const e of this.comps.byId.values()){e.compile(this.ParseContext);for(const t in e.views)for(const n of e.views[t].ctx.genEventNames())this._eventNames.add(n)}this._compiled=!0}subscribeToEvents(e){for(const t of e)this.rootNode.addEventListener(t,this,tc(t))}recompileStyles(e){Ms("tutuca-app",this.comps.compileStyles(),e?.head??document.head)}start(e){this._compiled||this.compile(),this.subscribeToEvents(this._eventNames),this.onChange(t=>{t.val!==t.old&&this.render()}),this.recompileStyles(e),e?.noCache?this.renderer.setNullCache():this.startCacheEvictionInterval(),this.render()}stop(){this.stopCacheEvictionInterval(),clearTimeout(this._transactNextBatchId),this._transactNextBatchId=null;for(const e of this._eventNames)this.rootNode.removeEventListener(e,this,tc(e))}sendAtRoot(e,t){this.transactor.pushSend(new at,e,t)}registerComponents(e,t){const n=this.compStack.enter();return n.registerComponents(e,t),n}_transactNextBatch(e=10){this._transactNextBatchId=null;const t=Date.now(),n=this.transactor;for(;n.hasPendingTransactions&&Date.now()-t<e;)n.transactNext();n.hasPendingTransactions&&this._scheduleNextTransactionBatchExecution()}_scheduleNextTransactionBatchExecution(){this._transactNextBatchId=setTimeout(()=>this._transactNextBatch(),0)}startCacheEvictionInterval(e=3e4){this._evictCacheId=setInterval(()=>this.renderer.cache.evict(),e)}stopCacheEvictionInterval(){clearInterval(this._evictCacheId),this._evictCacheId=null}};function Ms(e,t,n=document.head){const r=document.createElement("style"),s=n.querySelector(`#${e}`);s&&n.removeChild(s),r.id=e,r.innerHTML=t,n.appendChild(r)}var zp=()=>{};function Yp(e,t){for(const n of e.changedTouches)if(n.identifier===t)return n;for(const n of e.touches)if(n.identifier===t)return n;return null}var tc=e=>e==="touchmove"?{passive:!1}:void 0;function Xp(e,t,n,r,s){return{id:e,startX:t,startY:n,target:r,active:s}}function nc(e,t,n){let s=e.getRootNode().elementFromPoint?.(t,n)??null;for(;s?.shadowRoot;){const i=s.shadowRoot.elementFromPoint(t,n);if(i===null||i===s)break;s=i}return s??e}function Jp(e,t,n){let r=e;for(;n-- >0&&r!==t;){if(r.dataset?.droptarget!==void 0)return r;r=r.parentNode}return null}var Qp=class{constructor(e,t,n,r){this.stack=e,this.val=t,this.type=n,this.node=r}lookupBind(e){return this.stack.lookupBind(e)}},rc=e=>e!==null&&(typeof e=="object"||typeof e=="function"),Zp=class{get(e,t){}set(e,t,n){}evict(){}},em=class{constructor(){this.keysByLen=new Map}get(e,t){const n=e.length;let r=this.keysByLen.get(n);if(r){for(let s=0;s<n-1;s++)if(r=r.get(e[s]),!r)return;return r.get(e[n-1])?.[t]}}set(e,t,n){const r=e.length;let s=this.keysByLen.get(r);s||(s=new WeakMap,this.keysByLen.set(r,s));for(let a=0;a<r-1;a++){const l=e[a];let c=s.get(l);if(!c){if(!rc(l))return;c=new WeakMap,s.set(l,c)}s=c}const i=e[r-1],o=s.get(i);o?o[t]=n:rc(i)&&s.set(i,{[t]:n})}evict(){this.keysByLen=new Map}};function sc(e,t){return e instanceof sn?new sn(e.tag,{...e.attrs,"data-rp":t},e.childs,e.key,e.namespace):e instanceof pe?new pe(e.childs.map(n=>sc(n,t))):e}var tm=class{constructor(e){this.comps=e,this.cache=new em}renderTag(e,t,n,r){return Yh(e,t,n,r)}renderFragment(e){return new pe(e)}renderComment(e){return new zr(e)}setNullCache(){this.cache=new Zp}renderRoot(e,t,n=null){const r=this.comps.getCompFor(t);return r===null?null:this._rValComp(e,t,r,r.getView(n).anode,"ROOT",n)}renderIt(e,t,n,r=null){const s=this.comps.getCompFor(e.it);return s?this._rValComp(e,e.it,s,t,"",n,r):null}_rValComp(e,t,n,r,s,i,o=null){const a=`${i??""}${e.viewsId??""}${s}${e.renderPath.addressKey}`,l=[r,t];e._pushDynBindValuesToArray(l,n);const c=this.cache.get(l,a);if(c)return c;const f=i?n.getView(i):e.lookupBestView(n.views,"main"),p=this.renderView(f,e);if(p==null)return null;const g=o===null?null:mo(o),y=this._renderMetadata({$:"Comp",nid:r?.nodeId??null,cid:n.id,vid:f.name,...g===null?null:{base:g}}),E=new pe([y,g===null?p:sc(p,JSON.stringify(g))]);return this.cache.set(l,a,E),E}pushEachEntry(e,t,n,r,s){e.push(this._renderMetadata({$:"Each",nid:t,[n]:r}),s)}renderEachWhen(e,t){const{val:n,node:r,nodeId:s}=t,{seq:i,filter:o,loopWith:a,enricher:l}=t.evalIter(e),c=n instanceof dt?e.lookupDynamicLocated(n.name)?.path??null:null,f=[],p=e.it,g=(y,E,S,M)=>{const x=c===null?null:Uu(c,y),C=x===null?t.itemStep(y):null,D=x!==null?e.renderPath.pushFrame(x):C!==null?e.renderPath.pushItem(C):e.renderPath,k=l?[r,p,E]:[r,E],Q=`${e.viewsId??""}${s}${y}${D.addressKey}`,ce=this.cache.get(k,Q);if(ce)this.pushEachEntry(f,s,S,y,ce);else{const Ge=this.renderView(r,e.enter(E,M,!1,D,x!==null));Ge!=null&&this.pushEachEntry(f,s,S,y,Ge),this.cache.set(k,Q,Ge)}};return Uo({seq:i,it:p,filter:o,loopWith:a,enricher:l,ctx:Bo(e,o)},g),f}renderView(e,t){let n=t.binds[1];for(;n!==null;){const r=n[0];if(r.isFrame){if(t.it!==r.it)break;return console.error("recursion detected",t.it,r.it),new zr("RECURSION AVOIDED")}n=n[1]}return e.render(t,this)}_renderMetadata(e){return new zr(`\xA7${JSON.stringify(e)}\xA7`)}renderScopeMeta(e,t){return new pe([this._renderMetadata({$:"Scope",nid:e}),t])}},nm=String.raw,rm=String.raw,sm=(e,t)=>new rf(e,t);function im(e){const t=typeof e=="string"?document.querySelector(e):e,n=new ma,r=new tm(n);return new Kp(t,n,r,ns)}async function om(e,t,n="margaui-css"){const r=performance.now(),s=await ic(e,t),i=performance.now();return Ms(n,s),i-r}async function ic(e,t,n=ya){return e.ParseContext=n,e.compile(),await t(Array.from(Mf(e)))}function pn(e,t){if(t==null)return null;const n=e.alter?.[t];if(typeof n!="function")throw new Error(`alter handler '${t}' not found on component '${e.name}'`);return n}function am(e,t,n,r={}){const s=pn(e,r.when)??Ro,i=pn(e,r.loopWith)??$o,o=pn(e,r.enrichWith),a=pn(e,r.scopeEnrich),l=t,c=a?a.call(l)??{}:r.scope??{},f={lookup:g=>c[g],filter:(g,y,E)=>s.call(l,g,y,E)},p=[];return Uo({seq:n,it:l,filter:s,loopWith:i,enricher:o,ctx:f},(g,y,E,S)=>p.push(S)),p}function oc(e,t){const r=t.toString().match(/^(?:\w+|function\s*\w*)\s*\(([^)]*)\)/),s=r?r[1].trim():"";return`${e}(${s})`}function lm(e){return e==null?e:e instanceof Map?Object.fromEntries(e):e instanceof Set?[...e]:e}function cm(e){const{fields:t,name:n,methods:r}=e,s=Object.keys(r).map(c=>({name:c,sig:oc(c,r[c])})),i=c=>Object.keys(c??{}).map(f=>({name:f,sig:oc(f,c[f])})),o=i(e.receive),a=i(e.intent),l=[];for(const c in t){const f=t[c];l.push({name:c,type:f.type,default:lm(f.defaultValue),methods:[]})}return{name:n,methods:s,receive:o,intent:a,fields:l}}function um(e,{name:t=null}={}){const n=e.components,r=t===null?n:n.filter(s=>s.name===t);return new $l({items:r.map(s=>cm(s))})}async function hm(e={}){const t=await Kl({expect:De,...e});return Jl(t),t}function ac(e){const t={};for(const r in e.views){const s=e.views[r].rawView,i=new vl;Ve.parse(s,i),i.compile(e.scope),t[r]={name:r,ctx:i,rawView:s}}const n=Object.create(e);return n.views=t,gl(n).reports}function fm(e){const t={error:0,warn:0,hint:0};for(const r of e.comps.byId.values()){const s=ac(r);if(s.length!==0){console.group(r.name);for(const i of s){t[i.level]++;const o=ec(i.suggestion),a=o?` \u2014 ${o}`:"",l=`[${i.level}] ${Zl(i.id,i.info)}${a}`;i.level==="error"?console.error(l):i.level==="warn"?console.warn(l):console.log(l)}console.groupEnd()}}const n=t.error+t.warn+t.hint;return console.log(n===0?"check: no issues":`check: ${t.error} error, ${t.warn} warn, ${t.hint} hint`),t}export{Ma as ALT_HANDLER_NOT_DEFINED,Ca as ALT_HANDLER_NOT_REFERENCED,ll as ASYNC_HANDLER,tl as BAD_VALUE,rl as BINDING_MEMBER_TOO_DEEP,xe as COMPONENT,ps as COMP_FIELD_BAD_SHAPE,un as CONSTANT_CONDITION,$l as ComponentDocs,Op as ComponentList,Ip as ComponentSummary,Ha as DUPLICATE_ATTR_DEFINITION,ka as DYN_ALIAS_NOT_REFERENCED,Da as DYN_VAL_NOT_DEFINED,Bl as Describe,Fl as DescribeResult,fs as EVENT_HANDLER_METHOD_NOT_ALLOWED,Pp as ExampleIndex,hl as FIELD_METHOD_NAME_COLLISION,Ua as FIELD_VAL_IS_METHOD,Va as FIELD_VAL_NOT_DEFINED,ul as GLOBAL_SELECTOR_IN_SCOPED_STYLE,ds as HANDLER_NAME_COLLISION,Ga as IF_NO_BRANCH_SET,He as LOOKUP_BAD_SHAPE,hs as LOOKUP_NO_PROVIDER,Cp as LintComponentResult,bl as LintContext,Mp as LintFinding,vl as LintParseContext,Dp as LintReport,el as MAYBE_ADD_AT_PREFIX,Za as MAYBE_DROP_AT_PREFIX,qa as METHOD_VAL_IS_FIELD,ja as METHOD_VAL_NOT_DEFINED,xp as ModuleInfo,As as ModuleTestReport,Vl as ModuleTests,Ya as ORPHAN_DIRECTIVE,kl as PASS,ol as PLACEHOLDERLESS_TEMPLATE_STRING,La as PROVIDE_NOT_ADDRESSABLE,Ra as PROVIDE_TYPE_BAD_SHAPE,ns as ParseContext,Ba as RECEIVE_HANDLER_NOT_IMPLEMENTED,il as REDUNDANT_TEMPLATE_STRING,$a as RENDER_IT_OUTSIDE_OF_LOOP,Rp as RenderBatch,kp as RenderedExample,Lp as RenderedSection,ko as SEQ_INFO,sl as SUGGEST_BINDING_MEMBER,cl as TOP_LEVEL_AT_RULE_IN_SCOPED_STYLE,Is as Test,xs as TestReport,dn as TestResult,Wa as UNKNOWN_COMPONENT_NAME,al as UNKNOWN_COMPONENT_SPEC_KEY,za as UNKNOWN_DIRECTIVE,Fa as UNKNOWN_EVENT_MODIFIER,Ka as UNKNOWN_MACRO_ARG,Ja as UNKNOWN_X_ATTR,Xa as UNKNOWN_X_OP,nl as UNSUPPORTED_EXPR_SYNTAX,Qa as X_OP_IGNORES_CHILDREN,fm as check,gl as checkComponent,am as collectIterBindings,om as compileClassesToStyle,ic as compileClassesToStyleText,wp as component,nm as css,Sl as dispatchPhase,um as docComponents,Bp as drive,De as expect,rm as html,Ms as injectCss,Zl as lintIdToMessage,sm as macro,Hl as makeCollector,Yu as path,El as phaseOps,Jl as reportTestReportToConsole,_l as resolveArgs,Rl as rootDispatcher,Kl as runTests,ac as shadowCheckComponent,ec as suggestionToMessage,hm as test,im as tutuca};
//# sourceMappingURL=/sm/e72a83ec0220effca379de320aeb13be785e2ffa0e35dcbafc67b37afd6ebd25.map