(()=>{var Uk=Object.create;var kv=Object.defineProperty;var Hk=Object.getOwnPropertyDescriptor;var qk=Object.getOwnPropertyNames;var Mk=Object.getPrototypeOf,jk=Object.prototype.hasOwnProperty;var Ov=(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),Kk=(e,t)=>{for(var r in t)kv(e,r,{get:t[r],enumerable:!0})},Vk=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of qk(t))!jk.call(e,i)&&i!==r&&kv(e,i,{get:()=>t[i],enumerable:!(n=Hk(t,i))||n.enumerable});return e};var P=(e,t,r)=>(r=e!=null?Uk(Mk(e)):{},Vk(t||!e||!e.__esModule?kv(r,"default",{value:e,enumerable:!0}):r,e));var Ys=Ce((Nv,l3)=>{"use strict";var ZQ=P(x()),ed=function(e){return e&&e.Math===Math&&e};l3.exports=ed(typeof globalThis=="object"&&globalThis)||ed(typeof window=="object"&&window)||ed(typeof self=="object"&&self)||ed(typeof global=="object"&&global)||ed(typeof Nv=="object"&&Nv)||function(){return this}()||Function("return this")()});var Aa=Ce((JQ,h3)=>{"use strict";var QQ=P(x());h3.exports=function(e){try{return!!e()}catch{return!0}}});var Iu=Ce((eee,d3)=>{"use strict";var tee=P(x()),zk=Aa();d3.exports=!zk(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Lv=Ce((ree,p3)=>{"use strict";var nee=P(x()),Gk=Aa();p3.exports=!Gk(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")})});var H0=Ce((see,g3)=>{"use strict";var iee=P(x()),Wk=Lv(),U0=Function.prototype.call;g3.exports=Wk?U0.bind(U0):function(){return U0.apply(U0,arguments)}});var y3=Ce(w3=>{"use strict";var aee=P(x()),m3={}.propertyIsEnumerable,v3=Object.getOwnPropertyDescriptor,Yk=v3&&!m3.call({1:2},1);w3.f=Yk?function(t){var r=v3(this,t);return!!r&&r.enumerable}:m3});var Uv=Ce((uee,E3)=>{"use strict";var cee=P(x());E3.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}});var yo=Ce((fee,S3)=>{"use strict";var lee=P(x()),b3=Lv(),A3=Function.prototype,Hv=A3.call,Xk=b3&&A3.bind.bind(Hv,Hv);S3.exports=b3?Xk:function(e){return function(){return Hv.apply(e,arguments)}}});var D3=Ce((hee,_3)=>{"use strict";var dee=P(x()),C3=yo(),Zk=C3({}.toString),Jk=C3("".slice);_3.exports=function(e){return Jk(Zk(e),8,-1)}});var B3=Ce((pee,F3)=>{"use strict";var gee=P(x()),Qk=yo(),eO=Aa(),tO=D3(),qv=Object,rO=Qk("".split);F3.exports=eO(function(){return!qv("z").propertyIsEnumerable(0)})?function(e){return tO(e)==="String"?rO(e,""):qv(e)}:qv});var Mv=Ce((mee,I3)=>{"use strict";var vee=P(x());I3.exports=function(e){return e==null}});var jv=Ce((wee,$3)=>{"use strict";var yee=P(x()),nO=Mv(),sO=TypeError;$3.exports=function(e){if(nO(e))throw new sO("Can't call method on "+e);return e}});var q0=Ce((Eee,P3)=>{"use strict";var bee=P(x()),iO=B3(),oO=jv();P3.exports=function(e){return iO(oO(e))}});var xi=Ce((Aee,x3)=>{"use strict";var See=P(x()),Kv=typeof document=="object"&&document.all;x3.exports=typeof Kv>"u"&&Kv!==void 0?function(e){return typeof e=="function"||e===Kv}:function(e){return typeof e=="function"}});var sl=Ce((Cee,T3)=>{"use strict";var _ee=P(x()),aO=xi();T3.exports=function(e){return typeof e=="object"?e!==null:aO(e)}});var zv=Ce((Dee,R3)=>{"use strict";var Fee=P(x()),Vv=Ys(),uO=xi(),cO=function(e){return uO(e)?e:void 0};R3.exports=function(e,t){return arguments.length<2?cO(Vv[e]):Vv[e]&&Vv[e][t]}});var O3=Ce((Bee,k3)=>{"use strict";var Iee=P(x()),fO=yo();k3.exports=fO({}.isPrototypeOf)});var H3=Ce(($ee,U3)=>{"use strict";var Pee=P(x()),lO=Ys(),N3=lO.navigator,L3=N3&&N3.userAgent;U3.exports=L3?String(L3):""});var G3=Ce((xee,z3)=>{"use strict";var Tee=P(x()),V3=Ys(),Gv=H3(),q3=V3.process,M3=V3.Deno,j3=q3&&q3.versions||M3&&M3.version,K3=j3&&j3.v8,Ti,M0;K3&&(Ti=K3.split("."),M0=Ti[0]>0&&Ti[0]<4?1:+(Ti[0]+Ti[1]));!M0&&Gv&&(Ti=Gv.match(/Edge\/(\d+)/),(!Ti||Ti[1]>=74)&&(Ti=Gv.match(/Chrome\/(\d+)/),Ti&&(M0=+Ti[1])));z3.exports=M0});var Wv=Ce((Ree,Y3)=>{"use strict";var kee=P(x()),W3=G3(),hO=Aa(),dO=Ys(),pO=dO.String;Y3.exports=!!Object.getOwnPropertySymbols&&!hO(function(){var e=Symbol("symbol detection");return!pO(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&W3&&W3<41})});var Yv=Ce((Oee,X3)=>{"use strict";var Nee=P(x()),gO=Wv();X3.exports=gO&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Xv=Ce((Lee,Z3)=>{"use strict";var Uee=P(x()),mO=zv(),vO=xi(),wO=O3(),yO=Yv(),EO=Object;Z3.exports=yO?function(e){return typeof e=="symbol"}:function(e){var t=mO("Symbol");return vO(t)&&wO(t.prototype,EO(e))}});var Q3=Ce((Hee,J3)=>{"use strict";var qee=P(x()),bO=String;J3.exports=function(e){try{return bO(e)}catch{return"Object"}}});var t5=Ce((Mee,e5)=>{"use strict";var jee=P(x()),AO=xi(),SO=Q3(),CO=TypeError;e5.exports=function(e){if(AO(e))return e;throw new CO(SO(e)+" is not a function")}});var n5=Ce((Kee,r5)=>{"use strict";var Vee=P(x()),_O=t5(),DO=Mv();r5.exports=function(e,t){var r=e[t];return DO(r)?void 0:_O(r)}});var i5=Ce((zee,s5)=>{"use strict";var Gee=P(x()),Zv=H0(),Jv=xi(),Qv=sl(),FO=TypeError;s5.exports=function(e,t){var r,n;if(t==="string"&&Jv(r=e.toString)&&!Qv(n=Zv(r,e))||Jv(r=e.valueOf)&&!Qv(n=Zv(r,e))||t!=="string"&&Jv(r=e.toString)&&!Qv(n=Zv(r,e)))return n;throw new FO("Can't convert object to primitive value")}});var a5=Ce((Wee,o5)=>{"use strict";var Yee=P(x());o5.exports=!1});var j0=Ce((Xee,c5)=>{"use strict";var Zee=P(x()),u5=Ys(),BO=Object.defineProperty;c5.exports=function(e,t){try{BO(u5,e,{value:t,configurable:!0,writable:!0})}catch{u5[e]=t}return t}});var K0=Ce((Jee,h5)=>{"use strict";var Qee=P(x()),IO=a5(),$O=Ys(),PO=j0(),f5="__core-js_shared__",l5=h5.exports=$O[f5]||PO(f5,{});(l5.versions||(l5.versions=[])).push({version:"3.49.0",mode:IO?"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 ew=Ce((ete,p5)=>{"use strict";var tte=P(x()),d5=K0();p5.exports=function(e,t){return d5[e]||(d5[e]=t||{})}});var m5=Ce((rte,g5)=>{"use strict";var nte=P(x()),xO=jv(),TO=Object;g5.exports=function(e){return TO(xO(e))}});var Sa=Ce((ste,v5)=>{"use strict";var ite=P(x()),RO=yo(),kO=m5(),OO=RO({}.hasOwnProperty);v5.exports=Object.hasOwn||function(t,r){return OO(kO(t),r)}});var tw=Ce((ote,w5)=>{"use strict";var ate=P(x()),NO=yo(),LO=0,UO=Math.random(),HO=NO(1.1.toString);w5.exports=function(e){return"Symbol("+(e===void 0?"":e)+")_"+HO(++LO+UO,36)}});var b5=Ce((ute,E5)=>{"use strict";var cte=P(x()),qO=Ys(),MO=ew(),y5=Sa(),jO=tw(),KO=Wv(),VO=Yv(),il=qO.Symbol,rw=MO("wks"),zO=VO?il.for||il:il&&il.withoutSetter||jO;E5.exports=function(e){return y5(rw,e)||(rw[e]=KO&&y5(il,e)?il[e]:zO("Symbol."+e)),rw[e]}});var _5=Ce((fte,C5)=>{"use strict";var lte=P(x()),GO=H0(),A5=sl(),S5=Xv(),WO=n5(),YO=i5(),XO=b5(),ZO=TypeError,JO=XO("toPrimitive");C5.exports=function(e,t){if(!A5(e)||S5(e))return e;var r=WO(e,JO),n;if(r){if(t===void 0&&(t="default"),n=GO(r,e,t),!A5(n)||S5(n))return n;throw new ZO("Can't convert object to primitive value")}return t===void 0&&(t="number"),YO(e,t)}});var nw=Ce((hte,D5)=>{"use strict";var dte=P(x()),QO=_5(),eN=Xv();D5.exports=function(e){var t=QO(e,"string");return eN(t)?t:t+""}});var I5=Ce((pte,B5)=>{"use strict";var gte=P(x()),tN=Ys(),F5=sl(),sw=tN.document,rN=F5(sw)&&F5(sw.createElement);B5.exports=function(e){return rN?sw.createElement(e):{}}});var iw=Ce((mte,$5)=>{"use strict";var vte=P(x()),nN=Iu(),sN=Aa(),iN=I5();$5.exports=!nN&&!sN(function(){return Object.defineProperty(iN("div"),"a",{get:function(){return 7}}).a!==7})});var ow=Ce(x5=>{"use strict";var yte=P(x()),oN=Iu(),aN=H0(),uN=y3(),cN=Uv(),fN=q0(),lN=nw(),hN=Sa(),dN=iw(),P5=Object.getOwnPropertyDescriptor;x5.f=oN?P5:function(t,r){if(t=fN(t),r=lN(r),dN)try{return P5(t,r)}catch{}if(hN(t,r))return cN(!aN(uN.f,t,r),t[r])}});var R5=Ce((Ete,T5)=>{"use strict";var bte=P(x()),pN=Iu(),gN=Aa();T5.exports=pN&&gN(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var aw=Ce((Ate,k5)=>{"use strict";var Ste=P(x()),mN=sl(),vN=String,wN=TypeError;k5.exports=function(e){if(mN(e))return e;throw new wN(vN(e)+" is not an object")}});var z0=Ce(N5=>{"use strict";var _te=P(x()),yN=Iu(),EN=iw(),bN=R5(),V0=aw(),O5=nw(),AN=TypeError,uw=Object.defineProperty,SN=Object.getOwnPropertyDescriptor,cw="enumerable",fw="configurable",lw="writable";N5.f=yN?bN?function(t,r,n){if(V0(t),r=O5(r),V0(n),typeof t=="function"&&r==="prototype"&&"value"in n&&lw in n&&!n[lw]){var i=SN(t,r);i&&i[lw]&&(t[r]=n.value,n={configurable:fw in n?n[fw]:i[fw],enumerable:cw in n?n[cw]:i[cw],writable:!1})}return uw(t,r,n)}:uw:function(t,r,n){if(V0(t),r=O5(r),V0(n),EN)try{return uw(t,r,n)}catch{}if("get"in n||"set"in n)throw new AN("Accessors not supported");return"value"in n&&(t[r]=n.value),t}});var hw=Ce((Dte,L5)=>{"use strict";var Fte=P(x()),CN=Iu(),_N=z0(),DN=Uv();L5.exports=CN?function(e,t,r){return _N.f(e,t,DN(1,r))}:function(e,t,r){return e[t]=r,e}});var q5=Ce((Bte,H5)=>{"use strict";var Ite=P(x()),dw=Iu(),FN=Sa(),U5=Function.prototype,BN=dw&&Object.getOwnPropertyDescriptor,pw=FN(U5,"name"),IN=pw&&function(){}.name==="something",$N=pw&&(!dw||dw&&BN(U5,"name").configurable);H5.exports={EXISTS:pw,PROPER:IN,CONFIGURABLE:$N}});var j5=Ce(($te,M5)=>{"use strict";var Pte=P(x()),PN=yo(),xN=xi(),gw=K0(),TN=PN(Function.toString);xN(gw.inspectSource)||(gw.inspectSource=function(e){return TN(e)});M5.exports=gw.inspectSource});var z5=Ce((xte,V5)=>{"use strict";var Tte=P(x()),RN=Ys(),kN=xi(),K5=RN.WeakMap;V5.exports=kN(K5)&&/native code/.test(String(K5))});var Y5=Ce((Rte,W5)=>{"use strict";var kte=P(x()),ON=ew(),NN=tw(),G5=ON("keys");W5.exports=function(e){return G5[e]||(G5[e]=NN(e))}});var mw=Ce((Ote,X5)=>{"use strict";var Nte=P(x());X5.exports={}});var e4=Ce((Lte,Q5)=>{"use strict";var Ute=P(x()),LN=z5(),J5=Ys(),UN=sl(),HN=hw(),vw=Sa(),ww=K0(),qN=Y5(),MN=mw(),Z5="Object already initialized",yw=J5.TypeError,jN=J5.WeakMap,G0,td,W0,KN=function(e){return W0(e)?td(e):G0(e,{})},VN=function(e){return function(t){var r;if(!UN(t)||(r=td(t)).type!==e)throw new yw("Incompatible receiver, "+e+" required");return r}};LN||ww.state?(Ri=ww.state||(ww.state=new jN),Ri.get=Ri.get,Ri.has=Ri.has,Ri.set=Ri.set,G0=function(e,t){if(Ri.has(e))throw new yw(Z5);return t.facade=e,Ri.set(e,t),t},td=function(e){return Ri.get(e)||{}},W0=function(e){return Ri.has(e)}):(jc=qN("state"),MN[jc]=!0,G0=function(e,t){if(vw(e,jc))throw new yw(Z5);return t.facade=e,HN(e,jc,t),t},td=function(e){return vw(e,jc)?e[jc]:{}},W0=function(e){return vw(e,jc)});var Ri,jc;Q5.exports={set:G0,get:td,has:W0,enforce:KN,getterFor:VN}});var s4=Ce((Hte,n4)=>{"use strict";var qte=P(x()),bw=yo(),zN=Aa(),GN=xi(),Y0=Sa(),Ew=Iu(),WN=q5().CONFIGURABLE,YN=j5(),r4=e4(),XN=r4.enforce,ZN=r4.get,t4=String,X0=Object.defineProperty,JN=bw("".slice),QN=bw("".replace),eL=bw([].join),tL=Ew&&!zN(function(){return X0(function(){},"length",{value:8}).length!==8}),rL=String(String).split("String"),nL=n4.exports=function(e,t,r){JN(t4(t),0,7)==="Symbol("&&(t="["+QN(t4(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!Y0(e,"name")||WN&&e.name!==t)&&(Ew?X0(e,"name",{value:t,configurable:!0}):e.name=t),tL&&r&&Y0(r,"arity")&&e.length!==r.arity&&X0(e,"length",{value:r.arity});try{r&&Y0(r,"constructor")&&r.constructor?Ew&&X0(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var n=XN(e);return Y0(n,"source")||(n.source=eL(rL,typeof t=="string"?t:"")),e};Function.prototype.toString=nL(function(){return GN(this)&&ZN(this).source||YN(this)},"toString")});var o4=Ce((Mte,i4)=>{"use strict";var jte=P(x()),sL=xi(),iL=z0(),oL=s4(),aL=j0();i4.exports=function(e,t,r,n){n||(n={});var i=n.enumerable,o=n.name!==void 0?n.name:t;if(sL(r)&&oL(r,o,n),n.global)i?e[t]=r:aL(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch{}i?e[t]=r:iL.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e}});var u4=Ce((Kte,a4)=>{"use strict";var Vte=P(x()),uL=Math.ceil,cL=Math.floor;a4.exports=Math.trunc||function(t){var r=+t;return(r>0?cL:uL)(r)}});var Aw=Ce((zte,c4)=>{"use strict";var Gte=P(x()),fL=u4();c4.exports=function(e){var t=+e;return t!==t||t===0?0:fL(t)}});var l4=Ce((Wte,f4)=>{"use strict";var Yte=P(x()),lL=Aw(),hL=Math.max,dL=Math.min;f4.exports=function(e,t){var r=lL(e);return r<0?hL(r+t,0):dL(r,t)}});var d4=Ce((Xte,h4)=>{"use strict";var Zte=P(x()),pL=Aw(),gL=Math.min;h4.exports=function(e){var t=pL(e);return t>0?gL(t,9007199254740991):0}});var g4=Ce((Jte,p4)=>{"use strict";var Qte=P(x()),mL=d4();p4.exports=function(e){return mL(e.length)}});var w4=Ce((ere,v4)=>{"use strict";var tre=P(x()),vL=q0(),wL=l4(),yL=g4(),m4=function(e){return function(t,r,n){var i=vL(t),o=yL(i);if(o===0)return!e&&-1;var s=wL(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}};v4.exports={includes:m4(!0),indexOf:m4(!1)}});var b4=Ce((rre,E4)=>{"use strict";var nre=P(x()),EL=yo(),Sw=Sa(),bL=q0(),AL=w4().indexOf,SL=mw(),y4=EL([].push);E4.exports=function(e,t){var r=bL(e),n=0,i=[],o;for(o in r)!Sw(SL,o)&&Sw(r,o)&&y4(i,o);for(;t.length>n;)Sw(r,o=t[n++])&&(~AL(i,o)||y4(i,o));return i}});var S4=Ce((sre,A4)=>{"use strict";var ire=P(x());A4.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var _4=Ce(C4=>{"use strict";var are=P(x()),CL=b4(),_L=S4(),DL=_L.concat("length","prototype");C4.f=Object.getOwnPropertyNames||function(t){return CL(t,DL)}});var F4=Ce(D4=>{"use strict";var cre=P(x());D4.f=Object.getOwnPropertySymbols});var I4=Ce((fre,B4)=>{"use strict";var lre=P(x()),FL=zv(),BL=yo(),IL=_4(),$L=F4(),PL=aw(),xL=BL([].concat);B4.exports=FL("Reflect","ownKeys")||function(t){var r=IL.f(PL(t)),n=$L.f;return n?xL(r,n(t)):r}});var x4=Ce((hre,P4)=>{"use strict";var dre=P(x()),$4=Sa(),TL=I4(),RL=ow(),kL=z0();P4.exports=function(e,t,r){for(var n=TL(t),i=kL.f,o=RL.f,s=0;s{"use strict";var gre=P(x()),OL=Aa(),NL=xi(),LL=/#|\.prototype\./,rd=function(e,t){var r=HL[UL(e)];return r===ML?!0:r===qL?!1:NL(t)?OL(t):!!t},UL=rd.normalize=function(e){return String(e).replace(LL,".").toLowerCase()},HL=rd.data={},qL=rd.NATIVE="N",ML=rd.POLYFILL="P";T4.exports=rd});var O4=Ce((mre,k4)=>{"use strict";var vre=P(x()),Z0=Ys(),jL=ow().f,KL=hw(),VL=o4(),zL=j0(),GL=x4(),WL=R4();k4.exports=function(e,t){var r=e.target,n=e.global,i=e.stat,o,s,a,u,f,h;if(n?s=Z0:i?s=Z0[r]||zL(r,{}):s=Z0[r]&&Z0[r].prototype,s)for(a in t){if(f=t[a],e.dontCallGetSet?(h=jL(s,a),u=h&&h.value):u=s[a],o=WL(n?a:r+(i?".":"#")+a,e.forced),!o&&u!==void 0){if(typeof f==typeof u)continue;GL(f,u)}(e.sham||u&&u.sham)&&KL(f,"sham",!0),VL(s,a,f,e)}}});var N4=Ce(()=>{"use strict";var Ere=P(x()),YL=O4(),XL=Sa();YL({target:"Object",stat:!0},{hasOwn:XL})});var U4=Ce((bre,L4)=>{"use strict";var Are=P(x()),ZL=Ys();L4.exports=ZL});var q4=Ce((Sre,H4)=>{"use strict";var Cre=P(x());N4();var JL=U4();H4.exports=JL.Object.hasOwn});var j4=Ce((_re,M4)=>{"use strict";var Dre=P(x()),QL=q4();M4.exports=QL});var x=Ce((Fre,K4)=>{"use strict";var eU=j4();K4.exports=eU});var W4=Ce(G4=>{"use strict";var xre=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,f=a?ArrayBuffer:u,h=f.isView||function(v){return v&&"length"in v},m=i.call(f.prototype);f=r.prototype;var p=e.TextEncoder,d=new(a?Uint16Array:u)(32);t.prototype.decode=function(v){if(!h(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,C=E-32|0,D,B,H=0,V=0,S,I=0,U=-1;w>4){case 15:if(S=v[w=w+1|0]&255,S>>6!==2||247>6===2?V+4|0:24,B=B+256&768;case 13:case 12:S=v[w=w+1|0]&255,H<<=6,H|=(B&31)<<6|S&63,V=V+7|0,w>6===2&&H>>V&&1114112>H?(B=H,H=H-65536|0,0<=H&&(U=(H>>10)+55296|0,B=(H&1023)+56320|0,31>I?(d[I]=U,I=I+1|0,U=-1):(S=U,U=B,B=S))):(B>>=8,w=w-B-1|0,B=65533),H=V=0,D=w<=C?32:E-w|0;default:d[I]=B;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,U=-1,y.length=D)y[E]=D;else{if(2047>=D)y[E]=192|D>>6;else{e:{if(55296<=D)if(56319>=D){var B=v.charCodeAt(w=w+1|0)|0;if(56320<=B&&57343>=B){if(D=(D<<10)+B-56613888|0,65535>18,y[E=E+1|0]=128|D>>12&63,y[E=E+1|0]=128|D>>6&63,y[E=E+1|0]=128|D&63;continue}break e}D=65533}else 57343>=D&&(D=65533);!C&&w<<1>12,y[E=E+1|0]=128|D>>6&63}y[E=E+1|0]=128|D&63}}return a?y.subarray(0,E):y.slice(0,E)},p||(e.TextDecoder=t,e.TextEncoder=r)})(typeof global>"u"?typeof self>"u"?G4:self:global)});var Ow=Ce(cl=>{"use strict";var ane=P(x());Object.defineProperty(cl,"__esModule",{value:!0});cl.isCorrect=cl.isInSubnet=void 0;function XU(e){return this.subnetMask{"use strict";var cne=P(x());Object.defineProperty(Ao,"__esModule",{value:!0});Ao.RE_SUBNET_STRING=Ao.RE_ADDRESS=Ao.GROUPS=Ao.BITS=void 0;Ao.BITS=32;Ao.GROUPS=4;Ao.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;Ao.RE_SUBNET_STRING=/\/\d{1,2}$/});var a1=Ce(o1=>{"use strict";var lne=P(x());Object.defineProperty(o1,"__esModule",{value:!0});o1.AddressError=void 0;var Lw=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};o1.AddressError=Lw});var Uw=Ce((u1,P8)=>{var hne=P(x());(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n(M,z,J){M!=null&&(typeof M=="number"?this.fromNumber(M,z,J):z==null&&typeof M!="string"?this.fromString(M,256):this.fromString(M,z))}function i(){return new n(null)}function o(M,z,J,ae,Be,xe){for(;--xe>=0;){var qe=z*this[M++]+J[ae]+Be;Be=Math.floor(qe/67108864),J[ae++]=qe&67108863}return Be}function s(M,z,J,ae,Be,xe){for(var qe=z&32767,Ve=z>>15;--xe>=0;){var nr=this[M]&32767,Dr=this[M++]>>15,Ln=Ve*nr+Dr*qe;nr=qe*nr+((Ln&32767)<<15)+J[ae]+(Be&1073741823),Be=(nr>>>30)+(Ln>>>15)+Ve*Dr+(Be>>>30),J[ae++]=nr&1073741823}return Be}function a(M,z,J,ae,Be,xe){for(var qe=z&16383,Ve=z>>14;--xe>=0;){var nr=this[M]&16383,Dr=this[M++]>>14,Ln=Ve*nr+Dr*qe;nr=qe*nr+((Ln&16383)<<14)+J[ae]+Be,Be=(nr>>28)+(Ln>>14)+Ve*Dr,J[ae++]=nr&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;--z)M[z]=this[z];M.t=this.t,M.s=this.s}function w(M){this.t=1,this.s=M<0?-1:0,M>0?this[0]=M:M<-1?this[0]=M+this.DV:this.t=0}function E(M){var z=i();return z.fromInt(M),z}function C(M,z){var J;if(z==16)J=4;else if(z==8)J=3;else if(z==256)J=8;else if(z==2)J=1;else if(z==32)J=5;else if(z==4)J=2;else{this.fromRadix(M,z);return}this.t=0,this.s=0;for(var ae=M.length,Be=!1,xe=0;--ae>=0;){var qe=J==8?M[ae]&255:g(M,ae);if(qe<0){M.charAt(ae)=="-"&&(Be=!0);continue}Be=!1,xe==0?this[this.t++]=qe:xe+J>this.DB?(this[this.t-1]|=(qe&(1<>this.DB-xe):this[this.t-1]|=qe<=this.DB&&(xe-=this.DB)}J==8&&M[0]&128&&(this.s=-1,xe>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==M;)--this.t}function B(M){if(this.s<0)return"-"+this.negate().toString(M);var z;if(M==16)z=4;else if(M==8)z=3;else if(M==2)z=1;else if(M==32)z=5;else if(M==4)z=2;else return this.toRadix(M);var J=(1<0)for(Ve>Ve)>0&&(Be=!0,xe=v(ae));qe>=0;)Ve>(Ve+=this.DB-z)):(ae=this[qe]>>(Ve-=z)&J,Ve<=0&&(Ve+=this.DB,--qe)),ae>0&&(Be=!0),Be&&(xe+=v(ae));return Be?xe:"0"}function H(){var M=i();return n.ZERO.subTo(this,M),M}function V(){return this.s<0?this.negate():this}function S(M){var z=this.s-M.s;if(z!=0)return z;var J=this.t;if(z=J-M.t,z!=0)return this.s<0?-z:z;for(;--J>=0;)if((z=this[J]-M[J])!=0)return z;return 0}function I(M){var z=1,J;return(J=M>>>16)!=0&&(M=J,z+=16),(J=M>>8)!=0&&(M=J,z+=8),(J=M>>4)!=0&&(M=J,z+=4),(J=M>>2)!=0&&(M=J,z+=2),(J=M>>1)!=0&&(M=J,z+=1),z}function U(){return this.t<=0?0:this.DB*(this.t-1)+I(this[this.t-1]^this.s&this.DM)}function R(M,z){var J;for(J=this.t-1;J>=0;--J)z[J+M]=this[J];for(J=M-1;J>=0;--J)z[J]=0;z.t=this.t+M,z.s=this.s}function O(M,z){for(var J=M;J=0;--Ve)z[Ve+xe+1]=this[Ve]>>ae|qe,qe=(this[Ve]&Be)<=0;--Ve)z[Ve]=0;z[xe]=qe,z.t=this.t+xe+1,z.s=this.s,z.clamp()}function N(M,z){z.s=this.s;var J=Math.floor(M/this.DB);if(J>=this.t){z.t=0;return}var ae=M%this.DB,Be=this.DB-ae,xe=(1<>ae;for(var qe=J+1;qe>ae;ae>0&&(z[this.t-J-1]|=(this.s&xe)<>=this.DB;if(M.t>=this.DB;ae+=this.s}else{for(ae+=this.s;J>=this.DB;ae-=M.s}z.s=ae<0?-1:0,ae<-1?z[J++]=this.DV+ae:ae>0&&(z[J++]=ae),z.t=J,z.clamp()}function k(M,z){var J=this.abs(),ae=M.abs(),Be=J.t;for(z.t=Be+ae.t;--Be>=0;)z[Be]=0;for(Be=0;Be=0;)M[J]=0;for(J=0;J=z.DV&&(M[J+z.t]-=z.DV,M[J+z.t+1]=1)}M.t>0&&(M[M.t-1]+=z.am(J,z[J],M,2*J,0,1)),M.s=0,M.clamp()}function Z(M,z,J){var ae=M.abs();if(!(ae.t<=0)){var Be=this.abs();if(Be.t0?(ae.lShiftTo(nr,xe),Be.lShiftTo(nr,J)):(ae.copyTo(xe),Be.copyTo(J));var Dr=xe.t,Ln=xe[Dr-1];if(Ln!=0){var an=Ln*(1<1?xe[Dr-2]>>this.F2:0),js=this.FV/an,yu=(1<=0&&(J[J.t++]=1,J.subTo(ui,J)),n.ONE.dlShiftTo(Dr,ui),ui.subTo(xe,xe);xe.t=0;){var Pc=J[--ss]==Ln?this.DM:Math.floor(J[ss]*js+(J[ss-1]+ns)*yu);if((J[ss]+=xe.am(0,Pc,J,ho,0,Dr))0&&J.rShiftTo(nr,J),qe<0&&n.ZERO.subTo(J,J)}}}function G(M){var z=i();return this.abs().divRemTo(M,null,z),this.s<0&&z.compareTo(n.ZERO)>0&&M.subTo(z,z),z}function ee(M){this.m=M}function se(M){return M.s<0||M.compareTo(this.m)>=0?M.mod(this.m):M}function le(M){return M}function ve(M){M.divRemTo(this.m,null,M)}function we(M,z,J){M.multiplyTo(z,J),this.reduce(J)}function Pe(M,z){M.squareTo(z),this.reduce(z)}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 M=this[0];if(!(M&1))return 0;var z=M&3;return z=z*(2-(M&15)*z)&15,z=z*(2-(M&255)*z)&255,z=z*(2-((M&65535)*z&65535))&65535,z=z*(2-M*z%this.DV)%this.DV,z>0?this.DV-z:-z}function Oe(M){this.m=M,this.mp=M.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(z,z),z}function Se(M){var z=i();return M.copyTo(z),this.reduce(z),z}function Re(M){for(;M.t<=this.mt2;)M[M.t++]=0;for(var z=0;z>15)*this.mpl&this.um)<<15)&M.DM;for(J=z+this.m.t,M[J]+=this.m.am(0,ae,M,z,0,this.m.t);M[J]>=M.DV;)M[J]-=M.DV,M[++J]++}M.clamp(),M.drShiftTo(this.m.t,M),M.compareTo(this.m)>=0&&M.subTo(this.m,M)}function Ke(M,z){M.squareTo(z),this.reduce(z)}function Qe(M,z,J){M.multiplyTo(z,J),this.reduce(J)}Oe.prototype.convert=fe,Oe.prototype.revert=Se,Oe.prototype.reduce=Re,Oe.prototype.mulTo=Qe,Oe.prototype.sqrTo=Ke;function Me(){return(this.t>0?this[0]&1:this.s)==0}function yt(M,z){if(M>4294967295||M<1)return n.ONE;var J=i(),ae=i(),Be=z.convert(this),xe=I(M)-1;for(Be.copyTo(J);--xe>=0;)if(z.sqrTo(J,ae),(M&1<0)z.mulTo(ae,Be,J);else{var qe=J;J=ae,ae=qe}return z.revert(J)}function rt(M,z){var J;return M<256||z.isEven()?J=new ee(z):J=new Oe(z),this.exp(M,J)}n.prototype.copyTo=y,n.prototype.fromInt=w,n.prototype.fromString=C,n.prototype.clamp=D,n.prototype.dlShiftTo=R,n.prototype.drShiftTo=O,n.prototype.lShiftTo=q,n.prototype.rShiftTo=N,n.prototype.subTo=_,n.prototype.multiplyTo=k,n.prototype.squareTo=K,n.prototype.divRemTo=Z,n.prototype.invDigit=Le,n.prototype.isEven=Me,n.prototype.exp=yt,n.prototype.toString=B,n.prototype.negate=H,n.prototype.abs=V,n.prototype.compareTo=S,n.prototype.bitLength=U,n.prototype.mod=G,n.prototype.modPowInt=rt,n.ZERO=E(0),n.ONE=E(1);function vt(){var M=i();return this.copyTo(M),M}function rn(){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 Er(){return this.t==0?this.s:this[0]<<16>>16}function wt(M){return Math.floor(Math.LN2*this.DB/Math.log(M))}function Pr(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Rn(M){if(M==null&&(M=10),this.signum()==0||M<2||M>36)return"0";var z=this.chunkSize(M),J=Math.pow(M,z),ae=E(J),Be=i(),xe=i(),qe="";for(this.divRemTo(ae,Be,xe);Be.signum()>0;)qe=(J+xe.intValue()).toString(M).substr(1)+qe,Be.divRemTo(ae,Be,xe);return xe.intValue().toString(M)+qe}function Hs(M,z){this.fromInt(0),z==null&&(z=10);for(var J=this.chunkSize(z),ae=Math.pow(z,J),Be=!1,xe=0,qe=0,Ve=0;Ve=J&&(this.dMultiply(ae),this.dAddOffset(qe,0),xe=0,qe=0)}xe>0&&(this.dMultiply(Math.pow(z,xe)),this.dAddOffset(qe,0)),Be&&n.ZERO.subTo(this,this)}function It(M,z,J){if(typeof z=="number")if(M<2)this.fromInt(1);else for(this.fromNumber(M,J),this.testBit(M-1)||this.bitwiseTo(n.ONE.shiftLeft(M-1),De,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(z);)this.dAddOffset(2,0),this.bitLength()>M&&this.subTo(n.ONE.shiftLeft(M-1),this);else{var ae=new Array,Be=M&7;ae.length=(M>>3)+1,z.nextBytes(ae),Be>0?ae[0]&=(1<0)for(J>J)!=(this.s&this.DM)>>J&&(z[Be++]=ae|this.s<=0;)J<8?(ae=(this[M]&(1<>(J+=this.DB-8)):(ae=this[M]>>(J-=8)&255,J<=0&&(J+=this.DB,--M)),ae&128&&(ae|=-256),Be==0&&(this.s&128)!=(ae&128)&&++Be,(Be>0||ae!=this.s)&&(z[Be++]=ae);return z}function Ue(M){return this.compareTo(M)==0}function dr(M){return this.compareTo(M)<0?this:M}function gn(M){return this.compareTo(M)>0?this:M}function Et(M,z,J){var ae,Be,xe=Math.min(M.t,this.t);for(ae=0;ae>=16,z+=16),M&255||(M>>=8,z+=8),M&15||(M>>=4,z+=4),M&3||(M>>=2,z+=2),M&1||++z,z}function Vt(){for(var M=0;M=this.t?this.s!=0:(this[z]&1<>=this.DB;if(M.t>=this.DB;ae+=this.s}else{for(ae+=this.s;J>=this.DB;ae+=M.s}z.s=ae<0?-1:0,ae>0?z[J++]=ae:ae<-1&&(z[J++]=this.DV+ae),z.t=J,z.clamp()}function _c(M){var z=i();return this.addTo(M,z),z}function ue(M){var z=i();return this.subTo(M,z),z}function Ee(M){var z=i();return this.multiplyTo(M,z),z}function Xe(){var M=i();return this.squareTo(M),M}function Ye(M){var z=i();return this.divRemTo(M,z,null),z}function it(M){var z=i();return this.divRemTo(M,null,z),z}function bt(M){var z=i(),J=i();return this.divRemTo(M,z,J),new Array(z,J)}function At(M){this[this.t]=this.am(0,M-1,this,0,0,this.t),++this.t,this.clamp()}function xr(M,z){if(M!=0){for(;this.t<=z;)this[this.t++]=0;for(this[z]+=M;this[z]>=this.DV;)this[z]-=this.DV,++z>=this.t&&(this[this.t++]=0),++this[z]}}function rr(){}function es(M){return M}function oi(M,z,J){M.multiplyTo(z,J)}function vn(M,z){M.squareTo(z)}rr.prototype.convert=es,rr.prototype.revert=es,rr.prototype.mulTo=oi,rr.prototype.sqrTo=vn;function kn(M){return this.exp(M,new rr)}function Cr(M,z,J){var ae=Math.min(this.t+M.t,z);for(J.s=0,J.t=ae;ae>0;)J[--ae]=0;var Be;for(Be=J.t-this.t;ae=0;)J[ae]=0;for(ae=Math.max(z-this.t,0);ae2*this.m.t)return M.mod(this.m);if(M.compareTo(this.m)<0)return M;var z=i();return M.copyTo(z),this.reduce(z),z}function Dc(M){return M}function sn(M){for(M.drShiftTo(this.m.t-1,this.r2),M.t>this.m.t+1&&(M.t=this.m.t+1,M.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);M.compareTo(this.r2)<0;)M.dAddOffset(1,this.m.t+1);for(M.subTo(this.r2,M);M.compareTo(this.m)>=0;)M.subTo(this.m,M)}function Mt(M,z){M.squareTo(z),this.reduce(z)}function _r(M,z,J){M.multiplyTo(z,J),this.reduce(J)}On.prototype.convert=lo,On.prototype.revert=Dc,On.prototype.reduce=sn,On.prototype.mulTo=_r,On.prototype.sqrTo=Mt;function gt(M,z){var J=M.bitLength(),ae,Be=E(1),xe;if(J<=0)return Be;J<18?ae=1:J<48?ae=3:J<144?ae=4:J<768?ae=5:ae=6,J<8?xe=new ee(z):z.isEven()?xe=new On(z):xe=new Oe(z);var qe=new Array,Ve=3,nr=ae-1,Dr=(1<1){var Ln=i();for(xe.sqrTo(qe[1],Ln);Ve<=Dr;)qe[Ve]=i(),xe.mulTo(Ln,qe[Ve-2],qe[Ve]),Ve+=2}var an=M.t-1,js,yu=!0,ns=i(),ss;for(J=I(M[an])-1;an>=0;){for(J>=nr?js=M[an]>>J-nr&Dr:(js=(M[an]&(1<0&&(js|=M[an-1]>>this.DB+J-nr)),Ve=ae;!(js&1);)js>>=1,--Ve;if((J-=Ve)<0&&(J+=this.DB,--an),yu)qe[js].copyTo(Be),yu=!1;else{for(;Ve>1;)xe.sqrTo(Be,ns),xe.sqrTo(ns,Be),Ve-=2;Ve>0?xe.sqrTo(Be,ns):(ss=Be,Be=ns,ns=ss),xe.mulTo(ns,qe[js],Be)}for(;an>=0&&!(M[an]&1<0&&(z.rShiftTo(xe,z),J.rShiftTo(xe,J));z.signum()>0;)(Be=z.getLowestSetBit())>0&&z.rShiftTo(Be,z),(Be=J.getLowestSetBit())>0&&J.rShiftTo(Be,J),z.compareTo(J)>=0?(z.subTo(J,z),z.rShiftTo(1,z)):(J.subTo(z,J),J.rShiftTo(1,J));return xe>0&&J.lShiftTo(xe,J),J}function on(M){if(M<=0)return 0;var z=this.DV%M,J=this.s<0?M-1:0;if(this.t>0)if(z==0)J=this[0]%M;else for(var ae=this.t-1;ae>=0;--ae)J=(z*J+this[ae])%M;return J}function lr(M){var z=M.isEven();if(this.isEven()&&z||M.signum()==0)return n.ZERO;for(var J=M.clone(),ae=this.clone(),Be=E(1),xe=E(0),qe=E(0),Ve=E(1);J.signum()!=0;){for(;J.isEven();)J.rShiftTo(1,J),z?((!Be.isEven()||!xe.isEven())&&(Be.addTo(this,Be),xe.subTo(M,xe)),Be.rShiftTo(1,Be)):xe.isEven()||xe.subTo(M,xe),xe.rShiftTo(1,xe);for(;ae.isEven();)ae.rShiftTo(1,ae),z?((!qe.isEven()||!Ve.isEven())&&(qe.addTo(this,qe),Ve.subTo(M,Ve)),qe.rShiftTo(1,qe)):Ve.isEven()||Ve.subTo(M,Ve),Ve.rShiftTo(1,Ve);J.compareTo(ae)>=0?(J.subTo(ae,J),z&&Be.subTo(qe,Be),xe.subTo(Ve,xe)):(ae.subTo(J,ae),z&&qe.subTo(Be,qe),Ve.subTo(xe,Ve))}if(ae.compareTo(n.ONE)!=0)return n.ZERO;if(Ve.compareTo(M)>=0)return Ve.subtract(M);if(Ve.signum()<0)Ve.addTo(M,Ve);else return Ve;return Ve.signum()<0?Ve.add(M):Ve}var Zt=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],ts=(1<<26)/Zt[Zt.length-1];function As(M){var z,J=this.abs();if(J.t==1&&J[0]<=Zt[Zt.length-1]){for(z=0;z>1,M>Zt.length&&(M=Zt.length);for(var Be=i(),xe=0;xe>8&255,Mr[br++]^=M>>16&255,Mr[br++]^=M>>24&255,br>=ai&&(br-=ai)}function Hf(){Fc(new Date().getTime())}if(Mr==null){Mr=new Array,br=0;var Nn;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var sa=new Uint8Array(32);for(window.crypto.getRandomValues(sa),Nn=0;Nn<32;++Nn)Mr[br++]=sa[Nn]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var Bc=window.crypto.random(32);for(Nn=0;Nn>>8,Mr[br++]=Nn&255;br=0,Hf()}function Sh(){if(rs==null){for(Hf(),rs=$c(),rs.init(Mr),br=0;br{var pne=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,f=s.length,h,m="",p,d,v,g,y,w,E,C;for(p=0;p=0),v.type){case"b":h=parseInt(h,10).toString(2);break;case"c":h=String.fromCharCode(parseInt(h,10));break;case"d":case"i":h=parseInt(h,10);break;case"j":h=JSON.stringify(h,null,v.width?parseInt(v.width):0);break;case"e":h=v.precision?parseFloat(h).toExponential(v.precision):parseFloat(h).toExponential();break;case"f":h=v.precision?parseFloat(h).toFixed(v.precision):parseFloat(h);break;case"g":h=v.precision?String(Number(h.toPrecision(v.precision))):parseFloat(h);break;case"o":h=(parseInt(h,10)>>>0).toString(8);break;case"s":h=String(h),h=v.precision?h.substring(0,v.precision):h;break;case"t":h=String(!!h),h=v.precision?h.substring(0,v.precision):h;break;case"T":h=Object.prototype.toString.call(h).slice(8,-1).toLowerCase(),h=v.precision?h.substring(0,v.precision):h;break;case"u":h=parseInt(h,10)>>>0;break;case"v":h=h.valueOf(),h=v.precision?h.substring(0,v.precision):h;break;case"x":h=(parseInt(h,10)>>>0).toString(16);break;case"X":h=(parseInt(h,10)>>>0).toString(16).toUpperCase();break}e.json.test(v.type)?m+=h:(e.number.test(v.type)&&(!E||v.sign)?(C=E?"+":"-",h=h.toString().replace(e.sign,"")):C="",y=v.pad_char?v.pad_char==="0"?"0":v.pad_char.charAt(1):" ",w=v.width-(C+h).length,g=v.width&&w>0?y.repeat(w):"",m+=v.align?C+h+g:y==="0"?C+g+h:g+C+h)}return m}var i=Object.create(null);function o(s){if(i[s])return i[s];for(var a=s,u,f=[],h=0;a;){if((u=e.text.exec(a))!==null)f.push(u[0]);else if((u=e.modulo.exec(a))!==null)f.push("%");else if((u=e.placeholder.exec(a))!==null){if(u[2]){h|=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 h|=2;if(h===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");f.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]=f}typeof c1<"u"&&(c1.sprintf=t,c1.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var qw=Ce(So=>{"use strict";var mne=P(x()),JU=So&&So.__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]}),QU=So&&So.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),R8=So&&So.__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)&&JU(t,e,r);return QU(t,e),t};Object.defineProperty(So,"__esModule",{value:!0});So.Address4=void 0;var x8=R8(Ow()),ki=R8(Nw()),T8=a1(),od=Uw(),fl=sd(),Hw=class e{constructor(t){this.groups=ki.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=x8.isCorrect(ki.BITS),this.isInSubnet=x8.isInSubnet,this.address=t;let r=ki.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>ki.BITS)throw new T8.AddressError("Invalid subnet mask.");t=t.replace(ki.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(ki.RE_ADDRESS))throw new T8.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,fl.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r(0,fl.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new od.BigInteger(this.mask()+"0".repeat(ki.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new od.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new od.BigInteger(this.mask()+"1".repeat(ki.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new od.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,fl.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(ki.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(ki.RE_ADDRESS,(0,fl.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};So.Address4=Hw});var Mw=Ce(Br=>{"use strict";var wne=P(x());Object.defineProperty(Br,"__esModule",{value:!0});Br.RE_URL_WITH_PORT=Br.RE_URL=Br.RE_ZONE_STRING=Br.RE_SUBNET_STRING=Br.RE_BAD_ADDRESS=Br.RE_BAD_CHARACTERS=Br.TYPES=Br.SCOPES=Br.GROUPS=Br.BITS=void 0;Br.BITS=128;Br.GROUPS=8;Br.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};Br.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"};Br.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;Br.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;Br.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;Br.RE_ZONE_STRING=/%.*$/;Br.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);Br.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var jw=Ce(Co=>{"use strict";var Ene=P(x());Object.defineProperty(Co,"__esModule",{value:!0});Co.simpleGroup=Co.spanLeadingZeroes=Co.spanAll=Co.spanAllZeroes=void 0;var k8=sd();function O8(e){return e.replace(/(0+)/g,'$1')}Co.spanAllZeroes=O8;function eH(e,t=0){return e.split("").map((n,i)=>(0,k8.sprintf)('%s',n,i+t,O8(n))).join("")}Co.spanAll=eH;function N8(e){return e.replace(/^(0+)/,'$1')}function tH(e){return e.split(":").map(r=>N8(r)).join(":")}Co.spanLeadingZeroes=tH;function rH(e,t=0){return e.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,k8.sprintf)('%s',i+t,N8(n)))}Co.simpleGroup=rH});var L8=Ce(ln=>{"use strict";var Ane=P(x()),nH=ln&&ln.__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]}),sH=ln&&ln.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),iH=ln&&ln.__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)&&nH(t,e,r);return sH(t,e),t};Object.defineProperty(ln,"__esModule",{value:!0});ln.possibleElisions=ln.simpleRegularExpression=ln.ADDRESS_BOUNDARY=ln.padGroup=ln.groupPossibilities=void 0;var oH=iH(Mw()),ll=sd();function l1(e){return(0,ll.sprintf)("(%s)",e.join("|"))}ln.groupPossibilities=l1;function f1(e){return e.length<4?(0,ll.sprintf)("0{0,%d}%s",4-e.length,e):e}ln.padGroup=f1;ln.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function aH(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===oH.GROUPS-1?":":"";return l1([f1(i),s])}return f1(i)}).join(":"));return r.push(e.map(f1).join(":")),l1(r)}ln.simpleRegularExpression=aH;function uH(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,ll.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),o.push((0,ll.sprintf)("(0{1,4}:){1,%d}%s",e-1,i)),o.push((0,ll.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let s=1;s{"use strict";var Cne=P(x()),cH=_o&&_o.__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]}),fH=_o&&_o.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),d1=_o&&_o.__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)&&cH(t,e,r);return fH(t,e),t};Object.defineProperty(_o,"__esModule",{value:!0});_o.Address6=void 0;var U8=d1(Ow()),Kw=d1(Nw()),hr=d1(Mw()),Vw=d1(jw()),Wc=qw(),Yc=L8(),Ba=a1(),ls=Uw(),hs=sd();function h1(e){if(!e)throw new Error("Assertion failed.")}function lH(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function hH(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function dH(e,t){let r=[],n=[],i;for(i=0;it[1]&&n.push(e[i]);return r.concat(["compact"]).concat(n)}function H8(e){return(0,hs.sprintf)("%04x",parseInt(e,16))}function q8(e){return e&255}var zw=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=U8.isInSubnet,this.isCorrect=U8.isCorrect(hr.BITS),r===void 0?this.groups=hr.GROUPS:this.groups=r,this.address=t;let n=hr.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>hr.BITS)throw new Ba.AddressError("Invalid subnet mask.");t=t.replace(hr.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new Ba.AddressError("Invalid subnet mask.");let i=hr.RE_ZONE_STRING.exec(t);i&&(this.zone=i[0],t=t.replace(hr.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 Wc.Address4(t),n=hr.BITS-(Kw.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 Ba.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,hs.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=hr.BITS-this.subnetMask,n=Math.abs(t-hr.BITS),i=r-n;return i<0?"0":lH(new ls.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new ls.BigInteger(this.mask()+"0".repeat(hr.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new ls.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new ls.BigInteger(this.mask()+"1".repeat(hr.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new ls.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=hr.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(hr.TYPES))if(this.isInSubnet(new e(t)))return hr.TYPES[t];return"Global unicast"}getBits(t,r){return new ls.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,hr.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,hs.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=dH(this.parsedAddress,i[a])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace(hr.RE_BAD_CHARACTERS,'$1'));let n=t.match(hr.RE_BAD_ADDRESS);if(n)throw new Ba.AddressError((0,hs.sprintf)("Address failed regex: %s",n.join("")),t.replace(hr.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 Ba.AddressError("Error parsing groups");this.elidedGroups=u,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,i=i.concat(s);for(let f=0;f(0,hs.sprintf)("%x",parseInt(s,16))),i.length!==this.groups)throw new Ba.AddressError("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(H8).join(":")}decimal(){return this.parsedAddress.map(t=>(0,hs.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new ls.BigInteger(this.parsedAddress.map(H8).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return Wc.Address4.fromHex(new ls.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 ls.BigInteger("ffff",16)).toString(),n=Wc.Address4.fromHex(this.getBitsBase16(32,64)),i=Wc.Address4.fromHex(this.getBits(96,128).xor(new ls.BigInteger("ffffffff",16)).toString(16)),o=this.getBits(64,80),s=this.getBitsBase2(64,80),a=o.testBit(15),u=o.testBit(14),f=o.testBit(8),h=o.testBit(9),m=new ls.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,hs.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:h,groupIndividual:f,nonce:m},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=Wc.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,hs.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(q8)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(q8))}static fromUnsignedByteArray(t){let r=new ls.BigInteger("256",10),n=new ls.BigInteger("0",10),i=new ls.BigInteger("1",10);for(let o=t.length-1;o>=0;o--)n=n.add(i.multiply(new ls.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,hs.sprintf)(":%s",t),(0,hs.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,hs.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,hs.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return Vw.simpleGroup(this.address).join(":");h1(typeof this.elidedGroups=="number"),h1(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...Vw.simpleGroup(r)):t.push("");let i=["hover-group"];for(let o=this.elisionBegin;o',i.join(" "))),n.length?t.push(...Vw.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(h1(this.address4 instanceof Wc.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,Yc.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===hr.GROUPS)r.push((0,Yc.possibleElisions)(hr.GROUPS));else{let i=n.address.split("::");i[0].length&&r.push((0,Yc.simpleRegularExpression)(i[0].split(":"))),h1(typeof n.elidedGroups=="number"),r.push((0,Yc.possibleElisions)(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&r.push((0,Yc.simpleRegularExpression)(i[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",Yc.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",Yc.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};_o.Address6=zw});var j8=Ce(Vn=>{"use strict";var Dne=P(x()),pH=Vn&&Vn.__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]}),gH=Vn&&Vn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),mH=Vn&&Vn.__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)&&pH(t,e,r);return gH(t,e),t};Object.defineProperty(Vn,"__esModule",{value:!0});Vn.v6=Vn.AddressError=Vn.Address6=Vn.Address4=void 0;var vH=qw();Object.defineProperty(Vn,"Address4",{enumerable:!0,get:function(){return vH.Address4}});var wH=M8();Object.defineProperty(Vn,"Address6",{enumerable:!0,get:function(){return wH.Address6}});var yH=a1();Object.defineProperty(Vn,"AddressError",{enumerable:!0,get:function(){return yH.AddressError}});var EH=mH(jw());Vn.v6={helpers:EH}});var GC=Ce(ng=>{"use strict";var sle=P(x());ng.byteLength=Dq;ng.toByteArray=Bq;ng.fromByteArray=Pq;var xo=[],gi=[],_q=typeof Uint8Array<"u"?Uint8Array:Array,Py="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ef=0,VC=Py.length;ef0)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 Dq(e){var t=zC(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Fq(e,t,r){return(t+r)*3/4-r}function Bq(e){var t,r=zC(e),n=r[0],i=r[1],o=new _q(Fq(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=gi[e.charCodeAt(u)]<<2|gi[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=gi[e.charCodeAt(u)]<<10|gi[e.charCodeAt(u+1)]<<4|gi[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Iq(e){return xo[e>>18&63]+xo[e>>12&63]+xo[e>>6&63]+xo[e&63]}function $q(e,t,r){for(var n,i=[],o=t;oa?a:s+o));return n===1?(t=e[r-1],i.push(xo[t>>2]+xo[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(xo[t>>10]+xo[t>>4&63]+xo[t<<2&63]+"=")),i.join("")}});var WC=Ce(xy=>{var ole=P(x());xy.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<>1,h=-7,m=r?i-1:0,p=r?-1:1,d=e[t+m];for(m+=p,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=o*256+e[t+m],m+=p,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=s*256+e[t+m],m+=p,h-=8);if(o===0)o=1-f;else{if(o===u)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(d?-1:1)*s*Math.pow(2,o-n)};xy.write=function(e,t,r,n,i,o){var s,a,u,f=o*8-i-1,h=(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=h):(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>=h?(a=0,s=h):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,f-=8);e[r+d-v]|=g*128}});var og=Ce($l=>{"use strict";var cle=P(x());var Ty=GC(),Bl=WC(),YC=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;$l.Buffer=be;$l.SlowBuffer=Nq;$l.INSPECT_MAX_BYTES=50;var sg=2147483647;$l.kMaxLength=sg;be.TYPED_ARRAY_SUPPORT=xq();!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 xq(){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 Oa(e){if(e>sg)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 Ny(e)}return QC(e,t,r)}be.poolSize=8192;function QC(e,t,r){if(typeof e=="string")return Rq(e,t);if(ArrayBuffer.isView(e))return kq(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(To(e,ArrayBuffer)||e&&To(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(To(e,SharedArrayBuffer)||e&&To(e.buffer,SharedArrayBuffer)))return ky(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=Oq(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 QC(e,t,r)};Object.setPrototypeOf(be.prototype,Uint8Array.prototype);Object.setPrototypeOf(be,Uint8Array);function e_(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 Tq(e,t,r){return e_(e),e<=0?Oa(e):t!==void 0?typeof r=="string"?Oa(e).fill(t,r):Oa(e).fill(t):Oa(e)}be.alloc=function(e,t,r){return Tq(e,t,r)};function Ny(e){return e_(e),Oa(e<0?0:Ly(e)|0)}be.allocUnsafe=function(e){return Ny(e)};be.allocUnsafeSlow=function(e){return Ny(e)};function Rq(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!be.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=t_(e,t)|0,n=Oa(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Ry(e){let t=e.length<0?0:Ly(e.length)|0,r=Oa(t);for(let n=0;n=sg)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+sg.toString(16)+" bytes");return e|0}function Nq(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(To(t,Uint8Array)&&(t=be.from(t,t.offset,t.byteLength)),To(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 t_(e,t){if(be.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||To(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 Oy(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return f_(e).length;default:if(i)return n?-1:Oy(e).length;t=(""+t).toLowerCase(),i=!0}}be.byteLength=t_;function Lq(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 Wq(this,t,r);case"utf8":case"utf-8":return n_(this,t,r);case"ascii":return zq(this,t,r);case"latin1":case"binary":return Gq(this,t,r);case"base64":return Kq(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yq(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}be.prototype._isBuffer=!0;function tf(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+=" ... "),""};YC&&(be.prototype[YC]=be.prototype.inspect);be.prototype.compare=function(t,r,n,i,o){if(To(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),f=this.slice(i,o),h=t.slice(r,n);for(let m=0;m2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Hy(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:XC(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):XC(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function XC(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(h,m){return o===1?h[m]:h.readUInt16BE(m*o)}let f;if(i){let h=-1;for(f=r;fs&&(r=s-a),f=r;f>=0;f--){let h=!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 Uq(this,t,r,n);case"utf8":case"utf-8":return Hq(this,t,r,n);case"ascii":case"latin1":case"binary":return qq(this,t,r,n);case"base64":return Mq(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return jq(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 Kq(e,t,r){return t===0&&r===e.length?Ty.fromByteArray(e):Ty.fromByteArray(e.slice(t,r))}function n_(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,f,h,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],f=e[i+2],(u&192)===128&&(f&192)===128&&(m=(o&15)<<12|(u&63)<<6|f&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:u=e[i+1],f=e[i+2],h=e[i+3],(u&192)===128&&(f&192)===128&&(h&192)===128&&(m=(o&15)<<18|(u&63)<<12|(f&63)<<6|h&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 Vq(n)}var ZC=4096;function Vq(e){let t=e.length;if(t<=ZC)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||hn(t,r,this.length);let i=this[t],o=1,s=0;for(;++s>>0,r=r>>>0,n||hn(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||hn(t,1,this.length),this[t]};be.prototype.readUint16LE=be.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||hn(t,2,this.length),this[t]|this[t+1]<<8};be.prototype.readUint16BE=be.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||hn(t,2,this.length),this[t]<<8|this[t+1]};be.prototype.readUint32LE=be.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||hn(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||hn(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};be.prototype.readBigUInt64LE=qu(function(t){t=t>>>0,Il(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Pd(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,Il(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Pd(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||hn(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||hn(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||hn(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};be.prototype.readInt16LE=function(t,r){t=t>>>0,r||hn(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||hn(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||hn(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||hn(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};be.prototype.readBigInt64LE=qu(function(t){t=t>>>0,Il(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Pd(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,Il(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Pd(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<>>0,r||hn(t,4,this.length),Bl.read(this,t,!0,23,4)};be.prototype.readFloatBE=function(t,r){return t=t>>>0,r||hn(t,4,this.length),Bl.read(this,t,!1,23,4)};be.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||hn(t,8,this.length),Bl.read(this,t,!0,52,8)};be.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||hn(t,8,this.length),Bl.read(this,t,!1,52,8)};function $s(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;$s(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;$s(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||$s(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||$s(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||$s(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||$s(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||$s(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 s_(e,t,r,n,i){c_(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 i_(e,t,r,n,i){c_(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=qu(function(t,r=0){return s_(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});be.prototype.writeBigUInt64BE=qu(function(t,r=0){return i_(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);$s(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);$s(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||$s(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||$s(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||$s(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||$s(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||$s(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=qu(function(t,r=0){return s_(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});be.prototype.writeBigInt64BE=qu(function(t,r=0){return i_(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function o_(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 a_(e,t,r,n,i){return t=+t,r=r>>>0,i||o_(e,t,r,4,34028234663852886e22,-34028234663852886e22),Bl.write(e,t,r,n,23,4),r+4}be.prototype.writeFloatLE=function(t,r,n){return a_(this,t,r,!0,n)};be.prototype.writeFloatBE=function(t,r,n){return a_(this,t,r,!1,n)};function u_(e,t,r,n,i){return t=+t,r=r>>>0,i||o_(e,t,r,8,17976931348623157e292,-17976931348623157e292),Bl.write(e,t,r,n,52,8),r+8}be.prototype.writeDoubleLE=function(t,r,n){return u_(this,t,r,!0,n)};be.prototype.writeDoubleBE=function(t,r,n){return u_(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=JC(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=JC(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function JC(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 Xq(e,t,r){Il(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Pd(t,e.length-(r+1))}function c_(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 Fl.ERR_OUT_OF_RANGE("value",a,e)}Xq(n,i,o)}function Il(e,t){if(typeof e!="number")throw new Fl.ERR_INVALID_ARG_TYPE(t,"number",e)}function Pd(e,t,r){throw Math.floor(e)!==e?(Il(e,r),new Fl.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new Fl.ERR_BUFFER_OUT_OF_BOUNDS:new Fl.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var Zq=/[^+/0-9A-Za-z-_]/g;function Jq(e){if(e=e.split("=")[0],e=e.trim().replace(Zq,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Oy(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 Qq(e){let t=[];for(let r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function f_(e){return Ty.toByteArray(Jq(e))}function ig(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function To(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Hy(e){return e!==e}var tM=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 qu(e){return typeof BigInt>"u"?rM:e}function rM(){throw new Error("BigInt not supported")}});var O_=Ce(Ne=>{var hle=P(x()),Td={};Td.userAgent=!1;var Pl={},nM="11.1.3",sM="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]|=C<<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)}},f=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)))}},h=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(d){typeof d=="string"&&(d=f.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,C=y/E;d?C=e.ceil(C):C=e.max((C|0)-this._minBufferSize,0);var D=C*w,B=e.min(D*4,y);if(D){for(var H=0;H>>2]&255}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:m,padding:f}),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 h=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 h.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 C=g.createEncryptor(w,E);return y=C.finalize(y),C=C.cfg,h.create({ciphertext:y,key:w,iv:C.iv,algorithm:g,mode:C.mode,padding:C.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,h.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=[],f=[],h=[],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],C=p[E],D=257*p[y]^16843008*y;i[v]=D<<24|D>>>8,o[v]=D<<16|D>>>16,s[v]=D<<8|D>>>24,a[v]=D,D=16843009*C^65537*E^257*w^16843008*v,u[y]=D<<24|D>>>8,f[y]=D<<16|D>>>16,h[y]=D<<8|D>>>24,m[y]=D,v?(v=w^p[p[p[C^w]]],g^=p[p[g]]):v=g=1}var B=[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,S=I.sigBytes/4,I=4*((this._nRounds=S+6)+1),U=this._keySchedule=[],R=0;R>>24]<<24|r[O>>>16&255]<<16|r[O>>>8&255]<<8|r[O&255]):(O=O<<8|O>>>24,O=r[O>>>24]<<24|r[O>>>16&255]<<16|r[O>>>8&255]<<8|r[O&255],O^=B[R/S|0]<<24),U[R]=U[R-S]^O}for(V=this._invKeySchedule=[],S=0;SS||4>=R?O:u[r[O>>>24]]^f[r[O>>>16&255]]^h[r[O>>>8&255]]^m[r[O&255]]},encryptBlock:function(V,S){this._doCryptBlock(V,S,this._keySchedule,i,o,s,a,r)},decryptBlock:function(V,S){var I=V[S+1];V[S+1]=V[S+3],V[S+3]=I,this._doCryptBlock(V,S,this._invKeySchedule,u,f,h,m,n),I=V[S+1],V[S+1]=V[S+3],V[S+3]=I},_doCryptBlock:function(V,S,I,U,R,O,q,N){for(var _=this._nRounds,le=V[S]^I[0],ve=V[S+1]^I[1],we=V[S+2]^I[2],se=V[S+3]^I[3],k=4,K=1;K<_;K++)var Z=U[le>>>24]^R[ve>>>16&255]^O[we>>>8&255]^q[se&255]^I[k++],G=U[ve>>>24]^R[we>>>16&255]^O[se>>>8&255]^q[le&255]^I[k++],ee=U[we>>>24]^R[se>>>16&255]^O[le>>>8&255]^q[ve&255]^I[k++],se=U[se>>>24]^R[le>>>16&255]^O[ve>>>8&255]^q[we&255]^I[k++],le=Z,ve=G,we=ee;Z=(N[le>>>24]<<24|N[ve>>>16&255]<<16|N[we>>>8&255]<<8|N[se&255])^I[k++],G=(N[ve>>>24]<<24|N[we>>>16&255]<<16|N[se>>>8&255]<<8|N[le&255])^I[k++],ee=(N[we>>>24]<<24|N[se>>>16&255]<<16|N[le>>>8&255]<<8|N[ve&255])^I[k++],se=(N[se>>>24]<<24|N[le>>>16&255]<<16|N[ve>>>8&255]<<8|N[we&255])^I[k++],V[S]=Z,V[S+1]=G,V[S+2]=ee,V[S+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,C=0,D=0;8>D;D++)C|=f[D][((E^y[D])&h[D])>>>0];this._lBlock=E,this._rBlock=w^C}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|f)<<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,f=[],h=0;64>h;h++)f[h]=4294967296*e.abs(e.sin(h+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],C=m[p+5],D=m[p+6],B=m[p+7],H=m[p+8],V=m[p+9],S=m[p+10],I=m[p+11],U=m[p+12],R=m[p+13],O=m[p+14],q=m[p+15],N=d[0],K=d[1],k=d[2],_=d[3],N=t(N,K,k,_,v,7,f[0]),_=t(_,N,K,k,g,12,f[1]),k=t(k,_,N,K,y,17,f[2]),K=t(K,k,_,N,w,22,f[3]),N=t(N,K,k,_,E,7,f[4]),_=t(_,N,K,k,C,12,f[5]),k=t(k,_,N,K,D,17,f[6]),K=t(K,k,_,N,B,22,f[7]),N=t(N,K,k,_,H,7,f[8]),_=t(_,N,K,k,V,12,f[9]),k=t(k,_,N,K,S,17,f[10]),K=t(K,k,_,N,I,22,f[11]),N=t(N,K,k,_,U,7,f[12]),_=t(_,N,K,k,R,12,f[13]),k=t(k,_,N,K,O,17,f[14]),K=t(K,k,_,N,q,22,f[15]),N=r(N,K,k,_,g,5,f[16]),_=r(_,N,K,k,D,9,f[17]),k=r(k,_,N,K,I,14,f[18]),K=r(K,k,_,N,v,20,f[19]),N=r(N,K,k,_,C,5,f[20]),_=r(_,N,K,k,S,9,f[21]),k=r(k,_,N,K,q,14,f[22]),K=r(K,k,_,N,E,20,f[23]),N=r(N,K,k,_,V,5,f[24]),_=r(_,N,K,k,O,9,f[25]),k=r(k,_,N,K,w,14,f[26]),K=r(K,k,_,N,H,20,f[27]),N=r(N,K,k,_,R,5,f[28]),_=r(_,N,K,k,y,9,f[29]),k=r(k,_,N,K,B,14,f[30]),K=r(K,k,_,N,U,20,f[31]),N=n(N,K,k,_,C,4,f[32]),_=n(_,N,K,k,H,11,f[33]),k=n(k,_,N,K,I,16,f[34]),K=n(K,k,_,N,O,23,f[35]),N=n(N,K,k,_,g,4,f[36]),_=n(_,N,K,k,E,11,f[37]),k=n(k,_,N,K,B,16,f[38]),K=n(K,k,_,N,S,23,f[39]),N=n(N,K,k,_,R,4,f[40]),_=n(_,N,K,k,v,11,f[41]),k=n(k,_,N,K,w,16,f[42]),K=n(K,k,_,N,D,23,f[43]),N=n(N,K,k,_,V,4,f[44]),_=n(_,N,K,k,U,11,f[45]),k=n(k,_,N,K,q,16,f[46]),K=n(K,k,_,N,y,23,f[47]),N=i(N,K,k,_,v,6,f[48]),_=i(_,N,K,k,B,10,f[49]),k=i(k,_,N,K,O,15,f[50]),K=i(K,k,_,N,C,21,f[51]),N=i(N,K,k,_,U,6,f[52]),_=i(_,N,K,k,w,10,f[53]),k=i(k,_,N,K,S,15,f[54]),K=i(K,k,_,N,g,21,f[55]),N=i(N,K,k,_,H,6,f[56]),_=i(_,N,K,k,q,10,f[57]),k=i(k,_,N,K,D,15,f[58]),K=i(K,k,_,N,R,21,f[59]),N=i(N,K,k,_,E,6,f[60]),_=i(_,N,K,k,I,10,f[61]),k=i(k,_,N,K,y,15,f[62]),K=i(K,k,_,N,V,21,f[63]);d[0]=d[0]+N|0,d[1]=d[1]+K|0,d[2]=d[2]+k|0,d[3]=d[3]+_|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],f=a[1],h=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+((f&h|~f&m)+1518500249):40>d?v+((f^h^m)+1859775393):60>d?v+((f&h|f&m|h&m)-1894007588):v+((f^h^m)-899497514),p=m,m=h,h=f<<30|f>>>2,f=u,u=v}a[0]=a[0]+u|0,a[1]=a[1]+f|0,a[2]=a[2]+h|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 f;e:{f=a;for(var h=e.sqrt(f),m=2;m<=h;m++)if(!(f%m)){f=!1;break e}f=!0}f&&(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],C=y[2],D=y[3],B=y[4],H=y[5],V=y[6],S=y[7],I=0;64>I;I++){if(16>I)p[I]=v[g+I]|0;else{var U=p[I-15],R=p[I-2];p[I]=((U<<25|U>>>7)^(U<<14|U>>>18)^U>>>3)+p[I-7]+((R<<15|R>>>17)^(R<<13|R>>>19)^R>>>10)+p[I-16]}U=S+((B<<26|B>>>6)^(B<<21|B>>>11)^(B<<7|B>>>25))+(B&H^~B&V)+o[I]+p[I],R=((w<<30|w>>>2)^(w<<19|w>>>13)^(w<<10|w>>>22))+(w&E^w&C^E&C),S=V,V=H,H=B,B=D+U|0,D=C,C=E,E=w,w=U+R|0}y[0]=y[0]+w|0,y[1]=y[1]+E|0,y[2]=y[2]+C|0,y[3]=y[3]+D|0,y[4]=y[4]+B|0,y[5]=y[5]+H|0,y[6]=y[6]+V|0,y[7]=y[7]+S|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(f,h){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],C=m.high,D=m.low,B=p.high,H=p.low,V=d.high,S=d.low,I=v.high,U=v.low,R=g.high,O=g.low,q=y.high,N=y.low,_=w.high,k=w.low,K=E.high,Z=E.low,G=C,ee=D,se=B,le=H,ve=V,we=S,Pe=I,Le=U,Oe=R,fe=O,Se=q,Re=N,Ke=_,Qe=k,Me=K,yt=Z,rt=0;80>rt;rt++){var dr=a[rt];if(16>rt)var vt=dr.high=f[h+2*rt]|0,Ue=dr.low=f[h+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),Pr=a[rt-2],Ue=Pr.high,It=Pr.low,Pr=(Ue>>>19|It<<13)^(Ue<<3|It>>>29)^Ue>>>6,It=(It>>>19|Ue<<13)^(It<<3|Ue>>>29)^(It>>>6|Ue<<26),Ue=a[rt-7],rn=Ue.high,yr=a[rt-16],tt=yr.high,yr=yr.low,Ue=wt+Ue.low,vt=vt+rn+(Ue>>>0>>0?1:0),Ue=Ue+It,vt=vt+Pr+(Ue>>>0>>0?1:0),Ue=Ue+yr,vt=vt+tt+(Ue>>>0>>0?1:0);dr.high=vt,dr.low=Ue}var rn=Oe&Se^~Oe&Ke,yr=fe&Re^~fe&Qe,dr=G&se^G&ve^se&ve,Er=ee&le^ee&we^le&we,wt=(G>>>28|ee<<4)^(G<<30|ee>>>2)^(G<<25|ee>>>7),Pr=(ee>>>28|G<<4)^(ee<<30|G>>>2)^(ee<<25|G>>>7),It=s[rt],Rn=It.high,Hs=It.low,It=yt+((fe>>>14|Oe<<18)^(fe>>>18|Oe<<14)^(fe<<23|Oe>>>9)),tt=Me+((Oe>>>14|fe<<18)^(Oe>>>18|fe<<14)^(Oe<<23|fe>>>9))+(It>>>0>>0?1:0),It=It+yr,tt=tt+rn+(It>>>0>>0?1:0),It=It+Hs,tt=tt+Rn+(It>>>0>>0?1:0),It=It+Ue,tt=tt+vt+(It>>>0>>0?1:0),Ue=Pr+Er,dr=wt+dr+(Ue>>>0>>0?1:0),Me=Ke,yt=Qe,Ke=Se,Qe=Re,Se=Oe,Re=fe,fe=Le+It|0,Oe=Pe+tt+(fe>>>0>>0?1:0)|0,Pe=ve,Le=we,ve=se,we=le,se=G,le=ee,ee=It+Ue|0,G=tt+dr+(ee>>>0>>0?1:0)|0}D=m.low=D+ee,m.high=C+G+(D>>>0>>0?1:0),H=p.low=H+le,p.high=B+se+(H>>>0>>0?1:0),S=d.low=S+we,d.high=V+ve+(S>>>0>>0?1:0),U=v.low=U+Le,v.high=I+Pe+(U>>>0>>0?1:0),O=g.low=O+fe,g.high=R+Oe+(O>>>0>>0?1:0),N=y.low=N+Re,y.high=q+Se+(N>>>0>>0?1:0),k=w.low=k+Qe,w.high=_+Ke+(k>>>0>>0?1:0),Z=E.low=Z+yt,E.high=K+Me+(Z>>>0>>0?1:0)},_doFinalize:function(){var f=this._data,h=f.words,m=8*this._nDataBytes,p=8*f.sigBytes;return h[p>>>5]|=128<<24-p%32,h[(p+128>>>10<<5)+30]=Math.floor(m/4294967296),h[(p+128>>>10<<5)+31]=m,f.sigBytes=4*h.length,this._process(),this._hash.toX32()},clone:function(){var f=r.clone.call(this);return f._hash=this._hash.clone(),f},blockSize:32}),t.SHA512=r._createHelper(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,f=e.lib,t=f.WordArray,r=f.Hasher,f=e.algo,n=t.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),i=t.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),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]),f=f.RIPEMD160=r.extend({_doReset:function(){this._hash=t.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(h,m){for(var p=0;16>p;p++){var d=m+p,v=h[d];h[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,C=s.words,D,B,H,V,S,I,U,R,O,q;I=D=d[0],U=B=d[1],R=H=d[2],O=V=d[3],q=S=d[4];for(var N,p=0;80>p;p+=1)N=D+h[m+y[p]]|0,N=16>p?N+((B^H^V)+v[0]):32>p?N+((B&H|~B&V)+v[1]):48>p?N+(((B|~H)^V)+v[2]):64>p?N+((B&V|H&~V)+v[3]):N+((B^(H|~V))+v[4]),N|=0,N=N<>>32-E[p],N=N+S|0,D=S,S=V,V=H<<10|H>>>22,H=B,B=N,N=I+h[m+w[p]]|0,N=16>p?N+((U^(R|~O))+g[0]):32>p?N+((U&O|R&~O)+g[1]):48>p?N+(((U|~R)^O)+g[2]):64>p?N+((U&R|~U&O)+g[3]):N+((U^R^O)+g[4]),N|=0,N=N<>>32-C[p],N=N+q|0,I=q,q=O,O=R<<10|R>>>22,R=U,U=N;N=d[1]+H+O|0,d[1]=d[2]+V+q|0,d[2]=d[3]+S+I|0,d[3]=d[4]+D+U|0,d[4]=d[0]+B+R|0,d[0]=N},_doFinalize:function(){var h=this._data,m=h.words,p=8*this._nDataBytes,d=8*h.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,h.sigBytes=4*(m.length+1),this._process(),h=this._hash,m=h.words,p=0;5>p;p++)d=m[p],m[p]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360;return h},clone:function(){var h=r.clone.call(this);return h._hash=this._hash.clone(),h}});e.RIPEMD160=r._createHelper(f),e.HmacRIPEMD160=r._createHmacHelper(f)})(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,f=a.words,h=0;h>6)+xl.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=xl.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=xl.charAt(r>>2)+xl.charAt((r&3)<<4)),jy)for(;(n.length&3)>0;)n+=jy;return n}function Rl(e){var t="",r,n=0,i,o;for(r=0;r>2),i=o&3,n=1):n==1?(t+=Na(i<<2|o>>4),i=o&15,n=2):n==2?(t+=Na(i),t+=Na(o>>2),i=o&3,n=3):(t+=Na(i<<2|o>>4),t+=Na(o&15),n=0));return n==1&&(t+=Na(i<<2)),t}function p_(e){var t=Rl(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,f=this[e++]>>15,h=a*u+f*s;u=s*u+((h&32767)<<15)+r[n]+(i&1073741823),i=(u>>>30)+(h>>>15)+a*f+(i>>>30),r[n++]=u&1073741823}return i}function uM(e,t,r,n,i,o){for(var s=t&16383,a=t>>14;--o>=0;){var u=this[e]&16383,f=this[e++]>>14,h=a*u+f*s;u=s*u+((h&16383)<<14)+r[n]+i,i=(u>>28)+(h>>14)+a*f,r[n++]=u&268435455}return i}l_&&Td.appName=="Microsoft Internet Explorer"?(oe.prototype.am=aM,ju=30):l_&&Td.appName!="Netscape"?(oe.prototype.am=oM,ju=26):(oe.prototype.am=uM,ju=28);oe.prototype.DB=ju;oe.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function lM(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 Mu(e){var t=Ht();return t.fromInt(e),t}function hM(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:g_(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 pM(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=Na(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+=Na(n));return i?o:"0"}function gM(){var e=Ht();return oe.ZERO.subTo(this,e),e}function mM(){return this.s<0?this.negate():this}function vM(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 dg(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 wM(){return this.t<=0?0:this.DB*(this.t-1)+dg(this[this.t-1]^this.s&this.DM)}function yM(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 EM(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 AM(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 CM(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 DM(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 f=o.t,h=o[f-1];if(h!=0){var m=h*(1<1?o[f-2]>>this.F2:0),p=this.FV/m,d=(1<=0&&(r[r.t++]=1,r.subTo(w,r)),oe.ONE.dlShiftTo(f,w),w.subTo(o,o);o.t=0;){var E=r[--g]==h?this.DM:Math.floor(r[g]*p+(r[g-1]+v)*d);if((r[g]+=o.am(0,E,r,y,0,f))0&&r.rShiftTo(u,r),s<0&&oe.ZERO.subTo(r,r)}}function FM(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 rf(e){this.m=e}function BM(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function IM(e){return e}function $M(e){e.divRemTo(this.m,null,e)}function PM(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function xM(e,t){e.squareTo(t),this.reduce(t)}rf.prototype.convert=BM;rf.prototype.revert=IM;rf.prototype.reduce=$M;rf.prototype.mulTo=PM;rf.prototype.sqrTo=xM;function TM(){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 nf(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 kM(e){var t=Ht();return e.copyTo(t),this.reduce(t),t}function OM(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 NM(e,t){e.squareTo(t),this.reduce(t)}function LM(e,t,r){e.multiplyTo(t,r),this.reduce(r)}nf.prototype.convert=RM;nf.prototype.revert=kM;nf.prototype.reduce=OM;nf.prototype.mulTo=LM;nf.prototype.sqrTo=NM;function UM(){return(this.t>0?this[0]&1:this.s)==0}function HM(e,t){if(e>4294967295||e<1)return oe.ONE;var r=Ht(),n=Ht(),i=t.convert(this),o=dg(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 qM(e,t){var r;return e<256||t.isEven()?r=new rf(t):r=new nf(t),this.exp(e,r)}oe.prototype.copyTo=fM;oe.prototype.fromInt=lM;oe.prototype.fromString=hM;oe.prototype.clamp=dM;oe.prototype.dlShiftTo=yM;oe.prototype.drShiftTo=EM;oe.prototype.lShiftTo=bM;oe.prototype.rShiftTo=AM;oe.prototype.subTo=SM;oe.prototype.multiplyTo=CM;oe.prototype.squareTo=_M;oe.prototype.divRemTo=DM;oe.prototype.invDigit=TM;oe.prototype.isEven=UM;oe.prototype.exp=HM;oe.prototype.toString=pM;oe.prototype.negate=gM;oe.prototype.abs=mM;oe.prototype.compareTo=vM;oe.prototype.bitLength=wM;oe.prototype.mod=FM;oe.prototype.modPowInt=qM;oe.ZERO=Mu(0);oe.ONE=Mu(1);function MM(){var e=Ht();return this.copyTo(e),e}function jM(){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 VM(){return this.t==0?this.s:this[0]<<16>>16}function zM(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function GM(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function WM(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=Mu(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 YM(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 XM(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),Wy,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 JM(e){return this.compareTo(e)==0}function QM(e){return this.compareTo(e)<0?this:e}function ej(e){return this.compareTo(e)>0?this:e}function tj(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 lj(){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 Ej(e){var t=Ht();return this.addTo(e,t),t}function bj(e){var t=Ht();return this.subTo(e,t),t}function Aj(e){var t=Ht();return this.multiplyTo(e,t),t}function Sj(){var e=Ht();return this.squareTo(e),e}function Cj(e){var t=Ht();return this.divRemTo(e,t,null),t}function _j(e){var t=Ht();return this.divRemTo(e,null,t),t}function Dj(e){var t=Ht(),r=Ht();return this.divRemTo(e,t,r),new Array(t,r)}function Fj(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function Bj(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 kd(){}function w_(e){return e}function Ij(e,t,r){e.multiplyTo(t,r)}function $j(e,t){e.squareTo(t)}kd.prototype.convert=w_;kd.prototype.revert=w_;kd.prototype.mulTo=Ij;kd.prototype.sqrTo=$j;function Pj(e){return this.exp(e,new kd)}function xj(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 kj(e){return e}function Oj(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 Nj(e,t){e.squareTo(t),this.reduce(t)}function Lj(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Ol.prototype.convert=Rj;Ol.prototype.revert=kj;Ol.prototype.reduce=Oj;Ol.prototype.mulTo=Lj;Ol.prototype.sqrTo=Nj;function Uj(e,t){if(e.signum()<0)return this.modInverse(t).modPow(e.negate(),t);var r=e.bitLength(),n,i=Mu(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 rf(t):t.isEven()?o=new Ol(t):o=new nf(t);var s=new Array,a=3,u=n-1,f=(1<1){var h=Ht();for(o.sqrTo(s[1],h);a<=f;)s[a]=Ht(),o.mulTo(h,s[a-2],s[a]),a+=2}var m=e.t-1,p,d=!0,v=Ht(),g;for(r=dg(e[m])-1;m>=0;){for(r>=u?p=e[m]>>r-u&f:(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 qj(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 Mj(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=Mu(1),s=Mu(0),a=Mu(0),u=Mu(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 ps=[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],jj=(1<<26)/ps[ps.length-1];function Kj(e){if(this.signum()<=0)return!1;var t,r=this.abs();if(r.t==1&&r[0]<=ps[ps.length-1]){for(t=0;t>1,e>ps.length&&(e=ps.length);for(var i=Ht(),o=0;o>8&255,Ps[Ur++]^=e>>16&255,Ps[Ur++]^=e>>24&255,Ur>=xd&&(Ur-=xd)}function Xy(){Yj(new Date().getTime())}if(Ps==null){if(Ps=new Array,Ur=0,typeof Pl<"u"&&(Pl.crypto!==void 0||Pl.msCrypto!==void 0)){if(La=Pl.crypto||Pl.msCrypto,La.getRandomValues)for(qy=new Uint8Array(32),La.getRandomValues(qy),Wn=0;Wn<32;++Wn)Ps[Ur++]=qy[Wn];else if(Td.appName=="Netscape"&&Td.appVersion<"5")for(My=Pl.crypto.random(32),Wn=0;Wn>>8,Ps[Ur++]=Wn&255;Ur=0,Xy()}var Wn,La,qy,My,ug;function Xj(){if(ag==null){for(Xy(),ag=Wj(),ag.init(Ps),Ur=0;Ur0&&t.length>0)this.n=xs(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 Qj(e){return e.modPowInt(this.e,this.n)}mt.prototype.doPublic=Qj;mt.prototype.setPublic=Jj;mt.prototype.type="RSA";function eK(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=xs(e,16),this.e=parseInt(t,16),this.d=xs(r,16);else throw"Invalid RSA private key"}function tK(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=xs(e,16),this.e=parseInt(t,16),this.d=xs(r,16),this.p=xs(n,16),this.q=xs(i,16),this.dmp1=xs(o,16),this.dmq1=xs(s,16),this.coeff=xs(a,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function rK(e,t){var r=new Nl,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;--f){i=i.twice();var h=r.testBit(f),m=t.testBit(f);h!=m&&(i=i.add(h?this:n))}for(f=s.bitLength()-2;f>0;--f){a=a.twice();var p=s.testBit(f),d=o.testBit(f);p!=d&&(a=a.add(p?a:u))}return i}function EK(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}Gt.prototype.getX=hK;Gt.prototype.getY=dK;Gt.prototype.equals=pK;Gt.prototype.isInfinity=gK;Gt.prototype.negate=mK;Gt.prototype.add=vK;Gt.prototype.twice=wK;Gt.prototype.multiply=yK;Gt.prototype.multiplyTwo=EK;function Ha(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new Gt(this,null,null)}function bK(){return this.q}function AK(){return this.a}function SK(){return this.b}function CK(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function _K(){return this.infinity}function DK(e){return new Qr(this.q,e)}function FK(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(f,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 Gt(this,n,a);case 4:case 6:case 7:var u=(e.length-2)/2,f=e.substr(2,u),h=e.substr(u+2,u);return new Gt(this,this.fromBigInteger(new oe(f,16)),this.fromBigInteger(new oe(h,16)));default:return null}}Ha.prototype.getQ=bK;Ha.prototype.getA=AK;Ha.prototype.getB=SK;Ha.prototype.equals=CK;Ha.prototype.getInfinity=_K;Ha.prototype.fromBigInteger=DK;Ha.prototype.decodePointHex=FK;Qr.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};Gt.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};Gt.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 Gt(e,e.fromBigInteger(s),e.fromBigInteger(a))};Gt.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 Gt(e,e.fromBigInteger(s),e.fromBigInteger(a))};Gt.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 Gt(this.curve,i,o)};Gt.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 Gt(this.curve,n,i)};Gt.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};Gt.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)};Gt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};Gt.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 y_=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="\\",f={"{":Object,"[":Array},h=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],C=1-y,D=d.length;C=0;)delete I[U[q]]}return p.call(V,S,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 Nd(e)},this.getPEMStringFromHex=function(e,t){return Yn(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,f=r.DERObjectIdentifier,h=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,C=r.DERBMPString,D=r.DERSequence,B=r.DERSet,H=r.DERTaggedObject,V=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var S=Object.keys(e);if(S.length!=1)throw new Error("key of param shall be only one.");var I=S[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 f(e[I]);if(I=="enum")return new h(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 C(e[I]);if(I=="asn1")return new n(e[I]);if(I=="seq"){for(var U=e[I],R=[],O=0;O"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 f=128+u;return f.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=gg(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 f=s(String(a.getMonth()+1),2),h=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+f+h+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 f=new Date(Date.UTC(n,i-1,o,s,a,u,0));this.setByDate(f)},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=Nd;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)}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 Eg(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 Rs(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&&(h=h+"."+u.join(".")),h};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 f=function(V,S){if(V.length<=S*2)return V;var I=V.substr(0,S)+"..(total "+V.length/2+"bytes).."+V.substr(V.length-S,S);return I};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var h=t.ommit_long_octet,B=u.substr(r,2);if(B=="01"){var m=o(u,r);return m=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(B=="02"){var m=o(u,r);return n+"INTEGER "+f(m,h)+` `}if(B=="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 "+f(m,h)+` `}if(B=="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 "+f(m,h)+` `}if(B=="05")return n+`NULL `;if(B=="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(B=="0a")return n+"ENUMERATED "+parseInt(o(u,r))+` `;if(B=="0c")return n+"UTF8String '"+er(o(u,r))+`' `;if(B=="13")return n+"PrintableString '"+er(o(u,r))+`' `;if(B=="14")return n+"TeletexString '"+er(o(u,r))+`' `;if(B=="16")return n+"IA5String '"+er(o(u,r))+`' `;if(B=="17")return n+"UTCTime "+er(o(u,r))+` `;if(B=="18")return n+"GeneralizedTime "+er(o(u,r))+` `;if(B=="1a")return n+"VisualString '"+er(o(u,r))+`' `;if(B=="1e")return n+"BMPString '"+eE(o(u,r))+`' `;if(B=="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])),C=JSON.parse(JSON.stringify(t));C.x509ExtName=g,E=C}for(var D=0;D4?{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=h(w);return y[d[g]]={str:H},y}else if(g.match(/^8[0-9]$/)){var H=h(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 S=V.getLengthHexFromValue();return{asn1:{tlv:g+S+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),f=u.length-2-o.getL(e,t).length;if(f!==a*2)throw new Error("V string length and L's value not the same:"+f+"/"+a*2);if(t===0&&e.length!=u.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+u.length);var h=e.substr(t,2);if(h==="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(h,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,f=u.sigalg;u.sigalg.name!=null&&(f=u.sigalg.name);var h=u.tbsobj.tohex(),m=new A.crypto.Signature({alg:f});m.init(u.cakey),m.updateHex(h),u.sighex=m.sign()},this.getPEM=function(){return Yn(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 f=[];f.push(u.tbsobj),f.push(new a({name:u.sigalg})),f.push(new n({hex:"00"+u.sighex}));var h=new i({array:f});return h.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,f=n.X500Name,h=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 f(d.issuer)),p.push(new s({array:[new u(d.notbefore),new u(d.notafter)]})),p.push(new f(d.subject)),p.push(new m(xt.getKey(d.sbjpubkey))),d.ext!==void 0&&d.ext.length>0&&p.push(new i({tag:"a3",obj:new h(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,f=[],i=0;n.length>0;i++){var o=n.shift();if(u===!0){var h=f.pop();if(o.match(/"$/)){var a=(h+"+"+o).replace(/^([^=]+)="(.*)"$/,"$1=$2");f.push(a),u=!1}else f.push(h+"+"+o)}else f.push(o);o.match(/^[^=]+="/)&&(u=!0)}return f};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,f=r.DERBMPString,h=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"&&h(d)?"ia5":m(d)?"prn":"utf8":v==="utf8"?p=="CN"&&h(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 f({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,f=i.ASN1Util.newObject,h=i.x509,m=h.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 mt){var y=f({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 f({seq:[{int:{bigint:g.p}},{int:{bigint:g.q}},{int:{bigint:g.g}}]});this.asn1AlgId=new m({name:"dsa",asn1params:E});var C=new o({bigint:g.y});this.asn1SubjPKey=new s({hex:"00"+C.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,f=n.DEROctetString,h=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,C=null;if(d.certsubj!==void 0?(w=!1,E=d.certsubj):(w=!0,E=d.certissuer),E.match(/^[0-9A-Fa-f]+$/)&&C==E,E.indexOf("-----BEGIN ")!=-1&&(C=Sr(E)),C==null)throw new Error("certsubj/certissuer not cert");var D=new at;D.hex=C;var B;w?B=D.getIssuerHex():B=D.getSubjectHex(),g=new m,g.hTLV=B}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 S=V.length;if(S==8||S==16||S==32||S==64)H=V;else throw"err"}else H=Qy(V)}catch(U){throw new p("malformed IP address: "+d.ip+":"+U.message)}g=new f({hex:H})}else throw new p("improper params");var I=new h({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()}),f=new i({array:[a,u]});return f.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,f=[],h=0;h0){for(var v=o(p.valhex,d[0]),g=m(v,0),y=[],w=0;w1){var D=o(p.valhex,d[1]);p.polhex=D}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 C=i(p.valhex,y[1]);p.hash=C}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 D=o(p.valhex,d[1]);p.polhex=D}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]),C=this.getIssuerSerial(E);d.issuer=C.issuer,d.serial=C.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,f=n.DERTaggedObject,h=n.tsp,m=h.MessageImprint,p=h.Accuracy,d=n.x509.X500Name,v=n.x509.GeneralName;if(h.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 f({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}),f=new i({hex:a.hash}),h=new n({array:[u,f]});return h.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,f=u.MessageImprint;u.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var h=this.params,m=[];m.push(new i({int:1})),h.messageImprint instanceof A.asn1.ASN1Object?m.push(h.messageImprint):m.push(new f(h.messageImprint)),h.policy!=null&&m.push(new a(h.policy)),h.nonce!=null&&m.push(new i(h.nonce)),h.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 f=new n({array:u});return f.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 f=this.params,h=[];if(typeof f=="string")h.push(new s(f));else{if(f.status==null)throw new t("property 'status' unspecified");h.push(new s(f.status)),f.statusstr!=null&&h.push(new a(f.statusstr)),f.failinfo!=null&&h.push(new u(f.failinfo))}var m=new i({array:h});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,f;if(typeof a=="string")try{f=s[a]}catch{throw new t("undefined name: "+a)}else if(typeof a=="number")f=a;else throw new t("unsupported params");return new i({int:f}).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=[],f=0;f=0;p--)m+=h[p];return m}else{if(typeof u=="string"&&a[u]!=null)return lg([u],a);if(typeof u=="object"&&u.length!=null)return lg(u,a);throw new t("wrong params")}},this.tohex=function(){var u=this.params,f=this.getBinValue();return new i({bin:f}).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 f=new n.TimeStampToken(this.params);return f.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,f=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],h={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=Eg(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:er(w)};var E=0;if(d.length>5&&m.substr(d[5],2)=="30"){var C=o(m,d[5]);p.accuracy=this.getAccuracy(C),E++}if(d.length>5+E&&m.substr(d[5+E],2)=="01"){var D=i(m,d[5+E]);D=="ff"&&(p.ordering=!0),E++}if(d.length>5+E&&m.substr(d[5+E],2)=="02"){var B=i(m,d[5+E]);p.nonce={hex:B},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 S=o(m,d[5+E]);S="30"+S.substr(2);var I=r.getExtParamArray(S);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,f=a.OtherHashAlgAndValue;u.superclass.constructor.call(this),this.params=null,this.tohex=function(){var h=this.params,m=[];m.push(new i(h.oid)),m.push(new f(h));var p=new n({array:m});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(h){this.params=h},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,f=u.OtherHashAlgAndValue;f.superclass.constructor.call(this),this.params=null,this.tohex=function(){var h=this.params;if(h.alg==null)throw new t("property 'alg' not specified");if(h.hash==null&&h.cert==null)throw new t("property 'hash' nor 'cert' not specified");var m=null;if(h.hash!=null)m=h.hash;else if(h.cert!=null){if(typeof h.cert!="string")throw new t("cert not string");var p=h.cert;h.cert.indexOf("-----BEGIN")!=-1&&(p=Sr(h.cert)),m=A.crypto.Util.hashHex(p,h.alg)}var d=[];d.push(new a({name:h.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 f=a.cert;a.cert.indexOf("-----BEGIN")!=-1&&(f=Sr(a.cert)),u=A.crypto.Util.hashHex(f,"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 f=new o;return f.hTLV=u.tst,[f]}else{if(u.tst instanceof o)return[u.tst];throw new t("params.tst has wrong value")}else if(u.res!=null){var h=u.res;if(h instanceof o&&(h=h.tohex()),typeof h!="string"||!n(h))throw new t("params.res has wrong value");var m=ke.getTLVbyList(h,0,[1]),f=new o;return f.hTLV=u.tst,[f]}},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,f=[],h=0;h"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(),f=new A.crypto.Signature({alg:this.params.sigalg});f.init(this.params.sbjprvkey),f.updateHex(u);var h=f.sign();this.params.sighex=h},this.getPEM=function(){return Yn(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var u=this.params,f=new A.asn1.csr.CertificationRequestInfo(this.params),h=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:[f,h,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,f=r.csr,h=r.x509,m=h.X500Name,p=h.Extensions,d=h.SubjectPublicKeyInfo,v=f.AttributeList;f.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(xt.getKey(y.sbjpubkey))),y.attrs!=null){var E=g(y.attrs),C=u({tag:{tage:"a0",obj:E}});w.push(C)}else if(y.extreq!=null){var D=new p(y.extreq),C=u({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[D]}]}}});w.push(C)}else w.push(new a({tag:"a0",explicit:!1,obj:new s({str:""})}));var B=new i({array:w});return B.tohex()},this.getEncodedHex=function(){return this.tohex()};function g(y){for(var w=Error,E=A.asn1.x509.Extensions,C=[],D=0;D"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 f=new r({array:u});return f.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,f=r.x509.AlgorithmIdentifier,h=r.ocsp,m=h.ResponderID;_SingleResponseList=h.SingleResponseList,_ResponseData=h.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 f({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 E_(e){for(var t=new Array,r=0;r>6,u=128|s&63;return er(a.toString(16)+u.toString(16))}var a=224|(o&240)>>4,u=128|(o&15)<<2|(s&192)>>6,f=128|s&63;return er(a.toString(16)+u.toString(16)+f.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function yg(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function VK(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&&(f=f+"."+a.join(".")),f}catch{return null}}function I_(e){var t=new oe(String(e),10);return Nd(t)}function Nd(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 $_(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 P_(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+fg("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var i="0"+r;return i+n}function x_(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,f=0;f=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 f=A.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[u];this.mac=He.algo.HMAC.create(f,this.pass)}catch(h){throw"setAlgAndProvider hash alg set fail hashAlg="+u+"/"+h}this.updateString=function(h){this.mac.update(h)},this.updateHex=function(h){var m=He.enc.Hex.parse(h);this.mac.update(m)},this.doFinal=function(){var h=this.mac.finalize();return h.toString(He.enc.Hex)},this.doFinalString=function(h){return this.updateString(h),this.doFinal()},this.doFinalHex=function(h){return this.updateHex(h),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=Ro(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=gg(s.utf8)),s.rstr!==void 0&&(a=Ro(s.rstr)),s.b64!==void 0&&(a=Rl(s.b64)),s.b64u!==void 0&&(a=vr(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,f=null,h=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 C="",D=E/4-w.length,B=0;B"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=Gt,u=A.crypto.ECDSA,f=A.crypto.ECParameterDB,h=u.getName,m=ke,p=m.getVbyListEx,d=m.isASN1HEX,v=new Nl,g=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function y(w,E,C,D){for(var B=Math.max(E.bitLength(),D.bitLength()),H=w.add2D(C),V=w.curve.getInfinity(),S=B-1;S>=0;--S)V=V.twice2D(),V.z=s.ONE,E.testBit(S)?D.testBit(S)?V=V.add2D(H):V=V.add2D(w):D.testBit(S)&&(V=V.add2D(C));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=f.getByName(w),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=w},this.setPrivateKeyHex=function(w){this.isPrivate=!0,this.prvKeyHex=w},this.setPublicKeyHex=function(w){this.isPublic=!0,this.pubKeyHex=w},this.getPublicKeyXYHex=function(){var w=this.pubKeyHex;if(w.substr(0,2)!=="04")throw"this method supports uncompressed format(04) only";var E=this.ecparams.keycharlen;if(w.length!==2+E*2)throw"malformed public key hex length";var C={};return C.x=w.substr(2,E),C.y=w.substr(2+E),C},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),C=this.ecparams.keycharlen,D=("0000000000"+E.toString(16)).slice(-C);this.setPrivateKeyHex(D);var B=this.generatePublicKeyHex();return{ecprvhex:D,ecpubhex:B}},this.generatePublicKeyHex=function(){var w=new s(this.prvKeyHex,16),E=this.ecparams.G.multiply(w),C=E.getX().toBigInteger(),D=E.getY().toBigInteger(),B=this.ecparams.keycharlen,H=("0000000000"+C.toString(16)).slice(-B),V=("0000000000"+D.toString(16)).slice(-B),S="04"+H+V;return this.setPublicKeyHex(S),S},this.signWithMessageHash=function(w){return this.signHex(w,this.prvKeyHex)},this.signHex=function(w,E){var C=new s(E,16),D=this.ecparams.n,B=new s(w.substring(0,this.ecparams.keycharlen),16);do var H=this.getBigRandom(D),V=this.ecparams.G,S=V.multiply(H),I=S.getX().toBigInteger().mod(D);while(I.compareTo(s.ZERO)<=0);var U=H.modInverse(D).multiply(B.add(C.multiply(I))).mod(D);return u.biRSSigToASN1Sig(I,U)},this.sign=function(w,E){var C=E,D=this.ecparams.n,B=s.fromByteArrayUnsigned(w);do var H=this.getBigRandom(D),V=this.ecparams.G,S=V.multiply(H),I=S.getX().toBigInteger().mod(D);while(I.compareTo(oe.ZERO)<=0);var U=H.modInverse(D).multiply(B.add(C.multiply(I))).mod(D);return this.serializeSig(I,U)},this.verifyWithMessageHash=function(w,E){return this.verifyHex(w,E,this.pubKeyHex)},this.verifyHex=function(w,E,C){try{var D,B,H=u.parseSigHex(E);D=H.r,B=H.s;var V=a.decodeFromHex(this.ecparams.curve,C),S=new s(w.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(S,D,B,V)}catch{return!1}},this.verify=function(w,E,C){var D,B;if(Bitcoin.Util.isArray(E)){var H=this.parseSig(E);D=H.r,B=H.s}else if(typeof E=="object"&&E.r&&E.s)D=E.r,B=E.s;else throw"Invalid value for signature";var V;if(C instanceof Gt)V=C;else if(Bitcoin.Util.isArray(C))V=a.decodeFrom(this.ecparams.curve,C);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var S=s.fromByteArrayUnsigned(w);return this.verifyRaw(S,D,B,V)},this.verifyRaw=function(w,E,C,D){var B=this.ecparams.n,H=this.ecparams.G;if(E.compareTo(s.ONE)<0||E.compareTo(B)>=0||C.compareTo(s.ONE)<0||C.compareTo(B)>=0)return!1;var V=C.modInverse(B),S=w.multiply(V).mod(B),I=E.multiply(V).mod(B),U=H.multiply(S).add(D.multiply(I)),R=U.getX().toBigInteger().mod(B);return R.equals(E)},this.serializeSig=function(w,E){var C=w.toByteArraySigned(),D=E.toByteArraySigned(),B=[];return B.push(2),B.push(C.length),B=B.concat(C),B.push(2),B.push(D.length),B=B.concat(D),B.unshift(B.length),B.unshift(48),B},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 C=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 D=w.slice(E+2,E+2+w[E+1]);E+=2+w[E+1];var B=s.fromByteArrayUnsigned(C),H=s.fromByteArrayUnsigned(D);return{r:B,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 C=this.ecparams.n,D=s.fromByteArrayUnsigned(w.slice(1,33)).mod(C),B=s.fromByteArrayUnsigned(w.slice(33,65)).mod(C);return{r:D,s:B,i:E}},this.readPKCS5PrvKeyHex=function(w){if(d(w)===!1)throw new Error("not ASN.1 hex string");var E,C,D;try{E=p(w,0,["[0]",0],"06"),C=p(w,0,[1],"04");try{D=p(w,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=h(E),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(D),this.setPrivateKeyHex(C),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(w){if(d(w)===!1)throw new o("not ASN.1 hex string");var E,C,D,B;try{E=p(w,0,[1,0],"06"),C=p(w,0,[1,1],"06"),D=p(w,0,[2,0,1],"04");try{B=p(w,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new o("malformed PKCS#8 plain ECC private key")}if(this.curveName=h(C),this.curveName===void 0)throw new o("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(B),this.setPrivateKeyHex(D),this.isPublic=!1},this.readPKCS8PubKeyHex=function(w){if(d(w)===!1)throw new o("not ASN.1 hex string");var E,C,D;try{E=p(w,0,[0,0],"06"),C=p(w,0,[0,1],"06"),D=p(w,0,[1],"03")}catch{throw new o("malformed PKCS#8 ECC public key")}if(this.curveName=h(C),this.curveName===null)throw new o("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(D)},this.readCertPubKeyHex=function(w,E){if(d(w)===!1)throw new o("not ASN.1 hex string");var C,D;try{C=p(w,0,[0,5,0,1],"06"),D=p(w,0,[0,5,1],"03")}catch{throw new o("malformed X.509 certificate ECC public key")}if(this.curveName=h(C),this.curveName===null)throw new o("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(D)},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,f,h,m,p,d,v){e[n]={};var g=r(o),y=r(s),w=r(a),E=r(u),C=r(f),D=new Ha(g,y,w),B=D.decodePointHex("04"+h+m);e[n].name=n,e[n].keylen=i,e[n].keycharlen=Math.ceil(i/8)*2,e[n].curve=D,e[n].G=B,e[n].n=E,e[n].h=C,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,f,h){if(a==null||u==null||f==null||h==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(f)>=0||f.compareTo(a)>=0)throw new Error("invalid DSA public key");if(o.compareTo(h)>=0||h.compareTo(a)>=0)throw new Error("invalid DSA public key");if(f.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,f,h,m){this.isPrivate=!0,this.p=a,this.q=u,this.g=f,this.y=h,this.x=m},this.setPrivateHex=function(a,u,f,h,m){var p,d,v,g,y;p=new oe(a,16),d=new oe(u,16),v=new oe(f,16),typeof h=="string"&&h.length>1?g=new oe(h,16):g=null,y=new oe(m,16),this.setPrivate(p,d,v,g,y)},this.setPublic=function(a,u,f,h){s(a,u,f,h),this.isPublic=!0,this.p=a,this.q=u,this.g=f,this.y=h,this.x=null},this.setPublicHex=function(a,u,f,h){var m,p,d,v;m=new oe(a,16),p=new oe(u,16),d=new oe(f,16),v=new oe(h,16),this.setPublic(m,p,d,v)},this.signWithMessageHash=function(a){var u=this.p,f=this.q,h=this.g,m=this.y,p=this.x,d=a.substr(0,f.bitLength()/4),v=new oe(d,16),g,y,w;do g=A.crypto.Util.getRandomBigIntegerMinToMax(oe.ONE.add(oe.ONE),f.subtract(oe.ONE)),y=h.modPow(g,u).mod(f),w=g.modInverse(f).multiply(v.add(p.multiply(y))).mod(f);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 f=this.p,h=this.q,m=this.g,p=this.y,d=this.parseASN1Signature(u),v=d[0],g=d[1],y=a.substr(0,h.bitLength()/4),w=new oe(y,16);if(oe.ZERO.compareTo(v)>=0||v.compareTo(h)>=0||oe.ZERO.compareTo(g)>=0||g.compareTo(h)>=0)throw"invalid DSA signature";var E=g.modInverse(h),C=w.multiply(E).mod(h),D=v.multiply(E).mod(h),B=m.modPow(C,f).multiply(p.modPow(D,f)).mod(f).mod(h);return B.compareTo(v)==0},this.parseASN1Signature=function(a){try{var u=new i(r(a,0,[0],"02"),16),f=new i(r(a,0,[1],"02"),16);return[u,f]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(a){var u,f,h,m,p;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[1],"02"),f=r(a,0,[2],"02"),h=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,f,h,m,p)},this.readPKCS8PrvKeyHex=function(a){var u,f,h,m;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[1,1,0],"02"),f=r(a,0,[1,1,1],"02"),h=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,f,h,null,m)},this.readPKCS8PubKeyHex=function(a){var u,f,h,m;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{u=r(a,0,[0,1,0],"02"),f=r(a,0,[0,1,1],"02"),h=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,f,h,m)},this.readCertPubKeyHex=function(a,u){var f,h,m,p;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{f=r(a,0,[0,5,0,1,0],"02"),h=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(f,h,m,p)}};var xt=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 C=He.enc.Hex.parse(y),D=He.enc.Hex.parse(w),B=He.enc.Hex.parse(E),H={};H.key=D,H.iv=B,H.ciphertext=C;var V=g.decrypt(H,D,{iv:B});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 C=He.enc.Hex.parse(y),D=He.enc.Hex.parse(w),B=He.enc.Hex.parse(E),H=g.encrypt(C,D,{iv:B}),V=He.enc.Hex.parse(H.toString()),S=He.enc.Base64.stringify(V);return S},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}},f=function(g){return u[g].proc},h=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 C=-1,D=0;g.indexOf(`\r \r `)!=-1&&(C=g.indexOf(`\r \r `),D=2),g.indexOf(` `)!=-1&&(C=g.indexOf(` `),D=1);var B=g.indexOf("-----END");if(C!=-1&&B!=-1){var H=g.substring(C+D*2,B-D);H=H.replace(/\s+/g,""),y.data=H}return y},p=function(g,y,w){for(var E=w.substring(0,16),C=He.enc.Hex.parse(E),D=He.enc.Utf8.parse(y),B=u[g].keylen+u[g].ivlen,H="",V=null;;){var S=He.algo.MD5.create();if(V!=null&&S.update(V),S.update(D),S.update(C),V=S.finalize(),H=H+He.enc.Hex.stringify(V),H.length>=B*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 C=He.enc.Base64.parse(g),D=He.enc.Hex.stringify(C),B=u[y].proc,H=B(D,w,E);return H},v=function(g,y,w,E){var C=u[y].eproc,D=C(g,w,E);return D};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,C=w.cipher,D=w.ivsalt,B=w.data,H=p(C,y,D),V=H.keyhex,S=d(B,C,V,D);return S},getEncryptedPKCS5PEMFromPrvKeyHex:function(g,y,w,E,C){var U="";if((typeof E>"u"||E==null)&&(E="AES-256-CBC"),typeof u[E]>"u")throw new Error("KEYUTIL unsupported algorithm: "+E);if(typeof C>"u"||C==null){var D=u[E].ivlen,B=h(D);C=B.toUpperCase()}var H=p(E,w,C),V=H.keyhex,S=v(y,E,V,C),I=S.replace(/(.{64})/g,`$1\r `),U="-----BEGIN "+g+` PRIVATE KEY-----\r `;return U+=`Proc-Type: 4,ENCRYPTED\r `,U+="DEK-Info: "+E+","+C+`\r `,U+=`\r `,U+=I,U+=`\r -----END `+g+` PRIVATE KEY-----\r `,U},getEncryptedPKCS8PEM:function(g,y,w){var E=this.getEncryptedPKCS8Hex(g,y,w);return Yn(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 C=this.generatePBES2ASN1Param(E);return A.asn1.ASN1Util.newObject(C).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=xt.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:I_(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,C={},D=w(g,0);if(D.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+D.length);C.ciphertext=E(g,D[1]);var B=w(g,D[0]);if(B.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+B.length);if(E(g,B[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var H=w(g,B[1]);if(B.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";C.encryptionSchemeAlg="TripleDES",C.encryptionSchemeIV=E(g,V[1]);var S=w(g,H[0]);if(S.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+S.length);if(E(g,S[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var I=w(g,S[1]);if(I.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+I.length);C.pbkdf2Salt=E(g,I[0]);var U=E(g,I[1]);try{C.pbkdf2Iter=parseInt(U,16)}catch{throw new Error("malformed format pbkdf2Iter: "+U)}return C},getPBKDF2KeyHexFromParam:function(g,y){var w=He.enc.Hex.parse(g.pbkdf2Salt),E=g.pbkdf2Iter,C=He.PBKDF2(y,w,{keySize:192/32,iterations:E}),D=He.enc.Hex.stringify(C);return D},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(g,y){var w=Sr(g,"ENCRYPTED PRIVATE KEY"),E=this.parseHexOfEncryptedPKCS8(w),C=xt.getPBKDF2KeyHexFromParam(E,y),D={};D.ciphertext=He.enc.Hex.parse(E.ciphertext);var B=He.enc.Hex.parse(C),H=He.enc.Hex.parse(E.encryptionSchemeIV),V=He.TripleDES.decrypt(D,B,{iv:H}),S=He.enc.Hex.stringify(V);return S},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"),C=ur(w,"1.int.hex"),D=ur(w,"2.seq.0.oid","hmacWithSHA1"),B=-1;try{B=parseInt(C,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"),S=ur(y,"seq.1.octstr.hex");if(H==null||V==null||S==null)throw new Error("encalg, enciv or enc is undefined");var I={salt:E,iter:B,prf:D,encalg:H,enciv:V,enc:S};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},C=w[g.prf];if(C==null)throw new Error("unsupported prf");var D=E[g.encalg];if(D==null)throw new Error("unsupported encalg");var B=He.enc.Hex.parse(g.salt),H=g.iter;try{var V=He.PBKDF2(y,B,{keySize:D,iterations:H,hasher:C});return He.enc.Hex.stringify(V)}catch(S){throw new Error("PBKDF2 error: "+S+" "+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=Sr(g),E;try{E=xt.parsePBES2(w)}catch(D){throw new Error("malformed PBES2 format: "+D.message)}var C=xt.getDKFromPBES2Param(E,y);return A.crypto.Cipher.decrypt(E.enc,C,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,C={};if(C.algparam=null,g.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var D=w(g,0);if(D.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(g.substr(D[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var B=w(g,D[1]);if(B.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(g.substr(B[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(C.algoid=E(g,B[0]),g.substr(B[1],2)=="06"&&(C.algparam=E(g,B[1])),g.substr(D[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return C.keyidx=y.getVidx(g,D[2]),C},getKeyFromPlainPrivatePKCS8PEM:function(g){var y=Sr(g,"PRIVATE KEY"),w=this.getKeyFromPlainPrivatePKCS8Hex(y);return w},getKeyFromPlainPrivatePKCS8Hex:function(g){var y=this.parsePlainPrivatePKCS8Hex(g),w;if(y.algoid=="2a864886f70d010101")w=new mt;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 mt;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,C={};if(g.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var D=w(g,0);if(D.length!=2)throw new Error("malformed RSA key(code:002)");if(g.substr(D[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(C.n=E(g,D[0]),g.substr(D[1],2)!="02")throw new Error("malformed RSA key(code:004)");return C.e=E(g,D[1]),C},parsePublicPKCS8Hex:function(g){var y=ke,w=y.getChildIdx,E=y.getV,C={};C.algparam=null;var D=w(g,0);if(D.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+D.length);var B=D[0];if(g.substr(B,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var H=w(g,B);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(C.algoid=E(g,H[0]),g.substr(H[1],2)=="06"?C.algparam=E(g,H[1]):g.substr(H[1],2)=="30"&&(C.algparam={},C.algparam.p=y.getVbyList(g,H[1],[0],"02"),C.algparam.q=y.getVbyList(g,H[1],[1],"02"),C.algparam.g=y.getVbyList(g,H[1],[2],"02")),g.substr(D[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return C.key=E(g,D[1]).substr(2),C}}}();xt.getKey=function(e,t,r){var n=ke,i=n.getChildIdx,o=n.getV,s=n.getVbyList,a=A.crypto,u=a.ECDSA,f=a.DSA,h=mt,m=Sr,p=xt;if(typeof h<"u"&&e instanceof h||typeof u<"u"&&e instanceof u||typeof f<"u"&&e instanceof f)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 h;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 h;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 h;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 f;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 f;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 h;return d.setPublic(vr(e.n),vr(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 h;return d.setPrivateEx(vr(e.n),vr(e.e),vr(e.d),vr(e.p),vr(e.q),vr(e.dp),vr(e.dq),vr(e.qi)),d}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var d=new h;return d.setPrivate(vr(e.n),vr(e.e),vr(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"+vr(e.x)).slice(-g),w=("0000000000"+vr(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"+vr(e.x)).slice(-g),w=("0000000000"+vr(e.y)).slice(-g),E="04"+y+w,C=("0000000000"+vr(e.d)).slice(-g);return v.setPublicKeyHex(E),v.setPrivateKeyHex(C),v}if(r==="pkcs5prv"){var D=e,n=ke,B,d;if(B=i(D,0),B.length===9)d=new h,d.readPKCS5PrvKeyHex(D);else if(B.length===6)d=new f,d.readPKCS5PrvKeyHex(D);else if(B.length>2&&D.substr(B[1],2)==="04")d=new u,d.readPKCS5PrvKeyHex(D);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=Sr(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 S=m(e,"DSA PRIVATE KEY"),I=s(S,0,[1],"02"),U=s(S,0,[2],"02"),R=s(S,0,[3],"02"),O=s(S,0,[4],"02"),q=s(S,0,[5],"02"),d=new f;return d.setPrivate(new oe(I,16),new oe(U,16),new oe(R,16),new oe(O,16),new oe(q,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),_=new mt;return _.readPKCS5PrvKeyHex(N),_}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var S=p.getDecryptedKeyHex(e,t),d=s(S,0,[1],"04"),k=s(S,0,[2,0],"06"),K=s(S,0,[3,0],"03").substr(2),Z="";if(A.crypto.OID.oidhex2name[k]!==void 0)Z=A.crypto.OID.oidhex2name[k];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+k);var v=new u({curve:Z});return v.setPublicKeyHex(K),v.setPrivateKeyHex(d),v.isPublic=!1,v}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var S=p.getDecryptedKeyHex(e,t),I=s(S,0,[1],"02"),U=s(S,0,[2],"02"),R=s(S,0,[3],"02"),O=s(S,0,[4],"02"),q=s(S,0,[5],"02"),d=new f;return d.setPrivate(new oe(I,16),new oe(U,16),new oe(R,16),new oe(O,16),new oe(q,16)),d}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return p.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};xt.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new mt;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var i=new mt,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,f=new A.crypto.ECDSA({curve:u}),h=f.generateKeyPairHex(),n=new A.crypto.ECDSA({curve:u});n.setPublicKeyHex(h.ecpubhex),n.setPrivateKeyHex(h.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var i=new A.crypto.ECDSA({curve:u});i.setPublicKeyHex(h.ecpubhex),i.isPrivate=!1,i.isPublic=!0;var a={};return a.prvKeyObj=n,a.pubKeyObj=i,a}else throw new Error("unknown algorithm: "+e)};xt.getPEM=function(e,t,r,n,i,o){var s=A,a=s.asn1,u=a.DERObjectIdentifier,f=a.DERInteger,h=a.ASN1Util.newObject,m=a.x509,p=m.SubjectPublicKeyInfo,d=s.crypto,v=d.DSA,g=d.ECDSA,y=mt;function w(_){var k=h({seq:[{int:0},{int:{bigint:_.n}},{int:_.e},{int:{bigint:_.d}},{int:{bigint:_.p}},{int:{bigint:_.q}},{int:{bigint:_.dmp1}},{int:{bigint:_.dmq1}},{int:{bigint:_.coeff}}]});return k}function E(_){var k=h({seq:[{int:1},{octstr:{hex:_.prvKeyHex}},{tag:["a0",!0,{oid:{name:_.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+_.pubKeyHex}}]}]});return k}function C(_){var k=h({seq:[{int:0},{int:{bigint:_.p}},{int:{bigint:_.q}},{int:{bigint:_.g}},{int:{bigint:_.y}},{int:{bigint:_.x}}]});return k}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 D=new p(e),B=D.tohex();return Yn(B,"PUBLIC KEY")}if(t=="PKCS1PRV"&&y!==void 0&&e instanceof y&&(r===void 0||r==null)&&e.isPrivate==!0){var D=w(e),B=D.tohex();return Yn(B,"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(),S=E(e),I=S.tohex(),U="";return U+=Yn(V,"EC PARAMETERS"),U+=Yn(I,"EC PRIVATE KEY"),U}if(t=="PKCS1PRV"&&v!==void 0&&e instanceof v&&(r===void 0||r==null)&&e.isPrivate==!0){var D=C(e),B=D.tohex();return Yn(B,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&y!==void 0&&e instanceof y&&r!==void 0&&r!=null&&e.isPrivate==!0){var D=w(e),B=D.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",B,r,n,o)}if(t=="PKCS5PRV"&&g!==void 0&&e instanceof g&&r!==void 0&&r!=null&&e.isPrivate==!0){var D=E(e),B=D.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",B,r,n,o)}if(t=="PKCS5PRV"&&v!==void 0&&e instanceof v&&r!==void 0&&r!=null&&e.isPrivate==!0){var D=C(e),B=D.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",B,r,n,o)}var R=function(_,k){if(typeof k=="string")return xt.getEncryptedPKCS8PEM(_,k);if(typeof k=="object"&&ur(k,"passcode")!=null){var K=JSON.parse(JSON.stringify(k)),Z=K.passcode;return delete K.passcode,xt.getEncryptedPKCS8PEM(_,Z,K)}};if(t=="PKCS8PRV"&&y!=null&&e instanceof y&&e.isPrivate==!0){var O=w(e),q=O.tohex(),D=h({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:q}}]}),B=D.tohex();return r===void 0||r==null?Yn(B,"PRIVATE KEY"):R(B,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 O=new h(N),q=O.tohex(),D=h({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:q}}]}),B=D.tohex();return r===void 0||r==null?Yn(B,"PRIVATE KEY"):R(B,r)}if(t=="PKCS8PRV"&&v!==void 0&&e instanceof v&&e.isPrivate==!0){var O=new f({bigint:e.x}),q=O.tohex(),D=h({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:q}}]}),B=D.tohex();return r===void 0||r==null?Yn(B,"PRIVATE KEY"):R(B,r)}throw new Error("unsupported object nor format")};xt.getKeyFromCSRPEM=function(e){var t=Sr(e,"CERTIFICATE REQUEST"),r=xt.getKeyFromCSRHex(t);return r};xt.getKeyFromCSRHex=function(e){var t=xt.parseCSRHex(e),r=xt.getKey(t.p8pubkeyhex,null,"pkcs8pub");return r};xt.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};xt.getKeyID=function(e){var t=xt,r=ke;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=Sr(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),o=r.getV(n,i).substring(2);return A.crypto.Util.hashHex(o,"sha1")};xt.getJWK=function(e,t,r,n,i){var o,s={},a,u=A.crypto.Util.hashHex;if(typeof e=="string")o=xt.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(a=Sr(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 mt&&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 mt&&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 f=o.getShortNISTPCurveName();if(f!=="P-256"&&f!=="P-384"&&f!=="P-521")throw new Error("unsupported curve name for JWT: "+f);var h=o.getPublicKeyXYHex();s.kty="EC",s.crv=f,s.x=Jr(h.x),s.y=Jr(h.y),s.d=Jr(o.prvKeyHex)}else if(o instanceof A.crypto.ECDSA&&o.isPublic){var f=o.getShortNISTPCurveName();if(f!=="P-256"&&f!=="P-384"&&f!=="P-521")throw new Error("unsupported curve name for JWT: "+f);var h=o.getPublicKeyXYHex();s.kty="EC",s.crv=f,s.x=Jr(h.x),s.y=Jr(h.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=[Ua(a)]),a!=null&&n!=!0&&(s.x5t=Tl(Ua(u(a,"sha1")))),a!=null&&i!=!0&&(s["x5t#S256"]=Tl(Ua(u(a,"sha256")))),s};xt.getJWKFromKey=function(e){return xt.getJWK(e,!0,!0,!0,!0)};mt.getPosArrayOfChildrenFromHex=function(e){return ke.getChildIdx(e,0)};mt.getHexValueArrayOfChildrenFromHex=function(e){var t=ke,r=t.getV,p=mt.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]),f=r(e,p[6]),h=r(e,p[7]),m=r(e,p[8]),p=new Array;return p.push(n,i,o,s,a,u,f,h,m),p};mt.prototype.readPrivateKeyFromPEMString=function(e){var t=Sr(e),r=mt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};mt.prototype.readPKCS5PrvKeyHex=function(e){var t=mt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};mt.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,o,s,a,u,f=ke,h=f.getVbyListEx;if(f.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");try{t=h(e,0,[2,0,1],"02"),r=h(e,0,[2,0,2],"02"),n=h(e,0,[2,0,3],"02"),i=h(e,0,[2,0,4],"02"),o=h(e,0,[2,0,5],"02"),s=h(e,0,[2,0,6],"02"),a=h(e,0,[2,0,7],"02"),u=h(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)};mt.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)};mt.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)};mt.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new at,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var fle=new RegExp("[^0-9a-f]","gi");function T_(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}mt.prototype.signPSS=function(e,t,r){var n=function(o){return A.crypto.Util.hashHex(o,t)},i=n(Ro(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(i,t,r)};mt.prototype.signWithMessageHashPSS=function(e,t,r){var n=Rs(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&&(f=new Array(r),new Nl().nextBytes(f),f=String.fromCharCode.apply(String,f));var h=Rs(u(Ro("\0\0\0\0\0\0\0\0"+n+f))),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=k_(s);if(a.length==0)return!1;var u=a[0],f=a[1],h=function(p){return A.crypto.Util.hashString(p,u)},m=h(e);return f==m};mt.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=xs(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),i=n.toString(16).replace(/^1f+00/,""),o=k_(i);if(o.length==0)return!1;var s=o[0],a=o[1];return a==e};mt.prototype.verifyPSS=function(e,t,r,n){var i=function(s){return A.crypto.Util.hashHex(s,r)},o=i(Ro(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(o,t,r,n)};mt.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=Rs(e),a=s.length,u=this.n.bitLength()-1,f=Math.ceil(u/8),h;if(n===-1||n===void 0)n=a;else if(n===-2)n=f-a-2;else if(n<-2)throw new Error("invalid salt length");if(f>8*f-u&255;if(p.charCodeAt(0)&v)throw new Error("bits beyond keysize not zero");var g=R_(d,p.length,o),y=[];for(h=0;h0?I:void 0}catch{return}},this._asn1ToNoticeRef=function(S){try{for(var I={},U=ur(S,"seq"),R=0;R0?I:void 0}catch{return}},this._asn1ToNoticeNum=function(S){try{for(var I=ur(S,"seq"),U=[],R=0;R1){var q=s(S,O[1]),N=this.getGeneralName(q);N.uri!=null&&(R.uri=N.uri)}if(O.length>2){var _=s(S,O[2]);_=="0101ff"&&(R.reqauth=!0),_=="010100"&&(R.reqauth=!1)}return R},this.getExtSubjectDirectoryAttributes=function(S,I){if(S===void 0&&I===void 0){var U=this.getExtInfo("subjectDirectoryAttributes");if(U===void 0)return;S=s(this.hex,U.vidx),I=U.critical}var R={extname:"subjectDirectoryAttributes"};I&&(R.critical=!0);try{for(var O=o(S),q=[],N=0;N0&&(I.ext=this.getExtParamArray()),I.sighex=this.getSignatureValueHex(),S.tbshex==!0&&(I.tbshex=f(this.hex,0,[0])),S.nodnarray==!0&&(delete I.issuer.array,delete I.subject.array),I},this.getExtParamArray=function(S){if(S==null){var I=p(this.hex,0,[0,"[3]"]);I!=-1&&(S=h(this.hex,0,[0,"[3]",0],"30"))}for(var U=[],R=r(S,0),O=0;O"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],f=s+"."+a;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=a,this.parsedJWS.sigvalB64U=u,this.parsedJWS.si=f,!i){var h=vr(u),m=xs(h,16);this.parsedJWS.sigvalH=h,this.parsedJWS.sigvalBI=m}var p=zi(s),d=zi(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,f=a.isSafeJSONString,h=o.crypto,m=h.ECDSA,p=h.Mac,d=h.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,!f(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 C=Rd(g),D=Rd(w),B=C+"."+D,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(B),H=V.doFinal()}else if(E.indexOf("withECDSA")!=-1){var S=new d({alg:E});S.init(n,i),S.updateString(B);var I=S.sign();H=A.crypto.ECDSA.asn1SigToConcatSig(I)}else if(E!="none"){var S=new d({alg:E});S.init(n,i),S.updateString(B),H=S.sign()}var U=Jr(H);return B+"."+U};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,f=a.Mac,h=a.Signature,m;if(typeof mt!==void 0&&(m=mt),!tE(e))return!1;var p=e.split(".");if(p.length!==3)return!1;var d=p[0],v=p[1],g=d+"."+v,y=vr(p[2]),w=s(zi(p[0])),E=null,C=null;if(w.alg===void 0)throw"algorithm not specified in header";if(E=w.alg,C=E.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var D=":"+r.join(":")+":";if(D.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=xt.getKey(t)),(C=="RS"||C=="PS")&&!(t instanceof m))throw"key shall be a RSAKey obj for RS* and PS* algs";if(C=="ES"&&!(t instanceof u))throw"key shall be a ECDSA obj for ES* algs";E=="none";var B=null;if(o.jwsalg2sigalg[w.alg]===void 0)throw new Error("unsupported alg name: "+E);if(B=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 f=A.jws.JWS.sign(i,o,this.sPayload,s,a),h=f.split("."),m=h[0],p=h[2];this.aHeader.push(h[0]),this.aSignature.push(h[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=Nl;Ne.rng_seed_time=Xy;Ne.BigInteger=oe;Ne.RSAKey=mt;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=xt;Ne.ASN1HEX=ke;Ne.X509=at;Ne.X509CRL=WK;Ne.CryptoJS=He;Ne.b64tohex=Rl;Ne.b64toBA=p_;Ne.ECFieldElementFp=Qr;Ne.ECPointFp=Gt;Ne.ECCurveFp=Ha;Ne.stoBA=E_;Ne.BAtos=b_;Ne.BAtohex=pg;Ne.stohex=Ts;Ne.stob64=BK;Ne.stob64u=IK;Ne.b64utos=$K;Ne.b64tob64u=Tl;Ne.b64utob64=Od;Ne.hex2b64=Ua;Ne.hextob64u=Jr;Ne.b64utohex=vr;Ne.utf8tob64u=Rd;Ne.b64utoutf8=zi;Ne.utf8tob64=PK;Ne.b64toutf8=xK;Ne.utf8tohex=gg;Ne.hextoutf8=er;Ne.hextorstr=Rs;Ne.rstrtohex=Ro;Ne.hextob64=Zy;Ne.hextob64nl=kK;Ne.b64nltohex=A_;Ne.hextopem=Yn;Ne.pemtohex=Sr;Ne.hextoArrayBuffer=LK;Ne.ArrayBuffertohex=UK;Ne.zulutomsec=Jy;Ne.msectozulu=HK;Ne.zulutosec=S_;Ne.zulutodate=qK;Ne.datetozulu=MK;Ne.uricmptohex=vg;Ne.hextouricmp=wg;Ne.ipv6tohex=Ky;Ne.hextoipv6=Vy;Ne.hextoip=cg;Ne.iptohex=Qy;Ne.ucs2hextoutf8=eE;Ne.encodeURIComponentAll=yg;Ne.newline_toUnix=jK;Ne.newline_toDos=KK;Ne.hextoposhex=zy;Ne.intarystrtohex=VK;Ne.strdiffidx=zK;Ne.oidtohex=B_;Ne.hextooid=Eg;Ne.strpad=fg;Ne.bitstrtoint=$_;Ne.inttobitstr=P_;Ne.bitstrtobinstr=x_;Ne.binstrtobitstr=GK;Ne.isBase64URLDot=tE;Ne.namearraytobinstr=lg;Ne.extendClass=_e;Ne.foldnl=mg;Ne.b64topem=OK;Ne.pemtob64=NK;Ne.timeogen=C_;Ne.aryval=ur;Ne.inttohex=I_;Ne.twoscompl=Nd;Ne.timingSafeEqual=D_;Ne.timingSafeEqualImpl=F_;Ne.KJUR=A;Ne.crypto=A.crypto;Ne.asn1=A.asn1;Ne.jws=A.jws;Ne.lang=A.lang;Ne.VERSION=nM;Ne.VERSION_FULL=sM});var NB=Ce(Xb=>{"use strict";var s1e=P(x());Xb.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};Xb.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 LB=Ce(Zb=>{"use strict";var o1e=P(x());Zb.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};Zb.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 UB=Ce(Jb=>{"use strict";var u1e=P(x());Jb.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};Jb.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 HB=Ce(Qb=>{"use strict";var f1e=P(x());Qb.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};Qb.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 qB=Ce(eA=>{"use strict";var h1e=P(x());eA.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}`};eA.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 KB=Ce((jB,tA)=>{var d1e=P(x()),MB=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=m,e.encode=h,e.familyOf=f,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,C=!0,D=!1;d=d||new Uint8Array(v+i);for(let B=0;B>8),v=97?H-=87:H>=65?H-=55:(H-=48,E=E*10+H),w=(w<<4)+H)}if(C===!1)D===!0?(v>8),v=y+2;B--)d[B]=d[B-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 g1e=P(x()),st=og().Buffer,cu=NB(),jG=LB(),KG=UB(),$m=HB(),rA=qB(),Bf=KB(),VG=0,VB=32768,nA=32768,zG=~nA,zB=32768,GG=~zB,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 f=e.readUInt16BE(t-1)-49152;if(f>=i)throw new Error("Cannot decode name (bad pointer)");t=f,i=f,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 f=e.toString("utf-8",t,t+u);r&&(f=f.replace(/\./g,"\\.")),n.push(f),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 Pt={};Pt.encode=function(e,t,r){t||(t=st.alloc(Pt.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,Pt.encode.bytes=n+1,t};Pt.encode.bytes=0;Pt.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return Pt.decode.bytes=r+1,n};Pt.decode.bytes=0;Pt.encodingLength=function(e){return st.byteLength(e)+1};var to={};to.encode=function(e,t,r){t||(t=to.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,i=e.type==="response"?VB:VG;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};to.encode.bytes=12;to.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&VB?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:KG.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:jG.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))}};to.decode.bytes=12;to.encodingLength=function(){return 12};var eu=nt.unknown={};eu.encode=function(e,t,r){return t||(t=st.alloc(eu.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),eu.encode.bytes=e.length+2,t};eu.encode.bytes=0;eu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return eu.decode.bytes=r+2,n};eu.decode.bytes=0;eu.encodingLength=function(e){return e.length+2};var tu=nt.ns={};tu.encode=function(e,t,r){return t||(t=st.alloc(tu.encodingLength(e))),r||(r=0),ze.encode(e,t,r+2),t.writeUInt16BE(ze.encode.bytes,r),tu.encode.bytes=ze.encode.bytes+2,t};tu.encode.bytes=0;tu.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=ze.decode(e,t+2);return tu.decode.bytes=r+2,n};tu.decode.bytes=0;tu.encodingLength=function(e){return ze.encodingLength(e)+2};var ru=nt.soa={};ru.encode=function(e,t,r){t||(t=st.alloc(ru.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),ru.encode.bytes=r-n,t};ru.encode.bytes=0;ru.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,ru.decode.bytes=t-r,n};ru.decode.bytes=0;ru.encodingLength=function(e){return 22+ze.encodingLength(e.mname)+ze.encodingLength(e.rname)};var nu=nt.txt={};nu.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++]=Ns.decode(e,t),t+=Ns.decode.bytes,i-=Ns.decode.bytes;return ei.decode.bytes=t-r,n};ei.decode.bytes=0;ei.encodingLength=function(e){return 2+ah(e||[],Ns)};var ws=nt.dnskey={};ws.PROTOCOL_DNSSEC=3;ws.ZONE_KEY=128;ws.SECURE_ENTRYPOINT=32768;ws.encode=function(e,t,r){t||(t=st.alloc(ws.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(ws.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,i.copy(t,r,0,i.length),r+=i.length,ws.encode.bytes=r-n,t.writeUInt16BE(ws.encode.bytes-2,n),t};ws.encode.bytes=0;ws.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)!==ws.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,ws.decode.bytes=t-r,n};ws.decode.bytes=0;ws.encodingLength=function(e){return 6+st.byteLength(e.key)};var jo=nt.rrsig={};jo.encode=function(e,t,r){t||(t=st.alloc(jo.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,jo.encode.bytes=r-n,t.writeUInt16BE(jo.encode.bytes-2,n),t};jo.encode.bytes=0;jo.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,jo.decode.bytes=t-r,n};jo.decode.bytes=0;jo.encodingLength=function(e){return 20+ze.encodingLength(e.signersName)+st.byteLength(e.signature)};var Ko=nt.rp={};Ko.encode=function(e,t,r){t||(t=st.alloc(Ko.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,Ko.encode.bytes=r-n,t.writeUInt16BE(Ko.encode.bytes-2,n),t};Ko.encode.bytes=0;Ko.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,Ko.decode.bytes=t-r,n};Ko.decode.bytes=0;Ko.encodingLength=function(e){return 2+ze.encodingLength(e.mbox||".")+ze.encodingLength(e.txt||".")};var pn={};pn.encode=function(e,t,r){t||(t=st.alloc(pn.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=ei.decode(e,t+8),t+=8+ei.decode.bytes;else{let i=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=$m.toString(i&zG),r.flush=!!(i&nA);let o=sA(r.type);r.data=o.decode(e,t+8),t+=8+o.decode.bytes}return In.decode.bytes=t-n,r};In.decode.bytes=0;In.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return ze.encodingLength(e.name)+8+sA(e.type).encodingLength(t)};var eo=nt.question={};eo.encode=function(e,t,r){t||(t=st.alloc(eo.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($m.toClass(e.class===void 0?"IN":e.class),r),r+=2,eo.encode.bytes=r-n,e};eo.encode.bytes=0;eo.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=$m.toString(e.readUInt16BE(t)),t+=2,!!(n.class&zB)&&(n.class&=GG),eo.decode.bytes=t-r,n};eo.decode.bytes=0;eo.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=[]),to.encode(e,t,r),r+=to.encode.bytes,r=Ap(e.questions,eo,t,r),r=Ap(e.answers,In,t,r),r=Ap(e.authorities,In,t,r),r=Ap(e.additionals,In,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=to.decode(e,t);return t+=to.decode.bytes,t=Im(n.questions,eo,e,t),t=Im(n.answers,In,e,t),t=Im(n.authorities,In,e,t),t=Im(n.additionals,In,e,t),nt.decode.bytes=t-r,n};nt.decode.bytes=0;nt.encodingLength=function(e){return to.encodingLength(e)+ah(e.questions||[],eo)+ah(e.answers||[],In)+ah(e.authorities||[],In)+ah(e.additionals||[],In)};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 E1e=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,f="__lodash_placeholder__",h=1,m=2,p=4,d=1,v=2,g=1,y=2,w=4,E=8,C=16,D=32,B=64,H=128,V=256,S=512,I=30,U="...",R=800,O=16,q=1,N=2,_=3,k=1/0,K=9007199254740991,Z=17976931348623157e292,G=NaN,ee=4294967295,se=ee-1,le=ee>>>1,ve=[["ary",H],["bind",g],["bindKey",y],["curry",E],["curryRight",C],["flip",S],["partial",D],["partialRight",B],["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]",Me="[object Map]",yt="[object Number]",rt="[object Null]",vt="[object Object]",rn="[object Promise]",yr="[object Proxy]",Er="[object RegExp]",wt="[object Set]",Pr="[object String]",Rn="[object Symbol]",Hs="[object Undefined]",It="[object WeakMap]",tt="[object WeakSet]",Ue="[object ArrayBuffer]",dr="[object DataView]",gn="[object Float32Array]",Et="[object Float64Array]",ta="[object Int8Array]",mn="[object Int16Array]",De="[object Int32Array]",ao="[object Uint8Array]",qt="[object Uint8ClampedArray]",nn="[object Uint16Array]",qs="[object Uint32Array]",mu=/\b__p \+= '';/g,uo=/\b(__p \+=) '' \+/g,Ac=/(__e\(.*?\)|\b__t\)) \+\n'';/g,co=/&(?:amp|lt|gt|quot|#39);/g,ii=/[&<>"']/g,Vt=RegExp(co.source),bs=RegExp(ii.source),vu=/<%-([\s\S]+?)%>/g,Sc=/<%([\s\S]+?)%>/g,ra=/<%=([\s\S]+?)%>/g,fo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Cc=/^\w*$/,wu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,na=/[\\^$.*+?()[\]{}|]/g,_c=RegExp(na.source),ue=/^\s+/,Ee=/\s/,Xe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ye=/\{\n\/\* \[wrapped with (.+)\] \*/,it=/,? & /,bt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,At=/[()=,{}\[\]\/\s]/,xr=/\\(\\)?/g,rr=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,es=/\w*$/,oi=/^[-+]0x[0-9a-f]+$/i,vn=/^0b[01]+$/i,kn=/^\[object .+?Constructor\]$/,Cr=/^0o[0-7]+$/i,wn=/^(?:0|[1-9]\d*)$/,On=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,lo=/($^)/,Dc=/['\n\r\u2028\u2029\\]/g,sn="\\ud800-\\udfff",Mt="\\u0300-\\u036f",_r="\\ufe20-\\ufe2f",gt="\\u20d0-\\u20ff",pr=Mt+_r+gt,on="\\u2700-\\u27bf",lr="a-z\\xdf-\\xf6\\xf8-\\xff",Zt="\\xac\\xb1\\xd7\\xf7",ts="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",As="\\u2000-\\u206f",Ms=" \\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",rs="A-Z\\xc0-\\xd6\\xd8-\\xde",Mr="\\ufe0e\\ufe0f",br=Zt+ts+As+Ms,Fc="['\u2019]",Hf="["+sn+"]",Nn="["+br+"]",sa="["+pr+"]",Bc="\\d+",Sh="["+on+"]",Ic="["+lr+"]",ia="[^"+sn+br+Bc+on+lr+rs+"]",oa="\\ud83c[\\udffb-\\udfff]",Ch="(?:"+sa+"|"+oa+")",qf="[^"+sn+"]",$c="(?:\\ud83c[\\udde6-\\uddff]){2}",ai="[\\ud800-\\udbff][\\udc00-\\udfff]",M="["+rs+"]",z="\\u200d",J="(?:"+Ic+"|"+ia+")",ae="(?:"+M+"|"+ia+")",Be="(?:"+Fc+"(?:d|ll|m|re|s|t|ve))?",xe="(?:"+Fc+"(?:D|LL|M|RE|S|T|VE))?",qe=Ch+"?",Ve="["+Mr+"]?",nr="(?:"+z+"(?:"+[qf,$c,ai].join("|")+")"+Ve+qe+")*",Dr="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ln="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",an=Ve+qe+nr,js="(?:"+[Sh,$c,ai].join("|")+")"+an,yu="(?:"+[qf+sa+"?",sa,$c,ai,Hf].join("|")+")",ns=RegExp(Fc,"g"),ss=RegExp(sa,"g"),ho=RegExp(oa+"(?="+oa+")|"+yu+an,"g"),ui=RegExp([M+"?"+Ic+"+"+Be+"(?="+[Nn,M,"$"].join("|")+")",ae+"+"+xe+"(?="+[Nn,M+J,"$"].join("|")+")",M+"?"+J+"+"+Be,M+"+"+xe,Ln,Dr,Bc,js].join("|"),"g"),Pc=RegExp("["+z+sn+pr+Mr+"]"),y2=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,E2=["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"],b2=-1,fr={};fr[gn]=fr[Et]=fr[ta]=fr[mn]=fr[De]=fr[ao]=fr[qt]=fr[nn]=fr[qs]=!0,fr[we]=fr[Pe]=fr[Ue]=fr[Oe]=fr[dr]=fr[fe]=fr[Re]=fr[Ke]=fr[Me]=fr[yt]=fr[vt]=fr[Er]=fr[wt]=fr[Pr]=fr[It]=!1;var or={};or[we]=or[Pe]=or[Ue]=or[dr]=or[Oe]=or[fe]=or[gn]=or[Et]=or[ta]=or[mn]=or[De]=or[Me]=or[yt]=or[vt]=or[Er]=or[wt]=or[Pr]=or[Rn]=or[ao]=or[qt]=or[nn]=or[qs]=!0,or[Re]=or[Ke]=or[It]=!1;var A2={\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"},S2={"&":"&","<":"<",">":">",'"':""","'":"'"},C2={"&":"&","<":"<",">":">",""":'"',"'":"'"},_2={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},D2=parseFloat,F2=parseInt,Wp=typeof global=="object"&&global&&global.Object===Object&&global,B2=typeof self=="object"&&self&&self.Object===Object&&self,jr=Wp||B2||Function("return this")(),_h=typeof ch=="object"&&ch&&!ch.nodeType&&ch,aa=_h&&typeof Cp=="object"&&Cp&&!Cp.nodeType&&Cp,Yp=aa&&aa.exports===_h,Dh=Yp&&Wp.process,Ss=function(){try{var ce=aa&&aa.require&&aa.require("util").types;return ce||Dh&&Dh.binding&&Dh.binding("util")}catch{}}(),Xp=Ss&&Ss.isArrayBuffer,Zp=Ss&&Ss.isDate,Jp=Ss&&Ss.isMap,Qp=Ss&&Ss.isRegExp,e0=Ss&&Ss.isSet,t0=Ss&&Ss.isTypedArray;function is(ce,Ae,me){switch(me.length){case 0:return ce.call(Ae);case 1:return ce.call(Ae,me[0]);case 2:return ce.call(Ae,me[0],me[1]);case 3:return ce.call(Ae,me[0],me[1],me[2])}return ce.apply(Ae,me)}function I2(ce,Ae,me,We){for(var pt=-1,Ot=ce==null?0:ce.length;++pt-1}function de(ce,Ae,me){for(var We=-1,pt=ce==null?0:ce.length;++We-1;);return me}function kh(ce,Ae){for(var me=ce.length;me--&&bu(Ae,ce[me],0)>-1;);return me}function Oh(ce,Ae){for(var me=ce.length,We=0;me--;)ce[me]===Ae&&++We;return We}var $2=Ih(A2),o0=Ih(S2);function P2(ce){return"\\"+_2[ce]}function a0(ce,Ae){return ce==null?e:ce[Ae]}function Su(ce){return Pc.test(ce)}function x2(ce){return y2.test(ce)}function T2(ce){for(var Ae,me=[];!(Ae=ce.next()).done;)me.push(Ae.value);return me}function cn(ce){var Ae=-1,me=Array(ce.size);return ce.forEach(function(We,pt){me[++Ae]=[pt,We]}),me}function Tc(ce,Ae){return function(me){return ce(Ae(me))}}function En(ce,Ae){for(var me=-1,We=ce.length,pt=0,Ot=[];++me-1}function l$(c,l){var b=this.__data__,T=w0(b,c);return T<0?(++this.size,b.push([c,l])):b[T][1]=l,this}pa.prototype.clear=a$,pa.prototype.delete=u$,pa.prototype.get=c$,pa.prototype.has=f$,pa.prototype.set=l$;function ga(c){var l=-1,b=c==null?0:c.length;for(this.clear();++l=l?c:l)),c}function fi(c,l,b,T,j,X){var re,ie=l&h,he=l&m,Ie=l&p;if(b&&(re=j?b(c,T,j,X):b(c)),re!==e)return re;if(!Ar(c))return c;var $e=Ct(c);if($e){if(re=gP(c),!ie)return _s(c,re)}else{var Te=Hn(c),je=Te==Ke||Te==Qe;if(Bu(c))return t6(c,ie);if(Te==vt||Te==we||je&&!j){if(re=he||je?{}:E6(c),!ie)return he?sP(c,F$(re,c)):nP(c,PS(re,c))}else{if(!or[Te])return j?c:{};re=mP(c,Te,ie)}}X||(X=new Bi);var Je=X.get(c);if(Je)return Je;X.set(c,re),Y6(c)?c.forEach(function(ct){re.add(fi(ct,l,b,ct,c,X))}):G6(c)&&c.forEach(function(ct,Tt){re.set(Tt,fi(ct,l,b,Tt,c,X))});var ht=Ie?he?lv:fv:he?Fs:fn,Ft=$e?e:ht(c);return L(Ft||c,function(ct,Tt){Ft&&(Tt=ct,ct=c[Tt]),Vh(re,Tt,fi(ct,l,b,Tt,c,X))}),re}function B$(c){var l=fn(c);return function(b){return xS(b,c,l)}}function xS(c,l,b){var T=b.length;if(c==null)return!T;for(c=Jt(c);T--;){var j=b[T],X=l[j],re=c[j];if(re===e&&!(j in c)||!X(re))return!1}return!0}function TS(c,l,b){if(typeof c!="function")throw new Cs(i);return Jh(function(){c.apply(e,b)},l)}function zh(c,l,b,T){var j=-1,X=Eu,re=!0,ie=c.length,he=[],Ie=l.length;if(!ie)return he;b&&(l=sr(l,yn(b))),T?(X=de,re=!1):l.length>=r&&(X=ca,re=!1,l=new Nc(l));e:for(;++jj?0:j+b),T=T===e||T>j?j:_t(T),T<0&&(T+=j),T=b>T?0:Z6(T);b0&&b(ie)?l>1?bn(ie,l-1,b,T,j):po(j,ie):T||(j[j.length]=ie)}return j}var z2=a6(),OS=a6(!0);function vo(c,l){return c&&z2(c,l,fn)}function G2(c,l){return c&&OS(c,l,fn)}function E0(c,l){return Gr(l,function(b){return ya(c[b])})}function Uc(c,l){l=Du(l,c);for(var b=0,T=l.length;c!=null&&bl}function P$(c,l){return c!=null&&zt.call(c,l)}function x$(c,l){return c!=null&&l in Jt(c)}function T$(c,l,b){return c>=Un(l,b)&&c=120&&$e.length>=120)?new Nc(re&&$e):e}$e=c[0];var Te=-1,je=ie[0];e:for(;++Te-1;)ie!==c&&Wf.call(ie,he,1),Wf.call(c,he,1);return c}function GS(c,l){for(var b=c?l.length:0,T=b-1;b--;){var j=l[b];if(b==T||j!==X){var X=j;wa(j)?Wf.call(c,j,1):nv(c,j)}}return c}function ev(c,l){return c+ye(FS()*(l-c+1))}function z$(c,l,b,T){for(var j=-1,X=Wr(ge((l-c)/(b||1)),0),re=me(X);X--;)re[T?X:++j]=c,c+=b;return re}function tv(c,l){var b="";if(!c||l<1||l>K)return b;do l%2&&(b+=c),l=ye(l/2),l&&(c+=c);while(l);return b}function $t(c,l){return wv(S6(c,l,Bs),c+"")}function G$(c){return $S(nl(c))}function W$(c,l){var b=nl(c);return P0(b,Lc(l,0,b.length))}function Yh(c,l,b,T){if(!Ar(c))return c;l=Du(l,c);for(var j=-1,X=l.length,re=X-1,ie=c;ie!=null&&++jj?0:j+l),b=b>j?j:b,b<0&&(b+=j),j=l>b?0:b-l>>>0,l>>>=0;for(var X=me(j);++T>>1,re=c[X];re!==null&&!zs(re)&&(b?re<=l:re=r){var Ie=l?null:uP(c);if(Ie)return fa(Ie);re=!1,j=ca,he=new Nc}else he=l?[]:ie;e:for(;++T=T?c:li(c,l,b)}var e6=W||function(c){return jr.clearTimeout(c)};function t6(c,l){if(l)return c.slice();var b=c.length,T=d0?d0(b):new c.constructor(b);return c.copy(T),T}function av(c){var l=new c.constructor(c.byteLength);return new zf(l).set(new zf(c)),l}function Q$(c,l){var b=l?av(c.buffer):c.buffer;return new c.constructor(b,c.byteOffset,c.byteLength)}function eP(c){var l=new c.constructor(c.source,es.exec(c));return l.lastIndex=c.lastIndex,l}function tP(c){return Kh?Jt(Kh.call(c)):{}}function r6(c,l){var b=l?av(c.buffer):c.buffer;return new c.constructor(b,c.byteOffset,c.length)}function n6(c,l){if(c!==l){var b=c!==e,T=c===null,j=c===c,X=zs(c),re=l!==e,ie=l===null,he=l===l,Ie=zs(l);if(!ie&&!Ie&&!X&&c>l||X&&re&&he&&!ie&&!Ie||T&&re&&he||!b&&he||!j)return 1;if(!T&&!X&&!Ie&&c=ie)return he;var Ie=b[T];return he*(Ie=="desc"?-1:1)}}return c.index-l.index}function s6(c,l,b,T){for(var j=-1,X=c.length,re=b.length,ie=-1,he=l.length,Ie=Wr(X-re,0),$e=me(he+Ie),Te=!T;++ie1?b[j-1]:e,re=j>2?b[2]:e;for(X=c.length>3&&typeof X=="function"?(j--,X):e,re&&us(b[0],b[1],re)&&(X=j<3?e:X,j=1),l=Jt(l);++T-1?j[X?l[re]:re]:e}}function f6(c){return va(function(l){var b=l.length,T=b,j=ci.prototype.thru;for(c&&l.reverse();T--;){var X=l[T];if(typeof X!="function")throw new Cs(i);if(j&&!re&&I0(X)=="wrapper")var re=new ci([],!0)}for(T=re?T:b;++T1&&Nt.reverse(),$e&&heie))return!1;var Ie=X.get(c),$e=X.get(l);if(Ie&&$e)return Ie==l&&$e==c;var Te=-1,je=!0,Je=b&v?new Nc:e;for(X.set(c,l),X.set(l,c);++Te1?"& ":"")+l[T],l=l.join(b>2?", ":" "),c.replace(Xe,`{ /* [wrapped with `+l+`] */ `)}function wP(c){return Ct(c)||Mc(c)||!!(Yf&&c&&c[Yf])}function wa(c,l){var b=typeof c;return l=l??K,!!l&&(b=="number"||b!="symbol"&&wn.test(c))&&c>-1&&c%1==0&&c0){if(++l>=R)return arguments[0]}else l=0;return c.apply(e,arguments)}}function P0(c,l){var b=-1,T=c.length,j=T-1;for(l=l===e?T:l;++b1?c[l-1]:e;return b=typeof b=="function"?(c.pop(),b):e,k6(c,b)});function O6(c){var l=Y(c);return l.__chain__=!0,l}function Ix(c,l){return l(c),c}function x0(c,l){return l(c)}var $x=va(function(c){var l=c.length,b=l?c[0]:0,T=this.__wrapped__,j=function(X){return V2(X,c)};return l>1||this.__actions__.length||!(T instanceof Rt)||!wa(b)?this.thru(j):(T=T.slice(b,+b+(l?1:0)),T.__actions__.push({func:x0,args:[j],thisArg:e}),new ci(T,this.__chain__).thru(function(X){return l&&!X.length&&X.push(e),X}))});function Px(){return O6(this)}function xx(){return new ci(this.value(),this.__chain__)}function Tx(){this.__values__===e&&(this.__values__=X6(this.value()));var c=this.__index__>=this.__values__.length,l=c?e:this.__values__[this.__index__++];return{done:c,value:l}}function Rx(){return this}function kx(c){for(var l,b=this;b instanceof v0;){var T=I6(b);T.__index__=0,T.__values__=e,l?j.__wrapped__=T:l=T;var j=T;b=b.__wrapped__}return j.__wrapped__=c,l}function Ox(){var c=this.__wrapped__;if(c instanceof Rt){var l=c;return this.__actions__.length&&(l=new Rt(this)),l=l.reverse(),l.__actions__.push({func:x0,args:[yv],thisArg:e}),new ci(l,this.__chain__)}return this.thru(yv)}function Nx(){return JS(this.__wrapped__,this.__actions__)}var Lx=C0(function(c,l,b){zt.call(c,b)?++c[b]:mo(c,b,1)});function Ux(c,l,b){var T=Ct(c)?xc:I$;return b&&us(c,l,b)&&(l=e),T(c,ft(l,3))}function Hx(c,l){var b=Ct(c)?Gr:kS;return b(c,ft(l,3))}var qx=c6($6),Mx=c6(P6);function jx(c,l){return bn(T0(c,l),1)}function Kx(c,l){return bn(T0(c,l),k)}function Vx(c,l,b){return b=b===e?1:_t(b),bn(T0(c,l),b)}function N6(c,l){var b=Ct(c)?L:Cu;return b(c,ft(l,3))}function L6(c,l){var b=Ct(c)?St:RS;return b(c,ft(l,3))}var zx=C0(function(c,l,b){zt.call(c,b)?c[b].push(l):mo(c,b,[l])});function Gx(c,l,b,T){c=Ds(c)?c:nl(c),b=b&&!T?_t(b):0;var j=c.length;return b<0&&(b=Wr(j+b,0)),L0(c)?b<=j&&c.indexOf(l,b)>-1:!!j&&bu(c,l,b)>-1}var Wx=$t(function(c,l,b){var T=-1,j=typeof l=="function",X=Ds(c)?me(c.length):[];return Cu(c,function(re){X[++T]=j?is(l,re,b):Gh(re,l,b)}),X}),Yx=C0(function(c,l,b){mo(c,b,l)});function T0(c,l){var b=Ct(c)?sr:qS;return b(c,ft(l,3))}function Xx(c,l,b,T){return c==null?[]:(Ct(l)||(l=l==null?[]:[l]),b=T?e:b,Ct(b)||(b=b==null?[]:[b]),VS(c,l,b))}var Zx=C0(function(c,l,b){c[b?0:1].push(l)},function(){return[[],[]]});function Jx(c,l,b){var T=Ct(c)?r0:$h,j=arguments.length<3;return T(c,ft(l,4),b,j,Cu)}function Qx(c,l,b){var T=Ct(c)?CS:$h,j=arguments.length<3;return T(c,ft(l,4),b,j,RS)}function eT(c,l){var b=Ct(c)?Gr:kS;return b(c,O0(ft(l,3)))}function tT(c){var l=Ct(c)?$S:G$;return l(c)}function rT(c,l,b){(b?us(c,l,b):l===e)?l=1:l=_t(l);var T=Ct(c)?C$:W$;return T(c,l)}function nT(c){var l=Ct(c)?_$:X$;return l(c)}function sT(c){if(c==null)return 0;if(Ds(c))return L0(c)?la(c):c.length;var l=Hn(c);return l==Me||l==wt?c.size:Z2(c).length}function iT(c,l,b){var T=Ct(c)?gr:Z$;return b&&us(c,l,b)&&(l=e),T(c,ft(l,3))}var oT=$t(function(c,l){if(c==null)return[];var b=l.length;return b>1&&us(c,l[0],l[1])?l=[]:b>2&&us(l[0],l[1],l[2])&&(l=[l[0]]),VS(c,bn(l,1),[])}),R0=ne||function(){return jr.Date.now()};function aT(c,l){if(typeof l!="function")throw new Cs(i);return c=_t(c),function(){if(--c<1)return l.apply(this,arguments)}}function U6(c,l,b){return l=b?e:l,l=c&&l==null?c.length:l,ma(c,H,e,e,e,e,l)}function H6(c,l){var b;if(typeof l!="function")throw new Cs(i);return c=_t(c),function(){return--c>0&&(b=l.apply(this,arguments)),c<=1&&(l=e),b}}var bv=$t(function(c,l,b){var T=g;if(b.length){var j=En(b,tl(bv));T|=D}return ma(c,T,l,b,j)}),q6=$t(function(c,l,b){var T=g|y;if(b.length){var j=En(b,tl(q6));T|=D}return ma(l,T,c,b,j)});function M6(c,l,b){l=b?e:l;var T=ma(c,E,e,e,e,e,e,l);return T.placeholder=M6.placeholder,T}function j6(c,l,b){l=b?e:l;var T=ma(c,C,e,e,e,e,e,l);return T.placeholder=j6.placeholder,T}function K6(c,l,b){var T,j,X,re,ie,he,Ie=0,$e=!1,Te=!1,je=!0;if(typeof c!="function")throw new Cs(i);l=di(l)||0,Ar(b)&&($e=!!b.leading,Te="maxWait"in b,X=Te?Wr(di(b.maxWait)||0,l):X,je="trailing"in b?!!b.trailing:je);function Je(Or){var Pi=T,ba=j;return T=j=e,Ie=Or,re=c.apply(ba,Pi),re}function ht(Or){return Ie=Or,ie=Jh(Tt,l),$e?Je(Or):re}function Ft(Or){var Pi=Or-he,ba=Or-Ie,f3=l-Pi;return Te?Un(f3,X-ba):f3}function ct(Or){var Pi=Or-he,ba=Or-Ie;return he===e||Pi>=l||Pi<0||Te&&ba>=X}function Tt(){var Or=R0();if(ct(Or))return Nt(Or);ie=Jh(Tt,Ft(Or))}function Nt(Or){return ie=e,je&&T?Je(Or):(T=j=e,re)}function Gs(){ie!==e&&e6(ie),Ie=0,T=he=j=ie=e}function cs(){return ie===e?re:Nt(R0())}function Ws(){var Or=R0(),Pi=ct(Or);if(T=arguments,j=this,he=Or,Pi){if(ie===e)return ht(he);if(Te)return e6(ie),ie=Jh(Tt,l),Je(he)}return ie===e&&(ie=Jh(Tt,l)),re}return Ws.cancel=Gs,Ws.flush=cs,Ws}var uT=$t(function(c,l){return TS(c,1,l)}),cT=$t(function(c,l,b){return TS(c,di(l)||0,b)});function fT(c){return ma(c,S)}function k0(c,l){if(typeof c!="function"||l!=null&&typeof l!="function")throw new Cs(i);var b=function(){var T=arguments,j=l?l.apply(this,T):T[0],X=b.cache;if(X.has(j))return X.get(j);var re=c.apply(this,T);return b.cache=X.set(j,re)||X,re};return b.cache=new(k0.Cache||ga),b}k0.Cache=ga;function O0(c){if(typeof c!="function")throw new Cs(i);return function(){var l=arguments;switch(l.length){case 0:return!c.call(this);case 1:return!c.call(this,l[0]);case 2:return!c.call(this,l[0],l[1]);case 3:return!c.call(this,l[0],l[1],l[2])}return!c.apply(this,l)}}function lT(c){return H6(2,c)}var hT=J$(function(c,l){l=l.length==1&&Ct(l[0])?sr(l[0],yn(ft())):sr(bn(l,1),yn(ft()));var b=l.length;return $t(function(T){for(var j=-1,X=Un(T.length,b);++j=l}),Mc=LS(function(){return arguments}())?LS:function(c){return Fr(c)&&zt.call(c,"callee")&&!ir.call(c,"callee")},Ct=me.isArray,FT=Xp?yn(Xp):k$;function Ds(c){return c!=null&&N0(c.length)&&!ya(c)}function kr(c){return Fr(c)&&Ds(c)}function BT(c){return c===!0||c===!1||Fr(c)&&as(c)==Oe}var Bu=Rr||Rv,IT=Zp?yn(Zp):O$;function $T(c){return Fr(c)&&c.nodeType===1&&!Qh(c)}function PT(c){if(c==null)return!0;if(Ds(c)&&(Ct(c)||typeof c=="string"||typeof c.splice=="function"||Bu(c)||rl(c)||Mc(c)))return!c.length;var l=Hn(c);if(l==Me||l==wt)return!c.size;if(Zh(c))return!Z2(c).length;for(var b in c)if(zt.call(c,b))return!1;return!0}function xT(c,l){return Wh(c,l)}function TT(c,l,b){b=typeof b=="function"?b:e;var T=b?b(c,l):e;return T===e?Wh(c,l,e,b):!!T}function Sv(c){if(!Fr(c))return!1;var l=as(c);return l==Re||l==Se||typeof c.message=="string"&&typeof c.name=="string"&&!Qh(c)}function RT(c){return typeof c=="number"&&DS(c)}function ya(c){if(!Ar(c))return!1;var l=as(c);return l==Ke||l==Qe||l==Le||l==yr}function z6(c){return typeof c=="number"&&c==_t(c)}function N0(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=K}function Ar(c){var l=typeof c;return c!=null&&(l=="object"||l=="function")}function Fr(c){return c!=null&&typeof c=="object"}var G6=Jp?yn(Jp):L$;function kT(c,l){return c===l||X2(c,l,dv(l))}function OT(c,l,b){return b=typeof b=="function"?b:e,X2(c,l,dv(l),b)}function NT(c){return W6(c)&&c!=+c}function LT(c){if(bP(c))throw new pt(n);return US(c)}function UT(c){return c===null}function HT(c){return c==null}function W6(c){return typeof c=="number"||Fr(c)&&as(c)==yt}function Qh(c){if(!Fr(c)||as(c)!=vt)return!1;var l=Gf(c);if(l===null)return!0;var b=zt.call(l,"constructor")&&l.constructor;return typeof b=="function"&&b instanceof b&&ha.call(b)==U2}var Cv=Qp?yn(Qp):U$;function qT(c){return z6(c)&&c>=-K&&c<=K}var Y6=e0?yn(e0):H$;function L0(c){return typeof c=="string"||!Ct(c)&&Fr(c)&&as(c)==Pr}function zs(c){return typeof c=="symbol"||Fr(c)&&as(c)==Rn}var rl=t0?yn(t0):q$;function MT(c){return c===e}function jT(c){return Fr(c)&&Hn(c)==It}function KT(c){return Fr(c)&&as(c)==tt}var VT=B0(J2),zT=B0(function(c,l){return c<=l});function X6(c){if(!c)return[];if(Ds(c))return L0(c)?os(c):_s(c);if(kc&&c[kc])return T2(c[kc]());var l=Hn(c),b=l==Me?cn:l==wt?fa:nl;return b(c)}function Ea(c){if(!c)return c===0?c:0;if(c=di(c),c===k||c===-k){var l=c<0?-1:1;return l*Z}return c===c?c:0}function _t(c){var l=Ea(c),b=l%1;return l===l?b?l-b:l:0}function Z6(c){return c?Lc(_t(c),0,ee):0}function di(c){if(typeof c=="number")return c;if(zs(c))return G;if(Ar(c)){var l=typeof c.valueOf=="function"?c.valueOf():c;c=Ar(l)?l+"":l}if(typeof c!="string")return c===0?c:+c;c=Th(c);var b=vn.test(c);return b||Cr.test(c)?F2(c.slice(2),b?2:8):oi.test(c)?G:+c}function J6(c){return wo(c,Fs(c))}function GT(c){return c?Lc(_t(c),-K,K):c===0?c:0}function Qt(c){return c==null?"":Vs(c)}var WT=Qf(function(c,l){if(Zh(l)||Ds(l)){wo(l,fn(l),c);return}for(var b in l)zt.call(l,b)&&Vh(c,b,l[b])}),Q6=Qf(function(c,l){wo(l,Fs(l),c)}),e3=Qf(function(c,l,b,T){wo(l,Fs(l),c,T)}),_v=Qf(function(c,l,b,T){wo(l,fn(l),c,T)}),YT=va(V2);function XT(c,l){var b=Jf(c);return l==null?b:PS(b,l)}var ZT=$t(function(c,l){c=Jt(c);var b=-1,T=l.length,j=T>2?l[2]:e;for(j&&us(l[0],l[1],j)&&(T=1);++b1),X}),wo(c,lv(c),b),T&&(b=fi(b,h|m|p,cP));for(var j=l.length;j--;)nv(b,l[j]);return b});function gR(c,l){return r3(c,O0(ft(l)))}var mR=va(function(c,l){return c==null?{}:K$(c,l)});function r3(c,l){if(c==null)return{};var b=sr(lv(c),function(T){return[T]});return l=ft(l),zS(c,b,function(T,j){return l(T,j[0])})}function vR(c,l,b){l=Du(l,c);var T=-1,j=l.length;for(j||(j=1,c=e);++Tl){var T=c;c=l,l=T}if(b||c%1||l%1){var j=FS();return Un(c+j*(l-c+D2("1e-"+((j+"").length-1))),l)}return ev(c,l)}var BR=el(function(c,l,b){return l=l.toLowerCase(),c+(b?i3(l):l)});function i3(c){return Bv(Qt(c).toLowerCase())}function o3(c){return c=Qt(c),c&&c.replace(On,$2).replace(ss,"")}function IR(c,l,b){c=Qt(c),l=Vs(l);var T=c.length;b=b===e?T:Lc(_t(b),0,T);var j=b;return b-=l.length,b>=0&&c.slice(b,j)==l}function $R(c){return c=Qt(c),c&&bs.test(c)?c.replace(ii,o0):c}function PR(c){return c=Qt(c),c&&_c.test(c)?c.replace(na,"\\$&"):c}var xR=el(function(c,l,b){return c+(b?"-":"")+l.toLowerCase()}),TR=el(function(c,l,b){return c+(b?" ":"")+l.toLowerCase()}),RR=u6("toLowerCase");function kR(c,l,b){c=Qt(c),l=_t(l);var T=l?la(c):0;if(!l||T>=l)return c;var j=(l-T)/2;return F0(ye(j),b)+c+F0(ge(j),b)}function OR(c,l,b){c=Qt(c),l=_t(l);var T=l?la(c):0;return l&&T>>0,b?(c=Qt(c),c&&(typeof l=="string"||l!=null&&!Cv(l))&&(l=Vs(l),!l&&Su(c))?Fu(os(c),0,b):c.split(l,b)):[]}var jR=el(function(c,l,b){return c+(b?" ":"")+Bv(l)});function KR(c,l,b){return c=Qt(c),b=b==null?0:Lc(_t(b),0,c.length),l=Vs(l),c.slice(b,b+l.length)==l}function VR(c,l,b){var T=Y.templateSettings;b&&us(c,l,b)&&(l=e),c=Qt(c),l=_v({},l,T,g6);var j=_v({},l.imports,T.imports,g6),X=fn(j),re=Rh(j,X);L(X,function(ct){if(At.test(ct))throw new pt(s)});var ie,he,Ie=0,$e=l.interpolate||lo,Te="__p += '",je=Uh((l.escape||lo).source+"|"+$e.source+"|"+($e===ra?rr:lo).source+"|"+(l.evaluate||lo).source+"|$","g"),Je="//# sourceURL="+(zt.call(l,"sourceURL")?(l.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++b2+"]")+` `;c.replace(je,function(ct,Tt,Nt,Gs,cs,Ws){return Nt||(Nt=Gs),Te+=c.slice(Ie,Ws).replace(Dc,P2),Tt&&(ie=!0,Te+=`' + __e(`+Tt+`) + '`),cs&&(he=!0,Te+=`'; `+cs+`; __p += '`),Nt&&(Te+=`' + ((__t = (`+Nt+`)) == null ? '' : __t) + '`),Ie=Ws+ct.length,ct}),Te+=`'; `;var ht=zt.call(l,"variable")&&l.variable;if(!ht)Te=`with (obj) { `+Te+` } `;else if(At.test(ht))throw new pt(o);Te=(he?Te.replace(mu,""):Te).replace(uo,"$1").replace(Ac,"$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 Ft=u3(function(){return Ot(X,Je+"return "+Te).apply(e,re)});if(Ft.source=Te,Sv(Ft))throw Ft;return Ft}function zR(c){return Qt(c).toLowerCase()}function GR(c){return Qt(c).toUpperCase()}function WR(c,l,b){if(c=Qt(c),c&&(b||l===e))return Th(c);if(!c||!(l=Vs(l)))return c;var T=os(c),j=os(l),X=i0(T,j),re=kh(T,j)+1;return Fu(T,X,re).join("")}function YR(c,l,b){if(c=Qt(c),c&&(b||l===e))return c.slice(0,Nh(c)+1);if(!c||!(l=Vs(l)))return c;var T=os(c),j=kh(T,os(l))+1;return Fu(T,0,j).join("")}function XR(c,l,b){if(c=Qt(c),c&&(b||l===e))return c.replace(ue,"");if(!c||!(l=Vs(l)))return c;var T=os(c),j=i0(T,os(l));return Fu(T,j).join("")}function ZR(c,l){var b=I,T=U;if(Ar(l)){var j="separator"in l?l.separator:j;b="length"in l?_t(l.length):b,T="omission"in l?Vs(l.omission):T}c=Qt(c);var X=c.length;if(Su(c)){var re=os(c);X=re.length}if(b>=X)return c;var ie=b-la(T);if(ie<1)return T;var he=re?Fu(re,0,ie).join(""):c.slice(0,ie);if(j===e)return he+T;if(re&&(ie+=he.length-ie),Cv(j)){if(c.slice(ie).search(j)){var Ie,$e=he;for(j.global||(j=Uh(j.source,Qt(es.exec(j))+"g")),j.lastIndex=0;Ie=j.exec($e);)var Te=Ie.index;he=he.slice(0,Te===e?ie:Te)}}else if(c.indexOf(Vs(j),ie)!=ie){var je=he.lastIndexOf(j);je>-1&&(he=he.slice(0,je))}return he+T}function JR(c){return c=Qt(c),c&&Vt.test(c)?c.replace(co,f0):c}var QR=el(function(c,l,b){return c+(b?" ":"")+l.toUpperCase()}),Bv=u6("toUpperCase");function a3(c,l,b){return c=Qt(c),l=b?e:l,l===e?x2(c)?N2(c):ut(c):c.match(l)||[]}var u3=$t(function(c,l){try{return is(c,e,l)}catch(b){return Sv(b)?b:new pt(b)}}),ek=va(function(c,l){return L(l,function(b){b=Ii(b),mo(c,b,bv(c[b],c))}),c});function tk(c){var l=c==null?0:c.length,b=ft();return c=l?sr(c,function(T){if(typeof T[1]!="function")throw new Cs(i);return[b(T[0]),T[1]]}):[],$t(function(T){for(var j=-1;++jK)return[];var b=ee,T=Un(c,ee);l=ft(l),c-=ee;for(var j=xh(T,l);++b0||l<0)?new Rt(b):(c<0?b=b.takeRight(-c):c&&(b=b.drop(c)),l!==e&&(l=_t(l),b=l<0?b.dropRight(-l):b.take(l-c)),b)},Rt.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},Rt.prototype.toArray=function(){return this.take(ee)},vo(Rt.prototype,function(c,l){var b=/^(?:filter|find|map|reject)|While$/.test(l),T=/^(?:head|last)$/.test(l),j=Y[T?"take"+(l=="last"?"Right":""):l],X=T||/^find/.test(l);j&&(Y.prototype[l]=function(){var re=this.__wrapped__,ie=T?[1]:arguments,he=re instanceof Rt,Ie=ie[0],$e=he||Ct(re),Te=function(Tt){var Nt=j.apply(Y,po([Tt],ie));return T&&je?Nt[0]:Nt};$e&&b&&typeof Ie=="function"&&Ie.length!=1&&(he=$e=!1);var je=this.__chain__,Je=!!this.__actions__.length,ht=X&&!je,Ft=he&&!Je;if(!X&&$e){re=Ft?re:new Rt(this);var ct=c.apply(re,ie);return ct.__actions__.push({func:x0,args:[Te],thisArg:e}),new ci(ct,je)}return ht&&Ft?c.apply(this,ie):(ct=this.thru(Te),ht?T?ct.value()[0]:ct.value():ct)})}),L(["pop","push","shift","sort","splice","unshift"],function(c){var l=Rc[c],b=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",T=/^(?:pop|shift)$/.test(c);Y.prototype[c]=function(){var j=arguments;if(T&&!this.__chain__){var X=this.value();return l.apply(Ct(X)?X:[],j)}return this[b](function(re){return l.apply(Ct(re)?re:[],j)})}}),vo(Rt.prototype,function(c,l){var b=Y[l];if(b){var T=b.name+"";zt.call(Zf,T)||(Zf[T]=[]),Zf[T].push({name:l,func:b})}}),Zf[_0(e,y).name]=[{name:"wrapper",func:e}],Rt.prototype.clone=Q7,Rt.prototype.reverse=e$,Rt.prototype.value=t$,Y.prototype.at=$x,Y.prototype.chain=Px,Y.prototype.commit=xx,Y.prototype.next=Tx,Y.prototype.plant=kx,Y.prototype.reverse=Ox,Y.prototype.toJSON=Y.prototype.valueOf=Y.prototype.value=Nx,Y.prototype.first=Y.prototype.head,kc&&(Y.prototype[kc]=Rx),Y},Fi=Lh();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(jr._=Fi,define(function(){return Fi})):aa?((aa.exports=Fi)._=Fi,_h._=Fi):jr._=Fi}).call(ch)});var e2=Ce((Yme,e9)=>{"use strict";var Xme=P(x()),zX=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])},LA=class e extends Error{constructor(t,r,n){super(t),zX(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="",f=r.find(({source:m})=>m===o.source),h=o.start;if(f){let m=o.end,p=f.text[h.line-1],v=(h.line===m.line?m.column:p.length+1)-h.column||1;a&&(u+=` note: ${a}`),u+=` --> ${o.source}:${h.line}:${h.column} ${"".padEnd(s)} | ${h.line.toString().padStart(s)} | ${p} ${"".padEnd(s)} | ${"".padEnd(h.column-1)}${"".padEnd(v,"^")}`}else u+=` at ${o.source}:${h.line}:${h.column}`,a&&(u+=`: ${a}`);return u}function i(o,s,a,u=[]){let f;a?f=u.reduce((m,{location:p})=>Math.max(m,p.start.line),a.start.line):f=Math.max.apply(null,u.map(m=>m.location.start.line)),f=f.toString().length;let h=`${o}: ${s}`;a&&(h+=n(a,f));for(let m of u)h+=n(m.location,f,m.message);return h}return this.problems.filter(o=>o[0]!=="info").map(o=>i(...o)).join(` `)}};e9.exports=LA});var Si=Ce((Zme,t9)=>{"use strict";var Jme=P(x()),GX={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(f=>t(f,...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}};t9.exports=GX});var wc=Ce((Qme,n9)=>{"use strict";var e2e=P(x()),WX=Si(),r9={findRule(e,t){for(let r=0;r{"use strict";var r2e=P(x()),YX={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};s9.exports=YX});var HA=Ce((n2e,i9)=>{"use strict";var s2e=P(x()),XX=Si(),ZX=wc(),JX=e2(),Up=1,Lf=0,Hp=-1;function t2(e){function t(s){return s.match=Lf}function r(s){return o(s.expression),s.match=Up}function n(s){return s.match=o(s.expression)}function i(s,a){let u=s.length,f=0,h=0;for(let m=0;m0?Hp:Lf}let o=XX.build({rule(s){let a,u=0;if(typeof s.match>"u"){s.match=Lf;do if(a=s.match,s.match=o(s.expression),++u>6)throw new JX("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=ZX.findRule(e,s.name);return s.match=o(a)},literal(s){let a=s.value.length===0?Up:Lf;return s.match=a},class(s){let a=s.parts.length===0?Hp:Lf;return s.match=a},any:t});o(e)}t2.ALWAYS_MATCH=Up;t2.SOMETIMES_MATCH=Lf;t2.NEVER_MATCH=Hp;i9.exports=t2});var a9=Ce((i2e,o9)=>{"use strict";var o2e=P(x()),QX=wc(),Ge=UA(),eZ=Si(),{ALWAYS_MATCH:yh,SOMETIMES_MATCH:qA,NEVER_MATCH:MA}=HA();function tZ(e){let t=[],r=[],n=[],i=[];function o(E){let C=t.indexOf(E);return C===-1?t.push(E)-1:C}function s(E){let C={value:E.parts,inverted:E.inverted,ignoreCase:E.ignoreCase},D=JSON.stringify(C),B=r.findIndex(H=>JSON.stringify(H)===D);return B===-1?r.push(C)-1:B}function a(E){let C=JSON.stringify(E),D=n.findIndex(B=>JSON.stringify(B)===C);return D===-1?n.push(E)-1:D}function u(E,C,D){let B={predicate:E,params:C,body:D.code,location:D.codeLocation},H=JSON.stringify(B),V=i.findIndex(S=>JSON.stringify(S)===H);return V===-1?i.push(B)-1:V}function f(E){let C={};return Object.keys(E).forEach(D=>{C[D]=E[D]}),C}function h(E,...C){return E.concat(...C)}function m(E,C,D,B){return E===yh?D:E===MA?B:C.concat([D.length,B.length],D,B)}function p(E,C){return E.concat([C.length],C)}function d(E,C,D,B){let H=Object.keys(D).map(V=>B-D[V]);return[Ge.CALL,E,C,H.length].concat(H)}function v(E,C,D){let B=E.match|0;return h([Ge.PUSH_CURR_POS],[Ge.SILENT_FAILS_ON],w(E,{sp:D.sp+1,env:f(D.env),action:null}),[Ge.SILENT_FAILS_OFF],m(C?-B:B,[C?Ge.IF_ERROR:Ge.IF_NOT_ERROR],h([Ge.POP],[C?Ge.POP:Ge.POP_CURR_POS],[Ge.PUSH_UNDEFINED]),h([Ge.POP],[C?Ge.POP_CURR_POS:Ge.POP],[Ge.PUSH_FAILED])))}function g(E,C,D){let B=u(!0,Object.keys(D.env),E);return h([Ge.UPDATE_SAVED_POS],d(B,0,D.env,D.sp),m(E.match|0,[Ge.IF],h([Ge.POP],C?[Ge.PUSH_FAILED]:[Ge.PUSH_UNDEFINED]),h([Ge.POP],C?[Ge.PUSH_UNDEFINED]:[Ge.PUSH_FAILED])))}function y(E){return p([Ge.WHILE_NOT_ERROR],h([Ge.APPEND],E))}let w=eZ.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,C){let D=E.match|0,B=D===MA?null:a({type:"rule",value:E.name});return h([Ge.SILENT_FAILS_ON],w(E.expression,C),[Ge.SILENT_FAILS_OFF],m(D,[Ge.IF_ERROR],[Ge.FAIL,B],[]))},choice(E,C){function D(B,H){let V=B[0].match|0,S=w(B[0],{sp:H.sp,env:f(H.env),action:null});return V===yh?S:h(S,B.length>1?m(qA,[Ge.IF_ERROR],h([Ge.POP],D(B.slice(1),H)),[]):[])}return D(E.alternatives,C)},action(E,C){let D=f(C.env),B=E.expression.type!=="sequence"||E.expression.elements.length===0,H=w(E.expression,{sp:C.sp+(B?1:0),env:D,action:E}),V=E.expression.match|0,S=B&&V!==MA?u(!1,Object.keys(D),E):null;return B?h([Ge.PUSH_CURR_POS],H,m(V,[Ge.IF_NOT_ERROR],h([Ge.LOAD_SAVED_POS,1],d(S,1,D,C.sp+2)),[]),[Ge.NIP]):H},sequence(E,C){function D(B,H){if(B.length>0){let V=E.elements.length-B.length+1;return h(w(B[0],{sp:H.sp,env:H.env,pluck:H.pluck,action:null}),m(B[0].match|0,[Ge.IF_NOT_ERROR],D(B.slice(1),{sp:H.sp+1,env:H.env,pluck:H.pluck,action:H.action}),h(V>1?[Ge.POP_N,V]:[Ge.POP],[Ge.POP_CURR_POS],[Ge.PUSH_FAILED])))}else{if(H.pluck.length>0)return h([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 h([Ge.LOAD_SAVED_POS,E.elements.length],d(V,E.elements.length+1,H.env,H.sp))}else return h([Ge.WRAP,E.elements.length],[Ge.NIP])}}return h([Ge.PUSH_CURR_POS],D(E.elements,{sp:C.sp+1,env:C.env,pluck:[],action:C.action}))},labeled(E,C){let D=C.env,B=E.label,H=C.sp+1;return B&&(D=f(C.env),C.env[E.label]=H),E.pick&&C.pluck.push(H),w(E.expression,{sp:C.sp,env:D,action:null})},text(E,C){return h([Ge.PUSH_CURR_POS],w(E.expression,{sp:C.sp+1,env:f(C.env),action:null}),m(E.match|0,[Ge.IF_NOT_ERROR],h([Ge.POP],[Ge.TEXT]),[Ge.NIP]))},simple_and(E,C){return v(E.expression,!1,C)},simple_not(E,C){return v(E.expression,!0,C)},optional(E,C){return h(w(E.expression,{sp:C.sp,env:f(C.env),action:null}),m(-(E.expression.match|0),[Ge.IF_ERROR],h([Ge.POP],[Ge.PUSH_NULL]),[]))},zero_or_more(E,C){let D=w(E.expression,{sp:C.sp+1,env:f(C.env),action:null});return h([Ge.PUSH_EMPTY_ARRAY],D,y(D),[Ge.POP])},one_or_more(E,C){let D=w(E.expression,{sp:C.sp+1,env:f(C.env),action:null});return h([Ge.PUSH_EMPTY_ARRAY],D,m(E.expression.match|0,[Ge.IF_NOT_ERROR],h(y(D),[Ge.POP]),h([Ge.POP],[Ge.POP],[Ge.PUSH_FAILED])))},group(E,C){return w(E.expression,{sp:C.sp,env:f(C.env),action:null})},semantic_and(E,C){return g(E,!1,C)},semantic_not(E,C){return g(E,!0,C)},rule_ref(E){return[Ge.RULE,QX.indexOfRule(e,E.name)]},literal(E){if(E.value.length>0){let C=E.match|0,B=C===qA||C===yh&&!E.ignoreCase?o(E.ignoreCase?E.value.toLowerCase():E.value):null,H=C!==yh?a({type:"literal",value:E.value,ignoreCase:E.ignoreCase}):null;return m(C,E.ignoreCase?[Ge.MATCH_STRING_IC,B]:[Ge.MATCH_STRING,B],E.ignoreCase?[Ge.ACCEPT_N,E.value.length]:[Ge.ACCEPT_STRING,B],[Ge.FAIL,H])}return[Ge.PUSH_EMPTY_STRING]},class(E){let C=E.match|0,D=C===qA?s(E):null,B=C!==yh?a({type:"class",value:E.parts,inverted:E.inverted,ignoreCase:E.ignoreCase}):null;return m(C,[Ge.MATCH_CHAR_CLASS,D],[Ge.ACCEPT_N,1],[Ge.FAIL,B])},any(E){let C=E.match|0,D=C!==yh?a({type:"any"}):null;return m(C,[Ge.MATCH_ANY],[Ge.ACCEPT_N,1],[Ge.FAIL,D])}});w(e)}o9.exports=tZ});var c9=Ce((a2e,u9)=>{"use strict";var u2e=P(x()),jA=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+").")}};u9.exports=jA});var KA=Ce((c2e,f9)=>{"use strict";var f2e=P(x());f9.exports="2.0.1"});var l9=Ce(r2=>{"use strict";var h2e=P(x());function pu(e){return e.charCodeAt(0).toString(16).toUpperCase()}r2.hex=pu;function rZ(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"+pu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+pu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+pu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+pu(t))}r2.stringEscape=rZ;function nZ(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"+pu(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+pu(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+pu(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+pu(t))}r2.regexpClassEscape=nZ});var p9=Ce(d9=>{var p2e=P(x()),h9="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");d9.encode=function(e){if(0<=e&&e{var m2e=P(x()),sZ=p9(),g9=5,m9=1<>>=g9,i>0&&(n|=oZ),r+=sZ.encode(n);while(i>0);return r}});var s2=Ce(Ec=>{var w2e=P(x());function uZ(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}Ec.getArg=uZ;var E9=function(){return!("__proto__"in Object.create(null))}();function b9(e){return e}function cZ(e){return A9(e)?"$"+e:e}Ec.toSetString=E9?b9:cZ;function fZ(e){return A9(e)?e.slice(1):e}Ec.fromSetString=E9?b9:fZ;function A9(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 y9(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function lZ(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=y9(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:y9(e.name,t.name)}Ec.compareByGeneratedPositionsInflated=lZ;var VA="http:",qp=`${VA}//host`;function S9(e){return t=>{let r=Mp(t),n=zA(t),i=new URL(t,n);e(i);let o=i.toString();return r==="absolute"?o:r==="scheme-relative"?o.slice(VA.length):r==="path-absolute"?o.slice(qp.length):GA(n,o)}}function yc(e,t){return new URL(e,t).toString()}function hZ(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function zA(e){let t=e.split("..").length-1,r=hZ("p",e),n=`${qp}/`;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 pZ=S9(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),n2=S9(e=>{});Ec.normalize=n2;function gZ(e,t){let r=Mp(t),n=Mp(e);if(e=pZ(e),r==="absolute")return yc(t,void 0);if(n==="absolute")return yc(t,e);if(r==="scheme-relative")return n2(t);if(n==="scheme-relative")return yc(t,yc(e,qp)).slice(VA.length);if(r==="path-absolute")return n2(t);if(n==="path-absolute")return yc(t,yc(e,qp)).slice(qp.length);let i=zA(t+e),o=yc(t,yc(e,i));return GA(i,o)}Ec.join=gZ;function mZ(e,t){let r=vZ(e,t);return typeof r=="string"?r:n2(t)}Ec.relative=mZ;function vZ(e,t){if(Mp(e)!==Mp(t))return null;let n=zA(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:GA(i,o)}});var _9=Ce(C9=>{var E2e=P(x()),WA=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 A2e=P(x()),D9=s2();function wZ(e,t){let r=e.generatedLine,n=t.generatedLine,i=e.generatedColumn,o=t.generatedColumn;return n>r||n==r&&o>=i||D9.compareByGeneratedPositionsInflated(e,t)<=0}var YA=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){wZ(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(D9.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};F9.MappingList=YA});var XA=Ce(I9=>{var C2e=P(x()),jp=w9(),zr=s2(),i2=_9().ArraySet,yZ=B9().MappingList,o2=class e{constructor(t){t||(t={}),this._file=zr.getArg(t,"file",null),this._sourceRoot=zr.getArg(t,"sourceRoot",null),this._skipValidation=zr.getArg(t,"skipValidation",!1),this._sources=new i2,this._names=new i2,this._mappings=new yZ,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=zr.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=zr.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=zr.getArg(t,"generated"),n=zr.getArg(t,"original",null),i=zr.getArg(t,"source",null),o=zr.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=zr.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[zr.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[zr.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=zr.relative(o,i));let s=this._mappings.toArray().length>0?new i2:this._sources,a=new i2;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=zr.join(n,u.source)),o!=null&&(u.source=zr.relative(o,u.source)),u.originalLine=m.line,u.originalColumn=m.column,m.name!=null&&(u.name=m.name))}let f=u.source;f!=null&&!s.has(f)&&s.add(f);let h=u.name;h!=null&&!a.has(h)&&a.add(h)},this),this._sources=s,this._names=a,t.sources.forEach(function(u){let f=t.sourceContentFor(u);f!=null&&(n!=null&&(u=zr.join(n,u)),o!=null&&(u=zr.relative(o,u)),this.setSourceContent(u,f))},this)}_validateMapping(t,r,n,i){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!i)){if(!(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:i}))}}_serializeMappings(){let t=0,r=1,n=0,i=0,o=0,s=0,a="",u,f,h,m,p=this._mappings.toArray();for(let d=0,v=p.length;d0){if(!zr.compareByGeneratedPositionsInflated(f,p[d-1]))continue;u+=","}u+=jp.encode(f.generatedColumn-t),t=f.generatedColumn,f.source!=null&&(m=this._sources.indexOf(f.source),u+=jp.encode(m-s),s=m,u+=jp.encode(f.originalLine-1-i),i=f.originalLine-1,u+=jp.encode(f.originalColumn-n),n=f.originalColumn,f.name!=null&&(h=this._names.indexOf(f.name),u+=jp.encode(h-o),o=h)),a+=u}return a}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=zr.relative(r,n));let i=zr.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;I9.SourceMapGenerator=o2});var P9=Ce($9=>{var D2e=P(x()),EZ=XA().SourceMapGenerator,a2=s2(),bZ=/(\r?\n)/,AZ=10,Eh="$$$isSourceNode$$$",ZA=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[Eh]=!0,i!=null&&this.add(i)}static fromStringWithSourceMap(t,r,n){let i=new e,o=t.split(bZ),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[Eh]||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 B2e=P(x());JA.SourceMapGenerator=XA().SourceMapGenerator;JA.SourceNode=P9().SourceNode});var O9=Ce((I2e,k9)=>{"use strict";var $2e=P(x()),SZ=wc(),Xt=UA(),CZ=c9(),_Z=KA(),{stringEscape:si,regexpClassEscape:QA}=l9(),{SourceNode:Ci}=x9();function R9(e,t,r){let n=t.start.line,i=t.start.column-1,o=e.split(` `);return o.length===1?new Ci(n,i,t.source,e,r):new Ci(null,null,t.source,o.map((s,a)=>new Ci(n+a,a===0?i:0,t.source,a===o.length-1?s:[s,` `],r)))}function T9(e,t,r,n,i){return r?new Ci(null,null,r.source,[e,R9(t,r,i),new Ci(r.end.line,r.end.column-1,r.source,n)]):new Ci(null,null,null,[e,t,n])}function DZ(e,t){function r(g){return g instanceof Ci?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(C){return'"'+si(C)+'"'}function y(C){return"/^["+(C.inverted?"^":"")+C.value.map(D=>Array.isArray(D)?QA(D[0])+"-"+QA(D[1]):QA(D)).join("")+"]/"+(C.ignoreCase?"i":"")}function w(C){switch(C.type){case"rule":return'peg$otherExpectation("'+si(C.value)+'")';case"literal":return'peg$literalExpectation("'+si(C.value)+'", '+C.ignoreCase+")";case"class":return"peg$classExpectation(["+C.value.map(B=>Array.isArray(B)?'["'+si(B[0])+'", "'+si(B[1])+'"]':'"'+si(B)+'"').join(", ")+"], "+C.inverted+", "+C.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(C)+")")}}function E(C,D){return T9(` var ${s(D)} = function(${C.params.join(", ")}) {`,C.body,C.location,"};")}return new Ci(null,null,t.grammarSource,[e.literals.map((C,D)=>" var "+n(D)+" = "+g(C)+";").concat("",e.classes.map((C,D)=>" var "+i(D)+" = "+y(C)+";")).concat("",e.expectations.map((C,D)=>" var "+o(D)+" = "+w(C)+";")).concat("").join(` `),e.functions.map(E)])}function f(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 h(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 CZ(g.name,"s","var");function E(D){let B=0,H=D.length,V=[],S;function I(O,q){let N=q+3,_=D[B+N-2],k=D[B+N-1],K,Z;w.checkedIf(B,()=>{B+=N,K=E(D.slice(B,B+_)),B+=_},k>0?()=>{Z=E(D.slice(B,B+k)),B+=k}:null),V.push("if ("+O+") {"),V.push(...K.map(r)),k>0&&(V.push("} else {"),V.push(...Z.map(r))),V.push("}")}function U(O){let N=D[B+2-1],_;w.checkedLoop(B,()=>{B+=2,_=E(D.slice(B,B+N)),B+=N}),V.push("while ("+O+") {"),V.push(..._.map(r)),V.push("}")}function R(){let q=D[B+4-1],N=s(D[B+1])+"("+D.slice(B+4,B+4+q).map(_=>w.index(_)).join(", ")+")";w.pop(D[B+2]),V.push(w.push(N)),B+=4+q}for(;Bw.index(_)).join(", ")} ]`,w.pop(D[B+1]),V.push(w.push(S)),B+=N;break}case Xt.IF:I(w.top(),0);break;case Xt.IF_ERROR:I(w.top()+" === peg$FAILED",0);break;case Xt.IF_NOT_ERROR:I(w.top()+" !== peg$FAILED",0);break;case Xt.WHILE_NOT_ERROR:U(w.top()+" !== peg$FAILED");break;case Xt.MATCH_ANY:I("input.length > peg$currPos",0);break;case Xt.MATCH_STRING:I(e.literals[D[B+1]].length>1?"input.substr(peg$currPos, "+e.literals[D[B+1]].length+") === "+n(D[B+1]):"input.charCodeAt(peg$currPos) === "+e.literals[D[B+1]].charCodeAt(0),1);break;case Xt.MATCH_STRING_IC:I("input.substr(peg$currPos, "+e.literals[D[B+1]].length+").toLowerCase() === "+n(D[B+1]),1);break;case Xt.MATCH_CHAR_CLASS:I(i(D[B+1])+".test(input.charAt(peg$currPos))",1);break;case Xt.ACCEPT_N:V.push(w.push(D[B+1]>1?"input.substr(peg$currPos, "+D[B+1]+")":"input.charAt(peg$currPos)")),V.push(D[B+1]>1?"peg$currPos += "+D[B+1]+";":"peg$currPos++;"),B+=2;break;case Xt.ACCEPT_STRING:V.push(w.push(n(D[B+1]))),V.push(e.literals[D[B+1]].length>1?"peg$currPos += "+e.literals[D[B+1]].length+";":"peg$currPos++;"),B+=2;break;case Xt.FAIL:V.push(w.push("peg$FAILED")),V.push("if (peg$silentFails === 0) { peg$fail("+o(D[B+1])+"); }"),B+=2;break;case Xt.LOAD_SAVED_POS:V.push("peg$savedPos = "+w.index(D[B+1])+";"),B+=2;break;case Xt.UPDATE_SAVED_POS:V.push("peg$savedPos = peg$currPos;"),B++;break;case Xt.CALL:R();break;case Xt.RULE:V.push(w.push(a(e.rules[D[B+1]].name)+"()")),B+=2;break;case Xt.SILENT_FAILS_ON:V.push("peg$silentFails++;"),B++;break;case Xt.SILENT_FAILS_OFF:V.push("peg$silentFails--;"),B++;break;default:throw new Error("Invalid opcode: "+D[B]+".")}return V}let C=E(g.bytecode);return y.push(T9(" function ",a(g.name),g.nameLocation,`() { `,g.name)),t.trace&&y.push(" var startPos = peg$currPos;"),y.push(r(w.defines())),y.push(...f('"'+si(g.name)+'"',SZ.indexOfRule(e,g.name)).map(r)),y.push(...C.map(r)),y.push(...h('"'+si(g.name)+'"',w.result()).map(r)),y.push("}"),y}function p(g){return g.codeLocation?R9(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 Ci(null,null,t.grammarSource,g.map(E=>E instanceof Ci?E:E+` `))}function v(g){function y(){return[`// Generated by Peggy ${_Z}.`,"//","// 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 C={bare(){return[...y(),"(function() {",' "use strict";',"",g,"",r("return "+w()+";"),"})()"]},commonjs(){let D=Object.keys(t.dependencies),B=y();return B.push("",'"use strict";',""),D.length>0&&(D.forEach(H=>{B.push("var "+H+' = require("'+si(t.dependencies[H])+'");')}),B.push("")),B.push(g,"","module.exports = "+w()+";"),B},es(){let D=Object.keys(t.dependencies),B=y();return B.push(""),D.length>0&&(D.forEach(H=>{B.push("import "+H+' from "'+si(t.dependencies[H])+'";')}),B.push("")),B.push(g,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),B},amd(){let D=Object.keys(t.dependencies),H="["+D.map(S=>t.dependencies[S]).map(S=>'"'+si(S)+'"').join(", ")+"]",V=D.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 D=Object.keys(t.dependencies),B=D.map(U=>t.dependencies[U]),H="["+B.map(U=>'"'+si(U)+'"').join(", ")+"]",V=B.map(U=>'require("'+si(U)+'")').join(", "),S=D.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("+S+") {",' "use strict";',"",g,"",r("return "+w()+";"),"});"),I}}[t.format]();return new Ci(null,null,t.grammarSource,C.map(D=>D instanceof Ci?D:D+` `))}e.code=v(d())}k9.exports=DZ});var L9=Ce((P2e,N9)=>{"use strict";var x2e=P(x()),FZ=wc(),BZ=Si();function IZ(e,t,r){function n(s){return s.type==="rule"&&s.expression.type==="rule_ref"}function i(s,a,u){BZ.build({rule_ref(h){h.name===a&&(h.name=u,r.info(`Proxy rule "${a}" replaced by the rule "${u}"`,h.location,[{message:"This rule will be used",location:FZ.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)})}N9.exports=IZ});var H9=Ce((T2e,U9)=>{"use strict";var R2e=P(x()),$Z=Si();function PZ(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=$Z.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)}U9.exports=PZ});var M9=Ce((k2e,q9)=>{"use strict";var O2e=P(x()),xZ=Si();function TZ(e,t,r){let n={};xZ.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)}q9.exports=TZ});var V9=Ce((N2e,K9)=>{"use strict";var L2e=P(x()),j9=wc(),RZ=Si();function kZ(e,t,r){let n=[],i=[],o=RZ.build({rule(s){n.push(s.name),o(s.expression),n.pop()},sequence(s){s.elements.every(a=>(o(a),!j9.alwaysConsumesOnSuccess(e,a)))},rule_ref(s){i.push(s);let a=j9.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,f,h)=>({message:f+1!==h.length?`Step ${f+1}: call of the rule "${u.name}" without input consumption`:`Step ${f+1}: call itself without input consumption - left recursion`,location:u.location})));return}a&&o(a),i.pop()}});o(e)}K9.exports=kZ});var W9=Ce((U2e,G9)=>{"use strict";var H2e=P(x()),z9=wc(),OZ=Si();function NZ(e,t,r){OZ.build({zero_or_more(i){z9.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){z9.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)}G9.exports=NZ});var X9=Ce((q2e,Y9)=>{"use strict";var M2e=P(x()),LZ=wc(),UZ=Si();function HZ(e,t,r){UZ.build({rule_ref(i){LZ.findRule(e,i.name)||r.error(`Rule "${i.name}" is not defined`,i.location)}})(e)}Y9.exports=HZ});var J9=Ce((j2e,Z9)=>{"use strict";var K2e=P(x()),qZ=Si();function MZ(e,t,r){let n=qZ.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)}Z9.exports=MZ});var e7=Ce((V2e,Q9)=>{"use strict";var z2e=P(x()),jZ=e2(),eS=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(){}},tS=class{constructor(t){this._callbacks=new eS(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new jZ(...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}};Q9.exports=tS});var t7=Ce((exports,module)=>{"use strict";var G2e=P(x()),generateBytecode=a9(),generateJS=O9(),inferenceMatchResult=HA(),removeProxyRules=L9(),reportDuplicateLabels=H9(),reportDuplicateRules=M9(),reportInfiniteRecursion=V9(),reportInfiniteRepetition=W9(),reportUndefinedRules=X9(),reportIncorrectPlucking=J9(),Session=e7(),visitor=Si();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 n7=Ce((W2e,r7)=>{"use strict";var Y2e=P(x()),KZ={$:"text","&":"simple_and","!":"simple_not"},VZ={"?":"optional","*":"zero_or_more","+":"one_or_more"},zZ={"&":"semantic_and","!":"semantic_not"};function GZ(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function bc(e,t,r,n){var i=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(i,bc.prototype),i.expected=t,i.found=r,i.location=n,i.name="SyntaxError",i}GZ(bc,Error);function rS(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}bc.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+" | "+rS("",i.column-1," ")+rS("",h,"^")}else t+=` at `+o}return t};bc.buildMessage=function(e,t){var r={literal:function(f){return'"'+i(f.text)+'"'},class:function(f){var h=f.parts.map(function(m){return Array.isArray(m)?o(m[0])+"-"+o(m[1]):o(m)});return"["+(f.inverted?"^":"")+h.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(f){return f.description}};function n(f){return f.charCodeAt(0).toString(16).toUpperCase()}function i(f){return f.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+n(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+n(h)})}function o(f){return f.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+n(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+n(h)})}function s(f){return r[f.type](f)}function a(f){var h=f.map(s),m,p;if(h.sort(),h.length>0){for(m=1,p=1;m0?{type:"choice",alternatives:[F].concat(W),location:gr()}:F},ui=function(F,W){return W!==null?{type:"action",expression:F,code:W[0],codeLocation:W[1],location:gr()}:F},Pc=function(F,W){return W.length>0||F.type==="labeled"&&F.pick?{type:"sequence",elements:[F].concat(W),location:gr()}:F},y2=function(F,W,ne){return ne.type.startsWith("semantic_")&&Fh('"@" cannot be used on a semantic predicate',F),{type:"labeled",label:W!==null?W[0]:null,labelLocation:W!==null?W[1]:F,pick:!0,expression:ne,location:gr()}},E2=function(F,W){return{type:"labeled",label:F[0],labelLocation:F[1],expression:W,location:gr()}},b2=function(){return gr()},fr=function(F){return da.indexOf(F[0])>=0&&Fh(`Label can't be a reserved word "${F[0]}"`,F[1]),F},or=function(F,W){return{type:KZ[F],expression:W,location:gr()}},A2=function(F,W){return{type:VZ[W],expression:F,location:gr()}},S2=function(F){return F.type==="labeled"||F.type==="sequence"?{type:"group",expression:F,location:gr()}:F},C2=function(F){return{type:"rule_ref",name:F[0],location:gr()}},_2=function(F,W){return{type:zZ[F],code:W[0],codeLocation:W[1],location:gr()}},D2=function(F,W){return[F+W.join(""),gr()]},F2=function(F,W){return{type:"literal",value:F,ignoreCase:W!==null,location:gr()}},Wp=function(F){return F.join("")},B2=function(F){return F.join("")},jr=function(F,W,ne){return{type:"class",parts:W.filter(Q=>Q!==""),inverted:F!==null,ignoreCase:ne!==null,location:gr()}},_h=function(F,W){return F.charCodeAt(0)>W.charCodeAt(0)&&Fh("Invalid character range: "+po()+"."),[F,W]},aa=function(){return""},Yp=function(){return"\0"},Dh=function(){return"\b"},Ss=function(){return"\f"},Xp=function(){return` `},Zp=function(){return"\r"},Jp=function(){return" "},Qp=function(){return"\v"},e0=function(F){return String.fromCharCode(parseInt(F,16))},t0=function(F){return String.fromCharCode(parseInt(F,16))},is=function(){return{type:"any",location:gr()}},I2=function(F){return[F,gr()]},L=0,St=0,xc=[{line:1,column:1}],Gr=0,Eu=[],de=0,sr;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 po(){return e.substring(St,L)}function r0(){return St}function CS(){return{source:n,start:St,end:L}}function gr(){return Au(St,L)}function _S(F,W){throw W=W!==void 0?W:Au(St,L),$h([Di(F)],e.substring(St,L),W)}function Fh(F,W){throw W=W!==void 0?W:Au(St,L),Ih(F,W)}function ut(F,W){return{type:"literal",text:F,ignoreCase:W}}function un(F,W,ne){return{type:"class",parts:F,inverted:W,ignoreCase:ne}}function Mf(){return{type:"any"}}function bu(){return{type:"end"}}function Di(F){return{type:"other",description:F}}function Bh(F){var W=xc[F],ne;if(W)return W;for(ne=F-1;!xc[ne];)ne--;for(W=xc[ne],W={line:W.line,column:W.column};neGr&&(Gr=L,Eu=[]),Eu.push(F))}function Ih(F,W){return new bc(F,null,null,W)}function $h(F,W,ne){return new bc(bc.buildMessage(F,W),F,W,ne)}function n0(){var F,W,ne,Q,ge,ye,Wt,Rr;if(F=L,W=ir(),ne=L,Q=Ph(),Q!==r?(ge=ir(),ne=Q):(L=ne,ne=r),ne===r&&(ne=null),Q=L,ge=xh(),ge!==r?(ye=ir(),Q=ge):(L=Q,Q=r),Q===r&&(Q=null),ge=[],ye=L,Wt=s0(),Wt!==r?(Rr=ir(),ye=Wt):(L=ye,ye=r),ye!==r)for(;ye!==r;)ge.push(ye),ye=L,Wt=s0(),Wt!==r?(Rr=ir(),ye=Wt):(L=ye,ye=r);else ge=r;return ge!==r?(St=F,F=js(ne,Q,ge)):(L=F,F=r),F}function Ph(){var F,W,ne,Q,ge;return F=L,e.charCodeAt(L)===123?(W=s,L++):(W=r,de===0&&Fe(nn)),W!==r?(ne=ha(),ne!==r?(e.charCodeAt(L)===125?(Q=a,L++):(Q=r,de===0&&Fe(qs)),Q!==r?(ge=Yf(),ge!==r?(St=F,F=yu(ne)):(L=F,F=r)):(L=F,F=r)):(L=F,F=r)):(L=F,F=r),F}function xh(){var F,W,ne;return F=L,W=ha(),W!==r?(ne=Yf(),ne!==r?(St=F,F=ns(W)):(L=F,F=r)):(L=F,F=r),F}function s0(){var F,W,ne,Q,ge,ye,Wt,Rr;return F=L,W=os(),W!==r?(ne=ir(),Q=L,ge=Lh(),ge!==r?(ye=ir(),Q=ge):(L=Q,Q=r),Q===r&&(Q=null),e.charCodeAt(L)===61?(ge=u,L++):(ge=r,de===0&&Fe(mu)),ge!==r?(ye=ir(),Wt=Th(),Wt!==r?(Rr=Yf(),Rr!==r?(St=F,F=ss(W,Q,Wt)):(L=F,F=r)):(L=F,F=r)):(L=F,F=r)):(L=F,F=r),F}function Th(){var F,W,ne,Q,ge,ye,Wt,Rr;if(F=L,W=yn(),W!==r){for(ne=[],Q=L,ge=ir(),e.charCodeAt(L)===47?(ye=f,L++):(ye=r,de===0&&Fe(uo)),ye!==r?(Wt=ir(),Rr=yn(),Rr!==r?Q=Rr:(L=Q,Q=r)):(L=Q,Q=r);Q!==r;)ne.push(Q),Q=L,ge=ir(),e.charCodeAt(L)===47?(ye=f,L++):(ye=r,de===0&&Fe(uo)),ye!==r?(Wt=ir(),Rr=yn(),Rr!==r?Q=Rr:(L=Q,Q=r)):(L=Q,Q=r);St=F,F=ho(W,ne)}else L=F,F=r;return F}function yn(){var F,W,ne,Q,ge;return F=L,W=Rh(),W!==r?(ne=L,Q=ir(),ge=ha(),ge!==r?ne=ge:(L=ne,ne=r),ne===r&&(ne=null),St=F,F=ui(W,ne)):(L=F,F=r),F}function Rh(){var F,W,ne,Q,ge,ye;if(F=L,W=ca(),W!==r){for(ne=[],Q=L,ge=ir(),ye=ca(),ye!==r?Q=ye:(L=Q,Q=r);Q!==r;)ne.push(Q),Q=L,ge=ir(),ye=ca(),ye!==r?Q=ye:(L=Q,Q=r);St=F,F=Pc(W,ne)}else L=F,F=r;return F}function ca(){var F,W,ne,Q;return F=L,W=i0(),W!==r?(ne=kh(),ne===r&&(ne=null),Q=Oh(),Q!==r?(St=F,F=y2(W,ne,Q)):(L=F,F=r)):(L=F,F=r),F===r&&(F=L,W=kh(),W!==r?(ne=ir(),Q=Oh(),Q!==r?(St=F,F=E2(W,Q)):(L=F,F=r)):(L=F,F=r),F===r&&(F=Oh())),F}function i0(){var F,W;return F=L,e.charCodeAt(L)===64?(W=h,L++):(W=r,de===0&&Fe(Ac)),W!==r&&(St=F,W=b2()),F=W,F}function kh(){var F,W,ne,Q;return F=L,W=os(),W!==r?(ne=ir(),e.charCodeAt(L)===58?(Q=m,L++):(Q=r,de===0&&Fe(co)),Q!==r?(St=F,F=fr(W)):(L=F,F=r)):(L=F,F=r),F}function Oh(){var F,W,ne,Q;return F=L,W=$2(),W!==r?(ne=ir(),Q=o0(),Q!==r?(St=F,F=or(W,Q)):(L=F,F=r)):(L=F,F=r),F===r&&(F=o0()),F}function $2(){var F;return e.charCodeAt(L)===36?(F=p,L++):(F=r,de===0&&Fe(ii)),F===r&&(e.charCodeAt(L)===38?(F=d,L++):(F=r,de===0&&Fe(Vt)),F===r&&(e.charCodeAt(L)===33?(F=v,L++):(F=r,de===0&&Fe(bs)))),F}function o0(){var F,W,ne,Q;return F=L,W=a0(),W!==r?(ne=ir(),Q=P2(),Q!==r?(St=F,F=A2(W,Q)):(L=F,F=r)):(L=F,F=r),F===r&&(F=a0()),F}function P2(){var F;return e.charCodeAt(L)===63?(F=g,L++):(F=r,de===0&&Fe(vu)),F===r&&(e.charCodeAt(L)===42?(F=y,L++):(F=r,de===0&&Fe(Sc)),F===r&&(e.charCodeAt(L)===43?(F=w,L++):(F=r,de===0&&Fe(ra)))),F}function a0(){var F,W,ne,Q,ge,ye;return F=N2(),F===r&&(F=Ae(),F===r&&(F=jf(),F===r&&(F=Su(),F===r&&(F=x2(),F===r&&(F=L,e.charCodeAt(L)===40?(W=E,L++):(W=r,de===0&&Fe(fo)),W!==r?(ne=ir(),Q=Th(),Q!==r?(ge=ir(),e.charCodeAt(L)===41?(ye=C,L++):(ye=r,de===0&&Fe(Cc)),ye!==r?(St=F,F=S2(Q)):(L=F,F=r)):(L=F,F=r)):(L=F,F=r)))))),F}function Su(){var F,W,ne,Q,ge,ye,Wt,Rr;return F=L,W=os(),W!==r?(ne=L,de++,Q=L,ge=ir(),ye=L,Wt=Lh(),Wt!==r?(Rr=ir(),Wt=[Wt,Rr],ye=Wt):(L=ye,ye=r),ye===r&&(ye=null),e.charCodeAt(L)===61?(Wt=u,L++):(Wt=r,de===0&&Fe(mu)),Wt!==r?(ge=[ge,ye,Wt],Q=ge):(L=Q,Q=r),de--,Q===r?ne=void 0:(L=ne,ne=r),ne!==r?(St=F,F=C2(W)):(L=F,F=r)):(L=F,F=r),F}function x2(){var F,W,ne,Q;return F=L,W=T2(),W!==r?(ne=ir(),Q=ha(),Q!==r?(St=F,F=_2(W,Q)):(L=F,F=r)):(L=F,F=r),F}function T2(){var F;return e.charCodeAt(L)===38?(F=d,L++):(F=r,de===0&&Fe(Vt)),F===r&&(e.charCodeAt(L)===33?(F=v,L++):(F=r,de===0&&Fe(bs))),F}function cn(){var F;return e.length>L?(F=e.charAt(L),L++):(F=r,de===0&&Fe(wu)),F}function Tc(){var F,W;return de++,e.charCodeAt(L)===9?(F=D,L++):(F=r,de===0&&Fe(_c)),F===r&&(e.charCodeAt(L)===11?(F=B,L++):(F=r,de===0&&Fe(ue)),F===r&&(e.charCodeAt(L)===12?(F=H,L++):(F=r,de===0&&Fe(Ee)),F===r&&(e.charCodeAt(L)===32?(F=V,L++):(F=r,de===0&&Fe(Xe)),F===r&&(e.charCodeAt(L)===160?(F=S,L++):(F=r,de===0&&Fe(Ye)),F===r&&(e.charCodeAt(L)===65279?(F=I,L++):(F=r,de===0&&Fe(it)),F===r&&(F=p0())))))),de--,F===r&&(W=r,de===0&&Fe(na)),F}function En(){var F;return wt.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(bt)),F}function fa(){var F,W;return de++,e.charCodeAt(L)===10?(F=U,L++):(F=r,de===0&&Fe(xr)),F===r&&(e.substr(L,2)===R?(F=R,L+=2):(F=r,de===0&&Fe(rr)),F===r&&(e.charCodeAt(L)===13?(F=O,L++):(F=r,de===0&&Fe(es)),F===r&&(e.charCodeAt(L)===8232?(F=q,L++):(F=r,de===0&&Fe(oi)),F===r&&(e.charCodeAt(L)===8233?(F=N,L++):(F=r,de===0&&Fe(vn)))))),de--,F===r&&(W=r,de===0&&Fe(At)),F}function u0(){var F,W;return de++,F=R2(),F===r&&(F=la()),de--,F===r&&(W=r,de===0&&Fe(kn)),F}function R2(){var F,W,ne,Q,ge,ye;if(F=L,e.substr(L,2)===_?(W=_,L+=2):(W=r,de===0&&Fe(Cr)),W!==r){for(ne=[],Q=L,ge=L,de++,e.substr(L,2)===k?(ye=k,L+=2):(ye=r,de===0&&Fe(wn)),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r);Q!==r;)ne.push(Q),Q=L,ge=L,de++,e.substr(L,2)===k?(ye=k,L+=2):(ye=r,de===0&&Fe(wn)),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r);e.substr(L,2)===k?(Q=k,L+=2):(Q=r,de===0&&Fe(wn)),Q!==r?(W=[W,ne,Q],F=W):(L=F,F=r)}else L=F,F=r;return F}function c0(){var F,W,ne,Q,ge,ye;if(F=L,e.substr(L,2)===_?(W=_,L+=2):(W=r,de===0&&Fe(Cr)),W!==r){for(ne=[],Q=L,ge=L,de++,e.substr(L,2)===k?(ye=k,L+=2):(ye=r,de===0&&Fe(wn)),ye===r&&(ye=En()),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r);Q!==r;)ne.push(Q),Q=L,ge=L,de++,e.substr(L,2)===k?(ye=k,L+=2):(ye=r,de===0&&Fe(wn)),ye===r&&(ye=En()),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r);e.substr(L,2)===k?(Q=k,L+=2):(Q=r,de===0&&Fe(wn)),Q!==r?(W=[W,ne,Q],F=W):(L=F,F=r)}else L=F,F=r;return F}function la(){var F,W,ne,Q,ge,ye;if(F=L,e.substr(L,2)===K?(W=K,L+=2):(W=r,de===0&&Fe(On)),W!==r){for(ne=[],Q=L,ge=L,de++,ye=En(),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r);Q!==r;)ne.push(Q),Q=L,ge=L,de++,ye=En(),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r);W=[W,ne],F=W}else L=F,F=r;return F}function os(){var F,W,ne,Q;if(de++,F=L,W=Nh(),W!==r){for(ne=[],Q=f0();Q!==r;)ne.push(Q),Q=f0();St=F,F=D2(W,ne)}else L=F,F=r;return de--,F===r&&(W=r,de===0&&Fe(lo)),F}function Nh(){var F,W,ne;return F=k2(),F===r&&(e.charCodeAt(L)===36?(F=p,L++):(F=r,de===0&&Fe(ii)),F===r&&(e.charCodeAt(L)===95?(F=Z,L++):(F=r,de===0&&Fe(Dc)),F===r&&(F=L,e.charCodeAt(L)===92?(W=G,L++):(W=r,de===0&&Fe(sn)),W!==r?(ne=Rc(),ne!==r?F=ne:(L=F,F=r)):(L=F,F=r)))),F}function f0(){var F;return F=Nh(),F===r&&(F=O2(),F===r&&(F=zf(),F===r&&(F=Gf(),F===r&&(e.charCodeAt(L)===8204?(F=ee,L++):(F=r,de===0&&Fe(Mt)),F===r&&(e.charCodeAt(L)===8205?(F=se,L++):(F=r,de===0&&Fe(_r))))))),F}function k2(){var F;return F=q2(),F===r&&(F=h0(),F===r&&(F=H2(),F===r&&(F=Kf(),F===r&&(F=U2(),F===r&&(F=d0()))))),F}function O2(){var F;return F=go(),F===r&&(F=Vf()),F}function N2(){var F,W,ne;return de++,F=L,W=Lh(),W!==r?(e.charCodeAt(L)===105?(ne=le,L++):(ne=r,de===0&&Fe(pr)),ne===r&&(ne=null),St=F,F=F2(W,ne)):(L=F,F=r),de--,F===r&&(W=r,de===0&&Fe(gt)),F}function Lh(){var F,W,ne,Q;if(de++,F=L,e.charCodeAt(L)===34?(W=ve,L++):(W=r,de===0&&Fe(lr)),W!==r){for(ne=[],Q=Fi();Q!==r;)ne.push(Q),Q=Fi();e.charCodeAt(L)===34?(Q=ve,L++):(Q=r,de===0&&Fe(lr)),Q!==r?(St=F,F=Wp(ne)):(L=F,F=r)}else L=F,F=r;if(F===r)if(F=L,e.charCodeAt(L)===39?(W=we,L++):(W=r,de===0&&Fe(Zt)),W!==r){for(ne=[],Q=ce();Q!==r;)ne.push(Q),Q=ce();e.charCodeAt(L)===39?(Q=we,L++):(Q=r,de===0&&Fe(Zt)),Q!==r?(St=F,F=B2(ne)):(L=F,F=r)}else L=F,F=r;return de--,F===r&&(W=r,de===0&&Fe(on)),F}function Fi(){var F,W,ne,Q;return F=L,W=L,ne=L,de++,e.charCodeAt(L)===34?(Q=ve,L++):(Q=r,de===0&&Fe(lr)),Q===r&&(e.charCodeAt(L)===92?(Q=G,L++):(Q=r,de===0&&Fe(sn)),Q===r&&(Q=En())),de--,Q===r?ne=void 0:(L=ne,ne=r),ne!==r?(Q=cn(),Q!==r?(ne=[ne,Q],W=ne):(L=W,W=r)):(L=W,W=r),W!==r?F=e.substring(F,L):F=W,F===r&&(F=L,e.charCodeAt(L)===92?(W=G,L++):(W=r,de===0&&Fe(sn)),W!==r?(ne=Ot(),ne!==r?F=ne:(L=F,F=r)):(L=F,F=r),F===r&&(F=pt())),F}function ce(){var F,W,ne,Q;return F=L,W=L,ne=L,de++,e.charCodeAt(L)===39?(Q=we,L++):(Q=r,de===0&&Fe(Zt)),Q===r&&(e.charCodeAt(L)===92?(Q=G,L++):(Q=r,de===0&&Fe(sn)),Q===r&&(Q=En())),de--,Q===r?ne=void 0:(L=ne,ne=r),ne!==r?(Q=cn(),Q!==r?(ne=[ne,Q],W=ne):(L=W,W=r)):(L=W,W=r),W!==r?F=e.substring(F,L):F=W,F===r&&(F=L,e.charCodeAt(L)===92?(W=G,L++):(W=r,de===0&&Fe(sn)),W!==r?(ne=Ot(),ne!==r?F=ne:(L=F,F=r)):(L=F,F=r),F===r&&(F=pt())),F}function Ae(){var F,W,ne,Q,ge,ye;if(de++,F=L,e.charCodeAt(L)===91?(W=Pe,L++):(W=r,de===0&&Fe(As)),W!==r){for(e.charCodeAt(L)===94?(ne=Le,L++):(ne=r,de===0&&Fe(Ms)),ne===r&&(ne=null),Q=[],ge=me(),ge===r&&(ge=We());ge!==r;)Q.push(ge),ge=me(),ge===r&&(ge=We());e.charCodeAt(L)===93?(ge=Oe,L++):(ge=r,de===0&&Fe(rs)),ge!==r?(e.charCodeAt(L)===105?(ye=le,L++):(ye=r,de===0&&Fe(pr)),ye===r&&(ye=null),St=F,F=jr(ne,Q,ye)):(L=F,F=r)}else L=F,F=r;return de--,F===r&&(W=r,de===0&&Fe(ts)),F}function me(){var F,W,ne,Q;return F=L,W=We(),W!==r?(e.charCodeAt(L)===45?(ne=fe,L++):(ne=r,de===0&&Fe(Mr)),ne!==r?(Q=We(),Q!==r?(St=F,F=_h(W,Q)):(L=F,F=r)):(L=F,F=r)):(L=F,F=r),F}function We(){var F,W,ne,Q;return F=L,W=L,ne=L,de++,e.charCodeAt(L)===93?(Q=Oe,L++):(Q=r,de===0&&Fe(rs)),Q===r&&(e.charCodeAt(L)===92?(Q=G,L++):(Q=r,de===0&&Fe(sn)),Q===r&&(Q=En())),de--,Q===r?ne=void 0:(L=ne,ne=r),ne!==r?(Q=cn(),Q!==r?(ne=[ne,Q],W=ne):(L=W,W=r)):(L=W,W=r),W!==r?F=e.substring(F,L):F=W,F===r&&(F=L,e.charCodeAt(L)===92?(W=G,L++):(W=r,de===0&&Fe(sn)),W!==r?(ne=Ot(),ne!==r?F=ne:(L=F,F=r)):(L=F,F=r),F===r&&(F=pt())),F}function pt(){var F,W,ne;return F=L,e.charCodeAt(L)===92?(W=G,L++):(W=r,de===0&&Fe(sn)),W!==r?(ne=fa(),ne!==r?(St=F,F=aa()):(L=F,F=r)):(L=F,F=r),F}function Ot(){var F,W,ne,Q;return F=Tr(),F===r&&(F=L,e.charCodeAt(L)===48?(W=Se,L++):(W=r,de===0&&Fe(br)),W!==r?(ne=L,de++,Q=l0(),de--,Q===r?ne=void 0:(L=ne,ne=r),ne!==r?(St=F,F=Yp()):(L=F,F=r)):(L=F,F=r),F===r&&(F=Cs(),F===r&&(F=Rc()))),F}function Tr(){var F;return F=Jt(),F===r&&(F=Uh()),F}function Jt(){var F,W;return e.charCodeAt(L)===39?(F=we,L++):(F=r,de===0&&Fe(Zt)),F===r&&(e.charCodeAt(L)===34?(F=ve,L++):(F=r,de===0&&Fe(lr)),F===r&&(e.charCodeAt(L)===92?(F=G,L++):(F=r,de===0&&Fe(sn)),F===r&&(F=L,e.charCodeAt(L)===98?(W=Re,L++):(W=r,de===0&&Fe(Fc)),W!==r&&(St=F,W=Dh()),F=W,F===r&&(F=L,e.charCodeAt(L)===102?(W=Ke,L++):(W=r,de===0&&Fe(Hf)),W!==r&&(St=F,W=Ss()),F=W,F===r&&(F=L,e.charCodeAt(L)===110?(W=Qe,L++):(W=r,de===0&&Fe(Nn)),W!==r&&(St=F,W=Xp()),F=W,F===r&&(F=L,e.charCodeAt(L)===114?(W=Me,L++):(W=r,de===0&&Fe(sa)),W!==r&&(St=F,W=Zp()),F=W,F===r&&(F=L,e.charCodeAt(L)===116?(W=yt,L++):(W=r,de===0&&Fe(Bc)),W!==r&&(St=F,W=Jp()),F=W,F===r&&(F=L,e.charCodeAt(L)===118?(W=rt,L++):(W=r,de===0&&Fe(Sh)),W!==r&&(St=F,W=Qp()),F=W)))))))),F}function Uh(){var F,W,ne,Q;return F=L,W=L,ne=L,de++,Q=L2(),Q===r&&(Q=En()),de--,Q===r?ne=void 0:(L=ne,ne=r),ne!==r?(Q=cn(),Q!==r?(ne=[ne,Q],W=ne):(L=W,W=r)):(L=W,W=r),W!==r?F=e.substring(F,L):F=W,F}function L2(){var F;return F=Jt(),F===r&&(F=l0(),F===r&&(e.charCodeAt(L)===120?(F=vt,L++):(F=r,de===0&&Fe(Ic)),F===r&&(e.charCodeAt(L)===117?(F=rn,L++):(F=r,de===0&&Fe(ia))))),F}function Cs(){var F,W,ne,Q,ge,ye;return F=L,e.charCodeAt(L)===120?(W=vt,L++):(W=r,de===0&&Fe(Ic)),W!==r?(ne=L,Q=L,ge=Ks(),ge!==r?(ye=Ks(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r),Q!==r?ne=e.substring(ne,L):ne=Q,ne!==r?(St=F,F=e0(ne)):(L=F,F=r)):(L=F,F=r),F}function Rc(){var F,W,ne,Q,ge,ye,Wt,Rr;return F=L,e.charCodeAt(L)===117?(W=rn,L++):(W=r,de===0&&Fe(ia)),W!==r?(ne=L,Q=L,ge=Ks(),ge!==r?(ye=Ks(),ye!==r?(Wt=Ks(),Wt!==r?(Rr=Ks(),Rr!==r?(ge=[ge,ye,Wt,Rr],Q=ge):(L=Q,Q=r)):(L=Q,Q=r)):(L=Q,Q=r)):(L=Q,Q=r),Q!==r?ne=e.substring(ne,L):ne=Q,ne!==r?(St=F,F=t0(ne)):(L=F,F=r)):(L=F,F=r),F}function l0(){var F;return Pr.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(oa)),F}function Ks(){var F;return Rn.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(Ch)),F}function jf(){var F,W;return F=L,e.charCodeAt(L)===46?(W=yr,L++):(W=r,de===0&&Fe(qf)),W!==r&&(St=F,W=is()),F=W,F}function ha(){var F,W,ne,Q;return de++,F=L,e.charCodeAt(L)===123?(W=s,L++):(W=r,de===0&&Fe(nn)),W!==r?(ne=zt(),e.charCodeAt(L)===125?(Q=a,L++):(Q=r,de===0&&Fe(qs)),Q!==r?F=ne:(L=F,F=r)):(L=F,F=r),de--,F===r&&(W=r,de===0&&Fe($c)),F}function zt(){var F,W;return F=L,W=Hh(),St=F,W=I2(W),F=W,F}function Hh(){var F,W,ne,Q,ge,ye;if(F=L,W=[],ne=[],Q=L,ge=L,de++,Hs.test(e.charAt(L))?(ye=e.charAt(L),L++):(ye=r,de===0&&Fe(ai)),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r),Q!==r)for(;Q!==r;)ne.push(Q),Q=L,ge=L,de++,Hs.test(e.charAt(L))?(ye=e.charAt(L),L++):(ye=r,de===0&&Fe(ai)),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r);else ne=r;for(ne===r&&(ne=L,e.charCodeAt(L)===123?(Q=s,L++):(Q=r,de===0&&Fe(nn)),Q!==r?(ge=Hh(),e.charCodeAt(L)===125?(ye=a,L++):(ye=r,de===0&&Fe(qs)),ye!==r?(Q=[Q,ge,ye],ne=Q):(L=ne,ne=r)):(L=ne,ne=r));ne!==r;){if(W.push(ne),ne=[],Q=L,ge=L,de++,Hs.test(e.charAt(L))?(ye=e.charAt(L),L++):(ye=r,de===0&&Fe(ai)),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r),Q!==r)for(;Q!==r;)ne.push(Q),Q=L,ge=L,de++,Hs.test(e.charAt(L))?(ye=e.charAt(L),L++):(ye=r,de===0&&Fe(ai)),de--,ye===r?ge=void 0:(L=ge,ge=r),ge!==r?(ye=cn(),ye!==r?(ge=[ge,ye],Q=ge):(L=Q,Q=r)):(L=Q,Q=r);else ne=r;ne===r&&(ne=L,e.charCodeAt(L)===123?(Q=s,L++):(Q=r,de===0&&Fe(nn)),Q!==r?(ge=Hh(),e.charCodeAt(L)===125?(ye=a,L++):(ye=r,de===0&&Fe(qs)),ye!==r?(Q=[Q,ge,ye],ne=Q):(L=ne,ne=r)):(L=ne,ne=r))}return F=e.substring(F,L),F}function h0(){var F;return It.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(M)),F}function Kf(){var F;return tt.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(z)),F}function U2(){var F;return Ue.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(J)),F}function H2(){var F;return dr.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(ae)),F}function q2(){var F;return gn.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(Be)),F}function Vf(){var F;return Et.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(xe)),F}function go(){var F;return ta.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(qe)),F}function zf(){var F;return mn.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(Ve)),F}function d0(){var F;return De.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(nr)),F}function Gf(){var F;return ao.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(Dr)),F}function p0(){var F;return qt.test(e.charAt(L))?(F=e.charAt(L),L++):(F=r,de===0&&Fe(Ln)),F}function ir(){var F,W;for(F=[],W=Tc(),W===r&&(W=fa(),W===r&&(W=u0()));W!==r;)F.push(W),W=Tc(),W===r&&(W=fa(),W===r&&(W=u0()));return F}function Wf(){var F,W;for(F=[],W=Tc(),W===r&&(W=c0());W!==r;)F.push(W),W=Tc(),W===r&&(W=c0());return F}function Yf(){var F,W,ne,Q;return F=L,W=ir(),e.charCodeAt(L)===59?(ne=Er,L++):(ne=r,de===0&&Fe(an)),ne!==r?(W=[W,ne],F=W):(L=F,F=r),F===r&&(F=L,W=Wf(),ne=la(),ne===r&&(ne=null),Q=fa(),Q!==r?(W=[W,ne,Q],F=W):(L=F,F=r),F===r&&(F=L,W=ir(),ne=kc(),ne!==r?(W=[W,ne],F=W):(L=F,F=r))),F}function kc(){var F,W;return F=L,de++,e.length>L?(W=e.charAt(L),L++):(W=r,de===0&&Fe(wu)),de--,W===r?F=void 0:(L=F,F=r),F}let da=t.reservedWords||[];if(sr=o(),sr!==r&&L===e.length)return sr;throw sr!==r&&L{"use strict";var Z2e=P(x()),YZ=e2(),XZ=t7(),ZZ=n7(),JZ=KA(),QZ=["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"],Kp={VERSION:JZ,RESERVED_WORDS:QZ,GrammarError:YZ,parser:ZZ,compiler:XZ,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:Kp.parser,passes:r(Kp.compiler.passes),reservedWords:Kp.RESERVED_WORDS.slice()};return n.forEach(o=>{o.use(i,t)}),Kp.compiler.compile(i.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:i.reservedWords}),i.passes,t)}};s7.exports=Kp});var lS=Ce((cS,fS)=>{var uve=P(x());(function(e,t){typeof cS=="object"&&typeof fS<"u"?fS.exports=t():typeof define=="function"&&define.amd?define(t):e.JSON5=t()})(cS,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,f=i(u)&&i(u.createElement),h=function(ue){return f?u.createElement(ue):{}},m=!a&&!s(function(){return Object.defineProperty(h("div"),"a",{get:function(){return 7}}).a!=7}),p=function(ue,Ee){if(!i(ue))return ue;var Xe,Ye;if(Ee&&typeof(Xe=ue.toString)=="function"&&!i(Ye=Xe.call(ue))||typeof(Xe=ue.valueOf)=="function"&&!i(Ye=Xe.call(ue))||!Ee&&typeof(Xe=ue.toString)=="function"&&!i(Ye=Xe.call(ue)))return Ye;throw TypeError("Can't convert object to primitive value")},d=Object.defineProperty,v=a?Object.defineProperty:function(Ee,Xe,Ye){if(o(Ee),Xe=p(Xe,!0),o(Ye),m)try{return d(Ee,Xe,Ye)}catch{}if("get"in Ye||"set"in Ye)throw TypeError("Accessors not supported!");return"value"in Ye&&(Ee[Xe]=Ye.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,C=function(ue,Ee){return E.call(ue,Ee)},D=0,B=Math.random(),H=function(ue){return"Symbol(".concat(ue===void 0?"":ue,")_",(++D+B).toString(36))},V=!1,S=e(function(ue){var Ee="__core-js_shared__",Xe=t[Ee]||(t[Ee]={});(ue.exports=function(Ye,it){return Xe[Ye]||(Xe[Ye]=it!==void 0?it:{})})("versions",[]).push({version:r.version,mode:V?"pure":"global",copyright:"\xA9 2019 Denis Pushkarev (zloirock.ru)"})}),I=S("native-function-to-string",Function.toString),U=e(function(ue){var Ee=H("src"),Xe="toString",Ye=(""+I).split(Xe);r.inspectSource=function(it){return I.call(it)},(ue.exports=function(it,bt,At,xr){var rr=typeof At=="function";rr&&(C(At,"name")||w(At,"name",bt)),it[bt]!==At&&(rr&&(C(At,Ee)||w(At,Ee,it[bt]?""+it[bt]:Ye.join(String(bt)))),it===t?it[bt]=At:xr?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},O=function(ue,Ee,Xe){if(R(ue),Ee===void 0)return ue;switch(Xe){case 1:return function(Ye){return ue.call(Ee,Ye)};case 2:return function(Ye,it){return ue.call(Ee,Ye,it)};case 3:return function(Ye,it,bt){return ue.call(Ee,Ye,it,bt)}}return function(){return ue.apply(Ee,arguments)}},q="prototype",N=function(ue,Ee,Xe){var Ye=ue&N.F,it=ue&N.G,bt=ue&N.S,At=ue&N.P,xr=ue&N.B,rr=it?t:bt?t[Ee]||(t[Ee]={}):(t[Ee]||{})[q],es=it?r:r[Ee]||(r[Ee]={}),oi=es[q]||(es[q]={}),vn,kn,Cr,wn;it&&(Xe=Ee);for(vn in Xe)kn=!Ye&&rr&&rr[vn]!==void 0,Cr=(kn?rr:Xe)[vn],wn=xr&&kn?O(Cr,t):At&&typeof Cr=="function"?O(Function.call,Cr):Cr,rr&&U(rr,vn,Cr,ue&N.U),es[vn]!=Cr&&w(es,vn,wn),At&&oi[vn]!=Cr&&(oi[vn]=Cr)};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 _=N,k=Math.ceil,K=Math.floor,Z=function(ue){return isNaN(ue=+ue)?0:(ue>0?K:k)(ue)},G=function(ue){if(ue==null)throw TypeError("Can't call method on "+ue);return ue},ee=function(ue){return function(Ee,Xe){var Ye=String(G(Ee)),it=Z(Xe),bt=Ye.length,At,xr;return it<0||it>=bt?ue?"":void 0:(At=Ye.charCodeAt(it),At<55296||At>56319||it+1===bt||(xr=Ye.charCodeAt(it+1))<56320||xr>57343?ue?Ye.charAt(it):At:ue?Ye.slice(it,it+2):(At-55296<<10)+(xr-56320)+65536)}},se=ee(!1);_(_.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=Z(ue),ue<0?ve(ue+Ee,0):we(ue,Ee)},Le=String.fromCharCode,Oe=String.fromCodePoint;_(_.S+_.F*(!!Oe&&Oe.length!=1),"String",{fromCodePoint:function(Ee){for(var Xe=arguments,Ye=[],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");Ye.push(At<65536?Le(At):Le(((At-=65536)>>10)+55296,At%1024+56320))}return Ye.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},Me={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,rn,yr,Er,wt,Pr,Rn,Hs=function(Ee,Xe){yt=String(Ee),rt="start",vt=[],rn=0,yr=1,Er=0,wt=void 0,Pr=void 0,Rn=void 0;do wt=ta(),Ac[rt]();while(wt.type!=="eof");return typeof Xe=="function"?It({"":Rn},"",Xe):Rn};function It(ue,Ee,Xe){var Ye=ue[Ee];if(Ye!=null&&typeof Ye=="object")if(Array.isArray(Ye))for(var it=0;it0;){var Xe=mn();if(!Me.isHexDigit(Xe))throw Vt(De());ue+=De()}return String.fromCodePoint(parseInt(ue,16))}var Ac={start:function(){if(wt.type==="eof")throw bs();co()},beforePropertyName:function(){switch(wt.type){case"identifier":case"string":Pr=wt.value,rt="afterPropertyName";return;case"punctuator":ii();return;case"eof":throw bs()}},afterPropertyName:function(){if(wt.type==="eof")throw bs();rt="beforePropertyValue"},beforePropertyValue:function(){if(wt.type==="eof")throw bs();co()},beforeArrayValue:function(){if(wt.type==="eof")throw bs();if(wt.type==="punctuator"&&wt.value==="]"){ii();return}co()},afterPropertyValue:function(){if(wt.type==="eof")throw bs();switch(wt.value){case",":rt="beforePropertyName";return;case"}":ii()}},afterArrayValue:function(){if(wt.type==="eof")throw bs();switch(wt.value){case",":rt="beforeArrayValue";return;case"]":ii()}},end:function(){}};function co(){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(Rn===void 0)Rn=ue;else{var Ee=vt[vt.length-1];Array.isArray(Ee)?Ee.push(ue):Object.defineProperty(Ee,Pr,{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 ii(){vt.pop();var ue=vt[vt.length-1];ue==null?rt="end":Array.isArray(ue)?rt="afterArrayValue":rt="afterPropertyValue"}function Vt(ue){return fo(ue===void 0?"JSON5: invalid end of input at "+yr+":"+Er:"JSON5: invalid character '"+ra(ue)+"' at "+yr+":"+Er)}function bs(){return fo("JSON5: invalid end of input at "+yr+":"+Er)}function vu(){return Er-=5,fo("JSON5: invalid identifier character at "+yr+":"+Er)}function Sc(ue){console.warn("JSON5: '"+ra(ue)+"' in strings is not valid ECMAScript; consider escaping")}function ra(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 fo(ue){var Ee=new SyntaxError(ue);return Ee.lineNumber=yr,Ee.columnNumber=Er,Ee}var Cc=function(Ee,Xe,Ye){var it=[],bt="",At,xr,rr="",es;if(Xe!=null&&typeof Xe=="object"&&!Array.isArray(Xe)&&(Ye=Xe.space,es=Xe.quote,Xe=Xe.replacer),typeof Xe=="function")xr=Xe;else if(Array.isArray(Xe)){At=[];for(var oi=0,vn=Xe;oi0&&(Ye=Math.min(10,Math.floor(Ye)),rr=" ".substr(0,Ye)):typeof Ye=="string"&&(rr=Ye.substr(0,10)),wn("",{"":Ee});function wn(Mt,_r){var gt=_r[Mt];switch(gt!=null&&(typeof gt.toJSON5=="function"?gt=gt.toJSON5(Mt):typeof gt.toJSON=="function"&&(gt=gt.toJSON(Mt))),xr&&(gt=xr.call(_r,Mt,gt)),gt instanceof Number?gt=Number(gt):gt instanceof String?gt=String(gt):gt instanceof Boolean&&(gt=gt.valueOf()),gt){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof gt=="string")return On(gt,!1);if(typeof gt=="number")return String(gt);if(typeof gt=="object")return Array.isArray(gt)?sn(gt):lo(gt)}function On(Mt){for(var _r={"'":.1,'"':.2},gt={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},pr="",on=0;on=0)throw TypeError("Converting circular structure to JSON5");it.push(Mt);var _r=bt;bt=bt+rr;for(var gt=At||Object.keys(Mt),pr=[],on=0,lr=gt;on=0)throw TypeError("Converting circular structure to JSON5");it.push(Mt);var _r=bt;bt=bt+rr;for(var gt=[],pr=0;pr"u"||(Q4=!0,n8.forEach(t=>{let r=console[t];typeof r=="function"&&(console[t]=function(...n){if(r.apply(console,oU(n,{isNode:e.env.isNode})),!_w)try{_w=!0,lU(e,t,n)}finally{_w=!1}})}))}function hU(e){let t=Date.now();if(e1!==null&&tn.trim()).filter(Boolean);if(t.length===0)return t;let r=t[0].replace(i8,"").trim();return r!==t[0]&&(r?t[0]=r:t.shift()),t}function mU(e){return e.length<3||!J4.test(e[0])||!J4.test(e[e.length-1])?!1:e.slice(1,-1).some(t=>s8.test(t))}function vU(e){let t=e.replace(nU,"");return iU.some(r=>r.test(t))}function wU(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 yU(e){return e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.time=="number"&&typeof e.level=="string"&&typeof e.message=="string"}function EU(){return`${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var Nre=P(x(),1),d8="3.7.8",bU=d8,ul=typeof Buffer=="function",u8=typeof TextDecoder=="function"?new TextDecoder:void 0,c8=typeof TextEncoder=="function"?new TextEncoder:void 0,AU="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",nd=Array.prototype.slice.call(AU),t1=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(nd),SU=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,An=String.fromCharCode.bind(String),f8=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),p8=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),g8=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),m8=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+=nd[t>>18&63]+nd[t>>12&63]+nd[t>>6&63]+nd[t&63]}return s?o.slice(0,s-3)+"===".substring(s):o},Bw=typeof btoa=="function"?e=>btoa(e):ul?e=>Buffer.from(e,"binary").toString("base64"):m8,Dw=ul?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,i=e.length;nt?p8(Dw(e)):Dw(e),CU=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?An(192|t>>>6)+An(128|t&63):An(224|t>>>12&15)+An(128|t>>>6&63)+An(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return An(240|t>>>18&7)+An(128|t>>>12&63)+An(128|t>>>6&63)+An(128|t&63)}},_U=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,v8=e=>e.replace(_U,CU),l8=ul?e=>Buffer.from(e,"utf8").toString("base64"):c8?e=>Dw(c8.encode(e)):e=>Bw(v8(e)),al=(e,t=!1)=>t?p8(l8(e)):l8(e),h8=e=>al(e,!0),DU=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,FU=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 An((r>>>10)+55296)+An((r&1023)+56320);case 3:return An((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return An((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},w8=e=>e.replace(DU,FU),y8=e=>{if(e=e.replace(/\s+/g,""),!SU.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(An(t>>16&255,t>>8&255)):i.push(An(t>>16&255,t>>8&255,t&255));return i.join("")},Iw=typeof atob=="function"?e=>atob(g8(e)):ul?e=>Buffer.from(e,"base64").toString("binary"):y8,E8=ul?e=>f8(Buffer.from(e,"base64")):e=>f8(Iw(e).split("").map(t=>t.charCodeAt(0))),b8=e=>E8(A8(e)),BU=ul?e=>Buffer.from(e,"base64").toString("utf8"):u8?e=>u8.decode(E8(e)):e=>w8(Iw(e)),A8=e=>g8(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),Fw=e=>BU(A8(e)),IU=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)},S8=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),C8=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,S8(r));e("fromBase64",function(){return Fw(this)}),e("toBase64",function(t){return al(this,t)}),e("toBase64URI",function(){return al(this,!0)}),e("toBase64URL",function(){return al(this,!0)}),e("toUint8Array",function(){return b8(this)})},_8=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,S8(r));e("toBase64",function(t){return r1(this,t)}),e("toBase64URI",function(){return r1(this,!0)}),e("toBase64URL",function(){return r1(this,!0)})},$U=()=>{C8(),_8()},Bt={version:d8,VERSION:bU,atob:Iw,atobPolyfill:y8,btoa:Bw,btoaPolyfill:m8,fromBase64:Fw,toBase64:al,encode:al,encodeURI:h8,encodeURL:h8,utob:v8,btou:w8,decode:Fw,isValid:IU,fromUint8Array:r1,toUint8Array:b8,extendString:C8,extendUint8Array:_8,extendBuiltins:$U};var Pu=typeof $task<"u",_a=typeof $loon<"u",xu=typeof $httpClient<"u"&&!_a,Eo=eval('typeof process !== "undefined"'),D8=typeof $environment<"u"&&$environment["stash-version"],F8=typeof $rocket<"u",PU=typeof Egern<"u"&&Egern.version,xU=typeof $native<"u",Tu=typeof $Plugins<"u";function n1(e){return e!==null&&typeof e=="object"&&[null,Object.prototype].includes(Object.getPrototypeOf(e))}function TU(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 RU(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 s1=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=Da(),this.env=bo(),Eo){let dotenv=eval('require("dotenv")');dotenv.config()}this.node=(()=>{if(Eo){let fs=eval("require('fs')");return{fs}}else return null})(),this.initCache(),o8(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(Pu&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(_a||xu)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),Tu&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),Eo){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}`)}n1(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")),!n1(this.cache))throw new Error("Invalid Data")}catch{try{let t=Bt.decode(this.node.fs.readFileSync(`${fpath}`,"utf-8"));if(this.cache=JSON.parse(t),this.node.fs.writeFileSync(fpath,t,{flag:"w"}),!n1(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}`)}}n1(this.cache)||(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"w"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(Pu&&$prefs.setValueForKey(data,this.name),(_a||xu)&&$persistentStore.write(data,this.name),Tu&&$Plugins.SubStoreCache.set(this.name,data),Eo){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),xu||_a)return $persistentStore.write(e,t);if(Pu)return $prefs.setValueForKey(e,t);if(Eo&&(this.root[t]=e),Tu)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),xu||_a)return $persistentStore.read(e);if(Pu)return $prefs.valueForKey(e);if(Eo)return this.root[e];if(Tu)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),xu||_a)return $persistentStore.write(null,e);if(Pu)return $prefs.removeValueForKey(e);if(Eo&&delete this.root[e],Tu)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(Pu&&$notify(title,subtitle,content,options),xu&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),_a){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(Eo){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(` `)));Da().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}`)})}}Tu&&$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={}){Pu||_a||xu||Tu?$done(e):Eo&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function bo(){return{isQX:Pu,isLoon:_a,isSurge:xu,isNode:Eo,isStash:D8,isShadowRocket:F8,isEgern:PU,isLanceX:xU,isGUIforCores:Tu}}function Da(defaultOptions={baseURL:""}){let{isQX,isLoon,isSurge,isNode,isGUIforCores}=bo(),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||D8||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=RU(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(TU(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 kU=new s1("sub-store"),te=kU;var Sye=P(x());var Gre=P(x());var Yre=P(x()),$w=class{constructor(t,r,n){this.code=t,this.message=r,this.details=n}};var Fa=class extends $w{constructor(t,r,n){super(t,r,n),this.type="RequestInvalidError"}};var tne=P(x());var xw=new Map,Pw=new Set,Tw;function Rw(e){return e?.cron==null?"":`${e.cron}`.trim()}function B8(e){return Rw(e).length>0}function OU(e){let t=e?.displayName??e?.["display-name"];return t==null?"":`${t}`.trim()}function I8(e){if(!e||typeof e!="object")return`${e}`;let t=e.name==null?"":`${e.name}`,r=OU(e);return!r||r===t?t:`${t} (${r})`}function NU(e){return!B8(e)}function LU(cron){if(!(!cron||!te.env.isNode))try{let{CronTime}=eval('require("cron")');new CronTime(cron)}catch(e){throw new Fa("INVALID_ARTIFACT_CRON",`Artifact cron ${cron} is invalid.`,`Reason: ${e.message??e}`)}}function UU(e){if(!e||typeof e!="object")return e;let t=Rw(e);return t?(LU(t),e.cron=t,e):(delete e.cron,e)}function HU(){xw.forEach(e=>e.stop()),xw.clear()}async function qU(e,t,r){if(Pw.has(e)){te.info(`[ARTIFACT CRON] ${t} ${r} skipped: previous run is still running`);return}Pw.add(e);try{te.info(`[ARTIFACT CRON] ${t} ${r} started`),await Tw(e),te.info(`[ARTIFACT CRON] ${t} ${r} finished`)}catch(n){te.error(`[ARTIFACT CRON] ${t} ${r} error: ${n.message??n}`)}finally{Pw.delete(e)}}function MU(artifact){let cron=Rw(artifact),name=artifact.name,logName=I8(artifact),{CronJob}=eval('require("cron")');try{let e=new CronJob(cron,async function(){await qU(name,logName,cron)},null,!0);xw.set(name,e),te.info(`[ARTIFACT CRON] ${logName} ${cron} scheduled`)}catch(e){te.error(`[ARTIFACT CRON] ${logName} ${cron} schedule error: ${e.message??e}`)}}function $8(){if(!te.env.isNode||!Tw)return;HU();let e=te.read(Ca);(Array.isArray(e)?e:[]).filter(r=>r.sync&&r.source).filter(B8).forEach(MU)}function Qre(e){te.env.isNode&&(Tw=e,$8())}var nne=P(x());function Kr(e,t,r="name"){return e.find(n=>n[r]===t)}var hwe=P(x());var ine=P(x()),kw=0;function Yr(e){return KU(jU(VU(e)))}function jU(e){return GU(WU(zU(e),e.length*8))}function KU(e){try{}catch{kw=0}for(var t=kw?"0123456789ABCDEF":"0123456789abcdef",r="",n,i=0;i>>4&15)+t.charAt(n&15);return r}function VU(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 zU(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function WU(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 YU(e,t){return e<>>32-t}var Bne=P(x()),p1=P(j8()),bH=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,AH=/^(([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 Nr(e){return bH.test(e)}function mr(e){return AH.test(e)}function K8(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 Lt(e,t){return et(e)?e:t}function hl(e){return typeof e<"u"&&e!==null}function Ia(e,t){return hl(e)?e:t}function $a(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function SH(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function ad(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,i]=r.split("-").map(Number);return SH(n,i)}else return Number(r)}function V8(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function g1(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 xne=P(x());var Ww=class{constructor(){te.read(Vc)||te.write("{}",Vc);try{this.resourceCache=JSON.parse(te.read(Vc))}catch(t){te.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Vc} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},te.write("{}",Vc)}this._cleanup()}_cleanup(t,r){let n=Gw(r)??0,i=!1,o=Date.now();Object.entries(this.resourceCache).forEach(s=>{let[a,u]=s;(!u.time||u.time0?t:null}function _H(){let t=te.read(ar)?.resourceCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:36e5}var Xr=new Ww;var One=P(x());var Xw=class{constructor(){te.read(zc)||te.write("{}",zc);try{this.resourceCache=JSON.parse(te.read(zc))}catch(t){te.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${zc} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},te.write("{}",zc)}this._cleanup()}_cleanup(t,r){let n=Yw(r)??0,i=!1,o=Date.now();Object.entries(this.resourceCache).forEach(s=>{let[a,u]=s;(!u.time||u.time0?t:null}function FH(){let t=te.read(ar)?.headersCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:6e4}var ud=new Xw;var Yne=P(x());var Hne=P(x());var z8=10,BH="backendRequestConcurrency",G8=0,IH="backendRequestConcurrencyWaitTime",cd=0,Qw=[];function $H(e){return new Promise(t=>setTimeout(t,e))}function PH(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return z8;let t=Number(e);return!Number.isInteger(t)||t<1?z8:t}function xH(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return G8;let t=Number(e);return!Number.isInteger(t)||t<0?G8:t}function Zw(){let e=te.read(ar)||{};return PH(e[BH])}function Jw(){let e=te.read(ar)||{};return xH(e[IH])}function TH(e,t){return`active=${cd}, pending=${Qw.length}, limit=${e}, waitTime=${t}ms`}function m1(e,t,r,n){te.log(`[Backend Request Concurrency] ${e}: ${t} (${TH(r,n)})`)}function RH(){let e=Qw.shift();e&&e()}async function kH(e){let t=Zw(),r=Jw();for(;cd>=t;)m1("queued",e,t,r),await new Promise(n=>{Qw.push(n)}),t=Zw(),r=Jw();cd+=1,m1("acquired",e,t,r),r>0&&(m1("waiting before request",e,t,r),await $H(r))}function OH(e){cd=Math.max(0,cd-1),m1("released",e,Zw(),Jw()),RH()}async function dl(e,t="request"){await kH(t);try{return await e()}finally{OH(t)}}function Xc(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 v1(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}=bo(),insecure=$arguments?.insecure?te.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=te.read(ar),proxy=customProxy||defaultProxy;te.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){te.error(`\u89E3\u6790\u81EA\u5B9A\u4E49 ${flowHeaders||$arguments?.flowHeaders?"flowHeaders":"headers"} \u5931\u8D25: ${e}`)}let id=Yr(`${customHeaders?JSON.stringify(customHeaders):userAgent}${url}`),cached=ud.get(id),flowInfo;if(!$arguments?.noCache&&cached)te.info(`\u4F7F\u7528\u7F13\u5B58\u7684\u6D41\u91CF\u4FE1\u606F: ${url}, ${customHeaders?JSON.stringify(customHeaders):userAgent}`),flowInfo=cached;else{let e=Da();if(flowUrl){let t;try{te.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 dl(()=>e.get({url,headers:customHeaders||{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?$a(proxy):{},...insecure||{}}),"flow body GET");if(i<200||i>=400)throw new Error(`statusCode: ${i}`);t=r;let o=pl(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(te.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=Xc(t),i=pl(n);if(Number.isFinite(i?.total)&&Number.isFinite(i?.usage?.download)&&Number.isFinite(i?.usage?.upload))te.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){te.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{te.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 dl(()=>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?$a(proxy):{},...insecure||{}}),"flow headers HEAD");flowInfo=Xc(t)}catch(t){te.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){te.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 dl(()=>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?$a(proxy):{},...insecure||{}}),"flow headers GET");flowInfo=Xc(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&ud.set(id,flowInfo,$arguments?.headersCacheTtl?$arguments?.headersCacheTtl*1e3:void 0)}return flowInfo}function pl(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,f=e.match(/reset_day=([0-9]+)/),h=f?Number(f[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:h,appUrl:p,planName:v}}function fd(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}:fd(e/1024,r[++n])}function w1(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){te.error(`getRmainingDays failed: ${t.message??t}`)}}function Y8(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 f=decodeURIComponent(u);if(["upload","download","total","expire","reset_day"].includes(a))try{f=Number(f),["expire","reset_day"].includes(a)&&(f<=0||!Number.isFinite(f))?f="":["upload","download","total"].includes(a)&&!Number.isFinite(f)?f=0:f=f.toFixed(0)}catch(h){te.error(`Failed to convert value for key "${a}=${u}": ${h.message??h}`)}r.set(a,f)}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 te.error(`normalizeFlowHeader failed: ${r.message??r}`),t?{"subscription-userinfo":e}:e}}var rle=P(x());var Zfe=P(x());var Gfe=P(x(),1);var $fe=P(x(),1);var zce=P(x(),1);var sse=P(x(),1);var Zne=P(x(),1),y1=Symbol.for("yaml.alias"),E1=Symbol.for("yaml.document"),Oi=Symbol.for("yaml.map"),ey=Symbol.for("yaml.pair"),Xs=Symbol.for("yaml.scalar"),Pa=Symbol.for("yaml.seq"),ds=Symbol.for("yaml.node.type"),Ni=e=>!!e&&typeof e=="object"&&e[ds]===y1,Li=e=>!!e&&typeof e=="object"&&e[ds]===E1,Ui=e=>!!e&&typeof e=="object"&&e[ds]===Oi,kt=e=>!!e&&typeof e=="object"&&e[ds]===ey,Dt=e=>!!e&&typeof e=="object"&&e[ds]===Xs,Hi=e=>!!e&&typeof e=="object"&&e[ds]===Pa;function Yt(e){if(e&&typeof e=="object")switch(e[ds]){case Oi:case Pa:return!0}return!1}function Ut(e){if(e&&typeof e=="object")switch(e[ds]){case y1:case Oi:case Xs:case Pa:return!0}return!1}var b1=e=>(Dt(e)||Yt(e))&&!!e.anchor;var ese=P(x(),1);var Is=Symbol("break visit"),X8=Symbol("skip children"),Do=Symbol("remove node");function Fo(e,t){let r=Z8(t);Li(e)?gl(null,e.contents,r,Object.freeze([e]))===Do&&(e.contents=null):gl(null,e,r,Object.freeze([]))}Fo.BREAK=Is;Fo.SKIP=X8;Fo.REMOVE=Do;function gl(e,t,r,n){let i=J8(e,t,r,n);if(Ut(i)||kt(i))return Q8(e,n,i),gl(e,i,r,n);if(typeof i!="symbol"){if(Yt(t)){n=Object.freeze(n.concat(t));for(let o=0;oe.replace(/[!,[\]{}]/g,t=>NH[t]),Bo=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+LH(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&&Ut(t.contents)){let o={};Fo(t.contents,(s,a)=>{Ut(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(` `)}};Bo.defaultYaml={explicit:!1,version:"1.2"};Bo.defaultTags={"!!":"tag:yaml.org,2002:"};var vue=P(x(),1);var _se=P(x(),1);var use=P(x(),1);function S1(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 ty(e){let t=new Set;return Fo(e,{Value(r,n){n.anchor&&t.add(n.anchor)}}),t}function ry(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}function eC(e,t){let r=[],n=new Map,i=null;return{onAnchor:o=>{r.push(o),i??(i=ty(e));let s=ry(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)||Yt(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 wse=P(x(),1);var fse=P(x(),1);function ku(e,t,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let i=0,o=n.length;iZr(n,String(i),r));if(e&&typeof e.toJSON=="function"){if(!r||!b1(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 Ou=class{constructor(t){Object.defineProperty(this,ds,{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(!Li(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=Zr(this,"",s);if(typeof i=="function")for(let{count:u,res:f}of s.anchors.values())i(f,u);return typeof o=="function"?ku(o,{"":a},"",a):a}};var xa=class extends Ou{constructor(t){super(y1),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=[],Fo(t,{Node:(o,s)=>{(Ni(s)||b1(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||(Zr(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=C1(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(S1(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 C1(e,t,r){if(Ni(t)){let n=t.resolve(e),i=r&&n&&r.get(n);return i?i.count*i.aliasCount:0}else if(Yt(t)){let n=0;for(let i of t.items){let o=C1(e,i,r);o>n&&(n=o)}return n}else if(kt(t)){let n=C1(e,t.key,r),i=C1(e,t.value,r);return Math.max(n,i)}return 1}var Hse=P(x(),1);var kse=P(x(),1);var $se=P(x(),1);var _1=e=>!e||typeof e!="function"&&typeof e!="object",Ze=class extends Ou{constructor(t){super(Xs),this.value=t}toJSON(t,r){return r?.keep?this.value:Zr(this.value,t,r)}toString(){return String(this.value)}};Ze.BLOCK_FOLDED="BLOCK_FOLDED";Ze.BLOCK_LITERAL="BLOCK_LITERAL";Ze.PLAIN="PLAIN";Ze.QUOTE_DOUBLE="QUOTE_DOUBLE";Ze.QUOTE_SINGLE="QUOTE_SINGLE";var UH="tag:yaml.org,2002:";function HH(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 Ta(e,t,r){if(Li(e)&&(e=e.contents),Ut(e))return e;if(kt(e)){let m=r.schema[Oi].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 xa(u.anchor);u={anchor:null,node:null},a.set(e,u)}t?.startsWith("!!")&&(t=UH+t.slice(2));let f=HH(e,t,s.tags);if(!f){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let m=new Ze(e);return u&&(u.node=m),m}f=e instanceof Map?s[Oi]:Symbol.iterator in Object(e)?s[Pa]:s[Oi]}o&&(o(f),delete r.onTagObj);let h=f?.createNode?f.createNode(r.schema,e,r):typeof f?.nodeClass?.from=="function"?f.nodeClass.from(r.schema,e,r):new Ze(e);return t?h.tag=t:f.default||(h.tag=f.tag),u&&(u.node=h),h}function ld(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 Ta(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 wl=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,vl=class extends Ou{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=>Ut(n)||kt(n)?n.clone(t):n),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(wl(t))this.add(r);else{let[n,...i]=t,o=this.get(n,!0);if(Yt(o))o.addIn(i,r);else if(o===void 0&&this.schema)this.set(n,ld(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(Yt(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:Yt(o)?o.getIn(i,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!kt(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 Yt(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(Yt(o))o.setIn(i,r);else if(o===void 0&&this.schema)this.set(n,ld(this.schema,i,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}};var _ie=P(x(),1);var oie=P(x(),1);var eie=P(x(),1);var Mse=P(x(),1),tC=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function pi(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Io=(e,t,r)=>e.endsWith(` `)?pi(r,t):r.includes(` `)?` `+pi(r,t):(e.endsWith(" ")?"":" ")+r;var Wse=P(x(),1);var Kse=P(x(),1),ny="flow",D1="block",hd="quoted";function dd(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)?f.push(0):m=i-n);let p,d,v=!1,g=-1,y=-1,w=-1;r===D1&&(g=rC(e,g,t.length),g!==-1&&(m=g+u));for(let C;C=e[g+=1];){if(r===hd&&C==="\\"){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(C===` `)r===D1&&(g=rC(e,g,t.length)),m=g+t.length+u,p=void 0;else{if(C===" "&&d&&d!==" "&&d!==` `&&d!==" "){let D=e[g+1];D&&D!==" "&&D!==` `&&D!==" "&&(p=g)}if(g>=m)if(p)f.push(p),m=p+u,p=void 0;else if(r===hd){for(;d===" "||d===" ";)d=C,C=e[g+=1],v=!0;let D=g>w+1?g-2:y-1;if(h[D])return e;f.push(D),h[D]=!0,m=D+u,p=void 0}else v=!0}d=C}if(v&&a&&a(),f.length===0)return e;s&&s();let E=e.slice(0,f[0]);for(let C=0;C({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),I1=e=>/^(%|---|\.\.\.)/m.test(e);function qH(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 pd(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=t,i=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(I1(e)?" ":""),s="",a=0;for(let u=0,f=r[u];f;f=r[++u])if(f===" "&&r[u+1]==="\\"&&r[u+2]==="n"&&(s+=r.slice(a,u)+"\\ ",u+=1,a=u,f="\\"),f==="\\")switch(r[u+1]){case"u":{s+=r.slice(a,u);let h=r.substr(u+2,4);switch(h){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:h.substr(0,2)==="00"?s+="\\x"+h.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 B=r[p-1];if(B!==` `&&B!==" "&&B!==" ")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(iy,`$&${f}`));let g=!1,y,w=-1;for(y=0;y{H=!0});let S=dd(`${E}${B}${d}`,f,D1,V);if(!H)return`>${D} ${f}${S}`}return r=r.replace(/\n+/g,`$&${f}`),`|${D} ${f}${E}${r}${d}`}function MH(e,t,r,n){let{type:i,value:o}=e,{actualString:s,implicitKey:a,indent:u,indentStep:f,inFlow:h}=t;if(a&&o.includes(` `)||h&&/[[\]{},]/.test(o))return yl(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||h||!o.includes(` `)?yl(o,t):F1(e,t,r,n);if(!a&&!h&&i!==Ze.PLAIN&&o.includes(` `))return F1(e,t,r,n);if(I1(o)){if(u==="")return t.forceBlockIndent=!0,F1(e,t,r,n);if(a&&u===f)return yl(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 yl(o,t)}return a?m:dd(m,u,ny,B1(t,!1))}function Zc(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!==Ze.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(a=Ze.QUOTE_DOUBLE);let u=h=>{switch(h){case Ze.BLOCK_FOLDED:case Ze.BLOCK_LITERAL:return i||o?yl(s.value,t):F1(s,t,r,n);case Ze.QUOTE_DOUBLE:return pd(s.value,t);case Ze.QUOTE_SINGLE:return sy(s.value,t);case Ze.PLAIN:return MH(s,t,r,n);default:return null}},f=u(a);if(f===null){let{defaultKeyType:h,defaultStringType:m}=t.options,p=i&&h||m;if(f=u(p),f===null)throw new Error(`Unsupported default string type ${p}`)}return f}function $1(e,t){let r=Object.assign({blockQuote:!0,commentString:tC,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 jH(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 KH(e,t,{anchors:r,doc:n}){if(!n.directives)return"";let i=[],o=(Dt(e)||Yt(e))&&e.anchor;o&&S1(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 Ra(e,t,r,n){if(kt(e))return e.toString(t,r,n);if(Ni(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=Ut(e)?e:t.doc.createNode(e,{onTagObj:u=>i=u});i??(i=jH(t.doc.schema.tags,o));let s=KH(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)?Zc(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 nC({key:e,value:t},r,n,i){let{allNullValues:o,doc:s,indent:a,indentStep:u,options:{commentString:f,indentSeq:h,simpleKeys:m}}=r,p=Ut(e)&&e.comment||null;if(m){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(Yt(e)||!Ut(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||Yt(e)||(Dt(e)?e.type===Ze.BLOCK_FOLDED||e.type===Ze.BLOCK_LITERAL:typeof e=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!d&&(m||!o),indent:a+u});let v=!1,g=!1,y=Ra(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+=Io(y,r.indent,f(p)):g&&i&&i(),y;v&&(p=null),d?(p&&(y+=Io(y,r.indent,f(p))),y=`? ${y} ${a}:`):(y=`${y}:`,p&&(y+=Io(y,r.indent,f(p))));let w,E,C;Ut(t)?(w=!!t.spaceBefore,E=t.commentBefore,C=t.comment):(w=!1,E=null,C=null,t&&typeof t=="object"&&(t=s.createNode(t))),r.implicitKey=!1,!d&&!p&&Dt(t)&&(r.indentAtStart=y.length+1),g=!1,!h&&u.length>=2&&!r.inFlow&&!d&&Hi(t)&&!t.flow&&!t.tag&&!t.anchor&&(r.indent=r.indent.substring(2));let D=!1,B=Ra(t,r,()=>D=!0,()=>g=!0),H=" ";if(p||w||E){if(H=w?` `:"",E){let V=f(E);H+=` ${pi(V,r.indent)}`}B===""&&!r.inFlow?H===` `&&C&&(H=` `):H+=` ${r.indent}`}else if(!d&&Yt(t)){let V=B[0],S=B.indexOf(` `),I=S!==-1,U=r.inFlow??t.flow??t.items.length===0;if(I||!U){let R=!1;if(I&&(V==="&"||V==="!")){let O=B.indexOf(" ");V==="&"&&O!==-1&&Oe===x1||typeof e=="symbol"&&e.description===x1,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ze(Symbol(x1)),{addToJSMap:ay}),stringify:()=>x1},sC=(e,t)=>(qi.identify(t)||Dt(t)&&(!t.type||t.type===Ze.PLAIN)&&qi.identify(t.value))&&e?.doc.schema.tags.some(r=>r.tag===qi.tag&&r.default);function ay(e,t,r){let n=iC(e,r);if(Hi(n))for(let i of n.items)oy(e,t,i);else if(Array.isArray(n))for(let i of n)oy(e,t,i);else oy(e,t,n)}function oy(e,t,r){let n=iC(e,r);if(!Ui(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 iC(e,t){return e&&Ni(t)?t.resolve(e.doc,e):t}function T1(e,t,{key:r,value:n}){if(Ut(r)&&r.addToJSMap)r.addToJSMap(e,t,n);else if(sC(e,r))ay(e,t,n);else{let i=Zr(r,"",e);if(t instanceof Map)t.set(i,Zr(n,i,e));else if(t instanceof Set)t.add(i);else{let o=VH(r,i,e),s=Zr(n,o,e);o in t?Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0}):t[o]=s}}return t}function VH(e,t,r){if(t===null)return"";if(typeof t!="object")return String(t);if(Ut(e)&&r?.doc){let n=$1(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)+'..."'),P1(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 El(e,t,r){let n=Ta(e,void 0,r),i=Ta(t,void 0,r);return new Ir(n,i)}var Ir=class e{constructor(t,r=null){Object.defineProperty(this,ds,{value:ey}),this.key=t,this.value=r}clone(t){let{key:r,value:n}=this;return Ut(r)&&(r=r.clone(t)),Ut(n)&&(n=n.clone(t)),new e(r,n)}toJSON(t,r){let n=r?.mapAsMap?new Map:{};return T1(r,n,this)}toString(t,r,n){return t?.doc?nC(this,t,r,n):JSON.stringify(this)}};var Qae=P(x(),1);var Mie=P(x(),1);var Lie=P(x(),1);var $ie=P(x(),1);function k1(e,t,r){return(t.inFlow??e.flow?GH:zH)(e,t,r)}function zH({comment:e,items:t},r,{blockItemPrefix:n,flowChars:i,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:u,options:{commentString:f}}=r,h=Object.assign({},r,{indent:o,type:null}),m=!1,p=[];for(let v=0;vy=null,()=>m=!0);y&&(w+=Io(w,o,f(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);f||(f=m.length>h||w.includes(` `)),v0&&(f||(f=m.reduce((E,C)=>E+C.length+2,2)+(w.length+2)>t.options.lineWidth)),f&&(w+=",")),y&&(w+=Io(w,n,a(y))),m.push(w),h=m.length}let{start:p,end:d}=r;if(m.length===0)return p+d;if(!f){let v=m.reduce((g,y)=>g+y.length+2,2);f=t.options.lineWidth>0&&v>t.options.lineWidth}if(f){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 R1({indent:e,options:{commentString:t}},r,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){let o=pi(t(n),e);r.push(o.trimStart())}}function Nu(e,t){let r=Dt(t)?t.value:t;for(let n of e)if(kt(n)&&(n.key===t||n.key===r||Dt(n.key)&&n.key.value===r))return n}var Lr=class extends vl{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Oi,t),this.items=[]}static from(t,r,n){let{keepUndefined:i,replacer:o}=n,s=new this(t),a=(u,f)=>{if(typeof o=="function")f=o.call(r,u,f);else if(Array.isArray(o)&&!o.includes(u))return;(f!==void 0||i)&&s.items.push(El(u,f,n))};if(r instanceof Map)for(let[u,f]of r)a(u,f);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;kt(t)?n=t:!t||typeof t!="object"||!("key"in t)?n=new Ir(t,t?.value):n=new Ir(t.key,t.value);let i=Nu(this.items,n.key),o=this.schema?.sortMapEntries;if(i){if(!r)throw new Error(`Key ${n.key} already set`);Dt(i.value)&&_1(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=Nu(this.items,t);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(t,r){let i=Nu(this.items,t)?.value;return(!r&&Dt(i)?i.value:i)??void 0}has(t){return!!Nu(this.items,t)}set(t,r){this.add(new Ir(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)T1(r,i,o);return i}toString(t,r,n){if(!t)return JSON.stringify(this);for(let i of this.items)if(!kt(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})),k1(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:n,onComment:r})}};var Mi={collection:"map",default:!0,nodeClass:Lr,tag:"tag:yaml.org,2002:map",resolve(e,t){return Ui(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,r)=>Lr.from(e,t,r)};var eoe=P(x(),1);var Xie=P(x(),1);var zn=class extends vl{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Pa,t),this.items=[]}add(t){this.items.push(t)}delete(t){let r=O1(t);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(t,r){let n=O1(t);if(typeof n!="number")return;let i=this.items[n];return!r&&Dt(i)?i.value:i}has(t){let r=O1(t);return typeof r=="number"&&r=0?t:null}var ji={collection:"seq",default:!0,nodeClass:zn,tag:"tag:yaml.org,2002:seq",resolve(e,t){return Hi(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,r)=>zn.from(e,t,r)};var noe=P(x(),1);var Lu={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),Zc(e,t,r,n)}};var zae=P(x(),1);var ooe=P(x(),1);var Jc={identify:e=>e==null,createNode:()=>new Ze(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ze(null),stringify:({source:e},t)=>typeof e=="string"&&Jc.test.test(e)?e:t.options.nullStr};var coe=P(x(),1);var gd={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Ze(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&gd.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 goe=P(x(),1);var loe=P(x(),1);function Gn({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 N1={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:Gn},L1={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():Gn(e)}},U1={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 Ze(parseFloat(e)),r=e.indexOf(".");return r!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-r-1),t},stringify:Gn};var woe=P(x(),1);var H1=e=>typeof e=="bigint"||Number.isInteger(e),uy=(e,t,r,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),r);function oC(e,t,r){let{value:n}=e;return H1(n)&&n>=0?r+n.toString(t):Gn(e)}var q1={identify:e=>H1(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=>oC(e,8,"0o")},M1={identify:H1,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>uy(e,0,10,r),stringify:Gn},j1={identify:e=>H1(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=>oC(e,16,"0x")};var Foe=P(x(),1);var aC=[Mi,ji,Lu,Jc,gd,q1,M1,j1,N1,L1,U1];var xoe=P(x(),1);function uC(e){return typeof e=="bigint"||Number.isInteger(e)}var K1=({value:e})=>JSON.stringify(e),WH=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:K1},{identify:e=>e==null,createNode:()=>new Ze(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:K1},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:K1},{identify:uC,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})=>uC(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:K1}],YH={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},cC=[Mi,ji].concat(WH,YH);var Ooe=P(x(),1);var md={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 Ir(new Ze(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]=kt(n)?n:new Ir(n)}}else t("Expected a sequence for this tag");return e}function fy(e,t,r){let{replacer:n}=r,i=new zn(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 f=Object.keys(s);if(f.length===1)a=f[0],u=s[a];else throw new TypeError(`Expected tuple with one key, not ${f.length} keys`)}else a=s;i.items.push(El(a,u,r))}return i}var vd={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:cy,createNode:fy};var bl=class e extends zn{constructor(){super(),this.add=Lr.prototype.add.bind(this),this.delete=Lr.prototype.delete.bind(this),this.get=Lr.prototype.get.bind(this),this.has=Lr.prototype.has.bind(this),this.set=Lr.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(kt(i)?(o=Zr(i.key,"",r),s=Zr(i.value,o,r)):o=Zr(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=fy(t,r,n),o=new this;return o.items=i.items,o}};bl.tag="tag:yaml.org,2002:omap";var wd={collection:"seq",identify:e=>e instanceof Map,nodeClass:bl,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=cy(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 bl,r)},createNode:(e,t,r)=>bl.from(e,t,r)};var Bae=P(x(),1);var Joe=P(x(),1);function fC({value:e,source:t},r){return t&&(e?ly:hy).test.test(t)?t:e?r.options.trueStr:r.options.falseStr}var ly={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 Ze(!0),stringify:fC},hy={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 Ze(!1),stringify:fC};var rae=P(x(),1);var lC={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:Gn},hC={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():Gn(e)}},dC={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 Ze(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:Gn};var iae=P(x(),1);var yd=e=>typeof e=="bigint"||Number.isInteger(e);function V1(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 dy(e,t,r){let{value:n}=e;if(yd(n)){let i=n.toString(t);return n<0?"-"+r+i.substr(1):r+i}return Gn(e)}var pC={identify:yd,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>V1(e,2,2,r),stringify:e=>dy(e,2,"0b")},gC={identify:yd,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>V1(e,1,8,r),stringify:e=>dy(e,8,"0")},mC={identify:yd,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>V1(e,0,10,r),stringify:Gn},vC={identify:yd,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>V1(e,2,16,r),stringify:e=>dy(e,16,"0x")};var fae=P(x(),1);var Al=class e extends Lr{constructor(t){super(t),this.tag=e.tag}add(t){let r;kt(t)?r=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?r=new Ir(t.key,null):r=new Ir(t,null),Nu(this.items,r.key)||this.items.push(r)}get(t,r){let n=Nu(this.items,t);return!r&&kt(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=Nu(this.items,t);n&&!r?this.items.splice(this.items.indexOf(n),1):!n&&r&&this.items.push(new Ir(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(El(s,null,n));return o}};Al.tag="tag:yaml.org,2002:set";var Ed={collection:"map",identify:e=>e instanceof Set,nodeClass:Al,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>Al.from(e,t,r),resolve(e,t){if(Ui(e)){if(e.hasAllNullValues(!0))return Object.assign(new Al,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};var dae=P(x(),1);function py(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 wC(e){let{value:t}=e,r=s=>s;if(typeof t=="bigint")r=s=>BigInt(s);else if(isNaN(t)||!isFinite(t))return Gn(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 z1={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})=>py(e,r),stringify:wC},G1={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=>py(e,!1),stringify:wC},Sl={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(Sl.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,f=Date.UTC(r,n-1,i,o||0,s||0,a||0,u),h=t[8];if(h&&h!=="Z"){let m=py(h,!1);Math.abs(m)<30&&(m*=60),f-=6e4*m}return new Date(f)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var gy=[Mi,ji,Lu,Jc,ly,hy,pC,gC,mC,vC,lC,hC,dC,md,qi,wd,vd,Ed,z1,G1,Sl];var yC=new Map([["core",aC],["failsafe",[Mi,ji,Lu]],["json",cC],["yaml11",gy],["yaml-1.1",gy]]),EC={binary:md,bool:gd,float:U1,floatExp:L1,floatNaN:N1,floatTime:G1,int:M1,intHex:j1,intOct:q1,intTime:z1,map:Mi,merge:qi,null:Jc,omap:wd,pairs:vd,seq:ji,set:Ed,timestamp:Sl},bC={"tag:yaml.org,2002:binary":md,"tag:yaml.org,2002:merge":qi,"tag:yaml.org,2002:omap":wd,"tag:yaml.org,2002:pairs":vd,"tag:yaml.org,2002:set":Ed,"tag:yaml.org,2002:timestamp":Sl};function W1(e,t,r){let n=yC.get(t);if(n&&!e)return r&&!n.includes(qi)?n.concat(qi):n.slice();let i=n;if(!i)if(Array.isArray(e))i=[];else{let o=Array.from(yC.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(qi)),i.reduce((o,s)=>{let a=typeof s=="string"?EC[s]:s;if(!a){let u=JSON.stringify(s),f=Object.keys(EC).map(h=>JSON.stringify(h)).join(", ");throw new Error(`Unknown custom tag ${u}; use one of ${f}`)}return o.includes(a)||o.push(a),o},[])}var XH=(e,t)=>e.keyt.key?1:0,bd=class e{constructor({compat:t,customTags:r,merge:n,resolveKnownTags:i,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(t)?W1(t,"compat"):t?W1(null,t):null,this.name=typeof o=="string"&&o||"core",this.knownTags=i?bC:{},this.tags=W1(r,this.name,n),this.toStringOptions=a??null,Object.defineProperty(this,Oi,{value:Mi}),Object.defineProperty(this,Xs,{value:Lu}),Object.defineProperty(this,Pa,{value:ji}),this.sortMapEntries=typeof s=="function"?s:s===!0?XH:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};var sue=P(x(),1);function AC(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=$1(e,t),{commentString:o}=i.options;if(e.commentBefore){r.length!==1&&r.unshift("");let u=o(e.commentBefore);r.unshift(pi(u,""))}let s=!1,a=null;if(e.contents){if(Ut(e.contents)){if(e.contents.spaceBefore&&n&&r.push(""),e.contents.commentBefore){let h=o(e.contents.commentBefore);r.push(pi(h,""))}i.forceBlockIndent=!!e.comment,a=e.contents.comment}let u=a?void 0:()=>s=!0,f=Ra(e.contents,i,()=>a=null,u);a&&(f+=Io(f,"",o(a))),(f[0]==="|"||f[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${f}`:r.push(f)}else r.push(Ra(e.contents,i));if(e.directives?.docEnd)if(e.comment){let u=o(e.comment);u.includes(` `)?(r.push("..."),r.push(pi(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(pi(o(u),"")))}return r.join(` `)+` `}var ka=class e{constructor(t,r,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ds,{value:E1});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 Bo({version:s}),this.setSchema(s,n),this.contents=t===void 0?null:this.createNode(t,i,n)}clone(){let t=Object.create(e.prototype,{[ds]:{value:E1}});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=Ut(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){Cl(this.contents)&&this.contents.add(t)}addIn(t,r){Cl(this.contents)&&this.contents.addIn(t,r)}createAlias(t,r){if(!t.anchor){let n=ty(this);t.anchor=!r||n.has(r)?ry(r||"a",n):r}return new xa(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:f,tag:h}=n??{},{onAnchor:m,setAnchors:p,sourceObjects:d}=eC(this,s||"a"),v={aliasDuplicateObjects:o??!0,keepUndefined:u??!1,onAnchor:m,onTagObj:f,replacer:i,schema:this.schema,sourceObjects:d},g=Ta(t,h,v);return a&&Yt(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 Ir(i,o)}delete(t){return Cl(this.contents)?this.contents.delete(t):!1}deleteIn(t){return wl(t)?this.contents==null?!1:(this.contents=null,!0):Cl(this.contents)?this.contents.deleteIn(t):!1}get(t,r){return Yt(this.contents)?this.contents.get(t,r):void 0}getIn(t,r){return wl(t)?!r&&Dt(this.contents)?this.contents.value:this.contents:Yt(this.contents)?this.contents.getIn(t,r):void 0}has(t){return Yt(this.contents)?this.contents.has(t):!1}hasIn(t){return wl(t)?this.contents!==void 0:Yt(this.contents)?this.contents.hasIn(t):!1}set(t,r){this.contents==null?this.contents=ld(this.schema,[t],r):Cl(this.contents)&&this.contents.set(t,r)}setIn(t,r){wl(t)?this.contents=r:this.contents==null?this.contents=ld(this.schema,Array.from(t),r):Cl(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 Bo({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 Bo({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 bd(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=Zr(this.contents,r??"",a);if(typeof o=="function")for(let{count:f,res:h}of a.anchors.values())o(h,f);return typeof s=="function"?ku(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 AC(this,t)}};function Cl(e){if(Yt(e))return!0;throw new Error("Expected a YAML collection as document contents")}var yue=P(x(),1),Ad=class extends Error{constructor(t,r,n,i){super(),this.name=t,this.code=n,this.message=i,this.pos=r}},Ki=class extends Ad{constructor(t,r,n){super("YAMLParseError",t,r,n)}},Sd=class extends Ad{constructor(t,r,n){super("YAMLWarning",t,r,n)}},my=(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 f=" ".repeat(o)+"^".repeat(a);r.message+=`: ${s} ${f} `}};var Lce=P(x(),1);var xce=P(x(),1);var cce=P(x(),1);var Nue=P(x(),1);var bue=P(x(),1);function $o(e,{flow:t,indicator:r,next:n,offset:i,onError:o,parentIndent:s,startOnNewline:a}){let u=!1,f=a,h=a,m="",p="",d=!1,v=!1,g=null,y=null,w=null,E=null,C=null,D=null,B=null;for(let S of e)switch(v&&(S.type!=="space"&&S.type!=="newline"&&S.type!=="comma"&&o(S.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),g&&(f&&S.type!=="comment"&&S.type!=="newline"&&o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation"),g=null),S.type){case"space":!t&&(r!=="doc-start"||n?.type!=="flow-collection")&&S.source.includes(" ")&&(g=S),h=!0;break;case"comment":{h||o(S,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let I=S.source.substring(1)||" ";m?m+=p+I:m=I,p="",f=!1;break}case"newline":f?m?m+=S.source:(!D||r!=="seq-item-ind")&&(u=!0):p+=S.source,f=!0,d=!0,(y||w)&&(E=S),h=!0;break;case"anchor":y&&o(S,"MULTIPLE_ANCHORS","A node can have at most one anchor"),S.source.endsWith(":")&&o(S.offset+S.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=S,B??(B=S.offset),f=!1,h=!1,v=!0;break;case"tag":{w&&o(S,"MULTIPLE_TAGS","A node can have at most one tag"),w=S,B??(B=S.offset),f=!1,h=!1,v=!0;break}case r:(y||w)&&o(S,"BAD_PROP_ORDER",`Anchors and tags must be after the ${S.source} indicator`),D&&o(S,"UNEXPECTED_TOKEN",`Unexpected ${S.source} in ${t??"collection"}`),D=S,f=r==="seq-item-ind"||r==="explicit-key-ind",h=!1;break;case"comma":if(t){C&&o(S,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),C=S,f=!1,h=!1;break}default:o(S,"UNEXPECTED_TOKEN",`Unexpected ${S.type} token`),f=!1,h=!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&&(f&&g.indent<=s||n?.type==="block-map"||n?.type==="block-seq")&&o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:C,found:D,spaceBefore:u,comment:m,hasNewline:d,anchor:y,tag:w,newlineAfterProp:E,end:V,start:B??V}}var Sue=P(x(),1);function Uu(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(Uu(t.key)||Uu(t.value))return!0}return!1;default:return!0}}var Due=P(x(),1);function Cd(e,t,r){if(t?.type==="flow-collection"){let n=t.end[0];n.indent===e&&(n.source==="]"||n.source==="}")&&Uu(t)&&r(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}var Iue=P(x(),1);function Y1(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 SC="All mapping items must start at the same column";function CC({composeNode:e,composeEmptyNode:t},r,n,i,o){let s=o?.nodeClass??Lr,a=new s(r.schema);r.atRoot&&(r.atRoot=!1);let u=n.offset,f=null;for(let h of n.items){let{start:m,key:p,sep:d,value:v}=h,g=$o(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",SC)),!g.anchor&&!g.tag&&!d){f=g.end,g.comment&&(a.comment?a.comment+=` `+g.comment:a.comment=g.comment);continue}(g.newlineAfterProp||Uu(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",SC);r.atKey=!0;let w=g.end,E=p?e(r,p,g,i):t(r,w,m,null,g,i);r.schema.compat&&Cd(n.indent,p,i),r.atKey=!1,Y1(r,a.items,E)&&i(w,"DUPLICATE_KEY","Map keys must be unique");let C=$o(d??[],{indicator:"map-value-ind",next:v,offset:E.range[2],onError:i,parentIndent:n.indent,startOnNewline:!p||p.type==="block-scalar"});if(u=C.end,C.found){y&&(v?.type==="block-map"&&!C.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 DC({composeNode:e,composeEmptyNode:t},r,n,i,o){let s=n.start.source==="{",a=s?"flow map":"flow sequence",u=o?.nodeClass??(s?Lr:zn),f=new u(r.schema);f.flow=!0;let h=r.atRoot;h&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let m=n.offset+n.start.source.length;for(let y=0;y0){let y=Po(v,g,r.options.strict,i);y.comment&&(f.comment?f.comment+=` `+y.comment:f.comment=y.comment),f.range=[n.offset,g,y.offset]}else f.range=[n.offset,g,g];return f}function yy(e,t,r,n,i,o){let s=r.type==="block-map"?CC(e,t,r,n,o):r.type==="block-seq"?_C(e,t,r,n,o):DC(e,t,r,n,o),a=s.constructor;return i==="!"||i===a.tagName?(s.tag=a.tagName,s):(i&&(s.tag=i),s)}function FC(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),yy(e,t,r,i,s)}let f=yy(e,t,r,i,s,u),h=u.resolve?.(f,p=>i(o,"TAG_RESOLVE_FAILED",p),t.options)??f,m=Ut(h)?h:new Ze(h);return m.range=f.range,m.tag=s,u?.format&&(m.format=u.format),m}var Ace=P(x(),1);var hce=P(x(),1);function Ey(e,t,r){let n=t.offset,i=ZH(t,e.options.strict,r);if(!i)return{value:"",type:null,comment:"",range:[n,n,n]};let o=i.mode===">"?Ze.BLOCK_FOLDED:Ze.BLOCK_LITERAL,s=t.source?JH(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,f=t.offset+i.length,h=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=Ze.PLAIN,u=QH(o,f);break;case"single-quoted-scalar":a=Ze.QUOTE_SINGLE,u=eq(o,f);break;case"double-quoted-scalar":a=Ze.QUOTE_DOUBLE,u=tq(o,f);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 h=n+o.length,m=Po(s,h,t,r);return{value:u,type:a,comment:m.comment,range:[n,h,m.offset]}}function QH(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}`),BC(e)}function eq(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),BC(e.slice(1,-1)).replace(/''/g,"'")}function BC(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 rq(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 nq={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:` `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function sq(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 Ay(e,t,r,n){let{value:i,type:o,comment:s,range:a}=t.type==="block-scalar"?Ey(e,t,n):by(t,e.options.strict,n),u=r?e.directives.tagName(r.source,m=>n(r,"TAG_RESOLVE_FAILED",m)):null,f;e.options.stringKeys&&e.atKey?f=e.schema[Xs]:u?f=iq(e.schema,i,u,r,n):t.type==="scalar"?f=oq(e,i,t,n):f=e.schema[Xs];let h;try{let m=f.resolve(i,p=>n(r??t,"TAG_RESOLVE_FAILED",p),e.options);h=Dt(m)?m:new Ze(m)}catch(m){let p=m instanceof Error?m.message:String(m);n(r??t,"TAG_RESOLVE_FAILED",p),h=new Ze(i)}return h.range=a,h.source=i,o&&(h.type=o),u&&(h.tag=u),f.format&&(h.format=f.format),s&&(h.comment=s),h}function iq(e,t,r,n,i){if(r==="!")return e[Xs];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[Xs])}function oq({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[Xs];if(r.compat){let a=r.compat.find(u=>u.default&&u.test?.test(n))??r[Xs];if(s.tag!==a.tag){let u=t.tagString(s.tag),f=t.tagString(a.tag),h=`Value may be parsed as either ${u} or ${f}`;o(i,"TAG_RESOLVE_FAILED",h,!0)}}return s}var Cce=P(x(),1);function IC(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 aq={composeNode:Sy,composeEmptyNode:X1};function Sy(e,t,r,n){let i=e.atKey,{spaceBefore:o,comment:s,anchor:a,tag:u}=r,f,h=!0;switch(t.type){case"alias":f=uq(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":f=Ay(e,t,u,n),a&&(f.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{f=FC(aq,e,t,r,n),a&&(f.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),h=!1}}return f??(f=X1(e,t.offset,void 0,null,r,n)),a&&f.anchor===""&&n(a,"BAD_ALIAS","Anchor cannot be an empty string"),i&&e.options.stringKeys&&(!Dt(f)||typeof f.value!="string"||f.tag&&f.tag!=="tag:yaml.org,2002:str")&&n(u??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(f.spaceBefore=!0),s&&(t.type==="scalar"&&t.source===""?f.comment=s:f.commentBefore=s),e.options.keepSourceTokens&&h&&(f.srcToken=t),f}function X1(e,t,r,n,{spaceBefore:i,comment:o,anchor:s,tag:a,end:u},f){let h={type:"scalar",offset:IC(t,r,n),indent:-1,source:""},m=Ay(e,h,a,f);return s&&(m.anchor=s.source.substring(1),m.anchor===""&&f(s,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(m.spaceBefore=!0),o&&(m.comment=o,m.range[2]=u),m}function uq({options:e},{offset:t,source:r,end:n},i){let o=new xa(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=Po(n,s,e.strict,i);return o.range=[t,s,a.offset],a.comment&&(o.comment=a.comment),o}function $C(e,t,{offset:r,start:n,value:i,end:o},s){let a=Object.assign({_directives:t},e),u=new ka(void 0,a),f={atKey:!1,atRoot:!0,directives:u.directives,options:u.options,schema:u.schema},h=$o(n,{indicator:"doc-start",next:i??o?.[0],offset:r,onError:s,parentIndent:0,startOnNewline:!0});h.found&&(u.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!h.hasNewline&&s(h.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),u.contents=i?Sy(f,i,h,s):X1(f,h.end,n,null,h,s);let m=u.contents.range[2],p=Po(o,m,!1,s);return p.comment&&(u.comment=p.comment),u.range=[r,m,p.offset],u}function _d(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 PC(e){let t="",r=!1,n=!1;for(let i=0;i{let s=_d(r);o?this.warnings.push(new Sd(s,n,i)):this.errors.push(new Ki(s,n,i))},this.directives=new Bo({version:t.version||"1.2"}),this.options=t}decorate(t,r){let{comment:n,afterEmptyLine:i}=PC(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(Yt(o)&&!o.flow&&o.items.length>0){let s=o.items[0];kt(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=_d(t);o[0]+=r,this.onError(o,"BAD_DIRECTIVE",n,i)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let r=$C(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 Ki(_d(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 Ki(_d(t),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;let r=Po(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 Ki(_d(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 ka(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 afe=P(x(),1);var Jce=P(x(),1);var efe=P(x(),1);var rfe=P(x(),1),Cy=Symbol("break visit"),cq=Symbol("skip children"),xC=Symbol("remove item");function Qc(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),TC(Object.freeze([]),e,t)}Qc.BREAK=Cy;Qc.SKIP=cq;Qc.REMOVE=xC;Qc.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};Qc.parentCollection=(e,t)=>{let r=Qc.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 TC(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 dfe=P(x(),1);function Vi(e){switch(e){case void 0:case" ":case` `:case"\r":case" ":return!0;default:return!1}}var kC=new Set("0123456789ABCDEFabcdef"),lq=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),J1=new Set(",[]{}"),hq=new Set(` ,[]{} \r `),By=e=>!e||hq.has(e),Fd=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==="...")&&Vi(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&tthis.indentValue&&!Vi(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===":")&&Vi(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(By),"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=>Vi(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 Z1,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(Vi(o)||t&&J1.has(o))break;r=n}else if(Vi(i)){let o=this.buffer[n+1];if(i==="\r"&&(o===` `?(n+=1,i=` `,o=this.buffer[n+1]):r=n),o==="#"||t&&J1.has(o))break;if(i===` `){let s=this.continueScalar(n+1);if(s===-1)break;n=Math.max(n,s-2)}}else{if(t&&J1.has(i))break;r=n}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield Z1,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(By),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,n=this.charAt(1);if(Vi(n)||r&&J1.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(;!Vi(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(lq.has(r))r=this.buffer[++t];else if(r==="%"&&kC.has(this.buffer[t+1])&&kC.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 gfe=P(x(),1),Bd=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 eg(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"&&NC(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&&OC(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(Hu(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(LC(r.key)&&!Hu(r.sep,"newline")){let s=_l(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(Hu(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let s=_l(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]}):Hu(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&&!Hu(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)){eg(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||Hu(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=Q1(n),o=_l(i);NC(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=Q1(t),n=_l(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=Q1(t),n=_l(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 Bfe=P(x(),1);function dq(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Bd||null,prettyErrors:t}}function UC(e,t={}){let{lineCounter:r,prettyErrors:n}=dq(t),i=new Id(r?.addNewLine),o=new Dd(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 Ki(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(s.errors.forEach(my(e,r)),s.warnings.forEach(my(e,r))),s}function Iy(e,t,r){let n;typeof t=="function"?n=t:r===void 0&&t&&typeof t=="object"&&(r=t);let i=UC(e,r);if(!i)return null;if(i.warnings.forEach(o=>P1(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 $y(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 Li(e)&&!n?e.toString(r):new ka(e,n,r).toString(r)}var gq={logLevel:"error",merge:!0};function qC(e,t,...r){try{return e(t,...r)}catch{return e(KC(e(t.replace(/!\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function tg(e){return JSON.parse(JSON.stringify(e))}function mq(e){return{...gq,...e||{}}}function vq(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 MC(e,t){return Iy(e,mq(t))}function jC(e,t){return $y(e,vq(t))}function Dl(e,...t){return qC(MC,tg(e),...t)}function wq(e,...t){return qC(MC,tg(e),...t)}function HC(e,...t){return jC(tg(e),...t)}function KC(e,...t){return jC(tg(e),...t)}var Zs={safeLoad:Dl,load:wq,safeDump:HC,dump:KC,parse:Dl,stringify:HC};function $d(e){if(typeof e!="string"||!e.includes("proxies:")||!e.includes("short-id:"))return e;try{let t=Dl(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 yq(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function Eq(){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 Bt.isValid(i)&&!/^\w+:\/\/\w+/im.test(i)&&t.some(o=>i.indexOf(o)!==-1)},parse:function(i){let o=Bt.decode(i);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(o)?o:(te.error("Base64 Pre-processor error: decoded line does not start with protocol"),i)}}}function bq(){return{name:"Fallback Base64 Pre-processor",test:function(n){return Bt.isValid(n)},parse:function(n){let i=Bt.decode(n);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(i)?i:(te.error("Fallback Base64 Pre-processor error: decoded line does not start with protocol"),n)}}}function Aq(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let i=Dl(n);return Array.isArray(i.proxies)||Array.isArray(i["proxy-groups"])},parse:function(n,i){let o=$d(n),{proxies:s}=Dl(o);return(i?`proxies: `:"")+(Array.isArray(s)?s:[]).map(a=>`${i?" - ":""}${JSON.stringify(a)} `).join("")}}}function Sq(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let i=[],o=JSON.parse(Bt.decode(n.split("ssd://")[1])),s=o.port,a=o.encryption,u=o.password,f=o.servers;for(let h=0;h= 0, got ${e}`)}}function Sn(e,t,r=""){let n=nE(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}`,f=s+"expected Uint8Array"+a+", got "+u;throw n?new RangeError(f):new TypeError(f)}return e}function Ma(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Hr(e.outputLen),Hr(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Ll(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 bg(e,t){Sn(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length='+r)}function Ag(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function gs(...e){for(let t=0;t>>t}function jt(e,t){return e<>>32-t>>>0}var XK=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ZK(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function JK(e){for(let t=0;te:JK,U_=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",QK=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Sg(e){if(Sn(e),U_)return e.toHex();let t="";for(let r=0;r=qa._0&&e<=qa._9)return e-qa._0;if(e>=qa.A&&e<=qa.F)return e-(qa.A-10);if(e>=qa.a&&e<=qa.f)return e-(qa.a-10)}function Ld(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(U_)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 Ku(e=32){Hr(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 uE=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var _g=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(Ma(t),Sn(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 _g(t,r).update(n).digest();return e.create=(t,r)=>new _g(t,r),e})();var Sle=P(x(),1);function Ud(e,t,r){return Ma(e),r===void 0&&(r=new Uint8Array(e.outputLen)),ko(e,r,t)}var cE=Uint8Array.of(0),H_=Uint8Array.of();function fE(e,t,r,n=32){Ma(e),Hr(n,"length"),Sn(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=H_:Sn(r,void 0,"info");let s=new Uint8Array(o*i),a=ko.create(e,t),u=a._cloneInto(),f=new Uint8Array(a.outputLen);for(let h=0;hfE(e,Ud(e,t,r),n,i);var Tle=P(x(),1);var Dle=P(x(),1);function q_(e,t,r){return e&t^~e&r}function M_(e,t,r){return e&t^e&r^t&r}var Hd=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=Ul(this.buffer)}update(t){Ll(this),Sn(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;mh.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m>j_&Dg)}:{h:Number(e>>j_&Dg)|0,l:Number(e&Dg)|0}}function K_(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;oe>>>r,hE=(e,t,r)=>e<<32-r|t>>>r,sf=(e,t,r)=>e>>>r|t<<32-r,of=(e,t,r)=>e<<32-r|t>>>r,qd=(e,t,r)=>e<<64-r|t>>>r-32,Md=(e,t,r)=>e>>>r-32|t<<64-r;function Oo(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var V_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),z_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,G_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),W_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,Y_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),X_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;var nV=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]),zu=new Uint32Array(64),dE=class extends Hd{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)zu[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let p=zu[m-15],d=zu[m-2],v=Gi(p,7)^Gi(p,18)^p>>>3,g=Gi(d,17)^Gi(d,19)^d>>>10;zu[m]=g+zu[m-7]+v+zu[m-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let m=0;m<64;m++){let p=Gi(a,6)^Gi(a,11)^Gi(a,25),d=h+p+q_(a,u,f)+nV[m]+zu[m]|0,g=(Gi(n,2)^Gi(n,13)^Gi(n,22))+M_(n,i,o)|0;h=f,f=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,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){gs(zu)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),gs(this.buffer)}},pE=class extends dE{A=ja[0]|0;B=ja[1]|0;C=ja[2]|0;D=ja[3]|0;E=ja[4]|0;F=ja[5]|0;G=ja[6]|0;H=ja[7]|0;constructor(){super(32)}};var Z_=K_(["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))),sV=Z_[0],iV=Z_[1],Gu=new Uint32Array(80),Wu=new Uint32Array(80),gE=class extends Hd{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:f,El:h,Fh:m,Fl:p,Gh:d,Gl:v,Hh:g,Hl:y}=this;return[t,r,n,i,o,s,a,u,f,h,m,p,d,v,g,y]}set(t,r,n,i,o,s,a,u,f,h,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=f|0,this.El=h|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 C=0;C<16;C++,r+=4)Gu[C]=t.getUint32(r),Wu[C]=t.getUint32(r+=4);for(let C=16;C<80;C++){let D=Gu[C-15]|0,B=Wu[C-15]|0,H=sf(D,B,1)^sf(D,B,8)^lE(D,B,7),V=of(D,B,1)^of(D,B,8)^hE(D,B,7),S=Gu[C-2]|0,I=Wu[C-2]|0,U=sf(S,I,19)^qd(S,I,61)^lE(S,I,6),R=of(S,I,19)^Md(S,I,61)^hE(S,I,6),O=G_(V,R,Wu[C-7],Wu[C-16]),q=W_(O,H,U,Gu[C-7],Gu[C-16]);Gu[C]=q|0,Wu[C]=O|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:u,Dh:f,Dl:h,Eh:m,El:p,Fh:d,Fl:v,Gh:g,Gl:y,Hh:w,Hl:E}=this;for(let C=0;C<80;C++){let D=sf(m,p,14)^sf(m,p,18)^qd(m,p,41),B=of(m,p,14)^of(m,p,18)^Md(m,p,41),H=m&d^~m&g,V=p&v^~p&y,S=Y_(E,B,V,iV[C],Wu[C]),I=X_(S,w,D,H,sV[C],Gu[C]),U=S|0,R=sf(n,i,28)^qd(n,i,34)^qd(n,i,39),O=of(n,i,28)^Md(n,i,34)^Md(n,i,39),q=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}=Oo(f|0,h|0,I|0,U|0),f=a|0,h=u|0,a=o|0,u=s|0,o=n|0,s=i|0;let _=V_(U,O,N);n=z_(_,I,R,q),i=_|0}({h:n,l:i}=Oo(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=Oo(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:u}=Oo(this.Ch|0,this.Cl|0,a|0,u|0),{h:f,l:h}=Oo(this.Dh|0,this.Dl|0,f|0,h|0),{h:m,l:p}=Oo(this.Eh|0,this.El|0,m|0,p|0),{h:d,l:v}=Oo(this.Fh|0,this.Fl|0,d|0,v|0),{h:g,l:y}=Oo(this.Gh|0,this.Gl|0,g|0,y|0),{h:w,l:E}=Oo(this.Hh|0,this.Hl|0,w|0,E|0),this.set(n,i,o,s,a,u,f,h,m,p,d,v,g,y,w,E)}roundClean(){gs(Gu,Wu)}destroy(){this.destroyed=!0,gs(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},mE=class extends gE{Ah=Cn[0]|0;Al=Cn[1]|0;Bh=Cn[2]|0;Bl=Cn[3]|0;Ch=Cn[4]|0;Cl=Cn[5]|0;Dh=Cn[6]|0;Dl=Cn[7]|0;Eh=Cn[8]|0;El=Cn[9]|0;Fh=Cn[10]|0;Fl=Cn[11]|0;Gh=Cn[12]|0;Gl=Cn[13]|0;Hh=Cn[14]|0;Hl=Cn[15]|0;constructor(){super(64)}};var qr=aE(()=>new pE,uE(1));var Fg=aE(()=>new mE,uE(3));var c0e=P(x(),1);var kle=P(x(),1);function EE(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function oV(e){if(!EE(e))throw new TypeError("Uint8Array expected")}function tD(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 aV(e){if(typeof e!="function")throw new TypeError("function expected");return!0}function af(e,t){if(typeof t!="string")throw new TypeError(`${e}: string expected`);return!0}function bE(e){if(typeof e!="number")throw new TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw new RangeError(`invalid integer: ${e}`)}function vE(e){if(!Array.isArray(e))throw new TypeError("array expected")}function Ig(e,t){if(!tD(!0,t))throw new TypeError(`${e}: array of strings expected`)}function rD(e,t){if(!tD(!1,t))throw new TypeError(`${e}: array of numbers expected`)}function AE(...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 SE(e){let t=typeof e=="string"?e.split(""):e,r=t.length;Ig("alphabet",t);let n=new Map(t.map((i,o)=>[i,o]));return{encode:i=>(vE(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=>(vE(i),i.map(o=>{af("alphabet.decode",o);let s=n.get(o);if(s===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function CE(e=""){return af("join",e),{encode:t=>(Ig("join.decode",t),t.join(e)),decode:t=>(af("join.decode",t),t.split(e))}}function uV(e,t="="){return bE(e),af("padding",t),{encode(r){for(Ig("padding.encode",r);r.length*e%8;)r.push(t);return r},decode(r){Ig("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 nD=(e,t)=>t===0?e:nD(t,e%t),$g=(e,t)=>e+(t-nD(e,t)),Bg=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function wE(e,t,r,n){if(vE(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($g(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${$g(t,r)}`);let i=0,o=0,s=Bg[t],a=Bg[r]-1,u=[];for(let f of e){if(bE(f),f>=s)throw new Error(`convertRadix2: invalid data word=${f} 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 h=Bg[o];if(h===void 0)throw new Error("invalid carry");i&=h-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 _E(e,t=!1){if(bE(e),e<=0||e>32)throw new RangeError("radix2: bits should be in (0..32]");if($g(8,e)>32||$g(e,8)>32)throw new RangeError("radix2: carry overflow");return{encode:r=>{if(!EE(r))throw new TypeError("radix2.encode input should be Uint8Array");return wE(Array.from(r),8,e,!t)},decode:r=>(rD("radix2.decode",r),Uint8Array.from(wE(r,e,8,t)))}}function J_(e){return aV(e),function(...t){try{return e.apply(null,t)}catch{}}}var cV=typeof Uint8Array.from([]).toBase64=="function"&&typeof Uint8Array.fromBase64=="function",fV=/[\t\n\f\r ]/,lV=(e,t)=>{af("base64",e);let r=t?"base64url":"base64";if(e.length>0&&fV.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},DE=Object.freeze(cV?{encode(e){return oV(e),e.toBase64()},decode(e){return lV(e,!1)}}:AE(_E(6),SE("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),uV(6),CE(""))),Xn=Object.freeze(AE(_E(6),SE("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),CE("")));var yE=AE(SE("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),CE("")),Q_=[996825010,642813549,513874426,1027748829,705979059];function jd(e){let t=e>>25,r=(e&33554431)<<5;for(let n=0;n>n&1)===1&&(r^=Q_[n]);return r}function eD(e,t,r=1){let n=e.length,i=1;for(let o=0;o126)throw new Error(`Invalid prefix (${e})`);i=jd(i)^s>>5}i=jd(i);for(let o=0;od)throw new TypeError(`Length ${g} exceeds limit ${d}`);let y=m.toLowerCase(),w=eD(y,p,t);return`${y}1${yE.encode(p)}${w}`}function a(m,p=90){af("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=yE.decode(w).slice(0,-6),C=eD(y,E,t);if(!w.endsWith(C))throw new Error(`Invalid checksum in ${m}: expected "${C}"`);return{prefix:y,words:E}}let u=J_(a);function f(m){let{prefix:p,words:d}=a(m,!1);return{prefix:p,words:d,bytes:n(d)}}function h(m,p){return s(m,i(p))}return{encode:s,decode:a,encodeFromBytes:h,decodeToBytes:f,decodeUnsafe:u,fromWords:n,fromWordsUnsafe:o,toWords:i}}var vi=Object.freeze(hV("bech32"));var Kle=P(x(),1);var Ule=P(x(),1);function pV(e,t,r,n){Ma(e);let i=Cg({dkLen:32,asyncTick:10},n),{c:o,dkLen:s,asyncTick:a}=i;if(Hr(o,"c"),Hr(s,"dkLen"),Hr(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=iE(t,"password"),f=iE(r,"salt"),h=new Uint8Array(s),m=ko.create(e,u),p=m._cloneInto().update(f);return{c:o,dkLen:s,asyncTick:a,DK:h,PRF:m,PRFSalt:p}}function gV(e,t,r,n,i){return e.destroy(),t.destroy(),n&&n.destroy(),gs(i),r}function FE(e,t,r,n){let{c:i,dkLen:o,DK:s,PRF:a,PRFSalt:u}=pV(e,t,r,n),f,h=new Uint8Array(4),m=Ul(h),p=new Uint8Array(a.outputLen);for(let d=1,v=0;v0&&(s+=16),sD(r,o,e,t+=16,r,s)}function mV(e,t,r){let n=Cg({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:i,r:o,p:s,dkLen:a,asyncTick:u,maxmem:f,onProgress:h}=n;if(Hr(i,"N"),Hr(o,"r"),Hr(s,"p"),Hr(a,"dkLen"),Hr(u,"asyncTick"),Hr(f,"maxmem"),h!==void 0&&typeof h!="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>f)throw new Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+v+", maxmem="+f);let g=FE(qr,e,t,{c:1,dkLen:m*s}),y=Ag(g),w=Ag(new Uint8Array(m*i)),E=Ag(new Uint8Array(m)),C=()=>{};if(h){let D=2*i*s,B=Math.max(Math.floor(D/1e4),1),H=0;C=()=>{H++,h&&(!(H%B)||H===D)&&h(H/D)}}return{N:i,r:o,p:s,dkLen:a,blockSize32:p,V:w,B32:y,B:g,tmp:E,blockMixCb:C,asyncTick:u}}function vV(e,t,r,n,i){let o=FE(qr,e,r,{c:1,dkLen:t});return gs(r,n,i),o}function IE(e,t,r){let{N:n,r:i,p:o,dkLen:s,blockSize32:a,V:u,B32:f,B:h,tmp:m,blockMixCb:p}=mV(e,t,r);sE(f);for(let d=0;d>>0;for(let w=0;we<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var bV=e=>{for(let t=0;te:bV;function oD(e,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(e,t)}function aD(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 cD=(e,t)=>{function r(n,...i){if(en(n,void 0,"key"),e.nonceLength!==void 0){let h=i[0];en(h,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;o&&i[1]!==void 0&&en(i[1],void 0,"AAD");let s=t(n,...i),a=(h,m)=>{if(m!==void 0){if(h!==2)throw new Error("cipher output not supported");en(m,void 0,"output")}},u=!1;return{encrypt(h,m){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,en(h),a(s.encrypt.length,m),s.encrypt(h,m)},decrypt(h,m){if(en(h),o&&h.lengthUint8Array.from(e.split(""),t=>t.charCodeAt(0)),AV=Ka(No(hD("expand 16-byte k"))),SV=Ka(No(hD("expand 32-byte k")));function Kt(e,t){return e<>>32-t}var Vd=64,CV=16,PE=2**32-1,lD=Uint32Array.of();function _V(e,t,r,n,i,o,s,a){let u=i.length,f=new Uint8Array(Vd),h=No(f),m=uf&&ql(i)&&ql(o),p=m?No(i):lD,d=m?No(o):lD;if(!uf){for(let v=0;v=PE)throw new Error("arx: counter overflow");let g=Math.min(Vd,u-v);for(let y=0,w;y=PE)throw new Error("arx: counter overflow");let g=Math.min(Vd,u-v);if(m&&g===Vd){let y=v/4;if(v%4!==0)throw new Error("arx: invalid block position");for(let w=0,E;w{en(a,void 0,"key"),en(u,void 0,"nonce"),en(f,void 0,"data");let p=f.length;if(h=Kd(p,h,!1),Hl(m),m<0||m>=PE)throw new Error("arx: counter overflow");let d=[],v=a.length,g,y;if(v===32)d.push(g=Ml(a)),y=SV;else if(v===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),y=AV,d.push(g);else throw en(a,32,"arx key"),new Error("invalid key size");(!uf||!ql(u))&&d.push(u=Ml(u));let w=No(g);if(n){if(u.length!==24)throw new Error("arx: extended nonce must be 24 bytes");let D=u.subarray(0,16);if(uf)n(y,w,No(D),w);else{let B=Ka(Uint32Array.from(y));n(B,w,No(D),w),Wi(B),Ka(w)}u=u.subarray(16)}else uf||Ka(w);let E=16-i;if(E!==u.length)throw new Error(`arx: nonce must be ${E} or 16 bytes`);if(E!==12){let D=new Uint8Array(12);D.set(u,o?0:12-u.length),u=D,d.push(u)}let C=Ka(No(u));try{return _V(e,y,w,C,f,h,m,s),h}finally{Wi(...d)}}}var nhe=P(x(),1);function _n(e,t){return e[t++]&255|(e[t++]&255)<<8}var xE=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=Ml(en(t,32,"key"));let r=_n(t,0),n=_n(t,2),i=_n(t,4),o=_n(t,6),s=_n(t,8),a=_n(t,10),u=_n(t,12),f=_n(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|f<<8)&8191,this.r[9]=f>>>5&127;for(let h=0;h<8;h++)this.pad[h]=_n(t,16+2*h)}process(t,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],u=s[1],f=s[2],h=s[3],m=s[4],p=s[5],d=s[6],v=s[7],g=s[8],y=s[9],w=_n(t,r+0),E=_n(t,r+2),C=_n(t,r+4),D=_n(t,r+6),B=_n(t,r+8),H=_n(t,r+10),V=_n(t,r+12),S=_n(t,r+14),I=o[0]+(w&8191),U=o[1]+((w>>>13|E<<3)&8191),R=o[2]+((E>>>10|C<<6)&8191),O=o[3]+((C>>>7|D<<9)&8191),q=o[4]+((D>>>4|B<<12)&8191),N=o[5]+(B>>>1&8191),_=o[6]+((B>>>14|H<<2)&8191),k=o[7]+((H>>>11|V<<5)&8191),K=o[8]+((V>>>8|S<<8)&8191),Z=o[9]+(S>>>5|i),G=0,ee=G+I*a+U*(5*y)+R*(5*g)+O*(5*v)+q*(5*d);G=ee>>>13,ee&=8191,ee+=N*(5*p)+_*(5*m)+k*(5*h)+K*(5*f)+Z*(5*u),G+=ee>>>13,ee&=8191;let se=G+I*u+U*a+R*(5*y)+O*(5*g)+q*(5*v);G=se>>>13,se&=8191,se+=N*(5*d)+_*(5*p)+k*(5*m)+K*(5*h)+Z*(5*f),G+=se>>>13,se&=8191;let le=G+I*f+U*u+R*a+O*(5*y)+q*(5*g);G=le>>>13,le&=8191,le+=N*(5*v)+_*(5*d)+k*(5*p)+K*(5*m)+Z*(5*h),G+=le>>>13,le&=8191;let ve=G+I*h+U*f+R*u+O*a+q*(5*y);G=ve>>>13,ve&=8191,ve+=N*(5*g)+_*(5*v)+k*(5*d)+K*(5*p)+Z*(5*m),G+=ve>>>13,ve&=8191;let we=G+I*m+U*h+R*f+O*u+q*a;G=we>>>13,we&=8191,we+=N*(5*y)+_*(5*g)+k*(5*v)+K*(5*d)+Z*(5*p),G+=we>>>13,we&=8191;let Pe=G+I*p+U*m+R*h+O*f+q*u;G=Pe>>>13,Pe&=8191,Pe+=N*a+_*(5*y)+k*(5*g)+K*(5*v)+Z*(5*d),G+=Pe>>>13,Pe&=8191;let Le=G+I*d+U*p+R*m+O*h+q*f;G=Le>>>13,Le&=8191,Le+=N*u+_*a+k*(5*y)+K*(5*g)+Z*(5*v),G+=Le>>>13,Le&=8191;let Oe=G+I*v+U*d+R*p+O*m+q*h;G=Oe>>>13,Oe&=8191,Oe+=N*f+_*u+k*a+K*(5*y)+Z*(5*g),G+=Oe>>>13,Oe&=8191;let fe=G+I*g+U*v+R*d+O*p+q*m;G=fe>>>13,fe&=8191,fe+=N*h+_*f+k*u+K*a+Z*(5*y),G+=fe>>>13,fe&=8191;let Se=G+I*y+U*g+R*v+O*d+q*p;G=Se>>>13,Se&=8191,Se+=N*m+_*h+k*f+K*u+Z*a,G+=Se>>>13,Se&=8191,G=(G<<2)+G|0,G=G+ee|0,ee=G&8191,G=G>>>13,se+=G,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;Wi(n)}update(t){$E(this),en(t),t=Ml(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}},pD=uD(32,e=>new xE(e));function DV(e,t,r,n,i,o=20){let s=e[0],a=e[1],u=e[2],f=e[3],h=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,C=r[0],D=r[1],B=r[2],H=s,V=a,S=u,I=f,U=h,R=m,O=p,q=d,N=v,_=g,k=y,K=w,Z=E,G=C,ee=D,se=B;for(let ve=0;ve{e.update(t);let r=t.length%16;r&&e.update(BV.subarray(r))},IV=new Uint8Array(32);function mD(e,t,r,n,i){i!==void 0&&en(i,void 0,"AAD");let o=e(t,r,IV),s=fD(n.length,i?i.length:0,!0),a=pD.create(o);i&&gD(a,i),gD(a,n),a.update(s);let u=a.digest();return Wi(o,s),u}var $V=e=>(t,r,n)=>({encrypt(o,s){let a=o.length;s=Kd(a+16,s,!1),s.set(o);let u=s.subarray(0,-16);e(t,r,u,u,1);let f=mD(e,t,r,u,n);return s.set(f,a),Wi(f),s},decrypt(o,s){s=Kd(o.length-16,s,!1);let a=o.subarray(0,-16),u=o.subarray(-16),f=mD(e,t,r,a,n);if(!aD(u,f))throw Wi(f),new Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),Wi(f),s}}),wi=cD({blockSize:64,nonceLength:12,tagLength:16},$V(FV));var Wde=P(x(),1);var ghe=P(x(),1);var hhe=P(x(),1);function jl(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function dn(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=jl(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 yi(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");dn(e.outputLen),dn(e.blockLen)}function za(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 xg(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 ks(...e){for(let t=0;t>>t}var PV=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xV(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function TV(e){for(let t=0;te:TV,wD=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",RV=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function cf(e){if(ot(e),wD)return e.toHex();let t="";for(let r=0;r=Va._0&&e<=Va._9)return e-Va._0;if(e>=Va.A&&e<=Va.F)return e-(Va.A-10);if(e>=Va.a&&e<=Va.f)return e-(Va.a-10)}function ff(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(wD)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 Yu(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 Xu=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var kE=BigInt(0),RE=BigInt(1);function zd(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function yD(e){if(typeof e=="bigint"){if(!kg(e))throw new Error("positive bigint expected, got "+e)}else dn(e);return e}function Gd(e){let t=yD(e).toString(16);return t.length&1?"0"+t:t}function ED(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?kE:BigInt("0x"+e)}function Zu(e){return ED(cf(e))}function Ju(e){return ED(cf(Og(ot(e)).reverse()))}function Vl(e,t){dn(t),e=yD(e);let r=ff(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function Wd(e,t){return Vl(e,t).reverse()}function Og(e){return Uint8Array.from(e)}function Qu(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 kg=e=>typeof e=="bigint"&&kE<=e;function kV(e,t,r){return kg(e)&&kg(t)&&kg(r)&&t<=e&&ekE;e>>=RE,t+=1);return t}var Xd=e=>(RE<new Uint8Array(y),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,u=n(e),f=n(e),h=0,m=()=>{u.fill(1),f.fill(0),h=0},p=(...y)=>r(f,Vr(u,...y)),d=(y=i)=>{f=p(o,y),u=p(),y.length!==0&&(f=p(s,y),u=p())},v=()=>{if(h++>=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 lf(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 f=typeof u;if(f!==s||u===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${f}`)}let i=(o,s)=>Object.entries(o).forEach(([a,u])=>n(a,u,s));i(t,!1),i(r,!0)}function NE(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 She=P(x(),1);var yhe=P(x(),1);var vs=BigInt(0),Zn=BigInt(1),hf=BigInt(2),CD=BigInt(3),_D=BigInt(4),DD=BigInt(5),OV=BigInt(7),FD=BigInt(8),NV=BigInt(9),BD=BigInt(16);function ms(e,t){let r=e%t;return r>=vs?r:t+r}function Ei(e,t,r){let n=e;for(;t-- >vs;)n*=n,n%=r;return n}function AD(e,t){if(e===vs)throw new Error("invert: expected non-zero number");if(t<=vs)throw new Error("invert: expected positive modulus, got "+t);let r=ms(e,t),n=t,i=vs,o=Zn,s=Zn,a=vs;for(;r!==vs;){let f=n/r,h=n%r,m=i-s*f,p=o-a*f;n=r,r=h,i=s,o=a,s=m,a=p}if(n!==Zn)throw new Error("invert: does not exist");return ms(i,t)}function UE(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function ID(e,t){let r=(e.ORDER+Zn)/_D,n=e.pow(t,r);return UE(e,n,t),n}function LV(e,t){let r=(e.ORDER-DD)/FD,n=e.mul(t,hf),i=e.pow(n,r),o=e.mul(t,i),s=e.mul(e.mul(o,hf),i),a=e.mul(o,e.sub(s,e.ONE));return UE(e,a,t),a}function UV(e){let t=Ng(e),r=$D(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+OV)/BD;return(a,u)=>{let f=a.pow(u,s),h=a.mul(f,n),m=a.mul(f,i),p=a.mul(f,o),d=a.eql(a.sqr(h),u),v=a.eql(a.sqr(m),u);f=a.cmov(f,h,d),h=a.cmov(p,m,v);let g=a.eql(a.sqr(h),u),y=a.cmov(f,h,g);return UE(a,y,u),y}}function $D(e){if(e1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return ID;let o=i.pow(n,t),s=(t+Zn)/hf;return function(u,f){if(u.is0(f))return f;if(SD(u,f)!==1)throw new Error("Cannot find square root");let h=r,m=u.mul(u.ONE,o),p=u.pow(f,t),d=u.pow(f,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===h)throw new Error("Cannot find square root");let y=Zn<(n[i]="function",n),t);return lf(e,r),e}function MV(e,t,r){if(rvs;)r&Zn&&(n=e.mul(n,i)),i=e.sqr(i),r>>=Zn;return n}function Zd(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 SD(e,t){let r=(e.ORDER-Zn)/hf,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 jV(e,t){t!==void 0&&dn(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var LE=class{ORDER;BITS;BYTES;isLE;ZERO=vs;ONE=Zn;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=vs)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}=jV(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 ms(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return vs<=t&&ti)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(i);f.set(t,o?0:f.length-t.length),t=f}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let u=o?Ju(t):Zu(t);if(a&&(u=ms(u,s)),!r&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(t){return Zd(this,t)}cmov(t,r,n){return n?r:t}};function Ng(e,t={}){return new LE(e,t)}function PD(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 qE(e){let t=PD(e);return t+Math.ceil(t/2)}function xD(e,t,r=!1){ot(e);let n=e.length,i=PD(t),o=qE(t);if(n<16||n1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?Ju(e):Zu(e),a=ms(s,t-Zn)+Zn;return r?Wd(a,i):Vl(a,i)}var zl=BigInt(0),df=BigInt(1);function Jd(e,t){let r=t.negate();return e?r:t}function VE(e,t){let r=Zd(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function OD(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ME(e,t){OD(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=Xd(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function TD(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+=df);let f=t*n,h=f+Math.abs(a)-1,m=a===0,p=a<0,d=t%2!==0;return{nextN:u,offset:h,isZero:m,isNeg:p,isNegF:d,offsetF:f}}var jE=new WeakMap,ND=new WeakMap;function KE(e){return ND.get(e)||1}function RD(e){if(e!==zl)throw new Error("invalid wNAF")}var Lg=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>zl;)r&df&&(n=n.add(i)),i=i.double(),r>>=df;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=ME(r,this.bits),o=[],s=t,a=s;for(let u=0;uzl||n>zl;)r&df&&(o=o.add(i)),n&df&&(s=s.add(i)),i=i.double(),r>>=df,n>>=df;return{p1:o,p2:s}}function kD(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return HE(t),t}else return Ng(e,{isLE:r})}function UD(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 f=t[u];if(!(typeof f=="bigint"&&f>zl))throw new Error(`CURVE.${u} must be positive bigint`)}let i=kD(t.p,r.Fp,n),o=kD(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 Ug(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var Bhe=P(x(),1);var Qd=BigInt(0),Gl=BigInt(1),Hg=BigInt(2);function KV(e){return lf(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function HD(e){let t=KV(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||Yu,f=a?255:448,h=a?32:56,m=BigInt(a?9:5),p=BigInt(a?121665:39081),d=a?Hg**BigInt(254):Hg**BigInt(447),v=a?BigInt(8)*Hg**BigInt(251)-Gl:BigInt(4)*Hg**BigInt(445)-Gl,g=d+v+Gl,y=N=>ms(N,r),w=E(m);function E(N){return Wd(y(N),h)}function C(N){let _=Og(ot(N,h,"uCoordinate"));return a&&(_[31]&=127),y(Ju(_))}function D(N){return Ju(i(Og(ot(N,h,"scalar"))))}function B(N,_){let k=U(C(_),D(N));if(k===Qd)throw new Error("invalid private or public key received");return E(k)}function H(N){return B(N,w)}let V=H,S=B;function I(N,_,k){let K=y(N*(_-k));return _=y(_-K),k=y(k+K),{x_2:_,x_3:k}}function U(N,_){Yd("u",N,Qd,r),Yd("scalar",_,d,g);let k=_,K=N,Z=Gl,G=Qd,ee=N,se=Gl,le=Qd;for(let we=BigInt(f-1);we>=Qd;we--){let Pe=k>>we&Gl;le^=Pe,{x_2:Z,x_3:ee}=I(le,Z,ee),{x_2:G,x_3:se}=I(le,G,se),le=Pe;let Le=Z+G,Oe=y(Le*Le),fe=Z-G,Se=y(fe*fe),Re=Oe-Se,Ke=ee+se,Qe=ee-se,Me=y(Qe*Le),yt=y(Ke*fe),rt=Me+yt,vt=Me-yt;ee=y(rt*rt),se=y(K*y(vt*vt)),Z=y(Oe*Se),G=y(Re*(Oe+y(p*Re)))}({x_2:Z,x_3:ee}=I(le,Z,ee)),{x_2:G,x_3:se}=I(le,G,se);let ve=o(G);return y(Z*ve)}let R={secretKey:h,publicKey:h,seed:h},O=(N=u(h))=>(ot(N,R.seed,"seed"),N),q={randomSecretKey:O};return Object.freeze({keygen:Ug(O,V),getSharedSecret:S,getPublicKey:V,scalarMult:B,scalarMultBase:H,utils:q,GuBytes:w.slice(),lengths:R})}var Lhe=P(x(),1);var Phe=P(x(),1);var qg=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(yi(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 qg(e,t).update(r).digest();Wl.create=(e,t)=>new qg(e,t);var qD=(e,t)=>(e+(e>=0?t:-t)/MD)/t;function VV(e,t,r){let[[n,i],[o,s]]=t,a=qD(s*e,r),u=qD(-i*e,r),f=e-a*n-u*o,h=-a*i-u*s,m=f=d||h=d)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:m,k1:f,k2neg:p,k2:h}}function GE(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function zE(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return zd(r.lowS,"lowS"),zd(r.prehash,"prehash"),r.format!==void 0&&GE(r.format),r}var WE=class extends Error{constructor(t=""){super(t)}},ec={Err:WE,_tlv:{encode:(e,t)=>{let{Err:r}=ec;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=Gd(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?Gd(i.length/2|128):"";return Gd(e)+o+i+t},decode(e,t){let{Err:r}=ec,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 f=t.subarray(n,n+u);if(f.length!==u)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let h of f)s=s<<8|h;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}=ec;if(e{let{X:N,Y:_,Z:k}=O;if(n.eql(k,n.ONE))return{x:N,y:_};let K=O.is0();q==null&&(q=K?n.ONE:n.inv(k));let Z=n.mul(N,q),G=n.mul(_,q),ee=n.mul(k,q);if(K)return{x:n.ZERO,y:n.ZERO};if(!n.eql(ee,n.ONE))throw new Error("invZ was invalid");return{x:Z,y:G}}),V=NE(O=>{if(O.is0()){if(t.allowInfinityPoint&&!n.is0(O.Y))return;throw new Error("bad point: ZERO")}let{x:q,y:N}=O.toAffine();if(!n.isValid(q)||!n.isValid(N))throw new Error("bad point: x or y not field elements");if(!y(q,N))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function S(O,q,N,_,k){return N=new I(n.mul(N.X,O),N.Y,N.Z),q=Jd(_,q),N=Jd(k,N),q.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(q,N,_){this.X=C("x",q),this.Y=C("y",N,!0),this.Z=C("z",_),Object.freeze(this)}static CURVE(){return o}static fromAffine(q){let{x:N,y:_}=q||{};if(!q||!n.isValid(N)||!n.isValid(_))throw new Error("invalid affine point");if(q instanceof I)throw new Error("projective point not allowed");return n.is0(N)&&n.is0(_)?I.ZERO:new I(N,_,n.ONE)}static fromBytes(q){let N=I.fromAffine(v(ot(q,void 0,"point")));return N.assertValidity(),N}static fromHex(q){return I.fromBytes(ff(q))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(q=8,N=!0){return R.createCache(this,q),N||this.multiply(Mg),this}assertValidity(){V(this)}hasEvenY(){let{y:q}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(q)}equals(q){D(q);let{X:N,Y:_,Z:k}=this,{X:K,Y:Z,Z:G}=q,ee=n.eql(n.mul(N,G),n.mul(K,k)),se=n.eql(n.mul(_,G),n.mul(Z,k));return ee&&se}negate(){return new I(this.X,n.neg(this.Y),this.Z)}double(){let{a:q,b:N}=o,_=n.mul(N,Mg),{X:k,Y:K,Z}=this,G=n.ZERO,ee=n.ZERO,se=n.ZERO,le=n.mul(k,k),ve=n.mul(K,K),we=n.mul(Z,Z),Pe=n.mul(k,K);return Pe=n.add(Pe,Pe),se=n.mul(k,Z),se=n.add(se,se),G=n.mul(q,se),ee=n.mul(_,we),ee=n.add(G,ee),G=n.sub(ve,ee),ee=n.add(ve,ee),ee=n.mul(G,ee),G=n.mul(Pe,G),se=n.mul(_,se),we=n.mul(q,we),Pe=n.sub(le,we),Pe=n.mul(q,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(K,Z),we=n.add(we,we),le=n.mul(we,Pe),G=n.sub(G,le),se=n.mul(we,ve),se=n.add(se,se),se=n.add(se,se),new I(G,ee,se)}add(q){D(q);let{X:N,Y:_,Z:k}=this,{X:K,Y:Z,Z:G}=q,ee=n.ZERO,se=n.ZERO,le=n.ZERO,ve=o.a,we=n.mul(o.b,Mg),Pe=n.mul(N,K),Le=n.mul(_,Z),Oe=n.mul(k,G),fe=n.add(N,_),Se=n.add(K,Z);fe=n.mul(fe,Se),Se=n.add(Pe,Le),fe=n.sub(fe,Se),Se=n.add(N,k);let Re=n.add(K,G);return Se=n.mul(Se,Re),Re=n.add(Pe,Oe),Se=n.sub(Se,Re),Re=n.add(_,k),ee=n.add(Z,G),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(q){return this.add(q.negate())}is0(){return this.equals(I.ZERO)}multiply(q){let{endo:N}=t;if(!i.isValidNot0(q))throw new Error("invalid scalar: out of range");let _,k,K=Z=>R.cached(this,Z,G=>VE(I,G));if(N){let{k1neg:Z,k1:G,k2neg:ee,k2:se}=B(q),{p:le,f:ve}=K(G),{p:we,f:Pe}=K(se);k=ve.add(Pe),_=S(N.beta,le,we,Z,ee)}else{let{p:Z,f:G}=K(q);_=Z,k=G}return VE(I,[_,k])[0]}multiplyUnsafe(q){let{endo:N}=t,_=this;if(!i.isValid(q))throw new Error("invalid scalar: out of range");if(q===Ga||_.is0())return I.ZERO;if(q===Yl)return _;if(R.hasCache(this))return this.multiply(q);if(N){let{k1neg:k,k1:K,k2neg:Z,k2:G}=B(q),{p1:ee,p2:se}=LD(I,_,K,G);return S(N.beta,ee,se,k,Z)}else return R.unsafe(_,q)}toAffine(q){return H(this,q)}isTorsionFree(){let{isTorsionFree:q}=t;return s===Yl?!0:q?q(I,this):R.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:q}=t;return s===Yl?this:q?q(I,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(q=!0){return zd(q,"isCompressed"),this.assertValidity(),d(I,this,q)}toHex(q=!0){return cf(this.toBytes(q))}toString(){return``}}let U=i.BITS,R=new Lg(I,t.endo?Math.ceil(U/2):U);return I.BASE.precompute(8),I}function jD(e){return Uint8Array.of(e?2:3)}function KD(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function GV(e,t={}){let{Fn:r}=e,n=t.randomBytes||Yu,i=Object.assign(KD(e.Fp,r),{seed:qE(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 xD(ot(d,i.seed,"seed"),r.ORDER)}function u(d,v=!0){return e.BASE.multiply(r.fromBytes(d)).toBytes(v)}function f(d){let{secretKey:v,publicKey:g,publicKeyUncompressed:y}=i;if(!jl(d)||"_lengths"in r&&r._lengths||v===g)return;let w=ot(d,void 0,"key").length;return w===g||w===y}function h(d,v,g=!0){if(f(d)===!0)throw new Error("first arg must be private key");if(f(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=Ug(a,u);return Object.freeze({getPublicKey:u,getSharedSecret:h,keygen:p,Point:e,utils:m,lengths:i})}function XE(e,t,r={}){yi(t),lf(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Yu,i=r.hmac||((N,_)=>Wl(t,N,_)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:u}=s,{keygen:f,getPublicKey:h,getSharedSecret:m,utils:p,lengths:d}=GV(e,r),v={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*MD>Yl;return N>_}function w(N,_){if(!s.isValidNot0(_))throw new Error(`invalid signature ${N}: out of range 1..Point.Fn.ORDER`);return _}function E(){if(g)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function C(N,_){GE(_);let k=d.signature,K=_==="compact"?k:_==="recovered"?k+1:void 0;return ot(N,K)}class D{r;s;recovery;constructor(_,k,K){if(this.r=w("r",_),this.s=w("s",k),K!=null){if(E(),![0,1,2,3].includes(K))throw new Error("invalid recovery id");this.recovery=K}Object.freeze(this)}static fromBytes(_,k=v.format){C(_,k);let K;if(k==="der"){let{r:se,s:le}=ec.toSig(ot(_));return new D(se,le)}k==="recovered"&&(K=_[0],k="compact",_=_.subarray(1));let Z=d.signature/2,G=_.subarray(0,Z),ee=_.subarray(Z,Z*2);return new D(s.fromBytes(G),s.fromBytes(ee),K)}static fromHex(_,k){return this.fromBytes(ff(_),k)}assertRecovery(){let{recovery:_}=this;if(_==null)throw new Error("invalid recovery id: must be present");return _}addRecoveryBit(_){return new D(this.r,this.s,_)}recoverPublicKey(_){let{r:k,s:K}=this,Z=this.assertRecovery(),G=Z===2||Z===3?k+a:k;if(!o.isValid(G))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let ee=o.toBytes(G),se=e.fromBytes(Vr(jD((Z&1)===0),ee)),le=s.inv(G),ve=H(ot(_,void 0,"msgHash")),we=s.create(-ve*le),Pe=s.create(K*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(_=v.format){if(GE(_),_==="der")return ff(ec.hexFromSig(this));let{r:k,s:K}=this,Z=s.toBytes(k),G=s.toBytes(K);return _==="recovered"?(E(),Vr(Uint8Array.of(this.assertRecovery()),Z,G)):Vr(Z,G)}toHex(_){return cf(this.toBytes(_))}}let B=r.bits2int||function(_){if(_.length>8192)throw new Error("input is too large");let k=Zu(_),K=_.length*8-u;return K>0?k>>BigInt(K):k},H=r.bits2int_modN||function(_){return s.create(B(_))},V=Xd(u);function S(N){return Yd("num < 2^"+u,N,Ga,V),s.toBytes(N)}function I(N,_){return ot(N,void 0,"message"),_?ot(t(N),void 0,"prehashed message"):N}function U(N,_,k){let{lowS:K,prehash:Z,extraEntropy:G}=zE(k,v);N=I(N,Z);let ee=H(N),se=s.fromBytes(_);if(!s.isValidNot0(se))throw new Error("invalid private key");let le=[S(se),S(ee)];if(G!=null&&G!==!1){let Le=G===!0?n(d.secretKey):G;le.push(ot(Le,void 0,"extraEntropy"))}let ve=Vr(...le),we=ee;function Pe(Le){let Oe=B(Le);if(!s.isValidNot0(Oe))return;let fe=s.inv(Oe),Se=e.BASE.multiply(Oe).toAffine(),Re=s.create(Se.x);if(Re===Ga)return;let Ke=s.create(fe*s.create(we+Re*se));if(Ke===Ga)return;let Qe=(Se.x===Re?0:2)|Number(Se.y&Yl),Me=Ke;return K&&y(Ke)&&(Me=s.neg(Ke),Qe^=1),new D(Re,Me,g?void 0:Qe)}return{seed:ve,k2sig:Pe}}function R(N,_,k={}){let{seed:K,k2sig:Z}=U(N,_,k);return bD(t.outputLen,s.BYTES,i)(K,Z).toBytes(k.format)}function O(N,_,k,K={}){let{lowS:Z,prehash:G,format:ee}=zE(K,v);if(k=ot(k,void 0,"publicKey"),_=I(_,G),!jl(N)){let se=N instanceof D?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+se)}C(N,ee);try{let se=D.fromBytes(N,ee),le=e.fromBytes(k);if(Z&&se.hasHighS())return!1;let{r:ve,s:we}=se,Pe=H(_),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 q(N,_,k={}){let{prehash:K}=zE(k,v);return _=I(_,K),D.fromBytes(N,"recovered").recoverPublicKey(_).toBytes()}return Object.freeze({keygen:f,getPublicKey:h,getSharedSecret:m,utils:p,lengths:d,Point:e,sign:R,verify:O,recoverPublicKey:q,Signature:D,hash:t})}var tde=P(x(),1);var Whe=P(x(),1);var qhe=P(x(),1);function VD(e,t,r){return e&t^~e&r}function zD(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){za(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;mh.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m>GD&jg)}:{h:Number(e>>GD&jg)|0,l:Number(e&jg)|0}}function Kg(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;oe>>>r,JE=(e,t,r)=>e<<32-r|t>>>r,pf=(e,t,r)=>e>>>r|t<<32-r,gf=(e,t,r)=>e<<32-r|t>>>r,tp=(e,t,r)=>e<<64-r|t>>>r-32,rp=(e,t,r)=>e>>>r-32|t<<64-r;var WD=(e,t,r)=>e<>>32-r,YD=(e,t,r)=>t<>>32-r,XD=(e,t,r)=>t<>>64-r,ZD=(e,t,r)=>e<>>64-r;function Lo(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var JD=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),QD=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,eF=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),tF=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,rF=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),nF=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;var XV=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]),tc=new Uint32Array(64),QE=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)tc[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let p=tc[m-15],d=tc[m-2],v=Yi(p,7)^Yi(p,18)^p>>>3,g=Yi(d,17)^Yi(d,19)^d>>>10;tc[m]=g+tc[m-7]+v+tc[m-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let m=0;m<64;m++){let p=Yi(a,6)^Yi(a,11)^Yi(a,25),d=h+p+VD(a,u,f)+XV[m]+tc[m]|0,g=(Yi(n,2)^Yi(n,13)^Yi(n,22))+zD(n,i,o)|0;h=f,f=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,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){ks(tc)}destroy(){this.set(0,0,0,0,0,0,0,0),ks(this.buffer)}},eb=class extends QE{A=Wa[0]|0;B=Wa[1]|0;C=Wa[2]|0;D=Wa[3]|0;E=Wa[4]|0;F=Wa[5]|0;G=Wa[6]|0;H=Wa[7]|0;constructor(){super(32)}};var sF=Kg(["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))),ZV=sF[0],JV=sF[1],rc=new Uint32Array(80),nc=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:f,El:h,Fh:m,Fl:p,Gh:d,Gl:v,Hh:g,Hl:y}=this;return[t,r,n,i,o,s,a,u,f,h,m,p,d,v,g,y]}set(t,r,n,i,o,s,a,u,f,h,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=f|0,this.El=h|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 C=0;C<16;C++,r+=4)rc[C]=t.getUint32(r),nc[C]=t.getUint32(r+=4);for(let C=16;C<80;C++){let D=rc[C-15]|0,B=nc[C-15]|0,H=pf(D,B,1)^pf(D,B,8)^ZE(D,B,7),V=gf(D,B,1)^gf(D,B,8)^JE(D,B,7),S=rc[C-2]|0,I=nc[C-2]|0,U=pf(S,I,19)^tp(S,I,61)^ZE(S,I,6),R=gf(S,I,19)^rp(S,I,61)^JE(S,I,6),O=eF(V,R,nc[C-7],nc[C-16]),q=tF(O,H,U,rc[C-7],rc[C-16]);rc[C]=q|0,nc[C]=O|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:u,Dh:f,Dl:h,Eh:m,El:p,Fh:d,Fl:v,Gh:g,Gl:y,Hh:w,Hl:E}=this;for(let C=0;C<80;C++){let D=pf(m,p,14)^pf(m,p,18)^tp(m,p,41),B=gf(m,p,14)^gf(m,p,18)^rp(m,p,41),H=m&d^~m&g,V=p&v^~p&y,S=rF(E,B,V,JV[C],nc[C]),I=nF(S,w,D,H,ZV[C],rc[C]),U=S|0,R=pf(n,i,28)^tp(n,i,34)^tp(n,i,39),O=gf(n,i,28)^rp(n,i,34)^rp(n,i,39),q=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}=Lo(f|0,h|0,I|0,U|0),f=a|0,h=u|0,a=o|0,u=s|0,o=n|0,s=i|0;let _=JD(U,O,N);n=QD(_,I,R,q),i=_|0}({h:n,l:i}=Lo(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=Lo(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:u}=Lo(this.Ch|0,this.Cl|0,a|0,u|0),{h:f,l:h}=Lo(this.Dh|0,this.Dl|0,f|0,h|0),{h:m,l:p}=Lo(this.Eh|0,this.El|0,m|0,p|0),{h:d,l:v}=Lo(this.Fh|0,this.Fl|0,d|0,v|0),{h:g,l:y}=Lo(this.Gh|0,this.Gl|0,g|0,y|0),{h:w,l:E}=Lo(this.Hh|0,this.Hl|0,w|0,E|0),this.set(n,i,o,s,a,u,f,h,m,p,d,v,g,y,w,E)}roundClean(){ks(rc,nc)}destroy(){ks(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=Dn[0]|0;Al=Dn[1]|0;Bh=Dn[2]|0;Bl=Dn[3]|0;Ch=Dn[4]|0;Cl=Dn[5]|0;Dh=Dn[6]|0;Dl=Dn[7]|0;Eh=Dn[8]|0;El=Dn[9]|0;Fh=Dn[10]|0;Fl=Dn[11]|0;Gh=Dn[12]|0;Gl=Dn[13]|0;Hh=Dn[14]|0;Hl=Dn[15]|0;constructor(){super(48)}};var Vg=Kl(()=>new eb,Xu(1));var iF=Kl(()=>new rb,Xu(2));var QV=BigInt(1),oF=BigInt(2),ez=BigInt(3),tz=BigInt(5),Qhe=BigInt(8),aF=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function rz(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=aF,a=e*e%o*e%o,u=Ei(a,oF,o)*a%o,f=Ei(u,QV,o)*e%o,h=Ei(f,tz,o)*f%o,m=Ei(h,t,o)*h%o,p=Ei(m,r,o)*m%o,d=Ei(p,n,o)*p%o,v=Ei(d,i,o)*d%o,g=Ei(v,i,o)*d%o,y=Ei(g,t,o)*h%o;return{pow_p_5_8:Ei(y,oF,o)*e%o,b2:a}}function nz(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var uF=(()=>{let e=aF;return HD({P:e,type:"x25519",powPminus2:t=>{let{pow_p_5_8:r,b2:n}=rz(t);return ms(Ei(r,ez,e)*n,e)},adjustScalarBytes:nz})})();var ade=P(x(),1);var sz={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},iz={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")};var oz=YE(sz),nb=XE(oz,Vg);var az=YE(iz),cF=XE(az,iF);var lde=P(x(),1);function lF(e,t,r){return yi(e),r===void 0&&(r=new Uint8Array(e.outputLen)),Wl(e,r,t)}var sb=Uint8Array.of(0),fF=Uint8Array.of();function hF(e,t,r,n=32){yi(e),dn(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=fF:ot(r,void 0,"info");let s=new Uint8Array(o*i),a=Wl.create(e,t),u=a._cloneInto(),f=new Uint8Array(a.outputLen);for(let h=0;h>fz)*hz)%lz,t&cz&&(i^=np<<(np<r>32?XD(e,t,r):WD(e,t,r),pF=(e,t,r)=>r>32?ZD(e,t,r):YD(e,t,r);function gz(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,f=r[u],h=r[u+1],m=dF(f,h,1)^r[a],p=pF(f,h,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=mF[s],u=dF(i,o,a),f=pF(i,o,a),h=gF[s];i=e[h],o=e[h+1],e[h]=u,e[h+1]=f}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]^=dz[n],e[1]^=pz[n]}ks(r)}var zg=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,dn(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 dn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(xg(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,ks(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}},yF=(e,t,r,n={})=>Kl(()=>new zg(t,e,r),n);var mf=yF(6,136,32,Xu(8));var EF=yF(6,72,64,Xu(10));var bF=(e,t,r,n={})=>Kl((i={})=>new zg(t,e,i.dkLen===void 0?r:i.dkLen,!0),n),AF=bF(31,168,16,Xu(11)),Uo=bF(31,136,32,Xu(12));var Rde=P(x(),1);var Fde=P(x(),1);var vde=P(x(),1);function ib(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error("wrong u32 integer:"+e);return e}function CF(e){return ib(e),(e&e-1)===0&&e!==0}function ob(e,t){ib(e);let r=0;for(let n=0;n>>=1)r=r<<1|e&1;return r}function _F(e){return ib(e),31-Math.clz32(e)}function SF(e){let t=e.length;if(t<2||!CF(t))throw new Error("n must be a power of 2 and greater than 1. Got "+t);let r=_F(t);for(let n=0;n{let{N:r,roots:n,dit:i,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,u=_F(r);if(!CF(r))throw new Error("FFT: Polynomial size should be power of two");let f=i!==o;return h=>{if(h.length!==r)throw new Error("FFT: wrong Polynomial length");i&&a&&SF(h);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 Wg(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,C=n)=>{let D=E%C|0;return(D>=0?D|0:C+D|0)|0},f=(E,C=n)=>{let D=u(E,C)|0;return(D>C>>1?D-C|0:D)|0};function h(){let E=t(r);for(let C=0;Cu((E|0)+(C|0))|0,sub:(E,C)=>u((E|0)-(C|0))|0,mul:(E,C)=>u((E|0)*(C|0))|0,inv:E=>{throw new Error("not implemented")}},d={N:r,roots:m,invertButterflies:!0,skipStages:a?1:0,brp:!1},v=ab(p,{dit:!1,...d}),g=ab(p,{dit:!0,...d});return{mod:u,smod:f,nttZetas:m,NTT:{encode:E=>v(E),decode:E=>{g(E);for(let C=0;C{let D=ub(E),B=E*(r/8);return{bytesLen:B,encode:H=>{let V=new Uint8Array(B);for(let S=0,I=0,U=0,R=0;S=8;U-=8,I>>=8)V[R++]=I&ub(U);return V},decode:H=>{let V=t(r);for(let S=0,I=0,U=0,R=0;S=E;U-=E,I>>=E)V[R++]=C.decode(I&D);return V}}}}},mz=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:(f,h)=>(n[i+0]=f,n[i+1]=h,s.destroy(),s=e.create({}).update(n),a++,()=>(u++,s.xofInto(o))),clean:()=>{s.destroy(),tn(o,n)}}},BF=mz(AF);var Jn=256,Ya=3329,vz=3303,wz=17,{mod:op,nttZetas:yz,NTT:wf,bitsCoder:Ez}=FF({N:Jn,Q:Ya,F:vz,ROOT_OF_UNITY:wz,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0}),cb={512:{N:Jn,Q:Ya,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:Jn,Q:Ya,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:Jn,Q:Ya,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},bz=e=>{if(e>=12)return{encode:r=>r,decode:r=>r};let t=2**(e-1);return{encode:r=>((r<r*Ya+t>>>e}},sp=e=>Ez(e,bz(e));function yf(e,t){for(let r=0;r>1)];r&1&&(n=-n);let{c0:i,c1:o}=Sz(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 IF(e){let t=new Uint16Array(Jn);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=h,h=0):a===2*n&&(o[f++]=op(m-h),h=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return o}var Cz=e=>{let{K:t,PRF:r,XOF:n,HASH512:i,ETA1:o,ETA2:s,du:a,dv:u}=e,f=sp(1),h=sp(u),m=sp(a),p=vf("publicKey",Wg(sp(12),t),32),d=Wg(sp(12),t),v=vf("ciphertext",Wg(m,t),h),g=vf("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),[C,D]=g.decode(E),B=[],H=[];for(let I=0;I{let[C,D]=p.decode(y),B=[];for(let R=0;R{let[E,C]=v.decode(y),D=d.decode(w),B=new Uint16Array(Jn);for(let H=0;H{ot(h,f,"seed");let{publicKey:m,secretKey:p}=t.keygen(h.subarray(0,32)),d=r(m),v=a.encode([p,m,d,h.subarray(32)]);return tn(p,d),{publicKey:m,secretKey:v}},getPublicKey:h=>{let[m,p,d,v]=a.decode(h);return Uint8Array.from(p)},encapsulate:(h,m=Ho(u))=>{ot(h,s.publicKey,"publicKey"),ot(m,u,"message");let p=h.subarray(0,384*e.K),d=o.encode(o.decode(DF(p)));if(!Gg(d,p))throw tn(d),new Error("ML-KEM.encapsulate: wrong publicKey modulus");tn(d);let v=n.create().update(m).update(r(h)).digest(),g=t.encrypt(h,m,v.subarray(32,64));return tn(v.subarray(32)),{cipherText:g,sharedSecret:v.subarray(0,32)}},decapsulate:(h,m)=>{ot(m,a.bytesLen,"secretKey"),ot(h,s.cipherText,"cipherText");let p=a.bytesLen-96,d=p+32,v=r(m.subarray(p/2,d));if(!Gg(v,m.subarray(d,d+32)))throw new Error("invalid secretKey: hash check failed");let[g,y,w,E]=a.decode(m),C=t.decrypt(h,g),D=n.create().update(C).update(w).digest(),B=D.subarray(0,32),H=t.encrypt(y,C,D.subarray(32,64)),V=Gg(h,H),S=i.create({dkLen:32}).update(E).update(h).digest();return tn(C,H,V?S:B),V?B:S}}}function _z(e,t,r){return Uo.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var lb={HASH256:mf,HASH512:EF,KDF:Uo,XOF:BF,PRF:_z},xde=fb({...lb,...cb[512]}),ap=fb({...lb,...cb[768]}),$F=fb({...lb,...cb[1024]});function Dz(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=Ho(r.seed))=>{ot(s,r.seed,"seed");let a=o.isLE?Ju(s):Zu(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 hb(e,t=!1){let r=Dz(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=Ho(e.lengths.seed)){let o=this.keygen(i).secretKey,s=this.decapsulate(n,o),a=e.getPublicKey(o);return tn(o),{sharedSecret:s,cipherText:a}},decapsulate(n,i){let o=e.getSharedSecret(i,n);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function up(e,t){return vf(t,...e.map(r=>{if(typeof r.lengths[t]!="number")throw new Error("wrong length: "+t);return r.lengths[t]}))}function db(e){return(t,r)=>e(t,{dkLen:r})}function Fz(e,t,...r){let n=up(r,"seed"),i=up(r,"publicKey");e===void 0&&(e=n.bytesLen),dn(e);function o(s){ot(s,e);let a=n.decode(t(s,n.bytesLen)),u=r.map((m,p)=>m.keygen(a[p])),f=u.map(m=>m.secretKey),h=u.map(m=>m.publicKey);return{secretKey:f,publicKey:h}}return{info:{lengths:{seed:e,publicKey:i.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=Ho(e)){let{publicKey:a,secretKey:u}=o(s),f=i.encode(a);return tn(a),tn(u),{secretKey:s,publicKey:f}},expandDecapsulationKey:o,realSeedLen:e}}function Xg(e,t,r,n,...i){let o=Fz(e,r,...i),s=up(i,"cipherText"),a=up(i,"publicKey"),u=up(i,"msg");return t===void 0&&(t=u.bytesLen),dn(t),{lengths:{...o.info.lengths,msg:t,msgRand:u.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(f,h=Ho(u.bytesLen)){let m=a.decode(f),p=u.decode(h),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 tn(v,g),y},decapsulate(f,h){let m=s.decode(f),{publicKey:p,secretKey:d}=o.expandDecapsulationKey(h),v=i.map((g,y)=>g.decapsulate(m[y],d[y]));return n(p,m,v)}}}function PF(e,t,r,n,i){return yi(n),yi(i),Xg(32,32,db(n),(o,s,a)=>i(Vr(a[0],a[1],s[1],o[1],Qu(e))),t,r)}var Kde=PF("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",ap,hb(nb,!0),Uo,mf),Vde=PF("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",$F,hb(cF,!0),Uo,mf);function Bz(e,t,r,n,i){return yi(n),yi(i),Xg(32,32,db(n),(o,s,a)=>{let u=Vr(a[0],a[1],s[0],o[0],s[1],o[1],Qu(e)),f=32,h=Vr(Qu("hybrid_prk"),u),m=lF(i,h),p=Vr(Vl(f,2),Qu("shared_secret"),Qu("")),d=hF(i,m,p,f);return tn(m,p,h,u),d},t,r)}var xF=hb(uF),zde=Bz("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",ap,xF,Uo,Vg),Iz=Xg(32,32,db(Uo),(e,t,r)=>mf(Vr(r[0],r[1],t[1],e[1],Qu("\\.//^\\"))),ap,xF);function $z(e,t,r,n){let i=e.Point.Fn;if(!i)throw new Error("no Point.Fn");function o(s){let a;for(let h=0,m=t;;h=m,m+=t){if(m>s.length)throw new Error("rejection sampling failed");if(a=i.fromBytes(s.subarray(h,m),!0),i.isValidNot0(a))break}let u=i.toBytes(i.create(a)),f=e.getPublicKey(u,!1);return{secretKey:u,publicKey:f}}return{lengths:{secretKey:t,publicKey:r,seed:n,msg:n,cipherText:r},keygen(s=Ho(n)){return ot(s,n,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=Ho(n)){ot(a,n,"rand");let{secretKey:u}=o(a),f=this.decapsulate(s,u),h=e.getPublicKey(u,!1);return tn(u),{sharedSecret:f,cipherText:h}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function Pz(e,t,r,n){let{secretKey:i,publicKeyUncompressed:o}=r.lengths;if(!i||!o)throw new Error("wrong curve");let s=$z(r,i,o,n),a=64,u=a+n;return Xg(32,32,f=>{ot(f,32);let h=Uo(f,{dkLen:u}),m=h.subarray(0,a),p=h.subarray(a,u);return Vr(m,p)},(f,h,m)=>mf(Vr(m[0],m[1],h[1],f[1],Qu(e))),t,s)}var xz=Pz("MLKEM768-P256",ap,nb,128);var Zg=Iz,TF=xz;var bpe=P(x(),1);var Zde=P(x(),1);var cr=(e,t,r)=>Sn(e,t,r),gb=Hr,Xl=Sg,Fn=(...e)=>oE(...e),Zl=e=>Ld(e),Jl=nE,Ql=e=>Ku(e),Qg=BigInt(0),pb=BigInt(1);function Xa(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function em(e){if(typeof e=="bigint"){if(!Jg(e))throw new RangeError("positive bigint expected, got "+e)}else gb(e);return e}function qo(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 cp(e){let t=em(e).toString(16);return t.length&1?"0"+t:t}function RF(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Qg:BigInt("0x"+e)}function Ef(e){return RF(Sg(e))}function Xi(e){return RF(Sg(sc(Sn(e)).reverse()))}function tm(e,t){if(Hr(t),t===0)throw new RangeError("zero length");e=em(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return Ld(r.padStart(t*2,"0"))}function fp(e,t){return tm(e,t).reverse()}function kF(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 Jg=e=>typeof e=="bigint"&&Qg<=e;function Tz(e,t,r){return Jg(e)&&Jg(t)&&Jg(r)&&t<=e&&eQg;e>>=pb,t+=1);return t}var lp=e=>(pb<new Uint8Array(y),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,u=n(e),f=n(e),h=0,m=()=>{u.fill(1),f.fill(0),h=0},p=(...y)=>r(f,Fn(u,...y)),d=(y=i)=>{f=p(o,y),u=p(),y.length!==0&&(f=p(s,y),u=p())},v=()=>{if(h++>=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 bi(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 f=typeof u;if(f!==s||u===null)throw new TypeError(`param "${o}" is invalid: expected ${s}, got ${f}`)}let i=(o,s)=>Object.entries(o).forEach(([a,u])=>n(a,u,s));i(t,!1),i(r,!0)}var mb=()=>{throw new Error("not implemented")};var spe=P(x(),1);var epe=P(x(),1);var Bn=BigInt(0),$r=BigInt(1),bf=BigInt(2),HF=BigInt(3),qF=BigInt(4),MF=BigInt(5),Rz=BigInt(7),jF=BigInt(8),kz=BigInt(9),KF=BigInt(16);function wr(e,t){if(t<=Bn)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Bn?r:t+r}function Ai(e,t,r){if(tBn;)n*=n,n%=r;return n}function NF(e,t){if(e===Bn)throw new Error("invert: expected non-zero number");if(t<=Bn)throw new Error("invert: expected positive modulus, got "+t);let r=wr(e,t),n=t,i=Bn,o=$r,s=$r,a=Bn;for(;r!==Bn;){let f=n/r,h=n-r*f,m=i-s*f,p=o-a*f;n=r,r=h,i=s,o=a,s=m,a=p}if(n!==$r)throw new Error("invert: does not exist");return wr(i,t)}function vb(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function VF(e,t){let r=e,n=(r.ORDER+$r)/qF,i=r.pow(t,n);return vb(r,i,t),i}function Oz(e,t){let r=e,n=(r.ORDER-MF)/jF,i=r.mul(t,bf),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,bf),o),u=r.mul(s,r.sub(a,r.ONE));return vb(r,u,t),u}function Nz(e){let t=sm(e),r=zF(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+Rz)/KF;return(a,u)=>{let f=a,h=f.pow(u,s),m=f.mul(h,n),p=f.mul(h,i),d=f.mul(h,o),v=f.eql(f.sqr(m),u),g=f.eql(f.sqr(p),u);h=f.cmov(h,m,v),m=f.cmov(d,p,g);let y=f.eql(f.sqr(m),u),w=f.cmov(h,m,y);return vb(f,w,u),w}}function zF(e){if(e1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return VF;let o=i.pow(n,t),s=(t+$r)/bf;return function(u,f){let h=u;if(h.is0(f))return f;if(LF(h,f)!==1)throw new Error("Cannot find square root");let m=r,p=h.mul(h.ONE,o),d=h.pow(f,t),v=h.pow(f,s);for(;!h.eql(d,h.ONE);){if(h.is0(d))return h.ZERO;let g=1,y=h.sqr(d);for(;!h.eql(y,h.ONE);)if(g++,y=h.sqr(y),g===m)throw new Error("Cannot find square root");let w=$r<(wr(e,t)&$r)===$r,Uz=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wb(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Uz.reduce((n,i)=>(n[i]="function",n),t);if(bi(e,r),qo(e.BYTES,"BYTES"),qo(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=$r)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Hz(e,t,r){let n=e;if(rBn;)r&$r&&(i=n.mul(i,o)),o=n.sqr(o),r>>=$r;return i}function hp(e,t,r=!1){let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,u,f)=>n.is0(u)?a:(i[f]=a,n.mul(a,u)),n.ONE),s=n.inv(o);return t.reduceRight((a,u,f)=>n.is0(u)?a:(i[f]=n.mul(a,i[f]),n.mul(a,u)),s),i}function LF(e,t){let r=e,n=(r.ORDER-$r)/bf,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 qz(e,t){if(t!==void 0&&gb(t),e<=Bn)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=eh(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 UF=new WeakMap,nm=class{ORDER;BITS;BYTES;isLE;ZERO=Bn;ONE=$r;_lengths;_mod;constructor(t,r={}){if(t<=$r)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}=qz(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 wr(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Bn<=t&&ti)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(i);f.set(t,o?0:f.length-t.length),t=f}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let u=o?Xi(t):Ef(t);if(a&&(u=wr(u,s)),!r&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(t){return hp(this,t)}cmov(t,r,n){return Xa(n,"condition"),n?r:t}};Object.freeze(nm.prototype);function sm(e,t={}){return new nm(e,t)}function GF(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=$r)throw new Error("field order must be greater than 1");let t=eh(e-$r);return Math.ceil(t/8)}function yb(e){let t=GF(e);return t+Math.ceil(t/2)}function WF(e,t,r=!1){cr(e);let n=e.length,i=GF(t),o=Math.max(yb(t),16);if(n1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?Xi(e):Ef(e),a=wr(s,t-$r)+$r;return r?fp(a,i):tm(a,i)}var th=BigInt(0),Af=BigInt(1);function dp(e,t){let r=t.negate();return e?r:t}function Sf(e,t){let r=hp(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function JF(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){JF(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=lp(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function YF(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+=Af);let f=t*n,h=f+Math.abs(a)-1,m=a===0,p=a<0,d=t%2!==0;return{nextN:u,offset:h,isZero:m,isNeg:p,isNegF:d,offsetF:f}}var bb=new WeakMap,QF=new WeakMap;function Ab(e){return QF.get(e)||1}function XF(e){if(e!==th)throw new Error("invalid wNAF")}var rh=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>th;)r&Af&&(n=n.add(i)),i=i.double(),r>>=Af;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=Eb(r,this.bits),o=[],s=t,a=s;for(let u=0;uth||n>th;)r&Af&&(o=o.add(i)),n&Af&&(s=s.add(i)),i=i.double(),r>>=Af,n>>=Af;return{p1:o,p2:s}}function ZF(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 sm(e,{isLE:r})}function im(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 f=t[u];if(!(typeof f=="bigint"&&f>th))throw new Error(`CURVE.${u} must be positive bigint`)}let i=ZF(t.p,r.Fp,n),o=ZF(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 pp(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var ape=P(x(),1);function gp(e,t){if(qo(e),qo(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 Mz(e,t){let r=new Uint8Array(e.length);for(let n=0;n255&&(t=n(Fn(rm("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=Fn(t,gp(t.length,1)),u=new Uint8Array(o),f=gp(r,2),h=new Array(s),m=n(Fn(u,e,f,gp(0,1),a));h[0]=n(Fn(m,gp(1,1),a));for(let d=1;d(e+(e>=0?t:-t)/nB)/t;function Kz(e,t,r){Za("scalar",e,Mo,r);let[[n,i],[o,s]]=t,a=rB(s*e,r),u=rB(-i*e,r),f=e-a*n-u*o,h=-a*i-u*s,m=f=d||h=d)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:m,k1:f,k2neg:p,k2:h}}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){bi(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return Xa(r.lowS,"lowS"),Xa(r.prehash,"prehash"),r.format!==void 0&&_b(r.format),r}var Db=class extends Error{constructor(t=""){super(t)}},Zi={Err:Db,_tlv:{encode:(e,t)=>{let{Err:r}=Zi;if(qo(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=cp(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?cp(i.length/2|128):"";return cp(e)+o+i+t},decode(e,t){let{Err:r}=Zi;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 f=t.subarray(n,n+u);if(f.length!==u)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let h of f)s=s<<8|h;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}=Zi;if(em(e),e1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ef(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Zi,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:f,l:h}=n.decode(2,u);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=Zi,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(Zi._tlv);Object.freeze(Zi._int);Object.freeze(Zi);var Mo=BigInt(0),ic=BigInt(1),nB=BigInt(2),om=BigInt(3),Vz=BigInt(4);function sB(e,t={}){let r=im("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;bi(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:u,allowInfinityPoint:f}=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 h=oB(n,i);function m(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function p(R,O,q){if(f&&O.is0())return Uint8Array.of(0);let{x:N,y:_}=O.toAffine(),k=n.toBytes(N);if(Xa(q,"isCompressed"),q){m();let K=!n.isOdd(_);return Fn(iB(K),k)}else return Fn(Uint8Array.of(4),k,n.toBytes(_))}function d(R){cr(R,void 0,"Point");let{publicKey:O,publicKeyUncompressed:q}=h,N=R.length,_=R[0],k=R.subarray(1);if(f&&N===1&&_===0)return{x:n.ZERO,y:n.ZERO};if(N===O&&(_===2||_===3)){let K=n.fromBytes(k);if(!n.isValid(K))throw new Error("bad point: is not on curve, wrong x");let Z=y(K),G;try{G=n.sqrt(Z)}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(G);return(_&1)===1!==ee&&(G=n.neg(G)),{x:K,y:G}}else if(N===q&&_===4){let K=n.BYTES,Z=n.fromBytes(k.subarray(0,K)),G=n.fromBytes(k.subarray(K,K*2));if(!w(Z,G))throw new Error("bad point: is not on curve");return{x:Z,y:G}}else throw new Error(`bad point: got length ${N}, expected compressed=${O} or uncompressed=${q}`)}let v=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?d:t.fromBytes;function y(R){let O=n.sqr(R),q=n.mul(O,R);return n.add(n.add(q,n.mul(R,o.a)),o.b)}function w(R,O){let q=n.sqr(O),N=y(R);return n.eql(q,N)}if(!w(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let E=n.mul(n.pow(o.a,om),Vz),C=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(E,C)))throw new Error("bad curve params: a or b");function D(R,O,q=!1){if(!n.isValid(O)||q&&n.is0(O))throw new Error(`bad point coordinate ${R}`);return O}function B(R){if(!(R instanceof S))throw new Error("Weierstrass Point expected")}function H(R){if(!u||!u.basises)throw new Error("no endo");return Kz(R,u.basises,i.ORDER)}function V(R,O,q,N,_){return q=new S(n.mul(q.X,R),q.Y,q.Z),O=dp(N,O),q=dp(_,q),O.add(q)}class S{static BASE=new S(o.Gx,o.Gy,n.ONE);static ZERO=new S(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=i;X;Y;Z;constructor(O,q,N){this.X=D("x",O),this.Y=D("y",q,!0),this.Z=D("z",N),Object.freeze(this)}static CURVE(){return o}static fromAffine(O){let{x:q,y:N}=O||{};if(!O||!n.isValid(q)||!n.isValid(N))throw new Error("invalid affine point");if(O instanceof S)throw new Error("projective point not allowed");return n.is0(q)&&n.is0(N)?S.ZERO:new S(q,N,n.ONE)}static fromBytes(O){let q=S.fromAffine(g(cr(O,void 0,"point")));return q.assertValidity(),q}static fromHex(O){return S.fromBytes(Zl(O))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(O=8,q=!0){return U.createCache(this,O),q||this.multiply(om),this}assertValidity(){let O=this;if(O.is0()){if(t.allowInfinityPoint&&n.is0(O.X)&&n.eql(O.Y,n.ONE)&&n.is0(O.Z))return;throw new Error("bad point: ZERO")}let{x:q,y:N}=O.toAffine();if(!n.isValid(q)||!n.isValid(N))throw new Error("bad point: x or y not field elements");if(!w(q,N))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:O}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(O)}equals(O){B(O);let{X:q,Y:N,Z:_}=this,{X:k,Y:K,Z}=O,G=n.eql(n.mul(q,Z),n.mul(k,_)),ee=n.eql(n.mul(N,Z),n.mul(K,_));return G&&ee}negate(){return new S(this.X,n.neg(this.Y),this.Z)}double(){let{a:O,b:q}=o,N=n.mul(q,om),{X:_,Y:k,Z:K}=this,Z=n.ZERO,G=n.ZERO,ee=n.ZERO,se=n.mul(_,_),le=n.mul(k,k),ve=n.mul(K,K),we=n.mul(_,k);return we=n.add(we,we),ee=n.mul(_,K),ee=n.add(ee,ee),Z=n.mul(O,ee),G=n.mul(N,ve),G=n.add(Z,G),Z=n.sub(le,G),G=n.add(le,G),G=n.mul(Z,G),Z=n.mul(we,Z),ee=n.mul(N,ee),ve=n.mul(O,ve),we=n.sub(se,ve),we=n.mul(O,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),G=n.add(G,se),ve=n.mul(k,K),ve=n.add(ve,ve),se=n.mul(ve,we),Z=n.sub(Z,se),ee=n.mul(ve,le),ee=n.add(ee,ee),ee=n.add(ee,ee),new S(Z,G,ee)}add(O){B(O);let{X:q,Y:N,Z:_}=this,{X:k,Y:K,Z}=O,G=n.ZERO,ee=n.ZERO,se=n.ZERO,le=o.a,ve=n.mul(o.b,om),we=n.mul(q,k),Pe=n.mul(N,K),Le=n.mul(_,Z),Oe=n.add(q,N),fe=n.add(k,K);Oe=n.mul(Oe,fe),fe=n.add(we,Pe),Oe=n.sub(Oe,fe),fe=n.add(q,_);let Se=n.add(k,Z);return fe=n.mul(fe,Se),Se=n.add(we,Le),fe=n.sub(fe,Se),Se=n.add(N,_),G=n.add(K,Z),Se=n.mul(Se,G),G=n.add(Pe,Le),Se=n.sub(Se,G),se=n.mul(le,fe),G=n.mul(ve,Le),se=n.add(G,se),G=n.sub(Pe,se),se=n.add(Pe,se),ee=n.mul(G,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),G=n.mul(Oe,G),G=n.sub(G,we),we=n.mul(Oe,Pe),se=n.mul(Se,se),se=n.add(se,we),new S(G,ee,se)}subtract(O){return B(O),this.add(O.negate())}is0(){return this.equals(S.ZERO)}multiply(O){let{endo:q}=t;if(!i.isValidNot0(O))throw new RangeError("invalid scalar: out of range");let N,_,k=K=>U.cached(this,K,Z=>Sf(S,Z));if(q){let{k1neg:K,k1:Z,k2neg:G,k2:ee}=H(O),{p:se,f:le}=k(Z),{p:ve,f:we}=k(ee);_=le.add(we),N=V(q.beta,se,ve,K,G)}else{let{p:K,f:Z}=k(O);N=K,_=Z}return Sf(S,[N,_])[0]}multiplyUnsafe(O){let{endo:q}=t,N=this,_=O;if(!i.isValid(_))throw new RangeError("invalid scalar: out of range");if(_===Mo||N.is0())return S.ZERO;if(_===ic)return N;if(U.hasCache(this))return this.multiply(_);if(q){let{k1neg:k,k1:K,k2neg:Z,k2:G}=H(_),{p1:ee,p2:se}=eB(S,N,K,G);return V(q.beta,ee,se,k,Z)}else return U.unsafe(N,_)}toAffine(O){let q=this,N=O,{X:_,Y:k,Z:K}=q;if(n.eql(K,n.ONE))return{x:_,y:k};let Z=q.is0();N==null&&(N=Z?n.ONE:n.inv(K));let G=n.mul(_,N),ee=n.mul(k,N),se=n.mul(K,N);if(Z)return{x:n.ZERO,y:n.ZERO};if(!n.eql(se,n.ONE))throw new Error("invZ was invalid");return{x:G,y:ee}}isTorsionFree(){let{isTorsionFree:O}=t;return s===ic?!0:O?O(S,this):U.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:O}=t;return s===ic?this:O?O(S,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===ic?this.is0():this.clearCofactor().is0()}toBytes(O=!0){return Xa(O,"isCompressed"),this.assertValidity(),v(S,this,O)}toHex(O=!0){return Xl(this.toBytes(O))}toString(){return``}}let I=i.BITS,U=new rh(S,t.endo?Math.ceil(I/2):I);return I>=8&&S.BASE.precompute(8),Object.freeze(S.prototype),Object.freeze(S),S}function iB(e){return Uint8Array.of(e?2:3)}function oB(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function zz(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?Ql:t.randomBytes,i=Object.assign(oB(e.Fp,r),{seed:Math.max(yb(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,WF(cr(d,i.seed,"seed"),r.ORDER)}function u(d,v=!0){return e.BASE.multiply(r.fromBytes(d)).toBytes(v)}function f(d){let{secretKey:v,publicKey:g,publicKeyUncompressed:y}=i,w=r._lengths;if(!Jl(d))return;let E=cr(d,void 0,"key").length,C=E===g||E===y,D=E===v||!!w?.includes(E);if(!(C&&D))return C}function h(d,v,g=!0){if(f(d)===!0)throw new Error("first arg must be private key");if(f(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=pp(a,u);return Object.freeze(m),Object.freeze(i),Object.freeze({getPublicKey:u,getSharedSecret:h,keygen:p,Point:e,utils:m,lengths:i})}function aB(e,t,r={}){let n=t;Ma(n),bi(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes===void 0?Ql:r.randomBytes,o=r.hmac===void 0?(_,k)=>ko(n,_,k):r.hmac,{Fp:s,Fn:a}=e,{ORDER:u,BITS:f}=a,{keygen:h,getPublicKey:m,getSharedSecret:p,utils:d,lengths:v}=zz(e,r),g={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=u*nB+ic>ic;return _>k}function E(_,k){if(!a.isValidNot0(k))throw new Error(`invalid signature ${_}: out of range 1..Point.Fn.ORDER`);return k}function C(){if(y)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function D(_,k){_b(k);let K=v.signature,Z=k==="compact"?K:k==="recovered"?K+1:void 0;return cr(_,Z)}class B{r;s;recovery;constructor(k,K,Z){if(this.r=E("r",k),this.s=E("s",K),Z!=null){if(C(),![0,1,2,3].includes(Z))throw new Error("invalid recovery id");this.recovery=Z}Object.freeze(this)}static fromBytes(k,K=g.format){D(k,K);let Z;if(K==="der"){let{r:le,s:ve}=Zi.toSig(cr(k));return new B(le,ve)}K==="recovered"&&(Z=k[0],K="compact",k=k.subarray(1));let G=v.signature/2,ee=k.subarray(0,G),se=k.subarray(G,G*2);return new B(a.fromBytes(ee),a.fromBytes(se),Z)}static fromHex(k,K){return this.fromBytes(Zl(k),K)}assertRecovery(){let{recovery:k}=this;if(k==null)throw new Error("invalid recovery id: must be present");return k}addRecoveryBit(k){return new B(this.r,this.s,k)}recoverPublicKey(k){let{r:K,s:Z}=this,G=this.assertRecovery(),ee=G===2||G===3?K+u:K;if(!s.isValid(ee))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let se=s.toBytes(ee),le=e.fromBytes(Fn(iB((G&1)===0),se)),ve=a.inv(ee),we=V(cr(k,void 0,"msgHash")),Pe=a.create(-we*ve),Le=a.create(Z*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(k=g.format){if(_b(k),k==="der")return Zl(Zi.hexFromSig(this));let{r:K,s:Z}=this,G=a.toBytes(K),ee=a.toBytes(Z);return k==="recovered"?(C(),Fn(Uint8Array.of(this.assertRecovery()),G,ee)):Fn(G,ee)}toHex(k){return Xl(this.toBytes(k))}}Object.freeze(B.prototype),Object.freeze(B);let H=r.bits2int===void 0?function(k){if(k.length>8192)throw new Error("input is too large");let K=Ef(k),Z=k.length*8-f;return Z>0?K>>BigInt(Z):K}:r.bits2int,V=r.bits2int_modN===void 0?function(k){return a.create(H(k))}:r.bits2int_modN,S=lp(f);function I(_){return Za("num < 2^"+f,_,Mo,S),a.toBytes(_)}function U(_,k){return cr(_,void 0,"message"),k?cr(n(_),void 0,"prehashed message"):_}function R(_,k,K){let{lowS:Z,prehash:G,extraEntropy:ee}=Cb(K,g);_=U(_,G);let se=V(_),le=a.fromBytes(k);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=Fn(...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===Mo)return;let Qe=a.create(Se*a.create(Pe+Ke*le));if(Qe===Mo)return;let Me=(Re.x===Ke?0:2)|Number(Re.y&ic),yt=Qe;return Z&&w(Qe)&&(yt=a.neg(Qe),Me^=1),new B(Ke,yt,y?void 0:Me)}return{seed:we,k2sig:Le}}function O(_,k,K={}){let{seed:Z,k2sig:G}=R(_,k,K);return OF(n.outputLen,a.BYTES,o)(Z,G).toBytes(K.format)}function q(_,k,K,Z={}){let{lowS:G,prehash:ee,format:se}=Cb(Z,g);if(K=cr(K,void 0,"publicKey"),k=U(k,ee),!Jl(_)){let le=_ instanceof B?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+le)}D(_,se);try{let le=B.fromBytes(_,se),ve=e.fromBytes(K);if(G&&le.hasHighS())return!1;let{r:we,s:Pe}=le,Le=V(k),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(_,k,K={}){let{prehash:Z}=Cb(K,g);return k=U(k,Z),B.fromBytes(_,"recovered").recoverPublicKey(k).toBytes()}return Object.freeze({keygen:h,getPublicKey:m,getSharedSecret:p,utils:d,lengths:v,Point:e,sign:O,verify:q,recoverPublicKey:N,Signature:B,hash:n})}var Gz={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var Wz=sB(Gz),nh=aB(Wz,qr);var Kpe=P(x(),1);var Mpe=P(x(),1);var _pe=P(x(),1);var oc=BigInt(0),Os=BigInt(1),Fb=BigInt(2),Yz=BigInt(8);function Xz(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 uB(e,t={}){let r=t,n=im("edwards",e,r,r.FpFnLE),{Fp:i,Fn:o}=n,s=n.CURVE,{h:a}=s;bi(r,{},{uvRatio:"function"});let u=Fb<i.create(g),h=r.uvRatio===void 0?(g,y)=>{try{return{isValid:!0,value:i.sqrt(i.div(g,y))}}catch{return{isValid:!1,value:oc}}}:r.uvRatio;if(!Xz(i,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function m(g,y,w=!1){let E=w?Os:oc;return Za("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,Os,f(s.Gx*s.Gy));static ZERO=new d(oc,Os,Os,oc);static Fp=i;static Fn=o;X;Y;Z;T;constructor(y,w,E,C){this.X=m("x",y),this.Y=m("y",w),this.Z=m("z",E,!0),this.T=m("t",C),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,Os,f(w*E))}static fromBytes(y,w=!1){let E=i.BYTES,{a:C,d:D}=s;y=sc(cr(y,E,"point")),Xa(w,"zip215");let B=sc(y),H=y[E-1];B[E-1]=H&-129;let V=Xi(B),S=w?u:i.ORDER;Za("point.y",V,oc,S);let I=f(V*V),U=f(I-Os),R=f(D*I-C),{isValid:O,value:q}=h(U,R);if(!O)throw new Error("bad point: invalid y coordinate");let N=(q&Os)===Os,_=(H&128)!==0;if(!w&&q===oc&&_)throw new Error("bad point: x=0 and x_0=1");return _!==N&&(q=f(-q)),d.fromAffine({x:q,y:V})}static fromHex(y,w=!1){return d.fromBytes(Zl(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(Fb),this}assertValidity(){let y=this,{a:w,d:E}=s;if(y.is0())throw new Error("bad point: ZERO");let{X:C,Y:D,Z:B,T:H}=y,V=f(C*C),S=f(D*D),I=f(B*B),U=f(I*I),R=f(V*w),O=f(I*f(R+S)),q=f(U+f(E*f(V*S)));if(O!==q)throw new Error("bad point: equation left != right (1)");let N=f(C*D),_=f(B*H);if(N!==_)throw new Error("bad point: equation left != right (2)")}equals(y){p(y);let{X:w,Y:E,Z:C}=this,{X:D,Y:B,Z:H}=y,V=f(w*H),S=f(D*C),I=f(E*H),U=f(B*C);return V===S&&I===U}is0(){return this.equals(d.ZERO)}negate(){return new d(f(-this.X),this.Y,this.Z,f(-this.T))}double(){let{a:y}=s,{X:w,Y:E,Z:C}=this,D=f(w*w),B=f(E*E),H=f(Fb*f(C*C)),V=f(y*D),S=w+E,I=f(f(S*S)-D-B),U=V+B,R=U-H,O=V-B,q=f(I*R),N=f(U*O),_=f(I*O),k=f(R*U);return new d(q,N,k,_)}add(y){p(y);let{a:w,d:E}=s,{X:C,Y:D,Z:B,T:H}=this,{X:V,Y:S,Z:I,T:U}=y,R=f(C*V),O=f(D*S),q=f(H*E*U),N=f(B*I),_=f((C+D)*(V+S)-R-O),k=N-q,K=N+q,Z=f(O-w*R),G=f(_*k),ee=f(K*Z),se=f(_*Z),le=f(k*K);return new d(G,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,C=>Sf(d,C));return Sf(d,[w,E])[0]}multiplyUnsafe(y){if(!o.isValid(y))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return y===oc?d.ZERO:this.is0()||y===Os?this:v.unsafe(this,y,w=>Sf(d,w))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return v.unsafe(this,s.n).is0()}toAffine(y){let w=this,E=y,{X:C,Y:D,Z:B}=w,H=w.is0();E==null&&(E=H?Yz:i.inv(B));let V=f(C*E),S=f(D*E),I=i.mul(B,E);if(H)return{x:oc,y:Os};if(I!==Os)throw new Error("invZ was invalid");return{x:V,y:S}}clearCofactor(){return a===Os?this:this.multiplyUnsafe(a)}toBytes(){let{x:y,y:w}=this.toAffine(),E=i.toBytes(w);return E[E.length-1]|=y&Os?128:0,E}toHex(){return Xl(this.toBytes())}toString(){return``}}let v=new rh(d,o.BITS);return o.BITS>=8&&d.BASE.precompute(8),Object.freeze(d.prototype),Object.freeze(d),d}var am=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){mb()}static fromHex(t){mb()}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 Xl(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 $pe=P(x(),1);var mp=BigInt(0),sh=BigInt(1),um=BigInt(2);function Zz(e){return bi(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function cB(e){let t=Zz(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?Ql:s,f=a?255:448,h=a?32:56,m=BigInt(a?9:5),p=BigInt(a?121665:39081),d=a?um**BigInt(254):um**BigInt(447),v=a?BigInt(8)*um**BigInt(251)-sh:BigInt(4)*um**BigInt(445)-sh,g=d+v+sh,y=N=>wr(N,r),w=E(m);function E(N){return fp(y(N),h)}function C(N){let _=sc(cr(N,h,"uCoordinate"));return a&&(_[31]&=127),y(Xi(_))}function D(N){return Xi(i(sc(cr(N,h,"scalar"))))}function B(N,_){let k=U(C(_),D(N));if(k===mp)throw new Error("invalid private or public key received");return E(k)}function H(N){return B(N,w)}let V=H,S=B;function I(N,_,k){let K=y(N*(_-k));return _=y(_-K),k=y(k+K),{x_2:_,x_3:k}}function U(N,_){Za("u",N,mp,r),Za("scalar",_,d,g);let k=_,K=N,Z=sh,G=mp,ee=N,se=sh,le=mp;for(let we=BigInt(f-1);we>=mp;we--){let Pe=k>>we&sh;le^=Pe,{x_2:Z,x_3:ee}=I(le,Z,ee),{x_2:G,x_3:se}=I(le,G,se),le=Pe;let Le=Z+G,Oe=y(Le*Le),fe=Z-G,Se=y(fe*fe),Re=Oe-Se,Ke=ee+se,Qe=ee-se,Me=y(Qe*Le),yt=y(Ke*fe),rt=Me+yt,vt=Me-yt;ee=y(rt*rt),se=y(K*y(vt*vt)),Z=y(Oe*Se),G=y(Re*(Oe+y(p*Re)))}({x_2:Z,x_3:ee}=I(le,Z,ee)),{x_2:G,x_3:se}=I(le,G,se);let ve=o(G);return y(Z*ve)}let R={secretKey:h,publicKey:h,seed:h},O=N=>(N=N===void 0?u(h):N,cr(N,R.seed,"seed"),N),q={randomSecretKey:O};return Object.freeze(R),Object.freeze(q),Object.freeze({keygen:pp(O,V),getSharedSecret:S,getPublicKey:V,scalarMult:B,scalarMultBase:H,utils:q,GuBytes:w.slice(),lengths:R})}var Jz=BigInt(0),Qa=BigInt(1),fB=BigInt(2),Qz=BigInt(3),eG=BigInt(5),tG=BigInt(8),_f=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Pb={p:_f,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:tG,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function dB(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=_f,a=e*e%o*e%o,u=Ai(a,fB,o)*a%o,f=Ai(u,Qa,o)*e%o,h=Ai(f,eG,o)*f%o,m=Ai(h,t,o)*h%o,p=Ai(m,r,o)*m%o,d=Ai(p,n,o)*p%o,v=Ai(d,i,o)*d%o,g=Ai(v,i,o)*d%o,y=Ai(g,t,o)*h%o;return{pow_p_5_8:Ai(y,fB,o)*e%o,b2:a}}function rG(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Bb=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function xb(e,t){let r=_f,n=wr(t*t*t,r),i=wr(n*n*t,r),o=dB(e*i).pow_p_5_8,s=wr(e*n*o,r),a=wr(t*s*s,r),u=s,f=wr(s*Bb,r),h=a===e,m=a===wr(-e,r),p=a===wr(-e*Bb,r);return h&&(s=u),(m||p)&&(s=f),Ja(s,r)&&(s=wr(-s,r)),{isValid:h||m,value:s}}var Cf=uB(Pb,{uvRatio:xb}),ac=Cf.Fp,pB=Cf.Fn;var cm=(()=>{let e=_f;return cB({P:e,type:"x25519",powPminus2:t=>{let{pow_p_5_8:r,b2:n}=dB(t);return wr(Ai(r,Qz,e)*n,e)},adjustScalarBytes:rG})})();var Ib=Bb,nG=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),sG=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),iG=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),oG=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),lB=e=>xb(Qa,e),aG=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),$b=e=>ac.create(Xi(e)&aG);function hB(e){let{d:t}=Pb,r=_f,n=w=>ac.create(w),i=n(Ib*e*e),o=n((i+Qa)*iG),s=BigInt(-1),a=n((s-t*i)*n(i+t)),{isValid:u,value:f}=xb(o,a),h=n(f*e);Ja(h,r)||(h=n(-h)),u||(f=h),u||(s=i);let m=n(s*(i-Qa)*oG-a),p=f*f,d=n((f+f)*a),v=n(m*nG),g=n(Qa-p),y=n(Qa+p);return new Cf(n(d*y),n(g*v),n(v*y),n(d*g))}var uc=class e extends am{static BASE=new e(Cf.BASE);static ZERO=new e(Cf.ZERO);static Fp=ac;static Fn=pB;constructor(t){super(t)}static fromAffine(t){return new e(Cf.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static fromBytes(t){Sn(t,32);let{a:r,d:n}=Pb,i=_f,o=D=>ac.create(D),s=$b(t);if(!kF(ac.toBytes(s),t)||Ja(s,i))throw new Error("invalid ristretto255 encoding 1");let a=o(s*s),u=o(Qa+r*a),f=o(Qa-r*a),h=o(u*u),m=o(f*f),p=o(r*n*h-m),{isValid:d,value:v}=lB(o(p*m)),g=o(v*f),y=o(v*g*p),w=o((s+s)*g);Ja(w,i)&&(w=o(-w));let E=o(u*y),C=o(w*E);if(!d||Ja(C,i)||E===Jz)throw new Error("invalid ristretto255 encoding 2");return new e(new Cf(w,E,Qa,C))}static fromHex(t){return e.fromBytes(Ld(t))}toBytes(){let{X:t,Y:r,Z:n,T:i}=this.ep,o=_f,s=y=>ac.create(y),a=s(s(n+r)*s(n-r)),u=s(t*r),f=s(u*u),{value:h}=lB(s(a*f)),m=s(h*a),p=s(h*u),d=s(m*p*i),v;if(Ja(i*d,o)){let y=s(r*Ib),w=s(t*Ib);t=y,r=w,v=s(m*sG)}else v=p;Ja(t*d,o)&&(r=s(-r));let g=s((n-r)*v);return Ja(g,o)&&(g=s(-g)),ac.toBytes(g)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:i,Y:o}=t.ep,s=f=>ac.create(f),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(uc.BASE);Object.freeze(uc.ZERO);Object.freeze(uc.prototype);Object.freeze(uc);var uG=Object.freeze({Point:uc,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=Sb(e,r,64,Fg);return uG.deriveToCurve(n)},hashToScalar(e,t={DST:tB}){let r=Sb(e,t.DST,64,Fg);return pB.create(Xi(r))},deriveToCurve(e){Sn(e,64);let t=$b(e.subarray(0,32)),r=hB(t),n=$b(e.subarray(32,64)),i=hB(n);return new uc(r.add(i))}});var gB=!1,cG=!1;async function mB(e,t){if(cG)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 fm(e,t){return await mB(async()=>{let r=Tb(e)?e:await lG(e),n=await crypto.subtle.importKey("raw",t,{name:"X25519"},gB,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:n},r,256))},()=>{if(Tb(e))throw new Error("CryptoKey provided but X25519 WebCrypto is not supported");return cm.scalarMult(e,t)})}async function vp(e){return await mB(async()=>fm(e,cm.GuBytes),()=>{if(Tb(e))throw new Error("CryptoKey provided but X25519 WebCrypto is not supported");return cm.scalarMultBase(e)})}var fG=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function lG(e){if(e.length!==32)throw new Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...fG,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},gB,["deriveBits"])}function Tb(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var Xpe=P(x(),1);var zpe=P(x(),1);var lm=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),dG(Df(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=Df(t),null;this.buf=n.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:Df(this.transcript)}}};function dG(e){return e.forEach(t=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function Df(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 ih(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let n of t)r.enqueue(n)}}))}function hm(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function Rb(e){if(!(e instanceof ReadableStream))throw new Error("readAll expects a ReadableStream");return new Uint8Array(await new Response(e).arrayBuffer())}async function vB(e){if(!(e instanceof ReadableStream))throw new Error("readAllString expects a ReadableStream");return await new Response(e).text()}async function wB(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=Xn.decode(o);if(s.length>48)throw Error("invalid stanza");if(n.push(s),s.length<48)break}let i=Df(n);return{s:new Ji(r,i)}}async function yB(e){let t=new lm(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 pG(t);if(i!==void 0){n.push(i);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=Xn.decode(o.slice(4)),{rest:a,transcript:u}=t.close(),f=u.slice(0,u.length-1-o.length+3);return{stanzas:n,headerNoMAC:f,MAC:s,headerSize:u.length,rest:ih(e,a)}}}function kb(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(Xn.encode(r.body.subarray(n,i))+` `)}r.body.length%48===0&&t.push(` `)}return t.push("---"),new TextEncoder().encode(t.join(""))}function EB(e,t){return Df([kb(e),new TextEncoder().encode(" "+Xn.encode(t)+` `)])}async function bm(e){let t;if(AB(e))t=e;else if(e.startsWith("AGE-SECRET-KEY-PQ-1")){let n=vi.decodeToBytes(e);if(n.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||n.bytes.length!==32)throw Error("invalid identity");let i=Zg.getPublicKey(n.bytes);return vi.encode("age1pq",vi.toWords(i),!1)}else{let n=vi.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 vp(t);return vi.encodeFromBytes("age",r)}var pm=class{recipient;constructor(t){let r=vi.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}=Zg.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:o,nonce:s}=Am(bB,n,i),a=wi(o,s).encrypt(t);return[new Ji(["mlkem768x25519",Xn.encode(r)],a)]}},gm=class{identity;constructor(t){let r=vi.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=Xn.decode(r.args[1]);if(n.length!==1120||r.body.length!==32)throw Error("invalid mlkem768x25519 stanza");let i=Zg.decapsulate(n,this.identity),o=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:s,nonce:a}=Am(bB,i,o);try{return wi(s,a).decrypt(r.body)}catch{continue}}return null}},bB=25722,gG=80,Ob=16;function Am(e,t,r){let n=mG(e),i=dm(n,void 0,"psk_id_hash",new Uint8Array(0)),o=dm(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=dm(n,t,"secret",new Uint8Array(0)),u=Nb(n,a,"key",s,32),f=Nb(n,a,"base_nonce",s,12);return{key:u,nonce:f}}function mG(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 dm(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),Ud(qr,i,t)}function Nb(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),fE(qr,t,o,i)}function vG(e){e.length!==nh.lengths.publicKeyUncompressed&&(e=nh.Point.fromBytes(e).toBytes(!1));let t=nh.utils.randomSecretKey(),r=nh.getPublicKey(t,!1),n=nh.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]=Ob>>8,o[4]=Ob&255;let s=dm(o,void 0,"eae_prk",n),a=Nb(o,s,"shared_secret",i,32);return{encapsulatedKey:r,sharedSecret:a}}var mm=class{recipient;constructor(t){let r=vi.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}=vG(this.recipient),i=new TextEncoder().encode("age-encryption.org/p256tag"),o=(()=>{let f=qr(this.recipient).subarray(0,4),h=new Uint8Array(r.length+f.length);return h.set(r,0),h.set(f,r.length),Ud(qr,h,i).subarray(0,4)})(),{key:s,nonce:a}=Am(Ob,n,i),u=wi(s,a).encrypt(t);return[new Ji(["p256tag",Xn.encode(o),Xn.encode(r)],u)]}},vm=class{recipient;constructor(t){let r=vi.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}=TF.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768p256tag"),o=(()=>{let f=qr(this.recipient.subarray(1184)).subarray(0,4),h=new Uint8Array(r.length+f.length);return h.set(r,0),h.set(f,r.length),Ud(qr,h,i).subarray(0,4)})(),{key:s,nonce:a}=Am(gG,n,i),u=wi(s,a).encrypt(t);return[new Ji(["mlkem768p256tag",Xn.encode(o),Xn.encode(r)],u)]}},wm=class{recipient;constructor(t){let r=vi.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=Ku(32),n=await vp(r),i=await fm(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=Vu(qr,i,o,s,32);return[new Ji(["X25519",Xn.encode(n)],Lb(t,a))]}},wp=class{identity;recipient;constructor(t){if(AB(t)){this.identity=t,this.recipient=vp(t);return}let r=vi.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=vp(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=Xn.decode(r.args[1]);if(n.length!==32)throw Error("invalid X25519 stanza");let i=await fm(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=Vu(qr,i,s,a,32),f=Ub(r.body,u);if(f!==null)return f}return null}},ym=class{passphrase;logN;constructor(t,r){this.passphrase=t,this.logN=r}wrapFileKey(t){let r=Ku(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=IE(this.passphrase,i,{N:2**this.logN,r:8,p:1,dkLen:32});return[new Ji(["scrypt",Xn.encode(r),this.logN.toString()],Lb(t,o))]}},Em=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=Xn.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=IE(this.passphrase,s,{N:2**i,r:8,p:1,dkLen:32}),u=Ub(r.body,a);if(u!==null)return u}return null}};function Lb(e,t){let r=new Uint8Array(12);return wi(t,r).encrypt(e)}function Ub(e,t){if(e.length!==32)throw Error("invalid stanza");let r=new Uint8Array(12);try{return wi(t,r).decrypt(e)}catch{return null}}function AB(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var h0e=P(x(),1);var Ff=16,qb=64*1024,Hb=qb+Ff;function SB(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(Hb),o=0;return new TransformStream({transform(s,a){for(;s.length>0;){if(o===i.length){let f=wi(e,t).decrypt(i);a.enqueue(f),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=wi(e,t).decrypt(i.subarray(0,o));if(!n&&a.length===0)throw new Error("final chunk is empty");s.enqueue(a)}})}function CB(e){if(e0?Ff:0,n}function _B(e){let t=new Uint8Array(12),r=()=>{for(let o=t.length-2;o>=0&&(t[o]++,t[o]===0);o--);},n=new Uint8Array(qb),i=0;return new TransformStream({transform(o,s){for(;o.length>0;){if(i===n.length){let u=wi(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=wi(e,t).encrypt(n.subarray(0,i));o.enqueue(s)}})}function DB(e){let t=Math.max(1,Math.ceil(e/qb));return e+Ff*t}var yp={};Kk(yp,{decode:()=>yG,encode:()=>wG});var g0e=P(x(),1);function wG(e){let t=[];t.push(`-----BEGIN AGE ENCRYPTED FILE----- `);for(let r=0;re.length&&(n=e.length),t.push(DE.encode(e.subarray(r,n))+` `)}return t.push(`-----END AGE ENCRYPTED FILE----- `),t.join("")}function yG(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 DE.decode(t.join(""))}var I0e=P(x(),1);var m0e=P(x(),1);var Ep=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 pm(t));else if(t.startsWith("age1tag1"))this.recipients.push(new mm(t));else if(t.startsWith("age1tagpq1"))this.recipients.push(new vm(t));else if(t.startsWith("age1"))this.recipients.push(new wm(t));else throw new Error("unrecognized recipient type");else this.recipients.push(t)}async encrypt(t){let r=Ku(16),n=[],i=this.recipients;this.passphrase!==null&&(i=[new ym(this.passphrase,this.scryptWorkFactor)]);for(let d of i)n.push(...await d.wrapFileKey(r));let o=new TextEncoder().encode("header"),s=Vu(qr,r,void 0,o,32),a=ko(qr,s,kb(n)),u=EB(n,a),f=Ku(16),h=new TextEncoder().encode("payload"),m=Vu(qr,r,f,h,32),p=_B(m);return t instanceof ReadableStream?Object.assign(ih(t.pipeThrough(p),u,f),{size:d=>DB(d)+u.length+f.length}):(typeof t=="string"&&(t=new TextEncoder().encode(t)),await Rb(ih(hm(t).pipeThrough(p),u,f)))}},Sm=class{identities=[];addPassphrase(t){this.identities.push(new Em(t))}addIdentity(t){if(_G(t))this.identities.push(new wp(t));else if(typeof t=="string")if(t.startsWith("AGE-SECRET-KEY-1"))this.identities.push(new wp(t));else if(t.startsWith("AGE-SECRET-KEY-PQ-1"))this.identities.push(new gm(t));else throw new Error("unrecognized identity type");else this.identities.push(t)}async decrypt(t,r){let n=t instanceof ReadableStream?t:hm(t),{fileKey:i,headerSize:o,rest:s}=await this.decryptHeaderInternal(n),{data:a,rest:u}=await wB(s,16),f=new TextEncoder().encode("payload"),h=Vu(qr,i,a,f,32),m=SB(h),p=u.pipeThrough(m),d=Object.assign(p,{size:v=>CB(v-o-a.length)});return t instanceof ReadableStream?d:r==="text"?await vB(p):await Rb(p)}async decryptHeader(t){return(await this.decryptHeaderInternal(hm(t))).fileKey}async decryptHeaderInternal(t){let r=await yB(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=Vu(qr,n,void 0,i,32),s=ko(qr,o,r.headerNoMAC);if(!CG(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 CG(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(", ")}`);LG(e)}function Cm(){return typeof DOMException<"u"?new DOMException("X25519 WebCrypto is not available","NotSupportedError"):new ReferenceError("X25519 WebCrypto is not available")}function RG(){let e={importKey(){throw Cm()},deriveBits(){throw Cm()}};return e[jb]=!0,e}function kG(e){return typeof e=="string"?e:e?.name}function IB(e){return String(kG(e)||"").toUpperCase()==="X25519"}function OG(e){let t=String(e?.message||e||"");return/x25519|algorithm|not\s+supported|unsupported|unrecognized|unknown/i.test(t)}function $B(e){return e instanceof TypeError||e instanceof ReferenceError||e?.name==="TypeError"||e?.name==="ReferenceError"||e?.name==="NotSupportedError"||e?.name==="Error"&&OG(e)||typeof DOMException<"u"&&e instanceof DOMException&&e.name==="NotSupportedError"}function NG(e){let t=Object.create(e);return Object.defineProperty(t,jb,{configurable:!0,value:!0}),Object.defineProperty(t,"importKey",{configurable:!0,value:async(...r)=>{try{return await e.importKey.apply(e,r)}catch(n){throw IB(r[2])&&$B(n)?Cm():n}}}),Object.defineProperty(t,"deriveBits",{configurable:!0,value:async(...r)=>{try{return await e.deriveBits.apply(e,r)}catch(n){throw IB(r[0])&&$B(n)?Cm():n}}}),t}function PB(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 LG(e=globalThis){let t=e?.crypto,r=t?.subtle;if(!(!t||r?.[jb])){if(!r||typeof r.importKey!="function"||typeof r.deriveBits!="function"){PB(e,t,RG());return}typeof process>"u"&&PB(e,t,NG(r))}}function TB(e){let t=Kb(e);if(!t||!$G(t)&&!PG(t))throw FB();try{new Ep().addRecipient(t)}catch{throw FB()}return t}async function RB(e){let t=Kb(e);if(!t||!xG(t)&&!TG(t))throw BB();try{await bm(t)}catch{throw BB()}return t}async function kB(e){Vb();let t=await RB(e),r=await bm(t);return TB(r)}async function _m(e,t){Vb();let r=TB(t),n=new Ep;n.addRecipient(r);let i=await n.encrypt(e??"");return yp.encode(i)}function UG(e){return Kb(e).startsWith(FG)}async function Dm(e,t){let r=e??"",n=typeof r=="string"?r:new TextDecoder().decode(r);if(!UG(n))return r;Vb();let i=await RB(t),o=new Sm;o.addIdentity(i);try{let s=yp.decode(n);return await o.decrypt(s,"text")}catch(s){throw new Error(`age \u89E3\u5BC6\u5931\u8D25: ${s?.message??s}`)}}function HG(e){return String(e??"").replace(IG,t=>`${t.startsWith("AGE-SECRET-KEY-PQ-1")?"AGE-SECRET-KEY-PQ-1":"AGE-SECRET-KEY-1"}...${t.slice(-6)}`)}function cc(e){return HG(String(e??"").replace(/([?#&]age-secret-key=)[^&#\s]+/gi,"$1***"))}var j1e=P(x());var Z0e=P(x());var Gb=class{constructor(){te.read(Gc)||te.write("{}",Gc);try{this.resourceCache=JSON.parse(te.read(Gc))}catch(t){te.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Gc} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},te.write("{}",Gc)}this._cleanup()}_cleanup(t,r){let n=zb(r)??0,i=!1,o=Date.now();Object.entries(this.resourceCache).forEach(s=>{let[a,u]=s;(!u.time||u.time0?t:null}function MG(){let t=te.read(ar)?.scriptCacheTtl;return t&&(t=Number(t),isFinite(t)&&t>0)?t*1e3:1728e5}var Wb=new Gb;var Q0e=P(x());function Fm(e,t){return[...Array(e).keys()].map(()=>t)}var r1e=P(x());var Yb={"\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 oh(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(Yb))if(Yb[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 OB(e){return Yb[oh(e)]?.[0]}function bp(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var Bm=class{constructor({country,asn}={}){if(te.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 y1e=P(x());var uh=P(GB()),If=P(og());var WB=53,XG=853,Sp=2;function iA({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:Nr(r)?24:56,scopePrefixLength:0}]}),uh.default.encode({type:"query",id:0,flags:uh.default.RECURSION_DESIRED,questions:[{type:t,name:e}],additionals:n})}function YB(e){return e||8e3}function ZG(e){return e?.replace(/^\[(.*)\]$/,"$1")}function JG(e){return Nr(e)||mr(e)}function QG(e,t=WB){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 eW(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 tW(e,t){try{let r=t?e:`udp://${mr(e)?`[${e}]`:e}`,n=new URL(r);eW(n,e);let i=ZG(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:QG(n.port,t==="tls"?XG:WB)}}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 rW(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 tW(t,n)}async function oA({url:e,domain:t,type:r="A",timeout:n,edns:i,skipCertVerify:o}){let s=iA({domain:t,type:r,edns:i}),u=If.Buffer.from(s).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),f=await te.http.get({url:`${e}?dns=${encodeURIComponent(u)}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n,insecure:o===!0});return uh.default.decode(If.Buffer.from(te.env.isQX?f.bodyBytes:f.body))}async function nW({server,domain,type="A",timeout,edns}){let dgram=eval("require('dgram')"),buf=iA({domain,type,edns});return new Promise((e,t)=>{let r=!1,n=dgram.createSocket(mr(server.host)?"udp6":"udp4"),i=setTimeout(()=>{s(new Error("DNS UDP query timeout"))},YB(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,uh.default.decode(a))}catch(u){s(u)}}),n.send(buf,server.port,server.host,a=>{a&&s(a)})})}async function sW({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=iA({domain,type,edns}),length=If.Buffer.alloc(Sp);length.writeUInt16BE(payload.length,0);let request=If.Buffer.concat([length,payload]);return new Promise((e,t)=>{let r=!1,n=If.Buffer.alloc(0),i,o=server.protocol==="tls"?transport.connect({host:server.host,port:server.port,servername:JG(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,f){r||(r=!0,s(),u?t(u):e(f))}o.setTimeout(YB(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=If.Buffer.concat([n,u]),i==null&&n.length>=Sp&&(i=n.readUInt16BE(0)),i!=null&&n.length>=i+Sp){let f=n.slice(Sp,i+Sp);a(null,uh.default.decode(f))}}catch(f){a(f)}})})}async function Pm({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&&!te.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=rW(e);if(u.protocol==="doh")return oA({url:u.url,domain:t,type:r,timeout:n,edns:i,skipCertVerify:o});if(!te.env.isNode)throw new Error("DoT \u548C TCP/UDP DNS \u4EC5\u652F\u6301 Node.js \u73AF\u5883");return["tcp","tls"].includes(u.protocol)?sW({server:u,domain:t,type:r,timeout:n,edns:i,skipCertVerify:o}):nW({server:u,domain:t,type:r,timeout:n,edns:i})}var fh=P(xm());var A1e=P(x()),aA="mihomoConfig",iW="mihomoProfile",oW=[aA,iW];function $f(e){let t=typeof e=="string"?e:e?.type;return oW.includes(t)}function XB(e){return!e||!$f(e)||e.type===aA?e:{...e,type:aA}}var D1e=P(x());var{isNode:ZB,isQX:aW,isLoon:uW,isSurge:cW,isStash:fW,isShadowRocket:lW,isLanceX:hW,isEgern:dW,isGUIforCores:pW}=bo(),Xo="Node";ZB?Xo="Node":aW?Xo="QX":uW?Xo="Loon":fW?Xo="Stash":lW?Xo="Shadowrocket":dW?Xo="Egern":cW?Xo="Surge":hW?Xo="LanceX":pW&&(Xo="GUI.for.Cores");var Pf={},gW={};try{if(typeof $environment<"u"&&(Pf.env=$environment),typeof $loon<"u"&&(Pf.loon=$loon),typeof $script<"u"&&(Pf.script=$script),typeof $Plugin<"u"&&(Pf.plugin=$Plugin),ZB){Pf.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)&&(Pf.node.env[e]=env[e])}}catch(e){}var Tm={backend:Xo,version:J0,feature:gW,meta:Pf};var lA="Response Transformer";function hA(e){return e===lA}function _p(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function tI(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=_p(n.slice(0,-1));e[i]=r[n]}else{let i=_p(n);e[i]||Object.assign(e,{[i]:{}}),tI(e[i],r[i])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let i=_p(n.slice(1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...r[n],...e[i]]}else if(n.endsWith("+")){let i=_p(n.slice(0,-1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...e[i],...r[n]]}else{let i=_p(n);Object.assign(e,{[i]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function mW({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>Rm(e,r))}}function Rm(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=>Rm(r,t));case"OR":return e.child.some(r=>Rm(r,t));case"NOT":return!Rm(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function vW(e){return{name:"Quick Setting Operator",func:i=>{if(t(e.useless)){let s=uI().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 wW({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=bp(n.name);else{let i=oh(n.name);n.name=bp(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 yW(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 f=o.map(h=>fh.default.get(u,h,"-")).join("_");return a[f]?!1:(a[f]=!0,!0)})}else if(t==="rename"){let a=r.split(" "),u={},f=0;s.forEach(m=>{let p=o.map(d=>fh.default.get(m,d,"-")).join("_");typeof u[p]>"u"?u[p]=1:u[p]++,f=Math.max(u[p].toString().length,f)});let h={};return s.map(m=>{let p=o.map(d=>fh.default.get(m,d,"-")).join("_");if(u[p]>1){typeof h[p]>"u"&&(h[p]=1);let d="",v=h[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 zW(t);default:throw new Error("Unknown sort option: "+e)}}}}function bW(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=>pA(i)),n.sort((i,o)=>{let s=JB(r,i.name),a=JB(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(pA(n,"g"),i).trim();return r})}}function AW(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:rI(t).func}}function SW(e,t,r,n,i,o){return o.source=n,o.env=Tm,{name:"Script Operator",func:async s=>{let a=s;if($f(a?.$file))try{let u=Zs.safeLoad(e),f;if(a?.$content)try{f=Zs.safeLoad(a?.$content)}catch(h){te.error(h.message??h)}if(typeof u!="object")throw new Error("patch is not an object");return a.$content=tr.yaml.safeDump(tI(f||{},u)),a}catch{}return await async function(){a=lh("operator",e,r,i)(s,t,o)}(),a},nodeFunc:async s=>{let a=s;return await async function(){a=lh("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 nI="Add Proxies From Subscription Operator";function CW(e){if(!e)return{};let t=Zs.safeLoad(e);return dt(t)?t:{}}function _W(e){return Array.isArray(e?.proxies)?e.proxies:[]}function DW({sourceType:e="subscription",sourceName:t,includeUnsupportedProxy:r,position:n="replace"}={}){let i=async o=>{if(!$f(o?.$file))return o;let s=CW(o.$content),a=_W(s),u=await ti({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=tr.yaml.safeDump(s),o};return{name:nI,func:i,nodeFunc:i}}function FW(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,f=o&255;if(t=`${s}.${a}.${u}.${f}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!Nr(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){te.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var BW=10,IW=2,QB=20;function $W(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return BW;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 sI(e){if(typeof e>"u"||e===null||typeof e=="string"&&e.trim()==="")return IW;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 PW(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 xW(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 dA(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 TW(e){return dA(e).join(` `)}async function RW(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,f=[],h=Math.min(t,e.length);function m(){!u&&a===e.length&&i(new Error(f.length>0?f.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,f.push(`${d}: ${v}`),p(),m()})}m()}}p()})}function fA(e,t,r,n,i){switch(e){case"Custom":return Yr(`CUSTOM:${i?"INSECURE:":""}${n}:${t}:${r}`);case"Google":return Yr(`GOOGLE:${t}:${r}`);case"IP-API":return Yr(`IP-API:${t}`);case"Cloudflare":return Yr(`CLOUDFLARE:${t}:${r}`);case"Ali":return Yr(`ALI:${t}:${r}`);case"Tencent":return Yr(`TENCENT:${t}:${r}`)}}function OW(e,t,r,n,i,o){if(n==="disabled")return null;let s=fA(e,t,r,i,o),a=s?Xr.get(s):null;return e==="Custom"?oI(a):a}function uA(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 NW(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 iI(e,t){return e&&typeof e=="object"&&Object.defineProperty(e,"_resolverUrl",{value:t,enumerable:!1,configurable:!0}),e}function LW(e,t){return{result:e,resolverUrl:t}}function oI(e){return e&&typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.result)?iI(e.result,e.resolverUrl):e}function eI(e){return e&&typeof e=="object"?e._resolverUrl:null}var km={Custom:async function(e,t,r,n,i,o,s,a,u){let f=dA(o),h=f.join(` `),m=sI(a),p=Yr(`CUSTOM:${s?"INSECURE:":""}${h}:${e}:${t}`),d=oI(Xr.get(p));if(!r&&d)return d;let v=t==="IPv6"?"AAAA":"A",g=async E=>{let C=await Pm({url:E,domain:e,type:v,timeout:n,edns:i,skipCertVerify:s}),{answers:D}=C;if(!Array.isArray(D)||D.length===0)throw new Error("No answers");let B=D.filter(H=>H?.type===v).map(H=>H?.data).filter(H=>H);if(B.length===0)throw new Error("No answers");return B},{result:y,resolverUrl:w}=f.length===1?{result:await g(f[0]),resolverUrl:f[0]}:await kW(f,m,g);return Xr.set(p,LW(y,w),u),iI(y,w)},Google:async function(e,t,r,n,i,o,s,a,u){let f=Yr(`GOOGLE:${e}:${t}`),h=Xr.get(f);if(!r&&h)return h;let m=t==="IPv6"?"AAAA":"A",p=await Pm({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 Xr.set(f,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 f=Yr(`IP-API:${e}`),h=Xr.get(f);if(!r&&h)return h;let m=await te.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 Xr.set(f,d,u),d},Cloudflare:async function(e,t,r,n,i,o,s,a,u){let f=Yr(`CLOUDFLARE:${e}:${t}`),h=Xr.get(f);if(!r&&h)return h;let m=t==="IPv6"?"AAAA":"A",p=await Pm({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 Xr.set(f,v,u),v},Ali:async function(e,t,r,n,i,o,s,a,u){let f=Yr(`ALI:${e}:${t}`),h=Xr.get(f);if(!r&&h)return h;let m=await te.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${i}/${Nr(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 Xr.set(f,d,u),d},Tencent:async function(e,t,r,n,i,o,s,a,u){let f=Yr(`TENCENT:${e}:${t}`),h=Xr.get(f);if(!r&&h)return h;let p=(await te.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 Xr.set(f,d,u),d}};function aI({provider:e,type:t,filter:r,cache:n,url:i,tlsSkipCertVerify:o,timeout:s,cacheTtl:a,edns:u,concurrency:f,dnsConcurrency:h}){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}=te.read(ar)||{},p=PW(s,m),d=xW(a),v=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",g=km[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(!xf(y))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");let w=$W(f),E=e==="Custom"?TW(i):i,C=e==="Custom"?dA(E).length:1,D=e==="Custom"?sI(h):1,B=w*Math.min(D,C),H=e==="Custom"&&(o===!0||o==="enabled");return B>QB&&te.warn(`\u57DF\u540D\u89E3\u6790\u603B\u5E76\u53D1\u6570\u4E0A\u9650 ${B} \u8D85\u8FC7\u5EFA\u8BAE\u503C ${QB}, \u53EF\u80FD\u5BFC\u81F4\u4EE3\u7406 App TCP \u8FDE\u63A5\u6570\u6FC0\u589E`),te.info(`Domain Resolver: [${t}] ${e} ${y||""} ${NW(e,E)}${H?" tlsSkipCertVerify=enabled":""} concurrency=${w}${e==="Custom"?` dnsConcurrency=${D}`:""}`),{name:"Resolve Domain Operator",func:async V=>{V.forEach((R,O)=>{!R["_no-resolve"]&&R["no-resolve"]&&(V[O]["_no-resolve"]=R["no-resolve"])});let S={},I=[...new Map(V.filter(R=>!xf(R.server)&&!R["_no-resolve"]).map(R=>{let O=fA(e,R.server,v,E,H);return[O,{id:O,domain:R.server}]})).values()],U=[];return I.forEach(({id:R,domain:O})=>{let q=OW(e,O,v,n,E,H);if(q){S[R]=q;let N=e==="Custom"&&eI(q)||E;te.info(`Using cached resolved domain: ${O}${uA(e,N)} \u279F ${q}`)}else U.push({id:R,domain:O})}),await RW(U,w,async({id:R,domain:O})=>{try{let q=await g(O,v,n==="disabled",p,y,E,H,D,d);S[R]=q;let N=e==="Custom"&&eI(q)||E;te.info(`Successfully resolved domain: ${O}${uA(e,N)} \u279F ${q}`)}catch(q){te.error(`Failed to resolve domain: ${O}${uA(e,E)} with resolver [${e}]: ${q}`)}}),V.forEach(R=>{if(!R["_no-resolve"]){let O=fA(e,R.server,v,E,H);if(O&&S[O]){R._resolved_ips=S[O];let q=Array.isArray(S[O])?S[O][Math.floor(Math.random()*S[O].length)]:S[O];if(v==="IPv6"&&mr(q)){try{q=new p1.Address6(q).correctForm()}catch(N){te.error(`Failed to parse IPv6 address: ${q}: ${N}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(q)){R._IP4P=q;let{server:N,port:_}=FW(q);N&&_?(R._domain=R.server,R.server=N,R.port=_,R.resolved=!0,R._IPv4=R.server,xf(R._IP)||(R._IP=R.server)):R.resolved||(R.resolved=!1)}else R._domain=R.server,R.server=q,R.resolved=!0,R[`_${v}`]=R.server,xf(R._IP)||(R._IP=R.server)}else R._domain=R.server,R.server=q,R.resolved=!0,R[`_${v}`]=R.server,xf(R._IP)||(R._IP=R.server)}else R.resolved||(R.resolved=!1)}}),V.filter(R=>r==="removeFailed"?xf(R.server)||R["_no-resolve"]||R.resolved:r==="IPOnly"?xf(R.server):r==="IPv4Only"?Nr(R.server):r==="IPv6Only"?mr(R.server):!0)}}}function xf(e){return Nr(e)||mr(e)}aI.resolver=km;function cA(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function uI(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!cA(t.cipher))return!1;if(t.password&&!cA(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&&!cA(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function UW(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=oh(o.name),a=t.some(u=>n[u]===s);return r?a:!a})}}function HW({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let i=e.some(o=>pA(o).test(n.name));return t?i:!i})}}function pA(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function qW(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 MW(e,t,r,n,i,o){return o.source=n,o.env=Tm,{name:"Script Filter",func:async s=>{let a=Fm(s.length,!0);return await async function(){a=lh("filter",e,r,i)(s,t,o)}(),a},nodeFunc:async s=>{let a=Fm(s.length,!0);return await async function(){a=lh("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 jW(e,t,r,n,i,o){return o.source=n,o.env=Tm,{name:lA,func:async s=>{let a=s;return await async function(){a=lh("transformFunction",e,r,i)(s,o)}(),a},shortcutFunc:async s=>{let a=s;return await async function(){a=lh("transformFunction",`async function transformFunction(res = {}, context) { let $res = res ${e} return $res }`,r,i)(s,o)}(),a}}}var Dp={"Useless Filter":uI,"Region Filter":UW,"Regex Filter":HW,"Type Filter":qW,"Script Filter":MW,"Conditional Filter":mW,"Quick Setting Operator":vW,"Flag Operator":wW,"Sort Operator":EW,"Regex Sort Operator":bW,"Regex Rename Operator":rI,"Regex Delete Operator":AW,"Script Operator":SW,[nI]:DW,[lA]:jW,"Handle Duplicate Operator":yW,"Resolve Domain Operator":aI};async function cI(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")||(te.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){te.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 KW(e,t){let r=Fm(t.length,!0);try{r=await e.func(t)}catch(n){let i="",o=`${n.message??n}`;o.includes("$server is not defined")?i="":(te.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){te.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 VW(e,t){let r=GW(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="":(te.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){te.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 fI(e,t){if(e.name.indexOf("Filter")!==-1)return KW(e,t);if(e.name.indexOf("Operator")!==-1)return VW(e,t)}function zW(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 GW(e){return JSON.parse(JSON.stringify(e))}function lh(name,script,$arguments,$options){let flowUtils={getFlowField:Xc,getFlowHeaders:v1,parseFlowHeaders:pl,flowTransfer:fd,validCheck:w1,getRmainingDays:W8,normalizeFlowHeader:Y8};return te.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,te,fh.default,$persistentStore,$httpClient,$notification,tr,tr.yaml,tr.Buffer,tr.Base64.decode,tr.Base64.encode,km,Wb,flowUtils,ti,eval('typeof require !== "undefined"')?Ov:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","yaml","Buffer","b64d","b64e","DOMAIN_RESOLVERS","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,te,fh.default,tr,tr.yaml,tr.Buffer,tr.Base64.decode,tr.Base64.encode,km,Wb,flowUtils,ti,eval('typeof require !== "undefined"')?Ov:void 0)}var Wme=P(x());var nge=P(x());var Y1e=P(x()),dI=P(xm());var lt=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=dI.default.get(e,t);return typeof r<"u"&&r!==null}function hh(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 Fp(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 pI(e){return!!Fp(e)}function dh(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 lI(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 Om(e){if(["vmess","vless","trojan","anytls"].includes(e.type)&&lI(e,"sni")&&["vmess","vless"].includes(e.type)&&(e.tls=!0),e.type==="vless"&&e.network==="xhttp"){let t=e["xhttp-opts"]?.["download-settings"];lI(t,"servername")&&(t.tls=!0)}}function gA(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 gI(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?Nr(o):mr(o))?{address:o,cidr:gA(i,s?32:128)}:null}function hI(e,t){let{addressKey:r,cidrKey:n,family:i,defaultCIDR:o}=t,s=gI(e[r],i);if(!s){(e[r]==null||`${e[r]}`.trim().length===0)&&delete e[n];return}e[r]=s.address;let a=gA(e[n],o);e[n]=a??s.cidr??o}function mA(e={}){return hI(e,{addressKey:"ip",cidrKey:"ip-cidr",family:"ipv4",defaultCIDR:32}),hI(e,{addressKey:"ipv6",cidrKey:"ipv6-cidr",family:"ipv6",defaultCIDR:128}),e}function Ls(e={},t="ipv4"){let r=t==="ipv6"?{addressKey:"ipv6",cidrKey:"ipv6-cidr",defaultCIDR:128}:{addressKey:"ip",cidrKey:"ip-cidr",defaultCIDR:32},n=gI(e[r.addressKey],t);if(!n)return;let i=gA(e[r.cidrKey],r.defaultCIDR);return`${n.address}/${i??n.cidr??r.defaultCIDR}`}function Zo(e,t,r={}){return t==="internal"?e:r.prettyYaml||r["pretty-yaml"]?$d(Zs.safeDump({proxies:e},{lineWidth:-1})):`proxies: `+e.map(n=>" - "+JSON.stringify(n)+` `).join("")}var Z1e=P(x()),Nm="auto",WW=[Nm,"none","zero","aes-128-gcm","chacha20-poly1305"],YW=[Nm,"aes-128-gcm","chacha20-poly1305","none"],XW=["none","chacha20-poly1305"],ZW={"chacha20-ietf-poly1305":"chacha20-poly1305"};function mI(e){return e==null?"":`${e}`.trim().toLowerCase()}function vA(e){return ZW[e]||e}function $n(e,t=WW,{acceptAliases:r=!0,fallback:n=Nm}={}){let i=mI(e);if(!i)return n;let o=t.map(mI);if(o.includes(i))return vA(i);let s=vA(i),a=o.map(vA);return r&&a.includes(s)?s:n}function Bp(e){return $n(e,YW)}function vI(e){return $n(e,XW,{fallback:"chacha20-poly1305"})}function wI(e){let t=Bp(e);return t==="chacha20-poly1305"?"chacha20-ietf-poly1305":t}function yI(e){let t=$n(e,["aes-128-gcm","chacha20-poly1305"]);if(t!==Nm)return t==="chacha20-poly1305"?"chacha20-ietf-poly1305":t}var Lm="Surge",ph=class extends Error{constructor(t){super(t),this.name="SurgeUnsupportedProxyError"}};function fu(e){return new ph(e)}var ys={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function Um(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 gh(e){return`"${String(Um(e))}"`}function Hm(e){return e!=null&&`${e}`.trim().length>0}function EI(e){return(Array.isArray(e)?e:Um(`${e||""}`).split(",")).filter(r=>r!=null).map(r=>String(Um(r)).trim()).filter(r=>r!=="").join(",")}function JW(e,t){let r=EI(t.alpn);r&&e.append(`,alpn="${r}"`)}function QW(e){return EI(e?.["plugin-opts"]?.alpn??e?.alpn)}function ro(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 fu(`shadow-tls version ${o} is not supported`);e.append(`,shadow-tls-version=${o}`)}let s=QW(t);s&&e.append(`,alpn="${s}"`),r&&e.appendIfPresent(`,udp-port=${t["udp-port"]}`,"udp-port")}function lu(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=${gh(t["name-cert-verify"])}`,"name-cert-verify"),t.plugin!=="shadow-tls"&&JW(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=${gh(n)}`)}function eY(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=${gh(r)}`)}function bI(e){if(!pe(e,"max-streams"))return;let t=Number(Um(e["max-streams"]));!Number.isInteger(t)||t<=3||te.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 tY(e){return pe(e,"obfs-opts.mode")||pe(e,"obfs-opts.host")||pe(e,"obfs-opts.path")}function rY(e){return Number(e.version)===6&&tY(e)}function mh(){return{produce:(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw fu(`Platform ${Lm} 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 nY(t);case"trojan":return sY(t);case"vmess":return uY(t,n["include-unsupported-proxy"]);case"http":return fY(t);case"h2-connect":return aY(t);case"direct":return lY(t);case"socks5":return hY(t);case"snell":return pY(t);case"tuic":return gY(t);case"wireguard-surge":return vY(t);case"hysteria2":return wY(t);case"ssh":return cY(t);case"trusttunnel":return oY(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return mY(t);if(t.type==="anytls"){if(t.network&&(!["tcp"].includes(t.network)||["tcp"].includes(t.network)&&t["reality-opts"]))throw fu(`Platform ${Lm} does not support proxy type ${t.type} with network or REALITY`);return iY(t)}throw fu(`Platform ${Lm} does not support proxy type: ${t.type}`)}}}function nY(e){let t=new lt(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 fu(`cipher ${e.cipher} is not supported`);t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ys[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 fu(`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"),ro(t,e,!0),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function sY(e){let t=new lt(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ys[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"),SI(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),lu(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"),ro(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function iY(e){let t=new lt(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ys[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"),lu(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 oY(e){let t=new lt(e);t.append(`${e.name}=trust-tunnel,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),wA(t,e),bI(e),t.appendIfPresent(`,max-streams=${e["max-streams"]}`,"max-streams");let r=ys[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"),lu(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 aY(e){let t=new lt(e);t.append(`${e.name}=h2-connect,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),wA(t,e),bI(e),t.appendIfPresent(`,max-streams=${e["max-streams"]}`,"max-streams");let r=ys[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"),lu(t,e),e.tfo&&te.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"),ro(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function uY(e,t){let r=new lt(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=yI(e.cipher);n&&r.append(`,encrypt-method=${n}`);let i=ys[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"),SI(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"),lu(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"),ro(r,e),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.toString()}function cY(e){let t=new lt(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,username="${e.username}"`,"username"),t.appendIfPresent(`,password="${e.password}"`,"password"),eY(t,e),t.appendIfPresent(`,idle-timeout=${e["idle-timeout"]}`,"idle-timeout"),t.appendIfPresent(`,server-fingerprint="${e["server-fingerprint"]}"`,"server-fingerprint");let r=ys[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 fY(e){let t=new lt(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"),wA(t,e);let n=ys[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"),lu(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"),ro(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function lY(e){let t=new lt(e),r="direct";t.append(`${e.name}=${r}`);let n=ys[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 hY(e){let t=new lt(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=ys[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"),lu(t,e,!!e.tls),e.tfo&&te.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"),ro(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function wA(e,t){let r=dY(t.headers);et(r)&&e.append(`,headers=${gh(r)}`)}function dY(e){return AI(e,";")}function AI(e,t){return!e||typeof e!="object"?"":Object.entries(e).filter(([r,n])=>et(r)&&n!=null).map(([r,n])=>`${r}:${gh(n)}`).join(t)}function pY(e){if(rY(e))return te.error(`Platform ${Lm} does not support Snell version ${e.version} with obfs`),"";let t=new lt(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=ys[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"),ro(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 gY(e){let t=new lt(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"),Hm(e.ports)&&t.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),Hm(e["hop-interval"])&&t.append(`,port-hopping-interval=${e["hop-interval"]}`);let n=ys[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"),lu(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"),ro(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 mY(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 lt(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=Lt(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=ys[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"),ro(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 vY(e){let t=new lt(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=ys[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"),ro(t,e),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function wY(e){let t={salamander:"salamander-password",gecko:"gecko-password"}[e.obfs];if(e["obfs-password"]&&!t)throw fu("only salamander and gecko obfs are supported");let r=new lt(e);r.append(`${e.name}=hysteria2,${e.server},${e.port}`),r.appendIfPresent(`,password="${e.password}"`,"password"),Hm(e.ports)&&r.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),Hm(e["hop-interval"])&&r.append(`,port-hopping-interval=${e["hop-interval"]}`),e["obfs-password"]&&t&&r.append(`,${t}="${e["obfs-password"]}"`);let n=ys[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"),lu(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"),ro(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 SI(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=AI(n,"|");et(i)&&e.append(`,ws-headers=${gh(i)}`)}}else if(r&&["http"].includes(t.network))te.info(`Include Unsupported Proxy: network ${t.network} -> tcp`);else{if(["tcp"].includes(t.network)&&t["reality-opts"])throw fu("reality is unsupported");if(!["tcp"].includes(t.network))throw fu(`network ${t.network} is unsupported`)}}var Cge=P(x());var mge=P(x());var ige=P(x());function yA(e){try{return decodeURIComponent(`${e}`.replace(/\+/g,"%20"))}catch{return e}}function CI(e){let t=e.indexOf("=");return t===-1?{key:yA(e),value:""}:{key:yA(e.slice(0,t)),value:yA(e.slice(t+1))}}function hu(e){if(!/^\d+$/.test(`${e}`))return null;let t=parseInt(`${e}`,10);return Number.isSafeInteger(t)?t:null}function Us(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 f=CI(u);if(f.key===t){a===""&&f.value!==""&&(a=f.value);continue}s.push(u)}return{path:s.length>0?`${i}?${s.join("&")}`:i,value:a}}function Ip(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=CI(o);if(s.key===t&&s.value!=="")return s.value}return""}function EA(e,t){let r=Ip(e,t),n=hu(r);return n==null?{value:"",parsed:null}:{value:r,parsed:n}}function yY(e,t,r){let n=e.includes("?")?e.endsWith("?")||e.endsWith("&")?"":"&":"?";return`${e}${n}${encodeURIComponent(t)}=${encodeURIComponent(`${r}`)}`}function bA(e,t,r){let n=e==null||e===""?"/":`${e}`,{path:i}=Us(n,t);return yY(i,t,r)}function lc(e){let t=e?.path;if(!e)return;let{value:r,parsed:n}=EA(t,"ed");if(e["v2ray-http-upgrade"]){r!==""&&(e.path=Us(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=Us(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 hc(e){e&&delete e["_v2ray-http-upgrade-ed"]}var uge=P(x());var Tf="_dns",AA="_force-query",SA="_sockopt",_I="https://dns.alidns.com/dns-query";function DI(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 CA(e){return DI(e)!=null}function qm(e){return["none","half","full"].includes(e)}function EY(e){return typeof e=="boolean"?e:typeof e=="number"&&Number.isInteger(e)&&e!==0}function Mm({echConfigList:e,echForceQuery:t,echSockopt:r}={}){let n=DI(e);if(!n)return;let i={enable:!0};return n.type==="config"?i.config=n.config:(i[Tf]=n.dns,n.queryServerName&&(i["query-server-name"]=n.queryServerName)),qm(t)&&(i[AA]=t),dt(r)&&(i[SA]=r),i}function _A(e,t,{dnsFieldPath:r="ech-opts._dns",warnDefaultDns:n}={}){let i={};if(dt(e)){if(!EY(e.enable))return i;let o=e["query-server-name"];return et(e.config)?i.echConfigList=e.config:et(e[Tf])?i.echConfigList=et(o)?`${o}+${e[Tf]}`:e[Tf]:et(o)&&(i.echConfigList=`${o}+${_I}`,n?.({defaultDns:_I,dnsFieldPath:r,queryServerName:o})),i.echConfigList&&qm(e[AA])&&(i.echForceQuery=e[AA]),i.echConfigList&&dt(e[SA])&&(i.echSockopt=e[SA]),i}return et(t)&&(i.echConfigList=t),i}function DA(e,t,r){return _A(e,t,r).echConfigList}var bY={dual:"dual","v4-only":"ipv4","v6-only":"ipv6","prefer-v4":"ipv4-prefer","prefer-v6":"ipv6-prefer"};function FI(e,t,r){if(!dt(t)||!et(t[Tf]))return;let n=et(t["query-server-name"])?t["query-server-name"]:"\u8FD9\u91CC\u662F query-server-name";te.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[Tf]}"].`)}function AY(e,t){t!=="internal"&&(FI(e,e["ech-opts"],"ech-opts"),FI(e,e["xhttp-opts"]?.["download-settings"]?.["ech-opts"],"xhttp-opts.download-settings.ech-opts"))}function ri(){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 te.error(`mihomo does not support HTTP/2 CONNECT proxy type. Proxy ${s.name} has been filtered.`),!1;if(SY(s)&&s.type==="trusttunnel")return te.error(`mihomo does not support headers for TrustTunnel proxy ${s.name}. Proxy has been filtered.`),!1;if(dh(s,["websocket"])){if(s.type==="snell"&&!FA(s.version,[1,2,3,4,5]))return!1;if(BI(s)&&(!["ss","snell","vmess","vless","trojan","anytls"].includes(s.type)||!FA(II(s),["ss","snell"].includes(s.type)?[1,2,3]:[0,1,2,3])))return!1;if(s.type==="vless"&&s.network==="xhttp"&&BI(s["xhttp-opts"]?.["download-settings"])&&!FA(II(s["xhttp-opts"]["download-settings"]),[0,1,2,3]))return!1;if(CY(s))return te.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(AY(s,n),Om(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=$n(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=Ls(s,"ipv4"),s.ipv6=Ls(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=pI(s["plugin-opts"].mux)),s.type==="snell"){let a=BA(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="/"),lc(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];hc(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"]=bY[s["ip-version"]]||s["ip-version"]),s});return Zo(o,n,i)}}}function SY(e){return e?.headers&&typeof e.headers=="object"&&Object.keys(e.headers).length>0}function FA(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 BI(e){return!!BA(e)}function CY(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 II(e){return BA(e)?.version}function BA(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 PI="SurgeMac",xI=mh();function $p(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return TI(t);default:{if(n.mihomoExternal||t._mihomoExternal)return $I(t,r,n)||"";try{return xI.produce(t,r,n)}catch(i){if(n.useMihomoExternal&&i instanceof ph){let o=$I(t,r,n)||"";if(!o)throw i;return te.log(`${t.name} is not supported on ${PI}, try to use mihomo(SurgeMac - External Proxy Program) instead`),o}throw i instanceof ph?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 TI(e){let t=new lt(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 $I(e,t,r){let n=ri().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 f={name:e.name,type:"socks5",server:"127.0.0.1",port:i,udp:!0};u=xI.produce(f,"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 h=`${i}`;r._merged.config.listeners.push({name:`socks5-${i}`,type:"socks",port:i,listen:"127.0.0.1",udp:!0,proxy:h}),r._merged.config["proxy-groups"][0].proxies.push(h),r._merged.config.proxies.push({...n,name:h}),r._merged.config={...r._merged.config,...r?.config||e._config||{}}}else{let f={name:e.name,type:"external",udp:!0,exec:r?.exec||e._exec||"/usr/local/bin/mihomo","local-port":i,args:["-config",Bt.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:[]};_Y(e.server)?f.addresses.push(e.server):te.warn(`Platform ${PI}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),u=TI(f)}return r.localPort=i-1,u}}function _Y(e){return Nr(e)||mr(e)}var $ge=P(x());function IA(){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"]?(te.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=Bp(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="/"),lc(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];hc(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 Zo(o,n,i)}}}var Nge=P(x());function jm(){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(dh(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=Bp(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="/"),lc(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];hc(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 Zo(o,n,i)}}}var jge=P(x());var Pp="Loon",Jo={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function $A(){return{produce:(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${Pp} does not support network ${t.network} with http upgrade`);switch(t.type){case"ss":return IY(t);case"ssr":return $Y(t);case"trojan":return PY(t);case"vmess":return TY(t,n["include-unsupported-proxy"]);case"vless":return RY(t,n["include-unsupported-proxy"]);case"http":return kY(t);case"socks5":return OY(t);case"wireguard":return NY(t);case"hysteria2":return LY(t)}if(t.type==="anytls"){if(t.network&&!["tcp"].includes(t.network))throw new Error(`Platform ${Pp} does not support proxy type ${t.type} with network ${t.network}`);return xY(t)}throw new Error(`Platform ${Pp} does not support proxy type: ${t.type}`)}}}function dc(e,t){let r=BY(t);r&&e.append(`,tls-profile=${r}`)}function Rf(e,t){let r=FY(t);r&&e.append(`,alpn="${r}"`)}function DY(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 RI(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}`)}dc(e,t);let o=DY(t);o&&e.append(`,alpn="${o}"`),e.appendIfPresent(`,udp-port=${t["udp-port"]}`,"udp-port")}function Km(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 FY(e){return(Array.isArray(e.alpn)?e.alpn:`${e.alpn||""}`.split(",")).map(r=>`${r}`.trim()).filter(r=>r!=="").join(",")}function BY(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 IY(e){let t=new lt(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`)}RI(t,e),e["udp-over-tcp"]&&(e["udp-over-tcp-version"]===2?e.plugin==="obfs"?te.error(`Platform ${Pp} shadowsocks udp-over-tcp does not support obfs`):t.append(",udp-over-tcp=true"):te.error(`Platform ${Pp} 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=Jo[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function $Y(e){let t=new lt(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"),RI(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=Jo[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function PY(e){let t=!!e["reality-opts"],r=new lt(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"),dc(r,e),Rf(r,e),t?Km(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=Jo[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function xY(e){let t=!!e["reality-opts"],r=new lt(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"),dc(r,e),Rf(r,e),t?Km(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=Jo[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function TY(e){let t=!!e["reality-opts"],r=wI(e.cipher),n=new lt(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)&&(dc(n,e),Rf(n,e)),t?Km(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=Jo[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function RY(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 lt(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)&&(dc(n,e),Rf(n,e)),t&&n.appendIfPresent(`,flow=${e.flow}`,"flow"),r?Km(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=Jo[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function kY(e){let t=new lt(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&&(dc(t,e),Rf(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=Jo[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function OY(e){let t=new lt(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&&(dc(t,e),Rf(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=Jo[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function NY(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 lt(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=>mr(a));let s=e.dns.find(a=>Nr(a));s||(s=e.dns.find(a=>!Nr(a)&&!mr(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=Jo[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 LY(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new lt(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"),dc(t,e),Rf(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=Jo[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}var tme=P(x());var Vge=P(x());function PA(e,{allowZeroLowerBound:t=!0,allowZeroUpperBound:r=!0}={}){if(typeof e!="string"&&typeof e!="number")return;let n=h=>{let m=h.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 h=n(o[0]),m=Math.max(s,a);return h>=m?{lowerBound:h,upperBound:h}:void 0}if(o.length!==2)return;let u=n(o[0]),f=n(o[1]);if(!(u==null||f==null))return u>=s&&f>=a&&f>=u?{lowerBound:u,upperBound:f}:void 0}function UY(e){return PA(e,{allowZeroUpperBound:!1})}function kI(e){return PA(e,{allowZeroLowerBound:!1,allowZeroUpperBound:!1})}function xp(e){let t=UY(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?n:`${r}-${n}`}function vh(e){let t=kI(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?`${n}`:`${r}-${n}`}function Tp(e){let t=kI(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?n:`${r}-${n}`}function pc(e){let t=PA(e);if(!t)return;let{lowerBound:r,upperBound:n}=t;return r===n?n:`${r}-${n}`}function gc(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 HY(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 qY(e,t){let r=zm(e?.["_v2ray-http-upgrade-ed"]);if(r!=="")return r;let n=zm(Us(t||"/","ed").value);return n!==""?n:2560}function Vm(e,t){return t?.["v2ray-http-upgrade-fast-open"]?bA(e||"/","ed",qY(t,e)):e}function xA(e,t){let r=t?.["max-early-data"],n=zm(r);if(n==="")return r!=null&&`${r}`!=""?e==null?e:Us(e,"ed").path:e;let i=t?.["early-data-header-name"];return i&&i!=="Sec-WebSocket-Protocol"?e==null?e:Us(e,"ed").path:bA(e||"/","ed",n)}function zm(e){return e==null||`${e}`==""||hu(e)==null?"":`${e}`}function MY(e){return gc(e)}function jY(e){return pc(e)}function NI({defaultDns:e,dnsFieldPath:t,echOptsPath:r,proxyName:n,queryServerName:i}){let o=n||"\u672A\u547D\u540D\u8282\u70B9";te.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 Gm(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 KY(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=pc(e[i]);s!=null&&(t[o]=typeof s=="number"?`${s}`:s)}let n=MY(e["h-keep-alive-period"]);return n!=null&&(t.hKeepAlivePeriod=n),Object.keys(t).length>0?t:void 0}function LI(e,t,{excludeHostHeader:r=!0,xmuxTarget:n="root"}={}){if(!dt(e)||!dt(t))return;let i=HY(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=Tp(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=jY(t["uplink-chunk-size"]);if(o!=null&&(e.uplinkChunkSize=o),t["sc-max-each-post-bytes"]!=null){let a=Tp(t["sc-max-each-post-bytes"]);a!=null&&(e.scMaxEachPostBytes=a)}if(t["sc-min-posts-interval-ms"]!=null){let a=xp(t["sc-min-posts-interval-ms"]);a!=null&&(e.scMinPostsIntervalMs=a)}let s=KY(t["reuse-settings"]);s&&(n==="extra"?e.extra={...dt(e.extra)?e.extra:{},xmux:s}:e.xmux=s)}function VY(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=gc(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 f=_A(e["ech-opts"],void 0,{dnsFieldPath:"xhttp-opts.download-settings.ech-opts._dns",warnDefaultDns:v=>NI({...v,echOptsPath:"xhttp-opts.download-settings.ech-opts",proxyName:r.name})});if(f.echConfigList&&(u.echConfigList=f.echConfigList),f.echForceQuery&&(u.echForceQuery=f.echForceQuery),f.echSockopt&&(u.echSockopt=mc(f.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 h={},m=e.path??t.path;m&&(h.path=m);let p=Gm("xhttp",e)??Gm("xhttp",t);p&&(h.host=p);let d=e.mode??t.mode;if(d&&(h.mode=d),LI(h,e,{excludeHostHeader:!0,xmuxTarget:"extra"}),Object.keys(h).length>0&&(o.xhttpSettings=h),!(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 zY(e){let t=e["xhttp-opts"]||{},r={};LI(r,t,{excludeHostHeader:!0,xmuxTarget:"root"});let n=VY(t["download-settings"],t,e);return n&&(r.downloadSettings=n),Object.keys(r).length>0?r:void 0}function mc(e){if(Array.isArray(e))return e.map(mc);if(dt(e)){let t={};for(let[r,n]of Object.entries(e))t[r]=mc(n);return t}return e}function GY(e,t){return e==null?mc(t):Array.isArray(e)||Array.isArray(t)?mc(e):dt(e)&&dt(t)?UI(e,t):mc(e)}function UI(e,t){let r=dt(e)?mc(e):{};if(!dt(t))return r;for(let[n,i]of Object.entries(t)){if(!Object.prototype.hasOwnProperty.call(r,n)){r[n]=mc(i);continue}r[n]=GY(r[n],i)}return r}function WY(e){if(typeof e._extra=="string")return e._extra;if(dt(e._extra))return JSON.stringify(e._extra)}function YY(e){let t=WY(e);if(t!=null)return t;if(e.network!=="xhttp")return e._extra||"";let r=zY(e),n=UI(r,e._extra_unsupported);return Object.keys(n).length>0?JSON.stringify(n):""}function OI(e){let t="none",r=e["reality-opts"],n="",i="",o="";if(r){t="reality";let K=e["reality-opts"]?.["public-key"];K&&(i=`&pbk=${encodeURIComponent(K)}`);let Z=e["reality-opts"]?.["short-id"];Z&&(n=`&sid=${encodeURIComponent(Z)}`);let G=e["reality-opts"]?.["_spider-x"];G&&(o=`&spx=${encodeURIComponent(G)}`)}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 f="";e["tls-fingerprint"]&&(f=`&pcs=${encodeURIComponent(e["tls-fingerprint"])}`);let h="",m=Array.isArray(e._vcn)?e._vcn.join(","):e["name-cert-verify"];(Array.isArray(e._vcn)||m)&&(h=`&vcn=${encodeURIComponent(m)}`);let p="",d=DA(e["ech-opts"],e._echConfigList,{dnsFieldPath:"ech-opts._dns",warnDefaultDns:K=>NI({...K,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=YY(e);E&&(w=`&extra=${encodeURIComponent(E)}`);let C="";["xhttp"].includes(e.network)&&e[`${e.network}-opts`]?.mode?C=`&mode=${encodeURIComponent(e[`${e.network}-opts`].mode)}`:e._mode&&(C=`&mode=${encodeURIComponent(e._mode)}`);let D="";e._pqv&&(D=`&pqv=${encodeURIComponent(e._pqv)}`);let B="";e.encryption&&(B=`&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 K=e[`${e.network}-opts`]?.["_grpc-authority"];K&&(V+=`&authority=${encodeURIComponent(K)}`)}let S=e[`${e.network}-opts`]||{},I=e.network==="ws"&&S?.["v2ray-http-upgrade"],U=S?.[`${e.network}-service-name`],R=S?.path,O=Gm(e.network,S),q=zm(e["ws-opts"]?.["max-early-data"]);Array.isArray(R)&&(R=R[0]),I&&S?.["v2ray-http-upgrade-fast-open"]?R=Vm(R,S):e.network==="ws"&&e["ws-opts"]?.["max-early-data"]!=null&&R&&(R=Us(R,"ed").path),R&&(V+=`&path=${encodeURIComponent(R)}`),O&&(V+=`&host=${encodeURIComponent(Array.isArray(O)?O[0]:O)}`),U&&(V+=`&serviceName=${encodeURIComponent(U)}`),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&&q!==""&&(V+=`&ed=${encodeURIComponent(q)}`);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 _="",k;switch(e["packet-encoding"]!=null?k=`${e["packet-encoding"]}`.trim().toLowerCase():e.xudp?k="xudp":e["packet-addr"]?k="packetaddr":e.udp===!0&&(k=""),k){case"":_="&packetEncoding=none";break;case"packetaddr":_="&packetEncoding=packet";break;case"xudp":_="&packetEncoding=xudp";break}return`vless://${e.uuid}@${e.server}:${e.port}?security=${encodeURIComponent(t)}${V}${_}${s}${a}${f}${h}${p}${u}${v}${g}${y}${n}${o}${i}${C}${w}${D}${B}#${encodeURIComponent(e.name)}`}function wh(){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&&mr(r.server)&&(r.server=`[${r.server}]`),r.type){case"socks5":n=`socks://${encodeURIComponent(Bt.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)}`:Bt.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=Fp(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 Me=r[`${r.network}-opts`]?.[`${r.network}-service-name`],yt=r[`${r.network}-opts`]?.["_grpc-authority"];Me&&(s+=`&serviceName=${encodeURIComponent(Me)}`),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=Vm(Ke,Se):r.network==="ws"&&(Ke=xA(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 f=r["reality-opts"],h="",m="",p="",d=r.tls?"&security=tls":"",v="",g="";if(f){d="&security=reality";let fe=r["reality-opts"]?.["public-key"];fe&&(m=`&pbk=${encodeURIComponent(fe)}`);let Se=r["reality-opts"]?.["short-id"];Se&&(h=`&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}${h}${m}${p}${v}${g}#${encodeURIComponent(r.name)}`,n+=o.replace(/^&/,"?");break;case"ssr":n=`${r.server}:${r.port}:${r.protocol}:${r.cipher}:${r.obfs}:${Bt.encode(r.password)}/`,n+=`?remarks=${Bt.encode(r.name)}${r["obfs-param"]?"&obfsparam="+Bt.encode(r["obfs-param"]):""}${r["protocol-param"]?"&protocolparam="+Bt.encode(r["protocol-param"]):""}`,n="ssr://"+Bt.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:$n(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=Gm(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=Vm(Re,fe):r.network==="ws"&&(Re=xA(Re,fe)),Re&&(n.path=Re),Ke&&(n.host=Array.isArray(Ke)?Ke[0]:Ke))}n="vmess://"+Bt.encode(JSON.stringify(n));break;case"vless":n=OI(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 Me=r[`${r.network}-opts`]?.[`${r.network}-service-name`],yt=r[`${r.network}-opts`]?.["_grpc-authority"];Me&&(E+=`&serviceName=${encodeURIComponent(Me)}`),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=Vm(Ke,Se):r.network==="ws"&&(Ke=xA(Ke,Se)),Ke&&(E+=`&path=${encodeURIComponent(Ke)}`),Qe&&(E+=`&host=${encodeURIComponent(Array.isArray(Qe)?Qe[0]:Qe)}`)}let C="";r["client-fingerprint"]&&(C=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let D="";r["tls-fingerprint"]&&(D=`&pcs=${encodeURIComponent(r["tls-fingerprint"])}`);let B="",H=Array.isArray(r._vcn)?r._vcn.join(","):r["name-cert-verify"];(Array.isArray(r._vcn)||H)&&(B=`&vcn=${encodeURIComponent(H)}`);let V="";r.alpn&&(V=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let S=r["reality-opts"],I="",U="",R="",O="",q="",N="";if(S){O="&security=reality";let fe=r["reality-opts"]?.["public-key"];fe&&(U=`&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&&(q=`&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}${C}${D}${B}${O}${I}${U}${R}${q}${N}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let _=[];r["hop-interval"]&&_.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&_.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&_.push("insecure=1"),r.obfs&&(_.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&_.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&_.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&_.push(`mport=${r.ports}`),r["tls-fingerprint"]&&_.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&_.push("fastopen=1");let k=DA(r["ech-opts"]);k&&_.push(`ech=${encodeURIComponent(k)}`),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${_.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let K=[];Object.keys(r).forEach(fe=>{if(!["name","type","server","port"].includes(fe)){let Se=fe.replace(/-/,"_");["alpn"].includes(fe)?r[fe]&&K.push(`${Se}=${encodeURIComponent(Array.isArray(r[fe])?r[fe][0]:r[fe])}`):["skip-cert-verify"].includes(fe)?r[fe]&&K.push("insecure=1"):["tfo","fast-open"].includes(fe)?r[fe]&&!K.includes("fastopen=1")&&K.push("fastopen=1"):["ports"].includes(fe)?K.push(`mport=${r[fe]}`):["auth-str"].includes(fe)?K.push(`auth=${r[fe]}`):["up"].includes(fe)?K.push(`upmbps=${r[fe]}`):["down"].includes(fe)?K.push(`downmbps=${r[fe]}`):["_obfs"].includes(fe)?K.push(`obfs=${r[fe]}`):["obfs"].includes(fe)?K.push(`obfsParam=${r[fe]}`):["sni"].includes(fe)?K.push(`peer=${r[fe]}`):r[fe]&&!/^_/i.test(fe)&&K.push(`${Se}=${encodeURIComponent(r[fe])}`)}}),n=`hysteria://${r.server}:${r.port}?${K.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=OI({...r,uuid:r.password,network:r.network||"tcp"}).replace("vless","anytls");let Z=[];Object.keys(r).forEach(fe=>{if(!["name","type","password","server","port","tls"].includes(fe)){let Se=fe.replace(/-/,"_");["alpn"].includes(fe)?r[fe]&&Z.push(`${Se}=${encodeURIComponent(Array.isArray(r[fe])?r[fe][0]:r[fe])}`):["skip-cert-verify"].includes(fe)?r[fe]&&Z.push("insecure=1"):["udp"].includes(fe)?r[fe]&&Z.push("udp=1"):r[fe]&&!/^_|client-fingerprint/i.test(fe)&&["number","string","boolean"].includes(typeof r[fe])&&Z.push(`${Se.replace(/-/g,"_")}=${encodeURIComponent(r[fe])}`)}});let G=n.split("?"),ee=G[0],se={};G.length>1&&G[1].split("#")[0].split("&").forEach(Re=>{let[Ke,Qe]=Re.split("=");Ke&&(se[Ke]=Qe)}),Z.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=Ls(r,"ipv4"),Oe=Ls(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 ome=P(x());var XY=wh();function Rp(){return{type:"ALL",produce:r=>{let n=[];return r.map(i=>{try{n.push(XY.produce(i))}catch(o){te.error(`Cannot produce proxy: ${i.name} Reason: ${o}`)}}),Bt.encode(n.join(` `))}}}var fme=P(x());var Wm="QX";function kp(){let e=(t,r,n={})=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${Wm} does not support network ${t.network} with http upgrade`);switch(t.type){case"ss":return ZY(t);case"ssr":return JY(t);case"trojan":return QY(t);case"vmess":return eX(t);case"http":return nX(t);case"socks5":return sX(t);case"vless":return tX(t);case"anytls":return rX(t)}throw new Error(`Platform ${Wm} 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 ${Wm} 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 TA(e){return["http","vmess-http","vemss-http","shadowsocks-http"].includes(e._qx_obfs_http)?e._qx_obfs_http:"http"}function kf(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 ZY(e){let t=new lt(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t),i=hh(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}`),ni(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=${TA(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 ni(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"),kf(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 JY(e){let t=new lt(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 QY(e){let t=new lt(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")ni(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"&&ni(e)&&r(",over-tls=true"),ni(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"),kf(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 eX(e){let t=new lt(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);r(`vmess=${e.server}:${e.port}`);let i=vI(e.cipher);if(r(`,method=${i}`),r(`,password=${e.uuid}`),ni(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=${TA(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 ni(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"),kf(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 tX(e){if(e.encryption&&e.encryption!=="none")throw new Error("VLESS encryption is not supported");let t=new lt(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}`),ni(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=${TA(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 ni(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"),kf(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 rX(e){let t=e.network?.trim().toLowerCase();if(t&&t!=="tcp")throw new Error(`Platform ${Wm} does not support AnyTLS with transport ${e.network}`);let r=new lt(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"),kf(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 nX(e){let t=new lt(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"),ni(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),ni(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"),kf(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 sX(e){let t=new lt(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"),ni(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),ni(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"),kf(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 ni(e){return e.tls}var mme=P(x());function Op(){return{type:"ALL",produce:(r,n,i={})=>{let o=r.filter(s=>{if(i["include-unsupported-proxy"])return!0;if(dh(s,["websocket","quic","http2","mkcp","grpc"])){if(s.type==="snell"&&![1,2,3,4,5,6].includes(s.version))return!1;if(iX(s))return te.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 te.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(Om(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=$n(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=Ls(s,"ipv4"),s.ipv6=Ls(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"?hh(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="/"),lc(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];hc(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 Zo(o,n,i)}}}function iX(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 Eme=P(x());var Np="Surfboard";function Lp(e){return e!=null&&`${e}`.trim().length>0}function Of(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 Ym(){return{produce:t=>{if(["ws"].includes(t.network)&&t["ws-opts"]?.["v2ray-http-upgrade"])throw new Error(`Platform ${Np} does not support network ${t.network} with http upgrade`);switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return fX(t);case"trojan":return lX(t);case"vmess":return hX(t);case"http":return dX(t);case"snell":return cX(t);case"tuic":return oX(t);case"socks5":return pX(t);case"hysteria2":return aX(t);case"wireguard-surge":return gX(t)}if(t.type==="anytls"){if(t.network&&(!["tcp"].includes(t.network)||["tcp"].includes(t.network)&&t["reality-opts"]))throw new Error(`Platform ${Np} does not support proxy type ${t.type} with network or REALITY`);return uX(t)}throw new Error(`Platform ${Np} does not support proxy type: ${t.type}`)}}}function oX(e){if(e.token?.length)throw new Error(`Platform ${Np} does not support proxy type ${e.type} v4`);let t=new lt(e);return t.append(`${e.name}=tuic-v5,${e.server},${e.port}`),t.appendIfPresent(`,uuid=${e.uuid}`,"uuid"),t.appendIfPresent(`,password="${e.password}"`,"password"),Lp(e.alpn)&&t.append(`,alpn="${Array.isArray(e.alpn)?e.alpn.join(","):e.alpn}"`),Lp(e.ports)&&t.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),Lp(e["hop-interval"])&&t.append(`,port-hopping-interval=${e["hop-interval"]}`),Of(t,e),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function aX(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 lt(e);return t.append(`${e.name}=hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),Lp(e.ports)&&t.append(`,port-hopping="${String(e.ports).replace(/,/g,";")}"`),Lp(e["hop-interval"])&&t.append(`,port-hopping-interval=${e["hop-interval"]}`),e["obfs-password"]&&t.append(`,salamander-password="${e["obfs-password"]}"`),Of(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 uX(e){let t=new lt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),Of(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 cX(e){if(pe(e,"version")&&![1,2,3,4,5].includes(Number(e.version)))throw new Error(`Platform ${Np} does not support snell version ${e.version}`);let t=new lt(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 fX(e){let t=new lt(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 lX(e){let t=new lt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),HI(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),Of(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 hX(e){let t=new lt(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),HI(t,e),pe(e,"aead")?t.append(`,vmess-aead=${e.aead}`):t.append(`,vmess-aead=${e.alterId===0}`),t.appendIfPresent(`,tls=${e.tls}`,"tls"),Of(t,e,!!e.tls),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function dX(e){let t=new lt(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"),Of(t,e,!!e.tls),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function pX(e){let t=new lt(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"),Of(t,e,!!e.tls),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function gX(e){let t=new lt(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 HI(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 Bme=P(x());var mX={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"},Pn=(e,t)=>{let r=mX[e["ip-version"]];e._dns_server&&r&&(t.domain_resolver={server:e._dns_server,strategy:r})},xn=(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})},vX=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},Tn=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},no=(e,t)=>{if(["tcp","udp"].includes(e._network)){t.network=e._network;return}e.udp===!1&&(t.network="tcp")},Es=(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},so=(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))))},kA=(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 f of Object.keys(i)){let h=i[f];h!==""&&(Array.isArray(h)||(h=[`${h}`]),h.length>0&&(a[f]=h))}let{Host:u}=a;if(u.length===1)for(let f of`Host:${u[0]}`.split(` `)){let[h,m]=f.split(":");m.trim()!==""&&(a[h.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}=EA(r.path,"ed");n!==""&&(r.path=Us(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},MI=(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(f=>f.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},jI=(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},OA=(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},wX=(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}-----`]},yX=["chrome","firefox","edge","safari","360","qq","ios","android","random","randomized"],KI=e=>{let t=`${e||""}`.trim().toLowerCase();if(yX.includes(t))return t},du=(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=KI(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=wX(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},EX=(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),Es(e,t),Tn(e,t),Pn(e,t),xn(e,t),t},bX=(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),Es(e,t),Tn(e,t),du(e,t),Pn(e,t),xn(e,t),t},AX=(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),no(e,t),Es(e,t),Tn(e,t),Pn(e,t),xn(e,t),t},SX=(e={})=>{let t=Xm(e),r={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:Zm(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}),no(e,r),so(e.smux,r),{type:"ss-with-st",ssPart:r,stPart:RA(e,t)}},Zm=(e={})=>`${e.name}_shadowtls`,Xm=(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}},qI=e=>{if(typeof e=="string")return e.split(",").map(t=>t.trim()).filter(t=>t!=="");if(Array.isArray(e))return e},RA=(e={},t)=>{if(!t)throw new Error("shadow-tls plugin options are missing");let r=KI(e["client-fingerprint"]),n={tag:Zm(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=qI(t.alpn)??qI(e.alpn);return i&&(n.tls.alpn=i),e["fast-open"]===!0&&(n.udp_fragment=!0),Es(e,n),Tn(e,n),Pn(e,n),xn(e,n),n},CX=(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),no(e,t),Es(e,t),Tn(e,t),so(e.smux,t),Pn(e,t),xn(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=Fp(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},_X=(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),no(e,t),Es(e,t),Tn(e,t),so(e.smux,t),Pn(e,t),xn(e,t),t},DX=e=>{if(e==null)return;let t=`${e}`.trim();return/^\d+$/.test(t)?parseInt(t,10):NaN},FX=(e={},t=!1)=>{let r=DX(e.version),n=Xm(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),no(e,s),n?(s.detour=Zm(e),delete s.server,delete s.server_port):(e["fast-open"]&&(s.udp_fragment=!0),Es(e,s),Tn(e,s),Pn(e,s),xn(e,s)),s},BX=["","packetaddr","xudp"],IX=e=>{let t=`${e}`.trim().toLowerCase();if(BX.includes(t))return t},VI=(e,t)=>{if(e["packet-encoding"]!=null){let r=IX(e["packet-encoding"]);r!=null&&(t.packet_encoding=r)}else e.xudp?t.packet_encoding="xudp":e["packet-addr"]&&(t.packet_encoding="packetaddr")},$X=(e,t)=>{VI(e,t),e["global-padding"]!=null&&(t.global_padding=!!e["global-padding"]),e["authenticated-length"]!=null&&(t.authenticated_length=!!e["authenticated-length"])},PX=(e={})=>{let t={tag:e.name,type:"vmess",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,security:$n(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 $X(e,t),e["fast-open"]&&(t.udp_fragment=!0),e.network==="ws"&&kA(e,t),e.network==="h2"&&jI(e,t),e.network==="http"&&MI(e,t),e.network==="grpc"&&OA(e,t),no(e,t),Es(e,t),Tn(e,t),du(e,t),so(e.smux,t),Pn(e,t),xn(e,t),t},xX=(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 VI(e,t),e["fast-open"]&&(t.udp_fragment=!0),e.flow!=null&&(t.flow=e.flow),e.network==="ws"&&kA(e,t),e.network==="h2"&&jI(e,t),e.network==="http"&&MI(e,t),e.network==="grpc"&&OA(e,t),no(e,t),Es(e,t),Tn(e,t),so(e.smux,t),du(e,t),Pn(e,t),xn(e,t),t},TX=(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"&&OA(e,t),e.network==="ws"&&kA(e,t),no(e,t),Es(e,t),Tn(e,t),du(e,t),so(e.smux,t),Pn(e,t),xn(e,t),t},RX=(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),Es(e,t),Tn(e,t),du(e,t),so(e.smux,t),Pn(e,t),xn(e,t),t.tls?.insecure&&(te.info("Platform sing-box: insecure is not supported on naive outbound"),delete t.tls.insecure),t},kX=(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)),no(e,t),du(e,t),Tn(e,t),Es(e,t),so(e.smux,t),Pn(e,t),xn(e,t),t},OX=(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?hu(`${r}`.trim()):void 0,a=o?hu(`${n}`.trim()):void 0,u=a!=null?Math.min(a,2048):a,f=s??512,h=u??1200;o&&a!=null&&a>2048&&te.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)||h{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`),no(e,t),Es(e,t),Tn(e,t),du(e,t),so(e.smux,t),Pn(e,t),xn(e,t),t},LX=(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"]),Tn(e,t),du(e,t),Pn(e,t),xn(e,t),t},UX=(e={})=>{let t=vX(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||(Tn(e,r),Pn(e,r),xn(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},HX=(e={})=>{let t=["ipv4","ipv6"].map(n=>Ls(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 Es(e,r),Tn(e,r),so(e.smux,r),Pn(e,r),xn(e,r),delete r.server,delete r.server_port,delete r.pre_shared_key,delete r.peer_public_key,delete r.reserved,r};function Jm(){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(ri().produce(r,"internal",{"include-unsupported-proxy":!0}).map(u=>{let f=o.length;try{let h=s.get(u);h&&(u.plugin=h.plugin,u["plugin-opts"]=h["plugin-opts"],h["obfs-opts"]?u["obfs-opts"]=h["obfs-opts"]:delete u["obfs-opts"]);let m=Xm(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=RA(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(EX(u));break;case"http":o.push(bX(u));break;case"socks5":if(u.tls)throw new Error(`Platform sing-box does not support proxy type: ${u.type} with tls`);o.push(AX(u));break;case"ss":if(u.plugin==="shadow-tls"){let{ssPart:v,stPart:g}=SX(u);o.push(v),o.push(g)}else o.push(CX(u));break;case"ssr":if(i["include-unsupported-proxy"])o.push(_X(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type}`);break;case"snell":{o.push(FX(u,i["include-unsupported-proxy"]));let v=Xm(u);v&&o.push(RA(u,v));break}case"vmess":if(!u.network||["tcp","ws","grpc","h2","http"].includes(u.network))o.push(PX(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(xX(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(TX(u));else throw new Error(`Platform sing-box does not support proxy type: ${u.type} with flow ${u.flow}`);break;case"naive":o.push(RX(u));break;case"hysteria":o.push(kX(u));break;case"hysteria2":o.push(OX(u,i["include-unsupported-proxy"]));break;case"tuic":if(!u.token||u.token.length===0)o.push(NX(u));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":o.push(HX(u));break;case"anytls":o.push(LX(u));break;case"tailscale":o.push(UX(u));break;default:throw new Error(`Platform sing-box does not support proxy type: ${u.type}`)}if(d){let v=o[f];v.detour=Zm(u),delete v.tls,o.push(d)}if(i["include-unsupported-proxy"]&&u["name-cert-verify"])for(let v=f;v(["wireguard","tailscale"].includes(f.type)?u.endpoints.push(f):u.outbounds.push(f),u),{outbounds:[],endpoints:[]});return JSON.stringify(a,null,2)}}}var Tme=P(x());function Qm(){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||!YI(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||!YI(s)||typeof s.flow<"u"&&!["xtls-rprx-vision",""].includes(s.flow))||s.type==="tuic"&&s.token&&s.token.length!==0||s.type==="snell"&&XI(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},f;s.tls&&!s.sni&&(s.sni=s.server);let h=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,...zI(s)?{headers:s.headers}:{},tfo:io(s),...s.tls?{sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Nf(s)}:{}};else if(s.type==="https")s={type:"https",name:s.name,server:s.server,port:s.port,username:s.username,password:s.password,...zI(s)?{headers:s.headers}:{},tfo:io(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Nf(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:io(s),udp_relay:vc(s),...s.tls?{sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Nf(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:io(s),udp_relay:vc(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:io(s),udp_relay:vc(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:io(s),udp_relay:vc(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Nf(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:io(s),udp_relay:vc(s),sni:s.sni,skip_tls_verify:s["skip-cert-verify"],reality:Nf(s)};else if(s.type==="vmess"){let p=$n(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:ZI(s["h2-opts"]),sni:s.sni,skip_tls_verify:s["skip-cert-verify"]}}:s.network==="grpc"?s.transport=WI(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:io(s),legacy:d,udp_relay:vc(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:ZI(s["h2-opts"]),sni:s.sni,skip_tls_verify:s["skip-cert-verify"]}}:s.network==="grpc"?s.transport=WI(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:Nf(s)}},f=s.flow,f===""&&(f=void 0)),s={type:"vless",name:s.name,server:s.server,port:s.port,user_id:s.uuid,security:s.cipher,tfo:io(s),udp_relay:vc(s),transport:s.transport,flow:f}}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:Ls(s,"ipv4"),local_ipv6:Ls(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:io(s)};else if(s.type==="snell"){let p=XI(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:vc(s)}:{},reuse:s.reuse,obfs:s["obfs-opts"]?.mode||s.obfs,obfs_host:s["obfs-opts"]?.host||s["obfs-host"]||s.obfs_host,tfo:io(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=jX(u);if(m&&(KX(u,s)&&(s.fingerprint_sha256=m),VX(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:h}}}catch(u){return te.error(`Cannot produce proxy: ${s.name} Reason: ${u}`),null}}).filter(Boolean);return Zo(o,n,i)}}}function zI(e){return e?.headers&&typeof e.headers=="object"&&Object.keys(e.headers).length>0}function io(e){return e.tfo??e["fast-open"]}function vc(e){return e.udp??e.udp_relay}function GI(e){if(e!=null&&!(typeof e=="string"&&e.length===0))return e}function Nf(e){let t=e?.["reality-opts"];if(!t)return;let r={},n=GI(t["public-key"]),i=GI(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 WI(e){return{grpc:{service_name:e["grpc-opts"]?.["grpc-service-name"],sni:e.sni,reality:Nf(e),skip_tls_verify:e["skip-cert-verify"]}}}function YI(e){if(e.network!=="grpc")return!0;let t=e["grpc-opts"]?.["_grpc-type"];return t==null?!0:`${t}`.trim().toLowerCase()==="gun"}function XI(e){if(e==null)return;let t=`${e}`.trim();return/^[1-5]$/.test(t)?parseInt(t,10):null}function qX(e,...t){for(let r of t){let n=NA(e?.[r]);if(n)return n}}function MX(e){return NA(e?.host)||qX(e?.headers,"host","Host")}function ZI(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=NA(i);o!=null&&(t[n]=o)}let r=MX(e);return r&&(t.Host=r),Object.keys(t).length>0?t:void 0}function NA(e){if(Array.isArray(e))return e[0];if(e!=null)return e}function jX(e){let t=e?.["tls-fingerprint"];if(typeof t!="string")return;let r=t.trim();return r.length>0?r:void 0}function KX(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 VX(e,t){if(e)for(let r of["grpc","http2","tls","wss"])e[r]&&(e[r].fingerprint_sha256=t)}function JI(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var QI={qx:kp(),QX:kp(),QuantumultX:kp(),surge:mh(),Surge:mh(),SurgeMac:$p(),Loon:$A(),Clash:IA(),meta:ri(),clashmeta:ri(),"clash.meta":ri(),"Clash.Meta":ri(),ClashMeta:ri(),mihomo:ri(),Mihomo:ri(),uri:wh(),URI:wh(),v2:Rp(),v2ray:Rp(),V2Ray:Rp(),json:JI(),JSON:JI(),stash:jm(),Stash:jm(),shadowrocket:Op(),Shadowrocket:Op(),ShadowRocket:Op(),surfboard:Ym(),Surfboard:Ym(),singbox:Jm(),"sing-box":Jm(),egern:Qm(),Egern:Qm()};var Ave=P(x());var Q2e=P(x()),i7=P(u2()),eJ=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 [^=,]+ `,nS;function Qn(){return nS||(nS=i7.default.generate(eJ)),nS}var tve=P(x()),o7=P(u2()),tJ=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 [^=,]+ `,sS;function oo(){return sS||(sS=o7.default.generate(tJ)),sS}var nve=P(x()),a7=P(u2()),rJ=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" } `,iS;function Qo(){return iS||(iS=a7.default.generate(rJ)),iS}var ave=P(x());var nJ=new Set(["__proto__","constructor","prototype"]),oS;function gu(e,t,r){if(Object(e)!==e)return e;if(Array.isArray(t)||(t=t.toString().match(/[^.[\]]+/g)||[]),t.some(n=>nJ.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 c2(e){if(e!=null)return/(TRUE)|1/i.test(e)}function u7(e){return hu(e)!=null}function aS(e){try{return decodeURIComponent(e)}catch{return e}}function sJ(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(":"))&&!mr(u))throw new Error(`Invalid server: ${i}`);if(t.type="trojan",t.password=aS(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?aS(a):`${i}:${o}`;let f={};if(s)for(let h of s.split("&")){let m=h.indexOf("="),p=m===-1?h:h.slice(0,m);f[p]=m===-1?!0:aS(h.slice(m+1))}if(t["skip-cert-verify"]=c2(f.allowInsecure),t.sni=f.sni||f.peer,t["client-fingerprint"]=f.fp,t["tls-fingerprint"]=f.pcs,t._vcn=f.vcn?.split(",").map(h=>h.trim()).filter(Boolean),t["name-cert-verify"]=t._vcn?.[0],f.alpn&&(t.alpn=f.alpn.split(",")),c2(f.ws)&&(t.network="ws",gu(t,"ws-opts.path",f.wspath)),f.type){let h=!1,m="",p="";if(t.network=f.type,t.network==="httpupgrade"&&(t.network="ws",h=!0),t.network==="grpc")t["grpc-opts"]={"grpc-service-name":f.serviceName,"_grpc-type":f.mode,"_grpc-authority":f.authority};else{if(f.path){let d=f.path;if(t.network==="ws"){let v=Ip(d,"ed");u7(v)&&(d=Us(d,"ed").path,h?m=v:p=v)}gu(t,`${t.network}-opts.path`,d)}f.host&&gu(t,`${t.network}-opts.headers.Host`,f.host),h?(m=m||(u7(f.ed)?String(f.ed):""),gu(t,"ws-opts.v2ray-http-upgrade",!0),m&&(gu(t,"ws-opts.v2ray-http-upgrade-fast-open",!0),gu(t,"ws-opts._v2ray-http-upgrade-ed",m))):t.network==="ws"&&p&&(gu(t,"ws-opts.max-early-data",hu(p)),gu(t,"ws-opts.early-data-header-name","Sec-WebSocket-Protocol"))}if(f.security==="reality"){let d={};f.pbk&&(d["public-key"]=f.pbk),f.sid&&(d["short-id"]=f.sid),f.spx&&(d["_spider-x"]=f.spx),f.mode&&(t._mode=f.mode),f.extra&&(t._extra=f.extra),Object.keys(d).length&&gu(t,"reality-opts",d)}}return t.udp=c2(f.udp),t.tfo=c2(f.tfo),t}function uS(){return oS||(oS={parse:sJ}),oS}var hS=P(lS());var ea=P(xm());function c7(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 f7(e){let[t,r,n]=/^(.*?)(?:#(.*?))?$/.exec(e);return{content:r,fragment:n!=null?decodeURIComponent(n):void 0}}function iJ(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:Bt.decode(r)}function dS(e){return e==null||!/^\d+$/.test(`${e}`)?!1:Number.isSafeInteger(parseInt(`${e}`,10))}function pS(e){let t=Ip(e,"ed");return dS(t)?{path:Us(e,"ed").path,ed:t}:{path:e,ed:""}}function gS(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 mS(e){if(Array.isArray(e))return e.flatMap(r=>mS(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 oJ(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 Nr(i)?{family:"ipv4",address:i,cidr:o(n,32)}:mr(i)?{family:"ipv6",address:i,cidr:o(n,128)}:null}function aJ(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[i,o,s,a,u,f,h,m,p]=n.match(/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/);if(h)h=parseInt(h,10);else{if(s)h=443;else if(o==="http")h=80;else throw te.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);te.info(`port is not present in line: ${n}, set to ${h}`)}return{name:p!=null?decodeURIComponent(p):`${o} ${f}:${h}`,type:o,tls:!!s,server:f,port:h,username:a!=null?decodeURIComponent(a):void 0,password:u!=null?decodeURIComponent(u):void 0}}}}function uJ(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[i,o,s,a,u,f,h]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(u)u=parseInt(u,10);else throw te.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let m,p;if(s){let v=Bt.decode(decodeURIComponent(s)).split(":");m=v[0],p=v[1]}return{name:h!=null?decodeURIComponent(h):`${o} ${a}:${u}`,type:"socks5",server:a,port:u,username:m,password:p}}}}function cJ(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let{content:i,fragment:o}=f7(n.split("ss://")[1]),s={type:"ss"},a=i.match(/@([^/?]*)(\/|\?|$)/),u=iJ(i.split("@")[0]),f="";if(a)i.includes("?")&&(f=i.match(/(\?.*)$/)[1]);else{if(i.includes("?")){let w=i.match(/^(.*)(\?.*)$/);i=w[1],f=w[2]}if(i=Bt.decode(i),f){if(/(&|\?)v2ray-plugin=/.test(f)){let E=f.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];E&&(s.plugin="v2ray-plugin",s["plugin-opts"]=JSON.parse(Bt.decode(E)))}i=`${i}${f}`}u=i.match(/(^.*)@/)?.[1],a=i.match(/@([^/@]*)(\/|$)/)}let h={};for(let w of f.replace(/^\?/,"").split("&"))if(w){let[E,C]=w.split("="),D=C;D=decodeURIComponent(C),h[E]=D}if(s.tls=h.security&&h.security!=="none",s["skip-cert-verify"]=!!h.allowInsecure,s.sni=h.sni||h.peer,s["client-fingerprint"]=h.fp,s.alpn=h.alpn?decodeURIComponent(h.alpn).split(","):void 0,h.ws&&(s.network="ws",ea.default.set(s,"ws-opts.path",h.wspath)),h.type){let w,E="",C="";if(s.network=h.type,s.network==="httpupgrade"&&(s.network="ws",w=!0),["grpc"].includes(s.network))s[s.network+"-opts"]={"grpc-service-name":h.serviceName,"_grpc-type":h.mode,"_grpc-authority":h.authority};else{if(h.path){let D=h.path;if(s.network==="ws"){let B=pS(D);D=B.path,w?E=B.ed:C=B.ed}ea.default.set(s,s.network+"-opts.path",D)}h.host&&ea.default.set(s,s.network+"-opts.headers.Host",decodeURIComponent(h.host)),w?(E=E||(dS(h.ed)?`${h.ed}`:""),ea.default.set(s,s.network+"-opts.v2ray-http-upgrade",!0),E!==""&&(ea.default.set(s,s.network+"-opts.v2ray-http-upgrade-fast-open",!0),ea.default.set(s,s.network+"-opts._v2ray-http-upgrade-ed",E))):s.network==="ws"&&C!==""&&(ea.default.set(s,s.network+"-opts.max-early-data",gS(C)),ea.default.set(s,s.network+"-opts.early-data-header-name","Sec-WebSocket-Protocol"))}if(["reality"].includes(h.security)){let D={};h.pbk&&(D["public-key"]=h.pbk),h.sid&&(D["short-id"]=h.sid),h.spx&&(D["_spider-x"]=h.spx),h.mode&&(s._mode=h.mode),h.extra&&(s._extra=h.extra),Object.keys(D).length>0&&ea.default.set(s,h.security+"-opts",D)}}s.udp=!!h.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 C of w){let D=C.indexOf("=");if(D===-1){C&&(E[C]=!0);continue}let B=C.slice(0,D),H=C.slice(D+1).replace(/\\=/g,"=");B&&(E[B]=H||!0)}switch(E.plugin){case"obfs-local":case"simple-obfs":s.plugin="obfs",s["plugin-opts"]={mode:E.obfs,host:Lt(E["obfs-host"])};break;case"v2ray-plugin":s.plugin="v2ray-plugin",s["plugin-opts"]={mode:Lt(E.obfs)||Lt(E.mode)||"websocket",host:Lt(E["obfs-host"])||Lt(E.host),path:Lt(E.path),tls:Ia(E.tls),sni:Ia(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 C=Lt(E.version);s["plugin-opts"]={host:Lt(E.host),password:Lt(E.password),version:C?parseInt(C,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${E.plugin}`)}}if(g){let w=JSON.parse(Bt.decode(g[1])),E=Lt(w.version),C=Lt(w.address),D=Lt(w.port);s.plugin="shadow-tls",s["plugin-opts"]={host:Lt(w.host),password:Lt(w.password),version:E?parseInt(E,10):void 0},C&&(s.server=C),D&&(s.port=parseInt(D,10))}if(y){let w=JSON.parse(Bt.decode(decodeURIComponent(y[1]))),E=Lt(w.address),C=Lt(w.port),D=Lt(w.route),B=D?.trim().toLowerCase(),H=["ws","wss","websocket"].includes(B);s.plugin="gost-plugin",s["plugin-opts"]={mode:H?"websocket":D,host:Lt(w.host),path:Lt(w.path)},B==="wss"&&(s["plugin-opts"].tls=!0),E&&(s.server=E),C&&(s.port=parseInt(C,10))}return/(&|\?)uot=(1|true)/i.test(f)&&(s["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(f)&&(s.tfo=!0),s.name=o??`SS ${s.server}:${s.port}`,s}}}function fJ(){return{name:"URI SSR Parser",test:n=>/^ssr:\/\//.test(n),parse:n=>{n=Bt.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(":"),f={type:"ssr",server:s,port:a,protocol:u[0],cipher:u[1],obfs:u[2],password:Bt.decode(u[3])},h={};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)"&&(h[p]=d)}return f={...f,name:h.remarks?Bt.decode(h.remarks):f.server,"protocol-param":Lt(Bt.decode(h.protoparam||"").replace(/\s/g,"")),"obfs-param":Lt(Bt.decode(h.obfsparam||"").replace(/\s/g,""))},f}}}function lJ(){return{name:"URI VMess Parser",test:n=>/^vmess:\/\//.test(n),parse:n=>{let{content:i,fragment:o}=f7(n.split("vmess://")[1]),s=Bt.decode(i.replace(/\?.*?$/,""));if(/=\s*vmess/.test(s)){let a=s.split(",").map(h=>h.trim()),u={};for(let h of a)if(h.indexOf("=")!==-1){let[m,p]=h.split("=");u[m.trim()]=p.trim()}let f={name:a[0].split("=")[0].trim(),type:"vmess",server:a[1],port:a[2],cipher:$n(Lt(a[3],"auto")),uuid:a[4].match(/^"(.*)"$/)[1],tls:u.obfs==="wss",udp:Ia(u["udp-relay"]),tfo:Ia(u["fast-open"]),"skip-cert-verify":hl(u["tls-verification"])?!u["tls-verification"]:void 0};if(hl(u.obfs))if(u.obfs==="ws"||u.obfs==="wss"){f.network="ws",f["ws-opts"].path=(Lt(u["obfs-path"])||'"/"').match(/^"(.*)"$/)[1];let h=u["obfs-header"];h&&h.indexOf("Host")!==-1&&(h=h.match(/Host:\s*([a-zA-Z0-9-.]*)/)[1]),et(h)&&(f["ws-opts"].headers={Host:h})}else throw new Error(`Unsupported obfs: ${u.obfs}`);return et(o)&&(f.name=o),f}else{let a={};try{a=JSON.parse(s)}catch{let[d,v,g]=/(^[^?]+?)\/?\?(.*)$/.exec(i);s=Bt.decode(v);for(let B of g.split("&")){let[H,V]=B.split("="),S=V;S=decodeURIComponent(V),S.indexOf(",")===-1?a[H]=S:a[H]=S.split(",")}let[y,w,E,C,D]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(s);a.scy=w,a.id=E,a.port=D,a.add=C}let u=a.add,f=parseInt(Ia(a.port),10),h={name:a.ps??a.remarks??a.remark??`VMess ${u}:${f}`,type:"vmess",server:u,port:f,cipher:$n(a.scy),uuid:a.id,alterId:parseInt(Ia(a.aid??a.alterId,0),10),tls:["tls",!0,1,"1"].includes(a.tls),"skip-cert-verify":hl(a.verify_cert)?!a.verify_cert:void 0};!h["skip-cert-verify"]&&hl(a.allowInsecure)&&(h["skip-cert-verify"]=/(TRUE)|1/i.test(a.allowInsecure)),h.tls&&(a.sni&&a.sni!==""?h.sni=a.sni:a.peer&&a.peer!==""&&(h.sni=a.peer));let m=!1;if(a.net==="ws"||a.obfs==="websocket"?h.network="ws":["http"].includes(a.obfs)||["http"].includes(a.type)?h.network="http":a.net==="http"?h.network="h2":["grpc","kcp","quic"].includes(a.net)?h.network=a.net:a.net==="httpupgrade"||h.network==="httpupgrade"?(h.network="ws",m=!0):(a.net==="h2"||h.network==="h2")&&(h.network="h2"),h.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(h.network==="ws"&&d){let y=pS(d);d=y.path,m?v=y.ed:g=y.ed}if(["ws"].includes(h.network)&&(d=d||"/"),h.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="/"):h.network==="h2"&&(d||(d="/")),d||p||["kcp","quic"].includes(h.network))if(["grpc"].includes(h.network))h[`${h.network}-opts`]={"grpc-service-name":Lt(d),"_grpc-type":Lt(a.type),"_grpc-authority":Lt(a.authority)};else if(["kcp","quic"].includes(h.network))h[`${h.network}-opts`]={[`_${h.network}-type`]:Lt(a.type),[`_${h.network}-host`]:Lt(Lt(p)),[`_${h.network}-path`]:Lt(d)};else{let y={path:Lt(d)},w=Lt(p);if(h.network==="h2"){let E=mS(w);E&&(y.host=E)}else y.headers={Host:w};m?(y["v2ray-http-upgrade"]=!0,v=v||(dS(a.ed)?`${a.ed}`:""),v!==""&&(y["v2ray-http-upgrade-fast-open"]=!0,y["_v2ray-http-upgrade-ed"]=v)):h.network==="ws"&&g!==""&&(y["max-early-data"]=gS(g),y["early-data-header-name"]="Sec-WebSocket-Protocol"),h[`${h.network}-opts`]=y}else delete h.network}return h["client-fingerprint"]=a.fp,h.alpn=a.alpn?a.alpn.split(","):void 0,et(o)&&(h.name=o),h}}}}function l7(){return{name:"URI VLESS Parser",test:n=>/^vless:\/\//.test(n),parse:n=>{let i=_=>{if(!dt(_))return;let k={},K={maxConnections:"max-connections",maxConcurrency:"max-concurrency",cMaxReuseTimes:"c-max-reuse-times",hMaxRequestTimes:"h-max-request-times",hMaxReusableSecs:"h-max-reusable-secs"};for(let[G,ee]of Object.entries(K)){let se=pc(_[G]);se!=null&&(k[ee]=typeof se=="number"?`${se}`:se)}let Z=gc(_.hKeepAlivePeriod);return Z!=null&&(k["h-keep-alive-period"]=Z),Object.keys(k).length>0?k:void 0},o=_=>{if(!dt(_))return;let k={};for(let[K,Z]of Object.entries(_))typeof Z=="string"&&(k[K]=Z);return Object.keys(k).length>0?k:void 0},s=_=>{if(Array.isArray(_))return _.map(s);if(dt(_)){let k={};for(let[K,Z]of Object.entries(_))k[K]=s(Z);return k}return _},a=_=>{if(Array.isArray(_))return _.map(a).filter(K=>K!==void 0);if(!dt(_))return _;let k={};for(let[K,Z]of Object.entries(_)){let G=a(Z);G!==void 0&&(k[K]=G)}return Object.keys(k).length>0?k:void 0},u=(_,k,K)=>{let Z=a(s(K));Z!==void 0&&(_[k]=Z)},f=_=>{if(_==null)return;if(!dt(_))return s(_);let k={};for(let[K,Z]of Object.entries(_))typeof Z!="string"&&u(k,K,Z);return a(k)},h=(_,k)=>["maxConnections","maxConcurrency","cMaxReuseTimes","hMaxRequestTimes","hMaxReusableSecs"].includes(_)?pc(k)!=null:_==="hKeepAlivePeriod"?gc(k)!=null:!1,m=_=>{if(_==null)return;if(!dt(_))return s(_);let k={};for(let[K,Z]of Object.entries(_))h(K,Z)||u(k,K,Z);return a(k)},p=_=>{if(_==null)return;if(!dt(_))return s(_);let k={};for(let[K,Z]of Object.entries(_))switch(K){case"headers":{let G=f(Z);G!==void 0&&(k.headers=G);break}case"noGRPCHeader":case"xPaddingObfsMode":Z!==!0&&u(k,K,Z);break;case"xPaddingBytes":vh(Z)==null&&u(k,K,Z);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 Z!="string"&&u(k,K,Z);break;case"sessionIDTable":typeof Z!="string"&&u(k,K,Z);break;case"uplinkChunkSize":pc(Z)==null&&u(k,K,Z);break;case"scMaxEachPostBytes":vh(Z)==null&&u(k,K,Z);break;case"scMinPostsIntervalMs":xp(Z)==null&&u(k,K,Z);break;case"sessionIDLength":vh(Z)==null&&u(k,K,Z);break;case"xmux":{let G=m(Z);G!==void 0&&(k.xmux=G);break}default:u(k,K,Z);break}return a(k)},d=_=>{if(_==null)return;if(!dt(_))return s(_);let k={};Object.prototype.hasOwnProperty.call(_,"path")&&!et(_.path)&&u(k,"path",_.path),Object.prototype.hasOwnProperty.call(_,"host")&&!et(_.host)&&u(k,"host",_.host),Object.prototype.hasOwnProperty.call(_,"mode")&&!et(_.mode)&&u(k,"mode",_.mode);let K={};for(let[G,ee]of Object.entries(_))["path","host","mode","extra"].includes(G)||(K[G]=ee);let Z=p(K);if(dt(Z)&&Object.assign(k,Z),Object.prototype.hasOwnProperty.call(_,"extra")){let G=p(_.extra);G!==void 0&&(k.extra=G)}return a(k)},v=_=>{if(_==null)return;if(!dt(_))return s(_);let k={};for(let[K,Z]of Object.entries(_))switch(K){case"address":et(Z)||u(k,K,Z);break;case"port":gc(Z,{allowNegative:!1})==null&&u(k,K,Z);break;case"security":{let G=typeof Z=="string"?Z.toLowerCase():"";["tls","reality"].includes(G)||u(k,K,Z);break}case"tlsSettings":{if(!dt(Z)){u(k,K,Z);break}let G={},ee=CA(Z.echConfigList);for(let[le,ve]of Object.entries(Z))switch(le){case"serverName":case"fingerprint":et(ve)||u(G,le,ve);break;case"echConfigList":CA(ve)||u(G,le,ve);break;case"echForceQuery":(!ee||!qm(ve))&&u(G,le,ve);break;case"echSockopt":(!ee||!dt(ve))&&u(G,le,ve);break;case"alpn":Array.isArray(ve)&&ve.length>0&&ve.every(we=>typeof we=="string"&&we!=="")||u(G,le,ve);break;case"allowInsecure":ve!==!0&&u(G,le,ve);break;default:u(G,le,ve);break}let se=a(G);se!==void 0&&(k.tlsSettings=se);break}case"realitySettings":{if(!dt(Z)){u(k,K,Z);break}let G={};for(let[se,le]of Object.entries(Z))switch(se){case"publicKey":case"shortId":case"serverName":case"fingerprint":et(le)||u(G,se,le);break;default:u(G,se,le);break}let ee=a(G);ee!==void 0&&(k.realitySettings=ee);break}case"xhttpSettings":{let G=d(Z);G!==void 0&&(k.xhttpSettings=G);break}case"network":{let G=typeof Z=="string"?Z.toLowerCase():"";G!=="xhttp"&&G!=="splithttp"&&u(k,K,Z);break}default:u(k,K,Z);break}return a(k)},g=(_,{parsedDownloadSettings:k}={})=>{if(!dt(_))return;let{downloadSettings:K,...Z}=_,G=p(Z)||{};if(Object.prototype.hasOwnProperty.call(_,"downloadSettings")){let ee=v(K);ee!==void 0&&(G.downloadSettings=ee)}return a(G)},y=(_,k)=>{if(!dt(_)||!dt(k))return;let K=o(k.headers);if(K){let we={..._.headers||{}};for(let[Pe,Le]of Object.entries(K)){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&&(_.headers=we)}k.noGRPCHeader===!0&&(_["no-grpc-header"]=!0);let Z=vh(k.xPaddingBytes);Z!=null&&(_["x-padding-bytes"]=Z),k.xPaddingObfsMode===!0&&(_["x-padding-obfs-mode"]=!0),et(k.xPaddingKey)&&(_["x-padding-key"]=k.xPaddingKey),et(k.xPaddingHeader)&&(_["x-padding-header"]=k.xPaddingHeader),et(k.xPaddingPlacement)&&(_["x-padding-placement"]=k.xPaddingPlacement),et(k.xPaddingMethod)&&(_["x-padding-method"]=k.xPaddingMethod),et(k.uplinkHTTPMethod)&&(_["uplink-http-method"]=k.uplinkHTTPMethod),et(k.sessionIDPlacement)?_["session-placement"]=k.sessionIDPlacement:et(k.sessionPlacement)&&(_["session-placement"]=k.sessionPlacement),et(k.sessionIDKey)?_["session-key"]=k.sessionIDKey:et(k.sessionKey)&&(_["session-key"]=k.sessionKey),typeof k.sessionIDTable=="string"&&(_["session-table"]=k.sessionIDTable);let G=vh(k.sessionIDLength);G!=null&&(_["session-length"]=G),et(k.seqPlacement)&&(_["seq-placement"]=k.seqPlacement),et(k.seqKey)&&(_["seq-key"]=k.seqKey),et(k.uplinkDataPlacement)&&(_["uplink-data-placement"]=k.uplinkDataPlacement),et(k.uplinkDataKey)&&(_["uplink-data-key"]=k.uplinkDataKey);let ee=pc(k.uplinkChunkSize);ee!=null&&(_["uplink-chunk-size"]=ee);let se=Tp(k.scMaxEachPostBytes);se!=null&&(_["sc-max-each-post-bytes"]=se);let le=xp(k.scMinPostsIntervalMs);le!=null&&(_["sc-min-posts-interval-ms"]=le);let ve=i(k.xmux);ve&&(_["reuse-settings"]=ve)},w=_=>{if(!dt(_))return;let k={},K=typeof _.network=="string"?_.network.toLowerCase():"";(K==="xhttp"||K==="splithttp")&&(k.network="xhttp"),et(_.address)&&(k.server=_.address);let Z=gc(_.port,{allowNegative:!1});Z!=null&&(k.port=Z);let G=typeof _.security=="string"?_.security.toLowerCase():"";if((G==="tls"||G==="reality")&&(k.tls=!0),dt(_.tlsSettings)){et(_.tlsSettings.serverName)&&(k.servername=_.tlsSettings.serverName),et(_.tlsSettings.fingerprint)&&(k["client-fingerprint"]=_.tlsSettings.fingerprint),Array.isArray(_.tlsSettings.alpn)&&_.tlsSettings.alpn.length>0&&_.tlsSettings.alpn.every(le=>typeof le=="string"&&le!=="")&&(k.alpn=_.tlsSettings.alpn),_.tlsSettings.allowInsecure===!0&&(k["skip-cert-verify"]=!0);let se=Mm({echConfigList:_.tlsSettings.echConfigList,echForceQuery:_.tlsSettings.echForceQuery,echSockopt:_.tlsSettings.echSockopt});se&&(k["ech-opts"]=se)}let ee;return dt(_.realitySettings)&&(ee={},et(_.realitySettings.publicKey)&&(ee["public-key"]=_.realitySettings.publicKey),et(_.realitySettings.shortId)&&(ee["short-id"]=_.realitySettings.shortId),et(_.realitySettings.serverName)&&(k.servername=_.realitySettings.serverName),et(_.realitySettings.fingerprint)&&(k["client-fingerprint"]=_.realitySettings.fingerprint)),G==="reality"?k["reality-opts"]=ee||{}:ee&&Object.keys(ee).length>0&&(k["reality-opts"]=ee),dt(_.xhttpSettings)&&(et(_.xhttpSettings.path)&&(k.path=_.xhttpSettings.path),et(_.xhttpSettings.host)&&(k.host=_.xhttpSettings.host),et(_.xhttpSettings.mode)&&(k.mode=_.xhttpSettings.mode),y(k,_.xhttpSettings),dt(_.xhttpSettings.extra)&&y(k,_.xhttpSettings.extra)),Object.keys(k).length>0?k:void 0};n=n.split("vless://")[1];let E,C=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);if(!C){let[_,k,K]=/^(.*?)(\?.*?$)/.exec(n);n=`${Bt.decode(k)}${K}`,C=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),E=!0}let[D,B,H,V,S,I="",U]=C;E&&(B=B.replace(/^.*?:/g,"")),V=parseInt(`${V}`,10),B=decodeURIComponent(B),U!=null&&(U=decodeURIComponent(U));let R={type:"vless",name:U,server:H,port:V,uuid:B,udp:!0},O={};for(let _ of I.split("&"))if(_){let[k,K]=_.split("="),Z=K;Z=decodeURIComponent(K),O[k]=Z}if(R.name=U??O.remarks??O.remark??`VLESS ${H}:${V}`,R.tls=O.security&&O.security!=="none",O.pbk&&(O.security="reality"),E&&/TRUE|1/i.test(O.tls)&&(R.tls=!0,O.security=O.security??"reality"),R.sni=O.sni||O.peer,R.flow=O.flow,!R.flow&&E&&O.xtls){let _=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][O.xtls];_&&(R.flow=_)}R["client-fingerprint"]=O.fp,R.alpn=O.alpn?O.alpn.split(","):void 0,R["skip-cert-verify"]=/(TRUE)|1/i.test(O.allowInsecure),R._echConfigList=Ia(O.ech);let q=Mm({echConfigList:O.ech});switch(q&&(R["ech-opts"]=q),R["tls-fingerprint"]=Ia(O.pcs),R._vcn=O.vcn?.split(",").map(_=>_.trim()).filter(Boolean),R["name-cert-verify"]=R._vcn?.[0],R._h2=/(TRUE)|1/i.test(O.h2),`${O.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(O.security)){let _={};O.pbk&&(_["public-key"]=O.pbk),O.sid&&(_["short-id"]=O.sid),O.spx&&(_["_spider-x"]=O.spx),Object.keys(_).length>0&&(R[`${O.security}-opts`]=_)}let N=!1;if(R.network=O.type||"tcp",R.network==="tcp"&&O.headerType==="http"?R.network="http":R.network==="http"?R.network="h2":R.network==="httpupgrade"&&(R.network="ws",N=!0),!O.type&&E&&O.obfs&&(R.network=O.obfs,["none"].includes(R.network)&&(R.network="tcp")),["websocket"].includes(R.network)&&(R.network="ws"),R.network&&!["tcp","none"].includes(R.network)){let _={},k="",K=O.host??O.obfsParam;if(K){if(O.obfsParam)try{let ee=JSON.parse(K);_.headers=ee}catch{_.headers={Host:K}}else _.headers={Host:K};["xhttp"].includes(R.network)&&_.headers?.Host&&(_.host=_.headers.Host,delete _.headers.Host,Object.keys(_.headers).length===0&&delete _.headers);let G=_.headers?.Host??_.headers?.host;["h2"].includes(R.network)&&G&&(_.host=mS(G),delete _.headers.Host,delete _.headers.host,Object.keys(_.headers).length===0&&delete _.headers)}if(O.serviceName?(_[`${R.network}-service-name`]=O.serviceName,["grpc"].includes(R.network)&&O.authority&&(_["_grpc-authority"]=O.authority)):E&&O.path&&(["ws","http","h2"].includes(R.network)||(_[`${R.network}-service-name`]=O.path,delete O.path)),O.path){let G=O.path;if(R.network==="ws"){let ee=pS(G);G=ee.path,k=ee.ed}_.path=G}else R.network==="h2"&&(_.path="/");R.network==="http"&&O.method&&(_.method=O.method),["grpc"].includes(R.network)&&(_["_grpc-type"]=O.mode||"gun"),N&&(_["v2ray-http-upgrade"]=!0);let Z=k||O.ed;if(Z){let G=gS(Z);N?(_["v2ray-http-upgrade-fast-open"]=!0,_["_v2ray-http-upgrade-ed"]=`${Z}`):R.network==="ws"&&(_["max-early-data"]=G,_["early-data-header-name"]=O.eh||"Sec-WebSocket-Protocol")}if(O.eh&&(R.network==="ws"||N)&&(_["early-data-header-name"]=O.eh),Object.keys(_).length>0&&(R[`${R.network}-opts`]=_),R.network==="kcp"&&(O.seed&&(R.seed=O.seed),R.headerType=O.headerType||"none"),O.extra&&!["xhttp"].includes(R.network)&&(R._extra=O.extra),["xhttp"].includes(R.network)){let G={},ee;try{G=O.extra?JSON.parse(O.extra):{}}catch{te.error(`Failed to parse extra field as JSON: ${O.extra}`),ee=O.extra}let se={...R[`${R.network}-opts`]||{}};O.mode&&(se.mode=O.mode),y(se,G);let le=w(G?.downloadSettings);le&&(se["download-settings"]=le),Object.keys(se).length>0&&(R[`${R.network}-opts`]=se),ee!=null&&(R._extra=ee);let ve=g(G,{parsedDownloadSettings:le});ve&&(R._extra_unsupported=ve)}else O.mode&&(R._mode=O.mode)}return O.encryption&&(R.encryption=O.encryption),O.pqv&&(R._pqv=O.pqv),R}}}function hJ(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{let i=l7().parse(n.replace("anytls","vless"));n=n.split(/anytls:\/\//)[1];let[o,s,a,u,f="",h]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);s=decodeURIComponent(s),u=parseInt(`${u}`,10),isNaN(u)&&(u=443),s=decodeURIComponent(s),h!=null&&(h=decodeURIComponent(h)),h=h??`AnyTLS ${a}:${u}`;let m={...i,uuid:void 0,type:"anytls",name:h,server:a,port:u,password:s};for(let p of f.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 dJ(){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,f,h,m,p,d,v,g="",y]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(f)?(f=parseInt(`${f}`,10),isNaN(f)&&(f=443)):f?(i=f,f=ad(i)):f=443,s=decodeURIComponent(s),y!=null&&(y=decodeURIComponent(y)),y=y??`Hysteria2 ${a}:${f}`;let w={type:"hysteria2",name:y,server:a,port:f,ports:i,password:s},E={};for(let H of g.split("&"))if(H){let[V,S]=H.split("="),I=S;I=decodeURIComponent(S),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 C=E["hop-interval"]||E.hop_interval;C!=null&&(w["hop-interval"]=C);let D=E.keepalive;/^\d+$/.test(D)&&(w.keepalive=parseInt(`${D}`,10)),E.upmbps&&(w.up=E.upmbps),E.downmbps&&(w.down=E.downmbps);let B=Mm({echConfigList:E.ech});return B&&(w["ech-opts"]=B),w}}}function pJ(){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,f="",h]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);a=parseInt(`${a}`,10),isNaN(a)&&(a=443),h!=null&&(h=decodeURIComponent(h)),h=h??`Hysteria ${o}:${a}`;let m={type:"hysteria",name:h,server:o,port:a},p={};for(let d of f.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 gJ(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[i,o,s,a,u="",f]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);o=decodeURIComponent(o);let[h,...m]=o.split(":"),p=m.join(":");a=parseInt(`${a}`,10),isNaN(a)&&(a=443),p=decodeURIComponent(p),f!=null&&(f=decodeURIComponent(f)),f=f??`TUIC ${s}:${a}`;let d={type:"tuic",name:f,server:s,port:a,password:p,uuid:h};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 mJ(){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,f,h,m="",p]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);f=parseInt(`${f}`,10),isNaN(f)&&(f=51820),s=decodeURIComponent(s),p!=null&&(p=decodeURIComponent(p)),p=p??`WireGuard ${a}:${f}`;let d={type:"wireguard",name:p,server:a,port:f,"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(C=>parseInt(C.trim(),10)).filter(C=>Number.isInteger(C));E.length===3&&(d[y]=E)}else if(["address","ip"].includes(y))w.split(",").map(E=>{let C=oJ(E);C&&(C.family==="ipv4"?(d.ip=C.address,typeof C.cidr<"u"&&(d["ip-cidr"]=C.cidr)):C.family==="ipv6"&&(d.ipv6=C.address,typeof C.cidr<"u"&&(d["ipv6-cidr"]=C.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 vJ(){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),f=uS().parse(s);if(et(a))try{f.name=decodeURIComponent(a)}catch(h){console.log(h)}return f}}}function wJ(){return{name:"Clash Parser",test:n=>{let i;try{i=hS.default.parse(n)}catch{i=Zs.parse(n)}return!!i?.type},parse:n=>{let i;try{i=hS.default.parse(n)}catch{i=Zs.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=$n(i.cipher)),i}}}function yJ(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>Qo().parse(n)}}function EJ(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>Qo().parse(n)}}function bJ(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>Qo().parse(n)}}function AJ(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>Qo().parse(n)}}function SJ(){return{name:"QX AnyTLS Parser",test:n=>/^anytls\s*=/.test(n.split(",")[0].trim()),parse:n=>Qo().parse(n)}}function CJ(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>Qo().parse(n)}}function _J(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>Qo().parse(n)}}function DJ(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>Qo().parse(n)}}function FJ(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>oo().parse(n)}}function BJ(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>oo().parse(n)}}function IJ(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>oo().parse(n)}}function $J(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>oo().parse(n)}}function PJ(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>oo().parse(n)}}function xJ(){return{name:"Loon AnyTLS Parser",test:n=>/^.*=\s*anytls/i.test(n.split(",")[0]),parse:n=>oo().parse(n)}}function TJ(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>oo().parse(n)}}function RJ(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>oo().parse(n)}}function kJ(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>oo().parse(n)}}function OJ(){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),f=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];f&&(f=parseInt(f,10));let h=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];h&&(h=parseInt(h,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(B=>B.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],C=o.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],D={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":C,mtu:f,keepalive:h,reserved:m,"allowed-ips":g,"preshared-key":y,dns:p,udp:!0,peers:[{server:a,port:u,ip:w,ipv6:E,"public-key":C,"pre-shared-key":y,"allowed-ips":g,reserved:m}]};return Array.isArray(D.dns)&&D.dns.length>0&&(D["remote-dns-resolve"]=!0),D}}}function NJ(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>Qn().parse(n)}}function LJ(){return{name:"Surge AnyTLS Parser",test:n=>/^.*=\s*anytls/.test(n.split(",")[0]),parse:n=>Qn().parse(n)}}function UJ(){return{name:"Surge TrustTunnel Parser",test:n=>/^.*=\s*trust-tunnel/.test(n.split(",")[0]),parse:n=>Qn().parse(n)}}function HJ(){return{name:"Surge HTTP/2 CONNECT Parser",test:n=>/^.*=\s*h2-connect/.test(n.split(",")[0]),parse:n=>Qn().parse(n)}}function qJ(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>Qn().parse(n)}}function MJ(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>Qn().parse(n)}}function jJ(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>Qn().parse(n)}}function KJ(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>Qn().parse(n)}}var h7=/(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256)\s*=/i;function VJ(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0])&&!h7.test(n),parse:n=>Qn().parse(n)}}function zJ(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0])&&!h7.test(n),parse:n=>Qn().parse(n)}}function GJ(){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 f=/(,|^)\s*?local-port\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];f||(f=/(,|^)\s*?local-port\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let h=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,m,p=[];for(;(m=h.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(/\]$/,"")),JJ(w)&&g.push(w)}return{type:"external",name:s,exec:u,"local-port":f,args:p,addresses:g}}}}function WJ(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>Qn().parse(n)}}function YJ(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:o}=c7(n),s=Qn().parse(o);return s.ports=i,s}}}function XJ(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>Qn().parse(n)}}function ZJ(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:o}=c7(n),s=Qn().parse(o);return s.ports=i,s}}}function JJ(e){return Nr(e)||mr(e)}var d7=[aJ(),uJ(),cJ(),fJ(),lJ(),l7(),gJ(),mJ(),pJ(),dJ(),vJ(),hJ(),wJ(),NJ(),LJ(),UJ(),HJ(),qJ(),MJ(),jJ(),KJ(),VJ(),WJ(),YJ(),XJ(),ZJ(),zJ(),GJ(),FJ(),BJ(),IJ(),$J(),TJ(),PJ(),xJ(),RJ(),kJ(),OJ(),yJ(),EJ(),bJ(),AJ(),SJ(),CJ(),_J(),DJ()];var Bve=P(x());var vS="https://api.github.com";function p7(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 QJ(e,t=vS){return(String(e??"").trim()||t).replace(/\/+$/,"")}function eQ({githubApiUrl:e,githubProxy:t}={}){let r=QJ(e),n=r!==vS,i=String(t||"").trim().replace(/\/+$/,"");return n?r:`${i?`${i}/`:""}${vS}`}function g7(e={}){return!!e?.gistToken}var Uf=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=bo(),{defaultProxy,githubApiTimeout,githubProxy,githubApiUrl}=te.read(ar),githubApiRequestTimeout=githubApiTimeout||1e4,githubGistBaseURL=eQ({githubApiUrl,githubProxy}),proxy=defaultProxy;te.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=Da({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?$a(proxy):{},timeout:githubApiRequestTimeout,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(p7(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=Da({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?$a(proxy):{},timeout:githubApiRequestTimeout,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(p7(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);te.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=f=>f.then(h=>(Object.keys(s).length>0&&(h.subStoreUploadMeta=s),h)),u=({actions:f,existingFiles:h,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"?f.push({action:h[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"?f.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 f=[],h={...r.files};return Object.keys(n).map(m=>{h[m]?n[m].content==null||n[m].content===""?(delete h[m],n[m]=null,f.push({action:"delete",file_path:m})):(h[m]=n[m],f.push({action:"update",file_path:m,content:n[m].content})):n[m].content==null||n[m].content===""?(delete h[m],delete n[m]):(h[m]=n[m],f.push({action:"create",file_path:m,content:n[m].content}))}),u({actions:f,existingFiles:r.files,result:h}),this.syncPlatform==="gitlab"?Object.keys(h).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(h).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=f,a(this.http.put({headers:{...this.headers,"Content-Type":"application/json"},url:`/snippets/${r.id}`,body:JSON.stringify({files:n})}))):Object.keys(h).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((f,[h,m])=>(m.content!==null&&m.content!==""&&(f[h]=m),f),{}),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(f=>({file_path:f,content:n[f].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 E7=P(lS());var tQ={encrypt:_m,decrypt:Dm,derivePublicKey:kB};function rQ(e){for(let t of rg)try{if(t.test(e))return te.info(`Pre-processor [${t.name}] activated`),t.parse(e)}catch(r){te.error(`Parser [${t.name}] failed Reason: ${r}`)}return e}function nQ(e){e=rQ(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]=v7(n,i);a||(r.push(y7(s)),o=!0)}if(!o)for(let s of d7){let[a,u]=v7(s,i);if(!u){r.push(y7(a)),n=s,o=!0,te.info(`${s.name} is activated`);break}}o||te.error(`Failed to parse line: ${i}`)}return r.filter(i=>{if(["vless","vmess"].includes(i.type))g1(i.uuid)||te.warn(`UUID may be invalid: ${i.name} ${i.uuid}`);else if(["hysteria2"].includes(i.type)&&i.obfs&&!i["obfs-password"])return te.error(`Proxy ${i.name} has obfs ${i.obfs} but missing obfs-password`),!1;return!0})}function b7(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 sQ(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(hA(a.type)){te.log(`Skipping response transformer during proxy/file processing: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}if(b7(a,s)){te.info(`Skipping context-controlled operator: "${a.type}" with customName "${a.customName||""}"`);continue}if(a.disabled){te.log(`Skipping disabled operator: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}let u,f={};if(a.type.indexOf("Script")!==-1&&({script:u,$arguments:f}=await A7(a)),!Dp[a.type]){te.error(`Unknown operator: "${a.type}"`);continue}te.log(`Applying "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);let h;a.type.indexOf("Script")!==-1?h=Dp[a.type](u,r,f,n,i,s):h=Dp[a.type](a.args||{}),e=await fI(h,e)}return e}async function iQ(e,t=[],r,n,i){let o={},s=m7(e);for(let a of t){if(!hA(a.type))continue;if(b7(a,o)){te.info(`Skipping context-controlled response transformer: "${a.type}" with customName "${a.customName||""}"`);continue}if(a.disabled){te.log(`Skipping disabled response transformer: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}let{script:u,$arguments:f}=await A7(a);te.log(`Applying "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);let h=Dp[a.type](u,r,f,n,i,o);s=m7(await cI(h,s))}return s}async function A7(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"?Q0:$u,n=Kr(te.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);e==="module"?script=n.content:script=await ti({type:"file",name:t})}catch(t){throw te.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 te.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 _i(url)}catch(e){throw te.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 m7(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 oQ(e,t,r,n={}){let i=QI[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&&aQ(s)&&uQ(s)&&!cQ(s,t))return te.error(`Target platform ${t} does not support headers for ${fQ(s)} proxy ${s.name||`${s.server}:${s.port}`}. Proxy has been filtered.`),!1;if(!a&&hh(s)&&!["qx","quantumultx","shadowrocket"].includes(o))return!1;if(["vless","vmess"].includes(s.type)){g1(s.uuid)||te.warn(`UUID may be invalid: ${s.name} ${s.uuid}`);let f=s.type==="vless",h=f?[["reality-opts",s["reality-opts"]],["xhttp download-settings reality-opts",s["xhttp-opts"]?.["download-settings"]?.["reality-opts"]]]:[];for(let[p,d]of h)if(d&&!et(d["public-key"])){if(p==="xhttp download-settings reality-opts"&&et(s["reality-opts"]?.["public-key"])&&d["public-key"]==="")continue;return te.error(`Skipping VLESS Reality proxy ${s.name}: empty ${p}.public-key`),!1}let m=s["xhttp-opts"];if(f&&s.network==="xhttp"&&m?.mode==="stream-one"&&m["download-settings"])return te.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)&&(te.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=l2(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=ad(s.ports))),s.type==="wireguard"&&mA(s),s)),te.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 te.error(`Cannot produce proxy: ${a.name} Reason: ${u}`),""}}).filter(a=>a.length>0);return n._merged&&n.localPort>=1&&s.push($p().produce({name:n._merged.name,type:"external",udp:!0,exec:n._merged.exec,"local-port":n.localPort,args:["-config",Bt.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 aQ(e){return e?.headers&&typeof e.headers=="object"&&Object.keys(e.headers).length>0}function uQ(e){return["http","h2-connect","trusttunnel"].includes(e?.type)}function cQ(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 fQ(e){return e.type==="http"?e.tls?"HTTPS":"HTTP":e.type==="h2-connect"?"HTTP/2 CONNECT":e.type==="trusttunnel"?"TrustTunnel":e.type}var tr={parse:nQ,process:sQ,processResponse:iQ,produce:oQ,age:tQ,ipAddress:p1,getRandomPort:ad,isIPv4:Nr,isIPv6:mr,isIP:l2,yaml:Zs,getFlag:oh,removeFlag:bp,getISO:OB,MMDB:Bm,Gist:Uf,download:_i,downloadFile:S7,isValidUUID:g1,doh:oA,Buffer:f2.Buffer,Base64:Bt,JSON5:E7.default,hex_md5:Yr};function v7(e,t){if(!lQ(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function lQ(e,t){try{return e.test(t)}catch{return!1}}function w7(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function y7(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=V8(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),f=parseInt(a[2],10);u>0&&u<=f?(e["hop-interval"]=u,e["hop-interval-max"]=f):(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),K8(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=>w7(s)):i!=null&&(e[`${e.network}-opts`].path=w7(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&&!l2(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&&!l2(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=f2.Buffer.from(e.name.data).toString("utf8"):e.name=f2.Buffer.from(e.name).toString("utf8")}catch(s){te.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{te.env.isNode&&!o&&e._ca&&(o=te.node.fs.readFileSync(e._ca,{encoding:"utf8"}))}catch(s){te.error(`Read ca file failed Reason: ${s}`)}return!e["tls-fingerprint"]&&o&&(e["tls-fingerprint"]=N_.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)),mA(e)),e}function l2(e){return Nr(e)||mr(e)}var C7=rg.find(e=>e.name==="Clash Pre-processor"),wS=new Map;function hQ(e=""){let t=`${e}`.trim();return t?new RegExp(t,"i"):null}function dQ(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=hQ(r)}catch(o){return te.error(`GitHub \u52A0\u901F\u4EE3\u7406\u5339\u914D\u6B63\u5219\u65E0\u6548: ${o.message??o}`),e}return i?.test(e)?(te.info(`GitHub \u52A0\u901F\u4EE3\u7406\u547D\u4E2D\u4E0B\u8F7D\u94FE\u63A5: ${e}`),`${t}/${e}`):e}function pQ(e){return cc(e)}async function bh(e,{ageSecretKey:t,preprocess:r,url:n}){let i=t?await Dm(e,t):e,o=i;if(r)try{C7.test(i)&&(i=C7.parse(i,!0))}catch(s){te.error(`Clash Pre-processor error: ${s}`)}if(r)try{let s=tr.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 Vp(e,t){return t?{result:e.result,raw:e.raw}:e.result}function yS(e,t){return t?{result:e,raw:e}:e}async function _i(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?.[Mb]||options?.ageSecretKey:void 0,returnRaw=options&&typeof options=="object"&&options.returnRaw,ageSecretKey=explicitAgeSecretKey||$arguments?.[Mb],{isNode,isStash,isLoon,isShadowRocket,isQX}=bo(),{githubProxy,githubProxyRegex,defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=te.read(ar),cacheThreshold=defaultCacheThreshold||1024,proxy=customProxy||defaultProxy;te.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){te.error(`\u89E3\u6790\u81EA\u5B9A\u4E49 headers \u5931\u8D25: ${e}`)}let requestTimeout=timeout||defaultTimeout||8e3;url=dQ(url,githubProxy,githubProxyRegex);let safeUrl=pQ(url),id=Yr(`${customHeaders?JSON.stringify(customHeaders):userAgent}${url}`);$arguments?.cacheKey===!0&&(te.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=te.read(customCacheKey),t=Xr.get(id);if(!noCache&&!$arguments?.noCache&&t)return te.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`),Vp(await bh(t,{ageSecretKey,preprocess,url:safeUrl}),returnRaw);if(e){if(awaitCustomCache){te.info(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u672C\u6B21\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u66F4\u65B0\u7F13\u5B58`);try{await _i(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess)}catch(r){te.error(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`),te.info("\u4F7F\u7528\u4E50\u89C2\u7F13\u5B58\u7684\u6570\u636E\u5237\u65B0\u7F13\u5B58, \u9632\u6B62\u540E\u7EED\u8BF7\u6C42"),Xr.set(id,e)}}else te.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`),_i(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess).catch(r=>{te.error(`\u4E50\u89C2\u7F13\u5B58: URL ${safeUrl} \u5F02\u6B65\u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`)});return Vp(await bh(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"?Q0:$u,n=Kr(te.read(r),t);if(!n)throw new Error(`\u627E\u4E0D\u5230 ${e}: ${t}`);return yS(e==="module"?n.content:await ti({type:"file",name:t}),returnRaw)}catch(t){throw te.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 yS(fs.readFileSync(url.split("#")[0],"utf8"),returnRaw)}catch(e){throw te.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&&wS.has(id))return Vp(await bh(await wS.get(id),{ageSecretKey,preprocess,url:safeUrl}),returnRaw);let http=Da({headers:{...customHeaders||{"User-Agent":userAgent},...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,rawResult,cached=Xr.get(id);if(!noCache&&!$arguments?.noCache&&cached)te.info(`\u4F7F\u7528\u7F13\u5B58: ${safeUrl}, ${customHeaders?JSON.stringify(customHeaders):userAgent}`),rawResult=cached,result=await bh(cached,{ageSecretKey,preprocess,url:safeUrl}),customCacheKey&&(te.info(`URL ${safeUrl} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),te.write(cached,customCacheKey));else{let e=$arguments?.insecure?isNode?{strictSSL:!1}:{insecure:!0}:void 0;te.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 dl(()=>http.get({url,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?$a(proxy):{},...e||{}}),"download");if(te.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let o=Xc(r);o&&ud.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 bh(t,{ageSecretKey,preprocess,url:safeUrl});let i=!0;if(cacheThreshold){let o=t.length/1024;o>cacheThreshold&&(te.info(`\u8D44\u6E90\u5927\u5C0F ${o.toFixed(2)} KB \u8D85\u8FC7\u4E86 ${cacheThreshold} KB, \u4E0D\u7F13\u5B58`),i=!1)}result.shouldCache||(te.error(result.cacheReason),i=!1),i&&(Xr.set(id,t,$arguments?.cacheTtl?$arguments?.cacheTtl*1e3:void 0),customCacheKey&&(te.info(`URL ${safeUrl} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),te.write(t,customCacheKey))),rawResult=t}catch(t){if(customCacheKey){let n=te.read(customCacheKey);if(n)return te.info(`\u65E0\u6CD5\u4E0B\u8F7D URL ${safeUrl}: ${t.message??t} \u4F7F\u7528\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),Vp(await bh(n,{ageSecretKey,preprocess,url:safeUrl}),returnRaw)}let r=`\u65E0\u6CD5\u4E0B\u8F7D URL ${safeUrl}: ${t.message??t}`;throw te.error(r),new Error(r)}}return $arguments?.validCheck&&await w1(pl(await v1(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl,$arguments.flowHeaders))),isNode||wS.set(id,rawResult),Vp(result,returnRaw)}async function S7(url,file){let undici=eval("require('undici')"),fs=eval("require('fs')"),{pipeline}=eval("require('stream/promises')"),{Agent,interceptors,request}=undici;te.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),te.info(`File downloaded from ${url} to ${file}`),file}var _we=P(x());var pwe=P(x());function gQ(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function mQ(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var _7=[gQ(),mQ()];var vwe=P(x());function vQ(){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 D7(){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 wQ(){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))),D7().func(r))}}function yQ(){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 Zs.dump(i)}}}var F7={QX:vQ(),Surge:D7(),Loon:wQ(),Clash:yQ()};var ywe=P(x()),EQ=[[/^(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 bQ(){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(h=>h.trim()),u=a[0],f=!1;for(let h of EQ)if(h[0].test(u)){f=!0;let p={type:h[1],content:a[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(p.type)&&(p.options=a.slice(2)),o.push(p)}if(!f)throw new Error("Invalid rule type: "+u)}catch(a){console.log(`Failed to parse line: ${s} Reason: ${a}`)}return o}}}var B7=[bQ()];var h2=function(){function e(n){for(let i of _7)try{if(i.test(n))return te.info(`Pre-processor [${i.name}] activated`),i.parse(n)}catch(o){te.error(`Parser [${i.name}] failed Reason: ${o}`)}return n}function t(n){n=e(n);for(let i of B7){let o;try{o=i.test(n)}catch{o=!1}if(o)return te.info(`Rule parser [${i.name}] is activated!`),i.parse(n)}}function r(n,i){let o=F7[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 eye=P(x());var Iwe=P(x());var Nwe=P(x());var DQ=".sub-store-placeholder",FQ=["Sub-Store placeholder","This file keeps the Gist alive when all sync configuration files are deleted."].join(` `),BQ=10;function $7(e){let t=Math.floor(Number(e));return!isFinite(t)||t<=0?BQ:t}function IQ(){return{filename:DQ,content:FQ}}async function P7(e,t={}){let{gistToken:r,syncPlatform:n}=te.read(ar);if(!r)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=$Q(e);te.info(`\u51C6\u5907\u540C\u6B65 Gist: \u6587\u4EF6\u6570 ${i.count}, \u603B\u5927\u5C0F ${d2(i.totalBytes)}, \u6700\u5927\u6587\u4EF6 ${i.largestFilename||"-"} (${d2(i.largestBytes)})`);let o=new Uf({token:r,key:z4,syncPlatform:n}),s;try{s=await o.upload(e,{...t,emptyFileFallback:t.emptyFileFallback??IQ()})}catch(h){throw te.error(`\u540C\u6B65 Gist \u8BF7\u6C42\u5931\u8D25: \u6587\u4EF6\u6570 ${i.count}, \u603B\u5927\u5C0F ${d2(i.totalBytes)}, \u6700\u5927\u6587\u4EF6 ${i.largestFilename||"-"} (${d2(i.largestBytes)}), \u539F\u56E0: ${h.message??h}`),h}let a={};try{a=JSON.parse(s.body)}catch{}let u=a?.html_url??a?.web_url,f=te.read(ar);return u?(te.log(`\u540C\u6B65 Gist \u540E, \u627E\u5230 Sub-Store Gist: ${u}`),f.artifactStore=u,f.artifactStoreStatus="VALID"):(te.error("\u540C\u6B65 Gist \u540E, \u627E\u4E0D\u5230 Sub-Store Gist"),f.artifactStoreStatus="NOT FOUND"),te.write(f,ar),s}function $Q(e){return Object.entries(e||{}).reduce((t,[r,n])=>{let i=n?.content;if(typeof i!="string")return t;let o=PQ(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 PQ(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}function d2(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var nye=P(x());var xQ=new Set(["enabled","fallbackNotify"]),TQ=new Set(["fallbackNotify","fallbackQuiet"]);function p2(e){return e===!0?"quiet":e===!1||e==null||e===""?"disabled":e}function g2(...e){for(let t of e)if(t!=null&&t!=="")return p2(t);return"disabled"}function m2(e){return xQ.has(p2(e))}function Ah(e){return TQ.has(p2(e))}function zp({mode:e,message:t,notify:r}){let n=p2(e);if(n==="disabled"||Ah(n))throw new Error(t);m2(n)&&r?.(t)}function v2({mode:e,notify:t,error:r}){m2(e)&&t?.(r)}function ES({platform:e="JSON",produceType:t,produceOpts:r={}}){return t==="raw"?JSON.stringify([]):tr.produce([],e,t,r)}var oye=P(x());function RQ(e){return String(e??"").trim()}function kQ(...e){for(let t of e){let r=RQ(t?.[xB]);if(r)return r}return""}async function x7({body:e,res:t,configs:r=[]}){let n=kQ(...r);if(!n)return e;let i=await _m(e??"",n);return t?.set&&t.set("Content-Type","text/plain; charset=utf-8"),i}var OQ=["localFirst","remoteFirst"],NQ=["local","remote"],LQ=["collection","local","none","remote","subscription"];function Gp(e){return Object.keys(e).map(cc).join(", ")}function T7(e){return OQ.includes(e)}function UQ(e){return $f(e)?k7(e):e?.source}function k7(e){return LQ.includes(e?.sourceType)?e.sourceType:"collection"}function w2(e){return(Array.isArray(e)?e:[e]).flat()}function O7(e){return w2(e).filter(t=>t!=null&&t!=="").join(` `)}function HQ(e,t){return t!=null&&t!==""?t:e.ignoreFailedRemoteFile}async function R7({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 f=await Promise.all(u.map(async m=>{try{return await _i(m,r||e.ua,void 0,e.proxy||n,void 0,void 0,i)}catch(p){return a[m]=p,te.error(`\u6587\u4EF6 ${e.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${cc(m)} \u53D1\u751F\u9519\u8BEF: ${p}`),""}})),h=HQ(e,o);if(Object.keys(a).length>0)if(h)h==="enabled"&&te.notify(s,`\u274C ${e.name}`,`\u8FDC\u7A0B\u6587\u4EF6 ${Gp(a)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);else throw new Error(`\u6587\u4EF6 ${e.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Gp(a)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);return f}async function N7(e,{url:t,ua:r,content:n,mergeSources:i,ignoreFailedRemoteFile:o,proxy:s,noCache:a,notifyTitle:u}={}){if(n&&!T7(i))return n;if(t){let h=await R7({file:e,sourceUrl:t,ua:r,proxy:s,noCache:a,ignoreFailedRemoteFile:o,notifyTitle:u});return i==="localFirst"?h.unshift(n):i==="remoteFirst"&&h.push(n),h}if(UQ(e)==="local"&&!T7(e.mergeSources))return e.content;let f=await R7({file:e,sourceUrl:e.url,ua:r,proxy:s,noCache:a,ignoreFailedRemoteFile:o,notifyTitle:u});return e.mergeSources==="localFirst"?f.unshift(e.content):e.mergeSources==="remoteFirst"&&f.push(e.content),f}async function qQ(e,t={}){let r={},n=k7(e);if(n==="none")return tr.yaml.safeDump(r);if(NQ.includes(n)){let i=await N7(e,t);if(e?.mode!=="proxy")return O7(i);let o=w2(i).map(s=>tr.parse(s)).flat();if(o.length===0)throw new Error(`\u6587\u4EF6 ${e.name} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);r.proxies=tr.produce(o,"mihomo","internal",{"delete-underscore-fields":!0,"include-unsupported-proxy":e?.includeUnsupportedProxy})}else r.proxies=await ti({type:n,name:e?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0,"include-unsupported-proxy":e?.includeUnsupportedProxy}});return tr.yaml.safeDump(r)}async function ti({type:e,name:t,platform:r,url:n,ua:i,content:o,mergeSources:s,ignoreFailedRemoteSub:a,ignoreFailedRemoteFile:u,produceType:f,produceOpts:h={},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 D=te.read(Kc);if(E=Kr(D,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 C=g2(a,E.ignoreFailedRemoteSub);try{let D,B;if(o&&!["localFirst","remoteFirst"].includes(s))D=o,B=o;else if(n){let S={},I=await Promise.all(n.split(/[\r\n]+/).map(U=>U.trim()).filter(U=>U.length).map(async U=>{try{return await _i(U,i||E.ua,void 0,g||E.proxy,void 0,d,y||E.noCache,!0,{returnRaw:!0})}catch(R){return S[U]=R,te.error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${cc(U)} \u53D1\u751F\u9519\u8BEF: ${R}`),""}}));if(D=I.map(U=>U.result??U),B=I.map(U=>U.raw??U),Object.keys(S).length>0){let U=`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Gp(S)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;zp({mode:C,message:U,notify:()=>{te.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,U)}})}s==="localFirst"?(D.unshift(o),B.unshift(o)):s==="remoteFirst"&&(D.push(o),B.push(o))}else if(E.source==="local"&&!["localFirst","remoteFirst"].includes(E.mergeSources))D=E.content,B=E.content;else{let S={},I=await Promise.all(E.url.split(/[\r\n]+/).map(U=>U.trim()).filter(U=>U.length).map(async U=>{try{return await _i(U,i||E.ua,void 0,g||E.proxy,void 0,d,y||E.noCache,!0,{returnRaw:!0})}catch(R){return S[U]=R,te.error(`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${cc(U)} \u53D1\u751F\u9519\u8BEF: ${R}`),""}}));if(D=I.map(U=>U.result??U),B=I.map(U=>U.raw??U),Object.keys(S).length>0){let U=`\u8BA2\u9605 ${E.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Gp(S)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;zp({mode:C,message:U,notify:()=>{te.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,U)}})}E.mergeSources==="localFirst"?(D.unshift(E.content),B.unshift(E.content)):E.mergeSources==="remoteFirst"&&(D.push(E.content),B.push(E.content))}if(f==="raw")return JSON.stringify((Array.isArray(D)?D:[D]).flat());let H=(Array.isArray(D)?D:[D]).map(S=>tr.parse(S)).flat();if(H.forEach(S=>{S._subName=E.name,S._subDisplayName=E.displayName}),H=await tr.process(H,E.process||[],r,{[E.name]:E},v,B),H.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let V={};for(let S of H){if(V[S.name]){te.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${S.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[S.name]=!0}return tr.produce(H,r,f,h)}catch(D){if(!Ah(C))throw D;return v2({mode:C,error:D,notify:B=>{te.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${E.name}`,`\u{1F914} \u539F\u56E0\uFF1A${B.message??B}`)}}),te.error(`\u8BA2\u9605 ${E.name} \u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${D.message??D}`),ES({platform:r,produceType:f,produceOpts:h})}}else if(["collection","col"].includes(e)){let E=te.read(Kc),C=te.read(ol),D=Kr(C,t);if(!D)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let B=[...D.subscriptions],H=D.subscriptionTags;Array.isArray(H)&&H.length>0&&E.forEach(S=>{Array.isArray(S.tag)&&S.tag.length>0&&!B.includes(S.name)&&S.tag.some(I=>H.includes(I))&&B.push(S.name)});let V=g2(a,D.ignoreFailedRemoteSub);try{let S={},I={},U={},R=0;if(await Promise.all(B.map(async N=>{let _=Kr(E,N),k=g2(_.ignoreFailedRemoteSub),K=_.passThroughUA,Z=_.ua;K&&(te.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${i}`),Z=i);try{te.info(`\u6B63\u5728\u5904\u7406\u5B50\u8BA2\u9605\uFF1A${_.name}...`);let G,ee;if(_.source==="local"&&!["localFirst","remoteFirst"].includes(_.mergeSources))G=_.content,ee=_.content;else{let ve={},we=await Promise.all(_.url.split(/[\r\n]+/).map(Pe=>Pe.trim()).filter(Pe=>Pe.length).map(async Pe=>{try{return await _i(Pe,Z,void 0,g||_.proxy||D.proxy,void 0,void 0,y||_.noCache,!0,{returnRaw:!0})}catch(Le){return ve[Pe]=Le,te.error(`\u8BA2\u9605 ${_.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${cc(Pe)} \u53D1\u751F\u9519\u8BEF: ${Le}`),""}}));if(G=we.map(Pe=>Pe.result??Pe),ee=we.map(Pe=>Pe.raw??Pe),Object.keys(ve).length>0){let Pe=`\u8BA2\u9605 ${_.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Gp(ve)} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`;zp({mode:k,message:Pe,notify:()=>{te.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${_.name}`,Pe)}})}_.mergeSources==="localFirst"?(G.unshift(_.content),ee.unshift(_.content)):_.mergeSources==="remoteFirst"&&(G.push(_.content),ee.push(_.content))}let se=(Array.isArray(G)?G:[G]).map(ve=>tr.parse(ve)).flat();se.forEach(ve=>{ve._subName=_.name,ve._subDisplayName=_.displayName,ve._collectionName=D.name,ve._collectionDisplayName=D.displayName});let le=Array.isArray(ee)?ee:[ee];se=await tr.process(se,_.process||[],r,{[_.name]:_,_collection:D,$options:v},void 0,le),S[N]=se,U[N]=le,R++,te.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${_.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(R/B.length).toFixed(1)}% `)}catch(G){if(R++,Ah(k)){v2({mode:k,error:G,notify:ee=>{te.notify("\u{1F30D} Sub-Store \u5904\u7406\u8BA2\u9605\u5931\u8D25",`\u274C ${_.name}`,`\u{1F914} \u539F\u56E0\uFF1A${ee.message??ee}`)}}),te.error(`\u8BA2\u9605 ${_.name} \u5728\u7EC4\u5408\u8BA2\u9605\u5904\u7406\u4E2D\u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${G.message??G}`),S[N]=[],U[N]=[];return}I[N]=G,U[N]=void 0,te.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u4E2D\u7684\u5B50\u8BA2\u9605: ${_.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${G}\uFF01\u8FDB\u5EA6--${100*(R/B.length).toFixed(1)}%`)}})),Object.keys(I).length>0){let N=`\u7EC4\u5408\u8BA2\u9605 ${D.name} \u7684\u5B50\u8BA2\u9605 ${Object.keys(I).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`,_=()=>{te.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${D.name}`,N)};Object.keys(S).length>0&&Ah(V)?(Object.keys(I).forEach(K=>{U[K]=[]}),m2(V)&&_()):zp({mode:V,message:N,notify:_})}let O=Array.prototype.concat.apply([],B.map(N=>S[N]||[]));if(O.forEach(N=>{N._collectionName=D.name,N._collectionDisplayName=D.displayName}),O=await tr.process(O,D.process||[],r,{_collection:D},v,U),O.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let q={};for(let N of O){if(q[N.name]){te.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}q[N.name]=!0}return tr.produce(O,r,f,h)}catch(S){if(!Ah(V))throw S;return v2({mode:V,error:S,notify:I=>{te.notify("\u{1F30D} Sub-Store \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u5931\u8D25",`\u274C ${D.name}`,`\u{1F914} \u539F\u56E0\uFF1A${I.message??I}`)}}),te.error(`\u7EC4\u5408\u8BA2\u9605 ${D.name} \u542F\u7528\u515C\u5E95\u540E\u8FD4\u56DE\u7A7A\u7ED3\u679C: ${S.message??S}`),ES({platform:r,produceType:f,produceOpts:h})}}else if(e==="rule"){let E=te.read(V4),C=Kr(E,t);if(!C)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let D=[];for(let B=0;B0?await tr.process({$files:B,$content:H,$options:v,$file:C},C.process):{$content:H,$files:B,$options:v};return V.$content=$d(V?.$content??""),(w?V:V?.$content)??""}}function MQ(e,t){let r=[];for(let n=0;n[t.path,t]))}:{isGitLab:!1,files:e||{}}}function KQ(e){delete e.history,delete e.forks,delete e.owner,e.files&&Object.values(e.files).forEach(t=>{delete t.content}),te.info("\u4E0A\u4F20\u914D\u7F6E\u54CD\u5E94:"),te.info(JSON.stringify(e,null,2))}function VQ(e,t){let{files:r,isGitLab:n}=jQ(e.files),i=encodeURIComponent(t),o=r[i]?.raw_url,s=n?o:o?.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1");return te.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 bS(e){return e?.upload!==!1}function zQ(e){return e?.source?["subscription","sub"].includes(e.type)?Kr(te.read(Kc),e.source):["collection","col"].includes(e.type)?Kr(te.read(ol),e.source):e.type==="file"?Kr(te.read($u),e.source):null:null}async function L7(e){let t=e.platform==="SurgeMac",r=await ti({type:e.type,name:e.source,platform:e.platform,produceOpts:{"include-unsupported-proxy":e.includeUnsupportedProxy,useMihomoExternal:t,prettyYaml:e.prettyYaml}});return x7({body:r,configs:[e,zQ(e)]})}function U7(e){e.updated=new Date().getTime(),delete e.url}async function H7({allArtifacts:e,files:t,valid:r,invalid:n}){let i=te.read(ar)||{},o=$7(i.artifactSyncBatchSize),s=r.filter(f=>{let h=Kr(e,f);return h&&bS(h)}),a=MQ(s,o),u=[];if(s.length===0)return te.info("\u6CA1\u6709\u9700\u8981\u4E0A\u4F20\u7684\u540C\u6B65\u914D\u7F6E"),u;te.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 f=0;f[encodeURIComponent(p),t[encodeURIComponent(p)]]));try{te.info(`\u6B63\u5728\u4E0A\u4F20\u7B2C ${f+1}/${a.length} \u6279\u540C\u6B65\u914D\u7F6E: ${h.join(", ")}`);let p=await P7(m),d=JSON.parse(p.body);KQ(d);for(let v of e)if(v.sync&&v.source&&h.includes(v.name)){let g=VQ(d,v.name);g?(v.updated=new Date().getTime(),v.url=g,u.push(v.name)):(te.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){te.error(`\u7B2C ${f+1}/${a.length} \u6279\u540C\u6B65\u914D\u7F6E\u4E0A\u4F20\u5931\u8D25: ${h.join(", ")}, \u539F\u56E0: ${p.message??p}`),n.push(...h)}}return u}var Dye=P(x());function AS(e){return e?.upload!==!1}function q7({artifacts:e=[],settings:t={}}={}){let r=g7(t),n=e.some(s=>s.sync),i=e.some(s=>s.sync&&AS(s)),o=e.some(s=>s.sync&&!AS(s));return{canUpload:r||!i,shouldRun:n&&(r||o)}}function SS(e,{canUpload:t}){return!t&&AS(e)}(async function(){let e;typeof $argument<"u"?e=GQ($argument):e={};let t=(e?.subscription??e?.sub??"").split(/,|,/g).map(n=>n.trim()).filter(n=>n.length>0).map(n=>decodeURIComponent(n)),r=(e?.collection??e?.col??"").split(/,|,/g).map(n=>n.trim()).filter(n=>n.length>0).map(n=>decodeURIComponent(n));if(t.length>0||r.length>0)t.length>0&&await M7(t,"subscription"),r.length>0&&await M7(r,"collection");else{let n=te.read(ar),i=te.read(Ca);if(!i||i.length===0)return;let o=q7({artifacts:i,settings:n});o.shouldRun&&await YQ(e,o)}})().finally(()=>te.done());function GQ(e){return e==null?{}:typeof e=="object"?e:Object.fromEntries(`${e}`.split("&").filter(Boolean).map(t=>{let[r,...n]=t.split("=");return[r,n.join("=")]}))}function WQ(e,t=!0){if(e==null||e==="")return t;let r=`${e}`.trim().replace(/^["']|["']$/g,"").toLowerCase();return!["false","0","no","off"].includes(r)}async function M7(e,t){try{e.length>0&&(te.info(`produceArtifacts ${t} \u5F00\u59CB: ${e.join(", ")}`),await Promise.all(e.map(async r=>{try{await ti({type:t,name:r})}catch(n){te.error(`${t} ${r} error: ${n.message??n}`)}})),te.info(`produceArtifacts ${t} \u5B8C\u6210: ${e.join(", ")}`))}catch(r){te.error(`produceArtifacts error: ${r.message??r}`)}}async function YQ(e={},{canUpload:t=!0}={}){let r=WQ(e.sync_success_notify);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 Sync -- v${J0} \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 `),te.info("\u5F00\u59CB\u540C\u6B65\u6240\u6709\u8FDC\u7A0B\u914D\u7F6E...");let n=te.read(Ca),i={};try{let o=[],s=[],a=[],u=[],f=te.read(Kc),h=te.read(ol),m=[],p=0;if(n.map(g=>{if(g.sync&&g.source){if(p++,SS(g,{canUpload:t}))return;if(g.type==="subscription"){let y=g.source,w=Kr(f,y);w&&w.url&&!m.includes(y)&&m.push(y)}else if(g.type==="collection"){let y=Kr(h,g.source);y&&Array.isArray(y.subscriptions)&&y.subscriptions.map(w=>{let E=Kr(f,w);E&&E.url&&!m.includes(w)&&m.push(w)})}}}),p===0){te.info(`\u9700\u540C\u6B65\u7684\u914D\u7F6E: ${p}, \u603B\u6570: ${n.length}`);return}m.length>0&&await Promise.all(m.map(async g=>{try{await ti({type:"subscription",name:g,awaitCustomCache:!0})}catch{}})),await Promise.all(n.map(async g=>{try{if(g.sync&&g.source){if(SS(g,{canUpload:t})){u.push(g.name);return}te.info(`\u6B63\u5728\u540C\u6B65\u4E91\u914D\u7F6E\uFF1A${g.name}...`),g.platform==="SurgeMac"&&te.info("\u624B\u52A8\u6307\u5B9A\u4E86 target \u4E3A SurgeMac, \u5C06\u4F7F\u7528 mihomo External");let w=await L7(g);bS(g)?(i[encodeURIComponent(g.name)]={content:w},o.push(g.name)):(U7(g),a.push(g.name))}}catch(y){te.error(`\u751F\u6210\u540C\u6B65\u914D\u7F6E ${g.name} \u53D1\u751F\u9519\u8BEF: ${y.message??y}`),s.push(g.name)}}));let d=o.length+a.length;if(te.info(`${d} \u4E2A\u540C\u6B65\u914D\u7F6E\u751F\u6210\u6210\u529F: ${o.concat(a).join(", ")}`),te.info(`${s.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u751F\u6210\u5931\u8D25: ${s.join(", ")}`),a.length>0&&te.info(`${a.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u4EC5\u751F\u6210\u672A\u4E0A\u4F20: ${a.join(", ")}`),u.length>0&&te.info(`${u.length} \u4E2A\u540C\u6B65\u914D\u7F6E\u56E0\u672A\u8BBE\u7F6E GitHub Token \u5DF2\u8DF3\u8FC7\u4E0A\u4F20: ${u.join(", ")}`),d===0)throw new Error(`\u540C\u6B65\u914D\u7F6E ${s.join(", ")} \u751F\u6210\u5931\u8D25 \u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7`);let v=await H7({allArtifacts:n,files:i,valid:o,invalid:s});te.write(n,Ca),te.info("\u540C\u6B65\u914D\u7F6E\u6267\u884C\u5B8C\u6210"),s.length>0?te.notify("\u{1F30D} Sub-Store",`\u540C\u6B65\u914D\u7F6E\u6210\u529F ${v.length+a.length} \u4E2A, \u5931\u8D25 ${s.length} \u4E2A${u.length?`, \u8DF3\u8FC7 ${u.length} \u4E2A\u9700\u4E0A\u4F20\u914D\u7F6E`:""}, \u8BE6\u60C5\u8BF7\u67E5\u770B\u65E5\u5FD7`):r&&te.notify("\u{1F30D} Sub-Store","\u540C\u6B65\u914D\u7F6E\u5B8C\u6210",u.length?`\u5DF2\u8DF3\u8FC7 ${u.length} \u4E2A\u9700\u4E0A\u4F20\u914D\u7F6E\uFF08\u672A\u8BBE\u7F6E GitHub Token\uFF09`:void 0)}catch(o){te.notify("\u{1F30D} Sub-Store","\u540C\u6B65\u914D\u7F6E\u5931\u8D25",`\u539F\u56E0\uFF1A${o.message??o}`),te.error(`\u65E0\u6CD5\u540C\u6B65\u914D\u7F6E\u5230 Gist\uFF0C\u539F\u56E0\uFF1A${o.stack??o.message??o}`)}}})(); /*! 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) *) */