(()=>{var p3=Object.create;var X1=Object.defineProperty;var d3=Object.getOwnPropertyDescriptor;var g3=Object.getOwnPropertyNames;var m3=Object.getPrototypeOf,v3=Object.prototype.hasOwnProperty;var ba=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var be=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var A3=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of g3(t))!v3.call(e,s)&&s!==r&&X1(e,s,{get:()=>t[s],enumerable:!(n=d3(t,s))||n.enumerable});return e};var Un=(e,t,r)=>(r=e!=null?p3(m3(e)):{},A3(t||!e||!e.__esModule?X1(r,"default",{value:e,enumerable:!0}):r,e));var Q1=be(Bl=>{"use strict";Bl.byteLength=E3;Bl.toByteArray=S3;Bl.fromByteArray=F3;var fi=[],Hn=[],w3=typeof Uint8Array<"u"?Uint8Array:Array,lp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ca=0,J1=lp.length;Ca0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function E3(e){var t=Z1(e),r=t[0],n=t[1];return(r+n)*3/4-n}function y3(e,t,r){return(t+r)*3/4-r}function S3(e){var t,r=Z1(e),n=r[0],s=r[1],a=new w3(y3(e,n,s)),i=0,c=s>0?n-4:n,l;for(l=0;l>16&255,a[i++]=t>>8&255,a[i++]=t&255;return s===2&&(t=Hn[e.charCodeAt(l)]<<2|Hn[e.charCodeAt(l+1)]>>4,a[i++]=t&255),s===1&&(t=Hn[e.charCodeAt(l)]<<10|Hn[e.charCodeAt(l+1)]<<4|Hn[e.charCodeAt(l+2)]>>2,a[i++]=t>>8&255,a[i++]=t&255),a}function b3(e){return fi[e>>18&63]+fi[e>>12&63]+fi[e>>6&63]+fi[e&63]}function C3(e,t,r){for(var n,s=[],a=t;ac?c:i+a));return n===1?(t=e[r-1],s.push(fi[t>>2]+fi[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],s.push(fi[t>>10]+fi[t>>4&63]+fi[t<<2&63]+"=")),s.join("")}});var eg=be(fp=>{fp.read=function(e,t,r,n,s){var a,i,c=s*8-n-1,l=(1<>1,v=-7,E=r?s-1:0,p=r?-1:1,f=e[t+E];for(E+=p,a=f&(1<<-v)-1,f>>=-v,v+=c;v>0;a=a*256+e[t+E],E+=p,v-=8);for(i=a&(1<<-v)-1,a>>=-v,v+=n;v>0;i=i*256+e[t+E],E+=p,v-=8);if(a===0)a=1-h;else{if(a===l)return i?NaN:(f?-1:1)*(1/0);i=i+Math.pow(2,n),a=a-h}return(f?-1:1)*i*Math.pow(2,a-n)};fp.write=function(e,t,r,n,s,a){var i,c,l,h=a*8-s-1,v=(1<>1,p=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-1,w=n?1:-1,m=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,i=v):(i=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-i))<1&&(i--,l*=2),i+E>=1?t+=p/l:t+=p*Math.pow(2,1-E),t*l>=2&&(i++,l/=2),i+E>=v?(c=0,i=v):i+E>=1?(c=(t*l-1)*Math.pow(2,s),i=i+E):(c=t*Math.pow(2,E-1)*Math.pow(2,s),i=0));s>=8;e[r+f]=c&255,f+=w,c/=256,s-=8);for(i=i<0;e[r+f]=i&255,f+=w,i/=256,h-=8);e[r+f-w]|=m*128}});var Rl=be(Ru=>{"use strict";var hp=Q1(),Pu=eg(),tg=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Ru.Buffer=le;Ru.SlowBuffer=$3;Ru.INSPECT_MAX_BYTES=50;var Pl=2147483647;Ru.kMaxLength=Pl;le.TYPED_ARRAY_SUPPORT=_3();!le.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function _3(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(le.prototype,"parent",{enumerable:!0,get:function(){if(le.isBuffer(this))return this.buffer}});Object.defineProperty(le.prototype,"offset",{enumerable:!0,get:function(){if(le.isBuffer(this))return this.byteOffset}});function Ji(e){if(e>Pl)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,le.prototype),t}function le(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return mp(e)}return sg(e,t,r)}le.poolSize=8192;function sg(e,t,r){if(typeof e=="string")return D3(e,t);if(ArrayBuffer.isView(e))return B3(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(hi(e,ArrayBuffer)||e&&hi(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(hi(e,SharedArrayBuffer)||e&&hi(e.buffer,SharedArrayBuffer)))return dp(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return le.from(n,t,r);let s=P3(e);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return le.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}le.from=function(e,t,r){return sg(e,t,r)};Object.setPrototypeOf(le.prototype,Uint8Array.prototype);Object.setPrototypeOf(le,Uint8Array);function ag(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function I3(e,t,r){return ag(e),e<=0?Ji(e):t!==void 0?typeof r=="string"?Ji(e).fill(t,r):Ji(e).fill(t):Ji(e)}le.alloc=function(e,t,r){return I3(e,t,r)};function mp(e){return ag(e),Ji(e<0?0:vp(e)|0)}le.allocUnsafe=function(e){return mp(e)};le.allocUnsafeSlow=function(e){return mp(e)};function D3(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!le.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=ug(e,t)|0,n=Ji(r),s=n.write(e,t);return s!==r&&(n=n.slice(0,s)),n}function pp(e){let t=e.length<0?0:vp(e.length)|0,r=Ji(t);for(let n=0;n=Pl)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Pl.toString(16)+" bytes");return e|0}function $3(e){return+e!=e&&(e=0),le.alloc(+e)}le.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==le.prototype};le.compare=function(t,r){if(hi(t,Uint8Array)&&(t=le.from(t,t.offset,t.byteLength)),hi(r,Uint8Array)&&(r=le.from(r,r.offset,r.byteLength)),!le.isBuffer(t)||!le.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,s=r.length;for(let a=0,i=Math.min(n,s);as.length?(le.isBuffer(i)||(i=le.from(i)),i.copy(s,a)):Uint8Array.prototype.set.call(s,i,a);else if(le.isBuffer(i))i.copy(s,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=i.length}return s};function ug(e,t){if(le.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||hi(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let s=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return gp(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return mg(e).length;default:if(s)return n?-1:gp(e).length;t=(""+t).toLowerCase(),s=!0}}le.byteLength=ug;function R3(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return M3(this,t,r);case"utf8":case"utf-8":return cg(this,t,r);case"ascii":return H3(this,t,r);case"latin1":case"binary":return j3(this,t,r);case"base64":return L3(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q3(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}le.prototype._isBuffer=!0;function Fa(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}le.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;rr&&(t+=" ... "),""};tg&&(le.prototype[tg]=le.prototype.inspect);le.prototype.compare=function(t,r,n,s,a){if(hi(t,Uint8Array)&&(t=le.from(t,t.offset,t.byteLength)),!le.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),s===void 0&&(s=0),a===void 0&&(a=this.length),r<0||n>t.length||s<0||a>this.length)throw new RangeError("out of range index");if(s>=a&&r>=n)return 0;if(s>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,s>>>=0,a>>>=0,this===t)return 0;let i=a-s,c=n-r,l=Math.min(i,c),h=this.slice(s,a),v=t.slice(r,n);for(let E=0;E2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,wp(r)&&(r=s?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(s)return-1;r=e.length-1}else if(r<0)if(s)r=0;else return-1;if(typeof t=="string"&&(t=le.from(t,n)),le.isBuffer(t))return t.length===0?-1:rg(e,t,r,n,s);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):rg(e,[t],r,n,s);throw new TypeError("val must be string, number or Buffer")}function rg(e,t,r,n,s){let a=1,i=e.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,i/=2,c/=2,r/=2}function l(v,E){return a===1?v[E]:v.readUInt16BE(E*a)}let h;if(s){let v=-1;for(h=r;hi&&(r=i-c),h=r;h>=0;h--){let v=!0;for(let E=0;Es&&(n=s)):n=s;let a=t.length;n>a/2&&(n=a/2);let i;for(i=0;i>>0,isFinite(n)?(n=n>>>0,s===void 0&&(s="utf8")):(s=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-r;if((n===void 0||n>a)&&(n=a),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");let i=!1;for(;;)switch(s){case"hex":return T3(this,t,r,n);case"utf8":case"utf-8":return x3(this,t,r,n);case"ascii":case"latin1":case"binary":return O3(this,t,r,n);case"base64":return k3(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N3(this,t,r,n);default:if(i)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),i=!0}};le.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function L3(e,t,r){return t===0&&r===e.length?hp.fromByteArray(e):hp.fromByteArray(e.slice(t,r))}function cg(e,t,r){r=Math.min(e.length,r);let n=[],s=t;for(;s239?4:a>223?3:a>191?2:1;if(s+c<=r){let l,h,v,E;switch(c){case 1:a<128&&(i=a);break;case 2:l=e[s+1],(l&192)===128&&(E=(a&31)<<6|l&63,E>127&&(i=E));break;case 3:l=e[s+1],h=e[s+2],(l&192)===128&&(h&192)===128&&(E=(a&15)<<12|(l&63)<<6|h&63,E>2047&&(E<55296||E>57343)&&(i=E));break;case 4:l=e[s+1],h=e[s+2],v=e[s+3],(l&192)===128&&(h&192)===128&&(v&192)===128&&(E=(a&15)<<18|(l&63)<<12|(h&63)<<6|v&63,E>65535&&E<1114112&&(i=E))}}i===null?(i=65533,c=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),s+=c}return U3(n)}var ng=4096;function U3(e){let t=e.length;if(t<=ng)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn)&&(r=n);let s="";for(let a=t;an&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}le.prototype.readUintLE=le.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||cr(t,r,this.length);let s=this[t],a=1,i=0;for(;++i>>0,r=r>>>0,n||cr(t,r,this.length);let s=this[t+--r],a=1;for(;r>0&&(a*=256);)s+=this[t+--r]*a;return s};le.prototype.readUint8=le.prototype.readUInt8=function(t,r){return t=t>>>0,r||cr(t,1,this.length),this[t]};le.prototype.readUint16LE=le.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||cr(t,2,this.length),this[t]|this[t+1]<<8};le.prototype.readUint16BE=le.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||cr(t,2,this.length),this[t]<<8|this[t+1]};le.prototype.readUint32LE=le.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||cr(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};le.prototype.readUint32BE=le.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||cr(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};le.prototype.readBigUInt64LE=ks(function(t){t=t>>>0,$u(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&rc(t,this.length-8);let s=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,a=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(s)+(BigInt(a)<>>0,$u(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&rc(t,this.length-8);let s=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],a=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(s)<>>0,r=r>>>0,n||cr(t,r,this.length);let s=this[t],a=1,i=0;for(;++i=a&&(s-=Math.pow(2,8*r)),s};le.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||cr(t,r,this.length);let s=r,a=1,i=this[t+--s];for(;s>0&&(a*=256);)i+=this[t+--s]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*r)),i};le.prototype.readInt8=function(t,r){return t=t>>>0,r||cr(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};le.prototype.readInt16LE=function(t,r){t=t>>>0,r||cr(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};le.prototype.readInt16BE=function(t,r){t=t>>>0,r||cr(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};le.prototype.readInt32LE=function(t,r){return t=t>>>0,r||cr(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};le.prototype.readInt32BE=function(t,r){return t=t>>>0,r||cr(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};le.prototype.readBigInt64LE=ks(function(t){t=t>>>0,$u(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&rc(t,this.length-8);let s=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(s)<>>0,$u(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&rc(t,this.length-8);let s=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(s)<>>0,r||cr(t,4,this.length),Pu.read(this,t,!0,23,4)};le.prototype.readFloatBE=function(t,r){return t=t>>>0,r||cr(t,4,this.length),Pu.read(this,t,!1,23,4)};le.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||cr(t,8,this.length),Pu.read(this,t,!0,52,8)};le.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||cr(t,8,this.length),Pu.read(this,t,!1,52,8)};function nn(e,t,r,n,s,a){if(!le.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||te.length)throw new RangeError("Index out of range")}le.prototype.writeUintLE=le.prototype.writeUIntLE=function(t,r,n,s){if(t=+t,r=r>>>0,n=n>>>0,!s){let c=Math.pow(2,8*n)-1;nn(this,t,r,n,c,0)}let a=1,i=0;for(this[r]=t&255;++i>>0,n=n>>>0,!s){let c=Math.pow(2,8*n)-1;nn(this,t,r,n,c,0)}let a=n-1,i=1;for(this[r+a]=t&255;--a>=0&&(i*=256);)this[r+a]=t/i&255;return r+n};le.prototype.writeUint8=le.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,1,255,0),this[r]=t&255,r+1};le.prototype.writeUint16LE=le.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};le.prototype.writeUint16BE=le.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};le.prototype.writeUint32LE=le.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};le.prototype.writeUint32BE=le.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function lg(e,t,r,n,s){gg(t,n,s,e,r,7);let a=Number(t&BigInt(4294967295));e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a;let i=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=i,i=i>>8,e[r++]=i,i=i>>8,e[r++]=i,i=i>>8,e[r++]=i,r}function fg(e,t,r,n,s){gg(t,n,s,e,r,7);let a=Number(t&BigInt(4294967295));e[r+7]=a,a=a>>8,e[r+6]=a,a=a>>8,e[r+5]=a,a=a>>8,e[r+4]=a;let i=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=i,i=i>>8,e[r+2]=i,i=i>>8,e[r+1]=i,i=i>>8,e[r]=i,r+8}le.prototype.writeBigUInt64LE=ks(function(t,r=0){return lg(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});le.prototype.writeBigUInt64BE=ks(function(t,r=0){return fg(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});le.prototype.writeIntLE=function(t,r,n,s){if(t=+t,r=r>>>0,!s){let l=Math.pow(2,8*n-1);nn(this,t,r,n,l-1,-l)}let a=0,i=1,c=0;for(this[r]=t&255;++a>0)-c&255;return r+n};le.prototype.writeIntBE=function(t,r,n,s){if(t=+t,r=r>>>0,!s){let l=Math.pow(2,8*n-1);nn(this,t,r,n,l-1,-l)}let a=n-1,i=1,c=0;for(this[r+a]=t&255;--a>=0&&(i*=256);)t<0&&c===0&&this[r+a+1]!==0&&(c=1),this[r+a]=(t/i>>0)-c&255;return r+n};le.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};le.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};le.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};le.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};le.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||nn(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};le.prototype.writeBigInt64LE=ks(function(t,r=0){return lg(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});le.prototype.writeBigInt64BE=ks(function(t,r=0){return fg(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function hg(e,t,r,n,s,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function pg(e,t,r,n,s){return t=+t,r=r>>>0,s||hg(e,t,r,4,34028234663852886e22,-34028234663852886e22),Pu.write(e,t,r,n,23,4),r+4}le.prototype.writeFloatLE=function(t,r,n){return pg(this,t,r,!0,n)};le.prototype.writeFloatBE=function(t,r,n){return pg(this,t,r,!1,n)};function dg(e,t,r,n,s){return t=+t,r=r>>>0,s||hg(e,t,r,8,17976931348623157e292,-17976931348623157e292),Pu.write(e,t,r,n,52,8),r+8}le.prototype.writeDoubleLE=function(t,r,n){return dg(this,t,r,!0,n)};le.prototype.writeDoubleBE=function(t,r,n){return dg(this,t,r,!1,n)};le.prototype.copy=function(t,r,n,s){if(!le.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!s&&s!==0&&(s=this.length),r>=t.length&&(r=t.length),r||(r=0),s>0&&s=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-r>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let a;if(typeof t=="number")for(a=r;a2**32?s=ig(String(r)):typeof r=="bigint"&&(s=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(s=ig(s)),s+="n"),n+=` It must be ${t}. Received ${s}`,n},RangeError);function ig(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function K3(e,t,r){$u(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&rc(t,e.length-(r+1))}function gg(e,t,r,n,s,a){if(e>r||e3?t===0||t===BigInt(0)?c=`>= 0${i} and < 2${i} ** ${(a+1)*8}${i}`:c=`>= -(2${i} ** ${(a+1)*8-1}${i}) and < 2 ** ${(a+1)*8-1}${i}`:c=`>= ${t}${i} and <= ${r}${i}`,new Bu.ERR_OUT_OF_RANGE("value",c,e)}K3(n,s,a)}function $u(e,t){if(typeof e!="number")throw new Bu.ERR_INVALID_ARG_TYPE(t,"number",e)}function rc(e,t,r){throw Math.floor(e)!==e?($u(e,r),new Bu.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new Bu.ERR_BUFFER_OUT_OF_BOUNDS:new Bu.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var V3=/[^+/0-9A-Za-z-_]/g;function G3(e){if(e=e.split("=")[0],e=e.trim().replace(V3,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function gp(e,t){t=t||1/0;let r,n=e.length,s=null,a=[];for(let i=0;i55295&&r<57344){if(!s){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(i+1===n){(t-=3)>-1&&a.push(239,191,189);continue}s=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),s=r;continue}r=(s-55296<<10|r-56320)+65536}else s&&(t-=3)>-1&&a.push(239,191,189);if(s=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function z3(e){let t=[];for(let r=0;r>8,s=r%256,a.push(s),a.push(n);return a}function mg(e){return hp.toByteArray(G3(e))}function $l(e,t,r,n){let s;for(s=0;s=t.length||s>=e.length);++s)t[s+r]=e[s];return s}function hi(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function wp(e){return e!==e}var W3=function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let s=0;s<16;++s)t[n+s]=e[r]+e[s]}return t}();function ks(e){return typeof BigInt>"u"?X3:e}function X3(){throw new Error("BigInt not supported")}});var Hg=be(Ee=>{var nc={};nc.userAgent=!1;var Tu={},J3="11.1.0",Z3="jsrsasign(all) 11.1.0 (2024-02-01) (c) 2010-2023 Kenji Urushima | kjur.github.io/jsrsasign/license";var Se=Se||function(e,t){var r={},n=r.lib={},s=n.Base=function(){function f(){}return{extend:function(w){f.prototype=this;var m=new f;return w&&m.mixIn(w),m.hasOwnProperty("init")||(m.init=function(){m.$super.init.apply(this,arguments)}),m.init.prototype=m,m.$super=this,m},create:function(){var w=this.extend();return w.init.apply(w,arguments),w},init:function(){},mixIn:function(w){for(var m in w)w.hasOwnProperty(m)&&(this[m]=w[m]);w.hasOwnProperty("toString")&&(this.toString=w.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=n.WordArray=s.extend({init:function(f,w){f=this.words=f||[],w!=t?this.sigBytes=w:this.sigBytes=f.length*4},toString:function(f){return(f||c).stringify(this)},concat:function(f){var w=this.words,m=f.words,y=this.sigBytes,A=f.sigBytes;if(this.clamp(),y%4)for(var b=0;b>>2]>>>24-b%4*8&255;w[y+b>>>2]|=_<<24-(y+b)%4*8}else for(var b=0;b>>2]=m[b>>>2];return this.sigBytes+=A,this},clamp:function(){var f=this.words,w=this.sigBytes;f[w>>>2]&=4294967295<<32-w%4*8,f.length=e.ceil(w/4)},clone:function(){var f=s.clone.call(this);return f.words=this.words.slice(0),f},random:function(f){for(var w=[],m=0;m>>2]>>>24-A%4*8&255;y.push((b>>>4).toString(16)),y.push((b&15).toString(16))}return y.join("")},parse:function(f){for(var w=f.length,m=[],y=0;y>>3]|=parseInt(f.substr(y,2),16)<<24-y%8*4;return new a.init(m,w/2)}},l=i.Latin1={stringify:function(f){for(var w=f.words,m=f.sigBytes,y=[],A=0;A>>2]>>>24-A%4*8&255;y.push(String.fromCharCode(b))}return y.join("")},parse:function(f){for(var w=f.length,m=[],y=0;y>>2]|=(f.charCodeAt(y)&255)<<24-y%4*8;return new a.init(m,w)}},h=i.Utf8={stringify:function(f){try{return decodeURIComponent(escape(l.stringify(f)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(f){return l.parse(unescape(encodeURIComponent(f)))}},v=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(f){typeof f=="string"&&(f=h.parse(f)),this._data.concat(f),this._nDataBytes+=f.sigBytes},_process:function(f){var w=this._data,m=w.words,y=w.sigBytes,A=this.blockSize,b=A*4,_=y/b;f?_=e.ceil(_):_=e.max((_|0)-this._minBufferSize,0);var I=_*A,B=e.min(I*4,y);if(I){for(var j=0;j>>2]&255}},t.BlockCipher=c.extend({cfg:c.cfg.extend({mode:E,padding:h}),reset:function(){c.reset.call(this);var y=this.cfg,m=y.iv,y=y.mode;if(this._xformMode==this._ENC_XFORM_MODE)var A=y.createEncryptor;else A=y.createDecryptor,this._minBufferSize=1;this._mode=A.call(y,this,m&&m.words)},_doProcessBlock:function(m,y){this._mode.processBlock(m,y)},_doFinalize:function(){var m=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){m.pad(this._data,this.blockSize);var y=this._process(!0)}else y=this._process(!0),m.unpad(y);return y},blockSize:4});var v=t.CipherParams=r.extend({init:function(m){this.mixIn(m)},toString:function(m){return(m||this.formatter).stringify(this)}}),E=(f.format={}).OpenSSL={stringify:function(m){var y=m.ciphertext;return m=m.salt,(m?n.create([1398893684,1701076831]).concat(m).concat(y):y).toString(a)},parse:function(m){m=a.parse(m);var y=m.words;if(y[0]==1398893684&&y[1]==1701076831){var A=n.create(y.slice(2,4));y.splice(0,4),m.sigBytes-=16}return v.create({ciphertext:m,salt:A})}},p=t.SerializableCipher=r.extend({cfg:r.extend({format:E}),encrypt:function(m,y,A,b){b=this.cfg.extend(b);var _=m.createEncryptor(A,b);return y=_.finalize(y),_=_.cfg,v.create({ciphertext:y,key:A,iv:_.iv,algorithm:m,mode:_.mode,padding:_.padding,blockSize:m.blockSize,formatter:b.format})},decrypt:function(m,y,A,b){return b=this.cfg.extend(b),y=this._parse(y,b.format),m.createDecryptor(A,b).finalize(y.ciphertext)},_parse:function(m,y){return typeof m=="string"?y.parse(m,this):m}}),f=(f.kdf={}).OpenSSL={execute:function(m,y,A,b){return b||(b=n.random(8)),m=i.create({keySize:y+A}).compute(m,b),A=n.create(m.words.slice(y),4*A),m.sigBytes=4*y,v.create({key:m,iv:A,salt:b})}},w=t.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:f}),encrypt:function(m,y,A,b){return b=this.cfg.extend(b),A=b.kdf.execute(A,m.keySize,m.ivSize),b.iv=A.iv,m=p.encrypt.call(this,m,y,A.key,b),m.mixIn(A),m},decrypt:function(m,y,A,b){return b=this.cfg.extend(b),y=this._parse(y,b.format),A=b.kdf.execute(A,m.keySize,m.ivSize,y.salt),b.iv=A.iv,p.decrypt.call(this,m,y,A.key,b)}})}();(function(){for(var e=Se,t=e.lib.BlockCipher,j=e.algo,r=[],n=[],s=[],a=[],i=[],c=[],l=[],h=[],v=[],E=[],p=[],f=0;256>f;f++)p[f]=128>f?f<<1:f<<1^283;for(var w=0,m=0,f=0;256>f;f++){var y=m^m<<1^m<<2^m<<3^m<<4,y=y>>>8^y&255^99;r[w]=y,n[y]=w;var A=p[w],b=p[A],_=p[b],I=257*p[y]^16843008*y;s[w]=I<<24|I>>>8,a[w]=I<<16|I>>>16,i[w]=I<<8|I>>>24,c[w]=I,I=16843009*_^65537*b^257*A^16843008*w,l[y]=I<<24|I>>>8,h[y]=I<<16|I>>>16,v[y]=I<<8|I>>>24,E[y]=I,w?(w=A^p[p[p[_^A]]],m^=p[p[m]]):w=m=1}var B=[0,1,2,4,8,16,32,64,128,27,54],j=j.AES=t.extend({_doReset:function(){for(var P=this._key,V=P.words,F=P.sigBytes/4,P=4*((this._nRounds=F+6)+1),k=this._keySchedule=[],L=0;L>>24]<<24|r[M>>>16&255]<<16|r[M>>>8&255]<<8|r[M&255]):(M=M<<8|M>>>24,M=r[M>>>24]<<24|r[M>>>16&255]<<16|r[M>>>8&255]<<8|r[M&255],M^=B[L/F|0]<<24),k[L]=k[L-F]^M}for(V=this._invKeySchedule=[],F=0;FF||4>=L?M:l[r[M>>>24]]^h[r[M>>>16&255]]^v[r[M>>>8&255]]^E[r[M&255]]},encryptBlock:function(V,F){this._doCryptBlock(V,F,this._keySchedule,s,a,i,c,r)},decryptBlock:function(V,F){var P=V[F+1];V[F+1]=V[F+3],V[F+3]=P,this._doCryptBlock(V,F,this._invKeySchedule,l,h,v,E,n),P=V[F+1],V[F+1]=V[F+3],V[F+3]=P},_doCryptBlock:function(V,F,P,k,L,M,X,K){for(var q=this._nRounds,oe=V[F]^P[0],Fe=V[F+1]^P[1],Oe=V[F+2]^P[2],He=V[F+3]^P[3],Y=4,re=1;re>>24]^L[Fe>>>16&255]^M[Oe>>>8&255]^X[He&255]^P[Y++],we=k[Fe>>>24]^L[Oe>>>16&255]^M[He>>>8&255]^X[oe&255]^P[Y++],Be=k[Oe>>>24]^L[He>>>16&255]^M[oe>>>8&255]^X[Fe&255]^P[Y++],He=k[He>>>24]^L[oe>>>16&255]^M[Fe>>>8&255]^X[Oe&255]^P[Y++],oe=ye,Fe=we,Oe=Be;ye=(K[oe>>>24]<<24|K[Fe>>>16&255]<<16|K[Oe>>>8&255]<<8|K[He&255])^P[Y++],we=(K[Fe>>>24]<<24|K[Oe>>>16&255]<<16|K[He>>>8&255]<<8|K[oe&255])^P[Y++],Be=(K[Oe>>>24]<<24|K[He>>>16&255]<<16|K[oe>>>8&255]<<8|K[Fe&255])^P[Y++],He=(K[He>>>24]<<24|K[oe>>>16&255]<<16|K[Fe>>>8&255]<<8|K[Oe&255])^P[Y++],V[F]=ye,V[F+1]=we,V[F+2]=Be,V[F+3]=He},keySize:8});e.AES=t._createHelper(j)})();(function(){function e(p,f){var w=(this._lBlock>>>p^this._rBlock)&f;this._rBlock^=w,this._lBlock^=w<>>p^this._lBlock)&f;this._lBlock^=w,this._rBlock^=w<w;w++){var m=i[w]-1;f[w]=p[m>>>5]>>>31-m%32&1}for(p=this._subKeys=[],m=0;16>m;m++){for(var y=p[m]=[],A=l[m],w=0;24>w;w++)y[w/6|0]|=f[(c[w]-1+A)%28]<<31-w%6,y[4+(w/6|0)]|=f[28+(c[w+24]-1+A)%28]<<31-w%6;for(y[0]=y[0]<<1|y[0]>>>31,w=1;7>w;w++)y[w]>>>=4*(w-1)+3;y[7]=y[7]<<5|y[7]>>>27}for(f=this._invSubKeys=[],w=0;16>w;w++)f[w]=p[15-w]},encryptBlock:function(p,f){this._doCryptBlock(p,f,this._subKeys)},decryptBlock:function(p,f){this._doCryptBlock(p,f,this._invSubKeys)},_doCryptBlock:function(p,f,w){this._lBlock=p[f],this._rBlock=p[f+1],e.call(this,4,252645135),e.call(this,16,65535),t.call(this,2,858993459),t.call(this,8,16711935),e.call(this,1,1431655765);for(var m=0;16>m;m++){for(var y=w[m],A=this._lBlock,b=this._rBlock,_=0,I=0;8>I;I++)_|=h[I][((b^y[I])&v[I])>>>0];this._lBlock=b,this._rBlock=A^_}w=this._lBlock,this._lBlock=this._rBlock,this._rBlock=w,e.call(this,1,1431655765),t.call(this,8,16711935),t.call(this,2,858993459),e.call(this,16,65535),e.call(this,4,252645135),p[f]=this._lBlock,p[f+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=s._createHelper(E),a=a.TripleDES=s.extend({_doReset:function(){var p=this._key.words;this._des1=E.createEncryptor(n.create(p.slice(0,2))),this._des2=E.createEncryptor(n.create(p.slice(2,4))),this._des3=E.createEncryptor(n.create(p.slice(4,6)))},encryptBlock:function(p,f){this._des1.encryptBlock(p,f),this._des2.decryptBlock(p,f),this._des3.encryptBlock(p,f)},decryptBlock:function(p,f){this._des3.decryptBlock(p,f),this._des2.encryptBlock(p,f),this._des1.decryptBlock(p,f)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=s._createHelper(a)})();(function(){var e=Se,t=e.lib.WordArray;e.enc.Base64={stringify:function(r){var n=r.words,s=r.sigBytes,a=this._map;r.clamp(),r=[];for(var i=0;i>>2]>>>24-8*(i%4)&255)<<16|(n[i+1>>>2]>>>24-8*((i+1)%4)&255)<<8|n[i+2>>>2]>>>24-8*((i+2)%4)&255,l=0;4>l&&i+.75*l>>6*(3-l)&63));if(n=a.charAt(64))for(;r.length%4;)r.push(n);return r.join("")},parse:function(r){var n=r.length,s=this._map,a=s.charAt(64);a&&(a=r.indexOf(a),a!=-1&&(n=a));for(var a=[],i=0,c=0;c>>6-2*(c%4);a[i>>>2]|=(l|h)<<24-8*(i%4),i++}return t.create(a,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();(function(e){function t(E,p,f,w,m,y,A){return E=E+(p&f|~p&w)+m+A,(E<>>32-y)+p}function r(E,p,f,w,m,y,A){return E=E+(p&w|f&~w)+m+A,(E<>>32-y)+p}function n(E,p,f,w,m,y,A){return E=E+(p^f^w)+m+A,(E<>>32-y)+p}function s(E,p,f,w,m,y,A){return E=E+(f^(p|~w))+m+A,(E<>>32-y)+p}for(var a=Se,l=a.lib,i=l.WordArray,c=l.Hasher,l=a.algo,h=[],v=0;64>v;v++)h[v]=4294967296*e.abs(e.sin(v+1))|0;l=l.MD5=c.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(E,p){for(var f=0;16>f;f++){var w=p+f,m=E[w];E[w]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360}var f=this._hash.words,w=E[p+0],m=E[p+1],y=E[p+2],A=E[p+3],b=E[p+4],_=E[p+5],I=E[p+6],B=E[p+7],j=E[p+8],V=E[p+9],F=E[p+10],P=E[p+11],k=E[p+12],L=E[p+13],M=E[p+14],X=E[p+15],K=f[0],re=f[1],Y=f[2],q=f[3],K=t(K,re,Y,q,w,7,h[0]),q=t(q,K,re,Y,m,12,h[1]),Y=t(Y,q,K,re,y,17,h[2]),re=t(re,Y,q,K,A,22,h[3]),K=t(K,re,Y,q,b,7,h[4]),q=t(q,K,re,Y,_,12,h[5]),Y=t(Y,q,K,re,I,17,h[6]),re=t(re,Y,q,K,B,22,h[7]),K=t(K,re,Y,q,j,7,h[8]),q=t(q,K,re,Y,V,12,h[9]),Y=t(Y,q,K,re,F,17,h[10]),re=t(re,Y,q,K,P,22,h[11]),K=t(K,re,Y,q,k,7,h[12]),q=t(q,K,re,Y,L,12,h[13]),Y=t(Y,q,K,re,M,17,h[14]),re=t(re,Y,q,K,X,22,h[15]),K=r(K,re,Y,q,m,5,h[16]),q=r(q,K,re,Y,I,9,h[17]),Y=r(Y,q,K,re,P,14,h[18]),re=r(re,Y,q,K,w,20,h[19]),K=r(K,re,Y,q,_,5,h[20]),q=r(q,K,re,Y,F,9,h[21]),Y=r(Y,q,K,re,X,14,h[22]),re=r(re,Y,q,K,b,20,h[23]),K=r(K,re,Y,q,V,5,h[24]),q=r(q,K,re,Y,M,9,h[25]),Y=r(Y,q,K,re,A,14,h[26]),re=r(re,Y,q,K,j,20,h[27]),K=r(K,re,Y,q,L,5,h[28]),q=r(q,K,re,Y,y,9,h[29]),Y=r(Y,q,K,re,B,14,h[30]),re=r(re,Y,q,K,k,20,h[31]),K=n(K,re,Y,q,_,4,h[32]),q=n(q,K,re,Y,j,11,h[33]),Y=n(Y,q,K,re,P,16,h[34]),re=n(re,Y,q,K,M,23,h[35]),K=n(K,re,Y,q,m,4,h[36]),q=n(q,K,re,Y,b,11,h[37]),Y=n(Y,q,K,re,B,16,h[38]),re=n(re,Y,q,K,F,23,h[39]),K=n(K,re,Y,q,L,4,h[40]),q=n(q,K,re,Y,w,11,h[41]),Y=n(Y,q,K,re,A,16,h[42]),re=n(re,Y,q,K,I,23,h[43]),K=n(K,re,Y,q,V,4,h[44]),q=n(q,K,re,Y,k,11,h[45]),Y=n(Y,q,K,re,X,16,h[46]),re=n(re,Y,q,K,y,23,h[47]),K=s(K,re,Y,q,w,6,h[48]),q=s(q,K,re,Y,B,10,h[49]),Y=s(Y,q,K,re,M,15,h[50]),re=s(re,Y,q,K,_,21,h[51]),K=s(K,re,Y,q,k,6,h[52]),q=s(q,K,re,Y,A,10,h[53]),Y=s(Y,q,K,re,F,15,h[54]),re=s(re,Y,q,K,m,21,h[55]),K=s(K,re,Y,q,j,6,h[56]),q=s(q,K,re,Y,X,10,h[57]),Y=s(Y,q,K,re,I,15,h[58]),re=s(re,Y,q,K,L,21,h[59]),K=s(K,re,Y,q,b,6,h[60]),q=s(q,K,re,Y,P,10,h[61]),Y=s(Y,q,K,re,y,15,h[62]),re=s(re,Y,q,K,V,21,h[63]);f[0]=f[0]+K|0,f[1]=f[1]+re|0,f[2]=f[2]+Y|0,f[3]=f[3]+q|0},_doFinalize:function(){var E=this._data,p=E.words,f=8*this._nDataBytes,w=8*E.sigBytes;p[w>>>5]|=128<<24-w%32;var m=e.floor(f/4294967296);for(p[(w+64>>>9<<4)+15]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,p[(w+64>>>9<<4)+14]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360,E.sigBytes=4*(p.length+1),this._process(),E=this._hash,p=E.words,f=0;4>f;f++)w=p[f],p[f]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360;return E},clone:function(){var E=c.clone.call(this);return E._hash=this._hash.clone(),E}}),a.MD5=c._createHelper(l),a.HmacMD5=c._createHmacHelper(l)})(Math);(function(){var e=Se,s=e.lib,t=s.WordArray,r=s.Hasher,n=[],s=e.algo.SHA1=r.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,i){for(var c=this._hash.words,l=c[0],h=c[1],v=c[2],E=c[3],p=c[4],f=0;80>f;f++){if(16>f)n[f]=a[i+f]|0;else{var w=n[f-3]^n[f-8]^n[f-14]^n[f-16];n[f]=w<<1|w>>>31}w=(l<<5|l>>>27)+p+n[f],w=20>f?w+((h&v|~h&E)+1518500249):40>f?w+((h^v^E)+1859775393):60>f?w+((h&v|h&E|v&E)-1894007588):w+((h^v^E)-899497514),p=E,E=v,v=h<<30|h>>>2,h=l,l=w}c[0]=c[0]+l|0,c[1]=c[1]+h|0,c[2]=c[2]+v|0,c[3]=c[3]+E|0,c[4]=c[4]+p|0},_doFinalize:function(){var a=this._data,i=a.words,c=8*this._nDataBytes,l=8*a.sigBytes;return i[l>>>5]|=128<<24-l%32,i[(l+64>>>9<<4)+14]=Math.floor(c/4294967296),i[(l+64>>>9<<4)+15]=c,a.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var a=r.clone.call(this);return a._hash=this._hash.clone(),a}});e.SHA1=r._createHelper(s),e.HmacSHA1=r._createHmacHelper(s)})();(function(e){for(var t=Se,f=t.lib,r=f.WordArray,n=f.Hasher,f=t.algo,s=[],a=[],i=function(m){return 4294967296*(m-(m|0))|0},c=2,l=0;64>l;){var h;e:{h=c;for(var v=e.sqrt(h),E=2;E<=v;E++)if(!(h%E)){h=!1;break e}h=!0}h&&(8>l&&(s[l]=i(e.pow(c,.5))),a[l]=i(e.pow(c,1/3)),l++),c++}var p=[],f=f.SHA256=n.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(w,m){for(var y=this._hash.words,A=y[0],b=y[1],_=y[2],I=y[3],B=y[4],j=y[5],V=y[6],F=y[7],P=0;64>P;P++){if(16>P)p[P]=w[m+P]|0;else{var k=p[P-15],L=p[P-2];p[P]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+p[P-7]+((L<<15|L>>>17)^(L<<13|L>>>19)^L>>>10)+p[P-16]}k=F+((B<<26|B>>>6)^(B<<21|B>>>11)^(B<<7|B>>>25))+(B&j^~B&V)+a[P]+p[P],L=((A<<30|A>>>2)^(A<<19|A>>>13)^(A<<10|A>>>22))+(A&b^A&_^b&_),F=V,V=j,j=B,B=I+k|0,I=_,_=b,b=A,A=k+L|0}y[0]=y[0]+A|0,y[1]=y[1]+b|0,y[2]=y[2]+_|0,y[3]=y[3]+I|0,y[4]=y[4]+B|0,y[5]=y[5]+j|0,y[6]=y[6]+V|0,y[7]=y[7]+F|0},_doFinalize:function(){var w=this._data,m=w.words,y=8*this._nDataBytes,A=8*w.sigBytes;return m[A>>>5]|=128<<24-A%32,m[(A+64>>>9<<4)+14]=e.floor(y/4294967296),m[(A+64>>>9<<4)+15]=y,w.sigBytes=4*m.length,this._process(),this._hash},clone:function(){var w=n.clone.call(this);return w._hash=this._hash.clone(),w}});t.SHA256=n._createHelper(f),t.HmacSHA256=n._createHmacHelper(f)})(Math);(function(){var e=Se,t=e.lib.WordArray,n=e.algo,r=n.SHA256,n=n.SHA224=r.extend({_doReset:function(){this._hash=new t.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var s=r._doFinalize.call(this);return s.sigBytes-=4,s}});e.SHA224=r._createHelper(n),e.HmacSHA224=r._createHmacHelper(n)})();(function(){function e(){return n.create.apply(n,arguments)}for(var t=Se,r=t.lib.Hasher,a=t.x64,n=a.Word,s=a.WordArray,a=t.algo,i=[e(1116352408,3609767458),e(1899447441,602891725),e(3049323471,3964484399),e(3921009573,2173295548),e(961987163,4081628472),e(1508970993,3053834265),e(2453635748,2937671579),e(2870763221,3664609560),e(3624381080,2734883394),e(310598401,1164996542),e(607225278,1323610764),e(1426881987,3590304994),e(1925078388,4068182383),e(2162078206,991336113),e(2614888103,633803317),e(3248222580,3479774868),e(3835390401,2666613458),e(4022224774,944711139),e(264347078,2341262773),e(604807628,2007800933),e(770255983,1495990901),e(1249150122,1856431235),e(1555081692,3175218132),e(1996064986,2198950837),e(2554220882,3999719339),e(2821834349,766784016),e(2952996808,2566594879),e(3210313671,3203337956),e(3336571891,1034457026),e(3584528711,2466948901),e(113926993,3758326383),e(338241895,168717936),e(666307205,1188179964),e(773529912,1546045734),e(1294757372,1522805485),e(1396182291,2643833823),e(1695183700,2343527390),e(1986661051,1014477480),e(2177026350,1206759142),e(2456956037,344077627),e(2730485921,1290863460),e(2820302411,3158454273),e(3259730800,3505952657),e(3345764771,106217008),e(3516065817,3606008344),e(3600352804,1432725776),e(4094571909,1467031594),e(275423344,851169720),e(430227734,3100823752),e(506948616,1363258195),e(659060556,3750685593),e(883997877,3785050280),e(958139571,3318307427),e(1322822218,3812723403),e(1537002063,2003034995),e(1747873779,3602036899),e(1955562222,1575990012),e(2024104815,1125592928),e(2227730452,2716904306),e(2361852424,442776044),e(2428436474,593698344),e(2756734187,3733110249),e(3204031479,2999351573),e(3329325298,3815920427),e(3391569614,3928383900),e(3515267271,566280711),e(3940187606,3454069534),e(4118630271,4000239992),e(116418474,1914138554),e(174292421,2731055270),e(289380356,3203993006),e(460393269,320620315),e(685471733,587496836),e(852142971,1086792851),e(1017036298,365543100),e(1126000580,2618297676),e(1288033470,3409855158),e(1501505948,4234509866),e(1607167915,987167468),e(1816402316,1246189591)],c=[],l=0;80>l;l++)c[l]=e();a=a.SHA512=r.extend({_doReset:function(){this._hash=new s.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(h,v){for(var b=this._hash.words,E=b[0],p=b[1],f=b[2],w=b[3],m=b[4],y=b[5],A=b[6],b=b[7],_=E.high,I=E.low,B=p.high,j=p.low,V=f.high,F=f.low,P=w.high,k=w.low,L=m.high,M=m.low,X=y.high,K=y.low,q=A.high,Y=A.low,re=b.high,ye=b.low,we=_,Be=I,He=B,oe=j,Fe=V,Oe=F,ir=P,Ft=k,ct=L,Mt=M,Bt=X,Qe=K,bt=q,Je=Y,ft=re,qt=ye,ze=0;80>ze;ze++){var Cr=c[ze];if(16>ze)var Ot=Cr.high=h[v+2*ze]|0,Ye=Cr.low=h[v+2*ze+1]|0;else{var Ot=c[ze-15],Ye=Ot.high,Gt=Ot.low,Ot=(Ye>>>1|Gt<<31)^(Ye>>>8|Gt<<24)^Ye>>>7,Gt=(Gt>>>1|Ye<<31)^(Gt>>>8|Ye<<24)^(Gt>>>7|Ye<<25),br=c[ze-2],Ye=br.high,ht=br.low,br=(Ye>>>19|ht<<13)^(Ye<<3|ht>>>29)^Ye>>>6,ht=(ht>>>19|Ye<<13)^(ht<<3|Ye>>>29)^(ht>>>6|Ye<<26),Ye=c[ze-7],Pn=Ye.high,sr=c[ze-16],zt=sr.high,sr=sr.low,Ye=Gt+Ye.low,Ot=Ot+Pn+(Ye>>>0>>0?1:0),Ye=Ye+ht,Ot=Ot+br+(Ye>>>0>>0?1:0),Ye=Ye+sr,Ot=Ot+zt+(Ye>>>0>>0?1:0);Cr.high=Ot,Cr.low=Ye}var Pn=ct&Bt^~ct&bt,sr=Mt&Qe^~Mt&Je,Cr=we&He^we&Fe^He&Fe,gr=Be&oe^Be&Oe^oe&Oe,Gt=(we>>>28|Be<<4)^(we<<30|Be>>>2)^(we<<25|Be>>>7),br=(Be>>>28|we<<4)^(Be<<30|we>>>2)^(Be<<25|we>>>7),ht=i[ze],Js=ht.high,kr=ht.low,ht=qt+((Mt>>>14|ct<<18)^(Mt>>>18|ct<<14)^(Mt<<23|ct>>>9)),zt=ft+((ct>>>14|Mt<<18)^(ct>>>18|Mt<<14)^(ct<<23|Mt>>>9))+(ht>>>0>>0?1:0),ht=ht+sr,zt=zt+Pn+(ht>>>0>>0?1:0),ht=ht+kr,zt=zt+Js+(ht>>>0>>0?1:0),ht=ht+Ye,zt=zt+Ot+(ht>>>0>>0?1:0),Ye=br+gr,Cr=Gt+Cr+(Ye>>>0
>>0?1:0),ft=bt,qt=Je,bt=Bt,Je=Qe,Bt=ct,Qe=Mt,Mt=Ft+ht|0,ct=ir+zt+(Mt>>>0>>0?1:0)|0,ir=Fe,Ft=Oe,Fe=He,Oe=oe,He=we,oe=Be,Be=ht+Ye|0,we=zt+Cr+(Be>>>0>>0?1:0)|0}I=E.low=I+Be,E.high=_+we+(I>>>0>>0?1:0),j=p.low=j+oe,p.high=B+He+(j>>>0>>0?1:0),F=f.low=F+Oe,f.high=V+Fe+(F>>>0>>0?1:0),k=w.low=k+Ft,w.high=P+ir+(k>>>0>>0?1:0),M=m.low=M+Mt,m.high=L+ct+(M>>>0>>0?1:0),K=y.low=K+Qe,y.high=X+Bt+(K>>>0>>0?1:0),Y=A.low=Y+Je,A.high=q+bt+(Y>>>0>>0?1:0),ye=b.low=ye+qt,b.high=re+ft+(ye>>>0>>0?1:0)},_doFinalize:function(){var h=this._data,v=h.words,E=8*this._nDataBytes,p=8*h.sigBytes;return v[p>>>5]|=128<<24-p%32,v[(p+128>>>10<<5)+30]=Math.floor(E/4294967296),v[(p+128>>>10<<5)+31]=E,h.sigBytes=4*v.length,this._process(),this._hash.toX32()},clone:function(){var h=r.clone.call(this);return h._hash=this._hash.clone(),h},blockSize:32}),t.SHA512=r._createHelper(a),t.HmacSHA512=r._createHmacHelper(a)})();(function(){var e=Se,s=e.x64,t=s.Word,r=s.WordArray,s=e.algo,n=s.SHA512,s=s.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new t.init(3418070365,3238371032),new t.init(1654270250,914150663),new t.init(2438529370,812702999),new t.init(355462360,4144912697),new t.init(1731405415,4290775857),new t.init(2394180231,1750603025),new t.init(3675008525,1694076839),new t.init(1203062813,3204075428)])},_doFinalize:function(){var a=n._doFinalize.call(this);return a.sigBytes-=16,a}});e.SHA384=n._createHelper(s),e.HmacSHA384=n._createHmacHelper(s)})();(function(){var e=Se,h=e.lib,t=h.WordArray,r=h.Hasher,h=e.algo,n=t.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=t.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=t.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),i=t.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),c=t.create([0,1518500249,1859775393,2400959708,2840853838]),l=t.create([1352829926,1548603684,1836072691,2053994217,0]),h=h.RIPEMD160=r.extend({_doReset:function(){this._hash=t.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(v,E){for(var p=0;16>p;p++){var f=E+p,w=v[f];v[f]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360}var f=this._hash.words,w=c.words,m=l.words,y=n.words,A=s.words,b=a.words,_=i.words,I,B,j,V,F,P,k,L,M,X;P=I=f[0],k=B=f[1],L=j=f[2],M=V=f[3],X=F=f[4];for(var K,p=0;80>p;p+=1)K=I+v[E+y[p]]|0,K=16>p?K+((B^j^V)+w[0]):32>p?K+((B&j|~B&V)+w[1]):48>p?K+(((B|~j)^V)+w[2]):64>p?K+((B&V|j&~V)+w[3]):K+((B^(j|~V))+w[4]),K|=0,K=K<>>32-b[p],K=K+F|0,I=F,F=V,V=j<<10|j>>>22,j=B,B=K,K=P+v[E+A[p]]|0,K=16>p?K+((k^(L|~M))+m[0]):32>p?K+((k&M|L&~M)+m[1]):48>p?K+(((k|~L)^M)+m[2]):64>p?K+((k&L|~k&M)+m[3]):K+((k^L^M)+m[4]),K|=0,K=K<<_[p]|K>>>32-_[p],K=K+X|0,P=X,X=M,M=L<<10|L>>>22,L=k,k=K;K=f[1]+j+M|0,f[1]=f[2]+V+X|0,f[2]=f[3]+F+P|0,f[3]=f[4]+I+k|0,f[4]=f[0]+B+L|0,f[0]=K},_doFinalize:function(){var v=this._data,E=v.words,p=8*this._nDataBytes,f=8*v.sigBytes;for(E[f>>>5]|=128<<24-f%32,E[(f+64>>>9<<4)+14]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,v.sigBytes=4*(E.length+1),this._process(),v=this._hash,E=v.words,p=0;5>p;p++)f=E[p],E[p]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360;return v},clone:function(){var v=r.clone.call(this);return v._hash=this._hash.clone(),v}});e.RIPEMD160=r._createHelper(h),e.HmacRIPEMD160=r._createHmacHelper(h)})(Math);(function(){var e=Se,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(r,n){r=this._hasher=new r.init,typeof n=="string"&&(n=t.parse(n));var s=r.blockSize,a=4*s;n.sigBytes>a&&(n=r.finalize(n)),n.clamp();for(var i=this._oKey=n.clone(),c=this._iKey=n.clone(),l=i.words,h=c.words,v=0;v>6)+xu.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=xu.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=xu.charAt(r>>2)+xu.charAt((r&3)<<4)),bp)for(;(n.length&3)>0;)n+=bp;return n}function ku(e){var t="",r,n=0,s,a;for(r=0;r>2),s=a&3,n=1):n==1?(t+=Zi(s<<2|a>>4),s=a&15,n=2):n==2?(t+=Zi(s),t+=Zi(a>>2),s=a&3,n=3):(t+=Zi(s<<2|a>>4),t+=Zi(a&15),n=0));return n==1&&(t+=Zi(s<<2)),t}function Eg(e){var t=ku(e),r,n=new Array;for(r=0;2*r=0;){var i=t*this[e++]+r[n]+s;s=Math.floor(i/67108864),r[n++]=i&67108863}return s}function tS(e,t,r,n,s,a){for(var i=t&32767,c=t>>15;--a>=0;){var l=this[e]&32767,h=this[e++]>>15,v=c*l+h*i;l=i*l+((v&32767)<<15)+r[n]+(s&1073741823),s=(l>>>30)+(v>>>15)+c*h+(s>>>30),r[n++]=l&1073741823}return s}function rS(e,t,r,n,s,a){for(var i=t&16383,c=t>>14;--a>=0;){var l=this[e]&16383,h=this[e++]>>14,v=c*l+h*i;l=i*l+((v&16383)<<14)+r[n]+s,s=(l>>28)+(v>>14)+c*h,r[n++]=l&268435455}return s}vg&&nc.appName=="Microsoft Internet Explorer"?(Z.prototype.am=tS,Ls=30):vg&&nc.appName!="Netscape"?(Z.prototype.am=eS,Ls=26):(Z.prototype.am=rS,Ls=28);Z.prototype.DB=Ls;Z.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function sS(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}function Ns(e){var t=ut();return t.fromInt(e),t}function aS(e,t){var r;if(t==16)r=4;else if(t==8)r=3;else if(t==256)r=8;else if(t==2)r=1;else if(t==32)r=5;else if(t==4)r=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var n=e.length,s=!1,a=0;--n>=0;){var i=r==8?e[n]&255:yg(e,n);if(i<0){e.charAt(n)=="-"&&(s=!0);continue}s=!1,a==0?this[this.t++]=i:a+r>this.DB?(this[this.t-1]|=(i&(1<>this.DB-a):this[this.t-1]|=i<=this.DB&&(a-=this.DB)}r==8&&e[0]&128&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t}function oS(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var r=(1<0)for(c>c)>0&&(s=!0,a=Zi(n));i>=0;)c>(c+=this.DB-t)):(n=this[i]>>(c-=t)&r,c<=0&&(c+=this.DB,--i)),n>0&&(s=!0),s&&(a+=Zi(n));return s?a:"0"}function cS(){var e=ut();return Z.ZERO.subTo(this,e),e}function lS(){return this.s<0?this.negate():this}function fS(e){var t=this.s-e.s;if(t!=0)return t;var r=this.t;if(t=r-e.t,t!=0)return this.s<0?-t:t;for(;--r>=0;)if((t=this[r]-e[r])!=0)return t;return 0}function Ll(e){var t=1,r;return(r=e>>>16)!=0&&(e=r,t+=16),(r=e>>8)!=0&&(e=r,t+=8),(r=e>>4)!=0&&(e=r,t+=4),(r=e>>2)!=0&&(e=r,t+=2),(r=e>>1)!=0&&(e=r,t+=1),t}function hS(){return this.t<=0?0:this.DB*(this.t-1)+Ll(this[this.t-1]^this.s&this.DM)}function pS(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}function dS(e,t){for(var r=e;r=0;--c)t[c+a+1]=this[c]>>n|i,i=(this[c]&s)<=0;--c)t[c]=0;t[a]=i,t.t=this.t+a+1,t.s=this.s,t.clamp()}function mS(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t){t.t=0;return}var n=e%this.DB,s=this.DB-n,a=(1<>n;for(var i=r+1;i>n;n>0&&(t[this.t-r-1]|=(this.s&a)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}function AS(e,t){var r=this.abs(),n=e.abs(),s=r.t;for(t.t=s+n.t;--s>=0;)t[s]=0;for(s=0;s=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}function ES(e,t,r){var n=e.abs();if(!(n.t<=0)){var s=this.abs();if(s.t0?(n.lShiftTo(l,a),s.lShiftTo(l,r)):(n.copyTo(a),s.copyTo(r));var h=a.t,v=a[h-1];if(v!=0){var E=v*(1<1?a[h-2]>>this.F2:0),p=this.FV/E,f=(1<=0&&(r[r.t++]=1,r.subTo(A,r)),Z.ONE.dlShiftTo(h,A),A.subTo(a,a);a.t=0;){var b=r[--m]==v?this.DM:Math.floor(r[m]*p+(r[m-1]+w)*f);if((r[m]+=a.am(0,b,r,y,0,h))0&&r.rShiftTo(l,r),i<0&&Z.ZERO.subTo(r,r)}}}function yS(e){var t=ut();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(Z.ZERO)>0&&e.subTo(t,t),t}function _a(e){this.m=e}function SS(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function bS(e){return e}function CS(e){e.divRemTo(this.m,null,e)}function FS(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function _S(e,t){e.squareTo(t),this.reduce(t)}_a.prototype.convert=SS;_a.prototype.revert=bS;_a.prototype.reduce=CS;_a.prototype.mulTo=FS;_a.prototype.sqrTo=_S;function IS(){if(this.t<1)return 0;var e=this[0];if(!(e&1))return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Ia(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(t,t),t}function BS(e){var t=ut();return e.copyTo(t),this.reduce(t),t}function PS(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e[r]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function $S(e,t){e.squareTo(t),this.reduce(t)}function RS(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Ia.prototype.convert=DS;Ia.prototype.revert=BS;Ia.prototype.reduce=PS;Ia.prototype.mulTo=RS;Ia.prototype.sqrTo=$S;function TS(){return(this.t>0?this[0]&1:this.s)==0}function xS(e,t){if(e>4294967295||e<1)return Z.ONE;var r=ut(),n=ut(),s=t.convert(this),a=Ll(e)-1;for(s.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,s,r);else{var i=r;r=n,n=i}return t.revert(r)}function OS(e,t){var r;return e<256||t.isEven()?r=new _a(t):r=new Ia(t),this.exp(e,r)}Z.prototype.copyTo=iS;Z.prototype.fromInt=sS;Z.prototype.fromString=aS;Z.prototype.clamp=uS;Z.prototype.dlShiftTo=pS;Z.prototype.drShiftTo=dS;Z.prototype.lShiftTo=gS;Z.prototype.rShiftTo=mS;Z.prototype.subTo=vS;Z.prototype.multiplyTo=AS;Z.prototype.squareTo=wS;Z.prototype.divRemTo=ES;Z.prototype.invDigit=IS;Z.prototype.isEven=TS;Z.prototype.exp=xS;Z.prototype.toString=oS;Z.prototype.negate=cS;Z.prototype.abs=lS;Z.prototype.compareTo=fS;Z.prototype.bitLength=hS;Z.prototype.mod=yS;Z.prototype.modPowInt=OS;Z.ZERO=Ns(0);Z.ONE=Ns(1);function kS(){var e=ut();return this.copyTo(e),e}function NS(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function US(){return this.t==0?this.s:this[0]<<16>>16}function HS(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function jS(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function MS(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=Ns(r),s=ut(),a=ut(),i="";for(this.divRemTo(n,s,a);s.signum()>0;)i=(r+a.intValue()).toString(e).substr(1)+i,s.divRemTo(n,s,a);return a.intValue().toString(e)+i}function qS(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),s=!1,a=0,i=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(i,0),a=0,i=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(i,0)),s&&Z.ZERO.subTo(this,this)}function KS(e,t,r){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(Z.ONE.shiftLeft(e-1),Bp,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(Z.ONE.shiftLeft(e-1),this);else{var n=new Array,s=e&7;n.length=(e>>3)+1,t.nextBytes(n),s>0?n[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(t[s++]=n|this.s<=0;)r<8?(n=(this[e]&(1<>(r+=this.DB-8)):(n=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),n&128&&(n|=-256),s==0&&(this.s&128)!=(n&128)&&++s,(s>0||n!=this.s)&&(t[s++]=n);return t}function GS(e){return this.compareTo(e)==0}function zS(e){return this.compareTo(e)<0?this:e}function YS(e){return this.compareTo(e)>0?this:e}function WS(e,t,r){var n,s,a=Math.min(e.t,this.t);for(n=0;n>=16,t+=16),e&255||(e>>=8,t+=8),e&15||(e>>=4,t+=4),e&3||(e>>=2,t+=2),e&1||++t,t}function sb(){for(var e=0;e=this.t?this.s!=0:(this[t]&1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()}function db(e){var t=ut();return this.addTo(e,t),t}function gb(e){var t=ut();return this.subTo(e,t),t}function mb(e){var t=ut();return this.multiplyTo(e,t),t}function vb(){var e=ut();return this.squareTo(e),e}function Ab(e){var t=ut();return this.divRemTo(e,t,null),t}function wb(e){var t=ut();return this.divRemTo(e,null,t),t}function Eb(e){var t=ut(),r=ut();return this.divRemTo(e,t,r),new Array(t,r)}function yb(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function Sb(e,t){if(e!=0){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}function sc(){}function Cg(e){return e}function bb(e,t,r){e.multiplyTo(t,r)}function Cb(e,t){e.squareTo(t)}sc.prototype.convert=Cg;sc.prototype.revert=Cg;sc.prototype.mulTo=bb;sc.prototype.sqrTo=Cb;function Fb(e){return this.exp(e,new sc)}function _b(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r[--n]=0;var s;for(s=r.t-this.t;n=0;)r[n]=0;for(n=Math.max(t-this.t,0);n2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=ut();return e.copyTo(t),this.reduce(t),t}function Bb(e){return e}function Pb(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function $b(e,t){e.squareTo(t),this.reduce(t)}function Rb(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Lu.prototype.convert=Db;Lu.prototype.revert=Bb;Lu.prototype.reduce=Pb;Lu.prototype.mulTo=Rb;Lu.prototype.sqrTo=$b;function Tb(e,t){var r=e.bitLength(),n,s=Ns(1),a;if(r<=0)return s;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?a=new _a(t):t.isEven()?a=new Lu(t):a=new Ia(t);var i=new Array,c=3,l=n-1,h=(1<1){var v=ut();for(a.sqrTo(i[1],v);c<=h;)i[c]=ut(),a.mulTo(v,i[c-2],i[c]),c+=2}var E=e.t-1,p,f=!0,w=ut(),m;for(r=Ll(e[E])-1;E>=0;){for(r>=l?p=e[E]>>r-l&h:(p=(e[E]&(1<0&&(p|=e[E-1]>>this.DB+r-l)),c=n;!(p&1);)p>>=1,--c;if((r-=c)<0&&(r+=this.DB,--E),f)i[p].copyTo(s),f=!1;else{for(;c>1;)a.sqrTo(s,w),a.sqrTo(w,s),c-=2;c>0?a.sqrTo(s,w):(m=s,s=w,w=m),a.mulTo(w,i[p],s)}for(;E>=0&&!(e[E]&1<0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(s=t.getLowestSetBit())>0&&t.rShiftTo(s,t),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r}function Ob(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(t==0)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r}function kb(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return Z.ZERO;for(var r=e.clone(),n=this.clone(),s=Ns(1),a=Ns(0),i=Ns(0),c=Ns(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),t?((!s.isEven()||!a.isEven())&&(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?((!i.isEven()||!c.isEven())&&(i.addTo(this,i),c.subTo(e,c)),i.rShiftTo(1,i)):c.isEven()||c.subTo(e,c),c.rShiftTo(1,c);r.compareTo(n)>=0?(r.subTo(n,r),t&&s.subTo(i,s),a.subTo(c,a)):(n.subTo(r,n),t&&i.subTo(s,i),c.subTo(a,c))}if(n.compareTo(Z.ONE)!=0)return Z.ZERO;if(c.compareTo(e)>=0)return c.subtract(e);if(c.signum()<0)c.addTo(e,c);else return c;return c.signum()<0?c.add(e):c}var Kr=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Nb=(1<<26)/Kr[Kr.length-1];function Lb(e){var t,r=this.abs();if(r.t==1&&r[0]<=Kr[Kr.length-1]){for(t=0;t>1,e>Kr.length&&(e=Kr.length);for(var s=ut(),a=0;a>8&255,yn[lr++]^=e>>16&255,yn[lr++]^=e>>24&255,lr>=Cp&&(lr-=Cp)}function $p(){qb(new Date().getTime())}if(yn==null){if(yn=new Array,lr=0,Tu!==void 0&&(Tu.crypto!==void 0||Tu.msCrypto!==void 0)){if(Ep=Tu.crypto||Tu.msCrypto,Ep.getRandomValues)for(yp=new Uint8Array(32),Ep.getRandomValues(yp),jn=0;jn<32;++jn)yn[lr++]=yp[jn];else if(nc.appName=="Netscape"&&nc.appVersion<"5")for(Sp=Tu.crypto.random(32),jn=0;jn>>8,yn[lr++]=jn&255;lr=0,$p()}var jn,Ep,yp,Sp;function Kb(){if(Tl==null){for($p(),Tl=Mb(),Tl.init(yn),lr=0;lr0&&t.length>0)this.n=sn(e,16),this.e=parseInt(t,16);else throw"Invalid RSA public key"}function zb(e){return e.modPowInt(this.e,this.n)}Ke.prototype.doPublic=zb;Ke.prototype.setPublic=Gb;Ke.prototype.type="RSA";function Yb(e,t,r){if(this.isPrivate=!0,typeof e!="string")this.n=e,this.e=t,this.d=r;else if(e!=null&&t!=null&&e.length>0&&t.length>0)this.n=sn(e,16),this.e=parseInt(t,16),this.d=sn(r,16);else throw"Invalid RSA private key"}function Wb(e,t,r,n,s,a,i,c){if(this.isPrivate=!0,this.isPublic=!1,e==null)throw"RSASetPrivateEx N == null";if(t==null)throw"RSASetPrivateEx E == null";if(e.length==0)throw"RSASetPrivateEx N.length == 0";if(t.length==0)throw"RSASetPrivateEx E.length == 0";if(e!=null&&t!=null&&e.length>0&&t.length>0)this.n=sn(e,16),this.e=parseInt(t,16),this.d=sn(r,16),this.p=sn(n,16),this.q=sn(s,16),this.dmp1=sn(a,16),this.dmq1=sn(i,16),this.coeff=sn(c,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function Xb(e,t){var r=new Uu,n=e>>1;this.e=parseInt(t,16);for(var s=new Z(t,16),a=e/2-100,i=Z.ONE.shiftLeft(a);;){for(;this.p=new Z(e-n,1,r),!(this.p.subtract(Z.ONE).gcd(s).compareTo(Z.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new Z(n,1,r),!(this.q.subtract(Z.ONE).gcd(s).compareTo(Z.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var c=this.p;this.p=this.q,this.q=c}var l=this.q.subtract(this.p).abs();if(!(l.bitLength()0;--h){s=s.twice();var v=r.testBit(h),E=t.testBit(h);v!=E&&(s=s.add(v?this:n))}for(h=i.bitLength()-2;h>0;--h){c=c.twice();var p=i.testBit(h),f=a.testBit(h);p!=f&&(c=c.add(p?c:l))}return s}function dC(e,t,r){var n;e.bitLength()>r.bitLength()?n=e.bitLength()-1:n=r.bitLength()-1;for(var s=this.curve.getInfinity(),a=this.add(t);n>=0;)s=s.twice(),e.testBit(n)?r.testBit(n)?s=s.add(a):s=s.add(this):r.testBit(n)&&(s=s.add(t)),--n;return s}lt.prototype.getX=aC;lt.prototype.getY=uC;lt.prototype.equals=oC;lt.prototype.isInfinity=cC;lt.prototype.negate=lC;lt.prototype.add=fC;lt.prototype.twice=hC;lt.prototype.multiply=pC;lt.prototype.multiplyTwo=dC;function es(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new lt(this,null,null)}function gC(){return this.q}function mC(){return this.a}function vC(){return this.b}function AC(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function wC(){return this.infinity}function EC(e){return new er(this.q,e)}function yC(e){switch(parseInt(e.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var t=e.substr(0,2),r=e.substr(2),n=this.fromBigInteger(new Z(h,16)),s=this.getA(),a=this.getB(),i=n.square().add(s).multiply(n).add(a),c=i.sqrt();return t=="03"&&(c=c.negate()),new lt(this,n,c);case 4:case 6:case 7:var l=(e.length-2)/2,h=e.substr(2,l),v=e.substr(l+2,l);return new lt(this,this.fromBigInteger(new Z(h,16)),this.fromBigInteger(new Z(v,16)));default:return null}}es.prototype.getQ=gC;es.prototype.getA=mC;es.prototype.getB=vC;es.prototype.equals=AC;es.prototype.getInfinity=wC;es.prototype.fromBigInteger=EC;es.prototype.decodePointHex=yC;er.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};lt.prototype.getEncoded=function(e){var t=function(a,i){var c=a.toByteArrayUnsigned();if(ic.length;)c.unshift(0);return c},r=this.getX().toBigInteger(),n=this.getY().toBigInteger(),s=t(r,32);return e?n.isEven()?s.unshift(2):s.unshift(3):(s.unshift(4),s=s.concat(t(n,32))),s};lt.decodeFrom=function(e,t){var r=t[0],n=t.length-1,s=t.slice(1,1+n/2),a=t.slice(1+n/2,1+n);s.unshift(0),a.unshift(0);var i=new Z(s),c=new Z(a);return new lt(e,e.fromBigInteger(i),e.fromBigInteger(c))};lt.decodeFromHex=function(e,t){var r=t.substr(0,2),n=t.length-2,s=t.substr(2,n/2),a=t.substr(2+n/2,n/2),i=new Z(s,16),c=new Z(a,16);return new lt(e,e.fromBigInteger(i),e.fromBigInteger(c))};lt.prototype.add2D=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;if(this.x.equals(e.x))return this.y.equals(e.y)?this.twice():this.curve.getInfinity();var t=e.x.subtract(this.x),r=e.y.subtract(this.y),n=r.divide(t),s=n.square().subtract(this.x).subtract(e.x),a=n.multiply(this.x.subtract(s)).subtract(this.y);return new lt(this.curve,s,a)};lt.prototype.twice2D=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var e=this.curve.fromBigInteger(Z.valueOf(2)),t=this.curve.fromBigInteger(Z.valueOf(3)),r=this.x.square().multiply(t).add(this.curve.a).divide(this.y.multiply(e)),n=r.square().subtract(this.x.multiply(e)),s=r.multiply(this.x.subtract(n)).subtract(this.y);return new lt(this.curve,n,s)};lt.prototype.multiply2D=function(e){if(this.isInfinity())return this;if(e.signum()==0)return this.curve.getInfinity();var t=e,r=t.multiply(new Z("3")),n=this.negate(),s=this,a;for(a=r.bitLength()-2;a>0;--a){s=s.twice();var i=r.testBit(a),c=t.testBit(a);i!=c&&(s=s.add2D(i?this:n))}return s};lt.prototype.isOnCurve=function(){var e=this.getX().toBigInteger(),t=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),s=this.curve.getQ(),a=t.multiply(t).mod(s),i=e.multiply(e).multiply(e).add(r.multiply(e)).add(n).mod(s);return a.equals(i)};lt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};lt.prototype.validate=function(){var e=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var t=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(t.compareTo(Z.ONE)<0||t.compareTo(e.subtract(Z.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(Z.ONE)<0||r.compareTo(e.subtract(Z.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(e).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var Fg=function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)",t='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))',r='(?:"'+t+'*")',n=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+e+"|"+r+")","g"),s=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),a={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:` `,r:"\r",t:" "};function i(E,p,f){return p?a[p]:String.fromCharCode(parseInt(f,16))}var c=new String(""),l="\\",h={"{":Object,"[":Array},v=Object.hasOwnProperty;return function(E,p){var f=E.match(n),w,m=f[0],y=!1;m==="{"?w={}:m==="["?w=[]:(w=[],y=!0);for(var A,b=[w],_=1-y,I=f.length;_=0;)delete P[k[X]]}return p.call(V,F,P)};w=j({"":w},"")}return w}}();(typeof d>"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});d.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){return uc(e)},this.getPEMStringFromHex=function(e,t){return Dr(e,t)},this.newObject=function(e){var t=d,r=t.asn1,n=r.ASN1Object,s=r.DERBoolean,a=r.DERInteger,i=r.DERBitString,c=r.DEROctetString,l=r.DERNull,h=r.DERObjectIdentifier,v=r.DEREnumerated,E=r.DERUTF8String,p=r.DERNumericString,f=r.DERPrintableString,w=r.DERTeletexString,m=r.DERIA5String,y=r.DERUTCTime,A=r.DERGeneralizedTime,b=r.DERVisibleString,_=r.DERBMPString,I=r.DERSequence,B=r.DERSet,j=r.DERTaggedObject,V=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var F=Object.keys(e);if(F.length!=1)throw new Error("key of param shall be only one.");var P=F[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+P+":")==-1)throw new Error("undefined key: "+P);if(P=="bool")return new s(e[P]);if(P=="int")return new a(e[P]);if(P=="bitstr")return new i(e[P]);if(P=="octstr")return new c(e[P]);if(P=="null")return new l(e[P]);if(P=="oid")return new h(e[P]);if(P=="enum")return new v(e[P]);if(P=="utf8str")return new E(e[P]);if(P=="numstr")return new p(e[P]);if(P=="prnstr")return new f(e[P]);if(P=="telstr")return new w(e[P]);if(P=="ia5str")return new m(e[P]);if(P=="utctime")return new y(e[P]);if(P=="gentime")return new A(e[P]);if(P=="visstr")return new b(e[P]);if(P=="bmpstr")return new _(e[P]);if(P=="asn1")return new n(e[P]);if(P=="seq"){for(var k=e[P],L=[],M=0;M"u"||this.hV==null)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+a.length+",v="+this.hV);var i=this.hV.length/2,c=i.toString(16);if(c.length%2==1&&(c="0"+c),i<128)return c;var l=c.length/2;if(l>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+i.toString(16));var h=128+l;return h.toString(16)+c},this.tohex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(i){this.params=i},e!=null&&e.tlv!=null&&(this.hTLV=e.tlv,this.isModified=!1)};d.asn1.DERAbstractString=function(e){d.asn1.DERAbstractString.superclass.constructor.call(this);var t=null,r=null;this.getString=function(){return this.s},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.s=n,this.hV=Hl(this.s).toLowerCase()},this.setStringHex=function(n){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof e<"u"&&(typeof e=="string"?this.setString(e):typeof e.str<"u"?this.setString(e.str):typeof e.hex<"u"&&this.setStringHex(e.hex))};fe(d.asn1.DERAbstractString,d.asn1.ASN1Object);d.asn1.DERAbstractTime=function(e){d.asn1.DERAbstractTime.superclass.constructor.call(this);var t=null,r=null;this.localDateToUTC=function(n){var s=n.getTime()+n.getTimezoneOffset()*6e4,a=new Date(s);return a},this.formatDate=function(n,s,a){var i=this.zeroPadding,c=this.localDateToUTC(n),l=String(c.getFullYear());s=="utc"&&(l=l.substr(2,2));var h=i(String(c.getMonth()+1),2),v=i(String(c.getDate()),2),E=i(String(c.getHours()),2),p=i(String(c.getMinutes()),2),f=i(String(c.getSeconds()),2),w=l+h+v+E+p+f;if(a===!0){var m=c.getMilliseconds();if(m!=0){var y=i(String(m),3);y=y.replace(/[0]+$/,""),w=w+"."+y}}return w+"Z"},this.zeroPadding=function(n,s){return n.length>=s?n:new Array(s-n.length+1).join("0")+n},this.setByParam=function(n){this.hV=null,this.hTLV=null,this.params=n},this.getString=function(){},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.params==null&&(this.params={}),this.params.str=n},this.setByDate=function(n){this.hTLV=null,this.isModified=!0,this.params==null&&(this.params={}),this.params.date=n},this.setByDateValue=function(n,s,a,i,c,l){var h=new Date(Date.UTC(n,s-1,a,i,c,l,0));this.setByDate(h)},this.getFreshValueHex=function(){return this.hV}};fe(d.asn1.DERAbstractTime,d.asn1.ASN1Object);d.asn1.DERAbstractStructured=function(e){d.asn1.DERAbstractString.superclass.constructor.call(this);var t=null;this.setByASN1ObjectArray=function(r){this.hTLV=null,this.isModified=!0,this.asn1Array=r},this.appendASN1Object=function(r){this.hTLV=null,this.isModified=!0,this.asn1Array.push(r)},this.asn1Array=new Array,typeof e<"u"&&typeof e.array<"u"&&(this.asn1Array=e.array)};fe(d.asn1.DERAbstractStructured,d.asn1.ASN1Object);d.asn1.DERBoolean=function(e){d.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",e==!1?this.hTLV="010100":this.hTLV="0101ff"};fe(d.asn1.DERBoolean,d.asn1.ASN1Object);d.asn1.DERInteger=function(e){d.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var t=uc;this.setByBigInteger=function(r){this.isModified=!0,this.params={bigint:r}},this.setByInteger=function(r){this.isModified=!0,this.params=r},this.setValueHex=function(r){this.isModified=!0,this.params={hex:r}},this.getFreshValueHex=function(){var r=this.params,n=null;if(r==null)throw new Error("value not set");if(typeof r=="object"&&r.hex!=null)return this.hV=r.hex,this.hV;if(typeof r=="number")n=new Z(String(r),10);else if(r.int!=null)n=new Z(String(r.int),10);else if(r.bigint!=null)n=r.bigint;else throw new Error("wrong parameter");return this.hV=t(n),this.hV},e!=null&&(this.params=e)};fe(d.asn1.DERInteger,d.asn1.ASN1Object);d.asn1.DERBitString=function(e){if(e!==void 0&&typeof e.obj<"u"){var t=d.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.tohex()}d.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(r){this.hTLV=null,this.isModified=!0,this.hV=r},this.setUnusedBitsAndHexValue=function(r,n){if(r<0||7=a)break}return n};Ae.getNthChildIdx=function(e,t,r){var n=Ae.getChildIdx(e,t);return n[r]};Ae.getIdxbyList=function(e,t,r,n){var s=Ae,a,i;return r.length==0?n!==void 0&&e.substr(t,2)!==n?-1:t:(a=r.shift(),i=s.getChildIdx(e,t),a>=i.length?-1:s.getIdxbyList(e,i[a],r,n))};Ae.getIdxbyListEx=function(e,t,r,n){var s=Ae,a,i;if(r.length==0)return n!==void 0&&e.substr(t,2)!==n?-1:t;a=r.shift(),i=s.getChildIdx(e,t);for(var c=0,l=0;l=e.length?null:s.getTLV(e,a)};Ae.getTLVbyListEx=function(e,t,r,n){var s=Ae,a=s.getIdxbyListEx(e,t,r,n);return a==-1?null:s.getTLV(e,a)};Ae.getVbyList=function(e,t,r,n,s){var a=Ae,i,c;return i=a.getIdxbyList(e,t,r,n),i==-1||i>=e.length?null:(c=a.getV(e,i),s===!0&&(c=c.substr(2)),c)};Ae.getVbyListEx=function(e,t,r,n,s){var a=Ae,i,c,l;return i=a.getIdxbyListEx(e,t,r,n),i==-1?null:(l=a.getV(e,i),e.substr(i,2)=="03"&&s!==!1&&(l=l.substr(2)),l)};Ae.getInt=function(e,t,r){r==null&&(r=-1);try{var n=e.substr(t,2);if(n!="02"&&n!="03")return r;var s=Ae.getV(e,t);return n=="02"?parseInt(s,16):xg(s)}catch{return r}};Ae.getOID=function(e,t,r){r==null&&(r=null);try{if(e.substr(t,2)!="06")return r;var n=Ae.getV(e,t);return Vl(n)}catch{return r}};Ae.getOIDName=function(e,t,r){r==null&&(r=null);try{var n=Ae.getOID(e,t,r);if(n==r)return r;var s=d.asn1.x509.OID.oid2name(n);return s==""?n:s}catch{return r}};Ae.getString=function(e,t,r){r==null&&(r=null);try{var n=Ae.getV(e,t);return un(n)}catch{return r}};Ae.hextooidstr=function(e){var t=function(E,p){return E.length>=p?E:new Array(p-E.length+1).join("0")+E},r=[],n=e.substr(0,2),s=parseInt(n,16);r[0]=new String(Math.floor(s/40)),r[1]=new String(s%40);for(var a=e.substr(2),i=[],c=0;c0&&(v=v+"."+l.join(".")),v};Ae.dump=function(e,t,r,n){var s=Ae,a=s.getV,i=s.dump,c=s.getChildIdx,l=e;e instanceof d.asn1.ASN1Object&&(l=e.tohex());var h=function(V,F){if(V.length<=F*2)return V;var P=V.substr(0,F)+"..(total "+V.length/2+"bytes).."+V.substr(V.length-F,F);return P};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var v=t.ommit_long_octet,B=l.substr(r,2);if(B=="01"){var E=a(l,r);return E=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(B=="02"){var E=a(l,r);return n+"INTEGER "+h(E,v)+` `}if(B=="03"){var E=a(l,r);if(s.isASN1HEX(E.substr(2))){var p=n+`BITSTRING, encapsulates `;return p=p+i(E.substr(2),t,0,n+" "),p}else return n+"BITSTRING "+h(E,v)+` `}if(B=="04"){var E=a(l,r);if(s.isASN1HEX(E)){var p=n+`OCTETSTRING, encapsulates `;return p=p+i(E,t,0,n+" "),p}else return n+"OCTETSTRING "+h(E,v)+` `}if(B=="05")return n+`NULL `;if(B=="06"){var f=a(l,r),w=d.asn1.ASN1Util.oidHexToInt(f),m=d.asn1.x509.OID.oid2name(w),y=w.replace(/\./g," ");return m!=""?n+"ObjectIdentifier "+m+" ("+y+`) `:n+"ObjectIdentifier ("+y+`) `}if(B=="0a")return n+"ENUMERATED "+parseInt(a(l,r))+` `;if(B=="0c")return n+"UTF8String '"+vt(a(l,r))+`' `;if(B=="13")return n+"PrintableString '"+vt(a(l,r))+`' `;if(B=="14")return n+"TeletexString '"+vt(a(l,r))+`' `;if(B=="16")return n+"IA5String '"+vt(a(l,r))+`' `;if(B=="17")return n+"UTCTime "+vt(a(l,r))+` `;if(B=="18")return n+"GeneralizedTime "+vt(a(l,r))+` `;if(B=="1a")return n+"VisualString '"+vt(a(l,r))+`' `;if(B=="1e")return n+"BMPString '"+Op(a(l,r))+`' `;if(B=="30"){if(l.substr(r,4)=="3000")return n+`SEQUENCE {} `;var p=n+`SEQUENCE `,A=c(l,r),b=t;if((A.length==2||A.length==3)&&l.substr(A[0],2)=="06"&&l.substr(A[A.length-1],2)=="04"){var m=s.oidname(a(l,A[0])),_=JSON.parse(JSON.stringify(t));_.x509ExtName=m,b=_}for(var I=0;I4?{enum:{hex:A}}:{enum:parseInt(A,16)};if(m=="30"||m=="31")return y[f[m]]=w(e),y;if(m=="14"){var j=p(A);return y[f[m]]={str:j},y}else if(m=="1e"){var j=E(A);return y[f[m]]={str:j},y}else if(":0c:12:13:16:17:18:1a:".indexOf(m)!=-1){var j=v(A);return y[f[m]]={str:j},y}else if(m.match(/^8[0-9]$/)){var j=v(A);return j==null|j==""?{tag:{tag:m,explicit:!1,hex:A}}:j.match(/[\x00-\x1F\x7F-\x9F]/)!=null||j.match(/[\u0000-\u001F\u0080–\u009F]/)!=null?{tag:{tag:m,explicit:!1,hex:A}}:{tag:{tag:m,explicit:!1,str:j}}}else if(m.match(/^a[0-9]$/))try{if(!n(A))throw new Error("not encap");return{tag:{tag:m,explicit:!0,obj:r(A)}}}catch{return{tag:{tag:m,explicit:!0,hex:A}}}else{var V=new d.asn1.ASN1Object;V.hV=A;var F=V.getLengthHexFromValue();return{asn1:{tlv:m+F+A}}}}}};Ae.isContextTag=function(e,t){e=e.toLowerCase();var r,n;try{r=parseInt(e,16)}catch{return-1}if(t===void 0)return(r&192)==128;try{var s=t.match(/^\[[0-9]+\]$/);return s==null||(n=parseInt(t.substr(1,t.length-1),10),n>31)?!1:(r&192)==128&&(r&31)==n}catch{return!1}};Ae.isASN1HEX=function(e){var t=Ae;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),s=t.getL(e,0),a=e.length-n.length-s.length;return a==r*2};Ae.checkStrictDER=function(e,t,r,n,s){var a=Ae;if(r===void 0){if(typeof e!="string")throw new Error("not hex string");if(e=e.toLowerCase(),!d.lang.String.isHex(e))throw new Error("not hex string");r=e.length,n=e.length/2,n<128?s=1:s=Math.ceil(n.toString(16))+1}var i=a.getL(e,t);if(i.length>s*2)throw new Error("L of TLV too long: idx="+t);var c=a.getVblen(e,t);if(c>n)throw new Error("value of L too long than hex: idx="+t);var l=a.getTLV(e,t),h=l.length-2-a.getL(e,t).length;if(h!==c*2)throw new Error("V string length and L's value not the same:"+h+"/"+c*2);if(t===0&&e.length!=l.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+l.length);var v=e.substr(t,2);if(v==="02"){var E=a.getVidx(e,t);if(e.substr(E,2)=="00"&&e.charCodeAt(E+2)<56)throw new Error("not least zeros for DER INTEGER")}if(parseInt(v,16)&32){for(var p=a.getVblen(e,t),f=0,w=a.getChildIdx(e,t),m=0;m"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.x509>"u"||!d.asn1.x509)&&(d.asn1.x509={});d.asn1.x509.Certificate=function(e){d.asn1.x509.Certificate.superclass.constructor.call(this);var t=d,r=t.asn1,n=r.DERBitString,s=r.DERSequence,a=r.x509,i=a.TBSCertificate,c=a.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(l){this.params=l},this.sign=function(){var l=this.params,h=l.sigalg;l.sigalg.name!=null&&(h=l.sigalg.name);var v=l.tbsobj.tohex(),E=new d.crypto.Signature({alg:h});E.init(l.cakey),E.updateHex(v),l.sighex=E.sign()},this.getPEM=function(){return Dr(this.tohex(),"CERTIFICATE")},this.tohex=function(){var l=this.params;if((l.tbsobj==null||l.tbsobj==null)&&(l.tbsobj=new i(l)),l.sighex==null&&l.cakey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or cakey parameter not defined");var h=[];h.push(l.tbsobj),h.push(new c({name:l.sigalg})),h.push(new n({hex:"00"+l.sighex}));var v=new s({array:h});return v.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&(this.params=e)};fe(d.asn1.x509.Certificate,d.asn1.ASN1Object);d.asn1.x509.TBSCertificate=function(e){d.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=d,r=t.asn1,n=r.x509,s=r.DERTaggedObject,a=r.DERInteger,i=r.DERSequence,c=n.AlgorithmIdentifier,l=n.Time,h=n.X500Name,v=n.Extensions,E=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(p){this.params=p},this.tohex=function(){var p=[],f=this.params;if(f.version!=null||f.version!=1){var w=2;f.version!=null&&(w=f.version-1);var m=new s({obj:new a({int:w})});p.push(m)}p.push(new a(f.serial)),p.push(new c({name:f.sigalg})),p.push(new h(f.issuer)),p.push(new i({array:[new l(f.notbefore),new l(f.notafter)]})),p.push(new h(f.subject)),p.push(new E(rt.getKey(f.sbjpubkey))),f.ext!==void 0&&f.ext.length>0&&p.push(new s({tag:"a3",obj:new v(f.ext)}));var y=new d.asn1.DERSequence({array:p});return y.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};fe(d.asn1.x509.TBSCertificate,d.asn1.ASN1Object);d.asn1.x509.Extensions=function(e){d.asn1.x509.Extensions.superclass.constructor.call(this);var t=d,r=t.asn1,n=r.DERSequence,s=r.x509;this.aParam=[],this.setByParam=function(a){this.aParam=a},this.tohex=function(){for(var a=[],i=0;i-1&&c.push(new n({int:this.pathLen}));var l=new s({array:c});return this.asn1ExtnValue=l,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,e!==void 0&&(e.cA!==void 0&&(this.cA=e.cA),e.pathLen!==void 0&&(this.pathLen=e.pathLen))};fe(d.asn1.x509.BasicConstraints,d.asn1.x509.Extension);d.asn1.x509.CRLDistributionPoints=function(e){d.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=d,r=t.asn1,n=r.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(s){for(var a=[],i=0;i0&&a.push(new r({array:i}))}var l=new r({array:a});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};fe(d.asn1.x509.PolicyInformation,d.asn1.ASN1Object);d.asn1.x509.PolicyQualifierInfo=function(e){d.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=d.asn1,r=t.DERSequence,n=t.DERIA5String,s=t.DERObjectIdentifier,a=t.x509.UserNotice;this.params=null,this.tohex=function(){if(this.params.cps!==void 0){var i=new r({array:[new s({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]});return i.tohex()}if(this.params.unotice!=null){var i=new r({array:[new s({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return i.tohex()}},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};fe(d.asn1.x509.PolicyQualifierInfo,d.asn1.ASN1Object);d.asn1.x509.UserNotice=function(e){d.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=d.asn1.DERSequence,r=d.asn1.DERInteger,n=d.asn1.x509.DisplayText,s=d.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var a=[];this.params.noticeref!==void 0&&a.push(new s(this.params.noticeref)),this.params.exptext!==void 0&&a.push(new n(this.params.exptext));var i=new t({array:a});return i.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};fe(d.asn1.x509.UserNotice,d.asn1.ASN1Object);d.asn1.x509.NoticeReference=function(e){d.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=d.asn1.DERSequence,r=d.asn1.DERInteger,n=d.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var s=[];if(this.params.org!==void 0&&s.push(new n(this.params.org)),this.params.noticenum!==void 0){for(var a=[],i=this.params.noticenum,c=0;c0)for(var i=0;i0;s++){var a=t.shift();if(r===!0){var i=n.pop(),c=(i+","+a).replace(/\\,/g,",");n.push(c),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}return n=n.map(function(l){return l.replace("/","\\/")}),n.reverse(),"/"+n.join("/")};d.asn1.x509.X500Name.ldapToOneline=function(e){return d.asn1.x509.X500Name.ldapToCompat(e)};d.asn1.x509.RDN=function(e){d.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=d.asn1.x509.AttributeTypeAndValue;this.setByParam=function(r){r.rule!==void 0&&(this.sRule=r.rule),r.str!==void 0&&this.addByMultiValuedString(r.str),r.array!==void 0&&(this.paramArray=r.array)},this.addByString=function(r){this.asn1Array.push(new d.asn1.x509.AttributeTypeAndValue({str:r,rule:this.sRule}))},this.addByMultiValuedString=function(r){for(var n=d.asn1.x509.RDN.parseString(r),s=0;s0)for(var r=0;r0;s++){var a=t.shift();if(r===!0){var i=n.pop(),c=(i+"+"+a).replace(/\\\+/g,"+");n.push(c),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}for(var l=!1,h=[],s=0;n.length>0;s++){var a=n.shift();if(l===!0){var v=h.pop();if(a.match(/"$/)){var c=(v+"+"+a).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(c),l=!1}else h.push(v+"+"+a)}else h.push(a);a.match(/^[^=]+="/)&&(l=!0)}return h};d.asn1.x509.AttributeTypeAndValue=function(e){d.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=d,r=t.asn1,n=r.DERSequence,s=r.DERUTF8String,a=r.DERPrintableString,i=r.DERTeletexString,c=r.DERIA5String,l=r.DERVisibleString,h=r.DERBMPString,v=t.lang.String.isMail,E=t.lang.String.isPrintable;this.setByParam=function(p){if(p.rule!==void 0&&(this.sRule=p.rule),p.ds!==void 0&&(this.dsType=p.ds),p.value===void 0&&p.str!==void 0){var f=p.str,w=f.match(/^([^=]+)=(.+)$/);if(w)this.sType=w[1],this.sValue=w[2];else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}else this.sType=p.type,this.sValue=p.value},this.setByString=function(p,f){f!==void 0&&(this.sRule=f);var w=p.match(/^([^=]+)=(.+)$/);if(w)this.setByAttrTypeAndValueStr(w[1],w[2]);else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)},this._getDsType=function(){var p=this.sType,f=this.sValue,w=this.sRule;return w==="prn"?p=="CN"&&v(f)?"ia5":E(f)?"prn":"utf8":w==="utf8"?p=="CN"&&v(f)?"ia5":p=="C"?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(p,f,w){w!==void 0&&(this.sRule=w),this.sType=p,this.sValue=f},this.getValueObj=function(p,f){if(p=="utf8")return new s({str:f});if(p=="prn")return new a({str:f});if(p=="tel")return new i({str:f});if(p=="ia5")return new c({str:f});if(p=="vis")return new l({str:f});if(p=="bmp")return new h({str:f});throw new Error("unsupported directory string type: type="+p+" value="+f)},this.tohex=function(){this.dsType==null&&(this.dsType=this._getDsType());var p=d.asn1.x509.OID.atype2obj(this.sType),f=this.getValueObj(this.dsType,this.sValue),w=new n({array:[p,f]});return this.TLV=w.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};fe(d.asn1.x509.AttributeTypeAndValue,d.asn1.ASN1Object);d.asn1.x509.SubjectPublicKeyInfo=function(e){d.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=null,r=null,n=d,s=n.asn1,a=s.DERInteger,i=s.DERBitString,c=s.DERObjectIdentifier,l=s.DERSequence,h=s.ASN1Util.newObject,v=s.x509,E=v.AlgorithmIdentifier,p=n.crypto,f=p.ECDSA,w=p.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null)throw"algId and/or subjPubKey not set";var m=new l({array:[this.asn1AlgId,this.asn1SubjPKey]});return m},this.tohex=function(){var m=this.getASN1Object();return this.hTLV=m.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(m){try{if(m instanceof Ke){var y=h({seq:[{int:{bigint:m.n}},{int:{int:m.e}}]}),A=y.tohex();this.asn1AlgId=new E({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+A})}}catch{}try{if(m instanceof d.crypto.ECDSA){var b=new c({name:m.curveName});this.asn1AlgId=new E({name:"ecPublicKey",asn1params:b}),this.asn1SubjPKey=new i({hex:"00"+m.pubKeyHex})}}catch{}try{if(m instanceof d.crypto.DSA){var b=new h({seq:[{int:{bigint:m.p}},{int:{bigint:m.q}},{int:{bigint:m.g}}]});this.asn1AlgId=new E({name:"dsa",asn1params:b});var _=new a({bigint:m.y});this.asn1SubjPKey=new i({hex:"00"+_.tohex()})}}catch{}},e!==void 0&&this.setPubKey(e)};fe(d.asn1.x509.SubjectPublicKeyInfo,d.asn1.ASN1Object);d.asn1.x509.Time=function(e){d.asn1.x509.Time.superclass.constructor.call(this);var t=null,r=null,n=d,s=n.asn1,a=s.DERUTCTime,i=s.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(c){this.timeParams=c},this.setByParam=function(c){this.params=c},this.getType=function(c){return c.match(/^[0-9]{12}Z$/)?"utc":c.match(/^[0-9]{14}Z$/)?"gen":c.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":c.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var c=this.params,l=null;if(typeof c=="string"&&(c={str:c}),c!=null&&c.str&&(c.type==null||c.type==null)&&(c.type=this.getType(c.str)),c!=null&&c.str?(c.type=="utc"&&(l=new a(c.str)),c.type=="gen"&&(l=new i(c.str))):this.type=="gen"?l=new i:l=new a,l==null)throw new Error("wrong setting for Time");return this.TLV=l.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};d.asn1.x509.Time_bak=function(e){d.asn1.x509.Time_bak.superclass.constructor.call(this);var t=null,r=null,n=d,s=n.asn1,a=s.DERUTCTime,i=s.DERGeneralizedTime;this.setTimeParams=function(c){this.timeParams=c},this.tohex=function(){var c=null;return this.timeParams!=null?this.type=="utc"?c=new a(this.timeParams):c=new i(this.timeParams):this.type=="utc"?c=new a:c=new i,this.TLV=c.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",e!==void 0&&(e.type!==void 0?this.type=e.type:e.str!==void 0&&(e.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),e.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=e)};fe(d.asn1.x509.Time,d.asn1.ASN1Object);d.asn1.x509.AlgorithmIdentifier=function(e){d.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=d,r=t.asn1,n=r.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null)throw new Error("algorithm not specified");if(this.nameAlg!==null){var a=null;for(var i in n)i===this.nameAlg&&(a=n[i]);if(a!==null)return this.hTLV=a,this.hTLV}this.nameAlg!==null&&this.asn1Alg===null&&(this.asn1Alg=r.x509.OID.name2obj(this.nameAlg));var c=[this.asn1Alg];this.asn1Params!==null&&c.push(this.asn1Params);var l=new r.DERSequence({array:c});return this.hTLV=l.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(e.name!==void 0&&(this.nameAlg=e.name),e.asn1params!==void 0&&(this.asn1Params=e.asn1params),e.paramempty!==void 0&&(this.paramEmpty=e.paramempty)),this.asn1Params===null&&this.paramEmpty===!1&&this.nameAlg!==null){this.nameAlg.name!==void 0&&(this.nameAlg=this.nameAlg.name);var s=this.nameAlg.toLowerCase();s.substr(-7,7)!=="withdsa"&&s.substr(-9,9)!=="withecdsa"&&(this.asn1Params=new r.DERNull)}};fe(d.asn1.x509.AlgorithmIdentifier,d.asn1.ASN1Object);d.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};d.asn1.x509.GeneralName=function(e){d.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},r=d,n=r.asn1,s=n.x509,a=s.X500Name,i=s.OtherName,c=n.DERIA5String,l=n.DERPrintableString,h=n.DEROctetString,v=n.DERTaggedObject,E=n.ASN1Object,p=Error;this.params=null,this.setByParam=function(f){this.params=f},this.tohex=function(){var f=this.params,w,y,m,y=!1;if(f.other!==void 0)w="a0",m=new i(f.other);else if(f.rfc822!==void 0)w="81",m=new c({str:f.rfc822});else if(f.dns!==void 0)w="82",m=new c({str:f.dns});else if(f.dn!==void 0)w="a4",y=!0,typeof f.dn=="string"?m=new a({str:f.dn}):f.dn instanceof d.asn1.x509.X500Name?m=f.dn:m=new a(f.dn);else if(f.ldapdn!==void 0)w="a4",y=!0,m=new a({ldapstr:f.ldapdn});else if(f.certissuer!==void 0||f.certsubj!==void 0){w="a4",y=!0;var A,b,_=null;if(f.certsubj!==void 0?(A=!1,b=f.certsubj):(A=!0,b=f.certissuer),b.match(/^[0-9A-Fa-f]+$/)&&_==b,b.indexOf("-----BEGIN ")!=-1&&(_=Tt(b)),_==null)throw new Error("certsubj/certissuer not cert");var I=new Ne;I.hex=_;var B;A?B=I.getIssuerHex():B=I.getSubjectHex(),m=new E,m.hTLV=B}else if(f.uri!==void 0)w="86",m=new c({str:f.uri});else if(f.ip!==void 0){w="87";var j,V=f.ip;try{if(V.match(/^[0-9a-f]+$/)){var F=V.length;if(F==8||F==16||F==32||F==64)j=V;else throw"err"}else j=xp(V)}catch(k){throw new p("malformed IP address: "+f.ip+":"+k.message)}m=new h({hex:j})}else throw new p("improper params");var P=new v({tag:w,explicit:y,obj:m});return P.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};fe(d.asn1.x509.GeneralName,d.asn1.ASN1Object);d.asn1.x509.GeneralNames=function(e){d.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=null,r=d,n=r.asn1;this.setByParamArray=function(s){for(var a=0;a"u")throw"Name of ObjectIdentifier not defined: "+t;var r=this.name2oidList[t],n=new e({oid:r});return this.objCache[t]=n,n},this.atype2obj=function(t){if(this.objCache[t]!==void 0)return this.objCache[t];var r;if(t.match(/^\d+\.\d+\.[0-9.]+$/))r=t;else if(this.atype2oidList[t]!==void 0)r=this.atype2oidList[t];else if(this.name2oidList[t]!==void 0)r=this.name2oidList[t];else throw new Error("AttributeType name undefined: "+t);var n=new e({oid:r});return this.objCache[t]=n,n},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var r in t)this.name2oidList[r]=t[r]},this.checkOIDs=function(t){try{var r=Object.keys(t);return r.length==0?!1:(r.map(function(n,s,a){var i=this[n];if(!i.match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch{return!1}}};d.asn1.x509.OID.oid2name=function(e){var t=d.asn1.x509.OID.name2oidList;for(var r in t)if(t[r]==e)return r;return""};d.asn1.x509.OID.oid2atype=function(e){var t=d.asn1.x509.OID.atype2oidList;for(var r in t)if(t[r]==e)return r;return e};d.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=d.asn1.x509.OID.name2oidList;return t[e]===void 0?"":t[e]};d.asn1.x509.X509Util={};d.asn1.x509.X509Util.newCertPEM=function(e){var t=d.asn1.x509,r=t.TBSCertificate,n=t.Certificate,s=new n(e);return s.getPEM()};(typeof d>"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.cms>"u"||!d.asn1.cms)&&(d.asn1.cms={});d.asn1.cms.Attribute=function(e){var t=Error,r=d,n=r.asn1,s=n.DERSequence,a=n.DERSet,i=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(c){this.params=c},this.getValueArray=function(){throw new t("not yet implemented abstract")},this.tohex=function(){var c=new i({oid:this.typeOid}),l=new a({array:this.getValueArray()}),h=new s({array:[c,l]});return h.tohex()},this.getEncodedHex=function(){return this.tohex()}};fe(d.asn1.cms.Attribute,d.asn1.ASN1Object);d.asn1.cms.ContentType=function(e){var t=d,r=t.asn1;r.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){var n=new r.DERObjectIdentifier(this.params.type);return[n]},e!=null&&this.setByParam(e)};fe(d.asn1.cms.ContentType,d.asn1.cms.Attribute);d.asn1.cms.MessageDigest=function(e){var t=d,r=t.asn1,n=r.DEROctetString,s=r.cms;s.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){var a=new n(this.params);return[a]},e!=null&&this.setByParam(e)};fe(d.asn1.cms.MessageDigest,d.asn1.cms.Attribute);d.asn1.cms.SigningTime=function(e){var t=d,r=t.asn1;r.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){var n=new r.x509.Time(this.params);return[n]},e!=null&&this.setByParam(e)};fe(d.asn1.cms.SigningTime,d.asn1.cms.Attribute);d.asn1.cms.SigningCertificate=function(e){var t=Error,r=d,n=r.asn1,s=n.DERSequence,a=n.cms,i=a.ESSCertID,c=r.crypto;a.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(this.params==null||this.params==null||this.params.array==null)throw new t("parameter 'array' not specified");for(var l=this.params.array,h=[],v=0;v0){for(var w=a(p.valhex,f[0]),m=E(w,0),y=[],A=0;A1){var I=a(p.valhex,f[1]);p.polhex=I}delete p.valhex},this.setSignaturePolicyIdentifier=function(p){var f=E(p.valhex,0);if(f.length>0){var w=n.getOID(p.valhex,f[0]);p.oid=w}if(f.length>1){var m=new t,y=E(p.valhex,f[1]),A=a(p.valhex,y[0]),b=m.getAlgorithmIdentifierName(A);p.alg=b;var _=s(p.valhex,y[1]);p.hash=_}delete p.valhex},this.setSigningCertificateV2=function(p){var f=E(p.valhex,0);if(f.length>0){for(var w=a(p.valhex,f[0]),m=E(w,0),y=[],A=0;A1){var I=a(p.valhex,f[1]);p.polhex=I}delete p.valhex},this.getESSCertID=function(p){var f={},w=E(p,0);if(w.length>0){var m=s(p,w[0]);f.hash=m}if(w.length>1){var y=a(p,w[1]),A=this.getIssuerSerial(y);A.serial!=null&&(f.serial=A.serial),A.issuer!=null&&(f.issuer=A.issuer)}return f},this.getESSCertIDv2=function(p){var f={},w=E(p,0);if(w.length<1||3m+1){var b=a(p,w[m+1]),_=this.getIssuerSerial(b);f.issuer=_.issuer,f.serial=_.serial}return f},this.getIssuerSerial=function(p){var f={},w=E(p,0),m=a(p,w[0]),y=r.getGeneralNames(m),A=y[0].dn;f.issuer=A;var b=s(p,w[1]);return f.serial={hex:b},f},this.getCertificateSet=function(p){for(var f=E(p,0),w=[],m=0;m"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.tsp>"u"||!d.asn1.tsp)&&(d.asn1.tsp={});d.asn1.tsp.TimeStampToken=function(e){var t=d,r=t.asn1,n=r.tsp;n.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var s=new n.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=s.tohex()},e!=null&&this.setByParam(e)};fe(d.asn1.tsp.TimeStampToken,d.asn1.cms.SignedData);d.asn1.tsp.TSTInfo=function(e){var t=Error,r=d,n=r.asn1,s=n.DERSequence,a=n.DERInteger,i=n.DERBoolean,c=n.DERGeneralizedTime,l=n.DERObjectIdentifier,h=n.DERTaggedObject,v=n.tsp,E=v.MessageImprint,p=v.Accuracy,f=n.x509.X500Name,w=n.x509.GeneralName;if(v.TSTInfo.superclass.constructor.call(this),this.dVersion=new a({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var m=[this.dVersion];if(this.dPolicy==null)throw new Error("policy shall be specified.");if(m.push(this.dPolicy),this.dMessageImprint==null)throw new Error("messageImprint shall be specified.");if(m.push(this.dMessageImprint),this.dSerial==null)throw new Error("serialNumber shall be specified.");if(m.push(this.dSerial),this.dGenTime==null)throw new Error("genTime shall be specified.");m.push(this.dGenTime),this.dAccuracy!=null&&m.push(this.dAccuracy),this.dOrdering!=null&&m.push(this.dOrdering),this.dNonce!=null&&m.push(this.dNonce),this.dTsa!=null&&m.push(this.dTsa);var y=new s({array:m});return this.hTLV=y.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0){if(typeof e.policy=="string"){if(!e.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new l({oid:e.policy})}e.messageImprint!==void 0&&(this.dMessageImprint=new E(e.messageImprint)),e.serial!==void 0&&(this.dSerial=new a(e.serial)),e.genTime!==void 0&&(this.dGenTime=new c(e.genTime)),e.accuracy!==void 0&&(this.dAccuracy=new p(e.accuracy)),e.ordering!==void 0&&e.ordering==!0&&(this.dOrdering=new i),e.nonce!==void 0&&(this.dNonce=new a(e.nonce)),e.tsa!==void 0&&(this.dTsa=new h({tag:"a0",explicit:!0,obj:new w({dn:e.tsa})}))}};fe(d.asn1.tsp.TSTInfo,d.asn1.ASN1Object);d.asn1.tsp.Accuracy=function(e){var t=d,r=t.asn1,n=r.ASN1Util.newObject;r.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var s=this.params,a=[];return s.seconds!=null&&typeof s.seconds=="number"&&a.push({int:s.seconds}),s.millis!=null&&typeof s.millis=="number"&&a.push({tag:{tagi:"80",obj:{int:s.millis}}}),s.micros!=null&&typeof s.micros=="number"&&a.push({tag:{tagi:"81",obj:{int:s.micros}}}),n({seq:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};fe(d.asn1.tsp.Accuracy,d.asn1.ASN1Object);d.asn1.tsp.MessageImprint=function(e){var t=d,r=t.asn1,n=r.DERSequence,s=r.DEROctetString,a=r.x509,i=a.AlgorithmIdentifier;r.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var c=this.params,l=new i({name:c.alg}),h=new s({hex:c.hash}),v=new n({array:[l,h]});return v.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};fe(d.asn1.tsp.MessageImprint,d.asn1.ASN1Object);d.asn1.tsp.TimeStampReq=function(e){var t=d,r=t.asn1,n=r.DERSequence,s=r.DERInteger,a=r.DERBoolean,i=r.ASN1Object,c=r.DERObjectIdentifier,l=r.tsp,h=l.MessageImprint;l.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var v=this.params,E=[];E.push(new s({int:1})),v.messageImprint instanceof d.asn1.ASN1Object?E.push(v.messageImprint):E.push(new h(v.messageImprint)),v.policy!=null&&E.push(new c(v.policy)),v.nonce!=null&&E.push(new s(v.nonce)),v.certreq==!0&&E.push(new a);var p=new n({array:E});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};fe(d.asn1.tsp.TimeStampReq,d.asn1.ASN1Object);d.asn1.tsp.TimeStampResp=function(e){var t=d,r=t.asn1,n=r.DERSequence,s=r.ASN1Object,a=r.tsp,i=a.PKIStatusInfo;a.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var c=this.params,l=[];if(c.econtent!=null||c.tst!=null)if(c.statusinfo!=null?l.push(new i(c.statusinfo)):l.push(new i("granted")),c.econtent!=null)l.push(new a.TimeStampToken(c).getContentInfo());else if(c.tst instanceof r.ASN1Object)l.push(c.tst);else throw new Error("improper member tst value");else if(c.statusinfo!=null)l.push(new i(c.statusinfo));else throw new Error("parameter for token nor statusinfo not specified");var h=new n({array:l});return h.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};fe(d.asn1.tsp.TimeStampResp,d.asn1.ASN1Object);d.asn1.tsp.PKIStatusInfo=function(e){var t=Error,r=d,n=r.asn1,s=n.DERSequence,a=n.tsp,i=a.PKIStatus,c=a.PKIFreeText,l=a.PKIFailureInfo;a.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var h=this.params,v=[];if(typeof h=="string")v.push(new i(h));else{if(h.status==null)throw new t("property 'status' unspecified");v.push(new i(h.status)),h.statusstr!=null&&v.push(new c(h.statusstr)),h.failinfo!=null&&v.push(new l(h.failinfo))}var E=new s({array:v});return E.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};fe(d.asn1.tsp.PKIStatusInfo,d.asn1.ASN1Object);d.asn1.tsp.PKIStatus=function(e){var t=Error,r=d,n=r.asn1,s=n.DERInteger,a=n.tsp;a.PKIStatus.superclass.constructor.call(this);var i={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var c=this.params,l,h;if(typeof c=="string")try{h=i[c]}catch{throw new t("undefined name: "+c)}else if(typeof c=="number")h=c;else throw new t("unsupported params");return new s({int:h}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};fe(d.asn1.tsp.PKIStatus,d.asn1.ASN1Object);d.asn1.tsp.PKIFreeText=function(e){var t=Error,r=d,n=r.asn1,s=n.DERSequence,a=n.DERUTF8String,i=n.tsp;i.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var c=this.params;if(!c instanceof Array)throw new t("wrong params: not array");for(var l=[],h=0;h=0;p--)E+=v[p];return E}else{if(typeof l=="string"&&c[l]!=null)return kl([l],c);if(typeof l=="object"&&l.length!=null)return kl(l,c);throw new t("wrong params")}},this.tohex=function(){var l=this.params,h=this.getBinValue();return new s({bin:h}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};fe(d.asn1.tsp.PKIFailureInfo,d.asn1.ASN1Object);d.asn1.tsp.AbstractTSAAdapter=function(e){this.getTSTHex=function(t,r){throw"not implemented yet"}};d.asn1.tsp.SimpleTSAAdapter=function(e){var t=d,r=t.asn1,n=r.tsp,s=t.crypto.Util.hashHex;n.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(a,i){var c=s(a,i);this.params.econtent.content.messageImprint={alg:i,hash:c},this.params.econtent.content.serial={int:this.serial++};var l=Math.floor(Math.random()*1e9);this.params.econtent.content.nonce={int:l};var h=new n.TimeStampToken(this.params);return h.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};fe(d.asn1.tsp.SimpleTSAAdapter,d.asn1.tsp.AbstractTSAAdapter);d.asn1.tsp.FixedTSAAdapter=function(e){var t=d,r=t.asn1,n=r.tsp,s=t.crypto.Util.hashHex;n.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(a,i){var c=s(a,i);this.params.econtent.content.messageImprint={alg:i,hash:c};var l=new n.TimeStampToken(this.params);return l.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};fe(d.asn1.tsp.FixedTSAAdapter,d.asn1.tsp.AbstractTSAAdapter);d.asn1.tsp.TSPUtil=new function(){};d.asn1.tsp.TSPUtil.newTimeStampToken=function(e){return new d.asn1.tsp.TimeStampToken(e)};d.asn1.tsp.TSPUtil.parseTimeStampReq=function(e){var t=new d.asn1.tsp.TSPParser;return t.getTimeStampReq(e)};d.asn1.tsp.TSPUtil.parseMessageImprint=function(e){var t=new d.asn1.tsp.TSPParser;return t.getMessageImprint(e)};d.asn1.tsp.TSPParser=function(){var e=Error,t=Ne,r=new t,n=Ae,s=n.getV,a=n.getTLV,i=n.getIdxbyList,c=n.getTLVbyListEx,l=n.getChildIdx,h=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],v={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(E){var p=l(E,0);if(p.length==1)return this.getPKIStatusInfo(a(E,p[0]));if(p.length>1){var f=this.getPKIStatusInfo(a(E,p[0])),w=a(E,p[1]),m=this.getToken(w);return m.statusinfo=f,m}},this.getToken=function(E){var p=new d.asn1.cms.CMSParser,f=p.getCMSSignedData(E);return this.setTSTInfo(f),f},this.setTSTInfo=function(E){var p=E.econtent;if(p.type=="tstinfo"){var f=p.content.hex,w=this.getTSTInfo(f);p.content=w}},this.getTSTInfo=function(E){var p={},f=l(E,0),w=s(E,f[1]);p.policy=Vl(w);var m=a(E,f[2]);p.messageImprint=this.getMessageImprint(m);var y=s(E,f[3]);p.serial={hex:y};var A=s(E,f[4]);p.genTime={str:vt(A)};var b=0;if(f.length>5&&E.substr(f[5],2)=="30"){var _=a(E,f[5]);p.accuracy=this.getAccuracy(_),b++}if(f.length>5+b&&E.substr(f[5+b],2)=="01"){var I=s(E,f[5+b]);I=="ff"&&(p.ordering=!0),b++}if(f.length>5+b&&E.substr(f[5+b],2)=="02"){var B=s(E,f[5+b]);p.nonce={hex:B},b++}if(f.length>5+b&&E.substr(f[5+b],2)=="a0"){var j=a(E,f[5+b]);j="30"+j.substr(2),pGeneralNames=r.getGeneralNames(j);var V=pGeneralNames[0].dn;p.tsa=V,b++}if(f.length>5+b&&E.substr(f[5+b],2)=="a1"){var F=a(E,f[5+b]);F="30"+F.substr(2);var P=r.getExtParamArray(F);p.ext=P,b++}return p},this.getAccuracy=function(E){for(var p={},f=l(E,0),w=0;w1&&E.substr(f[1],2)=="30"){var A=a(E,f[1]);p.statusstr=this.getPKIFreeText(A),w++}if(f.length>w&&E.substr(f[1+w],2)=="03"){var b=a(E,f[1+w]);p.failinfo=this.getPKIFailureInfo(b)}return p},this.getPKIFreeText=function(E){for(var p=[],f=l(E,0),w=0;w"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.cades>"u"||!d.asn1.cades)&&(d.asn1.cades={});d.asn1.cades.SignaturePolicyIdentifier=function(e){var t=d,r=t.asn1,n=r.cades,s=n.SignaturePolicyId;n.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new s(this.params)]},this.setByParam=function(a){this.params=a},e!=null&&this.setByParam(e)};fe(d.asn1.cades.SignaturePolicyIdentifier,d.asn1.cms.Attribute);d.asn1.cades.SignaturePolicyId=function(e){var t=d,r=t.asn1,n=r.DERSequence,s=r.DERObjectIdentifier,a=r.x509,i=a.AlgorithmIdentifier,c=r.cades,l=c.SignaturePolicyId,h=c.OtherHashAlgAndValue;l.superclass.constructor.call(this),this.params=null,this.tohex=function(){var v=this.params,E=[];E.push(new s(v.oid)),E.push(new h(v));var p=new n({array:E});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(v){this.params=v},e!=null&&this.setByParam(e)};fe(d.asn1.cades.SignaturePolicyId,d.asn1.ASN1Object);d.asn1.cades.OtherHashAlgAndValue=function(e){var t=Error,r=d,n=r.asn1,s=n.DERSequence,a=n.DEROctetString,i=n.x509,c=i.AlgorithmIdentifier,l=n.cades,h=l.OtherHashAlgAndValue;h.superclass.constructor.call(this),this.params=null,this.tohex=function(){var v=this.params;if(v.alg==null)throw new t("property 'alg' not specified");if(v.hash==null&&v.cert==null)throw new t("property 'hash' nor 'cert' not specified");var E=null;if(v.hash!=null)E=v.hash;else if(v.cert!=null){if(typeof v.cert!="string")throw new t("cert not string");var p=v.cert;v.cert.indexOf("-----BEGIN")!=-1&&(p=Tt(v.cert)),E=d.crypto.Util.hashHex(p,v.alg)}var f=[];f.push(new c({name:v.alg})),f.push(new a({hex:E}));var w=new s({array:f});return w.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};fe(d.asn1.cades.OtherHashAlgAndValue,d.asn1.ASN1Object);d.asn1.cades.OtherHashValue=function(e){d.asn1.cades.OtherHashValue.superclass.constructor.call(this);var t=Error,r=d,n=r.lang.String.isHex,s=r.asn1,a=s.DEROctetString,i=r.crypto.Util.hashHex;this.params=null,this.tohex=function(){var c=this.params;if(c.hash==null&&c.cert==null)throw new t("hash or cert not specified");var l=null;if(c.hash!=null)l=c.hash;else if(c.cert!=null){if(typeof c.cert!="string")throw new t("cert not string");var h=c.cert;c.cert.indexOf("-----BEGIN")!=-1&&(h=Tt(c.cert)),l=d.crypto.Util.hashHex(h,"sha1")}return new a({hex:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};fe(d.asn1.cades.OtherHashValue,d.asn1.ASN1Object);d.asn1.cades.SignatureTimeStamp=function(e){var t=Error,r=d,n=r.lang.String.isHex,s=r.asn1,a=s.ASN1Object,i=s.x509,c=s.cades;c.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var l=this.params;if(l.tst!=null)if(n(l.tst)){var h=new a;return h.hTLV=l.tst,[h]}else{if(l.tst instanceof a)return[l.tst];throw new t("params.tst has wrong value")}else if(l.res!=null){var v=l.res;if(v instanceof a&&(v=v.tohex()),typeof v!="string"||!n(v))throw new t("params.res has wrong value");var E=Ae.getTLVbyList(v,0,[1]),h=new a;return h.hTLV=l.tst,[h]}},e!=null&&this.setByParam(e)};fe(d.asn1.cades.SignatureTimeStamp,d.asn1.cms.Attribute);d.asn1.cades.CompleteCertificateRefs=function(e){var t=Error,r=d,n=r.asn1,s=n.DERSequence,a=n.cades,i=a.OtherCertID,c=r.lang.String.isHex;a.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var l=this.params,h=[],v=0;v"u"||!d.asn1.csr)&&(d.asn1.csr={});d.asn1.csr.CertificationRequest=function(e){var t=d,r=t.asn1,n=r.DERBitString,s=r.DERSequence,a=r.csr,i=r.x509,c=a.CertificationRequestInfo;a.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(l){this.params=l},this.sign=function(){var l=new c(this.params).tohex(),h=new d.crypto.Signature({alg:this.params.sigalg});h.init(this.params.sbjprvkey),h.updateHex(l);var v=h.sign();this.params.sighex=v},this.getPEM=function(){return Dr(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var l=this.params,h=new d.asn1.csr.CertificationRequestInfo(this.params),v=new d.asn1.x509.AlgorithmIdentifier({name:l.sigalg});if(l.sighex==null&&l.sbjprvkey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or sbjprvkey parameter not defined");var E=new n({hex:"00"+l.sighex}),p=new s({array:[h,v,E]});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};fe(d.asn1.csr.CertificationRequest,d.asn1.ASN1Object);d.asn1.csr.CertificationRequestInfo=function(e){var t=d,r=t.asn1,n=r.DERBitString,s=r.DERSequence,a=r.DERInteger,i=r.DERUTF8String,c=r.DERTaggedObject,l=r.ASN1Util.newObject,h=r.csr,v=r.x509,E=v.X500Name,p=v.Extensions,f=v.SubjectPublicKeyInfo,w=h.AttributeList;h.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(y){y!=null&&(this.params=y)},this.tohex=function(){var y=this.params,A=[];if(A.push(new a({int:0})),A.push(new E(y.subject)),A.push(new f(rt.getKey(y.sbjpubkey))),y.attrs!=null){var b=m(y.attrs),_=l({tag:{tage:"a0",obj:b}});A.push(_)}else if(y.extreq!=null){var I=new p(y.extreq),_=l({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[I]}]}}});A.push(_)}else A.push(new c({tag:"a0",explicit:!1,obj:new i({str:""})}));var B=new s({array:A});return B.tohex()},this.getEncodedHex=function(){return this.tohex()};function m(y){for(var A=Error,b=d.asn1.x509.Extensions,_=[],I=0;I"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.ocsp>"u"||!d.asn1.ocsp)&&(d.asn1.ocsp={});d.asn1.ocsp.DEFAULT_HASH="sha1";d.asn1.ocsp.OCSPResponse=function(e){d.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var t=d.asn1.DEREnumerated,r=d.asn1.ASN1Util.newObject,n=d.asn1.ocsp.ResponseBytes,s=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var a=this.params.resstatus;return typeof a=="number"?a:typeof a!="string"?-1:s.indexOf(a)},this.setByParam=function(a){this.params=a},this.tohex=function(){var a=this.params,i=this._getStatusCode();if(i==-1)throw new Error("responseStatus not supported: "+a.resstatus);if(i!=0)return r({seq:[{enum:{int:i}}]}).tohex();var c=new n(a);return r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:c}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};fe(d.asn1.ocsp.OCSPResponse,d.asn1.ASN1Object);d.asn1.ocsp.ResponseBytes=function(e){d.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var t=d.asn1,r=t.DERSequence,n=t.DERObjectIdentifier,s=t.DEROctetString,a=t.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(i){this.params=i},this.tohex=function(){var i=this.params;if(i.restype!="ocspBasic")throw new Error("not supported responseType: "+i.restype);var c=new a(i),l=[];l.push(new n({name:"ocspBasic"})),l.push(new s({hex:c.tohex()}));var h=new r({array:l});return h.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};fe(d.asn1.ocsp.ResponseBytes,d.asn1.ASN1Object);d.asn1.ocsp.BasicOCSPResponse=function(e){d.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var t=Error,r=d.asn1,n=r.ASN1Object,s=r.DERSequence,a=r.DERGeneralizedTime,i=r.DERTaggedObject,c=r.DERBitString,l=r.x509.Extensions,h=r.x509.AlgorithmIdentifier,v=r.ocsp,E=v.ResponderID;_SingleResponseList=v.SingleResponseList,_ResponseData=v.ResponseData,this.params=null,this.setByParam=function(p){this.params=p},this.sign=function(){var p=this.params,f=p.tbsresp.tohex(),w=new d.crypto.Signature({alg:p.sigalg});w.init(p.reskey),w.updateHex(f),p.sighex=w.sign()},this.tohex=function(){var p=this.params;p.tbsresp==null&&(p.tbsresp=new _ResponseData(p)),p.sighex==null&&p.reskey!=null&&this.sign();var f=[];if(f.push(p.tbsresp),f.push(new h({name:p.sigalg})),f.push(new c({hex:"00"+p.sighex})),p.certs!=null&&p.certs.length!=null){for(var w=[],m=0;m"u"||!d)&&(d={});(typeof d.lang>"u"||!d.lang)&&(d.lang={});d.lang.String=function(){};function _g(e){for(var t=new Array,r=0;r>6,l=128|i&63;return vt(c.toString(16)+l.toString(16))}var c=224|(a&240)>>4,l=128|(a&15)<<2|(i&192)>>6,h=128|i&63;return vt(c.toString(16)+l.toString(16)+h.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function Kl(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function UC(e){e=e.replace(/^\s*\[\s*/,""),e=e.replace(/\s*\]\s*$/,""),e=e.replace(/\s*/g,"");try{var t=e.split(/,/).map(function(r,n,s){var a=parseInt(r);if(a<0||255t.length&&(r=t.length);for(var n=0;n0&&(h=h+"."+c.join(".")),h}catch{return null}}function Tg(e){var t=new Z(String(e),10);return uc(t)}function uc(e){var t=e.toString(16);if(t.substr(0,1)!="-")return t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t),t;var r=t.substr(1),n=r.length;n%2==1?n+=1:t.match(/^[0-7]/)||(n+=2);for(var s="",a=0;a=t?e:new Array(t-e.length+1).join(r)+e};function xg(e){if(e.length%2!=0||(e=e.toLowerCase(),e.match(/^[0-9a-f]+$/)==null))return-1;try{var t=e.substr(0,2);if(t=="00")return parseInt(e.substr(2),16);var r=parseInt(t,16);if(r>7)return-1;var n=e.substr(2),s=parseInt(n,16).toString(2);s=="0"&&(s="00000000"),s=s.slice(0,0-r);var a=parseInt(s,2);return a==NaN?-1:a}catch{return-1}}function Og(e){if(typeof e!="number"||e<0)return null;var t=Number(e).toString(2),r=8-t.length%8;r==8&&(r=0),t=t+Ol("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var s="0"+r;return s+n}function kg(e){if(typeof e!="string"||e.length%2!=0||!e.match(/^[0-9a-f]+$/))return null;try{var t=parseInt(e.substr(0,2),16);if(t<0||7=0;n--)a+=s[n];return a}function St(e,n,r){if(typeof e=="object"){for(var n=String(n).split("."),s=0;s"u"||!d)&&(d={});(typeof d.crypto>"u"||!d.crypto)&&(d.crypto={});d.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:Se.algo.MD5,sha1:Se.algo.SHA1,sha224:Se.algo.SHA224,sha256:Se.algo.SHA256,sha384:Se.algo.SHA384,sha512:Se.algo.SHA512,ripemd160:Se.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(typeof this.DIGESTINFOHEAD[t]>"u")throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,r){var n=this.getDigestInfoHex(e,t),s=r/4;if(n.length+22>s)throw"key is too short for SigAlg: keylen="+r+","+t;for(var a="0001",i="00"+n,c="",l=s-a.length-i.length,h=0;h"u"||!d)&&(d={});(typeof d.crypto>"u"||!d.crypto)&&(d.crypto={});d.crypto.ECDSA=function(e){var t="secp256r1",r=null,n=null,s=null,a=Error,i=Z,c=lt,l=d.crypto.ECDSA,h=d.crypto.ECParameterDB,v=l.getName,E=Ae,p=E.getVbyListEx,f=E.isASN1HEX,w=new Uu,m=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function y(A,b,_,I){for(var B=Math.max(b.bitLength(),I.bitLength()),j=A.add2D(_),V=A.curve.getInfinity(),F=B-1;F>=0;--F)V=V.twice2D(),V.z=i.ONE,b.testBit(F)?I.testBit(F)?V=V.add2D(j):V=V.add2D(A):I.testBit(F)&&(V=V.add2D(_));return V}this.getBigRandom=function(A){return new i(A.bitLength(),w).mod(A.subtract(i.ONE)).add(i.ONE)},this.setNamedCurve=function(A){this.ecparams=h.getByName(A),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=A},this.setPrivateKeyHex=function(A){this.isPrivate=!0,this.prvKeyHex=A},this.setPublicKeyHex=function(A){this.isPublic=!0,this.pubKeyHex=A},this.getPublicKeyXYHex=function(){var A=this.pubKeyHex;if(A.substr(0,2)!=="04")throw"this method supports uncompressed format(04) only";var b=this.ecparams.keycharlen;if(A.length!==2+b*2)throw"malformed public key hex length";var _={};return _.x=A.substr(2,b),_.y=A.substr(2+b),_},this.getShortNISTPCurveName=function(){var A=this.curveName;return A==="secp256r1"||A==="NIST P-256"||A==="P-256"||A==="prime256v1"?"P-256":A==="secp384r1"||A==="NIST P-384"||A==="P-384"?"P-384":A==="secp521r1"||A==="NIST P-521"||A==="P-521"?"P-521":null},this.generateKeyPairHex=function(){var A=this.ecparams.n,b=this.getBigRandom(A),_=this.ecparams.keycharlen,I=("0000000000"+b.toString(16)).slice(-_);this.setPrivateKeyHex(I);var B=this.generatePublicKeyHex();return{ecprvhex:I,ecpubhex:B}},this.generatePublicKeyHex=function(){var A=new i(this.prvKeyHex,16),b=this.ecparams.G.multiply(A),_=b.getX().toBigInteger(),I=b.getY().toBigInteger(),B=this.ecparams.keycharlen,j=("0000000000"+_.toString(16)).slice(-B),V=("0000000000"+I.toString(16)).slice(-B),F="04"+j+V;return this.setPublicKeyHex(F),F},this.signWithMessageHash=function(A){return this.signHex(A,this.prvKeyHex)},this.signHex=function(A,b){var _=new i(b,16),I=this.ecparams.n,B=new i(A.substring(0,this.ecparams.keycharlen),16);do var j=this.getBigRandom(I),V=this.ecparams.G,F=V.multiply(j),P=F.getX().toBigInteger().mod(I);while(P.compareTo(i.ZERO)<=0);var k=j.modInverse(I).multiply(B.add(_.multiply(P))).mod(I);return l.biRSSigToASN1Sig(P,k)},this.sign=function(A,b){var _=b,I=this.ecparams.n,B=i.fromByteArrayUnsigned(A);do var j=this.getBigRandom(I),V=this.ecparams.G,F=V.multiply(j),P=F.getX().toBigInteger().mod(I);while(P.compareTo(Z.ZERO)<=0);var k=j.modInverse(I).multiply(B.add(_.multiply(P))).mod(I);return this.serializeSig(P,k)},this.verifyWithMessageHash=function(A,b){return this.verifyHex(A,b,this.pubKeyHex)},this.verifyHex=function(A,b,_){try{var I,B,j=l.parseSigHex(b);I=j.r,B=j.s;var V=c.decodeFromHex(this.ecparams.curve,_),F=new i(A.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(F,I,B,V)}catch{return!1}},this.verify=function(A,b,_){var I,B;if(Bitcoin.Util.isArray(b)){var j=this.parseSig(b);I=j.r,B=j.s}else if(typeof b=="object"&&b.r&&b.s)I=b.r,B=b.s;else throw"Invalid value for signature";var V;if(_ instanceof lt)V=_;else if(Bitcoin.Util.isArray(_))V=c.decodeFrom(this.ecparams.curve,_);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var F=i.fromByteArrayUnsigned(A);return this.verifyRaw(F,I,B,V)},this.verifyRaw=function(A,b,_,I){var B=this.ecparams.n,j=this.ecparams.G;if(b.compareTo(i.ONE)<0||b.compareTo(B)>=0||_.compareTo(i.ONE)<0||_.compareTo(B)>=0)return!1;var V=_.modInverse(B),F=A.multiply(V).mod(B),P=b.multiply(V).mod(B),k=j.multiply(F).add(I.multiply(P)),L=k.getX().toBigInteger().mod(B);return L.equals(b)},this.serializeSig=function(A,b){var _=A.toByteArraySigned(),I=b.toByteArraySigned(),B=[];return B.push(2),B.push(_.length),B=B.concat(_),B.push(2),B.push(I.length),B=B.concat(I),B.unshift(B.length),B.unshift(48),B},this.parseSig=function(A){var b;if(A[0]!=48)throw new Error("Signature not a valid DERSequence");if(b=2,A[b]!=2)throw new Error("First element in signature must be a DERInteger");var _=A.slice(b+2,b+2+A[b+1]);if(b+=2+A[b+1],A[b]!=2)throw new Error("Second element in signature must be a DERInteger");var I=A.slice(b+2,b+2+A[b+1]);b+=2+A[b+1];var B=i.fromByteArrayUnsigned(_),j=i.fromByteArrayUnsigned(I);return{r:B,s:j}},this.parseSigCompact=function(A){if(A.length!==65)throw"Signature has the wrong length";var b=A[0]-27;if(b<0||b>7)throw"Invalid signature type";var _=this.ecparams.n,I=i.fromByteArrayUnsigned(A.slice(1,33)).mod(_),B=i.fromByteArrayUnsigned(A.slice(33,65)).mod(_);return{r:I,s:B,i:b}},this.readPKCS5PrvKeyHex=function(A){if(f(A)===!1)throw new Error("not ASN.1 hex string");var b,_,I;try{b=p(A,0,["[0]",0],"06"),_=p(A,0,[1],"04");try{I=p(A,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=v(b),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(I),this.setPrivateKeyHex(_),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(A){if(f(A)===!1)throw new a("not ASN.1 hex string");var b,_,I,B;try{b=p(A,0,[1,0],"06"),_=p(A,0,[1,1],"06"),I=p(A,0,[2,0,1],"04");try{B=p(A,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new a("malformed PKCS#8 plain ECC private key")}if(this.curveName=v(_),this.curveName===void 0)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(B),this.setPrivateKeyHex(I),this.isPublic=!1},this.readPKCS8PubKeyHex=function(A){if(f(A)===!1)throw new a("not ASN.1 hex string");var b,_,I;try{b=p(A,0,[0,0],"06"),_=p(A,0,[0,1],"06"),I=p(A,0,[1],"03")}catch{throw new a("malformed PKCS#8 ECC public key")}if(this.curveName=v(_),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(I)},this.readCertPubKeyHex=function(A,b){if(f(A)===!1)throw new a("not ASN.1 hex string");var _,I;try{_=p(A,0,[0,5,0,1],"06"),I=p(A,0,[0,5,1],"03")}catch{throw new a("malformed X.509 certificate ECC public key")}if(this.curveName=v(_),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(I)},e!==void 0&&e.curve!==void 0&&(this.curveName=e.curve),this.curveName===void 0&&(this.curveName=t),this.setNamedCurve(this.curveName),e!==void 0&&(e.prv!==void 0&&this.setPrivateKeyHex(e.prv),e.pub!==void 0&&this.setPublicKeyHex(e.pub))};d.crypto.ECDSA.parseSigHex=function(e){var t=d.crypto.ECDSA.parseSigHexInHexRS(e),r=new Z(t.r,16),n=new Z(t.s,16);return{r,s:n}};d.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=Ae,r=t.getChildIdx,n=t.getV;if(t.checkStrictDER(e,0),e.substr(0,2)!="30")throw new Error("signature is not a ASN.1 sequence");var s=r(e,0);if(s.length!=2)throw new Error("signature shall have two elements");var a=s[0],i=s[1];if(e.substr(a,2)!="02")throw new Error("1st item not ASN.1 integer");if(e.substr(i,2)!="02")throw new Error("2nd item not ASN.1 integer");var c=n(e,a),l=n(e,i);return{r:c,s:l}};d.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=d.crypto.ECDSA.parseSigHexInHexRS(e),r=t.r,n=t.s;if(r.length>=130&&r.length<=134){if(r.length%2!=0)throw Error("unknown ECDSA sig r length error");if(n.length%2!=0)throw Error("unknown ECDSA sig s length error");r.substr(0,2)=="00"&&(r=r.substr(2)),n.substr(0,2)=="00"&&(n=n.substr(2));var s=Math.max(r.length,n.length);return r=("000000"+r).slice(-s),n=("000000"+n).slice(-s),r+n}if(r.substr(0,2)=="00"&&r.length%32==2&&(r=r.substr(2)),n.substr(0,2)=="00"&&n.length%32==2&&(n=n.substr(2)),r.length%32==30&&(r="00"+r),n.length%32==30&&(n="00"+n),r.length%32!=0)throw Error("unknown ECDSA sig r length error");if(n.length%32!=0)throw Error("unknown ECDSA sig s length error");return r+n};d.crypto.ECDSA.concatSigToASN1Sig=function(e){if(e.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var t=e.substr(0,e.length/2),r=e.substr(e.length/2);return d.crypto.ECDSA.hexRSSigToASN1Sig(t,r)};d.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new Z(e,16),n=new Z(t,16);return d.crypto.ECDSA.biRSSigToASN1Sig(r,n)};d.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=d.asn1,n=new r.DERInteger({bigint:e}),s=new r.DERInteger({bigint:t}),a=new r.DERSequence({array:[n,s]});return a.tohex()};d.crypto.ECDSA.getName=function(e){return e==="2b8104001f"?"secp192k1":e==="2a8648ce3d030107"?"secp256r1":e==="2b8104000a"?"secp256k1":e==="2b81040021"?"secp224r1":e==="2b81040022"?"secp384r1":e==="2b81040023"?"secp521r1":"|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(e)!==-1?"secp256r1":"|secp256k1|".indexOf(e)!==-1?"secp256k1":"|secp224r1|NIST P-224|P-224|".indexOf(e)!==-1?"secp224r1":"|secp384r1|NIST P-384|P-384|".indexOf(e)!==-1?"secp384r1":"|secp521r1|NIST P-521|P-521|".indexOf(e)!==-1?"secp521r1":null};(typeof d>"u"||!d)&&(d={});(typeof d.crypto>"u"||!d.crypto)&&(d.crypto={});d.crypto.ECParameterDB=new function(){var e={},t={};function r(n){return new Z(n,16)}this.getByName=function(n){var s=n;if(typeof t[s]<"u"&&(s=t[n]),typeof e[s]<"u")return e[s];throw"unregistered EC curve name: "+s},this.regist=function(n,s,a,i,c,l,h,v,E,p,f,w){e[n]={};var m=r(a),y=r(i),A=r(c),b=r(l),_=r(h),I=new es(m,y,A),B=I.decodePointHex("04"+v+E);e[n].name=n,e[n].keylen=s,e[n].keycharlen=Math.ceil(s/8)*2,e[n].curve=I,e[n].G=B,e[n].n=b,e[n].h=_,e[n].oid=f,e[n].info=w;for(var j=0;j"u"||!d)&&(d={});(typeof d.crypto>"u"||!d.crypto)&&(d.crypto={});d.crypto.DSA=function(){var e=Ae,t=e.getVbyList,r=e.getVbyListEx,n=e.isASN1HEX,s=Z;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(a,i,c,l,h){this.isPrivate=!0,this.p=a,this.q=i,this.g=c,this.y=l,this.x=h},this.setPrivateHex=function(a,i,c,l,h){var v,E,p,f,w;v=new Z(a,16),E=new Z(i,16),p=new Z(c,16),typeof l=="string"&&l.length>1?f=new Z(l,16):f=null,w=new Z(h,16),this.setPrivate(v,E,p,f,w)},this.setPublic=function(a,i,c,l){this.isPublic=!0,this.p=a,this.q=i,this.g=c,this.y=l,this.x=null},this.setPublicHex=function(a,i,c,l){var h,v,E,p;h=new Z(a,16),v=new Z(i,16),E=new Z(c,16),p=new Z(l,16),this.setPublic(h,v,E,p)},this.signWithMessageHash=function(a){var i=this.p,c=this.q,l=this.g,h=this.y,v=this.x,E=d.crypto.Util.getRandomBigIntegerMinToMax(Z.ONE.add(Z.ONE),c.subtract(Z.ONE)),p=a.substr(0,c.bitLength()/4),f=new Z(p,16),w=l.modPow(E,i).mod(c),m=E.modInverse(c).multiply(f.add(v.multiply(w))).mod(c),y=d.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:w}},{int:{bigint:m}}]});return y},this.verifyWithMessageHash=function(a,i){var c=this.p,l=this.q,h=this.g,v=this.y,E=this.parseASN1Signature(i),p=E[0],f=E[1],w=a.substr(0,l.bitLength()/4),m=new Z(w,16);if(Z.ZERO.compareTo(p)>0||p.compareTo(l)>0||Z.ZERO.compareTo(f)>=0||f.compareTo(l)>0)throw"invalid DSA signature";var y=f.modInverse(l),A=m.multiply(y).mod(l),b=p.multiply(y).mod(l),_=h.modPow(A,c).multiply(v.modPow(b,c)).mod(c).mod(l);return _.compareTo(p)==0},this.parseASN1Signature=function(a){try{var i=new s(r(a,0,[0],"02"),16),c=new s(r(a,0,[1],"02"),16);return[i,c]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(a){var i,c,l,h,v;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{i=r(a,0,[1],"02"),c=r(a,0,[2],"02"),l=r(a,0,[3],"02"),h=r(a,0,[4],"02"),v=r(a,0,[5],"02")}catch{throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(i,c,l,h,v)},this.readPKCS8PrvKeyHex=function(a){var i,c,l,h;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{i=r(a,0,[1,1,0],"02"),c=r(a,0,[1,1,1],"02"),l=r(a,0,[1,1,2],"02"),h=r(a,0,[2,0],"02")}catch{throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(i,c,l,null,h)},this.readPKCS8PubKeyHex=function(a){var i,c,l,h;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{i=r(a,0,[0,1,0],"02"),c=r(a,0,[0,1,1],"02"),l=r(a,0,[0,1,2],"02"),h=r(a,0,[1,0],"02")}catch{throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(i,c,l,h)},this.readCertPubKeyHex=function(a,i){var c,l,h,v;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{c=r(a,0,[0,5,0,1,0],"02"),l=r(a,0,[0,5,0,1,1],"02"),h=r(a,0,[0,5,0,1,2],"02"),v=r(a,0,[0,5,1,0],"02")}catch{throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(c,l,h,v)}};var rt=function(){var e=function(m,y,A){return n(Se.AES,m,y,A)},t=function(m,y,A){return n(Se.TripleDES,m,y,A)},r=function(m,y,A){return n(Se.DES,m,y,A)},n=function(m,y,A,b){var _=Se.enc.Hex.parse(y),I=Se.enc.Hex.parse(A),B=Se.enc.Hex.parse(b),j={};j.key=I,j.iv=B,j.ciphertext=_;var V=m.decrypt(j,I,{iv:B});return Se.enc.Hex.stringify(V)},s=function(m,y,A){return c(Se.AES,m,y,A)},a=function(m,y,A){return c(Se.TripleDES,m,y,A)},i=function(m,y,A){return c(Se.DES,m,y,A)},c=function(m,y,A,b){var _=Se.enc.Hex.parse(y),I=Se.enc.Hex.parse(A),B=Se.enc.Hex.parse(b),j=m.encrypt(_,I,{iv:B}),V=Se.enc.Hex.parse(j.toString()),F=Se.enc.Base64.stringify(V);return F},l={"AES-256-CBC":{proc:e,eproc:s,keylen:32,ivlen:16},"AES-192-CBC":{proc:e,eproc:s,keylen:24,ivlen:16},"AES-128-CBC":{proc:e,eproc:s,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:t,eproc:a,keylen:24,ivlen:8},"DES-CBC":{proc:r,eproc:i,keylen:8,ivlen:8}},h=function(m){return l[m].proc},v=function(m){var y=Se.lib.WordArray.random(m),A=Se.enc.Hex.stringify(y);return A},E=function(m){var y={},A=m.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));A&&(y.cipher=A[1],y.ivsalt=A[2]);var b=m.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));b&&(y.type=b[1]);var _=-1,I=0;m.indexOf(`\r \r `)!=-1&&(_=m.indexOf(`\r \r `),I=2),m.indexOf(` `)!=-1&&(_=m.indexOf(` `),I=1);var B=m.indexOf("-----END");if(_!=-1&&B!=-1){var j=m.substring(_+I*2,B-I);j=j.replace(/\s+/g,""),y.data=j}return y},p=function(m,y,A){for(var b=A.substring(0,16),_=Se.enc.Hex.parse(b),I=Se.enc.Utf8.parse(y),B=l[m].keylen+l[m].ivlen,j="",V=null;;){var F=Se.algo.MD5.create();if(V!=null&&F.update(V),F.update(I),F.update(_),V=F.finalize(),j=j+Se.enc.Hex.stringify(V),j.length>=B*2)break}var P={};return P.keyhex=j.substr(0,l[m].keylen*2),P.ivhex=j.substr(l[m].keylen*2,l[m].ivlen*2),P},f=function(m,y,A,b){var _=Se.enc.Base64.parse(m),I=Se.enc.Hex.stringify(_),B=l[y].proc,j=B(I,A,b);return j},w=function(m,y,A,b){var _=l[y].eproc,I=_(m,A,b);return I};return{version:"1.0.0",parsePKCS5PEM:function(m){return E(m)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(m,y,A){return p(m,y,A)},decryptKeyB64:function(m,y,A,b){return f(m,y,A,b)},getDecryptedKeyHex:function(m,y){var A=E(m),b=A.type,_=A.cipher,I=A.ivsalt,B=A.data,j=p(_,y,I),V=j.keyhex,F=f(B,_,V,I);return F},getEncryptedPKCS5PEMFromPrvKeyHex:function(m,y,A,b,_){var k="";if((typeof b>"u"||b==null)&&(b="AES-256-CBC"),typeof l[b]>"u")throw new Error("KEYUTIL unsupported algorithm: "+b);if(typeof _>"u"||_==null){var I=l[b].ivlen,B=v(I);_=B.toUpperCase()}var j=p(b,A,_),V=j.keyhex,F=w(y,b,V,_),P=F.replace(/(.{64})/g,`$1\r `),k="-----BEGIN "+m+` PRIVATE KEY-----\r `;return k+=`Proc-Type: 4,ENCRYPTED\r `,k+="DEK-Info: "+b+","+_+`\r `,k+=`\r `,k+=P,k+=`\r -----END `+m+` PRIVATE KEY-----\r `,k},getEncryptedPKCS8PEM:function(m,y,A){var b=this.getEncryptedPKCS8Hex(m,y,A);return Dr(b,"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(m,y,A){var b;A==null||A==null?b={}:b=JSON.parse(JSON.stringify(A)),b.plain=m,this.initPBES2Param(b),this.encryptPBES2Param(b,y);var _=this.generatePBES2ASN1Param(b);return d.asn1.ASN1Util.newObject(_).tohex()},initPBES2Param:function(m){if(St(m,"encalg")==null&&(m.encalg="aes256-CBC"),St(m,"iter")==null&&(m.iter=2048),St(m,"prf")==null&&(m.prf="hmacWithSHA256"),St(m,"salt")==null&&(m.salt=Se.enc.Hex.stringify(Se.lib.WordArray.random(8))),St(m,"enciv")==null){var y;m.encalg=="des-EDE3-CBC"&&(y=8),m.encalg=="aes128-CBC"&&(y=16),m.encalg=="aes256-CBC"&&(y=16),m.enciv=Se.enc.Hex.stringify(Se.lib.WordArray.random(y))}},encryptPBES2Param:function(m,y){var A=rt.getDKFromPBES2Param(m,y);try{var b=d.crypto.Cipher.encrypt(m.plain,A,m.encalg,{iv:m.enciv})}catch{throw new Error("encrypt error: "+m.plain+" "+A+" "+m.encalg+" "+m.enciv)}m.enc=b},generatePBES2ASN1Param:function(m){var y={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:m.salt}},{int:{hex:Tg(m.iter)}}]}]},{seq:[{oid:m.encalg},{octstr:{hex:m.enciv}}]}]}]},{octstr:{hex:m.enc}}]};return m.prf!="hmacWithSHA1"&&y.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:m.prf},{null:""}]}),y},parseHexOfEncryptedPKCS8:function(m){var y=Ae,A=y.getChildIdx,b=y.getV,_={},I=A(m,0);if(I.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+I.length);_.ciphertext=b(m,I[1]);var B=A(m,I[0]);if(B.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+B.length);if(b(m,B[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var j=A(m,B[1]);if(B.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+j.length);var V=A(m,j[1]);if(V.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+V.length);if(b(m,V[0])!="2a864886f70d0307")throw"this only supports TripleDES";_.encryptionSchemeAlg="TripleDES",_.encryptionSchemeIV=b(m,V[1]);var F=A(m,j[0]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+F.length);if(b(m,F[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var P=A(m,F[1]);if(P.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+P.length);_.pbkdf2Salt=b(m,P[0]);var k=b(m,P[1]);try{_.pbkdf2Iter=parseInt(k,16)}catch{throw new Error("malformed format pbkdf2Iter: "+k)}return _},getPBKDF2KeyHexFromParam:function(m,y){var A=Se.enc.Hex.parse(m.pbkdf2Salt),b=m.pbkdf2Iter,_=Se.PBKDF2(y,A,{keySize:192/32,iterations:b}),I=Se.enc.Hex.stringify(_);return I},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(m,y){var A=Tt(m,"ENCRYPTED PRIVATE KEY"),b=this.parseHexOfEncryptedPKCS8(A),_=rt.getPBKDF2KeyHexFromParam(b,y),I={};I.ciphertext=Se.enc.Hex.parse(b.ciphertext);var B=Se.enc.Hex.parse(_),j=Se.enc.Hex.parse(b.encryptionSchemeIV),V=Se.TripleDES.decrypt(I,B,{iv:j}),F=Se.enc.Hex.stringify(V);return F},parsePBES2:function(m){var y=Ae.parse(m);if(St(y,"seq.0.seq.0.oid")!="pkcs5PBES2"||St(y,"seq.0.seq.1.seq.0.seq.0.oid")!="pkcs5PBKDF2")throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var A=St(y,"seq.0.seq.1.seq.0.seq.1.seq");if(A==null)throw new Error("PBKDF2 parameter not found");var b=St(A,"0.octstr.hex"),_=St(A,"1.int.hex"),I=St(A,"2.seq.0.oid","hmacWithSHA1"),B=-1;try{B=parseInt(_,16)}catch{throw new Error("iter not proper value")}var j=St(y,"seq.0.seq.1.seq.1.seq.0.oid"),V=St(y,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),F=St(y,"seq.1.octstr.hex");if(j==null||V==null||F==null)throw new Error("encalg, enciv or enc is undefined");var P={salt:b,iter:B,prf:I,encalg:j,enciv:V,enc:F};return P},getDKFromPBES2Param:function(m,y){var A={hmacWithSHA1:Se.algo.SHA1,hmacWithSHA224:Se.algo.SHA224,hmacWithSHA256:Se.algo.SHA256,hmacWithSHA384:Se.algo.SHA384,hmacWithSHA512:Se.algo.SHA512},b={"des-EDE3-CBC":192/32,"aes128-CBC":128/32,"aes256-CBC":256/32},_=A[m.prf];if(_==null)throw new Error("unsupported prf");var I=b[m.encalg];if(I==null)throw new Error("unsupported encalg");var B=Se.enc.Hex.parse(m.salt),j=m.iter;try{var V=Se.PBKDF2(y,B,{keySize:I,iterations:j,hasher:_});return Se.enc.Hex.stringify(V)}catch(F){throw new Error("PBKDF2 error: "+F+" "+JSON.stringify(m)+" "+y)}},getPlainHexFromEncryptedPKCS8PEM:function(m,y){if(m.indexOf("BEGIN ENCRYPTED PRIVATE KEY")==-1)throw new Error("not Encrypted PKCS#8 PEM string");var A=Tt(m),b;try{b=rt.parsePBES2(A)}catch(I){throw new Error("malformed PBES2 format: "+I.message)}var _=rt.getDKFromPBES2Param(b,y);return d.crypto.Cipher.decrypt(b.enc,_,b.encalg,{iv:b.enciv})},getKeyFromEncryptedPKCS8PEM:function(m,y){var A=this.getPlainHexFromEncryptedPKCS8PEM(m,y),b=this.getKeyFromPlainPrivatePKCS8Hex(A);return b},parsePlainPrivatePKCS8Hex:function(m){var y=Ae,A=y.getChildIdx,b=y.getV,_={};if(_.algparam=null,m.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var I=A(m,0);if(I.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(m.substr(I[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var B=A(m,I[1]);if(B.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(m.substr(B[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(_.algoid=b(m,B[0]),m.substr(B[1],2)=="06"&&(_.algparam=b(m,B[1])),m.substr(I[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return _.keyidx=y.getVidx(m,I[2]),_},getKeyFromPlainPrivatePKCS8PEM:function(m){var y=Tt(m,"PRIVATE KEY"),A=this.getKeyFromPlainPrivatePKCS8Hex(y);return A},getKeyFromPlainPrivatePKCS8Hex:function(m){var y=this.parsePlainPrivatePKCS8Hex(m),A;if(y.algoid=="2a864886f70d010101")A=new Ke;else if(y.algoid=="2a8648ce380401")A=new d.crypto.DSA;else if(y.algoid=="2a8648ce3d0201")A=new d.crypto.ECDSA;else throw new Error("unsupported private key algorithm");return A.readPKCS8PrvKeyHex(m),A},_getKeyFromPublicPKCS8Hex:function(m){var y,A=Ae.getVbyList(m,0,[0,0],"06");if(A==="2a864886f70d010101")y=new Ke;else if(A==="2a8648ce380401")y=new d.crypto.DSA;else if(A==="2a8648ce3d0201")y=new d.crypto.ECDSA;else throw new Error("unsupported PKCS#8 public key hex");return y.readPKCS8PubKeyHex(m),y},parsePublicRawRSAKeyHex:function(m){var y=Ae,A=y.getChildIdx,b=y.getV,_={};if(m.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var I=A(m,0);if(I.length!=2)throw new Error("malformed RSA key(code:002)");if(m.substr(I[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(_.n=b(m,I[0]),m.substr(I[1],2)!="02")throw new Error("malformed RSA key(code:004)");return _.e=b(m,I[1]),_},parsePublicPKCS8Hex:function(m){var y=Ae,A=y.getChildIdx,b=y.getV,_={};_.algparam=null;var I=A(m,0);if(I.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+I.length);var B=I[0];if(m.substr(B,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var j=A(m,B);if(j.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(m.substr(j[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(_.algoid=b(m,j[0]),m.substr(j[1],2)=="06"?_.algparam=b(m,j[1]):m.substr(j[1],2)=="30"&&(_.algparam={},_.algparam.p=y.getVbyList(m,j[1],[0],"02"),_.algparam.q=y.getVbyList(m,j[1],[1],"02"),_.algparam.g=y.getVbyList(m,j[1],[2],"02")),m.substr(I[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return _.key=b(m,I[1]).substr(2),_}}}();rt.getKey=function(e,t,r){var n=Ae,s=n.getChildIdx,a=n.getV,i=n.getVbyList,c=d.crypto,l=c.ECDSA,h=c.DSA,v=Ke,E=Tt,p=rt;if(typeof v<"u"&&e instanceof v||typeof l<"u"&&e instanceof l||typeof h<"u"&&e instanceof h)return e;if(e.curve!==void 0&&e.xy!==void 0&&e.d===void 0)return new l({pub:e.xy,curve:e.curve});if(e.curve!==void 0&&e.d!==void 0)return new l({prv:e.d,curve:e.curve});if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var f=new v;return f.setPublic(e.n,e.e),f}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p!==void 0&&e.q!==void 0&&e.dp!==void 0&&e.dq!==void 0&&e.co!==void 0&&e.qi===void 0){var f=new v;return f.setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),f}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p===void 0){var f=new v;return f.setPrivate(e.n,e.e,e.d),f}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x===void 0){var f=new h;return f.setPublic(e.p,e.q,e.g,e.y),f}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x!==void 0){var f=new h;return f.setPrivate(e.p,e.q,e.g,e.y,e.x),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var f=new v;return f.setPublic(It(e.n),It(e.e)),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p!==void 0&&e.q!==void 0&&e.dp!==void 0&&e.dq!==void 0&&e.qi!==void 0){var f=new v;return f.setPrivateEx(It(e.n),It(e.e),It(e.d),It(e.p),It(e.q),It(e.dp),It(e.dq),It(e.qi)),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var f=new v;return f.setPrivate(It(e.n),It(e.e),It(e.d)),f}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d===void 0){var w=new l({curve:e.crv}),m=w.ecparams.keycharlen,y=("0000000000"+It(e.x)).slice(-m),A=("0000000000"+It(e.y)).slice(-m),b="04"+y+A;return w.setPublicKeyHex(b),w}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d!==void 0){var w=new l({curve:e.crv}),m=w.ecparams.keycharlen,y=("0000000000"+It(e.x)).slice(-m),A=("0000000000"+It(e.y)).slice(-m),b="04"+y+A,_=("0000000000"+It(e.d)).slice(-m);return w.setPublicKeyHex(b),w.setPrivateKeyHex(_),w}if(r==="pkcs5prv"){var I=e,n=Ae,B,f;if(B=s(I,0),B.length===9)f=new v,f.readPKCS5PrvKeyHex(I);else if(B.length===6)f=new h,f.readPKCS5PrvKeyHex(I);else if(B.length>2&&I.substr(B[1],2)==="04")f=new l,f.readPKCS5PrvKeyHex(I);else throw new Error("unsupported PKCS#1/5 hexadecimal key");return f}if(r==="pkcs8prv"){var f=p.getKeyFromPlainPrivatePKCS8Hex(e);return f}if(r==="pkcs8pub")return p._getKeyFromPublicPKCS8Hex(e);if(r==="x509pub")return Ne.getPublicKeyFromCertHex(e);if(e.indexOf("-END CERTIFICATE-",0)!=-1||e.indexOf("-END X509 CERTIFICATE-",0)!=-1||e.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return Ne.getPublicKeyFromCertPEM(e);if(e.indexOf("-END PUBLIC KEY-")!=-1){var j=Tt(e,"PUBLIC KEY");return p._getKeyFromPublicPKCS8Hex(j)}if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var V=E(e,"RSA PRIVATE KEY");return p.getKey(V,null,"pkcs5prv")}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var F=E(e,"DSA PRIVATE KEY"),P=i(F,0,[1],"02"),k=i(F,0,[2],"02"),L=i(F,0,[3],"02"),M=i(F,0,[4],"02"),X=i(F,0,[5],"02"),f=new h;return f.setPrivate(new Z(P,16),new Z(k,16),new Z(L,16),new Z(M,16),new Z(X,16)),f}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var V=E(e,"EC PRIVATE KEY");return p.getKey(V,null,"pkcs5prv")}if(e.indexOf("-END PRIVATE KEY-")!=-1)return p.getKeyFromPlainPrivatePKCS8PEM(e);if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var K=p.getDecryptedKeyHex(e,t),q=new Ke;return q.readPKCS5PrvKeyHex(K),q}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var F=p.getDecryptedKeyHex(e,t),f=i(F,0,[1],"04"),Y=i(F,0,[2,0],"06"),re=i(F,0,[3,0],"03").substr(2),ye="";if(d.crypto.OID.oidhex2name[Y]!==void 0)ye=d.crypto.OID.oidhex2name[Y];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+Y);var w=new l({curve:ye});return w.setPublicKeyHex(re),w.setPrivateKeyHex(f),w.isPublic=!1,w}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var F=p.getDecryptedKeyHex(e,t),P=i(F,0,[1],"02"),k=i(F,0,[2],"02"),L=i(F,0,[3],"02"),M=i(F,0,[4],"02"),X=i(F,0,[5],"02"),f=new h;return f.setPrivate(new Z(P,16),new Z(k,16),new Z(L,16),new Z(M,16),new Z(X,16)),f}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return p.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};rt.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new Ke;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var s=new Ke,a=n.n.toString(16),i=n.e.toString(16);s.setPublic(a,i),s.isPrivate=!1,s.isPublic=!0;var c={};return c.prvKeyObj=n,c.pubKeyObj=s,c}else if(e=="EC"){var l=t,h=new d.crypto.ECDSA({curve:l}),v=h.generateKeyPairHex(),n=new d.crypto.ECDSA({curve:l});n.setPublicKeyHex(v.ecpubhex),n.setPrivateKeyHex(v.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var s=new d.crypto.ECDSA({curve:l});s.setPublicKeyHex(v.ecpubhex),s.isPrivate=!1,s.isPublic=!0;var c={};return c.prvKeyObj=n,c.pubKeyObj=s,c}else throw new Error("unknown algorithm: "+e)};rt.getPEM=function(e,t,r,n,s,a){var i=d,c=i.asn1,l=c.DERObjectIdentifier,h=c.DERInteger,v=c.ASN1Util.newObject,E=c.x509,p=E.SubjectPublicKeyInfo,f=i.crypto,w=f.DSA,m=f.ECDSA,y=Ke;function A(q){var Y=v({seq:[{int:0},{int:{bigint:q.n}},{int:q.e},{int:{bigint:q.d}},{int:{bigint:q.p}},{int:{bigint:q.q}},{int:{bigint:q.dmp1}},{int:{bigint:q.dmq1}},{int:{bigint:q.coeff}}]});return Y}function b(q){var Y=v({seq:[{int:1},{octstr:{hex:q.prvKeyHex}},{tag:["a0",!0,{oid:{name:q.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+q.pubKeyHex}}]}]});return Y}function _(q){var Y=v({seq:[{int:0},{int:{bigint:q.p}},{int:{bigint:q.q}},{int:{bigint:q.g}},{int:{bigint:q.y}},{int:{bigint:q.x}}]});return Y}if((y!==void 0&&e instanceof y||w!==void 0&&e instanceof w||m!==void 0&&e instanceof m)&&e.isPublic==!0&&(t===void 0||t=="PKCS8PUB")){var I=new p(e),B=I.tohex();return Dr(B,"PUBLIC KEY")}if(t=="PKCS1PRV"&&y!==void 0&&e instanceof y&&(r===void 0||r==null)&&e.isPrivate==!0){var I=A(e),B=I.tohex();return Dr(B,"RSA PRIVATE KEY")}if(t=="PKCS1PRV"&&m!==void 0&&e instanceof m&&(r===void 0||r==null)&&e.isPrivate==!0){var j=new l({name:e.curveName}),V=j.tohex(),F=b(e),P=F.tohex(),k="";return k+=Dr(V,"EC PARAMETERS"),k+=Dr(P,"EC PRIVATE KEY"),k}if(t=="PKCS1PRV"&&w!==void 0&&e instanceof w&&(r===void 0||r==null)&&e.isPrivate==!0){var I=_(e),B=I.tohex();return Dr(B,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&y!==void 0&&e instanceof y&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=A(e),B=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",B,r,n,a)}if(t=="PKCS5PRV"&&m!==void 0&&e instanceof m&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=b(e),B=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",B,r,n,a)}if(t=="PKCS5PRV"&&w!==void 0&&e instanceof w&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=_(e),B=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",B,r,n,a)}var L=function(q,Y){if(typeof Y=="string")return rt.getEncryptedPKCS8PEM(q,Y);if(typeof Y=="object"&&St(Y,"passcode")!=null){var re=JSON.parse(JSON.stringify(Y)),ye=re.passcode;return delete re.passcode,rt.getEncryptedPKCS8PEM(q,ye,re)}};if(t=="PKCS8PRV"&&y!=null&&e instanceof y&&e.isPrivate==!0){var M=A(e),X=M.tohex(),I=v({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:X}}]}),B=I.tohex();return r===void 0||r==null?Dr(B,"PRIVATE KEY"):L(B,r)}if(t=="PKCS8PRV"&&m!==void 0&&e instanceof m&&e.isPrivate==!0){var K={seq:[{int:1},{octstr:{hex:e.prvKeyHex}}]};typeof e.pubKeyHex=="string"&&K.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]});var M=new v(K),X=M.tohex(),I=v({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:X}}]}),B=I.tohex();return r===void 0||r==null?Dr(B,"PRIVATE KEY"):L(B,r)}if(t=="PKCS8PRV"&&w!==void 0&&e instanceof w&&e.isPrivate==!0){var M=new h({bigint:e.x}),X=M.tohex(),I=v({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:X}}]}),B=I.tohex();return r===void 0||r==null?Dr(B,"PRIVATE KEY"):L(B,r)}throw new Error("unsupported object nor format")};rt.getKeyFromCSRPEM=function(e){var t=Tt(e,"CERTIFICATE REQUEST"),r=rt.getKeyFromCSRHex(t);return r};rt.getKeyFromCSRHex=function(e){var t=rt.parseCSRHex(e),r=rt.getKey(t.p8pubkeyhex,null,"pkcs8pub");return r};rt.parseCSRHex=function(e){var t=Ae,r=t.getChildIdx,n=t.getTLV,s={},a=e;if(a.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var i=r(a,0);if(i.length<1)throw new Error("malformed CSR(code:002)");if(a.substr(i[0],2)!="30")throw new Error("malformed CSR(code:003)");var c=r(a,i[0]);if(c.length<3)throw new Error("malformed CSR(code:004)");return s.p8pubkeyhex=n(a,c[2]),s};rt.getKeyID=function(e){var t=rt,r=Ae;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=Tt(t.getPEM(e)),s=r.getIdxbyList(n,0,[1]),a=r.getV(n,s).substring(2);return d.crypto.Util.hashHex(a,"sha1")};rt.getJWK=function(e,t,r,n,s){var a,i={},c,l=d.crypto.Util.hashHex;if(typeof e=="string")a=rt.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(c=Tt(e));else if(typeof e=="object")e instanceof Ne?(a=e.getPublicKey(),c=e.hex):a=e;else throw new Error("unsupported keyinfo type");if(a instanceof Ke&&a.isPrivate)i.kty="RSA",i.n=Qt(a.n.toString(16)),i.e=Qt(a.e.toString(16)),i.d=Qt(a.d.toString(16)),i.p=Qt(a.p.toString(16)),i.q=Qt(a.q.toString(16)),i.dp=Qt(a.dmp1.toString(16)),i.dq=Qt(a.dmq1.toString(16)),i.qi=Qt(a.coeff.toString(16));else if(a instanceof Ke&&a.isPublic)i.kty="RSA",i.n=Qt(a.n.toString(16)),i.e=Qt(a.e.toString(16));else if(a instanceof d.crypto.ECDSA&&a.isPrivate){var h=a.getShortNISTPCurveName();if(h!=="P-256"&&h!=="P-384"&&h!=="P-521")throw new Error("unsupported curve name for JWT: "+h);var v=a.getPublicKeyXYHex();i.kty="EC",i.crv=h,i.x=Qt(v.x),i.y=Qt(v.y),i.d=Qt(a.prvKeyHex)}else if(a instanceof d.crypto.ECDSA&&a.isPublic){var h=a.getShortNISTPCurveName();if(h!=="P-256"&&h!=="P-384"&&h!=="P-521")throw new Error("unsupported curve name for JWT: "+h);var v=a.getPublicKeyXYHex();i.kty="EC",i.crv=h,i.x=Qt(v.x),i.y=Qt(v.y)}if(i.kty==null)throw new Error("unsupported keyinfo");return!a.isPrivate&&t!=!0&&(i.kid=d.jws.JWS.getJWKthumbprint(i)),c!=null&&r!=!0&&(i.x5c=[Qi(c)]),c!=null&&n!=!0&&(i.x5t=Ou(Qi(l(c,"sha1")))),c!=null&&s!=!0&&(i["x5t#S256"]=Ou(Qi(l(c,"sha256")))),i};rt.getJWKFromKey=function(e){return rt.getJWK(e,!0,!0,!0,!0)};Ke.getPosArrayOfChildrenFromHex=function(e){return Ae.getChildIdx(e,0)};Ke.getHexValueArrayOfChildrenFromHex=function(e){var t=Ae,r=t.getV,p=Ke.getPosArrayOfChildrenFromHex(e),n=r(e,p[0]),s=r(e,p[1]),a=r(e,p[2]),i=r(e,p[3]),c=r(e,p[4]),l=r(e,p[5]),h=r(e,p[6]),v=r(e,p[7]),E=r(e,p[8]),p=new Array;return p.push(n,s,a,i,c,l,h,v,E),p};Ke.prototype.readPrivateKeyFromPEMString=function(e){var t=Tt(e),r=Ke.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};Ke.prototype.readPKCS5PrvKeyHex=function(e){var t=Ke.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};Ke.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,s,a,i,c,l,h=Ae,v=h.getVbyListEx;if(h.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");try{t=v(e,0,[2,0,1],"02"),r=v(e,0,[2,0,2],"02"),n=v(e,0,[2,0,3],"02"),s=v(e,0,[2,0,4],"02"),a=v(e,0,[2,0,5],"02"),i=v(e,0,[2,0,6],"02"),c=v(e,0,[2,0,7],"02"),l=v(e,0,[2,0,8],"02")}catch{throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,s,a,i,c,l)};Ke.prototype.readPKCS5PubKeyHex=function(e){var t=Ae,r=t.getV;if(t.isASN1HEX(e)===!1)throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(n.length!==2||e.substr(n[0],2)!=="02"||e.substr(n[1],2)!=="02")throw new Error("wrong hex for PKCS#5 public key");var s=r(e,n[0]),a=r(e,n[1]);this.setPublic(s,a)};Ke.prototype.readPKCS8PubKeyHex=function(e){var t=Ae;if(t.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");if(t.getTLVbyListEx(e,0,[0,0])!=="06092a864886f70d010101")throw new Error("not PKCS8 RSA public key");var r=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(r)};Ke.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new Ne,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var $7=new RegExp("[^0-9a-f]","gi");function Ng(e,t){for(var r="",n=t/4-e.length,s=0;s>24,(s&16711680)>>16,(s&65280)>>8,s&255])))),s+=1;return n}Ke.prototype.signPSS=function(e,t,r){var n=function(a){return d.crypto.Util.hashHex(a,t)},s=n(pi(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(s,t,r)};Ke.prototype.signWithMessageHashPSS=function(e,t,r){var n=un(e),s=n.length,a=this.n.bitLength()-1,i=Math.ceil(a/8),c,l=function(y){return d.crypto.Util.hashHex(y,t)};if(r===-1||r===void 0)r=s;else if(r===-2)r=i-s-2;else if(r<-2)throw new Error("invalid salt length");if(i0&&(h=new Array(r),new Uu().nextBytes(h),h=String.fromCharCode.apply(String,h));var v=un(l(pi("\0\0\0\0\0\0\0\0"+n+h))),E=[];for(c=0;c>8*i-a&255;for(w[0]&=~m,c=0;cn)return!1;var s=this.doPublic(r),a=s.toString(16);if(a.length+3!=n/4)return!1;var i=a.replace(/^1f+00/,""),c=Ug(i);if(c.length==0)return!1;var l=c[0],h=c[1],v=function(p){return d.crypto.Util.hashString(p,l)},E=v(e);return h==E};Ke.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=sn(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),s=n.toString(16).replace(/^1f+00/,""),a=Ug(s);if(a.length==0)return!1;var i=a[0],c=a[1];return c==e};Ke.prototype.verifyPSS=function(e,t,r,n){var s=function(i){return d.crypto.Util.hashHex(i,r)},a=s(pi(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(a,t,r,n)};Ke.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var s=new Z(t,16),a=function(b){return d.crypto.Util.hashHex(b,r)},i=un(e),c=i.length,l=this.n.bitLength()-1,h=Math.ceil(l/8),v;if(n===-1||n===void 0)n=c;else if(n===-2)n=h-c-2;else if(n<-2)throw new Error("invalid salt length");if(h>8*h-l&255;if(p.charCodeAt(0)&w)throw new Error("bits beyond keysize not zero");var m=Lg(f,p.length,a),y=[];for(v=0;v0?P:void 0}catch{return}},this._asn1ToNoticeRef=function(F){try{for(var P={},k=St(F,"seq"),L=0;L0?P:void 0}catch{return}},this._asn1ToNoticeNum=function(F){try{for(var P=St(F,"seq"),k=[],L=0;L1){var X=i(F,M[1]),K=this.getGeneralName(X);K.uri!=null&&(L.uri=K.uri)}if(M.length>2){var q=i(F,M[2]);q=="0101ff"&&(L.reqauth=!0),q=="010100"&&(L.reqauth=!1)}return L},this.getExtSubjectDirectoryAttributes=function(F,P){if(F===void 0&&P===void 0){var k=this.getExtInfo("subjectDirectoryAttributes");if(k===void 0)return;F=i(this.hex,k.vidx),P=k.critical}var L={extname:"subjectDirectoryAttributes"};P&&(L.critical=!0);try{for(var M=a(F),X=[],K=0;K0&&(P.ext=this.getExtParamArray()),P.sighex=this.getSignatureValueHex(),F.tbshex==!0&&(P.tbshex=h(this.hex,0,[0])),F.nodnarray==!0&&(delete P.issuer.array,delete P.subject.array),P},this.getExtParamArray=function(F){if(F==null){var P=p(this.hex,0,[0,"[3]"]);P!=-1&&(F=v(this.hex,0,[0,"[3]",0],"30"))}for(var k=[],L=r(F,0),M=0;M"u"||!d)&&(d={});(typeof d.jws>"u"||!d.jws)&&(d.jws={});d.jws.JWS=function(){var e=d,t=e.jws.JWS,r=t.isSafeJSONString;this.parseJWS=function(n,s){if(!(this.parsedJWS!==void 0&&(s||this.parsedJWS.sigvalH!==void 0))){var a=n.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(a==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var i=a[1],c=a[2],l=a[3],h=i+"."+c;if(this.parsedJWS={},this.parsedJWS.headB64U=i,this.parsedJWS.payloadB64U=c,this.parsedJWS.sigvalB64U=l,this.parsedJWS.si=h,!s){var v=It(l),E=sn(v,16);this.parsedJWS.sigvalH=v,this.parsedJWS.sigvalBI=E}var p=Xn(i),f=Xn(c);if(this.parsedJWS.headS=p,this.parsedJWS.payloadS=f,!r(p,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+p}}};d.jws.JWS.sign=function(e,t,r,n,s){var a=d,i=a.jws,c=i.JWS,l=c.readSafeJSONString,h=c.isSafeJSONString,v=a.crypto,E=v.ECDSA,p=v.Mac,f=v.Signature,w=JSON,m,y,A;if(typeof t!="string"&&typeof t!="object")throw"spHeader must be JSON string or object: "+t;if(typeof t=="object"&&(y=t,m=w.stringify(y)),typeof t=="string"){if(m=t,!h(m))throw"JWS Head is not safe JSON string: "+m;y=l(m)}if(A=r,typeof r=="object"&&(A=w.stringify(r)),(e==""||e==null)&&y.alg!==void 0&&(e=y.alg),e!=""&&e!=null&&y.alg===void 0&&(y.alg=e,m=w.stringify(y)),e!==y.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+y.alg;var b=null;if(c.jwsalg2sigalg[e]===void 0)throw"unsupported alg name: "+e;b=c.jwsalg2sigalg[e];var _=ic(m),I=ic(A),B=_+"."+I,j="";if(b.substr(0,4)=="Hmac"){if(n===void 0)throw"mac key shall be specified for HS* alg";var V=new p({alg:b,prov:"cryptojs",pass:n});V.updateString(B),j=V.doFinal()}else if(b.indexOf("withECDSA")!=-1){var F=new f({alg:b});F.init(n,s),F.updateString(B);var P=F.sign();j=d.crypto.ECDSA.asn1SigToConcatSig(P)}else if(b!="none"){var F=new f({alg:b});F.init(n,s),F.updateString(B),j=F.sign()}var k=Qt(j);return B+"."+k};d.jws.JWS.verify=function(e,t,r){var n=d,s=n.jws,a=s.JWS,i=a.readSafeJSONString,c=n.crypto,l=c.ECDSA,h=c.Mac,v=c.Signature,E;if(typeof Ke!==void 0&&(E=Ke),!kp(e))return!1;var p=e.split(".");if(p.length!==3)return!1;var f=p[0],w=p[1],m=f+"."+w,y=It(p[2]),A=i(Xn(p[0])),b=null,_=null;if(A.alg===void 0)throw"algorithm not specified in header";if(b=A.alg,_=b.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var I=":"+r.join(":")+":";if(I.indexOf(":"+b+":")==-1)throw"algorithm '"+b+"' not accepted in the list"}if(b!="none"&&t===null)throw"key shall be specified to verify.";if(typeof t=="string"&&t.indexOf("-----BEGIN ")!=-1&&(t=rt.getKey(t)),(_=="RS"||_=="PS")&&!(t instanceof E))throw"key shall be a RSAKey obj for RS* and PS* algs";if(_=="ES"&&!(t instanceof l))throw"key shall be a ECDSA obj for ES* algs";b=="none";var B=null;if(a.jwsalg2sigalg[A.alg]===void 0)throw"unsupported alg name: "+b;if(B=a.jwsalg2sigalg[b],B=="none")throw"not supported";if(B.substr(0,4)=="Hmac"){var j=null;if(t===void 0)throw"hexadecimal key shall be specified for HMAC";var V=new h({alg:B,pass:t});return V.updateString(m),j=V.doFinal(),y==j}else if(B.indexOf("withECDSA")!=-1){var F=null;try{F=l.concatSigToASN1Sig(y)}catch{return!1}var P=new v({alg:B});return P.init(t),P.updateString(m),P.verify(F)}else{var P=new v({alg:B});return P.init(t),P.updateString(m),P.verify(y)}};d.jws.JWS.parse=function(e){var t=e.split("."),r={},n,s,a;if(t.length!=2&&t.length!=3)throw"malformed sJWS: wrong number of '.' splitted elements";return n=t[0],s=t[1],t.length==3&&(a=t[2]),r.headerObj=d.jws.JWS.readSafeJSONString(Xn(n)),r.payloadObj=d.jws.JWS.readSafeJSONString(Xn(s)),r.headerPP=JSON.stringify(r.headerObj,null," "),r.payloadObj==null?r.payloadPP=Xn(s):r.payloadPP=JSON.stringify(r.payloadObj,null," "),a!==void 0&&(r.sigHex=It(a)),r};d.jws.JWS.verifyJWT=function(e,t,r){var n=d,s=n.jws,a=s.JWS,i=a.readSafeJSONString,c=a.inArray,l=a.includedArray;if(!kp(e))return!1;var h=e.split(".");if(h.length!=3)return!1;var v=h[0],E=h[1],p=v+"."+E,f=It(h[2]),w=i(Xn(v)),m=i(Xn(E));if(w.alg===void 0)return!1;if(r.alg===void 0)throw"acceptField.alg shall be specified";if(!c(w.alg,r.alg)||m.iss!==void 0&&typeof r.iss=="object"&&!c(m.iss,r.iss)||m.sub!==void 0&&typeof r.sub=="object"&&!c(m.sub,r.sub))return!1;if(m.aud!==void 0&&typeof r.aud=="object"){if(typeof m.aud=="string"){if(!c(m.aud,r.aud))return!1}else if(typeof m.aud=="object"&&!l(m.aud,r.aud))return!1}var y=s.IntDate.getNow();return r.verifyAt!==void 0&&typeof r.verifyAt=="number"&&(y=r.verifyAt),(r.gracePeriod===void 0||typeof r.gracePeriod!="number")&&(r.gracePeriod=0),!(m.exp!==void 0&&typeof m.exp=="number"&&m.exp+r.gracePeriod"u"||!d)&&(d={});(typeof d.jws>"u"||!d.jws)&&(d.jws={});d.jws.JWSJS=function(){var e=d,t=e.jws,r=t.JWS,n=r.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(s){this.init();var a=s.split(".");if(a.length!=3)throw"malformed input JWS";this.aHeader.push(a[0]),this.sPayload=a[1],this.aSignature.push(a[2])},this.addSignature=function(s,a,i,c){if(this.sPayload===void 0||this.sPayload===null)throw"there's no JSON-JS signature to add.";var l=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var h=d.jws.JWS.sign(s,a,this.sPayload,i,c),v=h.split("."),E=v[0],p=v[2];this.aHeader.push(v[0]),this.aSignature.push(v[2])}catch(f){throw this.aHeader.length>l&&this.aHeader.pop(),this.aSignature.length>l&&this.aSignature.pop(),"addSignature failed: "+f}},this.verifyAll=function(s){if(this.aHeader.length!==s.length||this.aSignature.length!==s.length)return!1;for(var a=0;a0)this.aHeader=s.headers;else throw"malformed header";if(typeof s.payload=="string")this.sPayload=s.payload;else throw"malformed signatures";if(s.signatures.length>0)this.aSignature=s.signatures;else throw"malformed signatures"}catch(i){throw"malformed JWS-JS JSON object: "+i}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return this.aHeader.length==0?1:0}};Ee.SecureRandom=Uu;Ee.rng_seed_time=$p;Ee.BigInteger=Z;Ee.RSAKey=Ke;Ee.ECDSA=d.crypto.ECDSA;Ee.DSA=d.crypto.DSA;Ee.Signature=d.crypto.Signature;Ee.MessageDigest=d.crypto.MessageDigest;Ee.Mac=d.crypto.Mac;Ee.KEYUTIL=rt;Ee.ASN1HEX=Ae;Ee.X509=Ne;Ee.X509CRL=MC;Ee.CryptoJS=Se;Ee.b64tohex=ku;Ee.b64toBA=Eg;Ee.ECFieldElementFp=er;Ee.ECPointFp=lt;Ee.ECCurveFp=es;Ee.stoBA=_g;Ee.BAtos=Ig;Ee.BAtohex=Ul;Ee.stohex=an;Ee.stob64=SC;Ee.stob64u=bC;Ee.b64utos=CC;Ee.b64tob64u=Ou;Ee.b64utob64=ac;Ee.hex2b64=Qi;Ee.hextob64u=Qt;Ee.b64utohex=It;Ee.utf8tob64u=ic;Ee.b64utoutf8=Xn;Ee.utf8tob64=FC;Ee.b64toutf8=_C;Ee.utf8tohex=Hl;Ee.hextoutf8=vt;Ee.hextorstr=un;Ee.rstrtohex=pi;Ee.hextob64=Rp;Ee.hextob64nl=BC;Ee.b64nltohex=Dg;Ee.hextopem=Dr;Ee.pemtohex=Tt;Ee.hextoArrayBuffer=RC;Ee.ArrayBuffertohex=TC;Ee.zulutomsec=Tp;Ee.msectozulu=xC;Ee.zulutosec=Bg;Ee.zulutodate=OC;Ee.datetozulu=kC;Ee.uricmptohex=Ml;Ee.hextouricmp=ql;Ee.ipv6tohex=Fp;Ee.hextoipv6=_p;Ee.hextoip=xl;Ee.iptohex=xp;Ee.ucs2hextoutf8=Op;Ee.encodeURIComponentAll=Kl;Ee.newline_toUnix=NC;Ee.newline_toDos=LC;Ee.hextoposhex=Ip;Ee.intarystrtohex=UC;Ee.strdiffidx=HC;Ee.oidtohex=Rg;Ee.hextooid=Vl;Ee.strpad=Ol;Ee.bitstrtoint=xg;Ee.inttobitstr=Og;Ee.bitstrtobinstr=kg;Ee.binstrtobitstr=jC;Ee.isBase64URLDot=kp;Ee.namearraytobinstr=kl;Ee.extendClass=fe;Ee.foldnl=jl;Ee.b64topem=PC;Ee.pemtob64=$C;Ee.timeogen=Pg;Ee.aryval=St;Ee.inttohex=Tg;Ee.twoscompl=uc;Ee.KJUR=d;Ee.crypto=d.crypto;Ee.asn1=d.asn1;Ee.jws=d.jws;Ee.lang=d.lang;Ee.VERSION=J3;Ee.VERSION_FULL=Z3});var Ba=be((x7,Da)=>{"use strict";function Mg(e){return typeof e>"u"||e===null}function KC(e){return typeof e=="object"&&e!==null}function VC(e){return Array.isArray(e)?e:Mg(e)?[]:[e]}function GC(e,t){var r,n,s,a;if(t)for(a=Object.keys(t),r=0,n=a.length;r{"use strict";function oc(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}oc.prototype=Object.create(Error.prototype);oc.prototype.constructor=oc;oc.prototype.toString=function(t){var r=this.name+": ";return r+=this.reason||"(unknown reason)",!t&&this.mark&&(r+=" "+this.mark.toString()),r};qg.exports=oc});var Gg=be((k7,Vg)=>{"use strict";var Kg=Ba();function Lp(e,t,r,n,s){this.name=e,this.buffer=t,this.position=r,this.line=n,this.column=s}Lp.prototype.getSnippet=function(t,r){var n,s,a,i,c;if(!this.buffer)return null;for(t=t||4,r=r||75,n="",s=this.position;s>0&&`\0\r \x85\u2028\u2029`.indexOf(this.buffer.charAt(s-1))===-1;)if(s-=1,this.position-s>r/2-1){n=" ... ",s+=5;break}for(a="",i=this.position;ir/2-1){a=" ... ",i-=5;break}return c=this.buffer.slice(s,i),Kg.repeat(" ",t)+n+c+a+` `+Kg.repeat(" ",t+this.position-s+n.length)+"^"};Lp.prototype.toString=function(t){var r,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),t||(r=this.getSnippet(),r&&(n+=`: `+r)),n};Vg.exports=Lp});var tr=be((N7,Yg)=>{"use strict";var zg=Hu(),WC=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],XC=["scalar","sequence","mapping"];function JC(e){var t={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(n){t[String(n)]=r})}),t}function ZC(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(WC.indexOf(r)===-1)throw new zg('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(r){return r},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=JC(t.styleAliases||null),XC.indexOf(this.kind)===-1)throw new zg('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}Yg.exports=ZC});var Pa=be((L7,Xg)=>{"use strict";var Wg=Ba(),Gl=Hu(),QC=tr();function Up(e,t,r){var n=[];return e.include.forEach(function(s){r=Up(s,t,r)}),e[t].forEach(function(s){r.forEach(function(a,i){a.tag===s.tag&&a.kind===s.kind&&n.push(i)}),r.push(s)}),r.filter(function(s,a){return n.indexOf(a)===-1})}function eF(){var e={scalar:{},sequence:{},mapping:{},fallback:{}},t,r;function n(s){e[s.kind][s.tag]=e.fallback[s.tag]=s}for(t=0,r=arguments.length;t{"use strict";var tF=tr();Jg.exports=new tF("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var em=be((H7,Qg)=>{"use strict";var rF=tr();Qg.exports=new rF("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var rm=be((j7,tm)=>{"use strict";var nF=tr();tm.exports=new nF("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var zl=be((M7,nm)=>{"use strict";var iF=Pa();nm.exports=new iF({explicit:[Zg(),em(),rm()]})});var sm=be((q7,im)=>{"use strict";var sF=tr();function aF(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function uF(){return null}function oF(e){return e===null}im.exports=new sF("tag:yaml.org,2002:null",{kind:"scalar",resolve:aF,construct:uF,predicate:oF,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var um=be((K7,am)=>{"use strict";var cF=tr();function lF(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function fF(e){return e==="true"||e==="True"||e==="TRUE"}function hF(e){return Object.prototype.toString.call(e)==="[object Boolean]"}am.exports=new cF("tag:yaml.org,2002:bool",{kind:"scalar",resolve:lF,construct:fF,predicate:hF,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})});var cm=be((V7,om)=>{"use strict";var pF=Ba(),dF=tr();function gF(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function mF(e){return 48<=e&&e<=55}function vF(e){return 48<=e&&e<=57}function AF(e){if(e===null)return!1;var t=e.length,r=0,n=!1,s;if(!t)return!1;if(s=e[r],(s==="-"||s==="+")&&(s=e[++r]),s==="0"){if(r+1===t)return!0;if(s=e[++r],s==="b"){for(r++;r=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var hm=be((G7,fm)=>{"use strict";var lm=Ba(),yF=tr(),SF=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function bF(e){return!(e===null||!SF.test(e)||e[e.length-1]==="_")}function CF(e){var t,r,n,s;return t=e.replace(/_/g,"").toLowerCase(),r=t[0]==="-"?-1:1,s=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:t.indexOf(":")>=0?(t.split(":").forEach(function(a){s.unshift(parseFloat(a,10))}),t=0,n=1,s.forEach(function(a){t+=a*n,n*=60}),r*t):r*parseFloat(t,10)}var FF=/^[-+]?[0-9]+e/;function _F(e,t){var r;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(lm.isNegativeZero(e))return"-0.0";return r=e.toString(10),FF.test(r)?r.replace("e",".e"):r}function IF(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||lm.isNegativeZero(e))}fm.exports=new yF("tag:yaml.org,2002:float",{kind:"scalar",resolve:bF,construct:CF,predicate:IF,represent:_F,defaultStyle:"lowercase"})});var Hp=be((z7,pm)=>{"use strict";var DF=Pa();pm.exports=new DF({include:[zl()],implicit:[sm(),um(),cm(),hm()]})});var jp=be((Y7,dm)=>{"use strict";var BF=Pa();dm.exports=new BF({include:[Hp()]})});var Am=be((W7,vm)=>{"use strict";var PF=tr(),gm=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),mm=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function $F(e){return e===null?!1:gm.exec(e)!==null||mm.exec(e)!==null}function RF(e){var t,r,n,s,a,i,c,l=0,h=null,v,E,p;if(t=gm.exec(e),t===null&&(t=mm.exec(e)),t===null)throw new Error("Date resolve error");if(r=+t[1],n=+t[2]-1,s=+t[3],!t[4])return new Date(Date.UTC(r,n,s));if(a=+t[4],i=+t[5],c=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(v=+t[10],E=+(t[11]||0),h=(v*60+E)*6e4,t[9]==="-"&&(h=-h)),p=new Date(Date.UTC(r,n,s,a,i,c,l)),h&&p.setTime(p.getTime()-h),p}function TF(e){return e.toISOString()}vm.exports=new PF("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:$F,construct:RF,instanceOf:Date,represent:TF})});var Em=be((X7,wm)=>{"use strict";var xF=tr();function OF(e){return e==="<<"||e===null}wm.exports=new xF("tag:yaml.org,2002:merge",{kind:"scalar",resolve:OF})});var bm=be((J7,Sm)=>{"use strict";var $a;try{ym=ba,$a=ym("buffer").Buffer}catch{}var ym,kF=tr(),Mp=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= \r`;function NF(e){if(e===null)return!1;var t,r,n=0,s=e.length,a=Mp;for(r=0;r64)){if(t<0)return!1;n+=6}return n%8===0}function LF(e){var t,r,n=e.replace(/[\r\n=]/g,""),s=n.length,a=Mp,i=0,c=[];for(t=0;t>16&255),c.push(i>>8&255),c.push(i&255)),i=i<<6|a.indexOf(n.charAt(t));return r=s%4*6,r===0?(c.push(i>>16&255),c.push(i>>8&255),c.push(i&255)):r===18?(c.push(i>>10&255),c.push(i>>2&255)):r===12&&c.push(i>>4&255),$a?$a.from?$a.from(c):new $a(c):c}function UF(e){var t="",r=0,n,s,a=e.length,i=Mp;for(n=0;n>18&63],t+=i[r>>12&63],t+=i[r>>6&63],t+=i[r&63]),r=(r<<8)+e[n];return s=a%3,s===0?(t+=i[r>>18&63],t+=i[r>>12&63],t+=i[r>>6&63],t+=i[r&63]):s===2?(t+=i[r>>10&63],t+=i[r>>4&63],t+=i[r<<2&63],t+=i[64]):s===1&&(t+=i[r>>2&63],t+=i[r<<4&63],t+=i[64],t+=i[64]),t}function HF(e){return $a&&$a.isBuffer(e)}Sm.exports=new kF("tag:yaml.org,2002:binary",{kind:"scalar",resolve:NF,construct:LF,predicate:HF,represent:UF})});var Fm=be((Q7,Cm)=>{"use strict";var jF=tr(),MF=Object.prototype.hasOwnProperty,qF=Object.prototype.toString;function KF(e){if(e===null)return!0;var t=[],r,n,s,a,i,c=e;for(r=0,n=c.length;r{"use strict";var GF=tr(),zF=Object.prototype.toString;function YF(e){if(e===null)return!0;var t,r,n,s,a,i=e;for(a=new Array(i.length),t=0,r=i.length;t{"use strict";var XF=tr(),JF=Object.prototype.hasOwnProperty;function ZF(e){if(e===null)return!0;var t,r=e;for(t in r)if(JF.call(r,t)&&r[t]!==null)return!1;return!0}function QF(e){return e!==null?e:{}}Dm.exports=new XF("tag:yaml.org,2002:set",{kind:"mapping",resolve:ZF,construct:QF})});var Mu=be((rP,Pm)=>{"use strict";var e8=Pa();Pm.exports=new e8({include:[jp()],implicit:[Am(),Em()],explicit:[bm(),Fm(),Im(),Bm()]})});var Rm=be((nP,$m)=>{"use strict";var t8=tr();function r8(){return!0}function n8(){}function i8(){return""}function s8(e){return typeof e>"u"}$m.exports=new t8("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:r8,construct:n8,predicate:s8,represent:i8})});var xm=be((iP,Tm)=>{"use strict";var a8=tr();function u8(e){if(e===null||e.length===0)return!1;var t=e,r=/\/([gim]*)$/.exec(e),n="";return!(t[0]==="/"&&(r&&(n=r[1]),n.length>3||t[t.length-n.length-1]!=="/"))}function o8(e){var t=e,r=/\/([gim]*)$/.exec(e),n="";return t[0]==="/"&&(r&&(n=r[1]),t=t.slice(1,t.length-n.length-1)),new RegExp(t,n)}function c8(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}function l8(e){return Object.prototype.toString.call(e)==="[object RegExp]"}Tm.exports=new a8("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:u8,construct:o8,predicate:l8,represent:c8})});var Nm=be((sP,km)=>{"use strict";var Yl;try{Om=ba,Yl=Om("esprima")}catch{typeof window<"u"&&(Yl=window.esprima)}var Om,f8=tr();function h8(e){if(e===null)return!1;try{var t="("+e+")",r=Yl.parse(t,{range:!0});return!(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")}catch{return!1}}function p8(e){var t="("+e+")",r=Yl.parse(t,{range:!0}),n=[],s;if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")throw new Error("Failed to resolve function");return r.body[0].expression.params.forEach(function(a){n.push(a.name)}),s=r.body[0].expression.body.range,r.body[0].expression.body.type==="BlockStatement"?new Function(n,t.slice(s[0]+1,s[1]-1)):new Function(n,"return "+t.slice(s[0],s[1]))}function d8(e){return e.toString()}function g8(e){return Object.prototype.toString.call(e)==="[object Function]"}km.exports=new f8("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:h8,construct:p8,predicate:g8,represent:d8})});var cc=be((uP,Um)=>{"use strict";var Lm=Pa();Um.exports=Lm.DEFAULT=new Lm({include:[Mu()],explicit:[Rm(),xm(),Nm()]})});var iv=be((oP,lc)=>{"use strict";var ts=Ba(),Gm=Hu(),m8=Gg(),zm=Mu(),v8=cc(),Hs=Object.prototype.hasOwnProperty,Wl=1,Ym=2,Wm=3,Xl=4,qp=1,A8=2,Hm=3,w8=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,E8=/[\x85\u2028\u2029]/,y8=/[,\[\]\{\}]/,Xm=/^(?:!|!!|![a-z\-]+!)$/i,Jm=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function jm(e){return Object.prototype.toString.call(e)}function di(e){return e===10||e===13}function Ta(e){return e===9||e===32}function on(e){return e===9||e===32||e===10||e===13}function qu(e){return e===44||e===91||e===93||e===123||e===125}function S8(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function b8(e){return e===120?2:e===117?4:e===85?8:0}function C8(e){return 48<=e&&e<=57?e-48:-1}function Mm(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?` `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function F8(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var Zm=new Array(256),Qm=new Array(256);for(Ra=0;Ra<256;Ra++)Zm[Ra]=Mm(Ra)?1:0,Qm[Ra]=Mm(Ra);var Ra;function _8(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||v8,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function ev(e,t){return new Gm(t,new m8(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function Ue(e,t){throw ev(e,t)}function Jl(e,t){e.onWarning&&e.onWarning.call(null,ev(e,t))}var qm={YAML:function(t,r,n){var s,a,i;t.version!==null&&Ue(t,"duplication of %YAML directive"),n.length!==1&&Ue(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),s===null&&Ue(t,"ill-formed argument of the YAML directive"),a=parseInt(s[1],10),i=parseInt(s[2],10),a!==1&&Ue(t,"unacceptable YAML version of the document"),t.version=n[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&Jl(t,"unsupported YAML version of the document")},TAG:function(t,r,n){var s,a;n.length!==2&&Ue(t,"TAG directive accepts exactly two arguments"),s=n[0],a=n[1],Xm.test(s)||Ue(t,"ill-formed tag handle (first argument) of the TAG directive"),Hs.call(t.tagMap,s)&&Ue(t,'there is a previously declared suffix for "'+s+'" tag handle'),Jm.test(a)||Ue(t,"ill-formed tag prefix (second argument) of the TAG directive"),t.tagMap[s]=a}};function Us(e,t,r,n){var s,a,i,c;if(t1&&(e.result+=ts.repeat(` `,t-1))}function I8(e,t,r){var n,s,a,i,c,l,h,v,E=e.kind,p=e.result,f;if(f=e.input.charCodeAt(e.position),on(f)||qu(f)||f===35||f===38||f===42||f===33||f===124||f===62||f===39||f===34||f===37||f===64||f===96||(f===63||f===45)&&(s=e.input.charCodeAt(e.position+1),on(s)||r&&qu(s)))return!1;for(e.kind="scalar",e.result="",a=i=e.position,c=!1;f!==0;){if(f===58){if(s=e.input.charCodeAt(e.position+1),on(s)||r&&qu(s))break}else if(f===35){if(n=e.input.charCodeAt(e.position-1),on(n))break}else{if(e.position===e.lineStart&&Zl(e)||r&&qu(f))break;if(di(f))if(l=e.line,h=e.lineStart,v=e.lineIndent,Xt(e,!1,-1),e.lineIndent>=t){c=!0,f=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=l,e.lineStart=h,e.lineIndent=v;break}}c&&(Us(e,a,i,!1),Vp(e,e.line-l),a=i=e.position,c=!1),Ta(f)||(i=e.position+1),f=e.input.charCodeAt(++e.position)}return Us(e,a,i,!1),e.result?!0:(e.kind=E,e.result=p,!1)}function D8(e,t){var r,n,s;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,n=s=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(Us(e,n,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)n=e.position,e.position++,s=e.position;else return!0;else di(r)?(Us(e,n,s,!0),Vp(e,Xt(e,!1,t)),n=s=e.position):e.position===e.lineStart&&Zl(e)?Ue(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);Ue(e,"unexpected end of the stream within a single quoted scalar")}function B8(e,t){var r,n,s,a,i,c;if(c=e.input.charCodeAt(e.position),c!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=n=e.position;(c=e.input.charCodeAt(e.position))!==0;){if(c===34)return Us(e,r,e.position,!0),e.position++,!0;if(c===92){if(Us(e,r,e.position,!0),c=e.input.charCodeAt(++e.position),di(c))Xt(e,!1,t);else if(c<256&&Zm[c])e.result+=Qm[c],e.position++;else if((i=b8(c))>0){for(s=i,a=0;s>0;s--)c=e.input.charCodeAt(++e.position),(i=S8(c))>=0?a=(a<<4)+i:Ue(e,"expected hexadecimal character");e.result+=F8(a),e.position++}else Ue(e,"unknown escape sequence");r=n=e.position}else di(c)?(Us(e,r,n,!0),Vp(e,Xt(e,!1,t)),r=n=e.position):e.position===e.lineStart&&Zl(e)?Ue(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}Ue(e,"unexpected end of the stream within a double quoted scalar")}function P8(e,t){var r=!0,n,s=e.tag,a,i=e.anchor,c,l,h,v,E,p={},f,w,m,y;if(y=e.input.charCodeAt(e.position),y===91)l=93,E=!1,a=[];else if(y===123)l=125,E=!0,a={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),y=e.input.charCodeAt(++e.position);y!==0;){if(Xt(e,!0,t),y=e.input.charCodeAt(e.position),y===l)return e.position++,e.tag=s,e.anchor=i,e.kind=E?"mapping":"sequence",e.result=a,!0;r||Ue(e,"missed comma between flow collection entries"),w=f=m=null,h=v=!1,y===63&&(c=e.input.charCodeAt(e.position+1),on(c)&&(h=v=!0,e.position++,Xt(e,!0,t))),n=e.line,Vu(e,t,Wl,!1,!0),w=e.tag,f=e.result,Xt(e,!0,t),y=e.input.charCodeAt(e.position),(v||e.line===n)&&y===58&&(h=!0,y=e.input.charCodeAt(++e.position),Xt(e,!0,t),Vu(e,t,Wl,!1,!0),m=e.result),E?Ku(e,a,p,w,f,m):h?a.push(Ku(e,null,p,w,f,m)):a.push(f),Xt(e,!0,t),y=e.input.charCodeAt(e.position),y===44?(r=!0,y=e.input.charCodeAt(++e.position)):r=!1}Ue(e,"unexpected end of the stream within a flow collection")}function $8(e,t){var r,n,s=qp,a=!1,i=!1,c=t,l=0,h=!1,v,E;if(E=e.input.charCodeAt(e.position),E===124)n=!1;else if(E===62)n=!0;else return!1;for(e.kind="scalar",e.result="";E!==0;)if(E=e.input.charCodeAt(++e.position),E===43||E===45)qp===s?s=E===43?Hm:A8:Ue(e,"repeat of a chomping mode identifier");else if((v=C8(E))>=0)v===0?Ue(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?Ue(e,"repeat of an indentation width identifier"):(c=t+v-1,i=!0);else break;if(Ta(E)){do E=e.input.charCodeAt(++e.position);while(Ta(E));if(E===35)do E=e.input.charCodeAt(++e.position);while(!di(E)&&E!==0)}for(;E!==0;){for(Kp(e),e.lineIndent=0,E=e.input.charCodeAt(e.position);(!i||e.lineIndentc&&(c=e.lineIndent),di(E)){l++;continue}if(e.lineIndentt)&&l!==0)Ue(e,"bad indentation of a sequence entry");else if(e.lineIndentt)&&(Vu(e,t,Xl,!0,s)&&(w?p=e.result:f=e.result),w||(Ku(e,h,v,E,p,f,a,i),E=p=f=null),Xt(e,!0,-1),y=e.input.charCodeAt(e.position)),e.lineIndent>t&&y!==0)Ue(e,"bad indentation of a mapping entry");else if(e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndent tag; it should be "scalar", not "'+e.kind+'"'),E=0,p=e.implicitTypes.length;E tag; it should be "'+f.kind+'", not "'+e.kind+'"'),f.resolve(e.result)?(e.result=f.construct(e.result),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):Ue(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):Ue(e,"unknown tag !<"+e.tag+">");return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||v}function k8(e){var t=e.position,r,n,s,a=!1,i;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};(i=e.input.charCodeAt(e.position))!==0&&(Xt(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||i!==37));){for(a=!0,i=e.input.charCodeAt(++e.position),r=e.position;i!==0&&!on(i);)i=e.input.charCodeAt(++e.position);for(n=e.input.slice(r,e.position),s=[],n.length<1&&Ue(e,"directive name must not be less than one character in length");i!==0;){for(;Ta(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!di(i));break}if(di(i))break;for(r=e.position;i!==0&&!on(i);)i=e.input.charCodeAt(++e.position);s.push(e.input.slice(r,e.position))}i!==0&&Kp(e),Hs.call(qm,n)?qm[n](e,n,s):Jl(e,'unknown document directive "'+n+'"')}if(Xt(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,Xt(e,!0,-1)):a&&Ue(e,"directives end mark is expected"),Vu(e,e.lineIndent-1,Xl,!1,!0),Xt(e,!0,-1),e.checkLineBreaks&&E8.test(e.input.slice(t,e.position))&&Jl(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Zl(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Xt(e,!0,-1));return}if(e.position"u"&&(r=t,t=null);var n=tv(e,r);if(typeof t!="function")return n;for(var s=0,a=n.length;s"u"&&(r=t,t=null),rv(e,t,ts.extend({schema:zm},r))}function L8(e,t){return nv(e,ts.extend({schema:zm},t))}lc.exports.loadAll=rv;lc.exports.load=nv;lc.exports.safeLoadAll=N8;lc.exports.safeLoad=L8});var Iv=be((cP,Wp)=>{"use strict";var hc=Ba(),pc=Hu(),U8=cc(),H8=Mu(),hv=Object.prototype.toString,pv=Object.prototype.hasOwnProperty,j8=9,fc=10,M8=13,q8=32,K8=33,V8=34,dv=35,G8=37,z8=38,Y8=39,W8=42,gv=44,X8=45,mv=58,J8=61,Z8=62,Q8=63,e_=64,vv=91,Av=93,t_=96,wv=123,r_=124,Ev=125,Br={};Br[0]="\\0";Br[7]="\\a";Br[8]="\\b";Br[9]="\\t";Br[10]="\\n";Br[11]="\\v";Br[12]="\\f";Br[13]="\\r";Br[27]="\\e";Br[34]='\\"';Br[92]="\\\\";Br[133]="\\N";Br[160]="\\_";Br[8232]="\\L";Br[8233]="\\P";var n_=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function i_(e,t){var r,n,s,a,i,c,l;if(t===null)return{};for(r={},n=Object.keys(t),s=0,a=n.length;s0?e.charCodeAt(a-1):null,p=p&&uv(i,c)}else{for(a=0;an&&e[E+1]!==" ",E=a);else if(!Gu(i))return Ql;c=a>0?e.charCodeAt(a-1):null,p=p&&uv(i,c)}h=h||v&&a-E-1>n&&e[E+1]!==" "}return!l&&!h?p&&!s(e)?Sv:bv:r>9&&yv(e)?Ql:h?Fv:Cv}function l_(e,t,r,n){e.dump=function(){if(t.length===0)return"''";if(!e.noCompatMode&&n_.indexOf(t)!==-1)return"'"+t+"'";var s=e.indent*Math.max(1,r),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),i=n||e.flowLevel>-1&&r>=e.flowLevel;function c(l){return a_(e,l)}switch(c_(t,i,e.indent,a,c)){case Sv:return t;case bv:return"'"+t.replace(/'/g,"''")+"'";case Cv:return"|"+ov(t,e.indent)+cv(av(t,s));case Fv:return">"+ov(t,e.indent)+cv(av(f_(t,a),s));case Ql:return'"'+h_(t,a)+'"';default:throw new pc("impossible error: invalid scalar style")}}()}function ov(e,t){var r=yv(e)?String(t):"",n=e[e.length-1]===` `,s=n&&(e[e.length-2]===` `||e===` `),a=s?"+":n?"":"-";return r+a+` `}function cv(e){return e[e.length-1]===` `?e.slice(0,-1):e}function f_(e,t){for(var r=/(\n+)([^\n]*)/g,n=function(){var h=e.indexOf(` `);return h=h!==-1?h:e.length,r.lastIndex=h,lv(e.slice(0,h),t)}(),s=e[0]===` `||e[0]===" ",a,i;i=r.exec(e);){var c=i[1],l=i[2];a=l[0]===" ",n+=c+(!s&&!a&&l!==""?` `:"")+lv(l,t),s=a}return n}function lv(e,t){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,n,s=0,a,i=0,c=0,l="";n=r.exec(e);)c=n.index,c-s>t&&(a=i>s?i:c,l+=` `+e.slice(s,a),s=a+1),i=c;return l+=` `,e.length-s>t&&i>s?l+=e.slice(s,i)+` `+e.slice(i+1):l+=e.slice(s),l.slice(1)}function h_(e){for(var t="",r,n,s,a=0;a=55296&&r<=56319&&(n=e.charCodeAt(a+1),n>=56320&&n<=57343)){t+=sv((r-55296)*1024+n-56320+65536),a++;continue}s=Br[r],t+=!s&&Gu(r)?e[a]:s||sv(r)}return t}function p_(e,t,r){var n="",s=e.tag,a,i;for(a=0,i=r.length;a1024&&(v+="? "),v+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),xa(e,t,h,!1,!1)&&(v+=e.dump,n+=v));e.tag=s,e.dump="{"+n+"}"}function m_(e,t,r,n){var s="",a=e.tag,i=Object.keys(r),c,l,h,v,E,p;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new pc("sortKeys must be a boolean or a function");for(c=0,l=i.length;c1024,E&&(e.dump&&fc===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,E&&(p+=Gp(e,t)),xa(e,t+1,v,!0,E)&&(e.dump&&fc===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,s+=p));e.tag=a,e.dump=s||"{}"}function fv(e,t,r){var n,s,a,i,c,l;for(s=r?e.explicitTypes:e.implicitTypes,a=0,i=s.length;a tag resolver accepts not "'+l+'" style');e.dump=n}return!0}return!1}function xa(e,t,r,n,s,a){e.tag=null,e.dump=r,fv(e,r,!1)||fv(e,r,!0);var i=hv.call(e.dump);n&&(n=e.flowLevel<0||e.flowLevel>t);var c=i==="[object Object]"||i==="[object Array]",l,h;if(c&&(l=e.duplicates.indexOf(r),h=l!==-1),(e.tag!==null&&e.tag!=="?"||h||e.indent!==2&&t>0)&&(s=!1),h&&e.usedDuplicates[l])e.dump="*ref_"+l;else{if(c&&h&&!e.usedDuplicates[l]&&(e.usedDuplicates[l]=!0),i==="[object Object]")n&&Object.keys(e.dump).length!==0?(m_(e,t,e.dump,s),h&&(e.dump="&ref_"+l+e.dump)):(g_(e,t,e.dump),h&&(e.dump="&ref_"+l+" "+e.dump));else if(i==="[object Array]"){var v=e.noArrayIndent&&t>0?t-1:t;n&&e.dump.length!==0?(d_(e,v,e.dump,s),h&&(e.dump="&ref_"+l+e.dump)):(p_(e,v,e.dump),h&&(e.dump="&ref_"+l+" "+e.dump))}else if(i==="[object String]")e.tag!=="?"&&l_(e,e.dump,t,a);else{if(e.skipInvalid)return!1;throw new pc("unacceptable kind of an object to dump "+i)}e.tag!==null&&e.tag!=="?"&&(e.dump="!<"+e.tag+"> "+e.dump)}return!0}function v_(e,t){var r=[],n=[],s,a;for(zp(e,r,n),s=0,a=n.length;s{"use strict";var ef=iv(),Dv=Iv();function tf(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}Ht.exports.Type=tr();Ht.exports.Schema=Pa();Ht.exports.FAILSAFE_SCHEMA=zl();Ht.exports.JSON_SCHEMA=Hp();Ht.exports.CORE_SCHEMA=jp();Ht.exports.DEFAULT_SAFE_SCHEMA=Mu();Ht.exports.DEFAULT_FULL_SCHEMA=cc();Ht.exports.load=ef.load;Ht.exports.loadAll=ef.loadAll;Ht.exports.safeLoad=ef.safeLoad;Ht.exports.safeLoadAll=ef.safeLoadAll;Ht.exports.dump=Dv.dump;Ht.exports.safeDump=Dv.safeDump;Ht.exports.YAMLException=Hu();Ht.exports.MINIMAL_SCHEMA=zl();Ht.exports.SAFE_SCHEMA=Mu();Ht.exports.DEFAULT_SCHEMA=cc();Ht.exports.scan=tf("scan");Ht.exports.parse=tf("parse");Ht.exports.compose=tf("compose");Ht.exports.addConstructor=tf("addConstructor")});var $v=be((fP,Pv)=>{"use strict";var w_=Bv();Pv.exports=w_});var Tv=be((hP,Rv)=>{"use strict";var rf=$v();Rv.exports={safeLoad:rf.safeLoad,load:rf.load,safeDump:rf.safeDump,dump:rf.dump}});var Zp=be(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});zu.isCorrect=zu.isInSubnet=void 0;function $_(e){return this.subnetMask{"use strict";Object.defineProperty(vi,"__esModule",{value:!0});vi.RE_SUBNET_STRING=vi.RE_ADDRESS=vi.GROUPS=vi.BITS=void 0;vi.BITS=32;vi.GROUPS=4;vi.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g;vi.RE_SUBNET_STRING=/\/\d{1,2}$/});var ff=be(lf=>{"use strict";Object.defineProperty(lf,"__esModule",{value:!0});lf.AddressError=void 0;var e0=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};lf.AddressError=e0});var t0=be((hf,jv)=>{(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n($,T,U){$!=null&&(typeof $=="number"?this.fromNumber($,T,U):T==null&&typeof $!="string"?this.fromString($,256):this.fromString($,T))}function s(){return new n(null)}function a($,T,U,J,pe,me){for(;--me>=0;){var Ce=T*this[$++]+U[J]+pe;pe=Math.floor(Ce/67108864),U[J++]=Ce&67108863}return pe}function i($,T,U,J,pe,me){for(var Ce=T&32767,Pe=T>>15;--me>=0;){var At=this[$]&32767,Nt=this[$++]>>15,mr=Pe*At+Nt*Ce;At=Ce*At+((mr&32767)<<15)+U[J]+(pe&1073741823),pe=(At>>>30)+(mr>>>15)+Pe*Nt+(pe>>>30),U[J++]=At&1073741823}return pe}function c($,T,U,J,pe,me){for(var Ce=T&16383,Pe=T>>14;--me>=0;){var At=this[$]&16383,Nt=this[$++]>>14,mr=Pe*At+Nt*Ce;At=Ce*At+((mr&16383)<<14)+U[J]+pe,pe=(At>>28)+(mr>>14)+Pe*Nt,U[J++]=At&268435455}return pe}var l=typeof navigator<"u";l&&r&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=i,e=30):l&&r&&navigator.appName!="Netscape"?(n.prototype.am=a,e=26):(n.prototype.am=c,e=28),n.prototype.DB=e,n.prototype.DM=(1<=0;--T)$[T]=this[T];$.t=this.t,$.s=this.s}function A($){this.t=1,this.s=$<0?-1:0,$>0?this[0]=$:$<-1?this[0]=$+this.DV:this.t=0}function b($){var T=s();return T.fromInt($),T}function _($,T){var U;if(T==16)U=4;else if(T==8)U=3;else if(T==256)U=8;else if(T==2)U=1;else if(T==32)U=5;else if(T==4)U=2;else{this.fromRadix($,T);return}this.t=0,this.s=0;for(var J=$.length,pe=!1,me=0;--J>=0;){var Ce=U==8?$[J]&255:m($,J);if(Ce<0){$.charAt(J)=="-"&&(pe=!0);continue}pe=!1,me==0?this[this.t++]=Ce:me+U>this.DB?(this[this.t-1]|=(Ce&(1<>this.DB-me):this[this.t-1]|=Ce<=this.DB&&(me-=this.DB)}U==8&&$[0]&128&&(this.s=-1,me>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==$;)--this.t}function B($){if(this.s<0)return"-"+this.negate().toString($);var T;if($==16)T=4;else if($==8)T=3;else if($==2)T=1;else if($==32)T=5;else if($==4)T=2;else return this.toRadix($);var U=(1<0)for(Pe>Pe)>0&&(pe=!0,me=w(J));Ce>=0;)Pe>(Pe+=this.DB-T)):(J=this[Ce]>>(Pe-=T)&U,Pe<=0&&(Pe+=this.DB,--Ce)),J>0&&(pe=!0),pe&&(me+=w(J));return pe?me:"0"}function j(){var $=s();return n.ZERO.subTo(this,$),$}function V(){return this.s<0?this.negate():this}function F($){var T=this.s-$.s;if(T!=0)return T;var U=this.t;if(T=U-$.t,T!=0)return this.s<0?-T:T;for(;--U>=0;)if((T=this[U]-$[U])!=0)return T;return 0}function P($){var T=1,U;return(U=$>>>16)!=0&&($=U,T+=16),(U=$>>8)!=0&&($=U,T+=8),(U=$>>4)!=0&&($=U,T+=4),(U=$>>2)!=0&&($=U,T+=2),(U=$>>1)!=0&&($=U,T+=1),T}function k(){return this.t<=0?0:this.DB*(this.t-1)+P(this[this.t-1]^this.s&this.DM)}function L($,T){var U;for(U=this.t-1;U>=0;--U)T[U+$]=this[U];for(U=$-1;U>=0;--U)T[U]=0;T.t=this.t+$,T.s=this.s}function M($,T){for(var U=$;U=0;--Pe)T[Pe+me+1]=this[Pe]>>J|Ce,Ce=(this[Pe]&pe)<=0;--Pe)T[Pe]=0;T[me]=Ce,T.t=this.t+me+1,T.s=this.s,T.clamp()}function K($,T){T.s=this.s;var U=Math.floor($/this.DB);if(U>=this.t){T.t=0;return}var J=$%this.DB,pe=this.DB-J,me=(1<>J;for(var Ce=U+1;Ce>J;J>0&&(T[this.t-U-1]|=(this.s&me)<>=this.DB;if($.t>=this.DB;J+=this.s}else{for(J+=this.s;U<$.t;)J-=$[U],T[U++]=J&this.DM,J>>=this.DB;J-=$.s}T.s=J<0?-1:0,J<-1?T[U++]=this.DV+J:J>0&&(T[U++]=J),T.t=U,T.clamp()}function Y($,T){var U=this.abs(),J=$.abs(),pe=U.t;for(T.t=pe+J.t;--pe>=0;)T[pe]=0;for(pe=0;pe=0;)$[U]=0;for(U=0;U=T.DV&&($[U+T.t]-=T.DV,$[U+T.t+1]=1)}$.t>0&&($[$.t-1]+=T.am(U,T[U],$,2*U,0,1)),$.s=0,$.clamp()}function ye($,T,U){var J=$.abs();if(!(J.t<=0)){var pe=this.abs();if(pe.t0?(J.lShiftTo(At,me),pe.lShiftTo(At,U)):(J.copyTo(me),pe.copyTo(U));var Nt=me.t,mr=me[Nt-1];if(mr!=0){var vr=mr*(1<1?me[Nt-2]>>this.F2:0),hn=this.FV/vr,Ds=(1<=0&&(U[U.t++]=1,U.subTo($n,U)),n.ONE.dlShiftTo(Nt,$n),$n.subTo(me,me);me.t=0;){var ha=U[--Ar]==mr?this.DM:Math.floor(U[Ar]*hn+(U[Ar-1]+Lr)*Ds);if((U[Ar]+=me.am(0,ha,U,Bs,0,Nt))0&&U.rShiftTo(At,U),Ce<0&&n.ZERO.subTo(U,U)}}}function we($){var T=s();return this.abs().divRemTo($,null,T),this.s<0&&T.compareTo(n.ZERO)>0&&$.subTo(T,T),T}function Be($){this.m=$}function He($){return $.s<0||$.compareTo(this.m)>=0?$.mod(this.m):$}function oe($){return $}function Fe($){$.divRemTo(this.m,null,$)}function Oe($,T,U){$.multiplyTo(T,U),this.reduce(U)}function ir($,T){$.squareTo(T),this.reduce(T)}Be.prototype.convert=He,Be.prototype.revert=oe,Be.prototype.reduce=Fe,Be.prototype.mulTo=Oe,Be.prototype.sqrTo=ir;function Ft(){if(this.t<1)return 0;var $=this[0];if(!($&1))return 0;var T=$&3;return T=T*(2-($&15)*T)&15,T=T*(2-($&255)*T)&255,T=T*(2-(($&65535)*T&65535))&65535,T=T*(2-$*T%this.DV)%this.DV,T>0?this.DV-T:-T}function ct($){this.m=$,this.mp=$.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<$.DB-15)-1,this.mt2=2*$.t}function Mt($){var T=s();return $.abs().dlShiftTo(this.m.t,T),T.divRemTo(this.m,null,T),$.s<0&&T.compareTo(n.ZERO)>0&&this.m.subTo(T,T),T}function Bt($){var T=s();return $.copyTo(T),this.reduce(T),T}function Qe($){for(;$.t<=this.mt2;)$[$.t++]=0;for(var T=0;T>15)*this.mpl&this.um)<<15)&$.DM;for(U=T+this.m.t,$[U]+=this.m.am(0,J,$,T,0,this.m.t);$[U]>=$.DV;)$[U]-=$.DV,$[++U]++}$.clamp(),$.drShiftTo(this.m.t,$),$.compareTo(this.m)>=0&&$.subTo(this.m,$)}function bt($,T){$.squareTo(T),this.reduce(T)}function Je($,T,U){$.multiplyTo(T,U),this.reduce(U)}ct.prototype.convert=Mt,ct.prototype.revert=Bt,ct.prototype.reduce=Qe,ct.prototype.mulTo=Je,ct.prototype.sqrTo=bt;function ft(){return(this.t>0?this[0]&1:this.s)==0}function qt($,T){if($>4294967295||$<1)return n.ONE;var U=s(),J=s(),pe=T.convert(this),me=P($)-1;for(pe.copyTo(U);--me>=0;)if(T.sqrTo(U,J),($&1<0)T.mulTo(J,pe,U);else{var Ce=U;U=J,J=Ce}return T.revert(U)}function ze($,T){var U;return $<256||T.isEven()?U=new Be(T):U=new ct(T),this.exp($,U)}n.prototype.copyTo=y,n.prototype.fromInt=A,n.prototype.fromString=_,n.prototype.clamp=I,n.prototype.dlShiftTo=L,n.prototype.drShiftTo=M,n.prototype.lShiftTo=X,n.prototype.rShiftTo=K,n.prototype.subTo=q,n.prototype.multiplyTo=Y,n.prototype.squareTo=re,n.prototype.divRemTo=ye,n.prototype.invDigit=Ft,n.prototype.isEven=ft,n.prototype.exp=qt,n.prototype.toString=B,n.prototype.negate=j,n.prototype.abs=V,n.prototype.compareTo=F,n.prototype.bitLength=k,n.prototype.mod=we,n.prototype.modPowInt=ze,n.ZERO=b(0),n.ONE=b(1);function Ot(){var $=s();return this.copyTo($),$}function Pn(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function gr(){return this.t==0?this.s:this[0]<<16>>16}function Gt($){return Math.floor(Math.LN2*this.DB/Math.log($))}function br(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Js($){if($==null&&($=10),this.signum()==0||$<2||$>36)return"0";var T=this.chunkSize($),U=Math.pow($,T),J=b(U),pe=s(),me=s(),Ce="";for(this.divRemTo(J,pe,me);pe.signum()>0;)Ce=(U+me.intValue()).toString($).substr(1)+Ce,pe.divRemTo(J,pe,me);return me.intValue().toString($)+Ce}function kr($,T){this.fromInt(0),T==null&&(T=10);for(var U=this.chunkSize(T),J=Math.pow(T,U),pe=!1,me=0,Ce=0,Pe=0;Pe<$.length;++Pe){var At=m($,Pe);if(At<0){$.charAt(Pe)=="-"&&this.signum()==0&&(pe=!0);continue}Ce=T*Ce+At,++me>=U&&(this.dMultiply(J),this.dAddOffset(Ce,0),me=0,Ce=0)}me>0&&(this.dMultiply(Math.pow(T,me)),this.dAddOffset(Ce,0)),pe&&n.ZERO.subTo(this,this)}function ht($,T,U){if(typeof T=="number")if($<2)this.fromInt(1);else for(this.fromNumber($,U),this.testBit($-1)||this.bitwiseTo(n.ONE.shiftLeft($-1),Ti,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(T);)this.dAddOffset(2,0),this.bitLength()>$&&this.subTo(n.ONE.shiftLeft($-1),this);else{var J=new Array,pe=$&7;J.length=($>>3)+1,T.nextBytes(J),pe>0?J[0]&=(1<0)for(U>U)!=(this.s&this.DM)>>U&&(T[pe++]=J|this.s<=0;)U<8?(J=(this[$]&(1<>(U+=this.DB-8)):(J=this[$]>>(U-=8)&255,U<=0&&(U+=this.DB,--$)),J&128&&(J|=-256),pe==0&&(this.s&128)!=(J&128)&&++pe,(pe>0||J!=this.s)&&(T[pe++]=J);return T}function Ye($){return this.compareTo($)==0}function Cr($){return this.compareTo($)<0?this:$}function Zs($){return this.compareTo($)>0?this:$}function Qs($,T,U){var J,pe,me=Math.min($.t,this.t);for(J=0;J>=16,T+=16),$&255||($>>=8,T+=8),$&15||($>>=4,T+=4),$&3||($>>=2,T+=2),$&1||++T,T}function Ja(){for(var $=0;$=this.t?this.s!=0:(this[T]&1<<$%this.DB)!=0}function ho($,T){var U=n.ONE.shiftLeft($);return this.bitwiseTo(U,T,U),U}function po($){return this.changeBit($,Ti)}function go($){return this.changeBit($,xi)}function Fs($){return this.changeBit($,Cs)}function mo($,T){for(var U=0,J=0,pe=Math.min($.t,this.t);U>=this.DB;if($.t>=this.DB;J+=this.s}else{for(J+=this.s;U<$.t;)J+=$[U],T[U++]=J&this.DM,J>>=this.DB;J+=$.s}T.s=J<0?-1:0,J>0?T[U++]=J:J<-1&&(T[U++]=this.DV+J),T.t=U,T.clamp()}function na($){var T=s();return this.addTo($,T),T}function vo($){var T=s();return this.subTo($,T),T}function Ao($){var T=s();return this.multiplyTo($,T),T}function wo(){var $=s();return this.squareTo($),$}function Eo($){var T=s();return this.divRemTo($,T,null),T}function yo($){var T=s();return this.divRemTo($,null,T),T}function So($){var T=s(),U=s();return this.divRemTo($,T,U),new Array(T,U)}function bo($){this[this.t]=this.am(0,$-1,this,0,0,this.t),++this.t,this.clamp()}function Co($,T){if($!=0){for(;this.t<=T;)this[this.t++]=0;for(this[T]+=$;this[T]>=this.DV;)this[T]-=this.DV,++T>=this.t&&(this[this.t++]=0),++this[T]}}function ni(){}function eu($){return $}function Fo($,T,U){$.multiplyTo(T,U)}function _o($,T){$.squareTo(T)}ni.prototype.convert=eu,ni.prototype.revert=eu,ni.prototype.mulTo=Fo,ni.prototype.sqrTo=_o;function Io($){return this.exp($,new ni)}function tu($,T,U){var J=Math.min(this.t+$.t,T);for(U.s=0,U.t=J;J>0;)U[--J]=0;var pe;for(pe=U.t-this.t;J=0;)U[J]=0;for(J=Math.max(T-this.t,0);J<$.t;++J)U[this.t+J-T]=this.am(T-J,$[J],U,0,0,this.t+J-T);U.clamp(),U.drShiftTo(1,U)}function Yr($){this.r2=s(),this.q3=s(),n.ONE.dlShiftTo(2*$.t,this.r2),this.mu=this.r2.divide($),this.m=$}function Do($){if($.s<0||$.t>2*this.m.t)return $.mod(this.m);if($.compareTo(this.m)<0)return $;var T=s();return $.copyTo(T),this.reduce(T),T}function _s($){return $}function fn($){for($.drShiftTo(this.m.t-1,this.r2),$.t>this.m.t+1&&($.t=this.m.t+1,$.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);$.compareTo(this.r2)<0;)$.dAddOffset(1,this.m.t+1);for($.subTo(this.r2,$);$.compareTo(this.m)>=0;)$.subTo(this.m,$)}function Bo($,T){$.squareTo(T),this.reduce(T)}function Po($,T,U){$.multiplyTo(T,U),this.reduce(U)}Yr.prototype.convert=Do,Yr.prototype.revert=_s,Yr.prototype.reduce=fn,Yr.prototype.mulTo=Po,Yr.prototype.sqrTo=Bo;function ru($,T){var U=$.bitLength(),J,pe=b(1),me;if(U<=0)return pe;U<18?J=1:U<48?J=3:U<144?J=4:U<768?J=5:J=6,U<8?me=new Be(T):T.isEven()?me=new Yr(T):me=new ct(T);var Ce=new Array,Pe=3,At=J-1,Nt=(1<1){var mr=s();for(me.sqrTo(Ce[1],mr);Pe<=Nt;)Ce[Pe]=s(),me.mulTo(mr,Ce[Pe-2],Ce[Pe]),Pe+=2}var vr=$.t-1,hn,Ds=!0,Lr=s(),Ar;for(U=P($[vr])-1;vr>=0;){for(U>=At?hn=$[vr]>>U-At&Nt:(hn=($[vr]&(1<0&&(hn|=$[vr-1]>>this.DB+U-At)),Pe=J;!(hn&1);)hn>>=1,--Pe;if((U-=Pe)<0&&(U+=this.DB,--vr),Ds)Ce[hn].copyTo(pe),Ds=!1;else{for(;Pe>1;)me.sqrTo(pe,Lr),me.sqrTo(Lr,pe),Pe-=2;Pe>0?me.sqrTo(pe,Lr):(Ar=pe,pe=Lr,Lr=Ar),me.mulTo(Lr,Ce[hn],pe)}for(;vr>=0&&!($[vr]&1<0&&(T.rShiftTo(me,T),U.rShiftTo(me,U));T.signum()>0;)(pe=T.getLowestSetBit())>0&&T.rShiftTo(pe,T),(pe=U.getLowestSetBit())>0&&U.rShiftTo(pe,U),T.compareTo(U)>=0?(T.subTo(U,T),T.rShiftTo(1,T)):(U.subTo(T,U),U.rShiftTo(1,U));return me>0&&U.lShiftTo(me,U),U}function nu($){if($<=0)return 0;var T=this.DV%$,U=this.s<0?$-1:0;if(this.t>0)if(T==0)U=this[0]%$;else for(var J=this.t-1;J>=0;--J)U=(T*U+this[J])%$;return U}function Is($){var T=$.isEven();if(this.isEven()&&T||$.signum()==0)return n.ZERO;for(var U=$.clone(),J=this.clone(),pe=b(1),me=b(0),Ce=b(0),Pe=b(1);U.signum()!=0;){for(;U.isEven();)U.rShiftTo(1,U),T?((!pe.isEven()||!me.isEven())&&(pe.addTo(this,pe),me.subTo($,me)),pe.rShiftTo(1,pe)):me.isEven()||me.subTo($,me),me.rShiftTo(1,me);for(;J.isEven();)J.rShiftTo(1,J),T?((!Ce.isEven()||!Pe.isEven())&&(Ce.addTo(this,Ce),Pe.subTo($,Pe)),Ce.rShiftTo(1,Ce)):Pe.isEven()||Pe.subTo($,Pe),Pe.rShiftTo(1,Pe);U.compareTo(J)>=0?(U.subTo(J,U),T&&pe.subTo(Ce,pe),me.subTo(Pe,me)):(J.subTo(U,J),T&&Ce.subTo(pe,Ce),Pe.subTo(me,Pe))}if(J.compareTo(n.ONE)!=0)return n.ZERO;if(Pe.compareTo($)>=0)return Pe.subtract($);if(Pe.signum()<0)Pe.addTo($,Pe);else return Pe;return Pe.signum()<0?Pe.add($):Pe}var kt=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],$o=(1<<26)/kt[kt.length-1];function Ro($){var T,U=this.abs();if(U.t==1&&U[0]<=kt[kt.length-1]){for(T=0;T>1,$>kt.length&&($=kt.length);for(var pe=s(),me=0;me<$;++me){pe.fromInt(kt[Math.floor(Math.random()*kt.length)]);var Ce=pe.modPow(J,this);if(Ce.compareTo(n.ONE)!=0&&Ce.compareTo(T)!=0){for(var Pe=1;Pe++>8&255,ar[Dt++]^=$>>16&255,ar[Dt++]^=$>>24&255,Dt>=Nr&&(Dt-=Nr)}function sa(){To(new Date().getTime())}if(ar==null){ar=new Array,Dt=0;var ur;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var aa=new Uint8Array(32);for(window.crypto.getRandomValues(aa),ur=0;ur<32;++ur)ar[Dt++]=aa[ur]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var su=window.crypto.random(32);for(ur=0;ur>>8,ar[Dt++]=ur&255;Dt=0,sa()}function au(){if(si==null){for(sa(),si=fa(),si.init(ar),Dt=0;Dt{(function(){"use strict";var e={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(i){return n(a(i),arguments)}function r(i,c){return t.apply(null,[i].concat(c||[]))}function n(i,c){var l=1,h=i.length,v,E="",p,f,w,m,y,A,b,_;for(p=0;p=0),w.type){case"b":v=parseInt(v,10).toString(2);break;case"c":v=String.fromCharCode(parseInt(v,10));break;case"d":case"i":v=parseInt(v,10);break;case"j":v=JSON.stringify(v,null,w.width?parseInt(w.width):0);break;case"e":v=w.precision?parseFloat(v).toExponential(w.precision):parseFloat(v).toExponential();break;case"f":v=w.precision?parseFloat(v).toFixed(w.precision):parseFloat(v);break;case"g":v=w.precision?String(Number(v.toPrecision(w.precision))):parseFloat(v);break;case"o":v=(parseInt(v,10)>>>0).toString(8);break;case"s":v=String(v),v=w.precision?v.substring(0,w.precision):v;break;case"t":v=String(!!v),v=w.precision?v.substring(0,w.precision):v;break;case"T":v=Object.prototype.toString.call(v).slice(8,-1).toLowerCase(),v=w.precision?v.substring(0,w.precision):v;break;case"u":v=parseInt(v,10)>>>0;break;case"v":v=v.valueOf(),v=w.precision?v.substring(0,w.precision):v;break;case"x":v=(parseInt(v,10)>>>0).toString(16);break;case"X":v=(parseInt(v,10)>>>0).toString(16).toUpperCase();break}e.json.test(w.type)?E+=v:(e.number.test(w.type)&&(!b||w.sign)?(_=b?"+":"-",v=v.toString().replace(e.sign,"")):_="",y=w.pad_char?w.pad_char==="0"?"0":w.pad_char.charAt(1):" ",A=w.width-(_+v).length,m=w.width&&A>0?y.repeat(A):"",E+=w.align?_+v+m:y==="0"?_+m+v:m+_+v)}return E}var s=Object.create(null);function a(i){if(s[i])return s[i];for(var c=i,l,h=[],v=0;c;){if((l=e.text.exec(c))!==null)h.push(l[0]);else if((l=e.modulo.exec(c))!==null)h.push("%");else if((l=e.placeholder.exec(c))!==null){if(l[2]){v|=1;var E=[],p=l[2],f=[];if((f=e.key.exec(p))!==null)for(E.push(f[1]);(p=p.substring(f[0].length))!=="";)if((f=e.key_access.exec(p))!==null)E.push(f[1]);else if((f=e.index_access.exec(p))!==null)E.push(f[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=E}else v|=2;if(v===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");h.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");c=c.substring(l[0].length)}return s[i]=h}typeof pf<"u"&&(pf.sprintf=t,pf.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var n0=be(Ai=>{"use strict";var T_=Ai&&Ai.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),x_=Ai&&Ai.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Kv=Ai&&Ai.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&T_(t,e,r);return x_(t,e),t};Object.defineProperty(Ai,"__esModule",{value:!0});Ai.Address4=void 0;var Mv=Kv(Zp()),Zn=Kv(Qp()),qv=ff(),mc=t0(),Yu=gc(),r0=class e{constructor(t){this.groups=Zn.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Mv.isCorrect(Zn.BITS),this.isInSubnet=Mv.isInSubnet,this.address=t;let r=Zn.RE_SUBNET_STRING.exec(t);if(r){if(this.parsedSubnet=r[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>Zn.BITS)throw new qv.AddressError("Invalid subnet mask.");t=t.replace(Zn.RE_SUBNET_STRING,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new e(t),!0}catch{return!1}}parse(t){let r=t.split(".");if(!t.match(Zn.RE_ADDRESS))throw new qv.AddressError("Invalid IPv4 address.");return r}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let r=t.replace(/:/g,"").padStart(8,"0"),n=[],s;for(s=0;s<8;s+=2){let a=r.slice(s,s+2);n.push(parseInt(a,16))}return new e(n.join("."))}static fromInteger(t){return e.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new e(n)}toHex(){return this.parsedAddress.map(t=>(0,Yu.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r(0,Yu.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new mc.BigInteger(this.mask()+"0".repeat(Zn.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new mc.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new mc.BigInteger(this.mask()+"1".repeat(Zn.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new mc.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return e.fromInteger(parseInt(t.toString(),10))}mask(t){return t===void 0&&(t=this.subnetMask),this.getBitsBase2(0,t)}getBitsBase2(t,r){return this.binaryZeroPad().slice(t,r)}reverseForm(t){t||(t={});let r=this.correctForm().split(".").reverse().join(".");return t.omitSuffix?r:(0,Yu.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(Zn.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(Zn.RE_ADDRESS,(0,Yu.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};Ai.Address4=r0});var i0=be(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.RE_URL_WITH_PORT=jt.RE_URL=jt.RE_ZONE_STRING=jt.RE_SUBNET_STRING=jt.RE_BAD_ADDRESS=jt.RE_BAD_CHARACTERS=jt.TYPES=jt.SCOPES=jt.GROUPS=jt.BITS=void 0;jt.BITS=128;jt.GROUPS=8;jt.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};jt.TYPES={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"};jt.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;jt.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;jt.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;jt.RE_ZONE_STRING=/%.*$/;jt.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);jt.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var s0=be(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.simpleGroup=wi.spanLeadingZeroes=wi.spanAll=wi.spanAllZeroes=void 0;var Vv=gc();function Gv(e){return e.replace(/(0+)/g,'$1')}wi.spanAllZeroes=Gv;function O_(e,t=0){return e.split("").map((n,s)=>(0,Vv.sprintf)('%s',n,s+t,Gv(n))).join("")}wi.spanAll=O_;function zv(e){return e.replace(/^(0+)/,'$1')}function k_(e){return e.split(":").map(r=>zv(r)).join(":")}wi.spanLeadingZeroes=k_;function N_(e,t=0){return e.split(":").map((n,s)=>/group-v4/.test(n)?n:(0,Vv.sprintf)('%s',s+t,zv(n)))}wi.simpleGroup=N_});var Yv=be(fr=>{"use strict";var L_=fr&&fr.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),U_=fr&&fr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),H_=fr&&fr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&L_(t,e,r);return U_(t,e),t};Object.defineProperty(fr,"__esModule",{value:!0});fr.possibleElisions=fr.simpleRegularExpression=fr.ADDRESS_BOUNDARY=fr.padGroup=fr.groupPossibilities=void 0;var j_=H_(i0()),Wu=gc();function gf(e){return(0,Wu.sprintf)("(%s)",e.join("|"))}fr.groupPossibilities=gf;function df(e){return e.length<4?(0,Wu.sprintf)("0{0,%d}%s",4-e.length,e):e}fr.padGroup=df;fr.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function M_(e){let t=[];e.forEach((n,s)=>{parseInt(n,16)===0&&t.push(s)});let r=t.map(n=>e.map((s,a)=>{if(a===n){let i=a===0||a===j_.GROUPS-1?":":"";return gf([df(s),i])}return df(s)}).join(":"));return r.push(e.map(df).join(":")),gf(r)}fr.simpleRegularExpression=M_;function q_(e,t,r){let n=t?"":":",s=r?"":":",a=[];!t&&!r&&a.push("::"),t&&r&&a.push(""),(r&&!t||!r&&t)&&a.push(":"),a.push((0,Wu.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),a.push((0,Wu.sprintf)("(0{1,4}:){1,%d}%s",e-1,s)),a.push((0,Wu.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let i=1;i{"use strict";var K_=Ei&&Ei.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),V_=Ei&&Ei.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),vf=Ei&&Ei.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&K_(t,e,r);return V_(t,e),t};Object.defineProperty(Ei,"__esModule",{value:!0});Ei.Address6=void 0;var Wv=vf(Zp()),a0=vf(Qp()),_t=vf(i0()),u0=vf(s0()),Ua=n0(),Ha=Yv(),ss=ff(),Vr=t0(),Gr=gc();function mf(e){if(!e)throw new Error("Assertion failed.")}function G_(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function z_(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function Y_(e,t){let r=[],n=[],s;for(s=0;st[1]&&n.push(e[s]);return r.concat(["compact"]).concat(n)}function Xv(e){return(0,Gr.sprintf)("%04x",parseInt(e,16))}function Jv(e){return e&255}var o0=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=Wv.isInSubnet,this.isCorrect=Wv.isCorrect(_t.BITS),r===void 0?this.groups=_t.GROUPS:this.groups=r,this.address=t;let n=_t.RE_SUBNET_STRING.exec(t);if(n){if(this.parsedSubnet=n[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>_t.BITS)throw new ss.AddressError("Invalid subnet mask.");t=t.replace(_t.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new ss.AddressError("Invalid subnet mask.");let s=_t.RE_ZONE_STRING.exec(t);s&&(this.zone=s[0],t=t.replace(_t.RE_ZONE_STRING,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new e(t),!0}catch{return!1}}static fromBigInteger(t){let r=t.toString(16).padStart(32,"0"),n=[],s;for(s=0;s<_t.GROUPS;s++)n.push(r.slice(s*4,(s+1)*4));return new e(n.join(":"))}static fromURL(t){let r,n=null,s;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(s=_t.RE_URL_WITH_PORT.exec(t),s===null)return{error:"failed to parse address with port",address:null,port:null};r=s[1],n=s[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),s=_t.RE_URL.exec(t),s===null)return{error:"failed to parse address from URL",address:null,port:null};r=s[1]}else r=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new e(r),port:n}}static fromAddress4(t){let r=new Ua.Address4(t),n=_t.BITS-(a0.BITS-r.subnetMask);return new e(`::ffff:${r.correctForm()}/${n}`)}static fromArpa(t){let r=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(r.length!==63)throw new ss.AddressError("Invalid 'ip6.arpa' form.");let s=r.split(".").reverse();for(let a=n;a>0;a--){let i=a*4;s.splice(i,0,":")}return r=s.join(""),new e(r)}microsoftTranscription(){return(0,Gr.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=_t.BITS-this.subnetMask,n=Math.abs(t-_t.BITS),s=r-n;return s<0?"0":G_(new Vr.BigInteger("2",10).pow(s).toString(10))}_startAddress(){return new Vr.BigInteger(this.mask()+"0".repeat(_t.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Vr.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Vr.BigInteger(this.mask()+"1".repeat(_t.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Vr.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=_t.SCOPES[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(_t.TYPES))if(this.isInSubnet(new e(t)))return _t.TYPES[t];return"Global unicast"}getBits(t,r){return new Vr.BigInteger(this.getBitsBase2(t,r),2)}getBitsBase2(t,r){return this.binaryZeroPad().slice(t,r)}getBitsBase16(t,r){let n=r-t;if(n%4!==0)throw new Error("Length of bits to retrieve must be divisible by four");return this.getBits(t,r).toString(16).padStart(n/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,_t.BITS)}reverseForm(t){t||(t={});let r=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,"").split("").slice(0,r).reverse().join(".");return r>0?t.omitSuffix?n:(0,Gr.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,r=[],n=0,s=[];for(t=0;t0&&(n>1&&s.push([t-n,t-1]),n=0)}n>1&&s.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let a=s.map(c=>c[1]-c[0]+1);if(s.length>0){let c=a.indexOf(Math.max(...a));r=Y_(this.parsedAddress,s[c])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace(_t.RE_BAD_CHARACTERS,'$1'));let n=t.match(_t.RE_BAD_ADDRESS);if(n)throw new ss.AddressError((0,Gr.sprintf)("Address failed regex: %s",n.join("")),t.replace(_t.RE_BAD_ADDRESS,'$1'));let s=[],a=t.split("::");if(a.length===2){let i=a[0].split(":"),c=a[1].split(":");i.length===1&&i[0]===""&&(i=[]),c.length===1&&c[0]===""&&(c=[]);let l=this.groups-(i.length+c.length);if(!l)throw new ss.AddressError("Error parsing groups");this.elidedGroups=l,this.elisionBegin=i.length,this.elisionEnd=i.length+this.elidedGroups,s=s.concat(i);for(let h=0;h(0,Gr.sprintf)("%x",parseInt(i,16))),s.length!==this.groups)throw new ss.AddressError("Incorrect number of groups found");return s}canonicalForm(){return this.parsedAddress.map(Xv).join(":")}decimal(){return this.parsedAddress.map(t=>(0,Gr.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new Vr.BigInteger(this.parsedAddress.map(Xv).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return Ua.Address4.fromHex(new Vr.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new e(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),s="";return/:$/.test(n)||(s=":"),n+s+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),r=this.getBits(80,96).xor(new Vr.BigInteger("ffff",16)).toString(),n=Ua.Address4.fromHex(this.getBitsBase16(32,64)),s=Ua.Address4.fromHex(this.getBits(96,128).xor(new Vr.BigInteger("ffffffff",16)).toString(16)),a=this.getBits(64,80),i=this.getBitsBase2(64,80),c=a.testBit(15),l=a.testBit(14),h=a.testBit(8),v=a.testBit(9),E=new Vr.BigInteger(i.slice(2,6)+i.slice(8,16),2).toString(10);return{prefix:(0,Gr.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:s.address,flags:i,coneNat:c,microsoft:{reserved:l,universalLocal:v,groupIndividual:h,nonce:E},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=Ua.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,Gr.sprintf)("%s",t.slice(0,4)),gateway:r.address}}to6to4(){if(!this.is4())return null;let t=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new e(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Jv)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Jv))}static fromUnsignedByteArray(t){let r=new Vr.BigInteger("256",10),n=new Vr.BigInteger("0",10),s=new Vr.BigInteger("1",10);for(let a=t.length-1;a>=0;a--)n=n.add(s.multiply(new Vr.BigInteger(t[a].toString(10),10))),s=s.multiply(r);return e.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new e("2001::/32"))}is6to4(){return this.isInSubnet(new e("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,Gr.sprintf)(":%s",t),(0,Gr.sprintf)("http://[%s]%s/",this.correctForm(),t)}link(t){t||(t={}),t.className===void 0&&(t.className=""),t.prefix===void 0&&(t.prefix="/#address="),t.v4===void 0&&(t.v4=!1);let r=this.correctForm;return t.v4&&(r=this.to4in6),t.className?(0,Gr.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,Gr.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return u0.simpleGroup(this.address).join(":");mf(typeof this.elidedGroups=="number"),mf(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...u0.simpleGroup(r)):t.push("");let s=["hover-group"];for(let a=this.elisionBegin;a',s.join(" "))),n.length?t.push(...u0.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(mf(this.address4 instanceof Ua.Address4),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let r=[],n=new e(this.correctForm());if(n.elidedGroups===0)r.push((0,Ha.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===_t.GROUPS)r.push((0,Ha.possibleElisions)(_t.GROUPS));else{let s=n.address.split("::");s[0].length&&r.push((0,Ha.simpleRegularExpression)(s[0].split(":"))),mf(typeof n.elidedGroups=="number"),r.push((0,Ha.possibleElisions)(n.elidedGroups,s[0].length!==0,s[1].length!==0)),s[1].length&&r.push((0,Ha.simpleRegularExpression)(s[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",Ha.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",Ha.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};Ei.Address6=o0});var Qv=be(xr=>{"use strict";var W_=xr&&xr.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),X_=xr&&xr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),J_=xr&&xr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&W_(t,e,r);return X_(t,e),t};Object.defineProperty(xr,"__esModule",{value:!0});xr.v6=xr.AddressError=xr.Address6=xr.Address4=void 0;var Z_=n0();Object.defineProperty(xr,"Address4",{enumerable:!0,get:function(){return Z_.Address4}});var Q_=Zv();Object.defineProperty(xr,"Address6",{enumerable:!0,get:function(){return Q_.Address6}});var eI=ff();Object.defineProperty(xr,"AddressError",{enumerable:!0,get:function(){return eI.AddressError}});var tI=J_(s0());xr.v6={helpers:tI}});var C2=be(w0=>{"use strict";w0.toString=function(e){switch(e){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+e};w0.toType=function(e){switch(e.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return e.toUpperCase().startsWith("UNKNOWN_")?parseInt(e.slice(8)):0}});var F2=be(E0=>{"use strict";E0.toString=function(e){switch(e){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+e};E0.toRcode=function(e){switch(e.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var _2=be(y0=>{"use strict";y0.toString=function(e){switch(e){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+e};y0.toOpcode=function(e){switch(e.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var I2=be(S0=>{"use strict";S0.toString=function(e){switch(e){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+e};S0.toClass=function(e){switch(e.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var D2=be(b0=>{"use strict";b0.toString=function(e){switch(e){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return e<0?null:`OPTION_${e}`};b0.toCode=function(e){if(typeof e=="number")return e;if(!e)return-1;switch(e.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let t=e.match(/_(\d+)$/);return t?parseInt(t[1],10):-1}});var $2=be((P2,C0)=>{var B2=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=E,e.encode=v,e.familyOf=h,e.name=void 0,e.sizeOf=l,e.v6=e.v4=void 0;let t=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,s=16,a={name:"v4",size:r,isFormat:p=>t.test(p),encode(p,f,w){w=~~w,f=f||new Uint8Array(w+r);let m=p.length,y=0;for(let A=0;Ap.length>0&&n.test(p),encode(p,f,w){w=~~w;let m=w+s,y=-1,A=0,b=0,_=!0,I=!1;f=f||new Uint8Array(w+s);for(let B=0;B>8),w=97?j-=87:j>=65?j-=55:(j-=48,b=b*10+j),A=(A<<4)+j)}if(_===!1)I===!0?(w>8),w=y+2;B--)f[B]=f[B-2];f[y]=0,f[y+1]=0,y=w}if(y!==w&&y!==-1)for(w>m-2&&(w=m-2);m>y;)f[--m]=wy?f[--w]:0;else for(;w{"use strict";var xe=Rl().Buffer,vs=C2(),CI=F2(),FI=_2(),Bf=I2(),F0=D2(),Ma=$2(),_I=0,R2=32768,_0=32768,II=~_0,T2=32768,DI=~T2,Ie=Te.name={};Ie.encode=function(e,t,r,{mail:n=!1}={}){t||(t=xe.alloc(Ie.encodingLength(e))),r||(r=0);let s=r,a=e.replace(/^\.|\.$/gm,"");if(a.length){let i=[];if(n){let c="";a.split(".").forEach(l=>{l.endsWith("\\")?c+=(c.length?".":"")+l.slice(0,-1):i.length===0&&c.length?i.push(c+"."+l):i.push(l)})}else i=a.split(".");for(let c=0;c=e.length)throw new Error("Cannot decode name (buffer overflow)");let l=e[t++];if(i+=c?0:1,l===0)break;if(l&192)if((l&192)===192){if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");let h=e.readUInt16BE(t-1)-49152;if(h>=s)throw new Error("Cannot decode name (bad pointer)");t=h,s=h,i+=c?0:1,c=!0}else throw new Error("Cannot decode name (bad label)");else{if(t+l>e.length)throw new Error("Cannot decode name (buffer overflow)");if(a+=l+1,a>254)throw new Error("Cannot decode name (name too long)");let h=e.toString("utf-8",t,t+l);r&&(h=h.replace(/\./g,"\\.")),n.push(h),t+=l,i+=c?0:l}}return Ie.decode.bytes=i,n.length===0?".":n.join(".")};Ie.decode.bytes=0;Ie.encodingLength=function(e){return e==="."||e===".."?1:xe.byteLength(e.replace(/^\.|\.$/gm,""))+2};var tt={};tt.encode=function(e,t,r){t||(t=xe.alloc(tt.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,tt.encode.bytes=n+1,t};tt.encode.bytes=0;tt.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return tt.decode.bytes=r+1,n};tt.decode.bytes=0;tt.encodingLength=function(e){return xe.byteLength(e)+1};var ti={};ti.encode=function(e,t,r){t||(t=ti.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,s=e.type==="response"?R2:_I;return t.writeUInt16BE(e.id||0,r),t.writeUInt16BE(n|s,r+2),t.writeUInt16BE(e.questions.length,r+4),t.writeUInt16BE(e.answers.length,r+6),t.writeUInt16BE(e.authorities.length,r+8),t.writeUInt16BE(e.additionals.length,r+10),t};ti.encode.bytes=12;ti.decode=function(e,t){if(t||(t=0),e.length<12)throw new Error("Header must be 12 bytes");let r=e.readUInt16BE(t+2);return{id:e.readUInt16BE(t),type:r&R2?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:FI.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:CI.toString(r&15),questions:new Array(e.readUInt16BE(t+4)),answers:new Array(e.readUInt16BE(t+6)),authorities:new Array(e.readUInt16BE(t+8)),additionals:new Array(e.readUInt16BE(t+10))}};ti.decode.bytes=12;ti.encodingLength=function(){return 12};var us=Te.unknown={};us.encode=function(e,t,r){return t||(t=xe.alloc(us.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),us.encode.bytes=e.length+2,t};us.encode.bytes=0;us.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return us.decode.bytes=r+2,n};us.decode.bytes=0;us.encodingLength=function(e){return e.length+2};var os=Te.ns={};os.encode=function(e,t,r){return t||(t=xe.alloc(os.encodingLength(e))),r||(r=0),Ie.encode(e,t,r+2),t.writeUInt16BE(Ie.encode.bytes,r),os.encode.bytes=Ie.encode.bytes+2,t};os.encode.bytes=0;os.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=Ie.decode(e,t+2);return os.decode.bytes=r+2,n};os.decode.bytes=0;os.encodingLength=function(e){return Ie.encodingLength(e)+2};var cs=Te.soa={};cs.encode=function(e,t,r){t||(t=xe.alloc(cs.encodingLength(e))),r||(r=0);let n=r;return r+=2,Ie.encode(e.mname,t,r),r+=Ie.encode.bytes,Ie.encode(e.rname,t,r,{mail:!0}),r+=Ie.encode.bytes,t.writeUInt32BE(e.serial||0,r),r+=4,t.writeUInt32BE(e.refresh||0,r),r+=4,t.writeUInt32BE(e.retry||0,r),r+=4,t.writeUInt32BE(e.expire||0,r),r+=4,t.writeUInt32BE(e.minimum||0,r),r+=4,t.writeUInt16BE(r-n-2,n),cs.encode.bytes=r-n,t};cs.encode.bytes=0;cs.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mname=Ie.decode(e,t),t+=Ie.decode.bytes,n.rname=Ie.decode(e,t,{mail:!0}),t+=Ie.decode.bytes,n.serial=e.readUInt32BE(t),t+=4,n.refresh=e.readUInt32BE(t),t+=4,n.retry=e.readUInt32BE(t),t+=4,n.expire=e.readUInt32BE(t),t+=4,n.minimum=e.readUInt32BE(t),t+=4,cs.decode.bytes=t-r,n};cs.decode.bytes=0;cs.encodingLength=function(e){return 22+Ie.encodingLength(e.mname)+Ie.encodingLength(e.rname)};var ls=Te.txt={};ls.encode=function(e,t,r){Array.isArray(e)||(e=[e]);for(let s=0;s0;){let a=e[t++];if(--n,n0&&(r.timeout=e.readUInt16BE(t),t+=2);break;case 14:r.tags=[];for(let a=0;a0;)n[a++]=cn.decode(e,t),t+=cn.decode.bytes,s-=cn.decode.bytes;return Cn.decode.bytes=t-r,n};Cn.decode.bytes=0;Cn.encodingLength=function(e){return 2+to(e||[],cn)};var zr=Te.dnskey={};zr.PROTOCOL_DNSSEC=3;zr.ZONE_KEY=128;zr.SECURE_ENTRYPOINT=32768;zr.encode=function(e,t,r){t||(t=xe.alloc(zr.encodingLength(e))),r||(r=0);let n=r,s=e.key;if(!xe.isBuffer(s))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(zr.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,s.copy(t,r,0,s.length),r+=s.length,zr.encode.bytes=r-n,t.writeUInt16BE(zr.encode.bytes-2,n),t};zr.encode.bytes=0;zr.decode=function(e,t){t||(t=0);let r=t;var n={},s=e.readUInt16BE(t);if(t+=2,n.flags=e.readUInt16BE(t),t+=2,e.readUInt8(t)!==zr.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return t+=1,n.algorithm=e.readUInt8(t),t+=1,n.key=e.slice(t,r+s+2),t+=n.key.length,zr.decode.bytes=t-r,n};zr.decode.bytes=0;zr.encodingLength=function(e){return 6+xe.byteLength(e.key)};var Si=Te.rrsig={};Si.encode=function(e,t,r){t||(t=xe.alloc(Si.encodingLength(e))),r||(r=0);let n=r,s=e.signature;if(!xe.isBuffer(s))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(vs.toType(e.typeCovered),r),r+=2,t.writeUInt8(e.algorithm,r),r+=1,t.writeUInt8(e.labels,r),r+=1,t.writeUInt32BE(e.originalTTL,r),r+=4,t.writeUInt32BE(e.expiration,r),r+=4,t.writeUInt32BE(e.inception,r),r+=4,t.writeUInt16BE(e.keyTag,r),r+=2,Ie.encode(e.signersName,t,r),r+=Ie.encode.bytes,s.copy(t,r,0,s.length),r+=s.length,Si.encode.bytes=r-n,t.writeUInt16BE(Si.encode.bytes-2,n),t};Si.encode.bytes=0;Si.decode=function(e,t){t||(t=0);let r=t;var n={},s=e.readUInt16BE(t);return t+=2,n.typeCovered=vs.toString(e.readUInt16BE(t)),t+=2,n.algorithm=e.readUInt8(t),t+=1,n.labels=e.readUInt8(t),t+=1,n.originalTTL=e.readUInt32BE(t),t+=4,n.expiration=e.readUInt32BE(t),t+=4,n.inception=e.readUInt32BE(t),t+=4,n.keyTag=e.readUInt16BE(t),t+=2,n.signersName=Ie.decode(e,t),t+=Ie.decode.bytes,n.signature=e.slice(t,r+s+2),t+=n.signature.length,Si.decode.bytes=t-r,n};Si.decode.bytes=0;Si.encodingLength=function(e){return 20+Ie.encodingLength(e.signersName)+xe.byteLength(e.signature)};var bi=Te.rp={};bi.encode=function(e,t,r){t||(t=xe.alloc(bi.encodingLength(e))),r||(r=0);let n=r;return r+=2,Ie.encode(e.mbox||".",t,r,{mail:!0}),r+=Ie.encode.bytes,Ie.encode(e.txt||".",t,r),r+=Ie.encode.bytes,bi.encode.bytes=r-n,t.writeUInt16BE(bi.encode.bytes-2,n),t};bi.encode.bytes=0;bi.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mbox=Ie.decode(e,t,{mail:!0})||".",t+=Ie.decode.bytes,n.txt=Ie.decode(e,t)||".",t+=Ie.decode.bytes,bi.decode.bytes=t-r,n};bi.decode.bytes=0;bi.encodingLength=function(e){return 2+Ie.encodingLength(e.mbox||".")+Ie.encodingLength(e.txt||".")};var pr={};pr.encode=function(e,t,r){t||(t=xe.alloc(pr.encodingLength(e))),r||(r=0);let n=r;for(var s=[],a=0;a>8]===void 0&&(s[i>>8]=[]),s[i>>8][i>>3&31]|=1<<7-(i&7)}for(a=0;a>8]=Math.max(t[n>>8]||0,n&255)}var s=0;for(r=0;r>15&1)===1,r.options=Cn.decode(e,t+8),t+=8+Cn.decode.bytes;else{let s=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=Bf.toString(s&II),r.flush=!!(s&_0);let a=I0(r.type);r.data=a.decode(e,t+8),t+=8+a.decode.bytes}return Sr.decode.bytes=t-n,r};Sr.decode.bytes=0;Sr.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return Ie.encodingLength(e.name)+8+I0(e.type).encodingLength(t)};var ei=Te.question={};ei.encode=function(e,t,r){t||(t=xe.alloc(ei.encodingLength(e))),r||(r=0);let n=r;return Ie.encode(e.name,t,r),r+=Ie.encode.bytes,t.writeUInt16BE(vs.toType(e.type),r),r+=2,t.writeUInt16BE(Bf.toClass(e.class===void 0?"IN":e.class),r),r+=2,ei.encode.bytes=r-n,e};ei.encode.bytes=0;ei.decode=function(e,t){t||(t=0);let r=t,n={};return n.name=Ie.decode(e,t),t+=Ie.decode.bytes,n.type=vs.toString(e.readUInt16BE(t)),t+=2,n.class=Bf.toString(e.readUInt16BE(t)),t+=2,!!(n.class&T2)&&(n.class&=DI),ei.decode.bytes=t-r,n};ei.decode.bytes=0;ei.encodingLength=function(e){return Ie.encodingLength(e.name)+4};Te.AUTHORITATIVE_ANSWER=1024;Te.TRUNCATED_RESPONSE=512;Te.RECURSION_DESIRED=256;Te.RECURSION_AVAILABLE=128;Te.AUTHENTIC_DATA=32;Te.CHECKING_DISABLED=16;Te.DNSSEC_OK=32768;Te.encode=function(e,t,r){let n=!t;n&&(t=xe.alloc(Te.encodingLength(e))),r||(r=0);let s=r;return e.questions||(e.questions=[]),e.answers||(e.answers=[]),e.authorities||(e.authorities=[]),e.additionals||(e.additionals=[]),ti.encode(e,t,r),r+=ti.encode.bytes,r=Sc(e.questions,ei,t,r),r=Sc(e.answers,Sr,t,r),r=Sc(e.authorities,Sr,t,r),r=Sc(e.additionals,Sr,t,r),Te.encode.bytes=r-s,n&&Te.encode.bytes!==t.length?t.slice(0,Te.encode.bytes):t};Te.encode.bytes=0;Te.decode=function(e,t){t||(t=0);let r=t,n=ti.decode(e,t);return t+=ti.decode.bytes,t=Df(n.questions,ei,e,t),t=Df(n.answers,Sr,e,t),t=Df(n.authorities,Sr,e,t),t=Df(n.additionals,Sr,e,t),Te.decode.bytes=t-r,n};Te.decode.bytes=0;Te.encodingLength=function(e){return ti.encodingLength(e)+to(e.questions||[],ei)+to(e.answers||[],Sr)+to(e.authorities||[],Sr)+to(e.additionals||[],Sr)};Te.streamEncode=function(e){let t=Te.encode(e),r=xe.alloc(2);r.writeUInt16BE(t.byteLength);let n=xe.concat([r,t]);return Te.streamEncode.bytes=n.byteLength,n};Te.streamEncode.bytes=0;Te.streamDecode=function(e){let t=e.readUInt16BE(0);if(e.byteLength{(function(){var e,t="4.17.21",r=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",i="__lodash_hash_undefined__",c=500,l="__lodash_placeholder__",h=1,v=2,E=4,p=1,f=2,w=1,m=2,y=4,A=8,b=16,_=32,I=64,B=128,j=256,V=512,F=30,P="...",k=800,L=16,M=1,X=2,K=3,q=1/0,Y=9007199254740991,re=17976931348623157e292,ye=NaN,we=4294967295,Be=we-1,He=we>>>1,oe=[["ary",B],["bind",w],["bindKey",m],["curry",A],["curryRight",b],["flip",V],["partial",_],["partialRight",I],["rearg",j]],Fe="[object Arguments]",Oe="[object Array]",ir="[object AsyncFunction]",Ft="[object Boolean]",ct="[object Date]",Mt="[object DOMException]",Bt="[object Error]",Qe="[object Function]",bt="[object GeneratorFunction]",Je="[object Map]",ft="[object Number]",qt="[object Null]",ze="[object Object]",Ot="[object Promise]",Pn="[object Proxy]",sr="[object RegExp]",gr="[object Set]",Gt="[object String]",br="[object Symbol]",Js="[object Undefined]",kr="[object WeakMap]",ht="[object WeakSet]",zt="[object ArrayBuffer]",Ye="[object DataView]",Cr="[object Float32Array]",Zs="[object Float64Array]",Qs="[object Int8Array]",ea="[object Int16Array]",ta="[object Int32Array]",Ti="[object Uint8Array]",ra="[object Uint8ClampedArray]",Cs="[object Uint16Array]",ri="[object Uint32Array]",xi=/\b__p \+= '';/g,Ga=/\b(__p \+=) '' \+/g,za=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ya=/&(?:amp|lt|gt|quot|#39);/g,Wa=/[&<>"']/g,Xa=RegExp(Ya.source),Ja=RegExp(Wa.source),Za=/<%-([\s\S]+?)%>/g,fo=/<%([\s\S]+?)%>/g,Qa=/<%=([\s\S]+?)%>/g,ho=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,po=/^\w*$/,go=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Fs=/[\\^$.*+?()[\]{}|]/g,mo=RegExp(Fs.source),na=/^\s+/,vo=/\s/,Ao=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,wo=/\{\n\/\* \[wrapped with (.+)\] \*/,Eo=/,? & /,yo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,So=/[()=,{}\[\]\/\s]/,bo=/\\(\\)?/g,Co=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ni=/\w*$/,eu=/^[-+]0x[0-9a-f]+$/i,Fo=/^0b[01]+$/i,_o=/^\[object .+?Constructor\]$/,Io=/^0o[0-7]+$/i,tu=/^(?:0|[1-9]\d*)$/,ii=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Yr=/($^)/,Do=/['\n\r\u2028\u2029\\]/g,_s="\\ud800-\\udfff",fn="\\u0300-\\u036f",Bo="\\ufe20-\\ufe2f",Po="\\u20d0-\\u20ff",ru=fn+Bo+Po,ia="\\u2700-\\u27bf",nu="a-z\\xdf-\\xf6\\xf8-\\xff",Is="\\xac\\xb1\\xd7\\xf7",kt="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",$o="\\u2000-\\u206f",Ro=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",iu="A-Z\\xc0-\\xd6\\xd8-\\xde",si="\\ufe0e\\ufe0f",ar=Is+kt+$o+Ro,Dt="['\u2019]",To="["+_s+"]",sa="["+ar+"]",ur="["+ru+"]",aa="\\d+",su="["+ia+"]",au="["+nu+"]",oa="[^"+_s+ar+aa+ia+nu+iu+"]",ai="\\ud83c[\\udffb-\\udfff]",ca="(?:"+ur+"|"+ai+")",uu="[^"+_s+"]",la="(?:\\ud83c[\\udde6-\\uddff]){2}",fa="[\\ud800-\\udbff][\\udc00-\\udfff]",Nr="["+iu+"]",$="\\u200d",T="(?:"+au+"|"+oa+")",U="(?:"+Nr+"|"+oa+")",J="(?:"+Dt+"(?:d|ll|m|re|s|t|ve))?",pe="(?:"+Dt+"(?:D|LL|M|RE|S|T|VE))?",me=ca+"?",Ce="["+si+"]?",Pe="(?:"+$+"(?:"+[uu,la,fa].join("|")+")"+Ce+me+")*",At="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Nt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",mr=Ce+me+Pe,vr="(?:"+[su,la,fa].join("|")+")"+mr,hn="(?:"+[uu+ur+"?",ur,la,fa,To].join("|")+")",Ds=RegExp(Dt,"g"),Lr=RegExp(ur,"g"),Ar=RegExp(ai+"(?="+ai+")|"+hn+mr,"g"),Bs=RegExp([Nr+"?"+au+"+"+J+"(?="+[sa,Nr,"$"].join("|")+")",U+"+"+pe+"(?="+[sa,Nr+T,"$"].join("|")+")",Nr+"?"+T+"+"+J,Nr+"+"+pe,Nt,At,aa,vr].join("|"),"g"),$n=RegExp("["+$+_s+ru+si+"]"),ha=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,zf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Yf=-1,Ct={};Ct[Cr]=Ct[Zs]=Ct[Qs]=Ct[ea]=Ct[ta]=Ct[Ti]=Ct[ra]=Ct[Cs]=Ct[ri]=!0,Ct[Fe]=Ct[Oe]=Ct[zt]=Ct[Ft]=Ct[Ye]=Ct[ct]=Ct[Bt]=Ct[Qe]=Ct[Je]=Ct[ft]=Ct[ze]=Ct[sr]=Ct[gr]=Ct[Gt]=Ct[kr]=!1;var yt={};yt[Fe]=yt[Oe]=yt[zt]=yt[Ye]=yt[Ft]=yt[ct]=yt[Cr]=yt[Zs]=yt[Qs]=yt[ea]=yt[ta]=yt[Je]=yt[ft]=yt[ze]=yt[sr]=yt[gr]=yt[Gt]=yt[br]=yt[Ti]=yt[ra]=yt[Cs]=yt[ri]=!0,yt[Bt]=yt[Qe]=yt[kr]=!1;var Wf={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Xf={"&":"&","<":"<",">":">",'"':""","'":"'"},Jf={"&":"&","<":"<",">":">",""":'"',"'":"'"},Zf={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Qf=parseFloat,eh=parseInt,kc=typeof global=="object"&&global&&global.Object===Object&&global,th=typeof self=="object"&&self&&self.Object===Object&&self,Yt=kc||th||Function("return this")(),xo=typeof no=="object"&&no&&!no.nodeType&&no,Oi=xo&&typeof bc=="object"&&bc&&!bc.nodeType&&bc,Nc=Oi&&Oi.exports===xo,Oo=Nc&&kc.process,Wr=function(){try{var ee=Oi&&Oi.require&&Oi.require("util").types;return ee||Oo&&Oo.binding&&Oo.binding("util")}catch{}}(),Lc=Wr&&Wr.isArrayBuffer,Uc=Wr&&Wr.isDate,Hc=Wr&&Wr.isMap,jc=Wr&&Wr.isRegExp,Mc=Wr&&Wr.isSet,qc=Wr&&Wr.isTypedArray;function Ur(ee,ce,ae){switch(ae.length){case 0:return ee.call(ce);case 1:return ee.call(ce,ae[0]);case 2:return ee.call(ce,ae[0],ae[1]);case 3:return ee.call(ce,ae[0],ae[1],ae[2])}return ee.apply(ce,ae)}function rh(ee,ce,ae,$e){for(var qe=-1,st=ee==null?0:ee.length;++qe-1}function pa(ee,ce,ae){for(var $e=-1,qe=ee==null?0:ee.length;++$e-1;);return ae}function zc(ee,ce){for(var ae=ee.length;ae--&&Ps(ce,ee[ae],0)>-1;);return ae}function Yc(ee,ce){for(var ae=ee.length,$e=0;ae--;)ee[ae]===ce&&++$e;return $e}var jo=he(Wf),sh=he(Xf);function Wc(ee){return"\\"+Zf[ee]}function ah(ee,ce){return ee==null?e:ee[ce]}function Ni(ee){return $n.test(ee)}function uh(ee){return ha.test(ee)}function oh(ee){for(var ce,ae=[];!(ce=ee.next()).done;)ae.push(ce.value);return ae}function Mo(ee){var ce=-1,ae=Array(ee.size);return ee.forEach(function($e,qe){ae[++ce]=[qe,$e]}),ae}function wr(ee,ce){return function(ae){return ee(ce(ae))}}function gn(ee,ce){for(var ae=-1,$e=ee.length,qe=0,st=[];++ae<$e;){var $t=ee[ae];($t===ce||$t===l)&&(ee[ae]=l,st[qe++]=ae)}return st}function mn(ee){var ce=-1,ae=Array(ee.size);return ee.forEach(function($e){ae[++ce]=$e}),ae}function lu(ee){var ce=-1,ae=Array(ee.size);return ee.forEach(function($e){ae[++ce]=[$e,$e]}),ae}function Xc(ee,ce,ae){for(var $e=ae-1,qe=ee.length;++$e-1}function Lw(u,o){var g=this.__data__,C=ul(g,u);return C<0?(++this.size,g.push([u,o])):g[C][1]=o,this}Mi.prototype.clear=xw,Mi.prototype.delete=Ow,Mi.prototype.get=kw,Mi.prototype.has=Nw,Mi.prototype.set=Lw;function qi(u){var o=-1,g=u==null?0:u.length;for(this.clear();++o=o?u:o)),u}function On(u,o,g,C,R,N){var G,W=o&h,te=o&v,de=o&E;if(g&&(G=R?g(u,C,R,N):g(u)),G!==e)return G;if(!Rt(u))return u;var ge=Ge(u);if(ge){if(G=ME(u),!W)return Qr(u,G)}else{var ve=Ir(u),_e=ve==Qe||ve==bt;if(Os(u))return jd(u,W);if(ve==ze||ve==Fe||_e&&!R){if(G=te||_e?{}:a1(u),!W)return te?$E(u,eE(G,u)):PE(u,vd(G,u))}else{if(!yt[ve])return R?u:{};G=qE(u,ve,W)}}N||(N=new zn);var Re=N.get(u);if(Re)return Re;N.set(u,G),O1(u)?u.forEach(function(Me){G.add(On(Me,o,g,Me,u,N))}):T1(u)&&u.forEach(function(Me,nt){G.set(nt,On(Me,o,g,nt,u,N))});var je=de?te?jh:Hh:te?tn:or,Ze=ge?e:je(u);return Xr(Ze||u,function(Me,nt){Ze&&(nt=Me,Me=u[nt]),zo(G,nt,On(Me,o,g,nt,u,N))}),G}function tE(u){var o=or(u);return function(g){return Ad(g,u,o)}}function Ad(u,o,g){var C=g.length;if(u==null)return!C;for(u=wt(u);C--;){var R=g[C],N=o[R],G=u[R];if(G===e&&!(R in u)||!N(G))return!1}return!0}function wd(u,o,g){if(typeof u!="function")throw new Zr(s);return ec(function(){u.apply(e,g)},o)}function Yo(u,o,g,C){var R=-1,N=Hr,G=!0,W=u.length,te=[],de=o.length;if(!W)return te;g&&(o=Q(o,Fr(g))),C?(N=pa,G=!1):o.length>=r&&(N=ga,G=!1,o=new va(o));e:for(;++RR?0:R+g),C=C===e||C>R?R:Xe(C),C<0&&(C+=R),C=g>C?0:N1(C);g0&&g(W)?o>1?Er(W,o-1,g,C,R):dn(R,W):C||(R[R.length]=W)}return R}var Sh=zd(),Sd=zd(!0);function oi(u,o){return u&&Sh(u,o,or)}function bh(u,o){return u&&Sd(u,o,or)}function cl(u,o){return pn(o,function(g){return Yi(u[g])})}function wa(u,o){o=Ts(o,u);for(var g=0,C=o.length;u!=null&&go}function iE(u,o){return u!=null&&ot.call(u,o)}function sE(u,o){return u!=null&&o in wt(u)}function aE(u,o,g){return u>=_r(o,g)&&u=120&&ge.length>=120)?new va(G&&ge):e}ge=u[0];var ve=-1,_e=W[0];e:for(;++ve-1;)W!==u&&pt.call(W,te,1),pt.call(u,te,1);return u}function Td(u,o){for(var g=u?o.length:0,C=g-1;g--;){var R=o[g];if(g==C||R!==N){var N=R;zi(R)?pt.call(u,R,1):Th(u,R)}}return u}function Ph(u,o){return u+ie(pd()*(o-u+1))}function wE(u,o,g,C){for(var R=-1,N=Zt(H((o-u)/(g||1)),0),G=ae(N);N--;)G[C?N:++R]=u,u+=g;return G}function $h(u,o){var g="";if(!u||o<1||o>Y)return g;do o%2&&(g+=u),o=ie(o/2),o&&(u+=u);while(o);return g}function et(u,o){return Yh(c1(u,o,rn),u+"")}function EE(u){return md(Du(u))}function yE(u,o){var g=Du(u);return El(g,Aa(o,0,g.length))}function Jo(u,o,g,C){if(!Rt(u))return u;o=Ts(o,u);for(var R=-1,N=o.length,G=N-1,W=u;W!=null&&++RR?0:R+o),g=g>R?R:g,g<0&&(g+=R),R=o>g?0:g-o>>>0,o>>>=0;for(var N=ae(R);++C>>1,G=u[N];G!==null&&!An(G)&&(g?G<=o:G=r){var de=o?null:OE(u);if(de)return mn(de);G=!1,R=ga,te=new va}else te=o?[]:W;e:for(;++C=C?u:kn(u,o,g)}var Hd=S||function(u){return Yt.clearTimeout(u)};function jd(u,o){if(o)return u.slice();var g=u.length,C=el?el(g):new u.constructor(g);return u.copy(C),C}function Nh(u){var o=new u.constructor(u.byteLength);return new Au(o).set(new Au(u)),o}function _E(u,o){var g=o?Nh(u.buffer):u.buffer;return new u.constructor(g,u.byteOffset,u.byteLength)}function IE(u){var o=new u.constructor(u.source,ni.exec(u));return o.lastIndex=u.lastIndex,o}function DE(u){return Go?wt(Go.call(u)):{}}function Md(u,o){var g=o?Nh(u.buffer):u.buffer;return new u.constructor(g,u.byteOffset,u.length)}function qd(u,o){if(u!==o){var g=u!==e,C=u===null,R=u===u,N=An(u),G=o!==e,W=o===null,te=o===o,de=An(o);if(!W&&!de&&!N&&u>o||N&&G&&te&&!W&&!de||C&&G&&te||!g&&te||!R)return 1;if(!C&&!N&&!de&&u=W)return te;var de=g[C];return te*(de=="desc"?-1:1)}}return u.index-o.index}function Kd(u,o,g,C){for(var R=-1,N=u.length,G=g.length,W=-1,te=o.length,de=Zt(N-G,0),ge=ae(te+de),ve=!C;++W1?g[R-1]:e,G=R>2?g[2]:e;for(N=u.length>3&&typeof N=="function"?(R--,N):e,G&&Mr(g[0],g[1],G)&&(N=R<3?e:N,R=1),o=wt(o);++C-1?R[N?o[G]:G]:e}}function Xd(u){return Gi(function(o){var g=o.length,C=g,R=xn.prototype.thru;for(u&&o.reverse();C--;){var N=o[C];if(typeof N!="function")throw new Zr(s);if(R&&!G&&Al(N)=="wrapper")var G=new xn([],!0)}for(C=G?C:g;++C1&&at.reverse(),ge&&teW))return!1;var de=N.get(u),ge=N.get(o);if(de&&ge)return de==o&&ge==u;var ve=-1,_e=!0,Re=g&f?new va:e;for(N.set(u,o),N.set(o,u);++ve1?"& ":"")+o[C],o=o.join(g>2?", ":" "),u.replace(Ao,`{ /* [wrapped with `+o+`] */ `)}function VE(u){return Ge(u)||Sa(u)||!!(nl&&u&&u[nl])}function zi(u,o){var g=typeof u;return o=o??Y,!!o&&(g=="number"||g!="symbol"&&tu.test(u))&&u>-1&&u%1==0&&u0){if(++o>=k)return arguments[0]}else o=0;return u.apply(e,arguments)}}function El(u,o){var g=-1,C=u.length,R=C-1;for(o=o===e?C:o;++g1?u[o-1]:e;return g=typeof g=="function"?(u.pop(),g):e,y1(u,g)});function S1(u){var o=O(u);return o.__chain__=!0,o}function ry(u,o){return o(u),u}function yl(u,o){return o(u)}var ny=Gi(function(u){var o=u.length,g=o?u[0]:0,C=this.__wrapped__,R=function(N){return yh(N,u)};return o>1||this.__actions__.length||!(C instanceof it)||!zi(g)?this.thru(R):(C=C.slice(g,+g+(o?1:0)),C.__actions__.push({func:yl,args:[R],thisArg:e}),new xn(C,this.__chain__).thru(function(N){return o&&!N.length&&N.push(e),N}))});function iy(){return S1(this)}function sy(){return new xn(this.value(),this.__chain__)}function ay(){this.__values__===e&&(this.__values__=k1(this.value()));var u=this.__index__>=this.__values__.length,o=u?e:this.__values__[this.__index__++];return{done:u,value:o}}function uy(){return this}function oy(u){for(var o,g=this;g instanceof al;){var C=g1(g);C.__index__=0,C.__values__=e,o?R.__wrapped__=C:o=C;var R=C;g=g.__wrapped__}return R.__wrapped__=u,o}function cy(){var u=this.__wrapped__;if(u instanceof it){var o=u;return this.__actions__.length&&(o=new it(this)),o=o.reverse(),o.__actions__.push({func:yl,args:[Wh],thisArg:e}),new xn(o,this.__chain__)}return this.thru(Wh)}function ly(){return Ld(this.__wrapped__,this.__actions__)}var fy=pl(function(u,o,g){ot.call(u,g)?++u[g]:Ki(u,g,1)});function hy(u,o,g){var C=Ge(u)?Ve:rE;return g&&Mr(u,o,g)&&(o=e),C(u,Le(o,3))}function py(u,o){var g=Ge(u)?pn:yd;return g(u,Le(o,3))}var dy=Wd(m1),gy=Wd(v1);function my(u,o){return Er(Sl(u,o),1)}function vy(u,o){return Er(Sl(u,o),q)}function Ay(u,o,g){return g=g===e?1:Xe(g),Er(Sl(u,o),g)}function b1(u,o){var g=Ge(u)?Xr:$s;return g(u,Le(o,3))}function C1(u,o){var g=Ge(u)?D:Ed;return g(u,Le(o,3))}var wy=pl(function(u,o,g){ot.call(u,g)?u[g].push(o):Ki(u,g,[o])});function Ey(u,o,g,C){u=en(u)?u:Du(u),g=g&&!C?Xe(g):0;var R=u.length;return g<0&&(g=Zt(R+g,0)),Il(u)?g<=R&&u.indexOf(o,g)>-1:!!R&&Ps(u,o,g)>-1}var yy=et(function(u,o,g){var C=-1,R=typeof o=="function",N=en(u)?ae(u.length):[];return $s(u,function(G){N[++C]=R?Ur(o,G,g):Wo(G,o,g)}),N}),Sy=pl(function(u,o,g){Ki(u,g,o)});function Sl(u,o){var g=Ge(u)?Q:Id;return g(u,Le(o,3))}function by(u,o,g,C){return u==null?[]:(Ge(o)||(o=o==null?[]:[o]),g=C?e:g,Ge(g)||(g=g==null?[]:[g]),$d(u,o,g))}var Cy=pl(function(u,o,g){u[g?0:1].push(o)},function(){return[[],[]]});function Fy(u,o,g){var C=Ge(u)?ko:Vc,R=arguments.length<3;return C(u,Le(o,4),g,R,$s)}function _y(u,o,g){var C=Ge(u)?fd:Vc,R=arguments.length<3;return C(u,Le(o,4),g,R,Ed)}function Iy(u,o){var g=Ge(u)?pn:yd;return g(u,Fl(Le(o,3)))}function Dy(u){var o=Ge(u)?md:EE;return o(u)}function By(u,o,g){(g?Mr(u,o,g):o===e)?o=1:o=Xe(o);var C=Ge(u)?Jw:yE;return C(u,o)}function Py(u){var o=Ge(u)?Zw:bE;return o(u)}function $y(u){if(u==null)return 0;if(en(u))return Il(u)?Li(u):u.length;var o=Ir(u);return o==Je||o==gr?u.size:Ih(u).length}function Ry(u,o,g){var C=Ge(u)?Kc:CE;return g&&Mr(u,o,g)&&(o=e),C(u,Le(o,3))}var Ty=et(function(u,o){if(u==null)return[];var g=o.length;return g>1&&Mr(u,o[0],o[1])?o=[]:g>2&&Mr(o[0],o[1],o[2])&&(o=[o[0]]),$d(u,Er(o,1),[])}),bl=x||function(){return Yt.Date.now()};function xy(u,o){if(typeof o!="function")throw new Zr(s);return u=Xe(u),function(){if(--u<1)return o.apply(this,arguments)}}function F1(u,o,g){return o=g?e:o,o=u&&o==null?u.length:o,Vi(u,B,e,e,e,e,o)}function _1(u,o){var g;if(typeof o!="function")throw new Zr(s);return u=Xe(u),function(){return--u>0&&(g=o.apply(this,arguments)),u<=1&&(o=e),g}}var Jh=et(function(u,o,g){var C=w;if(g.length){var R=gn(g,_u(Jh));C|=_}return Vi(u,C,o,g,R)}),I1=et(function(u,o,g){var C=w|m;if(g.length){var R=gn(g,_u(I1));C|=_}return Vi(o,C,u,g,R)});function D1(u,o,g){o=g?e:o;var C=Vi(u,A,e,e,e,e,e,o);return C.placeholder=D1.placeholder,C}function B1(u,o,g){o=g?e:o;var C=Vi(u,b,e,e,e,e,e,o);return C.placeholder=B1.placeholder,C}function P1(u,o,g){var C,R,N,G,W,te,de=0,ge=!1,ve=!1,_e=!0;if(typeof u!="function")throw new Zr(s);o=Ln(o)||0,Rt(g)&&(ge=!!g.leading,ve="maxWait"in g,N=ve?Zt(Ln(g.maxWait)||0,o):N,_e="trailing"in g?!!g.trailing:_e);function Re(Vt){var Wn=C,Xi=R;return C=R=e,de=Vt,G=u.apply(Xi,Wn),G}function je(Vt){return de=Vt,W=ec(nt,o),ge?Re(Vt):G}function Ze(Vt){var Wn=Vt-te,Xi=Vt-de,W1=o-Wn;return ve?_r(W1,N-Xi):W1}function Me(Vt){var Wn=Vt-te,Xi=Vt-de;return te===e||Wn>=o||Wn<0||ve&&Xi>=N}function nt(){var Vt=bl();if(Me(Vt))return at(Vt);W=ec(nt,Ze(Vt))}function at(Vt){return W=e,_e&&C?Re(Vt):(C=R=e,G)}function wn(){W!==e&&Hd(W),de=0,C=te=R=W=e}function qr(){return W===e?G:at(bl())}function En(){var Vt=bl(),Wn=Me(Vt);if(C=arguments,R=this,te=Vt,Wn){if(W===e)return je(te);if(ve)return Hd(W),W=ec(nt,o),Re(te)}return W===e&&(W=ec(nt,o)),G}return En.cancel=wn,En.flush=qr,En}var Oy=et(function(u,o){return wd(u,1,o)}),ky=et(function(u,o,g){return wd(u,Ln(o)||0,g)});function Ny(u){return Vi(u,V)}function Cl(u,o){if(typeof u!="function"||o!=null&&typeof o!="function")throw new Zr(s);var g=function(){var C=arguments,R=o?o.apply(this,C):C[0],N=g.cache;if(N.has(R))return N.get(R);var G=u.apply(this,C);return g.cache=N.set(R,G)||N,G};return g.cache=new(Cl.Cache||qi),g}Cl.Cache=qi;function Fl(u){if(typeof u!="function")throw new Zr(s);return function(){var o=arguments;switch(o.length){case 0:return!u.call(this);case 1:return!u.call(this,o[0]);case 2:return!u.call(this,o[0],o[1]);case 3:return!u.call(this,o[0],o[1],o[2])}return!u.apply(this,o)}}function Ly(u){return _1(2,u)}var Uy=FE(function(u,o){o=o.length==1&&Ge(o[0])?Q(o[0],Fr(Le())):Q(Er(o,1),Fr(Le()));var g=o.length;return et(function(C){for(var R=-1,N=_r(C.length,g);++R=o}),Sa=Cd(function(){return arguments}())?Cd:function(u){return Ut(u)&&ot.call(u,"callee")&&!rl.call(u,"callee")},Ge=ae.isArray,e6=Lc?Fr(Lc):oE;function en(u){return u!=null&&_l(u.length)&&!Yi(u)}function Kt(u){return Ut(u)&&en(u)}function t6(u){return u===!0||u===!1||Ut(u)&&jr(u)==Ft}var Os=Et||cp,r6=Uc?Fr(Uc):cE;function n6(u){return Ut(u)&&u.nodeType===1&&!tc(u)}function i6(u){if(u==null)return!0;if(en(u)&&(Ge(u)||typeof u=="string"||typeof u.splice=="function"||Os(u)||Iu(u)||Sa(u)))return!u.length;var o=Ir(u);if(o==Je||o==gr)return!u.size;if(Qo(u))return!Ih(u).length;for(var g in u)if(ot.call(u,g))return!1;return!0}function s6(u,o){return Xo(u,o)}function a6(u,o,g){g=typeof g=="function"?g:e;var C=g?g(u,o):e;return C===e?Xo(u,o,e,g):!!C}function Qh(u){if(!Ut(u))return!1;var o=jr(u);return o==Bt||o==Mt||typeof u.message=="string"&&typeof u.name=="string"&&!tc(u)}function u6(u){return typeof u=="number"&&Lt(u)}function Yi(u){if(!Rt(u))return!1;var o=jr(u);return o==Qe||o==bt||o==ir||o==Pn}function R1(u){return typeof u=="number"&&u==Xe(u)}function _l(u){return typeof u=="number"&&u>-1&&u%1==0&&u<=Y}function Rt(u){var o=typeof u;return u!=null&&(o=="object"||o=="function")}function Ut(u){return u!=null&&typeof u=="object"}var T1=Hc?Fr(Hc):fE;function o6(u,o){return u===o||_h(u,o,qh(o))}function c6(u,o,g){return g=typeof g=="function"?g:e,_h(u,o,qh(o),g)}function l6(u){return x1(u)&&u!=+u}function f6(u){if(YE(u))throw new qe(n);return Fd(u)}function h6(u){return u===null}function p6(u){return u==null}function x1(u){return typeof u=="number"||Ut(u)&&jr(u)==ft}function tc(u){if(!Ut(u)||jr(u)!=ze)return!1;var o=wu(u);if(o===null)return!0;var g=ot.call(o,"constructor")&&o.constructor;return typeof g=="function"&&g instanceof g&&du.call(g)==gh}var ep=jc?Fr(jc):hE;function d6(u){return R1(u)&&u>=-Y&&u<=Y}var O1=Mc?Fr(Mc):pE;function Il(u){return typeof u=="string"||!Ge(u)&&Ut(u)&&jr(u)==Gt}function An(u){return typeof u=="symbol"||Ut(u)&&jr(u)==br}var Iu=qc?Fr(qc):dE;function g6(u){return u===e}function m6(u){return Ut(u)&&Ir(u)==kr}function v6(u){return Ut(u)&&jr(u)==ht}var A6=vl(Dh),w6=vl(function(u,o){return u<=o});function k1(u){if(!u)return[];if(en(u))return Il(u)?Jr(u):Qr(u);if(Hi&&u[Hi])return oh(u[Hi]());var o=Ir(u),g=o==Je?Mo:o==gr?mn:Du;return g(u)}function Wi(u){if(!u)return u===0?u:0;if(u=Ln(u),u===q||u===-q){var o=u<0?-1:1;return o*re}return u===u?u:0}function Xe(u){var o=Wi(u),g=o%1;return o===o?g?o-g:o:0}function N1(u){return u?Aa(Xe(u),0,we):0}function Ln(u){if(typeof u=="number")return u;if(An(u))return ye;if(Rt(u)){var o=typeof u.valueOf=="function"?u.valueOf():u;u=Rt(o)?o+"":o}if(typeof u!="string")return u===0?u:+u;u=Ho(u);var g=Fo.test(u);return g||Io.test(u)?eh(u.slice(2),g?2:8):eu.test(u)?ye:+u}function L1(u){return ci(u,tn(u))}function E6(u){return u?Aa(Xe(u),-Y,Y):u===0?u:0}function mt(u){return u==null?"":vn(u)}var y6=Cu(function(u,o){if(Qo(o)||en(o)){ci(o,or(o),u);return}for(var g in o)ot.call(o,g)&&zo(u,g,o[g])}),U1=Cu(function(u,o){ci(o,tn(o),u)}),Dl=Cu(function(u,o,g,C){ci(o,tn(o),u,C)}),S6=Cu(function(u,o,g,C){ci(o,or(o),u,C)}),b6=Gi(yh);function C6(u,o){var g=bu(u);return o==null?g:vd(g,o)}var F6=et(function(u,o){u=wt(u);var g=-1,C=o.length,R=C>2?o[2]:e;for(R&&Mr(o[0],o[1],R)&&(C=1);++g1),N}),ci(u,jh(u),g),C&&(g=On(g,h|v|E,kE));for(var R=o.length;R--;)Th(g,o[R]);return g});function q6(u,o){return j1(u,Fl(Le(o)))}var K6=Gi(function(u,o){return u==null?{}:vE(u,o)});function j1(u,o){if(u==null)return{};var g=Q(jh(u),function(C){return[C]});return o=Le(o),Rd(u,g,function(C,R){return o(C,R[0])})}function V6(u,o,g){o=Ts(o,u);var C=-1,R=o.length;for(R||(R=1,u=e);++Co){var C=u;u=o,o=C}if(g||u%1||o%1){var R=pd();return _r(u+R*(o-u+Qf("1e-"+((R+"").length-1))),o)}return Ph(u,o)}var r5=Fu(function(u,o,g){return o=o.toLowerCase(),u+(g?K1(o):o)});function K1(u){return np(mt(u).toLowerCase())}function V1(u){return u=mt(u),u&&u.replace(ii,jo).replace(Lr,"")}function n5(u,o,g){u=mt(u),o=vn(o);var C=u.length;g=g===e?C:Aa(Xe(g),0,C);var R=g;return g-=o.length,g>=0&&u.slice(g,R)==o}function i5(u){return u=mt(u),u&&Ja.test(u)?u.replace(Wa,sh):u}function s5(u){return u=mt(u),u&&mo.test(u)?u.replace(Fs,"\\$&"):u}var a5=Fu(function(u,o,g){return u+(g?"-":"")+o.toLowerCase()}),u5=Fu(function(u,o,g){return u+(g?" ":"")+o.toLowerCase()}),o5=Yd("toLowerCase");function c5(u,o,g){u=mt(u),o=Xe(o);var C=o?Li(u):0;if(!o||C>=o)return u;var R=(o-C)/2;return ml(ie(R),g)+u+ml(H(R),g)}function l5(u,o,g){u=mt(u),o=Xe(o);var C=o?Li(u):0;return o&&C>>0,g?(u=mt(u),u&&(typeof o=="string"||o!=null&&!ep(o))&&(o=vn(o),!o&&Ni(u))?xs(Jr(u),0,g):u.split(o,g)):[]}var v5=Fu(function(u,o,g){return u+(g?" ":"")+np(o)});function A5(u,o,g){return u=mt(u),g=g==null?0:Aa(Xe(g),0,u.length),o=vn(o),u.slice(g,g+o.length)==o}function w5(u,o,g){var C=O.templateSettings;g&&Mr(u,o,g)&&(o=e),u=mt(u),o=Dl({},o,C,t1);var R=Dl({},o.imports,C.imports,t1),N=or(R),G=da(R,N),W,te,de=0,ge=o.interpolate||Yr,ve="__p += '",_e=hu((o.escape||Yr).source+"|"+ge.source+"|"+(ge===Qa?Co:Yr).source+"|"+(o.evaluate||Yr).source+"|$","g"),Re="//# sourceURL="+(ot.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Yf+"]")+` `;u.replace(_e,function(Me,nt,at,wn,qr,En){return at||(at=wn),ve+=u.slice(de,En).replace(Do,Wc),nt&&(W=!0,ve+=`' + __e(`+nt+`) + '`),qr&&(te=!0,ve+=`'; `+qr+`; __p += '`),at&&(ve+=`' + ((__t = (`+at+`)) == null ? '' : __t) + '`),de=En+Me.length,Me}),ve+=`'; `;var je=ot.call(o,"variable")&&o.variable;if(!je)ve=`with (obj) { `+ve+` } `;else if(So.test(je))throw new qe(a);ve=(te?ve.replace(xi,""):ve).replace(Ga,"$1").replace(za,"$1;"),ve="function("+(je||"obj")+`) { `+(je?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(W?", __e = _.escape":"")+(te?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+ve+`return __p }`;var Ze=z1(function(){return st(N,Re+"return "+ve).apply(e,G)});if(Ze.source=ve,Qh(Ze))throw Ze;return Ze}function E5(u){return mt(u).toLowerCase()}function y5(u){return mt(u).toUpperCase()}function S5(u,o,g){if(u=mt(u),u&&(g||o===e))return Ho(u);if(!u||!(o=vn(o)))return u;var C=Jr(u),R=Jr(o),N=cu(C,R),G=zc(C,R)+1;return xs(C,N,G).join("")}function b5(u,o,g){if(u=mt(u),u&&(g||o===e))return u.slice(0,fu(u)+1);if(!u||!(o=vn(o)))return u;var C=Jr(u),R=zc(C,Jr(o))+1;return xs(C,0,R).join("")}function C5(u,o,g){if(u=mt(u),u&&(g||o===e))return u.replace(na,"");if(!u||!(o=vn(o)))return u;var C=Jr(u),R=cu(C,Jr(o));return xs(C,R).join("")}function F5(u,o){var g=F,C=P;if(Rt(o)){var R="separator"in o?o.separator:R;g="length"in o?Xe(o.length):g,C="omission"in o?vn(o.omission):C}u=mt(u);var N=u.length;if(Ni(u)){var G=Jr(u);N=G.length}if(g>=N)return u;var W=g-Li(C);if(W<1)return C;var te=G?xs(G,0,W).join(""):u.slice(0,W);if(R===e)return te+C;if(G&&(W+=te.length-W),ep(R)){if(u.slice(W).search(R)){var de,ge=te;for(R.global||(R=hu(R.source,mt(ni.exec(R))+"g")),R.lastIndex=0;de=R.exec(ge);)var ve=de.index;te=te.slice(0,ve===e?W:ve)}}else if(u.indexOf(vn(R),W)!=W){var _e=te.lastIndexOf(R);_e>-1&&(te=te.slice(0,_e))}return te+C}function _5(u){return u=mt(u),u&&Xa.test(u)?u.replace(Ya,Jc):u}var I5=Fu(function(u,o,g){return u+(g?" ":"")+o.toUpperCase()}),np=Yd("toUpperCase");function G1(u,o,g){return u=mt(u),o=g?e:o,o===e?uh(u)?fh(u):No(u):u.match(o)||[]}var z1=et(function(u,o){try{return Ur(u,e,o)}catch(g){return Qh(g)?g:new qe(g)}}),D5=Gi(function(u,o){return Xr(o,function(g){g=li(g),Ki(u,g,Jh(u[g],u))}),u});function B5(u){var o=u==null?0:u.length,g=Le();return u=o?Q(u,function(C){if(typeof C[1]!="function")throw new Zr(s);return[g(C[0]),C[1]]}):[],et(function(C){for(var R=-1;++RY)return[];var g=we,C=_r(u,we);o=Le(o),u-=we;for(var R=Uo(C,o);++g0||o<0)?new it(g):(u<0?g=g.takeRight(-u):u&&(g=g.drop(u)),o!==e&&(o=Xe(o),g=o<0?g.dropRight(-o):g.take(o-u)),g)},it.prototype.takeRightWhile=function(u){return this.reverse().takeWhile(u).reverse()},it.prototype.toArray=function(){return this.take(we)},oi(it.prototype,function(u,o){var g=/^(?:filter|find|map|reject)|While$/.test(o),C=/^(?:head|last)$/.test(o),R=O[C?"take"+(o=="last"?"Right":""):o],N=C||/^find/.test(o);R&&(O.prototype[o]=function(){var G=this.__wrapped__,W=C?[1]:arguments,te=G instanceof it,de=W[0],ge=te||Ge(G),ve=function(nt){var at=R.apply(O,dn([nt],W));return C&&_e?at[0]:at};ge&&g&&typeof de=="function"&&de.length!=1&&(te=ge=!1);var _e=this.__chain__,Re=!!this.__actions__.length,je=N&&!_e,Ze=te&&!Re;if(!N&&ge){G=Ze?G:new it(this);var Me=u.apply(G,W);return Me.__actions__.push({func:yl,args:[ve],thisArg:e}),new xn(Me,_e)}return je&&Ze?u.apply(this,W):(Me=this.thru(ve),je?C?Me.value()[0]:Me.value():Me)})}),Xr(["pop","push","shift","sort","splice","unshift"],function(u){var o=pu[u],g=/^(?:push|sort|unshift)$/.test(u)?"tap":"thru",C=/^(?:pop|shift)$/.test(u);O.prototype[u]=function(){var R=arguments;if(C&&!this.__chain__){var N=this.value();return o.apply(Ge(N)?N:[],R)}return this[g](function(G){return o.apply(Ge(G)?G:[],R)})}}),oi(it.prototype,function(u,o){var g=O[o];if(g){var C=g.name+"";ot.call(Su,C)||(Su[C]=[]),Su[C].push({name:o,func:g})}}),Su[dl(e,m).name]=[{name:"wrapper",func:e}],it.prototype.clone=_w,it.prototype.reverse=Iw,it.prototype.value=Dw,O.prototype.at=ny,O.prototype.chain=iy,O.prototype.commit=sy,O.prototype.next=ay,O.prototype.plant=oy,O.prototype.reverse=cy,O.prototype.toJSON=O.prototype.valueOf=O.prototype.value=ly,O.prototype.first=O.prototype.head,Hi&&(O.prototype[Hi]=uy),O},Tn=hh();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Yt._=Tn,define(function(){return Tn})):Oi?((Oi.exports=Tn)._=Tn,xo._=Tn):Yt._=Tn}).call(no)});var Uf=be((FT,tA)=>{"use strict";var yD=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},N0=class e extends Error{constructor(t,r,n){super(t),yD(this,e.prototype),this.name="GrammarError",this.location=r,n===void 0&&(n=[]),this.diagnostics=n,this.stage=null,this.problems=[["error",t,r,n]]}toString(){let t=super.toString();this.location&&(t+=` at `,this.location.source!==void 0&&this.location.source!==null&&(t+=`${this.location.source}:`),t+=`${this.location.start.line}:${this.location.start.column}`);for(let r of this.diagnostics)t+=` from `,r.location.source!==void 0&&r.location.source!==null&&(t+=`${r.location.source}:`),t+=`${r.location.start.line}:${r.location.start.column}: ${r.message}`;return t}format(t){let r=t.map(({source:a,text:i})=>({source:a,text:i.split(/\r\n|\n|\r/g)}));function n(a,i,c=""){let l="",h=r.find(({source:E})=>E===a.source),v=a.start;if(h){let E=a.end,p=h.text[v.line-1],w=(v.line===E.line?E.column:p.length+1)-v.column||1;c&&(l+=` note: ${c}`),l+=` --> ${a.source}:${v.line}:${v.column} ${"".padEnd(i)} | ${v.line.toString().padStart(i)} | ${p} ${"".padEnd(i)} | ${"".padEnd(v.column-1)}${"".padEnd(w,"^")}`}else l+=` at ${a.source}:${v.line}:${v.column}`,c&&(l+=`: ${c}`);return l}function s(a,i,c,l=[]){let h;c?h=l.reduce((E,{location:p})=>Math.max(E,p.start.line),c.start.line):h=Math.max.apply(null,l.map(E=>E.location.start.line)),h=h.toString().length;let v=`${a}: ${i}`;c&&(v+=n(c,h));for(let E of l)v+=n(E.location,h,E.message);return v}return this.problems.filter(a=>a[0]!=="info").map(a=>s(...a)).join(` `)}};tA.exports=N0});var Kn=be((_T,rA)=>{"use strict";var SD={build(e){function t(i,...c){return e[i.type](i,...c)}function r(){}function n(i,...c){return t(i.expression,...c)}function s(i){return function(c,...l){c[i].forEach(h=>t(h,...l))}}let a={grammar(i,...c){i.topLevelInitializer&&t(i.topLevelInitializer,...c),i.initializer&&t(i.initializer,...c),i.rules.forEach(l=>t(l,...c))},top_level_initializer:r,initializer:r,rule:n,named:n,choice:s("alternatives"),action:n,sequence:s("elements"),labeled:n,text:n,simple_and:n,simple_not:n,optional:n,zero_or_more:n,one_or_more:n,group:n,semantic_and:r,semantic_not:r,rule_ref:r,literal:r,class:r,any:r};return Object.keys(a).forEach(i=>{Object.prototype.hasOwnProperty.call(e,i)||(e[i]=a[i])}),t}};rA.exports=SD});var zs=be((IT,iA)=>{"use strict";var bD=Kn(),nA={findRule(e,t){for(let r=0;r{"use strict";var CD={PUSH:0,PUSH_EMPTY_STRING:35,PUSH_UNDEFINED:1,PUSH_NULL:2,PUSH_FAILED:3,PUSH_EMPTY_ARRAY:4,PUSH_CURR_POS:5,POP:6,POP_CURR_POS:7,POP_N:8,NIP:9,APPEND:10,WRAP:11,TEXT:12,PLUCK:36,IF:13,IF_ERROR:14,IF_NOT_ERROR:15,WHILE_NOT_ERROR:16,MATCH_ANY:17,MATCH_STRING:18,MATCH_STRING_IC:19,MATCH_CHAR_CLASS:20,MATCH_REGEXP:20,ACCEPT_N:21,ACCEPT_STRING:22,FAIL:23,LOAD_SAVED_POS:24,UPDATE_SAVED_POS:25,CALL:26,RULE:27,SILENT_FAILS_ON:28,SILENT_FAILS_OFF:29};sA.exports=CD});var U0=be((BT,aA)=>{"use strict";var FD=Kn(),_D=zs(),ID=Uf(),Bc=1,Va=0,Pc=-1;function Hf(e){function t(i){return i.match=Va}function r(i){return a(i.expression),i.match=Bc}function n(i){return i.match=a(i.expression)}function s(i,c){let l=i.length,h=0,v=0;for(let E=0;E0?Pc:Va}let a=FD.build({rule(i){let c,l=0;if(typeof i.match>"u"){i.match=Va;do if(c=i.match,i.match=a(i.expression),++l>6)throw new ID("Infinity cycle detected when trying to evaluate node match result",i.location);while(c!==i.match)}return i.match},named:n,choice(i){return i.match=s(i.alternatives,!0)},action:n,sequence(i){return i.match=s(i.elements,!1)},labeled:n,text:n,simple_and:n,simple_not(i){return i.match=-a(i.expression)},optional:r,zero_or_more:r,one_or_more:n,group:n,semantic_and:t,semantic_not:t,rule_ref(i){let c=_D.findRule(e,i.name);return i.match=a(c)},literal(i){let c=i.value.length===0?Bc:Va;return i.match=c},class(i){let c=i.parts.length===0?Pc:Va;return i.match=c},any:t});a(e)}Hf.ALWAYS_MATCH=Bc;Hf.SOMETIMES_MATCH=Va;Hf.NEVER_MATCH=Pc;aA.exports=Hf});var oA=be((PT,uA)=>{"use strict";var DD=zs(),De=L0(),BD=Kn(),{ALWAYS_MATCH:oo,SOMETIMES_MATCH:H0,NEVER_MATCH:j0}=U0();function PD(e){let t=[],r=[],n=[],s=[];function a(b){let _=t.indexOf(b);return _===-1?t.push(b)-1:_}function i(b){let _={value:b.parts,inverted:b.inverted,ignoreCase:b.ignoreCase},I=JSON.stringify(_),B=r.findIndex(j=>JSON.stringify(j)===I);return B===-1?r.push(_)-1:B}function c(b){let _=JSON.stringify(b),I=n.findIndex(B=>JSON.stringify(B)===_);return I===-1?n.push(b)-1:I}function l(b,_,I){let B={predicate:b,params:_,body:I.code,location:I.codeLocation},j=JSON.stringify(B),V=s.findIndex(F=>JSON.stringify(F)===j);return V===-1?s.push(B)-1:V}function h(b){let _={};return Object.keys(b).forEach(I=>{_[I]=b[I]}),_}function v(b,..._){return b.concat(..._)}function E(b,_,I,B){return b===oo?I:b===j0?B:_.concat([I.length,B.length],I,B)}function p(b,_){return b.concat([_.length],_)}function f(b,_,I,B){let j=Object.keys(I).map(V=>B-I[V]);return[De.CALL,b,_,j.length].concat(j)}function w(b,_,I){let B=b.match|0;return v([De.PUSH_CURR_POS],[De.SILENT_FAILS_ON],A(b,{sp:I.sp+1,env:h(I.env),action:null}),[De.SILENT_FAILS_OFF],E(_?-B:B,[_?De.IF_ERROR:De.IF_NOT_ERROR],v([De.POP],[_?De.POP:De.POP_CURR_POS],[De.PUSH_UNDEFINED]),v([De.POP],[_?De.POP_CURR_POS:De.POP],[De.PUSH_FAILED])))}function m(b,_,I){let B=l(!0,Object.keys(I.env),b);return v([De.UPDATE_SAVED_POS],f(B,0,I.env,I.sp),E(b.match|0,[De.IF],v([De.POP],_?[De.PUSH_FAILED]:[De.PUSH_UNDEFINED]),v([De.POP],_?[De.PUSH_UNDEFINED]:[De.PUSH_FAILED])))}function y(b){return p([De.WHILE_NOT_ERROR],v([De.APPEND],b))}let A=BD.build({grammar(b){b.rules.forEach(A),b.literals=t,b.classes=r,b.expectations=n,b.functions=s},rule(b){b.bytecode=A(b.expression,{sp:-1,env:{},pluck:[],action:null})},named(b,_){let I=b.match|0,B=I===j0?null:c({type:"rule",value:b.name});return v([De.SILENT_FAILS_ON],A(b.expression,_),[De.SILENT_FAILS_OFF],E(I,[De.IF_ERROR],[De.FAIL,B],[]))},choice(b,_){function I(B,j){let V=B[0].match|0,F=A(B[0],{sp:j.sp,env:h(j.env),action:null});return V===oo?F:v(F,B.length>1?E(H0,[De.IF_ERROR],v([De.POP],I(B.slice(1),j)),[]):[])}return I(b.alternatives,_)},action(b,_){let I=h(_.env),B=b.expression.type!=="sequence"||b.expression.elements.length===0,j=A(b.expression,{sp:_.sp+(B?1:0),env:I,action:b}),V=b.expression.match|0,F=B&&V!==j0?l(!1,Object.keys(I),b):null;return B?v([De.PUSH_CURR_POS],j,E(V,[De.IF_NOT_ERROR],v([De.LOAD_SAVED_POS,1],f(F,1,I,_.sp+2)),[]),[De.NIP]):j},sequence(b,_){function I(B,j){if(B.length>0){let V=b.elements.length-B.length+1;return v(A(B[0],{sp:j.sp,env:j.env,pluck:j.pluck,action:null}),E(B[0].match|0,[De.IF_NOT_ERROR],I(B.slice(1),{sp:j.sp+1,env:j.env,pluck:j.pluck,action:j.action}),v(V>1?[De.POP_N,V]:[De.POP],[De.POP_CURR_POS],[De.PUSH_FAILED])))}else{if(j.pluck.length>0)return v([De.PLUCK,b.elements.length+1,j.pluck.length],j.pluck.map(V=>j.sp-V));if(j.action){let V=l(!1,Object.keys(j.env),j.action);return v([De.LOAD_SAVED_POS,b.elements.length],f(V,b.elements.length+1,j.env,j.sp))}else return v([De.WRAP,b.elements.length],[De.NIP])}}return v([De.PUSH_CURR_POS],I(b.elements,{sp:_.sp+1,env:_.env,pluck:[],action:_.action}))},labeled(b,_){let I=_.env,B=b.label,j=_.sp+1;return B&&(I=h(_.env),_.env[b.label]=j),b.pick&&_.pluck.push(j),A(b.expression,{sp:_.sp,env:I,action:null})},text(b,_){return v([De.PUSH_CURR_POS],A(b.expression,{sp:_.sp+1,env:h(_.env),action:null}),E(b.match|0,[De.IF_NOT_ERROR],v([De.POP],[De.TEXT]),[De.NIP]))},simple_and(b,_){return w(b.expression,!1,_)},simple_not(b,_){return w(b.expression,!0,_)},optional(b,_){return v(A(b.expression,{sp:_.sp,env:h(_.env),action:null}),E(-(b.expression.match|0),[De.IF_ERROR],v([De.POP],[De.PUSH_NULL]),[]))},zero_or_more(b,_){let I=A(b.expression,{sp:_.sp+1,env:h(_.env),action:null});return v([De.PUSH_EMPTY_ARRAY],I,y(I),[De.POP])},one_or_more(b,_){let I=A(b.expression,{sp:_.sp+1,env:h(_.env),action:null});return v([De.PUSH_EMPTY_ARRAY],I,E(b.expression.match|0,[De.IF_NOT_ERROR],v(y(I),[De.POP]),v([De.POP],[De.POP],[De.PUSH_FAILED])))},group(b,_){return A(b.expression,{sp:_.sp,env:h(_.env),action:null})},semantic_and(b,_){return m(b,!1,_)},semantic_not(b,_){return m(b,!0,_)},rule_ref(b){return[De.RULE,DD.indexOfRule(e,b.name)]},literal(b){if(b.value.length>0){let _=b.match|0,B=_===H0||_===oo&&!b.ignoreCase?a(b.ignoreCase?b.value.toLowerCase():b.value):null,j=_!==oo?c({type:"literal",value:b.value,ignoreCase:b.ignoreCase}):null;return E(_,b.ignoreCase?[De.MATCH_STRING_IC,B]:[De.MATCH_STRING,B],b.ignoreCase?[De.ACCEPT_N,b.value.length]:[De.ACCEPT_STRING,B],[De.FAIL,j])}return[De.PUSH_EMPTY_STRING]},class(b){let _=b.match|0,I=_===H0?i(b):null,B=_!==oo?c({type:"class",value:b.parts,inverted:b.inverted,ignoreCase:b.ignoreCase}):null;return E(_,[De.MATCH_CHAR_CLASS,I],[De.ACCEPT_N,1],[De.FAIL,B])},any(b){let _=b.match|0,I=_!==oo?c({type:"any"}):null;return E(_,[De.MATCH_ANY],[De.ACCEPT_N,1],[De.FAIL,I])}});A(e)}uA.exports=PD});var lA=be(($T,cA)=>{"use strict";var M0=class{constructor(t,r,n){this.sp=-1,this.maxSp=-1,this.varName=r,this.ruleName=t,this.type=n}name(t){if(t<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack underflow: attempt to use a variable '${this.varName}' at an index ${t}`);return this.varName+t}push(t){let r=this.name(++this.sp)+" = "+t+";";return this.sp>this.maxSp&&(this.maxSp=this.sp),r}pop(t){return t!==void 0?(this.sp-=t,Array.from({length:t},(r,n)=>this.name(this.sp+1+n))):this.name(this.sp--)}top(){return this.name(this.sp)}index(t){if(t<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack overflow: attempt to get a variable at a negative index ${t}`);return this.name(this.sp-t)}result(){if(this.maxSp<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack is empty, can't get the result'`);return this.name(0)}defines(){return this.maxSp<0?"":this.type+" "+Array.from({length:this.maxSp+1},(t,r)=>this.name(r)).join(", ")+";"}checkedIf(t,r,n){let s=this.sp;if(r(),n){let a=this.sp;if(this.sp=s,n(),a!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+t+": Branches of a condition can't move the stack pointer differently (before: "+s+", after then: "+a+", after else: "+this.sp+").")}}checkedLoop(t,r){let n=this.sp;if(r(),n!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+t+": Body of a loop can't move the stack pointer (before: "+n+", after: "+this.sp+").")}};cA.exports=M0});var q0=be((RT,fA)=>{"use strict";fA.exports="2.0.1"});var hA=be(jf=>{"use strict";function Ss(e){return e.charCodeAt(0).toString(16).toUpperCase()}jf.hex=Ss;function $D(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\v").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+Ss(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Ss(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Ss(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Ss(t))}jf.stringEscape=$D;function RD(e){return e.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\v").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+Ss(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Ss(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Ss(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Ss(t))}jf.regexpClassEscape=RD});var gA=be(dA=>{var pA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");dA.encode=function(e){if(0<=e&&e{var TD=gA(),mA=5,vA=1<>>=mA,s>0&&(n|=OD),r+=TD.encode(n);while(s>0);return r}});var qf=be(Ws=>{function ND(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}Ws.getArg=ND;var yA=function(){return!("__proto__"in Object.create(null))}();function SA(e){return e}function LD(e){return bA(e)?"$"+e:e}Ws.toSetString=yA?SA:LD;function UD(e){return bA(e)?e.slice(1):e}Ws.fromSetString=yA?SA:UD;function bA(e){if(!e)return!1;let t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(let r=t-10;r>=0;r--)if(e.charCodeAt(r)!==36)return!1;return!0}function EA(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function HD(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=EA(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:EA(e.name,t.name)}Ws.compareByGeneratedPositionsInflated=HD;var K0="http:",$c=`${K0}//host`;function CA(e){return t=>{let r=Rc(t),n=V0(t),s=new URL(t,n);e(s);let a=s.toString();return r==="absolute"?a:r==="scheme-relative"?a.slice(K0.length):r==="path-absolute"?a.slice($c.length):G0(n,a)}}function Ys(e,t){return new URL(e,t).toString()}function jD(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function V0(e){let t=e.split("..").length-1,r=jD("p",e),n=`${$c}/`;for(let s=0;s0&&!n[n.length-1]&&n.pop();r.length>0&&n.length>0&&r[0]===n[0];)r.shift(),n.shift();return n.map(()=>"..").concat(r).join("/")+t.search+t.hash}var qD=CA(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),Mf=CA(e=>{});Ws.normalize=Mf;function KD(e,t){let r=Rc(t),n=Rc(e);if(e=qD(e),r==="absolute")return Ys(t,void 0);if(n==="absolute")return Ys(t,e);if(r==="scheme-relative")return Mf(t);if(n==="scheme-relative")return Ys(t,Ys(e,$c)).slice(K0.length);if(r==="path-absolute")return Mf(t);if(n==="path-absolute")return Ys(t,Ys(e,$c)).slice($c.length);let s=V0(t+e),a=Ys(t,Ys(e,s));return G0(s,a)}Ws.join=KD;function VD(e,t){let r=GD(e,t);return typeof r=="string"?r:Mf(t)}Ws.relative=VD;function GD(e,t){if(Rc(e)!==Rc(t))return null;let n=V0(e+t),s=new URL(e,n),a=new URL(t,n);try{new URL("",a.toString())}catch{return null}return a.protocol!==s.protocol||a.user!==s.user||a.password!==s.password||a.hostname!==s.hostname||a.port!==s.port?null:G0(s,a)}});var _A=be(FA=>{var z0=class e{constructor(){this._array=[],this._set=new Map}static fromArray(t,r){let n=new e;for(let s=0,a=t.length;s=0)return r;throw new Error('"'+t+'" is not in the set.')}at(t){if(t>=0&&t{var IA=qf();function zD(e,t){let r=e.generatedLine,n=t.generatedLine,s=e.generatedColumn,a=t.generatedColumn;return n>r||n==r&&a>=s||IA.compareByGeneratedPositionsInflated(e,t)<=0}var Y0=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){zD(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(IA.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};DA.MappingList=Y0});var W0=be(PA=>{var Tc=wA(),Jt=qf(),Kf=_A().ArraySet,YD=BA().MappingList,Vf=class e{constructor(t){t||(t={}),this._file=Jt.getArg(t,"file",null),this._sourceRoot=Jt.getArg(t,"sourceRoot",null),this._skipValidation=Jt.getArg(t,"skipValidation",!1),this._sources=new Kf,this._names=new Kf,this._mappings=new YD,this._sourcesContents=null}static fromSourceMap(t){let r=t.sourceRoot,n=new e({file:t.file,sourceRoot:r});return t.eachMapping(function(s){let a={generated:{line:s.generatedLine,column:s.generatedColumn}};s.source!=null&&(a.source=s.source,r!=null&&(a.source=Jt.relative(r,a.source)),a.original={line:s.originalLine,column:s.originalColumn},s.name!=null&&(a.name=s.name)),n.addMapping(a)}),t.sources.forEach(function(s){let a=s;r!=null&&(a=Jt.relative(r,s)),n._sources.has(a)||n._sources.add(a);let i=t.sourceContentFor(s);i!=null&&n.setSourceContent(s,i)}),n}addMapping(t){let r=Jt.getArg(t,"generated"),n=Jt.getArg(t,"original",null),s=Jt.getArg(t,"source",null),a=Jt.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,s,a),s!=null&&(s=String(s),this._sources.has(s)||this._sources.add(s)),a!=null&&(a=String(a),this._names.has(a)||this._names.add(a)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n&&n.line,originalColumn:n&&n.column,source:s,name:a})}setSourceContent(t,r){let n=t;this._sourceRoot!=null&&(n=Jt.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Jt.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[Jt.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))}applySourceMap(t,r,n){let s=r;if(r==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);s=t.file}let a=this._sourceRoot;a!=null&&(s=Jt.relative(a,s));let i=this._mappings.toArray().length>0?new Kf:this._sources,c=new Kf;this._mappings.unsortedForEach(function(l){if(l.source===s&&l.originalLine!=null){let E=t.originalPositionFor({line:l.originalLine,column:l.originalColumn});E.source!=null&&(l.source=E.source,n!=null&&(l.source=Jt.join(n,l.source)),a!=null&&(l.source=Jt.relative(a,l.source)),l.originalLine=E.line,l.originalColumn=E.column,E.name!=null&&(l.name=E.name))}let h=l.source;h!=null&&!i.has(h)&&i.add(h);let v=l.name;v!=null&&!c.has(v)&&c.add(v)},this),this._sources=i,this._names=c,t.sources.forEach(function(l){let h=t.sourceContentFor(l);h!=null&&(n!=null&&(l=Jt.join(n,l)),a!=null&&(l=Jt.relative(a,l)),this.setSourceContent(l,h))},this)}_validateMapping(t,r,n,s){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!s)){if(!(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:s}))}}_serializeMappings(){let t=0,r=1,n=0,s=0,a=0,i=0,c="",l,h,v,E,p=this._mappings.toArray();for(let f=0,w=p.length;f0){if(!Jt.compareByGeneratedPositionsInflated(h,p[f-1]))continue;l+=","}l+=Tc.encode(h.generatedColumn-t),t=h.generatedColumn,h.source!=null&&(E=this._sources.indexOf(h.source),l+=Tc.encode(E-i),i=E,l+=Tc.encode(h.originalLine-1-s),s=h.originalLine-1,l+=Tc.encode(h.originalColumn-n),n=h.originalColumn,h.name!=null&&(v=this._names.indexOf(h.name),l+=Tc.encode(v-a),a=v)),c+=l}return c}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=Jt.relative(r,n));let s=Jt.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,s)?this._sourcesContents[s]:null},this)}toJSON(){let t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t}toString(){return JSON.stringify(this.toJSON())}};Vf.prototype._version=3;PA.SourceMapGenerator=Vf});var RA=be($A=>{var WD=W0().SourceMapGenerator,Gf=qf(),XD=/(\r?\n)/,JD=10,co="$$$isSourceNode$$$",X0=class e{constructor(t,r,n,s,a){this.children=[],this.sourceContents={},this.line=t??null,this.column=r??null,this.source=n??null,this.name=a??null,this[co]=!0,s!=null&&this.add(s)}static fromStringWithSourceMap(t,r,n){let s=new e,a=t.split(XD),i=0,c=function(){let f=m(),w=m()||"";return f+w;function m(){return i=0;r--)this.prepend(t[r]);else if(t[co]||typeof t=="string")this.children.unshift(t);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);return this}walk(t){let r;for(let n=0,s=this.children.length;n0){for(r=[],n=0;n{J0.SourceMapGenerator=W0().SourceMapGenerator;J0.SourceNode=RA().SourceNode});var NA=be((MT,kA)=>{"use strict";var ZD=zs(),gt=L0(),QD=lA(),eB=q0(),{stringEscape:Dn,regexpClassEscape:Z0}=hA(),{SourceNode:Vn}=TA();function OA(e,t,r){let n=t.start.line,s=t.start.column-1,a=e.split(` `);return a.length===1?new Vn(n,s,t.source,e,r):new Vn(null,null,t.source,a.map((i,c)=>new Vn(n+c,c===0?s:0,t.source,c===a.length-1?i:[i,` `],r)))}function xA(e,t,r,n,s){return r?new Vn(null,null,r.source,[e,OA(t,r,s),new Vn(r.end.line,r.end.column-1,r.source,n)]):new Vn(null,null,null,[e,t,n])}function tB(e,t){function r(m){return m instanceof Vn?m:m.replace(/^(.+)$/gm," $1")}function n(m){return"peg$c"+m}function s(m){return"peg$r"+m}function a(m){return"peg$e"+m}function i(m){return"peg$f"+m}function c(m){return"peg$parse"+m}function l(){function m(_){return'"'+Dn(_)+'"'}function y(_){return"/^["+(_.inverted?"^":"")+_.value.map(I=>Array.isArray(I)?Z0(I[0])+"-"+Z0(I[1]):Z0(I)).join("")+"]/"+(_.ignoreCase?"i":"")}function A(_){switch(_.type){case"rule":return'peg$otherExpectation("'+Dn(_.value)+'")';case"literal":return'peg$literalExpectation("'+Dn(_.value)+'", '+_.ignoreCase+")";case"class":return"peg$classExpectation(["+_.value.map(B=>Array.isArray(B)?'["'+Dn(B[0])+'", "'+Dn(B[1])+'"]':'"'+Dn(B)+'"').join(", ")+"], "+_.inverted+", "+_.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(_)+")")}}function b(_,I){return xA(` var ${i(I)} = function(${_.params.join(", ")}) {`,_.body,_.location,"};")}return new Vn(null,null,t.grammarSource,[e.literals.map((_,I)=>" var "+n(I)+" = "+m(_)+";").concat("",e.classes.map((_,I)=>" var "+s(I)+" = "+y(_)+";")).concat("",e.expectations.map((_,I)=>" var "+a(I)+" = "+A(_)+";")).concat("").join(` `),e.functions.map(b)])}function h(m,y){let A=[];return A.push(""),t.trace&&A.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+m+","," location: peg$computeLocation(startPos, startPos)","});",""),t.cache&&(A.push("var key = peg$currPos * "+e.rules.length+" + "+y+";","var cached = peg$resultsCache[key];","","if (cached) {"," peg$currPos = cached.nextPos;",""),t.trace&&A.push("if (cached.result !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+m+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+m+","," location: peg$computeLocation(startPos, startPos)"," });","}",""),A.push(" return cached.result;","}","")),A}function v(m,y){let A=[];return t.cache&&A.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+y+" };"),t.trace&&A.push("","if ("+y+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+m+","," result: "+y+","," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+m+","," location: peg$computeLocation(startPos, startPos)"," });","}"),A.push("","return "+y+";"),A}function E(m){let y=[],A=new QD(m.name,"s","var");function b(I){let B=0,j=I.length,V=[],F;function P(M,X){let K=X+3,q=I[B+K-2],Y=I[B+K-1],re,ye;A.checkedIf(B,()=>{B+=K,re=b(I.slice(B,B+q)),B+=q},Y>0?()=>{ye=b(I.slice(B,B+Y)),B+=Y}:null),V.push("if ("+M+") {"),V.push(...re.map(r)),Y>0&&(V.push("} else {"),V.push(...ye.map(r))),V.push("}")}function k(M){let K=I[B+2-1],q;A.checkedLoop(B,()=>{B+=2,q=b(I.slice(B,B+K)),B+=K}),V.push("while ("+M+") {"),V.push(...q.map(r)),V.push("}")}function L(){let X=I[B+4-1],K=i(I[B+1])+"("+I.slice(B+4,B+4+X).map(q=>A.index(q)).join(", ")+")";A.pop(I[B+2]),V.push(A.push(K)),B+=4+X}for(;BA.index(q)).join(", ")} ]`,A.pop(I[B+1]),V.push(A.push(F)),B+=K;break}case gt.IF:P(A.top(),0);break;case gt.IF_ERROR:P(A.top()+" === peg$FAILED",0);break;case gt.IF_NOT_ERROR:P(A.top()+" !== peg$FAILED",0);break;case gt.WHILE_NOT_ERROR:k(A.top()+" !== peg$FAILED");break;case gt.MATCH_ANY:P("input.length > peg$currPos",0);break;case gt.MATCH_STRING:P(e.literals[I[B+1]].length>1?"input.substr(peg$currPos, "+e.literals[I[B+1]].length+") === "+n(I[B+1]):"input.charCodeAt(peg$currPos) === "+e.literals[I[B+1]].charCodeAt(0),1);break;case gt.MATCH_STRING_IC:P("input.substr(peg$currPos, "+e.literals[I[B+1]].length+").toLowerCase() === "+n(I[B+1]),1);break;case gt.MATCH_CHAR_CLASS:P(s(I[B+1])+".test(input.charAt(peg$currPos))",1);break;case gt.ACCEPT_N:V.push(A.push(I[B+1]>1?"input.substr(peg$currPos, "+I[B+1]+")":"input.charAt(peg$currPos)")),V.push(I[B+1]>1?"peg$currPos += "+I[B+1]+";":"peg$currPos++;"),B+=2;break;case gt.ACCEPT_STRING:V.push(A.push(n(I[B+1]))),V.push(e.literals[I[B+1]].length>1?"peg$currPos += "+e.literals[I[B+1]].length+";":"peg$currPos++;"),B+=2;break;case gt.FAIL:V.push(A.push("peg$FAILED")),V.push("if (peg$silentFails === 0) { peg$fail("+a(I[B+1])+"); }"),B+=2;break;case gt.LOAD_SAVED_POS:V.push("peg$savedPos = "+A.index(I[B+1])+";"),B+=2;break;case gt.UPDATE_SAVED_POS:V.push("peg$savedPos = peg$currPos;"),B++;break;case gt.CALL:L();break;case gt.RULE:V.push(A.push(c(e.rules[I[B+1]].name)+"()")),B+=2;break;case gt.SILENT_FAILS_ON:V.push("peg$silentFails++;"),B++;break;case gt.SILENT_FAILS_OFF:V.push("peg$silentFails--;"),B++;break;default:throw new Error("Invalid opcode: "+I[B]+".")}return V}let _=b(m.bytecode);return y.push(xA(" function ",c(m.name),m.nameLocation,`() { `,m.name)),t.trace&&y.push(" var startPos = peg$currPos;"),y.push(r(A.defines())),y.push(...h('"'+Dn(m.name)+'"',ZD.indexOfRule(e,m.name)).map(r)),y.push(..._.map(r)),y.push(...v('"'+Dn(m.name)+'"',A.result()).map(r)),y.push("}"),y}function p(m){return m.codeLocation?OA(m.code,m.codeLocation,"$"+m.type):m.code}function f(){let m=[];e.topLevelInitializer&&(m.push(p(e.topLevelInitializer)),m.push("")),m.push("function peg$subclass(child, parent) {"," function C() { this.constructor = child; }"," C.prototype = parent.prototype;"," child.prototype = new C();","}","","function peg$SyntaxError(message, expected, found, location) {"," var self = Error.call(this, message);"," // istanbul ignore next Check is a necessary evil to support older environments"," if (Object.setPrototypeOf) {"," Object.setPrototypeOf(self, peg$SyntaxError.prototype);"," }"," self.expected = expected;"," self.found = found;"," self.location = location;",' self.name = "SyntaxError";'," return self;","}","","peg$subclass(peg$SyntaxError, Error);","","function peg$padEnd(str, targetLength, padString) {",' padString = padString || " ";'," if (str.length > targetLength) { return str; }"," targetLength -= str.length;"," padString += padString.repeat(targetLength);"," return str + padString.slice(0, targetLength);","}","","peg$SyntaxError.prototype.format = function(sources) {",' var str = "Error: " + this.message;'," if (this.location) {"," var src = null;"," var k;"," for (k = 0; k < sources.length; k++) {"," if (sources[k].source === this.location.source) {"," src = sources[k].text.split(/\\r\\n|\\n|\\r/g);"," break;"," }"," }"," var s = this.location.start;",' var loc = this.location.source + ":" + s.line + ":" + s.column;'," if (src) {"," var e = this.location.end;",` var filler = peg$padEnd("", s.line.toString().length, ' ');`," var line = src[s.line - 1];"," var last = s.line === e.line ? e.column : line.length + 1;"," var hatLen = (last - s.column) || 1;",' str += "\\n --> " + loc + "\\n"',' + filler + " |\\n"',' + s.line + " | " + line + "\\n"',` + filler + " | " + peg$padEnd("", s.column - 1, ' ')`,' + peg$padEnd("", hatLen, "^");'," } else {",' str += "\\n at " + loc;'," }"," }"," return str;","};","","peg$SyntaxError.buildMessage = function(expected, found) {"," var DESCRIBE_EXPECTATION_FNS = {"," literal: function(expectation) {",' return "\\"" + literalEscape(expectation.text) + "\\"";'," },",""," class: function(expectation) {"," var escapedParts = expectation.parts.map(function(part) {"," return Array.isArray(part)",' ? classEscape(part[0]) + "-" + classEscape(part[1])'," : classEscape(part);"," });","",' return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";'," },",""," any: function() {",' return "any character";'," },",""," end: function() {",' return "end of input";'," },",""," other: function(expectation) {"," return expectation.description;"," }"," };",""," function hex(ch) {"," return ch.charCodeAt(0).toString(16).toUpperCase();"," }",""," function literalEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/"/g, "\\\\\\"")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function classEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/\\]/g, "\\\\]")',' .replace(/\\^/g, "\\\\^")',' .replace(/-/g, "\\\\-")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function describeExpectation(expectation) {"," return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);"," }",""," function describeExpected(expected) {"," var descriptions = expected.map(describeExpectation);"," var i, j;",""," descriptions.sort();",""," if (descriptions.length > 0) {"," for (i = 1, j = 1; i < descriptions.length; i++) {"," if (descriptions[i - 1] !== descriptions[i]) {"," descriptions[j] = descriptions[i];"," j++;"," }"," }"," descriptions.length = j;"," }",""," switch (descriptions.length) {"," case 1:"," return descriptions[0];",""," case 2:",' return descriptions[0] + " or " + descriptions[1];',""," default:",' return descriptions.slice(0, -1).join(", ")',' + ", or "'," + descriptions[descriptions.length - 1];"," }"," }",""," function describeFound(found) {",' return found ? "\\"" + literalEscape(found) + "\\"" : "end of input";'," }","",' return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";',"};",""),t.trace&&m.push("function peg$DefaultTracer() {"," this.indentLevel = 0;","}","","peg$DefaultTracer.prototype.trace = function(event) {"," var that = this;",""," function log(event) {"," function repeat(string, n) {",' var result = "", i;',""," for (i = 0; i < n; i++) {"," result += string;"," }",""," return result;"," }",""," function pad(string, length) {",' return string + repeat(" ", length - string.length);'," }","",' if (typeof console === "object") {'," console.log(",' event.location.start.line + ":" + event.location.start.column + "-"',' + event.location.end.line + ":" + event.location.end.column + " "',' + pad(event.type, 10) + " "',' + repeat(" ", that.indentLevel) + event.rule'," );"," }"," }",""," switch (event.type) {",' case "rule.enter":'," log(event);"," this.indentLevel++;"," break;","",' case "rule.match":'," this.indentLevel--;"," log(event);"," break;","",' case "rule.fail":'," this.indentLevel--;"," log(event);"," break;",""," default:",' throw new Error("Invalid event type: " + event.type + ".");'," }","};","");let y="{ "+t.allowedStartRules.map(b=>b+": "+c(b)).join(", ")+" }",A=c(t.allowedStartRules[0]);return m.push("function peg$parse(input, options) {"," options = options !== undefined ? options : {};",""," var peg$FAILED = {};"," var peg$source = options.grammarSource;",""," var peg$startRuleFunctions = "+y+";"," var peg$startRuleFunction = "+A+";","",l(),""," var peg$currPos = 0;"," var peg$savedPos = 0;"," var peg$posDetailsCache = [{ line: 1, column: 1 }];"," var peg$maxFailPos = 0;"," var peg$maxFailExpected = [];"," var peg$silentFails = 0;",""),t.cache&&m.push(" var peg$resultsCache = {};",""),t.trace&&m.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),m.push(" var peg$result;","",' if ("startRule" in options) {'," if (!(options.startRule in peg$startRuleFunctions)) {",` throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");`," }",""," peg$startRuleFunction = peg$startRuleFunctions[options.startRule];"," }",""," function text() {"," return input.substring(peg$savedPos, peg$currPos);"," }",""," function offset() {"," return peg$savedPos;"," }",""," function range() {"," return {"," source: peg$source,"," start: peg$savedPos,"," end: peg$currPos"," };"," }",""," function location() {"," return peg$computeLocation(peg$savedPos, peg$currPos);"," }",""," function expected(description, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildStructuredError("," [peg$otherExpectation(description)],"," input.substring(peg$savedPos, peg$currPos),"," location"," );"," }",""," function error(message, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildSimpleError(message, location);"," }",""," function peg$literalExpectation(text, ignoreCase) {",' return { type: "literal", text: text, ignoreCase: ignoreCase };'," }",""," function peg$classExpectation(parts, inverted, ignoreCase) {",' return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };'," }",""," function peg$anyExpectation() {",' return { type: "any" };'," }",""," function peg$endExpectation() {",' return { type: "end" };'," }",""," function peg$otherExpectation(description) {",' return { type: "other", description: description };'," }",""," function peg$computePosDetails(pos) {"," var details = peg$posDetailsCache[pos];"," var p;",""," if (details) {"," return details;"," } else {"," p = pos - 1;"," while (!peg$posDetailsCache[p]) {"," p--;"," }",""," details = peg$posDetailsCache[p];"," details = {"," line: details.line,"," column: details.column"," };",""," while (p < pos) {"," if (input.charCodeAt(p) === 10) {"," details.line++;"," details.column = 1;"," } else {"," details.column++;"," }",""," p++;"," }",""," peg$posDetailsCache[pos] = details;",""," return details;"," }"," }",""," function peg$computeLocation(startPos, endPos) {"," var startPosDetails = peg$computePosDetails(startPos);"," var endPosDetails = peg$computePosDetails(endPos);",""," return {"," source: peg$source,"," start: {"," offset: startPos,"," line: startPosDetails.line,"," column: startPosDetails.column"," },"," end: {"," offset: endPos,"," line: endPosDetails.line,"," column: endPosDetails.column"," }"," };"," }",""," function peg$fail(expected) {"," if (peg$currPos < peg$maxFailPos) { return; }",""," if (peg$currPos > peg$maxFailPos) {"," peg$maxFailPos = peg$currPos;"," peg$maxFailExpected = [];"," }",""," peg$maxFailExpected.push(expected);"," }",""," function peg$buildSimpleError(message, location) {"," return new peg$SyntaxError(message, null, null, location);"," }",""," function peg$buildStructuredError(expected, found, location) {"," return new peg$SyntaxError("," peg$SyntaxError.buildMessage(expected, found),"," expected,"," found,"," location"," );"," }",""),e.rules.forEach(b=>{m.push(...E(b).map(r)),m.push("")}),e.initializer&&(m.push(p(e.initializer)),m.push("")),m.push(" peg$result = peg$startRuleFunction();",""," if (peg$result !== peg$FAILED && peg$currPos === input.length) {"," return peg$result;"," } else {"," if (peg$result !== peg$FAILED && peg$currPos < input.length) {"," peg$fail(peg$endExpectation());"," }",""," throw peg$buildStructuredError("," peg$maxFailExpected,"," peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,"," peg$maxFailPos < input.length"," ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)"," : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)"," );"," }","}"),new Vn(null,null,t.grammarSource,m.map(b=>b instanceof Vn?b:b+` `))}function w(m){function y(){return[`// Generated by Peggy ${eB}.`,"//","// https://peggyjs.org/"]}function A(){return t.trace?["{"," SyntaxError: peg$SyntaxError,"," DefaultTracer: peg$DefaultTracer,"," parse: peg$parse","}"].join(` `):["{"," SyntaxError: peg$SyntaxError,"," parse: peg$parse","}"].join(` `)}let _={bare(){return[...y(),"(function() {",' "use strict";',"",m,"",r("return "+A()+";"),"})()"]},commonjs(){let I=Object.keys(t.dependencies),B=y();return B.push("",'"use strict";',""),I.length>0&&(I.forEach(j=>{B.push("var "+j+' = require("'+Dn(t.dependencies[j])+'");')}),B.push("")),B.push(m,"","module.exports = "+A()+";"),B},es(){let I=Object.keys(t.dependencies),B=y();return B.push(""),I.length>0&&(I.forEach(j=>{B.push("import "+j+' from "'+Dn(t.dependencies[j])+'";')}),B.push("")),B.push(m,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),B},amd(){let I=Object.keys(t.dependencies),j="["+I.map(F=>t.dependencies[F]).map(F=>'"'+Dn(F)+'"').join(", ")+"]",V=I.join(", ");return[...y(),"define("+j+", function("+V+") {",' "use strict";',"",m,"",r("return "+A()+";"),"});"]},globals(){return[...y(),"(function(root) {",' "use strict";',"",m,"",r("root."+t.exportVar+" = "+A()+";"),"})(this);"]},umd(){let I=Object.keys(t.dependencies),B=I.map(k=>t.dependencies[k]),j="["+B.map(k=>'"'+Dn(k)+'"').join(", ")+"]",V=B.map(k=>'require("'+Dn(k)+'")').join(", "),F=I.join(", "),P=y();return P.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+j+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+V+");"),t.exportVar!==null&&P.push(" } else {"," root."+t.exportVar+" = factory();"),P.push(" }","})(this, function("+F+") {",' "use strict";',"",m,"",r("return "+A()+";"),"});"),P}}[t.format]();return new Vn(null,null,t.grammarSource,_.map(I=>I instanceof Vn?I:I+` `))}e.code=w(f())}kA.exports=tB});var UA=be((qT,LA)=>{"use strict";var rB=zs(),nB=Kn();function iB(e,t,r){function n(i){return i.type==="rule"&&i.expression.type==="rule_ref"}function s(i,c,l){nB.build({rule_ref(v){v.name===c&&(v.name=l,r.info(`Proxy rule "${c}" replaced by the rule "${l}"`,v.location,[{message:"This rule will be used",location:rB.findRule(i,l).nameLocation}]))}})(i)}let a=[];e.rules.forEach((i,c)=>{n(i)&&(s(e,i.name,i.expression.name),t.allowedStartRules.indexOf(i.name)===-1&&a.push(c))}),a.reverse(),a.forEach(i=>{e.rules.splice(i,1)})}LA.exports=iB});var jA=be((KT,HA)=>{"use strict";var sB=Kn();function aB(e,t,r){function n(i){let c={};return Object.keys(i).forEach(l=>{c[l]=i[l]}),c}function s(i,c){a(i.expression,n(c))}let a=sB.build({rule(i){a(i.expression,{})},choice(i,c){i.alternatives.forEach(l=>{a(l,n(c))})},action:s,labeled(i,c){let l=i.label;l&&Object.prototype.hasOwnProperty.call(c,l)&&r.error(`Label "${i.label}" is already defined`,i.labelLocation,[{message:"Original label location",location:c[l]}]),a(i.expression,c),c[i.label]=i.labelLocation},text:s,simple_and:s,simple_not:s,optional:s,zero_or_more:s,one_or_more:s,group:s});a(e)}HA.exports=aB});var qA=be((VT,MA)=>{"use strict";var uB=Kn();function oB(e,t,r){let n={};uB.build({rule(a){if(Object.prototype.hasOwnProperty.call(n,a.name)){r.error(`Rule "${a.name}" is already defined`,a.nameLocation,[{message:"Original rule location",location:n[a.name]}]);return}n[a.name]=a.nameLocation}})(e)}MA.exports=oB});var GA=be((GT,VA)=>{"use strict";var KA=zs(),cB=Kn();function lB(e,t,r){let n=[],s=[],a=cB.build({rule(i){n.push(i.name),a(i.expression),n.pop()},sequence(i){i.elements.every(c=>(a(c),!KA.alwaysConsumesOnSuccess(e,c)))},rule_ref(i){s.push(i);let c=KA.findRule(e,i.name);if(n.indexOf(i.name)!==-1){n.push(i.name),r.error("Possible infinite loop when parsing (left recursion: "+n.join(" -> ")+")",c.nameLocation,s.map((l,h,v)=>({message:h+1!==v.length?`Step ${h+1}: call of the rule "${l.name}" without input consumption`:`Step ${h+1}: call itself without input consumption - left recursion`,location:l.location})));return}c&&a(c),s.pop()}});a(e)}VA.exports=lB});var WA=be((zT,YA)=>{"use strict";var zA=zs(),fB=Kn();function hB(e,t,r){fB.build({zero_or_more(s){zA.alwaysConsumesOnSuccess(e,s.expression)||r.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",s.location)},one_or_more(s){zA.alwaysConsumesOnSuccess(e,s.expression)||r.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",s.location)}})(e)}YA.exports=hB});var JA=be((YT,XA)=>{"use strict";var pB=zs(),dB=Kn();function gB(e,t,r){dB.build({rule_ref(s){pB.findRule(e,s.name)||r.error(`Rule "${s.name}" is not defined`,s.location)}})(e)}XA.exports=gB});var QA=be((WT,ZA)=>{"use strict";var mB=Kn();function vB(e,t,r){let n=mB.build({action(s){n(s.expression,s)},labeled(s,a){s.pick&&a&&r.error('"@" cannot be used with an action block',s.labelLocation,[{message:"Action block location",location:a.codeLocation}]),n(s.expression)}});n(e)}ZA.exports=vB});var tw=be((XT,ew)=>{"use strict";var AB=Uf(),Q0=class{constructor(t){t=typeof t<"u"?t:{},typeof t.error=="function"&&(this.error=t.error),typeof t.warning=="function"&&(this.warning=t.warning),typeof t.info=="function"&&(this.info=t.info)}error(){}warning(){}info(){}},ed=class{constructor(t){this._callbacks=new Q0(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new AB(...t),this._firstError.stage=this.stage,this._firstError.problems=this.problems),this.problems.push(["error",...t]),this._callbacks.error(this.stage,...t)}warning(...t){this.problems.push(["warning",...t]),this._callbacks.warning(this.stage,...t)}info(...t){this.problems.push(["info",...t]),this._callbacks.info(this.stage,...t)}checkErrors(){if(this.errors!==0)throw this._firstError}};ew.exports=ed});var rw=be((exports,module)=>{"use strict";var generateBytecode=oA(),generateJS=NA(),inferenceMatchResult=U0(),removeProxyRules=UA(),reportDuplicateLabels=jA(),reportDuplicateRules=qA(),reportInfiniteRecursion=GA(),reportInfiniteRepetition=WA(),reportUndefinedRules=JA(),reportIncorrectPlucking=QA(),Session=tw(),visitor=Kn();function processOptions(e,t){let r={};return Object.keys(e).forEach(n=>{r[n]=e[n]}),Object.keys(t).forEach(n=>{Object.prototype.hasOwnProperty.call(r,n)||(r[n]=t[n])}),r}var compiler={visitor,passes:{check:[reportUndefinedRules,reportDuplicateRules,reportDuplicateLabels,reportInfiniteRecursion,reportInfiniteRepetition,reportIncorrectPlucking],transform:[removeProxyRules,inferenceMatchResult],generate:[generateBytecode,generateJS]},compile(ast,passes,options){if(options=options!==void 0?options:{},options=processOptions(options,{allowedStartRules:[ast.rules[0].name],cache:!1,dependencies:{},exportVar:null,format:"bare",output:"parser",trace:!1}),!Array.isArray(options.allowedStartRules))throw new Error("allowedStartRules must be an array");if(options.allowedStartRules.length===0)throw new Error("Must have at least one start rule");let allRules=ast.rules.map(e=>e.name);for(let e of options.allowedStartRules)if(allRules.indexOf(e)===-1)throw new Error(`Unknown start rule "${e}"`);let session=new Session(options);switch(Object.keys(passes).forEach(e=>{session.stage=e,session.info(`Process stage ${e}`),passes[e].forEach(t=>{session.info(`Process pass ${e}.${t.name}`),t(ast,options,session)}),session.checkErrors()}),options.output){case"parser":return eval(ast.code.toString());case"source":return ast.code.toString();case"source-and-map":return ast.code;default:throw new Error("Invalid output format: "+options.output+".")}}};module.exports=compiler});var iw=be((JT,nw)=>{"use strict";var wB={$:"text","&":"simple_and","!":"simple_not"},EB={"?":"optional","*":"zero_or_more","+":"one_or_more"},yB={"&":"semantic_and","!":"semantic_not"};function SB(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function Xs(e,t,r,n){var s=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(s,Xs.prototype),s.expected=t,s.found=r,s.location=n,s.name="SyntaxError",s}SB(Xs,Error);function td(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}Xs.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var r=null,n;for(n=0;n `+a+` `+c+` | `+s.line+" | "+l+` `+c+" | "+td("",s.column-1," ")+td("",v,"^")}else t+=` at `+a}return t};Xs.buildMessage=function(e,t){var r={literal:function(h){return'"'+s(h.text)+'"'},class:function(h){var v=h.parts.map(function(E){return Array.isArray(E)?a(E[0])+"-"+a(E[1]):a(E)});return"["+(h.inverted?"^":"")+v.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(h){return h.description}};function n(h){return h.charCodeAt(0).toString(16).toUpperCase()}function s(h){return h.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(v){return"\\x0"+n(v)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(v){return"\\x"+n(v)})}function a(h){return h.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(v){return"\\x0"+n(v)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(v){return"\\x"+n(v)})}function i(h){return r[h.type](h)}function c(h){var v=h.map(i),E,p;if(v.sort(),v.length>0){for(E=1,p=1;E0?{type:"choice",alternatives:[S].concat(x),location:Pt()}:S},$n=function(S,x){return x!==null?{type:"action",expression:S,code:x[0],codeLocation:x[1],location:Pt()}:S},ha=function(S,x){return x.length>0||S.type==="labeled"&&S.pick?{type:"sequence",elements:[S].concat(x),location:Pt()}:S},zf=function(S,x,z){return z.type.startsWith("semantic_")&&No('"@" cannot be used on a semantic predicate',S),{type:"labeled",label:x!==null?x[0]:null,labelLocation:x!==null?x[1]:S,pick:!0,expression:z,location:Pt()}},Yf=function(S,x){return{type:"labeled",label:S[0],labelLocation:S[1],expression:x,location:Pt()}},Ct=function(){return Pt()},yt=function(S){return Eu.indexOf(S[0])>=0&&No(`Label can't be a reserved word "${S[0]}"`,S[1]),S},Wf=function(S,x){return{type:wB[S],expression:x,location:Pt()}},Xf=function(S,x){return{type:EB[x],expression:S,location:Pt()}},Jf=function(S){return S.type==="labeled"||S.type==="sequence"?{type:"group",expression:S,location:Pt()}:S},Zf=function(S){return{type:"rule_ref",name:S[0],location:Pt()}},Qf=function(S,x){return{type:yB[S],code:x[0],codeLocation:x[1],location:Pt()}},eh=function(S,x){return[S+x.join(""),Pt()]},kc=function(S,x){return{type:"literal",value:S,ignoreCase:x!==null,location:Pt()}},th=function(S){return S.join("")},Yt=function(S){return S.join("")},xo=function(S,x,z){return{type:"class",parts:x.filter(H=>H!==""),inverted:S!==null,ignoreCase:z!==null,location:Pt()}},Oi=function(S,x){return S.charCodeAt(0)>x.charCodeAt(0)&&No("Invalid character range: "+ko()+"."),[S,x]},Nc=function(){return""},Oo=function(){return"\0"},Wr=function(){return"\b"},Lc=function(){return"\f"},Uc=function(){return` `},Hc=function(){return"\r"},jc=function(){return" "},Mc=function(){return"\v"},qc=function(S){return String.fromCharCode(parseInt(S,16))},Ur=function(S){return String.fromCharCode(parseInt(S,16))},rh=function(){return{type:"any",location:Pt()}},Xr=function(S){return[S,Pt()]},D=0,Ve=0,pn=[{line:1,column:1}],Hr=0,pa=[],Q=0,dn;if("startRule"in t){if(!(t.startRule in s))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');a=s[t.startRule]}function ko(){return e.substring(Ve,D)}function fd(){return Ve}function Kc(){return{source:n,start:Ve,end:D}}function Pt(){return ki(Ve,D)}function hd(S,x){throw x=x!==void 0?x:ki(Ve,D),Gc([Rn(S)],e.substring(Ve,D),x)}function No(S,x){throw x=x!==void 0?x:ki(Ve,D),Vc(S,x)}function ke(S,x){return{type:"literal",text:S,ignoreCase:x}}function Wt(S,x,z){return{type:"class",parts:S,inverted:x,ignoreCase:z}}function Ps(){return{type:"any"}}function nh(){return{type:"end"}}function Rn(S){return{type:"other",description:S}}function Lo(S){var x=pn[S],z;if(x)return x;for(z=S-1;!pn[z];)z--;for(x=pn[z],x={line:x.line,column:x.column};zHr&&(Hr=D,pa=[]),pa.push(S))}function Vc(S,x){return new Xs(S,null,null,x)}function Gc(S,x,z){return new Xs(Xs.buildMessage(S,x),S,x,z)}function ou(){var S,x,z,H,ie,ue,Et,Lt;if(S=D,x=pt(),z=D,H=Uo(),H!==r?(ie=pt(),z=H):(D=z,z=r),z===r&&(z=null),H=D,ie=ih(),ie!==r?(ue=pt(),H=ie):(D=H,H=r),H===r&&(H=null),ie=[],ue=D,Et=Ho(),Et!==r?(Lt=pt(),ue=Et):(D=ue,ue=r),ue!==r)for(;ue!==r;)ie.push(ue),ue=D,Et=Ho(),Et!==r?(Lt=pt(),ue=Et):(D=ue,ue=r);else ie=r;return ie!==r?(Ve=S,S=hn(z,H,ie)):(D=S,S=r),S}function Uo(){var S,x,z,H,ie;return S=D,e.charCodeAt(D)===123?(x=i,D++):(x=r,Q===0&&he(ri)),x!==r?(z=ot(),z!==r?(e.charCodeAt(D)===125?(H=c,D++):(H=r,Q===0&&he(xi)),H!==r?(ie=Hi(),ie!==r?(Ve=S,S=Ds(z)):(D=S,S=r)):(D=S,S=r)):(D=S,S=r)):(D=S,S=r),S}function ih(){var S,x,z;return S=D,x=ot(),x!==r?(z=Hi(),z!==r?(Ve=S,S=Lr(x)):(D=S,S=r)):(D=S,S=r),S}function Ho(){var S,x,z,H,ie,ue,Et,Lt;return S=D,x=fu(),x!==r?(z=pt(),H=D,ie=Tn(),ie!==r?(ue=pt(),H=ie):(D=H,H=r),H===r&&(H=null),e.charCodeAt(D)===61?(ie=l,D++):(ie=r,Q===0&&he(Ga)),ie!==r?(ue=pt(),Et=Fr(),Et!==r?(Lt=Hi(),Lt!==r?(Ve=S,S=Ar(x,H,Et)):(D=S,S=r)):(D=S,S=r)):(D=S,S=r)):(D=S,S=r),S}function Fr(){var S,x,z,H,ie,ue,Et,Lt;if(S=D,x=da(),x!==r){for(z=[],H=D,ie=pt(),e.charCodeAt(D)===47?(ue=h,D++):(ue=r,Q===0&&he(za)),ue!==r?(Et=pt(),Lt=da(),Lt!==r?H=Lt:(D=H,H=r)):(D=H,H=r);H!==r;)z.push(H),H=D,ie=pt(),e.charCodeAt(D)===47?(ue=h,D++):(ue=r,Q===0&&he(za)),ue!==r?(Et=pt(),Lt=da(),Lt!==r?H=Lt:(D=H,H=r)):(D=H,H=r);Ve=S,S=Bs(x,z)}else D=S,S=r;return S}function da(){var S,x,z,H,ie;return S=D,x=ga(),x!==r?(z=D,H=pt(),ie=ot(),ie!==r?z=ie:(D=z,z=r),z===r&&(z=null),Ve=S,S=$n(x,z)):(D=S,S=r),S}function ga(){var S,x,z,H,ie,ue;if(S=D,x=cu(),x!==r){for(z=[],H=D,ie=pt(),ue=cu(),ue!==r?H=ue:(D=H,H=r);H!==r;)z.push(H),H=D,ie=pt(),ue=cu(),ue!==r?H=ue:(D=H,H=r);Ve=S,S=ha(x,z)}else D=S,S=r;return S}function cu(){var S,x,z,H;return S=D,x=zc(),x!==r?(z=Yc(),z===r&&(z=null),H=jo(),H!==r?(Ve=S,S=zf(x,z,H)):(D=S,S=r)):(D=S,S=r),S===r&&(S=D,x=Yc(),x!==r?(z=pt(),H=jo(),H!==r?(Ve=S,S=Yf(x,H)):(D=S,S=r)):(D=S,S=r),S===r&&(S=jo())),S}function zc(){var S,x;return S=D,e.charCodeAt(D)===64?(x=v,D++):(x=r,Q===0&&he(Ya)),x!==r&&(Ve=S,x=Ct()),S=x,S}function Yc(){var S,x,z,H;return S=D,x=fu(),x!==r?(z=pt(),e.charCodeAt(D)===58?(H=E,D++):(H=r,Q===0&&he(Wa)),H!==r?(Ve=S,S=yt(x)):(D=S,S=r)):(D=S,S=r),S}function jo(){var S,x,z,H;return S=D,x=sh(),x!==r?(z=pt(),H=Wc(),H!==r?(Ve=S,S=Wf(x,H)):(D=S,S=r)):(D=S,S=r),S===r&&(S=Wc()),S}function sh(){var S;return e.charCodeAt(D)===36?(S=p,D++):(S=r,Q===0&&he(Xa)),S===r&&(e.charCodeAt(D)===38?(S=f,D++):(S=r,Q===0&&he(Ja)),S===r&&(e.charCodeAt(D)===33?(S=w,D++):(S=r,Q===0&&he(Za)))),S}function Wc(){var S,x,z,H;return S=D,x=Ni(),x!==r?(z=pt(),H=ah(),H!==r?(Ve=S,S=Xf(x,H)):(D=S,S=r)):(D=S,S=r),S===r&&(S=Ni()),S}function ah(){var S;return e.charCodeAt(D)===63?(S=m,D++):(S=r,Q===0&&he(fo)),S===r&&(e.charCodeAt(D)===42?(S=y,D++):(S=r,Q===0&&he(Qa)),S===r&&(e.charCodeAt(D)===43?(S=A,D++):(S=r,Q===0&&he(ho)))),S}function Ni(){var S,x,z,H,ie,ue;return S=hh(),S===r&&(S=ae(),S===r&&(S=du(),S===r&&(S=uh(),S===r&&(S=oh(),S===r&&(S=D,e.charCodeAt(D)===40?(x=b,D++):(x=r,Q===0&&he(po)),x!==r?(z=pt(),H=Fr(),H!==r?(ie=pt(),e.charCodeAt(D)===41?(ue=_,D++):(ue=r,Q===0&&he(go)),ue!==r?(Ve=S,S=Jf(H)):(D=S,S=r)):(D=S,S=r)):(D=S,S=r)))))),S}function uh(){var S,x,z,H,ie,ue,Et,Lt;return S=D,x=fu(),x!==r?(z=D,Q++,H=D,ie=pt(),ue=D,Et=Tn(),Et!==r?(Lt=pt(),Et=[Et,Lt],ue=Et):(D=ue,ue=r),ue===r&&(ue=null),e.charCodeAt(D)===61?(Et=l,D++):(Et=r,Q===0&&he(Ga)),Et!==r?(ie=[ie,ue,Et],H=ie):(D=H,H=r),Q--,H===r?z=void 0:(D=z,z=r),z!==r?(Ve=S,S=Zf(x)):(D=S,S=r)):(D=S,S=r),S}function oh(){var S,x,z,H;return S=D,x=Mo(),x!==r?(z=pt(),H=ot(),H!==r?(Ve=S,S=Qf(x,H)):(D=S,S=r)):(D=S,S=r),S}function Mo(){var S;return e.charCodeAt(D)===38?(S=f,D++):(S=r,Q===0&&he(Ja)),S===r&&(e.charCodeAt(D)===33?(S=w,D++):(S=r,Q===0&&he(Za))),S}function wr(){var S;return e.length>D?(S=e.charAt(D),D++):(S=r,Q===0&&he(Fs)),S}function gn(){var S,x;return Q++,e.charCodeAt(D)===9?(S=I,D++):(S=r,Q===0&&he(na)),S===r&&(e.charCodeAt(D)===11?(S=B,D++):(S=r,Q===0&&he(vo)),S===r&&(e.charCodeAt(D)===12?(S=j,D++):(S=r,Q===0&&he(Ao)),S===r&&(e.charCodeAt(D)===32?(S=V,D++):(S=r,Q===0&&he(wo)),S===r&&(e.charCodeAt(D)===160?(S=F,D++):(S=r,Q===0&&he(Eo)),S===r&&(e.charCodeAt(D)===65279?(S=P,D++):(S=r,Q===0&&he(yo)),S===r&&(S=rl())))))),Q--,S===r&&(x=r,Q===0&&he(mo)),S}function mn(){var S;return Gt.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(So)),S}function lu(){var S,x;return Q++,e.charCodeAt(D)===10?(S=k,D++):(S=r,Q===0&&he(Co)),S===r&&(e.substr(D,2)===L?(S=L,D+=2):(S=r,Q===0&&he(ni)),S===r&&(e.charCodeAt(D)===13?(S=M,D++):(S=r,Q===0&&he(eu)),S===r&&(e.charCodeAt(D)===8232?(S=X,D++):(S=r,Q===0&&he(Fo)),S===r&&(e.charCodeAt(D)===8233?(S=K,D++):(S=r,Q===0&&he(_o)))))),Q--,S===r&&(x=r,Q===0&&he(bo)),S}function Xc(){var S,x;return Q++,S=ch(),S===r&&(S=Jr()),Q--,S===r&&(x=r,Q===0&&he(Io)),S}function ch(){var S,x,z,H,ie,ue;if(S=D,e.substr(D,2)===q?(x=q,D+=2):(x=r,Q===0&&he(tu)),x!==r){for(z=[],H=D,ie=D,Q++,e.substr(D,2)===Y?(ue=Y,D+=2):(ue=r,Q===0&&he(ii)),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r);H!==r;)z.push(H),H=D,ie=D,Q++,e.substr(D,2)===Y?(ue=Y,D+=2):(ue=r,Q===0&&he(ii)),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r);e.substr(D,2)===Y?(H=Y,D+=2):(H=r,Q===0&&he(ii)),H!==r?(x=[x,z,H],S=x):(D=S,S=r)}else D=S,S=r;return S}function Li(){var S,x,z,H,ie,ue;if(S=D,e.substr(D,2)===q?(x=q,D+=2):(x=r,Q===0&&he(tu)),x!==r){for(z=[],H=D,ie=D,Q++,e.substr(D,2)===Y?(ue=Y,D+=2):(ue=r,Q===0&&he(ii)),ue===r&&(ue=mn()),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r);H!==r;)z.push(H),H=D,ie=D,Q++,e.substr(D,2)===Y?(ue=Y,D+=2):(ue=r,Q===0&&he(ii)),ue===r&&(ue=mn()),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r);e.substr(D,2)===Y?(H=Y,D+=2):(H=r,Q===0&&he(ii)),H!==r?(x=[x,z,H],S=x):(D=S,S=r)}else D=S,S=r;return S}function Jr(){var S,x,z,H,ie,ue;if(S=D,e.substr(D,2)===re?(x=re,D+=2):(x=r,Q===0&&he(Yr)),x!==r){for(z=[],H=D,ie=D,Q++,ue=mn(),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r);H!==r;)z.push(H),H=D,ie=D,Q++,ue=mn(),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r);x=[x,z],S=x}else D=S,S=r;return S}function fu(){var S,x,z,H;if(Q++,S=D,x=Jc(),x!==r){for(z=[],H=Zc();H!==r;)z.push(H),H=Zc();Ve=S,S=eh(x,z)}else D=S,S=r;return Q--,S===r&&(x=r,Q===0&&he(Do)),S}function Jc(){var S,x,z;return S=lh(),S===r&&(e.charCodeAt(D)===36?(S=p,D++):(S=r,Q===0&&he(Xa)),S===r&&(e.charCodeAt(D)===95?(S=ye,D++):(S=r,Q===0&&he(_s)),S===r&&(S=D,e.charCodeAt(D)===92?(x=we,D++):(x=r,Q===0&&he(fn)),x!==r?(z=Qc(),z!==r?S=z:(D=S,S=r)):(D=S,S=r)))),S}function Zc(){var S;return S=Jc(),S===r&&(S=fh(),S===r&&(S=el(),S===r&&(S=tl(),S===r&&(e.charCodeAt(D)===8204?(S=Be,D++):(S=r,Q===0&&he(Bo)),S===r&&(e.charCodeAt(D)===8205?(S=He,D++):(S=r,Q===0&&he(Po))))))),S}function lh(){var S;return S=vu(),S===r&&(S=mu(),S===r&&(S=vh(),S===r&&(S=gh(),S===r&&(S=mh(),S===r&&(S=wu()))))),S}function fh(){var S;return S=Au(),S===r&&(S=ui()),S}function hh(){var S,x,z;return Q++,S=D,x=Tn(),x!==r?(e.charCodeAt(D)===105?(z=oe,D++):(z=r,Q===0&&he(ia)),z===r&&(z=null),Ve=S,S=kc(x,z)):(D=S,S=r),Q--,S===r&&(x=r,Q===0&&he(ru)),S}function Tn(){var S,x,z,H;if(Q++,S=D,e.charCodeAt(D)===34?(x=Fe,D++):(x=r,Q===0&&he(Is)),x!==r){for(z=[],H=ee();H!==r;)z.push(H),H=ee();e.charCodeAt(D)===34?(H=Fe,D++):(H=r,Q===0&&he(Is)),H!==r?(Ve=S,S=th(z)):(D=S,S=r)}else D=S,S=r;if(S===r)if(S=D,e.charCodeAt(D)===39?(x=Oe,D++):(x=r,Q===0&&he(kt)),x!==r){for(z=[],H=ce();H!==r;)z.push(H),H=ce();e.charCodeAt(D)===39?(H=Oe,D++):(H=r,Q===0&&he(kt)),H!==r?(Ve=S,S=Yt(z)):(D=S,S=r)}else D=S,S=r;return Q--,S===r&&(x=r,Q===0&&he(nu)),S}function ee(){var S,x,z,H;return S=D,x=D,z=D,Q++,e.charCodeAt(D)===34?(H=Fe,D++):(H=r,Q===0&&he(Is)),H===r&&(e.charCodeAt(D)===92?(H=we,D++):(H=r,Q===0&&he(fn)),H===r&&(H=mn())),Q--,H===r?z=void 0:(D=z,z=r),z!==r?(H=wr(),H!==r?(z=[z,H],x=z):(D=x,x=r)):(D=x,x=r),x!==r?S=e.substring(S,D):S=x,S===r&&(S=D,e.charCodeAt(D)===92?(x=we,D++):(x=r,Q===0&&he(fn)),x!==r?(z=$t(),z!==r?S=z:(D=S,S=r)):(D=S,S=r),S===r&&(S=st())),S}function ce(){var S,x,z,H;return S=D,x=D,z=D,Q++,e.charCodeAt(D)===39?(H=Oe,D++):(H=r,Q===0&&he(kt)),H===r&&(e.charCodeAt(D)===92?(H=we,D++):(H=r,Q===0&&he(fn)),H===r&&(H=mn())),Q--,H===r?z=void 0:(D=z,z=r),z!==r?(H=wr(),H!==r?(z=[z,H],x=z):(D=x,x=r)):(D=x,x=r),x!==r?S=e.substring(S,D):S=x,S===r&&(S=D,e.charCodeAt(D)===92?(x=we,D++):(x=r,Q===0&&he(fn)),x!==r?(z=$t(),z!==r?S=z:(D=S,S=r)):(D=S,S=r),S===r&&(S=st())),S}function ae(){var S,x,z,H,ie,ue;if(Q++,S=D,e.charCodeAt(D)===91?(x=ir,D++):(x=r,Q===0&&he(Ro)),x!==r){for(e.charCodeAt(D)===94?(z=Ft,D++):(z=r,Q===0&&he(iu)),z===r&&(z=null),H=[],ie=$e(),ie===r&&(ie=qe());ie!==r;)H.push(ie),ie=$e(),ie===r&&(ie=qe());e.charCodeAt(D)===93?(ie=ct,D++):(ie=r,Q===0&&he(si)),ie!==r?(e.charCodeAt(D)===105?(ue=oe,D++):(ue=r,Q===0&&he(ia)),ue===r&&(ue=null),Ve=S,S=xo(z,H,ue)):(D=S,S=r)}else D=S,S=r;return Q--,S===r&&(x=r,Q===0&&he($o)),S}function $e(){var S,x,z,H;return S=D,x=qe(),x!==r?(e.charCodeAt(D)===45?(z=Mt,D++):(z=r,Q===0&&he(ar)),z!==r?(H=qe(),H!==r?(Ve=S,S=Oi(x,H)):(D=S,S=r)):(D=S,S=r)):(D=S,S=r),S}function qe(){var S,x,z,H;return S=D,x=D,z=D,Q++,e.charCodeAt(D)===93?(H=ct,D++):(H=r,Q===0&&he(si)),H===r&&(e.charCodeAt(D)===92?(H=we,D++):(H=r,Q===0&&he(fn)),H===r&&(H=mn())),Q--,H===r?z=void 0:(D=z,z=r),z!==r?(H=wr(),H!==r?(z=[z,H],x=z):(D=x,x=r)):(D=x,x=r),x!==r?S=e.substring(S,D):S=x,S===r&&(S=D,e.charCodeAt(D)===92?(x=we,D++):(x=r,Q===0&&he(fn)),x!==r?(z=$t(),z!==r?S=z:(D=S,S=r)):(D=S,S=r),S===r&&(S=st())),S}function st(){var S,x,z;return S=D,e.charCodeAt(D)===92?(x=we,D++):(x=r,Q===0&&he(fn)),x!==r?(z=lu(),z!==r?(Ve=S,S=Nc()):(D=S,S=r)):(D=S,S=r),S}function $t(){var S,x,z,H;return S=wt(),S===r&&(S=D,e.charCodeAt(D)===48?(x=Bt,D++):(x=r,Q===0&&he(Dt)),x!==r?(z=D,Q++,H=Ui(),Q--,H===r?z=void 0:(D=z,z=r),z!==r?(Ve=S,S=Oo()):(D=S,S=r)):(D=S,S=r),S===r&&(S=pu(),S===r&&(S=Qc()))),S}function wt(){var S;return S=hu(),S===r&&(S=ph()),S}function hu(){var S,x;return e.charCodeAt(D)===39?(S=Oe,D++):(S=r,Q===0&&he(kt)),S===r&&(e.charCodeAt(D)===34?(S=Fe,D++):(S=r,Q===0&&he(Is)),S===r&&(e.charCodeAt(D)===92?(S=we,D++):(S=r,Q===0&&he(fn)),S===r&&(S=D,e.charCodeAt(D)===98?(x=Qe,D++):(x=r,Q===0&&he(To)),x!==r&&(Ve=S,x=Wr()),S=x,S===r&&(S=D,e.charCodeAt(D)===102?(x=bt,D++):(x=r,Q===0&&he(sa)),x!==r&&(Ve=S,x=Lc()),S=x,S===r&&(S=D,e.charCodeAt(D)===110?(x=Je,D++):(x=r,Q===0&&he(ur)),x!==r&&(Ve=S,x=Uc()),S=x,S===r&&(S=D,e.charCodeAt(D)===114?(x=ft,D++):(x=r,Q===0&&he(aa)),x!==r&&(Ve=S,x=Hc()),S=x,S===r&&(S=D,e.charCodeAt(D)===116?(x=qt,D++):(x=r,Q===0&&he(su)),x!==r&&(Ve=S,x=jc()),S=x,S===r&&(S=D,e.charCodeAt(D)===118?(x=ze,D++):(x=r,Q===0&&he(au)),x!==r&&(Ve=S,x=Mc()),S=x)))))))),S}function ph(){var S,x,z,H;return S=D,x=D,z=D,Q++,H=Zr(),H===r&&(H=mn()),Q--,H===r?z=void 0:(D=z,z=r),z!==r?(H=wr(),H!==r?(z=[z,H],x=z):(D=x,x=r)):(D=x,x=r),x!==r?S=e.substring(S,D):S=x,S}function Zr(){var S;return S=hu(),S===r&&(S=Ui(),S===r&&(e.charCodeAt(D)===120?(S=Ot,D++):(S=r,Q===0&&he(oa)),S===r&&(e.charCodeAt(D)===117?(S=Pn,D++):(S=r,Q===0&&he(ai))))),S}function pu(){var S,x,z,H,ie,ue;return S=D,e.charCodeAt(D)===120?(x=Ot,D++):(x=r,Q===0&&he(oa)),x!==r?(z=D,H=D,ie=Gn(),ie!==r?(ue=Gn(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r),H!==r?z=e.substring(z,D):z=H,z!==r?(Ve=S,S=qc(z)):(D=S,S=r)):(D=S,S=r),S}function Qc(){var S,x,z,H,ie,ue,Et,Lt;return S=D,e.charCodeAt(D)===117?(x=Pn,D++):(x=r,Q===0&&he(ai)),x!==r?(z=D,H=D,ie=Gn(),ie!==r?(ue=Gn(),ue!==r?(Et=Gn(),Et!==r?(Lt=Gn(),Lt!==r?(ie=[ie,ue,Et,Lt],H=ie):(D=H,H=r)):(D=H,H=r)):(D=H,H=r)):(D=H,H=r),H!==r?z=e.substring(z,D):z=H,z!==r?(Ve=S,S=Ur(z)):(D=S,S=r)):(D=S,S=r),S}function Ui(){var S;return br.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(ca)),S}function Gn(){var S;return Js.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(uu)),S}function du(){var S,x;return S=D,e.charCodeAt(D)===46?(x=sr,D++):(x=r,Q===0&&he(la)),x!==r&&(Ve=S,x=rh()),S=x,S}function ot(){var S,x,z,H;return Q++,S=D,e.charCodeAt(D)===123?(x=i,D++):(x=r,Q===0&&he(ri)),x!==r?(z=dh(),e.charCodeAt(D)===125?(H=c,D++):(H=r,Q===0&&he(xi)),H!==r?S=z:(D=S,S=r)):(D=S,S=r),Q--,S===r&&(x=r,Q===0&&he(fa)),S}function dh(){var S,x;return S=D,x=gu(),Ve=S,x=Xr(x),S=x,S}function gu(){var S,x,z,H,ie,ue;if(S=D,x=[],z=[],H=D,ie=D,Q++,kr.test(e.charAt(D))?(ue=e.charAt(D),D++):(ue=r,Q===0&&he(Nr)),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r),H!==r)for(;H!==r;)z.push(H),H=D,ie=D,Q++,kr.test(e.charAt(D))?(ue=e.charAt(D),D++):(ue=r,Q===0&&he(Nr)),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r);else z=r;for(z===r&&(z=D,e.charCodeAt(D)===123?(H=i,D++):(H=r,Q===0&&he(ri)),H!==r?(ie=gu(),e.charCodeAt(D)===125?(ue=c,D++):(ue=r,Q===0&&he(xi)),ue!==r?(H=[H,ie,ue],z=H):(D=z,z=r)):(D=z,z=r));z!==r;){if(x.push(z),z=[],H=D,ie=D,Q++,kr.test(e.charAt(D))?(ue=e.charAt(D),D++):(ue=r,Q===0&&he(Nr)),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r),H!==r)for(;H!==r;)z.push(H),H=D,ie=D,Q++,kr.test(e.charAt(D))?(ue=e.charAt(D),D++):(ue=r,Q===0&&he(Nr)),Q--,ue===r?ie=void 0:(D=ie,ie=r),ie!==r?(ue=wr(),ue!==r?(ie=[ie,ue],H=ie):(D=H,H=r)):(D=H,H=r);else z=r;z===r&&(z=D,e.charCodeAt(D)===123?(H=i,D++):(H=r,Q===0&&he(ri)),H!==r?(ie=gu(),e.charCodeAt(D)===125?(ue=c,D++):(ue=r,Q===0&&he(xi)),ue!==r?(H=[H,ie,ue],z=H):(D=z,z=r)):(D=z,z=r))}return S=e.substring(S,D),S}function mu(){var S;return ht.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he($)),S}function gh(){var S;return zt.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(T)),S}function mh(){var S;return Ye.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(U)),S}function vh(){var S;return Cr.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(J)),S}function vu(){var S;return Zs.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(pe)),S}function ui(){var S;return Qs.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(me)),S}function Au(){var S;return ea.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(Ce)),S}function el(){var S;return ta.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(Pe)),S}function wu(){var S;return Ti.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(At)),S}function tl(){var S;return ra.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(Nt)),S}function rl(){var S;return Cs.test(e.charAt(D))?(S=e.charAt(D),D++):(S=r,Q===0&&he(mr)),S}function pt(){var S,x;for(S=[],x=gn(),x===r&&(x=lu(),x===r&&(x=Xc()));x!==r;)S.push(x),x=gn(),x===r&&(x=lu(),x===r&&(x=Xc()));return S}function nl(){var S,x;for(S=[],x=gn(),x===r&&(x=Li());x!==r;)S.push(x),x=gn(),x===r&&(x=Li());return S}function Hi(){var S,x,z,H;return S=D,x=pt(),e.charCodeAt(D)===59?(z=gr,D++):(z=r,Q===0&&he(vr)),z!==r?(x=[x,z],S=x):(D=S,S=r),S===r&&(S=D,x=nl(),z=Jr(),z===r&&(z=null),H=lu(),H!==r?(x=[x,z,H],S=x):(D=S,S=r),S===r&&(S=D,x=pt(),z=ji(),z!==r?(x=[x,z],S=x):(D=S,S=r))),S}function ji(){var S,x;return S=D,Q++,e.length>D?(x=e.charAt(D),D++):(x=r,Q===0&&he(Fs)),Q--,x===r?S=void 0:(D=S,S=r),S}let Eu=t.reservedWords||[];if(dn=a(),dn!==r&&D===e.length)return dn;throw dn!==r&&D{"use strict";var CB=Uf(),FB=rw(),_B=iw(),IB=q0(),DB=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","new","return","super","switch","this","throw","try","typeof","var","void","while","with","null","true","false","enum","implements","interface","let","package","private","protected","public","static","yield","await"],xc={VERSION:IB,RESERVED_WORDS:DB,GrammarError:CB,parser:_B,compiler:FB,generate(e,t){t=t!==void 0?t:{};function r(a){let i={};return Object.keys(a).forEach(c=>{i[c]=a[c].slice()}),i}let n="plugins"in t?t.plugins:[],s={parser:xc.parser,passes:r(xc.compiler.passes),reservedWords:xc.RESERVED_WORDS.slice()};return n.forEach(a=>{a.use(s,t)}),xc.compiler.compile(s.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:s.reservedWords}),s.passes,t)}};sw.exports=xc});var od=Un(Rl());var Np=Un(Hg());function qC(e){let t=Np.default.pemtohex(e);return Np.default.KJUR.crypto.Util.hashHex(t,"sha256").match(/.{2}/g).join(":").toUpperCase()}var jg={generateFingerprint:qC};var dc=Un(Tv());function xv(e,t,...r){try{return e(t,...r)}catch{return e(Ov(e(t.replace(/!\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function nf(e,...t){return xv(dc.default.safeLoad,JSON.parse(JSON.stringify(e)),...t)}function E_(e,...t){return xv(dc.default.load,JSON.parse(JSON.stringify(e)),...t)}function y_(e,...t){return dc.default.safeDump(JSON.parse(JSON.stringify(e)),...t)}function Ov(e,...t){return dc.default.dump(JSON.parse(JSON.stringify(e)),...t)}var Oa={safeLoad:nf,load:E_,safeDump:y_,dump:Ov};var rs="settings",Xp="subs",kv="collections",sf="files",Nv="modules";var Lv="rules";var ka="#sub-store-cached-resource",Na="#sub-store-cached-headers-resource",af="#sub-store-chr-expiration-time";var La="#sub-store-cached-script-resource",uf="#sub-store-csr-expiration-time";var js=typeof $task<"u",ns=typeof $loon<"u",Ms=typeof $httpClient<"u"&&!ns,gi=eval('typeof process !== "undefined"'),Uv=typeof $environment<"u"&&$environment["stash-version"],Hv=typeof $rocket<"u",S_=typeof egern=="object",b_=typeof $native<"u",qs=typeof $Plugins<"u",of=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=is(),this.env=mi(),gi){let dotenv=eval('require("dotenv")');dotenv.config()}this.node=(()=>{if(gi){let fs=eval("require('fs')");return{fs}}else return null})(),this.initCache();let delay=(e,t)=>new Promise(function(r){setTimeout(r.bind(null,t),e)});Promise.prototype.delay=async function(e){let t=await this;return await delay(e,t)}}initCache(){if(js&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(ns||Ms)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),qs&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),gi){let basePath=eval("process.env.SUB_STORE_DATA_BASE_PATH")||".",rootPath=`${basePath}/root.json`;this.log(`Root path: ${rootPath}`),this.node.fs.existsSync(rootPath)?this.root=JSON.parse(this.node.fs.readFileSync(`${rootPath}`)):(this.node.fs.writeFileSync(rootPath,JSON.stringify({}),{flag:"wx"}),this.root={});let fpath=`${basePath}/${this.name}.json`;this.log(`Data path: ${fpath}`),this.node.fs.existsSync(fpath)?this.cache=JSON.parse(this.node.fs.readFileSync(`${fpath}`)):(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"wx"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(js&&$prefs.setValueForKey(data,this.name),(ns||Ms)&&$persistentStore.write(data,this.name),qs&&$Plugins.SubStoreCache.set(this.name,data),gi){let basePath=eval("process.env.SUB_STORE_DATA_BASE_PATH")||".";this.node.fs.writeFileSync(`${basePath}/${this.name}.json`,data,{flag:"w"},e=>console.log(e)),this.node.fs.writeFileSync(`${basePath}/root.json`,JSON.stringify(this.root,null,2),{flag:"w"},e=>console.log(e))}}write(e,t){if(this.log(`SET ${t}`),t.indexOf("#")!==-1){if(t=t.substr(1),Ms||ns)return $persistentStore.write(e,t);if(js)return $prefs.setValueForKey(e,t);if(gi&&(this.root[t]=e),qs)return $Plugins.SubStoreCache.set(t,e)}else this.cache[t]=e;this.persistCache()}read(e){if(this.log(`READ ${e}`),e.indexOf("#")!==-1){if(e=e.substr(1),Ms||ns)return $persistentStore.read(e);if(js)return $prefs.valueForKey(e);if(gi)return this.root[e];if(qs)return $Plugins.SubStoreCache.get(e)}else return this.cache[e]}delete(e){if(this.log(`DELETE ${e}`),e.indexOf("#")!==-1){if(e=e.substr(1),Ms||ns)return $persistentStore.write(null,e);if(js)return $prefs.removeValueForKey(e);if(gi&&delete this.root[e],qs)return $Plugins.SubStoreCache.remove(e)}else delete this.cache[e];this.persistCache()}notify(title,subtitle="",content="",options={}){let openURL=options["open-url"],mediaURL=options["media-url"];if(js&&$notify(title,subtitle,content,options),Ms&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),ns){let e={};openURL&&(e.openUrl=openURL),mediaURL&&(e.mediaUrl=mediaURL),JSON.stringify(e)==="{}"?$notification.post(title,subtitle,content):$notification.post(title,subtitle,content,e)}if(gi){let content_=content+(openURL?` \u70B9\u51FB\u8DF3\u8F6C: ${openURL}`:"")+(mediaURL?` \u591A\u5A92\u4F53: ${mediaURL}`:"");console.log(`${title} ${subtitle} ${content_} `);let push=eval("process.env.SUB_STORE_PUSH_SERVICE");if(push){let e=push.replace("[\u63A8\u9001\u6807\u9898]",encodeURIComponent(title||"Sub-Store")).replace("[\u63A8\u9001\u5185\u5BB9]",encodeURIComponent([subtitle,content_].map(r=>r).join(` `)));is().get({url:e}).then(r=>{console.log(`[Push Service] URL: ${e} RES: ${r.statusCode} ${r.body}`)}).catch(r=>{console.log(`[Push Service] URL: ${e} ERROR: ${r}`)})}}qs&&$Plugins.Notify(title,subtitle+` `+content)}log(e){this.debug&&console.log(`[${this.name}] LOG: ${e}`)}info(e){console.log(`[${this.name}] INFO: ${e}`)}error(e){console.log(`[${this.name}] ERROR: ${e}`)}wait(e){return new Promise(t=>setTimeout(t,e))}done(e={}){js||ns||Ms||qs?$done(e):gi&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function mi(){return{isQX:js,isLoon:ns,isSurge:Ms,isNode:gi,isStash:Uv,isShadowRocket:Hv,isEgern:S_,isLanceX:b_,isGUIforCores:qs}}function is(defaultOptions={baseURL:""}){let{isQX,isLoon,isSurge,isNode,isGUIforCores}=mi(),methods=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH"],URL_REGEX=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;function send(method,options){options=typeof options=="string"?{url:options}:options;let baseURL=defaultOptions.baseURL;baseURL&&!URL_REGEX.test(options.url||"")&&(options.url=baseURL?baseURL+options.url:options.url),options={...defaultOptions,...options};let timeout=options.timeout,events={onRequest:()=>{},onResponse:e=>e,onTimeout:()=>{},...options.events};if(events.onRequest(method,options),options.node&&isSurge){let e=$environment["surge-build"];e&&parseInt(e)>=2407&&(options["policy-descriptor"]=options.node,delete options.node)}let worker;isQX?worker=$task.fetch({method,url:options.url,headers:options.headers,body:options.body,opts:options.opts}):isLoon||isSurge||isNode?worker=new Promise(async(resolve,reject)=>{let body=options.body,opts=JSON.parse(JSON.stringify(options));if(opts.body=body,opts.timeout=opts.timeout||8e3,opts.timeout&&(opts.timeout++,isNaN(opts.timeout)&&(opts.timeout=8e3),!isNode)){let e="ms";(isSurge||Uv||Hv)&&(opts.timeout=Math.ceil(opts.timeout/1e3),e="s")}if(isNode){let undici=eval("require('undici')"),{ProxyAgent,EnvHttpProxyAgent,request,interceptors}=undici,agentOpts={connect:{rejectUnauthorized:!(opts.strictSSL===!1||opts.insecure===!0)},bodyTimeout:opts.timeout,headersTimeout:opts.timeout};try{let e=new URL(opts.url);(e.username||e.password)&&(opts.headers={...opts.headers||{},Authorization:`Basic ${Buffer.from(`${e.username||""}:${e.password||""}`).toString("base64")}`});let t=await request(opts.url,{...opts,method:method.toUpperCase(),dispatcher:(opts.proxy?new ProxyAgent({...agentOpts,uri:opts.proxy}):new EnvHttpProxyAgent(agentOpts)).compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirects:!0}))});resolve({statusCode:t.statusCode,headers:t.headers,body:opts.encoding===null?await t.body.arrayBuffer():await t.body.text()})}catch(e){reject(e)}}else $httpClient[method.toLowerCase()](opts,(e,t,r)=>{e?reject(e):resolve({statusCode:t.status||t.statusCode,headers:t.headers,body:r})})}):isGUIforCores&&(worker=new Promise(async(e,t)=>{try{let r=await $Plugins.Requests({method,url:options.url,headers:options.headers,body:options.body,options:{Proxy:options.proxy,Timeout:options.timeout?options.timeout/1e3:15}});e({statusCode:r.status,headers:r.headers,body:r.body})}catch(r){t(r)}}));let timeoutid,timer=timeout?new Promise((e,t)=>{timeoutid=setTimeout(()=>(events.onTimeout(),t(`${method} URL: ${options.url} exceeds the timeout ${timeout} ms`)),timeout)}):null;return(timer?Promise.race([timer,worker]).then(e=>(typeof clearTimeout<"u"&&clearTimeout(timeoutid),e)):worker).then(e=>events.onResponse(e))}let http={};return methods.forEach(e=>http[e.toLowerCase()]=t=>send(e,t)),http}var Jp=0;function Jn(e){return F_(C_(__(e)))}function C_(e){return D_(B_(I_(e),e.length*8))}function F_(e){try{}catch{Jp=0}for(var t=Jp?"0123456789ABCDEF":"0123456789abcdef",r="",n,s=0;s>>4&15)+t.charAt(n&15);return r}function __(e){for(var t="",r=-1,n,s;++r>>6&31,128|n&63):n<=65535?t+=String.fromCharCode(224|n>>>12&15,128|n>>>6&63,128|n&63):n<=2097151&&(t+=String.fromCharCode(240|n>>>18&7,128|n>>>12&63,128|n>>>6&63,128|n&63));return t}function I_(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function B_(e,t){e[t>>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,n=-271733879,s=-1732584194,a=271733878,i=0;i>16)+(t>>16)+(r>>16);return n<<16|r&65535}function P_(e,t){return e<>>32-t}var Af=Un(Qv()),rI=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,nI=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;function rr(e){return rI.test(e)}function nr(e){return nI.test(e)}function e2(e){return/^((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4}))$/.test(e)}function yi(e){return typeof e=="string"&&e.trim().length>0}function xt(e,t){return yi(e)?e:t}function Xu(e){return typeof e<"u"&&e!==null}function ja(e,t){return Xu(e)?e:t}function as(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function iI(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function vc(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,s]=r.split("-").map(Number);return iI(n,s)}else return Number(r)}function t2(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function wf(e){return typeof e=="string"&&/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)}var sI=new of("sub-store"),ne=sI;var c0=class{constructor(t){this.expires=t,ne.read(ka)||ne.write("{}",ka);try{this.resourceCache=JSON.parse(ne.read(ka))}catch(r){ne.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${ka} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${r?.message??r}`),this.resourceCache={},ne.write("{}",ka)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,s]=r;s.time||(delete this.resourceCache[n],ne.delete(`#${n}`),t=!0),new Date().getTime()-s.time>this.expires&&(delete this.resourceCache[n],t=!0)}),t&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){ne.write(JSON.stringify(this.resourceCache),ka)}get(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].data:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}},hr=new c0(36e5);var l0=class{constructor(){this.expires=uI(),ne.read(Na)||ne.write("{}",Na);try{this.resourceCache=JSON.parse(ne.read(Na))}catch(t){ne.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Na} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},ne.write("{}",Na)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,s]=r;s.time||(delete this.resourceCache[n],ne.delete(`#${n}`),t=!0),new Date().getTime()-s.time>this.expires&&(delete this.resourceCache[n],t=!0)}),t&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){ne.write(JSON.stringify(this.resourceCache),Na)}get(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].data:null}gettime(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].time:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}};function uI(){ne.read(af)||ne.write("6e4",af);let e=6e4;if(ne.env.isLoon){let t={"1\u5206\u949F":6e4,"5\u5206\u949F":3e5,"10\u5206\u949F":6e5,"30\u5206\u949F":18e5,"1\u5C0F\u65F6":36e5,"2\u5C0F\u65F6":72e5,"3\u5C0F\u65F6":108e5,"6\u5C0F\u65F6":216e5,"12\u5C0F\u65F6":432e5,"24\u5C0F\u65F6":864e5,"48\u5C0F\u65F6":1728e5,"72\u5C0F\u65F6":2592e5,\u53C2\u6570\u4F20\u5165:"readcachets"},r=ne.read("#\u54CD\u5E94\u5934\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=ne.read(af),e}var Ac=new l0;function Ju(e){let t=Object.keys(e),r="",n="";for(let s of t){let a=s.toLowerCase();a==="subscription-userinfo"?r=e[s]:a==="profile-web-page-url"&&(n=e[s])}return`${r||""}${n?`; app_url=${encodeURIComponent(n)}`:""}`}async function Ef(rawUrl,ua,timeout,customProxy,flowUrl){let url=flowUrl||rawUrl||"",$arguments={},rawArgs=url.split("#");if(url=url.split("#")[0],rawArgs.length>1)try{$arguments=JSON.parse(decodeURIComponent(rawArgs[1]))}catch{for(let t of rawArgs[1].split("&")){let r=t.split("=")[0],n=t.split("=")[1];$arguments[r]=n==null||n===""?!0:decodeURIComponent(n)}}if($arguments?.noFlow)return;let{isStash,isLoon,isShadowRocket,isQX}=mi(),insecure=$arguments?.insecure?ne.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=ne.read(rs),proxy=customProxy||defaultProxy;ne.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultFlowUserAgent||"clash",requestTimeout=timeout||defaultTimeout||8e3,id=Jn(userAgent+url),cached=Ac.get(id),flowInfo;if(!$arguments?.noCache&&cached)ne.info(`\u4F7F\u7528\u7F13\u5B58\u7684\u6D41\u91CF\u4FE1\u606F: ${url}, ${userAgent}`),flowInfo=cached;else{let e=is();if(flowUrl){ne.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${flowUrl}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{body:t}=await e.get({url:flowUrl,headers:{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?as(proxy):{},...insecure||{}});flowInfo=t}else{try{ne.info(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await e.head({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?as(proxy):{},...insecure||{}});flowInfo=Ju(t)}catch(t){ne.error(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${t.message??t}`)}if(!flowInfo){ne.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await e.get({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?as(proxy):{},...insecure||{}});flowInfo=Ju(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&Ac.set(id,flowInfo)}return flowInfo}function yf(e){if(!e)return;let t=e.match(/upload=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),r=Number(t[1]+t[2]),n=e.match(/download=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),s=Number(n[1]+n[2]),a=e.match(/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),i=Number(a[1]+a[2]),c=e.match(/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),l=c?Number(c[1]+c[2]):void 0,h=e.match(/reset_day=([0-9]+)/),v=h?Number(h[1]):void 0,E=e.match(/app_url=(.*?)\s*?(;|$)/),p=E?decodeURIComponent(E[1]):void 0,f=e.match(/plan_name=(.*?)\s*?(;|$)/),w=f?decodeURIComponent(f[1]):void 0;return{expires:l,total:i,usage:{upload:r,download:s},remainingDays:v,appUrl:p,planName:w}}function wc(e,t="B"){let r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],n=r.indexOf(t);return e<1024||n===r.length-1?{value:e.toFixed(1),unit:t}:wc(e/1024,r[++n])}function Sf(e){if(!e)throw new Error("\u6CA1\u6709\u6D41\u91CF\u4FE1\u606F");if(e?.expires&&e.expires*1e3a.getTime())throw new Error("\u5F00\u59CB\u65E5\u671F\u5E94\u65E9\u4E8E\u73B0\u5728");let i=new Date(r);for(i.setDate(i.getDate()+n);i31)throw new Error("\u6708\u91CD\u7F6E\u65E5\u5E94\u4E3A 1-31 \u4E4B\u95F4\u7684\u6574\u6570");let s=new Date,a=s.getDate(),i=s.getMonth(),c=s.getFullYear(),l;return t>a?l=0:l=new Date(c,i+1,0).getDate(),l-a+t}}catch(t){ne.error(`getRmainingDays failed: ${t.message??t}`)}}function n2(e){try{let t=new Map;return e.split(";").map(r=>r.trim()).filter(Boolean).forEach(r=>{let n=r.indexOf("=");if(n===-1)return;let s=r.slice(0,n).trim(),a=r.slice(n+1).trim();if(!t.has(s))try{let i=decodeURIComponent(a);t.set(s,i)}catch{t.set(s,a)}}),Array.from(t.entries()).map(([r,n])=>`${r}=${encodeURIComponent(n)}`).join("; ")}catch(t){return ne.error(`normalizeFlowHeader failed: ${t.message??t}`),e}}var c2="3.7.7",oI=c2,Qu=typeof Buffer=="function",i2=typeof TextDecoder=="function"?new TextDecoder:void 0,s2=typeof TextEncoder=="function"?new TextEncoder:void 0,cI="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Ec=Array.prototype.slice.call(cI),bf=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(Ec),lI=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,yr=String.fromCharCode.bind(String),a2=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),l2=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),f2=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),h2=e=>{let t,r,n,s,a="",i=e.length%3;for(let c=0;c255||(n=e.charCodeAt(c++))>255||(s=e.charCodeAt(c++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|s,a+=Ec[t>>18&63]+Ec[t>>12&63]+Ec[t>>6&63]+Ec[t&63]}return i?a.slice(0,i-3)+"===".substring(i):a},p0=typeof btoa=="function"?e=>btoa(e):Qu?e=>Buffer.from(e,"binary").toString("base64"):h2,f0=Qu?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,s=e.length;nt?l2(f0(e)):f0(e),fI=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?yr(192|t>>>6)+yr(128|t&63):yr(224|t>>>12&15)+yr(128|t>>>6&63)+yr(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return yr(240|t>>>18&7)+yr(128|t>>>12&63)+yr(128|t>>>6&63)+yr(128|t&63)}},hI=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,p2=e=>e.replace(hI,fI),u2=Qu?e=>Buffer.from(e,"utf8").toString("base64"):s2?e=>f0(s2.encode(e)):e=>p0(p2(e)),Zu=(e,t=!1)=>t?l2(u2(e)):u2(e),o2=e=>Zu(e,!0),pI=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,dI=e=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return yr((r>>>10)+55296)+yr((r&1023)+56320);case 3:return yr((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return yr((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},d2=e=>e.replace(pI,dI),g2=e=>{if(e=e.replace(/\s+/g,""),!lI.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,s;for(let a=0;a>16&255):s===64?yr(t>>16&255,t>>8&255):yr(t>>16&255,t>>8&255,t&255);return r},d0=typeof atob=="function"?e=>atob(f2(e)):Qu?e=>Buffer.from(e,"base64").toString("binary"):g2,m2=Qu?e=>a2(Buffer.from(e,"base64")):e=>a2(d0(e).split("").map(t=>t.charCodeAt(0))),v2=e=>m2(A2(e)),gI=Qu?e=>Buffer.from(e,"base64").toString("utf8"):i2?e=>i2.decode(m2(e)):e=>d2(d0(e)),A2=e=>f2(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),h0=e=>gI(A2(e)),mI=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},w2=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),E2=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,w2(r));e("fromBase64",function(){return h0(this)}),e("toBase64",function(t){return Zu(this,t)}),e("toBase64URI",function(){return Zu(this,!0)}),e("toBase64URL",function(){return Zu(this,!0)}),e("toUint8Array",function(){return v2(this)})},y2=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,w2(r));e("toBase64",function(t){return Cf(this,t)}),e("toBase64URI",function(){return Cf(this,!0)}),e("toBase64URL",function(){return Cf(this,!0)})},vI=()=>{E2(),y2()},dt={version:c2,VERSION:oI,atob:d0,atobPolyfill:g2,btoa:p0,btoaPolyfill:h2,fromBase64:h0,toBase64:Zu,encode:Zu,encodeURI:o2,encodeURL:o2,utob:p2,btou:d2,decode:h0,isValid:mI,fromUint8Array:Cf,toUint8Array:v2,extendString:E2,extendUint8Array:y2,extendBuiltins:vI};function AI(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function wI(){let e="Base64 Pre-processor",t=["dm1lc3M","c3NyOi8v","c29ja3M6Ly","dHJvamFu","c3M6Ly","c3NkOi8v","c2hhZG93","aHR0c","dmxlc3M=","aHlzdGVyaWEy","aHkyOi8v","d2lyZWd1YXJkOi8v","d2c6Ly8=","dHVpYzovLw=="];return{name:e,test:function(s){return!/^\w+:\/\/\w+/im.test(s)&&t.some(a=>s.indexOf(a)!==-1)},parse:function(s){let a=dt.decode(s);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(a)?a:(ne.error("Base64 Pre-processor error: decoded line does not start with protocol"),s)}}}function EI(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let s=nf(n);return s.proxies&&Array.isArray(s.proxies)},parse:function(n,s){let a=n.replace(/short-id:([ \t]*[^#\n,}]*)/g,(l,h)=>{let v=h.trim();return!v||v===""?'short-id: ""':/^(['"]).*\1$/.test(v)?`short-id: ${v}`:["null"].includes(v)?`short-id: ${v}`:`short-id: "${v}"`}),{proxies:i,"global-client-fingerprint":c}=nf(a);return(s?`proxies: `:"")+i.map(l=>(c&&!l["client-fingerprint"]&&(l["client-fingerprint"]=c),`${s?" - ":""}${JSON.stringify(l)} `)).join("")}}}function yI(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let s=[],a=JSON.parse(dt.decode(n.split("ssd://")[1])),i=a.port,c=a.encryption,l=a.password,h=a.servers;for(let v=0;ve.name==="Clash Pre-processor"),g0=new Map;async function Or(rawUrl="",ua,timeout,customProxy,skipCustomCache,awaitCustomCache,noCache,preprocess){let $arguments={},url=rawUrl.replace(/#noFlow$/,""),rawArgs=url.split("#");if(url=url.split("#")[0],rawArgs.length>1)try{$arguments=JSON.parse(decodeURIComponent(rawArgs[1]))}catch{for(let t of rawArgs[1].split("&")){let r=t.split("=")[0],n=t.split("=")[1];$arguments[r]=n==null||n===""?!0:decodeURIComponent(n)}}let{isNode,isStash,isLoon,isShadowRocket,isQX}=mi(),{defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=ne.read(rs),cacheThreshold=defaultCacheThreshold||1024,proxy=customProxy||defaultProxy;ne.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultUserAgent||"clash.meta",requestTimeout=timeout||defaultTimeout||8e3,id=Jn(userAgent+url);$arguments?.cacheKey===!0&&(ne.error("\u4F7F\u7528\u81EA\u5B9A\u4E49\u7F13\u5B58\u65F6 cacheKey \u7684\u503C\u4E0D\u80FD\u4E3A\u7A7A"),$arguments.cacheKey=void 0);let customCacheKey=$arguments?.cacheKey?`#sub-store-cached-custom-${$arguments?.cacheKey}`:void 0;if(customCacheKey&&!skipCustomCache){let e=ne.read(customCacheKey),t=hr.get(id);if(!noCache&&!$arguments?.noCache&&t)return ne.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u5B58\u5728\u6709\u6548\u7684\u5E38\u89C4\u7F13\u5B58 \u4F7F\u7528\u5E38\u89C4\u7F13\u5B58\u4EE5\u907F\u514D\u91CD\u590D\u8BF7\u6C42`),t;if(e){if(awaitCustomCache){ne.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u672C\u6B21\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u66F4\u65B0\u7F13\u5B58`);try{await Or(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess)}catch(r){ne.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`),ne.info("\u4F7F\u7528\u4E50\u89C2\u7F13\u5B58\u7684\u6570\u636E\u5237\u65B0\u7F13\u5B58, \u9632\u6B62\u540E\u7EED\u8BF7\u6C42"),hr.set(id,e)}}else ne.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u672C\u6B21\u8FD4\u56DE\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey} \u5E76\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u5F02\u6B65\u66F4\u65B0\u7F13\u5B58`),Or(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess).catch(r=>{ne.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u5F02\u6B65\u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`)});return e}}if(!isNode&&g0.has(id))return g0.get(id);let http=is({headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,cached=hr.get(id);if(!noCache&&!$arguments?.noCache&&cached)ne.info(`\u4F7F\u7528\u7F13\u5B58: ${url}, ${userAgent}`),result=cached,customCacheKey&&(ne.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),ne.write(cached,customCacheKey));else{let e=$arguments?.insecure?isNode?{strictSSL:!1}:{insecure:!0}:void 0;ne.info(`Downloading... User-Agent: ${userAgent} Timeout: ${requestTimeout} Proxy: ${proxy} Insecure: ${!!e} Preprocess: ${preprocess} URL: ${url}`);try{let{body:t,headers:r,statusCode:n}=await http.get({url,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?as(proxy):{},...e||{}});if(ne.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let a=Ju(r);a&&Ac.set(id,a)}if(t.replace(/\s/g,"").length===0)throw new Error(new Error("\u8FDC\u7A0B\u8D44\u6E90\u5185\u5BB9\u4E3A\u7A7A"));if(preprocess)try{S2.test(t)&&(t=S2.parse(t,!0))}catch(a){ne.error(`Clash Pre-processor error: ${a}`)}let s=!0;if(cacheThreshold){let a=t.length/1024;a>cacheThreshold&&(ne.info(`\u8D44\u6E90\u5927\u5C0F ${a.toFixed(2)} KB \u8D85\u8FC7\u4E86 ${cacheThreshold} KB, \u4E0D\u7F13\u5B58`),s=!1)}s&&(hr.set(id,t),customCacheKey&&(ne.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),ne.write(t,customCacheKey))),result=t}catch(t){if(customCacheKey){let r=ne.read(customCacheKey);if(r)return ne.info(`\u65E0\u6CD5\u4E0B\u8F7D URL ${url}: ${t.message??t} \u4F7F\u7528\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),r}throw new Error(`\u65E0\u6CD5\u4E0B\u8F7D URL ${url}: ${t.message??t}`)}}return $arguments?.validCheck&&await Sf(yf(await Ef(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl))),isNode||g0.set(id,result),result}var m0=class{constructor(){this.expires=bI(),ne.read(La)||ne.write("{}",La);try{this.resourceCache=JSON.parse(ne.read(La))}catch(t){ne.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${La} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},ne.write("{}",La)}this._cleanup()}_cleanup(t,r){let n=!1;Object.entries(this.resourceCache).forEach(s=>{let[a,i]=s;i.time||(delete this.resourceCache[a],ne.delete(`#${a}`),n=!0),(new Date().getTime()-i.time>(r??this.expires)||t&&a.startsWith(t))&&(delete this.resourceCache[a],n=!0)}),n&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){ne.write(JSON.stringify(this.resourceCache),La)}get(t,r,n){let s=this.resourceCache[t]&&this.resourceCache[t].time;if(s){if(new Date().getTime()-s<=(r??this.expires))return this.resourceCache[t].data;n&&(delete this.resourceCache[t],this._persist())}return null}gettime(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].time:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}};function bI(){ne.read(uf)||ne.write("1728e5",uf);let e=1728e5;if(ne.env.isLoon){let t={"1\u5206\u949F":6e4,"5\u5206\u949F":3e5,"10\u5206\u949F":6e5,"30\u5206\u949F":18e5,"1\u5C0F\u65F6":36e5,"2\u5C0F\u65F6":72e5,"3\u5C0F\u65F6":108e5,"6\u5C0F\u65F6":216e5,"12\u5C0F\u65F6":432e5,"24\u5C0F\u65F6":864e5,"48\u5C0F\u65F6":1728e5,"72\u5C0F\u65F6":2592e5,\u53C2\u6570\u4F20\u5165:"readcachets"},r=ne.read("#\u8282\u70B9\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=ne.read(uf),e}var v0=new m0;function _f(e,t){return[...Array(e).keys()].map(()=>t)}var A0={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["EXP","BAND"],"\u{1F1F8}\u{1F1F1}":["TEST","SOS"],"\u{1F1E6}\u{1F1E9}":["AD","AND"],"\u{1F1E6}\u{1F1EA}":["AE","ARE"],"\u{1F1E6}\u{1F1EB}":["AF","AFG"],"\u{1F1E6}\u{1F1F1}":["AL","ALB"],"\u{1F1E6}\u{1F1F2}":["AM","ARM"],"\u{1F1E6}\u{1F1F7}":["AR","ARG"],"\u{1F1E6}\u{1F1F9}":["AT","AUT"],"\u{1F1E6}\u{1F1FA}":["AU","AUS"],"\u{1F1E6}\u{1F1FF}":["AZ","AZE"],"\u{1F1E7}\u{1F1E6}":["BA","BIH"],"\u{1F1E7}\u{1F1E9}":["BD","BGD"],"\u{1F1E7}\u{1F1EA}":["BE","BEL"],"\u{1F1E7}\u{1F1EC}":["BG","BGR"],"\u{1F1E7}\u{1F1ED}":["BH","BHR"],"\u{1F1E7}\u{1F1F4}":["BO","BOL"],"\u{1F1E7}\u{1F1F3}":["BN","BRN"],"\u{1F1E7}\u{1F1F7}":["BR","BRA"],"\u{1F1E7}\u{1F1F9}":["BT","BTN"],"\u{1F1E7}\u{1F1FE}":["BY","BLR"],"\u{1F1E8}\u{1F1E6}":["CA","CAN"],"\u{1F1E8}\u{1F1ED}":["CH","CHE"],"\u{1F1E8}\u{1F1F1}":["CL","CHL"],"\u{1F1E8}\u{1F1F4}":["CO","COL"],"\u{1F1E8}\u{1F1F7}":["CR","CRI"],"\u{1F1E8}\u{1F1FE}":["CY","CYP"],"\u{1F1E8}\u{1F1FF}":["CZ","CZE"],"\u{1F1E9}\u{1F1EA}":["DE","DEU"],"\u{1F1E9}\u{1F1F0}":["DK","DNK"],"\u{1F1EA}\u{1F1E8}":["EC","ECU"],"\u{1F1EA}\u{1F1EA}":["EE","EST"],"\u{1F1EA}\u{1F1EC}":["EG","EGY"],"\u{1F1EA}\u{1F1F8}":["ES","ESP"],"\u{1F1EA}\u{1F1FA}":["EU"],"\u{1F1EB}\u{1F1EE}":["FI","FIN"],"\u{1F1EB}\u{1F1F7}":["FR","FRA"],"\u{1F1EC}\u{1F1E7}":["GB","GBR","UK"],"\u{1F1EC}\u{1F1EA}":["GE","GEO"],"\u{1F1EC}\u{1F1F7}":["GR","GRC"],"\u{1F1EC}\u{1F1F9}":["GT","GTM"],"\u{1F1EC}\u{1F1FA}":["GU","GUM"],"\u{1F1ED}\u{1F1F0}":["HK","HKG","HKT","HKBN","HGC","WTT","CMI"],"\u{1F1ED}\u{1F1F7}":["HR","HRV"],"\u{1F1ED}\u{1F1FA}":["HU","HUN"],"\u{1F1EF}\u{1F1F4}":["JO","JOR"],"\u{1F1EF}\u{1F1F5}":["JP","JPN","TYO"],"\u{1F1F0}\u{1F1EA}":["KE","KEN"],"\u{1F1F0}\u{1F1EC}":["KG","KGZ"],"\u{1F1F0}\u{1F1ED}":["KH","KGZ"],"\u{1F1F0}\u{1F1F5}":["KP","PRK"],"\u{1F1F0}\u{1F1F7}":["KR","KOR","SEL"],"\u{1F1F0}\u{1F1FF}":["KZ","KAZ"],"\u{1F1EE}\u{1F1E9}":["ID","IDN"],"\u{1F1EE}\u{1F1EA}":["IE","IRL"],"\u{1F1EE}\u{1F1F1}":["IL","ISR"],"\u{1F1EE}\u{1F1F2}":["IM","IMN"],"\u{1F1EE}\u{1F1F3}":["IN","IND"],"\u{1F1EE}\u{1F1F7}":["IR","IRN"],"\u{1F1EE}\u{1F1F8}":["IS","ISL"],"\u{1F1EE}\u{1F1F9}":["IT","ITA"],"\u{1F1F1}\u{1F1E6}":["LA","LAO"],"\u{1F1F1}\u{1F1F0}":["LK","LKA"],"\u{1F1F1}\u{1F1F9}":["LT","LTU"],"\u{1F1F1}\u{1F1FA}":["LU","LUX"],"\u{1F1F1}\u{1F1FB}":["LV","LVA"],"\u{1F1F2}\u{1F1E6}":["MA","MAR"],"\u{1F1F2}\u{1F1E9}":["MD","MDA"],"\u{1F1F3}\u{1F1EC}":["NG","NGA"],"\u{1F1F2}\u{1F1F2}":["MM","MMR"],"\u{1F1F2}\u{1F1F0}":["MK","MKD"],"\u{1F1F2}\u{1F1F3}":["MN","MNG"],"\u{1F1F2}\u{1F1F4}":["MO","MAC","CTM"],"\u{1F1F2}\u{1F1F9}":["MT","MLT"],"\u{1F1F2}\u{1F1FD}":["MX","MEX"],"\u{1F1F2}\u{1F1FE}":["MY","MYS"],"\u{1F1F3}\u{1F1F1}":["NL","NLD","AMS"],"\u{1F1F3}\u{1F1F4}":["NO","NOR"],"\u{1F1F3}\u{1F1F5}":["NP","NPL"],"\u{1F1F3}\u{1F1FF}":["NZ","NZL"],"\u{1F1F5}\u{1F1E6}":["PA","PAN"],"\u{1F1F5}\u{1F1EA}":["PE","PER"],"\u{1F1F5}\u{1F1ED}":["PH","PHL"],"\u{1F1F5}\u{1F1F0}":["PK","PAK"],"\u{1F1F5}\u{1F1F1}":["PL","POL"],"\u{1F1F5}\u{1F1F7}":["PR","PRI"],"\u{1F1F5}\u{1F1F9}":["PT","PRT"],"\u{1F1F5}\u{1F1FE}":["PY","PRY"],"\u{1F1F5}\u{1F1EC}":["PG","PNG"],"\u{1F1F7}\u{1F1F4}":["RO","ROU"],"\u{1F1F7}\u{1F1F8}":["RS","SRB"],"\u{1F1F7}\u{1F1EA}":["RE","REU"],"\u{1F1F7}\u{1F1FA}":["RU","RUS"],"\u{1F1F8}\u{1F1E6}":["SA","SAU"],"\u{1F1F8}\u{1F1EA}":["SE","SWE"],"\u{1F1F8}\u{1F1EC}":["SG","SGP"],"\u{1F1F8}\u{1F1EE}":["SI","SVN"],"\u{1F1F8}\u{1F1F0}":["SK","SVK"],"\u{1F1F9}\u{1F1ED}":["TH","THA"],"\u{1F1F9}\u{1F1F3}":["TN","TUN"],"\u{1F1F9}\u{1F1F7}":["TR","TUR"],"\u{1F1F9}\u{1F1FC}":["TW","TWN","CHT","HINET","ROC"],"\u{1F1FA}\u{1F1E6}":["UA","UKR"],"\u{1F1FA}\u{1F1F8}":["US","USA","LAX","SFO","SJC"],"\u{1F1FA}\u{1F1FE}":["UY","URY"],"\u{1F1FB}\u{1F1EA}":["VE","VEN"],"\u{1F1FB}\u{1F1F3}":["VN","VNM"],"\u{1F1FF}\u{1F1E6}":["ZA","ZAF","JNB"],"\u{1F1E8}\u{1F1F3}":["CN","CHN","BACK"]};function eo(e){let t={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["\u6D41\u91CF","\u65F6\u95F4","\u8FC7\u671F","Bandwidth","Expire"],"\u{1F1F8}\u{1F1F1}":["\u5E94\u6025","\u6D4B\u8BD5\u8282\u70B9"],"\u{1F1E6}\u{1F1E9}":["Andorra","\u5B89\u9053\u5C14"],"\u{1F1E6}\u{1F1EA}":["United Arab Emirates","\u963F\u8054\u914B","\u8FEA\u62DC"],"\u{1F1E6}\u{1F1EB}":["Afghanistan","\u963F\u5BCC\u6C57"],"\u{1F1E6}\u{1F1F1}":["Albania","\u963F\u5C14\u5DF4\u5C3C\u4E9A","\u963F\u723E\u5DF4\u5C3C\u4E9E"],"\u{1F1E6}\u{1F1F2}":["Armenia","\u4E9A\u7F8E\u5C3C\u4E9A"],"\u{1F1E6}\u{1F1F7}":["Argentina","\u963F\u6839\u5EF7"],"\u{1F1E6}\u{1F1F9}":["Austria","\u5965\u5730\u5229","\u5967\u5730\u5229","\u7EF4\u4E5F\u7EB3"],"\u{1F1E6}\u{1F1FA}":["Australia","\u6FB3\u5927\u5229\u4E9A","\u6FB3\u6D32","\u58A8\u5C14\u672C","\u6089\u5C3C","\u571F\u6FB3","\u4EAC\u6FB3","\u5EE3\u6FB3","\u6EEC\u6FB3","\u6CAA\u6FB3","\u5E7F\u6FB3","Sydney"],"\u{1F1E6}\u{1F1FF}":["Azerbaijan","\u963F\u585E\u62DC\u7586"],"\u{1F1E7}\u{1F1E6}":["Bosnia and Herzegovina","\u6CE2\u9ED1\u5171\u548C\u56FD","\u6CE2\u9ED1"],"\u{1F1E7}\u{1F1E9}":["Bangladesh","\u5B5F\u52A0\u62C9\u56FD","\u5B5F\u52A0\u62C9"],"\u{1F1E7}\u{1F1EA}":["Belgium","\u6BD4\u5229\u65F6","\u6BD4\u5229\u6642"],"\u{1F1E7}\u{1F1EC}":["Bulgaria","\u4FDD\u52A0\u5229\u4E9A","\u4FDD\u52A0\u5229\u4E9E"],"\u{1F1E7}\u{1F1ED}":["Bahrain","\u5DF4\u6797"],"\u{1F1E7}\u{1F1F7}":["Brazil","\u5DF4\u897F","\u5723\u4FDD\u7F57"],"\u{1F1E7}\u{1F1F3}":["Brunei","\u6587\u83B1","\u6C76\u840A"],"\u{1F1E7}\u{1F1FE}":["Belarus","\u767D\u4FC4\u7F57\u65AF","\u767D\u4FC4"],"\u{1F1E7}\u{1F1F4}":["Bolivia","\u73BB\u5229\u7EF4\u4E9A"],"\u{1F1E7}\u{1F1F9}":["Bhutan","\u4E0D\u4E39","\u4E0D\u4E39\u738B\u56FD"],"\u{1F1E8}\u{1F1E6}":["Canada","\u52A0\u62FF\u5927","\u8499\u7279\u5229\u5C14","\u6E29\u54E5\u534E","\u6953\u8449","\u67AB\u53F6","\u6ED1\u94C1\u5362","\u591A\u4F26\u591A","Waterloo","Toronto"],"\u{1F1E8}\u{1F1ED}":["Switzerland","\u745E\u58EB","\u82CF\u9ECE\u4E16","Zurich"],"\u{1F1E8}\u{1F1F1}":["Chile","\u667A\u5229"],"\u{1F1E8}\u{1F1F4}":["Colombia","\u54E5\u4F26\u6BD4\u4E9A"],"\u{1F1E8}\u{1F1F7}":["Costa Rica","\u54E5\u65AF\u8FBE\u9ECE\u52A0"],"\u{1F1E8}\u{1F1FE}":["Cyprus","\u585E\u6D66\u8DEF\u65AF"],"\u{1F1E8}\u{1F1FF}":["Czechia","\u6377\u514B"],"\u{1F1E9}\u{1F1EA}":["German","\u5FB7\u56FD","\u5FB7\u570B","\u4EAC\u5FB7","\u6EEC\u5FB7","\u5EE3\u5FB7","\u6CAA\u5FB7","\u5E7F\u5FB7","\u6CD5\u5170\u514B\u798F","Frankfurt","\u5FB7\u610F\u5FD7"],"\u{1F1E9}\u{1F1F0}":["Denmark","\u4E39\u9EA6","\u4E39\u9EA5"],"\u{1F1EA}\u{1F1E8}":["Ecuador","\u5384\u74DC\u591A\u5C14"],"\u{1F1EA}\u{1F1EA}":["Estonia","\u7231\u6C99\u5C3C\u4E9A"],"\u{1F1EA}\u{1F1EC}":["Egypt","\u57C3\u53CA"],"\u{1F1EA}\u{1F1F8}":["Spain","\u897F\u73ED\u7259"],"\u{1F1EA}\u{1F1FA}":["European Union","\u6B27\u76DF","\u6B27\u7F57\u5DF4"],"\u{1F1EB}\u{1F1EE}":["Finland","\u82AC\u5170","\u82AC\u862D","\u8D6B\u5C14\u8F9B\u57FA"],"\u{1F1EB}\u{1F1F7}":["France","\u6CD5\u56FD","\u6CD5\u570B","\u5DF4\u9ECE"],"\u{1F1EC}\u{1F1E7}":["Great Britain","\u82F1\u56FD","England","United Kingdom","\u4F26\u6566","\u82F1","London"],"\u{1F1EC}\u{1F1EA}":["Georgia","\u683C\u9C81\u5409\u4E9A","\u683C\u9B6F\u5409\u4E9E"],"\u{1F1EC}\u{1F1F7}":["Greece","\u5E0C\u814A","\u5E0C\u81D8"],"\u{1F1EC}\u{1F1FA}":["Guam","\u5173\u5C9B","\u95DC\u5CF6"],"\u{1F1EC}\u{1F1F9}":["Guatemala","\u5371\u5730\u9A6C\u62C9"],"\u{1F1ED}\u{1F1F0}":["Hongkong","\u9999\u6E2F","Hong Kong","HongKong","HONG KONG","\u6DF1\u6E2F","\u6CAA\u6E2F","\u547C\u6E2F","\u7A57\u6E2F","\u4EAC\u6E2F","\u6E2F"],"\u{1F1ED}\u{1F1F7}":["Croatia","\u514B\u7F57\u5730\u4E9A","\u514B\u7F85\u5730\u4E9E"],"\u{1F1ED}\u{1F1FA}":["Hungary","\u5308\u7259\u5229"],"\u{1F1EF}\u{1F1F4}":["Jordan","\u7EA6\u65E6"],"\u{1F1EF}\u{1F1F5}":["Japan","\u65E5\u672C","\u4E1C\u4EAC","\u5927\u962A","\u57FC\u7389","\u6CAA\u65E5","\u7A57\u65E5","\u5DDD\u65E5","\u4E2D\u65E5","\u6CC9\u65E5","\u676D\u65E5","\u6DF1\u65E5","\u8FBD\u65E5","\u5E7F\u65E5","\u5927\u5742","Osaka","Tokyo"],"\u{1F1F0}\u{1F1EA}":["Kenya","\u80AF\u5C3C\u4E9A"],"\u{1F1F0}\u{1F1EC}":["Kyrgyzstan","\u5409\u5C14\u5409\u65AF\u65AF\u5766"],"\u{1F1F0}\u{1F1ED}":["Cambodia","\u67EC\u57D4\u5BE8"],"\u{1F1F0}\u{1F1F5}":["North Korea","\u671D\u9C9C"],"\u{1F1F0}\u{1F1F7}":["Korea","\u97E9\u56FD","\u97D3\u570B","\u97E9","\u97D3","\u9996\u5C14","\u6625\u5DDD","Chuncheon","Seoul"],"\u{1F1F0}\u{1F1FF}":["Kazakhstan","\u54C8\u8428\u514B\u65AF\u5766","\u54C8\u8428\u514B"],"\u{1F1EE}\u{1F1E9}":["Indonesia","\u5370\u5C3C","\u5370\u5EA6\u5C3C\u897F\u4E9A","\u96C5\u52A0\u8FBE"],"\u{1F1EE}\u{1F1EA}":["Ireland","\u7231\u5C14\u5170","\u611B\u723E\u862D","\u90FD\u67CF\u6797"],"\u{1F1EE}\u{1F1F1}":["Israel","\u4EE5\u8272\u5217"],"\u{1F1EE}\u{1F1F2}":["Isle of Man","\u9A6C\u6069\u5C9B","\u99AC\u6069\u5CF6"],"\u{1F1EE}\u{1F1F3}":["India","\u5370\u5EA6","\u5B5F\u4E70","MFumbai","Mumbai"],"\u{1F1EE}\u{1F1F7}":["Iran","\u4F0A\u6717"],"\u{1F1EE}\u{1F1F8}":["Iceland","\u51B0\u5C9B","\u51B0\u5CF6"],"\u{1F1EE}\u{1F1F9}":["Italy","\u610F\u5927\u5229","\u7FA9\u5927\u5229","\u7C73\u5170","Nachash"],"\u{1F1F1}\u{1F1F0}":["Sri Lanka","\u65AF\u91CC\u5170\u5361","\u65AF\u91CC\u862D\u5361"],"\u{1F1F1}\u{1F1E6}":["Laos","\u8001\u631D","\u8001\u64BE"],"\u{1F1F1}\u{1F1F9}":["Lithuania","\u7ACB\u9676\u5B9B"],"\u{1F1F1}\u{1F1FA}":["Luxembourg","\u5362\u68EE\u5821"],"\u{1F1F1}\u{1F1FB}":["Latvia","\u62C9\u8131\u7EF4\u4E9A","Latvija"],"\u{1F1F2}\u{1F1E6}":["Morocco","\u6469\u6D1B\u54E5"],"\u{1F1F2}\u{1F1E9}":["Moldova","\u6469\u5C14\u591A\u74E6","\u6469\u723E\u591A\u74E6"],"\u{1F1F2}\u{1F1F2}":["Myanmar","\u7F05\u7538","\u7DEC\u7538"],"\u{1F1F3}\u{1F1EC}":["Nigeria","\u5C3C\u65E5\u5229\u4E9A","\u5C3C\u65E5\u5229\u4E9E"],"\u{1F1F2}\u{1F1F0}":["Macedonia","\u9A6C\u5176\u987F","\u99AC\u5176\u9813"],"\u{1F1F2}\u{1F1F3}":["Mongolia","\u8499\u53E4"],"\u{1F1F2}\u{1F1F4}":["Macao","\u6FB3\u95E8","\u6FB3\u9580","CTM"],"\u{1F1F2}\u{1F1F9}":["Malta","\u9A6C\u8033\u4ED6"],"\u{1F1F2}\u{1F1FD}":["Mexico","\u58A8\u897F\u54E5"],"\u{1F1F2}\u{1F1FE}":["Malaysia","\u9A6C\u6765","\u99AC\u4F86","\u5409\u9686\u5761","\u5927\u99AC"],"\u{1F1F3}\u{1F1F1}":["Netherlands","\u8377\u5170","\u8377\u862D","\u5C3C\u5FB7\u862D","\u963F\u59C6\u65AF\u7279\u4E39","Amsterdam"],"\u{1F1F3}\u{1F1F4}":["Norway","\u632A\u5A01"],"\u{1F1F3}\u{1F1F5}":["Nepal","\u5C3C\u6CCA\u5C14"],"\u{1F1F3}\u{1F1FF}":["New Zealand","\u65B0\u897F\u5170","\u65B0\u897F\u862D"],"\u{1F1F5}\u{1F1E6}":["Panama","\u5DF4\u62FF\u9A6C"],"\u{1F1F5}\u{1F1EA}":["Peru","\u79D8\u9C81","\u7955\u9B6F"],"\u{1F1F5}\u{1F1ED}":["Philippines","\u83F2\u5F8B\u5BBE","\u83F2\u5F8B\u8CD3"],"\u{1F1F5}\u{1F1F0}":["Pakistan","\u5DF4\u57FA\u65AF\u5766"],"\u{1F1F5}\u{1F1F1}":["Poland","\u6CE2\u5170","\u6CE2\u862D","\u534E\u6C99","Warsaw"],"\u{1F1F5}\u{1F1F7}":["Puerto Rico","\u6CE2\u591A\u9ECE\u5404"],"\u{1F1F5}\u{1F1F9}":["Portugal","\u8461\u8404\u7259"],"\u{1F1F5}\u{1F1EC}":["Papua New Guinea","\u5DF4\u5E03\u4E9A\u65B0\u51E0\u5185\u4E9A"],"\u{1F1F5}\u{1F1FE}":["Paraguay","\u5DF4\u62C9\u572D"],"\u{1F1F7}\u{1F1F4}":["Romania","\u7F57\u9A6C\u5C3C\u4E9A"],"\u{1F1F7}\u{1F1F8}":["Serbia","\u585E\u5C14\u7EF4\u4E9A"],"\u{1F1F7}\u{1F1EA}":["R\xE9union","\u7559\u5C3C\u6C6A","\u6CD5\u5C5E\u7559\u5C3C\u6C6A"],"\u{1F1F7}\u{1F1FA}":["Russia","\u4FC4\u7F57\u65AF","\u4FC4\u56FD","\u4FC4\u7F85\u65AF","\u4F2F\u529B","\u83AB\u65AF\u79D1","\u5723\u5F7C\u5F97\u5821","\u897F\u4F2F\u5229\u4E9A","\u4EAC\u4FC4","\u676D\u4FC4","\u5EE3\u4FC4","\u6EEC\u4FC4","\u5E7F\u4FC4","\u6CAA\u4FC4","Moscow"],"\u{1F1F8}\u{1F1E6}":["Saudi","\u6C99\u7279\u963F\u62C9\u4F2F","\u6C99\u7279","Riyadh","\u5229\u96C5\u5F97"],"\u{1F1F8}\u{1F1EA}":["Sweden","\u745E\u5178","\u65AF\u5FB7\u54E5\u5C14\u6469","Stockholm"],"\u{1F1F8}\u{1F1EC}":["Singapore","\u65B0\u52A0\u5761","\u72EE\u57CE","\u6CAA\u65B0","\u4EAC\u65B0","\u4E2D\u65B0","\u6CC9\u65B0","\u7A57\u65B0","\u6DF1\u65B0","\u676D\u65B0","\u5E7F\u65B0","\u5EE3\u65B0","\u6EEC\u65B0"],"\u{1F1F8}\u{1F1EE}":["Slovenia","\u65AF\u6D1B\u6587\u5C3C\u4E9A"],"\u{1F1F8}\u{1F1F0}":["Slovakia","\u65AF\u6D1B\u4F10\u514B"],"\u{1F1F9}\u{1F1ED}":["Thailand","\u6CF0\u56FD","\u6CF0\u570B","\u66FC\u8C37"],"\u{1F1F9}\u{1F1F3}":["Tunisia","\u7A81\u5C3C\u65AF"],"\u{1F1F9}\u{1F1F7}":["Turkey","\u571F\u8033\u5176","\u4F0A\u65AF\u5766\u5E03\u5C14","Istanbul"],"\u{1F1F9}\u{1F1FC}":["Taiwan","\u53F0\u6E7E","\u81FA\u7063","\u53F0\u7063","\u4E2D\u83EF\u6C11\u570B","\u4E2D\u534E\u6C11\u56FD","\u53F0\u5317","\u53F0\u4E2D","\u65B0\u5317","\u5F70\u5316","\u53F0","\u81FA","Taipei","Tai Wan"],"\u{1F1FA}\u{1F1E6}":["Ukraine","\u4E4C\u514B\u5170","\u70CF\u514B\u862D"],"\u{1F1FA}\u{1F1F8}":["United States","\u7F8E\u56FD","America","\u7F8E","\u4EAC\u7F8E","\u6CE2\u7279\u5170","\u8FBE\u62C9\u65AF","\u4FC4\u52D2\u5188","Oregon","\u51E4\u51F0\u57CE","\u8D39\u5229\u8499","\u7845\u8C37","\u77FD\u8C37","\u62C9\u65AF\u7EF4\u52A0\u65AF","\u6D1B\u6749\u77F6","\u5723\u4F55\u585E","\u5723\u514B\u62C9\u62C9","\u897F\u96C5\u56FE","\u829D\u52A0\u54E5","\u6CAA\u7F8E","\u54E5\u4F26\u5E03","\u7EBD\u7EA6","New York","Los Angeles","San Jose","Sillicon Valley","Michigan","\u4FC4\u4EA5\u4FC4","Ohio","\u9A6C\u7EB3\u8428\u65AF","Manassas","\u5F17\u5409\u5C3C\u4E9A","Virginia"],"\u{1F1FA}\u{1F1FE}":["Uruguay","\u4E4C\u62C9\u572D"],"\u{1F1FB}\u{1F1EA}":["Venezuela","\u59D4\u5185\u745E\u62C9"],"\u{1F1FB}\u{1F1F3}":["Vietnam","\u8D8A\u5357","\u80E1\u5FD7\u660E"],"\u{1F1FF}\u{1F1E6}":["South Africa","\u5357\u975E"],"\u{1F1E8}\u{1F1F3}":["China","\u4E2D\u56FD","\u4E2D\u570B","\u56DE\u56FD","\u56DE\u570B","\u56FD\u5185","\u570B\u5167","\u534E\u4E1C","\u534E\u897F","\u534E\u5357","\u534E\u5317","\u534E\u4E2D","\u6C5F\u82CF","\u5317\u4EAC","\u4E0A\u6D77","\u5E7F\u5DDE","\u6DF1\u5733","\u676D\u5DDE","\u5F90\u5DDE","\u9752\u5C9B","\u5B81\u6CE2","\u9547\u6C5F"]},r=e.match(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/)?.[0]||"\u{1F3F4}\u200D\u2620\uFE0F";for(let n of Object.keys(t))if(t[n].some(a=>RegExp(`${a}`,"i").test(e)))return/内蒙古/.test(e)&&["\u{1F1F2}\u{1F1F3}"].includes(n)?r="\u{1F1E8}\u{1F1F3}":r=n;for(let n of Object.keys(A0))if(A0[n].some(a=>RegExp(`(^|[^a-zA-Z])${a}([^a-zA-Z]|$)`).test(e))&&!(n=="\u{1F1E8}\u{1F1F3}"&&RegExp("(^|[^a-zA-Z])CN2([^a-zA-Z]|$)").test(e)))return r=n;return r}function b2(e){return A0[eo(e)]?.[0]}function yc(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var If=class{constructor({country,asn}={}){if(ne.env.isNode){let Reader=eval('require("@maxmind/geoip2-node")').Reader,fs=eval("require('fs')"),countryFile=country||eval("process.env.SUB_STORE_MMDB_COUNTRY_PATH"),asnFile=asn||eval("process.env.SUB_STORE_MMDB_ASN_PATH");if(countryFile&&(this.countryReader=Reader.openBuffer(fs.readFileSync(countryFile))),asnFile){if(!fs.existsSync(asnFile))throw new Error("GeoLite2 ASN MMDB does not exist");this.asnReader=Reader.openBuffer(fs.readFileSync(asnFile))}}}geoip(e){return this.countryReader?.country(e)?.country?.isoCode}ipaso(e){return this.asnReader?.asn(e)?.autonomousSystemOrganization}ipasn(e){return this.asnReader?.asn(e)?.autonomousSystemNumber}};var Pf=Un(x2()),O2=Un(Rl());async function ro({url:e,domain:t,type:r="A",timeout:n,edns:s}){let a=Pf.default.encode({type:"query",id:0,flags:Pf.default.RECURSION_DESIRED,questions:[{type:r,name:t}],additionals:[{type:"OPT",name:".",udpPayloadSize:4096,flags:0,options:[{code:"CLIENT_SUBNET",ip:s,sourcePrefixLength:rr(s)?24:56,scopePrefixLength:0}]}]}),i=await ne.http.get({url:`${e}?dns=${a.toString("base64").toString("utf-8").replace(/=/g,"")}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n});return Pf.default.decode(O2.Buffer.from(ne.env.isQX?i.bodyBytes:i.body))}var P0=Un(D0());function As(e,t,r="name"){return e.find(n=>n[r]===t)}function $I(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function RI(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var k2=[$I(),RI()];function TI(){return{type:"SINGLE",func:r=>["URL-REGEX","DEST-PORT","SRC-IP","IN-PORT","PROTOCOL","GEOSITE","GEOIP"].indexOf(r.type)!==-1?null:`${{"DOMAIN-KEYWORD":"HOST-KEYWORD","DOMAIN-SUFFIX":"HOST-SUFFIX",DOMAIN:"HOST","IP-CIDR6":"IP6-CIDR"}[r.type]||r.type},${r.content},SUB-STORE`}}function N2(){return{type:"SINGLE",func:r=>{if(["GEOSITE","GEOIP"].indexOf(r.type)!==-1)return null;let s=`${r.type},${r.content}`;return["IP-CIDR","IP-CIDR6"].includes(r.type)&&(s+=r.options?.length>0?`,${r.options.join(",")}`:""),s}}}function xI(){return{type:"SINGLE",func:r=>["SRC-IP","GEOSITE","GEOIP"].indexOf(r.type)!==-1?null:(["IP-CIDR","IP-CIDR6"].includes(r.type)&&r.options&&(r.options=r.options.filter(s=>["no-resolve"].includes(s))),N2().func(r))}}function OI(){return{type:"ALL",func:r=>{let n={"DEST-PORT":"DST-PORT","SRC-IP":"SRC-IP-CIDR","IN-PORT":"SRC-PORT"},s={payload:r.map(a=>{let i=`${n[a.type]||a.type},${a.content}`;return["IP-CIDR","IP-CIDR6","GEOIP"].includes(a.type)&&(a.options&&(a.options=a.options.filter(c=>["no-resolve"].includes(c))),i+=a.options?.length>0?`,${a.options.join(",")}`:""),i})};return Oa.dump(s)}}}var L2={QX:TI(),Surge:N2(),Loon:xI(),Clash:OI()};var kI=[[/^(DOMAIN|host|HOST)$/,"DOMAIN"],[/^(DOMAIN-KEYWORD|host-keyword|HOST-KEYWORD)$/,"DOMAIN-KEYWORD"],[/^(DOMAIN-SUFFIX|host-suffix|HOST-SUFFIX)$/,"DOMAIN-SUFFIX"],[/^USER-AGENT$/i,"USER-AGENT"],[/^PROCESS-NAME$/,"PROCESS-NAME"],[/^(DEST-PORT|DST-PORT)$/,"DST-PORT"],[/^SRC-IP(-CIDR)?$/,"SRC-IP"],[/^(IN|SRC)-PORT$/,"IN-PORT"],[/^PROTOCOL$/,"PROTOCOL"],[/^IP-CIDR$/i,"IP-CIDR"],[/^(IP-CIDR6|ip6-cidr|IP6-CIDR)$/,"IP-CIDR6"],[/^GEOIP$/i,"GEOIP"],[/^GEOSITE$/i,"GEOSITE"]];function NI(){return{name:"Universal Rule Parser",test:()=>!0,parse:n=>{let s=n.split(` `),a=[];for(let i of s)if(i=i.trim(),i.length!==0&&!/\s*#/.test(i))try{let c=i.split(",").map(v=>v.trim()),l=c[0],h=!1;for(let v of kI)if(v[0].test(l)){h=!0;let p={type:v[1],content:c[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(p.type)&&(p.options=c.slice(2)),a.push(p)}if(!h)throw new Error("Invalid rule type: "+l)}catch(c){console.log(`Failed to parse line: ${i} Reason: ${c}`)}return a}}}var U2=[NI()];var ws=function(){function e(n){for(let s of k2)try{if(s.test(n))return ne.info(`Pre-processor [${s.name}] activated`),s.parse(n)}catch(a){ne.error(`Parser [${s.name}] failed Reason: ${a}`)}return n}function t(n){n=e(n);for(let s of U2){let a;try{a=s.test(n)}catch{a=!1}if(a)return ne.info(`Rule parser [${s.name}] is activated!`),s.parse(n)}}function r(n,s){let a=L2[s];if(!a)throw new Error(`Target platform: ${s} is not supported!`);if(typeof a.type>"u"||a.type==="SINGLE")return n.map(i=>{try{return a.func(i)}catch(c){return console.log(`ERROR: cannot produce rule: ${JSON.stringify(i)} Reason: ${c}`),""}}).filter(i=>i.length>0).join(` `);if(a.type==="ALL")return a.func(n)}return{parse:t,produce:r}}();var io=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=mi(),{defaultProxy,defaultTimeout:timeout}=ne.read(rs),proxy=defaultProxy;ne.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY")),syncPlatform==="gitlab"?(this.headers={"PRIVATE-TOKEN":`${token}`,"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"},this.http=is({baseURL:"https://gitlab.com/api/v4",headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?as(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>{if(/^[45]/.test(String(e.statusCode))){let t=JSON.parse(e.body);return Promise.reject(`ERROR: ${t.message?.error??t.message}`)}else return e}}})):(this.headers={Authorization:`token ${token}`,"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"},this.http=is({baseURL:"https://api.github.com",headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?as(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(`ERROR: ${JSON.parse(e.body).message}`):e}})),this.key=key,this.syncPlatform=syncPlatform}async locate(){return this.syncPlatform==="gitlab"?this.http.get("/snippets").then(e=>{let t=JSON.parse(e.body);for(let r of t)if(r.title===this.key)return r}):this.http.get("/gists?per_page=100&page=1").then(e=>{let t=JSON.parse(e.body);ne.info(`\u83B7\u53D6\u5230\u5F53\u524D GitHub \u7528\u6237\u7684 gist: ${t.length} \u4E2A`);for(let r of t)if(r.description===this.key)return r})}async upload(e){if(Object.keys(e).length===0)return Promise.reject("\u672A\u63D0\u4F9B\u9700\u4E0A\u4F20\u7684\u6587\u4EF6");let t=await this.locate(),r=e;if(t?.id){this.syncPlatform==="gitlab"&&(t.files=t.files.reduce((a,i)=>(a[i.path]=i,a),{}));let n=[],s={...t.files};return Object.keys(r).map(a=>{s[a]?r[a].content==null||r[a].content===""?(delete s[a],n.push({action:"delete",file_path:a})):(s[a]=r[a],n.push({action:"update",file_path:a,content:r[a].content})):r[a].content==null||r[a].content===""?(delete s[a],delete r[a]):(s[a]=r[a],n.push({action:"create",file_path:a,content:r[a].content}))}),this.syncPlatform==="gitlab"?Object.keys(s).length===0?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u66F4\u65B0 snippet"):Object.keys(s).length>10?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4 snippet \u7684\u6587\u4EF6\u6570\u8D85\u8FC7 10, \u65E0\u6CD5\u66F4\u65B0 snippet"):(r=n,this.http.put({headers:{...this.headers,"Content-Type":"application/json"},url:`/snippets/${t.id}`,body:JSON.stringify({files:r})})):Object.keys(s).length===0?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u66F4\u65B0 gist"):this.http.patch({url:`/gists/${t.id}`,body:JSON.stringify({files:r})})}else return r=Object.entries(r).reduce((n,[s,a])=>(a.content!==null&&a.content!==""&&(n[s]=a),n),{}),this.syncPlatform==="gitlab"?Object.keys(r).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA snippet"):(r=Object.keys(r).map(n=>({file_path:n,content:r[n].content})),this.http.post({headers:{...this.headers,"Content-Type":"application/json"},url:"/snippets",body:JSON.stringify({title:this.key,visibility:"private",files:r})})):Object.keys(r).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA gist"):this.http.post({url:"/gists",body:JSON.stringify({description:this.key,public:!1,files:r})})}async download(e){let t=await this.locate();if(t?.id)try{let{files:r}=await this.http.get(`/gists/${t.id}`).then(s=>JSON.parse(s.body)),n=r[e].raw_url;return await this.http.get(n).then(s=>s.body)}catch(r){return Promise.reject(r)}else return Promise.reject(`\u627E\u4E0D\u5230 Sub-Store Gist (${this.key})`)}};async function so({type:e,name:t,platform:r,url:n,ua:s,content:a,mergeSources:i,ignoreFailedRemoteSub:c,ignoreFailedRemoteFile:l,produceType:h,produceOpts:v={},subscription:E,awaitCustomCache:p,$options:f,proxy:w,noCache:m}){if(r=r||"JSON",["subscription","sub"].includes(e)){let y;if(t){let I=ne.read(Xp);if(y=As(I,t),!y)throw new Error(`\u627E\u4E0D\u5230\u8BA2\u9605 ${t}`)}else if(E)y=E;else throw new Error("\u672A\u63D0\u4F9B\u8BA2\u9605\u540D\u79F0\u6216\u8BA2\u9605\u6570\u636E");let A;if(a&&!["localFirst","remoteFirst"].includes(i))A=a;else if(n){let I={};A=await Promise.all(n.split(/[\r\n]+/).map(j=>j.trim()).filter(j=>j.length).map(async j=>{try{return await Or(j,s||y.ua,void 0,w||y.proxy,void 0,p,m||y.noCache,!0)}catch(V){return I[j]=V,ne.error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${j} \u53D1\u751F\u9519\u8BEF: ${V}`),""}}));let B=y.ignoreFailedRemoteSub;if(c!=null&&c!==""&&(B=c),!B&&Object.keys(I).length>0)throw new Error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(I).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);i==="localFirst"?A.unshift(a):i==="remoteFirst"&&A.push(a)}else if(y.source==="local"&&!["localFirst","remoteFirst"].includes(y.mergeSources))A=y.content;else{let I={};A=await Promise.all(y.url.split(/[\r\n]+/).map(j=>j.trim()).filter(j=>j.length).map(async j=>{try{return await Or(j,s||y.ua,void 0,w||y.proxy,void 0,p,m||y.noCache,!0)}catch(V){return I[j]=V,ne.error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${j} \u53D1\u751F\u9519\u8BEF: ${V}`),""}}));let B=y.ignoreFailedRemoteSub;if(c!=null&&c!==""&&(B=c),!B&&Object.keys(I).length>0)throw new Error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(I).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);y.mergeSources==="localFirst"?A.unshift(y.content):y.mergeSources==="remoteFirst"&&A.push(y.content)}let b=(Array.isArray(A)?A:[A]).map(I=>dr.parse(I)).flat();if(b.forEach(I=>{I._subName=y.name,I._subDisplayName=y.displayName}),b=await dr.process(b,y.process||[],r,{[y.name]:y},f),b.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let _={};for(let I of b){if(_[I.name]){ne.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${I.name}\uFF01`,"\u8BF7\u4ED4\u7EC6\u68C0\u6D4B\u914D\u7F6E\uFF01",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"});break}_[I.name]=!0}return dr.produce(b,r,h,v)}else if(["collection","col"].includes(e)){let y=ne.read(Xp),A=ne.read(kv),b=As(A,t);if(!b)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let _=[...b.subscriptions],I=b.subscriptionTags;Array.isArray(I)&&I.length>0&&y.forEach(L=>{Array.isArray(L.tag)&&L.tag.length>0&&!_.includes(L.name)&&L.tag.some(M=>I.includes(M))&&_.push(L.name)});let B={},j={},V=0;await Promise.all(_.map(async L=>{let M=As(y,L),X=M.passThroughUA,K=M.ua;X&&(ne.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${s}`),K=s);try{ne.info(`\u6B63\u5728\u5904\u7406\u5B50\u8BA2\u9605\uFF1A${M.name}...`);let q;if(M.source==="local"&&!["localFirst","remoteFirst"].includes(M.mergeSources))q=M.content;else{let re={};if(q=await await Promise.all(M.url.split(/[\r\n]+/).map(ye=>ye.trim()).filter(ye=>ye.length).map(async ye=>{try{return await Or(ye,K,void 0,w||M.proxy||b.proxy,void 0,void 0,m||M.noCache,!0)}catch(we){return re[ye]=we,ne.error(`\u8BA2\u9605 ${M.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${ye} \u53D1\u751F\u9519\u8BEF: ${we}`),""}})),!M.ignoreFailedRemoteSub&&Object.keys(re).length>0)throw new Error(`\u8BA2\u9605 ${M.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(re).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);M.mergeSources==="localFirst"?q.unshift(M.content):M.mergeSources==="remoteFirst"&&q.push(M.content)}let Y=(Array.isArray(q)?q:[q]).map(re=>dr.parse(re)).flat();Y.forEach(re=>{re._subName=M.name,re._subDisplayName=M.displayName,re._collectionName=b.name,re._collectionDisplayName=b.displayName}),Y=await dr.process(Y,M.process||[],r,{[M.name]:M,_collection:b,$options:f}),B[L]=Y,V++,ne.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${M.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(V/_.length).toFixed(1)}% `)}catch(q){V++,j[L]=q,ne.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u4E2D\u7684\u5B50\u8BA2\u9605: ${M.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${q}\uFF01\u8FDB\u5EA6--${100*(V/_.length).toFixed(1)}%`)}}));let F=b.ignoreFailedRemoteSub;if(c!=null&&c!==""&&(F=c),!F&&Object.keys(j).length>0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u7684\u5B50\u8BA2\u9605 ${Object.keys(j).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let P=Array.prototype.concat.apply([],_.map(L=>B[L]||[]));if(P.forEach(L=>{L._collectionName=b.name,L._collectionDisplayName=b.displayName}),P=await dr.process(P,b.process||[],r,{_collection:b},f),P.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let k={};for(let L of P){if(k[L.name]){ne.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u7EC4\u5408\u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${L.name}\uFF01`,"\u8BF7\u4ED4\u7EC6\u68C0\u6D4B\u914D\u7F6E\uFF01",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"});break}k[L.name]=!0}return dr.produce(P,r,h,v)}else if(e==="rule"){let y=ne.read(Lv),A=As(y,t);if(!A)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let b=[];for(let _=0;_F.trim()).filter(F=>F.length).map(async F=>{try{return await Or(F,s||A.ua,void 0,A.proxy||w,void 0,void 0,m)}catch(P){return j[F]=P,ne.error(`\u6587\u4EF6 ${A.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${F} \u53D1\u751F\u9519\u8BEF: ${P}`),""}}));let V=A.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(V=l),!V&&Object.keys(j).length>0)throw new Error(`\u6587\u4EF6 ${A.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(j).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);i==="localFirst"?b.unshift(a):i==="remoteFirst"&&b.push(a)}else if(A.source==="local"&&!["localFirst","remoteFirst"].includes(A.mergeSources))b=A.content;else{let j={};b=await Promise.all(A.url.split(/[\r\n]+/).map(F=>F.trim()).filter(F=>F.length).map(async F=>{try{return await Or(F,s||A.ua,void 0,A.proxy||w,void 0,void 0,m)}catch(P){return j[F]=P,ne.error(`\u6587\u4EF6 ${A.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${F} \u53D1\u751F\u9519\u8BEF: ${P}`),""}}));let V=A.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(V=l),!V&&Object.keys(j).length>0)throw new Error(`\u6587\u4EF6 ${A.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(j).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);A.mergeSources==="localFirst"?b.unshift(A.content):A.mergeSources==="remoteFirst"&&b.push(A.content)}let _=(Array.isArray(b)?b:[b]).flat(),I=_.filter(j=>j!=null&&j!=="").join(` `);return(Array.isArray(A.process)&&A.process.length>0?await dr.process({$files:_,$content:I,$options:f,$file:A},A.process):{$content:I,$files:_,$options:f})?.$content??""}}var $f="2.19.18";var{isNode:H2,isQX:KI,isLoon:VI,isSurge:GI,isStash:zI,isShadowRocket:YI,isLanceX:WI,isEgern:XI,isGUIforCores:JI}=mi(),Bi="Node";H2&&(Bi="Node");KI&&(Bi="QX");VI&&(Bi="Loon");GI&&(Bi="Surge");zI&&(Bi="Stash");YI&&(Bi="ShadowRocket");XI&&(Bi="Egern");WI&&(Bi="LanceX");JI&&(Bi="GUI.for.Cores");var qa={},ZI={};try{if(typeof $environment<"u"&&(qa.env=$environment),typeof $loon<"u"&&(qa.loon=$loon),typeof $script<"u"&&(qa.script=$script),typeof $Plugin<"u"&&(qa.plugin=$Plugin),H2){qa.node={version:eval("process.version"),argv:eval("process.argv"),filename:eval("__filename"),dirname:eval("__dirname"),env:{}};let env=eval("process.env");for(let e in env)/^SUB_STORE_/.test(e)&&(qa.node.env[e]=env[e])}}catch(e){}var Cc={backend:Bi,version:$f,feature:ZI,meta:qa};function QI(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Fc(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function M2(e,t){let r=typeof t=="string"?JSON.parse(t):t;for(let n in r)if(QI(r[n]))if(n.endsWith("!")){let s=Fc(n.slice(0,-1));e[s]=r[n]}else{let s=Fc(n);e[s]||Object.assign(e,{[s]:{}}),M2(e[s],r[s])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let s=Fc(n.slice(1));e[s]||Object.assign(e,{[s]:[]}),e[s]=[...r[n],...e[s]]}else if(n.endsWith("+")){let s=Fc(n.slice(0,-1));e[s]||Object.assign(e,{[s]:[]}),e[s]=[...e[s],...r[n]]}else{let s=Fc(n);Object.assign(e,{[s]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function e9({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>Rf(e,r))}}function Rf(e,t){if(!e.operator)switch(e.proposition){case"IN":return e.value.indexOf(t[e.attr])!==-1;case"CONTAINS":return typeof t[e.attr]!="string"?!1:t[e.attr].indexOf(e.value)!==-1;case"EQUALS":return t[e.attr]===e.value;case"EXISTS":return t[e.attr]!==null||typeof t[e.attr]<"u";default:throw new Error(`Unknown proposition: ${e.proposition}`)}switch(e.operator){case"AND":return e.child.every(r=>Rf(r,t));case"OR":return e.child.some(r=>Rf(r,t));case"NOT":return!Rf(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function t9(e){return{name:"Quick Setting Operator",func:r=>{if(t(e.useless)){let s=G2().func(r);r=r.filter((a,i)=>s[i]&&a.port>0&&a.port<=65535)}return r.map(n=>(n.udp=t(e.udp,n.udp),n.tfo=t(e.tfo,n.tfo),n["fast-open"]=t(e.tfo,n["fast-open"]),n["skip-cert-verify"]=t(e.scert,n["skip-cert-verify"]),n.type==="vmess"&&(n.aead=t(e["vmess aead"],n.aead)),n))}};function t(r,n){switch(r){case"ENABLED":return!0;case"DISABLED":return!1;default:return n}}}function r9({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=yc(n.name);else{let s=eo(n.name);n.name=yc(n.name),n.name=s+" "+n.name,t=="ws"?n.name=n.name.replace(/🇹🇼/g,"\u{1F1FC}\u{1F1F8}"):t=="tw"||(n.name=n.name.replace(/🇹🇼/g,"\u{1F1E8}\u{1F1F3}"))}return n})}}function n9(e){let{action:t,template:r,link:n,position:s}={action:"rename",template:"0 1 2 3 4 5 6 7 8 9",link:"-",position:"back",...e};return{name:"Handle Duplicate Operator",func:a=>{if(t==="delete"){let i={};return a.filter(c=>i[c.name]?!1:(i[c.name]=!0,!0))}else if(t==="rename"){let i=r.split(" "),c={},l=0;a.forEach(v=>{typeof c[v.name]>"u"?c[v.name]=1:c[v.name]++,l=Math.max(c[v.name].toString().length,l)});let h={};return a.map(v=>{if(c[v.name]>1){typeof h[v.name]>"u"&&(h[v.name]=1);let E="",p=h[v.name]++,f=0;for(;p>0;)E=i[p%10]+E,p=parseInt(p/10),f++;for(;f++{switch(e){case"asc":case"desc":return t.sort((r,n)=>{let s=r.name>n.name?1:-1;return s*=e==="desc"?-1:1,s});case"random":return g9(t);default:throw new Error("Unknown sort option: "+e)}}}}function s9(e){let t=e.order||"asc",r=e.expressions;return Array.isArray(e)&&(r=e),Array.isArray(r)||(r=[]),{name:"Regex Sort Operator",func:n=>(r=r.map(s=>$0(s)),n.sort((s,a)=>{let i=j2(r,s.name),c=j2(r,a.name);return i&&!c?-1:c&&!i?1:i&&c?it.map(r=>{for(let{expr:n,now:s}of e)r.name=r.name.replace($0(n,"g"),s).trim();return r})}}function a9(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:q2(t).func}}function u9(e,t,r,n,s){return{name:"Script Operator",func:async a=>{let i=a;if(i?.$file?.type==="mihomoProfile")try{let c=Oa.safeLoad(e),l;if(i?.$content)try{l=Oa.safeLoad(i?.$content)}catch(h){ne.error(h.message??h)}if(typeof c!="object")throw new Error("patch is not an object");return i.$content=dr.yaml.safeDump(M2(l||(i?.$file?.sourceType==="none"?{}:{proxies:await so({type:i?.$file?.sourceType||"collection",name:i?.$file?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0}})}),c)),i}catch{}return await async function(){i=Tf("operator",e,r,s)(a,t,{source:n,...Cc})}(),i},nodeFunc:async a=>{let i=a;return await async function(){i=Tf("operator",`async function operator(input = []) { if (input && (input.$files || input.$content)) { let { $content, $files, $options, $file } = input if($file.type === 'mihomoProfile') { ${e} if(typeof main === 'function') { let config; if ($content) { try { config = ProxyUtils.yaml.safeLoad($content); } catch (e) { console.log(e.message ?? e); } } $content = ProxyUtils.yaml.safeDump(await main(config || ($file.sourceType === 'none' ? {} : { proxies: await produceArtifact({ type: $file.sourceType || 'collection', name: $file.sourceName, platform: 'mihomo', produceType: 'internal', produceOpts: { 'delete-underscore-fields': true } }), }))) } } else { ${e} } return { $content, $files, $options, $file } } else { let proxies = input let list = [] for await (let $server of proxies) { ${e} list.push($server) } return list } }`,r,s)(a,t,{source:n,...Cc})}(),i}}}function o9(e){let t,r;try{let n=e.split(":");r=parseInt(n[2],16);let s=parseInt(n[3],16),a=parseInt(n[4],16),i=s>>8,c=s&255,l=a>>8,h=a&255;if(t=`${i}.${c}.${l}.${h}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!rr(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){ne.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var K2={Custom:async function(e,t,r,n,s,a){let i=Jn(`CUSTOM:${a}:${e}:${t}`),c=hr.get(i);if(!r&&c)return c;let l=t==="IPv6"?"AAAA":"A",h=await ro({url:a,domain:e,type:l,timeout:n,edns:s}),{answers:v}=h;if(!Array.isArray(v)||v.length===0)throw new Error("No answers");let E=v.filter(p=>p?.type===l).map(p=>p?.data).filter(p=>p);if(E.length===0)throw new Error("No answers");return hr.set(i,E),E},Google:async function(e,t,r,n,s){let a=Jn(`GOOGLE:${e}:${t}`),i=hr.get(a);if(!r&&i)return i;let c=t==="IPv6"?"AAAA":"A",l=await ro({url:"https://8.8.4.4/dns-query",domain:e,type:c,timeout:n,edns:s}),{answers:h}=l;if(!Array.isArray(h)||h.length===0)throw new Error("No answers");let v=h.filter(E=>E?.type===c).map(E=>E?.data).filter(E=>E);if(v.length===0)throw new Error("No answers");return hr.set(a,v),v},"IP-API":async function(e,t,r,n){if(["IPv6"].includes(t))throw new Error(`\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9 IP-API \u4E0D\u652F\u6301 ${t}`);let s=Jn(`IP-API:${e}`),a=hr.get(s);if(!r&&a)return a;let i=await ne.http.get({url:`http://ip-api.com/json/${encodeURIComponent(e)}?lang=zh-CN`,timeout:n}),c=JSON.parse(i.body);if(c.status!=="success")throw new Error(`Status is ${c.status}`);if(!c.query||c.query===0)throw new Error("No answers");let l=[c.query];if(l.length===0)throw new Error("No answers");return hr.set(s,l),l},Cloudflare:async function(e,t,r,n,s){let a=Jn(`CLOUDFLARE:${e}:${t}`),i=hr.get(a);if(!r&&i)return i;let c=t==="IPv6"?"AAAA":"A",l=await ro({url:"https://1.0.0.1/dns-query",domain:e,type:c,timeout:n,edns:s}),{answers:h}=l;if(!Array.isArray(h)||h.length===0)throw new Error("No answers");let v=h.filter(E=>E?.type===c).map(E=>E?.data).filter(E=>E);if(v.length===0)throw new Error("No answers");return hr.set(a,v),v},Ali:async function(e,t,r,n,s){let a=Jn(`ALI:${e}:${t}`),i=hr.get(a);if(!r&&i)return i;let c=await ne.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${s}/24&name=${encodeURIComponent(e)}&type=${t==="IPv6"?"AAAA":"A"}&short=1`,headers:{accept:"application/dns-json"},timeout:n}),l=JSON.parse(c.body);if(!Array.isArray(l)||l.length===0)throw new Error("No answers");let h=l;if(h.length===0)throw new Error("No answers");return hr.set(a,h),h},Tencent:async function(e,t,r,n,s){let a=Jn(`TENCENT:${e}:${t}`),i=hr.get(a);if(!r&&i)return i;let l=(await ne.http.get({url:`http://119.28.28.28/d?ip=${s}&type=${t==="IPv6"?"AAAA":"A"}&dn=${encodeURIComponent(e)}`,headers:{accept:"application/dns-json"},timeout:n})).body.split(";").map(v=>v.split(",")[0]);if(l.length===0||String(l)==="0")throw new Error("No answers");let h=l;if(h.length===0)throw new Error("No answers");return hr.set(a,h),h}};function V2({provider:e,type:t,filter:r,cache:n,url:s,timeout:a,edns:i}){if(["IPv6","IP4P"].includes(t)&&["IP-API"].includes(e))throw new Error(`\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9 ${e} \u4E0D\u652F\u6301 ${t}`);let{defaultTimeout:c}=ne.read(rs),l=a||c||8e3,h=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",v=K2[e];if(!v)throw new Error(`\u627E\u4E0D\u5230\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9: ${e}`);let E=i||"223.6.6.6";if(!Ka(E))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");return ne.info(`Domain Resolver: [${t}] ${e} ${E||""} ${s||""}`),{name:"Resolve Domain Operator",func:async p=>{p.forEach((A,b)=>{!A["_no-resolve"]&&A["no-resolve"]&&(p[b]["_no-resolve"]=A["no-resolve"])});let f={},w=15,m=[...new Set(p.filter(A=>!Ka(A.server)&&!A["_no-resolve"]).map(A=>A.server))],y=Math.ceil(m.length/w);for(let A=0;A{f[_]=I,ne.info(`Successfully resolved domain: ${_} \u279F ${I}`)}).catch(I=>{ne.error(`Failed to resolve domain: ${_} with resolver [${e}]: ${I}`)}));await Promise.all(b)}return p.forEach(A=>{if(!A["_no-resolve"])if(f[A.server]){A._resolved_ips=f[A.server];let b=Array.isArray(f[A.server])?f[A.server][Math.floor(Math.random()*f[A.server].length)]:f[A.server];if(h==="IPv6"&&nr(b)){try{b=new Af.Address6(b).correctForm()}catch(_){ne.error(`Failed to parse IPv6 address: ${b}: ${_}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(b)){A._IP4P=b;let{server:_,port:I}=o9(b);_&&I?(A._domain=A.server,A.server=_,A.port=I,A.resolved=!0,A._IPv4=A.server,Ka(A._IP)||(A._IP=A.server)):A.resolved||(A.resolved=!1)}else A._domain=A.server,A.server=b,A.resolved=!0,A[`_${h}`]=A.server,Ka(A._IP)||(A._IP=A.server)}else A._domain=A.server,A.server=b,A.resolved=!0,A[`_${h}`]=A.server,Ka(A._IP)||(A._IP=A.server)}else A.resolved||(A.resolved=!1)}),p.filter(A=>r==="removeFailed"?Ka(A.server)||A["_no-resolve"]||A.resolved:r==="IPOnly"?Ka(A.server):r==="IPv4Only"?rr(A.server):r==="IPv6Only"?nr(A.server):!0)}}}function Ka(e){return rr(e)||nr(e)}V2.resolver=K2;function B0(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function G2(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!B0(t.cipher))return!1;if(t.password&&!B0(t.password))return!1;if(t.network){let r=t[`${t.network}-opts`]?.headers?.Host||t[`${t.network}-opts`]?.headers?.host;if(r=Array.isArray(r)?r:[r],r.some(n=>n&&!B0(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function c9(e){let t=e?.value||e;Array.isArray(t)||(t=[]);let r=e?.keep??!0,n={HK:"\u{1F1ED}\u{1F1F0}",TW:"\u{1F1F9}\u{1F1FC}",US:"\u{1F1FA}\u{1F1F8}",SG:"\u{1F1F8}\u{1F1EC}",JP:"\u{1F1EF}\u{1F1F5}",UK:"\u{1F1EC}\u{1F1E7}",DE:"\u{1F1E9}\u{1F1EA}",KR:"\u{1F1F0}\u{1F1F7}"};return{name:"Region Filter",func:s=>s.map(a=>{let i=eo(a.name),c=t.some(l=>n[l]===i);return r?c:!c})}}function l9({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let s=e.some(a=>$0(a).test(n.name));return t?s:!s})}}function $0(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function f9(e){let t=e?.value||e;Array.isArray(t)||(t=[]);let r=e?.keep??!0;return{name:"Type Filter",func:n=>n.map(s=>{let a=t.some(i=>s.type===i);return r?a:!a})}}function h9(e,t,r,n,s){return{name:"Script Filter",func:async a=>{let i=_f(a.length,!0);return await async function(){i=Tf("filter",e,r,s)(a,t,{source:n,...Cc})}(),i},nodeFunc:async a=>{let i=_f(a.length,!0);return await async function(){i=Tf("filter",`async function filter(input = []) { let proxies = input let list = [] const fn = async ($server) => { ${e} } for await (let $server of proxies) { list.push(await fn($server)) } return list }`,r,s)(a,t,{source:n,...Cc})}(),i}}}var xf={"Useless Filter":G2,"Region Filter":c9,"Regex Filter":l9,"Type Filter":f9,"Script Filter":h9,"Conditional Filter":e9,"Quick Setting Operator":t9,"Flag Operator":r9,"Sort Operator":i9,"Regex Sort Operator":s9,"Regex Rename Operator":q2,"Regex Delete Operator":a9,"Script Operator":u9,"Handle Duplicate Operator":n9,"Resolve Domain Operator":V2};async function p9(e,t){let r=_f(t.length,!0);try{r=await e.func(t)}catch(n){let s="",a=`${n.message??n}`;a.includes("$server is not defined")?s="":(ne.error(`Cannot apply filter ${e.name}(function filter)! Reason: ${n}`),s=`\u6267\u884C function filter \u5931\u8D25 ${a}; `);try{r=await e.nodeFunc(t)}catch(i){ne.error(`Cannot apply filter ${e.name}(shortcut script)! Reason: ${i}`);let c="",l=`${i.message??i}`;throw s&&l===a?(c="",s=`\u6267\u884C\u5931\u8D25 ${a}`):c=`\u6267\u884C\u5FEB\u6377\u8FC7\u6EE4\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u8FC7\u6EE4 ${s}${c}`)}}return t.filter((n,s)=>r[s])}async function d9(e,t){let r=m9(t);try{let n=await e.func(r);n&&(r=n)}catch(n){let s="",a=`${n.message??n}`;a.includes("$server is not defined")||a.includes("$content is not defined")||a.includes("$files is not defined")||r?.$files||r?.$content?s="":(ne.error(`Cannot apply operator ${e.name}(function operator)! Reason: ${n}`),s=`\u6267\u884C function operator \u5931\u8D25 ${a}; `);try{let i=await e.nodeFunc(r);i&&(r=i)}catch(i){ne.error(`Cannot apply operator ${e.name}(shortcut script)! Reason: ${i}`);let c="",l=`${i.message??i}`;throw s&&l===a?(c="",s=`\u6267\u884C\u5931\u8D25 ${a}`):c=`\u6267\u884C\u5FEB\u6377\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u64CD\u4F5C ${s}${c}`)}}return r}async function z2(e,t){if(e.name.indexOf("Filter")!==-1)return p9(e,t);if(e.name.indexOf("Operator")!==-1)return d9(e,t)}function g9(e){let t=e.length,r,n;for(;t!==0;)n=Math.floor(Math.random()*t),t-=1,r=e[t],e[t]=e[n],e[n]=r;return e}function m9(e){return JSON.parse(JSON.stringify(e))}function Tf(name,script,$arguments,$options){let flowUtils={getFlowField:Ju,getFlowHeaders:Ef,parseFlowHeaders:yf,flowTransfer:wc,validCheck:Sf,getRmainingDays:r2,normalizeFlowHeader:n2};return ne.env.isLoon?new Function("$arguments","$options","$substore","lodash","$persistentStore","$httpClient","$notification","ProxyUtils","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,ne,P0.default,$persistentStore,$httpClient,$notification,dr,v0,flowUtils,so,eval('typeof require !== "undefined"')?ba:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,ne,P0.default,dr,v0,flowUtils,so,eval('typeof require !== "undefined"')?ba:void 0)}var Y2=Un(D0()),We=class{constructor(t){this.proxy=t,this.output=[]}append(t){if(typeof t>"u")throw new Error("required field is missing");this.output.push(t)}appendIfPresent(t,r){se(this.proxy,r)&&this.append(t)}toString(){return this.output.join("")}};function se(e,t){let r=Y2.default.get(e,t);return typeof r<"u"&&r!==null}var v9="Surge",qn={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function ao(){return{produce:(t,r,n={})=>{switch(t.name=t.name.replace(/=|,/g,""),t.ports&&(t.ports=String(t.ports)),t.type){case"ss":return A9(t,n["include-unsupported-proxy"]);case"trojan":return w9(t);case"vmess":return E9(t,n["include-unsupported-proxy"]);case"http":return S9(t);case"direct":return b9(t);case"socks5":return C9(t);case"snell":return F9(t);case"tuic":return _9(t);case"wireguard-surge":return D9(t);case"hysteria2":return B9(t);case"ssh":return y9(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return I9(t);throw new Error(`Platform ${v9} does not support proxy type: ${t.type}`)}}}function A9(e){let t=new We(e);if(t.append(`${e.name}=${e.type},${e.server},${e.port}`),e.cipher||(e.cipher="none"),!["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","cast5-cfb","des-cfb","idea-cfb","rc2-cfb","seed-cfb","salsa20","chacha20","chacha20-ietf","none","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=qn[e["ip-version"]]||e["ip-version"];if(t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),se(e,"plugin")){if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,s=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),s&&t.append(`,shadow-tls-sni=${s}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}return t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function w9(e){let t=new We(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=qn[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),W2(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function E9(e,t){let r=new We(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=qn[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-version=${n}`,"ip-version"),r.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),W2(r,e,t),se(e,"aead")?r.append(`,vmess-aead=${e.aead}`):r.append(`,vmess-aead=${e.alterId===0}`),r.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),r.appendIfPresent(`,tls=${e.tls}`,"tls"),r.appendIfPresent(`,sni=${e.sni}`,"sni"),r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),r.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),r.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),r.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),r.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),r.appendIfPresent(`,tos=${e.tos}`,"tos"),r.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),r.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password")&&(r.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),r.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),r.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.toString()}function y9(e){let t=new We(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,private-key=${e["keystore-private-key"]}`,"keystore-private-key"),t.appendIfPresent(`,idle-timeout=${e["idle-timeout"]}`,"idle-timeout"),t.appendIfPresent(`,server-fingerprint="${e["server-fingerprint"]}"`,"server-fingerprint");let r=qn[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function S9(e){if(e.headers&&Object.keys(e.headers).length>0)throw new Error("headers is unsupported");let t=new We(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password");let n=qn[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function b9(e){let t=new We(e);t.append(`${e.name}=direct`);let n=qn[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function C9(e){let t=new We(e),r=e.tls?"socks5-tls":"socks5";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password");let n=qn[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),e.tfo&&ne.info("Option tfo is not supported by Surge, thus omitted"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function F9(e){let t=new We(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,version=${e.version}`,"version"),t.appendIfPresent(`,psk=${e.psk}`,"psk");let r=qn[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,obfs=${e["obfs-opts"]?.mode}`,"obfs-opts.mode"),t.appendIfPresent(`,obfs-host=${e["obfs-opts"]?.host}`,"obfs-opts.host"),t.appendIfPresent(`,obfs-uri=${e["obfs-opts"]?.path}`,"obfs-opts.path"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.toString()}function _9(e){let t=new We(e),r=e.type;(!e.token||e.token.length===0)&&(r="tuic-v5"),t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,uuid=${e.uuid}`,"uuid"),t.appendIfPresent(`,password="${e.password}"`,"password"),t.appendIfPresent(`,token=${e.token}`,"token"),t.appendIfPresent(`,alpn=${Array.isArray(e.alpn)?e.alpn[0]:e.alpn}`,"alpn"),se(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let n=qn[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),se(e,"tfo")?t.append(`,tfo=${e.tfo}`):se(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function I9(e){Array.isArray(e.peers)&&e.peers.length>0&&(e.server=e.peers[0].server,e.port=e.peers[0].port,e.ip=e.peers[0].ip,e.ipv6=e.peers[0].ipv6,e["public-key"]=e.peers[0]["public-key"],e["preshared-key"]=e.peers[0]["pre-shared-key"],e["allowed-ips"]=e.peers[0]["allowed-ips"],e.reserved=e.peers[0].reserved);let t=new We(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=xt(e["section-name"],e.name),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert");let r=qn[e["ip-version"]]||e["ip-version"];t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.append(` # > WireGuard Section ${e.name} [WireGuard ${e["section-name"]}] private-key = ${e["private-key"]}`),t.appendIfPresent(` self-ip = ${e.ip}`,"ip"),t.appendIfPresent(` self-ip-v6 = ${e.ipv6}`,"ipv6"),e.dns&&(Array.isArray(e.dns)&&(e.dns=e.dns.join(", ")),t.append(` dns-server = ${e.dns}`)),t.appendIfPresent(` mtu = ${e.mtu}`,"mtu"),r==="prefer-v6"&&t.append(` prefer-ipv6 = true`);let n=Array.isArray(e["allowed-ips"])?e["allowed-ips"].join(","):e["allowed-ips"],s=Array.isArray(e.reserved)?e.reserved.join("/"):e.reserved,a=e["preshared-key"]??e["pre-shared-key"];a&&(a=`,preshared-key="${a}"`);let i={"public-key":e["public-key"],"allowed-ips":n?`"${n}"`:void 0,endpoint:`${e.server}:${e.port}`,keepalive:e["persistent-keepalive"]||e.keepalive,"client-id":s,"preshared-key":a};return t.append(` peer = (${Object.keys(i).filter(c=>i[c]!=null).map(c=>`${c} = ${i[c]}`).join(", ")})`),t.toString()}function D9(e){let t=new We(e);t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert");let r=qn[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function B9(e){if(e.obfs||e["obfs-password"])throw new Error("obfs is unsupported");let t=new We(e);t.append(`${e.name}=hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),se(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let r=qn[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),se(e,"tfo")?t.append(`,tfo=${e.tfo}`):se(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),se(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function W2(e,t,r){if(se(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),se(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),se(t,"ws-opts.headers"))){let n=t["ws-opts"].headers,s=Object.keys(n).map(a=>{let i=n[a];return["Host"].includes(a)&&(i=`"${i}"`),`${a}:${i}`}).join("|");yi(s)&&e.append(`,ws-headers=${s}`)}}else if(r&&["http"].includes(t.network))ne.info(`Include Unsupported Proxy: nework ${t.network} -> tcp`);else throw new Error(`network ${t.network} is unsupported`)}function Fn(){return{type:"ALL",produce:(r,n,s={})=>{let a=r.filter(i=>s["include-unsupported-proxy"]?!0:i.type==="snell"&&String(i.version)==="4"||["juicity"].includes(i.type)?!1:!(["ss"].includes(i.type)&&!["aes-128-ctr","aes-192-ctr","aes-256-ctr","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-ccm","aes-192-ccm","aes-256-ccm","aes-128-gcm-siv","aes-256-gcm-siv","chacha20-ietf","chacha20","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","chacha8-ietf-poly1305","xchacha8-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm","2022-blake3-chacha20-poly1305","lea-128-gcm","lea-192-gcm","lea-256-gcm","rabbit128-poly1305","aegis-128l","aegis-256","aez-384","deoxys-ii-256-128","rc4-md5","none"].includes(i.cipher))).map(i=>{if(i.type==="vmess"?(se(i,"aead")&&(i.aead&&(i.alterId=0),delete i.aead),se(i,"sni")&&(i.servername=i.sni,delete i.sni),se(i,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(i.cipher)&&(i.cipher="auto")):i.type==="tuic"?(se(i,"alpn")?i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]:i.alpn=["h3"],se(i,"tfo")&&!se(i,"fast-open")&&(i["fast-open"]=i.tfo),(!i.token||i.token.length===0)&&!se(i,"version")&&(i.version=5)):i.type==="hysteria"?(se(i,"auth_str")&&!se(i,"auth-str")&&(i["auth-str"]=i.auth_str),se(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),se(i,"tfo")&&!se(i,"fast-open")&&(i["fast-open"]=i.tfo)):i.type==="wireguard"?(i.keepalive=i.keepalive??i["persistent-keepalive"],i["persistent-keepalive"]=i.keepalive,i["preshared-key"]=i["preshared-key"]??i["pre-shared-key"],i["pre-shared-key"]=i["preshared-key"]):i.type==="snell"&&i.version<3?delete i.udp:i.type==="vless"?se(i,"sni")&&(i.servername=i.sni,delete i.sni):i.type==="ss"&&se(i,"shadow-tls-password")&&!se(i,"plugin")&&(i.plugin="shadow-tls",i["plugin-opts"]={host:i["shadow-tls-sni"],password:i["shadow-tls-password"],version:i["shadow-tls-version"]},delete i["shadow-tls-password"],delete i["shadow-tls-sni"],delete i["shadow-tls-version"]),["vmess","vless"].includes(i.type)&&i.network==="http"){let c=i["http-opts"]?.path;se(i,"http-opts.path")&&!Array.isArray(c)&&(i["http-opts"].path=[c]);let l=i["http-opts"]?.headers?.Host;se(i,"http-opts.headers.Host")&&!Array.isArray(l)&&(i["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(i.type)&&i.network==="h2"){let c=i["h2-opts"]?.path;se(i,"h2-opts.path")&&Array.isArray(c)&&(i["h2-opts"].path=c[0]);let l=i["h2-opts"]?.headers?.host;se(i,"h2-opts.headers.Host")&&!Array.isArray(l)&&(i["h2-opts"].headers.host=[l])}if(i["plugin-opts"]?.tls&&se(i,"skip-cert-verify")&&(i["plugin-opts"]["skip-cert-verify"]=i["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(i.type)&&delete i.tls,i["tls-fingerprint"]&&(i.fingerprint=i["tls-fingerprint"]),delete i["tls-fingerprint"],i["underlying-proxy"]&&(i["dialer-proxy"]=i["underlying-proxy"]),delete i["underlying-proxy"],se(i,"tls")&&typeof i.tls!="boolean"&&delete i.tls,delete i.subName,delete i.collectionName,delete i.id,delete i.resolved,delete i["no-resolve"],n!=="internal"||s["delete-underscore-fields"])for(let c in i)(i[c]==null||/^_/i.test(c))&&delete i[c];return["grpc"].includes(i.network)&&i[`${i.network}-opts`]&&(delete i[`${i.network}-opts`]["_grpc-type"],delete i[`${i.network}-opts`]["_grpc-authority"]),i});return n==="internal"?a:`proxies: `+a.map(i=>" - "+JSON.stringify(i)+` `).join("")}}}var X2="SurgeMac",P9=ao();function R0(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return J2(t);default:try{return P9.produce(t,r,n)}catch{if(n.useMihomoExternal)return ne.log(`${t.name} is not supported on ${X2}, try to use Mihomo(SurgeMac - External Proxy Program) instead`),$9(t,r,n);throw new Error("Surge for macOS \u53EF\u624B\u52A8\u6307\u5B9A\u94FE\u63A5\u53C2\u6570 target=SurgeMac \u6216\u5728 \u540C\u6B65\u914D\u7F6E \u4E2D\u6307\u5B9A SurgeMac \u6765\u542F\u7528 mihomo \u652F\u63F4 Surge \u672C\u8EAB\u4E0D\u652F\u6301\u7684\u534F\u8BAE")}}}}}function J2(e){let t=new We(e);if(!e.exec||!e["local-port"])throw new Error(`${e.type}: exec and local-port are required`);return t.append(`${e.name}=external,exec="${e.exec}",local-port=${e["local-port"]}`),Array.isArray(e.args)&&e.args.map(r=>{t.append(`,args="${r}"`)}),Array.isArray(e.addresses)&&e.addresses.map(r=>{t.append(`,addresses=${r}`)}),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),se(e,"tfo")?t.append(`,tfo=${e.tfo}`):se(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function $9(e,t,r){let n=Fn().produce([e],"internal")?.[0];if(n){let s=r?.localPort||e._localPort||65535,a=!["ipv4","v4-only"].includes(e["ip-version"]),i={name:e.name,type:"external",exec:e._exec||"/usr/local/bin/mihomo","local-port":s,args:["-config",dt.encode(JSON.stringify({"mixed-port":s,ipv6:a,mode:"global",dns:{enable:!0,ipv6:a,"default-nameserver":r?.defaultNameserver||e._defaultNameserver||["180.76.76.76","52.80.52.52","119.28.28.28","223.6.6.6"],nameserver:r?.nameserver||e._nameserver||["https://doh.pub/dns-query","https://dns.alidns.com/dns-query","https://doh-pure.onedns.net/dns-query"]},proxies:[{...n,name:"proxy"}],"proxy-groups":[{name:"GLOBAL",type:"select",proxies:["proxy"]}]}))],addresses:[]};return R9(e.server)?i.addresses.push(e.server):ne.log(`Platform ${X2}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),r.localPort=s-1,J2(i)}}function R9(e){return rr(e)||nr(e)}function T0(){return{type:"ALL",produce:(r,n,s={})=>{let a=r.filter(i=>s["include-unsupported-proxy"]?!0:!(!["ss","ssr","vmess","vless","socks5","http","snell","trojan","wireguard"].includes(i.type)||i.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305"].includes(i.cipher)||i.type==="snell"&&String(i.version)==="4"||i.type==="vless"&&(typeof i.flow<"u"||i["reality-opts"]))).map(i=>{if(i.type==="vmess"?(se(i,"aead")&&(i.aead&&(i.alterId=0),delete i.aead),se(i,"sni")&&(i.servername=i.sni,delete i.sni),se(i,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(i.cipher)&&(i.cipher="auto")):i.type==="wireguard"?(i.keepalive=i.keepalive??i["persistent-keepalive"],i["persistent-keepalive"]=i.keepalive,i["preshared-key"]=i["preshared-key"]??i["pre-shared-key"],i["pre-shared-key"]=i["preshared-key"]):i.type==="snell"&&i.version<3?delete i.udp:i.type==="vless"&&se(i,"sni")&&(i.servername=i.sni,delete i.sni),["vmess","vless"].includes(i.type)&&i.network==="http"){let c=i["http-opts"]?.path;se(i,"http-opts.path")&&!Array.isArray(c)&&(i["http-opts"].path=[c]);let l=i["http-opts"]?.headers?.Host;se(i,"http-opts.headers.Host")&&!Array.isArray(l)&&(i["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(i.type)&&i.network==="h2"){let c=i["h2-opts"]?.path;se(i,"h2-opts.path")&&Array.isArray(c)&&(i["h2-opts"].path=c[0]);let l=i["h2-opts"]?.headers?.host;se(i,"h2-opts.headers.Host")&&!Array.isArray(l)&&(i["h2-opts"].headers.host=[l])}if(i["plugin-opts"]?.tls&&se(i,"skip-cert-verify")&&(i["plugin-opts"]["skip-cert-verify"]=i["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(i.type)&&delete i.tls,i["tls-fingerprint"]&&(i.fingerprint=i["tls-fingerprint"]),delete i["tls-fingerprint"],i["underlying-proxy"]&&(i["dialer-proxy"]=i["underlying-proxy"]),delete i["underlying-proxy"],se(i,"tls")&&typeof i.tls!="boolean"&&delete i.tls,delete i.subName,delete i.collectionName,delete i.id,delete i.resolved,delete i["no-resolve"],n!=="internal")for(let c in i)(i[c]==null||/^_/i.test(c))&&delete i[c];return["grpc"].includes(i.network)&&i[`${i.network}-opts`]&&(delete i[`${i.network}-opts`]["_grpc-type"],delete i[`${i.network}-opts`]["_grpc-authority"]),i});return n==="internal"?a:`proxies: `+a.map(i=>" - "+JSON.stringify(i)+` `).join("")}}}function Of(){return{type:"ALL",produce:(r,n,s={})=>{let a=r.filter(i=>!(!["ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","wireguard","hysteria","hysteria2","ssh","juicity"].includes(i.type)||i.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(i.cipher)||i.type==="snell"&&String(i.version)==="4"||(s["include-unsupported-proxy"]?i.type==="vless"&&i["reality-opts"]&&!["xtls-rprx-vision"].includes(i.flow):i.type==="vless"&&i["reality-opts"]))).map(i=>{if(i.type==="vmess"?(se(i,"aead")&&(i.aead&&(i.alterId=0),delete i.aead),se(i,"sni")&&(i.servername=i.sni,delete i.sni),se(i,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(i.cipher)&&(i.cipher="auto")):i.type==="tuic"?(se(i,"alpn")?i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]:i.alpn=["h3"],se(i,"tfo")&&!se(i,"fast-open")&&(i["fast-open"]=i.tfo,delete i.tfo),(!i.token||i.token.length===0)&&!se(i,"version")&&(i.version=5)):i.type==="hysteria"?(se(i,"auth_str")&&!se(i,"auth-str")&&(i["auth-str"]=i.auth_str),se(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),se(i,"tfo")&&!se(i,"fast-open")&&(i["fast-open"]=i.tfo,delete i.tfo),se(i,"down")&&!se(i,"down-speed")&&(i["down-speed"]=i.down,delete i.down),se(i,"up")&&!se(i,"up-speed")&&(i["up-speed"]=i.up,delete i.up),se(i,"down-speed")&&(i["down-speed"]=`${i["down-speed"]}`.match(/\d+/)?.[0]||0),se(i,"up-speed")&&(i["up-speed"]=`${i["up-speed"]}`.match(/\d+/)?.[0]||0)):i.type==="hysteria2"?(se(i,"password")&&!se(i,"auth")&&(i.auth=i.password,delete i.password),se(i,"tfo")&&!se(i,"fast-open")&&(i["fast-open"]=i.tfo,delete i.tfo),se(i,"down")&&!se(i,"down-speed")&&(i["down-speed"]=i.down,delete i.down),se(i,"up")&&!se(i,"up-speed")&&(i["up-speed"]=i.up,delete i.up),se(i,"down-speed")&&(i["down-speed"]=`${i["down-speed"]}`.match(/\d+/)?.[0]||0),se(i,"up-speed")&&(i["up-speed"]=`${i["up-speed"]}`.match(/\d+/)?.[0]||0)):i.type==="wireguard"?(i.keepalive=i.keepalive??i["persistent-keepalive"],i["persistent-keepalive"]=i.keepalive,i["preshared-key"]=i["preshared-key"]??i["pre-shared-key"],i["pre-shared-key"]=i["preshared-key"]):i.type==="snell"&&i.version<3?delete i.udp:i.type==="vless"&&se(i,"sni")&&(i.servername=i.sni,delete i.sni),["vmess","vless"].includes(i.type)&&i.network==="http"){let c=i["http-opts"]?.path;se(i,"http-opts.path")&&!Array.isArray(c)&&(i["http-opts"].path=[c]);let l=i["http-opts"]?.headers?.Host;se(i,"http-opts.headers.Host")&&!Array.isArray(l)&&(i["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(i.type)&&i.network==="h2"){let c=i["h2-opts"]?.path;se(i,"h2-opts.path")&&Array.isArray(c)&&(i["h2-opts"].path=c[0]);let l=i["h2-opts"]?.headers?.host;se(i,"h2-opts.headers.Host")&&!Array.isArray(l)&&(i["h2-opts"].headers.host=[l])}if(i["plugin-opts"]?.tls&&se(i,"skip-cert-verify")&&(i["plugin-opts"]["skip-cert-verify"]=i["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(i.type)&&delete i.tls,i["tls-fingerprint"]&&(i["server-cert-fingerprint"]=i["tls-fingerprint"]),delete i["tls-fingerprint"],i["underlying-proxy"]&&(i["dialer-proxy"]=i["underlying-proxy"]),delete i["underlying-proxy"],se(i,"tls")&&typeof i.tls!="boolean"&&delete i.tls,i["test-url"]&&(i["benchmark-url"]=i["test-url"],delete i["test-url"]),i["test-timeout"]&&(i["benchmark-timeout"]=i["test-timeout"],delete i["test-timeout"]),delete i.subName,delete i.collectionName,delete i.id,delete i.resolved,delete i["no-resolve"],n!=="internal")for(let c in i)(i[c]==null||/^_/i.test(c))&&delete i[c];return["grpc"].includes(i.network)&&i[`${i.network}-opts`]&&(delete i[`${i.network}-opts`]["_grpc-type"],delete i[`${i.network}-opts`]["_grpc-authority"]),i});return n==="internal"?a:`proxies: `+a.map(i=>" - "+JSON.stringify(i)+` `).join("")}}}var T9="Loon",Es={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function x0(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return x9(t);case"ssr":return O9(t);case"trojan":return k9(t);case"vmess":return N9(t,n["include-unsupported-proxy"]);case"vless":return L9(t,n["include-unsupported-proxy"]);case"http":return U9(t);case"socks5":return H9(t);case"wireguard":return j9(t);case"hysteria2":return M9(t)}throw new Error(`Platform ${T9} does not support proxy type: ${t.type}`)}}}function x9(e){let t=new We(e);if(!["rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","salsa20","chacha20","chacha20-ietf","aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(t.append(`${e.name}=shadowsocks,${e.server},${e.port},${e.cipher},"${e.password}"`),se(e,"plugin")){if(e.plugin==="obfs")t.append(`,obfs-name=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(se(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,s=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),s&&t.append(`,shadow-tls-sni=${s}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true");let r=Es[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function O9(e,t){let r=new We(e);if(r.append(`${e.name}=shadowsocksr,${e.server},${e.port},${e.cipher},"${e.password}"`),r.append(`,protocol=${e.protocol}`),r.appendIfPresent(`,protocol-param=${e["protocol-param"]}`,"protocol-param"),r.appendIfPresent(`,obfs=${e.obfs}`,"obfs"),r.appendIfPresent(`,obfs-param=${e["obfs-param"]}`,"obfs-param"),se(e,"shadow-tls-password"))r.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),r.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),r.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),r.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let s=e["plugin-opts"].password,a=e["plugin-opts"].host,i=e["plugin-opts"].version;if(s){if(r.append(`,shadow-tls-password=${s}`),a&&r.append(`,shadow-tls-sni=${a}`),i){if(i<2)throw new Error(`shadow-tls version ${i} is not supported`);r.append(`,shadow-tls-version=${i}`)}r.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}r.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&r.append(",udp=true");let n=Es[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function k9(e){let t=new We(e);if(t.append(`${e.name}=trojan,${e.server},${e.port},"${e.password}"`),e.network==="tcp"&&delete e.network,se(e,"network"))if(e.network==="ws")t.append(",transport=ws"),t.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),t.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true");let r=Es[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function N9(e,t){if(!t&&e["reality-opts"])throw new Error("VMess REALITY is not supported");let r=!1;t&&e["reality-opts"]&&(r=!0);let n=new We(e);if(n.append(`${e.name}=vmess,${e.server},${e.port},${e.cipher},"${e.uuid}"`),e.network==="tcp"&&delete e.network,se(e,"network"))if(e.network==="ws")n.append(",transport=ws"),n.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),n.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){n.append(",transport=http");let a=e["http-opts"]?.path,i=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(a)?a[0]:a}`,"http-opts.path"),n.appendIfPresent(`,host=${Array.isArray(i)?i[0]:i}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else n.append(",transport=tcp");n.appendIfPresent(`,over-tls=${e.tls}`,"tls"),n.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r?(n.appendIfPresent(`,sni=${e.sni}`,"sni"),n.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),n.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(n.appendIfPresent(`,tls-name=${e.sni}`,"sni"),n.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),se(e,"aead")?n.append(",alterId=0"):n.append(`,alterId=${e.alterId}`),n.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&n.append(",udp=true");let s=Es[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${s}`,"ip-version"),n.toString()}function L9(e,t){if(!t&&(typeof e.flow<"u"||e["reality-opts"]))throw new Error("VLESS XTLS/REALITY is not supported");let r=!1,n=!1;if(t&&(e["reality-opts"]&&(n=!0),typeof e.flow<"u"))if(["xtls-rprx-vision"].includes(e.flow))r=!0;else throw new Error(`VLESS flow(${e.flow}) is not supported`);let s=new We(e);if(s.append(`${e.name}=vless,${e.server},${e.port},"${e.uuid}"`),e.network==="tcp"&&delete e.network,se(e,"network"))if(e.network==="ws")s.append(",transport=ws"),s.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),s.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){s.append(",transport=http");let i=e["http-opts"]?.path,c=e["http-opts"]?.headers?.Host;s.appendIfPresent(`,path=${Array.isArray(i)?i[0]:i}`,"http-opts.path"),s.appendIfPresent(`,host=${Array.isArray(c)?c[0]:c}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else s.append(",transport=tcp");s.appendIfPresent(`,over-tls=${e.tls}`,"tls"),s.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r&&s.appendIfPresent(`,flow=${e.flow}`,"flow"),n?(s.appendIfPresent(`,sni=${e.sni}`,"sni"),s.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),s.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(s.appendIfPresent(`,tls-name=${e.sni}`,"sni"),s.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),s.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),s.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&s.append(",udp=true");let a=Es[e["ip-version"]]||e["ip-version"];return s.appendIfPresent(`,ip-mode=${a}`,"ip-version"),s.toString()}function U9(e){let t=new We(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo");let n=Es[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function H9(e){let t=new We(e);t.append(`${e.name}=socks5,${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,over-tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true");let r=Es[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function j9(e){Array.isArray(e.peers)&&e.peers.length>0&&(e.server=e.peers[0].server,e.port=e.peers[0].port,e.ip=e.peers[0].ip,e.ipv6=e.peers[0].ipv6,e["public-key"]=e.peers[0]["public-key"],e["preshared-key"]=e.peers[0]["pre-shared-key"],e["allowed-ips"]=e.peers[0]["allowed-ips"],e.reserved=e.peers[0].reserved);let t=new We(e);if(t.append(`${e.name}=wireguard`),t.appendIfPresent(`,interface-ip=${e.ip}`,"ip"),t.appendIfPresent(`,interface-ipv6=${e.ipv6}`,"ipv6"),t.appendIfPresent(`,private-key="${e["private-key"]}"`,"private-key"),t.appendIfPresent(`,mtu=${e.mtu}`,"mtu"),e.dns&&Array.isArray(e.dns)){e.dnsv6=e.dns.find(c=>nr(c));let i=e.dns.find(c=>rr(c));i||(i=e.dns.find(c=>!rr(c)&&!nr(c))),e.dns=i}t.appendIfPresent(`,dns=${e.dns}`,"dns"),t.appendIfPresent(`,dnsv6=${e.dnsv6}`,"dnsv6"),t.appendIfPresent(`,keepalive=${e["persistent-keepalive"]}`,"persistent-keepalive"),t.appendIfPresent(`,keepalive=${e.keepalive}`,"keepalive");let r=Array.isArray(e["allowed-ips"])?e["allowed-ips"].join(","):e["allowed-ips"],n=Array.isArray(e.reserved)?e.reserved.join(","):e.reserved;n&&(n=`,reserved=[${n}]`);let s=e["preshared-key"]??e["pre-shared-key"];s&&(s=`,preshared-key="${s}"`),t.append(`,peers=[{public-key="${e["public-key"]}",allowed-ips="${r??"0.0.0.0/0,::/0"}",endpoint=${e.server}:${e.port}${n??""}${s??""}}]`);let a=Es[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${a}`,"ip-version"),t.toString()}function M9(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new We(e);t.append(`${e.name}=Hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),e["obfs-password"]&&e.obfs=="salamander"&&t.append(`,salamander-password=${e["obfs-password"]}`),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn");let r=Es[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function uo(){return{type:"SINGLE",produce:r=>{let n="";delete r.subName,delete r.collectionName,delete r.id,delete r.resolved,delete r["no-resolve"];for(let s in r)(r[s]==null||/^_/i.test(s))&&delete r[s];switch(["trojan","tuic","hysteria","hysteria2","juicity"].includes(r.type)&&delete r.tls,!["vmess"].includes(r.type)&&r.server&&nr(r.server)&&(r.server=`[${r.server}]`),r.type){case"socks5":n=`socks://${encodeURIComponent(dt.encode(`${r.username}:${r.password}`))}@${r.server}:${r.port}#${r.name}`;break;case"ss":let s=`${r.cipher}:${r.password}`;if(n=`ss://${r.cipher?.startsWith("2022-blake3-")?`${encodeURIComponent(r.cipher)}:${encodeURIComponent(r.password)}`:dt.encode(s)}@${r.server}:${r.port}${r.plugin?"/":""}`,r.plugin){n+="?plugin=";let oe=r["plugin-opts"];switch(r.plugin){case"obfs":n+=encodeURIComponent(`simple-obfs;obfs=${oe.mode}${oe.host?";obfs-host="+oe.host:""}`);break;case"v2ray-plugin":n+=encodeURIComponent(`v2ray-plugin;obfs=${oe.mode}${oe.host?";obfs-host"+oe.host:""}${oe.tls?";tls":""}`);break;case"shadow-tls":n+=encodeURIComponent(`shadow-tls;host=${oe.host};password=${oe.password};version=${oe.version}`);break;default:throw new Error(`Unsupported plugin option: ${r.plugin}`)}}r["udp-over-tcp"]&&(n=`${n}${r.plugin?"&":"?"}uot=1`),r.tfo&&(n=`${n}${r.plugin||r["udp-over-tcp"]?"&":"?"}tfo=1`),n+=`#${encodeURIComponent(r.name)}`;break;case"ssr":n=`${r.server}:${r.port}:${r.protocol}:${r.cipher}:${r.obfs}:${dt.encode(r.password)}/`,n+=`?remarks=${dt.encode(r.name)}${r["obfs-param"]?"&obfsparam="+dt.encode(r["obfs-param"]):""}${r["protocol-param"]?"&protocolparam="+dt.encode(r["protocol-param"]):""}`,n="ssr://"+dt.encode(n);break;case"vmess":let a="",i=r.network||"tcp";if(r.network==="http"?(i="tcp",a="http"):r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(i="httpupgrade"),n={v:"2",ps:r.name,add:r.server,port:r.port,id:r.uuid,type:a,aid:r.alterId||0,net:i,tls:r.tls?"tls":""},r.tls&&r.sni&&(n.sni=r.sni),r.network){let oe=r[`${r.network}-opts`]?.path,Fe=r[`${r.network}-opts`]?.headers?.Host;oe&&(n.path=Array.isArray(oe)?oe[0]:oe),Fe&&(n.host=Array.isArray(Fe)?Fe[0]:Fe),["grpc"].includes(r.network)&&(n.path=r[`${r.network}-opts`]?.["grpc-service-name"],n.type=r[`${r.network}-opts`]?.["_grpc-type"]||"gun",n.host=r[`${r.network}-opts`]?.["_grpc-authority"])}n="vmess://"+dt.encode(JSON.stringify(n));break;case"vless":let c="none",l=r["reality-opts"],h="",v="",E="";if(l){c="reality";let oe=r["reality-opts"]?.["public-key"];oe&&(v=`&pbk=${encodeURIComponent(oe)}`);let Fe=r["reality-opts"]?.["short-id"];Fe&&(h=`&sid=${encodeURIComponent(Fe)}`);let Oe=r["reality-opts"]?.["_spider-x"];Oe&&(E=`&spx=${encodeURIComponent(Oe)}`)}else r.tls&&(c="tls");let p="";r.alpn&&(p=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let f="";r["skip-cert-verify"]&&(f="&allowInsecure=1");let w="";r.sni&&(w=`&sni=${encodeURIComponent(r.sni)}`);let m="";r["client-fingerprint"]&&(m=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let y="";r.flow&&(y=`&flow=${encodeURIComponent(r.flow)}`);let A="";r._extra&&(A=`&extra=${encodeURIComponent(r._extra)}`);let b="";r._mode&&(b=`&mode=${encodeURIComponent(r._mode)}`);let _=r.network;r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(_="httpupgrade");let I=`&type=${encodeURIComponent(_)}`;if(["grpc"].includes(r.network)){I+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`;let oe=r[`${r.network}-opts`]?.["_grpc-authority"];oe&&(I+=`&authority=${encodeURIComponent(oe)}`)}let B=r[`${r.network}-opts`]?.[`${r.network}-service-name`],j=r[`${r.network}-opts`]?.path,V=r[`${r.network}-opts`]?.headers?.Host;j&&(I+=`&path=${encodeURIComponent(Array.isArray(j)?j[0]:j)}`),V&&(I+=`&host=${encodeURIComponent(Array.isArray(V)?V[0]:V)}`),B&&(I+=`&serviceName=${encodeURIComponent(B)}`),r.network==="kcp"&&(r.seed&&(I+=`&seed=${encodeURIComponent(r.seed)}`),r.headerType&&(I+=`&headerType=${encodeURIComponent(r.headerType)}`)),n=`vless://${r.uuid}@${r.server}:${r.port}?security=${encodeURIComponent(c)}${I}${p}${f}${w}${m}${y}${h}${E}${v}${b}${A}#${encodeURIComponent(r.name)}`;break;case"trojan":let F="";if(r.network){let oe=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(oe="httpupgrade"),F=`&type=${encodeURIComponent(oe)}`,["grpc"].includes(r.network)){let ir=r[`${r.network}-opts`]?.[`${r.network}-service-name`],Ft=r[`${r.network}-opts`]?.["_grpc-authority"];ir&&(F+=`&serviceName=${encodeURIComponent(ir)}`),Ft&&(F+=`&authority=${encodeURIComponent(Ft)}`),F+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let Fe=r[`${r.network}-opts`]?.path,Oe=r[`${r.network}-opts`]?.headers?.Host;Fe&&(F+=`&path=${encodeURIComponent(Array.isArray(Fe)?Fe[0]:Fe)}`),Oe&&(F+=`&host=${encodeURIComponent(Array.isArray(Oe)?Oe[0]:Oe)}`)}let P="";r["client-fingerprint"]&&(P=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let k="";r.alpn&&(k=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let L=r["reality-opts"],M="",X="",K="",q="",Y="",re="";if(L){q="&security=reality";let oe=r["reality-opts"]?.["public-key"];oe&&(X=`&pbk=${encodeURIComponent(oe)}`);let Fe=r["reality-opts"]?.["short-id"];Fe&&(M=`&sid=${encodeURIComponent(Fe)}`);let Oe=r["reality-opts"]?.["_spider-x"];Oe&&(K=`&spx=${encodeURIComponent(Oe)}`),r._extra&&(re=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(Y=`&mode=${encodeURIComponent(r._mode)}`)}n=`trojan://${r.password}@${r.server}:${r.port}?sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}${F}${k}${P}${q}${M}${X}${K}${Y}${re}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let ye=[];r["hop-interval"]&&ye.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&ye.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&ye.push("insecure=1"),r.obfs&&(ye.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&ye.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&ye.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&ye.push(`mport=${r.ports}`),r["tls-fingerprint"]&&ye.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&ye.push("fastopen=1"),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${ye.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let we=[];Object.keys(r).forEach(oe=>{if(!["name","type","server","port"].includes(oe)){let Fe=oe.replace(/-/,"_");["alpn"].includes(oe)?r[oe]&&we.push(`${Fe}=${encodeURIComponent(Array.isArray(r[oe])?r[oe][0]:r[oe])}`):["skip-cert-verify"].includes(oe)?r[oe]&&we.push("insecure=1"):["tfo","fast-open"].includes(oe)?r[oe]&&!we.includes("fastopen=1")&&we.push("fastopen=1"):["ports"].includes(oe)?we.push(`mport=${r[oe]}`):["auth-str"].includes(oe)?we.push(`auth=${r[oe]}`):["up"].includes(oe)?we.push(`upmbps=${r[oe]}`):["down"].includes(oe)?we.push(`downmbps=${r[oe]}`):["_obfs"].includes(oe)?we.push(`obfs=${r[oe]}`):["obfs"].includes(oe)?we.push(`obfsParam=${r[oe]}`):["sni"].includes(oe)?we.push(`peer=${r[oe]}`):r[oe]&&we.push(`${Fe}=${encodeURIComponent(r[oe])}`)}}),n=`hysteria://${r.server}:${r.port}?${we.join("&")}#${encodeURIComponent(r.name)}`;break;case"tuic":if(!r.token||r.token.length===0){let oe=[];Object.keys(r).forEach(Fe=>{if(!["name","type","uuid","password","server","port","tls"].includes(Fe)){let Oe=Fe.replace(/-/,"_");["alpn"].includes(Fe)?r[Fe]&&oe.push(`${Oe}=${encodeURIComponent(Array.isArray(r[Fe])?r[Fe][0]:r[Fe])}`):["skip-cert-verify"].includes(Fe)?r[Fe]&&oe.push("allow_insecure=1"):["tfo","fast-open"].includes(Fe)?r[Fe]&&!oe.includes("fast_open=1")&&oe.push("fast_open=1"):["disable-sni","reduce-rtt"].includes(Fe)&&r[Fe]?oe.push(`${Oe.replace(/-/g,"_")}=1`):r[Fe]&&oe.push(`${Oe.replace(/-/g,"_")}=${encodeURIComponent(r[Fe])}`)}}),n=`tuic://${encodeURIComponent(r.uuid)}:${encodeURIComponent(r.password)}@${r.server}:${r.port}?${oe.join("&")}#${encodeURIComponent(r.name)}`}break;case"anytls":let Be=[];Object.keys(r).forEach(oe=>{if(!["name","type","password","server","port","tls"].includes(oe)){let Fe=oe.replace(/-/,"_");["alpn"].includes(oe)?r[oe]&&Be.push(`${Fe}=${encodeURIComponent(Array.isArray(r[oe])?r[oe][0]:r[oe])}`):["skip-cert-verify"].includes(oe)?r[oe]&&Be.push("insecure=1"):r[oe]&&Be.push(`${Fe.replace(/-/g,"_")}=${encodeURIComponent(r[oe])}`)}}),n=`anytls://${encodeURIComponent(r.password)}@${r.server}:${r.port}/?${Be.join("&")}#${encodeURIComponent(r.name)}`;break;case"wireguard":let He=[];Object.keys(r).forEach(oe=>{["name","type","server","port","ip","ipv6","private-key"].includes(oe)||(["public-key"].includes(oe)?He.push(`publickey=${r[oe]}`):["udp"].includes(oe)?r[oe]&&He.push(`${oe}=1`):r[oe]&&He.push(`${oe}=${encodeURIComponent(r[oe])}`))}),r.ip&&r.ipv6?He.push(`address=${r.ip}/32,${r.ipv6}/128`):r.ip?He.push(`address=${r.ip}/32`):r.ipv6&&He.push(`address=${r.ipv6}/128`),n=`wireguard://${encodeURIComponent(r["private-key"])}@${r.server}:${r.port}/?${He.join("&")}#${encodeURIComponent(r.name)}`;break}return n}}}var q9=uo();function _c(){return{type:"ALL",produce:r=>{let n=[];return r.map(s=>{try{n.push(q9.produce(s))}catch(a){ne.error(`Cannot produce proxy: ${JSON.stringify(s,null,2)} Reason: ${a}`)}}),dt.encode(n.join(` `))}}}var K9="QX";function Ic(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return V9(t,n["include-unsupported-proxy"]);case"ssr":return G9(t);case"trojan":return z9(t);case"vmess":return Y9(t);case"http":return X9(t);case"socks5":return J9(t);case"vless":return W9(t)}throw new Error(`Platform ${K9} does not support proxy type: ${t.type}`)}}}function V9(e,t){let r=new We(e),n=r.append.bind(r),s=r.appendIfPresent.bind(r);if(e.cipher||(e.cipher="none"),!["none","rc4-md5","rc4-md5-6","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","cast5-cfb","des-cfb","rc2-cfb","salsa20","chacha20","chacha20-ietf","aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305",...t?["2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"]:[]].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(n(`shadowsocks=${e.server}:${e.port}`),n(`,method=${e.cipher}`),n(`,password=${e.password}`),_n(e)&&(e.tls=!0),se(e,"plugin")){if(e.plugin==="obfs"){let a=e["plugin-opts"];n(`,obfs=${a.mode}`)}else if(e.plugin==="v2ray-plugin"&&e["plugin-opts"].mode==="websocket")e["plugin-opts"].tls?n(",obfs=wss"):n(",obfs=ws");else throw new Error("plugin is not supported");s(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),s(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path")}return _n(e)&&(s(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),s(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),s(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),s(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),s(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),s(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),s(`,tls-host=${e.sni}`,"sni")),s(`,fast-open=${e.tfo}`,"tfo"),s(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),n(`,tag=${e.name}`),r.toString()}function G9(e){let t=new We(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);return r(`shadowsocks=${e.server}:${e.port}`),r(`,method=${e.cipher}`),r(`,password=${e.password}`),r(`,ssr-protocol=${e.protocol}`),n(`,ssr-protocol-param=${e["protocol-param"]}`,"protocol-param"),n(`,obfs=${e.obfs}`,"obfs"),n(`,obfs-host=${e["obfs-param"]}`,"obfs-param"),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function z9(e){let t=new We(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`trojan=${e.server}:${e.port}`),r(`,password=${e.password}`),se(e,"network"))if(e.network==="ws")_n(e)?r(",obfs=wss"):r(",obfs=ws"),n(`,obfs-uri=${e["ws-opts"]?.path}`,"ws-opts.path"),n(`,obfs-host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);return e.network!=="ws"&&_n(e)&&r(",over-tls=true"),_n(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function Y9(e){let t=new We(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);r(`vmess=${e.server}:${e.port}`);let s;if(e.cipher==="auto"?s="chacha20-ietf-poly1305":s=e.cipher,r(`,method=${s}`),r(`,password=${e.uuid}`),_n(e)&&(e.tls=!0),se(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,i=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(i)?i[0]:i}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return _n(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),se(e,"aead")?r(`,aead=${e.aead}`):r(`,aead=${e.alterId===0}`),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function W9(e){if(typeof e.flow<"u"||e["reality-opts"])throw new Error("VLESS XTLS/REALITY is not supported");let t=new We(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`vless=${e.server}:${e.port}`),r(",method=none"),r(`,password=${e.uuid}`),_n(e)&&(e.tls=!0),se(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,i=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(i)?i[0]:i}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return _n(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function X9(e){let t=new We(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);return r(`http=${e.server}:${e.port}`),n(`,username=${e.username}`,"username"),n(`,password=${e.password}`,"password"),_n(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),_n(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function J9(e){let t=new We(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);return r(`socks5=${e.server}:${e.port}`),n(`,username=${e.username}`,"username"),n(`,password=${e.password}`,"password"),_n(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),_n(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function _n(e){return e.tls}function Dc(){return{type:"ALL",produce:(r,n,s={})=>{let a=r.filter(i=>s["include-unsupported-proxy"]?!0:i.type==="snell"&&String(i.version)==="4"?!1:!["mieru","anytls"].includes(i.type)).map(i=>{if(i.type==="vmess"?(se(i,"aead")&&(i.aead&&(i.alterId=0),delete i.aead),se(i,"sni")&&(i.servername=i.sni,delete i.sni),se(i,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(i.cipher)&&(i.cipher="auto")):i.type==="tuic"?(se(i,"alpn")?i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]:i.alpn=["h3"],se(i,"tfo")&&!se(i,"fast-open")&&(i["fast-open"]=i.tfo),(!i.token||i.token.length===0)&&!se(i,"version")&&(i.version=5)):i.type==="hysteria"?(se(i,"auth_str")&&!se(i,"auth-str")&&(i["auth-str"]=i.auth_str),se(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),se(i,"tfo")&&!se(i,"fast-open")&&(i["fast-open"]=i.tfo)):i.type==="hysteria2"?(i["obfs-password"]&&i.obfs=="salamander"&&(i.obfs=i["obfs-password"],delete i["obfs-password"]),se(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),se(i,"tfo")&&!se(i,"fast-open")&&(i["fast-open"]=i.tfo)):i.type==="wireguard"?(i.keepalive=i.keepalive??i["persistent-keepalive"],i["persistent-keepalive"]=i.keepalive,i["preshared-key"]=i["preshared-key"]??i["pre-shared-key"],i["pre-shared-key"]=i["preshared-key"]):i.type==="snell"&&i.version<3?delete i.udp:i.type==="vless"?se(i,"sni")&&(i.servername=i.sni,delete i.sni):i.type==="ss"&&se(i,"shadow-tls-password")&&!se(i,"plugin")&&(i.plugin="shadow-tls",i["plugin-opts"]={host:i["shadow-tls-sni"],password:i["shadow-tls-password"],version:i["shadow-tls-version"]},delete i["shadow-tls-password"],delete i["shadow-tls-sni"],delete i["shadow-tls-version"]),["vmess","vless"].includes(i.type)&&i.network==="http"){let c=i["http-opts"]?.path;se(i,"http-opts.path")&&!Array.isArray(c)&&(i["http-opts"].path=[c]);let l=i["http-opts"]?.headers?.Host;se(i,"http-opts.headers.Host")&&!Array.isArray(l)&&(i["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(i.type)&&i.network==="h2"){let c=i["h2-opts"]?.path;se(i,"h2-opts.path")&&Array.isArray(c)&&(i["h2-opts"].path=c[0]);let l=i["h2-opts"]?.headers?.host;se(i,"h2-opts.headers.Host")&&!Array.isArray(l)&&(i["h2-opts"].headers.host=[l])}if(i["plugin-opts"]?.tls&&se(i,"skip-cert-verify")&&(i["plugin-opts"]["skip-cert-verify"]=i["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(i.type)&&delete i.tls,i["tls-fingerprint"]&&(i.fingerprint=i["tls-fingerprint"]),delete i["tls-fingerprint"],i["underlying-proxy"]&&(i["dialer-proxy"]=i["underlying-proxy"]),delete i["underlying-proxy"],se(i,"tls")&&typeof i.tls!="boolean"&&delete i.tls,delete i.subName,delete i.collectionName,delete i.id,delete i.resolved,delete i["no-resolve"],n!=="internal")for(let c in i)(i[c]==null||/^_/i.test(c))&&delete i[c];return["grpc"].includes(i.network)&&i[`${i.network}-opts`]&&(delete i[`${i.network}-opts`]["_grpc-type"],delete i[`${i.network}-opts`]["_grpc-authority"]),i});return n==="internal"?a:`proxies: `+a.map(i=>" - "+JSON.stringify(i)+` `).join("")}}}var Z9="Surfboard";function kf(){return{produce:t=>{switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return Q9(t);case"trojan":return eD(t);case"vmess":return tD(t);case"http":return rD(t);case"socks5":return nD(t);case"wireguard-surge":return iD(t)}throw new Error(`Platform ${Z9} does not support proxy type: ${t.type}`)}}}function Q9(e){let t=new We(e);if(t.append(`${e.name}=${e.type},${e.server},${e.port}`),!["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","salsa20","chacha20","chacha20-ietf"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password=${e.password}`,"password"),se(e,"plugin"))if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else throw new Error(`plugin ${e.plugin} is not supported`);return t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function eD(e){let t=new We(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),Z2(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function tD(e){let t=new We(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),Z2(t,e),se(e,"aead")?t.append(`,vmess-aead=${e.aead}`):t.append(`,vmess-aead=${e.alterId===0}`),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function rD(e){let t=new We(e),r=e.tls?"https":"http";return t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,${e.password}`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function nD(e){let t=new We(e),r=e.tls?"socks5-tls":"socks5";return t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,${e.password}`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function iD(e){let t=new We(e);return t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.toString()}function Z2(e,t){if(se(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),se(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),se(t,"ws-opts.headers"))){let r=t["ws-opts"].headers,n=Object.keys(r).map(s=>{let a=r[s];return["Host"].includes(s)&&(a=`"${a}"`),`${s}:${a}`}).join("|");yi(n)&&e.append(`,ws-headers=${n}`)}}else throw new Error(`network ${t.network} is unsupported`)}var ln=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},ys=(e,t)=>{["tcp","udp"].includes(e._network)&&(t.network=e._network)},In=(e,t)=>{t.tcp_fast_open=!1,e.tfo&&(t.tcp_fast_open=!0),e.tcp_fast_open&&(t.tcp_fast_open=!0),e["tcp-fast-open"]&&(t.tcp_fast_open=!0),t.tcp_fast_open||delete t.tcp_fast_open},Pi=(e,t)=>{!e||!e.enabled||(t.multiplex={enabled:!0},t.multiplex.protocol=e.protocol,e["max-connections"]&&(t.multiplex.max_connections=parseInt(`${e["max-connections"]}`,10)),e["max-streams"]&&(t.multiplex.max_streams=parseInt(`${e["max-streams"]}`,10)),e["min-streams"]&&(t.multiplex.min_streams=parseInt(`${e["min-streams"]}`,10)),e.padding&&(t.multiplex.padding=!0))},O0=(e,t)=>{let r={type:"ws",headers:{}};if(e["ws-opts"]){let{path:n="",headers:s={}}=e["ws-opts"];if(n!==""&&(r.path=`${n}`),Object.keys(s).length>0){let a={};for(let c of Object.keys(s)){let l=s[c];l!==""&&(Array.isArray(l)||(l=[`${l}`]),l.length>0&&(a[c]=l))}let{Host:i}=a;if(i.length===1)for(let c of`Host:${i[0]}`.split(` `)){let[l,h]=c.split(":");h.trim()!==""&&(a[l.trim()]=h.trim().split(","))}r.headers=a}}if(e["ws-headers"]){let n={};for(let a of Object.keys(e["ws-headers"])){let i=e["ws-headers"][a];i!==""&&(Array.isArray(i)||(i=[`${i}`]),i.length>0&&(n[a]=i))}let{Host:s}=n;if(s.length===1)for(let a of`Host:${s[0]}`.split(` `)){let[i,c]=a.split(":");c.trim()!==""&&(n[i.trim()]=c.trim().split(","))}for(let a of Object.keys(n))r.headers[a]=n[a]}if(e["ws-path"]&&e["ws-path"]!==""&&(r.path=`${e["ws-path"]}`),r.path){let n=/^(.*?)(?:\?ed=(\d+))?$/,[s,a="",i=""]=n.exec(r.path);r.path=a,i!==""&&(r.early_data_header_name="Sec-WebSocket-Protocol",r.max_early_data=parseInt(i,10))}t.tls.insecure&&(t.tls.server_name=r.headers.Host[0]),e["ws-opts"]&&e["ws-opts"]["v2ray-http-upgrade"]&&(r.type="httpupgrade",r.headers.Host&&(r.host=r.headers.Host[0],delete r.headers.Host),r.max_early_data&&delete r.max_early_data,r.early_data_header_name&&delete r.early_data_header_name);for(let n of Object.keys(r.headers)){let s=r.headers[n];s.length===1&&(r.headers[n]=s[0])}t.transport=r},sD=(e,t)=>{let r={type:"http",headers:{}};if(e["http-opts"]){let{method:n="",path:s="",headers:a={}}=e["http-opts"];n!==""&&(r.method=n),Array.isArray(s)?r.path=`${s[0]}`:s!==""&&(r.path=`${s}`);for(let i of Object.keys(a)){let c=a[i];if(c!==""){if(i.toLowerCase()==="host"){let l=c;Array.isArray(l)||(l=`${l}`.split(",").map(h=>h.trim())),l.length>0&&(r.host=l);continue}Array.isArray(c)||(c=`${c}`.split(",").map(l=>l.trim())),c.length>0&&(r.headers[i]=c)}}}if(e["http-host"]&&e["http-host"]!==""){let n=e["http-host"];Array.isArray(n)||(n=`${n}`.split(",").map(s=>s.trim())),n.length>0&&(r.host=n)}if(r.host){if(e["http-path"]&&e["http-path"]!==""){let n=e["http-path"];Array.isArray(n)?r.path=`${n[0]}`:n!==""&&(r.path=`${n}`)}t.tls.insecure&&(t.tls.server_name=r.host[0]),r.host.length===1&&(r.host=r.host[0]);for(let n of Object.keys(r.headers)){let s=r.headers[n];s.length===1&&(r.headers[n]=s[0])}t.transport=r}},aD=(e,t)=>{let r={type:"http"};if(e["h2-opts"]){let{host:n="",path:s=""}=e["h2-opts"];s!==""&&(r.path=`${s}`),n!==""&&(Array.isArray(n)||(n=`${n}`.split(",").map(a=>a.trim())),n.length>0&&(r.host=n))}if(e["h2-host"]&&e["h2-host"]!==""){let n=e["h2-host"];Array.isArray(n)||(n=`${n}`.split(",").map(s=>s.trim())),n.length>0&&(r.host=n)}e["h2-path"]&&e["h2-path"]!==""&&(r.path=`${e["h2-path"]}`),t.tls.enabled=!0,t.tls.insecure&&(t.tls.server_name=r.host[0]),r.host.length===1&&(r.host=r.host[0]),t.transport=r},k0=(e,t)=>{let r={type:"grpc"};if(e["grpc-opts"]){let n=e["grpc-opts"]["grpc-service-name"];n!=null&&n!==""&&(r.service_name=`${n}`)}t.transport=r},Gs=(e,t)=>{e.tls&&(t.tls.enabled=!0),e.servername&&e.servername!==""&&(t.tls.server_name=e.servername),e.peer&&e.peer!==""&&(t.tls.server_name=e.peer),e.sni&&e.sni!==""&&(t.tls.server_name=e.sni),e["skip-cert-verify"]&&(t.tls.insecure=!0),e.insecure&&(t.tls.insecure=!0),e["disable-sni"]&&(t.tls.disable_sni=!0),typeof e.alpn=="string"?t.tls.alpn=[e.alpn]:Array.isArray(e.alpn)&&(t.tls.alpn=e.alpn),e.ca&&(t.tls.certificate_path=`${e.ca}`),e.ca_str&&(t.tls.certificate=[e.ca_str]),e["ca-str"]&&(t.tls.certificate=[e["ca-str"]]),e["reality-opts"]&&(t.tls.reality={enabled:!0},e["reality-opts"]["public-key"]&&(t.tls.reality.public_key=e["reality-opts"]["public-key"]),e["reality-opts"]["short-id"]&&(t.tls.reality.short_id=e["reality-opts"]["short-id"]),t.tls.utls={enabled:!0}),!["hysteria","hysteria2","tuic"].includes(e.type)&&e["client-fingerprint"]&&e["client-fingerprint"]!==""&&(t.tls.utls={enabled:!0,fingerprint:e["client-fingerprint"]}),t.tls.enabled||delete t.tls},uD=(e={})=>{let t={tag:e.name,type:"ssh",server:e.server,server_port:parseInt(`${e.port}`,10)};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.username&&(t.user=e.username),e.password&&(t.password=e.password),e.privateKey&&(t.private_key_path=e.privateKey),e["private-key"]&&(t.private_key_path=e["private-key"]),e["private-key-passphrase"]&&(t.private_key_passphrase=e["private-key-passphrase"]),e["server-fingerprint"]&&(t.host_key=[e["server-fingerprint"]],t.host_key_algorithms=[e["server-fingerprint"].split(" ")[0]]),e["host-key"]&&(t.host_key=e["host-key"]),e["host-key-algorithms"]&&(t.host_key_algorithms=e["host-key-algorithms"]),e["fast-open"]&&(t.udp_fragment=!0),In(e,t),ln(e,t),t},oD=(e={})=>{let t={tag:e.name,type:"http",server:e.server,server_port:parseInt(`${e.port}`,10),tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";if(e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.headers){t.headers={};for(let r of Object.keys(e.headers))t.headers[r]=`${e.headers[r]}`;Object.keys(t.headers).length===0&&delete t.headers}return e["fast-open"]&&(t.udp_fragment=!0),In(e,t),ln(e,t),Gs(e,t),t},cD=(e={})=>{let t={tag:e.name,type:"socks",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,version:"5"};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp=!0),e["fast-open"]&&(t.udp_fragment=!0),ys(e,t),In(e,t),ln(e,t),t},lD=(e={})=>{let t={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:`${e.name}_shadowtls`},r={tag:`${e.name}_shadowtls`,type:"shadowtls",server:e.server,server_port:parseInt(`${e.port}`,10),version:e["plugin-opts"].version,password:e["plugin-opts"].password,tls:{enabled:!0,server_name:e["plugin-opts"].host,utls:{enabled:!0,fingerprint:e["client-fingerprint"]}}};if(r.server_port<0||r.server_port>65535)throw"\u7AEF\u53E3\u503C\u975E\u6CD5";return e["fast-open"]===!0&&(r.udp_fragment=!0),In(e,r),ln(e,r),Pi(e.smux,t),{type:"ss-with-st",ssPart:t,stPart:r}},fD=(e={})=>{let t={tag:e.name,type:"shadowsocks",server:e.server,server_port:parseInt(`${e.port}`,10),method:e.cipher,password:e.password};if(t.server_port<0||t.server_port>65535)throw"invalid port";if(e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp=!0),e["fast-open"]&&(t.udp_fragment=!0),ys(e,t),In(e,t),ln(e,t),Pi(e.smux,t),e.plugin){let r=[];e.plugin==="obfs"&&(t.plugin="obfs-local",t.plugin_opts="",e["obfs-host"]&&(e["plugin-opts"].host=e["obfs-host"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"mode":r.push(`obfs=${e["plugin-opts"].mode}`);break;case"host":r.push(`obfs-host=${e["plugin-opts"].host}`);break;default:r.push(`${n}=${e["plugin-opts"][n]}`);break}})),e.plugin==="v2ray-plugin"&&(t.plugin="v2ray-plugin",e["ws-host"]&&(e["plugin-opts"].host=e["ws-host"]),e["ws-path"]&&(e["plugin-opts"].path=e["ws-path"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"tls":e["plugin-opts"].tls&&r.push("tls");break;case"host":r.push(`host=${e["plugin-opts"].host}`);break;case"path":r.push(`path=${e["plugin-opts"].path}`);break;case"headers":r.push(`headers=${JSON.stringify(e["plugin-opts"].headers)}`);break;case"mux":e["plugin-opts"].mux&&(t.multiplex={enabled:!0});break;default:r.push(`${n}=${e["plugin-opts"][n]}`)}})),t.plugin_opts=r.join(";")}return t},hD=(e={})=>{let t={tag:e.name,type:"shadowsocksr",server:e.server,server_port:parseInt(`${e.port}`,10),method:e.cipher,password:e.password,obfs:e.obfs,protocol:e.protocol};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["obfs-param"]&&(t.obfs_param=e["obfs-param"]),e["protocol-param"]&&e["protocol-param"]!==""&&(t.protocol_param=e["protocol-param"]),e["fast-open"]&&(t.udp_fragment=!0),In(e,t),ln(e,t),Pi(e.smux,t),t},pD=(e={})=>{let t={tag:e.name,type:"vmess",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,security:e.cipher,alter_id:parseInt(`${e.alterId}`,10),tls:{enabled:!1,server_name:e.server,insecure:!1}};if(["auto","none","zero","aes-128-gcm","chacha20-poly1305","aes-128-ctr"].indexOf(t.security)===-1&&(t.security="auto"),t.server_port<0||t.server_port>65535)throw"invalid port";return e.xudp&&(t.packet_encoding="xudp"),e["fast-open"]&&(t.udp_fragment=!0),e.network==="ws"&&O0(e,t),e.network==="h2"&&aD(e,t),e.network==="http"&&sD(e,t),e.network==="grpc"&&k0(e,t),ys(e,t),In(e,t),ln(e,t),Gs(e,t),Pi(e.smux,t),t},dD=(e={})=>{let t={tag:e.name,type:"vless",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["fast-open"]&&(t.udp_fragment=!0),e.flow==="xtls-rprx-vision"&&(t.flow=e.flow),e.network==="ws"&&O0(e,t),e.network==="grpc"&&k0(e,t),ys(e,t),In(e,t),ln(e,t),Pi(e.smux,t),Gs(e,t),t},gD=(e={})=>{let t={tag:e.name,type:"trojan",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["fast-open"]&&(t.udp_fragment=!0),e.network==="grpc"&&k0(e,t),e.network==="ws"&&O0(e,t),ys(e,t),In(e,t),ln(e,t),Gs(e,t),Pi(e.smux,t),t},mD=(e={})=>{let t={tag:e.name,type:"hysteria",server:e.server,server_port:parseInt(`${e.port}`,10),disable_mtu_discovery:!1,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";e.auth_str&&(t.auth_str=`${e.auth_str}`),e["auth-str"]&&(t.auth_str=`${e["auth-str"]}`),e["fast-open"]&&(t.udp_fragment=!0);let r=new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");return r.test(`${e.up}`)?t.up=`${e.up}`:t.up_mbps=parseInt(`${e.up}`,10),r.test(`${e.down}`)?t.down=`${e.down}`:t.down_mbps=parseInt(`${e.down}`,10),e.obfs&&(t.obfs=e.obfs),e.recv_window_conn&&(t.recv_window_conn=e.recv_window_conn),e["recv-window-conn"]&&(t.recv_window_conn=e["recv-window-conn"]),e.recv_window&&(t.recv_window=e.recv_window),e["recv-window"]&&(t.recv_window=e["recv-window"]),e.disable_mtu_discovery&&(typeof e.disable_mtu_discovery=="boolean"?t.disable_mtu_discovery=e.disable_mtu_discovery:e.disable_mtu_discovery===1&&(t.disable_mtu_discovery=!0)),ys(e,t),Gs(e,t),ln(e,t),In(e,t),Pi(e.smux,t),t},vD=(e={})=>{let t={tag:e.name,type:"hysteria2",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,obfs:{},tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["hop-interval"]&&(t.hop_interval=/^\d+$/.test(e["hop-interval"])?`${e["hop-interval"]}s`:e["hop-interval"]),e.ports&&(t.server_ports=e.ports.split(/\s*,\s*/).map(r=>r.replace(/\s*-\s*/g,":"))),e.up&&(t.up_mbps=parseInt(`${e.up}`,10)),e.down&&(t.down_mbps=parseInt(`${e.down}`,10)),e.obfs==="salamander"&&(t.obfs.type="salamander"),e["obfs-password"]&&(t.obfs.password=e["obfs-password"]),t.obfs.type||delete t.obfs,ys(e,t),Gs(e,t),In(e,t),ln(e,t),Pi(e.smux,t),t},AD=(e={})=>{let t={tag:e.name,type:"tuic",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,password:e.password,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["fast-open"]&&(t.udp_fragment=!0),e["congestion-controller"]&&e["congestion-controller"]!=="cubic"&&(t.congestion_control=e["congestion-controller"]),e["udp-relay-mode"]&&e["udp-relay-mode"]!=="native"&&(t.udp_relay_mode=e["udp-relay-mode"]),e["reduce-rtt"]&&(t.zero_rtt_handshake=!0),e["udp-over-stream"]&&(t.udp_over_stream=!0),e["heartbeat-interval"]&&(t.heartbeat=`${e["heartbeat-interval"]}ms`),ys(e,t),In(e,t),ln(e,t),Gs(e,t),Pi(e.smux,t),t},wD=(e={})=>{let t={tag:e.name,type:"anytls",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,tls:{enabled:!0,server_name:e.server,insecure:!1}};return/^\d+$/.test(e["idle-session-check-interval"])&&(t.idle_session_check_interval=`${e["idle-session-check-interval"]}s`),/^\d+$/.test(e["idle-session-timeout"])&&(t.idle_session_timeout=`${e["idle-session-timeout"]}s`),ln(e,t),Gs(e,t),t},ED=(e={})=>{let t=["ip","ipv6"].map(n=>e[n]).map(n=>{if(rr(n))return`${n}/32`;if(nr(n))return`${n}/128`}).filter(n=>n),r={tag:e.name,type:"wireguard",server:e.server,server_port:parseInt(`${e.port}`,10),local_address:t,private_key:e["private-key"],peer_public_key:e["public-key"],pre_shared_key:e["pre-shared-key"],reserved:[]};if(r.server_port<0||r.server_port>65535)throw"invalid port";if(e["fast-open"]&&(r.udp_fragment=!0),typeof e.reserved=="string")r.reserved=e.reserved;else if(Array.isArray(e.reserved))for(let n of e.reserved)r.reserved.push(n);else delete r.reserved;if(e.peers&&e.peers.length>0){r.peers=[];for(let n of e.peers){let s={server:n.server,server_port:parseInt(`${n.port}`,10),public_key:n["public-key"],allowed_ips:n["allowed-ips"]||n.allowed_ips,reserved:[]};if(typeof n.reserved=="string")s.reserved.push(n.reserved);else if(Array.isArray(n.reserved))for(let a of n.reserved)s.reserved.push(a);else delete s.reserved;n["pre-shared-key"]&&(s.pre_shared_key=n["pre-shared-key"]),r.peers.push(s)}}return ys(e,r),In(e,r),ln(e,r),Pi(e.smux,r),r};function Nf(){return{type:"ALL",produce:(r,n,s={})=>{let a=[];return Fn().produce(r,"internal",{"include-unsupported-proxy":!0}).map(i=>{try{switch(i.type){case"ssh":a.push(uD(i));break;case"http":a.push(oD(i));break;case"socks5":if(i.tls)throw new Error(`Platform sing-box does not support proxy type: ${i.type} with tls`);a.push(cD(i));break;case"ss":if(i.plugin==="shadow-tls"){let{ssPart:c,stPart:l}=lD(i);a.push(c),a.push(l)}else a.push(fD(i));break;case"ssr":if(s["include-unsupported-proxy"])a.push(hD(i));else throw new Error(`Platform sing-box does not support proxy type: ${i.type}`);break;case"vmess":if(!i.network||["ws","grpc","h2","http"].includes(i.network))a.push(pD(i));else throw new Error(`Platform sing-box does not support proxy type: ${i.type} with network ${i.network}`);break;case"vless":if(!i.flow||["xtls-rprx-vision"].includes(i.flow))a.push(dD(i));else throw new Error(`Platform sing-box does not support proxy type: ${i.type} with flow ${i.flow}`);break;case"trojan":if(!i.flow)a.push(gD(i));else throw new Error(`Platform sing-box does not support proxy type: ${i.type} with flow ${i.flow}`);break;case"hysteria":a.push(mD(i));break;case"hysteria2":a.push(vD(i,s["include-unsupported-proxy"]));break;case"tuic":if(!i.token||i.token.length===0)a.push(AD(i));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":a.push(ED(i));break;case"anytls":a.push(wD(i));break;default:throw new Error(`Platform sing-box does not support proxy type: ${i.type}`)}}catch(c){ne.error(c.message??c)}}),n==="internal"?a:JSON.stringify({outbounds:a},null,2)}}}function Lf(){return{type:"ALL",produce:(r,n)=>{let s=r.filter(a=>!(!["http","socks5","ss","trojan","hysteria2","vless","vmess","tuic"].includes(a.type)||a.type==="ss"&&(a.plugin==="obfs"&&!["http","tls"].includes(a["plugin-opts"]?.mode)||!["chacha20-ietf-poly1305","chacha20-poly1305","aes-256-gcm","aes-128-gcm","none","tbale","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","cast5-cfb","des-cfb","idea-cfb","rc2-cfb","seed-cfb","salsa20","chacha20","chacha20-ietf","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(a.cipher))||a.type==="vmess"&&!["http","ws","tcp"].includes(a.network)&&a.network||a.type==="trojan"&&!["http","ws","tcp"].includes(a.network)&&a.network||a.type==="vless"&&(typeof a.flow<"u"||a["reality-opts"]||!["http","ws","tcp"].includes(a.network)&&a.network)||a.type==="tuic"&&a.token&&a.token.length!==0)).map(a=>{let i={...a};a.tls&&!a.sni&&(a.sni=a.server);let c=a.prev_hop||a["underlying-proxy"]||a["dialer-proxy"]||a.detour;if(a.type==="http")a={type:"http",name:a.name,server:a.server,port:a.port,username:a.username,password:a.password,tfo:a.tfo||a["fast-open"],next_hop:a.next_hop};else if(a.type==="socks5")a={type:"socks5",name:a.name,server:a.server,port:a.port,username:a.username,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop};else if(a.type==="ss")a={type:"shadowsocks",name:a.name,method:a.cipher==="chacha20-ietf-poly1305"?"chacha20-poly1305":a.cipher,server:a.server,port:a.port,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop},i.plugin==="obfs"&&(a.obfs=i["plugin-opts"].mode,a.obfs_host=i["plugin-opts"].host,a.obfs_uri=i["plugin-opts"].path);else if(a.type==="hysteria2")a={type:"hysteria2",name:a.name,server:a.server,port:a.port,auth:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,sni:a.sni,skip_tls_verify:a["skip-cert-verify"],port_hopping:a.ports,port_hopping_interval:a["hop-interval"]},i["obfs-password"]&&i.obfs=="salamander"&&(a.obfs="salamander",a.obfs_password=i["obfs-password"]);else if(a.type==="tuic")a={type:"tuic",name:a.name,server:a.server,port:a.port,uuid:a.uuid,password:a.password,next_hop:a.next_hop,sni:a.sni,alpn:Array.isArray(a.alpn)?a.alpn:[a.alpn||"h3"],skip_tls_verify:a["skip-cert-verify"],port_hopping:a.ports,port_hopping_interval:a["hop-interval"]};else if(a.type==="trojan")a.network==="ws"&&(a.websocket={path:a["ws-opts"]?.path,host:a["ws-opts"]?.headers?.Host}),a={type:"trojan",name:a.name,server:a.server,port:a.port,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,sni:a.sni,skip_tls_verify:a["skip-cert-verify"],websocket:a.websocket};else if(a.type==="vmess"){let l=a.cipher;l&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(l)&&(l="auto"),a.network==="ws"?a.transport={[a.tls?"wss":"ws"]:{path:a["ws-opts"]?.path,headers:{Host:a["ws-opts"]?.headers?.Host},sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}:a.network==="http"?a.transport={http1:{method:a["http-opts"]?.method,path:Array.isArray(a["http-opts"]?.path)?a["http-opts"]?.path[0]:a["http-opts"]?.path,headers:{Host:Array.isArray(a["http-opts"]?.headers?.Host)?a["http-opts"]?.headers?.Host[0]:a["http-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:a.network==="h2"?a.transport={http2:{method:a["h2-opts"]?.method,path:Array.isArray(a["h2-opts"]?.path)?a["h2-opts"]?.path[0]:a["h2-opts"]?.path,headers:{Host:Array.isArray(a["h2-opts"]?.headers?.Host)?a["h2-opts"]?.headers?.Host[0]:a["h2-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:(a.network==="tcp"||!a.network)&&a.tls&&(a.transport={tls:{sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}),a={type:"vmess",name:a.name,server:a.server,port:a.port,user_id:a.uuid,security:l,tfo:a.tfo||a["fast-open"],legacy:a.legacy,udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,transport:a.transport}}else a.type==="vless"&&(a.network==="ws"?a.transport={[a.tls?"wss":"ws"]:{path:a["ws-opts"]?.path,headers:{Host:a["ws-opts"]?.headers?.Host},sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}:a.network==="http"?a.transport={http:{method:a["http-opts"]?.method,path:Array.isArray(a["http-opts"]?.path)?a["http-opts"]?.path[0]:a["http-opts"]?.path,headers:{Host:Array.isArray(a["http-opts"]?.headers?.Host)?a["http-opts"]?.headers?.Host[0]:a["http-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:(a.network==="tcp"||!a.network)&&(a.transport={[a.tls?"tls":"tcp"]:{sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}),a={type:"vless",name:a.name,server:a.server,port:a.port,user_id:a.uuid,security:a.cipher,tfo:a.tfo||a["fast-open"],legacy:a.legacy,udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,transport:a.transport});if(["http","socks5","ss","trojan","vless","vmess"].includes(i.type)){if(se(i,"shadow-tls-password")){if(i["shadow-tls-version"]!=3)throw new Error(`shadow-tls version ${i["shadow-tls-version"]} is not supported`);a.shadow_tls={password:i["shadow-tls-password"],sni:i["shadow-tls-sni"]}}else if(["shadow-tls"].includes(i.plugin)&&i["plugin-opts"]){if(i["plugin-opts"].version!=3)throw new Error(`shadow-tls version ${i["plugin-opts"].version} is not supported`);a.shadow_tls={password:i["plugin-opts"].password,sni:i["plugin-opts"].host}}}if(delete a.subName,delete a.collectionName,delete a.id,delete a.resolved,delete a["no-resolve"],n!=="internal")for(let l in a)(a[l]==null||/^_/i.test(l))&&delete a[l];return{[a.type]:{...a,type:void 0,prev_hop:c}}});return n==="internal"?s:`proxies: `+s.map(a=>" - "+JSON.stringify(a)+` `).join("")}}}function Q2(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var eA={qx:Ic(),QX:Ic(),QuantumultX:Ic(),surge:ao(),Surge:ao(),SurgeMac:R0(),Loon:x0(),Clash:T0(),meta:Fn(),clashmeta:Fn(),"clash.meta":Fn(),"Clash.Meta":Fn(),ClashMeta:Fn(),mihomo:Fn(),Mihomo:Fn(),uri:uo(),URI:uo(),v2:_c(),v2ray:_c(),V2Ray:_c(),json:Q2(),JSON:Q2(),stash:Of(),Stash:Of(),shadowrocket:Dc(),Shadowrocket:Dc(),ShadowRocket:Dc(),surfboard:kf(),Surfboard:kf(),singbox:Nf(),"sing-box":Nf(),egern:Lf(),Egern:Lf()};var aw=Un(Oc()),BB=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleWebsocket() { if (obfs.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers", obfs['ws-headers']); if (proxy['ws-opts'] && proxy['ws-opts']['headers'] && proxy['ws-opts']['headers'].Host) { proxy['ws-opts']['headers'].Host = proxy['ws-opts']['headers'].Host.replace(/^"(.*)"$/, '$1') } } } function handleShadowTLS() { if (proxy['shadow-tls-password'] && !proxy['shadow-tls-version']) { proxy['shadow-tls-version'] = 2; } } } start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) { return proxy; } shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* { proxy.type = "ss"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } handleShadowTLS(); } vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/tls_fingerprint/tls_verification/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead) { proxy.alterId = 0; } else { proxy.alterId = proxy.alterId || 0; } handleWebsocket(); handleShadowTLS(); } trojan = tag equals "trojan" address (passwordk/ws/ws_path/ws_headers/tls/sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "trojan"; handleWebsocket(); handleShadowTLS(); } https = tag equals "https" address (username password)? (usernamek passwordk)? (sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; proxy.tls = true; handleShadowTLS(); } http = tag equals "http" address (username password)? (usernamek passwordk)? (ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; handleShadowTLS(); } ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (server_fingerprint/idle_timeout/private_key/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "ssh"; handleShadowTLS(); } snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "snell"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { $set(proxy, "obfs-opts.mode", obfs.type); $set(proxy, "obfs-opts.host", obfs.host); $set(proxy, "obfs-opts.path", obfs.path); } handleShadowTLS(); } tuic = tag equals "tuic" address (alpn/token/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; handleShadowTLS(); } tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; proxy.version = 5; handleShadowTLS(); } wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "wireguard-surge"; handleShadowTLS(); } hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/fast_open/tfo/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "hysteria2"; handleShadowTLS(); } socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; handleShadowTLS(); } socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_fingerprint/tls_verification/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; proxy.tls = true; handleShadowTLS(); } direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* { proxy.type = "direct"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } port_hopping_interval = comma "port-hopping-interval" equals match:$[0-9]+ { proxy["hop-interval"] = parseInt(match.trim()); } username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username; } password = comma match:[^,]+ { proxy.password = match.join(""); } tls = comma "tls" equals flag:bool { proxy.tls = flag; } sni = comma "sni" equals sni:("off"/domain) { if (sni === "off") { proxy["disable-sni"] = true; } else { proxy.sni = sni; } } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join(""); } snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); } usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join(""); } passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join(""); } vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; } method = comma "encrypt-method" equals cipher:cipher { proxy.cipher = cipher; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"idea-cfb"/"none"/"rc2-cfb"/"rc4-md5"/"rc4"/"salsa20"/"seed-cfb"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); ws = comma "ws" equals flag:bool { obfs.type = "ws"; } ws_headers = comma "ws-headers" equals headers:$[^,]+ { const pairs = headers.split("|"); const result = {}; pairs.forEach(pair => { const [key, value] = pair.trim().split(":"); result[key.trim()] = value.trim(); }) obfs["ws-headers"] = result; } ws_path = comma "ws-path" equals path:uri { obfs.path = path; } obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; }; obfs_uri = comma "obfs-uri" equals path:uri { obfs.path = path } uri = $[^,]+ udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } reuse = comma "reuse" equals flag:bool { proxy.reuse = flag; } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; } ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); } no_error_alert = comma "no-error-alert" equals match:[^,]+ { proxy["no-error-alert"] = match.join(""); } underlying_proxy = comma "underlying-proxy" equals match:[^,]+ { proxy["underlying-proxy"] = match.join(""); } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } test_url = comma "test-url" equals match:[^,]+ { proxy["test-url"] = match.join(""); } test_udp = comma "test-udp" equals match:[^,]+ { proxy["test-udp"] = match.join(""); } test_timeout = comma "test-timeout" equals match:$[0-9]+ { proxy["test-timeout"] = parseInt(match.trim()); } tos = comma "tos" equals match:$[0-9]+ { proxy.tos = parseInt(match.trim()); } interface = comma "interface" equals match:[^,]+ { proxy.interface = match.join(""); } allow_other_interface = comma "allow-other-interface" equals flag:bool { proxy["allow-other-interface"] = flag; } hybrid = comma "hybrid" equals flag:bool { proxy.hybrid = flag; } idle_timeout = comma "idle-timeout" equals match:$[0-9]+ { proxy["idle-timeout"] = parseInt(match.trim()); } private_key = comma "private-key" equals match:[^,]+ { proxy["keystore-private-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } server_fingerprint = comma "server-fingerprint" equals match:[^,]+ { proxy["server-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match.join(""); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); } alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); } uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,rd;function Bn(){return rd||(rd=aw.generate(BB)),rd}var uw=Un(Oc()),PB=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const transport = {}; const $ = {}; function handleTransport() { if (transport.type === "tcp") { /* do nothing */ } else if (transport.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", transport.path); $set(proxy, "ws-opts.headers.Host", transport.host); } else if (transport.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", transport.path); $set(proxy, "http-opts.headers.Host", transport.host); } } } start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2) { return proxy; } shadowsocksr = tag equals "shadowsocksr"i address method password (ssr_protocol/ssr_protocol_param/obfs_ssr/obfs_ssr_param/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/others)*{ proxy.type = "ssr"; // handle ssr obfs proxy.obfs = obfs.type; } shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/others)* { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; proxy.alterId = proxy.alterId || 0; handleTransport(); } vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/flow/public_key/short_id/others)* { proxy.type = "vless"; handleTransport(); } trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* { proxy.type = "trojan"; handleTransport(); } hysteria2 = tag equals "hysteria2"i address password (tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/salamander_password/ecn/ip_mode/others)* { proxy.type = "hysteria2"; } https = tag equals "https"i address (username password)? (tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* { proxy.type = "http"; proxy.tls = true; } http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/others)* { proxy.type = "http"; } socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* { proxy.type = "socks5"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } throw new Error("Invalid domain: " + domain); } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } throw new Error("Invalid port number: " + port); } method = comma cipher:cipher { proxy.cipher = cipher; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username; } password = comma '"' match:[^"]* '"' { proxy.password = match.join(""); } uuid = comma '"' match:[^"]+ '"' { proxy.uuid = match.join(""); } obfs_typev = comma type:("http"/"tls") { obfs.type = type; } obfs_hostv = comma match:[^,]+ { obfs.host = match.join(""); } obfs_ss = comma "obfs-name" equals type:("http"/"tls") { obfs.type = type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { obfs.type = type; } obfs_ssr_param = comma "obfs-param" equals match:$[^,]+ { proxy["obfs-param"] = match; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } uri = $[^,]+ transport = comma "transport" equals type:("tcp"/"ws"/"http") { transport.type = type; } transport_host = comma "host" equals host:domain { transport.host = host; } transport_path = comma "path" equals path:uri { transport.path = path; } ssr_protocol = comma "protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; } ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseInt(alterId); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_host = comma sni:("tls-name"/"sni") equals host:domain { proxy.sni = host; } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); } flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); } public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } short_id = comma "short-id" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = match.join("").replace(/^"(.*)"$/, '$1'); } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; } ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join(""); proxy.obfs = 'salamander'; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,nd;function $i(){return nd||(nd=uw.generate(PB)),nd}var ow=Un(Oc()),$B=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parse initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleObfs() { if (obfs.type === "ws" || obfs.type === "wss") { proxy.network = "ws"; if (obfs.type === 'wss') { proxy.tls = true; } $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers.Host", obfs.host); } else if (obfs.type === "over-tls") { proxy.tls = true; } else if (obfs.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", obfs.path); $set(proxy, "http-opts.headers.Host", obfs.host); } } } start = (trojan/shadowsocks/vmess/vless/http/socks5) { return proxy } trojan = "trojan" equals address (password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/obfs/obfs_host/obfs_uri/tag/udp_relay/udp_over_tcp/fast_open/server_check_url/others)* { proxy.type = "trojan"; handleObfs(); } shadowsocks = "shadowsocks" equals address (password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/udp_over_tcp/fast_open/tag/server_check_url/others)* { if (proxy.protocol || proxy.type === "ssr") { proxy.type = "ssr"; if (!proxy.protocol) { proxy.protocol = "origin"; } // handle ssr obfs if (obfs.host) proxy["obfs-param"] = obfs.host; if (obfs.type) proxy.obfs = obfs.type; } else { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts", { mode: obfs.type }); } else if (obfs.type === "ws" || obfs.type === "wss") { proxy.plugin = "v2ray-plugin"; $set(proxy, "plugin-opts.mode", "websocket"); if (obfs.type === "wss") { $set(proxy, "plugin-opts.tls", true); } } else if (obfs.type === 'over-tls') { throw new Error('ss over-tls is not supported'); } if (obfs.type) { $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } } vmess = "vmess" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead) { proxy.alterId = 0; } else { proxy.alterId = proxy.alterId || 0; } handleObfs(); } vless = "vless" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/others)* { proxy.type = "vless"; proxy.cipher = proxy.cipher || "none"; handleObfs(); } http = "http" equals address (username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)*{ proxy.type = "http"; } socks5 = "socks5" equals address (username/password/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)* { proxy.type = "socks5"; } address = server:server ":" port:port { proxy.server = server; proxy.port = port; } server = ip/domain domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } ip = & { const start = peg$currPos; let end; let j = start; while (j < input.length) { if (input[j] === ",") break; if (input[j] === ":") end = j; j++; } peg$currPos = end || j; $.ip = input.substring(start, end).trim(); return true; } { return $.ip; } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); } password = comma "password" equals password:[^,]+ { proxy.password = password.join("").trim(); } uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); } method = comma "method" equals cipher:cipher { proxy.cipher = cipher; }; cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"none"/"rc2-cfb"/"rc4-md5-6"/"rc4-md5"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); aead = comma "aead" equals flag:bool { proxy.aead = flag; } udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_host = comma "tls-host" equals sni:domain { proxy.sni = sni; } tls_verification = comma "tls-verification" equals flag:bool { proxy["skip-cert-verify"] = !flag; } tls_fingerprint = comma "tls-cert-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals param:$[^=,]+ { proxy["tls-pubkey-sha256"] = param; } tls_alpn = comma "tls-alpn" equals param:$[^=,]+ { proxy["tls-alpn"] = param; } tls_no_session_ticket = comma "tls-no-session-ticket" equals flag:bool { proxy["tls-no-session-ticket"] = flag; } tls_no_session_reuse = comma "tls-no-session-reuse" equals flag:bool { proxy["tls-no-session-reuse"] = flag; } obfs_ss = comma "obfs" equals type:("http"/"tls"/"wss"/"ws"/"over-tls") { obfs.type = type; return type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { proxy.type = "ssr"; obfs.type = type; return type; } obfs = comma "obfs" equals type:("wss"/"ws"/"over-tls"/"http") { obfs.type = type; return type; }; obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } ssr_protocol = comma "ssr-protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; return protocol; } ssr_protocol_param = comma "ssr-protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } server_check_url = comma "server_check_url" equals param:$[^=,]+ { proxy["test-url"] = param; } uri = $[^,]+ tag = comma "tag" equals tag:[^=,]+ { proxy.name = tag.join(""); } others = comma [^=,]+ equals [^=,]+ comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } `,sd;function bs(){return sd||(sd=ow.generate($B)),sd}var cw=Un(Oc()),RB=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } function toBool(str) { if (typeof str === 'undefined' || str === null) return undefined; return /(TRUE)|1/i.test(str); } }} { const proxy = {}; const obfs = {}; const $ = {}; const params = {}; } start = (trojan) { return proxy } trojan = "trojan://" password:password "@" server:server ":" port:port "/"? params? name:name?{ proxy.type = "trojan"; proxy.password = password; proxy.server = server; proxy.port = port; proxy.name = name; // name may be empty if (!proxy.name) { proxy.name = server + ":" + port; } }; password = match:$[^@]+ { return decodeURIComponent(match); }; server = ip/domain; domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } ip = & { const start = peg$currPos; let end; let j = start; while (j < input.length) { if (input[j] === ",") break; if (input[j] === ":") end = j; j++; } peg$currPos = end || j; $.ip = input.substring(start, end).trim(); return true; } { return $.ip; } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } else { throw new Error("Invalid port: " + port); } } params = "?" head:param tail:("&"@param)* { for (const [key, value] of Object.entries(params)) { params[key] = decodeURIComponent(value); } proxy["skip-cert-verify"] = toBool(params["allowInsecure"]); proxy.sni = params["sni"] || params["peer"]; proxy['client-fingerprint'] = params.fp; proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(',') : undefined; if (toBool(params["ws"])) { proxy.network = "ws"; $set(proxy, "ws-opts.path", params["wspath"]); } if (params["type"]) { let httpupgrade proxy.network = params["type"] if(proxy.network === 'httpupgrade') { proxy.network = 'ws' httpupgrade = true } if (['grpc'].includes(proxy.network)) { proxy[proxy.network + '-opts'] = { 'grpc-service-name': params["serviceName"], '_grpc-type': params["mode"], '_grpc-authority': params["authority"], }; } else { if (params["path"]) { $set(proxy, proxy.network+"-opts.path", decodeURIComponent(params["path"])); } if (params["host"]) { $set(proxy, proxy.network+"-opts.headers.Host", decodeURIComponent(params["host"])); } if (httpupgrade) { $set(proxy, proxy.network+"-opts.v2ray-http-upgrade", true); $set(proxy, proxy.network+"-opts.v2ray-http-upgrade-fast-open", true); } } if (['reality'].includes(params.security)) { const opts = {}; if (params.pbk) { opts['public-key'] = params.pbk; } if (params.sid) { opts['short-id'] = params.sid; } if (params.spx) { opts['_spider-x'] = params.spx; } if (params.mode) { proxy._mode = params.mode; } if (params.extra) { proxy._extra = params.extra; } if (Object.keys(opts).length > 0) { $set(proxy, params.security+"-opts", opts); } } } proxy.udp = toBool(params["udp"]); proxy.tfo = toBool(params["tfo"]); } param = kv/single; kv = key:$[a-z]i+ "=" value:$[^&#]i* { params[key] = value; } single = key:$[a-z]i+ { params[key] = true; }; name = "#" + match:$.* { return decodeURIComponent(match); } `,ad;function ud(){return ad||(ad=cw.generate(RB)),ad}function lw(e){let[t,r]=e.match(/,\s*?port-hopping\s*?=\s*?["']?\s*?((\d+(-\d+)?)([,;]\d+(-\d+)?)*)\s*?["']?\s*?/)||[];return{port_hopping:r?r.replace(/;/g,","):void 0,line:t?e.replace(t,""):e}}function TB(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[s,a,i,c,l,h,v,E,p]=n.match(/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(v)v=parseInt(v,10);else{if(i)v=443;else if(a==="http")v=80;else throw ne.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);ne.info(`port is not present in line: ${n}, set to ${v}`)}return{name:p!=null?decodeURIComponent(p):`${a} ${h}:${v}`,type:a,tls:!!i,server:h,port:v,username:c!=null?decodeURIComponent(c):void 0,password:l!=null?decodeURIComponent(l):void 0}}}}function xB(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[s,a,i,c,l,h,v]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(l)l=parseInt(l,10);else throw ne.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let E,p;if(i){let w=dt.decode(decodeURIComponent(i)).split(":");E=w[0],p=w[1]}return{name:v!=null?decodeURIComponent(v):`${a} ${c}:${l}`,type:"socks5",server:c,port:l,username:E,password:p}}}}function OB(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let s=n.split("ss://")[1],a={name:decodeURIComponent(n.split("#")[1]),type:"ss"};s=s.split("#")[0];let i=s.match(/@([^/]*)(\/|$)/),c=decodeURIComponent(s.split("@")[0]),l;c?.startsWith("2022-blake3-")?l=c:l=dt.decode(c);let h="";if(i)s.includes("?")&&(h=s.match(/(\?.*)$/)[1]);else{if(s.includes("?")){let m=s.match(/^(.*)(\?.*)$/);s=m[1],h=m[2]}if(s=dt.decode(s),h){if(/(&|\?)v2ray-plugin=/.test(h)){let y=h.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];y&&(a.plugin="v2ray-plugin",a["plugin-opts"]=JSON.parse(dt.decode(y)))}s=`${s}${h}`}l=s.match(/(^.*)@/)?.[1],i=s.match(/@([^/@]*)(\/|$)/)}let v=i[1],E=v.lastIndexOf(":");a.server=v.substring(0,E),a.port=`${v.substring(E+1)}`.match(/\d+/)?.[0];let p=l.match(/(^.*?):(.*$)/);a.cipher=p?.[1],a.password=p?.[2];let f=s.match(/[?&]plugin=([^&]+)/),w=s.match(/[?&]shadow-tls=([^&]+)/);if(f){let m=("plugin="+decodeURIComponent(f[1])).split(";"),y={};for(let A of m){let[b,_]=A.split("=");b&&(y[b]=_||!0)}switch(y.plugin){case"obfs-local":case"simple-obfs":a.plugin="obfs",a["plugin-opts"]={mode:y.obfs,host:xt(y["obfs-host"])};break;case"v2ray-plugin":a.plugin="v2ray-plugin",a["plugin-opts"]={mode:"websocket",host:xt(y["obfs-host"]),path:xt(y.path),tls:ja(y.tls)};break;case"shadow-tls":{a.plugin="shadow-tls";let A=xt(y.version);a["plugin-opts"]={host:xt(y.host),password:xt(y.password),version:A?parseInt(A,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${y.plugin}`)}}if(w){let m=JSON.parse(dt.decode(w[1])),y=xt(m.version),A=xt(m.address),b=xt(m.port);a.plugin="shadow-tls",a["plugin-opts"]={host:xt(m.host),password:xt(m.password),version:y?parseInt(y,10):void 0},A&&(a.server=A),b&&(a.port=parseInt(b,10))}return/(&|\?)uot=(1|true)/i.test(h)&&(a["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(h)&&(a.tfo=!0),a}}}function kB(){return{name:"URI SSR Parser",test:n=>/^ssr:\/\//.test(n),parse:n=>{n=dt.decode(n.split("ssr://")[1]);let s=n.indexOf(":origin");s===-1&&(s=n.indexOf(":auth_"));let a=n.substring(0,s),i=a.substring(0,a.lastIndexOf(":")),c=a.substring(a.lastIndexOf(":")+1),l=n.substring(s+1).split("/?")[0].split(":"),h={type:"ssr",server:i,port:c,protocol:l[0],cipher:l[1],obfs:l[2],password:dt.decode(l[3])},v={};if(n=n.split("/?")[1].split("&"),n.length>1)for(let E of n){let[p,f]=E.split("=");f=f.trim(),f.length>0&&f!=="(null)"&&(v[p]=f)}return h={...h,name:v.remarks?dt.decode(v.remarks):h.server,"protocol-param":xt(dt.decode(v.protoparam||"").replace(/\s/g,"")),"obfs-param":xt(dt.decode(v.obfsparam||"").replace(/\s/g,""))},h}}}function NB(){return{name:"URI VMess Parser",test:n=>/^vmess:\/\//.test(n),parse:n=>{n=n.split("vmess://")[1];let s=dt.decode(n.replace(/\?.*?$/,""));if(/=\s*vmess/.test(s)){let a=s.split(",").map(l=>l.trim()),i={};for(let l of a)if(l.indexOf("=")!==-1){let[h,v]=l.split("=");i[h.trim()]=v.trim()}let c={name:a[0].split("=")[0].trim(),type:"vmess",server:a[1],port:a[2],cipher:xt(a[3],"auto"),uuid:a[4].match(/^"(.*)"$/)[1],tls:i.obfs==="wss",udp:ja(i["udp-relay"]),tfo:ja(i["fast-open"]),"skip-cert-verify":Xu(i["tls-verification"])?!i["tls-verification"]:void 0};if(Xu(i.obfs))if(i.obfs==="ws"||i.obfs==="wss"){c.network="ws",c["ws-opts"].path=(xt(i["obfs-path"])||'"/"').match(/^"(.*)"$/)[1];let l=i["obfs-header"];l&&l.indexOf("Host")!==-1&&(l=l.match(/Host:\s*([a-zA-Z0-9-.]*)/)[1]),yi(l)&&(c["ws-opts"].headers={Host:l})}else throw new Error(`Unsupported obfs: ${i.obfs}`);return c}else{let a={};try{a=JSON.parse(s)}catch{let[E,p,f]=/(^[^?]+?)\/?\?(.*)$/.exec(n);s=dt.decode(p);for(let _ of f.split("&")){let[I,B]=_.split("="),j=B;j=decodeURIComponent(B),j.indexOf(",")===-1?a[I]=j:a[I]=j.split(",")}let[w,m,y,A,b]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(s);a.scy=m,a.id=y,a.port=b,a.add=A}let i=a.add,c=parseInt(ja(a.port),10),l={name:a.ps??a.remarks??a.remark??`VMess ${i}:${c}`,type:"vmess",server:i,port:c,cipher:ja(a.scy,"auto"),uuid:a.id,alterId:parseInt(ja(a.aid??a.alterId,0),10),tls:["tls",!0,1,"1"].includes(a.tls),"skip-cert-verify":Xu(a.verify_cert)?!a.verify_cert:void 0};!l["skip-cert-verify"]&&Xu(a.allowInsecure)&&(l["skip-cert-verify"]=/(TRUE)|1/i.test(a.allowInsecure)),l.tls&&a.sni&&a.sni!==""&&(l.sni=a.sni);let h=!1;if(a.net==="ws"||a.obfs==="websocket"?l.network="ws":["http"].includes(a.net)||["http"].includes(a.obfs)||["http"].includes(a.type)?l.network="http":["grpc"].includes(a.net)?l.network="grpc":a.net==="httpupgrade"||l.network==="httpupgrade"?(l.network="ws",h=!0):(a.net==="h2"||l.network==="h2")&&(l.network="h2"),l.network){let v=a.host??a.obfsParam;try{let f=JSON.parse(v)?.Host;f&&(v=f)}catch{}let E=a.path;if(["ws"].includes(l.network)&&(E=E||"/"),l.network==="http"&&(v&&(v=v.split(",").map(p=>p.trim()),v=Array.isArray(v)?v[0]:v),E?E=Array.isArray(E)?E[0]:E:E="/"),E||v)if(["grpc"].includes(l.network))l[`${l.network}-opts`]={"grpc-service-name":xt(E),"_grpc-type":xt(a.type),"_grpc-authority":xt(a.authority)};else{let p={path:xt(E),headers:{Host:xt(v)}};h&&(p["v2ray-http-upgrade"]=!0,p["v2ray-http-upgrade-fast-open"]=!0),l[`${l.network}-opts`]=p}else delete l.network}return l}}}}function LB(){return{name:"URI VLESS Parser",test:n=>/^vless:\/\//.test(n),parse:n=>{n=n.split("vless://")[1];let s,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);if(!a){let[y,A,b]=/^(.*?)(\?.*?$)/.exec(n);n=`${dt.decode(A)}${b}`,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),s=!0}let[i,c,l,h,v,E="",p]=a;s&&(c=c.replace(/^.*?:/g,"")),h=parseInt(`${h}`,10),c=decodeURIComponent(c),p!=null&&(p=decodeURIComponent(p));let f={type:"vless",name:p,server:l,port:h,uuid:c},w={};for(let y of E.split("&")){let[A,b]=y.split("="),_=b;_=decodeURIComponent(b),w[A]=_}if(f.name=p??w.remarks??w.remark??`VLESS ${l}:${h}`,f.tls=w.security&&w.security!=="none",s&&/TRUE|1/i.test(w.tls)&&(f.tls=!0,w.security=w.security??"reality"),f.sni=w.sni||w.peer,f.flow=w.flow,!f.flow&&s&&w.xtls){let y=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][w.xtls];y&&(f.flow=y)}if(f["client-fingerprint"]=w.fp,f.alpn=w.alpn?w.alpn.split(","):void 0,f["skip-cert-verify"]=/(TRUE)|1/i.test(w.allowInsecure),["reality"].includes(w.security)){let y={};w.pbk&&(y["public-key"]=w.pbk),w.sid&&(y["short-id"]=w.sid),w.spx&&(y["_spider-x"]=w.spx),Object.keys(y).length>0&&(f[`${w.security}-opts`]=y)}let m=!1;if(f.network=w.type,f.network==="tcp"&&w.headerType==="http"?f.network="http":f.network==="httpupgrade"&&(f.network="ws",m=!0),!f.network&&s&&w.obfs&&(f.network=w.obfs,["none"].includes(f.network)&&(f.network="tcp")),["websocket"].includes(f.network)&&(f.network="ws"),f.network&&!["tcp","none"].includes(f.network)){let y={},A=w.host??w.obfsParam;if(A)if(w.obfsParam)try{let b=JSON.parse(A);y.headers=b}catch{y.headers={Host:A}}else y.headers={Host:A};w.serviceName?(y[`${f.network}-service-name`]=w.serviceName,["grpc"].includes(f.network)&&w.authority&&(y["_grpc-authority"]=w.authority)):s&&w.path&&(["ws","http","h2"].includes(f.network)||(y[`${f.network}-service-name`]=w.path,delete w.path)),w.path&&(y.path=w.path),["grpc"].includes(f.network)&&(y["_grpc-type"]=w.mode||"gun"),m&&(y["v2ray-http-upgrade"]=!0,y["v2ray-http-upgrade-fast-open"]=!0),Object.keys(y).length>0&&(f[`${f.network}-opts`]=y),f.network==="kcp"&&(w.seed&&(f.seed=w.seed),f.headerType=w.headerType||"none"),w.mode&&(f._mode=w.mode),w.extra&&(f._extra=w.extra)}return f}}}function UB(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{n=n.split(/anytls:\/\//)[1];let[s,a,i,c,l="",h]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a),c=parseInt(`${c}`,10),isNaN(c)&&(c=443),a=decodeURIComponent(a),h!=null&&(h=decodeURIComponent(h)),h=h??`AnyTLS ${i}:${c}`;let v={type:"anytls",name:h,server:i,port:c,password:a};for(let E of l.split("&")){let[p,f]=E.split("=");p=p.replace(/_/g,"-"),f=decodeURIComponent(f),["alpn"].includes(p)?v[p]=f?f.split(","):void 0:["insecure"].includes(p)?v["skip-cert-verify"]=/(TRUE)|1/i.test(f):v[p]=f}return v}}}function HB(){return{name:"URI Hysteria2 Parser",test:n=>/^(hysteria2|hy2):\/\//.test(n),parse:n=>{n=n.split(/(hysteria2|hy2):\/\//)[2];let s,[a,i,c,l,h,v,E,p,f,w,m="",y]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(h)?(h=parseInt(`${h}`,10),isNaN(h)&&(h=443)):h?(s=h,h=vc(s)):h=443,i=decodeURIComponent(i),y!=null&&(y=decodeURIComponent(y)),y=y??`Hysteria2 ${c}:${h}`;let A={type:"hysteria2",name:y,server:c,port:h,ports:s,password:i},b={};for(let B of m.split("&")){let[j,V]=B.split("="),F=V;F=decodeURIComponent(V),b[j]=F}A.sni=b.sni,!A.sni&&b.peer&&(A.sni=b.peer),b.obfs&&b.obfs!=="none"&&(A.obfs=b.obfs),b.mport&&(A.ports=b.mport),A["obfs-password"]=b["obfs-password"],A["skip-cert-verify"]=/(TRUE)|1/i.test(b.insecure),A.tfo=/(TRUE)|1/i.test(b.fastopen),A["tls-fingerprint"]=b.pinSHA256;let _=b["hop-interval"]||b.hop_interval;/^\d+$/.test(_)&&(A["hop-interval"]=parseInt(`${_}`,10));let I=b.keepalive;return/^\d+$/.test(I)&&(A.keepalive=parseInt(`${I}`,10)),A}}}function jB(){return{name:"URI Hysteria Parser",test:n=>/^(hysteria|hy):\/\//.test(n),parse:n=>{n=n.split(/(hysteria|hy):\/\//)[2];let[s,a,i,c,l,h="",v]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);c=parseInt(`${c}`,10),isNaN(c)&&(c=443),v!=null&&(v=decodeURIComponent(v)),v=v??`Hysteria ${a}:${c}`;let E={type:"hysteria",name:v,server:a,port:c},p={};for(let f of h.split("&")){let[w,m]=f.split("=");w=w.replace(/_/,"-"),m=decodeURIComponent(m),["alpn"].includes(w)?E[w]=m?m.split(","):void 0:["insecure"].includes(w)?E["skip-cert-verify"]=/(TRUE)|1/i.test(m):["auth"].includes(w)?E["auth-str"]=m:["mport"].includes(w)?E.ports=m:["obfsParam"].includes(w)?E.obfs=m:["upmbps"].includes(w)?E.up=m:["downmbps"].includes(w)?E.down=m:["obfs"].includes(w)?E._obfs=m||"":["fast-open","peer"].includes(w)?p[w]=m:E[w]=m}return!E.sni&&p.peer&&(E.sni=p.peer),!E["fast-open"]&&p.fastopen&&(E["fast-open"]=!0),E.protocol||(E.protocol="udp"),E}}}function MB(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[s,a,i,c,l="",h]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a);let[v,...E]=a.split(":"),p=E.join(":");c=parseInt(`${c}`,10),isNaN(c)&&(c=443),p=decodeURIComponent(p),h!=null&&(h=decodeURIComponent(h)),h=h??`TUIC ${i}:${c}`;let f={type:"tuic",name:h,server:i,port:c,password:p,uuid:v};for(let w of l.split("&")){let[m,y]=w.split("=");m=m.replace(/_/g,"-"),y=decodeURIComponent(y),["alpn"].includes(m)?f[m]=y?y.split(","):void 0:["allow-insecure"].includes(m)?f["skip-cert-verify"]=/(TRUE)|1/i.test(y):["fast-open"].includes(m)?f.tfo=!0:["disable-sni","reduce-rtt"].includes(m)?f[m]=/(TRUE)|1/i.test(y):f[m]=y}return f}}}function qB(){return{name:"URI WireGuard Parser",test:n=>/^(wireguard|wg):\/\//.test(n),parse:n=>{n=n.split(/(wireguard|wg):\/\//)[2];let[s,a,i,c,l,h,v,E="",p]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);h=parseInt(`${h}`,10),isNaN(h)&&(h=51820),i=decodeURIComponent(i),p!=null&&(p=decodeURIComponent(p)),p=p??`WireGuard ${c}:${h}`;let f={type:"wireguard",name:p,server:c,port:h,"private-key":i,udp:!0};for(let w of E.split("&")){let[m,y]=w.split("=");if(m=m.replace(/_/,"-"),y=decodeURIComponent(y),["reserved"].includes(m)){let A=y.split(",").map(b=>parseInt(b.trim(),10)).filter(b=>Number.isInteger(b));A.length===3&&(f[m]=A)}else if(["address","ip"].includes(m))y.split(",").map(A=>{let b=A.trim().replace(/\/\d+$/,"").replace(/^\[/,"").replace(/\]$/,"");rr(b)?f.ip=b:nr(b)&&(f.ipv6=b)});else if(["mtu"].includes(m)){let A=parseInt(y.trim(),10);Number.isInteger(A)&&(f[m]=A)}else/publickey/i.test(m)?f["public-key"]=y:/privatekey/i.test(m)?f["private-key"]=y:["udp"].includes(m)?f[m]=/(TRUE)|1/i.test(y):["flag"].includes(m)||(f[m]=y)}return f}}}function KB(){return{name:"URI Trojan Parser",test:n=>/^trojan:\/\//.test(n),parse:n=>{let s=/^(trojan:\/\/.*?@.*?)(:(\d+))?\/?(\?.*?)?$/.exec(n);s?.[2]||(n=n.replace(s[1],`${s[1]}:443`));let[i,c]=n.split(/#(.+)/,2),h=ud().parse(i);if(yi(c))try{h.name=decodeURIComponent(c)}catch(v){console.log(v)}return h}}}function VB(){return{name:"Clash Parser",test:n=>{try{JSON.parse(n)}catch{return!1}return!0},parse:n=>{let s=JSON.parse(n);if(!["anytls","mieru","juicity","ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","hysteria","hysteria2","wireguard","ssh","direct"].includes(s.type))throw new Error(`Clash does not support proxy with type: ${s.type}`);return["vmess","vless"].includes(s.type)&&(s.sni=s.servername,delete s.servername),s["server-cert-fingerprint"]&&(s["tls-fingerprint"]=s["server-cert-fingerprint"]),s.fingerprint&&(s["tls-fingerprint"]=s.fingerprint),s["dialer-proxy"]&&(s["underlying-proxy"]=s["dialer-proxy"]),s["benchmark-url"]&&(s["test-url"]=s["benchmark-url"]),s["benchmark-timeout"]&&(s["test-timeout"]=s["benchmark-timeout"]),s}}}function GB(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>bs().parse(n)}}function zB(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>bs().parse(n)}}function YB(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>bs().parse(n)}}function WB(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>bs().parse(n)}}function XB(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>bs().parse(n)}}function JB(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>bs().parse(n)}}function ZB(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>bs().parse(n)}}function QB(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>$i().parse(n)}}function e7(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>$i().parse(n)}}function t7(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>$i().parse(n)}}function r7(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>$i().parse(n)}}function n7(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>$i().parse(n)}}function i7(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>$i().parse(n)}}function s7(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>$i().parse(n)}}function a7(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>$i().parse(n)}}function u7(){return{name:"Loon WireGuard Parser",test:n=>/^.*=\s*wireguard/i.test(n.split(",")[0]),parse:n=>{let s=n.match(/(^.*?)\s*?=\s*?wireguard\s*?,.+?\s*?=\s*?.+?/i)?.[1];n=n.replace(s,"").replace(/^\s*?=\s*?wireguard\s*/i,"");let a=n.match(/,\s*?peers\s*?=\s*?\[\s*?\{\s*?(.+?)\s*?\}\s*?\]/i)?.[1],i=a.match(/(,|^)\s*?endpoint\s*?=\s*?"?(.+?):(\d+)"?\s*?(,|$)/i),c=i?.[2],l=parseInt(i?.[3],10),h=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];h&&(h=parseInt(h,10));let v=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];v&&(v=parseInt(v,10));let E=a.match(/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i)?.[2];E&&(E=JSON.parse(E));let p,f=n.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],w=n.match(/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];(f||w)&&(p=[],f&&p.push(f),w&&p.push(w));let m=a.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]?.split(",").map(B=>B.trim()),y=a.match(/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],A=n.match(/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],b=n.match(/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],_=a.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],I={type:"wireguard",name:s,server:c,port:l,ip:A,ipv6:b,"private-key":n.match(/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],"public-key":_,mtu:h,keepalive:v,reserved:E,"allowed-ips":m,"preshared-key":y,dns:p,udp:!0,peers:[{server:c,port:l,ip:A,ipv6:b,"public-key":_,"pre-shared-key":y,"allowed-ips":m,reserved:E}]};return Array.isArray(I.dns)&&I.dns.length>0&&(I["remote-dns-resolve"]=!0),I}}}function o7(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>Bn().parse(n)}}function c7(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>Bn().parse(n)}}function l7(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>Bn().parse(n)}}function f7(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>Bn().parse(n)}}function h7(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>Bn().parse(n)}}function p7(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0]),parse:n=>Bn().parse(n)}}function d7(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0]),parse:n=>Bn().parse(n)}}function g7(){return{name:"Surge External Parser",test:n=>/^.*=\s*external/.test(n.split(",")[0]),parse:n=>{let s=/^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(n),[a,i,c]=s;n=c;let l=/(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];l||(l=/(,|^)\s*?exec\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let h=/(,|^)\s*?local-port\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];h||(h=/(,|^)\s*?local-port\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let v=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,E,p=[];for(;(E=v.exec(n))!==null;)E[3]!=null?p.push(E[3]):E[4]!=null&&p.push(E[4]);let f=/(,|^)\s*?addresses\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,w,m=[];for(;(w=f.exec(n))!==null;){let A;w[3]!=null?A=w[3]:w[4]!=null&&(A=w[4]),A!=null&&(A=`${A}`.trim().replace(/^\[/,"").replace(/\]$/,"")),E7(A)&&m.push(A)}return{type:"external",name:i,exec:l,"local-port":h,args:p,addresses:m}}}}function m7(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>Bn().parse(n)}}function v7(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:s,line:a}=lw(n),i=Bn().parse(a);return i.ports=s,i}}}function A7(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>Bn().parse(n)}}function w7(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:s,line:a}=lw(n),i=Bn().parse(a);return i.ports=s,i}}}function E7(e){return rr(e)||nr(e)}var fw=[TB(),xB(),OB(),kB(),NB(),LB(),MB(),qB(),jB(),HB(),KB(),UB(),VB(),o7(),c7(),l7(),f7(),h7(),p7(),m7(),v7(),A7(),w7(),d7(),g7(),QB(),e7(),t7(),r7(),i7(),n7(),s7(),a7(),u7(),GB(),zB(),YB(),WB(),XB(),JB(),ZB()];function y7(e){for(let t of Ff)try{if(t.test(e))return ne.info(`Pre-processor [${t.name}] activated`),t.parse(e)}catch(r){ne.error(`Parser [${t.name}] failed Reason: ${r}`)}return e}function S7(e){e=y7(e);let t=e.split(` `),r=[],n;for(let s of t){if(s=s.trim(),s.length===0)continue;let a=!1;if(n){let[i,c]=hw(n,s);c||(r.push(dw(i)),a=!0)}if(!a)for(let i of fw){let[c,l]=hw(i,s);if(!l){r.push(dw(c)),n=i,a=!0,ne.info(`${i.name} is activated`);break}}a||ne.error(`Failed to parse line: ${s}`)}return r.filter(s=>(["vless","vmess"].includes(s.type)&&(wf(s.uuid)||ne.error(`UUID may be invalid: ${s.name} ${s.uuid}`)),!0))}async function b7(e,t=[],r,n,s){for(let a of t){if(a.disabled){ne.log(`Skipping disabled operator: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}let i,c={};if(a.type.indexOf("Script")!==-1){let{mode:h,content:v}=a.args;if(h==="link"){let E=v||"",p=E.split("#");if(p.length>1)try{c=JSON.parse(decodeURIComponent(p[1]))}catch{for(let m of p[1].split("&")){let y=m.split("=")[0],A=m.split("=")[1];c[y]=A==null||A===""?!0:decodeURIComponent(A)}}E=`${E.split("#")[0]}${p[2]?`#${p[2]}`:c?.noCache!=null||c?.insecure!=null?`#${p[1]}`:""}`;let f=E.match(/^\/api\/(file|module)\/(.+)/);if(f){let w="";try{w=f?.[1];let m=f?.[2];if(m==null)throw new Error(`\u672C\u5730 ${w} URL \u65E0\u6548: ${E}`);m=decodeURIComponent(m);let y=w==="module"?Nv:sf,A=As(ne.read(y),m);if(!A)throw new Error(`\u627E\u4E0D\u5230 ${w}: ${m}`);w==="module"?i=A.content:i=await so({type:"file",name:m})}catch(m){throw ne.error(`Error when loading ${w}: ${a.args.content}. Reason: ${m}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${w}: ${E}`)}}else try{i=await Or(E)}catch(w){throw ne.error(`Error when downloading remote script: ${a.args.content}. Reason: ${w}`),new Error(`\u65E0\u6CD5\u4E0B\u8F7D\u811A\u672C: ${E}`)}}else i=v,c=a.args.arguments||{}}if(!xf[a.type]){ne.error(`Unknown operator: "${a.type}"`);continue}ne.log(`Applying "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);let l;a.type.indexOf("Script")!==-1?l=xf[a.type](i,r,c,n,s):l=xf[a.type](a.args||{}),e=await z2(l,e)}return e}function C7(e,t,r,n={}){let s=eA[t];if(!s)throw new Error(`Target platform: ${t} is not supported!`);let a=/Surge|SurgeMac|Shadowrocket/i.test(t);if(e=e.filter(i=>i.supported&&i.supported[t]===!1?!1:(["vless","vmess"].includes(i.type)&&(wf(i.uuid)||ne.error(`UUID may be invalid: ${i.name} ${i.uuid}`)),!0)),e=e.map(i=>(i._resolved=i.resolved,yi(i.name)||(i.name=`${i.type} ${i.server}:${i.port}`),i["disable-sni"]&&(a?i.sni="off":["tuic"].includes(i.type)||(ne.error(`Target platform ${t} does not support sni off. Proxy's fields (sni, tls-fingerprint and skip-cert-verify) will be modified.`),i.sni="",i["skip-cert-verify"]=!0,delete i["tls-fingerprint"])),i.ports&&(i.ports=String(i.ports),["ClashMeta"].includes(t)||(i.ports=i.ports.replace(/\//g,",")),i.port||(i.port=vc(i.ports))),i)),ne.log(`Producing proxies for target: ${t}`),typeof s.type>"u"||s.type==="SINGLE"){let i=e.map(c=>{try{return s.produce(c,r,n)}catch(l){return ne.error(`Cannot produce proxy: ${JSON.stringify(c,null,2)} Reason: ${l}`),""}}).filter(c=>c.length>0);return i=r==="internal"?i:i.join(` `),t.startsWith("Surge")&&e.length>0&&e.every(c=>c.type==="wireguard")&&(i=`#!name=${e[0]?._subName} #!desc=${e[0]?._desc??""} #!category=${e[0]?._category??""} ${i}`),i}else if(s.type==="ALL")return s.produce(e,r,n)}var dr={parse:S7,process:b7,produce:C7,ipAddress:Af,getRandomPort:vc,isIPv4:rr,isIPv6:nr,isIP:cd,yaml:Oa,getFlag:eo,removeFlag:yc,getISO:b2,MMDB:If,Gist:io,download:Or,isValidUUID:wf,doh:ro};function hw(e,t){if(!F7(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function F7(e,t){try{return e.test(t)}catch{return!1}}function pw(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function dw(e){typeof e.cipher=="string"&&(e.cipher=e.cipher.toLowerCase()),typeof e.password=="number"&&(e.password=t2(e.password)),["ss"].includes(e.type)&&e.cipher==="none"&&!e.password&&(e.password=""),e.interface&&(e["interface-name"]=e.interface,delete e.interface),e2(e.port)&&(e.port=parseInt(e.port,10)),e.server&&(e.server=`${e.server}`.trim().replace(/^\[/,"").replace(/\]$/,"")),e.network==="ws"&&(!e["ws-opts"]&&(e["ws-path"]||e["ws-headers"])&&(e["ws-opts"]={},e["ws-path"]&&(e["ws-opts"].path=e["ws-path"]),e["ws-headers"]&&(e["ws-opts"].headers=e["ws-headers"])),delete e["ws-path"],delete e["ws-headers"]);let t=e[`${e.network}-opts`]?.path;if(Array.isArray(t)?e[`${e.network}-opts`].path=t.map(n=>pw(n)):t!=null&&(e[`${e.network}-opts`].path=pw(t)),e.type==="trojan"&&e.network==="tcp"&&delete e.network,["vless"].includes(e.type)&&(e.network||(e.network="tcp")),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(e.type)&&(e.tls=!0),e.network){let n=e[`${e.network}-opts`]?.headers?.Host,s=e[`${e.network}-opts`]?.headers?.host;e.network==="h2"?!s&&n&&(e[`${e.network}-opts`].headers.host=n,delete e[`${e.network}-opts`].headers.Host):s&&!n&&(e[`${e.network}-opts`].headers.Host=s,delete e[`${e.network}-opts`].headers.host)}if(e.network==="h2"){let n=e["h2-opts"]?.headers?.host,s=e["h2-opts"]?.path;n&&!Array.isArray(n)&&(e["h2-opts"].headers.host=[n]),Array.isArray(s)&&(e["h2-opts"].path=s[0])}if(!e.tls&&["ws","http"].includes(e.network)&&!e[`${e.network}-opts`]?.headers?.Host&&!cd(e.server)&&(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].headers=e[`${e.network}-opts`].headers||{},e[`${e.network}-opts`].headers.Host=["vmess","vless"].includes(e.type)&&e.network==="http"?[e.server]:e.server),["vmess","vless"].includes(e.type)&&e.network==="http"){let n=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;s&&!Array.isArray(s)&&(e[`${e.network}-opts`].headers.Host=[s]),n&&!Array.isArray(n)&&(e[`${e.network}-opts`].path=[n])}if(e.tls&&!e.sni&&(cd(e.server)||(e.sni=e.server),!e.sni&&e.network)){let n=e[`${e.network}-opts`]?.headers?.Host;n=Array.isArray(n)?n[0]:n,n&&(e.sni=n)}if(e.ports?e.ports=String(e.ports).replace(/\//g,","):delete e.ports,["hysteria2"].includes(e.type)&&e.obfs&&!["salamander"].includes(e.obfs)&&!e["obfs-password"]&&(e["obfs-password"]=e.obfs,e.obfs="salamander"),["hysteria2"].includes(e.type)&&!e["obfs-password"]&&e.obfs_password&&(e["obfs-password"]=e.obfs_password,delete e.obfs_password),["vless"].includes(e.type)&&(e["reality-opts"]&&Object.keys(e["reality-opts"]).length===0&&delete e["reality-opts"],e["grpc-opts"]&&Object.keys(e["grpc-opts"]).length===0&&delete e["grpc-opts"],!e["reality-opts"]&&!e.flow&&delete e.flow,["http"].includes(e.network)&&(e[`${e.network}-opts`]?.path||(e[`${e.network}-opts`]||(e[`${e.network}-opts`]={}),e[`${e.network}-opts`].path=["/"]))),typeof e.name!="string")if(/^\d+$/.test(e.name))e.name=`${e.name}`;else try{e.name?.data?e.name=od.Buffer.from(e.name.data).toString("utf8"):e.name=od.Buffer.from(e.name).toString("utf8")}catch(n){ne.error(`proxy.name decode failed Reason: ${n}`),e.name=`${e.type} ${e.server}:${e.port}`}["ws","http","h2"].includes(e.network)&&(["ws","h2"].includes(e.network)&&!e[`${e.network}-opts`]?.path?(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].path="/"):e.network==="http"&&(!Array.isArray(e[`${e.network}-opts`]?.path)||e[`${e.network}-opts`]?.path.every(n=>!n))&&(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].path=["/"])),["","off"].includes(e.sni)&&(e["disable-sni"]=!0);let r=e.ca_str;e["ca-str"]?r=e["ca-str"]:r&&(delete e.ca_str,e["ca-str"]=r);try{ne.env.isNode&&!r&&e._ca&&(r=ne.node.fs.readFileSync(e._ca,{encoding:"utf8"}))}catch(n){ne.error(`Read ca file failed Reason: ${n}`)}return!e["tls-fingerprint"]&&r&&(e["tls-fingerprint"]=jg.generateFingerprint(r)),["ss"].includes(e.type)&&se(e,"shadow-tls-password")&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e["shadow-tls-sni"],password:e["shadow-tls-password"],version:e["shadow-tls-version"]},delete e["shadow-tls-sni"],delete e["shadow-tls-password"],delete e["shadow-tls-version"]),e}function cd(e){return rr(e)||nr(e)}var Ri="",ld=typeof $resource<"u"?$resource:"",gw=typeof $resourceType<"u"?$resourceType:"",lo=typeof $resourceUrl<"u"?$resourceUrl:"";(async()=>{console.log(` \u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505 Sub-Store -- v${$f} Loon -- ${$loon} \u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505 `);let e=$loon.match(/\((\d+)\)$/)?.[1],t;typeof $argument<"u"?t=Object.fromEntries($argument.split("&").map(n=>n.split("="))):t={},console.log(`arg: ${JSON.stringify(t)}`);let r={PROXY:1,RULE:2};if(t.resourceUrlOnly||(Ri=ld),gw===r.PROXY){if(!t.resourceUrlOnly)try{let n=dr.parse(ld);Ri=dr.produce(n,"Loon",void 0,{"include-unsupported-proxy":t?.includeUnsupportedProxy||e>=842})}catch(n){console.log("\u89E3\u6790\u5668: \u4F7F\u7528 resource \u51FA\u73B0\u9519\u8BEF"),console.log(n.message??n)}if((!Ri||/^\s*$/.test(Ri))&&lo){console.log(`\u89E3\u6790\u5668: \u5C1D\u8BD5\u4ECE ${lo} \u83B7\u53D6\u8BA2\u9605`);try{let n=await Or(lo,t?.ua,t?.timeout,void 0,void 0,void 0,void 0,!0),s=dr.parse(n);Ri=dr.produce(s,"Loon",void 0,{"include-unsupported-proxy":t?.includeUnsupportedProxy||e>=842})}catch(n){console.log(n.message??n)}}}else if(gw===r.RULE){if(!t.resourceUrlOnly)try{let n=ws.parse(ld);Ri=ws.produce(n,"Loon")}catch(n){console.log(n.message??n)}if((!Ri||/^\s*$/.test(Ri))&&lo){console.log(`\u89E3\u6790\u5668: \u5C1D\u8BD5\u4ECE ${lo} \u83B7\u53D6\u89C4\u5219`);try{let n=await Or(lo,t?.ua,t?.timeout),s=ws.parse(n);Ri=ws.produce(s,"Loon")}catch(n){console.log(n.message??n)}}}})().catch(async e=>{console.log("\u89E3\u6790\u5668: \u51FA\u73B0\u9519\u8BEF"),console.log(e.message??e)}).finally(()=>{$done(Ri||"")});})(); /*! Bundled license information: ieee754/index.js: (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) buffer/index.js: (*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT *) jsrsasign/lib/jsrsasign.js: (*! CryptoJS v3.1.2 core-fix.js * code.google.com/p/crypto-js * (c) 2009-2013 by Jeff Mott. All rights reserved. * code.google.com/p/crypto-js/wiki/License * THIS IS FIX of 'core.js' to fix Hmac issue. * https://code.google.com/p/crypto-js/issues/detail?id=84 * https://crypto-js.googlecode.com/svn-history/r667/branches/3.x/src/core.js *) (*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ *) (*! (c) Tom Wu, Kenji Urushima | http://www-cs-students.stanford.edu/~tjw/jsbn/ *) (*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib *) (*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval *) lodash/lodash.js: (** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors *) */