@eluvio/elv-client-js 4.0.29 → 4.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@ e.read=function(t,e,n,r,i){var a,o,s=8*i-r-1,u=(1<<s)-1,c=u>>1,A=-7,f=n?i-1:0,l=
48
48
  * Licensed under
49
49
  * MIT License http://www.opensource.org/licenses/mit-license
50
50
  *
51
- */!function(o,s){"use strict";"object"===a(t)&&t.exports?t.exports=s():void 0===(i="function"==typeof(r=s)?r.call(e,n,e,t):r)||(t.exports=i)}(0,(function(t){"use strict";var e=t&&t.SecondLevelDomains,n={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ",do:" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ",in:" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch ",com:"ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ",net:"gb jp se uk ",org:"ae",de:"com "},has:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;var r=t.lastIndexOf(".",e-1);if(r<=0||r>=e-1)return!1;var i=n.list[t.slice(e+1)];return!!i&&i.indexOf(" "+t.slice(r+1,e)+" ")>=0},is:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;if(t.lastIndexOf(".",e-1)>=0)return!1;var r=n.list[t.slice(e+1)];return!!r&&r.indexOf(" "+t.slice(0,e)+" ")>=0},get:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return null;var r=t.lastIndexOf(".",e-1);if(r<=0||r>=e-1)return null;var i=n.list[t.slice(e+1)];return i?i.indexOf(" "+t.slice(r+1,e)+" ")<0?null:t.slice(r+1):null},noConflict:function(){return t.SecondLevelDomains===this&&(t.SecondLevelDomains=e),this}};return n}))}).call(this,n(18)(t))},function(t,e,n){"use strict";var r=n(19).rotr32;function i(t,e,n){return t&e^~t&n}function a(t,e,n){return t&e^t&n^e&n}function o(t,e,n){return t^e^n}e.ft_1=function(t,e,n,r){return 0===t?i(e,n,r):1===t||3===t?o(e,n,r):2===t?a(e,n,r):void 0},e.ch32=i,e.maj32=a,e.p32=o,e.s0_256=function(t){return r(t,2)^r(t,13)^r(t,22)},e.s1_256=function(t){return r(t,6)^r(t,11)^r(t,25)},e.g0_256=function(t){return r(t,7)^r(t,18)^t>>>3},e.g1_256=function(t){return r(t,17)^r(t,19)^t>>>10}},function(t,e,n){"use strict";var r=n(19),i=n(39),a=n(99),o=n(14),s=r.sum32,u=r.sum32_4,c=r.sum32_5,A=a.ch32,f=a.maj32,l=a.s0_256,p=a.s1_256,d=a.g0_256,h=a.g1_256,y=i.BlockHash,g=[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];function b(){if(!(this instanceof b))return new b;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(b,y),t.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(t,e){for(var n=this.W,r=0;r<16;r++)n[r]=t[e+r];for(;r<n.length;r++)n[r]=u(h(n[r-2]),n[r-7],d(n[r-15]),n[r-16]);var i=this.h[0],a=this.h[1],y=this.h[2],g=this.h[3],b=this.h[4],m=this.h[5],v=this.h[6],I=this.h[7];for(o(this.k.length===n.length),r=0;r<n.length;r++){var C=c(I,p(b),A(b,m,v),this.k[r],n[r]),w=s(l(i),f(i,a,y));I=v,v=m,m=b,b=s(g,C),g=y,y=a,a=i,i=s(C,w)}this.h[0]=s(this.h[0],i),this.h[1]=s(this.h[1],a),this.h[2]=s(this.h[2],y),this.h[3]=s(this.h[3],g),this.h[4]=s(this.h[4],b),this.h[5]=s(this.h[5],m),this.h[6]=s(this.h[6],v),this.h[7]=s(this.h[7],I)},b.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(t,e,n){"use strict";var r=n(19),i=n(39),a=n(14),o=r.rotr64_hi,s=r.rotr64_lo,u=r.shr64_hi,c=r.shr64_lo,A=r.sum64,f=r.sum64_hi,l=r.sum64_lo,p=r.sum64_4_hi,d=r.sum64_4_lo,h=r.sum64_5_hi,y=r.sum64_5_lo,g=i.BlockHash,b=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function m(){if(!(this instanceof m))return new m;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=b,this.W=new Array(160)}function v(t,e,n,r,i){var a=t&n^~t&i;return a<0&&(a+=4294967296),a}function I(t,e,n,r,i,a){var o=e&r^~e&a;return o<0&&(o+=4294967296),o}function C(t,e,n,r,i){var a=t&n^t&i^n&i;return a<0&&(a+=4294967296),a}function w(t,e,n,r,i,a){var o=e&r^e&a^r&a;return o<0&&(o+=4294967296),o}function E(t,e){var n=o(t,e,28)^o(e,t,2)^o(e,t,7);return n<0&&(n+=4294967296),n}function B(t,e){var n=s(t,e,28)^s(e,t,2)^s(e,t,7);return n<0&&(n+=4294967296),n}function Q(t,e){var n=o(t,e,14)^o(t,e,18)^o(e,t,9);return n<0&&(n+=4294967296),n}function k(t,e){var n=s(t,e,14)^s(t,e,18)^s(e,t,9);return n<0&&(n+=4294967296),n}function x(t,e){var n=o(t,e,1)^o(t,e,8)^u(t,e,7);return n<0&&(n+=4294967296),n}function S(t,e){var n=s(t,e,1)^s(t,e,8)^c(t,e,7);return n<0&&(n+=4294967296),n}function _(t,e){var n=o(t,e,19)^o(e,t,29)^u(t,e,6);return n<0&&(n+=4294967296),n}function M(t,e){var n=s(t,e,19)^s(e,t,29)^c(t,e,6);return n<0&&(n+=4294967296),n}r.inherits(m,g),t.exports=m,m.blockSize=1024,m.outSize=512,m.hmacStrength=192,m.padLength=128,m.prototype._prepareBlock=function(t,e){for(var n=this.W,r=0;r<32;r++)n[r]=t[e+r];for(;r<n.length;r+=2){var i=_(n[r-4],n[r-3]),a=M(n[r-4],n[r-3]),o=n[r-14],s=n[r-13],u=x(n[r-30],n[r-29]),c=S(n[r-30],n[r-29]),A=n[r-32],f=n[r-31];n[r]=p(i,a,o,s,u,c,A,f),n[r+1]=d(i,a,o,s,u,c,A,f)}},m.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,r=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],u=this.h[4],c=this.h[5],p=this.h[6],d=this.h[7],g=this.h[8],b=this.h[9],m=this.h[10],x=this.h[11],S=this.h[12],_=this.h[13],M=this.h[14],D=this.h[15];a(this.k.length===n.length);for(var R=0;R<n.length;R+=2){var O=M,j=D,N=Q(g,b),T=k(g,b),P=v(g,b,m,x,S),L=I(g,b,m,x,S,_),F=this.k[R],U=this.k[R+1],H=n[R],G=n[R+1],Y=h(O,j,N,T,P,L,F,U,H,G),q=y(O,j,N,T,P,L,F,U,H,G);O=E(r,i),j=B(r,i),N=C(r,i,o,s,u),T=w(r,i,o,s,u,c);var K=f(O,j,N,T),z=l(O,j,N,T);M=S,D=_,S=m,_=x,m=g,x=b,g=f(p,d,Y,q),b=l(d,d,Y,q),p=u,d=c,u=o,c=s,o=r,s=i,r=f(Y,q,K,z),i=l(Y,q,K,z)}A(this.h,0,r,i),A(this.h,2,o,s),A(this.h,4,u,c),A(this.h,6,p,d),A(this.h,8,g,b),A(this.h,10,m,x),A(this.h,12,S,_),A(this.h,14,M,D)},m.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function a(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new a(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new a(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},a.prototype.unref=a.prototype.ref=function(){},a.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(192),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(8))},function(t,e,n){var r=n(198);t.exports=r("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(t,e){t.exports={abi:[{constant:!0,inputs:[],name:"creator",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_SEE",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"customValues",type:"bytes32[]"},{name:"stakeholders",type:"address[]"}],name:"accessRequestV3",outputs:[{name:"",type:"bool"}],payable:!0,stateMutability:"payable",type:"function"},{constant:!0,inputs:[],name:"visibility",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[],name:"kill",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"version",outputs:[{name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"versionAPI",outputs:[{name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"indexCategory",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"newCreator",type:"address"}],name:"transferCreatorship",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"candidate",type:"address"}],name:"hasAccess",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_ACCESS",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_visibility_code",type:"uint8"}],name:"setVisibility",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"contentSpace",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_EDIT",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!1,name:"requestNonce",type:"uint256"},{indexed:!1,name:"parentAddress",type:"address"},{indexed:!1,name:"contextHash",type:"bytes32"},{indexed:!1,name:"accessor",type:"address"},{indexed:!1,name:"requestTimestamp",type:"uint256"}],name:"AccessRequestV3",type:"event"},{anonymous:!1,inputs:[{indexed:!1,name:"contentSpace",type:"address"},{indexed:!1,name:"parentAddress",type:"address"},{indexed:!1,name:"visibility",type:"uint8"}],name:"VisibilityChanged",type:"event"}]}},function(t,e,n){var r=n(30),i=n(17),a=n(13),o=n(9),s=n(10);function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?u(Object(n),!0).forEach((function(e){a(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var A=n(23),f=n(226),l=n(40),p=n(24),d=p.ValidateLibrary,h=p.ValidateObject,y=p.ValidateVersion,g=p.ValidatePartHash,b=p.ValidateWriteToken,m=p.ValidateParameters,v=n(227);e.permissionLevels={owner:{short:"Owner Only",description:"Only the owner has access to the object and ability to change permissions",settings:{visibility:0,statusCode:-1,kmsConk:!1}},editable:{short:"Editable",description:"Members of the editors group have full access to the object and the ability to change permissions",settings:{visibility:0,statusCode:-1,kmsConk:!0}},viewable:{short:"Viewable",description:"In addition to editors, members of the 'accessor' group can have read-only access to the object including playing video and retrieving metadata, images and documents",settings:{visibility:0,statusCode:0,kmsConk:!0}},listable:{short:"Publicly Listable",description:"Anyone can list the public portion of this object but only accounts with specific rights can access",settings:{visibility:1,statusCode:0,kmsConk:!0}},public:{short:"Public",description:"Anyone can access this object",settings:{visibility:10,statusCode:0,kmsConk:!0}}},e.Visibility=function(){var t=s(o.mark((function t(e){var n,r,i,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,r=e.clearCache,t.prev=1,i=this.utils.HashToAddress(n),r&&delete this.visibilityInfo[i],this.visibilityInfo[i]||(this.visibilityInfo[i]=new Promise(function(){var t=s(o.mark((function t(e,r){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,a.authClient.ContractHasMethod({contractAddress:i,methodName:"visibility"});case 3:if(t.sent){t.next=7;break}return e(0),t.abrupt("return");case 7:return t.t0=e,t.next=10,a.CallContractMethod({contractAddress:a.utils.HashToAddress(n),methodName:"visibility"});case 10:t.t1=t.sent,(0,t.t0)(t.t1),t.next=17;break;case 14:t.prev=14,t.t2=t.catch(0),r(t.t2);case 17:case"end":return t.stop()}}),t,null,[[0,14]])})));return function(e,n){return t.apply(this,arguments)}}())),t.prev=5,t.next=8,this.visibilityInfo[i];case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(5),delete this.visibilityInfo[i],t.t0;case 15:t.next=22;break;case 17:if(t.prev=17,t.t1=t.catch(1),"CALL_EXCEPTION"!==t.t1.code){t.next=21;break}return t.abrupt("return",0);case 21:throw t.t1;case 22:case"end":return t.stop()}}),t,this,[[1,17],[5,11]])})));return function(e){return t.apply(this,arguments)}}(),e.Permission=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.clearCache,h(n),t.next=4,this.AccessType({id:n});case 4:if(t.t0=t.sent,t.t1=this.authClient.ACCESS_TYPES.OBJECT,t.t0===t.t1){t.next=8;break}throw Error("Permission only valid for normal content objects: "+n);case 8:return t.next=10,this.Visibility({id:n,clearCache:r});case 10:return i=t.sent,t.next=13,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 13:if(a=t.sent,s=a&&"ikms".concat(this.utils.AddressToHash(a)),u=!1,!s){t.next=27;break}return t.t2=this,t.next=20,this.ContentObjectLibraryId({objectId:n});case 20:return t.t3=t.sent,t.t4=n,t.t5="eluv.caps.".concat(s),t.t6={libraryId:t.t3,objectId:t.t4,metadataSubtree:t.t5},t.next=26,t.t2.ContentObjectMetadata.call(t.t2,t.t6);case 26:u=!!t.sent;case 27:return t.next=29,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"statusCode"});case 29:return c=t.sent,c=parseInt(c._hex,16),(A=Object.keys(this.permissionLevels).filter((function(t){var e=f.permissionLevels[t].settings;return i>=e.visibility&&c>=e.statusCode&&u===e.kmsConk})))||(A=u?["editable"]:["owner"]),t.abrupt("return",A.slice(-1)[0]);case 34:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DefaultKMSAddress=s(o.mark((function t(){var e,n,r,i=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=i.length>0&&void 0!==i[0]?i[0]:{},n=e.tenantId,t.t0=n,!t.t0){t.next=8;break}return t.next=5,this.AccessType({id:n});case 5:t.t1=t.sent,t.t2=this.authClient.ACCESS_TYPES.TENANT,t.t0=t.t1===t.t2;case 8:if(!t.t0){t.next=14;break}return t.next=11,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 11:if(!(r=t.sent)){t.next=14;break}return t.abrupt("return",r);case 14:return t.next=16,this.CallContractMethod({contractAddress:this.contentSpaceAddress,methodName:"addressKMS"});case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t,this)}))),e.ContentSpaceId=function(){return this.contentSpaceId},e.ContentTypeOwner=function(){var t=s(o.mark((function t(e){var n,r,i,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.name,r=e.typeId,i=e.versionHash,t.next=3,this.ContentType({name:n,typeId:r,versionHash:i});case 3:return a=t.sent,t.t0=this.utils,t.next=7,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(a.id),methodName:"owner",methodArgs:[]});case 7:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentType=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.name,r=e.typeId,i=e.versionHash,a=e.publicOnly,s=void 0!==a&&a,this.Log("Retrieving content type: ".concat(n||r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),!n){t.next=13;break}return this.Log("Looking up type by name in content space metadata..."),t.prev=5,t.next=8,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:this.contentSpaceObjectId,metadataSubtree:A("public","contentTypes",n)});case 8:r=t.sent,t.next=13;break;case 11:t.prev=11,t.t0=t.catch(5);case 13:if(r){t.next=23;break}return this.Log("Looking up type by name in available types..."),t.next=17,this.ContentTypes();case 17:if(u=t.sent,!n){t.next=22;break}return t.abrupt("return",Object.values(u).find((function(t){return(t.name||"").toLowerCase()===n.toLowerCase()})));case 22:return t.abrupt("return",Object.values(u).find((function(t){return t.hash===i})));case 23:if(i){t.next=27;break}return t.next=26,this.LatestVersionHash({objectId:r});case 26:i=t.sent;case 27:if(t.prev=27,this.Log("Looking up type by ID..."),!s){t.next=39;break}return t.next=32,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:r,versionHash:i,metadataSubtree:"public"});case 32:if(t.t1=t.sent,t.t1){t.next=35;break}t.t1={};case 35:t.t2=t.t1,c={public:t.t2},t.next=45;break;case 39:return t.next=41,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:r,versionHash:i});case 41:if(t.t3=t.sent,t.t3){t.next=44;break}t.t3={};case 44:c=t.t3;case 45:return t.abrupt("return",{id:r,hash:i,name:c.public&&c.public.name||c.name||r,meta:c});case 48:throw t.prev=48,t.t4=t.catch(27),this.Log("Error looking up content type:"),this.Log(t.t4),new Error("Content Type ".concat(n||r," is invalid"));case 53:case"end":return t.stop()}}),t,this,[[5,11],[27,48]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentTypes=s(o.mark((function t(){var e,n,r,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.contentTypes=this.contentTypes||{},this.Log("Looking up all available content types"),t.next=4,this.Collection({collectionType:"contentTypes"});case 4:return e=t.sent,this.Log("Personally available types:"),this.Log(e),n={},t.prev=8,t.next=11,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:this.contentSpaceObjectId,metadataSubtree:"public/contentTypes"});case 11:if(t.t0=t.sent,t.t0){t.next=14;break}t.t0={};case 14:n=t.t0,t.next=19;break;case 17:t.prev=17,t.t1=t.catch(8);case 19:return r=Object.values(n).map((function(t){return i.utils.HashToAddress(t)})),this.Log("Content space types:"),this.Log(r),e=e.concat(r).filter((function(t){return t})).map((function(t){return i.utils.FormatAddress(t)})).filter((function(t,e,n){return n.indexOf(t)===e})),t.next=25,Promise.all(e.map(function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=i.utils.AddressToObjectId(e),i.contentTypes[n]){t.next=11;break}return t.prev=2,t.next=5,i.ContentType({typeId:n,publicOnly:!0});case 5:i.contentTypes[n]=t.sent,t.next=11;break;case 8:t.prev=8,t.t0=t.catch(2),console.error(t.t0);case 11:case"end":return t.stop()}}),t,null,[[2,8]])})));return function(e){return t.apply(this,arguments)}}()));case 25:return t.abrupt("return",this.contentTypes);case 26:case"end":return t.stop()}}),t,this,[[8,17]])}))),e.ContentLibraries=s(o.mark((function t(){var e,n=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.Collection({collectionType:"libraries"});case 2:return e=t.sent,t.abrupt("return",e.map((function(t){return n.utils.AddressToLibraryId(t)})));case 4:case"end":return t.stop()}}),t,this)}))),e.ContentLibrary=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),r=A("qlibs",n),t.t0=this.utils,t.t1=this.HttpClient,t.next=7,this.authClient.AuthorizationHeader({libraryId:n});case 7:return t.t2=t.sent,t.t3=r,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=13,t.t0.ResponseToJson.call(t.t0,t.t5);case 13:return i=t.sent,t.abrupt("return",c(c({},i),{},{meta:i.meta||{}}));case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentLibraryOwner=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),t.t0=this.utils,t.next=5,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"owner",methodArgs:[]});case 5:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LibraryContentTypes=function(){var t=s(o.mark((function t(e){var n,r,i,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),this.Log("Retrieving library content types for ".concat(n)),t.next=5,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"contentTypesLength",methodArgs:[]});case 5:if(r=t.sent.toNumber(),this.Log("".concat(r," types")),0!==r){t.next=9;break}return t.abrupt("return",{});case 9:return i={},t.next=12,Promise.all(Array.from(new Array(r),function(){var t=s(o.mark((function t(e,r){var s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.ethClient.CallContractMethod({contractAddress:a.utils.HashToAddress(n),methodName:"contentTypes",methodArgs:[r]});case 2:return s=t.sent,u=a.utils.AddressToObjectId(s),t.next=6,a.ContentType({typeId:u});case 6:i[u]=t.sent;case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()));case 12:return this.Log(i),t.abrupt("return",i);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjects=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.filterOptions,i=void 0===r?{}:r,d(n),this.Log("Retrieving content objects from ".concat(n)),a=A("qlibs",n,"q"),s={filter:[]},i.cacheId&&(s.cache_id=i.cacheId),i.start&&(s.start=i.start),i.limit&&(s.limit=i.limit),i.select&&(s.select=i.select),i.sort&&(s.sort_by=i.sort,i.sortDesc&&(s.sort_descending=!0)),u={eq:":eq:",neq:":ne:",lt:":lt:",lte:":le:",gt:":gt:",gte:":ge:",cnt:":co:",ncnt:":nc:"},c=function(t){var e=t.key,n=t.type,r=t.filter;s.filter.push("".concat(e).concat(u[n]).concat(r))},i.filter&&(Array.isArray(i.filter)?i.filter.forEach((function(t){return c(t)})):c(i.filter)),this.Log("Filter options:"),this.Log(i),t.t0=this.utils,t.t1=this.HttpClient,t.next=19,this.authClient.AuthorizationHeader({libraryId:n});case 19:return t.t2=t.sent,t.t3=a,t.t4=s,t.t5={headers:t.t2,method:"GET",path:t.t3,queryParams:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=26,t.t0.ResponseToJson.call(t.t0,t.t6);case 26:return t.abrupt("return",t.sent);case 27:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObject=function(){var t=s(o.mark((function t(e){var n,r,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object: ".concat(n||""," ").concat(a||i||r)),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=A("q",a||i||r),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 9:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=15,t.t0.ResponseToJson.call(t.t0,t.t5);case 15:return t.abrupt("return",t.sent);case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectOwner=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,h(n),this.Log("Retrieving content object owner: ".concat(n)),t.t0=this.utils,t.next=6,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"owner",methodArgs:[]});case 6:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectTenantId=function(){var t=s(o.mark((function t(e){var n,r;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,(r=e.versionHash)?y(r):h(n),r&&(n=this.utils.DecodeVersionHash(r).objectId),this.objectTenantIds[n]){t.next=7;break}return t.next=6,this.authClient.MakeElvMasterCall({methodName:"elv_getTenantById",params:[this.contentSpaceId,n]});case 6:this.objectTenantIds[n]=t.sent;case 7:return t.abrupt("return",this.objectTenantIds[n]);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectLibraryId=function(){var t=s(o.mark((function t(e){var n,r,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)?y(r):h(n),r&&(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.authClient.AccessType(n);case 5:t.t0=t.sent,t.next=t.t0===this.authClient.ACCESS_TYPES.LIBRARY?8:t.t0===this.authClient.ACCESS_TYPES.OBJECT?9:t.t0===this.authClient.ACCESS_TYPES.OTHER?20:21;break;case 8:return t.abrupt("return",this.utils.AddressToLibraryId(this.utils.HashToAddress(n)));case 9:return this.objectLibraryIds[n]||(this.Log("Retrieving content object library ID: ".concat(n||r)),this.objectLibraryIds[n]=new Promise(function(){var t=s(o.mark((function t(e,r){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.t0=e,t.t1=i.utils,t.next=5,i.CallContractMethod({contractAddress:i.utils.HashToAddress(n),methodName:"libraryAddress"});case 5:t.t2=t.sent,t.t3=t.t1.AddressToLibraryId.call(t.t1,t.t2),(0,t.t0)(t.t3),t.next=13;break;case 10:t.prev=10,t.t4=t.catch(0),r(t.t4);case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}())),t.prev=10,t.next=13,this.objectLibraryIds[n];case 13:return t.abrupt("return",t.sent);case 16:throw t.prev=16,t.t1=t.catch(10),delete this.objectLibraryIds[n],t.t1;case 20:throw Error("Unable to retrieve library ID for ".concat(r||n,": Unknown type. (wrong network or deleted object?)"));case 21:return t.abrupt("return",this.contentSpaceLibraryId);case 22:case"end":return t.stop()}}),t,this,[[10,16]])})));return function(e){return t.apply(this,arguments)}}(),e.ProduceMetadataLinks=function(){var t=s(o.mark((function t(e){var n,r,a,u,f,l,p,d,h,y=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,u=e.path,f=void 0===u?"/":u,l=e.metadata,p=e.authorizationToken,d=e.noAuth,l&&"object"===i(l)){t.next=3;break}return t.abrupt("return",l);case 3:if(!Array.isArray(l)){t.next=7;break}return t.next=6,this.utils.LimitedMap(5,l,function(){var t=s(o.mark((function t(e,i){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:A(f,i.toString()),metadata:e,authorizationToken:p,noAuth:d});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}());case 6:return t.abrupt("return",t.sent);case 7:if(!l["/"]||!l["/"].match(/\.\/(rep|files)\/.+/)&&!l["/"].match(/^\/?qfab\/([\w]+)\/?(rep|files)\/.+/)){t.next=16;break}return t.t0=c,t.t1=c({},l),t.t2={},t.next=13,this.LinkUrl({libraryId:n,objectId:r,versionHash:a,linkPath:f,authorizationToken:p,noAuth:d});case 13:return t.t3=t.sent,t.t4={url:t.t3},t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t4));case 16:return h={},t.next=19,this.utils.LimitedMap(5,Object.keys(l),function(){var t=s(o.mark((function t(e){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:A(f,e),metadata:l[e],authorizationToken:p,noAuth:d});case 2:h[e]=t.sent;case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 19:return t.abrupt("return",h);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.MetadataAuth=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p,d,h;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.path,s=void 0===a?"/":a,u=e.channelAuth,c=void 0!==u&&u,A=e.noAuth,f=void 0!==A&&A,m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),f=this.noAuth||f||this.staticToken,l=f,f){t.next=14;break}return t.next=8,this.Visibility({id:r});case 8:return d=t.sent,t.next=11,this.AccessType({id:r});case 11:p=t.sent,l=(s||"").replace(/^\/+/,"").startsWith("public"),f=d>=10||l&&d>=1;case 14:if(!this.oauthToken){t.next=22;break}return t.next=17,this.authClient.KMSAddress({objectId:r,versionHash:i});case 17:if(!(h=t.sent)||this.utils.EqualAddress(h,this.utils.nullAddress)){t.next=22;break}return t.next=21,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,channelAuth:!0,oauthToken:this.oauthToken});case 21:return t.abrupt("return",t.sent);case 22:if(this.inaccessibleLibraries[n]||!l||p!==this.authClient.ACCESS_TYPES.OBJECT||c){t.next=48;break}if(t.prev=23,t.t0=this.authClient,t.t1=n,t.t1){t.next=30;break}return t.next=29,this.ContentObjectLibraryId({objectId:r,versionHash:i});case 29:t.t1=t.sent;case 30:return t.t2=t.t1,t.t3=f,t.t4={libraryId:t.t2,noAuth:t.t3},t.next=35,t.t0.AuthorizationToken.call(t.t0,t.t4);case 35:return t.abrupt("return",t.sent);case 38:if(t.prev=38,t.t5=t.catch(23),!t.t5.message||!t.t5.message.toLowerCase().startsWith("access denied")){t.next=45;break}return this.inaccessibleLibraries[n]=!0,t.next=44,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,noAuth:f,channelAuth:c});case 44:return t.abrupt("return",t.sent);case 45:throw t.t5;case 46:t.next=51;break;case 48:return t.next=50,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,noAuth:f,channelAuth:c});case 50:return t.abrupt("return",t.sent);case 51:case"end":return t.stop()}}),t,this,[[23,38]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectMetadata=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,l,p,d,h,y,g,b,I,C,w,E,B,Q,k,x,S,_,M,D,R,O,j,N,T,P,L=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.metadataSubtree,u=void 0===s?"/":s,l=e.localizationSubtree,p=e.queryParams,d=void 0===p?{}:p,h=e.select,y=void 0===h?[]:h,g=e.remove,b=void 0===g?[]:g,I=e.authorizationToken,C=e.noAuth,w=void 0!==C&&C,E=e.resolveLinks,B=void 0!==E&&E,Q=e.resolveIncludeSource,k=void 0!==Q&&Q,x=e.resolveIgnoreErrors,S=void 0!==x&&x,_=e.linkDepthLimit,M=void 0===_?1:_,D=e.produceLinkUrls,R=void 0!==D&&D,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object metadata: ".concat(n||""," ").concat(r||i," ").concat(a||"","\n Subtree: ").concat(u)),d=c({},d||{}),i&&(r=this.utils.DecodeVersionHash(i).objectId),O=A("q",a||i||r,"meta",u),i){t.next=12;break}if(n){t.next=11;break}return t.next=10,this.ContentObjectLibraryId({objectId:r});case 10:n=t.sent;case 11:O=A("qlibs",n,O);case 12:return t.next=14,this.MetadataAuth({libraryId:n,objectId:r,versionHash:i,path:u,noAuth:w});case 14:return j=t.sent,N=[I,d.authorization,j].flat().filter((function(t){return t})),delete d.authorization,t.prev=17,t.next=20,this.utils.ResponseToJson(this.HttpClient.Request({headers:{Authorization:N.map((function(t){return"Bearer ".concat(t)}))},queryParams:c(c({},d),{},{select:y,remove:b,link_depth:M,resolve:B,resolve_include_source:k,resolve_ignore_errors:S}),method:"GET",path:O}));case 20:T=t.sent,t.next=33;break;case 23:if(t.prev=23,t.t0=t.catch(17),404===t.t0.status){t.next=27;break}throw t.t0;case 27:if(!f.get(t.t0.body,"errors[0].cause.cause.cause.qwtoken")){t.next=32;break}throw t.t0;case 32:T="/"===u?{}:void 0;case 33:if(!R){t.next=37;break}return t.next=36,this.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:i,path:u,metadata:T,authorizationToken:I,noAuth:w});case 36:T=t.sent;case 37:if(l){t.next=39;break}return t.abrupt("return",T);case 39:return t.prev=39,t.next=42,this.ContentObjectMetadata(c(c({},L[0]),{},{metadataSubtree:l,localizationSubtree:void 0}));case 42:return P=t.sent,t.abrupt("return",v({},T,P,(function(t,e){return null===e||""===e?t:void 0})));case 46:return t.prev=46,t.t1=t.catch(39),this.Log(t.t1,!0),t.abrupt("return",T);case 50:case"end":return t.stop()}}),t,this,[[17,23],[39,46]])})));return function(e){return t.apply(this,arguments)}}(),e.AssetMetadata=function(){var t=s(o.mark((function t(e){var n,i,a,s,u,f,l,p,d,h=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,i=e.objectId,a=e.versionHash,s=e.metadata,u=e.localization,f=e.noAuth,l=e.produceLinkUrls,p=void 0!==l&&l,m({libraryId:n,objectId:i,versionHash:a}),i||(i=this.utils.DecodeVersionHash(a).objectId),s){t.next=12;break}return t.next=6,this.ContentObjectMetadata({libraryId:n,objectId:i,versionHash:a,metadataSubtree:"public/asset_metadata",resolveLinks:!0,linkDepthLimit:2,resolveIgnoreErrors:!0,produceLinkUrls:p,noAuth:f});case 6:if(t.t0=t.sent,t.t0){t.next=9;break}t.t0={};case 9:s=t.t0,t.next=16;break;case 12:if(!p){t.next=16;break}return t.next=15,this.ProduceMetadataLinks({libraryId:n,objectId:i,versionHash:a,path:A("public","asset_metadata"),metadata:s,noAuth:f});case 15:s=t.sent;case 16:return s.info||(s.info={}),d=c({},s),u&&u.reverse().forEach((function(t){var e,n=(e=h.utils).SafeTraverse.apply(e,[s].concat(r(t)))||{};d=v({},d,n,(function(t,e){return null===e||""===e?t:void 0}))})),t.abrupt("return",d);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectVersions=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,m({libraryId:n,objectId:r}),this.Log("Retrieving content object versions: ".concat(n||""," ").concat(r)),i=A("qid",r),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r});case 8:return t.t2=t.sent,t.t3=i,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t5));case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LatestVersionHash=function(){var t=s(o.mark((function t(e){var n,r,i,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)&&(n=this.utils.DecodeVersionHash(r).objectId),h(n),t.prev=3,t.next=6,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"objectHash"});case 6:i=t.sent,t.next=11;break;case 9:t.prev=9,t.t0=t.catch(3);case 11:if(i){t.next=25;break}return t.prev=12,t.next=15,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"countVersionHashes"});case 15:a=t.sent,t.next=20;break;case 18:t.prev=18,t.t1=t.catch(12);case 20:if(a.toNumber()){t.next=22;break}throw Error("Unable to determine latest version hash for ".concat(r||n," - Item deleted?"));case 22:return t.next=24,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"versionHashes",methodArgs:[a-1]});case 24:i=t.sent;case 25:return t.abrupt("return",i);case 26:case"end":return t.stop()}}),t,this,[[3,9],[12,18]])})));return function(e){return t.apply(this,arguments)}}(),e.AvailableDRMs=s(o.mark((function t(){var e,n,r,i,a,s,u,c,A;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=["clear","aes-128"],"undefined"!=typeof window){t.next=3;break}return t.abrupt("return",e);case 3:if(window.navigator&&window.navigator.userAgent&&((n=window.navigator.userAgent.match(/(iPad|iPhone|iphone|iPod).*?(OS |os |OS_)(\d+((_|\.)\d)?((_|\.)\d)?)/))&&n[3]&&(r=n[3].split("_"),i=parseInt(r[0]),a=parseInt(r[1]),(i>13||13===i&&a>=1)&&(e[1]="sample-aes",e[2]="fairplay")),/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent)&&(s=window.navigator.userAgent.match(/.+Version\/(\d+)\.(\d+)/))&&s[2]&&(u=parseInt(s[1]),c=parseInt(s[2]),(u>13||13===u&&c>=1)&&(e[1]="sample-aes",e[2]="fairplay"))),"undefined"==typeof window||"function"==typeof window.navigator.requestMediaKeySystemAccess){t.next=6;break}return t.abrupt("return",e);case 6:return t.prev=6,A=[{initDataTypes:["cenc"],audioCapabilities:[{contentType:'audio/mp4;codecs="mp4a.40.2"'}],videoCapabilities:[{contentType:'video/mp4;codecs="avc1.42E01E"'}]}],t.next=10,navigator.requestMediaKeySystemAccess("com.widevine.alpha",A);case 10:e.push("widevine"),t.next=15;break;case 13:t.prev=13,t.t0=t.catch(6);case 15:return t.abrupt("return",e);case 16:case"end":return t.stop()}}),t,null,[[6,13]])}))),e.PlayoutPathResolution=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,f,l,p,d,h,y,g,b,m,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.handler,c=e.offering,f=void 0===c?"":c,l=e.signedLink,p=void 0!==l&&l,d=e.authorizationToken,n){t.next=5;break}return t.next=4,this.ContentObjectLibraryId({objectId:r});case 4:n=t.sent;case 5:if(i){t.next=9;break}return t.next=8,this.LatestVersionHash({objectId:r});case 8:i=t.sent;case 9:if(h=A("qlibs",n,"q",a||i,"rep",u,f,"options.json"),!s){t.next=26;break}return t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:s,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:d});case 13:if(v=t.sent,m=!!v&&!!v["/"]&&!v["/"].endsWith("options.json"),h=A("qlibs",n,"q",a||i,"meta",s),p){t.next=25;break}return t.next=19,this.LinkTarget({libraryId:n,objectId:r,versionHash:i,writeToken:a,linkPath:s,linkInfo:v,authorizationToken:d});case 19:return b=t.sent,g=this.utils.DecodeVersionHash(b).objectId,t.next=23,this.ContentObjectLibraryId({objectId:g});case 23:y=t.sent,m||f||(h=A("q",b,"rep",u,"options.json"));case 25:m&&(h=A(h,f,"options.json"));case 26:return t.abrupt("return",{path:h,multiOfferingLink:m,linkTarget:{libraryId:y,objectId:g,versionHash:b}});case 27:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AvailableOfferings=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.writeToken,a=e.linkPath,s=e.signedLink,u=e.directLink,c=e.handler,A=void 0===c?"playout":c,f=e.authorizationToken,n||(n=this.utils.DecodeVersionHash(r).objectId),!u){t.next=15;break}return t.t0=this,t.next=6,this.ContentObjectLibraryId({objectId:n});case 6:return t.t1=t.sent,t.t2=n,t.t3=r,t.t4=a,t.t5=f,t.t6={libraryId:t.t1,objectId:t.t2,versionHash:t.t3,metadataSubtree:t.t4,resolveLinks:!0,authorizationToken:t.t5},t.next=14,t.t0.ContentObjectMetadata.call(t.t0,t.t6);case 14:return t.abrupt("return",t.sent);case 15:return t.next=17,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:s,handler:A,authorizationToken:f});case 17:return l=t.sent,p=l.path,t.prev=19,t.t7=f,t.next=23,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 23:return t.t8=t.sent,d=[t.t7,t.t8].flat().filter((function(t){return t})),t.next=27,this.utils.ResponseToJson(this.HttpClient.Request({path:p,method:"GET",headers:{Authorization:"Bearer ".concat(d.join(","))}}));case 27:return t.abrupt("return",t.sent);case 30:if(t.prev=30,t.t9=t.catch(19),!t.t9.status||500!==parseInt(t.t9.status)){t.next=34;break}return t.abrupt("return",{});case 34:throw t.t9;case 35:case"end":return t.stop()}}),t,this,[[19,30]])})));return function(e){return t.apply(this,arguments)}}(),e.PlayoutOptions=function(){var t=s(o.mark((function t(e){var n,r,i,u,f,l,p,d,g,b,m,v,I,C,w,E,B,Q,k,x,S,_,M,D,R,O,j,N,T,P,L,F,U,H,G,Y,q,K,z,J,V,W,Z,X,$,tt,et=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.offeringURI,r=e.objectId,i=e.versionHash,u=e.writeToken,f=e.linkPath,l=e.signedLink,p=void 0!==l&&l,d=e.protocols,g=void 0===d?["dash","hls"]:d,b=e.handler,m=void 0===b?"playout":b,v=e.offering,I=void 0===v?"default":v,C=e.playoutType,w=e.drms,E=void 0===w?[]:w,B=e.context,Q=e.hlsjsProfile,k=void 0===Q||Q,x=e.authorizationToken,S=e.options,_=void 0===S?{}:S,!n){t.next=8;break}if(M=n.match(/(hq__[^/]+)\/rep\/([^/]+)\/([^/]+)\/options.json/),i=M[1],m=M[2],I=M[3],i&&m&&I){t.next=8;break}throw Error("Invalid offering URI: ".concat(n));case 8:if(i?y(i):h(r),g=g.map((function(t){return t.toLowerCase()})),E=E.map((function(t){return t.toLowerCase()})),r){t.next=15;break}r=this.utils.DecodeVersionHash(i).objectId,t.next=19;break;case 15:if(i){t.next=19;break}return t.next=18,this.LatestVersionHash({objectId:r});case 18:i=t.sent;case 19:return t.next=21,this.ContentObjectLibraryId({objectId:r});case 21:if(D=t.sent,t.prev=22,f){t.next=29;break}return R=A("public","asset_metadata","sources",I),t.next=27,this.ContentObjectMetadata({libraryId:D,objectId:r,versionHash:i,metadataSubtree:R,authorizationToken:x});case 27:t.sent&&(f=R);case 29:t.next=33;break;case 31:t.prev=31,t.t0=t.catch(22);case 33:return t.next=35,this.PlayoutPathResolution({libraryId:D,objectId:r,versionHash:i,writeToken:u,linkPath:f,signedLink:p,handler:m,offering:I,authorizationToken:x});case 35:if(O=t.sent,j=O.path,N=O.linkTarget,t.t1=this.authClient,t.t2=N.objectId||r,t.t3=N.versionHash||i,t.t3){t.next=45;break}return t.next=44,this.LatestVersionHash({objectId:r});case 44:t.t3=t.sent;case 45:return t.t4=t.t3,t.t5=g,t.t6=E,t.t7=B,t.t8={objectId:t.t2,versionHash:t.t4,protocols:t.t5,drms:t.t6,context:t.t7},T=t.t1.AudienceData.call(t.t1,t.t8),t.t9=x,t.next=54,this.authClient.AuthorizationToken({libraryId:D,objectId:r,channelAuth:!0,oauthToken:this.oauthToken,audienceData:T});case 54:return t.t10=t.sent,P=[t.t9,t.t10].flat().filter((function(t){return t})),L=c({authorization:P,resolve:!!f},_),t.t11=Object,t.next=60,this.utils.ResponseToJson(this.HttpClient.Request({path:j,method:"GET",queryParams:L}));case 60:if(t.t12=t.sent,F=t.t11.values.call(t.t11,t.t12),p||!N.versionHash){t.next=68;break}return t.t13=x,t.next=66,this.authClient.AuthorizationToken({libraryId:N.libraryId,objectId:N.objectId,channelAuth:!0,oauthToken:this.oauthToken,audienceData:T});case 66:t.t14=t.sent,L.authorization=[t.t13,t.t14].flat().filter((function(t){return t}));case 68:U={},Y=0;case 70:if(!(Y<F.length)){t.next=116;break}if(q=F[Y],K=q.properties.protocol,z=q.properties.drm,H=H||q.sid,G=G||!!q.properties.multiview,H&&(L.sid=H),J=q.uri.split("?")[0],C&&(J=J.replace("playlist","playlist-".concat(C))),V=q.properties.license_servers,W=q.properties.cert,k&&"hls"===K&&"aes-128"===z&&(L.player_profile="hls-js"),t.t15=c,t.t16=c({},U[K]||{}),t.t17={},t.t18=c,t.t19=c({},(U[K]||{}).playoutMethods||{}),t.t20={},t.t21=a,t.t22={},t.t23=z||"clear",!p){t.next=97;break}return t.next=94,this.LinkUrl({versionHash:i,linkPath:A(f,I,J),queryParams:L,noAuth:!0});case 94:t.t24=t.sent,t.next=100;break;case 97:return t.next=99,this.Rep({libraryId:N.libraryId||D,objectId:N.objectId||r,versionHash:N.versionHash||i,rep:A(m,I,J),noAuth:!0,queryParams:L});case 99:t.t24=t.sent;case 100:for(Z in t.t25=t.t24,t.t26=z?a({},z,{licenseServers:V,cert:W}):void 0,t.t27={playoutUrl:t.t25,drms:t.t26},t.t28=(0,t.t21)(t.t22,t.t23,t.t27),t.t29=(0,t.t18)(t.t19,t.t20,t.t28),t.t30={playoutMethods:t.t29},U[K]=(0,t.t15)(t.t16,t.t17,t.t30),U[K].playoutMethods)U[K].playoutMethods[Z].drms&&U[K].playoutMethods[Z].drms[z]&&U[K].playoutMethods[Z].drms[z].cert&&((X=new URL(U[K].playoutMethods[Z].playoutUrl)).pathname=X.pathname.split("/").slice(0,-1).concat(["drm.cert"]).join("/"),U[K].playoutMethods[Z].drms[z].cert_url=X.toString());if($=g.includes(K),tt=E.includes(z||"clear")||0===E.length&&!z,$&&tt){t.next=112;break}return t.abrupt("continue",113);case 112:(!U[K].playoutUrl||z&&"clear"!==z)&&(U[K].playoutUrl=U[K].playoutMethods[z||"clear"].playoutUrl,U[K].drms=U[K].playoutMethods[z||"clear"].drms);case 113:Y++,t.next=70;break;case 116:return G&&H&&(U.sessionId=H,U.multiview=!0,U.AvailableViews=s(o.mark((function t(){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=et.utils,t.next=3,et.HttpClient.Request({path:A("q",N.versionHash||i,"rep",m,I,"views.json"),method:"GET",queryParams:{sid:H,authorization:P}});case 3:return t.t1=t.sent,t.next=6,t.t0.ResponseToFormat.call(t.t0,"json",t.t1);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)}))),U.SwitchView=function(){var t=s(o.mark((function t(e){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,et.HttpClient.Request({path:A("q",N.versionHash||i,"rep",m,I,"select_view"),method:"POST",queryParams:{sid:H,authorization:P},body:{view:e}});case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),this.Log(U),t.abrupt("return",U);case 119:case"end":return t.stop()}}),t,this,[[22,31]])})));return function(e){return t.apply(this,arguments)}}(),e.BitmovinPlayoutOptions=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p,d,g,b,m,v,I,C,w,E,B,Q,k,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.versionHash,i=e.writeToken,a=e.linkPath,s=e.signedLink,u=void 0!==s&&s,c=e.protocols,A=void 0===c?["dash","hls"]:c,f=e.drms,l=void 0===f?[]:f,p=e.handler,d=void 0===p?"playout":p,g=e.offering,b=void 0===g?"default":g,m=e.playoutType,v=e.context,I=e.authorizationToken,C=e.options,w=void 0===C?{}:C,r?y(r):h(n),n||(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.PlayoutOptions({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:u,protocols:A,drms:l,handler:d,offering:b,playoutType:m,hlsjsProfile:!1,context:v,authorizationToken:I,options:w});case 5:return delete(E=t.sent).playoutMethods,t.next=9,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:u,handler:d,offering:b,authorizationToken:I});case 9:if(B=t.sent,Q=B.linkTarget,k=[],I&&k.push(I),!u&&Q.versionHash){t.next=21;break}return t.t0=k,t.next=17,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 17:t.t1=t.sent,t.t0.push.call(t.t0,t.t1),t.next=26;break;case 21:return t.t2=k,t.next=24,this.authClient.AuthorizationToken({libraryId:Q.libraryId,objectId:Q.objectId,channelAuth:!0,oauthToken:this.oauthToken});case 24:t.t3=t.sent,t.t2.push.call(t.t2,t.t3);case 26:return x={drm:{}},Object.keys(E).forEach((function(t){var e=E[t];x[t]=e.playoutUrl,e.drms&&Object.keys(e.drms).forEach((function(t){if(e.drms[t].licenseServers&&0!==e.drms[t].licenseServers.length){var n=function(t){return t.toLowerCase().startsWith("https")},r=e.drms[t].licenseServers;r.find(n)&&(r=r.filter(n));var i=r.sort((function(){return.5-Math.random()}))[0];x.drm[t]||(x.drm[t]={LA_URL:i,headers:{Authorization:"Bearer ".concat(k.flat().filter((function(t){return t})).join(","))}})}}))})),t.abrupt("return",x);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CallBitcodeMethod=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,f,l,p,d,h,y,g,b,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.method,u=e.queryParams,c=void 0===u?{}:u,f=e.body,l=void 0===f?{}:f,p=e.headers,d=void 0===p?{}:p,h=e.constant,y=void 0===h||h,g=e.format,b=void 0===g?"json":g,m({libraryId:n,objectId:r,versionHash:i}),s){t.next=4;break}throw"Bitcode method not specified";case 4:if(i&&(r=this.utils.DecodeVersionHash(i).objectId),v=A("q",a||i||r,"call",s),n&&(v=A("qlibs",n,v)),d.authorization||d.Authorization){t.next=12;break}return t.next=11,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!y});case 11:d.Authorization=t.sent.Authorization;case 12:return this.Log("Calling bitcode method: ".concat(n||""," ").concat(r||i," ").concat(a||"","\n ").concat(y?"GET":"POST"," ").concat(v,"\n Query Params:\n ").concat(JSON.stringify(c||""),"\n Body:\n ").concat(JSON.stringify(l||""),"\n Headers\n ").concat(JSON.stringify(d||""))),t.t0=this.utils,t.t1=b,t.next=17,this.HttpClient.Request({body:l,headers:d,method:y?"GET":"POST",path:v,queryParams:c,allowFailover:!1});case 17:return t.t2=t.sent,t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t2));case 19:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Rep=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p,d,h,y,g,b;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,A=void 0===c?"fabric":c,f=e.makeAccessRequest,l=void 0!==f&&f,p=e.channelAuth,d=void 0!==p&&p,h=e.noAuth,y=void 0!==h&&h,g=e.noCache,b=void 0!==g&&g,m({libraryId:n,objectId:r,versionHash:i}),a){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:i,rep:a,queryParams:u,service:A,makeAccessRequest:l,channelAuth:d,noAuth:y,noCache:b}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.PublicRep=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,A=void 0===c?"fabric":c,m({libraryId:n,objectId:r,versionHash:i}),a){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:i,publicRep:a,queryParams:u,service:A,noAuth:!0}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FabricUrl=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,f,l,p,d,h,y,g,b,v,I,C,w,E,B,Q,k,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.partHash,u=e.rep,f=e.publicRep,l=e.call,p=e.queryParams,d=void 0===p?{}:p,h=e.service,y=void 0===h?"fabric":h,g=e.channelAuth,b=void 0!==g&&g,v=e.makeAccessRequest,I=void 0!==v&&v,C=e.noAuth,w=void 0!==C&&C,E=e.noCache,B=void 0!==E&&E,(r||i)&&m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),this.Log("Building Fabric URL:\n libraryId: ".concat(n,"\n objectId: ").concat(r,"\n versionHash: ").concat(i,"\n writeToken: ").concat(a,"\n partHash: ").concat(s,"\n rep: ").concat(u,"\n publicRep: ").concat(f,"\n call: ").concat(l,"\n channelAuth: ").concat(b,"\n noAuth: ").concat(w,"\n noCache: ").concat(B,"\n queryParams: ").concat(JSON.stringify(d||{},null,2))),Q=[],d.authorization&&Q.push(d.authorization),w&&d.authorization){t.next=12;break}return t.t0=Q,t.next=10,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,channelAuth:b,makeAccessRequest:I,noAuth:w,noCache:B});case 10:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 12:if(d=c(c({},d),{},{authorization:Q.flat()}),!u&&!f||!r||i){t.next=17;break}return t.next=16,this.LatestVersionHash({objectId:r});case 16:i=t.sent;case 17:return k="",n?(k=A(k,"qlibs",n),(r||i)&&(k=A(k,"q",a||i||r))):i&&(k=A("q",i)),s?k=A(k,"data",s):u?k=A(k,"rep",u):f?k=A(k,"public",f):l&&(k=A(k,"call",l)),x=this.HttpClient,"search"===y?x=this.SearchHttpClient:"auth"===y&&(x=this.AuthHttpClient),t.abrupt("return",x.URL({path:k,queryParams:d}));case 23:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FileUrl=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,f,l,p,d,h,y;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.filePath,u=e.queryParams,f=void 0===u?{}:u,l=e.noCache,p=void 0!==l&&l,m({libraryId:n,objectId:r,versionHash:i}),s){t.next=4;break}throw"File path not specified";case 4:return i&&(r=this.utils.DecodeVersionHash(i).objectId),d=n?A("qlibs",n,"q",a||i||r):A("q",i),t.next=8,this.authClient.AuthorizationToken({libraryId:n,objectId:r,noCache:p});case 8:return h=t.sent,f=c(c({},f),{},{authorization:h}),t.next=12,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:A("files",s)});case 12:return y=t.sent,y&&y["."].encryption&&"cgck"===y["."].encryption.scheme?(d=A(d,"rep","files_download",s),f["header-x_decryption_mode"]="decrypt"):d=A(d,"files",s),t.abrupt("return",this.HttpClient.URL({path:d,queryParams:f}));case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectImageUrl=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.height,s=e.imagePath,u=void 0===s?"public/display_image":s,m({libraryId:n,objectId:r,versionHash:i}),i){t.next=6;break}return t.next=5,this.LatestVersionHash({objectId:r});case 5:i=t.sent;case 6:if(this.Log("Retrieving content object image url: ".concat(n," ").concat(r," ").concat(i)),this.objectImageUrls[i]){t.next=26;break}return t.prev=8,t.next=11,this.ContentObjectMetadata({versionHash:i,metadataSubtree:u});case 11:if(t.sent){t.next=15;break}return this.Log("No image url set: ".concat(n," ").concat(r," ").concat(i)),t.abrupt("return");case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(8),this.Log("Unable to query for image metadata: ".concat(n," ").concat(r," ").concat(i),!0),this.Log(t.t0,!0);case 21:return c={},a&&!isNaN(parseInt(a))&&(c.height=parseInt(a)),t.next=25,this.LinkUrl({versionHash:i,linkPath:u,queryParams:c});case 25:this.objectImageUrls[i]=t.sent;case 26:return t.abrupt("return",this.objectImageUrls[i]);case 27:case"end":return t.stop()}}),t,this,[[8,17]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectGraph=function(){var t=s(o.mark((function t(e){var n,r,i,a,u,c,f,l,p,d,h=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.autoUpdate,u=void 0!==a&&a,c=e.select,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object graph: ".concat(n||""," ").concat(r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),f=A("q",i||r,"links"),t.prev=5,t.t0=this.utils,t.t1=this.HttpClient,t.next=10,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 10:return t.t2=t.sent,t.t3={auto_update:u,select:c},t.t4=f,t.t5={headers:t.t2,queryParams:t.t3,method:"GET",path:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=17,t.t0.ResponseToJson.call(t.t0,t.t6);case 17:return t.abrupt("return",t.sent);case 20:if(t.prev=20,t.t7=t.catch(5),t.prev=22,(p=t.t7.body.errors[0].cause.cause.cause.cycle)&&0!==p.length){t.next=26;break}throw t.t7;case 26:return d={},t.next=29,Promise.all(p.map(function(){var t=s(o.mark((function t(e){var n,r;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!d[e]){t.next=2;break}return t.abrupt("return");case 2:return n=h.utils.DecodeVersionHash(e).objectId,t.next=5,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"public/asset_metadata/display_title"});case 5:if(t.t2=t.sent,t.t2){t.next=10;break}return t.next=9,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"public/name"});case 9:t.t2=t.sent;case 10:if(t.t1=t.t2,t.t1){t.next=15;break}return t.next=14,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"name"});case 14:t.t1=t.sent;case 15:if(t.t0=t.t1,t.t0){t.next=18;break}t.t0=n;case 18:r=t.t0,d[e]={name:r,objectId:n};case 20:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 29:l=p.map((function(t){return"".concat(d[t].name," (").concat(d[t].objectId,")")})),t.next=35;break;case 32:throw t.prev=32,t.t8=t.catch(22),t.t7;case 35:throw new Error("Cycle found in links: ".concat(l.join(" -> ")));case 36:case"end":return t.stop()}}),t,this,[[5,20],[22,32]])})));return function(e){return t.apply(this,arguments)}}(),e.LinkTarget=function(){var t=s(o.mark((function t(e){var n,r,a,s,u,c,A,f,l;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,s=e.writeToken,u=e.linkPath,c=e.authorizationToken,A=e.linkInfo,m({libraryId:n,objectId:r,versionHash:a}),s&&b(s),a&&(r=this.utils.DecodeVersionHash(a).objectId),!s||n){t.next=8;break}return t.next=7,this.ContentObjectLibraryId({objectId:r});case 7:n=t.sent;case 8:if(A){t.next=12;break}return t.next=11,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:s,metadataSubtree:u,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:c});case 11:A=t.sent;case 12:if(!A||!A["/"]){t.next=27;break}if((f=((A["/"]||"").match(/^\/?qfab\/([\w]+)\/?.+/)||[])[1])||(f=A["."].container),!f){t.next=19;break}return t.abrupt("return",f);case 19:if(!a){t.next=21;break}return t.abrupt("return",a);case 21:if(t.t0=a,t.t0){t.next=26;break}return t.next=25,this.LatestVersionHash({objectId:r});case 25:t.t0=t.sent;case 26:return t.abrupt("return",t.t0);case 27:return t.next=29,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:s,metadataSubtree:u,resolveIncludeSource:!0,authorizationToken:c});case 29:if((A=t.sent)&&A["."]){t.next=49;break}if("object"!==i(A)){t.next=38;break}if(t.t1=a,t.t1){t.next=37;break}return t.next=36,this.LatestVersionHash({objectId:r});case 36:t.t1=t.sent;case 37:return t.abrupt("return",t.t1);case 38:if(l=u.split("/").slice(0,-1).join("/")){t.next=46;break}if(t.t2=a,t.t2){t.next=45;break}return t.next=44,this.LatestVersionHash({objectId:r});case 44:t.t2=t.sent;case 45:return t.abrupt("return",t.t2);case 46:return t.next=48,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:s,metadataSubtree:l,resolveIncludeSource:!0,authorizationToken:c});case 48:A=t.sent;case 49:return t.abrupt("return",A["."].source);case 50:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LinkUrl=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,f,l,p,d,h,y,g,v,I;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.mimeType,f=e.authorizationToken,l=e.queryParams,p=void 0===l?{}:l,d=e.channelAuth,h=void 0!==d&&d,y=e.noAuth,g=void 0!==y&&y,m({libraryId:n,objectId:r,versionHash:i}),a&&b(a),s){t.next=5;break}throw Error("Link path not specified");case 5:return i&&(r=this.utils.DecodeVersionHash(i).objectId),v=n?A("qlibs",n,"q",a||i||r,"meta",s):A("q",i,"meta",s),I=[f],t.t0=I,t.next=11,this.MetadataAuth({libraryId:n,objectId:r,versionHash:i,path:s,channelAuth:h,noAuth:g});case 11:return t.t1=t.sent,t.t0.push.call(t.t0,t.t1),p.authorization&&I.push(p.authorization),p=c(c({},p),{},{authorization:I.flat().filter((function(t){return t})),resolve:!0}),u&&(p["header-accept"]=u),t.abrupt("return",this.HttpClient.URL({path:v,queryParams:p}));case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LinkData=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.queryParams,c=void 0===u?{}:u,A=e.format,f=void 0===A?"json":A,p=e.channelAuth,t.next=3,this.LinkUrl({libraryId:n,objectId:r,versionHash:i,writeToken:a,linkPath:s,queryParams:c,channelAuth:p});case 3:return d=t.sent,t.t0=this.utils,t.t1=f,t.next=8,l.Fetch(d);case 8:return t.t2=t.sent,t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t2));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateEncryptionConk=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.createKMSConk,u=void 0===s||s,!this.signer.remoteSigner){t.next=3;break}return t.abrupt("return");case 3:if(m({libraryId:n,objectId:r,versionHash:i}),b(a),r||(r=client.DecodeVersionHash(i).objectId),n){t.next=10;break}return t.next=9,this.ContentObjectLibraryId({objectId:r});case 9:n=t.sent;case 10:return c="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:a,metadataSubtree:c});case 13:if(!(A=t.sent)){t.next=20;break}return t.next=17,this.Crypto.DecryptCap(A,this.signer._signingKey().privateKey);case 17:this.encryptionConks[r]=t.sent,t.next=34;break;case 20:return t.next=22,this.Crypto.GeneratePrimaryConk({spaceId:this.contentSpaceId,objectId:r});case 22:return this.encryptionConks[r]=t.sent,t.t0=this,t.t1=n,t.t2=r,t.t3=a,t.t4=c,t.next=30,this.Crypto.EncryptConk(this.encryptionConks[r],this.signer._signingKey().publicKey);case 30:return t.t5=t.sent,t.t6={libraryId:t.t1,objectId:t.t2,writeToken:t.t3,metadataSubtree:t.t4,metadata:t.t5},t.next=34,t.t0.ReplaceMetadata.call(t.t0,t.t6);case 34:if(!u){t.next=64;break}return t.prev=35,t.next=38,this.authClient.KMSAddress({objectId:r});case 38:return f=t.sent,t.next=41,this.authClient.KMSInfo({objectId:r});case 41:return l=t.sent.publicKey,p="eluv.caps.ikms".concat(this.utils.AddressToHash(f)),t.next=45,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:a,metadataSubtree:p});case 45:if(t.sent){t.next=58;break}return t.t7=this,t.t8=n,t.t9=r,t.t10=a,t.t11=p,t.next=54,this.Crypto.EncryptConk(this.encryptionConks[r],l);case 54:return t.t12=t.sent,t.t13={libraryId:t.t8,objectId:t.t9,writeToken:t.t10,metadataSubtree:t.t11,metadata:t.t12},t.next=58,t.t7.ReplaceMetadata.call(t.t7,t.t13);case 58:t.next=64;break;case 60:t.prev=60,t.t14=t.catch(35),console.error("Failed to create encryption cap for KMS:"),console.error(t.t14);case 64:return t.abrupt("return",this.encryptionConks[r]);case 65:case"end":return t.stop()}}),t,this,[[35,60]])})));return function(e){return t.apply(this,arguments)}}(),e.EncryptionConk=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.download,u=void 0!==s&&s,m({libraryId:n,objectId:r,versionHash:i}),a&&b(a),r||(r=client.DecodeVersionHash(i).objectId),t.next=6,this.authClient.Owner({id:r});case 6:return c=t.sent,A="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=10,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,metadataSubtree:A});case 10:if(f=t.sent,this.utils.EqualAddress(c,this.signer.address)||f){t.next=21;break}if(!u){t.next=18;break}return t.next=15,this.authClient.ReEncryptionConk({libraryId:n,objectId:r,versionHash:i});case 15:return t.abrupt("return",t.sent);case 18:return t.next=20,this.authClient.EncryptionConk({libraryId:n,objectId:r,versionHash:i});case 20:return t.abrupt("return",t.sent);case 21:if(this.encryptionConks[r]){t.next=38;break}return l="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=25,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:l});case 25:if(!(p=t.sent)){t.next=32;break}return t.next=29,this.Crypto.DecryptCap(p,this.signer._signingKey().privateKey);case 29:this.encryptionConks[r]=t.sent,t.next=38;break;case 32:if(!a){t.next=37;break}return t.next=35,this.CreateEncryptionConk({libraryId:n,objectId:r,versionHash:i,writeToken:a,createKMSConk:!1});case 35:t.next=38;break;case 37:throw"No encryption conk present for "+r;case 38:return t.abrupt("return",this.encryptionConks[r]);case 39:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Encrypt=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,a=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i});case 4:return s=t.sent,t.next=7,this.Crypto.Encrypt(s,a);case 7:return u=t.sent,t.abrupt("return",u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Decrypt=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,a=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i,download:!0});case 4:return s=t.sent,t.next=7,this.Crypto.Decrypt(s,a);case 7:return u=t.sent,t.abrupt("return",u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessType=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,t.next=3,this.authClient.AccessType(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessInfo=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.args,h(n),r||(r=[0,[],[]]),this.Log("Retrieving access info: ".concat(n)),t.next=6,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"getAccessInfo",methodArgs:r});case 6:return i=t.sent,this.Log(i),t.abrupt("return",{visibilityCode:i[0],visible:i[0]>=1,accessible:i[0]>=10,editable:i[0]>=100,hasAccess:0===i[1],accessCode:i[1],accessCharge:this.utils.WeiToEther(i[2]).toString()});case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessRequest=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.args,s=void 0===a?[]:a,u=e.update,c=void 0!==u&&u,A=e.noCache,f=void 0!==A&&A,m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),t.next=5,this.authClient.MakeAccessRequest({libraryId:n,objectId:r,versionHash:i,args:s,update:c,skipCache:!0,noCache:f});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetAuthContext=function(t){var e=t.context;if(e&&Object.values(e).find((function(t){return"string"!=typeof t})))throw Error("Context must be a map of string->string");this.authContext=e},e.GenerateStateChannelToken=function(){var t=s(o.mark((function t(e){var n,r,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.context,a=e.noCache,s=void 0!==a&&a,r?y(r):h(n),!r){t.next=6;break}n=this.utils.DecodeVersionHash(r).objectId,t.next=10;break;case 6:if(this.stateChannelAccess[n]){t.next=10;break}return t.next=9,this.LatestVersionHash({objectId:n});case 9:r=t.sent;case 10:return this.stateChannelAccess[n]=r,t.next=13,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken,context:i,noCache:s});case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizeStateChannelAccess=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.percentComplete,r?y(r):h(n),!r){t.next=6;break}n=this.utils.DecodeVersionHash(r).objectId,t.next=13;break;case 6:if(!this.stateChannelAccess[n]){t.next=10;break}r=this.stateChannelAccess[n],t.next=13;break;case 10:return t.next=12,this.LatestVersionHash({objectId:n});case 12:r=t.sent;case 13:return this.stateChannelAccess[n]=void 0,t.next=16,this.authClient.ChannelContentFinalize({objectId:n,versionHash:r,percent:i});case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectAccessComplete=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.score,i=void 0===r?100:r,h(n),!(i<0||i>100)){t.next=4;break}throw Error("Invalid AccessComplete score: "+i);case 4:return t.next=6,this.authClient.AccessComplete({id:n,score:i});case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Collection=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.collectionType,["accessGroups","contentObjects","contentTypes","contracts","libraries"].includes(n)){t.next=4;break}throw new Error("Invalid collection type: "+n);case 4:if(!this.signer){t.next=10;break}return t.next=7,this.userProfileClient.WalletAddress();case 7:t.t0=t.sent,t.next=11;break;case 10:t.t0=void 0;case 11:if(t.t0){t.next=14;break}throw new Error("Unable to get collection: User wallet doesn't exist");case 14:return this.Log("Retrieving ".concat(n," contract collection for user ").concat(this.signer.address)),t.next=17,this.ethClient.MakeProviderCall({methodName:"send",args:["elv_getWalletCollection",[this.contentSpaceId,"iusr".concat(this.utils.AddressToHash(this.signer.address)),n]]});case 17:if(t.t1=t.sent,t.t1){t.next=20;break}t.t1=[];case 20:return t.abrupt("return",t.t1);case 21:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.VerifyContentObject=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,m({libraryId:n,objectId:r,versionHash:i}),t.next=4,ContentObjectVerification.VerifyContentObject({client:this,libraryId:n,objectId:r,versionHash:i});case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Proofs=function(){var t=s(o.mark((function t(e){var n,r,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.partHash,m({libraryId:n,objectId:r,versionHash:i}),g(a),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=A("q",i||r,"data",a,"proofs"),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 9:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t5));case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.QParts=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.partHash,a=e.format,s=void 0===a?"blob":a,m({libraryId:n,objectId:r,versionHash:versionHash}),g(i),u=A("qparts",i),t.t0=this.utils,t.t1=s,t.t2=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,partHash:i});case 9:return t.t3=t.sent,t.t4=u,t.t5={headers:t.t3,method:"GET",path:t.t4},t.t6=t.t2.Request.call(t.t2,t.t5),t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t6));case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()},function(t,e,n){var r=n(64)(n(32),"Map");t.exports=r},function(t,e,n){var r=n(32).Symbol;t.exports=r},function(t,e,n){(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r="object"==(void 0===e?"undefined":n(e))&&e&&e.Object===Object&&e;t.exports=r}).call(this,n(8))},function(t,e,n){var r=n(66),i=n(49);t.exports=function(t,e,n){(void 0!==n&&!i(t[e],n)||void 0===n&&!(e in t))&&r(t,e,n)}},function(t,e,n){var r=n(64),i=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=i},function(t,e,n){var r=n(270)(Object.getPrototypeOf,Object);t.exports=r},function(t,e){var n=Object.prototype;t.exports=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||n)}},function(t,e,n){var r=n(271),i=n(41),a=Object.prototype,o=a.hasOwnProperty,s=a.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(t){return i(t)&&o.call(t,"callee")&&!s.call(t,"callee")};t.exports=u},function(t,e){var n=Array.isArray;t.exports=n},function(t,e){t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},function(t,e,n){(function(t){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i=n(32),a=n(273),o="object"==r(e)&&e&&!e.nodeType&&e,s=o&&"object"==r(t)&&t&&!t.nodeType&&t,u=s&&s.exports===o?i.Buffer:void 0,c=(u?u.isBuffer:void 0)||a;t.exports=c}).call(this,n(18)(t))},function(t,e,n){var r=n(275),i=n(276),a=n(277),o=a&&a.isTypedArray,s=o?i(o):r;t.exports=s},function(t,e){t.exports=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}},function(t,e,n){var r=n(281),i=n(283),a=n(67);t.exports=function(t){return a(t)?r(t,!0):i(t)}},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=/^(?:0|[1-9]\d*)$/;t.exports=function(t,e){var i=n(t);return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&r.test(t))&&t>-1&&t%1==0&&t<e}},function(t,e){t.exports=function(t){return t}},function(t,e,n){(function(e){var r=n(9),i=n(10);void 0===globalThis.Buffer&&(globalThis.Buffer=n(5).Buffer);var a,o=n(103),s=n(123),u=n(22);if("undefined"==typeof crypto){var c=n(304);c.getRandomValues=function(t){return c.randomBytes(t.length)},globalThis.crypto=c}switch(u.Platform()){case u.PLATFORM_REACT_NATIVE:case u.PLATFORM_WEB:a=n(171).default;break;default:a=n(!function(){var t=new Error("Cannot find module '@eluvio/crypto/dist/elv-crypto.bundle.node'");throw t.code="MODULE_NOT_FOUND",t}()).default}var A,f,l,p,d,h={ElvCrypto:(d=i(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,h.elvCrypto){t.next=5;break}return t.next=4,(new a).init();case 4:h.elvCrypto=t.sent;case 5:return t.abrupt("return",h.elvCrypto);case 8:t.prev=8,t.t0=t.catch(0),console.error("Error initializing ElvCrypto:"),console.error(t.t0);case 12:case"end":return t.stop()}}),t,null,[[0,8]])}))),function(){return d.apply(this,arguments)}),EncryptedSize:function(t){var e=Math.floor(t/1e6)*h.EncryptedBlockSize(1e6);return t%1e6!=0&&(e+=h.EncryptedBlockSize(t%1e6)),e},EncryptedBlockSize:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=129,r=608,i=48,a=12*(i-1),o=12*i,s=Math.floor(t/a)*o;return t%a!=0&&(s+=o),e?s+r:s+n},EncryptConk:function(t,n){return i(r.mark((function i(){var a,o,s,c,A,f;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.ElvCrypto();case 2:return a=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=new Uint8Array(e.from(JSON.stringify(t))),r.next=7,a.encryptECIES(t,n);case 7:return o=r.sent,s=o.data,c=o.ephemeralKey,A=o.tag,f=e.concat([e.from(c),e.from(A),e.from(s)]),r.abrupt("return",u.B64(f));case 13:case"end":return r.stop()}}),i)})))()},DecryptCap:function(t,n){return i(r.mark((function i(){var a,o,s,u,c;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.ElvCrypto();case 2:return a=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=e.from(t,"base64"),o=t.slice(0,65),s=t.slice(65,81),u=t.slice(81),c=a.decryptECIES(new Uint8Array(u),n,new Uint8Array(o),new Uint8Array(s)),r.abrupt("return",JSON.parse(e.from(c).toString()));case 10:case"end":return r.stop()}}),i)})))()},GeneratePrimaryConk:function(t){return i(r.mark((function n(){var i,a,s,u,c,A,f;return r.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=t.spaceId,a=t.objectId,n.next=3,h.ElvCrypto();case 3:return s=n.sent,u=s.generatePrimaryKeys(),c=u.secretKey,A=u.publicKey,f=s.generateSymmetricKey().key,n.abrupt("return",{symm_key:"kpsy".concat(o.encode(e.from(f))),secret_key:"kpsk".concat(o.encode(e.from(c))),public_key:"kppk".concat(o.encode(e.from(A))),sid:i,qid:a});case 7:case"end":return n.stop()}}),n)})))()},GenerateTargetConk:function(){return i(r.mark((function t(){var n,i,a,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,i=n.generateTargetKeys(),a=i.secretKey,s=i.publicKey,t.abrupt("return",{secret_key:"kpsk".concat(o.encode(e.from(a))),public_key:"ktpk".concat(o.encode(e.from(s)))});case 5:case"end":return t.stop()}}),t)})))()},CapToConk:function(t){var e=function(t){return new Uint8Array(o.decode(t.slice(4)))};return{symmetricKey:e(t.symm_key),secretKey:e(t.secret_key),publicKey:e(t.public_key)}},EncryptionContext:function(t){return i(r.mark((function e(){var n,i,a,o,s,u,c;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,h.ElvCrypto();case 2:return n=e.sent,i=h.CapToConk(t),a=i.symmetricKey,o=i.secretKey,(s=i.publicKey).length===n.PRIMARY_PK_KEY_SIZE?(c=n.CRYPTO_TYPE_PRIMARY,u=n.newPrimaryContext(s,o,a)):(c=n.CRYPTO_TYPE_TARGET,u=n.newTargetDecryptionContext(o,a)),e.abrupt("return",{context:u,type:c});case 6:case"end":return e.stop()}}),e)})))()},Encrypt:(p=i(r.mark((function t(n,i){var a,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.OpenEncryptionStream(n);case 2:if(a=t.sent,e.isBuffer(i)||i instanceof ArrayBuffer){t.next=9;break}return t.t0=e,t.next=7,new Response(i).arrayBuffer();case 7:t.t1=t.sent,i=t.t0.from.call(t.t0,t.t1);case 9:for(o=new Uint8Array(i),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),a.write(o.slice(s,u));return a.end(),c=[],t.next=15,new Promise((function(t,e){a.on("data",(function(t){c.push(t)})).on("finish",(function(){t()})).on("error",(function(t){e(t)}))}));case 15:return t.abrupt("return",e.concat(c));case 16:case"end":return t.stop()}}),t)}))),function(t,e){return p.apply(this,arguments)}),OpenEncryptionStream:(l=i(r.mark((function t(e){var n,i,a,o,u;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,t.next=5,h.EncryptionContext(e);case 5:return i=t.sent,a=i.context,o=new s.PassThrough,u=n.createCipher(a),t.abrupt("return",o.pipe(u).on("finish",(function(){a.free()})).on("error",(function(t){throw Error(t)})));case 10:case"end":return t.stop()}}),t)}))),function(t){return l.apply(this,arguments)}),Decrypt:(f=i(r.mark((function t(n,i){var a,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.OpenDecryptionStream(n);case 2:for(a=t.sent,o=new Uint8Array(i),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),a.write(o.slice(s,u));return a.end(),c=[],t.next=9,new Promise((function(t,e){a.on("data",(function(t){c.push(t)})).on("finish",(function(){t()})).on("error",(function(t){e(t)}))}));case 9:return t.abrupt("return",e.concat(c));case 10:case"end":return t.stop()}}),t)}))),function(t,e){return f.apply(this,arguments)}),OpenDecryptionStream:(A=i(r.mark((function t(e){var n,i,a,o,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,t.next=5,h.EncryptionContext(e);case 5:return i=t.sent,a=i.context,o=i.type,u=new s.PassThrough,c=n.createDecipher(o,a),t.abrupt("return",u.pipe(c).on("finish",(function(){a.free()})).on("error",(function(t){throw Error(t)})));case 11:case"end":return t.stop()}}),t)}))),function(t){return A.apply(this,arguments)})};t.exports=h}).call(this,n(5).Buffer)},function(t,e,n){t.exports=i;var r=n(42).EventEmitter;function i(){r.call(this)}n(3)(i,r),i.Readable=n(68),i.Writable=n(300),i.Duplex=n(301),i.Transform=n(302),i.PassThrough=n(303),i.Stream=i,i.prototype.pipe=function(t,e){var n=this;function i(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function a(){n.readable&&n.resume&&n.resume()}n.on("data",i),t.on("drain",a),t._isStdio||e&&!1===e.end||(n.on("end",s),n.on("close",u));var o=!1;function s(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(A(),0===r.listenerCount(this,"error"))throw t}function A(){n.removeListener("data",i),t.removeListener("drain",a),n.removeListener("end",s),n.removeListener("close",u),n.removeListener("error",c),t.removeListener("error",c),n.removeListener("end",A),n.removeListener("close",A),t.removeListener("close",A)}return n.on("error",c),t.on("error",c),n.on("end",A),n.on("close",A),t.on("close",A),t.emit("pipe",n),t}},function(t,e,n){"use strict";(function(e,r){var i=n(53);t.exports=m;var a,o=n(294);m.ReadableState=b;n(42).EventEmitter;var s=function(t,e){return t.listeners(e).length},u=n(125),c=n(69).Buffer,A=e.Uint8Array||function(){};var f=Object.create(n(43));f.inherits=n(3);var l=n(295),p=void 0;p=l&&l.debuglog?l.debuglog("stream"):function(){};var d,h=n(296),y=n(126);f.inherits(m,u);var g=["error","close","destroy","pause","resume"];function b(t,e){t=t||{};var r=e instanceof(a=a||n(28));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,o=t.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(o||0===o)?o:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new h,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=n(44).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function m(t){if(a=a||n(28),!(this instanceof m))return new m(t);this._readableState=new b(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function v(t,e,n,r,i){var a,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,w(t)}(t,o)):(i||(a=function(t,e){var n;r=e,c.isBuffer(r)||r instanceof A||"string"==typeof e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(o,e)),a?t.emit("error",a):o.objectMode||e&&e.length>0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):I(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?I(t,o,e,!1):B(t,o)):I(t,o,e,!1))):r||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(o)}function I(t,e,n,r){e.flowing&&0===e.length&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,r?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&w(t)),B(t,e)}Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),m.prototype.destroy=y.destroy,m.prototype._undestroy=y.undestroy,m.prototype._destroy=function(t,e){this.push(null),e(t)},m.prototype.push=function(t,e){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof t&&((e=e||r.defaultEncoding)!==r.encoding&&(t=c.from(t,e),e=""),n=!0),v(this,t,e,!1,n)},m.prototype.unshift=function(t){return v(this,t,null,!0,!1)},m.prototype.isPaused=function(){return!1===this._readableState.flowing},m.prototype.setEncoding=function(t){return d||(d=n(44).StringDecoder),this._readableState.decoder=new d(t),this._readableState.encoding=t,this};function C(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function w(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(E,t):E(t))}function E(t){p("emit readable"),t.emit("readable"),S(t)}function B(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(Q,t,e))}function Q(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(p("maybeReadMore read 0"),t.read(0),n!==e.length);)n=e.length;e.readingMore=!1}function k(t){p("readable nexttick read 0"),t.read(0)}function x(t,e){e.reading||(p("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),S(t),e.flowing&&!e.reading&&t.read(0)}function S(t){var e=t._readableState;for(p("flow",e.flowing);e.flowing&&null!==t.read(););}function _(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;t<e.head.data.length?(r=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):r=t===e.head.data.length?e.shift():n?function(t,e){var n=e.head,r=1,i=n.data;t-=i.length;for(;n=n.next;){var a=n.data,o=t>a.length?a.length:t;if(o===a.length?i+=a:i+=a.slice(0,t),0===(t-=o)){o===a.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=a.slice(o));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var a=r.data,o=t>a.length?a.length:t;if(a.copy(n,n.length-t,0,o),0===(t-=o)){o===a.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=a.slice(o));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}m.prototype.read=function(t){p("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):w(this),null;if(0===(t=C(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,i=e.needReadable;return p("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&p("length less than watermark",i=!0),e.ended||e.reading?p("reading or ended",i=!1):i&&(p("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=C(n,e))),null===(r=t>0?_(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&M(this)),null!==r&&this.emit("data",r),r},m.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},m.prototype.pipe=function(t,e){var n=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,p("pipe count=%d opts=%j",a.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?A:m;function c(e,r){p("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),t.removeListener("close",g),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",A),n.removeListener("end",m),n.removeListener("data",h),l=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function A(){p("onend"),t.end()}a.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var f=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,S(t))}}(n);t.on("drain",f);var l=!1;var d=!1;function h(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==R(a.pipes,t))&&!l&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(e){p("onerror",e),m(),t.removeListener("error",y),0===s(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",b),m()}function b(){p("onfinish"),t.removeListener("close",g),m()}function m(){p("unpipe"),n.unpipe(t)}return n.on("data",h),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",y),t.once("close",g),t.once("finish",b),t.emit("pipe",n),a.flowing||(p("pipe resume"),n.resume()),t},m.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].emit("unpipe",this,n);return this}var o=R(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,n)),this},m.prototype.on=function(t,e){var n=u.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&w(this):i.nextTick(k,this))}return n},m.prototype.addListener=m.prototype.on,m.prototype.resume=function(){var t=this._readableState;return t.flowing||(p("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(x,t,e))}(this,t)),this},m.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},m.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i in t.on("end",(function(){if(p("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(p("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<g.length;a++)t.on(g[a],this.emit.bind(this,g[a]));return this._read=function(e){p("wrapped _read",e),r&&(r=!1,t.resume())},this},Object.defineProperty(m.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),m._fromList=_}).call(this,n(8),n(11))},function(t,e,n){t.exports=n(42).EventEmitter},function(t,e,n){"use strict";var r=n(53);function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?(r.nextTick(i,n,t),n._writableState&&(n._writableState.errorEmitted=!0)):e&&e(t)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(t,e,n){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(t){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}}).call(this,n(8))},function(t,e,n){"use strict";t.exports=o;var r=n(28),i=Object.create(n(43));function a(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);r.call(this,t),this._transformState={afterTransform:a.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",s)}function s(){var t=this;"function"==typeof this._flush?this._flush((function(e,n){u(t,e,n)})):u(this,null,null)}function u(t,e,n){if(e)return t.emit("error",e);if(null!=n&&t.push(n),t._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(t._transformState.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}i.inherits=n(3),i.inherits(o,r),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,r.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,n){throw new Error("_transform() is not implemented")},o.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},o.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},o.prototype._destroy=function(t,e){var n=this;r.prototype._destroy.call(this,t,(function(t){e(t),n.emit("close")}))}},function(t,e,n){"use strict";var r=n(4).Buffer,i=n(72).Transform;function a(t){i.call(this),this._block=r.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}n(3)(a,i),a.prototype._transform=function(t,e,n){var r=null;try{this.update(t,e)}catch(t){r=t}n(r)},a.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},a.prototype.update=function(t,e){if(function(t,e){if(!r.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");r.isBuffer(t)||(t=r.from(t,e));for(var n=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var a=this._blockOffset;a<this._blockSize;)n[a++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)n[this._blockOffset++]=t[i++];for(var o=0,s=8*t.length;s>0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},a.prototype._update=function(){throw new Error("_update is not implemented")},a.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return e},a.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=a},function(t,e,n){"use strict";(function(e,r){var i;t.exports=B,B.ReadableState=E;n(42).EventEmitter;var a=function(t,e){return t.listeners(e).length},o=n(131),s=n(5).Buffer,u=e.Uint8Array||function(){};var c,A=n(305);c=A&&A.debuglog?A.debuglog("stream"):function(){};var f,l,p,d=n(306),h=n(132),y=n(133).getHighWaterMark,g=n(34).codes,b=g.ERR_INVALID_ARG_TYPE,m=g.ERR_STREAM_PUSH_AFTER_EOF,v=g.ERR_METHOD_NOT_IMPLEMENTED,I=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(B,o);var C=h.errorOrDestroy,w=["error","close","destroy","pause","resume"];function E(t,e,r){i=i||n(35),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,"readableHighWaterMark",r),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=n(44).StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function B(t){if(i=i||n(35),!(this instanceof B))return new B(t);var e=this instanceof i;this._readableState=new E(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function Q(t,e,n,r,i){c("readableAddChunk",e);var a,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(c("onEofChunk"),e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?S(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,_(t)))}(t,o);else if(i||(a=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new b("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),a)C(t,a);else if(o.objectMode||e&&e.length>0)if("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),r)o.endEmitted?C(t,new I):k(t,o,e,!0);else if(o.ended)C(t,new m);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?k(t,o,e,!1):M(t,o)):k(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function k(t,e,n,r){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",n)):(e.length+=e.objectMode?1:n.length,r?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&S(t)),M(t,e)}Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),B.prototype.destroy=h.destroy,B.prototype._undestroy=h.undestroy,B.prototype._destroy=function(t,e){e(t)},B.prototype.push=function(t,e){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof t&&((e=e||r.defaultEncoding)!==r.encoding&&(t=s.from(t,e),e=""),n=!0),Q(this,t,e,!1,n)},B.prototype.unshift=function(t){return Q(this,t,null,!0,!1)},B.prototype.isPaused=function(){return!1===this._readableState.flowing},B.prototype.setEncoding=function(t){f||(f=n(44).StringDecoder);var e=new f(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};function x(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;c("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(_,t))}function _(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(D,t,e))}function D(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var n=e.length;if(c("maybeReadMore read 0"),t.read(0),n===e.length)break}e.readingMore=!1}function R(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){c("readable nexttick read 0"),t.read(0)}function j(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function T(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function P(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(L,e,t))}function L(t,e){if(c("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function F(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}B.prototype.read=function(t){c("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&P(this),null;var r,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",i=!0),e.ended||e.reading?c("reading or ended",i=!1):i&&(c("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=x(n,e))),null===(r=t>0?T(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&P(this)),null!==r&&this.emit("data",r),r},B.prototype._read=function(t){C(this,new v("_read()"))},B.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:y;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",d),t.removeListener("finish",h),t.removeListener("drain",A),t.removeListener("error",p),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",l),f=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||A())}function u(){c("onend"),t.end()}i.endEmitted?r.nextTick(o):n.once("end",o),t.on("unpipe",s);var A=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,N(t))}}(n);t.on("drain",A);var f=!1;function l(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==F(i.pipes,t))&&!f&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function p(e){c("onerror",e),y(),t.removeListener("error",p),0===a(t,"error")&&C(t,e)}function d(){t.removeListener("finish",h),y()}function h(){c("onfinish"),t.removeListener("close",d),y()}function y(){c("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",p),t.once("close",d),t.once("finish",h),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},B.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].emit("unpipe",this,{hasUnpiped:!1});return this}var o=F(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,n)),this},B.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?S(this):i.reading||r.nextTick(O,this))),n},B.prototype.addListener=B.prototype.on,B.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},B.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},B.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(j,t,e))}(this,t)),t.paused=!1,this},B.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},B.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i in t.on("end",(function(){if(c("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<w.length;a++)t.on(w[a],this.emit.bind(this,w[a]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(B.prototype[Symbol.asyncIterator]=function(){return void 0===l&&(l=n(308)),l(this)}),Object.defineProperty(B.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(B.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(B.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),B._fromList=T,Object.defineProperty(B.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(B.from=function(t,e){return void 0===p&&(p=n(309)),p(B,t,e)})}).call(this,n(8),n(11))},function(t,e,n){t.exports=n(42).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){i(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,a){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(a?a(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(i,this,t)):e.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!a&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):a?(e.nextTick(r,o),a(t)):e.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,r=t._writableState;n&&n.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}}}).call(this,n(11))},function(t,e,n){"use strict";var r=n(34).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var a=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(i?n:"highWaterMark",a);return Math.floor(a)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function i(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var r=t.entry;t.entry=null;for(;r;){var i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var a;t.exports=B,B.WritableState=E;var o={deprecate:n(127)},s=n(131),u=n(5).Buffer,c=e.Uint8Array||function(){};var A,f=n(132),l=n(133).getHighWaterMark,p=n(34).codes,d=p.ERR_INVALID_ARG_TYPE,h=p.ERR_METHOD_NOT_IMPLEMENTED,y=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,b=p.ERR_STREAM_DESTROYED,m=p.ERR_STREAM_NULL_VALUES,v=p.ERR_STREAM_WRITE_AFTER_END,I=p.ERR_UNKNOWN_ENCODING,C=f.errorOrDestroy;function w(){}function E(t,e,o){a=a||n(35),t=t||{},"boolean"!=typeof o&&(o=e instanceof a),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=l(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,i=n.sync,a=n.writecb;if("function"!=typeof a)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,a){--e.pendingcb,n?(r.nextTick(a,i),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,C(t,i)):(a(i),t._writableState.errorEmitted=!0,C(t,i),M(t,e))}(t,n,i,e,a);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),i?r.nextTick(k,t,n,o,a):k(t,n,o,a)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}function B(t){var e=this instanceof(a=a||n(35));if(!e&&!A.call(B,this))return new B(t);this._writableState=new E(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),s.call(this)}function Q(t,e,n,r,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function k(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),M(t,e)}function x(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,a=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)a[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;a.allBuffers=u,Q(t,e,!0,e.length,a,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new i(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,A=n.encoding,f=n.callback;if(Q(t,e,!1,e.objectMode?1:c.length,c,A,f),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function _(t,e){t._final((function(n){e.pendingcb--,n&&C(t,n),e.prefinished=!0,t.emit("prefinish"),M(t,e)}))}function M(t,e){var n=S(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,r.nextTick(_,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(3)(B,s),E.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(E.prototype,"buffer",{get:o.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(A=Function.prototype[Symbol.hasInstance],Object.defineProperty(B,Symbol.hasInstance,{value:function(t){return!!A.call(this,t)||this===B&&(t&&t._writableState instanceof E)}})):A=function(t){return t instanceof this},B.prototype.pipe=function(){C(this,new g)},B.prototype.write=function(t,e,n){var i,a=this._writableState,o=!1,s=!a.objectMode&&(i=t,u.isBuffer(i)||i instanceof c);return s&&!u.isBuffer(t)&&(t=function(t){return u.from(t)}(t)),"function"==typeof e&&(n=e,e=null),s?e="buffer":e||(e=a.defaultEncoding),"function"!=typeof n&&(n=w),a.ending?function(t,e){var n=new v;C(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,i){var a;return null===n?a=new m:"string"==typeof n||e.objectMode||(a=new d("chunk",["string","Buffer"],n)),!a||(C(t,a),r.nextTick(i,a),!1)}(this,a,t,n))&&(a.pendingcb++,o=function(t,e,n,r,i,a){if(!n){var o=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=u.from(e,n));return e}(e,r,i);r!==o&&(n=!0,i="buffer",r=o)}var s=e.objectMode?1:r.length;e.length+=s;var c=e.length<e.highWaterMark;c||(e.needDrain=!0);if(e.writing||e.corked){var A=e.lastBufferedRequest;e.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:a,next:null},A?A.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else Q(t,e,!1,s,r,i,a);return c}(this,a,s,t,e,n)),o},B.prototype.cork=function(){this._writableState.corked++},B.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},B.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new I(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(B.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(B.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),B.prototype._write=function(t,e,n){n(new h("_write()"))},B.prototype._writev=null,B.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,M(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(B.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),B.prototype.destroy=f.destroy,B.prototype._undestroy=f.undestroy,B.prototype._destroy=function(t,e){e(t)}}).call(this,n(8),n(11))},function(t,e,n){"use strict";t.exports=A;var r=n(34).codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,a=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(35);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new a);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function A(t){if(!(this instanceof A))return new A(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",f)}function f(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?l(this,null,null):this._flush((function(e,n){l(t,e,n)}))}function l(t,e,n){if(e)return t.emit("error",e);if(null!=n&&t.push(n),t._writableState.length)throw new s;if(t._transformState.transforming)throw new o;return t.push(null)}n(3)(A,u),A.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},A.prototype._transform=function(t,e,n){n(new i("_transform()"))},A.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},A.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},A.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},function(t,e,n){var r=n(3),i=n(36),a=n(4).Buffer,o=[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],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t,e,n){return n^t&(e^n)}function A(t,e,n){return t&e|n&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function l(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}r(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(t){for(var e,n=this._w,r=0|this._a,i=0|this._b,a=0|this._c,s=0|this._d,u=0|this._e,d=0|this._f,h=0|this._g,y=0|this._h,g=0;g<16;++g)n[g]=t.readInt32BE(4*g);for(;g<64;++g)n[g]=0|(((e=n[g-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+n[g-7]+p(n[g-15])+n[g-16];for(var b=0;b<64;++b){var m=y+l(u)+c(u,d,h)+o[b]+n[b]|0,v=f(r)+A(r,i,a)|0;y=h,h=d,d=u,u=s+m|0,s=a,a=i,i=r,r=m+v|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=h+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var t=a.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},function(t,e,n){var r=n(3),i=n(36),a=n(4).Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(t,e,n){return n^t&(e^n)}function A(t,e,n){return t&e|n&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function l(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function h(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(t,e){return t>>>0<e>>>0?1:0}r(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(t){for(var e=this._w,n=0|this._ah,r=0|this._bh,i=0|this._ch,a=0|this._dh,s=0|this._eh,u=0|this._fh,b=0|this._gh,m=0|this._hh,v=0|this._al,I=0|this._bl,C=0|this._cl,w=0|this._dl,E=0|this._el,B=0|this._fl,Q=0|this._gl,k=0|this._hl,x=0;x<32;x+=2)e[x]=t.readInt32BE(4*x),e[x+1]=t.readInt32BE(4*x+4);for(;x<160;x+=2){var S=e[x-30],_=e[x-30+1],M=p(S,_),D=d(_,S),R=h(S=e[x-4],_=e[x-4+1]),O=y(_,S),j=e[x-14],N=e[x-14+1],T=e[x-32],P=e[x-32+1],L=D+N|0,F=M+j+g(L,D)|0;F=(F=F+R+g(L=L+O|0,O)|0)+T+g(L=L+P|0,P)|0,e[x]=F,e[x+1]=L}for(var U=0;U<160;U+=2){F=e[U],L=e[U+1];var H=A(n,r,i),G=A(v,I,C),Y=f(n,v),q=f(v,n),K=l(s,E),z=l(E,s),J=o[U],V=o[U+1],W=c(s,u,b),Z=c(E,B,Q),X=k+z|0,$=m+K+g(X,k)|0;$=($=($=$+W+g(X=X+Z|0,Z)|0)+J+g(X=X+V|0,V)|0)+F+g(X=X+L|0,L)|0;var tt=q+G|0,et=Y+H+g(tt,q)|0;m=b,k=Q,b=u,Q=B,u=s,B=E,s=a+$+g(E=w+X|0,w)|0,a=i,w=C,i=r,C=I,r=n,I=v,n=$+et+g(v=X+tt|0,X)|0}this._al=this._al+v|0,this._bl=this._bl+I|0,this._cl=this._cl+C|0,this._dl=this._dl+w|0,this._el=this._el+E|0,this._fl=this._fl+B|0,this._gl=this._gl+Q|0,this._hl=this._hl+k|0,this._ah=this._ah+n+g(this._al,v)|0,this._bh=this._bh+r+g(this._bl,I)|0,this._ch=this._ch+i+g(this._cl,C)|0,this._dh=this._dh+a+g(this._dl,w)|0,this._eh=this._eh+s+g(this._el,E)|0,this._fh=this._fh+u+g(this._fl,B)|0,this._gh=this._gh+b+g(this._gl,Q)|0,this._hh=this._hh+m+g(this._hl,k)|0},u.prototype._hash=function(){var t=a.allocUnsafe(64);function e(e,n,r){t.writeInt32BE(e,r),t.writeInt32BE(n,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},function(t,e,n){var r=n(71);t.exports=function(t){return(new r).update(t).digest()}},function(t,e,n){t.exports=n(140)},function(t){t.exports=JSON.parse('{"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}')},function(t,e){var n=Math.pow(2,30)-1;t.exports=function(t,e){if("number"!=typeof t)throw new TypeError("Iterations not a number");if(t<0)throw new TypeError("Bad iterations");if("number"!=typeof e)throw new TypeError("Key length not a number");if(e<0||e>n||e!=e)throw new TypeError("Bad key length")}},function(t,e,n){(function(e,n){var r;if(e.process&&e.process.browser)r="utf-8";else if(e.process&&e.process.version){r=parseInt(n.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else r="utf-8";t.exports=r}).call(this,n(8),n(11))},function(t,e,n){var r=n(138),i=n(74),a=n(75),o=n(4).Buffer,s=n(141),u=n(142),c=n(144),A=o.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(t,e,n){var s=function(t){function e(e){return a(t).update(e).digest()}return"rmd160"===t||"ripemd160"===t?function(t){return(new i).update(t).digest()}:"md5"===t?r:e}(t),u="sha512"===t||"sha384"===t?128:64;e.length>u?e=s(e):e.length<u&&(e=o.concat([e,A],u));for(var c=o.allocUnsafe(u+f[t]),l=o.allocUnsafe(u+f[t]),p=0;p<u;p++)c[p]=54^e[p],l[p]=92^e[p];var d=o.allocUnsafe(u+n+4);c.copy(d,0,0,u),this.ipad1=d,this.ipad2=c,this.opad=l,this.alg=t,this.blocksize=u,this.hash=s,this.size=f[t]}l.prototype.run=function(t,e){return t.copy(e,this.blocksize),this.hash(e).copy(this.opad,this.blocksize),this.hash(this.opad)},t.exports=function(t,e,n,r,i){s(n,r);var a=new l(i=i||"sha1",t=c(t,u,"Password"),(e=c(e,u,"Salt")).length),A=o.allocUnsafe(r),p=o.allocUnsafe(e.length+4);e.copy(p,0,0,e.length);for(var d=0,h=f[i],y=Math.ceil(r/h),g=1;g<=y;g++){p.writeUInt32BE(g,e.length);for(var b=a.run(p,a.ipad1),m=b,v=1;v<n;v++){m=a.run(m,a.ipad2);for(var I=0;I<h;I++)b[I]^=m[I]}b.copy(A,d),d+=h}return A}},function(t,e,n){var r=n(4).Buffer;t.exports=function(t,e,n){if(r.isBuffer(t))return t;if("string"==typeof t)return r.from(t,e);if(ArrayBuffer.isView(t))return r.from(t.buffer);throw new TypeError(n+" must be a string, a Buffer, a typed array or a DataView")}},function(t,e,n){var r=n(318),i=n(79),a=n(80),o=n(331),s=n(55);function u(t,e,n){if(t=t.toLowerCase(),a[t])return i.createCipheriv(t,e,n);if(o[t])return new r({key:e,iv:n,mode:t});throw new TypeError("invalid suite type")}function c(t,e,n){if(t=t.toLowerCase(),a[t])return i.createDecipheriv(t,e,n);if(o[t])return new r({key:e,iv:n,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}e.createCipher=e.Cipher=function(t,e){var n,r;if(t=t.toLowerCase(),a[t])n=a[t].key,r=a[t].iv;else{if(!o[t])throw new TypeError("invalid suite type");n=8*o[t].key,r=o[t].iv}var i=s(e,!1,n,r);return u(t,i.key,i.iv)},e.createCipheriv=e.Cipheriv=u,e.createDecipher=e.Decipher=function(t,e){var n,r;if(t=t.toLowerCase(),a[t])n=a[t].key,r=a[t].iv;else{if(!o[t])throw new TypeError("invalid suite type");n=8*o[t].key,r=o[t].iv}var i=s(e,!1,n,r);return c(t,i.key,i.iv)},e.createDecipheriv=e.Decipheriv=c,e.listCiphers=e.getCiphers=function(){return Object.keys(o).concat(i.getCiphers())}},function(t,e,n){"use strict";e.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},e.writeUInt32BE=function(t,e,n){t[0+n]=e>>>24,t[1+n]=e>>>16&255,t[2+n]=e>>>8&255,t[3+n]=255&e},e.ip=function(t,e,n,r){for(var i=0,a=0,o=6;o>=0;o-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=e>>>s+o&1;for(s=0;s<=24;s+=8)i<<=1,i|=t>>>s+o&1}for(o=6;o>=0;o-=2){for(s=1;s<=25;s+=8)a<<=1,a|=e>>>s+o&1;for(s=1;s<=25;s+=8)a<<=1,a|=t>>>s+o&1}n[r+0]=i>>>0,n[r+1]=a>>>0},e.rip=function(t,e,n,r){for(var i=0,a=0,o=0;o<4;o++)for(var s=24;s>=0;s-=8)i<<=1,i|=e>>>s+o&1,i<<=1,i|=t>>>s+o&1;for(o=4;o<8;o++)for(s=24;s>=0;s-=8)a<<=1,a|=e>>>s+o&1,a<<=1,a|=t>>>s+o&1;n[r+0]=i>>>0,n[r+1]=a>>>0},e.pc1=function(t,e,n,r){for(var i=0,a=0,o=7;o>=5;o--){for(var s=0;s<=24;s+=8)i<<=1,i|=e>>s+o&1;for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+o&1}for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+o&1;for(o=1;o<=3;o++){for(s=0;s<=24;s+=8)a<<=1,a|=e>>s+o&1;for(s=0;s<=24;s+=8)a<<=1,a|=t>>s+o&1}for(s=0;s<=24;s+=8)a<<=1,a|=t>>s+o&1;n[r+0]=i>>>0,n[r+1]=a>>>0},e.r28shl=function(t,e){return t<<e&268435455|t>>>28-e};var r=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];e.pc2=function(t,e,n,i){for(var a=0,o=0,s=r.length>>>1,u=0;u<s;u++)a<<=1,a|=t>>>r[u]&1;for(u=s;u<r.length;u++)o<<=1,o|=e>>>r[u]&1;n[i+0]=a>>>0,n[i+1]=o>>>0},e.expand=function(t,e,n){var r=0,i=0;r=(1&t)<<5|t>>>27;for(var a=23;a>=15;a-=4)r<<=6,r|=t>>>a&63;for(a=11;a>=3;a-=4)i|=t>>>a&63,i<<=6;i|=(31&t)<<1|t>>>31,e[n+0]=r>>>0,e[n+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];e.substitute=function(t,e){for(var n=0,r=0;r<4;r++){n<<=4,n|=i[64*r+(t>>>18-6*r&63)]}for(r=0;r<4;r++){n<<=4,n|=i[256+64*r+(e>>>18-6*r&63)]}return n>>>0};var a=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];e.permute=function(t){for(var e=0,n=0;n<a.length;n++)e<<=1,e|=t>>>a[n]&1;return e>>>0},e.padSplit=function(t,e,n){for(var r=t.toString(2);r.length<e;)r="0"+r;for(var i=[],a=0;a<e;a+=n)i.push(r.slice(a,a+n));return i.join(" ")}},function(t,e,n){"use strict";var r=n(14),i=n(3),a=n(146),o=n(78);function s(){this.tmp=new Array(2),this.keys=null}function u(t){o.call(this,t);var e=new s;this._desState=e,this.deriveKeys(e,t.key)}i(u,o),t.exports=u,u.create=function(t){return new u(t)};var c=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];u.prototype.deriveKeys=function(t,e){t.keys=new Array(32),r.equal(e.length,this.blockSize,"Invalid key length");var n=a.readUInt32BE(e,0),i=a.readUInt32BE(e,4);a.pc1(n,i,t.tmp,0),n=t.tmp[0],i=t.tmp[1];for(var o=0;o<t.keys.length;o+=2){var s=c[o>>>1];n=a.r28shl(n,s),i=a.r28shl(i,s),a.pc2(n,i,t.keys,o)}},u.prototype._update=function(t,e,n,r){var i=this._desState,o=a.readUInt32BE(t,e),s=a.readUInt32BE(t,e+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(n,o,r),a.writeUInt32BE(n,s,r+4)},u.prototype._pad=function(t,e){for(var n=t.length-e,r=e;r<t.length;r++)t[r]=n;return!0},u.prototype._unpad=function(t){for(var e=t[t.length-1],n=t.length-e;n<t.length;n++)r.equal(t[n],e);return t.slice(0,t.length-e)},u.prototype._encrypt=function(t,e,n,r,i){for(var o=e,s=n,u=0;u<t.keys.length;u+=2){var c=t.keys[u],A=t.keys[u+1];a.expand(s,t.tmp,0),c^=t.tmp[0],A^=t.tmp[1];var f=a.substitute(c,A),l=s;s=(o^a.permute(f))>>>0,o=l}a.rip(s,o,r,i)},u.prototype._decrypt=function(t,e,n,r,i){for(var o=n,s=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],A=t.keys[u+1];a.expand(o,t.tmp,0),c^=t.tmp[0],A^=t.tmp[1];var f=a.substitute(c,A),l=o;o=(s^a.permute(f))>>>0,s=l}a.rip(o,s,r,i)}},function(t,e,n){var r=n(45),i=n(4).Buffer,a=n(149);function o(t){var e=t._cipher.encryptBlockRaw(t._prev);return a(t._prev),e}e.encrypt=function(t,e){var n=Math.ceil(e.length/16),a=t._cache.length;t._cache=i.concat([t._cache,i.allocUnsafe(16*n)]);for(var s=0;s<n;s++){var u=o(t),c=a+16*s;t._cache.writeUInt32BE(u[0],c+0),t._cache.writeUInt32BE(u[1],c+4),t._cache.writeUInt32BE(u[2],c+8),t._cache.writeUInt32BE(u[3],c+12)}var A=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),r(e,A)}},function(t,e){t.exports=function(t){for(var e,n=t.length;n--;){if(255!==(e=t.readUInt8(n))){e++,t.writeUInt8(e,n);break}t.writeUInt8(0,n)}}},function(t){t.exports=JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}')},function(t,e,n){var r=n(54),i=n(4).Buffer,a=n(26),o=n(3),s=n(329),u=n(45),c=n(149);function A(t,e,n,o){a.call(this);var u=i.alloc(4,0);this._cipher=new r.AES(e);var A=this._cipher.encryptBlock(u);this._ghash=new s(A),n=function(t,e,n){if(12===e.length)return t._finID=i.concat([e,i.from([0,0,0,1])]),i.concat([e,i.from([0,0,0,2])]);var r=new s(n),a=e.length,o=a%16;r.update(e),o&&(o=16-o,r.update(i.alloc(o,0))),r.update(i.alloc(8,0));var u=8*a,A=i.alloc(8);A.writeUIntBE(u,0,8),r.update(A),t._finID=r.state;var f=i.from(t._finID);return c(f),f}(this,n,A),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(A,a),A.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=i.alloc(e,0),this._ghash.update(e))}this._called=!0;var n=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(n),this._len+=t.length,n},A.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var n=0;t.length!==e.length&&n++;for(var r=Math.min(t.length,e.length),i=0;i<r;++i)n+=t[i]^e[i];return n}(t,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=t,this._cipher.scrub()},A.prototype.getAuthTag=function(){if(this._decrypt||!i.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},A.prototype.setAuthTag=function(t){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=t},A.prototype.setAAD=function(t){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(t),this._alen+=t.length},t.exports=A},function(t,e,n){var r=n(54),i=n(4).Buffer,a=n(26);function o(t,e,n,o){a.call(this),this._cipher=new r.AES(e),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._mode=t}n(3)(o,a),o.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)},o.prototype._final=function(){this._cipher.scrub()},t.exports=o},function(t,e,n){(function(t){var r=n(154),i=n(333),a=n(334);var o={binary:!0,hex:!0,base64:!0};e.DiffieHellmanGroup=e.createDiffieHellmanGroup=e.getDiffieHellman=function(e){var n=new t(i[e].prime,"hex"),r=new t(i[e].gen,"hex");return new a(n,r)},e.createDiffieHellman=e.DiffieHellman=function e(n,i,s,u){return t.isBuffer(i)||void 0===o[i]?e(n,"binary",i,s):(i=i||"binary",u=u||"binary",s=s||new t([2]),t.isBuffer(s)||(s=new t(s,u)),"number"==typeof n?new a(r(n,s),s,!0):(t.isBuffer(n)||(n=new t(n,i)),new a(n,s,!0)))}}).call(this,n(5).Buffer)},function(t,e,n){var r=n(29);t.exports=b,b.simpleSieve=y,b.fermatTest=g;var i=n(2),a=new i(24),o=new(n(155)),s=new i(1),u=new i(2),c=new i(5),A=(new i(16),new i(8),new i(10)),f=new i(3),l=(new i(7),new i(11)),p=new i(4),d=(new i(12),null);function h(){if(null!==d)return d;var t=[];t[0]=2;for(var e=1,n=3;n<1048576;n+=2){for(var r=Math.ceil(Math.sqrt(n)),i=0;i<e&&t[i]<=r&&n%t[i]!=0;i++);e!==i&&t[i]<=r||(t[e++]=n)}return d=t,t}function y(t){for(var e=h(),n=0;n<e.length;n++)if(0===t.modn(e[n]))return 0===t.cmpn(e[n]);return!0}function g(t){var e=i.mont(t);return 0===u.toRed(e).redPow(t.subn(1)).fromRed().cmpn(1)}function b(t,e){if(t<16)return new i(2===e||5===e?[140,123]:[140,39]);var n,d;for(e=new i(e);;){for(n=new i(r(Math.ceil(t/8)));n.bitLength()>t;)n.ishrn(1);if(n.isEven()&&n.iadd(s),n.testn(1)||n.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;n.mod(A).cmp(f);)n.iadd(p)}else for(;n.mod(a).cmp(l);)n.iadd(p);if(y(d=n.shrn(1))&&y(n)&&g(d)&&g(n)&&o.test(d)&&o.test(n))return n}}},function(t,e,n){var r=n(2),i=n(81);function a(t){this.rand=t||new i.Rand}t.exports=a,a.create=function(t){return new a(t)},a.prototype._randbelow=function(t){var e=t.bitLength(),n=Math.ceil(e/8);do{var i=new r(this.rand.generate(n))}while(i.cmp(t)>=0);return i},a.prototype._randrange=function(t,e){var n=e.sub(t);return t.add(this._randbelow(n))},a.prototype.test=function(t,e,n){var i=t.bitLength(),a=r.mont(t),o=new r(1).toRed(a);e||(e=Math.max(1,i/48|0));for(var s=t.subn(1),u=0;!s.testn(u);u++);for(var c=t.shrn(u),A=s.toRed(a);e>0;e--){var f=this._randrange(new r(2),s);n&&n(f);var l=f.toRed(a).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(A)){for(var p=1;p<u;p++){if(0===(l=l.redSqr()).cmp(o))return!1;if(0===l.cmp(A))break}if(p===u)return!1}}return!0},a.prototype.getDivisor=function(t,e){var n=t.bitLength(),i=r.mont(t),a=new r(1).toRed(i);e||(e=Math.max(1,n/48|0));for(var o=t.subn(1),s=0;!o.testn(s);s++);for(var u=t.shrn(s),c=o.toRed(i);e>0;e--){var A=this._randrange(new r(2),o),f=t.gcd(A);if(0!==f.cmpn(1))return f;var l=A.toRed(i).redPow(u);if(0!==l.cmp(a)&&0!==l.cmp(c)){for(var p=1;p<s;p++){if(0===(l=l.redSqr()).cmp(a))return l.fromRed().subn(1).gcd(t);if(0===l.cmp(c))break}if(p===s)return(l=l.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},function(t,e,n){var r=n(4).Buffer,i=n(33),a=n(72),o=n(3),s=n(335),u=n(357),c=n(140);function A(t){a.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){a.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign}function l(t){return new A(t)}function p(t){return new f(t)}Object.keys(c).forEach((function(t){c[t].id=r.from(c[t].id,"hex"),c[t.toLowerCase()]=c[t]})),o(A,a.Writable),A.prototype._write=function(t,e,n){this._hash.update(t),n()},A.prototype.update=function(t,e){return"string"==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},A.prototype.sign=function(t,e){this.end();var n=this._hash.digest(),r=s(n,t,this._hashType,this._signType,this._tag);return e?r.toString(e):r},o(f,a.Writable),f.prototype._write=function(t,e,n){this._hash.update(t),n()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,n){"string"==typeof e&&(e=r.from(e,n)),this.end();var i=this._hash.digest();return u(e,i,t,this._signType,this._tag)},t.exports={Sign:l,Verify:p,createSign:l,createVerify:p}},function(t,e,n){"use strict";var r=e;function i(t){return 1===t.length?"0"+t:t}function a(t){for(var e="",n=0;n<t.length;n++)e+=i(t[n].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if("string"!=typeof t){for(var r=0;r<t.length;r++)n[r]=0|t[r];return n}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(r=0;r<t.length;r+=2)n.push(parseInt(t[r]+t[r+1],16))}else for(r=0;r<t.length;r++){var i=t.charCodeAt(r),a=i>>8,o=255&i;a?n.push(a,o):n.push(o)}return n},r.zero2=i,r.toHex=a,r.encode=function(t,e){return"hex"===e?a(t):t}},function(t,e,n){"use strict";var r=e;r.base=n(56),r.short=n(337),r.mont=n(338),r.edwards=n(339)},function(t,e,n){"use strict";var r=e;r.bignum=n(2),r.define=n(349).define,r.base=n(352),r.constants=n(353),r.decoders=n(162),r.encoders=n(160)},function(t,e,n){"use strict";var r=e;r.der=n(161),r.pem=n(350)},function(t,e,n){"use strict";var r=n(3),i=n(85).Buffer,a=n(86),o=n(88);function s(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new u,this.tree._init(t.body)}function u(t){a.call(this,"der",t)}function c(t){return t<10?"0"+t:t}t.exports=s,s.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},r(u,a),u.prototype._encodeComposite=function(t,e,n,r){var a=function(t,e,n,r){var i;"seqof"===t?t="seq":"setof"===t&&(t="set");if(o.tagByName.hasOwnProperty(t))i=o.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);i=t}if(i>=31)return r.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[n||"universal"]<<6}(t,e,n,this.reporter);if(r.length<128){var s=i.alloc(2);return s[0]=a,s[1]=r.length,this._createEncoderBuffer([s,r])}for(var u=1,c=r.length;c>=256;c>>=8)u++;var A=i.alloc(2+u);A[0]=a,A[1]=128|u;for(var f=1+u,l=r.length;l>0;f--,l>>=8)A[f]=255&l;return this._createEncoderBuffer([A,r])},u.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){for(var n=i.alloc(2*t.length),r=0;r<t.length;r++)n.writeUInt16BE(t.charCodeAt(r),2*r);return this._createEncoderBuffer(n)}return"numstr"===e?this._isNumstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===e?this._isPrintstr(t)?this._createEncoderBuffer(t):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(e)||"objDesc"===e?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: "+e+" unsupported")},u.prototype._encodeObjid=function(t,e,n){if("string"==typeof t){if(!e)return this.reporter.error("string objid given, but no values map found");if(!e.hasOwnProperty(t))return this.reporter.error("objid not found in values map");t=e[t].split(/[\s.]+/g);for(var r=0;r<t.length;r++)t[r]|=0}else if(Array.isArray(t)){t=t.slice();for(var a=0;a<t.length;a++)t[a]|=0}if(!Array.isArray(t))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(t));if(!n){if(t[1]>=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}for(var o=0,s=0;s<t.length;s++){var u=t[s];for(o++;u>=128;u>>=7)o++}for(var c=i.alloc(o),A=c.length-1,f=t.length-1;f>=0;f--){var l=t[f];for(c[A--]=127&l;(l>>=7)>0;)c[A--]=128|127&l}return this._createEncoderBuffer(c)},u.prototype._encodeTime=function(t,e){var n,r=new Date(t);return"gentime"===e?n=[c(r.getUTCFullYear()),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):"utctime"===e?n=[c(r.getUTCFullYear()%100),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(n,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!i.isBuffer(t)){var n=t.toArray();!t.sign&&128&n[0]&&n.unshift(0),t=i.from(n)}if(i.isBuffer(t)){var r=t.length;0===t.length&&r++;var a=i.alloc(r);return t.copy(a),0===t.length&&(a[0]=0),this._createEncoderBuffer(a)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);for(var o=1,s=t;s>=256;s>>=8)o++;for(var u=new Array(o),c=u.length-1;c>=0;c--)u[c]=255&t,t>>=8;return 128&u[0]&&u.unshift(0),this._createEncoderBuffer(i.from(u))},u.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},u.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},u.prototype._skipDefault=function(t,e,n){var r,i=this._baseState;if(null===i.default)return!1;var a=t.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,e,n).join()),a.length!==i.defaultBuffer.length)return!1;for(r=0;r<a.length;r++)if(a[r]!==i.defaultBuffer[r])return!1;return!0}},function(t,e,n){"use strict";var r=e;r.der=n(163),r.pem=n(351)},function(t,e,n){"use strict";var r=n(3),i=n(2),a=n(46).DecoderBuffer,o=n(86),s=n(88);function u(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new c,this.tree._init(t.body)}function c(t){o.call(this,"der",t)}function A(t,e){var n=t.readUInt8(e);if(t.isError(n))return n;var r=s.tagClass[n>>6],i=0==(32&n);if(31==(31&n)){var a=n;for(n=0;128==(128&a);){if(a=t.readUInt8(e),t.isError(a))return a;n<<=7,n|=127&a}}else n&=31;return{cls:r,primitive:i,tag:n,tagStr:s.tag[n]}}function f(t,e,n){var r=t.readUInt8(n);if(t.isError(r))return r;if(!e&&128===r)return null;if(0==(128&r))return r;var i=127&r;if(i>4)return t.error("length octect is too long");r=0;for(var a=0;a<i;a++){r<<=8;var o=t.readUInt8(n);if(t.isError(o))return o;r|=o}return r}t.exports=u,u.prototype.decode=function(t,e){return a.isDecoderBuffer(t)||(t=new a(t,e)),this.tree._decode(t,e)},r(c,o),c.prototype._peekTag=function(t,e,n){if(t.isEmpty())return!1;var r=t.save(),i=A(t,'Failed to peek tag: "'+e+'"');return t.isError(i)?i:(t.restore(r),i.tag===e||i.tagStr===e||i.tagStr+"of"===e||n)},c.prototype._decodeTag=function(t,e,n){var r=A(t,'Failed to decode tag of "'+e+'"');if(t.isError(r))return r;var i=f(t,r.primitive,'Failed to get length of "'+e+'"');if(t.isError(i))return i;if(!n&&r.tag!==e&&r.tagStr!==e&&r.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(r.primitive||null!==i)return t.skip(i,'Failed to match body of: "'+e+'"');var a=t.save(),o=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(o)?o:(i=t.offset-a.offset,t.restore(a),t.skip(i,'Failed to match body of: "'+e+'"'))},c.prototype._skipUntilEnd=function(t,e){for(;;){var n=A(t,e);if(t.isError(n))return n;var r=f(t,n.primitive,e);if(t.isError(r))return r;var i=void 0;if(i=n.primitive||null!==r?t.skip(r):this._skipUntilEnd(t,e),t.isError(i))return i;if("end"===n.tagStr)break}},c.prototype._decodeList=function(t,e,n,r){for(var i=[];!t.isEmpty();){var a=this._peekTag(t,"end");if(t.isError(a))return a;var o=n.decode(t,"der",r);if(t.isError(o)&&a)break;i.push(o)}return i},c.prototype._decodeStr=function(t,e){if("bitstr"===e){var n=t.readUInt8();return t.isError(n)?n:{unused:n,data:t.raw()}}if("bmpstr"===e){var r=t.raw();if(r.length%2==1)return t.error("Decoding of string type: bmpstr length mismatch");for(var i="",a=0;a<r.length/2;a++)i+=String.fromCharCode(r.readUInt16BE(2*a));return i}if("numstr"===e){var o=t.raw().toString("ascii");return this._isNumstr(o)?o:t.error("Decoding of string type: numstr unsupported characters")}if("octstr"===e)return t.raw();if("objDesc"===e)return t.raw();if("printstr"===e){var s=t.raw().toString("ascii");return this._isPrintstr(s)?s:t.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(e)?t.raw().toString():t.error("Decoding of string type: "+e+" unsupported")},c.prototype._decodeObjid=function(t,e,n){for(var r,i=[],a=0,o=0;!t.isEmpty();)a<<=7,a|=127&(o=t.readUInt8()),0==(128&o)&&(i.push(a),a=0);128&o&&i.push(a);var s=i[0]/40|0,u=i[0]%40;if(r=n?i:[s,u].concat(i.slice(1)),e){var c=e[r.join(" ")];void 0===c&&(c=e[r.join(".")]),void 0!==c&&(r=c)}return r},c.prototype._decodeTime=function(t,e){var n,r,i,a,o,s,u=t.raw().toString();if("gentime"===e)n=0|u.slice(0,4),r=0|u.slice(4,6),i=0|u.slice(6,8),a=0|u.slice(8,10),o=0|u.slice(10,12),s=0|u.slice(12,14);else{if("utctime"!==e)return t.error("Decoding "+e+" time is not supported yet");n=0|u.slice(0,2),r=0|u.slice(2,4),i=0|u.slice(4,6),a=0|u.slice(6,8),o=0|u.slice(8,10),s=0|u.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,r-1,i,a,o,s,0)},c.prototype._decodeNull=function(){return null},c.prototype._decodeBool=function(t){var e=t.readUInt8();return t.isError(e)?e:0!==e},c.prototype._decodeInt=function(t,e){var n=t.raw(),r=new i(n);return e&&(r=e[r.toString(10)]||r),r},c.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getDecoder("der").tree}},function(t){t.exports=JSON.parse('{"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}')},function(t,e,n){(function(e){var r=n(83),i=n(2);t.exports=function(t){return new o(t)};var a={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function o(t){this.curveType=a[t],this.curveType||(this.curveType={name:t}),this.curve=new r.ec(this.curveType.name),this.keys=void 0}function s(t,n,r){Array.isArray(t)||(t=t.toArray());var i=new e(t);if(r&&i.length<r){var a=new e(r-i.length);a.fill(0),i=e.concat([a,i])}return n?i.toString(n):i}a.p224=a.secp224r1,a.p256=a.secp256r1=a.prime256v1,a.p192=a.secp192r1=a.prime192v1,a.p384=a.secp384r1,a.p521=a.secp521r1,o.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)},o.prototype.computeSecret=function(t,n,r){return n=n||"utf8",e.isBuffer(t)||(t=new e(t,n)),s(this.curve.keyFromPublic(t).getPublic().mul(this.keys.getPrivate()).getX(),r,this.curveType.byteLength)},o.prototype.getPublicKey=function(t,e){var n=this.keys.getPublic("compressed"===e,!0);return"hybrid"===e&&(n[n.length-1]%2?n[0]=7:n[0]=6),s(n,t)},o.prototype.getPrivateKey=function(t){return s(this.keys.getPrivate(),t)},o.prototype.setPublicKey=function(t,n){return n=n||"utf8",e.isBuffer(t)||(t=new e(t,n)),this.keys._importPublic(t),this},o.prototype.setPrivateKey=function(t,n){n=n||"utf8",e.isBuffer(t)||(t=new e(t,n));var r=new i(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this}}).call(this,n(5).Buffer)},function(t,e,n){e.publicEncrypt=n(358),e.privateDecrypt=n(359),e.privateEncrypt=function(t,n){return e.publicEncrypt(t,n,!0)},e.publicDecrypt=function(t,n){return e.privateDecrypt(t,n,!0)}},function(t,e,n){var r=n(33),i=n(4).Buffer;function a(t){var e=i.allocUnsafe(4);return e.writeUInt32BE(t,0),e}t.exports=function(t,e){for(var n,o=i.alloc(0),s=0;o.length<e;)n=a(s++),o=i.concat([o,r("sha1").update(t).update(n).digest()]);return o.slice(0,e)}},function(t,e){t.exports=function(t,e){for(var n=t.length,r=-1;++r<n;)t[r]^=e[r];return t}},function(t,e,n){var r=n(2),i=n(4).Buffer;t.exports=function(t,e){return i.from(t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed().toArray())}},function(t,e,n){"use strict";(function(t,r){function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var a=n(4),o=n(29),s=a.Buffer,u=a.kMaxLength,c=t.crypto||t.msCrypto,A=Math.pow(2,32)-1;function f(t,e){if("number"!=typeof t||t!=t)throw new TypeError("offset must be a number");if(t>A||t<0)throw new TypeError("offset must be a uint32");if(t>u||t>e)throw new RangeError("offset out of range")}function l(t,e,n){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>A||t<0)throw new TypeError("size must be a uint32");if(t+e>n||t>u)throw new RangeError("buffer too small")}function p(t,e,n,i){if(r.browser){var a=t.buffer,s=new Uint8Array(a,e,n);return c.getRandomValues(s),i?void r.nextTick((function(){i(null,t)})):t}if(!i)return o(n).copy(t,e),t;o(n,(function(n,r){if(n)return i(n);r.copy(t,e),i(null,t)}))}c&&c.getRandomValues||!r.browser?(e.randomFill=function(e,n,r,i){if(!(s.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof n)i=n,n=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-n;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(n,e.length),l(r,n,e.length),p(e,n,r,i)},e.randomFillSync=function(e,n,r){void 0===n&&(n=0);if(!(s.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(n,e.length),void 0===r&&(r=e.length-n);return l(r,n,e.length),p(e,n,r)}):(e.randomFill=i,e.randomFillSync=i)}).call(this,n(8),n(11))},function(t,e,n){(function(t){var r,i,a,o;function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(i=r.key,a=void 0,a=function(t,e){if("object"!==A(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==A(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"),"symbol"===A(a)?a:String(a)),r)}var i,a}function c(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function A(t){return(A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}window,o=function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==A(t)&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return a}));var r=n(7),i=n.n(r),a=function(){function e(t){s(this,e),this.wasm=t}return c(e,[{key:"arrayToBuf",value:function(e){var n=this.wasm,r={ptr:null,len:0};if(!e)return r;var i=null;if(e instanceof Uint8Array||void 0!==t&&e instanceof t)i=e;else{if(!(e instanceof ArrayBuffer||e.__proto__.toString().includes("ArrayBuffer")))throw new Error("arrayToBuf() failed: Expected Uint8Array, Buffer, or\n ArrayBuffer");i=new Uint8Array(e)}return r.len=i.length,r.ptr=n._malloc(i.length),n.writeArrayToMemory(i,r.ptr),r}},{key:"arrayToSmartBuf",value:function(t){var e=this.wasm,n=this.arrayToBuf(t);return n.ptr&&setTimeout((function(){e._free(n.ptr),n.len=0,n.ptr=null}),0),n}},{key:"smartMalloc",value:function(t){var e=this.wasm,n=e._malloc(t);return setTimeout((function(){e._free(n)}),0),n}}],[{key:"bytesToHex",value:function(t){return t.reduce((function(t,e){return t+e.toString(16).padStart(2,"0")}),"")}},{key:"bytesToBinary",value:function(t){return t.reduce((function(t,e){return t+e.toString(2).padStart(8,"0")+" "}),"")}},{key:"hexToBytes",value:function(t){return new Uint8Array(t.match(/.{1,2}/g).map((function(t){return parseInt(t,16)})))}},{key:"randomBytes",value:function(t){if("undefined"!=typeof window&&"undefined"!==window.crypto){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),e}return i.a.randomBytes(t)}}]),e}()}).call(this,n(3).Buffer)},function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));var r=function(){function t(e){s(this,t),this.wasm=e,this.ptr=null,this.len=0}return c(t,[{key:"clear",value:function(){this.len=0}},{key:"free",value:function(){null!==this.ptr&&(this.wasm._free(this.ptr),this.len=0,this.ptr=null)}},{key:"resize",value:function(t){null!==this.ptr&&this.free(),this.len=t,this.ptr=this.wasm._malloc(t)}},{key:"ensureSize",value:function(t){(null===this.ptr||this.len<t)&&this.resize(t)}}]),t}()},function(t,e){t.exports=n(360)},function(t,e,n){"use strict";(function(t){
51
+ */!function(o,s){"use strict";"object"===a(t)&&t.exports?t.exports=s():void 0===(i="function"==typeof(r=s)?r.call(e,n,e,t):r)||(t.exports=i)}(0,(function(t){"use strict";var e=t&&t.SecondLevelDomains,n={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ",do:" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ",in:" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch ",com:"ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ",net:"gb jp se uk ",org:"ae",de:"com "},has:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;var r=t.lastIndexOf(".",e-1);if(r<=0||r>=e-1)return!1;var i=n.list[t.slice(e+1)];return!!i&&i.indexOf(" "+t.slice(r+1,e)+" ")>=0},is:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;if(t.lastIndexOf(".",e-1)>=0)return!1;var r=n.list[t.slice(e+1)];return!!r&&r.indexOf(" "+t.slice(0,e)+" ")>=0},get:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return null;var r=t.lastIndexOf(".",e-1);if(r<=0||r>=e-1)return null;var i=n.list[t.slice(e+1)];return i?i.indexOf(" "+t.slice(r+1,e)+" ")<0?null:t.slice(r+1):null},noConflict:function(){return t.SecondLevelDomains===this&&(t.SecondLevelDomains=e),this}};return n}))}).call(this,n(18)(t))},function(t,e,n){"use strict";var r=n(19).rotr32;function i(t,e,n){return t&e^~t&n}function a(t,e,n){return t&e^t&n^e&n}function o(t,e,n){return t^e^n}e.ft_1=function(t,e,n,r){return 0===t?i(e,n,r):1===t||3===t?o(e,n,r):2===t?a(e,n,r):void 0},e.ch32=i,e.maj32=a,e.p32=o,e.s0_256=function(t){return r(t,2)^r(t,13)^r(t,22)},e.s1_256=function(t){return r(t,6)^r(t,11)^r(t,25)},e.g0_256=function(t){return r(t,7)^r(t,18)^t>>>3},e.g1_256=function(t){return r(t,17)^r(t,19)^t>>>10}},function(t,e,n){"use strict";var r=n(19),i=n(39),a=n(99),o=n(14),s=r.sum32,u=r.sum32_4,c=r.sum32_5,A=a.ch32,f=a.maj32,l=a.s0_256,p=a.s1_256,d=a.g0_256,h=a.g1_256,y=i.BlockHash,g=[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];function b(){if(!(this instanceof b))return new b;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(b,y),t.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(t,e){for(var n=this.W,r=0;r<16;r++)n[r]=t[e+r];for(;r<n.length;r++)n[r]=u(h(n[r-2]),n[r-7],d(n[r-15]),n[r-16]);var i=this.h[0],a=this.h[1],y=this.h[2],g=this.h[3],b=this.h[4],m=this.h[5],v=this.h[6],I=this.h[7];for(o(this.k.length===n.length),r=0;r<n.length;r++){var C=c(I,p(b),A(b,m,v),this.k[r],n[r]),w=s(l(i),f(i,a,y));I=v,v=m,m=b,b=s(g,C),g=y,y=a,a=i,i=s(C,w)}this.h[0]=s(this.h[0],i),this.h[1]=s(this.h[1],a),this.h[2]=s(this.h[2],y),this.h[3]=s(this.h[3],g),this.h[4]=s(this.h[4],b),this.h[5]=s(this.h[5],m),this.h[6]=s(this.h[6],v),this.h[7]=s(this.h[7],I)},b.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(t,e,n){"use strict";var r=n(19),i=n(39),a=n(14),o=r.rotr64_hi,s=r.rotr64_lo,u=r.shr64_hi,c=r.shr64_lo,A=r.sum64,f=r.sum64_hi,l=r.sum64_lo,p=r.sum64_4_hi,d=r.sum64_4_lo,h=r.sum64_5_hi,y=r.sum64_5_lo,g=i.BlockHash,b=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function m(){if(!(this instanceof m))return new m;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=b,this.W=new Array(160)}function v(t,e,n,r,i){var a=t&n^~t&i;return a<0&&(a+=4294967296),a}function I(t,e,n,r,i,a){var o=e&r^~e&a;return o<0&&(o+=4294967296),o}function C(t,e,n,r,i){var a=t&n^t&i^n&i;return a<0&&(a+=4294967296),a}function w(t,e,n,r,i,a){var o=e&r^e&a^r&a;return o<0&&(o+=4294967296),o}function E(t,e){var n=o(t,e,28)^o(e,t,2)^o(e,t,7);return n<0&&(n+=4294967296),n}function B(t,e){var n=s(t,e,28)^s(e,t,2)^s(e,t,7);return n<0&&(n+=4294967296),n}function Q(t,e){var n=o(t,e,14)^o(t,e,18)^o(e,t,9);return n<0&&(n+=4294967296),n}function k(t,e){var n=s(t,e,14)^s(t,e,18)^s(e,t,9);return n<0&&(n+=4294967296),n}function x(t,e){var n=o(t,e,1)^o(t,e,8)^u(t,e,7);return n<0&&(n+=4294967296),n}function S(t,e){var n=s(t,e,1)^s(t,e,8)^c(t,e,7);return n<0&&(n+=4294967296),n}function _(t,e){var n=o(t,e,19)^o(e,t,29)^u(t,e,6);return n<0&&(n+=4294967296),n}function M(t,e){var n=s(t,e,19)^s(e,t,29)^c(t,e,6);return n<0&&(n+=4294967296),n}r.inherits(m,g),t.exports=m,m.blockSize=1024,m.outSize=512,m.hmacStrength=192,m.padLength=128,m.prototype._prepareBlock=function(t,e){for(var n=this.W,r=0;r<32;r++)n[r]=t[e+r];for(;r<n.length;r+=2){var i=_(n[r-4],n[r-3]),a=M(n[r-4],n[r-3]),o=n[r-14],s=n[r-13],u=x(n[r-30],n[r-29]),c=S(n[r-30],n[r-29]),A=n[r-32],f=n[r-31];n[r]=p(i,a,o,s,u,c,A,f),n[r+1]=d(i,a,o,s,u,c,A,f)}},m.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,r=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],u=this.h[4],c=this.h[5],p=this.h[6],d=this.h[7],g=this.h[8],b=this.h[9],m=this.h[10],x=this.h[11],S=this.h[12],_=this.h[13],M=this.h[14],D=this.h[15];a(this.k.length===n.length);for(var R=0;R<n.length;R+=2){var O=M,j=D,N=Q(g,b),T=k(g,b),P=v(g,b,m,x,S),L=I(g,b,m,x,S,_),F=this.k[R],U=this.k[R+1],H=n[R],G=n[R+1],Y=h(O,j,N,T,P,L,F,U,H,G),q=y(O,j,N,T,P,L,F,U,H,G);O=E(r,i),j=B(r,i),N=C(r,i,o,s,u),T=w(r,i,o,s,u,c);var K=f(O,j,N,T),z=l(O,j,N,T);M=S,D=_,S=m,_=x,m=g,x=b,g=f(p,d,Y,q),b=l(d,d,Y,q),p=u,d=c,u=o,c=s,o=r,s=i,r=f(Y,q,K,z),i=l(Y,q,K,z)}A(this.h,0,r,i),A(this.h,2,o,s),A(this.h,4,u,c),A(this.h,6,p,d),A(this.h,8,g,b),A(this.h,10,m,x),A(this.h,12,S,_),A(this.h,14,M,D)},m.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function a(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new a(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new a(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},a.prototype.unref=a.prototype.ref=function(){},a.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(192),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(8))},function(t,e,n){var r=n(198);t.exports=r("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(t,e){t.exports={abi:[{constant:!0,inputs:[],name:"creator",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_SEE",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"customValues",type:"bytes32[]"},{name:"stakeholders",type:"address[]"}],name:"accessRequestV3",outputs:[{name:"",type:"bool"}],payable:!0,stateMutability:"payable",type:"function"},{constant:!0,inputs:[],name:"visibility",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[],name:"kill",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"version",outputs:[{name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"versionAPI",outputs:[{name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"indexCategory",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"newCreator",type:"address"}],name:"transferCreatorship",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"candidate",type:"address"}],name:"hasAccess",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_ACCESS",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_visibility_code",type:"uint8"}],name:"setVisibility",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"contentSpace",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_EDIT",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!1,name:"requestNonce",type:"uint256"},{indexed:!1,name:"parentAddress",type:"address"},{indexed:!1,name:"contextHash",type:"bytes32"},{indexed:!1,name:"accessor",type:"address"},{indexed:!1,name:"requestTimestamp",type:"uint256"}],name:"AccessRequestV3",type:"event"},{anonymous:!1,inputs:[{indexed:!1,name:"contentSpace",type:"address"},{indexed:!1,name:"parentAddress",type:"address"},{indexed:!1,name:"visibility",type:"uint8"}],name:"VisibilityChanged",type:"event"}]}},function(t,e,n){var r=n(30),i=n(17),a=n(13),o=n(9),s=n(10);function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?u(Object(n),!0).forEach((function(e){a(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var A=n(23),f=n(226),l=n(40),p=n(24),d=p.ValidateLibrary,h=p.ValidateObject,y=p.ValidateVersion,g=p.ValidatePartHash,b=p.ValidateWriteToken,m=p.ValidateParameters,v=n(227);e.permissionLevels={owner:{short:"Owner Only",description:"Only the owner has access to the object and ability to change permissions",settings:{visibility:0,statusCode:-1,kmsConk:!1}},editable:{short:"Editable",description:"Members of the editors group have full access to the object and the ability to change permissions",settings:{visibility:0,statusCode:-1,kmsConk:!0}},viewable:{short:"Viewable",description:"In addition to editors, members of the 'accessor' group can have read-only access to the object including playing video and retrieving metadata, images and documents",settings:{visibility:0,statusCode:0,kmsConk:!0}},listable:{short:"Publicly Listable",description:"Anyone can list the public portion of this object but only accounts with specific rights can access",settings:{visibility:1,statusCode:0,kmsConk:!0}},public:{short:"Public",description:"Anyone can access this object",settings:{visibility:10,statusCode:0,kmsConk:!0}}},e.Visibility=function(){var t=s(o.mark((function t(e){var n,r,i,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,r=e.clearCache,t.prev=1,i=this.utils.HashToAddress(n),r&&delete this.visibilityInfo[i],this.visibilityInfo[i]||(this.visibilityInfo[i]=new Promise(function(){var t=s(o.mark((function t(e,r){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,a.authClient.ContractHasMethod({contractAddress:i,methodName:"visibility"});case 3:if(t.sent){t.next=7;break}return e(0),t.abrupt("return");case 7:return t.t0=e,t.next=10,a.CallContractMethod({contractAddress:a.utils.HashToAddress(n),methodName:"visibility"});case 10:t.t1=t.sent,(0,t.t0)(t.t1),t.next=17;break;case 14:t.prev=14,t.t2=t.catch(0),r(t.t2);case 17:case"end":return t.stop()}}),t,null,[[0,14]])})));return function(e,n){return t.apply(this,arguments)}}())),t.prev=5,t.next=8,this.visibilityInfo[i];case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(5),delete this.visibilityInfo[i],t.t0;case 15:t.next=22;break;case 17:if(t.prev=17,t.t1=t.catch(1),"CALL_EXCEPTION"!==t.t1.code){t.next=21;break}return t.abrupt("return",0);case 21:throw t.t1;case 22:case"end":return t.stop()}}),t,this,[[1,17],[5,11]])})));return function(e){return t.apply(this,arguments)}}(),e.Permission=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.clearCache,h(n),t.next=4,this.AccessType({id:n});case 4:if(t.t0=t.sent,t.t1=this.authClient.ACCESS_TYPES.OBJECT,t.t0===t.t1){t.next=8;break}throw Error("Permission only valid for normal content objects: "+n);case 8:return t.next=10,this.Visibility({id:n,clearCache:r});case 10:return i=t.sent,t.next=13,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 13:if(a=t.sent,s=a&&"ikms".concat(this.utils.AddressToHash(a)),u=!1,!s){t.next=27;break}return t.t2=this,t.next=20,this.ContentObjectLibraryId({objectId:n});case 20:return t.t3=t.sent,t.t4=n,t.t5="eluv.caps.".concat(s),t.t6={libraryId:t.t3,objectId:t.t4,metadataSubtree:t.t5},t.next=26,t.t2.ContentObjectMetadata.call(t.t2,t.t6);case 26:u=!!t.sent;case 27:return t.next=29,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"statusCode"});case 29:return c=t.sent,c=parseInt(c._hex,16),(A=Object.keys(this.permissionLevels).filter((function(t){var e=f.permissionLevels[t].settings;return i>=e.visibility&&c>=e.statusCode&&u===e.kmsConk})))||(A=u?["editable"]:["owner"]),t.abrupt("return",A.slice(-1)[0]);case 34:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DefaultKMSAddress=s(o.mark((function t(){var e,n,r,i=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=i.length>0&&void 0!==i[0]?i[0]:{},n=e.tenantId,t.t0=n,!t.t0){t.next=8;break}return t.next=5,this.AccessType({id:n});case 5:t.t1=t.sent,t.t2=this.authClient.ACCESS_TYPES.TENANT,t.t0=t.t1===t.t2;case 8:if(!t.t0){t.next=14;break}return t.next=11,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 11:if(!(r=t.sent)){t.next=14;break}return t.abrupt("return",r);case 14:return t.next=16,this.CallContractMethod({contractAddress:this.contentSpaceAddress,methodName:"addressKMS"});case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t,this)}))),e.ContentSpaceId=function(){return this.contentSpaceId},e.ContentTypeOwner=function(){var t=s(o.mark((function t(e){var n,r,i,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.name,r=e.typeId,i=e.versionHash,t.next=3,this.ContentType({name:n,typeId:r,versionHash:i});case 3:return a=t.sent,t.t0=this.utils,t.next=7,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(a.id),methodName:"owner",methodArgs:[]});case 7:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentType=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.name,r=e.typeId,i=e.versionHash,a=e.publicOnly,s=void 0!==a&&a,this.Log("Retrieving content type: ".concat(n||r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),!n){t.next=13;break}return this.Log("Looking up type by name in content space metadata..."),t.prev=5,t.next=8,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:this.contentSpaceObjectId,metadataSubtree:A("public","contentTypes",n)});case 8:r=t.sent,t.next=13;break;case 11:t.prev=11,t.t0=t.catch(5);case 13:if(r){t.next=23;break}return this.Log("Looking up type by name in available types..."),t.next=17,this.ContentTypes();case 17:if(u=t.sent,!n){t.next=22;break}return t.abrupt("return",Object.values(u).find((function(t){return(t.name||"").toLowerCase()===n.toLowerCase()})));case 22:return t.abrupt("return",Object.values(u).find((function(t){return t.hash===i})));case 23:if(i){t.next=27;break}return t.next=26,this.LatestVersionHash({objectId:r});case 26:i=t.sent;case 27:if(t.prev=27,this.Log("Looking up type by ID..."),!s){t.next=39;break}return t.next=32,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:r,versionHash:i,metadataSubtree:"public"});case 32:if(t.t1=t.sent,t.t1){t.next=35;break}t.t1={};case 35:t.t2=t.t1,c={public:t.t2},t.next=45;break;case 39:return t.next=41,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:r,versionHash:i});case 41:if(t.t3=t.sent,t.t3){t.next=44;break}t.t3={};case 44:c=t.t3;case 45:return t.abrupt("return",{id:r,hash:i,name:c.public&&c.public.name||c.name||r,meta:c});case 48:throw t.prev=48,t.t4=t.catch(27),this.Log("Error looking up content type:"),this.Log(t.t4),new Error("Content Type ".concat(n||r," is invalid"));case 53:case"end":return t.stop()}}),t,this,[[5,11],[27,48]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentTypes=s(o.mark((function t(){var e,n,r,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.contentTypes=this.contentTypes||{},this.Log("Looking up all available content types"),t.next=4,this.Collection({collectionType:"contentTypes"});case 4:return e=t.sent,this.Log("Personally available types:"),this.Log(e),n={},t.prev=8,t.next=11,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:this.contentSpaceObjectId,metadataSubtree:"public/contentTypes"});case 11:if(t.t0=t.sent,t.t0){t.next=14;break}t.t0={};case 14:n=t.t0,t.next=19;break;case 17:t.prev=17,t.t1=t.catch(8);case 19:return r=Object.values(n).map((function(t){return i.utils.HashToAddress(t)})),this.Log("Content space types:"),this.Log(r),e=e.concat(r).filter((function(t){return t})).map((function(t){return i.utils.FormatAddress(t)})).filter((function(t,e,n){return n.indexOf(t)===e})),t.next=25,Promise.all(e.map(function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=i.utils.AddressToObjectId(e),i.contentTypes[n]){t.next=11;break}return t.prev=2,t.next=5,i.ContentType({typeId:n,publicOnly:!0});case 5:i.contentTypes[n]=t.sent,t.next=11;break;case 8:t.prev=8,t.t0=t.catch(2),console.error(t.t0);case 11:case"end":return t.stop()}}),t,null,[[2,8]])})));return function(e){return t.apply(this,arguments)}}()));case 25:return t.abrupt("return",this.contentTypes);case 26:case"end":return t.stop()}}),t,this,[[8,17]])}))),e.ContentLibraries=s(o.mark((function t(){var e,n=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.Collection({collectionType:"libraries"});case 2:return e=t.sent,t.abrupt("return",e.map((function(t){return n.utils.AddressToLibraryId(t)})));case 4:case"end":return t.stop()}}),t,this)}))),e.ContentLibrary=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),r=A("qlibs",n),t.t0=this.utils,t.t1=this.HttpClient,t.next=7,this.authClient.AuthorizationHeader({libraryId:n});case 7:return t.t2=t.sent,t.t3=r,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=13,t.t0.ResponseToJson.call(t.t0,t.t5);case 13:return i=t.sent,t.abrupt("return",c(c({},i),{},{meta:i.meta||{}}));case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentLibraryOwner=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),t.t0=this.utils,t.next=5,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"owner",methodArgs:[]});case 5:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LibraryContentTypes=function(){var t=s(o.mark((function t(e){var n,r,i,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),this.Log("Retrieving library content types for ".concat(n)),t.next=5,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"contentTypesLength",methodArgs:[]});case 5:if(r=t.sent.toNumber(),this.Log("".concat(r," types")),0!==r){t.next=9;break}return t.abrupt("return",{});case 9:return i={},t.next=12,Promise.all(Array.from(new Array(r),function(){var t=s(o.mark((function t(e,r){var s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.ethClient.CallContractMethod({contractAddress:a.utils.HashToAddress(n),methodName:"contentTypes",methodArgs:[r]});case 2:return s=t.sent,u=a.utils.AddressToObjectId(s),t.next=6,a.ContentType({typeId:u});case 6:i[u]=t.sent;case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()));case 12:return this.Log(i),t.abrupt("return",i);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjects=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.filterOptions,i=void 0===r?{}:r,d(n),this.Log("Retrieving content objects from ".concat(n)),a=A("qlibs",n,"q"),s={filter:[]},i.cacheId&&(s.cache_id=i.cacheId),i.start&&(s.start=i.start),i.limit&&(s.limit=i.limit),i.select&&(s.select=i.select),i.sort&&(s.sort_by=i.sort,i.sortDesc&&(s.sort_descending=!0)),u={eq:":eq:",neq:":ne:",lt:":lt:",lte:":le:",gt:":gt:",gte:":ge:",cnt:":co:",ncnt:":nc:"},c=function(t){var e=t.key,n=t.type,r=t.filter;s.filter.push("".concat(e).concat(u[n]).concat(r))},i.filter&&(Array.isArray(i.filter)?i.filter.forEach((function(t){return c(t)})):c(i.filter)),this.Log("Filter options:"),this.Log(i),t.t0=this.utils,t.t1=this.HttpClient,t.next=19,this.authClient.AuthorizationHeader({libraryId:n});case 19:return t.t2=t.sent,t.t3=a,t.t4=s,t.t5={headers:t.t2,method:"GET",path:t.t3,queryParams:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=26,t.t0.ResponseToJson.call(t.t0,t.t6);case 26:return t.abrupt("return",t.sent);case 27:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObject=function(){var t=s(o.mark((function t(e){var n,r,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object: ".concat(n||""," ").concat(a||i||r)),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=A("q",a||i||r),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 9:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=15,t.t0.ResponseToJson.call(t.t0,t.t5);case 15:return t.abrupt("return",t.sent);case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectOwner=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,h(n),this.Log("Retrieving content object owner: ".concat(n)),t.t0=this.utils,t.next=6,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"owner",methodArgs:[]});case 6:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectTenantId=function(){var t=s(o.mark((function t(e){var n,r;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,(r=e.versionHash)?y(r):h(n),r&&(n=this.utils.DecodeVersionHash(r).objectId),this.objectTenantIds[n]){t.next=7;break}return t.next=6,this.authClient.MakeElvMasterCall({methodName:"elv_getTenantById",params:[this.contentSpaceId,n]});case 6:this.objectTenantIds[n]=t.sent;case 7:return t.abrupt("return",this.objectTenantIds[n]);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectLibraryId=function(){var t=s(o.mark((function t(e){var n,r,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)?y(r):h(n),r&&(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.authClient.AccessType(n);case 5:t.t0=t.sent,t.next=t.t0===this.authClient.ACCESS_TYPES.LIBRARY?8:t.t0===this.authClient.ACCESS_TYPES.OBJECT?9:t.t0===this.authClient.ACCESS_TYPES.OTHER?20:21;break;case 8:return t.abrupt("return",this.utils.AddressToLibraryId(this.utils.HashToAddress(n)));case 9:return this.objectLibraryIds[n]||(this.Log("Retrieving content object library ID: ".concat(n||r)),this.objectLibraryIds[n]=new Promise(function(){var t=s(o.mark((function t(e,r){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.t0=e,t.t1=i.utils,t.next=5,i.CallContractMethod({contractAddress:i.utils.HashToAddress(n),methodName:"libraryAddress"});case 5:t.t2=t.sent,t.t3=t.t1.AddressToLibraryId.call(t.t1,t.t2),(0,t.t0)(t.t3),t.next=13;break;case 10:t.prev=10,t.t4=t.catch(0),r(t.t4);case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}())),t.prev=10,t.next=13,this.objectLibraryIds[n];case 13:return t.abrupt("return",t.sent);case 16:throw t.prev=16,t.t1=t.catch(10),delete this.objectLibraryIds[n],t.t1;case 20:throw Error("Unable to retrieve library ID for ".concat(r||n,": Unknown type. (wrong network or deleted object?)"));case 21:return t.abrupt("return",this.contentSpaceLibraryId);case 22:case"end":return t.stop()}}),t,this,[[10,16]])})));return function(e){return t.apply(this,arguments)}}(),e.ProduceMetadataLinks=function(){var t=s(o.mark((function t(e){var n,r,a,u,f,l,p,d,h,y=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,u=e.path,f=void 0===u?"/":u,l=e.metadata,p=e.authorizationToken,d=e.noAuth,l&&"object"===i(l)){t.next=3;break}return t.abrupt("return",l);case 3:if(!Array.isArray(l)){t.next=7;break}return t.next=6,this.utils.LimitedMap(5,l,function(){var t=s(o.mark((function t(e,i){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:A(f,i.toString()),metadata:e,authorizationToken:p,noAuth:d});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}());case 6:return t.abrupt("return",t.sent);case 7:if(!l["/"]||!l["/"].match(/\.\/(rep|files)\/.+/)&&!l["/"].match(/^\/?qfab\/([\w]+)\/?(rep|files)\/.+/)){t.next=16;break}return t.t0=c,t.t1=c({},l),t.t2={},t.next=13,this.LinkUrl({libraryId:n,objectId:r,versionHash:a,linkPath:f,authorizationToken:p,noAuth:d});case 13:return t.t3=t.sent,t.t4={url:t.t3},t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t4));case 16:return h={},t.next=19,this.utils.LimitedMap(5,Object.keys(l),function(){var t=s(o.mark((function t(e){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:A(f,e),metadata:l[e],authorizationToken:p,noAuth:d});case 2:h[e]=t.sent;case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 19:return t.abrupt("return",h);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.MetadataAuth=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p,d,h;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.path,s=void 0===a?"/":a,u=e.channelAuth,c=void 0!==u&&u,A=e.noAuth,f=void 0!==A&&A,m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),f=this.noAuth||f||this.staticToken,l=f,f){t.next=14;break}return t.next=8,this.Visibility({id:r});case 8:return d=t.sent,t.next=11,this.AccessType({id:r});case 11:p=t.sent,l=(s||"").replace(/^\/+/,"").startsWith("public"),f=d>=10||l&&d>=1;case 14:if(!this.oauthToken){t.next=22;break}return t.next=17,this.authClient.KMSAddress({objectId:r,versionHash:i});case 17:if(!(h=t.sent)||this.utils.EqualAddress(h,this.utils.nullAddress)){t.next=22;break}return t.next=21,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,channelAuth:!0,oauthToken:this.oauthToken});case 21:return t.abrupt("return",t.sent);case 22:if(this.inaccessibleLibraries[n]||!l||p!==this.authClient.ACCESS_TYPES.OBJECT||c){t.next=48;break}if(t.prev=23,t.t0=this.authClient,t.t1=n,t.t1){t.next=30;break}return t.next=29,this.ContentObjectLibraryId({objectId:r,versionHash:i});case 29:t.t1=t.sent;case 30:return t.t2=t.t1,t.t3=f,t.t4={libraryId:t.t2,noAuth:t.t3},t.next=35,t.t0.AuthorizationToken.call(t.t0,t.t4);case 35:return t.abrupt("return",t.sent);case 38:if(t.prev=38,t.t5=t.catch(23),!t.t5.message||!t.t5.message.toLowerCase().startsWith("access denied")){t.next=45;break}return this.inaccessibleLibraries[n]=!0,t.next=44,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,noAuth:f,channelAuth:c});case 44:return t.abrupt("return",t.sent);case 45:throw t.t5;case 46:t.next=51;break;case 48:return t.next=50,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,noAuth:f,channelAuth:c});case 50:return t.abrupt("return",t.sent);case 51:case"end":return t.stop()}}),t,this,[[23,38]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectMetadata=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,l,p,d,h,y,g,b,I,C,w,E,B,Q,k,x,S,_,M,D,R,O,j,N,T,P,L=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.metadataSubtree,u=void 0===s?"/":s,l=e.localizationSubtree,p=e.queryParams,d=void 0===p?{}:p,h=e.select,y=void 0===h?[]:h,g=e.remove,b=void 0===g?[]:g,I=e.authorizationToken,C=e.noAuth,w=void 0!==C&&C,E=e.resolveLinks,B=void 0!==E&&E,Q=e.resolveIncludeSource,k=void 0!==Q&&Q,x=e.resolveIgnoreErrors,S=void 0!==x&&x,_=e.linkDepthLimit,M=void 0===_?1:_,D=e.produceLinkUrls,R=void 0!==D&&D,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object metadata: ".concat(n||""," ").concat(r||i," ").concat(a||"","\n Subtree: ").concat(u)),d=c({},d||{}),i&&(r=this.utils.DecodeVersionHash(i).objectId),O=A("q",a||i||r,"meta",u),i){t.next=12;break}if(n){t.next=11;break}return t.next=10,this.ContentObjectLibraryId({objectId:r});case 10:n=t.sent;case 11:O=A("qlibs",n,O);case 12:return t.next=14,this.MetadataAuth({libraryId:n,objectId:r,versionHash:i,path:u,noAuth:w});case 14:return j=t.sent,N=[I,d.authorization,j].flat().filter((function(t){return t})),delete d.authorization,t.prev=17,t.next=20,this.utils.ResponseToJson(this.HttpClient.Request({headers:{Authorization:N.map((function(t){return"Bearer ".concat(t)}))},queryParams:c(c({},d),{},{select:y,remove:b,link_depth:M,resolve:B,resolve_include_source:k,resolve_ignore_errors:S}),method:"GET",path:O}));case 20:T=t.sent,t.next=33;break;case 23:if(t.prev=23,t.t0=t.catch(17),404===t.t0.status){t.next=27;break}throw t.t0;case 27:if(!f.get(t.t0.body,"errors[0].cause.cause.cause.qwtoken")){t.next=32;break}throw t.t0;case 32:T="/"===u?{}:void 0;case 33:if(!R){t.next=37;break}return t.next=36,this.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:i,path:u,metadata:T,authorizationToken:I,noAuth:w});case 36:T=t.sent;case 37:if(l){t.next=39;break}return t.abrupt("return",T);case 39:return t.prev=39,t.next=42,this.ContentObjectMetadata(c(c({},L[0]),{},{metadataSubtree:l,localizationSubtree:void 0}));case 42:return P=t.sent,t.abrupt("return",v({},T,P,(function(t,e){return null===e||""===e?t:void 0})));case 46:return t.prev=46,t.t1=t.catch(39),this.Log(t.t1,!0),t.abrupt("return",T);case 50:case"end":return t.stop()}}),t,this,[[17,23],[39,46]])})));return function(e){return t.apply(this,arguments)}}(),e.AssetMetadata=function(){var t=s(o.mark((function t(e){var n,i,a,s,u,f,l,p,d,h=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,i=e.objectId,a=e.versionHash,s=e.metadata,u=e.localization,f=e.noAuth,l=e.produceLinkUrls,p=void 0!==l&&l,m({libraryId:n,objectId:i,versionHash:a}),i||(i=this.utils.DecodeVersionHash(a).objectId),s){t.next=12;break}return t.next=6,this.ContentObjectMetadata({libraryId:n,objectId:i,versionHash:a,metadataSubtree:"public/asset_metadata",resolveLinks:!0,linkDepthLimit:2,resolveIgnoreErrors:!0,produceLinkUrls:p,noAuth:f});case 6:if(t.t0=t.sent,t.t0){t.next=9;break}t.t0={};case 9:s=t.t0,t.next=16;break;case 12:if(!p){t.next=16;break}return t.next=15,this.ProduceMetadataLinks({libraryId:n,objectId:i,versionHash:a,path:A("public","asset_metadata"),metadata:s,noAuth:f});case 15:s=t.sent;case 16:return s.info||(s.info={}),d=c({},s),u&&u.reverse().forEach((function(t){var e,n=(e=h.utils).SafeTraverse.apply(e,[s].concat(r(t)))||{};d=v({},d,n,(function(t,e){return null===e||""===e?t:void 0}))})),t.abrupt("return",d);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectVersions=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,m({libraryId:n,objectId:r}),this.Log("Retrieving content object versions: ".concat(n||""," ").concat(r)),i=A("qid",r),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r});case 8:return t.t2=t.sent,t.t3=i,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t5));case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LatestVersionHash=function(){var t=s(o.mark((function t(e){var n,r,i,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)&&(n=this.utils.DecodeVersionHash(r).objectId),h(n),t.prev=3,t.next=6,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"objectHash"});case 6:i=t.sent,t.next=11;break;case 9:t.prev=9,t.t0=t.catch(3);case 11:if(i){t.next=25;break}return t.prev=12,t.next=15,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"countVersionHashes"});case 15:a=t.sent,t.next=20;break;case 18:t.prev=18,t.t1=t.catch(12);case 20:if(a&&a.toNumber()){t.next=22;break}throw Error("Unable to determine latest version hash for ".concat(r||n," - Item deleted?"));case 22:return t.next=24,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"versionHashes",methodArgs:[a-1]});case 24:i=t.sent;case 25:return t.abrupt("return",i);case 26:case"end":return t.stop()}}),t,this,[[3,9],[12,18]])})));return function(e){return t.apply(this,arguments)}}(),e.AvailableDRMs=s(o.mark((function t(){var e,n,r,i,a,s,u,c,A;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=["clear","aes-128"],"undefined"!=typeof window){t.next=3;break}return t.abrupt("return",e);case 3:if(window.navigator&&window.navigator.userAgent&&((n=window.navigator.userAgent.match(/(iPad|iPhone|iphone|iPod).*?(OS |os |OS_)(\d+((_|\.)\d)?((_|\.)\d)?)/))&&n[3]&&(r=n[3].split("_"),i=parseInt(r[0]),a=parseInt(r[1]),(i>13||13===i&&a>=1)&&(e[1]="sample-aes",e[2]="fairplay")),/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent)&&(s=window.navigator.userAgent.match(/.+Version\/(\d+)\.(\d+)/))&&s[2]&&(u=parseInt(s[1]),c=parseInt(s[2]),(u>13||13===u&&c>=1)&&(e[1]="sample-aes",e[2]="fairplay"))),"undefined"==typeof window||"function"==typeof window.navigator.requestMediaKeySystemAccess){t.next=6;break}return t.abrupt("return",e);case 6:return t.prev=6,A=[{initDataTypes:["cenc"],audioCapabilities:[{contentType:'audio/mp4;codecs="mp4a.40.2"'}],videoCapabilities:[{contentType:'video/mp4;codecs="avc1.42E01E"'}]}],t.next=10,navigator.requestMediaKeySystemAccess("com.widevine.alpha",A);case 10:e.push("widevine"),t.next=15;break;case 13:t.prev=13,t.t0=t.catch(6);case 15:return t.abrupt("return",e);case 16:case"end":return t.stop()}}),t,null,[[6,13]])}))),e.PlayoutPathResolution=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,f,l,p,d,h,y,g,b,m,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.handler,c=e.offering,f=void 0===c?"":c,l=e.signedLink,p=void 0!==l&&l,d=e.authorizationToken,n){t.next=5;break}return t.next=4,this.ContentObjectLibraryId({objectId:r});case 4:n=t.sent;case 5:if(i){t.next=9;break}return t.next=8,this.LatestVersionHash({objectId:r});case 8:i=t.sent;case 9:if(h=A("qlibs",n,"q",a||i,"rep",u,f,"options.json"),!s){t.next=26;break}return t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:s,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:d});case 13:if(v=t.sent,m=!!v&&!!v["/"]&&!v["/"].endsWith("options.json"),h=A("qlibs",n,"q",a||i,"meta",s),p){t.next=25;break}return t.next=19,this.LinkTarget({libraryId:n,objectId:r,versionHash:i,writeToken:a,linkPath:s,linkInfo:v,authorizationToken:d});case 19:return b=t.sent,g=this.utils.DecodeVersionHash(b).objectId,t.next=23,this.ContentObjectLibraryId({objectId:g});case 23:y=t.sent,m||f||(h=A("q",b,"rep",u,"options.json"));case 25:m&&(h=A(h,f,"options.json"));case 26:return t.abrupt("return",{path:h,multiOfferingLink:m,linkTarget:{libraryId:y,objectId:g,versionHash:b}});case 27:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AvailableOfferings=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.writeToken,a=e.linkPath,s=e.signedLink,u=e.directLink,c=e.handler,A=void 0===c?"playout":c,f=e.authorizationToken,n||(n=this.utils.DecodeVersionHash(r).objectId),!u){t.next=15;break}return t.t0=this,t.next=6,this.ContentObjectLibraryId({objectId:n});case 6:return t.t1=t.sent,t.t2=n,t.t3=r,t.t4=a,t.t5=f,t.t6={libraryId:t.t1,objectId:t.t2,versionHash:t.t3,metadataSubtree:t.t4,resolveLinks:!0,authorizationToken:t.t5},t.next=14,t.t0.ContentObjectMetadata.call(t.t0,t.t6);case 14:return t.abrupt("return",t.sent);case 15:return t.next=17,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:s,handler:A,authorizationToken:f});case 17:return l=t.sent,p=l.path,t.prev=19,t.t7=f,t.next=23,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 23:return t.t8=t.sent,d=[t.t7,t.t8].flat().filter((function(t){return t})),t.next=27,this.utils.ResponseToJson(this.HttpClient.Request({path:p,method:"GET",headers:{Authorization:"Bearer ".concat(d.join(","))}}));case 27:return t.abrupt("return",t.sent);case 30:if(t.prev=30,t.t9=t.catch(19),!t.t9.status||500!==parseInt(t.t9.status)){t.next=34;break}return t.abrupt("return",{});case 34:throw t.t9;case 35:case"end":return t.stop()}}),t,this,[[19,30]])})));return function(e){return t.apply(this,arguments)}}(),e.PlayoutOptions=function(){var t=s(o.mark((function t(e){var n,r,i,u,f,l,p,d,g,b,m,v,I,C,w,E,B,Q,k,x,S,_,M,D,R,O,j,N,T,P,L,F,U,H,G,Y,q,K,z,J,V,W,Z,X,$,tt,et=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.offeringURI,r=e.objectId,i=e.versionHash,u=e.writeToken,f=e.linkPath,l=e.signedLink,p=void 0!==l&&l,d=e.protocols,g=void 0===d?["dash","hls"]:d,b=e.handler,m=void 0===b?"playout":b,v=e.offering,I=void 0===v?"default":v,C=e.playoutType,w=e.drms,E=void 0===w?[]:w,B=e.context,Q=e.hlsjsProfile,k=void 0===Q||Q,x=e.authorizationToken,S=e.options,_=void 0===S?{}:S,!n){t.next=8;break}if(M=n.match(/(hq__[^/]+)\/rep\/([^/]+)\/([^/]+)\/options.json/),i=M[1],m=M[2],I=M[3],i&&m&&I){t.next=8;break}throw Error("Invalid offering URI: ".concat(n));case 8:if(i?y(i):h(r),g=g.map((function(t){return t.toLowerCase()})),E=E.map((function(t){return t.toLowerCase()})),r){t.next=15;break}r=this.utils.DecodeVersionHash(i).objectId,t.next=19;break;case 15:if(i){t.next=19;break}return t.next=18,this.LatestVersionHash({objectId:r});case 18:i=t.sent;case 19:return t.next=21,this.ContentObjectLibraryId({objectId:r});case 21:if(D=t.sent,t.prev=22,f){t.next=29;break}return R=A("public","asset_metadata","sources",I),t.next=27,this.ContentObjectMetadata({libraryId:D,objectId:r,versionHash:i,metadataSubtree:R,authorizationToken:x});case 27:t.sent&&(f=R);case 29:t.next=33;break;case 31:t.prev=31,t.t0=t.catch(22);case 33:return t.next=35,this.PlayoutPathResolution({libraryId:D,objectId:r,versionHash:i,writeToken:u,linkPath:f,signedLink:p,handler:m,offering:I,authorizationToken:x});case 35:if(O=t.sent,j=O.path,N=O.linkTarget,t.t1=this.authClient,t.t2=N.objectId||r,t.t3=N.versionHash||i,t.t3){t.next=45;break}return t.next=44,this.LatestVersionHash({objectId:r});case 44:t.t3=t.sent;case 45:return t.t4=t.t3,t.t5=g,t.t6=E,t.t7=B,t.t8={objectId:t.t2,versionHash:t.t4,protocols:t.t5,drms:t.t6,context:t.t7},T=t.t1.AudienceData.call(t.t1,t.t8),t.t9=x,t.next=54,this.authClient.AuthorizationToken({libraryId:D,objectId:r,channelAuth:!0,oauthToken:this.oauthToken,audienceData:T});case 54:return t.t10=t.sent,P=[t.t9,t.t10].flat().filter((function(t){return t})),L=c({authorization:P,resolve:!!f},_),t.t11=Object,t.next=60,this.utils.ResponseToJson(this.HttpClient.Request({path:j,method:"GET",queryParams:L}));case 60:if(t.t12=t.sent,F=t.t11.values.call(t.t11,t.t12),p||!N.versionHash){t.next=68;break}return t.t13=x,t.next=66,this.authClient.AuthorizationToken({libraryId:N.libraryId,objectId:N.objectId,channelAuth:!0,oauthToken:this.oauthToken,audienceData:T});case 66:t.t14=t.sent,L.authorization=[t.t13,t.t14].flat().filter((function(t){return t}));case 68:U={},Y=0;case 70:if(!(Y<F.length)){t.next=116;break}if(q=F[Y],K=q.properties.protocol,z=q.properties.drm,H=H||q.sid,G=G||!!q.properties.multiview,H&&(L.sid=H),J=q.uri.split("?")[0],C&&(J=J.replace("playlist","playlist-".concat(C))),V=q.properties.license_servers,W=q.properties.cert,k&&"hls"===K&&"aes-128"===z&&(L.player_profile="hls-js"),t.t15=c,t.t16=c({},U[K]||{}),t.t17={},t.t18=c,t.t19=c({},(U[K]||{}).playoutMethods||{}),t.t20={},t.t21=a,t.t22={},t.t23=z||"clear",!p){t.next=97;break}return t.next=94,this.LinkUrl({versionHash:i,linkPath:A(f,I,J),queryParams:L,noAuth:!0});case 94:t.t24=t.sent,t.next=100;break;case 97:return t.next=99,this.Rep({libraryId:N.libraryId||D,objectId:N.objectId||r,versionHash:N.versionHash||i,rep:A(m,I,J),noAuth:!0,queryParams:L});case 99:t.t24=t.sent;case 100:for(Z in t.t25=t.t24,t.t26=z?a({},z,{licenseServers:V,cert:W}):void 0,t.t27={playoutUrl:t.t25,drms:t.t26},t.t28=(0,t.t21)(t.t22,t.t23,t.t27),t.t29=(0,t.t18)(t.t19,t.t20,t.t28),t.t30={playoutMethods:t.t29},U[K]=(0,t.t15)(t.t16,t.t17,t.t30),U[K].playoutMethods)U[K].playoutMethods[Z].drms&&U[K].playoutMethods[Z].drms[z]&&U[K].playoutMethods[Z].drms[z].cert&&((X=new URL(U[K].playoutMethods[Z].playoutUrl)).pathname=X.pathname.split("/").slice(0,-1).concat(["drm.cert"]).join("/"),U[K].playoutMethods[Z].drms[z].cert_url=X.toString());if($=g.includes(K),tt=E.includes(z||"clear")||0===E.length&&!z,$&&tt){t.next=112;break}return t.abrupt("continue",113);case 112:(!U[K].playoutUrl||z&&"clear"!==z)&&(U[K].playoutUrl=U[K].playoutMethods[z||"clear"].playoutUrl,U[K].drms=U[K].playoutMethods[z||"clear"].drms);case 113:Y++,t.next=70;break;case 116:return G&&H&&(U.sessionId=H,U.multiview=!0,U.AvailableViews=s(o.mark((function t(){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=et.utils,t.next=3,et.HttpClient.Request({path:A("q",N.versionHash||i,"rep",m,I,"views.json"),method:"GET",queryParams:{sid:H,authorization:P}});case 3:return t.t1=t.sent,t.next=6,t.t0.ResponseToFormat.call(t.t0,"json",t.t1);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)}))),U.SwitchView=function(){var t=s(o.mark((function t(e){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,et.HttpClient.Request({path:A("q",N.versionHash||i,"rep",m,I,"select_view"),method:"POST",queryParams:{sid:H,authorization:P},body:{view:e}});case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),this.Log(U),t.abrupt("return",U);case 119:case"end":return t.stop()}}),t,this,[[22,31]])})));return function(e){return t.apply(this,arguments)}}(),e.BitmovinPlayoutOptions=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p,d,g,b,m,v,I,C,w,E,B,Q,k,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.versionHash,i=e.writeToken,a=e.linkPath,s=e.signedLink,u=void 0!==s&&s,c=e.protocols,A=void 0===c?["dash","hls"]:c,f=e.drms,l=void 0===f?[]:f,p=e.handler,d=void 0===p?"playout":p,g=e.offering,b=void 0===g?"default":g,m=e.playoutType,v=e.context,I=e.authorizationToken,C=e.options,w=void 0===C?{}:C,r?y(r):h(n),n||(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.PlayoutOptions({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:u,protocols:A,drms:l,handler:d,offering:b,playoutType:m,hlsjsProfile:!1,context:v,authorizationToken:I,options:w});case 5:return delete(E=t.sent).playoutMethods,t.next=9,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:u,handler:d,offering:b,authorizationToken:I});case 9:if(B=t.sent,Q=B.linkTarget,k=[],I&&k.push(I),!u&&Q.versionHash){t.next=21;break}return t.t0=k,t.next=17,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 17:t.t1=t.sent,t.t0.push.call(t.t0,t.t1),t.next=26;break;case 21:return t.t2=k,t.next=24,this.authClient.AuthorizationToken({libraryId:Q.libraryId,objectId:Q.objectId,channelAuth:!0,oauthToken:this.oauthToken});case 24:t.t3=t.sent,t.t2.push.call(t.t2,t.t3);case 26:return x={drm:{}},Object.keys(E).forEach((function(t){var e=E[t];x[t]=e.playoutUrl,e.drms&&Object.keys(e.drms).forEach((function(t){if(e.drms[t].licenseServers&&0!==e.drms[t].licenseServers.length){var n=function(t){return t.toLowerCase().startsWith("https")},r=e.drms[t].licenseServers;r.find(n)&&(r=r.filter(n));var i=r.sort((function(){return.5-Math.random()}))[0];x.drm[t]||(x.drm[t]={LA_URL:i,headers:{Authorization:"Bearer ".concat(k.flat().filter((function(t){return t})).join(","))}})}}))})),t.abrupt("return",x);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CallBitcodeMethod=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,f,l,p,d,h,y,g,b,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.method,u=e.queryParams,c=void 0===u?{}:u,f=e.body,l=void 0===f?{}:f,p=e.headers,d=void 0===p?{}:p,h=e.constant,y=void 0===h||h,g=e.format,b=void 0===g?"json":g,m({libraryId:n,objectId:r,versionHash:i}),s){t.next=4;break}throw"Bitcode method not specified";case 4:if(i&&(r=this.utils.DecodeVersionHash(i).objectId),v=A("q",a||i||r,"call",s),n&&(v=A("qlibs",n,v)),d.authorization||d.Authorization){t.next=12;break}return t.next=11,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!y});case 11:d.Authorization=t.sent.Authorization;case 12:return this.Log("Calling bitcode method: ".concat(n||""," ").concat(r||i," ").concat(a||"","\n ").concat(y?"GET":"POST"," ").concat(v,"\n Query Params:\n ").concat(JSON.stringify(c||""),"\n Body:\n ").concat(JSON.stringify(l||""),"\n Headers\n ").concat(JSON.stringify(d||""))),t.t0=this.utils,t.t1=b,t.next=17,this.HttpClient.Request({body:l,headers:d,method:y?"GET":"POST",path:v,queryParams:c,allowFailover:!1});case 17:return t.t2=t.sent,t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t2));case 19:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Rep=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p,d,h,y,g,b;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,A=void 0===c?"fabric":c,f=e.makeAccessRequest,l=void 0!==f&&f,p=e.channelAuth,d=void 0!==p&&p,h=e.noAuth,y=void 0!==h&&h,g=e.noCache,b=void 0!==g&&g,m({libraryId:n,objectId:r,versionHash:i}),a){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:i,rep:a,queryParams:u,service:A,makeAccessRequest:l,channelAuth:d,noAuth:y,noCache:b}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.PublicRep=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,A=void 0===c?"fabric":c,m({libraryId:n,objectId:r,versionHash:i}),a){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:i,publicRep:a,queryParams:u,service:A,noAuth:!0}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FabricUrl=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,f,l,p,d,h,y,g,b,v,I,C,w,E,B,Q,k,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.partHash,u=e.rep,f=e.publicRep,l=e.call,p=e.queryParams,d=void 0===p?{}:p,h=e.service,y=void 0===h?"fabric":h,g=e.channelAuth,b=void 0!==g&&g,v=e.makeAccessRequest,I=void 0!==v&&v,C=e.noAuth,w=void 0!==C&&C,E=e.noCache,B=void 0!==E&&E,(r||i)&&m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),this.Log("Building Fabric URL:\n libraryId: ".concat(n,"\n objectId: ").concat(r,"\n versionHash: ").concat(i,"\n writeToken: ").concat(a,"\n partHash: ").concat(s,"\n rep: ").concat(u,"\n publicRep: ").concat(f,"\n call: ").concat(l,"\n channelAuth: ").concat(b,"\n noAuth: ").concat(w,"\n noCache: ").concat(B,"\n queryParams: ").concat(JSON.stringify(d||{},null,2))),Q=[],d.authorization&&Q.push(d.authorization),w&&d.authorization){t.next=12;break}return t.t0=Q,t.next=10,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,channelAuth:b,makeAccessRequest:I,noAuth:w,noCache:B});case 10:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 12:if(d=c(c({},d),{},{authorization:Q.flat()}),!u&&!f||!r||i){t.next=17;break}return t.next=16,this.LatestVersionHash({objectId:r});case 16:i=t.sent;case 17:return k="",n?(k=A(k,"qlibs",n),(r||i)&&(k=A(k,"q",a||i||r))):i&&(k=A("q",i)),s?k=A(k,"data",s):u?k=A(k,"rep",u):f?k=A(k,"public",f):l&&(k=A(k,"call",l)),x=this.HttpClient,"search"===y?x=this.SearchHttpClient:"auth"===y&&(x=this.AuthHttpClient),t.abrupt("return",x.URL({path:k,queryParams:d}));case 23:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FileUrl=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,f,l,p,d,h,y;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.filePath,u=e.queryParams,f=void 0===u?{}:u,l=e.noCache,p=void 0!==l&&l,m({libraryId:n,objectId:r,versionHash:i}),s){t.next=4;break}throw"File path not specified";case 4:return i&&(r=this.utils.DecodeVersionHash(i).objectId),d=n?A("qlibs",n,"q",a||i||r):A("q",i),t.next=8,this.authClient.AuthorizationToken({libraryId:n,objectId:r,noCache:p});case 8:return h=t.sent,f=c(c({},f),{},{authorization:h}),t.next=12,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:A("files",s)});case 12:return y=t.sent,y&&y["."].encryption&&"cgck"===y["."].encryption.scheme?(d=A(d,"rep","files_download",s),f["header-x_decryption_mode"]="decrypt"):d=A(d,"files",s),t.abrupt("return",this.HttpClient.URL({path:d,queryParams:f}));case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectImageUrl=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.height,s=e.imagePath,u=void 0===s?"public/display_image":s,m({libraryId:n,objectId:r,versionHash:i}),i){t.next=6;break}return t.next=5,this.LatestVersionHash({objectId:r});case 5:i=t.sent;case 6:if(this.Log("Retrieving content object image url: ".concat(n," ").concat(r," ").concat(i)),this.objectImageUrls[i]){t.next=26;break}return t.prev=8,t.next=11,this.ContentObjectMetadata({versionHash:i,metadataSubtree:u});case 11:if(t.sent){t.next=15;break}return this.Log("No image url set: ".concat(n," ").concat(r," ").concat(i)),t.abrupt("return");case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(8),this.Log("Unable to query for image metadata: ".concat(n," ").concat(r," ").concat(i),!0),this.Log(t.t0,!0);case 21:return c={},a&&!isNaN(parseInt(a))&&(c.height=parseInt(a)),t.next=25,this.LinkUrl({versionHash:i,linkPath:u,queryParams:c});case 25:this.objectImageUrls[i]=t.sent;case 26:return t.abrupt("return",this.objectImageUrls[i]);case 27:case"end":return t.stop()}}),t,this,[[8,17]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectGraph=function(){var t=s(o.mark((function t(e){var n,r,i,a,u,c,f,l,p,d,h=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.autoUpdate,u=void 0!==a&&a,c=e.select,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object graph: ".concat(n||""," ").concat(r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),f=A("q",i||r,"links"),t.prev=5,t.t0=this.utils,t.t1=this.HttpClient,t.next=10,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 10:return t.t2=t.sent,t.t3={auto_update:u,select:c},t.t4=f,t.t5={headers:t.t2,queryParams:t.t3,method:"GET",path:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=17,t.t0.ResponseToJson.call(t.t0,t.t6);case 17:return t.abrupt("return",t.sent);case 20:if(t.prev=20,t.t7=t.catch(5),t.prev=22,(p=t.t7.body.errors[0].cause.cause.cause.cycle)&&0!==p.length){t.next=26;break}throw t.t7;case 26:return d={},t.next=29,Promise.all(p.map(function(){var t=s(o.mark((function t(e){var n,r;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!d[e]){t.next=2;break}return t.abrupt("return");case 2:return n=h.utils.DecodeVersionHash(e).objectId,t.next=5,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"public/asset_metadata/display_title"});case 5:if(t.t2=t.sent,t.t2){t.next=10;break}return t.next=9,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"public/name"});case 9:t.t2=t.sent;case 10:if(t.t1=t.t2,t.t1){t.next=15;break}return t.next=14,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"name"});case 14:t.t1=t.sent;case 15:if(t.t0=t.t1,t.t0){t.next=18;break}t.t0=n;case 18:r=t.t0,d[e]={name:r,objectId:n};case 20:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 29:l=p.map((function(t){return"".concat(d[t].name," (").concat(d[t].objectId,")")})),t.next=35;break;case 32:throw t.prev=32,t.t8=t.catch(22),t.t7;case 35:throw new Error("Cycle found in links: ".concat(l.join(" -> ")));case 36:case"end":return t.stop()}}),t,this,[[5,20],[22,32]])})));return function(e){return t.apply(this,arguments)}}(),e.LinkTarget=function(){var t=s(o.mark((function t(e){var n,r,a,s,u,c,A,f,l;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,s=e.writeToken,u=e.linkPath,c=e.authorizationToken,A=e.linkInfo,m({libraryId:n,objectId:r,versionHash:a}),s&&b(s),a&&(r=this.utils.DecodeVersionHash(a).objectId),!s||n){t.next=8;break}return t.next=7,this.ContentObjectLibraryId({objectId:r});case 7:n=t.sent;case 8:if(A){t.next=12;break}return t.next=11,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:s,metadataSubtree:u,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:c});case 11:A=t.sent;case 12:if(!A||!A["/"]){t.next=27;break}if((f=((A["/"]||"").match(/^\/?qfab\/([\w]+)\/?.+/)||[])[1])||(f=A["."].container),!f){t.next=19;break}return t.abrupt("return",f);case 19:if(!a){t.next=21;break}return t.abrupt("return",a);case 21:if(t.t0=a,t.t0){t.next=26;break}return t.next=25,this.LatestVersionHash({objectId:r});case 25:t.t0=t.sent;case 26:return t.abrupt("return",t.t0);case 27:return t.next=29,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:s,metadataSubtree:u,resolveIncludeSource:!0,authorizationToken:c});case 29:if((A=t.sent)&&A["."]){t.next=49;break}if("object"!==i(A)){t.next=38;break}if(t.t1=a,t.t1){t.next=37;break}return t.next=36,this.LatestVersionHash({objectId:r});case 36:t.t1=t.sent;case 37:return t.abrupt("return",t.t1);case 38:if(l=u.split("/").slice(0,-1).join("/")){t.next=46;break}if(t.t2=a,t.t2){t.next=45;break}return t.next=44,this.LatestVersionHash({objectId:r});case 44:t.t2=t.sent;case 45:return t.abrupt("return",t.t2);case 46:return t.next=48,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:s,metadataSubtree:l,resolveIncludeSource:!0,authorizationToken:c});case 48:A=t.sent;case 49:return t.abrupt("return",A["."].source);case 50:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LinkUrl=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,f,l,p,d,h,y,g,v,I;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.mimeType,f=e.authorizationToken,l=e.queryParams,p=void 0===l?{}:l,d=e.channelAuth,h=void 0!==d&&d,y=e.noAuth,g=void 0!==y&&y,m({libraryId:n,objectId:r,versionHash:i}),a&&b(a),s){t.next=5;break}throw Error("Link path not specified");case 5:return i&&(r=this.utils.DecodeVersionHash(i).objectId),v=n?A("qlibs",n,"q",a||i||r,"meta",s):A("q",i,"meta",s),I=[f],t.t0=I,t.next=11,this.MetadataAuth({libraryId:n,objectId:r,versionHash:i,path:s,channelAuth:h,noAuth:g});case 11:return t.t1=t.sent,t.t0.push.call(t.t0,t.t1),p.authorization&&I.push(p.authorization),p=c(c({},p),{},{authorization:I.flat().filter((function(t){return t})),resolve:!0}),u&&(p["header-accept"]=u),t.abrupt("return",this.HttpClient.URL({path:v,queryParams:p}));case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LinkData=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.queryParams,c=void 0===u?{}:u,A=e.format,f=void 0===A?"json":A,p=e.channelAuth,t.next=3,this.LinkUrl({libraryId:n,objectId:r,versionHash:i,writeToken:a,linkPath:s,queryParams:c,channelAuth:p});case 3:return d=t.sent,t.t0=this.utils,t.t1=f,t.next=8,l.Fetch(d);case 8:return t.t2=t.sent,t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t2));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateEncryptionConk=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.createKMSConk,u=void 0===s||s,!this.signer.remoteSigner){t.next=3;break}return t.abrupt("return");case 3:if(m({libraryId:n,objectId:r,versionHash:i}),b(a),r||(r=client.DecodeVersionHash(i).objectId),n){t.next=10;break}return t.next=9,this.ContentObjectLibraryId({objectId:r});case 9:n=t.sent;case 10:return c="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:a,metadataSubtree:c});case 13:if(!(A=t.sent)){t.next=20;break}return t.next=17,this.Crypto.DecryptCap(A,this.signer._signingKey().privateKey);case 17:this.encryptionConks[r]=t.sent,t.next=34;break;case 20:return t.next=22,this.Crypto.GeneratePrimaryConk({spaceId:this.contentSpaceId,objectId:r});case 22:return this.encryptionConks[r]=t.sent,t.t0=this,t.t1=n,t.t2=r,t.t3=a,t.t4=c,t.next=30,this.Crypto.EncryptConk(this.encryptionConks[r],this.signer._signingKey().publicKey);case 30:return t.t5=t.sent,t.t6={libraryId:t.t1,objectId:t.t2,writeToken:t.t3,metadataSubtree:t.t4,metadata:t.t5},t.next=34,t.t0.ReplaceMetadata.call(t.t0,t.t6);case 34:if(!u){t.next=64;break}return t.prev=35,t.next=38,this.authClient.KMSAddress({objectId:r});case 38:return f=t.sent,t.next=41,this.authClient.KMSInfo({objectId:r});case 41:return l=t.sent.publicKey,p="eluv.caps.ikms".concat(this.utils.AddressToHash(f)),t.next=45,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:a,metadataSubtree:p});case 45:if(t.sent){t.next=58;break}return t.t7=this,t.t8=n,t.t9=r,t.t10=a,t.t11=p,t.next=54,this.Crypto.EncryptConk(this.encryptionConks[r],l);case 54:return t.t12=t.sent,t.t13={libraryId:t.t8,objectId:t.t9,writeToken:t.t10,metadataSubtree:t.t11,metadata:t.t12},t.next=58,t.t7.ReplaceMetadata.call(t.t7,t.t13);case 58:t.next=64;break;case 60:t.prev=60,t.t14=t.catch(35),console.error("Failed to create encryption cap for KMS:"),console.error(t.t14);case 64:return t.abrupt("return",this.encryptionConks[r]);case 65:case"end":return t.stop()}}),t,this,[[35,60]])})));return function(e){return t.apply(this,arguments)}}(),e.EncryptionConk=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f,l,p;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.download,u=void 0!==s&&s,m({libraryId:n,objectId:r,versionHash:i}),a&&b(a),r||(r=client.DecodeVersionHash(i).objectId),t.next=6,this.authClient.Owner({id:r});case 6:return c=t.sent,A="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=10,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,metadataSubtree:A});case 10:if(f=t.sent,this.utils.EqualAddress(c,this.signer.address)||f){t.next=21;break}if(!u){t.next=18;break}return t.next=15,this.authClient.ReEncryptionConk({libraryId:n,objectId:r,versionHash:i});case 15:return t.abrupt("return",t.sent);case 18:return t.next=20,this.authClient.EncryptionConk({libraryId:n,objectId:r,versionHash:i});case 20:return t.abrupt("return",t.sent);case 21:if(this.encryptionConks[r]){t.next=38;break}return l="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=25,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:l});case 25:if(!(p=t.sent)){t.next=32;break}return t.next=29,this.Crypto.DecryptCap(p,this.signer._signingKey().privateKey);case 29:this.encryptionConks[r]=t.sent,t.next=38;break;case 32:if(!a){t.next=37;break}return t.next=35,this.CreateEncryptionConk({libraryId:n,objectId:r,versionHash:i,writeToken:a,createKMSConk:!1});case 35:t.next=38;break;case 37:throw"No encryption conk present for "+r;case 38:return t.abrupt("return",this.encryptionConks[r]);case 39:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Encrypt=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,a=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i});case 4:return s=t.sent,t.next=7,this.Crypto.Encrypt(s,a);case 7:return u=t.sent,t.abrupt("return",u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Decrypt=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,a=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i,download:!0});case 4:return s=t.sent,t.next=7,this.Crypto.Decrypt(s,a);case 7:return u=t.sent,t.abrupt("return",u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessType=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,t.next=3,this.authClient.AccessType(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessInfo=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.args,h(n),r||(r=[0,[],[]]),this.Log("Retrieving access info: ".concat(n)),t.next=6,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"getAccessInfo",methodArgs:r});case 6:return i=t.sent,this.Log(i),t.abrupt("return",{visibilityCode:i[0],visible:i[0]>=1,accessible:i[0]>=10,editable:i[0]>=100,hasAccess:0===i[1],accessCode:i[1],accessCharge:this.utils.WeiToEther(i[2]).toString()});case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessRequest=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u,c,A,f;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.args,s=void 0===a?[]:a,u=e.update,c=void 0!==u&&u,A=e.noCache,f=void 0!==A&&A,m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),t.next=5,this.authClient.MakeAccessRequest({libraryId:n,objectId:r,versionHash:i,args:s,update:c,skipCache:!0,noCache:f});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetAuthContext=function(t){var e=t.context;if(e&&Object.values(e).find((function(t){return"string"!=typeof t})))throw Error("Context must be a map of string->string");this.authContext=e},e.GenerateStateChannelToken=function(){var t=s(o.mark((function t(e){var n,r,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.context,a=e.noCache,s=void 0!==a&&a,r?y(r):h(n),!r){t.next=6;break}n=this.utils.DecodeVersionHash(r).objectId,t.next=10;break;case 6:if(this.stateChannelAccess[n]){t.next=10;break}return t.next=9,this.LatestVersionHash({objectId:n});case 9:r=t.sent;case 10:return this.stateChannelAccess[n]=r,t.next=13,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken,context:i,noCache:s});case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizeStateChannelAccess=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.percentComplete,r?y(r):h(n),!r){t.next=6;break}n=this.utils.DecodeVersionHash(r).objectId,t.next=13;break;case 6:if(!this.stateChannelAccess[n]){t.next=10;break}r=this.stateChannelAccess[n],t.next=13;break;case 10:return t.next=12,this.LatestVersionHash({objectId:n});case 12:r=t.sent;case 13:return this.stateChannelAccess[n]=void 0,t.next=16,this.authClient.ChannelContentFinalize({objectId:n,versionHash:r,percent:i});case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectAccessComplete=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.score,i=void 0===r?100:r,h(n),!(i<0||i>100)){t.next=4;break}throw Error("Invalid AccessComplete score: "+i);case 4:return t.next=6,this.authClient.AccessComplete({id:n,score:i});case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Collection=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.collectionType,["accessGroups","contentObjects","contentTypes","contracts","libraries"].includes(n)){t.next=4;break}throw new Error("Invalid collection type: "+n);case 4:if(!this.signer){t.next=10;break}return t.next=7,this.userProfileClient.WalletAddress();case 7:t.t0=t.sent,t.next=11;break;case 10:t.t0=void 0;case 11:if(t.t0){t.next=14;break}throw new Error("Unable to get collection: User wallet doesn't exist");case 14:return this.Log("Retrieving ".concat(n," contract collection for user ").concat(this.signer.address)),t.next=17,this.ethClient.MakeProviderCall({methodName:"send",args:["elv_getWalletCollection",[this.contentSpaceId,"iusr".concat(this.utils.AddressToHash(this.signer.address)),n]]});case 17:if(t.t1=t.sent,t.t1){t.next=20;break}t.t1=[];case 20:return t.abrupt("return",t.t1);case 21:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.VerifyContentObject=function(){var t=s(o.mark((function t(e){var n,r,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,m({libraryId:n,objectId:r,versionHash:i}),t.next=4,ContentObjectVerification.VerifyContentObject({client:this,libraryId:n,objectId:r,versionHash:i});case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Proofs=function(){var t=s(o.mark((function t(e){var n,r,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.partHash,m({libraryId:n,objectId:r,versionHash:i}),g(a),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=A("q",i||r,"data",a,"proofs"),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 9:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t5));case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.QParts=function(){var t=s(o.mark((function t(e){var n,r,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.partHash,a=e.format,s=void 0===a?"blob":a,m({libraryId:n,objectId:r,versionHash:versionHash}),g(i),u=A("qparts",i),t.t0=this.utils,t.t1=s,t.t2=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,partHash:i});case 9:return t.t3=t.sent,t.t4=u,t.t5={headers:t.t3,method:"GET",path:t.t4},t.t6=t.t2.Request.call(t.t2,t.t5),t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t6));case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()},function(t,e,n){var r=n(64)(n(32),"Map");t.exports=r},function(t,e,n){var r=n(32).Symbol;t.exports=r},function(t,e,n){(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r="object"==(void 0===e?"undefined":n(e))&&e&&e.Object===Object&&e;t.exports=r}).call(this,n(8))},function(t,e,n){var r=n(66),i=n(49);t.exports=function(t,e,n){(void 0!==n&&!i(t[e],n)||void 0===n&&!(e in t))&&r(t,e,n)}},function(t,e,n){var r=n(64),i=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=i},function(t,e,n){var r=n(270)(Object.getPrototypeOf,Object);t.exports=r},function(t,e){var n=Object.prototype;t.exports=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||n)}},function(t,e,n){var r=n(271),i=n(41),a=Object.prototype,o=a.hasOwnProperty,s=a.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(t){return i(t)&&o.call(t,"callee")&&!s.call(t,"callee")};t.exports=u},function(t,e){var n=Array.isArray;t.exports=n},function(t,e){t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},function(t,e,n){(function(t){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i=n(32),a=n(273),o="object"==r(e)&&e&&!e.nodeType&&e,s=o&&"object"==r(t)&&t&&!t.nodeType&&t,u=s&&s.exports===o?i.Buffer:void 0,c=(u?u.isBuffer:void 0)||a;t.exports=c}).call(this,n(18)(t))},function(t,e,n){var r=n(275),i=n(276),a=n(277),o=a&&a.isTypedArray,s=o?i(o):r;t.exports=s},function(t,e){t.exports=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}},function(t,e,n){var r=n(281),i=n(283),a=n(67);t.exports=function(t){return a(t)?r(t,!0):i(t)}},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=/^(?:0|[1-9]\d*)$/;t.exports=function(t,e){var i=n(t);return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&r.test(t))&&t>-1&&t%1==0&&t<e}},function(t,e){t.exports=function(t){return t}},function(t,e,n){(function(e){var r=n(9),i=n(10);void 0===globalThis.Buffer&&(globalThis.Buffer=n(5).Buffer);var a,o=n(103),s=n(123),u=n(22);if("undefined"==typeof crypto){var c=n(304);c.getRandomValues=function(t){return c.randomBytes(t.length)},globalThis.crypto=c}switch(u.Platform()){case u.PLATFORM_REACT_NATIVE:case u.PLATFORM_WEB:a=n(171).default;break;default:a=n(!function(){var t=new Error("Cannot find module '@eluvio/crypto/dist/elv-crypto.bundle.node'");throw t.code="MODULE_NOT_FOUND",t}()).default}var A,f,l,p,d,h={ElvCrypto:(d=i(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,h.elvCrypto){t.next=5;break}return t.next=4,(new a).init();case 4:h.elvCrypto=t.sent;case 5:return t.abrupt("return",h.elvCrypto);case 8:t.prev=8,t.t0=t.catch(0),console.error("Error initializing ElvCrypto:"),console.error(t.t0);case 12:case"end":return t.stop()}}),t,null,[[0,8]])}))),function(){return d.apply(this,arguments)}),EncryptedSize:function(t){var e=Math.floor(t/1e6)*h.EncryptedBlockSize(1e6);return t%1e6!=0&&(e+=h.EncryptedBlockSize(t%1e6)),e},EncryptedBlockSize:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=129,r=608,i=48,a=12*(i-1),o=12*i,s=Math.floor(t/a)*o;return t%a!=0&&(s+=o),e?s+r:s+n},EncryptConk:function(t,n){return i(r.mark((function i(){var a,o,s,c,A,f;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.ElvCrypto();case 2:return a=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=new Uint8Array(e.from(JSON.stringify(t))),r.next=7,a.encryptECIES(t,n);case 7:return o=r.sent,s=o.data,c=o.ephemeralKey,A=o.tag,f=e.concat([e.from(c),e.from(A),e.from(s)]),r.abrupt("return",u.B64(f));case 13:case"end":return r.stop()}}),i)})))()},DecryptCap:function(t,n){return i(r.mark((function i(){var a,o,s,u,c;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.ElvCrypto();case 2:return a=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=e.from(t,"base64"),o=t.slice(0,65),s=t.slice(65,81),u=t.slice(81),c=a.decryptECIES(new Uint8Array(u),n,new Uint8Array(o),new Uint8Array(s)),r.abrupt("return",JSON.parse(e.from(c).toString()));case 10:case"end":return r.stop()}}),i)})))()},GeneratePrimaryConk:function(t){return i(r.mark((function n(){var i,a,s,u,c,A,f;return r.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=t.spaceId,a=t.objectId,n.next=3,h.ElvCrypto();case 3:return s=n.sent,u=s.generatePrimaryKeys(),c=u.secretKey,A=u.publicKey,f=s.generateSymmetricKey().key,n.abrupt("return",{symm_key:"kpsy".concat(o.encode(e.from(f))),secret_key:"kpsk".concat(o.encode(e.from(c))),public_key:"kppk".concat(o.encode(e.from(A))),sid:i,qid:a});case 7:case"end":return n.stop()}}),n)})))()},GenerateTargetConk:function(){return i(r.mark((function t(){var n,i,a,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,i=n.generateTargetKeys(),a=i.secretKey,s=i.publicKey,t.abrupt("return",{secret_key:"kpsk".concat(o.encode(e.from(a))),public_key:"ktpk".concat(o.encode(e.from(s)))});case 5:case"end":return t.stop()}}),t)})))()},CapToConk:function(t){var e=function(t){return new Uint8Array(o.decode(t.slice(4)))};return{symmetricKey:e(t.symm_key),secretKey:e(t.secret_key),publicKey:e(t.public_key)}},EncryptionContext:function(t){return i(r.mark((function e(){var n,i,a,o,s,u,c;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,h.ElvCrypto();case 2:return n=e.sent,i=h.CapToConk(t),a=i.symmetricKey,o=i.secretKey,(s=i.publicKey).length===n.PRIMARY_PK_KEY_SIZE?(c=n.CRYPTO_TYPE_PRIMARY,u=n.newPrimaryContext(s,o,a)):(c=n.CRYPTO_TYPE_TARGET,u=n.newTargetDecryptionContext(o,a)),e.abrupt("return",{context:u,type:c});case 6:case"end":return e.stop()}}),e)})))()},Encrypt:(p=i(r.mark((function t(n,i){var a,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.OpenEncryptionStream(n);case 2:if(a=t.sent,e.isBuffer(i)||i instanceof ArrayBuffer){t.next=9;break}return t.t0=e,t.next=7,new Response(i).arrayBuffer();case 7:t.t1=t.sent,i=t.t0.from.call(t.t0,t.t1);case 9:for(o=new Uint8Array(i),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),a.write(o.slice(s,u));return a.end(),c=[],t.next=15,new Promise((function(t,e){a.on("data",(function(t){c.push(t)})).on("finish",(function(){t()})).on("error",(function(t){e(t)}))}));case 15:return t.abrupt("return",e.concat(c));case 16:case"end":return t.stop()}}),t)}))),function(t,e){return p.apply(this,arguments)}),OpenEncryptionStream:(l=i(r.mark((function t(e){var n,i,a,o,u;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,t.next=5,h.EncryptionContext(e);case 5:return i=t.sent,a=i.context,o=new s.PassThrough,u=n.createCipher(a),t.abrupt("return",o.pipe(u).on("finish",(function(){a.free()})).on("error",(function(t){throw Error(t)})));case 10:case"end":return t.stop()}}),t)}))),function(t){return l.apply(this,arguments)}),Decrypt:(f=i(r.mark((function t(n,i){var a,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.OpenDecryptionStream(n);case 2:for(a=t.sent,o=new Uint8Array(i),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),a.write(o.slice(s,u));return a.end(),c=[],t.next=9,new Promise((function(t,e){a.on("data",(function(t){c.push(t)})).on("finish",(function(){t()})).on("error",(function(t){e(t)}))}));case 9:return t.abrupt("return",e.concat(c));case 10:case"end":return t.stop()}}),t)}))),function(t,e){return f.apply(this,arguments)}),OpenDecryptionStream:(A=i(r.mark((function t(e){var n,i,a,o,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,t.next=5,h.EncryptionContext(e);case 5:return i=t.sent,a=i.context,o=i.type,u=new s.PassThrough,c=n.createDecipher(o,a),t.abrupt("return",u.pipe(c).on("finish",(function(){a.free()})).on("error",(function(t){throw Error(t)})));case 11:case"end":return t.stop()}}),t)}))),function(t){return A.apply(this,arguments)})};t.exports=h}).call(this,n(5).Buffer)},function(t,e,n){t.exports=i;var r=n(42).EventEmitter;function i(){r.call(this)}n(3)(i,r),i.Readable=n(68),i.Writable=n(300),i.Duplex=n(301),i.Transform=n(302),i.PassThrough=n(303),i.Stream=i,i.prototype.pipe=function(t,e){var n=this;function i(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function a(){n.readable&&n.resume&&n.resume()}n.on("data",i),t.on("drain",a),t._isStdio||e&&!1===e.end||(n.on("end",s),n.on("close",u));var o=!1;function s(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(A(),0===r.listenerCount(this,"error"))throw t}function A(){n.removeListener("data",i),t.removeListener("drain",a),n.removeListener("end",s),n.removeListener("close",u),n.removeListener("error",c),t.removeListener("error",c),n.removeListener("end",A),n.removeListener("close",A),t.removeListener("close",A)}return n.on("error",c),t.on("error",c),n.on("end",A),n.on("close",A),t.on("close",A),t.emit("pipe",n),t}},function(t,e,n){"use strict";(function(e,r){var i=n(53);t.exports=m;var a,o=n(294);m.ReadableState=b;n(42).EventEmitter;var s=function(t,e){return t.listeners(e).length},u=n(125),c=n(69).Buffer,A=e.Uint8Array||function(){};var f=Object.create(n(43));f.inherits=n(3);var l=n(295),p=void 0;p=l&&l.debuglog?l.debuglog("stream"):function(){};var d,h=n(296),y=n(126);f.inherits(m,u);var g=["error","close","destroy","pause","resume"];function b(t,e){t=t||{};var r=e instanceof(a=a||n(28));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,o=t.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(o||0===o)?o:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new h,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=n(44).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function m(t){if(a=a||n(28),!(this instanceof m))return new m(t);this._readableState=new b(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function v(t,e,n,r,i){var a,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,w(t)}(t,o)):(i||(a=function(t,e){var n;r=e,c.isBuffer(r)||r instanceof A||"string"==typeof e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(o,e)),a?t.emit("error",a):o.objectMode||e&&e.length>0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):I(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?I(t,o,e,!1):B(t,o)):I(t,o,e,!1))):r||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(o)}function I(t,e,n,r){e.flowing&&0===e.length&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,r?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&w(t)),B(t,e)}Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),m.prototype.destroy=y.destroy,m.prototype._undestroy=y.undestroy,m.prototype._destroy=function(t,e){this.push(null),e(t)},m.prototype.push=function(t,e){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof t&&((e=e||r.defaultEncoding)!==r.encoding&&(t=c.from(t,e),e=""),n=!0),v(this,t,e,!1,n)},m.prototype.unshift=function(t){return v(this,t,null,!0,!1)},m.prototype.isPaused=function(){return!1===this._readableState.flowing},m.prototype.setEncoding=function(t){return d||(d=n(44).StringDecoder),this._readableState.decoder=new d(t),this._readableState.encoding=t,this};function C(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function w(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(E,t):E(t))}function E(t){p("emit readable"),t.emit("readable"),S(t)}function B(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(Q,t,e))}function Q(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(p("maybeReadMore read 0"),t.read(0),n!==e.length);)n=e.length;e.readingMore=!1}function k(t){p("readable nexttick read 0"),t.read(0)}function x(t,e){e.reading||(p("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),S(t),e.flowing&&!e.reading&&t.read(0)}function S(t){var e=t._readableState;for(p("flow",e.flowing);e.flowing&&null!==t.read(););}function _(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;t<e.head.data.length?(r=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):r=t===e.head.data.length?e.shift():n?function(t,e){var n=e.head,r=1,i=n.data;t-=i.length;for(;n=n.next;){var a=n.data,o=t>a.length?a.length:t;if(o===a.length?i+=a:i+=a.slice(0,t),0===(t-=o)){o===a.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=a.slice(o));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var a=r.data,o=t>a.length?a.length:t;if(a.copy(n,n.length-t,0,o),0===(t-=o)){o===a.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=a.slice(o));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}m.prototype.read=function(t){p("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):w(this),null;if(0===(t=C(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,i=e.needReadable;return p("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&p("length less than watermark",i=!0),e.ended||e.reading?p("reading or ended",i=!1):i&&(p("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=C(n,e))),null===(r=t>0?_(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&M(this)),null!==r&&this.emit("data",r),r},m.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},m.prototype.pipe=function(t,e){var n=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,p("pipe count=%d opts=%j",a.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?A:m;function c(e,r){p("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),t.removeListener("close",g),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",A),n.removeListener("end",m),n.removeListener("data",h),l=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function A(){p("onend"),t.end()}a.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var f=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,S(t))}}(n);t.on("drain",f);var l=!1;var d=!1;function h(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==R(a.pipes,t))&&!l&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(e){p("onerror",e),m(),t.removeListener("error",y),0===s(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",b),m()}function b(){p("onfinish"),t.removeListener("close",g),m()}function m(){p("unpipe"),n.unpipe(t)}return n.on("data",h),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",y),t.once("close",g),t.once("finish",b),t.emit("pipe",n),a.flowing||(p("pipe resume"),n.resume()),t},m.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].emit("unpipe",this,n);return this}var o=R(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,n)),this},m.prototype.on=function(t,e){var n=u.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&w(this):i.nextTick(k,this))}return n},m.prototype.addListener=m.prototype.on,m.prototype.resume=function(){var t=this._readableState;return t.flowing||(p("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(x,t,e))}(this,t)),this},m.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},m.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i in t.on("end",(function(){if(p("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(p("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<g.length;a++)t.on(g[a],this.emit.bind(this,g[a]));return this._read=function(e){p("wrapped _read",e),r&&(r=!1,t.resume())},this},Object.defineProperty(m.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),m._fromList=_}).call(this,n(8),n(11))},function(t,e,n){t.exports=n(42).EventEmitter},function(t,e,n){"use strict";var r=n(53);function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?(r.nextTick(i,n,t),n._writableState&&(n._writableState.errorEmitted=!0)):e&&e(t)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(t,e,n){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(t){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}}).call(this,n(8))},function(t,e,n){"use strict";t.exports=o;var r=n(28),i=Object.create(n(43));function a(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);r.call(this,t),this._transformState={afterTransform:a.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",s)}function s(){var t=this;"function"==typeof this._flush?this._flush((function(e,n){u(t,e,n)})):u(this,null,null)}function u(t,e,n){if(e)return t.emit("error",e);if(null!=n&&t.push(n),t._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(t._transformState.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}i.inherits=n(3),i.inherits(o,r),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,r.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,n){throw new Error("_transform() is not implemented")},o.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},o.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},o.prototype._destroy=function(t,e){var n=this;r.prototype._destroy.call(this,t,(function(t){e(t),n.emit("close")}))}},function(t,e,n){"use strict";var r=n(4).Buffer,i=n(72).Transform;function a(t){i.call(this),this._block=r.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}n(3)(a,i),a.prototype._transform=function(t,e,n){var r=null;try{this.update(t,e)}catch(t){r=t}n(r)},a.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},a.prototype.update=function(t,e){if(function(t,e){if(!r.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");r.isBuffer(t)||(t=r.from(t,e));for(var n=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var a=this._blockOffset;a<this._blockSize;)n[a++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)n[this._blockOffset++]=t[i++];for(var o=0,s=8*t.length;s>0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},a.prototype._update=function(){throw new Error("_update is not implemented")},a.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return e},a.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=a},function(t,e,n){"use strict";(function(e,r){var i;t.exports=B,B.ReadableState=E;n(42).EventEmitter;var a=function(t,e){return t.listeners(e).length},o=n(131),s=n(5).Buffer,u=e.Uint8Array||function(){};var c,A=n(305);c=A&&A.debuglog?A.debuglog("stream"):function(){};var f,l,p,d=n(306),h=n(132),y=n(133).getHighWaterMark,g=n(34).codes,b=g.ERR_INVALID_ARG_TYPE,m=g.ERR_STREAM_PUSH_AFTER_EOF,v=g.ERR_METHOD_NOT_IMPLEMENTED,I=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(B,o);var C=h.errorOrDestroy,w=["error","close","destroy","pause","resume"];function E(t,e,r){i=i||n(35),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,"readableHighWaterMark",r),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=n(44).StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function B(t){if(i=i||n(35),!(this instanceof B))return new B(t);var e=this instanceof i;this._readableState=new E(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function Q(t,e,n,r,i){c("readableAddChunk",e);var a,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(c("onEofChunk"),e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?S(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,_(t)))}(t,o);else if(i||(a=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new b("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),a)C(t,a);else if(o.objectMode||e&&e.length>0)if("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),r)o.endEmitted?C(t,new I):k(t,o,e,!0);else if(o.ended)C(t,new m);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?k(t,o,e,!1):M(t,o)):k(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function k(t,e,n,r){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",n)):(e.length+=e.objectMode?1:n.length,r?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&S(t)),M(t,e)}Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),B.prototype.destroy=h.destroy,B.prototype._undestroy=h.undestroy,B.prototype._destroy=function(t,e){e(t)},B.prototype.push=function(t,e){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof t&&((e=e||r.defaultEncoding)!==r.encoding&&(t=s.from(t,e),e=""),n=!0),Q(this,t,e,!1,n)},B.prototype.unshift=function(t){return Q(this,t,null,!0,!1)},B.prototype.isPaused=function(){return!1===this._readableState.flowing},B.prototype.setEncoding=function(t){f||(f=n(44).StringDecoder);var e=new f(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};function x(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;c("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(_,t))}function _(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(D,t,e))}function D(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var n=e.length;if(c("maybeReadMore read 0"),t.read(0),n===e.length)break}e.readingMore=!1}function R(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){c("readable nexttick read 0"),t.read(0)}function j(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function T(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function P(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(L,e,t))}function L(t,e){if(c("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function F(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}B.prototype.read=function(t){c("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&P(this),null;var r,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",i=!0),e.ended||e.reading?c("reading or ended",i=!1):i&&(c("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=x(n,e))),null===(r=t>0?T(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&P(this)),null!==r&&this.emit("data",r),r},B.prototype._read=function(t){C(this,new v("_read()"))},B.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:y;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",d),t.removeListener("finish",h),t.removeListener("drain",A),t.removeListener("error",p),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",l),f=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||A())}function u(){c("onend"),t.end()}i.endEmitted?r.nextTick(o):n.once("end",o),t.on("unpipe",s);var A=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,N(t))}}(n);t.on("drain",A);var f=!1;function l(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==F(i.pipes,t))&&!f&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function p(e){c("onerror",e),y(),t.removeListener("error",p),0===a(t,"error")&&C(t,e)}function d(){t.removeListener("finish",h),y()}function h(){c("onfinish"),t.removeListener("close",d),y()}function y(){c("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",p),t.once("close",d),t.once("finish",h),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},B.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].emit("unpipe",this,{hasUnpiped:!1});return this}var o=F(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,n)),this},B.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?S(this):i.reading||r.nextTick(O,this))),n},B.prototype.addListener=B.prototype.on,B.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},B.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},B.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(j,t,e))}(this,t)),t.paused=!1,this},B.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},B.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i in t.on("end",(function(){if(c("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<w.length;a++)t.on(w[a],this.emit.bind(this,w[a]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(B.prototype[Symbol.asyncIterator]=function(){return void 0===l&&(l=n(308)),l(this)}),Object.defineProperty(B.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(B.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(B.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),B._fromList=T,Object.defineProperty(B.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(B.from=function(t,e){return void 0===p&&(p=n(309)),p(B,t,e)})}).call(this,n(8),n(11))},function(t,e,n){t.exports=n(42).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){i(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,a){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(a?a(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(i,this,t)):e.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!a&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):a?(e.nextTick(r,o),a(t)):e.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,r=t._writableState;n&&n.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}}}).call(this,n(11))},function(t,e,n){"use strict";var r=n(34).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var a=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(i?n:"highWaterMark",a);return Math.floor(a)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function i(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var r=t.entry;t.entry=null;for(;r;){var i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var a;t.exports=B,B.WritableState=E;var o={deprecate:n(127)},s=n(131),u=n(5).Buffer,c=e.Uint8Array||function(){};var A,f=n(132),l=n(133).getHighWaterMark,p=n(34).codes,d=p.ERR_INVALID_ARG_TYPE,h=p.ERR_METHOD_NOT_IMPLEMENTED,y=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,b=p.ERR_STREAM_DESTROYED,m=p.ERR_STREAM_NULL_VALUES,v=p.ERR_STREAM_WRITE_AFTER_END,I=p.ERR_UNKNOWN_ENCODING,C=f.errorOrDestroy;function w(){}function E(t,e,o){a=a||n(35),t=t||{},"boolean"!=typeof o&&(o=e instanceof a),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=l(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,i=n.sync,a=n.writecb;if("function"!=typeof a)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,a){--e.pendingcb,n?(r.nextTick(a,i),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,C(t,i)):(a(i),t._writableState.errorEmitted=!0,C(t,i),M(t,e))}(t,n,i,e,a);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),i?r.nextTick(k,t,n,o,a):k(t,n,o,a)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}function B(t){var e=this instanceof(a=a||n(35));if(!e&&!A.call(B,this))return new B(t);this._writableState=new E(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),s.call(this)}function Q(t,e,n,r,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function k(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),M(t,e)}function x(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,a=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)a[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;a.allBuffers=u,Q(t,e,!0,e.length,a,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new i(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,A=n.encoding,f=n.callback;if(Q(t,e,!1,e.objectMode?1:c.length,c,A,f),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function _(t,e){t._final((function(n){e.pendingcb--,n&&C(t,n),e.prefinished=!0,t.emit("prefinish"),M(t,e)}))}function M(t,e){var n=S(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,r.nextTick(_,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(3)(B,s),E.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(E.prototype,"buffer",{get:o.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(A=Function.prototype[Symbol.hasInstance],Object.defineProperty(B,Symbol.hasInstance,{value:function(t){return!!A.call(this,t)||this===B&&(t&&t._writableState instanceof E)}})):A=function(t){return t instanceof this},B.prototype.pipe=function(){C(this,new g)},B.prototype.write=function(t,e,n){var i,a=this._writableState,o=!1,s=!a.objectMode&&(i=t,u.isBuffer(i)||i instanceof c);return s&&!u.isBuffer(t)&&(t=function(t){return u.from(t)}(t)),"function"==typeof e&&(n=e,e=null),s?e="buffer":e||(e=a.defaultEncoding),"function"!=typeof n&&(n=w),a.ending?function(t,e){var n=new v;C(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,i){var a;return null===n?a=new m:"string"==typeof n||e.objectMode||(a=new d("chunk",["string","Buffer"],n)),!a||(C(t,a),r.nextTick(i,a),!1)}(this,a,t,n))&&(a.pendingcb++,o=function(t,e,n,r,i,a){if(!n){var o=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=u.from(e,n));return e}(e,r,i);r!==o&&(n=!0,i="buffer",r=o)}var s=e.objectMode?1:r.length;e.length+=s;var c=e.length<e.highWaterMark;c||(e.needDrain=!0);if(e.writing||e.corked){var A=e.lastBufferedRequest;e.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:a,next:null},A?A.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else Q(t,e,!1,s,r,i,a);return c}(this,a,s,t,e,n)),o},B.prototype.cork=function(){this._writableState.corked++},B.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},B.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new I(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(B.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(B.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),B.prototype._write=function(t,e,n){n(new h("_write()"))},B.prototype._writev=null,B.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,M(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(B.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),B.prototype.destroy=f.destroy,B.prototype._undestroy=f.undestroy,B.prototype._destroy=function(t,e){e(t)}}).call(this,n(8),n(11))},function(t,e,n){"use strict";t.exports=A;var r=n(34).codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,a=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(35);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new a);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function A(t){if(!(this instanceof A))return new A(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",f)}function f(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?l(this,null,null):this._flush((function(e,n){l(t,e,n)}))}function l(t,e,n){if(e)return t.emit("error",e);if(null!=n&&t.push(n),t._writableState.length)throw new s;if(t._transformState.transforming)throw new o;return t.push(null)}n(3)(A,u),A.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},A.prototype._transform=function(t,e,n){n(new i("_transform()"))},A.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},A.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},A.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},function(t,e,n){var r=n(3),i=n(36),a=n(4).Buffer,o=[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],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t,e,n){return n^t&(e^n)}function A(t,e,n){return t&e|n&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function l(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}r(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(t){for(var e,n=this._w,r=0|this._a,i=0|this._b,a=0|this._c,s=0|this._d,u=0|this._e,d=0|this._f,h=0|this._g,y=0|this._h,g=0;g<16;++g)n[g]=t.readInt32BE(4*g);for(;g<64;++g)n[g]=0|(((e=n[g-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+n[g-7]+p(n[g-15])+n[g-16];for(var b=0;b<64;++b){var m=y+l(u)+c(u,d,h)+o[b]+n[b]|0,v=f(r)+A(r,i,a)|0;y=h,h=d,d=u,u=s+m|0,s=a,a=i,i=r,r=m+v|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=h+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var t=a.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},function(t,e,n){var r=n(3),i=n(36),a=n(4).Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(t,e,n){return n^t&(e^n)}function A(t,e,n){return t&e|n&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function l(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function h(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(t,e){return t>>>0<e>>>0?1:0}r(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(t){for(var e=this._w,n=0|this._ah,r=0|this._bh,i=0|this._ch,a=0|this._dh,s=0|this._eh,u=0|this._fh,b=0|this._gh,m=0|this._hh,v=0|this._al,I=0|this._bl,C=0|this._cl,w=0|this._dl,E=0|this._el,B=0|this._fl,Q=0|this._gl,k=0|this._hl,x=0;x<32;x+=2)e[x]=t.readInt32BE(4*x),e[x+1]=t.readInt32BE(4*x+4);for(;x<160;x+=2){var S=e[x-30],_=e[x-30+1],M=p(S,_),D=d(_,S),R=h(S=e[x-4],_=e[x-4+1]),O=y(_,S),j=e[x-14],N=e[x-14+1],T=e[x-32],P=e[x-32+1],L=D+N|0,F=M+j+g(L,D)|0;F=(F=F+R+g(L=L+O|0,O)|0)+T+g(L=L+P|0,P)|0,e[x]=F,e[x+1]=L}for(var U=0;U<160;U+=2){F=e[U],L=e[U+1];var H=A(n,r,i),G=A(v,I,C),Y=f(n,v),q=f(v,n),K=l(s,E),z=l(E,s),J=o[U],V=o[U+1],W=c(s,u,b),Z=c(E,B,Q),X=k+z|0,$=m+K+g(X,k)|0;$=($=($=$+W+g(X=X+Z|0,Z)|0)+J+g(X=X+V|0,V)|0)+F+g(X=X+L|0,L)|0;var tt=q+G|0,et=Y+H+g(tt,q)|0;m=b,k=Q,b=u,Q=B,u=s,B=E,s=a+$+g(E=w+X|0,w)|0,a=i,w=C,i=r,C=I,r=n,I=v,n=$+et+g(v=X+tt|0,X)|0}this._al=this._al+v|0,this._bl=this._bl+I|0,this._cl=this._cl+C|0,this._dl=this._dl+w|0,this._el=this._el+E|0,this._fl=this._fl+B|0,this._gl=this._gl+Q|0,this._hl=this._hl+k|0,this._ah=this._ah+n+g(this._al,v)|0,this._bh=this._bh+r+g(this._bl,I)|0,this._ch=this._ch+i+g(this._cl,C)|0,this._dh=this._dh+a+g(this._dl,w)|0,this._eh=this._eh+s+g(this._el,E)|0,this._fh=this._fh+u+g(this._fl,B)|0,this._gh=this._gh+b+g(this._gl,Q)|0,this._hh=this._hh+m+g(this._hl,k)|0},u.prototype._hash=function(){var t=a.allocUnsafe(64);function e(e,n,r){t.writeInt32BE(e,r),t.writeInt32BE(n,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},function(t,e,n){var r=n(71);t.exports=function(t){return(new r).update(t).digest()}},function(t,e,n){t.exports=n(140)},function(t){t.exports=JSON.parse('{"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}')},function(t,e){var n=Math.pow(2,30)-1;t.exports=function(t,e){if("number"!=typeof t)throw new TypeError("Iterations not a number");if(t<0)throw new TypeError("Bad iterations");if("number"!=typeof e)throw new TypeError("Key length not a number");if(e<0||e>n||e!=e)throw new TypeError("Bad key length")}},function(t,e,n){(function(e,n){var r;if(e.process&&e.process.browser)r="utf-8";else if(e.process&&e.process.version){r=parseInt(n.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else r="utf-8";t.exports=r}).call(this,n(8),n(11))},function(t,e,n){var r=n(138),i=n(74),a=n(75),o=n(4).Buffer,s=n(141),u=n(142),c=n(144),A=o.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(t,e,n){var s=function(t){function e(e){return a(t).update(e).digest()}return"rmd160"===t||"ripemd160"===t?function(t){return(new i).update(t).digest()}:"md5"===t?r:e}(t),u="sha512"===t||"sha384"===t?128:64;e.length>u?e=s(e):e.length<u&&(e=o.concat([e,A],u));for(var c=o.allocUnsafe(u+f[t]),l=o.allocUnsafe(u+f[t]),p=0;p<u;p++)c[p]=54^e[p],l[p]=92^e[p];var d=o.allocUnsafe(u+n+4);c.copy(d,0,0,u),this.ipad1=d,this.ipad2=c,this.opad=l,this.alg=t,this.blocksize=u,this.hash=s,this.size=f[t]}l.prototype.run=function(t,e){return t.copy(e,this.blocksize),this.hash(e).copy(this.opad,this.blocksize),this.hash(this.opad)},t.exports=function(t,e,n,r,i){s(n,r);var a=new l(i=i||"sha1",t=c(t,u,"Password"),(e=c(e,u,"Salt")).length),A=o.allocUnsafe(r),p=o.allocUnsafe(e.length+4);e.copy(p,0,0,e.length);for(var d=0,h=f[i],y=Math.ceil(r/h),g=1;g<=y;g++){p.writeUInt32BE(g,e.length);for(var b=a.run(p,a.ipad1),m=b,v=1;v<n;v++){m=a.run(m,a.ipad2);for(var I=0;I<h;I++)b[I]^=m[I]}b.copy(A,d),d+=h}return A}},function(t,e,n){var r=n(4).Buffer;t.exports=function(t,e,n){if(r.isBuffer(t))return t;if("string"==typeof t)return r.from(t,e);if(ArrayBuffer.isView(t))return r.from(t.buffer);throw new TypeError(n+" must be a string, a Buffer, a typed array or a DataView")}},function(t,e,n){var r=n(318),i=n(79),a=n(80),o=n(331),s=n(55);function u(t,e,n){if(t=t.toLowerCase(),a[t])return i.createCipheriv(t,e,n);if(o[t])return new r({key:e,iv:n,mode:t});throw new TypeError("invalid suite type")}function c(t,e,n){if(t=t.toLowerCase(),a[t])return i.createDecipheriv(t,e,n);if(o[t])return new r({key:e,iv:n,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}e.createCipher=e.Cipher=function(t,e){var n,r;if(t=t.toLowerCase(),a[t])n=a[t].key,r=a[t].iv;else{if(!o[t])throw new TypeError("invalid suite type");n=8*o[t].key,r=o[t].iv}var i=s(e,!1,n,r);return u(t,i.key,i.iv)},e.createCipheriv=e.Cipheriv=u,e.createDecipher=e.Decipher=function(t,e){var n,r;if(t=t.toLowerCase(),a[t])n=a[t].key,r=a[t].iv;else{if(!o[t])throw new TypeError("invalid suite type");n=8*o[t].key,r=o[t].iv}var i=s(e,!1,n,r);return c(t,i.key,i.iv)},e.createDecipheriv=e.Decipheriv=c,e.listCiphers=e.getCiphers=function(){return Object.keys(o).concat(i.getCiphers())}},function(t,e,n){"use strict";e.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},e.writeUInt32BE=function(t,e,n){t[0+n]=e>>>24,t[1+n]=e>>>16&255,t[2+n]=e>>>8&255,t[3+n]=255&e},e.ip=function(t,e,n,r){for(var i=0,a=0,o=6;o>=0;o-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=e>>>s+o&1;for(s=0;s<=24;s+=8)i<<=1,i|=t>>>s+o&1}for(o=6;o>=0;o-=2){for(s=1;s<=25;s+=8)a<<=1,a|=e>>>s+o&1;for(s=1;s<=25;s+=8)a<<=1,a|=t>>>s+o&1}n[r+0]=i>>>0,n[r+1]=a>>>0},e.rip=function(t,e,n,r){for(var i=0,a=0,o=0;o<4;o++)for(var s=24;s>=0;s-=8)i<<=1,i|=e>>>s+o&1,i<<=1,i|=t>>>s+o&1;for(o=4;o<8;o++)for(s=24;s>=0;s-=8)a<<=1,a|=e>>>s+o&1,a<<=1,a|=t>>>s+o&1;n[r+0]=i>>>0,n[r+1]=a>>>0},e.pc1=function(t,e,n,r){for(var i=0,a=0,o=7;o>=5;o--){for(var s=0;s<=24;s+=8)i<<=1,i|=e>>s+o&1;for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+o&1}for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+o&1;for(o=1;o<=3;o++){for(s=0;s<=24;s+=8)a<<=1,a|=e>>s+o&1;for(s=0;s<=24;s+=8)a<<=1,a|=t>>s+o&1}for(s=0;s<=24;s+=8)a<<=1,a|=t>>s+o&1;n[r+0]=i>>>0,n[r+1]=a>>>0},e.r28shl=function(t,e){return t<<e&268435455|t>>>28-e};var r=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];e.pc2=function(t,e,n,i){for(var a=0,o=0,s=r.length>>>1,u=0;u<s;u++)a<<=1,a|=t>>>r[u]&1;for(u=s;u<r.length;u++)o<<=1,o|=e>>>r[u]&1;n[i+0]=a>>>0,n[i+1]=o>>>0},e.expand=function(t,e,n){var r=0,i=0;r=(1&t)<<5|t>>>27;for(var a=23;a>=15;a-=4)r<<=6,r|=t>>>a&63;for(a=11;a>=3;a-=4)i|=t>>>a&63,i<<=6;i|=(31&t)<<1|t>>>31,e[n+0]=r>>>0,e[n+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];e.substitute=function(t,e){for(var n=0,r=0;r<4;r++){n<<=4,n|=i[64*r+(t>>>18-6*r&63)]}for(r=0;r<4;r++){n<<=4,n|=i[256+64*r+(e>>>18-6*r&63)]}return n>>>0};var a=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];e.permute=function(t){for(var e=0,n=0;n<a.length;n++)e<<=1,e|=t>>>a[n]&1;return e>>>0},e.padSplit=function(t,e,n){for(var r=t.toString(2);r.length<e;)r="0"+r;for(var i=[],a=0;a<e;a+=n)i.push(r.slice(a,a+n));return i.join(" ")}},function(t,e,n){"use strict";var r=n(14),i=n(3),a=n(146),o=n(78);function s(){this.tmp=new Array(2),this.keys=null}function u(t){o.call(this,t);var e=new s;this._desState=e,this.deriveKeys(e,t.key)}i(u,o),t.exports=u,u.create=function(t){return new u(t)};var c=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];u.prototype.deriveKeys=function(t,e){t.keys=new Array(32),r.equal(e.length,this.blockSize,"Invalid key length");var n=a.readUInt32BE(e,0),i=a.readUInt32BE(e,4);a.pc1(n,i,t.tmp,0),n=t.tmp[0],i=t.tmp[1];for(var o=0;o<t.keys.length;o+=2){var s=c[o>>>1];n=a.r28shl(n,s),i=a.r28shl(i,s),a.pc2(n,i,t.keys,o)}},u.prototype._update=function(t,e,n,r){var i=this._desState,o=a.readUInt32BE(t,e),s=a.readUInt32BE(t,e+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(n,o,r),a.writeUInt32BE(n,s,r+4)},u.prototype._pad=function(t,e){for(var n=t.length-e,r=e;r<t.length;r++)t[r]=n;return!0},u.prototype._unpad=function(t){for(var e=t[t.length-1],n=t.length-e;n<t.length;n++)r.equal(t[n],e);return t.slice(0,t.length-e)},u.prototype._encrypt=function(t,e,n,r,i){for(var o=e,s=n,u=0;u<t.keys.length;u+=2){var c=t.keys[u],A=t.keys[u+1];a.expand(s,t.tmp,0),c^=t.tmp[0],A^=t.tmp[1];var f=a.substitute(c,A),l=s;s=(o^a.permute(f))>>>0,o=l}a.rip(s,o,r,i)},u.prototype._decrypt=function(t,e,n,r,i){for(var o=n,s=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],A=t.keys[u+1];a.expand(o,t.tmp,0),c^=t.tmp[0],A^=t.tmp[1];var f=a.substitute(c,A),l=o;o=(s^a.permute(f))>>>0,s=l}a.rip(o,s,r,i)}},function(t,e,n){var r=n(45),i=n(4).Buffer,a=n(149);function o(t){var e=t._cipher.encryptBlockRaw(t._prev);return a(t._prev),e}e.encrypt=function(t,e){var n=Math.ceil(e.length/16),a=t._cache.length;t._cache=i.concat([t._cache,i.allocUnsafe(16*n)]);for(var s=0;s<n;s++){var u=o(t),c=a+16*s;t._cache.writeUInt32BE(u[0],c+0),t._cache.writeUInt32BE(u[1],c+4),t._cache.writeUInt32BE(u[2],c+8),t._cache.writeUInt32BE(u[3],c+12)}var A=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),r(e,A)}},function(t,e){t.exports=function(t){for(var e,n=t.length;n--;){if(255!==(e=t.readUInt8(n))){e++,t.writeUInt8(e,n);break}t.writeUInt8(0,n)}}},function(t){t.exports=JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}')},function(t,e,n){var r=n(54),i=n(4).Buffer,a=n(26),o=n(3),s=n(329),u=n(45),c=n(149);function A(t,e,n,o){a.call(this);var u=i.alloc(4,0);this._cipher=new r.AES(e);var A=this._cipher.encryptBlock(u);this._ghash=new s(A),n=function(t,e,n){if(12===e.length)return t._finID=i.concat([e,i.from([0,0,0,1])]),i.concat([e,i.from([0,0,0,2])]);var r=new s(n),a=e.length,o=a%16;r.update(e),o&&(o=16-o,r.update(i.alloc(o,0))),r.update(i.alloc(8,0));var u=8*a,A=i.alloc(8);A.writeUIntBE(u,0,8),r.update(A),t._finID=r.state;var f=i.from(t._finID);return c(f),f}(this,n,A),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(A,a),A.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=i.alloc(e,0),this._ghash.update(e))}this._called=!0;var n=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(n),this._len+=t.length,n},A.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var n=0;t.length!==e.length&&n++;for(var r=Math.min(t.length,e.length),i=0;i<r;++i)n+=t[i]^e[i];return n}(t,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=t,this._cipher.scrub()},A.prototype.getAuthTag=function(){if(this._decrypt||!i.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},A.prototype.setAuthTag=function(t){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=t},A.prototype.setAAD=function(t){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(t),this._alen+=t.length},t.exports=A},function(t,e,n){var r=n(54),i=n(4).Buffer,a=n(26);function o(t,e,n,o){a.call(this),this._cipher=new r.AES(e),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._mode=t}n(3)(o,a),o.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)},o.prototype._final=function(){this._cipher.scrub()},t.exports=o},function(t,e,n){(function(t){var r=n(154),i=n(333),a=n(334);var o={binary:!0,hex:!0,base64:!0};e.DiffieHellmanGroup=e.createDiffieHellmanGroup=e.getDiffieHellman=function(e){var n=new t(i[e].prime,"hex"),r=new t(i[e].gen,"hex");return new a(n,r)},e.createDiffieHellman=e.DiffieHellman=function e(n,i,s,u){return t.isBuffer(i)||void 0===o[i]?e(n,"binary",i,s):(i=i||"binary",u=u||"binary",s=s||new t([2]),t.isBuffer(s)||(s=new t(s,u)),"number"==typeof n?new a(r(n,s),s,!0):(t.isBuffer(n)||(n=new t(n,i)),new a(n,s,!0)))}}).call(this,n(5).Buffer)},function(t,e,n){var r=n(29);t.exports=b,b.simpleSieve=y,b.fermatTest=g;var i=n(2),a=new i(24),o=new(n(155)),s=new i(1),u=new i(2),c=new i(5),A=(new i(16),new i(8),new i(10)),f=new i(3),l=(new i(7),new i(11)),p=new i(4),d=(new i(12),null);function h(){if(null!==d)return d;var t=[];t[0]=2;for(var e=1,n=3;n<1048576;n+=2){for(var r=Math.ceil(Math.sqrt(n)),i=0;i<e&&t[i]<=r&&n%t[i]!=0;i++);e!==i&&t[i]<=r||(t[e++]=n)}return d=t,t}function y(t){for(var e=h(),n=0;n<e.length;n++)if(0===t.modn(e[n]))return 0===t.cmpn(e[n]);return!0}function g(t){var e=i.mont(t);return 0===u.toRed(e).redPow(t.subn(1)).fromRed().cmpn(1)}function b(t,e){if(t<16)return new i(2===e||5===e?[140,123]:[140,39]);var n,d;for(e=new i(e);;){for(n=new i(r(Math.ceil(t/8)));n.bitLength()>t;)n.ishrn(1);if(n.isEven()&&n.iadd(s),n.testn(1)||n.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;n.mod(A).cmp(f);)n.iadd(p)}else for(;n.mod(a).cmp(l);)n.iadd(p);if(y(d=n.shrn(1))&&y(n)&&g(d)&&g(n)&&o.test(d)&&o.test(n))return n}}},function(t,e,n){var r=n(2),i=n(81);function a(t){this.rand=t||new i.Rand}t.exports=a,a.create=function(t){return new a(t)},a.prototype._randbelow=function(t){var e=t.bitLength(),n=Math.ceil(e/8);do{var i=new r(this.rand.generate(n))}while(i.cmp(t)>=0);return i},a.prototype._randrange=function(t,e){var n=e.sub(t);return t.add(this._randbelow(n))},a.prototype.test=function(t,e,n){var i=t.bitLength(),a=r.mont(t),o=new r(1).toRed(a);e||(e=Math.max(1,i/48|0));for(var s=t.subn(1),u=0;!s.testn(u);u++);for(var c=t.shrn(u),A=s.toRed(a);e>0;e--){var f=this._randrange(new r(2),s);n&&n(f);var l=f.toRed(a).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(A)){for(var p=1;p<u;p++){if(0===(l=l.redSqr()).cmp(o))return!1;if(0===l.cmp(A))break}if(p===u)return!1}}return!0},a.prototype.getDivisor=function(t,e){var n=t.bitLength(),i=r.mont(t),a=new r(1).toRed(i);e||(e=Math.max(1,n/48|0));for(var o=t.subn(1),s=0;!o.testn(s);s++);for(var u=t.shrn(s),c=o.toRed(i);e>0;e--){var A=this._randrange(new r(2),o),f=t.gcd(A);if(0!==f.cmpn(1))return f;var l=A.toRed(i).redPow(u);if(0!==l.cmp(a)&&0!==l.cmp(c)){for(var p=1;p<s;p++){if(0===(l=l.redSqr()).cmp(a))return l.fromRed().subn(1).gcd(t);if(0===l.cmp(c))break}if(p===s)return(l=l.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},function(t,e,n){var r=n(4).Buffer,i=n(33),a=n(72),o=n(3),s=n(335),u=n(357),c=n(140);function A(t){a.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){a.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign}function l(t){return new A(t)}function p(t){return new f(t)}Object.keys(c).forEach((function(t){c[t].id=r.from(c[t].id,"hex"),c[t.toLowerCase()]=c[t]})),o(A,a.Writable),A.prototype._write=function(t,e,n){this._hash.update(t),n()},A.prototype.update=function(t,e){return"string"==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},A.prototype.sign=function(t,e){this.end();var n=this._hash.digest(),r=s(n,t,this._hashType,this._signType,this._tag);return e?r.toString(e):r},o(f,a.Writable),f.prototype._write=function(t,e,n){this._hash.update(t),n()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,n){"string"==typeof e&&(e=r.from(e,n)),this.end();var i=this._hash.digest();return u(e,i,t,this._signType,this._tag)},t.exports={Sign:l,Verify:p,createSign:l,createVerify:p}},function(t,e,n){"use strict";var r=e;function i(t){return 1===t.length?"0"+t:t}function a(t){for(var e="",n=0;n<t.length;n++)e+=i(t[n].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if("string"!=typeof t){for(var r=0;r<t.length;r++)n[r]=0|t[r];return n}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(r=0;r<t.length;r+=2)n.push(parseInt(t[r]+t[r+1],16))}else for(r=0;r<t.length;r++){var i=t.charCodeAt(r),a=i>>8,o=255&i;a?n.push(a,o):n.push(o)}return n},r.zero2=i,r.toHex=a,r.encode=function(t,e){return"hex"===e?a(t):t}},function(t,e,n){"use strict";var r=e;r.base=n(56),r.short=n(337),r.mont=n(338),r.edwards=n(339)},function(t,e,n){"use strict";var r=e;r.bignum=n(2),r.define=n(349).define,r.base=n(352),r.constants=n(353),r.decoders=n(162),r.encoders=n(160)},function(t,e,n){"use strict";var r=e;r.der=n(161),r.pem=n(350)},function(t,e,n){"use strict";var r=n(3),i=n(85).Buffer,a=n(86),o=n(88);function s(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new u,this.tree._init(t.body)}function u(t){a.call(this,"der",t)}function c(t){return t<10?"0"+t:t}t.exports=s,s.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},r(u,a),u.prototype._encodeComposite=function(t,e,n,r){var a=function(t,e,n,r){var i;"seqof"===t?t="seq":"setof"===t&&(t="set");if(o.tagByName.hasOwnProperty(t))i=o.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);i=t}if(i>=31)return r.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[n||"universal"]<<6}(t,e,n,this.reporter);if(r.length<128){var s=i.alloc(2);return s[0]=a,s[1]=r.length,this._createEncoderBuffer([s,r])}for(var u=1,c=r.length;c>=256;c>>=8)u++;var A=i.alloc(2+u);A[0]=a,A[1]=128|u;for(var f=1+u,l=r.length;l>0;f--,l>>=8)A[f]=255&l;return this._createEncoderBuffer([A,r])},u.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){for(var n=i.alloc(2*t.length),r=0;r<t.length;r++)n.writeUInt16BE(t.charCodeAt(r),2*r);return this._createEncoderBuffer(n)}return"numstr"===e?this._isNumstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===e?this._isPrintstr(t)?this._createEncoderBuffer(t):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(e)||"objDesc"===e?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: "+e+" unsupported")},u.prototype._encodeObjid=function(t,e,n){if("string"==typeof t){if(!e)return this.reporter.error("string objid given, but no values map found");if(!e.hasOwnProperty(t))return this.reporter.error("objid not found in values map");t=e[t].split(/[\s.]+/g);for(var r=0;r<t.length;r++)t[r]|=0}else if(Array.isArray(t)){t=t.slice();for(var a=0;a<t.length;a++)t[a]|=0}if(!Array.isArray(t))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(t));if(!n){if(t[1]>=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}for(var o=0,s=0;s<t.length;s++){var u=t[s];for(o++;u>=128;u>>=7)o++}for(var c=i.alloc(o),A=c.length-1,f=t.length-1;f>=0;f--){var l=t[f];for(c[A--]=127&l;(l>>=7)>0;)c[A--]=128|127&l}return this._createEncoderBuffer(c)},u.prototype._encodeTime=function(t,e){var n,r=new Date(t);return"gentime"===e?n=[c(r.getUTCFullYear()),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):"utctime"===e?n=[c(r.getUTCFullYear()%100),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(n,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!i.isBuffer(t)){var n=t.toArray();!t.sign&&128&n[0]&&n.unshift(0),t=i.from(n)}if(i.isBuffer(t)){var r=t.length;0===t.length&&r++;var a=i.alloc(r);return t.copy(a),0===t.length&&(a[0]=0),this._createEncoderBuffer(a)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);for(var o=1,s=t;s>=256;s>>=8)o++;for(var u=new Array(o),c=u.length-1;c>=0;c--)u[c]=255&t,t>>=8;return 128&u[0]&&u.unshift(0),this._createEncoderBuffer(i.from(u))},u.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},u.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},u.prototype._skipDefault=function(t,e,n){var r,i=this._baseState;if(null===i.default)return!1;var a=t.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,e,n).join()),a.length!==i.defaultBuffer.length)return!1;for(r=0;r<a.length;r++)if(a[r]!==i.defaultBuffer[r])return!1;return!0}},function(t,e,n){"use strict";var r=e;r.der=n(163),r.pem=n(351)},function(t,e,n){"use strict";var r=n(3),i=n(2),a=n(46).DecoderBuffer,o=n(86),s=n(88);function u(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new c,this.tree._init(t.body)}function c(t){o.call(this,"der",t)}function A(t,e){var n=t.readUInt8(e);if(t.isError(n))return n;var r=s.tagClass[n>>6],i=0==(32&n);if(31==(31&n)){var a=n;for(n=0;128==(128&a);){if(a=t.readUInt8(e),t.isError(a))return a;n<<=7,n|=127&a}}else n&=31;return{cls:r,primitive:i,tag:n,tagStr:s.tag[n]}}function f(t,e,n){var r=t.readUInt8(n);if(t.isError(r))return r;if(!e&&128===r)return null;if(0==(128&r))return r;var i=127&r;if(i>4)return t.error("length octect is too long");r=0;for(var a=0;a<i;a++){r<<=8;var o=t.readUInt8(n);if(t.isError(o))return o;r|=o}return r}t.exports=u,u.prototype.decode=function(t,e){return a.isDecoderBuffer(t)||(t=new a(t,e)),this.tree._decode(t,e)},r(c,o),c.prototype._peekTag=function(t,e,n){if(t.isEmpty())return!1;var r=t.save(),i=A(t,'Failed to peek tag: "'+e+'"');return t.isError(i)?i:(t.restore(r),i.tag===e||i.tagStr===e||i.tagStr+"of"===e||n)},c.prototype._decodeTag=function(t,e,n){var r=A(t,'Failed to decode tag of "'+e+'"');if(t.isError(r))return r;var i=f(t,r.primitive,'Failed to get length of "'+e+'"');if(t.isError(i))return i;if(!n&&r.tag!==e&&r.tagStr!==e&&r.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(r.primitive||null!==i)return t.skip(i,'Failed to match body of: "'+e+'"');var a=t.save(),o=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(o)?o:(i=t.offset-a.offset,t.restore(a),t.skip(i,'Failed to match body of: "'+e+'"'))},c.prototype._skipUntilEnd=function(t,e){for(;;){var n=A(t,e);if(t.isError(n))return n;var r=f(t,n.primitive,e);if(t.isError(r))return r;var i=void 0;if(i=n.primitive||null!==r?t.skip(r):this._skipUntilEnd(t,e),t.isError(i))return i;if("end"===n.tagStr)break}},c.prototype._decodeList=function(t,e,n,r){for(var i=[];!t.isEmpty();){var a=this._peekTag(t,"end");if(t.isError(a))return a;var o=n.decode(t,"der",r);if(t.isError(o)&&a)break;i.push(o)}return i},c.prototype._decodeStr=function(t,e){if("bitstr"===e){var n=t.readUInt8();return t.isError(n)?n:{unused:n,data:t.raw()}}if("bmpstr"===e){var r=t.raw();if(r.length%2==1)return t.error("Decoding of string type: bmpstr length mismatch");for(var i="",a=0;a<r.length/2;a++)i+=String.fromCharCode(r.readUInt16BE(2*a));return i}if("numstr"===e){var o=t.raw().toString("ascii");return this._isNumstr(o)?o:t.error("Decoding of string type: numstr unsupported characters")}if("octstr"===e)return t.raw();if("objDesc"===e)return t.raw();if("printstr"===e){var s=t.raw().toString("ascii");return this._isPrintstr(s)?s:t.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(e)?t.raw().toString():t.error("Decoding of string type: "+e+" unsupported")},c.prototype._decodeObjid=function(t,e,n){for(var r,i=[],a=0,o=0;!t.isEmpty();)a<<=7,a|=127&(o=t.readUInt8()),0==(128&o)&&(i.push(a),a=0);128&o&&i.push(a);var s=i[0]/40|0,u=i[0]%40;if(r=n?i:[s,u].concat(i.slice(1)),e){var c=e[r.join(" ")];void 0===c&&(c=e[r.join(".")]),void 0!==c&&(r=c)}return r},c.prototype._decodeTime=function(t,e){var n,r,i,a,o,s,u=t.raw().toString();if("gentime"===e)n=0|u.slice(0,4),r=0|u.slice(4,6),i=0|u.slice(6,8),a=0|u.slice(8,10),o=0|u.slice(10,12),s=0|u.slice(12,14);else{if("utctime"!==e)return t.error("Decoding "+e+" time is not supported yet");n=0|u.slice(0,2),r=0|u.slice(2,4),i=0|u.slice(4,6),a=0|u.slice(6,8),o=0|u.slice(8,10),s=0|u.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,r-1,i,a,o,s,0)},c.prototype._decodeNull=function(){return null},c.prototype._decodeBool=function(t){var e=t.readUInt8();return t.isError(e)?e:0!==e},c.prototype._decodeInt=function(t,e){var n=t.raw(),r=new i(n);return e&&(r=e[r.toString(10)]||r),r},c.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getDecoder("der").tree}},function(t){t.exports=JSON.parse('{"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}')},function(t,e,n){(function(e){var r=n(83),i=n(2);t.exports=function(t){return new o(t)};var a={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function o(t){this.curveType=a[t],this.curveType||(this.curveType={name:t}),this.curve=new r.ec(this.curveType.name),this.keys=void 0}function s(t,n,r){Array.isArray(t)||(t=t.toArray());var i=new e(t);if(r&&i.length<r){var a=new e(r-i.length);a.fill(0),i=e.concat([a,i])}return n?i.toString(n):i}a.p224=a.secp224r1,a.p256=a.secp256r1=a.prime256v1,a.p192=a.secp192r1=a.prime192v1,a.p384=a.secp384r1,a.p521=a.secp521r1,o.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)},o.prototype.computeSecret=function(t,n,r){return n=n||"utf8",e.isBuffer(t)||(t=new e(t,n)),s(this.curve.keyFromPublic(t).getPublic().mul(this.keys.getPrivate()).getX(),r,this.curveType.byteLength)},o.prototype.getPublicKey=function(t,e){var n=this.keys.getPublic("compressed"===e,!0);return"hybrid"===e&&(n[n.length-1]%2?n[0]=7:n[0]=6),s(n,t)},o.prototype.getPrivateKey=function(t){return s(this.keys.getPrivate(),t)},o.prototype.setPublicKey=function(t,n){return n=n||"utf8",e.isBuffer(t)||(t=new e(t,n)),this.keys._importPublic(t),this},o.prototype.setPrivateKey=function(t,n){n=n||"utf8",e.isBuffer(t)||(t=new e(t,n));var r=new i(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this}}).call(this,n(5).Buffer)},function(t,e,n){e.publicEncrypt=n(358),e.privateDecrypt=n(359),e.privateEncrypt=function(t,n){return e.publicEncrypt(t,n,!0)},e.publicDecrypt=function(t,n){return e.privateDecrypt(t,n,!0)}},function(t,e,n){var r=n(33),i=n(4).Buffer;function a(t){var e=i.allocUnsafe(4);return e.writeUInt32BE(t,0),e}t.exports=function(t,e){for(var n,o=i.alloc(0),s=0;o.length<e;)n=a(s++),o=i.concat([o,r("sha1").update(t).update(n).digest()]);return o.slice(0,e)}},function(t,e){t.exports=function(t,e){for(var n=t.length,r=-1;++r<n;)t[r]^=e[r];return t}},function(t,e,n){var r=n(2),i=n(4).Buffer;t.exports=function(t,e){return i.from(t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed().toArray())}},function(t,e,n){"use strict";(function(t,r){function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var a=n(4),o=n(29),s=a.Buffer,u=a.kMaxLength,c=t.crypto||t.msCrypto,A=Math.pow(2,32)-1;function f(t,e){if("number"!=typeof t||t!=t)throw new TypeError("offset must be a number");if(t>A||t<0)throw new TypeError("offset must be a uint32");if(t>u||t>e)throw new RangeError("offset out of range")}function l(t,e,n){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>A||t<0)throw new TypeError("size must be a uint32");if(t+e>n||t>u)throw new RangeError("buffer too small")}function p(t,e,n,i){if(r.browser){var a=t.buffer,s=new Uint8Array(a,e,n);return c.getRandomValues(s),i?void r.nextTick((function(){i(null,t)})):t}if(!i)return o(n).copy(t,e),t;o(n,(function(n,r){if(n)return i(n);r.copy(t,e),i(null,t)}))}c&&c.getRandomValues||!r.browser?(e.randomFill=function(e,n,r,i){if(!(s.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof n)i=n,n=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-n;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(n,e.length),l(r,n,e.length),p(e,n,r,i)},e.randomFillSync=function(e,n,r){void 0===n&&(n=0);if(!(s.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(n,e.length),void 0===r&&(r=e.length-n);return l(r,n,e.length),p(e,n,r)}):(e.randomFill=i,e.randomFillSync=i)}).call(this,n(8),n(11))},function(t,e,n){(function(t){var r,i,a,o;function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(i=r.key,a=void 0,a=function(t,e){if("object"!==A(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==A(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"),"symbol"===A(a)?a:String(a)),r)}var i,a}function c(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function A(t){return(A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}window,o=function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==A(t)&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return a}));var r=n(7),i=n.n(r),a=function(){function e(t){s(this,e),this.wasm=t}return c(e,[{key:"arrayToBuf",value:function(e){var n=this.wasm,r={ptr:null,len:0};if(!e)return r;var i=null;if(e instanceof Uint8Array||void 0!==t&&e instanceof t)i=e;else{if(!(e instanceof ArrayBuffer||e.__proto__.toString().includes("ArrayBuffer")))throw new Error("arrayToBuf() failed: Expected Uint8Array, Buffer, or\n ArrayBuffer");i=new Uint8Array(e)}return r.len=i.length,r.ptr=n._malloc(i.length),n.writeArrayToMemory(i,r.ptr),r}},{key:"arrayToSmartBuf",value:function(t){var e=this.wasm,n=this.arrayToBuf(t);return n.ptr&&setTimeout((function(){e._free(n.ptr),n.len=0,n.ptr=null}),0),n}},{key:"smartMalloc",value:function(t){var e=this.wasm,n=e._malloc(t);return setTimeout((function(){e._free(n)}),0),n}}],[{key:"bytesToHex",value:function(t){return t.reduce((function(t,e){return t+e.toString(16).padStart(2,"0")}),"")}},{key:"bytesToBinary",value:function(t){return t.reduce((function(t,e){return t+e.toString(2).padStart(8,"0")+" "}),"")}},{key:"hexToBytes",value:function(t){return new Uint8Array(t.match(/.{1,2}/g).map((function(t){return parseInt(t,16)})))}},{key:"randomBytes",value:function(t){if("undefined"!=typeof window&&"undefined"!==window.crypto){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),e}return i.a.randomBytes(t)}}]),e}()}).call(this,n(3).Buffer)},function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));var r=function(){function t(e){s(this,t),this.wasm=e,this.ptr=null,this.len=0}return c(t,[{key:"clear",value:function(){this.len=0}},{key:"free",value:function(){null!==this.ptr&&(this.wasm._free(this.ptr),this.len=0,this.ptr=null)}},{key:"resize",value:function(t){null!==this.ptr&&this.free(),this.len=t,this.ptr=this.wasm._malloc(t)}},{key:"ensureSize",value:function(t){(null===this.ptr||this.len<t)&&this.resize(t)}}]),t}()},function(t,e){t.exports=n(360)},function(t,e,n){"use strict";(function(t){
52
52
  /*!
53
53
  * The buffer module from node.js, for the browser.
54
54
  *