(()=>{var q3=Object.create;var zg=Object.defineProperty;var V3=Object.getOwnPropertyDescriptor;var K3=Object.getOwnPropertyNames;var G3=Object.getPrototypeOf,z3=Object.prototype.hasOwnProperty;var Aa=(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 De=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var W3=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of K3(t))!z3.call(e,s)&&s!==r&&zg(e,s,{get:()=>t[s],enumerable:!(n=V3(t,s))||n.enumerable});return e};var jr=(e,t,r)=>(r=e!=null?q3(G3(e)):{},W3(t||!e||!e.__esModule?zg(r,"default",{value:e,enumerable:!0}):r,e));var Xg=De(Yg=>{"use strict";(function(e){function t(){}function r(){}var n=String.fromCharCode,s={}.toString,u=s.call(e.SharedArrayBuffer),i=s(),o=e.Uint8Array,l=o||Array,h=o?ArrayBuffer:l,p=h.isView||function(w){return w&&"length"in w},E=s.call(h.prototype);h=r.prototype;var d=e.TextEncoder,f=new(o?Uint16Array:l)(32);t.prototype.decode=function(w){if(!p(w)){var g=s.call(w);if(g!==E&&g!==u&&g!==i)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");w=o?new l(w):w||[]}for(var F=g="",A=0,C=w.length|0,S=C-32|0,I,_,L=0,M=0,b,B=0,k=-1;A>4){case 15:if(b=w[A=A+1|0]&255,b>>6!==2||247<_){A=A-1|0;break}L=(_&7)<<6|b&63,M=5,_=256;case 14:b=w[A=A+1|0]&255,L<<=6,L|=(_&15)<<6|b&63,M=b>>6===2?M+4|0:24,_=_+256&768;case 13:case 12:b=w[A=A+1|0]&255,L<<=6,L|=(_&31)<<6|b&63,M=M+7|0,A>6===2&&L>>M&&1114112>L?(_=L,L=L-65536|0,0<=L&&(k=(L>>10)+55296|0,_=(L&1023)+56320|0,31>B?(f[B]=k,B=B+1|0,k=-1):(b=k,k=_,_=b))):(_>>=8,A=A-_-1|0,_=65533),L=M=0,I=A<=S?32:C-A|0;default:f[B]=_;continue;case 11:case 10:case 9:case 8:}f[B]=65533}if(F+=n(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9],f[10],f[11],f[12],f[13],f[14],f[15],f[16],f[17],f[18],f[19],f[20],f[21],f[22],f[23],f[24],f[25],f[26],f[27],f[28],f[29],f[30],f[31]),32>B&&(F=F.slice(0,B-32|0)),A>>31,k=-1,F.length=I)F[C]=I;else{if(2047>=I)F[C]=192|I>>6;else{e:{if(55296<=I)if(56319>=I){var _=w.charCodeAt(A=A+1|0)|0;if(56320<=_&&57343>=_){if(I=(I<<10)+_-56613888|0,65535>18,F[C=C+1|0]=128|I>>12&63,F[C=C+1|0]=128|I>>6&63,F[C=C+1|0]=128|I&63;continue}break e}I=65533}else 57343>=I&&(I=65533);!S&&A<<1>12,F[C=C+1|0]=128|I>>6&63}F[C=C+1|0]=128|I&63}}return o?F.subarray(0,C):F.slice(0,C)},d||(e.TextDecoder=t,e.TextEncoder=r)})(typeof global>"u"?typeof self>"u"?Yg:self:global)});var z0=De((nR,Em)=>{var gy=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};Em.exports=gy});var W0=De((iR,Am)=>{var my="2.0.0",vy=Number.MAX_SAFE_INTEGER||9007199254740991,Ey=16,Ay=250,wy=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Am.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:Ey,MAX_SAFE_BUILD_LENGTH:Ay,MAX_SAFE_INTEGER:vy,RELEASE_TYPES:wy,SEMVER_SPEC_VERSION:my,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var J0=De((eu,wm)=>{var{MAX_SAFE_COMPONENT_LENGTH:Y0,MAX_SAFE_BUILD_LENGTH:Cy,MAX_LENGTH:Fy}=W0(),Dy=z0();eu=wm.exports={};var yy=eu.re=[],Sy=eu.safeRe=[],Le=eu.src=[],Ue=eu.t={},by=0,X0="[a-zA-Z0-9-]",_y=[["\\s",1],["\\d",Fy],[X0,Cy]],Iy=e=>{for(let[t,r]of _y)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},ft=(e,t,r)=>{let n=Iy(t),s=by++;Dy(e,s,t),Ue[e]=s,Le[s]=t,yy[s]=new RegExp(t,r?"g":void 0),Sy[s]=new RegExp(n,r?"g":void 0)};ft("NUMERICIDENTIFIER","0|[1-9]\\d*");ft("NUMERICIDENTIFIERLOOSE","\\d+");ft("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${X0}*`);ft("MAINVERSION",`(${Le[Ue.NUMERICIDENTIFIER]})\\.(${Le[Ue.NUMERICIDENTIFIER]})\\.(${Le[Ue.NUMERICIDENTIFIER]})`);ft("MAINVERSIONLOOSE",`(${Le[Ue.NUMERICIDENTIFIERLOOSE]})\\.(${Le[Ue.NUMERICIDENTIFIERLOOSE]})\\.(${Le[Ue.NUMERICIDENTIFIERLOOSE]})`);ft("PRERELEASEIDENTIFIER",`(?:${Le[Ue.NUMERICIDENTIFIER]}|${Le[Ue.NONNUMERICIDENTIFIER]})`);ft("PRERELEASEIDENTIFIERLOOSE",`(?:${Le[Ue.NUMERICIDENTIFIERLOOSE]}|${Le[Ue.NONNUMERICIDENTIFIER]})`);ft("PRERELEASE",`(?:-(${Le[Ue.PRERELEASEIDENTIFIER]}(?:\\.${Le[Ue.PRERELEASEIDENTIFIER]})*))`);ft("PRERELEASELOOSE",`(?:-?(${Le[Ue.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${Le[Ue.PRERELEASEIDENTIFIERLOOSE]})*))`);ft("BUILDIDENTIFIER",`${X0}+`);ft("BUILD",`(?:\\+(${Le[Ue.BUILDIDENTIFIER]}(?:\\.${Le[Ue.BUILDIDENTIFIER]})*))`);ft("FULLPLAIN",`v?${Le[Ue.MAINVERSION]}${Le[Ue.PRERELEASE]}?${Le[Ue.BUILD]}?`);ft("FULL",`^${Le[Ue.FULLPLAIN]}$`);ft("LOOSEPLAIN",`[v=\\s]*${Le[Ue.MAINVERSIONLOOSE]}${Le[Ue.PRERELEASELOOSE]}?${Le[Ue.BUILD]}?`);ft("LOOSE",`^${Le[Ue.LOOSEPLAIN]}$`);ft("GTLT","((?:<|>)?=?)");ft("XRANGEIDENTIFIERLOOSE",`${Le[Ue.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);ft("XRANGEIDENTIFIER",`${Le[Ue.NUMERICIDENTIFIER]}|x|X|\\*`);ft("XRANGEPLAIN",`[v=\\s]*(${Le[Ue.XRANGEIDENTIFIER]})(?:\\.(${Le[Ue.XRANGEIDENTIFIER]})(?:\\.(${Le[Ue.XRANGEIDENTIFIER]})(?:${Le[Ue.PRERELEASE]})?${Le[Ue.BUILD]}?)?)?`);ft("XRANGEPLAINLOOSE",`[v=\\s]*(${Le[Ue.XRANGEIDENTIFIERLOOSE]})(?:\\.(${Le[Ue.XRANGEIDENTIFIERLOOSE]})(?:\\.(${Le[Ue.XRANGEIDENTIFIERLOOSE]})(?:${Le[Ue.PRERELEASELOOSE]})?${Le[Ue.BUILD]}?)?)?`);ft("XRANGE",`^${Le[Ue.GTLT]}\\s*${Le[Ue.XRANGEPLAIN]}$`);ft("XRANGELOOSE",`^${Le[Ue.GTLT]}\\s*${Le[Ue.XRANGEPLAINLOOSE]}$`);ft("COERCEPLAIN",`(^|[^\\d])(\\d{1,${Y0}})(?:\\.(\\d{1,${Y0}}))?(?:\\.(\\d{1,${Y0}}))?`);ft("COERCE",`${Le[Ue.COERCEPLAIN]}(?:$|[^\\d])`);ft("COERCEFULL",Le[Ue.COERCEPLAIN]+`(?:${Le[Ue.PRERELEASE]})?(?:${Le[Ue.BUILD]})?(?:$|[^\\d])`);ft("COERCERTL",Le[Ue.COERCE],!0);ft("COERCERTLFULL",Le[Ue.COERCEFULL],!0);ft("LONETILDE","(?:~>?)");ft("TILDETRIM",`(\\s*)${Le[Ue.LONETILDE]}\\s+`,!0);eu.tildeTrimReplace="$1~";ft("TILDE",`^${Le[Ue.LONETILDE]}${Le[Ue.XRANGEPLAIN]}$`);ft("TILDELOOSE",`^${Le[Ue.LONETILDE]}${Le[Ue.XRANGEPLAINLOOSE]}$`);ft("LONECARET","(?:\\^)");ft("CARETTRIM",`(\\s*)${Le[Ue.LONECARET]}\\s+`,!0);eu.caretTrimReplace="$1^";ft("CARET",`^${Le[Ue.LONECARET]}${Le[Ue.XRANGEPLAIN]}$`);ft("CARETLOOSE",`^${Le[Ue.LONECARET]}${Le[Ue.XRANGEPLAINLOOSE]}$`);ft("COMPARATORLOOSE",`^${Le[Ue.GTLT]}\\s*(${Le[Ue.LOOSEPLAIN]})$|^$`);ft("COMPARATOR",`^${Le[Ue.GTLT]}\\s*(${Le[Ue.FULLPLAIN]})$|^$`);ft("COMPARATORTRIM",`(\\s*)${Le[Ue.GTLT]}\\s*(${Le[Ue.LOOSEPLAIN]}|${Le[Ue.XRANGEPLAIN]})`,!0);eu.comparatorTrimReplace="$1$2$3";ft("HYPHENRANGE",`^\\s*(${Le[Ue.XRANGEPLAIN]})\\s+-\\s+(${Le[Ue.XRANGEPLAIN]})\\s*$`);ft("HYPHENRANGELOOSE",`^\\s*(${Le[Ue.XRANGEPLAINLOOSE]})\\s+-\\s+(${Le[Ue.XRANGEPLAINLOOSE]})\\s*$`);ft("STAR","(<|>)?=?\\s*\\*");ft("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");ft("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var Fm=De((sR,Cm)=>{var By=Object.freeze({loose:!0}),$y=Object.freeze({}),Py=e=>e?typeof e!="object"?By:e:$y;Cm.exports=Py});var bm=De((uR,Sm)=>{var Dm=/^[0-9]+$/,ym=(e,t)=>{let r=Dm.test(e),n=Dm.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:eym(t,e);Sm.exports={compareIdentifiers:ym,rcompareIdentifiers:Ry}});var uf=De((aR,$m)=>{var nf=z0(),{MAX_LENGTH:_m,MAX_SAFE_INTEGER:sf}=W0(),{safeRe:Im,t:Bm}=J0(),Ty=Fm(),{compareIdentifiers:mo}=bm(),Z0=class e{constructor(t,r){if(r=Ty(r),t instanceof e){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>_m)throw new TypeError(`version is longer than ${_m} characters`);nf("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let n=t.trim().match(r.loose?Im[Bm.LOOSE]:Im[Bm.FULL]);if(!n)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>sf||this.major<0)throw new TypeError("Invalid major version");if(this.minor>sf||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>sf||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(s=>{if(/^[0-9]+$/.test(s)){let u=+s;if(u>=0&&u=0;)typeof this.prerelease[u]=="number"&&(this.prerelease[u]++,u=-2);if(u===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(s)}}if(r){let u=[r,s];n===!1&&(u=[r]),mo(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=u):this.prerelease=u}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};$m.exports=Z0});var Tm=De((oR,Rm)=>{var Pm=uf(),Oy=(e,t,r)=>new Pm(e,r).compare(new Pm(t,r));Rm.exports=Oy});var km=De((cR,Om)=>{var ky=Tm(),Ny=(e,t,r)=>ky(e,t,r)>=0;Om.exports=Ny});var Lm=De((lR,xm)=>{var Nm=uf(),xy=(e,t,r=!1)=>{if(e instanceof Nm)return e;try{return new Nm(e,t)}catch(n){if(!r)return null;throw n}};xm.exports=xy});var jm=De((fR,Um)=>{var Ly=uf(),Uy=Lm(),{safeRe:af,t:of}=J0(),jy=(e,t)=>{if(e instanceof Ly)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?af[of.COERCEFULL]:af[of.COERCE]);else{let l=t.includePrerelease?af[of.COERCERTLFULL]:af[of.COERCERTL],h;for(;(h=l.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||h.index+h[0].length!==r.index+r[0].length)&&(r=h),l.lastIndex=h.index+h[1].length+h[2].length;l.lastIndex=-1}if(r===null)return null;let n=r[2],s=r[3]||"0",u=r[4]||"0",i=t.includePrerelease&&r[5]?`-${r[5]}`:"",o=t.includePrerelease&&r[6]?`+${r[6]}`:"";return Uy(`${n}.${s}.${u}${i}${o}`,t)};Um.exports=jy});var Km=De(cf=>{"use strict";cf.byteLength=qy;cf.toByteArray=Ky;cf.fromByteArray=Wy;var hs=[],Ti=[],My=typeof Uint8Array<"u"?Uint8Array:Array,tp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Da=0,qm=tp.length;Da0)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 qy(e){var t=Vm(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Vy(e,t,r){return(t+r)*3/4-r}function Ky(e){var t,r=Vm(e),n=r[0],s=r[1],u=new My(Vy(e,n,s)),i=0,o=s>0?n-4:n,l;for(l=0;l>16&255,u[i++]=t>>8&255,u[i++]=t&255;return s===2&&(t=Ti[e.charCodeAt(l)]<<2|Ti[e.charCodeAt(l+1)]>>4,u[i++]=t&255),s===1&&(t=Ti[e.charCodeAt(l)]<<10|Ti[e.charCodeAt(l+1)]<<4|Ti[e.charCodeAt(l+2)]>>2,u[i++]=t>>8&255,u[i++]=t&255),u}function Gy(e){return hs[e>>18&63]+hs[e>>12&63]+hs[e>>6&63]+hs[e&63]}function zy(e,t,r){for(var n,s=[],u=t;uo?o:i+u));return n===1?(t=e[r-1],s.push(hs[t>>2]+hs[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],s.push(hs[t>>10]+hs[t>>4&63]+hs[t<<2&63]+"=")),s.join("")}});var Gm=De(rp=>{rp.read=function(e,t,r,n,s){var u,i,o=s*8-n-1,l=(1<>1,p=-7,E=r?s-1:0,d=r?-1:1,f=e[t+E];for(E+=d,u=f&(1<<-p)-1,f>>=-p,p+=o;p>0;u=u*256+e[t+E],E+=d,p-=8);for(i=u&(1<<-p)-1,u>>=-p,p+=n;p>0;i=i*256+e[t+E],E+=d,p-=8);if(u===0)u=1-h;else{if(u===l)return i?NaN:(f?-1:1)*(1/0);i=i+Math.pow(2,n),u=u-h}return(f?-1:1)*i*Math.pow(2,u-n)};rp.write=function(e,t,r,n,s,u){var i,o,l,h=u*8-s-1,p=(1<>1,d=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:u-1,w=n?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,i=p):(i=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-i))<1&&(i--,l*=2),i+E>=1?t+=d/l:t+=d*Math.pow(2,1-E),t*l>=2&&(i++,l/=2),i+E>=p?(o=0,i=p):i+E>=1?(o=(t*l-1)*Math.pow(2,s),i=i+E):(o=t*Math.pow(2,E-1)*Math.pow(2,s),i=0));s>=8;e[r+f]=o&255,f+=w,o/=256,s-=8);for(i=i<0;e[r+f]=i&255,f+=w,i/=256,h-=8);e[r+f-w]|=g*128}});var hf=De(wo=>{"use strict";var np=Km(),Eo=Gm(),zm=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;wo.Buffer=pe;wo.SlowBuffer=e5;wo.INSPECT_MAX_BYTES=50;var lf=2147483647;wo.kMaxLength=lf;pe.TYPED_ARRAY_SUPPORT=Yy();!pe.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 Yy(){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(pe.prototype,"parent",{enumerable:!0,get:function(){if(pe.isBuffer(this))return this.buffer}});Object.defineProperty(pe.prototype,"offset",{enumerable:!0,get:function(){if(pe.isBuffer(this))return this.byteOffset}});function tu(e){if(e>lf)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,pe.prototype),t}function pe(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 ap(e)}return Jm(e,t,r)}pe.poolSize=8192;function Jm(e,t,r){if(typeof e=="string")return Jy(e,t);if(ArrayBuffer.isView(e))return Zy(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(ps(e,ArrayBuffer)||e&&ps(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ps(e,SharedArrayBuffer)||e&&ps(e.buffer,SharedArrayBuffer)))return sp(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 pe.from(n,t,r);let s=Qy(e);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return pe.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)}pe.from=function(e,t,r){return Jm(e,t,r)};Object.setPrototypeOf(pe.prototype,Uint8Array.prototype);Object.setPrototypeOf(pe,Uint8Array);function Zm(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 Xy(e,t,r){return Zm(e),e<=0?tu(e):t!==void 0?typeof r=="string"?tu(e).fill(t,r):tu(e).fill(t):tu(e)}pe.alloc=function(e,t,r){return Xy(e,t,r)};function ap(e){return Zm(e),tu(e<0?0:op(e)|0)}pe.allocUnsafe=function(e){return ap(e)};pe.allocUnsafeSlow=function(e){return ap(e)};function Jy(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!pe.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=Qm(e,t)|0,n=tu(r),s=n.write(e,t);return s!==r&&(n=n.slice(0,s)),n}function ip(e){let t=e.length<0?0:op(e.length)|0,r=tu(t);for(let n=0;n=lf)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+lf.toString(16)+" bytes");return e|0}function e5(e){return+e!=e&&(e=0),pe.alloc(+e)}pe.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==pe.prototype};pe.compare=function(t,r){if(ps(t,Uint8Array)&&(t=pe.from(t,t.offset,t.byteLength)),ps(r,Uint8Array)&&(r=pe.from(r,r.offset,r.byteLength)),!pe.isBuffer(t)||!pe.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 u=0,i=Math.min(n,s);us.length?(pe.isBuffer(i)||(i=pe.from(i)),i.copy(s,u)):Uint8Array.prototype.set.call(s,i,u);else if(pe.isBuffer(i))i.copy(s,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=i.length}return s};function Qm(e,t){if(pe.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||ps(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 up(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return ov(e).length;default:if(s)return n?-1:up(e).length;t=(""+t).toLowerCase(),s=!0}}pe.byteLength=Qm;function t5(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 f5(this,t,r);case"utf8":case"utf-8":return tv(this,t,r);case"ascii":return c5(this,t,r);case"latin1":case"binary":return l5(this,t,r);case"base64":return a5(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h5(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}pe.prototype._isBuffer=!0;function ya(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}pe.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+=" ... "),""};zm&&(pe.prototype[zm]=pe.prototype.inspect);pe.prototype.compare=function(t,r,n,s,u){if(ps(t,Uint8Array)&&(t=pe.from(t,t.offset,t.byteLength)),!pe.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),u===void 0&&(u=this.length),r<0||n>t.length||s<0||u>this.length)throw new RangeError("out of range index");if(s>=u&&r>=n)return 0;if(s>=u)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,s>>>=0,u>>>=0,this===t)return 0;let i=u-s,o=n-r,l=Math.min(i,o),h=this.slice(s,u),p=t.slice(r,n);for(let E=0;E2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,lp(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=pe.from(t,n)),pe.isBuffer(t))return t.length===0?-1:Wm(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):Wm(e,[t],r,n,s);throw new TypeError("val must be string, number or Buffer")}function Wm(e,t,r,n,s){let u=1,i=e.length,o=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;u=2,i/=2,o/=2,r/=2}function l(p,E){return u===1?p[E]:p.readUInt16BE(E*u)}let h;if(s){let p=-1;for(h=r;hi&&(r=i-o),h=r;h>=0;h--){let p=!0;for(let E=0;Es&&(n=s)):n=s;let u=t.length;n>u/2&&(n=u/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 u=this.length-r;if((n===void 0||n>u)&&(n=u),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 r5(this,t,r,n);case"utf8":case"utf-8":return n5(this,t,r,n);case"ascii":case"latin1":case"binary":return i5(this,t,r,n);case"base64":return s5(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u5(this,t,r,n);default:if(i)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),i=!0}};pe.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function a5(e,t,r){return t===0&&r===e.length?np.fromByteArray(e):np.fromByteArray(e.slice(t,r))}function tv(e,t,r){r=Math.min(e.length,r);let n=[],s=t;for(;s239?4:u>223?3:u>191?2:1;if(s+o<=r){let l,h,p,E;switch(o){case 1:u<128&&(i=u);break;case 2:l=e[s+1],(l&192)===128&&(E=(u&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=(u&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],p=e[s+3],(l&192)===128&&(h&192)===128&&(p&192)===128&&(E=(u&15)<<18|(l&63)<<12|(h&63)<<6|p&63,E>65535&&E<1114112&&(i=E))}}i===null?(i=65533,o=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),s+=o}return o5(n)}var Ym=4096;function o5(e){let t=e.length;if(t<=Ym)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn)&&(r=n);let s="";for(let u=t;un&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}pe.prototype.readUintLE=pe.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Mr(t,r,this.length);let s=this[t],u=1,i=0;for(;++i>>0,r=r>>>0,n||Mr(t,r,this.length);let s=this[t+--r],u=1;for(;r>0&&(u*=256);)s+=this[t+--r]*u;return s};pe.prototype.readUint8=pe.prototype.readUInt8=function(t,r){return t=t>>>0,r||Mr(t,1,this.length),this[t]};pe.prototype.readUint16LE=pe.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Mr(t,2,this.length),this[t]|this[t+1]<<8};pe.prototype.readUint16BE=pe.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Mr(t,2,this.length),this[t]<<8|this[t+1]};pe.prototype.readUint32LE=pe.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Mr(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};pe.prototype.readUint32BE=pe.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Mr(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};pe.prototype.readBigUInt64LE=ju(function(t){t=t>>>0,Ao(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Dc(t,this.length-8);let s=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,u=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(s)+(BigInt(u)<>>0,Ao(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Dc(t,this.length-8);let s=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],u=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(s)<>>0,r=r>>>0,n||Mr(t,r,this.length);let s=this[t],u=1,i=0;for(;++i=u&&(s-=Math.pow(2,8*r)),s};pe.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Mr(t,r,this.length);let s=r,u=1,i=this[t+--s];for(;s>0&&(u*=256);)i+=this[t+--s]*u;return u*=128,i>=u&&(i-=Math.pow(2,8*r)),i};pe.prototype.readInt8=function(t,r){return t=t>>>0,r||Mr(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};pe.prototype.readInt16LE=function(t,r){t=t>>>0,r||Mr(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};pe.prototype.readInt16BE=function(t,r){t=t>>>0,r||Mr(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};pe.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Mr(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};pe.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Mr(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};pe.prototype.readBigInt64LE=ju(function(t){t=t>>>0,Ao(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Dc(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,Ao(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Dc(t,this.length-8);let s=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(s)<>>0,r||Mr(t,4,this.length),Eo.read(this,t,!0,23,4)};pe.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Mr(t,4,this.length),Eo.read(this,t,!1,23,4)};pe.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Mr(t,8,this.length),Eo.read(this,t,!0,52,8)};pe.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Mr(t,8,this.length),Eo.read(this,t,!1,52,8)};function Yn(e,t,r,n,s,u){if(!pe.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||te.length)throw new RangeError("Index out of range")}pe.prototype.writeUintLE=pe.prototype.writeUIntLE=function(t,r,n,s){if(t=+t,r=r>>>0,n=n>>>0,!s){let o=Math.pow(2,8*n)-1;Yn(this,t,r,n,o,0)}let u=1,i=0;for(this[r]=t&255;++i>>0,n=n>>>0,!s){let o=Math.pow(2,8*n)-1;Yn(this,t,r,n,o,0)}let u=n-1,i=1;for(this[r+u]=t&255;--u>=0&&(i*=256);)this[r+u]=t/i&255;return r+n};pe.prototype.writeUint8=pe.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||Yn(this,t,r,1,255,0),this[r]=t&255,r+1};pe.prototype.writeUint16LE=pe.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Yn(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};pe.prototype.writeUint16BE=pe.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Yn(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};pe.prototype.writeUint32LE=pe.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Yn(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};pe.prototype.writeUint32BE=pe.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Yn(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 rv(e,t,r,n,s){av(t,n,s,e,r,7);let u=Number(t&BigInt(4294967295));e[r++]=u,u=u>>8,e[r++]=u,u=u>>8,e[r++]=u,u=u>>8,e[r++]=u;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 nv(e,t,r,n,s){av(t,n,s,e,r,7);let u=Number(t&BigInt(4294967295));e[r+7]=u,u=u>>8,e[r+6]=u,u=u>>8,e[r+5]=u,u=u>>8,e[r+4]=u;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}pe.prototype.writeBigUInt64LE=ju(function(t,r=0){return rv(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});pe.prototype.writeBigUInt64BE=ju(function(t,r=0){return nv(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});pe.prototype.writeIntLE=function(t,r,n,s){if(t=+t,r=r>>>0,!s){let l=Math.pow(2,8*n-1);Yn(this,t,r,n,l-1,-l)}let u=0,i=1,o=0;for(this[r]=t&255;++u>0)-o&255;return r+n};pe.prototype.writeIntBE=function(t,r,n,s){if(t=+t,r=r>>>0,!s){let l=Math.pow(2,8*n-1);Yn(this,t,r,n,l-1,-l)}let u=n-1,i=1,o=0;for(this[r+u]=t&255;--u>=0&&(i*=256);)t<0&&o===0&&this[r+u+1]!==0&&(o=1),this[r+u]=(t/i>>0)-o&255;return r+n};pe.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||Yn(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};pe.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Yn(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};pe.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Yn(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};pe.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Yn(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};pe.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Yn(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};pe.prototype.writeBigInt64LE=ju(function(t,r=0){return rv(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});pe.prototype.writeBigInt64BE=ju(function(t,r=0){return nv(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function iv(e,t,r,n,s,u){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function sv(e,t,r,n,s){return t=+t,r=r>>>0,s||iv(e,t,r,4,34028234663852886e22,-34028234663852886e22),Eo.write(e,t,r,n,23,4),r+4}pe.prototype.writeFloatLE=function(t,r,n){return sv(this,t,r,!0,n)};pe.prototype.writeFloatBE=function(t,r,n){return sv(this,t,r,!1,n)};function uv(e,t,r,n,s){return t=+t,r=r>>>0,s||iv(e,t,r,8,17976931348623157e292,-17976931348623157e292),Eo.write(e,t,r,n,52,8),r+8}pe.prototype.writeDoubleLE=function(t,r,n){return uv(this,t,r,!0,n)};pe.prototype.writeDoubleBE=function(t,r,n){return uv(this,t,r,!1,n)};pe.prototype.copy=function(t,r,n,s){if(!pe.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 u;if(typeof t=="number")for(u=r;u2**32?s=Xm(String(r)):typeof r=="bigint"&&(s=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(s=Xm(s)),s+="n"),n+=` It must be ${t}. Received ${s}`,n},RangeError);function Xm(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 p5(e,t,r){Ao(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Dc(t,e.length-(r+1))}function av(e,t,r,n,s,u){if(e>r||e3?t===0||t===BigInt(0)?o=`>= 0${i} and < 2${i} ** ${(u+1)*8}${i}`:o=`>= -(2${i} ** ${(u+1)*8-1}${i}) and < 2 ** ${(u+1)*8-1}${i}`:o=`>= ${t}${i} and <= ${r}${i}`,new vo.ERR_OUT_OF_RANGE("value",o,e)}p5(n,s,u)}function Ao(e,t){if(typeof e!="number")throw new vo.ERR_INVALID_ARG_TYPE(t,"number",e)}function Dc(e,t,r){throw Math.floor(e)!==e?(Ao(e,r),new vo.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new vo.ERR_BUFFER_OUT_OF_BOUNDS:new vo.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var d5=/[^+/0-9A-Za-z-_]/g;function g5(e){if(e=e.split("=")[0],e=e.trim().replace(d5,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function up(e,t){t=t||1/0;let r,n=e.length,s=null,u=[];for(let i=0;i55295&&r<57344){if(!s){if(r>56319){(t-=3)>-1&&u.push(239,191,189);continue}else if(i+1===n){(t-=3)>-1&&u.push(239,191,189);continue}s=r;continue}if(r<56320){(t-=3)>-1&&u.push(239,191,189),s=r;continue}r=(s-55296<<10|r-56320)+65536}else s&&(t-=3)>-1&&u.push(239,191,189);if(s=null,r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;u.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return u}function m5(e){let t=[];for(let r=0;r>8,s=r%256,u.push(s),u.push(n);return u}function ov(e){return np.toByteArray(g5(e))}function ff(e,t,r,n){let s;for(s=0;s=t.length||s>=e.length);++s)t[s+r]=e[s];return s}function ps(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function lp(e){return e!==e}var E5=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 ju(e){return typeof BigInt>"u"?A5:e}function A5(){throw new Error("BigInt not supported")}});var Rv=De(Se=>{var yc={};yc.userAgent=!1;var Co={},w5="11.1.0",C5="jsrsasign(all) 11.1.0 (2024-02-01) (c) 2010-2023 Kenji Urushima | kjur.github.io/jsrsasign/license";var Be=Be||function(e,t){var r={},n=r.lib={},s=n.Base=function(){function f(){}return{extend:function(w){f.prototype=this;var g=new f;return w&&g.mixIn(w),g.hasOwnProperty("init")||(g.init=function(){g.$super.init.apply(this,arguments)}),g.init.prototype=g,g.$super=this,g},create:function(){var w=this.extend();return w.init.apply(w,arguments),w},init:function(){},mixIn:function(w){for(var g in w)w.hasOwnProperty(g)&&(this[g]=w[g]);w.hasOwnProperty("toString")&&(this.toString=w.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),u=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||o).stringify(this)},concat:function(f){var w=this.words,g=f.words,F=this.sigBytes,A=f.sigBytes;if(this.clamp(),F%4)for(var C=0;C>>2]>>>24-C%4*8&255;w[F+C>>>2]|=S<<24-(F+C)%4*8}else for(var C=0;C>>2]=g[C>>>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=[],g=0;g>>2]>>>24-A%4*8&255;F.push((C>>>4).toString(16)),F.push((C&15).toString(16))}return F.join("")},parse:function(f){for(var w=f.length,g=[],F=0;F>>3]|=parseInt(f.substr(F,2),16)<<24-F%8*4;return new u.init(g,w/2)}},l=i.Latin1={stringify:function(f){for(var w=f.words,g=f.sigBytes,F=[],A=0;A>>2]>>>24-A%4*8&255;F.push(String.fromCharCode(C))}return F.join("")},parse:function(f){for(var w=f.length,g=[],F=0;F>>2]|=(f.charCodeAt(F)&255)<<24-F%4*8;return new u.init(g,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)))}},p=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new u.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,g=w.words,F=w.sigBytes,A=this.blockSize,C=A*4,S=F/C;f?S=e.ceil(S):S=e.max((S|0)-this._minBufferSize,0);var I=S*A,_=e.min(I*4,F);if(I){for(var L=0;L>>2]&255}},t.BlockCipher=o.extend({cfg:o.cfg.extend({mode:E,padding:h}),reset:function(){o.reset.call(this);var F=this.cfg,g=F.iv,F=F.mode;if(this._xformMode==this._ENC_XFORM_MODE)var A=F.createEncryptor;else A=F.createDecryptor,this._minBufferSize=1;this._mode=A.call(F,this,g&&g.words)},_doProcessBlock:function(g,F){this._mode.processBlock(g,F)},_doFinalize:function(){var g=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){g.pad(this._data,this.blockSize);var F=this._process(!0)}else F=this._process(!0),g.unpad(F);return F},blockSize:4});var p=t.CipherParams=r.extend({init:function(g){this.mixIn(g)},toString:function(g){return(g||this.formatter).stringify(this)}}),E=(f.format={}).OpenSSL={stringify:function(g){var F=g.ciphertext;return g=g.salt,(g?n.create([1398893684,1701076831]).concat(g).concat(F):F).toString(u)},parse:function(g){g=u.parse(g);var F=g.words;if(F[0]==1398893684&&F[1]==1701076831){var A=n.create(F.slice(2,4));F.splice(0,4),g.sigBytes-=16}return p.create({ciphertext:g,salt:A})}},d=t.SerializableCipher=r.extend({cfg:r.extend({format:E}),encrypt:function(g,F,A,C){C=this.cfg.extend(C);var S=g.createEncryptor(A,C);return F=S.finalize(F),S=S.cfg,p.create({ciphertext:F,key:A,iv:S.iv,algorithm:g,mode:S.mode,padding:S.padding,blockSize:g.blockSize,formatter:C.format})},decrypt:function(g,F,A,C){return C=this.cfg.extend(C),F=this._parse(F,C.format),g.createDecryptor(A,C).finalize(F.ciphertext)},_parse:function(g,F){return typeof g=="string"?F.parse(g,this):g}}),f=(f.kdf={}).OpenSSL={execute:function(g,F,A,C){return C||(C=n.random(8)),g=i.create({keySize:F+A}).compute(g,C),A=n.create(g.words.slice(F),4*A),g.sigBytes=4*F,p.create({key:g,iv:A,salt:C})}},w=t.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:f}),encrypt:function(g,F,A,C){return C=this.cfg.extend(C),A=C.kdf.execute(A,g.keySize,g.ivSize),C.iv=A.iv,g=d.encrypt.call(this,g,F,A.key,C),g.mixIn(A),g},decrypt:function(g,F,A,C){return C=this.cfg.extend(C),F=this._parse(F,C.format),A=C.kdf.execute(A,g.keySize,g.ivSize,F.salt),C.iv=A.iv,d.decrypt.call(this,g,F,A.key,C)}})}();(function(){for(var e=Be,t=e.lib.BlockCipher,L=e.algo,r=[],n=[],s=[],u=[],i=[],o=[],l=[],h=[],p=[],E=[],d=[],f=0;256>f;f++)d[f]=128>f?f<<1:f<<1^283;for(var w=0,g=0,f=0;256>f;f++){var F=g^g<<1^g<<2^g<<3^g<<4,F=F>>>8^F&255^99;r[w]=F,n[F]=w;var A=d[w],C=d[A],S=d[C],I=257*d[F]^16843008*F;s[w]=I<<24|I>>>8,u[w]=I<<16|I>>>16,i[w]=I<<8|I>>>24,o[w]=I,I=16843009*S^65537*C^257*A^16843008*w,l[F]=I<<24|I>>>8,h[F]=I<<16|I>>>16,p[F]=I<<8|I>>>24,E[F]=I,w?(w=A^d[d[d[S^A]]],g^=d[d[g]]):w=g=1}var _=[0,1,2,4,8,16,32,64,128,27,54],L=L.AES=t.extend({_doReset:function(){for(var B=this._key,M=B.words,b=B.sigBytes/4,B=4*((this._nRounds=b+6)+1),k=this._keySchedule=[],U=0;U>>24]<<24|r[q>>>16&255]<<16|r[q>>>8&255]<<8|r[q&255]):(q=q<<8|q>>>24,q=r[q>>>24]<<24|r[q>>>16&255]<<16|r[q>>>8&255]<<8|r[q&255],q^=_[U/b|0]<<24),k[U]=k[U-b]^q}for(M=this._invKeySchedule=[],b=0;bb||4>=U?q:l[r[q>>>24]]^h[r[q>>>16&255]]^p[r[q>>>8&255]]^E[r[q&255]]},encryptBlock:function(M,b){this._doCryptBlock(M,b,this._keySchedule,s,u,i,o,r)},decryptBlock:function(M,b){var B=M[b+1];M[b+1]=M[b+3],M[b+3]=B,this._doCryptBlock(M,b,this._invKeySchedule,l,h,p,E,n),B=M[b+1],M[b+1]=M[b+3],M[b+3]=B},_doCryptBlock:function(M,b,B,k,U,q,W,K){for(var z=this._nRounds,ae=M[b]^B[0],ye=M[b+1]^B[1],He=M[b+2]^B[2],Je=M[b+3]^B[3],X=4,se=1;se>>24]^U[ye>>>16&255]^q[He>>>8&255]^W[Je&255]^B[X++],be=k[ye>>>24]^U[He>>>16&255]^q[Je>>>8&255]^W[ae&255]^B[X++],Re=k[He>>>24]^U[Je>>>16&255]^q[ae>>>8&255]^W[ye&255]^B[X++],Je=k[Je>>>24]^U[ae>>>16&255]^q[ye>>>8&255]^W[He&255]^B[X++],ae=Ie,ye=be,He=Re;Ie=(K[ae>>>24]<<24|K[ye>>>16&255]<<16|K[He>>>8&255]<<8|K[Je&255])^B[X++],be=(K[ye>>>24]<<24|K[He>>>16&255]<<16|K[Je>>>8&255]<<8|K[ae&255])^B[X++],Re=(K[He>>>24]<<24|K[Je>>>16&255]<<16|K[ae>>>8&255]<<8|K[ye&255])^B[X++],Je=(K[Je>>>24]<<24|K[ae>>>16&255]<<16|K[ye>>>8&255]<<8|K[He&255])^B[X++],M[b]=Ie,M[b+1]=be,M[b+2]=Re,M[b+3]=Je},keySize:8});e.AES=t._createHelper(L)})();(function(){function e(d,f){var w=(this._lBlock>>>d^this._rBlock)&f;this._rBlock^=w,this._lBlock^=w<>>d^this._lBlock)&f;this._lBlock^=w,this._rBlock^=w<w;w++){var g=i[w]-1;f[w]=d[g>>>5]>>>31-g%32&1}for(d=this._subKeys=[],g=0;16>g;g++){for(var F=d[g]=[],A=l[g],w=0;24>w;w++)F[w/6|0]|=f[(o[w]-1+A)%28]<<31-w%6,F[4+(w/6|0)]|=f[28+(o[w+24]-1+A)%28]<<31-w%6;for(F[0]=F[0]<<1|F[0]>>>31,w=1;7>w;w++)F[w]>>>=4*(w-1)+3;F[7]=F[7]<<5|F[7]>>>27}for(f=this._invSubKeys=[],w=0;16>w;w++)f[w]=d[15-w]},encryptBlock:function(d,f){this._doCryptBlock(d,f,this._subKeys)},decryptBlock:function(d,f){this._doCryptBlock(d,f,this._invSubKeys)},_doCryptBlock:function(d,f,w){this._lBlock=d[f],this._rBlock=d[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 g=0;16>g;g++){for(var F=w[g],A=this._lBlock,C=this._rBlock,S=0,I=0;8>I;I++)S|=h[I][((C^F[I])&p[I])>>>0];this._lBlock=C,this._rBlock=A^S}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),d[f]=this._lBlock,d[f+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=s._createHelper(E),u=u.TripleDES=s.extend({_doReset:function(){var d=this._key.words;this._des1=E.createEncryptor(n.create(d.slice(0,2))),this._des2=E.createEncryptor(n.create(d.slice(2,4))),this._des3=E.createEncryptor(n.create(d.slice(4,6)))},encryptBlock:function(d,f){this._des1.encryptBlock(d,f),this._des2.decryptBlock(d,f),this._des3.encryptBlock(d,f)},decryptBlock:function(d,f){this._des3.decryptBlock(d,f),this._des2.encryptBlock(d,f),this._des1.decryptBlock(d,f)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=s._createHelper(u)})();(function(){var e=Be,t=e.lib.WordArray;e.enc.Base64={stringify:function(r){var n=r.words,s=r.sigBytes,u=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=u.charAt(64))for(;r.length%4;)r.push(n);return r.join("")},parse:function(r){var n=r.length,s=this._map,u=s.charAt(64);u&&(u=r.indexOf(u),u!=-1&&(n=u));for(var u=[],i=0,o=0;o>>6-2*(o%4);u[i>>>2]|=(l|h)<<24-8*(i%4),i++}return t.create(u,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();(function(e){function t(E,d,f,w,g,F,A){return E=E+(d&f|~d&w)+g+A,(E<>>32-F)+d}function r(E,d,f,w,g,F,A){return E=E+(d&w|f&~w)+g+A,(E<>>32-F)+d}function n(E,d,f,w,g,F,A){return E=E+(d^f^w)+g+A,(E<>>32-F)+d}function s(E,d,f,w,g,F,A){return E=E+(f^(d|~w))+g+A,(E<>>32-F)+d}for(var u=Be,l=u.lib,i=l.WordArray,o=l.Hasher,l=u.algo,h=[],p=0;64>p;p++)h[p]=4294967296*e.abs(e.sin(p+1))|0;l=l.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(E,d){for(var f=0;16>f;f++){var w=d+f,g=E[w];E[w]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360}var f=this._hash.words,w=E[d+0],g=E[d+1],F=E[d+2],A=E[d+3],C=E[d+4],S=E[d+5],I=E[d+6],_=E[d+7],L=E[d+8],M=E[d+9],b=E[d+10],B=E[d+11],k=E[d+12],U=E[d+13],q=E[d+14],W=E[d+15],K=f[0],se=f[1],X=f[2],z=f[3],K=t(K,se,X,z,w,7,h[0]),z=t(z,K,se,X,g,12,h[1]),X=t(X,z,K,se,F,17,h[2]),se=t(se,X,z,K,A,22,h[3]),K=t(K,se,X,z,C,7,h[4]),z=t(z,K,se,X,S,12,h[5]),X=t(X,z,K,se,I,17,h[6]),se=t(se,X,z,K,_,22,h[7]),K=t(K,se,X,z,L,7,h[8]),z=t(z,K,se,X,M,12,h[9]),X=t(X,z,K,se,b,17,h[10]),se=t(se,X,z,K,B,22,h[11]),K=t(K,se,X,z,k,7,h[12]),z=t(z,K,se,X,U,12,h[13]),X=t(X,z,K,se,q,17,h[14]),se=t(se,X,z,K,W,22,h[15]),K=r(K,se,X,z,g,5,h[16]),z=r(z,K,se,X,I,9,h[17]),X=r(X,z,K,se,B,14,h[18]),se=r(se,X,z,K,w,20,h[19]),K=r(K,se,X,z,S,5,h[20]),z=r(z,K,se,X,b,9,h[21]),X=r(X,z,K,se,W,14,h[22]),se=r(se,X,z,K,C,20,h[23]),K=r(K,se,X,z,M,5,h[24]),z=r(z,K,se,X,q,9,h[25]),X=r(X,z,K,se,A,14,h[26]),se=r(se,X,z,K,L,20,h[27]),K=r(K,se,X,z,U,5,h[28]),z=r(z,K,se,X,F,9,h[29]),X=r(X,z,K,se,_,14,h[30]),se=r(se,X,z,K,k,20,h[31]),K=n(K,se,X,z,S,4,h[32]),z=n(z,K,se,X,L,11,h[33]),X=n(X,z,K,se,B,16,h[34]),se=n(se,X,z,K,q,23,h[35]),K=n(K,se,X,z,g,4,h[36]),z=n(z,K,se,X,C,11,h[37]),X=n(X,z,K,se,_,16,h[38]),se=n(se,X,z,K,b,23,h[39]),K=n(K,se,X,z,U,4,h[40]),z=n(z,K,se,X,w,11,h[41]),X=n(X,z,K,se,A,16,h[42]),se=n(se,X,z,K,I,23,h[43]),K=n(K,se,X,z,M,4,h[44]),z=n(z,K,se,X,k,11,h[45]),X=n(X,z,K,se,W,16,h[46]),se=n(se,X,z,K,F,23,h[47]),K=s(K,se,X,z,w,6,h[48]),z=s(z,K,se,X,_,10,h[49]),X=s(X,z,K,se,q,15,h[50]),se=s(se,X,z,K,S,21,h[51]),K=s(K,se,X,z,k,6,h[52]),z=s(z,K,se,X,A,10,h[53]),X=s(X,z,K,se,b,15,h[54]),se=s(se,X,z,K,g,21,h[55]),K=s(K,se,X,z,L,6,h[56]),z=s(z,K,se,X,W,10,h[57]),X=s(X,z,K,se,I,15,h[58]),se=s(se,X,z,K,U,21,h[59]),K=s(K,se,X,z,C,6,h[60]),z=s(z,K,se,X,B,10,h[61]),X=s(X,z,K,se,F,15,h[62]),se=s(se,X,z,K,M,21,h[63]);f[0]=f[0]+K|0,f[1]=f[1]+se|0,f[2]=f[2]+X|0,f[3]=f[3]+z|0},_doFinalize:function(){var E=this._data,d=E.words,f=8*this._nDataBytes,w=8*E.sigBytes;d[w>>>5]|=128<<24-w%32;var g=e.floor(f/4294967296);for(d[(w+64>>>9<<4)+15]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360,d[(w+64>>>9<<4)+14]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360,E.sigBytes=4*(d.length+1),this._process(),E=this._hash,d=E.words,f=0;4>f;f++)w=d[f],d[f]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360;return E},clone:function(){var E=o.clone.call(this);return E._hash=this._hash.clone(),E}}),u.MD5=o._createHelper(l),u.HmacMD5=o._createHmacHelper(l)})(Math);(function(){var e=Be,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(u,i){for(var o=this._hash.words,l=o[0],h=o[1],p=o[2],E=o[3],d=o[4],f=0;80>f;f++){if(16>f)n[f]=u[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)+d+n[f],w=20>f?w+((h&p|~h&E)+1518500249):40>f?w+((h^p^E)+1859775393):60>f?w+((h&p|h&E|p&E)-1894007588):w+((h^p^E)-899497514),d=E,E=p,p=h<<30|h>>>2,h=l,l=w}o[0]=o[0]+l|0,o[1]=o[1]+h|0,o[2]=o[2]+p|0,o[3]=o[3]+E|0,o[4]=o[4]+d|0},_doFinalize:function(){var u=this._data,i=u.words,o=8*this._nDataBytes,l=8*u.sigBytes;return i[l>>>5]|=128<<24-l%32,i[(l+64>>>9<<4)+14]=Math.floor(o/4294967296),i[(l+64>>>9<<4)+15]=o,u.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var u=r.clone.call(this);return u._hash=this._hash.clone(),u}});e.SHA1=r._createHelper(s),e.HmacSHA1=r._createHmacHelper(s)})();(function(e){for(var t=Be,f=t.lib,r=f.WordArray,n=f.Hasher,f=t.algo,s=[],u=[],i=function(g){return 4294967296*(g-(g|0))|0},o=2,l=0;64>l;){var h;e:{h=o;for(var p=e.sqrt(h),E=2;E<=p;E++)if(!(h%E)){h=!1;break e}h=!0}h&&(8>l&&(s[l]=i(e.pow(o,.5))),u[l]=i(e.pow(o,1/3)),l++),o++}var d=[],f=f.SHA256=n.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(w,g){for(var F=this._hash.words,A=F[0],C=F[1],S=F[2],I=F[3],_=F[4],L=F[5],M=F[6],b=F[7],B=0;64>B;B++){if(16>B)d[B]=w[g+B]|0;else{var k=d[B-15],U=d[B-2];d[B]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+d[B-7]+((U<<15|U>>>17)^(U<<13|U>>>19)^U>>>10)+d[B-16]}k=b+((_<<26|_>>>6)^(_<<21|_>>>11)^(_<<7|_>>>25))+(_&L^~_&M)+u[B]+d[B],U=((A<<30|A>>>2)^(A<<19|A>>>13)^(A<<10|A>>>22))+(A&C^A&S^C&S),b=M,M=L,L=_,_=I+k|0,I=S,S=C,C=A,A=k+U|0}F[0]=F[0]+A|0,F[1]=F[1]+C|0,F[2]=F[2]+S|0,F[3]=F[3]+I|0,F[4]=F[4]+_|0,F[5]=F[5]+L|0,F[6]=F[6]+M|0,F[7]=F[7]+b|0},_doFinalize:function(){var w=this._data,g=w.words,F=8*this._nDataBytes,A=8*w.sigBytes;return g[A>>>5]|=128<<24-A%32,g[(A+64>>>9<<4)+14]=e.floor(F/4294967296),g[(A+64>>>9<<4)+15]=F,w.sigBytes=4*g.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=Be,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=Be,r=t.lib.Hasher,u=t.x64,n=u.Word,s=u.WordArray,u=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)],o=[],l=0;80>l;l++)o[l]=e();u=u.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,p){for(var C=this._hash.words,E=C[0],d=C[1],f=C[2],w=C[3],g=C[4],F=C[5],A=C[6],C=C[7],S=E.high,I=E.low,_=d.high,L=d.low,M=f.high,b=f.low,B=w.high,k=w.low,U=g.high,q=g.low,W=F.high,K=F.low,z=A.high,X=A.low,se=C.high,Ie=C.low,be=S,Re=I,Je=_,ae=L,ye=M,He=b,Zt=B,It=k,Ct=U,lr=q,er=W,pt=K,Mt=z,st=X,We=se,tr=Ie,Ve=0;80>Ve;Ve++){var fr=o[Ve];if(16>Ve)var Rt=fr.high=h[p+2*Ve]|0,_e=fr.low=h[p+2*Ve+1]|0;else{var Rt=o[Ve-15],_e=Rt.high,mt=Rt.low,Rt=(_e>>>1|mt<<31)^(_e>>>8|mt<<24)^_e>>>7,mt=(mt>>>1|_e<<31)^(mt>>>8|_e<<24)^(mt>>>7|_e<<25),yr=o[Ve-2],_e=yr.high,yt=yr.low,yr=(_e>>>19|yt<<13)^(_e<<3|yt>>>29)^_e>>>6,yt=(yt>>>19|_e<<13)^(yt<<3|_e>>>29)^(yt>>>6|_e<<26),_e=o[Ve-7],zr=_e.high,Yt=o[Ve-16],Me=Yt.high,Yt=Yt.low,_e=mt+_e.low,Rt=Rt+zr+(_e>>>0>>0?1:0),_e=_e+yt,Rt=Rt+yr+(_e>>>0>>0?1:0),_e=_e+Yt,Rt=Rt+Me+(_e>>>0>>0?1:0);fr.high=Rt,fr.low=_e}var zr=Ct&er^~Ct&Mt,Yt=lr&pt^~lr&st,fr=be&Je^be&ye^Je&ye,qt=Re&ae^Re&He^ae&He,mt=(be>>>28|Re<<4)^(be<<30|Re>>>2)^(be<<25|Re>>>7),yr=(Re>>>28|be<<4)^(Re<<30|be>>>2)^(Re<<25|be>>>7),yt=i[Ve],ii=yt.high,Wr=yt.low,yt=tr+((lr>>>14|Ct<<18)^(lr>>>18|Ct<<14)^(lr<<23|Ct>>>9)),Me=We+((Ct>>>14|lr<<18)^(Ct>>>18|lr<<14)^(Ct<<23|lr>>>9))+(yt>>>0>>0?1:0),yt=yt+Yt,Me=Me+zr+(yt>>>0>>0?1:0),yt=yt+Wr,Me=Me+ii+(yt>>>0>>0?1:0),yt=yt+_e,Me=Me+Rt+(yt>>>0<_e>>>0?1:0),_e=yr+qt,fr=mt+fr+(_e>>>0>>0?1:0),We=Mt,tr=st,Mt=er,st=pt,er=Ct,pt=lr,lr=It+yt|0,Ct=Zt+Me+(lr>>>0>>0?1:0)|0,Zt=ye,It=He,ye=Je,He=ae,Je=be,ae=Re,Re=yt+_e|0,be=Me+fr+(Re>>>0>>0?1:0)|0}I=E.low=I+Re,E.high=S+be+(I>>>0>>0?1:0),L=d.low=L+ae,d.high=_+Je+(L>>>0>>0?1:0),b=f.low=b+He,f.high=M+ye+(b>>>0>>0?1:0),k=w.low=k+It,w.high=B+Zt+(k>>>0>>0?1:0),q=g.low=q+lr,g.high=U+Ct+(q>>>0>>0?1:0),K=F.low=K+pt,F.high=W+er+(K>>>0>>0?1:0),X=A.low=X+st,A.high=z+Mt+(X>>>0>>0?1:0),Ie=C.low=Ie+tr,C.high=se+We+(Ie>>>0>>0?1:0)},_doFinalize:function(){var h=this._data,p=h.words,E=8*this._nDataBytes,d=8*h.sigBytes;return p[d>>>5]|=128<<24-d%32,p[(d+128>>>10<<5)+30]=Math.floor(E/4294967296),p[(d+128>>>10<<5)+31]=E,h.sigBytes=4*p.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(u),t.HmacSHA512=r._createHmacHelper(u)})();(function(){var e=Be,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 u=n._doFinalize.call(this);return u.sigBytes-=16,u}});e.SHA384=n._createHelper(s),e.HmacSHA384=n._createHmacHelper(s)})();(function(){var e=Be,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]),u=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]),o=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(p,E){for(var d=0;16>d;d++){var f=E+d,w=p[f];p[f]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360}var f=this._hash.words,w=o.words,g=l.words,F=n.words,A=s.words,C=u.words,S=i.words,I,_,L,M,b,B,k,U,q,W;B=I=f[0],k=_=f[1],U=L=f[2],q=M=f[3],W=b=f[4];for(var K,d=0;80>d;d+=1)K=I+p[E+F[d]]|0,K=16>d?K+((_^L^M)+w[0]):32>d?K+((_&L|~_&M)+w[1]):48>d?K+(((_|~L)^M)+w[2]):64>d?K+((_&M|L&~M)+w[3]):K+((_^(L|~M))+w[4]),K|=0,K=K<>>32-C[d],K=K+b|0,I=b,b=M,M=L<<10|L>>>22,L=_,_=K,K=B+p[E+A[d]]|0,K=16>d?K+((k^(U|~q))+g[0]):32>d?K+((k&q|U&~q)+g[1]):48>d?K+(((k|~U)^q)+g[2]):64>d?K+((k&U|~k&q)+g[3]):K+((k^U^q)+g[4]),K|=0,K=K<>>32-S[d],K=K+W|0,B=W,W=q,q=U<<10|U>>>22,U=k,k=K;K=f[1]+L+q|0,f[1]=f[2]+M+W|0,f[2]=f[3]+b+B|0,f[3]=f[4]+I+k|0,f[4]=f[0]+_+U|0,f[0]=K},_doFinalize:function(){var p=this._data,E=p.words,d=8*this._nDataBytes,f=8*p.sigBytes;for(E[f>>>5]|=128<<24-f%32,E[(f+64>>>9<<4)+14]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360,p.sigBytes=4*(E.length+1),this._process(),p=this._hash,E=p.words,d=0;5>d;d++)f=E[d],E[d]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360;return p},clone:function(){var p=r.clone.call(this);return p._hash=this._hash.clone(),p}});e.RIPEMD160=r._createHelper(h),e.HmacRIPEMD160=r._createHmacHelper(h)})(Math);(function(){var e=Be,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,u=4*s;n.sigBytes>u&&(n=r.finalize(n)),n.clamp();for(var i=this._oKey=n.clone(),o=this._iKey=n.clone(),l=i.words,h=o.words,p=0;p>6)+Fo.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=Fo.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=Fo.charAt(r>>2)+Fo.charAt((r&3)<<4)),dp)for(;(n.length&3)>0;)n+=dp;return n}function yo(e){var t="",r,n=0,s,u;for(r=0;r>2),s=u&3,n=1):n==1?(t+=ru(s<<2|u>>4),s=u&15,n=2):n==2?(t+=ru(s),t+=ru(u>>2),s=u&3,n=3):(t+=ru(s<<2|u>>4),t+=ru(u&15),n=0));return n==1&&(t+=ru(s<<2)),t}function hv(e){var t=yo(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 y5(e,t,r,n,s,u){for(var i=t&32767,o=t>>15;--u>=0;){var l=this[e]&32767,h=this[e++]>>15,p=o*l+h*i;l=i*l+((p&32767)<<15)+r[n]+(s&1073741823),s=(l>>>30)+(p>>>15)+o*h+(s>>>30),r[n++]=l&1073741823}return s}function S5(e,t,r,n,s,u){for(var i=t&16383,o=t>>14;--u>=0;){var l=this[e]&16383,h=this[e++]>>14,p=o*l+h*i;l=i*l+((p&16383)<<14)+r[n]+s,s=(l>>28)+(p>>14)+o*h,r[n++]=l&268435455}return s}cv&&yc.appName=="Microsoft Internet Explorer"?(ee.prototype.am=y5,Mu=30):cv&&yc.appName!="Netscape"?(ee.prototype.am=D5,Mu=26):(ee.prototype.am=S5,Mu=28);ee.prototype.DB=Mu;ee.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function I5(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 Hu(e){var t=_t();return t.fromInt(e),t}function B5(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,u=0;--n>=0;){var i=r==8?e[n]&255:pv(e,n);if(i<0){e.charAt(n)=="-"&&(s=!0);continue}s=!1,u==0?this[this.t++]=i:u+r>this.DB?(this[this.t-1]|=(i&(1<>this.DB-u):this[this.t-1]|=i<=this.DB&&(u-=this.DB)}r==8&&e[0]&128&&(this.s=-1,u>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t}function P5(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(o>o)>0&&(s=!0,u=ru(n));i>=0;)o>(o+=this.DB-t)):(n=this[i]>>(o-=t)&r,o<=0&&(o+=this.DB,--i)),n>0&&(s=!0),s&&(u+=ru(n));return s?u:"0"}function R5(){var e=_t();return ee.ZERO.subTo(this,e),e}function T5(){return this.s<0?this.negate():this}function O5(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 Ef(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 k5(){return this.t<=0?0:this.DB*(this.t-1)+Ef(this[this.t-1]^this.s&this.DM)}function N5(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 x5(e,t){for(var r=e;r=0;--o)t[o+u+1]=this[o]>>n|i,i=(this[o]&s)<=0;--o)t[o]=0;t[u]=i,t.t=this.t+u+1,t.s=this.s,t.clamp()}function U5(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,u=(1<>n;for(var i=r+1;i>n;n>0&&(t[this.t-r-1]|=(this.s&u)<>=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 H5(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 q5(e,t,r){var n=e.abs();if(!(n.t<=0)){var s=this.abs();if(s.t0?(n.lShiftTo(l,u),s.lShiftTo(l,r)):(n.copyTo(u),s.copyTo(r));var h=u.t,p=u[h-1];if(p!=0){var E=p*(1<1?u[h-2]>>this.F2:0),d=this.FV/E,f=(1<=0&&(r[r.t++]=1,r.subTo(A,r)),ee.ONE.dlShiftTo(h,A),A.subTo(u,u);u.t=0;){var C=r[--g]==p?this.DM:Math.floor(r[g]*d+(r[g-1]+w)*f);if((r[g]+=u.am(0,C,r,F,0,h))0&&r.rShiftTo(l,r),i<0&&ee.ZERO.subTo(r,r)}}}function V5(e){var t=_t();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ee.ZERO)>0&&e.subTo(t,t),t}function Sa(e){this.m=e}function K5(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function G5(e){return e}function z5(e){e.divRemTo(this.m,null,e)}function W5(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function Y5(e,t){e.squareTo(t),this.reduce(t)}Sa.prototype.convert=K5;Sa.prototype.revert=G5;Sa.prototype.reduce=z5;Sa.prototype.mulTo=W5;Sa.prototype.sqrTo=Y5;function X5(){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 ba(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 Z5(e){var t=_t();return e.copyTo(t),this.reduce(t),t}function Q5(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 eS(e,t){e.squareTo(t),this.reduce(t)}function tS(e,t,r){e.multiplyTo(t,r),this.reduce(r)}ba.prototype.convert=J5;ba.prototype.revert=Z5;ba.prototype.reduce=Q5;ba.prototype.mulTo=tS;ba.prototype.sqrTo=eS;function rS(){return(this.t>0?this[0]&1:this.s)==0}function nS(e,t){if(e>4294967295||e<1)return ee.ONE;var r=_t(),n=_t(),s=t.convert(this),u=Ef(e)-1;for(s.copyTo(r);--u>=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 iS(e,t){var r;return e<256||t.isEven()?r=new Sa(t):r=new ba(t),this.exp(e,r)}ee.prototype.copyTo=_5;ee.prototype.fromInt=I5;ee.prototype.fromString=B5;ee.prototype.clamp=$5;ee.prototype.dlShiftTo=N5;ee.prototype.drShiftTo=x5;ee.prototype.lShiftTo=L5;ee.prototype.rShiftTo=U5;ee.prototype.subTo=j5;ee.prototype.multiplyTo=H5;ee.prototype.squareTo=M5;ee.prototype.divRemTo=q5;ee.prototype.invDigit=X5;ee.prototype.isEven=rS;ee.prototype.exp=nS;ee.prototype.toString=P5;ee.prototype.negate=R5;ee.prototype.abs=T5;ee.prototype.compareTo=O5;ee.prototype.bitLength=k5;ee.prototype.mod=V5;ee.prototype.modPowInt=iS;ee.ZERO=Hu(0);ee.ONE=Hu(1);function sS(){var e=_t();return this.copyTo(e),e}function uS(){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 oS(){return this.t==0?this.s:this[0]<<16>>16}function cS(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function lS(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function fS(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=Hu(r),s=_t(),u=_t(),i="";for(this.divRemTo(n,s,u);s.signum()>0;)i=(r+u.intValue()).toString(e).substr(1)+i,s.divRemTo(n,s,u);return u.intValue().toString(e)+i}function hS(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),s=!1,u=0,i=0,o=0;o=r&&(this.dMultiply(n),this.dAddOffset(i,0),u=0,i=0)}u>0&&(this.dMultiply(Math.pow(t,u)),this.dAddOffset(i,0)),s&&ee.ZERO.subTo(this,this)}function pS(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(ee.ONE.shiftLeft(e-1),wp,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(ee.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 mS(e){return this.compareTo(e)<0?this:e}function vS(e){return this.compareTo(e)>0?this:e}function ES(e,t,r){var n,s,u=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 IS(){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 xS(e){var t=_t();return this.addTo(e,t),t}function LS(e){var t=_t();return this.subTo(e,t),t}function US(e){var t=_t();return this.multiplyTo(e,t),t}function jS(){var e=_t();return this.squareTo(e),e}function HS(e){var t=_t();return this.divRemTo(e,t,null),t}function MS(e){var t=_t();return this.divRemTo(e,null,t),t}function qS(e){var t=_t(),r=_t();return this.divRemTo(e,t,r),new Array(t,r)}function VS(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function KS(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 bc(){}function mv(e){return e}function GS(e,t,r){e.multiplyTo(t,r)}function zS(e,t){e.squareTo(t)}bc.prototype.convert=mv;bc.prototype.revert=mv;bc.prototype.mulTo=GS;bc.prototype.sqrTo=zS;function WS(e){return this.exp(e,new bc)}function YS(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=_t();return e.copyTo(t),this.reduce(t),t}function ZS(e){return e}function QS(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 eb(e,t){e.squareTo(t),this.reduce(t)}function tb(e,t,r){e.multiplyTo(t,r),this.reduce(r)}bo.prototype.convert=JS;bo.prototype.revert=ZS;bo.prototype.reduce=QS;bo.prototype.mulTo=tb;bo.prototype.sqrTo=eb;function rb(e,t){var r=e.bitLength(),n,s=Hu(1),u;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?u=new Sa(t):t.isEven()?u=new bo(t):u=new ba(t);var i=new Array,o=3,l=n-1,h=(1<1){var p=_t();for(u.sqrTo(i[1],p);o<=h;)i[o]=_t(),u.mulTo(p,i[o-2],i[o]),o+=2}var E=e.t-1,d,f=!0,w=_t(),g;for(r=Ef(e[E])-1;E>=0;){for(r>=l?d=e[E]>>r-l&h:(d=(e[E]&(1<0&&(d|=e[E-1]>>this.DB+r-l)),o=n;!(d&1);)d>>=1,--o;if((r-=o)<0&&(r+=this.DB,--E),f)i[d].copyTo(s),f=!1;else{for(;o>1;)u.sqrTo(s,w),u.sqrTo(w,s),o-=2;o>0?u.sqrTo(s,w):(g=s,s=w,w=g),u.mulTo(w,i[d],s)}for(;E>=0&&!(e[E]&1<0&&(t.rShiftTo(u,t),r.rShiftTo(u,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 u>0&&r.lShiftTo(u,r),r}function ib(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 sb(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return ee.ZERO;for(var r=e.clone(),n=this.clone(),s=Hu(1),u=Hu(0),i=Hu(0),o=Hu(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),t?((!s.isEven()||!u.isEven())&&(s.addTo(this,s),u.subTo(e,u)),s.rShiftTo(1,s)):u.isEven()||u.subTo(e,u),u.rShiftTo(1,u);for(;n.isEven();)n.rShiftTo(1,n),t?((!i.isEven()||!o.isEven())&&(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);r.compareTo(n)>=0?(r.subTo(n,r),t&&s.subTo(i,s),u.subTo(o,u)):(n.subTo(r,n),t&&i.subTo(s,i),o.subTo(u,o))}if(n.compareTo(ee.ONE)!=0)return ee.ZERO;if(o.compareTo(e)>=0)return o.subtract(e);if(o.signum()<0)o.addTo(e,o);else return o;return o.signum()<0?o.add(e):o}var $n=[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],ub=(1<<26)/$n[$n.length-1];function ab(e){var t,r=this.abs();if(r.t==1&&r[0]<=$n[$n.length-1]){for(t=0;t<$n.length;++t)if(r[0]==$n[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<$n.length;){for(var n=$n[t],s=t+1;s<$n.length&&n>1,e>$n.length&&(e=$n.length);for(var s=_t(),u=0;u>8&255,gi[qr++]^=e>>16&255,gi[qr++]^=e>>24&255,qr>=gp&&(qr-=gp)}function Fp(){hb(new Date().getTime())}if(gi==null){if(gi=new Array,qr=0,Co!==void 0&&(Co.crypto!==void 0||Co.msCrypto!==void 0)){if(fp=Co.crypto||Co.msCrypto,fp.getRandomValues)for(hp=new Uint8Array(32),fp.getRandomValues(hp),Oi=0;Oi<32;++Oi)gi[qr++]=hp[Oi];else if(yc.appName=="Netscape"&&yc.appVersion<"5")for(pp=Co.crypto.random(32),Oi=0;Oi>>8,gi[qr++]=Oi&255;qr=0,Fp()}var Oi,fp,hp,pp;function pb(){if(pf==null){for(Fp(),pf=fb(),pf.init(gi),qr=0;qr0&&t.length>0)this.n=Xn(e,16),this.e=parseInt(t,16);else throw"Invalid RSA public key"}function mb(e){return e.modPowInt(this.e,this.n)}it.prototype.doPublic=mb;it.prototype.setPublic=gb;it.prototype.type="RSA";function vb(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=Xn(e,16),this.e=parseInt(t,16),this.d=Xn(r,16);else throw"Invalid RSA private key"}function Eb(e,t,r,n,s,u,i,o){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=Xn(e,16),this.e=parseInt(t,16),this.d=Xn(r,16),this.p=Xn(n,16),this.q=Xn(s,16),this.dmp1=Xn(u,16),this.dmq1=Xn(i,16),this.coeff=Xn(o,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function Ab(e,t){var r=new _o,n=e>>1;this.e=parseInt(t,16);for(var s=new ee(t,16),u=e/2-100,i=ee.ONE.shiftLeft(u);;){for(;this.p=new ee(e-n,1,r),!(this.p.subtract(ee.ONE).gcd(s).compareTo(ee.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new ee(n,1,r),!(this.q.subtract(ee.ONE).gcd(s).compareTo(ee.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var l=this.q.subtract(this.p).abs();if(!(l.bitLength()0;--h){s=s.twice();var p=r.testBit(h),E=t.testBit(h);p!=E&&(s=s.add(p?this:n))}for(h=i.bitLength()-2;h>0;--h){o=o.twice();var d=i.testBit(h),f=u.testBit(h);d!=f&&(o=o.add(d?o:l))}return s}function xb(e,t,r){var n;e.bitLength()>r.bitLength()?n=e.bitLength()-1:n=r.bitLength()-1;for(var s=this.curve.getInfinity(),u=this.add(t);n>=0;)s=s.twice(),e.testBit(n)?r.testBit(n)?s=s.add(u):s=s.add(this):r.testBit(n)&&(s=s.add(t)),--n;return s}Ot.prototype.getX=Bb;Ot.prototype.getY=$b;Ot.prototype.equals=Pb;Ot.prototype.isInfinity=Rb;Ot.prototype.negate=Tb;Ot.prototype.add=Ob;Ot.prototype.twice=kb;Ot.prototype.multiply=Nb;Ot.prototype.multiplyTwo=xb;function iu(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new Ot(this,null,null)}function Lb(){return this.q}function Ub(){return this.a}function jb(){return this.b}function Hb(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function Mb(){return this.infinity}function qb(e){return new Or(this.q,e)}function Vb(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 ee(h,16)),s=this.getA(),u=this.getB(),i=n.square().add(s).multiply(n).add(u),o=i.sqrt();return t=="03"&&(o=o.negate()),new Ot(this,n,o);case 4:case 6:case 7:var l=(e.length-2)/2,h=e.substr(2,l),p=e.substr(l+2,l);return new Ot(this,this.fromBigInteger(new ee(h,16)),this.fromBigInteger(new ee(p,16)));default:return null}}iu.prototype.getQ=Lb;iu.prototype.getA=Ub;iu.prototype.getB=jb;iu.prototype.equals=Hb;iu.prototype.getInfinity=Mb;iu.prototype.fromBigInteger=qb;iu.prototype.decodePointHex=Vb;Or.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};Ot.prototype.getEncoded=function(e){var t=function(u,i){var o=u.toByteArrayUnsigned();if(io.length;)o.unshift(0);return o},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};Ot.decodeFrom=function(e,t){var r=t[0],n=t.length-1,s=t.slice(1,1+n/2),u=t.slice(1+n/2,1+n);s.unshift(0),u.unshift(0);var i=new ee(s),o=new ee(u);return new Ot(e,e.fromBigInteger(i),e.fromBigInteger(o))};Ot.decodeFromHex=function(e,t){var r=t.substr(0,2),n=t.length-2,s=t.substr(2,n/2),u=t.substr(2+n/2,n/2),i=new ee(s,16),o=new ee(u,16);return new Ot(e,e.fromBigInteger(i),e.fromBigInteger(o))};Ot.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),u=n.multiply(this.x.subtract(s)).subtract(this.y);return new Ot(this.curve,s,u)};Ot.prototype.twice2D=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var e=this.curve.fromBigInteger(ee.valueOf(2)),t=this.curve.fromBigInteger(ee.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 Ot(this.curve,n,s)};Ot.prototype.multiply2D=function(e){if(this.isInfinity())return this;if(e.signum()==0)return this.curve.getInfinity();var t=e,r=t.multiply(new ee("3")),n=this.negate(),s=this,u;for(u=r.bitLength()-2;u>0;--u){s=s.twice();var i=r.testBit(u),o=t.testBit(u);i!=o&&(s=s.add2D(i?this:n))}return s};Ot.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(),u=t.multiply(t).mod(s),i=e.multiply(e).multiply(e).add(r.multiply(e)).add(n).mod(s);return u.equals(i)};Ot.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};Ot.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(ee.ONE)<0||t.compareTo(e.subtract(ee.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(ee.ONE)<0||r.compareTo(e.subtract(ee.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 vv=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"),u={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:` `,r:"\r",t:" "};function i(E,d,f){return d?u[d]:String.fromCharCode(parseInt(f,16))}var o=new String(""),l="\\",h={"{":Object,"[":Array},p=Object.hasOwnProperty;return function(E,d){var f=E.match(n),w,g=f[0],F=!1;g==="{"?w={}:g==="["?w=[]:(w=[],F=!0);for(var A,C=[w],S=1-F,I=f.length;S=0;)delete B[k[W]]}return d.call(M,b,B)};w=L({"":w},"")}return w}}();(typeof m>"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});m.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 Ic(e)},this.getPEMStringFromHex=function(e,t){return pn(e,t)},this.newObject=function(e){var t=m,r=t.asn1,n=r.ASN1Object,s=r.DERBoolean,u=r.DERInteger,i=r.DERBitString,o=r.DEROctetString,l=r.DERNull,h=r.DERObjectIdentifier,p=r.DEREnumerated,E=r.DERUTF8String,d=r.DERNumericString,f=r.DERPrintableString,w=r.DERTeletexString,g=r.DERIA5String,F=r.DERUTCTime,A=r.DERGeneralizedTime,C=r.DERVisibleString,S=r.DERBMPString,I=r.DERSequence,_=r.DERSet,L=r.DERTaggedObject,M=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var b=Object.keys(e);if(b.length!=1)throw new Error("key of param shall be only one.");var B=b[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+B+":")==-1)throw new Error("undefined key: "+B);if(B=="bool")return new s(e[B]);if(B=="int")return new u(e[B]);if(B=="bitstr")return new i(e[B]);if(B=="octstr")return new o(e[B]);if(B=="null")return new l(e[B]);if(B=="oid")return new h(e[B]);if(B=="enum")return new p(e[B]);if(B=="utf8str")return new E(e[B]);if(B=="numstr")return new d(e[B]);if(B=="prnstr")return new f(e[B]);if(B=="telstr")return new w(e[B]);if(B=="ia5str")return new g(e[B]);if(B=="utctime")return new F(e[B]);if(B=="gentime")return new A(e[B]);if(B=="visstr")return new C(e[B]);if(B=="bmpstr")return new S(e[B]);if(B=="asn1")return new n(e[B]);if(B=="seq"){for(var k=e[B],U=[],q=0;q"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="+u.length+",v="+this.hV);var i=this.hV.length/2,o=i.toString(16);if(o.length%2==1&&(o="0"+o),i<128)return o;var l=o.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)+o},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)};m.asn1.DERAbstractString=function(e){m.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=wf(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))};de(m.asn1.DERAbstractString,m.asn1.ASN1Object);m.asn1.DERAbstractTime=function(e){m.asn1.DERAbstractTime.superclass.constructor.call(this);var t=null,r=null;this.localDateToUTC=function(n){var s=n.getTime()+n.getTimezoneOffset()*6e4,u=new Date(s);return u},this.formatDate=function(n,s,u){var i=this.zeroPadding,o=this.localDateToUTC(n),l=String(o.getFullYear());s=="utc"&&(l=l.substr(2,2));var h=i(String(o.getMonth()+1),2),p=i(String(o.getDate()),2),E=i(String(o.getHours()),2),d=i(String(o.getMinutes()),2),f=i(String(o.getSeconds()),2),w=l+h+p+E+d+f;if(u===!0){var g=o.getMilliseconds();if(g!=0){var F=i(String(g),3);F=F.replace(/[0]+$/,""),w=w+"."+F}}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,u,i,o,l){var h=new Date(Date.UTC(n,s-1,u,i,o,l,0));this.setByDate(h)},this.getFreshValueHex=function(){return this.hV}};de(m.asn1.DERAbstractTime,m.asn1.ASN1Object);m.asn1.DERAbstractStructured=function(e){m.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)};de(m.asn1.DERAbstractStructured,m.asn1.ASN1Object);m.asn1.DERBoolean=function(e){m.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",e==!1?this.hTLV="010100":this.hTLV="0101ff"};de(m.asn1.DERBoolean,m.asn1.ASN1Object);m.asn1.DERInteger=function(e){m.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var t=Ic;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 ee(String(r),10);else if(r.int!=null)n=new ee(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)};de(m.asn1.DERInteger,m.asn1.ASN1Object);m.asn1.DERBitString=function(e){if(e!==void 0&&typeof e.obj<"u"){var t=m.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.tohex()}m.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=u)break}return n};Fe.getNthChildIdx=function(e,t,r){var n=Fe.getChildIdx(e,t);return n[r]};Fe.getIdxbyList=function(e,t,r,n){var s=Fe,u,i;return r.length==0?n!==void 0&&e.substr(t,2)!==n?-1:t:(u=r.shift(),i=s.getChildIdx(e,t),u>=i.length?-1:s.getIdxbyList(e,i[u],r,n))};Fe.getIdxbyListEx=function(e,t,r,n){var s=Fe,u,i;if(r.length==0)return n!==void 0&&e.substr(t,2)!==n?-1:t;u=r.shift(),i=s.getChildIdx(e,t);for(var o=0,l=0;l=e.length?null:s.getTLV(e,u)};Fe.getTLVbyListEx=function(e,t,r,n){var s=Fe,u=s.getIdxbyListEx(e,t,r,n);return u==-1?null:s.getTLV(e,u)};Fe.getVbyList=function(e,t,r,n,s){var u=Fe,i,o;return i=u.getIdxbyList(e,t,r,n),i==-1||i>=e.length?null:(o=u.getV(e,i),s===!0&&(o=o.substr(2)),o)};Fe.getVbyListEx=function(e,t,r,n,s){var u=Fe,i,o,l;return i=u.getIdxbyListEx(e,t,r,n),i==-1?null:(l=u.getV(e,i),e.substr(i,2)=="03"&&s!==!1&&(l=l.substr(2)),l)};Fe.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=Fe.getV(e,t);return n=="02"?parseInt(s,16):bv(s)}catch{return r}};Fe.getOID=function(e,t,r){r==null&&(r=null);try{if(e.substr(t,2)!="06")return r;var n=Fe.getV(e,t);return Sf(n)}catch{return r}};Fe.getOIDName=function(e,t,r){r==null&&(r=null);try{var n=Fe.getOID(e,t,r);if(n==r)return r;var s=m.asn1.x509.OID.oid2name(n);return s==""?n:s}catch{return r}};Fe.getString=function(e,t,r){r==null&&(r=null);try{var n=Fe.getV(e,t);return Zn(n)}catch{return r}};Fe.hextooidstr=function(e){var t=function(E,d){return E.length>=d?E:new Array(d-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 u=e.substr(2),i=[],o=0;o0&&(p=p+"."+l.join(".")),p};Fe.dump=function(e,t,r,n){var s=Fe,u=s.getV,i=s.dump,o=s.getChildIdx,l=e;e instanceof m.asn1.ASN1Object&&(l=e.tohex());var h=function(M,b){if(M.length<=b*2)return M;var B=M.substr(0,b)+"..(total "+M.length/2+"bytes).."+M.substr(M.length-b,b);return B};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var p=t.ommit_long_octet,_=l.substr(r,2);if(_=="01"){var E=u(l,r);return E=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(_=="02"){var E=u(l,r);return n+"INTEGER "+h(E,p)+` `}if(_=="03"){var E=u(l,r);if(s.isASN1HEX(E.substr(2))){var d=n+`BITSTRING, encapsulates `;return d=d+i(E.substr(2),t,0,n+" "),d}else return n+"BITSTRING "+h(E,p)+` `}if(_=="04"){var E=u(l,r);if(s.isASN1HEX(E)){var d=n+`OCTETSTRING, encapsulates `;return d=d+i(E,t,0,n+" "),d}else return n+"OCTETSTRING "+h(E,p)+` `}if(_=="05")return n+`NULL `;if(_=="06"){var f=u(l,r),w=m.asn1.ASN1Util.oidHexToInt(f),g=m.asn1.x509.OID.oid2name(w),F=w.replace(/\./g," ");return g!=""?n+"ObjectIdentifier "+g+" ("+F+`) `:n+"ObjectIdentifier ("+F+`) `}if(_=="0a")return n+"ENUMERATED "+parseInt(u(l,r))+` `;if(_=="0c")return n+"UTF8String '"+Ht(u(l,r))+`' `;if(_=="13")return n+"PrintableString '"+Ht(u(l,r))+`' `;if(_=="14")return n+"TeletexString '"+Ht(u(l,r))+`' `;if(_=="16")return n+"IA5String '"+Ht(u(l,r))+`' `;if(_=="17")return n+"UTCTime "+Ht(u(l,r))+` `;if(_=="18")return n+"GeneralizedTime "+Ht(u(l,r))+` `;if(_=="1a")return n+"VisualString '"+Ht(u(l,r))+`' `;if(_=="1e")return n+"BMPString '"+bp(u(l,r))+`' `;if(_=="30"){if(l.substr(r,4)=="3000")return n+`SEQUENCE {} `;var d=n+`SEQUENCE `,A=o(l,r),C=t;if((A.length==2||A.length==3)&&l.substr(A[0],2)=="06"&&l.substr(A[A.length-1],2)=="04"){var g=s.oidname(u(l,A[0])),S=JSON.parse(JSON.stringify(t));S.x509ExtName=g,C=S}for(var I=0;I4?{enum:{hex:A}}:{enum:parseInt(A,16)};if(g=="30"||g=="31")return F[f[g]]=w(e),F;if(g=="14"){var L=d(A);return F[f[g]]={str:L},F}else if(g=="1e"){var L=E(A);return F[f[g]]={str:L},F}else if(":0c:12:13:16:17:18:1a:".indexOf(g)!=-1){var L=p(A);return F[f[g]]={str:L},F}else if(g.match(/^8[0-9]$/)){var L=p(A);return L==null|L==""?{tag:{tag:g,explicit:!1,hex:A}}:L.match(/[\x00-\x1F\x7F-\x9F]/)!=null||L.match(/[\u0000-\u001F\u0080–\u009F]/)!=null?{tag:{tag:g,explicit:!1,hex:A}}:{tag:{tag:g,explicit:!1,str:L}}}else if(g.match(/^a[0-9]$/))try{if(!n(A))throw new Error("not encap");return{tag:{tag:g,explicit:!0,obj:r(A)}}}catch{return{tag:{tag:g,explicit:!0,hex:A}}}else{var M=new m.asn1.ASN1Object;M.hV=A;var b=M.getLengthHexFromValue();return{asn1:{tlv:g+b+A}}}}}};Fe.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}};Fe.isASN1HEX=function(e){var t=Fe;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),s=t.getL(e,0),u=e.length-n.length-s.length;return u==r*2};Fe.checkStrictDER=function(e,t,r,n,s){var u=Fe;if(r===void 0){if(typeof e!="string")throw new Error("not hex string");if(e=e.toLowerCase(),!m.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=u.getL(e,t);if(i.length>s*2)throw new Error("L of TLV too long: idx="+t);var o=u.getVblen(e,t);if(o>n)throw new Error("value of L too long than hex: idx="+t);var l=u.getTLV(e,t),h=l.length-2-u.getL(e,t).length;if(h!==o*2)throw new Error("V string length and L's value not the same:"+h+"/"+o*2);if(t===0&&e.length!=l.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+l.length);var p=e.substr(t,2);if(p==="02"){var E=u.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(p,16)&32){for(var d=u.getVblen(e,t),f=0,w=u.getChildIdx(e,t),g=0;g"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.x509>"u"||!m.asn1.x509)&&(m.asn1.x509={});m.asn1.x509.Certificate=function(e){m.asn1.x509.Certificate.superclass.constructor.call(this);var t=m,r=t.asn1,n=r.DERBitString,s=r.DERSequence,u=r.x509,i=u.TBSCertificate,o=u.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 p=l.tbsobj.tohex(),E=new m.crypto.Signature({alg:h});E.init(l.cakey),E.updateHex(p),l.sighex=E.sign()},this.getPEM=function(){return pn(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 o({name:l.sigalg})),h.push(new n({hex:"00"+l.sighex}));var p=new s({array:h});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&(this.params=e)};de(m.asn1.x509.Certificate,m.asn1.ASN1Object);m.asn1.x509.TBSCertificate=function(e){m.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=m,r=t.asn1,n=r.x509,s=r.DERTaggedObject,u=r.DERInteger,i=r.DERSequence,o=n.AlgorithmIdentifier,l=n.Time,h=n.X500Name,p=n.Extensions,E=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(d){this.params=d},this.tohex=function(){var d=[],f=this.params;if(f.version!=null||f.version!=1){var w=2;f.version!=null&&(w=f.version-1);var g=new s({obj:new u({int:w})});d.push(g)}d.push(new u(f.serial)),d.push(new o({name:f.sigalg})),d.push(new h(f.issuer)),d.push(new i({array:[new l(f.notbefore),new l(f.notafter)]})),d.push(new h(f.subject)),d.push(new E(At.getKey(f.sbjpubkey))),f.ext!==void 0&&f.ext.length>0&&d.push(new s({tag:"a3",obj:new p(f.ext)}));var F=new m.asn1.DERSequence({array:d});return F.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};de(m.asn1.x509.TBSCertificate,m.asn1.ASN1Object);m.asn1.x509.Extensions=function(e){m.asn1.x509.Extensions.superclass.constructor.call(this);var t=m,r=t.asn1,n=r.DERSequence,s=r.x509;this.aParam=[],this.setByParam=function(u){this.aParam=u},this.tohex=function(){for(var u=[],i=0;i-1&&o.push(new n({int:this.pathLen}));var l=new s({array:o});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))};de(m.asn1.x509.BasicConstraints,m.asn1.x509.Extension);m.asn1.x509.CRLDistributionPoints=function(e){m.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=m,r=t.asn1,n=r.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(s){for(var u=[],i=0;i0&&u.push(new r({array:i}))}var l=new r({array:u});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};de(m.asn1.x509.PolicyInformation,m.asn1.ASN1Object);m.asn1.x509.PolicyQualifierInfo=function(e){m.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=m.asn1,r=t.DERSequence,n=t.DERIA5String,s=t.DERObjectIdentifier,u=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 u(this.params.unotice)]});return i.tohex()}},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};de(m.asn1.x509.PolicyQualifierInfo,m.asn1.ASN1Object);m.asn1.x509.UserNotice=function(e){m.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=m.asn1.DERSequence,r=m.asn1.DERInteger,n=m.asn1.x509.DisplayText,s=m.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var u=[];this.params.noticeref!==void 0&&u.push(new s(this.params.noticeref)),this.params.exptext!==void 0&&u.push(new n(this.params.exptext));var i=new t({array:u});return i.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};de(m.asn1.x509.UserNotice,m.asn1.ASN1Object);m.asn1.x509.NoticeReference=function(e){m.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=m.asn1.DERSequence,r=m.asn1.DERInteger,n=m.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 u=[],i=this.params.noticenum,o=0;o0)for(var i=0;i0;s++){var u=t.shift();if(r===!0){var i=n.pop(),o=(i+","+u).replace(/\\,/g,",");n.push(o),r=!1}else n.push(u);u.substr(-1,1)==="\\"&&(r=!0)}return n=n.map(function(l){return l.replace("/","\\/")}),n.reverse(),"/"+n.join("/")};m.asn1.x509.X500Name.ldapToOneline=function(e){return m.asn1.x509.X500Name.ldapToCompat(e)};m.asn1.x509.RDN=function(e){m.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=m.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 m.asn1.x509.AttributeTypeAndValue({str:r,rule:this.sRule}))},this.addByMultiValuedString=function(r){for(var n=m.asn1.x509.RDN.parseString(r),s=0;s0)for(var r=0;r0;s++){var u=t.shift();if(r===!0){var i=n.pop(),o=(i+"+"+u).replace(/\\\+/g,"+");n.push(o),r=!1}else n.push(u);u.substr(-1,1)==="\\"&&(r=!0)}for(var l=!1,h=[],s=0;n.length>0;s++){var u=n.shift();if(l===!0){var p=h.pop();if(u.match(/"$/)){var o=(p+"+"+u).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),l=!1}else h.push(p+"+"+u)}else h.push(u);u.match(/^[^=]+="/)&&(l=!0)}return h};m.asn1.x509.AttributeTypeAndValue=function(e){m.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=m,r=t.asn1,n=r.DERSequence,s=r.DERUTF8String,u=r.DERPrintableString,i=r.DERTeletexString,o=r.DERIA5String,l=r.DERVisibleString,h=r.DERBMPString,p=t.lang.String.isMail,E=t.lang.String.isPrintable;this.setByParam=function(d){if(d.rule!==void 0&&(this.sRule=d.rule),d.ds!==void 0&&(this.dsType=d.ds),d.value===void 0&&d.str!==void 0){var f=d.str,w=f.match(/^([^=]+)=(.+)$/);if(w)this.sType=w[1],this.sValue=w[2];else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}else this.sType=d.type,this.sValue=d.value},this.setByString=function(d,f){f!==void 0&&(this.sRule=f);var w=d.match(/^([^=]+)=(.+)$/);if(w)this.setByAttrTypeAndValueStr(w[1],w[2]);else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)},this._getDsType=function(){var d=this.sType,f=this.sValue,w=this.sRule;return w==="prn"?d=="CN"&&p(f)?"ia5":E(f)?"prn":"utf8":w==="utf8"?d=="CN"&&p(f)?"ia5":d=="C"?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(d,f,w){w!==void 0&&(this.sRule=w),this.sType=d,this.sValue=f},this.getValueObj=function(d,f){if(d=="utf8")return new s({str:f});if(d=="prn")return new u({str:f});if(d=="tel")return new i({str:f});if(d=="ia5")return new o({str:f});if(d=="vis")return new l({str:f});if(d=="bmp")return new h({str:f});throw new Error("unsupported directory string type: type="+d+" value="+f)},this.tohex=function(){this.dsType==null&&(this.dsType=this._getDsType());var d=m.asn1.x509.OID.atype2obj(this.sType),f=this.getValueObj(this.dsType,this.sValue),w=new n({array:[d,f]});return this.TLV=w.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};de(m.asn1.x509.AttributeTypeAndValue,m.asn1.ASN1Object);m.asn1.x509.SubjectPublicKeyInfo=function(e){m.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=null,r=null,n=m,s=n.asn1,u=s.DERInteger,i=s.DERBitString,o=s.DERObjectIdentifier,l=s.DERSequence,h=s.ASN1Util.newObject,p=s.x509,E=p.AlgorithmIdentifier,d=n.crypto,f=d.ECDSA,w=d.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null)throw"algId and/or subjPubKey not set";var g=new l({array:[this.asn1AlgId,this.asn1SubjPKey]});return g},this.tohex=function(){var g=this.getASN1Object();return this.hTLV=g.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(g){try{if(g instanceof it){var F=h({seq:[{int:{bigint:g.n}},{int:{int:g.e}}]}),A=F.tohex();this.asn1AlgId=new E({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+A})}}catch{}try{if(g instanceof m.crypto.ECDSA){var C=new o({name:g.curveName});this.asn1AlgId=new E({name:"ecPublicKey",asn1params:C}),this.asn1SubjPKey=new i({hex:"00"+g.pubKeyHex})}}catch{}try{if(g instanceof m.crypto.DSA){var C=new h({seq:[{int:{bigint:g.p}},{int:{bigint:g.q}},{int:{bigint:g.g}}]});this.asn1AlgId=new E({name:"dsa",asn1params:C});var S=new u({bigint:g.y});this.asn1SubjPKey=new i({hex:"00"+S.tohex()})}}catch{}},e!==void 0&&this.setPubKey(e)};de(m.asn1.x509.SubjectPublicKeyInfo,m.asn1.ASN1Object);m.asn1.x509.Time=function(e){m.asn1.x509.Time.superclass.constructor.call(this);var t=null,r=null,n=m,s=n.asn1,u=s.DERUTCTime,i=s.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(o){this.timeParams=o},this.setByParam=function(o){this.params=o},this.getType=function(o){return o.match(/^[0-9]{12}Z$/)?"utc":o.match(/^[0-9]{14}Z$/)?"gen":o.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":o.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var o=this.params,l=null;if(typeof o=="string"&&(o={str:o}),o!=null&&o.str&&(o.type==null||o.type==null)&&(o.type=this.getType(o.str)),o!=null&&o.str?(o.type=="utc"&&(l=new u(o.str)),o.type=="gen"&&(l=new i(o.str))):this.type=="gen"?l=new i:l=new u,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)};m.asn1.x509.Time_bak=function(e){m.asn1.x509.Time_bak.superclass.constructor.call(this);var t=null,r=null,n=m,s=n.asn1,u=s.DERUTCTime,i=s.DERGeneralizedTime;this.setTimeParams=function(o){this.timeParams=o},this.tohex=function(){var o=null;return this.timeParams!=null?this.type=="utc"?o=new u(this.timeParams):o=new i(this.timeParams):this.type=="utc"?o=new u:o=new i,this.TLV=o.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)};de(m.asn1.x509.Time,m.asn1.ASN1Object);m.asn1.x509.AlgorithmIdentifier=function(e){m.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=m,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 u=null;for(var i in n)i===this.nameAlg&&(u=n[i]);if(u!==null)return this.hTLV=u,this.hTLV}this.nameAlg!==null&&this.asn1Alg===null&&(this.asn1Alg=r.x509.OID.name2obj(this.nameAlg));var o=[this.asn1Alg];this.asn1Params!==null&&o.push(this.asn1Params);var l=new r.DERSequence({array:o});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)}};de(m.asn1.x509.AlgorithmIdentifier,m.asn1.ASN1Object);m.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};m.asn1.x509.GeneralName=function(e){m.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},r=m,n=r.asn1,s=n.x509,u=s.X500Name,i=s.OtherName,o=n.DERIA5String,l=n.DERPrintableString,h=n.DEROctetString,p=n.DERTaggedObject,E=n.ASN1Object,d=Error;this.params=null,this.setByParam=function(f){this.params=f},this.tohex=function(){var f=this.params,w,F,g,F=!1;if(f.other!==void 0)w="a0",g=new i(f.other);else if(f.rfc822!==void 0)w="81",g=new o({str:f.rfc822});else if(f.dns!==void 0)w="82",g=new o({str:f.dns});else if(f.dn!==void 0)w="a4",F=!0,typeof f.dn=="string"?g=new u({str:f.dn}):f.dn instanceof m.asn1.x509.X500Name?g=f.dn:g=new u(f.dn);else if(f.ldapdn!==void 0)w="a4",F=!0,g=new u({ldapstr:f.ldapdn});else if(f.certissuer!==void 0||f.certsubj!==void 0){w="a4",F=!0;var A,C,S=null;if(f.certsubj!==void 0?(A=!1,C=f.certsubj):(A=!0,C=f.certissuer),C.match(/^[0-9A-Fa-f]+$/)&&S==C,C.indexOf("-----BEGIN ")!=-1&&(S=cr(C)),S==null)throw new Error("certsubj/certissuer not cert");var I=new Xe;I.hex=S;var _;A?_=I.getIssuerHex():_=I.getSubjectHex(),g=new E,g.hTLV=_}else if(f.uri!==void 0)w="86",g=new o({str:f.uri});else if(f.ip!==void 0){w="87";var L,M=f.ip;try{if(M.match(/^[0-9a-f]+$/)){var b=M.length;if(b==8||b==16||b==32||b==64)L=M;else throw"err"}else L=Sp(M)}catch(k){throw new d("malformed IP address: "+f.ip+":"+k.message)}g=new h({hex:L})}else throw new d("improper params");var B=new p({tag:w,explicit:F,obj:g});return B.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};de(m.asn1.x509.GeneralName,m.asn1.ASN1Object);m.asn1.x509.GeneralNames=function(e){m.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=null,r=m,n=r.asn1;this.setByParamArray=function(s){for(var u=0;u"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,u){var i=this[n];if(!i.match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch{return!1}}};m.asn1.x509.OID.oid2name=function(e){var t=m.asn1.x509.OID.name2oidList;for(var r in t)if(t[r]==e)return r;return""};m.asn1.x509.OID.oid2atype=function(e){var t=m.asn1.x509.OID.atype2oidList;for(var r in t)if(t[r]==e)return r;return e};m.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=m.asn1.x509.OID.name2oidList;return t[e]===void 0?"":t[e]};m.asn1.x509.X509Util={};m.asn1.x509.X509Util.newCertPEM=function(e){var t=m.asn1.x509,r=t.TBSCertificate,n=t.Certificate,s=new n(e);return s.getPEM()};(typeof m>"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.cms>"u"||!m.asn1.cms)&&(m.asn1.cms={});m.asn1.cms.Attribute=function(e){var t=Error,r=m,n=r.asn1,s=n.DERSequence,u=n.DERSet,i=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(o){this.params=o},this.getValueArray=function(){throw new t("not yet implemented abstract")},this.tohex=function(){var o=new i({oid:this.typeOid}),l=new u({array:this.getValueArray()}),h=new s({array:[o,l]});return h.tohex()},this.getEncodedHex=function(){return this.tohex()}};de(m.asn1.cms.Attribute,m.asn1.ASN1Object);m.asn1.cms.ContentType=function(e){var t=m,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)};de(m.asn1.cms.ContentType,m.asn1.cms.Attribute);m.asn1.cms.MessageDigest=function(e){var t=m,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 u=new n(this.params);return[u]},e!=null&&this.setByParam(e)};de(m.asn1.cms.MessageDigest,m.asn1.cms.Attribute);m.asn1.cms.SigningTime=function(e){var t=m,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)};de(m.asn1.cms.SigningTime,m.asn1.cms.Attribute);m.asn1.cms.SigningCertificate=function(e){var t=Error,r=m,n=r.asn1,s=n.DERSequence,u=n.cms,i=u.ESSCertID,o=r.crypto;u.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=[],p=0;p0){for(var w=u(d.valhex,f[0]),g=E(w,0),F=[],A=0;A1){var I=u(d.valhex,f[1]);d.polhex=I}delete d.valhex},this.setSignaturePolicyIdentifier=function(d){var f=E(d.valhex,0);if(f.length>0){var w=n.getOID(d.valhex,f[0]);d.oid=w}if(f.length>1){var g=new t,F=E(d.valhex,f[1]),A=u(d.valhex,F[0]),C=g.getAlgorithmIdentifierName(A);d.alg=C;var S=s(d.valhex,F[1]);d.hash=S}delete d.valhex},this.setSigningCertificateV2=function(d){var f=E(d.valhex,0);if(f.length>0){for(var w=u(d.valhex,f[0]),g=E(w,0),F=[],A=0;A1){var I=u(d.valhex,f[1]);d.polhex=I}delete d.valhex},this.getESSCertID=function(d){var f={},w=E(d,0);if(w.length>0){var g=s(d,w[0]);f.hash=g}if(w.length>1){var F=u(d,w[1]),A=this.getIssuerSerial(F);A.serial!=null&&(f.serial=A.serial),A.issuer!=null&&(f.issuer=A.issuer)}return f},this.getESSCertIDv2=function(d){var f={},w=E(d,0);if(w.length<1||3g+1){var C=u(d,w[g+1]),S=this.getIssuerSerial(C);f.issuer=S.issuer,f.serial=S.serial}return f},this.getIssuerSerial=function(d){var f={},w=E(d,0),g=u(d,w[0]),F=r.getGeneralNames(g),A=F[0].dn;f.issuer=A;var C=s(d,w[1]);return f.serial={hex:C},f},this.getCertificateSet=function(d){for(var f=E(d,0),w=[],g=0;g"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.tsp>"u"||!m.asn1.tsp)&&(m.asn1.tsp={});m.asn1.tsp.TimeStampToken=function(e){var t=m,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)};de(m.asn1.tsp.TimeStampToken,m.asn1.cms.SignedData);m.asn1.tsp.TSTInfo=function(e){var t=Error,r=m,n=r.asn1,s=n.DERSequence,u=n.DERInteger,i=n.DERBoolean,o=n.DERGeneralizedTime,l=n.DERObjectIdentifier,h=n.DERTaggedObject,p=n.tsp,E=p.MessageImprint,d=p.Accuracy,f=n.x509.X500Name,w=n.x509.GeneralName;if(p.TSTInfo.superclass.constructor.call(this),this.dVersion=new u({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 g=[this.dVersion];if(this.dPolicy==null)throw new Error("policy shall be specified.");if(g.push(this.dPolicy),this.dMessageImprint==null)throw new Error("messageImprint shall be specified.");if(g.push(this.dMessageImprint),this.dSerial==null)throw new Error("serialNumber shall be specified.");if(g.push(this.dSerial),this.dGenTime==null)throw new Error("genTime shall be specified.");g.push(this.dGenTime),this.dAccuracy!=null&&g.push(this.dAccuracy),this.dOrdering!=null&&g.push(this.dOrdering),this.dNonce!=null&&g.push(this.dNonce),this.dTsa!=null&&g.push(this.dTsa);var F=new s({array:g});return this.hTLV=F.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 u(e.serial)),e.genTime!==void 0&&(this.dGenTime=new o(e.genTime)),e.accuracy!==void 0&&(this.dAccuracy=new d(e.accuracy)),e.ordering!==void 0&&e.ordering==!0&&(this.dOrdering=new i),e.nonce!==void 0&&(this.dNonce=new u(e.nonce)),e.tsa!==void 0&&(this.dTsa=new h({tag:"a0",explicit:!0,obj:new w({dn:e.tsa})}))}};de(m.asn1.tsp.TSTInfo,m.asn1.ASN1Object);m.asn1.tsp.Accuracy=function(e){var t=m,r=t.asn1,n=r.ASN1Util.newObject;r.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var s=this.params,u=[];return s.seconds!=null&&typeof s.seconds=="number"&&u.push({int:s.seconds}),s.millis!=null&&typeof s.millis=="number"&&u.push({tag:{tagi:"80",obj:{int:s.millis}}}),s.micros!=null&&typeof s.micros=="number"&&u.push({tag:{tagi:"81",obj:{int:s.micros}}}),n({seq:u}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};de(m.asn1.tsp.Accuracy,m.asn1.ASN1Object);m.asn1.tsp.MessageImprint=function(e){var t=m,r=t.asn1,n=r.DERSequence,s=r.DEROctetString,u=r.x509,i=u.AlgorithmIdentifier;r.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var o=this.params,l=new i({name:o.alg}),h=new s({hex:o.hash}),p=new n({array:[l,h]});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};de(m.asn1.tsp.MessageImprint,m.asn1.ASN1Object);m.asn1.tsp.TimeStampReq=function(e){var t=m,r=t.asn1,n=r.DERSequence,s=r.DERInteger,u=r.DERBoolean,i=r.ASN1Object,o=r.DERObjectIdentifier,l=r.tsp,h=l.MessageImprint;l.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var p=this.params,E=[];E.push(new s({int:1})),p.messageImprint instanceof m.asn1.ASN1Object?E.push(p.messageImprint):E.push(new h(p.messageImprint)),p.policy!=null&&E.push(new o(p.policy)),p.nonce!=null&&E.push(new s(p.nonce)),p.certreq==!0&&E.push(new u);var d=new n({array:E});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};de(m.asn1.tsp.TimeStampReq,m.asn1.ASN1Object);m.asn1.tsp.TimeStampResp=function(e){var t=m,r=t.asn1,n=r.DERSequence,s=r.ASN1Object,u=r.tsp,i=u.PKIStatusInfo;u.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var o=this.params,l=[];if(o.econtent!=null||o.tst!=null)if(o.statusinfo!=null?l.push(new i(o.statusinfo)):l.push(new i("granted")),o.econtent!=null)l.push(new u.TimeStampToken(o).getContentInfo());else if(o.tst instanceof r.ASN1Object)l.push(o.tst);else throw new Error("improper member tst value");else if(o.statusinfo!=null)l.push(new i(o.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)};de(m.asn1.tsp.TimeStampResp,m.asn1.ASN1Object);m.asn1.tsp.PKIStatusInfo=function(e){var t=Error,r=m,n=r.asn1,s=n.DERSequence,u=n.tsp,i=u.PKIStatus,o=u.PKIFreeText,l=u.PKIFailureInfo;u.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var h=this.params,p=[];if(typeof h=="string")p.push(new i(h));else{if(h.status==null)throw new t("property 'status' unspecified");p.push(new i(h.status)),h.statusstr!=null&&p.push(new o(h.statusstr)),h.failinfo!=null&&p.push(new l(h.failinfo))}var E=new s({array:p});return E.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};de(m.asn1.tsp.PKIStatusInfo,m.asn1.ASN1Object);m.asn1.tsp.PKIStatus=function(e){var t=Error,r=m,n=r.asn1,s=n.DERInteger,u=n.tsp;u.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 o=this.params,l,h;if(typeof o=="string")try{h=i[o]}catch{throw new t("undefined name: "+o)}else if(typeof o=="number")h=o;else throw new t("unsupported params");return new s({int:h}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};de(m.asn1.tsp.PKIStatus,m.asn1.ASN1Object);m.asn1.tsp.PKIFreeText=function(e){var t=Error,r=m,n=r.asn1,s=n.DERSequence,u=n.DERUTF8String,i=n.tsp;i.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var o=this.params;if(!o instanceof Array)throw new t("wrong params: not array");for(var l=[],h=0;h=0;d--)E+=p[d];return E}else{if(typeof l=="string"&&o[l]!=null)return mf([l],o);if(typeof l=="object"&&l.length!=null)return mf(l,o);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)};de(m.asn1.tsp.PKIFailureInfo,m.asn1.ASN1Object);m.asn1.tsp.AbstractTSAAdapter=function(e){this.getTSTHex=function(t,r){throw"not implemented yet"}};m.asn1.tsp.SimpleTSAAdapter=function(e){var t=m,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(u,i){var o=s(u,i);this.params.econtent.content.messageImprint={alg:i,hash:o},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)};de(m.asn1.tsp.SimpleTSAAdapter,m.asn1.tsp.AbstractTSAAdapter);m.asn1.tsp.FixedTSAAdapter=function(e){var t=m,r=t.asn1,n=r.tsp,s=t.crypto.Util.hashHex;n.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(u,i){var o=s(u,i);this.params.econtent.content.messageImprint={alg:i,hash:o};var l=new n.TimeStampToken(this.params);return l.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};de(m.asn1.tsp.FixedTSAAdapter,m.asn1.tsp.AbstractTSAAdapter);m.asn1.tsp.TSPUtil=new function(){};m.asn1.tsp.TSPUtil.newTimeStampToken=function(e){return new m.asn1.tsp.TimeStampToken(e)};m.asn1.tsp.TSPUtil.parseTimeStampReq=function(e){var t=new m.asn1.tsp.TSPParser;return t.getTimeStampReq(e)};m.asn1.tsp.TSPUtil.parseMessageImprint=function(e){var t=new m.asn1.tsp.TSPParser;return t.getMessageImprint(e)};m.asn1.tsp.TSPParser=function(){var e=Error,t=Xe,r=new t,n=Fe,s=n.getV,u=n.getTLV,i=n.getIdxbyList,o=n.getTLVbyListEx,l=n.getChildIdx,h=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],p={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(E){var d=l(E,0);if(d.length==1)return this.getPKIStatusInfo(u(E,d[0]));if(d.length>1){var f=this.getPKIStatusInfo(u(E,d[0])),w=u(E,d[1]),g=this.getToken(w);return g.statusinfo=f,g}},this.getToken=function(E){var d=new m.asn1.cms.CMSParser,f=d.getCMSSignedData(E);return this.setTSTInfo(f),f},this.setTSTInfo=function(E){var d=E.econtent;if(d.type=="tstinfo"){var f=d.content.hex,w=this.getTSTInfo(f);d.content=w}},this.getTSTInfo=function(E){var d={},f=l(E,0),w=s(E,f[1]);d.policy=Sf(w);var g=u(E,f[2]);d.messageImprint=this.getMessageImprint(g);var F=s(E,f[3]);d.serial={hex:F};var A=s(E,f[4]);d.genTime={str:Ht(A)};var C=0;if(f.length>5&&E.substr(f[5],2)=="30"){var S=u(E,f[5]);d.accuracy=this.getAccuracy(S),C++}if(f.length>5+C&&E.substr(f[5+C],2)=="01"){var I=s(E,f[5+C]);I=="ff"&&(d.ordering=!0),C++}if(f.length>5+C&&E.substr(f[5+C],2)=="02"){var _=s(E,f[5+C]);d.nonce={hex:_},C++}if(f.length>5+C&&E.substr(f[5+C],2)=="a0"){var L=u(E,f[5+C]);L="30"+L.substr(2),pGeneralNames=r.getGeneralNames(L);var M=pGeneralNames[0].dn;d.tsa=M,C++}if(f.length>5+C&&E.substr(f[5+C],2)=="a1"){var b=u(E,f[5+C]);b="30"+b.substr(2);var B=r.getExtParamArray(b);d.ext=B,C++}return d},this.getAccuracy=function(E){for(var d={},f=l(E,0),w=0;w1&&E.substr(f[1],2)=="30"){var A=u(E,f[1]);d.statusstr=this.getPKIFreeText(A),w++}if(f.length>w&&E.substr(f[1+w],2)=="03"){var C=u(E,f[1+w]);d.failinfo=this.getPKIFailureInfo(C)}return d},this.getPKIFreeText=function(E){for(var d=[],f=l(E,0),w=0;w"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.cades>"u"||!m.asn1.cades)&&(m.asn1.cades={});m.asn1.cades.SignaturePolicyIdentifier=function(e){var t=m,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(u){this.params=u},e!=null&&this.setByParam(e)};de(m.asn1.cades.SignaturePolicyIdentifier,m.asn1.cms.Attribute);m.asn1.cades.SignaturePolicyId=function(e){var t=m,r=t.asn1,n=r.DERSequence,s=r.DERObjectIdentifier,u=r.x509,i=u.AlgorithmIdentifier,o=r.cades,l=o.SignaturePolicyId,h=o.OtherHashAlgAndValue;l.superclass.constructor.call(this),this.params=null,this.tohex=function(){var p=this.params,E=[];E.push(new s(p.oid)),E.push(new h(p));var d=new n({array:E});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(p){this.params=p},e!=null&&this.setByParam(e)};de(m.asn1.cades.SignaturePolicyId,m.asn1.ASN1Object);m.asn1.cades.OtherHashAlgAndValue=function(e){var t=Error,r=m,n=r.asn1,s=n.DERSequence,u=n.DEROctetString,i=n.x509,o=i.AlgorithmIdentifier,l=n.cades,h=l.OtherHashAlgAndValue;h.superclass.constructor.call(this),this.params=null,this.tohex=function(){var p=this.params;if(p.alg==null)throw new t("property 'alg' not specified");if(p.hash==null&&p.cert==null)throw new t("property 'hash' nor 'cert' not specified");var E=null;if(p.hash!=null)E=p.hash;else if(p.cert!=null){if(typeof p.cert!="string")throw new t("cert not string");var d=p.cert;p.cert.indexOf("-----BEGIN")!=-1&&(d=cr(p.cert)),E=m.crypto.Util.hashHex(d,p.alg)}var f=[];f.push(new o({name:p.alg})),f.push(new u({hex:E}));var w=new s({array:f});return w.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};de(m.asn1.cades.OtherHashAlgAndValue,m.asn1.ASN1Object);m.asn1.cades.OtherHashValue=function(e){m.asn1.cades.OtherHashValue.superclass.constructor.call(this);var t=Error,r=m,n=r.lang.String.isHex,s=r.asn1,u=s.DEROctetString,i=r.crypto.Util.hashHex;this.params=null,this.tohex=function(){var o=this.params;if(o.hash==null&&o.cert==null)throw new t("hash or cert not specified");var l=null;if(o.hash!=null)l=o.hash;else if(o.cert!=null){if(typeof o.cert!="string")throw new t("cert not string");var h=o.cert;o.cert.indexOf("-----BEGIN")!=-1&&(h=cr(o.cert)),l=m.crypto.Util.hashHex(h,"sha1")}return new u({hex:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};de(m.asn1.cades.OtherHashValue,m.asn1.ASN1Object);m.asn1.cades.SignatureTimeStamp=function(e){var t=Error,r=m,n=r.lang.String.isHex,s=r.asn1,u=s.ASN1Object,i=s.x509,o=s.cades;o.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 u;return h.hTLV=l.tst,[h]}else{if(l.tst instanceof u)return[l.tst];throw new t("params.tst has wrong value")}else if(l.res!=null){var p=l.res;if(p instanceof u&&(p=p.tohex()),typeof p!="string"||!n(p))throw new t("params.res has wrong value");var E=Fe.getTLVbyList(p,0,[1]),h=new u;return h.hTLV=l.tst,[h]}},e!=null&&this.setByParam(e)};de(m.asn1.cades.SignatureTimeStamp,m.asn1.cms.Attribute);m.asn1.cades.CompleteCertificateRefs=function(e){var t=Error,r=m,n=r.asn1,s=n.DERSequence,u=n.cades,i=u.OtherCertID,o=r.lang.String.isHex;u.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=[],p=0;p"u"||!m.asn1.csr)&&(m.asn1.csr={});m.asn1.csr.CertificationRequest=function(e){var t=m,r=t.asn1,n=r.DERBitString,s=r.DERSequence,u=r.csr,i=r.x509,o=u.CertificationRequestInfo;u.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(l){this.params=l},this.sign=function(){var l=new o(this.params).tohex(),h=new m.crypto.Signature({alg:this.params.sigalg});h.init(this.params.sbjprvkey),h.updateHex(l);var p=h.sign();this.params.sighex=p},this.getPEM=function(){return pn(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var l=this.params,h=new m.asn1.csr.CertificationRequestInfo(this.params),p=new m.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}),d=new s({array:[h,p,E]});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};de(m.asn1.csr.CertificationRequest,m.asn1.ASN1Object);m.asn1.csr.CertificationRequestInfo=function(e){var t=m,r=t.asn1,n=r.DERBitString,s=r.DERSequence,u=r.DERInteger,i=r.DERUTF8String,o=r.DERTaggedObject,l=r.ASN1Util.newObject,h=r.csr,p=r.x509,E=p.X500Name,d=p.Extensions,f=p.SubjectPublicKeyInfo,w=h.AttributeList;h.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(F){F!=null&&(this.params=F)},this.tohex=function(){var F=this.params,A=[];if(A.push(new u({int:0})),A.push(new E(F.subject)),A.push(new f(At.getKey(F.sbjpubkey))),F.attrs!=null){var C=g(F.attrs),S=l({tag:{tage:"a0",obj:C}});A.push(S)}else if(F.extreq!=null){var I=new d(F.extreq),S=l({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[I]}]}}});A.push(S)}else A.push(new o({tag:"a0",explicit:!1,obj:new i({str:""})}));var _=new s({array:A});return _.tohex()},this.getEncodedHex=function(){return this.tohex()};function g(F){for(var A=Error,C=m.asn1.x509.Extensions,S=[],I=0;I"u"||!m)&&(m={});(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={});(typeof m.asn1.ocsp>"u"||!m.asn1.ocsp)&&(m.asn1.ocsp={});m.asn1.ocsp.DEFAULT_HASH="sha1";m.asn1.ocsp.OCSPResponse=function(e){m.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var t=m.asn1.DEREnumerated,r=m.asn1.ASN1Util.newObject,n=m.asn1.ocsp.ResponseBytes,s=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var u=this.params.resstatus;return typeof u=="number"?u:typeof u!="string"?-1:s.indexOf(u)},this.setByParam=function(u){this.params=u},this.tohex=function(){var u=this.params,i=this._getStatusCode();if(i==-1)throw new Error("responseStatus not supported: "+u.resstatus);if(i!=0)return r({seq:[{enum:{int:i}}]}).tohex();var o=new n(u);return r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:o}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};de(m.asn1.ocsp.OCSPResponse,m.asn1.ASN1Object);m.asn1.ocsp.ResponseBytes=function(e){m.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var t=m.asn1,r=t.DERSequence,n=t.DERObjectIdentifier,s=t.DEROctetString,u=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 o=new u(i),l=[];l.push(new n({name:"ocspBasic"})),l.push(new s({hex:o.tohex()}));var h=new r({array:l});return h.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};de(m.asn1.ocsp.ResponseBytes,m.asn1.ASN1Object);m.asn1.ocsp.BasicOCSPResponse=function(e){m.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var t=Error,r=m.asn1,n=r.ASN1Object,s=r.DERSequence,u=r.DERGeneralizedTime,i=r.DERTaggedObject,o=r.DERBitString,l=r.x509.Extensions,h=r.x509.AlgorithmIdentifier,p=r.ocsp,E=p.ResponderID;_SingleResponseList=p.SingleResponseList,_ResponseData=p.ResponseData,this.params=null,this.setByParam=function(d){this.params=d},this.sign=function(){var d=this.params,f=d.tbsresp.tohex(),w=new m.crypto.Signature({alg:d.sigalg});w.init(d.reskey),w.updateHex(f),d.sighex=w.sign()},this.tohex=function(){var d=this.params;d.tbsresp==null&&(d.tbsresp=new _ResponseData(d)),d.sighex==null&&d.reskey!=null&&this.sign();var f=[];if(f.push(d.tbsresp),f.push(new h({name:d.sigalg})),f.push(new o({hex:"00"+d.sighex})),d.certs!=null&&d.certs.length!=null){for(var w=[],g=0;g"u"||!m)&&(m={});(typeof m.lang>"u"||!m.lang)&&(m.lang={});m.lang.String=function(){};function Ev(e){for(var t=new Array,r=0;r>6,l=128|i&63;return Ht(o.toString(16)+l.toString(16))}var o=224|(u&240)>>4,l=128|(u&15)<<2|(i&192)>>6,h=128|i&63;return Ht(o.toString(16)+l.toString(16)+h.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function yf(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function o8(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 u=parseInt(r);if(u<0||255t.length&&(r=t.length);for(var n=0;n0&&(h=h+"."+o.join(".")),h}catch{return null}}function Sv(e){var t=new ee(String(e),10);return Ic(t)}function Ic(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="",u=0;u=t?e:new Array(t-e.length+1).join(r)+e};function bv(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 u=parseInt(s,2);return u==NaN?-1:u}catch{return-1}}function _v(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+gf("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var s="0"+r;return s+n}function Iv(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--)u+=s[n];return u}function Wt(e,n,r){if(typeof e=="object"){for(var n=String(n).split("."),s=0;s"u"||!m)&&(m={});(typeof m.crypto>"u"||!m.crypto)&&(m.crypto={});m.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:Be.algo.MD5,sha1:Be.algo.SHA1,sha224:Be.algo.SHA224,sha256:Be.algo.SHA256,sha384:Be.algo.SHA384,sha512:Be.algo.SHA512,ripemd160:Be.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 u="0001",i="00"+n,o="",l=s-u.length-i.length,h=0;h"u"||!m)&&(m={});(typeof m.crypto>"u"||!m.crypto)&&(m.crypto={});m.crypto.ECDSA=function(e){var t="secp256r1",r=null,n=null,s=null,u=Error,i=ee,o=Ot,l=m.crypto.ECDSA,h=m.crypto.ECParameterDB,p=l.getName,E=Fe,d=E.getVbyListEx,f=E.isASN1HEX,w=new _o,g=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function F(A,C,S,I){for(var _=Math.max(C.bitLength(),I.bitLength()),L=A.add2D(S),M=A.curve.getInfinity(),b=_-1;b>=0;--b)M=M.twice2D(),M.z=i.ONE,C.testBit(b)?I.testBit(b)?M=M.add2D(L):M=M.add2D(A):I.testBit(b)&&(M=M.add2D(S));return M}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 C=this.ecparams.keycharlen;if(A.length!==2+C*2)throw"malformed public key hex length";var S={};return S.x=A.substr(2,C),S.y=A.substr(2+C),S},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,C=this.getBigRandom(A),S=this.ecparams.keycharlen,I=("0000000000"+C.toString(16)).slice(-S);this.setPrivateKeyHex(I);var _=this.generatePublicKeyHex();return{ecprvhex:I,ecpubhex:_}},this.generatePublicKeyHex=function(){var A=new i(this.prvKeyHex,16),C=this.ecparams.G.multiply(A),S=C.getX().toBigInteger(),I=C.getY().toBigInteger(),_=this.ecparams.keycharlen,L=("0000000000"+S.toString(16)).slice(-_),M=("0000000000"+I.toString(16)).slice(-_),b="04"+L+M;return this.setPublicKeyHex(b),b},this.signWithMessageHash=function(A){return this.signHex(A,this.prvKeyHex)},this.signHex=function(A,C){var S=new i(C,16),I=this.ecparams.n,_=new i(A.substring(0,this.ecparams.keycharlen),16);do var L=this.getBigRandom(I),M=this.ecparams.G,b=M.multiply(L),B=b.getX().toBigInteger().mod(I);while(B.compareTo(i.ZERO)<=0);var k=L.modInverse(I).multiply(_.add(S.multiply(B))).mod(I);return l.biRSSigToASN1Sig(B,k)},this.sign=function(A,C){var S=C,I=this.ecparams.n,_=i.fromByteArrayUnsigned(A);do var L=this.getBigRandom(I),M=this.ecparams.G,b=M.multiply(L),B=b.getX().toBigInteger().mod(I);while(B.compareTo(ee.ZERO)<=0);var k=L.modInverse(I).multiply(_.add(S.multiply(B))).mod(I);return this.serializeSig(B,k)},this.verifyWithMessageHash=function(A,C){return this.verifyHex(A,C,this.pubKeyHex)},this.verifyHex=function(A,C,S){try{var I,_,L=l.parseSigHex(C);I=L.r,_=L.s;var M=o.decodeFromHex(this.ecparams.curve,S),b=new i(A.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(b,I,_,M)}catch{return!1}},this.verify=function(A,C,S){var I,_;if(Bitcoin.Util.isArray(C)){var L=this.parseSig(C);I=L.r,_=L.s}else if(typeof C=="object"&&C.r&&C.s)I=C.r,_=C.s;else throw"Invalid value for signature";var M;if(S instanceof Ot)M=S;else if(Bitcoin.Util.isArray(S))M=o.decodeFrom(this.ecparams.curve,S);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var b=i.fromByteArrayUnsigned(A);return this.verifyRaw(b,I,_,M)},this.verifyRaw=function(A,C,S,I){var _=this.ecparams.n,L=this.ecparams.G;if(C.compareTo(i.ONE)<0||C.compareTo(_)>=0||S.compareTo(i.ONE)<0||S.compareTo(_)>=0)return!1;var M=S.modInverse(_),b=A.multiply(M).mod(_),B=C.multiply(M).mod(_),k=L.multiply(b).add(I.multiply(B)),U=k.getX().toBigInteger().mod(_);return U.equals(C)},this.serializeSig=function(A,C){var S=A.toByteArraySigned(),I=C.toByteArraySigned(),_=[];return _.push(2),_.push(S.length),_=_.concat(S),_.push(2),_.push(I.length),_=_.concat(I),_.unshift(_.length),_.unshift(48),_},this.parseSig=function(A){var C;if(A[0]!=48)throw new Error("Signature not a valid DERSequence");if(C=2,A[C]!=2)throw new Error("First element in signature must be a DERInteger");var S=A.slice(C+2,C+2+A[C+1]);if(C+=2+A[C+1],A[C]!=2)throw new Error("Second element in signature must be a DERInteger");var I=A.slice(C+2,C+2+A[C+1]);C+=2+A[C+1];var _=i.fromByteArrayUnsigned(S),L=i.fromByteArrayUnsigned(I);return{r:_,s:L}},this.parseSigCompact=function(A){if(A.length!==65)throw"Signature has the wrong length";var C=A[0]-27;if(C<0||C>7)throw"Invalid signature type";var S=this.ecparams.n,I=i.fromByteArrayUnsigned(A.slice(1,33)).mod(S),_=i.fromByteArrayUnsigned(A.slice(33,65)).mod(S);return{r:I,s:_,i:C}},this.readPKCS5PrvKeyHex=function(A){if(f(A)===!1)throw new Error("not ASN.1 hex string");var C,S,I;try{C=d(A,0,["[0]",0],"06"),S=d(A,0,[1],"04");try{I=d(A,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=p(C),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(I),this.setPrivateKeyHex(S),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(A){if(f(A)===!1)throw new u("not ASN.1 hex string");var C,S,I,_;try{C=d(A,0,[1,0],"06"),S=d(A,0,[1,1],"06"),I=d(A,0,[2,0,1],"04");try{_=d(A,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new u("malformed PKCS#8 plain ECC private key")}if(this.curveName=p(S),this.curveName===void 0)throw new u("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(_),this.setPrivateKeyHex(I),this.isPublic=!1},this.readPKCS8PubKeyHex=function(A){if(f(A)===!1)throw new u("not ASN.1 hex string");var C,S,I;try{C=d(A,0,[0,0],"06"),S=d(A,0,[0,1],"06"),I=d(A,0,[1],"03")}catch{throw new u("malformed PKCS#8 ECC public key")}if(this.curveName=p(S),this.curveName===null)throw new u("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(I)},this.readCertPubKeyHex=function(A,C){if(f(A)===!1)throw new u("not ASN.1 hex string");var S,I;try{S=d(A,0,[0,5,0,1],"06"),I=d(A,0,[0,5,1],"03")}catch{throw new u("malformed X.509 certificate ECC public key")}if(this.curveName=p(S),this.curveName===null)throw new u("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))};m.crypto.ECDSA.parseSigHex=function(e){var t=m.crypto.ECDSA.parseSigHexInHexRS(e),r=new ee(t.r,16),n=new ee(t.s,16);return{r,s:n}};m.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=Fe,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 u=s[0],i=s[1];if(e.substr(u,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 o=n(e,u),l=n(e,i);return{r:o,s:l}};m.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=m.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};m.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 m.crypto.ECDSA.hexRSSigToASN1Sig(t,r)};m.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new ee(e,16),n=new ee(t,16);return m.crypto.ECDSA.biRSSigToASN1Sig(r,n)};m.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=m.asn1,n=new r.DERInteger({bigint:e}),s=new r.DERInteger({bigint:t}),u=new r.DERSequence({array:[n,s]});return u.tohex()};m.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 m>"u"||!m)&&(m={});(typeof m.crypto>"u"||!m.crypto)&&(m.crypto={});m.crypto.ECParameterDB=new function(){var e={},t={};function r(n){return new ee(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,u,i,o,l,h,p,E,d,f,w){e[n]={};var g=r(u),F=r(i),A=r(o),C=r(l),S=r(h),I=new iu(g,F,A),_=I.decodePointHex("04"+p+E);e[n].name=n,e[n].keylen=s,e[n].keycharlen=Math.ceil(s/8)*2,e[n].curve=I,e[n].G=_,e[n].n=C,e[n].h=S,e[n].oid=f,e[n].info=w;for(var L=0;L"u"||!m)&&(m={});(typeof m.crypto>"u"||!m.crypto)&&(m.crypto={});m.crypto.DSA=function(){var e=Fe,t=e.getVbyList,r=e.getVbyListEx,n=e.isASN1HEX,s=ee;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(u,i,o,l,h){this.isPrivate=!0,this.p=u,this.q=i,this.g=o,this.y=l,this.x=h},this.setPrivateHex=function(u,i,o,l,h){var p,E,d,f,w;p=new ee(u,16),E=new ee(i,16),d=new ee(o,16),typeof l=="string"&&l.length>1?f=new ee(l,16):f=null,w=new ee(h,16),this.setPrivate(p,E,d,f,w)},this.setPublic=function(u,i,o,l){this.isPublic=!0,this.p=u,this.q=i,this.g=o,this.y=l,this.x=null},this.setPublicHex=function(u,i,o,l){var h,p,E,d;h=new ee(u,16),p=new ee(i,16),E=new ee(o,16),d=new ee(l,16),this.setPublic(h,p,E,d)},this.signWithMessageHash=function(u){var i=this.p,o=this.q,l=this.g,h=this.y,p=this.x,E=m.crypto.Util.getRandomBigIntegerMinToMax(ee.ONE.add(ee.ONE),o.subtract(ee.ONE)),d=u.substr(0,o.bitLength()/4),f=new ee(d,16),w=l.modPow(E,i).mod(o),g=E.modInverse(o).multiply(f.add(p.multiply(w))).mod(o),F=m.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:w}},{int:{bigint:g}}]});return F},this.verifyWithMessageHash=function(u,i){var o=this.p,l=this.q,h=this.g,p=this.y,E=this.parseASN1Signature(i),d=E[0],f=E[1],w=u.substr(0,l.bitLength()/4),g=new ee(w,16);if(ee.ZERO.compareTo(d)>0||d.compareTo(l)>0||ee.ZERO.compareTo(f)>=0||f.compareTo(l)>0)throw"invalid DSA signature";var F=f.modInverse(l),A=g.multiply(F).mod(l),C=d.multiply(F).mod(l),S=h.modPow(A,o).multiply(p.modPow(C,o)).mod(o).mod(l);return S.compareTo(d)==0},this.parseASN1Signature=function(u){try{var i=new s(r(u,0,[0],"02"),16),o=new s(r(u,0,[1],"02"),16);return[i,o]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(u){var i,o,l,h,p;if(n(u)===!1)throw new Error("not ASN.1 hex string");try{i=r(u,0,[1],"02"),o=r(u,0,[2],"02"),l=r(u,0,[3],"02"),h=r(u,0,[4],"02"),p=r(u,0,[5],"02")}catch{throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(i,o,l,h,p)},this.readPKCS8PrvKeyHex=function(u){var i,o,l,h;if(n(u)===!1)throw new Error("not ASN.1 hex string");try{i=r(u,0,[1,1,0],"02"),o=r(u,0,[1,1,1],"02"),l=r(u,0,[1,1,2],"02"),h=r(u,0,[2,0],"02")}catch{throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(i,o,l,null,h)},this.readPKCS8PubKeyHex=function(u){var i,o,l,h;if(n(u)===!1)throw new Error("not ASN.1 hex string");try{i=r(u,0,[0,1,0],"02"),o=r(u,0,[0,1,1],"02"),l=r(u,0,[0,1,2],"02"),h=r(u,0,[1,0],"02")}catch{throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(i,o,l,h)},this.readCertPubKeyHex=function(u,i){var o,l,h,p;if(n(u)===!1)throw new Error("not ASN.1 hex string");try{o=r(u,0,[0,5,0,1,0],"02"),l=r(u,0,[0,5,0,1,1],"02"),h=r(u,0,[0,5,0,1,2],"02"),p=r(u,0,[0,5,1,0],"02")}catch{throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(o,l,h,p)}};var At=function(){var e=function(g,F,A){return n(Be.AES,g,F,A)},t=function(g,F,A){return n(Be.TripleDES,g,F,A)},r=function(g,F,A){return n(Be.DES,g,F,A)},n=function(g,F,A,C){var S=Be.enc.Hex.parse(F),I=Be.enc.Hex.parse(A),_=Be.enc.Hex.parse(C),L={};L.key=I,L.iv=_,L.ciphertext=S;var M=g.decrypt(L,I,{iv:_});return Be.enc.Hex.stringify(M)},s=function(g,F,A){return o(Be.AES,g,F,A)},u=function(g,F,A){return o(Be.TripleDES,g,F,A)},i=function(g,F,A){return o(Be.DES,g,F,A)},o=function(g,F,A,C){var S=Be.enc.Hex.parse(F),I=Be.enc.Hex.parse(A),_=Be.enc.Hex.parse(C),L=g.encrypt(S,I,{iv:_}),M=Be.enc.Hex.parse(L.toString()),b=Be.enc.Base64.stringify(M);return b},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:u,keylen:24,ivlen:8},"DES-CBC":{proc:r,eproc:i,keylen:8,ivlen:8}},h=function(g){return l[g].proc},p=function(g){var F=Be.lib.WordArray.random(g),A=Be.enc.Hex.stringify(F);return A},E=function(g){var F={},A=g.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));A&&(F.cipher=A[1],F.ivsalt=A[2]);var C=g.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));C&&(F.type=C[1]);var S=-1,I=0;g.indexOf(`\r \r `)!=-1&&(S=g.indexOf(`\r \r `),I=2),g.indexOf(` `)!=-1&&(S=g.indexOf(` `),I=1);var _=g.indexOf("-----END");if(S!=-1&&_!=-1){var L=g.substring(S+I*2,_-I);L=L.replace(/\s+/g,""),F.data=L}return F},d=function(g,F,A){for(var C=A.substring(0,16),S=Be.enc.Hex.parse(C),I=Be.enc.Utf8.parse(F),_=l[g].keylen+l[g].ivlen,L="",M=null;;){var b=Be.algo.MD5.create();if(M!=null&&b.update(M),b.update(I),b.update(S),M=b.finalize(),L=L+Be.enc.Hex.stringify(M),L.length>=_*2)break}var B={};return B.keyhex=L.substr(0,l[g].keylen*2),B.ivhex=L.substr(l[g].keylen*2,l[g].ivlen*2),B},f=function(g,F,A,C){var S=Be.enc.Base64.parse(g),I=Be.enc.Hex.stringify(S),_=l[F].proc,L=_(I,A,C);return L},w=function(g,F,A,C){var S=l[F].eproc,I=S(g,A,C);return I};return{version:"1.0.0",parsePKCS5PEM:function(g){return E(g)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(g,F,A){return d(g,F,A)},decryptKeyB64:function(g,F,A,C){return f(g,F,A,C)},getDecryptedKeyHex:function(g,F){var A=E(g),C=A.type,S=A.cipher,I=A.ivsalt,_=A.data,L=d(S,F,I),M=L.keyhex,b=f(_,S,M,I);return b},getEncryptedPKCS5PEMFromPrvKeyHex:function(g,F,A,C,S){var k="";if((typeof C>"u"||C==null)&&(C="AES-256-CBC"),typeof l[C]>"u")throw new Error("KEYUTIL unsupported algorithm: "+C);if(typeof S>"u"||S==null){var I=l[C].ivlen,_=p(I);S=_.toUpperCase()}var L=d(C,A,S),M=L.keyhex,b=w(F,C,M,S),B=b.replace(/(.{64})/g,`$1\r `),k="-----BEGIN "+g+` PRIVATE KEY-----\r `;return k+=`Proc-Type: 4,ENCRYPTED\r `,k+="DEK-Info: "+C+","+S+`\r `,k+=`\r `,k+=B,k+=`\r -----END `+g+` PRIVATE KEY-----\r `,k},getEncryptedPKCS8PEM:function(g,F,A){var C=this.getEncryptedPKCS8Hex(g,F,A);return pn(C,"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(g,F,A){var C;A==null||A==null?C={}:C=JSON.parse(JSON.stringify(A)),C.plain=g,this.initPBES2Param(C),this.encryptPBES2Param(C,F);var S=this.generatePBES2ASN1Param(C);return m.asn1.ASN1Util.newObject(S).tohex()},initPBES2Param:function(g){if(Wt(g,"encalg")==null&&(g.encalg="aes256-CBC"),Wt(g,"iter")==null&&(g.iter=2048),Wt(g,"prf")==null&&(g.prf="hmacWithSHA256"),Wt(g,"salt")==null&&(g.salt=Be.enc.Hex.stringify(Be.lib.WordArray.random(8))),Wt(g,"enciv")==null){var F;g.encalg=="des-EDE3-CBC"&&(F=8),g.encalg=="aes128-CBC"&&(F=16),g.encalg=="aes256-CBC"&&(F=16),g.enciv=Be.enc.Hex.stringify(Be.lib.WordArray.random(F))}},encryptPBES2Param:function(g,F){var A=At.getDKFromPBES2Param(g,F);try{var C=m.crypto.Cipher.encrypt(g.plain,A,g.encalg,{iv:g.enciv})}catch{throw new Error("encrypt error: "+g.plain+" "+A+" "+g.encalg+" "+g.enciv)}g.enc=C},generatePBES2ASN1Param:function(g){var F={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:g.salt}},{int:{hex:Sv(g.iter)}}]}]},{seq:[{oid:g.encalg},{octstr:{hex:g.enciv}}]}]}]},{octstr:{hex:g.enc}}]};return g.prf!="hmacWithSHA1"&&F.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:g.prf},{null:""}]}),F},parseHexOfEncryptedPKCS8:function(g){var F=Fe,A=F.getChildIdx,C=F.getV,S={},I=A(g,0);if(I.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+I.length);S.ciphertext=C(g,I[1]);var _=A(g,I[0]);if(_.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+_.length);if(C(g,_[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var L=A(g,_[1]);if(_.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+L.length);var M=A(g,L[1]);if(M.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+M.length);if(C(g,M[0])!="2a864886f70d0307")throw"this only supports TripleDES";S.encryptionSchemeAlg="TripleDES",S.encryptionSchemeIV=C(g,M[1]);var b=A(g,L[0]);if(b.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+b.length);if(C(g,b[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var B=A(g,b[1]);if(B.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+B.length);S.pbkdf2Salt=C(g,B[0]);var k=C(g,B[1]);try{S.pbkdf2Iter=parseInt(k,16)}catch{throw new Error("malformed format pbkdf2Iter: "+k)}return S},getPBKDF2KeyHexFromParam:function(g,F){var A=Be.enc.Hex.parse(g.pbkdf2Salt),C=g.pbkdf2Iter,S=Be.PBKDF2(F,A,{keySize:192/32,iterations:C}),I=Be.enc.Hex.stringify(S);return I},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(g,F){var A=cr(g,"ENCRYPTED PRIVATE KEY"),C=this.parseHexOfEncryptedPKCS8(A),S=At.getPBKDF2KeyHexFromParam(C,F),I={};I.ciphertext=Be.enc.Hex.parse(C.ciphertext);var _=Be.enc.Hex.parse(S),L=Be.enc.Hex.parse(C.encryptionSchemeIV),M=Be.TripleDES.decrypt(I,_,{iv:L}),b=Be.enc.Hex.stringify(M);return b},parsePBES2:function(g){var F=Fe.parse(g);if(Wt(F,"seq.0.seq.0.oid")!="pkcs5PBES2"||Wt(F,"seq.0.seq.1.seq.0.seq.0.oid")!="pkcs5PBKDF2")throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var A=Wt(F,"seq.0.seq.1.seq.0.seq.1.seq");if(A==null)throw new Error("PBKDF2 parameter not found");var C=Wt(A,"0.octstr.hex"),S=Wt(A,"1.int.hex"),I=Wt(A,"2.seq.0.oid","hmacWithSHA1"),_=-1;try{_=parseInt(S,16)}catch{throw new Error("iter not proper value")}var L=Wt(F,"seq.0.seq.1.seq.1.seq.0.oid"),M=Wt(F,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),b=Wt(F,"seq.1.octstr.hex");if(L==null||M==null||b==null)throw new Error("encalg, enciv or enc is undefined");var B={salt:C,iter:_,prf:I,encalg:L,enciv:M,enc:b};return B},getDKFromPBES2Param:function(g,F){var A={hmacWithSHA1:Be.algo.SHA1,hmacWithSHA224:Be.algo.SHA224,hmacWithSHA256:Be.algo.SHA256,hmacWithSHA384:Be.algo.SHA384,hmacWithSHA512:Be.algo.SHA512},C={"des-EDE3-CBC":192/32,"aes128-CBC":128/32,"aes256-CBC":256/32},S=A[g.prf];if(S==null)throw new Error("unsupported prf");var I=C[g.encalg];if(I==null)throw new Error("unsupported encalg");var _=Be.enc.Hex.parse(g.salt),L=g.iter;try{var M=Be.PBKDF2(F,_,{keySize:I,iterations:L,hasher:S});return Be.enc.Hex.stringify(M)}catch(b){throw new Error("PBKDF2 error: "+b+" "+JSON.stringify(g)+" "+F)}},getPlainHexFromEncryptedPKCS8PEM:function(g,F){if(g.indexOf("BEGIN ENCRYPTED PRIVATE KEY")==-1)throw new Error("not Encrypted PKCS#8 PEM string");var A=cr(g),C;try{C=At.parsePBES2(A)}catch(I){throw new Error("malformed PBES2 format: "+I.message)}var S=At.getDKFromPBES2Param(C,F);return m.crypto.Cipher.decrypt(C.enc,S,C.encalg,{iv:C.enciv})},getKeyFromEncryptedPKCS8PEM:function(g,F){var A=this.getPlainHexFromEncryptedPKCS8PEM(g,F),C=this.getKeyFromPlainPrivatePKCS8Hex(A);return C},parsePlainPrivatePKCS8Hex:function(g){var F=Fe,A=F.getChildIdx,C=F.getV,S={};if(S.algparam=null,g.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var I=A(g,0);if(I.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(g.substr(I[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var _=A(g,I[1]);if(_.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(g.substr(_[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(S.algoid=C(g,_[0]),g.substr(_[1],2)=="06"&&(S.algparam=C(g,_[1])),g.substr(I[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return S.keyidx=F.getVidx(g,I[2]),S},getKeyFromPlainPrivatePKCS8PEM:function(g){var F=cr(g,"PRIVATE KEY"),A=this.getKeyFromPlainPrivatePKCS8Hex(F);return A},getKeyFromPlainPrivatePKCS8Hex:function(g){var F=this.parsePlainPrivatePKCS8Hex(g),A;if(F.algoid=="2a864886f70d010101")A=new it;else if(F.algoid=="2a8648ce380401")A=new m.crypto.DSA;else if(F.algoid=="2a8648ce3d0201")A=new m.crypto.ECDSA;else throw new Error("unsupported private key algorithm");return A.readPKCS8PrvKeyHex(g),A},_getKeyFromPublicPKCS8Hex:function(g){var F,A=Fe.getVbyList(g,0,[0,0],"06");if(A==="2a864886f70d010101")F=new it;else if(A==="2a8648ce380401")F=new m.crypto.DSA;else if(A==="2a8648ce3d0201")F=new m.crypto.ECDSA;else throw new Error("unsupported PKCS#8 public key hex");return F.readPKCS8PubKeyHex(g),F},parsePublicRawRSAKeyHex:function(g){var F=Fe,A=F.getChildIdx,C=F.getV,S={};if(g.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var I=A(g,0);if(I.length!=2)throw new Error("malformed RSA key(code:002)");if(g.substr(I[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(S.n=C(g,I[0]),g.substr(I[1],2)!="02")throw new Error("malformed RSA key(code:004)");return S.e=C(g,I[1]),S},parsePublicPKCS8Hex:function(g){var F=Fe,A=F.getChildIdx,C=F.getV,S={};S.algparam=null;var I=A(g,0);if(I.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+I.length);var _=I[0];if(g.substr(_,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var L=A(g,_);if(L.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(g.substr(L[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(S.algoid=C(g,L[0]),g.substr(L[1],2)=="06"?S.algparam=C(g,L[1]):g.substr(L[1],2)=="30"&&(S.algparam={},S.algparam.p=F.getVbyList(g,L[1],[0],"02"),S.algparam.q=F.getVbyList(g,L[1],[1],"02"),S.algparam.g=F.getVbyList(g,L[1],[2],"02")),g.substr(I[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return S.key=C(g,I[1]).substr(2),S}}}();At.getKey=function(e,t,r){var n=Fe,s=n.getChildIdx,u=n.getV,i=n.getVbyList,o=m.crypto,l=o.ECDSA,h=o.DSA,p=it,E=cr,d=At;if(typeof p<"u"&&e instanceof p||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 p;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 p;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 p;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 p;return f.setPublic(ir(e.n),ir(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 p;return f.setPrivateEx(ir(e.n),ir(e.e),ir(e.d),ir(e.p),ir(e.q),ir(e.dp),ir(e.dq),ir(e.qi)),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var f=new p;return f.setPrivate(ir(e.n),ir(e.e),ir(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}),g=w.ecparams.keycharlen,F=("0000000000"+ir(e.x)).slice(-g),A=("0000000000"+ir(e.y)).slice(-g),C="04"+F+A;return w.setPublicKeyHex(C),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}),g=w.ecparams.keycharlen,F=("0000000000"+ir(e.x)).slice(-g),A=("0000000000"+ir(e.y)).slice(-g),C="04"+F+A,S=("0000000000"+ir(e.d)).slice(-g);return w.setPublicKeyHex(C),w.setPrivateKeyHex(S),w}if(r==="pkcs5prv"){var I=e,n=Fe,_,f;if(_=s(I,0),_.length===9)f=new p,f.readPKCS5PrvKeyHex(I);else if(_.length===6)f=new h,f.readPKCS5PrvKeyHex(I);else if(_.length>2&&I.substr(_[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=d.getKeyFromPlainPrivatePKCS8Hex(e);return f}if(r==="pkcs8pub")return d._getKeyFromPublicPKCS8Hex(e);if(r==="x509pub")return Xe.getPublicKeyFromCertHex(e);if(e.indexOf("-END CERTIFICATE-",0)!=-1||e.indexOf("-END X509 CERTIFICATE-",0)!=-1||e.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return Xe.getPublicKeyFromCertPEM(e);if(e.indexOf("-END PUBLIC KEY-")!=-1){var L=cr(e,"PUBLIC KEY");return d._getKeyFromPublicPKCS8Hex(L)}if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var M=E(e,"RSA PRIVATE KEY");return d.getKey(M,null,"pkcs5prv")}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var b=E(e,"DSA PRIVATE KEY"),B=i(b,0,[1],"02"),k=i(b,0,[2],"02"),U=i(b,0,[3],"02"),q=i(b,0,[4],"02"),W=i(b,0,[5],"02"),f=new h;return f.setPrivate(new ee(B,16),new ee(k,16),new ee(U,16),new ee(q,16),new ee(W,16)),f}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var M=E(e,"EC PRIVATE KEY");return d.getKey(M,null,"pkcs5prv")}if(e.indexOf("-END PRIVATE KEY-")!=-1)return d.getKeyFromPlainPrivatePKCS8PEM(e);if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var K=d.getDecryptedKeyHex(e,t),z=new it;return z.readPKCS5PrvKeyHex(K),z}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var b=d.getDecryptedKeyHex(e,t),f=i(b,0,[1],"04"),X=i(b,0,[2,0],"06"),se=i(b,0,[3,0],"03").substr(2),Ie="";if(m.crypto.OID.oidhex2name[X]!==void 0)Ie=m.crypto.OID.oidhex2name[X];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+X);var w=new l({curve:Ie});return w.setPublicKeyHex(se),w.setPrivateKeyHex(f),w.isPublic=!1,w}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var b=d.getDecryptedKeyHex(e,t),B=i(b,0,[1],"02"),k=i(b,0,[2],"02"),U=i(b,0,[3],"02"),q=i(b,0,[4],"02"),W=i(b,0,[5],"02"),f=new h;return f.setPrivate(new ee(B,16),new ee(k,16),new ee(U,16),new ee(q,16),new ee(W,16)),f}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return d.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};At.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new it;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var s=new it,u=n.n.toString(16),i=n.e.toString(16);s.setPublic(u,i),s.isPrivate=!1,s.isPublic=!0;var o={};return o.prvKeyObj=n,o.pubKeyObj=s,o}else if(e=="EC"){var l=t,h=new m.crypto.ECDSA({curve:l}),p=h.generateKeyPairHex(),n=new m.crypto.ECDSA({curve:l});n.setPublicKeyHex(p.ecpubhex),n.setPrivateKeyHex(p.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var s=new m.crypto.ECDSA({curve:l});s.setPublicKeyHex(p.ecpubhex),s.isPrivate=!1,s.isPublic=!0;var o={};return o.prvKeyObj=n,o.pubKeyObj=s,o}else throw new Error("unknown algorithm: "+e)};At.getPEM=function(e,t,r,n,s,u){var i=m,o=i.asn1,l=o.DERObjectIdentifier,h=o.DERInteger,p=o.ASN1Util.newObject,E=o.x509,d=E.SubjectPublicKeyInfo,f=i.crypto,w=f.DSA,g=f.ECDSA,F=it;function A(z){var X=p({seq:[{int:0},{int:{bigint:z.n}},{int:z.e},{int:{bigint:z.d}},{int:{bigint:z.p}},{int:{bigint:z.q}},{int:{bigint:z.dmp1}},{int:{bigint:z.dmq1}},{int:{bigint:z.coeff}}]});return X}function C(z){var X=p({seq:[{int:1},{octstr:{hex:z.prvKeyHex}},{tag:["a0",!0,{oid:{name:z.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+z.pubKeyHex}}]}]});return X}function S(z){var X=p({seq:[{int:0},{int:{bigint:z.p}},{int:{bigint:z.q}},{int:{bigint:z.g}},{int:{bigint:z.y}},{int:{bigint:z.x}}]});return X}if((F!==void 0&&e instanceof F||w!==void 0&&e instanceof w||g!==void 0&&e instanceof g)&&e.isPublic==!0&&(t===void 0||t=="PKCS8PUB")){var I=new d(e),_=I.tohex();return pn(_,"PUBLIC KEY")}if(t=="PKCS1PRV"&&F!==void 0&&e instanceof F&&(r===void 0||r==null)&&e.isPrivate==!0){var I=A(e),_=I.tohex();return pn(_,"RSA PRIVATE KEY")}if(t=="PKCS1PRV"&&g!==void 0&&e instanceof g&&(r===void 0||r==null)&&e.isPrivate==!0){var L=new l({name:e.curveName}),M=L.tohex(),b=C(e),B=b.tohex(),k="";return k+=pn(M,"EC PARAMETERS"),k+=pn(B,"EC PRIVATE KEY"),k}if(t=="PKCS1PRV"&&w!==void 0&&e instanceof w&&(r===void 0||r==null)&&e.isPrivate==!0){var I=S(e),_=I.tohex();return pn(_,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&F!==void 0&&e instanceof F&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=A(e),_=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",_,r,n,u)}if(t=="PKCS5PRV"&&g!==void 0&&e instanceof g&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=C(e),_=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",_,r,n,u)}if(t=="PKCS5PRV"&&w!==void 0&&e instanceof w&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=S(e),_=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",_,r,n,u)}var U=function(z,X){if(typeof X=="string")return At.getEncryptedPKCS8PEM(z,X);if(typeof X=="object"&&Wt(X,"passcode")!=null){var se=JSON.parse(JSON.stringify(X)),Ie=se.passcode;return delete se.passcode,At.getEncryptedPKCS8PEM(z,Ie,se)}};if(t=="PKCS8PRV"&&F!=null&&e instanceof F&&e.isPrivate==!0){var q=A(e),W=q.tohex(),I=p({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:W}}]}),_=I.tohex();return r===void 0||r==null?pn(_,"PRIVATE KEY"):U(_,r)}if(t=="PKCS8PRV"&&g!==void 0&&e instanceof g&&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 q=new p(K),W=q.tohex(),I=p({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:W}}]}),_=I.tohex();return r===void 0||r==null?pn(_,"PRIVATE KEY"):U(_,r)}if(t=="PKCS8PRV"&&w!==void 0&&e instanceof w&&e.isPrivate==!0){var q=new h({bigint:e.x}),W=q.tohex(),I=p({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:W}}]}),_=I.tohex();return r===void 0||r==null?pn(_,"PRIVATE KEY"):U(_,r)}throw new Error("unsupported object nor format")};At.getKeyFromCSRPEM=function(e){var t=cr(e,"CERTIFICATE REQUEST"),r=At.getKeyFromCSRHex(t);return r};At.getKeyFromCSRHex=function(e){var t=At.parseCSRHex(e),r=At.getKey(t.p8pubkeyhex,null,"pkcs8pub");return r};At.parseCSRHex=function(e){var t=Fe,r=t.getChildIdx,n=t.getTLV,s={},u=e;if(u.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var i=r(u,0);if(i.length<1)throw new Error("malformed CSR(code:002)");if(u.substr(i[0],2)!="30")throw new Error("malformed CSR(code:003)");var o=r(u,i[0]);if(o.length<3)throw new Error("malformed CSR(code:004)");return s.p8pubkeyhex=n(u,o[2]),s};At.getKeyID=function(e){var t=At,r=Fe;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=cr(t.getPEM(e)),s=r.getIdxbyList(n,0,[1]),u=r.getV(n,s).substring(2);return m.crypto.Util.hashHex(u,"sha1")};At.getJWK=function(e,t,r,n,s){var u,i={},o,l=m.crypto.Util.hashHex;if(typeof e=="string")u=At.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(o=cr(e));else if(typeof e=="object")e instanceof Xe?(u=e.getPublicKey(),o=e.hex):u=e;else throw new Error("unsupported keyinfo type");if(u instanceof it&&u.isPrivate)i.kty="RSA",i.n=Tr(u.n.toString(16)),i.e=Tr(u.e.toString(16)),i.d=Tr(u.d.toString(16)),i.p=Tr(u.p.toString(16)),i.q=Tr(u.q.toString(16)),i.dp=Tr(u.dmp1.toString(16)),i.dq=Tr(u.dmq1.toString(16)),i.qi=Tr(u.coeff.toString(16));else if(u instanceof it&&u.isPublic)i.kty="RSA",i.n=Tr(u.n.toString(16)),i.e=Tr(u.e.toString(16));else if(u instanceof m.crypto.ECDSA&&u.isPrivate){var h=u.getShortNISTPCurveName();if(h!=="P-256"&&h!=="P-384"&&h!=="P-521")throw new Error("unsupported curve name for JWT: "+h);var p=u.getPublicKeyXYHex();i.kty="EC",i.crv=h,i.x=Tr(p.x),i.y=Tr(p.y),i.d=Tr(u.prvKeyHex)}else if(u instanceof m.crypto.ECDSA&&u.isPublic){var h=u.getShortNISTPCurveName();if(h!=="P-256"&&h!=="P-384"&&h!=="P-521")throw new Error("unsupported curve name for JWT: "+h);var p=u.getPublicKeyXYHex();i.kty="EC",i.crv=h,i.x=Tr(p.x),i.y=Tr(p.y)}if(i.kty==null)throw new Error("unsupported keyinfo");return!u.isPrivate&&t!=!0&&(i.kid=m.jws.JWS.getJWKthumbprint(i)),o!=null&&r!=!0&&(i.x5c=[nu(o)]),o!=null&&n!=!0&&(i.x5t=Do(nu(l(o,"sha1")))),o!=null&&s!=!0&&(i["x5t#S256"]=Do(nu(l(o,"sha256")))),i};At.getJWKFromKey=function(e){return At.getJWK(e,!0,!0,!0,!0)};it.getPosArrayOfChildrenFromHex=function(e){return Fe.getChildIdx(e,0)};it.getHexValueArrayOfChildrenFromHex=function(e){var t=Fe,r=t.getV,d=it.getPosArrayOfChildrenFromHex(e),n=r(e,d[0]),s=r(e,d[1]),u=r(e,d[2]),i=r(e,d[3]),o=r(e,d[4]),l=r(e,d[5]),h=r(e,d[6]),p=r(e,d[7]),E=r(e,d[8]),d=new Array;return d.push(n,s,u,i,o,l,h,p,E),d};it.prototype.readPrivateKeyFromPEMString=function(e){var t=cr(e),r=it.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};it.prototype.readPKCS5PrvKeyHex=function(e){var t=it.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};it.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,s,u,i,o,l,h=Fe,p=h.getVbyListEx;if(h.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");try{t=p(e,0,[2,0,1],"02"),r=p(e,0,[2,0,2],"02"),n=p(e,0,[2,0,3],"02"),s=p(e,0,[2,0,4],"02"),u=p(e,0,[2,0,5],"02"),i=p(e,0,[2,0,6],"02"),o=p(e,0,[2,0,7],"02"),l=p(e,0,[2,0,8],"02")}catch{throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,s,u,i,o,l)};it.prototype.readPKCS5PubKeyHex=function(e){var t=Fe,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]),u=r(e,n[1]);this.setPublic(s,u)};it.prototype.readPKCS8PubKeyHex=function(e){var t=Fe;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)};it.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new Xe,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var CR=new RegExp("[^0-9a-f]","gi");function Bv(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}it.prototype.signPSS=function(e,t,r){var n=function(u){return m.crypto.Util.hashHex(u,t)},s=n(ds(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(s,t,r)};it.prototype.signWithMessageHashPSS=function(e,t,r){var n=Zn(e),s=n.length,u=this.n.bitLength()-1,i=Math.ceil(u/8),o,l=function(F){return m.crypto.Util.hashHex(F,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 _o().nextBytes(h),h=String.fromCharCode.apply(String,h));var p=Zn(l(ds("\0\0\0\0\0\0\0\0"+n+h))),E=[];for(o=0;o>8*i-u&255;for(w[0]&=~g,o=0;on)return!1;var s=this.doPublic(r),u=s.toString(16);if(u.length+3!=n/4)return!1;var i=u.replace(/^1f+00/,""),o=Pv(i);if(o.length==0)return!1;var l=o[0],h=o[1],p=function(d){return m.crypto.Util.hashString(d,l)},E=p(e);return h==E};it.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=Xn(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),s=n.toString(16).replace(/^1f+00/,""),u=Pv(s);if(u.length==0)return!1;var i=u[0],o=u[1];return o==e};it.prototype.verifyPSS=function(e,t,r,n){var s=function(i){return m.crypto.Util.hashHex(i,r)},u=s(ds(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(u,t,r,n)};it.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var s=new ee(t,16),u=function(C){return m.crypto.Util.hashHex(C,r)},i=Zn(e),o=i.length,l=this.n.bitLength()-1,h=Math.ceil(l/8),p;if(n===-1||n===void 0)n=o;else if(n===-2)n=h-o-2;else if(n<-2)throw new Error("invalid salt length");if(h>8*h-l&255;if(d.charCodeAt(0)&w)throw new Error("bits beyond keysize not zero");var g=$v(f,d.length,u),F=[];for(p=0;p0?B:void 0}catch{return}},this._asn1ToNoticeRef=function(b){try{for(var B={},k=Wt(b,"seq"),U=0;U0?B:void 0}catch{return}},this._asn1ToNoticeNum=function(b){try{for(var B=Wt(b,"seq"),k=[],U=0;U1){var W=i(b,q[1]),K=this.getGeneralName(W);K.uri!=null&&(U.uri=K.uri)}if(q.length>2){var z=i(b,q[2]);z=="0101ff"&&(U.reqauth=!0),z=="010100"&&(U.reqauth=!1)}return U},this.getExtSubjectDirectoryAttributes=function(b,B){if(b===void 0&&B===void 0){var k=this.getExtInfo("subjectDirectoryAttributes");if(k===void 0)return;b=i(this.hex,k.vidx),B=k.critical}var U={extname:"subjectDirectoryAttributes"};B&&(U.critical=!0);try{for(var q=u(b),W=[],K=0;K0&&(B.ext=this.getExtParamArray()),B.sighex=this.getSignatureValueHex(),b.tbshex==!0&&(B.tbshex=h(this.hex,0,[0])),b.nodnarray==!0&&(delete B.issuer.array,delete B.subject.array),B},this.getExtParamArray=function(b){if(b==null){var B=d(this.hex,0,[0,"[3]"]);B!=-1&&(b=p(this.hex,0,[0,"[3]",0],"30"))}for(var k=[],U=r(b,0),q=0;q"u"||!m)&&(m={});(typeof m.jws>"u"||!m.jws)&&(m.jws={});m.jws.JWS=function(){var e=m,t=e.jws.JWS,r=t.isSafeJSONString;this.parseJWS=function(n,s){if(!(this.parsedJWS!==void 0&&(s||this.parsedJWS.sigvalH!==void 0))){var u=n.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(u==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var i=u[1],o=u[2],l=u[3],h=i+"."+o;if(this.parsedJWS={},this.parsedJWS.headB64U=i,this.parsedJWS.payloadB64U=o,this.parsedJWS.sigvalB64U=l,this.parsedJWS.si=h,!s){var p=ir(l),E=Xn(p,16);this.parsedJWS.sigvalH=p,this.parsedJWS.sigvalBI=E}var d=Gi(i),f=Gi(o);if(this.parsedJWS.headS=d,this.parsedJWS.payloadS=f,!r(d,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+d}}};m.jws.JWS.sign=function(e,t,r,n,s){var u=m,i=u.jws,o=i.JWS,l=o.readSafeJSONString,h=o.isSafeJSONString,p=u.crypto,E=p.ECDSA,d=p.Mac,f=p.Signature,w=JSON,g,F,A;if(typeof t!="string"&&typeof t!="object")throw"spHeader must be JSON string or object: "+t;if(typeof t=="object"&&(F=t,g=w.stringify(F)),typeof t=="string"){if(g=t,!h(g))throw"JWS Head is not safe JSON string: "+g;F=l(g)}if(A=r,typeof r=="object"&&(A=w.stringify(r)),(e==""||e==null)&&F.alg!==void 0&&(e=F.alg),e!=""&&e!=null&&F.alg===void 0&&(F.alg=e,g=w.stringify(F)),e!==F.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+F.alg;var C=null;if(o.jwsalg2sigalg[e]===void 0)throw"unsupported alg name: "+e;C=o.jwsalg2sigalg[e];var S=Sc(g),I=Sc(A),_=S+"."+I,L="";if(C.substr(0,4)=="Hmac"){if(n===void 0)throw"mac key shall be specified for HS* alg";var M=new d({alg:C,prov:"cryptojs",pass:n});M.updateString(_),L=M.doFinal()}else if(C.indexOf("withECDSA")!=-1){var b=new f({alg:C});b.init(n,s),b.updateString(_);var B=b.sign();L=m.crypto.ECDSA.asn1SigToConcatSig(B)}else if(C!="none"){var b=new f({alg:C});b.init(n,s),b.updateString(_),L=b.sign()}var k=Tr(L);return _+"."+k};m.jws.JWS.verify=function(e,t,r){var n=m,s=n.jws,u=s.JWS,i=u.readSafeJSONString,o=n.crypto,l=o.ECDSA,h=o.Mac,p=o.Signature,E;if(typeof it!==void 0&&(E=it),!_p(e))return!1;var d=e.split(".");if(d.length!==3)return!1;var f=d[0],w=d[1],g=f+"."+w,F=ir(d[2]),A=i(Gi(d[0])),C=null,S=null;if(A.alg===void 0)throw"algorithm not specified in header";if(C=A.alg,S=C.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var I=":"+r.join(":")+":";if(I.indexOf(":"+C+":")==-1)throw"algorithm '"+C+"' not accepted in the list"}if(C!="none"&&t===null)throw"key shall be specified to verify.";if(typeof t=="string"&&t.indexOf("-----BEGIN ")!=-1&&(t=At.getKey(t)),(S=="RS"||S=="PS")&&!(t instanceof E))throw"key shall be a RSAKey obj for RS* and PS* algs";if(S=="ES"&&!(t instanceof l))throw"key shall be a ECDSA obj for ES* algs";C=="none";var _=null;if(u.jwsalg2sigalg[A.alg]===void 0)throw"unsupported alg name: "+C;if(_=u.jwsalg2sigalg[C],_=="none")throw"not supported";if(_.substr(0,4)=="Hmac"){var L=null;if(t===void 0)throw"hexadecimal key shall be specified for HMAC";var M=new h({alg:_,pass:t});return M.updateString(g),L=M.doFinal(),F==L}else if(_.indexOf("withECDSA")!=-1){var b=null;try{b=l.concatSigToASN1Sig(F)}catch{return!1}var B=new p({alg:_});return B.init(t),B.updateString(g),B.verify(b)}else{var B=new p({alg:_});return B.init(t),B.updateString(g),B.verify(F)}};m.jws.JWS.parse=function(e){var t=e.split("."),r={},n,s,u;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&&(u=t[2]),r.headerObj=m.jws.JWS.readSafeJSONString(Gi(n)),r.payloadObj=m.jws.JWS.readSafeJSONString(Gi(s)),r.headerPP=JSON.stringify(r.headerObj,null," "),r.payloadObj==null?r.payloadPP=Gi(s):r.payloadPP=JSON.stringify(r.payloadObj,null," "),u!==void 0&&(r.sigHex=ir(u)),r};m.jws.JWS.verifyJWT=function(e,t,r){var n=m,s=n.jws,u=s.JWS,i=u.readSafeJSONString,o=u.inArray,l=u.includedArray;if(!_p(e))return!1;var h=e.split(".");if(h.length!=3)return!1;var p=h[0],E=h[1],d=p+"."+E,f=ir(h[2]),w=i(Gi(p)),g=i(Gi(E));if(w.alg===void 0)return!1;if(r.alg===void 0)throw"acceptField.alg shall be specified";if(!o(w.alg,r.alg)||g.iss!==void 0&&typeof r.iss=="object"&&!o(g.iss,r.iss)||g.sub!==void 0&&typeof r.sub=="object"&&!o(g.sub,r.sub))return!1;if(g.aud!==void 0&&typeof r.aud=="object"){if(typeof g.aud=="string"){if(!o(g.aud,r.aud))return!1}else if(typeof g.aud=="object"&&!l(g.aud,r.aud))return!1}var F=s.IntDate.getNow();return r.verifyAt!==void 0&&typeof r.verifyAt=="number"&&(F=r.verifyAt),(r.gracePeriod===void 0||typeof r.gracePeriod!="number")&&(r.gracePeriod=0),!(g.exp!==void 0&&typeof g.exp=="number"&&g.exp+r.gracePeriod"u"||!m)&&(m={});(typeof m.jws>"u"||!m.jws)&&(m.jws={});m.jws.JWSJS=function(){var e=m,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 u=s.split(".");if(u.length!=3)throw"malformed input JWS";this.aHeader.push(u[0]),this.sPayload=u[1],this.aSignature.push(u[2])},this.addSignature=function(s,u,i,o){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=m.jws.JWS.sign(s,u,this.sPayload,i,o),p=h.split("."),E=p[0],d=p[2];this.aHeader.push(p[0]),this.aSignature.push(p[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 u=0;u0)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}};Se.SecureRandom=_o;Se.rng_seed_time=Fp;Se.BigInteger=ee;Se.RSAKey=it;Se.ECDSA=m.crypto.ECDSA;Se.DSA=m.crypto.DSA;Se.Signature=m.crypto.Signature;Se.MessageDigest=m.crypto.MessageDigest;Se.Mac=m.crypto.Mac;Se.KEYUTIL=At;Se.ASN1HEX=Fe;Se.X509=Xe;Se.X509CRL=f8;Se.CryptoJS=Be;Se.b64tohex=yo;Se.b64toBA=hv;Se.ECFieldElementFp=Or;Se.ECPointFp=Ot;Se.ECCurveFp=iu;Se.stoBA=Ev;Se.BAtos=Av;Se.BAtohex=Af;Se.stohex=Jn;Se.stob64=Kb;Se.stob64u=Gb;Se.b64utos=zb;Se.b64tob64u=Do;Se.b64utob64=_c;Se.hex2b64=nu;Se.hextob64u=Tr;Se.b64utohex=ir;Se.utf8tob64u=Sc;Se.b64utoutf8=Gi;Se.utf8tob64=Wb;Se.b64toutf8=Yb;Se.utf8tohex=wf;Se.hextoutf8=Ht;Se.hextorstr=Zn;Se.rstrtohex=ds;Se.hextob64=Dp;Se.hextob64nl=Zb;Se.b64nltohex=wv;Se.hextopem=pn;Se.pemtohex=cr;Se.hextoArrayBuffer=t8;Se.ArrayBuffertohex=r8;Se.zulutomsec=yp;Se.msectozulu=n8;Se.zulutosec=Cv;Se.zulutodate=i8;Se.datetozulu=s8;Se.uricmptohex=Ff;Se.hextouricmp=Df;Se.ipv6tohex=mp;Se.hextoipv6=vp;Se.hextoip=df;Se.iptohex=Sp;Se.ucs2hextoutf8=bp;Se.encodeURIComponentAll=yf;Se.newline_toUnix=u8;Se.newline_toDos=a8;Se.hextoposhex=Ep;Se.intarystrtohex=o8;Se.strdiffidx=c8;Se.oidtohex=yv;Se.hextooid=Sf;Se.strpad=gf;Se.bitstrtoint=bv;Se.inttobitstr=_v;Se.bitstrtobinstr=Iv;Se.binstrtobitstr=l8;Se.isBase64URLDot=_p;Se.namearraytobinstr=mf;Se.extendClass=de;Se.foldnl=Cf;Se.b64topem=Qb;Se.pemtob64=e8;Se.timeogen=Fv;Se.aryval=Wt;Se.inttohex=Sv;Se.twoscompl=Ic;Se.KJUR=m;Se.crypto=m.crypto;Se.asn1=m.asn1;Se.jws=m.jws;Se.lang=m.lang;Se.VERSION=w5;Se.VERSION_FULL=C5});var Ia=De((yR,_a)=>{"use strict";function Ov(e){return typeof e>"u"||e===null}function p8(e){return typeof e=="object"&&e!==null}function d8(e){return Array.isArray(e)?e:Ov(e)?[]:[e]}function g8(e,t){var r,n,s,u;if(t)for(u=Object.keys(t),r=0,n=u.length;r{"use strict";function Bc(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||""}Bc.prototype=Object.create(Error.prototype);Bc.prototype.constructor=Bc;Bc.prototype.toString=function(t){var r=this.name+": ";return r+=this.reason||"(unknown reason)",!t&&this.mark&&(r+=" "+this.mark.toString()),r};kv.exports=Bc});var Lv=De((bR,xv)=>{"use strict";var Nv=Ia();function Bp(e,t,r,n,s){this.name=e,this.buffer=t,this.position=r,this.line=n,this.column=s}Bp.prototype.getSnippet=function(t,r){var n,s,u,i,o;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(u="",i=this.position;ir/2-1){u=" ... ",i-=5;break}return o=this.buffer.slice(s,i),Nv.repeat(" ",t)+n+o+u+` `+Nv.repeat(" ",t+this.position-s+n.length)+"^"};Bp.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};xv.exports=Bp});var kr=De((_R,jv)=>{"use strict";var Uv=Io(),E8=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],A8=["scalar","sequence","mapping"];function w8(e){var t={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(n){t[String(n)]=r})}),t}function C8(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(E8.indexOf(r)===-1)throw new Uv('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=w8(t.styleAliases||null),A8.indexOf(this.kind)===-1)throw new Uv('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}jv.exports=C8});var Ba=De((IR,Mv)=>{"use strict";var Hv=Ia(),bf=Io(),F8=kr();function $p(e,t,r){var n=[];return e.include.forEach(function(s){r=$p(s,t,r)}),e[t].forEach(function(s){r.forEach(function(u,i){u.tag===s.tag&&u.kind===s.kind&&n.push(i)}),r.push(s)}),r.filter(function(s,u){return n.indexOf(u)===-1})}function D8(){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 y8=kr();qv.exports=new y8("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var Gv=De(($R,Kv)=>{"use strict";var S8=kr();Kv.exports=new S8("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var Wv=De((PR,zv)=>{"use strict";var b8=kr();zv.exports=new b8("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var _f=De((RR,Yv)=>{"use strict";var _8=Ba();Yv.exports=new _8({explicit:[Vv(),Gv(),Wv()]})});var Jv=De((TR,Xv)=>{"use strict";var I8=kr();function B8(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function $8(){return null}function P8(e){return e===null}Xv.exports=new I8("tag:yaml.org,2002:null",{kind:"scalar",resolve:B8,construct:$8,predicate:P8,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var Qv=De((OR,Zv)=>{"use strict";var R8=kr();function T8(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 O8(e){return e==="true"||e==="True"||e==="TRUE"}function k8(e){return Object.prototype.toString.call(e)==="[object Boolean]"}Zv.exports=new R8("tag:yaml.org,2002:bool",{kind:"scalar",resolve:T8,construct:O8,predicate:k8,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 t2=De((kR,e2)=>{"use strict";var N8=Ia(),x8=kr();function L8(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function U8(e){return 48<=e&&e<=55}function j8(e){return 48<=e&&e<=57}function H8(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 i2=De((NR,n2)=>{"use strict";var r2=Ia(),V8=kr(),K8=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 G8(e){return!(e===null||!K8.test(e)||e[e.length-1]==="_")}function z8(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(u){s.unshift(parseFloat(u,10))}),t=0,n=1,s.forEach(function(u){t+=u*n,n*=60}),r*t):r*parseFloat(t,10)}var W8=/^[-+]?[0-9]+e/;function Y8(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(r2.isNegativeZero(e))return"-0.0";return r=e.toString(10),W8.test(r)?r.replace("e",".e"):r}function X8(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||r2.isNegativeZero(e))}n2.exports=new V8("tag:yaml.org,2002:float",{kind:"scalar",resolve:G8,construct:z8,predicate:X8,represent:Y8,defaultStyle:"lowercase"})});var Pp=De((xR,s2)=>{"use strict";var J8=Ba();s2.exports=new J8({include:[_f()],implicit:[Jv(),Qv(),t2(),i2()]})});var Rp=De((LR,u2)=>{"use strict";var Z8=Ba();u2.exports=new Z8({include:[Pp()]})});var l2=De((UR,c2)=>{"use strict";var Q8=kr(),a2=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),o2=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 e_(e){return e===null?!1:a2.exec(e)!==null||o2.exec(e)!==null}function t_(e){var t,r,n,s,u,i,o,l=0,h=null,p,E,d;if(t=a2.exec(e),t===null&&(t=o2.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(u=+t[4],i=+t[5],o=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(p=+t[10],E=+(t[11]||0),h=(p*60+E)*6e4,t[9]==="-"&&(h=-h)),d=new Date(Date.UTC(r,n,s,u,i,o,l)),h&&d.setTime(d.getTime()-h),d}function r_(e){return e.toISOString()}c2.exports=new Q8("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:e_,construct:t_,instanceOf:Date,represent:r_})});var h2=De((jR,f2)=>{"use strict";var n_=kr();function i_(e){return e==="<<"||e===null}f2.exports=new n_("tag:yaml.org,2002:merge",{kind:"scalar",resolve:i_})});var g2=De((HR,d2)=>{"use strict";var $a;try{p2=Aa,$a=p2("buffer").Buffer}catch{}var p2,s_=kr(),Tp=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= \r`;function u_(e){if(e===null)return!1;var t,r,n=0,s=e.length,u=Tp;for(r=0;r64)){if(t<0)return!1;n+=6}return n%8===0}function a_(e){var t,r,n=e.replace(/[\r\n=]/g,""),s=n.length,u=Tp,i=0,o=[];for(t=0;t>16&255),o.push(i>>8&255),o.push(i&255)),i=i<<6|u.indexOf(n.charAt(t));return r=s%4*6,r===0?(o.push(i>>16&255),o.push(i>>8&255),o.push(i&255)):r===18?(o.push(i>>10&255),o.push(i>>2&255)):r===12&&o.push(i>>4&255),$a?$a.from?$a.from(o):new $a(o):o}function o_(e){var t="",r=0,n,s,u=e.length,i=Tp;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=u%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 c_(e){return $a&&$a.isBuffer(e)}d2.exports=new s_("tag:yaml.org,2002:binary",{kind:"scalar",resolve:u_,construct:a_,predicate:c_,represent:o_})});var v2=De((qR,m2)=>{"use strict";var l_=kr(),f_=Object.prototype.hasOwnProperty,h_=Object.prototype.toString;function p_(e){if(e===null)return!0;var t=[],r,n,s,u,i,o=e;for(r=0,n=o.length;r{"use strict";var g_=kr(),m_=Object.prototype.toString;function v_(e){if(e===null)return!0;var t,r,n,s,u,i=e;for(u=new Array(i.length),t=0,r=i.length;t{"use strict";var A_=kr(),w_=Object.prototype.hasOwnProperty;function C_(e){if(e===null)return!0;var t,r=e;for(t in r)if(w_.call(r,t)&&r[t]!==null)return!1;return!0}function F_(e){return e!==null?e:{}}w2.exports=new A_("tag:yaml.org,2002:set",{kind:"mapping",resolve:C_,construct:F_})});var $o=De((GR,F2)=>{"use strict";var D_=Ba();F2.exports=new D_({include:[Rp()],implicit:[l2(),h2()],explicit:[g2(),v2(),A2(),C2()]})});var y2=De((zR,D2)=>{"use strict";var y_=kr();function S_(){return!0}function b_(){}function __(){return""}function I_(e){return typeof e>"u"}D2.exports=new y_("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:S_,construct:b_,predicate:I_,represent:__})});var b2=De((WR,S2)=>{"use strict";var B_=kr();function $_(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 P_(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 R_(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}function T_(e){return Object.prototype.toString.call(e)==="[object RegExp]"}S2.exports=new B_("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:$_,construct:P_,predicate:T_,represent:R_})});var B2=De((YR,I2)=>{"use strict";var If;try{_2=Aa,If=_2("esprima")}catch{typeof window<"u"&&(If=window.esprima)}var _2,O_=kr();function k_(e){if(e===null)return!1;try{var t="("+e+")",r=If.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 N_(e){var t="("+e+")",r=If.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(u){n.push(u.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 x_(e){return e.toString()}function L_(e){return Object.prototype.toString.call(e)==="[object Function]"}I2.exports=new O_("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:k_,construct:N_,predicate:L_,represent:x_})});var $c=De((JR,P2)=>{"use strict";var $2=Ba();P2.exports=$2.DEFAULT=new $2({include:[$o()],explicit:[y2(),b2(),B2()]})});var X2=De((ZR,Pc)=>{"use strict";var su=Ia(),L2=Io(),U_=Lv(),U2=$o(),j_=$c(),Vu=Object.prototype.hasOwnProperty,Bf=1,j2=2,H2=3,$f=4,Op=1,H_=2,R2=3,M_=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,q_=/[\x85\u2028\u2029]/,V_=/[,\[\]\{\}]/,M2=/^(?:!|!!|![a-z\-]+!)$/i,q2=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function T2(e){return Object.prototype.toString.call(e)}function gs(e){return e===10||e===13}function Ra(e){return e===9||e===32}function Qn(e){return e===9||e===32||e===10||e===13}function Po(e){return e===44||e===91||e===93||e===123||e===125}function K_(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function G_(e){return e===120?2:e===117?4:e===85?8:0}function z_(e){return 48<=e&&e<=57?e-48:-1}function O2(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 W_(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var V2=new Array(256),K2=new Array(256);for(Pa=0;Pa<256;Pa++)V2[Pa]=O2(Pa)?1:0,K2[Pa]=O2(Pa);var Pa;function Y_(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||j_,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 G2(e,t){return new L2(t,new U_(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function Qe(e,t){throw G2(e,t)}function Pf(e,t){e.onWarning&&e.onWarning.call(null,G2(e,t))}var k2={YAML:function(t,r,n){var s,u,i;t.version!==null&&Qe(t,"duplication of %YAML directive"),n.length!==1&&Qe(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),s===null&&Qe(t,"ill-formed argument of the YAML directive"),u=parseInt(s[1],10),i=parseInt(s[2],10),u!==1&&Qe(t,"unacceptable YAML version of the document"),t.version=n[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&Pf(t,"unsupported YAML version of the document")},TAG:function(t,r,n){var s,u;n.length!==2&&Qe(t,"TAG directive accepts exactly two arguments"),s=n[0],u=n[1],M2.test(s)||Qe(t,"ill-formed tag handle (first argument) of the TAG directive"),Vu.call(t.tagMap,s)&&Qe(t,'there is a previously declared suffix for "'+s+'" tag handle'),q2.test(u)||Qe(t,"ill-formed tag prefix (second argument) of the TAG directive"),t.tagMap[s]=u}};function qu(e,t,r,n){var s,u,i,o;if(t1&&(e.result+=su.repeat(` `,t-1))}function X_(e,t,r){var n,s,u,i,o,l,h,p,E=e.kind,d=e.result,f;if(f=e.input.charCodeAt(e.position),Qn(f)||Po(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),Qn(s)||r&&Po(s)))return!1;for(e.kind="scalar",e.result="",u=i=e.position,o=!1;f!==0;){if(f===58){if(s=e.input.charCodeAt(e.position+1),Qn(s)||r&&Po(s))break}else if(f===35){if(n=e.input.charCodeAt(e.position-1),Qn(n))break}else{if(e.position===e.lineStart&&Rf(e)||r&&Po(f))break;if(gs(f))if(l=e.line,h=e.lineStart,p=e.lineIndent,Ir(e,!1,-1),e.lineIndent>=t){o=!0,f=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=l,e.lineStart=h,e.lineIndent=p;break}}o&&(qu(e,u,i,!1),Np(e,e.line-l),u=i=e.position,o=!1),Ra(f)||(i=e.position+1),f=e.input.charCodeAt(++e.position)}return qu(e,u,i,!1),e.result?!0:(e.kind=E,e.result=d,!1)}function J_(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(qu(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 gs(r)?(qu(e,n,s,!0),Np(e,Ir(e,!1,t)),n=s=e.position):e.position===e.lineStart&&Rf(e)?Qe(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);Qe(e,"unexpected end of the stream within a single quoted scalar")}function Z_(e,t){var r,n,s,u,i,o;if(o=e.input.charCodeAt(e.position),o!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=n=e.position;(o=e.input.charCodeAt(e.position))!==0;){if(o===34)return qu(e,r,e.position,!0),e.position++,!0;if(o===92){if(qu(e,r,e.position,!0),o=e.input.charCodeAt(++e.position),gs(o))Ir(e,!1,t);else if(o<256&&V2[o])e.result+=K2[o],e.position++;else if((i=G_(o))>0){for(s=i,u=0;s>0;s--)o=e.input.charCodeAt(++e.position),(i=K_(o))>=0?u=(u<<4)+i:Qe(e,"expected hexadecimal character");e.result+=W_(u),e.position++}else Qe(e,"unknown escape sequence");r=n=e.position}else gs(o)?(qu(e,r,n,!0),Np(e,Ir(e,!1,t)),r=n=e.position):e.position===e.lineStart&&Rf(e)?Qe(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}Qe(e,"unexpected end of the stream within a double quoted scalar")}function Q_(e,t){var r=!0,n,s=e.tag,u,i=e.anchor,o,l,h,p,E,d={},f,w,g,F;if(F=e.input.charCodeAt(e.position),F===91)l=93,E=!1,u=[];else if(F===123)l=125,E=!0,u={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),F=e.input.charCodeAt(++e.position);F!==0;){if(Ir(e,!0,t),F=e.input.charCodeAt(e.position),F===l)return e.position++,e.tag=s,e.anchor=i,e.kind=E?"mapping":"sequence",e.result=u,!0;r||Qe(e,"missed comma between flow collection entries"),w=f=g=null,h=p=!1,F===63&&(o=e.input.charCodeAt(e.position+1),Qn(o)&&(h=p=!0,e.position++,Ir(e,!0,t))),n=e.line,To(e,t,Bf,!1,!0),w=e.tag,f=e.result,Ir(e,!0,t),F=e.input.charCodeAt(e.position),(p||e.line===n)&&F===58&&(h=!0,F=e.input.charCodeAt(++e.position),Ir(e,!0,t),To(e,t,Bf,!1,!0),g=e.result),E?Ro(e,u,d,w,f,g):h?u.push(Ro(e,null,d,w,f,g)):u.push(f),Ir(e,!0,t),F=e.input.charCodeAt(e.position),F===44?(r=!0,F=e.input.charCodeAt(++e.position)):r=!1}Qe(e,"unexpected end of the stream within a flow collection")}function eI(e,t){var r,n,s=Op,u=!1,i=!1,o=t,l=0,h=!1,p,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)Op===s?s=E===43?R2:H_:Qe(e,"repeat of a chomping mode identifier");else if((p=z_(E))>=0)p===0?Qe(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?Qe(e,"repeat of an indentation width identifier"):(o=t+p-1,i=!0);else break;if(Ra(E)){do E=e.input.charCodeAt(++e.position);while(Ra(E));if(E===35)do E=e.input.charCodeAt(++e.position);while(!gs(E)&&E!==0)}for(;E!==0;){for(kp(e),e.lineIndent=0,E=e.input.charCodeAt(e.position);(!i||e.lineIndento&&(o=e.lineIndent),gs(E)){l++;continue}if(e.lineIndentt)&&l!==0)Qe(e,"bad indentation of a sequence entry");else if(e.lineIndentt)&&(To(e,t,$f,!0,s)&&(w?d=e.result:f=e.result),w||(Ro(e,h,p,E,d,f,u,i),E=d=f=null),Ir(e,!0,-1),F=e.input.charCodeAt(e.position)),e.lineIndent>t&&F!==0)Qe(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,d=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)):Qe(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):Qe(e,"unknown tag !<"+e.tag+">");return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||p}function sI(e){var t=e.position,r,n,s,u=!1,i;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};(i=e.input.charCodeAt(e.position))!==0&&(Ir(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||i!==37));){for(u=!0,i=e.input.charCodeAt(++e.position),r=e.position;i!==0&&!Qn(i);)i=e.input.charCodeAt(++e.position);for(n=e.input.slice(r,e.position),s=[],n.length<1&&Qe(e,"directive name must not be less than one character in length");i!==0;){for(;Ra(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!gs(i));break}if(gs(i))break;for(r=e.position;i!==0&&!Qn(i);)i=e.input.charCodeAt(++e.position);s.push(e.input.slice(r,e.position))}i!==0&&kp(e),Vu.call(k2,n)?k2[n](e,n,s):Pf(e,'unknown document directive "'+n+'"')}if(Ir(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,Ir(e,!0,-1)):u&&Qe(e,"directives end mark is expected"),To(e,e.lineIndent-1,$f,!1,!0),Ir(e,!0,-1),e.checkLineBreaks&&q_.test(e.input.slice(t,e.position))&&Pf(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Rf(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Ir(e,!0,-1));return}if(e.position"u"&&(r=t,t=null);var n=z2(e,r);if(typeof t!="function")return n;for(var s=0,u=n.length;s"u"&&(r=t,t=null),W2(e,t,su.extend({schema:U2},r))}function aI(e,t){return Y2(e,su.extend({schema:U2},t))}Pc.exports.loadAll=W2;Pc.exports.load=Y2;Pc.exports.safeLoadAll=uI;Pc.exports.safeLoad=aI});var AE=De((QR,jp)=>{"use strict";var Tc=Ia(),Oc=Io(),oI=$c(),cI=$o(),iE=Object.prototype.toString,sE=Object.prototype.hasOwnProperty,lI=9,Rc=10,fI=13,hI=32,pI=33,dI=34,uE=35,gI=37,mI=38,vI=39,EI=42,aE=44,AI=45,oE=58,wI=61,CI=62,FI=63,DI=64,cE=91,lE=93,yI=96,fE=123,SI=124,hE=125,dn={};dn[0]="\\0";dn[7]="\\a";dn[8]="\\b";dn[9]="\\t";dn[10]="\\n";dn[11]="\\v";dn[12]="\\f";dn[13]="\\r";dn[27]="\\e";dn[34]='\\"';dn[92]="\\\\";dn[133]="\\N";dn[160]="\\_";dn[8232]="\\L";dn[8233]="\\P";var bI=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function _I(e,t){var r,n,s,u,i,o,l;if(t===null)return{};for(r={},n=Object.keys(t),s=0,u=n.length;s0?e.charCodeAt(u-1):null,d=d&&Q2(i,o)}else{for(u=0;un&&e[E+1]!==" ",E=u);else if(!Oo(i))return Tf;o=u>0?e.charCodeAt(u-1):null,d=d&&Q2(i,o)}h=h||p&&u-E-1>n&&e[E+1]!==" "}return!l&&!h?d&&!s(e)?dE:gE:r>9&&pE(e)?Tf:h?vE:mE}function TI(e,t,r,n){e.dump=function(){if(t.length===0)return"''";if(!e.noCompatMode&&bI.indexOf(t)!==-1)return"'"+t+"'";var s=e.indent*Math.max(1,r),u=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),i=n||e.flowLevel>-1&&r>=e.flowLevel;function o(l){return BI(e,l)}switch(RI(t,i,e.indent,u,o)){case dE:return t;case gE:return"'"+t.replace(/'/g,"''")+"'";case mE:return"|"+eE(t,e.indent)+tE(Z2(t,s));case vE:return">"+eE(t,e.indent)+tE(Z2(OI(t,u),s));case Tf:return'"'+kI(t,u)+'"';default:throw new Oc("impossible error: invalid scalar style")}}()}function eE(e,t){var r=pE(e)?String(t):"",n=e[e.length-1]===` `,s=n&&(e[e.length-2]===` `||e===` `),u=s?"+":n?"":"-";return r+u+` `}function tE(e){return e[e.length-1]===` `?e.slice(0,-1):e}function OI(e,t){for(var r=/(\n+)([^\n]*)/g,n=function(){var h=e.indexOf(` `);return h=h!==-1?h:e.length,r.lastIndex=h,rE(e.slice(0,h),t)}(),s=e[0]===` `||e[0]===" ",u,i;i=r.exec(e);){var o=i[1],l=i[2];u=l[0]===" ",n+=o+(!s&&!u&&l!==""?` `:"")+rE(l,t),s=u}return n}function rE(e,t){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,n,s=0,u,i=0,o=0,l="";n=r.exec(e);)o=n.index,o-s>t&&(u=i>s?i:o,l+=` `+e.slice(s,u),s=u+1),i=o;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 kI(e){for(var t="",r,n,s,u=0;u=55296&&r<=56319&&(n=e.charCodeAt(u+1),n>=56320&&n<=57343)){t+=J2((r-55296)*1024+n-56320+65536),u++;continue}s=dn[r],t+=!s&&Oo(r)?e[u]:s||J2(r)}return t}function NI(e,t,r){var n="",s=e.tag,u,i;for(u=0,i=r.length;u1024&&(p+="? "),p+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),Ta(e,t,h,!1,!1)&&(p+=e.dump,n+=p));e.tag=s,e.dump="{"+n+"}"}function UI(e,t,r,n){var s="",u=e.tag,i=Object.keys(r),o,l,h,p,E,d;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new Oc("sortKeys must be a boolean or a function");for(o=0,l=i.length;o1024,E&&(e.dump&&Rc===e.dump.charCodeAt(0)?d+="?":d+="? "),d+=e.dump,E&&(d+=xp(e,t)),Ta(e,t+1,p,!0,E)&&(e.dump&&Rc===e.dump.charCodeAt(0)?d+=":":d+=": ",d+=e.dump,s+=d));e.tag=u,e.dump=s||"{}"}function nE(e,t,r){var n,s,u,i,o,l;for(s=r?e.explicitTypes:e.implicitTypes,u=0,i=s.length;u tag resolver accepts not "'+l+'" style');e.dump=n}return!0}return!1}function Ta(e,t,r,n,s,u){e.tag=null,e.dump=r,nE(e,r,!1)||nE(e,r,!0);var i=iE.call(e.dump);n&&(n=e.flowLevel<0||e.flowLevel>t);var o=i==="[object Object]"||i==="[object Array]",l,h;if(o&&(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(o&&h&&!e.usedDuplicates[l]&&(e.usedDuplicates[l]=!0),i==="[object Object]")n&&Object.keys(e.dump).length!==0?(UI(e,t,e.dump,s),h&&(e.dump="&ref_"+l+e.dump)):(LI(e,t,e.dump),h&&(e.dump="&ref_"+l+" "+e.dump));else if(i==="[object Array]"){var p=e.noArrayIndent&&t>0?t-1:t;n&&e.dump.length!==0?(xI(e,p,e.dump,s),h&&(e.dump="&ref_"+l+e.dump)):(NI(e,p,e.dump),h&&(e.dump="&ref_"+l+" "+e.dump))}else if(i==="[object String]")e.tag!=="?"&&TI(e,e.dump,t,u);else{if(e.skipInvalid)return!1;throw new Oc("unacceptable kind of an object to dump "+i)}e.tag!==null&&e.tag!=="?"&&(e.dump="!<"+e.tag+"> "+e.dump)}return!0}function jI(e,t){var r=[],n=[],s,u;for(Lp(e,r,n),s=0,u=n.length;s{"use strict";var Of=X2(),wE=AE();function kf(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}vr.exports.Type=kr();vr.exports.Schema=Ba();vr.exports.FAILSAFE_SCHEMA=_f();vr.exports.JSON_SCHEMA=Pp();vr.exports.CORE_SCHEMA=Rp();vr.exports.DEFAULT_SAFE_SCHEMA=$o();vr.exports.DEFAULT_FULL_SCHEMA=$c();vr.exports.load=Of.load;vr.exports.loadAll=Of.loadAll;vr.exports.safeLoad=Of.safeLoad;vr.exports.safeLoadAll=Of.safeLoadAll;vr.exports.dump=wE.dump;vr.exports.safeDump=wE.safeDump;vr.exports.YAMLException=Io();vr.exports.MINIMAL_SCHEMA=_f();vr.exports.SAFE_SCHEMA=$o();vr.exports.DEFAULT_SCHEMA=$c();vr.exports.scan=kf("scan");vr.exports.parse=kf("parse");vr.exports.compose=kf("compose");vr.exports.addConstructor=kf("addConstructor")});var DE=De((tT,FE)=>{"use strict";var MI=CE();FE.exports=MI});var SE=De((rT,yE)=>{"use strict";var Nf=DE();yE.exports={safeLoad:Nf.safeLoad,load:Nf.load,safeDump:Nf.safeDump,dump:Nf.dump}});var Mp=De(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.isCorrect=ko.isInSubnet=void 0;function JI(e){return this.subnetMask{"use strict";Object.defineProperty(vs,"__esModule",{value:!0});vs.RE_SUBNET_STRING=vs.RE_ADDRESS=vs.GROUPS=vs.BITS=void 0;vs.BITS=32;vs.GROUPS=4;vs.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;vs.RE_SUBNET_STRING=/\/\d{1,2}$/});var Uf=De(Lf=>{"use strict";Object.defineProperty(Lf,"__esModule",{value:!0});Lf.AddressError=void 0;var Vp=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};Lf.AddressError=Vp});var Kp=De((jf,BE)=>{(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n(R,O,H){R!=null&&(typeof R=="number"?this.fromNumber(R,O,H):O==null&&typeof R!="string"?this.fromString(R,256):this.fromString(R,O))}function s(){return new n(null)}function u(R,O,H,Q,ve,we){for(;--we>=0;){var $e=O*this[R++]+H[Q]+ve;ve=Math.floor($e/67108864),H[Q++]=$e&67108863}return ve}function i(R,O,H,Q,ve,we){for(var $e=O&32767,ke=O>>15;--we>=0;){var Vt=this[R]&32767,dr=this[R++]>>15,Qr=ke*Vt+dr*$e;Vt=$e*Vt+((Qr&32767)<<15)+H[Q]+(ve&1073741823),ve=(Vt>>>30)+(Qr>>>15)+ke*dr+(ve>>>30),H[Q++]=Vt&1073741823}return ve}function o(R,O,H,Q,ve,we){for(var $e=O&16383,ke=O>>14;--we>=0;){var Vt=this[R]&16383,dr=this[R++]>>14,Qr=ke*Vt+dr*$e;Vt=$e*Vt+((Qr&16383)<<14)+H[Q]+ve,ve=(Vt>>28)+(Qr>>14)+ke*dr,H[Q++]=Vt&268435455}return ve}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=u,e=26):(n.prototype.am=o,e=28),n.prototype.DB=e,n.prototype.DM=(1<=0;--O)R[O]=this[O];R.t=this.t,R.s=this.s}function A(R){this.t=1,this.s=R<0?-1:0,R>0?this[0]=R:R<-1?this[0]=R+this.DV:this.t=0}function C(R){var O=s();return O.fromInt(R),O}function S(R,O){var H;if(O==16)H=4;else if(O==8)H=3;else if(O==256)H=8;else if(O==2)H=1;else if(O==32)H=5;else if(O==4)H=2;else{this.fromRadix(R,O);return}this.t=0,this.s=0;for(var Q=R.length,ve=!1,we=0;--Q>=0;){var $e=H==8?R[Q]&255:g(R,Q);if($e<0){R.charAt(Q)=="-"&&(ve=!0);continue}ve=!1,we==0?this[this.t++]=$e:we+H>this.DB?(this[this.t-1]|=($e&(1<>this.DB-we):this[this.t-1]|=$e<=this.DB&&(we-=this.DB)}H==8&&R[0]&128&&(this.s=-1,we>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==R;)--this.t}function _(R){if(this.s<0)return"-"+this.negate().toString(R);var O;if(R==16)O=4;else if(R==8)O=3;else if(R==2)O=1;else if(R==32)O=5;else if(R==4)O=2;else return this.toRadix(R);var H=(1<0)for(ke>ke)>0&&(ve=!0,we=w(Q));$e>=0;)ke>(ke+=this.DB-O)):(Q=this[$e]>>(ke-=O)&H,ke<=0&&(ke+=this.DB,--$e)),Q>0&&(ve=!0),ve&&(we+=w(Q));return ve?we:"0"}function L(){var R=s();return n.ZERO.subTo(this,R),R}function M(){return this.s<0?this.negate():this}function b(R){var O=this.s-R.s;if(O!=0)return O;var H=this.t;if(O=H-R.t,O!=0)return this.s<0?-O:O;for(;--H>=0;)if((O=this[H]-R[H])!=0)return O;return 0}function B(R){var O=1,H;return(H=R>>>16)!=0&&(R=H,O+=16),(H=R>>8)!=0&&(R=H,O+=8),(H=R>>4)!=0&&(R=H,O+=4),(H=R>>2)!=0&&(R=H,O+=2),(H=R>>1)!=0&&(R=H,O+=1),O}function k(){return this.t<=0?0:this.DB*(this.t-1)+B(this[this.t-1]^this.s&this.DM)}function U(R,O){var H;for(H=this.t-1;H>=0;--H)O[H+R]=this[H];for(H=R-1;H>=0;--H)O[H]=0;O.t=this.t+R,O.s=this.s}function q(R,O){for(var H=R;H=0;--ke)O[ke+we+1]=this[ke]>>Q|$e,$e=(this[ke]&ve)<=0;--ke)O[ke]=0;O[we]=$e,O.t=this.t+we+1,O.s=this.s,O.clamp()}function K(R,O){O.s=this.s;var H=Math.floor(R/this.DB);if(H>=this.t){O.t=0;return}var Q=R%this.DB,ve=this.DB-Q,we=(1<>Q;for(var $e=H+1;$e>Q;Q>0&&(O[this.t-H-1]|=(this.s&we)<>=this.DB;if(R.t>=this.DB;Q+=this.s}else{for(Q+=this.s;H>=this.DB;Q-=R.s}O.s=Q<0?-1:0,Q<-1?O[H++]=this.DV+Q:Q>0&&(O[H++]=Q),O.t=H,O.clamp()}function X(R,O){var H=this.abs(),Q=R.abs(),ve=H.t;for(O.t=ve+Q.t;--ve>=0;)O[ve]=0;for(ve=0;ve=0;)R[H]=0;for(H=0;H=O.DV&&(R[H+O.t]-=O.DV,R[H+O.t+1]=1)}R.t>0&&(R[R.t-1]+=O.am(H,O[H],R,2*H,0,1)),R.s=0,R.clamp()}function Ie(R,O,H){var Q=R.abs();if(!(Q.t<=0)){var ve=this.abs();if(ve.t0?(Q.lShiftTo(Vt,we),ve.lShiftTo(Vt,H)):(Q.copyTo(we),ve.copyTo(H));var dr=we.t,Qr=we[dr-1];if(Qr!=0){var en=Qr*(1<1?we[dr-2]>>this.F2:0),si=this.FV/en,Iu=(1<=0&&(H[H.t++]=1,H.subTo(yi,H)),n.ONE.dlShiftTo(dr,yi),yi.subTo(we,we);we.t=0;){var oa=H[--tn]==Qr?this.DM:Math.floor(H[tn]*si+(H[tn-1]+yn)*Iu);if((H[tn]+=we.am(0,oa,H,Bu,0,dr))0&&H.rShiftTo(Vt,H),$e<0&&n.ZERO.subTo(H,H)}}}function be(R){var O=s();return this.abs().divRemTo(R,null,O),this.s<0&&O.compareTo(n.ZERO)>0&&R.subTo(O,O),O}function Re(R){this.m=R}function Je(R){return R.s<0||R.compareTo(this.m)>=0?R.mod(this.m):R}function ae(R){return R}function ye(R){R.divRemTo(this.m,null,R)}function He(R,O,H){R.multiplyTo(O,H),this.reduce(H)}function Zt(R,O){R.squareTo(O),this.reduce(O)}Re.prototype.convert=Je,Re.prototype.revert=ae,Re.prototype.reduce=ye,Re.prototype.mulTo=He,Re.prototype.sqrTo=Zt;function It(){if(this.t<1)return 0;var R=this[0];if(!(R&1))return 0;var O=R&3;return O=O*(2-(R&15)*O)&15,O=O*(2-(R&255)*O)&255,O=O*(2-((R&65535)*O&65535))&65535,O=O*(2-R*O%this.DV)%this.DV,O>0?this.DV-O:-O}function Ct(R){this.m=R,this.mp=R.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(O,O),O}function er(R){var O=s();return R.copyTo(O),this.reduce(O),O}function pt(R){for(;R.t<=this.mt2;)R[R.t++]=0;for(var O=0;O>15)*this.mpl&this.um)<<15)&R.DM;for(H=O+this.m.t,R[H]+=this.m.am(0,Q,R,O,0,this.m.t);R[H]>=R.DV;)R[H]-=R.DV,R[++H]++}R.clamp(),R.drShiftTo(this.m.t,R),R.compareTo(this.m)>=0&&R.subTo(this.m,R)}function Mt(R,O){R.squareTo(O),this.reduce(O)}function st(R,O,H){R.multiplyTo(O,H),this.reduce(H)}Ct.prototype.convert=lr,Ct.prototype.revert=er,Ct.prototype.reduce=pt,Ct.prototype.mulTo=st,Ct.prototype.sqrTo=Mt;function We(){return(this.t>0?this[0]&1:this.s)==0}function tr(R,O){if(R>4294967295||R<1)return n.ONE;var H=s(),Q=s(),ve=O.convert(this),we=B(R)-1;for(ve.copyTo(H);--we>=0;)if(O.sqrTo(H,Q),(R&1<0)O.mulTo(Q,ve,H);else{var $e=H;H=Q,Q=$e}return O.revert(H)}function Ve(R,O){var H;return R<256||O.isEven()?H=new Re(O):H=new Ct(O),this.exp(R,H)}n.prototype.copyTo=F,n.prototype.fromInt=A,n.prototype.fromString=S,n.prototype.clamp=I,n.prototype.dlShiftTo=U,n.prototype.drShiftTo=q,n.prototype.lShiftTo=W,n.prototype.rShiftTo=K,n.prototype.subTo=z,n.prototype.multiplyTo=X,n.prototype.squareTo=se,n.prototype.divRemTo=Ie,n.prototype.invDigit=It,n.prototype.isEven=We,n.prototype.exp=tr,n.prototype.toString=_,n.prototype.negate=L,n.prototype.abs=M,n.prototype.compareTo=b,n.prototype.bitLength=k,n.prototype.mod=be,n.prototype.modPowInt=Ve,n.ZERO=C(0),n.ONE=C(1);function Rt(){var R=s();return this.copyTo(R),R}function zr(){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 qt(){return this.t==0?this.s:this[0]<<16>>16}function mt(R){return Math.floor(Math.LN2*this.DB/Math.log(R))}function yr(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function ii(R){if(R==null&&(R=10),this.signum()==0||R<2||R>36)return"0";var O=this.chunkSize(R),H=Math.pow(R,O),Q=C(H),ve=s(),we=s(),$e="";for(this.divRemTo(Q,ve,we);ve.signum()>0;)$e=(H+we.intValue()).toString(R).substr(1)+$e,ve.divRemTo(Q,ve,we);return we.intValue().toString(R)+$e}function Wr(R,O){this.fromInt(0),O==null&&(O=10);for(var H=this.chunkSize(O),Q=Math.pow(O,H),ve=!1,we=0,$e=0,ke=0;ke=H&&(this.dMultiply(Q),this.dAddOffset($e,0),we=0,$e=0)}we>0&&(this.dMultiply(Math.pow(O,we)),this.dAddOffset($e,0)),ve&&n.ZERO.subTo(this,this)}function yt(R,O,H){if(typeof O=="number")if(R<2)this.fromInt(1);else for(this.fromNumber(R,H),this.testBit(R-1)||this.bitwiseTo(n.ONE.shiftLeft(R-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(O);)this.dAddOffset(2,0),this.bitLength()>R&&this.subTo(n.ONE.shiftLeft(R-1),this);else{var Q=new Array,ve=R&7;Q.length=(R>>3)+1,O.nextBytes(Q),ve>0?Q[0]&=(1<0)for(H>H)!=(this.s&this.DM)>>H&&(O[ve++]=Q|this.s<=0;)H<8?(Q=(this[R]&(1<>(H+=this.DB-8)):(Q=this[R]>>(H-=8)&255,H<=0&&(H+=this.DB,--R)),Q&128&&(Q|=-256),ve==0&&(this.s&128)!=(Q&128)&&++ve,(ve>0||Q!=this.s)&&(O[ve++]=Q);return O}function _e(R){return this.compareTo(R)==0}function fr(R){return this.compareTo(R)<0?this:R}function Yr(R){return this.compareTo(R)>0?this:R}function ut(R,O,H){var Q,ve,we=Math.min(R.t,this.t);for(Q=0;Q>=16,O+=16),R&255||(R>>=8,O+=8),R&15||(R>>=4,O+=4),R&3||(R>>=2,O+=2),R&1||++O,O}function Tt(){for(var R=0;R=this.t?this.s!=0:(this[O]&1<>=this.DB;if(R.t>=this.DB;Q+=this.s}else{for(Q+=this.s;H>=this.DB;Q+=R.s}O.s=Q<0?-1:0,Q>0?O[H++]=Q:Q<-1&&(O[H++]=this.DV+Q),O.t=H,O.clamp()}function ks(R){var O=s();return this.addTo(R,O),O}function re(R){var O=s();return this.subTo(R,O),O}function fe(R){var O=s();return this.multiplyTo(R,O),O}function je(){var R=s();return this.squareTo(R),R}function Ne(R){var O=s();return this.divRemTo(R,O,null),O}function ze(R){var O=s();return this.divRemTo(R,null,O),O}function at(R){var O=s(),H=s();return this.divRemTo(R,O,H),new Array(O,H)}function ht(R){this[this.t]=this.am(0,R-1,this,0,0,this.t),++this.t,this.clamp()}function Ar(R,O){if(R!=0){for(;this.t<=O;)this[this.t++]=0;for(this[O]+=R;this[O]>=this.DV;)this[O]-=this.DV,++O>=this.t&&(this[this.t++]=0),++this[O]}}function Lt(){}function Ln(R){return R}function Di(R,O,H){R.multiplyTo(O,H)}function Jr(R,O){R.squareTo(O)}Lt.prototype.convert=Ln,Lt.prototype.revert=Ln,Lt.prototype.mulTo=Di,Lt.prototype.sqrTo=Jr;function cn(R){return this.exp(R,new Lt)}function hr(R,O,H){var Q=Math.min(this.t+R.t,O);for(H.s=0,H.t=Q;Q>0;)H[--Q]=0;var ve;for(ve=H.t-this.t;Q=0;)H[Q]=0;for(Q=Math.max(O-this.t,0);Q2*this.m.t)return R.mod(this.m);if(R.compareTo(this.m)<0)return R;var O=s();return R.copyTo(O),this.reduce(O),O}function is(R){return R}function wn(R){for(R.drShiftTo(this.m.t-1,this.r2),R.t>this.m.t+1&&(R.t=this.m.t+1,R.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);R.compareTo(this.r2)<0;)R.dAddOffset(1,this.m.t+1);for(R.subTo(this.r2,R);R.compareTo(this.m)>=0;)R.subTo(this.m,R)}function Pt(R,O){R.squareTo(O),this.reduce(O)}function pr(R,O,H){R.multiplyTo(O,H),this.reduce(H)}Pr.prototype.convert=ea,Pr.prototype.revert=is,Pr.prototype.reduce=wn,Pr.prototype.mulTo=pr,Pr.prototype.sqrTo=Pt;function rt(R,O){var H=R.bitLength(),Q,ve=C(1),we;if(H<=0)return ve;H<18?Q=1:H<48?Q=3:H<144?Q=4:H<768?Q=5:Q=6,H<8?we=new Re(O):O.isEven()?we=new Pr(O):we=new Ct(O);var $e=new Array,ke=3,Vt=Q-1,dr=(1<1){var Qr=s();for(we.sqrTo($e[1],Qr);ke<=dr;)$e[ke]=s(),we.mulTo(Qr,$e[ke-2],$e[ke]),ke+=2}var en=R.t-1,si,Iu=!0,yn=s(),tn;for(H=B(R[en])-1;en>=0;){for(H>=Vt?si=R[en]>>H-Vt&dr:(si=(R[en]&(1<0&&(si|=R[en-1]>>this.DB+H-Vt)),ke=Q;!(si&1);)si>>=1,--ke;if((H-=ke)<0&&(H+=this.DB,--en),Iu)$e[si].copyTo(ve),Iu=!1;else{for(;ke>1;)we.sqrTo(ve,yn),we.sqrTo(yn,ve),ke-=2;ke>0?we.sqrTo(ve,yn):(tn=ve,ve=yn,yn=tn),we.mulTo(yn,$e[si],ve)}for(;en>=0&&!(R[en]&1<0&&(O.rShiftTo(we,O),H.rShiftTo(we,H));O.signum()>0;)(ve=O.getLowestSetBit())>0&&O.rShiftTo(ve,O),(ve=H.getLowestSetBit())>0&&H.rShiftTo(ve,H),O.compareTo(H)>=0?(O.subTo(H,O),O.rShiftTo(1,O)):(H.subTo(O,H),H.rShiftTo(1,H));return we>0&&H.lShiftTo(we,H),H}function xr(R){if(R<=0)return 0;var O=this.DV%R,H=this.s<0?R-1:0;if(this.t>0)if(O==0)H=this[0]%R;else for(var Q=this.t-1;Q>=0;--Q)H=(O*H+this[Q])%R;return H}function nr(R){var O=R.isEven();if(this.isEven()&&O||R.signum()==0)return n.ZERO;for(var H=R.clone(),Q=this.clone(),ve=C(1),we=C(0),$e=C(0),ke=C(1);H.signum()!=0;){for(;H.isEven();)H.rShiftTo(1,H),O?((!ve.isEven()||!we.isEven())&&(ve.addTo(this,ve),we.subTo(R,we)),ve.rShiftTo(1,ve)):we.isEven()||we.subTo(R,we),we.rShiftTo(1,we);for(;Q.isEven();)Q.rShiftTo(1,Q),O?((!$e.isEven()||!ke.isEven())&&($e.addTo(this,$e),ke.subTo(R,ke)),$e.rShiftTo(1,$e)):ke.isEven()||ke.subTo(R,ke),ke.rShiftTo(1,ke);H.compareTo(Q)>=0?(H.subTo(Q,H),O&&ve.subTo($e,ve),we.subTo(ke,we)):(Q.subTo(H,Q),O&&$e.subTo(ve,$e),ke.subTo(we,ke))}if(Q.compareTo(n.ONE)!=0)return n.ZERO;if(ke.compareTo(R)>=0)return ke.subtract(R);if(ke.signum()<0)ke.addTo(R,ke);else return ke;return ke.signum()<0?ke.add(R):ke}var Ut=[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],Cn=(1<<26)/Ut[Ut.length-1];function Un(R){var O,H=this.abs();if(H.t==1&&H[0]<=Ut[Ut.length-1]){for(O=0;O>1,R>Ut.length&&(R=Ut.length);for(var ve=s(),we=0;we>8&255,Sr[sr++]^=R>>16&255,Sr[sr++]^=R>>24&255,sr>=Dn&&(sr-=Dn)}function ta(){Zo(new Date().getTime())}if(Sr==null){Sr=new Array,sr=0;var Lr;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var ra=new Uint8Array(32);for(window.crypto.getRandomValues(ra),Lr=0;Lr<32;++Lr)Sr[sr++]=ra[Lr]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var qa=window.crypto.random(32);for(Lr=0;Lr>>8,Sr[sr++]=Lr&255;sr=0,ta()}function Va(){if(Fn==null){for(ta(),Fn=aa(),Fn.init(Sr),sr=0;sr{(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(u(i),arguments)}function r(i,o){return t.apply(null,[i].concat(o||[]))}function n(i,o){var l=1,h=i.length,p,E="",d,f,w,g,F,A,C,S;for(d=0;d=0),w.type){case"b":p=parseInt(p,10).toString(2);break;case"c":p=String.fromCharCode(parseInt(p,10));break;case"d":case"i":p=parseInt(p,10);break;case"j":p=JSON.stringify(p,null,w.width?parseInt(w.width):0);break;case"e":p=w.precision?parseFloat(p).toExponential(w.precision):parseFloat(p).toExponential();break;case"f":p=w.precision?parseFloat(p).toFixed(w.precision):parseFloat(p);break;case"g":p=w.precision?String(Number(p.toPrecision(w.precision))):parseFloat(p);break;case"o":p=(parseInt(p,10)>>>0).toString(8);break;case"s":p=String(p),p=w.precision?p.substring(0,w.precision):p;break;case"t":p=String(!!p),p=w.precision?p.substring(0,w.precision):p;break;case"T":p=Object.prototype.toString.call(p).slice(8,-1).toLowerCase(),p=w.precision?p.substring(0,w.precision):p;break;case"u":p=parseInt(p,10)>>>0;break;case"v":p=p.valueOf(),p=w.precision?p.substring(0,w.precision):p;break;case"x":p=(parseInt(p,10)>>>0).toString(16);break;case"X":p=(parseInt(p,10)>>>0).toString(16).toUpperCase();break}e.json.test(w.type)?E+=p:(e.number.test(w.type)&&(!C||w.sign)?(S=C?"+":"-",p=p.toString().replace(e.sign,"")):S="",F=w.pad_char?w.pad_char==="0"?"0":w.pad_char.charAt(1):" ",A=w.width-(S+p).length,g=w.width&&A>0?F.repeat(A):"",E+=w.align?S+p+g:F==="0"?S+g+p:g+S+p)}return E}var s=Object.create(null);function u(i){if(s[i])return s[i];for(var o=i,l,h=[],p=0;o;){if((l=e.text.exec(o))!==null)h.push(l[0]);else if((l=e.modulo.exec(o))!==null)h.push("%");else if((l=e.placeholder.exec(o))!==null){if(l[2]){p|=1;var E=[],d=l[2],f=[];if((f=e.key.exec(d))!==null)for(E.push(f[1]);(d=d.substring(f[0].length))!=="";)if((f=e.key_access.exec(d))!==null)E.push(f[1]);else if((f=e.index_access.exec(d))!==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 p|=2;if(p===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");o=o.substring(l[0].length)}return s[i]=h}typeof Hf<"u"&&(Hf.sprintf=t,Hf.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var zp=De(Es=>{"use strict";var QI=Es&&Es.__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]}),e9=Es&&Es.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),RE=Es&&Es.__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)&&QI(t,e,r);return e9(t,e),t};Object.defineProperty(Es,"__esModule",{value:!0});Es.Address4=void 0;var $E=RE(Mp()),Wi=RE(qp()),PE=Uf(),Lc=Kp(),No=xc(),Gp=class e{constructor(t){this.groups=Wi.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=$E.isCorrect(Wi.BITS),this.isInSubnet=$E.isInSubnet,this.address=t;let r=Wi.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>Wi.BITS)throw new PE.AddressError("Invalid subnet mask.");t=t.replace(Wi.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(Wi.RE_ADDRESS))throw new PE.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 u=r.slice(s,s+2);n.push(parseInt(u,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,No.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r(0,No.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Lc.BigInteger(this.mask()+"0".repeat(Wi.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Lc.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Lc.BigInteger(this.mask()+"1".repeat(Wi.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Lc.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,No.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(Wi.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(Wi.RE_ADDRESS,(0,No.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};Es.Address4=Gp});var Wp=De(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.RE_URL_WITH_PORT=Er.RE_URL=Er.RE_ZONE_STRING=Er.RE_SUBNET_STRING=Er.RE_BAD_ADDRESS=Er.RE_BAD_CHARACTERS=Er.TYPES=Er.SCOPES=Er.GROUPS=Er.BITS=void 0;Er.BITS=128;Er.GROUPS=8;Er.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};Er.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"};Er.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;Er.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;Er.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;Er.RE_ZONE_STRING=/%.*$/;Er.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);Er.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var Yp=De(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});As.simpleGroup=As.spanLeadingZeroes=As.spanAll=As.spanAllZeroes=void 0;var TE=xc();function OE(e){return e.replace(/(0+)/g,'$1')}As.spanAllZeroes=OE;function t9(e,t=0){return e.split("").map((n,s)=>(0,TE.sprintf)('%s',n,s+t,OE(n))).join("")}As.spanAll=t9;function kE(e){return e.replace(/^(0+)/,'$1')}function r9(e){return e.split(":").map(r=>kE(r)).join(":")}As.spanLeadingZeroes=r9;function n9(e,t=0){return e.split(":").map((n,s)=>/group-v4/.test(n)?n:(0,TE.sprintf)('%s',s+t,kE(n)))}As.simpleGroup=n9});var NE=De(Vr=>{"use strict";var i9=Vr&&Vr.__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]}),s9=Vr&&Vr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),u9=Vr&&Vr.__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)&&i9(t,e,r);return s9(t,e),t};Object.defineProperty(Vr,"__esModule",{value:!0});Vr.possibleElisions=Vr.simpleRegularExpression=Vr.ADDRESS_BOUNDARY=Vr.padGroup=Vr.groupPossibilities=void 0;var a9=u9(Wp()),xo=xc();function qf(e){return(0,xo.sprintf)("(%s)",e.join("|"))}Vr.groupPossibilities=qf;function Mf(e){return e.length<4?(0,xo.sprintf)("0{0,%d}%s",4-e.length,e):e}Vr.padGroup=Mf;Vr.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function o9(e){let t=[];e.forEach((n,s)=>{parseInt(n,16)===0&&t.push(s)});let r=t.map(n=>e.map((s,u)=>{if(u===n){let i=u===0||u===a9.GROUPS-1?":":"";return qf([Mf(s),i])}return Mf(s)}).join(":"));return r.push(e.map(Mf).join(":")),qf(r)}Vr.simpleRegularExpression=o9;function c9(e,t,r){let n=t?"":":",s=r?"":":",u=[];!t&&!r&&u.push("::"),t&&r&&u.push(""),(r&&!t||!r&&t)&&u.push(":"),u.push((0,xo.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),u.push((0,xo.sprintf)("(0{1,4}:){1,%d}%s",e-1,s)),u.push((0,xo.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let i=1;i{"use strict";var l9=ws&&ws.__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]}),f9=ws&&ws.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Kf=ws&&ws.__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)&&l9(t,e,r);return f9(t,e),t};Object.defineProperty(ws,"__esModule",{value:!0});ws.Address6=void 0;var xE=Kf(Mp()),Xp=Kf(qp()),Qt=Kf(Wp()),Jp=Kf(Yp()),Oa=zp(),ka=NE(),uu=Uf(),Pn=Kp(),Rn=xc();function Vf(e){if(!e)throw new Error("Assertion failed.")}function h9(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function p9(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function d9(e,t){let r=[],n=[],s;for(s=0;st[1]&&n.push(e[s]);return r.concat(["compact"]).concat(n)}function LE(e){return(0,Rn.sprintf)("%04x",parseInt(e,16))}function UE(e){return e&255}var Zp=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=xE.isInSubnet,this.isCorrect=xE.isCorrect(Qt.BITS),r===void 0?this.groups=Qt.GROUPS:this.groups=r,this.address=t;let n=Qt.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>Qt.BITS)throw new uu.AddressError("Invalid subnet mask.");t=t.replace(Qt.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new uu.AddressError("Invalid subnet mask.");let s=Qt.RE_ZONE_STRING.exec(t);s&&(this.zone=s[0],t=t.replace(Qt.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;s65536)&&(n=null)):n=null,{address:new e(r),port:n}}static fromAddress4(t){let r=new Oa.Address4(t),n=Qt.BITS-(Xp.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 uu.AddressError("Invalid 'ip6.arpa' form.");let s=r.split(".").reverse();for(let u=n;u>0;u--){let i=u*4;s.splice(i,0,":")}return r=s.join(""),new e(r)}microsoftTranscription(){return(0,Rn.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=Qt.BITS-this.subnetMask,n=Math.abs(t-Qt.BITS),s=r-n;return s<0?"0":h9(new Pn.BigInteger("2",10).pow(s).toString(10))}_startAddress(){return new Pn.BigInteger(this.mask()+"0".repeat(Qt.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Pn.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Pn.BigInteger(this.mask()+"1".repeat(Qt.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Pn.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Qt.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(Qt.TYPES))if(this.isInSubnet(new e(t)))return Qt.TYPES[t];return"Global unicast"}getBits(t,r){return new Pn.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,Qt.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,Rn.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 u=s.map(o=>o[1]-o[0]+1);if(s.length>0){let o=u.indexOf(Math.max(...u));r=d9(this.parsedAddress,s[o])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace(Qt.RE_BAD_CHARACTERS,'$1'));let n=t.match(Qt.RE_BAD_ADDRESS);if(n)throw new uu.AddressError((0,Rn.sprintf)("Address failed regex: %s",n.join("")),t.replace(Qt.RE_BAD_ADDRESS,'$1'));let s=[],u=t.split("::");if(u.length===2){let i=u[0].split(":"),o=u[1].split(":");i.length===1&&i[0]===""&&(i=[]),o.length===1&&o[0]===""&&(o=[]);let l=this.groups-(i.length+o.length);if(!l)throw new uu.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,Rn.sprintf)("%x",parseInt(i,16))),s.length!==this.groups)throw new uu.AddressError("Incorrect number of groups found");return s}canonicalForm(){return this.parsedAddress.map(LE).join(":")}decimal(){return this.parsedAddress.map(t=>(0,Rn.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new Pn.BigInteger(this.parsedAddress.map(LE).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return Oa.Address4.fromHex(new Pn.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 Pn.BigInteger("ffff",16)).toString(),n=Oa.Address4.fromHex(this.getBitsBase16(32,64)),s=Oa.Address4.fromHex(this.getBits(96,128).xor(new Pn.BigInteger("ffffffff",16)).toString(16)),u=this.getBits(64,80),i=this.getBitsBase2(64,80),o=u.testBit(15),l=u.testBit(14),h=u.testBit(8),p=u.testBit(9),E=new Pn.BigInteger(i.slice(2,6)+i.slice(8,16),2).toString(10);return{prefix:(0,Rn.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:s.address,flags:i,coneNat:o,microsoft:{reserved:l,universalLocal:p,groupIndividual:h,nonce:E},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=Oa.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,Rn.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(UE)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(UE))}static fromUnsignedByteArray(t){let r=new Pn.BigInteger("256",10),n=new Pn.BigInteger("0",10),s=new Pn.BigInteger("1",10);for(let u=t.length-1;u>=0;u--)n=n.add(s.multiply(new Pn.BigInteger(t[u].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,Rn.sprintf)(":%s",t),(0,Rn.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,Rn.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,Rn.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return Jp.simpleGroup(this.address).join(":");Vf(typeof this.elidedGroups=="number"),Vf(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...Jp.simpleGroup(r)):t.push("");let s=["hover-group"];for(let u=this.elisionBegin;u',s.join(" "))),n.length?t.push(...Jp.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(Vf(this.address4 instanceof Oa.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,ka.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===Qt.GROUPS)r.push((0,ka.possibleElisions)(Qt.GROUPS));else{let s=n.address.split("::");s[0].length&&r.push((0,ka.simpleRegularExpression)(s[0].split(":"))),Vf(typeof n.elidedGroups=="number"),r.push((0,ka.possibleElisions)(n.elidedGroups,s[0].length!==0,s[1].length!==0)),s[1].length&&r.push((0,ka.simpleRegularExpression)(s[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",ka.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",ka.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};ws.Address6=Zp});var HE=De(An=>{"use strict";var g9=An&&An.__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]}),m9=An&&An.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),v9=An&&An.__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)&&g9(t,e,r);return m9(t,e),t};Object.defineProperty(An,"__esModule",{value:!0});An.v6=An.AddressError=An.Address6=An.Address4=void 0;var E9=zp();Object.defineProperty(An,"Address4",{enumerable:!0,get:function(){return E9.Address4}});var A9=jE();Object.defineProperty(An,"Address6",{enumerable:!0,get:function(){return A9.Address6}});var w9=Uf();Object.defineProperty(An,"AddressError",{enumerable:!0,get:function(){return w9.AddressError}});var C9=v9(Yp());An.v6={helpers:C9}});var ZE=De(fd=>{"use strict";fd.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};fd.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 QE=De(hd=>{"use strict";hd.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};hd.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 eA=De(pd=>{"use strict";pd.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};pd.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 tA=De(dd=>{"use strict";dd.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};dd.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 rA=De(gd=>{"use strict";gd.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}`};gd.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 sA=De((iA,md)=>{var nA=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=E,e.encode=p,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,u={name:"v4",size:r,isFormat:d=>t.test(d),encode(d,f,w){w=~~w,f=f||new Uint8Array(w+r);let g=d.length,F=0;for(let A=0;Ad.length>0&&n.test(d),encode(d,f,w){w=~~w;let g=w+s,F=-1,A=0,C=0,S=!0,I=!1;f=f||new Uint8Array(w+s);for(let _=0;_>8),w=97?L-=87:L>=65?L-=55:(L-=48,C=C*10+L),A=(A<<4)+L)}if(S===!1)I===!0?(w>8),w=F+2;_--)f[_]=f[_-2];f[F]=0,f[F+1]=0,F=w}if(F!==w&&F!==-1)for(w>g-2&&(w=g-2);g>F;)f[--g]=wF?f[--w]:0;else for(;w{"use strict";var Ge=hf().Buffer,Eu=ZE(),z9=QE(),W9=eA(),rh=tA(),vd=rA(),La=sA(),Y9=0,uA=32768,Ed=32768,X9=~Ed,aA=32768,J9=~aA,Te=Ke.name={};Te.encode=function(e,t,r,{mail:n=!1}={}){t||(t=Ge.alloc(Te.encodingLength(e))),r||(r=0);let s=r,u=e.replace(/^\.|\.$/gm,"");if(u.length){let i=[];if(n){let o="";u.split(".").forEach(l=>{l.endsWith("\\")?o+=(o.length?".":"")+l.slice(0,-1):i.length===0&&o.length?i.push(o+"."+l):i.push(l)})}else i=u.split(".");for(let o=0;o=e.length)throw new Error("Cannot decode name (buffer overflow)");let l=e[t++];if(i+=o?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+=o?0:1,o=!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(u+=l+1,u>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+=o?0:l}}return Te.decode.bytes=i,n.length===0?".":n.join(".")};Te.decode.bytes=0;Te.encodingLength=function(e){return e==="."||e===".."?1:Ge.byteLength(e.replace(/^\.|\.$/gm,""))+2};var Et={};Et.encode=function(e,t,r){t||(t=Ge.alloc(Et.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,Et.encode.bytes=n+1,t};Et.encode.bytes=0;Et.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return Et.decode.bytes=r+1,n};Et.decode.bytes=0;Et.encodingLength=function(e){return Ge.byteLength(e)+1};var Ji={};Ji.encode=function(e,t,r){t||(t=Ji.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,s=e.type==="response"?uA:Y9;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};Ji.encode.bytes=12;Ji.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&uA?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:W9.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:z9.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))}};Ji.decode.bytes=12;Ji.encodingLength=function(){return 12};var cu=Ke.unknown={};cu.encode=function(e,t,r){return t||(t=Ge.alloc(cu.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),cu.encode.bytes=e.length+2,t};cu.encode.bytes=0;cu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return cu.decode.bytes=r+2,n};cu.decode.bytes=0;cu.encodingLength=function(e){return e.length+2};var lu=Ke.ns={};lu.encode=function(e,t,r){return t||(t=Ge.alloc(lu.encodingLength(e))),r||(r=0),Te.encode(e,t,r+2),t.writeUInt16BE(Te.encode.bytes,r),lu.encode.bytes=Te.encode.bytes+2,t};lu.encode.bytes=0;lu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=Te.decode(e,t+2);return lu.decode.bytes=r+2,n};lu.decode.bytes=0;lu.encodingLength=function(e){return Te.encodingLength(e)+2};var fu=Ke.soa={};fu.encode=function(e,t,r){t||(t=Ge.alloc(fu.encodingLength(e))),r||(r=0);let n=r;return r+=2,Te.encode(e.mname,t,r),r+=Te.encode.bytes,Te.encode(e.rname,t,r,{mail:!0}),r+=Te.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),fu.encode.bytes=r-n,t};fu.encode.bytes=0;fu.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mname=Te.decode(e,t),t+=Te.decode.bytes,n.rname=Te.decode(e,t,{mail:!0}),t+=Te.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,fu.decode.bytes=t-r,n};fu.decode.bytes=0;fu.encodingLength=function(e){return 22+Te.encodingLength(e.mname)+Te.encodingLength(e.rname)};var hu=Ke.txt={};hu.encode=function(e,t,r){Array.isArray(e)||(e=[e]);for(let s=0;s0;){let u=e[t++];if(--n,n0&&(r.timeout=e.readUInt16BE(t),t+=2);break;case 14:r.tags=[];for(let u=0;u0;)n[u++]=ti.decode(e,t),t+=ti.decode.bytes,s-=ti.decode.bytes;return Ai.decode.bytes=t-r,n};Ai.decode.bytes=0;Ai.encodingLength=function(e){return 2+Mo(e||[],ti)};var Tn=Ke.dnskey={};Tn.PROTOCOL_DNSSEC=3;Tn.ZONE_KEY=128;Tn.SECURE_ENTRYPOINT=32768;Tn.encode=function(e,t,r){t||(t=Ge.alloc(Tn.encodingLength(e))),r||(r=0);let n=r,s=e.key;if(!Ge.isBuffer(s))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(Tn.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,s.copy(t,r,0,s.length),r+=s.length,Tn.encode.bytes=r-n,t.writeUInt16BE(Tn.encode.bytes-2,n),t};Tn.encode.bytes=0;Tn.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)!==Tn.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,Tn.decode.bytes=t-r,n};Tn.decode.bytes=0;Tn.encodingLength=function(e){return 6+Ge.byteLength(e.key)};var ys=Ke.rrsig={};ys.encode=function(e,t,r){t||(t=Ge.alloc(ys.encodingLength(e))),r||(r=0);let n=r,s=e.signature;if(!Ge.isBuffer(s))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(Eu.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,Te.encode(e.signersName,t,r),r+=Te.encode.bytes,s.copy(t,r,0,s.length),r+=s.length,ys.encode.bytes=r-n,t.writeUInt16BE(ys.encode.bytes-2,n),t};ys.encode.bytes=0;ys.decode=function(e,t){t||(t=0);let r=t;var n={},s=e.readUInt16BE(t);return t+=2,n.typeCovered=Eu.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=Te.decode(e,t),t+=Te.decode.bytes,n.signature=e.slice(t,r+s+2),t+=n.signature.length,ys.decode.bytes=t-r,n};ys.decode.bytes=0;ys.encodingLength=function(e){return 20+Te.encodingLength(e.signersName)+Ge.byteLength(e.signature)};var Ss=Ke.rp={};Ss.encode=function(e,t,r){t||(t=Ge.alloc(Ss.encodingLength(e))),r||(r=0);let n=r;return r+=2,Te.encode(e.mbox||".",t,r,{mail:!0}),r+=Te.encode.bytes,Te.encode(e.txt||".",t,r),r+=Te.encode.bytes,Ss.encode.bytes=r-n,t.writeUInt16BE(Ss.encode.bytes-2,n),t};Ss.encode.bytes=0;Ss.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mbox=Te.decode(e,t,{mail:!0})||".",t+=Te.decode.bytes,n.txt=Te.decode(e,t)||".",t+=Te.decode.bytes,Ss.decode.bytes=t-r,n};Ss.decode.bytes=0;Ss.encodingLength=function(e){return 2+Te.encodingLength(e.mbox||".")+Te.encodingLength(e.txt||".")};var Gr={};Gr.encode=function(e,t,r){t||(t=Ge.alloc(Gr.encodingLength(e))),r||(r=0);let n=r;for(var s=[],u=0;u>8]===void 0&&(s[i>>8]=[]),s[i>>8][i>>3&31]|=1<<7-(i&7)}for(u=0;u>8]=Math.max(t[n>>8]||0,n&255)}var s=0;for(r=0;r>15&1)===1,r.options=Ai.decode(e,t+8),t+=8+Ai.decode.bytes;else{let s=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=rh.toString(s&X9),r.flush=!!(s&Ed);let u=Ad(r.type);r.data=u.decode(e,t+8),t+=8+u.decode.bytes}return on.decode.bytes=t-n,r};on.decode.bytes=0;on.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return Te.encodingLength(e.name)+8+Ad(e.type).encodingLength(t)};var Xi=Ke.question={};Xi.encode=function(e,t,r){t||(t=Ge.alloc(Xi.encodingLength(e))),r||(r=0);let n=r;return Te.encode(e.name,t,r),r+=Te.encode.bytes,t.writeUInt16BE(Eu.toType(e.type),r),r+=2,t.writeUInt16BE(rh.toClass(e.class===void 0?"IN":e.class),r),r+=2,Xi.encode.bytes=r-n,e};Xi.encode.bytes=0;Xi.decode=function(e,t){t||(t=0);let r=t,n={};return n.name=Te.decode(e,t),t+=Te.decode.bytes,n.type=Eu.toString(e.readUInt16BE(t)),t+=2,n.class=rh.toString(e.readUInt16BE(t)),t+=2,!!(n.class&aA)&&(n.class&=J9),Xi.decode.bytes=t-r,n};Xi.decode.bytes=0;Xi.encodingLength=function(e){return Te.encodingLength(e.name)+4};Ke.AUTHORITATIVE_ANSWER=1024;Ke.TRUNCATED_RESPONSE=512;Ke.RECURSION_DESIRED=256;Ke.RECURSION_AVAILABLE=128;Ke.AUTHENTIC_DATA=32;Ke.CHECKING_DISABLED=16;Ke.DNSSEC_OK=32768;Ke.encode=function(e,t,r){let n=!t;n&&(t=Ge.alloc(Ke.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=[]),Ji.encode(e,t,r),r+=Ji.encode.bytes,r=Vc(e.questions,Xi,t,r),r=Vc(e.answers,on,t,r),r=Vc(e.authorities,on,t,r),r=Vc(e.additionals,on,t,r),Ke.encode.bytes=r-s,n&&Ke.encode.bytes!==t.length?t.slice(0,Ke.encode.bytes):t};Ke.encode.bytes=0;Ke.decode=function(e,t){t||(t=0);let r=t,n=Ji.decode(e,t);return t+=Ji.decode.bytes,t=th(n.questions,Xi,e,t),t=th(n.answers,on,e,t),t=th(n.authorities,on,e,t),t=th(n.additionals,on,e,t),Ke.decode.bytes=t-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(e){return Ji.encodingLength(e)+Mo(e.questions||[],Xi)+Mo(e.answers||[],on)+Mo(e.authorities||[],on)+Mo(e.additionals||[],on)};Ke.streamEncode=function(e){let t=Ke.encode(e),r=Ge.alloc(2);r.writeUInt16BE(t.byteLength);let n=Ge.concat([r,t]);return Ke.streamEncode.bytes=n.byteLength,n};Ke.streamEncode.bytes=0;Ke.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",u="Invalid `variable` option passed into `_.template`",i="__lodash_hash_undefined__",o=500,l="__lodash_placeholder__",h=1,p=2,E=4,d=1,f=2,w=1,g=2,F=4,A=8,C=16,S=32,I=64,_=128,L=256,M=512,b=30,B="...",k=800,U=16,q=1,W=2,K=3,z=1/0,X=9007199254740991,se=17976931348623157e292,Ie=NaN,be=4294967295,Re=be-1,Je=be>>>1,ae=[["ary",_],["bind",w],["bindKey",g],["curry",A],["curryRight",C],["flip",M],["partial",S],["partialRight",I],["rearg",L]],ye="[object Arguments]",He="[object Array]",Zt="[object AsyncFunction]",It="[object Boolean]",Ct="[object Date]",lr="[object DOMException]",er="[object Error]",pt="[object Function]",Mt="[object GeneratorFunction]",st="[object Map]",We="[object Number]",tr="[object Null]",Ve="[object Object]",Rt="[object Promise]",zr="[object Proxy]",Yt="[object RegExp]",qt="[object Set]",mt="[object String]",yr="[object Symbol]",ii="[object Undefined]",Wr="[object WeakMap]",yt="[object WeakSet]",Me="[object ArrayBuffer]",_e="[object DataView]",fr="[object Float32Array]",Yr="[object Float64Array]",ut="[object Int8Array]",Os="[object Int16Array]",Xr="[object Int32Array]",ge="[object Uint8Array]",Qi="[object Uint8ClampedArray]",Bt="[object Uint16Array]",Nr="[object Uint32Array]",Li=/\b__p \+= '';/g,Du=/\b(__p \+=) '' \+/g,es=/(__e\(.*?\)|\b__t\)) \+\n'';/g,yu=/&(?:amp|lt|gt|quot|#39);/g,ts=/[&<>"']/g,Ui=RegExp(yu.source),Tt=RegExp(ts.source),xn=/<%-([\s\S]+?)%>/g,Su=/<%([\s\S]+?)%>/g,bu=/<%=([\s\S]+?)%>/g,_u=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,rs=/^\w*$/,Zu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ns=/[\\^$.*+?()[\]{}|]/g,Qu=RegExp(ns.source),ks=/^\s+/,re=/\s/,fe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,je=/\{\n\/\* \[wrapped with (.+)\] \*/,Ne=/,? & /,ze=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,at=/[()=,{}\[\]\/\s]/,ht=/\\(\\)?/g,Ar=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Lt=/\w*$/,Ln=/^[-+]0x[0-9a-f]+$/i,Di=/^0b[01]+$/i,Jr=/^\[object .+?Constructor\]$/,cn=/^0o[0-7]+$/i,hr=/^(?:0|[1-9]\d*)$/,Zr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Pr=/($^)/,ea=/['\n\r\u2028\u2029\\]/g,is="\\ud800-\\udfff",wn="\\u0300-\\u036f",Pt="\\ufe20-\\ufe2f",pr="\\u20d0-\\u20ff",rt=wn+Pt+pr,rr="\\u2700-\\u27bf",xr="a-z\\xdf-\\xf6\\xf8-\\xff",nr="\\xac\\xb1\\xd7\\xf7",Ut="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Cn="\\u2000-\\u206f",Un=" \\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",jn="A-Z\\xc0-\\xd6\\xd8-\\xde",Fn="\\ufe0e\\ufe0f",Sr=nr+Ut+Cn+Un,sr="['\u2019]",Zo="["+is+"]",ta="["+Sr+"]",Lr="["+rt+"]",ra="\\d+",qa="["+rr+"]",Va="["+xr+"]",na="[^"+is+Sr+ra+rr+xr+jn+"]",ss="\\ud83c[\\udffb-\\udfff]",ia="(?:"+Lr+"|"+ss+")",Ka="[^"+is+"]",sa="(?:\\ud83c[\\udde6-\\uddff]){2}",aa="[\\ud800-\\udbff][\\udc00-\\udfff]",Dn="["+jn+"]",R="\\u200d",O="(?:"+Va+"|"+na+")",H="(?:"+Dn+"|"+na+")",Q="(?:"+sr+"(?:d|ll|m|re|s|t|ve))?",ve="(?:"+sr+"(?:D|LL|M|RE|S|T|VE))?",we=ia+"?",$e="["+Fn+"]?",ke="(?:"+R+"(?:"+[Ka,sa,aa].join("|")+")"+$e+we+")*",Vt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",dr="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Qr=$e+we+ke,en="(?:"+[qa,sa,aa].join("|")+")"+Qr,si="(?:"+[Ka+Lr+"?",Lr,sa,aa,Zo].join("|")+")",Iu=RegExp(sr,"g"),yn=RegExp(Lr,"g"),tn=RegExp(ss+"(?="+ss+")|"+si+Qr,"g"),Bu=RegExp([Dn+"?"+Va+"+"+Q+"(?="+[ta,Dn,"$"].join("|")+")",H+"+"+ve+"(?="+[ta,Dn+O,"$"].join("|")+")",Dn+"?"+O+"+"+Q,Dn+"+"+ve,dr,Vt,ra,en].join("|"),"g"),yi=RegExp("["+R+is+rt+Fn+"]"),oa=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Fh=["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"],Dh=-1,Xt={};Xt[fr]=Xt[Yr]=Xt[ut]=Xt[Os]=Xt[Xr]=Xt[ge]=Xt[Qi]=Xt[Bt]=Xt[Nr]=!0,Xt[ye]=Xt[He]=Xt[Me]=Xt[It]=Xt[_e]=Xt[Ct]=Xt[er]=Xt[pt]=Xt[st]=Xt[We]=Xt[Ve]=Xt[Yt]=Xt[qt]=Xt[mt]=Xt[Wr]=!1;var zt={};zt[ye]=zt[He]=zt[Me]=zt[_e]=zt[It]=zt[Ct]=zt[fr]=zt[Yr]=zt[ut]=zt[Os]=zt[Xr]=zt[st]=zt[We]=zt[Ve]=zt[Yt]=zt[qt]=zt[mt]=zt[yr]=zt[ge]=zt[Qi]=zt[Bt]=zt[Nr]=!0,zt[er]=zt[pt]=zt[Wr]=!1;var yh={\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"},Sh={"&":"&","<":"<",">":">",'"':""","'":"'"},bh={"&":"&","<":"<",">":">",""":'"',"'":"'"},_h={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ih=parseFloat,Bh=parseInt,il=typeof global=="object"&&global&&global.Object===Object&&global,$h=typeof self=="object"&&self&&self.Object===Object&&self,br=il||$h||Function("return this")(),Qo=typeof Vo=="object"&&Vo&&!Vo.nodeType&&Vo,Ns=Qo&&typeof Kc=="object"&&Kc&&!Kc.nodeType&&Kc,sl=Ns&&Ns.exports===Qo,ec=sl&&il.process,Hn=function(){try{var ne=Ns&&Ns.require&&Ns.require("util").types;return ne||ec&&ec.binding&&ec.binding("util")}catch{}}(),ul=Hn&&Hn.isArrayBuffer,al=Hn&&Hn.isDate,ol=Hn&&Hn.isMap,cl=Hn&&Hn.isRegExp,ll=Hn&&Hn.isSet,fl=Hn&&Hn.isTypedArray;function Sn(ne,he,ce){switch(ce.length){case 0:return ne.call(he);case 1:return ne.call(he,ce[0]);case 2:return ne.call(he,ce[0],ce[1]);case 3:return ne.call(he,ce[0],ce[1],ce[2])}return ne.apply(he,ce)}function Ph(ne,he,ce,xe){for(var nt=-1,St=ne==null?0:ne.length;++nt-1}function ca(ne,he,ce){for(var xe=-1,nt=ne==null?0:ne.length;++xe-1;);return ce}function gl(ne,he){for(var ce=ne.length;ce--&&$u(he,ne[ce],0)>-1;);return ce}function ml(ne,he){for(var ce=ne.length,xe=0;ce--;)ne[ce]===he&&++xe;return xe}var uc=me(yh),Oh=me(Sh);function vl(ne){return"\\"+_h[ne]}function kh(ne,he){return ne==null?e:ne[he]}function Ls(ne){return yi.test(ne)}function Nh(ne){return oa.test(ne)}function xh(ne){for(var he,ce=[];!(he=ne.next()).done;)ce.push(he.value);return ce}function ac(ne){var he=-1,ce=Array(ne.size);return ne.forEach(function(xe,nt){ce[++he]=[nt,xe]}),ce}function rn(ne,he){return function(ce){return ne(he(ce))}}function oi(ne,he){for(var ce=-1,xe=ne.length,nt=0,St=[];++ce-1}function dC(a,c){var v=this.__data__,y=Bl(v,a);return y<0?(++this.size,v.push([a,c])):v[y][1]=c,this}qs.prototype.clear=lC,qs.prototype.delete=fC,qs.prototype.get=hC,qs.prototype.has=pC,qs.prototype.set=dC;function Vs(a){var c=-1,v=a==null?0:a.length;for(this.clear();++c=c?a:c)),a}function Ii(a,c,v,y,T,j){var Y,Z=c&h,ie=c&p,Ee=c&E;if(v&&(Y=T?v(a,y,T,j):v(a)),Y!==e)return Y;if(!or(a))return a;var Ae=lt(a);if(Ae){if(Y=EF(a),!Z)return Kn(a,Y)}else{var Ce=hn(a),Pe=Ce==pt||Ce==Mt;if(ku(a))return L1(a,Z);if(Ce==Ve||Ce==ye||Pe&&!T){if(Y=ie||Pe?{}:ng(a),!Z)return ie?aF(a,$C(Y,a)):uF(a,d1(Y,a))}else{if(!zt[Ce])return T?a:{};Y=AF(a,Ce,Z)}}j||(j=new Hi);var qe=j.get(a);if(qe)return qe;j.set(a,Y),Rg(a)?a.forEach(function(tt){Y.add(Ii(tt,c,v,tt,a,j))}):$g(a)&&a.forEach(function(tt,wt){Y.set(wt,Ii(tt,c,v,wt,a,j))});var et=Ee?ie?m0:g0:ie?zn:Ur,gt=Ae?e:et(a);return Mn(gt||a,function(tt,wt){gt&&(wt=tt,tt=a[wt]),hc(Y,wt,Ii(tt,c,v,wt,a,j))}),Y}function PC(a){var c=Ur(a);return function(v){return g1(v,a,c)}}function g1(a,c,v){var y=v.length;if(a==null)return!y;for(a=Kt(a);y--;){var T=v[y],j=c[T],Y=a[T];if(Y===e&&!(T in a)||!j(Y))return!1}return!0}function m1(a,c,v){if(typeof a!="function")throw new Vn(s);return Ac(function(){a.apply(e,v)},c)}function pc(a,c,v,y){var T=-1,j=bn,Y=!0,Z=a.length,ie=[],Ee=c.length;if(!Z)return ie;v&&(c=te(c,ln(v))),y?(j=ca,Y=!1):c.length>=r&&(j=fa,Y=!1,c=new pa(c));e:for(;++TT?0:T+v),y=y===e||y>T?T:dt(y),y<0&&(y+=T),y=v>y?0:Og(y);v0&&v(Z)?c>1?nn(Z,c-1,v,y,T):ai(T,Z):y||(T[T.length]=Z)}return T}var Jh=V1(),A1=V1(!0);function as(a,c){return a&&Jh(a,c,Ur)}function Zh(a,c){return a&&A1(a,c,Ur)}function Pl(a,c){return ui(c,function(v){return Ys(a[v])})}function ga(a,c){c=Tu(c,a);for(var v=0,y=c.length;a!=null&&vc}function OC(a,c){return a!=null&&$t.call(a,c)}function kC(a,c){return a!=null&&c in Kt(a)}function NC(a,c,v){return a>=fn(c,v)&&a=120&&Ae.length>=120)?new pa(Y&&Ae):e}Ae=a[0];var Ce=-1,Pe=Z[0];e:for(;++Ce-1;)Z!==a&&Nt.call(Z,ie,1),Nt.call(a,ie,1);return a}function $1(a,c){for(var v=a?c.length:0,y=v-1;v--;){var T=c[v];if(v==y||T!==j){var j=T;Ws(T)?Nt.call(a,T,1):o0(a,T)}}return a}function s0(a,c){return a+ue(l1()*(c-a+1))}function YC(a,c,v,y){for(var T=-1,j=Rr(V((c-a)/(v||1)),0),Y=ce(j);j--;)Y[y?j:++T]=a,a+=v;return Y}function u0(a,c){var v="";if(!a||c<1||c>X)return v;do c%2&&(v+=a),c=ue(c/2),c&&(a+=a);while(c);return v}function vt(a,c){return D0(ug(a,c,Wn),a+"")}function XC(a){return p1(ho(a))}function JC(a,c){var v=ho(a);return Ml(v,da(c,0,v.length))}function mc(a,c,v,y){if(!or(a))return a;c=Tu(c,a);for(var T=-1,j=c.length,Y=j-1,Z=a;Z!=null&&++TT?0:T+c),v=v>T?T:v,v<0&&(v+=T),T=c>v?0:v-c>>>0,c>>>=0;for(var j=ce(T);++y>>1,Y=a[j];Y!==null&&!fi(Y)&&(v?Y<=c:Y=r){var Ee=c?null:fF(a);if(Ee)return ci(Ee);Y=!1,T=fa,ie=new pa}else ie=c?[]:Z;e:for(;++y=y?a:Bi(a,c,v)}var x1=D||function(a){return br.clearTimeout(a)};function L1(a,c){if(c)return a.slice();var v=a.length,y=Fl?Fl(v):new a.constructor(v);return a.copy(y),y}function h0(a){var c=new a.constructor(a.byteLength);return new ro(c).set(new ro(a)),c}function rF(a,c){var v=c?h0(a.buffer):a.buffer;return new a.constructor(v,a.byteOffset,a.byteLength)}function nF(a){var c=new a.constructor(a.source,Lt.exec(a));return c.lastIndex=a.lastIndex,c}function iF(a){return fc?Kt(fc.call(a)):{}}function U1(a,c){var v=c?h0(a.buffer):a.buffer;return new a.constructor(v,a.byteOffset,a.length)}function j1(a,c){if(a!==c){var v=a!==e,y=a===null,T=a===a,j=fi(a),Y=c!==e,Z=c===null,ie=c===c,Ee=fi(c);if(!Z&&!Ee&&!j&&a>c||j&&Y&&ie&&!Z&&!Ee||y&&Y&&ie||!v&&ie||!T)return 1;if(!y&&!j&&!Ee&&a=Z)return ie;var Ee=v[y];return ie*(Ee=="desc"?-1:1)}}return a.index-c.index}function H1(a,c,v,y){for(var T=-1,j=a.length,Y=v.length,Z=-1,ie=c.length,Ee=Rr(j-Y,0),Ae=ce(ie+Ee),Ce=!y;++Z1?v[T-1]:e,Y=T>2?v[2]:e;for(j=a.length>3&&typeof j=="function"?(T--,j):e,Y&&In(v[0],v[1],Y)&&(j=T<3?e:j,T=1),c=Kt(c);++y-1?T[j?c[Y]:Y]:e}}function z1(a){return zs(function(c){var v=c.length,y=v,T=_i.prototype.thru;for(a&&c.reverse();y--;){var j=c[y];if(typeof j!="function")throw new Vn(s);if(T&&!Y&&jl(j)=="wrapper")var Y=new _i([],!0)}for(y=Y?y:v;++y1&&bt.reverse(),Ae&&ieZ))return!1;var Ee=j.get(a),Ae=j.get(c);if(Ee&&Ae)return Ee==c&&Ae==a;var Ce=-1,Pe=!0,qe=v&f?new pa:e;for(j.set(a,c),j.set(c,a);++Ce1?"& ":"")+c[y],c=c.join(v>2?", ":" "),a.replace(fe,`{ /* [wrapped with `+c+`] */ `)}function CF(a){return lt(a)||Ea(a)||!!(Sl&&a&&a[Sl])}function Ws(a,c){var v=typeof a;return c=c??X,!!c&&(v=="number"||v!="symbol"&&hr.test(a))&&a>-1&&a%1==0&&a0){if(++c>=k)return arguments[0]}else c=0;return a.apply(e,arguments)}}function Ml(a,c){var v=-1,y=a.length,T=y-1;for(c=c===e?y:c;++v1?a[c-1]:e;return v=typeof v=="function"?(a.pop(),v):e,Eg(a,v)});function Ag(a){var c=x(a);return c.__chain__=!0,c}function R4(a,c){return c(a),a}function ql(a,c){return c(a)}var T4=zs(function(a){var c=a.length,v=c?a[0]:0,y=this.__wrapped__,T=function(j){return Xh(j,a)};return c>1||this.__actions__.length||!(y instanceof Ft)||!Ws(v)?this.thru(T):(y=y.slice(v,+v+(c?1:0)),y.__actions__.push({func:ql,args:[T],thisArg:e}),new _i(y,this.__chain__).thru(function(j){return c&&!j.length&&j.push(e),j}))});function O4(){return Ag(this)}function k4(){return new _i(this.value(),this.__chain__)}function N4(){this.__values__===e&&(this.__values__=Tg(this.value()));var a=this.__index__>=this.__values__.length,c=a?e:this.__values__[this.__index__++];return{done:a,value:c}}function x4(){return this}function L4(a){for(var c,v=this;v instanceof Il;){var y=hg(v);y.__index__=0,y.__values__=e,c?T.__wrapped__=y:c=y;var T=y;v=v.__wrapped__}return T.__wrapped__=a,c}function U4(){var a=this.__wrapped__;if(a instanceof Ft){var c=a;return this.__actions__.length&&(c=new Ft(this)),c=c.reverse(),c.__actions__.push({func:ql,args:[y0],thisArg:e}),new _i(c,this.__chain__)}return this.thru(y0)}function j4(){return k1(this.__wrapped__,this.__actions__)}var H4=kl(function(a,c,v){$t.call(a,v)?++a[v]:Ks(a,v,1)});function M4(a,c,v){var y=lt(a)?ot:RC;return v&&In(a,c,v)&&(c=e),y(a,Ze(c,3))}function q4(a,c){var v=lt(a)?ui:E1;return v(a,Ze(c,3))}var V4=G1(pg),K4=G1(dg);function G4(a,c){return nn(Vl(a,c),1)}function z4(a,c){return nn(Vl(a,c),z)}function W4(a,c,v){return v=v===e?1:dt(v),nn(Vl(a,c),v)}function wg(a,c){var v=lt(a)?Mn:Pu;return v(a,Ze(c,3))}function Cg(a,c){var v=lt(a)?P:v1;return v(a,Ze(c,3))}var Y4=kl(function(a,c,v){$t.call(a,v)?a[v].push(c):Ks(a,v,[c])});function X4(a,c,v,y){a=Gn(a)?a:ho(a),v=v&&!y?dt(v):0;var T=a.length;return v<0&&(v=Rr(T+v,0)),Yl(a)?v<=T&&a.indexOf(c,v)>-1:!!T&&$u(a,c,v)>-1}var J4=vt(function(a,c,v){var y=-1,T=typeof c=="function",j=Gn(a)?ce(a.length):[];return Pu(a,function(Y){j[++y]=T?Sn(c,Y,v):dc(Y,c,v)}),j}),Z4=kl(function(a,c,v){Ks(a,v,c)});function Vl(a,c){var v=lt(a)?te:y1;return v(a,Ze(c,3))}function Q4(a,c,v,y){return a==null?[]:(lt(c)||(c=c==null?[]:[c]),v=y?e:v,lt(v)||(v=v==null?[]:[v]),I1(a,c,v))}var eD=kl(function(a,c,v){a[v?0:1].push(c)},function(){return[[],[]]});function tD(a,c,v){var y=lt(a)?tc:pl,T=arguments.length<3;return y(a,Ze(c,4),v,T,Pu)}function rD(a,c,v){var y=lt(a)?o1:pl,T=arguments.length<3;return y(a,Ze(c,4),v,T,v1)}function nD(a,c){var v=lt(a)?ui:E1;return v(a,zl(Ze(c,3)))}function iD(a){var c=lt(a)?p1:XC;return c(a)}function sD(a,c,v){(v?In(a,c,v):c===e)?c=1:c=dt(c);var y=lt(a)?_C:JC;return y(a,c)}function uD(a){var c=lt(a)?IC:QC;return c(a)}function aD(a){if(a==null)return 0;if(Gn(a))return Yl(a)?Us(a):a.length;var c=hn(a);return c==st||c==qt?a.size:r0(a).length}function oD(a,c,v){var y=lt(a)?hl:eF;return v&&In(a,c,v)&&(c=e),y(a,Ze(c,3))}var cD=vt(function(a,c){if(a==null)return[];var v=c.length;return v>1&&In(a,c[0],c[1])?c=[]:v>2&&In(c[0],c[1],c[2])&&(c=[c[0]]),I1(a,nn(c,1),[])}),Kl=N||function(){return br.Date.now()};function lD(a,c){if(typeof c!="function")throw new Vn(s);return a=dt(a),function(){if(--a<1)return c.apply(this,arguments)}}function Fg(a,c,v){return c=v?e:c,c=a&&c==null?a.length:c,Gs(a,_,e,e,e,e,c)}function Dg(a,c){var v;if(typeof c!="function")throw new Vn(s);return a=dt(a),function(){return--a>0&&(v=c.apply(this,arguments)),a<=1&&(c=e),v}}var b0=vt(function(a,c,v){var y=w;if(v.length){var T=oi(v,lo(b0));y|=S}return Gs(a,y,c,v,T)}),yg=vt(function(a,c,v){var y=w|g;if(v.length){var T=oi(v,lo(yg));y|=S}return Gs(c,y,a,v,T)});function Sg(a,c,v){c=v?e:c;var y=Gs(a,A,e,e,e,e,e,c);return y.placeholder=Sg.placeholder,y}function bg(a,c,v){c=v?e:c;var y=Gs(a,C,e,e,e,e,e,c);return y.placeholder=bg.placeholder,y}function _g(a,c,v){var y,T,j,Y,Z,ie,Ee=0,Ae=!1,Ce=!1,Pe=!0;if(typeof a!="function")throw new Vn(s);c=Pi(c)||0,or(v)&&(Ae=!!v.leading,Ce="maxWait"in v,j=Ce?Rr(Pi(v.maxWait)||0,c):j,Pe="trailing"in v?!!v.trailing:Pe);function qe(Cr){var qi=y,Js=T;return y=T=e,Ee=Cr,Y=a.apply(Js,qi),Y}function et(Cr){return Ee=Cr,Z=Ac(wt,c),Ae?qe(Cr):Y}function gt(Cr){var qi=Cr-ie,Js=Cr-Ee,Gg=c-qi;return Ce?fn(Gg,j-Js):Gg}function tt(Cr){var qi=Cr-ie,Js=Cr-Ee;return ie===e||qi>=c||qi<0||Ce&&Js>=j}function wt(){var Cr=Kl();if(tt(Cr))return bt(Cr);Z=Ac(wt,gt(Cr))}function bt(Cr){return Z=e,Pe&&y?qe(Cr):(y=T=e,Y)}function hi(){Z!==e&&x1(Z),Ee=0,y=ie=T=Z=e}function Bn(){return Z===e?Y:bt(Kl())}function pi(){var Cr=Kl(),qi=tt(Cr);if(y=arguments,T=this,ie=Cr,qi){if(Z===e)return et(ie);if(Ce)return x1(Z),Z=Ac(wt,c),qe(ie)}return Z===e&&(Z=Ac(wt,c)),Y}return pi.cancel=hi,pi.flush=Bn,pi}var fD=vt(function(a,c){return m1(a,1,c)}),hD=vt(function(a,c,v){return m1(a,Pi(c)||0,v)});function pD(a){return Gs(a,M)}function Gl(a,c){if(typeof a!="function"||c!=null&&typeof c!="function")throw new Vn(s);var v=function(){var y=arguments,T=c?c.apply(this,y):y[0],j=v.cache;if(j.has(T))return j.get(T);var Y=a.apply(this,y);return v.cache=j.set(T,Y)||j,Y};return v.cache=new(Gl.Cache||Vs),v}Gl.Cache=Vs;function zl(a){if(typeof a!="function")throw new Vn(s);return function(){var c=arguments;switch(c.length){case 0:return!a.call(this);case 1:return!a.call(this,c[0]);case 2:return!a.call(this,c[0],c[1]);case 3:return!a.call(this,c[0],c[1],c[2])}return!a.apply(this,c)}}function dD(a){return Dg(2,a)}var gD=tF(function(a,c){c=c.length==1&<(c[0])?te(c[0],ln(Ze())):te(nn(c,1),ln(Ze()));var v=c.length;return vt(function(y){for(var T=-1,j=fn(y.length,v);++T=c}),Ea=C1(function(){return arguments}())?C1:function(a){return mr(a)&&$t.call(a,"callee")&&!yl.call(a,"callee")},lt=ce.isArray,$D=ul?ln(ul):LC;function Gn(a){return a!=null&&Wl(a.length)&&!Ys(a)}function wr(a){return mr(a)&&Gn(a)}function PD(a){return a===!0||a===!1||mr(a)&&_n(a)==It}var ku=Gt||L0,RD=al?ln(al):UC;function TD(a){return mr(a)&&a.nodeType===1&&!wc(a)}function OD(a){if(a==null)return!0;if(Gn(a)&&(lt(a)||typeof a=="string"||typeof a.splice=="function"||ku(a)||fo(a)||Ea(a)))return!a.length;var c=hn(a);if(c==st||c==qt)return!a.size;if(Ec(a))return!r0(a).length;for(var v in a)if($t.call(a,v))return!1;return!0}function kD(a,c){return gc(a,c)}function ND(a,c,v){v=typeof v=="function"?v:e;var y=v?v(a,c):e;return y===e?gc(a,c,e,v):!!y}function I0(a){if(!mr(a))return!1;var c=_n(a);return c==er||c==lr||typeof a.message=="string"&&typeof a.name=="string"&&!wc(a)}function xD(a){return typeof a=="number"&&gr(a)}function Ys(a){if(!or(a))return!1;var c=_n(a);return c==pt||c==Mt||c==Zt||c==zr}function Bg(a){return typeof a=="number"&&a==dt(a)}function Wl(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=X}function or(a){var c=typeof a;return a!=null&&(c=="object"||c=="function")}function mr(a){return a!=null&&typeof a=="object"}var $g=ol?ln(ol):HC;function LD(a,c){return a===c||t0(a,c,E0(c))}function UD(a,c,v){return v=typeof v=="function"?v:e,t0(a,c,E0(c),v)}function jD(a){return Pg(a)&&a!=+a}function HD(a){if(yF(a))throw new nt(n);return F1(a)}function MD(a){return a===null}function qD(a){return a==null}function Pg(a){return typeof a=="number"||mr(a)&&_n(a)==We}function wc(a){if(!mr(a)||_n(a)!=Ve)return!1;var c=no(a);if(c===null)return!0;var v=$t.call(c,"constructor")&&c.constructor;return typeof v=="function"&&v instanceof v&&Za.call(v)==Vh}var B0=cl?ln(cl):MC;function VD(a){return Bg(a)&&a>=-X&&a<=X}var Rg=ll?ln(ll):qC;function Yl(a){return typeof a=="string"||!lt(a)&&mr(a)&&_n(a)==mt}function fi(a){return typeof a=="symbol"||mr(a)&&_n(a)==yr}var fo=fl?ln(fl):VC;function KD(a){return a===e}function GD(a){return mr(a)&&hn(a)==Wr}function zD(a){return mr(a)&&_n(a)==yt}var WD=Ul(n0),YD=Ul(function(a,c){return a<=c});function Tg(a){if(!a)return[];if(Gn(a))return Yl(a)?qn(a):Kn(a);if(Hs&&a[Hs])return xh(a[Hs]());var c=hn(a),v=c==st?ac:c==qt?ci:ho;return v(a)}function Xs(a){if(!a)return a===0?a:0;if(a=Pi(a),a===z||a===-z){var c=a<0?-1:1;return c*se}return a===a?a:0}function dt(a){var c=Xs(a),v=c%1;return c===c?v?c-v:c:0}function Og(a){return a?da(dt(a),0,be):0}function Pi(a){if(typeof a=="number")return a;if(fi(a))return Ie;if(or(a)){var c=typeof a.valueOf=="function"?a.valueOf():a;a=or(c)?c+"":c}if(typeof a!="string")return a===0?a:+a;a=sc(a);var v=Di.test(a);return v||cn.test(a)?Bh(a.slice(2),v?2:8):Ln.test(a)?Ie:+a}function kg(a){return os(a,zn(a))}function XD(a){return a?da(dt(a),-X,X):a===0?a:0}function jt(a){return a==null?"":li(a)}var JD=oo(function(a,c){if(Ec(c)||Gn(c)){os(c,Ur(c),a);return}for(var v in c)$t.call(c,v)&&hc(a,v,c[v])}),Ng=oo(function(a,c){os(c,zn(c),a)}),Xl=oo(function(a,c,v,y){os(c,zn(c),a,y)}),ZD=oo(function(a,c,v,y){os(c,Ur(c),a,y)}),QD=zs(Xh);function e6(a,c){var v=ao(a);return c==null?v:d1(v,c)}var t6=vt(function(a,c){a=Kt(a);var v=-1,y=c.length,T=y>2?c[2]:e;for(T&&In(c[0],c[1],T)&&(y=1);++v1),j}),os(a,m0(a),v),y&&(v=Ii(v,h|p|E,hF));for(var T=c.length;T--;)o0(v,c[T]);return v});function A6(a,c){return Lg(a,zl(Ze(c)))}var w6=zs(function(a,c){return a==null?{}:zC(a,c)});function Lg(a,c){if(a==null)return{};var v=te(m0(a),function(y){return[y]});return c=Ze(c),B1(a,v,function(y,T){return c(y,T[0])})}function C6(a,c,v){c=Tu(c,a);var y=-1,T=c.length;for(T||(T=1,a=e);++yc){var y=a;a=c,c=y}if(v||a%1||c%1){var T=l1();return fn(a+T*(c-a+Ih("1e-"+((T+"").length-1))),c)}return s0(a,c)}var R6=co(function(a,c,v){return c=c.toLowerCase(),a+(v?Hg(c):c)});function Hg(a){return R0(jt(a).toLowerCase())}function Mg(a){return a=jt(a),a&&a.replace(Zr,uc).replace(yn,"")}function T6(a,c,v){a=jt(a),c=li(c);var y=a.length;v=v===e?y:da(dt(v),0,y);var T=v;return v-=c.length,v>=0&&a.slice(v,T)==c}function O6(a){return a=jt(a),a&&Tt.test(a)?a.replace(ts,Oh):a}function k6(a){return a=jt(a),a&&Qu.test(a)?a.replace(ns,"\\$&"):a}var N6=co(function(a,c,v){return a+(v?"-":"")+c.toLowerCase()}),x6=co(function(a,c,v){return a+(v?" ":"")+c.toLowerCase()}),L6=K1("toLowerCase");function U6(a,c,v){a=jt(a),c=dt(c);var y=c?Us(a):0;if(!c||y>=c)return a;var T=(c-y)/2;return Ll(ue(T),v)+a+Ll(V(T),v)}function j6(a,c,v){a=jt(a),c=dt(c);var y=c?Us(a):0;return c&&y>>0,v?(a=jt(a),a&&(typeof c=="string"||c!=null&&!B0(c))&&(c=li(c),!c&&Ls(a))?Ou(qn(a),0,v):a.split(c,v)):[]}var z6=co(function(a,c,v){return a+(v?" ":"")+R0(c)});function W6(a,c,v){return a=jt(a),v=v==null?0:da(dt(v),0,a.length),c=li(c),a.slice(v,v+c.length)==c}function Y6(a,c,v){var y=x.templateSettings;v&&In(a,c,v)&&(c=e),a=jt(a),c=Xl({},c,y,Z1);var T=Xl({},c.imports,y.imports,Z1),j=Ur(T),Y=la(T,j),Z,ie,Ee=0,Ae=c.interpolate||Pr,Ce="__p += '",Pe=Xa((c.escape||Pr).source+"|"+Ae.source+"|"+(Ae===bu?Ar:Pr).source+"|"+(c.evaluate||Pr).source+"|$","g"),qe="//# sourceURL="+($t.call(c,"sourceURL")?(c.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Dh+"]")+` `;a.replace(Pe,function(tt,wt,bt,hi,Bn,pi){return bt||(bt=hi),Ce+=a.slice(Ee,pi).replace(ea,vl),wt&&(Z=!0,Ce+=`' + __e(`+wt+`) + '`),Bn&&(ie=!0,Ce+=`'; `+Bn+`; __p += '`),bt&&(Ce+=`' + ((__t = (`+bt+`)) == null ? '' : __t) + '`),Ee=pi+tt.length,tt}),Ce+=`'; `;var et=$t.call(c,"variable")&&c.variable;if(!et)Ce=`with (obj) { `+Ce+` } `;else if(at.test(et))throw new nt(u);Ce=(ie?Ce.replace(Li,""):Ce).replace(Du,"$1").replace(es,"$1;"),Ce="function("+(et||"obj")+`) { `+(et?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(Z?", __e = _.escape":"")+(ie?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+Ce+`return __p }`;var gt=Vg(function(){return St(j,qe+"return "+Ce).apply(e,Y)});if(gt.source=Ce,I0(gt))throw gt;return gt}function X6(a){return jt(a).toLowerCase()}function J6(a){return jt(a).toUpperCase()}function Z6(a,c,v){if(a=jt(a),a&&(v||c===e))return sc(a);if(!a||!(c=li(c)))return a;var y=qn(a),T=qn(c),j=za(y,T),Y=gl(y,T)+1;return Ou(y,j,Y).join("")}function Q6(a,c,v){if(a=jt(a),a&&(v||c===e))return a.slice(0,Ya(a)+1);if(!a||!(c=li(c)))return a;var y=qn(a),T=gl(y,qn(c))+1;return Ou(y,0,T).join("")}function e3(a,c,v){if(a=jt(a),a&&(v||c===e))return a.replace(ks,"");if(!a||!(c=li(c)))return a;var y=qn(a),T=za(y,qn(c));return Ou(y,T).join("")}function t3(a,c){var v=b,y=B;if(or(c)){var T="separator"in c?c.separator:T;v="length"in c?dt(c.length):v,y="omission"in c?li(c.omission):y}a=jt(a);var j=a.length;if(Ls(a)){var Y=qn(a);j=Y.length}if(v>=j)return a;var Z=v-Us(y);if(Z<1)return y;var ie=Y?Ou(Y,0,Z).join(""):a.slice(0,Z);if(T===e)return ie+y;if(Y&&(Z+=ie.length-Z),B0(T)){if(a.slice(Z).search(T)){var Ee,Ae=ie;for(T.global||(T=Xa(T.source,jt(Lt.exec(T))+"g")),T.lastIndex=0;Ee=T.exec(Ae);)var Ce=Ee.index;ie=ie.slice(0,Ce===e?Z:Ce)}}else if(a.indexOf(li(T),Z)!=Z){var Pe=ie.lastIndexOf(T);Pe>-1&&(ie=ie.slice(0,Pe))}return ie+y}function r3(a){return a=jt(a),a&&Ui.test(a)?a.replace(yu,Al):a}var n3=co(function(a,c,v){return a+(v?" ":"")+c.toUpperCase()}),R0=K1("toUpperCase");function qg(a,c,v){return a=jt(a),c=v?e:c,c===e?Nh(a)?jh(a):rc(a):a.match(c)||[]}var Vg=vt(function(a,c){try{return Sn(a,e,c)}catch(v){return I0(v)?v:new nt(v)}}),i3=zs(function(a,c){return Mn(c,function(v){v=cs(v),Ks(a,v,b0(a[v],a))}),a});function s3(a){var c=a==null?0:a.length,v=Ze();return a=c?te(a,function(y){if(typeof y[1]!="function")throw new Vn(s);return[v(y[0]),y[1]]}):[],vt(function(y){for(var T=-1;++TX)return[];var v=be,y=fn(a,be);c=Ze(c),a-=be;for(var T=ic(y,c);++v0||c<0)?new Ft(v):(a<0?v=v.takeRight(-a):a&&(v=v.drop(a)),c!==e&&(c=dt(c),v=c<0?v.dropRight(-c):v.take(c-a)),v)},Ft.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Ft.prototype.toArray=function(){return this.take(be)},as(Ft.prototype,function(a,c){var v=/^(?:filter|find|map|reject)|While$/.test(c),y=/^(?:head|last)$/.test(c),T=x[y?"take"+(c=="last"?"Right":""):c],j=y||/^find/.test(c);T&&(x.prototype[c]=function(){var Y=this.__wrapped__,Z=y?[1]:arguments,ie=Y instanceof Ft,Ee=Z[0],Ae=ie||lt(Y),Ce=function(wt){var bt=T.apply(x,ai([wt],Z));return y&&Pe?bt[0]:bt};Ae&&v&&typeof Ee=="function"&&Ee.length!=1&&(ie=Ae=!1);var Pe=this.__chain__,qe=!!this.__actions__.length,et=j&&!Pe,gt=ie&&!qe;if(!j&&Ae){Y=gt?Y:new Ft(this);var tt=a.apply(Y,Z);return tt.__actions__.push({func:ql,args:[Ce],thisArg:e}),new _i(tt,Pe)}return et&>?a.apply(this,Z):(tt=this.thru(Ce),et?y?tt.value()[0]:tt.value():tt)})}),Mn(["pop","push","shift","sort","splice","unshift"],function(a){var c=Ja[a],v=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",y=/^(?:pop|shift)$/.test(a);x.prototype[a]=function(){var T=arguments;if(y&&!this.__chain__){var j=this.value();return c.apply(lt(j)?j:[],T)}return this[v](function(Y){return c.apply(lt(Y)?Y:[],T)})}}),as(Ft.prototype,function(a,c){var v=x[c];if(v){var y=v.name+"";$t.call(uo,y)||(uo[y]=[]),uo[y].push({name:c,func:v})}}),uo[Nl(e,g).name]=[{name:"wrapper",func:e}],Ft.prototype.clone=rC,Ft.prototype.reverse=nC,Ft.prototype.value=iC,x.prototype.at=T4,x.prototype.chain=O4,x.prototype.commit=k4,x.prototype.next=N4,x.prototype.plant=L4,x.prototype.reverse=U4,x.prototype.toJSON=x.prototype.valueOf=x.prototype.value=j4,x.prototype.first=x.prototype.head,Hs&&(x.prototype[Hs]=x4),x},bi=Hh();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(br._=bi,define(function(){return bi})):Ns?((Ns.exports=bi)._=bi,Qo._=bi):br._=bi}).call(Vo)});var ph=De((gN,IA)=>{"use strict";var $$=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])},$d=class e extends Error{constructor(t,r,n){super(t),$$(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:u,text:i})=>({source:u,text:i.split(/\r\n|\n|\r/g)}));function n(u,i,o=""){let l="",h=r.find(({source:E})=>E===u.source),p=u.start;if(h){let E=u.end,d=h.text[p.line-1],w=(p.line===E.line?E.column:d.length+1)-p.column||1;o&&(l+=` note: ${o}`),l+=` --> ${u.source}:${p.line}:${p.column} ${"".padEnd(i)} | ${p.line.toString().padStart(i)} | ${d} ${"".padEnd(i)} | ${"".padEnd(p.column-1)}${"".padEnd(w,"^")}`}else l+=` at ${u.source}:${p.line}:${p.column}`,o&&(l+=`: ${o}`);return l}function s(u,i,o,l=[]){let h;o?h=l.reduce((E,{location:d})=>Math.max(E,d.start.line),o.start.line):h=Math.max.apply(null,l.map(E=>E.location.start.line)),h=h.toString().length;let p=`${u}: ${i}`;o&&(p+=n(o,h));for(let E of l)p+=n(E.location,h,E.message);return p}return this.problems.filter(u=>u[0]!=="info").map(u=>s(...u)).join(` `)}};IA.exports=$d});var Ni=De((mN,BA)=>{"use strict";var P$={build(e){function t(i,...o){return e[i.type](i,...o)}function r(){}function n(i,...o){return t(i.expression,...o)}function s(i){return function(o,...l){o[i].forEach(h=>t(h,...l))}}let u={grammar(i,...o){i.topLevelInitializer&&t(i.topLevelInitializer,...o),i.initializer&&t(i.initializer,...o),i.rules.forEach(l=>t(l,...o))},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(u).forEach(i=>{Object.prototype.hasOwnProperty.call(e,i)||(e[i]=u[i])}),t}};BA.exports=P$});var Wu=De((vN,PA)=>{"use strict";var R$=Ni(),$A={findRule(e,t){for(let r=0;r{"use strict";var T$={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};RA.exports=T$});var Rd=De((AN,TA)=>{"use strict";var O$=Ni(),k$=Wu(),N$=ph(),Jc=1,Ha=0,Zc=-1;function dh(e){function t(i){return i.match=Ha}function r(i){return u(i.expression),i.match=Jc}function n(i){return i.match=u(i.expression)}function s(i,o){let l=i.length,h=0,p=0;for(let E=0;E0?Zc:Ha}let u=O$.build({rule(i){let o,l=0;if(typeof i.match>"u"){i.match=Ha;do if(o=i.match,i.match=u(i.expression),++l>6)throw new N$("Infinity cycle detected when trying to evaluate node match result",i.location);while(o!==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=-u(i.expression)},optional:r,zero_or_more:r,one_or_more:n,group:n,semantic_and:t,semantic_not:t,rule_ref(i){let o=k$.findRule(e,i.name);return i.match=u(o)},literal(i){let o=i.value.length===0?Jc:Ha;return i.match=o},class(i){let o=i.parts.length===0?Zc:Ha;return i.match=o},any:t});u(e)}dh.ALWAYS_MATCH=Jc;dh.SOMETIMES_MATCH=Ha;dh.NEVER_MATCH=Zc;TA.exports=dh});var kA=De((wN,OA)=>{"use strict";var x$=Wu(),Oe=Pd(),L$=Ni(),{ALWAYS_MATCH:Wo,SOMETIMES_MATCH:Td,NEVER_MATCH:Od}=Rd();function U$(e){let t=[],r=[],n=[],s=[];function u(C){let S=t.indexOf(C);return S===-1?t.push(C)-1:S}function i(C){let S={value:C.parts,inverted:C.inverted,ignoreCase:C.ignoreCase},I=JSON.stringify(S),_=r.findIndex(L=>JSON.stringify(L)===I);return _===-1?r.push(S)-1:_}function o(C){let S=JSON.stringify(C),I=n.findIndex(_=>JSON.stringify(_)===S);return I===-1?n.push(C)-1:I}function l(C,S,I){let _={predicate:C,params:S,body:I.code,location:I.codeLocation},L=JSON.stringify(_),M=s.findIndex(b=>JSON.stringify(b)===L);return M===-1?s.push(_)-1:M}function h(C){let S={};return Object.keys(C).forEach(I=>{S[I]=C[I]}),S}function p(C,...S){return C.concat(...S)}function E(C,S,I,_){return C===Wo?I:C===Od?_:S.concat([I.length,_.length],I,_)}function d(C,S){return C.concat([S.length],S)}function f(C,S,I,_){let L=Object.keys(I).map(M=>_-I[M]);return[Oe.CALL,C,S,L.length].concat(L)}function w(C,S,I){let _=C.match|0;return p([Oe.PUSH_CURR_POS],[Oe.SILENT_FAILS_ON],A(C,{sp:I.sp+1,env:h(I.env),action:null}),[Oe.SILENT_FAILS_OFF],E(S?-_:_,[S?Oe.IF_ERROR:Oe.IF_NOT_ERROR],p([Oe.POP],[S?Oe.POP:Oe.POP_CURR_POS],[Oe.PUSH_UNDEFINED]),p([Oe.POP],[S?Oe.POP_CURR_POS:Oe.POP],[Oe.PUSH_FAILED])))}function g(C,S,I){let _=l(!0,Object.keys(I.env),C);return p([Oe.UPDATE_SAVED_POS],f(_,0,I.env,I.sp),E(C.match|0,[Oe.IF],p([Oe.POP],S?[Oe.PUSH_FAILED]:[Oe.PUSH_UNDEFINED]),p([Oe.POP],S?[Oe.PUSH_UNDEFINED]:[Oe.PUSH_FAILED])))}function F(C){return d([Oe.WHILE_NOT_ERROR],p([Oe.APPEND],C))}let A=L$.build({grammar(C){C.rules.forEach(A),C.literals=t,C.classes=r,C.expectations=n,C.functions=s},rule(C){C.bytecode=A(C.expression,{sp:-1,env:{},pluck:[],action:null})},named(C,S){let I=C.match|0,_=I===Od?null:o({type:"rule",value:C.name});return p([Oe.SILENT_FAILS_ON],A(C.expression,S),[Oe.SILENT_FAILS_OFF],E(I,[Oe.IF_ERROR],[Oe.FAIL,_],[]))},choice(C,S){function I(_,L){let M=_[0].match|0,b=A(_[0],{sp:L.sp,env:h(L.env),action:null});return M===Wo?b:p(b,_.length>1?E(Td,[Oe.IF_ERROR],p([Oe.POP],I(_.slice(1),L)),[]):[])}return I(C.alternatives,S)},action(C,S){let I=h(S.env),_=C.expression.type!=="sequence"||C.expression.elements.length===0,L=A(C.expression,{sp:S.sp+(_?1:0),env:I,action:C}),M=C.expression.match|0,b=_&&M!==Od?l(!1,Object.keys(I),C):null;return _?p([Oe.PUSH_CURR_POS],L,E(M,[Oe.IF_NOT_ERROR],p([Oe.LOAD_SAVED_POS,1],f(b,1,I,S.sp+2)),[]),[Oe.NIP]):L},sequence(C,S){function I(_,L){if(_.length>0){let M=C.elements.length-_.length+1;return p(A(_[0],{sp:L.sp,env:L.env,pluck:L.pluck,action:null}),E(_[0].match|0,[Oe.IF_NOT_ERROR],I(_.slice(1),{sp:L.sp+1,env:L.env,pluck:L.pluck,action:L.action}),p(M>1?[Oe.POP_N,M]:[Oe.POP],[Oe.POP_CURR_POS],[Oe.PUSH_FAILED])))}else{if(L.pluck.length>0)return p([Oe.PLUCK,C.elements.length+1,L.pluck.length],L.pluck.map(M=>L.sp-M));if(L.action){let M=l(!1,Object.keys(L.env),L.action);return p([Oe.LOAD_SAVED_POS,C.elements.length],f(M,C.elements.length+1,L.env,L.sp))}else return p([Oe.WRAP,C.elements.length],[Oe.NIP])}}return p([Oe.PUSH_CURR_POS],I(C.elements,{sp:S.sp+1,env:S.env,pluck:[],action:S.action}))},labeled(C,S){let I=S.env,_=C.label,L=S.sp+1;return _&&(I=h(S.env),S.env[C.label]=L),C.pick&&S.pluck.push(L),A(C.expression,{sp:S.sp,env:I,action:null})},text(C,S){return p([Oe.PUSH_CURR_POS],A(C.expression,{sp:S.sp+1,env:h(S.env),action:null}),E(C.match|0,[Oe.IF_NOT_ERROR],p([Oe.POP],[Oe.TEXT]),[Oe.NIP]))},simple_and(C,S){return w(C.expression,!1,S)},simple_not(C,S){return w(C.expression,!0,S)},optional(C,S){return p(A(C.expression,{sp:S.sp,env:h(S.env),action:null}),E(-(C.expression.match|0),[Oe.IF_ERROR],p([Oe.POP],[Oe.PUSH_NULL]),[]))},zero_or_more(C,S){let I=A(C.expression,{sp:S.sp+1,env:h(S.env),action:null});return p([Oe.PUSH_EMPTY_ARRAY],I,F(I),[Oe.POP])},one_or_more(C,S){let I=A(C.expression,{sp:S.sp+1,env:h(S.env),action:null});return p([Oe.PUSH_EMPTY_ARRAY],I,E(C.expression.match|0,[Oe.IF_NOT_ERROR],p(F(I),[Oe.POP]),p([Oe.POP],[Oe.POP],[Oe.PUSH_FAILED])))},group(C,S){return A(C.expression,{sp:S.sp,env:h(S.env),action:null})},semantic_and(C,S){return g(C,!1,S)},semantic_not(C,S){return g(C,!0,S)},rule_ref(C){return[Oe.RULE,x$.indexOfRule(e,C.name)]},literal(C){if(C.value.length>0){let S=C.match|0,_=S===Td||S===Wo&&!C.ignoreCase?u(C.ignoreCase?C.value.toLowerCase():C.value):null,L=S!==Wo?o({type:"literal",value:C.value,ignoreCase:C.ignoreCase}):null;return E(S,C.ignoreCase?[Oe.MATCH_STRING_IC,_]:[Oe.MATCH_STRING,_],C.ignoreCase?[Oe.ACCEPT_N,C.value.length]:[Oe.ACCEPT_STRING,_],[Oe.FAIL,L])}return[Oe.PUSH_EMPTY_STRING]},class(C){let S=C.match|0,I=S===Td?i(C):null,_=S!==Wo?o({type:"class",value:C.parts,inverted:C.inverted,ignoreCase:C.ignoreCase}):null;return E(S,[Oe.MATCH_CHAR_CLASS,I],[Oe.ACCEPT_N,1],[Oe.FAIL,_])},any(C){let S=C.match|0,I=S!==Wo?o({type:"any"}):null;return E(S,[Oe.MATCH_ANY],[Oe.ACCEPT_N,1],[Oe.FAIL,I])}});A(e)}OA.exports=U$});var xA=De((CN,NA)=>{"use strict";var kd=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 u=this.sp;if(this.sp=s,n(),u!==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: "+u+", 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+").")}};NA.exports=kd});var Nd=De((FN,LA)=>{"use strict";LA.exports="2.0.1"});var UA=De(gh=>{"use strict";function Cu(e){return e.charCodeAt(0).toString(16).toUpperCase()}gh.hex=Cu;function j$(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"+Cu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Cu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Cu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Cu(t))}gh.stringEscape=j$;function H$(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"+Cu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Cu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Cu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Cu(t))}gh.regexpClassEscape=H$});var MA=De(HA=>{var jA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");HA.encode=function(e){if(0<=e&&e{var M$=MA(),qA=5,VA=1<>>=qA,s>0&&(n|=V$),r+=M$.encode(n);while(s>0);return r}});var vh=De(Xu=>{function G$(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}Xu.getArg=G$;var WA=function(){return!("__proto__"in Object.create(null))}();function YA(e){return e}function z$(e){return XA(e)?"$"+e:e}Xu.toSetString=WA?YA:z$;function W$(e){return XA(e)?e.slice(1):e}Xu.fromSetString=WA?YA:W$;function XA(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 zA(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function Y$(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=zA(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:zA(e.name,t.name)}Xu.compareByGeneratedPositionsInflated=Y$;var xd="http:",Qc=`${xd}//host`;function JA(e){return t=>{let r=el(t),n=Ld(t),s=new URL(t,n);e(s);let u=s.toString();return r==="absolute"?u:r==="scheme-relative"?u.slice(xd.length):r==="path-absolute"?u.slice(Qc.length):Ud(n,u)}}function Yu(e,t){return new URL(e,t).toString()}function X$(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function Ld(e){let t=e.split("..").length-1,r=X$("p",e),n=`${Qc}/`;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 Z$=JA(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),mh=JA(e=>{});Xu.normalize=mh;function Q$(e,t){let r=el(t),n=el(e);if(e=Z$(e),r==="absolute")return Yu(t,void 0);if(n==="absolute")return Yu(t,e);if(r==="scheme-relative")return mh(t);if(n==="scheme-relative")return Yu(t,Yu(e,Qc)).slice(xd.length);if(r==="path-absolute")return mh(t);if(n==="path-absolute")return Yu(t,Yu(e,Qc)).slice(Qc.length);let s=Ld(t+e),u=Yu(t,Yu(e,s));return Ud(s,u)}Xu.join=Q$;function e7(e,t){let r=t7(e,t);return typeof r=="string"?r:mh(t)}Xu.relative=e7;function t7(e,t){if(el(e)!==el(t))return null;let n=Ld(e+t),s=new URL(e,n),u=new URL(t,n);try{new URL("",u.toString())}catch{return null}return u.protocol!==s.protocol||u.user!==s.user||u.password!==s.password||u.hostname!==s.hostname||u.port!==s.port?null:Ud(s,u)}});var QA=De(ZA=>{var jd=class e{constructor(){this._array=[],this._set=new Map}static fromArray(t,r){let n=new e;for(let s=0,u=t.length;s=0)return r;throw new Error('"'+t+'" is not in the set.')}at(t){if(t>=0&&t{var ew=vh();function r7(e,t){let r=e.generatedLine,n=t.generatedLine,s=e.generatedColumn,u=t.generatedColumn;return n>r||n==r&&u>=s||ew.compareByGeneratedPositionsInflated(e,t)<=0}var Hd=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){r7(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(ew.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};tw.MappingList=Hd});var Md=De(nw=>{var tl=GA(),$r=vh(),Eh=QA().ArraySet,n7=rw().MappingList,Ah=class e{constructor(t){t||(t={}),this._file=$r.getArg(t,"file",null),this._sourceRoot=$r.getArg(t,"sourceRoot",null),this._skipValidation=$r.getArg(t,"skipValidation",!1),this._sources=new Eh,this._names=new Eh,this._mappings=new n7,this._sourcesContents=null}static fromSourceMap(t){let r=t.sourceRoot,n=new e({file:t.file,sourceRoot:r});return t.eachMapping(function(s){let u={generated:{line:s.generatedLine,column:s.generatedColumn}};s.source!=null&&(u.source=s.source,r!=null&&(u.source=$r.relative(r,u.source)),u.original={line:s.originalLine,column:s.originalColumn},s.name!=null&&(u.name=s.name)),n.addMapping(u)}),t.sources.forEach(function(s){let u=s;r!=null&&(u=$r.relative(r,s)),n._sources.has(u)||n._sources.add(u);let i=t.sourceContentFor(s);i!=null&&n.setSourceContent(s,i)}),n}addMapping(t){let r=$r.getArg(t,"generated"),n=$r.getArg(t,"original",null),s=$r.getArg(t,"source",null),u=$r.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,s,u),s!=null&&(s=String(s),this._sources.has(s)||this._sources.add(s)),u!=null&&(u=String(u),this._names.has(u)||this._names.add(u)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n&&n.line,originalColumn:n&&n.column,source:s,name:u})}setSourceContent(t,r){let n=t;this._sourceRoot!=null&&(n=$r.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[$r.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[$r.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 u=this._sourceRoot;u!=null&&(s=$r.relative(u,s));let i=this._mappings.toArray().length>0?new Eh:this._sources,o=new Eh;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=$r.join(n,l.source)),u!=null&&(l.source=$r.relative(u,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 p=l.name;p!=null&&!o.has(p)&&o.add(p)},this),this._sources=i,this._names=o,t.sources.forEach(function(l){let h=t.sourceContentFor(l);h!=null&&(n!=null&&(l=$r.join(n,l)),u!=null&&(l=$r.relative(u,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,u=0,i=0,o="",l,h,p,E,d=this._mappings.toArray();for(let f=0,w=d.length;f0){if(!$r.compareByGeneratedPositionsInflated(h,d[f-1]))continue;l+=","}l+=tl.encode(h.generatedColumn-t),t=h.generatedColumn,h.source!=null&&(E=this._sources.indexOf(h.source),l+=tl.encode(E-i),i=E,l+=tl.encode(h.originalLine-1-s),s=h.originalLine-1,l+=tl.encode(h.originalColumn-n),n=h.originalColumn,h.name!=null&&(p=this._names.indexOf(h.name),l+=tl.encode(p-u),u=p)),o+=l}return o}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=$r.relative(r,n));let s=$r.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())}};Ah.prototype._version=3;nw.SourceMapGenerator=Ah});var sw=De(iw=>{var i7=Md().SourceMapGenerator,wh=vh(),s7=/(\r?\n)/,u7=10,Yo="$$$isSourceNode$$$",qd=class e{constructor(t,r,n,s,u){this.children=[],this.sourceContents={},this.line=t??null,this.column=r??null,this.source=n??null,this.name=u??null,this[Yo]=!0,s!=null&&this.add(s)}static fromStringWithSourceMap(t,r,n){let s=new e,u=t.split(s7),i=0,o=function(){let f=g(),w=g()||"";return f+w;function g(){return i=0;r--)this.prepend(t[r]);else if(t[Yo]||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{Vd.SourceMapGenerator=Md().SourceMapGenerator;Vd.SourceNode=sw().SourceNode});var lw=De((RN,cw)=>{"use strict";var a7=Wu(),xt=Pd(),o7=xA(),c7=Nd(),{stringEscape:Fi,regexpClassEscape:Kd}=UA(),{SourceNode:xi}=uw();function ow(e,t,r){let n=t.start.line,s=t.start.column-1,u=e.split(` `);return u.length===1?new xi(n,s,t.source,e,r):new xi(null,null,t.source,u.map((i,o)=>new xi(n+o,o===0?s:0,t.source,o===u.length-1?i:[i,` `],r)))}function aw(e,t,r,n,s){return r?new xi(null,null,r.source,[e,ow(t,r,s),new xi(r.end.line,r.end.column-1,r.source,n)]):new xi(null,null,null,[e,t,n])}function l7(e,t){function r(g){return g instanceof xi?g:g.replace(/^(.+)$/gm," $1")}function n(g){return"peg$c"+g}function s(g){return"peg$r"+g}function u(g){return"peg$e"+g}function i(g){return"peg$f"+g}function o(g){return"peg$parse"+g}function l(){function g(S){return'"'+Fi(S)+'"'}function F(S){return"/^["+(S.inverted?"^":"")+S.value.map(I=>Array.isArray(I)?Kd(I[0])+"-"+Kd(I[1]):Kd(I)).join("")+"]/"+(S.ignoreCase?"i":"")}function A(S){switch(S.type){case"rule":return'peg$otherExpectation("'+Fi(S.value)+'")';case"literal":return'peg$literalExpectation("'+Fi(S.value)+'", '+S.ignoreCase+")";case"class":return"peg$classExpectation(["+S.value.map(_=>Array.isArray(_)?'["'+Fi(_[0])+'", "'+Fi(_[1])+'"]':'"'+Fi(_)+'"').join(", ")+"], "+S.inverted+", "+S.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(S)+")")}}function C(S,I){return aw(` var ${i(I)} = function(${S.params.join(", ")}) {`,S.body,S.location,"};")}return new xi(null,null,t.grammarSource,[e.literals.map((S,I)=>" var "+n(I)+" = "+g(S)+";").concat("",e.classes.map((S,I)=>" var "+s(I)+" = "+F(S)+";")).concat("",e.expectations.map((S,I)=>" var "+u(I)+" = "+A(S)+";")).concat("").join(` `),e.functions.map(C)])}function h(g,F){let A=[];return A.push(""),t.trace&&A.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)","});",""),t.cache&&(A.push("var key = peg$currPos * "+e.rules.length+" + "+F+";","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: "+g+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)"," });","}",""),A.push(" return cached.result;","}","")),A}function p(g,F){let A=[];return t.cache&&A.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+F+" };"),t.trace&&A.push("","if ("+F+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+g+","," result: "+F+","," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)"," });","}"),A.push("","return "+F+";"),A}function E(g){let F=[],A=new o7(g.name,"s","var");function C(I){let _=0,L=I.length,M=[],b;function B(q,W){let K=W+3,z=I[_+K-2],X=I[_+K-1],se,Ie;A.checkedIf(_,()=>{_+=K,se=C(I.slice(_,_+z)),_+=z},X>0?()=>{Ie=C(I.slice(_,_+X)),_+=X}:null),M.push("if ("+q+") {"),M.push(...se.map(r)),X>0&&(M.push("} else {"),M.push(...Ie.map(r))),M.push("}")}function k(q){let K=I[_+2-1],z;A.checkedLoop(_,()=>{_+=2,z=C(I.slice(_,_+K)),_+=K}),M.push("while ("+q+") {"),M.push(...z.map(r)),M.push("}")}function U(){let W=I[_+4-1],K=i(I[_+1])+"("+I.slice(_+4,_+4+W).map(z=>A.index(z)).join(", ")+")";A.pop(I[_+2]),M.push(A.push(K)),_+=4+W}for(;_A.index(z)).join(", ")} ]`,A.pop(I[_+1]),M.push(A.push(b)),_+=K;break}case xt.IF:B(A.top(),0);break;case xt.IF_ERROR:B(A.top()+" === peg$FAILED",0);break;case xt.IF_NOT_ERROR:B(A.top()+" !== peg$FAILED",0);break;case xt.WHILE_NOT_ERROR:k(A.top()+" !== peg$FAILED");break;case xt.MATCH_ANY:B("input.length > peg$currPos",0);break;case xt.MATCH_STRING:B(e.literals[I[_+1]].length>1?"input.substr(peg$currPos, "+e.literals[I[_+1]].length+") === "+n(I[_+1]):"input.charCodeAt(peg$currPos) === "+e.literals[I[_+1]].charCodeAt(0),1);break;case xt.MATCH_STRING_IC:B("input.substr(peg$currPos, "+e.literals[I[_+1]].length+").toLowerCase() === "+n(I[_+1]),1);break;case xt.MATCH_CHAR_CLASS:B(s(I[_+1])+".test(input.charAt(peg$currPos))",1);break;case xt.ACCEPT_N:M.push(A.push(I[_+1]>1?"input.substr(peg$currPos, "+I[_+1]+")":"input.charAt(peg$currPos)")),M.push(I[_+1]>1?"peg$currPos += "+I[_+1]+";":"peg$currPos++;"),_+=2;break;case xt.ACCEPT_STRING:M.push(A.push(n(I[_+1]))),M.push(e.literals[I[_+1]].length>1?"peg$currPos += "+e.literals[I[_+1]].length+";":"peg$currPos++;"),_+=2;break;case xt.FAIL:M.push(A.push("peg$FAILED")),M.push("if (peg$silentFails === 0) { peg$fail("+u(I[_+1])+"); }"),_+=2;break;case xt.LOAD_SAVED_POS:M.push("peg$savedPos = "+A.index(I[_+1])+";"),_+=2;break;case xt.UPDATE_SAVED_POS:M.push("peg$savedPos = peg$currPos;"),_++;break;case xt.CALL:U();break;case xt.RULE:M.push(A.push(o(e.rules[I[_+1]].name)+"()")),_+=2;break;case xt.SILENT_FAILS_ON:M.push("peg$silentFails++;"),_++;break;case xt.SILENT_FAILS_OFF:M.push("peg$silentFails--;"),_++;break;default:throw new Error("Invalid opcode: "+I[_]+".")}return M}let S=C(g.bytecode);return F.push(aw(" function ",o(g.name),g.nameLocation,`() { `,g.name)),t.trace&&F.push(" var startPos = peg$currPos;"),F.push(r(A.defines())),F.push(...h('"'+Fi(g.name)+'"',a7.indexOfRule(e,g.name)).map(r)),F.push(...S.map(r)),F.push(...p('"'+Fi(g.name)+'"',A.result()).map(r)),F.push("}"),F}function d(g){return g.codeLocation?ow(g.code,g.codeLocation,"$"+g.type):g.code}function f(){let g=[];e.topLevelInitializer&&(g.push(d(e.topLevelInitializer)),g.push("")),g.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&&g.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 F="{ "+t.allowedStartRules.map(C=>C+": "+o(C)).join(", ")+" }",A=o(t.allowedStartRules[0]);return g.push("function peg$parse(input, options) {"," options = options !== undefined ? options : {};",""," var peg$FAILED = {};"," var peg$source = options.grammarSource;",""," var peg$startRuleFunctions = "+F+";"," 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&&g.push(" var peg$resultsCache = {};",""),t.trace&&g.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),g.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(C=>{g.push(...E(C).map(r)),g.push("")}),e.initializer&&(g.push(d(e.initializer)),g.push("")),g.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 xi(null,null,t.grammarSource,g.map(C=>C instanceof xi?C:C+` `))}function w(g){function F(){return[`// Generated by Peggy ${c7}.`,"//","// 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 S={bare(){return[...F(),"(function() {",' "use strict";',"",g,"",r("return "+A()+";"),"})()"]},commonjs(){let I=Object.keys(t.dependencies),_=F();return _.push("",'"use strict";',""),I.length>0&&(I.forEach(L=>{_.push("var "+L+' = require("'+Fi(t.dependencies[L])+'");')}),_.push("")),_.push(g,"","module.exports = "+A()+";"),_},es(){let I=Object.keys(t.dependencies),_=F();return _.push(""),I.length>0&&(I.forEach(L=>{_.push("import "+L+' from "'+Fi(t.dependencies[L])+'";')}),_.push("")),_.push(g,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),_},amd(){let I=Object.keys(t.dependencies),L="["+I.map(b=>t.dependencies[b]).map(b=>'"'+Fi(b)+'"').join(", ")+"]",M=I.join(", ");return[...F(),"define("+L+", function("+M+") {",' "use strict";',"",g,"",r("return "+A()+";"),"});"]},globals(){return[...F(),"(function(root) {",' "use strict";',"",g,"",r("root."+t.exportVar+" = "+A()+";"),"})(this);"]},umd(){let I=Object.keys(t.dependencies),_=I.map(k=>t.dependencies[k]),L="["+_.map(k=>'"'+Fi(k)+'"').join(", ")+"]",M=_.map(k=>'require("'+Fi(k)+'")').join(", "),b=I.join(", "),B=F();return B.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+L+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+M+");"),t.exportVar!==null&&B.push(" } else {"," root."+t.exportVar+" = factory();"),B.push(" }","})(this, function("+b+") {",' "use strict";',"",g,"",r("return "+A()+";"),"});"),B}}[t.format]();return new xi(null,null,t.grammarSource,S.map(I=>I instanceof xi?I:I+` `))}e.code=w(f())}cw.exports=l7});var hw=De((TN,fw)=>{"use strict";var f7=Wu(),h7=Ni();function p7(e,t,r){function n(i){return i.type==="rule"&&i.expression.type==="rule_ref"}function s(i,o,l){h7.build({rule_ref(p){p.name===o&&(p.name=l,r.info(`Proxy rule "${o}" replaced by the rule "${l}"`,p.location,[{message:"This rule will be used",location:f7.findRule(i,l).nameLocation}]))}})(i)}let u=[];e.rules.forEach((i,o)=>{n(i)&&(s(e,i.name,i.expression.name),t.allowedStartRules.indexOf(i.name)===-1&&u.push(o))}),u.reverse(),u.forEach(i=>{e.rules.splice(i,1)})}fw.exports=p7});var dw=De((ON,pw)=>{"use strict";var d7=Ni();function g7(e,t,r){function n(i){let o={};return Object.keys(i).forEach(l=>{o[l]=i[l]}),o}function s(i,o){u(i.expression,n(o))}let u=d7.build({rule(i){u(i.expression,{})},choice(i,o){i.alternatives.forEach(l=>{u(l,n(o))})},action:s,labeled(i,o){let l=i.label;l&&Object.prototype.hasOwnProperty.call(o,l)&&r.error(`Label "${i.label}" is already defined`,i.labelLocation,[{message:"Original label location",location:o[l]}]),u(i.expression,o),o[i.label]=i.labelLocation},text:s,simple_and:s,simple_not:s,optional:s,zero_or_more:s,one_or_more:s,group:s});u(e)}pw.exports=g7});var mw=De((kN,gw)=>{"use strict";var m7=Ni();function v7(e,t,r){let n={};m7.build({rule(u){if(Object.prototype.hasOwnProperty.call(n,u.name)){r.error(`Rule "${u.name}" is already defined`,u.nameLocation,[{message:"Original rule location",location:n[u.name]}]);return}n[u.name]=u.nameLocation}})(e)}gw.exports=v7});var Aw=De((NN,Ew)=>{"use strict";var vw=Wu(),E7=Ni();function A7(e,t,r){let n=[],s=[],u=E7.build({rule(i){n.push(i.name),u(i.expression),n.pop()},sequence(i){i.elements.every(o=>(u(o),!vw.alwaysConsumesOnSuccess(e,o)))},rule_ref(i){s.push(i);let o=vw.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(" -> ")+")",o.nameLocation,s.map((l,h,p)=>({message:h+1!==p.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}o&&u(o),s.pop()}});u(e)}Ew.exports=A7});var Fw=De((xN,Cw)=>{"use strict";var ww=Wu(),w7=Ni();function C7(e,t,r){w7.build({zero_or_more(s){ww.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){ww.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)}Cw.exports=C7});var yw=De((LN,Dw)=>{"use strict";var F7=Wu(),D7=Ni();function y7(e,t,r){D7.build({rule_ref(s){F7.findRule(e,s.name)||r.error(`Rule "${s.name}" is not defined`,s.location)}})(e)}Dw.exports=y7});var bw=De((UN,Sw)=>{"use strict";var S7=Ni();function b7(e,t,r){let n=S7.build({action(s){n(s.expression,s)},labeled(s,u){s.pick&&u&&r.error('"@" cannot be used with an action block',s.labelLocation,[{message:"Action block location",location:u.codeLocation}]),n(s.expression)}});n(e)}Sw.exports=b7});var Iw=De((jN,_w)=>{"use strict";var _7=ph(),Gd=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(){}},zd=class{constructor(t){this._callbacks=new Gd(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new _7(...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}};_w.exports=zd});var Bw=De((exports,module)=>{"use strict";var generateBytecode=kA(),generateJS=lw(),inferenceMatchResult=Rd(),removeProxyRules=hw(),reportDuplicateLabels=dw(),reportDuplicateRules=mw(),reportInfiniteRecursion=Aw(),reportInfiniteRepetition=Fw(),reportUndefinedRules=yw(),reportIncorrectPlucking=bw(),Session=Iw(),visitor=Ni();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 Pw=De((HN,$w)=>{"use strict";var I7={$:"text","&":"simple_and","!":"simple_not"},B7={"?":"optional","*":"zero_or_more","+":"one_or_more"},$7={"&":"semantic_and","!":"semantic_not"};function P7(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function Ju(e,t,r,n){var s=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(s,Ju.prototype),s.expected=t,s.found=r,s.location=n,s.name="SyntaxError",s}P7(Ju,Error);function Wd(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}Ju.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var r=null,n;for(n=0;n `+u+` `+o+` | `+s.line+" | "+l+` `+o+" | "+Wd("",s.column-1," ")+Wd("",p,"^")}else t+=` at `+u}return t};Ju.buildMessage=function(e,t){var r={literal:function(h){return'"'+s(h.text)+'"'},class:function(h){var p=h.parts.map(function(E){return Array.isArray(E)?u(E[0])+"-"+u(E[1]):u(E)});return"["+(h.inverted?"^":"")+p.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(p){return"\\x0"+n(p)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(p){return"\\x"+n(p)})}function u(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(p){return"\\x0"+n(p)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(p){return"\\x"+n(p)})}function i(h){return r[h.type](h)}function o(h){var p=h.map(i),E,d;if(p.sort(),p.length>0){for(E=1,d=1;E0?{type:"choice",alternatives:[D].concat(N),location:ur()}:D},yi=function(D,N){return N!==null?{type:"action",expression:D,code:N[0],codeLocation:N[1],location:ur()}:D},oa=function(D,N){return N.length>0||D.type==="labeled"&&D.pick?{type:"sequence",elements:[D].concat(N),location:ur()}:D},Fh=function(D,N,J){return J.type.startsWith("semantic_")&&rc('"@" cannot be used on a semantic predicate',D),{type:"labeled",label:N!==null?N[0]:null,labelLocation:N!==null?N[1]:D,pick:!0,expression:J,location:ur()}},Dh=function(D,N){return{type:"labeled",label:D[0],labelLocation:D[1],expression:N,location:ur()}},Xt=function(){return ur()},zt=function(D){return io.indexOf(D[0])>=0&&rc(`Label can't be a reserved word "${D[0]}"`,D[1]),D},yh=function(D,N){return{type:I7[D],expression:N,location:ur()}},Sh=function(D,N){return{type:B7[N],expression:D,location:ur()}},bh=function(D){return D.type==="labeled"||D.type==="sequence"?{type:"group",expression:D,location:ur()}:D},_h=function(D){return{type:"rule_ref",name:D[0],location:ur()}},Ih=function(D,N){return{type:$7[D],code:N[0],codeLocation:N[1],location:ur()}},Bh=function(D,N){return[D+N.join(""),ur()]},il=function(D,N){return{type:"literal",value:D,ignoreCase:N!==null,location:ur()}},$h=function(D){return D.join("")},br=function(D){return D.join("")},Qo=function(D,N,J){return{type:"class",parts:N.filter(V=>V!==""),inverted:D!==null,ignoreCase:J!==null,location:ur()}},Ns=function(D,N){return D.charCodeAt(0)>N.charCodeAt(0)&&rc("Invalid character range: "+tc()+"."),[D,N]},sl=function(){return""},ec=function(){return"\0"},Hn=function(){return"\b"},ul=function(){return"\f"},al=function(){return` `},ol=function(){return"\r"},cl=function(){return" "},ll=function(){return"\v"},fl=function(D){return String.fromCharCode(parseInt(D,16))},Sn=function(D){return String.fromCharCode(parseInt(D,16))},Ph=function(){return{type:"any",location:ur()}},Mn=function(D){return[D,ur()]},P=0,ot=0,ui=[{line:1,column:1}],bn=0,ca=[],te=0,ai;if("startRule"in t){if(!(t.startRule in s))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');u=s[t.startRule]}function tc(){return e.substring(ot,P)}function o1(){return ot}function hl(){return{source:n,start:ot,end:P}}function ur(){return xs(ot,P)}function c1(D,N){throw N=N!==void 0?N:xs(ot,P),dl([Si(D)],e.substring(ot,P),N)}function rc(D,N){throw N=N!==void 0?N:xs(ot,P),pl(D,N)}function Ye(D,N){return{type:"literal",text:D,ignoreCase:N}}function _r(D,N,J){return{type:"class",parts:D,inverted:N,ignoreCase:J}}function $u(){return{type:"any"}}function Rh(){return{type:"end"}}function Si(D){return{type:"other",description:D}}function nc(D){var N=ui[D],J;if(N)return N;for(J=D-1;!ui[J];)J--;for(N=ui[J],N={line:N.line,column:N.column};Jbn&&(bn=P,ca=[]),ca.push(D))}function pl(D,N){return new Ju(D,null,null,N)}function dl(D,N,J){return new Ju(Ju.buildMessage(D,N),D,N,J)}function Ga(){var D,N,J,V,ue,le,Gt,gr;if(D=P,N=Nt(),J=P,V=ic(),V!==r?(ue=Nt(),J=V):(P=J,J=r),J===r&&(J=null),V=P,ue=Th(),ue!==r?(le=Nt(),V=ue):(P=V,V=r),V===r&&(V=null),ue=[],le=P,Gt=sc(),Gt!==r?(gr=Nt(),le=Gt):(P=le,le=r),le!==r)for(;le!==r;)ue.push(le),le=P,Gt=sc(),Gt!==r?(gr=Nt(),le=Gt):(P=le,le=r);else ue=r;return ue!==r?(ot=D,D=si(J,V,ue)):(P=D,D=r),D}function ic(){var D,N,J,V,ue;return D=P,e.charCodeAt(P)===123?(N=i,P++):(N=r,te===0&&me(Nr)),N!==r?(J=$t(),J!==r?(e.charCodeAt(P)===125?(V=o,P++):(V=r,te===0&&me(Li)),V!==r?(ue=Hs(),ue!==r?(ot=D,D=Iu(J)):(P=D,D=r)):(P=D,D=r)):(P=D,D=r)):(P=D,D=r),D}function Th(){var D,N,J;return D=P,N=$t(),N!==r?(J=Hs(),J!==r?(ot=D,D=yn(N)):(P=D,D=r)):(P=D,D=r),D}function sc(){var D,N,J,V,ue,le,Gt,gr;return D=P,N=Ya(),N!==r?(J=Nt(),V=P,ue=bi(),ue!==r?(le=Nt(),V=ue):(P=V,V=r),V===r&&(V=null),e.charCodeAt(P)===61?(ue=l,P++):(ue=r,te===0&&me(Du)),ue!==r?(le=Nt(),Gt=ln(),Gt!==r?(gr=Hs(),gr!==r?(ot=D,D=tn(N,V,Gt)):(P=D,D=r)):(P=D,D=r)):(P=D,D=r)):(P=D,D=r),D}function ln(){var D,N,J,V,ue,le,Gt,gr;if(D=P,N=la(),N!==r){for(J=[],V=P,ue=Nt(),e.charCodeAt(P)===47?(le=h,P++):(le=r,te===0&&me(es)),le!==r?(Gt=Nt(),gr=la(),gr!==r?V=gr:(P=V,V=r)):(P=V,V=r);V!==r;)J.push(V),V=P,ue=Nt(),e.charCodeAt(P)===47?(le=h,P++):(le=r,te===0&&me(es)),le!==r?(Gt=Nt(),gr=la(),gr!==r?V=gr:(P=V,V=r)):(P=V,V=r);ot=D,D=Bu(N,J)}else P=D,D=r;return D}function la(){var D,N,J,V,ue;return D=P,N=fa(),N!==r?(J=P,V=Nt(),ue=$t(),ue!==r?J=ue:(P=J,J=r),J===r&&(J=null),ot=D,D=yi(N,J)):(P=D,D=r),D}function fa(){var D,N,J,V,ue,le;if(D=P,N=za(),N!==r){for(J=[],V=P,ue=Nt(),le=za(),le!==r?V=le:(P=V,V=r);V!==r;)J.push(V),V=P,ue=Nt(),le=za(),le!==r?V=le:(P=V,V=r);ot=D,D=oa(N,J)}else P=D,D=r;return D}function za(){var D,N,J,V;return D=P,N=gl(),N!==r?(J=ml(),J===r&&(J=null),V=uc(),V!==r?(ot=D,D=Fh(N,J,V)):(P=D,D=r)):(P=D,D=r),D===r&&(D=P,N=ml(),N!==r?(J=Nt(),V=uc(),V!==r?(ot=D,D=Dh(N,V)):(P=D,D=r)):(P=D,D=r),D===r&&(D=uc())),D}function gl(){var D,N;return D=P,e.charCodeAt(P)===64?(N=p,P++):(N=r,te===0&&me(yu)),N!==r&&(ot=D,N=Xt()),D=N,D}function ml(){var D,N,J,V;return D=P,N=Ya(),N!==r?(J=Nt(),e.charCodeAt(P)===58?(V=E,P++):(V=r,te===0&&me(ts)),V!==r?(ot=D,D=zt(N)):(P=D,D=r)):(P=D,D=r),D}function uc(){var D,N,J,V;return D=P,N=Oh(),N!==r?(J=Nt(),V=vl(),V!==r?(ot=D,D=yh(N,V)):(P=D,D=r)):(P=D,D=r),D===r&&(D=vl()),D}function Oh(){var D;return e.charCodeAt(P)===36?(D=d,P++):(D=r,te===0&&me(Ui)),D===r&&(e.charCodeAt(P)===38?(D=f,P++):(D=r,te===0&&me(Tt)),D===r&&(e.charCodeAt(P)===33?(D=w,P++):(D=r,te===0&&me(xn)))),D}function vl(){var D,N,J,V;return D=P,N=Ls(),N!==r?(J=Nt(),V=kh(),V!==r?(ot=D,D=Sh(N,V)):(P=D,D=r)):(P=D,D=r),D===r&&(D=Ls()),D}function kh(){var D;return e.charCodeAt(P)===63?(D=g,P++):(D=r,te===0&&me(Su)),D===r&&(e.charCodeAt(P)===42?(D=F,P++):(D=r,te===0&&me(bu)),D===r&&(e.charCodeAt(P)===43?(D=A,P++):(D=r,te===0&&me(_u)))),D}function Ls(){var D,N,J,V,ue,le;return D=Hh(),D===r&&(D=ce(),D===r&&(D=Za(),D===r&&(D=Nh(),D===r&&(D=xh(),D===r&&(D=P,e.charCodeAt(P)===40?(N=C,P++):(N=r,te===0&&me(rs)),N!==r?(J=Nt(),V=ln(),V!==r?(ue=Nt(),e.charCodeAt(P)===41?(le=S,P++):(le=r,te===0&&me(Zu)),le!==r?(ot=D,D=bh(V)):(P=D,D=r)):(P=D,D=r)):(P=D,D=r)))))),D}function Nh(){var D,N,J,V,ue,le,Gt,gr;return D=P,N=Ya(),N!==r?(J=P,te++,V=P,ue=Nt(),le=P,Gt=bi(),Gt!==r?(gr=Nt(),Gt=[Gt,gr],le=Gt):(P=le,le=r),le===r&&(le=null),e.charCodeAt(P)===61?(Gt=l,P++):(Gt=r,te===0&&me(Du)),Gt!==r?(ue=[ue,le,Gt],V=ue):(P=V,V=r),te--,V===r?J=void 0:(P=J,J=r),J!==r?(ot=D,D=_h(N)):(P=D,D=r)):(P=D,D=r),D}function xh(){var D,N,J,V;return D=P,N=ac(),N!==r?(J=Nt(),V=$t(),V!==r?(ot=D,D=Ih(N,V)):(P=D,D=r)):(P=D,D=r),D}function ac(){var D;return e.charCodeAt(P)===38?(D=f,P++):(D=r,te===0&&me(Tt)),D===r&&(e.charCodeAt(P)===33?(D=w,P++):(D=r,te===0&&me(xn))),D}function rn(){var D;return e.length>P?(D=e.charAt(P),P++):(D=r,te===0&&me(ns)),D}function oi(){var D,N;return te++,e.charCodeAt(P)===9?(D=I,P++):(D=r,te===0&&me(ks)),D===r&&(e.charCodeAt(P)===11?(D=_,P++):(D=r,te===0&&me(re)),D===r&&(e.charCodeAt(P)===12?(D=L,P++):(D=r,te===0&&me(fe)),D===r&&(e.charCodeAt(P)===32?(D=M,P++):(D=r,te===0&&me(je)),D===r&&(e.charCodeAt(P)===160?(D=b,P++):(D=r,te===0&&me(Ne)),D===r&&(e.charCodeAt(P)===65279?(D=B,P++):(D=r,te===0&&me(ze)),D===r&&(D=yl())))))),te--,D===r&&(N=r,te===0&&me(Qu)),D}function ci(){var D;return mt.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(at)),D}function Wa(){var D,N;return te++,e.charCodeAt(P)===10?(D=k,P++):(D=r,te===0&&me(Ar)),D===r&&(e.substr(P,2)===U?(D=U,P+=2):(D=r,te===0&&me(Lt)),D===r&&(e.charCodeAt(P)===13?(D=q,P++):(D=r,te===0&&me(Ln)),D===r&&(e.charCodeAt(P)===8232?(D=W,P++):(D=r,te===0&&me(Di)),D===r&&(e.charCodeAt(P)===8233?(D=K,P++):(D=r,te===0&&me(Jr)))))),te--,D===r&&(N=r,te===0&&me(ht)),D}function El(){var D,N;return te++,D=Lh(),D===r&&(D=qn()),te--,D===r&&(N=r,te===0&&me(cn)),D}function Lh(){var D,N,J,V,ue,le;if(D=P,e.substr(P,2)===z?(N=z,P+=2):(N=r,te===0&&me(hr)),N!==r){for(J=[],V=P,ue=P,te++,e.substr(P,2)===X?(le=X,P+=2):(le=r,te===0&&me(Zr)),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r);V!==r;)J.push(V),V=P,ue=P,te++,e.substr(P,2)===X?(le=X,P+=2):(le=r,te===0&&me(Zr)),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r);e.substr(P,2)===X?(V=X,P+=2):(V=r,te===0&&me(Zr)),V!==r?(N=[N,J,V],D=N):(P=D,D=r)}else P=D,D=r;return D}function Us(){var D,N,J,V,ue,le;if(D=P,e.substr(P,2)===z?(N=z,P+=2):(N=r,te===0&&me(hr)),N!==r){for(J=[],V=P,ue=P,te++,e.substr(P,2)===X?(le=X,P+=2):(le=r,te===0&&me(Zr)),le===r&&(le=ci()),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r);V!==r;)J.push(V),V=P,ue=P,te++,e.substr(P,2)===X?(le=X,P+=2):(le=r,te===0&&me(Zr)),le===r&&(le=ci()),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r);e.substr(P,2)===X?(V=X,P+=2):(V=r,te===0&&me(Zr)),V!==r?(N=[N,J,V],D=N):(P=D,D=r)}else P=D,D=r;return D}function qn(){var D,N,J,V,ue,le;if(D=P,e.substr(P,2)===se?(N=se,P+=2):(N=r,te===0&&me(Pr)),N!==r){for(J=[],V=P,ue=P,te++,le=ci(),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r);V!==r;)J.push(V),V=P,ue=P,te++,le=ci(),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r);N=[N,J],D=N}else P=D,D=r;return D}function Ya(){var D,N,J,V;if(te++,D=P,N=Al(),N!==r){for(J=[],V=wl();V!==r;)J.push(V),V=wl();ot=D,D=Bh(N,J)}else P=D,D=r;return te--,D===r&&(N=r,te===0&&me(ea)),D}function Al(){var D,N,J;return D=Uh(),D===r&&(e.charCodeAt(P)===36?(D=d,P++):(D=r,te===0&&me(Ui)),D===r&&(e.charCodeAt(P)===95?(D=Ie,P++):(D=r,te===0&&me(is)),D===r&&(D=P,e.charCodeAt(P)===92?(N=be,P++):(N=r,te===0&&me(wn)),N!==r?(J=Cl(),J!==r?D=J:(P=D,D=r)):(P=D,D=r)))),D}function wl(){var D;return D=Al(),D===r&&(D=jh(),D===r&&(D=Fl(),D===r&&(D=Dl(),D===r&&(e.charCodeAt(P)===8204?(D=Re,P++):(D=r,te===0&&me(Pt)),D===r&&(e.charCodeAt(P)===8205?(D=Je,P++):(D=r,te===0&&me(pr))))))),D}function Uh(){var D;return D=to(),D===r&&(D=eo(),D===r&&(D=Gh(),D===r&&(D=Vh(),D===r&&(D=Kh(),D===r&&(D=no()))))),D}function jh(){var D;return D=ro(),D===r&&(D=us()),D}function Hh(){var D,N,J;return te++,D=P,N=bi(),N!==r?(e.charCodeAt(P)===105?(J=ae,P++):(J=r,te===0&&me(rr)),J===r&&(J=null),ot=D,D=il(N,J)):(P=D,D=r),te--,D===r&&(N=r,te===0&&me(rt)),D}function bi(){var D,N,J,V;if(te++,D=P,e.charCodeAt(P)===34?(N=ye,P++):(N=r,te===0&&me(nr)),N!==r){for(J=[],V=ne();V!==r;)J.push(V),V=ne();e.charCodeAt(P)===34?(V=ye,P++):(V=r,te===0&&me(nr)),V!==r?(ot=D,D=$h(J)):(P=D,D=r)}else P=D,D=r;if(D===r)if(D=P,e.charCodeAt(P)===39?(N=He,P++):(N=r,te===0&&me(Ut)),N!==r){for(J=[],V=he();V!==r;)J.push(V),V=he();e.charCodeAt(P)===39?(V=He,P++):(V=r,te===0&&me(Ut)),V!==r?(ot=D,D=br(J)):(P=D,D=r)}else P=D,D=r;return te--,D===r&&(N=r,te===0&&me(xr)),D}function ne(){var D,N,J,V;return D=P,N=P,J=P,te++,e.charCodeAt(P)===34?(V=ye,P++):(V=r,te===0&&me(nr)),V===r&&(e.charCodeAt(P)===92?(V=be,P++):(V=r,te===0&&me(wn)),V===r&&(V=ci())),te--,V===r?J=void 0:(P=J,J=r),J!==r?(V=rn(),V!==r?(J=[J,V],N=J):(P=N,N=r)):(P=N,N=r),N!==r?D=e.substring(D,P):D=N,D===r&&(D=P,e.charCodeAt(P)===92?(N=be,P++):(N=r,te===0&&me(wn)),N!==r?(J=ar(),J!==r?D=J:(P=D,D=r)):(P=D,D=r),D===r&&(D=St())),D}function he(){var D,N,J,V;return D=P,N=P,J=P,te++,e.charCodeAt(P)===39?(V=He,P++):(V=r,te===0&&me(Ut)),V===r&&(e.charCodeAt(P)===92?(V=be,P++):(V=r,te===0&&me(wn)),V===r&&(V=ci())),te--,V===r?J=void 0:(P=J,J=r),J!==r?(V=rn(),V!==r?(J=[J,V],N=J):(P=N,N=r)):(P=N,N=r),N!==r?D=e.substring(D,P):D=N,D===r&&(D=P,e.charCodeAt(P)===92?(N=be,P++):(N=r,te===0&&me(wn)),N!==r?(J=ar(),J!==r?D=J:(P=D,D=r)):(P=D,D=r),D===r&&(D=St())),D}function ce(){var D,N,J,V,ue,le;if(te++,D=P,e.charCodeAt(P)===91?(N=Zt,P++):(N=r,te===0&&me(Un)),N!==r){for(e.charCodeAt(P)===94?(J=It,P++):(J=r,te===0&&me(jn)),J===r&&(J=null),V=[],ue=xe(),ue===r&&(ue=nt());ue!==r;)V.push(ue),ue=xe(),ue===r&&(ue=nt());e.charCodeAt(P)===93?(ue=Ct,P++):(ue=r,te===0&&me(Fn)),ue!==r?(e.charCodeAt(P)===105?(le=ae,P++):(le=r,te===0&&me(rr)),le===r&&(le=null),ot=D,D=Qo(J,V,le)):(P=D,D=r)}else P=D,D=r;return te--,D===r&&(N=r,te===0&&me(Cn)),D}function xe(){var D,N,J,V;return D=P,N=nt(),N!==r?(e.charCodeAt(P)===45?(J=lr,P++):(J=r,te===0&&me(Sr)),J!==r?(V=nt(),V!==r?(ot=D,D=Ns(N,V)):(P=D,D=r)):(P=D,D=r)):(P=D,D=r),D}function nt(){var D,N,J,V;return D=P,N=P,J=P,te++,e.charCodeAt(P)===93?(V=Ct,P++):(V=r,te===0&&me(Fn)),V===r&&(e.charCodeAt(P)===92?(V=be,P++):(V=r,te===0&&me(wn)),V===r&&(V=ci())),te--,V===r?J=void 0:(P=J,J=r),J!==r?(V=rn(),V!==r?(J=[J,V],N=J):(P=N,N=r)):(P=N,N=r),N!==r?D=e.substring(D,P):D=N,D===r&&(D=P,e.charCodeAt(P)===92?(N=be,P++):(N=r,te===0&&me(wn)),N!==r?(J=ar(),J!==r?D=J:(P=D,D=r)):(P=D,D=r),D===r&&(D=St())),D}function St(){var D,N,J;return D=P,e.charCodeAt(P)===92?(N=be,P++):(N=r,te===0&&me(wn)),N!==r?(J=Wa(),J!==r?(ot=D,D=sl()):(P=D,D=r)):(P=D,D=r),D}function ar(){var D,N,J,V;return D=Kt(),D===r&&(D=P,e.charCodeAt(P)===48?(N=er,P++):(N=r,te===0&&me(sr)),N!==r?(J=P,te++,V=js(),te--,V===r?J=void 0:(P=J,J=r),J!==r?(ot=D,D=ec()):(P=D,D=r)):(P=D,D=r),D===r&&(D=Ja(),D===r&&(D=Cl()))),D}function Kt(){var D;return D=Xa(),D===r&&(D=Mh()),D}function Xa(){var D,N;return e.charCodeAt(P)===39?(D=He,P++):(D=r,te===0&&me(Ut)),D===r&&(e.charCodeAt(P)===34?(D=ye,P++):(D=r,te===0&&me(nr)),D===r&&(e.charCodeAt(P)===92?(D=be,P++):(D=r,te===0&&me(wn)),D===r&&(D=P,e.charCodeAt(P)===98?(N=pt,P++):(N=r,te===0&&me(Zo)),N!==r&&(ot=D,N=Hn()),D=N,D===r&&(D=P,e.charCodeAt(P)===102?(N=Mt,P++):(N=r,te===0&&me(ta)),N!==r&&(ot=D,N=ul()),D=N,D===r&&(D=P,e.charCodeAt(P)===110?(N=st,P++):(N=r,te===0&&me(Lr)),N!==r&&(ot=D,N=al()),D=N,D===r&&(D=P,e.charCodeAt(P)===114?(N=We,P++):(N=r,te===0&&me(ra)),N!==r&&(ot=D,N=ol()),D=N,D===r&&(D=P,e.charCodeAt(P)===116?(N=tr,P++):(N=r,te===0&&me(qa)),N!==r&&(ot=D,N=cl()),D=N,D===r&&(D=P,e.charCodeAt(P)===118?(N=Ve,P++):(N=r,te===0&&me(Va)),N!==r&&(ot=D,N=ll()),D=N)))))))),D}function Mh(){var D,N,J,V;return D=P,N=P,J=P,te++,V=Vn(),V===r&&(V=ci()),te--,V===r?J=void 0:(P=J,J=r),J!==r?(V=rn(),V!==r?(J=[J,V],N=J):(P=N,N=r)):(P=N,N=r),N!==r?D=e.substring(D,P):D=N,D}function Vn(){var D;return D=Xa(),D===r&&(D=js(),D===r&&(e.charCodeAt(P)===120?(D=Rt,P++):(D=r,te===0&&me(na)),D===r&&(e.charCodeAt(P)===117?(D=zr,P++):(D=r,te===0&&me(ss))))),D}function Ja(){var D,N,J,V,ue,le;return D=P,e.charCodeAt(P)===120?(N=Rt,P++):(N=r,te===0&&me(na)),N!==r?(J=P,V=P,ue=ji(),ue!==r?(le=ji(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r),V!==r?J=e.substring(J,P):J=V,J!==r?(ot=D,D=fl(J)):(P=D,D=r)):(P=D,D=r),D}function Cl(){var D,N,J,V,ue,le,Gt,gr;return D=P,e.charCodeAt(P)===117?(N=zr,P++):(N=r,te===0&&me(ss)),N!==r?(J=P,V=P,ue=ji(),ue!==r?(le=ji(),le!==r?(Gt=ji(),Gt!==r?(gr=ji(),gr!==r?(ue=[ue,le,Gt,gr],V=ue):(P=V,V=r)):(P=V,V=r)):(P=V,V=r)):(P=V,V=r),V!==r?J=e.substring(J,P):J=V,J!==r?(ot=D,D=Sn(J)):(P=D,D=r)):(P=D,D=r),D}function js(){var D;return yr.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(ia)),D}function ji(){var D;return ii.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(Ka)),D}function Za(){var D,N;return D=P,e.charCodeAt(P)===46?(N=Yt,P++):(N=r,te===0&&me(sa)),N!==r&&(ot=D,N=Ph()),D=N,D}function $t(){var D,N,J,V;return te++,D=P,e.charCodeAt(P)===123?(N=i,P++):(N=r,te===0&&me(Nr)),N!==r?(J=qh(),e.charCodeAt(P)===125?(V=o,P++):(V=r,te===0&&me(Li)),V!==r?D=J:(P=D,D=r)):(P=D,D=r),te--,D===r&&(N=r,te===0&&me(aa)),D}function qh(){var D,N;return D=P,N=Qa(),ot=D,N=Mn(N),D=N,D}function Qa(){var D,N,J,V,ue,le;if(D=P,N=[],J=[],V=P,ue=P,te++,Wr.test(e.charAt(P))?(le=e.charAt(P),P++):(le=r,te===0&&me(Dn)),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r),V!==r)for(;V!==r;)J.push(V),V=P,ue=P,te++,Wr.test(e.charAt(P))?(le=e.charAt(P),P++):(le=r,te===0&&me(Dn)),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r);else J=r;for(J===r&&(J=P,e.charCodeAt(P)===123?(V=i,P++):(V=r,te===0&&me(Nr)),V!==r?(ue=Qa(),e.charCodeAt(P)===125?(le=o,P++):(le=r,te===0&&me(Li)),le!==r?(V=[V,ue,le],J=V):(P=J,J=r)):(P=J,J=r));J!==r;){if(N.push(J),J=[],V=P,ue=P,te++,Wr.test(e.charAt(P))?(le=e.charAt(P),P++):(le=r,te===0&&me(Dn)),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r),V!==r)for(;V!==r;)J.push(V),V=P,ue=P,te++,Wr.test(e.charAt(P))?(le=e.charAt(P),P++):(le=r,te===0&&me(Dn)),te--,le===r?ue=void 0:(P=ue,ue=r),ue!==r?(le=rn(),le!==r?(ue=[ue,le],V=ue):(P=V,V=r)):(P=V,V=r);else J=r;J===r&&(J=P,e.charCodeAt(P)===123?(V=i,P++):(V=r,te===0&&me(Nr)),V!==r?(ue=Qa(),e.charCodeAt(P)===125?(le=o,P++):(le=r,te===0&&me(Li)),le!==r?(V=[V,ue,le],J=V):(P=J,J=r)):(P=J,J=r))}return D=e.substring(D,P),D}function eo(){var D;return yt.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(R)),D}function Vh(){var D;return Me.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(O)),D}function Kh(){var D;return _e.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(H)),D}function Gh(){var D;return fr.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(Q)),D}function to(){var D;return Yr.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(ve)),D}function us(){var D;return ut.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(we)),D}function ro(){var D;return Os.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me($e)),D}function Fl(){var D;return Xr.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(ke)),D}function no(){var D;return ge.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(Vt)),D}function Dl(){var D;return Qi.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(dr)),D}function yl(){var D;return Bt.test(e.charAt(P))?(D=e.charAt(P),P++):(D=r,te===0&&me(Qr)),D}function Nt(){var D,N;for(D=[],N=oi(),N===r&&(N=Wa(),N===r&&(N=El()));N!==r;)D.push(N),N=oi(),N===r&&(N=Wa(),N===r&&(N=El()));return D}function Sl(){var D,N;for(D=[],N=oi(),N===r&&(N=Us());N!==r;)D.push(N),N=oi(),N===r&&(N=Us());return D}function Hs(){var D,N,J,V;return D=P,N=Nt(),e.charCodeAt(P)===59?(J=qt,P++):(J=r,te===0&&me(en)),J!==r?(N=[N,J],D=N):(P=D,D=r),D===r&&(D=P,N=Sl(),J=qn(),J===r&&(J=null),V=Wa(),V!==r?(N=[N,J,V],D=N):(P=D,D=r),D===r&&(D=P,N=Nt(),J=Ms(),J!==r?(N=[N,J],D=N):(P=D,D=r))),D}function Ms(){var D,N;return D=P,te++,e.length>P?(N=e.charAt(P),P++):(N=r,te===0&&me(ns)),te--,N===r?D=void 0:(P=D,D=r),D}let io=t.reservedWords||[];if(ai=u(),ai!==r&&P===e.length)return ai;throw ai!==r&&P{"use strict";var T7=ph(),O7=Bw(),k7=Pw(),N7=Nd(),x7=["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"],rl={VERSION:N7,RESERVED_WORDS:x7,GrammarError:T7,parser:k7,compiler:O7,generate(e,t){t=t!==void 0?t:{};function r(u){let i={};return Object.keys(u).forEach(o=>{i[o]=u[o].slice()}),i}let n="plugins"in t?t.plugins:[],s={parser:rl.parser,passes:r(rl.compiler.passes),reservedWords:rl.RESERVED_WORDS.slice()};return n.forEach(u=>{u.use(s,t)}),rl.compiler.compile(s.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:s.reservedWords}),s.passes,t)}};Rw.exports=rl});var r1=De((e1,t1)=>{(function(e,t){typeof e1=="object"&&typeof t1<"u"?t1.exports=t():typeof define=="function"&&define.amd?define(t):e.JSON5=t()})(e1,function(){"use strict";function e(re,fe){return fe={exports:{}},re(fe,fe.exports),fe.exports}var t=e(function(re){var fe=re.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=fe)}),r=e(function(re){var fe=re.exports={version:"2.6.5"};typeof __e=="number"&&(__e=fe)}),n=r.version,s=function(re){return typeof re=="object"?re!==null:typeof re=="function"},u=function(re){if(!s(re))throw TypeError(re+" is not an object!");return re},i=function(re){try{return!!re()}catch{return!0}},o=!i(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7}),l=t.document,h=s(l)&&s(l.createElement),p=function(re){return h?l.createElement(re):{}},E=!o&&!i(function(){return Object.defineProperty(p("div"),"a",{get:function(){return 7}}).a!=7}),d=function(re,fe){if(!s(re))return re;var je,Ne;if(fe&&typeof(je=re.toString)=="function"&&!s(Ne=je.call(re))||typeof(je=re.valueOf)=="function"&&!s(Ne=je.call(re))||!fe&&typeof(je=re.toString)=="function"&&!s(Ne=je.call(re)))return Ne;throw TypeError("Can't convert object to primitive value")},f=Object.defineProperty,w=o?Object.defineProperty:function(fe,je,Ne){if(u(fe),je=d(je,!0),u(Ne),E)try{return f(fe,je,Ne)}catch{}if("get"in Ne||"set"in Ne)throw TypeError("Accessors not supported!");return"value"in Ne&&(fe[je]=Ne.value),fe},g={f:w},F=function(re,fe){return{enumerable:!(re&1),configurable:!(re&2),writable:!(re&4),value:fe}},A=o?function(re,fe,je){return g.f(re,fe,F(1,je))}:function(re,fe,je){return re[fe]=je,re},C={}.hasOwnProperty,S=function(re,fe){return C.call(re,fe)},I=0,_=Math.random(),L=function(re){return"Symbol(".concat(re===void 0?"":re,")_",(++I+_).toString(36))},M=!1,b=e(function(re){var fe="__core-js_shared__",je=t[fe]||(t[fe]={});(re.exports=function(Ne,ze){return je[Ne]||(je[Ne]=ze!==void 0?ze:{})})("versions",[]).push({version:r.version,mode:M?"pure":"global",copyright:"\xA9 2019 Denis Pushkarev (zloirock.ru)"})}),B=b("native-function-to-string",Function.toString),k=e(function(re){var fe=L("src"),je="toString",Ne=(""+B).split(je);r.inspectSource=function(ze){return B.call(ze)},(re.exports=function(ze,at,ht,Ar){var Lt=typeof ht=="function";Lt&&(S(ht,"name")||A(ht,"name",at)),ze[at]!==ht&&(Lt&&(S(ht,fe)||A(ht,fe,ze[at]?""+ze[at]:Ne.join(String(at)))),ze===t?ze[at]=ht:Ar?ze[at]?ze[at]=ht:A(ze,at,ht):(delete ze[at],A(ze,at,ht)))})(Function.prototype,je,function(){return typeof this=="function"&&this[fe]||B.call(this)})}),U=function(re){if(typeof re!="function")throw TypeError(re+" is not a function!");return re},q=function(re,fe,je){if(U(re),fe===void 0)return re;switch(je){case 1:return function(Ne){return re.call(fe,Ne)};case 2:return function(Ne,ze){return re.call(fe,Ne,ze)};case 3:return function(Ne,ze,at){return re.call(fe,Ne,ze,at)}}return function(){return re.apply(fe,arguments)}},W="prototype",K=function(re,fe,je){var Ne=re&K.F,ze=re&K.G,at=re&K.S,ht=re&K.P,Ar=re&K.B,Lt=ze?t:at?t[fe]||(t[fe]={}):(t[fe]||{})[W],Ln=ze?r:r[fe]||(r[fe]={}),Di=Ln[W]||(Ln[W]={}),Jr,cn,hr,Zr;ze&&(je=fe);for(Jr in je)cn=!Ne&&Lt&&Lt[Jr]!==void 0,hr=(cn?Lt:je)[Jr],Zr=Ar&&cn?q(hr,t):ht&&typeof hr=="function"?q(Function.call,hr):hr,Lt&&k(Lt,Jr,hr,re&K.U),Ln[Jr]!=hr&&A(Ln,Jr,Zr),ht&&Di[Jr]!=hr&&(Di[Jr]=hr)};t.core=r,K.F=1,K.G=2,K.S=4,K.P=8,K.B=16,K.W=32,K.U=64,K.R=128;var z=K,X=Math.ceil,se=Math.floor,Ie=function(re){return isNaN(re=+re)?0:(re>0?se:X)(re)},be=function(re){if(re==null)throw TypeError("Can't call method on "+re);return re},Re=function(re){return function(fe,je){var Ne=String(be(fe)),ze=Ie(je),at=Ne.length,ht,Ar;return ze<0||ze>=at?re?"":void 0:(ht=Ne.charCodeAt(ze),ht<55296||ht>56319||ze+1===at||(Ar=Ne.charCodeAt(ze+1))<56320||Ar>57343?re?Ne.charAt(ze):ht:re?Ne.slice(ze,ze+2):(ht-55296<<10)+(Ar-56320)+65536)}},Je=Re(!1);z(z.P,"String",{codePointAt:function(fe){return Je(this,fe)}});var ae=r.String.codePointAt,ye=Math.max,He=Math.min,Zt=function(re,fe){return re=Ie(re),re<0?ye(re+fe,0):He(re,fe)},It=String.fromCharCode,Ct=String.fromCodePoint;z(z.S+z.F*(!!Ct&&Ct.length!=1),"String",{fromCodePoint:function(fe){for(var je=arguments,Ne=[],ze=arguments.length,at=0,ht;ze>at;){if(ht=+je[at++],Zt(ht,1114111)!==ht)throw RangeError(ht+" is not a valid code point");Ne.push(ht<65536?It(ht):It(((ht-=65536)>>10)+55296,ht%1024+56320))}return Ne.join("")}});var lr=r.String.fromCodePoint,er=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,pt=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,Mt=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,st={Space_Separator:er,ID_Start:pt,ID_Continue:Mt},We={isSpaceSeparator:function(fe){return typeof fe=="string"&&st.Space_Separator.test(fe)},isIdStartChar:function(fe){return typeof fe=="string"&&(fe>="a"&&fe<="z"||fe>="A"&&fe<="Z"||fe==="$"||fe==="_"||st.ID_Start.test(fe))},isIdContinueChar:function(fe){return typeof fe=="string"&&(fe>="a"&&fe<="z"||fe>="A"&&fe<="Z"||fe>="0"&&fe<="9"||fe==="$"||fe==="_"||fe==="\u200C"||fe==="\u200D"||st.ID_Continue.test(fe))},isDigit:function(fe){return typeof fe=="string"&&/[0-9]/.test(fe)},isHexDigit:function(fe){return typeof fe=="string"&&/[0-9A-Fa-f]/.test(fe)}},tr,Ve,Rt,zr,Yt,qt,mt,yr,ii,Wr=function(fe,je){tr=String(fe),Ve="start",Rt=[],zr=0,Yt=1,qt=0,mt=void 0,yr=void 0,ii=void 0;do mt=Os(),yu[Ve]();while(mt.type!=="eof");return typeof je=="function"?yt({"":ii},"",je):ii};function yt(re,fe,je){var Ne=re[fe];if(Ne!=null&&typeof Ne=="object")if(Array.isArray(Ne))for(var ze=0;ze0;){var je=Xr();if(!We.isHexDigit(je))throw Tt(ge());re+=ge()}return String.fromCodePoint(parseInt(re,16))}var yu={start:function(){if(mt.type==="eof")throw xn();ts()},beforePropertyName:function(){switch(mt.type){case"identifier":case"string":yr=mt.value,Ve="afterPropertyName";return;case"punctuator":Ui();return;case"eof":throw xn()}},afterPropertyName:function(){if(mt.type==="eof")throw xn();Ve="beforePropertyValue"},beforePropertyValue:function(){if(mt.type==="eof")throw xn();ts()},beforeArrayValue:function(){if(mt.type==="eof")throw xn();if(mt.type==="punctuator"&&mt.value==="]"){Ui();return}ts()},afterPropertyValue:function(){if(mt.type==="eof")throw xn();switch(mt.value){case",":Ve="beforePropertyName";return;case"}":Ui()}},afterArrayValue:function(){if(mt.type==="eof")throw xn();switch(mt.value){case",":Ve="beforeArrayValue";return;case"]":Ui()}},end:function(){}};function ts(){var re;switch(mt.type){case"punctuator":switch(mt.value){case"{":re={};break;case"[":re=[];break}break;case"null":case"boolean":case"numeric":case"string":re=mt.value;break}if(ii===void 0)ii=re;else{var fe=Rt[Rt.length-1];Array.isArray(fe)?fe.push(re):Object.defineProperty(fe,yr,{value:re,writable:!0,enumerable:!0,configurable:!0})}if(re!==null&&typeof re=="object")Rt.push(re),Array.isArray(re)?Ve="beforeArrayValue":Ve="beforePropertyName";else{var je=Rt[Rt.length-1];je==null?Ve="end":Array.isArray(je)?Ve="afterArrayValue":Ve="afterPropertyValue"}}function Ui(){Rt.pop();var re=Rt[Rt.length-1];re==null?Ve="end":Array.isArray(re)?Ve="afterArrayValue":Ve="afterPropertyValue"}function Tt(re){return rs(re===void 0?"JSON5: invalid end of input at "+Yt+":"+qt:"JSON5: invalid character '"+_u(re)+"' at "+Yt+":"+qt)}function xn(){return rs("JSON5: invalid end of input at "+Yt+":"+qt)}function Su(){return qt-=5,rs("JSON5: invalid identifier character at "+Yt+":"+qt)}function bu(re){console.warn("JSON5: '"+_u(re)+"' in strings is not valid ECMAScript; consider escaping")}function _u(re){var fe={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(fe[re])return fe[re];if(re<" "){var je=re.charCodeAt(0).toString(16);return"\\x"+("00"+je).substring(je.length)}return re}function rs(re){var fe=new SyntaxError(re);return fe.lineNumber=Yt,fe.columnNumber=qt,fe}var Zu=function(fe,je,Ne){var ze=[],at="",ht,Ar,Lt="",Ln;if(je!=null&&typeof je=="object"&&!Array.isArray(je)&&(Ne=je.space,Ln=je.quote,je=je.replacer),typeof je=="function")Ar=je;else if(Array.isArray(je)){ht=[];for(var Di=0,Jr=je;Di0&&(Ne=Math.min(10,Math.floor(Ne)),Lt=" ".substr(0,Ne)):typeof Ne=="string"&&(Lt=Ne.substr(0,10)),Zr("",{"":fe});function Zr(Pt,pr){var rt=pr[Pt];switch(rt!=null&&(typeof rt.toJSON5=="function"?rt=rt.toJSON5(Pt):typeof rt.toJSON=="function"&&(rt=rt.toJSON(Pt))),Ar&&(rt=Ar.call(pr,Pt,rt)),rt instanceof Number?rt=Number(rt):rt instanceof String?rt=String(rt):rt instanceof Boolean&&(rt=rt.valueOf()),rt){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof rt=="string")return Pr(rt,!1);if(typeof rt=="number")return String(rt);if(typeof rt=="object")return Array.isArray(rt)?wn(rt):ea(rt)}function Pr(Pt){for(var pr={"'":.1,'"':.2},rt={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},rr="",xr=0;xr=0)throw TypeError("Converting circular structure to JSON5");ze.push(Pt);var pr=at;at=at+Lt;for(var rt=ht||Object.keys(Pt),rr=[],xr=0,nr=rt;xr=0)throw TypeError("Converting circular structure to JSON5");ze.push(Pt);var pr=at;at=at+Lt;for(var rt=[],rr=0;rr{let t={};return e.forEach((r,n)=>t[r]=n),t})(Fc),Z3=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,sn=String.fromCharCode.bind(String),Qg=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),nm=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),im=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),sm=e=>{let t,r,n,s,u="",i=e.length%3;for(let o=0;o255||(n=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|s,u+=Fc[t>>18&63]+Fc[t>>12&63]+Fc[t>>6&63]+Fc[t&63]}return i?u.slice(0,i-3)+"===".substring(i):u},q0=typeof btoa=="function"?e=>btoa(e):go?e=>Buffer.from(e,"binary").toString("base64"):sm,H0=go?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,s=e.length;nt?nm(H0(e)):H0(e),Q3=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?sn(192|t>>>6)+sn(128|t&63):sn(224|t>>>12&15)+sn(128|t>>>6&63)+sn(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return sn(240|t>>>18&7)+sn(128|t>>>12&63)+sn(128|t>>>6&63)+sn(128|t&63)}},ey=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,um=e=>e.replace(ey,Q3),em=go?e=>Buffer.from(e,"utf8").toString("base64"):Zg?e=>H0(Zg.encode(e)):e=>q0(um(e)),po=(e,t=!1)=>t?nm(em(e)):em(e),tm=e=>po(e,!0),ty=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,ry=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 sn((r>>>10)+55296)+sn((r&1023)+56320);case 3:return sn((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return sn((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},am=e=>e.replace(ty,ry),om=e=>{if(e=e.replace(/\s+/g,""),!Z3.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,s;for(let u=0;u>16&255):s===64?sn(t>>16&255,t>>8&255):sn(t>>16&255,t>>8&255,t&255);return r},V0=typeof atob=="function"?e=>atob(im(e)):go?e=>Buffer.from(e,"base64").toString("binary"):om,cm=go?e=>Qg(Buffer.from(e,"base64")):e=>Qg(V0(e).split("").map(t=>t.charCodeAt(0))),lm=e=>cm(fm(e)),ny=go?e=>Buffer.from(e,"base64").toString("utf8"):Jg?e=>Jg.decode(cm(e)):e=>am(V0(e)),fm=e=>im(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),M0=e=>ny(fm(e)),iy=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)},hm=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),pm=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,hm(r));e("fromBase64",function(){return M0(this)}),e("toBase64",function(t){return po(this,t)}),e("toBase64URI",function(){return po(this,!0)}),e("toBase64URL",function(){return po(this,!0)}),e("toUint8Array",function(){return lm(this)})},dm=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,hm(r));e("toBase64",function(t){return ef(this,t)}),e("toBase64URI",function(){return ef(this,!0)}),e("toBase64URL",function(){return ef(this,!0)})},sy=()=>{pm(),dm()},Dt={version:rm,VERSION:X3,atob:V0,atobPolyfill:om,btoa:q0,btoaPolyfill:sm,fromBase64:M0,toBase64:po,encode:po,encodeURI:tm,encodeURL:tm,utob:um,btou:am,decode:M0,isValid:iy,fromUint8Array:ef,toUint8Array:lm,extendString:pm,extendUint8Array:dm,extendBuiltins:sy};var xu=typeof $task<"u",Qs=typeof $loon<"u",Lu=typeof $httpClient<"u"&&!Qs,ls=eval('typeof process !== "undefined"'),gm=typeof $environment<"u"&&$environment["stash-version"],mm=typeof $rocket<"u",uy=typeof egern=="object",ay=typeof $native<"u",Uu=typeof $Plugins<"u";function tf(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}function oy(e){let[t,r,n,s,u,i,o]=e.match(/^socks5:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(u)u=parseInt(u,10);else throw $.error(`port is not present in line: ${e}`),new Error(`port is not present in line: ${e}`);return{type:5,host:s,port:u,userId:r!=null?decodeURIComponent(r):void 0,password:n!=null?decodeURIComponent(n):void 0}}var rf=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=Ki(),this.env=di(),ls){let dotenv=eval('require("dotenv")');dotenv.config()}this.node=(()=>{if(ls){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(xu&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(Qs||Lu)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),Uu&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),ls){let basePath=eval("process.env.SUB_STORE_DATA_BASE_PATH")||".",rootPath=`${basePath}/root.json`,backupRootPath=`${basePath}/root_${Date.now()}.json`;if(this.log(`Root path: ${rootPath}`),this.node.fs.existsSync(rootPath))try{this.root=JSON.parse(this.node.fs.readFileSync(`${rootPath}`))}catch(e){this.node.fs.copyFileSync(rootPath,backupRootPath),this.error(`Failed to parse ${rootPath}: ${e.message}. Backup created at ${backupRootPath}`)}tf(this.root)||(this.node.fs.writeFileSync(rootPath,JSON.stringify({}),{flag:"w"}),this.root={});let fpath=`${basePath}/${this.name}.json`,backupPath=`${basePath}/${this.name}_${Date.now()}.json`;if(this.log(`Data path: ${fpath}`),this.node.fs.existsSync(fpath))try{if(this.cache=JSON.parse(this.node.fs.readFileSync(`${fpath}`,"utf-8")),!tf(this.cache))throw new Error("Invalid Data")}catch{try{let t=Dt.decode(this.node.fs.readFileSync(`${fpath}`,"utf-8"));if(this.cache=JSON.parse(t),this.node.fs.writeFileSync(fpath,t,{flag:"w"}),!tf(this.cache))throw new Error("Invalid Data")}catch(t){this.node.fs.copyFileSync(fpath,backupPath),this.error(`Failed to parse ${fpath}: ${t.message}. Backup created at ${backupPath}`)}}tf(this.cache)||(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"w"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(xu&&$prefs.setValueForKey(data,this.name),(Qs||Lu)&&$persistentStore.write(data,this.name),Uu&&$Plugins.SubStoreCache.set(this.name,data),ls){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),Lu||Qs)return $persistentStore.write(e,t);if(xu)return $prefs.setValueForKey(e,t);if(ls&&(this.root[t]=e),Uu)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),Lu||Qs)return $persistentStore.read(e);if(xu)return $prefs.valueForKey(e);if(ls)return this.root[e];if(Uu)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),Lu||Qs)return $persistentStore.write(null,e);if(xu)return $prefs.removeValueForKey(e);if(ls&&delete this.root[e],Uu)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(xu&&$notify(title,subtitle,content,options),Lu&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),Qs){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(ls){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)if(/^https?:\/\//.test(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(` `)));Ki().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}`)})}else{let{execFile}=eval('require("child_process")');execFile("shoutrrr",["send","--url",push,"--message",`${title} ${subtitle} ${content_}`],(e,t,r)=>{if(e){console.log(`[Push Service] URL: ${push} ERROR: ${e}`);return}r&&console.log(`[Push Service] URL: ${push} stderr: ${r}`),console.log(`[Push Service] URL: ${push} stdout: ${t}`)})}}Uu&&$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={}){xu||Qs||Lu||Uu?$done(e):ls&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function di(){return{isQX:xu,isLoon:Qs,isSurge:Lu,isNode:ls,isStash:gm,isShadowRocket:mm,isEgern:uy,isLanceX:ay,isGUIforCores:Uu}}function Ki(defaultOptions={baseURL:""}){let{isQX,isLoon,isSurge,isNode,isGUIforCores}=di(),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||gm||mm)&&(opts.timeout=Math.ceil(opts.timeout/1e3),e="s")}if(isNode){let undici=eval("require('undici')"),{socksDispatcher}=eval("require('fetch-socks')"),{ProxyAgent,EnvHttpProxyAgent,request,interceptors}=undici,agentOpts={connect:{rejectUnauthorized:!(opts.strictSSL===!1||opts.insecure===!0||opts.rejectUnauthorized===!1)},bodyTimeout:opts.timeout,headersTimeout:opts.timeout,maxHeaderSize:eval("process.env.SUB_STORE_MAX_HEADER_SIZE")||32*1024},tlsOptions={rejectUnauthorized:agentOpts.connect.rejectUnauthorized};opts.tls={...opts.tls||{},...tlsOptions};try{let url=new URL(opts.url);(url.username||url.password)&&(opts.headers={...opts.headers||{},Authorization:`Basic ${Buffer.from(`${url.username||""}:${url.password||""}`).toString("base64")}`});let dispatcher;if(!opts.proxy){let allProxy=eval("process.env.all_proxy")||eval("process.env.ALL_PROXY");allProxy&&/^socks5:\/\//.test(allProxy)&&(opts.proxy=allProxy)}opts.proxy?/^socks5:\/\//.test(opts.proxy)?dispatcher=socksDispatcher(oy(opts.proxy),{...agentOpts,requestTls:tlsOptions}):dispatcher=new ProxyAgent({...agentOpts,uri:opts.proxy,requestTls:tlsOptions}):dispatcher=new EnvHttpProxyAgent({...agentOpts,requestTls:tlsOptions});let response=await request(opts.url,{...opts,method:method.toUpperCase(),dispatcher:dispatcher.compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirects:!0}))});resolve({statusCode:response.statusCode,headers:response.headers,body:opts.encoding===null?await response.body.arrayBuffer():await response.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,autoTransformBody:!1,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 cy=new rf("sub-store"),G=cy;function K0(){ly()}function ly(){let e=G.read(U0);e||fy(),e!=="2.0"&&G.write("2.0",U0)}function fy(){G.info("Start migrating...");let e=G.read(Ri)||{},t=Object.values(e).map(w=>(w.source=w.source||"remote",d(w),f(w),w));G.write(t,Ri);let r=G.read(Nu)||{},n=Object.values(r).map(w=>(delete w.ua,d(w),f(w),w));G.write(n,Nu);let s=G.read(Vi)||{},u=Object.values(s);G.write(u,Vi);let i=G.read(Cc)||{},o=Object.values(i);G.write(o,Cc);let l=G.read(Zs)||{},h=Object.values(l);G.write(h,Zs);let p=G.read(j0)||{},E=Object.values(p);G.write(E,j0),delete G.cache.builtin,G.info("Migration complete!");function d(w){let g=w["display-name"];g&&(w.displayName=g,delete w["display-name"])}function f(w){let g=w.process;if(!g||g.length===0)return;let F=[],A={type:"Quick Setting Operator",args:{udp:"DEFAULT",tfo:"DEFAULT",scert:"DEFAULT","vmess aead":"DEFAULT",useless:"DEFAULT"}};for(let C of g)if(C.type){if(C.type==="Useless Filter")A.args.useless="ENABLED";else if(C.type==="Set Property Operator"){let{key:S,value:I}=C.args;switch(S){case"udp":A.args.udp=I?"ENABLED":"DISABLED";break;case"tfo":A.args.tfo=I?"ENABLED":"DISABLED";break;case"skip-cert-verify":A.args.scert=I?"ENABLED":"DISABLED";break;case"aead":A.args["vmess aead"]=I?"ENABLED":"DISABLED";break}}else if(C.type.indexOf("Keyword")===-1)if(C.type==="Flag Operator"){let S=typeof C.args>"u"?!0:C.args;C.args={mode:S?"add":"remove"},F.push(C)}else F.push(C)}F.unshift(A),w.process=F}}function G0({substore:$,port,host}){let{isNode}=di(),DEFAULT_HEADERS={"Content-Type":"text/plain;charset=UTF-8","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST,GET,OPTIONS,PATCH,PUT,DELETE","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept","X-Powered-By":isNode&&eval("process.env.SUB_STORE_X_POWERED_BY")||"Sub-Store"};if(isNode){let express_=eval('require("express")'),bodyParser=eval('require("body-parser")'),app=express_(),limit=eval("process.env.SUB_STORE_BODY_JSON_LIMIT")||"1mb";return $.info(`[BACKEND] body JSON limit: ${limit}`),app.use(bodyParser.json({verify:rawBodySaver,limit})),app.use(bodyParser.urlencoded({verify:rawBodySaver,extended:!0})),app.use(bodyParser.raw({verify:rawBodySaver,type:"*/*"})),app.use((e,t,r)=>{t.set(DEFAULT_HEADERS),r()}),app.start=()=>{app.get("*",function(t,r){r.status(404).end()});let e=app.listen(port,host,()=>{let{address:t,port:r}=e.address();$.info(`[BACKEND] listening on ${t}:${r}`)})},app}let handlers=[],METHODS_NAMES=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD'","ALL"],dispatch=(e,t=0)=>{let{method:r,url:n,headers:s,body:u}=e;s=hy(s),/json/i.test(s["content-type"])&&(u=JSON.parse(u)),r=r.toUpperCase();let{path:i,query:o}=dy(n),l=null,h,p=0;for(h=t;hp&&(l=handlers[h],p=E.split("/").length)}if(l){let E=()=>{dispatch(r,n,h)},d={method:r,url:n,path:i,query:o,params:vm(l.pattern,i),headers:s,body:u},f=Response(),w=l.callback,g=F=>{f.status(500).json({status:"failed",message:`Internal Server Error: ${F}`})};if(w.constructor.name==="AsyncFunction")w(d,f,E).catch(g);else try{w(d,f,E)}catch(F){g(F)}}else Response().status(404).json({status:"failed",message:"ERROR: 404 not found"})},app={};return METHODS_NAMES.forEach(e=>{app[e.toLowerCase()]=(t,r)=>{handlers.push({method:e,pattern:t,callback:r})}}),app.route=e=>{let t={};return METHODS_NAMES.forEach(r=>{t[r.toLowerCase()]=n=>(handlers.push({method:r,pattern:e,callback:n}),t)}),t},app.start=()=>{dispatch($request)},app;function rawBodySaver(e,t,r,n){r&&r.length&&(e.rawBody=r.toString(n||"utf8"))}function Response(){let e=200,{isQX:t,isLoon:r,isSurge:n,isGUIforCores:s}=di(),u=DEFAULT_HEADERS,i={200:"HTTP/1.1 200 OK",201:"HTTP/1.1 201 Created",302:"HTTP/1.1 302 Found",307:"HTTP/1.1 307 Temporary Redirect",308:"HTTP/1.1 308 Permanent Redirect",404:"HTTP/1.1 404 Not Found",500:"HTTP/1.1 500 Internal Server Error"};return new class{status(o){return e=o,this}send(o=""){let l={status:t?i[e]:e,body:o,headers:u};t||s?$done(l):(r||n)&&$done({response:l})}end(){this.send()}html(o){this.set("Content-Type","text/html;charset=UTF-8"),this.send(o)}json(o){this.set("Content-Type","application/json;charset=UTF-8"),this.send(JSON.stringify(o))}set(o,l){return u[o]=l,this}removeHeader(o){return delete u[o],this}}}}function hy(e){let t={};for(let r of Object.keys(e))t[r.toLowerCase()]=e[r];return t}function py(e,t){if(e instanceof RegExp&&e.test(t))return!0;if(e==="/")return!0;if(e.indexOf(":")===-1){let r=t.split("/"),n=e.split("/");for(let s=0;s=9860||r==="Surge"&&s>=3613)return!0}catch{}return!1}var Ch=jr(hf());var Ip=jr(Rv());function h8(e){let t=Ip.default.pemtohex(e);return Ip.default.KJUR.crypto.Util.hashHex(t,"sha256").match(/.{2}/g).join(":").toUpperCase()}var Tv={generateFingerprint:h8};var Nc=jr(SE());function _E(e,t,...r){try{return e(t,...r)}catch{return e(IE(e(t.replace(/!\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function kc(e,...t){return _E(Nc.default.safeLoad,JSON.parse(JSON.stringify(e)),...t)}function qI(e,...t){return _E(Nc.default.load,JSON.parse(JSON.stringify(e)),...t)}function bE(e,...t){return Nc.default.safeDump(JSON.parse(JSON.stringify(e)),...t)}function IE(e,...t){return Nc.default.dump(JSON.parse(JSON.stringify(e)),...t)}var ms={safeLoad:kc,load:qI,safeDump:bE,dump:IE,parse:kc,stringify:bE};var Hp=0;function zi(e){return KI(VI(GI(e)))}function VI(e){return WI(YI(zI(e),e.length*8))}function KI(e){try{}catch{Hp=0}for(var t=Hp?"0123456789ABCDEF":"0123456789abcdef",r="",n,s=0;s>>4&15)+t.charAt(n&15);return r}function GI(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 zI(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function YI(e,t){e[t>>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,n=-271733879,s=-1732584194,u=271733878,i=0;i>16)+(t>>16)+(r>>16);return n<<16|r&65535}function XI(e,t){return e<>>32-t}var Gf=jr(HE()),F9=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,D9=/^(([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 Br(e){return F9.test(e)}function Fr(e){return D9.test(e)}function ME(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 Cs(e){return typeof e=="string"&&e.trim().length>0}function Jt(e,t){return Cs(e)?e:t}function Lo(e){return typeof e<"u"&&e!==null}function Gu(e,t){return Lo(e)?e:t}function au(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function y9(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function Uc(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,s]=r.split("-").map(Number);return y9(n,s)}else return Number(r)}function qE(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function zf(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)}function VE(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}var ed=class{constructor(){G.read(wa)||G.write("{}",wa);try{this.resourceCache=JSON.parse(G.read(wa))}catch(t){G.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${wa} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},G.write("{}",wa)}this._cleanup()}_cleanup(t,r){let n=Qp(r)??0,s=!1,u=Date.now();Object.entries(this.resourceCache).forEach(i=>{let[o,l]=i;(!l.time||l.time0?t:null}function b9(){let t=G.read(Hr)?.resourceCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:36e5}var Kr=new ed;var rd=class{constructor(){G.read(Ca)||G.write("{}",Ca);try{this.resourceCache=JSON.parse(G.read(Ca))}catch(t){G.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Ca} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},G.write("{}",Ca)}this._cleanup()}_cleanup(t,r){let n=td(r)??0,s=!1,u=Date.now();Object.entries(this.resourceCache).forEach(i=>{let[o,l]=i;(!l.time||l.time0?t:null}function I9(){let t=G.read(Hr)?.headersCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:6e4}var jc=new rd;function Na(e){let t=Object.keys(e),r="",n="",s="";for(let u of t){let i=u.toLowerCase();i==="subscription-userinfo"?r=e[u]:i==="profile-web-page-url"?n=e[u]:i==="plan-name"&&(s=e[u])}return`${r||""}${n?`; app_url=${encodeURIComponent(n)}`:""}${s?`; plan_name=${encodeURIComponent(s)}`:""}`}async function Fs(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||!/^https?/.test(url))return;let{isStash,isLoon,isShadowRocket,isQX}=di(),insecure=$arguments?.insecure?G.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=G.read(Hr),proxy=customProxy||defaultProxy;G.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultFlowUserAgent||"clash.meta/v1.19.16",requestTimeout=timeout||defaultTimeout||8e3,id=zi(userAgent+url),cached=jc.get(id),flowInfo;if(!$arguments?.noCache&&cached)G.info(`\u4F7F\u7528\u7F13\u5B58\u7684\u6D41\u91CF\u4FE1\u606F: ${url}, ${userAgent}`),flowInfo=cached;else{let e=Ki();if(flowUrl){let t;try{G.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{headers:r,body:n,statusCode:s}=await e.get({url:flowUrl,headers:{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?au(proxy):{},...insecure||{}});if(s<200||s>=400)throw new Error(`statusCode: ${s}`);t=r;let u=Uo(n);if(Number.isFinite(u?.total)&&Number.isFinite(u?.usage?.download)&&Number.isFinite(u?.usage?.upload))flowInfo=n;else throw new Error("\u54CD\u5E94\u4F53\u4E2D\u672A\u5305\u542B\u5408\u6CD5\u7684\u6D41\u91CF\u4FE1\u606F")}catch(r){if(G.error(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${flowUrl}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${r.message??r}`),t)try{let n=Na(t),s=Uo(n);if(Number.isFinite(s?.total)&&Number.isFinite(s?.usage?.download)&&Number.isFinite(s?.usage?.upload))G.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u6210\u529F: ${flowUrl}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`),flowInfo=n;else throw new Error("\u54CD\u5E94\u4F53\u4E2D\u672A\u5305\u542B\u5408\u6CD5\u7684\u6D41\u91CF\u4FE1\u606F")}catch(n){G.error(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${flowUrl}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${n.message??n}`)}}}else{try{G.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?au(proxy):{},...insecure||{}});flowInfo=Na(t)}catch(t){G.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){G.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?au(proxy):{},...insecure||{}});flowInfo=Na(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&jc.set(id,flowInfo)}return flowInfo}function Uo(e){if(!e)return;let t=e.match(/upload=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),r=t==null?0:Number(t[1]+t[2]),n=e.match(/download=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),s=Number(n[1]+n[2]),u=e.match(/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),i=Number(u[1]+u[2]),o=e.match(/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),l=o?Number(o[1]+o[2]):void 0,h=e.match(/reset_day=([0-9]+)/),p=h?Number(h[1]):void 0,E=e.match(/app_url=(.*?)\s*?(;|$)/),d=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:p,appUrl:d,planName:w}}function Hc(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:(Math.round(e*100)/100).toString(),unit:t}:Hc(e/1024,r[++n])}function Wf(e){if(!e)throw new Error("\u6CA1\u6709\u6D41\u91CF\u4FE1\u606F");if(e?.expires&&e.expires*1e3u.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,u=s.getDate(),i=s.getMonth(),o=s.getFullYear(),l;return t>u?l=0:l=new Date(o,i+1,0).getDate(),l-u+t}}catch(t){G.error(`getRmainingDays failed: ${t.message??t}`)}}function jo(e,t){try{let r=new Map;e.split(";").map(u=>u.trim()).filter(Boolean).forEach(u=>{let i=u.indexOf("=");if(i===-1)return;let o=u.slice(0,i).trim(),l=u.slice(i+1).trim();if(!r.has(o))try{let h=decodeURIComponent(l);if(["upload","download","total","expire","reset_day"].includes(o))try{h=Number(h),["expire","reset_day"].includes(o)&&(h<=0||!Number.isFinite(h))?h="":["upload","download","total"].includes(o)&&!Number.isFinite(h)?h=0:h=h.toFixed(0)}catch(p){G.error(`Failed to convert value for key "${o}=${l}": ${p.message??p}`)}r.set(o,h)}catch{r.set(o,l)}});let n={},s={"subscription-userinfo":"","profile-web-page-url":"","plan-name":""};return r.forEach((u,i)=>{t&&i==="app_url"?s["profile-web-page-url"]=u:t&&i==="plan_name"?s["plan-name"]=u:n[i]=u}),Object.keys(n).length>0&&(s["subscription-userinfo"]=Object.entries(n).map(([u,i])=>`${u}=${encodeURIComponent(i)}`).join("; ")),t?s:s["subscription-userinfo"]}catch(r){return G.error(`normalizeFlowHeader failed: ${r.message??r}`),t?{"subscription-userinfo":e}:e}}function Dr(e,t,r="name"){return e.find(n=>n[r]===t)}function Ds(e,t,r){e.status(r||200).json({status:"success",data:t})}function un(e,t,r){e.status(r||500).json({status:"failed",error:{code:t.code,type:t.type,message:t.message,details:e.req?.route?.path?.startsWith("/share/")?"\u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7":t.details}})}var Mc=class{constructor(t,r,n){this.code=t,this.message=r,this.details=n}},mi=class extends Mc{constructor(t,r,n){super(t,r,n),this.type="InternalServerError"}};var ou=class extends Mc{constructor(t,r,n){super(t,r,n),this.type="ResourceNotFoundError"}},Yf=class extends Mc{constructor(t,r,n){super(t,r,n),this.type="NetworkError"}};function B9(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function $9(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var GE=[B9(),$9()];function P9(){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 zE(){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 R9(){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))),zE().func(r))}}function T9(){return{type:"ALL",func:r=>{let n={"DEST-PORT":"DST-PORT","SRC-IP":"SRC-IP-CIDR","IN-PORT":"SRC-PORT"},s={payload:r.map(u=>{let i=`${n[u.type]||u.type},${u.content}`;return["IP-CIDR","IP-CIDR6","GEOIP"].includes(u.type)&&(u.options&&(u.options=u.options.filter(o=>["no-resolve"].includes(o))),i+=u.options?.length>0?`,${u.options.join(",")}`:""),i})};return ms.dump(s)}}}var WE={QX:P9(),Surge:zE(),Loon:R9(),Clash:T9()};var O9=[[/^(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 k9(){return{name:"Universal Rule Parser",test:()=>!0,parse:n=>{let s=n.split(` `),u=[];for(let i of s)if(i=i.trim(),i.length!==0&&!/\s*#/.test(i))try{let o=i.split(",").map(p=>p.trim()),l=o[0],h=!1;for(let p of O9)if(p[0].test(l)){h=!0;let d={type:p[1],content:o[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(d.type)&&(d.options=o.slice(2)),u.push(d)}if(!h)throw new Error("Invalid rule type: "+l)}catch(o){console.log(`Failed to parse line: ${i} Reason: ${o}`)}return u}}}var YE=[k9()];var Xf=function(){function e(n){for(let s of GE)try{if(s.test(n))return G.info(`Pre-processor [${s.name}] activated`),s.parse(n)}catch(u){G.error(`Parser [${s.name}] failed Reason: ${u}`)}return n}function t(n){n=e(n);for(let s of YE){let u;try{u=s.test(n)}catch{u=!1}if(u)return G.info(`Rule parser [${s.name}] is activated!`),s.parse(n)}}function r(n,s){let u=WE[s];if(!u)throw new Error(`Target platform: ${s} is not supported!`);if(typeof u.type>"u"||u.type==="SINGLE")return n.map(i=>{try{return u.func(i)}catch(o){return console.log(`ERROR: cannot produce rule: ${JSON.stringify(i)} Reason: ${o}`),""}}).filter(i=>i.length>0).join(` `);if(u.type==="ALL")return u.func(n)}return{parse:t,produce:r}}();var xa=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=di(),{defaultProxy,defaultTimeout:timeout,githubProxy}=G.read(Hr),proxy=defaultProxy;G.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=Ki({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?au(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=Ki({baseURL:`${githubProxy?`${githubProxy}/`:""}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?au(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);G.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((u,i)=>(u[i.path]=i,u),{}));let n=[],s={...t.files};return Object.keys(r).map(u=>{s[u]?r[u].content==null||r[u].content===""?(delete s[u],n.push({action:"delete",file_path:u})):(s[u]=r[u],n.push({action:"update",file_path:u,content:r[u].content})):r[u].content==null||r[u].content===""?(delete s[u],delete r[u]):(s[u]=r[u],n.push({action:"create",file_path:u,content:r[u].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,u])=>(u.content!==null&&u.content!==""&&(n[s]=u),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 nd(e){let{gistToken:t,syncPlatform:r}=G.read(Hr);if(!t)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let s=await new xa({token:t,key:Wg,syncPlatform:r}).upload(e),u={};try{u=JSON.parse(s.body)}catch{}let i=u?.html_url??u?.web_url,o=G.read(Hr);return i?(G.log(`\u540C\u6B65 Gist \u540E, \u627E\u5230 Sub-Store Gist: ${i}`),o.artifactStore=i,o.artifactStoreStatus="VALID"):(G.error("\u540C\u6B65 Gist \u540E, \u627E\u4E0D\u5230 Sub-Store Gist"),o.artifactStoreStatus="NOT FOUND"),G.write(o,Hr),s}function sd(e){G.read(Vi)||G.write({},Vi),e.get("/api/sync/artifacts",x9),e.get("/api/sync/artifact/:name",L9)}async function ei({type:e,name:t,platform:r,url:n,ua:s,content:u,mergeSources:i,ignoreFailedRemoteSub:o,ignoreFailedRemoteFile:l,produceType:h,produceOpts:p={},subscription:E,awaitCustomCache:d,$options:f,proxy:w,noCache:g,all:F}){if(r=r||"JSON",["subscription","sub"].includes(e)){let A;if(t){let _=G.read(Ri);if(A=Dr(_,t),!A)throw new Error(`\u627E\u4E0D\u5230\u8BA2\u9605 ${t}`)}else if(E)A=E;else throw new Error("\u672A\u63D0\u4F9B\u8BA2\u9605\u540D\u79F0\u6216\u8BA2\u9605\u6570\u636E");let C;if(u&&!["localFirst","remoteFirst"].includes(i))C=u;else if(n){let _={};C=await Promise.all(n.split(/[\r\n]+/).map(M=>M.trim()).filter(M=>M.length).map(async M=>{try{return await an(M,s||A.ua,void 0,w||A.proxy,void 0,d,g||A.noCache,!0)}catch(b){return _[M]=b,G.error(`\u8BA2\u9605 ${A.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${M} \u53D1\u751F\u9519\u8BEF: ${b}`),""}}));let L=A.ignoreFailedRemoteSub;if(o!=null&&o!==""&&(L=o),Object.keys(_).length>0)if(L)L==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${A.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(_).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${A.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(_).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);i==="localFirst"?C.unshift(u):i==="remoteFirst"&&C.push(u)}else if(A.source==="local"&&!["localFirst","remoteFirst"].includes(A.mergeSources))C=A.content;else{let _={};C=await Promise.all(A.url.split(/[\r\n]+/).map(M=>M.trim()).filter(M=>M.length).map(async M=>{try{return await an(M,s||A.ua,void 0,w||A.proxy,void 0,d,g||A.noCache,!0)}catch(b){return _[M]=b,G.error(`\u8BA2\u9605 ${A.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${M} \u53D1\u751F\u9519\u8BEF: ${b}`),""}}));let L=A.ignoreFailedRemoteSub;if(o!=null&&o!==""&&(L=o),Object.keys(_).length>0)if(L)L==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${A.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(_).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${A.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(_).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);A.mergeSources==="localFirst"?C.unshift(A.content):A.mergeSources==="remoteFirst"&&C.push(A.content)}if(h==="raw")return JSON.stringify((Array.isArray(C)?C:[C]).flat());let S=(Array.isArray(C)?C:[C]).map(_=>kt.parse(_)).flat();if(S.forEach(_=>{_._subName=A.name,_._subDisplayName=A.displayName}),S=await kt.process(S,A.process||[],r,{[A.name]:A},f),S.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let I={};for(let _ of S){if(I[_.name]){G.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${_.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 kt.produce(S,r,h,p)}else if(["collection","col"].includes(e)){let A=G.read(Ri),C=G.read(Nu),S=Dr(C,t);if(!S)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let I=[...S.subscriptions],_=S.subscriptionTags;Array.isArray(_)&&_.length>0&&A.forEach(q=>{Array.isArray(q.tag)&&q.tag.length>0&&!I.includes(q.name)&&q.tag.some(W=>_.includes(W))&&I.push(q.name)});let L={},M={},b=0;await Promise.all(I.map(async q=>{let W=Dr(A,q),K=W.passThroughUA,z=W.ua;K&&(G.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${s}`),z=s);try{G.info(`\u6B63\u5728\u5904\u7406\u5B50\u8BA2\u9605\uFF1A${W.name}...`);let X;if(W.source==="local"&&!["localFirst","remoteFirst"].includes(W.mergeSources))X=W.content;else{let Ie={};if(X=await await Promise.all(W.url.split(/[\r\n]+/).map(be=>be.trim()).filter(be=>be.length).map(async be=>{try{return await an(be,z,void 0,w||W.proxy||S.proxy,void 0,void 0,g||W.noCache,!0)}catch(Re){return Ie[be]=Re,G.error(`\u8BA2\u9605 ${W.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${be} \u53D1\u751F\u9519\u8BEF: ${Re}`),""}})),Object.keys(Ie).length>0)if(W.ignoreFailedRemoteSub)W.ignoreFailedRemoteSub==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${W.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(Ie).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${W.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(Ie).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);W.mergeSources==="localFirst"?X.unshift(W.content):W.mergeSources==="remoteFirst"&&X.push(W.content)}let se=(Array.isArray(X)?X:[X]).map(Ie=>kt.parse(Ie)).flat();se.forEach(Ie=>{Ie._subName=W.name,Ie._subDisplayName=W.displayName,Ie._collectionName=S.name,Ie._collectionDisplayName=S.displayName}),se=await kt.process(se,W.process||[],r,{[W.name]:W,_collection:S,$options:f}),L[q]=se,b++,G.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${W.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(b/I.length).toFixed(1)}% `)}catch(X){b++,M[q]=X,G.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u4E2D\u7684\u5B50\u8BA2\u9605: ${W.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${X}\uFF01\u8FDB\u5EA6--${100*(b/I.length).toFixed(1)}%`)}}));let B=S.ignoreFailedRemoteSub;if(o!=null&&o!==""&&(B=o),Object.keys(M).length>0)if(B)B==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${S.name}`,`\u5B50\u8BA2\u9605 ${Object.keys(M).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${S.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(M).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let k=Array.prototype.concat.apply([],I.map(q=>L[q]||[]));if(k.forEach(q=>{q._collectionName=S.name,q._collectionDisplayName=S.displayName}),k=await kt.process(k,S.process||[],r,{_collection:S},f),k.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let U={};for(let q of k){if(U[q.name]){G.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u7EC4\u5408\u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${q.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}U[q.name]=!0}return kt.produce(k,r,h,p)}else if(e==="rule"){let A=G.read(Cc),C=Dr(A,t);if(!C)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let S=[];for(let I=0;IB.trim()).filter(B=>B.length).map(async B=>{try{return await an(B,s||C.ua,void 0,C.proxy||w,void 0,void 0,g)}catch(k){return M[B]=k,G.error(`\u6587\u4EF6 ${C.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${B} \u53D1\u751F\u9519\u8BEF: ${k}`),""}}));let b=C.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(b=l),!b&&Object.keys(M).length>0)throw new Error(`\u6587\u4EF6 ${C.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(M).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);i==="localFirst"?S.unshift(u):i==="remoteFirst"&&S.push(u)}else if(C.source==="local"&&!["localFirst","remoteFirst"].includes(C.mergeSources))S=C.content;else{let M={};S=await Promise.all(C.url.split(/[\r\n]+/).map(B=>B.trim()).filter(B=>B.length).map(async B=>{try{return await an(B,s||C.ua,void 0,C.proxy||w,void 0,void 0,g)}catch(k){return M[B]=k,G.error(`\u6587\u4EF6 ${C.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${B} \u53D1\u751F\u9519\u8BEF: ${k}`),""}}));let b=C.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(b=l),Object.keys(M).length>0)if(b)b==="enabled"&&G.notify("\u{1F30D} Sub-Store \u5904\u7406\u6587\u4EF6\u5931\u8D25",`\u274C ${C.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(M).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u6587\u4EF6 ${C.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(M).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);C.mergeSources==="localFirst"?S.unshift(C.content):C.mergeSources==="remoteFirst"&&S.push(C.content)}if(h==="raw")return JSON.stringify((Array.isArray(S)?S:[S]).flat());let I=(Array.isArray(S)?S:[S]).flat(),_=I.filter(M=>M!=null&&M!=="").join(` `),L=Array.isArray(C.process)&&C.process.length>0?await kt.process({$files:I,$content:_,$options:f,$file:C},C.process):{$content:_,$files:I,$options:f};return(F?L:L?.$content)??""}}async function N9(){G.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");let e=G.read(Vi),t={};try{let r=[],n=[],s=G.read(Ri),u=G.read(Nu),i=[],o=0;if(e.map(p=>{if(p.sync&&p.source){if(o++,p.type==="subscription"){let E=p.source,d=Dr(s,E);d&&d.url&&!i.includes(E)&&i.push(E)}else if(p.type==="collection"){let E=Dr(u,p.source);E&&Array.isArray(E.subscriptions)&&E.subscriptions.map(d=>{let f=Dr(s,d);f&&f.url&&!i.includes(d)&&i.push(d)})}}}),o===0){G.info(`\u9700\u540C\u6B65\u7684\u914D\u7F6E: ${o}, \u603B\u6570: ${e.length}`);return}if(i.length>0&&await Promise.all(i.map(async p=>{try{await ei({type:"subscription",name:p,awaitCustomCache:!0})}catch{}})),await Promise.all(e.map(async p=>{try{if(p.sync&&p.source){G.info(`\u6B63\u5728\u540C\u6B65\u4E91\u914D\u7F6E\uFF1A${p.name}...`);let E=p.platform==="SurgeMac";E&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External");let d=await ei({type:p.type,name:p.source,platform:p.platform,produceOpts:{"include-unsupported-proxy":p.includeUnsupportedProxy,useMihomoExternal:E}});t[encodeURIComponent(p.name)]={content:d},r.push(p.name)}}catch(E){G.error(`\u751F\u6210\u540C\u6B65\u914D\u7F6E ${p.name} \u53D1\u751F\u9519\u8BEF: ${E.message??E}`),n.push(p.name)}})),G.info(`${r.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u751F\u6210\u6210\u529F: ${r.join(", ")}`),G.info(`${n.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u751F\u6210\u5931\u8D25: ${n.join(", ")}`),r.length===0)throw new Error(`\u540C\u6B65\u914D\u7F6E ${n.join(", ")} \u751F\u6210\u5931\u8D25 \u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7`);let l=await nd(t),h=JSON.parse(l.body);delete h.history,delete h.forks,delete h.owner,Object.values(h.files).forEach(p=>{delete p.content}),G.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),G.info(JSON.stringify(h,null,2));for(let p of e)if(p.sync&&p.source&&r.includes(p.name)){p.updated=new Date().getTime();let E=h.files,d;Array.isArray(E)&&(d=!0,E=Object.fromEntries(E.map(g=>[g.path,g])));let f=E[encodeURIComponent(p.name)]?.raw_url,w=d?f:f?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");G.info(`\u4E0A\u4F20\u914D\u7F6E\u5B8C\u6210 \u6587\u4EF6\u5217\u8868: ${Object.keys(E).join(", ")} \u5F53\u524D\u6587\u4EF6: ${encodeURIComponent(p.name)} \u54CD\u5E94\u8FD4\u56DE\u7684\u539F\u59CB\u94FE\u63A5: ${f} \u5904\u7406\u5B8C\u7684\u65B0\u94FE\u63A5: ${w}`),p.url=w}if(G.write(e,Vi),G.info("\u4E0A\u4F20\u914D\u7F6E\u6210\u529F"),n.length>0)throw new Error(`\u540C\u6B65\u914D\u7F6E\u6210\u529F ${r.length} \u4E2A, \u5931\u8D25 ${n.length} \u4E2A, \u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7`);G.info(`\u540C\u6B65\u914D\u7F6E\u6210\u529F ${r.length} \u4E2A`)}catch(r){throw G.error(`\u540C\u6B65\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),r}}async function x9(e,t){G.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");try{await N9(),Ds(t)}catch(r){G.error(`\u540C\u6B65\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),un(t,new mi("FAILED_TO_SYNC_ARTIFACTS","Failed to sync all artifacts",`Reason: ${r.message??r}`))}}async function L9(e,t){let{name:r}=e.params;G.info(`\u5F00\u59CB\u540C\u6B65\u8FDC\u7A0B\u914D\u7F6E ${r}...`);let n=G.read(Vi),s=Dr(n,r);if(!s){G.error(`\u627E\u4E0D\u5230\u8FDC\u7A0B\u914D\u7F6E ${r}`),un(t,new ou("RESOURCE_NOT_FOUND",`\u627E\u4E0D\u5230\u8FDC\u7A0B\u914D\u7F6E ${r}`),404);return}if(!s.source){G.error(`\u8FDC\u7A0B\u914D\u7F6E ${r} \u672A\u8BBE\u7F6E\u6765\u6E90`),un(t,new ou("RESOURCE_HAS_NO_SOURCE",`\u8FDC\u7A0B\u914D\u7F6E ${r} \u672A\u8BBE\u7F6E\u6765\u6E90`),404);return}try{let u=s.platform==="SurgeMac";u&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External");let i=await ei({type:s.type,name:s.source,platform:s.platform,produceOpts:{"include-unsupported-proxy":s.includeUnsupportedProxy,useMihomoExternal:u}});G.info(`\u6B63\u5728\u4E0A\u4F20\u914D\u7F6E\uFF1A${s.name} >>>${JSON.stringify(s,null,2)}`);let o=await nd({[encodeURIComponent(s.name)]:{content:i}});s.updated=new Date().getTime();let l=JSON.parse(o.body);delete l.history,delete l.forks,delete l.owner,Object.values(l.files).forEach(f=>{delete f.content}),G.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),G.info(JSON.stringify(l,null,2));let h=l.files,p;Array.isArray(h)&&(p=!0,h=Object.fromEntries(h.map(f=>[f.path,f])));let E=h[encodeURIComponent(s.name)]?.raw_url,d=p?E:E?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");G.info(`\u4E0A\u4F20\u914D\u7F6E\u5B8C\u6210 \u6587\u4EF6\u5217\u8868: ${Object.keys(h).join(", ")} \u5F53\u524D\u6587\u4EF6: ${encodeURIComponent(s.name)} \u54CD\u5E94\u8FD4\u56DE\u7684\u539F\u59CB\u94FE\u63A5: ${E} \u5904\u7406\u5B8C\u7684\u65B0\u94FE\u63A5: ${d}`),s.url=d,G.write(n,Vi),Ds(t,s)}catch(u){G.error(`\u8FDC\u7A0B\u914D\u7F6E ${s.name} \u53D1\u751F\u9519\u8BEF: ${u.message??u}`),un(t,new mi("FAILED_TO_SYNC_ARTIFACT",`Failed to sync artifact ${r}`,`Reason: ${u}`))}}function U9(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function j9(){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(u=>s.indexOf(u)!==-1)},parse:function(s){let u=Dt.decode(s);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(u)?u:(G.error("Base64 Pre-processor error: decoded line does not start with protocol"),s)}}}function H9(){return{name:"Fallback Base64 Pre-processor",test:function(n){return!0},parse:function(n){let s=Dt.decode(n);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(s)?s:(G.error("Fallback Base64 Pre-processor error: decoded line does not start with protocol"),n)}}}function M9(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let s=kc(n);return s.proxies&&Array.isArray(s.proxies)},parse:function(n,s){let u=n.replace(/short-id:([ \t]*[^#\n,}]*)/g,(l,h)=>{let p=h.trim();return!p||p===""?'short-id: ""':/^(['"]).*\1$/.test(p)?`short-id: ${p}`:["null"].includes(p)?`short-id: ${p}`:`short-id: "${p}"`}),{proxies:i,"global-client-fingerprint":o}=kc(u);return(s?`proxies: `:"")+i.map(l=>(o&&["trojan","vmess","vless"].includes(l.type)&&!l["client-fingerprint"]&&(l["client-fingerprint"]=o),`${s?" - ":""}${JSON.stringify(l)} `)).join("")}}}function q9(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let s=[],u=JSON.parse(Dt.decode(n.split("ssd://")[1])),i=u.port,o=u.encryption,l=u.password,h=u.servers;for(let p=0;pe.name==="Clash Pre-processor"),ud=new Map;async function an(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}=di(),{defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=G.read(Hr),cacheThreshold=defaultCacheThreshold||1024,proxy=customProxy||defaultProxy;G.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultUserAgent||"clash.meta",requestTimeout=timeout||defaultTimeout||8e3,id=zi(userAgent+url);$arguments?.cacheKey===!0&&(G.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=G.read(customCacheKey),t=Kr.get(id);if(!noCache&&!$arguments?.noCache&&t)return G.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){G.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u672C\u6B21\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u66F4\u65B0\u7F13\u5B58`);try{await an(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess)}catch(r){G.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`),G.info("\u4F7F\u7528\u4E50\u89C2\u7F13\u5B58\u7684\u6570\u636E\u5237\u65B0\u7F13\u5B58, \u9632\u6B62\u540E\u7EED\u8BF7\u6C42"),Kr.set(id,e)}}else G.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`),an(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess).catch(r=>{G.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u5F02\u6B65\u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`)});return e}}let downloadUrlMatch=url.split("#")[0].match(/^\/api\/(file|module)\/(.+)/);if(downloadUrlMatch){let e="";try{e=downloadUrlMatch?.[1];let t=downloadUrlMatch?.[2];if(t==null)throw new Error(`\u672C\u5730 ${e} URL \u65E0\u6548: ${url}`);t=decodeURIComponent(t);let r=e==="module"?Zl:Zs,n=Dr(G.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);return e==="module"?n.content:await ei({type:"file",name:t})}catch(t){throw G.error(`Error when loading ${e}: ${url.split("#")[0]}. Reason: ${t}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${e}: ${url}`)}}else if(url?.startsWith("/"))try{let fs=eval('require("fs")');return fs.readFileSync(url.split("#")[0],"utf8")}catch(e){throw G.error(`Error when reading local file: ${url.split("#")[0]}. Reason: ${e}`),new Error(`\u65E0\u6CD5\u4ECE\u8BE5\u8DEF\u5F84\u8BFB\u53D6\u6587\u672C\u5185\u5BB9: ${url}`)}if(!isNode&&ud.has(id))return ud.get(id);let http=Ki({headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,cached=Kr.get(id);if(!noCache&&!$arguments?.noCache&&cached)G.info(`\u4F7F\u7528\u7F13\u5B58: ${url}, ${userAgent}`),result=cached,customCacheKey&&(G.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),G.write(cached,customCacheKey));else{let e=$arguments?.insecure?isNode?{strictSSL:!1}:{insecure:!0}:void 0;G.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?au(proxy):{},...e||{}});if(G.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let u=Na(r);u&&jc.set(id,u)}if(t.replace(/\s/g,"").length===0)throw new Error(new Error("\u8FDC\u7A0B\u8D44\u6E90\u5185\u5BB9\u4E3A\u7A7A"));if(preprocess)try{XE.test(t)&&(t=XE.parse(t,!0))}catch(u){G.error(`Clash Pre-processor error: ${u}`)}let s=!0;if(cacheThreshold){let u=t.length/1024;u>cacheThreshold&&(G.info(`\u8D44\u6E90\u5927\u5C0F ${u.toFixed(2)} KB \u8D85\u8FC7\u4E86 ${cacheThreshold} KB, \u4E0D\u7F13\u5B58`),s=!1)}if(preprocess)try{let u=kt.parse(t);(!Array.isArray(u)||u.length===0)&&(G.error(`URL ${url} \u4E0D\u5305\u542B\u6709\u6548\u8282\u70B9, \u4E0D\u7F13\u5B58`),s=!1)}catch(u){G.error(`URL ${url} \u5C1D\u8BD5\u89E3\u6790\u8282\u70B9\u5931\u8D25 ${u.message??u}, \u4E0D\u7F13\u5B58`),s=!1}s&&(Kr.set(id,t),customCacheKey&&(G.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),G.write(t,customCacheKey))),result=t}catch(t){if(customCacheKey){let r=G.read(customCacheKey);if(r)return G.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 Wf(Uo(await Fs(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl))),isNode||ud.set(id,result),result}async function JE(url,file){let undici=eval("require('undici')"),fs=eval("require('fs')"),{pipeline}=eval("require('stream/promises')"),{Agent,interceptors,request}=undici;G.info(`Downloading file... URL: ${url} File: ${file}`);let{body,statusCode}=await request(url,{dispatcher:new Agent().compose(interceptors.redirect({maxRedirections:3,throwOnRedirect:!0}))});if(statusCode!==200)throw new Error(`Failed to download file from ${url}`);let fileStream=fs.createWriteStream(file);return await pipeline(body,fileStream),G.info(`File downloaded from ${url} to ${file}`),file}var od=class{constructor(){G.read(Fa)||G.write("{}",Fa);try{this.resourceCache=JSON.parse(G.read(Fa))}catch(t){G.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Fa} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},G.write("{}",Fa)}this._cleanup()}_cleanup(t,r){let n=ad(r)??0,s=!1,u=Date.now();Object.entries(this.resourceCache).forEach(i=>{let[o,l]=i;(!l.time||l.time0?t:null}function G9(){let t=G.read(Hr)?.scriptCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:1728e5}var cd=new od;function Zf(e,t){return[...Array(e).keys()].map(()=>t)}var ld={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["EXP","BAND"],"\u{1F1F8}\u{1F1F1}":["TEST","SOS"],"\u{1F1F2}\u{1F1F5}":["MP","MNP"],"\u{1F1F8}\u{1F1F4}":["SO","SOM"],"\u{1F1E6}\u{1F1F6}":["AQ","ATA"],"\u{1F1E6}\u{1F1EC}":["AG","ATG"],"\u{1F1EC}\u{1F1F1}":["GL","GRL"],"\u{1F1FF}\u{1F1FC}":["ZW","ZWE"],"\u{1F1E6}\u{1F1FC}":["AW","ABW"],"\u{1F1F2}\u{1F1F1}":["ML","MLI"],"\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{1F1E9}\u{1F1FF}":["DZ","DZA"],"\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{1F1EE}\u{1F1F6}":["IQ","IRQ"],"\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{1F1F4}\u{1F1F2}":["OM","OMN"],"\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{1F1F6}\u{1F1E6}":["QA","QAT"],"\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{1F1FC}\u{1F1F8}":["WS","WSM"],"\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{1F1EC}":["TG","TGO"],"\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{1F1E6}":["VA","VAT"],"\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 Ho(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{1F1F2}\u{1F1F5}":["\u5317\u9A6C\u91CC\u4E9A\u7EB3","Northern Mariana Islands","Saipan","\u585E\u73ED"],"\u{1F1F8}\u{1F1F4}":["Somalia","\u7D22\u9A6C\u91CC","\u6469\u52A0\u8FEA\u6C99","Mogadishu"],"\u{1F1E6}\u{1F1F6}":["Antarctica","\u5357\u6781\u6D32","\u5357\u6781"],"\u{1F1E6}\u{1F1EC}":["Antigua and Barbuda","\u5B89\u63D0\u74DC\u548C\u5DF4\u5E03\u8FBE"],"\u{1F1EC}\u{1F1F1}":["Greenland","\u683C\u9675\u5170\u5C9B","\u683C\u9675\u5170"],"\u{1F1FF}\u{1F1FC}":["Zimbabwe","\u6D25\u5DF4\u5E03\u97E6"],"\u{1F1E6}\u{1F1FC}":["Aruba","\u963F\u9C81\u5DF4"],"\u{1F1F2}\u{1F1F1}":["Mali","\u9A6C\u91CC"],"\u{1F1E6}\u{1F1E9}":["Andorra","\u5B89\u9053\u5C14"],"\u{1F1E6}\u{1F1EA}":["United Arab Emirates","\u963F\u8054\u914B","\u8FEA\u62DC","Dubai"],"\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{1F1FC}\u{1F1F8}":["Samoa","\u8428\u6469\u4E9A","\u85A9\u6469\u4E9E"],"\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","Czech","Czech Republic"],"\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{1F1E9}\u{1F1FF}":["Algeria","\u963F\u5C14\u53CA\u5229\u4E9A","\u963F\u723E\u53CA\u5229\u4E9E"],"\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{1F1EE}\u{1F1F6}":["Iraq","\u4F0A\u62C9\u514B","\u5DF4\u683C\u8FBE","Baghdad"],"\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{1F1F4}\u{1F1F2}":["Oman","\u963F\u66FC","\u9A6C\u65AF\u5580\u7279"],"\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{1F1F6}\u{1F1E6}":["Qatar","\u5361\u5854\u5C14","\u5361\u5854\u723E"],"\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{1F1EC}":["Togo","\u591A\u54E5","\u6D1B\u7F8E","Lom\xE9","Lome"],"\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{1F1E6}":["Vatican","Vatican City","Holy See","\u68B5\u8482\u5188","\u68B5\u8482\u5CA1"],"\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(u=>RegExp(`${u}`,"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(ld))if(ld[n].some(u=>RegExp(`(^|[^a-zA-Z])${u}([^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 eh(e){return ld[Ho(e)]?.[0]}function qc(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var Qf=class{constructor({country,asn}={}){if(G.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 nh=jr(oA()),wd=jr(hf());async function qo({url:e,domain:t,type:r="A",timeout:n,edns:s}){let u=nh.default.encode({type:"query",id:0,flags:nh.default.RECURSION_DESIRED,questions:[{type:r,name:t}],additionals:[{type:"OPT",name:".",udpPayloadSize:4096,flags:0,options:[{code:"CLIENT_SUBNET",ip:s,sourcePrefixLength:Br(s)?24:56,scopePrefixLength:0}]}]}),o=wd.Buffer.from(u).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),l=await G.http.get({url:`${e}?dns=${encodeURIComponent(o)}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n});return nh.default.decode(wd.Buffer.from(G.env.isQX?l.bodyBytes:l.body))}var Ko=jr(ih());var{isNode:cA,isQX:eB,isLoon:tB,isSurge:rB,isStash:nB,isShadowRocket:iB,isLanceX:sB,isEgern:uB,isGUIforCores:aB}=di(),Ps="Node";cA&&(Ps="Node");eB&&(Ps="QX");tB&&(Ps="Loon");rB&&(Ps="Surge");nB&&(Ps="Stash");iB&&(Ps="Shadowrocket");uB&&(Ps="Egern");sB&&(Ps="LanceX");aB&&(Ps="GUI.for.Cores");var Ua={},oB={};try{if(typeof $environment<"u"&&(Ua.env=$environment),typeof $loon<"u"&&(Ua.loon=$loon),typeof $script<"u"&&(Ua.script=$script),typeof $Plugin<"u"&&(Ua.plugin=$Plugin),cA){Ua.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)&&(Ua.node.env[e]=env[e])}}catch(e){}var Gc={backend:Ps,version:Jl,feature:oB,meta:Ua};function cB(e){return e&&typeof e=="object"&&!Array.isArray(e)}function zc(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function fA(e,t){let r=typeof t=="string"?JSON.parse(t):t;for(let n in r)if(cB(r[n]))if(n.endsWith("!")){let s=zc(n.slice(0,-1));e[s]=r[n]}else{let s=zc(n);e[s]||Object.assign(e,{[s]:{}}),fA(e[s],r[s])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let s=zc(n.slice(1));e[s]||Object.assign(e,{[s]:[]}),e[s]=[...r[n],...e[s]]}else if(n.endsWith("+")){let s=zc(n.slice(0,-1));e[s]||Object.assign(e,{[s]:[]}),e[s]=[...e[s],...r[n]]}else{let s=zc(n);Object.assign(e,{[s]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function lB({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>sh(e,r))}}function sh(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=>sh(r,t));case"OR":return e.child.some(r=>sh(r,t));case"NOT":return!sh(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function fB(e){return{name:"Quick Setting Operator",func:r=>{if(t(e.useless)){let s=gA().func(r);r=r.filter((u,i)=>s[i]&&u.port>0&&u.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 hB({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=qc(n.name);else{let s=Ho(n.name);n.name=qc(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 pB(e){let{action:t,template:r,link:n,position:s,field:u}={action:"rename",template:"0 1 2 3 4 5 6 7 8 9",link:"-",position:"back",field:["name"],...e};return{name:"Handle Duplicate Operator",func:i=>{if(t==="delete"){let o={};return i.filter(l=>{let h=u.map(p=>Ko.default.get(l,p,"-")).join("_");return o[h]?!1:(o[h]=!0,!0)})}else if(t==="rename"){let o=r.split(" "),l={},h=0;i.forEach(E=>{let d=u.map(f=>Ko.default.get(E,f,"-")).join("_");typeof l[d]>"u"?l[d]=1:l[d]++,h=Math.max(l[d].toString().length,h)});let p={};return i.map(E=>{let d=u.map(f=>Ko.default.get(E,f,"-")).join("_");if(l[d]>1){typeof p[d]>"u"&&(p[d]=1);let f="",w=p[d]++,g=0;for(;w>0;)f=o[w%10]+f,w=parseInt(w/10),g++;for(;g++{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 SB(t);default:throw new Error("Unknown sort option: "+e)}}}}function gB(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=>Fd(s)),n.sort((s,u)=>{let i=lA(r,s.name),o=lA(r,u.name);return i&&!o?-1:o&&!i?1:i&&o?it.map(r=>{for(let{expr:n,now:s}of e)r.name=r.name.replace(Fd(n,"g"),s).trim();return r})}}function mB(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:hA(t).func}}function vB(e,t,r,n,s,u){return u.source=n,u.env=Gc,{name:"Script Operator",func:async i=>{let o=i;if(o?.$file?.type==="mihomoProfile")try{let l=ms.safeLoad(e),h;if(o?.$content)try{h=ms.safeLoad(o?.$content)}catch(p){G.error(p.message??p)}if(typeof l!="object")throw new Error("patch is not an object");return o.$content=kt.yaml.safeDump(fA(h||(o?.$file?.sourceType==="none"?{}:{proxies:await ei({type:o?.$file?.sourceType||"collection",name:o?.$file?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0}})}),l)),o}catch{}return await async function(){o=uh("operator",e,r,s)(i,t,u)}(),o},nodeFunc:async i=>{let o=i;return await async function(){o=uh("operator",`async function operator(input = [], targetPlatform, context) { 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)(i,t,u)}(),o}}}function EB(e){let t,r;try{let n=e.split(":");r=parseInt(n[2],16);let s=parseInt(n[3],16),u=parseInt(n[4],16),i=s>>8,o=s&255,l=u>>8,h=u&255;if(t=`${i}.${o}.${l}.${h}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!Br(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){G.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var pA={Custom:async function(e,t,r,n,s,u){let i=zi(`CUSTOM:${u}:${e}:${t}`),o=Kr.get(i);if(!r&&o)return o;let l=t==="IPv6"?"AAAA":"A",h=await qo({url:u,domain:e,type:l,timeout:n,edns:s}),{answers:p}=h;if(!Array.isArray(p)||p.length===0)throw new Error("No answers");let E=p.filter(d=>d?.type===l).map(d=>d?.data).filter(d=>d);if(E.length===0)throw new Error("No answers");return Kr.set(i,E),E},Google:async function(e,t,r,n,s){let u=zi(`GOOGLE:${e}:${t}`),i=Kr.get(u);if(!r&&i)return i;let o=t==="IPv6"?"AAAA":"A",l=await qo({url:"https://8.8.4.4/dns-query",domain:e,type:o,timeout:n,edns:s}),{answers:h}=l;if(!Array.isArray(h)||h.length===0)throw new Error("No answers");let p=h.filter(E=>E?.type===o).map(E=>E?.data).filter(E=>E);if(p.length===0)throw new Error("No answers");return Kr.set(u,p),p},"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=zi(`IP-API:${e}`),u=Kr.get(s);if(!r&&u)return u;let i=await G.http.get({url:`http://ip-api.com/json/${encodeURIComponent(e)}?lang=zh-CN`,timeout:n}),o=JSON.parse(i.body);if(o.status!=="success")throw new Error(`Status is ${o.status}`);if(!o.query||o.query===0)throw new Error("No answers");let l=[o.query];if(l.length===0)throw new Error("No answers");return Kr.set(s,l),l},Cloudflare:async function(e,t,r,n,s){let u=zi(`CLOUDFLARE:${e}:${t}`),i=Kr.get(u);if(!r&&i)return i;let o=t==="IPv6"?"AAAA":"A",l=await qo({url:"https://1.0.0.1/dns-query",domain:e,type:o,timeout:n,edns:s}),{answers:h}=l;if(!Array.isArray(h)||h.length===0)throw new Error("No answers");let p=h.filter(E=>E?.type===o).map(E=>E?.data).filter(E=>E);if(p.length===0)throw new Error("No answers");return Kr.set(u,p),p},Ali:async function(e,t,r,n,s){let u=zi(`ALI:${e}:${t}`),i=Kr.get(u);if(!r&&i)return i;let o=await G.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${s}/${Br(s)?24:56}&name=${encodeURIComponent(e)}&type=${t==="IPv6"?"AAAA":"A"}&short=1`,headers:{accept:"application/dns-json"},timeout:n}),l=JSON.parse(o.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 Kr.set(u,h),h},Tencent:async function(e,t,r,n,s){let u=zi(`TENCENT:${e}:${t}`),i=Kr.get(u);if(!r&&i)return i;let l=(await G.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(p=>p.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 Kr.set(u,h),h}};function dA({provider:e,type:t,filter:r,cache:n,url:s,timeout:u,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:o}=G.read(Hr),l=u||o||8e3,h=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",p=pA[e];if(!p)throw new Error(`\u627E\u4E0D\u5230\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9: ${e}`);let E=i||"223.6.6.6";if(!ja(E))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");return G.info(`Domain Resolver: [${t}] ${e} ${E||""} ${s||""}`),{name:"Resolve Domain Operator",func:async d=>{d.forEach((A,C)=>{!A["_no-resolve"]&&A["no-resolve"]&&(d[C]["_no-resolve"]=A["no-resolve"])});let f={},w=15,g=[...new Set(d.filter(A=>!ja(A.server)&&!A["_no-resolve"]).map(A=>A.server))],F=Math.ceil(g.length/w);for(let A=0;A{f[S]=I,G.info(`Successfully resolved domain: ${S} \u279F ${I}`)}).catch(I=>{G.error(`Failed to resolve domain: ${S} with resolver [${e}]: ${I}`)}));await Promise.all(C)}return d.forEach(A=>{if(!A["_no-resolve"])if(f[A.server]){A._resolved_ips=f[A.server];let C=Array.isArray(f[A.server])?f[A.server][Math.floor(Math.random()*f[A.server].length)]:f[A.server];if(h==="IPv6"&&Fr(C)){try{C=new Gf.Address6(C).correctForm()}catch(S){G.error(`Failed to parse IPv6 address: ${C}: ${S}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(C)){A._IP4P=C;let{server:S,port:I}=EB(C);S&&I?(A._domain=A.server,A.server=S,A.port=I,A.resolved=!0,A._IPv4=A.server,ja(A._IP)||(A._IP=A.server)):A.resolved||(A.resolved=!1)}else A._domain=A.server,A.server=C,A.resolved=!0,A[`_${h}`]=A.server,ja(A._IP)||(A._IP=A.server)}else A._domain=A.server,A.server=C,A.resolved=!0,A[`_${h}`]=A.server,ja(A._IP)||(A._IP=A.server)}else A.resolved||(A.resolved=!1)}),d.filter(A=>r==="removeFailed"?ja(A.server)||A["_no-resolve"]||A.resolved:r==="IPOnly"?ja(A.server):r==="IPv4Only"?Br(A.server):r==="IPv6Only"?Fr(A.server):!0)}}}function ja(e){return Br(e)||Fr(e)}dA.resolver=pA;function Cd(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function gA(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!Cd(t.cipher))return!1;if(t.password&&!Cd(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&&!Cd(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function AB(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(u=>{let i=Ho(u.name),o=t.some(l=>n[l]===i);return r?o:!o})}}function wB({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let s=e.some(u=>Fd(u).test(n.name));return t?s:!s})}}function Fd(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function CB(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 u=t.some(i=>s.type===i);return r?u:!u})}}function FB(e,t,r,n,s,u){return u.source=n,u.env=Gc,{name:"Script Filter",func:async i=>{let o=Zf(i.length,!0);return await async function(){o=uh("filter",e,r,s)(i,t,u)}(),o},nodeFunc:async i=>{let o=Zf(i.length,!0);return await async function(){o=uh("filter",`async function filter(input = [], targetPlatform, context) { 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)(i,t,u)}(),o}}}var ah={"Useless Filter":gA,"Region Filter":AB,"Regex Filter":wB,"Type Filter":CB,"Script Filter":FB,"Conditional Filter":lB,"Quick Setting Operator":fB,"Flag Operator":hB,"Sort Operator":dB,"Regex Sort Operator":gB,"Regex Rename Operator":hA,"Regex Delete Operator":mB,"Script Operator":vB,"Handle Duplicate Operator":pB,"Resolve Domain Operator":dA};async function DB(e,t){let r=Zf(t.length,!0);try{r=await e.func(t)}catch(n){let s="",u=`${n.message??n}`;u.includes("$server is not defined")?s="":(G.error(`Cannot apply filter ${e.name}(function filter)! Reason: ${n}`),s=`\u6267\u884C function filter \u5931\u8D25 ${u}; `);try{r=await e.nodeFunc(t)}catch(i){G.error(`Cannot apply filter ${e.name}(shortcut script)! Reason: ${i}`);let o="",l=`${i.message??i}`;throw s&&l===u?(o="",s=`\u6267\u884C\u5931\u8D25 ${u}`):o=`\u6267\u884C\u5FEB\u6377\u8FC7\u6EE4\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u8FC7\u6EE4 ${s}${o}`)}}return t.filter((n,s)=>r[s])}async function yB(e,t){let r=bB(t);try{let n=await e.func(r);n&&(r=n)}catch(n){let s="",u=`${n.message??n}`;u.includes("$server is not defined")||u.includes("$content is not defined")||u.includes("$files is not defined")||r?.$files||r?.$content?s="":(G.error(`Cannot apply operator ${e.name}(function operator)! Reason: ${n}`),s=`\u6267\u884C function operator \u5931\u8D25 ${u}; `);try{let i=await e.nodeFunc(r);i&&(r=i)}catch(i){G.error(`Cannot apply operator ${e.name}(shortcut script)! Reason: ${i}`);let o="",l=`${i.message??i}`;throw s&&l===u?(o="",s=`\u6267\u884C\u5931\u8D25 ${u}`):o=`\u6267\u884C\u5FEB\u6377\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u64CD\u4F5C ${s}${o}`)}}return r}async function mA(e,t){if(e.name.indexOf("Filter")!==-1)return DB(e,t);if(e.name.indexOf("Operator")!==-1)return yB(e,t)}function SB(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 bB(e){return JSON.parse(JSON.stringify(e))}function uh(name,script,$arguments,$options){let flowUtils={getFlowField:Na,getFlowHeaders:Fs,parseFlowHeaders:Uo,flowTransfer:Hc,validCheck:Wf,getRmainingDays:KE,normalizeFlowHeader:jo};return G.env.isLoon?new Function("$arguments","$options","$substore","lodash","$persistentStore","$httpClient","$notification","ProxyUtils","yaml","Buffer","b64d","b64e","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,G,Ko.default,$persistentStore,$httpClient,$notification,kt,kt.yaml,kt.Buffer,kt.Base64.decode,kt.Base64.encode,cd,flowUtils,ei,eval('typeof require !== "undefined"')?Aa:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","yaml","Buffer","b64d","b64e","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,G,Ko.default,kt,kt.yaml,kt.Buffer,kt.Base64.decode,kt.Base64.encode,cd,flowUtils,ei,eval('typeof require !== "undefined"')?Aa:void 0)}var vA=jr(ih()),ct=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){oe(this.proxy,r)&&this.append(t)}toString(){return this.output.join("")}};function oe(e,t){let r=vA.default.get(e,t);return typeof r<"u"&&r!==null}var Dd="Surge",ri={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function Go(){return{produce:(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${Dd} does not support network ${t.network} with http upgrade`);switch(t.name=t.name.replace(/=|,/g,""),t.ports&&(t.ports=String(t.ports)),t.type){case"ss":return _B(t);case"trojan":return IB(t);case"vmess":return PB(t,n["include-unsupported-proxy"]);case"http":return TB(t);case"direct":return OB(t);case"socks5":return kB(t);case"snell":return NB(t);case"tuic":return xB(t);case"wireguard-surge":return UB(t);case"hysteria2":return jB(t,n["include-unsupported-proxy"]);case"ssh":return RB(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return LB(t);if(n["include-unsupported-proxy"]&&t.type==="anytls"){if(t.network&&(!["tcp"].includes(t.network)||["tcp"].includes(t.network)&&t["reality-opts"]))throw new Error(`Platform ${Dd} does not support proxy type ${t.type} with network or reality`);return BB(t)}if(n["include-unsupported-proxy"]&&t.type==="trust-tunnel")return $B(t);throw new Error(`Platform ${Dd} does not support proxy type: ${t.type}`)}}}function _B(e){let t=new ct(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=ri[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"),oe(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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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,u=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),s&&t.append(`,shadow-tls-sni=${s}`),u){if(u<2)throw new Error(`shadow-tls version ${u} is not supported`);t.append(`,shadow-tls-version=${u}`)}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 IB(e){let t=new ct(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ri[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"),EA(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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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 BB(e){let t=new ct(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ri[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(`,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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),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 $B(e){let t=new ct(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ri[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(`,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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),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 PB(e,t){let r=new ct(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=ri[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"),EA(r,e,t),oe(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"),r.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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 RB(e){let t=new ct(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${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=ri[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(`,interface=${e.interface}`,"interface"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function TB(e){if(e.headers&&Object.keys(e.headers).length>0)throw new Error("headers is unsupported");let t=new ct(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password");let n=ri[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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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 OB(e){let t=new ct(e);t.append(`${e.name}=direct`);let n=ri[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(`,interface=${e.interface}`,"interface"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function kB(e){let t=new ct(e),r=e.tls?"socks5-tls":"socks5";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password");let n=ri[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&&G.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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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 NB(e){let t=new ct(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=ri[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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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 xB(e){let t=new ct(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"),oe(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let n=ri[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"),oe(e,"tfo")?t.append(`,tfo=${e.tfo}`):oe(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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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 LB(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 ct(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=Jt(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=ri[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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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,u=e["preshared-key"]??e["pre-shared-key"],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":u};return t.append(` peer = (${Object.keys(i).filter(o=>i[o]!=null).map(o=>`${o} = ${i[o]}`).join(", ")})`),t.toString()}function UB(e){let t=new ct(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=ri[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"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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 jB(e,t){if(t){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported")}else if(e.obfs||e["obfs-password"])throw new Error("obfs is unsupported");let r=new ct(e);r.append(`${e.name}=hysteria2,${e.server},${e.port}`),r.appendIfPresent(`,password="${e.password}"`,"password"),oe(e,"ports")&&r.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),r.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval"),e["obfs-password"]&&e.obfs=="salamander"&&r.append(`,salamander-password="${e["obfs-password"]}"`);let n=ri[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"),r.appendIfPresent(`,sni=${e.sni}`,"sni"),r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),oe(e,"tfo")?r.append(`,tfo=${e.tfo}`):oe(e,"fast-open")&&r.append(`,tfo=${e["fast-open"]}`),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"),r.appendIfPresent(`,interface=${e.interface}`,"interface"),oe(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.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),r.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),r.toString()}function EA(e,t,r){if(oe(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),oe(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),oe(t,"ws-opts.headers"))){let n=t["ws-opts"].headers,s=Object.keys(n).map(u=>{let i=n[u];return i=`"${i}"`,`${u}:${i}`}).join("|");Cs(s)&&e.append(`,ws-headers=${s}`)}}else if(r&&["http"].includes(t.network))G.info(`Include Unsupported Proxy: network ${t.network} -> tcp`);else{if(["tcp"].includes(t.network)&&t["reality-opts"])throw new Error("reality is unsupported");if(!["tcp"].includes(t.network))throw new Error(`network ${t.network} is unsupported`)}}var HB={dual:"dual","v4-only":"ipv4","v6-only":"ipv6","prefer-v4":"ipv4-prefer","prefer-v6":"ipv6-prefer"};function wi(){return{type:"ALL",produce:(r,n,s={})=>{let u=r.filter(i=>s["include-unsupported-proxy"]?!0:i.type==="snell"&&i.version>=4||["trust-tunnel","juicity","naive"].includes(i.type)||["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)||["anytls"].includes(i.type)&&i.network&&(!["tcp"].includes(i.network)||["tcp"].includes(i.network)&&i["reality-opts"])?!1:!["xhttp"].includes(i.network)).map(i=>{if(["trojan","vmess","vless"].includes(i.type)&&(i["client-fingerprint"]=i["client-fingerprint"]||"chrome"),i.type==="vmess"?(oe(i,"aead")&&(i.aead&&(i.alterId=0),delete i.aead),oe(i,"sni")&&(i.servername=i.sni,delete i.sni),oe(i,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(i.cipher)&&(i.cipher="auto")):i.type==="tuic"?(oe(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),oe(i,"tfo")&&!oe(i,"fast-open")&&(i["fast-open"]=i.tfo),(!i.token||i.token.length===0)&&!oe(i,"version")&&(i.version=5)):i.type==="hysteria"?(oe(i,"auth_str")&&!oe(i,"auth-str")&&(i["auth-str"]=i.auth_str),oe(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),oe(i,"tfo")&&!oe(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"?oe(i,"sni")&&(i.servername=i.sni,delete i.sni):i.type==="ss"&&oe(i,"shadow-tls-password")&&!oe(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 o=i["http-opts"]?.path;oe(i,"http-opts.path")&&!Array.isArray(o)&&(i["http-opts"].path=[o]);let l=i["http-opts"]?.headers?.Host;oe(i,"http-opts.headers.Host")&&!Array.isArray(l)&&(i["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(i.type)&&i.network==="h2"){let o=i["h2-opts"]?.path;oe(i,"h2-opts.path")&&Array.isArray(o)&&(i["h2-opts"].path=o[0]);let l=i["h2-opts"]?.headers?.host;oe(i,"h2-opts.headers.Host")&&!Array.isArray(l)&&(i["h2-opts"].headers.host=[l])}if(["ws"].includes(i.network)){let o=i[`${i.network}-opts`]?.path;if(o){let l=/^(.*?)(?:\?ed=(\d+))?$/,[h,p="",E=""]=l.exec(o);i[`${i.network}-opts`].path=p,E!==""&&(i["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",i["ws-opts"]["max-early-data"]=parseInt(E,10))}else i[`${i.network}-opts`]=i[`${i.network}-opts`]||{},i[`${i.network}-opts`].path="/"}if(i["plugin-opts"]?.tls&&oe(i,"skip-cert-verify")&&(i["plugin-opts"]["skip-cert-verify"]=i["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trust-tunnel","naive"].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"],oe(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 o in i)(i[o]==null||/^_/i.test(o))&&delete i[o];return["grpc"].includes(i.network)&&i[`${i.network}-opts`]&&(delete i[`${i.network}-opts`]["_grpc-type"],delete i[`${i.network}-opts`]["_grpc-authority"]),i["ip-version"]&&(i["ip-version"]=HB[i["ip-version"]]||i["ip-version"]),i});return n==="internal"?u:`proxies: `+u.map(i=>" - "+JSON.stringify(i)+` `).join("")}}}var AA="SurgeMac",MB=Go();function yd(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return wA(t);default:try{return MB.produce(t,r,n)}catch{if(n.useMihomoExternal)return G.log(`${t.name} is not supported on ${AA}, try to use Mihomo(SurgeMac - External Proxy Program) instead`),qB(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 wA(e){let t=new ct(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"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),oe(e,"tfo")?t.append(`,tfo=${e.tfo}`):oe(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 qB(e,t,r){let n=wi().produce([e],"internal")?.[0];if(n){let s=r?.localPort||e._localPort||65535,u=!["ipv4","v4-only"].includes(e["ip-version"]),i={name:e.name,type:"external",udp:!0,exec:e._exec||"/usr/local/bin/mihomo","local-port":s,args:["-config",Dt.encode(JSON.stringify({"mixed-port":s,ipv6:u,mode:"global",dns:{enable:!0,ipv6:u,"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 VB(e.server)?i.addresses.push(e.server):G.log(`Platform ${AA}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),r.localPort=s-1,wA(i)}}function VB(e){return Br(e)||Fr(e)}function Sd(){return{type:"ALL",produce:(r,n,s={})=>{let u=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"&&i.version>=4||i.type==="vless"&&(typeof i.flow<"u"||i["reality-opts"])||["ws"].includes(i.network)&&i["ws-opts"]?.["v2ray-http-upgrade"]?!1:i["underlying-proxy"]||i["dialer-proxy"]?(G.error(`Clash \u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${i.name}`),!1):!0).map(i=>{if(i.type==="vmess"?(oe(i,"aead")&&(i.aead&&(i.alterId=0),delete i.aead),oe(i,"sni")&&(i.servername=i.sni,delete i.sni),oe(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"&&oe(i,"sni")&&(i.servername=i.sni,delete i.sni),["vmess","vless"].includes(i.type)&&i.network==="http"){let o=i["http-opts"]?.path;oe(i,"http-opts.path")&&!Array.isArray(o)&&(i["http-opts"].path=[o]);let l=i["http-opts"]?.headers?.Host;oe(i,"http-opts.headers.Host")&&!Array.isArray(l)&&(i["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(i.type)&&i.network==="h2"){let o=i["h2-opts"]?.path;oe(i,"h2-opts.path")&&Array.isArray(o)&&(i["h2-opts"].path=o[0]);let l=i["h2-opts"]?.headers?.host;oe(i,"h2-opts.headers.Host")&&!Array.isArray(l)&&(i["h2-opts"].headers.host=[l])}if(["ws"].includes(i.network)){let o=i[`${i.network}-opts`]?.path;if(o){let l=/^(.*?)(?:\?ed=(\d+))?$/,[h,p="",E=""]=l.exec(o);i[`${i.network}-opts`].path=p,E!==""&&(i["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",i["ws-opts"]["max-early-data"]=parseInt(E,10))}else i[`${i.network}-opts`]=i[`${i.network}-opts`]||{},i[`${i.network}-opts`].path="/"}if(i["plugin-opts"]?.tls&&oe(i,"skip-cert-verify")&&(i["plugin-opts"]["skip-cert-verify"]=i["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trust-tunnel","naive"].includes(i.type)&&delete i.tls,i["tls-fingerprint"]&&(i.fingerprint=i["tls-fingerprint"]),delete i["tls-fingerprint"],oe(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 o in i)(i[o]==null||/^_/i.test(o))&&delete i[o];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"?u:`proxies: `+u.map(i=>" - "+JSON.stringify(i)+` `).join("")}}}function oh(){return{type:"ALL",produce:(r,n,s={})=>{let u=r.filter(i=>!["ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","wireguard","hysteria","hysteria2","ssh","juicity","anytls"].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"&&i.version>=4||i.type==="vless"&&i["reality-opts"]&&!["xtls-rprx-vision"].includes(i.flow)||["anytls"].includes(i.type)&&!s["include-unsupported-proxy"]||["anytls"].includes(i.type)&&i.network&&(!["tcp"].includes(i.network)||["tcp"].includes(i.network)&&i["reality-opts"])||["xhttp"].includes(i.network)||i.encryption&&i.encryption!=="none"&&["vless"].includes(i.type)?!1:!(["ws"].includes(i.network)&&i["ws-opts"]?.["v2ray-http-upgrade"])).map(i=>{if(i.type==="vmess"?(oe(i,"aead")&&(i.aead&&(i.alterId=0),delete i.aead),oe(i,"sni")&&(i.servername=i.sni,delete i.sni),oe(i,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(i.cipher)&&(i.cipher="auto")):i.type==="tuic"?(oe(i,"alpn")?i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]:i.alpn=["h3"],oe(i,"tfo")&&!oe(i,"fast-open")&&(i["fast-open"]=i.tfo,delete i.tfo),(!i.token||i.token.length===0)&&!oe(i,"version")&&(i.version=5)):i.type==="hysteria"?(oe(i,"auth_str")&&!oe(i,"auth-str")&&(i["auth-str"]=i.auth_str),oe(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),oe(i,"tfo")&&!oe(i,"fast-open")&&(i["fast-open"]=i.tfo,delete i.tfo),oe(i,"down")&&!oe(i,"down-speed")&&(i["down-speed"]=i.down,delete i.down),oe(i,"up")&&!oe(i,"up-speed")&&(i["up-speed"]=i.up,delete i.up),oe(i,"down-speed")&&(i["down-speed"]=`${i["down-speed"]}`.match(/\d+/)?.[0]||0),oe(i,"up-speed")&&(i["up-speed"]=`${i["up-speed"]}`.match(/\d+/)?.[0]||0)):i.type==="hysteria2"?(oe(i,"password")&&!oe(i,"auth")&&(i.auth=i.password,delete i.password),oe(i,"tfo")&&!oe(i,"fast-open")&&(i["fast-open"]=i.tfo,delete i.tfo),oe(i,"down")&&!oe(i,"down-speed")&&(i["down-speed"]=i.down,delete i.down),oe(i,"up")&&!oe(i,"up-speed")&&(i["up-speed"]=i.up,delete i.up),oe(i,"down-speed")&&(i["down-speed"]=`${i["down-speed"]}`.match(/\d+/)?.[0]||0),oe(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"&&oe(i,"sni")&&(i.servername=i.sni,delete i.sni),["vmess","vless"].includes(i.type)&&i.network==="http"){let o=i["http-opts"]?.path;oe(i,"http-opts.path")&&!Array.isArray(o)&&(i["http-opts"].path=[o]);let l=i["http-opts"]?.headers?.Host;oe(i,"http-opts.headers.Host")&&!Array.isArray(l)&&(i["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(i.type)&&i.network==="h2"){let o=i["h2-opts"]?.path;oe(i,"h2-opts.path")&&Array.isArray(o)&&(i["h2-opts"].path=o[0]);let l=i["h2-opts"]?.headers?.host;oe(i,"h2-opts.headers.Host")&&!Array.isArray(l)&&(i["h2-opts"].headers.host=[l])}if(["ws"].includes(i.network)){let o=i[`${i.network}-opts`]?.path;if(o){let l=/^(.*?)(?:\?ed=(\d+))?$/,[h,p="",E=""]=l.exec(o);i[`${i.network}-opts`].path=p,E!==""&&(i["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",i["ws-opts"]["max-early-data"]=parseInt(E,10))}else i[`${i.network}-opts`]=i[`${i.network}-opts`]||{},i[`${i.network}-opts`].path="/"}if(i["plugin-opts"]?.tls&&oe(i,"skip-cert-verify")&&(i["plugin-opts"]["skip-cert-verify"]=i["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trust-tunnel","naive"].includes(i.type)&&delete i.tls,i["tls-fingerprint"]&&(i["server-cert-fingerprint"]=i["tls-fingerprint"]),delete i["tls-fingerprint"],oe(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 o in i)(i[o]==null||/^_/i.test(o))&&delete i[o];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"?u:`proxies: `+u.map(i=>" - "+JSON.stringify(i)+` `).join("")}}}var CA="Loon",Au={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function bd(){return{produce:(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${CA} does not support network ${t.network} with http upgrade`);switch(t.type){case"ss":return KB(t);case"ssr":return GB(t);case"trojan":return zB(t);case"vmess":return WB(t,n["include-unsupported-proxy"]);case"vless":return YB(t,n["include-unsupported-proxy"]);case"http":return XB(t);case"socks5":return JB(t);case"wireguard":return ZB(t);case"hysteria2":return QB(t)}throw new Error(`Platform ${CA} does not support proxy type: ${t.type}`)}}}function KB(e){let t=new ct(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}"`),oe(e,"plugin")){if(e.plugin==="obfs"){if(e["plugin-opts"]?.mode&&e.cipher.startsWith("2022-"))throw new Error(`${e.cipher} ${e.plugin} is not supported`);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(oe(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,u=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),s&&t.append(`,shadow-tls-sni=${s}`),u){if(u<2)throw new Error(`shadow-tls version ${u} is not supported`);t.append(`,shadow-tls-version=${u}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=Au[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function GB(e){let t=new ct(e);if(t.append(`${e.name}=shadowsocksr,${e.server},${e.port},${e.cipher},"${e.password}"`),t.append(`,protocol=${e.protocol}`),t.appendIfPresent(`,protocol-param=${e["protocol-param"]}`,"protocol-param"),t.appendIfPresent(`,obfs=${e.obfs}`,"obfs"),t.appendIfPresent(`,obfs-param=${e["obfs-param"]}`,"obfs-param"),oe(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,u=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),s&&t.append(`,shadow-tls-sni=${s}`),u){if(u<2)throw new Error(`shadow-tls version ${u} is not supported`);t.append(`,shadow-tls-version=${u}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=Au[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function zB(e){let t=new ct(e);if(t.append(`${e.name}=trojan,${e.server},${e.port},"${e.password}"`),e.network==="tcp"&&delete e.network,oe(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["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=Au[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function WB(e){let t=!!e["reality-opts"],r=new ct(e);if(r.append(`${e.name}=vmess,${e.server},${e.port},${e.cipher},"${e.uuid}"`),e.network==="tcp"&&delete e.network,oe(e,"network"))if(e.network==="ws")r.append(",transport=ws"),r.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),r.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){r.append(",transport=http");let s=e["http-opts"]?.path,u=e["http-opts"]?.headers?.Host;r.appendIfPresent(`,path=${Array.isArray(s)?s[0]:s}`,"http-opts.path"),r.appendIfPresent(`,host=${Array.isArray(u)?u[0]:u}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else r.append(",transport=tcp");r.appendIfPresent(`,over-tls=${e.tls}`,"tls"),r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t?(r.appendIfPresent(`,sni=${e.sni}`,"sni"),r.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),r.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(r.appendIfPresent(`,tls-name=${e.sni}`,"sni"),r.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),r.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),oe(e,"aead")?r.append(`,alterId=${e.aead?0:1}`):r.append(`,alterId=${e.alterId}`),r.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?r.append(",block-quic=true"):e["block-quic"]==="off"&&r.append(",block-quic=false"),e.udp&&r.append(",udp=true");let n=Au[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function YB(e){if(e.encryption&&e.encryption!=="none")throw new Error("VLESS encryption is not supported");let t=!1,r=!!e["reality-opts"];if(typeof e.flow<"u")if(["xtls-rprx-vision"].includes(e.flow))t=!0;else throw new Error(`VLESS flow(${e.flow}) is not supported`);let n=new ct(e);if(n.append(`${e.name}=vless,${e.server},${e.port},"${e.uuid}"`),e.network==="tcp"&&delete e.network,oe(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 u=e["http-opts"]?.path,i=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(u)?u[0]:u}`,"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"),t&&n.appendIfPresent(`,flow=${e.flow}`,"flow"),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")),n.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["block-quic"]==="on"?n.append(",block-quic=true"):e["block-quic"]==="off"&&n.append(",block-quic=false"),e.udp&&n.append(",udp=true");let s=Au[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${s}`,"ip-version"),n.toString()}function XB(e){let t=new ct(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"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false");let n=Au[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function JB(e){let t=new ct(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["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),e.udp&&t.append(",udp=true");let r=Au[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function ZB(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 ct(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(o=>Fr(o));let i=e.dns.find(o=>Br(o));i||(i=e.dns.find(o=>!Br(o)&&!Fr(o))),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 u=Au[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${u}`,"ip-version"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),t.toString()}function QB(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new ct(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["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),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=Au[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function FA(e){let t="none",r=e["reality-opts"],n="",s="",u="";if(r){t="reality";let M=e["reality-opts"]?.["public-key"];M&&(s=`&pbk=${encodeURIComponent(M)}`);let b=e["reality-opts"]?.["short-id"];b&&(n=`&sid=${encodeURIComponent(b)}`);let B=e["reality-opts"]?.["_spider-x"];B&&(u=`&spx=${encodeURIComponent(B)}`)}else e.tls&&(t="tls");let i="";e.alpn&&(i=`&alpn=${encodeURIComponent(Array.isArray(e.alpn)?e.alpn:e.alpn.join(","))}`);let o="";e["skip-cert-verify"]&&(o="&allowInsecure=1");let l="";e._h2&&(l="&h2=1");let h="";e._pcs&&(h=`&pcs=${encodeURIComponent(e._pcs)}`);let p="";e._echConfigList&&(p=`&ech=${encodeURIComponent(e._echConfigList)}`);let E="";e.sni&&(E=`&sni=${encodeURIComponent(e.sni)}`);let d="";e["client-fingerprint"]&&(d=`&fp=${encodeURIComponent(e["client-fingerprint"])}`);let f="";e.flow&&(f=`&flow=${encodeURIComponent(e.flow)}`);let w="";e._extra&&(w=`&extra=${encodeURIComponent(e._extra)}`);let g="";e._mode&&(g=`&mode=${encodeURIComponent(e._mode)}`);let F="";e._pqv&&(F=`&pqv=${encodeURIComponent(e._pqv)}`);let A="";e.encryption&&(A=`&encryption=${encodeURIComponent(e.encryption)}`);let C=e.network;e.network==="ws"&&e["ws-opts"]?.["v2ray-http-upgrade"]&&(C="httpupgrade");let S=`&type=${encodeURIComponent(C)}`;if(["grpc"].includes(e.network)){S+=`&mode=${encodeURIComponent(e[`${e.network}-opts`]?.["_grpc-type"]||"gun")}`;let M=e[`${e.network}-opts`]?.["_grpc-authority"];M&&(S+=`&authority=${encodeURIComponent(M)}`)}let I=e[`${e.network}-opts`]?.[`${e.network}-service-name`],_=e[`${e.network}-opts`]?.path,L=e[`${e.network}-opts`]?.headers?.Host;return _&&(S+=`&path=${encodeURIComponent(Array.isArray(_)?_[0]:_)}`),L&&(S+=`&host=${encodeURIComponent(Array.isArray(L)?L[0]:L)}`),I&&(S+=`&serviceName=${encodeURIComponent(I)}`),e.network==="kcp"&&(e.seed&&(S+=`&seed=${encodeURIComponent(e.seed)}`),e.headerType&&(S+=`&headerType=${encodeURIComponent(e.headerType)}`)),`vless://${e.uuid}@${e.server}:${e.port}?security=${encodeURIComponent(t)}${S}${i}${o}${h}${p}${l}${E}${d}${f}${n}${u}${s}${g}${w}${F}${A}#${encodeURIComponent(e.name)}`}function zo(){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&&delete r[s];switch(["trojan","tuic","hysteria","hysteria2","juicity","anytls","trust-tunnel"].includes(r.type)&&delete r.tls,!["vmess"].includes(r.type)&&r.server&&Fr(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}`;n=`ss://${r.cipher?.startsWith("2022-blake3-")?`${encodeURIComponent(r.cipher)}:${encodeURIComponent(r.password)}`:Dt.encode(s)}@${r.server}:${r.port}${r.plugin?"/":""}`;let u="";if(r.plugin){u+="&plugin=";let ae=r["plugin-opts"];switch(r.plugin){case"obfs":u+=encodeURIComponent(`simple-obfs;obfs=${ae.mode}${ae.host?";obfs-host="+ae.host:""}`);break;case"v2ray-plugin":u+=encodeURIComponent(`v2ray-plugin;obfs=${ae.mode}${ae.host?";obfs-host"+ae.host:""}${ae.tls?";tls":""}`);break;case"shadow-tls":u+=encodeURIComponent(`shadow-tls;host=${ae.host};password=${ae.password};version=${ae.version}`);break;default:throw new Error(`Unsupported plugin option: ${r.plugin}`)}}r["udp-over-tcp"]&&(u+="&uot=1"),r.tfo&&(u+="&tfo=1");let i="";if(r.network){let ae=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(ae="httpupgrade"),i=`&type=${encodeURIComponent(ae)}`,["grpc"].includes(r.network)){let Zt=r[`${r.network}-opts`]?.[`${r.network}-service-name`],It=r[`${r.network}-opts`]?.["_grpc-authority"];Zt&&(i+=`&serviceName=${encodeURIComponent(Zt)}`),It&&(i+=`&authority=${encodeURIComponent(It)}`),i+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let ye=r[`${r.network}-opts`]?.path,He=r[`${r.network}-opts`]?.headers?.Host;ye&&(i+=`&path=${encodeURIComponent(Array.isArray(ye)?ye[0]:ye)}`),He&&(i+=`&host=${encodeURIComponent(Array.isArray(He)?He[0]:He)}`)}let o="";r["client-fingerprint"]&&(o=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let l="";r.alpn&&(l=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let h=r["reality-opts"],p="",E="",d="",f=r.tls?"&security=tls":"",w="",g="";if(h){f="&security=reality";let ae=r["reality-opts"]?.["public-key"];ae&&(E=`&pbk=${encodeURIComponent(ae)}`);let ye=r["reality-opts"]?.["short-id"];ye&&(p=`&sid=${encodeURIComponent(ye)}`);let He=r["reality-opts"]?.["_spider-x"];He&&(d=`&spx=${encodeURIComponent(He)}`),r._extra&&(g=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(w=`&mode=${encodeURIComponent(r._mode)}`)}r.tls&&(u+=`&sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}`),u+=`${i}${l}${o}${f}${p}${E}${d}${w}${g}#${encodeURIComponent(r.name)}`,n+=u.replace(/^&/,"?");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 F="",A=r.network||"tcp";if(r.network==="http"?(A="tcp",F="http"):r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(A="httpupgrade"),n={v:"2",ps:r.name,add:r.server,port:`${r.port}`,id:r.uuid,aid:`${r.alterId||0}`,scy:r.cipher,net:A,type:F,tls:r.tls?"tls":"",alpn:Array.isArray(r.alpn)?r.alpn.join(","):r.alpn,fp:r["client-fingerprint"]},r.tls&&r.sni&&(n.sni=r.sni),r.network){let ae=r[`${r.network}-opts`]?.path,ye=r[`${r.network}-opts`]?.headers?.Host;["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"]):["kcp","quic"].includes(r.network)?(n.type=r[`${r.network}-opts`]?.[`_${r.network}-type`]||"none",n.host=r[`${r.network}-opts`]?.[`_${r.network}-host`],n.path=r[`${r.network}-opts`]?.[`_${r.network}-path`]):(ae&&(n.path=Array.isArray(ae)?ae[0]:ae),ye&&(n.host=Array.isArray(ye)?ye[0]:ye))}n="vmess://"+Dt.encode(JSON.stringify(n));break;case"vless":n=FA(r);break;case"trojan":let C="";if(r.network){let ae=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(ae="httpupgrade"),C=`&type=${encodeURIComponent(ae)}`,["grpc"].includes(r.network)){let Zt=r[`${r.network}-opts`]?.[`${r.network}-service-name`],It=r[`${r.network}-opts`]?.["_grpc-authority"];Zt&&(C+=`&serviceName=${encodeURIComponent(Zt)}`),It&&(C+=`&authority=${encodeURIComponent(It)}`),C+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let ye=r[`${r.network}-opts`]?.path,He=r[`${r.network}-opts`]?.headers?.Host;ye&&(C+=`&path=${encodeURIComponent(Array.isArray(ye)?ye[0]:ye)}`),He&&(C+=`&host=${encodeURIComponent(Array.isArray(He)?He[0]:He)}`)}let S="";r["client-fingerprint"]&&(S=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let I="";r.alpn&&(I=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let _=r["reality-opts"],L="",M="",b="",B="",k="",U="";if(_){B="&security=reality";let ae=r["reality-opts"]?.["public-key"];ae&&(M=`&pbk=${encodeURIComponent(ae)}`);let ye=r["reality-opts"]?.["short-id"];ye&&(L=`&sid=${encodeURIComponent(ye)}`);let He=r["reality-opts"]?.["_spider-x"];He&&(b=`&spx=${encodeURIComponent(He)}`),r._extra&&(U=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(k=`&mode=${encodeURIComponent(r._mode)}`)}n=`trojan://${r.password}@${r.server}:${r.port}?sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}${C}${I}${S}${B}${L}${M}${b}${k}${U}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let q=[];r["hop-interval"]&&q.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&q.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&q.push("insecure=1"),r.obfs&&(q.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&q.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&q.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&q.push(`mport=${r.ports}`),r["tls-fingerprint"]&&q.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&q.push("fastopen=1"),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${q.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let W=[];Object.keys(r).forEach(ae=>{if(!["name","type","server","port"].includes(ae)){let ye=ae.replace(/-/,"_");["alpn"].includes(ae)?r[ae]&&W.push(`${ye}=${encodeURIComponent(Array.isArray(r[ae])?r[ae][0]:r[ae])}`):["skip-cert-verify"].includes(ae)?r[ae]&&W.push("insecure=1"):["tfo","fast-open"].includes(ae)?r[ae]&&!W.includes("fastopen=1")&&W.push("fastopen=1"):["ports"].includes(ae)?W.push(`mport=${r[ae]}`):["auth-str"].includes(ae)?W.push(`auth=${r[ae]}`):["up"].includes(ae)?W.push(`upmbps=${r[ae]}`):["down"].includes(ae)?W.push(`downmbps=${r[ae]}`):["_obfs"].includes(ae)?W.push(`obfs=${r[ae]}`):["obfs"].includes(ae)?W.push(`obfsParam=${r[ae]}`):["sni"].includes(ae)?W.push(`peer=${r[ae]}`):r[ae]&&!/^_/i.test(ae)&&W.push(`${ye}=${encodeURIComponent(r[ae])}`)}}),n=`hysteria://${r.server}:${r.port}?${W.join("&")}#${encodeURIComponent(r.name)}`;break;case"tuic":if(!r.token||r.token.length===0){let ae=[];Object.keys(r).forEach(ye=>{if(!["name","type","uuid","password","server","port","tls"].includes(ye)){let He=ye.replace(/-/,"_");["alpn"].includes(ye)?r[ye]&&ae.push(`${He}=${encodeURIComponent(Array.isArray(r[ye])?r[ye][0]:r[ye])}`):["skip-cert-verify"].includes(ye)?r[ye]&&ae.push("allow_insecure=1"):["tfo","fast-open"].includes(ye)?r[ye]&&!ae.includes("fast_open=1")&&ae.push("fast_open=1"):["disable-sni","reduce-rtt"].includes(ye)&&r[ye]?ae.push(`${He.replace(/-/g,"_")}=1`):["congestion-controller"].includes(ye)?ae.push(`congestion_control=${r[ye]}`):r[ye]&&!/^_/i.test(ye)&&ae.push(`${He.replace(/-/g,"_")}=${encodeURIComponent(r[ye])}`)}}),n=`tuic://${encodeURIComponent(r.uuid)}:${encodeURIComponent(r.password)}@${r.server}:${r.port}?${ae.join("&")}#${encodeURIComponent(r.name)}`}break;case"anytls":n=FA({...r,uuid:r.password,network:r.network||"tcp"}).replace("vless","anytls");let K=[];Object.keys(r).forEach(ae=>{if(!["name","type","password","server","port","tls"].includes(ae)){let ye=ae.replace(/-/,"_");["alpn"].includes(ae)?r[ae]&&K.push(`${ye}=${encodeURIComponent(Array.isArray(r[ae])?r[ae][0]:r[ae])}`):["skip-cert-verify"].includes(ae)?r[ae]&&K.push("insecure=1"):["udp"].includes(ae)?r[ae]&&K.push("udp=1"):r[ae]&&!/^_|client-fingerprint/i.test(ae)&&["number","string","boolean"].includes(typeof r[ae])&&K.push(`${ye.replace(/-/g,"_")}=${encodeURIComponent(r[ae])}`)}});let z=n.split("?"),X=z[0],se={};z.length>1&&z[1].split("#")[0].split("&").forEach(He=>{let[Zt,It]=He.split("=");Zt&&(se[Zt]=It)}),K.forEach(ae=>{let[ye,He]=ae.split("=");ye&&(se[ye]=He)});let Ie=Object.keys(se).map(ae=>`${ae}=${se[ae]}`).join("&"),be=n.match(/#(.*)$/),Re=be?`#${be[1]}`:"";n=`${X}?${Ie}${Re}`;break;case"wireguard":let Je=[];Object.keys(r).forEach(ae=>{["name","type","server","port","ip","ipv6","private-key"].includes(ae)||(["public-key"].includes(ae)?Je.push(`publickey=${r[ae]}`):["udp"].includes(ae)?r[ae]&&Je.push(`${ae}=1`):r[ae]&&!/^_/i.test(ae)&&Je.push(`${ae}=${encodeURIComponent(r[ae])}`))}),r.ip&&r.ipv6?Je.push(`address=${r.ip}/32,${r.ipv6}/128`):r.ip?Je.push(`address=${r.ip}/32`):r.ipv6&&Je.push(`address=${r.ipv6}/128`),n=`wireguard://${encodeURIComponent(r["private-key"])}@${r.server}:${r.port}/?${Je.join("&")}#${encodeURIComponent(r.name)}`;break}return n}}}var e$=zo();function Wc(){return{type:"ALL",produce:r=>{let n=[];return r.map(s=>{try{n.push(e$.produce(s))}catch(u){G.error(`Cannot produce proxy: ${JSON.stringify(s,null,2)} Reason: ${u}`)}}),Dt.encode(n.join(` `))}}}var _d="QX";function Yc(){let e=(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${_d} does not support network ${t.network} with http upgrade`);switch(t.type){case"ss":return t$(t);case"ssr":return r$(t);case"trojan":return n$(t);case"vmess":return i$(t);case"http":return u$(t);case"socks5":return a$(t);case"vless":return s$(t)}throw new Error(`Platform ${_d} does not support proxy type: ${t.type}`)};return{produce:(t,r,n={})=>{let s=e(t,r,n);if(t.flow&&t.flow!=="xtls-rprx-vision")throw new Error(`Platform ${_d} does not support flow ${t.flow}`);return t["reality-opts"]&&(t["reality-opts"]["public-key"]&&(s=`${s},reality-base64-pubkey=${t["reality-opts"]["public-key"]}`),t["reality-opts"]["short-id"]&&(s=`${s},reality-hex-shortid=${t["reality-opts"]["short-id"]}`)),s}}}function t$(e){let t=new ct(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);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","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(r(`shadowsocks=${e.server}:${e.port}`),r(`,method=${e.cipher}`),r(`,password=${e.password}`),Ci(e)&&(e.tls=!0),oe(e,"plugin")){if(e.plugin==="obfs"){let s=e["plugin-opts"];r(`,obfs=${s.mode}`)}else if(e.plugin==="v2ray-plugin"&&e["plugin-opts"].mode==="websocket")e["plugin-opts"].tls?r(",obfs=wss"):r(",obfs=ws");else throw new Error("plugin is not supported");n(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),n(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path")}return Ci(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"),e._ssr_python_uot?r(",udp-over-tcp=true"):e["udp-over-tcp"]&&(!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?r(",udp-over-tcp=sp.v1"):e["udp-over-tcp-version"]===2&&r(",udp-over-tcp=sp.v2")),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function r$(e){let t=new ct(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 n$(e){let t=new ct(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`trojan=${e.server}:${e.port}`),r(`,password=${e.password}`),oe(e,"network")){if(e.network==="ws")Ci(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 if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`)}return e.network!=="ws"&&Ci(e)&&r(",over-tls=true"),Ci(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 i$(e){let t=new ct(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}`),Ci(e)&&(e.tls=!0),oe(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))e.tls&&r(",obfs=over-tls");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`);let u=e[`${e.network}-opts`]?.path,i=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(u)?u[0]:u}`,`${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 Ci(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")),oe(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 s$(e){if(e.encryption&&e.encryption!=="none")throw new Error("VLESS encryption is not supported");let t=new ct(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}`),Ci(e)&&(e.tls=!0),oe(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))e.tls&&r(",obfs=over-tls");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`);let u=e[`${e.network}-opts`]?.path,i=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(u)?u[0]:u}`,`${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 Ci(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(`,vless-flow=${e.flow}`,"flow"),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 u$(e){let t=new ct(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"),Ci(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),Ci(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 a$(e){let t=new ct(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"),Ci(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),Ci(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 Ci(e){return e.tls}function Xc(){return{type:"ALL",produce:(r,n,s={})=>{let u=r.filter(i=>s["include-unsupported-proxy"]?!0:i.type==="snell"&&i.version>=4||["trust-tunnel","mieru","sudoku","naive"].includes(i.type)||i.encryption&&i.encryption!=="none"&&["vless"].includes(i.type)||["anytls"].includes(i.type)&&i.network&&(!["tcp"].includes(i.network)||["tcp"].includes(i.network)&&i["reality-opts"])?!1:!["xhttp"].includes(i.network)).map(i=>{if(i.type==="vmess"?(oe(i,"aead")&&(i.aead&&(i.alterId=0),delete i.aead),oe(i,"sni")&&(i.servername=i.sni,delete i.sni),oe(i,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(i.cipher)&&(i.cipher="auto")):i.type==="tuic"?(oe(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),oe(i,"tfo")&&!oe(i,"fast-open")&&(i["fast-open"]=i.tfo),(!i.token||i.token.length===0)&&!oe(i,"version")&&(i.version=5)):i.type==="hysteria"?(oe(i,"auth_str")&&!oe(i,"auth-str")&&(i["auth-str"]=i.auth_str),oe(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),oe(i,"tfo")&&!oe(i,"fast-open")&&(i["fast-open"]=i.tfo)):i.type==="hysteria2"?(oe(i,"alpn")&&(i.alpn=Array.isArray(i.alpn)?i.alpn:[i.alpn]),oe(i,"tfo")&&!oe(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"?oe(i,"sni")&&(i.servername=i.sni,delete i.sni):i.type==="ss"&&oe(i,"shadow-tls-password")&&!oe(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 o=i["http-opts"]?.path;oe(i,"http-opts.path")&&!Array.isArray(o)&&(i["http-opts"].path=[o]);let l=i["http-opts"]?.headers?.Host;oe(i,"http-opts.headers.Host")&&!Array.isArray(l)&&(i["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(i.type)&&i.network==="h2"){let o=i["h2-opts"]?.path;oe(i,"h2-opts.path")&&Array.isArray(o)&&(i["h2-opts"].path=o[0]);let l=i["h2-opts"]?.headers?.host;oe(i,"h2-opts.headers.Host")&&!Array.isArray(l)&&(i["h2-opts"].headers.host=[l])}if(["ws"].includes(i.network)){let o=i[`${i.network}-opts`]?.path;if(o){let l=/^(.*?)(?:\?ed=(\d+))?$/,[h,p="",E=""]=l.exec(o);i[`${i.network}-opts`].path=p,E!==""&&(i["ws-opts"]["early-data-header-name"]="Sec-WebSocket-Protocol",i["ws-opts"]["max-early-data"]=parseInt(E,10))}else i[`${i.network}-opts`]=i[`${i.network}-opts`]||{},i[`${i.network}-opts`].path="/"}if(i["plugin-opts"]?.tls&&oe(i,"skip-cert-verify")&&(i["plugin-opts"]["skip-cert-verify"]=i["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trust-tunnel","naive"].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"],oe(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 o in i)(i[o]==null||/^_/i.test(o))&&delete i[o];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"?u:`proxies: `+u.map(i=>" - "+JSON.stringify(i)+` `).join("")}}}var DA="Surfboard";function ch(){return{produce:t=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${DA} does not support network ${t.network} with http upgrade`);switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return o$(t);case"trojan":return c$(t);case"vmess":return l$(t);case"http":return f$(t);case"socks5":return h$(t);case"wireguard-surge":return p$(t)}throw new Error(`Platform ${DA} does not support proxy type: ${t.type}`)}}}function o$(e){let t=new ct(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"),oe(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 c$(e){let t=new ct(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),yA(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 l$(e){let t=new ct(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),yA(t,e),oe(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 f$(e){let t=new ct(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 h$(e){let t=new ct(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 p$(e){let t=new ct(e);return t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.toString()}function yA(e,t){if(oe(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),oe(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),oe(t,"ws-opts.headers"))){let r=t["ws-opts"].headers,n=Object.keys(r).map(s=>{let u=r[s];return["Host"].includes(s)&&(u=`"${u}"`),`${s}:${u}`}).join("|");Cs(n)&&e.append(`,ws-headers=${n}`)}}else{if(["tcp"].includes(t.network)&&t["reality-opts"])throw new Error("reality is unsupported");if(!["tcp"].includes(t.network))throw new Error(`network ${t.network} is unsupported`)}}var d$={ipv4:"ipv4_only",ipv6:"ipv6_only","v4-only":"ipv4_only","v6-only":"ipv6_only","ipv4-prefer":"prefer_ipv4","ipv6-prefer":"prefer_ipv6","prefer-v4":"prefer_ipv4","prefer-v6":"prefer_ipv6"},On=(e,t)=>{let r=d$[e["ip-version"]];e._dns_server&&r&&(t.domain_resolver={server:e._dns_server,strategy:r})},kn=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},Rs=(e,t)=>{["tcp","udp"].includes(e._network)&&(t.network=e._network)},ni=(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},Zi=(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),(e["brutal-opts"]?.up||e["brutal-opts"]?.down)&&(t.multiplex.brutal={enabled:!0},e["brutal-opts"]?.up&&(t.multiplex.brutal.up_mbps=parseInt(`${e["brutal-opts"]?.up}`,10)),e["brutal-opts"]?.down&&(t.multiplex.brutal.down_mbps=parseInt(`${e["brutal-opts"]?.down}`,10))))},Id=(e,t)=>{let r={type:"ws",headers:{}};if(e["ws-opts"]){let{path:n="",headers:s={},"max-early-data":u,"early-data-header-name":i}=e["ws-opts"];if(r.early_data_header_name=i,r.max_early_data=u?parseInt(u,10):void 0,n!==""&&(r.path=`${n}`),Object.keys(s).length>0){let o={};for(let h of Object.keys(s)){let p=s[h];p!==""&&(Array.isArray(p)||(p=[`${p}`]),p.length>0&&(o[h]=p))}let{Host:l}=o;if(l.length===1)for(let h of`Host:${l[0]}`.split(` `)){let[p,E]=h.split(":");E.trim()!==""&&(o[p.trim()]=E.trim().split(","))}r.headers=o}}if(e["ws-headers"]){let n={};for(let u of Object.keys(e["ws-headers"])){let i=e["ws-headers"][u];i!==""&&(Array.isArray(i)||(i=[`${i}`]),i.length>0&&(n[u]=i))}let{Host:s}=n;if(s.length===1)for(let u of`Host:${s[0]}`.split(` `)){let[i,o]=u.split(":");o.trim()!==""&&(n[i.trim()]=o.trim().split(","))}for(let u of Object.keys(n))r.headers[u]=n[u]}if(e["ws-path"]&&e["ws-path"]!==""&&(r.path=`${e["ws-path"]}`),r.path){let n=/^(.*?)(?:\?ed=(\d+))?$/,[s,u="",i=""]=n.exec(r.path);r.path=u,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},SA=(e,t)=>{let r={type:"http",headers:{}};if(e["http-opts"]){let{method:n="",path:s="",headers:u={}}=e["http-opts"];n!==""&&(r.method=n),Array.isArray(s)?r.path=`${s[0]}`:s!==""&&(r.path=`${s}`);for(let i of Object.keys(u)){let o=u[i];if(o!==""){if(i.toLowerCase()==="host"){let l=o;Array.isArray(l)||(l=`${l}`.split(",").map(h=>h.trim())),l.length>0&&(r.host=l);continue}Array.isArray(o)||(o=`${o}`.split(",").map(l=>l.trim())),o.length>0&&(r.headers[i]=o)}}}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(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},bA=(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(u=>u.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},Bd=(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},wu=(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"]}),e._ech&&VE(e._ech)&&(t.tls.ech=e._ech),e._curve_preferences&&Array.isArray(e._curve_preferences)&&(t.tls.curve_preferences=e._curve_preferences),e._fragment&&(t.tls.fragment=!!e._fragment),e._fragment_fallback_delay&&(t.tls.fragment_fallback_delay=e._fragment_fallback_delay),e._record_fragment&&(t.tls.record_fragment=!!e._record_fragment),e._certificate&&(t.tls.certificate=e._certificate),e._certificate_path&&(t.tls.certificate_path=e._certificate_path),e._certificate_public_key_sha256&&(t.tls.certificate_public_key_sha256=e._certificate_public_key_sha256),e._client_certificate&&(t.tls.client_certificate=e._client_certificate),e._client_certificate_path&&(t.tls.client_certificate_path=e._client_certificate_path),e._client_key&&(t.tls.client_key=e._client_key),e._client_key_path&&(t.tls.client_key_path=e._client_key_path),t.tls.enabled||delete t.tls},g$=(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),ni(e,t),kn(e,t),On(e,t),t},m$=(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),ni(e,t),kn(e,t),wu(e,t),On(e,t),t},v$=(e={})=>{let t={tag:e.name,type:"socks",server:e.server,server_port:parseInt(`${e.port}`,10),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={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2}),e["fast-open"]&&(t.udp_fragment=!0),Rs(e,t),ni(e,t),kn(e,t),On(e,t),t},E$=(e={})=>{let t={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:`${e.name}_shadowtls`};e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2});let 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),ni(e,r),kn(e,r),Zi(e.smux,t),On(e,r),{type:"ss-with-st",ssPart:t,stPart:r}},A$=(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={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2}),e["fast-open"]&&(t.udp_fragment=!0),Rs(e,t),ni(e,t),kn(e,t),Zi(e.smux,t),On(e,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},w$=(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),ni(e,t),kn(e,t),Zi(e.smux,t),On(e,t),t},C$=(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"&&Id(e,t),e.network==="h2"&&bA(e,t),e.network==="http"&&SA(e,t),e.network==="grpc"&&Bd(e,t),Rs(e,t),ni(e,t),kn(e,t),wu(e,t),Zi(e.smux,t),On(e,t),t},F$=(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.xudp&&(t.packet_encoding="xudp"),e["fast-open"]&&(t.udp_fragment=!0),e.flow!=null&&(t.flow=e.flow),e.network==="ws"&&Id(e,t),e.network==="h2"&&bA(e,t),e.network==="http"&&SA(e,t),e.network==="grpc"&&Bd(e,t),Rs(e,t),ni(e,t),kn(e,t),Zi(e.smux,t),wu(e,t),On(e,t),t},D$=(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"&&Bd(e,t),e.network==="ws"&&Id(e,t),Rs(e,t),ni(e,t),kn(e,t),wu(e,t),Zi(e.smux,t),On(e,t),t},y$=(e={})=>{let t={tag:e.name,type:"naive",server:e.server,server_port:parseInt(`${e.port}`,10),tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";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={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2});let r=parseInt(`${e["insecure-concurrency"]}`,10);return Number.isInteger(r)&&r>=0&&(t.insecure_concurrency=r),e["extra-headers"]&&(t.extra_headers=e["extra-headers"]),e.quic&&(t.quic=!!e.quic),e["quic-congestion-control"]&&(t.quic_congestion_control=e["quic-congestion-control"]),e["fast-open"]&&(t.udp_fragment=!0),ni(e,t),kn(e,t),wu(e,t),Zi(e.smux,t),On(e,t),t.tls?.insecure&&(G.info("Platform sing-box: insecure is not supported on naive outbound"),delete t.tls.insecure),t},S$=(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["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(n=>{let s=n.replace(/\s*-\s*/g,":");return s.includes(":")?s:`${s}:${s}`})),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}`)&&!`${e.up}`.endsWith("Mbps")?t.up=`${e.up}`:t.up_mbps=parseInt(`${e.up}`,10),r.test(`${e.down}`)&&!`${e.down}`.endsWith("Mbps")?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)),Rs(e,t),wu(e,t),kn(e,t),ni(e,t),Zi(e.smux,t),On(e,t),t},b$=(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=>{let n=r.replace(/\s*-\s*/g,":");return n.includes(":")?n:`${n}:${n}`})),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,Rs(e,t),wu(e,t),ni(e,t),kn(e,t),Zi(e.smux,t),On(e,t),t},_$=(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`),Rs(e,t),ni(e,t),kn(e,t),wu(e,t),Zi(e.smux,t),On(e,t),t},I$=(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`),/^\d+$/.test(e["min-idle-session"])&&(t.min_idle_session=parseInt(`${e["min-idle-session"]}`,10)),Rs(e,t),kn(e,t),wu(e,t),On(e,t),t},B$=(e={})=>{let t=["ip","ipv6"].map(n=>e[n]).map(n=>{if(Br(n))return`${n}/32`;if(Fr(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 u of n.reserved)s.reserved.push(u);else delete s.reserved;n["pre-shared-key"]&&(s.pre_shared_key=n["pre-shared-key"]),r.peers.push(s)}}return Rs(e,r),ni(e,r),kn(e,r),Zi(e.smux,r),On(e,r),r};function lh(){return{type:"ALL",produce:(r,n,s={})=>{let u=[];return wi().produce(r,"internal",{"include-unsupported-proxy":!0}).map(i=>{try{switch(i.type){case"ssh":u.push(g$(i));break;case"http":u.push(m$(i));break;case"socks5":if(i.tls)throw new Error(`Platform sing-box does not support proxy type: ${i.type} with tls`);u.push(v$(i));break;case"ss":if(i.plugin==="shadow-tls"){let{ssPart:o,stPart:l}=E$(i);u.push(o),u.push(l)}else u.push(A$(i));break;case"ssr":if(s["include-unsupported-proxy"])u.push(w$(i));else throw new Error(`Platform sing-box does not support proxy type: ${i.type}`);break;case"vmess":if(!i.network||["tcp","ws","grpc","h2","http"].includes(i.network))u.push(C$(i));else throw new Error(`Platform sing-box does not support proxy type: ${i.type} with network ${i.network}`);break;case"vless":if(i.encryption&&i.encryption!=="none")throw new Error("VLESS encryption is not supported");if(!i.flow||["xtls-rprx-vision"].includes(i.flow))u.push(F$(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)u.push(D$(i));else throw new Error(`Platform sing-box does not support proxy type: ${i.type} with flow ${i.flow}`);break;case"naive":u.push(y$(i));break;case"hysteria":u.push(S$(i));break;case"hysteria2":u.push(b$(i,s["include-unsupported-proxy"]));break;case"tuic":if(!i.token||i.token.length===0)u.push(_$(i));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":u.push(B$(i));break;case"anytls":u.push(I$(i));break;default:throw new Error(`Platform sing-box does not support proxy type: ${i.type}`)}}catch(o){G.error(o.message??o)}}),n==="internal"?u:JSON.stringify({outbounds:u},null,2)}}}function fh(){return{type:"ALL",produce:(r,n,s={})=>{let u=r.filter(i=>!["http","https","socks5","ss","trojan","hysteria2","vless","vmess","tuic","wireguard"].includes(i.type)||i.type==="ss"&&(i.plugin==="obfs"&&!["http","tls"].includes(i["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(i.cipher))||i.type==="vmess"&&!["http","ws","tcp"].includes(i.network)&&i.network||i.type==="trojan"&&!["http","ws","tcp"].includes(i.network)&&i.network||i.type==="vless"&&!["http","ws","tcp"].includes(i.network)&&i.network||i.type==="tuic"&&i.token&&i.token.length!==0?!1:!(["ws"].includes(i.network)&&i["ws-opts"]?.["v2ray-http-upgrade"])).map(i=>{let o={...i},l;i.tls&&!i.sni&&(i.sni=i.server);let h=i.prev_hop||i["underlying-proxy"]||i["dialer-proxy"]||i.detour;if(i.type==="http")i={type:i.tls?"https":"http",name:i.name,server:i.server,port:i.port,username:i.username,password:i.password,tfo:i.tfo||i["fast-open"],next_hop:i.next_hop,...i.tls?{sni:i.sni,skip_tls_verify:i["skip-cert-verify"]}:{}};else if(i.type==="socks5")i={type:"socks5",name:i.name,server:i.server,port:i.port,username:i.username,password:i.password,tfo:i.tfo||i["fast-open"],udp_relay:i.udp||i.udp_relay||i.udp_relay,next_hop:i.next_hop};else if(i.type==="ss")i={type:"shadowsocks",name:i.name,method:i.cipher==="chacha20-ietf-poly1305"?"chacha20-poly1305":i.cipher,server:i.server,port:i.port,password:i.password,tfo:i.tfo||i["fast-open"],udp_relay:i.udp||i.udp_relay||i.udp_relay,next_hop:i.next_hop},o.plugin==="obfs"&&(i.obfs=o["plugin-opts"].mode,i.obfs_host=o["plugin-opts"].host,i.obfs_uri=o["plugin-opts"].path);else if(i.type==="hysteria2")i={type:"hysteria2",name:i.name,server:i.server,port:i.port,auth:i.password,tfo:i.tfo||i["fast-open"],udp_relay:i.udp||i.udp_relay||i.udp_relay,next_hop:i.next_hop,sni:i.sni,skip_tls_verify:i["skip-cert-verify"],port_hopping:i.ports,port_hopping_interval:i["hop-interval"]},o["obfs-password"]&&o.obfs=="salamander"&&(i.obfs="salamander",i.obfs_password=o["obfs-password"]);else if(i.type==="tuic")i={type:"tuic",name:i.name,server:i.server,port:i.port,uuid:i.uuid,password:i.password,next_hop:i.next_hop,sni:i.sni,alpn:Array.isArray(i.alpn)?i.alpn:[i.alpn||"h3"],skip_tls_verify:i["skip-cert-verify"],port_hopping:i.ports,port_hopping_interval:i["hop-interval"]};else if(i.type==="trojan")i.network==="ws"&&(i.websocket={path:i["ws-opts"]?.path,host:i["ws-opts"]?.headers?.Host}),i={type:"trojan",name:i.name,server:i.server,port:i.port,password:i.password,tfo:i.tfo||i["fast-open"],udp_relay:i.udp||i.udp_relay||i.udp_relay,next_hop:i.next_hop,sni:i.sni,skip_tls_verify:i["skip-cert-verify"],websocket:i.websocket};else if(i.type==="vmess"){let p=i.cipher;p&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(p)&&(p="auto"),i.network==="ws"?i.transport={[i.tls?"wss":"ws"]:{path:i["ws-opts"]?.path,headers:{Host:i["ws-opts"]?.headers?.Host},sni:i.tls?i.sni:void 0,skip_tls_verify:i.tls?i["skip-cert-verify"]:void 0}}:i.network==="http"?i.transport={http1:{method:i["http-opts"]?.method,path:Array.isArray(i["http-opts"]?.path)?i["http-opts"]?.path[0]:i["http-opts"]?.path,headers:{Host:Array.isArray(i["http-opts"]?.headers?.Host)?i["http-opts"]?.headers?.Host[0]:i["http-opts"]?.headers?.Host},skip_tls_verify:i["skip-cert-verify"]}}:i.network==="h2"?i.transport={http2:{method:i["h2-opts"]?.method,path:Array.isArray(i["h2-opts"]?.path)?i["h2-opts"]?.path[0]:i["h2-opts"]?.path,headers:{Host:Array.isArray(i["h2-opts"]?.headers?.Host)?i["h2-opts"]?.headers?.Host[0]:i["h2-opts"]?.headers?.Host},skip_tls_verify:i["skip-cert-verify"]}}:(i.network==="tcp"||!i.network)&&i.tls&&(i.transport={tls:{sni:i.tls?i.sni:void 0,skip_tls_verify:i.tls?i["skip-cert-verify"]:void 0}});let E;(oe(i,"aead")&&!i.aead||i.alterId!==0)&&(E=!0),i={type:"vmess",name:i.name,server:i.server,port:i.port,user_id:i.uuid,security:p,tfo:i.tfo||i["fast-open"],legacy:E,udp_relay:i.udp||i.udp_relay||i.udp_relay,next_hop:i.next_hop,transport:i.transport}}else if(i.type==="vless"){if(i.encryption&&i.encryption!=="none")throw new Error("VLESS encryption is not supported");if(i.network==="ws")i.transport={[i.tls?"wss":"ws"]:{path:i["ws-opts"]?.path,headers:{Host:i["ws-opts"]?.headers?.Host},sni:i.tls?i.sni:void 0,skip_tls_verify:i.tls?i["skip-cert-verify"]:void 0}};else if(i.network==="http")i.transport={http:{method:i["http-opts"]?.method,path:Array.isArray(i["http-opts"]?.path)?i["http-opts"]?.path[0]:i["http-opts"]?.path,headers:{Host:Array.isArray(i["http-opts"]?.headers?.Host)?i["http-opts"]?.headers?.Host[0]:i["http-opts"]?.headers?.Host},skip_tls_verify:i["skip-cert-verify"]}};else if(i.network==="tcp"||!i.network){let p;if((i["reality-opts"]?.["short-id"]||i["reality-opts"]?.["public-key"])&&(p={short_id:i["reality-opts"]["short-id"],public_key:i["reality-opts"]["public-key"]}),i.transport={[i.tls?"tls":"tcp"]:{sni:i.tls?i.sni:void 0,skip_tls_verify:i.tls?i["skip-cert-verify"]:void 0,reality:p}},typeof i.flow<"u"&&!["xtls-rprx-vision"].includes(i.flow))throw new Error(`VLESS flow(${i.flow}) is not supported`);l=i.flow}i={type:"vless",name:i.name,server:i.server,port:i.port,user_id:i.uuid,security:i.cipher,tfo:i.tfo||i["fast-open"],udp_relay:i.udp||i.udp_relay||i.udp_relay,next_hop:i.next_hop,transport:i.transport,flow:l}}else i.type==="wireguard"&&(Array.isArray(i.peers)&&i.peers.length>0&&(i.server=i.peers[0].server,i.port=i.peers[0].port,i.ip=i.peers[0].ip,i.ipv6=i.peers[0].ipv6,i["public-key"]=i.peers[0]["public-key"],i["preshared-key"]=i.peers[0]["pre-shared-key"],i["allowed-ips"]=i.peers[0]["allowed-ips"],i.reserved=i.peers[0].reserved),i={type:"wireguard",name:i.name,local_ipv4:i.ip,local_ipv6:i.ipv6,server:i.server,port:i.port,private_key:i["private-key"],peer_public_key:i["public-key"],preshared_key:i["preshared-key"],reserved:i.reserved?Array.isArray(i.reserved)?i.reserved:i.reserved.split(/\s*\/\s*/).map(p=>p.trim()).filter(p=>p.length>0):void 0,dns_servers:i.dns?Array.isArray(i.dns)?i.dns:i.dns.split(/\s*,\s*/).map(p=>p.trim()).filter(p=>p.length>0):void 0,mtu:i.mtu,keepalive:i.keepalive});if(["http","https","socks5","ss","trojan","vless","vmess"].includes(o.type)){if(oe(o,"shadow-tls-password")){if(o["shadow-tls-version"]!=3)throw new Error(`shadow-tls version ${o["shadow-tls-version"]} is not supported`);i.shadow_tls={password:o["shadow-tls-password"],sni:o["shadow-tls-sni"]}}else if(["shadow-tls"].includes(o.plugin)&&o["plugin-opts"]){if(o["plugin-opts"].version!=3)throw new Error(`shadow-tls version ${o["plugin-opts"].version} is not supported`);i.shadow_tls={password:o["plugin-opts"].password,sni:o["plugin-opts"].host}}}if(["socks5","ss","trojan","vless","vmess","wireguard","tuic","hysteria2"].includes(o.type)&&(["on","true",!0,"1",1].includes(o["block-quic"])?i.block_quic=!0:["off","false",!1,"0",0].includes(o["block-quic"])&&(i.block_quic=!1)),["ss"].includes(o.type)&&i.shadow_tls&&o["udp-port"]>0&&o["udp-port"]<=65535&&(i.udp_port=o["udp-port"]),delete i.subName,delete i.collectionName,delete i.id,delete i.resolved,delete i["no-resolve"],i.transport){for(let p in i.transport)(Object.keys(i.transport[p]).length===0||Object.values(i.transport[p]).every(E=>E==null))&&delete i.transport[p];Object.keys(i.transport).length===0&&delete i.transport}if(n!=="internal")for(let p in i)(i[p]==null||/^_/i.test(p))&&delete i[p];return{[i.type]:{...i,type:void 0,prev_hop:h}}});return n==="internal"?u:`proxies: `+u.map(i=>" - "+JSON.stringify(i)+` `).join("")}}}function _A(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var hh={qx:Yc(),QX:Yc(),QuantumultX:Yc(),surge:Go(),Surge:Go(),SurgeMac:yd(),Loon:bd(),Clash:Sd(),meta:wi(),clashmeta:wi(),"clash.meta":wi(),"Clash.Meta":wi(),ClashMeta:wi(),mihomo:wi(),Mihomo:wi(),uri:zo(),URI:zo(),v2:Wc(),v2ray:Wc(),V2Ray:Wc(),json:_A(),JSON:_A(),stash:oh(),Stash:oh(),shadowrocket:Xc(),Shadowrocket:Xc(),ShadowRocket:Xc(),surfboard:ch(),Surfboard:ch(),singbox:lh(),"sing-box":lh(),egern:fh(),Egern:fh()};var Tw=jr(nl()),L7=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 = (anytls/shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/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"; // Surfboard 与 Surge 默认不一致, 不管 Surfboard https://getsurfboard.com/docs/profile-format/proxy/external-proxy/vmess if (proxy.aead) { proxy.alterId = 0; } else { proxy.alterId = 1; } 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/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/salamander_password/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/fast_open/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(); } anytls = tag equals "anytls" address (passwordk/reuse/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/block_quic/others)* { proxy.type = "anytls"; proxy.tls = true; } trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/reuse/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/block_quic/others)* { proxy.type = "trust-tunnel"; proxy.tls = true; } 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.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } password = comma match:[^,]+ { proxy.password = match.join("").replace(/^"(.*)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } 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("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } 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().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }) obfs["ws-headers"] = result; } ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } 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(""); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,Yd;function Nn(){return Yd||(Yd=Tw.generate(L7)),Yd}var Ow=jr(nl()),U7=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/block_quic/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/block_quic/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_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/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_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/flow/public_key/short_id/block_quic/others)* { proxy.type = "vless"; handleTransport(); } trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "trojan"; handleTransport(); } hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/salamander_password/ecn/ip_mode/block_quic/others)* { proxy.type = "hysteria2"; } https = tag equals "https"i address (username password)? (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "http"; proxy.tls = true; } http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "http"; } socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/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_name = comma sni:("tls-name") equals host:domain { proxy.sni = host; } sni = comma sni:("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'; } block_quic = comma "block-quic" equals flag:bool { if(flag) proxy["block-quic"] = "on"; else proxy["block-quic"] = "off"; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,Xd;function Ts(){return Xd||(Xd=Ow.generate(U7)),Xd}var kw=jr(nl()),j7=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/reality_base64_pubkey/reality_hex_shortid/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_new/fast_open/tag/server_check_url/reality_base64_pubkey/reality_hex_shortid/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/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead === false) { proxy.alterId = 1; } else { 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/reality_base64_pubkey/reality_hex_shortid/vless_flow/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/reality_base64_pubkey/reality_hex_shortid/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/reality_base64_pubkey/reality_hex_shortid/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"); } udp_over_tcp_new = comma "udp-over-tcp" equals param:$[^=,]+ { if (param === "sp.v1") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 1; } else if (param === "sp.v2") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; } else if (param === "true") { proxy["_ssr_python_uot"] = true; } else { throw new Error("Invalid value for udp-over-tcp"); } } 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; } reality_base64_pubkey = comma "reality-base64-pubkey" equals param:$[^=,]+ { $set(proxy, "reality-opts.public-key", param); } reality_hex_shortid = comma "reality-hex-shortid" equals param:$[^=,]+ { $set(proxy, "reality-opts.short-id", param); } vless_flow = comma "vless-flow" equals param:$[^=,]+ { proxy["flow"] = 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" } `,Jd;function Fu(){return Jd||(Jd=kw.generate(j7)),Jd}var Nw=jr(nl()),H7=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); } `,Zd;function Qd(){return Zd||(Zd=Nw.generate(H7)),Zd}var n1=jr(r1());var Ma=jr(ih());function xw(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 M7(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[s,u,i,o,l,h,p,E,d]=n.match(/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/);if(p)p=parseInt(p,10);else{if(i)p=443;else if(u==="http")p=80;else throw G.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);G.info(`port is not present in line: ${n}, set to ${p}`)}return{name:d!=null?decodeURIComponent(d):`${u} ${h}:${p}`,type:u,tls:!!i,server:h,port:p,username:o!=null?decodeURIComponent(o):void 0,password:l!=null?decodeURIComponent(l):void 0}}}}function q7(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[s,u,i,o,l,h,p]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(l)l=parseInt(l,10);else throw G.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let E,d;if(i){let w=Dt.decode(decodeURIComponent(i)).split(":");E=w[0],d=w[1]}return{name:p!=null?decodeURIComponent(p):`${u} ${o}:${l}`,type:"socks5",server:o,port:l,username:E,password:d}}}}function V7(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let s=n.split("ss://")[1],u=n.split("#")[1],i={type:"ss"};s=s.split("#")[0];let o=s.match(/@([^/?]*)(\/|\?|$)/),l=decodeURIComponent(s.split("@")[0]),h;l?.startsWith("2022-blake3-")?h=l:h=Dt.decode(l);let p="";if(o)s.includes("?")&&(p=s.match(/(\?.*)$/)[1]);else{if(s.includes("?")){let A=s.match(/^(.*)(\?.*)$/);s=A[1],p=A[2]}if(s=Dt.decode(s),p){if(/(&|\?)v2ray-plugin=/.test(p)){let C=p.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];C&&(i.plugin="v2ray-plugin",i["plugin-opts"]=JSON.parse(Dt.decode(C)))}s=`${s}${p}`}h=s.match(/(^.*)@/)?.[1],o=s.match(/@([^/@]*)(\/|$)/)}let E={};for(let A of p.replace(/^\?/,"").split("&"))if(A){let[C,S]=A.split("="),I=S;I=decodeURIComponent(S),E[C]=I}if(i.tls=E.security&&E.security!=="none",i["skip-cert-verify"]=!!E.allowInsecure,i.sni=E.sni||E.peer,i["client-fingerprint"]=E.fp,i.alpn=E.alpn?decodeURIComponent(E.alpn).split(","):void 0,E.ws&&(i.network="ws",Ma.default.set(i,"ws-opts.path",E.wspath)),E.type){let A;if(i.network=E.type,i.network==="httpupgrade"&&(i.network="ws",A=!0),["grpc"].includes(i.network)?i[i.network+"-opts"]={"grpc-service-name":E.serviceName,"_grpc-type":E.mode,"_grpc-authority":E.authority}:(E.path&&Ma.default.set(i,i.network+"-opts.path",decodeURIComponent(E.path)),E.host&&Ma.default.set(i,i.network+"-opts.headers.Host",decodeURIComponent(E.host)),A&&(Ma.default.set(i,i.network+"-opts.v2ray-http-upgrade",!0),Ma.default.set(i,i.network+"-opts.v2ray-http-upgrade-fast-open",!0))),["reality"].includes(E.security)){let C={};E.pbk&&(C["public-key"]=E.pbk),E.sid&&(C["short-id"]=E.sid),E.spx&&(C["_spider-x"]=E.spx),E.mode&&(i._mode=E.mode),E.extra&&(i._extra=E.extra),Object.keys(C).length>0&&Ma.default.set(i,E.security+"-opts",C)}}i.udp=!!E.udp;let d=o[1],f=d.lastIndexOf(":");i.server=d.substring(0,f),i.port=`${d.substring(f+1)}`.match(/\d+/)?.[0];let w=h.match(/(^.*?):(.*$)/);i.cipher=w?.[1],i.password=w?.[2];let g=s.match(/[?&]plugin=([^&]+)/),F=s.match(/[?&]shadow-tls=([^&]+)/);if(g){let A=("plugin="+decodeURIComponent(g[1])).split(";"),C={};for(let S of A){let[I,_]=S.split("=");I&&(C[I]=_||!0)}switch(C.plugin){case"obfs-local":case"simple-obfs":i.plugin="obfs",i["plugin-opts"]={mode:C.obfs,host:Jt(C["obfs-host"])};break;case"v2ray-plugin":i.plugin="v2ray-plugin",i["plugin-opts"]={mode:"websocket",host:Jt(C["obfs-host"]),path:Jt(C.path),tls:Gu(C.tls)};break;case"shadow-tls":{i.plugin="shadow-tls";let S=Jt(C.version);i["plugin-opts"]={host:Jt(C.host),password:Jt(C.password),version:S?parseInt(S,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${C.plugin}`)}}if(F){let A=JSON.parse(Dt.decode(F[1])),C=Jt(A.version),S=Jt(A.address),I=Jt(A.port);i.plugin="shadow-tls",i["plugin-opts"]={host:Jt(A.host),password:Jt(A.password),version:C?parseInt(C,10):void 0},S&&(i.server=S),I&&(i.port=parseInt(I,10))}return/(&|\?)uot=(1|true)/i.test(p)&&(i["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(p)&&(i.tfo=!0),u!=null&&(u=decodeURIComponent(u)),i.name=u??`SS ${i.server}:${i.port}`,i}}}function K7(){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 u=n.substring(0,s),i=u.substring(0,u.lastIndexOf(":")),o=u.substring(u.lastIndexOf(":")+1),l=n.substring(s+1).split("/?")[0].split(":"),h={type:"ssr",server:i,port:o,protocol:l[0],cipher:l[1],obfs:l[2],password:Dt.decode(l[3])},p={};if(n=n.split("/?")[1].split("&"),n.length>1)for(let E of n){let[d,f]=E.split("=");f=f.trim(),f.length>0&&f!=="(null)"&&(p[d]=f)}return h={...h,name:p.remarks?Dt.decode(p.remarks):h.server,"protocol-param":Jt(Dt.decode(p.protoparam||"").replace(/\s/g,"")),"obfs-param":Jt(Dt.decode(p.obfsparam||"").replace(/\s/g,""))},h}}}function G7(){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 u=s.split(",").map(l=>l.trim()),i={};for(let l of u)if(l.indexOf("=")!==-1){let[h,p]=l.split("=");i[h.trim()]=p.trim()}let o={name:u[0].split("=")[0].trim(),type:"vmess",server:u[1],port:u[2],cipher:Jt(u[3],"auto"),uuid:u[4].match(/^"(.*)"$/)[1],tls:i.obfs==="wss",udp:Gu(i["udp-relay"]),tfo:Gu(i["fast-open"]),"skip-cert-verify":Lo(i["tls-verification"])?!i["tls-verification"]:void 0};if(Lo(i.obfs))if(i.obfs==="ws"||i.obfs==="wss"){o.network="ws",o["ws-opts"].path=(Jt(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]),Cs(l)&&(o["ws-opts"].headers={Host:l})}else throw new Error(`Unsupported obfs: ${i.obfs}`);return o}else{let u={};try{u=JSON.parse(s)}catch{let[E,d,f]=/(^[^?]+?)\/?\?(.*)$/.exec(n);s=Dt.decode(d);for(let S of f.split("&")){let[I,_]=S.split("="),L=_;L=decodeURIComponent(_),L.indexOf(",")===-1?u[I]=L:u[I]=L.split(",")}let[w,g,F,A,C]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(s);u.scy=g,u.id=F,u.port=C,u.add=A}let i=u.add,o=parseInt(Gu(u.port),10),l={name:u.ps??u.remarks??u.remark??`VMess ${i}:${o}`,type:"vmess",server:i,port:o,cipher:["auto","aes-128-gcm","chacha20-poly1305","none"].includes(u.scy)?u.scy:"auto",uuid:u.id,alterId:parseInt(Gu(u.aid??u.alterId,0),10),tls:["tls",!0,1,"1"].includes(u.tls),"skip-cert-verify":Lo(u.verify_cert)?!u.verify_cert:void 0};!l["skip-cert-verify"]&&Lo(u.allowInsecure)&&(l["skip-cert-verify"]=/(TRUE)|1/i.test(u.allowInsecure)),l.tls&&(u.sni&&u.sni!==""?l.sni=u.sni:u.peer&&u.peer!==""&&(l.sni=u.peer));let h=!1;if(u.net==="ws"||u.obfs==="websocket"?l.network="ws":["http"].includes(u.net)||["http"].includes(u.obfs)||["http"].includes(u.type)?l.network="http":["grpc","kcp","quic"].includes(u.net)?l.network=u.net:u.net==="httpupgrade"||l.network==="httpupgrade"?(l.network="ws",h=!0):(u.net==="h2"||l.network==="h2")&&(l.network="h2"),l.network){let p=u.host??u.obfsParam;try{let f=JSON.parse(p)?.Host;f&&(p=f)}catch{}let E=u.path;if(["ws"].includes(l.network)&&(E=E||"/"),l.network==="http"&&(p&&(p=p.split(",").map(d=>d.trim()),p=Array.isArray(p)?p[0]:p),E?E=Array.isArray(E)?E[0]:E:E="/"),E||p||["kcp","quic"].includes(l.network))if(["grpc"].includes(l.network))l[`${l.network}-opts`]={"grpc-service-name":Jt(E),"_grpc-type":Jt(u.type),"_grpc-authority":Jt(u.authority)};else if(["kcp","quic"].includes(l.network))l[`${l.network}-opts`]={[`_${l.network}-type`]:Jt(u.type),[`_${l.network}-host`]:Jt(Jt(p)),[`_${l.network}-path`]:Jt(E)};else{let d={path:Jt(E),headers:{Host:Jt(p)}};h&&(d["v2ray-http-upgrade"]=!0,d["v2ray-http-upgrade-fast-open"]=!0),l[`${l.network}-opts`]=d}else delete l.network}return l["client-fingerprint"]=u.fp,l.alpn=u.alpn?u.alpn.split(","):void 0,l}}}}function Lw(){return{name:"URI VLESS Parser",test:n=>/^vless:\/\//.test(n),parse:n=>{n=n.split("vless://")[1];let s,u=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);if(!u){let[F,A,C]=/^(.*?)(\?.*?$)/.exec(n);n=`${Dt.decode(A)}${C}`,u=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),s=!0}let[i,o,l,h,p,E="",d]=u;s&&(o=o.replace(/^.*?:/g,"")),h=parseInt(`${h}`,10),o=decodeURIComponent(o),d!=null&&(d=decodeURIComponent(d));let f={type:"vless",name:d,server:l,port:h,uuid:o},w={};for(let F of E.split("&"))if(F){let[A,C]=F.split("="),S=C;S=decodeURIComponent(C),w[A]=S}if(f.name=d??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 F=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][w.xtls];F&&(f.flow=F)}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),f._echConfigList=Gu(w.ech),f._pcs=Gu(w.pcs),f._h2=/(TRUE)|1/i.test(w.h2),["reality"].includes(w.security)){let F={};w.pbk&&(F["public-key"]=w.pbk),w.sid&&(F["short-id"]=w.sid),w.spx&&(F["_spider-x"]=w.spx),Object.keys(F).length>0&&(f[`${w.security}-opts`]=F)}let g=!1;if(f.network=w.type,f.network==="tcp"&&w.headerType==="http"?f.network="http":f.network==="httpupgrade"&&(f.network="ws",g=!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 F={},A=w.host??w.obfsParam;if(A)if(w.obfsParam)try{let C=JSON.parse(A);F.headers=C}catch{F.headers={Host:A}}else F.headers={Host:A};w.serviceName?(F[`${f.network}-service-name`]=w.serviceName,["grpc"].includes(f.network)&&w.authority&&(F["_grpc-authority"]=w.authority)):s&&w.path&&(["ws","http","h2"].includes(f.network)||(F[`${f.network}-service-name`]=w.path,delete w.path)),w.path&&(F.path=w.path),["grpc"].includes(f.network)&&(F["_grpc-type"]=w.mode||"gun"),g&&(F["v2ray-http-upgrade"]=!0,F["v2ray-http-upgrade-fast-open"]=!0),Object.keys(F).length>0&&(f[`${f.network}-opts`]=F),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 w.encryption&&(f.encryption=w.encryption),w.pqv&&(f._pqv=w.pqv),f}}}function z7(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{let s=Lw().parse(n.replace("anytls","vless"));n=n.split(/anytls:\/\//)[1];let[u,i,o,l,h="",p]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);i=decodeURIComponent(i),l=parseInt(`${l}`,10),isNaN(l)&&(l=443),i=decodeURIComponent(i),p!=null&&(p=decodeURIComponent(p)),p=p??`AnyTLS ${o}:${l}`;let E={...s,uuid:void 0,type:"anytls",name:p,server:o,port:l,password:i};for(let d of h.split("&"))if(d){let[f,w]=d.split("=");f=f.replace(/_/g,"-"),w=decodeURIComponent(w),["alpn"].includes(f)?E[f]=w?w.split(","):void 0:["insecure"].includes(f)?E["skip-cert-verify"]=/(TRUE)|1/i.test(w):["udp"].includes(f)?E[f]=/(TRUE)|1/i.test(w):Object.keys(E).includes(f)||(E[f]=w)}return["tcp"].includes(E.network)&&!E["reality-opts"]&&(delete E.network,delete E.security),E}}}function W7(){return{name:"URI Hysteria2 Parser",test:n=>/^(hysteria2|hy2):\/\//.test(n),parse:n=>{n=n.split(/(hysteria2|hy2):\/\//)[2];let s,[u,i,o,l,h,p,E,d,f,w,g="",F]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(h)?(h=parseInt(`${h}`,10),isNaN(h)&&(h=443)):h?(s=h,h=Uc(s)):h=443,i=decodeURIComponent(i),F!=null&&(F=decodeURIComponent(F)),F=F??`Hysteria2 ${o}:${h}`;let A={type:"hysteria2",name:F,server:o,port:h,ports:s,password:i},C={};for(let _ of g.split("&"))if(_){let[L,M]=_.split("="),b=M;b=decodeURIComponent(M),C[L]=b}A.sni=C.sni,!A.sni&&C.peer&&(A.sni=C.peer),C.obfs&&C.obfs!=="none"&&(A.obfs=C.obfs),C.mport&&(A.ports=C.mport),A["obfs-password"]=C["obfs-password"],A["skip-cert-verify"]=/(TRUE)|1/i.test(C.insecure),A.tfo=/(TRUE)|1/i.test(C.fastopen),A["tls-fingerprint"]=C.pinSHA256;let S=C["hop-interval"]||C.hop_interval;/^\d+$/.test(S)&&(A["hop-interval"]=parseInt(`${S}`,10));let I=C.keepalive;return/^\d+$/.test(I)&&(A.keepalive=parseInt(`${I}`,10)),A}}}function Y7(){return{name:"URI Hysteria Parser",test:n=>/^(hysteria|hy):\/\//.test(n),parse:n=>{n=n.split(/(hysteria|hy):\/\//)[2];let[s,u,i,o,l,h="",p]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);o=parseInt(`${o}`,10),isNaN(o)&&(o=443),p!=null&&(p=decodeURIComponent(p)),p=p??`Hysteria ${u}:${o}`;let E={type:"hysteria",name:p,server:u,port:o},d={};for(let f of h.split("&"))if(f){let[w,g]=f.split("=");w=w.replace(/_/,"-"),g=decodeURIComponent(g),["alpn"].includes(w)?E[w]=g?g.split(","):void 0:["insecure"].includes(w)?E["skip-cert-verify"]=/(TRUE)|1/i.test(g):["auth"].includes(w)?E["auth-str"]=g:["mport"].includes(w)?E.ports=g:["obfsParam"].includes(w)?E.obfs=g:["upmbps"].includes(w)?E.up=g:["downmbps"].includes(w)?E.down=g:["obfs"].includes(w)?E._obfs=g||"":["fast-open","peer"].includes(w)?d[w]=g:Object.keys(E).includes(w)||(E[w]=g)}return!E.sni&&d.peer&&(E.sni=d.peer),!E["fast-open"]&&d.fastopen&&(E["fast-open"]=!0),E.protocol||(E.protocol="udp"),E}}}function X7(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[s,u,i,o,l="",h]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);u=decodeURIComponent(u);let[p,...E]=u.split(":"),d=E.join(":");o=parseInt(`${o}`,10),isNaN(o)&&(o=443),d=decodeURIComponent(d),h!=null&&(h=decodeURIComponent(h)),h=h??`TUIC ${i}:${o}`;let f={type:"tuic",name:h,server:i,port:o,password:d,uuid:p};for(let w of l.split("&"))if(w){let[g,F]=w.split("=");g=g.replace(/_/g,"-"),F=decodeURIComponent(F),["alpn"].includes(g)?f[g]=F?F.split(","):void 0:["allow-insecure","insecure"].includes(g)?f["skip-cert-verify"]=/(TRUE)|1/i.test(F):["fast-open"].includes(g)?f.tfo=!0:["disable-sni","reduce-rtt"].includes(g)?f[g]=/(TRUE)|1/i.test(F):g==="congestion-control"?(f["congestion-controller"]=F,delete f[g]):Object.keys(f).includes(g)||(f[g]=F)}return f}}}function J7(){return{name:"URI WireGuard Parser",test:n=>/^(wireguard|wg):\/\//.test(n),parse:n=>{n=n.split(/(wireguard|wg):\/\//)[2];let[s,u,i,o,l,h,p,E="",d]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);h=parseInt(`${h}`,10),isNaN(h)&&(h=51820),i=decodeURIComponent(i),d!=null&&(d=decodeURIComponent(d)),d=d??`WireGuard ${o}:${h}`;let f={type:"wireguard",name:d,server:o,port:h,"private-key":i,udp:!0};for(let w of E.split("&"))if(w){let[g,F]=w.split("=");if(g=g.replace(/_/,"-"),F=decodeURIComponent(F),["reserved"].includes(g)){let A=F.split(",").map(C=>parseInt(C.trim(),10)).filter(C=>Number.isInteger(C));A.length===3&&(f[g]=A)}else if(["address","ip"].includes(g))F.split(",").map(A=>{let C=A.trim().replace(/\/\d+$/,"").replace(/^\[/,"").replace(/\]$/,"");Br(C)?f.ip=C:Fr(C)&&(f.ipv6=C)});else if(["mtu"].includes(g)){let A=parseInt(F.trim(),10);Number.isInteger(A)&&(f[g]=A)}else/publickey/i.test(g)?f["public-key"]=F:/privatekey/i.test(g)?f["private-key"]=F:["udp"].includes(g)?f[g]=/(TRUE)|1/i.test(F):[...Object.keys(f),"flag"].includes(g)||(f[g]=F)}return f}}}function Z7(){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,o]=n.split(/#(.+)/,2),h=Qd().parse(i);if(Cs(o))try{h.name=decodeURIComponent(o)}catch(p){console.log(p)}return h}}}function Q7(){return{name:"Clash Parser",test:n=>{let s;try{s=n1.default.parse(n)}catch{s=ms.parse(n)}return!!s?.type},parse:n=>{let s;try{s=n1.default.parse(n)}catch{s=ms.parse(n)}if(!["trust-tunnel","naive","anytls","mieru","sudoku","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 eP(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>Fu().parse(n)}}function tP(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>Fu().parse(n)}}function rP(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>Fu().parse(n)}}function nP(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>Fu().parse(n)}}function iP(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>Fu().parse(n)}}function sP(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>Fu().parse(n)}}function uP(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>Fu().parse(n)}}function aP(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>Ts().parse(n)}}function oP(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>Ts().parse(n)}}function cP(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>Ts().parse(n)}}function lP(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>Ts().parse(n)}}function fP(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>Ts().parse(n)}}function hP(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>Ts().parse(n)}}function pP(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>Ts().parse(n)}}function dP(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>Ts().parse(n)}}function gP(){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 u=n.match(/,\s*?peers\s*?=\s*?\[\s*?\{\s*?(.+?)\s*?\}\s*?\]/i)?.[1],i=u.match(/(,|^)\s*?endpoint\s*?=\s*?"?(.+?):(\d+)"?\s*?(,|$)/i),o=i?.[2],l=parseInt(i?.[3],10),h=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];h&&(h=parseInt(h,10));let p=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];p&&(p=parseInt(p,10));let E=u.match(/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i)?.[2];E&&(E=JSON.parse(E));let d,f=n.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],w=n.match(/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];(f||w)&&(d=[],f&&d.push(f),w&&d.push(w));let g=u.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]?.split(",").map(_=>_.trim()),F=u.match(/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],A=n.match(/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],C=n.match(/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],S=u.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],I={type:"wireguard",name:s,server:o,port:l,ip:A,ipv6:C,"private-key":n.match(/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],"public-key":S,mtu:h,keepalive:p,reserved:E,"allowed-ips":g,"preshared-key":F,dns:d,udp:!0,peers:[{server:o,port:l,ip:A,ipv6:C,"public-key":S,"pre-shared-key":F,"allowed-ips":g,reserved:E}]};return Array.isArray(I.dns)&&I.dns.length>0&&(I["remote-dns-resolve"]=!0),I}}}function mP(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function vP(){return{name:"Surge Anytls Parser",test:n=>/^.*=\s*anytls/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function EP(){return{name:"Surge TrustTunnel Parser",test:n=>/^.*=\s*trust-tunnel/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function AP(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function wP(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function CP(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>Nn().parse(n)}}function FP(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function DP(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function yP(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function SP(){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),[u,i,o]=s;n=o;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 p=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,E,d=[];for(;(E=p.exec(n))!==null;)E[3]!=null?d.push(E[3]):E[4]!=null&&d.push(E[4]);let f=/(,|^)\s*?addresses\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,w,g=[];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(/\]$/,"")),$P(A)&&g.push(A)}return{type:"external",name:i,exec:l,"local-port":h,args:d,addresses:g}}}}function bP(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function _P(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:s,line:u}=xw(n),i=Nn().parse(u);return i.ports=s,i}}}function IP(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>Nn().parse(n)}}function BP(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:s,line:u}=xw(n),i=Nn().parse(u);return i.ports=s,i}}}function $P(e){return Br(e)||Fr(e)}var Uw=[M7(),q7(),V7(),K7(),G7(),Lw(),X7(),J7(),Y7(),W7(),Z7(),z7(),Q7(),mP(),vP(),EP(),AP(),wP(),CP(),FP(),DP(),bP(),_P(),IP(),BP(),yP(),SP(),aP(),oP(),cP(),lP(),hP(),fP(),pP(),dP(),gP(),eP(),tP(),rP(),nP(),iP(),sP(),uP()];var qw=jr(r1());function PP(e){for(let t of Jf)try{if(t.test(e))return G.info(`Pre-processor [${t.name}] activated`),t.parse(e)}catch(r){G.error(`Parser [${t.name}] failed Reason: ${r}`)}return e}function RP(e){e=PP(e);let t=e.split(` `),r=[],n;for(let s of t){if(s=s.trim(),s.length===0)continue;let u=!1;if(n){let[i,o]=jw(n,s);o||(r.push(Mw(i)),u=!0)}if(!u)for(let i of Uw){let[o,l]=jw(i,s);if(!l){r.push(Mw(o)),n=i,u=!0,G.info(`${i.name} is activated`);break}}u||G.error(`Failed to parse line: ${s}`)}return r.filter(s=>(["vless","vmess"].includes(s.type)&&(zf(s.uuid)||G.info(`UUID may be invalid: ${s.name} ${s.uuid}`)),!0))}async function TP(proxies,operators=[],targetPlatform,source,$options){let context={};for(let item of operators){if(item.disabled){G.log(`Skipping disabled operator: "${item.type}" with arguments: >>> ${JSON.stringify(item.args,null,2)||"None"}`);continue}let script,$arguments={};if(item.type.indexOf("Script")!==-1){let{mode,content}=item.args;if(mode==="link"){let url=content||"",rawArgs=url.split("#");if(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)}}url=`${url.split("#")[0]}${rawArgs[2]?`#${rawArgs[2]}`:$arguments?.noCache!=null||$arguments?.insecure!=null?`#${rawArgs[1]}`:""}`;let downloadUrlMatch=url.split("#")[0].match(/^\/api\/(file|module)\/(.+)/);if(downloadUrlMatch){let e="";try{e=downloadUrlMatch?.[1];let t=downloadUrlMatch?.[2];if(t==null)throw new Error(`\u672C\u5730 ${e} URL \u65E0\u6548: ${url}`);t=decodeURIComponent(t);let r=e==="module"?Zl:Zs,n=Dr(G.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);e==="module"?script=n.content:script=await ei({type:"file",name:t})}catch(t){throw G.error(`Error when loading ${e}: ${item.args.content}. Reason: ${t}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${e}: ${url}`)}}else if(url?.startsWith("/"))try{let fs=eval('require("fs")');script=fs.readFileSync(url.split("#")[0],"utf8")}catch(e){throw G.error(`Error when reading local script: ${item.args.content}. Reason: ${e}`),new Error(`\u65E0\u6CD5\u4ECE\u8BE5\u8DEF\u5F84\u8BFB\u53D6\u811A\u672C\u6587\u4EF6: ${url}`)}else try{script=await an(url)}catch(e){throw G.error(`Error when downloading remote script: ${item.args.content}. Reason: ${e}`),new Error(`\u65E0\u6CD5\u4E0B\u8F7D\u811A\u672C: ${url}`)}}else script=content,$arguments=item.args.arguments||{}}if(!ah[item.type]){G.error(`Unknown operator: "${item.type}"`);continue}G.log(`Applying "${item.type}" with arguments: >>> ${JSON.stringify(item.args,null,2)||"None"}`);let processor;item.type.indexOf("Script")!==-1?processor=ah[item.type](script,targetPlatform,$arguments,source,$options,context):processor=ah[item.type](item.args||{}),proxies=await mA(processor,proxies)}return proxies}function OP(e,t,r,n={}){let s=hh[t];if(!s)throw new Error(`Target platform: ${t} is not supported!`);let u=/Surge|SurgeMac|Shadowrocket/i.test(t);if(e=e.filter(i=>i.supported&&i.supported[t]===!1?!1:(["vless","vmess"].includes(i.type)&&(zf(i.uuid)||G.info(`UUID may be invalid: ${i.name} ${i.uuid}`)),!0)),e=e.map(i=>(i._resolved=i.resolved,Cs(i.name)||(i.name=`${i.type} ${i.server}:${i.port}`),i["disable-sni"]&&(u?i.sni="off":["tuic"].includes(i.type)||(G.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=Uc(i.ports))),i)),G.log(`Producing proxies for target: ${t}`),typeof s.type>"u"||s.type==="SINGLE"){let i=e.map(o=>{try{return s.produce(o,r,n)}catch(l){return G.error(`Cannot produce proxy: ${JSON.stringify(o,null,2)} Reason: ${l}`),""}}).filter(o=>o.length>0);return i=r==="internal"?i:i.join(` `),t.startsWith("Surge")&&e.length>0&&e.every(o=>o.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 kt={parse:RP,process:TP,produce:OP,ipAddress:Gf,getRandomPort:Uc,isIPv4:Br,isIPv6:Fr,isIP:i1,yaml:ms,getFlag:Ho,removeFlag:qc,getISO:eh,MMDB:Qf,Gist:xa,download:an,downloadFile:JE,isValidUUID:zf,doh:qo,Buffer:Ch.Buffer,Base64:Dt,JSON5:qw.default};function jw(e,t){if(!kP(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function kP(e,t){try{return e.test(t)}catch{return!1}}function Hw(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function Mw(e){typeof e.cipher=="string"&&(e.cipher=e.cipher.toLowerCase()),typeof e.password=="number"&&(e.password=qE(e.password)),["ss"].includes(e.type)&&e.cipher==="none"&&!e.password&&(e.password=""),e.interface&&(e["interface-name"]=e.interface,delete e.interface),ME(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=>Hw(n)):t!=null&&(e[`${e.network}-opts`].path=Hw(t)),e.type==="trojan"&&(e.network=e.network||"tcp"),["vmess"].includes(e.type)&&(e.network=e.network||"tcp",e.cipher=e.cipher||"none",e.alterId=e.alterId||0),["vless"].includes(e.type)&&(e.network=e.network||"tcp"),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trust-tunnel","naive"].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&&!i1(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&&(i1(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||["null",null].includes(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=Ch.Buffer.from(e.name.data).toString("utf8"):e.name=Ch.Buffer.from(e.name).toString("utf8")}catch(n){G.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{G.env.isNode&&!r&&e._ca&&(r=G.node.fs.readFileSync(e._ca,{encoding:"utf8"}))}catch(n){G.error(`Read ca file failed Reason: ${n}`)}return!e["tls-fingerprint"]&&r&&(e["tls-fingerprint"]=Tv.generateFingerprint(r)),["ss"].includes(e.type)&&oe(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"]),["tuic"].includes(e.type)&&(e.alpn=Array.isArray(e.alpn)?e.alpn:[e.alpn||"h3"],e["congestion-controller"]=e["congestion-controller"]||"cubic",e["udp-relay-mode"]=e["udp-relay-mode"]||"native"),e}function i1(e){return Br(e)||Fr(e)}function s1(e){e.get("/share/col/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,G.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Jo(t,r)}),e.get("/share/col/:name",Jo),e.get("/share/sub/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,G.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Xo(t,r)}),e.get("/share/sub/:name",Xo),e.get("/download/collection/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,G.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Jo(t,r)}),e.get("/download/collection/:name",Jo),e.get("/download/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,G.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Xo(t,r)}),e.get("/download/:name",Xo),e.get("/download/collection/:name/api/v1/server/details",async(t,r)=>{t.query.platform="JSON",t.query.produceType="internal",t.query.resultFormat="nezha",await Jo(t,r)}),e.get("/download/:name/api/v1/server/details",async(t,r)=>{t.query.platform="JSON",t.query.produceType="internal",t.query.resultFormat="nezha",await Xo(t,r)}),e.get("/download/collection/:name/api/v1/monitor/:nezhaIndex",async(t,r)=>{t.query.platform="JSON",t.query.produceType="internal",t.query.resultFormat="nezha-monitor",await Jo(t,r)}),e.get("/download/:name/api/v1/monitor/:nezhaIndex",async(t,r)=>{t.query.platform="JSON",t.query.produceType="internal",t.query.resultFormat="nezha-monitor",await Xo(t,r)})}async function Xo(e,t){let{name:r,nezhaIndex:n}=e.params,s=e.query.target==="SurgeMac",u=e.query.target||Q0(e.headers)||"JSON",i=e.headers["user-agent"]||e.headers["User-Agent"];G.info(`\u6B63\u5728\u4E0B\u8F7D\u8BA2\u9605\uFF1A${r} \u8BF7\u6C42 User-Agent: ${i} \u8BF7\u6C42 target: ${e.query.target} \u5B9E\u9645\u8F93\u51FA: ${u}`);let{url:o,ua:l,content:h,mergeSources:p,ignoreFailedRemoteSub:E,produceType:d,includeUnsupportedProxy:f,resultFormat:w,proxy:g,noCache:F,_fakeNode:A}=e.query,C={_req:{method:e.method,url:e.url,path:e.path,query:e.query,params:e.params,headers:e.headers,body:e.body}};if(e.query.$options){let L={};try{L=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let b of e.query.$options.split("&")){let B=b.split("=")[0],k=b.split("=")[1];L[B]=k==null||k===""?!0:decodeURIComponent(k)}}G.info(`\u4F20\u5165 $options: ${JSON.stringify(L)}`),Object.assign(C,L)}o&&(G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 URL: ${o}`),/^https?:\/\//.test(o)||(h=o,G.info("URL \u4E0D\u662F\u94FE\u63A5\uFF0C\u89C6\u4E3A\u672C\u5730\u8BA2\u9605"))),h&&G.info(`\u6307\u5B9A\u672C\u5730\u8BA2\u9605: ${h}`),g&&G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${g}`),l&&G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 User-Agent: ${l}`),p&&G.info(`\u6307\u5B9A\u5408\u5E76\u6765\u6E90: ${p}`),E!=null&&E!==""&&G.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${E}`),d&&G.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${d}`),f&&G.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${f}`),!f&&ep(u,i)&&(f=!0,G.info(`\u5F53\u524D\u5BA2\u6237\u7AEF\u53EF\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${f}`)),s&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External"),F&&G.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${F}`);let S=G.read(Ri),I={name:"fakeNodeInfo",source:"local",content:"invalid share = ss, 1.0.0.1, 80, encrypt-method=aes-128-gcm, password=password"},_=A?I:Dr(S,r);if(_)try{_.passThroughUA&&(G.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${i}`),l=i);let M={type:"subscription",name:r,platform:u,url:o,ua:l,content:h,mergeSources:p,ignoreFailedRemoteSub:E,produceType:d,produceOpts:{"include-unsupported-proxy":f,useMihomoExternal:s},$options:C,proxy:g,noCache:F};A&&(G.info("\u8FD4\u56DE\u5047\u8282\u70B9\u4FE1\u606F"),delete M.name,M.subscription=I);let b=await ei(M),B;if(_.source!=="local"||["localFirst","remoteFirst"].includes(_.mergeSources))try{o=`${o||_.url}`.split(/[\r\n]+/).map(q=>q.trim()).filter(q=>q.length)?.[0]||"";let k={},U=o.split("#");if(o=o.split("#")[0],U.length>1)try{k=JSON.parse(decodeURIComponent(U[1]))}catch{for(let W of U[1].split("&")){let K=W.split("=")[0],z=W.split("=")[1];k[K]=z==null||z===""?!0:decodeURIComponent(z)}}if(!k.noFlow&&/^https?/.test(o)&&(B=await Fs(k?.insecure?`${o}#insecure`:o,k.flowUserAgent,void 0,g||_.proxy,k.flowUrl),B)){let q=jo(B,!0);q?.["subscription-userinfo"]&&t.set("subscription-userinfo",q["subscription-userinfo"]),q?.["profile-web-page-url"]&&t.set("profile-web-page-url",q["profile-web-page-url"]),q?.["plan-name"]&&t.set("plan-name",q["plan-name"])}}catch(k){G.error(`\u8BA2\u9605 ${r} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(k)}`)}if(_.subUserinfo){let k;if(/^https?:\/\//.test(_.subUserinfo))try{k=await Fs(void 0,void 0,void 0,g||_.proxy,_.subUserinfo)}catch(q){G.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${_.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(q)}`)}else k=_.subUserinfo;let U=jo([k,B].filter(q=>q).join(";"),!0);U?.["subscription-userinfo"]&&t.set("subscription-userinfo",U["subscription-userinfo"]),U?.["profile-web-page-url"]&&t.set("profile-web-page-url",U["profile-web-page-url"]),U?.["plan-name"]&&t.set("plan-name",U["plan-name"])}u==="JSON"?(w==="nezha"?b=Kw(b):w==="nezha-monitor"&&(n=/^\d+$/.test(n)?parseInt(n,10):b.findIndex(k=>k.name===n),b=await Vw(b[n],n,e.query)),t.set("Content-Type","application/json;charset=utf-8")):t.set("Content-Type","text/plain; charset=utf-8"),C?._res?.headers&&Object.entries(C._res.headers).forEach(([k,U])=>{U==null?t.removeHeader(k):t.set(k,U)}),C?._res?.status&&t.status(C._res.status),t.send(b)}catch(L){G.notify("\u{1F30D} Sub-Store \u4E0B\u8F7D\u8BA2\u9605\u5931\u8D25",`\u274C \u65E0\u6CD5\u4E0B\u8F7D\u8BA2\u9605\uFF1A${r}\uFF01`,`\u{1F914} \u539F\u56E0\uFF1A${L.message??L}`),G.error(L.message??L),un(t,new mi("INTERNAL_SERVER_ERROR",`Failed to download subscription: ${r}`,`Reason: ${L.message??L}`))}else G.error(`\u{1F30D} Sub-Store \u4E0B\u8F7D\u8BA2\u9605\u5931\u8D25 \u274C \u672A\u627E\u5230\u8BA2\u9605\uFF1A${r}\uFF01`),un(t,new ou("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404)}async function Jo(e,t){let{name:r,nezhaIndex:n}=e.params,s=e.query.target==="SurgeMac",u=e.query.target||Q0(e.headers)||"JSON",i=G.read(Nu),o=Dr(i,r),l=e.headers["user-agent"]||e.headers["User-Agent"];G.info(`\u6B63\u5728\u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\uFF1A${r} \u8BF7\u6C42 User-Agent: ${l} \u8BF7\u6C42 target: ${e.query.target} \u5B9E\u9645\u8F93\u51FA: ${u}`);let{ignoreFailedRemoteSub:h,produceType:p,includeUnsupportedProxy:E,resultFormat:d,proxy:f,noCache:w}=e.query,g={_req:{method:e.method,url:e.url,path:e.path,query:e.query,params:e.params,headers:e.headers,body:e.body}};if(e.query.$options){let F={};try{F=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let C of e.query.$options.split("&")){let S=C.split("=")[0],I=C.split("=")[1];F[S]=I==null||I===""?!0:decodeURIComponent(I)}}G.info(`\u4F20\u5165 $options: ${JSON.stringify(F)}`),Object.assign(g,F)}if(f&&G.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${f}`),h!=null&&h!==""&&G.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${h}`),p&&G.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${p}`),E&&G.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${E}`),!E&&ep(u,l)&&(E=!0,G.info(`\u5F53\u524D\u5BA2\u6237\u7AEF\u53EF\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${E}`)),s&&G.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External"),w&&G.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${w}`),o)try{let F=await ei({type:"collection",name:r,platform:u,ignoreFailedRemoteSub:h,produceType:p,produceOpts:{"include-unsupported-proxy":E,useMihomoExternal:s},$options:g,proxy:f,noCache:w,ua:l}),A,C=G.read(Ri),S=o.subscriptions;if(S.length>0){let L=Dr(C,S[0]);if(L.source!=="local"||["localFirst","remoteFirst"].includes(L.mergeSources))try{let M=`${L.url}`.split(/[\r\n]+/).map(k=>k.trim()).filter(k=>k.length)?.[0]||"",b={},B=M.split("#");if(M=M.split("#")[0],B.length>1)try{b=JSON.parse(decodeURIComponent(B[1]))}catch{for(let U of B[1].split("&")){let q=U.split("=")[0],W=U.split("=")[1];b[q]=W==null||W===""?!0:decodeURIComponent(W)}}!b.noFlow&&/^https?:/.test(M)&&(A=await Fs(b?.insecure?`${M}#insecure`:M,b.flowUserAgent,void 0,f||L.proxy||o.proxy,b.flowUrl))}catch(M){G.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4E2D\u7684\u5B50\u8BA2\u9605 ${L.name} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${M.message??M}`)}if(L.subUserinfo){let M;if(/^https?:\/\//.test(L.subUserinfo))try{M=await Fs(void 0,void 0,void 0,f||L.proxy,L.subUserinfo)}catch(b){G.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${L.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(b)}`)}else M=L.subUserinfo;A=[M,A].filter(b=>b).join("; ")}}G.info(`\u7EC4\u5408\u8BA2\u9605 ${r} \u900F\u4F20\u7684\u7684\u6D41\u91CF\u4FE1\u606F: ${A}`);let I;if(/^https?:\/\//.test(o.subUserinfo))try{I=await Fs(void 0,void 0,void 0,f||o.proxy,o.subUserinfo)}catch(L){G.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${o.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(L)}`)}else I=o.subUserinfo;let _=[I,A].filter(L=>L).join("; ");if(_){let L=jo(_,!0);L?.["subscription-userinfo"]&&t.set("subscription-userinfo",L["subscription-userinfo"]),L?.["profile-web-page-url"]&&t.set("profile-web-page-url",L["profile-web-page-url"]),L?.["plan-name"]&&t.set("plan-name",L["plan-name"])}u==="JSON"?(d==="nezha"?F=Kw(F):d==="nezha-monitor"&&(n=/^\d+$/.test(n)?parseInt(n,10):F.findIndex(L=>L.name===n),F=await Vw(F[n],n,e.query)),t.set("Content-Type","application/json;charset=utf-8")):t.set("Content-Type","text/plain; charset=utf-8"),g?._res?.headers&&Object.entries(g._res.headers).forEach(([L,M])=>{M==null?t.removeHeader(L):t.set(L,M)}),g?._res?.status&&t.status(g._res.status),t.send(F)}catch(F){G.notify("\u{1F30D} Sub-Store \u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C \u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\u9519\u8BEF\uFF1A${r}\uFF01`,`\u{1F914} \u539F\u56E0\uFF1A${F}`),un(t,new mi("INTERNAL_SERVER_ERROR",`Failed to download collection: ${r}`,`Reason: ${F.message??F}`))}else G.error("\u{1F30D} Sub-Store \u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C \u672A\u627E\u5230\u7EC4\u5408\u8BA2\u9605\uFF1A${r}\uFF01`),un(t,new ou("RESOURCE_NOT_FOUND",`Collection ${r} does not exist!`),404)}async function Vw(e,t,r){let n={code:0,message:"success",result:[]};try{let{isLoon:s,isSurge:u}=G.env;if(!s&&!u)throw new Error("\u4EC5\u652F\u6301 Loon \u548C Surge(ability=http-client-policy)");let i=kt.produce([e],s?"Loon":"Surge");if(!i)throw new Error("\u5F53\u524D\u5BA2\u6237\u7AEF\u4E0D\u517C\u5BB9\u6B64\u8282\u70B9");let o=e._monitors||[{name:"Cloudflare",url:"http://cp.cloudflare.com/generate_204",method:"HEAD",number:3,timeout:2e3},{name:"Google",url:"http://www.google.com/generate_204",method:"HEAD",number:3,timeout:2e3}],l=r.number||Math.max(...o.map(h=>h.number))||3;for(let h of o){let E={monitor_id:o.indexOf(h),server_id:t,monitor_name:h.name,server_name:e.name,created_at:[],avg_delay:[]};for(let d=0;d{let s=r._geo?.countryCode||r._geo?.country;if(/^[a-z]{2}$/i.test(s)||(s=eh(r.name)),/^[a-z]{2}$/i.test(s)){let u=Math.round(new Date().getTime()/1e3),i=r._unavailable?0:u,o=parseInt(r._uptime||0,10);t.result.push({id:n,name:r.name,tag:`${r._tag??""}`,last_active:i,valid_ip:r._IP||r.server,ipv4:r._IPv4||r.server,ipv6:r._IPv6||(Fr(r.server)?r.server:""),host:{Platform:"Sub-Store",PlatformVersion:Gc.version,CPU:[],MemTotal:1024,DiskTotal:1024,SwapTotal:1024,Arch:"",Virtualization:"",BootTime:u-o,CountryCode:s,Version:"0.0.1"},status:{CPU:0,MemUsed:0,SwapUsed:0,DiskUsed:0,NetInTransfer:0,NetOutTransfer:0,NetInSpeed:0,NetOutSpeed:0,Uptime:o,Load1:0,Load5:0,Load15:0,TcpConnCount:0,UdpConnCount:0,ProcessCount:0}})}}),JSON.stringify(t,null,2)}function u1(e){e.post("/api/preview/sub",xP),e.post("/api/preview/collection",LP),e.post("/api/preview/file",NP)}async function NP(e,t){try{let r=e.body,n="";if(r.type!=="mihomoProfile")if(r.source==="local"&&!["localFirst","remoteFirst"].includes(r.mergeSources))n=r.content;else{let o={};if(n=await Promise.all(r.url.split(/[\r\n]+/).map(l=>l.trim()).filter(l=>l.length).map(async l=>{try{return await an(l,r.ua,void 0,r.proxy)}catch(h){return o[l]=h,G.error(`\u6587\u4EF6 ${r.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${l} \u53D1\u751F\u9519\u8BEF: ${h}`),""}})),Object.keys(o).length>0)if(r.ignoreFailedRemoteFile)r.ignoreFailedRemoteFile==="enabled"&&G.notify("\u{1F30D} Sub-Store \u9884\u89C8\u6587\u4EF6\u5931\u8D25",`\u274C ${r.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(o).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u6587\u4EF6 ${r.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(o).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);r.mergeSources==="localFirst"?n.unshift(r.content):r.mergeSources==="remoteFirst"&&n.push(r.content)}let s=(Array.isArray(n)?n:[n]).flat(),u=s.filter(o=>o!=null&&o!=="").join(` `),i=Array.isArray(r.process)&&r.process.length>0?await kt.process({$files:s,$content:u,$file:r},r.process):{$content:u,$files:s};Ds(t,{original:u,processed:i?.$content??""})}catch(r){G.error(r.message??r),un(t,new mi("INTERNAL_SERVER_ERROR","Failed to preview file",`Reason: ${r.message??r}`))}}async function xP(e,t){try{let r=e.body,n=e.query.target||"JSON",s;if(r.source==="local"&&!["localFirst","remoteFirst"].includes(r.mergeSources))s=r.content;else{let o={};if(s=await Promise.all(r.url.split(/[\r\n]+/).map(l=>l.trim()).filter(l=>l.length).map(async l=>{try{return await an(l,r.ua,void 0,r.proxy,void 0,void 0,void 0,!0)}catch(h){return o[l]=h,G.error(`\u8BA2\u9605 ${r.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${l} \u53D1\u751F\u9519\u8BEF: ${h}`),""}})),Object.keys(o).length>0)if(r.ignoreFailedRemoteSub)r.ignoreFailedRemoteSub==="enabled"&&G.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${r.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(o).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${r.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(o).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);r.mergeSources==="localFirst"?s.unshift(r.content):r.mergeSources==="remoteFirst"&&s.push(r.content)}let u=(Array.isArray(s)?s:[s]).map(o=>kt.parse(o)).flat();u.forEach((o,l)=>{o.id=l,o._subName=r.name,o._subDisplayName=r.displayName});let i=await kt.process(u,r.process||[],n,{[r.name]:r});Ds(t,{original:u,processed:i})}catch(r){G.error(r.message??r),un(t,new mi("INTERNAL_SERVER_ERROR","Failed to preview subscription",`Reason: ${r.message??r}`))}}async function LP(e,t){try{let r=G.read(Ri),n=e.body,s=[...n.subscriptions],u=n.subscriptionTags;Array.isArray(u)&&u.length>0&&r.forEach(p=>{Array.isArray(p.tag)&&p.tag.length>0&&!s.includes(p.name)&&p.tag.some(E=>u.includes(E))&&s.push(p.name)});let i={},o={};if(await Promise.all(s.map(async p=>{let E=Dr(r,p);try{let d;if(E.source==="local"&&!["localFirst","remoteFirst"].includes(E.mergeSources))d=E.content;else{let w={};if(d=await Promise.all(E.url.split(/[\r\n]+/).map(g=>g.trim()).filter(g=>g.length).map(async g=>{try{return await an(g,E.ua,void 0,E.proxy,void 0,void 0,void 0,!0)}catch(F){return w[g]=F,G.error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${g} \u53D1\u751F\u9519\u8BEF: ${F}`),""}})),Object.keys(w).length>0)if(E.ignoreFailedRemoteSub)E.ignoreFailedRemoteSub==="enabled"&&G.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(w).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(w).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);E.mergeSources==="localFirst"?d.unshift(E.content):E.mergeSources==="remoteFirst"&&d.push(E.content)}let f=(Array.isArray(d)?d:[d]).map(w=>kt.parse(w)).flat();f.forEach(w=>{w._subName=E.name,w._subDisplayName=E.displayName,w._collectionName=n.name,w._collectionDisplayName=n.displayName}),f=await kt.process(f,E.process||[],"JSON",{[E.name]:E,_collection:n}),i[p]=f}catch(d){o[p]=d,G.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605 ${n.name} \u4E2D\u7684\u5B50\u8BA2\u9605: ${E.name} \u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${d}\uFF01`)}})),Object.keys(o).length>0)if(n.ignoreFailedRemoteSub)n.ignoreFailedRemoteSub==="enabled"&&G.notify("\u{1F30D} Sub-Store \u9884\u89C8\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${n.name}`,`\u5B50\u8BA2\u9605 ${Object.keys(o).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${n.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(o).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let l=Array.prototype.concat.apply([],s.map(p=>i[p]||[]));l.forEach((p,E)=>{p.id=E,p._collectionName=n.name,p._collectionDisplayName=n.displayName});let h=await kt.process(l,n.process||[],"JSON",{_collection:n});Ds(t,{original:l,processed:h})}catch(r){G.error(r.message??r),un(t,new mi("INTERNAL_SERVER_ERROR","Failed to preview collection",`Reason: ${r.message??r}`))}}function a1(e){e.post("/api/utils/node-info",UP)}async function UP(e,t){let r=e.body,n=e.query.lang||"zh-CN",s;try{s=hh.URI.produce(r)}catch{}try{let i=await Ki().get({url:`http://ip-api.com/json/${encodeURIComponent(`${r.server}`.trim().replace(/^\[/,"").replace(/\]$/,""))}?lang=${n}`,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15"}}).then(o=>{let l=JSON.parse(o.body);if(l.status!=="success")throw new Error(l.message);return delete l.status,l});Ds(t,{shareUrl:s,info:i})}catch(u){un(t,new Yf("FAILED_TO_GET_NODE_INFO","Failed to get node info",`Reason: ${u}`))}}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${Jl} \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 `);K0();jP();function jP(){let e=G0({substore:G});s1(e),u1(e),sd(e),a1(e),e.options("/",(t,r)=>{r.status(200).end()}),e.start()}})(); /*! 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 *) */