(()=>{var $O=Object.create;var sw=Object.defineProperty;var PO=Object.getOwnPropertyDescriptor;var xO=Object.getOwnPropertyNames;var TO=Object.getPrototypeOf,RO=Object.prototype.hasOwnProperty;var iw=(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 Ce=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kO=(e,t)=>{for(var r in t)sw(e,r,{get:t[r],enumerable:!0})},OO=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of xO(t))!RO.call(e,i)&&i!==r&&sw(e,i,{get:()=>t[i],enumerable:!(n=PO(t,i))||n.enumerable});return e};var P=(e,t,r)=>(r=e!=null?$O(TO(e)):{},OO(t||!e||!e.__esModule?sw(r,"default",{value:e,enumerable:!0}):r,e));var ui=Ce((ow,X3)=>{"use strict";var _te=P(x()),bd=function(e){return e&&e.Math===Math&&e};X3.exports=bd(typeof globalThis=="object"&&globalThis)||bd(typeof window=="object"&&window)||bd(typeof self=="object"&&self)||bd(typeof global=="object"&&global)||bd(typeof ow=="object"&&ow)||function(){return this}()||Function("return this")()});var Na=Ce((Dte,J3)=>{"use strict";var Fte=P(x());J3.exports=function(e){try{return!!e()}catch{return!0}}});var Ku=Ce((Bte,Z3)=>{"use strict";var Ite=P(x()),NO=Na();Z3.exports=!NO(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var aw=Ce(($te,Q3)=>{"use strict";var Pte=P(x()),LO=Na();Q3.exports=!LO(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")})});var o1=Ce((xte,e5)=>{"use strict";var Tte=P(x()),UO=aw(),i1=Function.prototype.call;e5.exports=UO?i1.bind(i1):function(){return i1.apply(i1,arguments)}});var s5=Ce(n5=>{"use strict";var kte=P(x()),t5={}.propertyIsEnumerable,r5=Object.getOwnPropertyDescriptor,HO=r5&&!t5.call({1:2},1);n5.f=HO?function(t){var r=r5(this,t);return!!r&&r.enumerable}:t5});var uw=Ce((Ote,i5)=>{"use strict";var Nte=P(x());i5.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}});var Ro=Ce((Lte,u5)=>{"use strict";var Ute=P(x()),o5=aw(),a5=Function.prototype,cw=a5.call,MO=o5&&a5.bind.bind(cw,cw);u5.exports=o5?MO:function(e){return function(){return cw.apply(e,arguments)}}});var f5=Ce((Hte,l5)=>{"use strict";var Mte=P(x()),c5=Ro(),jO=c5({}.toString),qO=c5("".slice);l5.exports=function(e){return qO(jO(e),8,-1)}});var d5=Ce((jte,h5)=>{"use strict";var qte=P(x()),KO=Ro(),VO=Na(),zO=f5(),lw=Object,GO=KO("".split);h5.exports=VO(function(){return!lw("z").propertyIsEnumerable(0)})?function(e){return zO(e)==="String"?GO(e,""):lw(e)}:lw});var fw=Ce((Kte,p5)=>{"use strict";var Vte=P(x());p5.exports=function(e){return e==null}});var hw=Ce((zte,m5)=>{"use strict";var Gte=P(x()),YO=fw(),WO=TypeError;m5.exports=function(e){if(YO(e))throw new WO("Can't call method on "+e);return e}});var a1=Ce((Yte,g5)=>{"use strict";var Wte=P(x()),XO=d5(),JO=hw();g5.exports=function(e){return XO(JO(e))}});var Vi=Ce((Xte,v5)=>{"use strict";var Jte=P(x()),dw=typeof document=="object"&&document.all;v5.exports=typeof dw>"u"&&dw!==void 0?function(e){return typeof e=="function"||e===dw}:function(e){return typeof e=="function"}});var yf=Ce((Zte,w5)=>{"use strict";var Qte=P(x()),ZO=Vi();w5.exports=function(e){return typeof e=="object"?e!==null:ZO(e)}});var mw=Ce((ere,y5)=>{"use strict";var tre=P(x()),pw=ui(),QO=Vi(),eN=function(e){return QO(e)?e:void 0};y5.exports=function(e,t){return arguments.length<2?eN(pw[e]):pw[e]&&pw[e][t]}});var b5=Ce((rre,E5)=>{"use strict";var nre=P(x()),tN=Ro();E5.exports=tN({}.isPrototypeOf)});var _5=Ce((sre,C5)=>{"use strict";var ire=P(x()),rN=ui(),A5=rN.navigator,S5=A5&&A5.userAgent;C5.exports=S5?String(S5):""});var x5=Ce((ore,P5)=>{"use strict";var are=P(x()),$5=ui(),gw=_5(),D5=$5.process,F5=$5.Deno,B5=D5&&D5.versions||F5&&F5.version,I5=B5&&B5.v8,zi,u1;I5&&(zi=I5.split("."),u1=zi[0]>0&&zi[0]<4?1:+(zi[0]+zi[1]));!u1&&gw&&(zi=gw.match(/Edge\/(\d+)/),(!zi||zi[1]>=74)&&(zi=gw.match(/Chrome\/(\d+)/),zi&&(u1=+zi[1])));P5.exports=u1});var vw=Ce((ure,R5)=>{"use strict";var cre=P(x()),T5=x5(),nN=Na(),sN=ui(),iN=sN.String;R5.exports=!!Object.getOwnPropertySymbols&&!nN(function(){var e=Symbol("symbol detection");return!iN(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&T5&&T5<41})});var ww=Ce((lre,k5)=>{"use strict";var fre=P(x()),oN=vw();k5.exports=oN&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var yw=Ce((hre,O5)=>{"use strict";var dre=P(x()),aN=mw(),uN=Vi(),cN=b5(),lN=ww(),fN=Object;O5.exports=lN?function(e){return typeof e=="symbol"}:function(e){var t=aN("Symbol");return uN(t)&&cN(t.prototype,fN(e))}});var L5=Ce((pre,N5)=>{"use strict";var mre=P(x()),hN=String;N5.exports=function(e){try{return hN(e)}catch{return"Object"}}});var H5=Ce((gre,U5)=>{"use strict";var vre=P(x()),dN=Vi(),pN=L5(),mN=TypeError;U5.exports=function(e){if(dN(e))return e;throw new mN(pN(e)+" is not a function")}});var j5=Ce((wre,M5)=>{"use strict";var yre=P(x()),gN=H5(),vN=fw();M5.exports=function(e,t){var r=e[t];return vN(r)?void 0:gN(r)}});var K5=Ce((Ere,q5)=>{"use strict";var bre=P(x()),Ew=o1(),bw=Vi(),Aw=yf(),wN=TypeError;q5.exports=function(e,t){var r,n;if(t==="string"&&bw(r=e.toString)&&!Aw(n=Ew(r,e))||bw(r=e.valueOf)&&!Aw(n=Ew(r,e))||t!=="string"&&bw(r=e.toString)&&!Aw(n=Ew(r,e)))return n;throw new wN("Can't convert object to primitive value")}});var z5=Ce((Are,V5)=>{"use strict";var Sre=P(x());V5.exports=!1});var c1=Ce((Cre,Y5)=>{"use strict";var _re=P(x()),G5=ui(),yN=Object.defineProperty;Y5.exports=function(e,t){try{yN(G5,e,{value:t,configurable:!0,writable:!0})}catch{G5[e]=t}return t}});var l1=Ce((Dre,J5)=>{"use strict";var Fre=P(x()),EN=z5(),bN=ui(),AN=c1(),W5="__core-js_shared__",X5=J5.exports=bN[W5]||AN(W5,{});(X5.versions||(X5.versions=[])).push({version:"3.49.0",mode:EN?"pure":"global",copyright:"\xA9 2013\u20132025 Denis Pushkarev (zloirock.ru), 2025\u20132026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Sw=Ce((Bre,Q5)=>{"use strict";var Ire=P(x()),Z5=l1();Q5.exports=function(e,t){return Z5[e]||(Z5[e]=t||{})}});var t4=Ce(($re,e4)=>{"use strict";var Pre=P(x()),SN=hw(),CN=Object;e4.exports=function(e){return CN(SN(e))}});var La=Ce((xre,r4)=>{"use strict";var Tre=P(x()),_N=Ro(),DN=t4(),FN=_N({}.hasOwnProperty);r4.exports=Object.hasOwn||function(t,r){return FN(DN(t),r)}});var Cw=Ce((Rre,n4)=>{"use strict";var kre=P(x()),BN=Ro(),IN=0,$N=Math.random(),PN=BN(1.1.toString);n4.exports=function(e){return"Symbol("+(e===void 0?"":e)+")_"+PN(++IN+$N,36)}});var o4=Ce((Ore,i4)=>{"use strict";var Nre=P(x()),xN=ui(),TN=Sw(),s4=La(),RN=Cw(),kN=vw(),ON=ww(),Ef=xN.Symbol,_w=TN("wks"),NN=ON?Ef.for||Ef:Ef&&Ef.withoutSetter||RN;i4.exports=function(e){return s4(_w,e)||(_w[e]=kN&&s4(Ef,e)?Ef[e]:NN("Symbol."+e)),_w[e]}});var l4=Ce((Lre,c4)=>{"use strict";var Ure=P(x()),LN=o1(),a4=yf(),u4=yw(),UN=j5(),HN=K5(),MN=o4(),jN=TypeError,qN=MN("toPrimitive");c4.exports=function(e,t){if(!a4(e)||u4(e))return e;var r=UN(e,qN),n;if(r){if(t===void 0&&(t="default"),n=LN(r,e,t),!a4(n)||u4(n))return n;throw new jN("Can't convert object to primitive value")}return t===void 0&&(t="number"),HN(e,t)}});var Dw=Ce((Hre,f4)=>{"use strict";var Mre=P(x()),KN=l4(),VN=yw();f4.exports=function(e){var t=KN(e,"string");return VN(t)?t:t+""}});var p4=Ce((jre,d4)=>{"use strict";var qre=P(x()),zN=ui(),h4=yf(),Fw=zN.document,GN=h4(Fw)&&h4(Fw.createElement);d4.exports=function(e){return GN?Fw.createElement(e):{}}});var Bw=Ce((Kre,m4)=>{"use strict";var Vre=P(x()),YN=Ku(),WN=Na(),XN=p4();m4.exports=!YN&&!WN(function(){return Object.defineProperty(XN("div"),"a",{get:function(){return 7}}).a!==7})});var Iw=Ce(v4=>{"use strict";var Gre=P(x()),JN=Ku(),ZN=o1(),QN=s5(),eL=uw(),tL=a1(),rL=Dw(),nL=La(),sL=Bw(),g4=Object.getOwnPropertyDescriptor;v4.f=JN?g4:function(t,r){if(t=tL(t),r=rL(r),sL)try{return g4(t,r)}catch{}if(nL(t,r))return eL(!ZN(QN.f,t,r),t[r])}});var y4=Ce((Yre,w4)=>{"use strict";var Wre=P(x()),iL=Ku(),oL=Na();w4.exports=iL&&oL(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var $w=Ce((Xre,E4)=>{"use strict";var Jre=P(x()),aL=yf(),uL=String,cL=TypeError;E4.exports=function(e){if(aL(e))return e;throw new cL(uL(e)+" is not an object")}});var h1=Ce(A4=>{"use strict";var Qre=P(x()),lL=Ku(),fL=Bw(),hL=y4(),f1=$w(),b4=Dw(),dL=TypeError,Pw=Object.defineProperty,pL=Object.getOwnPropertyDescriptor,xw="enumerable",Tw="configurable",Rw="writable";A4.f=lL?hL?function(t,r,n){if(f1(t),r=b4(r),f1(n),typeof t=="function"&&r==="prototype"&&"value"in n&&Rw in n&&!n[Rw]){var i=pL(t,r);i&&i[Rw]&&(t[r]=n.value,n={configurable:Tw in n?n[Tw]:i[Tw],enumerable:xw in n?n[xw]:i[xw],writable:!1})}return Pw(t,r,n)}:Pw:function(t,r,n){if(f1(t),r=b4(r),f1(n),fL)try{return Pw(t,r,n)}catch{}if("get"in n||"set"in n)throw new dL("Accessors not supported");return"value"in n&&(t[r]=n.value),t}});var kw=Ce((ene,S4)=>{"use strict";var tne=P(x()),mL=Ku(),gL=h1(),vL=uw();S4.exports=mL?function(e,t,r){return gL.f(e,t,vL(1,r))}:function(e,t,r){return e[t]=r,e}});var D4=Ce((rne,_4)=>{"use strict";var nne=P(x()),Ow=Ku(),wL=La(),C4=Function.prototype,yL=Ow&&Object.getOwnPropertyDescriptor,Nw=wL(C4,"name"),EL=Nw&&function(){}.name==="something",bL=Nw&&(!Ow||Ow&&yL(C4,"name").configurable);_4.exports={EXISTS:Nw,PROPER:EL,CONFIGURABLE:bL}});var B4=Ce((sne,F4)=>{"use strict";var ine=P(x()),AL=Ro(),SL=Vi(),Lw=l1(),CL=AL(Function.toString);SL(Lw.inspectSource)||(Lw.inspectSource=function(e){return CL(e)});F4.exports=Lw.inspectSource});var P4=Ce((one,$4)=>{"use strict";var ane=P(x()),_L=ui(),DL=Vi(),I4=_L.WeakMap;$4.exports=DL(I4)&&/native code/.test(String(I4))});var R4=Ce((une,T4)=>{"use strict";var cne=P(x()),FL=Sw(),BL=Cw(),x4=FL("keys");T4.exports=function(e){return x4[e]||(x4[e]=BL(e))}});var Uw=Ce((lne,k4)=>{"use strict";var fne=P(x());k4.exports={}});var U4=Ce((hne,L4)=>{"use strict";var dne=P(x()),IL=P4(),N4=ui(),$L=yf(),PL=kw(),Hw=La(),Mw=l1(),xL=R4(),TL=Uw(),O4="Object already initialized",jw=N4.TypeError,RL=N4.WeakMap,d1,Ad,p1,kL=function(e){return p1(e)?Ad(e):d1(e,{})},OL=function(e){return function(t){var r;if(!$L(t)||(r=Ad(t)).type!==e)throw new jw("Incompatible receiver, "+e+" required");return r}};IL||Mw.state?(Gi=Mw.state||(Mw.state=new RL),Gi.get=Gi.get,Gi.has=Gi.has,Gi.set=Gi.set,d1=function(e,t){if(Gi.has(e))throw new jw(O4);return t.facade=e,Gi.set(e,t),t},Ad=function(e){return Gi.get(e)||{}},p1=function(e){return Gi.has(e)}):(sl=xL("state"),TL[sl]=!0,d1=function(e,t){if(Hw(e,sl))throw new jw(O4);return t.facade=e,PL(e,sl,t),t},Ad=function(e){return Hw(e,sl)?e[sl]:{}},p1=function(e){return Hw(e,sl)});var Gi,sl;L4.exports={set:d1,get:Ad,has:p1,enforce:kL,getterFor:OL}});var q4=Ce((pne,j4)=>{"use strict";var mne=P(x()),Kw=Ro(),NL=Na(),LL=Vi(),m1=La(),qw=Ku(),UL=D4().CONFIGURABLE,HL=B4(),M4=U4(),ML=M4.enforce,jL=M4.get,H4=String,g1=Object.defineProperty,qL=Kw("".slice),KL=Kw("".replace),VL=Kw([].join),zL=qw&&!NL(function(){return g1(function(){},"length",{value:8}).length!==8}),GL=String(String).split("String"),YL=j4.exports=function(e,t,r){qL(H4(t),0,7)==="Symbol("&&(t="["+KL(H4(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!m1(e,"name")||UL&&e.name!==t)&&(qw?g1(e,"name",{value:t,configurable:!0}):e.name=t),zL&&r&&m1(r,"arity")&&e.length!==r.arity&&g1(e,"length",{value:r.arity});try{r&&m1(r,"constructor")&&r.constructor?qw&&g1(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var n=ML(e);return m1(n,"source")||(n.source=VL(GL,typeof t=="string"?t:"")),e};Function.prototype.toString=YL(function(){return LL(this)&&jL(this).source||HL(this)},"toString")});var V4=Ce((gne,K4)=>{"use strict";var vne=P(x()),WL=Vi(),XL=h1(),JL=q4(),ZL=c1();K4.exports=function(e,t,r,n){n||(n={});var i=n.enumerable,o=n.name!==void 0?n.name:t;if(WL(r)&&JL(r,o,n),n.global)i?e[t]=r:ZL(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch{}i?e[t]=r:XL.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e}});var G4=Ce((wne,z4)=>{"use strict";var yne=P(x()),QL=Math.ceil,eU=Math.floor;z4.exports=Math.trunc||function(t){var r=+t;return(r>0?eU:QL)(r)}});var Vw=Ce((Ene,Y4)=>{"use strict";var bne=P(x()),tU=G4();Y4.exports=function(e){var t=+e;return t!==t||t===0?0:tU(t)}});var X4=Ce((Ane,W4)=>{"use strict";var Sne=P(x()),rU=Vw(),nU=Math.max,sU=Math.min;W4.exports=function(e,t){var r=rU(e);return r<0?nU(r+t,0):sU(r,t)}});var Z4=Ce((Cne,J4)=>{"use strict";var _ne=P(x()),iU=Vw(),oU=Math.min;J4.exports=function(e){var t=iU(e);return t>0?oU(t,9007199254740991):0}});var eC=Ce((Dne,Q4)=>{"use strict";var Fne=P(x()),aU=Z4();Q4.exports=function(e){return aU(e.length)}});var nC=Ce((Bne,rC)=>{"use strict";var Ine=P(x()),uU=a1(),cU=X4(),lU=eC(),tC=function(e){return function(t,r,n){var i=uU(t),o=lU(i);if(o===0)return!e&&-1;var s=cU(n,o),a;if(e&&r!==r){for(;o>s;)if(a=i[s++],a!==a)return!0}else for(;o>s;s++)if((e||s in i)&&i[s]===r)return e||s||0;return!e&&-1}};rC.exports={includes:tC(!0),indexOf:tC(!1)}});var oC=Ce(($ne,iC)=>{"use strict";var Pne=P(x()),fU=Ro(),zw=La(),hU=a1(),dU=nC().indexOf,pU=Uw(),sC=fU([].push);iC.exports=function(e,t){var r=hU(e),n=0,i=[],o;for(o in r)!zw(pU,o)&&zw(r,o)&&sC(i,o);for(;t.length>n;)zw(r,o=t[n++])&&(~dU(i,o)||sC(i,o));return i}});var uC=Ce((xne,aC)=>{"use strict";var Tne=P(x());aC.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var lC=Ce(cC=>{"use strict";var kne=P(x()),mU=oC(),gU=uC(),vU=gU.concat("length","prototype");cC.f=Object.getOwnPropertyNames||function(t){return mU(t,vU)}});var hC=Ce(fC=>{"use strict";var Nne=P(x());fC.f=Object.getOwnPropertySymbols});var pC=Ce((Lne,dC)=>{"use strict";var Une=P(x()),wU=mw(),yU=Ro(),EU=lC(),bU=hC(),AU=$w(),SU=yU([].concat);dC.exports=wU("Reflect","ownKeys")||function(t){var r=EU.f(AU(t)),n=bU.f;return n?SU(r,n(t)):r}});var vC=Ce((Hne,gC)=>{"use strict";var Mne=P(x()),mC=La(),CU=pC(),_U=Iw(),DU=h1();gC.exports=function(e,t,r){for(var n=CU(t),i=DU.f,o=_U.f,s=0;s{"use strict";var qne=P(x()),FU=Na(),BU=Vi(),IU=/#|\.prototype\./,Sd=function(e,t){var r=PU[$U(e)];return r===TU?!0:r===xU?!1:BU(t)?FU(t):!!t},$U=Sd.normalize=function(e){return String(e).replace(IU,".").toLowerCase()},PU=Sd.data={},xU=Sd.NATIVE="N",TU=Sd.POLYFILL="P";wC.exports=Sd});var bC=Ce((Kne,EC)=>{"use strict";var Vne=P(x()),v1=ui(),RU=Iw().f,kU=kw(),OU=V4(),NU=c1(),LU=vC(),UU=yC();EC.exports=function(e,t){var r=e.target,n=e.global,i=e.stat,o,s,a,u,l,f;if(n?s=v1:i?s=v1[r]||NU(r,{}):s=v1[r]&&v1[r].prototype,s)for(a in t){if(l=t[a],e.dontCallGetSet?(f=RU(s,a),u=f&&f.value):u=s[a],o=UU(n?a:r+(i?".":"#")+a,e.forced),!o&&u!==void 0){if(typeof l==typeof u)continue;LU(l,u)}(e.sham||u&&u.sham)&&kU(l,"sham",!0),OU(s,a,l,e)}}});var AC=Ce(()=>{"use strict";var Yne=P(x()),HU=bC(),MU=La();HU({target:"Object",stat:!0},{hasOwn:MU})});var CC=Ce((Wne,SC)=>{"use strict";var Xne=P(x()),jU=ui();SC.exports=jU});var DC=Ce((Jne,_C)=>{"use strict";var Zne=P(x());AC();var qU=CC();_C.exports=qU.Object.hasOwn});var BC=Ce((Qne,FC)=>{"use strict";var ese=P(x()),KU=DC();FC.exports=KU});var x=Ce((tse,IC)=>{"use strict";var VU=BC();IC.exports=VU});var xC=Ce(PC=>{"use strict";var ose=P(x());(function(e){function t(){}function r(){}var n=String.fromCharCode,i={}.toString,o=i.call(e.SharedArrayBuffer),s=i(),a=e.Uint8Array,u=a||Array,l=a?ArrayBuffer:u,f=l.isView||function(v){return v&&"length"in v},m=i.call(l.prototype);l=r.prototype;var p=e.TextEncoder,d=new(a?Uint16Array:u)(32);t.prototype.decode=function(v){if(!f(v)){var g=i.call(v);if(g!==m&&g!==o&&g!==s)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");v=a?new u(v):v||[]}for(var y=g="",w=0,E=v.length|0,S=E-32|0,F,_,H=0,V=0,C,I=0,L=-1;w>4){case 15:if(C=v[w=w+1|0]&255,C>>6!==2||247<_){w=w-1|0;break}H=(_&7)<<6|C&63,V=5,_=256;case 14:C=v[w=w+1|0]&255,H<<=6,H|=(_&15)<<6|C&63,V=C>>6===2?V+4|0:24,_=_+256&768;case 13:case 12:C=v[w=w+1|0]&255,H<<=6,H|=(_&31)<<6|C&63,V=V+7|0,w>6===2&&H>>V&&1114112>H?(_=H,H=H-65536|0,0<=H&&(L=(H>>10)+55296|0,_=(H&1023)+56320|0,31>I?(d[I]=L,I=I+1|0,L=-1):(C=L,L=_,_=C))):(_>>=8,w=w-_-1|0,_=65533),H=V=0,F=w<=S?32:E-w|0;default:d[I]=_;continue;case 11:case 10:case 9:case 8:}d[I]=65533}if(y+=n(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8],d[9],d[10],d[11],d[12],d[13],d[14],d[15],d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23],d[24],d[25],d[26],d[27],d[28],d[29],d[30],d[31]),32>I&&(y=y.slice(0,I-32|0)),w>>31,L=-1,y.length=F)y[E]=F;else{if(2047>=F)y[E]=192|F>>6;else{e:{if(55296<=F)if(56319>=F){var _=v.charCodeAt(w=w+1|0)|0;if(56320<=_&&57343>=_){if(F=(F<<10)+_-56613888|0,65535>18,y[E=E+1|0]=128|F>>12&63,y[E=E+1|0]=128|F>>6&63,y[E=E+1|0]=128|F&63;continue}break e}F=65533}else 57343>=F&&(F=65533);!S&&w<<1>12,y[E=E+1|0]=128|F>>6&63}y[E=E+1|0]=128|F&63}}return a?y.subarray(0,E):y.slice(0,E)},p||(e.TextDecoder=t,e.TextEncoder=r)})(typeof global>"u"?typeof self>"u"?PC:self:global)});var A8=Ce(F1=>{"use strict";var Rse=P(x());F1.byteLength=MH;F1.toByteArray=qH;F1.fromByteArray=zH;var Oo=[],Bi=[],HH=typeof Uint8Array<"u"?Uint8Array:Array,iy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ul=0,E8=iy.length;ul0)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 MH(e){var t=b8(e),r=t[0],n=t[1];return(r+n)*3/4-n}function jH(e,t,r){return(t+r)*3/4-r}function qH(e){var t,r=b8(e),n=r[0],i=r[1],o=new HH(jH(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Bi[e.charCodeAt(u)]<<2|Bi[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Bi[e.charCodeAt(u)]<<10|Bi[e.charCodeAt(u+1)]<<4|Bi[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function KH(e){return Oo[e>>18&63]+Oo[e>>12&63]+Oo[e>>6&63]+Oo[e&63]}function VH(e,t,r){for(var n,i=[],o=t;oa?a:s+o));return n===1?(t=e[r-1],i.push(Oo[t>>2]+Oo[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Oo[t>>10]+Oo[t>>4&63]+Oo[t<<2&63]+"=")),i.join("")}});var S8=Ce(oy=>{var Ose=P(x());oy.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<>1,f=-7,m=r?i-1:0,p=r?-1:1,d=e[t+m];for(m+=p,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=o*256+e[t+m],m+=p,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=s*256+e[t+m],m+=p,f-=8);if(o===0)o=1-l;else{if(o===u)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(d?-1:1)*s*Math.pow(2,o-n)};oy.write=function(e,t,r,n,i,o){var s,a,u,l=o*8-i-1,f=(1<>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,v=n?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+m>=1?t+=p/u:t+=p*Math.pow(2,1-m),t*u>=2&&(s++,u/=2),s+m>=f?(a=0,s=f):s+m>=1?(a=(t*u-1)*Math.pow(2,i),s=s+m):(a=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=a&255,d+=v,a/=256,i-=8);for(s=s<0;e[r+d]=s&255,d+=v,s/=256,l-=8);e[r+d-v]|=g*128}});var $1=Ce(Ff=>{"use strict";var Use=P(x());var ay=A8(),_f=S8(),C8=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Ff.Buffer=be;Ff.SlowBuffer=ZH;Ff.INSPECT_MAX_BYTES=50;var B1=2147483647;Ff.kMaxLength=B1;be.TYPED_ARRAY_SUPPORT=GH();!be.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 GH(){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(be.prototype,"parent",{enumerable:!0,get:function(){if(be.isBuffer(this))return this.buffer}});Object.defineProperty(be.prototype,"offset",{enumerable:!0,get:function(){if(be.isBuffer(this))return this.byteOffset}});function Ha(e){if(e>B1)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,be.prototype),t}function be(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 fy(e)}return B8(e,t,r)}be.poolSize=8192;function B8(e,t,r){if(typeof e=="string")return WH(e,t);if(ArrayBuffer.isView(e))return XH(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(No(e,ArrayBuffer)||e&&No(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(No(e,SharedArrayBuffer)||e&&No(e.buffer,SharedArrayBuffer)))return cy(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 be.from(n,t,r);let i=JH(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return be.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)}be.from=function(e,t,r){return B8(e,t,r)};Object.setPrototypeOf(be.prototype,Uint8Array.prototype);Object.setPrototypeOf(be,Uint8Array);function I8(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 YH(e,t,r){return I8(e),e<=0?Ha(e):t!==void 0?typeof r=="string"?Ha(e).fill(t,r):Ha(e).fill(t):Ha(e)}be.alloc=function(e,t,r){return YH(e,t,r)};function fy(e){return I8(e),Ha(e<0?0:hy(e)|0)}be.allocUnsafe=function(e){return fy(e)};be.allocUnsafeSlow=function(e){return fy(e)};function WH(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!be.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=$8(e,t)|0,n=Ha(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function uy(e){let t=e.length<0?0:hy(e.length)|0,r=Ha(t);for(let n=0;n=B1)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+B1.toString(16)+" bytes");return e|0}function ZH(e){return+e!=e&&(e=0),be.alloc(+e)}be.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==be.prototype};be.compare=function(t,r){if(No(t,Uint8Array)&&(t=be.from(t,t.offset,t.byteLength)),No(r,Uint8Array)&&(r=be.from(r,r.offset,r.byteLength)),!be.isBuffer(t)||!be.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 o=0,s=Math.min(n,i);oi.length?(be.isBuffer(s)||(s=be.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(be.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function $8(e,t){if(be.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||No(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 ly(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return U8(e).length;default:if(i)return n?-1:ly(e).length;t=(""+t).toLowerCase(),i=!0}}be.byteLength=$8;function QH(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 cM(this,t,r);case"utf8":case"utf-8":return x8(this,t,r);case"ascii":return aM(this,t,r);case"latin1":case"binary":return uM(this,t,r);case"base64":return iM(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return lM(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}be.prototype._isBuffer=!0;function cl(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}be.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+=" ... "),""};C8&&(be.prototype[C8]=be.prototype.inspect);be.prototype.compare=function(t,r,n,i,o){if(No(t,Uint8Array)&&(t=be.from(t,t.offset,t.byteLength)),!be.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),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=n-r,u=Math.min(s,a),l=this.slice(i,o),f=t.slice(r,n);for(let m=0;m2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,py(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=be.from(t,n)),be.isBuffer(t))return t.length===0?-1:_8(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):_8(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _8(e,t,r,n,i){let o=1,s=e.length,a=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;o=2,s/=2,a/=2,r/=2}function u(f,m){return o===1?f[m]:f.readUInt16BE(m*o)}let l;if(i){let f=-1;for(l=r;ls&&(r=s-a),l=r;l>=0;l--){let f=!0;for(let m=0;mi&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/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 o=this.length-r;if((n===void 0||n>o)&&(n=o),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 eM(this,t,r,n);case"utf8":case"utf-8":return tM(this,t,r,n);case"ascii":case"latin1":case"binary":return rM(this,t,r,n);case"base64":return nM(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sM(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};be.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function iM(e,t,r){return t===0&&r===e.length?ay.fromByteArray(e):ay.fromByteArray(e.slice(t,r))}function x8(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i239?4:o>223?3:o>191?2:1;if(i+a<=r){let u,l,f,m;switch(a){case 1:o<128&&(s=o);break;case 2:u=e[i+1],(u&192)===128&&(m=(o&31)<<6|u&63,m>127&&(s=m));break;case 3:u=e[i+1],l=e[i+2],(u&192)===128&&(l&192)===128&&(m=(o&15)<<12|(u&63)<<6|l&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:u=e[i+1],l=e[i+2],f=e[i+3],(u&192)===128&&(l&192)===128&&(f&192)===128&&(m=(o&15)<<18|(u&63)<<12|(l&63)<<6|f&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return oM(n)}var D8=4096;function oM(e){let t=e.length;if(t<=D8)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn)&&(r=n);let i="";for(let o=t;on&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}be.prototype.readUintLE=be.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||dn(t,r,this.length);let i=this[t],o=1,s=0;for(;++s>>0,r=r>>>0,n||dn(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};be.prototype.readUint8=be.prototype.readUInt8=function(t,r){return t=t>>>0,r||dn(t,1,this.length),this[t]};be.prototype.readUint16LE=be.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||dn(t,2,this.length),this[t]|this[t+1]<<8};be.prototype.readUint16BE=be.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||dn(t,2,this.length),this[t]<<8|this[t+1]};be.prototype.readUint32LE=be.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||dn(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};be.prototype.readUint32BE=be.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||dn(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};be.prototype.readBigUInt64LE=Yu(function(t){t=t>>>0,Df(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Dd(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<>>0,Df(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Dd(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<>>0,r=r>>>0,n||dn(t,r,this.length);let i=this[t],o=1,s=0;for(;++s=o&&(i-=Math.pow(2,8*r)),i};be.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||dn(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};be.prototype.readInt8=function(t,r){return t=t>>>0,r||dn(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};be.prototype.readInt16LE=function(t,r){t=t>>>0,r||dn(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};be.prototype.readInt16BE=function(t,r){t=t>>>0,r||dn(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};be.prototype.readInt32LE=function(t,r){return t=t>>>0,r||dn(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};be.prototype.readInt32BE=function(t,r){return t=t>>>0,r||dn(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};be.prototype.readBigInt64LE=Yu(function(t){t=t>>>0,Df(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Dd(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,Df(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Dd(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<>>0,r||dn(t,4,this.length),_f.read(this,t,!0,23,4)};be.prototype.readFloatBE=function(t,r){return t=t>>>0,r||dn(t,4,this.length),_f.read(this,t,!1,23,4)};be.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||dn(t,8,this.length),_f.read(this,t,!0,52,8)};be.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||dn(t,8,this.length),_f.read(this,t,!1,52,8)};function Hs(e,t,r,n,i,o){if(!be.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}be.prototype.writeUintLE=be.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Hs(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Hs(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};be.prototype.writeUint8=be.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||Hs(this,t,r,1,255,0),this[r]=t&255,r+1};be.prototype.writeUint16LE=be.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Hs(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};be.prototype.writeUint16BE=be.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Hs(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};be.prototype.writeUint32LE=be.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Hs(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};be.prototype.writeUint32BE=be.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Hs(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 T8(e,t,r,n,i){L8(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;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 R8(e,t,r,n,i){L8(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;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}be.prototype.writeBigUInt64LE=Yu(function(t,r=0){return T8(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});be.prototype.writeBigUInt64BE=Yu(function(t,r=0){return R8(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});be.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);Hs(this,t,r,n,u-1,-u)}let o=0,s=1,a=0;for(this[r]=t&255;++o>0)-a&255;return r+n};be.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);Hs(this,t,r,n,u-1,-u)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};be.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||Hs(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};be.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Hs(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};be.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Hs(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};be.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Hs(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};be.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Hs(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};be.prototype.writeBigInt64LE=Yu(function(t,r=0){return T8(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});be.prototype.writeBigInt64BE=Yu(function(t,r=0){return R8(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function k8(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O8(e,t,r,n,i){return t=+t,r=r>>>0,i||k8(e,t,r,4,34028234663852886e22,-34028234663852886e22),_f.write(e,t,r,n,23,4),r+4}be.prototype.writeFloatLE=function(t,r,n){return O8(this,t,r,!0,n)};be.prototype.writeFloatBE=function(t,r,n){return O8(this,t,r,!1,n)};function N8(e,t,r,n,i){return t=+t,r=r>>>0,i||k8(e,t,r,8,17976931348623157e292,-17976931348623157e292),_f.write(e,t,r,n,52,8),r+8}be.prototype.writeDoubleLE=function(t,r,n){return N8(this,t,r,!0,n)};be.prototype.writeDoubleBE=function(t,r,n){return N8(this,t,r,!1,n)};be.prototype.copy=function(t,r,n,i){if(!be.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 o;if(typeof t=="number")for(o=r;o2**32?i=F8(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=F8(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function F8(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 fM(e,t,r){Df(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Dd(t,e.length-(r+1))}function L8(e,t,r,n,i,o){if(e>r||e3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${r}${s}`,new Cf.ERR_OUT_OF_RANGE("value",a,e)}fM(n,i,o)}function Df(e,t){if(typeof e!="number")throw new Cf.ERR_INVALID_ARG_TYPE(t,"number",e)}function Dd(e,t,r){throw Math.floor(e)!==e?(Df(e,r),new Cf.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new Cf.ERR_BUFFER_OUT_OF_BOUNDS:new Cf.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var hM=/[^+/0-9A-Za-z-_]/g;function dM(e){if(e=e.split("=")[0],e=e.trim().replace(hM,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function ly(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function pM(e){let t=[];for(let r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function U8(e){return ay.toByteArray(dM(e))}function I1(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function No(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function py(e){return e!==e}var gM=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 Yu(e){return typeof BigInt>"u"?vM:e}function vM(){throw new Error("BigInt not supported")}});var f_=Ce(Ne=>{var jse=P(x()),Bd={};Bd.userAgent=!1;var Bf={},wM="11.1.3",yM="jsrsasign(all) 11.1.3 (2026-04-18) (c) 2010-2023 Kenji Urushima | kjur.github.io/jsrsasign/license";var He=He||function(e,t){var r={},n=r.lib={},i=n.Base=function(){function d(){}return{extend:function(v){d.prototype=this;var g=new d;return v&&g.mixIn(v),g.hasOwnProperty("init")||(g.init=function(){g.$super.init.apply(this,arguments)}),g.init.prototype=g,g.$super=this,g},create:function(){var v=this.extend();return v.init.apply(v,arguments),v},init:function(){},mixIn:function(v){for(var g in v)v.hasOwnProperty(g)&&(this[g]=v[g]);v.hasOwnProperty("toString")&&(this.toString=v.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),o=n.WordArray=i.extend({init:function(d,v){d=this.words=d||[],v!=t?this.sigBytes=v:this.sigBytes=d.length*4},toString:function(d){return(d||a).stringify(this)},concat:function(d){var v=this.words,g=d.words,y=this.sigBytes,w=d.sigBytes;if(this.clamp(),y%4)for(var E=0;E>>2]>>>24-E%4*8&255;v[y+E>>>2]|=S<<24-(y+E)%4*8}else for(var E=0;E>>2]=g[E>>>2];return this.sigBytes+=w,this},clamp:function(){var d=this.words,v=this.sigBytes;d[v>>>2]&=4294967295<<32-v%4*8,d.length=e.ceil(v/4)},clone:function(){var d=i.clone.call(this);return d.words=this.words.slice(0),d},random:function(d){for(var v=[],g=0;g>>2]>>>24-w%4*8&255;y.push((E>>>4).toString(16)),y.push((E&15).toString(16))}return y.join("")},parse:function(d){for(var v=d.length,g=[],y=0;y>>3]|=parseInt(d.substr(y,2),16)<<24-y%8*4;return new o.init(g,v/2)}},u=s.Latin1={stringify:function(d){for(var v=d.words,g=d.sigBytes,y=[],w=0;w>>2]>>>24-w%4*8&255;y.push(String.fromCharCode(E))}return y.join("")},parse:function(d){for(var v=d.length,g=[],y=0;y>>2]|=(d.charCodeAt(y)&255)<<24-y%4*8;return new o.init(g,v)}},l=s.Utf8={stringify:function(d){try{return decodeURIComponent(escape(u.stringify(d)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(d){return u.parse(unescape(encodeURIComponent(d)))}},f=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(d){typeof d=="string"&&(d=l.parse(d)),this._data.concat(d),this._nDataBytes+=d.sigBytes},_process:function(d){var v=this._data,g=v.words,y=v.sigBytes,w=this.blockSize,E=w*4,S=y/E;d?S=e.ceil(S):S=e.max((S|0)-this._minBufferSize,0);var F=S*w,_=e.min(F*4,y);if(F){for(var H=0;H>>2]&255}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:m,padding:l}),reset:function(){a.reset.call(this);var y=this.cfg,g=y.iv,y=y.mode;if(this._xformMode==this._ENC_XFORM_MODE)var w=y.createEncryptor;else w=y.createDecryptor,this._minBufferSize=1;this._mode=w.call(y,this,g&&g.words)},_doProcessBlock:function(g,y){this._mode.processBlock(g,y)},_doFinalize:function(){var g=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){g.pad(this._data,this.blockSize);var y=this._process(!0)}else y=this._process(!0),g.unpad(y);return y},blockSize:4});var f=t.CipherParams=r.extend({init:function(g){this.mixIn(g)},toString:function(g){return(g||this.formatter).stringify(this)}}),m=(d.format={}).OpenSSL={stringify:function(g){var y=g.ciphertext;return g=g.salt,(g?n.create([1398893684,1701076831]).concat(g).concat(y):y).toString(o)},parse:function(g){g=o.parse(g);var y=g.words;if(y[0]==1398893684&&y[1]==1701076831){var w=n.create(y.slice(2,4));y.splice(0,4),g.sigBytes-=16}return f.create({ciphertext:g,salt:w})}},p=t.SerializableCipher=r.extend({cfg:r.extend({format:m}),encrypt:function(g,y,w,E){E=this.cfg.extend(E);var S=g.createEncryptor(w,E);return y=S.finalize(y),S=S.cfg,f.create({ciphertext:y,key:w,iv:S.iv,algorithm:g,mode:S.mode,padding:S.padding,blockSize:g.blockSize,formatter:E.format})},decrypt:function(g,y,w,E){return E=this.cfg.extend(E),y=this._parse(y,E.format),g.createDecryptor(w,E).finalize(y.ciphertext)},_parse:function(g,y){return typeof g=="string"?y.parse(g,this):g}}),d=(d.kdf={}).OpenSSL={execute:function(g,y,w,E){return E||(E=n.random(8)),g=s.create({keySize:y+w}).compute(g,E),w=n.create(g.words.slice(y),4*w),g.sigBytes=4*y,f.create({key:g,iv:w,salt:E})}},v=t.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:d}),encrypt:function(g,y,w,E){return E=this.cfg.extend(E),w=E.kdf.execute(w,g.keySize,g.ivSize),E.iv=w.iv,g=p.encrypt.call(this,g,y,w.key,E),g.mixIn(w),g},decrypt:function(g,y,w,E){return E=this.cfg.extend(E),y=this._parse(y,E.format),w=E.kdf.execute(w,g.keySize,g.ivSize,y.salt),E.iv=w.iv,p.decrypt.call(this,g,y,w.key,E)}})}();(function(){for(var e=He,t=e.lib.BlockCipher,H=e.algo,r=[],n=[],i=[],o=[],s=[],a=[],u=[],l=[],f=[],m=[],p=[],d=0;256>d;d++)p[d]=128>d?d<<1:d<<1^283;for(var v=0,g=0,d=0;256>d;d++){var y=g^g<<1^g<<2^g<<3^g<<4,y=y>>>8^y&255^99;r[v]=y,n[y]=v;var w=p[v],E=p[w],S=p[E],F=257*p[y]^16843008*y;i[v]=F<<24|F>>>8,o[v]=F<<16|F>>>16,s[v]=F<<8|F>>>24,a[v]=F,F=16843009*S^65537*E^257*w^16843008*v,u[y]=F<<24|F>>>8,l[y]=F<<16|F>>>16,f[y]=F<<8|F>>>24,m[y]=F,v?(v=w^p[p[p[S^w]]],g^=p[p[g]]):v=g=1}var _=[0,1,2,4,8,16,32,64,128,27,54],H=H.AES=t.extend({_doReset:function(){for(var I=this._key,V=I.words,C=I.sigBytes/4,I=4*((this._nRounds=C+6)+1),L=this._keySchedule=[],R=0;R>>24]<<24|r[k>>>16&255]<<16|r[k>>>8&255]<<8|r[k&255]):(k=k<<8|k>>>24,k=r[k>>>24]<<24|r[k>>>16&255]<<16|r[k>>>8&255]<<8|r[k&255],k^=_[R/C|0]<<24),L[R]=L[R-C]^k}for(V=this._invKeySchedule=[],C=0;CC||4>=R?k:u[r[k>>>24]]^l[r[k>>>16&255]]^f[r[k>>>8&255]]^m[r[k&255]]},encryptBlock:function(V,C){this._doCryptBlock(V,C,this._keySchedule,i,o,s,a,r)},decryptBlock:function(V,C){var I=V[C+1];V[C+1]=V[C+3],V[C+3]=I,this._doCryptBlock(V,C,this._invKeySchedule,u,l,f,m,n),I=V[C+1],V[C+1]=V[C+3],V[C+3]=I},_doCryptBlock:function(V,C,I,L,R,k,M,N){for(var D=this._nRounds,le=V[C]^I[0],ve=V[C+1]^I[1],we=V[C+2]^I[2],se=V[C+3]^I[3],O=4,q=1;q>>24]^R[ve>>>16&255]^k[we>>>8&255]^M[se&255]^I[O++],Y=L[ve>>>24]^R[we>>>16&255]^k[se>>>8&255]^M[le&255]^I[O++],ee=L[we>>>24]^R[se>>>16&255]^k[le>>>8&255]^M[ve&255]^I[O++],se=L[se>>>24]^R[le>>>16&255]^k[ve>>>8&255]^M[we&255]^I[O++],le=J,ve=Y,we=ee;J=(N[le>>>24]<<24|N[ve>>>16&255]<<16|N[we>>>8&255]<<8|N[se&255])^I[O++],Y=(N[ve>>>24]<<24|N[we>>>16&255]<<16|N[se>>>8&255]<<8|N[le&255])^I[O++],ee=(N[we>>>24]<<24|N[se>>>16&255]<<16|N[le>>>8&255]<<8|N[ve&255])^I[O++],se=(N[se>>>24]<<24|N[le>>>16&255]<<16|N[ve>>>8&255]<<8|N[we&255])^I[O++],V[C]=J,V[C+1]=Y,V[C+2]=ee,V[C+3]=se},keySize:8});e.AES=t._createHelper(H)})();(function(){function e(p,d){var v=(this._lBlock>>>p^this._rBlock)&d;this._rBlock^=v,this._lBlock^=v<>>p^this._lBlock)&d;this._lBlock^=v,this._rBlock^=v<v;v++){var g=s[v]-1;d[v]=p[g>>>5]>>>31-g%32&1}for(p=this._subKeys=[],g=0;16>g;g++){for(var y=p[g]=[],w=u[g],v=0;24>v;v++)y[v/6|0]|=d[(a[v]-1+w)%28]<<31-v%6,y[4+(v/6|0)]|=d[28+(a[v+24]-1+w)%28]<<31-v%6;for(y[0]=y[0]<<1|y[0]>>>31,v=1;7>v;v++)y[v]>>>=4*(v-1)+3;y[7]=y[7]<<5|y[7]>>>27}for(d=this._invSubKeys=[],v=0;16>v;v++)d[v]=p[15-v]},encryptBlock:function(p,d){this._doCryptBlock(p,d,this._subKeys)},decryptBlock:function(p,d){this._doCryptBlock(p,d,this._invSubKeys)},_doCryptBlock:function(p,d,v){this._lBlock=p[d],this._rBlock=p[d+1],e.call(this,4,252645135),e.call(this,16,65535),t.call(this,2,858993459),t.call(this,8,16711935),e.call(this,1,1431655765);for(var g=0;16>g;g++){for(var y=v[g],w=this._lBlock,E=this._rBlock,S=0,F=0;8>F;F++)S|=l[F][((E^y[F])&f[F])>>>0];this._lBlock=E,this._rBlock=w^S}v=this._lBlock,this._lBlock=this._rBlock,this._rBlock=v,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[d]=this._lBlock,p[d+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=i._createHelper(m),o=o.TripleDES=i.extend({_doReset:function(){var p=this._key.words;this._des1=m.createEncryptor(n.create(p.slice(0,2))),this._des2=m.createEncryptor(n.create(p.slice(2,4))),this._des3=m.createEncryptor(n.create(p.slice(4,6)))},encryptBlock:function(p,d){this._des1.encryptBlock(p,d),this._des2.decryptBlock(p,d),this._des3.encryptBlock(p,d)},decryptBlock:function(p,d){this._des3.decryptBlock(p,d),this._des2.encryptBlock(p,d),this._des1.decryptBlock(p,d)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=i._createHelper(o)})();(function(){var e=He,t=e.lib.WordArray;e.enc.Base64={stringify:function(r){var n=r.words,i=r.sigBytes,o=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,u=0;4>u&&s+.75*u>>6*(3-u)&63));if(n=o.charAt(64))for(;r.length%4;)r.push(n);return r.join("")},parse:function(r){var n=r.length,i=this._map,o=i.charAt(64);o&&(o=r.indexOf(o),o!=-1&&(n=o));for(var o=[],s=0,a=0;a>>6-2*(a%4);o[s>>>2]|=(u|l)<<24-8*(s%4),s++}return t.create(o,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();(function(e){function t(m,p,d,v,g,y,w){return m=m+(p&d|~p&v)+g+w,(m<>>32-y)+p}function r(m,p,d,v,g,y,w){return m=m+(p&v|d&~v)+g+w,(m<>>32-y)+p}function n(m,p,d,v,g,y,w){return m=m+(p^d^v)+g+w,(m<>>32-y)+p}function i(m,p,d,v,g,y,w){return m=m+(d^(p|~v))+g+w,(m<>>32-y)+p}for(var o=He,u=o.lib,s=u.WordArray,a=u.Hasher,u=o.algo,l=[],f=0;64>f;f++)l[f]=4294967296*e.abs(e.sin(f+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(m,p){for(var d=0;16>d;d++){var v=p+d,g=m[v];m[v]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360}var d=this._hash.words,v=m[p+0],g=m[p+1],y=m[p+2],w=m[p+3],E=m[p+4],S=m[p+5],F=m[p+6],_=m[p+7],H=m[p+8],V=m[p+9],C=m[p+10],I=m[p+11],L=m[p+12],R=m[p+13],k=m[p+14],M=m[p+15],N=d[0],q=d[1],O=d[2],D=d[3],N=t(N,q,O,D,v,7,l[0]),D=t(D,N,q,O,g,12,l[1]),O=t(O,D,N,q,y,17,l[2]),q=t(q,O,D,N,w,22,l[3]),N=t(N,q,O,D,E,7,l[4]),D=t(D,N,q,O,S,12,l[5]),O=t(O,D,N,q,F,17,l[6]),q=t(q,O,D,N,_,22,l[7]),N=t(N,q,O,D,H,7,l[8]),D=t(D,N,q,O,V,12,l[9]),O=t(O,D,N,q,C,17,l[10]),q=t(q,O,D,N,I,22,l[11]),N=t(N,q,O,D,L,7,l[12]),D=t(D,N,q,O,R,12,l[13]),O=t(O,D,N,q,k,17,l[14]),q=t(q,O,D,N,M,22,l[15]),N=r(N,q,O,D,g,5,l[16]),D=r(D,N,q,O,F,9,l[17]),O=r(O,D,N,q,I,14,l[18]),q=r(q,O,D,N,v,20,l[19]),N=r(N,q,O,D,S,5,l[20]),D=r(D,N,q,O,C,9,l[21]),O=r(O,D,N,q,M,14,l[22]),q=r(q,O,D,N,E,20,l[23]),N=r(N,q,O,D,V,5,l[24]),D=r(D,N,q,O,k,9,l[25]),O=r(O,D,N,q,w,14,l[26]),q=r(q,O,D,N,H,20,l[27]),N=r(N,q,O,D,R,5,l[28]),D=r(D,N,q,O,y,9,l[29]),O=r(O,D,N,q,_,14,l[30]),q=r(q,O,D,N,L,20,l[31]),N=n(N,q,O,D,S,4,l[32]),D=n(D,N,q,O,H,11,l[33]),O=n(O,D,N,q,I,16,l[34]),q=n(q,O,D,N,k,23,l[35]),N=n(N,q,O,D,g,4,l[36]),D=n(D,N,q,O,E,11,l[37]),O=n(O,D,N,q,_,16,l[38]),q=n(q,O,D,N,C,23,l[39]),N=n(N,q,O,D,R,4,l[40]),D=n(D,N,q,O,v,11,l[41]),O=n(O,D,N,q,w,16,l[42]),q=n(q,O,D,N,F,23,l[43]),N=n(N,q,O,D,V,4,l[44]),D=n(D,N,q,O,L,11,l[45]),O=n(O,D,N,q,M,16,l[46]),q=n(q,O,D,N,y,23,l[47]),N=i(N,q,O,D,v,6,l[48]),D=i(D,N,q,O,_,10,l[49]),O=i(O,D,N,q,k,15,l[50]),q=i(q,O,D,N,S,21,l[51]),N=i(N,q,O,D,L,6,l[52]),D=i(D,N,q,O,w,10,l[53]),O=i(O,D,N,q,C,15,l[54]),q=i(q,O,D,N,g,21,l[55]),N=i(N,q,O,D,H,6,l[56]),D=i(D,N,q,O,M,10,l[57]),O=i(O,D,N,q,F,15,l[58]),q=i(q,O,D,N,R,21,l[59]),N=i(N,q,O,D,E,6,l[60]),D=i(D,N,q,O,I,10,l[61]),O=i(O,D,N,q,y,15,l[62]),q=i(q,O,D,N,V,21,l[63]);d[0]=d[0]+N|0,d[1]=d[1]+q|0,d[2]=d[2]+O|0,d[3]=d[3]+D|0},_doFinalize:function(){var m=this._data,p=m.words,d=8*this._nDataBytes,v=8*m.sigBytes;p[v>>>5]|=128<<24-v%32;var g=e.floor(d/4294967296);for(p[(v+64>>>9<<4)+15]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360,p[(v+64>>>9<<4)+14]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360,m.sigBytes=4*(p.length+1),this._process(),m=this._hash,p=m.words,d=0;4>d;d++)v=p[d],p[d]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360;return m},clone:function(){var m=a.clone.call(this);return m._hash=this._hash.clone(),m}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)})(Math);(function(){var e=He,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(o,s){for(var a=this._hash.words,u=a[0],l=a[1],f=a[2],m=a[3],p=a[4],d=0;80>d;d++){if(16>d)n[d]=o[s+d]|0;else{var v=n[d-3]^n[d-8]^n[d-14]^n[d-16];n[d]=v<<1|v>>>31}v=(u<<5|u>>>27)+p+n[d],v=20>d?v+((l&f|~l&m)+1518500249):40>d?v+((l^f^m)+1859775393):60>d?v+((l&f|l&m|f&m)-1894007588):v+((l^f^m)-899497514),p=m,m=f,f=l<<30|l>>>2,l=u,u=v}a[0]=a[0]+u|0,a[1]=a[1]+l|0,a[2]=a[2]+f|0,a[3]=a[3]+m|0,a[4]=a[4]+p|0},_doFinalize:function(){var o=this._data,s=o.words,a=8*this._nDataBytes,u=8*o.sigBytes;return s[u>>>5]|=128<<24-u%32,s[(u+64>>>9<<4)+14]=Math.floor(a/4294967296),s[(u+64>>>9<<4)+15]=a,o.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var o=r.clone.call(this);return o._hash=this._hash.clone(),o}});e.SHA1=r._createHelper(i),e.HmacSHA1=r._createHmacHelper(i)})();(function(e){for(var t=He,d=t.lib,r=d.WordArray,n=d.Hasher,d=t.algo,i=[],o=[],s=function(g){return 4294967296*(g-(g|0))|0},a=2,u=0;64>u;){var l;e:{l=a;for(var f=e.sqrt(l),m=2;m<=f;m++)if(!(l%m)){l=!1;break e}l=!0}l&&(8>u&&(i[u]=s(e.pow(a,.5))),o[u]=s(e.pow(a,1/3)),u++),a++}var p=[],d=d.SHA256=n.extend({_doReset:function(){this._hash=new r.init(i.slice(0))},_doProcessBlock:function(v,g){for(var y=this._hash.words,w=y[0],E=y[1],S=y[2],F=y[3],_=y[4],H=y[5],V=y[6],C=y[7],I=0;64>I;I++){if(16>I)p[I]=v[g+I]|0;else{var L=p[I-15],R=p[I-2];p[I]=((L<<25|L>>>7)^(L<<14|L>>>18)^L>>>3)+p[I-7]+((R<<15|R>>>17)^(R<<13|R>>>19)^R>>>10)+p[I-16]}L=C+((_<<26|_>>>6)^(_<<21|_>>>11)^(_<<7|_>>>25))+(_&H^~_&V)+o[I]+p[I],R=((w<<30|w>>>2)^(w<<19|w>>>13)^(w<<10|w>>>22))+(w&E^w&S^E&S),C=V,V=H,H=_,_=F+L|0,F=S,S=E,E=w,w=L+R|0}y[0]=y[0]+w|0,y[1]=y[1]+E|0,y[2]=y[2]+S|0,y[3]=y[3]+F|0,y[4]=y[4]+_|0,y[5]=y[5]+H|0,y[6]=y[6]+V|0,y[7]=y[7]+C|0},_doFinalize:function(){var v=this._data,g=v.words,y=8*this._nDataBytes,w=8*v.sigBytes;return g[w>>>5]|=128<<24-w%32,g[(w+64>>>9<<4)+14]=e.floor(y/4294967296),g[(w+64>>>9<<4)+15]=y,v.sigBytes=4*g.length,this._process(),this._hash},clone:function(){var v=n.clone.call(this);return v._hash=this._hash.clone(),v}});t.SHA256=n._createHelper(d),t.HmacSHA256=n._createHmacHelper(d)})(Math);(function(){var e=He,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=He,r=t.lib.Hasher,o=t.x64,n=o.Word,i=o.WordArray,o=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)],a=[],u=0;80>u;u++)a[u]=e();o=o.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(l,f){for(var E=this._hash.words,m=E[0],p=E[1],d=E[2],v=E[3],g=E[4],y=E[5],w=E[6],E=E[7],S=m.high,F=m.low,_=p.high,H=p.low,V=d.high,C=d.low,I=v.high,L=v.low,R=g.high,k=g.low,M=y.high,N=y.low,D=w.high,O=w.low,q=E.high,J=E.low,Y=S,ee=F,se=_,le=H,ve=V,we=C,Pe=I,Le=L,Oe=R,fe=k,Se=M,Re=N,Ke=D,Qe=O,je=q,yt=J,rt=0;80>rt;rt++){var gr=a[rt];if(16>rt)var vt=gr.high=l[f+2*rt]|0,Ue=gr.low=l[f+2*rt+1]|0;else{var vt=a[rt-15],Ue=vt.high,wt=vt.low,vt=(Ue>>>1|wt<<31)^(Ue>>>8|wt<<24)^Ue>>>7,wt=(wt>>>1|Ue<<31)^(wt>>>8|Ue<<24)^(wt>>>7|Ue<<25),Rr=a[rt-2],Ue=Rr.high,$t=Rr.low,Rr=(Ue>>>19|$t<<13)^(Ue<<3|$t>>>29)^Ue>>>6,$t=($t>>>19|Ue<<13)^($t<<3|Ue>>>29)^($t>>>6|Ue<<26),Ue=a[rt-7],sn=Ue.high,br=a[rt-16],tt=br.high,br=br.low,Ue=wt+Ue.low,vt=vt+sn+(Ue>>>0>>0?1:0),Ue=Ue+$t,vt=vt+Rr+(Ue>>>0<$t>>>0?1:0),Ue=Ue+br,vt=vt+tt+(Ue>>>0
>>0?1:0);gr.high=vt,gr.low=Ue}var sn=Oe&Se^~Oe&Ke,br=fe&Re^~fe&Qe,gr=Y&se^Y&ve^se&ve,Ar=ee&le^ee&we^le&we,wt=(Y>>>28|ee<<4)^(Y<<30|ee>>>2)^(Y<<25|ee>>>7),Rr=(ee>>>28|Y<<4)^(ee<<30|Y>>>2)^(ee<<25|Y>>>7),$t=s[rt],Nn=$t.high,Qs=$t.low,$t=yt+((fe>>>14|Oe<<18)^(fe>>>18|Oe<<14)^(fe<<23|Oe>>>9)),tt=je+((Oe>>>14|fe<<18)^(Oe>>>18|fe<<14)^(Oe<<23|fe>>>9))+($t>>>0>>0?1:0),$t=$t+br,tt=tt+sn+($t>>>0
>>0?1:0),$t=$t+Qs,tt=tt+Nn+($t>>>0>>0?1:0),$t=$t+Ue,tt=tt+vt+($t>>>0>>0?1:0),Ue=Rr+Ar,gr=wt+gr+(Ue>>>0>>0?1:0),je=Ke,yt=Qe,Ke=Se,Qe=Re,Se=Oe,Re=fe,fe=Le+$t|0,Oe=Pe+tt+(fe>>>0>>0?1:0)|0,Pe=ve,Le=we,ve=se,we=le,se=Y,le=ee,ee=$t+Ue|0,Y=tt+gr+(ee>>>0<$t>>>0?1:0)|0}F=m.low=F+ee,m.high=S+Y+(F>>>0>>0?1:0),H=p.low=H+le,p.high=_+se+(H>>>0>>0?1:0),C=d.low=C+we,d.high=V+ve+(C>>>0>>0?1:0),L=v.low=L+Le,v.high=I+Pe+(L>>>0>>0?1:0),k=g.low=k+fe,g.high=R+Oe+(k>>>0>>0?1:0),N=y.low=N+Re,y.high=M+Se+(N>>>0>>0?1:0),O=w.low=O+Qe,w.high=D+Ke+(O>>>0>>0?1:0),J=E.low=J+yt,E.high=q+je+(J>>>0>>0?1:0)},_doFinalize:function(){var l=this._data,f=l.words,m=8*this._nDataBytes,p=8*l.sigBytes;return f[p>>>5]|=128<<24-p%32,f[(p+128>>>10<<5)+30]=Math.floor(m/4294967296),f[(p+128>>>10<<5)+31]=m,l.sigBytes=4*f.length,this._process(),this._hash.toX32()},clone:function(){var l=r.clone.call(this);return l._hash=this._hash.clone(),l},blockSize:32}),t.SHA512=r._createHelper(o),t.HmacSHA512=r._createHmacHelper(o)})();(function(){var e=He,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 o=n._doFinalize.call(this);return o.sigBytes-=16,o}});e.SHA384=n._createHelper(i),e.HmacSHA384=n._createHmacHelper(i)})();(function(){var e=He,l=e.lib,t=l.WordArray,r=l.Hasher,l=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]),o=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]),a=t.create([0,1518500249,1859775393,2400959708,2840853838]),u=t.create([1352829926,1548603684,1836072691,2053994217,0]),l=l.RIPEMD160=r.extend({_doReset:function(){this._hash=t.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(f,m){for(var p=0;16>p;p++){var d=m+p,v=f[d];f[d]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360}var d=this._hash.words,v=a.words,g=u.words,y=n.words,w=i.words,E=o.words,S=s.words,F,_,H,V,C,I,L,R,k,M;I=F=d[0],L=_=d[1],R=H=d[2],k=V=d[3],M=C=d[4];for(var N,p=0;80>p;p+=1)N=F+f[m+y[p]]|0,N=16>p?N+((_^H^V)+v[0]):32>p?N+((_&H|~_&V)+v[1]):48>p?N+(((_|~H)^V)+v[2]):64>p?N+((_&V|H&~V)+v[3]):N+((_^(H|~V))+v[4]),N|=0,N=N<>>32-E[p],N=N+C|0,F=C,C=V,V=H<<10|H>>>22,H=_,_=N,N=I+f[m+w[p]]|0,N=16>p?N+((L^(R|~k))+g[0]):32>p?N+((L&k|R&~k)+g[1]):48>p?N+(((L|~R)^k)+g[2]):64>p?N+((L&R|~L&k)+g[3]):N+((L^R^k)+g[4]),N|=0,N=N<>>32-S[p],N=N+M|0,I=M,M=k,k=R<<10|R>>>22,R=L,L=N;N=d[1]+H+k|0,d[1]=d[2]+V+M|0,d[2]=d[3]+C+I|0,d[3]=d[4]+F+L|0,d[4]=d[0]+_+R|0,d[0]=N},_doFinalize:function(){var f=this._data,m=f.words,p=8*this._nDataBytes,d=8*f.sigBytes;for(m[d>>>5]|=128<<24-d%32,m[(d+64>>>9<<4)+14]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,f.sigBytes=4*(m.length+1),this._process(),f=this._hash,m=f.words,p=0;5>p;p++)d=m[p],m[p]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360;return f},clone:function(){var f=r.clone.call(this);return f._hash=this._hash.clone(),f}});e.RIPEMD160=r._createHelper(l),e.HmacRIPEMD160=r._createHmacHelper(l)})(Math);(function(){var e=He,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,o=4*i;n.sigBytes>o&&(n=r.finalize(n)),n.clamp();for(var s=this._oKey=n.clone(),a=this._iKey=n.clone(),u=s.words,l=a.words,f=0;f>6)+If.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=If.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=If.charAt(r>>2)+If.charAt((r&3)<<4)),vy)for(;(n.length&3)>0;)n+=vy;return n}function Pf(e){var t="",r,n=0,i,o;for(r=0;r>2),i=o&3,n=1):n==1?(t+=Ma(i<<2|o>>4),i=o&15,n=2):n==2?(t+=Ma(i),t+=Ma(o>>2),i=o&3,n=3):(t+=Ma(i<<2|o>>4),t+=Ma(o&15),n=0));return n==1&&(t+=Ma(i<<2)),t}function q8(e){var t=Pf(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 AM(e,t,r,n,i,o){for(var s=t&32767,a=t>>15;--o>=0;){var u=this[e]&32767,l=this[e++]>>15,f=a*u+l*s;u=s*u+((f&32767)<<15)+r[n]+(i&1073741823),i=(u>>>30)+(f>>>15)+a*l+(i>>>30),r[n++]=u&1073741823}return i}function SM(e,t,r,n,i,o){for(var s=t&16383,a=t>>14;--o>=0;){var u=this[e]&16383,l=this[e++]>>14,f=a*u+l*s;u=s*u+((f&16383)<<14)+r[n]+i,i=(u>>28)+(f>>14)+a*l,r[n++]=u&268435455}return i}H8&&Bd.appName=="Microsoft Internet Explorer"?(oe.prototype.am=AM,Xu=30):H8&&Bd.appName!="Netscape"?(oe.prototype.am=bM,Xu=26):(oe.prototype.am=SM,Xu=28);oe.prototype.DB=Xu;oe.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function DM(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 Wu(e){var t=Ht();return t.fromInt(e),t}function FM(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,o=0;--n>=0;){var s=r==8?e[n]&255:K8(e,n);if(s<0){e.charAt(n)=="-"&&(i=!0);continue}i=!1,o==0?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB)}r==8&&e[0]&128&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t}function IM(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(a>a)>0&&(i=!0,o=Ma(n));s>=0;)a>(a+=this.DB-t)):(n=this[s]>>(a-=t)&r,a<=0&&(a+=this.DB,--s)),n>0&&(i=!0),i&&(o+=Ma(n));return i?o:"0"}function $M(){var e=Ht();return oe.ZERO.subTo(this,e),e}function PM(){return this.s<0?this.negate():this}function xM(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 N1(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 TM(){return this.t<=0?0:this.DB*(this.t-1)+N1(this[this.t-1]^this.s&this.DM)}function RM(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 kM(e,t){for(var r=e;r=0;--a)t[a+o+1]=this[a]>>n|s,s=(this[a]&i)<=0;--a)t[a]=0;t[o]=s,t.t=this.t+o+1,t.s=this.s,t.clamp()}function NM(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,o=(1<>n;for(var s=r+1;s>n;n>0&&(t[this.t-r-1]|=(this.s&o)<>=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 UM(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 MM(e,t,r){var n=e.abs();if(n.t<=0)throw"BigInteger divide by zero";var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var l=o.t,f=o[l-1];if(f!=0){var m=f*(1<1?o[l-2]>>this.F2:0),p=this.FV/m,d=(1<=0&&(r[r.t++]=1,r.subTo(w,r)),oe.ONE.dlShiftTo(l,w),w.subTo(o,o);o.t=0;){var E=r[--g]==f?this.DM:Math.floor(r[g]*p+(r[g-1]+v)*d);if((r[g]+=o.am(0,E,r,y,0,l))0&&r.rShiftTo(u,r),s<0&&oe.ZERO.subTo(r,r)}}function jM(e){var t=Ht();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(oe.ZERO)>0&&e.subTo(t,t),t}function ll(e){this.m=e}function qM(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function KM(e){return e}function VM(e){e.divRemTo(this.m,null,e)}function zM(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function GM(e,t){e.squareTo(t),this.reduce(t)}ll.prototype.convert=qM;ll.prototype.revert=KM;ll.prototype.reduce=VM;ll.prototype.mulTo=zM;ll.prototype.sqrTo=GM;function YM(){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 fl(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 XM(e){var t=Ht();return e.copyTo(t),this.reduce(t),t}function JM(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 ZM(e,t){e.squareTo(t),this.reduce(t)}function QM(e,t,r){e.multiplyTo(t,r),this.reduce(r)}fl.prototype.convert=WM;fl.prototype.revert=XM;fl.prototype.reduce=JM;fl.prototype.mulTo=QM;fl.prototype.sqrTo=ZM;function ej(){return(this.t>0?this[0]&1:this.s)==0}function tj(e,t){if(e>4294967295||e<1)return oe.ONE;var r=Ht(),n=Ht(),i=t.convert(this),o=N1(e)-1;for(i.copyTo(r);--o>=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 rj(e,t){var r;return e<256||t.isEven()?r=new ll(t):r=new fl(t),this.exp(e,r)}oe.prototype.copyTo=_M;oe.prototype.fromInt=DM;oe.prototype.fromString=FM;oe.prototype.clamp=BM;oe.prototype.dlShiftTo=RM;oe.prototype.drShiftTo=kM;oe.prototype.lShiftTo=OM;oe.prototype.rShiftTo=NM;oe.prototype.subTo=LM;oe.prototype.multiplyTo=UM;oe.prototype.squareTo=HM;oe.prototype.divRemTo=MM;oe.prototype.invDigit=YM;oe.prototype.isEven=ej;oe.prototype.exp=tj;oe.prototype.toString=IM;oe.prototype.negate=$M;oe.prototype.abs=PM;oe.prototype.compareTo=xM;oe.prototype.bitLength=TM;oe.prototype.mod=jM;oe.prototype.modPowInt=rj;oe.ZERO=Wu(0);oe.ONE=Wu(1);function nj(){var e=Ht();return this.copyTo(e),e}function sj(){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 oj(){return this.t==0?this.s:this[0]<<16>>16}function aj(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function uj(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function cj(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=Wu(r),i=Ht(),o=Ht(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s}function lj(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0)}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),i&&oe.ZERO.subTo(this,this)}function fj(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(oe.ONE.shiftLeft(e-1),Ay,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(oe.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 dj(e){return this.compareTo(e)==0}function pj(e){return this.compareTo(e)<0?this:e}function mj(e){return this.compareTo(e)>0?this:e}function gj(e,t,r){var n,i,o=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 Dj(){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 kj(e){var t=Ht();return this.addTo(e,t),t}function Oj(e){var t=Ht();return this.subTo(e,t),t}function Nj(e){var t=Ht();return this.multiplyTo(e,t),t}function Lj(){var e=Ht();return this.squareTo(e),e}function Uj(e){var t=Ht();return this.divRemTo(e,t,null),t}function Hj(e){var t=Ht();return this.divRemTo(e,null,t),t}function Mj(e){var t=Ht(),r=Ht();return this.divRemTo(e,t,r),new Array(t,r)}function jj(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function qj(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 $d(){}function G8(e){return e}function Kj(e,t,r){e.multiplyTo(t,r)}function Vj(e,t){e.squareTo(t)}$d.prototype.convert=G8;$d.prototype.revert=G8;$d.prototype.mulTo=Kj;$d.prototype.sqrTo=Vj;function zj(e){return this.exp(e,new $d)}function Gj(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=Ht();return e.copyTo(t),this.reduce(t),t}function Xj(e){return e}function Jj(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 Zj(e,t){e.squareTo(t),this.reduce(t)}function Qj(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Tf.prototype.convert=Wj;Tf.prototype.revert=Xj;Tf.prototype.reduce=Jj;Tf.prototype.mulTo=Qj;Tf.prototype.sqrTo=Zj;function eq(e,t){if(e.signum()<0)return this.modInverse(t).modPow(e.negate(),t);var r=e.bitLength(),n,i=Wu(1),o;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?o=new ll(t):t.isEven()?o=new Tf(t):o=new fl(t);var s=new Array,a=3,u=n-1,l=(1<1){var f=Ht();for(o.sqrTo(s[1],f);a<=l;)s[a]=Ht(),o.mulTo(f,s[a-2],s[a]),a+=2}var m=e.t-1,p,d=!0,v=Ht(),g;for(r=N1(e[m])-1;m>=0;){for(r>=u?p=e[m]>>r-u&l:(p=(e[m]&(1<0&&(p|=e[m-1]>>this.DB+r-u)),a=n;!(p&1);)p>>=1,--a;if((r-=a)<0&&(r+=this.DB,--m),d)s[p].copyTo(i),d=!1;else{for(;a>1;)o.sqrTo(i,v),o.sqrTo(v,i),a-=2;a>0?o.sqrTo(i,v):(g=i,i=v,v=g),o.mulTo(v,s[p],i)}for(;m>=0&&!(e[m]&1<0&&(t.rShiftTo(o,t),r.rShiftTo(o,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 o>0&&r.lShiftTo(o,r),r}function rq(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 nq(e){if(e.signum()==0)return oe.ZERO;var t=this.mod(e),r=e.isEven();if(t.isEven()&&r||t.signum()==0)return oe.ZERO;for(var n=e.clone(),i=t.clone(),o=Wu(1),s=Wu(0),a=Wu(0),u=Wu(1);n.signum()!=0;){for(;n.isEven();)n.rShiftTo(1,n),r?((!o.isEven()||!s.isEven())&&(o.addTo(t,o),s.subTo(e,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),r?((!a.isEven()||!u.isEven())&&(a.addTo(t,a),u.subTo(e,u)),a.rShiftTo(1,a)):u.isEven()||u.subTo(e,u),u.rShiftTo(1,u);n.compareTo(i)>=0?(n.subTo(i,n),r&&o.subTo(a,o),s.subTo(u,s)):(i.subTo(n,i),r&&a.subTo(o,a),u.subTo(s,u))}if(i.compareTo(oe.ONE)!=0)return oe.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 ys=[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],sq=(1<<26)/ys[ys.length-1];function iq(e){if(this.signum()<=0)return!1;var t,r=this.abs();if(r.t==1&&r[0]<=ys[ys.length-1]){for(t=0;t>1,e>ys.length&&(e=ys.length);for(var i=Ht(),o=0;o>8&255,Ms[Hr++]^=e>>16&255,Ms[Hr++]^=e>>24&255,Hr>=Fd&&(Hr-=Fd)}function Cy(){lq(new Date().getTime())}if(Ms==null){if(Ms=new Array,Hr=0,typeof Bf<"u"&&(Bf.crypto!==void 0||Bf.msCrypto!==void 0)){if(ja=Bf.crypto||Bf.msCrypto,ja.getRandomValues)for(my=new Uint8Array(32),ja.getRandomValues(my),Vn=0;Vn<32;++Vn)Ms[Hr++]=my[Vn];else if(Bd.appName=="Netscape"&&Bd.appVersion<"5")for(gy=Bf.crypto.random(32),Vn=0;Vn>>8,Ms[Hr++]=Vn&255;Hr=0,Cy()}var Vn,ja,my,gy,x1;function fq(){if(P1==null){for(Cy(),P1=cq(),P1.init(Ms),Hr=0;Hr0&&t.length>0)this.n=js(e,16),this.e=parseInt(t,16);else throw"Invalid RSA public key";if(this.n==null||typeof this.n.compareTo!="function"||this.n.compareTo(oe.ONE)<=0||this.e==null||isNaN(this.e)||this.e<=0)throw"Invalid RSA public key"}function pq(e){return e.modPowInt(this.e,this.n)}gt.prototype.doPublic=pq;gt.prototype.setPublic=dq;gt.prototype.type="RSA";function mq(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=js(e,16),this.e=parseInt(t,16),this.d=js(r,16);else throw"Invalid RSA private key"}function gq(e,t,r,n,i,o,s,a){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=js(e,16),this.e=parseInt(t,16),this.d=js(r,16),this.p=js(n,16),this.q=js(i,16),this.dmp1=js(o,16),this.dmq1=js(s,16),this.coeff=js(a,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function vq(e,t){var r=new Rf,n=e>>1;this.e=parseInt(t,16);for(var i=new oe(t,16),o=e/2-100,s=oe.ONE.shiftLeft(o);;){for(;this.p=new oe(e-n,1,r),!(this.p.subtract(oe.ONE).gcd(i).compareTo(oe.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new oe(n,1,r),!(this.q.subtract(oe.ONE).gcd(i).compareTo(oe.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var u=this.q.subtract(this.p).abs();if(!(u.bitLength()0;--l){i=i.twice();var f=r.testBit(l),m=t.testBit(l);f!=m&&(i=i.add(f?this:n))}for(l=s.bitLength()-2;l>0;--l){a=a.twice();var p=s.testBit(l),d=o.testBit(l);p!=d&&(a=a.add(p?a:u))}return i}function kq(e,t,r){var n;e.bitLength()>r.bitLength()?n=e.bitLength()-1:n=r.bitLength()-1;for(var i=this.curve.getInfinity(),o=this.add(t);n>=0;)i=i.twice(),e.testBit(n)?r.testBit(n)?i=i.add(o):i=i.add(this):r.testBit(n)&&(i=i.add(t)),--n;return i}Wt.prototype.getX=Fq;Wt.prototype.getY=Bq;Wt.prototype.equals=Iq;Wt.prototype.isInfinity=$q;Wt.prototype.negate=Pq;Wt.prototype.add=xq;Wt.prototype.twice=Tq;Wt.prototype.multiply=Rq;Wt.prototype.multiplyTwo=kq;function Ka(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new Wt(this,null,null)}function Oq(){return this.q}function Nq(){return this.a}function Lq(){return this.b}function Uq(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function Hq(){return this.infinity}function Mq(e){return new Zr(this.q,e)}function jq(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 oe(l,16)),i=this.getA(),o=this.getB(),s=n.square().add(i).multiply(n).add(o),a=s.sqrt();return t=="03"&&(a=a.negate()),new Wt(this,n,a);case 4:case 6:case 7:var u=(e.length-2)/2,l=e.substr(2,u),f=e.substr(u+2,u);return new Wt(this,this.fromBigInteger(new oe(l,16)),this.fromBigInteger(new oe(f,16)));default:return null}}Ka.prototype.getQ=Oq;Ka.prototype.getA=Nq;Ka.prototype.getB=Lq;Ka.prototype.equals=Uq;Ka.prototype.getInfinity=Hq;Ka.prototype.fromBigInteger=Mq;Ka.prototype.decodePointHex=jq;Zr.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};Wt.prototype.getEncoded=function(e){var t=function(o,s){var a=o.toByteArrayUnsigned();if(sa.length;)a.unshift(0);return a},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};Wt.decodeFrom=function(e,t){var r=t[0],n=t.length-1,i=t.slice(1,1+n/2),o=t.slice(1+n/2,1+n);i.unshift(0),o.unshift(0);var s=new oe(i),a=new oe(o);return new Wt(e,e.fromBigInteger(s),e.fromBigInteger(a))};Wt.decodeFromHex=function(e,t){var r=t.substr(0,2),n=t.length-2,i=t.substr(2,n/2),o=t.substr(2+n/2,n/2),s=new oe(i,16),a=new oe(o,16);return new Wt(e,e.fromBigInteger(s),e.fromBigInteger(a))};Wt.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),o=n.multiply(this.x.subtract(i)).subtract(this.y);return new Wt(this.curve,i,o)};Wt.prototype.twice2D=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var e=this.curve.fromBigInteger(oe.valueOf(2)),t=this.curve.fromBigInteger(oe.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 Wt(this.curve,n,i)};Wt.prototype.multiply2D=function(e){if(this.isInfinity())return this;if(e.signum()==0)return this.curve.getInfinity();var t=e,r=t.multiply(new oe("3")),n=this.negate(),i=this,o;for(o=r.bitLength()-2;o>0;--o){i=i.twice();var s=r.testBit(o),a=t.testBit(o);s!=a&&(i=i.add2D(s?this:n))}return i};Wt.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(),o=t.multiply(t).mod(i),s=e.multiply(e).multiply(e).add(r.multiply(e)).add(n).mod(i);return o.equals(s)};Wt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};Wt.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(oe.ONE)<0||t.compareTo(e.subtract(oe.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(oe.ONE)<0||r.compareTo(e.subtract(oe.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 Y8=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"),o={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:` `,r:"\r",t:" "};function s(m,p,d){return p?o[p]:String.fromCharCode(parseInt(d,16))}var a=new String(""),u="\\",l={"{":Object,"[":Array},f=Object.hasOwnProperty;return function(m,p){var d=m.match(n),v,g=d[0],y=!1;g==="{"?v={}:g==="["?v=[]:(v=[],y=!0);for(var w,E=[v],S=1-y,F=d.length;S=0;)delete I[L[M]]}return p.call(V,C,I)};v=H({"":v},"")}return v}}();(typeof A>"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});A.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 xd(e)},this.getPEMStringFromHex=function(e,t){return zn(e,t)},this.newObject=function(e){var t=A,r=t.asn1,n=r.ASN1Object,i=r.DERBoolean,o=r.DERInteger,s=r.DERBitString,a=r.DEROctetString,u=r.DERNull,l=r.DERObjectIdentifier,f=r.DEREnumerated,m=r.DERUTF8String,p=r.DERNumericString,d=r.DERPrintableString,v=r.DERTeletexString,g=r.DERIA5String,y=r.DERUTCTime,w=r.DERGeneralizedTime,E=r.DERVisibleString,S=r.DERBMPString,F=r.DERSequence,_=r.DERSet,H=r.DERTaggedObject,V=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var C=Object.keys(e);if(C.length!=1)throw new Error("key of param shall be only one.");var I=C[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+I+":")==-1)throw new Error("undefined key: "+I);if(I=="bool")return new i(e[I]);if(I=="int")return new o(e[I]);if(I=="bitstr")return new s(e[I]);if(I=="octstr")return new a(e[I]);if(I=="null")return new u(e[I]);if(I=="oid")return new l(e[I]);if(I=="enum")return new f(e[I]);if(I=="utf8str")return new m(e[I]);if(I=="numstr")return new p(e[I]);if(I=="prnstr")return new d(e[I]);if(I=="telstr")return new v(e[I]);if(I=="ia5str")return new g(e[I]);if(I=="utctime")return new y(e[I]);if(I=="gentime")return new w(e[I]);if(I=="visstr")return new E(e[I]);if(I=="bmpstr")return new S(e[I]);if(I=="asn1")return new n(e[I]);if(I=="seq"){for(var L=e[I],R=[],k=0;k"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="+o.length+",v="+this.hV);var s=this.hV.length/2,a=s.toString(16);if(a.length%2==1&&(a="0"+a),s<128)return a;var u=a.length/2;if(u>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+s.toString(16));var l=128+u;return l.toString(16)+a},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)};A.asn1.DERAbstractString=function(e){A.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=U1(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))};_e(A.asn1.DERAbstractString,A.asn1.ASN1Object);A.asn1.DERAbstractTime=function(e){A.asn1.DERAbstractTime.superclass.constructor.call(this);var t=null,r=null;this.localDateToUTC=function(n){var i=n.getTime()+n.getTimezoneOffset()*6e4,o=new Date(i);return o},this.formatDate=function(n,i,o){var s=this.zeroPadding,a=this.localDateToUTC(n),u=String(a.getFullYear());i=="utc"&&(u=u.substr(2,2));var l=s(String(a.getMonth()+1),2),f=s(String(a.getDate()),2),m=s(String(a.getHours()),2),p=s(String(a.getMinutes()),2),d=s(String(a.getSeconds()),2),v=u+l+f+m+p+d;if(o===!0){var g=a.getMilliseconds();if(g!=0){var y=s(String(g),3);y=y.replace(/[0]+$/,""),v=v+"."+y}}return v+"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,o,s,a,u){var l=new Date(Date.UTC(n,i-1,o,s,a,u,0));this.setByDate(l)},this.getFreshValueHex=function(){return this.hV}};_e(A.asn1.DERAbstractTime,A.asn1.ASN1Object);A.asn1.DERAbstractStructured=function(e){A.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)};_e(A.asn1.DERAbstractStructured,A.asn1.ASN1Object);A.asn1.DERBoolean=function(e){A.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",e==!1?this.hTLV="010100":this.hTLV="0101ff"};_e(A.asn1.DERBoolean,A.asn1.ASN1Object);A.asn1.DERInteger=function(e){A.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var t=xd;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 oe(String(r),10);else if(r.int!=null)n=new oe(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)};_e(A.asn1.DERInteger,A.asn1.ASN1Object);A.asn1.DERBitString=function(e){if(e!==void 0&&typeof e.obj<"u"){var t=A.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.tohex()}A.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||7e.length)throw new Error("too short ASN.1 value");e.substr(t,2)=="03"&&(i+=2,o-=2),s=0;for(var a=i;s<=o;){var u=r.getTLVblen(e,a);if(u<=0)throw new Error("malformed ASN.1: invalid TLV length");if(s+=u,s<=o&&n.push(a),a+=u,s>=o)break}return n};ke.getNthChildIdx=function(e,t,r){var n=ke.getChildIdx(e,t);return n[r]};ke.getIdxbyList=function(e,t,r,n){var i=ke,o,s;return r.length==0?n!==void 0&&e.substr(t,2)!==n?-1:t:(o=r.shift(),s=i.getChildIdx(e,t),o>=s.length?-1:i.getIdxbyList(e,s[o],r,n))};ke.getIdxbyListEx=function(e,t,r,n){var i=ke,o,s;if(r.length==0)return n!==void 0&&e.substr(t,2)!==n?-1:t;o=r.shift(),s=i.getChildIdx(e,t);for(var a=0,u=0;u=e.length?null:i.getTLV(e,o)};ke.getTLVbyListEx=function(e,t,r,n){var i=ke,o=i.getIdxbyListEx(e,t,r,n);return o==-1?null:i.getTLV(e,o)};ke.getVbyList=function(e,t,r,n,i){var o=ke,s,a;return s=o.getIdxbyList(e,t,r,n),s==-1||s>=e.length?null:(a=o.getV(e,s),i===!0&&(a=a.substr(2)),a)};ke.getVbyListEx=function(e,t,r,n,i){var o=ke,s,a,u;return s=o.getIdxbyListEx(e,t,r,n),s==-1?null:(u=o.getV(e,s),e.substr(s,2)=="03"&&i!==!1&&(u=u.substr(2)),u)};ke.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=ke.getV(e,t);return n=="02"?parseInt(i,16):i_(i)}catch{return r}};ke.getOID=function(e,t,r){r==null&&(r=null);try{if(e.substr(t,2)!="06")return r;var n=ke.getV(e,t);return K1(n)}catch{return r}};ke.getOIDName=function(e,t,r){r==null&&(r=null);try{var n=ke.getOID(e,t,r);if(n==r)return r;var i=A.asn1.x509.OID.oid2name(n);return i==""?n:i}catch{return r}};ke.getString=function(e,t,r){r==null&&(r=null);try{var n=ke.getV(e,t);return Ks(n)}catch{return r}};ke.hextooidstr=function(e){var t=function(m,p){return m.length>=p?m:new Array(p-m.length+1).join("0")+m},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 o=e.substr(2),s=[],a=0;a0&&(f=f+"."+u.join(".")),f};ke.dump=function(e,t,r,n){var i=ke,o=i.getV,s=i.dump,a=i.getChildIdx,u=e;e instanceof A.asn1.ASN1Object&&(u=e.tohex());var l=function(V,C){if(V.length<=C*2)return V;var I=V.substr(0,C)+"..(total "+V.length/2+"bytes).."+V.substr(V.length-C,C);return I};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var f=t.ommit_long_octet,_=u.substr(r,2);if(_=="01"){var m=o(u,r);return m=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(_=="02"){var m=o(u,r);return n+"INTEGER "+l(m,f)+` `}if(_=="03"){var m=o(u,r);if(i.isASN1HEX(m.substr(2))){var p=n+`BITSTRING, encapsulates `;return p=p+s(m.substr(2),t,0,n+" "),p}else return n+"BITSTRING "+l(m,f)+` `}if(_=="04"){var m=o(u,r);if(i.isASN1HEX(m)){var p=n+`OCTETSTRING, encapsulates `;return p=p+s(m,t,0,n+" "),p}else return n+"OCTETSTRING "+l(m,f)+` `}if(_=="05")return n+`NULL `;if(_=="06"){var d=o(u,r),v=A.asn1.ASN1Util.oidHexToInt(d),g=A.asn1.x509.OID.oid2name(v),y=v.replace(/\./g," ");return g!=""?n+"ObjectIdentifier "+g+" ("+y+`) `:n+"ObjectIdentifier ("+y+`) `}if(_=="0a")return n+"ENUMERATED "+parseInt(o(u,r))+` `;if(_=="0c")return n+"UTF8String '"+rr(o(u,r))+`' `;if(_=="13")return n+"PrintableString '"+rr(o(u,r))+`' `;if(_=="14")return n+"TeletexString '"+rr(o(u,r))+`' `;if(_=="16")return n+"IA5String '"+rr(o(u,r))+`' `;if(_=="17")return n+"UTCTime "+rr(o(u,r))+` `;if(_=="18")return n+"GeneralizedTime "+rr(o(u,r))+` `;if(_=="1a")return n+"VisualString '"+rr(o(u,r))+`' `;if(_=="1e")return n+"BMPString '"+By(o(u,r))+`' `;if(_=="30"){if(u.substr(r,4)=="3000")return n+`SEQUENCE {} `;var p=n+`SEQUENCE `,w=a(u,r),E=t;if((w.length==2||w.length==3)&&u.substr(w[0],2)=="06"&&u.substr(w[w.length-1],2)=="04"){var g=i.oidname(o(u,w[0])),S=JSON.parse(JSON.stringify(t));S.x509ExtName=g,E=S}for(var F=0;F4?{enum:{hex:w}}:{enum:parseInt(w,16)};if(g=="30"||g=="31")return y[d[g]]=v(e),y;if(g=="14"){var H=p(w);return y[d[g]]={str:H},y}else if(g=="1e"){var H=m(w);return y[d[g]]={str:H},y}else if(":0c:12:13:16:17:18:1a:".indexOf(g)!=-1){var H=f(w);return y[d[g]]={str:H},y}else if(g.match(/^8[0-9]$/)){var H=f(w);return H==null|H==""?{tag:{tag:g,explicit:!1,hex:w}}:H.match(/[\x00-\x1F\x7F-\x9F]/)!=null||H.match(/[\u0000-\u001F\u0080–\u009F]/)!=null?{tag:{tag:g,explicit:!1,hex:w}}:{tag:{tag:g,explicit:!1,str:H}}}else if(g.match(/^a[0-9]$/))try{if(!n(w))throw new Error("not encap");return{tag:{tag:g,explicit:!0,obj:r(w)}}}catch{return{tag:{tag:g,explicit:!0,hex:w}}}else{var V=new A.asn1.ASN1Object;V.hV=w;var C=V.getLengthHexFromValue();return{asn1:{tlv:g+C+w}}}}}};ke.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}};ke.isASN1HEX=function(e){var t=ke;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),i=t.getL(e,0),o=e.length-n.length-i.length;return o==r*2};ke.checkStrictDER=function(e,t,r,n,i){var o=ke;if(r===void 0){if(typeof e!="string")throw new Error("not hex string");if(e=e.toLowerCase(),!A.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=o.getL(e,t);if(s.length>i*2)throw new Error("L of TLV too long: idx="+t);var a=o.getVblen(e,t);if(a>n)throw new Error("value of L too long than hex: idx="+t);var u=o.getTLV(e,t),l=u.length-2-o.getL(e,t).length;if(l!==a*2)throw new Error("V string length and L's value not the same:"+l+"/"+a*2);if(t===0&&e.length!=u.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+u.length);var f=e.substr(t,2);if(f==="02"){var m=o.getVidx(e,t);if(e.substr(m,2)=="00"&&e.charCodeAt(m+2)<56)throw new Error("not least zeros for DER INTEGER")}if(parseInt(f,16)&32){for(var p=o.getVblen(e,t),d=0,v=o.getChildIdx(e,t),g=0;g"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.x509>"u"||!A.asn1.x509)&&(A.asn1.x509={});A.asn1.x509.Certificate=function(e){A.asn1.x509.Certificate.superclass.constructor.call(this);var t=A,r=t.asn1,n=r.DERBitString,i=r.DERSequence,o=r.x509,s=o.TBSCertificate,a=o.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(u){this.params=u},this.sign=function(){var u=this.params,l=u.sigalg;u.sigalg.name!=null&&(l=u.sigalg.name);var f=u.tbsobj.tohex(),m=new A.crypto.Signature({alg:l});m.init(u.cakey),m.updateHex(f),u.sighex=m.sign()},this.getPEM=function(){return zn(this.tohex(),"CERTIFICATE")},this.tohex=function(){var u=this.params;if((u.tbsobj==null||u.tbsobj==null)&&(u.tbsobj=new s(u)),u.sighex==null&&u.cakey!=null&&this.sign(),u.sighex==null)throw new Error("sighex or cakey parameter not defined");var l=[];l.push(u.tbsobj),l.push(new a({name:u.sigalg})),l.push(new n({hex:"00"+u.sighex}));var f=new i({array:l});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&(this.params=e)};_e(A.asn1.x509.Certificate,A.asn1.ASN1Object);A.asn1.x509.TBSCertificate=function(e){A.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=A,r=t.asn1,n=r.x509,i=r.DERTaggedObject,o=r.DERInteger,s=r.DERSequence,a=n.AlgorithmIdentifier,u=n.Time,l=n.X500Name,f=n.Extensions,m=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(p){this.params=p},this.tohex=function(){var p=[],d=this.params;if(d.version!=null||d.version!=1){var v=2;d.version!=null&&(v=d.version-1);var g=new i({obj:new o({int:v})});p.push(g)}p.push(new o(d.serial)),p.push(new a({name:d.sigalg})),p.push(new l(d.issuer)),p.push(new s({array:[new u(d.notbefore),new u(d.notafter)]})),p.push(new l(d.subject)),p.push(new m(Tt.getKey(d.sbjpubkey))),d.ext!==void 0&&d.ext.length>0&&p.push(new i({tag:"a3",obj:new f(d.ext)}));var y=new A.asn1.DERSequence({array:p});return y.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.x509.TBSCertificate,A.asn1.ASN1Object);A.asn1.x509.Extensions=function(e){A.asn1.x509.Extensions.superclass.constructor.call(this);var t=A,r=t.asn1,n=r.DERSequence,i=r.x509;this.aParam=[],this.setByParam=function(o){this.aParam=o},this.tohex=function(){for(var o=[],s=0;s-1&&a.push(new n({int:this.pathLen}));var u=new i({array:a});return this.asn1ExtnValue=u,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))};_e(A.asn1.x509.BasicConstraints,A.asn1.x509.Extension);A.asn1.x509.CRLDistributionPoints=function(e){A.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=A,r=t.asn1,n=r.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(i){for(var o=[],s=0;s0&&o.push(new r({array:s}))}var u=new r({array:o});return u.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};_e(A.asn1.x509.PolicyInformation,A.asn1.ASN1Object);A.asn1.x509.PolicyQualifierInfo=function(e){A.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=A.asn1,r=t.DERSequence,n=t.DERIA5String,i=t.DERObjectIdentifier,o=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 o(this.params.unotice)]});return s.tohex()}},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};_e(A.asn1.x509.PolicyQualifierInfo,A.asn1.ASN1Object);A.asn1.x509.UserNotice=function(e){A.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=A.asn1.DERSequence,r=A.asn1.DERInteger,n=A.asn1.x509.DisplayText,i=A.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var o=[];this.params.noticeref!==void 0&&o.push(new i(this.params.noticeref)),this.params.exptext!==void 0&&o.push(new n(this.params.exptext));var s=new t({array:o});return s.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};_e(A.asn1.x509.UserNotice,A.asn1.ASN1Object);A.asn1.x509.NoticeReference=function(e){A.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=A.asn1.DERSequence,r=A.asn1.DERInteger,n=A.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 o=[],s=this.params.noticenum,a=0;a0)for(var s=0;s0;i++){var o=t.shift();if(r===!0){var s=n.pop(),a=(s+","+o).replace(/\\,/g,",");n.push(a),r=!1}else n.push(o);o.substr(-1,1)==="\\"&&(r=!0)}return n=n.map(function(u){return u.replace("/","\\/")}),n.reverse(),"/"+n.join("/")};A.asn1.x509.X500Name.ldapToOneline=function(e){return A.asn1.x509.X500Name.ldapToCompat(e)};A.asn1.x509.RDN=function(e){A.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=A.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 A.asn1.x509.AttributeTypeAndValue({str:r,rule:this.sRule}))},this.addByMultiValuedString=function(r){for(var n=A.asn1.x509.RDN.parseString(r),i=0;i0)for(var r=0;r0;i++){var o=t.shift();if(r===!0){var s=n.pop(),a=(s+"+"+o).replace(/\\\+/g,"+");n.push(a),r=!1}else n.push(o);o.substr(-1,1)==="\\"&&(r=!0)}for(var u=!1,l=[],i=0;n.length>0;i++){var o=n.shift();if(u===!0){var f=l.pop();if(o.match(/"$/)){var a=(f+"+"+o).replace(/^([^=]+)="(.*)"$/,"$1=$2");l.push(a),u=!1}else l.push(f+"+"+o)}else l.push(o);o.match(/^[^=]+="/)&&(u=!0)}return l};A.asn1.x509.AttributeTypeAndValue=function(e){A.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=A,r=t.asn1,n=r.DERSequence,i=r.DERUTF8String,o=r.DERPrintableString,s=r.DERTeletexString,a=r.DERIA5String,u=r.DERVisibleString,l=r.DERBMPString,f=t.lang.String.isMail,m=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 d=p.str,v=d.match(/^([^=]+)=(.+)$/);if(v)this.sType=v[1],this.sValue=v[2];else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}else this.sType=p.type,this.sValue=p.value},this.setByString=function(p,d){d!==void 0&&(this.sRule=d);var v=p.match(/^([^=]+)=(.+)$/);if(v)this.setByAttrTypeAndValueStr(v[1],v[2]);else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)},this._getDsType=function(){var p=this.sType,d=this.sValue,v=this.sRule;return v==="prn"?p=="CN"&&f(d)?"ia5":m(d)?"prn":"utf8":v==="utf8"?p=="CN"&&f(d)?"ia5":p=="C"?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(p,d,v){v!==void 0&&(this.sRule=v),this.sType=p,this.sValue=d},this.getValueObj=function(p,d){if(p=="utf8")return new i({str:d});if(p=="prn")return new o({str:d});if(p=="tel")return new s({str:d});if(p=="ia5")return new a({str:d});if(p=="vis")return new u({str:d});if(p=="bmp")return new l({str:d});throw new Error("unsupported directory string type: type="+p+" value="+d)},this.tohex=function(){this.dsType==null&&(this.dsType=this._getDsType());var p=A.asn1.x509.OID.atype2obj(this.sType),d=this.getValueObj(this.dsType,this.sValue),v=new n({array:[p,d]});return this.TLV=v.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.x509.AttributeTypeAndValue,A.asn1.ASN1Object);A.asn1.x509.SubjectPublicKeyInfo=function(e){A.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=null,r=null,n=A,i=n.asn1,o=i.DERInteger,s=i.DERBitString,a=i.DERObjectIdentifier,u=i.DERSequence,l=i.ASN1Util.newObject,f=i.x509,m=f.AlgorithmIdentifier,p=n.crypto,d=p.ECDSA,v=p.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null)throw"algId and/or subjPubKey not set";var g=new u({array:[this.asn1AlgId,this.asn1SubjPKey]});return g},this.tohex=function(){var g=this.getASN1Object();return this.hTLV=g.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(g){try{if(g instanceof gt){var y=l({seq:[{int:{bigint:g.n}},{int:{int:g.e}}]}),w=y.tohex();this.asn1AlgId=new m({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+w})}}catch{}try{if(g instanceof A.crypto.ECDSA){var E=new a({name:g.curveName});this.asn1AlgId=new m({name:"ecPublicKey",asn1params:E}),this.asn1SubjPKey=new s({hex:"00"+g.pubKeyHex})}}catch{}try{if(g instanceof A.crypto.DSA){var E=new l({seq:[{int:{bigint:g.p}},{int:{bigint:g.q}},{int:{bigint:g.g}}]});this.asn1AlgId=new m({name:"dsa",asn1params:E});var S=new o({bigint:g.y});this.asn1SubjPKey=new s({hex:"00"+S.tohex()})}}catch{}},e!==void 0&&this.setPubKey(e)};_e(A.asn1.x509.SubjectPublicKeyInfo,A.asn1.ASN1Object);A.asn1.x509.Time=function(e){A.asn1.x509.Time.superclass.constructor.call(this);var t=null,r=null,n=A,i=n.asn1,o=i.DERUTCTime,s=i.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(a){this.timeParams=a},this.setByParam=function(a){this.params=a},this.getType=function(a){return a.match(/^[0-9]{12}Z$/)?"utc":a.match(/^[0-9]{14}Z$/)?"gen":a.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":a.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var a=this.params,u=null;if(typeof a=="string"&&(a={str:a}),a!=null&&a.str&&(a.type==null||a.type==null)&&(a.type=this.getType(a.str)),a!=null&&a.str?(a.type=="utc"&&(u=new o(a.str)),a.type=="gen"&&(u=new s(a.str))):this.type=="gen"?u=new s:u=new o,u==null)throw new Error("wrong setting for Time");return this.TLV=u.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};A.asn1.x509.Time_bak=function(e){A.asn1.x509.Time_bak.superclass.constructor.call(this);var t=null,r=null,n=A,i=n.asn1,o=i.DERUTCTime,s=i.DERGeneralizedTime;this.setTimeParams=function(a){this.timeParams=a},this.tohex=function(){var a=null;return this.timeParams!=null?this.type=="utc"?a=new o(this.timeParams):a=new s(this.timeParams):this.type=="utc"?a=new o:a=new s,this.TLV=a.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)};_e(A.asn1.x509.Time,A.asn1.ASN1Object);A.asn1.x509.AlgorithmIdentifier=function(e){A.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=A,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 o=null;for(var s in n)s===this.nameAlg&&(o=n[s]);if(o!==null)return this.hTLV=o,this.hTLV}this.nameAlg!==null&&this.asn1Alg===null&&(this.asn1Alg=r.x509.OID.name2obj(this.nameAlg));var a=[this.asn1Alg];this.asn1Params!==null&&a.push(this.asn1Params);var u=new r.DERSequence({array:a});return this.hTLV=u.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)}};_e(A.asn1.x509.AlgorithmIdentifier,A.asn1.ASN1Object);A.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};A.asn1.x509.GeneralName=function(e){A.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},r=A,n=r.asn1,i=n.x509,o=i.X500Name,s=i.OtherName,a=n.DERIA5String,u=n.DERPrintableString,l=n.DEROctetString,f=n.DERTaggedObject,m=n.ASN1Object,p=Error;this.params=null,this.setByParam=function(d){this.params=d},this.tohex=function(){var d=this.params,v,y,g,y=!1;if(d.other!==void 0)v="a0",g=new s(d.other);else if(d.rfc822!==void 0)v="81",g=new a({str:d.rfc822});else if(d.dns!==void 0)v="82",g=new a({str:d.dns});else if(d.dn!==void 0)v="a4",y=!0,typeof d.dn=="string"?g=new o({str:d.dn}):d.dn instanceof A.asn1.x509.X500Name?g=d.dn:g=new o(d.dn);else if(d.ldapdn!==void 0)v="a4",y=!0,g=new o({ldapstr:d.ldapdn});else if(d.certissuer!==void 0||d.certsubj!==void 0){v="a4",y=!0;var w,E,S=null;if(d.certsubj!==void 0?(w=!1,E=d.certsubj):(w=!0,E=d.certissuer),E.match(/^[0-9A-Fa-f]+$/)&&S==E,E.indexOf("-----BEGIN ")!=-1&&(S=_r(E)),S==null)throw new Error("certsubj/certissuer not cert");var F=new at;F.hex=S;var _;w?_=F.getIssuerHex():_=F.getSubjectHex(),g=new m,g.hTLV=_}else if(d.uri!==void 0)v="86",g=new a({str:d.uri});else if(d.ip!==void 0){v="87";var H,V=d.ip;try{if(V.match(/^[0-9a-f]+$/)){var C=V.length;if(C==8||C==16||C==32||C==64)H=V;else throw"err"}else H=Fy(V)}catch(L){throw new p("malformed IP address: "+d.ip+":"+L.message)}g=new l({hex:H})}else throw new p("improper params");var I=new f({tag:v,explicit:y,obj:g});return I.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.x509.GeneralName,A.asn1.ASN1Object);A.asn1.x509.GeneralNames=function(e){A.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=null,r=A,n=r.asn1;this.setByParamArray=function(i){for(var o=0;o"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,o){var s=this[n];if(!s.match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch{return!1}}};A.asn1.x509.OID.oid2name=function(e){var t=A.asn1.x509.OID.name2oidList;for(var r in t)if(t[r]==e)return r;return""};A.asn1.x509.OID.oid2atype=function(e){var t=A.asn1.x509.OID.atype2oidList;for(var r in t)if(t[r]==e)return r;return e};A.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=A.asn1.x509.OID.name2oidList;return t[e]===void 0?"":t[e]};A.asn1.x509.X509Util={};A.asn1.x509.X509Util.newCertPEM=function(e){var t=A.asn1.x509,r=t.TBSCertificate,n=t.Certificate,i=new n(e);return i.getPEM()};(typeof A>"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.cms>"u"||!A.asn1.cms)&&(A.asn1.cms={});A.asn1.cms.Attribute=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.DERSet,s=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(a){this.params=a},this.getValueArray=function(){throw new t("not yet implemented abstract")},this.tohex=function(){var a=new s({oid:this.typeOid}),u=new o({array:this.getValueArray()}),l=new i({array:[a,u]});return l.tohex()},this.getEncodedHex=function(){return this.tohex()}};_e(A.asn1.cms.Attribute,A.asn1.ASN1Object);A.asn1.cms.ContentType=function(e){var t=A,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)};_e(A.asn1.cms.ContentType,A.asn1.cms.Attribute);A.asn1.cms.MessageDigest=function(e){var t=A,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 o=new n(this.params);return[o]},e!=null&&this.setByParam(e)};_e(A.asn1.cms.MessageDigest,A.asn1.cms.Attribute);A.asn1.cms.SigningTime=function(e){var t=A,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)};_e(A.asn1.cms.SigningTime,A.asn1.cms.Attribute);A.asn1.cms.SigningCertificate=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.cms,s=o.ESSCertID,a=r.crypto;o.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 u=this.params.array,l=[],f=0;f0){for(var v=o(p.valhex,d[0]),g=m(v,0),y=[],w=0;w1){var F=o(p.valhex,d[1]);p.polhex=F}delete p.valhex},this.setSignaturePolicyIdentifier=function(p){var d=m(p.valhex,0);if(d.length>0){var v=n.getOID(p.valhex,d[0]);p.oid=v}if(d.length>1){var g=new t,y=m(p.valhex,d[1]),w=o(p.valhex,y[0]),E=g.getAlgorithmIdentifierName(w);p.alg=E;var S=i(p.valhex,y[1]);p.hash=S}delete p.valhex},this.setSigningCertificateV2=function(p){var d=m(p.valhex,0);if(d.length>0){for(var v=o(p.valhex,d[0]),g=m(v,0),y=[],w=0;w1){var F=o(p.valhex,d[1]);p.polhex=F}delete p.valhex},this.getESSCertID=function(p){var d={},v=m(p,0);if(v.length>0){var g=i(p,v[0]);d.hash=g}if(v.length>1){var y=o(p,v[1]),w=this.getIssuerSerial(y);w.serial!=null&&(d.serial=w.serial),w.issuer!=null&&(d.issuer=w.issuer)}return d},this.getESSCertIDv2=function(p){var d={},v=m(p,0);if(v.length<1||3g+1){var E=o(p,v[g+1]),S=this.getIssuerSerial(E);d.issuer=S.issuer,d.serial=S.serial}return d},this.getIssuerSerial=function(p){var d={},v=m(p,0),g=o(p,v[0]),y=r.getGeneralNames(g),w=y[0].dn;d.issuer=w;var E=i(p,v[1]);return d.serial={hex:E},d},this.getCertificateSet=function(p){for(var d=m(p,0),v=[],g=0;g"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.tsp>"u"||!A.asn1.tsp)&&(A.asn1.tsp={});A.asn1.tsp.TimeStampToken=function(e){var t=A,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)};_e(A.asn1.tsp.TimeStampToken,A.asn1.cms.SignedData);A.asn1.tsp.TSTInfo=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.DERInteger,s=n.DERBoolean,a=n.DERGeneralizedTime,u=n.DERObjectIdentifier,l=n.DERTaggedObject,f=n.tsp,m=f.MessageImprint,p=f.Accuracy,d=n.x509.X500Name,v=n.x509.GeneralName;if(f.TSTInfo.superclass.constructor.call(this),this.dVersion=new o({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var g=[this.dVersion];if(this.dPolicy==null)throw new Error("policy shall be specified.");if(g.push(this.dPolicy),this.dMessageImprint==null)throw new Error("messageImprint shall be specified.");if(g.push(this.dMessageImprint),this.dSerial==null)throw new Error("serialNumber shall be specified.");if(g.push(this.dSerial),this.dGenTime==null)throw new Error("genTime shall be specified.");g.push(this.dGenTime),this.dAccuracy!=null&&g.push(this.dAccuracy),this.dOrdering!=null&&g.push(this.dOrdering),this.dNonce!=null&&g.push(this.dNonce),this.dTsa!=null&&g.push(this.dTsa);var y=new i({array:g});return this.hTLV=y.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0){if(typeof e.policy=="string"){if(!e.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new u({oid:e.policy})}e.messageImprint!==void 0&&(this.dMessageImprint=new m(e.messageImprint)),e.serial!==void 0&&(this.dSerial=new o(e.serial)),e.genTime!==void 0&&(this.dGenTime=new a(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 o(e.nonce)),e.tsa!==void 0&&(this.dTsa=new l({tag:"a0",explicit:!0,obj:new v({dn:e.tsa})}))}};_e(A.asn1.tsp.TSTInfo,A.asn1.ASN1Object);A.asn1.tsp.Accuracy=function(e){var t=A,r=t.asn1,n=r.ASN1Util.newObject;r.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var i=this.params,o=[];return i.seconds!=null&&typeof i.seconds=="number"&&o.push({int:i.seconds}),i.millis!=null&&typeof i.millis=="number"&&o.push({tag:{tagi:"80",obj:{int:i.millis}}}),i.micros!=null&&typeof i.micros=="number"&&o.push({tag:{tagi:"81",obj:{int:i.micros}}}),n({seq:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.Accuracy,A.asn1.ASN1Object);A.asn1.tsp.MessageImprint=function(e){var t=A,r=t.asn1,n=r.DERSequence,i=r.DEROctetString,o=r.x509,s=o.AlgorithmIdentifier;r.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var a=this.params,u=new s({name:a.alg}),l=new i({hex:a.hash}),f=new n({array:[u,l]});return f.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.tsp.MessageImprint,A.asn1.ASN1Object);A.asn1.tsp.TimeStampReq=function(e){var t=A,r=t.asn1,n=r.DERSequence,i=r.DERInteger,o=r.DERBoolean,s=r.ASN1Object,a=r.DERObjectIdentifier,u=r.tsp,l=u.MessageImprint;u.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var f=this.params,m=[];m.push(new i({int:1})),f.messageImprint instanceof A.asn1.ASN1Object?m.push(f.messageImprint):m.push(new l(f.messageImprint)),f.policy!=null&&m.push(new a(f.policy)),f.nonce!=null&&m.push(new i(f.nonce)),f.certreq==!0&&m.push(new o);var p=new n({array:m});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.TimeStampReq,A.asn1.ASN1Object);A.asn1.tsp.TimeStampResp=function(e){var t=A,r=t.asn1,n=r.DERSequence,i=r.ASN1Object,o=r.tsp,s=o.PKIStatusInfo;o.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var a=this.params,u=[];if(a.econtent!=null||a.tst!=null)if(a.statusinfo!=null?u.push(new s(a.statusinfo)):u.push(new s("granted")),a.econtent!=null)u.push(new o.TimeStampToken(a).getContentInfo());else if(a.tst instanceof r.ASN1Object)u.push(a.tst);else throw new Error("improper member tst value");else if(a.statusinfo!=null)u.push(new s(a.statusinfo));else throw new Error("parameter for token nor statusinfo not specified");var l=new n({array:u});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.TimeStampResp,A.asn1.ASN1Object);A.asn1.tsp.PKIStatusInfo=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.tsp,s=o.PKIStatus,a=o.PKIFreeText,u=o.PKIFailureInfo;o.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var l=this.params,f=[];if(typeof l=="string")f.push(new s(l));else{if(l.status==null)throw new t("property 'status' unspecified");f.push(new s(l.status)),l.statusstr!=null&&f.push(new a(l.statusstr)),l.failinfo!=null&&f.push(new u(l.failinfo))}var m=new i({array:f});return m.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.PKIStatusInfo,A.asn1.ASN1Object);A.asn1.tsp.PKIStatus=function(e){var t=Error,r=A,n=r.asn1,i=n.DERInteger,o=n.tsp;o.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 a=this.params,u,l;if(typeof a=="string")try{l=s[a]}catch{throw new t("undefined name: "+a)}else if(typeof a=="number")l=a;else throw new t("unsupported params");return new i({int:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.PKIStatus,A.asn1.ASN1Object);A.asn1.tsp.PKIFreeText=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.DERUTF8String,s=n.tsp;s.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var a=this.params;if(!(a instanceof Array))throw new t("wrong params: not array");for(var u=[],l=0;l=0;p--)m+=f[p];return m}else{if(typeof u=="string"&&a[u]!=null)return k1([u],a);if(typeof u=="object"&&u.length!=null)return k1(u,a);throw new t("wrong params")}},this.tohex=function(){var u=this.params,l=this.getBinValue();return new i({bin:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.tsp.PKIFailureInfo,A.asn1.ASN1Object);A.asn1.tsp.AbstractTSAAdapter=function(e){this.getTSTHex=function(t,r){throw"not implemented yet"}};A.asn1.tsp.SimpleTSAAdapter=function(e){var t=A,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(o,s){var a=i(o,s);this.params.econtent.content.messageImprint={alg:s,hash:a},this.params.econtent.content.serial={int:this.serial++};var u=Math.floor(Math.random()*1e9);this.params.econtent.content.nonce={int:u};var l=new n.TimeStampToken(this.params);return l.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};_e(A.asn1.tsp.SimpleTSAAdapter,A.asn1.tsp.AbstractTSAAdapter);A.asn1.tsp.FixedTSAAdapter=function(e){var t=A,r=t.asn1,n=r.tsp,i=t.crypto.Util.hashHex;n.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(o,s){var a=i(o,s);this.params.econtent.content.messageImprint={alg:s,hash:a};var u=new n.TimeStampToken(this.params);return u.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};_e(A.asn1.tsp.FixedTSAAdapter,A.asn1.tsp.AbstractTSAAdapter);A.asn1.tsp.TSPUtil=new function(){};A.asn1.tsp.TSPUtil.newTimeStampToken=function(e){return new A.asn1.tsp.TimeStampToken(e)};A.asn1.tsp.TSPUtil.parseTimeStampReq=function(e){var t=new A.asn1.tsp.TSPParser;return t.getTimeStampReq(e)};A.asn1.tsp.TSPUtil.parseMessageImprint=function(e){var t=new A.asn1.tsp.TSPParser;return t.getMessageImprint(e)};A.asn1.tsp.TSPParser=function(){var e=Error,t=at,r=new t,n=ke,i=n.getV,o=n.getTLV,s=n.getIdxbyList,a=n.getTLVbyListEx,u=n.getChildIdx,l=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],f={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(m){var p=u(m,0);if(p.length==1)return this.getPKIStatusInfo(o(m,p[0]));if(p.length>1){var d=this.getPKIStatusInfo(o(m,p[0])),v=o(m,p[1]),g=this.getToken(v);return g.statusinfo=d,g}},this.getToken=function(m){var p=new A.asn1.cms.CMSParser,d=p.getCMSSignedData(m);return this.setTSTInfo(d),d},this.setTSTInfo=function(m){var p=m.econtent;if(p.type=="tstinfo"){var d=p.content.hex,v=this.getTSTInfo(d);p.content=v}},this.getTSTInfo=function(m){var p={},d=u(m,0),v=i(m,d[1]);p.policy=K1(v);var g=o(m,d[2]);p.messageImprint=this.getMessageImprint(g);var y=i(m,d[3]);p.serial={hex:y};var w=i(m,d[4]);p.genTime={str:rr(w)};var E=0;if(d.length>5&&m.substr(d[5],2)=="30"){var S=o(m,d[5]);p.accuracy=this.getAccuracy(S),E++}if(d.length>5+E&&m.substr(d[5+E],2)=="01"){var F=i(m,d[5+E]);F=="ff"&&(p.ordering=!0),E++}if(d.length>5+E&&m.substr(d[5+E],2)=="02"){var _=i(m,d[5+E]);p.nonce={hex:_},E++}if(d.length>5+E&&m.substr(d[5+E],2)=="a0"){var H=o(m,d[5+E]);H="30"+H.substr(2),pGeneralNames=r.getGeneralNames(H);var V=pGeneralNames[0].dn;p.tsa=V,E++}if(d.length>5+E&&m.substr(d[5+E],2)=="a1"){var C=o(m,d[5+E]);C="30"+C.substr(2);var I=r.getExtParamArray(C);p.ext=I,E++}return p},this.getAccuracy=function(m){for(var p={},d=u(m,0),v=0;v1&&m.substr(d[1],2)=="30"){var w=o(m,d[1]);p.statusstr=this.getPKIFreeText(w),v++}if(d.length>v&&m.substr(d[1+v],2)=="03"){var E=o(m,d[1+v]);p.failinfo=this.getPKIFailureInfo(E)}return p},this.getPKIFreeText=function(m){for(var p=[],d=u(m,0),v=0;v"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.cades>"u"||!A.asn1.cades)&&(A.asn1.cades={});A.asn1.cades.SignaturePolicyIdentifier=function(e){var t=A,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(o){this.params=o},e!=null&&this.setByParam(e)};_e(A.asn1.cades.SignaturePolicyIdentifier,A.asn1.cms.Attribute);A.asn1.cades.SignaturePolicyId=function(e){var t=A,r=t.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,o=r.x509,s=o.AlgorithmIdentifier,a=r.cades,u=a.SignaturePolicyId,l=a.OtherHashAlgAndValue;u.superclass.constructor.call(this),this.params=null,this.tohex=function(){var f=this.params,m=[];m.push(new i(f.oid)),m.push(new l(f));var p=new n({array:m});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(f){this.params=f},e!=null&&this.setByParam(e)};_e(A.asn1.cades.SignaturePolicyId,A.asn1.ASN1Object);A.asn1.cades.OtherHashAlgAndValue=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.DEROctetString,s=n.x509,a=s.AlgorithmIdentifier,u=n.cades,l=u.OtherHashAlgAndValue;l.superclass.constructor.call(this),this.params=null,this.tohex=function(){var f=this.params;if(f.alg==null)throw new t("property 'alg' not specified");if(f.hash==null&&f.cert==null)throw new t("property 'hash' nor 'cert' not specified");var m=null;if(f.hash!=null)m=f.hash;else if(f.cert!=null){if(typeof f.cert!="string")throw new t("cert not string");var p=f.cert;f.cert.indexOf("-----BEGIN")!=-1&&(p=_r(f.cert)),m=A.crypto.Util.hashHex(p,f.alg)}var d=[];d.push(new a({name:f.alg})),d.push(new o({hex:m}));var v=new i({array:d});return v.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.cades.OtherHashAlgAndValue,A.asn1.ASN1Object);A.asn1.cades.OtherHashValue=function(e){A.asn1.cades.OtherHashValue.superclass.constructor.call(this);var t=Error,r=A,n=r.lang.String.isHex,i=r.asn1,o=i.DEROctetString,s=r.crypto.Util.hashHex;this.params=null,this.tohex=function(){var a=this.params;if(a.hash==null&&a.cert==null)throw new t("hash or cert not specified");var u=null;if(a.hash!=null)u=a.hash;else if(a.cert!=null){if(typeof a.cert!="string")throw new t("cert not string");var l=a.cert;a.cert.indexOf("-----BEGIN")!=-1&&(l=_r(a.cert)),u=A.crypto.Util.hashHex(l,"sha1")}return new o({hex:u}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};_e(A.asn1.cades.OtherHashValue,A.asn1.ASN1Object);A.asn1.cades.SignatureTimeStamp=function(e){var t=Error,r=A,n=r.lang.String.isHex,i=r.asn1,o=i.ASN1Object,s=i.x509,a=i.cades;a.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var u=this.params;if(u.tst!=null)if(n(u.tst)){var l=new o;return l.hTLV=u.tst,[l]}else{if(u.tst instanceof o)return[u.tst];throw new t("params.tst has wrong value")}else if(u.res!=null){var f=u.res;if(f instanceof o&&(f=f.tohex()),typeof f!="string"||!n(f))throw new t("params.res has wrong value");var m=ke.getTLVbyList(f,0,[1]),l=new o;return l.hTLV=u.tst,[l]}},e!=null&&this.setByParam(e)};_e(A.asn1.cades.SignatureTimeStamp,A.asn1.cms.Attribute);A.asn1.cades.CompleteCertificateRefs=function(e){var t=Error,r=A,n=r.asn1,i=n.DERSequence,o=n.cades,s=o.OtherCertID,a=r.lang.String.isHex;o.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var u=this.params,l=[],f=0;f"u"||!A.asn1.csr)&&(A.asn1.csr={});A.asn1.csr.CertificationRequest=function(e){var t=A,r=t.asn1,n=r.DERBitString,i=r.DERSequence,o=r.csr,s=r.x509,a=o.CertificationRequestInfo;o.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(u){this.params=u},this.sign=function(){var u=new a(this.params).tohex(),l=new A.crypto.Signature({alg:this.params.sigalg});l.init(this.params.sbjprvkey),l.updateHex(u);var f=l.sign();this.params.sighex=f},this.getPEM=function(){return zn(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var u=this.params,l=new A.asn1.csr.CertificationRequestInfo(this.params),f=new A.asn1.x509.AlgorithmIdentifier({name:u.sigalg});if(u.sighex==null&&u.sbjprvkey!=null&&this.sign(),u.sighex==null)throw new Error("sighex or sbjprvkey parameter not defined");var m=new n({hex:"00"+u.sighex}),p=new i({array:[l,f,m]});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.csr.CertificationRequest,A.asn1.ASN1Object);A.asn1.csr.CertificationRequestInfo=function(e){var t=A,r=t.asn1,n=r.DERBitString,i=r.DERSequence,o=r.DERInteger,s=r.DERUTF8String,a=r.DERTaggedObject,u=r.ASN1Util.newObject,l=r.csr,f=r.x509,m=f.X500Name,p=f.Extensions,d=f.SubjectPublicKeyInfo,v=l.AttributeList;l.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(y){y!=null&&(this.params=y)},this.tohex=function(){var y=this.params,w=[];if(w.push(new o({int:0})),w.push(new m(y.subject)),w.push(new d(Tt.getKey(y.sbjpubkey))),y.attrs!=null){var E=g(y.attrs),S=u({tag:{tage:"a0",obj:E}});w.push(S)}else if(y.extreq!=null){var F=new p(y.extreq),S=u({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[F]}]}}});w.push(S)}else w.push(new a({tag:"a0",explicit:!1,obj:new s({str:""})}));var _=new i({array:w});return _.tohex()},this.getEncodedHex=function(){return this.tohex()};function g(y){for(var w=Error,E=A.asn1.x509.Extensions,S=[],F=0;F"u"||!A)&&(A={});(typeof A.asn1>"u"||!A.asn1)&&(A.asn1={});(typeof A.asn1.ocsp>"u"||!A.asn1.ocsp)&&(A.asn1.ocsp={});A.asn1.ocsp.DEFAULT_HASH="sha1";A.asn1.ocsp.OCSPResponse=function(e){A.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var t=A.asn1.DEREnumerated,r=A.asn1.ASN1Util.newObject,n=A.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var o=this.params.resstatus;return typeof o=="number"?o:typeof o!="string"?-1:i.indexOf(o)},this.setByParam=function(o){this.params=o},this.tohex=function(){var o=this.params,s=this._getStatusCode();if(s==-1)throw new Error("responseStatus not supported: "+o.resstatus);if(s!=0)return r({seq:[{enum:{int:s}}]}).tohex();var a=new n(o);return r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:a}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.ocsp.OCSPResponse,A.asn1.ASN1Object);A.asn1.ocsp.ResponseBytes=function(e){A.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var t=A.asn1,r=t.DERSequence,n=t.DERObjectIdentifier,i=t.DEROctetString,o=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 a=new o(s),u=[];u.push(new n({name:"ocspBasic"})),u.push(new i({hex:a.tohex()}));var l=new r({array:u});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};_e(A.asn1.ocsp.ResponseBytes,A.asn1.ASN1Object);A.asn1.ocsp.BasicOCSPResponse=function(e){A.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var t=Error,r=A.asn1,n=r.ASN1Object,i=r.DERSequence,o=r.DERGeneralizedTime,s=r.DERTaggedObject,a=r.DERBitString,u=r.x509.Extensions,l=r.x509.AlgorithmIdentifier,f=r.ocsp,m=f.ResponderID;_SingleResponseList=f.SingleResponseList,_ResponseData=f.ResponseData,this.params=null,this.setByParam=function(p){this.params=p},this.sign=function(){var p=this.params,d=p.tbsresp.tohex(),v=new A.crypto.Signature({alg:p.sigalg});v.init(p.reskey),v.updateHex(d),p.sighex=v.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 d=[];if(d.push(p.tbsresp),d.push(new l({name:p.sigalg})),d.push(new a({hex:"00"+p.sighex})),p.certs!=null&&p.certs.length!=null){for(var v=[],g=0;g"u"||!A)&&(A={});(typeof A.lang>"u"||!A.lang)&&(A.lang={});A.lang.String=function(){};function W8(e){for(var t=new Array,r=0;r>6,u=128|s&63;return rr(a.toString(16)+u.toString(16))}var a=224|(o&240)>>4,u=128|(o&15)<<2|(s&192)>>6,l=128|s&63;return rr(a.toString(16)+u.toString(16)+l.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function q1(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function oK(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 o=parseInt(r);if(o<0||255t.length&&(r=t.length);for(var n=0;n0&&(l=l+"."+a.join(".")),l}catch{return null}}function s_(e){var t=new oe(String(e),10);return xd(t)}function xd(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="",o=0;o=t?e:new Array(t-e.length+1).join(r)+e};function i_(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 o=parseInt(i,2);return o==NaN?-1:o}catch{return-1}}function o_(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+R1("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var i="0"+r;return i+n}function a_(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--)o+=i[n];return o}function ur(e,n,r){if(typeof e=="object"){for(var n=String(n).split("."),i=0;i"u"||!A)&&(A={});(typeof A.crypto>"u"||!A.crypto)&&(A.crypto={});A.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:He.algo.MD5,sha1:He.algo.SHA1,sha224:He.algo.SHA224,sha256:He.algo.SHA256,sha384:He.algo.SHA384,sha512:He.algo.SHA512,ripemd160:He.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 o="0001",s="00"+n,a="",u=i-o.length-s.length,l=0;l=0)return r}};A.crypto.Util.getRandomBigIntegerMinToMax=function(e,t){var r=e.compareTo(t);if(r>0)throw"biMin is greater than biMax";if(r==0)return e;var n=t.subtract(e),i=A.crypto.Util.getRandomBigIntegerZeroToMax(n);return i.add(e)};A.crypto.MessageDigest=function(e){var t=null,r=null,n=null;this.setAlgAndProvider=function(i,o){if(i=A.crypto.MessageDigest.getCanonicalAlgName(i),i!==null&&o===void 0&&(o=A.crypto.Util.DEFAULTPROVIDER[i]),":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(i)!=-1&&o=="cryptojs"){try{this.md=A.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[i].create()}catch(s){throw"setAlgAndProvider hash alg set fail alg="+i+"/"+s}this.updateString=function(s){this.md.update(s)},this.updateHex=function(s){var a=He.enc.Hex.parse(s);this.md.update(a)},this.digest=function(){var s=this.md.finalize();return s.toString(He.enc.Hex)},this.digestString=function(s){return this.updateString(s),this.digest()},this.digestHex=function(s){return this.updateHex(s),this.digest()}}if(":sha256:".indexOf(i)!=-1&&o=="sjcl"){try{this.md=new sjcl.hash.sha256}catch(s){throw"setAlgAndProvider hash alg set fail alg="+i+"/"+s}this.updateString=function(s){this.md.update(s)},this.updateHex=function(s){var a=sjcl.codec.hex.toBits(s);this.md.update(a)},this.digest=function(){var s=this.md.finalize();return sjcl.codec.hex.fromBits(s)},this.digestString=function(s){return this.updateString(s),this.digest()},this.digestHex=function(s){return this.updateHex(s),this.digest()}}},this.updateString=function(i){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(i){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(i){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(i){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},e!==void 0&&e.alg!==void 0&&(this.algName=e.alg,e.prov===void 0&&(this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))};A.crypto.MessageDigest.getCanonicalAlgName=function(e){return typeof e=="string"&&(e=e.toLowerCase(),e=e.replace(/-/,"")),e};A.crypto.MessageDigest.getHashLength=function(e){var t=A.crypto.MessageDigest,r=t.getCanonicalAlgName(e);if(t.HASHLENGTH[r]===void 0)throw"not supported algorithm: "+e;return t.HASHLENGTH[r]};A.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20};A.crypto.Mac=function(e){var t=null,r=null,n=null,i=null,o=null;this.setAlgAndProvider=function(s,a){if(s=s.toLowerCase(),s==null&&(s="hmacsha1"),s=s.toLowerCase(),s.substr(0,4)!="hmac")throw"setAlgAndProvider unsupported HMAC alg: "+s;a===void 0&&(a=A.crypto.Util.DEFAULTPROVIDER[s]),this.algProv=s+"/"+a;var u=s.substr(4);if(":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(u)!=-1&&a=="cryptojs"){try{var l=A.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[u];this.mac=He.algo.HMAC.create(l,this.pass)}catch(f){throw"setAlgAndProvider hash alg set fail hashAlg="+u+"/"+f}this.updateString=function(f){this.mac.update(f)},this.updateHex=function(f){var m=He.enc.Hex.parse(f);this.mac.update(m)},this.doFinal=function(){var f=this.mac.finalize();return f.toString(He.enc.Hex)},this.doFinalString=function(f){return this.updateString(f),this.doFinal()},this.doFinalHex=function(f){return this.updateHex(f),this.doFinal()}}},this.updateString=function(s){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(s){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(s){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(s){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(s){if(typeof s=="string"){var a=s;(s.length%2==1||!s.match(/^[0-9A-Fa-f]+$/))&&(a=Lo(s)),this.pass=He.enc.Hex.parse(a);return}if(typeof s!="object")throw"KJUR.crypto.Mac unsupported password type: "+s;var a=null;if(s.hex!==void 0){if(s.hex.length%2!=0||!s.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+s.hex;a=s.hex}if(s.utf8!==void 0&&(a=U1(s.utf8)),s.rstr!==void 0&&(a=Lo(s.rstr)),s.b64!==void 0&&(a=Pf(s.b64)),s.b64u!==void 0&&(a=yr(s.b64u)),a==null)throw"KJUR.crypto.Mac unsupported password type: "+s;this.pass=He.enc.Hex.parse(a)},e!==void 0&&(e.pass!==void 0&&this.setPassword(e.pass),e.alg!==void 0&&(this.algName=e.alg,e.prov===void 0&&(this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))};A.crypto.Signature=function(e){var t=null,r=null,n=null,i=null,o=null,s=null,a=null,u=null,l=null,f=null,m=-1,p=null,d=null,v=null,g=null,y=null;if(this._setAlgNames=function(){var w=this.algName.match(/^(.+)with(.+)$/);w&&(this.mdAlgName=w[1].toLowerCase(),this.pubkeyAlgName=w[2].toLowerCase(),this.pubkeyAlgName=="rsaandmgf1"&&this.mdAlgName=="sha"&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(w,E){for(var S="",F=E/4-w.length,_=0;_"u"||!A)&&(A={});(typeof A.crypto>"u"||!A.crypto)&&(A.crypto={});A.crypto.ECDSA=function(e){var t="secp256r1",r=null,n=null,i=null,o=Error,s=oe,a=Wt,u=A.crypto.ECDSA,l=A.crypto.ECParameterDB,f=u.getName,m=ke,p=m.getVbyListEx,d=m.isASN1HEX,v=new Rf,g=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function y(w,E,S,F){for(var _=Math.max(E.bitLength(),F.bitLength()),H=w.add2D(S),V=w.curve.getInfinity(),C=_-1;C>=0;--C)V=V.twice2D(),V.z=s.ONE,E.testBit(C)?F.testBit(C)?V=V.add2D(H):V=V.add2D(w):F.testBit(C)&&(V=V.add2D(S));return V}this.getBigRandom=function(w){return new s(w.bitLength(),v).mod(w.subtract(s.ONE)).add(s.ONE)},this.setNamedCurve=function(w){this.ecparams=l.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 E=this.ecparams.keycharlen;if(w.length!==2+E*2)throw"malformed public key hex length";var S={};return S.x=w.substr(2,E),S.y=w.substr(2+E),S},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,E=this.getBigRandom(w),S=this.ecparams.keycharlen,F=("0000000000"+E.toString(16)).slice(-S);this.setPrivateKeyHex(F);var _=this.generatePublicKeyHex();return{ecprvhex:F,ecpubhex:_}},this.generatePublicKeyHex=function(){var w=new s(this.prvKeyHex,16),E=this.ecparams.G.multiply(w),S=E.getX().toBigInteger(),F=E.getY().toBigInteger(),_=this.ecparams.keycharlen,H=("0000000000"+S.toString(16)).slice(-_),V=("0000000000"+F.toString(16)).slice(-_),C="04"+H+V;return this.setPublicKeyHex(C),C},this.signWithMessageHash=function(w){return this.signHex(w,this.prvKeyHex)},this.signHex=function(w,E){var S=new s(E,16),F=this.ecparams.n,_=new s(w.substring(0,this.ecparams.keycharlen),16);do var H=this.getBigRandom(F),V=this.ecparams.G,C=V.multiply(H),I=C.getX().toBigInteger().mod(F);while(I.compareTo(s.ZERO)<=0);var L=H.modInverse(F).multiply(_.add(S.multiply(I))).mod(F);return u.biRSSigToASN1Sig(I,L)},this.sign=function(w,E){var S=E,F=this.ecparams.n,_=s.fromByteArrayUnsigned(w);do var H=this.getBigRandom(F),V=this.ecparams.G,C=V.multiply(H),I=C.getX().toBigInteger().mod(F);while(I.compareTo(oe.ZERO)<=0);var L=H.modInverse(F).multiply(_.add(S.multiply(I))).mod(F);return this.serializeSig(I,L)},this.verifyWithMessageHash=function(w,E){return this.verifyHex(w,E,this.pubKeyHex)},this.verifyHex=function(w,E,S){try{var F,_,H=u.parseSigHex(E);F=H.r,_=H.s;var V=a.decodeFromHex(this.ecparams.curve,S),C=new s(w.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(C,F,_,V)}catch{return!1}},this.verify=function(w,E,S){var F,_;if(Bitcoin.Util.isArray(E)){var H=this.parseSig(E);F=H.r,_=H.s}else if(typeof E=="object"&&E.r&&E.s)F=E.r,_=E.s;else throw"Invalid value for signature";var V;if(S instanceof Wt)V=S;else if(Bitcoin.Util.isArray(S))V=a.decodeFrom(this.ecparams.curve,S);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var C=s.fromByteArrayUnsigned(w);return this.verifyRaw(C,F,_,V)},this.verifyRaw=function(w,E,S,F){var _=this.ecparams.n,H=this.ecparams.G;if(E.compareTo(s.ONE)<0||E.compareTo(_)>=0||S.compareTo(s.ONE)<0||S.compareTo(_)>=0)return!1;var V=S.modInverse(_),C=w.multiply(V).mod(_),I=E.multiply(V).mod(_),L=H.multiply(C).add(F.multiply(I)),R=L.getX().toBigInteger().mod(_);return R.equals(E)},this.serializeSig=function(w,E){var S=w.toByteArraySigned(),F=E.toByteArraySigned(),_=[];return _.push(2),_.push(S.length),_=_.concat(S),_.push(2),_.push(F.length),_=_.concat(F),_.unshift(_.length),_.unshift(48),_},this.parseSig=function(w){var E;if(w[0]!=48)throw new Error("Signature not a valid DERSequence");if(E=2,w[E]!=2)throw new Error("First element in signature must be a DERInteger");var S=w.slice(E+2,E+2+w[E+1]);if(E+=2+w[E+1],w[E]!=2)throw new Error("Second element in signature must be a DERInteger");var F=w.slice(E+2,E+2+w[E+1]);E+=2+w[E+1];var _=s.fromByteArrayUnsigned(S),H=s.fromByteArrayUnsigned(F);return{r:_,s:H}},this.parseSigCompact=function(w){if(w.length!==65)throw"Signature has the wrong length";var E=w[0]-27;if(E<0||E>7)throw"Invalid signature type";var S=this.ecparams.n,F=s.fromByteArrayUnsigned(w.slice(1,33)).mod(S),_=s.fromByteArrayUnsigned(w.slice(33,65)).mod(S);return{r:F,s:_,i:E}},this.readPKCS5PrvKeyHex=function(w){if(d(w)===!1)throw new Error("not ASN.1 hex string");var E,S,F;try{E=p(w,0,["[0]",0],"06"),S=p(w,0,[1],"04");try{F=p(w,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=f(E),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(F),this.setPrivateKeyHex(S),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(w){if(d(w)===!1)throw new o("not ASN.1 hex string");var E,S,F,_;try{E=p(w,0,[1,0],"06"),S=p(w,0,[1,1],"06"),F=p(w,0,[2,0,1],"04");try{_=p(w,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new o("malformed PKCS#8 plain ECC private key")}if(this.curveName=f(S),this.curveName===void 0)throw new o("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(_),this.setPrivateKeyHex(F),this.isPublic=!1},this.readPKCS8PubKeyHex=function(w){if(d(w)===!1)throw new o("not ASN.1 hex string");var E,S,F;try{E=p(w,0,[0,0],"06"),S=p(w,0,[0,1],"06"),F=p(w,0,[1],"03")}catch{throw new o("malformed PKCS#8 ECC public key")}if(this.curveName=f(S),this.curveName===null)throw new o("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(F)},this.readCertPubKeyHex=function(w,E){if(d(w)===!1)throw new o("not ASN.1 hex string");var S,F;try{S=p(w,0,[0,5,0,1],"06"),F=p(w,0,[0,5,1],"03")}catch{throw new o("malformed X.509 certificate ECC public key")}if(this.curveName=f(S),this.curveName===null)throw new o("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(F)},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))};A.crypto.ECDSA.parseSigHex=function(e){var t=A.crypto.ECDSA.parseSigHexInHexRS(e),r=new oe(t.r,16),n=new oe(t.s,16);return{r,s:n}};A.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=ke,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 o=i[0],s=i[1];if(e.substr(o,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 a=n(e,o),u=n(e,s);return{r:a,s:u}};A.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=A.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};A.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 A.crypto.ECDSA.hexRSSigToASN1Sig(t,r)};A.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new oe(e,16),n=new oe(t,16);return A.crypto.ECDSA.biRSSigToASN1Sig(r,n)};A.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=A.asn1,n=new r.DERInteger({bigint:e}),i=new r.DERInteger({bigint:t}),o=new r.DERSequence({array:[n,i]});return o.tohex()};A.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 A>"u"||!A)&&(A={});(typeof A.crypto>"u"||!A.crypto)&&(A.crypto={});A.crypto.ECParameterDB=new function(){var e={},t={};function r(n){return new oe(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,o,s,a,u,l,f,m,p,d,v){e[n]={};var g=r(o),y=r(s),w=r(a),E=r(u),S=r(l),F=new Ka(g,y,w),_=F.decodePointHex("04"+f+m);e[n].name=n,e[n].keylen=i,e[n].keycharlen=Math.ceil(i/8)*2,e[n].curve=F,e[n].G=_,e[n].n=E,e[n].h=S,e[n].oid=d,e[n].info=v;for(var H=0;H"u"||!A)&&(A={});(typeof A.crypto>"u"||!A.crypto)&&(A.crypto={});A.crypto.DSA=function(){var e=ke,t=e.getVbyList,r=e.getVbyListEx,n=e.isASN1HEX,i=oe,o=oe.ONE,s=function(a,u,l,f){if(a==null||u==null||l==null||f==null)throw new Error("invalid DSA public key");if(o.compareTo(u)>=0||u.compareTo(a)>=0)throw new Error("invalid DSA public key");if(o.compareTo(l)>=0||l.compareTo(a)>=0)throw new Error("invalid DSA public key");if(o.compareTo(f)>=0||f.compareTo(a)>=0)throw new Error("invalid DSA public key");if(l.modPow(u,a).compareTo(o)!=0)throw new Error("invalid DSA public key")};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,u,l,f,m){this.isPrivate=!0,this.p=a,this.q=u,this.g=l,this.y=f,this.x=m},this.setPrivateHex=function(a,u,l,f,m){var p,d,v,g,y;p=new oe(a,16),d=new oe(u,16),v=new oe(l,16),typeof f=="string"&&f.length>1?g=new oe(f,16):g=null,y=new oe(m,16),this.setPrivate(p,d,v,g,y)},this.setPublic=function(a,u,l,f){s(a,u,l,f),this.isPublic=!0,this.p=a,this.q=u,this.g=l,this.y=f,this.x=null},this.setPublicHex=function(a,u,l,f){var m,p,d,v;m=new oe(a,16),p=new oe(u,16),d=new oe(l,16),v=new oe(f,16),this.setPublic(m,p,d,v)},this.signWithMessageHash=function(a){var u=this.p,l=this.q,f=this.g,m=this.y,p=this.x,d=a.substr(0,l.bitLength()/4),v=new oe(d,16),g,y,w;do g=A.crypto.Util.getRandomBigIntegerMinToMax(oe.ONE.add(oe.ONE),l.subtract(oe.ONE)),y=f.modPow(g,u).mod(l),w=g.modInverse(l).multiply(v.add(p.multiply(y))).mod(l);while(y.compareTo(oe.ZERO)==0||w.compareTo(oe.ZERO)==0);var E=A.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:y}},{int:{bigint:w}}]});return E},this.verifyWithMessageHash=function(a,u){var l=this.p,f=this.q,m=this.g,p=this.y,d=this.parseASN1Signature(u),v=d[0],g=d[1],y=a.substr(0,f.bitLength()/4),w=new oe(y,16);if(oe.ZERO.compareTo(v)>=0||v.compareTo(f)>=0||oe.ZERO.compareTo(g)>=0||g.compareTo(f)>=0)throw"invalid DSA signature";var E=g.modInverse(f),S=w.multiply(E).mod(f),F=v.multiply(E).mod(f),_=m.modPow(S,l).multiply(p.modPow(F,l)).mod(l).mod(f);return _.compareTo(v)==0},this.parseASN1Signature=function(a){try{var u=new i(r(a,0,[0],"02"),16),l=new i(r(a,0,[1],"02"),16);return[u,l]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(a){var u,l,f,m,p;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[1],"02"),l=r(a,0,[2],"02"),f=r(a,0,[3],"02"),m=r(a,0,[4],"02"),p=r(a,0,[5],"02")}catch{throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(u,l,f,m,p)},this.readPKCS8PrvKeyHex=function(a){var u,l,f,m;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[1,1,0],"02"),l=r(a,0,[1,1,1],"02"),f=r(a,0,[1,1,2],"02"),m=r(a,0,[2,0],"02")}catch{throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(u,l,f,null,m)},this.readPKCS8PubKeyHex=function(a){var u,l,f,m;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[0,1,0],"02"),l=r(a,0,[0,1,1],"02"),f=r(a,0,[0,1,2],"02"),m=r(a,0,[1,0],"02")}catch{throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(u,l,f,m)},this.readCertPubKeyHex=function(a,u){var l,f,m,p;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{l=r(a,0,[0,5,0,1,0],"02"),f=r(a,0,[0,5,0,1,1],"02"),m=r(a,0,[0,5,0,1,2],"02"),p=r(a,0,[0,5,1,0],"02")}catch{throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(l,f,m,p)}};var Tt=function(){var e=function(g,y,w){return n(He.AES,g,y,w)},t=function(g,y,w){return n(He.TripleDES,g,y,w)},r=function(g,y,w){return n(He.DES,g,y,w)},n=function(g,y,w,E){var S=He.enc.Hex.parse(y),F=He.enc.Hex.parse(w),_=He.enc.Hex.parse(E),H={};H.key=F,H.iv=_,H.ciphertext=S;var V=g.decrypt(H,F,{iv:_});return He.enc.Hex.stringify(V)},i=function(g,y,w){return a(He.AES,g,y,w)},o=function(g,y,w){return a(He.TripleDES,g,y,w)},s=function(g,y,w){return a(He.DES,g,y,w)},a=function(g,y,w,E){var S=He.enc.Hex.parse(y),F=He.enc.Hex.parse(w),_=He.enc.Hex.parse(E),H=g.encrypt(S,F,{iv:_}),V=He.enc.Hex.parse(H.toString()),C=He.enc.Base64.stringify(V);return C},u={"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:o,keylen:24,ivlen:8},"DES-CBC":{proc:r,eproc:s,keylen:8,ivlen:8}},l=function(g){return u[g].proc},f=function(g){var y=He.lib.WordArray.random(g),w=He.enc.Hex.stringify(y);return w},m=function(g){var y={},w=g.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));w&&(y.cipher=w[1],y.ivsalt=w[2]);var E=g.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));E&&(y.type=E[1]);var S=-1,F=0;g.indexOf(`\r \r `)!=-1&&(S=g.indexOf(`\r \r `),F=2),g.indexOf(` `)!=-1&&(S=g.indexOf(` `),F=1);var _=g.indexOf("-----END");if(S!=-1&&_!=-1){var H=g.substring(S+F*2,_-F);H=H.replace(/\s+/g,""),y.data=H}return y},p=function(g,y,w){for(var E=w.substring(0,16),S=He.enc.Hex.parse(E),F=He.enc.Utf8.parse(y),_=u[g].keylen+u[g].ivlen,H="",V=null;;){var C=He.algo.MD5.create();if(V!=null&&C.update(V),C.update(F),C.update(S),V=C.finalize(),H=H+He.enc.Hex.stringify(V),H.length>=_*2)break}var I={};return I.keyhex=H.substr(0,u[g].keylen*2),I.ivhex=H.substr(u[g].keylen*2,u[g].ivlen*2),I},d=function(g,y,w,E){var S=He.enc.Base64.parse(g),F=He.enc.Hex.stringify(S),_=u[y].proc,H=_(F,w,E);return H},v=function(g,y,w,E){var S=u[y].eproc,F=S(g,w,E);return F};return{version:"1.0.0",parsePKCS5PEM:function(g){return m(g)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(g,y,w){return p(g,y,w)},decryptKeyB64:function(g,y,w,E){return d(g,y,w,E)},getDecryptedKeyHex:function(g,y){var w=m(g),E=w.type,S=w.cipher,F=w.ivsalt,_=w.data,H=p(S,y,F),V=H.keyhex,C=d(_,S,V,F);return C},getEncryptedPKCS5PEMFromPrvKeyHex:function(g,y,w,E,S){var L="";if((typeof E>"u"||E==null)&&(E="AES-256-CBC"),typeof u[E]>"u")throw new Error("KEYUTIL unsupported algorithm: "+E);if(typeof S>"u"||S==null){var F=u[E].ivlen,_=f(F);S=_.toUpperCase()}var H=p(E,w,S),V=H.keyhex,C=v(y,E,V,S),I=C.replace(/(.{64})/g,`$1\r `),L="-----BEGIN "+g+` PRIVATE KEY-----\r `;return L+=`Proc-Type: 4,ENCRYPTED\r `,L+="DEK-Info: "+E+","+S+`\r `,L+=`\r `,L+=I,L+=`\r -----END `+g+` PRIVATE KEY-----\r `,L},getEncryptedPKCS8PEM:function(g,y,w){var E=this.getEncryptedPKCS8Hex(g,y,w);return zn(E,"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(g,y,w){var E;w==null||w==null?E={}:E=JSON.parse(JSON.stringify(w)),E.plain=g,this.initPBES2Param(E),this.encryptPBES2Param(E,y);var S=this.generatePBES2ASN1Param(E);return A.asn1.ASN1Util.newObject(S).tohex()},initPBES2Param:function(g){if(ur(g,"encalg")==null&&(g.encalg="aes256-CBC"),ur(g,"iter")==null&&(g.iter=2048),ur(g,"prf")==null&&(g.prf="hmacWithSHA256"),ur(g,"salt")==null&&(g.salt=He.enc.Hex.stringify(He.lib.WordArray.random(8))),ur(g,"enciv")==null){var y;g.encalg=="des-EDE3-CBC"&&(y=8),g.encalg=="aes128-CBC"&&(y=16),g.encalg=="aes256-CBC"&&(y=16),g.enciv=He.enc.Hex.stringify(He.lib.WordArray.random(y))}},encryptPBES2Param:function(g,y){var w=Tt.getDKFromPBES2Param(g,y);try{var E=A.crypto.Cipher.encrypt(g.plain,w,g.encalg,{iv:g.enciv})}catch{throw new Error("encrypt error: "+g.plain+" "+w+" "+g.encalg+" "+g.enciv)}g.enc=E},generatePBES2ASN1Param:function(g){var y={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:g.salt}},{int:{hex:s_(g.iter)}}]}]},{seq:[{oid:g.encalg},{octstr:{hex:g.enciv}}]}]}]},{octstr:{hex:g.enc}}]};return g.prf!="hmacWithSHA1"&&y.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:g.prf},{null:""}]}),y},parseHexOfEncryptedPKCS8:function(g){var y=ke,w=y.getChildIdx,E=y.getV,S={},F=w(g,0);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+F.length);S.ciphertext=E(g,F[1]);var _=w(g,F[0]);if(_.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+_.length);if(E(g,_[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var H=w(g,_[1]);if(_.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+H.length);var V=w(g,H[1]);if(V.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+V.length);if(E(g,V[0])!="2a864886f70d0307")throw"this only supports TripleDES";S.encryptionSchemeAlg="TripleDES",S.encryptionSchemeIV=E(g,V[1]);var C=w(g,H[0]);if(C.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+C.length);if(E(g,C[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var I=w(g,C[1]);if(I.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+I.length);S.pbkdf2Salt=E(g,I[0]);var L=E(g,I[1]);try{S.pbkdf2Iter=parseInt(L,16)}catch{throw new Error("malformed format pbkdf2Iter: "+L)}return S},getPBKDF2KeyHexFromParam:function(g,y){var w=He.enc.Hex.parse(g.pbkdf2Salt),E=g.pbkdf2Iter,S=He.PBKDF2(y,w,{keySize:192/32,iterations:E}),F=He.enc.Hex.stringify(S);return F},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(g,y){var w=_r(g,"ENCRYPTED PRIVATE KEY"),E=this.parseHexOfEncryptedPKCS8(w),S=Tt.getPBKDF2KeyHexFromParam(E,y),F={};F.ciphertext=He.enc.Hex.parse(E.ciphertext);var _=He.enc.Hex.parse(S),H=He.enc.Hex.parse(E.encryptionSchemeIV),V=He.TripleDES.decrypt(F,_,{iv:H}),C=He.enc.Hex.stringify(V);return C},parsePBES2:function(g){var y=ke.parse(g);if(ur(y,"seq.0.seq.0.oid")!="pkcs5PBES2"||ur(y,"seq.0.seq.1.seq.0.seq.0.oid")!="pkcs5PBKDF2")throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var w=ur(y,"seq.0.seq.1.seq.0.seq.1.seq");if(w==null)throw new Error("PBKDF2 parameter not found");var E=ur(w,"0.octstr.hex"),S=ur(w,"1.int.hex"),F=ur(w,"2.seq.0.oid","hmacWithSHA1"),_=-1;try{_=parseInt(S,16)}catch{throw new Error("iter not proper value")}var H=ur(y,"seq.0.seq.1.seq.1.seq.0.oid"),V=ur(y,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),C=ur(y,"seq.1.octstr.hex");if(H==null||V==null||C==null)throw new Error("encalg, enciv or enc is undefined");var I={salt:E,iter:_,prf:F,encalg:H,enciv:V,enc:C};return I},getDKFromPBES2Param:function(g,y){var w={hmacWithSHA1:He.algo.SHA1,hmacWithSHA224:He.algo.SHA224,hmacWithSHA256:He.algo.SHA256,hmacWithSHA384:He.algo.SHA384,hmacWithSHA512:He.algo.SHA512},E={"des-EDE3-CBC":192/32,"aes128-CBC":128/32,"aes256-CBC":256/32},S=w[g.prf];if(S==null)throw new Error("unsupported prf");var F=E[g.encalg];if(F==null)throw new Error("unsupported encalg");var _=He.enc.Hex.parse(g.salt),H=g.iter;try{var V=He.PBKDF2(y,_,{keySize:F,iterations:H,hasher:S});return He.enc.Hex.stringify(V)}catch(C){throw new Error("PBKDF2 error: "+C+" "+JSON.stringify(g)+" "+y)}},getPlainHexFromEncryptedPKCS8PEM:function(g,y){if(g.indexOf("BEGIN ENCRYPTED PRIVATE KEY")==-1)throw new Error("not Encrypted PKCS#8 PEM string");var w=_r(g),E;try{E=Tt.parsePBES2(w)}catch(F){throw new Error("malformed PBES2 format: "+F.message)}var S=Tt.getDKFromPBES2Param(E,y);return A.crypto.Cipher.decrypt(E.enc,S,E.encalg,{iv:E.enciv})},getKeyFromEncryptedPKCS8PEM:function(g,y){var w=this.getPlainHexFromEncryptedPKCS8PEM(g,y),E=this.getKeyFromPlainPrivatePKCS8Hex(w);return E},parsePlainPrivatePKCS8Hex:function(g){var y=ke,w=y.getChildIdx,E=y.getV,S={};if(S.algparam=null,g.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var F=w(g,0);if(F.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(g.substr(F[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var _=w(g,F[1]);if(_.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(g.substr(_[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(S.algoid=E(g,_[0]),g.substr(_[1],2)=="06"&&(S.algparam=E(g,_[1])),g.substr(F[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return S.keyidx=y.getVidx(g,F[2]),S},getKeyFromPlainPrivatePKCS8PEM:function(g){var y=_r(g,"PRIVATE KEY"),w=this.getKeyFromPlainPrivatePKCS8Hex(y);return w},getKeyFromPlainPrivatePKCS8Hex:function(g){var y=this.parsePlainPrivatePKCS8Hex(g),w;if(y.algoid=="2a864886f70d010101")w=new gt;else if(y.algoid=="2a8648ce380401")w=new A.crypto.DSA;else if(y.algoid=="2a8648ce3d0201")w=new A.crypto.ECDSA;else throw new Error("unsupported private key algorithm");return w.readPKCS8PrvKeyHex(g),w},_getKeyFromPublicPKCS8Hex:function(g){var y,w=ke.getVbyList(g,0,[0,0],"06");if(w==="2a864886f70d010101")y=new gt;else if(w==="2a8648ce380401")y=new A.crypto.DSA;else if(w==="2a8648ce3d0201")y=new A.crypto.ECDSA;else throw new Error("unsupported PKCS#8 public key hex");return y.readPKCS8PubKeyHex(g),y},parsePublicRawRSAKeyHex:function(g){var y=ke,w=y.getChildIdx,E=y.getV,S={};if(g.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var F=w(g,0);if(F.length!=2)throw new Error("malformed RSA key(code:002)");if(g.substr(F[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(S.n=E(g,F[0]),g.substr(F[1],2)!="02")throw new Error("malformed RSA key(code:004)");return S.e=E(g,F[1]),S},parsePublicPKCS8Hex:function(g){var y=ke,w=y.getChildIdx,E=y.getV,S={};S.algparam=null;var F=w(g,0);if(F.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+F.length);var _=F[0];if(g.substr(_,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var H=w(g,_);if(H.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(g.substr(H[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(S.algoid=E(g,H[0]),g.substr(H[1],2)=="06"?S.algparam=E(g,H[1]):g.substr(H[1],2)=="30"&&(S.algparam={},S.algparam.p=y.getVbyList(g,H[1],[0],"02"),S.algparam.q=y.getVbyList(g,H[1],[1],"02"),S.algparam.g=y.getVbyList(g,H[1],[2],"02")),g.substr(F[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return S.key=E(g,F[1]).substr(2),S}}}();Tt.getKey=function(e,t,r){var n=ke,i=n.getChildIdx,o=n.getV,s=n.getVbyList,a=A.crypto,u=a.ECDSA,l=a.DSA,f=gt,m=_r,p=Tt;if(typeof f<"u"&&e instanceof f||typeof u<"u"&&e instanceof u||typeof l<"u"&&e instanceof l)return e;if(e.curve!==void 0&&e.xy!==void 0&&e.d===void 0)return new u({pub:e.xy,curve:e.curve});if(e.curve!==void 0&&e.d!==void 0)return new u({prv:e.d,curve:e.curve});if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var d=new f;return d.setPublic(e.n,e.e),d}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 d=new f;return d.setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),d}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p===void 0){var d=new f;return d.setPrivate(e.n,e.e,e.d),d}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x===void 0){var d=new l;return d.setPublic(e.p,e.q,e.g,e.y),d}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x!==void 0){var d=new l;return d.setPrivate(e.p,e.q,e.g,e.y,e.x),d}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var d=new f;return d.setPublic(yr(e.n),yr(e.e)),d}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 d=new f;return d.setPrivateEx(yr(e.n),yr(e.e),yr(e.d),yr(e.p),yr(e.q),yr(e.dp),yr(e.dq),yr(e.qi)),d}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var d=new f;return d.setPrivate(yr(e.n),yr(e.e),yr(e.d)),d}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d===void 0){var v=new u({curve:e.crv}),g=v.ecparams.keycharlen,y=("0000000000"+yr(e.x)).slice(-g),w=("0000000000"+yr(e.y)).slice(-g),E="04"+y+w;return v.setPublicKeyHex(E),v}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d!==void 0){var v=new u({curve:e.crv}),g=v.ecparams.keycharlen,y=("0000000000"+yr(e.x)).slice(-g),w=("0000000000"+yr(e.y)).slice(-g),E="04"+y+w,S=("0000000000"+yr(e.d)).slice(-g);return v.setPublicKeyHex(E),v.setPrivateKeyHex(S),v}if(r==="pkcs5prv"){var F=e,n=ke,_,d;if(_=i(F,0),_.length===9)d=new f,d.readPKCS5PrvKeyHex(F);else if(_.length===6)d=new l,d.readPKCS5PrvKeyHex(F);else if(_.length>2&&F.substr(_[1],2)==="04")d=new u,d.readPKCS5PrvKeyHex(F);else throw new Error("unsupported PKCS#1/5 hexadecimal key");return d}if(r==="pkcs8prv"){var d=p.getKeyFromPlainPrivatePKCS8Hex(e);return d}if(r==="pkcs8pub")return p._getKeyFromPublicPKCS8Hex(e);if(r==="x509pub")return at.getPublicKeyFromCertHex(e);if(e.indexOf("-END CERTIFICATE-",0)!=-1||e.indexOf("-END X509 CERTIFICATE-",0)!=-1||e.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return at.getPublicKeyFromCertPEM(e);if(e.indexOf("-END PUBLIC KEY-")!=-1){var H=_r(e,"PUBLIC KEY");return p._getKeyFromPublicPKCS8Hex(H)}if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var V=m(e,"RSA PRIVATE KEY");return p.getKey(V,null,"pkcs5prv")}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var C=m(e,"DSA PRIVATE KEY"),I=s(C,0,[1],"02"),L=s(C,0,[2],"02"),R=s(C,0,[3],"02"),k=s(C,0,[4],"02"),M=s(C,0,[5],"02"),d=new l;return d.setPrivate(new oe(I,16),new oe(L,16),new oe(R,16),new oe(k,16),new oe(M,16)),d}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var V=m(e,"EC PRIVATE KEY");return p.getKey(V,null,"pkcs5prv")}if(e.indexOf("-END PRIVATE KEY-")!=-1)return p.getKeyFromPlainPrivatePKCS8PEM(e);if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var N=p.getDecryptedKeyHex(e,t),D=new gt;return D.readPKCS5PrvKeyHex(N),D}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var C=p.getDecryptedKeyHex(e,t),d=s(C,0,[1],"04"),O=s(C,0,[2,0],"06"),q=s(C,0,[3,0],"03").substr(2),J="";if(A.crypto.OID.oidhex2name[O]!==void 0)J=A.crypto.OID.oidhex2name[O];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+O);var v=new u({curve:J});return v.setPublicKeyHex(q),v.setPrivateKeyHex(d),v.isPublic=!1,v}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var C=p.getDecryptedKeyHex(e,t),I=s(C,0,[1],"02"),L=s(C,0,[2],"02"),R=s(C,0,[3],"02"),k=s(C,0,[4],"02"),M=s(C,0,[5],"02"),d=new l;return d.setPrivate(new oe(I,16),new oe(L,16),new oe(R,16),new oe(k,16),new oe(M,16)),d}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return p.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};Tt.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new gt;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var i=new gt,o=n.n.toString(16),s=n.e.toString(16);i.setPublic(o,s),i.isPrivate=!1,i.isPublic=!0;var a={};return a.prvKeyObj=n,a.pubKeyObj=i,a}else if(e=="EC"){var u=t,l=new A.crypto.ECDSA({curve:u}),f=l.generateKeyPairHex(),n=new A.crypto.ECDSA({curve:u});n.setPublicKeyHex(f.ecpubhex),n.setPrivateKeyHex(f.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var i=new A.crypto.ECDSA({curve:u});i.setPublicKeyHex(f.ecpubhex),i.isPrivate=!1,i.isPublic=!0;var a={};return a.prvKeyObj=n,a.pubKeyObj=i,a}else throw new Error("unknown algorithm: "+e)};Tt.getPEM=function(e,t,r,n,i,o){var s=A,a=s.asn1,u=a.DERObjectIdentifier,l=a.DERInteger,f=a.ASN1Util.newObject,m=a.x509,p=m.SubjectPublicKeyInfo,d=s.crypto,v=d.DSA,g=d.ECDSA,y=gt;function w(D){var O=f({seq:[{int:0},{int:{bigint:D.n}},{int:D.e},{int:{bigint:D.d}},{int:{bigint:D.p}},{int:{bigint:D.q}},{int:{bigint:D.dmp1}},{int:{bigint:D.dmq1}},{int:{bigint:D.coeff}}]});return O}function E(D){var O=f({seq:[{int:1},{octstr:{hex:D.prvKeyHex}},{tag:["a0",!0,{oid:{name:D.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+D.pubKeyHex}}]}]});return O}function S(D){var O=f({seq:[{int:0},{int:{bigint:D.p}},{int:{bigint:D.q}},{int:{bigint:D.g}},{int:{bigint:D.y}},{int:{bigint:D.x}}]});return O}if((y!==void 0&&e instanceof y||v!==void 0&&e instanceof v||g!==void 0&&e instanceof g)&&e.isPublic==!0&&(t===void 0||t=="PKCS8PUB")){var F=new p(e),_=F.tohex();return zn(_,"PUBLIC KEY")}if(t=="PKCS1PRV"&&y!==void 0&&e instanceof y&&(r===void 0||r==null)&&e.isPrivate==!0){var F=w(e),_=F.tohex();return zn(_,"RSA PRIVATE KEY")}if(t=="PKCS1PRV"&&g!==void 0&&e instanceof g&&(r===void 0||r==null)&&e.isPrivate==!0){var H=new u({name:e.curveName}),V=H.tohex(),C=E(e),I=C.tohex(),L="";return L+=zn(V,"EC PARAMETERS"),L+=zn(I,"EC PRIVATE KEY"),L}if(t=="PKCS1PRV"&&v!==void 0&&e instanceof v&&(r===void 0||r==null)&&e.isPrivate==!0){var F=S(e),_=F.tohex();return zn(_,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&y!==void 0&&e instanceof y&&r!==void 0&&r!=null&&e.isPrivate==!0){var F=w(e),_=F.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",_,r,n,o)}if(t=="PKCS5PRV"&&g!==void 0&&e instanceof g&&r!==void 0&&r!=null&&e.isPrivate==!0){var F=E(e),_=F.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",_,r,n,o)}if(t=="PKCS5PRV"&&v!==void 0&&e instanceof v&&r!==void 0&&r!=null&&e.isPrivate==!0){var F=S(e),_=F.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",_,r,n,o)}var R=function(D,O){if(typeof O=="string")return Tt.getEncryptedPKCS8PEM(D,O);if(typeof O=="object"&&ur(O,"passcode")!=null){var q=JSON.parse(JSON.stringify(O)),J=q.passcode;return delete q.passcode,Tt.getEncryptedPKCS8PEM(D,J,q)}};if(t=="PKCS8PRV"&&y!=null&&e instanceof y&&e.isPrivate==!0){var k=w(e),M=k.tohex(),F=f({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:M}}]}),_=F.tohex();return r===void 0||r==null?zn(_,"PRIVATE KEY"):R(_,r)}if(t=="PKCS8PRV"&&g!==void 0&&e instanceof g&&e.isPrivate==!0){var N={seq:[{int:1},{octstr:{hex:e.prvKeyHex}}]};typeof e.pubKeyHex=="string"&&N.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]});var k=new f(N),M=k.tohex(),F=f({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:M}}]}),_=F.tohex();return r===void 0||r==null?zn(_,"PRIVATE KEY"):R(_,r)}if(t=="PKCS8PRV"&&v!==void 0&&e instanceof v&&e.isPrivate==!0){var k=new l({bigint:e.x}),M=k.tohex(),F=f({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:M}}]}),_=F.tohex();return r===void 0||r==null?zn(_,"PRIVATE KEY"):R(_,r)}throw new Error("unsupported object nor format")};Tt.getKeyFromCSRPEM=function(e){var t=_r(e,"CERTIFICATE REQUEST"),r=Tt.getKeyFromCSRHex(t);return r};Tt.getKeyFromCSRHex=function(e){var t=Tt.parseCSRHex(e),r=Tt.getKey(t.p8pubkeyhex,null,"pkcs8pub");return r};Tt.parseCSRHex=function(e){var t=ke,r=t.getChildIdx,n=t.getTLV,i={},o=e;if(o.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var s=r(o,0);if(s.length<1)throw new Error("malformed CSR(code:002)");if(o.substr(s[0],2)!="30")throw new Error("malformed CSR(code:003)");var a=r(o,s[0]);if(a.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(o,a[2]),i};Tt.getKeyID=function(e){var t=Tt,r=ke;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=_r(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),o=r.getV(n,i).substring(2);return A.crypto.Util.hashHex(o,"sha1")};Tt.getJWK=function(e,t,r,n,i){var o,s={},a,u=A.crypto.Util.hashHex;if(typeof e=="string")o=Tt.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(a=_r(e));else if(typeof e=="object")e instanceof at?(o=e.getPublicKey(),a=e.hex):o=e;else throw new Error("unsupported keyinfo type");if(o instanceof gt&&o.isPrivate)s.kty="RSA",s.n=Jr(o.n.toString(16)),s.e=Jr(o.e.toString(16)),s.d=Jr(o.d.toString(16)),s.p=Jr(o.p.toString(16)),s.q=Jr(o.q.toString(16)),s.dp=Jr(o.dmp1.toString(16)),s.dq=Jr(o.dmq1.toString(16)),s.qi=Jr(o.coeff.toString(16));else if(o instanceof gt&&o.isPublic)s.kty="RSA",s.n=Jr(o.n.toString(16)),s.e=Jr(o.e.toString(16));else if(o instanceof A.crypto.ECDSA&&o.isPrivate){var l=o.getShortNISTPCurveName();if(l!=="P-256"&&l!=="P-384"&&l!=="P-521")throw new Error("unsupported curve name for JWT: "+l);var f=o.getPublicKeyXYHex();s.kty="EC",s.crv=l,s.x=Jr(f.x),s.y=Jr(f.y),s.d=Jr(o.prvKeyHex)}else if(o instanceof A.crypto.ECDSA&&o.isPublic){var l=o.getShortNISTPCurveName();if(l!=="P-256"&&l!=="P-384"&&l!=="P-521")throw new Error("unsupported curve name for JWT: "+l);var f=o.getPublicKeyXYHex();s.kty="EC",s.crv=l,s.x=Jr(f.x),s.y=Jr(f.y)}if(s.kty==null)throw new Error("unsupported keyinfo");return!o.isPrivate&&t!=!0&&(s.kid=A.jws.JWS.getJWKthumbprint(s)),a!=null&&r!=!0&&(s.x5c=[qa(a)]),a!=null&&n!=!0&&(s.x5t=$f(qa(u(a,"sha1")))),a!=null&&i!=!0&&(s["x5t#S256"]=$f(qa(u(a,"sha256")))),s};Tt.getJWKFromKey=function(e){return Tt.getJWK(e,!0,!0,!0,!0)};gt.getPosArrayOfChildrenFromHex=function(e){return ke.getChildIdx(e,0)};gt.getHexValueArrayOfChildrenFromHex=function(e){var t=ke,r=t.getV,p=gt.getPosArrayOfChildrenFromHex(e),n=r(e,p[0]),i=r(e,p[1]),o=r(e,p[2]),s=r(e,p[3]),a=r(e,p[4]),u=r(e,p[5]),l=r(e,p[6]),f=r(e,p[7]),m=r(e,p[8]),p=new Array;return p.push(n,i,o,s,a,u,l,f,m),p};gt.prototype.readPrivateKeyFromPEMString=function(e){var t=_r(e),r=gt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};gt.prototype.readPKCS5PrvKeyHex=function(e){var t=gt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};gt.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,o,s,a,u,l=ke,f=l.getVbyListEx;if(l.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");try{t=f(e,0,[2,0,1],"02"),r=f(e,0,[2,0,2],"02"),n=f(e,0,[2,0,3],"02"),i=f(e,0,[2,0,4],"02"),o=f(e,0,[2,0,5],"02"),s=f(e,0,[2,0,6],"02"),a=f(e,0,[2,0,7],"02"),u=f(e,0,[2,0,8],"02")}catch{throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,i,o,s,a,u)};gt.prototype.readPKCS5PubKeyHex=function(e){var t=ke,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]),o=r(e,n[1]);this.setPublic(i,o)};gt.prototype.readPKCS8PubKeyHex=function(e){var t=ke;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)};gt.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new at,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var Hse=new RegExp("[^0-9a-f]","gi");function u_(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}gt.prototype.signPSS=function(e,t,r){var n=function(o){return A.crypto.Util.hashHex(o,t)},i=n(Lo(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(i,t,r)};gt.prototype.signWithMessageHashPSS=function(e,t,r){var n=Ks(e),i=n.length,o=this.n.bitLength()-1,s=Math.ceil(o/8),a,u=function(y){return A.crypto.Util.hashHex(y,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&&(l=new Array(r),new Rf().nextBytes(l),l=String.fromCharCode.apply(String,l));var f=Ks(u(Lo("\0\0\0\0\0\0\0\0"+n+l))),m=[];for(a=0;a>8*s-o&255;for(v[0]&=~g,a=0;an)return!1;var i=this.doPublic(r),o=i.toString(16);if(o.length+3!=n/4)return!1;var s=o.replace(/^1f+00/,""),a=l_(s);if(a.length==0)return!1;var u=a[0],l=a[1],f=function(p){return A.crypto.Util.hashString(p,u)},m=f(e);return l==m};gt.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=js(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),i=n.toString(16).replace(/^1f+00/,""),o=l_(i);if(o.length==0)return!1;var s=o[0],a=o[1];return a==e};gt.prototype.verifyPSS=function(e,t,r,n){var i=function(s){return A.crypto.Util.hashHex(s,r)},o=i(Lo(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(o,t,r,n)};gt.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=new oe(t,16),o=function(E){return A.crypto.Util.hashHex(E,r)},s=Ks(e),a=s.length,u=this.n.bitLength()-1,l=Math.ceil(u/8),f;if(n===-1||n===void 0)n=a;else if(n===-2)n=l-a-2;else if(n<-2)throw new Error("invalid salt length");if(l>8*l-u&255;if(p.charCodeAt(0)&v)throw new Error("bits beyond keysize not zero");var g=c_(d,p.length,o),y=[];for(f=0;f0?I:void 0}catch{return}},this._asn1ToNoticeRef=function(C){try{for(var I={},L=ur(C,"seq"),R=0;R0?I:void 0}catch{return}},this._asn1ToNoticeNum=function(C){try{for(var I=ur(C,"seq"),L=[],R=0;R1){var M=s(C,k[1]),N=this.getGeneralName(M);N.uri!=null&&(R.uri=N.uri)}if(k.length>2){var D=s(C,k[2]);D=="0101ff"&&(R.reqauth=!0),D=="010100"&&(R.reqauth=!1)}return R},this.getExtSubjectDirectoryAttributes=function(C,I){if(C===void 0&&I===void 0){var L=this.getExtInfo("subjectDirectoryAttributes");if(L===void 0)return;C=s(this.hex,L.vidx),I=L.critical}var R={extname:"subjectDirectoryAttributes"};I&&(R.critical=!0);try{for(var k=o(C),M=[],N=0;N0&&(I.ext=this.getExtParamArray()),I.sighex=this.getSignatureValueHex(),C.tbshex==!0&&(I.tbshex=l(this.hex,0,[0])),C.nodnarray==!0&&(delete I.issuer.array,delete I.subject.array),I},this.getExtParamArray=function(C){if(C==null){var I=p(this.hex,0,[0,"[3]"]);I!=-1&&(C=f(this.hex,0,[0,"[3]",0],"30"))}for(var L=[],R=r(C,0),k=0;k"u"||!A)&&(A={});(typeof A.jws>"u"||!A.jws)&&(A.jws={});A.jws.JWS=function(){var e=A,t=e.jws.JWS,r=t.isSafeJSONString;this.parseJWS=function(n,i){if(!(this.parsedJWS!==void 0&&(i||this.parsedJWS.sigvalH!==void 0))){var o=n.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(o==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=o[1],a=o[2],u=o[3],l=s+"."+a;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=a,this.parsedJWS.sigvalB64U=u,this.parsedJWS.si=l,!i){var f=yr(u),m=js(f,16);this.parsedJWS.sigvalH=f,this.parsedJWS.sigvalBI=m}var p=Wi(s),d=Wi(a);if(this.parsedJWS.headS=p,this.parsedJWS.payloadS=d,!r(p,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+p}}};A.jws.JWS.sign=function(e,t,r,n,i){var o=A,s=o.jws,a=s.JWS,u=a.readSafeJSONString,l=a.isSafeJSONString,f=o.crypto,m=f.ECDSA,p=f.Mac,d=f.Signature,v=JSON,g,y,w;if(typeof t!="string"&&typeof t!="object")throw"spHeader must be JSON string or object: "+t;if(typeof t=="object"&&(y=t,g=v.stringify(y)),typeof t=="string"){if(g=t,!l(g))throw"JWS Head is not safe JSON string: "+g;y=u(g)}if(w=r,typeof r=="object"&&(w=v.stringify(r)),(e==""||e==null)&&y.alg!==void 0&&(e=y.alg),e!=""&&e!=null&&y.alg===void 0&&(y.alg=e,g=v.stringify(y)),e!==y.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+y.alg;var E=null;if(a.jwsalg2sigalg[e]===void 0)throw"unsupported alg name: "+e;E=a.jwsalg2sigalg[e];var S=Id(g),F=Id(w),_=S+"."+F,H="";if(E.substr(0,4)=="Hmac"){if(n===void 0)throw"mac key shall be specified for HS* alg";var V=new p({alg:E,prov:"cryptojs",pass:n});V.updateString(_),H=V.doFinal()}else if(E.indexOf("withECDSA")!=-1){var C=new d({alg:E});C.init(n,i),C.updateString(_);var I=C.sign();H=A.crypto.ECDSA.asn1SigToConcatSig(I)}else if(E!="none"){var C=new d({alg:E});C.init(n,i),C.updateString(_),H=C.sign()}var L=Jr(H);return _+"."+L};A.jws.JWS.verify=function(e,t,r){var n=A,i=n.jws,o=i.JWS,s=o.readSafeJSONString,a=n.crypto,u=a.ECDSA,l=a.Mac,f=a.Signature,m;if(typeof gt!==void 0&&(m=gt),!Iy(e))return!1;var p=e.split(".");if(p.length!==3)return!1;var d=p[0],v=p[1],g=d+"."+v,y=yr(p[2]),w=s(Wi(p[0])),E=null,S=null;if(w.alg===void 0)throw"algorithm not specified in header";if(E=w.alg,S=E.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var F=":"+r.join(":")+":";if(F.indexOf(":"+E+":")==-1)throw"algorithm '"+E+"' not accepted in the list"}if(E!="none"&&t===null)throw"key shall be specified to verify.";if(typeof t=="string"&&t.indexOf("-----BEGIN ")!=-1&&(t=Tt.getKey(t)),(S=="RS"||S=="PS")&&!(t instanceof m))throw"key shall be a RSAKey obj for RS* and PS* algs";if(S=="ES"&&!(t instanceof u))throw"key shall be a ECDSA obj for ES* algs";E=="none";var _=null;if(o.jwsalg2sigalg[w.alg]===void 0)throw new Error("unsupported alg name: "+E);if(_=o.jwsalg2sigalg[E],w.crit!==void 0){if(!Array.isArray(w.crit)||w.crit.length===0)throw new Error("wrong critical header");for(var H=0;H"u"||!A)&&(A={});(typeof A.jws>"u"||!A.jws)&&(A.jws={});A.jws.JWSJS=function(){var e=A,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 o=i.split(".");if(o.length!=3)throw"malformed input JWS";this.aHeader.push(o[0]),this.sPayload=o[1],this.aSignature.push(o[2])},this.addSignature=function(i,o,s,a){if(this.sPayload===void 0||this.sPayload===null)throw"there's no JSON-JS signature to add.";var u=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var l=A.jws.JWS.sign(i,o,this.sPayload,s,a),f=l.split("."),m=f[0],p=f[2];this.aHeader.push(f[0]),this.aSignature.push(f[2])}catch(d){throw this.aHeader.length>u&&this.aHeader.pop(),this.aSignature.length>u&&this.aSignature.pop(),"addSignature failed: "+d}},this.verifyAll=function(i){if(this.aHeader.length!==i.length||this.aSignature.length!==i.length)return!1;for(var o=0;o0)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}};Ne.SecureRandom=Rf;Ne.rng_seed_time=Cy;Ne.BigInteger=oe;Ne.RSAKey=gt;Ne.ECDSA=A.crypto.ECDSA;Ne.DSA=A.crypto.DSA;Ne.Signature=A.crypto.Signature;Ne.MessageDigest=A.crypto.MessageDigest;Ne.Mac=A.crypto.Mac;Ne.KEYUTIL=Tt;Ne.ASN1HEX=ke;Ne.X509=at;Ne.X509CRL=cK;Ne.CryptoJS=He;Ne.b64tohex=Pf;Ne.b64toBA=q8;Ne.ECFieldElementFp=Zr;Ne.ECPointFp=Wt;Ne.ECCurveFp=Ka;Ne.stoBA=W8;Ne.BAtos=X8;Ne.BAtohex=L1;Ne.stohex=qs;Ne.stob64=qq;Ne.stob64u=Kq;Ne.b64utos=Vq;Ne.b64tob64u=$f;Ne.b64utob64=Pd;Ne.hex2b64=qa;Ne.hextob64u=Jr;Ne.b64utohex=yr;Ne.utf8tob64u=Id;Ne.b64utoutf8=Wi;Ne.utf8tob64=zq;Ne.b64toutf8=Gq;Ne.utf8tohex=U1;Ne.hextoutf8=rr;Ne.hextorstr=Ks;Ne.rstrtohex=Lo;Ne.hextob64=_y;Ne.hextob64nl=Xq;Ne.b64nltohex=J8;Ne.hextopem=zn;Ne.pemtohex=_r;Ne.hextoArrayBuffer=Qq;Ne.ArrayBuffertohex=eK;Ne.zulutomsec=Dy;Ne.msectozulu=tK;Ne.zulutosec=Z8;Ne.zulutodate=rK;Ne.datetozulu=nK;Ne.uricmptohex=M1;Ne.hextouricmp=j1;Ne.ipv6tohex=wy;Ne.hextoipv6=yy;Ne.hextoip=T1;Ne.iptohex=Fy;Ne.ucs2hextoutf8=By;Ne.encodeURIComponentAll=q1;Ne.newline_toUnix=sK;Ne.newline_toDos=iK;Ne.hextoposhex=Ey;Ne.intarystrtohex=oK;Ne.strdiffidx=aK;Ne.oidtohex=n_;Ne.hextooid=K1;Ne.strpad=R1;Ne.bitstrtoint=i_;Ne.inttobitstr=o_;Ne.bitstrtobinstr=a_;Ne.binstrtobitstr=uK;Ne.isBase64URLDot=Iy;Ne.namearraytobinstr=k1;Ne.extendClass=_e;Ne.foldnl=H1;Ne.b64topem=Jq;Ne.pemtob64=Zq;Ne.timeogen=Q8;Ne.aryval=ur;Ne.inttohex=s_;Ne.twoscompl=xd;Ne.timingSafeEqual=t_;Ne.timingSafeEqualImpl=r_;Ne.KJUR=A;Ne.crypto=A.crypto;Ne.asn1=A.asn1;Ne.jws=A.jws;Ne.lang=A.lang;Ne.VERSION=wM;Ne.VERSION_FULL=yM});var cE=Ce(Gf=>{"use strict";var Xfe=P(x());Object.defineProperty(Gf,"__esModule",{value:!0});Gf.isCorrect=Gf.isInSubnet=void 0;function eV(e){return this.subnetMask{"use strict";var Zfe=P(x());Object.defineProperty(Vo,"__esModule",{value:!0});Vo.RE_SUBNET_STRING=Vo.RE_ADDRESS=Vo.GROUPS=Vo.BITS=void 0;Vo.BITS=32;Vo.GROUPS=4;Vo.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;Vo.RE_SUBNET_STRING=/\/\d{1,2}$/});var $m=Ce(Im=>{"use strict";var ehe=P(x());Object.defineProperty(Im,"__esModule",{value:!0});Im.AddressError=void 0;var fE=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};Im.AddressError=fE});var hE=Ce((Pm,uD)=>{var the=P(x());(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n(j,G,Q){j!=null&&(typeof j=="number"?this.fromNumber(j,G,Q):G==null&&typeof j!="string"?this.fromString(j,256):this.fromString(j,G))}function i(){return new n(null)}function o(j,G,Q,ae,Be,xe){for(;--xe>=0;){var Me=G*this[j++]+Q[ae]+Be;Be=Math.floor(Me/67108864),Q[ae++]=Me&67108863}return Be}function s(j,G,Q,ae,Be,xe){for(var Me=G&32767,Ve=G>>15;--xe>=0;){var sr=this[j]&32767,Br=this[j++]>>15,Mn=Ve*sr+Br*Me;sr=Me*sr+((Mn&32767)<<15)+Q[ae]+(Be&1073741823),Be=(sr>>>30)+(Mn>>>15)+Ve*Br+(Be>>>30),Q[ae++]=sr&1073741823}return Be}function a(j,G,Q,ae,Be,xe){for(var Me=G&16383,Ve=G>>14;--xe>=0;){var sr=this[j]&16383,Br=this[j++]>>14,Mn=Ve*sr+Br*Me;sr=Me*sr+((Mn&16383)<<14)+Q[ae]+Be,Be=(sr>>28)+(Mn>>14)+Ve*Br,Q[ae++]=sr&268435455}return Be}var u=typeof navigator<"u";u&&r&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=s,e=30):u&&r&&navigator.appName!="Netscape"?(n.prototype.am=o,e=26):(n.prototype.am=a,e=28),n.prototype.DB=e,n.prototype.DM=(1<=0;--G)j[G]=this[G];j.t=this.t,j.s=this.s}function w(j){this.t=1,this.s=j<0?-1:0,j>0?this[0]=j:j<-1?this[0]=j+this.DV:this.t=0}function E(j){var G=i();return G.fromInt(j),G}function S(j,G){var Q;if(G==16)Q=4;else if(G==8)Q=3;else if(G==256)Q=8;else if(G==2)Q=1;else if(G==32)Q=5;else if(G==4)Q=2;else{this.fromRadix(j,G);return}this.t=0,this.s=0;for(var ae=j.length,Be=!1,xe=0;--ae>=0;){var Me=Q==8?j[ae]&255:g(j,ae);if(Me<0){j.charAt(ae)=="-"&&(Be=!0);continue}Be=!1,xe==0?this[this.t++]=Me:xe+Q>this.DB?(this[this.t-1]|=(Me&(1<>this.DB-xe):this[this.t-1]|=Me<=this.DB&&(xe-=this.DB)}Q==8&&j[0]&128&&(this.s=-1,xe>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==j;)--this.t}function _(j){if(this.s<0)return"-"+this.negate().toString(j);var G;if(j==16)G=4;else if(j==8)G=3;else if(j==2)G=1;else if(j==32)G=5;else if(j==4)G=2;else return this.toRadix(j);var Q=(1<0)for(Ve>Ve)>0&&(Be=!0,xe=v(ae));Me>=0;)Ve>(Ve+=this.DB-G)):(ae=this[Me]>>(Ve-=G)&Q,Ve<=0&&(Ve+=this.DB,--Me)),ae>0&&(Be=!0),Be&&(xe+=v(ae));return Be?xe:"0"}function H(){var j=i();return n.ZERO.subTo(this,j),j}function V(){return this.s<0?this.negate():this}function C(j){var G=this.s-j.s;if(G!=0)return G;var Q=this.t;if(G=Q-j.t,G!=0)return this.s<0?-G:G;for(;--Q>=0;)if((G=this[Q]-j[Q])!=0)return G;return 0}function I(j){var G=1,Q;return(Q=j>>>16)!=0&&(j=Q,G+=16),(Q=j>>8)!=0&&(j=Q,G+=8),(Q=j>>4)!=0&&(j=Q,G+=4),(Q=j>>2)!=0&&(j=Q,G+=2),(Q=j>>1)!=0&&(j=Q,G+=1),G}function L(){return this.t<=0?0:this.DB*(this.t-1)+I(this[this.t-1]^this.s&this.DM)}function R(j,G){var Q;for(Q=this.t-1;Q>=0;--Q)G[Q+j]=this[Q];for(Q=j-1;Q>=0;--Q)G[Q]=0;G.t=this.t+j,G.s=this.s}function k(j,G){for(var Q=j;Q=0;--Ve)G[Ve+xe+1]=this[Ve]>>ae|Me,Me=(this[Ve]&Be)<=0;--Ve)G[Ve]=0;G[xe]=Me,G.t=this.t+xe+1,G.s=this.s,G.clamp()}function N(j,G){G.s=this.s;var Q=Math.floor(j/this.DB);if(Q>=this.t){G.t=0;return}var ae=j%this.DB,Be=this.DB-ae,xe=(1<>ae;for(var Me=Q+1;Me>ae;ae>0&&(G[this.t-Q-1]|=(this.s&xe)<>=this.DB;if(j.t>=this.DB;ae+=this.s}else{for(ae+=this.s;Q>=this.DB;ae-=j.s}G.s=ae<0?-1:0,ae<-1?G[Q++]=this.DV+ae:ae>0&&(G[Q++]=ae),G.t=Q,G.clamp()}function O(j,G){var Q=this.abs(),ae=j.abs(),Be=Q.t;for(G.t=Be+ae.t;--Be>=0;)G[Be]=0;for(Be=0;Be=0;)j[Q]=0;for(Q=0;Q=G.DV&&(j[Q+G.t]-=G.DV,j[Q+G.t+1]=1)}j.t>0&&(j[j.t-1]+=G.am(Q,G[Q],j,2*Q,0,1)),j.s=0,j.clamp()}function J(j,G,Q){var ae=j.abs();if(!(ae.t<=0)){var Be=this.abs();if(Be.t0?(ae.lShiftTo(sr,xe),Be.lShiftTo(sr,Q)):(ae.copyTo(xe),Be.copyTo(Q));var Br=xe.t,Mn=xe[Br-1];if(Mn!=0){var cn=Mn*(1<1?xe[Br-2]>>this.F2:0),ri=this.FV/cn,Ru=(1<=0&&(Q[Q.t++]=1,Q.subTo(bi,Q)),n.ONE.dlShiftTo(Br,bi),bi.subTo(xe,xe);xe.t=0;){var zc=Q[--cs]==Mn?this.DM:Math.floor(Q[cs]*ri+(Q[cs-1]+us)*Ru);if((Q[cs]+=xe.am(0,zc,Q,Bo,0,Br))0&&Q.rShiftTo(sr,Q),Me<0&&n.ZERO.subTo(Q,Q)}}}function Y(j){var G=i();return this.abs().divRemTo(j,null,G),this.s<0&&G.compareTo(n.ZERO)>0&&j.subTo(G,G),G}function ee(j){this.m=j}function se(j){return j.s<0||j.compareTo(this.m)>=0?j.mod(this.m):j}function le(j){return j}function ve(j){j.divRemTo(this.m,null,j)}function we(j,G,Q){j.multiplyTo(G,Q),this.reduce(Q)}function Pe(j,G){j.squareTo(G),this.reduce(G)}ee.prototype.convert=se,ee.prototype.revert=le,ee.prototype.reduce=ve,ee.prototype.mulTo=we,ee.prototype.sqrTo=Pe;function Le(){if(this.t<1)return 0;var j=this[0];if(!(j&1))return 0;var G=j&3;return G=G*(2-(j&15)*G)&15,G=G*(2-(j&255)*G)&255,G=G*(2-((j&65535)*G&65535))&65535,G=G*(2-j*G%this.DV)%this.DV,G>0?this.DV-G:-G}function Oe(j){this.m=j,this.mp=j.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(G,G),G}function Se(j){var G=i();return j.copyTo(G),this.reduce(G),G}function Re(j){for(;j.t<=this.mt2;)j[j.t++]=0;for(var G=0;G>15)*this.mpl&this.um)<<15)&j.DM;for(Q=G+this.m.t,j[Q]+=this.m.am(0,ae,j,G,0,this.m.t);j[Q]>=j.DV;)j[Q]-=j.DV,j[++Q]++}j.clamp(),j.drShiftTo(this.m.t,j),j.compareTo(this.m)>=0&&j.subTo(this.m,j)}function Ke(j,G){j.squareTo(G),this.reduce(G)}function Qe(j,G,Q){j.multiplyTo(G,Q),this.reduce(Q)}Oe.prototype.convert=fe,Oe.prototype.revert=Se,Oe.prototype.reduce=Re,Oe.prototype.mulTo=Qe,Oe.prototype.sqrTo=Ke;function je(){return(this.t>0?this[0]&1:this.s)==0}function yt(j,G){if(j>4294967295||j<1)return n.ONE;var Q=i(),ae=i(),Be=G.convert(this),xe=I(j)-1;for(Be.copyTo(Q);--xe>=0;)if(G.sqrTo(Q,ae),(j&1<0)G.mulTo(ae,Be,Q);else{var Me=Q;Q=ae,ae=Me}return G.revert(Q)}function rt(j,G){var Q;return j<256||G.isEven()?Q=new ee(G):Q=new Oe(G),this.exp(j,Q)}n.prototype.copyTo=y,n.prototype.fromInt=w,n.prototype.fromString=S,n.prototype.clamp=F,n.prototype.dlShiftTo=R,n.prototype.drShiftTo=k,n.prototype.lShiftTo=M,n.prototype.rShiftTo=N,n.prototype.subTo=D,n.prototype.multiplyTo=O,n.prototype.squareTo=q,n.prototype.divRemTo=J,n.prototype.invDigit=Le,n.prototype.isEven=je,n.prototype.exp=yt,n.prototype.toString=_,n.prototype.negate=H,n.prototype.abs=V,n.prototype.compareTo=C,n.prototype.bitLength=L,n.prototype.mod=Y,n.prototype.modPowInt=rt,n.ZERO=E(0),n.ONE=E(1);function vt(){var j=i();return this.copyTo(j),j}function sn(){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 Ar(){return this.t==0?this.s:this[0]<<16>>16}function wt(j){return Math.floor(Math.LN2*this.DB/Math.log(j))}function Rr(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Nn(j){if(j==null&&(j=10),this.signum()==0||j<2||j>36)return"0";var G=this.chunkSize(j),Q=Math.pow(j,G),ae=E(Q),Be=i(),xe=i(),Me="";for(this.divRemTo(ae,Be,xe);Be.signum()>0;)Me=(Q+xe.intValue()).toString(j).substr(1)+Me,Be.divRemTo(ae,Be,xe);return xe.intValue().toString(j)+Me}function Qs(j,G){this.fromInt(0),G==null&&(G=10);for(var Q=this.chunkSize(G),ae=Math.pow(G,Q),Be=!1,xe=0,Me=0,Ve=0;Ve=Q&&(this.dMultiply(ae),this.dAddOffset(Me,0),xe=0,Me=0)}xe>0&&(this.dMultiply(Math.pow(G,xe)),this.dAddOffset(Me,0)),Be&&n.ZERO.subTo(this,this)}function $t(j,G,Q){if(typeof G=="number")if(j<2)this.fromInt(1);else for(this.fromNumber(j,Q),this.testBit(j-1)||this.bitwiseTo(n.ONE.shiftLeft(j-1),De,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(G);)this.dAddOffset(2,0),this.bitLength()>j&&this.subTo(n.ONE.shiftLeft(j-1),this);else{var ae=new Array,Be=j&7;ae.length=(j>>3)+1,G.nextBytes(ae),Be>0?ae[0]&=(1<0)for(Q>Q)!=(this.s&this.DM)>>Q&&(G[Be++]=ae|this.s<=0;)Q<8?(ae=(this[j]&(1<>(Q+=this.DB-8)):(ae=this[j]>>(Q-=8)&255,Q<=0&&(Q+=this.DB,--j)),ae&128&&(ae|=-256),Be==0&&(this.s&128)!=(ae&128)&&++Be,(Be>0||ae!=this.s)&&(G[Be++]=ae);return G}function Ue(j){return this.compareTo(j)==0}function gr(j){return this.compareTo(j)<0?this:j}function vn(j){return this.compareTo(j)>0?this:j}function Et(j,G,Q){var ae,Be,xe=Math.min(j.t,this.t);for(ae=0;ae>=16,G+=16),j&255||(j>>=8,G+=8),j&15||(j>>=4,G+=4),j&3||(j>>=2,G+=2),j&1||++G,G}function Gt(){for(var j=0;j=this.t?this.s!=0:(this[G]&1<>=this.DB;if(j.t>=this.DB;ae+=this.s}else{for(ae+=this.s;Q>=this.DB;ae+=j.s}G.s=ae<0?-1:0,ae>0?G[Q++]=ae:ae<-1&&(G[Q++]=this.DV+ae),G.t=Q,G.clamp()}function Hc(j){var G=i();return this.addTo(j,G),G}function ue(j){var G=i();return this.subTo(j,G),G}function Ee(j){var G=i();return this.multiplyTo(j,G),G}function Xe(){var j=i();return this.squareTo(j),j}function We(j){var G=i();return this.divRemTo(j,G,null),G}function it(j){var G=i();return this.divRemTo(j,null,G),G}function bt(j){var G=i(),Q=i();return this.divRemTo(j,G,Q),new Array(G,Q)}function At(j){this[this.t]=this.am(0,j-1,this,0,0,this.t),++this.t,this.clamp()}function kr(j,G){if(j!=0){for(;this.t<=G;)this[this.t++]=0;for(this[G]+=j;this[G]>=this.DV;)this[G]-=this.DV,++G>=this.t&&(this[this.t++]=0),++this[G]}}function nr(){}function is(j){return j}function yi(j,G,Q){j.multiplyTo(G,Q)}function yn(j,G){j.squareTo(G)}nr.prototype.convert=is,nr.prototype.revert=is,nr.prototype.mulTo=yi,nr.prototype.sqrTo=yn;function Ln(j){return this.exp(j,new nr)}function Dr(j,G,Q){var ae=Math.min(this.t+j.t,G);for(Q.s=0,Q.t=ae;ae>0;)Q[--ae]=0;var Be;for(Be=Q.t-this.t;ae=0;)Q[ae]=0;for(ae=Math.max(G-this.t,0);ae2*this.m.t)return j.mod(this.m);if(j.compareTo(this.m)<0)return j;var G=i();return j.copyTo(G),this.reduce(G),G}function Mc(j){return j}function an(j){for(j.drShiftTo(this.m.t-1,this.r2),j.t>this.m.t+1&&(j.t=this.m.t+1,j.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);j.compareTo(this.r2)<0;)j.dAddOffset(1,this.m.t+1);for(j.subTo(this.r2,j);j.compareTo(this.m)>=0;)j.subTo(this.m,j)}function Kt(j,G){j.squareTo(G),this.reduce(G)}function Fr(j,G,Q){j.multiplyTo(G,Q),this.reduce(Q)}Un.prototype.convert=Fo,Un.prototype.revert=Mc,Un.prototype.reduce=an,Un.prototype.mulTo=Fr,Un.prototype.sqrTo=Kt;function mt(j,G){var Q=j.bitLength(),ae,Be=E(1),xe;if(Q<=0)return Be;Q<18?ae=1:Q<48?ae=3:Q<144?ae=4:Q<768?ae=5:ae=6,Q<8?xe=new ee(G):G.isEven()?xe=new Un(G):xe=new Oe(G);var Me=new Array,Ve=3,sr=ae-1,Br=(1<1){var Mn=i();for(xe.sqrTo(Me[1],Mn);Ve<=Br;)Me[Ve]=i(),xe.mulTo(Mn,Me[Ve-2],Me[Ve]),Ve+=2}var cn=j.t-1,ri,Ru=!0,us=i(),cs;for(Q=I(j[cn])-1;cn>=0;){for(Q>=sr?ri=j[cn]>>Q-sr&Br:(ri=(j[cn]&(1<0&&(ri|=j[cn-1]>>this.DB+Q-sr)),Ve=ae;!(ri&1);)ri>>=1,--Ve;if((Q-=Ve)<0&&(Q+=this.DB,--cn),Ru)Me[ri].copyTo(Be),Ru=!1;else{for(;Ve>1;)xe.sqrTo(Be,us),xe.sqrTo(us,Be),Ve-=2;Ve>0?xe.sqrTo(Be,us):(cs=Be,Be=us,us=cs),xe.mulTo(us,Me[ri],Be)}for(;cn>=0&&!(j[cn]&1<0&&(G.rShiftTo(xe,G),Q.rShiftTo(xe,Q));G.signum()>0;)(Be=G.getLowestSetBit())>0&&G.rShiftTo(Be,G),(Be=Q.getLowestSetBit())>0&&Q.rShiftTo(Be,Q),G.compareTo(Q)>=0?(G.subTo(Q,G),G.rShiftTo(1,G)):(Q.subTo(G,Q),Q.rShiftTo(1,Q));return xe>0&&Q.lShiftTo(xe,Q),Q}function un(j){if(j<=0)return 0;var G=this.DV%j,Q=this.s<0?j-1:0;if(this.t>0)if(G==0)Q=this[0]%j;else for(var ae=this.t-1;ae>=0;--ae)Q=(G*Q+this[ae])%j;return Q}function pr(j){var G=j.isEven();if(this.isEven()&&G||j.signum()==0)return n.ZERO;for(var Q=j.clone(),ae=this.clone(),Be=E(1),xe=E(0),Me=E(0),Ve=E(1);Q.signum()!=0;){for(;Q.isEven();)Q.rShiftTo(1,Q),G?((!Be.isEven()||!xe.isEven())&&(Be.addTo(this,Be),xe.subTo(j,xe)),Be.rShiftTo(1,Be)):xe.isEven()||xe.subTo(j,xe),xe.rShiftTo(1,xe);for(;ae.isEven();)ae.rShiftTo(1,ae),G?((!Me.isEven()||!Ve.isEven())&&(Me.addTo(this,Me),Ve.subTo(j,Ve)),Me.rShiftTo(1,Me)):Ve.isEven()||Ve.subTo(j,Ve),Ve.rShiftTo(1,Ve);Q.compareTo(ae)>=0?(Q.subTo(ae,Q),G&&Be.subTo(Me,Be),xe.subTo(Ve,xe)):(ae.subTo(Q,ae),G&&Me.subTo(Be,Me),Ve.subTo(xe,Ve))}if(ae.compareTo(n.ONE)!=0)return n.ZERO;if(Ve.compareTo(j)>=0)return Ve.subtract(j);if(Ve.signum()<0)Ve.addTo(j,Ve);else return Ve;return Ve.signum()<0?Ve.add(j):Ve}var Qt=[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],os=(1<<26)/Qt[Qt.length-1];function Ts(j){var G,Q=this.abs();if(Q.t==1&&Q[0]<=Qt[Qt.length-1]){for(G=0;G>1,j>Qt.length&&(j=Qt.length);for(var Be=i(),xe=0;xe>8&255,Vr[Sr++]^=j>>16&255,Vr[Sr++]^=j>>24&255,Sr>=Ei&&(Sr-=Ei)}function ef(){jc(new Date().getTime())}if(Vr==null){Vr=new Array,Sr=0;var Hn;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var Ea=new Uint8Array(32);for(window.crypto.getRandomValues(Ea),Hn=0;Hn<32;++Hn)Vr[Sr++]=Ea[Hn]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var qc=window.crypto.random(32);for(Hn=0;Hn>>8,Vr[Sr++]=Hn&255;Sr=0,ef()}function qh(){if(as==null){for(ef(),as=Vc(),as.init(Vr),Sr=0;Sr{var nhe=P(x());(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(o(s),arguments)}function r(s,a){return t.apply(null,[s].concat(a||[]))}function n(s,a){var u=1,l=s.length,f,m="",p,d,v,g,y,w,E,S;for(p=0;p=0),v.type){case"b":f=parseInt(f,10).toString(2);break;case"c":f=String.fromCharCode(parseInt(f,10));break;case"d":case"i":f=parseInt(f,10);break;case"j":f=JSON.stringify(f,null,v.width?parseInt(v.width):0);break;case"e":f=v.precision?parseFloat(f).toExponential(v.precision):parseFloat(f).toExponential();break;case"f":f=v.precision?parseFloat(f).toFixed(v.precision):parseFloat(f);break;case"g":f=v.precision?String(Number(f.toPrecision(v.precision))):parseFloat(f);break;case"o":f=(parseInt(f,10)>>>0).toString(8);break;case"s":f=String(f),f=v.precision?f.substring(0,v.precision):f;break;case"t":f=String(!!f),f=v.precision?f.substring(0,v.precision):f;break;case"T":f=Object.prototype.toString.call(f).slice(8,-1).toLowerCase(),f=v.precision?f.substring(0,v.precision):f;break;case"u":f=parseInt(f,10)>>>0;break;case"v":f=f.valueOf(),f=v.precision?f.substring(0,v.precision):f;break;case"x":f=(parseInt(f,10)>>>0).toString(16);break;case"X":f=(parseInt(f,10)>>>0).toString(16).toUpperCase();break}e.json.test(v.type)?m+=f:(e.number.test(v.type)&&(!E||v.sign)?(S=E?"+":"-",f=f.toString().replace(e.sign,"")):S="",y=v.pad_char?v.pad_char==="0"?"0":v.pad_char.charAt(1):" ",w=v.width-(S+f).length,g=v.width&&w>0?y.repeat(w):"",m+=v.align?S+f+g:y==="0"?S+g+f:g+S+f)}return m}var i=Object.create(null);function o(s){if(i[s])return i[s];for(var a=s,u,l=[],f=0;a;){if((u=e.text.exec(a))!==null)l.push(u[0]);else if((u=e.modulo.exec(a))!==null)l.push("%");else if((u=e.placeholder.exec(a))!==null){if(u[2]){f|=1;var m=[],p=u[2],d=[];if((d=e.key.exec(p))!==null)for(m.push(d[1]);(p=p.substring(d[0].length))!=="";)if((d=e.key_access.exec(p))!==null)m.push(d[1]);else if((d=e.index_access.exec(p))!==null)m.push(d[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");u[2]=m}else f|=2;if(f===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");l.push({placeholder:u[0],param_no:u[1],keys:u[2],sign:u[3],pad_char:u[4],align:u[5],width:u[6],precision:u[7],type:u[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");a=a.substring(u[0].length)}return i[s]=l}typeof xm<"u"&&(xm.sprintf=t,xm.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var pE=Ce(zo=>{"use strict";var ihe=P(x()),rV=zo&&zo.__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]}),nV=zo&&zo.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),fD=zo&&zo.__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)&&rV(t,e,r);return nV(t,e),t};Object.defineProperty(zo,"__esModule",{value:!0});zo.Address4=void 0;var cD=fD(cE()),oo=fD(lE()),lD=$m(),Qd=hE(),Yf=Zd(),dE=class e{constructor(t){this.groups=oo.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=cD.isCorrect(oo.BITS),this.isInSubnet=cD.isInSubnet,this.address=t;let r=oo.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>oo.BITS)throw new lD.AddressError("Invalid subnet mask.");t=t.replace(oo.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(oo.RE_ADDRESS))throw new lD.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 o=r.slice(i,i+2);n.push(parseInt(o,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,Yf.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r(0,Yf.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Qd.BigInteger(this.mask()+"0".repeat(oo.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Qd.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Qd.BigInteger(this.mask()+"1".repeat(oo.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Qd.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,Yf.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(oo.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(oo.RE_ADDRESS,(0,Yf.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};zo.Address4=dE});var mE=Ce(Pr=>{"use strict";var ahe=P(x());Object.defineProperty(Pr,"__esModule",{value:!0});Pr.RE_URL_WITH_PORT=Pr.RE_URL=Pr.RE_ZONE_STRING=Pr.RE_SUBNET_STRING=Pr.RE_BAD_ADDRESS=Pr.RE_BAD_CHARACTERS=Pr.TYPES=Pr.SCOPES=Pr.GROUPS=Pr.BITS=void 0;Pr.BITS=128;Pr.GROUPS=8;Pr.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};Pr.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"};Pr.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;Pr.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;Pr.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;Pr.RE_ZONE_STRING=/%.*$/;Pr.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);Pr.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var gE=Ce(Go=>{"use strict";var che=P(x());Object.defineProperty(Go,"__esModule",{value:!0});Go.simpleGroup=Go.spanLeadingZeroes=Go.spanAll=Go.spanAllZeroes=void 0;var hD=Zd();function dD(e){return e.replace(/(0+)/g,'$1')}Go.spanAllZeroes=dD;function sV(e,t=0){return e.split("").map((n,i)=>(0,hD.sprintf)('%s',n,i+t,dD(n))).join("")}Go.spanAll=sV;function pD(e){return e.replace(/^(0+)/,'$1')}function iV(e){return e.split(":").map(r=>pD(r)).join(":")}Go.spanLeadingZeroes=iV;function oV(e,t=0){return e.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,hD.sprintf)('%s',i+t,pD(n)))}Go.simpleGroup=oV});var mD=Ce(pn=>{"use strict";var fhe=P(x()),aV=pn&&pn.__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]}),uV=pn&&pn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),cV=pn&&pn.__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)&&aV(t,e,r);return uV(t,e),t};Object.defineProperty(pn,"__esModule",{value:!0});pn.possibleElisions=pn.simpleRegularExpression=pn.ADDRESS_BOUNDARY=pn.padGroup=pn.groupPossibilities=void 0;var lV=cV(mE()),Wf=Zd();function Rm(e){return(0,Wf.sprintf)("(%s)",e.join("|"))}pn.groupPossibilities=Rm;function Tm(e){return e.length<4?(0,Wf.sprintf)("0{0,%d}%s",4-e.length,e):e}pn.padGroup=Tm;pn.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function fV(e){let t=[];e.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let r=t.map(n=>e.map((i,o)=>{if(o===n){let s=o===0||o===lV.GROUPS-1?":":"";return Rm([Tm(i),s])}return Tm(i)}).join(":"));return r.push(e.map(Tm).join(":")),Rm(r)}pn.simpleRegularExpression=fV;function hV(e,t,r){let n=t?"":":",i=r?"":":",o=[];!t&&!r&&o.push("::"),t&&r&&o.push(""),(r&&!t||!r&&t)&&o.push(":"),o.push((0,Wf.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),o.push((0,Wf.sprintf)("(0{1,4}:){1,%d}%s",e-1,i)),o.push((0,Wf.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let s=1;s{"use strict";var dhe=P(x()),dV=Yo&&Yo.__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]}),pV=Yo&&Yo.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Om=Yo&&Yo.__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)&&dV(t,e,r);return pV(t,e),t};Object.defineProperty(Yo,"__esModule",{value:!0});Yo.Address6=void 0;var gD=Om(cE()),vE=Om(lE()),mr=Om(mE()),wE=Om(gE()),ml=pE(),gl=mD(),Xa=$m(),bs=hE(),As=Zd();function km(e){if(!e)throw new Error("Assertion failed.")}function mV(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function gV(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function vV(e,t){let r=[],n=[],i;for(i=0;it[1]&&n.push(e[i]);return r.concat(["compact"]).concat(n)}function vD(e){return(0,As.sprintf)("%04x",parseInt(e,16))}function wD(e){return e&255}var yE=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=gD.isInSubnet,this.isCorrect=gD.isCorrect(mr.BITS),r===void 0?this.groups=mr.GROUPS:this.groups=r,this.address=t;let n=mr.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>mr.BITS)throw new Xa.AddressError("Invalid subnet mask.");t=t.replace(mr.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new Xa.AddressError("Invalid subnet mask.");let i=mr.RE_ZONE_STRING.exec(t);i&&(this.zone=i[0],t=t.replace(mr.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 ml.Address4(t),n=mr.BITS-(vE.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 Xa.AddressError("Invalid 'ip6.arpa' form.");let i=r.split(".").reverse();for(let o=n;o>0;o--){let s=o*4;i.splice(s,0,":")}return r=i.join(""),new e(r)}microsoftTranscription(){return(0,As.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=mr.BITS-this.subnetMask,n=Math.abs(t-mr.BITS),i=r-n;return i<0?"0":mV(new bs.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new bs.BigInteger(this.mask()+"0".repeat(mr.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new bs.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new bs.BigInteger(this.mask()+"1".repeat(mr.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new bs.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=mr.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(mr.TYPES))if(this.isInSubnet(new e(t)))return mr.TYPES[t];return"Global unicast"}getBits(t,r){return new bs.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,mr.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,As.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 o=i.map(a=>a[1]-a[0]+1);if(i.length>0){let a=o.indexOf(Math.max(...o));r=vV(this.parsedAddress,i[a])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace(mr.RE_BAD_CHARACTERS,'$1'));let n=t.match(mr.RE_BAD_ADDRESS);if(n)throw new Xa.AddressError((0,As.sprintf)("Address failed regex: %s",n.join("")),t.replace(mr.RE_BAD_ADDRESS,'$1'));let i=[],o=t.split("::");if(o.length===2){let s=o[0].split(":"),a=o[1].split(":");s.length===1&&s[0]===""&&(s=[]),a.length===1&&a[0]===""&&(a=[]);let u=this.groups-(s.length+a.length);if(!u)throw new Xa.AddressError("Error parsing groups");this.elidedGroups=u,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,i=i.concat(s);for(let l=0;l(0,As.sprintf)("%x",parseInt(s,16))),i.length!==this.groups)throw new Xa.AddressError("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(vD).join(":")}decimal(){return this.parsedAddress.map(t=>(0,As.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new bs.BigInteger(this.parsedAddress.map(vD).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return ml.Address4.fromHex(new bs.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 bs.BigInteger("ffff",16)).toString(),n=ml.Address4.fromHex(this.getBitsBase16(32,64)),i=ml.Address4.fromHex(this.getBits(96,128).xor(new bs.BigInteger("ffffffff",16)).toString(16)),o=this.getBits(64,80),s=this.getBitsBase2(64,80),a=o.testBit(15),u=o.testBit(14),l=o.testBit(8),f=o.testBit(9),m=new bs.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,As.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:s,coneNat:a,microsoft:{reserved:u,universalLocal:f,groupIndividual:l,nonce:m},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=ml.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,As.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(wD)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(wD))}static fromUnsignedByteArray(t){let r=new bs.BigInteger("256",10),n=new bs.BigInteger("0",10),i=new bs.BigInteger("1",10);for(let o=t.length-1;o>=0;o--)n=n.add(i.multiply(new bs.BigInteger(t[o].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,As.sprintf)(":%s",t),(0,As.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,As.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,As.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return wE.simpleGroup(this.address).join(":");km(typeof this.elidedGroups=="number"),km(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...wE.simpleGroup(r)):t.push("");let i=["hover-group"];for(let o=this.elisionBegin;o',i.join(" "))),n.length?t.push(...wE.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(km(this.address4 instanceof ml.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,gl.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===mr.GROUPS)r.push((0,gl.possibleElisions)(mr.GROUPS));else{let i=n.address.split("::");i[0].length&&r.push((0,gl.simpleRegularExpression)(i[0].split(":"))),km(typeof n.elidedGroups=="number"),r.push((0,gl.possibleElisions)(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&r.push((0,gl.simpleRegularExpression)(i[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",gl.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",gl.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};Yo.Address6=yE});var ED=Ce(Qn=>{"use strict";var mhe=P(x()),wV=Qn&&Qn.__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]}),yV=Qn&&Qn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),EV=Qn&&Qn.__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)&&wV(t,e,r);return yV(t,e),t};Object.defineProperty(Qn,"__esModule",{value:!0});Qn.v6=Qn.AddressError=Qn.Address6=Qn.Address4=void 0;var bV=pE();Object.defineProperty(Qn,"Address4",{enumerable:!0,get:function(){return bV.Address4}});var AV=yD();Object.defineProperty(Qn,"Address6",{enumerable:!0,get:function(){return AV.Address6}});var SV=$m();Object.defineProperty(Qn,"AddressError",{enumerable:!0,get:function(){return SV.AddressError}});var CV=EV(gE());Qn.v6={helpers:CV}});var VI=Ce(LA=>{"use strict";var A2e=P(x());LA.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};LA.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 zI=Ce(UA=>{"use strict";var C2e=P(x());UA.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};UA.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 GI=Ce(HA=>{"use strict";var D2e=P(x());HA.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};HA.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 YI=Ce(MA=>{"use strict";var B2e=P(x());MA.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};MA.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 WI=Ce(jA=>{"use strict";var $2e=P(x());jA.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}`};jA.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 ZI=Ce((JI,qA)=>{var P2e=P(x()),XI=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=m,e.encode=f,e.familyOf=l,e.name=void 0,e.sizeOf=u,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,o={name:"v4",size:r,isFormat:p=>t.test(p),encode(p,d,v){v=~~v,d=d||new Uint8Array(v+r);let g=p.length,y=0;for(let w=0;wp.length>0&&n.test(p),encode(p,d,v){v=~~v;let g=v+i,y=-1,w=0,E=0,S=!0,F=!1;d=d||new Uint8Array(v+i);for(let _=0;_>8),v=97?H-=87:H>=65?H-=55:(H-=48,E=E*10+H),w=(w<<4)+H)}if(S===!1)F===!0?(v>8),v=y+2;_--)d[_]=d[_-2];d[y]=0,d[y+1]=0,y=v}if(y!==v&&y!==-1)for(v>g-2&&(v=g-2);g>y;)d[--g]=vy?d[--v]:0;else for(;v{"use strict";var T2e=P(x()),st=$1().Buffer,Cu=VI(),NW=zI(),LW=GI(),o2=YI(),KA=WI(),Kl=ZI(),UW=0,QI=32768,VA=32768,HW=~VA,e9=32768,MW=~e9,ze=nt.name={};ze.encode=function(e,t,r,{mail:n=!1}={}){t||(t=st.alloc(ze.encodingLength(e))),r||(r=0);let i=r,o=e.replace(/^\.|\.$/gm,"");if(o.length){let s=[];if(n){let a="";o.split(".").forEach(u=>{u.endsWith("\\")?a+=(a.length?".":"")+u.slice(0,-1):s.length===0&&a.length?s.push(a+"."+u):s.push(u)})}else s=o.split(".");for(let a=0;a=e.length)throw new Error("Cannot decode name (buffer overflow)");let u=e[t++];if(s+=a?0:1,u===0)break;if(u&192)if((u&192)===192){if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");let l=e.readUInt16BE(t-1)-49152;if(l>=i)throw new Error("Cannot decode name (bad pointer)");t=l,i=l,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)");else{if(t+u>e.length)throw new Error("Cannot decode name (buffer overflow)");if(o+=u+1,o>254)throw new Error("Cannot decode name (name too long)");let l=e.toString("utf-8",t,t+u);r&&(l=l.replace(/\./g,"\\.")),n.push(l),t+=u,s+=a?0:u}}return ze.decode.bytes=s,n.length===0?".":n.join(".")};ze.decode.bytes=0;ze.encodingLength=function(e){return e==="."||e===".."?1:st.byteLength(e.replace(/^\.|\.$/gm,""))+2};var xt={};xt.encode=function(e,t,r){t||(t=st.alloc(xt.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,xt.encode.bytes=n+1,t};xt.encode.bytes=0;xt.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return xt.decode.bytes=r+1,n};xt.decode.bytes=0;xt.encodingLength=function(e){return st.byteLength(e)+1};var vo={};vo.encode=function(e,t,r){t||(t=vo.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,i=e.type==="response"?QI:UW;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};vo.encode.bytes=12;vo.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&QI?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:LW.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:NW.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))}};vo.decode.bytes=12;vo.encodingLength=function(){return 12};var mu=nt.unknown={};mu.encode=function(e,t,r){return t||(t=st.alloc(mu.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),mu.encode.bytes=e.length+2,t};mu.encode.bytes=0;mu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return mu.decode.bytes=r+2,n};mu.decode.bytes=0;mu.encodingLength=function(e){return e.length+2};var gu=nt.ns={};gu.encode=function(e,t,r){return t||(t=st.alloc(gu.encodingLength(e))),r||(r=0),ze.encode(e,t,r+2),t.writeUInt16BE(ze.encode.bytes,r),gu.encode.bytes=ze.encode.bytes+2,t};gu.encode.bytes=0;gu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=ze.decode(e,t+2);return gu.decode.bytes=r+2,n};gu.decode.bytes=0;gu.encodingLength=function(e){return ze.encodingLength(e)+2};var vu=nt.soa={};vu.encode=function(e,t,r){t||(t=st.alloc(vu.encodingLength(e))),r||(r=0);let n=r;return r+=2,ze.encode(e.mname,t,r),r+=ze.encode.bytes,ze.encode(e.rname,t,r,{mail:!0}),r+=ze.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),vu.encode.bytes=r-n,t};vu.encode.bytes=0;vu.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mname=ze.decode(e,t),t+=ze.decode.bytes,n.rname=ze.decode(e,t,{mail:!0}),t+=ze.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,vu.decode.bytes=t-r,n};vu.decode.bytes=0;vu.encodingLength=function(e){return 22+ze.encodingLength(e.mname)+ze.encodingLength(e.rname)};var wu=nt.txt={};wu.encode=function(e,t,r){Array.isArray(e)||(e=[e]);for(let i=0;i0;){let o=e[t++];if(--n,n0&&(r.timeout=e.readUInt16BE(t),t+=2);break;case 14:r.tags=[];for(let o=0;o0;)n[o++]=Xs.decode(e,t),t+=Xs.decode.bytes,i-=Xs.decode.bytes;return pi.decode.bytes=t-r,n};pi.decode.bytes=0;pi.encodingLength=function(e){return 2+Dh(e||[],Xs)};var Is=nt.dnskey={};Is.PROTOCOL_DNSSEC=3;Is.ZONE_KEY=128;Is.SECURE_ENTRYPOINT=32768;Is.encode=function(e,t,r){t||(t=st.alloc(Is.encodingLength(e))),r||(r=0);let n=r,i=e.key;if(!st.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(Is.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,i.copy(t,r,0,i.length),r+=i.length,Is.encode.bytes=r-n,t.writeUInt16BE(Is.encode.bytes-2,n),t};Is.encode.bytes=0;Is.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)!==Is.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,Is.decode.bytes=t-r,n};Is.decode.bytes=0;Is.encodingLength=function(e){return 6+st.byteLength(e.key)};var sa=nt.rrsig={};sa.encode=function(e,t,r){t||(t=st.alloc(sa.encodingLength(e))),r||(r=0);let n=r,i=e.signature;if(!st.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(Cu.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,ze.encode(e.signersName,t,r),r+=ze.encode.bytes,i.copy(t,r,0,i.length),r+=i.length,sa.encode.bytes=r-n,t.writeUInt16BE(sa.encode.bytes-2,n),t};sa.encode.bytes=0;sa.decode=function(e,t){t||(t=0);let r=t;var n={},i=e.readUInt16BE(t);return t+=2,n.typeCovered=Cu.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=ze.decode(e,t),t+=ze.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,sa.decode.bytes=t-r,n};sa.decode.bytes=0;sa.encodingLength=function(e){return 20+ze.encodingLength(e.signersName)+st.byteLength(e.signature)};var ia=nt.rp={};ia.encode=function(e,t,r){t||(t=st.alloc(ia.encodingLength(e))),r||(r=0);let n=r;return r+=2,ze.encode(e.mbox||".",t,r,{mail:!0}),r+=ze.encode.bytes,ze.encode(e.txt||".",t,r),r+=ze.encode.bytes,ia.encode.bytes=r-n,t.writeUInt16BE(ia.encode.bytes-2,n),t};ia.encode.bytes=0;ia.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mbox=ze.decode(e,t,{mail:!0})||".",t+=ze.decode.bytes,n.txt=ze.decode(e,t)||".",t+=ze.decode.bytes,ia.decode.bytes=t-r,n};ia.decode.bytes=0;ia.encodingLength=function(e){return 2+ze.encodingLength(e.mbox||".")+ze.encodingLength(e.txt||".")};var gn={};gn.encode=function(e,t,r){t||(t=st.alloc(gn.encodingLength(e))),r||(r=0);let n=r;for(var i=[],o=0;o>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(o=0;o>8]=Math.max(t[n>>8]||0,n&255)}var i=0;for(r=0;r>15&1)===1,r.options=pi.decode(e,t+8),t+=8+pi.decode.bytes;else{let i=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=o2.toString(i&HW),r.flush=!!(i&VA);let o=zA(r.type);r.data=o.decode(e,t+8),t+=8+o.decode.bytes}return xn.decode.bytes=t-n,r};xn.decode.bytes=0;xn.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return ze.encodingLength(e.name)+8+zA(e.type).encodingLength(t)};var go=nt.question={};go.encode=function(e,t,r){t||(t=st.alloc(go.encodingLength(e))),r||(r=0);let n=r;return ze.encode(e.name,t,r),r+=ze.encode.bytes,t.writeUInt16BE(Cu.toType(e.type),r),r+=2,t.writeUInt16BE(o2.toClass(e.class===void 0?"IN":e.class),r),r+=2,go.encode.bytes=r-n,e};go.encode.bytes=0;go.decode=function(e,t){t||(t=0);let r=t,n={};return n.name=ze.decode(e,t),t+=ze.decode.bytes,n.type=Cu.toString(e.readUInt16BE(t)),t+=2,n.class=o2.toString(e.readUInt16BE(t)),t+=2,!!(n.class&e9)&&(n.class&=MW),go.decode.bytes=t-r,n};go.decode.bytes=0;go.encodingLength=function(e){return ze.encodingLength(e.name)+4};nt.AUTHORITATIVE_ANSWER=1024;nt.TRUNCATED_RESPONSE=512;nt.RECURSION_DESIRED=256;nt.RECURSION_AVAILABLE=128;nt.AUTHENTIC_DATA=32;nt.CHECKING_DISABLED=16;nt.DNSSEC_OK=32768;nt.encode=function(e,t,r){let n=!t;n&&(t=st.alloc(nt.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=[]),vo.encode(e,t,r),r+=vo.encode.bytes,r=Vp(e.questions,go,t,r),r=Vp(e.answers,xn,t,r),r=Vp(e.authorities,xn,t,r),r=Vp(e.additionals,xn,t,r),nt.encode.bytes=r-i,n&&nt.encode.bytes!==t.length?t.slice(0,nt.encode.bytes):t};nt.encode.bytes=0;nt.decode=function(e,t){t||(t=0);let r=t,n=vo.decode(e,t);return t+=vo.decode.bytes,t=i2(n.questions,go,e,t),t=i2(n.answers,xn,e,t),t=i2(n.authorities,xn,e,t),t=i2(n.additionals,xn,e,t),nt.decode.bytes=t-r,n};nt.decode.bytes=0;nt.encodingLength=function(e){return vo.encodingLength(e)+Dh(e.questions||[],go)+Dh(e.answers||[],xn)+Dh(e.authorities||[],xn)+Dh(e.additionals||[],xn)};nt.streamEncode=function(e){let t=nt.encode(e),r=st.alloc(2);r.writeUInt16BE(t.byteLength);let n=st.concat([r,t]);return nt.streamEncode.bytes=n.byteLength,n};nt.streamEncode.bytes=0;nt.streamDecode=function(e){let t=e.readUInt16BE(0);if(e.byteLength{var L2e=P(x());(function(){var e,t="4.18.1",r=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",i="Expected a function",o="Invalid `variable` option passed into `_.template`",s="Invalid `imports` option passed into `_.template`",a="__lodash_hash_undefined__",u=500,l="__lodash_placeholder__",f=1,m=2,p=4,d=1,v=2,g=1,y=2,w=4,E=8,S=16,F=32,_=64,H=128,V=256,C=512,I=30,L="...",R=800,k=16,M=1,N=2,D=3,O=1/0,q=9007199254740991,J=17976931348623157e292,Y=NaN,ee=4294967295,se=ee-1,le=ee>>>1,ve=[["ary",H],["bind",g],["bindKey",y],["curry",E],["curryRight",S],["flip",C],["partial",F],["partialRight",_],["rearg",V]],we="[object Arguments]",Pe="[object Array]",Le="[object AsyncFunction]",Oe="[object Boolean]",fe="[object Date]",Se="[object DOMException]",Re="[object Error]",Ke="[object Function]",Qe="[object GeneratorFunction]",je="[object Map]",yt="[object Number]",rt="[object Null]",vt="[object Object]",sn="[object Promise]",br="[object Proxy]",Ar="[object RegExp]",wt="[object Set]",Rr="[object String]",Nn="[object Symbol]",Qs="[object Undefined]",$t="[object WeakMap]",tt="[object WeakSet]",Ue="[object ArrayBuffer]",gr="[object DataView]",vn="[object Float32Array]",Et="[object Float64Array]",va="[object Int8Array]",wn="[object Int16Array]",De="[object Int32Array]",So="[object Uint8Array]",qt="[object Uint8ClampedArray]",on="[object Uint16Array]",ei="[object Uint32Array]",Pu=/\b__p \+= '';/g,Co=/\b(__p \+=) '' \+/g,Nc=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_o=/&(?:amp|lt|gt|quot|#39);/g,wi=/[&<>"']/g,Gt=RegExp(_o.source),xs=RegExp(wi.source),xu=/<%-([\s\S]+?)%>/g,Lc=/<%([\s\S]+?)%>/g,wa=/<%=([\s\S]+?)%>/g,Do=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Uc=/^\w*$/,Tu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ya=/[\\^$.*+?()[\]{}|]/g,Hc=RegExp(ya.source),ue=/^\s+/,Ee=/\s/,Xe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,We=/\{\n\/\* \[wrapped with (.+)\] \*/,it=/,? & /,bt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,At=/[()=,{}\[\]\/\s]/,kr=/\\(\\)?/g,nr=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,is=/\w*$/,yi=/^[-+]0x[0-9a-f]+$/i,yn=/^0b[01]+$/i,Ln=/^\[object .+?Constructor\]$/,Dr=/^0o[0-7]+$/i,En=/^(?:0|[1-9]\d*)$/,Un=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Fo=/($^)/,Mc=/['\n\r\u2028\u2029\\]/g,an="\\ud800-\\udfff",Kt="\\u0300-\\u036f",Fr="\\ufe20-\\ufe2f",mt="\\u20d0-\\u20ff",vr=Kt+Fr+mt,un="\\u2700-\\u27bf",pr="a-z\\xdf-\\xf6\\xf8-\\xff",Qt="\\xac\\xb1\\xd7\\xf7",os="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Ts="\\u2000-\\u206f",ti=" \\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",as="A-Z\\xc0-\\xd6\\xd8-\\xde",Vr="\\ufe0e\\ufe0f",Sr=Qt+os+Ts+ti,jc="['\u2019]",ef="["+an+"]",Hn="["+Sr+"]",Ea="["+vr+"]",qc="\\d+",qh="["+un+"]",Kc="["+pr+"]",ba="[^"+an+Sr+qc+un+pr+as+"]",Aa="\\ud83c[\\udffb-\\udfff]",Kh="(?:"+Ea+"|"+Aa+")",tf="[^"+an+"]",Vc="(?:\\ud83c[\\udde6-\\uddff]){2}",Ei="[\\ud800-\\udbff][\\udc00-\\udfff]",j="["+as+"]",G="\\u200d",Q="(?:"+Kc+"|"+ba+")",ae="(?:"+j+"|"+ba+")",Be="(?:"+jc+"(?:d|ll|m|re|s|t|ve))?",xe="(?:"+jc+"(?:D|LL|M|RE|S|T|VE))?",Me=Kh+"?",Ve="["+Vr+"]?",sr="(?:"+G+"(?:"+[tf,Vc,Ei].join("|")+")"+Ve+Me+")*",Br="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Mn="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",cn=Ve+Me+sr,ri="(?:"+[qh,Vc,Ei].join("|")+")"+cn,Ru="(?:"+[tf+Ea+"?",Ea,Vc,Ei,ef].join("|")+")",us=RegExp(jc,"g"),cs=RegExp(Ea,"g"),Bo=RegExp(Aa+"(?="+Aa+")|"+Ru+cn,"g"),bi=RegExp([j+"?"+Kc+"+"+Be+"(?="+[Hn,j,"$"].join("|")+")",ae+"+"+xe+"(?="+[Hn,j+Q,"$"].join("|")+")",j+"?"+Q+"+"+Be,j+"+"+xe,Mn,Br,qc,ri].join("|"),"g"),zc=RegExp("["+G+an+vr+Vr+"]"),j2=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,q2=["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"],K2=-1,lr={};lr[vn]=lr[Et]=lr[va]=lr[wn]=lr[De]=lr[So]=lr[qt]=lr[on]=lr[ei]=!0,lr[we]=lr[Pe]=lr[Ue]=lr[Oe]=lr[gr]=lr[fe]=lr[Re]=lr[Ke]=lr[je]=lr[yt]=lr[vt]=lr[Ar]=lr[wt]=lr[Rr]=lr[$t]=!1;var ar={};ar[we]=ar[Pe]=ar[Ue]=ar[gr]=ar[Oe]=ar[fe]=ar[vn]=ar[Et]=ar[va]=ar[wn]=ar[De]=ar[je]=ar[yt]=ar[vt]=ar[Ar]=ar[wt]=ar[Rr]=ar[Nn]=ar[So]=ar[qt]=ar[on]=ar[ei]=!0,ar[Re]=ar[Ke]=ar[$t]=!1;var V2={\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"},z2={"&":"&","<":"<",">":">",'"':""","'":"'"},G2={"&":"&","<":"<",">":">",""":'"',"'":"'"},Y2={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},W2=parseFloat,X2=parseInt,p0=typeof global=="object"&&global&&global.Object===Object&&global,J2=typeof self=="object"&&self&&self.Object===Object&&self,zr=p0||J2||Function("return this")(),Vh=typeof Bh=="object"&&Bh&&!Bh.nodeType&&Bh,Sa=Vh&&typeof Gp=="object"&&Gp&&!Gp.nodeType&&Gp,m0=Sa&&Sa.exports===Vh,zh=m0&&p0.process,Rs=function(){try{var ce=Sa&&Sa.require&&Sa.require("util").types;return ce||zh&&zh.binding&&zh.binding("util")}catch{}}(),g0=Rs&&Rs.isArrayBuffer,v0=Rs&&Rs.isDate,w0=Rs&&Rs.isMap,y0=Rs&&Rs.isRegExp,E0=Rs&&Rs.isSet,b0=Rs&&Rs.isTypedArray;function ls(ce,Ae,ge){switch(ge.length){case 0:return ce.call(Ae);case 1:return ce.call(Ae,ge[0]);case 2:return ce.call(Ae,ge[0],ge[1]);case 3:return ce.call(Ae,ge[0],ge[1],ge[2])}return ce.apply(Ae,ge)}function Z2(ce,Ae,ge,Ye){for(var pt=-1,Lt=ce==null?0:ce.length;++pt-1}function de(ce,Ae,ge){for(var Ye=-1,pt=ce==null?0:ce.length;++Ye-1;);return ge}function td(ce,Ae){for(var ge=ce.length;ge--&&Ou(Ae,ce[ge],0)>-1;);return ge}function rd(ce,Ae){for(var ge=ce.length,Ye=0;ge--;)ce[ge]===Ae&&++Ye;return Ye}var Q2=Wh(V2),D0=Wh(z2);function ev(ce){return"\\"+Y2[ce]}function F0(ce,Ae){return ce==null?e:ce[Ae]}function Lu(ce){return zc.test(ce)}function tv(ce){return j2.test(ce)}function rv(ce){for(var Ae,ge=[];!(Ae=ce.next()).done;)ge.push(Ae.value);return ge}function fn(ce){var Ae=-1,ge=Array(ce.size);return ce.forEach(function(Ye,pt){ge[++Ae]=[pt,Ye]}),ge}function Yc(ce,Ae){return function(ge){return ce(Ae(ge))}}function An(ce,Ae){for(var ge=-1,Ye=ce.length,pt=0,Lt=[];++ge-1}function rP(c,h){var b=this.__data__,T=L0(b,c);return T<0?(++this.size,b.push([c,h])):b[T][1]=h,this}Ia.prototype.clear=Z$,Ia.prototype.delete=Q$,Ia.prototype.get=eP,Ia.prototype.has=tP,Ia.prototype.set=rP;function $a(c){var h=-1,b=c==null?0:c.length;for(this.clear();++h=h?c:h)),c}function Si(c,h,b,T,K,Z){var re,ie=h&f,he=h&m,Ie=h&p;if(b&&(re=K?b(c,T,K,Z):b(c)),re!==e)return re;if(!Cr(c))return c;var $e=Ct(c);if($e){if(re=ox(c),!ie)return Os(c,re)}else{var Te=qn(c),qe=Te==Ke||Te==Qe;if(qu(c))return H6(c,ie);if(Te==vt||Te==we||qe&&!K){if(re=he||qe?{}:i3(c),!ie)return he?WP(c,wP(re,c)):YP(c,g6(re,c))}else{if(!ar[Te])return K?c:{};re=ax(c,Te,ie)}}Z||(Z=new Mi);var Ze=Z.get(c);if(Ze)return Ze;Z.set(c,re),R3(c)?c.forEach(function(ct){re.add(Si(ct,h,b,ct,c,Z))}):x3(c)&&c.forEach(function(ct,Rt){re.set(Rt,Si(ct,h,b,Rt,c,Z))});var ht=Ie?he?Rv:Tv:he?Ls:hn,Bt=$e?e:ht(c);return U(Bt||c,function(ct,Rt){Bt&&(Rt=ct,ct=c[Rt]),hd(re,Rt,Si(ct,h,b,Rt,c,Z))}),re}function yP(c){var h=hn(c);return function(b){return v6(b,c,h)}}function v6(c,h,b){var T=b.length;if(c==null)return!T;for(c=er(c);T--;){var K=b[T],Z=h[K],re=c[K];if(re===e&&!(K in c)||!Z(re))return!1}return!0}function w6(c,h,b){if(typeof c!="function")throw new ks(i);return yd(function(){c.apply(e,b)},h)}function dd(c,h,b,T){var K=-1,Z=ku,re=!0,ie=c.length,he=[],Ie=h.length;if(!ie)return he;b&&(h=ir(h,bn(b))),T?(Z=de,re=!1):h.length>=r&&(Z=Ca,re=!1,h=new Zc(h));e:for(;++KK?0:K+b),T=T===e||T>K?K:_t(T),T<0&&(T+=K),T=b>T?0:O3(T);b0&&b(ie)?h>1?Sn(ie,h-1,b,T,K):Io(K,ie):T||(K[K.length]=ie)}return K}var mv=z6(),b6=z6(!0);function xo(c,h){return c&&mv(c,h,hn)}function gv(c,h){return c&&b6(c,h,hn)}function H0(c,h){return Wr(h,function(b){return Ra(c[b])})}function el(c,h){h=Mu(h,c);for(var b=0,T=h.length;c!=null&&bh}function AP(c,h){return c!=null&&Yt.call(c,h)}function SP(c,h){return c!=null&&h in er(c)}function CP(c,h,b){return c>=jn(h,b)&&c=120&&$e.length>=120)?new Zc(re&&$e):e}$e=c[0];var Te=-1,qe=ie[0];e:for(;++Te-1;)ie!==c&&cf.call(ie,he,1),cf.call(c,he,1);return c}function x6(c,h){for(var b=c?h.length:0,T=b-1;b--;){var K=h[b];if(b==T||K!==Z){var Z=K;Ta(K)?cf.call(c,K,1):Dv(c,K)}}return c}function Sv(c,h){return c+ye(h6()*(h-c+1))}function NP(c,h,b,T){for(var K=-1,Z=Xr(me((h-c)/(b||1)),0),re=ge(Z);Z--;)re[T?Z:++K]=c,c+=b;return re}function Cv(c,h){var b="";if(!c||h<1||h>q)return b;do h%2&&(b+=c),h=ye(h/2),h&&(c+=c);while(h);return b}function Pt(c,h){return Mv(u3(c,h,Us),c+"")}function LP(c){return m6(wf(c))}function UP(c,h){var b=wf(c);return J0(b,Qc(h,0,b.length))}function gd(c,h,b,T){if(!Cr(c))return c;h=Mu(h,c);for(var K=-1,Z=h.length,re=Z-1,ie=c;ie!=null&&++KK?0:K+h),b=b>K?K:b,b<0&&(b+=K),K=h>b?0:b-h>>>0,h>>>=0;for(var Z=ge(K);++T>>1,re=c[Z];re!==null&&!ii(re)&&(b?re<=h:re=r){var Ie=h?null:QP(c);if(Ie)return _a(Ie);re=!1,K=Ca,he=new Zc}else he=h?[]:ie;e:for(;++T=T?c:Ci(c,h,b)}var U6=W||function(c){return zr.clearTimeout(c)};function H6(c,h){if(h)return c.slice();var b=c.length,T=T0?T0(b):new c.constructor(b);return c.copy(T),T}function $v(c){var h=new c.constructor(c.byteLength);return new af(h).set(new af(c)),h}function KP(c,h){var b=h?$v(c.buffer):c.buffer;return new c.constructor(b,c.byteOffset,c.byteLength)}function VP(c){var h=new c.constructor(c.source,is.exec(c));return h.lastIndex=c.lastIndex,h}function zP(c){return fd?er(fd.call(c)):{}}function M6(c,h){var b=h?$v(c.buffer):c.buffer;return new c.constructor(b,c.byteOffset,c.length)}function j6(c,h){if(c!==h){var b=c!==e,T=c===null,K=c===c,Z=ii(c),re=h!==e,ie=h===null,he=h===h,Ie=ii(h);if(!ie&&!Ie&&!Z&&c>h||Z&&re&&he&&!ie&&!Ie||T&&re&&he||!b&&he||!K)return 1;if(!T&&!Z&&!Ie&&c=ie)return he;var Ie=b[T];return he*(Ie=="desc"?-1:1)}}return c.index-h.index}function q6(c,h,b,T){for(var K=-1,Z=c.length,re=b.length,ie=-1,he=h.length,Ie=Xr(Z-re,0),$e=ge(he+Ie),Te=!T;++ie1?b[K-1]:e,re=K>2?b[2]:e;for(Z=c.length>3&&typeof Z=="function"?(K--,Z):e,re&&ps(b[0],b[1],re)&&(Z=K<3?e:Z,K=1),h=er(h);++T-1?K[Z?h[re]:re]:e}}function W6(c){return xa(function(h){var b=h.length,T=b,K=Ai.prototype.thru;for(c&&h.reverse();T--;){var Z=h[T];if(typeof Z!="function")throw new ks(i);if(K&&!re&&W0(Z)=="wrapper")var re=new Ai([],!0)}for(T=re?T:b;++T1&&Ut.reverse(),$e&&heie))return!1;var Ie=Z.get(c),$e=Z.get(h);if(Ie&&$e)return Ie==h&&$e==c;var Te=-1,qe=!0,Ze=b&v?new Zc:e;for(Z.set(c,h),Z.set(h,c);++Te1?"& ":"")+h[T],h=h.join(b>2?", ":" "),c.replace(Xe,`{ /* [wrapped with `+h+`] */ `)}function cx(c){return Ct(c)||nl(c)||!!(lf&&c&&c[lf])}function Ta(c,h){var b=typeof c;return h=h??q,!!h&&(b=="number"||b!="symbol"&&En.test(c))&&c>-1&&c%1==0&&c0){if(++h>=R)return arguments[0]}else h=0;return c.apply(e,arguments)}}function J0(c,h){var b=-1,T=c.length,K=T-1;for(h=h===e?T:h;++b1?c[h-1]:e;return b=typeof b=="function"?(c.pop(),b):e,E3(c,b)});function b3(c){var h=X(c);return h.__chain__=!0,h}function ET(c,h){return h(c),c}function Z0(c,h){return h(c)}var bT=xa(function(c){var h=c.length,b=h?c[0]:0,T=this.__wrapped__,K=function(Z){return pv(Z,c)};return h>1||this.__actions__.length||!(T instanceof Ot)||!Ta(b)?this.thru(K):(T=T.slice(b,+b+(h?1:0)),T.__actions__.push({func:Z0,args:[K],thisArg:e}),new Ai(T,this.__chain__).thru(function(Z){return h&&!Z.length&&Z.push(e),Z}))});function AT(){return b3(this)}function ST(){return new Ai(this.value(),this.__chain__)}function CT(){this.__values__===e&&(this.__values__=k3(this.value()));var c=this.__index__>=this.__values__.length,h=c?e:this.__values__[this.__index__++];return{done:c,value:h}}function _T(){return this}function DT(c){for(var h,b=this;b instanceof N0;){var T=p3(b);T.__index__=0,T.__values__=e,h?K.__wrapped__=T:h=T;var K=T;b=b.__wrapped__}return K.__wrapped__=c,h}function FT(){var c=this.__wrapped__;if(c instanceof Ot){var h=c;return this.__actions__.length&&(h=new Ot(this)),h=h.reverse(),h.__actions__.push({func:Z0,args:[jv],thisArg:e}),new Ai(h,this.__chain__)}return this.thru(jv)}function BT(){return N6(this.__wrapped__,this.__actions__)}var IT=K0(function(c,h,b){Yt.call(c,b)?++c[b]:Po(c,b,1)});function $T(c,h,b){var T=Ct(c)?Gc:EP;return b&&ps(c,h,b)&&(h=e),T(c,lt(h,3))}function PT(c,h){var b=Ct(c)?Wr:E6;return b(c,lt(h,3))}var xT=Y6(m3),TT=Y6(g3);function RT(c,h){return Sn(Q0(c,h),1)}function kT(c,h){return Sn(Q0(c,h),O)}function OT(c,h,b){return b=b===e?1:_t(b),Sn(Q0(c,h),b)}function A3(c,h){var b=Ct(c)?U:Uu;return b(c,lt(h,3))}function S3(c,h){var b=Ct(c)?St:y6;return b(c,lt(h,3))}var NT=K0(function(c,h,b){Yt.call(c,b)?c[b].push(h):Po(c,b,[h])});function LT(c,h,b,T){c=Ns(c)?c:wf(c),b=b&&!T?_t(b):0;var K=c.length;return b<0&&(b=Xr(K+b,0)),s1(c)?b<=K&&c.indexOf(h,b)>-1:!!K&&Ou(c,h,b)>-1}var UT=Pt(function(c,h,b){var T=-1,K=typeof h=="function",Z=Ns(c)?ge(c.length):[];return Uu(c,function(re){Z[++T]=K?ls(h,re,b):pd(re,h,b)}),Z}),HT=K0(function(c,h,b){Po(c,b,h)});function Q0(c,h){var b=Ct(c)?ir:D6;return b(c,lt(h,3))}function MT(c,h,b,T){return c==null?[]:(Ct(h)||(h=h==null?[]:[h]),b=T?e:b,Ct(b)||(b=b==null?[]:[b]),$6(c,h,b))}var jT=K0(function(c,h,b){c[b?0:1].push(h)},function(){return[[],[]]});function qT(c,h,b){var T=Ct(c)?A0:Xh,K=arguments.length<3;return T(c,lt(h,4),b,K,Uu)}function KT(c,h,b){var T=Ct(c)?c6:Xh,K=arguments.length<3;return T(c,lt(h,4),b,K,y6)}function VT(c,h){var b=Ct(c)?Wr:E6;return b(c,r1(lt(h,3)))}function zT(c){var h=Ct(c)?m6:LP;return h(c)}function GT(c,h,b){(b?ps(c,h,b):h===e)?h=1:h=_t(h);var T=Ct(c)?mP:UP;return T(c,h)}function YT(c){var h=Ct(c)?gP:MP;return h(c)}function WT(c){if(c==null)return 0;if(Ns(c))return s1(c)?Da(c):c.length;var h=qn(c);return h==je||h==wt?c.size:Ev(c).length}function XT(c,h,b){var T=Ct(c)?wr:jP;return b&&ps(c,h,b)&&(h=e),T(c,lt(h,3))}var JT=Pt(function(c,h){if(c==null)return[];var b=h.length;return b>1&&ps(c,h[0],h[1])?h=[]:b>2&&ps(h[0],h[1],h[2])&&(h=[h[0]]),$6(c,Sn(h,1),[])}),e1=ne||function(){return zr.Date.now()};function ZT(c,h){if(typeof h!="function")throw new ks(i);return c=_t(c),function(){if(--c<1)return h.apply(this,arguments)}}function C3(c,h,b){return h=b?e:h,h=c&&h==null?c.length:h,Pa(c,H,e,e,e,e,h)}function _3(c,h){var b;if(typeof h!="function")throw new ks(i);return c=_t(c),function(){return--c>0&&(b=h.apply(this,arguments)),c<=1&&(h=e),b}}var Kv=Pt(function(c,h,b){var T=g;if(b.length){var K=An(b,gf(Kv));T|=F}return Pa(c,T,h,b,K)}),D3=Pt(function(c,h,b){var T=g|y;if(b.length){var K=An(b,gf(D3));T|=F}return Pa(h,T,c,b,K)});function F3(c,h,b){h=b?e:h;var T=Pa(c,E,e,e,e,e,e,h);return T.placeholder=F3.placeholder,T}function B3(c,h,b){h=b?e:h;var T=Pa(c,S,e,e,e,e,e,h);return T.placeholder=B3.placeholder,T}function I3(c,h,b){var T,K,Z,re,ie,he,Ie=0,$e=!1,Te=!1,qe=!0;if(typeof c!="function")throw new ks(i);h=Di(h)||0,Cr(b)&&($e=!!b.leading,Te="maxWait"in b,Z=Te?Xr(Di(b.maxWait)||0,h):Z,qe="trailing"in b?!!b.trailing:qe);function Ze(Ur){var Ki=T,Oa=K;return T=K=e,Ie=Ur,re=c.apply(Oa,Ki),re}function ht(Ur){return Ie=Ur,ie=yd(Rt,h),$e?Ze(Ur):re}function Bt(Ur){var Ki=Ur-he,Oa=Ur-Ie,W3=h-Ki;return Te?jn(W3,Z-Oa):W3}function ct(Ur){var Ki=Ur-he,Oa=Ur-Ie;return he===e||Ki>=h||Ki<0||Te&&Oa>=Z}function Rt(){var Ur=e1();if(ct(Ur))return Ut(Ur);ie=yd(Rt,Bt(Ur))}function Ut(Ur){return ie=e,qe&&T?Ze(Ur):(T=K=e,re)}function oi(){ie!==e&&U6(ie),Ie=0,T=he=K=ie=e}function gs(){return ie===e?re:Ut(e1())}function ai(){var Ur=e1(),Ki=ct(Ur);if(T=arguments,K=this,he=Ur,Ki){if(ie===e)return ht(he);if(Te)return U6(ie),ie=yd(Rt,h),Ze(he)}return ie===e&&(ie=yd(Rt,h)),re}return ai.cancel=oi,ai.flush=gs,ai}var QT=Pt(function(c,h){return w6(c,1,h)}),eR=Pt(function(c,h,b){return w6(c,Di(h)||0,b)});function tR(c){return Pa(c,C)}function t1(c,h){if(typeof c!="function"||h!=null&&typeof h!="function")throw new ks(i);var b=function(){var T=arguments,K=h?h.apply(this,T):T[0],Z=b.cache;if(Z.has(K))return Z.get(K);var re=c.apply(this,T);return b.cache=Z.set(K,re)||Z,re};return b.cache=new(t1.Cache||$a),b}t1.Cache=$a;function r1(c){if(typeof c!="function")throw new ks(i);return function(){var h=arguments;switch(h.length){case 0:return!c.call(this);case 1:return!c.call(this,h[0]);case 2:return!c.call(this,h[0],h[1]);case 3:return!c.call(this,h[0],h[1],h[2])}return!c.apply(this,h)}}function rR(c){return _3(2,c)}var nR=qP(function(c,h){h=h.length==1&&Ct(h[0])?ir(h[0],bn(lt())):ir(Sn(h,1),bn(lt()));var b=h.length;return Pt(function(T){for(var K=-1,Z=jn(T.length,b);++K=h}),nl=S6(function(){return arguments}())?S6:function(c){return Ir(c)&&Yt.call(c,"callee")&&!or.call(c,"callee")},Ct=ge.isArray,wR=g0?bn(g0):DP;function Ns(c){return c!=null&&n1(c.length)&&!Ra(c)}function Lr(c){return Ir(c)&&Ns(c)}function yR(c){return c===!0||c===!1||Ir(c)&&ds(c)==Oe}var qu=Nr||nw,ER=v0?bn(v0):FP;function bR(c){return Ir(c)&&c.nodeType===1&&!Ed(c)}function AR(c){if(c==null)return!0;if(Ns(c)&&(Ct(c)||typeof c=="string"||typeof c.splice=="function"||qu(c)||vf(c)||nl(c)))return!c.length;var h=qn(c);if(h==je||h==wt)return!c.size;if(wd(c))return!Ev(c).length;for(var b in c)if(Yt.call(c,b))return!1;return!0}function SR(c,h){return md(c,h)}function CR(c,h,b){b=typeof b=="function"?b:e;var T=b?b(c,h):e;return T===e?md(c,h,e,b):!!T}function zv(c){if(!Ir(c))return!1;var h=ds(c);return h==Re||h==Se||typeof c.message=="string"&&typeof c.name=="string"&&!Ed(c)}function _R(c){return typeof c=="number"&&f6(c)}function Ra(c){if(!Cr(c))return!1;var h=ds(c);return h==Ke||h==Qe||h==Le||h==br}function P3(c){return typeof c=="number"&&c==_t(c)}function n1(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=q}function Cr(c){var h=typeof c;return c!=null&&(h=="object"||h=="function")}function Ir(c){return c!=null&&typeof c=="object"}var x3=w0?bn(w0):IP;function DR(c,h){return c===h||yv(c,h,Ov(h))}function FR(c,h,b){return b=typeof b=="function"?b:e,yv(c,h,Ov(h),b)}function BR(c){return T3(c)&&c!=+c}function IR(c){if(hx(c))throw new pt(n);return C6(c)}function $R(c){return c===null}function PR(c){return c==null}function T3(c){return typeof c=="number"||Ir(c)&&ds(c)==yt}function Ed(c){if(!Ir(c)||ds(c)!=vt)return!1;var h=uf(c);if(h===null)return!0;var b=Yt.call(h,"constructor")&&h.constructor;return typeof b=="function"&&b instanceof b&&Fa.call(b)==uv}var Gv=y0?bn(y0):$P;function xR(c){return P3(c)&&c>=-q&&c<=q}var R3=E0?bn(E0):PP;function s1(c){return typeof c=="string"||!Ct(c)&&Ir(c)&&ds(c)==Rr}function ii(c){return typeof c=="symbol"||Ir(c)&&ds(c)==Nn}var vf=b0?bn(b0):xP;function TR(c){return c===e}function RR(c){return Ir(c)&&qn(c)==$t}function kR(c){return Ir(c)&&ds(c)==tt}var OR=Y0(bv),NR=Y0(function(c,h){return c<=h});function k3(c){if(!c)return[];if(Ns(c))return s1(c)?hs(c):Os(c);if(Xc&&c[Xc])return rv(c[Xc]());var h=qn(c),b=h==je?fn:h==wt?_a:wf;return b(c)}function ka(c){if(!c)return c===0?c:0;if(c=Di(c),c===O||c===-O){var h=c<0?-1:1;return h*J}return c===c?c:0}function _t(c){var h=ka(c),b=h%1;return h===h?b?h-b:h:0}function O3(c){return c?Qc(_t(c),0,ee):0}function Di(c){if(typeof c=="number")return c;if(ii(c))return Y;if(Cr(c)){var h=typeof c.valueOf=="function"?c.valueOf():c;c=Cr(h)?h+"":h}if(typeof c!="string")return c===0?c:+c;c=Qh(c);var b=yn.test(c);return b||Dr.test(c)?X2(c.slice(2),b?2:8):yi.test(c)?Y:+c}function N3(c){return To(c,Ls(c))}function LR(c){return c?Qc(_t(c),-q,q):c===0?c:0}function tr(c){return c==null?"":si(c)}var UR=pf(function(c,h){if(wd(h)||Ns(h)){To(h,hn(h),c);return}for(var b in h)Yt.call(h,b)&&hd(c,b,h[b])}),L3=pf(function(c,h){To(h,Ls(h),c)}),U3=pf(function(c,h,b,T){To(h,Ls(h),c,T)}),Yv=pf(function(c,h,b,T){To(h,hn(h),c,T)}),HR=xa(pv);function MR(c,h){var b=df(c);return h==null?b:g6(b,h)}var jR=Pt(function(c,h){c=er(c);var b=-1,T=h.length,K=T>2?h[2]:e;for(K&&ps(h[0],h[1],K)&&(T=1);++b1),Z}),To(c,Rv(c),b),T&&(b=Si(b,f|m|p,ex));for(var K=h.length;K--;)Dv(b,h[K]);return b});function ok(c,h){return M3(c,r1(lt(h)))}var ak=xa(function(c,h){return c==null?{}:kP(c,h)});function M3(c,h){if(c==null)return{};var b=ir(Rv(c),function(T){return[T]});return h=lt(h),P6(c,b,function(T,K){return h(T,K[0])})}function uk(c,h,b){h=Mu(h,c);var T=-1,K=h.length;for(K||(K=1,c=e);++Th){var T=c;c=h,h=T}if(b||c%1||h%1){var K=h6();return jn(c+K*(h-c+W2("1e-"+((K+"").length-1))),h)}return Sv(c,h)}var yk=mf(function(c,h,b){return h=h.toLowerCase(),c+(b?K3(h):h)});function K3(c){return Jv(tr(c).toLowerCase())}function V3(c){return c=tr(c),c&&c.replace(Un,Q2).replace(cs,"")}function Ek(c,h,b){c=tr(c),h=si(h);var T=c.length;b=b===e?T:Qc(_t(b),0,T);var K=b;return b-=h.length,b>=0&&c.slice(b,K)==h}function bk(c){return c=tr(c),c&&xs.test(c)?c.replace(wi,D0):c}function Ak(c){return c=tr(c),c&&Hc.test(c)?c.replace(ya,"\\$&"):c}var Sk=mf(function(c,h,b){return c+(b?"-":"")+h.toLowerCase()}),Ck=mf(function(c,h,b){return c+(b?" ":"")+h.toLowerCase()}),_k=G6("toLowerCase");function Dk(c,h,b){c=tr(c),h=_t(h);var T=h?Da(c):0;if(!h||T>=h)return c;var K=(h-T)/2;return G0(ye(K),b)+c+G0(me(K),b)}function Fk(c,h,b){c=tr(c),h=_t(h);var T=h?Da(c):0;return h&&T>>0,b?(c=tr(c),c&&(typeof h=="string"||h!=null&&!Gv(h))&&(h=si(h),!h&&Lu(c))?ju(hs(c),0,b):c.split(h,b)):[]}var Rk=mf(function(c,h,b){return c+(b?" ":"")+Jv(h)});function kk(c,h,b){return c=tr(c),b=b==null?0:Qc(_t(b),0,c.length),h=si(h),c.slice(b,b+h.length)==h}function Ok(c,h,b){var T=X.templateSettings;b&&ps(c,h,b)&&(h=e),c=tr(c),h=Yv({},h,T,e3);var K=Yv({},h.imports,T.imports,e3),Z=hn(K),re=ed(K,Z);U(Z,function(ct){if(At.test(ct))throw new pt(s)});var ie,he,Ie=0,$e=h.interpolate||Fo,Te="__p += '",qe=od((h.escape||Fo).source+"|"+$e.source+"|"+($e===wa?nr:Fo).source+"|"+(h.evaluate||Fo).source+"|$","g"),Ze="//# sourceURL="+(Yt.call(h,"sourceURL")?(h.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++K2+"]")+` `;c.replace(qe,function(ct,Rt,Ut,oi,gs,ai){return Ut||(Ut=oi),Te+=c.slice(Ie,ai).replace(Mc,ev),Rt&&(ie=!0,Te+=`' + __e(`+Rt+`) + '`),gs&&(he=!0,Te+=`'; `+gs+`; __p += '`),Ut&&(Te+=`' + ((__t = (`+Ut+`)) == null ? '' : __t) + '`),Ie=ai+ct.length,ct}),Te+=`'; `;var ht=Yt.call(h,"variable")&&h.variable;if(!ht)Te=`with (obj) { `+Te+` } `;else if(At.test(ht))throw new pt(o);Te=(he?Te.replace(Pu,""):Te).replace(Co,"$1").replace(Nc,"$1;"),Te="function("+(ht||"obj")+`) { `+(ht?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(ie?", __e = _.escape":"")+(he?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+Te+`return __p }`;var Bt=G3(function(){return Lt(Z,Ze+"return "+Te).apply(e,re)});if(Bt.source=Te,zv(Bt))throw Bt;return Bt}function Nk(c){return tr(c).toLowerCase()}function Lk(c){return tr(c).toUpperCase()}function Uk(c,h,b){if(c=tr(c),c&&(b||h===e))return Qh(c);if(!c||!(h=si(h)))return c;var T=hs(c),K=hs(h),Z=_0(T,K),re=td(T,K)+1;return ju(T,Z,re).join("")}function Hk(c,h,b){if(c=tr(c),c&&(b||h===e))return c.slice(0,nd(c)+1);if(!c||!(h=si(h)))return c;var T=hs(c),K=td(T,hs(h))+1;return ju(T,0,K).join("")}function Mk(c,h,b){if(c=tr(c),c&&(b||h===e))return c.replace(ue,"");if(!c||!(h=si(h)))return c;var T=hs(c),K=_0(T,hs(h));return ju(T,K).join("")}function jk(c,h){var b=I,T=L;if(Cr(h)){var K="separator"in h?h.separator:K;b="length"in h?_t(h.length):b,T="omission"in h?si(h.omission):T}c=tr(c);var Z=c.length;if(Lu(c)){var re=hs(c);Z=re.length}if(b>=Z)return c;var ie=b-Da(T);if(ie<1)return T;var he=re?ju(re,0,ie).join(""):c.slice(0,ie);if(K===e)return he+T;if(re&&(ie+=he.length-ie),Gv(K)){if(c.slice(ie).search(K)){var Ie,$e=he;for(K.global||(K=od(K.source,tr(is.exec(K))+"g")),K.lastIndex=0;Ie=K.exec($e);)var Te=Ie.index;he=he.slice(0,Te===e?ie:Te)}}else if(c.indexOf(si(K),ie)!=ie){var qe=he.lastIndexOf(K);qe>-1&&(he=he.slice(0,qe))}return he+T}function qk(c){return c=tr(c),c&&Gt.test(c)?c.replace(_o,$0):c}var Kk=mf(function(c,h,b){return c+(b?" ":"")+h.toUpperCase()}),Jv=G6("toUpperCase");function z3(c,h,b){return c=tr(c),h=b?e:h,h===e?tv(c)?ov(c):ut(c):c.match(h)||[]}var G3=Pt(function(c,h){try{return ls(c,e,h)}catch(b){return zv(b)?b:new pt(b)}}),Vk=xa(function(c,h){return U(h,function(b){b=ji(b),Po(c,b,Kv(c[b],c))}),c});function zk(c){var h=c==null?0:c.length,b=lt();return c=h?ir(c,function(T){if(typeof T[1]!="function")throw new ks(i);return[b(T[0]),T[1]]}):[],Pt(function(T){for(var K=-1;++Kq)return[];var b=ee,T=jn(c,ee);h=lt(h),c-=ee;for(var K=Zh(T,h);++b0||h<0)?new Ot(b):(c<0?b=b.takeRight(-c):c&&(b=b.drop(c)),h!==e&&(h=_t(h),b=h<0?b.dropRight(-h):b.take(h-c)),b)},Ot.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},Ot.prototype.toArray=function(){return this.take(ee)},xo(Ot.prototype,function(c,h){var b=/^(?:filter|find|map|reject)|While$/.test(h),T=/^(?:head|last)$/.test(h),K=X[T?"take"+(h=="last"?"Right":""):h],Z=T||/^find/.test(h);K&&(X.prototype[h]=function(){var re=this.__wrapped__,ie=T?[1]:arguments,he=re instanceof Ot,Ie=ie[0],$e=he||Ct(re),Te=function(Rt){var Ut=K.apply(X,Io([Rt],ie));return T&&qe?Ut[0]:Ut};$e&&b&&typeof Ie=="function"&&Ie.length!=1&&(he=$e=!1);var qe=this.__chain__,Ze=!!this.__actions__.length,ht=Z&&!qe,Bt=he&&!Ze;if(!Z&&$e){re=Bt?re:new Ot(this);var ct=c.apply(re,ie);return ct.__actions__.push({func:Z0,args:[Te],thisArg:e}),new Ai(ct,qe)}return ht&&Bt?c.apply(this,ie):(ct=this.thru(Te),ht?T?ct.value()[0]:ct.value():ct)})}),U(["pop","push","shift","sort","splice","unshift"],function(c){var h=Wc[c],b=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",T=/^(?:pop|shift)$/.test(c);X.prototype[c]=function(){var K=arguments;if(T&&!this.__chain__){var Z=this.value();return h.apply(Ct(Z)?Z:[],K)}return this[b](function(re){return h.apply(Ct(re)?re:[],K)})}}),xo(Ot.prototype,function(c,h){var b=X[h];if(b){var T=b.name+"";Yt.call(hf,T)||(hf[T]=[]),hf[T].push({name:h,func:b})}}),hf[V0(e,y).name]=[{name:"wrapper",func:e}],Ot.prototype.clone=K$,Ot.prototype.reverse=V$,Ot.prototype.value=z$,X.prototype.at=bT,X.prototype.chain=AT,X.prototype.commit=ST,X.prototype.next=CT,X.prototype.plant=DT,X.prototype.reverse=FT,X.prototype.toJSON=X.prototype.valueOf=X.prototype.value=BT,X.prototype.first=X.prototype.head,Xc&&(X.prototype[Xc]=_T),X},Hi=sd();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(zr._=Hi,define(function(){return Hi})):Sa?((Sa.exports=Hi)._=Hi,Vh._=Hi):zr._=Hi}).call(Bh)});var $2=Ce((fye,o7)=>{"use strict";var hye=P(x()),LZ=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])},_S=class e extends Error{constructor(t,r,n){super(t),LZ(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:o,text:s})=>({source:o,text:s.split(/\r\n|\n|\r/g)}));function n(o,s,a=""){let u="",l=r.find(({source:m})=>m===o.source),f=o.start;if(l){let m=o.end,p=l.text[f.line-1],v=(f.line===m.line?m.column:p.length+1)-f.column||1;a&&(u+=` note: ${a}`),u+=` --> ${o.source}:${f.line}:${f.column} ${"".padEnd(s)} | ${f.line.toString().padStart(s)} | ${p} ${"".padEnd(s)} | ${"".padEnd(f.column-1)}${"".padEnd(v,"^")}`}else u+=` at ${o.source}:${f.line}:${f.column}`,a&&(u+=`: ${a}`);return u}function i(o,s,a,u=[]){let l;a?l=u.reduce((m,{location:p})=>Math.max(m,p.start.line),a.start.line):l=Math.max.apply(null,u.map(m=>m.location.start.line)),l=l.toString().length;let f=`${o}: ${s}`;a&&(f+=n(a,l));for(let m of u)f+=n(m.location,l,m.message);return f}return this.problems.filter(o=>o[0]!=="info").map(o=>i(...o)).join(` `)}};o7.exports=_S});var Ni=Ce((dye,a7)=>{"use strict";var pye=P(x()),UZ={build(e){function t(s,...a){return e[s.type](s,...a)}function r(){}function n(s,...a){return t(s.expression,...a)}function i(s){return function(a,...u){a[s].forEach(l=>t(l,...u))}}let o={grammar(s,...a){s.topLevelInitializer&&t(s.topLevelInitializer,...a),s.initializer&&t(s.initializer,...a),s.rules.forEach(u=>t(u,...a))},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(o).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||(e[s]=o[s])}),t}};a7.exports=UZ});var Tc=Ce((mye,c7)=>{"use strict";var gye=P(x()),HZ=Ni(),u7={findRule(e,t){for(let r=0;r{"use strict";var wye=P(x()),MZ={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};l7.exports=MZ});var FS=Ce((yye,f7)=>{"use strict";var Eye=P(x()),jZ=Ni(),qZ=Tc(),KZ=$2(),u0=1,Ql=0,c0=-1;function P2(e){function t(s){return s.match=Ql}function r(s){return o(s.expression),s.match=u0}function n(s){return s.match=o(s.expression)}function i(s,a){let u=s.length,l=0,f=0;for(let m=0;m0?c0:Ql}let o=jZ.build({rule(s){let a,u=0;if(typeof s.match>"u"){s.match=Ql;do if(a=s.match,s.match=o(s.expression),++u>6)throw new KZ("Infinity cycle detected when trying to evaluate node match result",s.location);while(a!==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=-o(s.expression)},optional:r,zero_or_more:r,one_or_more:n,group:n,semantic_and:t,semantic_not:t,rule_ref(s){let a=qZ.findRule(e,s.name);return s.match=o(a)},literal(s){let a=s.value.length===0?u0:Ql;return s.match=a},class(s){let a=s.parts.length===0?c0:Ql;return s.match=a},any:t});o(e)}P2.ALWAYS_MATCH=u0;P2.SOMETIMES_MATCH=Ql;P2.NEVER_MATCH=c0;f7.exports=P2});var d7=Ce((bye,h7)=>{"use strict";var Aye=P(x()),VZ=Tc(),Ge=DS(),zZ=Ni(),{ALWAYS_MATCH:Uh,SOMETIMES_MATCH:BS,NEVER_MATCH:IS}=FS();function GZ(e){let t=[],r=[],n=[],i=[];function o(E){let S=t.indexOf(E);return S===-1?t.push(E)-1:S}function s(E){let S={value:E.parts,inverted:E.inverted,ignoreCase:E.ignoreCase},F=JSON.stringify(S),_=r.findIndex(H=>JSON.stringify(H)===F);return _===-1?r.push(S)-1:_}function a(E){let S=JSON.stringify(E),F=n.findIndex(_=>JSON.stringify(_)===S);return F===-1?n.push(E)-1:F}function u(E,S,F){let _={predicate:E,params:S,body:F.code,location:F.codeLocation},H=JSON.stringify(_),V=i.findIndex(C=>JSON.stringify(C)===H);return V===-1?i.push(_)-1:V}function l(E){let S={};return Object.keys(E).forEach(F=>{S[F]=E[F]}),S}function f(E,...S){return E.concat(...S)}function m(E,S,F,_){return E===Uh?F:E===IS?_:S.concat([F.length,_.length],F,_)}function p(E,S){return E.concat([S.length],S)}function d(E,S,F,_){let H=Object.keys(F).map(V=>_-F[V]);return[Ge.CALL,E,S,H.length].concat(H)}function v(E,S,F){let _=E.match|0;return f([Ge.PUSH_CURR_POS],[Ge.SILENT_FAILS_ON],w(E,{sp:F.sp+1,env:l(F.env),action:null}),[Ge.SILENT_FAILS_OFF],m(S?-_:_,[S?Ge.IF_ERROR:Ge.IF_NOT_ERROR],f([Ge.POP],[S?Ge.POP:Ge.POP_CURR_POS],[Ge.PUSH_UNDEFINED]),f([Ge.POP],[S?Ge.POP_CURR_POS:Ge.POP],[Ge.PUSH_FAILED])))}function g(E,S,F){let _=u(!0,Object.keys(F.env),E);return f([Ge.UPDATE_SAVED_POS],d(_,0,F.env,F.sp),m(E.match|0,[Ge.IF],f([Ge.POP],S?[Ge.PUSH_FAILED]:[Ge.PUSH_UNDEFINED]),f([Ge.POP],S?[Ge.PUSH_UNDEFINED]:[Ge.PUSH_FAILED])))}function y(E){return p([Ge.WHILE_NOT_ERROR],f([Ge.APPEND],E))}let w=zZ.build({grammar(E){E.rules.forEach(w),E.literals=t,E.classes=r,E.expectations=n,E.functions=i},rule(E){E.bytecode=w(E.expression,{sp:-1,env:{},pluck:[],action:null})},named(E,S){let F=E.match|0,_=F===IS?null:a({type:"rule",value:E.name});return f([Ge.SILENT_FAILS_ON],w(E.expression,S),[Ge.SILENT_FAILS_OFF],m(F,[Ge.IF_ERROR],[Ge.FAIL,_],[]))},choice(E,S){function F(_,H){let V=_[0].match|0,C=w(_[0],{sp:H.sp,env:l(H.env),action:null});return V===Uh?C:f(C,_.length>1?m(BS,[Ge.IF_ERROR],f([Ge.POP],F(_.slice(1),H)),[]):[])}return F(E.alternatives,S)},action(E,S){let F=l(S.env),_=E.expression.type!=="sequence"||E.expression.elements.length===0,H=w(E.expression,{sp:S.sp+(_?1:0),env:F,action:E}),V=E.expression.match|0,C=_&&V!==IS?u(!1,Object.keys(F),E):null;return _?f([Ge.PUSH_CURR_POS],H,m(V,[Ge.IF_NOT_ERROR],f([Ge.LOAD_SAVED_POS,1],d(C,1,F,S.sp+2)),[]),[Ge.NIP]):H},sequence(E,S){function F(_,H){if(_.length>0){let V=E.elements.length-_.length+1;return f(w(_[0],{sp:H.sp,env:H.env,pluck:H.pluck,action:null}),m(_[0].match|0,[Ge.IF_NOT_ERROR],F(_.slice(1),{sp:H.sp+1,env:H.env,pluck:H.pluck,action:H.action}),f(V>1?[Ge.POP_N,V]:[Ge.POP],[Ge.POP_CURR_POS],[Ge.PUSH_FAILED])))}else{if(H.pluck.length>0)return f([Ge.PLUCK,E.elements.length+1,H.pluck.length],H.pluck.map(V=>H.sp-V));if(H.action){let V=u(!1,Object.keys(H.env),H.action);return f([Ge.LOAD_SAVED_POS,E.elements.length],d(V,E.elements.length+1,H.env,H.sp))}else return f([Ge.WRAP,E.elements.length],[Ge.NIP])}}return f([Ge.PUSH_CURR_POS],F(E.elements,{sp:S.sp+1,env:S.env,pluck:[],action:S.action}))},labeled(E,S){let F=S.env,_=E.label,H=S.sp+1;return _&&(F=l(S.env),S.env[E.label]=H),E.pick&&S.pluck.push(H),w(E.expression,{sp:S.sp,env:F,action:null})},text(E,S){return f([Ge.PUSH_CURR_POS],w(E.expression,{sp:S.sp+1,env:l(S.env),action:null}),m(E.match|0,[Ge.IF_NOT_ERROR],f([Ge.POP],[Ge.TEXT]),[Ge.NIP]))},simple_and(E,S){return v(E.expression,!1,S)},simple_not(E,S){return v(E.expression,!0,S)},optional(E,S){return f(w(E.expression,{sp:S.sp,env:l(S.env),action:null}),m(-(E.expression.match|0),[Ge.IF_ERROR],f([Ge.POP],[Ge.PUSH_NULL]),[]))},zero_or_more(E,S){let F=w(E.expression,{sp:S.sp+1,env:l(S.env),action:null});return f([Ge.PUSH_EMPTY_ARRAY],F,y(F),[Ge.POP])},one_or_more(E,S){let F=w(E.expression,{sp:S.sp+1,env:l(S.env),action:null});return f([Ge.PUSH_EMPTY_ARRAY],F,m(E.expression.match|0,[Ge.IF_NOT_ERROR],f(y(F),[Ge.POP]),f([Ge.POP],[Ge.POP],[Ge.PUSH_FAILED])))},group(E,S){return w(E.expression,{sp:S.sp,env:l(S.env),action:null})},semantic_and(E,S){return g(E,!1,S)},semantic_not(E,S){return g(E,!0,S)},rule_ref(E){return[Ge.RULE,VZ.indexOfRule(e,E.name)]},literal(E){if(E.value.length>0){let S=E.match|0,_=S===BS||S===Uh&&!E.ignoreCase?o(E.ignoreCase?E.value.toLowerCase():E.value):null,H=S!==Uh?a({type:"literal",value:E.value,ignoreCase:E.ignoreCase}):null;return m(S,E.ignoreCase?[Ge.MATCH_STRING_IC,_]:[Ge.MATCH_STRING,_],E.ignoreCase?[Ge.ACCEPT_N,E.value.length]:[Ge.ACCEPT_STRING,_],[Ge.FAIL,H])}return[Ge.PUSH_EMPTY_STRING]},class(E){let S=E.match|0,F=S===BS?s(E):null,_=S!==Uh?a({type:"class",value:E.parts,inverted:E.inverted,ignoreCase:E.ignoreCase}):null;return m(S,[Ge.MATCH_CHAR_CLASS,F],[Ge.ACCEPT_N,1],[Ge.FAIL,_])},any(E){let S=E.match|0,F=S!==Uh?a({type:"any"}):null;return m(S,[Ge.MATCH_ANY],[Ge.ACCEPT_N,1],[Ge.FAIL,F])}});w(e)}h7.exports=GZ});var m7=Ce((Sye,p7)=>{"use strict";var Cye=P(x()),$S=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 o=this.sp;if(this.sp=i,n(),o!==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: "+o+", 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+").")}};p7.exports=$S});var PS=Ce((_ye,g7)=>{"use strict";var Dye=P(x());g7.exports="2.0.1"});var v7=Ce(x2=>{"use strict";var Bye=P(x());function Iu(e){return e.charCodeAt(0).toString(16).toUpperCase()}x2.hex=Iu;function YZ(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"+Iu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Iu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Iu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Iu(t))}x2.stringEscape=YZ;function WZ(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"+Iu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+Iu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+Iu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+Iu(t))}x2.regexpClassEscape=WZ});var E7=Ce(y7=>{var $ye=P(x()),w7="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");y7.encode=function(e){if(0<=e&&e{var xye=P(x()),XZ=E7(),b7=5,A7=1<>>=b7,i>0&&(n|=ZZ),r+=XZ.encode(n);while(i>0);return r}});var R2=Ce(kc=>{var Rye=P(x());function eQ(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}kc.getArg=eQ;var D7=function(){return!("__proto__"in Object.create(null))}();function F7(e){return e}function tQ(e){return B7(e)?"$"+e:e}kc.toSetString=D7?F7:tQ;function rQ(e){return B7(e)?e.slice(1):e}kc.fromSetString=D7?F7:rQ;function B7(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 _7(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function nQ(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=_7(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:_7(e.name,t.name)}kc.compareByGeneratedPositionsInflated=nQ;var xS="http:",l0=`${xS}//host`;function I7(e){return t=>{let r=f0(t),n=TS(t),i=new URL(t,n);e(i);let o=i.toString();return r==="absolute"?o:r==="scheme-relative"?o.slice(xS.length):r==="path-absolute"?o.slice(l0.length):RS(n,o)}}function Rc(e,t){return new URL(e,t).toString()}function sQ(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function TS(e){let t=e.split("..").length-1,r=sQ("p",e),n=`${l0}/`;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 oQ=I7(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),T2=I7(e=>{});kc.normalize=T2;function aQ(e,t){let r=f0(t),n=f0(e);if(e=oQ(e),r==="absolute")return Rc(t,void 0);if(n==="absolute")return Rc(t,e);if(r==="scheme-relative")return T2(t);if(n==="scheme-relative")return Rc(t,Rc(e,l0)).slice(xS.length);if(r==="path-absolute")return T2(t);if(n==="path-absolute")return Rc(t,Rc(e,l0)).slice(l0.length);let i=TS(t+e),o=Rc(t,Rc(e,i));return RS(i,o)}kc.join=aQ;function uQ(e,t){let r=cQ(e,t);return typeof r=="string"?r:T2(t)}kc.relative=uQ;function cQ(e,t){if(f0(e)!==f0(t))return null;let n=TS(e+t),i=new URL(e,n),o=new URL(t,n);try{new URL("",o.toString())}catch{return null}return o.protocol!==i.protocol||o.user!==i.user||o.password!==i.password||o.hostname!==i.hostname||o.port!==i.port?null:RS(i,o)}});var P7=Ce($7=>{var Oye=P(x()),kS=class e{constructor(){this._array=[],this._set=new Map}static fromArray(t,r){let n=new e;for(let i=0,o=t.length;i=0)return r;throw new Error('"'+t+'" is not in the set.')}at(t){if(t>=0&&t{var Lye=P(x()),x7=R2();function lQ(e,t){let r=e.generatedLine,n=t.generatedLine,i=e.generatedColumn,o=t.generatedColumn;return n>r||n==r&&o>=i||x7.compareByGeneratedPositionsInflated(e,t)<=0}var OS=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){lQ(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(x7.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};T7.MappingList=OS});var NS=Ce(k7=>{var Hye=P(x()),h0=C7(),Yr=R2(),k2=P7().ArraySet,fQ=R7().MappingList,O2=class e{constructor(t){t||(t={}),this._file=Yr.getArg(t,"file",null),this._sourceRoot=Yr.getArg(t,"sourceRoot",null),this._skipValidation=Yr.getArg(t,"skipValidation",!1),this._sources=new k2,this._names=new k2,this._mappings=new fQ,this._sourcesContents=null}static fromSourceMap(t){let r=t.sourceRoot,n=new e({file:t.file,sourceRoot:r});return t.eachMapping(function(i){let o={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(o.source=i.source,r!=null&&(o.source=Yr.relative(r,o.source)),o.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(o.name=i.name)),n.addMapping(o)}),t.sources.forEach(function(i){let o=i;r!=null&&(o=Yr.relative(r,i)),n._sources.has(o)||n._sources.add(o);let s=t.sourceContentFor(i);s!=null&&n.setSourceContent(i,s)}),n}addMapping(t){let r=Yr.getArg(t,"generated"),n=Yr.getArg(t,"original",null),i=Yr.getArg(t,"source",null),o=Yr.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,i,o),i!=null&&(i=String(i),this._sources.has(i)||this._sources.add(i)),o!=null&&(o=String(o),this._names.has(o)||this._names.add(o)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n&&n.line,originalColumn:n&&n.column,source:i,name:o})}setSourceContent(t,r){let n=t;this._sourceRoot!=null&&(n=Yr.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Yr.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[Yr.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 o=this._sourceRoot;o!=null&&(i=Yr.relative(o,i));let s=this._mappings.toArray().length>0?new k2:this._sources,a=new k2;this._mappings.unsortedForEach(function(u){if(u.source===i&&u.originalLine!=null){let m=t.originalPositionFor({line:u.originalLine,column:u.originalColumn});m.source!=null&&(u.source=m.source,n!=null&&(u.source=Yr.join(n,u.source)),o!=null&&(u.source=Yr.relative(o,u.source)),u.originalLine=m.line,u.originalColumn=m.column,m.name!=null&&(u.name=m.name))}let l=u.source;l!=null&&!s.has(l)&&s.add(l);let f=u.name;f!=null&&!a.has(f)&&a.add(f)},this),this._sources=s,this._names=a,t.sources.forEach(function(u){let l=t.sourceContentFor(u);l!=null&&(n!=null&&(u=Yr.join(n,u)),o!=null&&(u=Yr.relative(o,u)),this.setSourceContent(u,l))},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,o=0,s=0,a="",u,l,f,m,p=this._mappings.toArray();for(let d=0,v=p.length;d0){if(!Yr.compareByGeneratedPositionsInflated(l,p[d-1]))continue;u+=","}u+=h0.encode(l.generatedColumn-t),t=l.generatedColumn,l.source!=null&&(m=this._sources.indexOf(l.source),u+=h0.encode(m-s),s=m,u+=h0.encode(l.originalLine-1-i),i=l.originalLine-1,u+=h0.encode(l.originalColumn-n),n=l.originalColumn,l.name!=null&&(f=this._names.indexOf(l.name),u+=h0.encode(f-o),o=f)),a+=u}return a}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=Yr.relative(r,n));let i=Yr.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())}};O2.prototype._version=3;k7.SourceMapGenerator=O2});var N7=Ce(O7=>{var jye=P(x()),hQ=NS().SourceMapGenerator,N2=R2(),dQ=/(\r?\n)/,pQ=10,Hh="$$$isSourceNode$$$",LS=class e{constructor(t,r,n,i,o){this.children=[],this.sourceContents={},this.line=t??null,this.column=r??null,this.source=n??null,this.name=o??null,this[Hh]=!0,i!=null&&this.add(i)}static fromStringWithSourceMap(t,r,n){let i=new e,o=t.split(dQ),s=0,a=function(){let d=g(),v=g()||"";return d+v;function g(){return s=0;r--)this.prepend(t[r]);else if(t[Hh]||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{var Kye=P(x());US.SourceMapGenerator=NS().SourceMapGenerator;US.SourceNode=N7().SourceNode});var j7=Ce((Vye,M7)=>{"use strict";var zye=P(x()),mQ=Tc(),Zt=DS(),gQ=m7(),vQ=PS(),{stringEscape:vi,regexpClassEscape:HS}=v7(),{SourceNode:Li}=L7();function H7(e,t,r){let n=t.start.line,i=t.start.column-1,o=e.split(` `);return o.length===1?new Li(n,i,t.source,e,r):new Li(null,null,t.source,o.map((s,a)=>new Li(n+a,a===0?i:0,t.source,a===o.length-1?s:[s,` `],r)))}function U7(e,t,r,n,i){return r?new Li(null,null,r.source,[e,H7(t,r,i),new Li(r.end.line,r.end.column-1,r.source,n)]):new Li(null,null,null,[e,t,n])}function wQ(e,t){function r(g){return g instanceof Li?g:g.replace(/^(.+)$/gm," $1")}function n(g){return"peg$c"+g}function i(g){return"peg$r"+g}function o(g){return"peg$e"+g}function s(g){return"peg$f"+g}function a(g){return"peg$parse"+g}function u(){function g(S){return'"'+vi(S)+'"'}function y(S){return"/^["+(S.inverted?"^":"")+S.value.map(F=>Array.isArray(F)?HS(F[0])+"-"+HS(F[1]):HS(F)).join("")+"]/"+(S.ignoreCase?"i":"")}function w(S){switch(S.type){case"rule":return'peg$otherExpectation("'+vi(S.value)+'")';case"literal":return'peg$literalExpectation("'+vi(S.value)+'", '+S.ignoreCase+")";case"class":return"peg$classExpectation(["+S.value.map(_=>Array.isArray(_)?'["'+vi(_[0])+'", "'+vi(_[1])+'"]':'"'+vi(_)+'"').join(", ")+"], "+S.inverted+", "+S.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(S)+")")}}function E(S,F){return U7(` var ${s(F)} = function(${S.params.join(", ")}) {`,S.body,S.location,"};")}return new Li(null,null,t.grammarSource,[e.literals.map((S,F)=>" var "+n(F)+" = "+g(S)+";").concat("",e.classes.map((S,F)=>" var "+i(F)+" = "+y(S)+";")).concat("",e.expectations.map((S,F)=>" var "+o(F)+" = "+w(S)+";")).concat("").join(` `),e.functions.map(E)])}function l(g,y){let w=[];return w.push(""),t.trace&&w.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)","});",""),t.cache&&(w.push("var key = peg$currPos * "+e.rules.length+" + "+y+";","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: "+g+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)"," });","}",""),w.push(" return cached.result;","}","")),w}function f(g,y){let w=[];return t.cache&&w.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+y+" };"),t.trace&&w.push("","if ("+y+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+g+","," result: "+y+","," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)"," });","}"),w.push("","return "+y+";"),w}function m(g){let y=[],w=new gQ(g.name,"s","var");function E(F){let _=0,H=F.length,V=[],C;function I(k,M){let N=M+3,D=F[_+N-2],O=F[_+N-1],q,J;w.checkedIf(_,()=>{_+=N,q=E(F.slice(_,_+D)),_+=D},O>0?()=>{J=E(F.slice(_,_+O)),_+=O}:null),V.push("if ("+k+") {"),V.push(...q.map(r)),O>0&&(V.push("} else {"),V.push(...J.map(r))),V.push("}")}function L(k){let N=F[_+2-1],D;w.checkedLoop(_,()=>{_+=2,D=E(F.slice(_,_+N)),_+=N}),V.push("while ("+k+") {"),V.push(...D.map(r)),V.push("}")}function R(){let M=F[_+4-1],N=s(F[_+1])+"("+F.slice(_+4,_+4+M).map(D=>w.index(D)).join(", ")+")";w.pop(F[_+2]),V.push(w.push(N)),_+=4+M}for(;_w.index(D)).join(", ")} ]`,w.pop(F[_+1]),V.push(w.push(C)),_+=N;break}case Zt.IF:I(w.top(),0);break;case Zt.IF_ERROR:I(w.top()+" === peg$FAILED",0);break;case Zt.IF_NOT_ERROR:I(w.top()+" !== peg$FAILED",0);break;case Zt.WHILE_NOT_ERROR:L(w.top()+" !== peg$FAILED");break;case Zt.MATCH_ANY:I("input.length > peg$currPos",0);break;case Zt.MATCH_STRING:I(e.literals[F[_+1]].length>1?"input.substr(peg$currPos, "+e.literals[F[_+1]].length+") === "+n(F[_+1]):"input.charCodeAt(peg$currPos) === "+e.literals[F[_+1]].charCodeAt(0),1);break;case Zt.MATCH_STRING_IC:I("input.substr(peg$currPos, "+e.literals[F[_+1]].length+").toLowerCase() === "+n(F[_+1]),1);break;case Zt.MATCH_CHAR_CLASS:I(i(F[_+1])+".test(input.charAt(peg$currPos))",1);break;case Zt.ACCEPT_N:V.push(w.push(F[_+1]>1?"input.substr(peg$currPos, "+F[_+1]+")":"input.charAt(peg$currPos)")),V.push(F[_+1]>1?"peg$currPos += "+F[_+1]+";":"peg$currPos++;"),_+=2;break;case Zt.ACCEPT_STRING:V.push(w.push(n(F[_+1]))),V.push(e.literals[F[_+1]].length>1?"peg$currPos += "+e.literals[F[_+1]].length+";":"peg$currPos++;"),_+=2;break;case Zt.FAIL:V.push(w.push("peg$FAILED")),V.push("if (peg$silentFails === 0) { peg$fail("+o(F[_+1])+"); }"),_+=2;break;case Zt.LOAD_SAVED_POS:V.push("peg$savedPos = "+w.index(F[_+1])+";"),_+=2;break;case Zt.UPDATE_SAVED_POS:V.push("peg$savedPos = peg$currPos;"),_++;break;case Zt.CALL:R();break;case Zt.RULE:V.push(w.push(a(e.rules[F[_+1]].name)+"()")),_+=2;break;case Zt.SILENT_FAILS_ON:V.push("peg$silentFails++;"),_++;break;case Zt.SILENT_FAILS_OFF:V.push("peg$silentFails--;"),_++;break;default:throw new Error("Invalid opcode: "+F[_]+".")}return V}let S=E(g.bytecode);return y.push(U7(" function ",a(g.name),g.nameLocation,`() { `,g.name)),t.trace&&y.push(" var startPos = peg$currPos;"),y.push(r(w.defines())),y.push(...l('"'+vi(g.name)+'"',mQ.indexOfRule(e,g.name)).map(r)),y.push(...S.map(r)),y.push(...f('"'+vi(g.name)+'"',w.result()).map(r)),y.push("}"),y}function p(g){return g.codeLocation?H7(g.code,g.codeLocation,"$"+g.type):g.code}function d(){let g=[];e.topLevelInitializer&&(g.push(p(e.topLevelInitializer)),g.push("")),g.push("function peg$subclass(child, parent) {"," function C() { this.constructor = child; }"," C.prototype = parent.prototype;"," child.prototype = new C();","}","","function peg$SyntaxError(message, expected, found, location) {"," var self = Error.call(this, message);"," // istanbul ignore next Check is a necessary evil to support older environments"," if (Object.setPrototypeOf) {"," Object.setPrototypeOf(self, peg$SyntaxError.prototype);"," }"," self.expected = expected;"," self.found = found;"," self.location = location;",' self.name = "SyntaxError";'," return self;","}","","peg$subclass(peg$SyntaxError, Error);","","function peg$padEnd(str, targetLength, padString) {",' padString = padString || " ";'," if (str.length > targetLength) { return str; }"," targetLength -= str.length;"," padString += padString.repeat(targetLength);"," return str + padString.slice(0, targetLength);","}","","peg$SyntaxError.prototype.format = function(sources) {",' var str = "Error: " + this.message;'," if (this.location) {"," var src = null;"," var k;"," for (k = 0; k < sources.length; k++) {"," if (sources[k].source === this.location.source) {"," src = sources[k].text.split(/\\r\\n|\\n|\\r/g);"," break;"," }"," }"," var s = this.location.start;",' var loc = this.location.source + ":" + s.line + ":" + s.column;'," if (src) {"," var e = this.location.end;",` var filler = peg$padEnd("", s.line.toString().length, ' ');`," var line = src[s.line - 1];"," var last = s.line === e.line ? e.column : line.length + 1;"," var hatLen = (last - s.column) || 1;",' str += "\\n --> " + loc + "\\n"',' + filler + " |\\n"',' + s.line + " | " + line + "\\n"',` + filler + " | " + peg$padEnd("", s.column - 1, ' ')`,' + peg$padEnd("", hatLen, "^");'," } else {",' str += "\\n at " + loc;'," }"," }"," return str;","};","","peg$SyntaxError.buildMessage = function(expected, found) {"," var DESCRIBE_EXPECTATION_FNS = {"," literal: function(expectation) {",' return "\\"" + literalEscape(expectation.text) + "\\"";'," },",""," class: function(expectation) {"," var escapedParts = expectation.parts.map(function(part) {"," return Array.isArray(part)",' ? classEscape(part[0]) + "-" + classEscape(part[1])'," : classEscape(part);"," });","",' return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";'," },",""," any: function() {",' return "any character";'," },",""," end: function() {",' return "end of input";'," },",""," other: function(expectation) {"," return expectation.description;"," }"," };",""," function hex(ch) {"," return ch.charCodeAt(0).toString(16).toUpperCase();"," }",""," function literalEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/"/g, "\\\\\\"")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function classEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/\\]/g, "\\\\]")',' .replace(/\\^/g, "\\\\^")',' .replace(/-/g, "\\\\-")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function describeExpectation(expectation) {"," return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);"," }",""," function describeExpected(expected) {"," var descriptions = expected.map(describeExpectation);"," var i, j;",""," descriptions.sort();",""," if (descriptions.length > 0) {"," for (i = 1, j = 1; i < descriptions.length; i++) {"," if (descriptions[i - 1] !== descriptions[i]) {"," descriptions[j] = descriptions[i];"," j++;"," }"," }"," descriptions.length = j;"," }",""," switch (descriptions.length) {"," case 1:"," return descriptions[0];",""," case 2:",' return descriptions[0] + " or " + descriptions[1];',""," default:",' return descriptions.slice(0, -1).join(", ")',' + ", or "'," + descriptions[descriptions.length - 1];"," }"," }",""," function describeFound(found) {",' return found ? "\\"" + literalEscape(found) + "\\"" : "end of input";'," }","",' return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";',"};",""),t.trace&&g.push("function peg$DefaultTracer() {"," this.indentLevel = 0;","}","","peg$DefaultTracer.prototype.trace = function(event) {"," var that = this;",""," function log(event) {"," function repeat(string, n) {",' var result = "", i;',""," for (i = 0; i < n; i++) {"," result += string;"," }",""," return result;"," }",""," function pad(string, length) {",' return string + repeat(" ", length - string.length);'," }","",' if (typeof console === "object") {'," console.log(",' event.location.start.line + ":" + event.location.start.column + "-"',' + event.location.end.line + ":" + event.location.end.column + " "',' + pad(event.type, 10) + " "',' + repeat(" ", that.indentLevel) + event.rule'," );"," }"," }",""," switch (event.type) {",' case "rule.enter":'," log(event);"," this.indentLevel++;"," break;","",' case "rule.match":'," this.indentLevel--;"," log(event);"," break;","",' case "rule.fail":'," this.indentLevel--;"," log(event);"," break;",""," default:",' throw new Error("Invalid event type: " + event.type + ".");'," }","};","");let y="{ "+t.allowedStartRules.map(E=>E+": "+a(E)).join(", ")+" }",w=a(t.allowedStartRules[0]);return g.push("function peg$parse(input, options) {"," options = options !== undefined ? options : {};",""," var peg$FAILED = {};"," var peg$source = options.grammarSource;",""," var peg$startRuleFunctions = "+y+";"," var peg$startRuleFunction = "+w+";","",u(),""," var peg$currPos = 0;"," var peg$savedPos = 0;"," var peg$posDetailsCache = [{ line: 1, column: 1 }];"," var peg$maxFailPos = 0;"," var peg$maxFailExpected = [];"," var peg$silentFails = 0;",""),t.cache&&g.push(" var peg$resultsCache = {};",""),t.trace&&g.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),g.push(" var peg$result;","",' if ("startRule" in options) {'," if (!(options.startRule in peg$startRuleFunctions)) {",` throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");`," }",""," peg$startRuleFunction = peg$startRuleFunctions[options.startRule];"," }",""," function text() {"," return input.substring(peg$savedPos, peg$currPos);"," }",""," function offset() {"," return peg$savedPos;"," }",""," function range() {"," return {"," source: peg$source,"," start: peg$savedPos,"," end: peg$currPos"," };"," }",""," function location() {"," return peg$computeLocation(peg$savedPos, peg$currPos);"," }",""," function expected(description, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildStructuredError("," [peg$otherExpectation(description)],"," input.substring(peg$savedPos, peg$currPos),"," location"," );"," }",""," function error(message, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildSimpleError(message, location);"," }",""," function peg$literalExpectation(text, ignoreCase) {",' return { type: "literal", text: text, ignoreCase: ignoreCase };'," }",""," function peg$classExpectation(parts, inverted, ignoreCase) {",' return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };'," }",""," function peg$anyExpectation() {",' return { type: "any" };'," }",""," function peg$endExpectation() {",' return { type: "end" };'," }",""," function peg$otherExpectation(description) {",' return { type: "other", description: description };'," }",""," function peg$computePosDetails(pos) {"," var details = peg$posDetailsCache[pos];"," var p;",""," if (details) {"," return details;"," } else {"," p = pos - 1;"," while (!peg$posDetailsCache[p]) {"," p--;"," }",""," details = peg$posDetailsCache[p];"," details = {"," line: details.line,"," column: details.column"," };",""," while (p < pos) {"," if (input.charCodeAt(p) === 10) {"," details.line++;"," details.column = 1;"," } else {"," details.column++;"," }",""," p++;"," }",""," peg$posDetailsCache[pos] = details;",""," return details;"," }"," }",""," function peg$computeLocation(startPos, endPos) {"," var startPosDetails = peg$computePosDetails(startPos);"," var endPosDetails = peg$computePosDetails(endPos);",""," return {"," source: peg$source,"," start: {"," offset: startPos,"," line: startPosDetails.line,"," column: startPosDetails.column"," },"," end: {"," offset: endPos,"," line: endPosDetails.line,"," column: endPosDetails.column"," }"," };"," }",""," function peg$fail(expected) {"," if (peg$currPos < peg$maxFailPos) { return; }",""," if (peg$currPos > peg$maxFailPos) {"," peg$maxFailPos = peg$currPos;"," peg$maxFailExpected = [];"," }",""," peg$maxFailExpected.push(expected);"," }",""," function peg$buildSimpleError(message, location) {"," return new peg$SyntaxError(message, null, null, location);"," }",""," function peg$buildStructuredError(expected, found, location) {"," return new peg$SyntaxError("," peg$SyntaxError.buildMessage(expected, found),"," expected,"," found,"," location"," );"," }",""),e.rules.forEach(E=>{g.push(...m(E).map(r)),g.push("")}),e.initializer&&(g.push(p(e.initializer)),g.push("")),g.push(" peg$result = peg$startRuleFunction();",""," if (peg$result !== peg$FAILED && peg$currPos === input.length) {"," return peg$result;"," } else {"," if (peg$result !== peg$FAILED && peg$currPos < input.length) {"," peg$fail(peg$endExpectation());"," }",""," throw peg$buildStructuredError("," peg$maxFailExpected,"," peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,"," peg$maxFailPos < input.length"," ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)"," : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)"," );"," }","}"),new Li(null,null,t.grammarSource,g.map(E=>E instanceof Li?E:E+` `))}function v(g){function y(){return[`// Generated by Peggy ${vQ}.`,"//","// 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 S={bare(){return[...y(),"(function() {",' "use strict";',"",g,"",r("return "+w()+";"),"})()"]},commonjs(){let F=Object.keys(t.dependencies),_=y();return _.push("",'"use strict";',""),F.length>0&&(F.forEach(H=>{_.push("var "+H+' = require("'+vi(t.dependencies[H])+'");')}),_.push("")),_.push(g,"","module.exports = "+w()+";"),_},es(){let F=Object.keys(t.dependencies),_=y();return _.push(""),F.length>0&&(F.forEach(H=>{_.push("import "+H+' from "'+vi(t.dependencies[H])+'";')}),_.push("")),_.push(g,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),_},amd(){let F=Object.keys(t.dependencies),H="["+F.map(C=>t.dependencies[C]).map(C=>'"'+vi(C)+'"').join(", ")+"]",V=F.join(", ");return[...y(),"define("+H+", function("+V+") {",' "use strict";',"",g,"",r("return "+w()+";"),"});"]},globals(){return[...y(),"(function(root) {",' "use strict";',"",g,"",r("root."+t.exportVar+" = "+w()+";"),"})(this);"]},umd(){let F=Object.keys(t.dependencies),_=F.map(L=>t.dependencies[L]),H="["+_.map(L=>'"'+vi(L)+'"').join(", ")+"]",V=_.map(L=>'require("'+vi(L)+'")').join(", "),C=F.join(", "),I=y();return I.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+H+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+V+");"),t.exportVar!==null&&I.push(" } else {"," root."+t.exportVar+" = factory();"),I.push(" }","})(this, function("+C+") {",' "use strict";',"",g,"",r("return "+w()+";"),"});"),I}}[t.format]();return new Li(null,null,t.grammarSource,S.map(F=>F instanceof Li?F:F+` `))}e.code=v(d())}M7.exports=wQ});var K7=Ce((Gye,q7)=>{"use strict";var Yye=P(x()),yQ=Tc(),EQ=Ni();function bQ(e,t,r){function n(s){return s.type==="rule"&&s.expression.type==="rule_ref"}function i(s,a,u){EQ.build({rule_ref(f){f.name===a&&(f.name=u,r.info(`Proxy rule "${a}" replaced by the rule "${u}"`,f.location,[{message:"This rule will be used",location:yQ.findRule(s,u).nameLocation}]))}})(s)}let o=[];e.rules.forEach((s,a)=>{n(s)&&(i(e,s.name,s.expression.name),t.allowedStartRules.indexOf(s.name)===-1&&o.push(a))}),o.reverse(),o.forEach(s=>{e.rules.splice(s,1)})}q7.exports=bQ});var z7=Ce((Wye,V7)=>{"use strict";var Xye=P(x()),AQ=Ni();function SQ(e,t,r){function n(s){let a={};return Object.keys(s).forEach(u=>{a[u]=s[u]}),a}function i(s,a){o(s.expression,n(a))}let o=AQ.build({rule(s){o(s.expression,{})},choice(s,a){s.alternatives.forEach(u=>{o(u,n(a))})},action:i,labeled(s,a){let u=s.label;u&&Object.prototype.hasOwnProperty.call(a,u)&&r.error(`Label "${s.label}" is already defined`,s.labelLocation,[{message:"Original label location",location:a[u]}]),o(s.expression,a),a[s.label]=s.labelLocation},text:i,simple_and:i,simple_not:i,optional:i,zero_or_more:i,one_or_more:i,group:i});o(e)}V7.exports=SQ});var Y7=Ce((Jye,G7)=>{"use strict";var Zye=P(x()),CQ=Ni();function _Q(e,t,r){let n={};CQ.build({rule(o){if(Object.prototype.hasOwnProperty.call(n,o.name)){r.error(`Rule "${o.name}" is already defined`,o.nameLocation,[{message:"Original rule location",location:n[o.name]}]);return}n[o.name]=o.nameLocation}})(e)}G7.exports=_Q});var J7=Ce((Qye,X7)=>{"use strict";var eEe=P(x()),W7=Tc(),DQ=Ni();function FQ(e,t,r){let n=[],i=[],o=DQ.build({rule(s){n.push(s.name),o(s.expression),n.pop()},sequence(s){s.elements.every(a=>(o(a),!W7.alwaysConsumesOnSuccess(e,a)))},rule_ref(s){i.push(s);let a=W7.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(" -> ")+")",a.nameLocation,i.map((u,l,f)=>({message:l+1!==f.length?`Step ${l+1}: call of the rule "${u.name}" without input consumption`:`Step ${l+1}: call itself without input consumption - left recursion`,location:u.location})));return}a&&o(a),i.pop()}});o(e)}X7.exports=FQ});var e$=Ce((tEe,Q7)=>{"use strict";var rEe=P(x()),Z7=Tc(),BQ=Ni();function IQ(e,t,r){BQ.build({zero_or_more(i){Z7.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){Z7.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)}Q7.exports=IQ});var r$=Ce((nEe,t$)=>{"use strict";var sEe=P(x()),$Q=Tc(),PQ=Ni();function xQ(e,t,r){PQ.build({rule_ref(i){$Q.findRule(e,i.name)||r.error(`Rule "${i.name}" is not defined`,i.location)}})(e)}t$.exports=xQ});var s$=Ce((iEe,n$)=>{"use strict";var oEe=P(x()),TQ=Ni();function RQ(e,t,r){let n=TQ.build({action(i){n(i.expression,i)},labeled(i,o){i.pick&&o&&r.error('"@" cannot be used with an action block',i.labelLocation,[{message:"Action block location",location:o.codeLocation}]),n(i.expression)}});n(e)}n$.exports=RQ});var o$=Ce((aEe,i$)=>{"use strict";var uEe=P(x()),kQ=$2(),MS=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(){}},jS=class{constructor(t){this._callbacks=new MS(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new kQ(...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}};i$.exports=jS});var a$=Ce((exports,module)=>{"use strict";var cEe=P(x()),generateBytecode=d7(),generateJS=j7(),inferenceMatchResult=FS(),removeProxyRules=K7(),reportDuplicateLabels=z7(),reportDuplicateRules=Y7(),reportInfiniteRecursion=J7(),reportInfiniteRepetition=e$(),reportUndefinedRules=r$(),reportIncorrectPlucking=s$(),Session=o$(),visitor=Ni();function processOptions(e,t){let r={};return Object.keys(e).forEach(n=>{r[n]=e[n]}),Object.keys(t).forEach(n=>{Object.prototype.hasOwnProperty.call(r,n)||(r[n]=t[n])}),r}var compiler={visitor,passes:{check:[reportUndefinedRules,reportDuplicateRules,reportDuplicateLabels,reportInfiniteRecursion,reportInfiniteRepetition,reportIncorrectPlucking],transform:[removeProxyRules,inferenceMatchResult],generate:[generateBytecode,generateJS]},compile(ast,passes,options){if(options=options!==void 0?options:{},options=processOptions(options,{allowedStartRules:[ast.rules[0].name],cache:!1,dependencies:{},exportVar:null,format:"bare",output:"parser",trace:!1}),!Array.isArray(options.allowedStartRules))throw new Error("allowedStartRules must be an array");if(options.allowedStartRules.length===0)throw new Error("Must have at least one start rule");let allRules=ast.rules.map(e=>e.name);for(let e of options.allowedStartRules)if(allRules.indexOf(e)===-1)throw new Error(`Unknown start rule "${e}"`);let session=new Session(options);switch(Object.keys(passes).forEach(e=>{session.stage=e,session.info(`Process stage ${e}`),passes[e].forEach(t=>{session.info(`Process pass ${e}.${t.name}`),t(ast,options,session)}),session.checkErrors()}),options.output){case"parser":return eval(ast.code.toString());case"source":return ast.code.toString();case"source-and-map":return ast.code;default:throw new Error("Invalid output format: "+options.output+".")}}};module.exports=compiler});var c$=Ce((lEe,u$)=>{"use strict";var fEe=P(x()),OQ={$:"text","&":"simple_and","!":"simple_not"},NQ={"?":"optional","*":"zero_or_more","+":"one_or_more"},LQ={"&":"semantic_and","!":"semantic_not"};function UQ(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function Oc(e,t,r,n){var i=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(i,Oc.prototype),i.expected=t,i.found=r,i.location=n,i.name="SyntaxError",i}UQ(Oc,Error);function qS(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}Oc.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var r=null,n;for(n=0;n `+o+` `+a+` | `+i.line+" | "+u+` `+a+" | "+qS("",i.column-1," ")+qS("",f,"^")}else t+=` at `+o}return t};Oc.buildMessage=function(e,t){var r={literal:function(l){return'"'+i(l.text)+'"'},class:function(l){var f=l.parts.map(function(m){return Array.isArray(m)?o(m[0])+"-"+o(m[1]):o(m)});return"["+(l.inverted?"^":"")+f.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(l){return l.description}};function n(l){return l.charCodeAt(0).toString(16).toUpperCase()}function i(l){return l.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(f){return"\\x0"+n(f)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(f){return"\\x"+n(f)})}function o(l){return l.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(f){return"\\x0"+n(f)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(f){return"\\x"+n(f)})}function s(l){return r[l.type](l)}function a(l){var f=l.map(s),m,p;if(f.sort(),f.length>0){for(m=1,p=1;m0?{type:"choice",alternatives:[B].concat(W),location:wr()}:B},bi=function(B,W){return W!==null?{type:"action",expression:B,code:W[0],codeLocation:W[1],location:wr()}:B},zc=function(B,W){return W.length>0||B.type==="labeled"&&B.pick?{type:"sequence",elements:[B].concat(W),location:wr()}:B},j2=function(B,W,ne){return ne.type.startsWith("semantic_")&&Gh('"@" cannot be used on a semantic predicate',B),{type:"labeled",label:W!==null?W[0]:null,labelLocation:W!==null?W[1]:B,pick:!0,expression:ne,location:wr()}},q2=function(B,W){return{type:"labeled",label:B[0],labelLocation:B[1],expression:W,location:wr()}},K2=function(){return wr()},lr=function(B){return Ba.indexOf(B[0])>=0&&Gh(`Label can't be a reserved word "${B[0]}"`,B[1]),B},ar=function(B,W){return{type:OQ[B],expression:W,location:wr()}},V2=function(B,W){return{type:NQ[W],expression:B,location:wr()}},z2=function(B){return B.type==="labeled"||B.type==="sequence"?{type:"group",expression:B,location:wr()}:B},G2=function(B){return{type:"rule_ref",name:B[0],location:wr()}},Y2=function(B,W){return{type:LQ[B],code:W[0],codeLocation:W[1],location:wr()}},W2=function(B,W){return[B+W.join(""),wr()]},X2=function(B,W){return{type:"literal",value:B,ignoreCase:W!==null,location:wr()}},p0=function(B){return B.join("")},J2=function(B){return B.join("")},zr=function(B,W,ne){return{type:"class",parts:W.filter(te=>te!==""),inverted:B!==null,ignoreCase:ne!==null,location:wr()}},Vh=function(B,W){return B.charCodeAt(0)>W.charCodeAt(0)&&Gh("Invalid character range: "+Io()+"."),[B,W]},Sa=function(){return""},m0=function(){return"\0"},zh=function(){return"\b"},Rs=function(){return"\f"},g0=function(){return` `},v0=function(){return"\r"},w0=function(){return" "},y0=function(){return"\v"},E0=function(B){return String.fromCharCode(parseInt(B,16))},b0=function(B){return String.fromCharCode(parseInt(B,16))},ls=function(){return{type:"any",location:wr()}},Z2=function(B){return[B,wr()]},U=0,St=0,Gc=[{line:1,column:1}],Wr=0,ku=[],de=0,ir;if("startRule"in t){if(!(t.startRule in i))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');o=i[t.startRule]}function Io(){return e.substring(St,U)}function A0(){return St}function c6(){return{source:n,start:St,end:U}}function wr(){return Nu(St,U)}function l6(B,W){throw W=W!==void 0?W:Nu(St,U),Xh([Ui(B)],e.substring(St,U),W)}function Gh(B,W){throw W=W!==void 0?W:Nu(St,U),Wh(B,W)}function ut(B,W){return{type:"literal",text:B,ignoreCase:W}}function ln(B,W,ne){return{type:"class",parts:B,inverted:W,ignoreCase:ne}}function rf(){return{type:"any"}}function Ou(){return{type:"end"}}function Ui(B){return{type:"other",description:B}}function Yh(B){var W=Gc[B],ne;if(W)return W;for(ne=B-1;!Gc[ne];)ne--;for(W=Gc[ne],W={line:W.line,column:W.column};neWr&&(Wr=U,ku=[]),ku.push(B))}function Wh(B,W){return new Oc(B,null,null,W)}function Xh(B,W,ne){return new Oc(Oc.buildMessage(B,W),B,W,ne)}function S0(){var B,W,ne,te,me,ye,Xt,Nr;if(B=U,W=or(),ne=U,te=Jh(),te!==r?(me=or(),ne=te):(U=ne,ne=r),ne===r&&(ne=null),te=U,me=Zh(),me!==r?(ye=or(),te=me):(U=te,te=r),te===r&&(te=null),me=[],ye=U,Xt=C0(),Xt!==r?(Nr=or(),ye=Xt):(U=ye,ye=r),ye!==r)for(;ye!==r;)me.push(ye),ye=U,Xt=C0(),Xt!==r?(Nr=or(),ye=Xt):(U=ye,ye=r);else me=r;return me!==r?(St=B,B=ri(ne,te,me)):(U=B,B=r),B}function Jh(){var B,W,ne,te,me;return B=U,e.charCodeAt(U)===123?(W=s,U++):(W=r,de===0&&Fe(on)),W!==r?(ne=Fa(),ne!==r?(e.charCodeAt(U)===125?(te=a,U++):(te=r,de===0&&Fe(ei)),te!==r?(me=lf(),me!==r?(St=B,B=Ru(ne)):(U=B,B=r)):(U=B,B=r)):(U=B,B=r)):(U=B,B=r),B}function Zh(){var B,W,ne;return B=U,W=Fa(),W!==r?(ne=lf(),ne!==r?(St=B,B=us(W)):(U=B,B=r)):(U=B,B=r),B}function C0(){var B,W,ne,te,me,ye,Xt,Nr;return B=U,W=hs(),W!==r?(ne=or(),te=U,me=sd(),me!==r?(ye=or(),te=me):(U=te,te=r),te===r&&(te=null),e.charCodeAt(U)===61?(me=u,U++):(me=r,de===0&&Fe(Pu)),me!==r?(ye=or(),Xt=Qh(),Xt!==r?(Nr=lf(),Nr!==r?(St=B,B=cs(W,te,Xt)):(U=B,B=r)):(U=B,B=r)):(U=B,B=r)):(U=B,B=r),B}function Qh(){var B,W,ne,te,me,ye,Xt,Nr;if(B=U,W=bn(),W!==r){for(ne=[],te=U,me=or(),e.charCodeAt(U)===47?(ye=l,U++):(ye=r,de===0&&Fe(Co)),ye!==r?(Xt=or(),Nr=bn(),Nr!==r?te=Nr:(U=te,te=r)):(U=te,te=r);te!==r;)ne.push(te),te=U,me=or(),e.charCodeAt(U)===47?(ye=l,U++):(ye=r,de===0&&Fe(Co)),ye!==r?(Xt=or(),Nr=bn(),Nr!==r?te=Nr:(U=te,te=r)):(U=te,te=r);St=B,B=Bo(W,ne)}else U=B,B=r;return B}function bn(){var B,W,ne,te,me;return B=U,W=ed(),W!==r?(ne=U,te=or(),me=Fa(),me!==r?ne=me:(U=ne,ne=r),ne===r&&(ne=null),St=B,B=bi(W,ne)):(U=B,B=r),B}function ed(){var B,W,ne,te,me,ye;if(B=U,W=Ca(),W!==r){for(ne=[],te=U,me=or(),ye=Ca(),ye!==r?te=ye:(U=te,te=r);te!==r;)ne.push(te),te=U,me=or(),ye=Ca(),ye!==r?te=ye:(U=te,te=r);St=B,B=zc(W,ne)}else U=B,B=r;return B}function Ca(){var B,W,ne,te;return B=U,W=_0(),W!==r?(ne=td(),ne===r&&(ne=null),te=rd(),te!==r?(St=B,B=j2(W,ne,te)):(U=B,B=r)):(U=B,B=r),B===r&&(B=U,W=td(),W!==r?(ne=or(),te=rd(),te!==r?(St=B,B=q2(W,te)):(U=B,B=r)):(U=B,B=r),B===r&&(B=rd())),B}function _0(){var B,W;return B=U,e.charCodeAt(U)===64?(W=f,U++):(W=r,de===0&&Fe(Nc)),W!==r&&(St=B,W=K2()),B=W,B}function td(){var B,W,ne,te;return B=U,W=hs(),W!==r?(ne=or(),e.charCodeAt(U)===58?(te=m,U++):(te=r,de===0&&Fe(_o)),te!==r?(St=B,B=lr(W)):(U=B,B=r)):(U=B,B=r),B}function rd(){var B,W,ne,te;return B=U,W=Q2(),W!==r?(ne=or(),te=D0(),te!==r?(St=B,B=ar(W,te)):(U=B,B=r)):(U=B,B=r),B===r&&(B=D0()),B}function Q2(){var B;return e.charCodeAt(U)===36?(B=p,U++):(B=r,de===0&&Fe(wi)),B===r&&(e.charCodeAt(U)===38?(B=d,U++):(B=r,de===0&&Fe(Gt)),B===r&&(e.charCodeAt(U)===33?(B=v,U++):(B=r,de===0&&Fe(xs)))),B}function D0(){var B,W,ne,te;return B=U,W=F0(),W!==r?(ne=or(),te=ev(),te!==r?(St=B,B=V2(W,te)):(U=B,B=r)):(U=B,B=r),B===r&&(B=F0()),B}function ev(){var B;return e.charCodeAt(U)===63?(B=g,U++):(B=r,de===0&&Fe(xu)),B===r&&(e.charCodeAt(U)===42?(B=y,U++):(B=r,de===0&&Fe(Lc)),B===r&&(e.charCodeAt(U)===43?(B=w,U++):(B=r,de===0&&Fe(wa)))),B}function F0(){var B,W,ne,te,me,ye;return B=ov(),B===r&&(B=Ae(),B===r&&(B=nf(),B===r&&(B=Lu(),B===r&&(B=tv(),B===r&&(B=U,e.charCodeAt(U)===40?(W=E,U++):(W=r,de===0&&Fe(Do)),W!==r?(ne=or(),te=Qh(),te!==r?(me=or(),e.charCodeAt(U)===41?(ye=S,U++):(ye=r,de===0&&Fe(Uc)),ye!==r?(St=B,B=z2(te)):(U=B,B=r)):(U=B,B=r)):(U=B,B=r)))))),B}function Lu(){var B,W,ne,te,me,ye,Xt,Nr;return B=U,W=hs(),W!==r?(ne=U,de++,te=U,me=or(),ye=U,Xt=sd(),Xt!==r?(Nr=or(),Xt=[Xt,Nr],ye=Xt):(U=ye,ye=r),ye===r&&(ye=null),e.charCodeAt(U)===61?(Xt=u,U++):(Xt=r,de===0&&Fe(Pu)),Xt!==r?(me=[me,ye,Xt],te=me):(U=te,te=r),de--,te===r?ne=void 0:(U=ne,ne=r),ne!==r?(St=B,B=G2(W)):(U=B,B=r)):(U=B,B=r),B}function tv(){var B,W,ne,te;return B=U,W=rv(),W!==r?(ne=or(),te=Fa(),te!==r?(St=B,B=Y2(W,te)):(U=B,B=r)):(U=B,B=r),B}function rv(){var B;return e.charCodeAt(U)===38?(B=d,U++):(B=r,de===0&&Fe(Gt)),B===r&&(e.charCodeAt(U)===33?(B=v,U++):(B=r,de===0&&Fe(xs))),B}function fn(){var B;return e.length>U?(B=e.charAt(U),U++):(B=r,de===0&&Fe(Tu)),B}function Yc(){var B,W;return de++,e.charCodeAt(U)===9?(B=F,U++):(B=r,de===0&&Fe(Hc)),B===r&&(e.charCodeAt(U)===11?(B=_,U++):(B=r,de===0&&Fe(ue)),B===r&&(e.charCodeAt(U)===12?(B=H,U++):(B=r,de===0&&Fe(Ee)),B===r&&(e.charCodeAt(U)===32?(B=V,U++):(B=r,de===0&&Fe(Xe)),B===r&&(e.charCodeAt(U)===160?(B=C,U++):(B=r,de===0&&Fe(We)),B===r&&(e.charCodeAt(U)===65279?(B=I,U++):(B=r,de===0&&Fe(it)),B===r&&(B=R0())))))),de--,B===r&&(W=r,de===0&&Fe(ya)),B}function An(){var B;return wt.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(bt)),B}function _a(){var B,W;return de++,e.charCodeAt(U)===10?(B=L,U++):(B=r,de===0&&Fe(kr)),B===r&&(e.substr(U,2)===R?(B=R,U+=2):(B=r,de===0&&Fe(nr)),B===r&&(e.charCodeAt(U)===13?(B=k,U++):(B=r,de===0&&Fe(is)),B===r&&(e.charCodeAt(U)===8232?(B=M,U++):(B=r,de===0&&Fe(yi)),B===r&&(e.charCodeAt(U)===8233?(B=N,U++):(B=r,de===0&&Fe(yn)))))),de--,B===r&&(W=r,de===0&&Fe(At)),B}function B0(){var B,W;return de++,B=nv(),B===r&&(B=Da()),de--,B===r&&(W=r,de===0&&Fe(Ln)),B}function nv(){var B,W,ne,te,me,ye;if(B=U,e.substr(U,2)===D?(W=D,U+=2):(W=r,de===0&&Fe(Dr)),W!==r){for(ne=[],te=U,me=U,de++,e.substr(U,2)===O?(ye=O,U+=2):(ye=r,de===0&&Fe(En)),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r);te!==r;)ne.push(te),te=U,me=U,de++,e.substr(U,2)===O?(ye=O,U+=2):(ye=r,de===0&&Fe(En)),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r);e.substr(U,2)===O?(te=O,U+=2):(te=r,de===0&&Fe(En)),te!==r?(W=[W,ne,te],B=W):(U=B,B=r)}else U=B,B=r;return B}function I0(){var B,W,ne,te,me,ye;if(B=U,e.substr(U,2)===D?(W=D,U+=2):(W=r,de===0&&Fe(Dr)),W!==r){for(ne=[],te=U,me=U,de++,e.substr(U,2)===O?(ye=O,U+=2):(ye=r,de===0&&Fe(En)),ye===r&&(ye=An()),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r);te!==r;)ne.push(te),te=U,me=U,de++,e.substr(U,2)===O?(ye=O,U+=2):(ye=r,de===0&&Fe(En)),ye===r&&(ye=An()),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r);e.substr(U,2)===O?(te=O,U+=2):(te=r,de===0&&Fe(En)),te!==r?(W=[W,ne,te],B=W):(U=B,B=r)}else U=B,B=r;return B}function Da(){var B,W,ne,te,me,ye;if(B=U,e.substr(U,2)===q?(W=q,U+=2):(W=r,de===0&&Fe(Un)),W!==r){for(ne=[],te=U,me=U,de++,ye=An(),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r);te!==r;)ne.push(te),te=U,me=U,de++,ye=An(),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r);W=[W,ne],B=W}else U=B,B=r;return B}function hs(){var B,W,ne,te;if(de++,B=U,W=nd(),W!==r){for(ne=[],te=$0();te!==r;)ne.push(te),te=$0();St=B,B=W2(W,ne)}else U=B,B=r;return de--,B===r&&(W=r,de===0&&Fe(Fo)),B}function nd(){var B,W,ne;return B=sv(),B===r&&(e.charCodeAt(U)===36?(B=p,U++):(B=r,de===0&&Fe(wi)),B===r&&(e.charCodeAt(U)===95?(B=J,U++):(B=r,de===0&&Fe(Mc)),B===r&&(B=U,e.charCodeAt(U)===92?(W=Y,U++):(W=r,de===0&&Fe(an)),W!==r?(ne=Wc(),ne!==r?B=ne:(U=B,B=r)):(U=B,B=r)))),B}function $0(){var B;return B=nd(),B===r&&(B=iv(),B===r&&(B=af(),B===r&&(B=uf(),B===r&&(e.charCodeAt(U)===8204?(B=ee,U++):(B=r,de===0&&Fe(Kt)),B===r&&(e.charCodeAt(U)===8205?(B=se,U++):(B=r,de===0&&Fe(Fr))))))),B}function sv(){var B;return B=lv(),B===r&&(B=x0(),B===r&&(B=cv(),B===r&&(B=sf(),B===r&&(B=uv(),B===r&&(B=T0()))))),B}function iv(){var B;return B=$o(),B===r&&(B=of()),B}function ov(){var B,W,ne;return de++,B=U,W=sd(),W!==r?(e.charCodeAt(U)===105?(ne=le,U++):(ne=r,de===0&&Fe(vr)),ne===r&&(ne=null),St=B,B=X2(W,ne)):(U=B,B=r),de--,B===r&&(W=r,de===0&&Fe(mt)),B}function sd(){var B,W,ne,te;if(de++,B=U,e.charCodeAt(U)===34?(W=ve,U++):(W=r,de===0&&Fe(pr)),W!==r){for(ne=[],te=Hi();te!==r;)ne.push(te),te=Hi();e.charCodeAt(U)===34?(te=ve,U++):(te=r,de===0&&Fe(pr)),te!==r?(St=B,B=p0(ne)):(U=B,B=r)}else U=B,B=r;if(B===r)if(B=U,e.charCodeAt(U)===39?(W=we,U++):(W=r,de===0&&Fe(Qt)),W!==r){for(ne=[],te=ce();te!==r;)ne.push(te),te=ce();e.charCodeAt(U)===39?(te=we,U++):(te=r,de===0&&Fe(Qt)),te!==r?(St=B,B=J2(ne)):(U=B,B=r)}else U=B,B=r;return de--,B===r&&(W=r,de===0&&Fe(un)),B}function Hi(){var B,W,ne,te;return B=U,W=U,ne=U,de++,e.charCodeAt(U)===34?(te=ve,U++):(te=r,de===0&&Fe(pr)),te===r&&(e.charCodeAt(U)===92?(te=Y,U++):(te=r,de===0&&Fe(an)),te===r&&(te=An())),de--,te===r?ne=void 0:(U=ne,ne=r),ne!==r?(te=fn(),te!==r?(ne=[ne,te],W=ne):(U=W,W=r)):(U=W,W=r),W!==r?B=e.substring(B,U):B=W,B===r&&(B=U,e.charCodeAt(U)===92?(W=Y,U++):(W=r,de===0&&Fe(an)),W!==r?(ne=Lt(),ne!==r?B=ne:(U=B,B=r)):(U=B,B=r),B===r&&(B=pt())),B}function ce(){var B,W,ne,te;return B=U,W=U,ne=U,de++,e.charCodeAt(U)===39?(te=we,U++):(te=r,de===0&&Fe(Qt)),te===r&&(e.charCodeAt(U)===92?(te=Y,U++):(te=r,de===0&&Fe(an)),te===r&&(te=An())),de--,te===r?ne=void 0:(U=ne,ne=r),ne!==r?(te=fn(),te!==r?(ne=[ne,te],W=ne):(U=W,W=r)):(U=W,W=r),W!==r?B=e.substring(B,U):B=W,B===r&&(B=U,e.charCodeAt(U)===92?(W=Y,U++):(W=r,de===0&&Fe(an)),W!==r?(ne=Lt(),ne!==r?B=ne:(U=B,B=r)):(U=B,B=r),B===r&&(B=pt())),B}function Ae(){var B,W,ne,te,me,ye;if(de++,B=U,e.charCodeAt(U)===91?(W=Pe,U++):(W=r,de===0&&Fe(Ts)),W!==r){for(e.charCodeAt(U)===94?(ne=Le,U++):(ne=r,de===0&&Fe(ti)),ne===r&&(ne=null),te=[],me=ge(),me===r&&(me=Ye());me!==r;)te.push(me),me=ge(),me===r&&(me=Ye());e.charCodeAt(U)===93?(me=Oe,U++):(me=r,de===0&&Fe(as)),me!==r?(e.charCodeAt(U)===105?(ye=le,U++):(ye=r,de===0&&Fe(vr)),ye===r&&(ye=null),St=B,B=zr(ne,te,ye)):(U=B,B=r)}else U=B,B=r;return de--,B===r&&(W=r,de===0&&Fe(os)),B}function ge(){var B,W,ne,te;return B=U,W=Ye(),W!==r?(e.charCodeAt(U)===45?(ne=fe,U++):(ne=r,de===0&&Fe(Vr)),ne!==r?(te=Ye(),te!==r?(St=B,B=Vh(W,te)):(U=B,B=r)):(U=B,B=r)):(U=B,B=r),B}function Ye(){var B,W,ne,te;return B=U,W=U,ne=U,de++,e.charCodeAt(U)===93?(te=Oe,U++):(te=r,de===0&&Fe(as)),te===r&&(e.charCodeAt(U)===92?(te=Y,U++):(te=r,de===0&&Fe(an)),te===r&&(te=An())),de--,te===r?ne=void 0:(U=ne,ne=r),ne!==r?(te=fn(),te!==r?(ne=[ne,te],W=ne):(U=W,W=r)):(U=W,W=r),W!==r?B=e.substring(B,U):B=W,B===r&&(B=U,e.charCodeAt(U)===92?(W=Y,U++):(W=r,de===0&&Fe(an)),W!==r?(ne=Lt(),ne!==r?B=ne:(U=B,B=r)):(U=B,B=r),B===r&&(B=pt())),B}function pt(){var B,W,ne;return B=U,e.charCodeAt(U)===92?(W=Y,U++):(W=r,de===0&&Fe(an)),W!==r?(ne=_a(),ne!==r?(St=B,B=Sa()):(U=B,B=r)):(U=B,B=r),B}function Lt(){var B,W,ne,te;return B=Or(),B===r&&(B=U,e.charCodeAt(U)===48?(W=Se,U++):(W=r,de===0&&Fe(Sr)),W!==r?(ne=U,de++,te=P0(),de--,te===r?ne=void 0:(U=ne,ne=r),ne!==r?(St=B,B=m0()):(U=B,B=r)):(U=B,B=r),B===r&&(B=ks(),B===r&&(B=Wc()))),B}function Or(){var B;return B=er(),B===r&&(B=od()),B}function er(){var B,W;return e.charCodeAt(U)===39?(B=we,U++):(B=r,de===0&&Fe(Qt)),B===r&&(e.charCodeAt(U)===34?(B=ve,U++):(B=r,de===0&&Fe(pr)),B===r&&(e.charCodeAt(U)===92?(B=Y,U++):(B=r,de===0&&Fe(an)),B===r&&(B=U,e.charCodeAt(U)===98?(W=Re,U++):(W=r,de===0&&Fe(jc)),W!==r&&(St=B,W=zh()),B=W,B===r&&(B=U,e.charCodeAt(U)===102?(W=Ke,U++):(W=r,de===0&&Fe(ef)),W!==r&&(St=B,W=Rs()),B=W,B===r&&(B=U,e.charCodeAt(U)===110?(W=Qe,U++):(W=r,de===0&&Fe(Hn)),W!==r&&(St=B,W=g0()),B=W,B===r&&(B=U,e.charCodeAt(U)===114?(W=je,U++):(W=r,de===0&&Fe(Ea)),W!==r&&(St=B,W=v0()),B=W,B===r&&(B=U,e.charCodeAt(U)===116?(W=yt,U++):(W=r,de===0&&Fe(qc)),W!==r&&(St=B,W=w0()),B=W,B===r&&(B=U,e.charCodeAt(U)===118?(W=rt,U++):(W=r,de===0&&Fe(qh)),W!==r&&(St=B,W=y0()),B=W)))))))),B}function od(){var B,W,ne,te;return B=U,W=U,ne=U,de++,te=av(),te===r&&(te=An()),de--,te===r?ne=void 0:(U=ne,ne=r),ne!==r?(te=fn(),te!==r?(ne=[ne,te],W=ne):(U=W,W=r)):(U=W,W=r),W!==r?B=e.substring(B,U):B=W,B}function av(){var B;return B=er(),B===r&&(B=P0(),B===r&&(e.charCodeAt(U)===120?(B=vt,U++):(B=r,de===0&&Fe(Kc)),B===r&&(e.charCodeAt(U)===117?(B=sn,U++):(B=r,de===0&&Fe(ba))))),B}function ks(){var B,W,ne,te,me,ye;return B=U,e.charCodeAt(U)===120?(W=vt,U++):(W=r,de===0&&Fe(Kc)),W!==r?(ne=U,te=U,me=ni(),me!==r?(ye=ni(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r),te!==r?ne=e.substring(ne,U):ne=te,ne!==r?(St=B,B=E0(ne)):(U=B,B=r)):(U=B,B=r),B}function Wc(){var B,W,ne,te,me,ye,Xt,Nr;return B=U,e.charCodeAt(U)===117?(W=sn,U++):(W=r,de===0&&Fe(ba)),W!==r?(ne=U,te=U,me=ni(),me!==r?(ye=ni(),ye!==r?(Xt=ni(),Xt!==r?(Nr=ni(),Nr!==r?(me=[me,ye,Xt,Nr],te=me):(U=te,te=r)):(U=te,te=r)):(U=te,te=r)):(U=te,te=r),te!==r?ne=e.substring(ne,U):ne=te,ne!==r?(St=B,B=b0(ne)):(U=B,B=r)):(U=B,B=r),B}function P0(){var B;return Rr.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(Aa)),B}function ni(){var B;return Nn.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(Kh)),B}function nf(){var B,W;return B=U,e.charCodeAt(U)===46?(W=br,U++):(W=r,de===0&&Fe(tf)),W!==r&&(St=B,W=ls()),B=W,B}function Fa(){var B,W,ne,te;return de++,B=U,e.charCodeAt(U)===123?(W=s,U++):(W=r,de===0&&Fe(on)),W!==r?(ne=Yt(),e.charCodeAt(U)===125?(te=a,U++):(te=r,de===0&&Fe(ei)),te!==r?B=ne:(U=B,B=r)):(U=B,B=r),de--,B===r&&(W=r,de===0&&Fe(Vc)),B}function Yt(){var B,W;return B=U,W=ad(),St=B,W=Z2(W),B=W,B}function ad(){var B,W,ne,te,me,ye;if(B=U,W=[],ne=[],te=U,me=U,de++,Qs.test(e.charAt(U))?(ye=e.charAt(U),U++):(ye=r,de===0&&Fe(Ei)),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r),te!==r)for(;te!==r;)ne.push(te),te=U,me=U,de++,Qs.test(e.charAt(U))?(ye=e.charAt(U),U++):(ye=r,de===0&&Fe(Ei)),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r);else ne=r;for(ne===r&&(ne=U,e.charCodeAt(U)===123?(te=s,U++):(te=r,de===0&&Fe(on)),te!==r?(me=ad(),e.charCodeAt(U)===125?(ye=a,U++):(ye=r,de===0&&Fe(ei)),ye!==r?(te=[te,me,ye],ne=te):(U=ne,ne=r)):(U=ne,ne=r));ne!==r;){if(W.push(ne),ne=[],te=U,me=U,de++,Qs.test(e.charAt(U))?(ye=e.charAt(U),U++):(ye=r,de===0&&Fe(Ei)),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r),te!==r)for(;te!==r;)ne.push(te),te=U,me=U,de++,Qs.test(e.charAt(U))?(ye=e.charAt(U),U++):(ye=r,de===0&&Fe(Ei)),de--,ye===r?me=void 0:(U=me,me=r),me!==r?(ye=fn(),ye!==r?(me=[me,ye],te=me):(U=te,te=r)):(U=te,te=r);else ne=r;ne===r&&(ne=U,e.charCodeAt(U)===123?(te=s,U++):(te=r,de===0&&Fe(on)),te!==r?(me=ad(),e.charCodeAt(U)===125?(ye=a,U++):(ye=r,de===0&&Fe(ei)),ye!==r?(te=[te,me,ye],ne=te):(U=ne,ne=r)):(U=ne,ne=r))}return B=e.substring(B,U),B}function x0(){var B;return $t.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(j)),B}function sf(){var B;return tt.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(G)),B}function uv(){var B;return Ue.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(Q)),B}function cv(){var B;return gr.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(ae)),B}function lv(){var B;return vn.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(Be)),B}function of(){var B;return Et.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(xe)),B}function $o(){var B;return va.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(Me)),B}function af(){var B;return wn.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(Ve)),B}function T0(){var B;return De.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(sr)),B}function uf(){var B;return So.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(Br)),B}function R0(){var B;return qt.test(e.charAt(U))?(B=e.charAt(U),U++):(B=r,de===0&&Fe(Mn)),B}function or(){var B,W;for(B=[],W=Yc(),W===r&&(W=_a(),W===r&&(W=B0()));W!==r;)B.push(W),W=Yc(),W===r&&(W=_a(),W===r&&(W=B0()));return B}function cf(){var B,W;for(B=[],W=Yc(),W===r&&(W=I0());W!==r;)B.push(W),W=Yc(),W===r&&(W=I0());return B}function lf(){var B,W,ne,te;return B=U,W=or(),e.charCodeAt(U)===59?(ne=Ar,U++):(ne=r,de===0&&Fe(cn)),ne!==r?(W=[W,ne],B=W):(U=B,B=r),B===r&&(B=U,W=cf(),ne=Da(),ne===r&&(ne=null),te=_a(),te!==r?(W=[W,ne,te],B=W):(U=B,B=r),B===r&&(B=U,W=or(),ne=Xc(),ne!==r?(W=[W,ne],B=W):(U=B,B=r))),B}function Xc(){var B,W;return B=U,de++,e.length>U?(W=e.charAt(U),U++):(W=r,de===0&&Fe(Tu)),de--,W===r?B=void 0:(U=B,B=r),B}let Ba=t.reservedWords||[];if(ir=o(),ir!==r&&U===e.length)return ir;throw ir!==r&&U{"use strict";var dEe=P(x()),MQ=$2(),jQ=a$(),qQ=c$(),KQ=PS(),VQ=["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"],d0={VERSION:KQ,RESERVED_WORDS:VQ,GrammarError:MQ,parser:qQ,compiler:jQ,generate(e,t){t=t!==void 0?t:{};function r(o){let s={};return Object.keys(o).forEach(a=>{s[a]=o[a].slice()}),s}let n="plugins"in t?t.plugins:[],i={parser:d0.parser,passes:r(d0.compiler.passes),reservedWords:d0.RESERVED_WORDS.slice()};return n.forEach(o=>{o.use(i,t)}),d0.compiler.compile(i.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:i.reservedWords}),i.passes,t)}};l$.exports=d0});var ZS=Ce((XS,JS)=>{var CEe=P(x());(function(e,t){typeof XS=="object"&&typeof JS<"u"?JS.exports=t():typeof define=="function"&&define.amd?define(t):e.JSON5=t()})(XS,function(){"use strict";function e(ue,Ee){return Ee={exports:{}},ue(Ee,Ee.exports),Ee.exports}var t=e(function(ue){var Ee=ue.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=Ee)}),r=e(function(ue){var Ee=ue.exports={version:"2.6.5"};typeof __e=="number"&&(__e=Ee)}),n=r.version,i=function(ue){return typeof ue=="object"?ue!==null:typeof ue=="function"},o=function(ue){if(!i(ue))throw TypeError(ue+" is not an object!");return ue},s=function(ue){try{return!!ue()}catch{return!0}},a=!s(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7}),u=t.document,l=i(u)&&i(u.createElement),f=function(ue){return l?u.createElement(ue):{}},m=!a&&!s(function(){return Object.defineProperty(f("div"),"a",{get:function(){return 7}}).a!=7}),p=function(ue,Ee){if(!i(ue))return ue;var Xe,We;if(Ee&&typeof(Xe=ue.toString)=="function"&&!i(We=Xe.call(ue))||typeof(Xe=ue.valueOf)=="function"&&!i(We=Xe.call(ue))||!Ee&&typeof(Xe=ue.toString)=="function"&&!i(We=Xe.call(ue)))return We;throw TypeError("Can't convert object to primitive value")},d=Object.defineProperty,v=a?Object.defineProperty:function(Ee,Xe,We){if(o(Ee),Xe=p(Xe,!0),o(We),m)try{return d(Ee,Xe,We)}catch{}if("get"in We||"set"in We)throw TypeError("Accessors not supported!");return"value"in We&&(Ee[Xe]=We.value),Ee},g={f:v},y=function(ue,Ee){return{enumerable:!(ue&1),configurable:!(ue&2),writable:!(ue&4),value:Ee}},w=a?function(ue,Ee,Xe){return g.f(ue,Ee,y(1,Xe))}:function(ue,Ee,Xe){return ue[Ee]=Xe,ue},E={}.hasOwnProperty,S=function(ue,Ee){return E.call(ue,Ee)},F=0,_=Math.random(),H=function(ue){return"Symbol(".concat(ue===void 0?"":ue,")_",(++F+_).toString(36))},V=!1,C=e(function(ue){var Ee="__core-js_shared__",Xe=t[Ee]||(t[Ee]={});(ue.exports=function(We,it){return Xe[We]||(Xe[We]=it!==void 0?it:{})})("versions",[]).push({version:r.version,mode:V?"pure":"global",copyright:"\xA9 2019 Denis Pushkarev (zloirock.ru)"})}),I=C("native-function-to-string",Function.toString),L=e(function(ue){var Ee=H("src"),Xe="toString",We=(""+I).split(Xe);r.inspectSource=function(it){return I.call(it)},(ue.exports=function(it,bt,At,kr){var nr=typeof At=="function";nr&&(S(At,"name")||w(At,"name",bt)),it[bt]!==At&&(nr&&(S(At,Ee)||w(At,Ee,it[bt]?""+it[bt]:We.join(String(bt)))),it===t?it[bt]=At:kr?it[bt]?it[bt]=At:w(it,bt,At):(delete it[bt],w(it,bt,At)))})(Function.prototype,Xe,function(){return typeof this=="function"&&this[Ee]||I.call(this)})}),R=function(ue){if(typeof ue!="function")throw TypeError(ue+" is not a function!");return ue},k=function(ue,Ee,Xe){if(R(ue),Ee===void 0)return ue;switch(Xe){case 1:return function(We){return ue.call(Ee,We)};case 2:return function(We,it){return ue.call(Ee,We,it)};case 3:return function(We,it,bt){return ue.call(Ee,We,it,bt)}}return function(){return ue.apply(Ee,arguments)}},M="prototype",N=function(ue,Ee,Xe){var We=ue&N.F,it=ue&N.G,bt=ue&N.S,At=ue&N.P,kr=ue&N.B,nr=it?t:bt?t[Ee]||(t[Ee]={}):(t[Ee]||{})[M],is=it?r:r[Ee]||(r[Ee]={}),yi=is[M]||(is[M]={}),yn,Ln,Dr,En;it&&(Xe=Ee);for(yn in Xe)Ln=!We&&nr&&nr[yn]!==void 0,Dr=(Ln?nr:Xe)[yn],En=kr&&Ln?k(Dr,t):At&&typeof Dr=="function"?k(Function.call,Dr):Dr,nr&&L(nr,yn,Dr,ue&N.U),is[yn]!=Dr&&w(is,yn,En),At&&yi[yn]!=Dr&&(yi[yn]=Dr)};t.core=r,N.F=1,N.G=2,N.S=4,N.P=8,N.B=16,N.W=32,N.U=64,N.R=128;var D=N,O=Math.ceil,q=Math.floor,J=function(ue){return isNaN(ue=+ue)?0:(ue>0?q:O)(ue)},Y=function(ue){if(ue==null)throw TypeError("Can't call method on "+ue);return ue},ee=function(ue){return function(Ee,Xe){var We=String(Y(Ee)),it=J(Xe),bt=We.length,At,kr;return it<0||it>=bt?ue?"":void 0:(At=We.charCodeAt(it),At<55296||At>56319||it+1===bt||(kr=We.charCodeAt(it+1))<56320||kr>57343?ue?We.charAt(it):At:ue?We.slice(it,it+2):(At-55296<<10)+(kr-56320)+65536)}},se=ee(!1);D(D.P,"String",{codePointAt:function(Ee){return se(this,Ee)}});var le=r.String.codePointAt,ve=Math.max,we=Math.min,Pe=function(ue,Ee){return ue=J(ue),ue<0?ve(ue+Ee,0):we(ue,Ee)},Le=String.fromCharCode,Oe=String.fromCodePoint;D(D.S+D.F*(!!Oe&&Oe.length!=1),"String",{fromCodePoint:function(Ee){for(var Xe=arguments,We=[],it=arguments.length,bt=0,At;it>bt;){if(At=+Xe[bt++],Pe(At,1114111)!==At)throw RangeError(At+" is not a valid code point");We.push(At<65536?Le(At):Le(((At-=65536)>>10)+55296,At%1024+56320))}return We.join("")}});var fe=r.String.fromCodePoint,Se=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,Re=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,Ke=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Qe={Space_Separator:Se,ID_Start:Re,ID_Continue:Ke},je={isSpaceSeparator:function(Ee){return typeof Ee=="string"&&Qe.Space_Separator.test(Ee)},isIdStartChar:function(Ee){return typeof Ee=="string"&&(Ee>="a"&&Ee<="z"||Ee>="A"&&Ee<="Z"||Ee==="$"||Ee==="_"||Qe.ID_Start.test(Ee))},isIdContinueChar:function(Ee){return typeof Ee=="string"&&(Ee>="a"&&Ee<="z"||Ee>="A"&&Ee<="Z"||Ee>="0"&&Ee<="9"||Ee==="$"||Ee==="_"||Ee==="\u200C"||Ee==="\u200D"||Qe.ID_Continue.test(Ee))},isDigit:function(Ee){return typeof Ee=="string"&&/[0-9]/.test(Ee)},isHexDigit:function(Ee){return typeof Ee=="string"&&/[0-9A-Fa-f]/.test(Ee)}},yt,rt,vt,sn,br,Ar,wt,Rr,Nn,Qs=function(Ee,Xe){yt=String(Ee),rt="start",vt=[],sn=0,br=1,Ar=0,wt=void 0,Rr=void 0,Nn=void 0;do wt=va(),Nc[rt]();while(wt.type!=="eof");return typeof Xe=="function"?$t({"":Nn},"",Xe):Nn};function $t(ue,Ee,Xe){var We=ue[Ee];if(We!=null&&typeof We=="object")if(Array.isArray(We))for(var it=0;it0;){var Xe=wn();if(!je.isHexDigit(Xe))throw Gt(De());ue+=De()}return String.fromCodePoint(parseInt(ue,16))}var Nc={start:function(){if(wt.type==="eof")throw xs();_o()},beforePropertyName:function(){switch(wt.type){case"identifier":case"string":Rr=wt.value,rt="afterPropertyName";return;case"punctuator":wi();return;case"eof":throw xs()}},afterPropertyName:function(){if(wt.type==="eof")throw xs();rt="beforePropertyValue"},beforePropertyValue:function(){if(wt.type==="eof")throw xs();_o()},beforeArrayValue:function(){if(wt.type==="eof")throw xs();if(wt.type==="punctuator"&&wt.value==="]"){wi();return}_o()},afterPropertyValue:function(){if(wt.type==="eof")throw xs();switch(wt.value){case",":rt="beforePropertyName";return;case"}":wi()}},afterArrayValue:function(){if(wt.type==="eof")throw xs();switch(wt.value){case",":rt="beforeArrayValue";return;case"]":wi()}},end:function(){}};function _o(){var ue;switch(wt.type){case"punctuator":switch(wt.value){case"{":ue={};break;case"[":ue=[];break}break;case"null":case"boolean":case"numeric":case"string":ue=wt.value;break}if(Nn===void 0)Nn=ue;else{var Ee=vt[vt.length-1];Array.isArray(Ee)?Ee.push(ue):Object.defineProperty(Ee,Rr,{value:ue,writable:!0,enumerable:!0,configurable:!0})}if(ue!==null&&typeof ue=="object")vt.push(ue),Array.isArray(ue)?rt="beforeArrayValue":rt="beforePropertyName";else{var Xe=vt[vt.length-1];Xe==null?rt="end":Array.isArray(Xe)?rt="afterArrayValue":rt="afterPropertyValue"}}function wi(){vt.pop();var ue=vt[vt.length-1];ue==null?rt="end":Array.isArray(ue)?rt="afterArrayValue":rt="afterPropertyValue"}function Gt(ue){return Do(ue===void 0?"JSON5: invalid end of input at "+br+":"+Ar:"JSON5: invalid character '"+wa(ue)+"' at "+br+":"+Ar)}function xs(){return Do("JSON5: invalid end of input at "+br+":"+Ar)}function xu(){return Ar-=5,Do("JSON5: invalid identifier character at "+br+":"+Ar)}function Lc(ue){console.warn("JSON5: '"+wa(ue)+"' in strings is not valid ECMAScript; consider escaping")}function wa(ue){var Ee={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(Ee[ue])return Ee[ue];if(ue<" "){var Xe=ue.charCodeAt(0).toString(16);return"\\x"+("00"+Xe).substring(Xe.length)}return ue}function Do(ue){var Ee=new SyntaxError(ue);return Ee.lineNumber=br,Ee.columnNumber=Ar,Ee}var Uc=function(Ee,Xe,We){var it=[],bt="",At,kr,nr="",is;if(Xe!=null&&typeof Xe=="object"&&!Array.isArray(Xe)&&(We=Xe.space,is=Xe.quote,Xe=Xe.replacer),typeof Xe=="function")kr=Xe;else if(Array.isArray(Xe)){At=[];for(var yi=0,yn=Xe;yi0&&(We=Math.min(10,Math.floor(We)),nr=" ".substr(0,We)):typeof We=="string"&&(nr=We.substr(0,10)),En("",{"":Ee});function En(Kt,Fr){var mt=Fr[Kt];switch(mt!=null&&(typeof mt.toJSON5=="function"?mt=mt.toJSON5(Kt):typeof mt.toJSON=="function"&&(mt=mt.toJSON(Kt))),kr&&(mt=kr.call(Fr,Kt,mt)),mt instanceof Number?mt=Number(mt):mt instanceof String?mt=String(mt):mt instanceof Boolean&&(mt=mt.valueOf()),mt){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof mt=="string")return Un(mt,!1);if(typeof mt=="number")return String(mt);if(typeof mt=="object")return Array.isArray(mt)?an(mt):Fo(mt)}function Un(Kt){for(var Fr={"'":.1,'"':.2},mt={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},vr="",un=0;un=0)throw TypeError("Converting circular structure to JSON5");it.push(Kt);var Fr=bt;bt=bt+nr;for(var mt=At||Object.keys(Kt),vr=[],un=0,pr=mt;un=0)throw TypeError("Converting circular structure to JSON5");it.push(Kt);var Fr=bt;bt=bt+nr;for(var mt=[],vr=0;vr"u"||(NC=!0,MC.forEach(t=>{let r=console[t];typeof r=="function"&&(console[t]=function(...n){if(r.apply(console,JU(n,{isNode:e.env.isNode})),!Ww)try{Ww=!0,rH(e,t,n)}finally{Ww=!1}})}))}function nH(e){let t=Date.now();if(b1!==null&&tn.trim()).filter(Boolean);if(t.length===0)return t;let r=t[0].replace(qC,"").trim();return r!==t[0]&&(r?t[0]=r:t.shift()),t}function aH(e){return e.length<3||!OC.test(e[0])||!OC.test(e[e.length-1])?!1:e.slice(1,-1).some(t=>jC.test(t))}function uH(e){let t=e.replace(YU,"");return XU.some(r=>r.test(t))}function cH(e){if(e instanceof Error)return e.stack||e.message||String(e);if(typeof e=="string")return e;if(e==null)return String(e);if(typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function lH(e){return e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.time=="number"&&typeof e.level=="string"&&typeof e.message=="string"}function fH(){return`${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var fse=P(x(),1),JC="3.7.8",hH=JC,Af=typeof Buffer=="function",zC=typeof TextDecoder=="function"?new TextDecoder:void 0,GC=typeof TextEncoder=="function"?new TextEncoder:void 0,dH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_d=Array.prototype.slice.call(dH),A1=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(_d),pH=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,_n=String.fromCharCode.bind(String),YC=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),ZC=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),QC=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),e8=e=>{let t,r,n,i,o="",s=e.length%3;for(let a=0;a255||(n=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|i,o+=_d[t>>18&63]+_d[t>>12&63]+_d[t>>6&63]+_d[t&63]}return s?o.slice(0,s-3)+"===".substring(s):o},Zw=typeof btoa=="function"?e=>btoa(e):Af?e=>Buffer.from(e,"binary").toString("base64"):e8,Xw=Af?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,i=e.length;nt?ZC(Xw(e)):Xw(e),mH=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?_n(192|t>>>6)+_n(128|t&63):_n(224|t>>>12&15)+_n(128|t>>>6&63)+_n(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return _n(240|t>>>18&7)+_n(128|t>>>12&63)+_n(128|t>>>6&63)+_n(128|t&63)}},gH=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,t8=e=>e.replace(gH,mH),WC=Af?e=>Buffer.from(e,"utf8").toString("base64"):GC?e=>Xw(GC.encode(e)):e=>Zw(t8(e)),bf=(e,t=!1)=>t?ZC(WC(e)):WC(e),XC=e=>bf(e,!0),vH=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,wH=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 _n((r>>>10)+55296)+_n((r&1023)+56320);case 3:return _n((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return _n((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},r8=e=>e.replace(vH,wH),n8=e=>{if(e=e.replace(/\s+/g,""),!pH.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r,n,i=[];for(let o=0;o>16&255)):n===64?i.push(_n(t>>16&255,t>>8&255)):i.push(_n(t>>16&255,t>>8&255,t&255));return i.join("")},Qw=typeof atob=="function"?e=>atob(QC(e)):Af?e=>Buffer.from(e,"base64").toString("binary"):n8,s8=Af?e=>YC(Buffer.from(e,"base64")):e=>YC(Qw(e).split("").map(t=>t.charCodeAt(0))),i8=e=>s8(o8(e)),yH=Af?e=>Buffer.from(e,"base64").toString("utf8"):zC?e=>zC.decode(s8(e)):e=>r8(Qw(e)),o8=e=>QC(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),Jw=e=>yH(o8(e)),EH=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)},a8=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),u8=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,a8(r));e("fromBase64",function(){return Jw(this)}),e("toBase64",function(t){return bf(this,t)}),e("toBase64URI",function(){return bf(this,!0)}),e("toBase64URL",function(){return bf(this,!0)}),e("toUint8Array",function(){return i8(this)})},c8=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,a8(r));e("toBase64",function(t){return S1(this,t)}),e("toBase64URI",function(){return S1(this,!0)}),e("toBase64URL",function(){return S1(this,!0)})},bH=()=>{u8(),c8()},It={version:JC,VERSION:hH,atob:Qw,atobPolyfill:n8,btoa:Zw,btoaPolyfill:e8,fromBase64:Jw,toBase64:bf,encode:bf,encodeURI:XC,encodeURL:XC,utob:t8,btou:r8,decode:Jw,isValid:EH,fromUint8Array:S1,toUint8Array:i8,extendString:u8,extendUint8Array:c8,extendBuiltins:bH};var Vu=typeof $task<"u",Ua=typeof $loon<"u",zu=typeof $httpClient<"u"&&!Ua,ko=eval('typeof process !== "undefined"'),l8=typeof $environment<"u"&&$environment["stash-version"],f8=typeof $rocket<"u",AH=typeof Egern<"u"&&Egern.version,SH=typeof $native<"u",Gu=typeof $Plugins<"u";function C1(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}function CH(e){let[t,r,n,i,o,s,a]=e.match(/^socks5:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(o)o=parseInt(o,10);else throw $.error(`port is not present in line: ${e}`),new Error(`port is not present in line: ${e}`);return{type:5,host:i,port:o,userId:r!=null?decodeURIComponent(r):void 0,password:n!=null?decodeURIComponent(n):void 0}}function _H(e){let t=[],r=!1;for(let[n,i]of Object.entries(e||{})){let o=n.toLowerCase();o==="accept"&&(r=!0,i==null)||t.push([o,i])}return r||t.push(["accept","*/*"]),Object.fromEntries(t)}var _1=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=Yi(),this.env=ws(),ko){let dotenv=eval('require("dotenv")');dotenv.config()}this.node=(()=>{if(ko){let fs=eval("require('fs')");return{fs}}else return null})(),this.initCache(),KC(this);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(Vu&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(Ua||zu)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),Gu&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),ko){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}`)}C1(this.root)||(this.node.fs.writeFileSync(rootPath,JSON.stringify({}),{flag:"w"}),this.root={});let fpath=`${basePath}/${this.name}.json`,backupPath=`${basePath}/${this.name}_${Date.now()}.json`;if(this.log(`Data path: ${fpath}`),this.node.fs.existsSync(fpath))try{if(this.cache=JSON.parse(this.node.fs.readFileSync(`${fpath}`,"utf-8")),!C1(this.cache))throw new Error("Invalid Data")}catch{try{let t=It.decode(this.node.fs.readFileSync(`${fpath}`,"utf-8"));if(this.cache=JSON.parse(t),this.node.fs.writeFileSync(fpath,t,{flag:"w"}),!C1(this.cache))throw new Error("Invalid Data")}catch(t){this.node.fs.copyFileSync(fpath,backupPath),this.error(`Failed to parse ${fpath}: ${t.message}. Backup created at ${backupPath}`)}}C1(this.cache)||(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"w"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(Vu&&$prefs.setValueForKey(data,this.name),(Ua||zu)&&$persistentStore.write(data,this.name),Gu&&$Plugins.SubStoreCache.set(this.name,data),ko){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),zu||Ua)return $persistentStore.write(e,t);if(Vu)return $prefs.setValueForKey(e,t);if(ko&&(this.root[t]=e),Gu)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),zu||Ua)return $persistentStore.read(e);if(Vu)return $prefs.valueForKey(e);if(ko)return this.root[e];if(Gu)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),zu||Ua)return $persistentStore.write(null,e);if(Vu)return $prefs.removeValueForKey(e);if(ko&&delete this.root[e],Gu)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(Vu&&$notify(title,subtitle,content,options),zu&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),Ua){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(ko){let content_=content+(openURL?` \u70B9\u51FB\u8DF3\u8F6C: ${openURL}`:"")+(mediaURL?` \u591A\u5A92\u4F53: ${mediaURL}`:"");console.log(`[Notify] ${title} ${subtitle} ${content_} `);let push=eval("process.env.SUB_STORE_PUSH_SERVICE");if(push)if(/^https?:\/\//.test(push)){let e=push.replace("[\u63A8\u9001\u6807\u9898]",encodeURIComponent(title||"Sub-Store")).replace("[\u63A8\u9001\u5185\u5BB9]",encodeURIComponent([subtitle,content_].map(r=>r).join(` `)));Yi().get({url:e}).then(r=>{console.log(`[Push Service] URL: ${e} RES: ${r.statusCode} ${r.body}`)}).catch(r=>{console.log(`[Push Service] URL: ${e} ERROR: ${r}`)})}else{let{execFile}=eval('require("child_process")');execFile("shoutrrr",["send","--url",push,"--message",`${title} ${subtitle} ${content_}`],(e,t,r)=>{if(e){console.log(`[Push Service] URL: ${push} ERROR: ${e}`);return}r&&console.log(`[Push Service] URL: ${push} stderr: ${r}`),console.log(`[Push Service] URL: ${push} stdout: ${t}`)})}}Gu&&$Plugins.Notify(title,subtitle+` `+content)}log(e){this.debug&&console.log(`[${this.name}] LOG: ${e}`)}info(e){console.log(`[${this.name}] INFO: ${e}`)}warn(e){console.log(`[${this.name}] WARN: ${e}`)}error(e){console.log(`[${this.name}] ERROR: ${e}`)}wait(e){return new Promise(t=>setTimeout(t,e))}done(e={}){Vu||Ua||zu||Gu?$done(e):ko&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function ws(){return{isQX:Vu,isLoon:Ua,isSurge:zu,isNode:ko,isStash:l8,isShadowRocket:f8,isEgern:AH,isLanceX:SH,isGUIforCores:Gu}}function Yi(defaultOptions={baseURL:""}){let{isQX,isLoon,isSurge,isNode,isGUIforCores}=ws(),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;if(isQX)worker=$task.fetch({method,url:options.url,headers:options.headers,body:options.body,opts:options.opts});else if(isLoon||isSurge||isNode){let run=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||l8||f8)&&(opts.timeout=Math.ceil(opts.timeout/1e3),e="s")}if(isNode){let undici=eval("require('undici')"),{socksDispatcher}=eval("require('fetch-socks')"),defaultMaxHeaderSize=32*1024,parsedMaxHeaderSize=Number.parseInt(eval("process.env.SUB_STORE_MAX_HEADER_SIZE"),10),maxHeaderSize=Number.isInteger(parsedMaxHeaderSize)&&parsedMaxHeaderSize>0?parsedMaxHeaderSize:defaultMaxHeaderSize,{ProxyAgent,EnvHttpProxyAgent,request,interceptors}=undici,allowH2=opts.allowH2!==!1,agentOpts={connect:{rejectUnauthorized:!(opts.strictSSL===!1||opts.insecure===!0||opts.rejectUnauthorized===!1),allowH2},bodyTimeout:opts.timeout,headersTimeout:opts.timeout,maxHeaderSize,allowH2},tlsOptions={rejectUnauthorized:agentOpts.connect.rejectUnauthorized,allowH2};opts.tls={...opts.tls||{},...tlsOptions};try{let url=new URL(opts.url);(url.username||url.password)&&(opts.headers={...opts.headers||{},Authorization:`Basic ${Buffer.from(`${url.username||""}:${url.password||""}`).toString("base64")}`}),opts.headers=_H(opts.headers);let dispatcher;if(!opts.proxy){let allProxy=eval("process.env.all_proxy")||eval("process.env.ALL_PROXY");allProxy&&/^socks5:\/\//.test(allProxy)&&(opts.proxy=allProxy)}opts.proxy?/^socks5:\/\//.test(opts.proxy)?dispatcher=socksDispatcher(CH(opts.proxy),{...agentOpts,requestTls:tlsOptions}):dispatcher=new ProxyAgent({...agentOpts,uri:opts.proxy,requestTls:tlsOptions,proxyTunnel:opts.proxyTunnel}):dispatcher=new EnvHttpProxyAgent({...agentOpts,requestTls:tlsOptions,proxyTunnel:opts.proxyTunnel});let response=await request(opts.url,{...opts,method:method.toUpperCase(),dispatcher:dispatcher.compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirect:!0}))});resolve({statusCode:response.statusCode,headers:response.headers,body:opts.encoding===null?await response.body.arrayBuffer():await response.body.text()})}catch(e){reject(e)}}else $httpClient[method.toLowerCase()](opts,(e,t,r)=>{e?reject(e):resolve({statusCode:t.status||t.statusCode,headers:t.headers,body:r})})};worker=new Promise((e,t)=>{run(e,t).catch(t)})}else isGUIforCores&&(worker=new Promise(async(e,t)=>{try{let r=await $Plugins.Requests({method,url:options.url,headers:options.headers,body:options.body,autoTransformBody:!1,options:{Proxy:options.proxy,Timeout:options.timeout?options.timeout/1e3:15}});e({statusCode:r.status,headers:r.headers,body:r.body})}catch(r){t(r)}}));let timeoutid,timer=timeout?new Promise((e,t)=>{timeoutid=setTimeout(()=>(events.onTimeout(),t(`${method} URL: ${options.url} exceeds the timeout ${timeout} ms`)),timeout)}):null,request=timer?Promise.race([timer,worker]):worker;return request.finally(()=>{timer&&typeof clearTimeout<"u"&&clearTimeout(timeoutid)}).then(e=>events.onResponse(e))}let http={request:e=>send(e.method||"GET",e)};return methods.forEach(e=>http[e.toLowerCase()]=t=>send(e,t)),http}var DH=new _1("sub-store"),z=DH;function ey(){FH()}function FH(){let e=z.read(Gw);e||BH(),e!=="2.0"&&z.write("2.0",Gw)}function BH(){z.info("Start migrating...");let e=z.read(Kn)||{},t=Object.values(e).map(v=>(v.source=v.source||"remote",p(v),d(v),v));z.write(t,Kn);let r=z.read(Fi)||{},n=Object.values(r).map(v=>(delete v.ua,p(v),d(v),v));z.write(n,Fi);let i=z.read(vs)||{},o=Object.values(i);z.write(o,vs);let s=z.read(Cd)||{},a=Object.values(s);z.write(a,Cd);let u=z.read(ci)||{},l=Object.values(u);z.write(l,ci);let f=z.read(Cn)||{},m=Object.values(f);z.write(m,Cn),delete z.cache.builtin,z.info("Migration complete!");function p(v){let g=v["display-name"];g&&(v.displayName=g,delete v["display-name"])}function d(v){let g=v.process;if(!g||g.length===0)return;let y=[],w={type:"Quick Setting Operator",args:{udp:"DEFAULT",tfo:"DEFAULT",scert:"DEFAULT","vmess aead":"DEFAULT",useless:"DEFAULT"}};for(let E of g)if(E.type){if(E.type==="Useless Filter")w.args.useless="ENABLED";else if(E.type==="Set Property Operator"){let{key:S,value:F}=E.args;switch(S){case"udp":w.args.udp=F?"ENABLED":"DISABLED";break;case"tfo":w.args.tfo=F?"ENABLED":"DISABLED";break;case"skip-cert-verify":w.args.scert=F?"ENABLED":"DISABLED";break;case"aead":w.args["vmess aead"]=F?"ENABLED":"DISABLED";break}}else if(E.type.indexOf("Keyword")===-1)if(E.type==="Flag Operator"){let S=typeof E.args>"u"?!0:E.args;E.args={mode:S?"add":"remove"},y.push(E)}else y.push(E)}y.unshift(w),v.process=y}}var Ise=P(x());var _se=P(x()),m8="SUB_STORE_CORS_ALLOWED_ORIGINS",IH="*",$H="https://sub-store.vercel.app,http://substore.stash,https://substore.stash",h8="cors",Sf="*";function PH(e){if(e==null||e==="")return{};if(typeof e=="object")return e;let t=D1(`${e}`.trim());return Object.fromEntries(t.split("&").filter(Boolean).map(r=>{let[n,...i]=r.split("=");return[D1(p8(n).trim()),D1(p8(i.join("=").trim()))]}))}function xH({isNode:e,envValue:t,argument:r}={}){let n=e?IH:$H,i=e?t:PH(r)?.[h8],o=i!=null&&`${i}`.trim()!=="",s=o?i:n,a=o?e?`env:${m8}`:`argument:${h8}`:e?"default:node":"default:non-node",u=d8(s,a);return!u.wildcard&&u.origins.length===0?d8(n,e?"default:node":"default:non-node"):u}function g8({isNode:e}={}){return xH({isNode:e,envValue:e?TH():void 0,argument:e?void 0:RH()})}function ty(e,t){if(!t||e?.wildcard)return!0;let r=ry(t);return e?.origins?.includes(r)}function v8(e,t){return e?.wildcard?{"Access-Control-Allow-Origin":Sf}:!t||!ty(e,t)?{}:{"Access-Control-Allow-Origin":ry(t),Vary:"Origin"}}function w8(e){return`${e?.wildcard?Sf:e?.origins?.join(",")||""} (${e?.source})`}function d8(e,t){let r=`${e}`.split(/[,,\s]+/).map(i=>i.trim()).filter(Boolean);if(r.includes(Sf))return{wildcard:!0,origins:[],source:t,value:Sf};let n=[...new Set(r.map(ry))];return{wildcard:!1,origins:n,source:t,value:n.join(",")}}function ry(e){let t=D1(`${e}`.trim());if(t===Sf)return Sf;try{return new URL(t).origin}catch{return t}}function TH(){try{return eval(`process.env.${m8}`)}catch{return}}function RH(){try{if(typeof $argument<"u")return $argument}catch{return}}function p8(e){try{return decodeURIComponent(e)}catch{return e}}function D1(e){return e.replace(/^["']|["']$/g,"")}function ny({substore:$,port,host}){let{isNode}=ws(),corsPolicy=g8({isNode});$.info(`[CORS] allowed origins: ${w8(corsPolicy)}`);let DEFAULT_HEADERS={"Content-Type":"text/plain;charset=UTF-8","Access-Control-Allow-Methods":"POST,GET,OPTIONS,PATCH,PUT,DELETE","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept","X-Powered-By":isNode&&eval("process.env.SUB_STORE_X_POWERED_BY")||"Sub-Store"};if(isNode){let express_=eval('require("express")'),bodyParser=eval('require("body-parser")'),app=express_(),limit=eval("process.env.SUB_STORE_BODY_JSON_LIMIT")||"1mb";return $.info(`[BACKEND] body JSON limit: ${limit}`),app.use((e,t,r)=>{let n=t.setHeader.bind(t);t.setHeader=function(i,o){function s(a){if(typeof a!="string")return a;if(["profile-web-page-url"].includes(i.toLowerCase()))try{return new URL(a).href}catch{return a}return a}try{return Array.isArray(o)?o=o.map(s):o=s(o),n(i,o)}catch{return console.log(`Invalid header ignored ${i}: ${o}`),this}},r()}),app.use((e,t,r)=>{let n=applyCors(e.headers?.origin,e.method);if(t.set({...DEFAULT_HEADERS,...n.headers}),!n.allowed){t.status(403).end("CORS origin not allowed");return}if(n.preflight){t.status(200).end();return}r()}),app.use(bodyParser.json({verify:rawBodySaver,limit})),app.use(bodyParser.urlencoded({verify:rawBodySaver,extended:!0})),app.use(bodyParser.raw({verify:rawBodySaver,type:"*/*"})),app.start=()=>{app.get("*",function(t,r){r.status(404).end()});let e=app.listen(port,host,()=>{let{address:t,port:r}=e.address();$.info(`[BACKEND] listening on ${t}:${r}`)})},app}let handlers=[],METHODS_NAMES=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD'","ALL"],dispatch=(e,t=0)=>{let{method:r,url:n,headers:i,body:o}=e;i=kH(i),/json/i.test(i["content-type"])&&(o=JSON.parse(o)),r=r.toUpperCase();let{path:s,query:a}=NH(n),u=applyCors(i.origin,r);if(!u.allowed){Response().status(403).send("CORS origin not allowed");return}if(u.preflight){Response(u.headers).status(200).end();return}let l=null,f,m=0;for(f=t;fm&&(l=handlers[f],m=p.split("/").length)}if(l){let p=()=>{dispatch(r,n,f)},d={method:r,url:n,path:s,query:a,params:y8(l.pattern,s),headers:i,body:o},v=Response(u.headers),g=l.callback,y=w=>{v.status(500).json({status:"failed",message:`Internal Server Error: ${w}`})};if(g.constructor.name==="AsyncFunction")g(d,v,p).catch(y);else try{g(d,v,p)}catch(w){y(w)}}else Response(u.headers).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(e={}){let t=200,{isQX:r,isLoon:n,isSurge:i,isGUIforCores:o}=ws(),s={...DEFAULT_HEADERS,...e},a={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",403:"HTTP/1.1 403 Forbidden",404:"HTTP/1.1 404 Not Found",500:"HTTP/1.1 500 Internal Server Error"};return new class{status(u){return t=u,this}send(u=""){let l={status:r?a[t]:t,body:u,headers:s};r||o?$done(l):(n||i)&&$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 s[u]=l,this}removeHeader(u){return delete s[u],this}}}function applyCors(e,t){let r=ty(corsPolicy,e);return{allowed:r,preflight:!!e&&r&&t?.toUpperCase()==="OPTIONS",headers:r?v8(corsPolicy,e):{}}}}function kH(e){let t={};for(let r of Object.keys(e))t[r.toLowerCase()]=e[r];return t}function OH(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!!e&&typeof e=="object"&&e[Es]===V1,Zi=e=>!!e&&typeof e=="object"&&e[Es]===z1,Qi=e=>!!e&&typeof e=="object"&&e[Es]===Xi,Nt=e=>!!e&&typeof e=="object"&&e[Es]===Py,Dt=e=>!!e&&typeof e=="object"&&e[Es]===li,eo=e=>!!e&&typeof e=="object"&&e[Es]===Va;function Jt(e){if(e&&typeof e=="object")switch(e[Es]){case Xi:case Va:return!0}return!1}function Mt(e){if(e&&typeof e=="object")switch(e[Es]){case V1:case Xi:case li:case Va:return!0}return!1}var G1=e=>(Dt(e)||Jt(e))&&!!e.anchor;var Wse=P(x(),1);var Vs=Symbol("break visit"),d_=Symbol("skip children"),Uo=Symbol("remove node");function Ho(e,t){let r=p_(t);Zi(e)?kf(null,e.contents,r,Object.freeze([e]))===Uo&&(e.contents=null):kf(null,e,r,Object.freeze([]))}Ho.BREAK=Vs;Ho.SKIP=d_;Ho.REMOVE=Uo;function kf(e,t,r,n){let i=m_(e,t,r,n);if(Mt(i)||Nt(i))return g_(e,n,i),kf(e,i,r,n);if(typeof i!="symbol"){if(Jt(t)){n=Object.freeze(n.concat(t));for(let o=0;oe.replace(/[!,[\]{}]/g,t=>fK[t]),Mo=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let n=t.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[o,s]=n;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[o]=n;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return r(6,`Unsupported YAML version ${o}`,s),!1}}default:return r(0,`Unknown directive ${i}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let s=t.slice(2,-1);return s==="!"||s==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),s)}let[,n,i]=t.match(/^(.*!)([^!]*)$/s);i||r(`The ${t} tag has no suffix`);let o=this.tags[n];if(o)try{return o+decodeURIComponent(i)}catch(s){return r(String(s)),null}return n==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,n]of Object.entries(this.tags))if(t.startsWith(n))return r+hK(t.substring(n.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(t&&n.length>0&&Mt(t.contents)){let o={};Ho(t.contents,(s,a)=>{Mt(a)&&a.tag&&(o[a.tag]=!0)}),i=Object.keys(o)}else i=[];for(let[o,s]of n)o==="!!"&&s==="tag:yaml.org,2002:"||(!t||i.some(a=>a.startsWith(s)))&&r.push(`%TAG ${o} ${s}`);return r.join(` `)}};Mo.defaultYaml={explicit:!1,version:"1.2"};Mo.defaultTags={"!!":"tag:yaml.org,2002:"};var hce=P(x(),1);var Eie=P(x(),1);var nie=P(x(),1);function W1(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function xy(e){let t=new Set;return Ho(e,{Value(r,n){n.anchor&&t.add(n.anchor)}}),t}function Ty(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}function v_(e,t){let r=[],n=new Map,i=null;return{onAnchor:o=>{r.push(o),i??(i=xy(e));let s=Ty(t,i);return i.add(s),s},setAnchors:()=>{for(let o of r){let s=n.get(o);if(typeof s=="object"&&s.anchor&&(Dt(s.node)||Jt(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:n}}var die=P(x(),1);var iie=P(x(),1);function Ju(e,t,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let i=0,o=n.length;iQr(n,String(i),r));if(e&&typeof e.toJSON=="function"){if(!r||!G1(e))return e.toJSON(t,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(e,n),r.onCreate=o=>{n.res=o,delete r.onCreate};let i=e.toJSON(t,r);return r.onCreate&&r.onCreate(i),i}return typeof e=="bigint"&&!r?.keep?Number(e):e}var Zu=class{constructor(t){Object.defineProperty(this,Es,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:n,onAnchor:i,reviver:o}={}){if(!Zi(t))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=Qr(this,"",s);if(typeof i=="function")for(let{count:u,res:l}of s.anchors.values())i(l,u);return typeof o=="function"?Ju(o,{"":a},"",a):a}};var za=class extends Zu{constructor(t){super(V1),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let n;r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],Ho(t,{Node:(o,s)=>{(Ji(s)||G1(s))&&n.push(s)}}),r&&(r.aliasResolveCache=n));let i;for(let o of n){if(o===this)break;o.anchor===this.source&&(i=o)}return i}toJSON(t,r){if(!r)return{source:this.source};let{anchors:n,doc:i,maxAliasCount:o}=r,s=this.resolve(i,r);if(!s){let u=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(u)}let a=n.get(s);if(a||(Qr(s,null,r),a=n.get(s)),a?.res===void 0){let u="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(u)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=X1(i,s,n)),a.count*a.aliasCount>o)){let u="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(u)}return a.res}toString(t,r,n){let i=`*${this.source}`;if(t){if(W1(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(t.implicitKey)return`${i} `}return i}};function X1(e,t,r){if(Ji(t)){let n=t.resolve(e),i=r&&n&&r.get(n);return i?i.count*i.aliasCount:0}else if(Jt(t)){let n=0;for(let i of t.items){let o=X1(e,i,r);o>n&&(n=o)}return n}else if(Nt(t)){let n=X1(e,t.key,r),i=X1(e,t.value,r);return Math.max(n,i)}return 1}var kie=P(x(),1);var $ie=P(x(),1);var _ie=P(x(),1);var J1=e=>!e||typeof e!="function"&&typeof e!="object",Je=class extends Zu{constructor(t){super(li),this.value=t}toJSON(t,r){return r?.keep?this.value:Qr(this.value,t,r)}toString(){return String(this.value)}};Je.BLOCK_FOLDED="BLOCK_FOLDED";Je.BLOCK_LITERAL="BLOCK_LITERAL";Je.PLAIN="PLAIN";Je.QUOTE_DOUBLE="QUOTE_DOUBLE";Je.QUOTE_SINGLE="QUOTE_SINGLE";var dK="tag:yaml.org,2002:";function pK(e,t,r){if(t){let n=r.filter(o=>o.tag===t),i=n.find(o=>!o.format)??n[0];if(!i)throw new Error(`Tag ${t} not found`);return i}return r.find(n=>n.identify?.(e)&&!n.format)}function Ga(e,t,r){if(Zi(e)&&(e=e.contents),Mt(e))return e;if(Nt(e)){let m=r.schema[Xi].createNode?.(r.schema,null,r);return m.items.push(e),m}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:n,onAnchor:i,onTagObj:o,schema:s,sourceObjects:a}=r,u;if(n&&e&&typeof e=="object"){if(u=a.get(e),u)return u.anchor??(u.anchor=i(e)),new za(u.anchor);u={anchor:null,node:null},a.set(e,u)}t?.startsWith("!!")&&(t=dK+t.slice(2));let l=pK(e,t,s.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let m=new Je(e);return u&&(u.node=m),m}l=e instanceof Map?s[Xi]:Symbol.iterator in Object(e)?s[Va]:s[Xi]}o&&(o(l),delete r.onTagObj);let f=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,e,r):new Je(e);return t?f.tag=t:l.default||(f.tag=l.tag),u&&(u.node=f),f}function Td(e,t,r){let n=r;for(let i=t.length-1;i>=0;--i){let o=t[i];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=n,n=s}else n=new Map([[o,n]])}return Ga(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Lf=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,Nf=class extends Zu{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(n=>Mt(n)||Nt(n)?n.clone(t):n),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(Lf(t))this.add(r);else{let[n,...i]=t,o=this.get(n,!0);if(Jt(o))o.addIn(i,r);else if(o===void 0&&this.schema)this.set(n,Td(this.schema,i,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(t){let[r,...n]=t;if(n.length===0)return this.delete(r);let i=this.get(r,!0);if(Jt(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}getIn(t,r){let[n,...i]=t,o=this.get(n,!0);return i.length===0?!r&&Dt(o)?o.value:o:Jt(o)?o.getIn(i,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!Nt(r))return!1;let n=r.value;return n==null||t&&Dt(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(t){let[r,...n]=t;if(n.length===0)return this.has(r);let i=this.get(r,!0);return Jt(i)?i.hasIn(n):!1}setIn(t,r){let[n,...i]=t;if(i.length===0)this.set(n,r);else{let o=this.get(n,!0);if(Jt(o))o.setIn(i,r);else if(o===void 0&&this.schema)this.set(n,Td(this.schema,i,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}};var Eoe=P(x(),1);var toe=P(x(),1);var Wie=P(x(),1);var Nie=P(x(),1),w_=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function $i(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var jo=(e,t,r)=>e.endsWith(` `)?$i(r,t):r.includes(` `)?` `+$i(r,t):(e.endsWith(" ")?"":" ")+r;var qie=P(x(),1);var Uie=P(x(),1),Ry="flow",Z1="block",Rd="quoted";function kd(e,t,r="flow",{indentAtStart:n,lineWidth:i=80,minContentWidth:o=20,onFold:s,onOverflow:a}={}){if(!i||i<0)return e;ii-Math.max(2,o)?l.push(0):m=i-n);let p,d,v=!1,g=-1,y=-1,w=-1;r===Z1&&(g=y_(e,g,t.length),g!==-1&&(m=g+u));for(let S;S=e[g+=1];){if(r===Rd&&S==="\\"){switch(y=g,e[g+1]){case"x":g+=3;break;case"u":g+=5;break;case"U":g+=9;break;default:g+=1}w=g}if(S===` `)r===Z1&&(g=y_(e,g,t.length)),m=g+t.length+u,p=void 0;else{if(S===" "&&d&&d!==" "&&d!==` `&&d!==" "){let F=e[g+1];F&&F!==" "&&F!==` `&&F!==" "&&(p=g)}if(g>=m)if(p)l.push(p),m=p+u,p=void 0;else if(r===Rd){for(;d===" "||d===" ";)d=S,S=e[g+=1],v=!0;let F=g>w+1?g-2:y-1;if(f[F])return e;l.push(F),f[F]=!0,m=F+u,p=void 0}else v=!0}d=S}if(v&&a&&a(),l.length===0)return e;s&&s();let E=e.slice(0,l[0]);for(let S=0;S({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),tm=e=>/^(%|---|\.\.\.)/m.test(e);function mK(e,t,r){if(!t||t<0)return!1;let n=t-r,i=e.length;if(i<=n)return!1;for(let o=0,s=0;on)return!0;if(s=o+1,i-s<=n)return!1}return!0}function Od(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=t,i=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(tm(e)?" ":""),s="",a=0;for(let u=0,l=r[u];l;l=r[++u])if(l===" "&&r[u+1]==="\\"&&r[u+2]==="n"&&(s+=r.slice(a,u)+"\\ ",u+=1,a=u,l="\\"),l==="\\")switch(r[u+1]){case"u":{s+=r.slice(a,u);let f=r.substr(u+2,4);switch(f){case"0000":s+="\\0";break;case"0007":s+="\\a";break;case"000b":s+="\\v";break;case"001b":s+="\\e";break;case"0085":s+="\\N";break;case"00a0":s+="\\_";break;case"2028":s+="\\L";break;case"2029":s+="\\P";break;default:f.substr(0,2)==="00"?s+="\\x"+f.substr(2):s+=r.substr(u,6)}u+=5,a=u+1}break;case"n":if(n||r[u+2]==='"'||r.length `;let m,p;for(p=r.length;p>0;--p){let _=r[p-1];if(_!==` `&&_!==" "&&_!==" ")break}let d=r.substring(p),v=d.indexOf(` `);v===-1?m="-":r===d||v!==d.length-1?(m="+",o&&o()):m="",d&&(r=r.slice(0,-d.length),d[d.length-1]===` `&&(d=d.slice(0,-1)),d=d.replace(Oy,`$&${l}`));let g=!1,y,w=-1;for(y=0;y{H=!0});let C=kd(`${E}${_}${d}`,l,Z1,V);if(!H)return`>${F} ${l}${C}`}return r=r.replace(/\n+/g,`$&${l}`),`|${F} ${l}${E}${r}${d}`}function gK(e,t,r,n){let{type:i,value:o}=e,{actualString:s,implicitKey:a,indent:u,indentStep:l,inFlow:f}=t;if(a&&o.includes(` `)||f&&/[[\]{},]/.test(o))return Uf(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||f||!o.includes(` `)?Uf(o,t):Q1(e,t,r,n);if(!a&&!f&&i!==Je.PLAIN&&o.includes(` `))return Q1(e,t,r,n);if(tm(o)){if(u==="")return t.forceBlockIndent=!0,Q1(e,t,r,n);if(a&&u===l)return Uf(o,t)}let m=o.replace(/\n+/g,`$& ${u}`);if(s){let p=g=>g.default&&g.tag!=="tag:yaml.org,2002:str"&&g.test?.test(m),{compat:d,tags:v}=t.doc.schema;if(v.some(p)||d?.some(p))return Uf(o,t)}return a?m:kd(m,u,Ry,em(t,!1))}function hl(e,t,r,n){let{implicitKey:i,inFlow:o}=t,s=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;a!==Je.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(a=Je.QUOTE_DOUBLE);let u=f=>{switch(f){case Je.BLOCK_FOLDED:case Je.BLOCK_LITERAL:return i||o?Uf(s.value,t):Q1(s,t,r,n);case Je.QUOTE_DOUBLE:return Od(s.value,t);case Je.QUOTE_SINGLE:return ky(s.value,t);case Je.PLAIN:return gK(s,t,r,n);default:return null}},l=u(a);if(l===null){let{defaultKeyType:f,defaultStringType:m}=t.options,p=i&&f||m;if(l=u(p),l===null)throw new Error(`Unsupported default string type ${p}`)}return l}function rm(e,t){let r=Object.assign({blockQuote:!0,commentString:w_,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),n;switch(r.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:n,options:r}}function vK(e,t){if(t.tag){let i=e.filter(o=>o.tag===t.tag);if(i.length>0)return i.find(o=>o.format===t.format)??i[0]}let r,n;if(Dt(t)){n=t.value;let i=e.filter(o=>o.identify?.(n));if(i.length>1){let o=i.filter(s=>s.test);o.length>0&&(i=o)}r=i.find(o=>o.format===t.format)??i.find(o=>!o.format)}else n=t,r=e.find(i=>i.nodeClass&&n instanceof i.nodeClass);if(!r){let i=n?.constructor?.name??(n===null?"null":typeof n);throw new Error(`Tag not resolved for ${i} value`)}return r}function wK(e,t,{anchors:r,doc:n}){if(!n.directives)return"";let i=[],o=(Dt(e)||Jt(e))&&e.anchor;o&&W1(o)&&(r.add(o),i.push(`&${o}`));let s=e.tag??(t.default?null:t.tag);return s&&i.push(n.directives.tagString(s)),i.join(" ")}function Ya(e,t,r,n){if(Nt(e))return e.toString(t,r,n);if(Ji(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,o=Mt(e)?e:t.doc.createNode(e,{onTagObj:u=>i=u});i??(i=vK(t.doc.schema.tags,o));let s=wK(o,i,t);s.length>0&&(t.indentAtStart=(t.indentAtStart??0)+s.length+1);let a=typeof i.stringify=="function"?i.stringify(o,t,r,n):Dt(o)?hl(o,t,r,n):o.toString(t,r,n);return s?Dt(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s} ${t.indent}${a}`:a}function E_({key:e,value:t},r,n,i){let{allNullValues:o,doc:s,indent:a,indentStep:u,options:{commentString:l,indentSeq:f,simpleKeys:m}}=r,p=Mt(e)&&e.comment||null;if(m){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(Jt(e)||!Mt(e)&&typeof e=="object"){let V="With simple keys, collection cannot be used as a key value";throw new Error(V)}}let d=!m&&(!e||p&&t==null&&!r.inFlow||Jt(e)||(Dt(e)?e.type===Je.BLOCK_FOLDED||e.type===Je.BLOCK_LITERAL:typeof e=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!d&&(m||!o),indent:a+u});let v=!1,g=!1,y=Ya(e,r,()=>v=!0,()=>g=!0);if(!d&&!r.inFlow&&y.length>1024){if(m)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");d=!0}if(r.inFlow){if(o||t==null)return v&&n&&n(),y===""?"?":d?`? ${y}`:y}else if(o&&!m||t==null&&d)return y=`? ${y}`,p&&!v?y+=jo(y,r.indent,l(p)):g&&i&&i(),y;v&&(p=null),d?(p&&(y+=jo(y,r.indent,l(p))),y=`? ${y} ${a}:`):(y=`${y}:`,p&&(y+=jo(y,r.indent,l(p))));let w,E,S;Mt(t)?(w=!!t.spaceBefore,E=t.commentBefore,S=t.comment):(w=!1,E=null,S=null,t&&typeof t=="object"&&(t=s.createNode(t))),r.implicitKey=!1,!d&&!p&&Dt(t)&&(r.indentAtStart=y.length+1),g=!1,!f&&u.length>=2&&!r.inFlow&&!d&&eo(t)&&!t.flow&&!t.tag&&!t.anchor&&(r.indent=r.indent.substring(2));let F=!1,_=Ya(t,r,()=>F=!0,()=>g=!0),H=" ";if(p||w||E){if(H=w?` `:"",E){let V=l(E);H+=` ${$i(V,r.indent)}`}_===""&&!r.inFlow?H===` `&&S&&(H=` `):H+=` ${r.indent}`}else if(!d&&Jt(t)){let V=_[0],C=_.indexOf(` `),I=C!==-1,L=r.inFlow??t.flow??t.items.length===0;if(I||!L){let R=!1;if(I&&(V==="&"||V==="!")){let k=_.indexOf(" ");V==="&"&&k!==-1&&ke===sm||typeof e=="symbol"&&e.description===sm,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Je(Symbol(sm)),{addToJSMap:Ly}),stringify:()=>sm},b_=(e,t)=>(to.identify(t)||Dt(t)&&(!t.type||t.type===Je.PLAIN)&&to.identify(t.value))&&e?.doc.schema.tags.some(r=>r.tag===to.tag&&r.default);function Ly(e,t,r){let n=A_(e,r);if(eo(n))for(let i of n.items)Ny(e,t,i);else if(Array.isArray(n))for(let i of n)Ny(e,t,i);else Ny(e,t,n)}function Ny(e,t,r){let n=A_(e,r);if(!Qi(n))throw new Error("Merge sources must be maps or map aliases");let i=n.toJSON(null,e,Map);for(let[o,s]of i)t instanceof Map?t.has(o)||t.set(o,s):t instanceof Set?t.add(o):Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function A_(e,t){return e&&Ji(t)?t.resolve(e.doc,e):t}function im(e,t,{key:r,value:n}){if(Mt(r)&&r.addToJSMap)r.addToJSMap(e,t,n);else if(b_(e,r))Ly(e,t,n);else{let i=Qr(r,"",e);if(t instanceof Map)t.set(i,Qr(n,i,e));else if(t instanceof Set)t.add(i);else{let o=yK(r,i,e),s=Qr(n,o,e);o in t?Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0}):t[o]=s}}return t}function yK(e,t,r){if(t===null)return"";if(typeof t!="object")return String(t);if(Mt(e)&&r?.doc){let n=rm(r.doc,{});n.anchors=new Set;for(let o of r.anchors.keys())n.anchors.add(o.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!r.mapKeyWarned){let o=JSON.stringify(i);o.length>40&&(o=o.substring(0,36)+'..."'),nm(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return i}return JSON.stringify(t)}function Hf(e,t,r){let n=Ga(e,void 0,r),i=Ga(t,void 0,r);return new $r(n,i)}var $r=class e{constructor(t,r=null){Object.defineProperty(this,Es,{value:Py}),this.key=t,this.value=r}clone(t){let{key:r,value:n}=this;return Mt(r)&&(r=r.clone(t)),Mt(n)&&(n=n.clone(t)),new e(r,n)}toJSON(t,r){let n=r?.mapAsMap?new Map:{};return im(r,n,this)}toString(t,r,n){return t?.doc?E_(this,t,r,n):JSON.stringify(this)}};var Yue=P(x(),1);var Noe=P(x(),1);var Toe=P(x(),1);var _oe=P(x(),1);function am(e,t,r){return(t.inFlow??e.flow?bK:EK)(e,t,r)}function EK({comment:e,items:t},r,{blockItemPrefix:n,flowChars:i,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:u,options:{commentString:l}}=r,f=Object.assign({},r,{indent:o,type:null}),m=!1,p=[];for(let v=0;vy=null,()=>m=!0);y&&(w+=jo(w,o,l(y))),m&&y&&(m=!1),p.push(n+w)}let d;if(p.length===0)d=i.start+i.end;else{d=p[0];for(let v=1;vy=null);l||(l=m.length>f||w.includes(` `)),v0&&(l||(l=m.reduce((E,S)=>E+S.length+2,2)+(w.length+2)>t.options.lineWidth)),l&&(w+=",")),y&&(w+=jo(w,n,a(y))),m.push(w),f=m.length}let{start:p,end:d}=r;if(m.length===0)return p+d;if(!l){let v=m.reduce((g,y)=>g+y.length+2,2);l=t.options.lineWidth>0&&v>t.options.lineWidth}if(l){let v=p;for(let g of m)v+=g?` ${o}${i}${g}`:` `;return`${v} ${i}${d}`}else return`${p}${s}${m.join(" ")}${s}${d}`}function om({indent:e,options:{commentString:t}},r,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){let o=$i(t(n),e);r.push(o.trimStart())}}function Qu(e,t){let r=Dt(t)?t.value:t;for(let n of e)if(Nt(n)&&(n.key===t||n.key===r||Dt(n.key)&&n.key.value===r))return n}var Mr=class extends Nf{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Xi,t),this.items=[]}static from(t,r,n){let{keepUndefined:i,replacer:o}=n,s=new this(t),a=(u,l)=>{if(typeof o=="function")l=o.call(r,u,l);else if(Array.isArray(o)&&!o.includes(u))return;(l!==void 0||i)&&s.items.push(Hf(u,l,n))};if(r instanceof Map)for(let[u,l]of r)a(u,l);else if(r&&typeof r=="object")for(let u of Object.keys(r))a(u,r[u]);return typeof t.sortMapEntries=="function"&&s.items.sort(t.sortMapEntries),s}add(t,r){let n;Nt(t)?n=t:!t||typeof t!="object"||!("key"in t)?n=new $r(t,t?.value):n=new $r(t.key,t.value);let i=Qu(this.items,n.key),o=this.schema?.sortMapEntries;if(i){if(!r)throw new Error(`Key ${n.key} already set`);Dt(i.value)&&J1(n.value)?i.value.value=n.value:i.value=n.value}else if(o){let s=this.items.findIndex(a=>o(n,a)<0);s===-1?this.items.push(n):this.items.splice(s,0,n)}else this.items.push(n)}delete(t){let r=Qu(this.items,t);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(t,r){let i=Qu(this.items,t)?.value;return(!r&&Dt(i)?i.value:i)??void 0}has(t){return!!Qu(this.items,t)}set(t,r){this.add(new $r(t,r),!0)}toJSON(t,r,n){let i=n?new n:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(i);for(let o of this.items)im(r,i,o);return i}toString(t,r,n){if(!t)return JSON.stringify(this);for(let i of this.items)if(!Nt(i))throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),am(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:n,onComment:r})}};var ro={collection:"map",default:!0,nodeClass:Mr,tag:"tag:yaml.org,2002:map",resolve(e,t){return Qi(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,r)=>Mr.from(e,t,r)};var Woe=P(x(),1);var Voe=P(x(),1);var Gn=class extends Nf{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Va,t),this.items=[]}add(t){this.items.push(t)}delete(t){let r=um(t);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(t,r){let n=um(t);if(typeof n!="number")return;let i=this.items[n];return!r&&Dt(i)?i.value:i}has(t){let r=um(t);return typeof r=="number"&&r=0?t:null}var no={collection:"seq",default:!0,nodeClass:Gn,tag:"tag:yaml.org,2002:seq",resolve(e,t){return eo(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,r)=>Gn.from(e,t,r)};var Zoe=P(x(),1);var ec={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,r,n){return t=Object.assign({actualString:!0},t),hl(e,t,r,n)}};var Mue=P(x(),1);var tae=P(x(),1);var dl={identify:e=>e==null,createNode:()=>new Je(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Je(null),stringify:({source:e},t)=>typeof e=="string"&&dl.test.test(e)?e:t.options.nullStr};var sae=P(x(),1);var Nd={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Je(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&Nd.test.test(e)){let n=e[0]==="t"||e[0]==="T";if(t===n)return e}return t?r.options.trueStr:r.options.falseStr}};var lae=P(x(),1);var oae=P(x(),1);function Yn({format:e,minFractionDigits:t,tag:r,value:n}){if(typeof n=="bigint")return String(n);let i=typeof n=="number"?n:Number(n);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let o=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let s=o.indexOf(".");s<0&&(s=o.length,o+=".");let a=t-(o.length-s-1);for(;a-- >0;)o+="0"}return o}var cm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Yn},lm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Yn(e)}},fm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new Je(parseFloat(e)),r=e.indexOf(".");return r!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-r-1),t},stringify:Yn};var dae=P(x(),1);var hm=e=>typeof e=="bigint"||Number.isInteger(e),Uy=(e,t,r,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),r);function S_(e,t,r){let{value:n}=e;return hm(n)&&n>=0?r+n.toString(t):Yn(e)}var dm={identify:e=>hm(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>Uy(e,2,8,r),stringify:e=>S_(e,8,"0o")},pm={identify:hm,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>Uy(e,0,10,r),stringify:Yn},mm={identify:e=>hm(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>Uy(e,2,16,r),stringify:e=>S_(e,16,"0x")};var Aae=P(x(),1);var C_=[ro,no,ec,dl,Nd,dm,pm,mm,cm,lm,fm];var Fae=P(x(),1);function __(e){return typeof e=="bigint"||Number.isInteger(e)}var gm=({value:e})=>JSON.stringify(e),AK=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:gm},{identify:e=>e==null,createNode:()=>new Je(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:gm},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:gm},{identify:__,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>__(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:gm}],SK={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},D_=[ro,no].concat(AK,SK);var Pae=P(x(),1);var Ld={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof atob=="function"){let r=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(r.length);for(let i=0;i1&&t("Each pair must have its own sequence indicator");let i=n.items[0]||new $r(new Je(null));if(n.commentBefore&&(i.key.commentBefore=i.key.commentBefore?`${n.commentBefore} ${i.key.commentBefore}`:n.commentBefore),n.comment){let o=i.value??i.key;o.comment=o.comment?`${n.comment} ${o.comment}`:n.comment}n=i}e.items[r]=Nt(n)?n:new $r(n)}}else t("Expected a sequence for this tag");return e}function My(e,t,r){let{replacer:n}=r,i=new Gn(e);i.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let s of t){typeof n=="function"&&(s=n.call(t,String(o++),s));let a,u;if(Array.isArray(s))if(s.length===2)a=s[0],u=s[1];else throw new TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let l=Object.keys(s);if(l.length===1)a=l[0],u=s[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;i.items.push(Hf(a,u,r))}return i}var Ud={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Hy,createNode:My};var Mf=class e extends Gn{constructor(){super(),this.add=Mr.prototype.add.bind(this),this.delete=Mr.prototype.delete.bind(this),this.get=Mr.prototype.get.bind(this),this.has=Mr.prototype.has.bind(this),this.set=Mr.prototype.set.bind(this),this.tag=e.tag}toJSON(t,r){if(!r)return super.toJSON(t);let n=new Map;r?.onCreate&&r.onCreate(n);for(let i of this.items){let o,s;if(Nt(i)?(o=Qr(i.key,"",r),s=Qr(i.value,o,r)):o=Qr(i,"",r),n.has(o))throw new Error("Ordered maps must not include duplicate keys");n.set(o,s)}return n}static from(t,r,n){let i=My(t,r,n),o=new this;return o.items=i.items,o}};Mf.tag="tag:yaml.org,2002:omap";var Hd={collection:"seq",identify:e=>e instanceof Map,nodeClass:Mf,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=Hy(e,t),n=[];for(let{key:i}of r.items)Dt(i)&&(n.includes(i.value)?t(`Ordered maps must not include duplicate keys: ${i.value}`):n.push(i.value));return Object.assign(new Mf,r)},createNode:(e,t,r)=>Mf.from(e,t,r)};var Sue=P(x(),1);var Gae=P(x(),1);function F_({value:e,source:t},r){return t&&(e?jy:qy).test.test(t)?t:e?r.options.trueStr:r.options.falseStr}var jy={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Je(!0),stringify:F_},qy={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Je(!1),stringify:F_};var Jae=P(x(),1);var B_={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Yn},I_={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Yn(e)}},$_={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Je(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let n=e.substring(r+1).replace(/_/g,"");n[n.length-1]==="0"&&(t.minFractionDigits=n.length)}return t},stringify:Yn};var eue=P(x(),1);var Md=e=>typeof e=="bigint"||Number.isInteger(e);function vm(e,t,r,{intAsBigInt:n}){let i=e[0];if((i==="-"||i==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),n){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let s=BigInt(e);return i==="-"?BigInt(-1)*s:s}let o=parseInt(e,r);return i==="-"?-1*o:o}function Ky(e,t,r){let{value:n}=e;if(Md(n)){let i=n.toString(t);return n<0?"-"+r+i.substr(1):r+i}return Yn(e)}var P_={identify:Md,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>vm(e,2,2,r),stringify:e=>Ky(e,2,"0b")},x_={identify:Md,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>vm(e,1,8,r),stringify:e=>Ky(e,8,"0")},T_={identify:Md,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>vm(e,0,10,r),stringify:Yn},R_={identify:Md,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>vm(e,2,16,r),stringify:e=>Ky(e,16,"0x")};var iue=P(x(),1);var jf=class e extends Mr{constructor(t){super(t),this.tag=e.tag}add(t){let r;Nt(t)?r=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?r=new $r(t.key,null):r=new $r(t,null),Qu(this.items,r.key)||this.items.push(r)}get(t,r){let n=Qu(this.items,t);return!r&&Nt(n)?Dt(n.key)?n.key.value:n.key:n}set(t,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let n=Qu(this.items,t);n&&!r?this.items.splice(this.items.indexOf(n),1):!n&&r&&this.items.push(new $r(t))}toJSON(t,r){return super.toJSON(t,r,Set)}toString(t,r,n){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),r,n);throw new Error("Set items must all have null values")}static from(t,r,n){let{replacer:i}=n,o=new this(t);if(r&&Symbol.iterator in Object(r))for(let s of r)typeof i=="function"&&(s=i.call(r,s,s)),o.items.push(Hf(s,null,n));return o}};jf.tag="tag:yaml.org,2002:set";var jd={collection:"map",identify:e=>e instanceof Set,nodeClass:jf,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>jf.from(e,t,r),resolve(e,t){if(Qi(e)){if(e.hasAllNullValues(!0))return Object.assign(new jf,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};var uue=P(x(),1);function Vy(e,t){let r=e[0],n=r==="-"||r==="+"?e.substring(1):e,i=s=>t?BigInt(s):Number(s),o=n.replace(/_/g,"").split(":").reduce((s,a)=>s*i(60)+i(a),i(0));return r==="-"?i(-1)*o:o}function k_(e){let{value:t}=e,r=s=>s;if(typeof t=="bigint")r=s=>BigInt(s);else if(isNaN(t)||!isFinite(t))return Yn(e);let n="";t<0&&(n="-",t*=r(-1));let i=r(60),o=[t%i];return t<60?o.unshift(0):(t=(t-o[0])/i,o.unshift(t%i),t>=60&&(t=(t-o[0])/i,o.unshift(t))),n+o.map(s=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var wm={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>Vy(e,r),stringify:k_},ym={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Vy(e,!1),stringify:k_},qf={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(qf.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,i,o,s,a]=t.map(Number),u=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(r,n-1,i,o||0,s||0,a||0,u),f=t[8];if(f&&f!=="Z"){let m=Vy(f,!1);Math.abs(m)<30&&(m*=60),l-=6e4*m}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var zy=[ro,no,ec,dl,jy,qy,P_,x_,T_,R_,B_,I_,$_,Ld,to,Hd,Ud,jd,wm,ym,qf];var O_=new Map([["core",C_],["failsafe",[ro,no,ec]],["json",D_],["yaml11",zy],["yaml-1.1",zy]]),N_={binary:Ld,bool:Nd,float:fm,floatExp:lm,floatNaN:cm,floatTime:ym,int:pm,intHex:mm,intOct:dm,intTime:wm,map:ro,merge:to,null:dl,omap:Hd,pairs:Ud,seq:no,set:jd,timestamp:qf},L_={"tag:yaml.org,2002:binary":Ld,"tag:yaml.org,2002:merge":to,"tag:yaml.org,2002:omap":Hd,"tag:yaml.org,2002:pairs":Ud,"tag:yaml.org,2002:set":jd,"tag:yaml.org,2002:timestamp":qf};function Em(e,t,r){let n=O_.get(t);if(n&&!e)return r&&!n.includes(to)?n.concat(to):n.slice();let i=n;if(!i)if(Array.isArray(e))i=[];else{let o=Array.from(O_.keys()).filter(s=>s!=="yaml11").map(s=>JSON.stringify(s)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${o} or define customTags array`)}if(Array.isArray(e))for(let o of e)i=i.concat(o);else typeof e=="function"&&(i=e(i.slice()));return r&&(i=i.concat(to)),i.reduce((o,s)=>{let a=typeof s=="string"?N_[s]:s;if(!a){let u=JSON.stringify(s),l=Object.keys(N_).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${u}; use one of ${l}`)}return o.includes(a)||o.push(a),o},[])}var CK=(e,t)=>e.keyt.key?1:0,qd=class e{constructor({compat:t,customTags:r,merge:n,resolveKnownTags:i,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(t)?Em(t,"compat"):t?Em(null,t):null,this.name=typeof o=="string"&&o||"core",this.knownTags=i?L_:{},this.tags=Em(r,this.name,n),this.toStringOptions=a??null,Object.defineProperty(this,Xi,{value:ro}),Object.defineProperty(this,li,{value:ec}),Object.defineProperty(this,Va,{value:no}),this.sortMapEntries=typeof s=="function"?s:s===!0?CK:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};var Que=P(x(),1);function U_(e,t){let r=[],n=t.directives===!0;if(t.directives!==!1&&e.directives){let u=e.directives.toString(e);u?(r.push(u),n=!0):e.directives.docStart&&(n=!0)}n&&r.push("---");let i=rm(e,t),{commentString:o}=i.options;if(e.commentBefore){r.length!==1&&r.unshift("");let u=o(e.commentBefore);r.unshift($i(u,""))}let s=!1,a=null;if(e.contents){if(Mt(e.contents)){if(e.contents.spaceBefore&&n&&r.push(""),e.contents.commentBefore){let f=o(e.contents.commentBefore);r.push($i(f,""))}i.forceBlockIndent=!!e.comment,a=e.contents.comment}let u=a?void 0:()=>s=!0,l=Ya(e.contents,i,()=>a=null,u);a&&(l+=jo(l,"",o(a))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(Ya(e.contents,i));if(e.directives?.docEnd)if(e.comment){let u=o(e.comment);u.includes(` `)?(r.push("..."),r.push($i(u,""))):r.push(`... ${u}`)}else r.push("...");else{let u=e.comment;u&&s&&(u=u.replace(/^\n+/,"")),u&&((!s||a)&&r[r.length-1]!==""&&r.push(""),r.push($i(o(u),"")))}return r.join(` `)+` `}var Wa=class e{constructor(t,r,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Es,{value:z1});let i=null;typeof r=="function"||Array.isArray(r)?i=r:n===void 0&&r&&(n=r,r=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=o;let{version:s}=o;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(s=this.directives.yaml.version)):this.directives=new Mo({version:s}),this.setSchema(s,n),this.contents=t===void 0?null:this.createNode(t,i,n)}clone(){let t=Object.create(e.prototype,{[Es]:{value:z1}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Mt(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){Kf(this.contents)&&this.contents.add(t)}addIn(t,r){Kf(this.contents)&&this.contents.addIn(t,r)}createAlias(t,r){if(!t.anchor){let n=xy(this);t.anchor=!r||n.has(r)?Ty(r||"a",n):r}return new za(t.anchor)}createNode(t,r,n){let i;if(typeof r=="function")t=r.call({"":t},"",t),i=r;else if(Array.isArray(r)){let y=E=>typeof E=="number"||E instanceof String||E instanceof Number,w=r.filter(y).map(String);w.length>0&&(r=r.concat(w)),i=r}else n===void 0&&r&&(n=r,r=void 0);let{aliasDuplicateObjects:o,anchorPrefix:s,flow:a,keepUndefined:u,onTagObj:l,tag:f}=n??{},{onAnchor:m,setAnchors:p,sourceObjects:d}=v_(this,s||"a"),v={aliasDuplicateObjects:o??!0,keepUndefined:u??!1,onAnchor:m,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:d},g=Ga(t,f,v);return a&&Jt(g)&&(g.flow=!0),p(),g}createPair(t,r,n={}){let i=this.createNode(t,null,n),o=this.createNode(r,null,n);return new $r(i,o)}delete(t){return Kf(this.contents)?this.contents.delete(t):!1}deleteIn(t){return Lf(t)?this.contents==null?!1:(this.contents=null,!0):Kf(this.contents)?this.contents.deleteIn(t):!1}get(t,r){return Jt(this.contents)?this.contents.get(t,r):void 0}getIn(t,r){return Lf(t)?!r&&Dt(this.contents)?this.contents.value:this.contents:Jt(this.contents)?this.contents.getIn(t,r):void 0}has(t){return Jt(this.contents)?this.contents.has(t):!1}hasIn(t){return Lf(t)?this.contents!==void 0:Jt(this.contents)?this.contents.hasIn(t):!1}set(t,r){this.contents==null?this.contents=Td(this.schema,[t],r):Kf(this.contents)&&this.contents.set(t,r)}setIn(t,r){Lf(t)?this.contents=r:this.contents==null?this.contents=Td(this.schema,Array.from(t),r):Kf(this.contents)&&this.contents.setIn(t,r)}setSchema(t,r={}){typeof t=="number"&&(t=String(t));let n;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Mo({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new Mo({version:t}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{let i=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(n)this.schema=new qd(Object.assign(n,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:r,mapAsMap:n,maxAliasCount:i,onAnchor:o,reviver:s}={}){let a={anchors:new Map,doc:this,keep:!t,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},u=Qr(this.contents,r??"",a);if(typeof o=="function")for(let{count:l,res:f}of a.anchors.values())o(f,l);return typeof s=="function"?Ju(s,{"":u},"",u):u}toJSON(t,r){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:r})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let r=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return U_(this,t)}};function Kf(e){if(Jt(e))return!0;throw new Error("Expected a YAML collection as document contents")}var pce=P(x(),1),Kd=class extends Error{constructor(t,r,n,i){super(),this.name=t,this.code=n,this.message=i,this.pos=r}},so=class extends Kd{constructor(t,r,n){super("YAMLParseError",t,r,n)}},Vd=class extends Kd{constructor(t,r,n){super("YAMLWarning",t,r,n)}},Gy=(e,t)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(a=>t.linePos(a));let{line:n,col:i}=r.linePos[0];r.message+=` at line ${n}, column ${i}`;let o=i-1,s=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(o>=60&&s.length>80){let a=Math.min(o-39,s.length-79);s="\u2026"+s.substring(a),o-=a-1}if(s.length>80&&(s=s.substring(0,79)+"\u2026"),n>1&&/^ *$/.test(s.substring(0,o))){let a=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);a.length>80&&(a=a.substring(0,79)+`\u2026 `),s=a+s}if(/[^ ]/.test(s)){let a=1,u=r.linePos[1];u?.line===n&&u.col>i&&(a=Math.max(1,Math.min(u.col-i,80-o)));let l=" ".repeat(o)+"^".repeat(a);r.message+=`: ${s} ${l} `}};var Tle=P(x(),1);var Fle=P(x(),1);var sle=P(x(),1);var xce=P(x(),1);var gce=P(x(),1);function qo(e,{flow:t,indicator:r,next:n,offset:i,onError:o,parentIndent:s,startOnNewline:a}){let u=!1,l=a,f=a,m="",p="",d=!1,v=!1,g=null,y=null,w=null,E=null,S=null,F=null,_=null;for(let C of e)switch(v&&(C.type!=="space"&&C.type!=="newline"&&C.type!=="comma"&&o(C.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),g&&(l&&C.type!=="comment"&&C.type!=="newline"&&o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation"),g=null),C.type){case"space":!t&&(r!=="doc-start"||n?.type!=="flow-collection")&&C.source.includes(" ")&&(g=C),f=!0;break;case"comment":{f||o(C,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let I=C.source.substring(1)||" ";m?m+=p+I:m=I,p="",l=!1;break}case"newline":l?m?m+=C.source:(!F||r!=="seq-item-ind")&&(u=!0):p+=C.source,l=!0,d=!0,(y||w)&&(E=C),f=!0;break;case"anchor":y&&o(C,"MULTIPLE_ANCHORS","A node can have at most one anchor"),C.source.endsWith(":")&&o(C.offset+C.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=C,_??(_=C.offset),l=!1,f=!1,v=!0;break;case"tag":{w&&o(C,"MULTIPLE_TAGS","A node can have at most one tag"),w=C,_??(_=C.offset),l=!1,f=!1,v=!0;break}case r:(y||w)&&o(C,"BAD_PROP_ORDER",`Anchors and tags must be after the ${C.source} indicator`),F&&o(C,"UNEXPECTED_TOKEN",`Unexpected ${C.source} in ${t??"collection"}`),F=C,l=r==="seq-item-ind"||r==="explicit-key-ind",f=!1;break;case"comma":if(t){S&&o(C,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),S=C,l=!1,f=!1;break}default:o(C,"UNEXPECTED_TOKEN",`Unexpected ${C.type} token`),l=!1,f=!1}let H=e[e.length-1],V=H?H.offset+H.source.length:i;return v&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!=="")&&o(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g&&(l&&g.indent<=s||n?.type==="block-map"||n?.type==="block-seq")&&o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:S,found:F,spaceBefore:u,comment:m,hasNewline:d,anchor:y,tag:w,newlineAfterProp:E,end:V,start:_??V}}var wce=P(x(),1);function tc(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(` `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(tc(t.key)||tc(t.value))return!0}return!1;default:return!0}}var bce=P(x(),1);function zd(e,t,r){if(t?.type==="flow-collection"){let n=t.end[0];n.indent===e&&(n.source==="]"||n.source==="}")&&tc(t)&&r(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}var Cce=P(x(),1);function bm(e,t,r){let{uniqueKeys:n}=e.options;if(n===!1)return!1;let i=typeof n=="function"?n:(o,s)=>o===s||Dt(o)&&Dt(s)&&o.value===s.value;return t.some(o=>i(o.key,r))}var H_="All mapping items must start at the same column";function M_({composeNode:e,composeEmptyNode:t},r,n,i,o){let s=o?.nodeClass??Mr,a=new s(r.schema);r.atRoot&&(r.atRoot=!1);let u=n.offset,l=null;for(let f of n.items){let{start:m,key:p,sep:d,value:v}=f,g=qo(m,{indicator:"explicit-key-ind",next:p??d?.[0],offset:u,onError:i,parentIndent:n.indent,startOnNewline:!0}),y=!g.found;if(y){if(p&&(p.type==="block-seq"?i(u,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==n.indent&&i(u,"BAD_INDENT",H_)),!g.anchor&&!g.tag&&!d){l=g.end,g.comment&&(a.comment?a.comment+=` `+g.comment:a.comment=g.comment);continue}(g.newlineAfterProp||tc(p))&&i(p??m[m.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else g.found?.indent!==n.indent&&i(u,"BAD_INDENT",H_);r.atKey=!0;let w=g.end,E=p?e(r,p,g,i):t(r,w,m,null,g,i);r.schema.compat&&zd(n.indent,p,i),r.atKey=!1,bm(r,a.items,E)&&i(w,"DUPLICATE_KEY","Map keys must be unique");let S=qo(d??[],{indicator:"map-value-ind",next:v,offset:E.range[2],onError:i,parentIndent:n.indent,startOnNewline:!p||p.type==="block-scalar"});if(u=S.end,S.found){y&&(v?.type==="block-map"&&!S.hasNewline&&i(u,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&g.starte&&(e.type==="block-map"||e.type==="block-seq");function q_({composeNode:e,composeEmptyNode:t},r,n,i,o){let s=n.start.source==="{",a=s?"flow map":"flow sequence",u=o?.nodeClass??(s?Mr:Gn),l=new u(r.schema);l.flow=!0;let f=r.atRoot;f&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let m=n.offset+n.start.source.length;for(let y=0;y0){let y=Ko(v,g,r.options.strict,i);y.comment&&(l.comment?l.comment+=` `+y.comment:l.comment=y.comment),l.range=[n.offset,g,y.offset]}else l.range=[n.offset,g,g];return l}function Xy(e,t,r,n,i,o){let s=r.type==="block-map"?M_(e,t,r,n,o):r.type==="block-seq"?j_(e,t,r,n,o):q_(e,t,r,n,o),a=s.constructor;return i==="!"||i===a.tagName?(s.tag=a.tagName,s):(i&&(s.tag=i),s)}function K_(e,t,r,n,i){let o=n.tag,s=o?t.directives.tagName(o.source,p=>i(o,"TAG_RESOLVE_FAILED",p)):null;if(r.type==="block-seq"){let{anchor:p,newlineAfterProp:d}=n,v=p&&o?p.offset>o.offset?p:o:p??o;v&&(!d||d.offsetp.tag===s&&p.collection===a);if(!u){let p=t.schema.knownTags[s];if(p?.collection===a)t.schema.tags.push(Object.assign({},p,{default:!1})),u=p;else return p?i(o,"BAD_COLLECTION_TYPE",`${p.tag} used for ${a} collection, but expects ${p.collection??"scalar"}`,!0):i(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0),Xy(e,t,r,i,s)}let l=Xy(e,t,r,i,s,u),f=u.resolve?.(l,p=>i(o,"TAG_RESOLVE_FAILED",p),t.options)??l,m=Mt(f)?f:new Je(f);return m.range=l.range,m.tag=s,u?.format&&(m.format=u.format),m}var vle=P(x(),1);var ale=P(x(),1);function Jy(e,t,r){let n=t.offset,i=_K(t,e.options.strict,r);if(!i)return{value:"",type:null,comment:"",range:[n,n,n]};let o=i.mode===">"?Je.BLOCK_FOLDED:Je.BLOCK_LITERAL,s=t.source?DK(t.source):[],a=s.length;for(let g=s.length-1;g>=0;--g){let y=s[g][1];if(y===""||y==="\r")a=g;else break}if(a===0){let g=i.chomp==="+"&&s.length>0?` `.repeat(Math.max(1,s.length-1)):"",y=n+i.length;return t.source&&(y+=t.source.length),{value:g,type:o,comment:i.comment,range:[n,y,y]}}let u=t.indent+i.indent,l=t.offset+i.length,f=0;for(let g=0;gu&&(u=y.length);else{if(y.length=a;--g)s[g][0].length>u&&(a=g+1);let m="",p="",d=!1;for(let g=0;gu||w[0]===" "?(p===" "?p=` `:!d&&p===` `&&(p=` `),m+=p+y.slice(u)+w,p=` `,d=!0):w===""?p===` `?m+=` `:p=` `:(m+=p+w,p=" ",d=!1)}switch(i.chomp){case"-":break;case"+":for(let g=a;gr(n+p,d,v);switch(i){case"scalar":a=Je.PLAIN,u=FK(o,l);break;case"single-quoted-scalar":a=Je.QUOTE_SINGLE,u=BK(o,l);break;case"double-quoted-scalar":a=Je.QUOTE_DOUBLE,u=IK(o,l);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[n,n+o.length,n+o.length]}}let f=n+o.length,m=Ko(s,f,t,r);return{value:u,type:a,comment:m.comment,range:[n,f,m.offset]}}function FK(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),V_(e)}function BK(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),V_(e.slice(1,-1)).replace(/''/g,"'")}function V_(e){let t,r;try{t=new RegExp(`(.*?)(?o?e.slice(o,n+1):i)}else r+=i}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}function $K(e,t){let r="",n=e[t+1];for(;(n===" "||n===" "||n===` `||n==="\r")&&!(n==="\r"&&e[t+2]!==` `);)n===` `&&(r+=` `),t+=1,n=e[t+1];return r||(r=" "),{fold:r,offset:t}}var PK={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:` `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function xK(e,t,r,n){let i=e.substr(t,r),s=i.length===r&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(s)}catch{let a=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}function Qy(e,t,r,n){let{value:i,type:o,comment:s,range:a}=t.type==="block-scalar"?Jy(e,t,n):Zy(t,e.options.strict,n),u=r?e.directives.tagName(r.source,m=>n(r,"TAG_RESOLVE_FAILED",m)):null,l;e.options.stringKeys&&e.atKey?l=e.schema[li]:u?l=TK(e.schema,i,u,r,n):t.type==="scalar"?l=RK(e,i,t,n):l=e.schema[li];let f;try{let m=l.resolve(i,p=>n(r??t,"TAG_RESOLVE_FAILED",p),e.options);f=Dt(m)?m:new Je(m)}catch(m){let p=m instanceof Error?m.message:String(m);n(r??t,"TAG_RESOLVE_FAILED",p),f=new Je(i)}return f.range=a,f.source=i,o&&(f.type=o),u&&(f.tag=u),l.format&&(f.format=l.format),s&&(f.comment=s),f}function TK(e,t,r,n,i){if(r==="!")return e[li];let o=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(t))return a;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(i(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[li])}function RK({atKey:e,directives:t,schema:r},n,i,o){let s=r.tags.find(a=>(a.default===!0||e&&a.default==="key")&&a.test?.test(n))||r[li];if(r.compat){let a=r.compat.find(u=>u.default&&u.test?.test(n))??r[li];if(s.tag!==a.tag){let u=t.tagString(s.tag),l=t.tagString(a.tag),f=`Value may be parsed as either ${u} or ${l}`;o(i,"TAG_RESOLVE_FAILED",f,!0)}}return s}var yle=P(x(),1);function z_(e,t,r){if(t){r??(r=t.length);for(let n=r-1;n>=0;--n){let i=t[n];switch(i.type){case"space":case"comment":case"newline":e-=i.source.length;continue}for(i=t[++n];i?.type==="space";)e+=i.source.length,i=t[++n];break}}return e}var kK={composeNode:eE,composeEmptyNode:Am};function eE(e,t,r,n){let i=e.atKey,{spaceBefore:o,comment:s,anchor:a,tag:u}=r,l,f=!0;switch(t.type){case"alias":l=OK(e,t,n),(a||u)&&n(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=Qy(e,t,u,n),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=K_(kK,e,t,r,n),a&&(l.anchor=a.source.substring(1))}catch(m){let p=m instanceof Error?m.message:String(m);n(t,"RESOURCE_EXHAUSTION",p)}break;default:{let m=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;n(t,"UNEXPECTED_TOKEN",m),f=!1}}return l??(l=Am(e,t.offset,void 0,null,r,n)),a&&l.anchor===""&&n(a,"BAD_ALIAS","Anchor cannot be an empty string"),i&&e.options.stringKeys&&(!Dt(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&n(u??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(l.spaceBefore=!0),s&&(t.type==="scalar"&&t.source===""?l.comment=s:l.commentBefore=s),e.options.keepSourceTokens&&f&&(l.srcToken=t),l}function Am(e,t,r,n,{spaceBefore:i,comment:o,anchor:s,tag:a,end:u},l){let f={type:"scalar",offset:z_(t,r,n),indent:-1,source:""},m=Qy(e,f,a,l);return s&&(m.anchor=s.source.substring(1),m.anchor===""&&l(s,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(m.spaceBefore=!0),o&&(m.comment=o,m.range[2]=u),m}function OK({options:e},{offset:t,source:r,end:n},i){let o=new za(r.substring(1));o.source===""&&i(t,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&i(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=t+r.length,a=Ko(n,s,e.strict,i);return o.range=[t,s,a.offset],a.comment&&(o.comment=a.comment),o}function G_(e,t,{offset:r,start:n,value:i,end:o},s){let a=Object.assign({_directives:t},e),u=new Wa(void 0,a),l={atKey:!1,atRoot:!0,directives:u.directives,options:u.options,schema:u.schema},f=qo(n,{indicator:"doc-start",next:i??o?.[0],offset:r,onError:s,parentIndent:0,startOnNewline:!0});f.found&&(u.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!f.hasNewline&&s(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),u.contents=i?eE(l,i,f,s):Am(l,f.end,n,null,f,s);let m=u.contents.range[2],p=Ko(o,m,!1,s);return p.comment&&(u.comment=p.comment),u.range=[r,m,p.offset],u}function Gd(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r=="string"?r.length:1)]}function Y_(e){let t="",r=!1,n=!1;for(let i=0;i{let s=Gd(r);o?this.warnings.push(new Vd(s,n,i)):this.errors.push(new so(s,n,i))},this.directives=new Mo({version:t.version||"1.2"}),this.options=t}decorate(t,r){let{comment:n,afterEmptyLine:i}=Y_(this.prelude);if(n){let o=t.contents;if(r)t.comment=t.comment?`${t.comment} ${n}`:n;else if(i||t.directives.docStart||!o)t.commentBefore=n;else if(Jt(o)&&!o.flow&&o.items.length>0){let s=o.items[0];Nt(s)&&(s=s.key);let a=s.commentBefore;s.commentBefore=a?`${n} ${a}`:n}else{let s=o.commentBefore;o.commentBefore=s?`${n} ${s}`:n}}if(r){for(let o=0;o{let o=Gd(t);o[0]+=r,this.onError(o,"BAD_DIRECTIVE",n,i)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let r=G_(this.options,this.directives,t,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let r=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,n=new so(Gd(t),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){let n="Unexpected doc-end without preceding document";this.errors.push(new so(Gd(t),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;let r=Ko(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let n=this.doc.comment;this.doc.comment=n?`${n} ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new so(Gd(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let n=Object.assign({_directives:this.directives},this.options),i=new Wa(void 0,n);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,r,r],this.decorate(i,!1),yield i}}};var rfe=P(x(),1);var Gle=P(x(),1);var Wle=P(x(),1);var Jle=P(x(),1),tE=Symbol("break visit"),NK=Symbol("skip children"),W_=Symbol("remove item");function pl(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),X_(Object.freeze([]),e,t)}pl.BREAK=tE;pl.SKIP=NK;pl.REMOVE=W_;pl.itemAtPath=(e,t)=>{let r=e;for(let[n,i]of t){let o=r?.[n];if(o&&"items"in o)r=o.items[i];else return}return r};pl.parentCollection=(e,t)=>{let r=pl.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],i=r?.[n];if(i&&"items"in i)return i;throw new Error("Parent collection not found")};function X_(e,t,r){let n=r(t,e);if(typeof n=="symbol")return n;for(let i of["key","value"]){let o=t[i];if(o&&"items"in o){for(let s=0;s":return"block-scalar-header"}return null}var ufe=P(x(),1);function io(e){switch(e){case void 0:case" ":case` `:case"\r":case" ":return!0;default:return!1}}var Z_=new Set("0123456789ABCDEFabcdef"),UK=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Cm=new Set(",[]{}"),HK=new Set(` ,[]{} \r `),iE=e=>!e||HK.has(e),Wd=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,r=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!r;let n=this.next??"stream";for(;n&&(r||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let t=this.pos,r=this.buffer[t];for(;r===" "||r===" ";)r=this.buffer[++t];return!r||r==="#"||r===` `?!0:r==="\r"?this.buffer[t+1]===` `:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let r=this.buffer[t];if(this.indentNext>0){let n=0;for(;r===" ";)r=this.buffer[++n+t];if(r==="\r"){let i=this.buffer[n+t+1];if(i===` `||!i&&!this.atEnd)return t+n+1}return r===` `||n>=this.indentNext||!r&&!this.atEnd?t+n:-1}if(r==="-"||r==="."){let n=this.buffer.substr(t,3);if((n==="---"||n==="...")&&io(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&tthis.indentValue&&!io(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&io(r)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let t=this.getLine();if(t===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(t[r]){case"#":yield*this.pushCount(t.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(iE),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,r,n=-1;do t=yield*this.pushNewline(),t>0?(r=yield*this.pushSpaces(!1),this.indentValue=n=r):r=0,r+=yield*this.pushSpaces(!0);while(t+r>0);let i=this.getLine();if(i===null)return this.setNext("flow");if((n!==-1&&n"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>io(r)||r==="#")}*parseBlockScalar(){let t=this.pos-1,r=0,n;e:for(let o=this.pos;n=this.buffer[o];++o)switch(n){case" ":r+=1;break;case` `:t=o,r=0;break;case"\r":{let s=this.buffer[o+1];if(!s&&!this.atEnd)return this.setNext("block-scalar");if(s===` `)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(t+1);if(o===-1)break;t=this.buffer.indexOf(` `,o)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let i=t+1;for(n=this.buffer[i];n===" ";)n=this.buffer[++i];if(n===" "){for(;n===" "||n===" "||n==="\r"||n===` `;)n=this.buffer[++i];t=i-1}else if(!this.blockScalarKeep)do{let o=t-1,s=this.buffer[o];s==="\r"&&(s=this.buffer[--o]);let a=o;for(;s===" ";)s=this.buffer[--o];if(s===` `&&o>=this.pos&&o+1+r>a)t=o;else break}while(!0);return yield Sm,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,r=this.pos-1,n=this.pos-1,i;for(;i=this.buffer[++n];)if(i===":"){let o=this.buffer[n+1];if(io(o)||t&&Cm.has(o))break;r=n}else if(io(i)){let o=this.buffer[n+1];if(i==="\r"&&(o===` `?(n+=1,i=` `,o=this.buffer[n+1]):r=n),o==="#"||t&&Cm.has(o))break;if(i===` `){let s=this.continueScalar(n+1);if(s===-1)break;n=Math.max(n,s-2)}}else{if(t&&Cm.has(i))break;r=n}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield Sm,yield*this.pushToIndex(r+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,r){let n=this.buffer.slice(this.pos,t);return n?(yield n,this.pos+=n.length,n.length):(r&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(iE),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,n=this.charAt(1);if(io(n)||r&&Cm.has(n)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,r=this.buffer[t];for(;!io(r)&&r!==">";)r=this.buffer[++t];return yield*this.pushToIndex(r===">"?t+1:t,!1)}else{let t=this.pos+1,r=this.buffer[t];for(;r;)if(UK.has(r))r=this.buffer[++t];else if(r==="%"&&Z_.has(this.buffer[t+1])&&Z_.has(this.buffer[t+2]))r=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===` `?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===` `?yield*this.pushCount(2):0}*pushSpaces(t){let r=this.pos-1,n;do n=this.buffer[++r];while(n===" "||t&&n===" ");let i=r-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=r),i}*pushUntil(t){let r=this.pos,n=this.buffer[r];for(;!t(n);)n=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};var lfe=P(x(),1),Xd=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let r=0,n=this.lineStarts.length;for(;r>1;this.lineStarts[o]=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function Dm(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let r=t??this.stack.pop();if(r)if(this.stack.length===0)yield r;else{let n=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in n?n.indent:0:r.type==="flow-collection"&&n.type==="document"&&(r.indent=0),r.type==="flow-collection"&&eD(r),n.type){case"document":n.value=r;break;case"block-scalar":n.props.push(r);break;case"block-map":{let i=n.items[n.items.length-1];if(i.value){n.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=r;else{Object.assign(i,{key:r,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{let i=n.items[n.items.length-1];i.value?n.items.push({start:[],value:r}):i.value=r;break}case"flow-collection":{let i=n.items[n.items.length-1];!i||i.value?n.items.push({start:[],key:r,sep:[]}):i.sep?i.value=r:Object.assign(i,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let i=r.items[r.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&Q_(i.start)===-1&&(r.indent===0||i.start.every(o=>o.type!=="comment"||o.indent=t.indent){let n=!this.onKeyLine&&this.indent===t.indent,i=n&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",o=[];if(i&&r.sep&&!r.value){let s=[];for(let a=0;at.indent&&(s.length=0);break;default:s.length=0}}s.length>=2&&(o=r.sep.splice(s[1]))}switch(this.type){case"anchor":case"tag":i||r.value?(o.push(this.sourceToken),t.items.push({start:o}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):i||r.value?(o.push(this.sourceToken),t.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(rc(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(tD(r.key)&&!rc(r.sep,"newline")){let s=Vf(r.start),a=r.key,u=r.sep;u.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:a,sep:u}]})}else o.length>0?r.sep=r.sep.concat(o,this.sourceToken):r.sep.push(this.sourceToken);else if(rc(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let s=Vf(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||i?t.items.push({start:o,key:null,sep:[this.sourceToken]}):rc(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);i||r.value?(t.items.push({start:o,key:s,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(s):(Object.assign(r,{key:s,sep:[]}),this.onKeyLine=!0);return}default:{let s=this.startBlockValue(t);if(s){if(s.type==="block-seq"){if(!r.explicitKey&&r.sep&&!rc(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else n&&t.items.push({start:o});this.stack.push(s);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,t.indent)){let i=t.items[t.items.length-2]?.value?.end;if(Array.isArray(i)){Dm(i,r.start),i.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=t.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;r.value||rc(r.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>t.indent){let n=this.startBlockValue(t);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let r=t.items[t.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?t.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);!r||r.value?t.items.push({start:[],key:i,sep:[]}):r.sep?this.stack.push(i):Object.assign(r,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let n=this.startBlockValue(t);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===t.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let i=_m(n),o=Vf(i);eD(t);let s=t.end.splice(1,t.end.length);s.push(this.sourceToken);let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:o,key:t,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let r=this.source.indexOf(` `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(` `,r)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=_m(t),n=Vf(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=_m(t),n=Vf(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?!1:t.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};var Sfe=P(x(),1);function MK(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Xd||null,prettyErrors:t}}function rD(e,t={}){let{lineCounter:r,prettyErrors:n}=MK(t),i=new Jd(r?.addNewLine),o=new Yd(t),s=null;for(let a of o.compose(i.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new so(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(s.errors.forEach(Gy(e,r)),s.warnings.forEach(Gy(e,r))),s}function oE(e,t,r){let n;typeof t=="function"?n=t:r===void 0&&t&&typeof t=="object"&&(r=t);let i=rD(e,r);if(!i)return null;if(i.warnings.forEach(o=>nm(i.options.logLevel,o)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:n},r))}function aE(e,t,r){let n=null;if(typeof t=="function"||Array.isArray(t)?n=t:r===void 0&&t&&(r=t),typeof r=="string"&&(r=r.length),typeof r=="number"){let i=Math.round(r);r=i<1?void 0:i>8?{indent:8}:{indent:i}}if(e===void 0){let{keepUndefined:i}=r??t??{};if(!i)return}return Zi(e)&&!n?e.toString(r):new Wa(e,n,r).toString(r)}var qK={logLevel:"error",merge:!0};function sD(e,t,...r){try{return e(t,...r)}catch{return e(aD(e(t.replace(/!\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function Fm(e){return JSON.parse(JSON.stringify(e))}function KK(e){return{...qK,...e||{}}}function VK(e={}){let{forceQuotes:t,lineWidth:r,noArrayIndent:n,noRefs:i,quotingType:o,sortKeys:s,...a}=e||{},u={...a};return typeof r=="number"&&(u.lineWidth=r<=0?0:r),typeof n=="boolean"&&(u.indentSeq=!n),typeof i=="boolean"&&(u.aliasDuplicateObjects=!i),typeof s<"u"&&(u.sortMapEntries=s),o==="'"?u.singleQuote=!0:o==='"'&&(u.singleQuote=!1),t&&(u.defaultStringType=o==="'"?"QUOTE_SINGLE":"QUOTE_DOUBLE"),u}function iD(e,t){return oE(e,KK(t))}function oD(e,t){return aE(e,VK(t))}function zf(e,...t){return sD(iD,Fm(e),...t)}function zK(e,...t){return sD(iD,Fm(e),...t)}function nD(e,...t){return oD(Fm(e),...t)}function aD(e,...t){return oD(Fm(e),...t)}var fi={safeLoad:zf,load:zK,safeDump:nD,dump:aD,parse:zf,stringify:nD};var f2e=P(x());var Yfe=P(x()),uE=0;function en(e){return YK(GK(WK(e)))}function GK(e){return JK(ZK(XK(e),e.length*8))}function YK(e){try{}catch{uE=0}for(var t=uE?"0123456789ABCDEF":"0123456789abcdef",r="",n,i=0;i>>4&15)+t.charAt(n&15);return r}function WK(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 XK(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function ZK(e,t){e[t>>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,s=0;s>16)+(t>>16)+(r>>16);return n<<16|r&65535}function QK(e,t){return e<>>32-t}var vhe=P(x()),Nm=P(ED()),_V=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,DV=/^(([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 jr(e){return _V.test(e)}function hr(e){return DV.test(e)}function bD(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 et(e){return typeof e=="string"&&e.trim().length>0}function jt(e,t){return et(e)?e:t}function Xf(e){return typeof e<"u"&&e!==null}function Ja(e,t){return Xf(e)?e:t}function Za(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function FV(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function ep(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,i]=r.split("-").map(Number);return FV(n,i)}else return Number(r)}function AD(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function Lm(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 dt(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}var bhe=P(x());var bE=class{constructor(){z.read(il)||z.write("{}",il);try{this.resourceCache=JSON.parse(z.read(il))}catch(t){z.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${il} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},z.write("{}",il)}this._cleanup()}_cleanup(t,r){let n=EE(r)??0,i=!1,o=Date.now();Object.entries(this.resourceCache).forEach(s=>{let[a,u]=s;(!u.time||u.time0?t:null}function IV(){let t=z.read(fr)?.resourceCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:36e5}var tn=new bE;var _he=P(x());var SE=class{constructor(){z.read(ol)||z.write("{}",ol);try{this.resourceCache=JSON.parse(z.read(ol))}catch(t){z.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${ol} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},z.write("{}",ol)}this._cleanup()}_cleanup(t,r){let n=AE(r)??0,i=!1,o=Date.now();Object.entries(this.resourceCache).forEach(s=>{let[a,u]=s;(!u.time||u.time0?t:null}function PV(){let t=z.read(fr)?.headersCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:6e4}var tp=new SE;var Lhe=P(x());var Ihe=P(x());var SD=10,xV="backendRequestConcurrency",CD=0,TV="backendRequestConcurrencyWaitTime",rp=0,DE=[];function RV(e){return new Promise(t=>setTimeout(t,e))}function kV(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return SD;let t=Number(e);return!Number.isInteger(t)||t<1?SD:t}function OV(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return CD;let t=Number(e);return!Number.isInteger(t)||t<0?CD:t}function CE(){let e=z.read(fr)||{};return kV(e[xV])}function _E(){let e=z.read(fr)||{};return OV(e[TV])}function NV(e,t){return`active=${rp}, pending=${DE.length}, limit=${e}, waitTime=${t}ms`}function Um(e,t,r,n){z.log(`[Backend Request Concurrency] ${e}: ${t} (${NV(r,n)})`)}function LV(){let e=DE.shift();e&&e()}async function UV(e){let t=CE(),r=_E();for(;rp>=t;)Um("queued",e,t,r),await new Promise(n=>{DE.push(n)}),t=CE(),r=_E();rp+=1,Um("acquired",e,t,r),r>0&&(Um("waiting before request",e,t,r),await RV(r))}function HV(e){rp=Math.max(0,rp-1),Um("released",e,CE(),_E()),LV()}async function Jf(e,t="request"){await UV(t);try{return await e()}finally{HV(t)}}function vl(e){let t=Object.keys(e),r="",n="",i="";for(let o of t){let s=o.toLowerCase();s==="subscription-userinfo"?r=e[o]:s==="profile-web-page-url"?n=e[o]:s==="plan-name"&&(i=e[o])}return`${r||""}${n?`; app_url=${encodeURIComponent(n)}`:""}${i?`; plan_name=${encodeURIComponent(i)}`:""}`}async function Wo(rawUrl,ua,timeout,customProxy,flowUrl,flowHeaders){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}=ws(),insecure=$arguments?.insecure?z.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=z.read(fr),proxy=customProxy||defaultProxy;z.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultFlowUserAgent||"clash.meta/v1.19.29",requestTimeout=timeout||defaultTimeout||8e3,customHeaders,customHeadersArg=flowHeaders||$arguments?.flowHeaders||$arguments?.headers;if(customHeadersArg)try{let e=typeof customHeadersArg=="string"?JSON.parse(customHeadersArg):customHeadersArg;if(e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0){let t={"user-agent":userAgent};for(let r in e)t[r.toLowerCase()]=e[r];customHeaders=t}}catch(e){z.error(`\u89E3\u6790\u81EA\u5B9A\u4E49 ${flowHeaders||$arguments?.flowHeaders?"flowHeaders":"headers"} \u5931\u8D25: ${e}`)}let id=en(`${customHeaders?JSON.stringify(customHeaders):userAgent}${url}`),cached=tp.get(id),flowInfo;if(!$arguments?.noCache&&cached)z.info(`\u4F7F\u7528\u7F13\u5B58\u7684\u6D41\u91CF\u4FE1\u606F: ${url}, ${customHeaders?JSON.stringify(customHeaders):userAgent}`),flowInfo=cached;else{let e=Yi();if(flowUrl){let t;try{z.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${flowUrl}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:r,body:n,statusCode:i}=await Jf(()=>e.get({url,headers:customHeaders||{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},...insecure||{}}),"flow body GET");if(i<200||i>=400)throw new Error(`statusCode: ${i}`);t=r;let o=Zf(n);if(Number.isFinite(o?.total)&&Number.isFinite(o?.usage?.download)&&Number.isFinite(o?.usage?.upload))flowInfo=n;else throw new Error("\u54CD\u5E94\u4F53\u4E2D\u672A\u5305\u542B\u5408\u6CD5\u7684\u6D41\u91CF\u4FE1\u606F")}catch(r){if(z.error(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${flowUrl}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${r.message??r}`),t)try{let n=vl(t),i=Zf(n);if(Number.isFinite(i?.total)&&Number.isFinite(i?.usage?.download)&&Number.isFinite(i?.usage?.upload))z.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u6210\u529F: ${flowUrl}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}`),flowInfo=n;else throw new Error("\u54CD\u5E94\u4F53\u4E2D\u672A\u5305\u542B\u5408\u6CD5\u7684\u6D41\u91CF\u4FE1\u606F")}catch(n){z.error(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${flowUrl}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${n.message??n}`)}}}else{try{z.info(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await Jf(()=>e.head({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{...customHeaders||{"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?Za(proxy):{},...insecure||{}}),"flow headers HEAD");flowInfo=vl(t)}catch(t){z.error(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${url}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${t.message??t}`)}if(!flowInfo){z.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent||""}`}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await Jf(()=>e.get({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{...customHeaders||{"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?Za(proxy):{},...insecure||{}}),"flow headers GET");flowInfo=vl(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&tp.set(id,flowInfo,$arguments?.headersCacheTtl?$arguments?.headersCacheTtl*1e3:void 0)}return flowInfo}function Zf(e){if(!e)return;let t=e.match(/upload=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),r=t==null?0:Number(t[1]+t[2]),n=e.match(/download=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),i=Number(n[1]+n[2]),o=e.match(/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),s=Number(o[1]+o[2]),a=e.match(/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),u=a?Number(a[1]+a[2]):void 0,l=e.match(/reset_day=([0-9]+)/),f=l?Number(l[1]):void 0,m=e.match(/app_url=(.*?)\s*?(;|$)/),p=m?decodeURIComponent(m[1]):void 0,d=e.match(/plan_name=(.*?)\s*?(;|$)/),v=d?decodeURIComponent(d[1]):void 0;return{expires:u,total:s,usage:{upload:r,download:i},remainingDays:f,appUrl:p,planName:v}}function np(e,t="B"){let r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],n=r.indexOf(t);return e<1024||n===r.length-1?{value:(Math.round(e*100)/100).toString(),unit:t}:np(e/1024,r[++n])}function Hm(e){if(!e)throw new Error("\u6CA1\u6709\u6D41\u91CF\u4FE1\u606F");if(e?.expires&&e.expires*1e3o.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,o=i.getDate(),s=i.getMonth(),a=i.getFullYear(),u;return t>o?u=0:u=new Date(a,s+1,0).getDate(),u-o+t}}catch(t){z.error(`getRmainingDays failed: ${t.message??t}`)}}function Qf(e,t){try{let r=new Map;e.split(";").map(o=>o.trim()).filter(Boolean).forEach(o=>{let s=o.indexOf("=");if(s===-1)return;let a=o.slice(0,s).trim(),u=o.slice(s+1).trim();if(!r.has(a))try{let l=decodeURIComponent(u);if(["upload","download","total","expire","reset_day"].includes(a))try{l=Number(l),["expire","reset_day"].includes(a)&&(l<=0||!Number.isFinite(l))?l="":["upload","download","total"].includes(a)&&!Number.isFinite(l)?l=0:l=l.toFixed(0)}catch(f){z.error(`Failed to convert value for key "${a}=${u}": ${f.message??f}`)}r.set(a,l)}catch{r.set(a,u)}});let n={},i={"subscription-userinfo":"","profile-web-page-url":"","plan-name":""};return r.forEach((o,s)=>{t&&s==="app_url"?i["profile-web-page-url"]=o:t&&s==="plan_name"?i["plan-name"]=o:n[s]=o}),Object.keys(n).length>0&&(i["subscription-userinfo"]=Object.entries(n).map(([o,s])=>`${o}=${encodeURIComponent(s)}`).join("; ")),t?i:i["subscription-userinfo"]}catch(r){return z.error(`normalizeFlowHeader failed: ${r.message??r}`),t?{"subscription-userinfo":e}:e}}var Hhe=P(x());function dr(e,t,r="name"){return e.find(n=>n[r]===t)}function MV(e,t,r="name"){return e.findIndex(n=>n[r]===t)}function FE(e,t,r,n="name"){let i=MV(e,t,n);e[i]=r}function BE(e,t,r="bottom"){if(r==="top"){e.unshift(t);return}e.push(t)}var Wge=P(x());var jhe=P(x());function es(e,t,r){e.status(r||200).json({status:"success",data:t})}function xr(e,t,r){e.status(r||500).json({status:"failed",error:{code:t.code,type:t.type,message:t.message,details:e.req?.route?.path?.startsWith("/share/")?"\u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7":t.details}})}var Khe=P(x()),eh=class{constructor(t,r,n){this.code=t,this.message=r,this.details=n}},Ss=class extends eh{constructor(t,r,n){super(t,r,n),this.type="InternalServerError"}},kt=class extends eh{constructor(t,r,n){super(t,r,n),this.type="RequestInvalidError"}},Cs=class extends eh{constructor(t,r,n){super(t,r,n),this.type="ResourceNotFoundError"}},Mm=class extends eh{constructor(t,r,n){super(t,r,n),this.type="NetworkError"}};var Xhe=P(x());var $E=new Map,IE=new Set,PE;function xE(e){return e?.cron==null?"":`${e.cron}`.trim()}function DD(e){return xE(e).length>0}function jV(e){let t=e?.displayName??e?.["display-name"];return t==null?"":`${t}`.trim()}function Qa(e){if(!e||typeof e!="object")return`${e}`;let t=e.name==null?"":`${e.name}`,r=jV(e);return!r||r===t?t:`${t} (${r})`}function FD(e){return!DD(e)}function qV(cron){if(!(!cron||!z.env.isNode))try{let{CronTime}=eval('require("cron")');new CronTime(cron)}catch(e){throw new kt("INVALID_ARTIFACT_CRON",`Artifact cron ${cron} is invalid.`,`Reason: ${e.message??e}`)}}function KV(e){if(!e||typeof e!="object")return e;let t=xE(e);return t?(qV(t),e.cron=t,e):(delete e.cron,e)}function VV(){$E.forEach(e=>e.stop()),$E.clear()}async function zV(e,t,r){if(IE.has(e)){z.info(`[ARTIFACT CRON] ${t} ${r} skipped: previous run is still running`);return}IE.add(e);try{z.info(`[ARTIFACT CRON] ${t} ${r} started`),await PE(e),z.info(`[ARTIFACT CRON] ${t} ${r} finished`)}catch(n){z.error(`[ARTIFACT CRON] ${t} ${r} error: ${n.message??n}`)}finally{IE.delete(e)}}function GV(artifact){let cron=xE(artifact),name=artifact.name,logName=Qa(artifact),{CronJob}=eval('require("cron")');try{let e=new CronJob(cron,async function(){await zV(name,logName,cron)},null,!0);$E.set(name,e),z.info(`[ARTIFACT CRON] ${logName} ${cron} scheduled`)}catch(e){z.error(`[ARTIFACT CRON] ${logName} ${cron} schedule error: ${e.message??e}`)}}function BD(){if(!z.env.isNode||!PE)return;VV();let e=z.read(vs);(Array.isArray(e)?e:[]).filter(r=>r.sync&&r.source).filter(DD).forEach(GV)}function Yhe(e){z.env.isNode&&(PE=e,BD())}var cde=P(x());var Zhe=P(x());function YV(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function WV(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var ID=[YV(),WV()];var tde=P(x());function XV(){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 $D(){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 JV(){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))),$D().func(r))}}function ZV(){return{type:"ALL",func:r=>{let n={"DEST-PORT":"DST-PORT","SRC-IP":"SRC-IP-CIDR","IN-PORT":"SRC-PORT"},i={payload:r.map(o=>{let s=`${n[o.type]||o.type},${o.content}`;return["IP-CIDR","IP-CIDR6","GEOIP"].includes(o.type)&&(o.options&&(o.options=o.options.filter(a=>["no-resolve"].includes(a))),s+=o.options?.length>0?`,${o.options.join(",")}`:""),s})};return fi.dump(i)}}}var PD={QX:XV(),Surge:$D(),Loon:JV(),Clash:ZV()};var nde=P(x()),QV=[[/^(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 ez(){return{name:"Universal Rule Parser",test:()=>!0,parse:n=>{let i=n.split(` `),o=[];for(let s of i)if(s=s.trim(),s.length!==0&&!/\s*#/.test(s))try{let a=s.split(",").map(f=>f.trim()),u=a[0],l=!1;for(let f of QV)if(f[0].test(u)){l=!0;let p={type:f[1],content:a[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(p.type)&&(p.options=a.slice(2)),o.push(p)}if(!l)throw new Error("Invalid rule type: "+u)}catch(a){console.log(`Failed to parse line: ${s} Reason: ${a}`)}return o}}}var xD=[ez()];var jm=function(){function e(n){for(let i of ID)try{if(i.test(n))return z.info(`Pre-processor [${i.name}] activated`),i.parse(n)}catch(o){z.error(`Parser [${i.name}] failed Reason: ${o}`)}return n}function t(n){n=e(n);for(let i of xD){let o;try{o=i.test(n)}catch{o=!1}if(o)return z.info(`Rule parser [${i.name}] is activated!`),i.parse(n)}}function r(n,i){let o=PD[i];if(!o)throw new Error(`Target platform: ${i} is not supported!`);if(typeof o.type>"u"||o.type==="SINGLE")return n.map(s=>{try{return o.func(s)}catch(a){return console.log(`ERROR: cannot produce rule: ${JSON.stringify(s)} Reason: ${a}`),""}}).filter(s=>s.length>0).join(` `);if(o.type==="ALL")return o.func(n)}return{parse:t,produce:r}}();var yge=P(x());var dde=P(x());function TE(){return z.read(fr)?.appearanceSetting?.createItemPosition==="top"?"top":"bottom"}var Ede=P(x());var RE="https://api.github.com";function TD(e){let t;try{t=JSON.parse(e.body)}catch{}let r=t?.message?.error??t?.error??t?.message??e.body??"Unknown error";return`ERROR: HTTP ${e.statusCode}: ${r}`}function tz(e,t=RE){return(String(e??"").trim()||t).replace(/\/+$/,"")}function rz({githubApiUrl:e,githubProxy:t}={}){let r=tz(e),n=r!==RE,i=String(t||"").trim().replace(/\/+$/,"");return n?r:`${i?`${i}/`:""}${RE}`}function wde(e={}){return!!e?.gistToken}var wl=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=ws(),{defaultProxy,githubApiTimeout,githubProxy,githubApiUrl}=z.read(fr),githubApiRequestTimeout=githubApiTimeout||1e4,githubGistBaseURL=rz({githubApiUrl,githubProxy}),proxy=defaultProxy;z.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=Yi({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?Za(proxy):{},timeout:githubApiRequestTimeout,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(TD(e)):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=Yi({baseURL:githubGistBaseURL,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?Za(proxy):{},timeout:githubApiRequestTimeout,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(TD(e)):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);z.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,t={}){if(Object.keys(e).length===0)return Promise.reject("\u672A\u63D0\u4F9B\u9700\u4E0A\u4F20\u7684\u6587\u4EF6");let r=await this.locate(),n=e,i=t.emptyFileFallback,o=!!i?.filename,s={},a=l=>l.then(f=>(Object.keys(s).length>0&&(f.subStoreUploadMeta=s),f)),u=({actions:l,existingFiles:f,result:m})=>{if(!o)return;let p=i.filename,d=i.content??"",v=Object.keys(m).filter(g=>g!==p);Object.keys(m).length===0?(m[p]={content:d},s.emptyFileFallback={status:"created",filename:p},this.syncPlatform==="gitlab"?l.push({action:f[p]?"update":"create",file_path:p,content:d}):n[p]={content:d}):m[p]&&v.length>0?(delete m[p],s.emptyFileFallback={status:"removed",filename:p},this.syncPlatform==="gitlab"?l.push({action:"delete",file_path:p}):n[p]=null):m[p]&&v.length===0&&(s.emptyFileFallback={status:"retained",filename:p})};if(r?.id){this.syncPlatform==="gitlab"&&(r.files=r.files.reduce((m,p)=>(m[p.path]=p,m),{}));let l=[],f={...r.files};return Object.keys(n).map(m=>{f[m]?n[m].content==null||n[m].content===""?(delete f[m],n[m]=null,l.push({action:"delete",file_path:m})):(f[m]=n[m],l.push({action:"update",file_path:m,content:n[m].content})):n[m].content==null||n[m].content===""?(delete f[m],delete n[m]):(f[m]=n[m],l.push({action:"create",file_path:m,content:n[m].content}))}),u({actions:l,existingFiles:r.files,result:f}),this.syncPlatform==="gitlab"?Object.keys(f).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(f).length>10?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4 snippet \u7684\u6587\u4EF6\u6570\u8D85\u8FC7 10, \u65E0\u6CD5\u66F4\u65B0 snippet"):(n=l,a(this.http.put({headers:{...this.headers,"Content-Type":"application/json"},url:`/snippets/${r.id}`,body:JSON.stringify({files:n})}))):Object.keys(f).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"):a(this.http.patch({url:`/gists/${r.id}`,body:JSON.stringify({files:n})}))}else return n=Object.entries(n).reduce((l,[f,m])=>(m.content!==null&&m.content!==""&&(l[f]=m),l),{}),this.syncPlatform==="gitlab"?Object.keys(n).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA snippet"):(n=Object.keys(n).map(l=>({file_path:l,content:n[l].content})),a(this.http.post({headers:{...this.headers,"Content-Type":"application/json"},url:"/snippets",body:JSON.stringify({title:this.key,visibility:"private",files:n})}))):Object.keys(n).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA gist"):a(this.http.post({url:"/gists",body:JSON.stringify({description:this.key,public:!1,files:n})}))}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})`)}};var Dde=P(x());function RD(e){if(e!==void 0)return JSON.parse(JSON.stringify(e))}function nz(){let e=z.read(E1);if(Array.isArray(e))return e;let t=[];return z.write(t,E1),t}function sz(e){z.write(e,E1)}function iz(){return`${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function oz(e){let t=nz(),r={id:iz(),archivedAt:Date.now(),...e};return t.unshift(r),sz(t),r}function az(e,t,r={}){return oz({itemType:e,name:t.name,displayName:t.displayName,remark:t.remark,tag:RD(t.tag),snapshot:RD(t),...r})}function kD(e,t,r){let i=(z.read(Cn)||[]).find(o=>o.token===e&&o.type===t&&o.name===r);if(!i)throw new Cs("RESOURCE_NOT_FOUND",`Share ${t}/${r}/${e} does not exist!`);return az("share",i,{shareType:i.type})}var ige=P(x());var ege=P(x(),1);var Pde=P(x(),1);var Bde=P(x(),1);function kE(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function qr(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function Dn(e,t,r=""){let n=kE(e),i=e?.length,o=t!==void 0;if(!n||o&&i!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",u=n?`length=${i}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+u;throw n?new RangeError(l):new TypeError(l)}return e}function tu(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(qr(e.outputLen),qr(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function th(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function qm(e,t){Dn(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length='+r)}function Km(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function _s(...e){for(let t=0;t>>t}function Vt(e,t){return e<>>32-t>>>0}var uz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function cz(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function lz(e){for(let t=0;te:lz,ND=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",fz=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Vm(e){if(Dn(e),ND)return e.toHex();let t="";for(let r=0;r=eu._0&&e<=eu._9)return e-eu._0;if(e>=eu.A&&e<=eu.F)return e-(eu.A-10);if(e>=eu.a&&e<=eu.f)return e-(eu.a-10)}function sp(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(ND)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;ie(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function sc(e=32){qr(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var HE=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var Gm=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(tu(t),Dn(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o{let e=(t,r,n)=>new Gm(t,r).update(n).digest();return e.create=(t,r)=>new Gm(t,r),e})();var kde=P(x(),1);function ip(e,t,r){return tu(e),r===void 0&&(r=new Uint8Array(e.outputLen)),Xo(e,r,t)}var ME=Uint8Array.of(0),LD=Uint8Array.of();function jE(e,t,r,n=32){tu(e),qr(n,"length"),Dn(t,void 0,"prk");let i=e.outputLen;if(t.length255*i)throw new Error("Length must be <= 255*HashLen");let o=Math.ceil(n/i);r===void 0?r=LD:Dn(r,void 0,"info");let s=new Uint8Array(o*i),a=Xo.create(e,t),u=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let f=0;fjE(e,ip(e,t,r),n,i);var Vde=P(x(),1);var Lde=P(x(),1);function UD(e,t,r){return e&t^~e&r}function HD(e,t,r){return e&t^e&r^t&r}var op=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,i){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=rh(this.buffer)}update(t){th(this),Dn(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let m=s;mf.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m>MD&Ym)}:{h:Number(e>>MD&Ym)|0,l:Number(e&Ym)|0}}function jD(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;oe>>>r,KE=(e,t,r)=>e<<32-r|t>>>r,yl=(e,t,r)=>e>>>r|t<<32-r,El=(e,t,r)=>e<<32-r|t>>>r,ap=(e,t,r)=>e<<64-r|t>>>r-32,up=(e,t,r)=>e>>>r-32|t<<64-r;function Jo(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var qD=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),KD=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,VD=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),zD=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,GD=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),YD=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;var mz=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),oc=new Uint32Array(64),VE=class extends op{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let m=0;m<16;m++,r+=4)oc[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let p=oc[m-15],d=oc[m-2],v=ao(p,7)^ao(p,18)^p>>>3,g=ao(d,17)^ao(d,19)^d>>>10;oc[m]=g+oc[m-7]+v+oc[m-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:l,H:f}=this;for(let m=0;m<64;m++){let p=ao(a,6)^ao(a,11)^ao(a,25),d=f+p+UD(a,u,l)+mz[m]+oc[m]|0,g=(ao(n,2)^ao(n,13)^ao(n,22))+HD(n,i,o)|0;f=l,l=u,u=a,a=s+d|0,s=o,o=i,i=n,n=d+g|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(n,i,o,s,a,u,l,f)}roundClean(){_s(oc)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),_s(this.buffer)}},zE=class extends VE{A=ru[0]|0;B=ru[1]|0;C=ru[2]|0;D=ru[3]|0;E=ru[4]|0;F=ru[5]|0;G=ru[6]|0;H=ru[7]|0;constructor(){super(32)}};var WD=jD(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),gz=WD[0],vz=WD[1],ac=new Uint32Array(80),uc=new Uint32Array(80),GE=class extends op{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:u,Eh:l,El:f,Fh:m,Fl:p,Gh:d,Gl:v,Hh:g,Hl:y}=this;return[t,r,n,i,o,s,a,u,l,f,m,p,d,v,g,y]}set(t,r,n,i,o,s,a,u,l,f,m,p,d,v,g,y){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=f|0,this.Fh=m|0,this.Fl=p|0,this.Gh=d|0,this.Gl=v|0,this.Hh=g|0,this.Hl=y|0}process(t,r){for(let S=0;S<16;S++,r+=4)ac[S]=t.getUint32(r),uc[S]=t.getUint32(r+=4);for(let S=16;S<80;S++){let F=ac[S-15]|0,_=uc[S-15]|0,H=yl(F,_,1)^yl(F,_,8)^qE(F,_,7),V=El(F,_,1)^El(F,_,8)^KE(F,_,7),C=ac[S-2]|0,I=uc[S-2]|0,L=yl(C,I,19)^ap(C,I,61)^qE(C,I,6),R=El(C,I,19)^up(C,I,61)^KE(C,I,6),k=VD(V,R,uc[S-7],uc[S-16]),M=zD(k,H,L,ac[S-7],ac[S-16]);ac[S]=M|0,uc[S]=k|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:u,Dh:l,Dl:f,Eh:m,El:p,Fh:d,Fl:v,Gh:g,Gl:y,Hh:w,Hl:E}=this;for(let S=0;S<80;S++){let F=yl(m,p,14)^yl(m,p,18)^ap(m,p,41),_=El(m,p,14)^El(m,p,18)^up(m,p,41),H=m&d^~m&g,V=p&v^~p&y,C=GD(E,_,V,vz[S],uc[S]),I=YD(C,w,F,H,gz[S],ac[S]),L=C|0,R=yl(n,i,28)^ap(n,i,34)^ap(n,i,39),k=El(n,i,28)^up(n,i,34)^up(n,i,39),M=n&o^n&a^o&a,N=i&s^i&u^s&u;w=g|0,E=y|0,g=d|0,y=v|0,d=m|0,v=p|0,{h:m,l:p}=Jo(l|0,f|0,I|0,L|0),l=a|0,f=u|0,a=o|0,u=s|0,o=n|0,s=i|0;let D=qD(L,k,N);n=KD(D,I,R,M),i=D|0}({h:n,l:i}=Jo(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=Jo(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:u}=Jo(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:f}=Jo(this.Dh|0,this.Dl|0,l|0,f|0),{h:m,l:p}=Jo(this.Eh|0,this.El|0,m|0,p|0),{h:d,l:v}=Jo(this.Fh|0,this.Fl|0,d|0,v|0),{h:g,l:y}=Jo(this.Gh|0,this.Gl|0,g|0,y|0),{h:w,l:E}=Jo(this.Hh|0,this.Hl|0,w|0,E|0),this.set(n,i,o,s,a,u,l,f,m,p,d,v,g,y,w,E)}roundClean(){_s(ac,uc)}destroy(){this.destroyed=!0,_s(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},YE=class extends GE{Ah=Fn[0]|0;Al=Fn[1]|0;Bh=Fn[2]|0;Bl=Fn[3]|0;Ch=Fn[4]|0;Cl=Fn[5]|0;Dh=Fn[6]|0;Dl=Fn[7]|0;Eh=Fn[8]|0;El=Fn[9]|0;Fh=Fn[10]|0;Fl=Fn[11]|0;Gh=Fn[12]|0;Gl=Fn[13]|0;Hh=Fn[14]|0;Hl=Fn[15]|0;constructor(){super(64)}};var Kr=UE(()=>new zE,HE(1));var Wm=UE(()=>new YE,HE(3));var bme=P(x(),1);var Gde=P(x(),1);function ZE(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function wz(e){if(!ZE(e))throw new TypeError("Uint8Array expected")}function QD(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function yz(e){if(typeof e!="function")throw new TypeError("function expected");return!0}function bl(e,t){if(typeof t!="string")throw new TypeError(`${e}: string expected`);return!0}function QE(e){if(typeof e!="number")throw new TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw new RangeError(`invalid integer: ${e}`)}function WE(e){if(!Array.isArray(e))throw new TypeError("array expected")}function Jm(e,t){if(!QD(!0,t))throw new TypeError(`${e}: array of strings expected`)}function eF(e,t){if(!QD(!1,t))throw new TypeError(`${e}: array of numbers expected`)}function eb(...e){let t=o=>o,r=(o,s)=>a=>o(s(a)),n=e.map(o=>o.encode).reduceRight(r,t),i=e.map(o=>o.decode).reduce(r,t);return{encode:n,decode:i}}function tb(e){let t=typeof e=="string"?e.split(""):e,r=t.length;Jm("alphabet",t);let n=new Map(t.map((i,o)=>[i,o]));return{encode:i=>(WE(i),i.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:i=>(WE(i),i.map(o=>{bl("alphabet.decode",o);let s=n.get(o);if(s===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function rb(e=""){return bl("join",e),{encode:t=>(Jm("join.decode",t),t.join(e)),decode:t=>(bl("join.decode",t),t.split(e))}}function Ez(e,t="="){return QE(e),bl("padding",t),{encode(r){for(Jm("padding.encode",r);r.length*e%8;)r.push(t);return r},decode(r){Jm("padding.decode",r);let n=r.length;if(n*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===t;n--)if((n-1)*e%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}var tF=(e,t)=>t===0?e:tF(t,e%t),Zm=(e,t)=>e+(t-tF(e,t)),Xm=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function XE(e,t,r,n){if(WE(e),t<=0||t>32)throw new RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new RangeError(`convertRadix2: wrong to=${r}`);if(Zm(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Zm(t,r)}`);let i=0,o=0,s=Xm[t],a=Xm[r]-1,u=[];for(let l of e){if(QE(l),l>=s)throw new Error(`convertRadix2: invalid data word=${l} from=${t}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=r;o-=r)u.push((i>>o-r&a)>>>0);let f=Xm[o];if(f===void 0)throw new Error("invalid carry");i&=f-1}if(i=i<=t)throw new Error("Excess padding");if(!n&&i>0)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&u.push(i>>>0),u}function nb(e,t=!1){if(QE(e),e<=0||e>32)throw new RangeError("radix2: bits should be in (0..32]");if(Zm(8,e)>32||Zm(e,8)>32)throw new RangeError("radix2: carry overflow");return{encode:r=>{if(!ZE(r))throw new TypeError("radix2.encode input should be Uint8Array");return XE(Array.from(r),8,e,!t)},decode:r=>(eF("radix2.decode",r),Uint8Array.from(XE(r,e,8,t)))}}function XD(e){return yz(e),function(...t){try{return e.apply(null,t)}catch{}}}var bz=typeof Uint8Array.from([]).toBase64=="function"&&typeof Uint8Array.fromBase64=="function",Az=/[\t\n\f\r ]/,Sz=(e,t)=>{bl("base64",e);let r=t?"base64url":"base64";if(e.length>0&&Az.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},sb=Object.freeze(bz?{encode(e){return wz(e),e.toBase64()},decode(e){return Sz(e,!1)}}:eb(nb(6),tb("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Ez(6),rb(""))),ts=Object.freeze(eb(nb(6),tb("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),rb("")));var JE=eb(tb("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),rb("")),JD=[996825010,642813549,513874426,1027748829,705979059];function cp(e){let t=e>>25,r=(e&33554431)<<5;for(let n=0;n>n&1)===1&&(r^=JD[n]);return r}function ZD(e,t,r=1){let n=e.length,i=1;for(let o=0;o126)throw new Error(`Invalid prefix (${e})`);i=cp(i)^s>>5}i=cp(i);for(let o=0;od)throw new TypeError(`Length ${g} exceeds limit ${d}`);let y=m.toLowerCase(),w=ZD(y,p,t);return`${y}1${JE.encode(p)}${w}`}function a(m,p=90){bl("bech32.decode input",m);let d=m.length;if(d<8||p!==!1&&d>p)throw new TypeError(`invalid string length: ${d} (${m}). Expected (8..${p})`);let v=m.toLowerCase();if(m!==v&&m!==m.toUpperCase())throw new Error("String must be lowercase or uppercase");let g=v.lastIndexOf("1");if(g===0||g===-1)throw new Error('Letter "1" must be present between prefix and data only');let y=v.slice(0,g),w=v.slice(g+1);if(w.length<6)throw new Error("Data must be at least 6 characters long");let E=JE.decode(w).slice(0,-6),S=ZD(y,E,t);if(!w.endsWith(S))throw new Error(`Invalid checksum in ${m}: expected "${S}"`);return{prefix:y,words:E}}let u=XD(a);function l(m){let{prefix:p,words:d}=a(m,!1);return{prefix:p,words:d,bytes:n(d)}}function f(m,p){return s(m,i(p))}return{encode:s,decode:a,encodeFromBytes:f,decodeToBytes:l,decodeUnsafe:u,fromWords:n,fromWordsUnsafe:o,toWords:i}}var Pi=Object.freeze(Cz("bech32"));var rpe=P(x(),1);var Jde=P(x(),1);function Dz(e,t,r,n){tu(e);let i=zm({dkLen:32,asyncTick:10},n),{c:o,dkLen:s,asyncTick:a}=i;if(qr(o,"c"),qr(s,"dkLen"),qr(a,"asyncTick"),o<1)throw new Error("iterations (c) must be >= 1");if(s<1)throw new Error('"dkLen" must be >= 1');if(s>(2**32-1)*e.outputLen)throw new Error("derived key too long");let u=NE(t,"password"),l=NE(r,"salt"),f=new Uint8Array(s),m=Xo.create(e,u),p=m._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:f,PRF:m,PRFSalt:p}}function Fz(e,t,r,n,i){return e.destroy(),t.destroy(),n&&n.destroy(),_s(i),r}function ib(e,t,r,n){let{c:i,dkLen:o,DK:s,PRF:a,PRFSalt:u}=Dz(e,t,r,n),l,f=new Uint8Array(4),m=rh(f),p=new Uint8Array(a.outputLen);for(let d=1,v=0;v0&&(s+=16),rF(r,o,e,t+=16,r,s)}function Bz(e,t,r){let n=zm({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:i,r:o,p:s,dkLen:a,asyncTick:u,maxmem:l,onProgress:f}=n;if(qr(i,"N"),qr(o,"r"),qr(s,"p"),qr(a,"dkLen"),qr(u,"asyncTick"),qr(l,"maxmem"),f!==void 0&&typeof f!="function")throw new Error("progressCb must be a function");let m=128*o,p=m/4,d=Math.pow(2,32);if(i<=1||i&i-1||i>d)throw new Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(d-1)*32/m)throw new Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(d-1)*32)throw new Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let v=m*(i+s+1);if(v>l)throw new Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+v+", maxmem="+l);let g=ib(Kr,e,t,{c:1,dkLen:m*s}),y=Km(g),w=Km(new Uint8Array(m*i)),E=Km(new Uint8Array(m)),S=()=>{};if(f){let F=2*i*s,_=Math.max(Math.floor(F/1e4),1),H=0;S=()=>{H++,f&&(!(H%_)||H===F)&&f(H/F)}}return{N:i,r:o,p:s,dkLen:a,blockSize32:p,V:w,B32:y,B:g,tmp:E,blockMixCb:S,asyncTick:u}}function Iz(e,t,r,n,i){let o=ib(Kr,e,r,{c:1,dkLen:t});return _s(r,n,i),o}function ab(e,t,r){let{N:n,r:i,p:o,dkLen:s,blockSize32:a,V:u,B32:l,B:f,tmp:m,blockMixCb:p}=Bz(e,t,r);OE(l);for(let d=0;d>>0;for(let w=0;we<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var Tz=e=>{for(let t=0;te:Tz;function sF(e,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(e,t)}function iF(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n[]),o=(a,u)=>n(u,...i(a)).update(a).digest(),s=n(new Uint8Array(e),...i(new Uint8Array(0)));return o.outputLen=s.outputLen,o.blockLen=s.blockLen,o.create=(a,...u)=>n(a,...u),o}var aF=(e,t)=>{function r(n,...i){if(rn(n,void 0,"key"),e.nonceLength!==void 0){let f=i[0];rn(f,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;o&&i[1]!==void 0&&rn(i[1],void 0,"AAD");let s=t(n,...i),a=(f,m)=>{if(m!==void 0){if(f!==2)throw new Error("cipher output not supported");rn(m,void 0,"output")}},u=!1;return{encrypt(f,m){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,rn(f),a(s.encrypt.length,m),s.encrypt(f,m)},decrypt(f,m){if(rn(f),o&&f.lengthUint8Array.from(e.split(""),t=>t.charCodeAt(0)),Rz=nu(Zo(lF("expand 16-byte k"))),kz=nu(Zo(lF("expand 32-byte k")));function zt(e,t){return e<>>32-t}var fp=64,Oz=16,cb=2**32-1,cF=Uint32Array.of();function Nz(e,t,r,n,i,o,s,a){let u=i.length,l=new Uint8Array(fp),f=Zo(l),m=Al&&sh(i)&&sh(o),p=m?Zo(i):cF,d=m?Zo(o):cF;if(!Al){for(let v=0;v=cb)throw new Error("arx: counter overflow");let g=Math.min(fp,u-v);for(let y=0,w;y=cb)throw new Error("arx: counter overflow");let g=Math.min(fp,u-v);if(m&&g===fp){let y=v/4;if(v%4!==0)throw new Error("arx: invalid block position");for(let w=0,E;w{rn(a,void 0,"key"),rn(u,void 0,"nonce"),rn(l,void 0,"data");let p=l.length;if(f=lp(p,f,!1),nh(m),m<0||m>=cb)throw new Error("arx: counter overflow");let d=[],v=a.length,g,y;if(v===32)d.push(g=ih(a)),y=kz;else if(v===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),y=Rz,d.push(g);else throw rn(a,32,"arx key"),new Error("invalid key size");(!Al||!sh(u))&&d.push(u=ih(u));let w=Zo(g);if(n){if(u.length!==24)throw new Error("arx: extended nonce must be 24 bytes");let F=u.subarray(0,16);if(Al)n(y,w,Zo(F),w);else{let _=nu(Uint32Array.from(y));n(_,w,Zo(F),w),uo(_),nu(w)}u=u.subarray(16)}else Al||nu(w);let E=16-i;if(E!==u.length)throw new Error(`arx: nonce must be ${E} or 16 bytes`);if(E!==12){let F=new Uint8Array(12);F.set(u,o?0:12-u.length),u=F,d.push(u)}let S=nu(Zo(u));try{return Nz(e,y,w,S,l,f,m,s),f}finally{uo(...d)}}}var mpe=P(x(),1);function Bn(e,t){return e[t++]&255|(e[t++]&255)<<8}var lb=class{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(t){t=ih(rn(t,32,"key"));let r=Bn(t,0),n=Bn(t,2),i=Bn(t,4),o=Bn(t,6),s=Bn(t,8),a=Bn(t,10),u=Bn(t,12),l=Bn(t,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|u<<5)&8065,this.r[8]=(u>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let f=0;f<8;f++)this.pad[f]=Bn(t,16+2*f)}process(t,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],u=s[1],l=s[2],f=s[3],m=s[4],p=s[5],d=s[6],v=s[7],g=s[8],y=s[9],w=Bn(t,r+0),E=Bn(t,r+2),S=Bn(t,r+4),F=Bn(t,r+6),_=Bn(t,r+8),H=Bn(t,r+10),V=Bn(t,r+12),C=Bn(t,r+14),I=o[0]+(w&8191),L=o[1]+((w>>>13|E<<3)&8191),R=o[2]+((E>>>10|S<<6)&8191),k=o[3]+((S>>>7|F<<9)&8191),M=o[4]+((F>>>4|_<<12)&8191),N=o[5]+(_>>>1&8191),D=o[6]+((_>>>14|H<<2)&8191),O=o[7]+((H>>>11|V<<5)&8191),q=o[8]+((V>>>8|C<<8)&8191),J=o[9]+(C>>>5|i),Y=0,ee=Y+I*a+L*(5*y)+R*(5*g)+k*(5*v)+M*(5*d);Y=ee>>>13,ee&=8191,ee+=N*(5*p)+D*(5*m)+O*(5*f)+q*(5*l)+J*(5*u),Y+=ee>>>13,ee&=8191;let se=Y+I*u+L*a+R*(5*y)+k*(5*g)+M*(5*v);Y=se>>>13,se&=8191,se+=N*(5*d)+D*(5*p)+O*(5*m)+q*(5*f)+J*(5*l),Y+=se>>>13,se&=8191;let le=Y+I*l+L*u+R*a+k*(5*y)+M*(5*g);Y=le>>>13,le&=8191,le+=N*(5*v)+D*(5*d)+O*(5*p)+q*(5*m)+J*(5*f),Y+=le>>>13,le&=8191;let ve=Y+I*f+L*l+R*u+k*a+M*(5*y);Y=ve>>>13,ve&=8191,ve+=N*(5*g)+D*(5*v)+O*(5*d)+q*(5*p)+J*(5*m),Y+=ve>>>13,ve&=8191;let we=Y+I*m+L*f+R*l+k*u+M*a;Y=we>>>13,we&=8191,we+=N*(5*y)+D*(5*g)+O*(5*v)+q*(5*d)+J*(5*p),Y+=we>>>13,we&=8191;let Pe=Y+I*p+L*m+R*f+k*l+M*u;Y=Pe>>>13,Pe&=8191,Pe+=N*a+D*(5*y)+O*(5*g)+q*(5*v)+J*(5*d),Y+=Pe>>>13,Pe&=8191;let Le=Y+I*d+L*p+R*m+k*f+M*l;Y=Le>>>13,Le&=8191,Le+=N*u+D*a+O*(5*y)+q*(5*g)+J*(5*v),Y+=Le>>>13,Le&=8191;let Oe=Y+I*v+L*d+R*p+k*m+M*f;Y=Oe>>>13,Oe&=8191,Oe+=N*l+D*u+O*a+q*(5*y)+J*(5*g),Y+=Oe>>>13,Oe&=8191;let fe=Y+I*g+L*v+R*d+k*p+M*m;Y=fe>>>13,fe&=8191,fe+=N*f+D*l+O*u+q*a+J*(5*y),Y+=fe>>>13,fe&=8191;let Se=Y+I*y+L*g+R*v+k*d+M*p;Y=Se>>>13,Se&=8191,Se+=N*m+D*f+O*l+q*u+J*a,Y+=Se>>>13,Se&=8191,Y=(Y<<2)+Y|0,Y=Y+ee|0,ee=Y&8191,Y=Y>>>13,se+=Y,o[0]=ee,o[1]=se,o[2]=le,o[3]=ve,o[4]=we,o[5]=Pe,o[6]=Le,o[7]=Oe,o[8]=fe,o[9]=Se}finalize(){let{h:t,pad:r}=this,n=new Uint16Array(10),i=t[1]>>>13;t[1]&=8191;for(let a=2;a<10;a++)t[a]+=i,i=t[a]>>>13,t[a]&=8191;t[0]+=i*5,i=t[0]>>>13,t[0]&=8191,t[1]+=i,i=t[1]>>>13,t[1]&=8191,t[2]+=i,n[0]=t[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=t[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)n[a]&=o;o=~o;for(let a=0;a<10;a++)t[a]=t[a]&o|n[a];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let s=t[0]+r[0];t[0]=s&65535;for(let a=1;a<8;a++)s=(t[a]+r[a]|0)+(s>>>16)|0,t[a]=s&65535;uo(n)}update(t){ub(this),rn(t),t=ih(t);let{buffer:r,blockLen:n}=this,i=t.length;for(let o=0;o>>0,t[o++]=n[s]>>>8}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}},hF=oF(32,e=>new lb(e));function Lz(e,t,r,n,i,o=20){let s=e[0],a=e[1],u=e[2],l=e[3],f=t[0],m=t[1],p=t[2],d=t[3],v=t[4],g=t[5],y=t[6],w=t[7],E=i,S=r[0],F=r[1],_=r[2],H=s,V=a,C=u,I=l,L=f,R=m,k=p,M=d,N=v,D=g,O=y,q=w,J=E,Y=S,ee=F,se=_;for(let ve=0;ve{e.update(t);let r=t.length%16;r&&e.update(Hz.subarray(r))},Mz=new Uint8Array(32);function pF(e,t,r,n,i){i!==void 0&&rn(i,void 0,"AAD");let o=e(t,r,Mz),s=uF(n.length,i?i.length:0,!0),a=hF.create(o);i&&dF(a,i),dF(a,n),a.update(s);let u=a.digest();return uo(o,s),u}var jz=e=>(t,r,n)=>({encrypt(o,s){let a=o.length;s=lp(a+16,s,!1),s.set(o);let u=s.subarray(0,-16);e(t,r,u,u,1);let l=pF(e,t,r,u,n);return s.set(l,a),uo(l),s},decrypt(o,s){s=lp(o.length-16,s,!1);let a=o.subarray(0,-16),u=o.subarray(-16),l=pF(e,t,r,a,n);if(!iF(u,l))throw uo(l),new Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),uo(l),s}}),xi=aF({blockSize:64,nonceLength:12,tagLength:16},jz(Uz));var o1e=P(x(),1);var Fpe=P(x(),1);var Cpe=P(x(),1);function oh(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function mn(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >0, got ${e}`)}}function ot(e,t,r=""){let n=oh(e),i=e?.length,o=t!==void 0;if(!n||o&&i!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",u=n?`length=${i}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+u)}return e}function Ti(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");mn(e.outputLen),mn(e.blockLen)}function iu(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function eg(e,t){ot(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length='+r)}function tg(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function zs(...e){for(let t=0;t>>t}var qz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Kz(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Vz(e){for(let t=0;te:Vz,gF=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",zz=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Sl(e){if(ot(e),gF)return e.toHex();let t="";for(let r=0;r=su._0&&e<=su._9)return e-su._0;if(e>=su.A&&e<=su.F)return e-(su.A-10);if(e>=su.a&&e<=su.f)return e-(su.a-10)}function Cl(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(gF)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;ie(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function cc(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var lc=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var db=BigInt(0),hb=BigInt(1);function hp(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function vF(e){if(typeof e=="bigint"){if(!ng(e))throw new Error("positive bigint expected, got "+e)}else mn(e);return e}function dp(e){let t=vF(e).toString(16);return t.length&1?"0"+t:t}function wF(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?db:BigInt("0x"+e)}function fc(e){return wF(Sl(e))}function hc(e){return wF(Sl(sg(ot(e)).reverse()))}function uh(e,t){mn(t),e=vF(e);let r=Cl(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function pp(e,t){return uh(e,t).reverse()}function sg(e){return Uint8Array.from(e)}function dc(e){return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new Error(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var ng=e=>typeof e=="bigint"&&db<=e;function Gz(e,t,r){return ng(e)&&ng(t)&&ng(r)&&t<=e&&edb;e>>=hb,t+=1);return t}var gp=e=>(hb<new Uint8Array(y),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,u=n(e),l=n(e),f=0,m=()=>{u.fill(1),l.fill(0),f=0},p=(...y)=>r(l,Gr(u,...y)),d=(y=i)=>{l=p(o,y),u=p(),y.length!==0&&(l=p(s,y),u=p())},v=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let y=0,w=[];for(;y{m(),d(y);let E;for(;!(E=w(v()));)d();return m(),E}}function _l(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(o,s,a){let u=e[o];if(a&&u===void 0)return;let l=typeof u;if(l!==s||u===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${l}`)}let i=(o,s)=>Object.entries(o).forEach(([a,u])=>n(a,u,s));i(t,!1),i(r,!0)}function mb(e){let t=new WeakMap;return(r,...n)=>{let i=t.get(r);if(i!==void 0)return i;let o=e(r,...n);return t.set(r,o),o}}var kpe=P(x(),1);var Ppe=P(x(),1);var Fs=BigInt(0),rs=BigInt(1),Dl=BigInt(2),AF=BigInt(3),SF=BigInt(4),CF=BigInt(5),Yz=BigInt(7),_F=BigInt(8),Wz=BigInt(9),DF=BigInt(16);function Ds(e,t){let r=e%t;return r>=Fs?r:t+r}function Ri(e,t,r){let n=e;for(;t-- >Fs;)n*=n,n%=r;return n}function EF(e,t){if(e===Fs)throw new Error("invert: expected non-zero number");if(t<=Fs)throw new Error("invert: expected positive modulus, got "+t);let r=Ds(e,t),n=t,i=Fs,o=rs,s=rs,a=Fs;for(;r!==Fs;){let l=n/r,f=n%r,m=i-s*l,p=o-a*l;n=r,r=f,i=s,o=a,s=m,a=p}if(n!==rs)throw new Error("invert: does not exist");return Ds(i,t)}function vb(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function FF(e,t){let r=(e.ORDER+rs)/SF,n=e.pow(t,r);return vb(e,n,t),n}function Xz(e,t){let r=(e.ORDER-CF)/_F,n=e.mul(t,Dl),i=e.pow(n,r),o=e.mul(t,i),s=e.mul(e.mul(o,Dl),i),a=e.mul(o,e.sub(s,e.ONE));return vb(e,a,t),a}function Jz(e){let t=ig(e),r=BF(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+Yz)/DF;return(a,u)=>{let l=a.pow(u,s),f=a.mul(l,n),m=a.mul(l,i),p=a.mul(l,o),d=a.eql(a.sqr(f),u),v=a.eql(a.sqr(m),u);l=a.cmov(l,f,d),f=a.cmov(p,m,v);let g=a.eql(a.sqr(f),u),y=a.cmov(l,f,g);return vb(a,y,u),y}}function BF(e){if(e1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return FF;let o=i.pow(n,t),s=(t+rs)/Dl;return function(u,l){if(u.is0(l))return l;if(bF(u,l)!==1)throw new Error("Cannot find square root");let f=r,m=u.mul(u.ONE,o),p=u.pow(l,t),d=u.pow(l,s);for(;!u.eql(p,u.ONE);){if(u.is0(p))return u.ZERO;let v=1,g=u.sqr(p);for(;!u.eql(g,u.ONE);)if(v++,g=u.sqr(g),v===f)throw new Error("Cannot find square root");let y=rs<(n[i]="function",n),t);return _l(e,r),e}function eG(e,t,r){if(rFs;)r&rs&&(n=e.mul(n,i)),i=e.sqr(i),r>>=rs;return n}function vp(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),i=t.reduce((s,a,u)=>e.is0(a)?s:(n[u]=s,e.mul(s,a)),e.ONE),o=e.inv(i);return t.reduceRight((s,a,u)=>e.is0(a)?s:(n[u]=e.mul(s,n[u]),e.mul(s,a)),o),n}function bF(e,t){let r=(e.ORDER-rs)/Dl,n=e.pow(t,r),i=e.eql(n,e.ONE),o=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function tG(e,t){t!==void 0&&mn(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var gb=class{ORDER;BITS;BYTES;isLE;ZERO=Fs;ONE=rs;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=Fs)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=tG(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return Ds(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return Fs<=t&&ti)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(i);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let u=o?hc(t):fc(t);if(a&&(u=Ds(u,s)),!r&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(t){return vp(this,t)}cmov(t,r,n){return n?r:t}};function ig(e,t={}){return new gb(e,t)}function IF(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function yb(e){let t=IF(e);return t+Math.ceil(t/2)}function $F(e,t,r=!1){ot(e);let n=e.length,i=IF(t),o=yb(t);if(n<16||n1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?hc(e):fc(e),a=Ds(s,t-rs)+rs;return r?pp(a,i):uh(a,i)}var ch=BigInt(0),Fl=BigInt(1);function wp(e,t){let r=t.negate();return e?r:t}function Sb(e,t){let r=vp(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function RF(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Eb(e,t){RF(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=gp(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function PF(e,t,r){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r,a=Number(e&i),u=e>>s;a>n&&(a-=o,u+=Fl);let l=t*n,f=l+Math.abs(a)-1,m=a===0,p=a<0,d=t%2!==0;return{nextN:u,offset:f,isZero:m,isNeg:p,isNegF:d,offsetF:l}}var bb=new WeakMap,kF=new WeakMap;function Ab(e){return kF.get(e)||1}function xF(e){if(e!==ch)throw new Error("invalid wNAF")}var og=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let i=t;for(;r>ch;)r&Fl&&(n=n.add(i)),i=i.double(),r>>=Fl;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=Eb(r,this.bits),o=[],s=t,a=s;for(let u=0;uch||n>ch;)r&Fl&&(o=o.add(i)),n&Fl&&(s=s.add(i)),i=i.double(),r>>=Fl,n>>=Fl;return{p1:o,p2:s}}function TF(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return wb(t),t}else return ig(e,{isLE:r})}function NF(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let u of["p","n","h"]){let l=t[u];if(!(typeof l=="bigint"&&l>ch))throw new Error(`CURVE.${u} must be positive bigint`)}let i=TF(t.p,r.Fp,n),o=TF(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let u of a)if(!i.isValid(t[u]))throw new Error(`CURVE.${u} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function ag(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var Hpe=P(x(),1);var yp=BigInt(0),lh=BigInt(1),ug=BigInt(2);function rG(e){return _l(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function LF(e){let t=rG(e),{P:r,type:n,adjustScalarBytes:i,powPminus2:o,randomBytes:s}=t,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");let u=s||cc,l=a?255:448,f=a?32:56,m=BigInt(a?9:5),p=BigInt(a?121665:39081),d=a?ug**BigInt(254):ug**BigInt(447),v=a?BigInt(8)*ug**BigInt(251)-lh:BigInt(4)*ug**BigInt(445)-lh,g=d+v+lh,y=N=>Ds(N,r),w=E(m);function E(N){return pp(y(N),f)}function S(N){let D=sg(ot(N,f,"uCoordinate"));return a&&(D[31]&=127),y(hc(D))}function F(N){return hc(i(sg(ot(N,f,"scalar"))))}function _(N,D){let O=L(S(D),F(N));if(O===yp)throw new Error("invalid private or public key received");return E(O)}function H(N){return _(N,w)}let V=H,C=_;function I(N,D,O){let q=y(N*(D-O));return D=y(D-q),O=y(O+q),{x_2:D,x_3:O}}function L(N,D){mp("u",N,yp,r),mp("scalar",D,d,g);let O=D,q=N,J=lh,Y=yp,ee=N,se=lh,le=yp;for(let we=BigInt(l-1);we>=yp;we--){let Pe=O>>we&lh;le^=Pe,{x_2:J,x_3:ee}=I(le,J,ee),{x_2:Y,x_3:se}=I(le,Y,se),le=Pe;let Le=J+Y,Oe=y(Le*Le),fe=J-Y,Se=y(fe*fe),Re=Oe-Se,Ke=ee+se,Qe=ee-se,je=y(Qe*Le),yt=y(Ke*fe),rt=je+yt,vt=je-yt;ee=y(rt*rt),se=y(q*y(vt*vt)),J=y(Oe*Se),Y=y(Re*(Oe+y(p*Re)))}({x_2:J,x_3:ee}=I(le,J,ee)),{x_2:Y,x_3:se}=I(le,Y,se);let ve=o(Y);return y(J*ve)}let R={secretKey:f,publicKey:f,seed:f},k=(N=u(f))=>(ot(N,R.seed,"seed"),N),M={randomSecretKey:k};return Object.freeze({keygen:ag(k,V),getSharedSecret:C,getPublicKey:V,scalarMult:_,scalarMultBase:H,utils:M,GuBytes:w.slice(),lengths:R})}var Xpe=P(x(),1);var qpe=P(x(),1);var cg=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(Ti(t),ot(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;onew cg(e,t).update(r).digest();fh.create=(e,t)=>new cg(e,t);var UF=(e,t)=>(e+(e>=0?t:-t)/HF)/t;function nG(e,t,r){let[[n,i],[o,s]]=t,a=UF(s*e,r),u=UF(-i*e,r),l=e-a*n-u*o,f=-a*i-u*s,m=l=d||f=d)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:m,k1:l,k2neg:p,k2:f}}function _b(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Cb(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return hp(r.lowS,"lowS"),hp(r.prehash,"prehash"),r.format!==void 0&&_b(r.format),r}var Db=class extends Error{constructor(t=""){super(t)}},pc={Err:Db,_tlv:{encode:(e,t)=>{let{Err:r}=pc;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=dp(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?dp(i.length/2|128):"";return dp(e)+o+i+t},decode(e,t){let{Err:r}=pc,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let u=i&127;if(!u)throw new r("tlv.decode(long): indefinite length not supported");if(u>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+u);if(l.length!==u)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of l)s=s<<8|f;if(n+=u,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=pc;if(e{let{X:N,Y:D,Z:O}=k;if(n.eql(O,n.ONE))return{x:N,y:D};let q=k.is0();M==null&&(M=q?n.ONE:n.inv(O));let J=n.mul(N,M),Y=n.mul(D,M),ee=n.mul(O,M);if(q)return{x:n.ZERO,y:n.ZERO};if(!n.eql(ee,n.ONE))throw new Error("invZ was invalid");return{x:J,y:Y}}),V=mb(k=>{if(k.is0()){if(t.allowInfinityPoint&&!n.is0(k.Y))return;throw new Error("bad point: ZERO")}let{x:M,y:N}=k.toAffine();if(!n.isValid(M)||!n.isValid(N))throw new Error("bad point: x or y not field elements");if(!y(M,N))throw new Error("bad point: equation left != right");if(!k.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function C(k,M,N,D,O){return N=new I(n.mul(N.X,k),N.Y,N.Z),M=wp(D,M),N=wp(O,N),M.add(N)}class I{static BASE=new I(o.Gx,o.Gy,n.ONE);static ZERO=new I(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=i;X;Y;Z;constructor(M,N,D){this.X=S("x",M),this.Y=S("y",N,!0),this.Z=S("z",D),Object.freeze(this)}static CURVE(){return o}static fromAffine(M){let{x:N,y:D}=M||{};if(!M||!n.isValid(N)||!n.isValid(D))throw new Error("invalid affine point");if(M instanceof I)throw new Error("projective point not allowed");return n.is0(N)&&n.is0(D)?I.ZERO:new I(N,D,n.ONE)}static fromBytes(M){let N=I.fromAffine(v(ot(M,void 0,"point")));return N.assertValidity(),N}static fromHex(M){return I.fromBytes(Cl(M))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(M=8,N=!0){return R.createCache(this,M),N||this.multiply(lg),this}assertValidity(){V(this)}hasEvenY(){let{y:M}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(M)}equals(M){F(M);let{X:N,Y:D,Z:O}=this,{X:q,Y:J,Z:Y}=M,ee=n.eql(n.mul(N,Y),n.mul(q,O)),se=n.eql(n.mul(D,Y),n.mul(J,O));return ee&&se}negate(){return new I(this.X,n.neg(this.Y),this.Z)}double(){let{a:M,b:N}=o,D=n.mul(N,lg),{X:O,Y:q,Z:J}=this,Y=n.ZERO,ee=n.ZERO,se=n.ZERO,le=n.mul(O,O),ve=n.mul(q,q),we=n.mul(J,J),Pe=n.mul(O,q);return Pe=n.add(Pe,Pe),se=n.mul(O,J),se=n.add(se,se),Y=n.mul(M,se),ee=n.mul(D,we),ee=n.add(Y,ee),Y=n.sub(ve,ee),ee=n.add(ve,ee),ee=n.mul(Y,ee),Y=n.mul(Pe,Y),se=n.mul(D,se),we=n.mul(M,we),Pe=n.sub(le,we),Pe=n.mul(M,Pe),Pe=n.add(Pe,se),se=n.add(le,le),le=n.add(se,le),le=n.add(le,we),le=n.mul(le,Pe),ee=n.add(ee,le),we=n.mul(q,J),we=n.add(we,we),le=n.mul(we,Pe),Y=n.sub(Y,le),se=n.mul(we,ve),se=n.add(se,se),se=n.add(se,se),new I(Y,ee,se)}add(M){F(M);let{X:N,Y:D,Z:O}=this,{X:q,Y:J,Z:Y}=M,ee=n.ZERO,se=n.ZERO,le=n.ZERO,ve=o.a,we=n.mul(o.b,lg),Pe=n.mul(N,q),Le=n.mul(D,J),Oe=n.mul(O,Y),fe=n.add(N,D),Se=n.add(q,J);fe=n.mul(fe,Se),Se=n.add(Pe,Le),fe=n.sub(fe,Se),Se=n.add(N,O);let Re=n.add(q,Y);return Se=n.mul(Se,Re),Re=n.add(Pe,Oe),Se=n.sub(Se,Re),Re=n.add(D,O),ee=n.add(J,Y),Re=n.mul(Re,ee),ee=n.add(Le,Oe),Re=n.sub(Re,ee),le=n.mul(ve,Se),ee=n.mul(we,Oe),le=n.add(ee,le),ee=n.sub(Le,le),le=n.add(Le,le),se=n.mul(ee,le),Le=n.add(Pe,Pe),Le=n.add(Le,Pe),Oe=n.mul(ve,Oe),Se=n.mul(we,Se),Le=n.add(Le,Oe),Oe=n.sub(Pe,Oe),Oe=n.mul(ve,Oe),Se=n.add(Se,Oe),Pe=n.mul(Le,Se),se=n.add(se,Pe),Pe=n.mul(Re,Se),ee=n.mul(fe,ee),ee=n.sub(ee,Pe),Pe=n.mul(fe,Le),le=n.mul(Re,le),le=n.add(le,Pe),new I(ee,se,le)}subtract(M){return this.add(M.negate())}is0(){return this.equals(I.ZERO)}multiply(M){let{endo:N}=t;if(!i.isValidNot0(M))throw new Error("invalid scalar: out of range");let D,O,q=J=>R.cached(this,J,Y=>Sb(I,Y));if(N){let{k1neg:J,k1:Y,k2neg:ee,k2:se}=_(M),{p:le,f:ve}=q(Y),{p:we,f:Pe}=q(se);O=ve.add(Pe),D=C(N.beta,le,we,J,ee)}else{let{p:J,f:Y}=q(M);D=J,O=Y}return Sb(I,[D,O])[0]}multiplyUnsafe(M){let{endo:N}=t,D=this;if(!i.isValid(M))throw new Error("invalid scalar: out of range");if(M===ou||D.is0())return I.ZERO;if(M===hh)return D;if(R.hasCache(this))return this.multiply(M);if(N){let{k1neg:O,k1:q,k2neg:J,k2:Y}=_(M),{p1:ee,p2:se}=OF(I,D,q,Y);return C(N.beta,ee,se,O,J)}else return R.unsafe(D,M)}toAffine(M){return H(this,M)}isTorsionFree(){let{isTorsionFree:M}=t;return s===hh?!0:M?M(I,this):R.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:M}=t;return s===hh?this:M?M(I,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(M=!0){return hp(M,"isCompressed"),this.assertValidity(),d(I,this,M)}toHex(M=!0){return Sl(this.toBytes(M))}toString(){return``}}let L=i.BITS,R=new og(I,t.endo?Math.ceil(L/2):L);return I.BASE.precompute(8),I}function MF(e){return Uint8Array.of(e?2:3)}function jF(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function iG(e,t={}){let{Fn:r}=e,n=t.randomBytes||cc,i=Object.assign(jF(e.Fp,r),{seed:yb(r.ORDER)});function o(d){try{let v=r.fromBytes(d);return r.isValidNot0(v)}catch{return!1}}function s(d,v){let{publicKey:g,publicKeyUncompressed:y}=i;try{let w=d.length;return v===!0&&w!==g||v===!1&&w!==y?!1:!!e.fromBytes(d)}catch{return!1}}function a(d=n(i.seed)){return $F(ot(d,i.seed,"seed"),r.ORDER)}function u(d,v=!0){return e.BASE.multiply(r.fromBytes(d)).toBytes(v)}function l(d){let{secretKey:v,publicKey:g,publicKeyUncompressed:y}=i;if(!oh(d)||"_lengths"in r&&r._lengths||v===g)return;let w=ot(d,void 0,"key").length;return w===g||w===y}function f(d,v,g=!0){if(l(d)===!0)throw new Error("first arg must be private key");if(l(v)===!1)throw new Error("second arg must be public key");let y=r.fromBytes(d);return e.fromBytes(v).multiply(y).toBytes(g)}let m={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=ag(a,u);return Object.freeze({getPublicKey:u,getSharedSecret:f,keygen:p,Point:e,utils:m,lengths:i})}function Bb(e,t,r={}){Ti(t),_l(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||cc,i=r.hmac||((N,D)=>fh(t,N,D)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:u}=s,{keygen:l,getPublicKey:f,getSharedSecret:m,utils:p,lengths:d}=iG(e,r),v={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*HF>hh;return N>D}function w(N,D){if(!s.isValidNot0(D))throw new Error(`invalid signature ${N}: out of range 1..Point.Fn.ORDER`);return D}function E(){if(g)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function S(N,D){_b(D);let O=d.signature,q=D==="compact"?O:D==="recovered"?O+1:void 0;return ot(N,q)}class F{r;s;recovery;constructor(D,O,q){if(this.r=w("r",D),this.s=w("s",O),q!=null){if(E(),![0,1,2,3].includes(q))throw new Error("invalid recovery id");this.recovery=q}Object.freeze(this)}static fromBytes(D,O=v.format){S(D,O);let q;if(O==="der"){let{r:se,s:le}=pc.toSig(ot(D));return new F(se,le)}O==="recovered"&&(q=D[0],O="compact",D=D.subarray(1));let J=d.signature/2,Y=D.subarray(0,J),ee=D.subarray(J,J*2);return new F(s.fromBytes(Y),s.fromBytes(ee),q)}static fromHex(D,O){return this.fromBytes(Cl(D),O)}assertRecovery(){let{recovery:D}=this;if(D==null)throw new Error("invalid recovery id: must be present");return D}addRecoveryBit(D){return new F(this.r,this.s,D)}recoverPublicKey(D){let{r:O,s:q}=this,J=this.assertRecovery(),Y=J===2||J===3?O+a:O;if(!o.isValid(Y))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let ee=o.toBytes(Y),se=e.fromBytes(Gr(MF((J&1)===0),ee)),le=s.inv(Y),ve=H(ot(D,void 0,"msgHash")),we=s.create(-ve*le),Pe=s.create(q*le),Le=e.BASE.multiplyUnsafe(we).add(se.multiplyUnsafe(Pe));if(Le.is0())throw new Error("invalid recovery: point at infinify");return Le.assertValidity(),Le}hasHighS(){return y(this.s)}toBytes(D=v.format){if(_b(D),D==="der")return Cl(pc.hexFromSig(this));let{r:O,s:q}=this,J=s.toBytes(O),Y=s.toBytes(q);return D==="recovered"?(E(),Gr(Uint8Array.of(this.assertRecovery()),J,Y)):Gr(J,Y)}toHex(D){return Sl(this.toBytes(D))}}let _=r.bits2int||function(D){if(D.length>8192)throw new Error("input is too large");let O=fc(D),q=D.length*8-u;return q>0?O>>BigInt(q):O},H=r.bits2int_modN||function(D){return s.create(_(D))},V=gp(u);function C(N){return mp("num < 2^"+u,N,ou,V),s.toBytes(N)}function I(N,D){return ot(N,void 0,"message"),D?ot(t(N),void 0,"prehashed message"):N}function L(N,D,O){let{lowS:q,prehash:J,extraEntropy:Y}=Cb(O,v);N=I(N,J);let ee=H(N),se=s.fromBytes(D);if(!s.isValidNot0(se))throw new Error("invalid private key");let le=[C(se),C(ee)];if(Y!=null&&Y!==!1){let Le=Y===!0?n(d.secretKey):Y;le.push(ot(Le,void 0,"extraEntropy"))}let ve=Gr(...le),we=ee;function Pe(Le){let Oe=_(Le);if(!s.isValidNot0(Oe))return;let fe=s.inv(Oe),Se=e.BASE.multiply(Oe).toAffine(),Re=s.create(Se.x);if(Re===ou)return;let Ke=s.create(fe*s.create(we+Re*se));if(Ke===ou)return;let Qe=(Se.x===Re?0:2)|Number(Se.y&hh),je=Ke;return q&&y(Ke)&&(je=s.neg(Ke),Qe^=1),new F(Re,je,g?void 0:Qe)}return{seed:ve,k2sig:Pe}}function R(N,D,O={}){let{seed:q,k2sig:J}=L(N,D,O);return yF(t.outputLen,s.BYTES,i)(q,J).toBytes(O.format)}function k(N,D,O,q={}){let{lowS:J,prehash:Y,format:ee}=Cb(q,v);if(O=ot(O,void 0,"publicKey"),D=I(D,Y),!oh(N)){let se=N instanceof F?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+se)}S(N,ee);try{let se=F.fromBytes(N,ee),le=e.fromBytes(O);if(J&&se.hasHighS())return!1;let{r:ve,s:we}=se,Pe=H(D),Le=s.inv(we),Oe=s.create(Pe*Le),fe=s.create(ve*Le),Se=e.BASE.multiplyUnsafe(Oe).add(le.multiplyUnsafe(fe));return Se.is0()?!1:s.create(Se.x)===ve}catch{return!1}}function M(N,D,O={}){let{prehash:q}=Cb(O,v);return D=I(D,q),F.fromBytes(N,"recovered").recoverPublicKey(D).toBytes()}return Object.freeze({keygen:l,getPublicKey:f,getSharedSecret:m,utils:p,lengths:d,Point:e,sign:R,verify:k,recoverPublicKey:M,Signature:F,hash:t})}var d0e=P(x(),1);var o0e=P(x(),1);var Qpe=P(x(),1);function qF(e,t,r){return e&t^~e&r}function KF(e,t,r){return e&t^e&r^t&r}var Ep=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,i){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=rg(this.buffer)}update(t){iu(this),ot(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let m=s;mf.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m>VF&fg)}:{h:Number(e>>VF&fg)|0,l:Number(e&fg)|0}}function hg(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;oe>>>r,$b=(e,t,r)=>e<<32-r|t>>>r,Bl=(e,t,r)=>e>>>r|t<<32-r,Il=(e,t,r)=>e<<32-r|t>>>r,bp=(e,t,r)=>e<<64-r|t>>>r-32,Ap=(e,t,r)=>e>>>r-32|t<<64-r;var zF=(e,t,r)=>e<>>32-r,GF=(e,t,r)=>t<>>32-r,YF=(e,t,r)=>t<>>64-r,WF=(e,t,r)=>e<>>64-r;function Qo(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var XF=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),JF=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,ZF=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),QF=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,eB=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),tB=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;var uG=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),mc=new Uint32Array(64),Pb=class extends Ep{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let m=0;m<16;m++,r+=4)mc[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let p=mc[m-15],d=mc[m-2],v=co(p,7)^co(p,18)^p>>>3,g=co(d,17)^co(d,19)^d>>>10;mc[m]=g+mc[m-7]+v+mc[m-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:l,H:f}=this;for(let m=0;m<64;m++){let p=co(a,6)^co(a,11)^co(a,25),d=f+p+qF(a,u,l)+uG[m]+mc[m]|0,g=(co(n,2)^co(n,13)^co(n,22))+KF(n,i,o)|0;f=l,l=u,u=a,a=s+d|0,s=o,o=i,i=n,n=d+g|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(n,i,o,s,a,u,l,f)}roundClean(){zs(mc)}destroy(){this.set(0,0,0,0,0,0,0,0),zs(this.buffer)}},xb=class extends Pb{A=au[0]|0;B=au[1]|0;C=au[2]|0;D=au[3]|0;E=au[4]|0;F=au[5]|0;G=au[6]|0;H=au[7]|0;constructor(){super(32)}};var rB=hg(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),cG=rB[0],lG=rB[1],gc=new Uint32Array(80),vc=new Uint32Array(80),Tb=class extends Ep{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:u,Eh:l,El:f,Fh:m,Fl:p,Gh:d,Gl:v,Hh:g,Hl:y}=this;return[t,r,n,i,o,s,a,u,l,f,m,p,d,v,g,y]}set(t,r,n,i,o,s,a,u,l,f,m,p,d,v,g,y){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=f|0,this.Fh=m|0,this.Fl=p|0,this.Gh=d|0,this.Gl=v|0,this.Hh=g|0,this.Hl=y|0}process(t,r){for(let S=0;S<16;S++,r+=4)gc[S]=t.getUint32(r),vc[S]=t.getUint32(r+=4);for(let S=16;S<80;S++){let F=gc[S-15]|0,_=vc[S-15]|0,H=Bl(F,_,1)^Bl(F,_,8)^Ib(F,_,7),V=Il(F,_,1)^Il(F,_,8)^$b(F,_,7),C=gc[S-2]|0,I=vc[S-2]|0,L=Bl(C,I,19)^bp(C,I,61)^Ib(C,I,6),R=Il(C,I,19)^Ap(C,I,61)^$b(C,I,6),k=ZF(V,R,vc[S-7],vc[S-16]),M=QF(k,H,L,gc[S-7],gc[S-16]);gc[S]=M|0,vc[S]=k|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:u,Dh:l,Dl:f,Eh:m,El:p,Fh:d,Fl:v,Gh:g,Gl:y,Hh:w,Hl:E}=this;for(let S=0;S<80;S++){let F=Bl(m,p,14)^Bl(m,p,18)^bp(m,p,41),_=Il(m,p,14)^Il(m,p,18)^Ap(m,p,41),H=m&d^~m&g,V=p&v^~p&y,C=eB(E,_,V,lG[S],vc[S]),I=tB(C,w,F,H,cG[S],gc[S]),L=C|0,R=Bl(n,i,28)^bp(n,i,34)^bp(n,i,39),k=Il(n,i,28)^Ap(n,i,34)^Ap(n,i,39),M=n&o^n&a^o&a,N=i&s^i&u^s&u;w=g|0,E=y|0,g=d|0,y=v|0,d=m|0,v=p|0,{h:m,l:p}=Qo(l|0,f|0,I|0,L|0),l=a|0,f=u|0,a=o|0,u=s|0,o=n|0,s=i|0;let D=XF(L,k,N);n=JF(D,I,R,M),i=D|0}({h:n,l:i}=Qo(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=Qo(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:u}=Qo(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:f}=Qo(this.Dh|0,this.Dl|0,l|0,f|0),{h:m,l:p}=Qo(this.Eh|0,this.El|0,m|0,p|0),{h:d,l:v}=Qo(this.Fh|0,this.Fl|0,d|0,v|0),{h:g,l:y}=Qo(this.Gh|0,this.Gl|0,g|0,y|0),{h:w,l:E}=Qo(this.Hh|0,this.Hl|0,w|0,E|0),this.set(n,i,o,s,a,u,l,f,m,p,d,v,g,y,w,E)}roundClean(){zs(gc,vc)}destroy(){zs(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Rb=class extends Tb{Ah=In[0]|0;Al=In[1]|0;Bh=In[2]|0;Bl=In[3]|0;Ch=In[4]|0;Cl=In[5]|0;Dh=In[6]|0;Dl=In[7]|0;Eh=In[8]|0;El=In[9]|0;Fh=In[10]|0;Fl=In[11]|0;Gh=In[12]|0;Gl=In[13]|0;Hh=In[14]|0;Hl=In[15]|0;constructor(){super(48)}};var dg=ah(()=>new xb,lc(1));var nB=ah(()=>new Rb,lc(2));var fG=BigInt(1),sB=BigInt(2),hG=BigInt(3),dG=BigInt(5),f0e=BigInt(8),iB=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function pG(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=iB,a=e*e%o*e%o,u=Ri(a,sB,o)*a%o,l=Ri(u,fG,o)*e%o,f=Ri(l,dG,o)*l%o,m=Ri(f,t,o)*f%o,p=Ri(m,r,o)*m%o,d=Ri(p,n,o)*p%o,v=Ri(d,i,o)*d%o,g=Ri(v,i,o)*d%o,y=Ri(g,t,o)*f%o;return{pow_p_5_8:Ri(y,sB,o)*e%o,b2:a}}function mG(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var oB=(()=>{let e=iB;return LF({P:e,type:"x25519",powPminus2:t=>{let{pow_p_5_8:r,b2:n}=pG(t);return Ds(Ri(r,hG,e)*n,e)},adjustScalarBytes:mG})})();var y0e=P(x(),1);var gG={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},vG={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")};var wG=Fb(gG),kb=Bb(wG,dg);var yG=Fb(vG),aB=Bb(yG,nB);var S0e=P(x(),1);function cB(e,t,r){return Ti(e),r===void 0&&(r=new Uint8Array(e.outputLen)),fh(e,r,t)}var Ob=Uint8Array.of(0),uB=Uint8Array.of();function lB(e,t,r,n=32){Ti(e),mn(n,"length");let i=e.outputLen;if(n>255*i)throw new Error("Length must be <= 255*HashLen");let o=Math.ceil(n/i);r===void 0?r=uB:ot(r,void 0,"info");let s=new Uint8Array(o*i),a=fh.create(e,t),u=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let f=0;f>AG)*CG)%SG,t&bG&&(i^=Sp<<(Sp<r>32?YF(e,t,r):zF(e,t,r),hB=(e,t,r)=>r>32?WF(e,t,r):GF(e,t,r);function FG(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,u=(s+2)%10,l=r[u],f=r[u+1],m=fB(l,f,1)^r[a],p=hB(l,f,1)^r[a+1];for(let d=0;d<50;d+=10)e[s+d]^=m,e[s+d+1]^=p}let i=e[2],o=e[3];for(let s=0;s<24;s++){let a=pB[s],u=fB(i,o,a),l=hB(i,o,a),f=dB[s];i=e[f],o=e[f+1],e[f]=u,e[f+1]=l}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=_G[n],e[1]^=DG[n]}zs(r)}var pg=class e{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,r,n,i=!1,o=24){if(this.blockLen=t,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=o,mn(n,"outputLen"),!(0=n&&this.keccak();let s=Math.min(n-this.posOut,o-i);t.set(r.subarray(this.posOut,this.posOut+s),i),this.posOut+=s,i+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return mn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(eg(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,zs(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:i,rounds:o,enableXOF:s}=this;return t||=new e(r,n,i,s,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=n,t.outputLen=i,t.enableXOF=s,t.destroyed=this.destroyed,t}},vB=(e,t,r,n={})=>ah(()=>new pg(t,e,r),n);var $l=vB(6,136,32,lc(8));var wB=vB(6,72,64,lc(10));var yB=(e,t,r,n={})=>ah((i={})=>new pg(t,e,i.dkLen===void 0?r:i.dkLen,!0),n),EB=yB(31,168,16,lc(11)),ea=yB(31,136,32,lc(12));var z0e=P(x(),1);var U0e=P(x(),1);var I0e=P(x(),1);function Nb(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error("wrong u32 integer:"+e);return e}function AB(e){return Nb(e),(e&e-1)===0&&e!==0}function Lb(e,t){Nb(e);let r=0;for(let n=0;n>>=1)r=r<<1|e&1;return r}function SB(e){return Nb(e),31-Math.clz32(e)}function bB(e){let t=e.length;if(t<2||!AB(t))throw new Error("n must be a power of 2 and greater than 1. Got "+t);let r=SB(t);for(let n=0;n{let{N:r,roots:n,dit:i,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,u=SB(r);if(!AB(r))throw new Error("FFT: Polynomial size should be power of two");let l=i!==o;return f=>{if(f.length!==r)throw new Error("FFT: wrong Polynomial length");i&&a&&bB(f);for(let m=0,p=1;m>1,y=r>>d;for(let w=0;wtypeof i=="number"?i:i.bytesLen,n=t.reduce((i,o)=>i+r(o),0);return{bytesLen:n,encode:i=>{let o=new Uint8Array(n);for(let s=0,a=0;s{ot(i,n,e);let o=[];for(let s of t){let a=r(s),u=i.subarray(0,a);o.push(typeof s=="number"?u:s.decode(u)),i=i.subarray(a)}return o}}}function gg(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:n=>{if(n.length!==t)throw new Error(`vecCoder.encode: wrong length=${n.length}. Expected: ${t}`);let i=new Uint8Array(r);for(let o=0,s=0;o{ot(n,r);let i=[];for(let o=0;o{let{newPoly:t,N:r,Q:n,F:i,ROOT_OF_UNITY:o,brvBits:s,isKyber:a}=e,u=(E,S=n)=>{let F=E%S|0;return(F>=0?F|0:S+F|0)|0},l=(E,S=n)=>{let F=u(E,S)|0;return(F>S>>1?F-S|0:F)|0};function f(){let E=t(r);for(let S=0;Su((E|0)+(S|0))|0,sub:(E,S)=>u((E|0)-(S|0))|0,mul:(E,S)=>u((E|0)*(S|0))|0,inv:E=>{throw new Error("not implemented")}},d={N:r,roots:m,invertButterflies:!0,skipStages:a?1:0,brp:!1},v=Ub(p,{dit:!1,...d}),g=Ub(p,{dit:!0,...d});return{mod:u,smod:l,nttZetas:m,NTT:{encode:E=>v(E),decode:E=>{g(E);for(let S=0;S{let F=Hb(E),_=E*(r/8);return{bytesLen:_,encode:H=>{let V=new Uint8Array(_);for(let C=0,I=0,L=0,R=0;C=8;L-=8,I>>=8)V[R++]=I&Hb(L);return V},decode:H=>{let V=t(r);for(let C=0,I=0,L=0,R=0;C=E;L-=E,I>>=E)V[R++]=S.decode(I&F);return V}}}}},BG=e=>(t,r)=>{r||(r=e.blockLen);let n=new Uint8Array(t.length+2);n.set(t);let i=t.length,o=new Uint8Array(r),s=e.create({}),a=0,u=0;return{stats:()=>({calls:a,xofs:u}),get:(l,f)=>(n[i+0]=l,n[i+1]=f,s.destroy(),s=e.create({}).update(n),a++,()=>(u++,s.xofInto(o))),clean:()=>{s.destroy(),nn(o,n)}}},DB=BG(EB);var ns=256,uu=3329,IG=3303,$G=17,{mod:Dp,nttZetas:PG,NTT:xl,bitsCoder:xG}=_B({N:ns,Q:uu,F:IG,ROOT_OF_UNITY:$G,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0}),Mb={512:{N:ns,Q:uu,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:ns,Q:uu,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:ns,Q:uu,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},TG=e=>{if(e>=12)return{encode:r=>r,decode:r=>r};let t=2**(e-1);return{encode:r=>((r<r*uu+t>>>e}},Cp=e=>xG(e,TG(e));function Tl(e,t){for(let r=0;r>1)];r&1&&(n=-n);let{c0:i,c1:o}=kG(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],n);e[2*r+0]=i,e[2*r+1]=o}return e}function FB(e){let t=new Uint16Array(ns);for(let r=0;r>0|n[i+1]<<8)&4095,s=(n[i+1]>>4|n[i+2]<<4)&4095;o>=1,a+=1,a===n?(m=f,f=0):a===2*n&&(o[l++]=Dp(m-f),f=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return o}var OG=e=>{let{K:t,PRF:r,XOF:n,HASH512:i,ETA1:o,ETA2:s,du:a,dv:u}=e,l=Cp(1),f=Cp(u),m=Cp(a),p=Pl("publicKey",gg(Cp(12),t),32),d=gg(Cp(12),t),v=Pl("ciphertext",gg(m,t),f),g=Pl("seed",32,32);return{secretCoder:d,lengths:{secretKey:d.bytesLen,publicKey:p.bytesLen,cipherText:v.bytesLen},keygen:y=>{ot(y,32,"seed");let w=new Uint8Array(33);w.set(y),w[32]=t;let E=i(w),[S,F]=g.decode(E),_=[],H=[];for(let I=0;I{let[S,F]=p.decode(y),_=[];for(let R=0;R{let[E,S]=v.decode(y),F=d.decode(w),_=new Uint16Array(ns);for(let H=0;H{ot(f,l,"seed");let{publicKey:m,secretKey:p}=t.keygen(f.subarray(0,32)),d=r(m),v=a.encode([p,m,d,f.subarray(32)]);return nn(p,d),{publicKey:m,secretKey:v}},getPublicKey:f=>{let[m,p,d,v]=a.decode(f);return Uint8Array.from(p)},encapsulate:(f,m=ta(u))=>{ot(f,s.publicKey,"publicKey"),ot(m,u,"message");let p=f.subarray(0,384*e.K),d=o.encode(o.decode(CB(p)));if(!mg(d,p))throw nn(d),new Error("ML-KEM.encapsulate: wrong publicKey modulus");nn(d);let v=n.create().update(m).update(r(f)).digest(),g=t.encrypt(f,m,v.subarray(32,64));return nn(v.subarray(32)),{cipherText:g,sharedSecret:v.subarray(0,32)}},decapsulate:(f,m)=>{ot(m,a.bytesLen,"secretKey"),ot(f,s.cipherText,"cipherText");let p=a.bytesLen-96,d=p+32,v=r(m.subarray(p/2,d));if(!mg(v,m.subarray(d,d+32)))throw new Error("invalid secretKey: hash check failed");let[g,y,w,E]=a.decode(m),S=t.decrypt(f,g),F=n.create().update(S).update(w).digest(),_=F.subarray(0,32),H=t.encrypt(y,S,F.subarray(32,64)),V=mg(f,H),C=i.create({dkLen:32}).update(E).update(f).digest();return nn(S,H,V?C:_),V?_:C}}}function NG(e,t,r){return ea.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var qb={HASH256:$l,HASH512:wB,KDF:ea,XOF:DB,PRF:NG},K0e=jb({...qb,...Mb[512]}),Fp=jb({...qb,...Mb[768]}),BB=jb({...qb,...Mb[1024]});function LG(e,t=!1){let r=e.lengths,n=e.keygen;if(t){let o=e.Point.Fn;if(!o)throw new Error("No Point.Fn");n=(s=ta(r.seed))=>{ot(s,r.seed,"seed");let a=o.isLE?hc(s):fc(s),u=o.toBytes(o.create(a));return{secretKey:u,publicKey:e.getPublicKey(u)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:n,getPublicKey:i=>e.getPublicKey(i)}}function Kb(e,t=!1){let r=LG(e,t);if(!e.getSharedSecret)throw new Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(n,i=ta(e.lengths.seed)){let o=this.keygen(i).secretKey,s=this.decapsulate(n,o),a=e.getPublicKey(o);return nn(o),{sharedSecret:s,cipherText:a}},decapsulate(n,i){let o=e.getSharedSecret(i,n);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function Bp(e,t){return Pl(t,...e.map(r=>{if(typeof r.lengths[t]!="number")throw new Error("wrong length: "+t);return r.lengths[t]}))}function Vb(e){return(t,r)=>e(t,{dkLen:r})}function UG(e,t,...r){let n=Bp(r,"seed"),i=Bp(r,"publicKey");e===void 0&&(e=n.bytesLen),mn(e);function o(s){ot(s,e);let a=n.decode(t(s,n.bytesLen)),u=r.map((m,p)=>m.keygen(a[p])),l=u.map(m=>m.secretKey),f=u.map(m=>m.publicKey);return{secretKey:l,publicKey:f}}return{info:{lengths:{seed:e,publicKey:i.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=ta(e)){let{publicKey:a,secretKey:u}=o(s),l=i.encode(a);return nn(a),nn(u),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function wg(e,t,r,n,...i){let o=UG(e,r,...i),s=Bp(i,"cipherText"),a=Bp(i,"publicKey"),u=Bp(i,"msg");return t===void 0&&(t=u.bytesLen),mn(t),{lengths:{...o.info.lengths,msg:t,msgRand:u.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,f=ta(u.bytesLen)){let m=a.decode(l),p=u.decode(f),d=i.map((w,E)=>w.encapsulate(m[E],p[E])),v=d.map(w=>w.sharedSecret),g=d.map(w=>w.cipherText),y={sharedSecret:n(m,g,v),cipherText:s.encode(g)};return nn(v,g),y},decapsulate(l,f){let m=s.decode(l),{publicKey:p,secretKey:d}=o.expandDecapsulationKey(f),v=i.map((g,y)=>g.decapsulate(m[y],d[y]));return n(p,m,v)}}}function IB(e,t,r,n,i){return Ti(n),Ti(i),wg(32,32,Vb(n),(o,s,a)=>i(Gr(a[0],a[1],s[1],o[1],dc(e))),t,r)}var r1e=IB("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Fp,Kb(kb,!0),ea,$l),n1e=IB("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",BB,Kb(aB,!0),ea,$l);function HG(e,t,r,n,i){return Ti(n),Ti(i),wg(32,32,Vb(n),(o,s,a)=>{let u=Gr(a[0],a[1],s[0],o[0],s[1],o[1],dc(e)),l=32,f=Gr(dc("hybrid_prk"),u),m=cB(i,f),p=Gr(uh(l,2),dc("shared_secret"),dc("")),d=lB(i,m,p,l);return nn(m,p,f,u),d},t,r)}var $B=Kb(oB),s1e=HG("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Fp,$B,ea,dg),MG=wg(32,32,Vb(ea),(e,t,r)=>$l(Gr(r[0],r[1],t[1],e[1],dc("\\.//^\\"))),Fp,$B);function jG(e,t,r,n){let i=e.Point.Fn;if(!i)throw new Error("no Point.Fn");function o(s){let a;for(let f=0,m=t;;f=m,m+=t){if(m>s.length)throw new Error("rejection sampling failed");if(a=i.fromBytes(s.subarray(f,m),!0),i.isValidNot0(a))break}let u=i.toBytes(i.create(a)),l=e.getPublicKey(u,!1);return{secretKey:u,publicKey:l}}return{lengths:{secretKey:t,publicKey:r,seed:n,msg:n,cipherText:r},keygen(s=ta(n)){return ot(s,n,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=ta(n)){ot(a,n,"rand");let{secretKey:u}=o(a),l=this.decapsulate(s,u),f=e.getPublicKey(u,!1);return nn(u),{sharedSecret:l,cipherText:f}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function qG(e,t,r,n){let{secretKey:i,publicKeyUncompressed:o}=r.lengths;if(!i||!o)throw new Error("wrong curve");let s=jG(r,i,o,n),a=64,u=a+n;return wg(32,32,l=>{ot(l,32);let f=ea(l,{dkLen:u}),m=f.subarray(0,a),p=f.subarray(a,u);return Gr(m,p)},(l,f,m)=>$l(Gr(m[0],m[1],f[1],l[1],dc(e))),t,s)}var KG=qG("MLKEM768-P256",Fp,kb,128);var yg=MG,PB=KG;var T1e=P(x(),1);var c1e=P(x(),1);var cr=(e,t,r)=>Dn(e,t,r),Gb=qr,dh=Vm,$n=(...e)=>LE(...e),ph=e=>sp(e),mh=kE,gh=e=>sc(e),bg=BigInt(0),zb=BigInt(1);function cu(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Ag(e){if(typeof e=="bigint"){if(!Eg(e))throw new RangeError("positive bigint expected, got "+e)}else Gb(e);return e}function ra(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function Ip(e){let t=Ag(e).toString(16);return t.length&1?"0"+t:t}function xB(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?bg:BigInt("0x"+e)}function Rl(e){return xB(Vm(e))}function lo(e){return xB(Vm(wc(Dn(e)).reverse()))}function Sg(e,t){if(qr(t),t===0)throw new RangeError("zero length");e=Ag(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return sp(r.padStart(t*2,"0"))}function $p(e,t){return Sg(e,t).reverse()}function TB(e,t){if(e=cr(e),t=cr(t),e.length!==t.length)return!1;let r=0;for(let n=0;n{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var Eg=e=>typeof e=="bigint"&&bg<=e;function VG(e,t,r){return Eg(e)&&Eg(t)&&Eg(r)&&t<=e&&ebg;e>>=zb,t+=1);return t}var Pp=e=>(zb<new Uint8Array(y),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,u=n(e),l=n(e),f=0,m=()=>{u.fill(1),l.fill(0),f=0},p=(...y)=>r(l,$n(u,...y)),d=(y=i)=>{l=p(o,y),u=p(),y.length!==0&&(l=p(s,y),u=p())},v=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let y=0,w=[];for(;y{m(),d(y);let E;for(;(E=w(v()))===void 0;)d();return m(),E}}function ki(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw new TypeError(`param "${o}" is invalid: expected own property`);let u=e[o];if(a&&u===void 0)return;let l=typeof u;if(l!==s||u===null)throw new TypeError(`param "${o}" is invalid: expected ${s}, got ${l}`)}let i=(o,s)=>Object.entries(o).forEach(([a,u])=>n(a,u,s));i(t,!1),i(r,!0)}var Yb=()=>{throw new Error("not implemented")};var g1e=P(x(),1);var h1e=P(x(),1);var Pn=BigInt(0),Tr=BigInt(1),kl=BigInt(2),LB=BigInt(3),UB=BigInt(4),HB=BigInt(5),zG=BigInt(7),MB=BigInt(8),GG=BigInt(9),jB=BigInt(16);function Er(e,t){if(t<=Pn)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Pn?r:t+r}function Oi(e,t,r){if(tPn;)n*=n,n%=r;return n}function kB(e,t){if(e===Pn)throw new Error("invert: expected non-zero number");if(t<=Pn)throw new Error("invert: expected positive modulus, got "+t);let r=Er(e,t),n=t,i=Pn,o=Tr,s=Tr,a=Pn;for(;r!==Pn;){let l=n/r,f=n-r*l,m=i-s*l,p=o-a*l;n=r,r=f,i=s,o=a,s=m,a=p}if(n!==Tr)throw new Error("invert: does not exist");return Er(i,t)}function Wb(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function qB(e,t){let r=e,n=(r.ORDER+Tr)/UB,i=r.pow(t,n);return Wb(r,i,t),i}function YG(e,t){let r=e,n=(r.ORDER-HB)/MB,i=r.mul(t,kl),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,kl),o),u=r.mul(s,r.sub(a,r.ONE));return Wb(r,u,t),u}function WG(e){let t=Dg(e),r=KB(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+zG)/jB;return(a,u)=>{let l=a,f=l.pow(u,s),m=l.mul(f,n),p=l.mul(f,i),d=l.mul(f,o),v=l.eql(l.sqr(m),u),g=l.eql(l.sqr(p),u);f=l.cmov(f,m,v),m=l.cmov(d,p,g);let y=l.eql(l.sqr(m),u),w=l.cmov(f,m,y);return Wb(l,w,u),w}}function KB(e){if(e1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return qB;let o=i.pow(n,t),s=(t+Tr)/kl;return function(u,l){let f=u;if(f.is0(l))return l;if(OB(f,l)!==1)throw new Error("Cannot find square root");let m=r,p=f.mul(f.ONE,o),d=f.pow(l,t),v=f.pow(l,s);for(;!f.eql(d,f.ONE);){if(f.is0(d))return f.ZERO;let g=1,y=f.sqr(d);for(;!f.eql(y,f.ONE);)if(g++,y=f.sqr(y),g===m)throw new Error("Cannot find square root");let w=Tr<(Er(e,t)&Tr)===Tr,JG=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Xb(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=JG.reduce((n,i)=>(n[i]="function",n),t);if(ki(e,r),ra(e.BYTES,"BYTES"),ra(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Tr)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function ZG(e,t,r){let n=e;if(rPn;)r&Tr&&(i=n.mul(i,o)),o=n.sqr(o),r>>=Tr;return i}function xp(e,t,r=!1){let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,u,l)=>n.is0(u)?a:(i[l]=a,n.mul(a,u)),n.ONE),s=n.inv(o);return t.reduceRight((a,u,l)=>n.is0(u)?a:(i[l]=n.mul(a,i[l]),n.mul(a,u)),s),i}function OB(e,t){let r=e,n=(r.ORDER-Tr)/kl,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function QG(e,t){if(t!==void 0&&Gb(t),e<=Pn)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=vh(e);if(t!==void 0&&t= n.length (${t})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}var NB=new WeakMap,_g=class{ORDER;BITS;BYTES;isLE;ZERO=Pn;ONE=Tr;_lengths;_mod;constructor(t,r={}){if(t<=Tr)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=QG(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return Er(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Pn<=t&&ti)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(i);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let u=o?lo(t):Rl(t);if(a&&(u=Er(u,s)),!r&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(t){return xp(this,t)}cmov(t,r,n){return cu(n,"condition"),n?r:t}};Object.freeze(_g.prototype);function Dg(e,t={}){return new _g(e,t)}function VB(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Tr)throw new Error("field order must be greater than 1");let t=vh(e-Tr);return Math.ceil(t/8)}function Jb(e){let t=VB(e);return t+Math.ceil(t/2)}function zB(e,t,r=!1){cr(e);let n=e.length,i=VB(t),o=Math.max(Jb(t),16);if(n1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?lo(e):Rl(e),a=Er(s,t-Tr)+Tr;return r?$p(a,i):Sg(a,i)}var wh=BigInt(0),Ol=BigInt(1);function Tp(e,t){let r=t.negate();return e?r:t}function Nl(e,t){let r=xp(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function XB(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Zb(e,t){XB(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=Pp(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function GB(e,t,r){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r,a=Number(e&i),u=e>>s;a>n&&(a-=o,u+=Ol);let l=t*n,f=l+Math.abs(a)-1,m=a===0,p=a<0,d=t%2!==0;return{nextN:u,offset:f,isZero:m,isNeg:p,isNegF:d,offsetF:l}}var Qb=new WeakMap,JB=new WeakMap;function eA(e){return JB.get(e)||1}function YB(e){if(e!==wh)throw new Error("invalid wNAF")}var yh=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let i=t;for(;r>wh;)r&Ol&&(n=n.add(i)),i=i.double(),r>>=Ol;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=Zb(r,this.bits),o=[],s=t,a=s;for(let u=0;uwh||n>wh;)r&Ol&&(o=o.add(i)),n&Ol&&(s=s.add(i)),i=i.double(),r>>=Ol,n>>=Ol;return{p1:o,p2:s}}function WB(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Xb(t),t}else return Dg(e,{isLE:r})}function Fg(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let u of["p","n","h"]){let l=t[u];if(!(typeof l=="bigint"&&l>wh))throw new Error(`CURVE.${u} must be positive bigint`)}let i=WB(t.p,r.Fp,n),o=WB(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let u of a)if(!i.isValid(t[u]))throw new Error(`CURVE.${u} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function Rp(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var y1e=P(x(),1);function kp(e,t){if(ra(e),ra(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function eY(e,t){let r=new Uint8Array(e.length);for(let n=0;n255&&(t=n($n(Cg("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=$n(t,kp(t.length,1)),u=new Uint8Array(o),l=kp(r,2),f=new Array(s),m=n($n(u,e,l,kp(0,1),a));f[0]=n($n(m,kp(1,1),a));for(let d=1;d(e+(e>=0?t:-t)/tI)/t;function rY(e,t,r){lu("scalar",e,na,r);let[[n,i],[o,s]]=t,a=eI(s*e,r),u=eI(-i*e,r),l=e-a*n-u*o,f=-a*i-u*s,m=l=d||f=d)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:m,k1:l,k2neg:p,k2:f}}function nA(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function rA(e,t){ki(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return cu(r.lowS,"lowS"),cu(r.prehash,"prehash"),r.format!==void 0&&nA(r.format),r}var sA=class extends Error{constructor(t=""){super(t)}},fo={Err:sA,_tlv:{encode:(e,t)=>{let{Err:r}=fo;if(ra(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=Ip(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?Ip(i.length/2|128):"";return Ip(e)+o+i+t},decode(e,t){let{Err:r}=fo;t=cr(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let u=i&127;if(!u)throw new r("tlv.decode(long): indefinite length not supported");if(u>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+u);if(l.length!==u)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of l)s=s<<8|f;if(n+=u,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=fo;if(Ag(e),e1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Rl(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=fo,i=cr(e,void 0,"signature"),{v:o,l:s}=n.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:u}=n.decode(2,o),{v:l,l:f}=n.decode(2,u);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=fo,n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}};Object.freeze(fo._tlv);Object.freeze(fo._int);Object.freeze(fo);var na=BigInt(0),yc=BigInt(1),tI=BigInt(2),Bg=BigInt(3),nY=BigInt(4);function rI(e,t={}){let r=Fg("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;ki(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:u,allowInfinityPoint:l}=t;if(u&&(!n.is0(o.a)||typeof u.beta!="bigint"||!Array.isArray(u.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=sI(n,i);function m(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function p(R,k,M){if(l&&k.is0())return Uint8Array.of(0);let{x:N,y:D}=k.toAffine(),O=n.toBytes(N);if(cu(M,"isCompressed"),M){m();let q=!n.isOdd(D);return $n(nI(q),O)}else return $n(Uint8Array.of(4),O,n.toBytes(D))}function d(R){cr(R,void 0,"Point");let{publicKey:k,publicKeyUncompressed:M}=f,N=R.length,D=R[0],O=R.subarray(1);if(l&&N===1&&D===0)return{x:n.ZERO,y:n.ZERO};if(N===k&&(D===2||D===3)){let q=n.fromBytes(O);if(!n.isValid(q))throw new Error("bad point: is not on curve, wrong x");let J=y(q),Y;try{Y=n.sqrt(J)}catch(le){let ve=le instanceof Error?": "+le.message:"";throw new Error("bad point: is not on curve, sqrt error"+ve)}m();let ee=n.isOdd(Y);return(D&1)===1!==ee&&(Y=n.neg(Y)),{x:q,y:Y}}else if(N===M&&D===4){let q=n.BYTES,J=n.fromBytes(O.subarray(0,q)),Y=n.fromBytes(O.subarray(q,q*2));if(!w(J,Y))throw new Error("bad point: is not on curve");return{x:J,y:Y}}else throw new Error(`bad point: got length ${N}, expected compressed=${k} or uncompressed=${M}`)}let v=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?d:t.fromBytes;function y(R){let k=n.sqr(R),M=n.mul(k,R);return n.add(n.add(M,n.mul(R,o.a)),o.b)}function w(R,k){let M=n.sqr(k),N=y(R);return n.eql(M,N)}if(!w(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let E=n.mul(n.pow(o.a,Bg),nY),S=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(E,S)))throw new Error("bad curve params: a or b");function F(R,k,M=!1){if(!n.isValid(k)||M&&n.is0(k))throw new Error(`bad point coordinate ${R}`);return k}function _(R){if(!(R instanceof C))throw new Error("Weierstrass Point expected")}function H(R){if(!u||!u.basises)throw new Error("no endo");return rY(R,u.basises,i.ORDER)}function V(R,k,M,N,D){return M=new C(n.mul(M.X,R),M.Y,M.Z),k=Tp(N,k),M=Tp(D,M),k.add(M)}class C{static BASE=new C(o.Gx,o.Gy,n.ONE);static ZERO=new C(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=i;X;Y;Z;constructor(k,M,N){this.X=F("x",k),this.Y=F("y",M,!0),this.Z=F("z",N),Object.freeze(this)}static CURVE(){return o}static fromAffine(k){let{x:M,y:N}=k||{};if(!k||!n.isValid(M)||!n.isValid(N))throw new Error("invalid affine point");if(k instanceof C)throw new Error("projective point not allowed");return n.is0(M)&&n.is0(N)?C.ZERO:new C(M,N,n.ONE)}static fromBytes(k){let M=C.fromAffine(g(cr(k,void 0,"point")));return M.assertValidity(),M}static fromHex(k){return C.fromBytes(ph(k))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(k=8,M=!0){return L.createCache(this,k),M||this.multiply(Bg),this}assertValidity(){let k=this;if(k.is0()){if(t.allowInfinityPoint&&n.is0(k.X)&&n.eql(k.Y,n.ONE)&&n.is0(k.Z))return;throw new Error("bad point: ZERO")}let{x:M,y:N}=k.toAffine();if(!n.isValid(M)||!n.isValid(N))throw new Error("bad point: x or y not field elements");if(!w(M,N))throw new Error("bad point: equation left != right");if(!k.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:k}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(k)}equals(k){_(k);let{X:M,Y:N,Z:D}=this,{X:O,Y:q,Z:J}=k,Y=n.eql(n.mul(M,J),n.mul(O,D)),ee=n.eql(n.mul(N,J),n.mul(q,D));return Y&&ee}negate(){return new C(this.X,n.neg(this.Y),this.Z)}double(){let{a:k,b:M}=o,N=n.mul(M,Bg),{X:D,Y:O,Z:q}=this,J=n.ZERO,Y=n.ZERO,ee=n.ZERO,se=n.mul(D,D),le=n.mul(O,O),ve=n.mul(q,q),we=n.mul(D,O);return we=n.add(we,we),ee=n.mul(D,q),ee=n.add(ee,ee),J=n.mul(k,ee),Y=n.mul(N,ve),Y=n.add(J,Y),J=n.sub(le,Y),Y=n.add(le,Y),Y=n.mul(J,Y),J=n.mul(we,J),ee=n.mul(N,ee),ve=n.mul(k,ve),we=n.sub(se,ve),we=n.mul(k,we),we=n.add(we,ee),ee=n.add(se,se),se=n.add(ee,se),se=n.add(se,ve),se=n.mul(se,we),Y=n.add(Y,se),ve=n.mul(O,q),ve=n.add(ve,ve),se=n.mul(ve,we),J=n.sub(J,se),ee=n.mul(ve,le),ee=n.add(ee,ee),ee=n.add(ee,ee),new C(J,Y,ee)}add(k){_(k);let{X:M,Y:N,Z:D}=this,{X:O,Y:q,Z:J}=k,Y=n.ZERO,ee=n.ZERO,se=n.ZERO,le=o.a,ve=n.mul(o.b,Bg),we=n.mul(M,O),Pe=n.mul(N,q),Le=n.mul(D,J),Oe=n.add(M,N),fe=n.add(O,q);Oe=n.mul(Oe,fe),fe=n.add(we,Pe),Oe=n.sub(Oe,fe),fe=n.add(M,D);let Se=n.add(O,J);return fe=n.mul(fe,Se),Se=n.add(we,Le),fe=n.sub(fe,Se),Se=n.add(N,D),Y=n.add(q,J),Se=n.mul(Se,Y),Y=n.add(Pe,Le),Se=n.sub(Se,Y),se=n.mul(le,fe),Y=n.mul(ve,Le),se=n.add(Y,se),Y=n.sub(Pe,se),se=n.add(Pe,se),ee=n.mul(Y,se),Pe=n.add(we,we),Pe=n.add(Pe,we),Le=n.mul(le,Le),fe=n.mul(ve,fe),Pe=n.add(Pe,Le),Le=n.sub(we,Le),Le=n.mul(le,Le),fe=n.add(fe,Le),we=n.mul(Pe,fe),ee=n.add(ee,we),we=n.mul(Se,fe),Y=n.mul(Oe,Y),Y=n.sub(Y,we),we=n.mul(Oe,Pe),se=n.mul(Se,se),se=n.add(se,we),new C(Y,ee,se)}subtract(k){return _(k),this.add(k.negate())}is0(){return this.equals(C.ZERO)}multiply(k){let{endo:M}=t;if(!i.isValidNot0(k))throw new RangeError("invalid scalar: out of range");let N,D,O=q=>L.cached(this,q,J=>Nl(C,J));if(M){let{k1neg:q,k1:J,k2neg:Y,k2:ee}=H(k),{p:se,f:le}=O(J),{p:ve,f:we}=O(ee);D=le.add(we),N=V(M.beta,se,ve,q,Y)}else{let{p:q,f:J}=O(k);N=q,D=J}return Nl(C,[N,D])[0]}multiplyUnsafe(k){let{endo:M}=t,N=this,D=k;if(!i.isValid(D))throw new RangeError("invalid scalar: out of range");if(D===na||N.is0())return C.ZERO;if(D===yc)return N;if(L.hasCache(this))return this.multiply(D);if(M){let{k1neg:O,k1:q,k2neg:J,k2:Y}=H(D),{p1:ee,p2:se}=ZB(C,N,q,Y);return V(M.beta,ee,se,O,J)}else return L.unsafe(N,D)}toAffine(k){let M=this,N=k,{X:D,Y:O,Z:q}=M;if(n.eql(q,n.ONE))return{x:D,y:O};let J=M.is0();N==null&&(N=J?n.ONE:n.inv(q));let Y=n.mul(D,N),ee=n.mul(O,N),se=n.mul(q,N);if(J)return{x:n.ZERO,y:n.ZERO};if(!n.eql(se,n.ONE))throw new Error("invZ was invalid");return{x:Y,y:ee}}isTorsionFree(){let{isTorsionFree:k}=t;return s===yc?!0:k?k(C,this):L.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:k}=t;return s===yc?this:k?k(C,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===yc?this.is0():this.clearCofactor().is0()}toBytes(k=!0){return cu(k,"isCompressed"),this.assertValidity(),v(C,this,k)}toHex(k=!0){return dh(this.toBytes(k))}toString(){return``}}let I=i.BITS,L=new yh(C,t.endo?Math.ceil(I/2):I);return I>=8&&C.BASE.precompute(8),Object.freeze(C.prototype),Object.freeze(C),C}function nI(e){return Uint8Array.of(e?2:3)}function sI(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function sY(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?gh:t.randomBytes,i=Object.assign(sI(e.Fp,r),{seed:Math.max(Jb(r.ORDER),16)});function o(d){try{let v=r.fromBytes(d);return r.isValidNot0(v)}catch{return!1}}function s(d,v){let{publicKey:g,publicKeyUncompressed:y}=i;try{let w=d.length;return v===!0&&w!==g||v===!1&&w!==y?!1:!!e.fromBytes(d)}catch{return!1}}function a(d){return d=d===void 0?n(i.seed):d,zB(cr(d,i.seed,"seed"),r.ORDER)}function u(d,v=!0){return e.BASE.multiply(r.fromBytes(d)).toBytes(v)}function l(d){let{secretKey:v,publicKey:g,publicKeyUncompressed:y}=i,w=r._lengths;if(!mh(d))return;let E=cr(d,void 0,"key").length,S=E===g||E===y,F=E===v||!!w?.includes(E);if(!(S&&F))return S}function f(d,v,g=!0){if(l(d)===!0)throw new Error("first arg must be private key");if(l(v)===!1)throw new Error("second arg must be public key");let y=r.fromBytes(d);return e.fromBytes(v).multiply(y).toBytes(g)}let m={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=Rp(a,u);return Object.freeze(m),Object.freeze(i),Object.freeze({getPublicKey:u,getSharedSecret:f,keygen:p,Point:e,utils:m,lengths:i})}function iI(e,t,r={}){let n=t;tu(n),ki(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes===void 0?gh:r.randomBytes,o=r.hmac===void 0?(D,O)=>Xo(n,D,O):r.hmac,{Fp:s,Fn:a}=e,{ORDER:u,BITS:l}=a,{keygen:f,getPublicKey:m,getSharedSecret:p,utils:d,lengths:v}=sY(e,r),g={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=u*tI+yc>yc;return D>O}function E(D,O){if(!a.isValidNot0(O))throw new Error(`invalid signature ${D}: out of range 1..Point.Fn.ORDER`);return O}function S(){if(y)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function F(D,O){nA(O);let q=v.signature,J=O==="compact"?q:O==="recovered"?q+1:void 0;return cr(D,J)}class _{r;s;recovery;constructor(O,q,J){if(this.r=E("r",O),this.s=E("s",q),J!=null){if(S(),![0,1,2,3].includes(J))throw new Error("invalid recovery id");this.recovery=J}Object.freeze(this)}static fromBytes(O,q=g.format){F(O,q);let J;if(q==="der"){let{r:le,s:ve}=fo.toSig(cr(O));return new _(le,ve)}q==="recovered"&&(J=O[0],q="compact",O=O.subarray(1));let Y=v.signature/2,ee=O.subarray(0,Y),se=O.subarray(Y,Y*2);return new _(a.fromBytes(ee),a.fromBytes(se),J)}static fromHex(O,q){return this.fromBytes(ph(O),q)}assertRecovery(){let{recovery:O}=this;if(O==null)throw new Error("invalid recovery id: must be present");return O}addRecoveryBit(O){return new _(this.r,this.s,O)}recoverPublicKey(O){let{r:q,s:J}=this,Y=this.assertRecovery(),ee=Y===2||Y===3?q+u:q;if(!s.isValid(ee))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let se=s.toBytes(ee),le=e.fromBytes($n(nI((Y&1)===0),se)),ve=a.inv(ee),we=V(cr(O,void 0,"msgHash")),Pe=a.create(-we*ve),Le=a.create(J*ve),Oe=e.BASE.multiplyUnsafe(Pe).add(le.multiplyUnsafe(Le));if(Oe.is0())throw new Error("invalid recovery: point at infinify");return Oe.assertValidity(),Oe}hasHighS(){return w(this.s)}toBytes(O=g.format){if(nA(O),O==="der")return ph(fo.hexFromSig(this));let{r:q,s:J}=this,Y=a.toBytes(q),ee=a.toBytes(J);return O==="recovered"?(S(),$n(Uint8Array.of(this.assertRecovery()),Y,ee)):$n(Y,ee)}toHex(O){return dh(this.toBytes(O))}}Object.freeze(_.prototype),Object.freeze(_);let H=r.bits2int===void 0?function(O){if(O.length>8192)throw new Error("input is too large");let q=Rl(O),J=O.length*8-l;return J>0?q>>BigInt(J):q}:r.bits2int,V=r.bits2int_modN===void 0?function(O){return a.create(H(O))}:r.bits2int_modN,C=Pp(l);function I(D){return lu("num < 2^"+l,D,na,C),a.toBytes(D)}function L(D,O){return cr(D,void 0,"message"),O?cr(n(D),void 0,"prehashed message"):D}function R(D,O,q){let{lowS:J,prehash:Y,extraEntropy:ee}=rA(q,g);D=L(D,Y);let se=V(D),le=a.fromBytes(O);if(!a.isValidNot0(le))throw new Error("invalid private key");let ve=[I(le),I(se)];if(ee!=null&&ee!==!1){let Oe=ee===!0?i(v.secretKey):ee;ve.push(cr(Oe,void 0,"extraEntropy"))}let we=$n(...ve),Pe=se;function Le(Oe){let fe=H(Oe);if(!a.isValidNot0(fe))return;let Se=a.inv(fe),Re=e.BASE.multiply(fe).toAffine(),Ke=a.create(Re.x);if(Ke===na)return;let Qe=a.create(Se*a.create(Pe+Ke*le));if(Qe===na)return;let je=(Re.x===Ke?0:2)|Number(Re.y&yc),yt=Qe;return J&&w(Qe)&&(yt=a.neg(Qe),je^=1),new _(Ke,yt,y?void 0:je)}return{seed:we,k2sig:Le}}function k(D,O,q={}){let{seed:J,k2sig:Y}=R(D,O,q);return RB(n.outputLen,a.BYTES,o)(J,Y).toBytes(q.format)}function M(D,O,q,J={}){let{lowS:Y,prehash:ee,format:se}=rA(J,g);if(q=cr(q,void 0,"publicKey"),O=L(O,ee),!mh(D)){let le=D instanceof _?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+le)}F(D,se);try{let le=_.fromBytes(D,se),ve=e.fromBytes(q);if(Y&&le.hasHighS())return!1;let{r:we,s:Pe}=le,Le=V(O),Oe=a.inv(Pe),fe=a.create(Le*Oe),Se=a.create(we*Oe),Re=e.BASE.multiplyUnsafe(fe).add(ve.multiplyUnsafe(Se));return Re.is0()?!1:a.create(Re.x)===we}catch{return!1}}function N(D,O,q={}){let{prehash:J}=rA(q,g);return O=L(O,J),_.fromBytes(D,"recovered").recoverPublicKey(O).toBytes()}return Object.freeze({keygen:f,getPublicKey:m,getSharedSecret:p,utils:d,lengths:v,Point:e,sign:k,verify:M,recoverPublicKey:N,Signature:_,hash:n})}var iY={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var oY=rI(iY),Eh=iI(oY,Kr);var rme=P(x(),1);var eme=P(x(),1);var N1e=P(x(),1);var Ec=BigInt(0),Gs=BigInt(1),iA=BigInt(2),aY=BigInt(8);function uY(e,t,r,n){let i=e.sqr(r),o=e.sqr(n),s=e.add(e.mul(t.a,i),o),a=e.add(e.ONE,e.mul(t.d,e.mul(i,o)));return e.eql(s,a)}function oI(e,t={}){let r=t,n=Fg("edwards",e,r,r.FpFnLE),{Fp:i,Fn:o}=n,s=n.CURVE,{h:a}=s;ki(r,{},{uvRatio:"function"});let u=iA<i.create(g),f=r.uvRatio===void 0?(g,y)=>{try{return{isValid:!0,value:i.sqrt(i.div(g,y))}}catch{return{isValid:!1,value:Ec}}}:r.uvRatio;if(!uY(i,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function m(g,y,w=!1){let E=w?Gs:Ec;return lu("coordinate "+g,y,E,u),y}function p(g){if(!(g instanceof d))throw new Error("EdwardsPoint expected")}class d{static BASE=new d(s.Gx,s.Gy,Gs,l(s.Gx*s.Gy));static ZERO=new d(Ec,Gs,Gs,Ec);static Fp=i;static Fn=o;X;Y;Z;T;constructor(y,w,E,S){this.X=m("x",y),this.Y=m("y",w),this.Z=m("z",E,!0),this.T=m("t",S),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof d)throw new Error("extended point not allowed");let{x:w,y:E}=y||{};return m("x",w),m("y",E),new d(w,E,Gs,l(w*E))}static fromBytes(y,w=!1){let E=i.BYTES,{a:S,d:F}=s;y=wc(cr(y,E,"point")),cu(w,"zip215");let _=wc(y),H=y[E-1];_[E-1]=H&-129;let V=lo(_),C=w?u:i.ORDER;lu("point.y",V,Ec,C);let I=l(V*V),L=l(I-Gs),R=l(F*I-S),{isValid:k,value:M}=f(L,R);if(!k)throw new Error("bad point: invalid y coordinate");let N=(M&Gs)===Gs,D=(H&128)!==0;if(!w&&M===Ec&&D)throw new Error("bad point: x=0 and x_0=1");return D!==N&&(M=l(-M)),d.fromAffine({x:M,y:V})}static fromHex(y,w=!1){return d.fromBytes(ph(y),w)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,w=!0){return v.createCache(this,y),w||this.multiply(iA),this}assertValidity(){let y=this,{a:w,d:E}=s;if(y.is0())throw new Error("bad point: ZERO");let{X:S,Y:F,Z:_,T:H}=y,V=l(S*S),C=l(F*F),I=l(_*_),L=l(I*I),R=l(V*w),k=l(I*l(R+C)),M=l(L+l(E*l(V*C)));if(k!==M)throw new Error("bad point: equation left != right (1)");let N=l(S*F),D=l(_*H);if(N!==D)throw new Error("bad point: equation left != right (2)")}equals(y){p(y);let{X:w,Y:E,Z:S}=this,{X:F,Y:_,Z:H}=y,V=l(w*H),C=l(F*S),I=l(E*H),L=l(_*S);return V===C&&I===L}is0(){return this.equals(d.ZERO)}negate(){return new d(l(-this.X),this.Y,this.Z,l(-this.T))}double(){let{a:y}=s,{X:w,Y:E,Z:S}=this,F=l(w*w),_=l(E*E),H=l(iA*l(S*S)),V=l(y*F),C=w+E,I=l(l(C*C)-F-_),L=V+_,R=L-H,k=V-_,M=l(I*R),N=l(L*k),D=l(I*k),O=l(R*L);return new d(M,N,O,D)}add(y){p(y);let{a:w,d:E}=s,{X:S,Y:F,Z:_,T:H}=this,{X:V,Y:C,Z:I,T:L}=y,R=l(S*V),k=l(F*C),M=l(H*E*L),N=l(_*I),D=l((S+F)*(V+C)-R-k),O=N-M,q=N+M,J=l(k-w*R),Y=l(D*O),ee=l(q*J),se=l(D*J),le=l(O*q);return new d(Y,ee,le,se)}subtract(y){return p(y),this.add(y.negate())}multiply(y){if(!o.isValidNot0(y))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:w,f:E}=v.cached(this,y,S=>Nl(d,S));return Nl(d,[w,E])[0]}multiplyUnsafe(y){if(!o.isValid(y))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return y===Ec?d.ZERO:this.is0()||y===Gs?this:v.unsafe(this,y,w=>Nl(d,w))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return v.unsafe(this,s.n).is0()}toAffine(y){let w=this,E=y,{X:S,Y:F,Z:_}=w,H=w.is0();E==null&&(E=H?aY:i.inv(_));let V=l(S*E),C=l(F*E),I=i.mul(_,E);if(H)return{x:Ec,y:Gs};if(I!==Gs)throw new Error("invZ was invalid");return{x:V,y:C}}clearCofactor(){return a===Gs?this:this.multiplyUnsafe(a)}toBytes(){let{x:y,y:w}=this.toAffine(),E=i.toBytes(w);return E[E.length-1]|=y&Gs?128:0,E}toHex(){return dh(this.toBytes())}toString(){return``}}let v=new yh(d,o.BITS);return o.BITS>=8&&d.BASE.precompute(8),Object.freeze(d.prototype),Object.freeze(d),d}var Ig=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){Yb()}static fromHex(t){Yb()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return dh(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.ep.precompute(t,r),this}};var j1e=P(x(),1);var Op=BigInt(0),bh=BigInt(1),$g=BigInt(2);function cY(e){return ki(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function aI(e){let t=cY(e),{P:r,type:n,adjustScalarBytes:i,powPminus2:o,randomBytes:s}=t,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");let u=s===void 0?gh:s,l=a?255:448,f=a?32:56,m=BigInt(a?9:5),p=BigInt(a?121665:39081),d=a?$g**BigInt(254):$g**BigInt(447),v=a?BigInt(8)*$g**BigInt(251)-bh:BigInt(4)*$g**BigInt(445)-bh,g=d+v+bh,y=N=>Er(N,r),w=E(m);function E(N){return $p(y(N),f)}function S(N){let D=wc(cr(N,f,"uCoordinate"));return a&&(D[31]&=127),y(lo(D))}function F(N){return lo(i(wc(cr(N,f,"scalar"))))}function _(N,D){let O=L(S(D),F(N));if(O===Op)throw new Error("invalid private or public key received");return E(O)}function H(N){return _(N,w)}let V=H,C=_;function I(N,D,O){let q=y(N*(D-O));return D=y(D-q),O=y(O+q),{x_2:D,x_3:O}}function L(N,D){lu("u",N,Op,r),lu("scalar",D,d,g);let O=D,q=N,J=bh,Y=Op,ee=N,se=bh,le=Op;for(let we=BigInt(l-1);we>=Op;we--){let Pe=O>>we&bh;le^=Pe,{x_2:J,x_3:ee}=I(le,J,ee),{x_2:Y,x_3:se}=I(le,Y,se),le=Pe;let Le=J+Y,Oe=y(Le*Le),fe=J-Y,Se=y(fe*fe),Re=Oe-Se,Ke=ee+se,Qe=ee-se,je=y(Qe*Le),yt=y(Ke*fe),rt=je+yt,vt=je-yt;ee=y(rt*rt),se=y(q*y(vt*vt)),J=y(Oe*Se),Y=y(Re*(Oe+y(p*Re)))}({x_2:J,x_3:ee}=I(le,J,ee)),{x_2:Y,x_3:se}=I(le,Y,se);let ve=o(Y);return y(J*ve)}let R={secretKey:f,publicKey:f,seed:f},k=N=>(N=N===void 0?u(f):N,cr(N,R.seed,"seed"),N),M={randomSecretKey:k};return Object.freeze(R),Object.freeze(M),Object.freeze({keygen:Rp(k,V),getSharedSecret:C,getPublicKey:V,scalarMult:_,scalarMultBase:H,utils:M,GuBytes:w.slice(),lengths:R})}var lY=BigInt(0),hu=BigInt(1),uI=BigInt(2),fY=BigInt(3),hY=BigInt(5),dY=BigInt(8),Ul=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),cA={p:Ul,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:dY,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function fI(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=Ul,a=e*e%o*e%o,u=Oi(a,uI,o)*a%o,l=Oi(u,hu,o)*e%o,f=Oi(l,hY,o)*l%o,m=Oi(f,t,o)*f%o,p=Oi(m,r,o)*m%o,d=Oi(p,n,o)*p%o,v=Oi(d,i,o)*d%o,g=Oi(v,i,o)*d%o,y=Oi(g,t,o)*f%o;return{pow_p_5_8:Oi(y,uI,o)*e%o,b2:a}}function pY(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var oA=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function lA(e,t){let r=Ul,n=Er(t*t*t,r),i=Er(n*n*t,r),o=fI(e*i).pow_p_5_8,s=Er(e*n*o,r),a=Er(t*s*s,r),u=s,l=Er(s*oA,r),f=a===e,m=a===Er(-e,r),p=a===Er(-e*oA,r);return f&&(s=u),(m||p)&&(s=l),fu(s,r)&&(s=Er(-s,r)),{isValid:f||m,value:s}}var Ll=oI(cA,{uvRatio:lA}),bc=Ll.Fp,hI=Ll.Fn;var Pg=(()=>{let e=Ul;return aI({P:e,type:"x25519",powPminus2:t=>{let{pow_p_5_8:r,b2:n}=fI(t);return Er(Oi(r,fY,e)*n,e)},adjustScalarBytes:pY})})();var aA=oA,mY=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),gY=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),vY=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),wY=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),cI=e=>lA(hu,e),yY=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),uA=e=>bc.create(lo(e)&yY);function lI(e){let{d:t}=cA,r=Ul,n=w=>bc.create(w),i=n(aA*e*e),o=n((i+hu)*vY),s=BigInt(-1),a=n((s-t*i)*n(i+t)),{isValid:u,value:l}=lA(o,a),f=n(l*e);fu(f,r)||(f=n(-f)),u||(l=f),u||(s=i);let m=n(s*(i-hu)*wY-a),p=l*l,d=n((l+l)*a),v=n(m*mY),g=n(hu-p),y=n(hu+p);return new Ll(n(d*y),n(g*v),n(v*y),n(d*g))}var Ac=class e extends Ig{static BASE=new e(Ll.BASE);static ZERO=new e(Ll.ZERO);static Fp=bc;static Fn=hI;constructor(t){super(t)}static fromAffine(t){return new e(Ll.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static fromBytes(t){Dn(t,32);let{a:r,d:n}=cA,i=Ul,o=F=>bc.create(F),s=uA(t);if(!TB(bc.toBytes(s),t)||fu(s,i))throw new Error("invalid ristretto255 encoding 1");let a=o(s*s),u=o(hu+r*a),l=o(hu-r*a),f=o(u*u),m=o(l*l),p=o(r*n*f-m),{isValid:d,value:v}=cI(o(p*m)),g=o(v*l),y=o(v*g*p),w=o((s+s)*g);fu(w,i)&&(w=o(-w));let E=o(u*y),S=o(w*E);if(!d||fu(S,i)||E===lY)throw new Error("invalid ristretto255 encoding 2");return new e(new Ll(w,E,hu,S))}static fromHex(t){return e.fromBytes(sp(t))}toBytes(){let{X:t,Y:r,Z:n,T:i}=this.ep,o=Ul,s=y=>bc.create(y),a=s(s(n+r)*s(n-r)),u=s(t*r),l=s(u*u),{value:f}=cI(s(a*l)),m=s(f*a),p=s(f*u),d=s(m*p*i),v;if(fu(i*d,o)){let y=s(r*aA),w=s(t*aA);t=y,r=w,v=s(m*gY)}else v=p;fu(t*d,o)&&(r=s(-r));let g=s((n-r)*v);return fu(g,o)&&(g=s(-g)),bc.toBytes(g)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:i,Y:o}=t.ep,s=l=>bc.create(l),a=s(r*o)===s(n*i),u=s(n*o)===s(r*i);return a||u}is0(){return this.equals(e.ZERO)}};Object.freeze(Ac.BASE);Object.freeze(Ac.ZERO);Object.freeze(Ac.prototype);Object.freeze(Ac);var EY=Object.freeze({Point:Ac,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=tA(e,r,64,Wm);return EY.deriveToCurve(n)},hashToScalar(e,t={DST:QB}){let r=tA(e,t.DST,64,Wm);return hI.create(lo(r))},deriveToCurve(e){Dn(e,64);let t=uA(e.subarray(0,32)),r=lI(t),n=uA(e.subarray(32,64)),i=lI(n);return new Ac(r.add(i))}});var dI=!1,bY=!1;async function pI(e,t){if(bY)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();throw r}}async function xg(e,t){return await pI(async()=>{let r=fA(e)?e:await SY(e),n=await crypto.subtle.importKey("raw",t,{name:"X25519"},dI,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:n},r,256))},()=>{if(fA(e))throw new Error("CryptoKey provided but X25519 WebCrypto is not supported");return Pg.scalarMult(e,t)})}async function Np(e){return await pI(async()=>xg(e,Pg.GuBytes),()=>{if(fA(e))throw new Error("CryptoKey provided but X25519 WebCrypto is not supported");return Pg.scalarMultBase(e)})}var AY=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function SY(e){if(e.length!==32)throw new Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...AY,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},dI,["deriveBits"])}function fA(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var ume=P(x(),1);var sme=P(x(),1);var Tg=class{s;transcript=[];buf=new Uint8Array(0);constructor(t){this.s=t.getReader()}async readLine(){let t=[];for(;;){let r=this.buf.indexOf(10);if(r>=0)return t.push(this.buf.subarray(0,r)),this.transcript.push(this.buf.subarray(0,r+1)),this.buf=this.buf.subarray(r+1),_Y(Hl(t));this.buf.length>0&&(t.push(this.buf),this.transcript.push(this.buf));let n=await this.s.read();if(n.done)return this.buf=Hl(t),null;this.buf=n.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:Hl(this.transcript)}}};function _Y(e){return e.forEach(t=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function Hl(e){let t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return r}function Ah(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let n of t)r.enqueue(n)}}))}function Rg(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function hA(e){if(!(e instanceof ReadableStream))throw new Error("readAll expects a ReadableStream");return new Uint8Array(await new Response(e).arrayBuffer())}async function mI(e){if(!(e instanceof ReadableStream))throw new Error("readAllString expects a ReadableStream");return await new Response(e).text()}async function gI(e,t){let r=e.getReader(),n=[],i=0;for(;i")return{next:t};for(let o of r)if(o.length===0)throw Error("invalid stanza");let n=[];for(;;){let o=await e.readLine();if(o===null)throw Error("invalid stanza");let s=ts.decode(o);if(s.length>48)throw Error("invalid stanza");if(n.push(s),s.length<48)break}let i=Hl(n);return{s:new ho(r,i)}}async function vI(e){let t=new Tg(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let n=[];for(;;){let{s:i,next:o}=await DY(t);if(i!==void 0){n.push(i);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=ts.decode(o.slice(4)),{rest:a,transcript:u}=t.close(),l=u.slice(0,u.length-1-o.length+3);return{stanzas:n,headerNoMAC:l,MAC:s,headerSize:u.length,rest:Ah(e,a)}}}function dA(e){let t=[];t.push(`age-encryption.org/v1 `);for(let r of e){t.push("-> "+r.args.join(" ")+` `);for(let n=0;nr.body.length&&(i=r.body.length),t.push(ts.encode(r.body.subarray(n,i))+` `)}r.body.length%48===0&&t.push(` `)}return t.push("---"),new TextEncoder().encode(t.join(""))}function wI(e,t){return Hl([dA(e),new TextEncoder().encode(" "+ts.encode(t)+` `)])}async function qg(e){let t;if(EI(e))t=e;else if(e.startsWith("AGE-SECRET-KEY-PQ-1")){let n=Pi.decodeToBytes(e);if(n.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||n.bytes.length!==32)throw Error("invalid identity");let i=yg.getPublicKey(n.bytes);return Pi.encode("age1pq",Pi.toWords(i),!1)}else{let n=Pi.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||n.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||n.bytes.length!==32)throw Error("invalid identity");t=n.bytes}let r=await Np(t);return Pi.encodeFromBytes("age",r)}var Og=class{recipient;constructor(t){let r=Pi.decodeToBytes(t);if(!t.startsWith("age1pq1")||r.prefix.toLowerCase()!=="age1pq"||r.bytes.length!==1216)throw Error("invalid recipient");this.recipient=r.bytes}wrapFileKey(t){let{cipherText:r,sharedSecret:n}=yg.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:o,nonce:s}=Kg(yI,n,i),a=xi(o,s).encrypt(t);return[new ho(["mlkem768x25519",ts.encode(r)],a)]}},Ng=class{identity;constructor(t){let r=Pi.decodeToBytes(t);if(!t.startsWith("AGE-SECRET-KEY-PQ-1")||r.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||r.bytes.length!==32)throw Error("invalid identity");this.identity=r.bytes}unwrapFileKey(t){for(let r of t){if(r.args.length<1||r.args[0]!=="mlkem768x25519")continue;if(r.args.length!==2)throw Error("invalid mlkem768x25519 stanza");let n=ts.decode(r.args[1]);if(n.length!==1120||r.body.length!==32)throw Error("invalid mlkem768x25519 stanza");let i=yg.decapsulate(n,this.identity),o=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:s,nonce:a}=Kg(yI,i,o);try{return xi(s,a).decrypt(r.body)}catch{continue}}return null}},yI=25722,FY=80,pA=16;function Kg(e,t,r){let n=BY(e),i=kg(n,void 0,"psk_id_hash",new Uint8Array(0)),o=kg(n,void 0,"info_hash",r),s=new Uint8Array(1+i.length+o.length);s[0]=0,s.set(i,1),s.set(o,1+i.length);let a=kg(n,t,"secret",new Uint8Array(0)),u=mA(n,a,"key",s,32),l=mA(n,a,"base_nonce",s,12);return{key:u,nonce:l}}function BY(e){let t=new Uint8Array(10);return t.set(new TextEncoder().encode("HPKE"),0),t[4]=e>>8&255,t[5]=e&255,t[6]=0,t[7]=1,t[8]=0,t[9]=3,t}function kg(e,t,r,n){let i=new Uint8Array(7+e.length+r.length+n.length),o=0;return i.set(new TextEncoder().encode("HPKE-v1"),o),o+=7,i.set(e,o),o+=e.length,i.set(new TextEncoder().encode(r),o),o+=r.length,i.set(n,o),ip(Kr,i,t)}function mA(e,t,r,n,i){let o=new Uint8Array(9+e.length+r.length+n.length),s=0;return o[s]=i>>8&255,o[s+1]=i&255,s+=2,o.set(new TextEncoder().encode("HPKE-v1"),s),s+=7,o.set(e,s),s+=e.length,o.set(new TextEncoder().encode(r),s),s+=r.length,o.set(n,s),jE(Kr,t,o,i)}function IY(e){e.length!==Eh.lengths.publicKeyUncompressed&&(e=Eh.Point.fromBytes(e).toBytes(!1));let t=Eh.utils.randomSecretKey(),r=Eh.getPublicKey(t,!1),n=Eh.getSharedSecret(t,e,!0).subarray(1),i=new Uint8Array(r.length+e.length);i.set(r,0),i.set(e,r.length);let o=new Uint8Array(5);o.set(new TextEncoder().encode("KEM"),0),o[3]=pA>>8,o[4]=pA&255;let s=kg(o,void 0,"eae_prk",n),a=mA(o,s,"shared_secret",i,32);return{encapsulatedKey:r,sharedSecret:a}}var Lg=class{recipient;constructor(t){let r=Pi.decodeToBytes(t);if(!t.startsWith("age1tag1")||r.prefix.toLowerCase()!=="age1tag"||r.bytes.length!==33)throw Error("invalid recipient");this.recipient=r.bytes}wrapFileKey(t){let{encapsulatedKey:r,sharedSecret:n}=IY(this.recipient),i=new TextEncoder().encode("age-encryption.org/p256tag"),o=(()=>{let l=Kr(this.recipient).subarray(0,4),f=new Uint8Array(r.length+l.length);return f.set(r,0),f.set(l,r.length),ip(Kr,f,i).subarray(0,4)})(),{key:s,nonce:a}=Kg(pA,n,i),u=xi(s,a).encrypt(t);return[new ho(["p256tag",ts.encode(o),ts.encode(r)],u)]}},Ug=class{recipient;constructor(t){let r=Pi.decodeToBytes(t);if(!t.startsWith("age1tagpq1")||r.prefix.toLowerCase()!=="age1tagpq"||r.bytes.length!==1249)throw Error("invalid recipient");this.recipient=r.bytes}wrapFileKey(t){let{cipherText:r,sharedSecret:n}=PB.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768p256tag"),o=(()=>{let l=Kr(this.recipient.subarray(1184)).subarray(0,4),f=new Uint8Array(r.length+l.length);return f.set(r,0),f.set(l,r.length),ip(Kr,f,i).subarray(0,4)})(),{key:s,nonce:a}=Kg(FY,n,i),u=xi(s,a).encrypt(t);return[new ho(["mlkem768p256tag",ts.encode(o),ts.encode(r)],u)]}},Hg=class{recipient;constructor(t){let r=Pi.decodeToBytes(t);if(!t.startsWith("age1")||r.prefix.toLowerCase()!=="age"||r.bytes.length!==32)throw Error("invalid recipient");this.recipient=r.bytes}async wrapFileKey(t){let r=sc(32),n=await Np(r),i=await xg(r,this.recipient),o=new Uint8Array(n.length+this.recipient.length);o.set(n),o.set(this.recipient,n.length);let s=new TextEncoder().encode("age-encryption.org/v1/X25519"),a=ic(Kr,i,o,s,32);return[new ho(["X25519",ts.encode(n)],gA(t,a))]}},Lp=class{identity;recipient;constructor(t){if(EI(t)){this.identity=t,this.recipient=Np(t);return}let r=Pi.decodeToBytes(t);if(!t.startsWith("AGE-SECRET-KEY-1")||r.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||r.bytes.length!==32)throw Error("invalid identity");this.identity=r.bytes,this.recipient=Np(r.bytes)}async unwrapFileKey(t){for(let r of t){if(r.args.length<1||r.args[0]!=="X25519")continue;if(r.args.length!==2)throw Error("invalid X25519 stanza");let n=ts.decode(r.args[1]);if(n.length!==32)throw Error("invalid X25519 stanza");let i=await xg(this.identity,n),o=await this.recipient,s=new Uint8Array(n.length+o.length);s.set(n),s.set(o,n.length);let a=new TextEncoder().encode("age-encryption.org/v1/X25519"),u=ic(Kr,i,s,a,32),l=vA(r.body,u);if(l!==null)return l}return null}},Mg=class{passphrase;logN;constructor(t,r){this.passphrase=t,this.logN=r}wrapFileKey(t){let r=sc(16),n="age-encryption.org/v1/scrypt",i=new Uint8Array(n.length+16);i.set(new TextEncoder().encode(n)),i.set(r,n.length);let o=ab(this.passphrase,i,{N:2**this.logN,r:8,p:1,dkLen:32});return[new ho(["scrypt",ts.encode(r),this.logN.toString()],gA(t,o))]}},jg=class{passphrase;constructor(t){this.passphrase=t}unwrapFileKey(t){for(let r of t){if(r.args.length<1||r.args[0]!=="scrypt")continue;if(t.length!==1)throw Error("scrypt recipient is not the only one in the header");if(r.args.length!==3||!/^[1-9][0-9]*$/.test(r.args[2]))throw Error("invalid scrypt stanza");let n=ts.decode(r.args[1]);if(n.length!==16)throw Error("invalid scrypt stanza");let i=Number(r.args[2]);if(i>20)throw Error("scrypt work factor is too high");let o="age-encryption.org/v1/scrypt",s=new Uint8Array(o.length+16);s.set(new TextEncoder().encode(o)),s.set(n,o.length);let a=ab(this.passphrase,s,{N:2**i,r:8,p:1,dkLen:32}),u=vA(r.body,a);if(u!==null)return u}return null}};function gA(e,t){let r=new Uint8Array(12);return xi(t,r).encrypt(e)}function vA(e,t){if(e.length!==32)throw Error("invalid stanza");let r=new Uint8Array(12);try{return xi(t,r).decrypt(e)}catch{return null}}function EI(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var Cme=P(x(),1);var Ml=16,yA=64*1024,wA=yA+Ml;function bI(e){let t=new Uint8Array(12),r=()=>{for(let s=t.length-2;s>=0&&(t[s]++,t[s]===0);s--);},n=!0,i=new Uint8Array(wA),o=0;return new TransformStream({transform(s,a){for(;s.length>0;){if(o===i.length){let l=xi(e,t).decrypt(i);a.enqueue(l),r(),o=0,n=!1}let u=Math.min(i.length-o,s.length);i.set(s.subarray(0,u),o),o+=u,s=s.subarray(u)}},flush(s){t[11]=1;let a=xi(e,t).decrypt(i.subarray(0,o));if(!n&&a.length===0)throw new Error("final chunk is empty");s.enqueue(a)}})}function AI(e){if(e0?Ml:0,n}function SI(e){let t=new Uint8Array(12),r=()=>{for(let o=t.length-2;o>=0&&(t[o]++,t[o]===0);o--);},n=new Uint8Array(yA),i=0;return new TransformStream({transform(o,s){for(;o.length>0;){if(i===n.length){let u=xi(e,t).encrypt(n);s.enqueue(u),r(),i=0}let a=Math.min(n.length-i,o.length);n.set(o.subarray(0,a),i),i+=a,o=o.subarray(a)}},flush(o){t[11]=1;let s=xi(e,t).encrypt(n.subarray(0,i));o.enqueue(s)}})}function CI(e){let t=Math.max(1,Math.ceil(e/yA));return e+Ml*t}var Up={};kO(Up,{decode:()=>PY,encode:()=>$Y});var Fme=P(x(),1);function $Y(e){let t=[];t.push(`-----BEGIN AGE ENCRYPTED FILE----- `);for(let r=0;re.length&&(n=e.length),t.push(sb.encode(e.subarray(r,n))+` `)}return t.push(`-----END AGE ENCRYPTED FILE----- `),t.join("")}function PY(e){let t=e.trim().replaceAll(`\r `,` `).split(` `);if(t.shift()!=="-----BEGIN AGE ENCRYPTED FILE-----")throw Error("invalid header");if(t.pop()!=="-----END AGE ENCRYPTED FILE-----")throw Error("invalid footer");function r(n,i){return n===t.length-1?i.length>0&&i.length<=64&&i.length%4===0:i.length===64}if(!t.every((n,i)=>r(i,n)))throw Error("invalid line length");if(!t.every(n=>/^[A-Za-z0-9+/=]+$/.test(n)))throw Error("invalid base64");return sb.decode(t.join(""))}var Mme=P(x(),1);var Bme=P(x(),1);var Hp=class{passphrase=null;scryptWorkFactor=18;recipients=[];setPassphrase(t){if(this.passphrase!==null)throw new Error("can encrypt to at most one passphrase");if(this.recipients.length!==0)throw new Error("can't encrypt to both recipients and passphrases");this.passphrase=t}setScryptWorkFactor(t){this.scryptWorkFactor=t}addRecipient(t){if(this.passphrase!==null)throw new Error("can't encrypt to both recipients and passphrases");if(typeof t=="string")if(t.startsWith("age1pq1"))this.recipients.push(new Og(t));else if(t.startsWith("age1tag1"))this.recipients.push(new Lg(t));else if(t.startsWith("age1tagpq1"))this.recipients.push(new Ug(t));else if(t.startsWith("age1"))this.recipients.push(new Hg(t));else throw new Error("unrecognized recipient type");else this.recipients.push(t)}async encrypt(t){let r=sc(16),n=[],i=this.recipients;this.passphrase!==null&&(i=[new Mg(this.passphrase,this.scryptWorkFactor)]);for(let d of i)n.push(...await d.wrapFileKey(r));let o=new TextEncoder().encode("header"),s=ic(Kr,r,void 0,o,32),a=Xo(Kr,s,dA(n)),u=wI(n,a),l=sc(16),f=new TextEncoder().encode("payload"),m=ic(Kr,r,l,f,32),p=SI(m);return t instanceof ReadableStream?Object.assign(Ah(t.pipeThrough(p),u,l),{size:d=>CI(d)+u.length+l.length}):(typeof t=="string"&&(t=new TextEncoder().encode(t)),await hA(Ah(Rg(t).pipeThrough(p),u,l)))}},Vg=class{identities=[];addPassphrase(t){this.identities.push(new jg(t))}addIdentity(t){if(NY(t))this.identities.push(new Lp(t));else if(typeof t=="string")if(t.startsWith("AGE-SECRET-KEY-1"))this.identities.push(new Lp(t));else if(t.startsWith("AGE-SECRET-KEY-PQ-1"))this.identities.push(new Ng(t));else throw new Error("unrecognized identity type");else this.identities.push(t)}async decrypt(t,r){let n=t instanceof ReadableStream?t:Rg(t),{fileKey:i,headerSize:o,rest:s}=await this.decryptHeaderInternal(n),{data:a,rest:u}=await gI(s,16),l=new TextEncoder().encode("payload"),f=ic(Kr,i,a,l,32),m=bI(f),p=u.pipeThrough(m),d=Object.assign(p,{size:v=>AI(v-o-a.length)});return t instanceof ReadableStream?d:r==="text"?await mI(p):await hA(p)}async decryptHeader(t){return(await this.decryptHeaderInternal(Rg(t))).fileKey}async decryptHeaderInternal(t){let r=await vI(t),n=await this.unwrapFileKey(r.stanzas);if(n===null)throw Error("no identity matched any of the file's recipients");let i=new TextEncoder().encode("header"),o=ic(Kr,n,void 0,i,32),s=Xo(Kr,o,r.headerNoMAC);if(!OY(r.MAC,s))throw Error("invalid header HMAC");return{fileKey:n,headerSize:r.headerSize,rest:r.rest}}async unwrapFileKey(t){for(let r of this.identities){let n=await r.unwrapFileKey(t);if(n!==null)return n}return null}};function OY(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;ntypeof e?.[i]>"u"),r=e?.crypto;if(r&&typeof r.getRandomValues=="function"||t.push("crypto.getRandomValues"),t.length>0)throw new Error(`\u5F53\u524D\u8FD0\u884C\u73AF\u5883\u7F3A\u5C11 age \u52A0\u89E3\u5BC6\u6240\u9700 Web API: ${t.join(", ")}`);XY(e)}function zg(){return typeof DOMException<"u"?new DOMException("X25519 WebCrypto is not available","NotSupportedError"):new ReferenceError("X25519 WebCrypto is not available")}function zY(){let e={importKey(){throw zg()},deriveBits(){throw zg()}};return e[bA]=!0,e}function GY(e){return typeof e=="string"?e:e?.name}function FI(e){return String(GY(e)||"").toUpperCase()==="X25519"}function YY(e){let t=String(e?.message||e||"");return/x25519|algorithm|not\s+supported|unsupported|unrecognized|unknown/i.test(t)}function BI(e){return e instanceof TypeError||e instanceof ReferenceError||e?.name==="TypeError"||e?.name==="ReferenceError"||e?.name==="NotSupportedError"||e?.name==="Error"&&YY(e)||typeof DOMException<"u"&&e instanceof DOMException&&e.name==="NotSupportedError"}function WY(e){let t=Object.create(e);return Object.defineProperty(t,bA,{configurable:!0,value:!0}),Object.defineProperty(t,"importKey",{configurable:!0,value:async(...r)=>{try{return await e.importKey.apply(e,r)}catch(n){throw FI(r[2])&&BI(n)?zg():n}}}),Object.defineProperty(t,"deriveBits",{configurable:!0,value:async(...r)=>{try{return await e.deriveBits.apply(e,r)}catch(n){throw FI(r[0])&&BI(n)?zg():n}}}),t}function II(e,t,r){try{if(t.subtle=r,t.subtle===r)return!0}catch{}try{if(Object.defineProperty(t,"subtle",{configurable:!0,value:r}),t.subtle===r)return!0}catch{}try{let n=Object.create(t);return Object.defineProperty(n,"subtle",{configurable:!0,value:r}),typeof t.getRandomValues=="function"&&Object.defineProperty(n,"getRandomValues",{configurable:!0,value:t.getRandomValues.bind(t)}),e.crypto=n,e.crypto?.subtle===r}catch{return!1}}function XY(e=globalThis){let t=e?.crypto,r=t?.subtle;if(!(!t||r?.[bA])){if(!r||typeof r.importKey!="function"||typeof r.deriveBits!="function"){II(e,t,zY());return}typeof process>"u"&&II(e,t,WY(r))}}function CA(e){let t=Gg(e);if(!t||!jY(t)&&!qY(t))throw _I();try{new Hp().addRecipient(t)}catch{throw _I()}return t}async function $I(e){let t=Gg(e);if(!t||!KY(t)&&!VY(t))throw DI();try{await qg(t)}catch{throw DI()}return t}async function PI(e){SA();let t=await $I(e),r=await qg(t);return CA(r)}async function Yg(e,t){SA();let r=CA(t),n=new Hp;n.addRecipient(r);let i=await n.encrypt(e??"");return Up.encode(i)}function JY(e){return Gg(e).startsWith(UY)}async function Wg(e,t){let r=e??"",n=typeof r=="string"?r:new TextDecoder().decode(r);if(!JY(n))return r;SA();let i=await $I(t),o=new Vg;o.addIdentity(i);try{let s=Up.decode(n);return await o.decrypt(s,"text")}catch(s){throw new Error(`age \u89E3\u5BC6\u5931\u8D25: ${s?.message??s}`)}}function ZY(e){return String(e??"").replace(MY,t=>`${t.startsWith("AGE-SECRET-KEY-PQ-1")?"AGE-SECRET-KEY-PQ-1":"AGE-SECRET-KEY-1"}...${t.slice(-6)}`)}function Ys(e){return ZY(String(e??"").replace(/([?#&]age-secret-key=)[^&#\s]+/gi,"$1***"))}var QY=".sub-store-placeholder",eW=["Sub-Store placeholder","This file keeps the Gist alive when all sync configuration files are deleted."].join(` `),tW=10;function xI(e){let t=Math.floor(Number(e));return!isFinite(t)||t<=0?tW:t}function rW(){return{filename:QY,content:eW}}async function _A(e,t={}){let{gistToken:r,syncPlatform:n}=z.read(fr);if(!r)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=nW(e);z.info(`\u51C6\u5907\u540C\u6B65 Gist: \u6587\u4EF6\u6570 ${i.count}, \u603B\u5927\u5C0F ${Xg(i.totalBytes)}, \u6700\u5927\u6587\u4EF6 ${i.largestFilename||"-"} (${Xg(i.largestBytes)})`);let o=new wl({token:r,key:$C,syncPlatform:n}),s;try{s=await o.upload(e,{...t,emptyFileFallback:t.emptyFileFallback??rW()})}catch(f){throw z.error(`\u540C\u6B65 Gist \u8BF7\u6C42\u5931\u8D25: \u6587\u4EF6\u6570 ${i.count}, \u603B\u5927\u5C0F ${Xg(i.totalBytes)}, \u6700\u5927\u6587\u4EF6 ${i.largestFilename||"-"} (${Xg(i.largestBytes)}), \u539F\u56E0: ${f.message??f}`),f}let a={};try{a=JSON.parse(s.body)}catch{}let u=a?.html_url??a?.web_url,l=z.read(fr);return u?(z.log(`\u540C\u6B65 Gist \u540E, \u627E\u5230 Sub-Store Gist: ${u}`),l.artifactStore=u,l.artifactStoreStatus="VALID"):(z.error("\u540C\u6B65 Gist \u540E, \u627E\u4E0D\u5230 Sub-Store Gist"),l.artifactStoreStatus="NOT FOUND"),z.write(l,fr),s}function nW(e){return Object.entries(e||{}).reduce((t,[r,n])=>{let i=n?.content;if(typeof i!="string")return t;let o=sW(i);return t.count++,t.totalBytes+=o,o>t.largestBytes&&(t.largestBytes=o,t.largestFilename=r),t},{count:0,totalBytes:0,largestBytes:0,largestFilename:""})}function sW(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}function Xg(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var Age=P(x());var iW=new Set(["enabled","fallbackNotify"]),oW=new Set(["fallbackNotify","fallbackQuiet"]);function Jg(e){return e===!0?"quiet":e===!1||e==null||e===""?"disabled":e}function Sc(...e){for(let t of e)if(t!=null&&t!=="")return Jg(t);return"disabled"}function Sh(e){return iW.has(Jg(e))}function po(e){return oW.has(Jg(e))}function du({mode:e,message:t,notify:r}){let n=Jg(e);if(n==="disabled"||po(n))throw new Error(t);Sh(n)&&r?.(t)}function Cc({mode:e,notify:t,error:r}){Sh(e)&&t?.(r)}function DA({platform:e="JSON",produceType:t,produceOpts:r={}}){return t==="raw"?JSON.stringify([]):Ft.produce([],e,t,r)}var Fge=P(x());function ql(e){if(typeof e!="string"||!e.includes("proxies:")||!e.includes("short-id:"))return e;try{let t=zf(e);if(!Array.isArray(t.proxies)||t.proxies.length===0)return e}catch{return e}return e.replace(/short-id:([ \t]*[^#\n,}]*)/g,(t,r)=>{let n=r.trim();return!n||n===""?'short-id: ""':/^(['"]).*\1$/.test(n)?`short-id: ${n}`:["null"].includes(n)?`short-id: ${n}`:`short-id: "${n}"`})}function aW(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function uW(){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 It.isValid(i)&&!/^\w+:\/\/\w+/im.test(i)&&t.some(o=>i.indexOf(o)!==-1)},parse:function(i){let o=It.decode(i);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(o)?o:(z.error("Base64 Pre-processor error: decoded line does not start with protocol"),i)}}}function cW(){return{name:"Fallback Base64 Pre-processor",test:function(n){return It.isValid(n)},parse:function(n){let i=It.decode(n);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(i)?i:(z.error("Fallback Base64 Pre-processor error: decoded line does not start with protocol"),n)}}}function lW(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let i=zf(n);return Array.isArray(i.proxies)||Array.isArray(i["proxy-groups"])},parse:function(n,i){let o=ql(n),{proxies:s}=zf(o);return(i?`proxies: `:"")+(Array.isArray(s)?s:[]).map(a=>`${i?" - ":""}${JSON.stringify(a)} `).join("")}}}function fW(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let i=[],o=JSON.parse(It.decode(n.split("ssd://")[1])),s=o.port,a=o.encryption,u=o.password,l=o.servers;for(let f=0;ft!=null&&t!=="").join(` `)}function AW(e,t){return t!=null&&t!==""?t:e.ignoreFailedRemoteFile}async function kI({file:e,sourceUrl:t,ua:r,proxy:n,noCache:i,ignoreFailedRemoteFile:o,notifyTitle:s="\u{1F30D} Sub-Store \u5904\u7406\u6587\u4EF6\u5931\u8D25"}){let a={},u=`${t||""}`.split(/[\r\n]+/).map(m=>m.trim()).filter(m=>m.length);if(u.length===0)throw new Error(`\u6587\u4EF6 ${e.name} \u672A\u914D\u7F6E\u8FDC\u7A0B\u6587\u4EF6 URL`);let l=await Promise.all(u.map(async m=>{try{return await Bs(m,r||e.ua,void 0,e.proxy||n,void 0,void 0,i)}catch(p){return a[m]=p,z.error(`\u6587\u4EF6 ${e.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Ys(m)} \u53D1\u751F\u9519\u8BEF: ${p}`),""}})),f=AW(e,o);if(Object.keys(a).length>0)if(f)f==="enabled"&&z.notify(s,`\u274C ${e.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${jp(a)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u6587\u4EF6 ${e.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${jp(a)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);return l}async function t2(e,{url:t,ua:r,content:n,mergeSources:i,ignoreFailedRemoteFile:o,proxy:s,noCache:a,notifyTitle:u}={}){if(n&&!RI(i))return n;if(t){let f=await kI({file:e,sourceUrl:t,ua:r,proxy:s,noCache:a,ignoreFailedRemoteFile:o,notifyTitle:u});return i==="localFirst"?f.unshift(n):i==="remoteFirst"&&f.push(n),f}if(bW(e)==="local"&&!RI(e.mergeSources))return e.content;let l=await kI({file:e,sourceUrl:e.url,ua:r,proxy:s,noCache:a,ignoreFailedRemoteFile:o,notifyTitle:u});return e.mergeSources==="localFirst"?l.unshift(e.content):e.mergeSources==="remoteFirst"&&l.push(e.content),l}async function $A(e,t={}){let r={},n=LI(e);if(n==="none")return Ft.yaml.safeDump(r);if(yW.includes(n)){let i=await t2(e,t);if(e?.mode!=="proxy")return UI(i);let o=e2(i).map(s=>Ft.parse(s)).flat();if(o.length===0)throw new Error(`\u6587\u4EF6 ${e.name} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);r.proxies=Ft.produce(o,"mihomo","internal",{"delete-underscore-fields":!0,"include-unsupported-proxy":e?.includeUnsupportedProxy})}else r.proxies=await Ws({type:n,name:e?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0,"include-unsupported-proxy":e?.includeUnsupportedProxy}});return Ft.yaml.safeDump(r)}async function Ws({type:e,name:t,platform:r,url:n,ua:i,content:o,mergeSources:s,ignoreFailedRemoteSub:a,ignoreFailedRemoteFile:u,produceType:l,produceOpts:f={},subscription:m,file:p,awaitCustomCache:d,$options:v,proxy:g,noCache:y,all:w}){if(r=r||"JSON",["subscription","sub"].includes(e)){let E;if(t){let F=z.read(Kn);if(E=dr(F,t),!E)throw new Error(`\u627E\u4E0D\u5230\u8BA2\u9605 ${t}`)}else if(m)E=m;else throw new Error("\u672A\u63D0\u4F9B\u8BA2\u9605\u540D\u79F0\u6216\u8BA2\u9605\u6570\u636E");let S=Sc(a,E.ignoreFailedRemoteSub);try{let F,_;if(o&&!["localFirst","remoteFirst"].includes(s))F=o,_=o;else if(n){let C={},I=await Promise.all(n.split(/[\r\n]+/).map(L=>L.trim()).filter(L=>L.length).map(async L=>{try{return await Bs(L,i||E.ua,void 0,g||E.proxy,void 0,d,y||E.noCache,!0,{returnRaw:!0})}catch(R){return C[L]=R,z.error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Ys(L)} \u53D1\u751F\u9519\u8BEF: ${R}`),""}}));if(F=I.map(L=>L.result??L),_=I.map(L=>L.raw??L),Object.keys(C).length>0){let L=`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${jp(C)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;du({mode:S,message:L,notify:()=>{z.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,L)}})}s==="localFirst"?(F.unshift(o),_.unshift(o)):s==="remoteFirst"&&(F.push(o),_.push(o))}else if(E.source==="local"&&!["localFirst","remoteFirst"].includes(E.mergeSources))F=E.content,_=E.content;else{let C={},I=await Promise.all(E.url.split(/[\r\n]+/).map(L=>L.trim()).filter(L=>L.length).map(async L=>{try{return await Bs(L,i||E.ua,void 0,g||E.proxy,void 0,d,y||E.noCache,!0,{returnRaw:!0})}catch(R){return C[L]=R,z.error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Ys(L)} \u53D1\u751F\u9519\u8BEF: ${R}`),""}}));if(F=I.map(L=>L.result??L),_=I.map(L=>L.raw??L),Object.keys(C).length>0){let L=`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${jp(C)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;du({mode:S,message:L,notify:()=>{z.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,L)}})}E.mergeSources==="localFirst"?(F.unshift(E.content),_.unshift(E.content)):E.mergeSources==="remoteFirst"&&(F.push(E.content),_.push(E.content))}if(l==="raw")return JSON.stringify((Array.isArray(F)?F:[F]).flat());let H=(Array.isArray(F)?F:[F]).map(C=>Ft.parse(C)).flat();if(H.forEach(C=>{C._subName=E.name,C._subDisplayName=E.displayName}),H=await Ft.process(H,E.process||[],r,{[E.name]:E},v,_),H.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let V={};for(let C of H){if(V[C.name]){z.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${C.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}V[C.name]=!0}return Ft.produce(H,r,l,f)}catch(F){if(!po(S))throw F;return Cc({mode:S,error:F,notify:_=>{z.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,`\u{1F914} \u539F\u56E0\uFF1A${_.message??_}`)}}),z.error(`\u8BA2\u9605 ${E.name} \u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${F.message??F}`),DA({platform:r,produceType:l,produceOpts:f})}}else if(["collection","col"].includes(e)){let E=z.read(Kn),S=z.read(Fi),F=dr(S,t);if(!F)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let _=[...F.subscriptions],H=F.subscriptionTags;Array.isArray(H)&&H.length>0&&E.forEach(C=>{Array.isArray(C.tag)&&C.tag.length>0&&!_.includes(C.name)&&C.tag.some(I=>H.includes(I))&&_.push(C.name)});let V=Sc(a,F.ignoreFailedRemoteSub);try{let C={},I={},L={},R=0;if(await Promise.all(_.map(async N=>{let D=dr(E,N),O=Sc(D.ignoreFailedRemoteSub),q=D.passThroughUA,J=D.ua;q&&(z.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${i}`),J=i);try{z.info(`\u6B63\u5728\u5904\u7406\u5B50\u8BA2\u9605\uFF1A${D.name}...`);let Y,ee;if(D.source==="local"&&!["localFirst","remoteFirst"].includes(D.mergeSources))Y=D.content,ee=D.content;else{let ve={},we=await Promise.all(D.url.split(/[\r\n]+/).map(Pe=>Pe.trim()).filter(Pe=>Pe.length).map(async Pe=>{try{return await Bs(Pe,J,void 0,g||D.proxy||F.proxy,void 0,void 0,y||D.noCache,!0,{returnRaw:!0})}catch(Le){return ve[Pe]=Le,z.error(`\u8BA2\u9605 ${D.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Ys(Pe)} \u53D1\u751F\u9519\u8BEF: ${Le}`),""}}));if(Y=we.map(Pe=>Pe.result??Pe),ee=we.map(Pe=>Pe.raw??Pe),Object.keys(ve).length>0){let Pe=`\u8BA2\u9605 ${D.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${jp(ve)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;du({mode:O,message:Pe,notify:()=>{z.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${D.name}`,Pe)}})}D.mergeSources==="localFirst"?(Y.unshift(D.content),ee.unshift(D.content)):D.mergeSources==="remoteFirst"&&(Y.push(D.content),ee.push(D.content))}let se=(Array.isArray(Y)?Y:[Y]).map(ve=>Ft.parse(ve)).flat();se.forEach(ve=>{ve._subName=D.name,ve._subDisplayName=D.displayName,ve._collectionName=F.name,ve._collectionDisplayName=F.displayName});let le=Array.isArray(ee)?ee:[ee];se=await Ft.process(se,D.process||[],r,{[D.name]:D,_collection:F,$options:v},void 0,le),C[N]=se,L[N]=le,R++,z.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${D.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(R/_.length).toFixed(1)}% `)}catch(Y){if(R++,po(O)){Cc({mode:O,error:Y,notify:ee=>{z.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${D.name}`,`\u{1F914} \u539F\u56E0\uFF1A${ee.message??ee}`)}}),z.error(`\u8BA2\u9605 ${D.name} \u5728\u7EC4\u5408\u8BA2\u9605\u5904\u7406\u4E2D\u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${Y.message??Y}`),C[N]=[],L[N]=[];return}I[N]=Y,L[N]=void 0,z.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u4E2D\u7684\u5B50\u8BA2\u9605: ${D.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${Y}\uFF01\u8FDB\u5EA6--${100*(R/_.length).toFixed(1)}%`)}})),Object.keys(I).length>0){let N=`\u7EC4\u5408\u8BA2\u9605 ${F.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(I).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`,D=()=>{z.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${F.name}`,N)};Object.keys(C).length>0&&po(V)?(Object.keys(I).forEach(q=>{L[q]=[]}),Sh(V)&&D()):du({mode:V,message:N,notify:D})}let k=Array.prototype.concat.apply([],_.map(N=>C[N]||[]));if(k.forEach(N=>{N._collectionName=F.name,N._collectionDisplayName=F.displayName}),k=await Ft.process(k,F.process||[],r,{_collection:F},v,L),k.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let M={};for(let N of k){if(M[N.name]){z.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u7EC4\u5408\u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${N.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[N.name]=!0}return Ft.produce(k,r,l,f)}catch(C){if(!po(V))throw C;return Cc({mode:V,error:C,notify:I=>{z.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${F.name}`,`\u{1F914} \u539F\u56E0\uFF1A${I.message??I}`)}}),z.error(`\u7EC4\u5408\u8BA2\u9605 ${F.name} \u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${C.message??C}`),DA({platform:r,produceType:l,produceOpts:f})}}else if(e==="rule"){let E=z.read(Cd),S=dr(E,t);if(!S)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let F=[];for(let _=0;_0?await Ft.process({$files:_,$content:H,$options:v,$file:S},S.process):{$content:H,$files:_,$options:v};return V.$content=ql(V?.$content??""),(w?V:V?.$content)??""}}function SW(e,t){let r=[];for(let n=0;n[t.path,t]))}:{isGitLab:!1,files:e||{}}}function HI(e){delete e.history,delete e.forks,delete e.owner,e.files&&Object.values(e.files).forEach(t=>{delete t.content}),z.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),z.info(JSON.stringify(e,null,2))}function MI(e,t){let{files:r,isGitLab:n}=CW(e.files),i=encodeURIComponent(t),o=r[i]?.raw_url,s=n?o:o?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");return z.info(`\u4E0A\u4F20\u914D\u7F6E\u5B8C\u6210 \u6587\u4EF6\u5217\u8868: ${Object.keys(r).join(", ")} \u5F53\u524D\u6587\u4EF6: ${i} \u54CD\u5E94\u8FD4\u56DE\u7684\u539F\u59CB\u94FE\u63A5: ${o} \u5904\u7406\u5B8C\u7684\u65B0\u94FE\u63A5: ${s}`),s}function PA(e){return e?.upload!==!1}function _W(e){return e?.source?["subscription","sub"].includes(e.type)?dr(z.read(Kn),e.source):["collection","col"].includes(e.type)?dr(z.read(Fi),e.source):e.type==="file"?dr(z.read(ci),e.source):null:null}async function jI(e){let t=e.platform==="SurgeMac",r=await Ws({type:e.type,name:e.source,platform:e.platform,produceOpts:{"include-unsupported-proxy":e.includeUnsupportedProxy,useMihomoExternal:t,prettyYaml:e.prettyYaml}});return Mp({body:r,configs:[e,_W(e)]})}function DW(e){e.updated=new Date().getTime(),delete e.url}function OI(e,t){let r=z.read(vs),n=dr(r,e);if(!n)return z.info(`\u8FDC\u7A0B\u914D\u7F6E ${e} \u5DF2\u4E0D\u5B58\u5728, \u8DF3\u8FC7\u540C\u6B65\u7ED3\u679C\u5199\u5165`),null;let i=t({...n});return FE(r,e,i),z.write(r,vs),i}async function FW({allArtifacts:e,files:t,valid:r,invalid:n}){let i=z.read(fr)||{},o=xI(i.artifactSyncBatchSize),s=r.filter(l=>{let f=dr(e,l);return f&&PA(f)}),a=SW(s,o),u=[];if(s.length===0)return z.info("\u6CA1\u6709\u9700\u8981\u4E0A\u4F20\u7684\u540C\u6B65\u914D\u7F6E"),u;z.info(`\u51C6\u5907\u5206\u6279\u4E0A\u4F20\u540C\u6B65\u914D\u7F6E: \u5171 ${s.length} \u4E2A, \u6BCF\u6279 ${o} \u4E2A, \u6279\u6B21\u6570 ${a.length}`);for(let l=0;l[encodeURIComponent(p),t[encodeURIComponent(p)]]));try{z.info(`\u6B63\u5728\u4E0A\u4F20\u7B2C ${l+1}/${a.length} \u6279\u540C\u6B65\u914D\u7F6E: ${f.join(", ")}`);let p=await _A(m),d=JSON.parse(p.body);HI(d);for(let v of e)if(v.sync&&v.source&&f.includes(v.name)){let g=MI(d,v.name);g?(v.updated=new Date().getTime(),v.url=g,u.push(v.name)):(z.error(`\u540C\u6B65\u914D\u7F6E ${v.name} \u4E0A\u4F20\u6210\u529F\u4F46\u54CD\u5E94\u4E2D\u672A\u627E\u5230\u6587\u4EF6\u94FE\u63A5`),n.push(v.name))}}catch(p){z.error(`\u7B2C ${l+1}/${a.length} \u6279\u540C\u6B65\u914D\u7F6E\u4E0A\u4F20\u5931\u8D25: ${f.join(", ")}, \u539F\u56E0: ${p.message??p}`),n.push(...f)}}return u}function NI(e,{skipCronArtifacts:t=!1}={}){return e.sync&&e.source&&(!t||FD(e))}async function BW(e={}){z.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");let t=z.read(vs),r={};try{let n=[],i=[],o=[],s=z.read(Kn),a=z.read(Fi),u=[],l=0;if(t.map(p=>{if(NI(p,e)){if(l++,p.type==="subscription"){let d=p.source,v=dr(s,d);v&&v.url&&!u.includes(d)&&u.push(d)}else if(p.type==="collection"){let d=dr(a,p.source);d&&Array.isArray(d.subscriptions)&&d.subscriptions.map(v=>{let g=dr(s,v);g&&g.url&&!u.includes(v)&&u.push(v)})}}}),l===0){z.info(`\u9700\u540C\u6B65\u7684\u914D\u7F6E: ${l}, \u603B\u6570: ${t.length}`);return}u.length>0&&await Promise.all(u.map(async p=>{try{await Ws({type:"subscription",name:p,awaitCustomCache:!0})}catch{}})),await Promise.all(t.map(async p=>{try{if(NI(p,e)){z.info(`\u6B63\u5728\u540C\u6B65\u4E91\u914D\u7F6E\uFF1A${Qa(p)}...`),p.platform==="SurgeMac"&&z.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 mihomo External");let v=await jI(p);PA(p)?(r[encodeURIComponent(p.name)]={content:v},n.push(p.name)):(DW(p),o.push(p.name))}}catch(d){z.error(`\u751F\u6210\u540C\u6B65\u914D\u7F6E ${Qa(p)} \u53D1\u751F\u9519\u8BEF: ${d.message??d}`),i.push(p.name)}}));let f=n.length+o.length;if(z.info(`${f} \u4E2A\u540C\u6B65\u914D\u7F6E\u751F\u6210\u6210\u529F: ${n.concat(o).join(", ")}`),z.info(`${i.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u751F\u6210\u5931\u8D25: ${i.join(", ")}`),o.length>0&&z.info(`${o.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u4EC5\u751F\u6210\u672A\u4E0A\u4F20: ${o.join(", ")}`),f===0)throw new Error(`\u540C\u6B65\u914D\u7F6E ${i.join(", ")} \u751F\u6210\u5931\u8D25 \u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7`);let m=await FW({allArtifacts:t,files:r,valid:n,invalid:i});if(z.write(t,vs),z.info("\u540C\u6B65\u914D\u7F6E\u6267\u884C\u5B8C\u6210"),i.length>0)throw new Error(`\u540C\u6B65\u914D\u7F6E\u6210\u529F ${m.length+o.length} \u4E2A, \u5931\u8D25 ${i.length} \u4E2A, \u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7`);z.info(`\u540C\u6B65\u914D\u7F6E\u6210\u529F ${m.length+o.length} \u4E2A`)}catch(n){throw z.error(`\u540C\u6B65\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${n.message??n}`),n}}async function IW(e,t){z.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");try{await BW(),es(t)}catch(r){z.error(`\u540C\u6B65\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),xr(t,new Ss("FAILED_TO_SYNC_ARTIFACTS","Failed to sync all artifacts",`Reason: ${r.message??r}`))}}async function $W(e){let t=z.read(vs),r=dr(t,e);if(!r)throw z.error(`\u627E\u4E0D\u5230\u8FDC\u7A0B\u914D\u7F6E ${e}`),new Cs("RESOURCE_NOT_FOUND",`\u627E\u4E0D\u5230\u8FDC\u7A0B\u914D\u7F6E ${e}`);if(!r.source)throw z.error(`\u8FDC\u7A0B\u914D\u7F6E ${Qa(r)} \u672A\u8BBE\u7F6E\u6765\u6E90`),new Cs("RESOURCE_HAS_NO_SOURCE",`\u8FDC\u7A0B\u914D\u7F6E ${Qa(r)} \u672A\u8BBE\u7F6E\u6765\u6E90`);z.info(`\u5F00\u59CB\u540C\u6B65\u8FDC\u7A0B\u914D\u7F6E ${Qa(r)}...`),r.platform==="SurgeMac"&&z.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 mihomo External");let i=await jI(r);if(!PA(r)){z.info(`\u914D\u7F6E ${Qa(r)} \u5DF2\u5173\u95ED\u4E0A\u4F20, \u4EC5\u66F4\u65B0\u6267\u884C\u65F6\u95F4`);let f=new Date().getTime(),m=OI(e,d=>(d.updated=f,delete d.url,d));if(m)return m;let p={...r,updated:f};return delete p.url,p}z.info(`\u6B63\u5728\u4E0A\u4F20\u914D\u7F6E\uFF1A${Qa(r)} >>>${JSON.stringify(r,null,2)}`);let o=await _A({[encodeURIComponent(r.name)]:{content:i}}),s=new Date().getTime(),a=JSON.parse(o.body);HI(a);let u=MI(a,r.name);return OI(e,f=>({...f,updated:s,url:u}))||{...r,updated:s,url:u}}async function PW(e,t){let{name:r}=e.params;try{let n=await $W(r);es(t,n)}catch(n){z.error(`\u8FDC\u7A0B\u914D\u7F6E ${r} \u53D1\u751F\u9519\u8BEF: ${n.message??n}`),xr(t,n instanceof Cs?n:new Ss("FAILED_TO_SYNC_ARTIFACT",`Failed to sync artifact ${r}`,`Reason: ${n}`),n instanceof Cs?404:void 0)}}var qI=Zg.find(e=>e.name==="Clash Pre-processor"),xA=new Map;function xW(e=""){let t=`${e}`.trim();return t?new RegExp(t,"i"):null}function TW(e,t,r){if(!t||!r||typeof e!="string"||!/^https?:\/\//i.test(e))return e;let n=`${t}/`;if(e.startsWith(n))return e;let i;try{i=xW(r)}catch(o){return z.error(`GitHub \u52A0\u901F\u4EE3\u7406\u5339\u914D\u6B63\u5219\u65E0\u6548: ${o.message??o}`),e}return i?.test(e)?(z.info(`GitHub \u52A0\u901F\u4EE3\u7406\u547D\u4E2D\u4E0B\u8F7D\u94FE\u63A5: ${e}`),`${t}/${e}`):e}function RW(e){return Ys(e)}async function Ch(e,{ageSecretKey:t,preprocess:r,url:n}){let i=t?await Wg(e,t):e,o=i;if(r)try{qI.test(i)&&(i=qI.parse(i,!0))}catch(s){z.error(`Clash Pre-processor error: ${s}`)}if(r)try{let s=Ft.parse(i);if(!Array.isArray(s)||s.length===0)return{result:i,raw:o,shouldCache:!1,cacheReason:`URL ${n} \u4E0D\u5305\u542B\u6709\u6548\u8282\u70B9, \u4E0D\u7F13\u5B58`}}catch(s){return{result:i,raw:o,shouldCache:!1,cacheReason:`URL ${n} \u5C1D\u8BD5\u89E3\u6790\u8282\u70B9\u5931\u8D25 ${s.message??s}, \u4E0D\u7F13\u5B58`}}return{result:i,raw:o,shouldCache:!0}}function qp(e,t){return t?{result:e.result,raw:e.raw}:e.result}function TA(e,t){return t?{result:e,raw:e}:e}async function Bs(rawUrl="",ua,timeout,customProxy,skipCustomCache,awaitCustomCache,noCache,preprocess,options={}){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 explicitAgeSecretKey=options&&typeof options=="object"?options?.[EA]||options?.ageSecretKey:void 0,returnRaw=options&&typeof options=="object"&&options.returnRaw,ageSecretKey=explicitAgeSecretKey||$arguments?.[EA],{isNode,isStash,isLoon,isShadowRocket,isQX}=ws(),{githubProxy,githubProxyRegex,defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=z.read(fr),cacheThreshold=defaultCacheThreshold||1024,proxy=customProxy||defaultProxy;z.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultUserAgent||"clash.meta/v1.19.29",customHeaders;if($arguments?.headers)try{let e=JSON.parse($arguments?.headers);if(e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0){let t={"user-agent":userAgent};for(let r in e)t[r.toLowerCase()]=e[r];customHeaders=t}}catch(e){z.error(`\u89E3\u6790\u81EA\u5B9A\u4E49 headers \u5931\u8D25: ${e}`)}let requestTimeout=timeout||defaultTimeout||8e3;url=TW(url,githubProxy,githubProxyRegex);let safeUrl=RW(url),id=en(`${customHeaders?JSON.stringify(customHeaders):userAgent}${url}`);$arguments?.cacheKey===!0&&(z.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=z.read(customCacheKey),t=tn.get(id);if(!noCache&&!$arguments?.noCache&&t)return z.info(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u5B58\u5728\u6709\u6548\u7684\u5E38\u89C4\u7F13\u5B58 \u4F7F\u7528\u5E38\u89C4\u7F13\u5B58\u4EE5\u907F\u514D\u91CD\u590D\u8BF7\u6C42`),qp(await Ch(t,{ageSecretKey,preprocess,url:safeUrl}),returnRaw);if(e){if(awaitCustomCache){z.info(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u672C\u6B21\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u66F4\u65B0\u7F13\u5B58`);try{await Bs(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess)}catch(r){z.error(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`),z.info("\u4F7F\u7528\u4E50\u89C2\u7F13\u5B58\u7684\u6570\u636E\u5237\u65B0\u7F13\u5B58, \u9632\u6B62\u540E\u7EED\u8BF7\u6C42"),tn.set(id,e)}}else z.info(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u672C\u6B21\u8FD4\u56DE\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey} \u5E76\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u5F02\u6B65\u66F4\u65B0\u7F13\u5B58`),Bs(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess).catch(r=>{z.error(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u5F02\u6B65\u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`)});return qp(await Ch(e,{ageSecretKey,preprocess,url:safeUrl}),returnRaw)}}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"?y1:ci,n=dr(z.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);return TA(e==="module"?n.content:await Ws({type:"file",name:t}),returnRaw)}catch(t){throw z.error(`Error when loading ${e}: ${url.split("#")[0]}. Reason: ${t}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${e}: ${url}`)}}else if(url?.startsWith("/"))try{let fs=eval('require("fs")');return TA(fs.readFileSync(url.split("#")[0],"utf8"),returnRaw)}catch(e){throw z.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&&xA.has(id))return qp(await Ch(await xA.get(id),{ageSecretKey,preprocess,url:safeUrl}),returnRaw);let http=Yi({headers:{...customHeaders||{"User-Agent":userAgent},...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,rawResult,cached=tn.get(id);if(!noCache&&!$arguments?.noCache&&cached)z.info(`\u4F7F\u7528\u7F13\u5B58: ${safeUrl}, ${customHeaders?JSON.stringify(customHeaders):userAgent}`),rawResult=cached,result=await Ch(cached,{ageSecretKey,preprocess,url:safeUrl}),customCacheKey&&(z.info(`URL ${safeUrl} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),z.write(cached,customCacheKey));else{let e=$arguments?.insecure?isNode?{strictSSL:!1}:{insecure:!0}:void 0;z.info(`Downloading... ${customHeaders?JSON.stringify(customHeaders):`User-Agent: ${userAgent}`} Timeout: ${requestTimeout} Proxy: ${proxy} Insecure: ${!!e} Preprocess: ${preprocess} URL: ${safeUrl}`);try{let{body:t,headers:r,statusCode:n}=await Jf(()=>http.get({url,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?Za(proxy):{},...e||{}}),"download");if(z.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let o=vl(r);o&&tp.set(id,o,$arguments?.headersCacheTtl?$arguments?.headersCacheTtl*1e3:void 0)}if(t.replace(/\s/g,"").length===0)throw new Error(new Error("\u8FDC\u7A0B\u8D44\u6E90\u5185\u5BB9\u4E3A\u7A7A"));result=await Ch(t,{ageSecretKey,preprocess,url:safeUrl});let i=!0;if(cacheThreshold){let o=t.length/1024;o>cacheThreshold&&(z.info(`\u8D44\u6E90\u5927\u5C0F ${o.toFixed(2)} KB \u8D85\u8FC7\u4E86 ${cacheThreshold} KB, \u4E0D\u7F13\u5B58`),i=!1)}result.shouldCache||(z.error(result.cacheReason),i=!1),i&&(tn.set(id,t,$arguments?.cacheTtl?$arguments?.cacheTtl*1e3:void 0),customCacheKey&&(z.info(`URL ${safeUrl} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),z.write(t,customCacheKey))),rawResult=t}catch(t){if(customCacheKey){let n=z.read(customCacheKey);if(n)return z.info(`\u65E0\u6CD5\u4E0B\u8F7D URL ${safeUrl}: ${t.message??t} \u4F7F\u7528\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),qp(await Ch(n,{ageSecretKey,preprocess,url:safeUrl}),returnRaw)}let r=`\u65E0\u6CD5\u4E0B\u8F7D URL ${safeUrl}: ${t.message??t}`;throw z.error(r),new Error(r)}}return $arguments?.validCheck&&await Hm(Zf(await Wo(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl,$arguments.flowHeaders))),isNode||xA.set(id,rawResult),qp(result,returnRaw)}async function KI(url,file){let undici=eval("require('undici')"),fs=eval("require('fs')"),{pipeline}=eval("require('stream/promises')"),{Agent,interceptors,request}=undici;z.info(`Downloading file... URL: ${url} File: ${file}`);let{body,statusCode}=await request(url,{dispatcher:new Agent().compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirect:!0}))});if(statusCode!==200)throw new Error(`Failed to download file from ${url}`);let fileStream=fs.createWriteStream(file);return await pipeline(body,fileStream),z.info(`File downloaded from ${url} to ${file}`),file}var ive=P(x());var m2e=P(x());var kA=class{constructor(){z.read(al)||z.write("{}",al);try{this.resourceCache=JSON.parse(z.read(al))}catch(t){z.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${al} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},z.write("{}",al)}this._cleanup()}_cleanup(t,r){let n=RA(r)??0,i=!1,o=Date.now();Object.entries(this.resourceCache).forEach(s=>{let[a,u]=s;(!u.time||u.time0?t:null}function OW(){let t=z.read(fr)?.scriptCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:1728e5}var OA=new kA;var v2e=P(x());function r2(e,t){return[...Array(e).keys()].map(()=>t)}var E2e=P(x());var NA={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["EXP","BAND"],"\u{1F1F8}\u{1F1F1}":["TEST","SOS"],"\u{1F1F2}\u{1F1F5}":["MP","MNP"],"\u{1F1F8}\u{1F1F4}":["SO","SOM"],"\u{1F1E6}\u{1F1F6}":["AQ","ATA"],"\u{1F1E6}\u{1F1EC}":["AG","ATG"],"\u{1F1EC}\u{1F1F1}":["GL","GRL"],"\u{1F1FF}\u{1F1FC}":["ZW","ZWE"],"\u{1F1E6}\u{1F1FC}":["AW","ABW"],"\u{1F1F2}\u{1F1F1}":["ML","MLI"],"\u{1F1E6}\u{1F1E9}":["AD","AND"],"\u{1F1E6}\u{1F1EA}":["AE","ARE"],"\u{1F1E6}\u{1F1EB}":["AF","AFG"],"\u{1F1E6}\u{1F1F1}":["AL","ALB"],"\u{1F1E6}\u{1F1F2}":["AM","ARM"],"\u{1F1E6}\u{1F1F7}":["AR","ARG"],"\u{1F1E6}\u{1F1F9}":["AT","AUT"],"\u{1F1E6}\u{1F1FA}":["AU","AUS"],"\u{1F1E6}\u{1F1FF}":["AZ","AZE"],"\u{1F1E7}\u{1F1E6}":["BA","BIH"],"\u{1F1E7}\u{1F1E9}":["BD","BGD"],"\u{1F1E7}\u{1F1EA}":["BE","BEL"],"\u{1F1E7}\u{1F1EC}":["BG","BGR"],"\u{1F1E7}\u{1F1ED}":["BH","BHR"],"\u{1F1E7}\u{1F1F4}":["BO","BOL"],"\u{1F1E7}\u{1F1F3}":["BN","BRN"],"\u{1F1E7}\u{1F1F7}":["BR","BRA"],"\u{1F1E7}\u{1F1F9}":["BT","BTN"],"\u{1F1E7}\u{1F1FE}":["BY","BLR"],"\u{1F1E8}\u{1F1E6}":["CA","CAN"],"\u{1F1E8}\u{1F1EB}":["CF","CAF"],"\u{1F1E8}\u{1F1ED}":["CH","CHE"],"\u{1F1E8}\u{1F1F1}":["CL","CHL"],"\u{1F1E8}\u{1F1F4}":["CO","COL"],"\u{1F1E8}\u{1F1F7}":["CR","CRI"],"\u{1F1E8}\u{1F1FE}":["CY","CYP"],"\u{1F1E8}\u{1F1FF}":["CZ","CZE"],"\u{1F1E9}\u{1F1EA}":["DE","DEU"],"\u{1F1E9}\u{1F1F0}":["DK","DNK"],"\u{1F1E9}\u{1F1FF}":["DZ","DZA"],"\u{1F1EA}\u{1F1E8}":["EC","ECU"],"\u{1F1EA}\u{1F1EA}":["EE","EST"],"\u{1F1EA}\u{1F1EC}":["EG","EGY"],"\u{1F1EA}\u{1F1F8}":["ES","ESP"],"\u{1F1EA}\u{1F1FA}":["EU"],"\u{1F1EB}\u{1F1EE}":["FI","FIN"],"\u{1F1EB}\u{1F1F7}":["FR","FRA"],"\u{1F1EC}\u{1F1E7}":["GB","GBR","UK"],"\u{1F1EC}\u{1F1EA}":["GE","GEO"],"\u{1F1EC}\u{1F1F7}":["GR","GRC"],"\u{1F1EC}\u{1F1F9}":["GT","GTM"],"\u{1F1EC}\u{1F1FA}":["GU","GUM"],"\u{1F1ED}\u{1F1F0}":["HK","HKG","HKT","HKBN","HGC","WTT","CMI"],"\u{1F1ED}\u{1F1F7}":["HR","HRV"],"\u{1F1ED}\u{1F1FA}":["HU","HUN"],"\u{1F1EE}\u{1F1F6}":["IQ","IRQ"],"\u{1F1EF}\u{1F1F4}":["JO","JOR"],"\u{1F1EF}\u{1F1F5}":["JP","JPN","TYO"],"\u{1F1F0}\u{1F1EA}":["KE","KEN"],"\u{1F1F0}\u{1F1EC}":["KG","KGZ"],"\u{1F1F0}\u{1F1ED}":["KH","KGZ"],"\u{1F1F0}\u{1F1F5}":["KP","PRK"],"\u{1F1F0}\u{1F1F7}":["KR","KOR","SEL"],"\u{1F1F0}\u{1F1FF}":["KZ","KAZ"],"\u{1F1EE}\u{1F1E9}":["ID","IDN"],"\u{1F1EE}\u{1F1EA}":["IE","IRL"],"\u{1F1EE}\u{1F1F1}":["IL","ISR"],"\u{1F1EE}\u{1F1F2}":["IM","IMN"],"\u{1F1EE}\u{1F1F3}":["IN","IND"],"\u{1F1EE}\u{1F1F7}":["IR","IRN"],"\u{1F1EE}\u{1F1F8}":["IS","ISL"],"\u{1F1EE}\u{1F1F9}":["IT","ITA"],"\u{1F1F1}\u{1F1E6}":["LA","LAO"],"\u{1F1F1}\u{1F1F0}":["LK","LKA"],"\u{1F1F1}\u{1F1F8}":["LS","LSO"],"\u{1F1F1}\u{1F1F9}":["LT","LTU"],"\u{1F1F1}\u{1F1FA}":["LU","LUX"],"\u{1F1F1}\u{1F1FB}":["LV","LVA"],"\u{1F1F2}\u{1F1E6}":["MA","MAR"],"\u{1F1F2}\u{1F1E9}":["MD","MDA"],"\u{1F1F3}\u{1F1EC}":["NG","NGA"],"\u{1F1F2}\u{1F1F2}":["MM","MMR"],"\u{1F1F2}\u{1F1F0}":["MK","MKD"],"\u{1F1F2}\u{1F1F3}":["MN","MNG"],"\u{1F1F2}\u{1F1F4}":["MO","MAC","CTM"],"\u{1F1F2}\u{1F1F9}":["MT","MLT"],"\u{1F1F2}\u{1F1FD}":["MX","MEX"],"\u{1F1F2}\u{1F1FE}":["MY","MYS"],"\u{1F1F3}\u{1F1F1}":["NL","NLD","AMS"],"\u{1F1F3}\u{1F1F4}":["NO","NOR"],"\u{1F1F3}\u{1F1F5}":["NP","NPL"],"\u{1F1F3}\u{1F1FF}":["NZ","NZL"],"\u{1F1F4}\u{1F1F2}":["OM","OMN"],"\u{1F1F5}\u{1F1E6}":["PA","PAN"],"\u{1F1F5}\u{1F1EA}":["PE","PER"],"\u{1F1F5}\u{1F1ED}":["PH","PHL"],"\u{1F1F5}\u{1F1F0}":["PK","PAK"],"\u{1F1F5}\u{1F1F1}":["PL","POL"],"\u{1F1F5}\u{1F1F7}":["PR","PRI"],"\u{1F1F5}\u{1F1F9}":["PT","PRT"],"\u{1F1F5}\u{1F1FE}":["PY","PRY"],"\u{1F1F5}\u{1F1EC}":["PG","PNG"],"\u{1F1F6}\u{1F1E6}":["QA","QAT"],"\u{1F1F7}\u{1F1F4}":["RO","ROU"],"\u{1F1F7}\u{1F1F8}":["RS","SRB"],"\u{1F1F7}\u{1F1EA}":["RE","REU"],"\u{1F1F7}\u{1F1FA}":["RU","RUS"],"\u{1F1F8}\u{1F1E6}":["SA","SAU"],"\u{1F1FC}\u{1F1F8}":["WS","WSM"],"\u{1F1F8}\u{1F1EA}":["SE","SWE"],"\u{1F1F8}\u{1F1EC}":["SG","SGP"],"\u{1F1F8}\u{1F1EE}":["SI","SVN"],"\u{1F1F8}\u{1F1F0}":["SK","SVK"],"\u{1F1F9}\u{1F1EC}":["TG","TGO"],"\u{1F1F9}\u{1F1ED}":["TH","THA"],"\u{1F1F9}\u{1F1F3}":["TN","TUN"],"\u{1F1F9}\u{1F1F7}":["TR","TUR"],"\u{1F1F9}\u{1F1FC}":["TW","TWN","CHT","HINET","ROC"],"\u{1F1FA}\u{1F1E6}":["UA","UKR"],"\u{1F1FA}\u{1F1F8}":["US","USA","LAX","SFO","SJC"],"\u{1F1FA}\u{1F1FE}":["UY","URY"],"\u{1F1FB}\u{1F1E6}":["VA","VAT"],"\u{1F1FB}\u{1F1EA}":["VE","VEN"],"\u{1F1FB}\u{1F1F3}":["VN","VNM"],"\u{1F1FF}\u{1F1E6}":["ZA","ZAF","JNB"],"\u{1F1E8}\u{1F1F3}":["CN","CHN","BACK"]};function _h(e){let t={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["\u6D41\u91CF","\u65F6\u95F4","\u8FC7\u671F","Bandwidth","Expire"],"\u{1F1F8}\u{1F1F1}":["\u5E94\u6025","\u6D4B\u8BD5\u8282\u70B9"],"\u{1F1F2}\u{1F1F5}":["\u5317\u9A6C\u91CC\u4E9A\u7EB3","Northern Mariana Islands","Saipan","\u585E\u73ED"],"\u{1F1F8}\u{1F1F4}":["Somalia","\u7D22\u9A6C\u91CC","\u6469\u52A0\u8FEA\u6C99","Mogadishu"],"\u{1F1E6}\u{1F1F6}":["Antarctica","\u5357\u6781\u6D32","\u5357\u6781"],"\u{1F1E6}\u{1F1EC}":["Antigua and Barbuda","\u5B89\u63D0\u74DC\u548C\u5DF4\u5E03\u8FBE"],"\u{1F1EC}\u{1F1F1}":["Greenland","\u683C\u9675\u5170\u5C9B","\u683C\u9675\u5170"],"\u{1F1FF}\u{1F1FC}":["Zimbabwe","\u6D25\u5DF4\u5E03\u97E6"],"\u{1F1E6}\u{1F1FC}":["Aruba","\u963F\u9C81\u5DF4"],"\u{1F1F2}\u{1F1F1}":["Mali","\u9A6C\u91CC"],"\u{1F1E6}\u{1F1E9}":["Andorra","\u5B89\u9053\u5C14"],"\u{1F1E6}\u{1F1EA}":["United Arab Emirates","\u963F\u8054\u914B","\u8FEA\u62DC","Dubai"],"\u{1F1E6}\u{1F1EB}":["Afghanistan","\u963F\u5BCC\u6C57"],"\u{1F1E6}\u{1F1F1}":["Albania","\u963F\u5C14\u5DF4\u5C3C\u4E9A","\u963F\u723E\u5DF4\u5C3C\u4E9E"],"\u{1F1E6}\u{1F1F2}":["Armenia","\u4E9A\u7F8E\u5C3C\u4E9A"],"\u{1F1E6}\u{1F1F7}":["Argentina","\u963F\u6839\u5EF7"],"\u{1F1E6}\u{1F1F9}":["Austria","\u5965\u5730\u5229","\u5967\u5730\u5229","\u7EF4\u4E5F\u7EB3"],"\u{1F1FC}\u{1F1F8}":["Samoa","\u8428\u6469\u4E9A","\u85A9\u6469\u4E9E"],"\u{1F1E6}\u{1F1FA}":["Australia","\u6FB3\u5927\u5229\u4E9A","\u6FB3\u6D32","\u58A8\u5C14\u672C","\u6089\u5C3C","\u571F\u6FB3","\u4EAC\u6FB3","\u5EE3\u6FB3","\u6EEC\u6FB3","\u6CAA\u6FB3","\u5E7F\u6FB3","Sydney"],"\u{1F1E6}\u{1F1FF}":["Azerbaijan","\u963F\u585E\u62DC\u7586"],"\u{1F1E7}\u{1F1E6}":["Bosnia and Herzegovina","\u6CE2\u9ED1\u5171\u548C\u56FD","\u6CE2\u9ED1"],"\u{1F1E7}\u{1F1E9}":["Bangladesh","\u5B5F\u52A0\u62C9\u56FD","\u5B5F\u52A0\u62C9"],"\u{1F1E7}\u{1F1EA}":["Belgium","\u6BD4\u5229\u65F6","\u6BD4\u5229\u6642"],"\u{1F1E7}\u{1F1EC}":["Bulgaria","\u4FDD\u52A0\u5229\u4E9A","\u4FDD\u52A0\u5229\u4E9E"],"\u{1F1E7}\u{1F1ED}":["Bahrain","\u5DF4\u6797"],"\u{1F1E7}\u{1F1F7}":["Brazil","\u5DF4\u897F","\u5723\u4FDD\u7F57"],"\u{1F1E7}\u{1F1F3}":["Brunei","\u6587\u83B1","\u6C76\u840A"],"\u{1F1E7}\u{1F1FE}":["Belarus","\u767D\u4FC4\u7F57\u65AF","\u767D\u4FC4"],"\u{1F1E7}\u{1F1F4}":["Bolivia","\u73BB\u5229\u7EF4\u4E9A"],"\u{1F1E7}\u{1F1F9}":["Bhutan","\u4E0D\u4E39","\u4E0D\u4E39\u738B\u56FD"],"\u{1F1E8}\u{1F1E6}":["Canada","\u52A0\u62FF\u5927","\u8499\u7279\u5229\u5C14","\u6E29\u54E5\u534E","\u6953\u8449","\u67AB\u53F6","\u6ED1\u94C1\u5362","\u591A\u4F26\u591A","Waterloo","Toronto"],"\u{1F1E8}\u{1F1EB}":["Central African Republic","\u4E2D\u975E\u5171\u548C\u56FD","\u4E2D\u975E"],"\u{1F1E8}\u{1F1ED}":["Switzerland","\u745E\u58EB","\u82CF\u9ECE\u4E16","Zurich"],"\u{1F1E8}\u{1F1F1}":["Chile","\u667A\u5229"],"\u{1F1E8}\u{1F1F4}":["Colombia","\u54E5\u4F26\u6BD4\u4E9A"],"\u{1F1E8}\u{1F1F7}":["Costa Rica","\u54E5\u65AF\u8FBE\u9ECE\u52A0"],"\u{1F1E8}\u{1F1FE}":["Cyprus","\u585E\u6D66\u8DEF\u65AF"],"\u{1F1E8}\u{1F1FF}":["Czechia","\u6377\u514B","Czech","Czech Republic"],"\u{1F1E9}\u{1F1EA}":["German","\u5FB7\u56FD","\u5FB7\u570B","\u4EAC\u5FB7","\u6EEC\u5FB7","\u5EE3\u5FB7","\u6CAA\u5FB7","\u5E7F\u5FB7","\u6CD5\u5170\u514B\u798F","Frankfurt","\u5FB7\u610F\u5FD7"],"\u{1F1E9}\u{1F1F0}":["Denmark","\u4E39\u9EA6","\u4E39\u9EA5"],"\u{1F1E9}\u{1F1FF}":["Algeria","\u963F\u5C14\u53CA\u5229\u4E9A","\u963F\u723E\u53CA\u5229\u4E9E"],"\u{1F1EA}\u{1F1E8}":["Ecuador","\u5384\u74DC\u591A\u5C14"],"\u{1F1EA}\u{1F1EA}":["Estonia","\u7231\u6C99\u5C3C\u4E9A"],"\u{1F1EA}\u{1F1EC}":["Egypt","\u57C3\u53CA"],"\u{1F1EA}\u{1F1F8}":["Spain","\u897F\u73ED\u7259"],"\u{1F1EA}\u{1F1FA}":["European Union","\u6B27\u76DF","\u6B27\u7F57\u5DF4"],"\u{1F1EB}\u{1F1EE}":["Finland","\u82AC\u5170","\u82AC\u862D","\u8D6B\u5C14\u8F9B\u57FA"],"\u{1F1EB}\u{1F1F7}":["France","\u6CD5\u56FD","\u6CD5\u570B","\u5DF4\u9ECE"],"\u{1F1EC}\u{1F1E7}":["Great Britain","\u82F1\u56FD","England","United Kingdom","\u4F26\u6566","\u82F1","London"],"\u{1F1EC}\u{1F1EA}":["Georgia","\u683C\u9C81\u5409\u4E9A","\u683C\u9B6F\u5409\u4E9E"],"\u{1F1EC}\u{1F1F7}":["Greece","\u5E0C\u814A","\u5E0C\u81D8"],"\u{1F1EC}\u{1F1FA}":["Guam","\u5173\u5C9B","\u95DC\u5CF6"],"\u{1F1EC}\u{1F1F9}":["Guatemala","\u5371\u5730\u9A6C\u62C9"],"\u{1F1ED}\u{1F1F0}":["Hongkong","\u9999\u6E2F","Hong Kong","HongKong","HONG KONG","\u6DF1\u6E2F","\u6CAA\u6E2F","\u547C\u6E2F","\u7A57\u6E2F","\u4EAC\u6E2F","\u6E2F"],"\u{1F1ED}\u{1F1F7}":["Croatia","\u514B\u7F57\u5730\u4E9A","\u514B\u7F85\u5730\u4E9E"],"\u{1F1ED}\u{1F1FA}":["Hungary","\u5308\u7259\u5229"],"\u{1F1EE}\u{1F1F6}":["Iraq","\u4F0A\u62C9\u514B","\u5DF4\u683C\u8FBE","Baghdad"],"\u{1F1EF}\u{1F1F4}":["Jordan","\u7EA6\u65E6"],"\u{1F1EF}\u{1F1F5}":["Japan","\u65E5\u672C","\u4E1C\u4EAC","\u5927\u962A","\u57FC\u7389","\u6CAA\u65E5","\u7A57\u65E5","\u5DDD\u65E5","\u4E2D\u65E5","\u6CC9\u65E5","\u676D\u65E5","\u6DF1\u65E5","\u8FBD\u65E5","\u5E7F\u65E5","\u5927\u5742","Osaka","Tokyo"],"\u{1F1F0}\u{1F1EA}":["Kenya","\u80AF\u5C3C\u4E9A"],"\u{1F1F0}\u{1F1EC}":["Kyrgyzstan","\u5409\u5C14\u5409\u65AF\u65AF\u5766"],"\u{1F1F0}\u{1F1ED}":["Cambodia","\u67EC\u57D4\u5BE8"],"\u{1F1F0}\u{1F1F5}":["North Korea","\u671D\u9C9C"],"\u{1F1F0}\u{1F1F7}":["Korea","\u97E9\u56FD","\u97D3\u570B","\u97E9","\u97D3","\u9996\u5C14","\u6625\u5DDD","Chuncheon","Seoul"],"\u{1F1F0}\u{1F1FF}":["Kazakhstan","\u54C8\u8428\u514B\u65AF\u5766","\u54C8\u8428\u514B"],"\u{1F1EE}\u{1F1E9}":["Indonesia","\u5370\u5C3C","\u5370\u5EA6\u5C3C\u897F\u4E9A","\u96C5\u52A0\u8FBE"],"\u{1F1EE}\u{1F1EA}":["Ireland","\u7231\u5C14\u5170","\u611B\u723E\u862D","\u90FD\u67CF\u6797"],"\u{1F1EE}\u{1F1F1}":["Israel","\u4EE5\u8272\u5217"],"\u{1F1EE}\u{1F1F2}":["Isle of Man","\u9A6C\u6069\u5C9B","\u99AC\u6069\u5CF6"],"\u{1F1EE}\u{1F1F3}":["India","\u5370\u5EA6","\u5B5F\u4E70","MFumbai","Mumbai"],"\u{1F1EE}\u{1F1F7}":["Iran","\u4F0A\u6717"],"\u{1F1EE}\u{1F1F8}":["Iceland","\u51B0\u5C9B","\u51B0\u5CF6"],"\u{1F1EE}\u{1F1F9}":["Italy","\u610F\u5927\u5229","\u7FA9\u5927\u5229","\u7C73\u5170","Nachash"],"\u{1F1F1}\u{1F1F0}":["Sri Lanka","\u65AF\u91CC\u5170\u5361","\u65AF\u91CC\u862D\u5361"],"\u{1F1F1}\u{1F1E6}":["Laos","\u8001\u631D","\u8001\u64BE"],"\u{1F1F1}\u{1F1F8}":["Lesotho","\u83B1\u7D22\u6258"],"\u{1F1F1}\u{1F1F9}":["Lithuania","\u7ACB\u9676\u5B9B"],"\u{1F1F1}\u{1F1FA}":["Luxembourg","\u5362\u68EE\u5821"],"\u{1F1F1}\u{1F1FB}":["Latvia","\u62C9\u8131\u7EF4\u4E9A","Latvija"],"\u{1F1F2}\u{1F1E6}":["Morocco","\u6469\u6D1B\u54E5"],"\u{1F1F2}\u{1F1E9}":["Moldova","\u6469\u5C14\u591A\u74E6","\u6469\u723E\u591A\u74E6"],"\u{1F1F2}\u{1F1F2}":["Myanmar","\u7F05\u7538","\u7DEC\u7538"],"\u{1F1F3}\u{1F1EC}":["Nigeria","\u5C3C\u65E5\u5229\u4E9A","\u5C3C\u65E5\u5229\u4E9E"],"\u{1F1F2}\u{1F1F0}":["Macedonia","\u9A6C\u5176\u987F","\u99AC\u5176\u9813"],"\u{1F1F2}\u{1F1F3}":["Mongolia","\u8499\u53E4"],"\u{1F1F2}\u{1F1F4}":["Macao","\u6FB3\u95E8","\u6FB3\u9580","CTM"],"\u{1F1F2}\u{1F1F9}":["Malta","\u9A6C\u8033\u4ED6"],"\u{1F1F2}\u{1F1FD}":["Mexico","\u58A8\u897F\u54E5"],"\u{1F1F2}\u{1F1FE}":["Malaysia","\u9A6C\u6765","\u99AC\u4F86","\u5409\u9686\u5761","\u5927\u99AC"],"\u{1F1F3}\u{1F1F1}":["Netherlands","\u8377\u5170","\u8377\u862D","\u5C3C\u5FB7\u862D","\u963F\u59C6\u65AF\u7279\u4E39","Amsterdam"],"\u{1F1F3}\u{1F1F4}":["Norway","\u632A\u5A01"],"\u{1F1F3}\u{1F1F5}":["Nepal","\u5C3C\u6CCA\u5C14"],"\u{1F1F3}\u{1F1FF}":["New Zealand","\u65B0\u897F\u5170","\u65B0\u897F\u862D"],"\u{1F1F4}\u{1F1F2}":["Oman","\u963F\u66FC","\u9A6C\u65AF\u5580\u7279"],"\u{1F1F5}\u{1F1E6}":["Panama","\u5DF4\u62FF\u9A6C"],"\u{1F1F5}\u{1F1EA}":["Peru","\u79D8\u9C81","\u7955\u9B6F"],"\u{1F1F5}\u{1F1ED}":["Philippines","\u83F2\u5F8B\u5BBE","\u83F2\u5F8B\u8CD3"],"\u{1F1F5}\u{1F1F0}":["Pakistan","\u5DF4\u57FA\u65AF\u5766"],"\u{1F1F5}\u{1F1F1}":["Poland","\u6CE2\u5170","\u6CE2\u862D","\u534E\u6C99","Warsaw"],"\u{1F1F5}\u{1F1F7}":["Puerto Rico","\u6CE2\u591A\u9ECE\u5404"],"\u{1F1F5}\u{1F1F9}":["Portugal","\u8461\u8404\u7259"],"\u{1F1F5}\u{1F1EC}":["Papua New Guinea","\u5DF4\u5E03\u4E9A\u65B0\u51E0\u5185\u4E9A"],"\u{1F1F5}\u{1F1FE}":["Paraguay","\u5DF4\u62C9\u572D"],"\u{1F1F6}\u{1F1E6}":["Qatar","\u5361\u5854\u5C14","\u5361\u5854\u723E"],"\u{1F1F7}\u{1F1F4}":["Romania","\u7F57\u9A6C\u5C3C\u4E9A"],"\u{1F1F7}\u{1F1F8}":["Serbia","\u585E\u5C14\u7EF4\u4E9A"],"\u{1F1F7}\u{1F1EA}":["R\xE9union","\u7559\u5C3C\u6C6A","\u6CD5\u5C5E\u7559\u5C3C\u6C6A"],"\u{1F1F7}\u{1F1FA}":["Russia","\u4FC4\u7F57\u65AF","\u4FC4\u56FD","\u4FC4\u7F85\u65AF","\u4F2F\u529B","\u83AB\u65AF\u79D1","\u5723\u5F7C\u5F97\u5821","\u897F\u4F2F\u5229\u4E9A","\u4EAC\u4FC4","\u676D\u4FC4","\u5EE3\u4FC4","\u6EEC\u4FC4","\u5E7F\u4FC4","\u6CAA\u4FC4","Moscow"],"\u{1F1F8}\u{1F1E6}":["Saudi","\u6C99\u7279\u963F\u62C9\u4F2F","\u6C99\u7279","Riyadh","\u5229\u96C5\u5F97"],"\u{1F1F8}\u{1F1EA}":["Sweden","\u745E\u5178","\u65AF\u5FB7\u54E5\u5C14\u6469","Stockholm"],"\u{1F1F8}\u{1F1EC}":["Singapore","\u65B0\u52A0\u5761","\u72EE\u57CE","\u6CAA\u65B0","\u4EAC\u65B0","\u4E2D\u65B0","\u6CC9\u65B0","\u7A57\u65B0","\u6DF1\u65B0","\u676D\u65B0","\u5E7F\u65B0","\u5EE3\u65B0","\u6EEC\u65B0"],"\u{1F1F8}\u{1F1EE}":["Slovenia","\u65AF\u6D1B\u6587\u5C3C\u4E9A"],"\u{1F1F8}\u{1F1F0}":["Slovakia","\u65AF\u6D1B\u4F10\u514B"],"\u{1F1F9}\u{1F1EC}":["Togo","\u591A\u54E5","\u6D1B\u7F8E","Lom\xE9","Lome"],"\u{1F1F9}\u{1F1ED}":["Thailand","\u6CF0\u56FD","\u6CF0\u570B","\u66FC\u8C37"],"\u{1F1F9}\u{1F1F3}":["Tunisia","\u7A81\u5C3C\u65AF"],"\u{1F1F9}\u{1F1F7}":["Turkey","\u571F\u8033\u5176","\u4F0A\u65AF\u5766\u5E03\u5C14","Istanbul"],"\u{1F1F9}\u{1F1FC}":["Taiwan","\u53F0\u6E7E","\u81FA\u7063","\u53F0\u7063","\u4E2D\u83EF\u6C11\u570B","\u4E2D\u534E\u6C11\u56FD","\u53F0\u5317","\u53F0\u4E2D","\u65B0\u5317","\u5F70\u5316","\u53F0","\u81FA","Taipei","Tai Wan"],"\u{1F1FA}\u{1F1E6}":["Ukraine","\u4E4C\u514B\u5170","\u70CF\u514B\u862D"],"\u{1F1FA}\u{1F1F8}":["United States","\u7F8E\u56FD","America","\u7F8E","\u4EAC\u7F8E","\u6CE2\u7279\u5170","\u8FBE\u62C9\u65AF","\u4FC4\u52D2\u5188","Oregon","\u51E4\u51F0\u57CE","\u8D39\u5229\u8499","\u7845\u8C37","\u77FD\u8C37","\u62C9\u65AF\u7EF4\u52A0\u65AF","\u6D1B\u6749\u77F6","\u5723\u4F55\u585E","\u5723\u514B\u62C9\u62C9","\u897F\u96C5\u56FE","\u829D\u52A0\u54E5","\u6CAA\u7F8E","\u54E5\u4F26\u5E03","\u7EBD\u7EA6","New York","Los Angeles","San Jose","Sillicon Valley","Michigan","\u4FC4\u4EA5\u4FC4","Ohio","\u9A6C\u7EB3\u8428\u65AF","Manassas","\u5F17\u5409\u5C3C\u4E9A","Virginia"],"\u{1F1FA}\u{1F1FE}":["Uruguay","\u4E4C\u62C9\u572D"],"\u{1F1FB}\u{1F1E6}":["Vatican","Vatican City","Holy See","\u68B5\u8482\u5188","\u68B5\u8482\u5CA1"],"\u{1F1FB}\u{1F1EA}":["Venezuela","\u59D4\u5185\u745E\u62C9"],"\u{1F1FB}\u{1F1F3}":["Vietnam","\u8D8A\u5357","\u80E1\u5FD7\u660E"],"\u{1F1FF}\u{1F1E6}":["South Africa","\u5357\u975E"],"\u{1F1E8}\u{1F1F3}":["China","\u4E2D\u56FD","\u4E2D\u570B","\u56DE\u56FD","\u56DE\u570B","\u56FD\u5185","\u570B\u5167","\u534E\u4E1C","\u534E\u897F","\u534E\u5357","\u534E\u5317","\u534E\u4E2D","\u6C5F\u82CF","\u5317\u4EAC","\u4E0A\u6D77","\u5E7F\u5DDE","\u6DF1\u5733","\u676D\u5DDE","\u5F90\u5DDE","\u9752\u5C9B","\u5B81\u6CE2","\u9547\u6C5F"]},r=e.match(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/)?.[0]||"\u{1F3F4}\u200D\u2620\uFE0F";for(let n of Object.keys(t))if(t[n].some(o=>RegExp(`${o}`,"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(NA))if(NA[n].some(o=>RegExp(`(^|[^a-zA-Z])${o}([^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 s2(e){return NA[_h(e)]?.[0]}function Kp(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var n2=class{constructor({country,asn}={}){if(z.env.isNode){let Reader=eval('require("@maxmind/geoip2-node")').Reader,fs=eval("require('fs')"),countryFile=country||eval("process.env.SUB_STORE_MMDB_COUNTRY_PATH"),asnFile=asn||eval("process.env.SUB_STORE_MMDB_ASN_PATH");if(countryFile&&(this.countryReader=Reader.openBuffer(fs.readFileSync(countryFile))),asnFile){if(!fs.existsSync(asnFile))throw new Error("GeoLite2 ASN MMDB does not exist");this.asnReader=Reader.openBuffer(fs.readFileSync(asnFile))}}}geoip(e){return this.countryReader?.country(e)?.country?.isoCode}ipaso(e){return this.asnReader?.asn(e)?.autonomousSystemOrganization}ipasn(e){return this.asnReader?.asn(e)?.autonomousSystemNumber}};var N2e=P(x());var Fh=P(t9()),Vl=P($1());var r9=53,KW=853,zp=2;function GA({domain:e,type:t="A",edns:r}){let n=[];return r&&n.push({type:"OPT",name:".",udpPayloadSize:4096,flags:0,options:[{code:"CLIENT_SUBNET",ip:r,sourcePrefixLength:jr(r)?24:56,scopePrefixLength:0}]}),Fh.default.encode({type:"query",id:0,flags:Fh.default.RECURSION_DESIRED,questions:[{type:t,name:e}],additionals:n})}function n9(e){return e||8e3}function VW(e){return e?.replace(/^\[(.*)\]$/,"$1")}function zW(e){return jr(e)||hr(e)}function GW(e,t=r9){if(!e)return t;let r=Number(e);if(!Number.isInteger(r)||r<1||r>65535)throw new Error("\u81EA\u5B9A\u4E49 DNS \u7AEF\u53E3\u53F7\u5E94\u4E3A 1-65535 \u7684\u6574\u6570");return r}function YW(e,t){if(e.username||e.password||e.pathname&&e.pathname!=="/"||e.search||e.hash)throw new Error(`\u81EA\u5B9A\u4E49 DNS \u5730\u5740\u683C\u5F0F\u65E0\u6548: ${t}`)}function WW(e,t){try{let r=t?e:`udp://${hr(e)?`[${e}]`:e}`,n=new URL(r);YW(n,e);let i=VW(n.hostname);if(!i)throw new Error(`\u81EA\u5B9A\u4E49 DNS \u5730\u5740\u683C\u5F0F\u65E0\u6548: ${e}`);return{protocol:t||"udp",host:i,port:GW(n.port,t==="tls"?KW:r9)}}catch(r){throw r?.message?.includes("\u81EA\u5B9A\u4E49 DNS")?r:new Error(`\u81EA\u5B9A\u4E49 DNS \u5730\u5740\u683C\u5F0F\u65E0\u6548: ${e}`)}}function XW(e){let t=`${e||""}`.trim();if(!t)throw new Error("\u81EA\u5B9A\u4E49 DNS \u4E0D\u80FD\u4E3A\u7A7A");if(/^https?:\/\//i.test(t))return{protocol:"doh",url:t};let r=t.match(/^([a-z][a-z\d+.-]*):\/\//i)?.[1],n=r?.toLowerCase();if(n&&!["udp","tcp","tls"].includes(n))throw new Error(`\u81EA\u5B9A\u4E49 DNS \u4E0D\u652F\u6301 ${r} \u534F\u8BAE`);return WW(t,n)}async function YA({url:e,domain:t,type:r="A",timeout:n,edns:i,skipCertVerify:o}){let s=GA({domain:t,type:r,edns:i}),u=Vl.Buffer.from(s).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),l=await z.http.get({url:`${e}?dns=${encodeURIComponent(u)}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n,insecure:o===!0});return Fh.default.decode(Vl.Buffer.from(z.env.isQX?l.bodyBytes:l.body))}async function JW({server,domain,type="A",timeout,edns}){let dgram=eval("require('dgram')"),buf=GA({domain,type,edns});return new Promise((e,t)=>{let r=!1,n=dgram.createSocket(hr(server.host)?"udp6":"udp4"),i=setTimeout(()=>{s(new Error("DNS UDP query timeout"))},n9(timeout));function o(){clearTimeout(i),n.removeAllListeners();try{n.close()}catch{}}function s(a,u){r||(r=!0,o(),a?t(a):e(u))}n.on("error",a=>s(a)),n.on("message",a=>{try{s(null,Fh.default.decode(a))}catch(u){s(u)}}),n.send(buf,server.port,server.host,a=>{a&&s(a)})})}async function ZW({server,domain,type="A",timeout,edns,skipCertVerify}){let transport=server.protocol==="tls"?eval("require('tls')"):eval("require('net')"),transportName=server.protocol==="tls"?"TLS":"TCP",payload=GA({domain,type,edns}),length=Vl.Buffer.alloc(zp);length.writeUInt16BE(payload.length,0);let request=Vl.Buffer.concat([length,payload]);return new Promise((e,t)=>{let r=!1,n=Vl.Buffer.alloc(0),i,o=server.protocol==="tls"?transport.connect({host:server.host,port:server.port,servername:zW(server.host)?void 0:server.host,rejectUnauthorized:skipCertVerify===!0?!1:void 0}):transport.createConnection({host:server.host,port:server.port});function s(){o.removeAllListeners(),o.destroy()}function a(u,l){r||(r=!0,s(),u?t(u):e(l))}o.setTimeout(n9(timeout),()=>{a(new Error(`DNS ${transportName} query timeout`))}),o.on(server.protocol==="tls"?"secureConnect":"connect",()=>{o.write(request)}),o.on("error",u=>a(u)),o.on("end",()=>{a(new Error(`DNS ${transportName} connection ended before response`))}),o.on("data",u=>{try{if(n=Vl.Buffer.concat([n,u]),i==null&&n.length>=zp&&(i=n.readUInt16BE(0)),i!=null&&n.length>=i+zp){let l=n.slice(zp,i+zp);a(null,Fh.default.decode(l))}}catch(l){a(l)}})})}async function a2({url:e,domain:t,type:r="A",timeout:n,edns:i,skipCertVerify:o}){let s=`${e||""}`.trim(),a=s.match(/^([a-z][a-z\d+.-]*):\/\//i)?.[1];if(s&&!z.env.isNode&&!/^https?:\/\//i.test(s)&&(!a||["udp","tcp","tls"].includes(a.toLowerCase())))throw new Error("DoT \u548C TCP/UDP DNS \u4EC5\u652F\u6301 Node.js \u73AF\u5883");let u=XW(e);if(u.protocol==="doh")return YA({url:u.url,domain:t,type:r,timeout:n,edns:i,skipCertVerify:o});if(!z.env.isNode)throw new Error("DoT \u548C TCP/UDP DNS \u4EC5\u652F\u6301 Node.js \u73AF\u5883");return["tcp","tls"].includes(u.protocol)?ZW({server:u,domain:t,type:r,timeout:n,edns:i,skipCertVerify:o}):JW({server:u,domain:t,type:r,timeout:n,edns:i})}var $h=P(u2());var j2e=P(x());var{isNode:s9,isQX:QW,isLoon:eX,isSurge:tX,isStash:rX,isShadowRocket:nX,isLanceX:sX,isEgern:iX,isGUIforCores:oX}=ws(),ha="Node";s9?ha="Node":QW?ha="QX":eX?ha="Loon":rX?ha="Stash":nX?ha="Shadowrocket":iX?ha="Egern":tX?ha="Surge":sX?ha="LanceX":oX&&(ha="GUI.for.Cores");var zl={},aX={};try{if(typeof $environment<"u"&&(zl.env=$environment),typeof $loon<"u"&&(zl.loon=$loon),typeof $script<"u"&&(zl.script=$script),typeof $Plugin<"u"&&(zl.plugin=$Plugin),s9){zl.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)&&(zl.node.env[e]=env[e])}}catch(e){}var Ih={backend:ha,version:w1,feature:aX,meta:zl};var ZA="Response Transformer";function QA(e){return e===ZA}function Yp(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function u9(e,t){let r=typeof t=="string"?JSON.parse(t):t;for(let n in r)if(dt(r[n]))if(n.endsWith("!")){let i=Yp(n.slice(0,-1));e[i]=r[n]}else{let i=Yp(n);e[i]||Object.assign(e,{[i]:{}}),u9(e[i],r[i])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let i=Yp(n.slice(1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...r[n],...e[i]]}else if(n.endsWith("+")){let i=Yp(n.slice(0,-1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...e[i],...r[n]]}else{let i=Yp(n);Object.assign(e,{[i]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function uX({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>c2(e,r))}}function c2(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=>c2(r,t));case"OR":return e.child.some(r=>c2(r,t));case"NOT":return!c2(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function cX(e){return{name:"Quick Setting Operator",func:i=>{if(t(e.useless)){let s=m9().func(i);i=i.filter((a,u)=>s[u]&&a.port>0&&a.port<=65535)}return i.map(o=>(o.udp=t(e.udp,o.udp),o.tfo=t(e.tfo,o.tfo),o["fast-open"]=t(e.tfo,o["fast-open"]),o["skip-cert-verify"]=t(e.scert,o["skip-cert-verify"]),o.type==="vmess"&&(o.aead=t(e["vmess aead"],o.aead)),["snell","anytls","trusttunnel"].includes(o.type)&&(o.reuse=t(e.reuse,o.reuse)),["tuic","hysteria2"].includes(o.type)&&(o.ecn=t(e.ecn,o.ecn)),o["block-quic"]=r(e["block-quic"],o["block-quic"]),o["ip-version"]=n(e["ip-version"],o["ip-version"]),o))}};function t(i,o){switch(i){case"ENABLED":return!0;case"DISABLED":return!1;default:return o}}function r(i,o){switch(i){case"auto":case"on":case"off":return i;default:return o}}function n(i,o){switch(i){case void 0:case null:case"":case"DEFAULT":return o;default:return i}}}function lX({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=Kp(n.name);else{let i=_h(n.name);n.name=Kp(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 fX(e){let{action:t,template:r,link:n,position:i,field:o}={action:"rename",template:"0 1 2 3 4 5 6 7 8 9",link:"-",position:"back",field:["name"],...e};return{name:"Handle Duplicate Operator",func:s=>{if(t==="delete"){let a={};return s.filter(u=>{let l=o.map(f=>$h.default.get(u,f,"-")).join("_");return a[l]?!1:(a[l]=!0,!0)})}else if(t==="rename"){let a=r.split(" "),u={},l=0;s.forEach(m=>{let p=o.map(d=>$h.default.get(m,d,"-")).join("_");typeof u[p]>"u"?u[p]=1:u[p]++,l=Math.max(u[p].toString().length,l)});let f={};return s.map(m=>{let p=o.map(d=>$h.default.get(m,d,"-")).join("_");if(u[p]>1){typeof f[p]>"u"&&(f[p]=1);let d="",v=f[p]++,g=0;for(;v>0;)d=a[v%10]+d,v=parseInt(v/10),g++;for(;g++{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 LX(t);default:throw new Error("Unknown sort option: "+e)}}}}function dX(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=>tS(i)),n.sort((i,o)=>{let s=i9(r,i.name),a=i9(r,o.name);return s&&!a?-1:a&&!s?1:s&&a?st.map(r=>{for(let{expr:n,now:i}of e)r.name=r.name.replace(tS(n,"g"),i).trim();return r})}}function pX(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:c9(t).func}}function mX(e,t,r,n,i,o){return o.source=n,o.env=Ih,{name:"Script Operator",func:async s=>{let a=s;if(pu(a?.$file))try{let u=fi.safeLoad(e),l;if(a?.$content)try{l=fi.safeLoad(a?.$content)}catch(f){z.error(f.message??f)}if(typeof u!="object")throw new Error("patch is not an object");return a.$content=Ft.yaml.safeDump(u9(l||{},u)),a}catch{}return await async function(){a=Ph("operator",e,r,i)(s,t,o)}(),a},nodeFunc:async s=>{let a=s;return await async function(){a=Ph("operator",`async function operator(input = [], targetPlatform, context) { if (input && (input.$files || input.$content)) { let { $content, $files, $options, $file } = input if (['mihomoConfig', 'mihomoProfile'].includes($file?.type)) { ${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 || {})) } } 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)(s,t,o)}(),a}}}var l9="Add Proxies From Subscription Operator";function gX(e){if(!e)return{};let t=fi.safeLoad(e);return dt(t)?t:{}}function vX(e){return Array.isArray(e?.proxies)?e.proxies:[]}function wX({sourceType:e="subscription",sourceName:t,includeUnsupportedProxy:r,position:n="replace"}={}){let i=async o=>{if(!pu(o?.$file))return o;let s=gX(o.$content),a=vX(s),u=await Ws({type:e,name:t,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0,"include-unsupported-proxy":r}});switch(n){case"front":s.proxies=[...u,...a];break;case"back":s.proxies=[...a,...u];break;case"replace":default:s.proxies=u;break}return o.$content=Ft.yaml.safeDump(s),o};return{name:l9,func:i,nodeFunc:i}}function yX(e){let t,r;try{let n=e.split(":");r=parseInt(n[2],16);let i=parseInt(n[3],16),o=parseInt(n[4],16),s=i>>8,a=i&255,u=o>>8,l=o&255;if(t=`${s}.${a}.${u}.${l}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!jr(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){z.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var EX=10,bX=2,o9=20;function AX(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return EX;let t=Number(e);if(!Number.isInteger(t)||t<1)throw new Error("\u57DF\u540D\u89E3\u6790\u5E76\u53D1\u6570\u5E94\u4E3A\u5927\u4E8E 0 \u7684\u6574\u6570");return t}function f9(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return bX;let t=Number(e);if(!Number.isInteger(t)||t<1)throw new Error("\u591A DNS \u5E76\u53D1\u6570\u5E94\u4E3A\u5927\u4E8E 0 \u7684\u6574\u6570");return t}function SX(e,t){if(!(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")){let i=Number(e);if(!Number.isInteger(i)||i<1)throw new Error("DNS \u8D85\u65F6\u5E94\u4E3A\u5927\u4E8E 0 \u7684\u6574\u6570");return i}if(typeof t>"u"||t===null||typeof t=="string"&&t.trim()==="")return 8e3;let n=Number(t);return!isFinite(n)||n<=0?8e3:n}function CX(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return;let t=Number(e);if(!Number.isInteger(t)||t<1)throw new Error("\u57DF\u540D\u89E3\u6790\u7F13\u5B58\u65F6\u957F\u5E94\u4E3A\u5927\u4E8E 0 \u7684\u6574\u6570");return t*1e3}function eS(e){let t=`${e||""}`.split(/\r?\n/).map(r=>r.trim()).filter(r=>r);if(t.length===0)throw new Error("\u81EA\u5B9A\u4E49 DNS \u4E0D\u80FD\u4E3A\u7A7A");return t}function _X(e){return eS(e).join(` `)}async function DX(e,t,r){let n=0,i=Math.min(t,e.length),o=Array.from({length:i},async()=>{for(;n{let o=0,s=0,a=0,u=!1,l=[],f=Math.min(t,e.length);function m(){!u&&a===e.length&&i(new Error(l.length>0?l.join("; "):"No answers"))}function p(){if(!u){for(;sr(d)).then(v=>{s-=1,a+=1,!u&&(u=!0,n({result:v,resolverUrl:d}))}).catch(v=>{s-=1,a+=1,l.push(`${d}: ${v}`),p(),m()})}m()}}p()})}function JA(e,t,r,n,i){switch(e){case"Custom":return en(`CUSTOM:${i?"INSECURE:":""}${n}:${t}:${r}`);case"Google":return en(`GOOGLE:${t}:${r}`);case"IP-API":return en(`IP-API:${t}`);case"Cloudflare":return en(`CLOUDFLARE:${t}:${r}`);case"Ali":return en(`ALI:${t}:${r}`);case"Tencent":return en(`TENCENT:${t}:${r}`)}}function BX(e,t,r,n,i,o){if(n==="disabled")return null;let s=JA(e,t,r,i,o),a=s?tn.get(s):null;return e==="Custom"?d9(a):a}function WA(e,t){if(e!=="Custom"||!t)return"";let r=`${t}`.split(/\r?\n/).map(n=>n.trim()).filter(n=>n);return r.length<=1?` via ${t}`:` via ${r.length} custom DNS`}function IX(e,t){if(e!=="Custom"||!t)return t||"";let r=`${t}`.split(/\r?\n/).map(n=>n.trim()).filter(n=>n);return r.length<=1?t:`${r.length} custom DNS`}function h9(e,t){return e&&typeof e=="object"&&Object.defineProperty(e,"_resolverUrl",{value:t,enumerable:!1,configurable:!0}),e}function $X(e,t){return{result:e,resolverUrl:t}}function d9(e){return e&&typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.result)?h9(e.result,e.resolverUrl):e}function a9(e){return e&&typeof e=="object"?e._resolverUrl:null}var l2={Custom:async function(e,t,r,n,i,o,s,a,u){let l=eS(o),f=l.join(` `),m=f9(a),p=en(`CUSTOM:${s?"INSECURE:":""}${f}:${e}:${t}`),d=d9(tn.get(p));if(!r&&d)return d;let v=t==="IPv6"?"AAAA":"A",g=async E=>{let S=await a2({url:E,domain:e,type:v,timeout:n,edns:i,skipCertVerify:s}),{answers:F}=S;if(!Array.isArray(F)||F.length===0)throw new Error("No answers");let _=F.filter(H=>H?.type===v).map(H=>H?.data).filter(H=>H);if(_.length===0)throw new Error("No answers");return _},{result:y,resolverUrl:w}=l.length===1?{result:await g(l[0]),resolverUrl:l[0]}:await FX(l,m,g);return tn.set(p,$X(y,w),u),h9(y,w)},Google:async function(e,t,r,n,i,o,s,a,u){let l=en(`GOOGLE:${e}:${t}`),f=tn.get(l);if(!r&&f)return f;let m=t==="IPv6"?"AAAA":"A",p=await a2({url:"https://8.8.4.4/dns-query",domain:e,type:m,timeout:n,edns:i}),{answers:d}=p;if(!Array.isArray(d)||d.length===0)throw new Error("No answers");let v=d.filter(g=>g?.type===m).map(g=>g?.data).filter(g=>g);if(v.length===0)throw new Error("No answers");return tn.set(l,v,u),v},"IP-API":async function(e,t,r,n,i,o,s,a,u){if(["IPv6"].includes(t))throw new Error(`\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9 IP-API \u4E0D\u652F\u6301 ${t}`);let l=en(`IP-API:${e}`),f=tn.get(l);if(!r&&f)return f;let m=await z.http.get({url:`http://ip-api.com/json/${encodeURIComponent(e)}?lang=zh-CN`,timeout:n}),p=JSON.parse(m.body);if(p.status!=="success")throw new Error(`Status is ${p.status}`);if(!p.query||p.query===0)throw new Error("No answers");let d=[p.query];if(d.length===0)throw new Error("No answers");return tn.set(l,d,u),d},Cloudflare:async function(e,t,r,n,i,o,s,a,u){let l=en(`CLOUDFLARE:${e}:${t}`),f=tn.get(l);if(!r&&f)return f;let m=t==="IPv6"?"AAAA":"A",p=await a2({url:"https://1.0.0.1/dns-query",domain:e,type:m,timeout:n,edns:i}),{answers:d}=p;if(!Array.isArray(d)||d.length===0)throw new Error("No answers");let v=d.filter(g=>g?.type===m).map(g=>g?.data).filter(g=>g);if(v.length===0)throw new Error("No answers");return tn.set(l,v,u),v},Ali:async function(e,t,r,n,i,o,s,a,u){let l=en(`ALI:${e}:${t}`),f=tn.get(l);if(!r&&f)return f;let m=await z.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${i}/${jr(i)?24:56}&name=${encodeURIComponent(e)}&type=${t==="IPv6"?"AAAA":"A"}&short=1`,headers:{accept:"application/dns-json"},timeout:n}),p=JSON.parse(m.body);if(!Array.isArray(p)||p.length===0)throw new Error("No answers");let d=p;if(d.length===0)throw new Error("No answers");return tn.set(l,d,u),d},Tencent:async function(e,t,r,n,i,o,s,a,u){let l=en(`TENCENT:${e}:${t}`),f=tn.get(l);if(!r&&f)return f;let p=(await z.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(v=>v.split(",")[0]);if(p.length===0||String(p)==="0")throw new Error("No answers");let d=p;if(d.length===0)throw new Error("No answers");return tn.set(l,d,u),d}};function p9({provider:e,type:t,filter:r,cache:n,url:i,tlsSkipCertVerify:o,timeout:s,cacheTtl:a,edns:u,concurrency:l,dnsConcurrency:f}){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:m}=z.read(fr)||{},p=SX(s,m),d=CX(a),v=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",g=l2[e];if(!g)throw new Error(`\u627E\u4E0D\u5230\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9: ${e}`);let y=u||"223.6.6.6";if(!Gl(y))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");let w=AX(l),E=e==="Custom"?_X(i):i,S=e==="Custom"?eS(E).length:1,F=e==="Custom"?f9(f):1,_=w*Math.min(F,S),H=e==="Custom"&&(o===!0||o==="enabled");return _>o9&&z.warn(`\u57DF\u540D\u89E3\u6790\u603B\u5E76\u53D1\u6570\u4E0A\u9650 ${_} \u8D85\u8FC7\u5EFA\u8BAE\u503C ${o9}, \u53EF\u80FD\u5BFC\u81F4\u4EE3\u7406 App TCP \u8FDE\u63A5\u6570\u6FC0\u589E`),z.info(`Domain Resolver: [${t}] ${e} ${y||""} ${IX(e,E)}${H?" tlsSkipCertVerify=enabled":""} concurrency=${w}${e==="Custom"?` dnsConcurrency=${F}`:""}`),{name:"Resolve Domain Operator",func:async V=>{V.forEach((R,k)=>{!R["_no-resolve"]&&R["no-resolve"]&&(V[k]["_no-resolve"]=R["no-resolve"])});let C={},I=[...new Map(V.filter(R=>!Gl(R.server)&&!R["_no-resolve"]).map(R=>{let k=JA(e,R.server,v,E,H);return[k,{id:k,domain:R.server}]})).values()],L=[];return I.forEach(({id:R,domain:k})=>{let M=BX(e,k,v,n,E,H);if(M){C[R]=M;let N=e==="Custom"&&a9(M)||E;z.info(`Using cached resolved domain: ${k}${WA(e,N)} \u279F ${M}`)}else L.push({id:R,domain:k})}),await DX(L,w,async({id:R,domain:k})=>{try{let M=await g(k,v,n==="disabled",p,y,E,H,F,d);C[R]=M;let N=e==="Custom"&&a9(M)||E;z.info(`Successfully resolved domain: ${k}${WA(e,N)} \u279F ${M}`)}catch(M){z.error(`Failed to resolve domain: ${k}${WA(e,E)} with resolver [${e}]: ${M}`)}}),V.forEach(R=>{if(!R["_no-resolve"]){let k=JA(e,R.server,v,E,H);if(k&&C[k]){R._resolved_ips=C[k];let M=Array.isArray(C[k])?C[k][Math.floor(Math.random()*C[k].length)]:C[k];if(v==="IPv6"&&hr(M)){try{M=new Nm.Address6(M).correctForm()}catch(N){z.error(`Failed to parse IPv6 address: ${M}: ${N}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(M)){R._IP4P=M;let{server:N,port:D}=yX(M);N&&D?(R._domain=R.server,R.server=N,R.port=D,R.resolved=!0,R._IPv4=R.server,Gl(R._IP)||(R._IP=R.server)):R.resolved||(R.resolved=!1)}else R._domain=R.server,R.server=M,R.resolved=!0,R[`_${v}`]=R.server,Gl(R._IP)||(R._IP=R.server)}else R._domain=R.server,R.server=M,R.resolved=!0,R[`_${v}`]=R.server,Gl(R._IP)||(R._IP=R.server)}else R.resolved||(R.resolved=!1)}}),V.filter(R=>r==="removeFailed"?Gl(R.server)||R["_no-resolve"]||R.resolved:r==="IPOnly"?Gl(R.server):r==="IPv4Only"?jr(R.server):r==="IPv6Only"?hr(R.server):!0)}}}function Gl(e){return jr(e)||hr(e)}p9.resolver=l2;function XA(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function m9(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!XA(t.cipher))return!1;if(t.password&&!XA(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&&!XA(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function PX(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(o=>{let s=_h(o.name),a=t.some(u=>n[u]===s);return r?a:!a})}}function xX({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let i=e.some(o=>tS(o).test(n.name));return t?i:!i})}}function tS(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function TX(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 o=t.some(s=>i.type===s);return r?o:!o})}}function RX(e,t,r,n,i,o){return o.source=n,o.env=Ih,{name:"Script Filter",func:async s=>{let a=r2(s.length,!0);return await async function(){a=Ph("filter",e,r,i)(s,t,o)}(),a},nodeFunc:async s=>{let a=r2(s.length,!0);return await async function(){a=Ph("filter",`async function filter(input = [], targetPlatform, context) { let proxies = input let list = [] const fn = async ($server) => { ${e} } for await (let $server of proxies) { list.push(await fn($server)) } return list }`,r,i)(s,t,o)}(),a}}}function kX(e,t,r,n,i,o){return o.source=n,o.env=Ih,{name:ZA,func:async s=>{let a=s;return await async function(){a=Ph("transformFunction",e,r,i)(s,o)}(),a},shortcutFunc:async s=>{let a=s;return await async function(){a=Ph("transformFunction",`async function transformFunction(res = {}, context) { let $res = res ${e} return $res }`,r,i)(s,o)}(),a}}}var Wp={"Useless Filter":m9,"Region Filter":PX,"Regex Filter":xX,"Type Filter":TX,"Script Filter":RX,"Conditional Filter":uX,"Quick Setting Operator":cX,"Flag Operator":lX,"Sort Operator":hX,"Regex Sort Operator":dX,"Regex Rename Operator":c9,"Regex Delete Operator":pX,"Script Operator":mX,[l9]:wX,[ZA]:kX,"Handle Duplicate Operator":fX,"Resolve Domain Operator":p9};async function g9(e,t){let r=t;try{let n=await e.func(r);n&&(r=n)}catch(n){let i="",o=`${n.message??n}`;o.includes("$res is not defined")||(z.error(`Cannot apply ${e.name}(function transformFunction)! Reason: ${n}`),i=`\u6267\u884C function transformFunction \u5931\u8D25 ${o}; `);try{let s=await e.shortcutFunc(r);s&&(r=s)}catch(s){z.error(`Cannot apply ${e.name}(shortcut script)! Reason: ${s}`);let a="",u=`${s.message??s}`;throw i&&u===o?(a="",i=`\u6267\u884C\u5931\u8D25 ${o}`):a=`\u6267\u884C\u5FEB\u6377\u811A\u672C\u5931\u8D25 ${u}`,new Error(`\u54CD\u5E94\u4FEE\u6539 ${i}${a}`)}}return r}async function OX(e,t){let r=r2(t.length,!0);try{r=await e.func(t)}catch(n){let i="",o=`${n.message??n}`;o.includes("$server is not defined")?i="":(z.error(`Cannot apply filter ${e.name}(function filter)! Reason: ${n}`),i=`\u6267\u884C function filter \u5931\u8D25 ${o}; `);try{r=await e.nodeFunc(t)}catch(s){z.error(`Cannot apply filter ${e.name}(shortcut script)! Reason: ${s}`);let a="",u=`${s.message??s}`;throw i&&u===o?(a="",i=`\u6267\u884C\u5931\u8D25 ${o}`):a=`\u6267\u884C\u5FEB\u6377\u8FC7\u6EE4\u811A\u672C \u5931\u8D25 ${u}`,new Error(`\u811A\u672C\u8FC7\u6EE4 ${i}${a}`)}}return t.filter((n,i)=>r[i])}async function NX(e,t){let r=UX(t);try{let n=await e.func(r);n&&(r=n)}catch(n){let i="",o=`${n.message??n}`;o.includes("$server is not defined")||o.includes("$content is not defined")||o.includes("$files is not defined")||r?.$files||r?.$content?i="":(z.error(`Cannot apply operator ${e.name}(function operator)! Reason: ${n}`),i=`\u6267\u884C function operator \u5931\u8D25 ${o}; `);try{let s=await e.nodeFunc(r);s&&(r=s)}catch(s){z.error(`Cannot apply operator ${e.name}(shortcut script)! Reason: ${s}`);let a="",u=`${s.message??s}`;throw i&&u===o?(a="",i=`\u6267\u884C\u5931\u8D25 ${o}`):a=`\u6267\u884C\u5FEB\u6377\u811A\u672C \u5931\u8D25 ${u}`,new Error(`\u811A\u672C\u64CD\u4F5C ${i}${a}`)}}return r}async function v9(e,t){if(e.name.indexOf("Filter")!==-1)return OX(e,t);if(e.name.indexOf("Operator")!==-1)return NX(e,t)}function LX(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 UX(e){return JSON.parse(JSON.stringify(e))}function Ph(name,script,$arguments,$options){let flowUtils={getFlowField:vl,getFlowHeaders:Wo,parseFlowHeaders:Zf,flowTransfer:np,validCheck:Hm,getRmainingDays:_D,normalizeFlowHeader:Qf};return z.env.isLoon?new Function("$arguments","$options","$substore","lodash","$persistentStore","$httpClient","$notification","ProxyUtils","yaml","Buffer","b64d","b64e","DOMAIN_RESOLVERS","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,z,$h.default,$persistentStore,$httpClient,$notification,Ft,Ft.yaml,Ft.Buffer,Ft.Base64.decode,Ft.Base64.encode,l2,OA,flowUtils,Ws,eval('typeof require !== "undefined"')?iw:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","yaml","Buffer","b64d","b64e","DOMAIN_RESOLVERS","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,z,$h.default,Ft,Ft.yaml,Ft.Buffer,Ft.Base64.decode,Ft.Base64.encode,l2,OA,flowUtils,Ws,eval('typeof require !== "undefined"')?iw:void 0)}var lye=P(x());var yve=P(x());var fve=P(x()),E9=P(u2());var ft=class{constructor(t){this.proxy=t,this.output=[]}append(t){if(typeof t>"u")throw new Error("required field is missing");this.output.push(t)}appendIfPresent(t,r){pe(this.proxy,r)&&this.append(t)}toString(){return this.output.join("")}};function pe(e,t){let r=E9.default.get(e,t);return typeof r<"u"&&r!==null}function xh(e){let t=typeof e?.network=="string"?e.network.trim().toLowerCase():e?.network;return e?.type==="ss"&&e?.tls===!0&&!pe(e,"plugin")&&(!pe(e,"network")||t==="tcp")}function Xp(e){if(typeof e=="boolean")return Number(e);if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true")return 1;if(t==="false")return 0;if(/^\d+$/.test(t))return parseInt(t,10)}return e}function b9(e){return!!Xp(e)}function Th(e,t){if(e?.type!=="ss"||e?.plugin!=="v2ray-plugin")return!0;let r=typeof e?.["plugin-opts"]?.mode=="string"?e["plugin-opts"].mode.trim().toLowerCase():e?.["plugin-opts"]?.mode;return t.includes(r)}function w9(e,t){if(e?.plugin!=="shadow-tls"||!e["plugin-opts"])return;let r=e["plugin-opts"],n=!!r.password||r.version!=null&&Number(r.version)!==0;return e["shadow-tls-opts"]={password:r.password,version:r.version},r.host!=null&&(e[t]=r.host),r.alpn!=null&&(e.alpn=r.alpn),delete e.plugin,delete e["plugin-opts"],n}function f2(e){if(["vmess","vless","trojan","anytls"].includes(e.type)&&w9(e,"sni")&&["vmess","vless"].includes(e.type)&&(e.tls=!0),e.type==="vless"&&e.network==="xhttp"){let t=e["xhttp-opts"]?.["download-settings"];w9(t,"servername")&&(t.tls=!0)}}function rS(e,t){if(e==null)return;let r=`${e}`.trim();if(!/^\d+$/.test(r))return;let n=parseInt(r,10);if(!(n<0||n>t))return n}function A9(e,t){if(e==null)return null;let r=`${e}`.trim();if(!r)return null;let[,n=r,i]=/^(.*?)(?:\/(\d+))?$/.exec(r)||[],o=`${n}`.trim().replace(/^\[/,"").replace(/\]$/,""),s=t==="ipv4";return(s?jr(o):hr(o))?{address:o,cidr:rS(i,s?32:128)}:null}function y9(e,t){let{addressKey:r,cidrKey:n,family:i,defaultCIDR:o}=t,s=A9(e[r],i);if(!s){(e[r]==null||`${e[r]}`.trim().length===0)&&delete e[n];return}e[r]=s.address;let a=rS(e[n],o);e[n]=a??s.cidr??o}function nS(e={}){return y9(e,{addressKey:"ip",cidrKey:"ip-cidr",family:"ipv4",defaultCIDR:32}),y9(e,{addressKey:"ipv6",cidrKey:"ipv6-cidr",family:"ipv6",defaultCIDR:128}),e}function Js(e={},t="ipv4"){let r=t==="ipv6"?{addressKey:"ipv6",cidrKey:"ipv6-cidr",defaultCIDR:128}:{addressKey:"ip",cidrKey:"ip-cidr",defaultCIDR:32},n=A9(e[r.addressKey],t);if(!n)return;let i=rS(e[r.cidrKey],r.defaultCIDR);return`${n.address}/${i??n.cidr??r.defaultCIDR}`}function da(e,t,r={}){return t==="internal"?e:r.prettyYaml||r["pretty-yaml"]?ql(fi.safeDump({proxies:e},{lineWidth:-1})):`proxies: `+e.map(n=>" - "+JSON.stringify(n)+` `).join("")}var dve=P(x()),h2="auto",HX=[h2,"none","zero","aes-128-gcm","chacha20-poly1305"],MX=[h2,"aes-128-gcm","chacha20-poly1305","none"],jX=["none","chacha20-poly1305"],qX={"chacha20-ietf-poly1305":"chacha20-poly1305"};function S9(e){return e==null?"":`${e}`.trim().toLowerCase()}function sS(e){return qX[e]||e}function Tn(e,t=HX,{acceptAliases:r=!0,fallback:n=h2}={}){let i=S9(e);if(!i)return n;let o=t.map(S9);if(o.includes(i))return sS(i);let s=sS(i),a=o.map(sS);return r&&a.includes(s)?s:n}function Jp(e){return Tn(e,MX)}function C9(e){return Tn(e,jX,{fallback:"chacha20-poly1305"})}function _9(e){let t=Jp(e);return t==="chacha20-poly1305"?"chacha20-ietf-poly1305":t}function D9(e){let t=Tn(e,["aes-128-gcm","chacha20-poly1305"]);if(t!==h2)return t==="chacha20-poly1305"?"chacha20-ietf-poly1305":t}var d2="Surge",Rh=class extends Error{constructor(t){super(t),this.name="SurgeUnsupportedProxyError"}};function _u(e){return new Rh(e)}var $s={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function p2(e){if(typeof e!="string")return e;let t=e.trim(),r=t[0];return(r==='"'||r==="'")&&t[t.length-1]===r?t.slice(1,-1):t}function kh(e){return`"${String(p2(e))}"`}function m2(e){return e!=null&&`${e}`.trim().length>0}function F9(e){return(Array.isArray(e)?e:p2(`${e||""}`).split(",")).filter(r=>r!=null).map(r=>String(p2(r)).trim()).filter(r=>r!=="").join(",")}function KX(e,t){let r=F9(t.alpn);r&&e.append(`,alpn="${r}"`)}function VX(e){return F9(e?.["plugin-opts"]?.alpn??e?.alpn)}function wo(e,t,r=!1){if(t.plugin!=="shadow-tls"||!t["plugin-opts"])return;let n=t["plugin-opts"].password,i=t["plugin-opts"].host,o=t["plugin-opts"].version;if(!n)return;if(e.append(`,shadow-tls-password="${n}"`),i&&e.append(`,shadow-tls-sni=${i}`),o){if(o<2)throw _u(`shadow-tls version ${o} is not supported`);e.append(`,shadow-tls-version=${o}`)}let s=VX(t);s&&e.append(`,alpn="${s}"`),r&&e.appendIfPresent(`,udp-port=${t["udp-port"]}`,"udp-port")}function Du(e,t,r=!0){if(!r)return;e.appendIfPresent(`,server-cert-fingerprint-sha256=${t["tls-fingerprint"]}`,"tls-fingerprint"),e.appendIfPresent(`,sni="${t.sni}"`,"sni"),e.appendIfPresent(`,server-cert-verify-name=${kh(t["name-cert-verify"])}`,"name-cert-verify"),t.plugin!=="shadow-tls"&&KX(e,t),e.appendIfPresent(`,skip-cert-verify=${t["skip-cert-verify"]}`,"skip-cert-verify");let n=pe(t,"keystore-client-cert")?t["keystore-client-cert"]:t["client-cert"];(pe(t,"keystore-client-cert")||pe(t,"client-cert"))&&e.append(`,client-cert=${kh(n)}`)}function zX(e,t){let r=pe(t,"keystore-private-key")?t["keystore-private-key"]:t["private-key"];(pe(t,"keystore-private-key")||pe(t,"private-key"))&&e.append(`,private-key=${kh(r)}`)}function B9(e){if(!pe(e,"max-streams"))return;let t=Number(p2(e["max-streams"]));!Number.isInteger(t)||t<=3||z.warn(`Surge ${e.type} proxy ${e.name}: max-streams=${t} is greater than 3. Too many streams sharing one TCP connection may hurt performance.`)}function GX(e){return pe(e,"obfs-opts.mode")||pe(e,"obfs-opts.host")||pe(e,"obfs-opts.path")}function YX(e){return Number(e.version)===6&&GX(e)}function Oh(){return{produce:(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw _u(`Platform ${d2} does not support network ${t.network} with http upgrade`);switch(t.name=t.name.replace(/=|,/g,""),t.ports&&(t.ports=String(t.ports)),t.type){case"ss":return WX(t);case"trojan":return XX(t);case"vmess":return eJ(t,n["include-unsupported-proxy"]);case"http":return rJ(t);case"h2-connect":return QX(t);case"direct":return nJ(t);case"socks5":return sJ(t);case"snell":return oJ(t);case"tuic":return aJ(t);case"wireguard-surge":return cJ(t);case"hysteria2":return lJ(t);case"ssh":return tJ(t);case"trusttunnel":return ZX(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return uJ(t);if(t.type==="anytls"){if(t.network&&(!["tcp"].includes(t.network)||["tcp"].includes(t.network)&&t["reality-opts"]))throw _u(`Platform ${d2} does not support proxy type ${t.type} with network or REALITY`);return JX(t)}throw _u(`Platform ${d2} does not support proxy type: ${t.type}`)}}}function WX(e){let t=new ft(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 _u(`cipher ${e.cipher} is not supported`);t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=$s[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"),pe(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 _u(`plugin ${e.plugin} is not supported`)}return t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(t,e,!0),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function XX(e){let t=new ft(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=$s[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"),$9(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),Du(t,e),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function JX(e){let t=new ft(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=$s[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"),Du(t,e),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.toString()}function ZX(e){let t=new ft(e);t.append(`${e.name}=trust-tunnel,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),iS(t,e),B9(e),t.appendIfPresent(`,max-streams=${e["max-streams"]}`,"max-streams");let r=$s[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"),Du(t,e),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.toString()}function QX(e){let t=new ft(e);t.append(`${e.name}=h2-connect,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),iS(t,e),B9(e),t.appendIfPresent(`,max-streams=${e["max-streams"]}`,"max-streams");let r=$s[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"),Du(t,e),e.tfo&&z.info("Option tfo is not supported by Surge, thus omitted"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function eJ(e,t){let r=new ft(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=D9(e.cipher);n&&r.append(`,encrypt-method=${n}`);let i=$s[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-version=${i}`,"ip-version"),r.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),$9(r,e,t),pe(e,"aead")?r.append(`,vmess-aead=${e.aead}`):r.append(`,vmess-aead=${e.alterId===0}`),r.appendIfPresent(`,tls=${e.tls}`,"tls"),Du(r,e,!!e.tls),r.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),r.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),r.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),r.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),r.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),r.appendIfPresent(`,tos=${e.tos}`,"tos"),r.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),r.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),r.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(r,e),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.toString()}function tJ(e){let t=new ft(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),zX(t,e),t.appendIfPresent(`,idle-timeout=${e["idle-timeout"]}`,"idle-timeout"),t.appendIfPresent(`,server-fingerprint="${e["server-fingerprint"]}"`,"server-fingerprint");let r=$s[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function rJ(e){let t=new ft(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),iS(t,e);let n=$s[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"),Du(t,e,!!e.tls),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function nJ(e){let t=new ft(e),r="direct";t.append(`${e.name}=${r}`);let n=$s[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function sJ(e){let t=new ft(e),r=e.tls?"socks5-tls":"socks5";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password");let n=$s[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"),Du(t,e,!!e.tls),e.tfo&&z.info("Option tfo is not supported by Surge, thus omitted"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function iS(e,t){let r=iJ(t.headers);et(r)&&e.append(`,headers=${kh(r)}`)}function iJ(e){return I9(e,";")}function I9(e,t){return!e||typeof e!="object"?"":Object.entries(e).filter(([r,n])=>et(r)&&n!=null).map(([r,n])=>`${r}:${kh(n)}`).join(t)}function oJ(e){if(YX(e))return z.error(`Platform ${d2} does not support Snell version ${e.version} with obfs`),"";let t=new ft(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,version=${e.version}`,"version"),t.appendIfPresent(`,psk="${e.psk}"`,"psk"),Number(e.version)===6&&t.appendIfPresent(`,mode=${e.mode}`,"mode");let r=$s[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,obfs=${e["obfs-opts"]?.mode}`,"obfs-opts.mode"),t.appendIfPresent(`,obfs-host=${e["obfs-opts"]?.host}`,"obfs-opts.host"),t.appendIfPresent(`,obfs-uri=${e["obfs-opts"]?.path}`,"obfs-opts.path"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(t,e),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 aJ(e){let t=new ft(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"),m2(e.ports)&&t.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),m2(e["hop-interval"])&&t.append(`,port-hopping-interval=${e["hop-interval"]}`);let n=$s[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"),Du(t,e),pe(e,"tfo")?t.append(`,tfo=${e.tfo}`):pe(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(t,e),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 uJ(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 ft(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=jt(e["section-name"],e.name),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert");let r=$s[e["ip-version"]]||e["ip-version"];t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(t,e),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,o=e["preshared-key"]??e["pre-shared-key"],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":o};return t.append(` peer = (${Object.keys(s).filter(a=>s[a]!=null).map(a=>`${a} = ${s[a]}`).join(", ")})`),t.toString()}function cJ(e){let t=new ft(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=$s[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function lJ(e){let t={salamander:"salamander-password",gecko:"gecko-password"}[e.obfs];if(e["obfs-password"]&&!t)throw _u("only salamander and gecko obfs are supported");let r=new ft(e);r.append(`${e.name}=hysteria2,${e.server},${e.port}`),r.appendIfPresent(`,password="${e.password}"`,"password"),m2(e.ports)&&r.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),m2(e["hop-interval"])&&r.append(`,port-hopping-interval=${e["hop-interval"]}`),e["obfs-password"]&&t&&r.append(`,${t}="${e["obfs-password"]}"`);let n=$s[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"),Du(r,e),pe(e,"tfo")?r.append(`,tfo=${e.tfo}`):pe(e,"fast-open")&&r.append(`,tfo=${e["fast-open"]}`),r.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),r.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),r.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),r.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),r.appendIfPresent(`,tos=${e.tos}`,"tos"),r.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),r.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),r.appendIfPresent(`,interface=${e.interface}`,"interface"),wo(r,e),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),r.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),r.toString()}function $9(e,t,r){if(pe(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),pe(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),pe(t,"ws-opts.headers"))){let n=t["ws-opts"].headers,i=I9(n,"|");et(i)&&e.append(`,ws-headers=${kh(i)}`)}}else if(r&&["http"].includes(t.network))z.info(`Include Unsupported Proxy: network ${t.network} -> tcp`);else{if(["tcp"].includes(t.network)&&t["reality-opts"])throw _u("reality is unsupported");if(!["tcp"].includes(t.network))throw _u(`network ${t.network} is unsupported`)}}var Hve=P(x());var xve=P(x());var bve=P(x());function oS(e){try{return decodeURIComponent(`${e}`.replace(/\+/g,"%20"))}catch{return e}}function P9(e){let t=e.indexOf("=");return t===-1?{key:oS(e),value:""}:{key:oS(e.slice(0,t)),value:oS(e.slice(t+1))}}function Fu(e){if(!/^\d+$/.test(`${e}`))return null;let t=parseInt(`${e}`,10);return Number.isSafeInteger(t)?t:null}function Zs(e,t){let r=e==null?"":`${e}`,n=r.indexOf("?");if(n===-1)return{path:r,value:""};let i=r.slice(0,n),o=r.slice(n+1),s=[],a="";for(let u of o.split("&")){if(u==="")continue;let l=P9(u);if(l.key===t){a===""&&l.value!==""&&(a=l.value);continue}s.push(u)}return{path:s.length>0?`${i}?${s.join("&")}`:i,value:a}}function Zp(e,t){let r=e==null?"":`${e}`,n=r.indexOf("?");if(n===-1)return"";let i=r.slice(n+1);for(let o of i.split("&")){if(o==="")continue;let s=P9(o);if(s.key===t&&s.value!=="")return s.value}return""}function aS(e,t){let r=Zp(e,t),n=Fu(r);return n==null?{value:"",parsed:null}:{value:r,parsed:n}}function fJ(e,t,r){let n=e.includes("?")?e.endsWith("?")||e.endsWith("&")?"":"&":"?";return`${e}${n}${encodeURIComponent(t)}=${encodeURIComponent(`${r}`)}`}function uS(e,t,r){let n=e==null||e===""?"/":`${e}`,{path:i}=Zs(n,t);return fJ(i,t,r)}function Dc(e){let t=e?.path;if(!e)return;let{value:r,parsed:n}=aS(t,"ed");if(e["v2ray-http-upgrade"]){r!==""&&(e.path=Zs(t,"ed").path,e["v2ray-http-upgrade-fast-open"]=!0,(e["_v2ray-http-upgrade-ed"]==null||`${e["_v2ray-http-upgrade-ed"]}`=="")&&(e["_v2ray-http-upgrade-ed"]=r)),delete e["early-data-header-name"],delete e["max-early-data"];return}r!==""&&(e.path=Zs(t,"ed").path,e["early-data-header-name"]==null&&(e["early-data-header-name"]="Sec-WebSocket-Protocol"),e["max-early-data"]==null&&(e["max-early-data"]=n))}function Fc(e){e&&delete e["_v2ray-http-upgrade-ed"]}var Cve=P(x());var Yl="_dns",cS="_force-query",lS="_sockopt",x9="https://dns.alidns.com/dns-query";function T9(e){if(!et(e))return;if(!e.includes("://"))return{type:"config",config:e};let t=e.split("+");if(t.length===1&&et(t[0]))return{type:"dns",dns:t[0]};if(t.length===2&&et(t[0])&&et(t[1]))return{type:"dns",queryServerName:t[0],dns:t[1]}}function fS(e){return T9(e)!=null}function g2(e){return["none","half","full"].includes(e)}function hJ(e){return typeof e=="boolean"?e:typeof e=="number"&&Number.isInteger(e)&&e!==0}function v2({echConfigList:e,echForceQuery:t,echSockopt:r}={}){let n=T9(e);if(!n)return;let i={enable:!0};return n.type==="config"?i.config=n.config:(i[Yl]=n.dns,n.queryServerName&&(i["query-server-name"]=n.queryServerName)),g2(t)&&(i[cS]=t),dt(r)&&(i[lS]=r),i}function hS(e,t,{dnsFieldPath:r="ech-opts._dns",warnDefaultDns:n}={}){let i={};if(dt(e)){if(!hJ(e.enable))return i;let o=e["query-server-name"];return et(e.config)?i.echConfigList=e.config:et(e[Yl])?i.echConfigList=et(o)?`${o}+${e[Yl]}`:e[Yl]:et(o)&&(i.echConfigList=`${o}+${x9}`,n?.({defaultDns:x9,dnsFieldPath:r,queryServerName:o})),i.echConfigList&&g2(e[cS])&&(i.echForceQuery=e[cS]),i.echConfigList&&dt(e[lS])&&(i.echSockopt=e[lS]),i}return et(t)&&(i.echConfigList=t),i}function dS(e,t,r){return hS(e,t,r).echConfigList}var dJ={dual:"dual","v4-only":"ipv4","v6-only":"ipv6","prefer-v4":"ipv4-prefer","prefer-v6":"ipv6-prefer"};function R9(e,t,r){if(!dt(t)||!et(t[Yl]))return;let n=et(t["query-server-name"])?t["query-server-name"]:"\u8FD9\u91CC\u662F query-server-name";z.warn(`mihomo \u4E0D\u652F\u6301\u5728 ech-opts \u4E2D\u914D\u7F6E ECH DNS. \u5982\u9700\u8DDF\u8282\u70B9 ECH \u914D\u7F6E\u4E00\u81F4, \u8BF7\u5728 mihomo \u914D\u7F6E\u6587\u4EF6\u91CC\u8BBE\u7F6E dns["nameserver-policy"]["${n}"] = ["${t[Yl]}"].`)}function pJ(e,t){t!=="internal"&&(R9(e,e["ech-opts"],"ech-opts"),R9(e,e["xhttp-opts"]?.["download-settings"]?.["ech-opts"],"xhttp-opts.download-settings.ech-opts"))}function mi(){return{type:"ALL",produce:(r,n,i={})=>{let o=r.filter(s=>{if(i["include-unsupported-proxy"])return!0;if(s.type==="h2-connect")return z.error(`mihomo does not support HTTP/2 CONNECT proxy type. Proxy ${s.name} has been filtered.`),!1;if(mJ(s)&&s.type==="trusttunnel")return z.error(`mihomo does not support headers for TrustTunnel proxy ${s.name}. Proxy has been filtered.`),!1;if(Th(s,["websocket"])){if(s.type==="snell"&&!pS(s.version,[1,2,3,4,5]))return!1;if(k9(s)&&(!["ss","snell","vmess","vless","trojan","anytls"].includes(s.type)||!pS(O9(s),["ss","snell"].includes(s.type)?[1,2,3]:[0,1,2,3])))return!1;if(s.type==="vless"&&s.network==="xhttp"&&k9(s["xhttp-opts"]?.["download-settings"])&&!pS(O9(s["xhttp-opts"]["download-settings"]),[0,1,2,3]))return!1;if(gJ(s))return z.error(`Platform Mihomo does not support Snell shadow-tls with obfs for proxy ${s.name}. Proxy has been filtered.`),!1;if(["juicity","naive"].includes(s.type))return!1;if(["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))return!1;if(["anytls"].includes(s.type)&&s.network&&(!["tcp"].includes(s.network)||["tcp"].includes(s.network)&&s["reality-opts"]))return!1;if(!["vless"].includes(s.type)&&["xhttp"].includes(s.network))return!1}else return!1;return!0}).map(s=>{if(pJ(s,n),f2(s),s["reality-opts"]&&!s["client-fingerprint"]&&(s["client-fingerprint"]="chrome"),s.type==="vmess")pe(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.cipher=Tn(s.cipher);else if(s.type==="tuic")pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!pe(s,"version")&&(s.version=5);else if(s.type==="hysteria")pe(s,"auth_str")&&!pe(s,"auth-str")&&(s["auth-str"]=s.auth_str),pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo);else if(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.ip=Js(s,"ipv4"),s.ipv6=Js(s,"ipv6");else if(s.type==="snell"&&s.version<3)delete s.udp;else if(s.type==="vless"){if(pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.network==="xhttp"&&s["xhttp-opts"]?.["download-settings"]){let a=s["xhttp-opts"]["download-settings"];s.tls&&a.tls&&s["reality-opts"]&&!a["reality-opts"]&&(a["reality-opts"]={"public-key":""})}}else["anytls"].includes(s.type)&&s.reuse!=null&&!s.reuse&&(s["disable-reuse"]=!0,delete s.reuse);if(pe(s,"plugin-opts.mux")&&(s["plugin-opts"].mux=b9(s["plugin-opts"].mux)),s.type==="snell"){let a=mS(s);a&&(s["obfs-opts"]={mode:"shadow-tls",host:a.host,password:a.password,version:a.version},a.alpn&&(s["obfs-opts"].alpn=a.alpn),delete s.plugin,delete s["plugin-opts"])}if(["vmess","vless"].includes(s.type)&&s.network==="http"){let a=s["http-opts"]?.path;pe(s,"http-opts.path")&&!Array.isArray(a)&&(s["http-opts"].path=[a]);let u=s["http-opts"]?.headers?.Host;pe(s,"http-opts.headers.Host")&&!Array.isArray(u)&&(s["http-opts"].headers.Host=[u])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let a=s["h2-opts"]?.path;pe(s,"h2-opts.path")&&Array.isArray(a)&&(s["h2-opts"].path=a[0]);let u=s["h2-opts"]?.host??s["h2-opts"]?.headers?.host??s["h2-opts"]?.headers?.Host;(pe(s,"h2-opts.host")||pe(s,"h2-opts.headers.host")||pe(s,"h2-opts.headers.Host"))&&(s["h2-opts"].host=Array.isArray(u)?u:[u]),s["h2-opts"]?.headers&&(delete s["h2-opts"].headers.host,delete s["h2-opts"].headers.Host,Object.keys(s["h2-opts"].headers).length===0&&delete s["h2-opts"].headers)}if(["ws"].includes(s.network)){let a=`${s.network}-opts`;s[a]=s[a]||{},s[a].path||(s[a].path="/"),Dc(s[a])}if(s["plugin-opts"]?.tls&&pe(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["plugin-opts"]["skip-cert-verify"]||s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","naive","masque","shadowquic"].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"],pe(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"],delete s["ip-cidr"],delete s["ipv6-cidr"],n!=="internal"||i["delete-underscore-fields"]){for(let a in s)(s[a]==null||/^_/i.test(a))&&delete s[a];Fc(s[`${s.network}-opts`])}return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s["ip-version"]&&(s["ip-version"]=dJ[s["ip-version"]]||s["ip-version"]),s});return da(o,n,i)}}}function mJ(e){return e?.headers&&typeof e.headers=="object"&&Object.keys(e.headers).length>0}function pS(e,t){if(e==null)return!0;let r=typeof e=="string"?e.trim():`${e}`;if(!r)return!1;let n=Number(r);return Number.isInteger(n)&&t.includes(n)}function k9(e){return!!mS(e)}function gJ(e){return e?.type==="snell"&&e?.plugin==="shadow-tls"&&(pe(e,"obfs-opts.mode")||pe(e,"obfs-opts.host")||pe(e,"obfs-opts.path"))}function O9(e){return mS(e)?.version}function mS(e){if(e?.plugin==="shadow-tls"&&e?.["plugin-opts"])return e["plugin-opts"];if(e?.type==="snell"&&e?.["obfs-opts"]?.mode==="shadow-tls")return e["obfs-opts"]}var L9="SurgeMac",U9=Oh();function Qp(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return H9(t);default:{if(n.mihomoExternal||t._mihomoExternal)return N9(t,r,n)||"";try{return U9.produce(t,r,n)}catch(i){if(n.useMihomoExternal&&i instanceof Rh){let o=N9(t,r,n)||"";if(!o)throw i;return z.log(`${t.name} is not supported on ${L9}, try to use mihomo(SurgeMac - External Proxy Program) instead`),o}throw i instanceof Rh?new Error(`${i.message}. 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`):i}}}}}}function H9(e){let t=new ft(e);if(!e.exec||!e["local-port"])throw new Error(`${e.type}: exec and local-port are required`);return t.append(`${e.name}=external,exec="${e.exec}",local-port=${e["local-port"]}`),Array.isArray(e.args)&&e.args.map(r=>{t.append(`,args="${r}"`)}),Array.isArray(e.addresses)&&e.addresses.map(r=>{t.append(`,addresses=${r}`)}),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),pe(e,"tfo")?t.append(`,tfo=${e.tfo}`):pe(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 N9(e,t,r){let n=mi().produce([e],"internal")?.[0];if(n){let i=r?.localPort||e._localPort||65535,o=!["ipv4","v4-only"].includes(e["ip-version"]),s={enable:!0,ipv6:o,"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"]},a=r?.merge||e._merge,u;if(a){let l={name:e.name,type:"socks5",server:"127.0.0.1",port:i,udp:!0};u=U9.produce(l,"socks5",r),r._merged=r._merged||{name:r?.mergeName||e._mergeName||"mihomo merged",exec:r?.exec||e._exec||"/usr/local/bin/mihomo",config:{ipv6:o,mode:"global",dns:s,proxies:[],"proxy-groups":[{name:"GLOBAL",type:"fallback",proxies:[]}],listeners:[]}};let f=`${i}`;r._merged.config.listeners.push({name:`socks5-${i}`,type:"socks",port:i,listen:"127.0.0.1",udp:!0,proxy:f}),r._merged.config["proxy-groups"][0].proxies.push(f),r._merged.config.proxies.push({...n,name:f}),r._merged.config={...r._merged.config,...r?.config||e._config||{}}}else{let l={name:e.name,type:"external",udp:!0,exec:r?.exec||e._exec||"/usr/local/bin/mihomo","local-port":i,args:["-config",It.encode(JSON.stringify({"mixed-port":i,ipv6:o,mode:"global",dns:s,proxies:[{...n,name:"proxy"}],"proxy-groups":[{name:"GLOBAL",type:"select",proxies:["proxy"]}],...r?.config||e._config||{}}))],addresses:[]};vJ(e.server)?l.addresses.push(e.server):z.warn(`Platform ${L9}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),u=H9(l)}return r.localPort=i-1,u}}function vJ(e){return jr(e)||hr(e)}var zve=P(x());function gS(){return{type:"ALL",produce:(r,n,i={})=>{let o=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"&&s.version>=4||s.type==="vless"&&(typeof s.flow<"u"||s["reality-opts"])||["ws"].includes(s.network)&&s["ws-opts"]?.["v2ray-http-upgrade"]?!1:s["underlying-proxy"]||s["dialer-proxy"]?(z.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"?(pe(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.cipher=Jp(s.cipher)):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"&&pe(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let a=s["http-opts"]?.path;pe(s,"http-opts.path")&&!Array.isArray(a)&&(s["http-opts"].path=[a]);let u=s["http-opts"]?.headers?.Host;pe(s,"http-opts.headers.Host")&&!Array.isArray(u)&&(s["http-opts"].headers.Host=[u])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let a=s["h2-opts"]?.path;pe(s,"h2-opts.path")&&Array.isArray(a)&&(s["h2-opts"].path=a[0]);let u=s["h2-opts"]?.host??s["h2-opts"]?.headers?.host??s["h2-opts"]?.headers?.Host;(pe(s,"h2-opts.host")||pe(s,"h2-opts.headers.host")||pe(s,"h2-opts.headers.Host"))&&(s["h2-opts"].host=Array.isArray(u)?u:[u]),s["h2-opts"]?.headers&&(delete s["h2-opts"].headers.host,delete s["h2-opts"].headers.Host,Object.keys(s["h2-opts"].headers).length===0&&delete s["h2-opts"].headers)}if(["ws"].includes(s.network)){let a=`${s.network}-opts`;s[a]=s[a]||{},s[a].path||(s[a].path="/"),Dc(s[a])}if(s["plugin-opts"]?.tls&&pe(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["plugin-opts"]["skip-cert-verify"]||s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","naive"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],pe(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"],delete s["ip-cidr"],delete s["ipv6-cidr"],n!=="internal"){for(let a in s)(s[a]==null||/^_/i.test(a))&&delete s[a];Fc(s[`${s.network}-opts`])}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 da(o,n,i)}}}var Qve=P(x());function w2(){return{type:"ALL",produce:(r,n,i={})=>{let o=r.filter(s=>{if(i["include-unsupported-proxy"])return!0;if(!["ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","wireguard","hysteria","hysteria2","ssh","juicity","anytls","tailscale","trusttunnel"].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"&&s.version>=4)return!1;if(Th(s,["websocket"])){if(["vless"].includes(s.type)&&s["reality-opts"]&&s.network&&!["tcp"].includes(s.network))return!1;if(["anytls"].includes(s.type)&&s.network&&(!["tcp"].includes(s.network)||["tcp"].includes(s.network)&&s["reality-opts"]))return!1;if(["xhttp"].includes(s.network))return!1;if(s.encryption&&s.encryption!=="none"&&["vless"].includes(s.type))return!1;if(["ws"].includes(s.network)&&s["ws-opts"]?.["v2ray-http-upgrade"])return!1}else return!1;return!0}).map(s=>{if(s.type==="vmess"?(pe(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.cipher=Jp(s.cipher)):s.type==="tuic"?(pe(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),(!s.token||s.token.length===0)&&!pe(s,"version")&&(s.version=5)):s.type==="hysteria"?(pe(s,"auth_str")&&!pe(s,"auth-str")&&(s["auth-str"]=s.auth_str),pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),pe(s,"down")&&!pe(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),pe(s,"up")&&!pe(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),pe(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),pe(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="hysteria2"?(pe(s,"password")&&!pe(s,"auth")&&(s.auth=s.password,delete s.password),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),pe(s,"down")&&!pe(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),pe(s,"up")&&!pe(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),pe(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),pe(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"&&pe(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let a=s["http-opts"]?.path;pe(s,"http-opts.path")&&!Array.isArray(a)&&(s["http-opts"].path=[a]);let u=s["http-opts"]?.headers?.Host;pe(s,"http-opts.headers.Host")&&!Array.isArray(u)&&(s["http-opts"].headers.Host=[u])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let a=s["h2-opts"]?.path;pe(s,"h2-opts.path")&&Array.isArray(a)&&(s["h2-opts"].path=a[0]);let u=s["h2-opts"]?.host??s["h2-opts"]?.headers?.host??s["h2-opts"]?.headers?.Host;(pe(s,"h2-opts.host")||pe(s,"h2-opts.headers.host")||pe(s,"h2-opts.headers.Host"))&&(s["h2-opts"].host=Array.isArray(u)?u:[u]),s["h2-opts"]?.headers&&(delete s["h2-opts"].headers.host,delete s["h2-opts"].headers.Host,Object.keys(s["h2-opts"].headers).length===0&&delete s["h2-opts"].headers)}if(["ws"].includes(s.network)){let a=`${s.network}-opts`;s[a]=s[a]||{},s[a].path||(s[a].path="/"),Dc(s[a])}if(s["plugin-opts"]?.tls&&pe(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["plugin-opts"]["skip-cert-verify"]||s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","naive"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s["server-cert-fingerprint"]=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],pe(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"],delete s["ip-cidr"],delete s["ipv6-cidr"],n!=="internal"){for(let a in s)(s[a]==null||/^_/i.test(a))&&delete s[a];Fc(s[`${s.network}-opts`])}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 da(o,n,i)}}}var iwe=P(x());var e0="Loon",pa={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function vS(){return{produce:(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${e0} does not support network ${t.network} with http upgrade`);switch(t.type){case"ss":return bJ(t);case"ssr":return AJ(t);case"trojan":return SJ(t);case"vmess":return _J(t,n["include-unsupported-proxy"]);case"vless":return DJ(t,n["include-unsupported-proxy"]);case"http":return FJ(t);case"socks5":return BJ(t);case"wireguard":return IJ(t);case"hysteria2":return $J(t)}if(t.type==="anytls"){if(t.network&&!["tcp"].includes(t.network))throw new Error(`Platform ${e0} does not support proxy type ${t.type} with network ${t.network}`);return CJ(t)}throw new Error(`Platform ${e0} does not support proxy type: ${t.type}`)}}}function Bc(e,t){let r=EJ(t);r&&e.append(`,tls-profile=${r}`)}function Wl(e,t){let r=yJ(t);r&&e.append(`,alpn="${r}"`)}function wJ(e){let t=e?.["plugin-opts"]?.alpn??e?.alpn;return(Array.isArray(t)?t:`${t||""}`.split(",")).map(n=>`${n}`.trim()).filter(n=>n!=="").join(",")}function M9(e,t){if(t.plugin!=="shadow-tls"||!t["plugin-opts"])return;let r=t["plugin-opts"].password,n=t["plugin-opts"].host,i=t["plugin-opts"].version;if(!r)return;if(e.append(`,shadow-tls-password=${r}`),n&&e.append(`,shadow-tls-sni=${n}`),i){if(i<2)throw new Error(`shadow-tls version ${i} is not supported`);e.append(`,shadow-tls-version=${i}`)}Bc(e,t);let o=wJ(t);o&&e.append(`,alpn="${o}"`),e.appendIfPresent(`,udp-port=${t["udp-port"]}`,"udp-port")}function y2(e,t){e.appendIfPresent(`,sni=${t.sni}`,"sni"),e.appendIfPresent(`,public-key="${t["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),e.appendIfPresent(`,short-id=${t["reality-opts"]["short-id"]}`,"reality-opts.short-id")}function yJ(e){return(Array.isArray(e.alpn)?e.alpn:`${e.alpn||""}`.split(",")).map(r=>`${r}`.trim()).filter(r=>r!=="").join(",")}function EJ(e){let t=`${e._loon_tls_profile||""}`.trim();if(["default","chrome","ios18","ios26"].includes(t))return t;switch(`${e["client-fingerprint"]||""}`.trim()){case"chrome":return"chrome";case"ios":return"ios26"}}function bJ(e){let t=new ft(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}"`),pe(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`)}M9(t,e),e["udp-over-tcp"]&&(e["udp-over-tcp-version"]===2?e.plugin==="obfs"?z.error(`Platform ${e0} shadowsocks udp-over-tcp does not support obfs`):t.append(",udp-over-tcp=true"):z.error(`Platform ${e0} shadowsocks only supports udp-over-tcp-version 2`)),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=pa[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function AJ(e){let t=new ft(e);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"),M9(t,e),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=pa[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function SJ(e){let t=!!e["reality-opts"],r=new ft(e);if(r.append(`${e.name}=trojan,${e.server},${e.port},"${e.password}"`),e.network==="tcp"&&delete e.network,pe(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 throw new Error(`network ${e.network} is unsupported`);r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),Bc(r,e),Wl(r,e),t?y2(r,e):(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")),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=pa[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function CJ(e){let t=!!e["reality-opts"],r=new ft(e);r.append(`${e.name}=anytls,${e.server},${e.port},"${e.password}"`);for(let i of["idle-session-timeout","max-stream-count"])pe(e,i)&&Number.isInteger(e[i])&&r.append(`,${i}=${e[i]}`);r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),Bc(r,e),Wl(r,e),t?y2(r,e):(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")),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=pa[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function _J(e){let t=!!e["reality-opts"],r=_9(e.cipher),n=new ft(e);if(n.append(`${e.name}=vmess,${e.server},${e.port},${r},"${e.uuid}"`),e.network==="tcp"&&delete e.network,pe(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 o=e["http-opts"]?.path,s=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(o)?o[0]:o}`,"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"),(e.tls||t)&&(Bc(n,e),Wl(n,e)),t?y2(n,e):(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")),pe(e,"aead")?n.append(`,alterId=${e.aead?0:1}`):n.append(`,alterId=${e.alterId}`),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=pa[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function DJ(e){if(e.encryption&&e.encryption!=="none")throw new Error("VLESS encryption is not supported");let t=!1,r=!!e["reality-opts"];if(typeof e.flow<"u")if(["xtls-rprx-vision"].includes(e.flow))t=!0;else throw new Error(`VLESS flow(${e.flow}) is not supported`);let n=new ft(e);if(n.append(`${e.name}=vless,${e.server},${e.port},"${e.uuid}"`),e.network==="tcp"&&delete e.network,pe(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 o=e["http-opts"]?.path,s=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(o)?o[0]:o}`,"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"),(e.tls||r||t)&&(Bc(n,e),Wl(n,e)),t&&n.appendIfPresent(`,flow=${e.flow}`,"flow"),r?y2(n,e):(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=pa[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function FJ(e){let t=new ft(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"),e.tls&&(Bc(t,e),Wl(t,e)),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=pa[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function BJ(e){let t=new ft(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"),e.tls&&(Bc(t,e),Wl(t,e)),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=pa[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function IJ(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 ft(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(a=>hr(a));let s=e.dns.find(a=>jr(a));s||(s=e.dns.find(a=>!jr(a)&&!hr(a))),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 o=pa[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${o}`,"ip-version"),e["block-quic"]==="on"?t.append(",block-quic=true"):e["block-quic"]==="off"&&t.append(",block-quic=false"),t.toString()}function $J(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new ft(e);t.append(`${e.name}=Hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,"${e.password}"`,"password"),pe(e,"ports")&&`${e.ports}`.trim().length>0&&t.append(`,server-ports="${e.ports}"`),pe(e,"hop-interval")&&`${e["hop-interval"]}`.trim().length>0&&t.append(`,hop-interval=${e["hop-interval"]}`),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"),Bc(t,e),Wl(t,e),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=pa[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}var vwe=P(x());var awe=P(x());function wS(e,{allowZeroLowerBound:t=!0,allowZeroUpperBound:r=!0}={}){if(typeof e!="string"&&typeof e!="number")return;let n=f=>{let m=f.trim();if(!/^\+?\d+$/.test(m))return;let p=parseInt(m,10);return Number.isSafeInteger(p)?p:void 0},o=`${e}`.trim().split("-"),s=t?0:1,a=r?0:1;if(o.length===1){let f=n(o[0]),m=Math.max(s,a);return f>=m?{lowerBound:f,upperBound:f}:void 0}if(o.length!==2)return;let u=n(o[0]),l=n(o[1]);if(!(u==null||l==null))return u>=s&&l>=a&&l>=u?{lowerBound:u,upperBound:l}:void 0}function PJ(e){return wS(e,{allowZeroUpperBound:!1})}function j9(e){return wS(e,{allowZeroLowerBound:!1,allowZeroUpperBound:!1})}function t0(e){let t=PJ(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?n:`${r}-${n}`}function Nh(e){let t=j9(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?`${n}`:`${r}-${n}`}function r0(e){let t=j9(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?n:`${r}-${n}`}function Ic(e){let t=wS(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?n:`${r}-${n}`}function $c(e,{allowNegative:t=!0}={}){if(typeof e=="number"&&Number.isFinite(e)&&Number.isSafeInteger(e))return!t&&e<0?void 0:e;if(typeof e!="string")return;let r=e.trim();if(!(t?/^[+-]?\d+$/:/^\+?\d+$/).test(r))return;let i=parseInt(r,10);if(Number.isSafeInteger(i)&&!(!t&&i<0))return i}function xJ(e,{excludeHost:t=!1}={}){if(!dt(e))return;let r={};for(let[n,i]of Object.entries(e))typeof i=="string"&&(t&&/^host$/i.test(n)||(r[n]=i));return Object.keys(r).length>0?r:void 0}function TJ(e,t){let r=b2(e?.["_v2ray-http-upgrade-ed"]);if(r!=="")return r;let n=b2(Zs(t||"/","ed").value);return n!==""?n:2560}function E2(e,t){return t?.["v2ray-http-upgrade-fast-open"]?uS(e||"/","ed",TJ(t,e)):e}function yS(e,t){let r=t?.["max-early-data"],n=b2(r);if(n==="")return r!=null&&`${r}`!=""?e==null?e:Zs(e,"ed").path:e;let i=t?.["early-data-header-name"];return i&&i!=="Sec-WebSocket-Protocol"?e==null?e:Zs(e,"ed").path:uS(e||"/","ed",n)}function b2(e){return e==null||`${e}`==""||Fu(e)==null?"":`${e}`}function RJ(e){return $c(e)}function kJ(e){return Ic(e)}function K9({defaultDns:e,dnsFieldPath:t,echOptsPath:r,proxyName:n,queryServerName:i}){let o=n||"\u672A\u547D\u540D\u8282\u70B9";z.warn(`URI ECH: \u8282\u70B9 "${o}" \u7684 ${r} \u5DF2\u5F00\u542F\u4E14\u8BBE\u7F6E query-server-name="${i}", \u4F46\u672A\u8BBE\u7F6E ${t}; \u5DF2\u4F7F\u7528\u9ED8\u8BA4 DNS ${e}. \u5982\u9700\u81EA\u5B9A\u4E49, \u8BF7\u8BBE\u7F6E ${t}.`)}function A2(e,t={}){return e==="h2"?t.host??t.headers?.host??t.headers?.Host:e==="xhttp"?t.host??t.headers?.Host??t.headers?.host:t.headers?.Host??t.headers?.host??t.host}function OJ(e){if(!dt(e))return;let t={},r={"max-connections":"maxConnections","max-concurrency":"maxConcurrency","c-max-reuse-times":"cMaxReuseTimes","h-max-request-times":"hMaxRequestTimes","h-max-reusable-secs":"hMaxReusableSecs"};for(let[i,o]of Object.entries(r)){let s=Ic(e[i]);s!=null&&(t[o]=typeof s=="number"?`${s}`:s)}let n=RJ(e["h-keep-alive-period"]);return n!=null&&(t.hKeepAlivePeriod=n),Object.keys(t).length>0?t:void 0}function V9(e,t,{excludeHostHeader:r=!0,xmuxTarget:n="root"}={}){if(!dt(e)||!dt(t))return;let i=xJ(t.headers,{excludeHost:r});if(i&&(e.headers=i),t["no-grpc-header"]===!0&&(e.noGRPCHeader=!0),t["x-padding-bytes"]&&(e.xPaddingBytes=t["x-padding-bytes"]),t["x-padding-obfs-mode"]===!0&&(e.xPaddingObfsMode=!0),t["x-padding-key"]&&(e.xPaddingKey=t["x-padding-key"]),t["x-padding-header"]&&(e.xPaddingHeader=t["x-padding-header"]),t["x-padding-placement"]&&(e.xPaddingPlacement=t["x-padding-placement"]),t["x-padding-method"]&&(e.xPaddingMethod=t["x-padding-method"]),t["uplink-http-method"]&&(e.uplinkHTTPMethod=t["uplink-http-method"]),t["session-placement"]&&(e.sessionIDPlacement=t["session-placement"]),t["session-key"]&&(e.sessionIDKey=t["session-key"]),typeof t["session-table"]=="string"&&(e.sessionIDTable=t["session-table"]),t["session-length"]!=null){let a=r0(t["session-length"]);a!=null&&(e.sessionIDLength=a)}t["seq-placement"]&&(e.seqPlacement=t["seq-placement"]),t["seq-key"]&&(e.seqKey=t["seq-key"]),t["uplink-data-placement"]&&(e.uplinkDataPlacement=t["uplink-data-placement"]),t["uplink-data-key"]&&(e.uplinkDataKey=t["uplink-data-key"]);let o=kJ(t["uplink-chunk-size"]);if(o!=null&&(e.uplinkChunkSize=o),t["sc-max-each-post-bytes"]!=null){let a=r0(t["sc-max-each-post-bytes"]);a!=null&&(e.scMaxEachPostBytes=a)}if(t["sc-min-posts-interval-ms"]!=null){let a=t0(t["sc-min-posts-interval-ms"]);a!=null&&(e.scMinPostsIntervalMs=a)}let s=OJ(t["reuse-settings"]);s&&(n==="extra"?e.extra={...dt(e.extra)?e.extra:{},xmux:s}:e.xmux=s)}function NJ(e,t={},r={}){if(!dt(e))return;let n=typeof e.network=="string"?e.network.toLowerCase():"",i=n==="xhttp"||n==="splithttp"?"xhttp":void 0,o={};e.server&&(o.address=e.server);let s=$c(e.port,{allowNegative:!1});s!=null&&(o.port=s);let a=dt(e["reality-opts"])?e["reality-opts"]:void 0;a?o.security="reality":e.tls&&(o.security="tls");let u={};e.servername&&(u.serverName=e.servername),e["client-fingerprint"]&&(u.fingerprint=e["client-fingerprint"]),e["skip-cert-verify"]&&(u.allowInsecure=!0),e.alpn&&(u.alpn=Array.isArray(e.alpn)?e.alpn:[e.alpn]);let l=hS(e["ech-opts"],void 0,{dnsFieldPath:"xhttp-opts.download-settings.ech-opts._dns",warnDefaultDns:v=>K9({...v,echOptsPath:"xhttp-opts.download-settings.ech-opts",proxyName:r.name})});if(l.echConfigList&&(u.echConfigList=l.echConfigList),l.echForceQuery&&(u.echForceQuery=l.echForceQuery),l.echSockopt&&(u.echSockopt=Pc(l.echSockopt)),Object.keys(u).length>0&&(o.tlsSettings=u),a){let v={};e.servername&&(v.serverName=e.servername),e["client-fingerprint"]&&(v.fingerprint=e["client-fingerprint"]),a["public-key"]&&(v.publicKey=a["public-key"]),a["short-id"]&&(v.shortId=a["short-id"]),Object.keys(v).length>0&&(o.realitySettings=v)}let f={},m=e.path??t.path;m&&(f.path=m);let p=A2("xhttp",e)??A2("xhttp",t);p&&(f.host=p);let d=e.mode??t.mode;if(d&&(f.mode=d),V9(f,e,{excludeHostHeader:!0,xmuxTarget:"extra"}),Object.keys(f).length>0&&(o.xhttpSettings=f),!(Object.keys(o).length===0&&i==null))return{...o.address!=null?{address:o.address}:{},network:i||"xhttp",...o.port!=null?{port:o.port}:{},...o.security!=null?{security:o.security}:{},...o.tlsSettings!=null?{tlsSettings:o.tlsSettings}:{},...o.realitySettings!=null?{realitySettings:o.realitySettings}:{},...o.xhttpSettings!=null?{xhttpSettings:o.xhttpSettings}:{}}}function LJ(e){let t=e["xhttp-opts"]||{},r={};V9(r,t,{excludeHostHeader:!0,xmuxTarget:"root"});let n=NJ(t["download-settings"],t,e);return n&&(r.downloadSettings=n),Object.keys(r).length>0?r:void 0}function Pc(e){if(Array.isArray(e))return e.map(Pc);if(dt(e)){let t={};for(let[r,n]of Object.entries(e))t[r]=Pc(n);return t}return e}function UJ(e,t){return e==null?Pc(t):Array.isArray(e)||Array.isArray(t)?Pc(e):dt(e)&&dt(t)?z9(e,t):Pc(e)}function z9(e,t){let r=dt(e)?Pc(e):{};if(!dt(t))return r;for(let[n,i]of Object.entries(t)){if(!Object.prototype.hasOwnProperty.call(r,n)){r[n]=Pc(i);continue}r[n]=UJ(r[n],i)}return r}function HJ(e){if(typeof e._extra=="string")return e._extra;if(dt(e._extra))return JSON.stringify(e._extra)}function MJ(e){let t=HJ(e);if(t!=null)return t;if(e.network!=="xhttp")return e._extra||"";let r=LJ(e),n=z9(r,e._extra_unsupported);return Object.keys(n).length>0?JSON.stringify(n):""}function q9(e){let t="none",r=e["reality-opts"],n="",i="",o="";if(r){t="reality";let q=e["reality-opts"]?.["public-key"];q&&(i=`&pbk=${encodeURIComponent(q)}`);let J=e["reality-opts"]?.["short-id"];J&&(n=`&sid=${encodeURIComponent(J)}`);let Y=e["reality-opts"]?.["_spider-x"];Y&&(o=`&spx=${encodeURIComponent(Y)}`)}else e.tls&&(t="tls");let s="";e.alpn&&(s=`&alpn=${encodeURIComponent(Array.isArray(e.alpn)?e.alpn:e.alpn.join(","))}`);let a="";e["skip-cert-verify"]&&(a="&allowInsecure=1");let u="";e._h2&&(u="&h2=1");let l="";e["tls-fingerprint"]&&(l=`&pcs=${encodeURIComponent(e["tls-fingerprint"])}`);let f="",m=Array.isArray(e._vcn)?e._vcn.join(","):e["name-cert-verify"];(Array.isArray(e._vcn)||m)&&(f=`&vcn=${encodeURIComponent(m)}`);let p="",d=dS(e["ech-opts"],e._echConfigList,{dnsFieldPath:"ech-opts._dns",warnDefaultDns:q=>K9({...q,echOptsPath:"ech-opts",proxyName:e.name})});d&&(p=`&ech=${encodeURIComponent(d)}`);let v="";e.sni&&(v=`&sni=${encodeURIComponent(e.sni)}`);let g="";e["client-fingerprint"]&&(g=`&fp=${encodeURIComponent(e["client-fingerprint"])}`);let y="";e.flow&&(y=`&flow=${encodeURIComponent(e.flow)}`);let w="",E=MJ(e);E&&(w=`&extra=${encodeURIComponent(E)}`);let S="";["xhttp"].includes(e.network)&&e[`${e.network}-opts`]?.mode?S=`&mode=${encodeURIComponent(e[`${e.network}-opts`].mode)}`:e._mode&&(S=`&mode=${encodeURIComponent(e._mode)}`);let F="";e._pqv&&(F=`&pqv=${encodeURIComponent(e._pqv)}`);let _="";e.encryption&&(_=`&encryption=${encodeURIComponent(e.encryption)}`);let H=e.network;e.network==="ws"&&e["ws-opts"]?.["v2ray-http-upgrade"]?H="httpupgrade":e.network==="http"?H="tcp":e.network==="h2"&&(H="http");let V=`&type=${encodeURIComponent(H)}`;if(e.network==="http"&&(V+="&headerType=http"),["grpc"].includes(e.network)){V+=`&mode=${encodeURIComponent(e[`${e.network}-opts`]?.["_grpc-type"]||"gun")}`;let q=e[`${e.network}-opts`]?.["_grpc-authority"];q&&(V+=`&authority=${encodeURIComponent(q)}`)}let C=e[`${e.network}-opts`]||{},I=e.network==="ws"&&C?.["v2ray-http-upgrade"],L=C?.[`${e.network}-service-name`],R=C?.path,k=A2(e.network,C),M=b2(e["ws-opts"]?.["max-early-data"]);Array.isArray(R)&&(R=R[0]),I&&C?.["v2ray-http-upgrade-fast-open"]?R=E2(R,C):e.network==="ws"&&e["ws-opts"]?.["max-early-data"]!=null&&R&&(R=Zs(R,"ed").path),R&&(V+=`&path=${encodeURIComponent(R)}`),k&&(V+=`&host=${encodeURIComponent(Array.isArray(k)?k[0]:k)}`),L&&(V+=`&serviceName=${encodeURIComponent(L)}`),e.network==="http"&&e["http-opts"]?.method&&(V+=`&method=${encodeURIComponent(e["http-opts"].method)}`),e.network==="kcp"&&(e.seed&&(V+=`&seed=${encodeURIComponent(e.seed)}`),e.headerType&&(V+=`&headerType=${encodeURIComponent(e.headerType)}`)),e.network==="ws"&&!I&&M!==""&&(V+=`&ed=${encodeURIComponent(M)}`);let N=e["ws-opts"]?.["early-data-header-name"];N&&(I||e["ws-opts"]?.["max-early-data"]==null||N!=="Sec-WebSocket-Protocol")&&(V+=`&eh=${encodeURIComponent(N)}`);let D="",O;switch(e["packet-encoding"]!=null?O=`${e["packet-encoding"]}`.trim().toLowerCase():e.xudp?O="xudp":e["packet-addr"]?O="packetaddr":e.udp===!0&&(O=""),O){case"":D="&packetEncoding=none";break;case"packetaddr":D="&packetEncoding=packet";break;case"xudp":D="&packetEncoding=xudp";break}return`vless://${e.uuid}@${e.server}:${e.port}?security=${encodeURIComponent(t)}${V}${D}${s}${a}${l}${f}${p}${u}${v}${g}${y}${n}${o}${i}${S}${w}${F}${_}#${encodeURIComponent(e.name)}`}function Lh(){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(["tuic","hysteria","hysteria2","juicity","trusttunnel"].includes(r.type)&&delete r.tls,!["vmess"].includes(r.type)&&r.server&&hr(r.server)&&(r.server=`[${r.server}]`),r.type){case"socks5":n=`socks://${encodeURIComponent(It.encode(`${r.username??""}:${r.password??""}`))}@${r.server}:${r.port}#${r.name}`;break;case"ss":let i=`${r.cipher}:${r.password}`;n=`ss://${r.cipher?.startsWith("2022-blake3-")?`${encodeURIComponent(r.cipher)}:${encodeURIComponent(r.password)}`:It.encode(i)}@${r.server}:${r.port}${r.plugin?"/":""}`;let o="";if(r.plugin){o+="&plugin=";let fe=r["plugin-opts"];switch(r.plugin){case"obfs":o+=encodeURIComponent(`simple-obfs;obfs=${fe.mode}${fe.host?";obfs-host="+fe.host:""}`);break;case"v2ray-plugin":let Se=Xp(fe.mux);o+=encodeURIComponent(`v2ray-plugin;obfs=${fe.mode};mode=${fe.mode}${fe.host?";obfs-host="+fe.host:""}${fe.host?";host="+fe.host:""}${fe.path?";path="+fe.path:""}${fe.tls?";tls":""}${fe.sni?";sni="+fe.sni:""}${fe["skip-cert-verify"]?";skip-cert-verify="+fe["skip-cert-verify"]:""}${Se!=null?";mux="+Se:""}`);break;case"shadow-tls":o+=encodeURIComponent(`shadow-tls;host=${fe.host};password=${fe.password};version=${fe.version}`);break;default:throw new Error(`Unsupported plugin option: ${r.plugin}`)}}r["udp-over-tcp"]&&(o+="&uot=1"),r.tfo&&(o+="&tfo=1");let s="";if(r.network){let fe=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(fe="httpupgrade"),s=`&type=${encodeURIComponent(fe)}`,["grpc"].includes(r.network)){let je=r[`${r.network}-opts`]?.[`${r.network}-service-name`],yt=r[`${r.network}-opts`]?.["_grpc-authority"];je&&(s+=`&serviceName=${encodeURIComponent(je)}`),yt&&(s+=`&authority=${encodeURIComponent(yt)}`),s+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let Se=r[`${r.network}-opts`]||{},Re=r.network==="ws"&&Se?.["v2ray-http-upgrade"],Ke=Se?.path,Qe=Se?.headers?.Host;Array.isArray(Ke)&&(Ke=Ke[0]),Re?Ke=E2(Ke,Se):r.network==="ws"&&(Ke=yS(Ke,Se)),Ke&&(s+=`&path=${encodeURIComponent(Ke)}`),Qe&&(s+=`&host=${encodeURIComponent(Array.isArray(Qe)?Qe[0]:Qe)}`)}let a="";r["client-fingerprint"]&&(a=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let u="";r.alpn&&(u=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let l=r["reality-opts"],f="",m="",p="",d=r.tls?"&security=tls":"",v="",g="";if(l){d="&security=reality";let fe=r["reality-opts"]?.["public-key"];fe&&(m=`&pbk=${encodeURIComponent(fe)}`);let Se=r["reality-opts"]?.["short-id"];Se&&(f=`&sid=${encodeURIComponent(Se)}`);let Re=r["reality-opts"]?.["_spider-x"];Re&&(p=`&spx=${encodeURIComponent(Re)}`),r._extra&&(g=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(v=`&mode=${encodeURIComponent(r._mode)}`)}r.tls&&(o+=`&sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}`),o+=`${s}${u}${a}${d}${f}${m}${p}${v}${g}#${encodeURIComponent(r.name)}`,n+=o.replace(/^&/,"?");break;case"ssr":n=`${r.server}:${r.port}:${r.protocol}:${r.cipher}:${r.obfs}:${It.encode(r.password)}/`,n+=`?remarks=${It.encode(r.name)}${r["obfs-param"]?"&obfsparam="+It.encode(r["obfs-param"]):""}${r["protocol-param"]?"&protocolparam="+It.encode(r["protocol-param"]):""}`,n="ssr://"+It.encode(n);break;case"vmess":let y="",w=r.network||"tcp";if(r.network==="http"?(w="tcp",y="http"):r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(w="httpupgrade"),n={v:"2",ps:r.name,add:r.server,port:`${r.port}`,id:r.uuid,aid:`${r.alterId||0}`,scy:Tn(r.cipher),net:w,type:y,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 fe=r[`${r.network}-opts`]||{},Se=r.network==="ws"&&fe?.["v2ray-http-upgrade"],Re=fe?.path,Ke=A2(r.network,fe);["grpc"].includes(r.network)?(n.path=r[`${r.network}-opts`]?.["grpc-service-name"],n.type=r[`${r.network}-opts`]?.["_grpc-type"]||"gun",n.host=r[`${r.network}-opts`]?.["_grpc-authority"]):["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`]):(Array.isArray(Re)&&(Re=Re[0]),Se?Re=E2(Re,fe):r.network==="ws"&&(Re=yS(Re,fe)),Re&&(n.path=Re),Ke&&(n.host=Array.isArray(Ke)?Ke[0]:Ke))}n="vmess://"+It.encode(JSON.stringify(n));break;case"vless":n=q9(r);break;case"trojan":let E="";if(r.network){let fe=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(fe="httpupgrade"),E=`&type=${encodeURIComponent(fe)}`,["grpc"].includes(r.network)){let je=r[`${r.network}-opts`]?.[`${r.network}-service-name`],yt=r[`${r.network}-opts`]?.["_grpc-authority"];je&&(E+=`&serviceName=${encodeURIComponent(je)}`),yt&&(E+=`&authority=${encodeURIComponent(yt)}`),E+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let Se=r[`${r.network}-opts`]||{},Re=r.network==="ws"&&Se?.["v2ray-http-upgrade"],Ke=Se?.path,Qe=Se?.headers?.Host;Array.isArray(Ke)&&(Ke=Ke[0]),Re?Ke=E2(Ke,Se):r.network==="ws"&&(Ke=yS(Ke,Se)),Ke&&(E+=`&path=${encodeURIComponent(Ke)}`),Qe&&(E+=`&host=${encodeURIComponent(Array.isArray(Qe)?Qe[0]:Qe)}`)}let S="";r["client-fingerprint"]&&(S=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let F="";r["tls-fingerprint"]&&(F=`&pcs=${encodeURIComponent(r["tls-fingerprint"])}`);let _="",H=Array.isArray(r._vcn)?r._vcn.join(","):r["name-cert-verify"];(Array.isArray(r._vcn)||H)&&(_=`&vcn=${encodeURIComponent(H)}`);let V="";r.alpn&&(V=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let C=r["reality-opts"],I="",L="",R="",k="",M="",N="";if(C){k="&security=reality";let fe=r["reality-opts"]?.["public-key"];fe&&(L=`&pbk=${encodeURIComponent(fe)}`);let Se=r["reality-opts"]?.["short-id"];Se&&(I=`&sid=${encodeURIComponent(Se)}`);let Re=r["reality-opts"]?.["_spider-x"];Re&&(R=`&spx=${encodeURIComponent(Re)}`),r._extra&&(N=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(M=`&mode=${encodeURIComponent(r._mode)}`)}n=`trojan://${r.password}@${r.server}:${r.port}?sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}${E}${V}${S}${F}${_}${k}${I}${L}${R}${M}${N}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let D=[];r["hop-interval"]&&D.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&D.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&D.push("insecure=1"),r.obfs&&(D.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&D.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&D.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&D.push(`mport=${r.ports}`),r["tls-fingerprint"]&&D.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&D.push("fastopen=1");let O=dS(r["ech-opts"]);O&&D.push(`ech=${encodeURIComponent(O)}`),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${D.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let q=[];Object.keys(r).forEach(fe=>{if(!["name","type","server","port"].includes(fe)){let Se=fe.replace(/-/,"_");["alpn"].includes(fe)?r[fe]&&q.push(`${Se}=${encodeURIComponent(Array.isArray(r[fe])?r[fe][0]:r[fe])}`):["skip-cert-verify"].includes(fe)?r[fe]&&q.push("insecure=1"):["tfo","fast-open"].includes(fe)?r[fe]&&!q.includes("fastopen=1")&&q.push("fastopen=1"):["ports"].includes(fe)?q.push(`mport=${r[fe]}`):["auth-str"].includes(fe)?q.push(`auth=${r[fe]}`):["up"].includes(fe)?q.push(`upmbps=${r[fe]}`):["down"].includes(fe)?q.push(`downmbps=${r[fe]}`):["_obfs"].includes(fe)?q.push(`obfs=${r[fe]}`):["obfs"].includes(fe)?q.push(`obfsParam=${r[fe]}`):["sni"].includes(fe)?q.push(`peer=${r[fe]}`):r[fe]&&!/^_/i.test(fe)&&q.push(`${Se}=${encodeURIComponent(r[fe])}`)}}),n=`hysteria://${r.server}:${r.port}?${q.join("&")}#${encodeURIComponent(r.name)}`;break;case"tuic":if(!r.token||r.token.length===0){let fe=[];Object.keys(r).forEach(Se=>{if(!["name","type","uuid","password","server","port","tls"].includes(Se)){let Re=Se.replace(/-/,"_");["alpn"].includes(Se)?r[Se]&&fe.push(`${Re}=${encodeURIComponent(Array.isArray(r[Se])?r[Se][0]:r[Se])}`):["skip-cert-verify"].includes(Se)?r[Se]&&fe.push("allow_insecure=1"):["tfo","fast-open"].includes(Se)?r[Se]&&!fe.includes("fast_open=1")&&fe.push("fast_open=1"):["disable-sni","reduce-rtt"].includes(Se)&&r[Se]?fe.push(`${Re.replace(/-/g,"_")}=1`):["congestion-controller"].includes(Se)?fe.push(`congestion_control=${r[Se]}`):r[Se]&&!/^_/i.test(Se)&&fe.push(`${Re.replace(/-/g,"_")}=${encodeURIComponent(r[Se])}`)}}),n=`tuic://${encodeURIComponent(r.uuid)}:${encodeURIComponent(r.password)}@${r.server}:${r.port}?${fe.join("&")}#${encodeURIComponent(r.name)}`}break;case"anytls":n=q9({...r,uuid:r.password,network:r.network||"tcp"}).replace("vless","anytls");let J=[];Object.keys(r).forEach(fe=>{if(!["name","type","password","server","port","tls"].includes(fe)){let Se=fe.replace(/-/,"_");["alpn"].includes(fe)?r[fe]&&J.push(`${Se}=${encodeURIComponent(Array.isArray(r[fe])?r[fe][0]:r[fe])}`):["skip-cert-verify"].includes(fe)?r[fe]&&J.push("insecure=1"):["udp"].includes(fe)?r[fe]&&J.push("udp=1"):r[fe]&&!/^_|client-fingerprint/i.test(fe)&&["number","string","boolean"].includes(typeof r[fe])&&J.push(`${Se.replace(/-/g,"_")}=${encodeURIComponent(r[fe])}`)}});let Y=n.split("?"),ee=Y[0],se={};Y.length>1&&Y[1].split("#")[0].split("&").forEach(Re=>{let[Ke,Qe]=Re.split("=");Ke&&(se[Ke]=Qe)}),J.forEach(fe=>{let[Se,Re]=fe.split("=");Se&&(se[Se]=Re)});let le=Object.keys(se).map(fe=>`${fe}=${se[fe]}`).join("&"),ve=n.match(/#(.*)$/),we=ve?`#${ve[1]}`:"";n=`${ee}?${le}${we}`;break;case"wireguard":let Pe=[];Object.keys(r).forEach(fe=>{["name","type","server","port","ip","ipv6","ip-cidr","ipv6-cidr","private-key"].includes(fe)||(["public-key"].includes(fe)?Pe.push(`publickey=${encodeURIComponent(r[fe])}`):["udp"].includes(fe)?r[fe]&&Pe.push(`${fe}=1`):r[fe]&&!/^_/i.test(fe)&&Pe.push(`${fe}=${encodeURIComponent(r[fe])}`))});let Le=Js(r,"ipv4"),Oe=Js(r,"ipv6");Le&&Oe?Pe.push(`address=${encodeURIComponent(`${Le},${Oe}`)}`):Le?Pe.push(`address=${encodeURIComponent(Le)}`):Oe&&Pe.push(`address=${encodeURIComponent(Oe)}`),n=`wireguard://${encodeURIComponent(r["private-key"])}@${r.server}:${r.port}/?${Pe.join("&")}#${encodeURIComponent(r.name)}`;break}return n}}}var Awe=P(x());var jJ=Lh();function n0(){return{type:"ALL",produce:r=>{let n=[];return r.map(i=>{try{n.push(jJ.produce(i))}catch(o){z.error(`Cannot produce proxy: ${i.name} Reason: ${o}`)}}),It.encode(n.join(` `))}}}var Dwe=P(x());var S2="QX";function s0(){let e=(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${S2} does not support network ${t.network} with http upgrade`);switch(t.type){case"ss":return qJ(t);case"ssr":return KJ(t);case"trojan":return VJ(t);case"vmess":return zJ(t);case"http":return WJ(t);case"socks5":return XJ(t);case"vless":return GJ(t);case"anytls":return YJ(t)}throw new Error(`Platform ${S2} does not support proxy type: ${t.type}`)};return{produce:(t,r,n={})=>{let i=e(t,r,n);if(t.flow&&t.flow!=="xtls-rprx-vision")throw new Error(`Platform ${S2} does not support flow ${t.flow}`);return t["reality-opts"]&&(t["reality-opts"]["public-key"]&&(i=`${i},reality-base64-pubkey=${t["reality-opts"]["public-key"]}`),t["reality-opts"]["short-id"]&&(i=`${i},reality-hex-shortid=${t["reality-opts"]["short-id"]}`)),i}}}function ES(e){return["http","vmess-http","vemss-http","shadowsocks-http"].includes(e._qx_obfs_http)?e._qx_obfs_http:"http"}function Xl(e,t){let r=pe(t,"name-cert-verify")?"name-cert-verify":"skip-cert-verify";e.appendIfPresent(`,tls-verification=${t["name-cert-verify"]??!t["skip-cert-verify"]}`,r)}function qJ(e){let t=new ft(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t),i=xh(e);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}`),gi(e)&&(e.tls=!0),i)r(",obfs=over-tls"),pe(e,"sni")?r(`,obfs-host=${e.sni}`):n(`,obfs-host=${e.servername}`,"servername");else if(pe(e,"plugin")){if(e.plugin==="obfs"){let o=e["plugin-opts"];o.mode==="http"?r(`,obfs=${ES(e)}`):r(`,obfs=${o.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 gi(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"),Xl(t,e),i||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 KJ(e){let t=new ft(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 VJ(e){let t=new ft(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`trojan=${e.server}:${e.port}`),r(`,password=${e.password}`),pe(e,"network")){if(e.network==="ws")gi(e)?r(",obfs=wss"):r(",obfs=ws"),n(`,obfs-uri=${e["ws-opts"]?.path}`,"ws-opts.path"),n(`,obfs-host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`)}return e.network!=="ws"&&gi(e)&&r(",over-tls=true"),gi(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"),Xl(t,e),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 zJ(e){let t=new ft(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);r(`vmess=${e.server}:${e.port}`);let i=C9(e.cipher);if(r(`,method=${i}`),r(`,password=${e.uuid}`),gi(e)&&(e.tls=!0),pe(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(`,obfs=${ES(e)}`);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 o=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(o)?o[0]:o}`,`${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 gi(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"),Xl(t,e),n(`,tls-host=${e.sni}`,"sni")),pe(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 GJ(e){if(e.encryption&&e.encryption!=="none")throw new Error("VLESS encryption is not supported");let t=new ft(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}`),gi(e)&&(e.tls=!0),pe(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(`,obfs=${ES(e)}`);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 o=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(o)?o[0]:o}`,`${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 gi(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"),Xl(t,e),n(`,tls-host=${e.sni}`,"sni")),n(`,vless-flow=${e.flow}`,"flow"),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function YJ(e){let t=e.network?.trim().toLowerCase();if(t&&t!=="tcp")throw new Error(`Platform ${S2} does not support AnyTLS with transport ${e.network}`);let r=new ft(e),n=r.append.bind(r),i=r.appendIfPresent.bind(r);return n(`anytls=${e.server}:${e.port}`),n(`,password=${e.password}`),e.tls=!0,n(",over-tls=true"),i(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),i(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),i(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),i(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),i(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),Xl(r,e),i(`,tls-host=${e.sni}`,"sni"),i(`,fast-open=${e.tfo}`,"tfo"),i(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),n(`,tag=${e.name}`),r.toString()}function WJ(e){let t=new ft(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"),gi(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),gi(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"),Xl(t,e),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 XJ(e){let t=new ft(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"),gi(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),gi(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"),Xl(t,e),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 gi(e){return e.tls}var xwe=P(x());function i0(){return{type:"ALL",produce:(r,n,i={})=>{let o=r.filter(s=>{if(i["include-unsupported-proxy"])return!0;if(Th(s,["websocket","quic","http2","mkcp","grpc"])){if(s.type==="snell"&&![1,2,3,4,5,6].includes(s.version))return!1;if(JJ(s))return z.error(`Platform Shadowrocket does not support Snell shadow-tls with obfs for proxy ${s.name}. Proxy has been filtered.`),!1;if(["tailscale","sudoku","naive","openvpn","gost-relay","shadowquic"].includes(s.type))return!1;if(["xhttp"].includes(s.network))return z.warn("VLESS XHTTP \u7ED3\u6784\u590D\u6742, Shadowrocket \u53EF\u80FD\u65E0\u6CD5\u5B8C\u5168\u517C\u5BB9"),!0}else return!1;return!0}).map(s=>{if(f2(s),s.type==="vmess"?(pe(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),pe(s,"sni")&&(s.servername=s.sni,delete s.sni),s.cipher=Tn(s.cipher)):s.type==="tuic"?(pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!pe(s,"version")&&(s.version=5)):s.type==="hysteria"?(pe(s,"auth_str")&&!pe(s,"auth-str")&&(s["auth-str"]=s.auth_str),pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="hysteria2"?(pe(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),pe(s,"tfo")&&!pe(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.ip=Js(s,"ipv4"),s.ipv6=Js(s,"ipv6")):s.type==="snell"?(s.version<3&&delete s.udp,s.plugin==="shadow-tls"&&s["plugin-opts"]&&(s["obfs-opts"]={mode:"shadow-tls",host:s["plugin-opts"].host,password:s["plugin-opts"].password,version:s["plugin-opts"].version},s["plugin-opts"].alpn&&(s["obfs-opts"].alpn=s["plugin-opts"].alpn),delete s.plugin,delete s["plugin-opts"])):s.type==="vless"?pe(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"?xh(s)&&pe(s,"sni")&&(s.servername=s.sni):["anytls"].includes(s.type)&&s.reuse!=null&&!s.reuse&&(s["disable-reuse"]=!0,delete s.reuse),["vmess","vless"].includes(s.type)&&s.network==="http"){let a=s["http-opts"]?.path;pe(s,"http-opts.path")&&!Array.isArray(a)&&(s["http-opts"].path=[a]);let u=s["http-opts"]?.headers?.Host;pe(s,"http-opts.headers.Host")&&!Array.isArray(u)&&(s["http-opts"].headers.Host=[u])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let a=s["h2-opts"]?.path;pe(s,"h2-opts.path")&&Array.isArray(a)&&(s["h2-opts"].path=a[0]);let u=s["h2-opts"]?.host??s["h2-opts"]?.headers?.host??s["h2-opts"]?.headers?.Host;(pe(s,"h2-opts.host")||pe(s,"h2-opts.headers.host")||pe(s,"h2-opts.headers.Host"))&&(s["h2-opts"].host=Array.isArray(u)?u:[u]),s["h2-opts"]?.headers&&(delete s["h2-opts"].headers.host,delete s["h2-opts"].headers.Host,Object.keys(s["h2-opts"].headers).length===0&&delete s["h2-opts"].headers)}if(["ws"].includes(s.network)){let a=`${s.network}-opts`;s[a]=s[a]||{},s[a].path||(s[a].path="/"),Dc(s[a])}if(s["plugin-opts"]?.tls&&pe(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["plugin-opts"]["skip-cert-verify"]||s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","naive"].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"],pe(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"],delete s["ip-cidr"],delete s["ipv6-cidr"],n!=="internal"){for(let a in s)(s[a]==null||/^_/i.test(a))&&delete s[a];Fc(s[`${s.network}-opts`])}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 da(o,n,i)}}}function JJ(e){return e?.type==="snell"&&e?.plugin==="shadow-tls"&&(pe(e,"obfs-opts.mode")||pe(e,"obfs-opts.host")||pe(e,"obfs-opts.path"))}var Owe=P(x());var o0="Surfboard";function a0(e){return e!=null&&`${e}`.trim().length>0}function Jl(e,t,r=!0){r&&(e.appendIfPresent(`,server-cert-fingerprint-sha256=${t["tls-fingerprint"]}`,"tls-fingerprint"),e.appendIfPresent(`,sni="${t.sni}"`,"sni"),e.appendIfPresent(`,skip-cert-verify=${t["skip-cert-verify"]}`,"skip-cert-verify"))}function C2(){return{produce:t=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${o0} does not support network ${t.network} with http upgrade`);switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return rZ(t);case"trojan":return nZ(t);case"vmess":return sZ(t);case"http":return iZ(t);case"snell":return tZ(t);case"tuic":return ZJ(t);case"socks5":return oZ(t);case"hysteria2":return QJ(t);case"wireguard-surge":return aZ(t)}if(t.type==="anytls"){if(t.network&&(!["tcp"].includes(t.network)||["tcp"].includes(t.network)&&t["reality-opts"]))throw new Error(`Platform ${o0} does not support proxy type ${t.type} with network or REALITY`);return eZ(t)}throw new Error(`Platform ${o0} does not support proxy type: ${t.type}`)}}}function ZJ(e){if(e.token?.length)throw new Error(`Platform ${o0} does not support proxy type ${e.type} v4`);let t=new ft(e);return t.append(`${e.name}=tuic-v5,${e.server},${e.port}`),t.appendIfPresent(`,uuid=${e.uuid}`,"uuid"),t.appendIfPresent(`,password="${e.password}"`,"password"),a0(e.alpn)&&t.append(`,alpn="${Array.isArray(e.alpn)?e.alpn.join(","):e.alpn}"`),a0(e.ports)&&t.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),a0(e["hop-interval"])&&t.append(`,port-hopping-interval=${e["hop-interval"]}`),Jl(t,e),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function QJ(e){if(e.obfs&&e.obfs!=="salamander"||e["obfs-password"]&&e.obfs!=="salamander")throw new Error("Surfboard Hysteria2 only supports salamander obfs");let t=new ft(e);return t.append(`${e.name}=hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),a0(e.ports)&&t.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),a0(e["hop-interval"])&&t.append(`,port-hopping-interval=${e["hop-interval"]}`),e["obfs-password"]&&t.append(`,salamander-password="${e["obfs-password"]}"`),Jl(t,e),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function eZ(e){let t=new ft(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),Jl(t,e),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function tZ(e){if(pe(e,"version")&&![1,2,3,4,5].includes(Number(e.version)))throw new Error(`Platform ${o0} does not support snell version ${e.version}`);let t=new ft(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,version=${e.version}`,"version"),t.appendIfPresent(`,psk="${e.psk}"`,"psk"),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"),e.version>=3&&t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function rZ(e){let t=new ft(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","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(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password="${e.password}"`,"password"),pe(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.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function nZ(e){let t=new ft(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),G9(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),Jl(t,e),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function sZ(e){let t=new ft(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),G9(t,e),pe(e,"aead")?t.append(`,vmess-aead=${e.aead}`):t.append(`,vmess-aead=${e.alterId===0}`),t.appendIfPresent(`,tls=${e.tls}`,"tls"),Jl(t,e,!!e.tls),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function iZ(e){let t=new ft(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"),Jl(t,e,!!e.tls),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function oZ(e){let t=new ft(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"),Jl(t,e,!!e.tls),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function aZ(e){let t=new ft(e);return t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function G9(e,t){if(pe(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),pe(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),pe(t,"ws-opts.headers"))){let r=t["ws-opts"].headers,n=Object.keys(r).map(i=>{let o=r[i];return["Host"].includes(i)&&(o=`"${o}"`),`${i}:${o}`}).join("|");et(n)&&e.append(`,ws-headers=${n}`)}}else{if(["tcp"].includes(t.network)&&t["reality-opts"])throw new Error("reality is unsupported");if(!["tcp"].includes(t.network))throw new Error(`network ${t.network} is unsupported`)}}var Kwe=P(x());var uZ={ipv4:"ipv4_only",ipv6:"ipv6_only","v4-only":"ipv4_only","v6-only":"ipv6_only","ipv4-prefer":"prefer_ipv4","ipv6-prefer":"prefer_ipv6","prefer-v4":"prefer_ipv4","prefer-v6":"prefer_ipv6"},Rn=(e,t)=>{let r=uZ[e["ip-version"]];e._dns_server&&r&&(t.domain_resolver={server:e._dns_server,strategy:r})},kn=(e,t)=>{e._domain_resolver&&(typeof e._domain_resolver=="string"?t.domain_resolver={...t.domain_resolver??{},server:e._domain_resolver}:t.domain_resolver={...t.domain_resolver??{},...e._domain_resolver})},cZ=e=>{let t=e["control-http-client"];return t==null?!1:typeof t=="string"?t.trim()!=="":dt(t)?Object.values(t).some(r=>r!=null&&r!==""):!0},On=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},yo=(e,t)=>{if(["tcp","udp"].includes(e._network)){t.network=e._network;return}e.udp===!1&&(t.network="tcp")},Ps=(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},Eo=(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))))},AS=(e,t)=>{let r={type:"ws",headers:{}};if(e["ws-opts"]){let{path:n="",headers:i={},"max-early-data":o,"early-data-header-name":s}=e["ws-opts"];if(r.early_data_header_name=s,r.max_early_data=o?parseInt(o,10):void 0,n!==""&&(r.path=`${n}`),Object.keys(i).length>0){let a={};for(let l of Object.keys(i)){let f=i[l];f!==""&&(Array.isArray(f)||(f=[`${f}`]),f.length>0&&(a[l]=f))}let{Host:u}=a;if(u.length===1)for(let l of`Host:${u[0]}`.split(` `)){let[f,m]=l.split(":");m.trim()!==""&&(a[f.trim()]=m.trim().split(","))}r.headers=a}}if(e["ws-headers"]){let n={};for(let o of Object.keys(e["ws-headers"])){let s=e["ws-headers"][o];s!==""&&(Array.isArray(s)||(s=[`${s}`]),s.length>0&&(n[o]=s))}let{Host:i}=n;if(i.length===1)for(let o of`Host:${i[0]}`.split(` `)){let[s,a]=o.split(":");a.trim()!==""&&(n[s.trim()]=a.trim().split(","))}for(let o of Object.keys(n))r.headers[o]=n[o]}if(e["ws-path"]&&e["ws-path"]!==""&&(r.path=`${e["ws-path"]}`),r.path){let{value:n,parsed:i}=aS(r.path,"ed");n!==""&&(r.path=Zs(r.path,"ed").path,r.early_data_header_name="Sec-WebSocket-Protocol",r.max_early_data=i)}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},W9=(e,t)=>{let r={type:"http",headers:{}};if(e["http-opts"]){let{method:n="",path:i="",headers:o={}}=e["http-opts"];n!==""&&(r.method=n),Array.isArray(i)?r.path=`${i[0]}`:i!==""&&(r.path=`${i}`);for(let s of Object.keys(o)){let a=o[s];if(a!==""){if(s.toLowerCase()==="host"){let u=a;Array.isArray(u)||(u=`${u}`.split(",").map(l=>l.trim())),u.length>0&&(r.host=u);continue}Array.isArray(a)||(a=`${a}`.split(",").map(u=>u.trim())),a.length>0&&(r.headers[s]=a)}}}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(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},X9=(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(o=>o.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},SS=(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},lZ=(e,t)=>{let r=Array.isArray(e)?e:[e],n=[];for(let i of r){let o=`${i}`.trim().replace(/\\r\\n/g,` `).replace(/\\n/g,` `);if(o!=="")for(let s of o.split(/\r?\n/)){let a=s.trim();a!==""&&n.push(a)}}if(n.length!==0)return n.some(i=>/^-----BEGIN [A-Za-z0-9 -]+-----$/.test(i))?n:[`-----BEGIN ${t}-----`,...n,`-----END ${t}-----`]},fZ=["chrome","firefox","edge","safari","360","qq","ios","android","random","randomized"],J9=e=>{let t=`${e||""}`.trim().toLowerCase();if(fZ.includes(t))return t},Bu=(e,t)=>{if(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"]!==""){let r=J9(e["client-fingerprint"]);r&&(t.tls.utls={...t.tls.utls,enabled:!0,fingerprint:r})}if(e._ech&&dt(e._ech))t.tls.ech=e._ech;else if(e["ech-opts"]&&dt(e["ech-opts"])){t.tls.ech=t.tls.ech||{},t.tls.ech.enabled=e["ech-opts"].enable;let r=e["ech-opts"].config;if(Array.isArray(r)||typeof r=="string"){let n=lZ(r,"ECH CONFIGS");n&&(t.tls.ech.config=n)}t.tls.ech.query_server_name=e["ech-opts"]["query-server-name"],t.tls.ech.config_path=e["ech-opts"]["config-path"],t.tls.ech.fragment=e["ech-opts"].fragment,t.tls.ech.fragment_fallback_delay=e["ech-opts"]["fragment-fallback-delay"],t.tls.ech.record_fragment=e["ech-opts"]["record-fragment"]}e._curve_preferences&&Array.isArray(e._curve_preferences)&&(t.tls.curve_preferences=e._curve_preferences),e._fragment&&(t.tls.fragment=!!e._fragment),e._fragment_fallback_delay&&(t.tls.fragment_fallback_delay=e._fragment_fallback_delay),e._record_fragment&&(t.tls.record_fragment=!!e._record_fragment),e._certificate&&(t.tls.certificate=e._certificate),e._certificate_path&&(t.tls.certificate_path=e._certificate_path),e._certificate_public_key_sha256&&(t.tls.certificate_public_key_sha256=e._certificate_public_key_sha256),e._client_certificate&&(t.tls.client_certificate=e._client_certificate),e._client_certificate_path&&(t.tls.client_certificate_path=e._client_certificate_path),e._client_key&&(t.tls.client_key=e._client_key),e._client_key_path&&(t.tls.client_key_path=e._client_key_path),t.tls.enabled||delete t.tls},hZ=(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),Ps(e,t),On(e,t),Rn(e,t),kn(e,t),t},dZ=(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),Ps(e,t),On(e,t),Bu(e,t),Rn(e,t),kn(e,t),t},pZ=(e={})=>{let t={tag:e.name,type:"socks",server:e.server,server_port:parseInt(`${e.port}`,10),version:"5"};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2}),e["fast-open"]&&(t.udp_fragment=!0),yo(e,t),Ps(e,t),On(e,t),Rn(e,t),kn(e,t),t},mZ=(e={})=>{let t=_2(e),r={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:D2(e)};return e.uot&&(r.udp_over_tcp=!0),e["udp-over-tcp"]&&(r.udp_over_tcp={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2}),yo(e,r),Eo(e.smux,r),{type:"ss-with-st",ssPart:r,stPart:bS(e,t)}},D2=(e={})=>`${e.name}_shadowtls`,_2=(e={})=>{if(e.plugin==="shadow-tls"&&e["plugin-opts"])return e["plugin-opts"];if(e.type==="snell"&&e["obfs-opts"]?.mode==="shadow-tls")return{host:e["obfs-opts"].host,password:e["obfs-opts"].password,version:e["obfs-opts"].version,alpn:e["obfs-opts"].alpn}},Y9=e=>{if(typeof e=="string")return e.split(",").map(t=>t.trim()).filter(t=>t!=="");if(Array.isArray(e))return e},bS=(e={},t)=>{if(!t)throw new Error("shadow-tls plugin options are missing");let r=J9(e["client-fingerprint"]),n={tag:D2(e),type:"shadowtls",server:e.server,server_port:parseInt(`${e.port}`,10),version:t.version,password:t.password,tls:{enabled:!0,server_name:t.host}};if(e["skip-cert-verify"]&&(n.tls.insecure=!0),r&&(n.tls.utls={enabled:!0,fingerprint:r}),n.server_port<0||n.server_port>65535)throw"\u7AEF\u53E3\u503C\u975E\u6CD5";let i=Y9(t.alpn)??Y9(e.alpn);return i&&(n.tls.alpn=i),e["fast-open"]===!0&&(n.udp_fragment=!0),Ps(e,n),On(e,n),Rn(e,n),kn(e,n),n},gZ=(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),yo(e,t),Ps(e,t),On(e,t),Eo(e.smux,t),Rn(e,t),kn(e,t),e.plugin){let r=[];e.plugin==="obfs"&&(t.plugin="obfs-local",t.plugin_opts="",e["obfs-host"]&&(e["plugin-opts"].host=e["obfs-host"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"mode":r.push(`obfs=${e["plugin-opts"].mode}`);break;case"host":r.push(`obfs-host=${e["plugin-opts"].host}`);break;default:r.push(`${n}=${e["plugin-opts"][n]}`);break}})),e.plugin==="v2ray-plugin"&&(t.plugin="v2ray-plugin",e["ws-host"]&&(e["plugin-opts"].host=e["ws-host"]),e["ws-path"]&&(e["plugin-opts"].path=e["ws-path"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"tls":e["plugin-opts"].tls&&r.push("tls");break;case"host":r.push(`host=${e["plugin-opts"].host}`);break;case"path":r.push(`path=${e["plugin-opts"].path}`);break;case"headers":r.push(`headers=${JSON.stringify(e["plugin-opts"].headers)}`);break;case"mux":{let i=Xp(e["plugin-opts"].mux);i&&(t.multiplex={enabled:!0}),r.push(`mux=${i}`);break}default:r.push(`${n}=${e["plugin-opts"][n]}`)}})),t.plugin_opts=r.join(";")}return t},vZ=(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),yo(e,t),Ps(e,t),On(e,t),Eo(e.smux,t),Rn(e,t),kn(e,t),t},wZ=e=>{if(e==null)return;let t=`${e}`.trim();return/^\d+$/.test(t)?parseInt(t,10):NaN},yZ=(e={},t=!1)=>{let r=wZ(e.version),n=_2(e),i=t?[1,2,3,4,5,6]:[4,5,6];if(r!=null&&(!i.includes(r)||Number.isNaN(r)))throw new Error(`Platform sing-box does not support snell version ${e.version}`);let o=!t&&r===5?4:r,s={tag:e.name,type:"snell",server:e.server,server_port:parseInt(`${e.port}`,10),psk:e.psk};if(s.server_port<0||s.server_port>65535)throw"invalid port";return o!=null&&(s.version=o),e._userkey&&(s.userkey=e._userkey),o===6?e.mode&&(s.mode=e.mode):(e["obfs-opts"]?.mode&&e["obfs-opts"].mode!=="shadow-tls"&&(s.obfs_mode=e["obfs-opts"].mode),e["obfs-opts"]?.host&&e["obfs-opts"]?.mode!=="shadow-tls"&&(s.obfs_host=e["obfs-opts"].host)),e.reuse&&(r==null||r>=4)&&(s.reuse=!0),yo(e,s),n?(s.detour=D2(e),delete s.server,delete s.server_port):(e["fast-open"]&&(s.udp_fragment=!0),Ps(e,s),On(e,s),Rn(e,s),kn(e,s)),s},EZ=["","packetaddr","xudp"],bZ=e=>{let t=`${e}`.trim().toLowerCase();if(EZ.includes(t))return t},Z9=(e,t)=>{if(e["packet-encoding"]!=null){let r=bZ(e["packet-encoding"]);r!=null&&(t.packet_encoding=r)}else e.xudp?t.packet_encoding="xudp":e["packet-addr"]&&(t.packet_encoding="packetaddr")},AZ=(e,t)=>{Z9(e,t),e["global-padding"]!=null&&(t.global_padding=!!e["global-padding"]),e["authenticated-length"]!=null&&(t.authenticated_length=!!e["authenticated-length"])},SZ=(e={})=>{let t={tag:e.name,type:"vmess",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,security:Tn(e.cipher),alter_id:parseInt(`${e.alterId}`,10),tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return AZ(e,t),e["fast-open"]&&(t.udp_fragment=!0),e.network==="ws"&&AS(e,t),e.network==="h2"&&X9(e,t),e.network==="http"&&W9(e,t),e.network==="grpc"&&SS(e,t),yo(e,t),Ps(e,t),On(e,t),Bu(e,t),Eo(e.smux,t),Rn(e,t),kn(e,t),t},CZ=(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 Z9(e,t),e["fast-open"]&&(t.udp_fragment=!0),e.flow!=null&&(t.flow=e.flow),e.network==="ws"&&AS(e,t),e.network==="h2"&&X9(e,t),e.network==="http"&&W9(e,t),e.network==="grpc"&&SS(e,t),yo(e,t),Ps(e,t),On(e,t),Eo(e.smux,t),Bu(e,t),Rn(e,t),kn(e,t),t},_Z=(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"&&SS(e,t),e.network==="ws"&&AS(e,t),yo(e,t),Ps(e,t),On(e,t),Bu(e,t),Eo(e.smux,t),Rn(e,t),kn(e,t),t},DZ=(e={})=>{let t={tag:e.name,type:"naive",server:e.server,server_port:parseInt(`${e.port}`,10),tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp={enabled:!0,version:!e["udp-over-tcp-version"]||e["udp-over-tcp-version"]===1?1:2});let r=parseInt(`${e["insecure-concurrency"]}`,10);return Number.isInteger(r)&&r>=0&&(t.insecure_concurrency=r),e["extra-headers"]&&(t.extra_headers=e["extra-headers"]),e.quic&&(t.quic=!!e.quic),e["quic-congestion-control"]&&(t.quic_congestion_control=e["quic-congestion-control"]),e["fast-open"]&&(t.udp_fragment=!0),Ps(e,t),On(e,t),Bu(e,t),Eo(e.smux,t),Rn(e,t),kn(e,t),t.tls?.insecure&&(z.info("Platform sing-box: insecure is not supported on naive outbound"),delete t.tls.insecure),t},FZ=(e={})=>{let t={tag:e.name,type:"hysteria",server:e.server,server_port:parseInt(`${e.port}`,10),disable_mtu_discovery:!1,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";e["hop-interval"]&&(t.hop_interval=/^\d+$/.test(e["hop-interval"])?`${e["hop-interval"]}s`:e["hop-interval"]),e.ports&&(t.server_ports=e.ports.split(/\s*,\s*/).map(n=>{let i=n.replace(/\s*-\s*/g,":");return i.includes(":")?i:`${i}:${i}`})),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)),yo(e,t),Bu(e,t),On(e,t),Ps(e,t),Eo(e.smux,t),Rn(e,t),kn(e,t),t},BZ=(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";if(e["hop-interval"]&&(t.hop_interval=/^\d+$/.test(e["hop-interval"])?`${e["hop-interval"]}s`:e["hop-interval"]),e.ports&&(t.server_ports=e.ports.split(/\s*,\s*/).map(r=>{let n=r.replace(/\s*-\s*/g,":");return n.includes(":")?n:`${n}:${n}`})),e.up&&(t.up_mbps=parseInt(`${e.up}`,10)),e.down&&(t.down_mbps=parseInt(`${e.down}`,10)),["salamander","gecko"].includes(e.obfs)&&(t.obfs.type=e.obfs),e.obfs==="gecko"){let r=e["obfs-min-packet-size"],n=e["obfs-max-packet-size"],i=r!=null&&`${r}`!="",o=n!=null&&`${n}`!="";if(i||o){let s=i?Fu(`${r}`.trim()):void 0,a=o?Fu(`${n}`.trim()):void 0,u=a!=null?Math.min(a,2048):a,l=s??512,f=u??1200;o&&a!=null&&a>2048&&z.warn(`Gecko obfs max packet size for proxy ${e.name} exceeds 2048, clamped to 2048: ${n}`),i&&(s==null||s<=0)||o&&(a==null||a<=0)||f{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`),yo(e,t),Ps(e,t),On(e,t),Bu(e,t),Eo(e.smux,t),Rn(e,t),kn(e,t),t},$Z=(e={})=>{let t={tag:e.name,type:"anytls",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,tls:{enabled:!0,server_name:e.server,insecure:!1}};return/^\d+$/.test(e["idle-session-check-interval"])&&(t.idle_session_check_interval=`${e["idle-session-check-interval"]}s`),/^\d+$/.test(e["idle-session-timeout"])&&(t.idle_session_timeout=`${e["idle-session-timeout"]}s`),/^\d+$/.test(e["min-idle-session"])&&(t.min_idle_session=parseInt(`${e["min-idle-session"]}`,10)),e["disable-reuse"]!=null&&(t.disable_reuse=!!e["disable-reuse"]),On(e,t),Bu(e,t),Rn(e,t),kn(e,t),t},PZ=(e={})=>{let t=cZ(e),r={tag:e.name,type:"tailscale",control_http_client:e["control-http-client"],udp_timeout:e["udp-timeout"],state_directory:e["state-dir"]||e["state-directory"],auth_key:e["auth-key"],control_url:e["control-url"],ephemeral:e.ephemeral,hostname:e.hostname,accept_routes:e["accept-routes"],exit_node:e["exit-node"],exit_node_allow_lan_access:e["exit-node-allow-lan-access"],advertise_routes:Array.isArray(e["advertise-routes"])?e["advertise-routes"]:void 0,advertise_exit_node:e["advertise-exit-node"],advertise_tags:Array.isArray(e["advertise-tags"])?e["advertise-tags"]:void 0,relay_server_static_endpoints:Array.isArray(e["relay-server-static-endpoints"])?e["relay-server-static-endpoints"]:void 0,system_interface:e["system-interface"],system_interface_name:e["system-interface-name"]};return/^\d+$/.test(e["system-interface-mtu"])&&(r.system_interface_mtu=parseInt(`${e["system-interface-mtu"]}`,10)),/^\d+$/.test(e["relay-server-port"])&&(r.relay_server_port=parseInt(`${e["relay-server-port"]}`,10)),t||(On(e,r),Rn(e,r),kn(e,r)),dt(e["ssh-server"])?r.ssh_server={enabled:e["ssh-server"].enabled!==!1,disable_pty:e["ssh-server"]["disable-pty"],disable_sftp:e["ssh-server"]["disable-sftp"],disable_forwarding:e["ssh-server"]["disable-forwarding"]}:e["ssh-server"]&&(r.ssh_server=!!e["ssh-server"]),r},xZ=(e={})=>{let t=["ipv4","ipv6"].map(n=>Js(e,n)).filter(n=>n),r={system:!!e.system,mtu:e.mtu?parseInt(`${e.mtu}`,10):void 0,udp_timeout:e["udp-timeout"],workers:e.workers?parseInt(`${e.workers}`,10):void 0,tag:e.name,type:"wireguard",server:e.server,server_port:parseInt(`${e.port}`,10),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((!Array.isArray(e.peers)||e.peers.length===0)&&(e.peers=[{}]),e.peers&&e.peers.length>0){r.peers=[];for(let n of e.peers){let i,o;n.server&&n.port?(i=n.server,o=parseInt(`${n.port}`,10)):(i=r.server,o=parseInt(`${r.server_port}`,10));let s={address:i,port:o,persistent_keepalive_interval:n["persistent-keepalive-interval"]?parseInt(`${n["persistent-keepalive-interval"]}`,10):void 0,public_key:n["public-key"]||n.public_key||r.peer_public_key,pre_shared_key:n["pre-shared-key"]||n.pre_shared_key||r.pre_shared_key,allowed_ips:n["allowed-ips"]||n.allowed_ips||["0.0.0.0/0",...e.ipv6?["::/0"]:[]],reserved:[]};if(typeof n.reserved=="string")s.reserved.push(n.reserved);else if(Array.isArray(n.reserved))for(let a of n.reserved)s.reserved.push(a);else delete s.reserved;(!Array.isArray(s.reserved)||s.reserved.length===0)&&(s.reserved=r.reserved),r.peers.push(s)}}return Ps(e,r),On(e,r),Eo(e.smux,r),Rn(e,r),kn(e,r),delete r.server,delete r.server_port,delete r.pre_shared_key,delete r.peer_public_key,delete r.reserved,r};function F2(){return{type:"ALL",produce:(r,n,i={})=>{let o=[],s=new Map(r.filter(u=>u?.plugin==="shadow-tls"&&u?.["plugin-opts"]).map(u=>[u,{plugin:u.plugin,"plugin-opts":u["plugin-opts"]?JSON.parse(JSON.stringify(u["plugin-opts"])):void 0,"obfs-opts":u["obfs-opts"]?JSON.parse(JSON.stringify(u["obfs-opts"])):void 0}]));if(mi().produce(r,"internal",{"include-unsupported-proxy":!0}).map(u=>{let l=o.length;try{let f=s.get(u);f&&(u.plugin=f.plugin,u["plugin-opts"]=f["plugin-opts"],f["obfs-opts"]?u["obfs-opts"]=f["obfs-opts"]:delete u["obfs-opts"]);let m=_2(u),p=!!(m&&(m.password||m.version!=null&&Number(m.version)!==0)),d;if(p&&["vmess","vless","trojan"].includes(u.type)){if(u["reality-opts"])throw new Error(`Platform sing-box cannot chain ShadowTLS with Reality for proxy ${u.name}`);if(["vmess","vless"].includes(u.type)&&u.network==="h2")throw new Error(`Platform sing-box cannot chain ShadowTLS with network h2 for proxy ${u.name}`);if(u.type==="vless"&&u.flow==="xtls-rprx-vision")throw new Error(`Platform sing-box cannot chain ShadowTLS with flow xtls-rprx-vision for proxy ${u.name}`);let v=m.version,g=typeof v=="string"&&v.trim()===""?NaN:Number(v??0),y=g===0?2:g;if(!Number.isInteger(y)||![1,2,3].includes(y))throw new Error(`Platform sing-box does not support shadow-tls version ${v} for proxy ${u.name}`);d=bS(u,{...m,version:y})}if(u.type==="anytls"&&p)throw new Error("Platform sing-box cannot replace AnyTLS TLS with ShadowTLS");if(["xhttp"].includes(u.network))throw new Error(`Platform sing-box does not support network: ${u.network}`);switch(u.type){case"ssh":o.push(hZ(u));break;case"http":o.push(dZ(u));break;case"socks5":if(u.tls)throw new Error(`Platform sing-box does not support proxy type: ${u.type} with tls`);o.push(pZ(u));break;case"ss":if(u.plugin==="shadow-tls"){let{ssPart:v,stPart:g}=mZ(u);o.push(v),o.push(g)}else o.push(gZ(u));break;case"ssr":if(i["include-unsupported-proxy"])o.push(vZ(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type}`);break;case"snell":{o.push(yZ(u,i["include-unsupported-proxy"]));let v=_2(u);v&&o.push(bS(u,v));break}case"vmess":if(!u.network||["tcp","ws","grpc","h2","http"].includes(u.network))o.push(SZ(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type} with network ${u.network}`);break;case"vless":if(u.encryption&&u.encryption!=="none")throw new Error("VLESS encryption is not supported");if(!u.flow||["xtls-rprx-vision"].includes(u.flow))o.push(CZ(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type} with flow ${u.flow}`);break;case"trojan":if(!u.flow)o.push(_Z(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type} with flow ${u.flow}`);break;case"naive":o.push(DZ(u));break;case"hysteria":o.push(FZ(u));break;case"hysteria2":o.push(BZ(u,i["include-unsupported-proxy"]));break;case"tuic":if(!u.token||u.token.length===0)o.push(IZ(u));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":o.push(xZ(u));break;case"anytls":o.push($Z(u));break;case"tailscale":o.push(PZ(u));break;default:throw new Error(`Platform sing-box does not support proxy type: ${u.type}`)}if(d){let v=o[l];v.detour=D2(u),delete v.tls,o.push(d)}if(i["include-unsupported-proxy"]&&u["name-cert-verify"])for(let v=l;v(["wireguard","tailscale"].includes(l.type)?u.endpoints.push(l):u.outbounds.push(l),u),{outbounds:[],endpoints:[]});return JSON.stringify(a,null,2)}}}var Wwe=P(x());function B2(){return{type:"ALL",produce:(r,n,i={})=>{let o=r.filter(s=>!["http","https","socks5","ss","trojan","hysteria2","vless","vmess","tuic","wireguard","anytls","ssh","snell"].includes(s.type)||s.type==="ss"&&(s.plugin==="obfs"&&!["http","tls"].includes(s["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(s.cipher))||s.type==="vmess"&&(!["h2","http","ws","tcp","grpc"].includes(s.network)&&s.network||!r7(s))||s.type==="trojan"&&!["http","ws","tcp"].includes(s.network)&&s.network||s.type==="vless"&&(!["h2","http","ws","tcp","grpc"].includes(s.network)&&s.network||!r7(s)||typeof s.flow<"u"&&!["xtls-rprx-vision",""].includes(s.flow))||s.type==="tuic"&&s.token&&s.token.length!==0||s.type==="snell"&&n7(s.version)===null||["anytls"].includes(s.type)&&s.network&&!["tcp"].includes(s.network)?!1:!(["ws"].includes(s.network)&&s["ws-opts"]?.["v2ray-http-upgrade"])).map(s=>{let a=s;try{let u={...s},l;s.tls&&!s.sni&&(s.sni=s.server);let f=s.prev_hop||s["underlying-proxy"]||s["dialer-proxy"]||s.detour;if(s.type==="http")s={type:s.tls?"https":"http",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,...Q9(s)?{headers:s.headers}:{},tfo:bo(s),...s.tls?{sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Zl(s)}:{}};else if(s.type==="https")s={type:"https",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,...Q9(s)?{headers:s.headers}:{},tfo:bo(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Zl(s)};else if(s.type==="socks5")s={type:s.tls?"socks5_tls":"socks5",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,tfo:bo(s),udp_relay:xc(s),...s.tls?{sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Zl(s)}:{}};else if(s.type==="ss"){if(s={type:"shadowsocks",name:s.name,method:s.cipher==="chacha20-ietf-poly1305"?"chacha20-poly1305":s.cipher,server:s.server,port:s.port,password:s.password,tfo:bo(s),udp_relay:xc(s)},pe(u,"plugin")){if(u.plugin==="obfs")s.obfs=u["plugin-opts"].mode,s.obfs_host=u["plugin-opts"].host,s.obfs_uri=u["plugin-opts"].path;else if(!["shadow-tls"].includes(u.plugin))throw new Error(`plugin ${u.plugin} is not supported`)}}else if(s.type==="hysteria2")s={type:"hysteria2",name:s.name,server:s.server,port:s.port,auth:s.password,...pe(s,"up")?{bandwidth:parseInt(`${s.up}`.match(/\d+/)?.[0]||0,10)}:{},tfo:bo(s),udp_relay:xc(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],port_hopping:s.ports,port_hopping_interval:s["hop-interval"]},u["obfs-password"]&&u.obfs=="salamander"&&(s.obfs="salamander",s.obfs_password=u["obfs-password"]);else if(s.type==="tuic")s={type:"tuic",name:s.name,server:s.server,port:s.port,uuid:s.uuid,password:s.password,sni:s.sni,alpn:Array.isArray(s.alpn)?s.alpn:[s.alpn||"h3"],skip_tls_verify:s["skip-cert-verify"],port_hopping:s.ports,port_hopping_interval:s["hop-interval"]};else if(s.type==="trojan")s.network==="ws"&&(s.websocket={path:s["ws-opts"]?.path,host:s["ws-opts"]?.headers?.Host}),s={type:"trojan",name:s.name,server:s.server,port:s.port,password:s.password,tfo:bo(s),udp_relay:xc(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Zl(s),websocket:s.websocket};else if(s.type==="anytls")s={type:"anytls",name:s.name,server:s.server,port:s.port,password:s.password,tfo:bo(s),udp_relay:xc(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Zl(s)};else if(s.type==="vmess"){let p=Tn(s.cipher);s.network==="ws"?s.transport={[s.tls?"wss":"ws"]:{path:s["ws-opts"]?.path,headers:{Host:s["ws-opts"]?.headers?.Host},sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0}}:s.network==="http"?s.transport={http1:{method:s["http-opts"]?.method,path:Array.isArray(s["http-opts"]?.path)?s["http-opts"]?.path[0]:s["http-opts"]?.path,headers:{Host:Array.isArray(s["http-opts"]?.headers?.Host)?s["http-opts"]?.headers?.Host[0]:s["http-opts"]?.headers?.Host},skip_tls_verify:s["skip-cert-verify"]}}:s.network==="h2"?s.transport={http2:{method:s["h2-opts"]?.method,path:Array.isArray(s["h2-opts"]?.path)?s["h2-opts"]?.path[0]:s["h2-opts"]?.path,headers:s7(s["h2-opts"]),sni:s.sni,skip_tls_verify:s["skip-cert-verify"]}}:s.network==="grpc"?s.transport=t7(s):(s.network==="tcp"||!s.network)&&s.tls&&(s.transport={tls:{sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0}});let d=!1;(pe(s,"aead")&&!s.aead||pe(s,"alterId")&&s.alterId!==0)&&(d=!0),s={type:"vmess",name:s.name,server:s.server,port:s.port,user_id:s.uuid,security:p,tfo:bo(s),legacy:d,udp_relay:xc(s),transport:s.transport}}else if(s.type==="vless"){if(s.encryption&&s.encryption!=="none")throw new Error("VLESS encryption is not supported");s.network==="ws"?s.transport={[s.tls?"wss":"ws"]:{path:s["ws-opts"]?.path,headers:{Host:s["ws-opts"]?.headers?.Host},sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0}}:s.network==="http"?s.transport={http:{method:s["http-opts"]?.method,path:Array.isArray(s["http-opts"]?.path)?s["http-opts"]?.path[0]:s["http-opts"]?.path,headers:{Host:Array.isArray(s["http-opts"]?.headers?.Host)?s["http-opts"]?.headers?.Host[0]:s["http-opts"]?.headers?.Host},skip_tls_verify:s["skip-cert-verify"]}}:s.network==="h2"?s.transport={http2:{method:s["h2-opts"]?.method,path:Array.isArray(s["h2-opts"]?.path)?s["h2-opts"]?.path[0]:s["h2-opts"]?.path,headers:s7(s["h2-opts"]),sni:s.sni,skip_tls_verify:s["skip-cert-verify"]}}:s.network==="grpc"?s.transport=t7(s):(s.network==="tcp"||!s.network)&&(s.transport={[s.tls?"tls":"tcp"]:{sni:s.tls?s.sni:void 0,skip_tls_verify:s.tls?s["skip-cert-verify"]:void 0,reality:Zl(s)}},l=s.flow,l===""&&(l=void 0)),s={type:"vless",name:s.name,server:s.server,port:s.port,user_id:s.uuid,security:s.cipher,tfo:bo(s),udp_relay:xc(s),transport:s.transport,flow:l}}else if(s.type==="wireguard")Array.isArray(s.peers)&&s.peers.length>0&&(s.server=s.peers[0].server,s.port=s.peers[0].port,s.ip=s.peers[0].ip,s.ipv6=s.peers[0].ipv6,s["public-key"]=s.peers[0]["public-key"],s["preshared-key"]=s.peers[0]["pre-shared-key"],s["allowed-ips"]=s.peers[0]["allowed-ips"],s.reserved=s.peers[0].reserved),s={type:"wireguard",name:s.name,local_ipv4:Js(s,"ipv4"),local_ipv6:Js(s,"ipv6"),server:s.server,port:s.port,private_key:s["private-key"],peer_public_key:s["public-key"],preshared_key:s["preshared-key"],reserved:s.reserved?Array.isArray(s.reserved)?s.reserved:s.reserved.split(/\s*\/\s*/).map(p=>p.trim()).filter(p=>p.length>0):void 0,dns_servers:s.dns?Array.isArray(s.dns)?s.dns:s.dns.split(/\s*,\s*/).map(p=>p.trim()).filter(p=>p.length>0):void 0,mtu:s.mtu,keepalive:s.keepalive};else if(s.type==="ssh")s={type:"ssh",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,private_key:s["private-key"],host_keys:s["host-key"],tfo:bo(s)};else if(s.type==="snell"){let p=n7(s.version);s={type:"snell",name:s.name,server:s.server,port:s.port,psk:s.psk,version:p,...p==null||p>=3?{udp_relay:xc(s)}:{},reuse:s.reuse,obfs:s["obfs-opts"]?.mode||s.obfs,obfs_host:s["obfs-opts"]?.host||s["obfs-host"]||s.obfs_host,tfo:bo(s)}}if(["http","https","socks5","ss","trojan","vless","vmess","anytls","ssh","snell"].includes(u.type)&&["shadow-tls"].includes(u.plugin)&&u["plugin-opts"]){if(u["plugin-opts"].version!=3)throw new Error(`shadow-tls version ${u["plugin-opts"].version} is not supported`);s.shadow_tls={password:u["plugin-opts"].password,sni:u["plugin-opts"].host}}let m=kZ(u);if(m&&(OZ(u,s)&&(s.fingerprint_sha256=m),NZ(s.transport,m)),["socks5","ss","trojan","vless","vmess","wireguard","tuic","hysteria2","anytls","ssh","snell"].includes(u.type)&&(["on","true",!0,"1",1].includes(u["block-quic"])?s.block_quic=!0:["off","false",!1,"0",0].includes(u["block-quic"])&&(s.block_quic=!1)),["ss"].includes(u.type)&&s.shadow_tls&&u["udp-port"]>0&&u["udp-port"]<=65535&&(s.udp_port=u["udp-port"]),delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],s.transport){for(let p in s.transport)p!=="grpc"&&(Object.keys(s.transport[p]).length===0||Object.values(s.transport[p]).every(d=>d==null))&&delete s.transport[p];Object.keys(s.transport).length===0&&delete s.transport}if(n!=="internal")for(let p in s)(s[p]==null||/^_/i.test(p))&&delete s[p];return{[s.type]:{...s,type:void 0,prev_hop:f}}}catch(u){return z.error(`Cannot produce proxy: ${s.name} Reason: ${u}`),null}}).filter(Boolean);return da(o,n,i)}}}function Q9(e){return e?.headers&&typeof e.headers=="object"&&Object.keys(e.headers).length>0}function bo(e){return e.tfo??e["fast-open"]}function xc(e){return e.udp??e.udp_relay}function e7(e){if(e!=null&&!(typeof e=="string"&&e.length===0))return e}function Zl(e){let t=e?.["reality-opts"];if(!t)return;let r={},n=e7(t["public-key"]),i=e7(t["short-id"]);return n!=null&&(r.public_key=n),i!=null&&(r.short_id=i),Object.keys(r).length>0?r:void 0}function t7(e){return{grpc:{service_name:e["grpc-opts"]?.["grpc-service-name"],sni:e.sni,reality:Zl(e),skip_tls_verify:e["skip-cert-verify"]}}}function r7(e){if(e.network!=="grpc")return!0;let t=e["grpc-opts"]?.["_grpc-type"];return t==null?!0:`${t}`.trim().toLowerCase()==="gun"}function n7(e){if(e==null)return;let t=`${e}`.trim();return/^[1-5]$/.test(t)?parseInt(t,10):null}function TZ(e,...t){for(let r of t){let n=CS(e?.[r]);if(n)return n}}function RZ(e){return CS(e?.host)||TZ(e?.headers,"host","Host")}function s7(e){let t={};if(e?.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers))for(let[n,i]of Object.entries(e.headers)){if(/^host$/i.test(n))continue;let o=CS(i);o!=null&&(t[n]=o)}let r=RZ(e);return r&&(t.Host=r),Object.keys(t).length>0?t:void 0}function CS(e){if(Array.isArray(e))return e[0];if(e!=null)return e}function kZ(e){let t=e?.["tls-fingerprint"];if(typeof t!="string")return;let r=t.trim();return r.length>0?r:void 0}function OZ(e,t){return["anytls","https","hysteria2","trojan","tuic"].includes(e.type)||e.type==="socks5"&&t.type==="socks5_tls"||e.type==="http"&&t.type==="https"}function NZ(e,t){if(e)for(let r of["grpc","http2","tls","wss"])e[r]&&(e[r].fingerprint_sha256=t)}function i7(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var I2={qx:s0(),QX:s0(),QuantumultX:s0(),surge:Oh(),Surge:Oh(),SurgeMac:Qp(),Loon:vS(),Clash:gS(),meta:mi(),clashmeta:mi(),"clash.meta":mi(),"Clash.Meta":mi(),ClashMeta:mi(),mihomo:mi(),Mihomo:mi(),uri:Lh(),URI:Lh(),v2:n0(),v2ray:n0(),V2Ray:n0(),json:i7(),JSON:i7(),stash:w2(),Stash:w2(),shadowrocket:i0(),Shadowrocket:i0(),ShadowRocket:i0(),surfboard:C2(),Surfboard:C2(),singbox:F2(),"sing-box":F2(),egern:B2(),Egern:B2()};var LEe=P(x());var mEe=P(x()),f$=P(L2()),zQ=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 shadowTLS = {}; 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 (shadowTLS.password && !shadowTLS.version) { shadowTLS.version = 2; } if (shadowTLS.password) { if (shadowTLS.version < 2) { throw new Error("shadow-tls version " + shadowTLS.version + " is not supported"); } proxy.plugin = "shadow-tls"; proxy["plugin-opts"] = { host: shadowTLS.host, password: shadowTLS.password, version: shadowTLS.version, }; if (proxy.alpn) { $set(proxy, "plugin-opts.alpn", proxy.alpn); delete proxy.alpn; } } } function stripQuotes(value) { const trimmed = value.trim(); const quote = trimmed[0]; if ( (quote === '"' || quote === "'") && trimmed[trimmed.length - 1] === quote ) { return trimmed.slice(1, -1); } return trimmed; } function readQuotedHeaderKey(text, start) { const quote = text[start]; let index = start + 1; let hasKey = false; while (index < text.length) { const char = text[index]; if (char === quote) { return hasKey ? index + 1 : -1; } hasKey = true; index++; } return -1; } function startsWithQuotedHeaderKey(text) { const trimmed = text.trim(); if (trimmed[0] !== '"' && trimmed[0] !== "'") return false; const index = readQuotedHeaderKey(trimmed, 0); if (index === -1) return false; let cursor = index; while (cursor < trimmed.length && /\s/.test(trimmed[cursor])) cursor++; return trimmed[cursor] === ":"; } function stripOuterHeadersQuotes(headers) { const trimmed = headers.trim(); const quote = trimmed[0]; if ( (quote === '"' || quote === "'") && trimmed[trimmed.length - 1] === quote && !startsWithQuotedHeaderKey(trimmed) ) { return trimmed.slice(1, -1); } return trimmed; } function isHeaderKeyStart(text, start) { let index = start; while (index < text.length && /\s/.test(text[index])) index++; if (text[index] === '"' || text[index] === "'") { index = readQuotedHeaderKey(text, index); if (index === -1) return false; } else { const keyStart = index; while ( index < text.length && /[!#$%&'*+\-.^_|~0-9A-Za-z]/.test(text[index]) ) index++; if (index === keyStart) return false; } while (index < text.length && /\s/.test(text[index])) index++; return text[index] === ":"; } function isOptionStart(text, start) { let index = start; while (index < text.length && /\s/.test(text[index])) index++; const keyStart = index; while (index < text.length && /[0-9A-Za-z-]/.test(text[index])) index++; if (index === keyStart) return false; while (index < text.length && /\s/.test(text[index])) index++; return text[index] === "="; } function isHeaderValueQuoteEnd(text, index, pairSeparator, allowCommaEnd, containerQuote) { let cursor = index + 1; while (cursor < text.length && /\s/.test(text[cursor])) cursor++; if (cursor >= text.length) return true; if (allowCommaEnd && text[cursor] === "," && isOptionStart(text, cursor + 1)) { return true; } if (text[cursor] === pairSeparator && isHeaderKeyStart(text, cursor + 1)) { return true; } if (containerQuote && text[cursor] === containerQuote) { let next = cursor + 1; while (next < text.length && /\s/.test(text[next])) next++; return next >= text.length || text[next] === ","; } return false; } function findHeaderSeparator(pair) { let quote = ""; for (let index = 0; index < pair.length; index++) { const char = pair[index]; if (quote) { if (char === quote) { quote = ""; } continue; } if (char === '"' || char === "'") { quote = char; continue; } if (char === ":") { return index; } } return -1; } function readUnquotedHeadersEnd(text, start, pairSeparator) { let index = start; let quote = ""; let quoteRole = ""; let seenSeparator = false; while (index < text.length) { const char = text[index]; if (quote) { if (char === quote) { if ( quoteRole === "key" || isHeaderValueQuoteEnd(text, index, pairSeparator, true) ) { quote = ""; quoteRole = ""; } } index++; continue; } if (char === '"' || char === "'") { quote = char; quoteRole = seenSeparator ? "value" : "key"; index++; continue; } if (char === ":" && !seenSeparator) { seenSeparator = true; index++; continue; } if (char === pairSeparator && isHeaderKeyStart(text, index + 1)) { seenSeparator = false; index++; continue; } if (char === ",") break; index++; } return index; } function readQuotedHeadersEnd(text, start, pairSeparator) { const quote = text[start]; let index = start + 1; let innerQuote = ""; let quoteRole = ""; let seenSeparator = false; while (index < text.length) { const char = text[index]; if (innerQuote) { if (char === innerQuote) { if ( quoteRole === "key" || isHeaderValueQuoteEnd(text, index, pairSeparator, false, quote) ) { innerQuote = ""; quoteRole = ""; } } index++; continue; } if (char === quote) { let cursor = index + 1; while (cursor < text.length && /\s/.test(text[cursor])) cursor++; if (cursor >= text.length || text[cursor] === ",") { return index + 1; } } if (char === '"' || char === "'") { innerQuote = char; quoteRole = seenSeparator ? "value" : "key"; index++; continue; } if (char === ":" && !seenSeparator) { seenSeparator = true; index++; continue; } if (char === pairSeparator && isHeaderKeyStart(text, index + 1)) { seenSeparator = false; index++; continue; } index++; } return text.length; } function readHeadersEnd(text, start, pairSeparator) { let index = start; while (index < text.length && /\s/.test(text[index])) index++; if ( (text[index] === '"' || text[index] === "'") && !startsWithQuotedHeaderKey(text.slice(index)) ) { return readQuotedHeadersEnd(text, index, pairSeparator); } return readUnquotedHeadersEnd(text, start, pairSeparator); } function splitHeaders(headers, pairSeparator) { const result = []; let start = 0; let quote = ""; let quoteRole = ""; let seenSeparator = false; for (let index = 0; index < headers.length; index++) { const char = headers[index]; if (quote) { if (char === quote) { if ( quoteRole === "key" || isHeaderValueQuoteEnd(headers, index, pairSeparator, false) ) { quote = ""; quoteRole = ""; } } continue; } if (char === '"' || char === "'") { quote = char; quoteRole = seenSeparator ? "value" : "key"; continue; } if (char === ":" && !seenSeparator) { seenSeparator = true; continue; } if (char === pairSeparator && isHeaderKeyStart(headers, index + 1)) { result.push(headers.slice(start, index)); start = index + 1; seenSeparator = false; } } result.push(headers.slice(start)); return result; } function parseHeaders(headers, pairSeparator) { const result = {}; splitHeaders(stripOuterHeadersQuotes(headers), pairSeparator).forEach((pair) => { const index = findHeaderSeparator(pair); if (index === -1) return; const key = stripQuotes(pair.slice(0, index)); const value = stripQuotes(pair.slice(index + 1)); if (key) { result[key] = value; } }); return result; } function normalizeVmessSecurity(security) { const normalized = String(security || "").trim().toLowerCase(); const supported = ["aes-128-gcm", "chacha20-ietf-poly1305"]; if (!supported.includes(normalized)) return "auto"; return normalized === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : normalized; } function parseAlpn(value) { return stripQuotes(value) .split(",") .map((item) => item.trim()) .filter((item) => item !== ""); } } start = (anytls/shadowsocks/vmess/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) { return proxy; } shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/alpn/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/vmess_method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "auto"; // 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/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/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)? (headers/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/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(); } h2_connect = tag equals "h2-connect" address (username password)? (usernamek passwordk)? (headers/max_streams/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/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 = "h2-connect"; proxy.tls = true; handleShadowTLS(); } http = tag equals "http" address (username password)? (usernamek passwordk)? (headers/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_mode/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/alpn/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/client_cert/sni/cert_verify_name/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/client_cert/sni/cert_verify_name/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/cert_verify_name/alpn/tls_verification/client_cert/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/salamander_password/gecko_password/others)* { proxy.type = "hysteria2"; handleShadowTLS(); } socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; handleShadowTLS(); } socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; proxy.tls = true; handleShadowTLS(); } anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/block_quic/others)* { proxy.type = "anytls"; proxy.tls = true; } trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/block_quic/others)* { proxy.type = "trusttunnel"; proxy.tls = true; } direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* { proxy.type = "direct"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } port_hopping_interval = comma "port-hopping-interval" equals match:$[0-9]+ { proxy["hop-interval"] = parseInt(match.trim()); } username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } password = comma match:[^,]+ { proxy.password = match.join("").replace(/^"(.*)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } tls = comma "tls" equals flag:bool { proxy.tls = flag; } sni = comma "sni" equals match:[^,]+ { const sni = match.join("").replace(/^"(.*)"$/, '$1'); if (sni === "off") { proxy["disable-sni"] = true; } else { proxy.sni = sni; } } cert_verify_name = comma "server-cert-verify-name" equals match:[^,]+ { proxy["name-cert-verify"] = stripQuotes(match.join("")); } 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(); } client_cert = comma "client-cert" equals match:[^,]+ { proxy["keystore-client-cert"] = stripQuotes(match.join("")); } snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); } snell_mode = comma "mode" equals match:[^,]+ { const mode = stripQuotes(match.join("")).trim(); if (["default", "unshaped", "unsafe-raw"].includes(mode)) { proxy.mode = mode; } } usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join(""); } vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; } method = comma "encrypt-method" equals cipher:cipher { proxy.cipher = cipher; } vmess_method = comma "encrypt-method" equals cipher:$[^,]+ { proxy.cipher = normalizeVmessSecurity(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 & { const start = peg$currPos; const index = readHeadersEnd(input, start, "|"); $.headers = input.substring(start, index); peg$currPos = index; return $.headers.trim().length > 0; } { obfs["ws-headers"] = parseHeaders($.headers, "|"); } ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } headers = comma "headers" equals & { const start = peg$currPos; const index = readHeadersEnd(input, start, ";"); $.headers = input.substring(start, index); peg$currPos = index; return $.headers.trim().length > 0; } { proxy.headers = parseHeaders($.headers, ";"); } obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; } obfs_host = comma "obfs-host" equals match:[^,]+ { obfs.host = match.join("").replace(/^"(.*)"$/, '$1'); }; 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()); } max_streams = comma "max-streams" equals match:quoted_integer { proxy["max-streams"] = match; } quoted_integer = '"' match:$[0-9]+ '"' { return parseInt(match.trim()); } / "'" match:$[0-9]+ "'" { return parseInt(match.trim()); } / match:$[0-9]+ { return 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"] = stripQuotes(match.join("")); } 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]+ { shadowTLS.version = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { shadowTLS.host = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { shadowTLS.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); } alpn = comma "alpn" equals match:quoted_value { const values = parseAlpn(match); if (values.length > 0) proxy.alpn = values; } quoted_value = '"' match:$[^"]* '"' { return match; } / "'" match:$[^']* "'" { return match; } / match:$[^,]+ { return match; } uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; } gecko_password = comma "gecko-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'gecko'; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,KS;function ss(){return KS||(KS=f$.default.generate(zQ)),KS}var vEe=P(x()),h$=P(L2()),GQ=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 shadowTLS = {}; 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); } } function handleShadowTLS() { if (shadowTLS.password) { if (shadowTLS.version < 2) { throw new Error("shadow-tls version " + shadowTLS.version + " is not supported"); } proxy.plugin = "shadow-tls"; proxy["plugin-opts"] = { host: shadowTLS.host, password: shadowTLS.password, version: shadowTLS.version, }; if (proxy.alpn) { $set(proxy, "plugin-opts.alpn", proxy.alpn); delete proxy.alpn; } } } function normalizeVmessSecurity(security) { const normalized = String(security || "").trim().toLowerCase(); const supported = ["none", "auto", "aes-128-gcm", "chacha20-ietf-poly1305"]; if (!supported.includes(normalized)) return "auto"; return normalized === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : normalized; } function loonClientFingerprint(tlsProfile) { switch (String(tlsProfile || "").trim()) { case "chrome": return "chrome"; case "ios18": case "ios26": return "ios"; } } } start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls) { 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/tls_profile/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/others)*{ proxy.type = "ssr"; // handle ssr obfs proxy.obfs = obfs.type; handleShadowTLS(); } shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/tls_profile/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/udp_over_tcp/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); } handleShadowTLS(); } vmess = tag equals "vmess"i address vmess_method uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "auto"; proxy.alterId = proxy.alterId || 0; handleTransport(); } vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/flow/public_key/short_id/block_quic/others)* { proxy.type = "vless"; handleTransport(); } trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* { proxy.type = "trojan"; handleTransport(); } anytls = tag equals "anytls"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/idle_session_check_interval/idle_session_timeout/min_idle_session/max_stream_count/others)* { proxy.type = "anytls"; handleTransport(); } hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/udp_relay/fast_open/download_bandwidth/server_ports/hop_interval/salamander_password/ecn/ip_mode/block_quic/others)* { proxy.type = "hysteria2"; } https = tag equals "https"i address (username password)? (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "http"; proxy.tls = true; } http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/block_quic/others)* { proxy.type = "http"; } socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/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; } vmess_method = comma cipher:$[^,]+ { proxy.cipher = normalizeVmessSecurity(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 match:[^,]+ { obfs.host = match.join("").replace(/^"(.*)"$/, '$1'); } 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 match:[^,]+ { transport.host = match.join("").replace(/^"(.*)"$/, '$1'); } 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]+ { shadowTLS.version = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { shadowTLS.host = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { shadowTLS.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_name = comma sni:("tls-name") equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); } sni = comma "sni" equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); } 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'); } tls_profile = comma "tls-profile" equals match:[^,]+ { const tlsProfile = match.join("").replace(/^"(.*)"$/, '$1').trim(); proxy["_loon_tls_profile"] = tlsProfile; const clientFingerprint = loonClientFingerprint(tlsProfile); if (clientFingerprint) proxy["client-fingerprint"] = clientFingerprint; } alpn = comma "alpn" equals '"' match:$[^"]* '"' { const values = match .split(",") .map((item) => item.trim()) .filter((item) => item !== ""); if (values.length > 0) proxy.alpn = values; } 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(""); } server_ports = comma "server-ports" equals '"' match:$[^"]+ '"' { proxy.ports = match.trim().replace(/\s*-\s*/g, "-").replace(/\s*,\s*/g, ","); } hop_interval = comma "hop-interval" equals match:$[0-9]+ { proxy["hop-interval"] = parseInt(match, 10); } 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"; } idle_session_check_interval = comma "idle-session-check-interval" equals match:$[0-9]+ { proxy["idle-session-check-interval"] = parseInt(match.trim()); } idle_session_timeout = comma "idle-session-timeout" equals match:$[0-9]+ { proxy["idle-session-timeout"] = parseInt(match.trim()); } min_idle_session = comma "min-idle-session" equals match:$[0-9]+ { proxy["min-idle-session"] = parseInt(match.trim()); } max_stream_count = comma "max-stream-count" equals match:$[0-9]+ { proxy["max-stream-count"] = parseInt(match.trim()); } udp_over_tcp = comma "udp-over-tcp" equals flag:bool { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,VS;function Ao(){return VS||(VS=h$.default.generate(GQ)),VS}var yEe=P(x()),d$=P(L2()),YQ=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 setQxHttpObfs(type) { // Preserve the original QX http-obfs token for round-trip output, // including the upstream "vemss-http" typo that appears in QX // examples. proxy._qx_obfs_http = type; obfs.type = "http"; return type; } 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; // Some QX share links use obfs-host as the TLS server name for // plain over-tls TCP nodes instead of the explicit tls-host field. // Accept it as a compatibility alias, but do not override tls-host. if (obfs.host && !proxy.sni) { proxy.sni = obfs.host; } } 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/anytls/http/socks5) { return proxy } trojan = "trojan" equals address (password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/obfs/obfs_host/obfs_uri/tag/udp_relay/udp_over_tcp/fast_open/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "trojan"; handleObfs(); } shadowsocks = "shadowsocks" equals address (password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/udp_over_tcp_new/fast_open/tag/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { if (proxy.protocol || proxy.type === "ssr") { proxy.type = "ssr"; if (!proxy.protocol) { proxy.protocol = "origin"; } // handle ssr obfs if (obfs.host) proxy["obfs-param"] = obfs.host; if (obfs.type) proxy.obfs = obfs.type; } else { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts", { mode: obfs.type }); } else if (obfs.type === "ws" || obfs.type === "wss") { proxy.plugin = "v2ray-plugin"; $set(proxy, "plugin-opts.mode", "websocket"); if (obfs.type === "wss") { $set(proxy, "plugin-opts.tls", true); } } else if (obfs.type === 'over-tls') { proxy.tls = true; if (obfs.host) { proxy.sni = obfs.host; } } if (obfs.type && obfs.type !== 'over-tls') { $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_vmess/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead === false) { proxy.alterId = 1; } else { proxy.alterId = 0; } handleObfs(); } vless = "vless" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs_vless/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/reality_base64_pubkey/reality_hex_shortid/vless_flow/others)* { proxy.type = "vless"; proxy.cipher = proxy.cipher || "none"; handleObfs(); } anytls = "anytls" equals address (password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/udp_relay/fast_open/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "anytls"; proxy.tls = true; } http = "http" equals address (username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)*{ proxy.type = "http"; } socks5 = "socks5" equals address (username/password/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* { proxy.type = "socks5"; } address = server:server ":" port:port { proxy.server = server; proxy.port = port; } server = ip/domain domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } ip = & { const start = peg$currPos; let end; let j = start; while (j < input.length) { if (input[j] === ",") break; if (input[j] === ":") end = j; j++; } peg$currPos = end || j; $.ip = input.substring(start, end).trim(); return true; } { return $.ip; } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); } password = comma "password" equals password:[^,]+ { proxy.password = password.join("").trim(); } uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); } method = comma "method" equals cipher:cipher { proxy.cipher = cipher; }; cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"none"/"rc2-cfb"/"rc4-md5-6"/"rc4-md5"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); aead = comma "aead" equals flag:bool { proxy.aead = flag; } udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); } udp_over_tcp_new = comma "udp-over-tcp" equals param:$[^=,]+ { if (param === "sp.v1") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 1; } else if (param === "sp.v2") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; } else if (param === "true") { proxy["_ssr_python_uot"] = true; } else { throw new Error("Invalid value for udp-over-tcp"); } } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_host = comma sni:("tls-host") equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); } tls_verification = comma "tls-verification" equals raw:$[^,]+ { const value = raw.trim(); if (value === "true" || value === "false") { proxy["skip-cert-verify"] = value !== "true"; } else { proxy["name-cert-verify"] = value; } } 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:("tls"/"wss"/"ws"/"over-tls") { obfs.type = type; return type; } / type:("http"/"vmess-http"/"vemss-http"/"shadowsocks-http") { // QX accepts multiple http-obfs spellings for ss/vmess/vless; keep // the original token so QX output can round-trip it unchanged. return setQxHttpObfs(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_vmess = comma "obfs" equals ( type:("wss"/"ws"/"over-tls") { obfs.type = type; return type; } / type:("http"/"vmess-http"/"vemss-http"/"shadowsocks-http") { // QX accepts multiple http-obfs spellings for ss/vmess/vless; keep // the original token so QX output can round-trip it unchanged. return setQxHttpObfs(type); } ); obfs_vless = comma "obfs" equals ( type:("wss"/"ws"/"over-tls") { obfs.type = type; return type; } / type:("http"/"vmess-http"/"vemss-http"/"shadowsocks-http") { // QX accepts multiple http-obfs spellings for ss/vmess/vless; keep // the original token so QX output can round-trip it unchanged. return setQxHttpObfs(type); } ); obfs_host = comma "obfs-host" equals match:[^,]+ { obfs.host = match.join("").replace(/^"(.*)"$/, '$1'); } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } ssr_protocol = comma "ssr-protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; return protocol; } ssr_protocol_param = comma "ssr-protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } reality_base64_pubkey = comma "reality-base64-pubkey" equals param:$[^=,]+ { $set(proxy, "reality-opts.public-key", param); } reality_hex_shortid = comma "reality-hex-shortid" equals param:$[^=,]+ { $set(proxy, "reality-opts.short-id", param); } vless_flow = comma "vless-flow" equals param:$[^=,]+ { proxy["flow"] = param; } server_check_url = comma "server_check_url" equals param:$[^=,]+ { proxy["test-url"] = param; } uri = $[^,]+ tag = comma "tag" equals tag:[^=,]+ { proxy.name = tag.join(""); } others = comma [^=,]+ equals [^=,]+ comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } `,zS;function ma(){return zS||(zS=d$.default.generate(YQ)),zS}var SEe=P(x());var WQ=new Set(["__proto__","constructor","prototype"]),GS;function $u(e,t,r){if(Object(e)!==e)return e;if(Array.isArray(t)||(t=t.toString().match(/[^.[\]]+/g)||[]),t.some(n=>WQ.has(n)))throw new Error("Unsafe property path");return t.slice(0,-1).reduce((n,i,o)=>Object.prototype.hasOwnProperty.call(n,i)&&Object(n[i])===n[i]?n[i]:n[i]=Math.abs(t[o+1])>>0===+t[o+1]?[]:{},e)[t[t.length-1]]=r,e}function U2(e){if(e!=null)return/(TRUE)|1/i.test(e)}function p$(e){return Fu(e)!=null}function YS(e){try{return decodeURIComponent(e)}catch{return e}}function XQ(e){let t={},r=e.match(/^trojan:\/\/([^@]+)@(\[[^\]]+\]|[^/?#]+):(\d+)(?:\/)?(?:\?([^#]*))?(?:#(.*))?$/);if(!r)throw new Error("Invalid trojan url");let[,n,i,o,s,a]=r,u=i.replace(/^\[|\]$/g,"");if((i.startsWith("[")||i.includes(":"))&&!hr(u))throw new Error(`Invalid server: ${i}`);if(t.type="trojan",t.password=YS(n),t.server=i,t.port=Number(o),!Number.isSafeInteger(t.port)||t.port<1||t.port>65535)throw new Error(`Invalid port: ${o}`);t.name=a?YS(a):`${i}:${o}`;let l={};if(s)for(let f of s.split("&")){let m=f.indexOf("="),p=m===-1?f:f.slice(0,m);l[p]=m===-1?!0:YS(f.slice(m+1))}if(t["skip-cert-verify"]=U2(l.allowInsecure),t.sni=l.sni||l.peer,t["client-fingerprint"]=l.fp,t["tls-fingerprint"]=l.pcs,t._vcn=l.vcn?.split(",").map(f=>f.trim()).filter(Boolean),t["name-cert-verify"]=t._vcn?.[0],l.alpn&&(t.alpn=l.alpn.split(",")),U2(l.ws)&&(t.network="ws",$u(t,"ws-opts.path",l.wspath)),l.type){let f=!1,m="",p="";if(t.network=l.type,t.network==="httpupgrade"&&(t.network="ws",f=!0),t.network==="grpc")t["grpc-opts"]={"grpc-service-name":l.serviceName,"_grpc-type":l.mode,"_grpc-authority":l.authority};else{if(l.path){let d=l.path;if(t.network==="ws"){let v=Zp(d,"ed");p$(v)&&(d=Zs(d,"ed").path,f?m=v:p=v)}$u(t,`${t.network}-opts.path`,d)}l.host&&$u(t,`${t.network}-opts.headers.Host`,l.host),f?(m=m||(p$(l.ed)?String(l.ed):""),$u(t,"ws-opts.v2ray-http-upgrade",!0),m&&($u(t,"ws-opts.v2ray-http-upgrade-fast-open",!0),$u(t,"ws-opts._v2ray-http-upgrade-ed",m))):t.network==="ws"&&p&&($u(t,"ws-opts.max-early-data",Fu(p)),$u(t,"ws-opts.early-data-header-name","Sec-WebSocket-Protocol"))}if(l.security==="reality"){let d={};l.pbk&&(d["public-key"]=l.pbk),l.sid&&(d["short-id"]=l.sid),l.spx&&(d["_spider-x"]=l.spx),l.mode&&(t._mode=l.mode),l.extra&&(t._extra=l.extra),Object.keys(d).length&&$u(t,"reality-opts",d)}}return t.udp=U2(l.udp),t.tfo=U2(l.tfo),t}function WS(){return GS||(GS={parse:XQ}),GS}var QS=P(ZS());var ga=P(u2());function m$(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 g$(e){let[t,r,n]=/^(.*?)(?:#(.*?))?$/.exec(e);return{content:r,fragment:n!=null?decodeURIComponent(n):void 0}}function JQ(e){let t=e.indexOf(":");if(t!==-1)return[decodeURIComponent(e.slice(0,t)),decodeURIComponent(e.slice(t+1))].join(":");let r=decodeURIComponent(e);return r.includes(":")?r:It.decode(r)}function e6(e){return e==null||!/^\d+$/.test(`${e}`)?!1:Number.isSafeInteger(parseInt(`${e}`,10))}function t6(e){let t=Zp(e,"ed");return e6(t)?{path:Zs(e,"ed").path,ed:t}:{path:e,ed:""}}function r6(e){let t=`${e}`;if(!/^\d+$/.test(t))throw new Error(`bad WebSocket max early data size: ${e}`);let r=parseInt(t,10);if(!Number.isSafeInteger(r))throw new Error(`bad WebSocket max early data size: ${e}`);return r}function n6(e){if(Array.isArray(e))return e.flatMap(r=>n6(r)||[]);if(typeof e!="string")return e==null?void 0:[e];let t=e.split(",").map(r=>r.trim()).filter(Boolean);return t.length>0?t:void 0}function ZQ(e){if(e==null)return null;let t=`${e}`.trim();if(!t)return null;let[,r=t,n]=/^(.*?)(?:\/(\d+))?$/.exec(t)||[],i=`${r}`.trim().replace(/^\[/,"").replace(/\]$/,""),o=(s,a)=>{if(s==null||!/^\d+$/.test(s))return;let u=parseInt(s,10);if(!(u<0||u>a))return u};return jr(i)?{family:"ipv4",address:i,cidr:o(n,32)}:hr(i)?{family:"ipv6",address:i,cidr:o(n,128)}:null}function QQ(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[i,o,s,a,u,l,f,m,p]=n.match(/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/);if(f)f=parseInt(f,10);else{if(s)f=443;else if(o==="http")f=80;else throw z.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);z.info(`port is not present in line: ${n}, set to ${f}`)}return{name:p!=null?decodeURIComponent(p):`${o} ${l}:${f}`,type:o,tls:!!s,server:l,port:f,username:a!=null?decodeURIComponent(a):void 0,password:u!=null?decodeURIComponent(u):void 0}}}}function eee(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[i,o,s,a,u,l,f]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(u)u=parseInt(u,10);else throw z.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let m,p;if(s){let v=It.decode(decodeURIComponent(s)).split(":");m=v[0],p=v[1]}return{name:f!=null?decodeURIComponent(f):`${o} ${a}:${u}`,type:"socks5",server:a,port:u,username:m,password:p}}}}function tee(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let{content:i,fragment:o}=g$(n.split("ss://")[1]),s={type:"ss"},a=i.match(/@([^/?]*)(\/|\?|$)/),u=JQ(i.split("@")[0]),l="";if(a)i.includes("?")&&(l=i.match(/(\?.*)$/)[1]);else{if(i.includes("?")){let w=i.match(/^(.*)(\?.*)$/);i=w[1],l=w[2]}if(i=It.decode(i),l){if(/(&|\?)v2ray-plugin=/.test(l)){let E=l.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];E&&(s.plugin="v2ray-plugin",s["plugin-opts"]=JSON.parse(It.decode(E)))}i=`${i}${l}`}u=i.match(/(^.*)@/)?.[1],a=i.match(/@([^/@]*)(\/|$)/)}let f={};for(let w of l.replace(/^\?/,"").split("&"))if(w){let[E,S]=w.split("="),F=S;F=decodeURIComponent(S),f[E]=F}if(s.tls=f.security&&f.security!=="none",s["skip-cert-verify"]=!!f.allowInsecure,s.sni=f.sni||f.peer,s["client-fingerprint"]=f.fp,s.alpn=f.alpn?decodeURIComponent(f.alpn).split(","):void 0,f.ws&&(s.network="ws",ga.default.set(s,"ws-opts.path",f.wspath)),f.type){let w,E="",S="";if(s.network=f.type,s.network==="httpupgrade"&&(s.network="ws",w=!0),["grpc"].includes(s.network))s[s.network+"-opts"]={"grpc-service-name":f.serviceName,"_grpc-type":f.mode,"_grpc-authority":f.authority};else{if(f.path){let F=f.path;if(s.network==="ws"){let _=t6(F);F=_.path,w?E=_.ed:S=_.ed}ga.default.set(s,s.network+"-opts.path",F)}f.host&&ga.default.set(s,s.network+"-opts.headers.Host",decodeURIComponent(f.host)),w?(E=E||(e6(f.ed)?`${f.ed}`:""),ga.default.set(s,s.network+"-opts.v2ray-http-upgrade",!0),E!==""&&(ga.default.set(s,s.network+"-opts.v2ray-http-upgrade-fast-open",!0),ga.default.set(s,s.network+"-opts._v2ray-http-upgrade-ed",E))):s.network==="ws"&&S!==""&&(ga.default.set(s,s.network+"-opts.max-early-data",r6(S)),ga.default.set(s,s.network+"-opts.early-data-header-name","Sec-WebSocket-Protocol"))}if(["reality"].includes(f.security)){let F={};f.pbk&&(F["public-key"]=f.pbk),f.sid&&(F["short-id"]=f.sid),f.spx&&(F["_spider-x"]=f.spx),f.mode&&(s._mode=f.mode),f.extra&&(s._extra=f.extra),Object.keys(F).length>0&&ga.default.set(s,f.security+"-opts",F)}}s.udp=!!f.udp;let m=a[1],p=m.lastIndexOf(":");s.server=m.substring(0,p),s.port=`${m.substring(p+1)}`.match(/\d+/)?.[0];let d=u.match(/(^.*?):(.*$)/);s.cipher=d?.[1],s.password=d?.[2];let v=i.match(/[?&]plugin=([^&]+)/),g=i.match(/[?&]shadow-tls=([^&]+)/),y=i.match(/[?&]gost=([^&]+)/);if(v){let w=("plugin="+decodeURIComponent(v[1])).split(";"),E={};for(let S of w){let F=S.indexOf("=");if(F===-1){S&&(E[S]=!0);continue}let _=S.slice(0,F),H=S.slice(F+1).replace(/\\=/g,"=");_&&(E[_]=H||!0)}switch(E.plugin){case"obfs-local":case"simple-obfs":s.plugin="obfs",s["plugin-opts"]={mode:E.obfs,host:jt(E["obfs-host"])};break;case"v2ray-plugin":s.plugin="v2ray-plugin",s["plugin-opts"]={mode:jt(E.obfs)||jt(E.mode)||"websocket",host:jt(E["obfs-host"])||jt(E.host),path:jt(E.path),tls:Ja(E.tls),sni:Ja(E.sni),"skip-cert-verify":["1","true",1,!0].includes(E["skip-cert-verify"]),mux:/^\d+$/.test(E.mux)?parseInt(E.mux,10):void 0};break;case"shadow-tls":{s.plugin="shadow-tls";let S=jt(E.version);s["plugin-opts"]={host:jt(E.host),password:jt(E.password),version:S?parseInt(S,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${E.plugin}`)}}if(g){let w=JSON.parse(It.decode(g[1])),E=jt(w.version),S=jt(w.address),F=jt(w.port);s.plugin="shadow-tls",s["plugin-opts"]={host:jt(w.host),password:jt(w.password),version:E?parseInt(E,10):void 0},S&&(s.server=S),F&&(s.port=parseInt(F,10))}if(y){let w=JSON.parse(It.decode(decodeURIComponent(y[1]))),E=jt(w.address),S=jt(w.port),F=jt(w.route),_=F?.trim().toLowerCase(),H=["ws","wss","websocket"].includes(_);s.plugin="gost-plugin",s["plugin-opts"]={mode:H?"websocket":F,host:jt(w.host),path:jt(w.path)},_==="wss"&&(s["plugin-opts"].tls=!0),E&&(s.server=E),S&&(s.port=parseInt(S,10))}return/(&|\?)uot=(1|true)/i.test(l)&&(s["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(l)&&(s.tfo=!0),s.name=o??`SS ${s.server}:${s.port}`,s}}}function ree(){return{name:"URI SSR Parser",test:n=>/^ssr:\/\//.test(n),parse:n=>{n=It.decode(n.split("ssr://")[1]);let i=n.indexOf(":origin");i===-1&&(i=n.indexOf(":auth_"));let o=n.substring(0,i),s=o.substring(0,o.lastIndexOf(":")),a=o.substring(o.lastIndexOf(":")+1),u=n.substring(i+1).split("/?")[0].split(":"),l={type:"ssr",server:s,port:a,protocol:u[0],cipher:u[1],obfs:u[2],password:It.decode(u[3])},f={};if(n=n.split("/?")[1].split("&"),n.length>1)for(let m of n){let[p,d]=m.split("=");d=d.trim(),d.length>0&&d!=="(null)"&&(f[p]=d)}return l={...l,name:f.remarks?It.decode(f.remarks):l.server,"protocol-param":jt(It.decode(f.protoparam||"").replace(/\s/g,"")),"obfs-param":jt(It.decode(f.obfsparam||"").replace(/\s/g,""))},l}}}function nee(){return{name:"URI VMess Parser",test:n=>/^vmess:\/\//.test(n),parse:n=>{let{content:i,fragment:o}=g$(n.split("vmess://")[1]),s=It.decode(i.replace(/\?.*?$/,""));if(/=\s*vmess/.test(s)){let a=s.split(",").map(f=>f.trim()),u={};for(let f of a)if(f.indexOf("=")!==-1){let[m,p]=f.split("=");u[m.trim()]=p.trim()}let l={name:a[0].split("=")[0].trim(),type:"vmess",server:a[1],port:a[2],cipher:Tn(jt(a[3],"auto")),uuid:a[4].match(/^"(.*)"$/)[1],tls:u.obfs==="wss",udp:Ja(u["udp-relay"]),tfo:Ja(u["fast-open"]),"skip-cert-verify":Xf(u["tls-verification"])?!u["tls-verification"]:void 0};if(Xf(u.obfs))if(u.obfs==="ws"||u.obfs==="wss"){l.network="ws",l["ws-opts"].path=(jt(u["obfs-path"])||'"/"').match(/^"(.*)"$/)[1];let f=u["obfs-header"];f&&f.indexOf("Host")!==-1&&(f=f.match(/Host:\s*([a-zA-Z0-9-.]*)/)[1]),et(f)&&(l["ws-opts"].headers={Host:f})}else throw new Error(`Unsupported obfs: ${u.obfs}`);return et(o)&&(l.name=o),l}else{let a={};try{a=JSON.parse(s)}catch{let[d,v,g]=/(^[^?]+?)\/?\?(.*)$/.exec(i);s=It.decode(v);for(let _ of g.split("&")){let[H,V]=_.split("="),C=V;C=decodeURIComponent(V),C.indexOf(",")===-1?a[H]=C:a[H]=C.split(",")}let[y,w,E,S,F]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(s);a.scy=w,a.id=E,a.port=F,a.add=S}let u=a.add,l=parseInt(Ja(a.port),10),f={name:a.ps??a.remarks??a.remark??`VMess ${u}:${l}`,type:"vmess",server:u,port:l,cipher:Tn(a.scy),uuid:a.id,alterId:parseInt(Ja(a.aid??a.alterId,0),10),tls:["tls",!0,1,"1"].includes(a.tls),"skip-cert-verify":Xf(a.verify_cert)?!a.verify_cert:void 0};!f["skip-cert-verify"]&&Xf(a.allowInsecure)&&(f["skip-cert-verify"]=/(TRUE)|1/i.test(a.allowInsecure)),f.tls&&(a.sni&&a.sni!==""?f.sni=a.sni:a.peer&&a.peer!==""&&(f.sni=a.peer));let m=!1;if(a.net==="ws"||a.obfs==="websocket"?f.network="ws":["http"].includes(a.obfs)||["http"].includes(a.type)?f.network="http":a.net==="http"?f.network="h2":["grpc","kcp","quic"].includes(a.net)?f.network=a.net:a.net==="httpupgrade"||f.network==="httpupgrade"?(f.network="ws",m=!0):(a.net==="h2"||f.network==="h2")&&(f.network="h2"),f.network){let p=a.host??a.obfsParam;try{let w=JSON.parse(p)?.Host;w&&(p=w)}catch{}let d=a.path,v="",g="";if(f.network==="ws"&&d){let y=t6(d);d=y.path,m?v=y.ed:g=y.ed}if(["ws"].includes(f.network)&&(d=d||"/"),f.network==="http"?(p&&(p=p.split(",").map(y=>y.trim()),p=Array.isArray(p)?p[0]:p),d?d=Array.isArray(d)?d[0]:d:d="/"):f.network==="h2"&&(d||(d="/")),d||p||["kcp","quic"].includes(f.network))if(["grpc"].includes(f.network))f[`${f.network}-opts`]={"grpc-service-name":jt(d),"_grpc-type":jt(a.type),"_grpc-authority":jt(a.authority)};else if(["kcp","quic"].includes(f.network))f[`${f.network}-opts`]={[`_${f.network}-type`]:jt(a.type),[`_${f.network}-host`]:jt(jt(p)),[`_${f.network}-path`]:jt(d)};else{let y={path:jt(d)},w=jt(p);if(f.network==="h2"){let E=n6(w);E&&(y.host=E)}else y.headers={Host:w};m?(y["v2ray-http-upgrade"]=!0,v=v||(e6(a.ed)?`${a.ed}`:""),v!==""&&(y["v2ray-http-upgrade-fast-open"]=!0,y["_v2ray-http-upgrade-ed"]=v)):f.network==="ws"&&g!==""&&(y["max-early-data"]=r6(g),y["early-data-header-name"]="Sec-WebSocket-Protocol"),f[`${f.network}-opts`]=y}else delete f.network}return f["client-fingerprint"]=a.fp,f.alpn=a.alpn?a.alpn.split(","):void 0,et(o)&&(f.name=o),f}}}}function v$(){return{name:"URI VLESS Parser",test:n=>/^vless:\/\//.test(n),parse:n=>{let i=D=>{if(!dt(D))return;let O={},q={maxConnections:"max-connections",maxConcurrency:"max-concurrency",cMaxReuseTimes:"c-max-reuse-times",hMaxRequestTimes:"h-max-request-times",hMaxReusableSecs:"h-max-reusable-secs"};for(let[Y,ee]of Object.entries(q)){let se=Ic(D[Y]);se!=null&&(O[ee]=typeof se=="number"?`${se}`:se)}let J=$c(D.hKeepAlivePeriod);return J!=null&&(O["h-keep-alive-period"]=J),Object.keys(O).length>0?O:void 0},o=D=>{if(!dt(D))return;let O={};for(let[q,J]of Object.entries(D))typeof J=="string"&&(O[q]=J);return Object.keys(O).length>0?O:void 0},s=D=>{if(Array.isArray(D))return D.map(s);if(dt(D)){let O={};for(let[q,J]of Object.entries(D))O[q]=s(J);return O}return D},a=D=>{if(Array.isArray(D))return D.map(a).filter(q=>q!==void 0);if(!dt(D))return D;let O={};for(let[q,J]of Object.entries(D)){let Y=a(J);Y!==void 0&&(O[q]=Y)}return Object.keys(O).length>0?O:void 0},u=(D,O,q)=>{let J=a(s(q));J!==void 0&&(D[O]=J)},l=D=>{if(D==null)return;if(!dt(D))return s(D);let O={};for(let[q,J]of Object.entries(D))typeof J!="string"&&u(O,q,J);return a(O)},f=(D,O)=>["maxConnections","maxConcurrency","cMaxReuseTimes","hMaxRequestTimes","hMaxReusableSecs"].includes(D)?Ic(O)!=null:D==="hKeepAlivePeriod"?$c(O)!=null:!1,m=D=>{if(D==null)return;if(!dt(D))return s(D);let O={};for(let[q,J]of Object.entries(D))f(q,J)||u(O,q,J);return a(O)},p=D=>{if(D==null)return;if(!dt(D))return s(D);let O={};for(let[q,J]of Object.entries(D))switch(q){case"headers":{let Y=l(J);Y!==void 0&&(O.headers=Y);break}case"noGRPCHeader":case"xPaddingObfsMode":J!==!0&&u(O,q,J);break;case"xPaddingBytes":Nh(J)==null&&u(O,q,J);break;case"xPaddingKey":case"xPaddingHeader":case"xPaddingPlacement":case"xPaddingMethod":case"uplinkHTTPMethod":case"sessionIDPlacement":case"sessionPlacement":case"sessionIDKey":case"sessionKey":case"seqPlacement":case"seqKey":case"uplinkDataPlacement":case"uplinkDataKey":typeof J!="string"&&u(O,q,J);break;case"sessionIDTable":typeof J!="string"&&u(O,q,J);break;case"uplinkChunkSize":Ic(J)==null&&u(O,q,J);break;case"scMaxEachPostBytes":Nh(J)==null&&u(O,q,J);break;case"scMinPostsIntervalMs":t0(J)==null&&u(O,q,J);break;case"sessionIDLength":Nh(J)==null&&u(O,q,J);break;case"xmux":{let Y=m(J);Y!==void 0&&(O.xmux=Y);break}default:u(O,q,J);break}return a(O)},d=D=>{if(D==null)return;if(!dt(D))return s(D);let O={};Object.prototype.hasOwnProperty.call(D,"path")&&!et(D.path)&&u(O,"path",D.path),Object.prototype.hasOwnProperty.call(D,"host")&&!et(D.host)&&u(O,"host",D.host),Object.prototype.hasOwnProperty.call(D,"mode")&&!et(D.mode)&&u(O,"mode",D.mode);let q={};for(let[Y,ee]of Object.entries(D))["path","host","mode","extra"].includes(Y)||(q[Y]=ee);let J=p(q);if(dt(J)&&Object.assign(O,J),Object.prototype.hasOwnProperty.call(D,"extra")){let Y=p(D.extra);Y!==void 0&&(O.extra=Y)}return a(O)},v=D=>{if(D==null)return;if(!dt(D))return s(D);let O={};for(let[q,J]of Object.entries(D))switch(q){case"address":et(J)||u(O,q,J);break;case"port":$c(J,{allowNegative:!1})==null&&u(O,q,J);break;case"security":{let Y=typeof J=="string"?J.toLowerCase():"";["tls","reality"].includes(Y)||u(O,q,J);break}case"tlsSettings":{if(!dt(J)){u(O,q,J);break}let Y={},ee=fS(J.echConfigList);for(let[le,ve]of Object.entries(J))switch(le){case"serverName":case"fingerprint":et(ve)||u(Y,le,ve);break;case"echConfigList":fS(ve)||u(Y,le,ve);break;case"echForceQuery":(!ee||!g2(ve))&&u(Y,le,ve);break;case"echSockopt":(!ee||!dt(ve))&&u(Y,le,ve);break;case"alpn":Array.isArray(ve)&&ve.length>0&&ve.every(we=>typeof we=="string"&&we!=="")||u(Y,le,ve);break;case"allowInsecure":ve!==!0&&u(Y,le,ve);break;default:u(Y,le,ve);break}let se=a(Y);se!==void 0&&(O.tlsSettings=se);break}case"realitySettings":{if(!dt(J)){u(O,q,J);break}let Y={};for(let[se,le]of Object.entries(J))switch(se){case"publicKey":case"shortId":case"serverName":case"fingerprint":et(le)||u(Y,se,le);break;default:u(Y,se,le);break}let ee=a(Y);ee!==void 0&&(O.realitySettings=ee);break}case"xhttpSettings":{let Y=d(J);Y!==void 0&&(O.xhttpSettings=Y);break}case"network":{let Y=typeof J=="string"?J.toLowerCase():"";Y!=="xhttp"&&Y!=="splithttp"&&u(O,q,J);break}default:u(O,q,J);break}return a(O)},g=(D,{parsedDownloadSettings:O}={})=>{if(!dt(D))return;let{downloadSettings:q,...J}=D,Y=p(J)||{};if(Object.prototype.hasOwnProperty.call(D,"downloadSettings")){let ee=v(q);ee!==void 0&&(Y.downloadSettings=ee)}return a(Y)},y=(D,O)=>{if(!dt(D)||!dt(O))return;let q=o(O.headers);if(q){let we={...D.headers||{}};for(let[Pe,Le]of Object.entries(q)){if(/^host$/i.test(Pe)){!Object.prototype.hasOwnProperty.call(we,"Host")&&!Object.prototype.hasOwnProperty.call(we,"host")&&(we.Host=Le);continue}we[Pe]=Le}Object.keys(we).length>0&&(D.headers=we)}O.noGRPCHeader===!0&&(D["no-grpc-header"]=!0);let J=Nh(O.xPaddingBytes);J!=null&&(D["x-padding-bytes"]=J),O.xPaddingObfsMode===!0&&(D["x-padding-obfs-mode"]=!0),et(O.xPaddingKey)&&(D["x-padding-key"]=O.xPaddingKey),et(O.xPaddingHeader)&&(D["x-padding-header"]=O.xPaddingHeader),et(O.xPaddingPlacement)&&(D["x-padding-placement"]=O.xPaddingPlacement),et(O.xPaddingMethod)&&(D["x-padding-method"]=O.xPaddingMethod),et(O.uplinkHTTPMethod)&&(D["uplink-http-method"]=O.uplinkHTTPMethod),et(O.sessionIDPlacement)?D["session-placement"]=O.sessionIDPlacement:et(O.sessionPlacement)&&(D["session-placement"]=O.sessionPlacement),et(O.sessionIDKey)?D["session-key"]=O.sessionIDKey:et(O.sessionKey)&&(D["session-key"]=O.sessionKey),typeof O.sessionIDTable=="string"&&(D["session-table"]=O.sessionIDTable);let Y=Nh(O.sessionIDLength);Y!=null&&(D["session-length"]=Y),et(O.seqPlacement)&&(D["seq-placement"]=O.seqPlacement),et(O.seqKey)&&(D["seq-key"]=O.seqKey),et(O.uplinkDataPlacement)&&(D["uplink-data-placement"]=O.uplinkDataPlacement),et(O.uplinkDataKey)&&(D["uplink-data-key"]=O.uplinkDataKey);let ee=Ic(O.uplinkChunkSize);ee!=null&&(D["uplink-chunk-size"]=ee);let se=r0(O.scMaxEachPostBytes);se!=null&&(D["sc-max-each-post-bytes"]=se);let le=t0(O.scMinPostsIntervalMs);le!=null&&(D["sc-min-posts-interval-ms"]=le);let ve=i(O.xmux);ve&&(D["reuse-settings"]=ve)},w=D=>{if(!dt(D))return;let O={},q=typeof D.network=="string"?D.network.toLowerCase():"";(q==="xhttp"||q==="splithttp")&&(O.network="xhttp"),et(D.address)&&(O.server=D.address);let J=$c(D.port,{allowNegative:!1});J!=null&&(O.port=J);let Y=typeof D.security=="string"?D.security.toLowerCase():"";if((Y==="tls"||Y==="reality")&&(O.tls=!0),dt(D.tlsSettings)){et(D.tlsSettings.serverName)&&(O.servername=D.tlsSettings.serverName),et(D.tlsSettings.fingerprint)&&(O["client-fingerprint"]=D.tlsSettings.fingerprint),Array.isArray(D.tlsSettings.alpn)&&D.tlsSettings.alpn.length>0&&D.tlsSettings.alpn.every(le=>typeof le=="string"&&le!=="")&&(O.alpn=D.tlsSettings.alpn),D.tlsSettings.allowInsecure===!0&&(O["skip-cert-verify"]=!0);let se=v2({echConfigList:D.tlsSettings.echConfigList,echForceQuery:D.tlsSettings.echForceQuery,echSockopt:D.tlsSettings.echSockopt});se&&(O["ech-opts"]=se)}let ee;return dt(D.realitySettings)&&(ee={},et(D.realitySettings.publicKey)&&(ee["public-key"]=D.realitySettings.publicKey),et(D.realitySettings.shortId)&&(ee["short-id"]=D.realitySettings.shortId),et(D.realitySettings.serverName)&&(O.servername=D.realitySettings.serverName),et(D.realitySettings.fingerprint)&&(O["client-fingerprint"]=D.realitySettings.fingerprint)),Y==="reality"?O["reality-opts"]=ee||{}:ee&&Object.keys(ee).length>0&&(O["reality-opts"]=ee),dt(D.xhttpSettings)&&(et(D.xhttpSettings.path)&&(O.path=D.xhttpSettings.path),et(D.xhttpSettings.host)&&(O.host=D.xhttpSettings.host),et(D.xhttpSettings.mode)&&(O.mode=D.xhttpSettings.mode),y(O,D.xhttpSettings),dt(D.xhttpSettings.extra)&&y(O,D.xhttpSettings.extra)),Object.keys(O).length>0?O:void 0};n=n.split("vless://")[1];let E,S=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);if(!S){let[D,O,q]=/^(.*?)(\?.*?$)/.exec(n);n=`${It.decode(O)}${q}`,S=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),E=!0}let[F,_,H,V,C,I="",L]=S;E&&(_=_.replace(/^.*?:/g,"")),V=parseInt(`${V}`,10),_=decodeURIComponent(_),L!=null&&(L=decodeURIComponent(L));let R={type:"vless",name:L,server:H,port:V,uuid:_,udp:!0},k={};for(let D of I.split("&"))if(D){let[O,q]=D.split("="),J=q;J=decodeURIComponent(q),k[O]=J}if(R.name=L??k.remarks??k.remark??`VLESS ${H}:${V}`,R.tls=k.security&&k.security!=="none",k.pbk&&(k.security="reality"),E&&/TRUE|1/i.test(k.tls)&&(R.tls=!0,k.security=k.security??"reality"),R.sni=k.sni||k.peer,R.flow=k.flow,!R.flow&&E&&k.xtls){let D=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][k.xtls];D&&(R.flow=D)}R["client-fingerprint"]=k.fp,R.alpn=k.alpn?k.alpn.split(","):void 0,R["skip-cert-verify"]=/(TRUE)|1/i.test(k.allowInsecure),R._echConfigList=Ja(k.ech);let M=v2({echConfigList:k.ech});switch(M&&(R["ech-opts"]=M),R["tls-fingerprint"]=Ja(k.pcs),R._vcn=k.vcn?.split(",").map(D=>D.trim()).filter(Boolean),R["name-cert-verify"]=R._vcn?.[0],R._h2=/(TRUE)|1/i.test(k.h2),`${k.packetEncoding||""}`.trim().toLowerCase()){case"none":R["packet-encoding"]="";break;case"packet":R["packet-encoding"]="packetaddr";break;default:R["packet-encoding"]="xudp";break}if(["reality"].includes(k.security)){let D={};k.pbk&&(D["public-key"]=k.pbk),k.sid&&(D["short-id"]=k.sid),k.spx&&(D["_spider-x"]=k.spx),Object.keys(D).length>0&&(R[`${k.security}-opts`]=D)}let N=!1;if(R.network=k.type||"tcp",R.network==="tcp"&&k.headerType==="http"?R.network="http":R.network==="http"?R.network="h2":R.network==="httpupgrade"&&(R.network="ws",N=!0),!k.type&&E&&k.obfs&&(R.network=k.obfs,["none"].includes(R.network)&&(R.network="tcp")),["websocket"].includes(R.network)&&(R.network="ws"),R.network&&!["tcp","none"].includes(R.network)){let D={},O="",q=k.host??k.obfsParam;if(q){if(k.obfsParam)try{let ee=JSON.parse(q);D.headers=ee}catch{D.headers={Host:q}}else D.headers={Host:q};["xhttp"].includes(R.network)&&D.headers?.Host&&(D.host=D.headers.Host,delete D.headers.Host,Object.keys(D.headers).length===0&&delete D.headers);let Y=D.headers?.Host??D.headers?.host;["h2"].includes(R.network)&&Y&&(D.host=n6(Y),delete D.headers.Host,delete D.headers.host,Object.keys(D.headers).length===0&&delete D.headers)}if(k.serviceName?(D[`${R.network}-service-name`]=k.serviceName,["grpc"].includes(R.network)&&k.authority&&(D["_grpc-authority"]=k.authority)):E&&k.path&&(["ws","http","h2"].includes(R.network)||(D[`${R.network}-service-name`]=k.path,delete k.path)),k.path){let Y=k.path;if(R.network==="ws"){let ee=t6(Y);Y=ee.path,O=ee.ed}D.path=Y}else R.network==="h2"&&(D.path="/");R.network==="http"&&k.method&&(D.method=k.method),["grpc"].includes(R.network)&&(D["_grpc-type"]=k.mode||"gun"),N&&(D["v2ray-http-upgrade"]=!0);let J=O||k.ed;if(J){let Y=r6(J);N?(D["v2ray-http-upgrade-fast-open"]=!0,D["_v2ray-http-upgrade-ed"]=`${J}`):R.network==="ws"&&(D["max-early-data"]=Y,D["early-data-header-name"]=k.eh||"Sec-WebSocket-Protocol")}if(k.eh&&(R.network==="ws"||N)&&(D["early-data-header-name"]=k.eh),Object.keys(D).length>0&&(R[`${R.network}-opts`]=D),R.network==="kcp"&&(k.seed&&(R.seed=k.seed),R.headerType=k.headerType||"none"),k.extra&&!["xhttp"].includes(R.network)&&(R._extra=k.extra),["xhttp"].includes(R.network)){let Y={},ee;try{Y=k.extra?JSON.parse(k.extra):{}}catch{z.error(`Failed to parse extra field as JSON: ${k.extra}`),ee=k.extra}let se={...R[`${R.network}-opts`]||{}};k.mode&&(se.mode=k.mode),y(se,Y);let le=w(Y?.downloadSettings);le&&(se["download-settings"]=le),Object.keys(se).length>0&&(R[`${R.network}-opts`]=se),ee!=null&&(R._extra=ee);let ve=g(Y,{parsedDownloadSettings:le});ve&&(R._extra_unsupported=ve)}else k.mode&&(R._mode=k.mode)}return k.encryption&&(R.encryption=k.encryption),k.pqv&&(R._pqv=k.pqv),R}}}function see(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{let i=v$().parse(n.replace("anytls","vless"));n=n.split(/anytls:\/\//)[1];let[o,s,a,u,l="",f]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);s=decodeURIComponent(s),u=parseInt(`${u}`,10),isNaN(u)&&(u=443),s=decodeURIComponent(s),f!=null&&(f=decodeURIComponent(f)),f=f??`AnyTLS ${a}:${u}`;let m={...i,uuid:void 0,type:"anytls",name:f,server:a,port:u,password:s};for(let p of l.split("&"))if(p){let[d,v]=p.split("=");d=d.replace(/_/g,"-"),v=decodeURIComponent(v),["alpn"].includes(d)?m[d]=v?v.split(","):void 0:["insecure"].includes(d)?m["skip-cert-verify"]=/(TRUE)|1/i.test(v):["udp"].includes(d)?m[d]=/(TRUE)|1/i.test(v):Object.keys(m).includes(d)||(m[d]=v)}return["tcp"].includes(m.network)&&!m["reality-opts"]&&(delete m.network,delete m.security),m}}}function iee(){return{name:"URI Hysteria2 Parser",test:n=>/^(hysteria2|hy2):\/\//.test(n),parse:n=>{n=n.split(/(hysteria2|hy2):\/\//)[2];let i,[o,s,a,u,l,f,m,p,d,v,g="",y]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(l)?(l=parseInt(`${l}`,10),isNaN(l)&&(l=443)):l?(i=l,l=ep(i)):l=443,s=decodeURIComponent(s),y!=null&&(y=decodeURIComponent(y)),y=y??`Hysteria2 ${a}:${l}`;let w={type:"hysteria2",name:y,server:a,port:l,ports:i,password:s},E={};for(let H of g.split("&"))if(H){let[V,C]=H.split("="),I=C;I=decodeURIComponent(C),E[V]=I}w.sni=E.sni,!w.sni&&E.peer&&(w.sni=E.peer),E.obfs&&E.obfs!=="none"&&(w.obfs=E.obfs),E.mport&&(w.ports=E.mport),w["obfs-password"]=E["obfs-password"],w["skip-cert-verify"]=/(TRUE)|1/i.test(E.insecure),w.tfo=/(TRUE)|1/i.test(E.fastopen),w["tls-fingerprint"]=E.pinSHA256;let S=E["hop-interval"]||E.hop_interval;S!=null&&(w["hop-interval"]=S);let F=E.keepalive;/^\d+$/.test(F)&&(w.keepalive=parseInt(`${F}`,10)),E.upmbps&&(w.up=E.upmbps),E.downmbps&&(w.down=E.downmbps);let _=v2({echConfigList:E.ech});return _&&(w["ech-opts"]=_),w}}}function oee(){return{name:"URI Hysteria Parser",test:n=>/^(hysteria|hy):\/\//.test(n),parse:n=>{n=n.split(/(hysteria|hy):\/\//)[2];let[i,o,s,a,u,l="",f]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);a=parseInt(`${a}`,10),isNaN(a)&&(a=443),f!=null&&(f=decodeURIComponent(f)),f=f??`Hysteria ${o}:${a}`;let m={type:"hysteria",name:f,server:o,port:a},p={};for(let d of l.split("&"))if(d){let[v,g]=d.split("=");v=v.replace(/_/,"-"),g=decodeURIComponent(g),["alpn"].includes(v)?m[v]=g?g.split(","):void 0:["insecure"].includes(v)?m["skip-cert-verify"]=/(TRUE)|1/i.test(g):["auth"].includes(v)?m["auth-str"]=g:["mport"].includes(v)?m.ports=g:["obfsParam"].includes(v)?m.obfs=g:["upmbps"].includes(v)?m.up=g:["downmbps"].includes(v)?m.down=g:["obfs"].includes(v)?m._obfs=g||"":["fast-open","peer"].includes(v)?p[v]=g:Object.keys(m).includes(v)||(m[v]=g)}return!m.sni&&p.peer&&(m.sni=p.peer),!m["fast-open"]&&p.fastopen&&(m["fast-open"]=!0),m.protocol||(m.protocol="udp"),m}}}function aee(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[i,o,s,a,u="",l]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);o=decodeURIComponent(o);let[f,...m]=o.split(":"),p=m.join(":");a=parseInt(`${a}`,10),isNaN(a)&&(a=443),p=decodeURIComponent(p),l!=null&&(l=decodeURIComponent(l)),l=l??`TUIC ${s}:${a}`;let d={type:"tuic",name:l,server:s,port:a,password:p,uuid:f};for(let v of u.split("&"))if(v){let[g,y]=v.split("=");g=g.replace(/_/g,"-"),y=decodeURIComponent(y),["alpn"].includes(g)?d[g]=y?y.split(","):void 0:["allow-insecure","insecure"].includes(g)?d["skip-cert-verify"]=/(TRUE)|1/i.test(y):["fast-open"].includes(g)?d.tfo=!0:["disable-sni","reduce-rtt"].includes(g)?d[g]=/(TRUE)|1/i.test(y):g==="congestion-control"?(d["congestion-controller"]=y,delete d[g]):Object.keys(d).includes(g)||(d[g]=y)}return d}}}function uee(){return{name:"URI WireGuard Parser",test:n=>/^(wireguard|wg):\/\//.test(n),parse:n=>{n=n.split(/(wireguard|wg):\/\//)[2];let[i,o,s,a,u,l,f,m="",p]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);l=parseInt(`${l}`,10),isNaN(l)&&(l=51820),s=decodeURIComponent(s),p!=null&&(p=decodeURIComponent(p)),p=p??`WireGuard ${a}:${l}`;let d={type:"wireguard",name:p,server:a,port:l,"private-key":s,udp:!0};for(let v of m.split("&"))if(v){let g=v.indexOf("="),y,w;if(g===-1?(y=v,w=""):(y=v.slice(0,g),w=v.slice(g+1)),y=y.replace(/_/,"-"),w=decodeURIComponent(w),["reserved"].includes(y)){let E=w.split(",").map(S=>parseInt(S.trim(),10)).filter(S=>Number.isInteger(S));E.length===3&&(d[y]=E)}else if(["address","ip"].includes(y))w.split(",").map(E=>{let S=ZQ(E);S&&(S.family==="ipv4"?(d.ip=S.address,typeof S.cidr<"u"&&(d["ip-cidr"]=S.cidr)):S.family==="ipv6"&&(d.ipv6=S.address,typeof S.cidr<"u"&&(d["ipv6-cidr"]=S.cidr)))});else if(["mtu"].includes(y)){let E=parseInt(w.trim(),10);Number.isInteger(E)&&(d[y]=E)}else/publickey/i.test(y)?d["public-key"]=w:/privatekey/i.test(y)?d["private-key"]=w:["udp"].includes(y)?d[y]=/(TRUE)|1/i.test(w):[...Object.keys(d),"flag"].includes(y)||(d[y]=w)}return d}}}function cee(){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,a]=n.split(/#(.+)/,2),l=WS().parse(s);if(et(a))try{l.name=decodeURIComponent(a)}catch(f){console.log(f)}return l}}}function lee(){return{name:"Clash Parser",test:n=>{let i;try{i=QS.default.parse(n)}catch{i=fi.parse(n)}return!!i?.type},parse:n=>{let i;try{i=QS.default.parse(n)}catch{i=fi.parse(n)}if(!["shadowquic","gost-relay","openvpn","tailscale","trusttunnel","h2-connect","naive","anytls","mieru","masque","sudoku","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.servername&&(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.type==="vmess"&&(i.cipher=Tn(i.cipher)),i}}}function fee(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>ma().parse(n)}}function hee(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>ma().parse(n)}}function dee(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>ma().parse(n)}}function pee(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>ma().parse(n)}}function mee(){return{name:"QX AnyTLS Parser",test:n=>/^anytls\s*=/.test(n.split(",")[0].trim()),parse:n=>ma().parse(n)}}function gee(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>ma().parse(n)}}function vee(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>ma().parse(n)}}function wee(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>ma().parse(n)}}function yee(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>Ao().parse(n)}}function Eee(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>Ao().parse(n)}}function bee(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>Ao().parse(n)}}function Aee(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>Ao().parse(n)}}function See(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>Ao().parse(n)}}function Cee(){return{name:"Loon AnyTLS Parser",test:n=>/^.*=\s*anytls/i.test(n.split(",")[0]),parse:n=>Ao().parse(n)}}function _ee(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>Ao().parse(n)}}function Dee(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>Ao().parse(n)}}function Fee(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>Ao().parse(n)}}function Bee(){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 o=n.match(/,\s*?peers\s*?=\s*?\[\s*?\{\s*?(.+?)\s*?\}\s*?\]/i)?.[1],s=o.match(/(,|^)\s*?endpoint\s*?=\s*?"?(.+?):(\d+)"?\s*?(,|$)/i),a=s?.[2],u=parseInt(s?.[3],10),l=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];l&&(l=parseInt(l,10));let f=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];f&&(f=parseInt(f,10));let m=o.match(/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i)?.[2];m&&(m=JSON.parse(m));let p,d=n.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],v=n.match(/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];(d||v)&&(p=[],d&&p.push(d),v&&p.push(v));let g=o.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]?.split(",").map(_=>_.trim()),y=o.match(/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],w=n.match(/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],E=n.match(/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],S=o.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],F={type:"wireguard",name:i,server:a,port:u,ip:w,ipv6:E,"private-key":n.match(/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],"public-key":S,mtu:l,keepalive:f,reserved:m,"allowed-ips":g,"preshared-key":y,dns:p,udp:!0,peers:[{server:a,port:u,ip:w,ipv6:E,"public-key":S,"pre-shared-key":y,"allowed-ips":g,reserved:m}]};return Array.isArray(F.dns)&&F.dns.length>0&&(F["remote-dns-resolve"]=!0),F}}}function Iee(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>ss().parse(n)}}function $ee(){return{name:"Surge AnyTLS Parser",test:n=>/^.*=\s*anytls/.test(n.split(",")[0]),parse:n=>ss().parse(n)}}function Pee(){return{name:"Surge TrustTunnel Parser",test:n=>/^.*=\s*trust-tunnel/.test(n.split(",")[0]),parse:n=>ss().parse(n)}}function xee(){return{name:"Surge HTTP/2 CONNECT Parser",test:n=>/^.*=\s*h2-connect/.test(n.split(",")[0]),parse:n=>ss().parse(n)}}function Tee(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>ss().parse(n)}}function Ree(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>ss().parse(n)}}function kee(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>ss().parse(n)}}function Oee(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>ss().parse(n)}}var w$=/(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256)\s*=/i;function Nee(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0])&&!w$.test(n),parse:n=>ss().parse(n)}}function Lee(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0])&&!w$.test(n),parse:n=>ss().parse(n)}}function Uee(){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),[o,s,a]=i;n=a;let u=/(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];u||(u=/(,|^)\s*?exec\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let l=/(,|^)\s*?local-port\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];l||(l=/(,|^)\s*?local-port\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let f=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,m,p=[];for(;(m=f.exec(n))!==null;)m[3]!=null?p.push(m[3]):m[4]!=null&&p.push(m[4]);let d=/(,|^)\s*?addresses\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,v,g=[];for(;(v=d.exec(n))!==null;){let w;v[3]!=null?w=v[3]:v[4]!=null&&(w=v[4]),w!=null&&(w=`${w}`.trim().replace(/^\[/,"").replace(/\]$/,"")),Kee(w)&&g.push(w)}return{type:"external",name:s,exec:u,"local-port":l,args:p,addresses:g}}}}function Hee(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>ss().parse(n)}}function Mee(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:o}=m$(n),s=ss().parse(o);return s.ports=i,s}}}function jee(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>ss().parse(n)}}function qee(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:o}=m$(n),s=ss().parse(o);return s.ports=i,s}}}function Kee(e){return jr(e)||hr(e)}var y$=[QQ(),eee(),tee(),ree(),nee(),v$(),aee(),uee(),oee(),iee(),cee(),see(),lee(),Iee(),$ee(),Pee(),xee(),Tee(),Ree(),kee(),Oee(),Nee(),Hee(),Mee(),jee(),qee(),Lee(),Uee(),yee(),Eee(),bee(),Aee(),_ee(),See(),Cee(),Dee(),Fee(),Bee(),fee(),hee(),dee(),pee(),mee(),gee(),vee(),wee()];var C$=P(ZS());var Vee={encrypt:Yg,decrypt:Wg,derivePublicKey:PI};function zee(e){for(let t of Zg)try{if(t.test(e))return z.info(`Pre-processor [${t.name}] activated`),t.parse(e)}catch(r){z.error(`Parser [${t.name}] failed Reason: ${r}`)}return e}function Gee(e){e=zee(e);let t=e.split(` `),r=[],n;for(let i of t){if(i=i.trim(),i.length===0)continue;let o=!1;if(n){let[s,a]=b$(n,i);a||(r.push(S$(s)),o=!0)}if(!o)for(let s of y$){let[a,u]=b$(s,i);if(!u){r.push(S$(a)),n=s,o=!0,z.info(`${s.name} is activated`);break}}o||z.error(`Failed to parse line: ${i}`)}return r.filter(i=>{if(["vless","vmess"].includes(i.type))Lm(i.uuid)||z.warn(`UUID may be invalid: ${i.name} ${i.uuid}`);else if(["hysteria2"].includes(i.type)&&i.obfs&&!i["obfs-password"])return z.error(`Proxy ${i.name} has obfs ${i.obfs} but missing obfs-password`),!1;return!0})}function _$(e,t){let r=t.process;if(!r||typeof r!="object")return!1;let{type:n,customNames:i}=r;if(!Array.isArray(i))return!1;let o=e.customName!=null&&i.includes(e.customName);return n==="disable"?o:n==="enable"?!o:!1}async function Yee(e,t=[],r,n,i,o){let s={};o!==void 0&&(s.raw=Array.isArray(o)||o!==null&&typeof o=="object"?o:[o]);for(let a of t){if(QA(a.type)){z.log(`Skipping response transformer during proxy/file processing: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}if(_$(a,s)){z.info(`Skipping context-controlled operator: "${a.type}" with customName "${a.customName||""}"`);continue}if(a.disabled){z.log(`Skipping disabled operator: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}let u,l={};if(a.type.indexOf("Script")!==-1&&({script:u,$arguments:l}=await D$(a)),!Wp[a.type]){z.error(`Unknown operator: "${a.type}"`);continue}z.log(`Applying "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);let f;a.type.indexOf("Script")!==-1?f=Wp[a.type](u,r,l,n,i,s):f=Wp[a.type](a.args||{}),e=await v9(f,e)}return e}async function Wee(e,t=[],r,n,i){let o={},s=E$(e);for(let a of t){if(!QA(a.type))continue;if(_$(a,o)){z.info(`Skipping context-controlled response transformer: "${a.type}" with customName "${a.customName||""}"`);continue}if(a.disabled){z.log(`Skipping disabled response transformer: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}let{script:u,$arguments:l}=await D$(a);z.log(`Applying "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);let f=Wp[a.type](u,r,l,n,i,o);s=E$(await g9(f,s))}return s}async function D$(item){let script,$arguments={},{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"?y1:ci,n=dr(z.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);e==="module"?script=n.content:script=await Ws({type:"file",name:t})}catch(t){throw z.error(`Error when loading ${e}: ${item.args.content}. Reason: ${t}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${e}: ${url}`)}}else if(url?.startsWith("/"))try{let fs=eval('require("fs")');script=fs.readFileSync(url.split("#")[0],"utf8")}catch(e){throw z.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 Bs(url)}catch(e){throw z.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||{};return{script,$arguments}}function E$(e={}){let t=e.header||e.headers||{};(!t||typeof t!="object")&&(t={});let r={status:e.status||e.statusCode||200,body:Object.prototype.hasOwnProperty.call(e,"body")?e.body:""};return Object.defineProperty(r,"headers",{enumerable:!0,get(){return t},set(n){t=n&&typeof n=="object"?n:{}}}),Object.defineProperty(r,"header",{enumerable:!0,get(){return t},set(n){t=n&&typeof n=="object"?n:{}}}),r}function Xee(e,t,r,n={}){let i=I2[t];if(!i)throw new Error(`Target platform: ${t} is not supported!`);let o=String(t).toLowerCase();if(e=e.filter(s=>{let a=n["include-unsupported-proxy"];if(!a&&s.supported&&s.supported[t]===!1)return!1;if(!a&&Jee(s)&&Zee(s)&&!Qee(s,t))return z.error(`Target platform ${t} does not support headers for ${ete(s)} proxy ${s.name||`${s.server}:${s.port}`}. Proxy has been filtered.`),!1;if(!a&&xh(s)&&!["qx","quantumultx","shadowrocket"].includes(o))return!1;if(["vless","vmess"].includes(s.type)){Lm(s.uuid)||z.warn(`UUID may be invalid: ${s.name} ${s.uuid}`);let l=s.type==="vless",f=l?[["reality-opts",s["reality-opts"]],["xhttp download-settings reality-opts",s["xhttp-opts"]?.["download-settings"]?.["reality-opts"]]]:[];for(let[p,d]of f)if(d&&!et(d["public-key"])){if(p==="xhttp download-settings reality-opts"&&et(s["reality-opts"]?.["public-key"])&&d["public-key"]==="")continue;return z.error(`Skipping VLESS Reality proxy ${s.name}: empty ${p}.public-key`),!1}let m=s["xhttp-opts"];if(l&&s.network==="xhttp"&&m?.mode==="stream-one"&&m["download-settings"])return z.error(`Skipping VLESS xhttp proxy ${s.name}: mode "stream-one" cannot be used with download-settings`),!1}return!0}),e=e.map(s=>(s._resolved=s.resolved,et(s.name)||(s.name=`${s.type} ${s.server}:${s.port}`),s["disable-sni"]&&(["surge","surgemac","shadowrocket"].includes(o)?s.sni="off":!["tuic"].includes(s.type)&&!["sing-box","singbox"].includes(o)&&(z.error(`Target platform ${t} does not support sni off. As a workaround for mihomo, proxy ${s.name} sni will be set to IP instead`),s.sni=M2(s.server)?s.server:"127.0.0.1")),s.ports&&(s.ports=String(s.ports),["meta","clashmeta","clash.meta","mihomo"].includes(o)||(s.ports=s.ports.replace(/\//g,",")),s.port||(s.port=ep(s.ports))),s.type==="wireguard"&&nS(s),s)),z.log(`Producing proxies for target: ${t}`),typeof i.type>"u"||i.type==="SINGLE"){let s=e.map(a=>{try{return i.produce(a,r,n)}catch(u){return z.error(`Cannot produce proxy: ${a.name} Reason: ${u}`),""}}).filter(a=>a.length>0);return n._merged&&n.localPort>=1&&s.push(Qp().produce({name:n._merged.name,type:"external",udp:!0,exec:n._merged.exec,"local-port":n.localPort,args:["-config",It.encode(JSON.stringify({...n._merged.config,"mixed-port":n.localPort}))],addresses:[]},r,n)),s=r==="internal"?s:s.join(` `),t.startsWith("Surge")&&e.length>0&&e.every(a=>a.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)}function Jee(e){return e?.headers&&typeof e.headers=="object"&&Object.keys(e.headers).length>0}function Zee(e){return["http","h2-connect","trusttunnel"].includes(e?.type)}function Qee(e,t){let r=`${t}`.toLowerCase();return r.startsWith("surge")?["http","h2-connect","trusttunnel"].includes(e.type):r==="egern"||["clashmeta","clash.meta","meta","mihomo"].includes(r)||["singbox","sing-box"].includes(r)?e.type==="http":r==="json"?["http","h2-connect","trusttunnel"].includes(e.type):!1}function ete(e){return e.type==="http"?e.tls?"HTTPS":"HTTP":e.type==="h2-connect"?"HTTP/2 CONNECT":e.type==="trusttunnel"?"TrustTunnel":e.type}var Ft={parse:Gee,process:Yee,processResponse:Wee,produce:Xee,age:Vee,ipAddress:Nm,getRandomPort:ep,isIPv4:jr,isIPv6:hr,isIP:M2,yaml:fi,getFlag:_h,removeFlag:Kp,getISO:s2,MMDB:n2,Gist:wl,download:Bs,downloadFile:KI,isValidUUID:Lm,doh:YA,Buffer:H2.Buffer,Base64:It,JSON5:C$.default,hex_md5:en};function b$(e,t){if(!tte(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function tte(e,t){try{return e.test(t)}catch{return!1}}function A$(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function S$(e){let t=(s,a)=>Object.prototype.hasOwnProperty.call(s,a),r=s=>{if(!(!s||typeof s!="object"||Array.isArray(s)))for(let a of Object.keys(s)){let u=a.toLowerCase();a!==u&&(t(s,u)||(s[u]=s[a]),delete s[a])}};for(let s of Object.keys(e)){let a=s.toLowerCase();a.endsWith("-opts")&&(s!==a&&(t(e,a)||(e[a]=e[s]),delete e[s]),r(e[a]))}if(e.udp=![!1,0,"0","false","off"].includes(typeof e.udp=="string"?e.udp.toLowerCase():e.udp),typeof e.cipher=="string"&&(e.cipher=e.cipher.toLowerCase()),typeof e.password=="number"&&(e.password=AD(e.password)),e["hop-interval"]!=null){let s=`${e["hop-interval"]}`.trim(),a=s.match(/^(\d+)\s*-\s*(\d+)$/);if(a){let u=parseInt(a[1],10),l=parseInt(a[2],10);u>0&&u<=l?(e["hop-interval"]=u,e["hop-interval-max"]=l):(delete e["hop-interval"],delete e["hop-interval-max"])}else if(/^\d+$/.test(s)){let u=parseInt(s,10);u>0?(e["hop-interval"]=u,delete e["hop-interval-max"]):(delete e["hop-interval"],delete e["hop-interval-max"])}else delete e["hop-interval"],delete e["hop-interval-max"]}["ss"].includes(e.type)&&e.cipher==="none"&&!e.password&&(e.password=""),e.interface&&(e["interface-name"]=e.interface,delete e.interface),bD(e.port)&&(e.port=parseInt(e.port,10)),e.server&&(e.server=`${e.server}`.trim().replace(/^\[/,"").replace(/\]$/,"")),["vmess","vless","trojan","anytls"].includes(e.type)&&e["shadow-tls-opts"]&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e.sni,password:e["shadow-tls-opts"].password,version:e["shadow-tls-opts"].version},delete e["shadow-tls-opts"]),e.type==="snell"&&e["obfs-opts"]?.mode==="shadow-tls"&&!e.plugin&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e["obfs-opts"].host,password:e["obfs-opts"].password,version:e["obfs-opts"].version,alpn:e["obfs-opts"].alpn},delete e["obfs-opts"]),e.plugin==="shadow-tls"&&e["plugin-opts"]&&(e.alpn&&!e["plugin-opts"].alpn&&(e["plugin-opts"].alpn=e.alpn),delete e.alpn);let n=e.type==="vless"&&e.network==="xhttp"?e["xhttp-opts"]?.["download-settings"]:void 0;n?.["shadow-tls-opts"]&&(n.plugin="shadow-tls",n["plugin-opts"]={host:n.servername,password:n["shadow-tls-opts"].password,version:n["shadow-tls-opts"].version},delete n["shadow-tls-opts"]),n?.plugin==="shadow-tls"&&n["plugin-opts"]&&(n.alpn&&!n["plugin-opts"].alpn&&(n["plugin-opts"].alpn=n.alpn),delete n.alpn),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 i=e[`${e.network}-opts`]?.path;if(Array.isArray(i)?e[`${e.network}-opts`].path=i.map(s=>A$(s)):i!=null&&(e[`${e.network}-opts`].path=A$(i)),e.type==="trojan"&&(e.network=e.network||"tcp"),["vmess"].includes(e.type)&&(e.network=e.network||"tcp",e.cipher=e.cipher||"none",e.alterId=e.alterId||0),["vless"].includes(e.type)&&(e.network=e.network||"tcp"),["vmess","vless"].includes(e.type)&&e["packet-encoding"]==null&&(e.xudp?e["packet-encoding"]="xudp":e["packet-addr"]&&(e["packet-encoding"]="packetaddr")),["trojan","tuic","hysteria","hysteria2","juicity","anytls","trusttunnel","h2-connect","naive","masque","shadowquic"].includes(e.type)&&(e.tls=!0),e.network){let s=e[`${e.network}-opts`]?.headers?.Host,a=e[`${e.network}-opts`]?.headers?.host;e.network!=="h2"&&a&&!s&&(e[`${e.network}-opts`].headers.Host=a,delete e[`${e.network}-opts`].headers.host)}if(e.network==="h2"){let s=e["h2-opts"],a=s?.host??s?.headers?.host??s?.headers?.Host,u=s?.path;a&&(s.host=Array.isArray(a)?a:[a]),s?.headers&&(delete s.headers.host,delete s.headers.Host,Object.keys(s.headers).length===0&&delete s.headers),Array.isArray(u)&&(s.path=u[0])}if(!e.tls&&["ws","http"].includes(e.network)&&!e[`${e.network}-opts`]?.headers?.Host&&!M2(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 s=e[`${e.network}-opts`]?.path,a=e[`${e.network}-opts`]?.headers?.Host;a&&!Array.isArray(a)&&(e[`${e.network}-opts`].headers.Host=[a]),s&&!Array.isArray(s)&&(e[`${e.network}-opts`].path=[s])}if(e.tls&&!e.sni&&e.sni!==""){if(e.network){let s=e.network==="h2"?e["h2-opts"]?.host:e[`${e.network}-opts`]?.headers?.Host;s=Array.isArray(s)?s[0]:s,s&&(e.sni=s)}!e.sni&&!M2(e.server)&&(e.sni=e.server)}if(e.ports?e.ports=String(e.ports).replace(/\//g,","):delete e.ports,["hysteria2"].includes(e.type)&&e.obfs&&!["salamander"].includes(e.obfs)&&!e["obfs-password"]&&(e["obfs-password"]=e.obfs,e.obfs="salamander"),["hysteria2"].includes(e.type)&&!e["obfs-password"]&&e.obfs_password&&(e["obfs-password"]=e.obfs_password,delete e.obfs_password),["vless"].includes(e.type)&&(e["reality-opts"]&&Object.keys(e["reality-opts"]).length===0&&delete e["reality-opts"],e["grpc-opts"]&&Object.keys(e["grpc-opts"]).length===0&&delete e["grpc-opts"],(!e["reality-opts"]&&!e.flow||["null",null].includes(e.flow))&&delete e.flow,["http"].includes(e.network)&&(e[`${e.network}-opts`]?.path||(e[`${e.network}-opts`]||(e[`${e.network}-opts`]={}),e[`${e.network}-opts`].path=["/"]))),typeof e.name!="string")if(/^\d+$/.test(e.name))e.name=`${e.name}`;else try{e.name?.data?e.name=H2.Buffer.from(e.name.data).toString("utf8"):e.name=H2.Buffer.from(e.name).toString("utf8")}catch(s){z.error(`proxy.name decode failed Reason: ${s}`),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(s=>!s))&&(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].path=["/"])),["anytls"].includes(e.type)&&e["disable-reuse"]&&(e.reuse=!1),["","off"].includes(e.sni)&&(e["disable-sni"]=!0);let o=e.ca_str;e["ca-str"]?o=e["ca-str"]:o&&(delete e.ca_str,e["ca-str"]=o);try{z.env.isNode&&!o&&e._ca&&(o=z.node.fs.readFileSync(e._ca,{encoding:"utf8"}))}catch(s){z.error(`Read ca file failed Reason: ${s}`)}return!e["tls-fingerprint"]&&o&&(e["tls-fingerprint"]=h_.generateFingerprint(o)),["tuic"].includes(e.type)&&(e.alpn=Array.isArray(e.alpn)?e.alpn:[e.alpn||"h3"],e["congestion-controller"]=e["congestion-controller"]||"cubic",e["udp-relay-mode"]=e["udp-relay-mode"]||"native"),["wireguard"].includes(e.type)&&(Array.isArray(e.peers)&&e.peers.length>0&&(e.peers.find(a=>a.ip&&a.ipv6)||e.peers.find(a=>a.ip||a.ipv6))&&(e.ip||(e.ip=e.peers[0]?.ip),e.ipv6||(e.ipv6=e.peers[0]?.ipv6)),nS(e)),e}function M2(e){return jr(e)||hr(e)}var cbe=P(x());function rte(e){return typeof e.getHeaders=="function"?{...e.getHeaders()}:{}}function nte(e,t,r={}){for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(r,n)||e.removeHeader(n);for(let[n,i]of Object.entries(r))i==null?e.removeHeader(n):e.set(n,i)}function ste(e,t){let r=Number(t);Number.isInteger(r)&&r>=100&&r<=599&&e.status(r)}async function s6({res:e,body:t,process:r,targetPlatform:n,source:i,$options:o}){let s=rte(e),a=await Ft.processResponse({status:e.statusCode||200,headers:s,body:t},r||[],n,i,o);return nte(e,s,a.header||a.headers),ste(e,a.status||a.statusCode),a.body}var bbe=P(x());function ite(e){z.read(Cn)||z.write([],Cn),e.post("/api/token",ute),e.route("/api/token/:token").delete(ote),e.route("/api/tokens").get(ate)}function ote(e,t){try{let{token:r}=e.params,{type:n,name:i}=e.query;if(!n||!i)throw new kt("INVALID_PAYLOAD","Payload type and name are required. Please update your front-end(version >= 2.15.76)");z.info(`\u6B63\u5728\u5220\u9664... token: ${r}, \u7C7B\u578B\uFF1A${n}, \u540D\u79F0\uFF1A${i}`),wte(e.query.mode)&&kD(r,n,i),vte(r,n,i),es(t)}catch(r){xr(t,r)}}function ate(e,t){let{type:r,name:n}=e.query,i=z.read(Cn)||[];es(t,r||n?i.filter(o=>(r?o.type===r:!0)&&(n?o.name===n:!0)):i)}async function ute(e,t){if(!ws().isNode)return xr(t,new kt("INVALID_ENV","This endpoint is only available in Node.js environment"));try{let r=gte(e.body.payload,e.body.options);return es(t,{token:r.token})}catch(r){return xr(t,r instanceof kt?r:new Ss("TOKEN_SIGN_FAILED","Failed to sign token",`Reason: ${r.message??r}`))}}function cte(e){if(!(e==null||e==="")){if(e==="duration"||e==="datetime"||e==="count")return e;throw new kt("INVALID_EXPIRATION_MODE",`Unsupported expiration mode: ${e}`)}}function lte(e={}){if(e?.expiresIn!=null&&e.expiresIn!=="")return"duration";if(e?.exp!=null&&e.exp!=="")return"datetime"}function fte(e={}){let t=e?.exp;if(typeof t!="number"&&typeof t!="string")throw new kt("INVALID_EXPIRATION_DATETIME",`Invalid exp option: ${t}`);let r=typeof t=="string"?t.trim():t;if(r==="")throw new kt("INVALID_EXPIRATION_DATETIME",`Invalid exp option: ${t}`);let n=Number(r);if(!Number.isSafeInteger(n)||n<=0||n<1e12)throw new kt("INVALID_EXPIRATION_DATETIME",`Invalid exp option: ${t}`);return n}function hte(options={},{required=!1}={}){let rawExpiresIn=options?.expiresIn;if(rawExpiresIn==null||rawExpiresIn===""){if(required)throw new kt("INVALID_EXPIRES_IN",`Invalid expiresIn option: ${rawExpiresIn}`);return null}let ms=eval('require("ms")'),expiresIn=ms(rawExpiresIn);if(expiresIn==null||isNaN(expiresIn)||expiresIn<=0)throw new kt("INVALID_EXPIRES_IN",`Invalid expiresIn option: ${rawExpiresIn}`);return{rawExpiresIn,expiresIn,exp:Date.now()+expiresIn}}var dte={day:24*60*60*1e3,month:30*24*60*60*1e3,season:90*24*60*60*1e3,year:365*24*60*60*1e3};function pte(e={},t){let r=e?.expiresValue,n=e?.expiresUnit,i=r!=null&&r!=="",o=n!=null&&n!=="";if(!i&&!o)return null;let s=Number(r);if(!Number.isFinite(s)||s<=0)throw new kt("INVALID_EXPIRES_VALUE",`Invalid expiresValue option: ${r}`);let a=typeof n=="string"?n.trim():"";if(!["day","month","season","year"].includes(a))throw new kt("INVALID_EXPIRES_UNIT",`Invalid expiresUnit option: ${n}`);let u=Number(s.toFixed(2)),l=u*dte[a];if(t&&Math.abs(t.expiresIn-l)>1)throw new kt("INVALID_DURATION_INPUT",`expiresValue/expiresUnit do not match expiresIn option: ${r}${a} != ${e?.expiresIn}`);return{expiresValue:String(u),expiresUnit:a}}function mte(e={}){let t=e?.count;if(t==null||t==="")throw new kt("INVALID_SHARE_COUNT",`Invalid count option: ${t}`);let r=Number(t);if(!Number.isSafeInteger(r)||r<=0)throw new kt("INVALID_SHARE_COUNT",`Invalid count option: ${t}`);let n=e?.usedCount??0,i=Number(n);if(!Number.isSafeInteger(i)||i<0||i>r)throw new kt("INVALID_SHARE_USED_COUNT",`Invalid usedCount option: ${n}`);return{count:r,usedCount:i}}function gte(payload,options={}){let type=payload?.type,name=payload?.name;if(!type||!name)throw new kt("INVALID_PAYLOAD","payload type and name are required");let token=payload?.token;if(token!=null){if(typeof token!="string"||token.length<1)throw new kt("INVALID_CUSTOM_TOKEN",`Invalid custom token: ${token}`);if((z.read(Cn)||[]).find(t=>t.token===token&&t.type===type&&t.name===name))throw new kt("DUPLICATE_TOKEN",`Token ${token} already exists`)}if(type==="col"){if(!(z.read(Fi)||[]).find(r=>r.name===name))throw new kt("INVALID_COLLECTION",`collection ${name} not found`)}else if(type==="file"){if(!(z.read(ci)||[]).find(r=>r.name===name))throw new kt("INVALID_FILE",`file ${name} not found`)}else if(type==="sub"){if(!(z.read(Kn)||[]).find(r=>r.name===name))throw new kt("INVALID_SUB",`sub ${name} not found`)}else throw new kt("INVALID_TYPE",`type ${name} not supported`);let expirationMode=cte(options?.mode)??lte(options),durationExpiration=null,durationInput=null,exp,countExpiration=null;expirationMode==="datetime"?exp=fte(options):expirationMode==="count"?countExpiration=mte(options):(durationExpiration=hte(options,{required:expirationMode==="duration"}),durationExpiration&&(durationInput=pte(options,durationExpiration)),exp=durationExpiration?.exp);let nanoid=eval('require("nanoid")'),tokens=z.read(Cn)||[];if(!token)do token=nanoid.customAlphabet(nanoid.urlAlphabet)();while(tokens.find(e=>e.token===token&&e.type===type&&e.name===name));let normalizedMode=expirationMode==="datetime"?"datetime":expirationMode==="count"?"count":durationExpiration?"duration":void 0,safePayload={...payload};delete safePayload.mode,delete safePayload.exp,delete safePayload.expiresIn,delete safePayload.expiresValue,delete safePayload.expiresUnit,delete safePayload.count,delete safePayload.usedCount,AA(safePayload);let tokenData={...safePayload,token,createdAt:Date.now(),...normalizedMode?{mode:normalizedMode}:{},...normalizedMode==="datetime"?{exp}:normalizedMode==="count"?{count:countExpiration.count,usedCount:countExpiration.usedCount}:durationExpiration?{expiresIn:durationExpiration.rawExpiresIn,...durationInput||{},exp}:{}};return BE(tokens,tokenData,TE()),z.write(tokens,Cn),tokenData}function vte(e,t,r){let n=z.read(Cn)||[],i=n.find(s=>s.token===e&&s.type===t&&s.name===r);if(!i)throw new Cs("RESOURCE_NOT_FOUND",`Share ${t}/${r}/${e} does not exist!`);let o=n.filter(s=>!(s.token===e&&s.type===t&&s.name===r));return z.write(o,Cn),i}function F$(e,{token:t,type:r,name:n,pathname:i}){return e.token===t&&(r?e.type===r:!0)&&(n?e.name===n:!0)&&(i?`/share/${e.type}/${e.name}`===i||i.startsWith(`/share/${e.type}/${e.name}/`):!0)}function B$(e){if(e.exp!=null&&e.exp<=Date.now())return!1;if(e.mode==="count"){let t=Number(e.count),r=e.usedCount==null?0:Number(e.usedCount);return Number.isSafeInteger(t)&&t>0&&Number.isSafeInteger(r)&&r>=0&&rF$(o,e)&&B$(o));if(r<0)return null;let n=t[r];if(n.mode!=="count")return n;let i={...n,usedCount:Number(n.usedCount??0)+1};return t[r]=i,z.write(t,Cn),i}function i6(e){return(z.read(Cn)||[]).find(r=>F$(r,e)&&B$(r))||null}function wte(e){if(e==null||e===""||e==="permanent")return!1;if(e==="archive")return!0;throw new kt("INVALID_DELETE_MODE",`Unsupported delete mode: ${e}`)}function I$(){return JSON.stringify({code:0,message:"success",result:[]},null,2)}function $$(e){let t=e.target==="SurgeMac",r=t?e.mihomoExternal:void 0,n=t?e.mihomoMerge:void 0,i=t?e.mihomoMergeName:void 0,o;if(t&&e.mihomoLocalPort!=null){let s=parseInt(e.mihomoLocalPort,10);Number.isInteger(s)&&s>=1&&s<=65535&&(o=s)}return{useMihomoExternal:t,mihomoExternal:r,mihomoMerge:n,mihomoMergeName:i,mihomoLocalPort:o}}function o6(e){e.get("/share/col/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,z.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await jh(t,r)}),e.get("/share/col/:name",jh),e.get("/share/sub/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,z.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Mh(t,r)}),e.get("/share/sub/:name",Mh),e.get("/download/collection/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,z.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await jh(t,r)}),e.get("/download/collection/:name",jh),e.get("/download/:name/:target",async(t,r)=>{let{target:n}=t.params;n&&(t.query.target=n,z.info(`\u4F7F\u7528\u8DEF\u7531\u6307\u5B9A\u76EE\u6807: ${n}`)),await Mh(t,r)}),e.get("/download/:name",Mh),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 jh(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 Mh(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 jh(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 Mh(t,r)})}async function Mh(e,t){let{name:r,nezhaIndex:n}=e.params,i=e.path?.startsWith("/share/"),{useMihomoExternal:o,mihomoMerge:s,mihomoMergeName:a,mihomoExternal:u,mihomoLocalPort:l}=$$(e.query),f=e.query.platform||e.query.target||sy(e.headers)||"JSON",m=e.headers["user-agent"]||e.headers["User-Agent"];z.info(`\u6B63\u5728\u4E0B\u8F7D\u8BA2\u9605\uFF1A${r} \u8BF7\u6C42 User-Agent: ${m} \u8BF7\u6C42 target: ${e.query.target} \u5B9E\u9645\u8F93\u51FA: ${f}`);let{url:p,ua:d,content:v,mergeSources:g,ignoreFailedRemoteSub:y,produceType:w,includeUnsupportedProxy:E,resultFormat:S,proxy:F,noCache:_,_fakeNode:H,fakeSub:V}=e.query,C=e.query.prettyYaml??e.query["pretty-yaml"],I={_req:{method:e.method,url:e.url,path:e.path,query:e.query,params:e.params,headers:e.headers,body:e.body,socket:{remoteAddress:e.socket?.remoteAddress}}};if(e.query.$options){let M={};try{M=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let D of e.query.$options.split("&")){let O=D.split("=")[0],q=D.split("=")[1];M[O]=q==null||q===""?!0:decodeURIComponent(q)}}z.info(`\u4F20\u5165 $options: ${JSON.stringify(M)}`),Object.assign(I,M)}if(i&&V){z.warn(`\u5206\u4EAB\u94FE\u63A5\u7981\u6B62\u4F7F\u7528 fakeSub: ${r}`),xr(t,new kt("UNSUPPORTED_SHARE_FAKE_SUB","share/sub \u4E0D\u652F\u6301 fakeSub \u53C2\u6570"),400);return}if(i&&(p!=null&&p!==""||v!=null&&v!=="")){z.warn(`\u5206\u4EAB\u94FE\u63A5\u7981\u6B62\u4F7F\u7528 url/content: ${r}`),xr(t,new kt("UNSUPPORTED_SHARE_SUB_SOURCE_OVERRIDE","share/sub \u4E0D\u652F\u6301 url \u6216 content \u53C2\u6570"),400);return}if(i&&g){z.warn(`\u5206\u4EAB\u94FE\u63A5\u7981\u6B62\u4F7F\u7528 mergeSources: ${r}`),xr(t,new kt("UNSUPPORTED_SHARE_SUB_MERGE_SOURCES","share/sub \u4E0D\u652F\u6301 mergeSources \u53C2\u6570"),400);return}p&&(z.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 URL: ${Ys(p)}`),/^https?:\/\//.test(p)||(v=p,z.info("URL \u4E0D\u662F\u94FE\u63A5\uFF0C\u89C6\u4E3A\u672C\u5730\u8BA2\u9605"))),V&&z.info(`\u4F7F\u7528\u5047\u8BA2\u9605, \u4E0D\u518D\u901A\u8FC7\u5355\u6761\u8BA2\u9605\u540D\u79F0 ${r} \u67E5\u8BE2`),v&&z.info(`\u6307\u5B9A\u672C\u5730\u8BA2\u9605: ${v}`),F&&z.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${F}`),d&&z.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 User-Agent: ${d}`),g&&z.info(`\u6307\u5B9A\u5408\u5E76\u6765\u6E90: ${g}`),y!=null&&y!==""&&z.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${y}`),w&&z.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${w}`),E&&z.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${E}`),C&&z.info(`\u6307\u5B9A\u8F93\u51FA\u6613\u8BFB YAML: ${C}`),s&&z.info(`\u6307\u5B9A\u5408\u5E76 mihomo External: ${s}`),a&&z.info(`\u6307\u5B9A\u5408\u5E76 mihomo External \u540D\u79F0: ${a}`),o&&z.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 mihomo External"),u&&z.info(`\u624B\u52A8\u6307\u5B9A\u4E86 mihomo External \u94FE\u63A5\u53C2\u6570: ${u}`),_&&z.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${_}`);let L=z.read(Kn),R=H?{name:"fakeNodeInfo",source:"local",content:"invalid share = ss, 1.0.0.1, 80, encrypt-method=aes-128-gcm, password=password"}:{name:"fakeSub",source:"remote",url:""},k=H||V?R:dr(L,r);if(k)try{k.passThroughUA&&(z.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${m}`),d=m);let N={type:"subscription",name:r,platform:f,url:p,ua:d,content:v,mergeSources:g,ignoreFailedRemoteSub:y,produceType:w,produceOpts:{"include-unsupported-proxy":E,useMihomoExternal:o,merge:s,mergeName:a,mihomoExternal:u,localPort:l,prettyYaml:C},$options:I,proxy:F,noCache:_};(H||V)&&(H&&z.info("\u8FD4\u56DE\u5047\u8282\u70B9\u4FE1\u606F"),delete N.name,N.subscription=R);let D=await Ws(N),O;if(k.source!=="local"||["localFirst","remoteFirst"].includes(k.mergeSources))try{p=`${p||k.url}`.split(/[\r\n]+/).map(ee=>ee.trim()).filter(ee=>ee.length)?.[0]||"";let J={},Y=p.split("#");if(p=p.split("#")[0],Y.length>1)try{J=JSON.parse(decodeURIComponent(Y[1]))}catch{for(let se of Y[1].split("&")){let le=se.split("=")[0],ve=se.split("=")[1];J[le]=ve==null||ve===""?!0:decodeURIComponent(ve)}}if(!J.noFlow&&/^https?/.test(p)&&(O=await Wo(J?.insecure?`${p}#insecure`:p,J.flowUserAgent,void 0,F||k.proxy,J.flowUrl,J.flowHeaders),O)){let ee=Qf(O,!0);ee?.["subscription-userinfo"]&&t.set("subscription-userinfo",ee["subscription-userinfo"]),ee?.["profile-web-page-url"]&&t.set("profile-web-page-url",ee["profile-web-page-url"]),ee?.["plan-name"]&&t.set("plan-name",ee["plan-name"])}}catch(J){z.error(`\u8BA2\u9605 ${r} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(J)}`)}if(k.subUserinfo){let J;if(/^https?:\/\//.test(k.subUserinfo))try{J=await Wo(void 0,void 0,void 0,F||k.proxy,k.subUserinfo)}catch(ee){z.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${k.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(ee)}`)}else J=k.subUserinfo;let Y=Qf([J,O].filter(ee=>ee).join(";"),!0);Y?.["subscription-userinfo"]&&t.set("subscription-userinfo",Y["subscription-userinfo"]),Y?.["profile-web-page-url"]&&t.set("profile-web-page-url",Y["profile-web-page-url"]),Y?.["plan-name"]&&t.set("plan-name",Y["plan-name"])}f==="JSON"?(S==="nezha"?D=x$(D):S==="nezha-monitor"&&(!Array.isArray(D)||D.length===0?D=I$():(n=/^\d+$/.test(n)?parseInt(n,10):D.findIndex(J=>J.name===n),D=await P$(D[n],n,e.query))),t.set("Content-Type","application/json;charset=utf-8")):t.set("Content-Type","text/plain; charset=utf-8"),I?._res?.headers&&Object.entries(I._res.headers).forEach(([J,Y])=>{Y==null?t.removeHeader(J):t.set(J,Y)}),I?._res?.status&&t.status(I._res.status);let q=await s6({res:t,body:D,process:k.process,targetPlatform:f,source:{[k.name]:k},$options:I});t.send(await Mp({res:t,body:q,configs:[FA({req:e,type:"sub",name:r,findShareToken:i6}),k]}))}catch(M){z.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${M.message??M}`),z.error(M.message??M),xr(t,new Ss("INTERNAL_SERVER_ERROR",`Failed to download subscription: ${r}`,`Reason: ${M.message??M}`))}else z.error(`\u{1F30D} Sub-Store \u4E0B\u8F7D\u8BA2\u9605\u5931\u8D25 \u274C \u672A\u627E\u5230\u8BA2\u9605\uFF1A${r}\uFF01`),xr(t,new Cs("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404)}async function jh(e,t){let{name:r,nezhaIndex:n}=e.params,{useMihomoExternal:i,mihomoMerge:o,mihomoMergeName:s,mihomoExternal:a,mihomoLocalPort:u}=$$(e.query),l=e.query.platform||e.query.target||sy(e.headers)||"JSON",f=z.read(Fi),m=dr(f,r),p=e.headers["user-agent"]||e.headers["User-Agent"];z.info(`\u6B63\u5728\u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\uFF1A${r} \u8BF7\u6C42 User-Agent: ${p} \u8BF7\u6C42 target: ${e.query.target} \u5B9E\u9645\u8F93\u51FA: ${l}`);let{ignoreFailedRemoteSub:d,produceType:v,includeUnsupportedProxy:g,resultFormat:y,proxy:w,noCache:E}=e.query,S=e.query.prettyYaml??e.query["pretty-yaml"],F={_req:{method:e.method,url:e.url,path:e.path,query:e.query,params:e.params,headers:e.headers,body:e.body,socket:{remoteAddress:e.socket?.remoteAddress}}};if(e.query.$options){let _={};try{_=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let V of e.query.$options.split("&")){let C=V.split("=")[0],I=V.split("=")[1];_[C]=I==null||I===""?!0:decodeURIComponent(I)}}z.info(`\u4F20\u5165 $options: ${JSON.stringify(_)}`),Object.assign(F,_)}if(w&&z.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${w}`),d!=null&&d!==""&&z.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u8BA2\u9605: ${d}`),v&&z.info(`\u6307\u5B9A\u751F\u4EA7\u7C7B\u578B: ${v}`),g&&z.info(`\u5305\u542B\u5B98\u65B9/\u5546\u5E97\u7248\u4E0D\u652F\u6301\u7684\u534F\u8BAE: ${g}`),S&&z.info(`\u6307\u5B9A\u8F93\u51FA\u6613\u8BFB YAML: ${S}`),o&&z.info(`\u6307\u5B9A\u5408\u5E76 mihomo External: ${o}`),s&&z.info(`\u6307\u5B9A\u5408\u5E76 mihomo External \u540D\u79F0: ${s}`),i&&z.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 mihomo External"),a&&z.info(`\u624B\u52A8\u6307\u5B9A\u4E86 mihomo External \u94FE\u63A5\u53C2\u6570: ${a}`),E&&z.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${E}`),m)try{let _=await Ws({type:"collection",name:r,platform:l,ignoreFailedRemoteSub:d,produceType:v,produceOpts:{"include-unsupported-proxy":g,useMihomoExternal:i,merge:o,mergeName:s,mihomoExternal:a,localPort:u,prettyYaml:S},$options:F,proxy:w,noCache:E,ua:p}),H;if(m.firstSubFlow!==!1){let L=z.read(Kn),R=m.subscriptions;if(R.length>0){let k=dr(L,R[0]);if(k.source!=="local"||["localFirst","remoteFirst"].includes(k.mergeSources))try{let M=`${k.url}`.split(/[\r\n]+/).map(O=>O.trim()).filter(O=>O.length)?.[0]||"",N={},D=M.split("#");if(M=M.split("#")[0],D.length>1)try{N=JSON.parse(decodeURIComponent(D[1]))}catch{for(let q of D[1].split("&")){let J=q.split("=")[0],Y=q.split("=")[1];N[J]=Y==null||Y===""?!0:decodeURIComponent(Y)}}!N.noFlow&&/^https?:/.test(M)&&(H=await Wo(N?.insecure?`${M}#insecure`:M,N.flowUserAgent,void 0,w||k.proxy||m.proxy,N.flowUrl,N.flowHeaders))}catch(M){z.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4E2D\u7684\u5B50\u8BA2\u9605 ${k.name} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${M.message??M}`)}if(k.subUserinfo){let M;if(/^https?:\/\//.test(k.subUserinfo))try{M=await Wo(void 0,void 0,void 0,w||k.proxy,k.subUserinfo)}catch(N){z.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${k.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(N)}`)}else M=k.subUserinfo;H=[M,H].filter(N=>N).join("; ")}}z.info(`\u7EC4\u5408\u8BA2\u9605 ${r} \u900F\u4F20\u7684\u7684\u6D41\u91CF\u4FE1\u606F: ${H}`)}let V;if(/^https?:\/\//.test(m.subUserinfo))try{V=await Wo(void 0,void 0,void 0,w||m.proxy,m.subUserinfo)}catch(L){z.error(`\u7EC4\u5408\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${m.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(L)}`)}else V=m.subUserinfo;let C=[V,H].filter(L=>L).join("; ");if(C){let L=Qf(C,!0);L?.["subscription-userinfo"]&&t.set("subscription-userinfo",L["subscription-userinfo"]),L?.["profile-web-page-url"]&&t.set("profile-web-page-url",L["profile-web-page-url"]),L?.["plan-name"]&&t.set("plan-name",L["plan-name"])}l==="JSON"?(y==="nezha"?_=x$(_):y==="nezha-monitor"&&(!Array.isArray(_)||_.length===0?_=I$():(n=/^\d+$/.test(n)?parseInt(n,10):_.findIndex(L=>L.name===n),_=await P$(_[n],n,e.query))),t.set("Content-Type","application/json;charset=utf-8")):t.set("Content-Type","text/plain; charset=utf-8"),F?._res?.headers&&Object.entries(F._res.headers).forEach(([L,R])=>{R==null?t.removeHeader(L):t.set(L,R)}),F?._res?.status&&t.status(F._res.status);let I=await s6({res:t,body:_,process:m.process,targetPlatform:l,source:{_collection:m},$options:F});t.send(await Mp({res:t,body:I,configs:[FA({req:e,type:"col",name:r,findShareToken:i6}),m]}))}catch(_){z.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${_}`),xr(t,new Ss("INTERNAL_SERVER_ERROR",`Failed to download collection: ${r}`,`Reason: ${_.message??_}`))}else z.error("\u{1F30D} Sub-Store \u4E0B\u8F7D\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C \u672A\u627E\u5230\u7EC4\u5408\u8BA2\u9605\uFF1A${r}\uFF01`),xr(t,new Cs("RESOURCE_NOT_FOUND",`Collection ${r} does not exist!`),404)}async function P$(e,t,r){let n={code:0,message:"success",result:[]};try{let{isLoon:i,isSurge:o}=z.env;if(!i&&!o)throw new Error("\u4EC5\u652F\u6301 Loon \u548C Surge(ability=http-client-policy)");let s=Ft.produce([e],i?"Loon":"Surge");if(!s)throw new Error("\u5F53\u524D\u5BA2\u6237\u7AEF\u4E0D\u517C\u5BB9\u6B64\u8282\u70B9");let a=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}],u=r.number||Math.max(...a.map(l=>l.number))||3;for(let l of a){let m={monitor_id:a.indexOf(l),server_id:t,monitor_name:l.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=s2(r.name)),/^[a-z]{2}$/i.test(i)){let o=Math.round(new Date().getTime()/1e3),s=r._unavailable?0:o,a=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||(hr(r.server)?r.server:""),host:{Platform:"Sub-Store",PlatformVersion:Ih.version,CPU:[],MemTotal:1024,DiskTotal:1024,SwapTotal:1024,Arch:"",Virtualization:"",BootTime:o-a,CountryCode:i,Version:"0.0.1"},status:{CPU:0,MemUsed:0,SwapUsed:0,DiskUsed:0,NetInTransfer:0,NetOutTransfer:0,NetInSpeed:0,NetOutSpeed:0,Uptime:a,Load1:0,Load5:0,Load15:0,TcpConnCount:0,UdpConnCount:0,ProcessCount:0}})}}),JSON.stringify(t,null,2)}var eAe=P(x());function T$(e){return Object.keys(e).map(Ys).join(", ")}function a6(e){e.post("/api/preview/sub",Ete),e.post("/api/preview/collection",bte),e.post("/api/preview/file",yte)}async function yte(e,t){try{let r=Qg(e.body),n="";pu(r)?n=await $A(r,{notifyTitle:"\u{1F30D} Sub-Store \u9884\u89C8\u6587\u4EF6\u5931\u8D25"}):n=await t2(r,{notifyTitle:"\u{1F30D} Sub-Store \u9884\u89C8\u6587\u4EF6\u5931\u8D25"});let i=(Array.isArray(n)?n:[n]).flat(),o=i.filter(a=>a!=null&&a!=="").join(` `),s=Array.isArray(r.process)&&r.process.length>0?await Ft.process({$files:i,$content:o,$file:r},r.process):{$content:o,$files:i};es(t,{original:o,processed:ql(s?.$content??"")})}catch(r){z.error(r.message??r),xr(t,new Ss("INTERNAL_SERVER_ERROR","Failed to preview file",`Reason: ${r.message??r}`))}}async function Ete(e,t){let r=e.body,n=Sc(r.ignoreFailedRemoteSub);try{let i=e.query.target||"JSON",o,s;if(r.source==="local"&&!["localFirst","remoteFirst"].includes(r.mergeSources))o=r.content,s=r.content;else{let l={},f=await Promise.all(r.url.split(/[\r\n]+/).map(m=>m.trim()).filter(m=>m.length).map(async m=>{try{return await Bs(m,r.ua,void 0,r.proxy,void 0,void 0,void 0,!0,{returnRaw:!0})}catch(p){return l[m]=p,z.error(`\u8BA2\u9605 ${r.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Ys(m)} \u53D1\u751F\u9519\u8BEF: ${p}`),""}}));if(o=f.map(m=>m.result??m),s=f.map(m=>m.raw??m),Object.keys(l).length>0){let m=`\u8BA2\u9605 ${r.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${T$(l)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;du({mode:n,message:m,notify:()=>{z.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${r.name}`,m)}})}r.mergeSources==="localFirst"?(o.unshift(r.content),s.unshift(r.content)):r.mergeSources==="remoteFirst"&&(o.push(r.content),s.push(r.content))}let a=(Array.isArray(o)?o:[o]).map(l=>Ft.parse(l)).flat();a.forEach((l,f)=>{l.id=f,l._subName=r.name,l._subDisplayName=r.displayName});let u=await Ft.process(a,r.process||[],i,{[r.name]:r},void 0,s);es(t,{original:a,processed:u})}catch(i){if(po(n)){Cc({mode:n,error:i,notify:o=>{z.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${r.name}`,`\u{1F914} \u539F\u56E0\uFF1A${o.message??o}`)}}),z.error(`\u8BA2\u9605 ${r.name} \u9884\u89C8\u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${i.message??i}`),es(t,{original:[],processed:[]});return}z.error(i.message??i),xr(t,new Ss("INTERNAL_SERVER_ERROR","Failed to preview subscription",`Reason: ${i.message??i}`))}}async function bte(e,t){let r=e.body,n=Sc(r.ignoreFailedRemoteSub);try{let i=z.read(Kn),o=[...r.subscriptions],s=r.subscriptionTags;Array.isArray(s)&&s.length>0&&i.forEach(p=>{Array.isArray(p.tag)&&p.tag.length>0&&!o.includes(p.name)&&p.tag.some(d=>s.includes(d))&&o.push(p.name)});let a={},u={},l={};if(await Promise.all(o.map(async p=>{let d=dr(i,p),v=Sc(d.ignoreFailedRemoteSub);try{let g,y;if(d.source==="local"&&!["localFirst","remoteFirst"].includes(d.mergeSources))g=d.content,y=d.content;else{let S={},F=await Promise.all(d.url.split(/[\r\n]+/).map(_=>_.trim()).filter(_=>_.length).map(async _=>{try{return await Bs(_,d.ua,void 0,d.proxy,void 0,void 0,void 0,!0,{returnRaw:!0})}catch(H){return S[_]=H,z.error(`\u8BA2\u9605 ${d.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Ys(_)} \u53D1\u751F\u9519\u8BEF: ${H}`),""}}));if(g=F.map(_=>_.result??_),y=F.map(_=>_.raw??_),Object.keys(S).length>0){let _=`\u8BA2\u9605 ${d.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${T$(S)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;du({mode:v,message:_,notify:()=>{z.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${d.name}`,_)}})}d.mergeSources==="localFirst"?(g.unshift(d.content),y.unshift(d.content)):d.mergeSources==="remoteFirst"&&(g.push(d.content),y.push(d.content))}let w=(Array.isArray(g)?g:[g]).map(S=>Ft.parse(S)).flat();w.forEach(S=>{S._subName=d.name,S._subDisplayName=d.displayName,S._collectionName=r.name,S._collectionDisplayName=r.displayName});let E=Array.isArray(y)?y:[y];w=await Ft.process(w,d.process||[],"JSON",{[d.name]:d,_collection:r},void 0,E),a[p]=w,l[p]=E}catch(g){if(po(v)){Cc({mode:v,error:g,notify:y=>{z.notify("\u{1F30D} Sub-Store \u9884\u89C8\u8BA2\u9605\u5931\u8D25",`\u274C ${d.name}`,`\u{1F914} \u539F\u56E0\uFF1A${y.message??y}`)}}),z.error(`\u8BA2\u9605 ${d.name} \u5728\u7EC4\u5408\u8BA2\u9605\u9884\u89C8\u4E2D\u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${g.message??g}`),a[p]=[],l[p]=[];return}u[p]=g,l[p]=void 0,z.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605 ${r.name} \u4E2D\u7684\u5B50\u8BA2\u9605: ${d.name} \u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${g}\uFF01`)}})),Object.keys(u).length>0){let p=`\u7EC4\u5408\u8BA2\u9605 ${r.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(u).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`,d=()=>{z.notify("\u{1F30D} Sub-Store \u9884\u89C8\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${r.name}`,p)};Object.keys(a).length>0&&po(n)?(Object.keys(u).forEach(g=>{l[g]=[]}),Sh(n)&&d()):du({mode:n,message:p,notify:d})}let f=Array.prototype.concat.apply([],o.map(p=>a[p]||[]));f.forEach((p,d)=>{p.id=d,p._collectionName=r.name,p._collectionDisplayName=r.displayName});let m=await Ft.process(f,r.process||[],"JSON",{_collection:r},void 0,l);es(t,{original:f,processed:m})}catch(i){if(po(n)){Cc({mode:n,error:i,notify:o=>{z.notify("\u{1F30D} Sub-Store \u9884\u89C8\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${r.name}`,`\u{1F914} \u539F\u56E0\uFF1A${o.message??o}`)}}),z.error(`\u7EC4\u5408\u8BA2\u9605 ${r.name} \u9884\u89C8\u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${i.message??i}`),es(t,{original:[],processed:[]});return}z.error(i.message??i),xr(t,new Ss("INTERNAL_SERVER_ERROR","Failed to preview collection",`Reason: ${i.message??i}`))}}var oAe=P(x());function u6(e){e.post("/api/utils/node-info",Ate)}async function Ate(e,t){let r=e.body,n=e.query.lang||"zh-CN",i;try{i=I2.URI.produce(r)}catch{}try{let s=await Yi().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(a=>{let u=JSON.parse(a.body);if(u.status!=="success")throw new Error(u.message);return delete u.status,u});es(t,{shareUrl:i,info:s})}catch(o){xr(t,new Mm("FAILED_TO_GET_NODE_INFO","Failed to get node info",`Reason: ${o}`))}}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${w1} \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 `);ey();Ste();function Ste(){let e=ny({substore:z});o6(e),a6(e),IA(e),u6(e),e.options("/",(t,r)=>{r.status(200).end()}),e.start()}})(); /*! Bundled license information: ieee754/index.js: (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) buffer/index.js: (*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT *) jsrsasign/lib/jsrsasign.js: (*! CryptoJS v3.1.2 core-fix.js * code.google.com/p/crypto-js * (c) 2009-2013 by Jeff Mott. All rights reserved. * code.google.com/p/crypto-js/wiki/License * THIS IS FIX of 'core.js' to fix Hmac issue. * https://code.google.com/p/crypto-js/issues/detail?id=84 * https://crypto-js.googlecode.com/svn-history/r667/branches/3.x/src/core.js *) (*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ *) (*! (c) Tom Wu, Kenji Urushima | http://www-cs-students.stanford.edu/~tjw/jsbn/ *) (*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib *) (*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval *) lodash/lodash.js: (** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors *) @scure/base/index.js: (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/ciphers/utils.js: (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *) @noble/hashes/utils.js: (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/utils.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/modular.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/curve.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/montgomery.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/weierstrass.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/ed25519.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/nist.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/post-quantum/utils.js: (*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *) @noble/post-quantum/_crystals.js: (*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *) @noble/post-quantum/ml-kem.js: (*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *) @noble/post-quantum/hybrid.js: (*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *) @noble/curves/utils.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/modular.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/curve.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/weierstrass.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/nist.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/edwards.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/abstract/montgomery.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/ed25519.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) */