(()=>{var YC=Object.create;var am=Object.defineProperty;var WC=Object.getOwnPropertyDescriptor;var XC=Object.getOwnPropertyNames;var JC=Object.getPrototypeOf,ZC=Object.prototype.hasOwnProperty;var za=(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 ye=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var QC=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of XC(t))!ZC.call(e,i)&&i!==r&&am(e,i,{get:()=>t[i],enumerable:!(n=WC(t,i))||n.enumerable});return e};var Cn=(e,t,r)=>(r=e!=null?YC(JC(e)):{},QC(t||!e||!e.__esModule?am(r,"default",{value:e,enumerable:!0}):r,e));var td=ye(nu=>{"use strict";Object.defineProperty(nu,"__esModule",{value:!0});nu.isCorrect=nu.isInSubnet=void 0;function m_(e){return this.subnetMask{"use strict";Object.defineProperty(Ni,"__esModule",{value:!0});Ni.RE_SUBNET_STRING=Ni.RE_ADDRESS=Ni.GROUPS=Ni.BITS=void 0;Ni.BITS=32;Ni.GROUPS=4;Ni.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;Ni.RE_SUBNET_STRING=/\/\d{1,2}$/});var gf=ye(df=>{"use strict";Object.defineProperty(df,"__esModule",{value:!0});df.AddressError=void 0;var nd=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};df.AddressError=nd});var sd=ye((mf,hm)=>{(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n(T,x,H){T!=null&&(typeof T=="number"?this.fromNumber(T,x,H):x==null&&typeof T!="string"?this.fromString(T,256):this.fromString(T,x))}function i(){return new n(null)}function a(T,x,H,Q,de,ve){for(;--ve>=0;){var Fe=x*this[T++]+H[Q]+de;de=Math.floor(Fe/67108864),H[Q++]=Fe&67108863}return de}function s(T,x,H,Q,de,ve){for(var Fe=x&32767,Re=x>>15;--ve>=0;){var Pt=this[T]&32767,Qt=this[T++]>>15,Or=Re*Pt+Qt*Fe;Pt=Fe*Pt+((Or&32767)<<15)+H[Q]+(de&1073741823),de=(Pt>>>30)+(Or>>>15)+Re*Qt+(de>>>30),H[Q++]=Pt&1073741823}return de}function u(T,x,H,Q,de,ve){for(var Fe=x&16383,Re=x>>14;--ve>=0;){var Pt=this[T]&16383,Qt=this[T++]>>14,Or=Re*Pt+Qt*Fe;Pt=Fe*Pt+((Or&16383)<<14)+H[Q]+de,de=(Pt>>28)+(Or>>14)+Re*Qt,H[Q++]=Pt&268435455}return de}var l=typeof navigator<"u";l&&r&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=s,e=30):l&&r&&navigator.appName!="Netscape"?(n.prototype.am=a,e=26):(n.prototype.am=u,e=28),n.prototype.DB=e,n.prototype.DM=(1<=0;--x)T[x]=this[x];T.t=this.t,T.s=this.s}function w(T){this.t=1,this.s=T<0?-1:0,T>0?this[0]=T:T<-1?this[0]=T+this.DV:this.t=0}function y(T){var x=i();return x.fromInt(T),x}function _(T,x){var H;if(x==16)H=4;else if(x==8)H=3;else if(x==256)H=8;else if(x==2)H=1;else if(x==32)H=5;else if(x==4)H=2;else{this.fromRadix(T,x);return}this.t=0,this.s=0;for(var Q=T.length,de=!1,ve=0;--Q>=0;){var Fe=H==8?T[Q]&255:m(T,Q);if(Fe<0){T.charAt(Q)=="-"&&(de=!0);continue}de=!1,ve==0?this[this.t++]=Fe:ve+H>this.DB?(this[this.t-1]|=(Fe&(1<>this.DB-ve):this[this.t-1]|=Fe<=this.DB&&(ve-=this.DB)}H==8&&T[0]&128&&(this.s=-1,ve>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==T;)--this.t}function D(T){if(this.s<0)return"-"+this.negate().toString(T);var x;if(T==16)x=4;else if(T==8)x=3;else if(T==2)x=1;else if(T==32)x=5;else if(T==4)x=2;else return this.toRadix(T);var H=(1<0)for(Re>Re)>0&&(de=!0,ve=A(Q));Fe>=0;)Re>(Re+=this.DB-x)):(Q=this[Fe]>>(Re-=x)&H,Re<=0&&(Re+=this.DB,--Fe)),Q>0&&(de=!0),de&&(ve+=A(Q));return de?ve:"0"}function j(){var T=i();return n.ZERO.subTo(this,T),T}function q(){return this.s<0?this.negate():this}function F(T){var x=this.s-T.s;if(x!=0)return x;var H=this.t;if(x=H-T.t,x!=0)return this.s<0?-x:x;for(;--H>=0;)if((x=this[H]-T[H])!=0)return x;return 0}function P(T){var x=1,H;return(H=T>>>16)!=0&&(T=H,x+=16),(H=T>>8)!=0&&(T=H,x+=8),(H=T>>4)!=0&&(T=H,x+=4),(H=T>>2)!=0&&(T=H,x+=2),(H=T>>1)!=0&&(T=H,x+=1),x}function L(){return this.t<=0?0:this.DB*(this.t-1)+P(this[this.t-1]^this.s&this.DM)}function M(T,x){var H;for(H=this.t-1;H>=0;--H)x[H+T]=this[H];for(H=T-1;H>=0;--H)x[H]=0;x.t=this.t+T,x.s=this.s}function V(T,x){for(var H=T;H=0;--Re)x[Re+ve+1]=this[Re]>>Q|Fe,Fe=(this[Re]&de)<=0;--Re)x[Re]=0;x[ve]=Fe,x.t=this.t+ve+1,x.s=this.s,x.clamp()}function G(T,x){x.s=this.s;var H=Math.floor(T/this.DB);if(H>=this.t){x.t=0;return}var Q=T%this.DB,de=this.DB-Q,ve=(1<>Q;for(var Fe=H+1;Fe>Q;Q>0&&(x[this.t-H-1]|=(this.s&ve)<>=this.DB;if(T.t>=this.DB;Q+=this.s}else{for(Q+=this.s;H>=this.DB;Q-=T.s}x.s=Q<0?-1:0,Q<-1?x[H++]=this.DV+Q:Q>0&&(x[H++]=Q),x.t=H,x.clamp()}function X(T,x){var H=this.abs(),Q=T.abs(),de=H.t;for(x.t=de+Q.t;--de>=0;)x[de]=0;for(de=0;de=0;)T[H]=0;for(H=0;H=x.DV&&(T[H+x.t]-=x.DV,T[H+x.t+1]=1)}T.t>0&&(T[T.t-1]+=x.am(H,x[H],T,2*H,0,1)),T.s=0,T.clamp()}function Se(T,x,H){var Q=T.abs();if(!(Q.t<=0)){var de=this.abs();if(de.t0?(Q.lShiftTo(Pt,ve),de.lShiftTo(Pt,H)):(Q.copyTo(ve),de.copyTo(H));var Qt=ve.t,Or=ve[Qt-1];if(Or!=0){var xr=Or*(1<1?ve[Qt-2]>>this.F2:0),Tn=this.FV/xr,Ws=(1<=0&&(H[H.t++]=1,H.subTo(Qn,H)),n.ONE.dlShiftTo(Qt,Qn),Qn.subTo(ve,ve);ve.t=0;){var Na=H[--Nr]==Or?this.DM:Math.floor(H[Nr]*Tn+(H[Nr-1]+nn)*Ws);if((H[Nr]+=ve.am(0,Na,H,Xs,0,Qt))0&&H.rShiftTo(Pt,H),Fe<0&&n.ZERO.subTo(H,H)}}}function we(T){var x=i();return this.abs().divRemTo(T,null,x),this.s<0&&x.compareTo(n.ZERO)>0&&T.subTo(x,x),x}function Ie(T){this.m=T}function Ve(T){return T.s<0||T.compareTo(this.m)>=0?T.mod(this.m):T}function ue(T){return T}function _e(T){T.divRemTo(this.m,null,T)}function He(T,x,H){T.multiplyTo(x,H),this.reduce(H)}function Sr(T,x){T.squareTo(x),this.reduce(x)}Ie.prototype.convert=Ve,Ie.prototype.revert=ue,Ie.prototype.reduce=_e,Ie.prototype.mulTo=He,Ie.prototype.sqrTo=Sr;function Ht(){if(this.t<1)return 0;var T=this[0];if(!(T&1))return 0;var x=T&3;return x=x*(2-(T&15)*x)&15,x=x*(2-(T&255)*x)&255,x=x*(2-((T&65535)*x&65535))&65535,x=x*(2-T*x%this.DV)%this.DV,x>0?this.DV-x:-x}function wt(T){this.m=T,this.mp=T.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(x,x),x}function Gt(T){var x=i();return T.copyTo(x),this.reduce(x),x}function at(T){for(;T.t<=this.mt2;)T[T.t++]=0;for(var x=0;x>15)*this.mpl&this.um)<<15)&T.DM;for(H=x+this.m.t,T[H]+=this.m.am(0,Q,T,x,0,this.m.t);T[H]>=T.DV;)T[H]-=T.DV,T[++H]++}T.clamp(),T.drShiftTo(this.m.t,T),T.compareTo(this.m)>=0&&T.subTo(this.m,T)}function kt(T,x){T.squareTo(x),this.reduce(x)}function it(T,x,H){T.multiplyTo(x,H),this.reduce(H)}wt.prototype.convert=ir,wt.prototype.revert=Gt,wt.prototype.reduce=at,wt.prototype.mulTo=it,wt.prototype.sqrTo=kt;function bt(){return(this.t>0?this[0]&1:this.s)==0}function sr(T,x){if(T>4294967295||T<1)return n.ONE;var H=i(),Q=i(),de=x.convert(this),ve=P(T)-1;for(de.copyTo(H);--ve>=0;)if(x.sqrTo(H,Q),(T&1<0)x.mulTo(Q,de,H);else{var Fe=H;H=Q,Q=Fe}return x.revert(H)}function et(T,x){var H;return T<256||x.isEven()?H=new Ie(x):H=new wt(x),this.exp(T,H)}n.prototype.copyTo=S,n.prototype.fromInt=w,n.prototype.fromString=_,n.prototype.clamp=B,n.prototype.dlShiftTo=M,n.prototype.drShiftTo=V,n.prototype.lShiftTo=W,n.prototype.rShiftTo=G,n.prototype.subTo=z,n.prototype.multiplyTo=X,n.prototype.squareTo=ie,n.prototype.divRemTo=Se,n.prototype.invDigit=Ht,n.prototype.isEven=bt,n.prototype.exp=sr,n.prototype.toString=D,n.prototype.negate=j,n.prototype.abs=q,n.prototype.compareTo=F,n.prototype.bitLength=L,n.prototype.mod=we,n.prototype.modPowInt=et,n.ZERO=y(0),n.ONE=y(1);function Jt(){var T=i();return this.copyTo(T),T}function Zn(){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 Tr(){return this.t==0?this.s:this[0]<<16>>16}function cr(T){return Math.floor(Math.LN2*this.DB/Math.log(T))}function Mr(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Sa(T){if(T==null&&(T=10),this.signum()==0||T<2||T>36)return"0";var x=this.chunkSize(T),H=Math.pow(T,x),Q=y(H),de=i(),ve=i(),Fe="";for(this.divRemTo(Q,de,ve);de.signum()>0;)Fe=(H+ve.intValue()).toString(T).substr(1)+Fe,de.divRemTo(Q,de,ve);return ve.intValue().toString(T)+Fe}function tn(T,x){this.fromInt(0),x==null&&(x=10);for(var H=this.chunkSize(x),Q=Math.pow(x,H),de=!1,ve=0,Fe=0,Re=0;Re=H&&(this.dMultiply(Q),this.dAddOffset(Fe,0),ve=0,Fe=0)}ve>0&&(this.dMultiply(Math.pow(x,ve)),this.dAddOffset(Fe,0)),de&&n.ZERO.subTo(this,this)}function Ct(T,x,H){if(typeof x=="number")if(T<2)this.fromInt(1);else for(this.fromNumber(T,H),this.testBit(T-1)||this.bitwiseTo(n.ONE.shiftLeft(T-1),rs,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(x);)this.dAddOffset(2,0),this.bitLength()>T&&this.subTo(n.ONE.shiftLeft(T-1),this);else{var Q=new Array,de=T&7;Q.length=(T>>3)+1,x.nextBytes(Q),de>0?Q[0]&=(1<0)for(H>H)!=(this.s&this.DM)>>H&&(x[de++]=Q|this.s<=0;)H<8?(Q=(this[T]&(1<>(H+=this.DB-8)):(Q=this[T]>>(H-=8)&255,H<=0&&(H+=this.DB,--T)),Q&128&&(Q|=-256),de==0&&(this.s&128)!=(Q&128)&&++de,(de>0||Q!=this.s)&&(x[de++]=Q);return x}function tt(T){return this.compareTo(T)==0}function jr(T){return this.compareTo(T)<0?this:T}function ba(T){return this.compareTo(T)>0?this:T}function Ca(T,x,H){var Q,de,ve=Math.min(T.t,this.t);for(Q=0;Q>=16,x+=16),T&255||(T>>=8,x+=8),T&15||(T>>=4,x+=4),T&3||(T>>=2,x+=2),T&1||++x,x}function _o(){for(var T=0;T=this.t?this.s!=0:(this[x]&1<>=this.DB;if(T.t>=this.DB;Q+=this.s}else{for(Q+=this.s;H>=this.DB;Q+=T.s}x.s=Q<0?-1:0,Q>0?x[H++]=Q:Q<-1&&(x[H++]=this.DV+Q),x.t=H,x.clamp()}function $a(T){var x=i();return this.addTo(T,x),x}function zu(T){var x=i();return this.subTo(T,x),x}function Yu(T){var x=i();return this.multiplyTo(T,x),x}function Wu(){var T=i();return this.squareTo(T),T}function Xu(T){var x=i();return this.divRemTo(T,x,null),x}function Ju(T){var x=i();return this.divRemTo(T,null,x),x}function Zu(T){var x=i(),H=i();return this.divRemTo(T,x,H),new Array(x,H)}function Qu(T){this[this.t]=this.am(0,T-1,this,0,0,this.t),++this.t,this.clamp()}function ec(T,x){if(T!=0){for(;this.t<=x;)this[this.t++]=0;for(this[x]+=T;this[x]>=this.DV;)this[x]-=this.DV,++x>=this.t&&(this[this.t++]=0),++this[x]}}function Ii(){}function $o(T){return T}function tc(T,x,H){T.multiplyTo(x,H)}function rc(T,x){T.squareTo(x)}Ii.prototype.convert=$o,Ii.prototype.revert=$o,Ii.prototype.mulTo=tc,Ii.prototype.sqrTo=rc;function nc(T){return this.exp(T,new Ii)}function Do(T,x,H){var Q=Math.min(this.t+T.t,x);for(H.s=0,H.t=Q;Q>0;)H[--Q]=0;var de;for(de=H.t-this.t;Q=0;)H[Q]=0;for(Q=Math.max(x-this.t,0);Q2*this.m.t)return T.mod(this.m);if(T.compareTo(this.m)<0)return T;var x=i();return T.copyTo(x),this.reduce(x),x}function zs(T){return T}function Pn(T){for(T.drShiftTo(this.m.t-1,this.r2),T.t>this.m.t+1&&(T.t=this.m.t+1,T.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);T.compareTo(this.r2)<0;)T.dAddOffset(1,this.m.t+1);for(T.subTo(this.r2,T);T.compareTo(this.m)>=0;)T.subTo(this.m,T)}function sc(T,x){T.squareTo(x),this.reduce(x)}function ac(T,x,H){T.multiplyTo(x,H),this.reduce(H)}gn.prototype.convert=ic,gn.prototype.revert=zs,gn.prototype.reduce=Pn,gn.prototype.mulTo=ac,gn.prototype.sqrTo=sc;function Bo(T,x){var H=T.bitLength(),Q,de=y(1),ve;if(H<=0)return de;H<18?Q=1:H<48?Q=3:H<144?Q=4:H<768?Q=5:Q=6,H<8?ve=new Ie(x):x.isEven()?ve=new gn(x):ve=new wt(x);var Fe=new Array,Re=3,Pt=Q-1,Qt=(1<1){var Or=i();for(ve.sqrTo(Fe[1],Or);Re<=Qt;)Fe[Re]=i(),ve.mulTo(Or,Fe[Re-2],Fe[Re]),Re+=2}var xr=T.t-1,Tn,Ws=!0,nn=i(),Nr;for(H=P(T[xr])-1;xr>=0;){for(H>=Pt?Tn=T[xr]>>H-Pt&Qt:(Tn=(T[xr]&(1<0&&(Tn|=T[xr-1]>>this.DB+H-Pt)),Re=Q;!(Tn&1);)Tn>>=1,--Re;if((H-=Re)<0&&(H+=this.DB,--xr),Ws)Fe[Tn].copyTo(de),Ws=!1;else{for(;Re>1;)ve.sqrTo(de,nn),ve.sqrTo(nn,de),Re-=2;Re>0?ve.sqrTo(de,nn):(Nr=de,de=nn,nn=Nr),ve.mulTo(nn,Fe[Tn],de)}for(;xr>=0&&!(T[xr]&1<0&&(x.rShiftTo(ve,x),H.rShiftTo(ve,H));x.signum()>0;)(de=x.getLowestSetBit())>0&&x.rShiftTo(de,x),(de=H.getLowestSetBit())>0&&H.rShiftTo(de,H),x.compareTo(H)>=0?(x.subTo(H,x),x.rShiftTo(1,x)):(H.subTo(x,H),H.rShiftTo(1,H));return ve>0&&H.lShiftTo(ve,H),H}function Ro(T){if(T<=0)return 0;var x=this.DV%T,H=this.s<0?T-1:0;if(this.t>0)if(x==0)H=this[0]%T;else for(var Q=this.t-1;Q>=0;--Q)H=(x*H+this[Q])%T;return H}function Ys(T){var x=T.isEven();if(this.isEven()&&x||T.signum()==0)return n.ZERO;for(var H=T.clone(),Q=this.clone(),de=y(1),ve=y(0),Fe=y(0),Re=y(1);H.signum()!=0;){for(;H.isEven();)H.rShiftTo(1,H),x?((!de.isEven()||!ve.isEven())&&(de.addTo(this,de),ve.subTo(T,ve)),de.rShiftTo(1,de)):ve.isEven()||ve.subTo(T,ve),ve.rShiftTo(1,ve);for(;Q.isEven();)Q.rShiftTo(1,Q),x?((!Fe.isEven()||!Re.isEven())&&(Fe.addTo(this,Fe),Re.subTo(T,Re)),Fe.rShiftTo(1,Fe)):Re.isEven()||Re.subTo(T,Re),Re.rShiftTo(1,Re);H.compareTo(Q)>=0?(H.subTo(Q,H),x&&de.subTo(Fe,de),ve.subTo(Re,ve)):(Q.subTo(H,Q),x&&Fe.subTo(de,Fe),Re.subTo(ve,Re))}if(Q.compareTo(n.ONE)!=0)return n.ZERO;if(Re.compareTo(T)>=0)return Re.subtract(T);if(Re.signum()<0)Re.addTo(T,Re);else return Re;return Re.signum()<0?Re.add(T):Re}var Zt=[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],oc=(1<<26)/Zt[Zt.length-1];function uc(T){var x,H=this.abs();if(H.t==1&&H[0]<=Zt[Zt.length-1]){for(x=0;x>1,T>Zt.length&&(T=Zt.length);for(var de=i(),ve=0;ve>8&255,Cr[Kt++]^=T>>16&255,Cr[Kt++]^=T>>24&255,Kt>=rn&&(Kt-=rn)}function Ba(){cc(new Date().getTime())}if(Cr==null){Cr=new Array,Kt=0;var _r;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var Ra=new Uint8Array(32);for(window.crypto.getRandomValues(Ra),_r=0;_r<32;++_r)Cr[Kt++]=Ra[_r]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var To=window.crypto.random(32);for(_r=0;_r>>8,Cr[Kt++]=_r&255;Kt=0,Ba()}function Oo(){if(Di==null){for(Ba(),Di=xa(),Di.init(Cr),Kt=0;Kt{(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(s){return n(a(s),arguments)}function r(s,u){return t.apply(null,[s].concat(u||[]))}function n(s,u){var l=1,f=s.length,d,E="",p,h,A,m,S,w,y,_;for(p=0;p=0),A.type){case"b":d=parseInt(d,10).toString(2);break;case"c":d=String.fromCharCode(parseInt(d,10));break;case"d":case"i":d=parseInt(d,10);break;case"j":d=JSON.stringify(d,null,A.width?parseInt(A.width):0);break;case"e":d=A.precision?parseFloat(d).toExponential(A.precision):parseFloat(d).toExponential();break;case"f":d=A.precision?parseFloat(d).toFixed(A.precision):parseFloat(d);break;case"g":d=A.precision?String(Number(d.toPrecision(A.precision))):parseFloat(d);break;case"o":d=(parseInt(d,10)>>>0).toString(8);break;case"s":d=String(d),d=A.precision?d.substring(0,A.precision):d;break;case"t":d=String(!!d),d=A.precision?d.substring(0,A.precision):d;break;case"T":d=Object.prototype.toString.call(d).slice(8,-1).toLowerCase(),d=A.precision?d.substring(0,A.precision):d;break;case"u":d=parseInt(d,10)>>>0;break;case"v":d=d.valueOf(),d=A.precision?d.substring(0,A.precision):d;break;case"x":d=(parseInt(d,10)>>>0).toString(16);break;case"X":d=(parseInt(d,10)>>>0).toString(16).toUpperCase();break}e.json.test(A.type)?E+=d:(e.number.test(A.type)&&(!y||A.sign)?(_=y?"+":"-",d=d.toString().replace(e.sign,"")):_="",S=A.pad_char?A.pad_char==="0"?"0":A.pad_char.charAt(1):" ",w=A.width-(_+d).length,m=A.width&&w>0?S.repeat(w):"",E+=A.align?_+d+m:S==="0"?_+m+d:m+_+d)}return E}var i=Object.create(null);function a(s){if(i[s])return i[s];for(var u=s,l,f=[],d=0;u;){if((l=e.text.exec(u))!==null)f.push(l[0]);else if((l=e.modulo.exec(u))!==null)f.push("%");else if((l=e.placeholder.exec(u))!==null){if(l[2]){d|=1;var E=[],p=l[2],h=[];if((h=e.key.exec(p))!==null)for(E.push(h[1]);(p=p.substring(h[0].length))!=="";)if((h=e.key_access.exec(p))!==null)E.push(h[1]);else if((h=e.index_access.exec(p))!==null)E.push(h[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 d|=2;if(d===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");f.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");u=u.substring(l[0].length)}return i[s]=f}typeof vf<"u"&&(vf.sprintf=t,vf.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var od=ye(ki=>{"use strict";var E_=ki&&ki.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),w_=ki&&ki.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),gm=ki&&ki.__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)&&E_(t,e,r);return w_(t,e),t};Object.defineProperty(ki,"__esModule",{value:!0});ki.Address4=void 0;var pm=gm(td()),Ai=gm(rd()),dm=gf(),Oc=sd(),iu=Tc(),ad=class e{constructor(t){this.groups=Ai.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=pm.isCorrect(Ai.BITS),this.isInSubnet=pm.isInSubnet,this.address=t;let r=Ai.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>Ai.BITS)throw new dm.AddressError("Invalid subnet mask.");t=t.replace(Ai.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(Ai.RE_ADDRESS))throw new dm.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=[],i;for(i=0;i<8;i+=2){let a=r.slice(i,i+2);n.push(parseInt(a,16))}return new e(n.join("."))}static fromInteger(t){return e.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new e(n)}toHex(){return this.parsedAddress.map(t=>(0,iu.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r(0,iu.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Oc.BigInteger(this.mask()+"0".repeat(Ai.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Oc.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Oc.BigInteger(this.mask()+"1".repeat(Ai.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Oc.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,iu.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(Ai.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(Ai.RE_ADDRESS,(0,iu.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};ki.Address4=ad});var ud=ye(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.RE_URL_WITH_PORT=rr.RE_URL=rr.RE_ZONE_STRING=rr.RE_SUBNET_STRING=rr.RE_BAD_ADDRESS=rr.RE_BAD_CHARACTERS=rr.TYPES=rr.SCOPES=rr.GROUPS=rr.BITS=void 0;rr.BITS=128;rr.GROUPS=8;rr.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};rr.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"};rr.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;rr.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;rr.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;rr.RE_ZONE_STRING=/%.*$/;rr.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);rr.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var cd=ye(Li=>{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});Li.simpleGroup=Li.spanLeadingZeroes=Li.spanAll=Li.spanAllZeroes=void 0;var mm=Tc();function vm(e){return e.replace(/(0+)/g,'$1')}Li.spanAllZeroes=vm;function A_(e,t=0){return e.split("").map((n,i)=>(0,mm.sprintf)('%s',n,i+t,vm(n))).join("")}Li.spanAll=A_;function Em(e){return e.replace(/^(0+)/,'$1')}function y_(e){return e.split(":").map(r=>Em(r)).join(":")}Li.spanLeadingZeroes=y_;function S_(e,t=0){return e.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,mm.sprintf)('%s',i+t,Em(n)))}Li.simpleGroup=S_});var wm=ye($r=>{"use strict";var b_=$r&&$r.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),C_=$r&&$r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__=$r&&$r.__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)&&b_(t,e,r);return C_(t,e),t};Object.defineProperty($r,"__esModule",{value:!0});$r.possibleElisions=$r.simpleRegularExpression=$r.ADDRESS_BOUNDARY=$r.padGroup=$r.groupPossibilities=void 0;var F_=__(ud()),su=Tc();function wf(e){return(0,su.sprintf)("(%s)",e.join("|"))}$r.groupPossibilities=wf;function Ef(e){return e.length<4?(0,su.sprintf)("0{0,%d}%s",4-e.length,e):e}$r.padGroup=Ef;$r.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function I_(e){let t=[];e.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let r=t.map(n=>e.map((i,a)=>{if(a===n){let s=a===0||a===F_.GROUPS-1?":":"";return wf([Ef(i),s])}return Ef(i)}).join(":"));return r.push(e.map(Ef).join(":")),wf(r)}$r.simpleRegularExpression=I_;function $_(e,t,r){let n=t?"":":",i=r?"":":",a=[];!t&&!r&&a.push("::"),t&&r&&a.push(""),(r&&!t||!r&&t)&&a.push(":"),a.push((0,su.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),a.push((0,su.sprintf)("(0{1,4}:){1,%d}%s",e-1,i)),a.push((0,su.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let s=1;s{"use strict";var D_=Ui&&Ui.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),B_=Ui&&Ui.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),yf=Ui&&Ui.__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)&&D_(t,e,r);return B_(t,e),t};Object.defineProperty(Ui,"__esModule",{value:!0});Ui.Address6=void 0;var Am=yf(td()),ld=yf(rd()),Mt=yf(ud()),fd=yf(cd()),Za=od(),Qa=wm(),bs=gf(),fn=sd(),hn=Tc();function Af(e){if(!e)throw new Error("Assertion failed.")}function R_(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function P_(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function T_(e,t){let r=[],n=[],i;for(i=0;it[1]&&n.push(e[i]);return r.concat(["compact"]).concat(n)}function ym(e){return(0,hn.sprintf)("%04x",parseInt(e,16))}function Sm(e){return e&255}var hd=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=Am.isInSubnet,this.isCorrect=Am.isCorrect(Mt.BITS),r===void 0?this.groups=Mt.GROUPS:this.groups=r,this.address=t;let n=Mt.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>Mt.BITS)throw new bs.AddressError("Invalid subnet mask.");t=t.replace(Mt.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new bs.AddressError("Invalid subnet mask.");let i=Mt.RE_ZONE_STRING.exec(t);i&&(this.zone=i[0],t=t.replace(Mt.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=[],i;for(i=0;i65536)&&(n=null)):n=null,{address:new e(r),port:n}}static fromAddress4(t){let r=new Za.Address4(t),n=Mt.BITS-(ld.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 bs.AddressError("Invalid 'ip6.arpa' form.");let i=r.split(".").reverse();for(let a=n;a>0;a--){let s=a*4;i.splice(s,0,":")}return r=i.join(""),new e(r)}microsoftTranscription(){return(0,hn.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=Mt.BITS-this.subnetMask,n=Math.abs(t-Mt.BITS),i=r-n;return i<0?"0":R_(new fn.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new fn.BigInteger(this.mask()+"0".repeat(Mt.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new fn.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new fn.BigInteger(this.mask()+"1".repeat(Mt.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new fn.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Mt.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(Mt.TYPES))if(this.isInSubnet(new e(t)))return Mt.TYPES[t];return"Global unicast"}getBits(t,r){return new fn.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,Mt.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,hn.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,r=[],n=0,i=[];for(t=0;t0&&(n>1&&i.push([t-n,t-1]),n=0)}n>1&&i.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let a=i.map(u=>u[1]-u[0]+1);if(i.length>0){let u=a.indexOf(Math.max(...a));r=T_(this.parsedAddress,i[u])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace(Mt.RE_BAD_CHARACTERS,'$1'));let n=t.match(Mt.RE_BAD_ADDRESS);if(n)throw new bs.AddressError((0,hn.sprintf)("Address failed regex: %s",n.join("")),t.replace(Mt.RE_BAD_ADDRESS,'$1'));let i=[],a=t.split("::");if(a.length===2){let s=a[0].split(":"),u=a[1].split(":");s.length===1&&s[0]===""&&(s=[]),u.length===1&&u[0]===""&&(u=[]);let l=this.groups-(s.length+u.length);if(!l)throw new bs.AddressError("Error parsing groups");this.elidedGroups=l,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,i=i.concat(s);for(let f=0;f(0,hn.sprintf)("%x",parseInt(s,16))),i.length!==this.groups)throw new bs.AddressError("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(ym).join(":")}decimal(){return this.parsedAddress.map(t=>(0,hn.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new fn.BigInteger(this.parsedAddress.map(ym).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return Za.Address4.fromHex(new fn.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(),i="";return/:$/.test(n)||(i=":"),n+i+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),r=this.getBits(80,96).xor(new fn.BigInteger("ffff",16)).toString(),n=Za.Address4.fromHex(this.getBitsBase16(32,64)),i=Za.Address4.fromHex(this.getBits(96,128).xor(new fn.BigInteger("ffffffff",16)).toString(16)),a=this.getBits(64,80),s=this.getBitsBase2(64,80),u=a.testBit(15),l=a.testBit(14),f=a.testBit(8),d=a.testBit(9),E=new fn.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,hn.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:s,coneNat:u,microsoft:{reserved:l,universalLocal:d,groupIndividual:f,nonce:E},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=Za.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,hn.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(Sm)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Sm))}static fromUnsignedByteArray(t){let r=new fn.BigInteger("256",10),n=new fn.BigInteger("0",10),i=new fn.BigInteger("1",10);for(let a=t.length-1;a>=0;a--)n=n.add(i.multiply(new fn.BigInteger(t[a].toString(10),10))),i=i.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,hn.sprintf)(":%s",t),(0,hn.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,hn.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,hn.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return fd.simpleGroup(this.address).join(":");Af(typeof this.elidedGroups=="number"),Af(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...fd.simpleGroup(r)):t.push("");let i=["hover-group"];for(let a=this.elisionBegin;a',i.join(" "))),n.length?t.push(...fd.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(Af(this.address4 instanceof Za.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,Qa.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===Mt.GROUPS)r.push((0,Qa.possibleElisions)(Mt.GROUPS));else{let i=n.address.split("::");i[0].length&&r.push((0,Qa.simpleRegularExpression)(i[0].split(":"))),Af(typeof n.elidedGroups=="number"),r.push((0,Qa.possibleElisions)(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&r.push((0,Qa.simpleRegularExpression)(i[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",Qa.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",Qa.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};Ui.Address6=hd});var Cm=ye(Jr=>{"use strict";var O_=Jr&&Jr.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),x_=Jr&&Jr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),N_=Jr&&Jr.__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)&&O_(t,e,r);return x_(t,e),t};Object.defineProperty(Jr,"__esModule",{value:!0});Jr.v6=Jr.AddressError=Jr.Address6=Jr.Address4=void 0;var k_=od();Object.defineProperty(Jr,"Address4",{enumerable:!0,get:function(){return k_.Address4}});var L_=bm();Object.defineProperty(Jr,"Address6",{enumerable:!0,get:function(){return L_.Address6}});var U_=gf();Object.defineProperty(Jr,"AddressError",{enumerable:!0,get:function(){return U_.AddressError}});var H_=N_(cd());Jr.v6={helpers:H_}});var Ym=ye($f=>{"use strict";$f.byteLength=n5;$f.toByteArray=s5;$f.fromByteArray=u5;var Mi=[],ui=[],r5=typeof Uint8Array<"u"?Uint8Array:Array,wd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ro=0,Gm=wd.length;ro0)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 n5(e){var t=zm(e),r=t[0],n=t[1];return(r+n)*3/4-n}function i5(e,t,r){return(t+r)*3/4-r}function s5(e){var t,r=zm(e),n=r[0],i=r[1],a=new r5(i5(e,n,i)),s=0,u=i>0?n-4:n,l;for(l=0;l>16&255,a[s++]=t>>8&255,a[s++]=t&255;return i===2&&(t=ui[e.charCodeAt(l)]<<2|ui[e.charCodeAt(l+1)]>>4,a[s++]=t&255),i===1&&(t=ui[e.charCodeAt(l)]<<10|ui[e.charCodeAt(l+1)]<<4|ui[e.charCodeAt(l+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function a5(e){return Mi[e>>18&63]+Mi[e>>12&63]+Mi[e>>6&63]+Mi[e&63]}function o5(e,t,r){for(var n,i=[],a=t;au?u:s+a));return n===1?(t=e[r-1],i.push(Mi[t>>2]+Mi[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Mi[t>>10]+Mi[t>>4&63]+Mi[t<<2&63]+"=")),i.join("")}});var Wm=ye(Ad=>{Ad.read=function(e,t,r,n,i){var a,s,u=i*8-n-1,l=(1<>1,d=-7,E=r?i-1:0,p=r?-1:1,h=e[t+E];for(E+=p,a=h&(1<<-d)-1,h>>=-d,d+=u;d>0;a=a*256+e[t+E],E+=p,d-=8);for(s=a&(1<<-d)-1,a>>=-d,d+=n;d>0;s=s*256+e[t+E],E+=p,d-=8);if(a===0)a=1-f;else{if(a===l)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,n),a=a-f}return(h?-1:1)*s*Math.pow(2,a-n)};Ad.write=function(e,t,r,n,i,a){var s,u,l,f=a*8-i-1,d=(1<>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,A=n?1:-1,m=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+E>=1?t+=p/l:t+=p*Math.pow(2,1-E),t*l>=2&&(s++,l/=2),s+E>=d?(u=0,s=d):s+E>=1?(u=(t*l-1)*Math.pow(2,i),s=s+E):(u=t*Math.pow(2,E-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=u&255,h+=A,u/=256,i-=8);for(s=s<0;e[r+h]=s&255,h+=A,s/=256,f-=8);e[r+h-A]|=m*128}});var Rf=ye(mu=>{"use strict";var yd=Ym(),du=Wm(),Xm=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;mu.Buffer=fe;mu.SlowBuffer=d5;mu.INSPECT_MAX_BYTES=50;var Df=2147483647;mu.kMaxLength=Df;fe.TYPED_ARRAY_SUPPORT=c5();!fe.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 c5(){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(fe.prototype,"parent",{enumerable:!0,get:function(){if(fe.isBuffer(this))return this.buffer}});Object.defineProperty(fe.prototype,"offset",{enumerable:!0,get:function(){if(fe.isBuffer(this))return this.byteOffset}});function _s(e){if(e>Df)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,fe.prototype),t}function fe(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 _d(e)}return ev(e,t,r)}fe.poolSize=8192;function ev(e,t,r){if(typeof e=="string")return f5(e,t);if(ArrayBuffer.isView(e))return h5(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(ji(e,ArrayBuffer)||e&&ji(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ji(e,SharedArrayBuffer)||e&&ji(e.buffer,SharedArrayBuffer)))return bd(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 fe.from(n,t,r);let i=p5(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return fe.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)}fe.from=function(e,t,r){return ev(e,t,r)};Object.setPrototypeOf(fe.prototype,Uint8Array.prototype);Object.setPrototypeOf(fe,Uint8Array);function tv(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 l5(e,t,r){return tv(e),e<=0?_s(e):t!==void 0?typeof r=="string"?_s(e).fill(t,r):_s(e).fill(t):_s(e)}fe.alloc=function(e,t,r){return l5(e,t,r)};function _d(e){return tv(e),_s(e<0?0:Fd(e)|0)}fe.allocUnsafe=function(e){return _d(e)};fe.allocUnsafeSlow=function(e){return _d(e)};function f5(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!fe.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=rv(e,t)|0,n=_s(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Sd(e){let t=e.length<0?0:Fd(e.length)|0,r=_s(t);for(let n=0;n=Df)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Df.toString(16)+" bytes");return e|0}function d5(e){return+e!=e&&(e=0),fe.alloc(+e)}fe.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==fe.prototype};fe.compare=function(t,r){if(ji(t,Uint8Array)&&(t=fe.from(t,t.offset,t.byteLength)),ji(r,Uint8Array)&&(r=fe.from(r,r.offset,r.byteLength)),!fe.isBuffer(t)||!fe.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,i=r.length;for(let a=0,s=Math.min(n,i);ai.length?(fe.isBuffer(s)||(s=fe.from(s)),s.copy(i,a)):Uint8Array.prototype.set.call(i,s,a);else if(fe.isBuffer(s))s.copy(i,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=s.length}return i};function rv(e,t){if(fe.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||ji(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 i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Cd(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return fv(e).length;default:if(i)return n?-1:Cd(e).length;t=(""+t).toLowerCase(),i=!0}}fe.byteLength=rv;function g5(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 _5(this,t,r);case"utf8":case"utf-8":return iv(this,t,r);case"ascii":return b5(this,t,r);case"latin1":case"binary":return C5(this,t,r);case"base64":return y5(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F5(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}fe.prototype._isBuffer=!0;function no(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}fe.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+=" ... "),""};Xm&&(fe.prototype[Xm]=fe.prototype.inspect);fe.prototype.compare=function(t,r,n,i,a){if(ji(t,Uint8Array)&&(t=fe.from(t,t.offset,t.byteLength)),!fe.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),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>t.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===t)return 0;let s=a-i,u=n-r,l=Math.min(s,u),f=this.slice(i,a),d=t.slice(r,n);for(let E=0;E2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,$d(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=fe.from(t,n)),fe.isBuffer(t))return t.length===0?-1:Jm(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Jm(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Jm(e,t,r,n,i){let a=1,s=e.length,u=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function l(d,E){return a===1?d[E]:d.readUInt16BE(E*a)}let f;if(i){let d=-1;for(f=r;fs&&(r=s-u),f=r;f>=0;f--){let d=!0;for(let E=0;Ei&&(n=i)):n=i;let a=t.length;n>a/2&&(n=a/2);let s;for(s=0;s>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-r;if((n===void 0||n>a)&&(n=a),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return m5(this,t,r,n);case"utf8":case"utf-8":return v5(this,t,r,n);case"ascii":case"latin1":case"binary":return E5(this,t,r,n);case"base64":return w5(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A5(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};fe.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function y5(e,t,r){return t===0&&r===e.length?yd.fromByteArray(e):yd.fromByteArray(e.slice(t,r))}function iv(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i239?4:a>223?3:a>191?2:1;if(i+u<=r){let l,f,d,E;switch(u){case 1:a<128&&(s=a);break;case 2:l=e[i+1],(l&192)===128&&(E=(a&31)<<6|l&63,E>127&&(s=E));break;case 3:l=e[i+1],f=e[i+2],(l&192)===128&&(f&192)===128&&(E=(a&15)<<12|(l&63)<<6|f&63,E>2047&&(E<55296||E>57343)&&(s=E));break;case 4:l=e[i+1],f=e[i+2],d=e[i+3],(l&192)===128&&(f&192)===128&&(d&192)===128&&(E=(a&15)<<18|(l&63)<<12|(f&63)<<6|d&63,E>65535&&E<1114112&&(s=E))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=u}return S5(n)}var Zm=4096;function S5(e){let t=e.length;if(t<=Zm)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn)&&(r=n);let i="";for(let a=t;an&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}fe.prototype.readUintLE=fe.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Dr(t,r,this.length);let i=this[t],a=1,s=0;for(;++s>>0,r=r>>>0,n||Dr(t,r,this.length);let i=this[t+--r],a=1;for(;r>0&&(a*=256);)i+=this[t+--r]*a;return i};fe.prototype.readUint8=fe.prototype.readUInt8=function(t,r){return t=t>>>0,r||Dr(t,1,this.length),this[t]};fe.prototype.readUint16LE=fe.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Dr(t,2,this.length),this[t]|this[t+1]<<8};fe.prototype.readUint16BE=fe.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Dr(t,2,this.length),this[t]<<8|this[t+1]};fe.prototype.readUint32LE=fe.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Dr(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};fe.prototype.readUint32BE=fe.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Dr(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};fe.prototype.readBigUInt64LE=fa(function(t){t=t>>>0,gu(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Lc(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,a=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(a)<>>0,gu(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Lc(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],a=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<>>0,r=r>>>0,n||Dr(t,r,this.length);let i=this[t],a=1,s=0;for(;++s=a&&(i-=Math.pow(2,8*r)),i};fe.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Dr(t,r,this.length);let i=r,a=1,s=this[t+--i];for(;i>0&&(a*=256);)s+=this[t+--i]*a;return a*=128,s>=a&&(s-=Math.pow(2,8*r)),s};fe.prototype.readInt8=function(t,r){return t=t>>>0,r||Dr(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};fe.prototype.readInt16LE=function(t,r){t=t>>>0,r||Dr(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};fe.prototype.readInt16BE=function(t,r){t=t>>>0,r||Dr(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};fe.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Dr(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};fe.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Dr(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};fe.prototype.readBigInt64LE=fa(function(t){t=t>>>0,gu(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Lc(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<>>0,gu(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Lc(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<>>0,r||Dr(t,4,this.length),du.read(this,t,!0,23,4)};fe.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Dr(t,4,this.length),du.read(this,t,!1,23,4)};fe.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Dr(t,8,this.length),du.read(this,t,!0,52,8)};fe.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Dr(t,8,this.length),du.read(this,t,!1,52,8)};function _n(e,t,r,n,i,a){if(!fe.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}fe.prototype.writeUintLE=fe.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let u=Math.pow(2,8*n)-1;_n(this,t,r,n,u,0)}let a=1,s=0;for(this[r]=t&255;++s>>0,n=n>>>0,!i){let u=Math.pow(2,8*n)-1;_n(this,t,r,n,u,0)}let a=n-1,s=1;for(this[r+a]=t&255;--a>=0&&(s*=256);)this[r+a]=t/s&255;return r+n};fe.prototype.writeUint8=fe.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||_n(this,t,r,1,255,0),this[r]=t&255,r+1};fe.prototype.writeUint16LE=fe.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||_n(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};fe.prototype.writeUint16BE=fe.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||_n(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};fe.prototype.writeUint32LE=fe.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||_n(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};fe.prototype.writeUint32BE=fe.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||_n(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 sv(e,t,r,n,i){lv(t,n,i,e,r,7);let a=Number(t&BigInt(4294967295));e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function av(e,t,r,n,i){lv(t,n,i,e,r,7);let a=Number(t&BigInt(4294967295));e[r+7]=a,a=a>>8,e[r+6]=a,a=a>>8,e[r+5]=a,a=a>>8,e[r+4]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}fe.prototype.writeBigUInt64LE=fa(function(t,r=0){return sv(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});fe.prototype.writeBigUInt64BE=fa(function(t,r=0){return av(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});fe.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);_n(this,t,r,n,l-1,-l)}let a=0,s=1,u=0;for(this[r]=t&255;++a>0)-u&255;return r+n};fe.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);_n(this,t,r,n,l-1,-l)}let a=n-1,s=1,u=0;for(this[r+a]=t&255;--a>=0&&(s*=256);)t<0&&u===0&&this[r+a+1]!==0&&(u=1),this[r+a]=(t/s>>0)-u&255;return r+n};fe.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||_n(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};fe.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||_n(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};fe.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||_n(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};fe.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||_n(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};fe.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||_n(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};fe.prototype.writeBigInt64LE=fa(function(t,r=0){return sv(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});fe.prototype.writeBigInt64BE=fa(function(t,r=0){return av(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ov(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function uv(e,t,r,n,i){return t=+t,r=r>>>0,i||ov(e,t,r,4,34028234663852886e22,-34028234663852886e22),du.write(e,t,r,n,23,4),r+4}fe.prototype.writeFloatLE=function(t,r,n){return uv(this,t,r,!0,n)};fe.prototype.writeFloatBE=function(t,r,n){return uv(this,t,r,!1,n)};function cv(e,t,r,n,i){return t=+t,r=r>>>0,i||ov(e,t,r,8,17976931348623157e292,-17976931348623157e292),du.write(e,t,r,n,52,8),r+8}fe.prototype.writeDoubleLE=function(t,r,n){return cv(this,t,r,!0,n)};fe.prototype.writeDoubleBE=function(t,r,n){return cv(this,t,r,!1,n)};fe.prototype.copy=function(t,r,n,i){if(!fe.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let a;if(typeof t=="number")for(a=r;a2**32?i=Qm(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Qm(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function Qm(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 I5(e,t,r){gu(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Lc(t,e.length-(r+1))}function lv(e,t,r,n,i,a){if(e>r||e3?t===0||t===BigInt(0)?u=`>= 0${s} and < 2${s} ** ${(a+1)*8}${s}`:u=`>= -(2${s} ** ${(a+1)*8-1}${s}) and < 2 ** ${(a+1)*8-1}${s}`:u=`>= ${t}${s} and <= ${r}${s}`,new pu.ERR_OUT_OF_RANGE("value",u,e)}I5(n,i,a)}function gu(e,t){if(typeof e!="number")throw new pu.ERR_INVALID_ARG_TYPE(t,"number",e)}function Lc(e,t,r){throw Math.floor(e)!==e?(gu(e,r),new pu.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new pu.ERR_BUFFER_OUT_OF_BOUNDS:new pu.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var $5=/[^+/0-9A-Za-z-_]/g;function D5(e){if(e=e.split("=")[0],e=e.trim().replace($5,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Cd(e,t){t=t||1/0;let r,n=e.length,i=null,a=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function B5(e){let t=[];for(let r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function fv(e){return yd.toByteArray(D5(e))}function Bf(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function ji(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function $d(e){return e!==e}var P5=function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function fa(e){return typeof BigInt>"u"?T5:e}function T5(){throw new Error("BigInt not supported")}});var xv=ye(be=>{var Uc={};Uc.userAgent=!1;var vu={},O5="11.1.0",x5="jsrsasign(all) 11.1.0 (2024-02-01) (c) 2010-2023 Kenji Urushima | kjur.github.io/jsrsasign/license";var Ce=Ce||function(e,t){var r={},n=r.lib={},i=n.Base=function(){function h(){}return{extend:function(A){h.prototype=this;var m=new h;return A&&m.mixIn(A),m.hasOwnProperty("init")||(m.init=function(){m.$super.init.apply(this,arguments)}),m.init.prototype=m,m.$super=this,m},create:function(){var A=this.extend();return A.init.apply(A,arguments),A},init:function(){},mixIn:function(A){for(var m in A)A.hasOwnProperty(m)&&(this[m]=A[m]);A.hasOwnProperty("toString")&&(this.toString=A.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=n.WordArray=i.extend({init:function(h,A){h=this.words=h||[],A!=t?this.sigBytes=A:this.sigBytes=h.length*4},toString:function(h){return(h||u).stringify(this)},concat:function(h){var A=this.words,m=h.words,S=this.sigBytes,w=h.sigBytes;if(this.clamp(),S%4)for(var y=0;y>>2]>>>24-y%4*8&255;A[S+y>>>2]|=_<<24-(S+y)%4*8}else for(var y=0;y>>2]=m[y>>>2];return this.sigBytes+=w,this},clamp:function(){var h=this.words,A=this.sigBytes;h[A>>>2]&=4294967295<<32-A%4*8,h.length=e.ceil(A/4)},clone:function(){var h=i.clone.call(this);return h.words=this.words.slice(0),h},random:function(h){for(var A=[],m=0;m>>2]>>>24-w%4*8&255;S.push((y>>>4).toString(16)),S.push((y&15).toString(16))}return S.join("")},parse:function(h){for(var A=h.length,m=[],S=0;S>>3]|=parseInt(h.substr(S,2),16)<<24-S%8*4;return new a.init(m,A/2)}},l=s.Latin1={stringify:function(h){for(var A=h.words,m=h.sigBytes,S=[],w=0;w>>2]>>>24-w%4*8&255;S.push(String.fromCharCode(y))}return S.join("")},parse:function(h){for(var A=h.length,m=[],S=0;S>>2]|=(h.charCodeAt(S)&255)<<24-S%4*8;return new a.init(m,A)}},f=s.Utf8={stringify:function(h){try{return decodeURIComponent(escape(l.stringify(h)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(h){return l.parse(unescape(encodeURIComponent(h)))}},d=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(h){typeof h=="string"&&(h=f.parse(h)),this._data.concat(h),this._nDataBytes+=h.sigBytes},_process:function(h){var A=this._data,m=A.words,S=A.sigBytes,w=this.blockSize,y=w*4,_=S/y;h?_=e.ceil(_):_=e.max((_|0)-this._minBufferSize,0);var B=_*w,D=e.min(B*4,S);if(B){for(var j=0;j>>2]&255}},t.BlockCipher=u.extend({cfg:u.cfg.extend({mode:E,padding:f}),reset:function(){u.reset.call(this);var S=this.cfg,m=S.iv,S=S.mode;if(this._xformMode==this._ENC_XFORM_MODE)var w=S.createEncryptor;else w=S.createDecryptor,this._minBufferSize=1;this._mode=w.call(S,this,m&&m.words)},_doProcessBlock:function(m,S){this._mode.processBlock(m,S)},_doFinalize:function(){var m=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){m.pad(this._data,this.blockSize);var S=this._process(!0)}else S=this._process(!0),m.unpad(S);return S},blockSize:4});var d=t.CipherParams=r.extend({init:function(m){this.mixIn(m)},toString:function(m){return(m||this.formatter).stringify(this)}}),E=(h.format={}).OpenSSL={stringify:function(m){var S=m.ciphertext;return m=m.salt,(m?n.create([1398893684,1701076831]).concat(m).concat(S):S).toString(a)},parse:function(m){m=a.parse(m);var S=m.words;if(S[0]==1398893684&&S[1]==1701076831){var w=n.create(S.slice(2,4));S.splice(0,4),m.sigBytes-=16}return d.create({ciphertext:m,salt:w})}},p=t.SerializableCipher=r.extend({cfg:r.extend({format:E}),encrypt:function(m,S,w,y){y=this.cfg.extend(y);var _=m.createEncryptor(w,y);return S=_.finalize(S),_=_.cfg,d.create({ciphertext:S,key:w,iv:_.iv,algorithm:m,mode:_.mode,padding:_.padding,blockSize:m.blockSize,formatter:y.format})},decrypt:function(m,S,w,y){return y=this.cfg.extend(y),S=this._parse(S,y.format),m.createDecryptor(w,y).finalize(S.ciphertext)},_parse:function(m,S){return typeof m=="string"?S.parse(m,this):m}}),h=(h.kdf={}).OpenSSL={execute:function(m,S,w,y){return y||(y=n.random(8)),m=s.create({keySize:S+w}).compute(m,y),w=n.create(m.words.slice(S),4*w),m.sigBytes=4*S,d.create({key:m,iv:w,salt:y})}},A=t.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:h}),encrypt:function(m,S,w,y){return y=this.cfg.extend(y),w=y.kdf.execute(w,m.keySize,m.ivSize),y.iv=w.iv,m=p.encrypt.call(this,m,S,w.key,y),m.mixIn(w),m},decrypt:function(m,S,w,y){return y=this.cfg.extend(y),S=this._parse(S,y.format),w=y.kdf.execute(w,m.keySize,m.ivSize,S.salt),y.iv=w.iv,p.decrypt.call(this,m,S,w.key,y)}})}();(function(){for(var e=Ce,t=e.lib.BlockCipher,j=e.algo,r=[],n=[],i=[],a=[],s=[],u=[],l=[],f=[],d=[],E=[],p=[],h=0;256>h;h++)p[h]=128>h?h<<1:h<<1^283;for(var A=0,m=0,h=0;256>h;h++){var S=m^m<<1^m<<2^m<<3^m<<4,S=S>>>8^S&255^99;r[A]=S,n[S]=A;var w=p[A],y=p[w],_=p[y],B=257*p[S]^16843008*S;i[A]=B<<24|B>>>8,a[A]=B<<16|B>>>16,s[A]=B<<8|B>>>24,u[A]=B,B=16843009*_^65537*y^257*w^16843008*A,l[S]=B<<24|B>>>8,f[S]=B<<16|B>>>16,d[S]=B<<8|B>>>24,E[S]=B,A?(A=w^p[p[p[_^w]]],m^=p[p[m]]):A=m=1}var D=[0,1,2,4,8,16,32,64,128,27,54],j=j.AES=t.extend({_doReset:function(){for(var P=this._key,q=P.words,F=P.sigBytes/4,P=4*((this._nRounds=F+6)+1),L=this._keySchedule=[],M=0;M>>24]<<24|r[V>>>16&255]<<16|r[V>>>8&255]<<8|r[V&255]):(V=V<<8|V>>>24,V=r[V>>>24]<<24|r[V>>>16&255]<<16|r[V>>>8&255]<<8|r[V&255],V^=D[M/F|0]<<24),L[M]=L[M-F]^V}for(q=this._invKeySchedule=[],F=0;FF||4>=M?V:l[r[V>>>24]]^f[r[V>>>16&255]]^d[r[V>>>8&255]]^E[r[V&255]]},encryptBlock:function(q,F){this._doCryptBlock(q,F,this._keySchedule,i,a,s,u,r)},decryptBlock:function(q,F){var P=q[F+1];q[F+1]=q[F+3],q[F+3]=P,this._doCryptBlock(q,F,this._invKeySchedule,l,f,d,E,n),P=q[F+1],q[F+1]=q[F+3],q[F+3]=P},_doCryptBlock:function(q,F,P,L,M,V,W,G){for(var z=this._nRounds,ue=q[F]^P[0],_e=q[F+1]^P[1],He=q[F+2]^P[2],Ve=q[F+3]^P[3],X=4,ie=1;ie>>24]^M[_e>>>16&255]^V[He>>>8&255]^W[Ve&255]^P[X++],we=L[_e>>>24]^M[He>>>16&255]^V[Ve>>>8&255]^W[ue&255]^P[X++],Ie=L[He>>>24]^M[Ve>>>16&255]^V[ue>>>8&255]^W[_e&255]^P[X++],Ve=L[Ve>>>24]^M[ue>>>16&255]^V[_e>>>8&255]^W[He&255]^P[X++],ue=Se,_e=we,He=Ie;Se=(G[ue>>>24]<<24|G[_e>>>16&255]<<16|G[He>>>8&255]<<8|G[Ve&255])^P[X++],we=(G[_e>>>24]<<24|G[He>>>16&255]<<16|G[Ve>>>8&255]<<8|G[ue&255])^P[X++],Ie=(G[He>>>24]<<24|G[Ve>>>16&255]<<16|G[ue>>>8&255]<<8|G[_e&255])^P[X++],Ve=(G[Ve>>>24]<<24|G[ue>>>16&255]<<16|G[_e>>>8&255]<<8|G[He&255])^P[X++],q[F]=Se,q[F+1]=we,q[F+2]=Ie,q[F+3]=Ve},keySize:8});e.AES=t._createHelper(j)})();(function(){function e(p,h){var A=(this._lBlock>>>p^this._rBlock)&h;this._rBlock^=A,this._lBlock^=A<>>p^this._lBlock)&h;this._lBlock^=A,this._rBlock^=A<A;A++){var m=s[A]-1;h[A]=p[m>>>5]>>>31-m%32&1}for(p=this._subKeys=[],m=0;16>m;m++){for(var S=p[m]=[],w=l[m],A=0;24>A;A++)S[A/6|0]|=h[(u[A]-1+w)%28]<<31-A%6,S[4+(A/6|0)]|=h[28+(u[A+24]-1+w)%28]<<31-A%6;for(S[0]=S[0]<<1|S[0]>>>31,A=1;7>A;A++)S[A]>>>=4*(A-1)+3;S[7]=S[7]<<5|S[7]>>>27}for(h=this._invSubKeys=[],A=0;16>A;A++)h[A]=p[15-A]},encryptBlock:function(p,h){this._doCryptBlock(p,h,this._subKeys)},decryptBlock:function(p,h){this._doCryptBlock(p,h,this._invSubKeys)},_doCryptBlock:function(p,h,A){this._lBlock=p[h],this._rBlock=p[h+1],e.call(this,4,252645135),e.call(this,16,65535),t.call(this,2,858993459),t.call(this,8,16711935),e.call(this,1,1431655765);for(var m=0;16>m;m++){for(var S=A[m],w=this._lBlock,y=this._rBlock,_=0,B=0;8>B;B++)_|=f[B][((y^S[B])&d[B])>>>0];this._lBlock=y,this._rBlock=w^_}A=this._lBlock,this._lBlock=this._rBlock,this._rBlock=A,e.call(this,1,1431655765),t.call(this,8,16711935),t.call(this,2,858993459),e.call(this,16,65535),e.call(this,4,252645135),p[h]=this._lBlock,p[h+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=i._createHelper(E),a=a.TripleDES=i.extend({_doReset:function(){var p=this._key.words;this._des1=E.createEncryptor(n.create(p.slice(0,2))),this._des2=E.createEncryptor(n.create(p.slice(2,4))),this._des3=E.createEncryptor(n.create(p.slice(4,6)))},encryptBlock:function(p,h){this._des1.encryptBlock(p,h),this._des2.decryptBlock(p,h),this._des3.encryptBlock(p,h)},decryptBlock:function(p,h){this._des3.decryptBlock(p,h),this._des2.encryptBlock(p,h),this._des1.decryptBlock(p,h)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=i._createHelper(a)})();(function(){var e=Ce,t=e.lib.WordArray;e.enc.Base64={stringify:function(r){var n=r.words,i=r.sigBytes,a=this._map;r.clamp(),r=[];for(var s=0;s>>2]>>>24-8*(s%4)&255)<<16|(n[s+1>>>2]>>>24-8*((s+1)%4)&255)<<8|n[s+2>>>2]>>>24-8*((s+2)%4)&255,l=0;4>l&&s+.75*l>>6*(3-l)&63));if(n=a.charAt(64))for(;r.length%4;)r.push(n);return r.join("")},parse:function(r){var n=r.length,i=this._map,a=i.charAt(64);a&&(a=r.indexOf(a),a!=-1&&(n=a));for(var a=[],s=0,u=0;u>>6-2*(u%4);a[s>>>2]|=(l|f)<<24-8*(s%4),s++}return t.create(a,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();(function(e){function t(E,p,h,A,m,S,w){return E=E+(p&h|~p&A)+m+w,(E<>>32-S)+p}function r(E,p,h,A,m,S,w){return E=E+(p&A|h&~A)+m+w,(E<>>32-S)+p}function n(E,p,h,A,m,S,w){return E=E+(p^h^A)+m+w,(E<>>32-S)+p}function i(E,p,h,A,m,S,w){return E=E+(h^(p|~A))+m+w,(E<>>32-S)+p}for(var a=Ce,l=a.lib,s=l.WordArray,u=l.Hasher,l=a.algo,f=[],d=0;64>d;d++)f[d]=4294967296*e.abs(e.sin(d+1))|0;l=l.MD5=u.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(E,p){for(var h=0;16>h;h++){var A=p+h,m=E[A];E[A]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360}var h=this._hash.words,A=E[p+0],m=E[p+1],S=E[p+2],w=E[p+3],y=E[p+4],_=E[p+5],B=E[p+6],D=E[p+7],j=E[p+8],q=E[p+9],F=E[p+10],P=E[p+11],L=E[p+12],M=E[p+13],V=E[p+14],W=E[p+15],G=h[0],ie=h[1],X=h[2],z=h[3],G=t(G,ie,X,z,A,7,f[0]),z=t(z,G,ie,X,m,12,f[1]),X=t(X,z,G,ie,S,17,f[2]),ie=t(ie,X,z,G,w,22,f[3]),G=t(G,ie,X,z,y,7,f[4]),z=t(z,G,ie,X,_,12,f[5]),X=t(X,z,G,ie,B,17,f[6]),ie=t(ie,X,z,G,D,22,f[7]),G=t(G,ie,X,z,j,7,f[8]),z=t(z,G,ie,X,q,12,f[9]),X=t(X,z,G,ie,F,17,f[10]),ie=t(ie,X,z,G,P,22,f[11]),G=t(G,ie,X,z,L,7,f[12]),z=t(z,G,ie,X,M,12,f[13]),X=t(X,z,G,ie,V,17,f[14]),ie=t(ie,X,z,G,W,22,f[15]),G=r(G,ie,X,z,m,5,f[16]),z=r(z,G,ie,X,B,9,f[17]),X=r(X,z,G,ie,P,14,f[18]),ie=r(ie,X,z,G,A,20,f[19]),G=r(G,ie,X,z,_,5,f[20]),z=r(z,G,ie,X,F,9,f[21]),X=r(X,z,G,ie,W,14,f[22]),ie=r(ie,X,z,G,y,20,f[23]),G=r(G,ie,X,z,q,5,f[24]),z=r(z,G,ie,X,V,9,f[25]),X=r(X,z,G,ie,w,14,f[26]),ie=r(ie,X,z,G,j,20,f[27]),G=r(G,ie,X,z,M,5,f[28]),z=r(z,G,ie,X,S,9,f[29]),X=r(X,z,G,ie,D,14,f[30]),ie=r(ie,X,z,G,L,20,f[31]),G=n(G,ie,X,z,_,4,f[32]),z=n(z,G,ie,X,j,11,f[33]),X=n(X,z,G,ie,P,16,f[34]),ie=n(ie,X,z,G,V,23,f[35]),G=n(G,ie,X,z,m,4,f[36]),z=n(z,G,ie,X,y,11,f[37]),X=n(X,z,G,ie,D,16,f[38]),ie=n(ie,X,z,G,F,23,f[39]),G=n(G,ie,X,z,M,4,f[40]),z=n(z,G,ie,X,A,11,f[41]),X=n(X,z,G,ie,w,16,f[42]),ie=n(ie,X,z,G,B,23,f[43]),G=n(G,ie,X,z,q,4,f[44]),z=n(z,G,ie,X,L,11,f[45]),X=n(X,z,G,ie,W,16,f[46]),ie=n(ie,X,z,G,S,23,f[47]),G=i(G,ie,X,z,A,6,f[48]),z=i(z,G,ie,X,D,10,f[49]),X=i(X,z,G,ie,V,15,f[50]),ie=i(ie,X,z,G,_,21,f[51]),G=i(G,ie,X,z,L,6,f[52]),z=i(z,G,ie,X,w,10,f[53]),X=i(X,z,G,ie,F,15,f[54]),ie=i(ie,X,z,G,m,21,f[55]),G=i(G,ie,X,z,j,6,f[56]),z=i(z,G,ie,X,W,10,f[57]),X=i(X,z,G,ie,B,15,f[58]),ie=i(ie,X,z,G,M,21,f[59]),G=i(G,ie,X,z,y,6,f[60]),z=i(z,G,ie,X,P,10,f[61]),X=i(X,z,G,ie,S,15,f[62]),ie=i(ie,X,z,G,q,21,f[63]);h[0]=h[0]+G|0,h[1]=h[1]+ie|0,h[2]=h[2]+X|0,h[3]=h[3]+z|0},_doFinalize:function(){var E=this._data,p=E.words,h=8*this._nDataBytes,A=8*E.sigBytes;p[A>>>5]|=128<<24-A%32;var m=e.floor(h/4294967296);for(p[(A+64>>>9<<4)+15]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,p[(A+64>>>9<<4)+14]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360,E.sigBytes=4*(p.length+1),this._process(),E=this._hash,p=E.words,h=0;4>h;h++)A=p[h],p[h]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360;return E},clone:function(){var E=u.clone.call(this);return E._hash=this._hash.clone(),E}}),a.MD5=u._createHelper(l),a.HmacMD5=u._createHmacHelper(l)})(Math);(function(){var e=Ce,i=e.lib,t=i.WordArray,r=i.Hasher,n=[],i=e.algo.SHA1=r.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,s){for(var u=this._hash.words,l=u[0],f=u[1],d=u[2],E=u[3],p=u[4],h=0;80>h;h++){if(16>h)n[h]=a[s+h]|0;else{var A=n[h-3]^n[h-8]^n[h-14]^n[h-16];n[h]=A<<1|A>>>31}A=(l<<5|l>>>27)+p+n[h],A=20>h?A+((f&d|~f&E)+1518500249):40>h?A+((f^d^E)+1859775393):60>h?A+((f&d|f&E|d&E)-1894007588):A+((f^d^E)-899497514),p=E,E=d,d=f<<30|f>>>2,f=l,l=A}u[0]=u[0]+l|0,u[1]=u[1]+f|0,u[2]=u[2]+d|0,u[3]=u[3]+E|0,u[4]=u[4]+p|0},_doFinalize:function(){var a=this._data,s=a.words,u=8*this._nDataBytes,l=8*a.sigBytes;return s[l>>>5]|=128<<24-l%32,s[(l+64>>>9<<4)+14]=Math.floor(u/4294967296),s[(l+64>>>9<<4)+15]=u,a.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var a=r.clone.call(this);return a._hash=this._hash.clone(),a}});e.SHA1=r._createHelper(i),e.HmacSHA1=r._createHmacHelper(i)})();(function(e){for(var t=Ce,h=t.lib,r=h.WordArray,n=h.Hasher,h=t.algo,i=[],a=[],s=function(m){return 4294967296*(m-(m|0))|0},u=2,l=0;64>l;){var f;e:{f=u;for(var d=e.sqrt(f),E=2;E<=d;E++)if(!(f%E)){f=!1;break e}f=!0}f&&(8>l&&(i[l]=s(e.pow(u,.5))),a[l]=s(e.pow(u,1/3)),l++),u++}var p=[],h=h.SHA256=n.extend({_doReset:function(){this._hash=new r.init(i.slice(0))},_doProcessBlock:function(A,m){for(var S=this._hash.words,w=S[0],y=S[1],_=S[2],B=S[3],D=S[4],j=S[5],q=S[6],F=S[7],P=0;64>P;P++){if(16>P)p[P]=A[m+P]|0;else{var L=p[P-15],M=p[P-2];p[P]=((L<<25|L>>>7)^(L<<14|L>>>18)^L>>>3)+p[P-7]+((M<<15|M>>>17)^(M<<13|M>>>19)^M>>>10)+p[P-16]}L=F+((D<<26|D>>>6)^(D<<21|D>>>11)^(D<<7|D>>>25))+(D&j^~D&q)+a[P]+p[P],M=((w<<30|w>>>2)^(w<<19|w>>>13)^(w<<10|w>>>22))+(w&y^w&_^y&_),F=q,q=j,j=D,D=B+L|0,B=_,_=y,y=w,w=L+M|0}S[0]=S[0]+w|0,S[1]=S[1]+y|0,S[2]=S[2]+_|0,S[3]=S[3]+B|0,S[4]=S[4]+D|0,S[5]=S[5]+j|0,S[6]=S[6]+q|0,S[7]=S[7]+F|0},_doFinalize:function(){var A=this._data,m=A.words,S=8*this._nDataBytes,w=8*A.sigBytes;return m[w>>>5]|=128<<24-w%32,m[(w+64>>>9<<4)+14]=e.floor(S/4294967296),m[(w+64>>>9<<4)+15]=S,A.sigBytes=4*m.length,this._process(),this._hash},clone:function(){var A=n.clone.call(this);return A._hash=this._hash.clone(),A}});t.SHA256=n._createHelper(h),t.HmacSHA256=n._createHmacHelper(h)})(Math);(function(){var e=Ce,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 i=r._doFinalize.call(this);return i.sigBytes-=4,i}});e.SHA224=r._createHelper(n),e.HmacSHA224=r._createHmacHelper(n)})();(function(){function e(){return n.create.apply(n,arguments)}for(var t=Ce,r=t.lib.Hasher,a=t.x64,n=a.Word,i=a.WordArray,a=t.algo,s=[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)],u=[],l=0;80>l;l++)u[l]=e();a=a.SHA512=r.extend({_doReset:function(){this._hash=new i.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(f,d){for(var y=this._hash.words,E=y[0],p=y[1],h=y[2],A=y[3],m=y[4],S=y[5],w=y[6],y=y[7],_=E.high,B=E.low,D=p.high,j=p.low,q=h.high,F=h.low,P=A.high,L=A.low,M=m.high,V=m.low,W=S.high,G=S.low,z=w.high,X=w.low,ie=y.high,Se=y.low,we=_,Ie=B,Ve=D,ue=j,_e=q,He=F,Sr=P,Ht=L,wt=M,ir=V,Gt=W,at=G,kt=z,it=X,bt=ie,sr=Se,et=0;80>et;et++){var jr=u[et];if(16>et)var Jt=jr.high=f[d+2*et]|0,tt=jr.low=f[d+2*et+1]|0;else{var Jt=u[et-15],tt=Jt.high,cr=Jt.low,Jt=(tt>>>1|cr<<31)^(tt>>>8|cr<<24)^tt>>>7,cr=(cr>>>1|tt<<31)^(cr>>>8|tt<<24)^(cr>>>7|tt<<25),Mr=u[et-2],tt=Mr.high,Ct=Mr.low,Mr=(tt>>>19|Ct<<13)^(tt<<3|Ct>>>29)^tt>>>6,Ct=(Ct>>>19|tt<<13)^(Ct<<3|tt>>>29)^(Ct>>>6|tt<<26),tt=u[et-7],Zn=tt.high,br=u[et-16],lr=br.high,br=br.low,tt=cr+tt.low,Jt=Jt+Zn+(tt>>>0>>0?1:0),tt=tt+Ct,Jt=Jt+Mr+(tt>>>0>>0?1:0),tt=tt+br,Jt=Jt+lr+(tt>>>0
>>0?1:0);jr.high=Jt,jr.low=tt}var Zn=wt&Gt^~wt&kt,br=ir&at^~ir&it,jr=we&Ve^we&_e^Ve&_e,Tr=Ie&ue^Ie&He^ue&He,cr=(we>>>28|Ie<<4)^(we<<30|Ie>>>2)^(we<<25|Ie>>>7),Mr=(Ie>>>28|we<<4)^(Ie<<30|we>>>2)^(Ie<<25|we>>>7),Ct=s[et],Sa=Ct.high,tn=Ct.low,Ct=sr+((ir>>>14|wt<<18)^(ir>>>18|wt<<14)^(ir<<23|wt>>>9)),lr=bt+((wt>>>14|ir<<18)^(wt>>>18|ir<<14)^(wt<<23|ir>>>9))+(Ct>>>0>>0?1:0),Ct=Ct+br,lr=lr+Zn+(Ct>>>0
>>0?1:0),Ct=Ct+tn,lr=lr+Sa+(Ct>>>0>>0?1:0),Ct=Ct+tt,lr=lr+Jt+(Ct>>>0>>0?1:0),tt=Mr+Tr,jr=cr+jr+(tt>>>0>>0?1:0),bt=kt,sr=it,kt=Gt,it=at,Gt=wt,at=ir,ir=Ht+Ct|0,wt=Sr+lr+(ir>>>0>>0?1:0)|0,Sr=_e,Ht=He,_e=Ve,He=ue,Ve=we,ue=Ie,Ie=Ct+tt|0,we=lr+jr+(Ie>>>0>>0?1:0)|0}B=E.low=B+Ie,E.high=_+we+(B>>>0>>0?1:0),j=p.low=j+ue,p.high=D+Ve+(j>>>0>>0?1:0),F=h.low=F+He,h.high=q+_e+(F>>>0>>0?1:0),L=A.low=L+Ht,A.high=P+Sr+(L>>>0>>0?1:0),V=m.low=V+ir,m.high=M+wt+(V>>>0>>0?1:0),G=S.low=G+at,S.high=W+Gt+(G>>>0>>0?1:0),X=w.low=X+it,w.high=z+kt+(X>>>0>>0?1:0),Se=y.low=Se+sr,y.high=ie+bt+(Se>>>0>>0?1:0)},_doFinalize:function(){var f=this._data,d=f.words,E=8*this._nDataBytes,p=8*f.sigBytes;return d[p>>>5]|=128<<24-p%32,d[(p+128>>>10<<5)+30]=Math.floor(E/4294967296),d[(p+128>>>10<<5)+31]=E,f.sigBytes=4*d.length,this._process(),this._hash.toX32()},clone:function(){var f=r.clone.call(this);return f._hash=this._hash.clone(),f},blockSize:32}),t.SHA512=r._createHelper(a),t.HmacSHA512=r._createHmacHelper(a)})();(function(){var e=Ce,i=e.x64,t=i.Word,r=i.WordArray,i=e.algo,n=i.SHA512,i=i.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new t.init(3418070365,3238371032),new t.init(1654270250,914150663),new t.init(2438529370,812702999),new t.init(355462360,4144912697),new t.init(1731405415,4290775857),new t.init(2394180231,1750603025),new t.init(3675008525,1694076839),new t.init(1203062813,3204075428)])},_doFinalize:function(){var a=n._doFinalize.call(this);return a.sigBytes-=16,a}});e.SHA384=n._createHelper(i),e.HmacSHA384=n._createHmacHelper(i)})();(function(){var e=Ce,f=e.lib,t=f.WordArray,r=f.Hasher,f=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]),i=t.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=t.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),s=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]),u=t.create([0,1518500249,1859775393,2400959708,2840853838]),l=t.create([1352829926,1548603684,1836072691,2053994217,0]),f=f.RIPEMD160=r.extend({_doReset:function(){this._hash=t.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(d,E){for(var p=0;16>p;p++){var h=E+p,A=d[h];d[h]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360}var h=this._hash.words,A=u.words,m=l.words,S=n.words,w=i.words,y=a.words,_=s.words,B,D,j,q,F,P,L,M,V,W;P=B=h[0],L=D=h[1],M=j=h[2],V=q=h[3],W=F=h[4];for(var G,p=0;80>p;p+=1)G=B+d[E+S[p]]|0,G=16>p?G+((D^j^q)+A[0]):32>p?G+((D&j|~D&q)+A[1]):48>p?G+(((D|~j)^q)+A[2]):64>p?G+((D&q|j&~q)+A[3]):G+((D^(j|~q))+A[4]),G|=0,G=G<>>32-y[p],G=G+F|0,B=F,F=q,q=j<<10|j>>>22,j=D,D=G,G=P+d[E+w[p]]|0,G=16>p?G+((L^(M|~V))+m[0]):32>p?G+((L&V|M&~V)+m[1]):48>p?G+(((L|~M)^V)+m[2]):64>p?G+((L&M|~L&V)+m[3]):G+((L^M^V)+m[4]),G|=0,G=G<<_[p]|G>>>32-_[p],G=G+W|0,P=W,W=V,V=M<<10|M>>>22,M=L,L=G;G=h[1]+j+V|0,h[1]=h[2]+q+W|0,h[2]=h[3]+F+P|0,h[3]=h[4]+B+L|0,h[4]=h[0]+D+M|0,h[0]=G},_doFinalize:function(){var d=this._data,E=d.words,p=8*this._nDataBytes,h=8*d.sigBytes;for(E[h>>>5]|=128<<24-h%32,E[(h+64>>>9<<4)+14]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,d.sigBytes=4*(E.length+1),this._process(),d=this._hash,E=d.words,p=0;5>p;p++)h=E[p],E[p]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;return d},clone:function(){var d=r.clone.call(this);return d._hash=this._hash.clone(),d}});e.RIPEMD160=r._createHelper(f),e.HmacRIPEMD160=r._createHmacHelper(f)})(Math);(function(){var e=Ce,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 i=r.blockSize,a=4*i;n.sigBytes>a&&(n=r.finalize(n)),n.clamp();for(var s=this._oKey=n.clone(),u=this._iKey=n.clone(),l=s.words,f=u.words,d=0;d>6)+Eu.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=Eu.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=Eu.charAt(r>>2)+Eu.charAt((r&3)<<4)),Pd)for(;(n.length&3)>0;)n+=Pd;return n}function Au(e){var t="",r,n=0,i,a;for(r=0;r>2),i=a&3,n=1):n==1?(t+=Fs(i<<2|a>>4),i=a&15,n=2):n==2?(t+=Fs(i),t+=Fs(a>>2),i=a&3,n=3):(t+=Fs(i<<2|a>>4),t+=Fs(a&15),n=0));return n==1&&(t+=Fs(i<<2)),t}function gv(e){var t=Au(e),r,n=new Array;for(r=0;2*r=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=s&67108863}return i}function L5(e,t,r,n,i,a){for(var s=t&32767,u=t>>15;--a>=0;){var l=this[e]&32767,f=this[e++]>>15,d=u*l+f*s;l=s*l+((d&32767)<<15)+r[n]+(i&1073741823),i=(l>>>30)+(d>>>15)+u*f+(i>>>30),r[n++]=l&1073741823}return i}function U5(e,t,r,n,i,a){for(var s=t&16383,u=t>>14;--a>=0;){var l=this[e]&16383,f=this[e++]>>14,d=u*l+f*s;l=s*l+((d&16383)<<14)+r[n]+i,i=(l>>28)+(d>>14)+u*f,r[n++]=l&268435455}return i}hv&&Uc.appName=="Microsoft Internet Explorer"?(ee.prototype.am=L5,pa=30):hv&&Uc.appName!="Netscape"?(ee.prototype.am=k5,pa=26):(ee.prototype.am=U5,pa=28);ee.prototype.DB=pa;ee.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function j5(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 ha(e){var t=gt();return t.fromInt(e),t}function q5(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,i=!1,a=0;--n>=0;){var s=r==8?e[n]&255:mv(e,n);if(s<0){e.charAt(n)=="-"&&(i=!0);continue}i=!1,a==0?this[this.t++]=s:a+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-a):this[this.t-1]|=s<=this.DB&&(a-=this.DB)}r==8&&e[0]&128&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t}function V5(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(u>u)>0&&(i=!0,a=Fs(n));s>=0;)u>(u+=this.DB-t)):(n=this[s]>>(u-=t)&r,u<=0&&(u+=this.DB,--s)),n>0&&(i=!0),i&&(a+=Fs(n));return i?a:"0"}function G5(){var e=gt();return ee.ZERO.subTo(this,e),e}function z5(){return this.s<0?this.negate():this}function Y5(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 kf(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 W5(){return this.t<=0?0:this.DB*(this.t-1)+kf(this[this.t-1]^this.s&this.DM)}function X5(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 J5(e,t){for(var r=e;r=0;--u)t[u+a+1]=this[u]>>n|s,s=(this[u]&i)<=0;--u)t[u]=0;t[a]=s,t.t=this.t+a+1,t.s=this.s,t.clamp()}function Q5(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,i=this.DB-n,a=(1<>n;for(var s=r+1;s>n;n>0&&(t[this.t-r-1]|=(this.s&a)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}function t3(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i=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 n3(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(l,a),i.lShiftTo(l,r)):(n.copyTo(a),i.copyTo(r));var f=a.t,d=a[f-1];if(d!=0){var E=d*(1<1?a[f-2]>>this.F2:0),p=this.FV/E,h=(1<=0&&(r[r.t++]=1,r.subTo(w,r)),ee.ONE.dlShiftTo(f,w),w.subTo(a,a);a.t=0;){var y=r[--m]==d?this.DM:Math.floor(r[m]*p+(r[m-1]+A)*h);if((r[m]+=a.am(0,y,r,S,0,f))0&&r.rShiftTo(l,r),s<0&&ee.ZERO.subTo(r,r)}}}function i3(e){var t=gt();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ee.ZERO)>0&&e.subTo(t,t),t}function io(e){this.m=e}function s3(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function a3(e){return e}function o3(e){e.divRemTo(this.m,null,e)}function u3(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function c3(e,t){e.squareTo(t),this.reduce(t)}io.prototype.convert=s3;io.prototype.revert=a3;io.prototype.reduce=o3;io.prototype.mulTo=u3;io.prototype.sqrTo=c3;function l3(){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 so(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 h3(e){var t=gt();return e.copyTo(t),this.reduce(t),t}function p3(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 d3(e,t){e.squareTo(t),this.reduce(t)}function g3(e,t,r){e.multiplyTo(t,r),this.reduce(r)}so.prototype.convert=f3;so.prototype.revert=h3;so.prototype.reduce=p3;so.prototype.mulTo=g3;so.prototype.sqrTo=d3;function m3(){return(this.t>0?this[0]&1:this.s)==0}function v3(e,t){if(e>4294967295||e<1)return ee.ONE;var r=gt(),n=gt(),i=t.convert(this),a=kf(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)}function E3(e,t){var r;return e<256||t.isEven()?r=new io(t):r=new so(t),this.exp(e,r)}ee.prototype.copyTo=M5;ee.prototype.fromInt=j5;ee.prototype.fromString=q5;ee.prototype.clamp=K5;ee.prototype.dlShiftTo=X5;ee.prototype.drShiftTo=J5;ee.prototype.lShiftTo=Z5;ee.prototype.rShiftTo=Q5;ee.prototype.subTo=e3;ee.prototype.multiplyTo=t3;ee.prototype.squareTo=r3;ee.prototype.divRemTo=n3;ee.prototype.invDigit=l3;ee.prototype.isEven=m3;ee.prototype.exp=v3;ee.prototype.toString=V5;ee.prototype.negate=G5;ee.prototype.abs=z5;ee.prototype.compareTo=Y5;ee.prototype.bitLength=W5;ee.prototype.mod=i3;ee.prototype.modPowInt=E3;ee.ZERO=ha(0);ee.ONE=ha(1);function w3(){var e=gt();return this.copyTo(e),e}function A3(){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 S3(){return this.t==0?this.s:this[0]<<16>>16}function b3(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function C3(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function _3(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=ha(r),i=gt(),a=gt(),s="";for(this.divRemTo(n,i,a);i.signum()>0;)s=(r+a.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,a);return a.intValue().toString(e)+s}function F3(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,a=0,s=0,u=0;u=r&&(this.dMultiply(n),this.dAddOffset(s,0),a=0,s=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),i&&ee.ZERO.subTo(this,this)}function I3(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),Ld,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,i=e&7;n.length=(e>>3)+1,t.nextBytes(n),i>0?n[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(t[i++]=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),i==0&&(this.s&128)!=(n&128)&&++i,(i>0||n!=this.s)&&(t[i++]=n);return t}function D3(e){return this.compareTo(e)==0}function B3(e){return this.compareTo(e)<0?this:e}function R3(e){return this.compareTo(e)>0?this:e}function P3(e,t,r){var n,i,a=Math.min(e.t,this.t);for(n=0;n>=16,t+=16),e&255||(e>>=8,t+=8),e&15||(e>>=4,t+=4),e&3||(e>>=2,t+=2),e&1||++t,t}function j3(){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 J3(e){var t=gt();return this.addTo(e,t),t}function Z3(e){var t=gt();return this.subTo(e,t),t}function Q3(e){var t=gt();return this.multiplyTo(e,t),t}function eF(){var e=gt();return this.squareTo(e),e}function tF(e){var t=gt();return this.divRemTo(e,t,null),t}function rF(e){var t=gt();return this.divRemTo(e,null,t),t}function nF(e){var t=gt(),r=gt();return this.divRemTo(e,t,r),new Array(t,r)}function iF(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function sF(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 Mc(){}function wv(e){return e}function aF(e,t,r){e.multiplyTo(t,r)}function oF(e,t){e.squareTo(t)}Mc.prototype.convert=wv;Mc.prototype.revert=wv;Mc.prototype.mulTo=aF;Mc.prototype.sqrTo=oF;function uF(e){return this.exp(e,new Mc)}function cF(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 i;for(i=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=gt();return e.copyTo(t),this.reduce(t),t}function hF(e){return e}function pF(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 dF(e,t){e.squareTo(t),this.reduce(t)}function gF(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Su.prototype.convert=fF;Su.prototype.revert=hF;Su.prototype.reduce=pF;Su.prototype.mulTo=gF;Su.prototype.sqrTo=dF;function mF(e,t){var r=e.bitLength(),n,i=ha(1),a;if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?a=new io(t):t.isEven()?a=new Su(t):a=new so(t);var s=new Array,u=3,l=n-1,f=(1<1){var d=gt();for(a.sqrTo(s[1],d);u<=f;)s[u]=gt(),a.mulTo(d,s[u-2],s[u]),u+=2}var E=e.t-1,p,h=!0,A=gt(),m;for(r=kf(e[E])-1;E>=0;){for(r>=l?p=e[E]>>r-l&f:(p=(e[E]&(1<0&&(p|=e[E-1]>>this.DB+r-l)),u=n;!(p&1);)p>>=1,--u;if((r-=u)<0&&(r+=this.DB,--E),h)s[p].copyTo(i),h=!1;else{for(;u>1;)a.sqrTo(i,A),a.sqrTo(A,i),u-=2;u>0?a.sqrTo(i,A):(m=i,i=A,A=m),a.mulTo(A,s[p],i)}for(;E>=0&&!(e[E]&1<0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r}function EF(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 wF(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return ee.ZERO;for(var r=e.clone(),n=this.clone(),i=ha(1),a=ha(0),s=ha(0),u=ha(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),t?((!i.isEven()||!a.isEven())&&(i.addTo(this,i),a.subTo(e,a)),i.rShiftTo(1,i)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),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);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),a.subTo(u,a)):(n.subTo(r,n),t&&s.subTo(i,s),u.subTo(a,u))}if(n.compareTo(ee.ONE)!=0)return ee.ZERO;if(u.compareTo(e)>=0)return u.subtract(e);if(u.signum()<0)u.addTo(e,u);else return u;return u.signum()<0?u.add(e):u}var pn=[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],AF=(1<<26)/pn[pn.length-1];function yF(e){var t,r=this.abs();if(r.t==1&&r[0]<=pn[pn.length-1]){for(t=0;t>1,e>pn.length&&(e=pn.length);for(var i=gt(),a=0;a>8&255,qn[Br++]^=e>>16&255,qn[Br++]^=e>>24&255,Br>=Td&&(Br-=Td)}function Hd(){FF(new Date().getTime())}if(qn==null){if(qn=new Array,Br=0,vu!==void 0&&(vu.crypto!==void 0||vu.msCrypto!==void 0)){if(Dd=vu.crypto||vu.msCrypto,Dd.getRandomValues)for(Bd=new Uint8Array(32),Dd.getRandomValues(Bd),ci=0;ci<32;++ci)qn[Br++]=Bd[ci];else if(Uc.appName=="Netscape"&&Uc.appVersion<"5")for(Rd=vu.crypto.random(32),ci=0;ci>>8,qn[Br++]=ci&255;Br=0,Hd()}var ci,Dd,Bd,Rd;function IF(){if(Pf==null){for(Hd(),Pf=_F(),Pf.init(qn),Br=0;Br0&&t.length>0)this.n=Fn(e,16),this.e=parseInt(t,16);else throw"Invalid RSA public key"}function BF(e){return e.modPowInt(this.e,this.n)}We.prototype.doPublic=BF;We.prototype.setPublic=DF;We.prototype.type="RSA";function RF(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=Fn(e,16),this.e=parseInt(t,16),this.d=Fn(r,16);else throw"Invalid RSA private key"}function PF(e,t,r,n,i,a,s,u){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=Fn(e,16),this.e=parseInt(t,16),this.d=Fn(r,16),this.p=Fn(n,16),this.q=Fn(i,16),this.dmp1=Fn(a,16),this.dmq1=Fn(s,16),this.coeff=Fn(u,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function TF(e,t){var r=new bu,n=e>>1;this.e=parseInt(t,16);for(var i=new ee(t,16),a=e/2-100,s=ee.ONE.shiftLeft(a);;){for(;this.p=new ee(e-n,1,r),!(this.p.subtract(ee.ONE).gcd(i).compareTo(ee.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new ee(n,1,r),!(this.q.subtract(ee.ONE).gcd(i).compareTo(ee.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var u=this.p;this.p=this.q,this.q=u}var l=this.q.subtract(this.p).abs();if(!(l.bitLength()0;--f){i=i.twice();var d=r.testBit(f),E=t.testBit(f);d!=E&&(i=i.add(d?this:n))}for(f=s.bitLength()-2;f>0;--f){u=u.twice();var p=s.testBit(f),h=a.testBit(f);p!=h&&(u=u.add(p?u:l))}return i}function JF(e,t,r){var n;e.bitLength()>r.bitLength()?n=e.bitLength()-1:n=r.bitLength()-1;for(var i=this.curve.getInfinity(),a=this.add(t);n>=0;)i=i.twice(),e.testBit(n)?r.testBit(n)?i=i.add(a):i=i.add(this):r.testBit(n)&&(i=i.add(t)),--n;return i}St.prototype.getX=qF;St.prototype.getY=KF;St.prototype.equals=VF;St.prototype.isInfinity=GF;St.prototype.negate=zF;St.prototype.add=YF;St.prototype.twice=WF;St.prototype.multiply=XF;St.prototype.multiplyTwo=JF;function $s(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new St(this,null,null)}function ZF(){return this.q}function QF(){return this.a}function e8(){return this.b}function t8(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function r8(){return this.infinity}function n8(e){return new wr(this.q,e)}function i8(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(f,16)),i=this.getA(),a=this.getB(),s=n.square().add(i).multiply(n).add(a),u=s.sqrt();return t=="03"&&(u=u.negate()),new St(this,n,u);case 4:case 6:case 7:var l=(e.length-2)/2,f=e.substr(2,l),d=e.substr(l+2,l);return new St(this,this.fromBigInteger(new ee(f,16)),this.fromBigInteger(new ee(d,16)));default:return null}}$s.prototype.getQ=ZF;$s.prototype.getA=QF;$s.prototype.getB=e8;$s.prototype.equals=t8;$s.prototype.getInfinity=r8;$s.prototype.fromBigInteger=n8;$s.prototype.decodePointHex=i8;wr.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};St.prototype.getEncoded=function(e){var t=function(a,s){var u=a.toByteArrayUnsigned();if(su.length;)u.unshift(0);return u},r=this.getX().toBigInteger(),n=this.getY().toBigInteger(),i=t(r,32);return e?n.isEven()?i.unshift(2):i.unshift(3):(i.unshift(4),i=i.concat(t(n,32))),i};St.decodeFrom=function(e,t){var r=t[0],n=t.length-1,i=t.slice(1,1+n/2),a=t.slice(1+n/2,1+n);i.unshift(0),a.unshift(0);var s=new ee(i),u=new ee(a);return new St(e,e.fromBigInteger(s),e.fromBigInteger(u))};St.decodeFromHex=function(e,t){var r=t.substr(0,2),n=t.length-2,i=t.substr(2,n/2),a=t.substr(2+n/2,n/2),s=new ee(i,16),u=new ee(a,16);return new St(e,e.fromBigInteger(s),e.fromBigInteger(u))};St.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),i=n.square().subtract(this.x).subtract(e.x),a=n.multiply(this.x.subtract(i)).subtract(this.y);return new St(this.curve,i,a)};St.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)),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new St(this.curve,n,i)};St.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(),i=this,a;for(a=r.bitLength()-2;a>0;--a){i=i.twice();var s=r.testBit(a),u=t.testBit(a);s!=u&&(i=i.add2D(s?this:n))}return i};St.prototype.isOnCurve=function(){var e=this.getX().toBigInteger(),t=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),i=this.curve.getQ(),a=t.multiply(t).mod(i),s=e.multiply(e).multiply(e).add(r.multiply(e)).add(n).mod(i);return a.equals(s)};St.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};St.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 Av=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"),i=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),a={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:` `,r:"\r",t:" "};function s(E,p,h){return p?a[p]:String.fromCharCode(parseInt(h,16))}var u=new String(""),l="\\",f={"{":Object,"[":Array},d=Object.hasOwnProperty;return function(E,p){var h=E.match(n),A,m=h[0],S=!1;m==="{"?A={}:m==="["?A=[]:(A=[],S=!0);for(var w,y=[A],_=1-S,B=h.length;_=0;)delete P[L[W]]}return p.call(q,F,P)};A=j({"":A},"")}return A}}();(typeof g>"u"||!g)&&(g={});(typeof g.asn1>"u"||!g.asn1)&&(g.asn1={});g.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 qc(e)},this.getPEMStringFromHex=function(e,t){return Qr(e,t)},this.newObject=function(e){var t=g,r=t.asn1,n=r.ASN1Object,i=r.DERBoolean,a=r.DERInteger,s=r.DERBitString,u=r.DEROctetString,l=r.DERNull,f=r.DERObjectIdentifier,d=r.DEREnumerated,E=r.DERUTF8String,p=r.DERNumericString,h=r.DERPrintableString,A=r.DERTeletexString,m=r.DERIA5String,S=r.DERUTCTime,w=r.DERGeneralizedTime,y=r.DERVisibleString,_=r.DERBMPString,B=r.DERSequence,D=r.DERSet,j=r.DERTaggedObject,q=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var F=Object.keys(e);if(F.length!=1)throw new Error("key of param shall be only one.");var P=F[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+P+":")==-1)throw new Error("undefined key: "+P);if(P=="bool")return new i(e[P]);if(P=="int")return new a(e[P]);if(P=="bitstr")return new s(e[P]);if(P=="octstr")return new u(e[P]);if(P=="null")return new l(e[P]);if(P=="oid")return new f(e[P]);if(P=="enum")return new d(e[P]);if(P=="utf8str")return new E(e[P]);if(P=="numstr")return new p(e[P]);if(P=="prnstr")return new h(e[P]);if(P=="telstr")return new A(e[P]);if(P=="ia5str")return new m(e[P]);if(P=="utctime")return new S(e[P]);if(P=="gentime")return new w(e[P]);if(P=="visstr")return new y(e[P]);if(P=="bmpstr")return new _(e[P]);if(P=="asn1")return new n(e[P]);if(P=="seq"){for(var L=e[P],M=[],V=0;V"u"||this.hV==null)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+a.length+",v="+this.hV);var s=this.hV.length/2,u=s.toString(16);if(u.length%2==1&&(u="0"+u),s<128)return u;var l=u.length/2;if(l>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+s.toString(16));var f=128+l;return f.toString(16)+u},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(s){this.params=s},e!=null&&e.tlv!=null&&(this.hTLV=e.tlv,this.isModified=!1)};g.asn1.DERAbstractString=function(e){g.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=Uf(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))};he(g.asn1.DERAbstractString,g.asn1.ASN1Object);g.asn1.DERAbstractTime=function(e){g.asn1.DERAbstractTime.superclass.constructor.call(this);var t=null,r=null;this.localDateToUTC=function(n){var i=n.getTime()+n.getTimezoneOffset()*6e4,a=new Date(i);return a},this.formatDate=function(n,i,a){var s=this.zeroPadding,u=this.localDateToUTC(n),l=String(u.getFullYear());i=="utc"&&(l=l.substr(2,2));var f=s(String(u.getMonth()+1),2),d=s(String(u.getDate()),2),E=s(String(u.getHours()),2),p=s(String(u.getMinutes()),2),h=s(String(u.getSeconds()),2),A=l+f+d+E+p+h;if(a===!0){var m=u.getMilliseconds();if(m!=0){var S=s(String(m),3);S=S.replace(/[0]+$/,""),A=A+"."+S}}return A+"Z"},this.zeroPadding=function(n,i){return n.length>=i?n:new Array(i-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,i,a,s,u,l){var f=new Date(Date.UTC(n,i-1,a,s,u,l,0));this.setByDate(f)},this.getFreshValueHex=function(){return this.hV}};he(g.asn1.DERAbstractTime,g.asn1.ASN1Object);g.asn1.DERAbstractStructured=function(e){g.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)};he(g.asn1.DERAbstractStructured,g.asn1.ASN1Object);g.asn1.DERBoolean=function(e){g.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",e==!1?this.hTLV="010100":this.hTLV="0101ff"};he(g.asn1.DERBoolean,g.asn1.ASN1Object);g.asn1.DERInteger=function(e){g.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var t=qc;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)};he(g.asn1.DERInteger,g.asn1.ASN1Object);g.asn1.DERBitString=function(e){if(e!==void 0&&typeof e.obj<"u"){var t=g.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.tohex()}g.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(r){this.hTLV=null,this.isModified=!0,this.hV=r},this.setUnusedBitsAndHexValue=function(r,n){if(r<0||7=a)break}return n};Ae.getNthChildIdx=function(e,t,r){var n=Ae.getChildIdx(e,t);return n[r]};Ae.getIdxbyList=function(e,t,r,n){var i=Ae,a,s;return r.length==0?n!==void 0&&e.substr(t,2)!==n?-1:t:(a=r.shift(),s=i.getChildIdx(e,t),a>=s.length?-1:i.getIdxbyList(e,s[a],r,n))};Ae.getIdxbyListEx=function(e,t,r,n){var i=Ae,a,s;if(r.length==0)return n!==void 0&&e.substr(t,2)!==n?-1:t;a=r.shift(),s=i.getChildIdx(e,t);for(var u=0,l=0;l=e.length?null:i.getTLV(e,a)};Ae.getTLVbyListEx=function(e,t,r,n){var i=Ae,a=i.getIdxbyListEx(e,t,r,n);return a==-1?null:i.getTLV(e,a)};Ae.getVbyList=function(e,t,r,n,i){var a=Ae,s,u;return s=a.getIdxbyList(e,t,r,n),s==-1||s>=e.length?null:(u=a.getV(e,s),i===!0&&(u=u.substr(2)),u)};Ae.getVbyListEx=function(e,t,r,n,i){var a=Ae,s,u,l;return s=a.getIdxbyListEx(e,t,r,n),s==-1?null:(l=a.getV(e,s),e.substr(s,2)=="03"&&i!==!1&&(l=l.substr(2)),l)};Ae.getInt=function(e,t,r){r==null&&(r=-1);try{var n=e.substr(t,2);if(n!="02"&&n!="03")return r;var i=Ae.getV(e,t);return n=="02"?parseInt(i,16):Dv(i)}catch{return r}};Ae.getOID=function(e,t,r){r==null&&(r=null);try{if(e.substr(t,2)!="06")return r;var n=Ae.getV(e,t);return Kf(n)}catch{return r}};Ae.getOIDName=function(e,t,r){r==null&&(r=null);try{var n=Ae.getOID(e,t,r);if(n==r)return r;var i=g.asn1.x509.OID.oid2name(n);return i==""?n:i}catch{return r}};Ae.getString=function(e,t,r){r==null&&(r=null);try{var n=Ae.getV(e,t);return $n(n)}catch{return r}};Ae.hextooidstr=function(e){var t=function(E,p){return E.length>=p?E:new Array(p-E.length+1).join("0")+E},r=[],n=e.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var a=e.substr(2),s=[],u=0;u0&&(d=d+"."+l.join(".")),d};Ae.dump=function(e,t,r,n){var i=Ae,a=i.getV,s=i.dump,u=i.getChildIdx,l=e;e instanceof g.asn1.ASN1Object&&(l=e.tohex());var f=function(q,F){if(q.length<=F*2)return q;var P=q.substr(0,F)+"..(total "+q.length/2+"bytes).."+q.substr(q.length-F,F);return P};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var d=t.ommit_long_octet,D=l.substr(r,2);if(D=="01"){var E=a(l,r);return E=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(D=="02"){var E=a(l,r);return n+"INTEGER "+f(E,d)+` `}if(D=="03"){var E=a(l,r);if(i.isASN1HEX(E.substr(2))){var p=n+`BITSTRING, encapsulates `;return p=p+s(E.substr(2),t,0,n+" "),p}else return n+"BITSTRING "+f(E,d)+` `}if(D=="04"){var E=a(l,r);if(i.isASN1HEX(E)){var p=n+`OCTETSTRING, encapsulates `;return p=p+s(E,t,0,n+" "),p}else return n+"OCTETSTRING "+f(E,d)+` `}if(D=="05")return n+`NULL `;if(D=="06"){var h=a(l,r),A=g.asn1.ASN1Util.oidHexToInt(h),m=g.asn1.x509.OID.oid2name(A),S=A.replace(/\./g," ");return m!=""?n+"ObjectIdentifier "+m+" ("+S+`) `:n+"ObjectIdentifier ("+S+`) `}if(D=="0a")return n+"ENUMERATED "+parseInt(a(l,r))+` `;if(D=="0c")return n+"UTF8String '"+Rt(a(l,r))+`' `;if(D=="13")return n+"PrintableString '"+Rt(a(l,r))+`' `;if(D=="14")return n+"TeletexString '"+Rt(a(l,r))+`' `;if(D=="16")return n+"IA5String '"+Rt(a(l,r))+`' `;if(D=="17")return n+"UTCTime "+Rt(a(l,r))+` `;if(D=="18")return n+"GeneralizedTime "+Rt(a(l,r))+` `;if(D=="1a")return n+"VisualString '"+Rt(a(l,r))+`' `;if(D=="1e")return n+"BMPString '"+Kd(a(l,r))+`' `;if(D=="30"){if(l.substr(r,4)=="3000")return n+`SEQUENCE {} `;var p=n+`SEQUENCE `,w=u(l,r),y=t;if((w.length==2||w.length==3)&&l.substr(w[0],2)=="06"&&l.substr(w[w.length-1],2)=="04"){var m=i.oidname(a(l,w[0])),_=JSON.parse(JSON.stringify(t));_.x509ExtName=m,y=_}for(var B=0;B4?{enum:{hex:w}}:{enum:parseInt(w,16)};if(m=="30"||m=="31")return S[h[m]]=A(e),S;if(m=="14"){var j=p(w);return S[h[m]]={str:j},S}else if(m=="1e"){var j=E(w);return S[h[m]]={str:j},S}else if(":0c:12:13:16:17:18:1a:".indexOf(m)!=-1){var j=d(w);return S[h[m]]={str:j},S}else if(m.match(/^8[0-9]$/)){var j=d(w);return j==null|j==""?{tag:{tag:m,explicit:!1,hex:w}}:j.match(/[\x00-\x1F\x7F-\x9F]/)!=null||j.match(/[\u0000-\u001F\u0080–\u009F]/)!=null?{tag:{tag:m,explicit:!1,hex:w}}:{tag:{tag:m,explicit:!1,str:j}}}else if(m.match(/^a[0-9]$/))try{if(!n(w))throw new Error("not encap");return{tag:{tag:m,explicit:!0,obj:r(w)}}}catch{return{tag:{tag:m,explicit:!0,hex:w}}}else{var q=new g.asn1.ASN1Object;q.hV=w;var F=q.getLengthHexFromValue();return{asn1:{tlv:m+F+w}}}}}};Ae.isContextTag=function(e,t){e=e.toLowerCase();var r,n;try{r=parseInt(e,16)}catch{return-1}if(t===void 0)return(r&192)==128;try{var i=t.match(/^\[[0-9]+\]$/);return i==null||(n=parseInt(t.substr(1,t.length-1),10),n>31)?!1:(r&192)==128&&(r&31)==n}catch{return!1}};Ae.isASN1HEX=function(e){var t=Ae;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),i=t.getL(e,0),a=e.length-n.length-i.length;return a==r*2};Ae.checkStrictDER=function(e,t,r,n,i){var a=Ae;if(r===void 0){if(typeof e!="string")throw new Error("not hex string");if(e=e.toLowerCase(),!g.lang.String.isHex(e))throw new Error("not hex string");r=e.length,n=e.length/2,n<128?i=1:i=Math.ceil(n.toString(16))+1}var s=a.getL(e,t);if(s.length>i*2)throw new Error("L of TLV too long: idx="+t);var u=a.getVblen(e,t);if(u>n)throw new Error("value of L too long than hex: idx="+t);var l=a.getTLV(e,t),f=l.length-2-a.getL(e,t).length;if(f!==u*2)throw new Error("V string length and L's value not the same:"+f+"/"+u*2);if(t===0&&e.length!=l.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+l.length);var d=e.substr(t,2);if(d==="02"){var E=a.getVidx(e,t);if(e.substr(E,2)=="00"&&e.charCodeAt(E+2)<56)throw new Error("not least zeros for DER INTEGER")}if(parseInt(d,16)&32){for(var p=a.getVblen(e,t),h=0,A=a.getChildIdx(e,t),m=0;m"u"||!g)&&(g={});(typeof g.asn1>"u"||!g.asn1)&&(g.asn1={});(typeof g.asn1.x509>"u"||!g.asn1.x509)&&(g.asn1.x509={});g.asn1.x509.Certificate=function(e){g.asn1.x509.Certificate.superclass.constructor.call(this);var t=g,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.x509,s=a.TBSCertificate,u=a.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(l){this.params=l},this.sign=function(){var l=this.params,f=l.sigalg;l.sigalg.name!=null&&(f=l.sigalg.name);var d=l.tbsobj.tohex(),E=new g.crypto.Signature({alg:f});E.init(l.cakey),E.updateHex(d),l.sighex=E.sign()},this.getPEM=function(){return Qr(this.tohex(),"CERTIFICATE")},this.tohex=function(){var l=this.params;if((l.tbsobj==null||l.tbsobj==null)&&(l.tbsobj=new s(l)),l.sighex==null&&l.cakey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or cakey parameter not defined");var f=[];f.push(l.tbsobj),f.push(new u({name:l.sigalg})),f.push(new n({hex:"00"+l.sighex}));var d=new i({array:f});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&(this.params=e)};he(g.asn1.x509.Certificate,g.asn1.ASN1Object);g.asn1.x509.TBSCertificate=function(e){g.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=g,r=t.asn1,n=r.x509,i=r.DERTaggedObject,a=r.DERInteger,s=r.DERSequence,u=n.AlgorithmIdentifier,l=n.Time,f=n.X500Name,d=n.Extensions,E=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(p){this.params=p},this.tohex=function(){var p=[],h=this.params;if(h.version!=null||h.version!=1){var A=2;h.version!=null&&(A=h.version-1);var m=new i({obj:new a({int:A})});p.push(m)}p.push(new a(h.serial)),p.push(new u({name:h.sigalg})),p.push(new f(h.issuer)),p.push(new s({array:[new l(h.notbefore),new l(h.notafter)]})),p.push(new f(h.subject)),p.push(new E(ct.getKey(h.sbjpubkey))),h.ext!==void 0&&h.ext.length>0&&p.push(new i({tag:"a3",obj:new d(h.ext)}));var S=new g.asn1.DERSequence({array:p});return S.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(g.asn1.x509.TBSCertificate,g.asn1.ASN1Object);g.asn1.x509.Extensions=function(e){g.asn1.x509.Extensions.superclass.constructor.call(this);var t=g,r=t.asn1,n=r.DERSequence,i=r.x509;this.aParam=[],this.setByParam=function(a){this.aParam=a},this.tohex=function(){for(var a=[],s=0;s-1&&u.push(new n({int:this.pathLen}));var l=new i({array:u});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))};he(g.asn1.x509.BasicConstraints,g.asn1.x509.Extension);g.asn1.x509.CRLDistributionPoints=function(e){g.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=g,r=t.asn1,n=r.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(i){for(var a=[],s=0;s0&&a.push(new r({array:s}))}var l=new r({array:a});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};he(g.asn1.x509.PolicyInformation,g.asn1.ASN1Object);g.asn1.x509.PolicyQualifierInfo=function(e){g.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=g.asn1,r=t.DERSequence,n=t.DERIA5String,i=t.DERObjectIdentifier,a=t.x509.UserNotice;this.params=null,this.tohex=function(){if(this.params.cps!==void 0){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]});return s.tohex()}if(this.params.unotice!=null){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return s.tohex()}},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};he(g.asn1.x509.PolicyQualifierInfo,g.asn1.ASN1Object);g.asn1.x509.UserNotice=function(e){g.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=g.asn1.DERSequence,r=g.asn1.DERInteger,n=g.asn1.x509.DisplayText,i=g.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var a=[];this.params.noticeref!==void 0&&a.push(new i(this.params.noticeref)),this.params.exptext!==void 0&&a.push(new n(this.params.exptext));var s=new t({array:a});return s.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};he(g.asn1.x509.UserNotice,g.asn1.ASN1Object);g.asn1.x509.NoticeReference=function(e){g.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=g.asn1.DERSequence,r=g.asn1.DERInteger,n=g.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var i=[];if(this.params.org!==void 0&&i.push(new n(this.params.org)),this.params.noticenum!==void 0){for(var a=[],s=this.params.noticenum,u=0;u0)for(var s=0;s0;i++){var a=t.shift();if(r===!0){var s=n.pop(),u=(s+","+a).replace(/\\,/g,",");n.push(u),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}return n=n.map(function(l){return l.replace("/","\\/")}),n.reverse(),"/"+n.join("/")};g.asn1.x509.X500Name.ldapToOneline=function(e){return g.asn1.x509.X500Name.ldapToCompat(e)};g.asn1.x509.RDN=function(e){g.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=g.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 g.asn1.x509.AttributeTypeAndValue({str:r,rule:this.sRule}))},this.addByMultiValuedString=function(r){for(var n=g.asn1.x509.RDN.parseString(r),i=0;i0)for(var r=0;r0;i++){var a=t.shift();if(r===!0){var s=n.pop(),u=(s+"+"+a).replace(/\\\+/g,"+");n.push(u),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}for(var l=!1,f=[],i=0;n.length>0;i++){var a=n.shift();if(l===!0){var d=f.pop();if(a.match(/"$/)){var u=(d+"+"+a).replace(/^([^=]+)="(.*)"$/,"$1=$2");f.push(u),l=!1}else f.push(d+"+"+a)}else f.push(a);a.match(/^[^=]+="/)&&(l=!0)}return f};g.asn1.x509.AttributeTypeAndValue=function(e){g.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=g,r=t.asn1,n=r.DERSequence,i=r.DERUTF8String,a=r.DERPrintableString,s=r.DERTeletexString,u=r.DERIA5String,l=r.DERVisibleString,f=r.DERBMPString,d=t.lang.String.isMail,E=t.lang.String.isPrintable;this.setByParam=function(p){if(p.rule!==void 0&&(this.sRule=p.rule),p.ds!==void 0&&(this.dsType=p.ds),p.value===void 0&&p.str!==void 0){var h=p.str,A=h.match(/^([^=]+)=(.+)$/);if(A)this.sType=A[1],this.sValue=A[2];else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}else this.sType=p.type,this.sValue=p.value},this.setByString=function(p,h){h!==void 0&&(this.sRule=h);var A=p.match(/^([^=]+)=(.+)$/);if(A)this.setByAttrTypeAndValueStr(A[1],A[2]);else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)},this._getDsType=function(){var p=this.sType,h=this.sValue,A=this.sRule;return A==="prn"?p=="CN"&&d(h)?"ia5":E(h)?"prn":"utf8":A==="utf8"?p=="CN"&&d(h)?"ia5":p=="C"?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(p,h,A){A!==void 0&&(this.sRule=A),this.sType=p,this.sValue=h},this.getValueObj=function(p,h){if(p=="utf8")return new i({str:h});if(p=="prn")return new a({str:h});if(p=="tel")return new s({str:h});if(p=="ia5")return new u({str:h});if(p=="vis")return new l({str:h});if(p=="bmp")return new f({str:h});throw new Error("unsupported directory string type: type="+p+" value="+h)},this.tohex=function(){this.dsType==null&&(this.dsType=this._getDsType());var p=g.asn1.x509.OID.atype2obj(this.sType),h=this.getValueObj(this.dsType,this.sValue),A=new n({array:[p,h]});return this.TLV=A.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(g.asn1.x509.AttributeTypeAndValue,g.asn1.ASN1Object);g.asn1.x509.SubjectPublicKeyInfo=function(e){g.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=null,r=null,n=g,i=n.asn1,a=i.DERInteger,s=i.DERBitString,u=i.DERObjectIdentifier,l=i.DERSequence,f=i.ASN1Util.newObject,d=i.x509,E=d.AlgorithmIdentifier,p=n.crypto,h=p.ECDSA,A=p.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null)throw"algId and/or subjPubKey not set";var m=new l({array:[this.asn1AlgId,this.asn1SubjPKey]});return m},this.tohex=function(){var m=this.getASN1Object();return this.hTLV=m.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(m){try{if(m instanceof We){var S=f({seq:[{int:{bigint:m.n}},{int:{int:m.e}}]}),w=S.tohex();this.asn1AlgId=new E({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+w})}}catch{}try{if(m instanceof g.crypto.ECDSA){var y=new u({name:m.curveName});this.asn1AlgId=new E({name:"ecPublicKey",asn1params:y}),this.asn1SubjPKey=new s({hex:"00"+m.pubKeyHex})}}catch{}try{if(m instanceof g.crypto.DSA){var y=new f({seq:[{int:{bigint:m.p}},{int:{bigint:m.q}},{int:{bigint:m.g}}]});this.asn1AlgId=new E({name:"dsa",asn1params:y});var _=new a({bigint:m.y});this.asn1SubjPKey=new s({hex:"00"+_.tohex()})}}catch{}},e!==void 0&&this.setPubKey(e)};he(g.asn1.x509.SubjectPublicKeyInfo,g.asn1.ASN1Object);g.asn1.x509.Time=function(e){g.asn1.x509.Time.superclass.constructor.call(this);var t=null,r=null,n=g,i=n.asn1,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(u){this.timeParams=u},this.setByParam=function(u){this.params=u},this.getType=function(u){return u.match(/^[0-9]{12}Z$/)?"utc":u.match(/^[0-9]{14}Z$/)?"gen":u.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":u.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var u=this.params,l=null;if(typeof u=="string"&&(u={str:u}),u!=null&&u.str&&(u.type==null||u.type==null)&&(u.type=this.getType(u.str)),u!=null&&u.str?(u.type=="utc"&&(l=new a(u.str)),u.type=="gen"&&(l=new s(u.str))):this.type=="gen"?l=new s:l=new a,l==null)throw new Error("wrong setting for Time");return this.TLV=l.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};g.asn1.x509.Time_bak=function(e){g.asn1.x509.Time_bak.superclass.constructor.call(this);var t=null,r=null,n=g,i=n.asn1,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.setTimeParams=function(u){this.timeParams=u},this.tohex=function(){var u=null;return this.timeParams!=null?this.type=="utc"?u=new a(this.timeParams):u=new s(this.timeParams):this.type=="utc"?u=new a:u=new s,this.TLV=u.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)};he(g.asn1.x509.Time,g.asn1.ASN1Object);g.asn1.x509.AlgorithmIdentifier=function(e){g.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=g,r=t.asn1,n=r.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null)throw new Error("algorithm not specified");if(this.nameAlg!==null){var a=null;for(var s in n)s===this.nameAlg&&(a=n[s]);if(a!==null)return this.hTLV=a,this.hTLV}this.nameAlg!==null&&this.asn1Alg===null&&(this.asn1Alg=r.x509.OID.name2obj(this.nameAlg));var u=[this.asn1Alg];this.asn1Params!==null&&u.push(this.asn1Params);var l=new r.DERSequence({array:u});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 i=this.nameAlg.toLowerCase();i.substr(-7,7)!=="withdsa"&&i.substr(-9,9)!=="withecdsa"&&(this.asn1Params=new r.DERNull)}};he(g.asn1.x509.AlgorithmIdentifier,g.asn1.ASN1Object);g.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};g.asn1.x509.GeneralName=function(e){g.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},r=g,n=r.asn1,i=n.x509,a=i.X500Name,s=i.OtherName,u=n.DERIA5String,l=n.DERPrintableString,f=n.DEROctetString,d=n.DERTaggedObject,E=n.ASN1Object,p=Error;this.params=null,this.setByParam=function(h){this.params=h},this.tohex=function(){var h=this.params,A,S,m,S=!1;if(h.other!==void 0)A="a0",m=new s(h.other);else if(h.rfc822!==void 0)A="81",m=new u({str:h.rfc822});else if(h.dns!==void 0)A="82",m=new u({str:h.dns});else if(h.dn!==void 0)A="a4",S=!0,typeof h.dn=="string"?m=new a({str:h.dn}):h.dn instanceof g.asn1.x509.X500Name?m=h.dn:m=new a(h.dn);else if(h.ldapdn!==void 0)A="a4",S=!0,m=new a({ldapstr:h.ldapdn});else if(h.certissuer!==void 0||h.certsubj!==void 0){A="a4",S=!0;var w,y,_=null;if(h.certsubj!==void 0?(w=!1,y=h.certsubj):(w=!0,y=h.certissuer),y.match(/^[0-9A-Fa-f]+$/)&&_==y,y.indexOf("-----BEGIN ")!=-1&&(_=Xt(y)),_==null)throw new Error("certsubj/certissuer not cert");var B=new je;B.hex=_;var D;w?D=B.getIssuerHex():D=B.getSubjectHex(),m=new E,m.hTLV=D}else if(h.uri!==void 0)A="86",m=new u({str:h.uri});else if(h.ip!==void 0){A="87";var j,q=h.ip;try{if(q.match(/^[0-9a-f]+$/)){var F=q.length;if(F==8||F==16||F==32||F==64)j=q;else throw"err"}else j=qd(q)}catch(L){throw new p("malformed IP address: "+h.ip+":"+L.message)}m=new f({hex:j})}else throw new p("improper params");var P=new d({tag:A,explicit:S,obj:m});return P.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(g.asn1.x509.GeneralName,g.asn1.ASN1Object);g.asn1.x509.GeneralNames=function(e){g.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=null,r=g,n=r.asn1;this.setByParamArray=function(i){for(var a=0;a"u")throw"Name of ObjectIdentifier not defined: "+t;var r=this.name2oidList[t],n=new e({oid:r});return this.objCache[t]=n,n},this.atype2obj=function(t){if(this.objCache[t]!==void 0)return this.objCache[t];var r;if(t.match(/^\d+\.\d+\.[0-9.]+$/))r=t;else if(this.atype2oidList[t]!==void 0)r=this.atype2oidList[t];else if(this.name2oidList[t]!==void 0)r=this.name2oidList[t];else throw new Error("AttributeType name undefined: "+t);var n=new e({oid:r});return this.objCache[t]=n,n},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var r in t)this.name2oidList[r]=t[r]},this.checkOIDs=function(t){try{var r=Object.keys(t);return r.length==0?!1:(r.map(function(n,i,a){var s=this[n];if(!s.match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch{return!1}}};g.asn1.x509.OID.oid2name=function(e){var t=g.asn1.x509.OID.name2oidList;for(var r in t)if(t[r]==e)return r;return""};g.asn1.x509.OID.oid2atype=function(e){var t=g.asn1.x509.OID.atype2oidList;for(var r in t)if(t[r]==e)return r;return e};g.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=g.asn1.x509.OID.name2oidList;return t[e]===void 0?"":t[e]};g.asn1.x509.X509Util={};g.asn1.x509.X509Util.newCertPEM=function(e){var t=g.asn1.x509,r=t.TBSCertificate,n=t.Certificate,i=new n(e);return i.getPEM()};(typeof g>"u"||!g)&&(g={});(typeof g.asn1>"u"||!g.asn1)&&(g.asn1={});(typeof g.asn1.cms>"u"||!g.asn1.cms)&&(g.asn1.cms={});g.asn1.cms.Attribute=function(e){var t=Error,r=g,n=r.asn1,i=n.DERSequence,a=n.DERSet,s=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(u){this.params=u},this.getValueArray=function(){throw new t("not yet implemented abstract")},this.tohex=function(){var u=new s({oid:this.typeOid}),l=new a({array:this.getValueArray()}),f=new i({array:[u,l]});return f.tohex()},this.getEncodedHex=function(){return this.tohex()}};he(g.asn1.cms.Attribute,g.asn1.ASN1Object);g.asn1.cms.ContentType=function(e){var t=g,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)};he(g.asn1.cms.ContentType,g.asn1.cms.Attribute);g.asn1.cms.MessageDigest=function(e){var t=g,r=t.asn1,n=r.DEROctetString,i=r.cms;i.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){var a=new n(this.params);return[a]},e!=null&&this.setByParam(e)};he(g.asn1.cms.MessageDigest,g.asn1.cms.Attribute);g.asn1.cms.SigningTime=function(e){var t=g,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)};he(g.asn1.cms.SigningTime,g.asn1.cms.Attribute);g.asn1.cms.SigningCertificate=function(e){var t=Error,r=g,n=r.asn1,i=n.DERSequence,a=n.cms,s=a.ESSCertID,u=r.crypto;a.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(this.params==null||this.params==null||this.params.array==null)throw new t("parameter 'array' not specified");for(var l=this.params.array,f=[],d=0;d0){for(var A=a(p.valhex,h[0]),m=E(A,0),S=[],w=0;w1){var B=a(p.valhex,h[1]);p.polhex=B}delete p.valhex},this.setSignaturePolicyIdentifier=function(p){var h=E(p.valhex,0);if(h.length>0){var A=n.getOID(p.valhex,h[0]);p.oid=A}if(h.length>1){var m=new t,S=E(p.valhex,h[1]),w=a(p.valhex,S[0]),y=m.getAlgorithmIdentifierName(w);p.alg=y;var _=i(p.valhex,S[1]);p.hash=_}delete p.valhex},this.setSigningCertificateV2=function(p){var h=E(p.valhex,0);if(h.length>0){for(var A=a(p.valhex,h[0]),m=E(A,0),S=[],w=0;w1){var B=a(p.valhex,h[1]);p.polhex=B}delete p.valhex},this.getESSCertID=function(p){var h={},A=E(p,0);if(A.length>0){var m=i(p,A[0]);h.hash=m}if(A.length>1){var S=a(p,A[1]),w=this.getIssuerSerial(S);w.serial!=null&&(h.serial=w.serial),w.issuer!=null&&(h.issuer=w.issuer)}return h},this.getESSCertIDv2=function(p){var h={},A=E(p,0);if(A.length<1||3m+1){var y=a(p,A[m+1]),_=this.getIssuerSerial(y);h.issuer=_.issuer,h.serial=_.serial}return h},this.getIssuerSerial=function(p){var h={},A=E(p,0),m=a(p,A[0]),S=r.getGeneralNames(m),w=S[0].dn;h.issuer=w;var y=i(p,A[1]);return h.serial={hex:y},h},this.getCertificateSet=function(p){for(var h=E(p,0),A=[],m=0;m"u"||!g)&&(g={});(typeof g.asn1>"u"||!g.asn1)&&(g.asn1={});(typeof g.asn1.tsp>"u"||!g.asn1.tsp)&&(g.asn1.tsp={});g.asn1.tsp.TimeStampToken=function(e){var t=g,r=t.asn1,n=r.tsp;n.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var i=new n.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=i.tohex()},e!=null&&this.setByParam(e)};he(g.asn1.tsp.TimeStampToken,g.asn1.cms.SignedData);g.asn1.tsp.TSTInfo=function(e){var t=Error,r=g,n=r.asn1,i=n.DERSequence,a=n.DERInteger,s=n.DERBoolean,u=n.DERGeneralizedTime,l=n.DERObjectIdentifier,f=n.DERTaggedObject,d=n.tsp,E=d.MessageImprint,p=d.Accuracy,h=n.x509.X500Name,A=n.x509.GeneralName;if(d.TSTInfo.superclass.constructor.call(this),this.dVersion=new a({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var m=[this.dVersion];if(this.dPolicy==null)throw new Error("policy shall be specified.");if(m.push(this.dPolicy),this.dMessageImprint==null)throw new Error("messageImprint shall be specified.");if(m.push(this.dMessageImprint),this.dSerial==null)throw new Error("serialNumber shall be specified.");if(m.push(this.dSerial),this.dGenTime==null)throw new Error("genTime shall be specified.");m.push(this.dGenTime),this.dAccuracy!=null&&m.push(this.dAccuracy),this.dOrdering!=null&&m.push(this.dOrdering),this.dNonce!=null&&m.push(this.dNonce),this.dTsa!=null&&m.push(this.dTsa);var S=new i({array:m});return this.hTLV=S.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0){if(typeof e.policy=="string"){if(!e.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new l({oid:e.policy})}e.messageImprint!==void 0&&(this.dMessageImprint=new E(e.messageImprint)),e.serial!==void 0&&(this.dSerial=new a(e.serial)),e.genTime!==void 0&&(this.dGenTime=new u(e.genTime)),e.accuracy!==void 0&&(this.dAccuracy=new p(e.accuracy)),e.ordering!==void 0&&e.ordering==!0&&(this.dOrdering=new s),e.nonce!==void 0&&(this.dNonce=new a(e.nonce)),e.tsa!==void 0&&(this.dTsa=new f({tag:"a0",explicit:!0,obj:new A({dn:e.tsa})}))}};he(g.asn1.tsp.TSTInfo,g.asn1.ASN1Object);g.asn1.tsp.Accuracy=function(e){var t=g,r=t.asn1,n=r.ASN1Util.newObject;r.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var i=this.params,a=[];return i.seconds!=null&&typeof i.seconds=="number"&&a.push({int:i.seconds}),i.millis!=null&&typeof i.millis=="number"&&a.push({tag:{tagi:"80",obj:{int:i.millis}}}),i.micros!=null&&typeof i.micros=="number"&&a.push({tag:{tagi:"81",obj:{int:i.micros}}}),n({seq:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(g.asn1.tsp.Accuracy,g.asn1.ASN1Object);g.asn1.tsp.MessageImprint=function(e){var t=g,r=t.asn1,n=r.DERSequence,i=r.DEROctetString,a=r.x509,s=a.AlgorithmIdentifier;r.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var u=this.params,l=new s({name:u.alg}),f=new i({hex:u.hash}),d=new n({array:[l,f]});return d.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(g.asn1.tsp.MessageImprint,g.asn1.ASN1Object);g.asn1.tsp.TimeStampReq=function(e){var t=g,r=t.asn1,n=r.DERSequence,i=r.DERInteger,a=r.DERBoolean,s=r.ASN1Object,u=r.DERObjectIdentifier,l=r.tsp,f=l.MessageImprint;l.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params,E=[];E.push(new i({int:1})),d.messageImprint instanceof g.asn1.ASN1Object?E.push(d.messageImprint):E.push(new f(d.messageImprint)),d.policy!=null&&E.push(new u(d.policy)),d.nonce!=null&&E.push(new i(d.nonce)),d.certreq==!0&&E.push(new a);var p=new n({array:E});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(g.asn1.tsp.TimeStampReq,g.asn1.ASN1Object);g.asn1.tsp.TimeStampResp=function(e){var t=g,r=t.asn1,n=r.DERSequence,i=r.ASN1Object,a=r.tsp,s=a.PKIStatusInfo;a.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var u=this.params,l=[];if(u.econtent!=null||u.tst!=null)if(u.statusinfo!=null?l.push(new s(u.statusinfo)):l.push(new s("granted")),u.econtent!=null)l.push(new a.TimeStampToken(u).getContentInfo());else if(u.tst instanceof r.ASN1Object)l.push(u.tst);else throw new Error("improper member tst value");else if(u.statusinfo!=null)l.push(new s(u.statusinfo));else throw new Error("parameter for token nor statusinfo not specified");var f=new n({array:l});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(g.asn1.tsp.TimeStampResp,g.asn1.ASN1Object);g.asn1.tsp.PKIStatusInfo=function(e){var t=Error,r=g,n=r.asn1,i=n.DERSequence,a=n.tsp,s=a.PKIStatus,u=a.PKIFreeText,l=a.PKIFailureInfo;a.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var f=this.params,d=[];if(typeof f=="string")d.push(new s(f));else{if(f.status==null)throw new t("property 'status' unspecified");d.push(new s(f.status)),f.statusstr!=null&&d.push(new u(f.statusstr)),f.failinfo!=null&&d.push(new l(f.failinfo))}var E=new i({array:d});return E.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(g.asn1.tsp.PKIStatusInfo,g.asn1.ASN1Object);g.asn1.tsp.PKIStatus=function(e){var t=Error,r=g,n=r.asn1,i=n.DERInteger,a=n.tsp;a.PKIStatus.superclass.constructor.call(this);var s={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var u=this.params,l,f;if(typeof u=="string")try{f=s[u]}catch{throw new t("undefined name: "+u)}else if(typeof u=="number")f=u;else throw new t("unsupported params");return new i({int:f}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(g.asn1.tsp.PKIStatus,g.asn1.ASN1Object);g.asn1.tsp.PKIFreeText=function(e){var t=Error,r=g,n=r.asn1,i=n.DERSequence,a=n.DERUTF8String,s=n.tsp;s.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var u=this.params;if(!u instanceof Array)throw new t("wrong params: not array");for(var l=[],f=0;f=0;p--)E+=d[p];return E}else{if(typeof l=="string"&&u[l]!=null)return xf([l],u);if(typeof l=="object"&&l.length!=null)return xf(l,u);throw new t("wrong params")}},this.tohex=function(){var l=this.params,f=this.getBinValue();return new i({bin:f}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(g.asn1.tsp.PKIFailureInfo,g.asn1.ASN1Object);g.asn1.tsp.AbstractTSAAdapter=function(e){this.getTSTHex=function(t,r){throw"not implemented yet"}};g.asn1.tsp.SimpleTSAAdapter=function(e){var t=g,r=t.asn1,n=r.tsp,i=t.crypto.Util.hashHex;n.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(a,s){var u=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:u},this.params.econtent.content.serial={int:this.serial++};var l=Math.floor(Math.random()*1e9);this.params.econtent.content.nonce={int:l};var f=new n.TimeStampToken(this.params);return f.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};he(g.asn1.tsp.SimpleTSAAdapter,g.asn1.tsp.AbstractTSAAdapter);g.asn1.tsp.FixedTSAAdapter=function(e){var t=g,r=t.asn1,n=r.tsp,i=t.crypto.Util.hashHex;n.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(a,s){var u=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:u};var l=new n.TimeStampToken(this.params);return l.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};he(g.asn1.tsp.FixedTSAAdapter,g.asn1.tsp.AbstractTSAAdapter);g.asn1.tsp.TSPUtil=new function(){};g.asn1.tsp.TSPUtil.newTimeStampToken=function(e){return new g.asn1.tsp.TimeStampToken(e)};g.asn1.tsp.TSPUtil.parseTimeStampReq=function(e){var t=new g.asn1.tsp.TSPParser;return t.getTimeStampReq(e)};g.asn1.tsp.TSPUtil.parseMessageImprint=function(e){var t=new g.asn1.tsp.TSPParser;return t.getMessageImprint(e)};g.asn1.tsp.TSPParser=function(){var e=Error,t=je,r=new t,n=Ae,i=n.getV,a=n.getTLV,s=n.getIdxbyList,u=n.getTLVbyListEx,l=n.getChildIdx,f=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],d={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(E){var p=l(E,0);if(p.length==1)return this.getPKIStatusInfo(a(E,p[0]));if(p.length>1){var h=this.getPKIStatusInfo(a(E,p[0])),A=a(E,p[1]),m=this.getToken(A);return m.statusinfo=h,m}},this.getToken=function(E){var p=new g.asn1.cms.CMSParser,h=p.getCMSSignedData(E);return this.setTSTInfo(h),h},this.setTSTInfo=function(E){var p=E.econtent;if(p.type=="tstinfo"){var h=p.content.hex,A=this.getTSTInfo(h);p.content=A}},this.getTSTInfo=function(E){var p={},h=l(E,0),A=i(E,h[1]);p.policy=Kf(A);var m=a(E,h[2]);p.messageImprint=this.getMessageImprint(m);var S=i(E,h[3]);p.serial={hex:S};var w=i(E,h[4]);p.genTime={str:Rt(w)};var y=0;if(h.length>5&&E.substr(h[5],2)=="30"){var _=a(E,h[5]);p.accuracy=this.getAccuracy(_),y++}if(h.length>5+y&&E.substr(h[5+y],2)=="01"){var B=i(E,h[5+y]);B=="ff"&&(p.ordering=!0),y++}if(h.length>5+y&&E.substr(h[5+y],2)=="02"){var D=i(E,h[5+y]);p.nonce={hex:D},y++}if(h.length>5+y&&E.substr(h[5+y],2)=="a0"){var j=a(E,h[5+y]);j="30"+j.substr(2),pGeneralNames=r.getGeneralNames(j);var q=pGeneralNames[0].dn;p.tsa=q,y++}if(h.length>5+y&&E.substr(h[5+y],2)=="a1"){var F=a(E,h[5+y]);F="30"+F.substr(2);var P=r.getExtParamArray(F);p.ext=P,y++}return p},this.getAccuracy=function(E){for(var p={},h=l(E,0),A=0;A1&&E.substr(h[1],2)=="30"){var w=a(E,h[1]);p.statusstr=this.getPKIFreeText(w),A++}if(h.length>A&&E.substr(h[1+A],2)=="03"){var y=a(E,h[1+A]);p.failinfo=this.getPKIFailureInfo(y)}return p},this.getPKIFreeText=function(E){for(var p=[],h=l(E,0),A=0;A"u"||!g)&&(g={});(typeof g.asn1>"u"||!g.asn1)&&(g.asn1={});(typeof g.asn1.cades>"u"||!g.asn1.cades)&&(g.asn1.cades={});g.asn1.cades.SignaturePolicyIdentifier=function(e){var t=g,r=t.asn1,n=r.cades,i=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 i(this.params)]},this.setByParam=function(a){this.params=a},e!=null&&this.setByParam(e)};he(g.asn1.cades.SignaturePolicyIdentifier,g.asn1.cms.Attribute);g.asn1.cades.SignaturePolicyId=function(e){var t=g,r=t.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,a=r.x509,s=a.AlgorithmIdentifier,u=r.cades,l=u.SignaturePolicyId,f=u.OtherHashAlgAndValue;l.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params,E=[];E.push(new i(d.oid)),E.push(new f(d));var p=new n({array:E});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(d){this.params=d},e!=null&&this.setByParam(e)};he(g.asn1.cades.SignaturePolicyId,g.asn1.ASN1Object);g.asn1.cades.OtherHashAlgAndValue=function(e){var t=Error,r=g,n=r.asn1,i=n.DERSequence,a=n.DEROctetString,s=n.x509,u=s.AlgorithmIdentifier,l=n.cades,f=l.OtherHashAlgAndValue;f.superclass.constructor.call(this),this.params=null,this.tohex=function(){var d=this.params;if(d.alg==null)throw new t("property 'alg' not specified");if(d.hash==null&&d.cert==null)throw new t("property 'hash' nor 'cert' not specified");var E=null;if(d.hash!=null)E=d.hash;else if(d.cert!=null){if(typeof d.cert!="string")throw new t("cert not string");var p=d.cert;d.cert.indexOf("-----BEGIN")!=-1&&(p=Xt(d.cert)),E=g.crypto.Util.hashHex(p,d.alg)}var h=[];h.push(new u({name:d.alg})),h.push(new a({hex:E}));var A=new i({array:h});return A.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(g.asn1.cades.OtherHashAlgAndValue,g.asn1.ASN1Object);g.asn1.cades.OtherHashValue=function(e){g.asn1.cades.OtherHashValue.superclass.constructor.call(this);var t=Error,r=g,n=r.lang.String.isHex,i=r.asn1,a=i.DEROctetString,s=r.crypto.Util.hashHex;this.params=null,this.tohex=function(){var u=this.params;if(u.hash==null&&u.cert==null)throw new t("hash or cert not specified");var l=null;if(u.hash!=null)l=u.hash;else if(u.cert!=null){if(typeof u.cert!="string")throw new t("cert not string");var f=u.cert;u.cert.indexOf("-----BEGIN")!=-1&&(f=Xt(u.cert)),l=g.crypto.Util.hashHex(f,"sha1")}return new a({hex:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(g.asn1.cades.OtherHashValue,g.asn1.ASN1Object);g.asn1.cades.SignatureTimeStamp=function(e){var t=Error,r=g,n=r.lang.String.isHex,i=r.asn1,a=i.ASN1Object,s=i.x509,u=i.cades;u.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 f=new a;return f.hTLV=l.tst,[f]}else{if(l.tst instanceof a)return[l.tst];throw new t("params.tst has wrong value")}else if(l.res!=null){var d=l.res;if(d instanceof a&&(d=d.tohex()),typeof d!="string"||!n(d))throw new t("params.res has wrong value");var E=Ae.getTLVbyList(d,0,[1]),f=new a;return f.hTLV=l.tst,[f]}},e!=null&&this.setByParam(e)};he(g.asn1.cades.SignatureTimeStamp,g.asn1.cms.Attribute);g.asn1.cades.CompleteCertificateRefs=function(e){var t=Error,r=g,n=r.asn1,i=n.DERSequence,a=n.cades,s=a.OtherCertID,u=r.lang.String.isHex;a.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var l=this.params,f=[],d=0;d"u"||!g.asn1.csr)&&(g.asn1.csr={});g.asn1.csr.CertificationRequest=function(e){var t=g,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.csr,s=r.x509,u=a.CertificationRequestInfo;a.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(l){this.params=l},this.sign=function(){var l=new u(this.params).tohex(),f=new g.crypto.Signature({alg:this.params.sigalg});f.init(this.params.sbjprvkey),f.updateHex(l);var d=f.sign();this.params.sighex=d},this.getPEM=function(){return Qr(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var l=this.params,f=new g.asn1.csr.CertificationRequestInfo(this.params),d=new g.asn1.x509.AlgorithmIdentifier({name:l.sigalg});if(l.sighex==null&&l.sbjprvkey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or sbjprvkey parameter not defined");var E=new n({hex:"00"+l.sighex}),p=new i({array:[f,d,E]});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(g.asn1.csr.CertificationRequest,g.asn1.ASN1Object);g.asn1.csr.CertificationRequestInfo=function(e){var t=g,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.DERInteger,s=r.DERUTF8String,u=r.DERTaggedObject,l=r.ASN1Util.newObject,f=r.csr,d=r.x509,E=d.X500Name,p=d.Extensions,h=d.SubjectPublicKeyInfo,A=f.AttributeList;f.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(S){S!=null&&(this.params=S)},this.tohex=function(){var S=this.params,w=[];if(w.push(new a({int:0})),w.push(new E(S.subject)),w.push(new h(ct.getKey(S.sbjpubkey))),S.attrs!=null){var y=m(S.attrs),_=l({tag:{tage:"a0",obj:y}});w.push(_)}else if(S.extreq!=null){var B=new p(S.extreq),_=l({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[B]}]}}});w.push(_)}else w.push(new u({tag:"a0",explicit:!1,obj:new s({str:""})}));var D=new i({array:w});return D.tohex()},this.getEncodedHex=function(){return this.tohex()};function m(S){for(var w=Error,y=g.asn1.x509.Extensions,_=[],B=0;B"u"||!g)&&(g={});(typeof g.asn1>"u"||!g.asn1)&&(g.asn1={});(typeof g.asn1.ocsp>"u"||!g.asn1.ocsp)&&(g.asn1.ocsp={});g.asn1.ocsp.DEFAULT_HASH="sha1";g.asn1.ocsp.OCSPResponse=function(e){g.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var t=g.asn1.DEREnumerated,r=g.asn1.ASN1Util.newObject,n=g.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var a=this.params.resstatus;return typeof a=="number"?a:typeof a!="string"?-1:i.indexOf(a)},this.setByParam=function(a){this.params=a},this.tohex=function(){var a=this.params,s=this._getStatusCode();if(s==-1)throw new Error("responseStatus not supported: "+a.resstatus);if(s!=0)return r({seq:[{enum:{int:s}}]}).tohex();var u=new n(a);return r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:u}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(g.asn1.ocsp.OCSPResponse,g.asn1.ASN1Object);g.asn1.ocsp.ResponseBytes=function(e){g.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var t=g.asn1,r=t.DERSequence,n=t.DERObjectIdentifier,i=t.DEROctetString,a=t.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(s){this.params=s},this.tohex=function(){var s=this.params;if(s.restype!="ocspBasic")throw new Error("not supported responseType: "+s.restype);var u=new a(s),l=[];l.push(new n({name:"ocspBasic"})),l.push(new i({hex:u.tohex()}));var f=new r({array:l});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(g.asn1.ocsp.ResponseBytes,g.asn1.ASN1Object);g.asn1.ocsp.BasicOCSPResponse=function(e){g.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var t=Error,r=g.asn1,n=r.ASN1Object,i=r.DERSequence,a=r.DERGeneralizedTime,s=r.DERTaggedObject,u=r.DERBitString,l=r.x509.Extensions,f=r.x509.AlgorithmIdentifier,d=r.ocsp,E=d.ResponderID;_SingleResponseList=d.SingleResponseList,_ResponseData=d.ResponseData,this.params=null,this.setByParam=function(p){this.params=p},this.sign=function(){var p=this.params,h=p.tbsresp.tohex(),A=new g.crypto.Signature({alg:p.sigalg});A.init(p.reskey),A.updateHex(h),p.sighex=A.sign()},this.tohex=function(){var p=this.params;p.tbsresp==null&&(p.tbsresp=new _ResponseData(p)),p.sighex==null&&p.reskey!=null&&this.sign();var h=[];if(h.push(p.tbsresp),h.push(new f({name:p.sigalg})),h.push(new u({hex:"00"+p.sighex})),p.certs!=null&&p.certs.length!=null){for(var A=[],m=0;m"u"||!g)&&(g={});(typeof g.lang>"u"||!g.lang)&&(g.lang={});g.lang.String=function(){};function yv(e){for(var t=new Array,r=0;r>6,l=128|s&63;return Rt(u.toString(16)+l.toString(16))}var u=224|(a&240)>>4,l=128|(a&15)<<2|(s&192)>>6,f=128|s&63;return Rt(u.toString(16)+l.toString(16)+f.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function qf(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function S8(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,i){var a=parseInt(r);if(a<0||255t.length&&(r=t.length);for(var n=0;n0&&(f=f+"."+u.join(".")),f}catch{return null}}function $v(e){var t=new ee(String(e),10);return qc(t)}function qc(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 i="",a=0;a=t?e:new Array(t-e.length+1).join(r)+e};function Dv(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),i=parseInt(n,16).toString(2);i=="0"&&(i="00000000"),i=i.slice(0,0-r);var a=parseInt(i,2);return a==NaN?-1:a}catch{return-1}}function Bv(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+Of("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var i="0"+r;return i+n}function Rv(e){if(typeof e!="string"||e.length%2!=0||!e.match(/^[0-9a-f]+$/))return null;try{var t=parseInt(e.substr(0,2),16);if(t<0||7=0;n--)a+=i[n];return a}function Nt(e,n,r){if(typeof e=="object"){for(var n=String(n).split("."),i=0;i"u"||!g)&&(g={});(typeof g.crypto>"u"||!g.crypto)&&(g.crypto={});g.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:Ce.algo.MD5,sha1:Ce.algo.SHA1,sha224:Ce.algo.SHA224,sha256:Ce.algo.SHA256,sha384:Ce.algo.SHA384,sha512:Ce.algo.SHA512,ripemd160:Ce.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),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+t;for(var a="0001",s="00"+n,u="",l=i-a.length-s.length,f=0;f"u"||!g)&&(g={});(typeof g.crypto>"u"||!g.crypto)&&(g.crypto={});g.crypto.ECDSA=function(e){var t="secp256r1",r=null,n=null,i=null,a=Error,s=ee,u=St,l=g.crypto.ECDSA,f=g.crypto.ECParameterDB,d=l.getName,E=Ae,p=E.getVbyListEx,h=E.isASN1HEX,A=new bu,m=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function S(w,y,_,B){for(var D=Math.max(y.bitLength(),B.bitLength()),j=w.add2D(_),q=w.curve.getInfinity(),F=D-1;F>=0;--F)q=q.twice2D(),q.z=s.ONE,y.testBit(F)?B.testBit(F)?q=q.add2D(j):q=q.add2D(w):B.testBit(F)&&(q=q.add2D(_));return q}this.getBigRandom=function(w){return new s(w.bitLength(),A).mod(w.subtract(s.ONE)).add(s.ONE)},this.setNamedCurve=function(w){this.ecparams=f.getByName(w),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=w},this.setPrivateKeyHex=function(w){this.isPrivate=!0,this.prvKeyHex=w},this.setPublicKeyHex=function(w){this.isPublic=!0,this.pubKeyHex=w},this.getPublicKeyXYHex=function(){var w=this.pubKeyHex;if(w.substr(0,2)!=="04")throw"this method supports uncompressed format(04) only";var y=this.ecparams.keycharlen;if(w.length!==2+y*2)throw"malformed public key hex length";var _={};return _.x=w.substr(2,y),_.y=w.substr(2+y),_},this.getShortNISTPCurveName=function(){var w=this.curveName;return w==="secp256r1"||w==="NIST P-256"||w==="P-256"||w==="prime256v1"?"P-256":w==="secp384r1"||w==="NIST P-384"||w==="P-384"?"P-384":w==="secp521r1"||w==="NIST P-521"||w==="P-521"?"P-521":null},this.generateKeyPairHex=function(){var w=this.ecparams.n,y=this.getBigRandom(w),_=this.ecparams.keycharlen,B=("0000000000"+y.toString(16)).slice(-_);this.setPrivateKeyHex(B);var D=this.generatePublicKeyHex();return{ecprvhex:B,ecpubhex:D}},this.generatePublicKeyHex=function(){var w=new s(this.prvKeyHex,16),y=this.ecparams.G.multiply(w),_=y.getX().toBigInteger(),B=y.getY().toBigInteger(),D=this.ecparams.keycharlen,j=("0000000000"+_.toString(16)).slice(-D),q=("0000000000"+B.toString(16)).slice(-D),F="04"+j+q;return this.setPublicKeyHex(F),F},this.signWithMessageHash=function(w){return this.signHex(w,this.prvKeyHex)},this.signHex=function(w,y){var _=new s(y,16),B=this.ecparams.n,D=new s(w.substring(0,this.ecparams.keycharlen),16);do var j=this.getBigRandom(B),q=this.ecparams.G,F=q.multiply(j),P=F.getX().toBigInteger().mod(B);while(P.compareTo(s.ZERO)<=0);var L=j.modInverse(B).multiply(D.add(_.multiply(P))).mod(B);return l.biRSSigToASN1Sig(P,L)},this.sign=function(w,y){var _=y,B=this.ecparams.n,D=s.fromByteArrayUnsigned(w);do var j=this.getBigRandom(B),q=this.ecparams.G,F=q.multiply(j),P=F.getX().toBigInteger().mod(B);while(P.compareTo(ee.ZERO)<=0);var L=j.modInverse(B).multiply(D.add(_.multiply(P))).mod(B);return this.serializeSig(P,L)},this.verifyWithMessageHash=function(w,y){return this.verifyHex(w,y,this.pubKeyHex)},this.verifyHex=function(w,y,_){try{var B,D,j=l.parseSigHex(y);B=j.r,D=j.s;var q=u.decodeFromHex(this.ecparams.curve,_),F=new s(w.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(F,B,D,q)}catch{return!1}},this.verify=function(w,y,_){var B,D;if(Bitcoin.Util.isArray(y)){var j=this.parseSig(y);B=j.r,D=j.s}else if(typeof y=="object"&&y.r&&y.s)B=y.r,D=y.s;else throw"Invalid value for signature";var q;if(_ instanceof St)q=_;else if(Bitcoin.Util.isArray(_))q=u.decodeFrom(this.ecparams.curve,_);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var F=s.fromByteArrayUnsigned(w);return this.verifyRaw(F,B,D,q)},this.verifyRaw=function(w,y,_,B){var D=this.ecparams.n,j=this.ecparams.G;if(y.compareTo(s.ONE)<0||y.compareTo(D)>=0||_.compareTo(s.ONE)<0||_.compareTo(D)>=0)return!1;var q=_.modInverse(D),F=w.multiply(q).mod(D),P=y.multiply(q).mod(D),L=j.multiply(F).add(B.multiply(P)),M=L.getX().toBigInteger().mod(D);return M.equals(y)},this.serializeSig=function(w,y){var _=w.toByteArraySigned(),B=y.toByteArraySigned(),D=[];return D.push(2),D.push(_.length),D=D.concat(_),D.push(2),D.push(B.length),D=D.concat(B),D.unshift(D.length),D.unshift(48),D},this.parseSig=function(w){var y;if(w[0]!=48)throw new Error("Signature not a valid DERSequence");if(y=2,w[y]!=2)throw new Error("First element in signature must be a DERInteger");var _=w.slice(y+2,y+2+w[y+1]);if(y+=2+w[y+1],w[y]!=2)throw new Error("Second element in signature must be a DERInteger");var B=w.slice(y+2,y+2+w[y+1]);y+=2+w[y+1];var D=s.fromByteArrayUnsigned(_),j=s.fromByteArrayUnsigned(B);return{r:D,s:j}},this.parseSigCompact=function(w){if(w.length!==65)throw"Signature has the wrong length";var y=w[0]-27;if(y<0||y>7)throw"Invalid signature type";var _=this.ecparams.n,B=s.fromByteArrayUnsigned(w.slice(1,33)).mod(_),D=s.fromByteArrayUnsigned(w.slice(33,65)).mod(_);return{r:B,s:D,i:y}},this.readPKCS5PrvKeyHex=function(w){if(h(w)===!1)throw new Error("not ASN.1 hex string");var y,_,B;try{y=p(w,0,["[0]",0],"06"),_=p(w,0,[1],"04");try{B=p(w,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=d(y),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(B),this.setPrivateKeyHex(_),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(w){if(h(w)===!1)throw new a("not ASN.1 hex string");var y,_,B,D;try{y=p(w,0,[1,0],"06"),_=p(w,0,[1,1],"06"),B=p(w,0,[2,0,1],"04");try{D=p(w,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new a("malformed PKCS#8 plain ECC private key")}if(this.curveName=d(_),this.curveName===void 0)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(D),this.setPrivateKeyHex(B),this.isPublic=!1},this.readPKCS8PubKeyHex=function(w){if(h(w)===!1)throw new a("not ASN.1 hex string");var y,_,B;try{y=p(w,0,[0,0],"06"),_=p(w,0,[0,1],"06"),B=p(w,0,[1],"03")}catch{throw new a("malformed PKCS#8 ECC public key")}if(this.curveName=d(_),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(B)},this.readCertPubKeyHex=function(w,y){if(h(w)===!1)throw new a("not ASN.1 hex string");var _,B;try{_=p(w,0,[0,5,0,1],"06"),B=p(w,0,[0,5,1],"03")}catch{throw new a("malformed X.509 certificate ECC public key")}if(this.curveName=d(_),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(B)},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))};g.crypto.ECDSA.parseSigHex=function(e){var t=g.crypto.ECDSA.parseSigHexInHexRS(e),r=new ee(t.r,16),n=new ee(t.s,16);return{r,s:n}};g.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=Ae,r=t.getChildIdx,n=t.getV;if(t.checkStrictDER(e,0),e.substr(0,2)!="30")throw new Error("signature is not a ASN.1 sequence");var i=r(e,0);if(i.length!=2)throw new Error("signature shall have two elements");var a=i[0],s=i[1];if(e.substr(a,2)!="02")throw new Error("1st item not ASN.1 integer");if(e.substr(s,2)!="02")throw new Error("2nd item not ASN.1 integer");var u=n(e,a),l=n(e,s);return{r:u,s:l}};g.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=g.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 i=Math.max(r.length,n.length);return r=("000000"+r).slice(-i),n=("000000"+n).slice(-i),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};g.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 g.crypto.ECDSA.hexRSSigToASN1Sig(t,r)};g.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new ee(e,16),n=new ee(t,16);return g.crypto.ECDSA.biRSSigToASN1Sig(r,n)};g.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=g.asn1,n=new r.DERInteger({bigint:e}),i=new r.DERInteger({bigint:t}),a=new r.DERSequence({array:[n,i]});return a.tohex()};g.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 g>"u"||!g)&&(g={});(typeof g.crypto>"u"||!g.crypto)&&(g.crypto={});g.crypto.ECParameterDB=new function(){var e={},t={};function r(n){return new ee(n,16)}this.getByName=function(n){var i=n;if(typeof t[i]<"u"&&(i=t[n]),typeof e[i]<"u")return e[i];throw"unregistered EC curve name: "+i},this.regist=function(n,i,a,s,u,l,f,d,E,p,h,A){e[n]={};var m=r(a),S=r(s),w=r(u),y=r(l),_=r(f),B=new $s(m,S,w),D=B.decodePointHex("04"+d+E);e[n].name=n,e[n].keylen=i,e[n].keycharlen=Math.ceil(i/8)*2,e[n].curve=B,e[n].G=D,e[n].n=y,e[n].h=_,e[n].oid=h,e[n].info=A;for(var j=0;j"u"||!g)&&(g={});(typeof g.crypto>"u"||!g.crypto)&&(g.crypto={});g.crypto.DSA=function(){var e=Ae,t=e.getVbyList,r=e.getVbyListEx,n=e.isASN1HEX,i=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(a,s,u,l,f){this.isPrivate=!0,this.p=a,this.q=s,this.g=u,this.y=l,this.x=f},this.setPrivateHex=function(a,s,u,l,f){var d,E,p,h,A;d=new ee(a,16),E=new ee(s,16),p=new ee(u,16),typeof l=="string"&&l.length>1?h=new ee(l,16):h=null,A=new ee(f,16),this.setPrivate(d,E,p,h,A)},this.setPublic=function(a,s,u,l){this.isPublic=!0,this.p=a,this.q=s,this.g=u,this.y=l,this.x=null},this.setPublicHex=function(a,s,u,l){var f,d,E,p;f=new ee(a,16),d=new ee(s,16),E=new ee(u,16),p=new ee(l,16),this.setPublic(f,d,E,p)},this.signWithMessageHash=function(a){var s=this.p,u=this.q,l=this.g,f=this.y,d=this.x,E=g.crypto.Util.getRandomBigIntegerMinToMax(ee.ONE.add(ee.ONE),u.subtract(ee.ONE)),p=a.substr(0,u.bitLength()/4),h=new ee(p,16),A=l.modPow(E,s).mod(u),m=E.modInverse(u).multiply(h.add(d.multiply(A))).mod(u),S=g.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:A}},{int:{bigint:m}}]});return S},this.verifyWithMessageHash=function(a,s){var u=this.p,l=this.q,f=this.g,d=this.y,E=this.parseASN1Signature(s),p=E[0],h=E[1],A=a.substr(0,l.bitLength()/4),m=new ee(A,16);if(ee.ZERO.compareTo(p)>0||p.compareTo(l)>0||ee.ZERO.compareTo(h)>=0||h.compareTo(l)>0)throw"invalid DSA signature";var S=h.modInverse(l),w=m.multiply(S).mod(l),y=p.multiply(S).mod(l),_=f.modPow(w,u).multiply(d.modPow(y,u)).mod(u).mod(l);return _.compareTo(p)==0},this.parseASN1Signature=function(a){try{var s=new i(r(a,0,[0],"02"),16),u=new i(r(a,0,[1],"02"),16);return[s,u]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(a){var s,u,l,f,d;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1],"02"),u=r(a,0,[2],"02"),l=r(a,0,[3],"02"),f=r(a,0,[4],"02"),d=r(a,0,[5],"02")}catch{throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(s,u,l,f,d)},this.readPKCS8PrvKeyHex=function(a){var s,u,l,f;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1,1,0],"02"),u=r(a,0,[1,1,1],"02"),l=r(a,0,[1,1,2],"02"),f=r(a,0,[2,0],"02")}catch{throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(s,u,l,null,f)},this.readPKCS8PubKeyHex=function(a){var s,u,l,f;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[0,1,0],"02"),u=r(a,0,[0,1,1],"02"),l=r(a,0,[0,1,2],"02"),f=r(a,0,[1,0],"02")}catch{throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(s,u,l,f)},this.readCertPubKeyHex=function(a,s){var u,l,f,d;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[0,5,0,1,0],"02"),l=r(a,0,[0,5,0,1,1],"02"),f=r(a,0,[0,5,0,1,2],"02"),d=r(a,0,[0,5,1,0],"02")}catch{throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(u,l,f,d)}};var ct=function(){var e=function(m,S,w){return n(Ce.AES,m,S,w)},t=function(m,S,w){return n(Ce.TripleDES,m,S,w)},r=function(m,S,w){return n(Ce.DES,m,S,w)},n=function(m,S,w,y){var _=Ce.enc.Hex.parse(S),B=Ce.enc.Hex.parse(w),D=Ce.enc.Hex.parse(y),j={};j.key=B,j.iv=D,j.ciphertext=_;var q=m.decrypt(j,B,{iv:D});return Ce.enc.Hex.stringify(q)},i=function(m,S,w){return u(Ce.AES,m,S,w)},a=function(m,S,w){return u(Ce.TripleDES,m,S,w)},s=function(m,S,w){return u(Ce.DES,m,S,w)},u=function(m,S,w,y){var _=Ce.enc.Hex.parse(S),B=Ce.enc.Hex.parse(w),D=Ce.enc.Hex.parse(y),j=m.encrypt(_,B,{iv:D}),q=Ce.enc.Hex.parse(j.toString()),F=Ce.enc.Base64.stringify(q);return F},l={"AES-256-CBC":{proc:e,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:e,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:e,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:t,eproc:a,keylen:24,ivlen:8},"DES-CBC":{proc:r,eproc:s,keylen:8,ivlen:8}},f=function(m){return l[m].proc},d=function(m){var S=Ce.lib.WordArray.random(m),w=Ce.enc.Hex.stringify(S);return w},E=function(m){var S={},w=m.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));w&&(S.cipher=w[1],S.ivsalt=w[2]);var y=m.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));y&&(S.type=y[1]);var _=-1,B=0;m.indexOf(`\r \r `)!=-1&&(_=m.indexOf(`\r \r `),B=2),m.indexOf(` `)!=-1&&(_=m.indexOf(` `),B=1);var D=m.indexOf("-----END");if(_!=-1&&D!=-1){var j=m.substring(_+B*2,D-B);j=j.replace(/\s+/g,""),S.data=j}return S},p=function(m,S,w){for(var y=w.substring(0,16),_=Ce.enc.Hex.parse(y),B=Ce.enc.Utf8.parse(S),D=l[m].keylen+l[m].ivlen,j="",q=null;;){var F=Ce.algo.MD5.create();if(q!=null&&F.update(q),F.update(B),F.update(_),q=F.finalize(),j=j+Ce.enc.Hex.stringify(q),j.length>=D*2)break}var P={};return P.keyhex=j.substr(0,l[m].keylen*2),P.ivhex=j.substr(l[m].keylen*2,l[m].ivlen*2),P},h=function(m,S,w,y){var _=Ce.enc.Base64.parse(m),B=Ce.enc.Hex.stringify(_),D=l[S].proc,j=D(B,w,y);return j},A=function(m,S,w,y){var _=l[S].eproc,B=_(m,w,y);return B};return{version:"1.0.0",parsePKCS5PEM:function(m){return E(m)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(m,S,w){return p(m,S,w)},decryptKeyB64:function(m,S,w,y){return h(m,S,w,y)},getDecryptedKeyHex:function(m,S){var w=E(m),y=w.type,_=w.cipher,B=w.ivsalt,D=w.data,j=p(_,S,B),q=j.keyhex,F=h(D,_,q,B);return F},getEncryptedPKCS5PEMFromPrvKeyHex:function(m,S,w,y,_){var L="";if((typeof y>"u"||y==null)&&(y="AES-256-CBC"),typeof l[y]>"u")throw new Error("KEYUTIL unsupported algorithm: "+y);if(typeof _>"u"||_==null){var B=l[y].ivlen,D=d(B);_=D.toUpperCase()}var j=p(y,w,_),q=j.keyhex,F=A(S,y,q,_),P=F.replace(/(.{64})/g,`$1\r `),L="-----BEGIN "+m+` PRIVATE KEY-----\r `;return L+=`Proc-Type: 4,ENCRYPTED\r `,L+="DEK-Info: "+y+","+_+`\r `,L+=`\r `,L+=P,L+=`\r -----END `+m+` PRIVATE KEY-----\r `,L},getEncryptedPKCS8PEM:function(m,S,w){var y=this.getEncryptedPKCS8Hex(m,S,w);return Qr(y,"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(m,S,w){var y;w==null||w==null?y={}:y=JSON.parse(JSON.stringify(w)),y.plain=m,this.initPBES2Param(y),this.encryptPBES2Param(y,S);var _=this.generatePBES2ASN1Param(y);return g.asn1.ASN1Util.newObject(_).tohex()},initPBES2Param:function(m){if(Nt(m,"encalg")==null&&(m.encalg="aes256-CBC"),Nt(m,"iter")==null&&(m.iter=2048),Nt(m,"prf")==null&&(m.prf="hmacWithSHA256"),Nt(m,"salt")==null&&(m.salt=Ce.enc.Hex.stringify(Ce.lib.WordArray.random(8))),Nt(m,"enciv")==null){var S;m.encalg=="des-EDE3-CBC"&&(S=8),m.encalg=="aes128-CBC"&&(S=16),m.encalg=="aes256-CBC"&&(S=16),m.enciv=Ce.enc.Hex.stringify(Ce.lib.WordArray.random(S))}},encryptPBES2Param:function(m,S){var w=ct.getDKFromPBES2Param(m,S);try{var y=g.crypto.Cipher.encrypt(m.plain,w,m.encalg,{iv:m.enciv})}catch{throw new Error("encrypt error: "+m.plain+" "+w+" "+m.encalg+" "+m.enciv)}m.enc=y},generatePBES2ASN1Param:function(m){var S={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:m.salt}},{int:{hex:$v(m.iter)}}]}]},{seq:[{oid:m.encalg},{octstr:{hex:m.enciv}}]}]}]},{octstr:{hex:m.enc}}]};return m.prf!="hmacWithSHA1"&&S.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:m.prf},{null:""}]}),S},parseHexOfEncryptedPKCS8:function(m){var S=Ae,w=S.getChildIdx,y=S.getV,_={},B=w(m,0);if(B.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+B.length);_.ciphertext=y(m,B[1]);var D=w(m,B[0]);if(D.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+D.length);if(y(m,D[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var j=w(m,D[1]);if(D.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+j.length);var q=w(m,j[1]);if(q.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+q.length);if(y(m,q[0])!="2a864886f70d0307")throw"this only supports TripleDES";_.encryptionSchemeAlg="TripleDES",_.encryptionSchemeIV=y(m,q[1]);var F=w(m,j[0]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+F.length);if(y(m,F[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var P=w(m,F[1]);if(P.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+P.length);_.pbkdf2Salt=y(m,P[0]);var L=y(m,P[1]);try{_.pbkdf2Iter=parseInt(L,16)}catch{throw new Error("malformed format pbkdf2Iter: "+L)}return _},getPBKDF2KeyHexFromParam:function(m,S){var w=Ce.enc.Hex.parse(m.pbkdf2Salt),y=m.pbkdf2Iter,_=Ce.PBKDF2(S,w,{keySize:192/32,iterations:y}),B=Ce.enc.Hex.stringify(_);return B},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(m,S){var w=Xt(m,"ENCRYPTED PRIVATE KEY"),y=this.parseHexOfEncryptedPKCS8(w),_=ct.getPBKDF2KeyHexFromParam(y,S),B={};B.ciphertext=Ce.enc.Hex.parse(y.ciphertext);var D=Ce.enc.Hex.parse(_),j=Ce.enc.Hex.parse(y.encryptionSchemeIV),q=Ce.TripleDES.decrypt(B,D,{iv:j}),F=Ce.enc.Hex.stringify(q);return F},parsePBES2:function(m){var S=Ae.parse(m);if(Nt(S,"seq.0.seq.0.oid")!="pkcs5PBES2"||Nt(S,"seq.0.seq.1.seq.0.seq.0.oid")!="pkcs5PBKDF2")throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var w=Nt(S,"seq.0.seq.1.seq.0.seq.1.seq");if(w==null)throw new Error("PBKDF2 parameter not found");var y=Nt(w,"0.octstr.hex"),_=Nt(w,"1.int.hex"),B=Nt(w,"2.seq.0.oid","hmacWithSHA1"),D=-1;try{D=parseInt(_,16)}catch{throw new Error("iter not proper value")}var j=Nt(S,"seq.0.seq.1.seq.1.seq.0.oid"),q=Nt(S,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),F=Nt(S,"seq.1.octstr.hex");if(j==null||q==null||F==null)throw new Error("encalg, enciv or enc is undefined");var P={salt:y,iter:D,prf:B,encalg:j,enciv:q,enc:F};return P},getDKFromPBES2Param:function(m,S){var w={hmacWithSHA1:Ce.algo.SHA1,hmacWithSHA224:Ce.algo.SHA224,hmacWithSHA256:Ce.algo.SHA256,hmacWithSHA384:Ce.algo.SHA384,hmacWithSHA512:Ce.algo.SHA512},y={"des-EDE3-CBC":192/32,"aes128-CBC":128/32,"aes256-CBC":256/32},_=w[m.prf];if(_==null)throw new Error("unsupported prf");var B=y[m.encalg];if(B==null)throw new Error("unsupported encalg");var D=Ce.enc.Hex.parse(m.salt),j=m.iter;try{var q=Ce.PBKDF2(S,D,{keySize:B,iterations:j,hasher:_});return Ce.enc.Hex.stringify(q)}catch(F){throw new Error("PBKDF2 error: "+F+" "+JSON.stringify(m)+" "+S)}},getPlainHexFromEncryptedPKCS8PEM:function(m,S){if(m.indexOf("BEGIN ENCRYPTED PRIVATE KEY")==-1)throw new Error("not Encrypted PKCS#8 PEM string");var w=Xt(m),y;try{y=ct.parsePBES2(w)}catch(B){throw new Error("malformed PBES2 format: "+B.message)}var _=ct.getDKFromPBES2Param(y,S);return g.crypto.Cipher.decrypt(y.enc,_,y.encalg,{iv:y.enciv})},getKeyFromEncryptedPKCS8PEM:function(m,S){var w=this.getPlainHexFromEncryptedPKCS8PEM(m,S),y=this.getKeyFromPlainPrivatePKCS8Hex(w);return y},parsePlainPrivatePKCS8Hex:function(m){var S=Ae,w=S.getChildIdx,y=S.getV,_={};if(_.algparam=null,m.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var B=w(m,0);if(B.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(m.substr(B[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var D=w(m,B[1]);if(D.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(m.substr(D[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(_.algoid=y(m,D[0]),m.substr(D[1],2)=="06"&&(_.algparam=y(m,D[1])),m.substr(B[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return _.keyidx=S.getVidx(m,B[2]),_},getKeyFromPlainPrivatePKCS8PEM:function(m){var S=Xt(m,"PRIVATE KEY"),w=this.getKeyFromPlainPrivatePKCS8Hex(S);return w},getKeyFromPlainPrivatePKCS8Hex:function(m){var S=this.parsePlainPrivatePKCS8Hex(m),w;if(S.algoid=="2a864886f70d010101")w=new We;else if(S.algoid=="2a8648ce380401")w=new g.crypto.DSA;else if(S.algoid=="2a8648ce3d0201")w=new g.crypto.ECDSA;else throw new Error("unsupported private key algorithm");return w.readPKCS8PrvKeyHex(m),w},_getKeyFromPublicPKCS8Hex:function(m){var S,w=Ae.getVbyList(m,0,[0,0],"06");if(w==="2a864886f70d010101")S=new We;else if(w==="2a8648ce380401")S=new g.crypto.DSA;else if(w==="2a8648ce3d0201")S=new g.crypto.ECDSA;else throw new Error("unsupported PKCS#8 public key hex");return S.readPKCS8PubKeyHex(m),S},parsePublicRawRSAKeyHex:function(m){var S=Ae,w=S.getChildIdx,y=S.getV,_={};if(m.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var B=w(m,0);if(B.length!=2)throw new Error("malformed RSA key(code:002)");if(m.substr(B[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(_.n=y(m,B[0]),m.substr(B[1],2)!="02")throw new Error("malformed RSA key(code:004)");return _.e=y(m,B[1]),_},parsePublicPKCS8Hex:function(m){var S=Ae,w=S.getChildIdx,y=S.getV,_={};_.algparam=null;var B=w(m,0);if(B.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+B.length);var D=B[0];if(m.substr(D,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var j=w(m,D);if(j.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(m.substr(j[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(_.algoid=y(m,j[0]),m.substr(j[1],2)=="06"?_.algparam=y(m,j[1]):m.substr(j[1],2)=="30"&&(_.algparam={},_.algparam.p=S.getVbyList(m,j[1],[0],"02"),_.algparam.q=S.getVbyList(m,j[1],[1],"02"),_.algparam.g=S.getVbyList(m,j[1],[2],"02")),m.substr(B[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return _.key=y(m,B[1]).substr(2),_}}}();ct.getKey=function(e,t,r){var n=Ae,i=n.getChildIdx,a=n.getV,s=n.getVbyList,u=g.crypto,l=u.ECDSA,f=u.DSA,d=We,E=Xt,p=ct;if(typeof d<"u"&&e instanceof d||typeof l<"u"&&e instanceof l||typeof f<"u"&&e instanceof f)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 h=new d;return h.setPublic(e.n,e.e),h}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 h=new d;return h.setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),h}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p===void 0){var h=new d;return h.setPrivate(e.n,e.e,e.d),h}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x===void 0){var h=new f;return h.setPublic(e.p,e.q,e.g,e.y),h}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x!==void 0){var h=new f;return h.setPrivate(e.p,e.q,e.g,e.y,e.x),h}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var h=new d;return h.setPublic(qt(e.n),qt(e.e)),h}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 h=new d;return h.setPrivateEx(qt(e.n),qt(e.e),qt(e.d),qt(e.p),qt(e.q),qt(e.dp),qt(e.dq),qt(e.qi)),h}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var h=new d;return h.setPrivate(qt(e.n),qt(e.e),qt(e.d)),h}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d===void 0){var A=new l({curve:e.crv}),m=A.ecparams.keycharlen,S=("0000000000"+qt(e.x)).slice(-m),w=("0000000000"+qt(e.y)).slice(-m),y="04"+S+w;return A.setPublicKeyHex(y),A}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d!==void 0){var A=new l({curve:e.crv}),m=A.ecparams.keycharlen,S=("0000000000"+qt(e.x)).slice(-m),w=("0000000000"+qt(e.y)).slice(-m),y="04"+S+w,_=("0000000000"+qt(e.d)).slice(-m);return A.setPublicKeyHex(y),A.setPrivateKeyHex(_),A}if(r==="pkcs5prv"){var B=e,n=Ae,D,h;if(D=i(B,0),D.length===9)h=new d,h.readPKCS5PrvKeyHex(B);else if(D.length===6)h=new f,h.readPKCS5PrvKeyHex(B);else if(D.length>2&&B.substr(D[1],2)==="04")h=new l,h.readPKCS5PrvKeyHex(B);else throw new Error("unsupported PKCS#1/5 hexadecimal key");return h}if(r==="pkcs8prv"){var h=p.getKeyFromPlainPrivatePKCS8Hex(e);return h}if(r==="pkcs8pub")return p._getKeyFromPublicPKCS8Hex(e);if(r==="x509pub")return je.getPublicKeyFromCertHex(e);if(e.indexOf("-END CERTIFICATE-",0)!=-1||e.indexOf("-END X509 CERTIFICATE-",0)!=-1||e.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return je.getPublicKeyFromCertPEM(e);if(e.indexOf("-END PUBLIC KEY-")!=-1){var j=Xt(e,"PUBLIC KEY");return p._getKeyFromPublicPKCS8Hex(j)}if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var q=E(e,"RSA PRIVATE KEY");return p.getKey(q,null,"pkcs5prv")}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var F=E(e,"DSA PRIVATE KEY"),P=s(F,0,[1],"02"),L=s(F,0,[2],"02"),M=s(F,0,[3],"02"),V=s(F,0,[4],"02"),W=s(F,0,[5],"02"),h=new f;return h.setPrivate(new ee(P,16),new ee(L,16),new ee(M,16),new ee(V,16),new ee(W,16)),h}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var q=E(e,"EC PRIVATE KEY");return p.getKey(q,null,"pkcs5prv")}if(e.indexOf("-END PRIVATE KEY-")!=-1)return p.getKeyFromPlainPrivatePKCS8PEM(e);if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var G=p.getDecryptedKeyHex(e,t),z=new We;return z.readPKCS5PrvKeyHex(G),z}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var F=p.getDecryptedKeyHex(e,t),h=s(F,0,[1],"04"),X=s(F,0,[2,0],"06"),ie=s(F,0,[3,0],"03").substr(2),Se="";if(g.crypto.OID.oidhex2name[X]!==void 0)Se=g.crypto.OID.oidhex2name[X];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+X);var A=new l({curve:Se});return A.setPublicKeyHex(ie),A.setPrivateKeyHex(h),A.isPublic=!1,A}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var F=p.getDecryptedKeyHex(e,t),P=s(F,0,[1],"02"),L=s(F,0,[2],"02"),M=s(F,0,[3],"02"),V=s(F,0,[4],"02"),W=s(F,0,[5],"02"),h=new f;return h.setPrivate(new ee(P,16),new ee(L,16),new ee(M,16),new ee(V,16),new ee(W,16)),h}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return p.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};ct.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new We;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var i=new We,a=n.n.toString(16),s=n.e.toString(16);i.setPublic(a,s),i.isPrivate=!1,i.isPublic=!0;var u={};return u.prvKeyObj=n,u.pubKeyObj=i,u}else if(e=="EC"){var l=t,f=new g.crypto.ECDSA({curve:l}),d=f.generateKeyPairHex(),n=new g.crypto.ECDSA({curve:l});n.setPublicKeyHex(d.ecpubhex),n.setPrivateKeyHex(d.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var i=new g.crypto.ECDSA({curve:l});i.setPublicKeyHex(d.ecpubhex),i.isPrivate=!1,i.isPublic=!0;var u={};return u.prvKeyObj=n,u.pubKeyObj=i,u}else throw new Error("unknown algorithm: "+e)};ct.getPEM=function(e,t,r,n,i,a){var s=g,u=s.asn1,l=u.DERObjectIdentifier,f=u.DERInteger,d=u.ASN1Util.newObject,E=u.x509,p=E.SubjectPublicKeyInfo,h=s.crypto,A=h.DSA,m=h.ECDSA,S=We;function w(z){var X=d({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 y(z){var X=d({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 _(z){var X=d({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((S!==void 0&&e instanceof S||A!==void 0&&e instanceof A||m!==void 0&&e instanceof m)&&e.isPublic==!0&&(t===void 0||t=="PKCS8PUB")){var B=new p(e),D=B.tohex();return Qr(D,"PUBLIC KEY")}if(t=="PKCS1PRV"&&S!==void 0&&e instanceof S&&(r===void 0||r==null)&&e.isPrivate==!0){var B=w(e),D=B.tohex();return Qr(D,"RSA PRIVATE KEY")}if(t=="PKCS1PRV"&&m!==void 0&&e instanceof m&&(r===void 0||r==null)&&e.isPrivate==!0){var j=new l({name:e.curveName}),q=j.tohex(),F=y(e),P=F.tohex(),L="";return L+=Qr(q,"EC PARAMETERS"),L+=Qr(P,"EC PRIVATE KEY"),L}if(t=="PKCS1PRV"&&A!==void 0&&e instanceof A&&(r===void 0||r==null)&&e.isPrivate==!0){var B=_(e),D=B.tohex();return Qr(D,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&S!==void 0&&e instanceof S&&r!==void 0&&r!=null&&e.isPrivate==!0){var B=w(e),D=B.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",D,r,n,a)}if(t=="PKCS5PRV"&&m!==void 0&&e instanceof m&&r!==void 0&&r!=null&&e.isPrivate==!0){var B=y(e),D=B.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",D,r,n,a)}if(t=="PKCS5PRV"&&A!==void 0&&e instanceof A&&r!==void 0&&r!=null&&e.isPrivate==!0){var B=_(e),D=B.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",D,r,n,a)}var M=function(z,X){if(typeof X=="string")return ct.getEncryptedPKCS8PEM(z,X);if(typeof X=="object"&&Nt(X,"passcode")!=null){var ie=JSON.parse(JSON.stringify(X)),Se=ie.passcode;return delete ie.passcode,ct.getEncryptedPKCS8PEM(z,Se,ie)}};if(t=="PKCS8PRV"&&S!=null&&e instanceof S&&e.isPrivate==!0){var V=w(e),W=V.tohex(),B=d({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:W}}]}),D=B.tohex();return r===void 0||r==null?Qr(D,"PRIVATE KEY"):M(D,r)}if(t=="PKCS8PRV"&&m!==void 0&&e instanceof m&&e.isPrivate==!0){var G={seq:[{int:1},{octstr:{hex:e.prvKeyHex}}]};typeof e.pubKeyHex=="string"&&G.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]});var V=new d(G),W=V.tohex(),B=d({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:W}}]}),D=B.tohex();return r===void 0||r==null?Qr(D,"PRIVATE KEY"):M(D,r)}if(t=="PKCS8PRV"&&A!==void 0&&e instanceof A&&e.isPrivate==!0){var V=new f({bigint:e.x}),W=V.tohex(),B=d({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:W}}]}),D=B.tohex();return r===void 0||r==null?Qr(D,"PRIVATE KEY"):M(D,r)}throw new Error("unsupported object nor format")};ct.getKeyFromCSRPEM=function(e){var t=Xt(e,"CERTIFICATE REQUEST"),r=ct.getKeyFromCSRHex(t);return r};ct.getKeyFromCSRHex=function(e){var t=ct.parseCSRHex(e),r=ct.getKey(t.p8pubkeyhex,null,"pkcs8pub");return r};ct.parseCSRHex=function(e){var t=Ae,r=t.getChildIdx,n=t.getTLV,i={},a=e;if(a.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var s=r(a,0);if(s.length<1)throw new Error("malformed CSR(code:002)");if(a.substr(s[0],2)!="30")throw new Error("malformed CSR(code:003)");var u=r(a,s[0]);if(u.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(a,u[2]),i};ct.getKeyID=function(e){var t=ct,r=Ae;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=Xt(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),a=r.getV(n,i).substring(2);return g.crypto.Util.hashHex(a,"sha1")};ct.getJWK=function(e,t,r,n,i){var a,s={},u,l=g.crypto.Util.hashHex;if(typeof e=="string")a=ct.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(u=Xt(e));else if(typeof e=="object")e instanceof je?(a=e.getPublicKey(),u=e.hex):a=e;else throw new Error("unsupported keyinfo type");if(a instanceof We&&a.isPrivate)s.kty="RSA",s.n=Er(a.n.toString(16)),s.e=Er(a.e.toString(16)),s.d=Er(a.d.toString(16)),s.p=Er(a.p.toString(16)),s.q=Er(a.q.toString(16)),s.dp=Er(a.dmp1.toString(16)),s.dq=Er(a.dmq1.toString(16)),s.qi=Er(a.coeff.toString(16));else if(a instanceof We&&a.isPublic)s.kty="RSA",s.n=Er(a.n.toString(16)),s.e=Er(a.e.toString(16));else if(a instanceof g.crypto.ECDSA&&a.isPrivate){var f=a.getShortNISTPCurveName();if(f!=="P-256"&&f!=="P-384"&&f!=="P-521")throw new Error("unsupported curve name for JWT: "+f);var d=a.getPublicKeyXYHex();s.kty="EC",s.crv=f,s.x=Er(d.x),s.y=Er(d.y),s.d=Er(a.prvKeyHex)}else if(a instanceof g.crypto.ECDSA&&a.isPublic){var f=a.getShortNISTPCurveName();if(f!=="P-256"&&f!=="P-384"&&f!=="P-521")throw new Error("unsupported curve name for JWT: "+f);var d=a.getPublicKeyXYHex();s.kty="EC",s.crv=f,s.x=Er(d.x),s.y=Er(d.y)}if(s.kty==null)throw new Error("unsupported keyinfo");return!a.isPrivate&&t!=!0&&(s.kid=g.jws.JWS.getJWKthumbprint(s)),u!=null&&r!=!0&&(s.x5c=[Is(u)]),u!=null&&n!=!0&&(s.x5t=wu(Is(l(u,"sha1")))),u!=null&&i!=!0&&(s["x5t#S256"]=wu(Is(l(u,"sha256")))),s};ct.getJWKFromKey=function(e){return ct.getJWK(e,!0,!0,!0,!0)};We.getPosArrayOfChildrenFromHex=function(e){return Ae.getChildIdx(e,0)};We.getHexValueArrayOfChildrenFromHex=function(e){var t=Ae,r=t.getV,p=We.getPosArrayOfChildrenFromHex(e),n=r(e,p[0]),i=r(e,p[1]),a=r(e,p[2]),s=r(e,p[3]),u=r(e,p[4]),l=r(e,p[5]),f=r(e,p[6]),d=r(e,p[7]),E=r(e,p[8]),p=new Array;return p.push(n,i,a,s,u,l,f,d,E),p};We.prototype.readPrivateKeyFromPEMString=function(e){var t=Xt(e),r=We.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};We.prototype.readPKCS5PrvKeyHex=function(e){var t=We.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};We.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,a,s,u,l,f=Ae,d=f.getVbyListEx;if(f.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");try{t=d(e,0,[2,0,1],"02"),r=d(e,0,[2,0,2],"02"),n=d(e,0,[2,0,3],"02"),i=d(e,0,[2,0,4],"02"),a=d(e,0,[2,0,5],"02"),s=d(e,0,[2,0,6],"02"),u=d(e,0,[2,0,7],"02"),l=d(e,0,[2,0,8],"02")}catch{throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,i,a,s,u,l)};We.prototype.readPKCS5PubKeyHex=function(e){var t=Ae,r=t.getV;if(t.isASN1HEX(e)===!1)throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(n.length!==2||e.substr(n[0],2)!=="02"||e.substr(n[1],2)!=="02")throw new Error("wrong hex for PKCS#5 public key");var i=r(e,n[0]),a=r(e,n[1]);this.setPublic(i,a)};We.prototype.readPKCS8PubKeyHex=function(e){var t=Ae;if(t.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");if(t.getTLVbyListEx(e,0,[0,0])!=="06092a864886f70d010101")throw new Error("not PKCS8 RSA public key");var r=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(r)};We.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new je,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var CT=new RegExp("[^0-9a-f]","gi");function Pv(e,t){for(var r="",n=t/4-e.length,i=0;i>24,(i&16711680)>>16,(i&65280)>>8,i&255])))),i+=1;return n}We.prototype.signPSS=function(e,t,r){var n=function(a){return g.crypto.Util.hashHex(a,t)},i=n(qi(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(i,t,r)};We.prototype.signWithMessageHashPSS=function(e,t,r){var n=$n(e),i=n.length,a=this.n.bitLength()-1,s=Math.ceil(a/8),u,l=function(S){return g.crypto.Util.hashHex(S,t)};if(r===-1||r===void 0)r=i;else if(r===-2)r=s-i-2;else if(r<-2)throw new Error("invalid salt length");if(s0&&(f=new Array(r),new bu().nextBytes(f),f=String.fromCharCode.apply(String,f));var d=$n(l(qi("\0\0\0\0\0\0\0\0"+n+f))),E=[];for(u=0;u>8*s-a&255;for(A[0]&=~m,u=0;un)return!1;var i=this.doPublic(r),a=i.toString(16);if(a.length+3!=n/4)return!1;var s=a.replace(/^1f+00/,""),u=Ov(s);if(u.length==0)return!1;var l=u[0],f=u[1],d=function(p){return g.crypto.Util.hashString(p,l)},E=d(e);return f==E};We.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=Fn(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),i=n.toString(16).replace(/^1f+00/,""),a=Ov(i);if(a.length==0)return!1;var s=a[0],u=a[1];return u==e};We.prototype.verifyPSS=function(e,t,r,n){var i=function(s){return g.crypto.Util.hashHex(s,r)},a=i(qi(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(a,t,r,n)};We.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=new ee(t,16),a=function(y){return g.crypto.Util.hashHex(y,r)},s=$n(e),u=s.length,l=this.n.bitLength()-1,f=Math.ceil(l/8),d;if(n===-1||n===void 0)n=u;else if(n===-2)n=f-u-2;else if(n<-2)throw new Error("invalid salt length");if(f>8*f-l&255;if(p.charCodeAt(0)&A)throw new Error("bits beyond keysize not zero");var m=Tv(h,p.length,a),S=[];for(d=0;d0?P:void 0}catch{return}},this._asn1ToNoticeRef=function(F){try{for(var P={},L=Nt(F,"seq"),M=0;M0?P:void 0}catch{return}},this._asn1ToNoticeNum=function(F){try{for(var P=Nt(F,"seq"),L=[],M=0;M1){var W=s(F,V[1]),G=this.getGeneralName(W);G.uri!=null&&(M.uri=G.uri)}if(V.length>2){var z=s(F,V[2]);z=="0101ff"&&(M.reqauth=!0),z=="010100"&&(M.reqauth=!1)}return M},this.getExtSubjectDirectoryAttributes=function(F,P){if(F===void 0&&P===void 0){var L=this.getExtInfo("subjectDirectoryAttributes");if(L===void 0)return;F=s(this.hex,L.vidx),P=L.critical}var M={extname:"subjectDirectoryAttributes"};P&&(M.critical=!0);try{for(var V=a(F),W=[],G=0;G0&&(P.ext=this.getExtParamArray()),P.sighex=this.getSignatureValueHex(),F.tbshex==!0&&(P.tbshex=f(this.hex,0,[0])),F.nodnarray==!0&&(delete P.issuer.array,delete P.subject.array),P},this.getExtParamArray=function(F){if(F==null){var P=p(this.hex,0,[0,"[3]"]);P!=-1&&(F=d(this.hex,0,[0,"[3]",0],"30"))}for(var L=[],M=r(F,0),V=0;V"u"||!g)&&(g={});(typeof g.jws>"u"||!g.jws)&&(g.jws={});g.jws.JWS=function(){var e=g,t=e.jws.JWS,r=t.isSafeJSONString;this.parseJWS=function(n,i){if(!(this.parsedJWS!==void 0&&(i||this.parsedJWS.sigvalH!==void 0))){var a=n.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(a==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=a[1],u=a[2],l=a[3],f=s+"."+u;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=u,this.parsedJWS.sigvalB64U=l,this.parsedJWS.si=f,!i){var d=qt(l),E=Fn(d,16);this.parsedJWS.sigvalH=d,this.parsedJWS.sigvalBI=E}var p=Si(s),h=Si(u);if(this.parsedJWS.headS=p,this.parsedJWS.payloadS=h,!r(p,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+p}}};g.jws.JWS.sign=function(e,t,r,n,i){var a=g,s=a.jws,u=s.JWS,l=u.readSafeJSONString,f=u.isSafeJSONString,d=a.crypto,E=d.ECDSA,p=d.Mac,h=d.Signature,A=JSON,m,S,w;if(typeof t!="string"&&typeof t!="object")throw"spHeader must be JSON string or object: "+t;if(typeof t=="object"&&(S=t,m=A.stringify(S)),typeof t=="string"){if(m=t,!f(m))throw"JWS Head is not safe JSON string: "+m;S=l(m)}if(w=r,typeof r=="object"&&(w=A.stringify(r)),(e==""||e==null)&&S.alg!==void 0&&(e=S.alg),e!=""&&e!=null&&S.alg===void 0&&(S.alg=e,m=A.stringify(S)),e!==S.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+S.alg;var y=null;if(u.jwsalg2sigalg[e]===void 0)throw"unsupported alg name: "+e;y=u.jwsalg2sigalg[e];var _=Hc(m),B=Hc(w),D=_+"."+B,j="";if(y.substr(0,4)=="Hmac"){if(n===void 0)throw"mac key shall be specified for HS* alg";var q=new p({alg:y,prov:"cryptojs",pass:n});q.updateString(D),j=q.doFinal()}else if(y.indexOf("withECDSA")!=-1){var F=new h({alg:y});F.init(n,i),F.updateString(D);var P=F.sign();j=g.crypto.ECDSA.asn1SigToConcatSig(P)}else if(y!="none"){var F=new h({alg:y});F.init(n,i),F.updateString(D),j=F.sign()}var L=Er(j);return D+"."+L};g.jws.JWS.verify=function(e,t,r){var n=g,i=n.jws,a=i.JWS,s=a.readSafeJSONString,u=n.crypto,l=u.ECDSA,f=u.Mac,d=u.Signature,E;if(typeof We!==void 0&&(E=We),!Vd(e))return!1;var p=e.split(".");if(p.length!==3)return!1;var h=p[0],A=p[1],m=h+"."+A,S=qt(p[2]),w=s(Si(p[0])),y=null,_=null;if(w.alg===void 0)throw"algorithm not specified in header";if(y=w.alg,_=y.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var B=":"+r.join(":")+":";if(B.indexOf(":"+y+":")==-1)throw"algorithm '"+y+"' not accepted in the list"}if(y!="none"&&t===null)throw"key shall be specified to verify.";if(typeof t=="string"&&t.indexOf("-----BEGIN ")!=-1&&(t=ct.getKey(t)),(_=="RS"||_=="PS")&&!(t instanceof E))throw"key shall be a RSAKey obj for RS* and PS* algs";if(_=="ES"&&!(t instanceof l))throw"key shall be a ECDSA obj for ES* algs";y=="none";var D=null;if(a.jwsalg2sigalg[w.alg]===void 0)throw"unsupported alg name: "+y;if(D=a.jwsalg2sigalg[y],D=="none")throw"not supported";if(D.substr(0,4)=="Hmac"){var j=null;if(t===void 0)throw"hexadecimal key shall be specified for HMAC";var q=new f({alg:D,pass:t});return q.updateString(m),j=q.doFinal(),S==j}else if(D.indexOf("withECDSA")!=-1){var F=null;try{F=l.concatSigToASN1Sig(S)}catch{return!1}var P=new d({alg:D});return P.init(t),P.updateString(m),P.verify(F)}else{var P=new d({alg:D});return P.init(t),P.updateString(m),P.verify(S)}};g.jws.JWS.parse=function(e){var t=e.split("."),r={},n,i,a;if(t.length!=2&&t.length!=3)throw"malformed sJWS: wrong number of '.' splitted elements";return n=t[0],i=t[1],t.length==3&&(a=t[2]),r.headerObj=g.jws.JWS.readSafeJSONString(Si(n)),r.payloadObj=g.jws.JWS.readSafeJSONString(Si(i)),r.headerPP=JSON.stringify(r.headerObj,null," "),r.payloadObj==null?r.payloadPP=Si(i):r.payloadPP=JSON.stringify(r.payloadObj,null," "),a!==void 0&&(r.sigHex=qt(a)),r};g.jws.JWS.verifyJWT=function(e,t,r){var n=g,i=n.jws,a=i.JWS,s=a.readSafeJSONString,u=a.inArray,l=a.includedArray;if(!Vd(e))return!1;var f=e.split(".");if(f.length!=3)return!1;var d=f[0],E=f[1],p=d+"."+E,h=qt(f[2]),A=s(Si(d)),m=s(Si(E));if(A.alg===void 0)return!1;if(r.alg===void 0)throw"acceptField.alg shall be specified";if(!u(A.alg,r.alg)||m.iss!==void 0&&typeof r.iss=="object"&&!u(m.iss,r.iss)||m.sub!==void 0&&typeof r.sub=="object"&&!u(m.sub,r.sub))return!1;if(m.aud!==void 0&&typeof r.aud=="object"){if(typeof m.aud=="string"){if(!u(m.aud,r.aud))return!1}else if(typeof m.aud=="object"&&!l(m.aud,r.aud))return!1}var S=i.IntDate.getNow();return r.verifyAt!==void 0&&typeof r.verifyAt=="number"&&(S=r.verifyAt),(r.gracePeriod===void 0||typeof r.gracePeriod!="number")&&(r.gracePeriod=0),!(m.exp!==void 0&&typeof m.exp=="number"&&m.exp+r.gracePeriod"u"||!g)&&(g={});(typeof g.jws>"u"||!g.jws)&&(g.jws={});g.jws.JWSJS=function(){var e=g,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(i){this.init();var a=i.split(".");if(a.length!=3)throw"malformed input JWS";this.aHeader.push(a[0]),this.sPayload=a[1],this.aSignature.push(a[2])},this.addSignature=function(i,a,s,u){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 f=g.jws.JWS.sign(i,a,this.sPayload,s,u),d=f.split("."),E=d[0],p=d[2];this.aHeader.push(d[0]),this.aSignature.push(d[2])}catch(h){throw this.aHeader.length>l&&this.aHeader.pop(),this.aSignature.length>l&&this.aSignature.pop(),"addSignature failed: "+h}},this.verifyAll=function(i){if(this.aHeader.length!==i.length||this.aSignature.length!==i.length)return!1;for(var a=0;a0)this.aHeader=i.headers;else throw"malformed header";if(typeof i.payload=="string")this.sPayload=i.payload;else throw"malformed signatures";if(i.signatures.length>0)this.aSignature=i.signatures;else throw"malformed signatures"}catch(s){throw"malformed JWS-JS JSON object: "+s}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return this.aHeader.length==0?1:0}};be.SecureRandom=bu;be.rng_seed_time=Hd;be.BigInteger=ee;be.RSAKey=We;be.ECDSA=g.crypto.ECDSA;be.DSA=g.crypto.DSA;be.Signature=g.crypto.Signature;be.MessageDigest=g.crypto.MessageDigest;be.Mac=g.crypto.Mac;be.KEYUTIL=ct;be.ASN1HEX=Ae;be.X509=je;be.X509CRL=_8;be.CryptoJS=Ce;be.b64tohex=Au;be.b64toBA=gv;be.ECFieldElementFp=wr;be.ECPointFp=St;be.ECCurveFp=$s;be.stoBA=yv;be.BAtos=Sv;be.BAtohex=Lf;be.stohex=In;be.stob64=s8;be.stob64u=a8;be.b64utos=o8;be.b64tob64u=wu;be.b64utob64=jc;be.hex2b64=Is;be.hextob64u=Er;be.b64utohex=qt;be.utf8tob64u=Hc;be.b64utoutf8=Si;be.utf8tob64=u8;be.b64toutf8=c8;be.utf8tohex=Uf;be.hextoutf8=Rt;be.hextorstr=$n;be.rstrtohex=qi;be.hextob64=Md;be.hextob64nl=h8;be.b64nltohex=bv;be.hextopem=Qr;be.pemtohex=Xt;be.hextoArrayBuffer=g8;be.ArrayBuffertohex=m8;be.zulutomsec=jd;be.msectozulu=v8;be.zulutosec=Cv;be.zulutodate=E8;be.datetozulu=w8;be.uricmptohex=Mf;be.hextouricmp=jf;be.ipv6tohex=Od;be.hextoipv6=xd;be.hextoip=Tf;be.iptohex=qd;be.ucs2hextoutf8=Kd;be.encodeURIComponentAll=qf;be.newline_toUnix=A8;be.newline_toDos=y8;be.hextoposhex=Nd;be.intarystrtohex=S8;be.strdiffidx=b8;be.oidtohex=Iv;be.hextooid=Kf;be.strpad=Of;be.bitstrtoint=Dv;be.inttobitstr=Bv;be.bitstrtobinstr=Rv;be.binstrtobitstr=C8;be.isBase64URLDot=Vd;be.namearraytobinstr=xf;be.extendClass=he;be.foldnl=Hf;be.b64topem=p8;be.pemtob64=d8;be.timeogen=_v;be.aryval=Nt;be.inttohex=$v;be.twoscompl=qc;be.KJUR=g;be.crypto=g.crypto;be.asn1=g.asn1;be.jws=g.jws;be.lang=g.lang;be.VERSION=O5;be.VERSION_FULL=x5});var oo=ye((IT,ao)=>{"use strict";function kv(e){return typeof e>"u"||e===null}function I8(e){return typeof e=="object"&&e!==null}function $8(e){return Array.isArray(e)?e:kv(e)?[]:[e]}function D8(e,t){var r,n,i,a;if(t)for(a=Object.keys(t),r=0,n=a.length;r{"use strict";function Kc(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||""}Kc.prototype=Object.create(Error.prototype);Kc.prototype.constructor=Kc;Kc.prototype.toString=function(t){var r=this.name+": ";return r+=this.reason||"(unknown reason)",!t&&this.mark&&(r+=" "+this.mark.toString()),r};Lv.exports=Kc});var Mv=ye((DT,Hv)=>{"use strict";var Uv=oo();function zd(e,t,r,n,i){this.name=e,this.buffer=t,this.position=r,this.line=n,this.column=i}zd.prototype.getSnippet=function(t,r){var n,i,a,s,u;if(!this.buffer)return null;for(t=t||4,r=r||75,n="",i=this.position;i>0&&`\0\r \x85\u2028\u2029`.indexOf(this.buffer.charAt(i-1))===-1;)if(i-=1,this.position-i>r/2-1){n=" ... ",i+=5;break}for(a="",s=this.position;sr/2-1){a=" ... ",s-=5;break}return u=this.buffer.slice(i,s),Uv.repeat(" ",t)+n+u+a+` `+Uv.repeat(" ",t+this.position-i+n.length)+"^"};zd.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};Hv.exports=zd});var Ar=ye((BT,qv)=>{"use strict";var jv=Cu(),P8=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],T8=["scalar","sequence","mapping"];function O8(e){var t={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(n){t[String(n)]=r})}),t}function x8(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(P8.indexOf(r)===-1)throw new jv('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=O8(t.styleAliases||null),T8.indexOf(this.kind)===-1)throw new jv('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}qv.exports=x8});var uo=ye((RT,Vv)=>{"use strict";var Kv=oo(),Vf=Cu(),N8=Ar();function Yd(e,t,r){var n=[];return e.include.forEach(function(i){r=Yd(i,t,r)}),e[t].forEach(function(i){r.forEach(function(a,s){a.tag===i.tag&&a.kind===i.kind&&n.push(s)}),r.push(i)}),r.filter(function(i,a){return n.indexOf(a)===-1})}function k8(){var e={scalar:{},sequence:{},mapping:{},fallback:{}},t,r;function n(i){e[i.kind][i.tag]=e.fallback[i.tag]=i}for(t=0,r=arguments.length;t{"use strict";var L8=Ar();Gv.exports=new L8("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var Wv=ye((TT,Yv)=>{"use strict";var U8=Ar();Yv.exports=new U8("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var Jv=ye((OT,Xv)=>{"use strict";var H8=Ar();Xv.exports=new H8("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var Gf=ye((xT,Zv)=>{"use strict";var M8=uo();Zv.exports=new M8({explicit:[zv(),Wv(),Jv()]})});var e2=ye((NT,Qv)=>{"use strict";var j8=Ar();function q8(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function K8(){return null}function V8(e){return e===null}Qv.exports=new j8("tag:yaml.org,2002:null",{kind:"scalar",resolve:q8,construct:K8,predicate:V8,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var r2=ye((kT,t2)=>{"use strict";var G8=Ar();function z8(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 Y8(e){return e==="true"||e==="True"||e==="TRUE"}function W8(e){return Object.prototype.toString.call(e)==="[object Boolean]"}t2.exports=new G8("tag:yaml.org,2002:bool",{kind:"scalar",resolve:z8,construct:Y8,predicate:W8,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 i2=ye((LT,n2)=>{"use strict";var X8=oo(),J8=Ar();function Z8(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Q8(e){return 48<=e&&e<=55}function eI(e){return 48<=e&&e<=57}function tI(e){if(e===null)return!1;var t=e.length,r=0,n=!1,i;if(!t)return!1;if(i=e[r],(i==="-"||i==="+")&&(i=e[++r]),i==="0"){if(r+1===t)return!0;if(i=e[++r],i==="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 o2=ye((UT,a2)=>{"use strict";var s2=oo(),iI=Ar(),sI=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 aI(e){return!(e===null||!sI.test(e)||e[e.length-1]==="_")}function oI(e){var t,r,n,i;return t=e.replace(/_/g,"").toLowerCase(),r=t[0]==="-"?-1:1,i=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:t.indexOf(":")>=0?(t.split(":").forEach(function(a){i.unshift(parseFloat(a,10))}),t=0,n=1,i.forEach(function(a){t+=a*n,n*=60}),r*t):r*parseFloat(t,10)}var uI=/^[-+]?[0-9]+e/;function cI(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(s2.isNegativeZero(e))return"-0.0";return r=e.toString(10),uI.test(r)?r.replace("e",".e"):r}function lI(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||s2.isNegativeZero(e))}a2.exports=new iI("tag:yaml.org,2002:float",{kind:"scalar",resolve:aI,construct:oI,predicate:lI,represent:cI,defaultStyle:"lowercase"})});var Wd=ye((HT,u2)=>{"use strict";var fI=uo();u2.exports=new fI({include:[Gf()],implicit:[e2(),r2(),i2(),o2()]})});var Xd=ye((MT,c2)=>{"use strict";var hI=uo();c2.exports=new hI({include:[Wd()]})});var p2=ye((jT,h2)=>{"use strict";var pI=Ar(),l2=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),f2=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 dI(e){return e===null?!1:l2.exec(e)!==null||f2.exec(e)!==null}function gI(e){var t,r,n,i,a,s,u,l=0,f=null,d,E,p;if(t=l2.exec(e),t===null&&(t=f2.exec(e)),t===null)throw new Error("Date resolve error");if(r=+t[1],n=+t[2]-1,i=+t[3],!t[4])return new Date(Date.UTC(r,n,i));if(a=+t[4],s=+t[5],u=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(d=+t[10],E=+(t[11]||0),f=(d*60+E)*6e4,t[9]==="-"&&(f=-f)),p=new Date(Date.UTC(r,n,i,a,s,u,l)),f&&p.setTime(p.getTime()-f),p}function mI(e){return e.toISOString()}h2.exports=new pI("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:dI,construct:gI,instanceOf:Date,represent:mI})});var g2=ye((qT,d2)=>{"use strict";var vI=Ar();function EI(e){return e==="<<"||e===null}d2.exports=new vI("tag:yaml.org,2002:merge",{kind:"scalar",resolve:EI})});var E2=ye((KT,v2)=>{"use strict";var co;try{m2=za,co=m2("buffer").Buffer}catch{}var m2,wI=Ar(),Jd=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= \r`;function AI(e){if(e===null)return!1;var t,r,n=0,i=e.length,a=Jd;for(r=0;r64)){if(t<0)return!1;n+=6}return n%8===0}function yI(e){var t,r,n=e.replace(/[\r\n=]/g,""),i=n.length,a=Jd,s=0,u=[];for(t=0;t>16&255),u.push(s>>8&255),u.push(s&255)),s=s<<6|a.indexOf(n.charAt(t));return r=i%4*6,r===0?(u.push(s>>16&255),u.push(s>>8&255),u.push(s&255)):r===18?(u.push(s>>10&255),u.push(s>>2&255)):r===12&&u.push(s>>4&255),co?co.from?co.from(u):new co(u):u}function SI(e){var t="",r=0,n,i,a=e.length,s=Jd;for(n=0;n>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]),r=(r<<8)+e[n];return i=a%3,i===0?(t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]):i===2?(t+=s[r>>10&63],t+=s[r>>4&63],t+=s[r<<2&63],t+=s[64]):i===1&&(t+=s[r>>2&63],t+=s[r<<4&63],t+=s[64],t+=s[64]),t}function bI(e){return co&&co.isBuffer(e)}v2.exports=new wI("tag:yaml.org,2002:binary",{kind:"scalar",resolve:AI,construct:yI,predicate:bI,represent:SI})});var A2=ye((GT,w2)=>{"use strict";var CI=Ar(),_I=Object.prototype.hasOwnProperty,FI=Object.prototype.toString;function II(e){if(e===null)return!0;var t=[],r,n,i,a,s,u=e;for(r=0,n=u.length;r{"use strict";var DI=Ar(),BI=Object.prototype.toString;function RI(e){if(e===null)return!0;var t,r,n,i,a,s=e;for(a=new Array(s.length),t=0,r=s.length;t{"use strict";var TI=Ar(),OI=Object.prototype.hasOwnProperty;function xI(e){if(e===null)return!0;var t,r=e;for(t in r)if(OI.call(r,t)&&r[t]!==null)return!1;return!0}function NI(e){return e!==null?e:{}}b2.exports=new TI("tag:yaml.org,2002:set",{kind:"mapping",resolve:xI,construct:NI})});var Fu=ye((WT,_2)=>{"use strict";var kI=uo();_2.exports=new kI({include:[Xd()],implicit:[p2(),g2()],explicit:[E2(),A2(),S2(),C2()]})});var I2=ye((XT,F2)=>{"use strict";var LI=Ar();function UI(){return!0}function HI(){}function MI(){return""}function jI(e){return typeof e>"u"}F2.exports=new LI("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:UI,construct:HI,predicate:jI,represent:MI})});var D2=ye((JT,$2)=>{"use strict";var qI=Ar();function KI(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 VI(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 GI(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}function zI(e){return Object.prototype.toString.call(e)==="[object RegExp]"}$2.exports=new qI("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:KI,construct:VI,predicate:zI,represent:GI})});var P2=ye((ZT,R2)=>{"use strict";var zf;try{B2=za,zf=B2("esprima")}catch{typeof window<"u"&&(zf=window.esprima)}var B2,YI=Ar();function WI(e){if(e===null)return!1;try{var t="("+e+")",r=zf.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 XI(e){var t="("+e+")",r=zf.parse(t,{range:!0}),n=[],i;if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")throw new Error("Failed to resolve function");return r.body[0].expression.params.forEach(function(a){n.push(a.name)}),i=r.body[0].expression.body.range,r.body[0].expression.body.type==="BlockStatement"?new Function(n,t.slice(i[0]+1,i[1]-1)):new Function(n,"return "+t.slice(i[0],i[1]))}function JI(e){return e.toString()}function ZI(e){return Object.prototype.toString.call(e)==="[object Function]"}R2.exports=new YI("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:WI,construct:XI,predicate:ZI,represent:JI})});var Vc=ye((eO,O2)=>{"use strict";var T2=uo();O2.exports=T2.DEFAULT=new T2({include:[Fu()],explicit:[I2(),D2(),P2()]})});var Q2=ye((tO,Gc)=>{"use strict";var Ds=oo(),M2=Cu(),QI=Mv(),j2=Fu(),e$=Vc(),ga=Object.prototype.hasOwnProperty,Yf=1,q2=2,K2=3,Wf=4,Zd=1,t$=2,x2=3,r$=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,n$=/[\x85\u2028\u2029]/,i$=/[,\[\]\{\}]/,V2=/^(?:!|!!|![a-z\-]+!)$/i,G2=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function N2(e){return Object.prototype.toString.call(e)}function Ki(e){return e===10||e===13}function fo(e){return e===9||e===32}function Dn(e){return e===9||e===32||e===10||e===13}function Iu(e){return e===44||e===91||e===93||e===123||e===125}function s$(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function a$(e){return e===120?2:e===117?4:e===85?8:0}function o$(e){return 48<=e&&e<=57?e-48:-1}function k2(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 u$(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var z2=new Array(256),Y2=new Array(256);for(lo=0;lo<256;lo++)z2[lo]=k2(lo)?1:0,Y2[lo]=k2(lo);var lo;function c$(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||e$,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 W2(e,t){return new M2(t,new QI(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function Ke(e,t){throw W2(e,t)}function Xf(e,t){e.onWarning&&e.onWarning.call(null,W2(e,t))}var L2={YAML:function(t,r,n){var i,a,s;t.version!==null&&Ke(t,"duplication of %YAML directive"),n.length!==1&&Ke(t,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),i===null&&Ke(t,"ill-formed argument of the YAML directive"),a=parseInt(i[1],10),s=parseInt(i[2],10),a!==1&&Ke(t,"unacceptable YAML version of the document"),t.version=n[0],t.checkLineBreaks=s<2,s!==1&&s!==2&&Xf(t,"unsupported YAML version of the document")},TAG:function(t,r,n){var i,a;n.length!==2&&Ke(t,"TAG directive accepts exactly two arguments"),i=n[0],a=n[1],V2.test(i)||Ke(t,"ill-formed tag handle (first argument) of the TAG directive"),ga.call(t.tagMap,i)&&Ke(t,'there is a previously declared suffix for "'+i+'" tag handle'),G2.test(a)||Ke(t,"ill-formed tag prefix (second argument) of the TAG directive"),t.tagMap[i]=a}};function da(e,t,r,n){var i,a,s,u;if(t1&&(e.result+=Ds.repeat(` `,t-1))}function l$(e,t,r){var n,i,a,s,u,l,f,d,E=e.kind,p=e.result,h;if(h=e.input.charCodeAt(e.position),Dn(h)||Iu(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(i=e.input.charCodeAt(e.position+1),Dn(i)||r&&Iu(i)))return!1;for(e.kind="scalar",e.result="",a=s=e.position,u=!1;h!==0;){if(h===58){if(i=e.input.charCodeAt(e.position+1),Dn(i)||r&&Iu(i))break}else if(h===35){if(n=e.input.charCodeAt(e.position-1),Dn(n))break}else{if(e.position===e.lineStart&&Jf(e)||r&&Iu(h))break;if(Ki(h))if(l=e.line,f=e.lineStart,d=e.lineIndent,dr(e,!1,-1),e.lineIndent>=t){u=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=s,e.line=l,e.lineStart=f,e.lineIndent=d;break}}u&&(da(e,a,s,!1),e0(e,e.line-l),a=s=e.position,u=!1),fo(h)||(s=e.position+1),h=e.input.charCodeAt(++e.position)}return da(e,a,s,!1),e.result?!0:(e.kind=E,e.result=p,!1)}function f$(e,t){var r,n,i;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(da(e,n,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)n=e.position,e.position++,i=e.position;else return!0;else Ki(r)?(da(e,n,i,!0),e0(e,dr(e,!1,t)),n=i=e.position):e.position===e.lineStart&&Jf(e)?Ke(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);Ke(e,"unexpected end of the stream within a single quoted scalar")}function h$(e,t){var r,n,i,a,s,u;if(u=e.input.charCodeAt(e.position),u!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=n=e.position;(u=e.input.charCodeAt(e.position))!==0;){if(u===34)return da(e,r,e.position,!0),e.position++,!0;if(u===92){if(da(e,r,e.position,!0),u=e.input.charCodeAt(++e.position),Ki(u))dr(e,!1,t);else if(u<256&&z2[u])e.result+=Y2[u],e.position++;else if((s=a$(u))>0){for(i=s,a=0;i>0;i--)u=e.input.charCodeAt(++e.position),(s=s$(u))>=0?a=(a<<4)+s:Ke(e,"expected hexadecimal character");e.result+=u$(a),e.position++}else Ke(e,"unknown escape sequence");r=n=e.position}else Ki(u)?(da(e,r,n,!0),e0(e,dr(e,!1,t)),r=n=e.position):e.position===e.lineStart&&Jf(e)?Ke(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}Ke(e,"unexpected end of the stream within a double quoted scalar")}function p$(e,t){var r=!0,n,i=e.tag,a,s=e.anchor,u,l,f,d,E,p={},h,A,m,S;if(S=e.input.charCodeAt(e.position),S===91)l=93,E=!1,a=[];else if(S===123)l=125,E=!0,a={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),S=e.input.charCodeAt(++e.position);S!==0;){if(dr(e,!0,t),S=e.input.charCodeAt(e.position),S===l)return e.position++,e.tag=i,e.anchor=s,e.kind=E?"mapping":"sequence",e.result=a,!0;r||Ke(e,"missed comma between flow collection entries"),A=h=m=null,f=d=!1,S===63&&(u=e.input.charCodeAt(e.position+1),Dn(u)&&(f=d=!0,e.position++,dr(e,!0,t))),n=e.line,Du(e,t,Yf,!1,!0),A=e.tag,h=e.result,dr(e,!0,t),S=e.input.charCodeAt(e.position),(d||e.line===n)&&S===58&&(f=!0,S=e.input.charCodeAt(++e.position),dr(e,!0,t),Du(e,t,Yf,!1,!0),m=e.result),E?$u(e,a,p,A,h,m):f?a.push($u(e,null,p,A,h,m)):a.push(h),dr(e,!0,t),S=e.input.charCodeAt(e.position),S===44?(r=!0,S=e.input.charCodeAt(++e.position)):r=!1}Ke(e,"unexpected end of the stream within a flow collection")}function d$(e,t){var r,n,i=Zd,a=!1,s=!1,u=t,l=0,f=!1,d,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)Zd===i?i=E===43?x2:t$:Ke(e,"repeat of a chomping mode identifier");else if((d=o$(E))>=0)d===0?Ke(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?Ke(e,"repeat of an indentation width identifier"):(u=t+d-1,s=!0);else break;if(fo(E)){do E=e.input.charCodeAt(++e.position);while(fo(E));if(E===35)do E=e.input.charCodeAt(++e.position);while(!Ki(E)&&E!==0)}for(;E!==0;){for(Qd(e),e.lineIndent=0,E=e.input.charCodeAt(e.position);(!s||e.lineIndentu&&(u=e.lineIndent),Ki(E)){l++;continue}if(e.lineIndentt)&&l!==0)Ke(e,"bad indentation of a sequence entry");else if(e.lineIndentt)&&(Du(e,t,Wf,!0,i)&&(A?p=e.result:h=e.result),A||($u(e,f,d,E,p,h,a,s),E=p=h=null),dr(e,!0,-1),S=e.input.charCodeAt(e.position)),e.lineIndent>t&&S!==0)Ke(e,"bad indentation of a mapping entry");else if(e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndent tag; it should be "scalar", not "'+e.kind+'"'),E=0,p=e.implicitTypes.length;E tag; it should be "'+h.kind+'", not "'+e.kind+'"'),h.resolve(e.result)?(e.result=h.construct(e.result),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):Ke(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):Ke(e,"unknown tag !<"+e.tag+">");return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||d}function w$(e){var t=e.position,r,n,i,a=!1,s;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};(s=e.input.charCodeAt(e.position))!==0&&(dr(e,!0,-1),s=e.input.charCodeAt(e.position),!(e.lineIndent>0||s!==37));){for(a=!0,s=e.input.charCodeAt(++e.position),r=e.position;s!==0&&!Dn(s);)s=e.input.charCodeAt(++e.position);for(n=e.input.slice(r,e.position),i=[],n.length<1&&Ke(e,"directive name must not be less than one character in length");s!==0;){for(;fo(s);)s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!Ki(s));break}if(Ki(s))break;for(r=e.position;s!==0&&!Dn(s);)s=e.input.charCodeAt(++e.position);i.push(e.input.slice(r,e.position))}s!==0&&Qd(e),ga.call(L2,n)?L2[n](e,n,i):Xf(e,'unknown document directive "'+n+'"')}if(dr(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,dr(e,!0,-1)):a&&Ke(e,"directives end mark is expected"),Du(e,e.lineIndent-1,Wf,!1,!0),dr(e,!0,-1),e.checkLineBreaks&&n$.test(e.input.slice(t,e.position))&&Xf(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Jf(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,dr(e,!0,-1));return}if(e.position"u"&&(r=t,t=null);var n=X2(e,r);if(typeof t!="function")return n;for(var i=0,a=n.length;i"u"&&(r=t,t=null),J2(e,t,Ds.extend({schema:j2},r))}function y$(e,t){return Z2(e,Ds.extend({schema:j2},t))}Gc.exports.loadAll=J2;Gc.exports.load=Z2;Gc.exports.safeLoadAll=A$;Gc.exports.safeLoad=y$});var SE=ye((rO,i0)=>{"use strict";var Yc=oo(),Wc=Cu(),S$=Vc(),b$=Fu(),oE=Object.prototype.toString,uE=Object.prototype.hasOwnProperty,C$=9,zc=10,_$=13,F$=32,I$=33,$$=34,cE=35,D$=37,B$=38,R$=39,P$=42,lE=44,T$=45,fE=58,O$=61,x$=62,N$=63,k$=64,hE=91,pE=93,L$=96,dE=123,U$=124,gE=125,en={};en[0]="\\0";en[7]="\\a";en[8]="\\b";en[9]="\\t";en[10]="\\n";en[11]="\\v";en[12]="\\f";en[13]="\\r";en[27]="\\e";en[34]='\\"';en[92]="\\\\";en[133]="\\N";en[160]="\\_";en[8232]="\\L";en[8233]="\\P";var H$=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function M$(e,t){var r,n,i,a,s,u,l;if(t===null)return{};for(r={},n=Object.keys(t),i=0,a=n.length;i0?e.charCodeAt(a-1):null,p=p&&rE(s,u)}else{for(a=0;an&&e[E+1]!==" ",E=a);else if(!Bu(s))return Zf;u=a>0?e.charCodeAt(a-1):null,p=p&&rE(s,u)}f=f||d&&a-E-1>n&&e[E+1]!==" "}return!l&&!f?p&&!i(e)?vE:EE:r>9&&mE(e)?Zf:f?AE:wE}function z$(e,t,r,n){e.dump=function(){if(t.length===0)return"''";if(!e.noCompatMode&&H$.indexOf(t)!==-1)return"'"+t+"'";var i=e.indent*Math.max(1,r),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),s=n||e.flowLevel>-1&&r>=e.flowLevel;function u(l){return q$(e,l)}switch(G$(t,s,e.indent,a,u)){case vE:return t;case EE:return"'"+t.replace(/'/g,"''")+"'";case wE:return"|"+nE(t,e.indent)+iE(tE(t,i));case AE:return">"+nE(t,e.indent)+iE(tE(Y$(t,a),i));case Zf:return'"'+W$(t,a)+'"';default:throw new Wc("impossible error: invalid scalar style")}}()}function nE(e,t){var r=mE(e)?String(t):"",n=e[e.length-1]===` `,i=n&&(e[e.length-2]===` `||e===` `),a=i?"+":n?"":"-";return r+a+` `}function iE(e){return e[e.length-1]===` `?e.slice(0,-1):e}function Y$(e,t){for(var r=/(\n+)([^\n]*)/g,n=function(){var f=e.indexOf(` `);return f=f!==-1?f:e.length,r.lastIndex=f,sE(e.slice(0,f),t)}(),i=e[0]===` `||e[0]===" ",a,s;s=r.exec(e);){var u=s[1],l=s[2];a=l[0]===" ",n+=u+(!i&&!a&&l!==""?` `:"")+sE(l,t),i=a}return n}function sE(e,t){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,n,i=0,a,s=0,u=0,l="";n=r.exec(e);)u=n.index,u-i>t&&(a=s>i?s:u,l+=` `+e.slice(i,a),i=a+1),s=u;return l+=` `,e.length-i>t&&s>i?l+=e.slice(i,s)+` `+e.slice(s+1):l+=e.slice(i),l.slice(1)}function W$(e){for(var t="",r,n,i,a=0;a=55296&&r<=56319&&(n=e.charCodeAt(a+1),n>=56320&&n<=57343)){t+=eE((r-55296)*1024+n-56320+65536),a++;continue}i=en[r],t+=!i&&Bu(r)?e[a]:i||eE(r)}return t}function X$(e,t,r){var n="",i=e.tag,a,s;for(a=0,s=r.length;a1024&&(d+="? "),d+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),ho(e,t,f,!1,!1)&&(d+=e.dump,n+=d));e.tag=i,e.dump="{"+n+"}"}function Q$(e,t,r,n){var i="",a=e.tag,s=Object.keys(r),u,l,f,d,E,p;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new Wc("sortKeys must be a boolean or a function");for(u=0,l=s.length;u1024,E&&(e.dump&&zc===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,E&&(p+=t0(e,t)),ho(e,t+1,d,!0,E)&&(e.dump&&zc===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,i+=p));e.tag=a,e.dump=i||"{}"}function aE(e,t,r){var n,i,a,s,u,l;for(i=r?e.explicitTypes:e.implicitTypes,a=0,s=i.length;a tag resolver accepts not "'+l+'" style');e.dump=n}return!0}return!1}function ho(e,t,r,n,i,a){e.tag=null,e.dump=r,aE(e,r,!1)||aE(e,r,!0);var s=oE.call(e.dump);n&&(n=e.flowLevel<0||e.flowLevel>t);var u=s==="[object Object]"||s==="[object Array]",l,f;if(u&&(l=e.duplicates.indexOf(r),f=l!==-1),(e.tag!==null&&e.tag!=="?"||f||e.indent!==2&&t>0)&&(i=!1),f&&e.usedDuplicates[l])e.dump="*ref_"+l;else{if(u&&f&&!e.usedDuplicates[l]&&(e.usedDuplicates[l]=!0),s==="[object Object]")n&&Object.keys(e.dump).length!==0?(Q$(e,t,e.dump,i),f&&(e.dump="&ref_"+l+e.dump)):(Z$(e,t,e.dump),f&&(e.dump="&ref_"+l+" "+e.dump));else if(s==="[object Array]"){var d=e.noArrayIndent&&t>0?t-1:t;n&&e.dump.length!==0?(J$(e,d,e.dump,i),f&&(e.dump="&ref_"+l+e.dump)):(X$(e,d,e.dump),f&&(e.dump="&ref_"+l+" "+e.dump))}else if(s==="[object String]")e.tag!=="?"&&z$(e,e.dump,t,a);else{if(e.skipInvalid)return!1;throw new Wc("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(e.dump="!<"+e.tag+"> "+e.dump)}return!0}function eD(e,t){var r=[],n=[],i,a;for(r0(e,r,n),i=0,a=n.length;i{"use strict";var Qf=Q2(),bE=SE();function eh(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}nr.exports.Type=Ar();nr.exports.Schema=uo();nr.exports.FAILSAFE_SCHEMA=Gf();nr.exports.JSON_SCHEMA=Wd();nr.exports.CORE_SCHEMA=Xd();nr.exports.DEFAULT_SAFE_SCHEMA=Fu();nr.exports.DEFAULT_FULL_SCHEMA=Vc();nr.exports.load=Qf.load;nr.exports.loadAll=Qf.loadAll;nr.exports.safeLoad=Qf.safeLoad;nr.exports.safeLoadAll=Qf.safeLoadAll;nr.exports.dump=bE.dump;nr.exports.safeDump=bE.safeDump;nr.exports.YAMLException=Cu();nr.exports.MINIMAL_SCHEMA=Gf();nr.exports.SAFE_SCHEMA=Fu();nr.exports.DEFAULT_SCHEMA=Vc();nr.exports.scan=eh("scan");nr.exports.parse=eh("parse");nr.exports.compose=eh("compose");nr.exports.addConstructor=eh("addConstructor")});var FE=ye((iO,_E)=>{"use strict";var rD=CE();_E.exports=rD});var $E=ye((sO,IE)=>{"use strict";var th=FE();IE.exports={safeLoad:th.safeLoad,load:th.load,safeDump:th.safeDump,dump:th.dump}});var PE=ye(o0=>{"use strict";o0.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};o0.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 TE=ye(u0=>{"use strict";u0.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};u0.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 OE=ye(c0=>{"use strict";c0.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};c0.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 xE=ye(l0=>{"use strict";l0.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};l0.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 NE=ye(f0=>{"use strict";f0.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}`};f0.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 UE=ye((LE,h0)=>{var kE=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=E,e.encode=d,e.familyOf=f,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,i=16,a={name:"v4",size:r,isFormat:p=>t.test(p),encode(p,h,A){A=~~A,h=h||new Uint8Array(A+r);let m=p.length,S=0;for(let w=0;wp.length>0&&n.test(p),encode(p,h,A){A=~~A;let m=A+i,S=-1,w=0,y=0,_=!0,B=!1;h=h||new Uint8Array(A+i);for(let D=0;D>8),A=97?j-=87:j>=65?j-=55:(j-=48,y=y*10+j),w=(w<<4)+j)}if(_===!1)B===!0?(A>8),A=S+2;D--)h[D]=h[D-2];h[S]=0,h[S+1]=0,S=A}if(S!==A&&S!==-1)for(A>m-2&&(A=m-2);m>S;)h[--m]=AS?h[--A]:0;else for(;A{"use strict";var Ue=Rf().Buffer,Us=PE(),sD=TE(),aD=OE(),ah=xE(),p0=NE(),go=UE(),oD=0,HE=32768,d0=32768,uD=~d0,ME=32768,cD=~ME,De=Le.name={};De.encode=function(e,t,r,{mail:n=!1}={}){t||(t=Ue.alloc(De.encodingLength(e))),r||(r=0);let i=r,a=e.replace(/^\.|\.$/gm,"");if(a.length){let s=[];if(n){let u="";a.split(".").forEach(l=>{l.endsWith("\\")?u+=(u.length?".":"")+l.slice(0,-1):s.length===0&&u.length?s.push(u+"."+l):s.push(l)})}else s=a.split(".");for(let u=0;u=e.length)throw new Error("Cannot decode name (buffer overflow)");let l=e[t++];if(s+=u?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 f=e.readUInt16BE(t-1)-49152;if(f>=i)throw new Error("Cannot decode name (bad pointer)");t=f,i=f,s+=u?0:1,u=!0}else throw new Error("Cannot decode name (bad label)");else{if(t+l>e.length)throw new Error("Cannot decode name (buffer overflow)");if(a+=l+1,a>254)throw new Error("Cannot decode name (name too long)");let f=e.toString("utf-8",t,t+l);r&&(f=f.replace(/\./g,"\\.")),n.push(f),t+=l,s+=u?0:l}}return De.decode.bytes=s,n.length===0?".":n.join(".")};De.decode.bytes=0;De.encodingLength=function(e){return e==="."||e===".."?1:Ue.byteLength(e.replace(/^\.|\.$/gm,""))+2};var ut={};ut.encode=function(e,t,r){t||(t=Ue.alloc(ut.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,ut.encode.bytes=n+1,t};ut.encode.bytes=0;ut.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return ut.decode.bytes=r+1,n};ut.decode.bytes=0;ut.encodingLength=function(e){return Ue.byteLength(e)+1};var _i={};_i.encode=function(e,t,r){t||(t=_i.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,i=e.type==="response"?HE:oD;return t.writeUInt16BE(e.id||0,r),t.writeUInt16BE(n|i,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};_i.encode.bytes=12;_i.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&HE?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:aD.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:sD.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))}};_i.decode.bytes=12;_i.encodingLength=function(){return 12};var Bs=Le.unknown={};Bs.encode=function(e,t,r){return t||(t=Ue.alloc(Bs.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),Bs.encode.bytes=e.length+2,t};Bs.encode.bytes=0;Bs.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return Bs.decode.bytes=r+2,n};Bs.decode.bytes=0;Bs.encodingLength=function(e){return e.length+2};var Rs=Le.ns={};Rs.encode=function(e,t,r){return t||(t=Ue.alloc(Rs.encodingLength(e))),r||(r=0),De.encode(e,t,r+2),t.writeUInt16BE(De.encode.bytes,r),Rs.encode.bytes=De.encode.bytes+2,t};Rs.encode.bytes=0;Rs.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=De.decode(e,t+2);return Rs.decode.bytes=r+2,n};Rs.decode.bytes=0;Rs.encodingLength=function(e){return De.encodingLength(e)+2};var Ps=Le.soa={};Ps.encode=function(e,t,r){t||(t=Ue.alloc(Ps.encodingLength(e))),r||(r=0);let n=r;return r+=2,De.encode(e.mname,t,r),r+=De.encode.bytes,De.encode(e.rname,t,r,{mail:!0}),r+=De.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),Ps.encode.bytes=r-n,t};Ps.encode.bytes=0;Ps.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mname=De.decode(e,t),t+=De.decode.bytes,n.rname=De.decode(e,t,{mail:!0}),t+=De.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,Ps.decode.bytes=t-r,n};Ps.decode.bytes=0;Ps.encodingLength=function(e){return 22+De.encodingLength(e.mname)+De.encodingLength(e.rname)};var Ts=Le.txt={};Ts.encode=function(e,t,r){Array.isArray(e)||(e=[e]);for(let i=0;i0;){let a=e[t++];if(--n,n0&&(r.timeout=e.readUInt16BE(t),t+=2);break;case 14:r.tags=[];for(let a=0;a0;)n[a++]=Bn.decode(e,t),t+=Bn.decode.bytes,i-=Bn.decode.bytes;return Gn.decode.bytes=t-r,n};Gn.decode.bytes=0;Gn.encodingLength=function(e){return 2+Pu(e||[],Bn)};var dn=Le.dnskey={};dn.PROTOCOL_DNSSEC=3;dn.ZONE_KEY=128;dn.SECURE_ENTRYPOINT=32768;dn.encode=function(e,t,r){t||(t=Ue.alloc(dn.encodingLength(e))),r||(r=0);let n=r,i=e.key;if(!Ue.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(dn.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,i.copy(t,r,0,i.length),r+=i.length,dn.encode.bytes=r-n,t.writeUInt16BE(dn.encode.bytes-2,n),t};dn.encode.bytes=0;dn.decode=function(e,t){t||(t=0);let r=t;var n={},i=e.readUInt16BE(t);if(t+=2,n.flags=e.readUInt16BE(t),t+=2,e.readUInt8(t)!==dn.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+i+2),t+=n.key.length,dn.decode.bytes=t-r,n};dn.decode.bytes=0;dn.encodingLength=function(e){return 6+Ue.byteLength(e.key)};var Vi=Le.rrsig={};Vi.encode=function(e,t,r){t||(t=Ue.alloc(Vi.encodingLength(e))),r||(r=0);let n=r,i=e.signature;if(!Ue.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(Us.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,De.encode(e.signersName,t,r),r+=De.encode.bytes,i.copy(t,r,0,i.length),r+=i.length,Vi.encode.bytes=r-n,t.writeUInt16BE(Vi.encode.bytes-2,n),t};Vi.encode.bytes=0;Vi.decode=function(e,t){t||(t=0);let r=t;var n={},i=e.readUInt16BE(t);return t+=2,n.typeCovered=Us.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=De.decode(e,t),t+=De.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,Vi.decode.bytes=t-r,n};Vi.decode.bytes=0;Vi.encodingLength=function(e){return 20+De.encodingLength(e.signersName)+Ue.byteLength(e.signature)};var Gi=Le.rp={};Gi.encode=function(e,t,r){t||(t=Ue.alloc(Gi.encodingLength(e))),r||(r=0);let n=r;return r+=2,De.encode(e.mbox||".",t,r,{mail:!0}),r+=De.encode.bytes,De.encode(e.txt||".",t,r),r+=De.encode.bytes,Gi.encode.bytes=r-n,t.writeUInt16BE(Gi.encode.bytes-2,n),t};Gi.encode.bytes=0;Gi.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mbox=De.decode(e,t,{mail:!0})||".",t+=De.decode.bytes,n.txt=De.decode(e,t)||".",t+=De.decode.bytes,Gi.decode.bytes=t-r,n};Gi.decode.bytes=0;Gi.encodingLength=function(e){return 2+De.encodingLength(e.mbox||".")+De.encodingLength(e.txt||".")};var Rr={};Rr.encode=function(e,t,r){t||(t=Ue.alloc(Rr.encodingLength(e))),r||(r=0);let n=r;for(var i=[],a=0;a>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(a=0;a>8]=Math.max(t[n>>8]||0,n&255)}var i=0;for(r=0;r>15&1)===1,r.options=Gn.decode(e,t+8),t+=8+Gn.decode.bytes;else{let i=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=ah.toString(i&uD),r.flush=!!(i&d0);let a=g0(r.type);r.data=a.decode(e,t+8),t+=8+a.decode.bytes}return Hr.decode.bytes=t-n,r};Hr.decode.bytes=0;Hr.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return De.encodingLength(e.name)+8+g0(e.type).encodingLength(t)};var Ci=Le.question={};Ci.encode=function(e,t,r){t||(t=Ue.alloc(Ci.encodingLength(e))),r||(r=0);let n=r;return De.encode(e.name,t,r),r+=De.encode.bytes,t.writeUInt16BE(Us.toType(e.type),r),r+=2,t.writeUInt16BE(ah.toClass(e.class===void 0?"IN":e.class),r),r+=2,Ci.encode.bytes=r-n,e};Ci.encode.bytes=0;Ci.decode=function(e,t){t||(t=0);let r=t,n={};return n.name=De.decode(e,t),t+=De.decode.bytes,n.type=Us.toString(e.readUInt16BE(t)),t+=2,n.class=ah.toString(e.readUInt16BE(t)),t+=2,!!(n.class&ME)&&(n.class&=cD),Ci.decode.bytes=t-r,n};Ci.decode.bytes=0;Ci.encodingLength=function(e){return De.encodingLength(e.name)+4};Le.AUTHORITATIVE_ANSWER=1024;Le.TRUNCATED_RESPONSE=512;Le.RECURSION_DESIRED=256;Le.RECURSION_AVAILABLE=128;Le.AUTHENTIC_DATA=32;Le.CHECKING_DISABLED=16;Le.DNSSEC_OK=32768;Le.encode=function(e,t,r){let n=!t;n&&(t=Ue.alloc(Le.encodingLength(e))),r||(r=0);let i=r;return e.questions||(e.questions=[]),e.answers||(e.answers=[]),e.authorities||(e.authorities=[]),e.additionals||(e.additionals=[]),_i.encode(e,t,r),r+=_i.encode.bytes,r=el(e.questions,Ci,t,r),r=el(e.answers,Hr,t,r),r=el(e.authorities,Hr,t,r),r=el(e.additionals,Hr,t,r),Le.encode.bytes=r-i,n&&Le.encode.bytes!==t.length?t.slice(0,Le.encode.bytes):t};Le.encode.bytes=0;Le.decode=function(e,t){t||(t=0);let r=t,n=_i.decode(e,t);return t+=_i.decode.bytes,t=sh(n.questions,Ci,e,t),t=sh(n.answers,Hr,e,t),t=sh(n.authorities,Hr,e,t),t=sh(n.additionals,Hr,e,t),Le.decode.bytes=t-r,n};Le.decode.bytes=0;Le.encodingLength=function(e){return _i.encodingLength(e)+Pu(e.questions||[],Ci)+Pu(e.answers||[],Hr)+Pu(e.authorities||[],Hr)+Pu(e.additionals||[],Hr)};Le.streamEncode=function(e){let t=Le.encode(e),r=Ue.alloc(2);r.writeUInt16BE(t.byteLength);let n=Ue.concat([r,t]);return Le.streamEncode.bytes=n.byteLength,n};Le.streamEncode.bytes=0;Le.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.",i="Expected a function",a="Invalid `variable` option passed into `_.template`",s="__lodash_hash_undefined__",u=500,l="__lodash_placeholder__",f=1,d=2,E=4,p=1,h=2,A=1,m=2,S=4,w=8,y=16,_=32,B=64,D=128,j=256,q=512,F=30,P="...",L=800,M=16,V=1,W=2,G=3,z=1/0,X=9007199254740991,ie=17976931348623157e292,Se=NaN,we=4294967295,Ie=we-1,Ve=we>>>1,ue=[["ary",D],["bind",A],["bindKey",m],["curry",w],["curryRight",y],["flip",q],["partial",_],["partialRight",B],["rearg",j]],_e="[object Arguments]",He="[object Array]",Sr="[object AsyncFunction]",Ht="[object Boolean]",wt="[object Date]",ir="[object DOMException]",Gt="[object Error]",at="[object Function]",kt="[object GeneratorFunction]",it="[object Map]",bt="[object Number]",sr="[object Null]",et="[object Object]",Jt="[object Promise]",Zn="[object Proxy]",br="[object RegExp]",Tr="[object Set]",cr="[object String]",Mr="[object Symbol]",Sa="[object Undefined]",tn="[object WeakMap]",Ct="[object WeakSet]",lr="[object ArrayBuffer]",tt="[object DataView]",jr="[object Float32Array]",ba="[object Float64Array]",Ca="[object Int8Array]",_a="[object Int16Array]",Fa="[object Int32Array]",rs="[object Uint8Array]",Ia="[object Uint8ClampedArray]",Vs="[object Uint16Array]",Fi="[object Uint32Array]",ns=/\b__p \+= '';/g,Ao=/\b(__p \+=) '' \+/g,yo=/(__e\(.*?\)|\b__t\)) \+\n'';/g,So=/&(?:amp|lt|gt|quot|#39);/g,bo=/[&<>"']/g,Co=RegExp(So.source),_o=RegExp(bo.source),Fo=/<%-([\s\S]+?)%>/g,ju=/<%([\s\S]+?)%>/g,Io=/<%=([\s\S]+?)%>/g,qu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ku=/^\w*$/,Vu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gs=/[\\^$.*+?()[\]{}|]/g,Gu=RegExp(Gs.source),$a=/^\s+/,zu=/\s/,Yu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Wu=/\{\n\/\* \[wrapped with (.+)\] \*/,Xu=/,? & /,Ju=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Zu=/[()=,{}\[\]\/\s]/,Qu=/\\(\\)?/g,ec=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ii=/\w*$/,$o=/^[-+]0x[0-9a-f]+$/i,tc=/^0b[01]+$/i,rc=/^\[object .+?Constructor\]$/,nc=/^0o[0-7]+$/i,Do=/^(?:0|[1-9]\d*)$/,$i=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,gn=/($^)/,ic=/['\n\r\u2028\u2029\\]/g,zs="\\ud800-\\udfff",Pn="\\u0300-\\u036f",sc="\\ufe20-\\ufe2f",ac="\\u20d0-\\u20ff",Bo=Pn+sc+ac,Da="\\u2700-\\u27bf",Ro="a-z\\xdf-\\xf6\\xf8-\\xff",Ys="\\xac\\xb1\\xd7\\xf7",Zt="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",oc="\\u2000-\\u206f",uc=" \\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",Po="A-Z\\xc0-\\xd6\\xd8-\\xde",Di="\\ufe0e\\ufe0f",Cr=Ys+Zt+oc+uc,Kt="['\u2019]",cc="["+zs+"]",Ba="["+Cr+"]",_r="["+Bo+"]",Ra="\\d+",To="["+Da+"]",Oo="["+Ro+"]",Pa="[^"+zs+Cr+Ra+Da+Ro+Po+"]",Bi="\\ud83c[\\udffb-\\udfff]",Ta="(?:"+_r+"|"+Bi+")",xo="[^"+zs+"]",Oa="(?:\\ud83c[\\udde6-\\uddff]){2}",xa="[\\ud800-\\udbff][\\udc00-\\udfff]",rn="["+Po+"]",T="\\u200d",x="(?:"+Oo+"|"+Pa+")",H="(?:"+rn+"|"+Pa+")",Q="(?:"+Kt+"(?:d|ll|m|re|s|t|ve))?",de="(?:"+Kt+"(?:D|LL|M|RE|S|T|VE))?",ve=Ta+"?",Fe="["+Di+"]?",Re="(?:"+T+"(?:"+[xo,Oa,xa].join("|")+")"+Fe+ve+")*",Pt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Qt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Or=Fe+ve+Re,xr="(?:"+[To,Oa,xa].join("|")+")"+Or,Tn="(?:"+[xo+_r+"?",_r,Oa,xa,cc].join("|")+")",Ws=RegExp(Kt,"g"),nn=RegExp(_r,"g"),Nr=RegExp(Bi+"(?="+Bi+")|"+Tn+Or,"g"),Xs=RegExp([rn+"?"+Oo+"+"+Q+"(?="+[Ba,rn,"$"].join("|")+")",H+"+"+de+"(?="+[Ba,rn+x,"$"].join("|")+")",rn+"?"+x+"+"+Q,rn+"+"+de,Qt,Pt,Ra,xr].join("|"),"g"),Qn=RegExp("["+T+zs+Bo+Di+"]"),Na=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,xh=["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"],Nh=-1,Lt={};Lt[jr]=Lt[ba]=Lt[Ca]=Lt[_a]=Lt[Fa]=Lt[rs]=Lt[Ia]=Lt[Vs]=Lt[Fi]=!0,Lt[_e]=Lt[He]=Lt[lr]=Lt[Ht]=Lt[tt]=Lt[wt]=Lt[Gt]=Lt[at]=Lt[it]=Lt[bt]=Lt[et]=Lt[br]=Lt[Tr]=Lt[cr]=Lt[tn]=!1;var xt={};xt[_e]=xt[He]=xt[lr]=xt[tt]=xt[Ht]=xt[wt]=xt[jr]=xt[ba]=xt[Ca]=xt[_a]=xt[Fa]=xt[it]=xt[bt]=xt[et]=xt[br]=xt[Tr]=xt[cr]=xt[Mr]=xt[rs]=xt[Ia]=xt[Vs]=xt[Fi]=!0,xt[Gt]=xt[at]=xt[tn]=!1;var kh={\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"},Lh={"&":"&","<":"<",">":">",'"':""","'":"'"},Uh={"&":"&","<":"<",">":">",""":'"',"'":"'"},Hh={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mh=parseFloat,jh=parseInt,dl=typeof global=="object"&&global&&global.Object===Object&&global,qh=typeof self=="object"&&self&&self.Object===Object&&self,fr=dl||qh||Function("return this")(),lc=typeof Ou=="object"&&Ou&&!Ou.nodeType&&Ou,is=lc&&typeof tl=="object"&&tl&&!tl.nodeType&&tl,gl=is&&is.exports===lc,fc=gl&&dl.process,mn=function(){try{var re=is&&is.require&&is.require("util").types;return re||fc&&fc.binding&&fc.binding("util")}catch{}}(),ml=mn&&mn.isArrayBuffer,vl=mn&&mn.isDate,El=mn&&mn.isMap,wl=mn&&mn.isRegExp,Al=mn&&mn.isSet,yl=mn&&mn.isTypedArray;function sn(re,le,oe){switch(oe.length){case 0:return re.call(le);case 1:return re.call(le,oe[0]);case 2:return re.call(le,oe[0],oe[1]);case 3:return re.call(le,oe[0],oe[1],oe[2])}return re.apply(le,oe)}function Kh(re,le,oe,Te){for(var Ye=-1,pt=re==null?0:re.length;++Ye-1}function ka(re,le,oe){for(var Te=-1,Ye=re==null?0:re.length;++Te-1;);return oe}function _l(re,le){for(var oe=re.length;oe--&&Js(le,re[oe],0)>-1;);return oe}function Fl(re,le){for(var oe=re.length,Te=0;oe--;)re[oe]===le&&++Te;return Te}var vc=pe(kh),zh=pe(Lh);function Il(re){return"\\"+Hh[re]}function Yh(re,le){return re==null?e:re[le]}function as(re){return Qn.test(re)}function Wh(re){return Na.test(re)}function Xh(re){for(var le,oe=[];!(le=re.next()).done;)oe.push(le.value);return oe}function Ec(re){var le=-1,oe=Array(re.size);return re.forEach(function(Te,Ye){oe[++le]=[Ye,Te]}),oe}function kr(re,le){return function(oe){return re(le(oe))}}function Nn(re,le){for(var oe=-1,Te=re.length,Ye=0,pt=[];++oe-1}function wy(o,c){var v=this.__data__,C=Ul(v,o);return C<0?(++this.size,v.push([o,c])):v[C][1]=c,this}hs.prototype.clear=gy,hs.prototype.delete=my,hs.prototype.get=vy,hs.prototype.has=Ey,hs.prototype.set=wy;function ps(o){var c=-1,v=o==null?0:o.length;for(this.clear();++c=c?o:c)),o}function ni(o,c,v,C,O,U){var Y,Z=c&f,ne=c&d,ge=c&E;if(v&&(Y=O?v(o,C,O,U):v(o)),Y!==e)return Y;if(!Wt(o))return o;var me=Ze(o);if(me){if(Y=bS(o),!Z)return An(o,Y)}else{var Ee=Vr(o),$e=Ee==at||Ee==kt;if(ra(o))return J1(o,Z);if(Ee==et||Ee==_e||$e&&!O){if(Y=ne||$e?{}:mg(o),!Z)return ne?hS(o,xy(Y,o)):fS(o,I1(Y,o))}else{if(!xt[Ee])return O?o:{};Y=CS(o,Ee,Z)}}U||(U=new mi);var ke=U.get(o);if(ke)return ke;U.set(o,Y),Vg(o)?o.forEach(function(ze){Y.add(ni(ze,c,v,ze,o,U))}):qg(o)&&o.forEach(function(ze,lt){Y.set(lt,ni(ze,c,v,lt,o,U))});var Ge=ge?ne?Dp:$p:ne?Sn:Fr,st=me?e:Ge(o);return vn(st||o,function(ze,lt){st&&(lt=ze,ze=o[lt]),bc(Y,lt,ni(ze,c,v,lt,o,U))}),Y}function Ny(o){var c=Fr(o);return function(v){return $1(v,o,c)}}function $1(o,c,v){var C=v.length;if(o==null)return!C;for(o=Tt(o);C--;){var O=v[C],U=c[O],Y=o[O];if(Y===e&&!(O in o)||!U(Y))return!1}return!0}function D1(o,c,v){if(typeof o!="function")throw new wn(i);return Bc(function(){o.apply(e,v)},c)}function Cc(o,c,v,C){var O=-1,U=an,Y=!0,Z=o.length,ne=[],ge=c.length;if(!Z)return ne;v&&(c=te(c,qr(v))),C?(U=ka,Y=!1):c.length>=r&&(U=Ua,Y=!1,c=new Ma(c));e:for(;++OO?0:O+v),C=C===e||C>O?O:nt(C),C<0&&(C+=O),C=v>C?0:zg(C);v0&&v(Z)?c>1?Lr(Z,c-1,v,C,O):xn(O,Z):C||(O[O.length]=Z)}return O}var lp=ng(),P1=ng(!0);function Pi(o,c){return o&&lp(o,c,Fr)}function fp(o,c){return o&&P1(o,c,Fr)}function Ml(o,c){return On(c,function(v){return ws(o[v])})}function qa(o,c){c=ea(c,o);for(var v=0,C=c.length;o!=null&&vc}function Uy(o,c){return o!=null&&mt.call(o,c)}function Hy(o,c){return o!=null&&c in Tt(o)}function My(o,c,v){return o>=Kr(c,v)&&o=120&&me.length>=120)?new Ma(Y&&me):e}me=o[0];var Ee=-1,$e=Z[0];e:for(;++Ee-1;)Z!==o&&_t.call(Z,ne,1),_t.call(o,ne,1);return o}function q1(o,c){for(var v=o?c.length:0,C=v-1;v--;){var O=c[v];if(v==C||O!==U){var U=O;Es(O)?_t.call(o,O,1):yp(o,O)}}return o}function Ep(o,c){return o+se(b1()*(c-o+1))}function eS(o,c,v,C){for(var O=-1,U=mr(K((c-o)/(v||1)),0),Y=oe(U);U--;)Y[C?U:++O]=o,o+=v;return Y}function wp(o,c){var v="";if(!o||c<1||c>X)return v;do c%2&&(v+=o),c=se(c/2),c&&(o+=o);while(c);return v}function ot(o,c){return Np(wg(o,c,bn),o+"")}function tS(o){return F1(ru(o))}function rS(o,c){var v=ru(o);return Zl(v,ja(c,0,v.length))}function Ic(o,c,v,C){if(!Wt(o))return o;c=ea(c,o);for(var O=-1,U=c.length,Y=U-1,Z=o;Z!=null&&++OO?0:O+c),v=v>O?O:v,v<0&&(v+=O),O=c>v?0:v-c>>>0,c>>>=0;for(var U=oe(O);++C>>1,Y=o[U];Y!==null&&!Un(Y)&&(v?Y<=c:Y=r){var ge=c?null:mS(o);if(ge)return kn(ge);Y=!1,O=Ua,ne=new Ma}else ne=c?[]:Z;e:for(;++C=C?o:ii(o,c,v)}var X1=b||function(o){return fr.clearTimeout(o)};function J1(o,c){if(c)return o.slice();var v=o.length,C=Pl?Pl(v):new o.constructor(v);return o.copy(C),C}function _p(o){var c=new o.constructor(o.byteLength);return new Go(c).set(new Go(o)),c}function oS(o,c){var v=c?_p(o.buffer):o.buffer;return new o.constructor(v,o.byteOffset,o.byteLength)}function uS(o){var c=new o.constructor(o.source,Ii.exec(o));return c.lastIndex=o.lastIndex,c}function cS(o){return Sc?Tt(Sc.call(o)):{}}function Z1(o,c){var v=c?_p(o.buffer):o.buffer;return new o.constructor(v,o.byteOffset,o.length)}function Q1(o,c){if(o!==c){var v=o!==e,C=o===null,O=o===o,U=Un(o),Y=c!==e,Z=c===null,ne=c===c,ge=Un(c);if(!Z&&!ge&&!U&&o>c||U&&Y&&ne&&!Z&&!ge||C&&Y&&ne||!v&&ne||!O)return 1;if(!C&&!U&&!ge&&o=Z)return ne;var ge=v[C];return ne*(ge=="desc"?-1:1)}}return o.index-c.index}function eg(o,c,v,C){for(var O=-1,U=o.length,Y=v.length,Z=-1,ne=c.length,ge=mr(U-Y,0),me=oe(ne+ge),Ee=!C;++Z1?v[O-1]:e,Y=O>2?v[2]:e;for(U=o.length>3&&typeof U=="function"?(O--,U):e,Y&&un(v[0],v[1],Y)&&(U=O<3?e:U,O=1),c=Tt(c);++C-1?O[U?c[Y]:Y]:e}}function ag(o){return vs(function(c){var v=c.length,C=v,O=ri.prototype.thru;for(o&&c.reverse();C--;){var U=c[C];if(typeof U!="function")throw new wn(i);if(O&&!Y&&Xl(U)=="wrapper")var Y=new ri([],!0)}for(C=Y?C:v;++C1&&dt.reverse(),me&&neZ))return!1;var ge=U.get(o),me=U.get(c);if(ge&&me)return ge==c&&me==o;var Ee=-1,$e=!0,ke=v&h?new Ma:e;for(U.set(o,c),U.set(c,o);++Ee1?"& ":"")+c[C],c=c.join(v>2?", ":" "),o.replace(Yu,`{ /* [wrapped with `+c+`] */ `)}function FS(o){return Ze(o)||Ga(o)||!!(xl&&o&&o[xl])}function Es(o,c){var v=typeof o;return c=c??X,!!c&&(v=="number"||v!="symbol"&&Do.test(o))&&o>-1&&o%1==0&&o0){if(++c>=L)return arguments[0]}else c=0;return o.apply(e,arguments)}}function Zl(o,c){var v=-1,C=o.length,O=C-1;for(c=c===e?C:c;++v1?o[c-1]:e;return v=typeof v=="function"?(o.pop(),v):e,Rg(o,v)});function Pg(o){var c=k(o);return c.__chain__=!0,c}function k4(o,c){return c(o),o}function Ql(o,c){return c(o)}var L4=vs(function(o){var c=o.length,v=c?o[0]:0,C=this.__wrapped__,O=function(U){return cp(U,o)};return c>1||this.__actions__.length||!(C instanceof ft)||!Es(v)?this.thru(O):(C=C.slice(v,+v+(c?1:0)),C.__actions__.push({func:Ql,args:[O],thisArg:e}),new ri(C,this.__chain__).thru(function(U){return c&&!U.length&&U.push(e),U}))});function U4(){return Pg(this)}function H4(){return new ri(this.value(),this.__chain__)}function M4(){this.__values__===e&&(this.__values__=Gg(this.value()));var o=this.__index__>=this.__values__.length,c=o?e:this.__values__[this.__index__++];return{done:o,value:c}}function j4(){return this}function q4(o){for(var c,v=this;v instanceof Ll;){var C=_g(v);C.__index__=0,C.__values__=e,c?O.__wrapped__=C:c=C;var O=C;v=v.__wrapped__}return O.__wrapped__=o,c}function K4(){var o=this.__wrapped__;if(o instanceof ft){var c=o;return this.__actions__.length&&(c=new ft(this)),c=c.reverse(),c.__actions__.push({func:Ql,args:[kp],thisArg:e}),new ri(c,this.__chain__)}return this.thru(kp)}function V4(){return Y1(this.__wrapped__,this.__actions__)}var G4=Vl(function(o,c,v){mt.call(o,v)?++o[v]:ds(o,v,1)});function z4(o,c,v){var C=Ze(o)?Xe:ky;return v&&un(o,c,v)&&(c=e),C(o,qe(c,3))}function Y4(o,c){var v=Ze(o)?On:R1;return v(o,qe(c,3))}var W4=sg(Fg),X4=sg(Ig);function J4(o,c){return Lr(ef(o,c),1)}function Z4(o,c){return Lr(ef(o,c),z)}function Q4(o,c,v){return v=v===e?1:nt(v),Lr(ef(o,c),v)}function Tg(o,c){var v=Ze(o)?vn:Zs;return v(o,qe(c,3))}function Og(o,c){var v=Ze(o)?R:B1;return v(o,qe(c,3))}var eb=Vl(function(o,c,v){mt.call(o,v)?o[v].push(c):ds(o,v,[c])});function tb(o,c,v,C){o=yn(o)?o:ru(o),v=v&&!C?nt(v):0;var O=o.length;return v<0&&(v=mr(O+v,0)),af(o)?v<=O&&o.indexOf(c,v)>-1:!!O&&Js(o,c,v)>-1}var rb=ot(function(o,c,v){var C=-1,O=typeof c=="function",U=yn(o)?oe(o.length):[];return Zs(o,function(Y){U[++C]=O?sn(c,Y,v):_c(Y,c,v)}),U}),nb=Vl(function(o,c,v){ds(o,v,c)});function ef(o,c){var v=Ze(o)?te:k1;return v(o,qe(c,3))}function ib(o,c,v,C){return o==null?[]:(Ze(c)||(c=c==null?[]:[c]),v=C?e:v,Ze(v)||(v=v==null?[]:[v]),M1(o,c,v))}var sb=Vl(function(o,c,v){o[v?0:1].push(c)},function(){return[[],[]]});function ab(o,c,v){var C=Ze(o)?hc:bl,O=arguments.length<3;return C(o,qe(c,4),v,O,Zs)}function ob(o,c,v){var C=Ze(o)?y1:bl,O=arguments.length<3;return C(o,qe(c,4),v,O,B1)}function ub(o,c){var v=Ze(o)?On:R1;return v(o,nf(qe(c,3)))}function cb(o){var c=Ze(o)?F1:tS;return c(o)}function lb(o,c,v){(v?un(o,c,v):c===e)?c=1:c=nt(c);var C=Ze(o)?Py:rS;return C(o,c)}function fb(o){var c=Ze(o)?Ty:iS;return c(o)}function hb(o){if(o==null)return 0;if(yn(o))return af(o)?os(o):o.length;var c=Vr(o);return c==it||c==Tr?o.size:gp(o).length}function pb(o,c,v){var C=Ze(o)?Sl:sS;return v&&un(o,c,v)&&(c=e),C(o,qe(c,3))}var db=ot(function(o,c){if(o==null)return[];var v=c.length;return v>1&&un(o,c[0],c[1])?c=[]:v>2&&un(c[0],c[1],c[2])&&(c=[c[0]]),M1(o,Lr(c,1),[])}),tf=N||function(){return fr.Date.now()};function gb(o,c){if(typeof c!="function")throw new wn(i);return o=nt(o),function(){if(--o<1)return c.apply(this,arguments)}}function xg(o,c,v){return c=v?e:c,c=o&&c==null?o.length:c,gs(o,D,e,e,e,e,c)}function Ng(o,c){var v;if(typeof c!="function")throw new wn(i);return o=nt(o),function(){return--o>0&&(v=c.apply(this,arguments)),o<=1&&(c=e),v}}var Up=ot(function(o,c,v){var C=A;if(v.length){var O=Nn(v,eu(Up));C|=_}return gs(o,C,c,v,O)}),kg=ot(function(o,c,v){var C=A|m;if(v.length){var O=Nn(v,eu(kg));C|=_}return gs(c,C,o,v,O)});function Lg(o,c,v){c=v?e:c;var C=gs(o,w,e,e,e,e,e,c);return C.placeholder=Lg.placeholder,C}function Ug(o,c,v){c=v?e:c;var C=gs(o,y,e,e,e,e,e,c);return C.placeholder=Ug.placeholder,C}function Hg(o,c,v){var C,O,U,Y,Z,ne,ge=0,me=!1,Ee=!1,$e=!0;if(typeof o!="function")throw new wn(i);c=ai(c)||0,Wt(v)&&(me=!!v.leading,Ee="maxWait"in v,U=Ee?mr(ai(v.maxWait)||0,c):U,$e="trailing"in v?!!v.trailing:$e);function ke(or){var Ei=C,ys=O;return C=O=e,ge=or,Y=o.apply(ys,Ei),Y}function Ge(or){return ge=or,Z=Bc(lt,c),me?ke(or):Y}function st(or){var Ei=or-ne,ys=or-ge,sm=c-Ei;return Ee?Kr(sm,U-ys):sm}function ze(or){var Ei=or-ne,ys=or-ge;return ne===e||Ei>=c||Ei<0||Ee&&ys>=U}function lt(){var or=tf();if(ze(or))return dt(or);Z=Bc(lt,st(or))}function dt(or){return Z=e,$e&&C?ke(or):(C=O=e,Y)}function Hn(){Z!==e&&X1(Z),ge=0,C=ne=O=Z=e}function cn(){return Z===e?Y:dt(tf())}function Mn(){var or=tf(),Ei=ze(or);if(C=arguments,O=this,ne=or,Ei){if(Z===e)return Ge(ne);if(Ee)return X1(Z),Z=Bc(lt,c),ke(ne)}return Z===e&&(Z=Bc(lt,c)),Y}return Mn.cancel=Hn,Mn.flush=cn,Mn}var mb=ot(function(o,c){return D1(o,1,c)}),vb=ot(function(o,c,v){return D1(o,ai(c)||0,v)});function Eb(o){return gs(o,q)}function rf(o,c){if(typeof o!="function"||c!=null&&typeof c!="function")throw new wn(i);var v=function(){var C=arguments,O=c?c.apply(this,C):C[0],U=v.cache;if(U.has(O))return U.get(O);var Y=o.apply(this,C);return v.cache=U.set(O,Y)||U,Y};return v.cache=new(rf.Cache||ps),v}rf.Cache=ps;function nf(o){if(typeof o!="function")throw new wn(i);return function(){var c=arguments;switch(c.length){case 0:return!o.call(this);case 1:return!o.call(this,c[0]);case 2:return!o.call(this,c[0],c[1]);case 3:return!o.call(this,c[0],c[1],c[2])}return!o.apply(this,c)}}function wb(o){return Ng(2,o)}var Ab=aS(function(o,c){c=c.length==1&&Ze(c[0])?te(c[0],qr(qe())):te(Lr(c,1),qr(qe()));var v=c.length;return ot(function(C){for(var O=-1,U=Kr(C.length,v);++O=c}),Ga=O1(function(){return arguments}())?O1:function(o){return tr(o)&&mt.call(o,"callee")&&!Ol.call(o,"callee")},Ze=oe.isArray,xb=ml?qr(ml):qy;function yn(o){return o!=null&&sf(o.length)&&!ws(o)}function ar(o){return tr(o)&&yn(o)}function Nb(o){return o===!0||o===!1||tr(o)&&on(o)==Ht}var ra=Ot||Jp,kb=vl?qr(vl):Ky;function Lb(o){return tr(o)&&o.nodeType===1&&!Rc(o)}function Ub(o){if(o==null)return!0;if(yn(o)&&(Ze(o)||typeof o=="string"||typeof o.splice=="function"||ra(o)||tu(o)||Ga(o)))return!o.length;var c=Vr(o);if(c==it||c==Tr)return!o.size;if(Dc(o))return!gp(o).length;for(var v in o)if(mt.call(o,v))return!1;return!0}function Hb(o,c){return Fc(o,c)}function Mb(o,c,v){v=typeof v=="function"?v:e;var C=v?v(o,c):e;return C===e?Fc(o,c,e,v):!!C}function Mp(o){if(!tr(o))return!1;var c=on(o);return c==Gt||c==ir||typeof o.message=="string"&&typeof o.name=="string"&&!Rc(o)}function jb(o){return typeof o=="number"&&er(o)}function ws(o){if(!Wt(o))return!1;var c=on(o);return c==at||c==kt||c==Sr||c==Zn}function jg(o){return typeof o=="number"&&o==nt(o)}function sf(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=X}function Wt(o){var c=typeof o;return o!=null&&(c=="object"||c=="function")}function tr(o){return o!=null&&typeof o=="object"}var qg=El?qr(El):Gy;function qb(o,c){return o===c||dp(o,c,Rp(c))}function Kb(o,c,v){return v=typeof v=="function"?v:e,dp(o,c,Rp(c),v)}function Vb(o){return Kg(o)&&o!=+o}function Gb(o){if(DS(o))throw new Ye(n);return x1(o)}function zb(o){return o===null}function Yb(o){return o==null}function Kg(o){return typeof o=="number"||tr(o)&&on(o)==bt}function Rc(o){if(!tr(o)||on(o)!=et)return!1;var c=zo(o);if(c===null)return!0;var v=mt.call(c,"constructor")&&c.constructor;return typeof v=="function"&&v instanceof v&&jo.call(v)==np}var jp=wl?qr(wl):zy;function Wb(o){return jg(o)&&o>=-X&&o<=X}var Vg=Al?qr(Al):Yy;function af(o){return typeof o=="string"||!Ze(o)&&tr(o)&&on(o)==cr}function Un(o){return typeof o=="symbol"||tr(o)&&on(o)==Mr}var tu=yl?qr(yl):Wy;function Xb(o){return o===e}function Jb(o){return tr(o)&&Vr(o)==tn}function Zb(o){return tr(o)&&on(o)==Ct}var Qb=Wl(mp),e6=Wl(function(o,c){return o<=c});function Gg(o){if(!o)return[];if(yn(o))return af(o)?En(o):An(o);if(cs&&o[cs])return Xh(o[cs]());var c=Vr(o),v=c==it?Ec:c==Tr?kn:ru;return v(o)}function As(o){if(!o)return o===0?o:0;if(o=ai(o),o===z||o===-z){var c=o<0?-1:1;return c*ie}return o===o?o:0}function nt(o){var c=As(o),v=c%1;return c===c?v?c-v:c:0}function zg(o){return o?ja(nt(o),0,we):0}function ai(o){if(typeof o=="number")return o;if(Un(o))return Se;if(Wt(o)){var c=typeof o.valueOf=="function"?o.valueOf():o;o=Wt(c)?c+"":c}if(typeof o!="string")return o===0?o:+o;o=mc(o);var v=tc.test(o);return v||nc.test(o)?jh(o.slice(2),v?2:8):$o.test(o)?Se:+o}function Yg(o){return Ti(o,Sn(o))}function t6(o){return o?ja(nt(o),-X,X):o===0?o:0}function $t(o){return o==null?"":Ln(o)}var r6=Zo(function(o,c){if(Dc(c)||yn(c)){Ti(c,Fr(c),o);return}for(var v in c)mt.call(c,v)&&bc(o,v,c[v])}),Wg=Zo(function(o,c){Ti(c,Sn(c),o)}),of=Zo(function(o,c,v,C){Ti(c,Sn(c),o,C)}),n6=Zo(function(o,c,v,C){Ti(c,Fr(c),o,C)}),i6=vs(cp);function s6(o,c){var v=Jo(o);return c==null?v:I1(v,c)}var a6=ot(function(o,c){o=Tt(o);var v=-1,C=c.length,O=C>2?c[2]:e;for(O&&un(c[0],c[1],O)&&(C=1);++v1),U}),Ti(o,Dp(o),v),C&&(v=ni(v,f|d|E,vS));for(var O=c.length;O--;)yp(v,c[O]);return v});function C6(o,c){return Jg(o,nf(qe(c)))}var _6=vs(function(o,c){return o==null?{}:Zy(o,c)});function Jg(o,c){if(o==null)return{};var v=te(Dp(o),function(C){return[C]});return c=qe(c),j1(o,v,function(C,O){return c(C,O[0])})}function F6(o,c,v){c=ea(c,o);var C=-1,O=c.length;for(O||(O=1,o=e);++Cc){var C=o;o=c,c=C}if(v||o%1||c%1){var O=b1();return Kr(o+O*(c-o+Mh("1e-"+((O+"").length-1))),c)}return Ep(o,c)}var k6=Qo(function(o,c,v){return c=c.toLowerCase(),o+(v?em(c):c)});function em(o){return Vp($t(o).toLowerCase())}function tm(o){return o=$t(o),o&&o.replace($i,vc).replace(nn,"")}function L6(o,c,v){o=$t(o),c=Ln(c);var C=o.length;v=v===e?C:ja(nt(v),0,C);var O=v;return v-=c.length,v>=0&&o.slice(v,O)==c}function U6(o){return o=$t(o),o&&_o.test(o)?o.replace(bo,zh):o}function H6(o){return o=$t(o),o&&Gu.test(o)?o.replace(Gs,"\\$&"):o}var M6=Qo(function(o,c,v){return o+(v?"-":"")+c.toLowerCase()}),j6=Qo(function(o,c,v){return o+(v?" ":"")+c.toLowerCase()}),q6=ig("toLowerCase");function K6(o,c,v){o=$t(o),c=nt(c);var C=c?os(o):0;if(!c||C>=c)return o;var O=(c-C)/2;return Yl(se(O),v)+o+Yl(K(O),v)}function V6(o,c,v){o=$t(o),c=nt(c);var C=c?os(o):0;return c&&C>>0,v?(o=$t(o),o&&(typeof c=="string"||c!=null&&!jp(c))&&(c=Ln(c),!c&&as(o))?ta(En(o),0,v):o.split(c,v)):[]}var Z6=Qo(function(o,c,v){return o+(v?" ":"")+Vp(c)});function Q6(o,c,v){return o=$t(o),v=v==null?0:ja(nt(v),0,o.length),c=Ln(c),o.slice(v,v+c.length)==c}function eC(o,c,v){var C=k.templateSettings;v&&un(o,c,v)&&(c=e),o=$t(o),c=of({},c,C,fg);var O=of({},c.imports,C.imports,fg),U=Fr(O),Y=La(O,U),Z,ne,ge=0,me=c.interpolate||gn,Ee="__p += '",$e=Ho((c.escape||gn).source+"|"+me.source+"|"+(me===Io?ec:gn).source+"|"+(c.evaluate||gn).source+"|$","g"),ke="//# sourceURL="+(mt.call(c,"sourceURL")?(c.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Nh+"]")+` `;o.replace($e,function(ze,lt,dt,Hn,cn,Mn){return dt||(dt=Hn),Ee+=o.slice(ge,Mn).replace(ic,Il),lt&&(Z=!0,Ee+=`' + __e(`+lt+`) + '`),cn&&(ne=!0,Ee+=`'; `+cn+`; __p += '`),dt&&(Ee+=`' + ((__t = (`+dt+`)) == null ? '' : __t) + '`),ge=Mn+ze.length,ze}),Ee+=`'; `;var Ge=mt.call(c,"variable")&&c.variable;if(!Ge)Ee=`with (obj) { `+Ee+` } `;else if(Zu.test(Ge))throw new Ye(a);Ee=(ne?Ee.replace(ns,""):Ee).replace(Ao,"$1").replace(yo,"$1;"),Ee="function("+(Ge||"obj")+`) { `+(Ge?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(Z?", __e = _.escape":"")+(ne?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+Ee+`return __p }`;var st=nm(function(){return pt(U,ke+"return "+Ee).apply(e,Y)});if(st.source=Ee,Mp(st))throw st;return st}function tC(o){return $t(o).toLowerCase()}function rC(o){return $t(o).toUpperCase()}function nC(o,c,v){if(o=$t(o),o&&(v||c===e))return mc(o);if(!o||!(c=Ln(c)))return o;var C=En(o),O=En(c),U=ko(C,O),Y=_l(C,O)+1;return ta(C,U,Y).join("")}function iC(o,c,v){if(o=$t(o),o&&(v||c===e))return o.slice(0,Uo(o)+1);if(!o||!(c=Ln(c)))return o;var C=En(o),O=_l(C,En(c))+1;return ta(C,0,O).join("")}function sC(o,c,v){if(o=$t(o),o&&(v||c===e))return o.replace($a,"");if(!o||!(c=Ln(c)))return o;var C=En(o),O=ko(C,En(c));return ta(C,O).join("")}function aC(o,c){var v=F,C=P;if(Wt(c)){var O="separator"in c?c.separator:O;v="length"in c?nt(c.length):v,C="omission"in c?Ln(c.omission):C}o=$t(o);var U=o.length;if(as(o)){var Y=En(o);U=Y.length}if(v>=U)return o;var Z=v-os(C);if(Z<1)return C;var ne=Y?ta(Y,0,Z).join(""):o.slice(0,Z);if(O===e)return ne+C;if(Y&&(Z+=ne.length-Z),jp(O)){if(o.slice(Z).search(O)){var ge,me=ne;for(O.global||(O=Ho(O.source,$t(Ii.exec(O))+"g")),O.lastIndex=0;ge=O.exec(me);)var Ee=ge.index;ne=ne.slice(0,Ee===e?Z:Ee)}}else if(o.indexOf(Ln(O),Z)!=Z){var $e=ne.lastIndexOf(O);$e>-1&&(ne=ne.slice(0,$e))}return ne+C}function oC(o){return o=$t(o),o&&Co.test(o)?o.replace(So,Dl):o}var uC=Qo(function(o,c,v){return o+(v?" ":"")+c.toUpperCase()}),Vp=ig("toUpperCase");function rm(o,c,v){return o=$t(o),c=v?e:c,c===e?Wh(o)?Qh(o):pc(o):o.match(c)||[]}var nm=ot(function(o,c){try{return sn(o,e,c)}catch(v){return Mp(v)?v:new Ye(v)}}),cC=vs(function(o,c){return vn(c,function(v){v=Oi(v),ds(o,v,Up(o[v],o))}),o});function lC(o){var c=o==null?0:o.length,v=qe();return o=c?te(o,function(C){if(typeof C[1]!="function")throw new wn(i);return[v(C[0]),C[1]]}):[],ot(function(C){for(var O=-1;++OX)return[];var v=we,C=Kr(o,we);c=qe(c),o-=we;for(var O=gc(C,c);++v0||c<0)?new ft(v):(o<0?v=v.takeRight(-o):o&&(v=v.drop(o)),c!==e&&(c=nt(c),v=c<0?v.dropRight(-c):v.take(c-o)),v)},ft.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},ft.prototype.toArray=function(){return this.take(we)},Pi(ft.prototype,function(o,c){var v=/^(?:filter|find|map|reject)|While$/.test(c),C=/^(?:head|last)$/.test(c),O=k[C?"take"+(c=="last"?"Right":""):c],U=C||/^find/.test(c);O&&(k.prototype[c]=function(){var Y=this.__wrapped__,Z=C?[1]:arguments,ne=Y instanceof ft,ge=Z[0],me=ne||Ze(Y),Ee=function(lt){var dt=O.apply(k,xn([lt],Z));return C&&$e?dt[0]:dt};me&&v&&typeof ge=="function"&&ge.length!=1&&(ne=me=!1);var $e=this.__chain__,ke=!!this.__actions__.length,Ge=U&&!$e,st=ne&&!ke;if(!U&&me){Y=st?Y:new ft(this);var ze=o.apply(Y,Z);return ze.__actions__.push({func:Ql,args:[Ee],thisArg:e}),new ri(ze,$e)}return Ge&&st?o.apply(this,Z):(ze=this.thru(Ee),Ge?C?ze.value()[0]:ze.value():ze)})}),vn(["pop","push","shift","sort","splice","unshift"],function(o){var c=Mo[o],v=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",C=/^(?:pop|shift)$/.test(o);k.prototype[o]=function(){var O=arguments;if(C&&!this.__chain__){var U=this.value();return c.apply(Ze(U)?U:[],O)}return this[v](function(Y){return c.apply(Ze(Y)?Y:[],O)})}}),Pi(ft.prototype,function(o,c){var v=k[c];if(v){var C=v.name+"";mt.call(Xo,C)||(Xo[C]=[]),Xo[C].push({name:c,func:v})}}),Xo[Gl(e,m).name]=[{name:"wrapper",func:e}],ft.prototype.clone=oy,ft.prototype.reverse=uy,ft.prototype.value=cy,k.prototype.at=L4,k.prototype.chain=U4,k.prototype.commit=H4,k.prototype.next=M4,k.prototype.plant=q4,k.prototype.reverse=K4,k.prototype.toJSON=k.prototype.valueOf=k.prototype.value=V4,k.prototype.first=k.prototype.head,cs&&(k.prototype[cs]=j4),k},ti=ep();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(fr._=ti,define(function(){return ti})):is?((is.exports=ti)._=ti,lc._=ti):fr._=ti}).call(Ou)});var vh=ye((Xx,iw)=>{"use strict";var W9=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])},_0=class e extends Error{constructor(t,r,n){super(t),W9(this,e.prototype),this.name="GrammarError",this.location=r,n===void 0&&(n=[]),this.diagnostics=n,this.stage=null,this.problems=[["error",t,r,n]]}toString(){let t=super.toString();this.location&&(t+=` at `,this.location.source!==void 0&&this.location.source!==null&&(t+=`${this.location.source}:`),t+=`${this.location.start.line}:${this.location.start.column}`);for(let r of this.diagnostics)t+=` from `,r.location.source!==void 0&&r.location.source!==null&&(t+=`${r.location.source}:`),t+=`${r.location.start.line}:${r.location.start.column}: ${r.message}`;return t}format(t){let r=t.map(({source:a,text:s})=>({source:a,text:s.split(/\r\n|\n|\r/g)}));function n(a,s,u=""){let l="",f=r.find(({source:E})=>E===a.source),d=a.start;if(f){let E=a.end,p=f.text[d.line-1],A=(d.line===E.line?E.column:p.length+1)-d.column||1;u&&(l+=` note: ${u}`),l+=` --> ${a.source}:${d.line}:${d.column} ${"".padEnd(s)} | ${d.line.toString().padStart(s)} | ${p} ${"".padEnd(s)} | ${"".padEnd(d.column-1)}${"".padEnd(A,"^")}`}else l+=` at ${a.source}:${d.line}:${d.column}`,u&&(l+=`: ${u}`);return l}function i(a,s,u,l=[]){let f;u?f=l.reduce((E,{location:p})=>Math.max(E,p.start.line),u.start.line):f=Math.max.apply(null,l.map(E=>E.location.start.line)),f=f.toString().length;let d=`${a}: ${s}`;u&&(d+=n(u,f));for(let E of l)d+=n(E.location,f,E.message);return d}return this.problems.filter(a=>a[0]!=="info").map(a=>i(...a)).join(` `)}};iw.exports=_0});var hi=ye((Jx,sw)=>{"use strict";var X9={build(e){function t(s,...u){return e[s.type](s,...u)}function r(){}function n(s,...u){return t(s.expression,...u)}function i(s){return function(u,...l){u[s].forEach(f=>t(f,...l))}}let a={grammar(s,...u){s.topLevelInitializer&&t(s.topLevelInitializer,...u),s.initializer&&t(s.initializer,...u),s.rules.forEach(l=>t(l,...u))},top_level_initializer:r,initializer:r,rule:n,named:n,choice:i("alternatives"),action:n,sequence:i("elements"),labeled:n,text:n,simple_and:n,simple_not:n,optional:n,zero_or_more:n,one_or_more:n,group:n,semantic_and:r,semantic_not:r,rule_ref:r,literal:r,class:r,any:r};return Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||(e[s]=a[s])}),t}};sw.exports=X9});var Ea=ye((Zx,ow)=>{"use strict";var J9=hi(),aw={findRule(e,t){for(let r=0;r{"use strict";var Z9={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};uw.exports=Z9});var I0=ye((eN,cw)=>{"use strict";var Q9=hi(),eB=Ea(),tB=vh(),al=1,Eo=0,ol=-1;function Eh(e){function t(s){return s.match=Eo}function r(s){return a(s.expression),s.match=al}function n(s){return s.match=a(s.expression)}function i(s,u){let l=s.length,f=0,d=0;for(let E=0;E0?ol:Eo}let a=Q9.build({rule(s){let u,l=0;if(typeof s.match>"u"){s.match=Eo;do if(u=s.match,s.match=a(s.expression),++l>6)throw new tB("Infinity cycle detected when trying to evaluate node match result",s.location);while(u!==s.match)}return s.match},named:n,choice(s){return s.match=i(s.alternatives,!0)},action:n,sequence(s){return s.match=i(s.elements,!1)},labeled:n,text:n,simple_and:n,simple_not(s){return s.match=-a(s.expression)},optional:r,zero_or_more:r,one_or_more:n,group:n,semantic_and:t,semantic_not:t,rule_ref(s){let u=eB.findRule(e,s.name);return s.match=a(u)},literal(s){let u=s.value.length===0?al:Eo;return s.match=u},class(s){let u=s.parts.length===0?ol:Eo;return s.match=u},any:t});a(e)}Eh.ALWAYS_MATCH=al;Eh.SOMETIMES_MATCH=Eo;Eh.NEVER_MATCH=ol;cw.exports=Eh});var fw=ye((tN,lw)=>{"use strict";var rB=Ea(),Be=F0(),nB=hi(),{ALWAYS_MATCH:ku,SOMETIMES_MATCH:$0,NEVER_MATCH:D0}=I0();function iB(e){let t=[],r=[],n=[],i=[];function a(y){let _=t.indexOf(y);return _===-1?t.push(y)-1:_}function s(y){let _={value:y.parts,inverted:y.inverted,ignoreCase:y.ignoreCase},B=JSON.stringify(_),D=r.findIndex(j=>JSON.stringify(j)===B);return D===-1?r.push(_)-1:D}function u(y){let _=JSON.stringify(y),B=n.findIndex(D=>JSON.stringify(D)===_);return B===-1?n.push(y)-1:B}function l(y,_,B){let D={predicate:y,params:_,body:B.code,location:B.codeLocation},j=JSON.stringify(D),q=i.findIndex(F=>JSON.stringify(F)===j);return q===-1?i.push(D)-1:q}function f(y){let _={};return Object.keys(y).forEach(B=>{_[B]=y[B]}),_}function d(y,..._){return y.concat(..._)}function E(y,_,B,D){return y===ku?B:y===D0?D:_.concat([B.length,D.length],B,D)}function p(y,_){return y.concat([_.length],_)}function h(y,_,B,D){let j=Object.keys(B).map(q=>D-B[q]);return[Be.CALL,y,_,j.length].concat(j)}function A(y,_,B){let D=y.match|0;return d([Be.PUSH_CURR_POS],[Be.SILENT_FAILS_ON],w(y,{sp:B.sp+1,env:f(B.env),action:null}),[Be.SILENT_FAILS_OFF],E(_?-D:D,[_?Be.IF_ERROR:Be.IF_NOT_ERROR],d([Be.POP],[_?Be.POP:Be.POP_CURR_POS],[Be.PUSH_UNDEFINED]),d([Be.POP],[_?Be.POP_CURR_POS:Be.POP],[Be.PUSH_FAILED])))}function m(y,_,B){let D=l(!0,Object.keys(B.env),y);return d([Be.UPDATE_SAVED_POS],h(D,0,B.env,B.sp),E(y.match|0,[Be.IF],d([Be.POP],_?[Be.PUSH_FAILED]:[Be.PUSH_UNDEFINED]),d([Be.POP],_?[Be.PUSH_UNDEFINED]:[Be.PUSH_FAILED])))}function S(y){return p([Be.WHILE_NOT_ERROR],d([Be.APPEND],y))}let w=nB.build({grammar(y){y.rules.forEach(w),y.literals=t,y.classes=r,y.expectations=n,y.functions=i},rule(y){y.bytecode=w(y.expression,{sp:-1,env:{},pluck:[],action:null})},named(y,_){let B=y.match|0,D=B===D0?null:u({type:"rule",value:y.name});return d([Be.SILENT_FAILS_ON],w(y.expression,_),[Be.SILENT_FAILS_OFF],E(B,[Be.IF_ERROR],[Be.FAIL,D],[]))},choice(y,_){function B(D,j){let q=D[0].match|0,F=w(D[0],{sp:j.sp,env:f(j.env),action:null});return q===ku?F:d(F,D.length>1?E($0,[Be.IF_ERROR],d([Be.POP],B(D.slice(1),j)),[]):[])}return B(y.alternatives,_)},action(y,_){let B=f(_.env),D=y.expression.type!=="sequence"||y.expression.elements.length===0,j=w(y.expression,{sp:_.sp+(D?1:0),env:B,action:y}),q=y.expression.match|0,F=D&&q!==D0?l(!1,Object.keys(B),y):null;return D?d([Be.PUSH_CURR_POS],j,E(q,[Be.IF_NOT_ERROR],d([Be.LOAD_SAVED_POS,1],h(F,1,B,_.sp+2)),[]),[Be.NIP]):j},sequence(y,_){function B(D,j){if(D.length>0){let q=y.elements.length-D.length+1;return d(w(D[0],{sp:j.sp,env:j.env,pluck:j.pluck,action:null}),E(D[0].match|0,[Be.IF_NOT_ERROR],B(D.slice(1),{sp:j.sp+1,env:j.env,pluck:j.pluck,action:j.action}),d(q>1?[Be.POP_N,q]:[Be.POP],[Be.POP_CURR_POS],[Be.PUSH_FAILED])))}else{if(j.pluck.length>0)return d([Be.PLUCK,y.elements.length+1,j.pluck.length],j.pluck.map(q=>j.sp-q));if(j.action){let q=l(!1,Object.keys(j.env),j.action);return d([Be.LOAD_SAVED_POS,y.elements.length],h(q,y.elements.length+1,j.env,j.sp))}else return d([Be.WRAP,y.elements.length],[Be.NIP])}}return d([Be.PUSH_CURR_POS],B(y.elements,{sp:_.sp+1,env:_.env,pluck:[],action:_.action}))},labeled(y,_){let B=_.env,D=y.label,j=_.sp+1;return D&&(B=f(_.env),_.env[y.label]=j),y.pick&&_.pluck.push(j),w(y.expression,{sp:_.sp,env:B,action:null})},text(y,_){return d([Be.PUSH_CURR_POS],w(y.expression,{sp:_.sp+1,env:f(_.env),action:null}),E(y.match|0,[Be.IF_NOT_ERROR],d([Be.POP],[Be.TEXT]),[Be.NIP]))},simple_and(y,_){return A(y.expression,!1,_)},simple_not(y,_){return A(y.expression,!0,_)},optional(y,_){return d(w(y.expression,{sp:_.sp,env:f(_.env),action:null}),E(-(y.expression.match|0),[Be.IF_ERROR],d([Be.POP],[Be.PUSH_NULL]),[]))},zero_or_more(y,_){let B=w(y.expression,{sp:_.sp+1,env:f(_.env),action:null});return d([Be.PUSH_EMPTY_ARRAY],B,S(B),[Be.POP])},one_or_more(y,_){let B=w(y.expression,{sp:_.sp+1,env:f(_.env),action:null});return d([Be.PUSH_EMPTY_ARRAY],B,E(y.expression.match|0,[Be.IF_NOT_ERROR],d(S(B),[Be.POP]),d([Be.POP],[Be.POP],[Be.PUSH_FAILED])))},group(y,_){return w(y.expression,{sp:_.sp,env:f(_.env),action:null})},semantic_and(y,_){return m(y,!1,_)},semantic_not(y,_){return m(y,!0,_)},rule_ref(y){return[Be.RULE,rB.indexOfRule(e,y.name)]},literal(y){if(y.value.length>0){let _=y.match|0,D=_===$0||_===ku&&!y.ignoreCase?a(y.ignoreCase?y.value.toLowerCase():y.value):null,j=_!==ku?u({type:"literal",value:y.value,ignoreCase:y.ignoreCase}):null;return E(_,y.ignoreCase?[Be.MATCH_STRING_IC,D]:[Be.MATCH_STRING,D],y.ignoreCase?[Be.ACCEPT_N,y.value.length]:[Be.ACCEPT_STRING,D],[Be.FAIL,j])}return[Be.PUSH_EMPTY_STRING]},class(y){let _=y.match|0,B=_===$0?s(y):null,D=_!==ku?u({type:"class",value:y.parts,inverted:y.inverted,ignoreCase:y.ignoreCase}):null;return E(_,[Be.MATCH_CHAR_CLASS,B],[Be.ACCEPT_N,1],[Be.FAIL,D])},any(y){let _=y.match|0,B=_!==ku?u({type:"any"}):null;return E(_,[Be.MATCH_ANY],[Be.ACCEPT_N,1],[Be.FAIL,B])}});w(e)}lw.exports=iB});var pw=ye((rN,hw)=>{"use strict";var B0=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 i=this.sp;if(r(),n){let a=this.sp;if(this.sp=i,n(),a!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+t+": Branches of a condition can't move the stack pointer differently (before: "+i+", after then: "+a+", after else: "+this.sp+").")}}checkedLoop(t,r){let n=this.sp;if(r(),n!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+t+": Body of a loop can't move the stack pointer (before: "+n+", after: "+this.sp+").")}};hw.exports=B0});var R0=ye((nN,dw)=>{"use strict";dw.exports="2.0.1"});var gw=ye(wh=>{"use strict";function js(e){return e.charCodeAt(0).toString(16).toUpperCase()}wh.hex=js;function sB(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"+js(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+js(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+js(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+js(t))}wh.stringEscape=sB;function aB(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"+js(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+js(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+js(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+js(t))}wh.regexpClassEscape=aB});var Ew=ye(vw=>{var mw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");vw.encode=function(e){if(0<=e&&e{var oB=Ew(),ww=5,Aw=1<>>=ww,i>0&&(n|=cB),r+=oB.encode(n);while(i>0);return r}});var yh=ye(Aa=>{function fB(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}Aa.getArg=fB;var Cw=function(){return!("__proto__"in Object.create(null))}();function _w(e){return e}function hB(e){return Fw(e)?"$"+e:e}Aa.toSetString=Cw?_w:hB;function pB(e){return Fw(e)?e.slice(1):e}Aa.fromSetString=Cw?_w:pB;function Fw(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 bw(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function dB(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=bw(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:bw(e.name,t.name)}Aa.compareByGeneratedPositionsInflated=dB;var P0="http:",ul=`${P0}//host`;function Iw(e){return t=>{let r=cl(t),n=T0(t),i=new URL(t,n);e(i);let a=i.toString();return r==="absolute"?a:r==="scheme-relative"?a.slice(P0.length):r==="path-absolute"?a.slice(ul.length):O0(n,a)}}function wa(e,t){return new URL(e,t).toString()}function gB(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function T0(e){let t=e.split("..").length-1,r=gB("p",e),n=`${ul}/`;for(let i=0;i0&&!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 vB=Iw(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),Ah=Iw(e=>{});Aa.normalize=Ah;function EB(e,t){let r=cl(t),n=cl(e);if(e=vB(e),r==="absolute")return wa(t,void 0);if(n==="absolute")return wa(t,e);if(r==="scheme-relative")return Ah(t);if(n==="scheme-relative")return wa(t,wa(e,ul)).slice(P0.length);if(r==="path-absolute")return Ah(t);if(n==="path-absolute")return wa(t,wa(e,ul)).slice(ul.length);let i=T0(t+e),a=wa(t,wa(e,i));return O0(i,a)}Aa.join=EB;function wB(e,t){let r=AB(e,t);return typeof r=="string"?r:Ah(t)}Aa.relative=wB;function AB(e,t){if(cl(e)!==cl(t))return null;let n=T0(e+t),i=new URL(e,n),a=new URL(t,n);try{new URL("",a.toString())}catch{return null}return a.protocol!==i.protocol||a.user!==i.user||a.password!==i.password||a.hostname!==i.hostname||a.port!==i.port?null:O0(i,a)}});var Dw=ye($w=>{var x0=class e{constructor(){this._array=[],this._set=new Map}static fromArray(t,r){let n=new e;for(let i=0,a=t.length;i=0)return r;throw new Error('"'+t+'" is not in the set.')}at(t){if(t>=0&&t{var Bw=yh();function yB(e,t){let r=e.generatedLine,n=t.generatedLine,i=e.generatedColumn,a=t.generatedColumn;return n>r||n==r&&a>=i||Bw.compareByGeneratedPositionsInflated(e,t)<=0}var N0=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){yB(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(Bw.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};Rw.MappingList=N0});var k0=ye(Tw=>{var ll=Sw(),gr=yh(),Sh=Dw().ArraySet,SB=Pw().MappingList,bh=class e{constructor(t){t||(t={}),this._file=gr.getArg(t,"file",null),this._sourceRoot=gr.getArg(t,"sourceRoot",null),this._skipValidation=gr.getArg(t,"skipValidation",!1),this._sources=new Sh,this._names=new Sh,this._mappings=new SB,this._sourcesContents=null}static fromSourceMap(t){let r=t.sourceRoot,n=new e({file:t.file,sourceRoot:r});return t.eachMapping(function(i){let a={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(a.source=i.source,r!=null&&(a.source=gr.relative(r,a.source)),a.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(a.name=i.name)),n.addMapping(a)}),t.sources.forEach(function(i){let a=i;r!=null&&(a=gr.relative(r,i)),n._sources.has(a)||n._sources.add(a);let s=t.sourceContentFor(i);s!=null&&n.setSourceContent(i,s)}),n}addMapping(t){let r=gr.getArg(t,"generated"),n=gr.getArg(t,"original",null),i=gr.getArg(t,"source",null),a=gr.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,i,a),i!=null&&(i=String(i),this._sources.has(i)||this._sources.add(i)),a!=null&&(a=String(a),this._names.has(a)||this._names.add(a)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n&&n.line,originalColumn:n&&n.column,source:i,name:a})}setSourceContent(t,r){let n=t;this._sourceRoot!=null&&(n=gr.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[gr.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[gr.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))}applySourceMap(t,r,n){let i=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.`);i=t.file}let a=this._sourceRoot;a!=null&&(i=gr.relative(a,i));let s=this._mappings.toArray().length>0?new Sh:this._sources,u=new Sh;this._mappings.unsortedForEach(function(l){if(l.source===i&&l.originalLine!=null){let E=t.originalPositionFor({line:l.originalLine,column:l.originalColumn});E.source!=null&&(l.source=E.source,n!=null&&(l.source=gr.join(n,l.source)),a!=null&&(l.source=gr.relative(a,l.source)),l.originalLine=E.line,l.originalColumn=E.column,E.name!=null&&(l.name=E.name))}let f=l.source;f!=null&&!s.has(f)&&s.add(f);let d=l.name;d!=null&&!u.has(d)&&u.add(d)},this),this._sources=s,this._names=u,t.sources.forEach(function(l){let f=t.sourceContentFor(l);f!=null&&(n!=null&&(l=gr.join(n,l)),a!=null&&(l=gr.relative(a,l)),this.setSourceContent(l,f))},this)}_validateMapping(t,r,n,i){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&&!i)){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:i}))}}_serializeMappings(){let t=0,r=1,n=0,i=0,a=0,s=0,u="",l,f,d,E,p=this._mappings.toArray();for(let h=0,A=p.length;h0){if(!gr.compareByGeneratedPositionsInflated(f,p[h-1]))continue;l+=","}l+=ll.encode(f.generatedColumn-t),t=f.generatedColumn,f.source!=null&&(E=this._sources.indexOf(f.source),l+=ll.encode(E-s),s=E,l+=ll.encode(f.originalLine-1-i),i=f.originalLine-1,l+=ll.encode(f.originalColumn-n),n=f.originalColumn,f.name!=null&&(d=this._names.indexOf(f.name),l+=ll.encode(d-a),a=d)),u+=l}return u}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=gr.relative(r,n));let i=gr.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,i)?this._sourcesContents[i]: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())}};bh.prototype._version=3;Tw.SourceMapGenerator=bh});var xw=ye(Ow=>{var bB=k0().SourceMapGenerator,Ch=yh(),CB=/(\r?\n)/,_B=10,Lu="$$$isSourceNode$$$",L0=class e{constructor(t,r,n,i,a){this.children=[],this.sourceContents={},this.line=t??null,this.column=r??null,this.source=n??null,this.name=a??null,this[Lu]=!0,i!=null&&this.add(i)}static fromStringWithSourceMap(t,r,n){let i=new e,a=t.split(CB),s=0,u=function(){let h=m(),A=m()||"";return h+A;function m(){return s=0;r--)this.prepend(t[r]);else if(t[Lu]||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,i=this.children.length;n0){for(r=[],n=0;n{U0.SourceMapGenerator=k0().SourceMapGenerator;U0.SourceNode=xw().SourceNode});var Hw=ye((pN,Uw)=>{"use strict";var FB=Ea(),It=F0(),IB=pw(),$B=R0(),{stringEscape:Xn,regexpClassEscape:H0}=gw(),{SourceNode:pi}=Nw();function Lw(e,t,r){let n=t.start.line,i=t.start.column-1,a=e.split(` `);return a.length===1?new pi(n,i,t.source,e,r):new pi(null,null,t.source,a.map((s,u)=>new pi(n+u,u===0?i:0,t.source,u===a.length-1?s:[s,` `],r)))}function kw(e,t,r,n,i){return r?new pi(null,null,r.source,[e,Lw(t,r,i),new pi(r.end.line,r.end.column-1,r.source,n)]):new pi(null,null,null,[e,t,n])}function DB(e,t){function r(m){return m instanceof pi?m:m.replace(/^(.+)$/gm," $1")}function n(m){return"peg$c"+m}function i(m){return"peg$r"+m}function a(m){return"peg$e"+m}function s(m){return"peg$f"+m}function u(m){return"peg$parse"+m}function l(){function m(_){return'"'+Xn(_)+'"'}function S(_){return"/^["+(_.inverted?"^":"")+_.value.map(B=>Array.isArray(B)?H0(B[0])+"-"+H0(B[1]):H0(B)).join("")+"]/"+(_.ignoreCase?"i":"")}function w(_){switch(_.type){case"rule":return'peg$otherExpectation("'+Xn(_.value)+'")';case"literal":return'peg$literalExpectation("'+Xn(_.value)+'", '+_.ignoreCase+")";case"class":return"peg$classExpectation(["+_.value.map(D=>Array.isArray(D)?'["'+Xn(D[0])+'", "'+Xn(D[1])+'"]':'"'+Xn(D)+'"').join(", ")+"], "+_.inverted+", "+_.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(_)+")")}}function y(_,B){return kw(` var ${s(B)} = function(${_.params.join(", ")}) {`,_.body,_.location,"};")}return new pi(null,null,t.grammarSource,[e.literals.map((_,B)=>" var "+n(B)+" = "+m(_)+";").concat("",e.classes.map((_,B)=>" var "+i(B)+" = "+S(_)+";")).concat("",e.expectations.map((_,B)=>" var "+a(B)+" = "+w(_)+";")).concat("").join(` `),e.functions.map(y)])}function f(m,S){let w=[];return w.push(""),t.trace&&w.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+m+","," location: peg$computeLocation(startPos, startPos)","});",""),t.cache&&(w.push("var key = peg$currPos * "+e.rules.length+" + "+S+";","var cached = peg$resultsCache[key];","","if (cached) {"," peg$currPos = cached.nextPos;",""),t.trace&&w.push("if (cached.result !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+m+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+m+","," location: peg$computeLocation(startPos, startPos)"," });","}",""),w.push(" return cached.result;","}","")),w}function d(m,S){let w=[];return t.cache&&w.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+S+" };"),t.trace&&w.push("","if ("+S+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+m+","," result: "+S+","," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+m+","," location: peg$computeLocation(startPos, startPos)"," });","}"),w.push("","return "+S+";"),w}function E(m){let S=[],w=new IB(m.name,"s","var");function y(B){let D=0,j=B.length,q=[],F;function P(V,W){let G=W+3,z=B[D+G-2],X=B[D+G-1],ie,Se;w.checkedIf(D,()=>{D+=G,ie=y(B.slice(D,D+z)),D+=z},X>0?()=>{Se=y(B.slice(D,D+X)),D+=X}:null),q.push("if ("+V+") {"),q.push(...ie.map(r)),X>0&&(q.push("} else {"),q.push(...Se.map(r))),q.push("}")}function L(V){let G=B[D+2-1],z;w.checkedLoop(D,()=>{D+=2,z=y(B.slice(D,D+G)),D+=G}),q.push("while ("+V+") {"),q.push(...z.map(r)),q.push("}")}function M(){let W=B[D+4-1],G=s(B[D+1])+"("+B.slice(D+4,D+4+W).map(z=>w.index(z)).join(", ")+")";w.pop(B[D+2]),q.push(w.push(G)),D+=4+W}for(;Dw.index(z)).join(", ")} ]`,w.pop(B[D+1]),q.push(w.push(F)),D+=G;break}case It.IF:P(w.top(),0);break;case It.IF_ERROR:P(w.top()+" === peg$FAILED",0);break;case It.IF_NOT_ERROR:P(w.top()+" !== peg$FAILED",0);break;case It.WHILE_NOT_ERROR:L(w.top()+" !== peg$FAILED");break;case It.MATCH_ANY:P("input.length > peg$currPos",0);break;case It.MATCH_STRING:P(e.literals[B[D+1]].length>1?"input.substr(peg$currPos, "+e.literals[B[D+1]].length+") === "+n(B[D+1]):"input.charCodeAt(peg$currPos) === "+e.literals[B[D+1]].charCodeAt(0),1);break;case It.MATCH_STRING_IC:P("input.substr(peg$currPos, "+e.literals[B[D+1]].length+").toLowerCase() === "+n(B[D+1]),1);break;case It.MATCH_CHAR_CLASS:P(i(B[D+1])+".test(input.charAt(peg$currPos))",1);break;case It.ACCEPT_N:q.push(w.push(B[D+1]>1?"input.substr(peg$currPos, "+B[D+1]+")":"input.charAt(peg$currPos)")),q.push(B[D+1]>1?"peg$currPos += "+B[D+1]+";":"peg$currPos++;"),D+=2;break;case It.ACCEPT_STRING:q.push(w.push(n(B[D+1]))),q.push(e.literals[B[D+1]].length>1?"peg$currPos += "+e.literals[B[D+1]].length+";":"peg$currPos++;"),D+=2;break;case It.FAIL:q.push(w.push("peg$FAILED")),q.push("if (peg$silentFails === 0) { peg$fail("+a(B[D+1])+"); }"),D+=2;break;case It.LOAD_SAVED_POS:q.push("peg$savedPos = "+w.index(B[D+1])+";"),D+=2;break;case It.UPDATE_SAVED_POS:q.push("peg$savedPos = peg$currPos;"),D++;break;case It.CALL:M();break;case It.RULE:q.push(w.push(u(e.rules[B[D+1]].name)+"()")),D+=2;break;case It.SILENT_FAILS_ON:q.push("peg$silentFails++;"),D++;break;case It.SILENT_FAILS_OFF:q.push("peg$silentFails--;"),D++;break;default:throw new Error("Invalid opcode: "+B[D]+".")}return q}let _=y(m.bytecode);return S.push(kw(" function ",u(m.name),m.nameLocation,`() { `,m.name)),t.trace&&S.push(" var startPos = peg$currPos;"),S.push(r(w.defines())),S.push(...f('"'+Xn(m.name)+'"',FB.indexOfRule(e,m.name)).map(r)),S.push(..._.map(r)),S.push(...d('"'+Xn(m.name)+'"',w.result()).map(r)),S.push("}"),S}function p(m){return m.codeLocation?Lw(m.code,m.codeLocation,"$"+m.type):m.code}function h(){let m=[];e.topLevelInitializer&&(m.push(p(e.topLevelInitializer)),m.push("")),m.push("function peg$subclass(child, parent) {"," function C() { this.constructor = child; }"," C.prototype = parent.prototype;"," child.prototype = new C();","}","","function peg$SyntaxError(message, expected, found, location) {"," var self = Error.call(this, message);"," // istanbul ignore next Check is a necessary evil to support older environments"," if (Object.setPrototypeOf) {"," Object.setPrototypeOf(self, peg$SyntaxError.prototype);"," }"," self.expected = expected;"," self.found = found;"," self.location = location;",' self.name = "SyntaxError";'," return self;","}","","peg$subclass(peg$SyntaxError, Error);","","function peg$padEnd(str, targetLength, padString) {",' padString = padString || " ";'," if (str.length > targetLength) { return str; }"," targetLength -= str.length;"," padString += padString.repeat(targetLength);"," return str + padString.slice(0, targetLength);","}","","peg$SyntaxError.prototype.format = function(sources) {",' var str = "Error: " + this.message;'," if (this.location) {"," var src = null;"," var k;"," for (k = 0; k < sources.length; k++) {"," if (sources[k].source === this.location.source) {"," src = sources[k].text.split(/\\r\\n|\\n|\\r/g);"," break;"," }"," }"," var s = this.location.start;",' var loc = this.location.source + ":" + s.line + ":" + s.column;'," if (src) {"," var e = this.location.end;",` var filler = peg$padEnd("", s.line.toString().length, ' ');`," var line = src[s.line - 1];"," var last = s.line === e.line ? e.column : line.length + 1;"," var hatLen = (last - s.column) || 1;",' str += "\\n --> " + loc + "\\n"',' + filler + " |\\n"',' + s.line + " | " + line + "\\n"',` + filler + " | " + peg$padEnd("", s.column - 1, ' ')`,' + peg$padEnd("", hatLen, "^");'," } else {",' str += "\\n at " + loc;'," }"," }"," return str;","};","","peg$SyntaxError.buildMessage = function(expected, found) {"," var DESCRIBE_EXPECTATION_FNS = {"," literal: function(expectation) {",' return "\\"" + literalEscape(expectation.text) + "\\"";'," },",""," class: function(expectation) {"," var escapedParts = expectation.parts.map(function(part) {"," return Array.isArray(part)",' ? classEscape(part[0]) + "-" + classEscape(part[1])'," : classEscape(part);"," });","",' return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";'," },",""," any: function() {",' return "any character";'," },",""," end: function() {",' return "end of input";'," },",""," other: function(expectation) {"," return expectation.description;"," }"," };",""," function hex(ch) {"," return ch.charCodeAt(0).toString(16).toUpperCase();"," }",""," function literalEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/"/g, "\\\\\\"")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function classEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/\\]/g, "\\\\]")',' .replace(/\\^/g, "\\\\^")',' .replace(/-/g, "\\\\-")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function describeExpectation(expectation) {"," return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);"," }",""," function describeExpected(expected) {"," var descriptions = expected.map(describeExpectation);"," var i, j;",""," descriptions.sort();",""," if (descriptions.length > 0) {"," for (i = 1, j = 1; i < descriptions.length; i++) {"," if (descriptions[i - 1] !== descriptions[i]) {"," descriptions[j] = descriptions[i];"," j++;"," }"," }"," descriptions.length = j;"," }",""," switch (descriptions.length) {"," case 1:"," return descriptions[0];",""," case 2:",' return descriptions[0] + " or " + descriptions[1];',""," default:",' return descriptions.slice(0, -1).join(", ")',' + ", or "'," + descriptions[descriptions.length - 1];"," }"," }",""," function describeFound(found) {",' return found ? "\\"" + literalEscape(found) + "\\"" : "end of input";'," }","",' return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";',"};",""),t.trace&&m.push("function peg$DefaultTracer() {"," this.indentLevel = 0;","}","","peg$DefaultTracer.prototype.trace = function(event) {"," var that = this;",""," function log(event) {"," function repeat(string, n) {",' var result = "", i;',""," for (i = 0; i < n; i++) {"," result += string;"," }",""," return result;"," }",""," function pad(string, length) {",' return string + repeat(" ", length - string.length);'," }","",' if (typeof console === "object") {'," console.log(",' event.location.start.line + ":" + event.location.start.column + "-"',' + event.location.end.line + ":" + event.location.end.column + " "',' + pad(event.type, 10) + " "',' + repeat(" ", that.indentLevel) + event.rule'," );"," }"," }",""," switch (event.type) {",' case "rule.enter":'," log(event);"," this.indentLevel++;"," break;","",' case "rule.match":'," this.indentLevel--;"," log(event);"," break;","",' case "rule.fail":'," this.indentLevel--;"," log(event);"," break;",""," default:",' throw new Error("Invalid event type: " + event.type + ".");'," }","};","");let S="{ "+t.allowedStartRules.map(y=>y+": "+u(y)).join(", ")+" }",w=u(t.allowedStartRules[0]);return m.push("function peg$parse(input, options) {"," options = options !== undefined ? options : {};",""," var peg$FAILED = {};"," var peg$source = options.grammarSource;",""," var peg$startRuleFunctions = "+S+";"," var peg$startRuleFunction = "+w+";","",l(),""," var peg$currPos = 0;"," var peg$savedPos = 0;"," var peg$posDetailsCache = [{ line: 1, column: 1 }];"," var peg$maxFailPos = 0;"," var peg$maxFailExpected = [];"," var peg$silentFails = 0;",""),t.cache&&m.push(" var peg$resultsCache = {};",""),t.trace&&m.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),m.push(" var peg$result;","",' if ("startRule" in options) {'," if (!(options.startRule in peg$startRuleFunctions)) {",` throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");`," }",""," peg$startRuleFunction = peg$startRuleFunctions[options.startRule];"," }",""," function text() {"," return input.substring(peg$savedPos, peg$currPos);"," }",""," function offset() {"," return peg$savedPos;"," }",""," function range() {"," return {"," source: peg$source,"," start: peg$savedPos,"," end: peg$currPos"," };"," }",""," function location() {"," return peg$computeLocation(peg$savedPos, peg$currPos);"," }",""," function expected(description, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildStructuredError("," [peg$otherExpectation(description)],"," input.substring(peg$savedPos, peg$currPos),"," location"," );"," }",""," function error(message, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildSimpleError(message, location);"," }",""," function peg$literalExpectation(text, ignoreCase) {",' return { type: "literal", text: text, ignoreCase: ignoreCase };'," }",""," function peg$classExpectation(parts, inverted, ignoreCase) {",' return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };'," }",""," function peg$anyExpectation() {",' return { type: "any" };'," }",""," function peg$endExpectation() {",' return { type: "end" };'," }",""," function peg$otherExpectation(description) {",' return { type: "other", description: description };'," }",""," function peg$computePosDetails(pos) {"," var details = peg$posDetailsCache[pos];"," var p;",""," if (details) {"," return details;"," } else {"," p = pos - 1;"," while (!peg$posDetailsCache[p]) {"," p--;"," }",""," details = peg$posDetailsCache[p];"," details = {"," line: details.line,"," column: details.column"," };",""," while (p < pos) {"," if (input.charCodeAt(p) === 10) {"," details.line++;"," details.column = 1;"," } else {"," details.column++;"," }",""," p++;"," }",""," peg$posDetailsCache[pos] = details;",""," return details;"," }"," }",""," function peg$computeLocation(startPos, endPos) {"," var startPosDetails = peg$computePosDetails(startPos);"," var endPosDetails = peg$computePosDetails(endPos);",""," return {"," source: peg$source,"," start: {"," offset: startPos,"," line: startPosDetails.line,"," column: startPosDetails.column"," },"," end: {"," offset: endPos,"," line: endPosDetails.line,"," column: endPosDetails.column"," }"," };"," }",""," function peg$fail(expected) {"," if (peg$currPos < peg$maxFailPos) { return; }",""," if (peg$currPos > peg$maxFailPos) {"," peg$maxFailPos = peg$currPos;"," peg$maxFailExpected = [];"," }",""," peg$maxFailExpected.push(expected);"," }",""," function peg$buildSimpleError(message, location) {"," return new peg$SyntaxError(message, null, null, location);"," }",""," function peg$buildStructuredError(expected, found, location) {"," return new peg$SyntaxError("," peg$SyntaxError.buildMessage(expected, found),"," expected,"," found,"," location"," );"," }",""),e.rules.forEach(y=>{m.push(...E(y).map(r)),m.push("")}),e.initializer&&(m.push(p(e.initializer)),m.push("")),m.push(" peg$result = peg$startRuleFunction();",""," if (peg$result !== peg$FAILED && peg$currPos === input.length) {"," return peg$result;"," } else {"," if (peg$result !== peg$FAILED && peg$currPos < input.length) {"," peg$fail(peg$endExpectation());"," }",""," throw peg$buildStructuredError("," peg$maxFailExpected,"," peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,"," peg$maxFailPos < input.length"," ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)"," : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)"," );"," }","}"),new pi(null,null,t.grammarSource,m.map(y=>y instanceof pi?y:y+` `))}function A(m){function S(){return[`// Generated by Peggy ${$B}.`,"//","// https://peggyjs.org/"]}function w(){return t.trace?["{"," SyntaxError: peg$SyntaxError,"," DefaultTracer: peg$DefaultTracer,"," parse: peg$parse","}"].join(` `):["{"," SyntaxError: peg$SyntaxError,"," parse: peg$parse","}"].join(` `)}let _={bare(){return[...S(),"(function() {",' "use strict";',"",m,"",r("return "+w()+";"),"})()"]},commonjs(){let B=Object.keys(t.dependencies),D=S();return D.push("",'"use strict";',""),B.length>0&&(B.forEach(j=>{D.push("var "+j+' = require("'+Xn(t.dependencies[j])+'");')}),D.push("")),D.push(m,"","module.exports = "+w()+";"),D},es(){let B=Object.keys(t.dependencies),D=S();return D.push(""),B.length>0&&(B.forEach(j=>{D.push("import "+j+' from "'+Xn(t.dependencies[j])+'";')}),D.push("")),D.push(m,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),D},amd(){let B=Object.keys(t.dependencies),j="["+B.map(F=>t.dependencies[F]).map(F=>'"'+Xn(F)+'"').join(", ")+"]",q=B.join(", ");return[...S(),"define("+j+", function("+q+") {",' "use strict";',"",m,"",r("return "+w()+";"),"});"]},globals(){return[...S(),"(function(root) {",' "use strict";',"",m,"",r("root."+t.exportVar+" = "+w()+";"),"})(this);"]},umd(){let B=Object.keys(t.dependencies),D=B.map(L=>t.dependencies[L]),j="["+D.map(L=>'"'+Xn(L)+'"').join(", ")+"]",q=D.map(L=>'require("'+Xn(L)+'")').join(", "),F=B.join(", "),P=S();return P.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+j+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+q+");"),t.exportVar!==null&&P.push(" } else {"," root."+t.exportVar+" = factory();"),P.push(" }","})(this, function("+F+") {",' "use strict";',"",m,"",r("return "+w()+";"),"});"),P}}[t.format]();return new pi(null,null,t.grammarSource,_.map(B=>B instanceof pi?B:B+` `))}e.code=A(h())}Uw.exports=DB});var jw=ye((dN,Mw)=>{"use strict";var BB=Ea(),RB=hi();function PB(e,t,r){function n(s){return s.type==="rule"&&s.expression.type==="rule_ref"}function i(s,u,l){RB.build({rule_ref(d){d.name===u&&(d.name=l,r.info(`Proxy rule "${u}" replaced by the rule "${l}"`,d.location,[{message:"This rule will be used",location:BB.findRule(s,l).nameLocation}]))}})(s)}let a=[];e.rules.forEach((s,u)=>{n(s)&&(i(e,s.name,s.expression.name),t.allowedStartRules.indexOf(s.name)===-1&&a.push(u))}),a.reverse(),a.forEach(s=>{e.rules.splice(s,1)})}Mw.exports=PB});var Kw=ye((gN,qw)=>{"use strict";var TB=hi();function OB(e,t,r){function n(s){let u={};return Object.keys(s).forEach(l=>{u[l]=s[l]}),u}function i(s,u){a(s.expression,n(u))}let a=TB.build({rule(s){a(s.expression,{})},choice(s,u){s.alternatives.forEach(l=>{a(l,n(u))})},action:i,labeled(s,u){let l=s.label;l&&Object.prototype.hasOwnProperty.call(u,l)&&r.error(`Label "${s.label}" is already defined`,s.labelLocation,[{message:"Original label location",location:u[l]}]),a(s.expression,u),u[s.label]=s.labelLocation},text:i,simple_and:i,simple_not:i,optional:i,zero_or_more:i,one_or_more:i,group:i});a(e)}qw.exports=OB});var Gw=ye((mN,Vw)=>{"use strict";var xB=hi();function NB(e,t,r){let n={};xB.build({rule(a){if(Object.prototype.hasOwnProperty.call(n,a.name)){r.error(`Rule "${a.name}" is already defined`,a.nameLocation,[{message:"Original rule location",location:n[a.name]}]);return}n[a.name]=a.nameLocation}})(e)}Vw.exports=NB});var Ww=ye((vN,Yw)=>{"use strict";var zw=Ea(),kB=hi();function LB(e,t,r){let n=[],i=[],a=kB.build({rule(s){n.push(s.name),a(s.expression),n.pop()},sequence(s){s.elements.every(u=>(a(u),!zw.alwaysConsumesOnSuccess(e,u)))},rule_ref(s){i.push(s);let u=zw.findRule(e,s.name);if(n.indexOf(s.name)!==-1){n.push(s.name),r.error("Possible infinite loop when parsing (left recursion: "+n.join(" -> ")+")",u.nameLocation,i.map((l,f,d)=>({message:f+1!==d.length?`Step ${f+1}: call of the rule "${l.name}" without input consumption`:`Step ${f+1}: call itself without input consumption - left recursion`,location:l.location})));return}u&&a(u),i.pop()}});a(e)}Yw.exports=LB});var Zw=ye((EN,Jw)=>{"use strict";var Xw=Ea(),UB=hi();function HB(e,t,r){UB.build({zero_or_more(i){Xw.alwaysConsumesOnSuccess(e,i.expression)||r.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",i.location)},one_or_more(i){Xw.alwaysConsumesOnSuccess(e,i.expression)||r.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",i.location)}})(e)}Jw.exports=HB});var eA=ye((wN,Qw)=>{"use strict";var MB=Ea(),jB=hi();function qB(e,t,r){jB.build({rule_ref(i){MB.findRule(e,i.name)||r.error(`Rule "${i.name}" is not defined`,i.location)}})(e)}Qw.exports=qB});var rA=ye((AN,tA)=>{"use strict";var KB=hi();function VB(e,t,r){let n=KB.build({action(i){n(i.expression,i)},labeled(i,a){i.pick&&a&&r.error('"@" cannot be used with an action block',i.labelLocation,[{message:"Action block location",location:a.codeLocation}]),n(i.expression)}});n(e)}tA.exports=VB});var iA=ye((yN,nA)=>{"use strict";var GB=vh(),M0=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(){}},j0=class{constructor(t){this._callbacks=new M0(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new GB(...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}};nA.exports=j0});var sA=ye((exports,module)=>{"use strict";var generateBytecode=fw(),generateJS=Hw(),inferenceMatchResult=I0(),removeProxyRules=jw(),reportDuplicateLabels=Kw(),reportDuplicateRules=Gw(),reportInfiniteRecursion=Ww(),reportInfiniteRepetition=Zw(),reportUndefinedRules=eA(),reportIncorrectPlucking=rA(),Session=iA(),visitor=hi();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 oA=ye((SN,aA)=>{"use strict";var zB={$:"text","&":"simple_and","!":"simple_not"},YB={"?":"optional","*":"zero_or_more","+":"one_or_more"},WB={"&":"semantic_and","!":"semantic_not"};function XB(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function ya(e,t,r,n){var i=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(i,ya.prototype),i.expected=t,i.found=r,i.location=n,i.name="SyntaxError",i}XB(ya,Error);function q0(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}ya.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var r=null,n;for(n=0;n `+a+` `+u+` | `+i.line+" | "+l+` `+u+" | "+q0("",i.column-1," ")+q0("",d,"^")}else t+=` at `+a}return t};ya.buildMessage=function(e,t){var r={literal:function(f){return'"'+i(f.text)+'"'},class:function(f){var d=f.parts.map(function(E){return Array.isArray(E)?a(E[0])+"-"+a(E[1]):a(E)});return"["+(f.inverted?"^":"")+d.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(f){return f.description}};function n(f){return f.charCodeAt(0).toString(16).toUpperCase()}function i(f){return f.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(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function a(f){return f.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(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function s(f){return r[f.type](f)}function u(f){var d=f.map(s),E,p;if(d.sort(),d.length>0){for(E=1,p=1;E0?{type:"choice",alternatives:[b].concat(N),location:zt()}:b},Qn=function(b,N){return N!==null?{type:"action",expression:b,code:N[0],codeLocation:N[1],location:zt()}:b},Na=function(b,N){return N.length>0||b.type==="labeled"&&b.pick?{type:"sequence",elements:[b].concat(N),location:zt()}:b},xh=function(b,N,J){return J.type.startsWith("semantic_")&&pc('"@" cannot be used on a semantic predicate',b),{type:"labeled",label:N!==null?N[0]:null,labelLocation:N!==null?N[1]:b,pick:!0,expression:J,location:zt()}},Nh=function(b,N){return{type:"labeled",label:b[0],labelLocation:b[1],expression:N,location:zt()}},Lt=function(){return zt()},xt=function(b){return Yo.indexOf(b[0])>=0&&pc(`Label can't be a reserved word "${b[0]}"`,b[1]),b},kh=function(b,N){return{type:zB[b],expression:N,location:zt()}},Lh=function(b,N){return{type:YB[N],expression:b,location:zt()}},Uh=function(b){return b.type==="labeled"||b.type==="sequence"?{type:"group",expression:b,location:zt()}:b},Hh=function(b){return{type:"rule_ref",name:b[0],location:zt()}},Mh=function(b,N){return{type:WB[b],code:N[0],codeLocation:N[1],location:zt()}},jh=function(b,N){return[b+N.join(""),zt()]},dl=function(b,N){return{type:"literal",value:b,ignoreCase:N!==null,location:zt()}},qh=function(b){return b.join("")},fr=function(b){return b.join("")},lc=function(b,N,J){return{type:"class",parts:N.filter(K=>K!==""),inverted:b!==null,ignoreCase:J!==null,location:zt()}},is=function(b,N){return b.charCodeAt(0)>N.charCodeAt(0)&&pc("Invalid character range: "+hc()+"."),[b,N]},gl=function(){return""},fc=function(){return"\0"},mn=function(){return"\b"},ml=function(){return"\f"},vl=function(){return` `},El=function(){return"\r"},wl=function(){return" "},Al=function(){return"\v"},yl=function(b){return String.fromCharCode(parseInt(b,16))},sn=function(b){return String.fromCharCode(parseInt(b,16))},Kh=function(){return{type:"any",location:zt()}},vn=function(b){return[b,zt()]},R=0,Xe=0,On=[{line:1,column:1}],an=0,ka=[],te=0,xn;if("startRule"in t){if(!(t.startRule in i))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');a=i[t.startRule]}function hc(){return e.substring(Xe,R)}function y1(){return Xe}function Sl(){return{source:n,start:Xe,end:R}}function zt(){return ss(Xe,R)}function S1(b,N){throw N=N!==void 0?N:ss(Xe,R),Cl([ei(b)],e.substring(Xe,R),N)}function pc(b,N){throw N=N!==void 0?N:ss(Xe,R),bl(b,N)}function Me(b,N){return{type:"literal",text:b,ignoreCase:N}}function hr(b,N,J){return{type:"class",parts:b,inverted:N,ignoreCase:J}}function Js(){return{type:"any"}}function Vh(){return{type:"end"}}function ei(b){return{type:"other",description:b}}function dc(b){var N=On[b],J;if(N)return N;for(J=b-1;!On[J];)J--;for(N=On[J],N={line:N.line,column:N.column};Jan&&(an=R,ka=[]),ka.push(b))}function bl(b,N){return new ya(b,null,null,N)}function Cl(b,N,J){return new ya(ya.buildMessage(b,N),b,N,J)}function No(){var b,N,J,K,se,ce,Ot,er;if(b=R,N=_t(),J=R,K=gc(),K!==r?(se=_t(),J=K):(R=J,J=r),J===r&&(J=null),K=R,se=Gh(),se!==r?(ce=_t(),K=se):(R=K,K=r),K===r&&(K=null),se=[],ce=R,Ot=mc(),Ot!==r?(er=_t(),ce=Ot):(R=ce,ce=r),ce!==r)for(;ce!==r;)se.push(ce),ce=R,Ot=mc(),Ot!==r?(er=_t(),ce=Ot):(R=ce,ce=r);else se=r;return se!==r?(Xe=b,b=Tn(J,K,se)):(R=b,b=r),b}function gc(){var b,N,J,K,se;return b=R,e.charCodeAt(R)===123?(N=s,R++):(N=r,te===0&&pe(Fi)),N!==r?(J=mt(),J!==r?(e.charCodeAt(R)===125?(K=u,R++):(K=r,te===0&&pe(ns)),K!==r?(se=cs(),se!==r?(Xe=b,b=Ws(J)):(R=b,b=r)):(R=b,b=r)):(R=b,b=r)):(R=b,b=r),b}function Gh(){var b,N,J;return b=R,N=mt(),N!==r?(J=cs(),J!==r?(Xe=b,b=nn(N)):(R=b,b=r)):(R=b,b=r),b}function mc(){var b,N,J,K,se,ce,Ot,er;return b=R,N=Uo(),N!==r?(J=_t(),K=R,se=ti(),se!==r?(ce=_t(),K=se):(R=K,K=r),K===r&&(K=null),e.charCodeAt(R)===61?(se=l,R++):(se=r,te===0&&pe(Ao)),se!==r?(ce=_t(),Ot=qr(),Ot!==r?(er=cs(),er!==r?(Xe=b,b=Nr(N,K,Ot)):(R=b,b=r)):(R=b,b=r)):(R=b,b=r)):(R=b,b=r),b}function qr(){var b,N,J,K,se,ce,Ot,er;if(b=R,N=La(),N!==r){for(J=[],K=R,se=_t(),e.charCodeAt(R)===47?(ce=f,R++):(ce=r,te===0&&pe(yo)),ce!==r?(Ot=_t(),er=La(),er!==r?K=er:(R=K,K=r)):(R=K,K=r);K!==r;)J.push(K),K=R,se=_t(),e.charCodeAt(R)===47?(ce=f,R++):(ce=r,te===0&&pe(yo)),ce!==r?(Ot=_t(),er=La(),er!==r?K=er:(R=K,K=r)):(R=K,K=r);Xe=b,b=Xs(N,J)}else R=b,b=r;return b}function La(){var b,N,J,K,se;return b=R,N=Ua(),N!==r?(J=R,K=_t(),se=mt(),se!==r?J=se:(R=J,J=r),J===r&&(J=null),Xe=b,b=Qn(N,J)):(R=b,b=r),b}function Ua(){var b,N,J,K,se,ce;if(b=R,N=ko(),N!==r){for(J=[],K=R,se=_t(),ce=ko(),ce!==r?K=ce:(R=K,K=r);K!==r;)J.push(K),K=R,se=_t(),ce=ko(),ce!==r?K=ce:(R=K,K=r);Xe=b,b=Na(N,J)}else R=b,b=r;return b}function ko(){var b,N,J,K;return b=R,N=_l(),N!==r?(J=Fl(),J===r&&(J=null),K=vc(),K!==r?(Xe=b,b=xh(N,J,K)):(R=b,b=r)):(R=b,b=r),b===r&&(b=R,N=Fl(),N!==r?(J=_t(),K=vc(),K!==r?(Xe=b,b=Nh(N,K)):(R=b,b=r)):(R=b,b=r),b===r&&(b=vc())),b}function _l(){var b,N;return b=R,e.charCodeAt(R)===64?(N=d,R++):(N=r,te===0&&pe(So)),N!==r&&(Xe=b,N=Lt()),b=N,b}function Fl(){var b,N,J,K;return b=R,N=Uo(),N!==r?(J=_t(),e.charCodeAt(R)===58?(K=E,R++):(K=r,te===0&&pe(bo)),K!==r?(Xe=b,b=xt(N)):(R=b,b=r)):(R=b,b=r),b}function vc(){var b,N,J,K;return b=R,N=zh(),N!==r?(J=_t(),K=Il(),K!==r?(Xe=b,b=kh(N,K)):(R=b,b=r)):(R=b,b=r),b===r&&(b=Il()),b}function zh(){var b;return e.charCodeAt(R)===36?(b=p,R++):(b=r,te===0&&pe(Co)),b===r&&(e.charCodeAt(R)===38?(b=h,R++):(b=r,te===0&&pe(_o)),b===r&&(e.charCodeAt(R)===33?(b=A,R++):(b=r,te===0&&pe(Fo)))),b}function Il(){var b,N,J,K;return b=R,N=as(),N!==r?(J=_t(),K=Yh(),K!==r?(Xe=b,b=Lh(N,K)):(R=b,b=r)):(R=b,b=r),b===r&&(b=as()),b}function Yh(){var b;return e.charCodeAt(R)===63?(b=m,R++):(b=r,te===0&&pe(ju)),b===r&&(e.charCodeAt(R)===42?(b=S,R++):(b=r,te===0&&pe(Io)),b===r&&(e.charCodeAt(R)===43?(b=w,R++):(b=r,te===0&&pe(qu)))),b}function as(){var b,N,J,K,se,ce;return b=ep(),b===r&&(b=oe(),b===r&&(b=jo(),b===r&&(b=Wh(),b===r&&(b=Xh(),b===r&&(b=R,e.charCodeAt(R)===40?(N=y,R++):(N=r,te===0&&pe(Ku)),N!==r?(J=_t(),K=qr(),K!==r?(se=_t(),e.charCodeAt(R)===41?(ce=_,R++):(ce=r,te===0&&pe(Vu)),ce!==r?(Xe=b,b=Uh(K)):(R=b,b=r)):(R=b,b=r)):(R=b,b=r)))))),b}function Wh(){var b,N,J,K,se,ce,Ot,er;return b=R,N=Uo(),N!==r?(J=R,te++,K=R,se=_t(),ce=R,Ot=ti(),Ot!==r?(er=_t(),Ot=[Ot,er],ce=Ot):(R=ce,ce=r),ce===r&&(ce=null),e.charCodeAt(R)===61?(Ot=l,R++):(Ot=r,te===0&&pe(Ao)),Ot!==r?(se=[se,ce,Ot],K=se):(R=K,K=r),te--,K===r?J=void 0:(R=J,J=r),J!==r?(Xe=b,b=Hh(N)):(R=b,b=r)):(R=b,b=r),b}function Xh(){var b,N,J,K;return b=R,N=Ec(),N!==r?(J=_t(),K=mt(),K!==r?(Xe=b,b=Mh(N,K)):(R=b,b=r)):(R=b,b=r),b}function Ec(){var b;return e.charCodeAt(R)===38?(b=h,R++):(b=r,te===0&&pe(_o)),b===r&&(e.charCodeAt(R)===33?(b=A,R++):(b=r,te===0&&pe(Fo))),b}function kr(){var b;return e.length>R?(b=e.charAt(R),R++):(b=r,te===0&&pe(Gs)),b}function Nn(){var b,N;return te++,e.charCodeAt(R)===9?(b=B,R++):(b=r,te===0&&pe($a)),b===r&&(e.charCodeAt(R)===11?(b=D,R++):(b=r,te===0&&pe(zu)),b===r&&(e.charCodeAt(R)===12?(b=j,R++):(b=r,te===0&&pe(Yu)),b===r&&(e.charCodeAt(R)===32?(b=q,R++):(b=r,te===0&&pe(Wu)),b===r&&(e.charCodeAt(R)===160?(b=F,R++):(b=r,te===0&&pe(Xu)),b===r&&(e.charCodeAt(R)===65279?(b=P,R++):(b=r,te===0&&pe(Ju)),b===r&&(b=Ol())))))),te--,b===r&&(N=r,te===0&&pe(Gu)),b}function kn(){var b;return cr.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(Zu)),b}function Lo(){var b,N;return te++,e.charCodeAt(R)===10?(b=L,R++):(b=r,te===0&&pe(ec)),b===r&&(e.substr(R,2)===M?(b=M,R+=2):(b=r,te===0&&pe(Ii)),b===r&&(e.charCodeAt(R)===13?(b=V,R++):(b=r,te===0&&pe($o)),b===r&&(e.charCodeAt(R)===8232?(b=W,R++):(b=r,te===0&&pe(tc)),b===r&&(e.charCodeAt(R)===8233?(b=G,R++):(b=r,te===0&&pe(rc)))))),te--,b===r&&(N=r,te===0&&pe(Qu)),b}function $l(){var b,N;return te++,b=Jh(),b===r&&(b=En()),te--,b===r&&(N=r,te===0&&pe(nc)),b}function Jh(){var b,N,J,K,se,ce;if(b=R,e.substr(R,2)===z?(N=z,R+=2):(N=r,te===0&&pe(Do)),N!==r){for(J=[],K=R,se=R,te++,e.substr(R,2)===X?(ce=X,R+=2):(ce=r,te===0&&pe($i)),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r);K!==r;)J.push(K),K=R,se=R,te++,e.substr(R,2)===X?(ce=X,R+=2):(ce=r,te===0&&pe($i)),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r);e.substr(R,2)===X?(K=X,R+=2):(K=r,te===0&&pe($i)),K!==r?(N=[N,J,K],b=N):(R=b,b=r)}else R=b,b=r;return b}function os(){var b,N,J,K,se,ce;if(b=R,e.substr(R,2)===z?(N=z,R+=2):(N=r,te===0&&pe(Do)),N!==r){for(J=[],K=R,se=R,te++,e.substr(R,2)===X?(ce=X,R+=2):(ce=r,te===0&&pe($i)),ce===r&&(ce=kn()),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r);K!==r;)J.push(K),K=R,se=R,te++,e.substr(R,2)===X?(ce=X,R+=2):(ce=r,te===0&&pe($i)),ce===r&&(ce=kn()),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r);e.substr(R,2)===X?(K=X,R+=2):(K=r,te===0&&pe($i)),K!==r?(N=[N,J,K],b=N):(R=b,b=r)}else R=b,b=r;return b}function En(){var b,N,J,K,se,ce;if(b=R,e.substr(R,2)===ie?(N=ie,R+=2):(N=r,te===0&&pe(gn)),N!==r){for(J=[],K=R,se=R,te++,ce=kn(),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r);K!==r;)J.push(K),K=R,se=R,te++,ce=kn(),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r);N=[N,J],b=N}else R=b,b=r;return b}function Uo(){var b,N,J,K;if(te++,b=R,N=Dl(),N!==r){for(J=[],K=Bl();K!==r;)J.push(K),K=Bl();Xe=b,b=jh(N,J)}else R=b,b=r;return te--,b===r&&(N=r,te===0&&pe(ic)),b}function Dl(){var b,N,J;return b=Zh(),b===r&&(e.charCodeAt(R)===36?(b=p,R++):(b=r,te===0&&pe(Co)),b===r&&(e.charCodeAt(R)===95?(b=Se,R++):(b=r,te===0&&pe(zs)),b===r&&(b=R,e.charCodeAt(R)===92?(N=we,R++):(N=r,te===0&&pe(Pn)),N!==r?(J=Rl(),J!==r?b=J:(R=b,b=r)):(R=b,b=r)))),b}function Bl(){var b;return b=Dl(),b===r&&(b=Qh(),b===r&&(b=Pl(),b===r&&(b=Tl(),b===r&&(e.charCodeAt(R)===8204?(b=Ie,R++):(b=r,te===0&&pe(sc)),b===r&&(e.charCodeAt(R)===8205?(b=Ve,R++):(b=r,te===0&&pe(ac))))))),b}function Zh(){var b;return b=Vo(),b===r&&(b=Ko(),b===r&&(b=sp(),b===r&&(b=np(),b===r&&(b=ip(),b===r&&(b=zo()))))),b}function Qh(){var b;return b=Go(),b===r&&(b=Ri()),b}function ep(){var b,N,J;return te++,b=R,N=ti(),N!==r?(e.charCodeAt(R)===105?(J=ue,R++):(J=r,te===0&&pe(Da)),J===r&&(J=null),Xe=b,b=dl(N,J)):(R=b,b=r),te--,b===r&&(N=r,te===0&&pe(Bo)),b}function ti(){var b,N,J,K;if(te++,b=R,e.charCodeAt(R)===34?(N=_e,R++):(N=r,te===0&&pe(Ys)),N!==r){for(J=[],K=re();K!==r;)J.push(K),K=re();e.charCodeAt(R)===34?(K=_e,R++):(K=r,te===0&&pe(Ys)),K!==r?(Xe=b,b=qh(J)):(R=b,b=r)}else R=b,b=r;if(b===r)if(b=R,e.charCodeAt(R)===39?(N=He,R++):(N=r,te===0&&pe(Zt)),N!==r){for(J=[],K=le();K!==r;)J.push(K),K=le();e.charCodeAt(R)===39?(K=He,R++):(K=r,te===0&&pe(Zt)),K!==r?(Xe=b,b=fr(J)):(R=b,b=r)}else R=b,b=r;return te--,b===r&&(N=r,te===0&&pe(Ro)),b}function re(){var b,N,J,K;return b=R,N=R,J=R,te++,e.charCodeAt(R)===34?(K=_e,R++):(K=r,te===0&&pe(Ys)),K===r&&(e.charCodeAt(R)===92?(K=we,R++):(K=r,te===0&&pe(Pn)),K===r&&(K=kn())),te--,K===r?J=void 0:(R=J,J=r),J!==r?(K=kr(),K!==r?(J=[J,K],N=J):(R=N,N=r)):(R=N,N=r),N!==r?b=e.substring(b,R):b=N,b===r&&(b=R,e.charCodeAt(R)===92?(N=we,R++):(N=r,te===0&&pe(Pn)),N!==r?(J=Yt(),J!==r?b=J:(R=b,b=r)):(R=b,b=r),b===r&&(b=pt())),b}function le(){var b,N,J,K;return b=R,N=R,J=R,te++,e.charCodeAt(R)===39?(K=He,R++):(K=r,te===0&&pe(Zt)),K===r&&(e.charCodeAt(R)===92?(K=we,R++):(K=r,te===0&&pe(Pn)),K===r&&(K=kn())),te--,K===r?J=void 0:(R=J,J=r),J!==r?(K=kr(),K!==r?(J=[J,K],N=J):(R=N,N=r)):(R=N,N=r),N!==r?b=e.substring(b,R):b=N,b===r&&(b=R,e.charCodeAt(R)===92?(N=we,R++):(N=r,te===0&&pe(Pn)),N!==r?(J=Yt(),J!==r?b=J:(R=b,b=r)):(R=b,b=r),b===r&&(b=pt())),b}function oe(){var b,N,J,K,se,ce;if(te++,b=R,e.charCodeAt(R)===91?(N=Sr,R++):(N=r,te===0&&pe(uc)),N!==r){for(e.charCodeAt(R)===94?(J=Ht,R++):(J=r,te===0&&pe(Po)),J===r&&(J=null),K=[],se=Te(),se===r&&(se=Ye());se!==r;)K.push(se),se=Te(),se===r&&(se=Ye());e.charCodeAt(R)===93?(se=wt,R++):(se=r,te===0&&pe(Di)),se!==r?(e.charCodeAt(R)===105?(ce=ue,R++):(ce=r,te===0&&pe(Da)),ce===r&&(ce=null),Xe=b,b=lc(J,K,ce)):(R=b,b=r)}else R=b,b=r;return te--,b===r&&(N=r,te===0&&pe(oc)),b}function Te(){var b,N,J,K;return b=R,N=Ye(),N!==r?(e.charCodeAt(R)===45?(J=ir,R++):(J=r,te===0&&pe(Cr)),J!==r?(K=Ye(),K!==r?(Xe=b,b=is(N,K)):(R=b,b=r)):(R=b,b=r)):(R=b,b=r),b}function Ye(){var b,N,J,K;return b=R,N=R,J=R,te++,e.charCodeAt(R)===93?(K=wt,R++):(K=r,te===0&&pe(Di)),K===r&&(e.charCodeAt(R)===92?(K=we,R++):(K=r,te===0&&pe(Pn)),K===r&&(K=kn())),te--,K===r?J=void 0:(R=J,J=r),J!==r?(K=kr(),K!==r?(J=[J,K],N=J):(R=N,N=r)):(R=N,N=r),N!==r?b=e.substring(b,R):b=N,b===r&&(b=R,e.charCodeAt(R)===92?(N=we,R++):(N=r,te===0&&pe(Pn)),N!==r?(J=Yt(),J!==r?b=J:(R=b,b=r)):(R=b,b=r),b===r&&(b=pt())),b}function pt(){var b,N,J;return b=R,e.charCodeAt(R)===92?(N=we,R++):(N=r,te===0&&pe(Pn)),N!==r?(J=Lo(),J!==r?(Xe=b,b=gl()):(R=b,b=r)):(R=b,b=r),b}function Yt(){var b,N,J,K;return b=Tt(),b===r&&(b=R,e.charCodeAt(R)===48?(N=Gt,R++):(N=r,te===0&&pe(Kt)),N!==r?(J=R,te++,K=us(),te--,K===r?J=void 0:(R=J,J=r),J!==r?(Xe=b,b=fc()):(R=b,b=r)):(R=b,b=r),b===r&&(b=Mo(),b===r&&(b=Rl()))),b}function Tt(){var b;return b=Ho(),b===r&&(b=tp()),b}function Ho(){var b,N;return e.charCodeAt(R)===39?(b=He,R++):(b=r,te===0&&pe(Zt)),b===r&&(e.charCodeAt(R)===34?(b=_e,R++):(b=r,te===0&&pe(Ys)),b===r&&(e.charCodeAt(R)===92?(b=we,R++):(b=r,te===0&&pe(Pn)),b===r&&(b=R,e.charCodeAt(R)===98?(N=at,R++):(N=r,te===0&&pe(cc)),N!==r&&(Xe=b,N=mn()),b=N,b===r&&(b=R,e.charCodeAt(R)===102?(N=kt,R++):(N=r,te===0&&pe(Ba)),N!==r&&(Xe=b,N=ml()),b=N,b===r&&(b=R,e.charCodeAt(R)===110?(N=it,R++):(N=r,te===0&&pe(_r)),N!==r&&(Xe=b,N=vl()),b=N,b===r&&(b=R,e.charCodeAt(R)===114?(N=bt,R++):(N=r,te===0&&pe(Ra)),N!==r&&(Xe=b,N=El()),b=N,b===r&&(b=R,e.charCodeAt(R)===116?(N=sr,R++):(N=r,te===0&&pe(To)),N!==r&&(Xe=b,N=wl()),b=N,b===r&&(b=R,e.charCodeAt(R)===118?(N=et,R++):(N=r,te===0&&pe(Oo)),N!==r&&(Xe=b,N=Al()),b=N)))))))),b}function tp(){var b,N,J,K;return b=R,N=R,J=R,te++,K=wn(),K===r&&(K=kn()),te--,K===r?J=void 0:(R=J,J=r),J!==r?(K=kr(),K!==r?(J=[J,K],N=J):(R=N,N=r)):(R=N,N=r),N!==r?b=e.substring(b,R):b=N,b}function wn(){var b;return b=Ho(),b===r&&(b=us(),b===r&&(e.charCodeAt(R)===120?(b=Jt,R++):(b=r,te===0&&pe(Pa)),b===r&&(e.charCodeAt(R)===117?(b=Zn,R++):(b=r,te===0&&pe(Bi))))),b}function Mo(){var b,N,J,K,se,ce;return b=R,e.charCodeAt(R)===120?(N=Jt,R++):(N=r,te===0&&pe(Pa)),N!==r?(J=R,K=R,se=gi(),se!==r?(ce=gi(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r),K!==r?J=e.substring(J,R):J=K,J!==r?(Xe=b,b=yl(J)):(R=b,b=r)):(R=b,b=r),b}function Rl(){var b,N,J,K,se,ce,Ot,er;return b=R,e.charCodeAt(R)===117?(N=Zn,R++):(N=r,te===0&&pe(Bi)),N!==r?(J=R,K=R,se=gi(),se!==r?(ce=gi(),ce!==r?(Ot=gi(),Ot!==r?(er=gi(),er!==r?(se=[se,ce,Ot,er],K=se):(R=K,K=r)):(R=K,K=r)):(R=K,K=r)):(R=K,K=r),K!==r?J=e.substring(J,R):J=K,J!==r?(Xe=b,b=sn(J)):(R=b,b=r)):(R=b,b=r),b}function us(){var b;return Mr.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(Ta)),b}function gi(){var b;return Sa.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(xo)),b}function jo(){var b,N;return b=R,e.charCodeAt(R)===46?(N=br,R++):(N=r,te===0&&pe(Oa)),N!==r&&(Xe=b,N=Kh()),b=N,b}function mt(){var b,N,J,K;return te++,b=R,e.charCodeAt(R)===123?(N=s,R++):(N=r,te===0&&pe(Fi)),N!==r?(J=rp(),e.charCodeAt(R)===125?(K=u,R++):(K=r,te===0&&pe(ns)),K!==r?b=J:(R=b,b=r)):(R=b,b=r),te--,b===r&&(N=r,te===0&&pe(xa)),b}function rp(){var b,N;return b=R,N=qo(),Xe=b,N=vn(N),b=N,b}function qo(){var b,N,J,K,se,ce;if(b=R,N=[],J=[],K=R,se=R,te++,tn.test(e.charAt(R))?(ce=e.charAt(R),R++):(ce=r,te===0&&pe(rn)),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r),K!==r)for(;K!==r;)J.push(K),K=R,se=R,te++,tn.test(e.charAt(R))?(ce=e.charAt(R),R++):(ce=r,te===0&&pe(rn)),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r);else J=r;for(J===r&&(J=R,e.charCodeAt(R)===123?(K=s,R++):(K=r,te===0&&pe(Fi)),K!==r?(se=qo(),e.charCodeAt(R)===125?(ce=u,R++):(ce=r,te===0&&pe(ns)),ce!==r?(K=[K,se,ce],J=K):(R=J,J=r)):(R=J,J=r));J!==r;){if(N.push(J),J=[],K=R,se=R,te++,tn.test(e.charAt(R))?(ce=e.charAt(R),R++):(ce=r,te===0&&pe(rn)),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r),K!==r)for(;K!==r;)J.push(K),K=R,se=R,te++,tn.test(e.charAt(R))?(ce=e.charAt(R),R++):(ce=r,te===0&&pe(rn)),te--,ce===r?se=void 0:(R=se,se=r),se!==r?(ce=kr(),ce!==r?(se=[se,ce],K=se):(R=K,K=r)):(R=K,K=r);else J=r;J===r&&(J=R,e.charCodeAt(R)===123?(K=s,R++):(K=r,te===0&&pe(Fi)),K!==r?(se=qo(),e.charCodeAt(R)===125?(ce=u,R++):(ce=r,te===0&&pe(ns)),ce!==r?(K=[K,se,ce],J=K):(R=J,J=r)):(R=J,J=r))}return b=e.substring(b,R),b}function Ko(){var b;return Ct.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(T)),b}function np(){var b;return lr.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(x)),b}function ip(){var b;return tt.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(H)),b}function sp(){var b;return jr.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(Q)),b}function Vo(){var b;return ba.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(de)),b}function Ri(){var b;return Ca.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(ve)),b}function Go(){var b;return _a.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(Fe)),b}function Pl(){var b;return Fa.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(Re)),b}function zo(){var b;return rs.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(Pt)),b}function Tl(){var b;return Ia.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(Qt)),b}function Ol(){var b;return Vs.test(e.charAt(R))?(b=e.charAt(R),R++):(b=r,te===0&&pe(Or)),b}function _t(){var b,N;for(b=[],N=Nn(),N===r&&(N=Lo(),N===r&&(N=$l()));N!==r;)b.push(N),N=Nn(),N===r&&(N=Lo(),N===r&&(N=$l()));return b}function xl(){var b,N;for(b=[],N=Nn(),N===r&&(N=os());N!==r;)b.push(N),N=Nn(),N===r&&(N=os());return b}function cs(){var b,N,J,K;return b=R,N=_t(),e.charCodeAt(R)===59?(J=Tr,R++):(J=r,te===0&&pe(xr)),J!==r?(N=[N,J],b=N):(R=b,b=r),b===r&&(b=R,N=xl(),J=En(),J===r&&(J=null),K=Lo(),K!==r?(N=[N,J,K],b=N):(R=b,b=r),b===r&&(b=R,N=_t(),J=ls(),J!==r?(N=[N,J],b=N):(R=b,b=r))),b}function ls(){var b,N;return b=R,te++,e.length>R?(N=e.charAt(R),R++):(N=r,te===0&&pe(Gs)),te--,N===r?b=void 0:(R=b,b=r),b}let Yo=t.reservedWords||[];if(xn=a(),xn!==r&&R===e.length)return xn;throw xn!==r&&R{"use strict";var ZB=vh(),QB=sA(),eR=oA(),tR=R0(),rR=["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"],fl={VERSION:tR,RESERVED_WORDS:rR,GrammarError:ZB,parser:eR,compiler:QB,generate(e,t){t=t!==void 0?t:{};function r(a){let s={};return Object.keys(a).forEach(u=>{s[u]=a[u].slice()}),s}let n="plugins"in t?t.plugins:[],i={parser:fl.parser,passes:r(fl.compiler.passes),reservedWords:fl.RESERVED_WORDS.slice()};return n.forEach(a=>{a.use(i,t)}),fl.compiler.compile(i.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:i.reservedWords}),i.passes,t)}};uA.exports=fl});var o1=ye((zL,FA)=>{var WP=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};FA.exports=WP});var u1=ye((YL,IA)=>{var XP="2.0.0",JP=Number.MAX_SAFE_INTEGER||9007199254740991,ZP=16,QP=250,e7=["major","premajor","minor","preminor","patch","prepatch","prerelease"];IA.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:ZP,MAX_SAFE_BUILD_LENGTH:QP,MAX_SAFE_INTEGER:JP,RELEASE_TYPES:e7,SEMVER_SPEC_VERSION:XP,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var f1=ye((Ks,$A)=>{var{MAX_SAFE_COMPONENT_LENGTH:c1,MAX_SAFE_BUILD_LENGTH:t7,MAX_LENGTH:r7}=u1(),n7=o1();Ks=$A.exports={};var i7=Ks.re=[],s7=Ks.safeRe=[],Oe=Ks.src=[],xe=Ks.t={},a7=0,l1="[a-zA-Z0-9-]",o7=[["\\s",1],["\\d",r7],[l1,t7]],u7=e=>{for(let[t,r]of o7)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},Qe=(e,t,r)=>{let n=u7(t),i=a7++;n7(e,i,t),xe[e]=i,Oe[i]=t,i7[i]=new RegExp(t,r?"g":void 0),s7[i]=new RegExp(n,r?"g":void 0)};Qe("NUMERICIDENTIFIER","0|[1-9]\\d*");Qe("NUMERICIDENTIFIERLOOSE","\\d+");Qe("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${l1}*`);Qe("MAINVERSION",`(${Oe[xe.NUMERICIDENTIFIER]})\\.(${Oe[xe.NUMERICIDENTIFIER]})\\.(${Oe[xe.NUMERICIDENTIFIER]})`);Qe("MAINVERSIONLOOSE",`(${Oe[xe.NUMERICIDENTIFIERLOOSE]})\\.(${Oe[xe.NUMERICIDENTIFIERLOOSE]})\\.(${Oe[xe.NUMERICIDENTIFIERLOOSE]})`);Qe("PRERELEASEIDENTIFIER",`(?:${Oe[xe.NUMERICIDENTIFIER]}|${Oe[xe.NONNUMERICIDENTIFIER]})`);Qe("PRERELEASEIDENTIFIERLOOSE",`(?:${Oe[xe.NUMERICIDENTIFIERLOOSE]}|${Oe[xe.NONNUMERICIDENTIFIER]})`);Qe("PRERELEASE",`(?:-(${Oe[xe.PRERELEASEIDENTIFIER]}(?:\\.${Oe[xe.PRERELEASEIDENTIFIER]})*))`);Qe("PRERELEASELOOSE",`(?:-?(${Oe[xe.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${Oe[xe.PRERELEASEIDENTIFIERLOOSE]})*))`);Qe("BUILDIDENTIFIER",`${l1}+`);Qe("BUILD",`(?:\\+(${Oe[xe.BUILDIDENTIFIER]}(?:\\.${Oe[xe.BUILDIDENTIFIER]})*))`);Qe("FULLPLAIN",`v?${Oe[xe.MAINVERSION]}${Oe[xe.PRERELEASE]}?${Oe[xe.BUILD]}?`);Qe("FULL",`^${Oe[xe.FULLPLAIN]}$`);Qe("LOOSEPLAIN",`[v=\\s]*${Oe[xe.MAINVERSIONLOOSE]}${Oe[xe.PRERELEASELOOSE]}?${Oe[xe.BUILD]}?`);Qe("LOOSE",`^${Oe[xe.LOOSEPLAIN]}$`);Qe("GTLT","((?:<|>)?=?)");Qe("XRANGEIDENTIFIERLOOSE",`${Oe[xe.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);Qe("XRANGEIDENTIFIER",`${Oe[xe.NUMERICIDENTIFIER]}|x|X|\\*`);Qe("XRANGEPLAIN",`[v=\\s]*(${Oe[xe.XRANGEIDENTIFIER]})(?:\\.(${Oe[xe.XRANGEIDENTIFIER]})(?:\\.(${Oe[xe.XRANGEIDENTIFIER]})(?:${Oe[xe.PRERELEASE]})?${Oe[xe.BUILD]}?)?)?`);Qe("XRANGEPLAINLOOSE",`[v=\\s]*(${Oe[xe.XRANGEIDENTIFIERLOOSE]})(?:\\.(${Oe[xe.XRANGEIDENTIFIERLOOSE]})(?:\\.(${Oe[xe.XRANGEIDENTIFIERLOOSE]})(?:${Oe[xe.PRERELEASELOOSE]})?${Oe[xe.BUILD]}?)?)?`);Qe("XRANGE",`^${Oe[xe.GTLT]}\\s*${Oe[xe.XRANGEPLAIN]}$`);Qe("XRANGELOOSE",`^${Oe[xe.GTLT]}\\s*${Oe[xe.XRANGEPLAINLOOSE]}$`);Qe("COERCEPLAIN",`(^|[^\\d])(\\d{1,${c1}})(?:\\.(\\d{1,${c1}}))?(?:\\.(\\d{1,${c1}}))?`);Qe("COERCE",`${Oe[xe.COERCEPLAIN]}(?:$|[^\\d])`);Qe("COERCEFULL",Oe[xe.COERCEPLAIN]+`(?:${Oe[xe.PRERELEASE]})?(?:${Oe[xe.BUILD]})?(?:$|[^\\d])`);Qe("COERCERTL",Oe[xe.COERCE],!0);Qe("COERCERTLFULL",Oe[xe.COERCEFULL],!0);Qe("LONETILDE","(?:~>?)");Qe("TILDETRIM",`(\\s*)${Oe[xe.LONETILDE]}\\s+`,!0);Ks.tildeTrimReplace="$1~";Qe("TILDE",`^${Oe[xe.LONETILDE]}${Oe[xe.XRANGEPLAIN]}$`);Qe("TILDELOOSE",`^${Oe[xe.LONETILDE]}${Oe[xe.XRANGEPLAINLOOSE]}$`);Qe("LONECARET","(?:\\^)");Qe("CARETTRIM",`(\\s*)${Oe[xe.LONECARET]}\\s+`,!0);Ks.caretTrimReplace="$1^";Qe("CARET",`^${Oe[xe.LONECARET]}${Oe[xe.XRANGEPLAIN]}$`);Qe("CARETLOOSE",`^${Oe[xe.LONECARET]}${Oe[xe.XRANGEPLAINLOOSE]}$`);Qe("COMPARATORLOOSE",`^${Oe[xe.GTLT]}\\s*(${Oe[xe.LOOSEPLAIN]})$|^$`);Qe("COMPARATOR",`^${Oe[xe.GTLT]}\\s*(${Oe[xe.FULLPLAIN]})$|^$`);Qe("COMPARATORTRIM",`(\\s*)${Oe[xe.GTLT]}\\s*(${Oe[xe.LOOSEPLAIN]}|${Oe[xe.XRANGEPLAIN]})`,!0);Ks.comparatorTrimReplace="$1$2$3";Qe("HYPHENRANGE",`^\\s*(${Oe[xe.XRANGEPLAIN]})\\s+-\\s+(${Oe[xe.XRANGEPLAIN]})\\s*$`);Qe("HYPHENRANGELOOSE",`^\\s*(${Oe[xe.XRANGEPLAINLOOSE]})\\s+-\\s+(${Oe[xe.XRANGEPLAINLOOSE]})\\s*$`);Qe("STAR","(<|>)?=?\\s*\\*");Qe("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");Qe("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var BA=ye((WL,DA)=>{var c7=Object.freeze({loose:!0}),l7=Object.freeze({}),f7=e=>e?typeof e!="object"?c7:e:l7;DA.exports=f7});var OA=ye((XL,TA)=>{var RA=/^[0-9]+$/,PA=(e,t)=>{let r=RA.test(e),n=RA.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:ePA(t,e);TA.exports={compareIdentifiers:PA,rcompareIdentifiers:h7}});var Ph=ye((JL,LA)=>{var Bh=o1(),{MAX_LENGTH:xA,MAX_SAFE_INTEGER:Rh}=u1(),{safeRe:NA,t:kA}=f1(),p7=BA(),{compareIdentifiers:Uu}=OA(),h1=class e{constructor(t,r){if(r=p7(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>xA)throw new TypeError(`version is longer than ${xA} characters`);Bh("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let n=t.trim().match(r.loose?NA[kA.LOOSE]:NA[kA.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>Rh||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Rh||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Rh||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let a=+i;if(a>=0&&a=0;)typeof this.prerelease[a]=="number"&&(this.prerelease[a]++,a=-2);if(a===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(r){let a=[r,i];n===!1&&(a=[r]),Uu(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=a):this.prerelease=a}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};LA.exports=h1});var MA=ye((ZL,HA)=>{var UA=Ph(),d7=(e,t,r)=>new UA(e,r).compare(new UA(t,r));HA.exports=d7});var qA=ye((QL,jA)=>{var g7=MA(),m7=(e,t,r)=>g7(e,t,r)>=0;jA.exports=m7});var GA=ye((eU,VA)=>{var KA=Ph(),v7=(e,t,r=!1)=>{if(e instanceof KA)return e;try{return new KA(e,t)}catch(n){if(!r)return null;throw n}};VA.exports=v7});var YA=ye((tU,zA)=>{var E7=Ph(),w7=GA(),{safeRe:Th,t:Oh}=f1(),A7=(e,t)=>{if(e instanceof E7)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?Th[Oh.COERCEFULL]:Th[Oh.COERCE]);else{let l=t.includePrerelease?Th[Oh.COERCERTLFULL]:Th[Oh.COERCERTL],f;for(;(f=l.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||f.index+f[0].length!==r.index+r[0].length)&&(r=f),l.lastIndex=f.index+f[1].length+f[2].length;l.lastIndex=-1}if(r===null)return null;let n=r[2],i=r[3]||"0",a=r[4]||"0",s=t.includePrerelease&&r[5]?`-${r[5]}`:"",u=t.includePrerelease&&r[6]?`+${r[6]}`:"";return w7(`${n}.${i}.${a}${s}${u}`,t)};zA.exports=A7});var uf="2.19.60";var na=typeof $task<"u",Ss=typeof $loon<"u",ia=typeof $httpClient<"u"&&!Ss,xi=eval('typeof process !== "undefined"'),um=typeof $environment<"u"&&$environment["stash-version"],cm=typeof $rocket<"u",t_=typeof egern=="object",r_=typeof $native<"u",sa=typeof $Plugins<"u";function om(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}var cf=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=wi(),this.env=Ir(),xi){let dotenv=require("dotenv");dotenv.config()}this.node=(()=>{if(xi){let fs=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(na&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(Ss||ia)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),sa&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),xi){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}`)}om(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{this.cache=JSON.parse(this.node.fs.readFileSync(`${fpath}`))}catch(e){this.node.fs.copyFileSync(fpath,backupPath),this.error(`Failed to parse ${fpath}: ${e.message}. Backup created at ${backupPath}`)}om(this.cache)||(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"w"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(na&&$prefs.setValueForKey(data,this.name),(Ss||ia)&&$persistentStore.write(data,this.name),sa&&$Plugins.SubStoreCache.set(this.name,data),xi){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),ia||Ss)return $persistentStore.write(e,t);if(na)return $prefs.setValueForKey(e,t);if(xi&&(this.root[t]=e),sa)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),ia||Ss)return $persistentStore.read(e);if(na)return $prefs.valueForKey(e);if(xi)return this.root[e];if(sa)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),ia||Ss)return $persistentStore.write(null,e);if(na)return $prefs.removeValueForKey(e);if(xi&&delete this.root[e],sa)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(na&&$notify(title,subtitle,content,options),ia&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),Ss){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(xi){let content_=content+(openURL?` \u70B9\u51FB\u8DF3\u8F6C: ${openURL}`:"")+(mediaURL?` \u591A\u5A92\u4F53: ${mediaURL}`:"");console.log(`${title} ${subtitle} ${content_} `);let push=eval("process.env.SUB_STORE_PUSH_SERVICE");if(push){let e=push.replace("[\u63A8\u9001\u6807\u9898]",encodeURIComponent(title||"Sub-Store")).replace("[\u63A8\u9001\u5185\u5BB9]",encodeURIComponent([subtitle,content_].map(r=>r).join(` `)));wi().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}`)})}}sa&&$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={}){na||Ss||ia||sa?$done(e):xi&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function Ir(){return{isQX:na,isLoon:Ss,isSurge:ia,isNode:xi,isStash:um,isShadowRocket:cm,isEgern:t_,isLanceX:r_,isGUIforCores:sa}}function wi(defaultOptions={baseURL:""}){let{isQX,isLoon,isSurge,isNode,isGUIforCores}=Ir(),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||um||cm)&&(opts.timeout=Math.ceil(opts.timeout/1e3),e="s")}if(isNode){let undici=require('undici'),{ProxyAgent,EnvHttpProxyAgent,request,interceptors}=undici,agentOpts={connect:{rejectUnauthorized:!(opts.strictSSL===!1||opts.insecure===!0)},bodyTimeout:opts.timeout,headersTimeout:opts.timeout};try{let e=new URL(opts.url);(e.username||e.password)&&(opts.headers={...opts.headers||{},Authorization:`Basic ${Buffer.from(`${e.username||""}:${e.password||""}`).toString("base64")}`});let t=await request(opts.url,{...opts,method:method.toUpperCase(),dispatcher:(opts.proxy?new ProxyAgent({...agentOpts,uri:opts.proxy}):new EnvHttpProxyAgent(agentOpts)).compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirects:!0}))});resolve({statusCode:t.statusCode,headers:t.headers,body:opts.encoding===null?await t.body.arrayBuffer():await t.body.text()})}catch(e){reject(e)}}else $httpClient[method.toLowerCase()](opts,(e,t,r)=>{e?reject(e):resolve({statusCode:t.status||t.statusCode,headers:t.headers,body:r})})}):isGUIforCores&&(worker=new Promise(async(e,t)=>{try{let r=await $Plugins.Requests({method,url:options.url,headers:options.headers,body:options.body,options:{Proxy:options.proxy,Timeout:options.timeout?options.timeout/1e3:15}});e({statusCode:r.status,headers:r.headers,body:r.body})}catch(r){t(r)}}));let timeoutid,timer=timeout?new Promise((e,t)=>{timeoutid=setTimeout(()=>(events.onTimeout(),t(`${method} URL: ${options.url} exceeds the timeout ${timeout} ms`)),timeout)}):null;return(timer?Promise.race([timer,worker]).then(e=>(typeof clearTimeout<"u"&&clearTimeout(timeoutid),e)):worker).then(e=>events.onResponse(e))}let http={};return methods.forEach(e=>http[e.toLowerCase()]=t=>send(e,t)),http}var n_=new cf("sub-store"),I=n_;var Zp="schemaVersion",Ft="settings",Dt="subs",Bt="collections",vt="files",Gr="modules",ht="artifacts",Pc="rules",ln="tokens",lm="Auto Generated Sub-Store Backup",lf="Sub-Store",Ya="Sub-Store Artifacts Repository",Wa="#sub-store-cached-resource",Xa="#sub-store-cached-headers-resource",ff="#sub-store-chr-expiration-time";var Ja="#sub-store-cached-script-resource",hf="#sub-store-csr-expiration-time";function aa(){i_()}function i_(){let e=I.read(Zp);e||s_(),e!=="2.0"&&I.write("2.0",Zp)}function s_(){I.info("Start migrating...");let e=I.read(Dt)||{},t=Object.values(e).map(A=>(A.source=A.source||"remote",p(A),h(A),A));I.write(t,Dt);let r=I.read(Bt)||{},n=Object.values(r).map(A=>(delete A.ua,p(A),h(A),A));I.write(n,Bt);let i=I.read(ht)||{},a=Object.values(i);I.write(a,ht);let s=I.read(Pc)||{},u=Object.values(s);I.write(u,Pc);let l=I.read(vt)||{},f=Object.values(l);I.write(f,vt);let d=I.read(ln)||{},E=Object.values(d);I.write(E,ln),delete I.cache.builtin,I.info("Migration complete!");function p(A){let m=A["display-name"];m&&(A.displayName=m,delete A["display-name"])}function h(A){let m=A.process;if(!m||m.length===0)return;let S=[],w={type:"Quick Setting Operator",args:{udp:"DEFAULT",tfo:"DEFAULT",scert:"DEFAULT","vmess aead":"DEFAULT",useless:"DEFAULT"}};for(let y of m)if(y.type){if(y.type==="Useless Filter")w.args.useless="ENABLED";else if(y.type==="Set Property Operator"){let{key:_,value:B}=y.args;switch(_){case"udp":w.args.udp=B?"ENABLED":"DISABLED";break;case"tfo":w.args.tfo=B?"ENABLED":"DISABLED";break;case"skip-cert-verify":w.args.scert=B?"ENABLED":"DISABLED";break;case"aead":w.args["vmess aead"]=B?"ENABLED":"DISABLED";break}}else if(y.type.indexOf("Keyword")===-1)if(y.type==="Flag Operator"){let _=typeof y.args>"u"?!0:y.args;y.args={mode:_?"add":"remove"},S.push(y)}else S.push(y)}S.unshift(w),A.process=S}}function Qp({substore:$,port,host}){let{isNode}=Ir(),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":"Sub-Store"};if(isNode){let express_=require("express"),bodyParser=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=()=>{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:i,body:a}=e;i=a_(i),/json/i.test(i["content-type"])&&(a=JSON.parse(a)),r=r.toUpperCase();let{path:s,query:u}=u_(n),l=null,f,d=0;for(f=t;fd&&(l=handlers[f],d=E.split("/").length)}if(l){let E=()=>{dispatch(r,n,f)},p={method:r,url:n,path:s,query:u,params:fm(l.pattern,s),headers:i,body:a},h=Response(),A=l.callback,m=S=>{h.status(500).json({status:"failed",message:`Internal Server Error: ${S}`})};if(A.constructor.name==="AsyncFunction")A(p,h,E).catch(m);else try{A(p,h,E)}catch(S){m(S)}}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:i}=Ir(),a=DEFAULT_HEADERS,s={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(u){return e=u,this}send(u=""){let l={status:t?s[e]:e,body:u,headers:a};t||i?$done(l):(r||n)&&$done({response:l})}end(){this.send()}html(u){this.set("Content-Type","text/html;charset=UTF-8"),this.send(u)}json(u){this.set("Content-Type","application/json;charset=UTF-8"),this.send(JSON.stringify(u))}set(u,l){return a[u]=l,this}}}}function a_(e){let t={};for(let r of Object.keys(e))t[r.toLowerCase()]=e[r];return t}function o_(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 i=0;i>>4&15)+t.charAt(n&15);return r}function f_(e){for(var t="",r=-1,n,i;++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 h_(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function d_(e,t){e[t>>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,n=-271733879,i=-1732584194,a=271733878,s=0;s>16)+(t>>16)+(r>>16);return n<<16|r&65535}function g_(e,t){return e<>>32-t}var Sf=Cn(Cm()),M_=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,j_=/^(([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 vr(e){return M_.test(e)}function ur(e){return j_.test(e)}function _m(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 Hi(e){return typeof e=="string"&&e.trim().length>0}function Ut(e,t){return Hi(e)?e:t}function au(e){return typeof e<"u"&&e!==null}function ou(e,t){return au(e)?e:t}function Cs(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function q_(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function xc(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,i]=r.split("-").map(Number);return q_(n,i)}else return Number(r)}function Fm(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function bf(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 ca(e,t="YYYY-MM-DD_HH-mm-ss"){let r=e instanceof Date?e:new Date(e);if(isNaN(r.getTime()))return"";let n=a=>String(a).padStart(2,"0"),i={YYYY:r.getFullYear(),MM:n(r.getMonth()+1),DD:n(r.getDate()),HH:n(r.getHours()),mm:n(r.getMinutes()),ss:n(r.getSeconds())};return t.replace(/YYYY|MM|DD|HH|mm|ss/g,a=>i[a])}var pd=class{constructor(t){this.expires=t,I.read(Wa)||I.write("{}",Wa);try{this.resourceCache=JSON.parse(I.read(Wa))}catch(r){I.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Wa} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${r?.message??r}`),this.resourceCache={},I.write("{}",Wa)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,i]=r;i.time||(delete this.resourceCache[n],I.delete(`#${n}`),t=!0),new Date().getTime()-i.time>this.expires&&(delete this.resourceCache[n],t=!0)}),t&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){I.write(JSON.stringify(this.resourceCache),Wa)}get(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].data:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}},pr=new pd(36e5);var dd=class{constructor(){this.expires=V_(),I.read(Xa)||I.write("{}",Xa);try{this.resourceCache=JSON.parse(I.read(Xa))}catch(t){I.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Xa} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},I.write("{}",Xa)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,i]=r;i.time||(delete this.resourceCache[n],I.delete(`#${n}`),t=!0),new Date().getTime()-i.time>this.expires&&(delete this.resourceCache[n],t=!0)}),t&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){I.write(JSON.stringify(this.resourceCache),Xa)}get(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].data:null}gettime(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].time:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}};function V_(){I.read(ff)||I.write("6e4",ff);let e=6e4;if(I.env.isLoon){let t={"1\u5206\u949F":6e4,"5\u5206\u949F":3e5,"10\u5206\u949F":6e5,"30\u5206\u949F":18e5,"1\u5C0F\u65F6":36e5,"2\u5C0F\u65F6":72e5,"3\u5C0F\u65F6":108e5,"6\u5C0F\u65F6":216e5,"12\u5C0F\u65F6":432e5,"24\u5C0F\u65F6":864e5,"48\u5C0F\u65F6":1728e5,"72\u5C0F\u65F6":2592e5,\u53C2\u6570\u4F20\u5165:"readcachets"},r=I.read("#\u54CD\u5E94\u5934\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=I.read(ff),e}var eo=new dd;function uu(e){let t=Object.keys(e),r="",n="";for(let i of t){let a=i.toLowerCase();a==="subscription-userinfo"?r=e[i]:a==="profile-web-page-url"&&(n=e[i])}return`${r||""}${n?`; app_url=${encodeURIComponent(n)}`:""}`}async function Zr(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}=Ir(),insecure=$arguments?.insecure?I.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=I.read(Ft),proxy=customProxy||defaultProxy;I.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultFlowUserAgent||"clash",requestTimeout=timeout||defaultTimeout||8e3,id=jn(userAgent+url),cached=eo.get(id),flowInfo;if(!$arguments?.noCache&&cached)I.info(`\u4F7F\u7528\u7F13\u5B58\u7684\u6D41\u91CF\u4FE1\u606F: ${url}, ${userAgent}`),flowInfo=cached;else{let e=wi();if(flowUrl){I.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${flowUrl}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{body:t}=await e.get({url:flowUrl,headers:{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Cs(proxy):{},...insecure||{}});flowInfo=t}else{try{I.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?Cs(proxy):{},...insecure||{}});flowInfo=uu(t)}catch(t){I.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){I.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?Cs(proxy):{},...insecure||{}});flowInfo=uu(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&eo.set(id,flowInfo)}return flowInfo}function to(e){if(!e)return;let t=e.match(/upload=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),r=Number(t[1]+t[2]),n=e.match(/download=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),i=Number(n[1]+n[2]),a=e.match(/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),s=Number(a[1]+a[2]),u=e.match(/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),l=u?Number(u[1]+u[2]):void 0,f=e.match(/reset_day=([0-9]+)/),d=f?Number(f[1]):void 0,E=e.match(/app_url=(.*?)\s*?(;|$)/),p=E?decodeURIComponent(E[1]):void 0,h=e.match(/plan_name=(.*?)\s*?(;|$)/),A=h?decodeURIComponent(h[1]):void 0;return{expires:l,total:s,usage:{upload:r,download:i},remainingDays:d,appUrl:p,planName:A}}function Nc(e,t="B"){let r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],n=r.indexOf(t);return e<1024||n===r.length-1?{value:e.toFixed(1),unit:t}:Nc(e/1024,r[++n])}function Cf(e){if(!e)throw new Error("\u6CA1\u6709\u6D41\u91CF\u4FE1\u606F");if(e?.expires&&e.expires*1e3a.getTime())throw new Error("\u5F00\u59CB\u65E5\u671F\u5E94\u65E9\u4E8E\u73B0\u5728");let s=new Date(r);for(s.setDate(s.getDate()+n);s31)throw new Error("\u6708\u91CD\u7F6E\u65E5\u5E94\u4E3A 1-31 \u4E4B\u95F4\u7684\u6574\u6570");let i=new Date,a=i.getDate(),s=i.getMonth(),u=i.getFullYear(),l;return t>a?l=0:l=new Date(u,s+1,0).getDate(),l-a+t}}catch(t){I.error(`getRmainingDays failed: ${t.message??t}`)}}function la(e){try{let t=new Map;return e.split(";").map(r=>r.trim()).filter(Boolean).forEach(r=>{let n=r.indexOf("=");if(n===-1)return;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();if(!t.has(i))try{let s=decodeURIComponent(a);t.set(i,s)}catch{t.set(i,a)}}),Array.from(t.entries()).map(([r,n])=>`${r}=${encodeURIComponent(n)}`).join("; ")}catch(t){return I.error(`normalizeFlowHeader failed: ${t.message??t}`),e}}function Je(e,t,r="name"){return e.find(n=>n[r]===t)}function Im(e,t,r="name"){return e.findIndex(n=>n[r]===t)}function oi(e,t,r="name"){let n=Im(e,t,r);e.splice(n,1)}function yi(e,t,r,n="name"){let i=Im(e,t,n);e[i]=r}function Ne(e,t,r){e.status(r||200).json({status:"success",data:t})}function Pe(e,t,r){e.status(r||500).json({status:"failed",error:{code:t.code,type:t.type,message:t.message,details:t.details}})}var cu=class{constructor(t,r,n){this.code=t,this.message=r,this.details=n}},jt=class extends cu{constructor(t,r,n){super(t,r,n),this.type="InternalServerError"}},At=class extends cu{constructor(t,r,n){super(t,r,n),this.type="RequestInvalidError"}},Vt=class extends cu{constructor(t,r,n){super(t,r,n),this.type="ResourceNotFoundError"}},lu=class extends cu{constructor(t,r,n){super(t,r,n),this.type="NetworkError"}};var Tm="3.7.7",G_=Tm,hu=typeof Buffer=="function",$m=typeof TextDecoder=="function"?new TextDecoder:void 0,Dm=typeof TextEncoder=="function"?new TextEncoder:void 0,z_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",kc=Array.prototype.slice.call(z_),Ff=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(kc),Y_=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Ur=String.fromCharCode.bind(String),Bm=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),Om=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),xm=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Nm=e=>{let t,r,n,i,a="",s=e.length%3;for(let u=0;u255||(n=e.charCodeAt(u++))>255||(i=e.charCodeAt(u++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|i,a+=kc[t>>18&63]+kc[t>>12&63]+kc[t>>6&63]+kc[t&63]}return s?a.slice(0,s-3)+"===".substring(s):a},vd=typeof btoa=="function"?e=>btoa(e):hu?e=>Buffer.from(e,"binary").toString("base64"):Nm,gd=hu?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,i=e.length;nt?Om(gd(e)):gd(e),W_=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?Ur(192|t>>>6)+Ur(128|t&63):Ur(224|t>>>12&15)+Ur(128|t>>>6&63)+Ur(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return Ur(240|t>>>18&7)+Ur(128|t>>>12&63)+Ur(128|t>>>6&63)+Ur(128|t&63)}},X_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,km=e=>e.replace(X_,W_),Rm=hu?e=>Buffer.from(e,"utf8").toString("base64"):Dm?e=>gd(Dm.encode(e)):e=>vd(km(e)),fu=(e,t=!1)=>t?Om(Rm(e)):Rm(e),Pm=e=>fu(e,!0),J_=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Z_=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 Ur((r>>>10)+55296)+Ur((r&1023)+56320);case 3:return Ur((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return Ur((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},Lm=e=>e.replace(J_,Z_),Um=e=>{if(e=e.replace(/\s+/g,""),!Y_.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,i;for(let a=0;a>16&255):i===64?Ur(t>>16&255,t>>8&255):Ur(t>>16&255,t>>8&255,t&255);return r},Ed=typeof atob=="function"?e=>atob(xm(e)):hu?e=>Buffer.from(e,"base64").toString("binary"):Um,Hm=hu?e=>Bm(Buffer.from(e,"base64")):e=>Bm(Ed(e).split("").map(t=>t.charCodeAt(0))),Mm=e=>Hm(jm(e)),Q_=hu?e=>Buffer.from(e,"base64").toString("utf8"):$m?e=>$m.decode(Hm(e)):e=>Lm(Ed(e)),jm=e=>xm(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),md=e=>Q_(jm(e)),e5=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)},qm=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),Km=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,qm(r));e("fromBase64",function(){return md(this)}),e("toBase64",function(t){return fu(this,t)}),e("toBase64URI",function(){return fu(this,!0)}),e("toBase64URL",function(){return fu(this,!0)}),e("toUint8Array",function(){return Mm(this)})},Vm=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,qm(r));e("toBase64",function(t){return If(this,t)}),e("toBase64URI",function(){return If(this,!0)}),e("toBase64URL",function(){return If(this,!0)})},t5=()=>{Km(),Vm()},Et={version:Tm,VERSION:G_,atob:Ed,atobPolyfill:Um,btoa:vd,btoaPolyfill:Nm,fromBase64:md,toBase64:fu,encode:fu,encodeURI:Pm,encodeURL:Pm,utob:km,btou:Lm,decode:md,isValid:e5,fromUint8Array:If,toUint8Array:Mm,extendString:Km,extendUint8Array:Vm,extendBuiltins:t5};var _h=Cn(Rf());var Gd=Cn(xv());function F8(e){let t=Gd.default.pemtohex(e);return Gd.default.KJUR.crypto.Util.hashHex(t,"sha256").match(/.{2}/g).join(":").toUpperCase()}var Nv={generateFingerprint:F8};var Jc=Cn($E());function BE(e,t,...r){try{return e(t,...r)}catch{return e(RE(e(t.replace(/!\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function Xc(e,...t){return BE(Jc.default.safeLoad,JSON.parse(JSON.stringify(e)),...t)}function nD(e,...t){return BE(Jc.default.load,JSON.parse(JSON.stringify(e)),...t)}function DE(e,...t){return Jc.default.safeDump(JSON.parse(JSON.stringify(e)),...t)}function RE(e,...t){return Jc.default.dump(JSON.parse(JSON.stringify(e)),...t)}var po={safeLoad:Xc,load:nD,safeDump:DE,dump:RE,parse:Xc,stringify:DE};var s0=class{constructor(){this.expires=iD(),I.read(Ja)||I.write("{}",Ja);try{this.resourceCache=JSON.parse(I.read(Ja))}catch(t){I.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Ja} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},I.write("{}",Ja)}this._cleanup()}_cleanup(t,r){let n=!1;Object.entries(this.resourceCache).forEach(i=>{let[a,s]=i;s.time||(delete this.resourceCache[a],I.delete(`#${a}`),n=!0),(new Date().getTime()-s.time>(r??this.expires)||t&&a.startsWith(t))&&(delete this.resourceCache[a],n=!0)}),n&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){I.write(JSON.stringify(this.resourceCache),Ja)}get(t,r,n){let i=this.resourceCache[t]&&this.resourceCache[t].time;if(i){if(new Date().getTime()-i<=(r??this.expires))return this.resourceCache[t].data;n&&(delete this.resourceCache[t],this._persist())}return null}gettime(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].time:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}};function iD(){I.read(hf)||I.write("1728e5",hf);let e=1728e5;if(I.env.isLoon){let t={"1\u5206\u949F":6e4,"5\u5206\u949F":3e5,"10\u5206\u949F":6e5,"30\u5206\u949F":18e5,"1\u5C0F\u65F6":36e5,"2\u5C0F\u65F6":72e5,"3\u5C0F\u65F6":108e5,"6\u5C0F\u65F6":216e5,"12\u5C0F\u65F6":432e5,"24\u5C0F\u65F6":864e5,"48\u5C0F\u65F6":1728e5,"72\u5C0F\u65F6":2592e5,\u53C2\u6570\u4F20\u5165:"readcachets"},r=I.read("#\u8282\u70B9\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=I.read(hf),e}var Zc=new s0;function rh(e,t){return[...Array(e).keys()].map(()=>t)}var a0={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["EXP","BAND"],"\u{1F1F8}\u{1F1F1}":["TEST","SOS"],"\u{1F1E6}\u{1F1E9}":["AD","AND"],"\u{1F1E6}\u{1F1EA}":["AE","ARE"],"\u{1F1E6}\u{1F1EB}":["AF","AFG"],"\u{1F1E6}\u{1F1F1}":["AL","ALB"],"\u{1F1E6}\u{1F1F2}":["AM","ARM"],"\u{1F1E6}\u{1F1F7}":["AR","ARG"],"\u{1F1E6}\u{1F1F9}":["AT","AUT"],"\u{1F1E6}\u{1F1FA}":["AU","AUS"],"\u{1F1E6}\u{1F1FF}":["AZ","AZE"],"\u{1F1E7}\u{1F1E6}":["BA","BIH"],"\u{1F1E7}\u{1F1E9}":["BD","BGD"],"\u{1F1E7}\u{1F1EA}":["BE","BEL"],"\u{1F1E7}\u{1F1EC}":["BG","BGR"],"\u{1F1E7}\u{1F1ED}":["BH","BHR"],"\u{1F1E7}\u{1F1F4}":["BO","BOL"],"\u{1F1E7}\u{1F1F3}":["BN","BRN"],"\u{1F1E7}\u{1F1F7}":["BR","BRA"],"\u{1F1E7}\u{1F1F9}":["BT","BTN"],"\u{1F1E7}\u{1F1FE}":["BY","BLR"],"\u{1F1E8}\u{1F1E6}":["CA","CAN"],"\u{1F1E8}\u{1F1ED}":["CH","CHE"],"\u{1F1E8}\u{1F1F1}":["CL","CHL"],"\u{1F1E8}\u{1F1F4}":["CO","COL"],"\u{1F1E8}\u{1F1F7}":["CR","CRI"],"\u{1F1E8}\u{1F1FE}":["CY","CYP"],"\u{1F1E8}\u{1F1FF}":["CZ","CZE"],"\u{1F1E9}\u{1F1EA}":["DE","DEU"],"\u{1F1E9}\u{1F1F0}":["DK","DNK"],"\u{1F1EA}\u{1F1E8}":["EC","ECU"],"\u{1F1EA}\u{1F1EA}":["EE","EST"],"\u{1F1EA}\u{1F1EC}":["EG","EGY"],"\u{1F1EA}\u{1F1F8}":["ES","ESP"],"\u{1F1EA}\u{1F1FA}":["EU"],"\u{1F1EB}\u{1F1EE}":["FI","FIN"],"\u{1F1EB}\u{1F1F7}":["FR","FRA"],"\u{1F1EC}\u{1F1E7}":["GB","GBR","UK"],"\u{1F1EC}\u{1F1EA}":["GE","GEO"],"\u{1F1EC}\u{1F1F7}":["GR","GRC"],"\u{1F1EC}\u{1F1F9}":["GT","GTM"],"\u{1F1EC}\u{1F1FA}":["GU","GUM"],"\u{1F1ED}\u{1F1F0}":["HK","HKG","HKT","HKBN","HGC","WTT","CMI"],"\u{1F1ED}\u{1F1F7}":["HR","HRV"],"\u{1F1ED}\u{1F1FA}":["HU","HUN"],"\u{1F1EF}\u{1F1F4}":["JO","JOR"],"\u{1F1EF}\u{1F1F5}":["JP","JPN","TYO"],"\u{1F1F0}\u{1F1EA}":["KE","KEN"],"\u{1F1F0}\u{1F1EC}":["KG","KGZ"],"\u{1F1F0}\u{1F1ED}":["KH","KGZ"],"\u{1F1F0}\u{1F1F5}":["KP","PRK"],"\u{1F1F0}\u{1F1F7}":["KR","KOR","SEL"],"\u{1F1F0}\u{1F1FF}":["KZ","KAZ"],"\u{1F1EE}\u{1F1E9}":["ID","IDN"],"\u{1F1EE}\u{1F1EA}":["IE","IRL"],"\u{1F1EE}\u{1F1F1}":["IL","ISR"],"\u{1F1EE}\u{1F1F2}":["IM","IMN"],"\u{1F1EE}\u{1F1F3}":["IN","IND"],"\u{1F1EE}\u{1F1F7}":["IR","IRN"],"\u{1F1EE}\u{1F1F8}":["IS","ISL"],"\u{1F1EE}\u{1F1F9}":["IT","ITA"],"\u{1F1F1}\u{1F1E6}":["LA","LAO"],"\u{1F1F1}\u{1F1F0}":["LK","LKA"],"\u{1F1F1}\u{1F1F9}":["LT","LTU"],"\u{1F1F1}\u{1F1FA}":["LU","LUX"],"\u{1F1F1}\u{1F1FB}":["LV","LVA"],"\u{1F1F2}\u{1F1E6}":["MA","MAR"],"\u{1F1F2}\u{1F1E9}":["MD","MDA"],"\u{1F1F3}\u{1F1EC}":["NG","NGA"],"\u{1F1F2}\u{1F1F2}":["MM","MMR"],"\u{1F1F2}\u{1F1F0}":["MK","MKD"],"\u{1F1F2}\u{1F1F3}":["MN","MNG"],"\u{1F1F2}\u{1F1F4}":["MO","MAC","CTM"],"\u{1F1F2}\u{1F1F9}":["MT","MLT"],"\u{1F1F2}\u{1F1FD}":["MX","MEX"],"\u{1F1F2}\u{1F1FE}":["MY","MYS"],"\u{1F1F3}\u{1F1F1}":["NL","NLD","AMS"],"\u{1F1F3}\u{1F1F4}":["NO","NOR"],"\u{1F1F3}\u{1F1F5}":["NP","NPL"],"\u{1F1F3}\u{1F1FF}":["NZ","NZL"],"\u{1F1F5}\u{1F1E6}":["PA","PAN"],"\u{1F1F5}\u{1F1EA}":["PE","PER"],"\u{1F1F5}\u{1F1ED}":["PH","PHL"],"\u{1F1F5}\u{1F1F0}":["PK","PAK"],"\u{1F1F5}\u{1F1F1}":["PL","POL"],"\u{1F1F5}\u{1F1F7}":["PR","PRI"],"\u{1F1F5}\u{1F1F9}":["PT","PRT"],"\u{1F1F5}\u{1F1FE}":["PY","PRY"],"\u{1F1F5}\u{1F1EC}":["PG","PNG"],"\u{1F1F7}\u{1F1F4}":["RO","ROU"],"\u{1F1F7}\u{1F1F8}":["RS","SRB"],"\u{1F1F7}\u{1F1EA}":["RE","REU"],"\u{1F1F7}\u{1F1FA}":["RU","RUS"],"\u{1F1F8}\u{1F1E6}":["SA","SAU"],"\u{1F1F8}\u{1F1EA}":["SE","SWE"],"\u{1F1F8}\u{1F1EC}":["SG","SGP"],"\u{1F1F8}\u{1F1EE}":["SI","SVN"],"\u{1F1F8}\u{1F1F0}":["SK","SVK"],"\u{1F1F9}\u{1F1ED}":["TH","THA"],"\u{1F1F9}\u{1F1F3}":["TN","TUN"],"\u{1F1F9}\u{1F1F7}":["TR","TUR"],"\u{1F1F9}\u{1F1FC}":["TW","TWN","CHT","HINET","ROC"],"\u{1F1FA}\u{1F1E6}":["UA","UKR"],"\u{1F1FA}\u{1F1F8}":["US","USA","LAX","SFO","SJC"],"\u{1F1FA}\u{1F1FE}":["UY","URY"],"\u{1F1FB}\u{1F1EA}":["VE","VEN"],"\u{1F1FB}\u{1F1F3}":["VN","VNM"],"\u{1F1FF}\u{1F1E6}":["ZA","ZAF","JNB"],"\u{1F1E8}\u{1F1F3}":["CN","CHN","BACK"]};function Ru(e){let t={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["\u6D41\u91CF","\u65F6\u95F4","\u8FC7\u671F","Bandwidth","Expire"],"\u{1F1F8}\u{1F1F1}":["\u5E94\u6025","\u6D4B\u8BD5\u8282\u70B9"],"\u{1F1E6}\u{1F1E9}":["Andorra","\u5B89\u9053\u5C14"],"\u{1F1E6}\u{1F1EA}":["United Arab Emirates","\u963F\u8054\u914B","\u8FEA\u62DC"],"\u{1F1E6}\u{1F1EB}":["Afghanistan","\u963F\u5BCC\u6C57"],"\u{1F1E6}\u{1F1F1}":["Albania","\u963F\u5C14\u5DF4\u5C3C\u4E9A","\u963F\u723E\u5DF4\u5C3C\u4E9E"],"\u{1F1E6}\u{1F1F2}":["Armenia","\u4E9A\u7F8E\u5C3C\u4E9A"],"\u{1F1E6}\u{1F1F7}":["Argentina","\u963F\u6839\u5EF7"],"\u{1F1E6}\u{1F1F9}":["Austria","\u5965\u5730\u5229","\u5967\u5730\u5229","\u7EF4\u4E5F\u7EB3"],"\u{1F1E6}\u{1F1FA}":["Australia","\u6FB3\u5927\u5229\u4E9A","\u6FB3\u6D32","\u58A8\u5C14\u672C","\u6089\u5C3C","\u571F\u6FB3","\u4EAC\u6FB3","\u5EE3\u6FB3","\u6EEC\u6FB3","\u6CAA\u6FB3","\u5E7F\u6FB3","Sydney"],"\u{1F1E6}\u{1F1FF}":["Azerbaijan","\u963F\u585E\u62DC\u7586"],"\u{1F1E7}\u{1F1E6}":["Bosnia and Herzegovina","\u6CE2\u9ED1\u5171\u548C\u56FD","\u6CE2\u9ED1"],"\u{1F1E7}\u{1F1E9}":["Bangladesh","\u5B5F\u52A0\u62C9\u56FD","\u5B5F\u52A0\u62C9"],"\u{1F1E7}\u{1F1EA}":["Belgium","\u6BD4\u5229\u65F6","\u6BD4\u5229\u6642"],"\u{1F1E7}\u{1F1EC}":["Bulgaria","\u4FDD\u52A0\u5229\u4E9A","\u4FDD\u52A0\u5229\u4E9E"],"\u{1F1E7}\u{1F1ED}":["Bahrain","\u5DF4\u6797"],"\u{1F1E7}\u{1F1F7}":["Brazil","\u5DF4\u897F","\u5723\u4FDD\u7F57"],"\u{1F1E7}\u{1F1F3}":["Brunei","\u6587\u83B1","\u6C76\u840A"],"\u{1F1E7}\u{1F1FE}":["Belarus","\u767D\u4FC4\u7F57\u65AF","\u767D\u4FC4"],"\u{1F1E7}\u{1F1F4}":["Bolivia","\u73BB\u5229\u7EF4\u4E9A"],"\u{1F1E7}\u{1F1F9}":["Bhutan","\u4E0D\u4E39","\u4E0D\u4E39\u738B\u56FD"],"\u{1F1E8}\u{1F1E6}":["Canada","\u52A0\u62FF\u5927","\u8499\u7279\u5229\u5C14","\u6E29\u54E5\u534E","\u6953\u8449","\u67AB\u53F6","\u6ED1\u94C1\u5362","\u591A\u4F26\u591A","Waterloo","Toronto"],"\u{1F1E8}\u{1F1ED}":["Switzerland","\u745E\u58EB","\u82CF\u9ECE\u4E16","Zurich"],"\u{1F1E8}\u{1F1F1}":["Chile","\u667A\u5229"],"\u{1F1E8}\u{1F1F4}":["Colombia","\u54E5\u4F26\u6BD4\u4E9A"],"\u{1F1E8}\u{1F1F7}":["Costa Rica","\u54E5\u65AF\u8FBE\u9ECE\u52A0"],"\u{1F1E8}\u{1F1FE}":["Cyprus","\u585E\u6D66\u8DEF\u65AF"],"\u{1F1E8}\u{1F1FF}":["Czechia","\u6377\u514B"],"\u{1F1E9}\u{1F1EA}":["German","\u5FB7\u56FD","\u5FB7\u570B","\u4EAC\u5FB7","\u6EEC\u5FB7","\u5EE3\u5FB7","\u6CAA\u5FB7","\u5E7F\u5FB7","\u6CD5\u5170\u514B\u798F","Frankfurt","\u5FB7\u610F\u5FD7"],"\u{1F1E9}\u{1F1F0}":["Denmark","\u4E39\u9EA6","\u4E39\u9EA5"],"\u{1F1EA}\u{1F1E8}":["Ecuador","\u5384\u74DC\u591A\u5C14"],"\u{1F1EA}\u{1F1EA}":["Estonia","\u7231\u6C99\u5C3C\u4E9A"],"\u{1F1EA}\u{1F1EC}":["Egypt","\u57C3\u53CA"],"\u{1F1EA}\u{1F1F8}":["Spain","\u897F\u73ED\u7259"],"\u{1F1EA}\u{1F1FA}":["European Union","\u6B27\u76DF","\u6B27\u7F57\u5DF4"],"\u{1F1EB}\u{1F1EE}":["Finland","\u82AC\u5170","\u82AC\u862D","\u8D6B\u5C14\u8F9B\u57FA"],"\u{1F1EB}\u{1F1F7}":["France","\u6CD5\u56FD","\u6CD5\u570B","\u5DF4\u9ECE"],"\u{1F1EC}\u{1F1E7}":["Great Britain","\u82F1\u56FD","England","United Kingdom","\u4F26\u6566","\u82F1","London"],"\u{1F1EC}\u{1F1EA}":["Georgia","\u683C\u9C81\u5409\u4E9A","\u683C\u9B6F\u5409\u4E9E"],"\u{1F1EC}\u{1F1F7}":["Greece","\u5E0C\u814A","\u5E0C\u81D8"],"\u{1F1EC}\u{1F1FA}":["Guam","\u5173\u5C9B","\u95DC\u5CF6"],"\u{1F1EC}\u{1F1F9}":["Guatemala","\u5371\u5730\u9A6C\u62C9"],"\u{1F1ED}\u{1F1F0}":["Hongkong","\u9999\u6E2F","Hong Kong","HongKong","HONG KONG","\u6DF1\u6E2F","\u6CAA\u6E2F","\u547C\u6E2F","\u7A57\u6E2F","\u4EAC\u6E2F","\u6E2F"],"\u{1F1ED}\u{1F1F7}":["Croatia","\u514B\u7F57\u5730\u4E9A","\u514B\u7F85\u5730\u4E9E"],"\u{1F1ED}\u{1F1FA}":["Hungary","\u5308\u7259\u5229"],"\u{1F1EF}\u{1F1F4}":["Jordan","\u7EA6\u65E6"],"\u{1F1EF}\u{1F1F5}":["Japan","\u65E5\u672C","\u4E1C\u4EAC","\u5927\u962A","\u57FC\u7389","\u6CAA\u65E5","\u7A57\u65E5","\u5DDD\u65E5","\u4E2D\u65E5","\u6CC9\u65E5","\u676D\u65E5","\u6DF1\u65E5","\u8FBD\u65E5","\u5E7F\u65E5","\u5927\u5742","Osaka","Tokyo"],"\u{1F1F0}\u{1F1EA}":["Kenya","\u80AF\u5C3C\u4E9A"],"\u{1F1F0}\u{1F1EC}":["Kyrgyzstan","\u5409\u5C14\u5409\u65AF\u65AF\u5766"],"\u{1F1F0}\u{1F1ED}":["Cambodia","\u67EC\u57D4\u5BE8"],"\u{1F1F0}\u{1F1F5}":["North Korea","\u671D\u9C9C"],"\u{1F1F0}\u{1F1F7}":["Korea","\u97E9\u56FD","\u97D3\u570B","\u97E9","\u97D3","\u9996\u5C14","\u6625\u5DDD","Chuncheon","Seoul"],"\u{1F1F0}\u{1F1FF}":["Kazakhstan","\u54C8\u8428\u514B\u65AF\u5766","\u54C8\u8428\u514B"],"\u{1F1EE}\u{1F1E9}":["Indonesia","\u5370\u5C3C","\u5370\u5EA6\u5C3C\u897F\u4E9A","\u96C5\u52A0\u8FBE"],"\u{1F1EE}\u{1F1EA}":["Ireland","\u7231\u5C14\u5170","\u611B\u723E\u862D","\u90FD\u67CF\u6797"],"\u{1F1EE}\u{1F1F1}":["Israel","\u4EE5\u8272\u5217"],"\u{1F1EE}\u{1F1F2}":["Isle of Man","\u9A6C\u6069\u5C9B","\u99AC\u6069\u5CF6"],"\u{1F1EE}\u{1F1F3}":["India","\u5370\u5EA6","\u5B5F\u4E70","MFumbai","Mumbai"],"\u{1F1EE}\u{1F1F7}":["Iran","\u4F0A\u6717"],"\u{1F1EE}\u{1F1F8}":["Iceland","\u51B0\u5C9B","\u51B0\u5CF6"],"\u{1F1EE}\u{1F1F9}":["Italy","\u610F\u5927\u5229","\u7FA9\u5927\u5229","\u7C73\u5170","Nachash"],"\u{1F1F1}\u{1F1F0}":["Sri Lanka","\u65AF\u91CC\u5170\u5361","\u65AF\u91CC\u862D\u5361"],"\u{1F1F1}\u{1F1E6}":["Laos","\u8001\u631D","\u8001\u64BE"],"\u{1F1F1}\u{1F1F9}":["Lithuania","\u7ACB\u9676\u5B9B"],"\u{1F1F1}\u{1F1FA}":["Luxembourg","\u5362\u68EE\u5821"],"\u{1F1F1}\u{1F1FB}":["Latvia","\u62C9\u8131\u7EF4\u4E9A","Latvija"],"\u{1F1F2}\u{1F1E6}":["Morocco","\u6469\u6D1B\u54E5"],"\u{1F1F2}\u{1F1E9}":["Moldova","\u6469\u5C14\u591A\u74E6","\u6469\u723E\u591A\u74E6"],"\u{1F1F2}\u{1F1F2}":["Myanmar","\u7F05\u7538","\u7DEC\u7538"],"\u{1F1F3}\u{1F1EC}":["Nigeria","\u5C3C\u65E5\u5229\u4E9A","\u5C3C\u65E5\u5229\u4E9E"],"\u{1F1F2}\u{1F1F0}":["Macedonia","\u9A6C\u5176\u987F","\u99AC\u5176\u9813"],"\u{1F1F2}\u{1F1F3}":["Mongolia","\u8499\u53E4"],"\u{1F1F2}\u{1F1F4}":["Macao","\u6FB3\u95E8","\u6FB3\u9580","CTM"],"\u{1F1F2}\u{1F1F9}":["Malta","\u9A6C\u8033\u4ED6"],"\u{1F1F2}\u{1F1FD}":["Mexico","\u58A8\u897F\u54E5"],"\u{1F1F2}\u{1F1FE}":["Malaysia","\u9A6C\u6765","\u99AC\u4F86","\u5409\u9686\u5761","\u5927\u99AC"],"\u{1F1F3}\u{1F1F1}":["Netherlands","\u8377\u5170","\u8377\u862D","\u5C3C\u5FB7\u862D","\u963F\u59C6\u65AF\u7279\u4E39","Amsterdam"],"\u{1F1F3}\u{1F1F4}":["Norway","\u632A\u5A01"],"\u{1F1F3}\u{1F1F5}":["Nepal","\u5C3C\u6CCA\u5C14"],"\u{1F1F3}\u{1F1FF}":["New Zealand","\u65B0\u897F\u5170","\u65B0\u897F\u862D"],"\u{1F1F5}\u{1F1E6}":["Panama","\u5DF4\u62FF\u9A6C"],"\u{1F1F5}\u{1F1EA}":["Peru","\u79D8\u9C81","\u7955\u9B6F"],"\u{1F1F5}\u{1F1ED}":["Philippines","\u83F2\u5F8B\u5BBE","\u83F2\u5F8B\u8CD3"],"\u{1F1F5}\u{1F1F0}":["Pakistan","\u5DF4\u57FA\u65AF\u5766"],"\u{1F1F5}\u{1F1F1}":["Poland","\u6CE2\u5170","\u6CE2\u862D","\u534E\u6C99","Warsaw"],"\u{1F1F5}\u{1F1F7}":["Puerto Rico","\u6CE2\u591A\u9ECE\u5404"],"\u{1F1F5}\u{1F1F9}":["Portugal","\u8461\u8404\u7259"],"\u{1F1F5}\u{1F1EC}":["Papua New Guinea","\u5DF4\u5E03\u4E9A\u65B0\u51E0\u5185\u4E9A"],"\u{1F1F5}\u{1F1FE}":["Paraguay","\u5DF4\u62C9\u572D"],"\u{1F1F7}\u{1F1F4}":["Romania","\u7F57\u9A6C\u5C3C\u4E9A"],"\u{1F1F7}\u{1F1F8}":["Serbia","\u585E\u5C14\u7EF4\u4E9A"],"\u{1F1F7}\u{1F1EA}":["R\xE9union","\u7559\u5C3C\u6C6A","\u6CD5\u5C5E\u7559\u5C3C\u6C6A"],"\u{1F1F7}\u{1F1FA}":["Russia","\u4FC4\u7F57\u65AF","\u4FC4\u56FD","\u4FC4\u7F85\u65AF","\u4F2F\u529B","\u83AB\u65AF\u79D1","\u5723\u5F7C\u5F97\u5821","\u897F\u4F2F\u5229\u4E9A","\u4EAC\u4FC4","\u676D\u4FC4","\u5EE3\u4FC4","\u6EEC\u4FC4","\u5E7F\u4FC4","\u6CAA\u4FC4","Moscow"],"\u{1F1F8}\u{1F1E6}":["Saudi","\u6C99\u7279\u963F\u62C9\u4F2F","\u6C99\u7279","Riyadh","\u5229\u96C5\u5F97"],"\u{1F1F8}\u{1F1EA}":["Sweden","\u745E\u5178","\u65AF\u5FB7\u54E5\u5C14\u6469","Stockholm"],"\u{1F1F8}\u{1F1EC}":["Singapore","\u65B0\u52A0\u5761","\u72EE\u57CE","\u6CAA\u65B0","\u4EAC\u65B0","\u4E2D\u65B0","\u6CC9\u65B0","\u7A57\u65B0","\u6DF1\u65B0","\u676D\u65B0","\u5E7F\u65B0","\u5EE3\u65B0","\u6EEC\u65B0"],"\u{1F1F8}\u{1F1EE}":["Slovenia","\u65AF\u6D1B\u6587\u5C3C\u4E9A"],"\u{1F1F8}\u{1F1F0}":["Slovakia","\u65AF\u6D1B\u4F10\u514B"],"\u{1F1F9}\u{1F1ED}":["Thailand","\u6CF0\u56FD","\u6CF0\u570B","\u66FC\u8C37"],"\u{1F1F9}\u{1F1F3}":["Tunisia","\u7A81\u5C3C\u65AF"],"\u{1F1F9}\u{1F1F7}":["Turkey","\u571F\u8033\u5176","\u4F0A\u65AF\u5766\u5E03\u5C14","Istanbul"],"\u{1F1F9}\u{1F1FC}":["Taiwan","\u53F0\u6E7E","\u81FA\u7063","\u53F0\u7063","\u4E2D\u83EF\u6C11\u570B","\u4E2D\u534E\u6C11\u56FD","\u53F0\u5317","\u53F0\u4E2D","\u65B0\u5317","\u5F70\u5316","\u53F0","\u81FA","Taipei","Tai Wan"],"\u{1F1FA}\u{1F1E6}":["Ukraine","\u4E4C\u514B\u5170","\u70CF\u514B\u862D"],"\u{1F1FA}\u{1F1F8}":["United States","\u7F8E\u56FD","America","\u7F8E","\u4EAC\u7F8E","\u6CE2\u7279\u5170","\u8FBE\u62C9\u65AF","\u4FC4\u52D2\u5188","Oregon","\u51E4\u51F0\u57CE","\u8D39\u5229\u8499","\u7845\u8C37","\u77FD\u8C37","\u62C9\u65AF\u7EF4\u52A0\u65AF","\u6D1B\u6749\u77F6","\u5723\u4F55\u585E","\u5723\u514B\u62C9\u62C9","\u897F\u96C5\u56FE","\u829D\u52A0\u54E5","\u6CAA\u7F8E","\u54E5\u4F26\u5E03","\u7EBD\u7EA6","New York","Los Angeles","San Jose","Sillicon Valley","Michigan","\u4FC4\u4EA5\u4FC4","Ohio","\u9A6C\u7EB3\u8428\u65AF","Manassas","\u5F17\u5409\u5C3C\u4E9A","Virginia"],"\u{1F1FA}\u{1F1FE}":["Uruguay","\u4E4C\u62C9\u572D"],"\u{1F1FB}\u{1F1EA}":["Venezuela","\u59D4\u5185\u745E\u62C9"],"\u{1F1FB}\u{1F1F3}":["Vietnam","\u8D8A\u5357","\u80E1\u5FD7\u660E"],"\u{1F1FF}\u{1F1E6}":["South Africa","\u5357\u975E"],"\u{1F1E8}\u{1F1F3}":["China","\u4E2D\u56FD","\u4E2D\u570B","\u56DE\u56FD","\u56DE\u570B","\u56FD\u5185","\u570B\u5167","\u534E\u4E1C","\u534E\u897F","\u534E\u5357","\u534E\u5317","\u534E\u4E2D","\u6C5F\u82CF","\u5317\u4EAC","\u4E0A\u6D77","\u5E7F\u5DDE","\u6DF1\u5733","\u676D\u5DDE","\u5F90\u5DDE","\u9752\u5C9B","\u5B81\u6CE2","\u9547\u6C5F"]},r=e.match(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/)?.[0]||"\u{1F3F4}\u200D\u2620\uFE0F";for(let n of Object.keys(t))if(t[n].some(a=>RegExp(`${a}`,"i").test(e)))return/内蒙古/.test(e)&&["\u{1F1F2}\u{1F1F3}"].includes(n)?r="\u{1F1E8}\u{1F1F3}":r=n;for(let n of Object.keys(a0))if(a0[n].some(a=>RegExp(`(^|[^a-zA-Z])${a}([^a-zA-Z]|$)`).test(e))&&!(n=="\u{1F1E8}\u{1F1F3}"&&RegExp("(^|[^a-zA-Z])CN2([^a-zA-Z]|$)").test(e)))return r=n;return r}function ih(e){return a0[Ru(e)]?.[0]}function Qc(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var nh=class{constructor({country,asn}={}){if(I.env.isNode){let Reader=require("@maxmind/geoip2-node").Reader,fs=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 oh=Cn(jE()),qE=Cn(Rf());async function Tu({url:e,domain:t,type:r="A",timeout:n,edns:i}){let a=oh.default.encode({type:"query",id:0,flags:oh.default.RECURSION_DESIRED,questions:[{type:r,name:t}],additionals:[{type:"OPT",name:".",udpPayloadSize:4096,flags:0,options:[{code:"CLIENT_SUBNET",ip:i,sourcePrefixLength:vr(i)?24:56,scopePrefixLength:0}]}]}),s=await I.http.get({url:`${e}?dns=${a.toString("base64").toString("utf-8").replace(/=/g,"")}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n});return oh.default.decode(qE.Buffer.from(I.env.isQX?s.bodyBytes:s.body))}var E0=Cn(m0());var{isNode:KE,isQX:hD,isLoon:pD,isSurge:dD,isStash:gD,isShadowRocket:mD,isLanceX:vD,isEgern:ED,isGUIforCores:wD}=Ir(),Zi="Node";KE&&(Zi="Node");hD&&(Zi="QX");pD&&(Zi="Loon");dD&&(Zi="Surge");gD&&(Zi="Stash");mD&&(Zi="ShadowRocket");ED&&(Zi="Egern");vD&&(Zi="LanceX");wD&&(Zi="GUI.for.Cores");var mo={},AD={};try{if(typeof $environment<"u"&&(mo.env=$environment),typeof $loon<"u"&&(mo.loon=$loon),typeof $script<"u"&&(mo.script=$script),typeof $Plugin<"u"&&(mo.plugin=$Plugin),KE){mo.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)&&(mo.node.env[e]=env[e])}}catch(e){}var Qi={backend:Zi,version:uf,feature:AD,meta:mo};function yD(e){return e&&typeof e=="object"&&!Array.isArray(e)}function rl(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function GE(e,t){let r=typeof t=="string"?JSON.parse(t):t;for(let n in r)if(yD(r[n]))if(n.endsWith("!")){let i=rl(n.slice(0,-1));e[i]=r[n]}else{let i=rl(n);e[i]||Object.assign(e,{[i]:{}}),GE(e[i],r[i])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let i=rl(n.slice(1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...r[n],...e[i]]}else if(n.endsWith("+")){let i=rl(n.slice(0,-1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...e[i],...r[n]]}else{let i=rl(n);Object.assign(e,{[i]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function SD({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>uh(e,r))}}function uh(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=>uh(r,t));case"OR":return e.child.some(r=>uh(r,t));case"NOT":return!uh(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function bD(e){return{name:"Quick Setting Operator",func:r=>{if(t(e.useless)){let i=XE().func(r);r=r.filter((a,s)=>i[s]&&a.port>0&&a.port<=65535)}return r.map(n=>(n.udp=t(e.udp,n.udp),n.tfo=t(e.tfo,n.tfo),n["fast-open"]=t(e.tfo,n["fast-open"]),n["skip-cert-verify"]=t(e.scert,n["skip-cert-verify"]),n.type==="vmess"&&(n.aead=t(e["vmess aead"],n.aead)),n))}};function t(r,n){switch(r){case"ENABLED":return!0;case"DISABLED":return!1;default:return n}}}function CD({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=Qc(n.name);else{let i=Ru(n.name);n.name=Qc(n.name),n.name=i+" "+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 _D(e){let{action:t,template:r,link:n,position:i}={action:"rename",template:"0 1 2 3 4 5 6 7 8 9",link:"-",position:"back",...e};return{name:"Handle Duplicate Operator",func:a=>{if(t==="delete"){let s={};return a.filter(u=>s[u.name]?!1:(s[u.name]=!0,!0))}else if(t==="rename"){let s=r.split(" "),u={},l=0;a.forEach(d=>{typeof u[d.name]>"u"?u[d.name]=1:u[d.name]++,l=Math.max(u[d.name].toString().length,l)});let f={};return a.map(d=>{if(u[d.name]>1){typeof f[d.name]>"u"&&(f[d.name]=1);let E="",p=f[d.name]++,h=0;for(;p>0;)E=s[p%10]+E,p=parseInt(p/10),h++;for(;h++{switch(e){case"asc":case"desc":return t.sort((r,n)=>{let i=r.name>n.name?1:-1;return i*=e==="desc"?-1:1,i});case"random":return kD(t);default:throw new Error("Unknown sort option: "+e)}}}}function ID(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(i=>w0(i)),n.sort((i,a)=>{let s=VE(r,i.name),u=VE(r,a.name);return s&&!u?-1:u&&!s?1:s&&u?st.map(r=>{for(let{expr:n,now:i}of e)r.name=r.name.replace(w0(n,"g"),i).trim();return r})}}function $D(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:zE(t).func}}function DD(e,t,r,n,i){return{name:"Script Operator",func:async a=>{let s=a;if(s?.$file?.type==="mihomoProfile")try{let u=po.safeLoad(e),l;if(s?.$content)try{l=po.safeLoad(s?.$content)}catch(f){I.error(f.message??f)}if(typeof u!="object")throw new Error("patch is not an object");return s.$content=yt.yaml.safeDump(GE(l||(s?.$file?.sourceType==="none"?{}:{proxies:await Pr({type:s?.$file?.sourceType||"collection",name:s?.$file?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0}})}),u)),s}catch{}return await async function(){s=ch("operator",e,r,i)(a,t,{source:n,...Qi})}(),s},nodeFunc:async a=>{let s=a;return await async function(){s=ch("operator",`async function operator(input = []) { if (input && (input.$files || input.$content)) { let { $content, $files, $options, $file } = input if($file.type === 'mihomoProfile') { ${e} if(typeof main === 'function') { let config; if ($content) { try { config = ProxyUtils.yaml.safeLoad($content); } catch (e) { console.log(e.message ?? e); } } $content = ProxyUtils.yaml.safeDump(await main(config || ($file.sourceType === 'none' ? {} : { proxies: await produceArtifact({ type: $file.sourceType || 'collection', name: $file.sourceName, platform: 'mihomo', produceType: 'internal', produceOpts: { 'delete-underscore-fields': true } }), }))) } } else { ${e} } return { $content, $files, $options, $file } } else { let proxies = input let list = [] for await (let $server of proxies) { ${e} list.push($server) } return list } }`,r,i)(a,t,{source:n,...Qi})}(),s}}}function BD(e){let t,r;try{let n=e.split(":");r=parseInt(n[2],16);let i=parseInt(n[3],16),a=parseInt(n[4],16),s=i>>8,u=i&255,l=a>>8,f=a&255;if(t=`${s}.${u}.${l}.${f}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!vr(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){I.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var YE={Custom:async function(e,t,r,n,i,a){let s=jn(`CUSTOM:${a}:${e}:${t}`),u=pr.get(s);if(!r&&u)return u;let l=t==="IPv6"?"AAAA":"A",f=await Tu({url:a,domain:e,type:l,timeout:n,edns:i}),{answers:d}=f;if(!Array.isArray(d)||d.length===0)throw new Error("No answers");let E=d.filter(p=>p?.type===l).map(p=>p?.data).filter(p=>p);if(E.length===0)throw new Error("No answers");return pr.set(s,E),E},Google:async function(e,t,r,n,i){let a=jn(`GOOGLE:${e}:${t}`),s=pr.get(a);if(!r&&s)return s;let u=t==="IPv6"?"AAAA":"A",l=await Tu({url:"https://8.8.4.4/dns-query",domain:e,type:u,timeout:n,edns:i}),{answers:f}=l;if(!Array.isArray(f)||f.length===0)throw new Error("No answers");let d=f.filter(E=>E?.type===u).map(E=>E?.data).filter(E=>E);if(d.length===0)throw new Error("No answers");return pr.set(a,d),d},"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 i=jn(`IP-API:${e}`),a=pr.get(i);if(!r&&a)return a;let s=await I.http.get({url:`http://ip-api.com/json/${encodeURIComponent(e)}?lang=zh-CN`,timeout:n}),u=JSON.parse(s.body);if(u.status!=="success")throw new Error(`Status is ${u.status}`);if(!u.query||u.query===0)throw new Error("No answers");let l=[u.query];if(l.length===0)throw new Error("No answers");return pr.set(i,l),l},Cloudflare:async function(e,t,r,n,i){let a=jn(`CLOUDFLARE:${e}:${t}`),s=pr.get(a);if(!r&&s)return s;let u=t==="IPv6"?"AAAA":"A",l=await Tu({url:"https://1.0.0.1/dns-query",domain:e,type:u,timeout:n,edns:i}),{answers:f}=l;if(!Array.isArray(f)||f.length===0)throw new Error("No answers");let d=f.filter(E=>E?.type===u).map(E=>E?.data).filter(E=>E);if(d.length===0)throw new Error("No answers");return pr.set(a,d),d},Ali:async function(e,t,r,n,i){let a=jn(`ALI:${e}:${t}`),s=pr.get(a);if(!r&&s)return s;let u=await I.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${i}/24&name=${encodeURIComponent(e)}&type=${t==="IPv6"?"AAAA":"A"}&short=1`,headers:{accept:"application/dns-json"},timeout:n}),l=JSON.parse(u.body);if(!Array.isArray(l)||l.length===0)throw new Error("No answers");let f=l;if(f.length===0)throw new Error("No answers");return pr.set(a,f),f},Tencent:async function(e,t,r,n,i){let a=jn(`TENCENT:${e}:${t}`),s=pr.get(a);if(!r&&s)return s;let l=(await I.http.get({url:`http://119.28.28.28/d?ip=${i}&type=${t==="IPv6"?"AAAA":"A"}&dn=${encodeURIComponent(e)}`,headers:{accept:"application/dns-json"},timeout:n})).body.split(";").map(d=>d.split(",")[0]);if(l.length===0||String(l)==="0")throw new Error("No answers");let f=l;if(f.length===0)throw new Error("No answers");return pr.set(a,f),f}};function WE({provider:e,type:t,filter:r,cache:n,url:i,timeout:a,edns:s}){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:u}=I.read(Ft),l=a||u||8e3,f=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",d=YE[e];if(!d)throw new Error(`\u627E\u4E0D\u5230\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9: ${e}`);let E=s||"223.6.6.6";if(!vo(E))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");return I.info(`Domain Resolver: [${t}] ${e} ${E||""} ${i||""}`),{name:"Resolve Domain Operator",func:async p=>{p.forEach((w,y)=>{!w["_no-resolve"]&&w["no-resolve"]&&(p[y]["_no-resolve"]=w["no-resolve"])});let h={},A=15,m=[...new Set(p.filter(w=>!vo(w.server)&&!w["_no-resolve"]).map(w=>w.server))],S=Math.ceil(m.length/A);for(let w=0;w{h[_]=B,I.info(`Successfully resolved domain: ${_} \u279F ${B}`)}).catch(B=>{I.error(`Failed to resolve domain: ${_} with resolver [${e}]: ${B}`)}));await Promise.all(y)}return p.forEach(w=>{if(!w["_no-resolve"])if(h[w.server]){w._resolved_ips=h[w.server];let y=Array.isArray(h[w.server])?h[w.server][Math.floor(Math.random()*h[w.server].length)]:h[w.server];if(f==="IPv6"&&ur(y)){try{y=new Sf.Address6(y).correctForm()}catch(_){I.error(`Failed to parse IPv6 address: ${y}: ${_}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(y)){w._IP4P=y;let{server:_,port:B}=BD(y);_&&B?(w._domain=w.server,w.server=_,w.port=B,w.resolved=!0,w._IPv4=w.server,vo(w._IP)||(w._IP=w.server)):w.resolved||(w.resolved=!1)}else w._domain=w.server,w.server=y,w.resolved=!0,w[`_${f}`]=w.server,vo(w._IP)||(w._IP=w.server)}else w._domain=w.server,w.server=y,w.resolved=!0,w[`_${f}`]=w.server,vo(w._IP)||(w._IP=w.server)}else w.resolved||(w.resolved=!1)}),p.filter(w=>r==="removeFailed"?vo(w.server)||w["_no-resolve"]||w.resolved:r==="IPOnly"?vo(w.server):r==="IPv4Only"?vr(w.server):r==="IPv6Only"?ur(w.server):!0)}}}function vo(e){return vr(e)||ur(e)}WE.resolver=YE;function v0(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function XE(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!v0(t.cipher))return!1;if(t.password&&!v0(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&&!v0(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function RD(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:i=>i.map(a=>{let s=Ru(a.name),u=t.some(l=>n[l]===s);return r?u:!u})}}function PD({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let i=e.some(a=>w0(a).test(n.name));return t?i:!i})}}function w0(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function TD(e){let t=e?.value||e;Array.isArray(t)||(t=[]);let r=e?.keep??!0;return{name:"Type Filter",func:n=>n.map(i=>{let a=t.some(s=>i.type===s);return r?a:!a})}}function OD(e,t,r,n,i){return{name:"Script Filter",func:async a=>{let s=rh(a.length,!0);return await async function(){s=ch("filter",e,r,i)(a,t,{source:n,...Qi})}(),s},nodeFunc:async a=>{let s=rh(a.length,!0);return await async function(){s=ch("filter",`async function filter(input = []) { let proxies = input let list = [] const fn = async ($server) => { ${e} } for await (let $server of proxies) { list.push(await fn($server)) } return list }`,r,i)(a,t,{source:n,...Qi})}(),s}}}var lh={"Useless Filter":XE,"Region Filter":RD,"Regex Filter":PD,"Type Filter":TD,"Script Filter":OD,"Conditional Filter":SD,"Quick Setting Operator":bD,"Flag Operator":CD,"Sort Operator":FD,"Regex Sort Operator":ID,"Regex Rename Operator":zE,"Regex Delete Operator":$D,"Script Operator":DD,"Handle Duplicate Operator":_D,"Resolve Domain Operator":WE};async function xD(e,t){let r=rh(t.length,!0);try{r=await e.func(t)}catch(n){let i="",a=`${n.message??n}`;a.includes("$server is not defined")?i="":(I.error(`Cannot apply filter ${e.name}(function filter)! Reason: ${n}`),i=`\u6267\u884C function filter \u5931\u8D25 ${a}; `);try{r=await e.nodeFunc(t)}catch(s){I.error(`Cannot apply filter ${e.name}(shortcut script)! Reason: ${s}`);let u="",l=`${s.message??s}`;throw i&&l===a?(u="",i=`\u6267\u884C\u5931\u8D25 ${a}`):u=`\u6267\u884C\u5FEB\u6377\u8FC7\u6EE4\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u8FC7\u6EE4 ${i}${u}`)}}return t.filter((n,i)=>r[i])}async function ND(e,t){let r=LD(t);try{let n=await e.func(r);n&&(r=n)}catch(n){let i="",a=`${n.message??n}`;a.includes("$server is not defined")||a.includes("$content is not defined")||a.includes("$files is not defined")||r?.$files||r?.$content?i="":(I.error(`Cannot apply operator ${e.name}(function operator)! Reason: ${n}`),i=`\u6267\u884C function operator \u5931\u8D25 ${a}; `);try{let s=await e.nodeFunc(r);s&&(r=s)}catch(s){I.error(`Cannot apply operator ${e.name}(shortcut script)! Reason: ${s}`);let u="",l=`${s.message??s}`;throw i&&l===a?(u="",i=`\u6267\u884C\u5931\u8D25 ${a}`):u=`\u6267\u884C\u5FEB\u6377\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u64CD\u4F5C ${i}${u}`)}}return r}async function JE(e,t){if(e.name.indexOf("Filter")!==-1)return xD(e,t);if(e.name.indexOf("Operator")!==-1)return ND(e,t)}function kD(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 LD(e){return JSON.parse(JSON.stringify(e))}function ch(name,script,$arguments,$options){let flowUtils={getFlowField:uu,getFlowHeaders:Zr,parseFlowHeaders:to,flowTransfer:Nc,validCheck:Cf,getRmainingDays:_f,normalizeFlowHeader:la};return I.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,I,E0.default,$persistentStore,$httpClient,$notification,yt,yt.yaml,yt.Buffer,yt.Base64.decode,yt.Base64.encode,Zc,flowUtils,Pr,eval('typeof require !== "undefined"')?za:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","yaml","Buffer","b64d","b64e","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,I,E0.default,yt,yt.yaml,yt.Buffer,yt.Base64.decode,yt.Base64.encode,Zc,flowUtils,Pr,eval('typeof require !== "undefined"')?za:void 0)}function UD(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function HD(){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(i){return!/^\w+:\/\/\w+/im.test(i)&&t.some(a=>i.indexOf(a)!==-1)},parse:function(i){let a=Et.decode(i);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(a)?a:(I.error("Base64 Pre-processor error: decoded line does not start with protocol"),i)}}}function MD(){return{name:"Fallback Base64 Pre-processor",test:function(n){return!0},parse:function(n){let i=Et.decode(n);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(i)?i:(I.error("Fallback Base64 Pre-processor error: decoded line does not start with protocol"),n)}}}function jD(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let i=Xc(n);return i.proxies&&Array.isArray(i.proxies)},parse:function(n,i){let a=n.replace(/short-id:([ \t]*[^#\n,}]*)/g,(l,f)=>{let d=f.trim();return!d||d===""?'short-id: ""':/^(['"]).*\1$/.test(d)?`short-id: ${d}`:["null"].includes(d)?`short-id: ${d}`:`short-id: "${d}"`}),{proxies:s,"global-client-fingerprint":u}=Xc(a);return(i?`proxies: `:"")+s.map(l=>(u&&!l["client-fingerprint"]&&(l["client-fingerprint"]=u),`${i?" - ":""}${JSON.stringify(l)} `)).join("")}}}function qD(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let i=[],a=JSON.parse(Et.decode(n.split("ssd://")[1])),s=a.port,u=a.encryption,l=a.password,f=a.servers;for(let d=0;d"u")throw new Error("required field is missing");this.output.push(t)}appendIfPresent(t,r){ae(this.proxy,r)&&this.append(t)}toString(){return this.output.join("")}};function ae(e,t){let r=ZE.default.get(e,t);return typeof r<"u"&&r!==null}var VD="Surge",fi={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function xu(){return{produce:(t,r,n={})=>{switch(t.name=t.name.replace(/=|,/g,""),t.ports&&(t.ports=String(t.ports)),t.type){case"ss":return GD(t,n["include-unsupported-proxy"]);case"trojan":return zD(t);case"vmess":return YD(t,n["include-unsupported-proxy"]);case"http":return XD(t);case"direct":return JD(t);case"socks5":return ZD(t);case"snell":return QD(t);case"tuic":return e9(t);case"wireguard-surge":return r9(t);case"hysteria2":return n9(t);case"ssh":return WD(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return t9(t);throw new Error(`Platform ${VD} does not support proxy type: ${t.type}`)}}}function GD(e){let t=new rt(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=fi[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"),ae(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"),ae(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,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}return t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function zD(e){let t=new rt(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=fi[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"),QE(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"),ae(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 YD(e,t){let r=new rt(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=fi[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"),QE(r,e,t),ae(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"),ae(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 WD(e){let t=new rt(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,private-key=${e["keystore-private-key"]}`,"keystore-private-key"),t.appendIfPresent(`,idle-timeout=${e["idle-timeout"]}`,"idle-timeout"),t.appendIfPresent(`,server-fingerprint="${e["server-fingerprint"]}"`,"server-fingerprint");let r=fi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function XD(e){if(e.headers&&Object.keys(e.headers).length>0)throw new Error("headers is unsupported");let t=new rt(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password");let n=fi[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"),ae(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 JD(e){let t=new rt(e);t.append(`${e.name}=direct`);let n=fi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function ZD(e){let t=new rt(e),r=e.tls?"socks5-tls":"socks5";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password");let n=fi[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&&I.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"),ae(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 QD(e){let t=new rt(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=fi[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"),ae(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 e9(e){let t=new rt(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"),ae(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let n=fi[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"),ae(e,"tfo")?t.append(`,tfo=${e.tfo}`):ae(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"),ae(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 t9(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 rt(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=Ut(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=fi[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"),ae(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"],i=Array.isArray(e.reserved)?e.reserved.join("/"):e.reserved,a=e["preshared-key"]??e["pre-shared-key"];a&&(a=`,preshared-key="${a}"`);let s={"public-key":e["public-key"],"allowed-ips":n?`"${n}"`:void 0,endpoint:`${e.server}:${e.port}`,keepalive:e["persistent-keepalive"]||e.keepalive,"client-id":i,"preshared-key":a};return t.append(` peer = (${Object.keys(s).filter(u=>s[u]!=null).map(u=>`${u} = ${s[u]}`).join(", ")})`),t.toString()}function r9(e){let t=new rt(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=fi[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"),ae(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 n9(e){if(e.obfs||e["obfs-password"])throw new Error("obfs is unsupported");let t=new rt(e);t.append(`${e.name}=hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),ae(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let r=fi[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),ae(e,"tfo")?t.append(`,tfo=${e.tfo}`):ae(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"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function QE(e,t,r){if(ae(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ae(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ae(t,"ws-opts.headers"))){let n=t["ws-opts"].headers,i=Object.keys(n).map(a=>{let s=n[a];return["Host"].includes(a)&&(s=`"${s}"`),`${a}:${s}`}).join("|");Hi(i)&&e.append(`,ws-headers=${i}`)}}else if(r&&["http"].includes(t.network))I.info(`Include Unsupported Proxy: nework ${t.network} -> tcp`);else throw new Error(`network ${t.network} is unsupported`)}function zn(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&String(s.version)==="4"||["juicity"].includes(s.type)?!1:!(["ss"].includes(s.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(s.cipher))).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ae(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ae(s,"version")&&(s.version=5)):s.type==="hysteria"?(ae(s,"auth_str")&&!ae(s,"auth-str")&&(s["auth-str"]=s.auth_str),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"?ae(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"&&ae(s,"shadow-tls-password")&&!ae(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal"||i["delete-underscore-fields"])for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var ew="SurgeMac",i9=xu();function A0(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return tw(t);default:try{return i9.produce(t,r,n)}catch{if(n.useMihomoExternal)return I.log(`${t.name} is not supported on ${ew}, try to use Mihomo(SurgeMac - External Proxy Program) instead`),s9(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 tw(e){let t=new rt(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"),ae(e,"tfo")?t.append(`,tfo=${e.tfo}`):ae(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 s9(e,t,r){let n=zn().produce([e],"internal")?.[0];if(n){let i=r?.localPort||e._localPort||65535,a=!["ipv4","v4-only"].includes(e["ip-version"]),s={name:e.name,type:"external",exec:e._exec||"/usr/local/bin/mihomo","local-port":i,args:["-config",Et.encode(JSON.stringify({"mixed-port":i,ipv6:a,mode:"global",dns:{enable:!0,ipv6:a,"default-nameserver":r?.defaultNameserver||e._defaultNameserver||["180.76.76.76","52.80.52.52","119.28.28.28","223.6.6.6"],nameserver:r?.nameserver||e._nameserver||["https://doh.pub/dns-query","https://dns.alidns.com/dns-query","https://doh-pure.onedns.net/dns-query"]},proxies:[{...n,name:"proxy"}],"proxy-groups":[{name:"GLOBAL",type:"select",proxies:["proxy"]}]}))],addresses:[]};return a9(e.server)?s.addresses.push(e.server):I.log(`Platform ${ew}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),r.localPort=i-1,tw(s)}}function a9(e){return vr(e)||ur(e)}function y0(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:!["ss","ssr","vmess","vless","socks5","http","snell","trojan","wireguard"].includes(s.type)||s.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(s.cipher)||s.type==="snell"&&String(s.version)==="4"||s.type==="vless"&&(typeof s.flow<"u"||s["reality-opts"])?!1:s["underlying-proxy"]||s["dialer-proxy"]?(I.error(`Clash \u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${s.name}`),!1):!0).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"&&ae(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}function hh(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>!["ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","wireguard","hysteria","hysteria2","ssh","juicity"].includes(s.type)||s.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(s.cipher)||s.type==="snell"&&String(s.version)==="4"||s.type==="vless"&&s["reality-opts"]&&!["xtls-rprx-vision"].includes(s.flow)?!1:s["underlying-proxy"]||s["dialer-proxy"]?(I.error(`Stash \u6682\u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${s.name}. \u8BF7\u4F7F\u7528 \u4EE3\u7406\u7684\u8F6C\u53D1\u94FE https://stash.wiki/proxy-protocols/proxy-groups#relay`),!1):!0).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ae(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),(!s.token||s.token.length===0)&&!ae(s,"version")&&(s.version=5)):s.type==="hysteria"?(ae(s,"auth_str")&&!ae(s,"auth-str")&&(s["auth-str"]=s.auth_str),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ae(s,"down")&&!ae(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ae(s,"up")&&!ae(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ae(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ae(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="hysteria2"?(ae(s,"password")&&!ae(s,"auth")&&(s.auth=s.password,delete s.password),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ae(s,"down")&&!ae(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ae(s,"up")&&!ae(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ae(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ae(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"&&ae(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s["server-cert-fingerprint"]=s["tls-fingerprint"]),delete s["tls-fingerprint"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,s["test-url"]&&(s["benchmark-url"]=s["test-url"],delete s["test-url"]),s["test-timeout"]&&(s["benchmark-timeout"]=s["test-timeout"],delete s["test-timeout"]),delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var o9="Loon",Hs={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function S0(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return u9(t);case"ssr":return c9(t);case"trojan":return l9(t);case"vmess":return f9(t,n["include-unsupported-proxy"]);case"vless":return h9(t,n["include-unsupported-proxy"]);case"http":return p9(t);case"socks5":return d9(t);case"wireguard":return g9(t);case"hysteria2":return m9(t)}throw new Error(`Platform ${o9} does not support proxy type: ${t.type}`)}}}function u9(e){let t=new rt(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}"`),ae(e,"plugin")){if(e.plugin==="obfs")t.append(`,obfs-name=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(ae(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,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["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=Hs[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function c9(e){let t=new rt(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"),ae(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,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e["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=Hs[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function l9(e){let t=new rt(e);if(t.append(`${e.name}=trojan,${e.server},${e.port},"${e.password}"`),e.network==="tcp"&&delete e.network,ae(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=Hs[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function f9(e){let t=!!e["reality-opts"],r=new rt(e);if(r.append(`${e.name}=vmess,${e.server},${e.port},${e.cipher},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ae(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 i=e["http-opts"]?.path,a=e["http-opts"]?.headers?.Host;r.appendIfPresent(`,path=${Array.isArray(i)?i[0]:i}`,"http-opts.path"),r.appendIfPresent(`,host=${Array.isArray(a)?a[0]:a}`,"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")),ae(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=Hs[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function h9(e){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 rt(e);if(n.append(`${e.name}=vless,${e.server},${e.port},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ae(e,"network"))if(e.network==="ws")n.append(",transport=ws"),n.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),n.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){n.append(",transport=http");let a=e["http-opts"]?.path,s=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(a)?a[0]:a}`,"http-opts.path"),n.appendIfPresent(`,host=${Array.isArray(s)?s[0]:s}`,"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 i=Hs[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function p9(e){let t=new rt(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=Hs[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function d9(e){let t=new rt(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=Hs[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function g9(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 rt(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(u=>ur(u));let s=e.dns.find(u=>vr(u));s||(s=e.dns.find(u=>!vr(u)&&!ur(u))),e.dns=s}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 i=e["preshared-key"]??e["pre-shared-key"];i&&(i=`,preshared-key="${i}"`),t.append(`,peers=[{public-key="${e["public-key"]}",allowed-ips="${r??"0.0.0.0/0,::/0"}",endpoint=${e.server}:${e.port}${n??""}${i??""}}]`);let a=Hs[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${a}`,"ip-version"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),t.toString()}function m9(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new rt(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=Hs[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function Nu(){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 i in r)r[i]==null&&delete r[i];switch(["trojan","tuic","hysteria","hysteria2","juicity"].includes(r.type)&&delete r.tls,!["vmess"].includes(r.type)&&r.server&&ur(r.server)&&(r.server=`[${r.server}]`),r.type){case"socks5":n=`socks://${encodeURIComponent(Et.encode(`${r.username??""}:${r.password??""}`))}@${r.server}:${r.port}#${r.name}`;break;case"ss":let i=`${r.cipher}:${r.password}`;if(n=`ss://${r.cipher?.startsWith("2022-blake3-")?`${encodeURIComponent(r.cipher)}:${encodeURIComponent(r.password)}`:Et.encode(i)}@${r.server}:${r.port}${r.plugin?"/":""}`,r.plugin){n+="?plugin=";let ue=r["plugin-opts"];switch(r.plugin){case"obfs":n+=encodeURIComponent(`simple-obfs;obfs=${ue.mode}${ue.host?";obfs-host="+ue.host:""}`);break;case"v2ray-plugin":n+=encodeURIComponent(`v2ray-plugin;obfs=${ue.mode}${ue.host?";obfs-host"+ue.host:""}${ue.tls?";tls":""}`);break;case"shadow-tls":n+=encodeURIComponent(`shadow-tls;host=${ue.host};password=${ue.password};version=${ue.version}`);break;default:throw new Error(`Unsupported plugin option: ${r.plugin}`)}}r["udp-over-tcp"]&&(n=`${n}${r.plugin?"&":"?"}uot=1`),r.tfo&&(n=`${n}${r.plugin||r["udp-over-tcp"]?"&":"?"}tfo=1`),n+=`#${encodeURIComponent(r.name)}`;break;case"ssr":n=`${r.server}:${r.port}:${r.protocol}:${r.cipher}:${r.obfs}:${Et.encode(r.password)}/`,n+=`?remarks=${Et.encode(r.name)}${r["obfs-param"]?"&obfsparam="+Et.encode(r["obfs-param"]):""}${r["protocol-param"]?"&protocolparam="+Et.encode(r["protocol-param"]):""}`,n="ssr://"+Et.encode(n);break;case"vmess":let a="",s=r.network||"tcp";if(r.network==="http"?(s="tcp",a="http"):r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(s="httpupgrade"),n={v:"2",ps:r.name,add:r.server,port:`${r.port}`,id:r.uuid,aid:`${r.alterId||0}`,scy:r.cipher,net:s,type:a,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 ue=r[`${r.network}-opts`]?.path,_e=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`]):(ue&&(n.path=Array.isArray(ue)?ue[0]:ue),_e&&(n.host=Array.isArray(_e)?_e[0]:_e))}n="vmess://"+Et.encode(JSON.stringify(n));break;case"vless":let u="none",l=r["reality-opts"],f="",d="",E="";if(l){u="reality";let ue=r["reality-opts"]?.["public-key"];ue&&(d=`&pbk=${encodeURIComponent(ue)}`);let _e=r["reality-opts"]?.["short-id"];_e&&(f=`&sid=${encodeURIComponent(_e)}`);let He=r["reality-opts"]?.["_spider-x"];He&&(E=`&spx=${encodeURIComponent(He)}`)}else r.tls&&(u="tls");let p="";r.alpn&&(p=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let h="";r["skip-cert-verify"]&&(h="&allowInsecure=1");let A="";r.sni&&(A=`&sni=${encodeURIComponent(r.sni)}`);let m="";r["client-fingerprint"]&&(m=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let S="";r.flow&&(S=`&flow=${encodeURIComponent(r.flow)}`);let w="";r._extra&&(w=`&extra=${encodeURIComponent(r._extra)}`);let y="";r._mode&&(y=`&mode=${encodeURIComponent(r._mode)}`);let _=r.network;r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(_="httpupgrade");let B=`&type=${encodeURIComponent(_)}`;if(["grpc"].includes(r.network)){B+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`;let ue=r[`${r.network}-opts`]?.["_grpc-authority"];ue&&(B+=`&authority=${encodeURIComponent(ue)}`)}let D=r[`${r.network}-opts`]?.[`${r.network}-service-name`],j=r[`${r.network}-opts`]?.path,q=r[`${r.network}-opts`]?.headers?.Host;j&&(B+=`&path=${encodeURIComponent(Array.isArray(j)?j[0]:j)}`),q&&(B+=`&host=${encodeURIComponent(Array.isArray(q)?q[0]:q)}`),D&&(B+=`&serviceName=${encodeURIComponent(D)}`),r.network==="kcp"&&(r.seed&&(B+=`&seed=${encodeURIComponent(r.seed)}`),r.headerType&&(B+=`&headerType=${encodeURIComponent(r.headerType)}`)),n=`vless://${r.uuid}@${r.server}:${r.port}?security=${encodeURIComponent(u)}${B}${p}${h}${A}${m}${S}${f}${E}${d}${y}${w}#${encodeURIComponent(r.name)}`;break;case"trojan":let F="";if(r.network){let ue=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(ue="httpupgrade"),F=`&type=${encodeURIComponent(ue)}`,["grpc"].includes(r.network)){let Sr=r[`${r.network}-opts`]?.[`${r.network}-service-name`],Ht=r[`${r.network}-opts`]?.["_grpc-authority"];Sr&&(F+=`&serviceName=${encodeURIComponent(Sr)}`),Ht&&(F+=`&authority=${encodeURIComponent(Ht)}`),F+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let _e=r[`${r.network}-opts`]?.path,He=r[`${r.network}-opts`]?.headers?.Host;_e&&(F+=`&path=${encodeURIComponent(Array.isArray(_e)?_e[0]:_e)}`),He&&(F+=`&host=${encodeURIComponent(Array.isArray(He)?He[0]:He)}`)}let P="";r["client-fingerprint"]&&(P=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let L="";r.alpn&&(L=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let M=r["reality-opts"],V="",W="",G="",z="",X="",ie="";if(M){z="&security=reality";let ue=r["reality-opts"]?.["public-key"];ue&&(W=`&pbk=${encodeURIComponent(ue)}`);let _e=r["reality-opts"]?.["short-id"];_e&&(V=`&sid=${encodeURIComponent(_e)}`);let He=r["reality-opts"]?.["_spider-x"];He&&(G=`&spx=${encodeURIComponent(He)}`),r._extra&&(ie=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(X=`&mode=${encodeURIComponent(r._mode)}`)}n=`trojan://${r.password}@${r.server}:${r.port}?sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}${F}${L}${P}${z}${V}${W}${G}${X}${ie}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let Se=[];r["hop-interval"]&&Se.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&Se.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&Se.push("insecure=1"),r.obfs&&(Se.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&Se.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&Se.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&Se.push(`mport=${r.ports}`),r["tls-fingerprint"]&&Se.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&Se.push("fastopen=1"),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${Se.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let we=[];Object.keys(r).forEach(ue=>{if(!["name","type","server","port"].includes(ue)){let _e=ue.replace(/-/,"_");["alpn"].includes(ue)?r[ue]&&we.push(`${_e}=${encodeURIComponent(Array.isArray(r[ue])?r[ue][0]:r[ue])}`):["skip-cert-verify"].includes(ue)?r[ue]&&we.push("insecure=1"):["tfo","fast-open"].includes(ue)?r[ue]&&!we.includes("fastopen=1")&&we.push("fastopen=1"):["ports"].includes(ue)?we.push(`mport=${r[ue]}`):["auth-str"].includes(ue)?we.push(`auth=${r[ue]}`):["up"].includes(ue)?we.push(`upmbps=${r[ue]}`):["down"].includes(ue)?we.push(`downmbps=${r[ue]}`):["_obfs"].includes(ue)?we.push(`obfs=${r[ue]}`):["obfs"].includes(ue)?we.push(`obfsParam=${r[ue]}`):["sni"].includes(ue)?we.push(`peer=${r[ue]}`):r[ue]&&!/^_/i.test(ue)&&we.push(`${_e}=${encodeURIComponent(r[ue])}`)}}),n=`hysteria://${r.server}:${r.port}?${we.join("&")}#${encodeURIComponent(r.name)}`;break;case"tuic":if(!r.token||r.token.length===0){let ue=[];Object.keys(r).forEach(_e=>{if(!["name","type","uuid","password","server","port","tls"].includes(_e)){let He=_e.replace(/-/,"_");["alpn"].includes(_e)?r[_e]&&ue.push(`${He}=${encodeURIComponent(Array.isArray(r[_e])?r[_e][0]:r[_e])}`):["skip-cert-verify"].includes(_e)?r[_e]&&ue.push("allow_insecure=1"):["tfo","fast-open"].includes(_e)?r[_e]&&!ue.includes("fast_open=1")&&ue.push("fast_open=1"):["disable-sni","reduce-rtt"].includes(_e)&&r[_e]?ue.push(`${He.replace(/-/g,"_")}=1`):["congestion-controller"].includes(_e)?ue.push(`congestion_control=${r[_e]}`):r[_e]&&!/^_/i.test(_e)&&ue.push(`${He.replace(/-/g,"_")}=${encodeURIComponent(r[_e])}`)}}),n=`tuic://${encodeURIComponent(r.uuid)}:${encodeURIComponent(r.password)}@${r.server}:${r.port}?${ue.join("&")}#${encodeURIComponent(r.name)}`}break;case"anytls":let Ie=[];Object.keys(r).forEach(ue=>{if(!["name","type","password","server","port","tls"].includes(ue)){let _e=ue.replace(/-/,"_");["alpn"].includes(ue)?r[ue]&&Ie.push(`${_e}=${encodeURIComponent(Array.isArray(r[ue])?r[ue][0]:r[ue])}`):["skip-cert-verify"].includes(ue)?r[ue]&&Ie.push("insecure=1"):["udp"].includes(ue)?r[ue]&&Ie.push("udp=1"):r[ue]&&!/^_/i.test(ue)&&Ie.push(`${_e.replace(/-/g,"_")}=${encodeURIComponent(r[ue])}`)}}),n=`anytls://${encodeURIComponent(r.password)}@${r.server}:${r.port}/?${Ie.join("&")}#${encodeURIComponent(r.name)}`;break;case"wireguard":let Ve=[];Object.keys(r).forEach(ue=>{["name","type","server","port","ip","ipv6","private-key"].includes(ue)||(["public-key"].includes(ue)?Ve.push(`publickey=${r[ue]}`):["udp"].includes(ue)?r[ue]&&Ve.push(`${ue}=1`):r[ue]&&!/^_/i.test(ue)&&Ve.push(`${ue}=${encodeURIComponent(r[ue])}`))}),r.ip&&r.ipv6?Ve.push(`address=${r.ip}/32,${r.ipv6}/128`):r.ip?Ve.push(`address=${r.ip}/32`):r.ipv6&&Ve.push(`address=${r.ipv6}/128`),n=`wireguard://${encodeURIComponent(r["private-key"])}@${r.server}:${r.port}/?${Ve.join("&")}#${encodeURIComponent(r.name)}`;break}return n}}}var v9=Nu();function nl(){return{type:"ALL",produce:r=>{let n=[];return r.map(i=>{try{n.push(v9.produce(i))}catch(a){I.error(`Cannot produce proxy: ${JSON.stringify(i,null,2)} Reason: ${a}`)}}),Et.encode(n.join(` `))}}}var E9="QX";function il(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return w9(t);case"ssr":return A9(t);case"trojan":return y9(t);case"vmess":return S9(t);case"http":return C9(t);case"socks5":return _9(t);case"vless":return b9(t)}throw new Error(`Platform ${E9} does not support proxy type: ${t.type}`)}}}function w9(e){let t=new rt(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}`),Yn(e)&&(e.tls=!0),ae(e,"plugin")){if(e.plugin==="obfs"){let i=e["plugin-opts"];r(`,obfs=${i.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 Yn(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 A9(e){let t=new rt(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 y9(e){let t=new rt(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`trojan=${e.server}:${e.port}`),r(`,password=${e.password}`),ae(e,"network"))if(e.network==="ws")Yn(e)?r(",obfs=wss"):r(",obfs=ws"),n(`,obfs-uri=${e["ws-opts"]?.path}`,"ws-opts.path"),n(`,obfs-host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);return e.network!=="ws"&&Yn(e)&&r(",over-tls=true"),Yn(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 S9(e){let t=new rt(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);r(`vmess=${e.server}:${e.port}`);let i;if(e.cipher==="auto"?i="chacha20-ietf-poly1305":i=e.cipher,r(`,method=${i}`),r(`,password=${e.uuid}`),Yn(e)&&(e.tls=!0),ae(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return Yn(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")),ae(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 b9(e){if(typeof e.flow<"u"||e["reality-opts"])throw new Error("VLESS XTLS/REALITY is not supported");let t=new rt(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}`),Yn(e)&&(e.tls=!0),ae(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 a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return Yn(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 C9(e){let t=new rt(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"),Yn(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),Yn(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 _9(e){let t=new rt(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"),Yn(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),Yn(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 Yn(e){return e.tls}function sl(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&String(s.version)==="4"?!1:!["mieru"].includes(s.type)).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ae(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ae(s,"version")&&(s.version=5)):s.type==="hysteria"?(ae(s,"auth_str")&&!ae(s,"auth-str")&&(s["auth-str"]=s.auth_str),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="hysteria2"?(s["obfs-password"]&&s.obfs=="salamander"&&(s.obfs=s["obfs-password"],delete s["obfs-password"]),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"?ae(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"&&ae(s,"shadow-tls-password")&&!ae(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]),["vmess","vless"].includes(s.type)&&s.network==="http"){let u=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(u)&&(s["http-opts"].path=[u]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let u=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(u)&&(s["h2-opts"].path=u[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let u in s)(s[u]==null||/^_/i.test(u))&&delete s[u];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var F9="Surfboard";function ph(){return{produce:t=>{switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return I9(t);case"trojan":return $9(t);case"vmess":return D9(t);case"http":return B9(t);case"socks5":return R9(t);case"wireguard-surge":return P9(t)}throw new Error(`Platform ${F9} does not support proxy type: ${t.type}`)}}}function I9(e){let t=new rt(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"),ae(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 $9(e){let t=new rt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),rw(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 D9(e){let t=new rt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),rw(t,e),ae(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 B9(e){let t=new rt(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 R9(e){let t=new rt(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 P9(e){let t=new rt(e);return t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.toString()}function rw(e,t){if(ae(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ae(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ae(t,"ws-opts.headers"))){let r=t["ws-opts"].headers,n=Object.keys(r).map(i=>{let a=r[i];return["Host"].includes(i)&&(a=`"${a}"`),`${i}:${a}`}).join("|");Hi(n)&&e.append(`,ws-headers=${n}`)}}else throw new Error(`network ${t.network} is unsupported`)}var Rn=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},Ms=(e,t)=>{["tcp","udp"].includes(e._network)&&(t.network=e._network)},Wn=(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},es=(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))))},b0=(e,t)=>{let r={type:"ws",headers:{}};if(e["ws-opts"]){let{path:n="",headers:i={}}=e["ws-opts"];if(n!==""&&(r.path=`${n}`),Object.keys(i).length>0){let a={};for(let u of Object.keys(i)){let l=i[u];l!==""&&(Array.isArray(l)||(l=[`${l}`]),l.length>0&&(a[u]=l))}let{Host:s}=a;if(s.length===1)for(let u of`Host:${s[0]}`.split(` `)){let[l,f]=u.split(":");f.trim()!==""&&(a[l.trim()]=f.trim().split(","))}r.headers=a}}if(e["ws-headers"]){let n={};for(let a of Object.keys(e["ws-headers"])){let s=e["ws-headers"][a];s!==""&&(Array.isArray(s)||(s=[`${s}`]),s.length>0&&(n[a]=s))}let{Host:i}=n;if(i.length===1)for(let a of`Host:${i[0]}`.split(` `)){let[s,u]=a.split(":");u.trim()!==""&&(n[s.trim()]=u.trim().split(","))}for(let a of Object.keys(n))r.headers[a]=n[a]}if(e["ws-path"]&&e["ws-path"]!==""&&(r.path=`${e["ws-path"]}`),r.path){let n=/^(.*?)(?:\?ed=(\d+))?$/,[i,a="",s=""]=n.exec(r.path);r.path=a,s!==""&&(r.early_data_header_name="Sec-WebSocket-Protocol",r.max_early_data=parseInt(s,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 i=r.headers[n];i.length===1&&(r.headers[n]=i[0])}t.transport=r},T9=(e,t)=>{let r={type:"http",headers:{}};if(e["http-opts"]){let{method:n="",path:i="",headers:a={}}=e["http-opts"];n!==""&&(r.method=n),Array.isArray(i)?r.path=`${i[0]}`:i!==""&&(r.path=`${i}`);for(let s of Object.keys(a)){let u=a[s];if(u!==""){if(s.toLowerCase()==="host"){let l=u;Array.isArray(l)||(l=`${l}`.split(",").map(f=>f.trim())),l.length>0&&(r.host=l);continue}Array.isArray(u)||(u=`${u}`.split(",").map(l=>l.trim())),u.length>0&&(r.headers[s]=u)}}}if(e["http-host"]&&e["http-host"]!==""){let n=e["http-host"];Array.isArray(n)||(n=`${n}`.split(",").map(i=>i.trim())),n.length>0&&(r.host=n)}if(r.host){if(e["http-path"]&&e["http-path"]!==""){let n=e["http-path"];Array.isArray(n)?r.path=`${n[0]}`:n!==""&&(r.path=`${n}`)}t.tls.insecure&&(t.tls.server_name=r.host[0]),r.host.length===1&&(r.host=r.host[0]);for(let n of Object.keys(r.headers)){let i=r.headers[n];i.length===1&&(r.headers[n]=i[0])}t.transport=r}},O9=(e,t)=>{let r={type:"http"};if(e["h2-opts"]){let{host:n="",path:i=""}=e["h2-opts"];i!==""&&(r.path=`${i}`),n!==""&&(Array.isArray(n)||(n=`${n}`.split(",").map(a=>a.trim())),n.length>0&&(r.host=n))}if(e["h2-host"]&&e["h2-host"]!==""){let n=e["h2-host"];Array.isArray(n)||(n=`${n}`.split(",").map(i=>i.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},C0=(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},va=(e,t)=>{e.tls&&(t.tls.enabled=!0),e.servername&&e.servername!==""&&(t.tls.server_name=e.servername),e.peer&&e.peer!==""&&(t.tls.server_name=e.peer),e.sni&&e.sni!==""&&(t.tls.server_name=e.sni),e["skip-cert-verify"]&&(t.tls.insecure=!0),e.insecure&&(t.tls.insecure=!0),e["disable-sni"]&&(t.tls.disable_sni=!0),typeof e.alpn=="string"?t.tls.alpn=[e.alpn]:Array.isArray(e.alpn)&&(t.tls.alpn=e.alpn),e.ca&&(t.tls.certificate_path=`${e.ca}`),e.ca_str&&(t.tls.certificate=[e.ca_str]),e["ca-str"]&&(t.tls.certificate=[e["ca-str"]]),e["reality-opts"]&&(t.tls.reality={enabled:!0},e["reality-opts"]["public-key"]&&(t.tls.reality.public_key=e["reality-opts"]["public-key"]),e["reality-opts"]["short-id"]&&(t.tls.reality.short_id=e["reality-opts"]["short-id"]),t.tls.utls={enabled:!0}),!["hysteria","hysteria2","tuic"].includes(e.type)&&e["client-fingerprint"]&&e["client-fingerprint"]!==""&&(t.tls.utls={enabled:!0,fingerprint:e["client-fingerprint"]}),t.tls.enabled||delete t.tls},x9=(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),Wn(e,t),Rn(e,t),t},N9=(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),Wn(e,t),Rn(e,t),va(e,t),t},k9=(e={})=>{let t={tag:e.name,type:"socks",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,version:"5"};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp=!0),e["fast-open"]&&(t.udp_fragment=!0),Ms(e,t),Wn(e,t),Rn(e,t),t},L9=(e={})=>{let t={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:`${e.name}_shadowtls`},r={tag:`${e.name}_shadowtls`,type:"shadowtls",server:e.server,server_port:parseInt(`${e.port}`,10),version:e["plugin-opts"].version,password:e["plugin-opts"].password,tls:{enabled:!0,server_name:e["plugin-opts"].host,utls:{enabled:!0,fingerprint:e["client-fingerprint"]}}};if(r.server_port<0||r.server_port>65535)throw"\u7AEF\u53E3\u503C\u975E\u6CD5";return e["fast-open"]===!0&&(r.udp_fragment=!0),Wn(e,r),Rn(e,r),es(e.smux,t),{type:"ss-with-st",ssPart:t,stPart:r}},U9=(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),Ms(e,t),Wn(e,t),Rn(e,t),es(e.smux,t),e.plugin){let r=[];e.plugin==="obfs"&&(t.plugin="obfs-local",t.plugin_opts="",e["obfs-host"]&&(e["plugin-opts"].host=e["obfs-host"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"mode":r.push(`obfs=${e["plugin-opts"].mode}`);break;case"host":r.push(`obfs-host=${e["plugin-opts"].host}`);break;default:r.push(`${n}=${e["plugin-opts"][n]}`);break}})),e.plugin==="v2ray-plugin"&&(t.plugin="v2ray-plugin",e["ws-host"]&&(e["plugin-opts"].host=e["ws-host"]),e["ws-path"]&&(e["plugin-opts"].path=e["ws-path"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"tls":e["plugin-opts"].tls&&r.push("tls");break;case"host":r.push(`host=${e["plugin-opts"].host}`);break;case"path":r.push(`path=${e["plugin-opts"].path}`);break;case"headers":r.push(`headers=${JSON.stringify(e["plugin-opts"].headers)}`);break;case"mux":e["plugin-opts"].mux&&(t.multiplex={enabled:!0});break;default:r.push(`${n}=${e["plugin-opts"][n]}`)}})),t.plugin_opts=r.join(";")}return t},H9=(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),Wn(e,t),Rn(e,t),es(e.smux,t),t},M9=(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"&&b0(e,t),e.network==="h2"&&O9(e,t),e.network==="http"&&T9(e,t),e.network==="grpc"&&C0(e,t),Ms(e,t),Wn(e,t),Rn(e,t),va(e,t),es(e.smux,t),t},j9=(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==="xtls-rprx-vision"&&(t.flow=e.flow),e.network==="ws"&&b0(e,t),e.network==="grpc"&&C0(e,t),Ms(e,t),Wn(e,t),Rn(e,t),es(e.smux,t),va(e,t),t},q9=(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"&&C0(e,t),e.network==="ws"&&b0(e,t),Ms(e,t),Wn(e,t),Rn(e,t),va(e,t),es(e.smux,t),t},K9=(e={})=>{let t={tag:e.name,type:"hysteria",server:e.server,server_port:parseInt(`${e.port}`,10),disable_mtu_discovery:!1,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";e.auth_str&&(t.auth_str=`${e.auth_str}`),e["auth-str"]&&(t.auth_str=`${e["auth-str"]}`),e["fast-open"]&&(t.udp_fragment=!0);let r=new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");return r.test(`${e.up}`)&&!`${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)),Ms(e,t),va(e,t),Rn(e,t),Wn(e,t),es(e.smux,t),t},V9=(e={})=>{let t={tag:e.name,type:"hysteria2",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,obfs:{},tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["hop-interval"]&&(t.hop_interval=/^\d+$/.test(e["hop-interval"])?`${e["hop-interval"]}s`:e["hop-interval"]),e.ports&&(t.server_ports=e.ports.split(/\s*,\s*/).map(r=>r.replace(/\s*-\s*/g,":"))),e.up&&(t.up_mbps=parseInt(`${e.up}`,10)),e.down&&(t.down_mbps=parseInt(`${e.down}`,10)),e.obfs==="salamander"&&(t.obfs.type="salamander"),e["obfs-password"]&&(t.obfs.password=e["obfs-password"]),t.obfs.type||delete t.obfs,Ms(e,t),va(e,t),Wn(e,t),Rn(e,t),es(e.smux,t),t},G9=(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`),Ms(e,t),Wn(e,t),Rn(e,t),va(e,t),es(e.smux,t),t},z9=(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`),Rn(e,t),va(e,t),t},Y9=(e={})=>{let t=["ip","ipv6"].map(n=>e[n]).map(n=>{if(vr(n))return`${n}/32`;if(ur(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 i={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")i.reserved.push(n.reserved);else if(Array.isArray(n.reserved))for(let a of n.reserved)i.reserved.push(a);else delete i.reserved;n["pre-shared-key"]&&(i.pre_shared_key=n["pre-shared-key"]),r.peers.push(i)}}return Ms(e,r),Wn(e,r),Rn(e,r),es(e.smux,r),r};function dh(){return{type:"ALL",produce:(r,n,i={})=>{let a=[];return zn().produce(r,"internal",{"include-unsupported-proxy":!0}).map(s=>{try{switch(s.type){case"ssh":a.push(x9(s));break;case"http":a.push(N9(s));break;case"socks5":if(s.tls)throw new Error(`Platform sing-box does not support proxy type: ${s.type} with tls`);a.push(k9(s));break;case"ss":if(s.plugin==="shadow-tls"){let{ssPart:u,stPart:l}=L9(s);a.push(u),a.push(l)}else a.push(U9(s));break;case"ssr":if(i["include-unsupported-proxy"])a.push(H9(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type}`);break;case"vmess":if(!s.network||["ws","grpc","h2","http"].includes(s.network))a.push(M9(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with network ${s.network}`);break;case"vless":if(!s.flow||["xtls-rprx-vision"].includes(s.flow))a.push(j9(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with flow ${s.flow}`);break;case"trojan":if(!s.flow)a.push(q9(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with flow ${s.flow}`);break;case"hysteria":a.push(K9(s));break;case"hysteria2":a.push(V9(s,i["include-unsupported-proxy"]));break;case"tuic":if(!s.token||s.token.length===0)a.push(G9(s));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":a.push(Y9(s));break;case"anytls":a.push(z9(s));break;default:throw new Error(`Platform sing-box does not support proxy type: ${s.type}`)}}catch(u){I.error(u.message??u)}}),n==="internal"?a:JSON.stringify({outbounds:a},null,2)}}}function gh(){return{type:"ALL",produce:(r,n)=>{let i=r.filter(a=>!(!["http","socks5","ss","trojan","hysteria2","vless","vmess","tuic"].includes(a.type)||a.type==="ss"&&(a.plugin==="obfs"&&!["http","tls"].includes(a["plugin-opts"]?.mode)||!["chacha20-ietf-poly1305","chacha20-poly1305","aes-256-gcm","aes-128-gcm","none","tbale","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","cast5-cfb","des-cfb","idea-cfb","rc2-cfb","seed-cfb","salsa20","chacha20","chacha20-ietf","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(a.cipher))||a.type==="vmess"&&!["http","ws","tcp"].includes(a.network)&&a.network||a.type==="trojan"&&!["http","ws","tcp"].includes(a.network)&&a.network||a.type==="vless"&&(typeof a.flow<"u"||a["reality-opts"]||!["http","ws","tcp"].includes(a.network)&&a.network)||a.type==="tuic"&&a.token&&a.token.length!==0)).map(a=>{let s={...a};a.tls&&!a.sni&&(a.sni=a.server);let u=a.prev_hop||a["underlying-proxy"]||a["dialer-proxy"]||a.detour;if(a.type==="http")a={type:"http",name:a.name,server:a.server,port:a.port,username:a.username,password:a.password,tfo:a.tfo||a["fast-open"],next_hop:a.next_hop};else if(a.type==="socks5")a={type:"socks5",name:a.name,server:a.server,port:a.port,username:a.username,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop};else if(a.type==="ss")a={type:"shadowsocks",name:a.name,method:a.cipher==="chacha20-ietf-poly1305"?"chacha20-poly1305":a.cipher,server:a.server,port:a.port,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop},s.plugin==="obfs"&&(a.obfs=s["plugin-opts"].mode,a.obfs_host=s["plugin-opts"].host,a.obfs_uri=s["plugin-opts"].path);else if(a.type==="hysteria2")a={type:"hysteria2",name:a.name,server:a.server,port:a.port,auth:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,sni:a.sni,skip_tls_verify:a["skip-cert-verify"],port_hopping:a.ports,port_hopping_interval:a["hop-interval"]},s["obfs-password"]&&s.obfs=="salamander"&&(a.obfs="salamander",a.obfs_password=s["obfs-password"]);else if(a.type==="tuic")a={type:"tuic",name:a.name,server:a.server,port:a.port,uuid:a.uuid,password:a.password,next_hop:a.next_hop,sni:a.sni,alpn:Array.isArray(a.alpn)?a.alpn:[a.alpn||"h3"],skip_tls_verify:a["skip-cert-verify"],port_hopping:a.ports,port_hopping_interval:a["hop-interval"]};else if(a.type==="trojan")a.network==="ws"&&(a.websocket={path:a["ws-opts"]?.path,host:a["ws-opts"]?.headers?.Host}),a={type:"trojan",name:a.name,server:a.server,port:a.port,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,sni:a.sni,skip_tls_verify:a["skip-cert-verify"],websocket:a.websocket};else if(a.type==="vmess"){let l=a.cipher;l&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(l)&&(l="auto"),a.network==="ws"?a.transport={[a.tls?"wss":"ws"]:{path:a["ws-opts"]?.path,headers:{Host:a["ws-opts"]?.headers?.Host},sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}:a.network==="http"?a.transport={http1:{method:a["http-opts"]?.method,path:Array.isArray(a["http-opts"]?.path)?a["http-opts"]?.path[0]:a["http-opts"]?.path,headers:{Host:Array.isArray(a["http-opts"]?.headers?.Host)?a["http-opts"]?.headers?.Host[0]:a["http-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:a.network==="h2"?a.transport={http2:{method:a["h2-opts"]?.method,path:Array.isArray(a["h2-opts"]?.path)?a["h2-opts"]?.path[0]:a["h2-opts"]?.path,headers:{Host:Array.isArray(a["h2-opts"]?.headers?.Host)?a["h2-opts"]?.headers?.Host[0]:a["h2-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:(a.network==="tcp"||!a.network)&&a.tls&&(a.transport={tls:{sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}),a={type:"vmess",name:a.name,server:a.server,port:a.port,user_id:a.uuid,security:l,tfo:a.tfo||a["fast-open"],legacy:a.legacy,udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,transport:a.transport}}else a.type==="vless"&&(a.network==="ws"?a.transport={[a.tls?"wss":"ws"]:{path:a["ws-opts"]?.path,headers:{Host:a["ws-opts"]?.headers?.Host},sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}:a.network==="http"?a.transport={http:{method:a["http-opts"]?.method,path:Array.isArray(a["http-opts"]?.path)?a["http-opts"]?.path[0]:a["http-opts"]?.path,headers:{Host:Array.isArray(a["http-opts"]?.headers?.Host)?a["http-opts"]?.headers?.Host[0]:a["http-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:(a.network==="tcp"||!a.network)&&(a.transport={[a.tls?"tls":"tcp"]:{sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}),a={type:"vless",name:a.name,server:a.server,port:a.port,user_id:a.uuid,security:a.cipher,tfo:a.tfo||a["fast-open"],legacy:a.legacy,udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,transport:a.transport});if(["http","socks5","ss","trojan","vless","vmess"].includes(s.type)){if(ae(s,"shadow-tls-password")){if(s["shadow-tls-version"]!=3)throw new Error(`shadow-tls version ${s["shadow-tls-version"]} is not supported`);a.shadow_tls={password:s["shadow-tls-password"],sni:s["shadow-tls-sni"]}}else if(["shadow-tls"].includes(s.plugin)&&s["plugin-opts"]){if(s["plugin-opts"].version!=3)throw new Error(`shadow-tls version ${s["plugin-opts"].version} is not supported`);a.shadow_tls={password:s["plugin-opts"].password,sni:s["plugin-opts"].host}}}if(delete a.subName,delete a.collectionName,delete a.id,delete a.resolved,delete a["no-resolve"],n!=="internal")for(let l in a)(a[l]==null||/^_/i.test(l))&&delete a[l];return{[a.type]:{...a,type:void 0,prev_hop:u}}});return n==="internal"?i:`proxies: `+i.map(a=>" - "+JSON.stringify(a)+` `).join("")}}}function nw(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var mh={qx:il(),QX:il(),QuantumultX:il(),surge:xu(),Surge:xu(),SurgeMac:A0(),Loon:S0(),Clash:y0(),meta:zn(),clashmeta:zn(),"clash.meta":zn(),"Clash.Meta":zn(),ClashMeta:zn(),mihomo:zn(),Mihomo:zn(),uri:Nu(),URI:Nu(),v2:nl(),v2ray:nl(),V2Ray:nl(),json:nw(),JSON:nw(),stash:hh(),Stash:hh(),shadowrocket:sl(),Shadowrocket:sl(),ShadowRocket:sl(),surfboard:ph(),Surfboard:ph(),singbox:dh(),"sing-box":dh(),egern:gh(),Egern:gh()};var cA=Cn(hl()),nR=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleWebsocket() { if (obfs.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers", obfs['ws-headers']); if (proxy['ws-opts'] && proxy['ws-opts']['headers'] && proxy['ws-opts']['headers'].Host) { proxy['ws-opts']['headers'].Host = proxy['ws-opts']['headers'].Host.replace(/^"(.*)"$/, '$1') } } } function handleShadowTLS() { if (proxy['shadow-tls-password'] && !proxy['shadow-tls-version']) { proxy['shadow-tls-version'] = 2; } } } start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) { return proxy; } shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* { proxy.type = "ss"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } handleShadowTLS(); } vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/tls_fingerprint/tls_verification/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; // 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/fast_open/tfo/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "hysteria2"; handleShadowTLS(); } socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; handleShadowTLS(); } socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_fingerprint/tls_verification/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; proxy.tls = true; handleShadowTLS(); } direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* { proxy.type = "direct"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } port_hopping_interval = comma "port-hopping-interval" equals match:$[0-9]+ { proxy["hop-interval"] = parseInt(match.trim()); } username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username; } password = comma match:[^,]+ { proxy.password = match.join(""); } tls = comma "tls" equals flag:bool { proxy.tls = flag; } sni = comma "sni" equals sni:("off"/domain) { if (sni === "off") { proxy["disable-sni"] = true; } else { proxy.sni = sni; } } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join(""); } snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); } usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join(""); } passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join(""); } vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; } method = comma "encrypt-method" equals cipher:cipher { proxy.cipher = cipher; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"idea-cfb"/"none"/"rc2-cfb"/"rc4-md5"/"rc4"/"salsa20"/"seed-cfb"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); ws = comma "ws" equals flag:bool { obfs.type = "ws"; } ws_headers = comma "ws-headers" equals headers:$[^,]+ { const pairs = headers.split("|"); const result = {}; pairs.forEach(pair => { const [key, value] = pair.trim().split(":"); result[key.trim()] = value.trim(); }) obfs["ws-headers"] = result; } ws_path = comma "ws-path" equals path:uri { obfs.path = path; } obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; }; obfs_uri = comma "obfs-uri" equals path:uri { obfs.path = path } uri = $[^,]+ udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } reuse = comma "reuse" equals flag:bool { proxy.reuse = flag; } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; } ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); } no_error_alert = comma "no-error-alert" equals match:[^,]+ { proxy["no-error-alert"] = match.join(""); } underlying_proxy = comma "underlying-proxy" equals match:[^,]+ { proxy["underlying-proxy"] = match.join(""); } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } test_url = comma "test-url" equals match:[^,]+ { proxy["test-url"] = match.join(""); } test_udp = comma "test-udp" equals match:[^,]+ { proxy["test-udp"] = match.join(""); } test_timeout = comma "test-timeout" equals match:$[0-9]+ { proxy["test-timeout"] = parseInt(match.trim()); } tos = comma "tos" equals match:$[0-9]+ { proxy.tos = parseInt(match.trim()); } interface = comma "interface" equals match:[^,]+ { proxy.interface = match.join(""); } allow_other_interface = comma "allow-other-interface" equals flag:bool { proxy["allow-other-interface"] = flag; } hybrid = comma "hybrid" equals flag:bool { proxy.hybrid = flag; } idle_timeout = comma "idle-timeout" equals match:$[0-9]+ { proxy["idle-timeout"] = parseInt(match.trim()); } private_key = comma "private-key" equals match:[^,]+ { proxy["keystore-private-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } server_fingerprint = comma "server-fingerprint" equals match:[^,]+ { proxy["server-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match.join(""); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); } alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); } uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,K0;function Jn(){return K0||(K0=cA.generate(nR)),K0}var lA=Cn(hl()),iR=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_host/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_host/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_host/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_host/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_host/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_host/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_host = comma sni:("tls-name"/"sni") equals host:domain { proxy.sni = host; } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); } flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); } public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } short_id = comma "short-id" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = match.join("").replace(/^"(.*)"$/, '$1'); } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; } ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join(""); proxy.obfs = 'salamander'; } 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 [^=,]+ `,V0;function ts(){return V0||(V0=lA.generate(iR)),V0}var fA=Cn(hl()),sR=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parse initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleObfs() { if (obfs.type === "ws" || obfs.type === "wss") { proxy.network = "ws"; if (obfs.type === 'wss') { proxy.tls = true; } $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers.Host", obfs.host); } else if (obfs.type === "over-tls") { proxy.tls = true; } else if (obfs.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", obfs.path); $set(proxy, "http-opts.headers.Host", obfs.host); } } } start = (trojan/shadowsocks/vmess/vless/http/socks5) { return proxy } trojan = "trojan" equals address (password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/obfs/obfs_host/obfs_uri/tag/udp_relay/udp_over_tcp/fast_open/server_check_url/others)* { proxy.type = "trojan"; handleObfs(); } shadowsocks = "shadowsocks" equals address (password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/udp_over_tcp_new/fast_open/tag/server_check_url/others)* { if (proxy.protocol || proxy.type === "ssr") { proxy.type = "ssr"; if (!proxy.protocol) { proxy.protocol = "origin"; } // handle ssr obfs if (obfs.host) proxy["obfs-param"] = obfs.host; if (obfs.type) proxy.obfs = obfs.type; } else { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts", { mode: obfs.type }); } else if (obfs.type === "ws" || obfs.type === "wss") { proxy.plugin = "v2ray-plugin"; $set(proxy, "plugin-opts.mode", "websocket"); if (obfs.type === "wss") { $set(proxy, "plugin-opts.tls", true); } } else if (obfs.type === 'over-tls') { throw new Error('ss over-tls is not supported'); } if (obfs.type) { $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } } vmess = "vmess" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead === 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/others)* { proxy.type = "vless"; proxy.cipher = proxy.cipher || "none"; handleObfs(); } http = "http" equals address (username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)*{ proxy.type = "http"; } socks5 = "socks5" equals address (username/password/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)* { proxy.type = "socks5"; } address = server:server ":" port:port { proxy.server = server; proxy.port = port; } server = ip/domain domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } ip = & { const start = peg$currPos; let end; let j = start; while (j < input.length) { if (input[j] === ",") break; if (input[j] === ":") end = j; j++; } peg$currPos = end || j; $.ip = input.substring(start, end).trim(); return true; } { return $.ip; } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); } password = comma "password" equals password:[^,]+ { proxy.password = password.join("").trim(); } uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); } method = comma "method" equals cipher:cipher { proxy.cipher = cipher; }; cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"none"/"rc2-cfb"/"rc4-md5-6"/"rc4-md5"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); aead = comma "aead" equals flag:bool { proxy.aead = flag; } udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); } 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; } 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" } `,G0;function qs(){return G0||(G0=fA.generate(sR)),G0}var hA=Cn(hl()),aR=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); } `,z0;function Y0(){return z0||(z0=hA.generate(aR)),z0}function pA(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 oR(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[i,a,s,u,l,f,d,E,p]=n.match(/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(d)d=parseInt(d,10);else{if(s)d=443;else if(a==="http")d=80;else throw I.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);I.info(`port is not present in line: ${n}, set to ${d}`)}return{name:p!=null?decodeURIComponent(p):`${a} ${f}:${d}`,type:a,tls:!!s,server:f,port:d,username:u!=null?decodeURIComponent(u):void 0,password:l!=null?decodeURIComponent(l):void 0}}}}function uR(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[i,a,s,u,l,f,d]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(l)l=parseInt(l,10);else throw I.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let E,p;if(s){let A=Et.decode(decodeURIComponent(s)).split(":");E=A[0],p=A[1]}return{name:d!=null?decodeURIComponent(d):`${a} ${u}:${l}`,type:"socks5",server:u,port:l,username:E,password:p}}}}function cR(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let i=n.split("ss://")[1],a=n.split("#")[1],s={type:"ss"};i=i.split("#")[0];let u=i.match(/@([^/?]*)(\/|\?|$)/),l=decodeURIComponent(i.split("@")[0]),f;l?.startsWith("2022-blake3-")?f=l:f=Et.decode(l);let d="";if(u)i.includes("?")&&(d=i.match(/(\?.*)$/)[1]);else{if(i.includes("?")){let S=i.match(/^(.*)(\?.*)$/);i=S[1],d=S[2]}if(i=Et.decode(i),d){if(/(&|\?)v2ray-plugin=/.test(d)){let w=d.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];w&&(s.plugin="v2ray-plugin",s["plugin-opts"]=JSON.parse(Et.decode(w)))}i=`${i}${d}`}f=i.match(/(^.*)@/)?.[1],u=i.match(/@([^/@]*)(\/|$)/)}let E=u[1],p=E.lastIndexOf(":");s.server=E.substring(0,p),s.port=`${E.substring(p+1)}`.match(/\d+/)?.[0];let h=f.match(/(^.*?):(.*$)/);s.cipher=h?.[1],s.password=h?.[2];let A=i.match(/[?&]plugin=([^&]+)/),m=i.match(/[?&]shadow-tls=([^&]+)/);if(A){let S=("plugin="+decodeURIComponent(A[1])).split(";"),w={};for(let y of S){let[_,B]=y.split("=");_&&(w[_]=B||!0)}switch(w.plugin){case"obfs-local":case"simple-obfs":s.plugin="obfs",s["plugin-opts"]={mode:w.obfs,host:Ut(w["obfs-host"])};break;case"v2ray-plugin":s.plugin="v2ray-plugin",s["plugin-opts"]={mode:"websocket",host:Ut(w["obfs-host"]),path:Ut(w.path),tls:ou(w.tls)};break;case"shadow-tls":{s.plugin="shadow-tls";let y=Ut(w.version);s["plugin-opts"]={host:Ut(w.host),password:Ut(w.password),version:y?parseInt(y,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${w.plugin}`)}}if(m){let S=JSON.parse(Et.decode(m[1])),w=Ut(S.version),y=Ut(S.address),_=Ut(S.port);s.plugin="shadow-tls",s["plugin-opts"]={host:Ut(S.host),password:Ut(S.password),version:w?parseInt(w,10):void 0},y&&(s.server=y),_&&(s.port=parseInt(_,10))}return/(&|\?)uot=(1|true)/i.test(d)&&(s["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(d)&&(s.tfo=!0),a!=null&&(a=decodeURIComponent(a)),s.name=a??`SS ${s.server}:${s.port}`,s}}}function lR(){return{name:"URI SSR Parser",test:n=>/^ssr:\/\//.test(n),parse:n=>{n=Et.decode(n.split("ssr://")[1]);let i=n.indexOf(":origin");i===-1&&(i=n.indexOf(":auth_"));let a=n.substring(0,i),s=a.substring(0,a.lastIndexOf(":")),u=a.substring(a.lastIndexOf(":")+1),l=n.substring(i+1).split("/?")[0].split(":"),f={type:"ssr",server:s,port:u,protocol:l[0],cipher:l[1],obfs:l[2],password:Et.decode(l[3])},d={};if(n=n.split("/?")[1].split("&"),n.length>1)for(let E of n){let[p,h]=E.split("=");h=h.trim(),h.length>0&&h!=="(null)"&&(d[p]=h)}return f={...f,name:d.remarks?Et.decode(d.remarks):f.server,"protocol-param":Ut(Et.decode(d.protoparam||"").replace(/\s/g,"")),"obfs-param":Ut(Et.decode(d.obfsparam||"").replace(/\s/g,""))},f}}}function fR(){return{name:"URI VMess Parser",test:n=>/^vmess:\/\//.test(n),parse:n=>{n=n.split("vmess://")[1];let i=Et.decode(n.replace(/\?.*?$/,""));if(/=\s*vmess/.test(i)){let a=i.split(",").map(l=>l.trim()),s={};for(let l of a)if(l.indexOf("=")!==-1){let[f,d]=l.split("=");s[f.trim()]=d.trim()}let u={name:a[0].split("=")[0].trim(),type:"vmess",server:a[1],port:a[2],cipher:Ut(a[3],"auto"),uuid:a[4].match(/^"(.*)"$/)[1],tls:s.obfs==="wss",udp:ou(s["udp-relay"]),tfo:ou(s["fast-open"]),"skip-cert-verify":au(s["tls-verification"])?!s["tls-verification"]:void 0};if(au(s.obfs))if(s.obfs==="ws"||s.obfs==="wss"){u.network="ws",u["ws-opts"].path=(Ut(s["obfs-path"])||'"/"').match(/^"(.*)"$/)[1];let l=s["obfs-header"];l&&l.indexOf("Host")!==-1&&(l=l.match(/Host:\s*([a-zA-Z0-9-.]*)/)[1]),Hi(l)&&(u["ws-opts"].headers={Host:l})}else throw new Error(`Unsupported obfs: ${s.obfs}`);return u}else{let a={};try{a=JSON.parse(i)}catch{let[E,p,h]=/(^[^?]+?)\/?\?(.*)$/.exec(n);i=Et.decode(p);for(let _ of h.split("&")){let[B,D]=_.split("="),j=D;j=decodeURIComponent(D),j.indexOf(",")===-1?a[B]=j:a[B]=j.split(",")}let[A,m,S,w,y]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(i);a.scy=m,a.id=S,a.port=y,a.add=w}let s=a.add,u=parseInt(ou(a.port),10),l={name:a.ps??a.remarks??a.remark??`VMess ${s}:${u}`,type:"vmess",server:s,port:u,cipher:["auto","aes-128-gcm","chacha20-poly1305","none"].includes(a.scy)?a.scy:"auto",uuid:a.id,alterId:parseInt(ou(a.aid??a.alterId,0),10),tls:["tls",!0,1,"1"].includes(a.tls),"skip-cert-verify":au(a.verify_cert)?!a.verify_cert:void 0};!l["skip-cert-verify"]&&au(a.allowInsecure)&&(l["skip-cert-verify"]=/(TRUE)|1/i.test(a.allowInsecure)),l.tls&&(a.sni&&a.sni!==""?l.sni=a.sni:a.peer&&a.peer!==""&&(l.sni=a.peer));let f=!1;if(a.net==="ws"||a.obfs==="websocket"?l.network="ws":["http"].includes(a.net)||["http"].includes(a.obfs)||["http"].includes(a.type)?l.network="http":["grpc","kcp","quic"].includes(a.net)?l.network=a.net:a.net==="httpupgrade"||l.network==="httpupgrade"?(l.network="ws",f=!0):(a.net==="h2"||l.network==="h2")&&(l.network="h2"),l.network){let d=a.host??a.obfsParam;try{let h=JSON.parse(d)?.Host;h&&(d=h)}catch{}let E=a.path;if(["ws"].includes(l.network)&&(E=E||"/"),l.network==="http"&&(d&&(d=d.split(",").map(p=>p.trim()),d=Array.isArray(d)?d[0]:d),E?E=Array.isArray(E)?E[0]:E:E="/"),E||d||["kcp","quic"].includes(l.network))if(["grpc"].includes(l.network))l[`${l.network}-opts`]={"grpc-service-name":Ut(E),"_grpc-type":Ut(a.type),"_grpc-authority":Ut(a.authority)};else if(["kcp","quic"].includes(l.network))l[`${l.network}-opts`]={[`_${l.network}-type`]:Ut(a.type),[`_${l.network}-host`]:Ut(Ut(d)),[`_${l.network}-path`]:Ut(E)};else{let p={path:Ut(E),headers:{Host:Ut(d)}};f&&(p["v2ray-http-upgrade"]=!0,p["v2ray-http-upgrade-fast-open"]=!0),l[`${l.network}-opts`]=p}else delete l.network}return l["client-fingerprint"]=a.fp,l.alpn=a.alpn?a.alpn.split(","):void 0,l}}}}function hR(){return{name:"URI VLESS Parser",test:n=>/^vless:\/\//.test(n),parse:n=>{n=n.split("vless://")[1];let i,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);if(!a){let[S,w,y]=/^(.*?)(\?.*?$)/.exec(n);n=`${Et.decode(w)}${y}`,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),i=!0}let[s,u,l,f,d,E="",p]=a;i&&(u=u.replace(/^.*?:/g,"")),f=parseInt(`${f}`,10),u=decodeURIComponent(u),p!=null&&(p=decodeURIComponent(p));let h={type:"vless",name:p,server:l,port:f,uuid:u},A={};for(let S of E.split("&")){let[w,y]=S.split("="),_=y;_=decodeURIComponent(y),A[w]=_}if(h.name=p??A.remarks??A.remark??`VLESS ${l}:${f}`,h.tls=A.security&&A.security!=="none",i&&/TRUE|1/i.test(A.tls)&&(h.tls=!0,A.security=A.security??"reality"),h.sni=A.sni||A.peer,h.flow=A.flow,!h.flow&&i&&A.xtls){let S=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][A.xtls];S&&(h.flow=S)}if(h["client-fingerprint"]=A.fp,h.alpn=A.alpn?A.alpn.split(","):void 0,h["skip-cert-verify"]=/(TRUE)|1/i.test(A.allowInsecure),["reality"].includes(A.security)){let S={};A.pbk&&(S["public-key"]=A.pbk),A.sid&&(S["short-id"]=A.sid),A.spx&&(S["_spider-x"]=A.spx),Object.keys(S).length>0&&(h[`${A.security}-opts`]=S)}let m=!1;if(h.network=A.type,h.network==="tcp"&&A.headerType==="http"?h.network="http":h.network==="httpupgrade"&&(h.network="ws",m=!0),!h.network&&i&&A.obfs&&(h.network=A.obfs,["none"].includes(h.network)&&(h.network="tcp")),["websocket"].includes(h.network)&&(h.network="ws"),h.network&&!["tcp","none"].includes(h.network)){let S={},w=A.host??A.obfsParam;if(w)if(A.obfsParam)try{let y=JSON.parse(w);S.headers=y}catch{S.headers={Host:w}}else S.headers={Host:w};A.serviceName?(S[`${h.network}-service-name`]=A.serviceName,["grpc"].includes(h.network)&&A.authority&&(S["_grpc-authority"]=A.authority)):i&&A.path&&(["ws","http","h2"].includes(h.network)||(S[`${h.network}-service-name`]=A.path,delete A.path)),A.path&&(S.path=A.path),["grpc"].includes(h.network)&&(S["_grpc-type"]=A.mode||"gun"),m&&(S["v2ray-http-upgrade"]=!0,S["v2ray-http-upgrade-fast-open"]=!0),Object.keys(S).length>0&&(h[`${h.network}-opts`]=S),h.network==="kcp"&&(A.seed&&(h.seed=A.seed),h.headerType=A.headerType||"none"),A.mode&&(h._mode=A.mode),A.extra&&(h._extra=A.extra)}return h}}}function pR(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{n=n.split(/anytls:\/\//)[1];let[i,a,s,u,l="",f]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a),u=parseInt(`${u}`,10),isNaN(u)&&(u=443),a=decodeURIComponent(a),f!=null&&(f=decodeURIComponent(f)),f=f??`AnyTLS ${s}:${u}`;let d={type:"anytls",name:f,server:s,port:u,password:a};for(let E of l.split("&")){let[p,h]=E.split("=");p=p.replace(/_/g,"-"),h=decodeURIComponent(h),["alpn"].includes(p)?d[p]=h?h.split(","):void 0:["insecure"].includes(p)?d["skip-cert-verify"]=/(TRUE)|1/i.test(h):["udp"].includes(p)?d[p]=/(TRUE)|1/i.test(h):d[p]=h}return d}}}function dR(){return{name:"URI Hysteria2 Parser",test:n=>/^(hysteria2|hy2):\/\//.test(n),parse:n=>{n=n.split(/(hysteria2|hy2):\/\//)[2];let i,[a,s,u,l,f,d,E,p,h,A,m="",S]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(f)?(f=parseInt(`${f}`,10),isNaN(f)&&(f=443)):f?(i=f,f=xc(i)):f=443,s=decodeURIComponent(s),S!=null&&(S=decodeURIComponent(S)),S=S??`Hysteria2 ${u}:${f}`;let w={type:"hysteria2",name:S,server:u,port:f,ports:i,password:s},y={};for(let D of m.split("&")){let[j,q]=D.split("="),F=q;F=decodeURIComponent(q),y[j]=F}w.sni=y.sni,!w.sni&&y.peer&&(w.sni=y.peer),y.obfs&&y.obfs!=="none"&&(w.obfs=y.obfs),y.mport&&(w.ports=y.mport),w["obfs-password"]=y["obfs-password"],w["skip-cert-verify"]=/(TRUE)|1/i.test(y.insecure),w.tfo=/(TRUE)|1/i.test(y.fastopen),w["tls-fingerprint"]=y.pinSHA256;let _=y["hop-interval"]||y.hop_interval;/^\d+$/.test(_)&&(w["hop-interval"]=parseInt(`${_}`,10));let B=y.keepalive;return/^\d+$/.test(B)&&(w.keepalive=parseInt(`${B}`,10)),w}}}function gR(){return{name:"URI Hysteria Parser",test:n=>/^(hysteria|hy):\/\//.test(n),parse:n=>{n=n.split(/(hysteria|hy):\/\//)[2];let[i,a,s,u,l,f="",d]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);u=parseInt(`${u}`,10),isNaN(u)&&(u=443),d!=null&&(d=decodeURIComponent(d)),d=d??`Hysteria ${a}:${u}`;let E={type:"hysteria",name:d,server:a,port:u},p={};for(let h of f.split("&")){let[A,m]=h.split("=");A=A.replace(/_/,"-"),m=decodeURIComponent(m),["alpn"].includes(A)?E[A]=m?m.split(","):void 0:["insecure"].includes(A)?E["skip-cert-verify"]=/(TRUE)|1/i.test(m):["auth"].includes(A)?E["auth-str"]=m:["mport"].includes(A)?E.ports=m:["obfsParam"].includes(A)?E.obfs=m:["upmbps"].includes(A)?E.up=m:["downmbps"].includes(A)?E.down=m:["obfs"].includes(A)?E._obfs=m||"":["fast-open","peer"].includes(A)?p[A]=m:E[A]=m}return!E.sni&&p.peer&&(E.sni=p.peer),!E["fast-open"]&&p.fastopen&&(E["fast-open"]=!0),E.protocol||(E.protocol="udp"),E}}}function mR(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[i,a,s,u,l="",f]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a);let[d,...E]=a.split(":"),p=E.join(":");u=parseInt(`${u}`,10),isNaN(u)&&(u=443),p=decodeURIComponent(p),f!=null&&(f=decodeURIComponent(f)),f=f??`TUIC ${s}:${u}`;let h={type:"tuic",name:f,server:s,port:u,password:p,uuid:d};for(let A of l.split("&")){let[m,S]=A.split("=");m=m.replace(/_/g,"-"),S=decodeURIComponent(S),["alpn"].includes(m)?h[m]=S?S.split(","):void 0:["allow-insecure"].includes(m)?h["skip-cert-verify"]=/(TRUE)|1/i.test(S):["fast-open"].includes(m)?h.tfo=!0:["disable-sni","reduce-rtt"].includes(m)?h[m]=/(TRUE)|1/i.test(S):m==="congestion-control"?(h["congestion-controller"]=S,delete h[m]):h[m]=S}return h}}}function vR(){return{name:"URI WireGuard Parser",test:n=>/^(wireguard|wg):\/\//.test(n),parse:n=>{n=n.split(/(wireguard|wg):\/\//)[2];let[i,a,s,u,l,f,d,E="",p]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);f=parseInt(`${f}`,10),isNaN(f)&&(f=51820),s=decodeURIComponent(s),p!=null&&(p=decodeURIComponent(p)),p=p??`WireGuard ${u}:${f}`;let h={type:"wireguard",name:p,server:u,port:f,"private-key":s,udp:!0};for(let A of E.split("&")){let[m,S]=A.split("=");if(m=m.replace(/_/,"-"),S=decodeURIComponent(S),["reserved"].includes(m)){let w=S.split(",").map(y=>parseInt(y.trim(),10)).filter(y=>Number.isInteger(y));w.length===3&&(h[m]=w)}else if(["address","ip"].includes(m))S.split(",").map(w=>{let y=w.trim().replace(/\/\d+$/,"").replace(/^\[/,"").replace(/\]$/,"");vr(y)?h.ip=y:ur(y)&&(h.ipv6=y)});else if(["mtu"].includes(m)){let w=parseInt(S.trim(),10);Number.isInteger(w)&&(h[m]=w)}else/publickey/i.test(m)?h["public-key"]=S:/privatekey/i.test(m)?h["private-key"]=S:["udp"].includes(m)?h[m]=/(TRUE)|1/i.test(S):["flag"].includes(m)||(h[m]=S)}return h}}}function ER(){return{name:"URI Trojan Parser",test:n=>/^trojan:\/\//.test(n),parse:n=>{let i=/^(trojan:\/\/.*?@.*?)(:(\d+))?\/?(\?.*?)?$/.exec(n);i?.[2]||(n=n.replace(i[1],`${i[1]}:443`));let[s,u]=n.split(/#(.+)/,2),f=Y0().parse(s);if(Hi(u))try{f.name=decodeURIComponent(u)}catch(d){console.log(d)}return f}}}function wR(){return{name:"Clash Parser",test:n=>{try{JSON.parse(n)}catch{return!1}return!0},parse:n=>{let i=JSON.parse(n);if(!["anytls","mieru","juicity","ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","hysteria","hysteria2","wireguard","ssh","direct"].includes(i.type))throw new Error(`Clash does not support proxy with type: ${i.type}`);return["vmess","vless"].includes(i.type)&&(i.sni=i.servername,delete i.servername),i["server-cert-fingerprint"]&&(i["tls-fingerprint"]=i["server-cert-fingerprint"]),i.fingerprint&&(i["tls-fingerprint"]=i.fingerprint),i["dialer-proxy"]&&(i["underlying-proxy"]=i["dialer-proxy"]),i["benchmark-url"]&&(i["test-url"]=i["benchmark-url"]),i["benchmark-timeout"]&&(i["test-timeout"]=i["benchmark-timeout"]),i}}}function AR(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>qs().parse(n)}}function yR(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>qs().parse(n)}}function SR(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>qs().parse(n)}}function bR(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>qs().parse(n)}}function CR(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>qs().parse(n)}}function _R(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>qs().parse(n)}}function FR(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>qs().parse(n)}}function IR(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>ts().parse(n)}}function $R(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>ts().parse(n)}}function DR(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>ts().parse(n)}}function BR(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>ts().parse(n)}}function RR(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>ts().parse(n)}}function PR(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>ts().parse(n)}}function TR(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>ts().parse(n)}}function OR(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>ts().parse(n)}}function xR(){return{name:"Loon WireGuard Parser",test:n=>/^.*=\s*wireguard/i.test(n.split(",")[0]),parse:n=>{let i=n.match(/(^.*?)\s*?=\s*?wireguard\s*?,.+?\s*?=\s*?.+?/i)?.[1];n=n.replace(i,"").replace(/^\s*?=\s*?wireguard\s*/i,"");let a=n.match(/,\s*?peers\s*?=\s*?\[\s*?\{\s*?(.+?)\s*?\}\s*?\]/i)?.[1],s=a.match(/(,|^)\s*?endpoint\s*?=\s*?"?(.+?):(\d+)"?\s*?(,|$)/i),u=s?.[2],l=parseInt(s?.[3],10),f=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];f&&(f=parseInt(f,10));let d=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];d&&(d=parseInt(d,10));let E=a.match(/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i)?.[2];E&&(E=JSON.parse(E));let p,h=n.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],A=n.match(/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];(h||A)&&(p=[],h&&p.push(h),A&&p.push(A));let m=a.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]?.split(",").map(D=>D.trim()),S=a.match(/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],w=n.match(/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],y=n.match(/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],_=a.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],B={type:"wireguard",name:i,server:u,port:l,ip:w,ipv6:y,"private-key":n.match(/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],"public-key":_,mtu:f,keepalive:d,reserved:E,"allowed-ips":m,"preshared-key":S,dns:p,udp:!0,peers:[{server:u,port:l,ip:w,ipv6:y,"public-key":_,"pre-shared-key":S,"allowed-ips":m,reserved:E}]};return Array.isArray(B.dns)&&B.dns.length>0&&(B["remote-dns-resolve"]=!0),B}}}function NR(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>Jn().parse(n)}}function kR(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>Jn().parse(n)}}function LR(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>Jn().parse(n)}}function UR(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>Jn().parse(n)}}function HR(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>Jn().parse(n)}}function MR(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0]),parse:n=>Jn().parse(n)}}function jR(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0]),parse:n=>Jn().parse(n)}}function qR(){return{name:"Surge External Parser",test:n=>/^.*=\s*external/.test(n.split(",")[0]),parse:n=>{let i=/^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(n),[a,s,u]=i;n=u;let l=/(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];l||(l=/(,|^)\s*?exec\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let f=/(,|^)\s*?local-port\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];f||(f=/(,|^)\s*?local-port\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let d=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,E,p=[];for(;(E=d.exec(n))!==null;)E[3]!=null?p.push(E[3]):E[4]!=null&&p.push(E[4]);let h=/(,|^)\s*?addresses\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,A,m=[];for(;(A=h.exec(n))!==null;){let w;A[3]!=null?w=A[3]:A[4]!=null&&(w=A[4]),w!=null&&(w=`${w}`.trim().replace(/^\[/,"").replace(/\]$/,"")),YR(w)&&m.push(w)}return{type:"external",name:s,exec:l,"local-port":f,args:p,addresses:m}}}}function KR(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>Jn().parse(n)}}function VR(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=pA(n),s=Jn().parse(a);return s.ports=i,s}}}function GR(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>Jn().parse(n)}}function zR(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=pA(n),s=Jn().parse(a);return s.ports=i,s}}}function YR(e){return vr(e)||ur(e)}var dA=[oR(),uR(),cR(),lR(),fR(),hR(),mR(),vR(),gR(),dR(),ER(),pR(),wR(),NR(),kR(),LR(),UR(),HR(),MR(),KR(),VR(),GR(),zR(),jR(),qR(),IR(),$R(),DR(),BR(),PR(),RR(),TR(),OR(),xR(),AR(),yR(),SR(),bR(),CR(),_R(),FR()];var di=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=Ir(),{defaultProxy,defaultTimeout:timeout}=I.read(Ft),proxy=defaultProxy;I.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=wi({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?Cs(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=wi({baseURL:"https://api.github.com",headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Cs(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);I.info(`\u83B7\u53D6\u5230\u5F53\u524D GitHub \u7528\u6237\u7684 gist: ${t.length} \u4E2A`);for(let r of t)if(r.description===this.key)return r})}async upload(e){if(Object.keys(e).length===0)return Promise.reject("\u672A\u63D0\u4F9B\u9700\u4E0A\u4F20\u7684\u6587\u4EF6");let t=await this.locate(),r=e;if(t?.id){this.syncPlatform==="gitlab"&&(t.files=t.files.reduce((a,s)=>(a[s.path]=s,a),{}));let n=[],i={...t.files};return Object.keys(r).map(a=>{i[a]?r[a].content==null||r[a].content===""?(delete i[a],n.push({action:"delete",file_path:a})):(i[a]=r[a],n.push({action:"update",file_path:a,content:r[a].content})):r[a].content==null||r[a].content===""?(delete i[a],delete r[a]):(i[a]=r[a],n.push({action:"create",file_path:a,content:r[a].content}))}),this.syncPlatform==="gitlab"?Object.keys(i).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(i).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(i).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,[i,a])=>(a.content!==null&&a.content!==""&&(n[i]=a),n),{}),this.syncPlatform==="gitlab"?Object.keys(r).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA snippet"):(r=Object.keys(r).map(n=>({file_path:n,content:r[n].content})),this.http.post({headers:{...this.headers,"Content-Type":"application/json"},url:"/snippets",body:JSON.stringify({title:this.key,visibility:"private",files:r})})):Object.keys(r).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA gist"):this.http.post({url:"/gists",body:JSON.stringify({description:this.key,public:!1,files:r})})}async download(e){let t=await this.locate();if(t?.id)try{let{files:r}=await this.http.get(`/gists/${t.id}`).then(i=>JSON.parse(i.body)),n=r[e].raw_url;return await this.http.get(n).then(i=>i.body)}catch(r){return Promise.reject(r)}else return Promise.reject(`\u627E\u4E0D\u5230 Sub-Store Gist (${this.key})`)}};function WR(e){for(let t of fh)try{if(t.test(e))return I.info(`Pre-processor [${t.name}] activated`),t.parse(e)}catch(r){I.error(`Parser [${t.name}] failed Reason: ${r}`)}return e}function XR(e){e=WR(e);let t=e.split(` `),r=[],n;for(let i of t){if(i=i.trim(),i.length===0)continue;let a=!1;if(n){let[s,u]=gA(n,i);u||(r.push(vA(s)),a=!0)}if(!a)for(let s of dA){let[u,l]=gA(s,i);if(!l){r.push(vA(u)),n=s,a=!0,I.info(`${s.name} is activated`);break}}a||I.error(`Failed to parse line: ${i}`)}return r.filter(i=>(["vless","vmess"].includes(i.type)&&(bf(i.uuid)||I.error(`UUID may be invalid: ${i.name} ${i.uuid}`)),!0))}async function JR(proxies,operators=[],targetPlatform,source,$options){for(let item of operators){if(item.disabled){I.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"?Gr:vt,n=Je(I.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);e==="module"?script=n.content:script=await Pr({type:"file",name:t})}catch(t){throw I.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=require("fs");script=fs.readFileSync(url.split("#")[0],"utf8")}catch(e){throw I.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 yr(url)}catch(e){throw I.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(!lh[item.type]){I.error(`Unknown operator: "${item.type}"`);continue}I.log(`Applying "${item.type}" with arguments: >>> ${JSON.stringify(item.args,null,2)||"None"}`);let processor;item.type.indexOf("Script")!==-1?processor=lh[item.type](script,targetPlatform,$arguments,source,$options):processor=lh[item.type](item.args||{}),proxies=await JE(processor,proxies)}return proxies}function ZR(e,t,r,n={}){let i=mh[t];if(!i)throw new Error(`Target platform: ${t} is not supported!`);let a=/Surge|SurgeMac|Shadowrocket/i.test(t);if(e=e.filter(s=>s.supported&&s.supported[t]===!1?!1:(["vless","vmess"].includes(s.type)&&(bf(s.uuid)||I.error(`UUID may be invalid: ${s.name} ${s.uuid}`)),!0)),e=e.map(s=>(s._resolved=s.resolved,Hi(s.name)||(s.name=`${s.type} ${s.server}:${s.port}`),s["disable-sni"]&&(a?s.sni="off":["tuic"].includes(s.type)||(I.error(`Target platform ${t} does not support sni off. Proxy's fields (sni, tls-fingerprint and skip-cert-verify) will be modified.`),s.sni="",s["skip-cert-verify"]=!0,delete s["tls-fingerprint"])),s.ports&&(s.ports=String(s.ports),["ClashMeta"].includes(t)||(s.ports=s.ports.replace(/\//g,",")),s.port||(s.port=xc(s.ports))),s)),I.log(`Producing proxies for target: ${t}`),typeof i.type>"u"||i.type==="SINGLE"){let s=e.map(u=>{try{return i.produce(u,r,n)}catch(l){return I.error(`Cannot produce proxy: ${JSON.stringify(u,null,2)} Reason: ${l}`),""}}).filter(u=>u.length>0);return s=r==="internal"?s:s.join(` `),t.startsWith("Surge")&&e.length>0&&e.every(u=>u.type==="wireguard")&&(s=`#!name=${e[0]?._subName} #!desc=${e[0]?._desc??""} #!category=${e[0]?._category??""} ${s}`),s}else if(i.type==="ALL")return i.produce(e,r,n)}var yt={parse:XR,process:JR,produce:ZR,ipAddress:Sf,getRandomPort:xc,isIPv4:vr,isIPv6:ur,isIP:W0,yaml:po,getFlag:Ru,removeFlag:Qc,getISO:ih,MMDB:nh,Gist:di,download:yr,downloadFile:pl,isValidUUID:bf,doh:Tu,Buffer:_h.Buffer,Base64:Et};function gA(e,t){if(!QR(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function QR(e,t){try{return e.test(t)}catch{return!1}}function mA(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function vA(e){typeof e.cipher=="string"&&(e.cipher=e.cipher.toLowerCase()),typeof e.password=="number"&&(e.password=Fm(e.password)),["ss"].includes(e.type)&&e.cipher==="none"&&!e.password&&(e.password=""),e.interface&&(e["interface-name"]=e.interface,delete e.interface),_m(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=>mA(n)):t!=null&&(e[`${e.network}-opts`].path=mA(t)),e.type==="trojan"&&e.network==="tcp"&&delete e.network,["vless"].includes(e.type)&&(e.network||(e.network="tcp")),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(e.type)&&(e.tls=!0),e.network){let n=e[`${e.network}-opts`]?.headers?.Host,i=e[`${e.network}-opts`]?.headers?.host;e.network==="h2"?!i&&n&&(e[`${e.network}-opts`].headers.host=n,delete e[`${e.network}-opts`].headers.Host):i&&!n&&(e[`${e.network}-opts`].headers.Host=i,delete e[`${e.network}-opts`].headers.host)}if(e.network==="h2"){let n=e["h2-opts"]?.headers?.host,i=e["h2-opts"]?.path;n&&!Array.isArray(n)&&(e["h2-opts"].headers.host=[n]),Array.isArray(i)&&(e["h2-opts"].path=i[0])}if(!e.tls&&["ws","http"].includes(e.network)&&!e[`${e.network}-opts`]?.headers?.Host&&!W0(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,i=e[`${e.network}-opts`]?.headers?.Host;i&&!Array.isArray(i)&&(e[`${e.network}-opts`].headers.Host=[i]),n&&!Array.isArray(n)&&(e[`${e.network}-opts`].path=[n])}if(e.tls&&!e.sni&&(W0(e.server)||(e.sni=e.server),!e.sni&&e.network)){let n=e[`${e.network}-opts`]?.headers?.Host;n=Array.isArray(n)?n[0]:n,n&&(e.sni=n)}if(e.ports?e.ports=String(e.ports).replace(/\//g,","):delete e.ports,["hysteria2"].includes(e.type)&&e.obfs&&!["salamander"].includes(e.obfs)&&!e["obfs-password"]&&(e["obfs-password"]=e.obfs,e.obfs="salamander"),["hysteria2"].includes(e.type)&&!e["obfs-password"]&&e.obfs_password&&(e["obfs-password"]=e.obfs_password,delete e.obfs_password),["vless"].includes(e.type)&&(e["reality-opts"]&&Object.keys(e["reality-opts"]).length===0&&delete e["reality-opts"],e["grpc-opts"]&&Object.keys(e["grpc-opts"]).length===0&&delete e["grpc-opts"],!e["reality-opts"]&&!e.flow&&delete e.flow,["http"].includes(e.network)&&(e[`${e.network}-opts`]?.path||(e[`${e.network}-opts`]||(e[`${e.network}-opts`]={}),e[`${e.network}-opts`].path=["/"]))),typeof e.name!="string")if(/^\d+$/.test(e.name))e.name=`${e.name}`;else try{e.name?.data?e.name=_h.Buffer.from(e.name.data).toString("utf8"):e.name=_h.Buffer.from(e.name).toString("utf8")}catch(n){I.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{I.env.isNode&&!r&&e._ca&&(r=I.node.fs.readFileSync(e._ca,{encoding:"utf8"}))}catch(n){I.error(`Read ca file failed Reason: ${n}`)}return!e["tls-fingerprint"]&&r&&(e["tls-fingerprint"]=Nv.generateFingerprint(r)),["ss"].includes(e.type)&&ae(e,"shadow-tls-password")&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e["shadow-tls-sni"],password:e["shadow-tls-password"],version:e["shadow-tls-version"]},delete e["shadow-tls-sni"],delete e["shadow-tls-password"],delete e["shadow-tls-version"]),e}function W0(e){return vr(e)||ur(e)}function eP(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function tP(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var EA=[eP(),tP()];function rP(){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 wA(){return{type:"SINGLE",func:r=>{if(["GEOSITE","GEOIP"].indexOf(r.type)!==-1)return null;let i=`${r.type},${r.content}`;return["IP-CIDR","IP-CIDR6"].includes(r.type)&&(i+=r.options?.length>0?`,${r.options.join(",")}`:""),i}}}function nP(){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(i=>["no-resolve"].includes(i))),wA().func(r))}}function iP(){return{type:"ALL",func:r=>{let n={"DEST-PORT":"DST-PORT","SRC-IP":"SRC-IP-CIDR","IN-PORT":"SRC-PORT"},i={payload:r.map(a=>{let s=`${n[a.type]||a.type},${a.content}`;return["IP-CIDR","IP-CIDR6","GEOIP"].includes(a.type)&&(a.options&&(a.options=a.options.filter(u=>["no-resolve"].includes(u))),s+=a.options?.length>0?`,${a.options.join(",")}`:""),s})};return po.dump(i)}}}var AA={QX:rP(),Surge:wA(),Loon:nP(),Clash:iP()};var sP=[[/^(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 aP(){return{name:"Universal Rule Parser",test:()=>!0,parse:n=>{let i=n.split(` `),a=[];for(let s of i)if(s=s.trim(),s.length!==0&&!/\s*#/.test(s))try{let u=s.split(",").map(d=>d.trim()),l=u[0],f=!1;for(let d of sP)if(d[0].test(l)){f=!0;let p={type:d[1],content:u[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(p.type)&&(p.options=u.slice(2)),a.push(p)}if(!f)throw new Error("Invalid rule type: "+l)}catch(u){console.log(`Failed to parse line: ${s} Reason: ${u}`)}return a}}}var yA=[aP()];var wo=function(){function e(n){for(let i of EA)try{if(i.test(n))return I.info(`Pre-processor [${i.name}] activated`),i.parse(n)}catch(a){I.error(`Parser [${i.name}] failed Reason: ${a}`)}return n}function t(n){n=e(n);for(let i of yA){let a;try{a=i.test(n)}catch{a=!1}if(a)return I.info(`Rule parser [${i.name}] is activated!`),i.parse(n)}}function r(n,i){let a=AA[i];if(!a)throw new Error(`Target platform: ${i} is not supported!`);if(typeof a.type>"u"||a.type==="SINGLE")return n.map(s=>{try{return a.func(s)}catch(u){return console.log(`ERROR: cannot produce rule: ${JSON.stringify(s)} Reason: ${u}`),""}}).filter(s=>s.length>0).join(` `);if(a.type==="ALL")return a.func(n)}return{parse:t,produce:r}}();function X0(e){I.read(ht)||I.write({},ht),e.get("/api/artifacts/restore",oP),e.route("/api/artifacts").get(uP).post(fP).put(cP),e.route("/api/artifact/:name").get(lP).patch(hP).delete(pP)}async function oP(e,t){I.info("\u5F00\u59CB\u6062\u590D\u8FDC\u7A0B\u914D\u7F6E...");try{let{gistToken:r,syncPlatform:n}=I.read(Ft);if(!r)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=new di({token:r,key:Ya,syncPlatform:n});try{let a=await i.locate();if(!a?.files)throw new Error("\u627E\u4E0D\u5230 Sub-Store Gist \u6587\u4EF6\u5217\u8868");let s=I.read(ht),u=[];Object.keys(a.files).map(l=>{let f=a.files[l]?.filename;if(f)if(encodeURIComponent(f)!==f)I.error(`\u6587\u4EF6\u540D ${f} \u672A\u7F16\u7801 \u4E0D\u4FDD\u5B58`),u.push(f);else{let d=Je(s,f);d?yi(s,f,{...d,url:a.files[l]?.raw_url.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1")}):s.push({name:`${f}`,url:a.files[l]?.raw_url.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1")})}}),I.write(s,ht)}catch(a){throw I.error(`\u67E5\u627E Sub-Store Gist \u65F6\u53D1\u751F\u9519\u8BEF: ${a.message??a}`),a}Ne(t)}catch(r){I.error(`\u6062\u590D\u8FDC\u7A0B\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),Pe(t,new jt("FAILED_TO_RESTORE_ARTIFACTS","Failed to restore artifacts",`Reason: ${r.message??r}`))}}function uP(e,t){let r=I.read(ht);Ne(t,r)}function cP(e,t){let r=e.body;I.write(r,ht),Ne(t)}async function lP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=I.read(ht),i=Je(n,r);i?Ne(t,i):Pe(t,new Vt("RESOURCE_NOT_FOUND",`Artifact ${r} does not exist!`),404)}function fP(e,t){let r=e.body;if(!SA(r.name)){Pe(t,new At("INVALID_ARTIFACT_NAME",`Artifact name ${r.name} is invalid.`));return}I.info(`\u6B63\u5728\u521B\u5EFA\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r.name}`);let n=I.read(ht);Je(n,r.name)?Pe(t,new At("DUPLICATE_KEY",`Artifact ${r.name} already exists.`)):(n.push(r),I.write(n,ht),Ne(t,r,201))}function hP(e,t){let r=I.read(ht),n=e.params.name;n=decodeURIComponent(n);let i=Je(r,n);if(i){I.info(`\u6B63\u5728\u66F4\u65B0\u8FDC\u7A0B\u914D\u7F6E\uFF1A${i.name}`);let a={...i,...e.body};if(!SA(a.name)){Pe(t,new At("INVALID_ARTIFACT_NAME",`Artifact name ${a.name} is invalid.`));return}yi(r,n,a),I.write(r,ht),Ne(t,a)}else Pe(t,new At("DUPLICATE_KEY",`Artifact ${n} already exists.`))}async function pP(e,t){let{name:r}=e.params;r=decodeURIComponent(r),I.info(`\u6B63\u5728\u5220\u9664\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}`);let n=I.read(ht);try{let i=Je(n,r);if(!i)throw new Error(`\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}\u4E0D\u5B58\u5728\uFF01`);if(i.updated){let a={};a[encodeURIComponent(i.name)]={content:""},encodeURIComponent(i.name)!==i.name&&(a[i.name]={content:""});try{await Fh(a)}catch(s){I.error(`Function syncToGist: ${r} : ${s}`)}}oi(n,r),I.write(n,ht),Ne(t)}catch(i){I.error(`\u65E0\u6CD5\u5220\u9664\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}\uFF0C\u539F\u56E0\uFF1A${i}`),Pe(t,new jt("FAILED_TO_DELETE_ARTIFACT",`Failed to delete artifact ${r}`,`Reason: ${i}`))}}function SA(e){return/^[a-zA-Z0-9._-]*$/.test(e)}async function Fh(e){let{gistToken:t,syncPlatform:r}=I.read(Ft);if(!t)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=await new di({token:t,key:Ya,syncPlatform:r}).upload(e),a={};try{a=JSON.parse(i.body)}catch{}let s=a?.html_url??a?.web_url,u=I.read(Ft);return s?(I.log(`\u540C\u6B65 Gist \u540E, \u627E\u5230 Sub-Store Gist: ${s}`),u.artifactStore=s,u.artifactStoreStatus="VALID"):(I.error("\u540C\u6B65 Gist \u540E, \u627E\u4E0D\u5230 Sub-Store Gist"),u.artifactStoreStatus="NOT FOUND"),I.write(u,Ft),i}function J0(e){I.read(ht)||I.write({},ht),e.get("/api/sync/artifacts",dP),e.get("/api/sync/artifact/:name",gP)}async function Pr({type:e,name:t,platform:r,url:n,ua:i,content:a,mergeSources:s,ignoreFailedRemoteSub:u,ignoreFailedRemoteFile:l,produceType:f,produceOpts:d={},subscription:E,awaitCustomCache:p,$options:h,proxy:A,noCache:m,all:S}){if(r=r||"JSON",["subscription","sub"].includes(e)){let w;if(t){let D=I.read(Dt);if(w=Je(D,t),!w)throw new Error(`\u627E\u4E0D\u5230\u8BA2\u9605 ${t}`)}else if(E)w=E;else throw new Error("\u672A\u63D0\u4F9B\u8BA2\u9605\u540D\u79F0\u6216\u8BA2\u9605\u6570\u636E");let y;if(a&&!["localFirst","remoteFirst"].includes(s))y=a;else if(n){let D={};y=await Promise.all(n.split(/[\r\n]+/).map(q=>q.trim()).filter(q=>q.length).map(async q=>{try{return await yr(q,i||w.ua,void 0,A||w.proxy,void 0,p,m||w.noCache,!0)}catch(F){return D[q]=F,I.error(`\u8BA2\u9605 ${w.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${q} \u53D1\u751F\u9519\u8BEF: ${F}`),""}}));let j=w.ignoreFailedRemoteSub;if(u!=null&&u!==""&&(j=u),Object.keys(D).length>0)if(j)j==="enabled"&&I.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${w.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(D).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(D).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?y.unshift(a):s==="remoteFirst"&&y.push(a)}else if(w.source==="local"&&!["localFirst","remoteFirst"].includes(w.mergeSources))y=w.content;else{let D={};y=await Promise.all(w.url.split(/[\r\n]+/).map(q=>q.trim()).filter(q=>q.length).map(async q=>{try{return await yr(q,i||w.ua,void 0,A||w.proxy,void 0,p,m||w.noCache,!0)}catch(F){return D[q]=F,I.error(`\u8BA2\u9605 ${w.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${q} \u53D1\u751F\u9519\u8BEF: ${F}`),""}}));let j=w.ignoreFailedRemoteSub;if(u!=null&&u!==""&&(j=u),Object.keys(D).length>0)if(j)j==="enabled"&&I.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${w.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(D).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(D).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);w.mergeSources==="localFirst"?y.unshift(w.content):w.mergeSources==="remoteFirst"&&y.push(w.content)}if(f==="raw")return JSON.stringify((Array.isArray(y)?y:[y]).flat());let _=(Array.isArray(y)?y:[y]).map(D=>yt.parse(D)).flat();if(_.forEach(D=>{D._subName=w.name,D._subDisplayName=w.displayName}),_=await yt.process(_,w.process||[],r,{[w.name]:w},h),_.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let B={};for(let D of _){if(B[D.name]){I.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${D.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}B[D.name]=!0}return yt.produce(_,r,f,d)}else if(["collection","col"].includes(e)){let w=I.read(Dt),y=I.read(Bt),_=Je(y,t);if(!_)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let B=[..._.subscriptions],D=_.subscriptionTags;Array.isArray(D)&&D.length>0&&w.forEach(V=>{Array.isArray(V.tag)&&V.tag.length>0&&!B.includes(V.name)&&V.tag.some(W=>D.includes(W))&&B.push(V.name)});let j={},q={},F=0;await Promise.all(B.map(async V=>{let W=Je(w,V),G=W.passThroughUA,z=W.ua;G&&(I.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${i}`),z=i);try{I.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 Se={};if(X=await await Promise.all(W.url.split(/[\r\n]+/).map(we=>we.trim()).filter(we=>we.length).map(async we=>{try{return await yr(we,z,void 0,A||W.proxy||_.proxy,void 0,void 0,m||W.noCache,!0)}catch(Ie){return Se[we]=Ie,I.error(`\u8BA2\u9605 ${W.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${we} \u53D1\u751F\u9519\u8BEF: ${Ie}`),""}})),Object.keys(Se).length>0)if(W.ignoreFailedRemoteSub)W.ignoreFailedRemoteSub==="enabled"&&I.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${W.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(Se).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(Se).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 ie=(Array.isArray(X)?X:[X]).map(Se=>yt.parse(Se)).flat();ie.forEach(Se=>{Se._subName=W.name,Se._subDisplayName=W.displayName,Se._collectionName=_.name,Se._collectionDisplayName=_.displayName}),ie=await yt.process(ie,W.process||[],r,{[W.name]:W,_collection:_,$options:h}),j[V]=ie,F++,I.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${W.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(F/B.length).toFixed(1)}% `)}catch(X){F++,q[V]=X,I.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*(F/B.length).toFixed(1)}%`)}}));let P=_.ignoreFailedRemoteSub;if(u!=null&&u!==""&&(P=u),Object.keys(q).length>0)if(P)P==="enabled"&&I.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${_.name}`,`\u5B50\u8BA2\u9605 ${Object.keys(q).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${_.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(q).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let L=Array.prototype.concat.apply([],B.map(V=>j[V]||[]));if(L.forEach(V=>{V._collectionName=_.name,V._collectionDisplayName=_.displayName}),L=await yt.process(L,_.process||[],r,{_collection:_},h),L.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let M={};for(let V of L){if(M[V.name]){I.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u7EC4\u5408\u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${V.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}M[V.name]=!0}return yt.produce(L,r,f,d)}else if(e==="rule"){let w=I.read(Pc),y=Je(w,t);if(!y)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let _=[];for(let B=0;BP.trim()).filter(P=>P.length).map(async P=>{try{return await yr(P,i||y.ua,void 0,y.proxy||A,void 0,void 0,m)}catch(L){return q[P]=L,I.error(`\u6587\u4EF6 ${y.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${P} \u53D1\u751F\u9519\u8BEF: ${L}`),""}}));let F=y.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(F=l),!F&&Object.keys(q).length>0)throw new Error(`\u6587\u4EF6 ${y.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(q).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?_.unshift(a):s==="remoteFirst"&&_.push(a)}else if(y.source==="local"&&!["localFirst","remoteFirst"].includes(y.mergeSources))_=y.content;else{let q={};_=await Promise.all(y.url.split(/[\r\n]+/).map(P=>P.trim()).filter(P=>P.length).map(async P=>{try{return await yr(P,i||y.ua,void 0,y.proxy||A,void 0,void 0,m)}catch(L){return q[P]=L,I.error(`\u6587\u4EF6 ${y.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${P} \u53D1\u751F\u9519\u8BEF: ${L}`),""}}));let F=y.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(F=l),Object.keys(q).length>0)if(F)F==="enabled"&&I.notify("\u{1F30D} Sub-Store \u5904\u7406\u6587\u4EF6\u5931\u8D25",`\u274C ${y.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(q).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u6587\u4EF6 ${y.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(q).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);y.mergeSources==="localFirst"?_.unshift(y.content):y.mergeSources==="remoteFirst"&&_.push(y.content)}if(f==="raw")return JSON.stringify((Array.isArray(_)?_:[_]).flat());let B=(Array.isArray(_)?_:[_]).flat(),D=B.filter(q=>q!=null&&q!=="").join(` `),j=Array.isArray(y.process)&&y.process.length>0?await yt.process({$files:B,$content:D,$options:h,$file:y},y.process):{$content:D,$files:B,$options:h};return(S?j:j?.$content)??""}}async function Z0(){I.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");let e=I.read(ht),t={};try{let r=[],n=[],i=I.read(Dt),a=I.read(Bt),s=[],u=0;if(e.map(d=>{if(d.sync&&d.source){if(u++,d.type==="subscription"){let E=d.source,p=Je(i,E);p&&p.url&&!s.includes(E)&&s.push(E)}else if(d.type==="collection"){let E=Je(a,d.source);E&&Array.isArray(E.subscriptions)&&E.subscriptions.map(p=>{let h=Je(i,p);h&&h.url&&!s.includes(p)&&s.push(p)})}}}),u===0){I.info(`\u9700\u540C\u6B65\u7684\u914D\u7F6E: ${u}, \u603B\u6570: ${e.length}`);return}if(s.length>0&&await Promise.all(s.map(async d=>{try{await Pr({type:"subscription",name:d,awaitCustomCache:!0})}catch{}})),await Promise.all(e.map(async d=>{try{if(d.sync&&d.source){I.info(`\u6B63\u5728\u540C\u6B65\u4E91\u914D\u7F6E\uFF1A${d.name}...`);let E=d.platform==="SurgeMac";E&&I.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External");let p=await Pr({type:d.type,name:d.source,platform:d.platform,produceOpts:{"include-unsupported-proxy":d.includeUnsupportedProxy,useMihomoExternal:E}});t[encodeURIComponent(d.name)]={content:p},r.push(d.name)}}catch(E){I.error(`\u751F\u6210\u540C\u6B65\u914D\u7F6E ${d.name} \u53D1\u751F\u9519\u8BEF: ${E.message??E}`),n.push(d.name)}})),I.info(`${r.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u751F\u6210\u6210\u529F: ${r.join(", ")}`),I.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 Fh(t),f=JSON.parse(l.body);delete f.history,delete f.forks,delete f.owner,Object.values(f.files).forEach(d=>{delete d.content}),I.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),I.info(JSON.stringify(f,null,2));for(let d of e)if(d.sync&&d.source&&r.includes(d.name)){d.updated=new Date().getTime();let E=f.files,p;Array.isArray(E)&&(p=!0,E=Object.fromEntries(E.map(m=>[m.path,m])));let h=E[encodeURIComponent(d.name)]?.raw_url,A=p?h:h?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");I.info(`\u4E0A\u4F20\u914D\u7F6E\u5B8C\u6210 \u6587\u4EF6\u5217\u8868: ${Object.keys(E).join(", ")} \u5F53\u524D\u6587\u4EF6: ${encodeURIComponent(d.name)} \u54CD\u5E94\u8FD4\u56DE\u7684\u539F\u59CB\u94FE\u63A5: ${h} \u5904\u7406\u5B8C\u7684\u65B0\u94FE\u63A5: ${A}`),d.url=A}if(I.write(e,ht),I.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`);I.info(`\u540C\u6B65\u914D\u7F6E\u6210\u529F ${r.length} \u4E2A`)}catch(r){throw I.error(`\u540C\u6B65\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),r}}async function dP(e,t){I.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");try{await Z0(),Ne(t)}catch(r){I.error(`\u540C\u6B65\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),Pe(t,new jt("FAILED_TO_SYNC_ARTIFACTS","Failed to sync all artifacts",`Reason: ${r.message??r}`))}}async function gP(e,t){let{name:r}=e.params;r=decodeURIComponent(r),I.info(`\u5F00\u59CB\u540C\u6B65\u8FDC\u7A0B\u914D\u7F6E ${r}...`);let n=I.read(ht),i=Je(n,r);if(!i){I.error(`\u627E\u4E0D\u5230\u8FDC\u7A0B\u914D\u7F6E ${r}`),Pe(t,new Vt("RESOURCE_NOT_FOUND",`\u627E\u4E0D\u5230\u8FDC\u7A0B\u914D\u7F6E ${r}`),404);return}if(!i.source){I.error(`\u8FDC\u7A0B\u914D\u7F6E ${r} \u672A\u8BBE\u7F6E\u6765\u6E90`),Pe(t,new Vt("RESOURCE_HAS_NO_SOURCE",`\u8FDC\u7A0B\u914D\u7F6E ${r} \u672A\u8BBE\u7F6E\u6765\u6E90`),404);return}try{let a=i.platform==="SurgeMac";a&&I.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External");let s=await Pr({type:i.type,name:i.source,platform:i.platform,produceOpts:{"include-unsupported-proxy":i.includeUnsupportedProxy,useMihomoExternal:a}});I.info(`\u6B63\u5728\u4E0A\u4F20\u914D\u7F6E\uFF1A${i.name} >>>${JSON.stringify(i,null,2)}`);let u=await Fh({[encodeURIComponent(i.name)]:{content:s}});i.updated=new Date().getTime();let l=JSON.parse(u.body);delete l.history,delete l.forks,delete l.owner,Object.values(l.files).forEach(h=>{delete h.content}),I.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),I.info(JSON.stringify(l,null,2));let f=l.files,d;Array.isArray(f)&&(d=!0,f=Object.fromEntries(f.map(h=>[h.path,h])));let E=f[encodeURIComponent(i.name)]?.raw_url,p=d?E:E?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");I.info(`\u4E0A\u4F20\u914D\u7F6E\u5B8C\u6210 \u6587\u4EF6\u5217\u8868: ${Object.keys(f).join(", ")} \u5F53\u524D\u6587\u4EF6: ${encodeURIComponent(i.name)} \u54CD\u5E94\u8FD4\u56DE\u7684\u539F\u59CB\u94FE\u63A5: ${E} \u5904\u7406\u5B8C\u7684\u65B0\u94FE\u63A5: ${p}`),i.url=p,I.write(n,ht),Ne(t,i)}catch(a){I.error(`\u8FDC\u7A0B\u914D\u7F6E ${i.name} \u53D1\u751F\u9519\u8BEF: ${a.message??a}`),Pe(t,new jt("FAILED_TO_SYNC_ARTIFACT",`Failed to sync artifact ${r}`,`Reason: ${a}`))}}var bA=fh.find(e=>e.name==="Clash Pre-processor"),Q0=new Map;async function yr(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}=Ir(),{defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=I.read(Ft),cacheThreshold=defaultCacheThreshold||1024,proxy=customProxy||defaultProxy;I.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultUserAgent||"clash.meta",requestTimeout=timeout||defaultTimeout||8e3,id=jn(userAgent+url);$arguments?.cacheKey===!0&&(I.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=I.read(customCacheKey),t=pr.get(id);if(!noCache&&!$arguments?.noCache&&t)return I.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){I.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u672C\u6B21\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u66F4\u65B0\u7F13\u5B58`);try{await yr(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess)}catch(r){I.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`),I.info("\u4F7F\u7528\u4E50\u89C2\u7F13\u5B58\u7684\u6570\u636E\u5237\u65B0\u7F13\u5B58, \u9632\u6B62\u540E\u7EED\u8BF7\u6C42"),pr.set(id,e)}}else I.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`),yr(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess).catch(r=>{I.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"?Gr:vt,n=Je(I.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);return e==="module"?n.content:await Pr({type:"file",name:t})}catch(t){throw I.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=require("fs");return fs.readFileSync(url.split("#")[0],"utf8")}catch(e){throw I.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&&Q0.has(id))return Q0.get(id);let http=wi({headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,cached=pr.get(id);if(!noCache&&!$arguments?.noCache&&cached)I.info(`\u4F7F\u7528\u7F13\u5B58: ${url}, ${userAgent}`),result=cached,customCacheKey&&(I.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),I.write(cached,customCacheKey));else{let e=$arguments?.insecure?isNode?{strictSSL:!1}:{insecure:!0}:void 0;I.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?Cs(proxy):{},...e||{}});if(I.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let a=uu(r);a&&eo.set(id,a)}if(t.replace(/\s/g,"").length===0)throw new Error(new Error("\u8FDC\u7A0B\u8D44\u6E90\u5185\u5BB9\u4E3A\u7A7A"));if(preprocess)try{bA.test(t)&&(t=bA.parse(t,!0))}catch(a){I.error(`Clash Pre-processor error: ${a}`)}let i=!0;if(cacheThreshold){let a=t.length/1024;a>cacheThreshold&&(I.info(`\u8D44\u6E90\u5927\u5C0F ${a.toFixed(2)} KB \u8D85\u8FC7\u4E86 ${cacheThreshold} KB, \u4E0D\u7F13\u5B58`),i=!1)}i&&(pr.set(id,t),customCacheKey&&(I.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),I.write(t,customCacheKey))),result=t}catch(t){if(customCacheKey){let r=I.read(customCacheKey);if(r)return I.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 Cf(to(await Zr(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl))),isNode||Q0.set(id,result),result}async function pl(url,file){let undici=require('undici'),fs=require('fs'),{pipeline}=require('stream/promises'),{Agent,interceptors,request}=undici;I.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),I.info(`File downloaded from ${url} to ${file}`),file}function e1(e){I.read(Ft)||I.write({},Ft),e.route("/api/settings").get(mP).patch(vP)}async function mP(e,t){try{let r=I.read(Ft);r||(r={},I.write(r,Ft)),r.avatarUrl||await Ih(),r.artifactStore||await $h(),Ne(t,r)}catch(r){I.error(`Failed to get settings: ${r.message??r}`),Pe(t,new jt("FAILED_TO_GET_SETTINGS","Failed to get settings",`Reason: ${r.message??r}`))}}async function vP(e,t){try{let n={...I.read(Ft),...e.body};I.write(n,Ft),await Ih(),await $h(),Ne(t,n)}catch(r){I.error(`Failed to update settings: ${r.message??r}`),Pe(t,new jt("FAILED_TO_UPDATE_SETTINGS","Failed to update settings",`Reason: ${r.message??r}`))}}async function Ih(){let e=I.read(Ft),{githubUser:t,syncPlatform:r}=e;if(t)if(r==="gitlab")try{let n=await I.http.get({url:`https://gitlab.com/api/v4/users?username=${encodeURIComponent(t)}`,headers:{"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"}}).then(i=>JSON.parse(i.body));e.avatarUrl=n[0].avatar_url.replace(/(\?|&)s=\d+(&|$)/,"$1s=160$2"),I.write(e,Ft)}catch(n){I.error(`Failed to fetch GitLab avatar for User: ${t}. Reason: ${n.message??n}`)}else try{let n=await I.http.get({url:`https://api.github.com/users/${encodeURIComponent(t)}`,headers:{"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"}}).then(i=>JSON.parse(i.body));e.avatarUrl=n.avatar_url,I.write(e,Ft)}catch(n){I.error(`Failed to fetch GitHub avatar for User: ${t}. Reason: ${n.message??n}`)}}async function $h(){I.log("Updating artifact store");let e=I.read(Ft),{gistToken:t,syncPlatform:r}=e;if(t){let n=new di({token:t,key:Ya,syncPlatform:r});try{let i=await n.locate(),a=i?.html_url??i?.web_url;a?(I.log(`\u627E\u5230 Sub-Store Gist: ${a}`),e.artifactStore=a,e.artifactStoreStatus="VALID"):(I.error(`\u627E\u4E0D\u5230 Sub-Store Gist (${Ya})`),e.artifactStoreStatus="NOT FOUND")}catch(i){I.error(`\u67E5\u627E Sub-Store Gist (${Ya}) \u65F6\u53D1\u751F\u9519\u8BEF: ${i.message??i}`),e.artifactStoreStatus="ERROR"}I.write(e,Ft)}}function t1(e){e.get("/api/utils/env",CA),e.get("/api/utils/backup",wP),e.get("/api/utils/refresh",EP),e.route("/api/storage").get((t,r)=>{r.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_data_${ca(new Date)}.json`)}"`).send(I.env.isNode?JSON.stringify(I.cache):I.read("#sub-store"))}).post((t,r)=>{let{content:n}=t.body;I.write(n,"#sub-store"),I.env.isNode&&(I.cache=JSON.parse(n),I.persistCache()),aa(),Ne(r)}),Ir().isNode?e.get("/",CA):e.get("/",async(t,r)=>{r.set("location","https://sub-store.vercel.app/").status(302).end()}),Ir().isQX&&e.options("/",async(t,r)=>{r.status(200).end()}),e.all("/",(t,r)=>{r.send("Hello from sub-store, made with \u2764\uFE0F by Peng-YM")})}function CA(e,t){e.query.share&&(Qi.feature.share=!0),t.set("Content-Type","application/json;charset=UTF-8").send(JSON.stringify({status:"success",data:{guide:"\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F \u60A8\u5F53\u524D\u770B\u5230\u7684\u662F\u540E\u7AEF\u7684\u54CD\u5E94. \u82E5\u60F3\u914D\u5408\u524D\u7AEF\u4F7F\u7528, \u53EF\u8BBF\u95EE\u5B98\u65B9\u524D\u7AEF https://sub-store.vercel.app \u540E\u81EA\u884C\u914D\u7F6E\u540E\u7AEF\u5730\u5740, \u6216\u4E00\u952E\u914D\u7F6E\u540E\u7AEF https://sub-store.vercel.app?api=https://a.com/xxx (\u5047\u8BBE https://a.com \u662F\u4F60\u540E\u7AEF\u7684\u57DF\u540D, /xxx \u662F\u81EA\u5B9A\u4E49\u8DEF\u5F84). \u9700\u6CE8\u610F HTTPS \u524D\u7AEF\u65E0\u6CD5\u8BF7\u6C42\u975E\u672C\u5730\u7684 HTTP \u540E\u7AEF(\u90E8\u5206\u6D4F\u89C8\u5668\u4E0A\u4E5F\u65E0\u6CD5\u8BBF\u95EE\u672C\u5730 HTTP \u540E\u7AEF). \u8BF7\u914D\u7F6E\u53CD\u4EE3\u6216\u5728\u5C40\u57DF\u7F51\u81EA\u5EFA HTTP \u524D\u7AEF. \u5982\u679C\u8FD8\u6709\u95EE\u9898, \u53EF\u67E5\u770B\u6B64\u6392\u67E5\u8BF4\u660E: https://t.me/zhetengsha/1068",...Qi}},null,2))}async function EP(e,t){await Ih(),await $h(),pr.revokeAll(),Zc.revokeAll(),eo.revokeAll(),Ne(t)}async function Dh(e){let{gistToken:t,syncPlatform:r}=I.read(Ft);if(!t)throw new Error("GitHub Token is required for backup!");let n=new di({token:t,key:lm,syncPlatform:r}),i,a=I.read(Ft),s=a.syncTime;switch(e){case"upload":try{if(i=I.read("#sub-store"),I.env.isNode&&(i=JSON.stringify(I.cache,null," ")),I.info("\u4E0B\u8F7D\u5907\u4EFD, \u4E0E\u672C\u5730\u5185\u5BB9\u5BF9\u6BD4..."),await n.download(lf)===i){I.info("\u5185\u5BB9\u4E00\u81F4, \u65E0\u9700\u4E0A\u4F20\u5907\u4EFD");return}}catch(u){I.error(`${u.message??u}`)}a.syncTime=new Date().getTime(),I.write(a,Ft),i=I.read("#sub-store"),I.env.isNode&&(i=JSON.stringify(I.cache,null," ")),I.info("\u4E0A\u4F20\u5907\u4EFD\u4E2D...");try{await n.upload({[lf]:{content:i}}),I.info("\u4E0A\u4F20\u5907\u4EFD\u5B8C\u6210")}catch(u){throw a.syncTime=s,I.write(a,Ft),u}break;case"download":I.info("\u8FD8\u539F\u5907\u4EFD\u4E2D..."),i=await n.download(lf);try{if(Object.keys(JSON.parse(i).settings).length===0)throw new Error("\u5907\u4EFD\u6587\u4EF6\u5E94\u8BE5\u81F3\u5C11\u5305\u542B settings \u5B57\u6BB5")}catch(u){throw I.error(`Gist \u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F Reason: ${u.message??u}`),new Error("Gist \u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F")}I.write(i,"#sub-store"),I.env.isNode&&(i=JSON.parse(i),I.cache=i,I.persistCache()),I.info("perform migration after restoring from gist..."),aa(),I.info("migration completed"),I.info("\u8FD8\u539F\u5907\u4EFD\u5B8C\u6210");break}}async function wP(e,t){let{action:r}=e.query,{gistToken:n}=I.read(Ft);if(!n)Pe(t,new At("GIST_TOKEN_NOT_FOUND","GitHub Token is required for backup!"));else try{await Dh(r),Ne(t)}catch(i){I.error(`Failed to ${r} gist data. Reason: ${i.message??i}`),Pe(t,new jt("BACKUP_FAILED",`Failed to ${r} gist data!`,`Reason: ${i.message??i}`))}}I.read(Dt)||I.write({},Dt);function r1(e){e.get("/api/sub/flow/:name",AP),e.route("/api/sub/:name").get(SP).patch(bP).delete(CP),e.route("/api/subs").get(_P).post(yP).put(FP)}async function AP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let{url:n}=e.query;n&&(n=decodeURIComponent(n),I.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 URL: ${n}`));let i=I.read(Dt),a=Je(i,r);if(!a){Pe(t,new Vt("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404);return}if(a.source==="local"&&!["localFirst","remoteFirst"].includes(a.mergeSources)){if(a.subUserinfo){let s;if(/^https?:\/\//.test(a.subUserinfo))try{s=await Zr(void 0,void 0,void 0,a.proxy,a.subUserinfo)}catch(u){I.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${a.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(u)}`)}else s=a.subUserinfo;try{Ne(t,{...to(s)})}catch(u){I.error(`Failed to parse flow info for local subscription ${r}: ${u.message??u}`),Pe(t,new At("NO_FLOW_INFO","N/A","Failed to parse flow info"))}}else Pe(t,new At("NO_FLOW_INFO","N/A",`Local subscription ${r} has no flow information!`));return}try{n=`${n||a.url}`.split(/[\r\n]+/).map(f=>f.trim()).filter(f=>f.length)?.[0]||"";let s={},u=n.split("#");if(n=n.split("#")[0],u.length>1)try{s=JSON.parse(decodeURIComponent(u[1]))}catch{for(let d of u[1].split("&")){let E=d.split("=")[0],p=d.split("=")[1];s[E]=p==null||p===""?!0:decodeURIComponent(p)}}if(s.noFlow||!/^https?/.test(n)){Pe(t,new At("NO_FLOW_INFO","N/A",`Subscription ${r}: noFlow`));return}let l=await Zr(s?.insecure?`${n}#insecure`:n,s.flowUserAgent,void 0,a.proxy,s.flowUrl);if(!l&&!a.subUserinfo){Pe(t,new jt("NO_FLOW_INFO","No flow info","Failed to fetch flow headers"));return}try{let f=_f({resetDay:s.resetDay,startDate:s.startDate,cycleDays:s.cycleDays}),d;if(/^https?:\/\//.test(a.subUserinfo))try{d=await Zr(void 0,void 0,void 0,a.proxy,a.subUserinfo)}catch(p){I.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${a.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(p)}`)}else d=a.subUserinfo;let E={...to([d,l].filter(p=>p).join("; "))};f!=null&&(E.remainingDays=f),Ne(t,E)}catch(f){I.error(`Failed to parse flow info for local subscription ${r}: ${f.message??f}`),Pe(t,new At("NO_FLOW_INFO","N/A","Failed to parse flow info"))}}catch{Pe(t,new lu("URL_NOT_ACCESSIBLE",`The URL for subscription ${r} is inaccessible.`))}}function yP(e,t){let r=e.body;if(I.info(`\u6B63\u5728\u521B\u5EFA\u8BA2\u9605\uFF1A ${r.name}`),/\//.test(r.name)){Pe(t,new At("INVALID_NAME",`Subscription ${r.name} is invalid`));return}let n=I.read(Dt);if(Je(n,r.name)){Pe(t,new At("DUPLICATE_KEY",`Subscription ${r.name} already exists.`));return}n.push(r),I.write(n,Dt),Ne(t,r,201)}function SP(e,t){let{name:r}=e.params,{raw:n}=e.query;r=decodeURIComponent(r);let i=I.read(Dt),a=Je(i,r);a?n?t.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_subscription_${r}_${ca(new Date)}.json`)}"`).send(JSON.stringify(a)):Ne(t,a):Pe(t,new Vt("SUBSCRIPTION_NOT_FOUND",`Subscription ${r} does not exist`,404))}function bP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.body,i=I.read(Dt),a=Je(i,r);if(a){let s={...a,...n};if(I.info(`\u6B63\u5728\u66F4\u65B0\u8BA2\u9605\uFF1A ${r}`),r!==n.name){let u=I.read(Bt)||[];for(let d of u){let E=d.subscriptions.indexOf(r);E!==-1&&(d.subscriptions[E]=n.name)}let l=I.read(ht)||[];for(let d of l)d.type==="subscription"&&d.source==r&&(d.source=n.name);let f=I.read(vt)||[];for(let d of f)d.sourceType==="subscription"&&d.sourceName==r&&(d.sourceName=n.name);I.write(u,Bt),I.write(l,ht),I.write(f,vt)}yi(i,r,s),I.write(i,Dt),Ne(t,s)}else Pe(t,new Vt("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404)}function CP(e,t){let{name:r}=e.params;r=decodeURIComponent(r),I.info(`\u5220\u9664\u8BA2\u9605\uFF1A${r}...`);let n=I.read(Dt);oi(n,r),I.write(n,Dt);let i=I.read(Bt);for(let a of i)a.subscriptions=a.subscriptions.filter(s=>s!==r);I.write(i,Bt),Ne(t)}function _P(e,t){let r=I.read(Dt);Ne(t,r)}function FP(e,t){let r=e.body;I.write(r,Dt),Ne(t)}function n1(e){I.read(Bt)||I.write({},Bt),e.route("/api/collection/:name").get($P).patch(DP).delete(BP),e.route("/api/collections").get(RP).post(IP).put(PP)}function IP(e,t){let r=e.body;if(I.info(`\u6B63\u5728\u521B\u5EFA\u7EC4\u5408\u8BA2\u9605\uFF1A${r.name}`),/\//.test(r.name)){Pe(t,new At("INVALID_NAME",`Collection ${r.name} is invalid`));return}let n=I.read(Bt);if(Je(n,r.name)){Pe(t,new At("DUPLICATE_KEY",`Collection ${r.name} already exists.`));return}n.push(r),I.write(n,Bt),Ne(t,r,201)}function $P(e,t){let{name:r}=e.params,{raw:n}=e.query;r=decodeURIComponent(r);let i=I.read(Bt),a=Je(i,r);a?n?t.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_collection_${r}_${ca(new Date)}.json`)}"`).send(JSON.stringify(a)):Ne(t,a):Pe(t,new Vt("SUBSCRIPTION_NOT_FOUND",`Collection ${r} does not exist`,404))}function DP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.body,i=I.read(Bt),a=Je(i,r);if(a){let s={...a,...n};if(I.info(`\u6B63\u5728\u66F4\u65B0\u7EC4\u5408\u8BA2\u9605\uFF1A${r}...`),r!==s.name){let u=I.read(ht)||[];for(let f of u)f.type==="collection"&&f.source===a.name&&(f.source=s.name);let l=I.read(vt)||[];for(let f of l)f.sourceType==="collection"&&f.sourceName===a.name&&(f.sourceName=s.name);I.write(u,ht),I.write(l,vt)}yi(i,r,s),I.write(i,Bt),Ne(t,s)}else Pe(t,new Vt("RESOURCE_NOT_FOUND",`Collection ${r} does not exist!`),404)}function BP(e,t){let{name:r}=e.params;r=decodeURIComponent(r),I.info(`\u6B63\u5728\u5220\u9664\u7EC4\u5408\u8BA2\u9605\uFF1A${r}`);let n=I.read(Bt);oi(n,r),I.write(n,Bt),Ne(t)}function RP(e,t){let r=I.read(Bt);Ne(t,r)}function PP(e,t){let r=e.body;I.write(r,Bt),Ne(t)}function i1(e){I.read(vt)||I.write([],vt),e.get("/share/file/:name",_A),e.route("/api/file/:name").get(_A).patch(xP).delete(NP),e.route("/api/wholeFile/:name").get(OP),e.route("/api/files").get(kP).post(TP).put(UP),e.route("/api/wholeFiles").get(LP)}function TP(e,t){let r=e.body;r.name=`${r.name??Date.now()}`,I.info(`\u6B63\u5728\u521B\u5EFA\u6587\u4EF6\uFF1A${r.name}`);let n=I.read(vt);if(Je(n,r.name))return Pe(t,new At("DUPLICATE_KEY",e.body.name?`\u5DF2\u5B58\u5728 name \u4E3A ${r.name} \u7684\u6587\u4EF6`:"\u65E0\u6CD5\u540C\u65F6\u521B\u5EFA\u76F8\u540C\u7684\u6587\u4EF6 \u53EF\u7A0D\u540E\u91CD\u8BD5"));n.push(r),I.write(n,vt),Ne(t,r,201)}async function _A(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.headers["user-agent"]||e.headers["User-Agent"];I.info(`\u6B63\u5728\u4E0B\u8F7D\u6587\u4EF6\uFF1A${r} \u8BF7\u6C42 User-Agent: ${n}`);let{url:i,subInfoUrl:a,subInfoUserAgent:s,ua:u,content:l,mergeSources:f,ignoreFailedRemoteFile:d,proxy:E,noCache:p,produceType:h}=e.query,A={_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){try{A=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let y of e.query.$options.split("&")){let _=y.split("=")[0],B=y.split("=")[1];A[_]=B==null||B===""?!0:decodeURIComponent(B)}}I.info(`\u4F20\u5165 $options: ${JSON.stringify(A)}`)}i&&(i=decodeURIComponent(i),I.info(`\u6307\u5B9A\u8FDC\u7A0B\u6587\u4EF6 URL: ${i}`)),E&&(E=decodeURIComponent(E),I.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${E}`)),u&&(u=decodeURIComponent(u),I.info(`\u6307\u5B9A\u8FDC\u7A0B\u6587\u4EF6 User-Agent: ${u}`)),a&&(a=decodeURIComponent(a),I.info(`\u6307\u5B9A\u83B7\u53D6\u6D41\u91CF\u7684 subInfoUrl: ${a}`)),s&&(s=decodeURIComponent(s),I.info(`\u6307\u5B9A\u83B7\u53D6\u6D41\u91CF\u7684 subInfoUserAgent: ${s}`)),l&&(l=decodeURIComponent(l),I.info(`\u6307\u5B9A\u672C\u5730\u6587\u4EF6: ${l}`)),f&&(f=decodeURIComponent(f),I.info(`\u6307\u5B9A\u5408\u5E76\u6765\u6E90: ${f}`)),d!=null&&d!==""&&(d=decodeURIComponent(d),I.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u6587\u4EF6: ${d}`)),p&&I.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${p}`),h&&(h=decodeURIComponent(h),I.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${h}`));let m=I.read(vt),S=Je(m,r);if(S)try{let w=await Pr({type:"file",name:r,url:i,ua:u,content:l,mergeSources:f,ignoreFailedRemoteFile:d,$options:A,proxy:E,noCache:p,produceType:h,all:!0});try{if(a=a||S.subInfoUrl,a){let y=await Zr(a,s||S.subInfoUserAgent,void 0,E||S.proxy);y&&t.set("subscription-userinfo",la(y))}}catch(y){I.error(`\u6587\u4EF6 ${r} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(y)}`)}S.download&&t.set("Content-Disposition",`attachment; filename*=UTF-8''${encodeURIComponent(S.displayName||S.name)}`),t.set("Content-Type","text/plain; charset=utf-8"),w?.$options?._res?.headers&&Object.entries(w.$options._res.headers).forEach(([y,_])=>{t.set(y,_)}),t.send(w?.$content??"")}catch(w){I.notify("\u{1F30D} Sub-Store \u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25",`\u274C \u65E0\u6CD5\u4E0B\u8F7D\u6587\u4EF6\uFF1A${r}\uFF01`,`\u{1F914} \u539F\u56E0\uFF1A${w.message??w}`),I.error(w.message??w),Pe(t,new jt("INTERNAL_SERVER_ERROR",`Failed to download file: ${r}`,`Reason: ${w.message??w}`))}else I.error(`\u{1F30D} Sub-Store \u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25 \u274C \u672A\u627E\u5230\u6587\u4EF6\uFF1A${r}\uFF01`),Pe(t,new Vt("RESOURCE_NOT_FOUND",`File ${r} does not exist!`),404)}function OP(e,t){let{name:r}=e.params,{raw:n}=e.query;r=decodeURIComponent(r);let i=I.read(vt),a=Je(i,r);a?n?t.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_file_${r}_${ca(new Date)}.json`)}"`).send(JSON.stringify(a)):Ne(t,a):Pe(t,new Vt("FILE_NOT_FOUND",`File ${r} does not exist`,404))}function xP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.body,i=I.read(vt),a=Je(i,r);if(a){let s={...a,...n};if(I.info(`\u6B63\u5728\u66F4\u65B0\u6587\u4EF6\uFF1A${r}...`),r!==s.name){let u=I.read(ht)||[];for(let l of u)l.type==="file"&&l.source===a.name&&(l.source=s.name);I.write(u,ht)}yi(i,r,s),I.write(i,vt),Ne(t,s)}else Pe(t,new Vt("RESOURCE_NOT_FOUND",`File ${r} does not exist!`),404)}function NP(e,t){let{name:r}=e.params;r=decodeURIComponent(r),I.info(`\u6B63\u5728\u5220\u9664\u6587\u4EF6\uFF1A${r}`);let n=I.read(vt);oi(n,r),I.write(n,vt),Ne(t)}function kP(e,t){let r=I.read(vt);Ne(t,r.map(({content:n,...i})=>i))}function LP(e,t){let r=I.read(vt);Ne(t,r)}function UP(e,t){let r=e.body;I.write(r,vt),Ne(t)}function s1(e){I.read(ln)||I.write([],ln),e.post("/api/token",jP),e.route("/api/token/:token").delete(HP),e.route("/api/tokens").get(MP)}function HP(e,t){let{token:r}=e.params;r=decodeURIComponent(r),I.info(`\u6B63\u5728\u5220\u9664\uFF1A${r}`);let n=I.read(ln);oi(n,r,"token"),I.write(n,ln),Ne(t)}function MP(e,t){let{type:r,name:n}=e.query,i=I.read(ln)||[];Ne(t,r||n?i.filter(a=>(r?a.type===r:!0)&&(n?a.name===n:!0)):i)}async function jP(req,res){if(!Ir().isNode)return Pe(res,new At("INVALID_ENV","This endpoint is only available in Node.js environment"));try{let{payload,options}=req.body,ms=require("ms"),token=payload?.token;if(token!=null){if(typeof token!="string"||token.length<1)return Pe(res,new At("INVALID_CUSTOM_TOKEN",`Invalid custom token: ${token}`));if((I.read(ln)||[]).find(t=>t.token===token))return Pe(res,new At("DUPLICATE_TOKEN",`Token ${token} already exists`))}let type=payload?.type,name=payload?.name;if(!type||!name)return Pe(res,new At("INVALID_PAYLOAD","payload type and name are required"));if(type==="col"){if(!(I.read(Bt)||[]).find(r=>r.name===name))return Pe(res,new At("INVALID_COLLECTION",`collection ${name} not found`))}else if(type==="file"){if(!(I.read(vt)||[]).find(r=>r.name===name))return Pe(res,new At("INVALID_FILE",`file ${name} not found`))}else if(type==="sub"){if(!(I.read(Dt)||[]).find(r=>r.name===name))return Pe(res,new At("INVALID_SUB",`sub ${name} not found`))}else return Pe(res,new At("INVALID_TYPE",`type ${name} not supported`));let expiresIn=options?.expiresIn;if(options?.expiresIn!=null&&(expiresIn=ms(options.expiresIn),expiresIn==null||isNaN(expiresIn)||expiresIn<=0))return Pe(res,new At("INVALID_EXPIRES_IN",`Invalid expiresIn option: ${options.expiresIn}`));let nanoid=require("nanoid"),tokens=I.read(ln)||[];if(!token)do token=nanoid.customAlphabet(nanoid.urlAlphabet)();while(tokens.find(e=>e.token===token));return tokens.push({...payload,token,createdAt:Date.now(),expiresIn:expiresIn>0?options?.expiresIn:void 0,exp:expiresIn>0?Date.now()+expiresIn:void 0}),I.write(tokens,ln),Ne(res,{token})}catch(e){return Pe(res,new jt("TOKEN_SIGN_FAILED","Failed to sign token",`Reason: ${e.message??e}`))}}function a1(e){I.read(Gr)||I.write([],Gr),e.route("/api/module/:name").get(KP).patch(VP).delete(GP),e.route("/api/modules").get(zP).post(qP).put(YP)}function qP(e,t){let r=e.body;r.name=`${r.name??jn(JSON.stringify(r))}`,I.info(`\u6B63\u5728\u521B\u5EFA\u6A21\u5757\uFF1A${r.name}`);let n=I.read(Gr);if(Je(n,r.name))return Pe(t,new At("DUPLICATE_KEY",e.body.name?`\u5DF2\u5B58\u5728 name \u4E3A ${r.name} \u7684\u6A21\u5757`:"\u5DF2\u5B58\u5728\u76F8\u540C\u7684\u6A21\u5757 \u8BF7\u52FF\u91CD\u590D\u6DFB\u52A0"));n.push(r),I.write(n,Gr),Ne(t,r,201)}function KP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=I.read(Gr),i=Je(n,r);i?t.set("Content-Type","text/plain; charset=utf-8").send(i.content):Pe(t,new Vt("MODULE_NOT_FOUND",`Module ${r} does not exist`,404))}function VP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.body,i=I.read(Gr),a=Je(i,r);if(a){let s={...a,...n};I.info(`\u6B63\u5728\u66F4\u65B0\u6A21\u5757\uFF1A${r}...`),yi(i,r,s),I.write(i,Gr),Ne(t,s)}else Pe(t,new Vt("RESOURCE_NOT_FOUND",`Module ${r} does not exist!`),404)}function GP(e,t){let{name:r}=e.params;r=decodeURIComponent(r),I.info(`\u6B63\u5728\u5220\u9664\u6A21\u5757\uFF1A${r}`);let n=I.read(Gr);oi(n,r),I.write(n,Gr),Ne(t)}function zP(e,t){let r=I.read(Gr);Ne(t,r.map(({content:n,...i})=>i))}function YP(e,t){let r=e.body;I.write(r,Gr),Ne(t)}var rU=Cn(qA()),iU=Cn(YA());function y7(e){let t=Object.keys(e),r="",n="",i="";for(let a of t){let s=a.toLowerCase();s==="user-agent"?(r=e[a],n=r.toLowerCase()):s==="accept"&&(i=e[a])}return{UA:r,ua:n,accept:i}}function S7({ua:e,UA:t,accept:r}){return t.indexOf("Quantumult%20X")!==-1?"QX":e.indexOf("egern")!==-1?"Egern":t.indexOf("Surfboard")!==-1?"Surfboard":t.indexOf("Surge Mac")!==-1?"SurgeMac":t.indexOf("Surge")!==-1?"Surge":t.indexOf("Decar")!==-1||t.indexOf("Loon")!==-1?"Loon":t.indexOf("Shadowrocket")!==-1?"Shadowrocket":t.indexOf("Stash")!==-1?"Stash":e==="meta"||e.indexOf("clash")!==-1&&e.indexOf("meta")!==-1||e.indexOf("clash-verge")!==-1||e.indexOf("flclash")!==-1?"ClashMeta":e.indexOf("clash")!==-1?"Clash":e.indexOf("v2ray")!==-1?"V2Ray":e.indexOf("sing-box")!==-1||e.indexOf("singbox")!==-1?"sing-box":r.indexOf("application/json")===0?"JSON":"V2Ray"}function p1(e){let{UA:t,ua:r,accept:n}=y7(e);return S7({ua:r,UA:t,accept:n})}function d1(e,t){return!1}function g1(e){e.get("/share/col/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,I.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Mu(t,r)}),e.get("/share/col/:name",Mu),e.get("/share/sub/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,I.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Hu(t,r)}),e.get("/share/sub/:name",Hu),e.get("/download/collection/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,I.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Mu(t,r)}),e.get("/download/collection/:name",Mu),e.get("/download/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,I.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Hu(t,r)}),e.get("/download/:name",Hu),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 Mu(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 Hu(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 Mu(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 Hu(t,r)})}async function Hu(e,t){let{name:r,nezhaIndex:n}=e.params;r=decodeURIComponent(r),n=decodeURIComponent(n);let i=e.query.target==="SurgeMac",a=e.query.target||p1(e.headers)||"JSON",s=e.headers["user-agent"]||e.headers["User-Agent"];I.info(`\u6B63\u5728\u4E0B\u8F7D\u8BA2\u9605\uFF1A${r} \u8BF7\u6C42 User-Agent: ${s} \u8BF7\u6C42 target: ${e.query.target} \u5B9E\u9645\u8F93\u51FA: ${a}`);let{url:u,ua:l,content:f,mergeSources:d,ignoreFailedRemoteSub:E,produceType:p,includeUnsupportedProxy:h,resultFormat:A,proxy:m,noCache:S}=e.query,w={_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){try{w=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let D of e.query.$options.split("&")){let j=D.split("=")[0],q=D.split("=")[1];w[j]=q==null||q===""?!0:decodeURIComponent(q)}}I.info(`\u4F20\u5165 $options: ${JSON.stringify(w)}`)}u&&(u=decodeURIComponent(u),I.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 URL: ${u}`),/^https?:\/\//.test(u)||(f=u,I.info("URL \u4E0D\u662F\u94FE\u63A5\uFF0C\u89C6\u4E3A\u672C\u5730\u8BA2\u9605"))),f&&(f=decodeURIComponent(f),I.info(`\u6307\u5B9A\u672C\u5730\u8BA2\u9605: ${f}`)),m&&(m=decodeURIComponent(m),I.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${m}`)),l&&(l=decodeURIComponent(l),I.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 User-Agent: ${l}`)),d&&(d=decodeURIComponent(d),I.info(`\u6307\u5B9A\u5408\u5E76\u6765\u6E90: ${d}`)),E!=null&&E!==""&&(E=decodeURIComponent(E),I.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${E}`)),p&&(p=decodeURIComponent(p),I.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${p}`)),h&&(h=decodeURIComponent(h),I.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${h}`)),!h&&d1(a,s)&&(h=!0,I.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: ${h}`)),i&&I.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External"),S&&I.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${S}`);let y=I.read(Dt),_=Je(y,r);if(_)try{_.passThroughUA&&(I.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${s}`),l=s);let D=await Pr({type:"subscription",name:r,platform:a,url:u,ua:l,content:f,mergeSources:d,ignoreFailedRemoteSub:E,produceType:p,produceOpts:{"include-unsupported-proxy":h,useMihomoExternal:i},$options:w,proxy:m,noCache:S}),j;if(_.source!=="local"||["localFirst","remoteFirst"].includes(_.mergeSources))try{u=`${u||_.url}`.split(/[\r\n]+/).map(P=>P.trim()).filter(P=>P.length)?.[0]||"";let q={},F=u.split("#");if(u=u.split("#")[0],F.length>1)try{q=JSON.parse(decodeURIComponent(F[1]))}catch{for(let L of F[1].split("&")){let M=L.split("=")[0],V=L.split("=")[1];q[M]=V==null||V===""?!0:decodeURIComponent(V)}}!q.noFlow&&/^https?/.test(u)&&(j=await Zr(q?.insecure?`${u}#insecure`:u,q.flowUserAgent,void 0,m||_.proxy,q.flowUrl),j&&t.set("subscription-userinfo",la(j)))}catch(q){I.error(`\u8BA2\u9605 ${r} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(q)}`)}if(_.subUserinfo){let q;if(/^https?:\/\//.test(_.subUserinfo))try{q=await Zr(void 0,void 0,void 0,m||_.proxy,_.subUserinfo)}catch(F){I.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(F)}`)}else q=_.subUserinfo;t.set("subscription-userinfo",la([q,j].filter(F=>F).join(";")))}a==="JSON"?(A==="nezha"?D=XA(D):A==="nezha-monitor"&&(n=/^\d+$/.test(n)?parseInt(n,10):D.findIndex(q=>q.name===n),D=await WA(D[n],n,e.query)),t.set("Content-Type","application/json;charset=utf-8").send(D)):t.send(D)}catch(B){I.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${B.message??B}`),I.error(B.message??B),Pe(t,new jt("INTERNAL_SERVER_ERROR",`Failed to download subscription: ${r}`,`Reason: ${B.message??B}`))}else I.error(`\u{1F30D} Sub-Store \u4E0B\u8F7D\u8BA2\u9605\u5931\u8D25 \u274C \u672A\u627E\u5230\u8BA2\u9605\uFF1A${r}\uFF01`),Pe(t,new Vt("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404)}async function Mu(e,t){let{name:r,nezhaIndex:n}=e.params;r=decodeURIComponent(r),n=decodeURIComponent(n);let i=e.query.target==="SurgeMac",a=e.query.target||p1(e.headers)||"JSON",s=I.read(Bt),u=Je(s,r),l=e.headers["user-agent"]||e.headers["User-Agent"];I.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: ${a}`);let{ignoreFailedRemoteSub:f,produceType:d,includeUnsupportedProxy:E,resultFormat:p,proxy:h,noCache:A}=e.query,m={_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){try{m=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let w of e.query.$options.split("&")){let y=w.split("=")[0],_=w.split("=")[1];m[y]=_==null||_===""?!0:decodeURIComponent(_)}}I.info(`\u4F20\u5165 $options: ${JSON.stringify(m)}`)}if(h&&(h=decodeURIComponent(h),I.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${h}`)),f!=null&&f!==""&&(f=decodeURIComponent(f),I.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${f}`)),d&&(d=decodeURIComponent(d),I.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${d}`)),E&&(E=decodeURIComponent(E),I.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248/\u672A\u7EED\u8D39\u8BA2\u9605\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${E}`)),!E&&d1(a,l)&&(E=!0,I.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}`)),i&&I.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 Mihomo External"),A&&I.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${A}`),u)try{let S=await Pr({type:"collection",name:r,platform:a,ignoreFailedRemoteSub:f,produceType:d,produceOpts:{"include-unsupported-proxy":E,useMihomoExternal:i},$options:m,proxy:h,noCache:A,ua:l}),w,y=I.read(Dt),_=u.subscriptions;if(_.length>0){let j=Je(y,_[0]);if(j.source!=="local"||["localFirst","remoteFirst"].includes(j.mergeSources))try{let q=`${j.url}`.split(/[\r\n]+/).map(L=>L.trim()).filter(L=>L.length)?.[0]||"",F={},P=q.split("#");if(q=q.split("#")[0],P.length>1)try{F=JSON.parse(decodeURIComponent(P[1]))}catch{for(let M of P[1].split("&")){let V=M.split("=")[0],W=M.split("=")[1];F[V]=W==null||W===""?!0:decodeURIComponent(W)}}!F.noFlow&&/^https?:/.test(q)&&(w=await Zr(F?.insecure?`${q}#insecure`:q,F.flowUserAgent,void 0,h||j.proxy||u.proxy,F.flowUrl))}catch(q){I.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4E2D\u7684\u5B50\u8BA2\u9605 ${j.name} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${q.message??q}`)}if(j.subUserinfo){let q;if(/^https?:\/\//.test(j.subUserinfo))try{q=await Zr(void 0,void 0,void 0,h||j.proxy,j.subUserinfo)}catch(F){I.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${j.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(F)}`)}else q=j.subUserinfo;w=[q,w].filter(F=>F).join("; ")}}I.info(`\u7EC4\u5408\u8BA2\u9605 ${r} \u900F\u4F20\u7684\u7684\u6D41\u91CF\u4FE1\u606F: ${w}`);let B;if(/^https?:\/\//.test(u.subUserinfo))try{B=await Zr(void 0,void 0,void 0,h||u.proxy,u.subUserinfo)}catch(j){I.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${u.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(j)}`)}else B=u.subUserinfo;let D=[B,w].filter(j=>j).join("; ");D&&t.set("subscription-userinfo",la(D)),a==="JSON"?(p==="nezha"?S=XA(S):p==="nezha-monitor"&&(n=/^\d+$/.test(n)?parseInt(n,10):S.findIndex(j=>j.name===n),S=await WA(S[n],n,e.query)),t.set("Content-Type","application/json;charset=utf-8").send(S)):t.send(S)}catch(S){I.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${S}`),Pe(t,new jt("INTERNAL_SERVER_ERROR",`Failed to download collection: ${r}`,`Reason: ${S.message??S}`))}else I.error("\u{1F30D} Sub-Store \u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C \u672A\u627E\u5230\u7EC4\u5408\u8BA2\u9605\uFF1A${r}\uFF01`),Pe(t,new Vt("RESOURCE_NOT_FOUND",`Collection ${r} does not exist!`),404)}async function WA(e,t,r){let n={code:0,message:"success",result:[]};try{let{isLoon:i,isSurge:a}=I.env;if(!i&&!a)throw new Error("\u4EC5\u652F\u6301 Loon \u548C Surge(ability=http-client-policy)");let s=yt.produce([e],i?"Loon":"Surge");if(!s)throw new Error("\u5F53\u524D\u5BA2\u6237\u7AEF\u4E0D\u517C\u5BB9\u6B64\u8282\u70B9");let u=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(...u.map(f=>f.number))||3;for(let f of u){let E={monitor_id:u.indexOf(f),server_id:t,monitor_name:f.name,server_name:e.name,created_at:[],avg_delay:[]};for(let p=0;p{let i=r._geo?.countryCode||r._geo?.country;if(/^[a-z]{2}$/i.test(i)||(i=ih(r.name)),/^[a-z]{2}$/i.test(i)){let a=Math.round(new Date().getTime()/1e3),s=r._unavailable?0:a,u=parseInt(r._uptime||0,10);t.result.push({id:n,name:r.name,tag:`${r._tag??""}`,last_active:s,valid_ip:r._IP||r.server,ipv4:r._IPv4||r.server,ipv6:r._IPv6||(ur(r.server)?r.server:""),host:{Platform:"Sub-Store",PlatformVersion:Qi.version,CPU:[],MemTotal:1024,DiskTotal:1024,SwapTotal:1024,Arch:"",Virtualization:"",BootTime:a-u,CountryCode:i,Version:"0.0.1"},status:{CPU:0,MemUsed:0,SwapUsed:0,DiskUsed:0,NetInTransfer:0,NetOutTransfer:0,NetInSpeed:0,NetOutSpeed:0,Uptime:u,Load1:0,Load5:0,Load15:0,TcpConnCount:0,UdpConnCount:0,ProcessCount:0}})}}),JSON.stringify(t,null,2)}function m1(e){e.post("/api/preview/sub",C7),e.post("/api/preview/collection",_7),e.post("/api/preview/file",b7)}async function b7(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 u={};if(n=await Promise.all(r.url.split(/[\r\n]+/).map(l=>l.trim()).filter(l=>l.length).map(async l=>{try{return await yr(l,r.ua,void 0,r.proxy)}catch(f){return u[l]=f,I.error(`\u6587\u4EF6 ${r.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${l} \u53D1\u751F\u9519\u8BEF: ${f}`),""}})),Object.keys(u).length>0)if(r.ignoreFailedRemoteFile)r.ignoreFailedRemoteFile==="enabled"&&I.notify("\u{1F30D} Sub-Store \u9884\u89C8\u6587\u4EF6\u5931\u8D25",`\u274C ${r.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(u).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(u).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 i=(Array.isArray(n)?n:[n]).flat(),a=i.filter(u=>u!=null&&u!=="").join(` `),s=Array.isArray(r.process)&&r.process.length>0?await yt.process({$files:i,$content:a,$file:r},r.process):{$content:a,$files:i};Ne(t,{original:a,processed:s?.$content??""})}catch(r){I.error(r.message??r),Pe(t,new jt("INTERNAL_SERVER_ERROR","Failed to preview file",`Reason: ${r.message??r}`))}}async function C7(e,t){try{let r=e.body,n=e.query.target||"JSON",i;if(r.source==="local"&&!["localFirst","remoteFirst"].includes(r.mergeSources))i=r.content;else{let u={};if(i=await Promise.all(r.url.split(/[\r\n]+/).map(l=>l.trim()).filter(l=>l.length).map(async l=>{try{return await yr(l,r.ua,void 0,r.proxy,void 0,void 0,void 0,!0)}catch(f){return u[l]=f,I.error(`\u8BA2\u9605 ${r.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${l} \u53D1\u751F\u9519\u8BEF: ${f}`),""}})),Object.keys(u).length>0)if(r.ignoreFailedRemoteSub)r.ignoreFailedRemoteSub==="enabled"&&I.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${r.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(u).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(u).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);r.mergeSources==="localFirst"?i.unshift(r.content):r.mergeSources==="remoteFirst"&&i.push(r.content)}let a=(Array.isArray(i)?i:[i]).map(u=>yt.parse(u)).flat();a.forEach((u,l)=>{u.id=l,u._subName=r.name,u._subDisplayName=r.displayName});let s=await yt.process(a,r.process||[],n,{[r.name]:r});Ne(t,{original:a,processed:s})}catch(r){I.error(r.message??r),Pe(t,new jt("INTERNAL_SERVER_ERROR","Failed to preview subscription",`Reason: ${r.message??r}`))}}async function _7(e,t){try{let r=I.read(Dt),n=e.body,i=[...n.subscriptions],a=n.subscriptionTags;Array.isArray(a)&&a.length>0&&r.forEach(d=>{Array.isArray(d.tag)&&d.tag.length>0&&!i.includes(d.name)&&d.tag.some(E=>a.includes(E))&&i.push(d.name)});let s={},u={};if(await Promise.all(i.map(async d=>{let E=Je(r,d);try{let p;if(E.source==="local"&&!["localFirst","remoteFirst"].includes(E.mergeSources))p=E.content;else{let A={};if(p=await Promise.all(E.url.split(/[\r\n]+/).map(m=>m.trim()).filter(m=>m.length).map(async m=>{try{return await yr(m,E.ua,void 0,E.proxy,void 0,void 0,void 0,!0)}catch(S){return A[m]=S,I.error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${m} \u53D1\u751F\u9519\u8BEF: ${S}`),""}})),Object.keys(A).length>0)if(E.ignoreFailedRemoteSub)E.ignoreFailedRemoteSub==="enabled"&&I.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,`\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(A).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(A).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);E.mergeSources==="localFirst"?p.unshift(E.content):E.mergeSources==="remoteFirst"&&p.push(E.content)}let h=(Array.isArray(p)?p:[p]).map(A=>yt.parse(A)).flat();h.forEach(A=>{A._subName=E.name,A._subDisplayName=E.displayName,A._collectionName=n.name,A._collectionDisplayName=n.displayName}),h=await yt.process(h,E.process||[],"JSON",{[E.name]:E,_collection:n}),s[d]=h}catch(p){u[d]=p,I.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605 ${n.name} \u4E2D\u7684\u5B50\u8BA2\u9605: ${E.name} \u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${p}\uFF01`)}})),Object.keys(u).length>0)if(n.ignoreFailedRemoteSub)n.ignoreFailedRemoteSub==="enabled"&&I.notify("\u{1F30D} Sub-Store \u9884\u89C8\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${n.name}`,`\u5B50\u8BA2\u9605 ${Object.keys(u).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(u).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let l=Array.prototype.concat.apply([],i.map(d=>s[d]||[]));l.forEach((d,E)=>{d.id=E,d._collectionName=n.name,d._collectionDisplayName=n.displayName});let f=await yt.process(l,n.process||[],"JSON",{_collection:n});Ne(t,{original:l,processed:f})}catch(r){I.error(r.message??r),Pe(t,new jt("INTERNAL_SERVER_ERROR","Failed to preview collection",`Reason: ${r.message??r}`))}}function v1(e){e.post("/api/sort/subs",F7),e.post("/api/sort/collections",I7),e.post("/api/sort/artifacts",$7),e.post("/api/sort/files",D7)}function F7(e,t){let r=e.body,n=I.read(Dt);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),I.write(n,Dt),Ne(t,n)}function I7(e,t){let r=e.body,n=I.read(Bt);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),I.write(n,Bt),Ne(t,n)}function $7(e,t){let r=e.body,n=I.read(ht);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),I.write(n,ht),Ne(t,n)}function D7(e,t){let r=e.body,n=I.read(vt);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),I.write(n,vt),Ne(t,n)}function E1(e){e.post("/api/utils/node-info",B7)}async function B7(e,t){let r=e.body,n=e.query.lang||"zh-CN",i;try{i=mh.URI.produce(r)}catch{}try{let s=await wi().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(u=>{let l=JSON.parse(u.body);if(l.status!=="success")throw new Error(l.message);return delete l.status,l});Ne(t,{shareUrl:i,info:s})}catch(a){Pe(t,new lu("FAILED_TO_GET_NODE_INFO","Failed to get node info",`Reason: ${a}`))}}function w1(e){e.route("/api/proxy/parse").post(R7),e.route("/api/rule/parse").post(P7)}function R7(e,t){let{data:r,client:n,content:i,platform:a}=e.body;var s={};try{var u=yt.parse(r??i),l=yt.produce(u,n??a);s.par_res=l}catch(f){Pe(t,f);return}Ne(t,s)}function P7(e,t){let{data:r,client:n,content:i,platform:a}=e.body;var s={};try{let l=wo.parse(r??i);var u=wo.produce(l,n??a);s.par_res=u}catch(l){Pe(t,l);return}Ne(t,s)}function A1(){let port,host;I.env.isNode&&(port=eval("process.env.SUB_STORE_BACKEND_API_PORT")||3e3,host=eval("process.env.SUB_STORE_BACKEND_API_HOST")||"::");let $app=Qp({substore:I,port,host});if(I.env.isNode){let be_merge=eval("process.env.SUB_STORE_BACKEND_MERGE"),be_prefix=eval("process.env.SUB_STORE_BACKEND_PREFIX"),fe_be_path=eval("process.env.SUB_STORE_FRONTEND_BACKEND_PATH"),fe_path=eval("process.env.SUB_STORE_FRONTEND_PATH");if(be_prefix||be_merge){if(!fe_be_path.startsWith("/"))throw new Error("SUB_STORE_FRONTEND_BACKEND_PATH should start with /");be_merge&&(I.info("[BACKEND] MERGE mode is [ON]."),I.info(`[BACKEND && FRONTEND] ${host}:${port}`)),I.info(`[BACKEND PREFIX] ${host}:${port}${fe_be_path}`),$app.use((req,res,next)=>{if(req.path.startsWith(fe_be_path)){req.url=req.url.replace(fe_be_path,"")||"/",be_merge&&req.url.startsWith("/api/")&&(req.query.share="true"),next();return}let pathname=decodeURIComponent(req._parsedUrl.pathname)||"/";if(be_merge&&req.path.startsWith("/share/")&&req.query.token){if(req.method.toLowerCase()!=="get"){res.status(405).send("Method not allowed");return}if((I.read(ln)||[]).find(r=>r.token===req.query.token&&`/share/${r.type}/${r.name}`===pathname&&(r.exp==null||r.exp>Date.now()))){next();return}}if(be_merge&&fe_path&&req.path.indexOf("/",1)==-1){req.path.indexOf(".")==-1&&(req.url="/index.html");let express_=require("express"),mime_=require("mime-types"),path_=require("path"),staticFileMiddleware=express_.static(fe_path,{setHeaders:(e,t)=>{let r=mime_.contentType(path_.extname(t));r&&e.set("Content-Type",r)}});staticFileMiddleware(req,res,next);return}res.status(403).end("Forbbiden")})}}if(n1($app),r1($app),g1($app),m1($app),v1($app),e1($app),X0($app),i1($app),s1($app),a1($app),J0($app),E1($app),t1($app),w1($app),$app.start(),I.env.isNode){let backend_sync_cron=eval("process.env.SUB_STORE_BACKEND_SYNC_CRON")||eval("process.env.SUB_STORE_BACKEND_CRON");if(backend_sync_cron){I.info(`[SYNC CRON] ${backend_sync_cron} enabled`);let{CronJob}=require("cron");new CronJob(backend_sync_cron,async function(){try{I.info(`[SYNC CRON] ${backend_sync_cron} started`),await Z0(),I.info(`[SYNC CRON] ${backend_sync_cron} finished`)}catch(e){I.error(`[SYNC CRON] ${backend_sync_cron} error: ${e.message??e}`)}},null,!0)}let produce_cron=eval("process.env.SUB_STORE_PRODUCE_CRON");if(produce_cron){I.info(`[PRODUCE CRON] ${produce_cron} enabled`);let{CronJob}=require("cron");produce_cron.split(/\s*;\s*/).map(e=>{let[t,r,n]=e.split(/\s*,\s*/);new CronJob(t.trim(),async function(){try{I.info(`[PRODUCE CRON] ${r} ${n} ${t} started`),await Pr({type:r,name:n}),I.info(`[PRODUCE CRON] ${r} ${n} ${t} finished`)}catch(i){I.error(`[PRODUCE CRON] ${r} ${n} ${t} error: ${i.message??i}`)}},null,!0)})}let backend_download_cron=eval("process.env.SUB_STORE_BACKEND_DOWNLOAD_CRON");if(backend_download_cron){I.info(`[DOWNLOAD CRON] ${backend_download_cron} enabled`);let{CronJob}=require("cron");new CronJob(backend_download_cron,async function(){try{I.info(`[DOWNLOAD CRON] ${backend_download_cron} started`),await Dh("download"),I.info(`[DOWNLOAD CRON] ${backend_download_cron} finished`)}catch(e){I.error(`[DOWNLOAD CRON] ${backend_download_cron} error: ${e.message??e}`)}},null,!0)}let backend_upload_cron=eval("process.env.SUB_STORE_BACKEND_UPLOAD_CRON");if(backend_upload_cron){I.info(`[UPLOAD CRON] ${backend_upload_cron} enabled`);let{CronJob}=require("cron");new CronJob(backend_upload_cron,async function(){try{I.info(`[UPLOAD CRON] ${backend_upload_cron} started`),await Dh("upload"),I.info(`[UPLOAD CRON] ${backend_upload_cron} finished`)}catch(e){I.error(`[UPLOAD CRON] ${backend_upload_cron} error: ${e.message??e}`)}},null,!0)}let mmdb_cron=eval("process.env.SUB_STORE_MMDB_CRON"),countryFile=eval("process.env.SUB_STORE_MMDB_COUNTRY_PATH"),countryUrl=eval("process.env.SUB_STORE_MMDB_COUNTRY_URL"),asnFile=eval("process.env.SUB_STORE_MMDB_ASN_PATH"),asnUrl=eval("process.env.SUB_STORE_MMDB_ASN_URL");if(mmdb_cron&&(countryFile&&countryUrl||asnFile&&asnUrl)){I.info(`[MMDB CRON] ${mmdb_cron} enabled`);let{CronJob}=require("cron");new CronJob(mmdb_cron,async function(){try{if(I.info(`[MMDB CRON] ${mmdb_cron} started`),countryFile&&countryUrl)try{I.info(`[MMDB CRON] downloading ${countryUrl} to ${countryFile}`),await pl(countryUrl,countryFile)}catch(e){I.error(`[MMDB CRON] ${countryUrl} download failed: ${e.message??e}`)}if(asnFile&&asnUrl)try{I.info(`[MMDB CRON] downloading ${asnUrl} to ${asnFile}`),await pl(asnUrl,asnFile)}catch(e){I.error(`[MMDB CRON] ${asnUrl} download failed: ${e.message??e}`)}I.info(`[MMDB CRON] ${mmdb_cron} finished`)}catch(e){I.error(`[MMDB CRON] ${mmdb_cron} error: ${e.message??e}`)}},null,!0)}let path=require("path"),fs=require("fs"),data_url=eval("process.env.SUB_STORE_DATA_URL"),fe_be_path=eval("process.env.SUB_STORE_FRONTEND_BACKEND_PATH"),fe_port=eval("process.env.SUB_STORE_FRONTEND_PORT")||3001,fe_host=eval("process.env.SUB_STORE_FRONTEND_HOST")||host||"::",fe_path=eval("process.env.SUB_STORE_FRONTEND_PATH"),fe_abs_path=path.resolve(fe_path||path.join(__dirname,"frontend")),be_merge=eval("process.env.SUB_STORE_BACKEND_MERGE");if(fe_path&&!be_merge){try{fs.accessSync(path.join(fe_abs_path,"index.html"))}catch(e){I.error(`[FRONTEND] index.html file not found in ${fe_abs_path}`)}let express_=require("express"),history=require("connect-history-api-fallback"),{createProxyMiddleware}=require("http-proxy-middleware"),app=express_(),staticFileMiddleware=express_.static(fe_path),be_api="/api/",be_download="/download/",be_share="/share/",be_download_rewrite="",be_api_rewrite="",be_share_rewrite=`${be_share}:type/:name`,prefix=eval("process.env.SUB_STORE_BACKEND_PREFIX")?fe_be_path:"";if(fe_be_path){if(!fe_be_path.startsWith("/"))throw new Error("SUB_STORE_FRONTEND_BACKEND_PATH should start with /");be_api_rewrite=`${fe_be_path==="/"?"":fe_be_path}${be_api}`,be_download_rewrite=`${fe_be_path==="/"?"":fe_be_path}${be_download}`,app.use(be_share_rewrite,createProxyMiddleware({target:`http://127.0.0.1:${port}${prefix}`,changeOrigin:!0,pathRewrite:async(e,t)=>{if(t.method.toLowerCase()!=="get")throw new Error("Method not allowed");if(!(I.read(ln)||[]).find(i=>i.token===t.query.token&&i.type===t.params.type&&i.name===t.params.name&&(i.exp==null||i.exp>Date.now())))throw new Error("Forbbiden");return t.originalUrl}})),app.use(be_api_rewrite,createProxyMiddleware({target:`http://127.0.0.1:${port}${prefix}${be_api}`,pathRewrite:async e=>e.includes("?")?`${e}&share=true`:`${e}?share=true`})),app.use(be_download_rewrite,createProxyMiddleware({target:`http://127.0.0.1:${port}${prefix}${be_download}`,changeOrigin:!0}))}app.use(staticFileMiddleware),app.use(history({disableDotRule:!0,verbose:!1})),app.use(staticFileMiddleware);let listener=app.listen(fe_port,fe_host,()=>{let{address:e,port:t}=listener.address();I.info(`[FRONTEND] ${e}:${t}`),fe_be_path&&(I.info(`[FRONTEND -> BACKEND] ${e}:${t}${be_api_rewrite} -> ${host}:${port}${prefix}${be_api}`),I.info(`[FRONTEND -> BACKEND] ${e}:${t}${be_download_rewrite} -> ${host}:${port}${prefix}${be_download}`),I.info(`[SHARE BACKEND] ${e}:${t}${be_share_rewrite}`))})}data_url&&(I.info(`[BACKEND] downloading data from ${data_url}`),yr(data_url).then(e=>{I.write(e,"#sub-store"),I.cache=JSON.parse(e),I.persistCache(),aa(),I.info(`[BACKEND] restored data from ${data_url}`)}).catch(e=>{throw I.error("[BACKEND] restore data failed"),console.error(e),e}))}}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${uf} \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 `);aa();A1();})(); /*! 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 *) */