@gaiot/apis
Version:
aiot apis
2 lines • 1.23 MB
JavaScript
"use strict";var Nh=Object.defineProperty,Rh=Object.defineProperties;var Ph=Object.getOwnPropertyDescriptors;var So=Object.getOwnPropertySymbols;var Vu=Object.prototype.hasOwnProperty,Ku=Object.prototype.propertyIsEnumerable;var La=(de,B)=>{if(B=Symbol[de])return B;throw Error("Symbol."+de+" is not defined")},Yi=Math.pow,zu=(de,B,X)=>B in de?Nh(de,B,{enumerable:!0,configurable:!0,writable:!0,value:X}):de[B]=X,Wn=(de,B)=>{for(var X in B||(B={}))Vu.call(B,X)&&zu(de,X,B[X]);if(So)for(var X of So(B))Ku.call(B,X)&&zu(de,X,B[X]);return de},bi=(de,B)=>Rh(de,Ph(B));var Hu=(de,B)=>{var X={};for(var pe in de)Vu.call(de,pe)&&B.indexOf(pe)<0&&(X[pe]=de[pe]);if(de!=null&&So)for(var pe of So(de))B.indexOf(pe)<0&&Ku.call(de,pe)&&(X[pe]=de[pe]);return X};var re=(de,B,X)=>new Promise((pe,_e)=>{var Oe=x=>{try{O(X.next(x))}catch(k){_e(k)}},H=x=>{try{O(X.throw(x))}catch(k){_e(k)}},O=x=>x.done?pe(x.value):Promise.resolve(x.value).then(Oe,H);O((X=X.apply(de,B)).next())}),Ch=function(de,B){this[0]=de,this[1]=B};var Wu=de=>{var B=de[La("asyncIterator")],X=!1,pe,_e={};return B==null?(B=de[La("iterator")](),pe=Oe=>_e[Oe]=H=>B[Oe](H)):(B=B.call(de),pe=Oe=>_e[Oe]=H=>{if(X){if(X=!1,Oe==="throw")throw H;return H}return X=!0,{done:!1,value:new Ch(new Promise(O=>{var x=B[Oe](H);if(!(x instanceof Object))throw TypeError("Object expected");O(x)}),1)}}),_e[La("iterator")]=()=>_e,pe("next"),"throw"in B?pe("throw"):_e.throw=Oe=>{throw Oe},"return"in B&&pe("return"),_e};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ui=require("axios"),Fa=require("dayjs"),Yu=require("buffer");class Qn{constructor(B,X){this.axios=B,this.errorHandler=X}get(B,X,pe){return re(this,null,function*(){const _e=this.axios.get(B,{params:X});return this.handleResponse(_e,pe)})}listPaged(B,X){return re(this,null,function*(){const pe=this.axios.get(B,{params:X});return this.handleResponse(pe)})}list(B,X){return re(this,null,function*(){const pe=this.axios.get(B,{params:X});return this.handleResponse(pe)})}delete(B,X){return re(this,null,function*(){const pe=this.axios.delete(B,{params:X});return this.handleResponse(pe)})}post(B,X,pe,_e){return re(this,null,function*(){const Oe=this.axios.post(B,X,Wn({params:pe},_e));return this.handleResponse(Oe)})}postForm(B,X,pe){return re(this,null,function*(){const _e=this.axios.post(B,X,{params:pe,headers:{"Content-Type":"multipart/form-data"}});return this.handleResponse(_e)})}patch(B,X,pe){return re(this,null,function*(){const _e=this.axios.patch(B,X,{params:pe});return this.handleResponse(_e)})}put(B,X){return re(this,null,function*(){const pe=this.axios.put(B,X);return this.handleResponse(pe)})}upload(B,X,pe){return re(this,null,function*(){const _e=this.axios.post(B,X,Wn({},pe));return this.handleResponse(_e)})}getNonStandard(B,X){return re(this,null,function*(){const pe=this.axios.get(B,X);try{const _e=yield pe;if(_e.status===200)return _e}catch(_e){throw this.handleError(_e)}})}postNonStandard(B,X,pe,_e){return re(this,null,function*(){var O,x;const H=yield this.axios.post(B,X,Wn({params:pe},_e));if(H.status===200)if((O=H.data)!=null&&O.code)(x=this.errorHandler)!=null&&x.onAppStatusError&&this.errorHandler.onAppStatusError(H.data.code,H.data.message);else return H.data})}handleResponse(B,X){return re(this,null,function*(){try{const pe=yield B;return this.handleAppError(pe.data,X).data}catch(pe){throw this.handleError(pe)}})}handleAppError(B,X){var pe;if(B.code<200||B.code>=300)throw(pe=this.errorHandler)!=null&&pe.onAppStatusError?this.errorHandler.onAppStatusError(B.code,Qu(B.code,B.message),X):console.error("未处理应用错误:",B),{isAxiosError:!1,message:B.message};return B}handleError(B){var X,pe;return B.response?(console.log(B.response.data),console.log(B.response.status),console.log(B.response.headers),(X=this.errorHandler)!=null&&X.onHttpStatusError&&(console.log("HTTP 错误",this.errorHandler),this.errorHandler.onHttpStatusError(B.response.status,"",B.response))):B.request?(console.log(B.request),(pe=this.errorHandler)!=null&&pe.onNetworkError&&this.errorHandler.onNetworkError()):console.error("axios request config error:",B),new Error(B.message)}}const Ju=de=>de>=10002&&de<=10012,Qu=(de,B)=>Ju(de)?"数据操作错误":B||"未知接口错误";class Bh extends Qn{constructor(B,X){super(B!=null?B:ui.create(),X)}getLoginUrl(){return re(this,null,function*(){return this.get("/openAddress")})}getToken(B,X){return re(this,null,function*(){return this.get(B,X)})}getAIoTTokenByGTeamToken(B){return re(this,null,function*(){return this.post("/validate/glodonCloud",B).then(X=>X.accessToken)})}postRefreshToken(B,X,pe,_e="3600",Oe){return re(this,null,function*(){return this.post("/refresh-token",{oldToken:B,tenant:X,orgId:pe,expired:_e,product:Oe})})}}class Dh extends Qn{constructor(B,X){super(B!=null?B:ui.create(),X)}getTenant(B){return re(this,null,function*(){return this.get(`/tenant/${B}`)})}listProduct(){return re(this,null,function*(){return this.list("/products")})}listProvinces(){return re(this,null,function*(){return this.list("/regions/provinces")})}listCities(B){return re(this,null,function*(){return this.list(`/regions/provinces/${B}/city`)})}listCounties(B,X){return re(this,null,function*(){return this.list(`/regions/provinces/${B}/city/${X}/county`)})}getOrgList(B){return re(this,null,function*(){return this.list("/org",B)})}getUserIdOrgList(B,X){return re(this,null,function*(){return this.list(`/users/${B}/org`,X)})}delOrg(B){return re(this,null,function*(){return this.delete(`/org/${B}`)})}postOrg(B){return re(this,null,function*(){return this.post("/org",B)})}patchOrg(B,X){return re(this,null,function*(){return this.patch(`/org/${B}`,X)})}getUsers(B,X){return re(this,null,function*(){return this.list(`/tenant/${B}/users`,X)})}delUser(B,X){return re(this,null,function*(){return this.delete(`/tenant/${B}/users/${X}`)})}postUser(B,X){return re(this,null,function*(){return this.post(`/tenant/${B}/users`,X)})}patchUser(B,X,pe){return re(this,null,function*(){return this.patch(`tenant/${B}/users/${X}`,pe)})}getTenantList(){return re(this,null,function*(){return this.get("/tenant")})}getUserIdRoles(B){return re(this,null,function*(){return this.get(`/users/${B}/role`)})}getProductCodeRole(B){return re(this,null,function*(){return this.get(`/products/${B}/role`)})}postUserRole(B,X){return re(this,null,function*(){return this.post(`/users/${B}/role`,X)})}patchUserRole(B,X,pe){return re(this,null,function*(){return this.patch(`/users/${B}/role/${X}`,pe)})}deleteUserRole(B,X){return re(this,null,function*(){return this.delete(`/users/${B}/role/${X}`)})}getUsersIdProductCodeMenu(B,X,pe="web",_e){return re(this,null,function*(){return this.get(`/users/${B}/product/${X}/menu?groupCode=${pe}`,{level:_e})})}getUserInfo(B){return re(this,null,function*(){return this.get(`/users/${B}`)})}uipermission(B,X,pe="web"){return re(this,null,function*(){return this.get(`/users/${B}/product/${X}/uipermission?groupCode=${pe}`)})}getAppInfo(B){return re(this,null,function*(){return this.get(`/products/${B}/apps`)})}getTenantUserInfo(B,X){return re(this,null,function*(){return this.get(`/tenant/${B}/users/${X}`)})}uploadFile(B){return re(this,null,function*(){return this.upload("/upload",B)})}getUserIdProductCodeOrg(B,X){return re(this,null,function*(){return this.get(`/users/${B}/product/${X}/org`)})}getOrg(B){return re(this,null,function*(){return this.get(`/org/${B}`)})}getUploadTicket(B){return re(this,null,function*(){return this.get("/upload/ticket",B)})}putAppInfo(B,X){return re(this,null,function*(){return this.put(`/products/${B}/apps`,X)})}getTenantKeySecret(B){return re(this,null,function*(){return this.get(`/tenant/${B}/key`)})}resetTenantKeySecret(B){return re(this,null,function*(){return this.post(`/tenant/${B}/resetSecret`,void 0)})}getProductsCode(B){return re(this,null,function*(){return this.get(`/products/${B}`)})}}var ec=(de=>(de.Collecting="采集中",de.CollectionTimeout="超时",de.CollectionFinish="完成",de.WaitUpload="等待上传",de.Uploading="上传中",de.UploadFinish="上传完成",de.UploadFailed="上传失败",de.WaitMerge="等待合成",de.CreateMergeTaskFailed="创建合成任务失败",de.Merging="合成中",de.MergeFailed="合成失败",de.MergeFinish="合成成功",de))(ec||{}),tc=(de=>(de.Collecting="采集中",de.CollectionTimeout="超时",de.CollectionFinish="完成",de.WaitUpload="等待上传",de.Uploading="上传中",de.UploadFinish="上传完成",de.UploadFailed="上传失败",de.WaitMerge="等待合成",de.CreateMergeTaskFailed="创建合成任务失败",de.Merging="合成中",de.MergeFailed="合成失败",de.MergeFinish="合成成功",de))(tc||{});class Lh extends Qn{constructor(B,X){super(B!=null?B:ui.create(),X)}static parseApiToken(B){const X=window.atob(B.split(".")[1]);return JSON.parse(X)}static loadApiToken(B,X,pe){return re(this,null,function*(){return fetch(`${B}${X}/viewtoken/${pe}/create_apitoken`,{method:"POST"}).then(_e=>{if(_e.status!==200)throw console.error(_e),Error(JSON.stringify(_e));return _e.json()}).then(_e=>{if(_e.code!==200)throw Error(JSON.stringify(_e));return _e.data.apiToken})})}listRecord(B){return re(this,null,function*(){return this.listPaged("/spacetwins",B)})}postRecord(B){return re(this,null,function*(){return this.post("/spacetwins",B)})}getRecordOverview(B){return re(this,null,function*(){return this.get(`/spacetwins/${B}`)})}getRecordViewtoken(B){return re(this,null,function*(){return this.get(`/spacetwins/${B}/viewtoken`)})}listScene(B){return re(this,null,function*(){return this.list(`/spacetwins/${B}/scenes`)})}getScenesByTimestamp(B,X){return re(this,null,function*(){return this.list(`/spacetwins/${B}/scenes_timestamp`,{timestamp:X})})}recomputeTrack(B,X){return re(this,null,function*(){return this.patch(`/spacetwins/${B}/track`,{points:X})})}updateRecordUploadStatus(B,X){return re(this,null,function*(){return this.post(`/spacetwins/${B}/update_upload_status`,X)})}getApiToken(B){return re(this,null,function*(){return this.post(`/viewtoken/${B}/create_apitoken`,{})})}getSpacetwins(B){return re(this,null,function*(){return this.listPaged("/spacetwins",B)})}postSpacetwins(B){return re(this,null,function*(){return this.post("/spacetwins",B)})}updateInspection(B,X){return re(this,null,function*(){return this.patch(`/patrolInspection/${B}`,X)})}getSpacetwinsIdViewtoken(B){return re(this,null,function*(){return this.get(`/spacetwins/${B}/viewtoken`)})}postSpacetwinsIdUpdateUploadStatus(B,X){return re(this,null,function*(){return this.post(`/spacetwins/${B}/update_upload_status`,X)})}postUploadTicket(B){return re(this,null,function*(){return this.post("/upload/ticket",B)})}getDownloadUrl(B){return re(this,null,function*(){return this.get(`/download/url?isv=${B.isv}&key=${B.key}`)})}listTrack(B,X){return re(this,null,function*(){return this.list(`/spacetwins/${B}/track`,{type:X})})}}class qh extends Qn{constructor(B,X){super(B!=null?B:ui.create(),X)}listPlugin(B){return re(this,null,function*(){return this.list("/plugins",B)})}postPlugin(B){return re(this,null,function*(){return this.post("/plugins",B)})}getPlugin(B){return re(this,null,function*(){return this.get(`/plugins/${B}`)})}updatePlugin(B,X){return re(this,null,function*(){return this.patch(`/plugins/${B}`,X)})}listPluginData(B,X){return re(this,null,function*(){return this.list(`/plugins/${B}/datas`,X)})}postPluginData(B,X){return re(this,null,function*(){return this.post(`/plugins/${B}/datas`,X)})}getPluginData(B,X){return re(this,null,function*(){return this.get(`/plugins/${B}/datas/${X}`).then(pe=>bi(Wn({},pe),{arguments:JSON.parse(pe.arguments)}))})}updatePluginData(B,X,pe){return re(this,null,function*(){return this.patch(`/plugins/${B}/datas/${X}`,pe)})}deletePluginData(B,X){return re(this,null,function*(){return this.delete(`/plugins/${B}/datas/${X}`)})}}var Fh=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},nc={exports:{}};/*! For license information please see minio-zj.js.LICENSE.txt */(function(de,B){(function(X,pe){de.exports=pe()})(Fh,()=>(()=>{var X={9809:(H,O,x)=>{const k=O;k.bignum=x(4590),k.define=x(2500).define,k.base=x(1979),k.constants=x(6826),k.decoders=x(8307),k.encoders=x(6579)},2500:(H,O,x)=>{const k=x(6579),w=x(8307),g=x(5717);function M(a,d){this.name=a,this.body=d,this.decoders={},this.encoders={}}O.define=function(a,d){return new M(a,d)},M.prototype._createNamed=function(a){const d=this.name;function c(l){this._initNamed(l,d)}return g(c,a),c.prototype._initNamed=function(l,p){a.call(this,l,p)},new c(this)},M.prototype._getDecoder=function(a){return a=a||"der",this.decoders.hasOwnProperty(a)||(this.decoders[a]=this._createNamed(w[a])),this.decoders[a]},M.prototype.decode=function(a,d,c){return this._getDecoder(d).decode(a,c)},M.prototype._getEncoder=function(a){return a=a||"der",this.encoders.hasOwnProperty(a)||(this.encoders[a]=this._createNamed(k[a])),this.encoders[a]},M.prototype.encode=function(a,d,c){return this._getEncoder(d).encode(a,c)}},6625:(H,O,x)=>{const k=x(5717),w=x(8465).b,g=x(2399).Buffer;function M(d,c){w.call(this,c),g.isBuffer(d)?(this.base=d,this.offset=0,this.length=d.length):this.error("Input not Buffer")}function a(d,c){if(Array.isArray(d))this.length=0,this.value=d.map(function(l){return a.isEncoderBuffer(l)||(l=new a(l,c)),this.length+=l.length,l},this);else if(typeof d=="number"){if(!(0<=d&&d<=255))return c.error("non-byte EncoderBuffer value");this.value=d,this.length=1}else if(typeof d=="string")this.value=d,this.length=g.byteLength(d);else{if(!g.isBuffer(d))return c.error("Unsupported type: "+typeof d);this.value=d,this.length=d.length}}k(M,w),O.C=M,M.isDecoderBuffer=function(d){return d instanceof M||typeof d=="object"&&g.isBuffer(d.base)&&d.constructor.name==="DecoderBuffer"&&typeof d.offset=="number"&&typeof d.length=="number"&&typeof d.save=="function"&&typeof d.restore=="function"&&typeof d.isEmpty=="function"&&typeof d.readUInt8=="function"&&typeof d.skip=="function"&&typeof d.raw=="function"},M.prototype.save=function(){return{offset:this.offset,reporter:w.prototype.save.call(this)}},M.prototype.restore=function(d){const c=new M(this.base);return c.offset=d.offset,c.length=this.offset,this.offset=d.offset,w.prototype.restore.call(this,d.reporter),c},M.prototype.isEmpty=function(){return this.offset===this.length},M.prototype.readUInt8=function(d){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(d||"DecoderBuffer overrun")},M.prototype.skip=function(d,c){if(!(this.offset+d<=this.length))return this.error(c||"DecoderBuffer overrun");const l=new M(this.base);return l._reporterState=this._reporterState,l.offset=this.offset,l.length=this.offset+d,this.offset+=d,l},M.prototype.raw=function(d){return this.base.slice(d?d.offset:this.offset,this.length)},O.R=a,a.isEncoderBuffer=function(d){return d instanceof a||typeof d=="object"&&d.constructor.name==="EncoderBuffer"&&typeof d.length=="number"&&typeof d.join=="function"},a.prototype.join=function(d,c){return d||(d=g.alloc(this.length)),c||(c=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(l){l.join(d,c),c+=l.length}):(typeof this.value=="number"?d[c]=this.value:typeof this.value=="string"?d.write(this.value,c):g.isBuffer(this.value)&&this.value.copy(d,c),c+=this.length)),d}},1979:(H,O,x)=>{const k=O;k.Reporter=x(8465).b,k.DecoderBuffer=x(6625).C,k.EncoderBuffer=x(6625).R,k.Node=x(1949)},1949:(H,O,x)=>{const k=x(8465).b,w=x(6625).R,g=x(6625).C,M=x(9746),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],d=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function c(p,m,h){const u={};this._baseState=u,u.name=h,u.enc=p,u.parent=m||null,u.children=null,u.tag=null,u.args=null,u.reverseArgs=null,u.choice=null,u.optional=!1,u.any=!1,u.obj=!1,u.use=null,u.useDecoder=null,u.key=null,u.default=null,u.explicit=null,u.implicit=null,u.contains=null,u.parent||(u.children=[],this._wrap())}H.exports=c;const l=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){const p=this._baseState,m={};l.forEach(function(u){m[u]=p[u]});const h=new this.constructor(m.parent);return h._baseState=m,h},c.prototype._wrap=function(){const p=this._baseState;d.forEach(function(m){this[m]=function(){const h=new this.constructor(this);return p.children.push(h),h[m].apply(h,arguments)}},this)},c.prototype._init=function(p){const m=this._baseState;M(m.parent===null),p.call(this),m.children=m.children.filter(function(h){return h._baseState.parent===this},this),M.equal(m.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(p){const m=this._baseState,h=p.filter(function(u){return u instanceof this.constructor},this);p=p.filter(function(u){return!(u instanceof this.constructor)},this),h.length!==0&&(M(m.children===null),m.children=h,h.forEach(function(u){u._baseState.parent=this},this)),p.length!==0&&(M(m.args===null),m.args=p,m.reverseArgs=p.map(function(u){if(typeof u!="object"||u.constructor!==Object)return u;const y={};return Object.keys(u).forEach(function(v){v==(0|v)&&(v|=0);const _=u[v];y[_]=v}),y}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(p){c.prototype[p]=function(){const m=this._baseState;throw new Error(p+" not implemented for encoding: "+m.enc)}}),a.forEach(function(p){c.prototype[p]=function(){const m=this._baseState,h=Array.prototype.slice.call(arguments);return M(m.tag===null),m.tag=p,this._useArgs(h),this}}),c.prototype.use=function(p){M(p);const m=this._baseState;return M(m.use===null),m.use=p,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(p){const m=this._baseState;return M(m.default===null),m.default=p,m.optional=!0,this},c.prototype.explicit=function(p){const m=this._baseState;return M(m.explicit===null&&m.implicit===null),m.explicit=p,this},c.prototype.implicit=function(p){const m=this._baseState;return M(m.explicit===null&&m.implicit===null),m.implicit=p,this},c.prototype.obj=function(){const p=this._baseState,m=Array.prototype.slice.call(arguments);return p.obj=!0,m.length!==0&&this._useArgs(m),this},c.prototype.key=function(p){const m=this._baseState;return M(m.key===null),m.key=p,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(p){const m=this._baseState;return M(m.choice===null),m.choice=p,this._useArgs(Object.keys(p).map(function(h){return p[h]})),this},c.prototype.contains=function(p){const m=this._baseState;return M(m.use===null),m.contains=p,this},c.prototype._decode=function(p,m){const h=this._baseState;if(h.parent===null)return p.wrapResult(h.children[0]._decode(p,m));let u,y=h.default,v=!0,_=null;if(h.key!==null&&(_=p.enterKey(h.key)),h.optional){let S=null;if(h.explicit!==null?S=h.explicit:h.implicit!==null?S=h.implicit:h.tag!==null&&(S=h.tag),S!==null||h.any){if(v=this._peekTag(p,S,h.any),p.isError(v))return v}else{const b=p.save();try{h.choice===null?this._decodeGeneric(h.tag,p,m):this._decodeChoice(p,m),v=!0}catch(T){v=!1}p.restore(b)}}if(h.obj&&v&&(u=p.enterObject()),v){if(h.explicit!==null){const b=this._decodeTag(p,h.explicit);if(p.isError(b))return b;p=b}const S=p.offset;if(h.use===null&&h.choice===null){let b;h.any&&(b=p.save());const T=this._decodeTag(p,h.implicit!==null?h.implicit:h.tag,h.any);if(p.isError(T))return T;h.any?y=p.raw(b):p=T}if(m&&m.track&&h.tag!==null&&m.track(p.path(),S,p.length,"tagged"),m&&m.track&&h.tag!==null&&m.track(p.path(),p.offset,p.length,"content"),h.any||(y=h.choice===null?this._decodeGeneric(h.tag,p,m):this._decodeChoice(p,m)),p.isError(y))return y;if(h.any||h.choice!==null||h.children===null||h.children.forEach(function(b){b._decode(p,m)}),h.contains&&(h.tag==="octstr"||h.tag==="bitstr")){const b=new g(y);y=this._getUse(h.contains,p._reporterState.obj)._decode(b,m)}}return h.obj&&v&&(y=p.leaveObject(u)),h.key===null||y===null&&v!==!0?_!==null&&p.exitKey(_):p.leaveKey(_,h.key,y),y},c.prototype._decodeGeneric=function(p,m,h){const u=this._baseState;return p==="seq"||p==="set"?null:p==="seqof"||p==="setof"?this._decodeList(m,p,u.args[0],h):/str$/.test(p)?this._decodeStr(m,p,h):p==="objid"&&u.args?this._decodeObjid(m,u.args[0],u.args[1],h):p==="objid"?this._decodeObjid(m,null,null,h):p==="gentime"||p==="utctime"?this._decodeTime(m,p,h):p==="null_"?this._decodeNull(m,h):p==="bool"?this._decodeBool(m,h):p==="objDesc"?this._decodeStr(m,p,h):p==="int"||p==="enum"?this._decodeInt(m,u.args&&u.args[0],h):u.use!==null?this._getUse(u.use,m._reporterState.obj)._decode(m,h):m.error("unknown tag: "+p)},c.prototype._getUse=function(p,m){const h=this._baseState;return h.useDecoder=this._use(p,m),M(h.useDecoder._baseState.parent===null),h.useDecoder=h.useDecoder._baseState.children[0],h.implicit!==h.useDecoder._baseState.implicit&&(h.useDecoder=h.useDecoder.clone(),h.useDecoder._baseState.implicit=h.implicit),h.useDecoder},c.prototype._decodeChoice=function(p,m){const h=this._baseState;let u=null,y=!1;return Object.keys(h.choice).some(function(v){const _=p.save(),S=h.choice[v];try{const b=S._decode(p,m);if(p.isError(b))return!1;u={type:v,value:b},y=!0}catch(b){return p.restore(_),!1}return!0},this),y?u:p.error("Choice not matched")},c.prototype._createEncoderBuffer=function(p){return new w(p,this.reporter)},c.prototype._encode=function(p,m,h){const u=this._baseState;if(u.default!==null&&u.default===p)return;const y=this._encodeValue(p,m,h);return y===void 0||this._skipDefault(y,m,h)?void 0:y},c.prototype._encodeValue=function(p,m,h){const u=this._baseState;if(u.parent===null)return u.children[0]._encode(p,m||new k);let y=null;if(this.reporter=m,u.optional&&p===void 0){if(u.default===null)return;p=u.default}let v=null,_=!1;if(u.any)y=this._createEncoderBuffer(p);else if(u.choice)y=this._encodeChoice(p,m);else if(u.contains)v=this._getUse(u.contains,h)._encode(p,m),_=!0;else if(u.children)v=u.children.map(function(S){if(S._baseState.tag==="null_")return S._encode(null,m,p);if(S._baseState.key===null)return m.error("Child should have a key");const b=m.enterKey(S._baseState.key);if(typeof p!="object")return m.error("Child expected, but input is not object");const T=S._encode(p[S._baseState.key],m,p);return m.leaveKey(b),T},this).filter(function(S){return S}),v=this._createEncoderBuffer(v);else if(u.tag==="seqof"||u.tag==="setof"){if(!u.args||u.args.length!==1)return m.error("Too many args for : "+u.tag);if(!Array.isArray(p))return m.error("seqof/setof, but data is not Array");const S=this.clone();S._baseState.implicit=null,v=this._createEncoderBuffer(p.map(function(b){const T=this._baseState;return this._getUse(T.args[0],p)._encode(b,m)},S))}else u.use!==null?y=this._getUse(u.use,h)._encode(p,m):(v=this._encodePrimitive(u.tag,p),_=!0);if(!u.any&&u.choice===null){const S=u.implicit!==null?u.implicit:u.tag,b=u.implicit===null?"universal":"context";S===null?u.use===null&&m.error("Tag could be omitted only for .use()"):u.use===null&&(y=this._encodeComposite(S,_,b,v))}return u.explicit!==null&&(y=this._encodeComposite(u.explicit,!1,"context",y)),y},c.prototype._encodeChoice=function(p,m){const h=this._baseState,u=h.choice[p.type];return u||M(!1,p.type+" not found in "+JSON.stringify(Object.keys(h.choice))),u._encode(p.value,m)},c.prototype._encodePrimitive=function(p,m){const h=this._baseState;if(/str$/.test(p))return this._encodeStr(m,p);if(p==="objid"&&h.args)return this._encodeObjid(m,h.reverseArgs[0],h.args[1]);if(p==="objid")return this._encodeObjid(m,null,null);if(p==="gentime"||p==="utctime")return this._encodeTime(m,p);if(p==="null_")return this._encodeNull();if(p==="int"||p==="enum")return this._encodeInt(m,h.args&&h.reverseArgs[0]);if(p==="bool")return this._encodeBool(m);if(p==="objDesc")return this._encodeStr(m,p);throw new Error("Unsupported tag: "+p)},c.prototype._isNumstr=function(p){return/^[0-9 ]*$/.test(p)},c.prototype._isPrintstr=function(p){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(p)}},8465:(H,O,x)=>{const k=x(5717);function w(M){this._reporterState={obj:null,path:[],options:M||{},errors:[]}}function g(M,a){this.path=M,this.rethrow(a)}O.b=w,w.prototype.isError=function(M){return M instanceof g},w.prototype.save=function(){const M=this._reporterState;return{obj:M.obj,pathLen:M.path.length}},w.prototype.restore=function(M){const a=this._reporterState;a.obj=M.obj,a.path=a.path.slice(0,M.pathLen)},w.prototype.enterKey=function(M){return this._reporterState.path.push(M)},w.prototype.exitKey=function(M){const a=this._reporterState;a.path=a.path.slice(0,M-1)},w.prototype.leaveKey=function(M,a,d){const c=this._reporterState;this.exitKey(M),c.obj!==null&&(c.obj[a]=d)},w.prototype.path=function(){return this._reporterState.path.join("/")},w.prototype.enterObject=function(){const M=this._reporterState,a=M.obj;return M.obj={},a},w.prototype.leaveObject=function(M){const a=this._reporterState,d=a.obj;return a.obj=M,d},w.prototype.error=function(M){let a;const d=this._reporterState,c=M instanceof g;if(a=c?M:new g(d.path.map(function(l){return"["+JSON.stringify(l)+"]"}).join(""),M.message||M,M.stack),!d.options.partial)throw a;return c||d.errors.push(a),a},w.prototype.wrapResult=function(M){const a=this._reporterState;return a.options.partial?{result:this.isError(M)?null:M,errors:a.errors}:M},k(g,Error),g.prototype.rethrow=function(M){if(this.message=M+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,g),!this.stack)try{throw new Error(this.message)}catch(a){this.stack=a.stack}return this}},160:(H,O)=>{function x(k){const w={};return Object.keys(k).forEach(function(g){(0|g)==g&&(g|=0);const M=k[g];w[M]=g}),w}O.tagClass={0:"universal",1:"application",2:"context",3:"private"},O.tagClassByName=x(O.tagClass),O.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},O.tagByName=x(O.tag)},6826:(H,O,x)=>{const k=O;k._reverse=function(w){const g={};return Object.keys(w).forEach(function(M){(0|M)==M&&(M|=0);const a=w[M];g[a]=M}),g},k.der=x(160)},1671:(H,O,x)=>{const k=x(5717),w=x(4590),g=x(6625).C,M=x(1949),a=x(160);function d(m){this.enc="der",this.name=m.name,this.entity=m,this.tree=new c,this.tree._init(m.body)}function c(m){M.call(this,"der",m)}function l(m,h){let u=m.readUInt8(h);if(m.isError(u))return u;const y=a.tagClass[u>>6],v=(32&u)==0;if((31&u)==31){let _=u;for(u=0;(128&_)==128;){if(_=m.readUInt8(h),m.isError(_))return _;u<<=7,u|=127&_}}else u&=31;return{cls:y,primitive:v,tag:u,tagStr:a.tag[u]}}function p(m,h,u){let y=m.readUInt8(u);if(m.isError(y))return y;if(!h&&y===128)return null;if(!(128&y))return y;const v=127&y;if(v>4)return m.error("length octect is too long");y=0;for(let _=0;_<v;_++){y<<=8;const S=m.readUInt8(u);if(m.isError(S))return S;y|=S}return y}H.exports=d,d.prototype.decode=function(m,h){return g.isDecoderBuffer(m)||(m=new g(m,h)),this.tree._decode(m,h)},k(c,M),c.prototype._peekTag=function(m,h,u){if(m.isEmpty())return!1;const y=m.save(),v=l(m,'Failed to peek tag: "'+h+'"');return m.isError(v)?v:(m.restore(y),v.tag===h||v.tagStr===h||v.tagStr+"of"===h||u)},c.prototype._decodeTag=function(m,h,u){const y=l(m,'Failed to decode tag of "'+h+'"');if(m.isError(y))return y;let v=p(m,y.primitive,'Failed to get length of "'+h+'"');if(m.isError(v))return v;if(!u&&y.tag!==h&&y.tagStr!==h&&y.tagStr+"of"!==h)return m.error('Failed to match tag: "'+h+'"');if(y.primitive||v!==null)return m.skip(v,'Failed to match body of: "'+h+'"');const _=m.save(),S=this._skipUntilEnd(m,'Failed to skip indefinite length body: "'+this.tag+'"');return m.isError(S)?S:(v=m.offset-_.offset,m.restore(_),m.skip(v,'Failed to match body of: "'+h+'"'))},c.prototype._skipUntilEnd=function(m,h){for(;;){const u=l(m,h);if(m.isError(u))return u;const y=p(m,u.primitive,h);if(m.isError(y))return y;let v;if(v=u.primitive||y!==null?m.skip(y):this._skipUntilEnd(m,h),m.isError(v))return v;if(u.tagStr==="end")break}},c.prototype._decodeList=function(m,h,u,y){const v=[];for(;!m.isEmpty();){const _=this._peekTag(m,"end");if(m.isError(_))return _;const S=u.decode(m,"der",y);if(m.isError(S)&&_)break;v.push(S)}return v},c.prototype._decodeStr=function(m,h){if(h==="bitstr"){const u=m.readUInt8();return m.isError(u)?u:{unused:u,data:m.raw()}}if(h==="bmpstr"){const u=m.raw();if(u.length%2==1)return m.error("Decoding of string type: bmpstr length mismatch");let y="";for(let v=0;v<u.length/2;v++)y+=String.fromCharCode(u.readUInt16BE(2*v));return y}if(h==="numstr"){const u=m.raw().toString("ascii");return this._isNumstr(u)?u:m.error("Decoding of string type: numstr unsupported characters")}if(h==="octstr"||h==="objDesc")return m.raw();if(h==="printstr"){const u=m.raw().toString("ascii");return this._isPrintstr(u)?u:m.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(h)?m.raw().toString():m.error("Decoding of string type: "+h+" unsupported")},c.prototype._decodeObjid=function(m,h,u){let y;const v=[];let _=0,S=0;for(;!m.isEmpty();)S=m.readUInt8(),_<<=7,_|=127&S,!(128&S)&&(v.push(_),_=0);128&S&&v.push(_);const b=v[0]/40|0,T=v[0]%40;if(y=u?v:[b,T].concat(v.slice(1)),h){let C=h[y.join(" ")];C===void 0&&(C=h[y.join(".")]),C!==void 0&&(y=C)}return y},c.prototype._decodeTime=function(m,h){const u=m.raw().toString();let y,v,_,S,b,T;if(h==="gentime")y=0|u.slice(0,4),v=0|u.slice(4,6),_=0|u.slice(6,8),S=0|u.slice(8,10),b=0|u.slice(10,12),T=0|u.slice(12,14);else{if(h!=="utctime")return m.error("Decoding "+h+" time is not supported yet");y=0|u.slice(0,2),v=0|u.slice(2,4),_=0|u.slice(4,6),S=0|u.slice(6,8),b=0|u.slice(8,10),T=0|u.slice(10,12),y=y<70?2e3+y:1900+y}return Date.UTC(y,v-1,_,S,b,T,0)},c.prototype._decodeNull=function(){return null},c.prototype._decodeBool=function(m){const h=m.readUInt8();return m.isError(h)?h:h!==0},c.prototype._decodeInt=function(m,h){const u=m.raw();let y=new w(u);return h&&(y=h[y.toString(10)]||y),y},c.prototype._use=function(m,h){return typeof m=="function"&&(m=m(h)),m._getDecoder("der").tree}},8307:(H,O,x)=>{const k=O;k.der=x(1671),k.pem=x(9631)},9631:(H,O,x)=>{const k=x(5717),w=x(2399).Buffer,g=x(1671);function M(a){g.call(this,a),this.enc="pem"}k(M,g),H.exports=M,M.prototype.decode=function(a,d){const c=a.toString().split(/[\r\n]+/g),l=d.label.toUpperCase(),p=/^-----(BEGIN|END) ([^-]+)-----$/;let m=-1,h=-1;for(let v=0;v<c.length;v++){const _=c[v].match(p);if(_!==null&&_[2]===l){if(m!==-1){if(_[1]!=="END")break;h=v;break}if(_[1]!=="BEGIN")break;m=v}}if(m===-1||h===-1)throw new Error("PEM section not found for: "+l);const u=c.slice(m+1,h).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const y=w.from(u,"base64");return g.prototype.decode.call(this,y,d)}},6984:(H,O,x)=>{const k=x(5717),w=x(2399).Buffer,g=x(1949),M=x(160);function a(l){this.enc="der",this.name=l.name,this.entity=l,this.tree=new d,this.tree._init(l.body)}function d(l){g.call(this,"der",l)}function c(l){return l<10?"0"+l:l}H.exports=a,a.prototype.encode=function(l,p){return this.tree._encode(l,p).join()},k(d,g),d.prototype._encodeComposite=function(l,p,m,h){const u=function(_,S,b,T){let C;if(_==="seqof"?_="seq":_==="setof"&&(_="set"),M.tagByName.hasOwnProperty(_))C=M.tagByName[_];else{if(typeof _!="number"||(0|_)!==_)return T.error("Unknown tag: "+_);C=_}return C>=31?T.error("Multi-octet tag encoding unsupported"):(S||(C|=32),C|=M.tagClassByName[b||"universal"]<<6,C)}(l,p,m,this.reporter);if(h.length<128){const _=w.alloc(2);return _[0]=u,_[1]=h.length,this._createEncoderBuffer([_,h])}let y=1;for(let _=h.length;_>=256;_>>=8)y++;const v=w.alloc(2+y);v[0]=u,v[1]=128|y;for(let _=1+y,S=h.length;S>0;_--,S>>=8)v[_]=255&S;return this._createEncoderBuffer([v,h])},d.prototype._encodeStr=function(l,p){if(p==="bitstr")return this._createEncoderBuffer([0|l.unused,l.data]);if(p==="bmpstr"){const m=w.alloc(2*l.length);for(let h=0;h<l.length;h++)m.writeUInt16BE(l.charCodeAt(h),2*h);return this._createEncoderBuffer(m)}return p==="numstr"?this._isNumstr(l)?this._createEncoderBuffer(l):this.reporter.error("Encoding of string type: numstr supports only digits and space"):p==="printstr"?this._isPrintstr(l)?this._createEncoderBuffer(l):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(p)||p==="objDesc"?this._createEncoderBuffer(l):this.reporter.error("Encoding of string type: "+p+" unsupported")},d.prototype._encodeObjid=function(l,p,m){if(typeof l=="string"){if(!p)return this.reporter.error("string objid given, but no values map found");if(!p.hasOwnProperty(l))return this.reporter.error("objid not found in values map");l=p[l].split(/[\s.]+/g);for(let v=0;v<l.length;v++)l[v]|=0}else if(Array.isArray(l)){l=l.slice();for(let v=0;v<l.length;v++)l[v]|=0}if(!Array.isArray(l))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(l));if(!m){if(l[1]>=40)return this.reporter.error("Second objid identifier OOB");l.splice(0,2,40*l[0]+l[1])}let h=0;for(let v=0;v<l.length;v++){let _=l[v];for(h++;_>=128;_>>=7)h++}const u=w.alloc(h);let y=u.length-1;for(let v=l.length-1;v>=0;v--){let _=l[v];for(u[y--]=127&_;(_>>=7)>0;)u[y--]=128|127&_}return this._createEncoderBuffer(u)},d.prototype._encodeTime=function(l,p){let m;const h=new Date(l);return p==="gentime"?m=[c(h.getUTCFullYear()),c(h.getUTCMonth()+1),c(h.getUTCDate()),c(h.getUTCHours()),c(h.getUTCMinutes()),c(h.getUTCSeconds()),"Z"].join(""):p==="utctime"?m=[c(h.getUTCFullYear()%100),c(h.getUTCMonth()+1),c(h.getUTCDate()),c(h.getUTCHours()),c(h.getUTCMinutes()),c(h.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+p+" time is not supported yet"),this._encodeStr(m,"octstr")},d.prototype._encodeNull=function(){return this._createEncoderBuffer("")},d.prototype._encodeInt=function(l,p){if(typeof l=="string"){if(!p)return this.reporter.error("String int or enum given, but no values map");if(!p.hasOwnProperty(l))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(l));l=p[l]}if(typeof l!="number"&&!w.isBuffer(l)){const u=l.toArray();!l.sign&&128&u[0]&&u.unshift(0),l=w.from(u)}if(w.isBuffer(l)){let u=l.length;l.length===0&&u++;const y=w.alloc(u);return l.copy(y),l.length===0&&(y[0]=0),this._createEncoderBuffer(y)}if(l<128)return this._createEncoderBuffer(l);if(l<256)return this._createEncoderBuffer([0,l]);let m=1;for(let u=l;u>=256;u>>=8)m++;const h=new Array(m);for(let u=h.length-1;u>=0;u--)h[u]=255&l,l>>=8;return 128&h[0]&&h.unshift(0),this._createEncoderBuffer(w.from(h))},d.prototype._encodeBool=function(l){return this._createEncoderBuffer(l?255:0)},d.prototype._use=function(l,p){return typeof l=="function"&&(l=l(p)),l._getEncoder("der").tree},d.prototype._skipDefault=function(l,p,m){const h=this._baseState;let u;if(h.default===null)return!1;const y=l.join();if(h.defaultBuffer===void 0&&(h.defaultBuffer=this._encodeValue(h.default,p,m).join()),y.length!==h.defaultBuffer.length)return!1;for(u=0;u<y.length;u++)if(y[u]!==h.defaultBuffer[u])return!1;return!0}},6579:(H,O,x)=>{const k=O;k.der=x(6984),k.pem=x(2883)},2883:(H,O,x)=>{const k=x(5717),w=x(6984);function g(M){w.call(this,M),this.enc="pem"}k(g,w),H.exports=g,g.prototype.encode=function(M,a){const d=w.prototype.encode.call(this,M).toString("base64"),c=["-----BEGIN "+a.label+"-----"];for(let l=0;l<d.length;l+=64)c.push(d.slice(l,l+64));return c.push("-----END "+a.label+"-----"),c.join(`
`)}},4590:function(H,O,x){(function(k,w){function g(e,r){if(!e)throw new Error(r||"Assertion failed")}function M(e,r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}function a(e,r,i){if(a.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,e!==null&&(r!=="le"&&r!=="be"||(i=r,r=10),this._init(e||0,r||10,i||"be"))}var d;typeof k=="object"?k.exports=a:w.BN=a,a.BN=a,a.wordSize=26;try{d=typeof window!="undefined"&&window.Buffer!==void 0?window.Buffer:x(950).Buffer}catch(e){}function c(e,r){var i=e.charCodeAt(r);return i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:i-48&15}function l(e,r,i){var n=c(e,i);return i-1>=r&&(n|=c(e,i-1)<<4),n}function p(e,r,i,n){for(var t=0,o=Math.min(e.length,i),s=r;s<o;s++){var I=e.charCodeAt(s)-48;t*=n,t+=I>=49?I-49+10:I>=17?I-17+10:I}return t}a.isBN=function(e){return e instanceof a||e!==null&&typeof e=="object"&&e.constructor.wordSize===a.wordSize&&Array.isArray(e.words)},a.max=function(e,r){return e.cmp(r)>0?e:r},a.min=function(e,r){return e.cmp(r)<0?e:r},a.prototype._init=function(e,r,i){if(typeof e=="number")return this._initNumber(e,r,i);if(typeof e=="object")return this._initArray(e,r,i);r==="hex"&&(r=16),g(r===(0|r)&&r>=2&&r<=36);var n=0;(e=e.toString().replace(/\s+/g,""))[0]==="-"&&(n++,this.negative=1),n<e.length&&(r===16?this._parseHex(e,n,i):(this._parseBase(e,r,n),i==="le"&&this._initArray(this.toArray(),r,i)))},a.prototype._initNumber=function(e,r,i){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(g(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),i==="le"&&this._initArray(this.toArray(),r,i)},a.prototype._initArray=function(e,r,i){if(g(typeof e.length=="number"),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var t,o,s=0;if(i==="be")for(n=e.length-1,t=0;n>=0;n-=3)o=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[t]|=o<<s&67108863,this.words[t+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,t++);else if(i==="le")for(n=0,t=0;n<e.length;n+=3)o=e[n]|e[n+1]<<8|e[n+2]<<16,this.words[t]|=o<<s&67108863,this.words[t+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,t++);return this.strip()},a.prototype._parseHex=function(e,r,i){this.length=Math.ceil((e.length-r)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var t,o=0,s=0;if(i==="be")for(n=e.length-1;n>=r;n-=2)t=l(e,r,n)<<o,this.words[s]|=67108863&t,o>=18?(o-=18,s+=1,this.words[s]|=t>>>26):o+=8;else for(n=(e.length-r)%2==0?r+1:r;n<e.length;n+=2)t=l(e,r,n)<<o,this.words[s]|=67108863&t,o>=18?(o-=18,s+=1,this.words[s]|=t>>>26):o+=8;this.strip()},a.prototype._parseBase=function(e,r,i){this.words=[0],this.length=1;for(var n=0,t=1;t<=67108863;t*=r)n++;n--,t=t/r|0;for(var o=e.length-i,s=o%n,I=Math.min(o,o-s)+i,P=0,j=i;j<I;j+=n)P=p(e,j,j+n,r),this.imuln(t),this.words[0]+P<67108864?this.words[0]+=P:this._iaddn(P);if(s!==0){var A=1;for(P=p(e,j,e.length,r),j=0;j<s;j++)A*=r;this.imuln(A),this.words[0]+P<67108864?this.words[0]+=P:this._iaddn(P)}this.strip()},a.prototype.copy=function(e){e.words=new Array(this.length);for(var r=0;r<this.length;r++)e.words[r]=this.words[r];e.length=this.length,e.negative=this.negative,e.red=this.red},a.prototype.clone=function(){var e=new a(null);return this.copy(e),e},a.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},a.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var m=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function y(e,r,i){i.negative=r.negative^e.negative;var n=e.length+r.length|0;i.length=n,n=n-1|0;var t=0|e.words[0],o=0|r.words[0],s=t*o,I=67108863&s,P=s/67108864|0;i.words[0]=I;for(var j=1;j<n;j++){for(var A=P>>>26,N=67108863&P,L=Math.min(j,r.length-1),z=Math.max(0,j-e.length+1);z<=L;z++){var Y=j-z|0;A+=(s=(t=0|e.words[Y])*(o=0|r.words[z])+N)/67108864|0,N=67108863&s}i.words[j]=0|N,P=0|A}return P!==0?i.words[j]=0|P:i.length--,i.strip()}a.prototype.toString=function(e,r){var i;if(r=0|r||1,(e=e||10)===16||e==="hex"){i="";for(var n=0,t=0,o=0;o<this.length;o++){var s=this.words[o],I=(16777215&(s<<n|t)).toString(16);i=(t=s>>>24-n&16777215)!=0||o!==this.length-1?m[6-I.length]+I+i:I+i,(n+=2)>=26&&(n-=26,o--)}for(t!==0&&(i=t.toString(16)+i);i.length%r!=0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}if(e===(0|e)&&e>=2&&e<=36){var P=h[e],j=u[e];i="";var A=this.clone();for(A.negative=0;!A.isZero();){var N=A.modn(j).toString(e);i=(A=A.idivn(j)).isZero()?N+i:m[P-N.length]+N+i}for(this.isZero()&&(i="0"+i);i.length%r!=0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}g(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=67108864*this.words[1]:this.length===3&&this.words[2]===1?e+=4503599627370496+67108864*this.words[1]:this.length>2&&g(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-e:e},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(e,r){return g(d!==void 0),this.toArrayLike(d,e,r)},a.prototype.toArray=function(e,r){return this.toArrayLike(Array,e,r)},a.prototype.toArrayLike=function(e,r,i){var n=this.byteLength(),t=i||Math.max(1,n);g(n<=t,"byte array longer than desired length"),g(t>0,"Requested array length <= 0"),this.strip();var o,s,I=r==="le",P=new e(t),j=this.clone();if(I){for(s=0;!j.isZero();s++)o=j.andln(255),j.iushrn(8),P[s]=o;for(;s<t;s++)P[s]=0}else{for(s=0;s<t-n;s++)P[s]=0;for(s=0;!j.isZero();s++)o=j.andln(255),j.iushrn(8),P[t-s-1]=o}return P},Math.clz32?a.prototype._countBits=function(e){return 32-Math.clz32(e)}:a.prototype._countBits=function(e){var r=e,i=0;return r>=4096&&(i+=13,r>>>=13),r>=64&&(i+=7,r>>>=7),r>=8&&(i+=4,r>>>=4),r>=2&&(i+=2,r>>>=2),i+r},a.prototype._zeroBits=function(e){if(e===0)return 26;var r=e,i=0;return!(8191&r)&&(i+=13,r>>>=13),!(127&r)&&(i+=7,r>>>=7),!(15&r)&&(i+=4,r>>>=4),!(3&r)&&(i+=2,r>>>=2),!(1&r)&&i++,i},a.prototype.bitLength=function(){var e=this.words[this.length-1],r=this._countBits(e);return 26*(this.length-1)+r},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,r=0;r<this.length;r++){var i=this._zeroBits(this.words[r]);if(e+=i,i!==26)break}return e},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(e){return this.negative!==0?this.abs().inotn(e).iaddn(1):this.clone()},a.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]|e.words[r];return this.strip()},a.prototype.ior=function(e){return g((this.negative|e.negative)==0),this.iuor(e)},a.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},a.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},a.prototype.iuand=function(e){var r;r=this.length>e.length?e:this;for(var i=0;i<r.length;i++)this.words[i]=this.words[i]&e.words[i];return this.length=r.length,this.strip()},a.prototype.iand=function(e){return g((this.negative|e.negative)==0),this.iuand(e)},a.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},a.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},a.prototype.iuxor=function(e){var r,i;this.length>e.length?(r=this,i=e):(r=e,i=this);for(var n=0;n<i.length;n++)this.words[n]=r.words[n]^i.words[n];if(this!==r)for(;n<r.length;n++)this.words[n]=r.words[n];return this.length=r.length,this.strip()},a.prototype.ixor=function(e){return g((this.negative|e.negative)==0),this.iuxor(e)},a.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},a.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},a.prototype.inotn=function(e){g(typeof e=="number"&&e>=0);var r=0|Math.ceil(e/26),i=e%26;this._expand(r),i>0&&r--;for(var n=0;n<r;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},a.prototype.notn=function(e){return this.clone().inotn(e)},a.prototype.setn=function(e,r){g(typeof e=="number"&&e>=0);var i=e/26|0,n=e%26;return this._expand(i+1),this.words[i]=r?this.words[i]|1<<n:this.words[i]&~(1<<n),this.strip()},a.prototype.iadd=function(e){var r,i,n;if(this.negative!==0&&e.negative===0)return this.negative=0,r=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,r=this.isub(e),e.negative=1,r._normSign();this.length>e.length?(i=this,n=e):(i=e,n=this);for(var t=0,o=0;o<n.length;o++)r=(0|i.words[o])+(0|n.words[o])+t,this.words[o]=67108863&r,t=r>>>26;for(;t!==0&&o<i.length;o++)r=(0|i.words[o])+t,this.words[o]=67108863&r,t=r>>>26;if(this.length=i.length,t!==0)this.words[this.length]=t,this.length++;else if(i!==this)for(;o<i.length;o++)this.words[o]=i.words[o];return this},a.prototype.add=function(e){var r;return e.negative!==0&&this.negative===0?(e.negative=0,r=this.sub(e),e.negative^=1,r):e.negative===0&&this.negative!==0?(this.negative=0,r=e.sub(this),this.negative=1,r):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},a.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var r=this.iadd(e);return e.negative=1,r._normSign()}if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var i,n,t=this.cmp(e);if(t===0)return this.negative=0,this.length=1,this.words[0]=0,this;t>0?(i=this,n=e):(i=e,n=this);for(var o=0,s=0;s<n.length;s++)o=(r=(0|i.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&r;for(;o!==0&&s<i.length;s++)o=(r=(0|i.words[s])+o)>>26,this.words[s]=67108863&r;if(o===0&&s<i.length&&i!==this)for(;s<i.length;s++)this.words[s]=i.words[s];return this.length=Math.max(this.length,s),i!==this&&(this.negative=1),this.strip()},a.prototype.sub=function(e){return this.clone().isub(e)};var v=function(e,r,i){var n,t,o,s=e.words,I=r.words,P=i.words,j=0,A=0|s[0],N=8191&A,L=A>>>13,z=0|s[1],Y=8191&z,D=z>>>13,K=0|s[2],q=8191&K,U=K>>>13,te=0|s[3],J=8191&te,ae=te>>>13,xe=0|s[4],ce=8191&xe,fe=xe>>>13,Te=0|s[5],ye=8191&Te,Ee=Te>>>13,V=0|s[6],W=8191&V,Q=V>>>13,ge=0|s[7],oe=8191&ge,ue=ge>>>13,Ne=0|s[8],we=8191&Ne,Me=Ne>>>13,pt=0|s[9],ke=8191&pt,je=pt>>>13,Et=0|I[0],Ie=8191&Et,Xe=Et>>>13,Ct=0|I[1],De=8191&Ct,Ke=Ct>>>13,Nt=0|I[2],Pe=8191&Nt,He=Nt>>>13,vt=0|I[3],Ce=8191&vt,Ze=vt>>>13,St=0|I[4],Re=8191&St,Ge=St>>>13,It=0|I[5],qe=8191&It,Ye=It>>>13,Dt=0|I[6],Le=8191&Dt,et=Dt>>>13,$t=0|I[7],Fe=8191&$t,Qe=$t>>>13,Ut=0|I[8],$e=8191&Ut,nt=Ut>>>13,zt=0|I[9],Ue=8191&zt,tt=zt>>>13;i.negative=e.negative^r.negative,i.length=19;var Tt=(j+(n=Math.imul(N,Ie))|0)+((8191&(t=(t=Math.imul(N,Xe))+Math.imul(L,Ie)|0))<<13)|0;j=((o=Math.imul(L,Xe))+(t>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(Y,Ie),t=(t=Math.imul(Y,Xe))+Math.imul(D,Ie)|0,o=Math.imul(D,Xe);var Rt=(j+(n=n+Math.imul(N,De)|0)|0)+((8191&(t=(t=t+Math.imul(N,Ke)|0)+Math.imul(L,De)|0))<<13)|0;j=((o=o+Math.imul(L,Ke)|0)+(t>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(q,Ie),t=(t=Math.imul(q,Xe))+Math.imul(U,Ie)|0,o=Math.imul(U,Xe),n=n+Math.imul(Y,De)|0,t=(t=t+Math.imul(Y,Ke)|0)+Math.imul(D,De)|0,o=o+Math.imul(D,Ke)|0;var Zt=(j+(n=n+Math.imul(N,Pe)|0)|0)+((8191&(t=(t=t+Math.imul(N,He)|0)+Math.imul(L,Pe)|0))<<13)|0;j=((o=o+Math.imul(L,He)|0)+(t>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,n=Math.imul(J,Ie),t=(t=Math.imul(J,Xe))+Math.imul(ae,Ie)|0,o=Math.imul(ae,Xe),n=n+Math.imul(q,De)|0,t=(t=t+Math.imul(q,Ke)|0)+Math.imul(U,De)|0,o=o+Math.imul(U,Ke)|0,n=n+Math.imul(Y,Pe)|0,t=(t=t+Math.imul(Y,He)|0)+Math.imul(D,Pe)|0,o=o+Math.imul(D,He)|0;var on=(j+(n=n+Math.imul(N,Ce)|0)|0)+((8191&(t=(t=t+Math.imul(N,Ze)|0)+Math.imul(L,Ce)|0))<<13)|0;j=((o=o+Math.imul(L,Ze)|0)+(t>>>13)|0)+(on>>>26)|0,on&=67108863,n=Math.imul(ce,Ie),t=(t=Math.imul(ce,Xe))+Math.imul(fe,Ie)|0,o=Math.imul(fe,Xe),n=n+Math.imul(J,De)|0,t=(t=t+Math.imul(J,Ke)|0)+Math.imul(ae,De)|0,o=o+Math.imul(ae,Ke)|0,n=n+Math.imul(q,Pe)|0,t=(t=t+Math.imul(q,He)|0)+Math.imul(U,Pe)|0,o=o+Math.imul(U,He)|0,n=n+Math.imul(Y,Ce)|0,t=(t=t+Math.imul(Y,Ze)|0)+Math.imul(D,Ce)|0,o=o+Math.imul(D,Ze)|0;var tn=(j+(n=n+Math.imul(N,Re)|0)|0)+((8191&(t=(t=t+Math.imul(N,Ge)|0)+Math.imul(L,Re)|0))<<13)|0;j=((o=o+Math.imul(L,Ge)|0)+(t>>>13)|0)+(tn>>>26)|0,tn&=67108863,n=Math.imul(ye,Ie),t=(t=Math.imul(ye,Xe))+Math.imul(Ee,Ie)|0,o=Math.imul(Ee,Xe),n=n+Math.imul(ce,De)|0,t=(t=t+Math.imul(ce,Ke)|0)+Math.imul(fe,De)|0,o=o+Math.imul(fe,Ke)|0,n=n+Math.imul(J,Pe)|0,t=(t=t+Math.imul(J,He)|0)+Math.imul(ae,Pe)|0,o=o+Math.imul(ae,He)|0,n=n+Math.imul(q,Ce)|0,t=(t=t+Math.imul(q,Ze)|0)+Math.imul(U,Ce)|0,o=o+Math.imul(U,Ze)|0,n=n+Math.imul(Y,