exceljs.js 2.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601
  1. (function (f) { if (typeof exports === "object" && typeof module !== "undefined") { module.exports = f() } else if (typeof define === "function" && define.amd) { define([], f) } else { var g; if (typeof window !== "undefined") { g = window } else if (typeof global !== "undefined") { g = global } else if (typeof self !== "undefined") { g = self } else { g = this } g.ExcelJS = f() } })(function () {
  2. var define, module, exports; return (function () { function r(e, n, t) { function o(i, f) { if (!n[i]) { if (!e[i]) { var c = "function" == typeof require && require; if (!f && c) return c(i, !0); if (u) return u(i, !0); var a = new Error("Cannot find module '" + i + "'"); throw a.code = "MODULE_NOT_FOUND", a } var p = n[i] = { exports: {} }; e[i][0].call(p.exports, function (r) { var n = e[i][1][r]; return o(n || r) }, p, p.exports, r, e, n, t) } return n[i].exports } for (var u = "function" == typeof require && require, i = 0; i < t.length; i++)o(t[i]); return o } return r })()({
  3. 1: [function (require, module, exports) {
  4. "use strict";
  5. String.prototype.startsWith = String.prototype.startsWith || function (str) {
  6. var reg = new RegExp("^" + str);
  7. return reg.test(this);
  8. }
  9. String.prototype.endsWith = String.prototype.endsWith || function (str) {
  10. var reg = new RegExp(str + "$");
  11. return reg.test(this);
  12. }
  13. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  15. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  16. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  18. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  19. var fs = require('fs');
  20. var fastCsv = require('fast-csv');
  21. var customParseFormat = require('dayjs/plugin/customParseFormat');
  22. var utc = require('dayjs/plugin/utc');
  23. var dayjs = require('dayjs').extend(customParseFormat).extend(utc);
  24. var StreamBuf = require('../utils/stream-buf');
  25. var _require = require('../utils/utils'),
  26. exists = _require.fs.exists;
  27. /* eslint-disable quote-props */
  28. var SpecialValues = {
  29. true: true,
  30. false: false,
  31. '#N/A': {
  32. error: '#N/A'
  33. },
  34. '#REF!': {
  35. error: '#REF!'
  36. },
  37. '#NAME?': {
  38. error: '#NAME?'
  39. },
  40. '#DIV/0!': {
  41. error: '#DIV/0!'
  42. },
  43. '#NULL!': {
  44. error: '#NULL!'
  45. },
  46. '#VALUE!': {
  47. error: '#VALUE!'
  48. },
  49. '#NUM!': {
  50. error: '#NUM!'
  51. }
  52. };
  53. /* eslint-ensable quote-props */
  54. var CSV = /*#__PURE__*/function () {
  55. function CSV(workbook) {
  56. _classCallCheck(this, CSV);
  57. this.workbook = workbook;
  58. this.worksheet = null;
  59. }
  60. _createClass(CSV, [{
  61. key: "readFile",
  62. value: function () {
  63. var _readFile = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(filename, options) {
  64. var stream, worksheet;
  65. return regeneratorRuntime.wrap(function _callee$(_context) {
  66. while (1) {
  67. switch (_context.prev = _context.next) {
  68. case 0:
  69. options = options || {};
  70. _context.next = 3;
  71. return exists(filename);
  72. case 3:
  73. if (_context.sent) {
  74. _context.next = 5;
  75. break;
  76. }
  77. throw new Error("File not found: ".concat(filename));
  78. case 5:
  79. stream = fs.createReadStream(filename);
  80. _context.next = 8;
  81. return this.read(stream, options);
  82. case 8:
  83. worksheet = _context.sent;
  84. stream.close();
  85. return _context.abrupt("return", worksheet);
  86. case 11:
  87. case "end":
  88. return _context.stop();
  89. }
  90. }
  91. }, _callee, this);
  92. }));
  93. function readFile(_x, _x2) {
  94. return _readFile.apply(this, arguments);
  95. }
  96. return readFile;
  97. }()
  98. }, {
  99. key: "read",
  100. value: function read(stream, options) {
  101. var _this = this;
  102. options = options || {};
  103. return new Promise(function (resolve, reject) {
  104. var worksheet = _this.workbook.addWorksheet(options.sheetName);
  105. var dateFormats = options.dateFormats || ['YYYY-MM-DD[T]HH:mm:ssZ', 'YYYY-MM-DD[T]HH:mm:ss', 'MM-DD-YYYY', 'YYYY-MM-DD'];
  106. var map = options.map || function (datum) {
  107. if (datum === '') {
  108. return null;
  109. }
  110. var datumNumber = Number(datum);
  111. if (!Number.isNaN(datumNumber) && datumNumber !== Infinity) {
  112. return datumNumber;
  113. }
  114. var dt = dateFormats.reduce(function (matchingDate, currentDateFormat) {
  115. if (matchingDate) {
  116. return matchingDate;
  117. }
  118. var dayjsObj = dayjs(datum, currentDateFormat, true);
  119. if (dayjsObj.isValid()) {
  120. return dayjsObj;
  121. }
  122. return null;
  123. }, null);
  124. if (dt) {
  125. return new Date(dt.valueOf());
  126. }
  127. var special = SpecialValues[datum];
  128. if (special !== undefined) {
  129. return special;
  130. }
  131. return datum;
  132. };
  133. var csvStream = fastCsv.parse(options.parserOptions).on('data', function (data) {
  134. worksheet.addRow(data.map(map));
  135. }).on('end', function () {
  136. csvStream.emit('worksheet', worksheet);
  137. });
  138. csvStream.on('worksheet', resolve).on('error', reject);
  139. stream.pipe(csvStream);
  140. });
  141. }
  142. /**
  143. * @deprecated since version 4.0. You should use `CSV#read` instead. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md
  144. */
  145. }, {
  146. key: "createInputStream",
  147. value: function createInputStream() {
  148. throw new Error('`CSV#createInputStream` is deprecated. You should use `CSV#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md');
  149. }
  150. }, {
  151. key: "write",
  152. value: function write(stream, options) {
  153. var _this2 = this;
  154. return new Promise(function (resolve, reject) {
  155. options = options || {}; // const encoding = options.encoding || 'utf8';
  156. // const separator = options.separator || ',';
  157. // const quoteChar = options.quoteChar || '\'';
  158. var worksheet = _this2.workbook.getWorksheet(options.sheetName || options.sheetId);
  159. var csvStream = fastCsv.format(options.formatterOptions);
  160. stream.on('finish', function () {
  161. resolve();
  162. });
  163. csvStream.on('error', reject);
  164. csvStream.pipe(stream);
  165. var _options = options,
  166. dateFormat = _options.dateFormat,
  167. dateUTC = _options.dateUTC;
  168. var map = options.map || function (value) {
  169. if (value) {
  170. if (value.text || value.hyperlink) {
  171. return value.hyperlink || value.text || '';
  172. }
  173. if (value.formula || value.result) {
  174. return value.result || '';
  175. }
  176. if (value instanceof Date) {
  177. if (dateFormat) {
  178. return dateUTC ? dayjs.utc(value).format(dateFormat) : dayjs(value).format(dateFormat);
  179. }
  180. return dateUTC ? dayjs.utc(value).format() : dayjs(value).format();
  181. }
  182. if (value.error) {
  183. return value.error;
  184. }
  185. if (_typeof(value) === 'object') {
  186. return JSON.stringify(value);
  187. }
  188. }
  189. return value;
  190. };
  191. var includeEmptyRows = options.includeEmptyRows === undefined || options.includeEmptyRows;
  192. var lastRow = 1;
  193. if (worksheet) {
  194. worksheet.eachRow(function (row, rowNumber) {
  195. if (includeEmptyRows) {
  196. while (lastRow++ < rowNumber - 1) {
  197. csvStream.write([]);
  198. }
  199. }
  200. var values = row.values;
  201. values.shift();
  202. csvStream.write(values.map(map));
  203. lastRow = rowNumber;
  204. });
  205. }
  206. csvStream.end();
  207. });
  208. }
  209. }, {
  210. key: "writeFile",
  211. value: function writeFile(filename, options) {
  212. options = options || {};
  213. var streamOptions = {
  214. encoding: options.encoding || 'utf8'
  215. };
  216. var stream = fs.createWriteStream(filename, streamOptions);
  217. return this.write(stream, options);
  218. }
  219. }, {
  220. key: "writeBuffer",
  221. value: function () {
  222. var _writeBuffer = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(options) {
  223. var stream;
  224. return regeneratorRuntime.wrap(function _callee2$(_context2) {
  225. while (1) {
  226. switch (_context2.prev = _context2.next) {
  227. case 0:
  228. stream = new StreamBuf();
  229. _context2.next = 3;
  230. return this.write(stream, options);
  231. case 3:
  232. return _context2.abrupt("return", stream.read());
  233. case 4:
  234. case "end":
  235. return _context2.stop();
  236. }
  237. }
  238. }, _callee2, this);
  239. }));
  240. function writeBuffer(_x3) {
  241. return _writeBuffer.apply(this, arguments);
  242. }
  243. return writeBuffer;
  244. }()
  245. }]);
  246. return CSV;
  247. }();
  248. module.exports = CSV;
  249. }, { "../utils/stream-buf": 23, "../utils/utils": 26, "dayjs": 336, "dayjs/plugin/customParseFormat": 337, "dayjs/plugin/utc": 338, "fast-csv": 369, "fs": 215 }], 2: [function (require, module, exports) {
  250. 'use strict';
  251. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  252. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  253. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  254. var colCache = require('../utils/col-cache');
  255. var Anchor = /*#__PURE__*/function () {
  256. function Anchor(worksheet, address) {
  257. var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  258. _classCallCheck(this, Anchor);
  259. if (!address) {
  260. this.nativeCol = 0;
  261. this.nativeColOff = 0;
  262. this.nativeRow = 0;
  263. this.nativeRowOff = 0;
  264. } else if (typeof address === 'string') {
  265. var decoded = colCache.decodeAddress(address);
  266. this.nativeCol = decoded.col + offset;
  267. this.nativeColOff = 0;
  268. this.nativeRow = decoded.row + offset;
  269. this.nativeRowOff = 0;
  270. } else if (address.nativeCol !== undefined) {
  271. this.nativeCol = address.nativeCol || 0;
  272. this.nativeColOff = address.nativeColOff || 0;
  273. this.nativeRow = address.nativeRow || 0;
  274. this.nativeRowOff = address.nativeRowOff || 0;
  275. } else if (address.col !== undefined) {
  276. this.col = address.col + offset;
  277. this.row = address.row + offset;
  278. } else {
  279. this.nativeCol = 0;
  280. this.nativeColOff = 0;
  281. this.nativeRow = 0;
  282. this.nativeRowOff = 0;
  283. }
  284. this.worksheet = worksheet;
  285. }
  286. _createClass(Anchor, [{
  287. key: "col",
  288. get: function get() {
  289. return this.nativeCol + Math.min(this.colWidth - 1, this.nativeColOff) / this.colWidth;
  290. },
  291. set: function set(v) {
  292. this.nativeCol = Math.floor(v);
  293. this.nativeColOff = Math.floor((v - this.nativeCol) * this.colWidth);
  294. }
  295. }, {
  296. key: "row",
  297. get: function get() {
  298. return this.nativeRow + Math.min(this.rowHeight - 1, this.nativeRowOff) / this.rowHeight;
  299. },
  300. set: function set(v) {
  301. this.nativeRow = Math.floor(v);
  302. this.nativeRowOff = Math.floor((v - this.nativeRow) * this.rowHeight);
  303. }
  304. }, {
  305. key: "colWidth",
  306. get: function get() {
  307. return this.worksheet && this.worksheet.getColumn(this.nativeCol + 1) && this.worksheet.getColumn(this.nativeCol + 1).isCustomWidth ? Math.floor(this.worksheet.getColumn(this.nativeCol + 1).width * 10000) : 640000;
  308. }
  309. }, {
  310. key: "rowHeight",
  311. get: function get() {
  312. return this.worksheet && this.worksheet.getRow(this.nativeRow + 1) && this.worksheet.getRow(this.nativeRow + 1).height ? Math.floor(this.worksheet.getRow(this.nativeRow + 1).height * 10000) : 180000;
  313. }
  314. }, {
  315. key: "model",
  316. get: function get() {
  317. return {
  318. nativeCol: this.nativeCol,
  319. nativeColOff: this.nativeColOff,
  320. nativeRow: this.nativeRow,
  321. nativeRowOff: this.nativeRowOff
  322. };
  323. },
  324. set: function set(value) {
  325. this.nativeCol = value.nativeCol;
  326. this.nativeColOff = value.nativeColOff;
  327. this.nativeRow = value.nativeRow;
  328. this.nativeRowOff = value.nativeRowOff;
  329. }
  330. }], [{
  331. key: "asInstance",
  332. value: function asInstance(model) {
  333. return model instanceof Anchor || model == null ? model : new Anchor(model);
  334. }
  335. }]);
  336. return Anchor;
  337. }();
  338. module.exports = Anchor;
  339. }, { "../utils/col-cache": 19 }], 3: [function (require, module, exports) {
  340. "use strict";
  341. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  342. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  343. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  344. /* eslint-disable max-classes-per-file */
  345. var colCache = require('../utils/col-cache');
  346. var _ = require('../utils/under-dash');
  347. var Enums = require('./enums');
  348. var _require = require('../utils/shared-formula'),
  349. slideFormula = _require.slideFormula;
  350. var Note = require('./note'); // Cell requirements
  351. // Operate inside a worksheet
  352. // Store and retrieve a value with a range of types: text, number, date, hyperlink, reference, formula, etc.
  353. // Manage/use and manipulate cell format either as local to cell or inherited from column or row.
  354. var Cell = /*#__PURE__*/function () {
  355. function Cell(row, column, address) {
  356. _classCallCheck(this, Cell);
  357. if (!row || !column) {
  358. throw new Error('A Cell needs a Row');
  359. }
  360. this._row = row;
  361. this._column = column;
  362. colCache.validateAddress(address);
  363. this._address = address; // TODO: lazy evaluation of this._value
  364. this._value = Value.create(Cell.Types.Null, this);
  365. this.style = this._mergeStyle(row.style, column.style, {});
  366. this._mergeCount = 0;
  367. }
  368. _createClass(Cell, [{
  369. key: "destroy",
  370. // help GC by removing cyclic (and other) references
  371. value: function destroy() {
  372. delete this.style;
  373. delete this._value;
  374. delete this._row;
  375. delete this._column;
  376. delete this._address;
  377. } // =========================================================================
  378. // Styles stuff
  379. }, {
  380. key: "_mergeStyle",
  381. value: function _mergeStyle(rowStyle, colStyle, style) {
  382. var numFmt = rowStyle && rowStyle.numFmt || colStyle && colStyle.numFmt;
  383. if (numFmt) style.numFmt = numFmt;
  384. var font = rowStyle && rowStyle.font || colStyle && colStyle.font;
  385. if (font) style.font = font;
  386. var alignment = rowStyle && rowStyle.alignment || colStyle && colStyle.alignment;
  387. if (alignment) style.alignment = alignment;
  388. var border = rowStyle && rowStyle.border || colStyle && colStyle.border;
  389. if (border) style.border = border;
  390. var fill = rowStyle && rowStyle.fill || colStyle && colStyle.fill;
  391. if (fill) style.fill = fill;
  392. var protection = rowStyle && rowStyle.protection || colStyle && colStyle.protection;
  393. if (protection) style.protection = protection;
  394. return style;
  395. } // =========================================================================
  396. // return the address for this cell
  397. }, {
  398. key: "toCsvString",
  399. value: function toCsvString() {
  400. return this._value.toCsvString();
  401. } // =========================================================================
  402. // Merge stuff
  403. }, {
  404. key: "addMergeRef",
  405. value: function addMergeRef() {
  406. this._mergeCount++;
  407. }
  408. }, {
  409. key: "releaseMergeRef",
  410. value: function releaseMergeRef() {
  411. this._mergeCount--;
  412. }
  413. }, {
  414. key: "merge",
  415. value: function merge(master, ignoreStyle) {
  416. this._value.release();
  417. this._value = Value.create(Cell.Types.Merge, this, master);
  418. if (!ignoreStyle) {
  419. this.style = master.style;
  420. }
  421. }
  422. }, {
  423. key: "unmerge",
  424. value: function unmerge() {
  425. if (this.type === Cell.Types.Merge) {
  426. this._value.release();
  427. this._value = Value.create(Cell.Types.Null, this);
  428. this.style = this._mergeStyle(this._row.style, this._column.style, {});
  429. }
  430. }
  431. }, {
  432. key: "isMergedTo",
  433. value: function isMergedTo(master) {
  434. if (this._value.type !== Cell.Types.Merge) return false;
  435. return this._value.isMergedTo(master);
  436. }
  437. }, {
  438. key: "toString",
  439. value: function toString() {
  440. return this.text;
  441. }
  442. }, {
  443. key: "_upgradeToHyperlink",
  444. value: function _upgradeToHyperlink(hyperlink) {
  445. // if this cell is a string, turn it into a Hyperlink
  446. if (this.type === Cell.Types.String) {
  447. this._value = Value.create(Cell.Types.Hyperlink, this, {
  448. text: this._value.value,
  449. hyperlink: hyperlink
  450. });
  451. }
  452. } // =========================================================================
  453. // Formula stuff
  454. }, {
  455. key: "addName",
  456. value: function addName(name) {
  457. this.workbook.definedNames.addEx(this.fullAddress, name);
  458. }
  459. }, {
  460. key: "removeName",
  461. value: function removeName(name) {
  462. this.workbook.definedNames.removeEx(this.fullAddress, name);
  463. }
  464. }, {
  465. key: "removeAllNames",
  466. value: function removeAllNames() {
  467. this.workbook.definedNames.removeAllNames(this.fullAddress);
  468. } // =========================================================================
  469. // Data Validation stuff
  470. }, {
  471. key: "worksheet",
  472. get: function get() {
  473. return this._row.worksheet;
  474. }
  475. }, {
  476. key: "workbook",
  477. get: function get() {
  478. return this._row.worksheet.workbook;
  479. }
  480. }, {
  481. key: "numFmt",
  482. get: function get() {
  483. return this.style.numFmt;
  484. },
  485. set: function set(value) {
  486. this.style.numFmt = value;
  487. }
  488. }, {
  489. key: "font",
  490. get: function get() {
  491. return this.style.font;
  492. },
  493. set: function set(value) {
  494. this.style.font = value;
  495. }
  496. }, {
  497. key: "alignment",
  498. get: function get() {
  499. return this.style.alignment;
  500. },
  501. set: function set(value) {
  502. this.style.alignment = value;
  503. }
  504. }, {
  505. key: "border",
  506. get: function get() {
  507. return this.style.border;
  508. },
  509. set: function set(value) {
  510. this.style.border = value;
  511. }
  512. }, {
  513. key: "fill",
  514. get: function get() {
  515. return this.style.fill;
  516. },
  517. set: function set(value) {
  518. this.style.fill = value;
  519. }
  520. }, {
  521. key: "protection",
  522. get: function get() {
  523. return this.style.protection;
  524. },
  525. set: function set(value) {
  526. this.style.protection = value;
  527. }
  528. }, {
  529. key: "address",
  530. get: function get() {
  531. return this._address;
  532. }
  533. }, {
  534. key: "row",
  535. get: function get() {
  536. return this._row.number;
  537. }
  538. }, {
  539. key: "col",
  540. get: function get() {
  541. return this._column.number;
  542. }
  543. }, {
  544. key: "$col$row",
  545. get: function get() {
  546. return "$".concat(this._column.letter, "$").concat(this.row);
  547. } // =========================================================================
  548. // Value stuff
  549. }, {
  550. key: "type",
  551. get: function get() {
  552. return this._value.type;
  553. }
  554. }, {
  555. key: "effectiveType",
  556. get: function get() {
  557. return this._value.effectiveType;
  558. }
  559. }, {
  560. key: "isMerged",
  561. get: function get() {
  562. return this._mergeCount > 0 || this.type === Cell.Types.Merge;
  563. }
  564. }, {
  565. key: "master",
  566. get: function get() {
  567. if (this.type === Cell.Types.Merge) {
  568. return this._value.master;
  569. }
  570. return this; // an unmerged cell is its own master
  571. }
  572. }, {
  573. key: "isHyperlink",
  574. get: function get() {
  575. return this._value.type === Cell.Types.Hyperlink;
  576. }
  577. }, {
  578. key: "hyperlink",
  579. get: function get() {
  580. return this._value.hyperlink;
  581. } // return the value
  582. }, {
  583. key: "value",
  584. get: function get() {
  585. return this._value.value;
  586. } // set the value - can be number, string or raw
  587. ,
  588. set: function set(v) {
  589. // special case - merge cells set their master's value
  590. if (this.type === Cell.Types.Merge) {
  591. this._value.master.value = v;
  592. return;
  593. }
  594. this._value.release(); // assign value
  595. this._value = Value.create(Value.getType(v), this, v);
  596. }
  597. }, {
  598. key: "note",
  599. get: function get() {
  600. return this._comment && this._comment.note;
  601. },
  602. set: function set(note) {
  603. this._comment = new Note(note);
  604. }
  605. }, {
  606. key: "text",
  607. get: function get() {
  608. return this._value.toString();
  609. }
  610. }, {
  611. key: "html",
  612. get: function get() {
  613. return _.escapeHtml(this.text);
  614. }
  615. }, {
  616. key: "formula",
  617. get: function get() {
  618. return this._value.formula;
  619. }
  620. }, {
  621. key: "result",
  622. get: function get() {
  623. return this._value.result;
  624. }
  625. }, {
  626. key: "formulaType",
  627. get: function get() {
  628. return this._value.formulaType;
  629. } // =========================================================================
  630. // Name stuff
  631. }, {
  632. key: "fullAddress",
  633. get: function get() {
  634. var worksheet = this._row.worksheet;
  635. return {
  636. sheetName: worksheet.name,
  637. address: this.address,
  638. row: this.row,
  639. col: this.col
  640. };
  641. }
  642. }, {
  643. key: "name",
  644. get: function get() {
  645. return this.names[0];
  646. },
  647. set: function set(value) {
  648. this.names = [value];
  649. }
  650. }, {
  651. key: "names",
  652. get: function get() {
  653. return this.workbook.definedNames.getNamesEx(this.fullAddress);
  654. },
  655. set: function set(value) {
  656. var _this = this;
  657. var definedNames = this.workbook.definedNames;
  658. definedNames.removeAllNames(this.fullAddress);
  659. value.forEach(function (name) {
  660. definedNames.addEx(_this.fullAddress, name);
  661. });
  662. }
  663. }, {
  664. key: "_dataValidations",
  665. get: function get() {
  666. return this.worksheet.dataValidations;
  667. }
  668. }, {
  669. key: "dataValidation",
  670. get: function get() {
  671. return this._dataValidations.find(this.address);
  672. },
  673. set: function set(value) {
  674. this._dataValidations.add(this.address, value);
  675. } // =========================================================================
  676. // Model stuff
  677. }, {
  678. key: "model",
  679. get: function get() {
  680. var model = this._value.model;
  681. model.style = this.style;
  682. if (this._comment) {
  683. model.comment = this._comment.model;
  684. }
  685. return model;
  686. },
  687. set: function set(value) {
  688. this._value.release();
  689. this._value = Value.create(value.type, this);
  690. this._value.model = value;
  691. if (value.comment) {
  692. switch (value.comment.type) {
  693. case 'note':
  694. this._comment = Note.fromModel(value.comment);
  695. break;
  696. }
  697. }
  698. if (value.style) {
  699. this.style = value.style;
  700. } else {
  701. this.style = {};
  702. }
  703. }
  704. }]);
  705. return Cell;
  706. }();
  707. Cell.Types = Enums.ValueType; // =============================================================================
  708. // Internal Value Types
  709. var NullValue = /*#__PURE__*/function () {
  710. function NullValue(cell) {
  711. _classCallCheck(this, NullValue);
  712. this.model = {
  713. address: cell.address,
  714. type: Cell.Types.Null
  715. };
  716. }
  717. _createClass(NullValue, [{
  718. key: "toCsvString",
  719. value: function toCsvString() {
  720. return '';
  721. }
  722. }, {
  723. key: "release",
  724. value: function release() { }
  725. }, {
  726. key: "toString",
  727. value: function toString() {
  728. return '';
  729. }
  730. }, {
  731. key: "value",
  732. get: function get() {
  733. return null;
  734. },
  735. set: function set(value) {// nothing to do
  736. }
  737. }, {
  738. key: "type",
  739. get: function get() {
  740. return Cell.Types.Null;
  741. }
  742. }, {
  743. key: "effectiveType",
  744. get: function get() {
  745. return Cell.Types.Null;
  746. }
  747. }, {
  748. key: "address",
  749. get: function get() {
  750. return this.model.address;
  751. },
  752. set: function set(value) {
  753. this.model.address = value;
  754. }
  755. }]);
  756. return NullValue;
  757. }();
  758. var NumberValue = /*#__PURE__*/function () {
  759. function NumberValue(cell, value) {
  760. _classCallCheck(this, NumberValue);
  761. this.model = {
  762. address: cell.address,
  763. type: Cell.Types.Number,
  764. value: value
  765. };
  766. }
  767. _createClass(NumberValue, [{
  768. key: "toCsvString",
  769. value: function toCsvString() {
  770. return this.model.value.toString();
  771. }
  772. }, {
  773. key: "release",
  774. value: function release() { }
  775. }, {
  776. key: "toString",
  777. value: function toString() {
  778. return this.model.value.toString();
  779. }
  780. }, {
  781. key: "value",
  782. get: function get() {
  783. return this.model.value;
  784. },
  785. set: function set(value) {
  786. this.model.value = value;
  787. }
  788. }, {
  789. key: "type",
  790. get: function get() {
  791. return Cell.Types.Number;
  792. }
  793. }, {
  794. key: "effectiveType",
  795. get: function get() {
  796. return Cell.Types.Number;
  797. }
  798. }, {
  799. key: "address",
  800. get: function get() {
  801. return this.model.address;
  802. },
  803. set: function set(value) {
  804. this.model.address = value;
  805. }
  806. }]);
  807. return NumberValue;
  808. }();
  809. var StringValue = /*#__PURE__*/function () {
  810. function StringValue(cell, value) {
  811. _classCallCheck(this, StringValue);
  812. this.model = {
  813. address: cell.address,
  814. type: Cell.Types.String,
  815. value: value
  816. };
  817. }
  818. _createClass(StringValue, [{
  819. key: "toCsvString",
  820. value: function toCsvString() {
  821. return "\"".concat(this.model.value.replace(/"/g, '""'), "\"");
  822. }
  823. }, {
  824. key: "release",
  825. value: function release() { }
  826. }, {
  827. key: "toString",
  828. value: function toString() {
  829. return this.model.value;
  830. }
  831. }, {
  832. key: "value",
  833. get: function get() {
  834. return this.model.value;
  835. },
  836. set: function set(value) {
  837. this.model.value = value;
  838. }
  839. }, {
  840. key: "type",
  841. get: function get() {
  842. return Cell.Types.String;
  843. }
  844. }, {
  845. key: "effectiveType",
  846. get: function get() {
  847. return Cell.Types.String;
  848. }
  849. }, {
  850. key: "address",
  851. get: function get() {
  852. return this.model.address;
  853. },
  854. set: function set(value) {
  855. this.model.address = value;
  856. }
  857. }]);
  858. return StringValue;
  859. }();
  860. var RichTextValue = /*#__PURE__*/function () {
  861. function RichTextValue(cell, value) {
  862. _classCallCheck(this, RichTextValue);
  863. this.model = {
  864. address: cell.address,
  865. type: Cell.Types.String,
  866. value: value
  867. };
  868. }
  869. _createClass(RichTextValue, [{
  870. key: "toString",
  871. value: function toString() {
  872. return this.model.value.richText.map(function (t) {
  873. return t.text;
  874. }).join('');
  875. }
  876. }, {
  877. key: "toCsvString",
  878. value: function toCsvString() {
  879. return "\"".concat(this.text.replace(/"/g, '""'), "\"");
  880. }
  881. }, {
  882. key: "release",
  883. value: function release() { }
  884. }, {
  885. key: "value",
  886. get: function get() {
  887. return this.model.value;
  888. },
  889. set: function set(value) {
  890. this.model.value = value;
  891. }
  892. }, {
  893. key: "type",
  894. get: function get() {
  895. return Cell.Types.RichText;
  896. }
  897. }, {
  898. key: "effectiveType",
  899. get: function get() {
  900. return Cell.Types.RichText;
  901. }
  902. }, {
  903. key: "address",
  904. get: function get() {
  905. return this.model.address;
  906. },
  907. set: function set(value) {
  908. this.model.address = value;
  909. }
  910. }]);
  911. return RichTextValue;
  912. }();
  913. var DateValue = /*#__PURE__*/function () {
  914. function DateValue(cell, value) {
  915. _classCallCheck(this, DateValue);
  916. this.model = {
  917. address: cell.address,
  918. type: Cell.Types.Date,
  919. value: value
  920. };
  921. }
  922. _createClass(DateValue, [{
  923. key: "toCsvString",
  924. value: function toCsvString() {
  925. return this.model.value.toISOString();
  926. }
  927. }, {
  928. key: "release",
  929. value: function release() { }
  930. }, {
  931. key: "toString",
  932. value: function toString() {
  933. return this.model.value.toString();
  934. }
  935. }, {
  936. key: "value",
  937. get: function get() {
  938. return this.model.value;
  939. },
  940. set: function set(value) {
  941. this.model.value = value;
  942. }
  943. }, {
  944. key: "type",
  945. get: function get() {
  946. return Cell.Types.Date;
  947. }
  948. }, {
  949. key: "effectiveType",
  950. get: function get() {
  951. return Cell.Types.Date;
  952. }
  953. }, {
  954. key: "address",
  955. get: function get() {
  956. return this.model.address;
  957. },
  958. set: function set(value) {
  959. this.model.address = value;
  960. }
  961. }]);
  962. return DateValue;
  963. }();
  964. var HyperlinkValue = /*#__PURE__*/function () {
  965. function HyperlinkValue(cell, value) {
  966. _classCallCheck(this, HyperlinkValue);
  967. this.model = {
  968. address: cell.address,
  969. type: Cell.Types.Hyperlink,
  970. text: value ? value.text : undefined,
  971. hyperlink: value ? value.hyperlink : undefined
  972. };
  973. if (value && value.tooltip) {
  974. this.model.tooltip = value.tooltip;
  975. }
  976. }
  977. _createClass(HyperlinkValue, [{
  978. key: "toCsvString",
  979. value: function toCsvString() {
  980. return this.model.hyperlink;
  981. }
  982. }, {
  983. key: "release",
  984. value: function release() { }
  985. }, {
  986. key: "toString",
  987. value: function toString() {
  988. return this.model.text;
  989. }
  990. }, {
  991. key: "value",
  992. get: function get() {
  993. var v = {
  994. text: this.model.text,
  995. hyperlink: this.model.hyperlink
  996. };
  997. if (this.model.tooltip) {
  998. v.tooltip = this.model.tooltip;
  999. }
  1000. return v;
  1001. },
  1002. set: function set(value) {
  1003. this.model = {
  1004. text: value.text,
  1005. hyperlink: value.hyperlink
  1006. };
  1007. if (value.tooltip) {
  1008. this.model.tooltip = value.tooltip;
  1009. }
  1010. }
  1011. }, {
  1012. key: "text",
  1013. get: function get() {
  1014. return this.model.text;
  1015. },
  1016. set: function set(value) {
  1017. this.model.text = value;
  1018. }
  1019. /*
  1020. get tooltip() {
  1021. return this.model.tooltip;
  1022. }
  1023. set tooltip(value) {
  1024. this.model.tooltip = value;
  1025. } */
  1026. }, {
  1027. key: "hyperlink",
  1028. get: function get() {
  1029. return this.model.hyperlink;
  1030. },
  1031. set: function set(value) {
  1032. this.model.hyperlink = value;
  1033. }
  1034. }, {
  1035. key: "type",
  1036. get: function get() {
  1037. return Cell.Types.Hyperlink;
  1038. }
  1039. }, {
  1040. key: "effectiveType",
  1041. get: function get() {
  1042. return Cell.Types.Hyperlink;
  1043. }
  1044. }, {
  1045. key: "address",
  1046. get: function get() {
  1047. return this.model.address;
  1048. },
  1049. set: function set(value) {
  1050. this.model.address = value;
  1051. }
  1052. }]);
  1053. return HyperlinkValue;
  1054. }();
  1055. var MergeValue = /*#__PURE__*/function () {
  1056. function MergeValue(cell, master) {
  1057. _classCallCheck(this, MergeValue);
  1058. this.model = {
  1059. address: cell.address,
  1060. type: Cell.Types.Merge,
  1061. master: master ? master.address : undefined
  1062. };
  1063. this._master = master;
  1064. if (master) {
  1065. master.addMergeRef();
  1066. }
  1067. }
  1068. _createClass(MergeValue, [{
  1069. key: "isMergedTo",
  1070. value: function isMergedTo(master) {
  1071. return master === this._master;
  1072. }
  1073. }, {
  1074. key: "toCsvString",
  1075. value: function toCsvString() {
  1076. return '';
  1077. }
  1078. }, {
  1079. key: "release",
  1080. value: function release() {
  1081. this._master.releaseMergeRef();
  1082. }
  1083. }, {
  1084. key: "toString",
  1085. value: function toString() {
  1086. return this.value.toString();
  1087. }
  1088. }, {
  1089. key: "value",
  1090. get: function get() {
  1091. return this._master.value;
  1092. },
  1093. set: function set(value) {
  1094. if (value instanceof Cell) {
  1095. if (this._master) {
  1096. this._master.releaseMergeRef();
  1097. }
  1098. value.addMergeRef();
  1099. this._master = value;
  1100. } else {
  1101. this._master.value = value;
  1102. }
  1103. }
  1104. }, {
  1105. key: "master",
  1106. get: function get() {
  1107. return this._master;
  1108. }
  1109. }, {
  1110. key: "type",
  1111. get: function get() {
  1112. return Cell.Types.Merge;
  1113. }
  1114. }, {
  1115. key: "effectiveType",
  1116. get: function get() {
  1117. return this._master.effectiveType;
  1118. }
  1119. }, {
  1120. key: "address",
  1121. get: function get() {
  1122. return this.model.address;
  1123. },
  1124. set: function set(value) {
  1125. this.model.address = value;
  1126. }
  1127. }]);
  1128. return MergeValue;
  1129. }();
  1130. var FormulaValue = /*#__PURE__*/function () {
  1131. function FormulaValue(cell, value) {
  1132. _classCallCheck(this, FormulaValue);
  1133. this.cell = cell;
  1134. this.model = {
  1135. address: cell.address,
  1136. type: Cell.Types.Formula,
  1137. shareType: value ? value.shareType : undefined,
  1138. ref: value ? value.ref : undefined,
  1139. formula: value ? value.formula : undefined,
  1140. sharedFormula: value ? value.sharedFormula : undefined,
  1141. result: value ? value.result : undefined
  1142. };
  1143. }
  1144. _createClass(FormulaValue, [{
  1145. key: "_copyModel",
  1146. value: function _copyModel(model) {
  1147. var copy = {};
  1148. var cp = function cp(name) {
  1149. var value = model[name];
  1150. if (value) {
  1151. copy[name] = value;
  1152. }
  1153. };
  1154. cp('formula');
  1155. cp('result');
  1156. cp('ref');
  1157. cp('shareType');
  1158. cp('sharedFormula');
  1159. return copy;
  1160. }
  1161. }, {
  1162. key: "validate",
  1163. value: function validate(value) {
  1164. switch (Value.getType(value)) {
  1165. case Cell.Types.Null:
  1166. case Cell.Types.String:
  1167. case Cell.Types.Number:
  1168. case Cell.Types.Date:
  1169. break;
  1170. case Cell.Types.Hyperlink:
  1171. case Cell.Types.Formula:
  1172. default:
  1173. throw new Error('Cannot process that type of result value');
  1174. }
  1175. }
  1176. }, {
  1177. key: "_getTranslatedFormula",
  1178. value: function _getTranslatedFormula() {
  1179. if (!this._translatedFormula && this.model.sharedFormula) {
  1180. var worksheet = this.cell.worksheet;
  1181. var master = worksheet.findCell(this.model.sharedFormula);
  1182. this._translatedFormula = master && slideFormula(master.formula, master.address, this.model.address);
  1183. }
  1184. return this._translatedFormula;
  1185. }
  1186. }, {
  1187. key: "toCsvString",
  1188. value: function toCsvString() {
  1189. return "".concat(this.model.result || '');
  1190. }
  1191. }, {
  1192. key: "release",
  1193. value: function release() { }
  1194. }, {
  1195. key: "toString",
  1196. value: function toString() {
  1197. return this.model.result ? this.model.result.toString() : '';
  1198. }
  1199. }, {
  1200. key: "value",
  1201. get: function get() {
  1202. return this._copyModel(this.model);
  1203. },
  1204. set: function set(value) {
  1205. this.model = this._copyModel(value);
  1206. }
  1207. }, {
  1208. key: "dependencies",
  1209. get: function get() {
  1210. // find all the ranges and cells mentioned in the formula
  1211. var ranges = this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g);
  1212. var cells = this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g, '').match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g);
  1213. return {
  1214. ranges: ranges,
  1215. cells: cells
  1216. };
  1217. }
  1218. }, {
  1219. key: "formula",
  1220. get: function get() {
  1221. return this.model.formula || this._getTranslatedFormula();
  1222. },
  1223. set: function set(value) {
  1224. this.model.formula = value;
  1225. }
  1226. }, {
  1227. key: "formulaType",
  1228. get: function get() {
  1229. if (this.model.formula) {
  1230. return Enums.FormulaType.Master;
  1231. }
  1232. if (this.model.sharedFormula) {
  1233. return Enums.FormulaType.Shared;
  1234. }
  1235. return Enums.FormulaType.None;
  1236. }
  1237. }, {
  1238. key: "result",
  1239. get: function get() {
  1240. return this.model.result;
  1241. },
  1242. set: function set(value) {
  1243. this.model.result = value;
  1244. }
  1245. }, {
  1246. key: "type",
  1247. get: function get() {
  1248. return Cell.Types.Formula;
  1249. }
  1250. }, {
  1251. key: "effectiveType",
  1252. get: function get() {
  1253. var v = this.model.result;
  1254. if (v === null || v === undefined) {
  1255. return Enums.ValueType.Null;
  1256. }
  1257. if (v instanceof String || typeof v === 'string') {
  1258. return Enums.ValueType.String;
  1259. }
  1260. if (typeof v === 'number') {
  1261. return Enums.ValueType.Number;
  1262. }
  1263. if (v instanceof Date) {
  1264. return Enums.ValueType.Date;
  1265. }
  1266. if (v.text && v.hyperlink) {
  1267. return Enums.ValueType.Hyperlink;
  1268. }
  1269. if (v.formula) {
  1270. return Enums.ValueType.Formula;
  1271. }
  1272. return Enums.ValueType.Null;
  1273. }
  1274. }, {
  1275. key: "address",
  1276. get: function get() {
  1277. return this.model.address;
  1278. },
  1279. set: function set(value) {
  1280. this.model.address = value;
  1281. }
  1282. }]);
  1283. return FormulaValue;
  1284. }();
  1285. var SharedStringValue = /*#__PURE__*/function () {
  1286. function SharedStringValue(cell, value) {
  1287. _classCallCheck(this, SharedStringValue);
  1288. this.model = {
  1289. address: cell.address,
  1290. type: Cell.Types.SharedString,
  1291. value: value
  1292. };
  1293. }
  1294. _createClass(SharedStringValue, [{
  1295. key: "toCsvString",
  1296. value: function toCsvString() {
  1297. return this.model.value.toString();
  1298. }
  1299. }, {
  1300. key: "release",
  1301. value: function release() { }
  1302. }, {
  1303. key: "toString",
  1304. value: function toString() {
  1305. return this.model.value.toString();
  1306. }
  1307. }, {
  1308. key: "value",
  1309. get: function get() {
  1310. return this.model.value;
  1311. },
  1312. set: function set(value) {
  1313. this.model.value = value;
  1314. }
  1315. }, {
  1316. key: "type",
  1317. get: function get() {
  1318. return Cell.Types.SharedString;
  1319. }
  1320. }, {
  1321. key: "effectiveType",
  1322. get: function get() {
  1323. return Cell.Types.SharedString;
  1324. }
  1325. }, {
  1326. key: "address",
  1327. get: function get() {
  1328. return this.model.address;
  1329. },
  1330. set: function set(value) {
  1331. this.model.address = value;
  1332. }
  1333. }]);
  1334. return SharedStringValue;
  1335. }();
  1336. var BooleanValue = /*#__PURE__*/function () {
  1337. function BooleanValue(cell, value) {
  1338. _classCallCheck(this, BooleanValue);
  1339. this.model = {
  1340. address: cell.address,
  1341. type: Cell.Types.Boolean,
  1342. value: value
  1343. };
  1344. }
  1345. _createClass(BooleanValue, [{
  1346. key: "toCsvString",
  1347. value: function toCsvString() {
  1348. return this.model.value ? 1 : 0;
  1349. }
  1350. }, {
  1351. key: "release",
  1352. value: function release() { }
  1353. }, {
  1354. key: "toString",
  1355. value: function toString() {
  1356. return this.model.value.toString();
  1357. }
  1358. }, {
  1359. key: "value",
  1360. get: function get() {
  1361. return this.model.value;
  1362. },
  1363. set: function set(value) {
  1364. this.model.value = value;
  1365. }
  1366. }, {
  1367. key: "type",
  1368. get: function get() {
  1369. return Cell.Types.Boolean;
  1370. }
  1371. }, {
  1372. key: "effectiveType",
  1373. get: function get() {
  1374. return Cell.Types.Boolean;
  1375. }
  1376. }, {
  1377. key: "address",
  1378. get: function get() {
  1379. return this.model.address;
  1380. },
  1381. set: function set(value) {
  1382. this.model.address = value;
  1383. }
  1384. }]);
  1385. return BooleanValue;
  1386. }();
  1387. var ErrorValue = /*#__PURE__*/function () {
  1388. function ErrorValue(cell, value) {
  1389. _classCallCheck(this, ErrorValue);
  1390. this.model = {
  1391. address: cell.address,
  1392. type: Cell.Types.Error,
  1393. value: value
  1394. };
  1395. }
  1396. _createClass(ErrorValue, [{
  1397. key: "toCsvString",
  1398. value: function toCsvString() {
  1399. return this.toString();
  1400. }
  1401. }, {
  1402. key: "release",
  1403. value: function release() { }
  1404. }, {
  1405. key: "toString",
  1406. value: function toString() {
  1407. return this.model.value.error.toString();
  1408. }
  1409. }, {
  1410. key: "value",
  1411. get: function get() {
  1412. return this.model.value;
  1413. },
  1414. set: function set(value) {
  1415. this.model.value = value;
  1416. }
  1417. }, {
  1418. key: "type",
  1419. get: function get() {
  1420. return Cell.Types.Error;
  1421. }
  1422. }, {
  1423. key: "effectiveType",
  1424. get: function get() {
  1425. return Cell.Types.Error;
  1426. }
  1427. }, {
  1428. key: "address",
  1429. get: function get() {
  1430. return this.model.address;
  1431. },
  1432. set: function set(value) {
  1433. this.model.address = value;
  1434. }
  1435. }]);
  1436. return ErrorValue;
  1437. }();
  1438. var JSONValue = /*#__PURE__*/function () {
  1439. function JSONValue(cell, value) {
  1440. _classCallCheck(this, JSONValue);
  1441. this.model = {
  1442. address: cell.address,
  1443. type: Cell.Types.String,
  1444. value: JSON.stringify(value),
  1445. rawValue: value
  1446. };
  1447. }
  1448. _createClass(JSONValue, [{
  1449. key: "toCsvString",
  1450. value: function toCsvString() {
  1451. return this.model.value;
  1452. }
  1453. }, {
  1454. key: "release",
  1455. value: function release() { }
  1456. }, {
  1457. key: "toString",
  1458. value: function toString() {
  1459. return this.model.value;
  1460. }
  1461. }, {
  1462. key: "value",
  1463. get: function get() {
  1464. return this.model.rawValue;
  1465. },
  1466. set: function set(value) {
  1467. this.model.rawValue = value;
  1468. this.model.value = JSON.stringify(value);
  1469. }
  1470. }, {
  1471. key: "type",
  1472. get: function get() {
  1473. return Cell.Types.String;
  1474. }
  1475. }, {
  1476. key: "effectiveType",
  1477. get: function get() {
  1478. return Cell.Types.String;
  1479. }
  1480. }, {
  1481. key: "address",
  1482. get: function get() {
  1483. return this.model.address;
  1484. },
  1485. set: function set(value) {
  1486. this.model.address = value;
  1487. }
  1488. }]);
  1489. return JSONValue;
  1490. }(); // Value is a place to hold common static Value type functions
  1491. var Value = {
  1492. getType: function getType(value) {
  1493. if (value === null || value === undefined) {
  1494. return Cell.Types.Null;
  1495. }
  1496. if (value instanceof String || typeof value === 'string') {
  1497. return Cell.Types.String;
  1498. }
  1499. if (typeof value === 'number') {
  1500. return Cell.Types.Number;
  1501. }
  1502. if (typeof value === 'boolean') {
  1503. return Cell.Types.Boolean;
  1504. }
  1505. if (value instanceof Date) {
  1506. return Cell.Types.Date;
  1507. }
  1508. if (value.text && value.hyperlink) {
  1509. return Cell.Types.Hyperlink;
  1510. }
  1511. if (value.formula || value.sharedFormula) {
  1512. return Cell.Types.Formula;
  1513. }
  1514. if (value.richText) {
  1515. return Cell.Types.RichText;
  1516. }
  1517. if (value.sharedString) {
  1518. return Cell.Types.SharedString;
  1519. }
  1520. if (value.error) {
  1521. return Cell.Types.Error;
  1522. }
  1523. return Cell.Types.JSON;
  1524. },
  1525. // map valueType to constructor
  1526. types: [{
  1527. t: Cell.Types.Null,
  1528. f: NullValue
  1529. }, {
  1530. t: Cell.Types.Number,
  1531. f: NumberValue
  1532. }, {
  1533. t: Cell.Types.String,
  1534. f: StringValue
  1535. }, {
  1536. t: Cell.Types.Date,
  1537. f: DateValue
  1538. }, {
  1539. t: Cell.Types.Hyperlink,
  1540. f: HyperlinkValue
  1541. }, {
  1542. t: Cell.Types.Formula,
  1543. f: FormulaValue
  1544. }, {
  1545. t: Cell.Types.Merge,
  1546. f: MergeValue
  1547. }, {
  1548. t: Cell.Types.JSON,
  1549. f: JSONValue
  1550. }, {
  1551. t: Cell.Types.SharedString,
  1552. f: SharedStringValue
  1553. }, {
  1554. t: Cell.Types.RichText,
  1555. f: RichTextValue
  1556. }, {
  1557. t: Cell.Types.Boolean,
  1558. f: BooleanValue
  1559. }, {
  1560. t: Cell.Types.Error,
  1561. f: ErrorValue
  1562. }].reduce(function (p, t) {
  1563. p[t.t] = t.f;
  1564. return p;
  1565. }, []),
  1566. create: function create(type, cell, value) {
  1567. var T = this.types[type];
  1568. if (!T) {
  1569. throw new Error("Could not create Value of type ".concat(type));
  1570. }
  1571. return new T(cell, value);
  1572. }
  1573. };
  1574. module.exports = Cell;
  1575. }, { "../utils/col-cache": 19, "../utils/shared-formula": 22, "../utils/under-dash": 25, "./enums": 7, "./note": 9 }], 4: [function (require, module, exports) {
  1576. 'use strict';
  1577. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1578. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  1579. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1580. var _ = require('../utils/under-dash');
  1581. var Enums = require('./enums');
  1582. var colCache = require('../utils/col-cache');
  1583. var DEFAULT_COLUMN_WIDTH = 9; // Column defines the column properties for 1 column.
  1584. // This includes header rows, widths, key, (style), etc.
  1585. // Worksheet will condense the columns as appropriate during serialization
  1586. var Column = /*#__PURE__*/function () {
  1587. function Column(worksheet, number, defn) {
  1588. _classCallCheck(this, Column);
  1589. this._worksheet = worksheet;
  1590. this._number = number;
  1591. if (defn !== false) {
  1592. // sometimes defn will follow
  1593. this.defn = defn;
  1594. }
  1595. }
  1596. _createClass(Column, [{
  1597. key: "toString",
  1598. value: function toString() {
  1599. return JSON.stringify({
  1600. key: this.key,
  1601. width: this.width,
  1602. headers: this.headers.length ? this.headers : undefined
  1603. });
  1604. }
  1605. }, {
  1606. key: "equivalentTo",
  1607. value: function equivalentTo(other) {
  1608. return this.width === other.width && this.hidden === other.hidden && this.outlineLevel === other.outlineLevel && _.isEqual(this.style, other.style);
  1609. }
  1610. }, {
  1611. key: "eachCell",
  1612. value: function eachCell(options, iteratee) {
  1613. var colNumber = this.number;
  1614. if (!iteratee) {
  1615. iteratee = options;
  1616. options = null;
  1617. }
  1618. this._worksheet.eachRow(options, function (row, rowNumber) {
  1619. iteratee(row.getCell(colNumber), rowNumber);
  1620. });
  1621. }
  1622. }, {
  1623. key: "_applyStyle",
  1624. // =========================================================================
  1625. // styles
  1626. value: function _applyStyle(name, value) {
  1627. this.style[name] = value;
  1628. this.eachCell(function (cell) {
  1629. cell[name] = value;
  1630. });
  1631. return value;
  1632. }
  1633. }, {
  1634. key: "number",
  1635. get: function get() {
  1636. return this._number;
  1637. }
  1638. }, {
  1639. key: "worksheet",
  1640. get: function get() {
  1641. return this._worksheet;
  1642. }
  1643. }, {
  1644. key: "letter",
  1645. get: function get() {
  1646. return colCache.n2l(this._number);
  1647. }
  1648. }, {
  1649. key: "isCustomWidth",
  1650. get: function get() {
  1651. return this.width !== undefined && this.width !== DEFAULT_COLUMN_WIDTH;
  1652. }
  1653. }, {
  1654. key: "defn",
  1655. get: function get() {
  1656. return {
  1657. header: this._header,
  1658. key: this.key,
  1659. width: this.width,
  1660. style: this.style,
  1661. hidden: this.hidden,
  1662. outlineLevel: this.outlineLevel
  1663. };
  1664. },
  1665. set: function set(value) {
  1666. if (value) {
  1667. this.key = value.key;
  1668. this.width = value.width !== undefined ? value.width : DEFAULT_COLUMN_WIDTH;
  1669. this.outlineLevel = value.outlineLevel;
  1670. if (value.style) {
  1671. this.style = value.style;
  1672. } else {
  1673. this.style = {};
  1674. } // headers must be set after style
  1675. this.header = value.header;
  1676. this._hidden = !!value.hidden;
  1677. } else {
  1678. delete this._header;
  1679. delete this._key;
  1680. delete this.width;
  1681. this.style = {};
  1682. this.outlineLevel = 0;
  1683. }
  1684. }
  1685. }, {
  1686. key: "headers",
  1687. get: function get() {
  1688. return this._header && this._header instanceof Array ? this._header : [this._header];
  1689. }
  1690. }, {
  1691. key: "header",
  1692. get: function get() {
  1693. return this._header;
  1694. },
  1695. set: function set(value) {
  1696. var _this = this;
  1697. if (value !== undefined) {
  1698. this._header = value;
  1699. this.headers.forEach(function (text, index) {
  1700. _this._worksheet.getCell(index + 1, _this.number).value = text;
  1701. });
  1702. } else {
  1703. this._header = undefined;
  1704. }
  1705. }
  1706. }, {
  1707. key: "key",
  1708. get: function get() {
  1709. return this._key;
  1710. },
  1711. set: function set(value) {
  1712. var column = this._key && this._worksheet.getColumnKey(this._key);
  1713. if (column === this) {
  1714. this._worksheet.deleteColumnKey(this._key);
  1715. }
  1716. this._key = value;
  1717. if (value) {
  1718. this._worksheet.setColumnKey(this._key, this);
  1719. }
  1720. }
  1721. }, {
  1722. key: "hidden",
  1723. get: function get() {
  1724. return !!this._hidden;
  1725. },
  1726. set: function set(value) {
  1727. this._hidden = value;
  1728. }
  1729. }, {
  1730. key: "outlineLevel",
  1731. get: function get() {
  1732. return this._outlineLevel || 0;
  1733. },
  1734. set: function set(value) {
  1735. this._outlineLevel = value;
  1736. }
  1737. }, {
  1738. key: "collapsed",
  1739. get: function get() {
  1740. return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelCol);
  1741. }
  1742. }, {
  1743. key: "isDefault",
  1744. get: function get() {
  1745. if (this.isCustomWidth) {
  1746. return false;
  1747. }
  1748. if (this.hidden) {
  1749. return false;
  1750. }
  1751. if (this.outlineLevel) {
  1752. return false;
  1753. }
  1754. var s = this.style;
  1755. if (s && (s.font || s.numFmt || s.alignment || s.border || s.fill || s.protection)) {
  1756. return false;
  1757. }
  1758. return true;
  1759. }
  1760. }, {
  1761. key: "headerCount",
  1762. get: function get() {
  1763. return this.headers.length;
  1764. }
  1765. }, {
  1766. key: "values",
  1767. get: function get() {
  1768. var v = [];
  1769. this.eachCell(function (cell, rowNumber) {
  1770. if (cell && cell.type !== Enums.ValueType.Null) {
  1771. v[rowNumber] = cell.value;
  1772. }
  1773. });
  1774. return v;
  1775. },
  1776. set: function set(v) {
  1777. var _this2 = this;
  1778. if (!v) {
  1779. return;
  1780. }
  1781. var colNumber = this.number;
  1782. var offset = 0;
  1783. if (v.hasOwnProperty('0')) {
  1784. // assume contiguous array, start at row 1
  1785. offset = 1;
  1786. }
  1787. v.forEach(function (value, index) {
  1788. _this2._worksheet.getCell(index + offset, colNumber).value = value;
  1789. });
  1790. }
  1791. }, {
  1792. key: "numFmt",
  1793. get: function get() {
  1794. return this.style.numFmt;
  1795. },
  1796. set: function set(value) {
  1797. this._applyStyle('numFmt', value);
  1798. }
  1799. }, {
  1800. key: "font",
  1801. get: function get() {
  1802. return this.style.font;
  1803. },
  1804. set: function set(value) {
  1805. this._applyStyle('font', value);
  1806. }
  1807. }, {
  1808. key: "alignment",
  1809. get: function get() {
  1810. return this.style.alignment;
  1811. },
  1812. set: function set(value) {
  1813. this._applyStyle('alignment', value);
  1814. }
  1815. }, {
  1816. key: "protection",
  1817. get: function get() {
  1818. return this.style.protection;
  1819. },
  1820. set: function set(value) {
  1821. this._applyStyle('protection', value);
  1822. }
  1823. }, {
  1824. key: "border",
  1825. get: function get() {
  1826. return this.style.border;
  1827. },
  1828. set: function set(value) {
  1829. this._applyStyle('border', value);
  1830. }
  1831. }, {
  1832. key: "fill",
  1833. get: function get() {
  1834. return this.style.fill;
  1835. },
  1836. set: function set(value) {
  1837. this._applyStyle('fill', value);
  1838. } // =============================================================================
  1839. // static functions
  1840. }], [{
  1841. key: "toModel",
  1842. value: function toModel(columns) {
  1843. // Convert array of Column into compressed list cols
  1844. var cols = [];
  1845. var col = null;
  1846. if (columns) {
  1847. columns.forEach(function (column, index) {
  1848. if (column.isDefault) {
  1849. if (col) {
  1850. col = null;
  1851. }
  1852. } else if (!col || !column.equivalentTo(col)) {
  1853. col = {
  1854. min: index + 1,
  1855. max: index + 1,
  1856. width: column.width !== undefined ? column.width : DEFAULT_COLUMN_WIDTH,
  1857. style: column.style,
  1858. isCustomWidth: column.isCustomWidth,
  1859. hidden: column.hidden,
  1860. outlineLevel: column.outlineLevel,
  1861. collapsed: column.collapsed
  1862. };
  1863. cols.push(col);
  1864. } else {
  1865. col.max = index + 1;
  1866. }
  1867. });
  1868. }
  1869. return cols.length ? cols : undefined;
  1870. }
  1871. }, {
  1872. key: "fromModel",
  1873. value: function fromModel(worksheet, cols) {
  1874. cols = cols || [];
  1875. var columns = [];
  1876. var count = 1;
  1877. var index = 0;
  1878. while (index < cols.length) {
  1879. var col = cols[index++];
  1880. while (count < col.min) {
  1881. columns.push(new Column(worksheet, count++));
  1882. }
  1883. while (count <= col.max) {
  1884. columns.push(new Column(worksheet, count++, col));
  1885. }
  1886. }
  1887. return columns.length ? columns : null;
  1888. }
  1889. }]);
  1890. return Column;
  1891. }();
  1892. module.exports = Column;
  1893. }, { "../utils/col-cache": 19, "../utils/under-dash": 25, "./enums": 7 }], 5: [function (require, module, exports) {
  1894. "use strict";
  1895. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1896. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  1897. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1898. var DataValidations = /*#__PURE__*/function () {
  1899. function DataValidations(model) {
  1900. _classCallCheck(this, DataValidations);
  1901. this.model = model || {};
  1902. }
  1903. _createClass(DataValidations, [{
  1904. key: "add",
  1905. value: function add(address, validation) {
  1906. return this.model[address] = validation;
  1907. }
  1908. }, {
  1909. key: "find",
  1910. value: function find(address) {
  1911. return this.model[address];
  1912. }
  1913. }, {
  1914. key: "remove",
  1915. value: function remove(address) {
  1916. this.model[address] = undefined;
  1917. }
  1918. }]);
  1919. return DataValidations;
  1920. }();
  1921. module.exports = DataValidations;
  1922. }, {}], 6: [function (require, module, exports) {
  1923. 'use strict';
  1924. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1925. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  1926. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1927. var _ = require('../utils/under-dash');
  1928. var colCache = require('../utils/col-cache');
  1929. var CellMatrix = require('../utils/cell-matrix');
  1930. var Range = require('./range');
  1931. var rangeRegexp = /[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;
  1932. var DefinedNames = /*#__PURE__*/function () {
  1933. function DefinedNames() {
  1934. _classCallCheck(this, DefinedNames);
  1935. this.matrixMap = {};
  1936. }
  1937. _createClass(DefinedNames, [{
  1938. key: "getMatrix",
  1939. value: function getMatrix(name) {
  1940. var matrix = this.matrixMap[name] || (this.matrixMap[name] = new CellMatrix());
  1941. return matrix;
  1942. } // add a name to a cell. locStr in the form SheetName!$col$row or SheetName!$c1$r1:$c2:$r2
  1943. }, {
  1944. key: "add",
  1945. value: function add(locStr, name) {
  1946. var location = colCache.decodeEx(locStr);
  1947. this.addEx(location, name);
  1948. }
  1949. }, {
  1950. key: "addEx",
  1951. value: function addEx(location, name) {
  1952. var matrix = this.getMatrix(name);
  1953. if (location.top) {
  1954. for (var col = location.left; col <= location.right; col++) {
  1955. for (var row = location.top; row <= location.bottom; row++) {
  1956. var address = {
  1957. sheetName: location.sheetName,
  1958. address: colCache.n2l(col) + row,
  1959. row: row,
  1960. col: col
  1961. };
  1962. matrix.addCellEx(address);
  1963. }
  1964. }
  1965. } else {
  1966. matrix.addCellEx(location);
  1967. }
  1968. }
  1969. }, {
  1970. key: "remove",
  1971. value: function remove(locStr, name) {
  1972. var location = colCache.decodeEx(locStr);
  1973. this.removeEx(location, name);
  1974. }
  1975. }, {
  1976. key: "removeEx",
  1977. value: function removeEx(location, name) {
  1978. var matrix = this.getMatrix(name);
  1979. matrix.removeCellEx(location);
  1980. }
  1981. }, {
  1982. key: "removeAllNames",
  1983. value: function removeAllNames(location) {
  1984. _.each(this.matrixMap, function (matrix) {
  1985. matrix.removeCellEx(location);
  1986. });
  1987. }
  1988. }, {
  1989. key: "forEach",
  1990. value: function forEach(callback) {
  1991. _.each(this.matrixMap, function (matrix, name) {
  1992. matrix.forEach(function (cell) {
  1993. callback(name, cell);
  1994. });
  1995. });
  1996. } // get all the names of a cell
  1997. }, {
  1998. key: "getNames",
  1999. value: function getNames(addressStr) {
  2000. return this.getNamesEx(colCache.decodeEx(addressStr));
  2001. }
  2002. }, {
  2003. key: "getNamesEx",
  2004. value: function getNamesEx(address) {
  2005. return _.map(this.matrixMap, function (matrix, name) {
  2006. return matrix.findCellEx(address) && name;
  2007. }).filter(Boolean);
  2008. }
  2009. }, {
  2010. key: "_explore",
  2011. value: function _explore(matrix, cell) {
  2012. cell.mark = false;
  2013. var sheetName = cell.sheetName;
  2014. var range = new Range(cell.row, cell.col, cell.row, cell.col, sheetName);
  2015. var x;
  2016. var y; // grow vertical - only one col to worry about
  2017. function vGrow(yy, edge) {
  2018. var c = matrix.findCellAt(sheetName, yy, cell.col);
  2019. if (!c || !c.mark) {
  2020. return false;
  2021. }
  2022. range[edge] = yy;
  2023. c.mark = false;
  2024. return true;
  2025. }
  2026. for (y = cell.row - 1; vGrow(y, 'top'); y--) {
  2027. ;
  2028. }
  2029. for (y = cell.row + 1; vGrow(y, 'bottom'); y++) {
  2030. ;
  2031. } // grow horizontal - ensure all rows can grow
  2032. function hGrow(xx, edge) {
  2033. var cells = [];
  2034. for (y = range.top; y <= range.bottom; y++) {
  2035. var c = matrix.findCellAt(sheetName, y, xx);
  2036. if (c && c.mark) {
  2037. cells.push(c);
  2038. } else {
  2039. return false;
  2040. }
  2041. }
  2042. range[edge] = xx;
  2043. for (var i = 0; i < cells.length; i++) {
  2044. cells[i].mark = false;
  2045. }
  2046. return true;
  2047. }
  2048. for (x = cell.col - 1; hGrow(x, 'left'); x--) {
  2049. ;
  2050. }
  2051. for (x = cell.col + 1; hGrow(x, 'right'); x++) {
  2052. ;
  2053. }
  2054. return range;
  2055. }
  2056. }, {
  2057. key: "getRanges",
  2058. value: function getRanges(name, matrix) {
  2059. var _this = this;
  2060. matrix = matrix || this.matrixMap[name];
  2061. if (!matrix) {
  2062. return {
  2063. name: name,
  2064. ranges: []
  2065. };
  2066. } // mark and sweep!
  2067. matrix.forEach(function (cell) {
  2068. cell.mark = true;
  2069. });
  2070. var ranges = matrix.map(function (cell) {
  2071. return cell.mark && _this._explore(matrix, cell);
  2072. }).filter(Boolean).map(function (range) {
  2073. return range.$shortRange;
  2074. });
  2075. return {
  2076. name: name,
  2077. ranges: ranges
  2078. };
  2079. }
  2080. }, {
  2081. key: "normaliseMatrix",
  2082. value: function normaliseMatrix(matrix, sheetName) {
  2083. // some of the cells might have shifted on specified sheet
  2084. // need to reassign rows, cols
  2085. matrix.forEachInSheet(sheetName, function (cell, row, col) {
  2086. if (cell) {
  2087. if (cell.row !== row || cell.col !== col) {
  2088. cell.row = row;
  2089. cell.col = col;
  2090. cell.address = colCache.n2l(col) + row;
  2091. }
  2092. }
  2093. });
  2094. }
  2095. }, {
  2096. key: "spliceRows",
  2097. value: function spliceRows(sheetName, start, numDelete, numInsert) {
  2098. var _this2 = this;
  2099. _.each(this.matrixMap, function (matrix) {
  2100. matrix.spliceRows(sheetName, start, numDelete, numInsert);
  2101. _this2.normaliseMatrix(matrix, sheetName);
  2102. });
  2103. }
  2104. }, {
  2105. key: "spliceColumns",
  2106. value: function spliceColumns(sheetName, start, numDelete, numInsert) {
  2107. var _this3 = this;
  2108. _.each(this.matrixMap, function (matrix) {
  2109. matrix.spliceColumns(sheetName, start, numDelete, numInsert);
  2110. _this3.normaliseMatrix(matrix, sheetName);
  2111. });
  2112. }
  2113. }, {
  2114. key: "model",
  2115. get: function get() {
  2116. var _this4 = this;
  2117. // To get names per cell - just iterate over all names finding cells if they exist
  2118. return _.map(this.matrixMap, function (matrix, name) {
  2119. return _this4.getRanges(name, matrix);
  2120. }).filter(function (definedName) {
  2121. return definedName.ranges.length;
  2122. });
  2123. },
  2124. set: function set(value) {
  2125. // value is [ { name, ranges }, ... ]
  2126. var matrixMap = this.matrixMap = {};
  2127. value.forEach(function (definedName) {
  2128. var matrix = matrixMap[definedName.name] = new CellMatrix();
  2129. definedName.ranges.forEach(function (rangeStr) {
  2130. if (rangeRegexp.test(rangeStr.split('!').pop() || '')) {
  2131. matrix.addCell(rangeStr);
  2132. }
  2133. });
  2134. });
  2135. }
  2136. }]);
  2137. return DefinedNames;
  2138. }();
  2139. module.exports = DefinedNames;
  2140. }, { "../utils/cell-matrix": 18, "../utils/col-cache": 19, "../utils/under-dash": 25, "./range": 10 }], 7: [function (require, module, exports) {
  2141. 'use strict';
  2142. module.exports = {
  2143. ValueType: {
  2144. Null: 0,
  2145. Merge: 1,
  2146. Number: 2,
  2147. String: 3,
  2148. Date: 4,
  2149. Hyperlink: 5,
  2150. Formula: 6,
  2151. SharedString: 7,
  2152. RichText: 8,
  2153. Boolean: 9,
  2154. Error: 10
  2155. },
  2156. FormulaType: {
  2157. None: 0,
  2158. Master: 1,
  2159. Shared: 2
  2160. },
  2161. RelationshipType: {
  2162. None: 0,
  2163. OfficeDocument: 1,
  2164. Worksheet: 2,
  2165. CalcChain: 3,
  2166. SharedStrings: 4,
  2167. Styles: 5,
  2168. Theme: 6,
  2169. Hyperlink: 7
  2170. },
  2171. DocumentType: {
  2172. Xlsx: 1
  2173. },
  2174. ReadingOrder: {
  2175. LeftToRight: 1,
  2176. RightToLeft: 2
  2177. },
  2178. ErrorValue: {
  2179. NotApplicable: '#N/A',
  2180. Ref: '#REF!',
  2181. Name: '#NAME?',
  2182. DivZero: '#DIV/0!',
  2183. Null: '#NULL!',
  2184. Value: '#VALUE!',
  2185. Num: '#NUM!'
  2186. }
  2187. };
  2188. }, {}], 8: [function (require, module, exports) {
  2189. "use strict";
  2190. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2191. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2192. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2193. var colCache = require('../utils/col-cache');
  2194. var Anchor = require('./anchor');
  2195. var Image = /*#__PURE__*/function () {
  2196. function Image(worksheet, model) {
  2197. _classCallCheck(this, Image);
  2198. this.worksheet = worksheet;
  2199. this.model = model;
  2200. }
  2201. _createClass(Image, [{
  2202. key: "model",
  2203. get: function get() {
  2204. switch (this.type) {
  2205. case 'background':
  2206. return {
  2207. type: this.type,
  2208. imageId: this.imageId
  2209. };
  2210. case 'image':
  2211. return {
  2212. type: this.type,
  2213. imageId: this.imageId,
  2214. hyperlinks: this.range.hyperlinks,
  2215. range: {
  2216. tl: this.range.tl.model,
  2217. br: this.range.br && this.range.br.model,
  2218. ext: this.range.ext,
  2219. editAs: this.range.editAs
  2220. }
  2221. };
  2222. default:
  2223. throw new Error('Invalid Image Type');
  2224. }
  2225. },
  2226. set: function set(_ref) {
  2227. var type = _ref.type,
  2228. imageId = _ref.imageId,
  2229. range = _ref.range,
  2230. hyperlinks = _ref.hyperlinks;
  2231. this.type = type;
  2232. this.imageId = imageId;
  2233. if (type === 'image') {
  2234. if (typeof range === 'string') {
  2235. var decoded = colCache.decode(range);
  2236. this.range = {
  2237. tl: new Anchor(this.worksheet, {
  2238. col: decoded.left,
  2239. row: decoded.top
  2240. }, -1),
  2241. br: new Anchor(this.worksheet, {
  2242. col: decoded.right,
  2243. row: decoded.bottom
  2244. }, 0),
  2245. editAs: 'oneCell'
  2246. };
  2247. } else {
  2248. this.range = {
  2249. tl: new Anchor(this.worksheet, range.tl, 0),
  2250. br: range.br && new Anchor(this.worksheet, range.br, 0),
  2251. ext: range.ext,
  2252. editAs: range.editAs,
  2253. hyperlinks: hyperlinks || range.hyperlinks
  2254. };
  2255. }
  2256. }
  2257. }
  2258. }]);
  2259. return Image;
  2260. }();
  2261. module.exports = Image;
  2262. }, { "../utils/col-cache": 19, "./anchor": 2 }], 9: [function (require, module, exports) {
  2263. "use strict";
  2264. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2265. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2266. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2267. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2268. var _ = require('../utils/under-dash');
  2269. var Note = /*#__PURE__*/function () {
  2270. function Note(note) {
  2271. _classCallCheck(this, Note);
  2272. this.note = note;
  2273. }
  2274. _createClass(Note, [{
  2275. key: "model",
  2276. get: function get() {
  2277. var value = null;
  2278. switch (_typeof(this.note)) {
  2279. case 'string':
  2280. value = {
  2281. type: 'note',
  2282. note: {
  2283. texts: [{
  2284. text: this.note
  2285. }]
  2286. }
  2287. };
  2288. break;
  2289. default:
  2290. value = {
  2291. type: 'note',
  2292. note: this.note
  2293. };
  2294. break;
  2295. } // Suitable for all cell comments
  2296. return _.deepMerge({}, Note.DEFAULT_CONFIGS, value);
  2297. },
  2298. set: function set(value) {
  2299. var note = value.note;
  2300. var texts = note.texts;
  2301. if (texts.length === 1 && Object.keys(texts[0]).length === 1) {
  2302. this.note = texts[0].text;
  2303. } else {
  2304. this.note = note;
  2305. }
  2306. }
  2307. }], [{
  2308. key: "fromModel",
  2309. value: function fromModel(model) {
  2310. var note = new Note();
  2311. note.model = model;
  2312. return note;
  2313. }
  2314. }]);
  2315. return Note;
  2316. }();
  2317. Note.DEFAULT_CONFIGS = {
  2318. note: {
  2319. margins: {
  2320. insetmode: 'auto',
  2321. inset: [0.13, 0.13, 0.25, 0.25]
  2322. },
  2323. protection: {
  2324. locked: 'True',
  2325. lockText: 'True'
  2326. },
  2327. editAs: 'absolute'
  2328. }
  2329. };
  2330. module.exports = Note;
  2331. }, { "../utils/under-dash": 25 }], 10: [function (require, module, exports) {
  2332. "use strict";
  2333. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2334. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2335. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2336. var colCache = require('../utils/col-cache'); // used by worksheet to calculate sheet dimensions
  2337. var Range = /*#__PURE__*/function () {
  2338. function Range() {
  2339. _classCallCheck(this, Range);
  2340. this.decode(arguments);
  2341. }
  2342. _createClass(Range, [{
  2343. key: "setTLBR",
  2344. value: function setTLBR(t, l, b, r, s) {
  2345. if (arguments.length < 4) {
  2346. // setTLBR(tl, br, s)
  2347. var tl = colCache.decodeAddress(t);
  2348. var br = colCache.decodeAddress(l);
  2349. this.model = {
  2350. top: Math.min(tl.row, br.row),
  2351. left: Math.min(tl.col, br.col),
  2352. bottom: Math.max(tl.row, br.row),
  2353. right: Math.max(tl.col, br.col),
  2354. sheetName: b
  2355. };
  2356. this.setTLBR(tl.row, tl.col, br.row, br.col, s);
  2357. } else {
  2358. // setTLBR(t, l, b, r, s)
  2359. this.model = {
  2360. top: Math.min(t, b),
  2361. left: Math.min(l, r),
  2362. bottom: Math.max(t, b),
  2363. right: Math.max(l, r),
  2364. sheetName: s
  2365. };
  2366. }
  2367. }
  2368. }, {
  2369. key: "decode",
  2370. value: function decode(argv) {
  2371. switch (argv.length) {
  2372. case 5:
  2373. // [t,l,b,r,s]
  2374. this.setTLBR(argv[0], argv[1], argv[2], argv[3], argv[4]);
  2375. break;
  2376. case 4:
  2377. // [t,l,b,r]
  2378. this.setTLBR(argv[0], argv[1], argv[2], argv[3]);
  2379. break;
  2380. case 3:
  2381. // [tl,br,s]
  2382. this.setTLBR(argv[0], argv[1], argv[2]);
  2383. break;
  2384. case 2:
  2385. // [tl,br]
  2386. this.setTLBR(argv[0], argv[1]);
  2387. break;
  2388. case 1:
  2389. {
  2390. var value = argv[0];
  2391. if (value instanceof Range) {
  2392. // copy constructor
  2393. this.model = {
  2394. top: value.model.top,
  2395. left: value.model.left,
  2396. bottom: value.model.bottom,
  2397. right: value.model.right,
  2398. sheetName: value.sheetName
  2399. };
  2400. } else if (value instanceof Array) {
  2401. // an arguments array
  2402. this.decode(value);
  2403. } else if (value.top && value.left && value.bottom && value.right) {
  2404. // a model
  2405. this.model = {
  2406. top: value.top,
  2407. left: value.left,
  2408. bottom: value.bottom,
  2409. right: value.right,
  2410. sheetName: value.sheetName
  2411. };
  2412. } else {
  2413. // [sheetName!]tl:br
  2414. var tlbr = colCache.decodeEx(value);
  2415. if (tlbr.top) {
  2416. this.model = {
  2417. top: tlbr.top,
  2418. left: tlbr.left,
  2419. bottom: tlbr.bottom,
  2420. right: tlbr.right,
  2421. sheetName: tlbr.sheetName
  2422. };
  2423. } else {
  2424. this.model = {
  2425. top: tlbr.row,
  2426. left: tlbr.col,
  2427. bottom: tlbr.row,
  2428. right: tlbr.col,
  2429. sheetName: tlbr.sheetName
  2430. };
  2431. }
  2432. }
  2433. break;
  2434. }
  2435. case 0:
  2436. this.model = {
  2437. top: 0,
  2438. left: 0,
  2439. bottom: 0,
  2440. right: 0
  2441. };
  2442. break;
  2443. default:
  2444. throw new Error("Invalid number of arguments to _getDimensions() - ".concat(argv.length));
  2445. }
  2446. }
  2447. }, {
  2448. key: "expand",
  2449. value: function expand(top, left, bottom, right) {
  2450. if (!this.model.top || top < this.top) this.top = top;
  2451. if (!this.model.left || left < this.left) this.left = left;
  2452. if (!this.model.bottom || bottom > this.bottom) this.bottom = bottom;
  2453. if (!this.model.right || right > this.right) this.right = right;
  2454. }
  2455. }, {
  2456. key: "expandRow",
  2457. value: function expandRow(row) {
  2458. if (row) {
  2459. var dimensions = row.dimensions,
  2460. number = row.number;
  2461. if (dimensions) {
  2462. this.expand(number, dimensions.min, number, dimensions.max);
  2463. }
  2464. }
  2465. }
  2466. }, {
  2467. key: "expandToAddress",
  2468. value: function expandToAddress(addressStr) {
  2469. var address = colCache.decodeEx(addressStr);
  2470. this.expand(address.row, address.col, address.row, address.col);
  2471. }
  2472. }, {
  2473. key: "toString",
  2474. value: function toString() {
  2475. return this.range;
  2476. }
  2477. }, {
  2478. key: "intersects",
  2479. value: function intersects(other) {
  2480. if (other.sheetName && this.sheetName && other.sheetName !== this.sheetName) return false;
  2481. if (other.bottom < this.top) return false;
  2482. if (other.top > this.bottom) return false;
  2483. if (other.right < this.left) return false;
  2484. if (other.left > this.right) return false;
  2485. return true;
  2486. }
  2487. }, {
  2488. key: "contains",
  2489. value: function contains(addressStr) {
  2490. var address = colCache.decodeEx(addressStr);
  2491. return this.containsEx(address);
  2492. }
  2493. }, {
  2494. key: "containsEx",
  2495. value: function containsEx(address) {
  2496. if (address.sheetName && this.sheetName && address.sheetName !== this.sheetName) return false;
  2497. return address.row >= this.top && address.row <= this.bottom && address.col >= this.left && address.col <= this.right;
  2498. }
  2499. }, {
  2500. key: "forEachAddress",
  2501. value: function forEachAddress(cb) {
  2502. for (var col = this.left; col <= this.right; col++) {
  2503. for (var row = this.top; row <= this.bottom; row++) {
  2504. cb(colCache.encodeAddress(row, col), row, col);
  2505. }
  2506. }
  2507. }
  2508. }, {
  2509. key: "top",
  2510. get: function get() {
  2511. return this.model.top || 1;
  2512. },
  2513. set: function set(value) {
  2514. this.model.top = value;
  2515. }
  2516. }, {
  2517. key: "left",
  2518. get: function get() {
  2519. return this.model.left || 1;
  2520. },
  2521. set: function set(value) {
  2522. this.model.left = value;
  2523. }
  2524. }, {
  2525. key: "bottom",
  2526. get: function get() {
  2527. return this.model.bottom || 1;
  2528. },
  2529. set: function set(value) {
  2530. this.model.bottom = value;
  2531. }
  2532. }, {
  2533. key: "right",
  2534. get: function get() {
  2535. return this.model.right || 1;
  2536. },
  2537. set: function set(value) {
  2538. this.model.right = value;
  2539. }
  2540. }, {
  2541. key: "sheetName",
  2542. get: function get() {
  2543. return this.model.sheetName;
  2544. },
  2545. set: function set(value) {
  2546. this.model.sheetName = value;
  2547. }
  2548. }, {
  2549. key: "_serialisedSheetName",
  2550. get: function get() {
  2551. var sheetName = this.model.sheetName;
  2552. if (sheetName) {
  2553. if (/^[a-zA-Z0-9]*$/.test(sheetName)) {
  2554. return "".concat(sheetName, "!");
  2555. }
  2556. return "'".concat(sheetName, "'!");
  2557. }
  2558. return '';
  2559. }
  2560. }, {
  2561. key: "tl",
  2562. get: function get() {
  2563. return colCache.n2l(this.left) + this.top;
  2564. }
  2565. }, {
  2566. key: "$t$l",
  2567. get: function get() {
  2568. return "$".concat(colCache.n2l(this.left), "$").concat(this.top);
  2569. }
  2570. }, {
  2571. key: "br",
  2572. get: function get() {
  2573. return colCache.n2l(this.right) + this.bottom;
  2574. }
  2575. }, {
  2576. key: "$b$r",
  2577. get: function get() {
  2578. return "$".concat(colCache.n2l(this.right), "$").concat(this.bottom);
  2579. }
  2580. }, {
  2581. key: "range",
  2582. get: function get() {
  2583. return "".concat(this._serialisedSheetName + this.tl, ":").concat(this.br);
  2584. }
  2585. }, {
  2586. key: "$range",
  2587. get: function get() {
  2588. return "".concat(this._serialisedSheetName + this.$t$l, ":").concat(this.$b$r);
  2589. }
  2590. }, {
  2591. key: "shortRange",
  2592. get: function get() {
  2593. return this.count > 1 ? this.range : this._serialisedSheetName + this.tl;
  2594. }
  2595. }, {
  2596. key: "$shortRange",
  2597. get: function get() {
  2598. return this.count > 1 ? this.$range : this._serialisedSheetName + this.$t$l;
  2599. }
  2600. }, {
  2601. key: "count",
  2602. get: function get() {
  2603. return (1 + this.bottom - this.top) * (1 + this.right - this.left);
  2604. }
  2605. }]);
  2606. return Range;
  2607. }();
  2608. module.exports = Range;
  2609. }, { "../utils/col-cache": 19 }], 11: [function (require, module, exports) {
  2610. 'use strict';
  2611. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2612. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2613. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2614. var _ = require('../utils/under-dash');
  2615. var Enums = require('./enums');
  2616. var colCache = require('../utils/col-cache');
  2617. var Cell = require('./cell');
  2618. var Row = /*#__PURE__*/function () {
  2619. function Row(worksheet, number) {
  2620. _classCallCheck(this, Row);
  2621. this._worksheet = worksheet;
  2622. this._number = number;
  2623. this._cells = [];
  2624. this.style = {};
  2625. this.outlineLevel = 0;
  2626. } // return the row number
  2627. _createClass(Row, [{
  2628. key: "commit",
  2629. // Inform Streaming Writer that this row (and all rows before it) are complete
  2630. // and ready to write. Has no effect on Worksheet document
  2631. value: function commit() {
  2632. this._worksheet._commitRow(this); // eslint-disable-line no-underscore-dangle
  2633. } // helps GC by breaking cyclic references
  2634. }, {
  2635. key: "destroy",
  2636. value: function destroy() {
  2637. delete this._worksheet;
  2638. delete this._cells;
  2639. delete this.style;
  2640. }
  2641. }, {
  2642. key: "findCell",
  2643. value: function findCell(colNumber) {
  2644. return this._cells[colNumber - 1];
  2645. } // given {address, row, col}, find or create new cell
  2646. }, {
  2647. key: "getCellEx",
  2648. value: function getCellEx(address) {
  2649. var cell = this._cells[address.col - 1];
  2650. if (!cell) {
  2651. var column = this._worksheet.getColumn(address.col);
  2652. cell = new Cell(this, column, address.address);
  2653. this._cells[address.col - 1] = cell;
  2654. }
  2655. return cell;
  2656. } // get cell by key, letter or column number
  2657. }, {
  2658. key: "getCell",
  2659. value: function getCell(col) {
  2660. if (typeof col === 'string') {
  2661. // is it a key?
  2662. var column = this._worksheet.getColumnKey(col);
  2663. if (column) {
  2664. col = column.number;
  2665. } else {
  2666. col = colCache.l2n(col);
  2667. }
  2668. }
  2669. return this._cells[col - 1] || this.getCellEx({
  2670. address: colCache.encodeAddress(this._number, col),
  2671. row: this._number,
  2672. col: col
  2673. });
  2674. } // remove cell(s) and shift all higher cells down by count
  2675. }, {
  2676. key: "splice",
  2677. value: function splice(start, count) {
  2678. var nKeep = start + count;
  2679. for (var _len = arguments.length, inserts = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  2680. inserts[_key - 2] = arguments[_key];
  2681. }
  2682. var nExpand = inserts.length - count;
  2683. var nEnd = this._cells.length;
  2684. var i;
  2685. var cSrc;
  2686. var cDst;
  2687. if (nExpand < 0) {
  2688. // remove cells
  2689. for (i = start + inserts.length; i <= nEnd; i++) {
  2690. cDst = this._cells[i - 1];
  2691. cSrc = this._cells[i - nExpand - 1];
  2692. if (cSrc) {
  2693. cDst = this.getCell(i);
  2694. cDst.value = cSrc.value;
  2695. cDst.style = cSrc.style; // eslint-disable-next-line no-underscore-dangle
  2696. cDst._comment = cSrc._comment;
  2697. } else if (cDst) {
  2698. cDst.value = null;
  2699. cDst.style = {}; // eslint-disable-next-line no-underscore-dangle
  2700. cDst._comment = undefined;
  2701. }
  2702. }
  2703. } else if (nExpand > 0) {
  2704. // insert new cells
  2705. for (i = nEnd; i >= nKeep; i--) {
  2706. cSrc = this._cells[i - 1];
  2707. if (cSrc) {
  2708. cDst = this.getCell(i + nExpand);
  2709. cDst.value = cSrc.value;
  2710. cDst.style = cSrc.style; // eslint-disable-next-line no-underscore-dangle
  2711. cDst._comment = cSrc._comment;
  2712. } else {
  2713. this._cells[i + nExpand - 1] = undefined;
  2714. }
  2715. }
  2716. } // now add the new values
  2717. for (i = 0; i < inserts.length; i++) {
  2718. cDst = this.getCell(start + i);
  2719. cDst.value = inserts[i];
  2720. cDst.style = {}; // eslint-disable-next-line no-underscore-dangle
  2721. cDst._comment = undefined;
  2722. }
  2723. } // Iterate over all non-null cells in this row
  2724. }, {
  2725. key: "eachCell",
  2726. value: function eachCell(options, iteratee) {
  2727. if (!iteratee) {
  2728. iteratee = options;
  2729. options = null;
  2730. }
  2731. if (options && options.includeEmpty) {
  2732. var n = this._cells.length;
  2733. for (var i = 1; i <= n; i++) {
  2734. iteratee(this.getCell(i), i);
  2735. }
  2736. } else {
  2737. this._cells.forEach(function (cell, index) {
  2738. if (cell && cell.type !== Enums.ValueType.Null) {
  2739. iteratee(cell, index + 1);
  2740. }
  2741. });
  2742. }
  2743. } // ===========================================================================
  2744. // Page Breaks
  2745. }, {
  2746. key: "addPageBreak",
  2747. value: function addPageBreak(lft, rght) {
  2748. var ws = this._worksheet;
  2749. var left = Math.max(0, lft - 1) || 0;
  2750. var right = Math.max(0, rght - 1) || 16838;
  2751. var pb = {
  2752. id: this._number,
  2753. max: right,
  2754. man: 1
  2755. };
  2756. if (left) pb.min = left;
  2757. ws.rowBreaks.push(pb);
  2758. } // return a sparse array of cell values
  2759. }, {
  2760. key: "_applyStyle",
  2761. // =========================================================================
  2762. // styles
  2763. value: function _applyStyle(name, value) {
  2764. this.style[name] = value;
  2765. this._cells.forEach(function (cell) {
  2766. if (cell) {
  2767. cell[name] = value;
  2768. }
  2769. });
  2770. return value;
  2771. }
  2772. }, {
  2773. key: "number",
  2774. get: function get() {
  2775. return this._number;
  2776. }
  2777. }, {
  2778. key: "worksheet",
  2779. get: function get() {
  2780. return this._worksheet;
  2781. }
  2782. }, {
  2783. key: "values",
  2784. get: function get() {
  2785. var values = [];
  2786. this._cells.forEach(function (cell) {
  2787. if (cell && cell.type !== Enums.ValueType.Null) {
  2788. values[cell.col] = cell.value;
  2789. }
  2790. });
  2791. return values;
  2792. } // set the values by contiguous or sparse array, or by key'd object literal
  2793. ,
  2794. set: function set(value) {
  2795. var _this = this;
  2796. // this operation is not additive - any prior cells are removed
  2797. this._cells = [];
  2798. if (!value) {// empty row
  2799. } else if (value instanceof Array) {
  2800. var offset = 0;
  2801. if (value.hasOwnProperty('0')) {
  2802. // contiguous array - start at column 1
  2803. offset = 1;
  2804. }
  2805. value.forEach(function (item, index) {
  2806. if (item !== undefined) {
  2807. _this.getCellEx({
  2808. address: colCache.encodeAddress(_this._number, index + offset),
  2809. row: _this._number,
  2810. col: index + offset
  2811. }).value = item;
  2812. }
  2813. });
  2814. } else {
  2815. // assume object with column keys
  2816. this._worksheet.eachColumnKey(function (column, key) {
  2817. if (value[key] !== undefined) {
  2818. _this.getCellEx({
  2819. address: colCache.encodeAddress(_this._number, column.number),
  2820. row: _this._number,
  2821. col: column.number
  2822. }).value = value[key];
  2823. }
  2824. });
  2825. }
  2826. } // returns true if the row includes at least one cell with a value
  2827. }, {
  2828. key: "hasValues",
  2829. get: function get() {
  2830. return _.some(this._cells, function (cell) {
  2831. return cell && cell.type !== Enums.ValueType.Null;
  2832. });
  2833. }
  2834. }, {
  2835. key: "cellCount",
  2836. get: function get() {
  2837. return this._cells.length;
  2838. }
  2839. }, {
  2840. key: "actualCellCount",
  2841. get: function get() {
  2842. var count = 0;
  2843. this.eachCell(function () {
  2844. count++;
  2845. });
  2846. return count;
  2847. } // get the min and max column number for the non-null cells in this row or null
  2848. }, {
  2849. key: "dimensions",
  2850. get: function get() {
  2851. var min = 0;
  2852. var max = 0;
  2853. this._cells.forEach(function (cell) {
  2854. if (cell && cell.type !== Enums.ValueType.Null) {
  2855. if (!min || min > cell.col) {
  2856. min = cell.col;
  2857. }
  2858. if (max < cell.col) {
  2859. max = cell.col;
  2860. }
  2861. }
  2862. });
  2863. return min > 0 ? {
  2864. min: min,
  2865. max: max
  2866. } : null;
  2867. }
  2868. }, {
  2869. key: "numFmt",
  2870. get: function get() {
  2871. return this.style.numFmt;
  2872. },
  2873. set: function set(value) {
  2874. this._applyStyle('numFmt', value);
  2875. }
  2876. }, {
  2877. key: "font",
  2878. get: function get() {
  2879. return this.style.font;
  2880. },
  2881. set: function set(value) {
  2882. this._applyStyle('font', value);
  2883. }
  2884. }, {
  2885. key: "alignment",
  2886. get: function get() {
  2887. return this.style.alignment;
  2888. },
  2889. set: function set(value) {
  2890. this._applyStyle('alignment', value);
  2891. }
  2892. }, {
  2893. key: "protection",
  2894. get: function get() {
  2895. return this.style.protection;
  2896. },
  2897. set: function set(value) {
  2898. this._applyStyle('protection', value);
  2899. }
  2900. }, {
  2901. key: "border",
  2902. get: function get() {
  2903. return this.style.border;
  2904. },
  2905. set: function set(value) {
  2906. this._applyStyle('border', value);
  2907. }
  2908. }, {
  2909. key: "fill",
  2910. get: function get() {
  2911. return this.style.fill;
  2912. },
  2913. set: function set(value) {
  2914. this._applyStyle('fill', value);
  2915. }
  2916. }, {
  2917. key: "hidden",
  2918. get: function get() {
  2919. return !!this._hidden;
  2920. },
  2921. set: function set(value) {
  2922. this._hidden = value;
  2923. }
  2924. }, {
  2925. key: "outlineLevel",
  2926. get: function get() {
  2927. return this._outlineLevel || 0;
  2928. },
  2929. set: function set(value) {
  2930. this._outlineLevel = value;
  2931. }
  2932. }, {
  2933. key: "collapsed",
  2934. get: function get() {
  2935. return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow);
  2936. } // =========================================================================
  2937. }, {
  2938. key: "model",
  2939. get: function get() {
  2940. var cells = [];
  2941. var min = 0;
  2942. var max = 0;
  2943. this._cells.forEach(function (cell) {
  2944. if (cell) {
  2945. var cellModel = cell.model;
  2946. if (cellModel) {
  2947. if (!min || min > cell.col) {
  2948. min = cell.col;
  2949. }
  2950. if (max < cell.col) {
  2951. max = cell.col;
  2952. }
  2953. cells.push(cellModel);
  2954. }
  2955. }
  2956. });
  2957. return this.height || cells.length ? {
  2958. cells: cells,
  2959. number: this.number,
  2960. min: min,
  2961. max: max,
  2962. height: this.height,
  2963. style: this.style,
  2964. hidden: this.hidden,
  2965. outlineLevel: this.outlineLevel,
  2966. collapsed: this.collapsed
  2967. } : null;
  2968. },
  2969. set: function set(value) {
  2970. var _this2 = this;
  2971. if (value.number !== this._number) {
  2972. throw new Error('Invalid row number in model');
  2973. }
  2974. this._cells = [];
  2975. var previousAddress;
  2976. value.cells.forEach(function (cellModel) {
  2977. switch (cellModel.type) {
  2978. case Cell.Types.Merge:
  2979. // special case - don't add this types
  2980. break;
  2981. default:
  2982. {
  2983. var address;
  2984. if (cellModel.address) {
  2985. address = colCache.decodeAddress(cellModel.address);
  2986. } else if (previousAddress) {
  2987. // This is a <c> element without an r attribute
  2988. // Assume that it's the cell for the next column
  2989. var _previousAddress = previousAddress,
  2990. row = _previousAddress.row;
  2991. var col = previousAddress.col + 1;
  2992. address = {
  2993. row: row,
  2994. col: col,
  2995. address: colCache.encodeAddress(row, col),
  2996. $col$row: "$".concat(colCache.n2l(col), "$").concat(row)
  2997. };
  2998. }
  2999. previousAddress = address;
  3000. var cell = _this2.getCellEx(address);
  3001. cell.model = cellModel;
  3002. break;
  3003. }
  3004. }
  3005. });
  3006. if (value.height) {
  3007. this.height = value.height;
  3008. } else {
  3009. delete this.height;
  3010. }
  3011. this.hidden = value.hidden;
  3012. this.outlineLevel = value.outlineLevel || 0;
  3013. this.style = value.style && JSON.parse(JSON.stringify(value.style)) || {};
  3014. }
  3015. }]);
  3016. return Row;
  3017. }();
  3018. module.exports = Row;
  3019. }, { "../utils/col-cache": 19, "../utils/under-dash": 25, "./cell": 3, "./enums": 7 }], 12: [function (require, module, exports) {
  3020. "use strict";
  3021. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3022. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3023. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3024. /* eslint-disable max-classes-per-file */
  3025. var colCache = require('../utils/col-cache');
  3026. var Column = /*#__PURE__*/function () {
  3027. // wrapper around column model, allowing access and manipulation
  3028. function Column(table, column, index) {
  3029. _classCallCheck(this, Column);
  3030. this.table = table;
  3031. this.column = column;
  3032. this.index = index;
  3033. }
  3034. _createClass(Column, [{
  3035. key: "_set",
  3036. value: function _set(name, value) {
  3037. this.table.cacheState();
  3038. this.column[name] = value;
  3039. }
  3040. /* eslint-disable lines-between-class-members */
  3041. }, {
  3042. key: "name",
  3043. get: function get() {
  3044. return this.column.name;
  3045. },
  3046. set: function set(value) {
  3047. this._set('name', value);
  3048. }
  3049. }, {
  3050. key: "filterButton",
  3051. get: function get() {
  3052. return this.column.filterButton;
  3053. },
  3054. set: function set(value) {
  3055. this.column.filterButton = value;
  3056. }
  3057. }, {
  3058. key: "style",
  3059. get: function get() {
  3060. return this.column.style;
  3061. },
  3062. set: function set(value) {
  3063. this.column.style = value;
  3064. }
  3065. }, {
  3066. key: "totalsRowLabel",
  3067. get: function get() {
  3068. return this.column.totalsRowLabel;
  3069. },
  3070. set: function set(value) {
  3071. this._set('totalsRowLabel', value);
  3072. }
  3073. }, {
  3074. key: "totalsRowFunction",
  3075. get: function get() {
  3076. return this.column.totalsRowFunction;
  3077. },
  3078. set: function set(value) {
  3079. this._set('totalsRowFunction', value);
  3080. }
  3081. }, {
  3082. key: "totalsRowResult",
  3083. get: function get() {
  3084. return this.column.totalsRowResult;
  3085. },
  3086. set: function set(value) {
  3087. this._set('totalsRowResult', value);
  3088. }
  3089. }, {
  3090. key: "totalsRowFormula",
  3091. get: function get() {
  3092. return this.column.totalsRowFormula;
  3093. },
  3094. set: function set(value) {
  3095. this._set('totalsRowFormula', value);
  3096. }
  3097. /* eslint-enable lines-between-class-members */
  3098. }]);
  3099. return Column;
  3100. }();
  3101. var Table = /*#__PURE__*/function () {
  3102. function Table(worksheet, table) {
  3103. _classCallCheck(this, Table);
  3104. this.worksheet = worksheet;
  3105. if (table) {
  3106. this.table = table; // check things are ok first
  3107. this.validate();
  3108. this.store();
  3109. }
  3110. }
  3111. _createClass(Table, [{
  3112. key: "getFormula",
  3113. value: function getFormula(column) {
  3114. // get the correct formula to apply to the totals row
  3115. switch (column.totalsRowFunction) {
  3116. case 'none':
  3117. return null;
  3118. case 'average':
  3119. return "SUBTOTAL(101,".concat(this.table.name, "[").concat(column.name, "])");
  3120. case 'countNums':
  3121. return "SUBTOTAL(102,".concat(this.table.name, "[").concat(column.name, "])");
  3122. case 'count':
  3123. return "SUBTOTAL(103,".concat(this.table.name, "[").concat(column.name, "])");
  3124. case 'max':
  3125. return "SUBTOTAL(104,".concat(this.table.name, "[").concat(column.name, "])");
  3126. case 'min':
  3127. return "SUBTOTAL(105,".concat(this.table.name, "[").concat(column.name, "])");
  3128. case 'stdDev':
  3129. return "SUBTOTAL(106,".concat(this.table.name, "[").concat(column.name, "])");
  3130. case 'var':
  3131. return "SUBTOTAL(107,".concat(this.table.name, "[").concat(column.name, "])");
  3132. case 'sum':
  3133. return "SUBTOTAL(109,".concat(this.table.name, "[").concat(column.name, "])");
  3134. case 'custom':
  3135. return column.totalsRowFormula;
  3136. default:
  3137. throw new Error("Invalid Totals Row Function: ".concat(column.totalsRowFunction));
  3138. }
  3139. }
  3140. }, {
  3141. key: "validate",
  3142. value: function validate() {
  3143. var _this = this;
  3144. var table = this.table; // set defaults and check is valid
  3145. var assign = function assign(o, name, dflt) {
  3146. if (o[name] === undefined) {
  3147. o[name] = dflt;
  3148. }
  3149. };
  3150. assign(table, 'headerRow', true);
  3151. assign(table, 'totalsRow', false);
  3152. assign(table, 'style', {});
  3153. assign(table.style, 'theme', 'TableStyleMedium2');
  3154. assign(table.style, 'showFirstColumn', false);
  3155. assign(table.style, 'showLastColumn', false);
  3156. assign(table.style, 'showRowStripes', false);
  3157. assign(table.style, 'showColumnStripes', false);
  3158. var assert = function assert(test, message) {
  3159. if (!test) {
  3160. throw new Error(message);
  3161. }
  3162. };
  3163. assert(table.ref, 'Table must have ref');
  3164. assert(table.columns, 'Table must have column definitions');
  3165. assert(table.rows, 'Table must have row definitions');
  3166. table.tl = colCache.decodeAddress(table.ref);
  3167. var _table$tl = table.tl,
  3168. row = _table$tl.row,
  3169. col = _table$tl.col;
  3170. assert(row > 0, 'Table must be on valid row');
  3171. assert(col > 0, 'Table must be on valid col');
  3172. var width = this.width,
  3173. filterHeight = this.filterHeight,
  3174. tableHeight = this.tableHeight; // autoFilterRef is a range that includes optional headers only
  3175. table.autoFilterRef = colCache.encode(row, col, row + filterHeight - 1, col + width - 1); // tableRef is a range that includes optional headers and totals
  3176. table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);
  3177. table.columns.forEach(function (column, i) {
  3178. assert(column.name, "Column ".concat(i, " must have a name"));
  3179. if (i === 0) {
  3180. assign(column, 'totalsRowLabel', 'Total');
  3181. } else {
  3182. assign(column, 'totalsRowFunction', 'none');
  3183. column.totalsRowFormula = _this.getFormula(column);
  3184. }
  3185. });
  3186. }
  3187. }, {
  3188. key: "store",
  3189. value: function store() {
  3190. var _this2 = this;
  3191. // where the table needs to store table data, headers, footers in
  3192. // the sheet...
  3193. var assignStyle = function assignStyle(cell, style) {
  3194. if (style) {
  3195. Object.keys(style).forEach(function (key) {
  3196. cell[key] = style[key];
  3197. });
  3198. }
  3199. };
  3200. var worksheet = this.worksheet,
  3201. table = this.table;
  3202. var _table$tl2 = table.tl,
  3203. row = _table$tl2.row,
  3204. col = _table$tl2.col;
  3205. var count = 0;
  3206. if (table.headerRow) {
  3207. var r = worksheet.getRow(row + count++);
  3208. table.columns.forEach(function (column, j) {
  3209. var style = column.style,
  3210. name = column.name;
  3211. var cell = r.getCell(col + j);
  3212. cell.value = name;
  3213. assignStyle(cell, style);
  3214. });
  3215. }
  3216. table.rows.forEach(function (data) {
  3217. var r = worksheet.getRow(row + count++);
  3218. data.forEach(function (value, j) {
  3219. var cell = r.getCell(col + j);
  3220. cell.value = value;
  3221. assignStyle(cell, table.columns[j].style);
  3222. });
  3223. });
  3224. if (table.totalsRow) {
  3225. var _r = worksheet.getRow(row + count++);
  3226. table.columns.forEach(function (column, j) {
  3227. var cell = _r.getCell(col + j);
  3228. if (j === 0) {
  3229. cell.value = column.totalsRowLabel;
  3230. } else {
  3231. var formula = _this2.getFormula(column);
  3232. if (formula) {
  3233. cell.value = {
  3234. formula: column.totalsRowFormula,
  3235. result: column.totalsRowResult
  3236. };
  3237. } else {
  3238. cell.value = null;
  3239. }
  3240. }
  3241. assignStyle(cell, column.style);
  3242. });
  3243. }
  3244. }
  3245. }, {
  3246. key: "load",
  3247. value: function load(worksheet) {
  3248. var _this3 = this;
  3249. // where the table will read necessary features from a loaded sheet
  3250. var table = this.table;
  3251. var _table$tl3 = table.tl,
  3252. row = _table$tl3.row,
  3253. col = _table$tl3.col;
  3254. var count = 0;
  3255. if (table.headerRow) {
  3256. var r = worksheet.getRow(row + count++);
  3257. table.columns.forEach(function (column, j) {
  3258. var cell = r.getCell(col + j);
  3259. cell.value = column.name;
  3260. });
  3261. }
  3262. table.rows.forEach(function (data) {
  3263. var r = worksheet.getRow(row + count++);
  3264. data.forEach(function (value, j) {
  3265. var cell = r.getCell(col + j);
  3266. cell.value = value;
  3267. });
  3268. });
  3269. if (table.totalsRow) {
  3270. var _r2 = worksheet.getRow(row + count++);
  3271. table.columns.forEach(function (column, j) {
  3272. var cell = _r2.getCell(col + j);
  3273. if (j === 0) {
  3274. cell.value = column.totalsRowLabel;
  3275. } else {
  3276. var formula = _this3.getFormula(column);
  3277. if (formula) {
  3278. cell.value = {
  3279. formula: column.totalsRowFormula,
  3280. result: column.totalsRowResult
  3281. };
  3282. }
  3283. }
  3284. });
  3285. }
  3286. }
  3287. }, {
  3288. key: "cacheState",
  3289. // ================================================================
  3290. // TODO: Mutating methods
  3291. value: function cacheState() {
  3292. if (!this._cache) {
  3293. this._cache = {
  3294. ref: this.ref,
  3295. width: this.width,
  3296. tableHeight: this.tableHeight
  3297. };
  3298. }
  3299. }
  3300. }, {
  3301. key: "commit",
  3302. value: function commit() {
  3303. // changes may have been made that might have on-sheet effects
  3304. if (!this._cache) {
  3305. return;
  3306. } // check things are ok first
  3307. this.validate();
  3308. var ref = colCache.decodeAddress(this._cache.ref);
  3309. if (this.ref !== this._cache.ref) {
  3310. // wipe out whole table footprint at previous location
  3311. for (var i = 0; i < this._cache.tableHeight; i++) {
  3312. var row = this.worksheet.getRow(ref.row + i);
  3313. for (var j = 0; j < this._cache.width; j++) {
  3314. var cell = row.getCell(ref.col + j);
  3315. cell.value = null;
  3316. }
  3317. }
  3318. } else {
  3319. // clear out below table if it has shrunk
  3320. for (var _i = this.tableHeight; _i < this._cache.tableHeight; _i++) {
  3321. var _row = this.worksheet.getRow(ref.row + _i);
  3322. for (var _j = 0; _j < this._cache.width; _j++) {
  3323. var _cell = _row.getCell(ref.col + _j);
  3324. _cell.value = null;
  3325. }
  3326. } // clear out to right of table if it has lost columns
  3327. for (var _i2 = 0; _i2 < this.tableHeight; _i2++) {
  3328. var _row2 = this.worksheet.getRow(ref.row + _i2);
  3329. for (var _j2 = this.width; _j2 < this._cache.width; _j2++) {
  3330. var _cell2 = _row2.getCell(ref.col + _j2);
  3331. _cell2.value = null;
  3332. }
  3333. }
  3334. }
  3335. this.store();
  3336. }
  3337. }, {
  3338. key: "addRow",
  3339. value: function addRow(values, rowNumber) {
  3340. // Add a row of data, either insert at rowNumber or append
  3341. this.cacheState();
  3342. if (rowNumber === undefined) {
  3343. this.table.rows.push(values);
  3344. } else {
  3345. this.table.rows.splice(rowNumber, 0, values);
  3346. }
  3347. }
  3348. }, {
  3349. key: "removeRows",
  3350. value: function removeRows(rowIndex) {
  3351. var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  3352. // Remove a rows of data
  3353. this.cacheState();
  3354. this.table.rows.splice(rowIndex, count);
  3355. }
  3356. }, {
  3357. key: "getColumn",
  3358. value: function getColumn(colIndex) {
  3359. var column = this.table.columns[colIndex];
  3360. return new Column(this, column, colIndex);
  3361. }
  3362. }, {
  3363. key: "addColumn",
  3364. value: function addColumn(column, values, colIndex) {
  3365. // Add a new column, including column defn and values
  3366. // Inserts at colNumber or adds to the right
  3367. this.cacheState();
  3368. if (colIndex === undefined) {
  3369. this.table.columns.push(column);
  3370. this.table.rows.forEach(function (row, i) {
  3371. row.push(values[i]);
  3372. });
  3373. } else {
  3374. this.table.columns.splice(colIndex, 0, column);
  3375. this.table.rows.forEach(function (row, i) {
  3376. row.splice(colIndex, 0, values[i]);
  3377. });
  3378. }
  3379. }
  3380. }, {
  3381. key: "removeColumns",
  3382. value: function removeColumns(colIndex) {
  3383. var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  3384. // Remove a column with data
  3385. this.cacheState();
  3386. this.table.columns.splice(colIndex, count);
  3387. this.table.rows.forEach(function (row) {
  3388. row.splice(colIndex, count);
  3389. });
  3390. }
  3391. }, {
  3392. key: "_assign",
  3393. value: function _assign(target, prop, value) {
  3394. this.cacheState();
  3395. target[prop] = value;
  3396. }
  3397. /* eslint-disable lines-between-class-members */
  3398. }, {
  3399. key: "width",
  3400. get: function get() {
  3401. // width of the table
  3402. return this.table.columns.length;
  3403. }
  3404. }, {
  3405. key: "height",
  3406. get: function get() {
  3407. // height of the table data
  3408. return this.table.rows.length;
  3409. }
  3410. }, {
  3411. key: "filterHeight",
  3412. get: function get() {
  3413. // height of the table data plus optional header row
  3414. return this.height + (this.table.headerRow ? 1 : 0);
  3415. }
  3416. }, {
  3417. key: "tableHeight",
  3418. get: function get() {
  3419. // full height of the table on the sheet
  3420. return this.filterHeight + (this.table.totalsRow ? 1 : 0);
  3421. }
  3422. }, {
  3423. key: "model",
  3424. get: function get() {
  3425. return this.table;
  3426. },
  3427. set: function set(value) {
  3428. this.table = value;
  3429. }
  3430. }, {
  3431. key: "ref",
  3432. get: function get() {
  3433. return this.table.ref;
  3434. },
  3435. set: function set(value) {
  3436. this._assign(this.table, 'ref', value);
  3437. }
  3438. }, {
  3439. key: "name",
  3440. get: function get() {
  3441. return this.table.name;
  3442. },
  3443. set: function set(value) {
  3444. this.table.name = value;
  3445. }
  3446. }, {
  3447. key: "displayName",
  3448. get: function get() {
  3449. return this.table.displyName || this.table.name;
  3450. }
  3451. }, {
  3452. key: "displayNamename",
  3453. set: function set(value) {
  3454. this.table.displayName = value;
  3455. }
  3456. }, {
  3457. key: "headerRow",
  3458. get: function get() {
  3459. return this.table.headerRow;
  3460. },
  3461. set: function set(value) {
  3462. this._assign(this.table, 'headerRow', value);
  3463. }
  3464. }, {
  3465. key: "totalsRow",
  3466. get: function get() {
  3467. return this.table.totalsRow;
  3468. },
  3469. set: function set(value) {
  3470. this._assign(this.table, 'totalsRow', value);
  3471. }
  3472. }, {
  3473. key: "theme",
  3474. get: function get() {
  3475. return this.table.style.name;
  3476. },
  3477. set: function set(value) {
  3478. this.table.style.name = value;
  3479. }
  3480. }, {
  3481. key: "showFirstColumn",
  3482. get: function get() {
  3483. return this.table.style.showFirstColumn;
  3484. },
  3485. set: function set(value) {
  3486. this.table.style.showFirstColumn = value;
  3487. }
  3488. }, {
  3489. key: "showLastColumn",
  3490. get: function get() {
  3491. return this.table.style.showLastColumn;
  3492. },
  3493. set: function set(value) {
  3494. this.table.style.showLastColumn = value;
  3495. }
  3496. }, {
  3497. key: "showRowStripes",
  3498. get: function get() {
  3499. return this.table.style.showRowStripes;
  3500. },
  3501. set: function set(value) {
  3502. this.table.style.showRowStripes = value;
  3503. }
  3504. }, {
  3505. key: "showColumnStripes",
  3506. get: function get() {
  3507. return this.table.style.showColumnStripes;
  3508. },
  3509. set: function set(value) {
  3510. this.table.style.showColumnStripes = value;
  3511. }
  3512. /* eslint-enable lines-between-class-members */
  3513. }]);
  3514. return Table;
  3515. }();
  3516. module.exports = Table;
  3517. }, { "../utils/col-cache": 19 }], 13: [function (require, module, exports) {
  3518. 'use strict';
  3519. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3520. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3521. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3522. var Worksheet = require('./worksheet');
  3523. var DefinedNames = require('./defined-names');
  3524. var XLSX = require('../xlsx/xlsx');
  3525. var CSV = require('../csv/csv'); // Workbook requirements
  3526. // Load and Save from file and stream
  3527. // Access/Add/Delete individual worksheets
  3528. // Manage String table, Hyperlink table, etc.
  3529. // Manage scaffolding for contained objects to write to/read from
  3530. var Workbook = /*#__PURE__*/function () {
  3531. function Workbook() {
  3532. _classCallCheck(this, Workbook);
  3533. this.created = new Date();
  3534. this.modified = this.created;
  3535. this.properties = {};
  3536. this.calcProperties = {};
  3537. this._worksheets = [];
  3538. this.views = [];
  3539. this.media = [];
  3540. this._definedNames = new DefinedNames();
  3541. }
  3542. _createClass(Workbook, [{
  3543. key: "addWorksheet",
  3544. value: function addWorksheet(name, options) {
  3545. var id = this.nextId;
  3546. if (name && name.length > 31) {
  3547. // eslint-disable-next-line no-console
  3548. console.warn("Worksheet name ".concat(name, " exceeds 31 chars. This will be truncated"));
  3549. } // Illegal character in worksheet name: asterisk (*), question mark (?),
  3550. // colon (:), forward slash (/ \), or bracket ([])
  3551. if (/[*?:/\\[\]]/.test(name)) {
  3552. throw new Error("Worksheet name ".concat(name, " cannot include any of the following characters: * ? : \\ / [ ]"));
  3553. }
  3554. if (/(^')|('$)/.test(name)) {
  3555. throw new Error("The first or last character of worksheet name cannot be a single quotation mark: ".concat(name));
  3556. }
  3557. name = (name || "sheet".concat(id)).substring(0, 31);
  3558. if (this._worksheets.find(function (ws) {
  3559. return ws && ws.name.toLowerCase() === name.toLowerCase();
  3560. })) {
  3561. throw new Error("Worksheet name already exists: ".concat(name));
  3562. } // if options is a color, call it tabColor (and signal deprecated message)
  3563. if (options) {
  3564. if (typeof options === 'string') {
  3565. // eslint-disable-next-line no-console
  3566. console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }');
  3567. options = {
  3568. properties: {
  3569. tabColor: {
  3570. argb: options
  3571. }
  3572. }
  3573. };
  3574. } else if (options.argb || options.theme || options.indexed) {
  3575. // eslint-disable-next-line no-console
  3576. console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }');
  3577. options = {
  3578. properties: {
  3579. tabColor: options
  3580. }
  3581. };
  3582. }
  3583. }
  3584. var lastOrderNo = this._worksheets.reduce(function (acc, ws) {
  3585. return (ws && ws.orderNo) > acc ? ws.orderNo : acc;
  3586. }, 0);
  3587. var worksheetOptions = Object.assign({}, options, {
  3588. id: id,
  3589. name: name,
  3590. orderNo: lastOrderNo + 1,
  3591. workbook: this
  3592. });
  3593. var worksheet = new Worksheet(worksheetOptions);
  3594. this._worksheets[id] = worksheet;
  3595. return worksheet;
  3596. }
  3597. }, {
  3598. key: "removeWorksheetEx",
  3599. value: function removeWorksheetEx(worksheet) {
  3600. delete this._worksheets[worksheet.id];
  3601. }
  3602. }, {
  3603. key: "removeWorksheet",
  3604. value: function removeWorksheet(id) {
  3605. var worksheet = this.getWorksheet(id);
  3606. if (worksheet) {
  3607. worksheet.destroy();
  3608. }
  3609. }
  3610. }, {
  3611. key: "getWorksheet",
  3612. value: function getWorksheet(id) {
  3613. if (id === undefined) {
  3614. return this._worksheets.find(Boolean);
  3615. }
  3616. if (typeof id === 'number') {
  3617. return this._worksheets[id];
  3618. }
  3619. if (typeof id === 'string') {
  3620. return this._worksheets.find(function (worksheet) {
  3621. return worksheet && worksheet.name === id;
  3622. });
  3623. }
  3624. return undefined;
  3625. }
  3626. }, {
  3627. key: "eachSheet",
  3628. value: function eachSheet(iteratee) {
  3629. this.worksheets.forEach(function (sheet) {
  3630. iteratee(sheet, sheet.id);
  3631. });
  3632. }
  3633. }, {
  3634. key: "clearThemes",
  3635. value: function clearThemes() {
  3636. // Note: themes are not an exposed feature, meddle at your peril!
  3637. this._themes = undefined;
  3638. }
  3639. }, {
  3640. key: "addImage",
  3641. value: function addImage(image) {
  3642. // TODO: validation?
  3643. var id = this.media.length;
  3644. this.media.push(Object.assign({}, image, {
  3645. type: 'image'
  3646. }));
  3647. return id;
  3648. }
  3649. }, {
  3650. key: "getImage",
  3651. value: function getImage(id) {
  3652. return this.media[id];
  3653. }
  3654. }, {
  3655. key: "xlsx",
  3656. get: function get() {
  3657. if (!this._xlsx) this._xlsx = new XLSX(this);
  3658. return this._xlsx;
  3659. }
  3660. }, {
  3661. key: "csv",
  3662. get: function get() {
  3663. if (!this._csv) this._csv = new CSV(this);
  3664. return this._csv;
  3665. }
  3666. }, {
  3667. key: "nextId",
  3668. get: function get() {
  3669. // find the next unique spot to add worksheet
  3670. for (var i = 1; i < this._worksheets.length; i++) {
  3671. if (!this._worksheets[i]) {
  3672. return i;
  3673. }
  3674. }
  3675. return this._worksheets.length || 1;
  3676. }
  3677. }, {
  3678. key: "worksheets",
  3679. get: function get() {
  3680. // return a clone of _worksheets
  3681. return this._worksheets.slice(1).sort(function (a, b) {
  3682. return a.orderNo - b.orderNo;
  3683. }).filter(Boolean);
  3684. }
  3685. }, {
  3686. key: "definedNames",
  3687. get: function get() {
  3688. return this._definedNames;
  3689. }
  3690. }, {
  3691. key: "model",
  3692. get: function get() {
  3693. return {
  3694. creator: this.creator || 'Unknown',
  3695. lastModifiedBy: this.lastModifiedBy || 'Unknown',
  3696. lastPrinted: this.lastPrinted,
  3697. created: this.created,
  3698. modified: this.modified,
  3699. properties: this.properties,
  3700. worksheets: this.worksheets.map(function (worksheet) {
  3701. return worksheet.model;
  3702. }),
  3703. sheets: this.worksheets.map(function (ws) {
  3704. return ws.model;
  3705. }).filter(Boolean),
  3706. definedNames: this._definedNames.model,
  3707. views: this.views,
  3708. company: this.company,
  3709. manager: this.manager,
  3710. title: this.title,
  3711. subject: this.subject,
  3712. keywords: this.keywords,
  3713. category: this.category,
  3714. description: this.description,
  3715. language: this.language,
  3716. revision: this.revision,
  3717. contentStatus: this.contentStatus,
  3718. themes: this._themes,
  3719. media: this.media,
  3720. calcProperties: this.calcProperties
  3721. };
  3722. },
  3723. set: function set(value) {
  3724. var _this = this;
  3725. this.creator = value.creator;
  3726. this.lastModifiedBy = value.lastModifiedBy;
  3727. this.lastPrinted = value.lastPrinted;
  3728. this.created = value.created;
  3729. this.modified = value.modified;
  3730. this.company = value.company;
  3731. this.manager = value.manager;
  3732. this.title = value.title;
  3733. this.subject = value.subject;
  3734. this.keywords = value.keywords;
  3735. this.category = value.category;
  3736. this.description = value.description;
  3737. this.language = value.language;
  3738. this.revision = value.revision;
  3739. this.contentStatus = value.contentStatus;
  3740. this.properties = value.properties;
  3741. this.calcProperties = value.calcProperties;
  3742. this._worksheets = [];
  3743. value.worksheets.forEach(function (worksheetModel) {
  3744. var id = worksheetModel.id,
  3745. name = worksheetModel.name,
  3746. state = worksheetModel.state;
  3747. var orderNo = value.sheets && value.sheets.findIndex(function (ws) {
  3748. return ws.id === id;
  3749. });
  3750. var worksheet = _this._worksheets[id] = new Worksheet({
  3751. id: id,
  3752. name: name,
  3753. orderNo: orderNo,
  3754. state: state,
  3755. workbook: _this
  3756. });
  3757. worksheet.model = worksheetModel;
  3758. });
  3759. this._definedNames.model = value.definedNames;
  3760. this.views = value.views;
  3761. this._themes = value.themes;
  3762. this.media = value.media || [];
  3763. }
  3764. }]);
  3765. return Workbook;
  3766. }();
  3767. module.exports = Workbook;
  3768. }, { "../csv/csv": 1, "../xlsx/xlsx": 141, "./defined-names": 6, "./worksheet": 14 }], 14: [function (require, module, exports) {
  3769. "use strict";
  3770. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  3771. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  3772. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  3773. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  3774. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  3775. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  3776. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  3777. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  3778. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  3779. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3780. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3781. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3782. var _ = require('../utils/under-dash');
  3783. var colCache = require('../utils/col-cache');
  3784. var Range = require('./range');
  3785. var Row = require('./row');
  3786. var Column = require('./column');
  3787. var Enums = require('./enums');
  3788. var Image = require('./image');
  3789. var Table = require('./table');
  3790. var DataValidations = require('./data-validations');
  3791. var Encryptor = require('../utils/encryptor'); // Worksheet requirements
  3792. // Operate as sheet inside workbook or standalone
  3793. // Load and Save from file and stream
  3794. // Access/Add/Delete individual cells
  3795. // Manage column widths and row heights
  3796. var Worksheet = /*#__PURE__*/function () {
  3797. function Worksheet(options) {
  3798. _classCallCheck(this, Worksheet);
  3799. options = options || {}; // in a workbook, each sheet will have a number
  3800. this.id = options.id;
  3801. this.orderNo = options.orderNo; // and a name
  3802. this.name = options.name || "Sheet".concat(this.id); // add a state
  3803. this.state = options.state || 'visible'; // rows allows access organised by row. Sparse array of arrays indexed by row-1, col
  3804. // Note: _rows is zero based. Must subtract 1 to go from cell.row to index
  3805. this._rows = []; // column definitions
  3806. this._columns = null; // column keys (addRow convenience): key ==> this._collumns index
  3807. this._keys = {}; // keep record of all merges
  3808. this._merges = {}; // record of all row and column pageBreaks
  3809. this.rowBreaks = [];
  3810. this._workbook = options.workbook; // for tabColor, default row height, outline levels, etc
  3811. this.properties = Object.assign({}, {
  3812. defaultRowHeight: 15,
  3813. dyDescent: 55,
  3814. outlineLevelCol: 0,
  3815. outlineLevelRow: 0
  3816. }, options.properties); // for all things printing
  3817. this.pageSetup = Object.assign({}, {
  3818. margins: {
  3819. left: 0.7,
  3820. right: 0.7,
  3821. top: 0.75,
  3822. bottom: 0.75,
  3823. header: 0.3,
  3824. footer: 0.3
  3825. },
  3826. orientation: 'portrait',
  3827. horizontalDpi: 4294967295,
  3828. verticalDpi: 4294967295,
  3829. fitToPage: !!(options.pageSetup && (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && !options.pageSetup.scale),
  3830. pageOrder: 'downThenOver',
  3831. blackAndWhite: false,
  3832. draft: false,
  3833. cellComments: 'None',
  3834. errors: 'displayed',
  3835. scale: 100,
  3836. fitToWidth: 1,
  3837. fitToHeight: 1,
  3838. paperSize: undefined,
  3839. showRowColHeaders: false,
  3840. showGridLines: false,
  3841. firstPageNumber: undefined,
  3842. horizontalCentered: false,
  3843. verticalCentered: false,
  3844. rowBreaks: null,
  3845. colBreaks: null
  3846. }, options.pageSetup);
  3847. this.headerFooter = Object.assign({}, {
  3848. differentFirst: false,
  3849. differentOddEven: false,
  3850. oddHeader: null,
  3851. oddFooter: null,
  3852. evenHeader: null,
  3853. evenFooter: null,
  3854. firstHeader: null,
  3855. firstFooter: null
  3856. }, options.headerFooter);
  3857. this.dataValidations = new DataValidations(); // for freezepanes, split, zoom, gridlines, etc
  3858. this.views = options.views || [];
  3859. this.autoFilter = options.autoFilter || null; // for images, etc
  3860. this._media = []; // worksheet protection
  3861. this.sheetProtection = null; // for tables
  3862. this.tables = {};
  3863. this.conditionalFormattings = [];
  3864. }
  3865. _createClass(Worksheet, [{
  3866. key: "destroy",
  3867. // when you're done with this worksheet, call this to remove from workbook
  3868. value: function destroy() {
  3869. this._workbook.removeWorksheetEx(this);
  3870. } // Get the bounding range of the cells in this worksheet
  3871. }, {
  3872. key: "getColumnKey",
  3873. value: function getColumnKey(key) {
  3874. return this._keys[key];
  3875. }
  3876. }, {
  3877. key: "setColumnKey",
  3878. value: function setColumnKey(key, value) {
  3879. this._keys[key] = value;
  3880. }
  3881. }, {
  3882. key: "deleteColumnKey",
  3883. value: function deleteColumnKey(key) {
  3884. delete this._keys[key];
  3885. }
  3886. }, {
  3887. key: "eachColumnKey",
  3888. value: function eachColumnKey(f) {
  3889. _.each(this._keys, f);
  3890. } // get a single column by col number. If it doesn't exist, create it and any gaps before it
  3891. }, {
  3892. key: "getColumn",
  3893. value: function getColumn(c) {
  3894. if (typeof c === 'string') {
  3895. // if it matches a key'd column, return that
  3896. var col = this._keys[c];
  3897. if (col) return col; // otherwise, assume letter
  3898. c = colCache.l2n(c);
  3899. }
  3900. if (!this._columns) {
  3901. this._columns = [];
  3902. }
  3903. if (c > this._columns.length) {
  3904. var n = this._columns.length + 1;
  3905. while (n <= c) {
  3906. this._columns.push(new Column(this, n++));
  3907. }
  3908. }
  3909. return this._columns[c - 1];
  3910. }
  3911. }, {
  3912. key: "spliceColumns",
  3913. value: function spliceColumns(start, count) {
  3914. var _this = this;
  3915. var rows = this._rows;
  3916. var nRows = rows.length;
  3917. for (var _len = arguments.length, inserts = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  3918. inserts[_key - 2] = arguments[_key];
  3919. }
  3920. if (inserts.length > 0) {
  3921. var _loop = function _loop(i) {
  3922. var rowArguments = [start, count]; // eslint-disable-next-line no-loop-func
  3923. inserts.forEach(function (insert) {
  3924. rowArguments.push(insert[i] || null);
  3925. });
  3926. var row = _this.getRow(i + 1); // eslint-disable-next-line prefer-spread
  3927. row.splice.apply(row, rowArguments);
  3928. };
  3929. // must iterate over all rows whether they exist yet or not
  3930. for (var i = 0; i < nRows; i++) {
  3931. _loop(i);
  3932. }
  3933. } else {
  3934. // nothing to insert, so just splice all rows
  3935. this._rows.forEach(function (r) {
  3936. if (r) {
  3937. r.splice(start, count);
  3938. }
  3939. });
  3940. } // splice column definitions
  3941. var nExpand = inserts.length - count;
  3942. var nKeep = start + count;
  3943. var nEnd = this._columns.length;
  3944. if (nExpand < 0) {
  3945. for (var _i = start + inserts.length; _i <= nEnd; _i++) {
  3946. this.getColumn(_i).defn = this.getColumn(_i - nExpand).defn;
  3947. }
  3948. } else if (nExpand > 0) {
  3949. for (var _i2 = nEnd; _i2 >= nKeep; _i2--) {
  3950. this.getColumn(_i2 + nExpand).defn = this.getColumn(_i2).defn;
  3951. }
  3952. }
  3953. for (var _i3 = start; _i3 < start + inserts.length; _i3++) {
  3954. this.getColumn(_i3).defn = null;
  3955. } // account for defined names
  3956. this.workbook.definedNames.spliceColumns(this.name, start, count, inserts.length);
  3957. }
  3958. }, {
  3959. key: "_commitRow",
  3960. // =========================================================================
  3961. // Rows
  3962. value: function _commitRow() {// nop - allows streaming reader to fill a document
  3963. }
  3964. }, {
  3965. key: "findRow",
  3966. // find a row (if exists) by row number
  3967. value: function findRow(r) {
  3968. return this._rows[r - 1];
  3969. } // find multiple rows (if exists) by row number
  3970. }, {
  3971. key: "findRows",
  3972. value: function findRows(start, length) {
  3973. return this._rows.slice(start - 1, start - 1 + length);
  3974. }
  3975. }, {
  3976. key: "getRow",
  3977. // get a row by row number.
  3978. value: function getRow(r) {
  3979. var row = this._rows[r - 1];
  3980. if (!row) {
  3981. row = this._rows[r - 1] = new Row(this, r);
  3982. }
  3983. return row;
  3984. } // get multiple rows by row number.
  3985. }, {
  3986. key: "getRows",
  3987. value: function getRows(start, length) {
  3988. if (length < 1) return undefined;
  3989. var rows = [];
  3990. for (var i = start; i < start + length; i++) {
  3991. rows.push(this.getRow(i));
  3992. }
  3993. return rows;
  3994. }
  3995. }, {
  3996. key: "addRow",
  3997. value: function addRow(value) {
  3998. var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'n';
  3999. var rowNo = this._nextRow;
  4000. var row = this.getRow(rowNo);
  4001. row.values = value;
  4002. this._setStyleOption(rowNo, style[0] === 'i' ? style : 'n');
  4003. return row;
  4004. }
  4005. }, {
  4006. key: "addRows",
  4007. value: function addRows(value) {
  4008. var _this2 = this;
  4009. var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'n';
  4010. var rows = [];
  4011. value.forEach(function (row) {
  4012. rows.push(_this2.addRow(row, style));
  4013. });
  4014. return rows;
  4015. }
  4016. }, {
  4017. key: "insertRow",
  4018. value: function insertRow(pos, value) {
  4019. var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n';
  4020. this.spliceRows(pos, 0, value);
  4021. this._setStyleOption(pos, style);
  4022. return this.getRow(pos);
  4023. }
  4024. }, {
  4025. key: "insertRows",
  4026. value: function insertRows(pos, values) {
  4027. var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n';
  4028. this.spliceRows.apply(this, [pos, 0].concat(_toConsumableArray(values)));
  4029. if (style !== 'n') {
  4030. // copy over the styles
  4031. for (var i = 0; i < values.length; i++) {
  4032. if (style[0] === 'o' && this.findRow(values.length + pos + i) !== undefined) {
  4033. this._copyStyle(values.length + pos + i, pos + i, style[1] === '+');
  4034. } else if (style[0] === 'i' && this.findRow(pos - 1) !== undefined) {
  4035. this._copyStyle(pos - 1, pos + i, style[1] === '+');
  4036. }
  4037. }
  4038. }
  4039. return this.getRows(pos, values.length);
  4040. } // set row at position to same style as of either pervious row (option 'i') or next row (option 'o')
  4041. }, {
  4042. key: "_setStyleOption",
  4043. value: function _setStyleOption(pos) {
  4044. var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'n';
  4045. if (style[0] === 'o' && this.findRow(pos + 1) !== undefined) {
  4046. this._copyStyle(pos + 1, pos, style[1] === '+');
  4047. } else if (style[0] === 'i' && this.findRow(pos - 1) !== undefined) {
  4048. this._copyStyle(pos - 1, pos, style[1] === '+');
  4049. }
  4050. }
  4051. }, {
  4052. key: "_copyStyle",
  4053. value: function _copyStyle(src, dest) {
  4054. var styleEmpty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4055. var rSrc = this.getRow(src);
  4056. var rDst = this.getRow(dest);
  4057. rDst.style = Object.freeze(_objectSpread({}, rSrc.style)); // eslint-disable-next-line no-loop-func
  4058. rSrc.eachCell({
  4059. includeEmpty: styleEmpty
  4060. }, function (cell, colNumber) {
  4061. rDst.getCell(colNumber).style = Object.freeze(_objectSpread({}, cell.style));
  4062. });
  4063. rDst.height = rSrc.height;
  4064. }
  4065. }, {
  4066. key: "duplicateRow",
  4067. value: function duplicateRow(rowNum, count) {
  4068. var _this3 = this;
  4069. var insert = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4070. // create count duplicates of rowNum
  4071. // either inserting new or overwriting existing rows
  4072. var rSrc = this._rows[rowNum - 1];
  4073. var inserts = new Array(count).fill(rSrc.values);
  4074. this.spliceRows.apply(this, [rowNum + 1, insert ? 0 : count].concat(_toConsumableArray(inserts))); // now copy styles...
  4075. var _loop2 = function _loop2(i) {
  4076. var rDst = _this3._rows[rowNum + i];
  4077. rDst.style = rSrc.style;
  4078. rDst.height = rSrc.height; // eslint-disable-next-line no-loop-func
  4079. rSrc.eachCell({
  4080. includeEmpty: true
  4081. }, function (cell, colNumber) {
  4082. rDst.getCell(colNumber).style = cell.style;
  4083. });
  4084. };
  4085. for (var i = 0; i < count; i++) {
  4086. _loop2(i);
  4087. }
  4088. }
  4089. }, {
  4090. key: "spliceRows",
  4091. value: function spliceRows(start, count) {
  4092. var _this4 = this;
  4093. // same problem as row.splice, except worse.
  4094. var nKeep = start + count;
  4095. for (var _len2 = arguments.length, inserts = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  4096. inserts[_key2 - 2] = arguments[_key2];
  4097. }
  4098. var nInserts = inserts.length;
  4099. var nExpand = nInserts - count;
  4100. var nEnd = this._rows.length;
  4101. var i;
  4102. var rSrc;
  4103. if (nExpand < 0) {
  4104. // remove rows
  4105. for (i = nKeep; i <= nEnd; i++) {
  4106. rSrc = this._rows[i - 1];
  4107. if (rSrc) {
  4108. (function () {
  4109. var rDst = _this4.getRow(i + nExpand);
  4110. rDst.values = rSrc.values;
  4111. rDst.style = rSrc.style;
  4112. rDst.height = rSrc.height; // eslint-disable-next-line no-loop-func
  4113. rSrc.eachCell({
  4114. includeEmpty: true
  4115. }, function (cell, colNumber) {
  4116. rDst.getCell(colNumber).style = cell.style;
  4117. });
  4118. _this4._rows[i - 1] = undefined;
  4119. })();
  4120. } else {
  4121. this._rows[i + nExpand - 1] = undefined;
  4122. }
  4123. }
  4124. } else if (nExpand > 0) {
  4125. // insert new cells
  4126. for (i = nEnd; i >= nKeep; i--) {
  4127. rSrc = this._rows[i - 1];
  4128. if (rSrc) {
  4129. (function () {
  4130. var rDst = _this4.getRow(i + nExpand);
  4131. rDst.values = rSrc.values;
  4132. rDst.style = rSrc.style;
  4133. rDst.height = rSrc.height; // eslint-disable-next-line no-loop-func
  4134. rSrc.eachCell({
  4135. includeEmpty: true
  4136. }, function (cell, colNumber) {
  4137. rDst.getCell(colNumber).style = cell.style; // remerge cells accounting for insert offset
  4138. if (cell._value.constructor.name === 'MergeValue') {
  4139. var cellToBeMerged = _this4.getRow(cell._row._number + nInserts).getCell(colNumber);
  4140. var prevMaster = cell._value._master;
  4141. var newMaster = _this4.getRow(prevMaster._row._number + nInserts).getCell(prevMaster._column._number);
  4142. cellToBeMerged.merge(newMaster);
  4143. }
  4144. });
  4145. })();
  4146. } else {
  4147. this._rows[i + nExpand - 1] = undefined;
  4148. }
  4149. }
  4150. } // now copy over the new values
  4151. for (i = 0; i < nInserts; i++) {
  4152. var rDst = this.getRow(start + i);
  4153. rDst.style = {};
  4154. rDst.values = inserts[i];
  4155. } // account for defined names
  4156. this.workbook.definedNames.spliceRows(this.name, start, count, nInserts);
  4157. } // iterate over every row in the worksheet, including maybe empty rows
  4158. }, {
  4159. key: "eachRow",
  4160. value: function eachRow(options, iteratee) {
  4161. if (!iteratee) {
  4162. iteratee = options;
  4163. options = undefined;
  4164. }
  4165. if (options && options.includeEmpty) {
  4166. var n = this._rows.length;
  4167. for (var i = 1; i <= n; i++) {
  4168. iteratee(this.getRow(i), i);
  4169. }
  4170. } else {
  4171. this._rows.forEach(function (row) {
  4172. if (row && row.hasValues) {
  4173. iteratee(row, row.number);
  4174. }
  4175. });
  4176. }
  4177. } // return all rows as sparse array
  4178. }, {
  4179. key: "getSheetValues",
  4180. value: function getSheetValues() {
  4181. var rows = [];
  4182. this._rows.forEach(function (row) {
  4183. if (row) {
  4184. rows[row.number] = row.values;
  4185. }
  4186. });
  4187. return rows;
  4188. } // =========================================================================
  4189. // Cells
  4190. // returns the cell at [r,c] or address given by r. If not found, return undefined
  4191. }, {
  4192. key: "findCell",
  4193. value: function findCell(r, c) {
  4194. var address = colCache.getAddress(r, c);
  4195. var row = this._rows[address.row - 1];
  4196. return row ? row.findCell(address.col) : undefined;
  4197. } // return the cell at [r,c] or address given by r. If not found, create a new one.
  4198. }, {
  4199. key: "getCell",
  4200. value: function getCell(r, c) {
  4201. var address = colCache.getAddress(r, c);
  4202. var row = this.getRow(address.row);
  4203. return row.getCellEx(address);
  4204. } // =========================================================================
  4205. // Merge
  4206. // convert the range defined by ['tl:br'], [tl,br] or [t,l,b,r] into a single 'merged' cell
  4207. }, {
  4208. key: "mergeCells",
  4209. value: function mergeCells() {
  4210. for (var _len3 = arguments.length, cells = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  4211. cells[_key3] = arguments[_key3];
  4212. }
  4213. var dimensions = new Range(cells);
  4214. this._mergeCellsInternal(dimensions);
  4215. }
  4216. }, {
  4217. key: "mergeCellsWithoutStyle",
  4218. value: function mergeCellsWithoutStyle() {
  4219. for (var _len4 = arguments.length, cells = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  4220. cells[_key4] = arguments[_key4];
  4221. }
  4222. var dimensions = new Range(cells);
  4223. this._mergeCellsInternal(dimensions, true);
  4224. }
  4225. }, {
  4226. key: "_mergeCellsInternal",
  4227. value: function _mergeCellsInternal(dimensions, ignoreStyle) {
  4228. // check cells aren't already merged
  4229. _.each(this._merges, function (merge) {
  4230. if (merge.intersects(dimensions)) {
  4231. throw new Error('Cannot merge already merged cells');
  4232. }
  4233. }); // apply merge
  4234. var master = this.getCell(dimensions.top, dimensions.left);
  4235. for (var i = dimensions.top; i <= dimensions.bottom; i++) {
  4236. for (var j = dimensions.left; j <= dimensions.right; j++) {
  4237. // merge all but the master cell
  4238. if (i > dimensions.top || j > dimensions.left) {
  4239. this.getCell(i, j).merge(master, ignoreStyle);
  4240. }
  4241. }
  4242. } // index merge
  4243. this._merges[master.address] = dimensions;
  4244. }
  4245. }, {
  4246. key: "_unMergeMaster",
  4247. value: function _unMergeMaster(master) {
  4248. // master is always top left of a rectangle
  4249. var merge = this._merges[master.address];
  4250. if (merge) {
  4251. for (var i = merge.top; i <= merge.bottom; i++) {
  4252. for (var j = merge.left; j <= merge.right; j++) {
  4253. this.getCell(i, j).unmerge();
  4254. }
  4255. }
  4256. delete this._merges[master.address];
  4257. }
  4258. }
  4259. }, {
  4260. key: "unMergeCells",
  4261. // scan the range defined by ['tl:br'], [tl,br] or [t,l,b,r] and if any cell is part of a merge,
  4262. // un-merge the group. Note this function can affect multiple merges and merge-blocks are
  4263. // atomic - either they're all merged or all un-merged.
  4264. value: function unMergeCells() {
  4265. for (var _len5 = arguments.length, cells = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  4266. cells[_key5] = arguments[_key5];
  4267. }
  4268. var dimensions = new Range(cells); // find any cells in that range and unmerge them
  4269. for (var i = dimensions.top; i <= dimensions.bottom; i++) {
  4270. for (var j = dimensions.left; j <= dimensions.right; j++) {
  4271. var cell = this.findCell(i, j);
  4272. if (cell) {
  4273. if (cell.type === Enums.ValueType.Merge) {
  4274. // this cell merges to another master
  4275. this._unMergeMaster(cell.master);
  4276. } else if (this._merges[cell.address]) {
  4277. // this cell is a master
  4278. this._unMergeMaster(cell);
  4279. }
  4280. }
  4281. }
  4282. }
  4283. } // ===========================================================================
  4284. // Shared/Array Formula
  4285. }, {
  4286. key: "fillFormula",
  4287. value: function fillFormula(range, formula, results) {
  4288. var shareType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'shared';
  4289. // Define formula for top-left cell and share to rest
  4290. var decoded = colCache.decode(range);
  4291. var top = decoded.top,
  4292. left = decoded.left,
  4293. bottom = decoded.bottom,
  4294. right = decoded.right;
  4295. var width = right - left + 1;
  4296. var masterAddress = colCache.encodeAddress(top, left);
  4297. var isShared = shareType === 'shared'; // work out result accessor
  4298. var getResult;
  4299. if (typeof results === 'function') {
  4300. getResult = results;
  4301. } else if (Array.isArray(results)) {
  4302. if (Array.isArray(results[0])) {
  4303. getResult = function getResult(row, col) {
  4304. return results[row - top][col - left];
  4305. };
  4306. } else {
  4307. // eslint-disable-next-line no-mixed-operators
  4308. getResult = function getResult(row, col) {
  4309. return results[(row - top) * width + (col - left)];
  4310. };
  4311. }
  4312. } else {
  4313. getResult = function getResult() {
  4314. return undefined;
  4315. };
  4316. }
  4317. var first = true;
  4318. for (var r = top; r <= bottom; r++) {
  4319. for (var c = left; c <= right; c++) {
  4320. if (first) {
  4321. this.getCell(r, c).value = {
  4322. shareType: shareType,
  4323. formula: formula,
  4324. ref: range,
  4325. result: getResult(r, c)
  4326. };
  4327. first = false;
  4328. } else {
  4329. this.getCell(r, c).value = isShared ? {
  4330. sharedFormula: masterAddress,
  4331. result: getResult(r, c)
  4332. } : getResult(r, c);
  4333. }
  4334. }
  4335. }
  4336. } // =========================================================================
  4337. // Images
  4338. }, {
  4339. key: "addImage",
  4340. value: function addImage(imageId, range) {
  4341. var model = {
  4342. type: 'image',
  4343. imageId: imageId,
  4344. range: range
  4345. };
  4346. this._media.push(new Image(this, model));
  4347. }
  4348. }, {
  4349. key: "getImages",
  4350. value: function getImages() {
  4351. return this._media.filter(function (m) {
  4352. return m.type === 'image';
  4353. });
  4354. }
  4355. }, {
  4356. key: "addBackgroundImage",
  4357. value: function addBackgroundImage(imageId) {
  4358. var model = {
  4359. type: 'background',
  4360. imageId: imageId
  4361. };
  4362. this._media.push(new Image(this, model));
  4363. }
  4364. }, {
  4365. key: "getBackgroundImageId",
  4366. value: function getBackgroundImageId() {
  4367. var image = this._media.find(function (m) {
  4368. return m.type === 'background';
  4369. });
  4370. return image && image.imageId;
  4371. } // =========================================================================
  4372. // Worksheet Protection
  4373. }, {
  4374. key: "protect",
  4375. value: function protect(password, options) {
  4376. var _this5 = this;
  4377. // TODO: make this function truly async
  4378. // perhaps marshal to worker thread or something
  4379. return new Promise(function (resolve) {
  4380. _this5.sheetProtection = {
  4381. sheet: true
  4382. };
  4383. if (options && 'spinCount' in options) {
  4384. // force spinCount to be integer >= 0
  4385. options.spinCount = Number.isFinite(options.spinCount) ? Math.round(Math.max(0, options.spinCount)) : 100000;
  4386. }
  4387. if (password) {
  4388. _this5.sheetProtection.algorithmName = 'SHA-512';
  4389. _this5.sheetProtection.saltValue = Encryptor.randomBytes(16).toString('base64');
  4390. _this5.sheetProtection.spinCount = options && 'spinCount' in options ? options.spinCount : 100000; // allow user specified spinCount
  4391. _this5.sheetProtection.hashValue = Encryptor.convertPasswordToHash(password, 'SHA512', _this5.sheetProtection.saltValue, _this5.sheetProtection.spinCount);
  4392. }
  4393. if (options) {
  4394. _this5.sheetProtection = Object.assign(_this5.sheetProtection, options);
  4395. if (!password && 'spinCount' in options) {
  4396. delete _this5.sheetProtection.spinCount;
  4397. }
  4398. }
  4399. resolve();
  4400. });
  4401. }
  4402. }, {
  4403. key: "unprotect",
  4404. value: function unprotect() {
  4405. this.sheetProtection = null;
  4406. } // =========================================================================
  4407. // Tables
  4408. }, {
  4409. key: "addTable",
  4410. value: function addTable(model) {
  4411. var table = new Table(this, model);
  4412. this.tables[model.name] = table;
  4413. return table;
  4414. }
  4415. }, {
  4416. key: "getTable",
  4417. value: function getTable(name) {
  4418. return this.tables[name];
  4419. }
  4420. }, {
  4421. key: "removeTable",
  4422. value: function removeTable(name) {
  4423. delete this.tables[name];
  4424. }
  4425. }, {
  4426. key: "getTables",
  4427. value: function getTables() {
  4428. return Object.values(this.tables);
  4429. } // ===========================================================================
  4430. // Conditional Formatting
  4431. }, {
  4432. key: "addConditionalFormatting",
  4433. value: function addConditionalFormatting(cf) {
  4434. this.conditionalFormattings.push(cf);
  4435. }
  4436. }, {
  4437. key: "removeConditionalFormatting",
  4438. value: function removeConditionalFormatting(filter) {
  4439. if (typeof filter === 'number') {
  4440. this.conditionalFormattings.splice(filter, 1);
  4441. } else if (filter instanceof Function) {
  4442. this.conditionalFormattings = this.conditionalFormattings.filter(filter);
  4443. } else {
  4444. this.conditionalFormattings = [];
  4445. }
  4446. } // ===========================================================================
  4447. // Deprecated
  4448. }, {
  4449. key: "_parseRows",
  4450. value: function _parseRows(model) {
  4451. var _this6 = this;
  4452. this._rows = [];
  4453. model.rows.forEach(function (rowModel) {
  4454. var row = new Row(_this6, rowModel.number);
  4455. _this6._rows[row.number - 1] = row;
  4456. row.model = rowModel;
  4457. });
  4458. }
  4459. }, {
  4460. key: "_parseMergeCells",
  4461. value: function _parseMergeCells(model) {
  4462. var _this7 = this;
  4463. _.each(model.mergeCells, function (merge) {
  4464. // Do not merge styles when importing an Excel file
  4465. // since each cell may have different styles intentionally.
  4466. _this7.mergeCellsWithoutStyle(merge);
  4467. });
  4468. }
  4469. }, {
  4470. key: "workbook",
  4471. get: function get() {
  4472. return this._workbook;
  4473. }
  4474. }, {
  4475. key: "dimensions",
  4476. get: function get() {
  4477. var dimensions = new Range();
  4478. this._rows.forEach(function (row) {
  4479. if (row) {
  4480. var rowDims = row.dimensions;
  4481. if (rowDims) {
  4482. dimensions.expand(row.number, rowDims.min, row.number, rowDims.max);
  4483. }
  4484. }
  4485. });
  4486. return dimensions;
  4487. } // =========================================================================
  4488. // Columns
  4489. // get the current columns array.
  4490. }, {
  4491. key: "columns",
  4492. get: function get() {
  4493. return this._columns;
  4494. } // set the columns from an array of column definitions.
  4495. // Note: any headers defined will overwrite existing values.
  4496. ,
  4497. set: function set(value) {
  4498. var _this8 = this;
  4499. // calculate max header row count
  4500. this._headerRowCount = value.reduce(function (pv, cv) {
  4501. var headerCount = cv.header && 1 || cv.headers && cv.headers.length || 0;
  4502. return Math.max(pv, headerCount);
  4503. }, 0); // construct Column objects
  4504. var count = 1;
  4505. var columns = this._columns = [];
  4506. value.forEach(function (defn) {
  4507. var column = new Column(_this8, count++, false);
  4508. columns.push(column);
  4509. column.defn = defn;
  4510. });
  4511. }
  4512. }, {
  4513. key: "lastColumn",
  4514. get: function get() {
  4515. return this.getColumn(this.columnCount);
  4516. }
  4517. }, {
  4518. key: "columnCount",
  4519. get: function get() {
  4520. var maxCount = 0;
  4521. this.eachRow(function (row) {
  4522. maxCount = Math.max(maxCount, row.cellCount);
  4523. });
  4524. return maxCount;
  4525. }
  4526. }, {
  4527. key: "actualColumnCount",
  4528. get: function get() {
  4529. // performance nightmare - for each row, counts all the columns used
  4530. var counts = [];
  4531. var count = 0;
  4532. this.eachRow(function (row) {
  4533. row.eachCell(function (_ref) {
  4534. var col = _ref.col;
  4535. if (!counts[col]) {
  4536. counts[col] = true;
  4537. count++;
  4538. }
  4539. });
  4540. });
  4541. return count;
  4542. }
  4543. }, {
  4544. key: "_lastRowNumber",
  4545. get: function get() {
  4546. // need to cope with results of splice
  4547. var rows = this._rows;
  4548. var n = rows.length;
  4549. while (n > 0 && rows[n - 1] === undefined) {
  4550. n--;
  4551. }
  4552. return n;
  4553. }
  4554. }, {
  4555. key: "_nextRow",
  4556. get: function get() {
  4557. return this._lastRowNumber + 1;
  4558. }
  4559. }, {
  4560. key: "lastRow",
  4561. get: function get() {
  4562. if (this._rows.length) {
  4563. return this._rows[this._rows.length - 1];
  4564. }
  4565. return undefined;
  4566. }
  4567. }, {
  4568. key: "rowCount",
  4569. get: function get() {
  4570. return this._lastRowNumber;
  4571. }
  4572. }, {
  4573. key: "actualRowCount",
  4574. get: function get() {
  4575. // counts actual rows that have actual data
  4576. var count = 0;
  4577. this.eachRow(function () {
  4578. count++;
  4579. });
  4580. return count;
  4581. }
  4582. }, {
  4583. key: "hasMerges",
  4584. get: function get() {
  4585. // return true if this._merges has a merge object
  4586. return _.some(this._merges, Boolean);
  4587. }
  4588. }, {
  4589. key: "tabColor",
  4590. get: function get() {
  4591. // eslint-disable-next-line no-console
  4592. console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor');
  4593. return this.properties.tabColor;
  4594. },
  4595. set: function set(value) {
  4596. // eslint-disable-next-line no-console
  4597. console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor');
  4598. this.properties.tabColor = value;
  4599. } // ===========================================================================
  4600. // Model
  4601. }, {
  4602. key: "model",
  4603. get: function get() {
  4604. var model = {
  4605. id: this.id,
  4606. name: this.name,
  4607. dataValidations: this.dataValidations.model,
  4608. properties: this.properties,
  4609. state: this.state,
  4610. pageSetup: this.pageSetup,
  4611. headerFooter: this.headerFooter,
  4612. rowBreaks: this.rowBreaks,
  4613. views: this.views,
  4614. autoFilter: this.autoFilter,
  4615. media: this._media.map(function (medium) {
  4616. return medium.model;
  4617. }),
  4618. sheetProtection: this.sheetProtection,
  4619. tables: Object.values(this.tables).map(function (table) {
  4620. return table.model;
  4621. }),
  4622. conditionalFormattings: this.conditionalFormattings
  4623. }; // =================================================
  4624. // columns
  4625. model.cols = Column.toModel(this.columns); // ==========================================================
  4626. // Rows
  4627. var rows = model.rows = [];
  4628. var dimensions = model.dimensions = new Range();
  4629. this._rows.forEach(function (row) {
  4630. var rowModel = row && row.model;
  4631. if (rowModel) {
  4632. dimensions.expand(rowModel.number, rowModel.min, rowModel.number, rowModel.max);
  4633. rows.push(rowModel);
  4634. }
  4635. }); // ==========================================================
  4636. // Merges
  4637. model.merges = [];
  4638. _.each(this._merges, function (merge) {
  4639. model.merges.push(merge.range);
  4640. });
  4641. return model;
  4642. },
  4643. set: function set(value) {
  4644. var _this9 = this;
  4645. this.name = value.name;
  4646. this._columns = Column.fromModel(this, value.cols);
  4647. this._parseRows(value);
  4648. this._parseMergeCells(value);
  4649. this.dataValidations = new DataValidations(value.dataValidations);
  4650. this.properties = value.properties;
  4651. this.pageSetup = value.pageSetup;
  4652. this.headerFooter = value.headerFooter;
  4653. this.views = value.views;
  4654. this.autoFilter = value.autoFilter;
  4655. this._media = value.media.map(function (medium) {
  4656. return new Image(_this9, medium);
  4657. });
  4658. this.sheetProtection = value.sheetProtection;
  4659. this.tables = value.tables.reduce(function (tables, table) {
  4660. var t = new Table();
  4661. t.model = table;
  4662. tables[table.name] = t;
  4663. return tables;
  4664. }, {});
  4665. this.conditionalFormattings = value.conditionalFormattings;
  4666. }
  4667. }]);
  4668. return Worksheet;
  4669. }();
  4670. module.exports = Worksheet;
  4671. }, { "../utils/col-cache": 19, "../utils/encryptor": 20, "../utils/under-dash": 25, "./column": 4, "./data-validations": 5, "./enums": 7, "./image": 8, "./range": 10, "./row": 11, "./table": 12 }], 15: [function (require, module, exports) {
  4672. "use strict";
  4673. /* eslint-disable import/no-extraneous-dependencies,node/no-unpublished-require */
  4674. require('core-js/modules/es.promise');
  4675. require('core-js/modules/es.object.assign');
  4676. require('core-js/modules/es.object.keys');
  4677. require('core-js/modules/es.object.values');
  4678. require('core-js/modules/es.symbol');
  4679. require('core-js/modules/es.symbol.async-iterator'); // required by core-js/modules/es.promise Promise.all
  4680. require('core-js/modules/es.array.iterator'); // required by node_modules/saxes/saxes.js SaxesParser.captureTo
  4681. require('core-js/modules/es.array.includes'); // required by lib/doc/workbook.js Workbook.model
  4682. require('core-js/modules/es.array.find-index'); // required by lib/doc/workbook.js Workbook.addWorksheet and Workbook.getWorksheet
  4683. require('core-js/modules/es.array.find'); // required by node_modules/saxes/saxes.js SaxesParser.getCode10
  4684. require('core-js/modules/es.string.from-code-point'); // required by lib/xlsx/xform/sheet/data-validations-xform.js DataValidationsXform.parseClose
  4685. require('core-js/modules/es.string.includes'); // required by lib/utils/utils.js utils.validInt and lib/csv/csv.js CSV.read
  4686. require('core-js/modules/es.number.is-nan');
  4687. require('regenerator-runtime/runtime');
  4688. var ExcelJS = {
  4689. Workbook: require('./doc/workbook')
  4690. }; // Object.assign mono-fill
  4691. var Enums = require('./doc/enums');
  4692. Object.keys(Enums).forEach(function (key) {
  4693. ExcelJS[key] = Enums[key];
  4694. });
  4695. module.exports = ExcelJS;
  4696. }, { "./doc/enums": 7, "./doc/workbook": 13, "core-js/modules/es.array.find": 316, "core-js/modules/es.array.find-index": 315, "core-js/modules/es.array.includes": 317, "core-js/modules/es.array.iterator": 318, "core-js/modules/es.number.is-nan": 319, "core-js/modules/es.object.assign": 320, "core-js/modules/es.object.keys": 321, "core-js/modules/es.object.values": 322, "core-js/modules/es.promise": 323, "core-js/modules/es.string.from-code-point": 324, "core-js/modules/es.string.includes": 325, "core-js/modules/es.symbol": 327, "core-js/modules/es.symbol.async-iterator": 326, "regenerator-runtime/runtime": 492 }], 16: [function (require, module, exports) {
  4697. "use strict";
  4698. // eslint-disable-next-line node/no-unsupported-features/node-builtins
  4699. var textDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf-8');
  4700. function bufferToString(chunk) {
  4701. if (typeof chunk === 'string') {
  4702. return chunk;
  4703. }
  4704. if (textDecoder) {
  4705. return textDecoder.decode(chunk);
  4706. }
  4707. return chunk.toString();
  4708. }
  4709. exports.bufferToString = bufferToString;
  4710. }, {}], 17: [function (require, module, exports) {
  4711. "use strict";
  4712. // eslint-disable-next-line node/no-unsupported-features/node-builtins
  4713. var textEncoder = typeof TextEncoder === 'undefined' ? null : new TextEncoder('utf-8');
  4714. var _require = require('buffer'),
  4715. Buffer = _require.Buffer;
  4716. function stringToBuffer(str) {
  4717. if (typeof str !== 'string') {
  4718. return str;
  4719. }
  4720. if (textEncoder) {
  4721. return Buffer.from(textEncoder.encode(str).buffer);
  4722. }
  4723. return Buffer.from(str);
  4724. }
  4725. exports.stringToBuffer = stringToBuffer;
  4726. }, { "buffer": 216 }], 18: [function (require, module, exports) {
  4727. "use strict";
  4728. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4729. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4730. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4731. var _ = require('./under-dash');
  4732. var colCache = require('./col-cache');
  4733. var CellMatrix = /*#__PURE__*/function () {
  4734. function CellMatrix(template) {
  4735. _classCallCheck(this, CellMatrix);
  4736. this.template = template;
  4737. this.sheets = {};
  4738. }
  4739. _createClass(CellMatrix, [{
  4740. key: "addCell",
  4741. value: function addCell(addressStr) {
  4742. this.addCellEx(colCache.decodeEx(addressStr));
  4743. }
  4744. }, {
  4745. key: "getCell",
  4746. value: function getCell(addressStr) {
  4747. return this.findCellEx(colCache.decodeEx(addressStr), true);
  4748. }
  4749. }, {
  4750. key: "findCell",
  4751. value: function findCell(addressStr) {
  4752. return this.findCellEx(colCache.decodeEx(addressStr), false);
  4753. }
  4754. }, {
  4755. key: "findCellAt",
  4756. value: function findCellAt(sheetName, rowNumber, colNumber) {
  4757. var sheet = this.sheets[sheetName];
  4758. var row = sheet && sheet[rowNumber];
  4759. return row && row[colNumber];
  4760. }
  4761. }, {
  4762. key: "addCellEx",
  4763. value: function addCellEx(address) {
  4764. if (address.top) {
  4765. for (var row = address.top; row <= address.bottom; row++) {
  4766. for (var col = address.left; col <= address.right; col++) {
  4767. this.getCellAt(address.sheetName, row, col);
  4768. }
  4769. }
  4770. } else {
  4771. this.findCellEx(address, true);
  4772. }
  4773. }
  4774. }, {
  4775. key: "getCellEx",
  4776. value: function getCellEx(address) {
  4777. return this.findCellEx(address, true);
  4778. }
  4779. }, {
  4780. key: "findCellEx",
  4781. value: function findCellEx(address, create) {
  4782. var sheet = this.findSheet(address, create);
  4783. var row = this.findSheetRow(sheet, address, create);
  4784. return this.findRowCell(row, address, create);
  4785. }
  4786. }, {
  4787. key: "getCellAt",
  4788. value: function getCellAt(sheetName, rowNumber, colNumber) {
  4789. var sheet = this.sheets[sheetName] || (this.sheets[sheetName] = []);
  4790. var row = sheet[rowNumber] || (sheet[rowNumber] = []);
  4791. var cell = row[colNumber] || (row[colNumber] = {
  4792. sheetName: sheetName,
  4793. address: colCache.n2l(colNumber) + rowNumber,
  4794. row: rowNumber,
  4795. col: colNumber
  4796. });
  4797. return cell;
  4798. }
  4799. }, {
  4800. key: "removeCellEx",
  4801. value: function removeCellEx(address) {
  4802. var sheet = this.findSheet(address);
  4803. if (!sheet) {
  4804. return;
  4805. }
  4806. var row = this.findSheetRow(sheet, address);
  4807. if (!row) {
  4808. return;
  4809. }
  4810. delete row[address.col];
  4811. }
  4812. }, {
  4813. key: "forEachInSheet",
  4814. value: function forEachInSheet(sheetName, callback) {
  4815. var sheet = this.sheets[sheetName];
  4816. if (sheet) {
  4817. sheet.forEach(function (row, rowNumber) {
  4818. if (row) {
  4819. row.forEach(function (cell, colNumber) {
  4820. if (cell) {
  4821. callback(cell, rowNumber, colNumber);
  4822. }
  4823. });
  4824. }
  4825. });
  4826. }
  4827. }
  4828. }, {
  4829. key: "forEach",
  4830. value: function forEach(callback) {
  4831. var _this = this;
  4832. _.each(this.sheets, function (sheet, sheetName) {
  4833. _this.forEachInSheet(sheetName, callback);
  4834. });
  4835. }
  4836. }, {
  4837. key: "map",
  4838. value: function map(callback) {
  4839. var results = [];
  4840. this.forEach(function (cell) {
  4841. results.push(callback(cell));
  4842. });
  4843. return results;
  4844. }
  4845. }, {
  4846. key: "findSheet",
  4847. value: function findSheet(address, create) {
  4848. var name = address.sheetName;
  4849. if (this.sheets[name]) {
  4850. return this.sheets[name];
  4851. }
  4852. if (create) {
  4853. return this.sheets[name] = [];
  4854. }
  4855. return undefined;
  4856. }
  4857. }, {
  4858. key: "findSheetRow",
  4859. value: function findSheetRow(sheet, address, create) {
  4860. var row = address.row;
  4861. if (sheet && sheet[row]) {
  4862. return sheet[row];
  4863. }
  4864. if (create) {
  4865. return sheet[row] = [];
  4866. }
  4867. return undefined;
  4868. }
  4869. }, {
  4870. key: "findRowCell",
  4871. value: function findRowCell(row, address, create) {
  4872. var col = address.col;
  4873. if (row && row[col]) {
  4874. return row[col];
  4875. }
  4876. if (create) {
  4877. return row[col] = this.template ? Object.assign(address, JSON.parse(JSON.stringify(this.template))) : address;
  4878. }
  4879. return undefined;
  4880. }
  4881. }, {
  4882. key: "spliceRows",
  4883. value: function spliceRows(sheetName, start, numDelete, numInsert) {
  4884. var sheet = this.sheets[sheetName];
  4885. if (sheet) {
  4886. var inserts = [];
  4887. for (var i = 0; i < numInsert; i++) {
  4888. inserts.push([]);
  4889. }
  4890. sheet.splice.apply(sheet, [start, numDelete].concat(inserts));
  4891. }
  4892. }
  4893. }, {
  4894. key: "spliceColumns",
  4895. value: function spliceColumns(sheetName, start, numDelete, numInsert) {
  4896. var sheet = this.sheets[sheetName];
  4897. if (sheet) {
  4898. var inserts = [];
  4899. for (var i = 0; i < numInsert; i++) {
  4900. inserts.push(null);
  4901. }
  4902. _.each(sheet, function (row) {
  4903. row.splice.apply(row, [start, numDelete].concat(inserts));
  4904. });
  4905. }
  4906. }
  4907. }]);
  4908. return CellMatrix;
  4909. }();
  4910. module.exports = CellMatrix;
  4911. }, { "./col-cache": 19, "./under-dash": 25 }], 19: [function (require, module, exports) {
  4912. "use strict";
  4913. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  4914. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  4915. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  4916. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  4917. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  4918. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4919. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  4920. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  4921. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  4922. var addressRegex = /^[A-Z]+\d+$/; // =========================================================================
  4923. // Column Letter to Number conversion
  4924. var colCache = {
  4925. _dictionary: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
  4926. _l2nFill: 0,
  4927. _l2n: {},
  4928. _n2l: [],
  4929. _level: function _level(n) {
  4930. if (n <= 26) {
  4931. return 1;
  4932. }
  4933. if (n <= 26 * 26) {
  4934. return 2;
  4935. }
  4936. return 3;
  4937. },
  4938. _fill: function _fill(level) {
  4939. var c;
  4940. var v;
  4941. var l1;
  4942. var l2;
  4943. var l3;
  4944. var n = 1;
  4945. if (level >= 4) {
  4946. throw new Error('Out of bounds. Excel supports columns from 1 to 16384');
  4947. }
  4948. if (this._l2nFill < 1 && level >= 1) {
  4949. while (n <= 26) {
  4950. c = this._dictionary[n - 1];
  4951. this._n2l[n] = c;
  4952. this._l2n[c] = n;
  4953. n++;
  4954. }
  4955. this._l2nFill = 1;
  4956. }
  4957. if (this._l2nFill < 2 && level >= 2) {
  4958. n = 27;
  4959. while (n <= 26 + 26 * 26) {
  4960. v = n - (26 + 1);
  4961. l1 = v % 26;
  4962. l2 = Math.floor(v / 26);
  4963. c = this._dictionary[l2] + this._dictionary[l1];
  4964. this._n2l[n] = c;
  4965. this._l2n[c] = n;
  4966. n++;
  4967. }
  4968. this._l2nFill = 2;
  4969. }
  4970. if (this._l2nFill < 3 && level >= 3) {
  4971. n = 26 + 26 * 26 + 1;
  4972. while (n <= 16384) {
  4973. v = n - (26 * 26 + 26 + 1);
  4974. l1 = v % 26;
  4975. l2 = Math.floor(v / 26) % 26;
  4976. l3 = Math.floor(v / (26 * 26));
  4977. c = this._dictionary[l3] + this._dictionary[l2] + this._dictionary[l1];
  4978. this._n2l[n] = c;
  4979. this._l2n[c] = n;
  4980. n++;
  4981. }
  4982. this._l2nFill = 3;
  4983. }
  4984. },
  4985. l2n: function l2n(l) {
  4986. if (!this._l2n[l]) {
  4987. this._fill(l.length);
  4988. }
  4989. if (!this._l2n[l]) {
  4990. throw new Error("Out of bounds. Invalid column letter: ".concat(l));
  4991. }
  4992. return this._l2n[l];
  4993. },
  4994. n2l: function n2l(n) {
  4995. if (n < 1 || n > 16384) {
  4996. throw new Error("".concat(n, " is out of bounds. Excel supports columns from 1 to 16384"));
  4997. }
  4998. if (!this._n2l[n]) {
  4999. this._fill(this._level(n));
  5000. }
  5001. return this._n2l[n];
  5002. },
  5003. // =========================================================================
  5004. // Address processing
  5005. _hash: {},
  5006. // check if value looks like an address
  5007. validateAddress: function validateAddress(value) {
  5008. if (!addressRegex.test(value)) {
  5009. throw new Error("Invalid Address: ".concat(value));
  5010. }
  5011. return true;
  5012. },
  5013. // convert address string into structure
  5014. decodeAddress: function decodeAddress(value) {
  5015. var addr = value.length < 5 && this._hash[value];
  5016. if (addr) {
  5017. return addr;
  5018. }
  5019. var hasCol = false;
  5020. var col = '';
  5021. var colNumber = 0;
  5022. var hasRow = false;
  5023. var row = '';
  5024. var rowNumber = 0;
  5025. for (var i = 0, char; i < value.length; i++) {
  5026. char = value.charCodeAt(i); // col should before row
  5027. if (!hasRow && char >= 65 && char <= 90) {
  5028. // 65 = 'A'.charCodeAt(0)
  5029. // 90 = 'Z'.charCodeAt(0)
  5030. hasCol = true;
  5031. col += value[i]; // colNumber starts from 1
  5032. colNumber = colNumber * 26 + char - 64;
  5033. } else if (char >= 48 && char <= 57) {
  5034. // 48 = '0'.charCodeAt(0)
  5035. // 57 = '9'.charCodeAt(0)
  5036. hasRow = true;
  5037. row += value[i]; // rowNumber starts from 0
  5038. rowNumber = rowNumber * 10 + char - 48;
  5039. } else if (hasRow && hasCol && char !== 36) {
  5040. // 36 = '$'.charCodeAt(0)
  5041. break;
  5042. }
  5043. }
  5044. if (!hasCol) {
  5045. colNumber = undefined;
  5046. } else if (colNumber > 16384) {
  5047. throw new Error("Out of bounds. Invalid column letter: ".concat(col));
  5048. }
  5049. if (!hasRow) {
  5050. rowNumber = undefined;
  5051. } // in case $row$col
  5052. value = col + row;
  5053. var address = {
  5054. address: value,
  5055. col: colNumber,
  5056. row: rowNumber,
  5057. $col$row: "$".concat(col, "$").concat(row)
  5058. }; // mem fix - cache only the tl 100x100 square
  5059. if (colNumber <= 100 && rowNumber <= 100) {
  5060. this._hash[value] = address;
  5061. this._hash[address.$col$row] = address;
  5062. }
  5063. return address;
  5064. },
  5065. // convert r,c into structure (if only 1 arg, assume r is address string)
  5066. getAddress: function getAddress(r, c) {
  5067. if (c) {
  5068. var address = this.n2l(c) + r;
  5069. return this.decodeAddress(address);
  5070. }
  5071. return this.decodeAddress(r);
  5072. },
  5073. // convert [address], [tl:br] into address structures
  5074. decode: function decode(value) {
  5075. var parts = value.split(':');
  5076. if (parts.length === 2) {
  5077. var tl = this.decodeAddress(parts[0]);
  5078. var br = this.decodeAddress(parts[1]);
  5079. var result = {
  5080. top: Math.min(tl.row, br.row),
  5081. left: Math.min(tl.col, br.col),
  5082. bottom: Math.max(tl.row, br.row),
  5083. right: Math.max(tl.col, br.col)
  5084. }; // reconstruct tl, br and dimensions
  5085. result.tl = this.n2l(result.left) + result.top;
  5086. result.br = this.n2l(result.right) + result.bottom;
  5087. result.dimensions = "".concat(result.tl, ":").concat(result.br);
  5088. return result;
  5089. }
  5090. return this.decodeAddress(value);
  5091. },
  5092. // convert [sheetName!][$]col[$]row[[$]col[$]row] into address or range structures
  5093. decodeEx: function decodeEx(value) {
  5094. var groups = value.match(/(?:(?:(?:'((?:[^']|'')*)')|([^'^ !]*))!)?(.*)/);
  5095. var sheetName = groups[1] || groups[2]; // Qouted and unqouted groups
  5096. var reference = groups[3]; // Remaining address
  5097. var parts = reference.split(':');
  5098. if (parts.length > 1) {
  5099. var tl = this.decodeAddress(parts[0]);
  5100. var br = this.decodeAddress(parts[1]);
  5101. var top = Math.min(tl.row, br.row);
  5102. var left = Math.min(tl.col, br.col);
  5103. var bottom = Math.max(tl.row, br.row);
  5104. var right = Math.max(tl.col, br.col);
  5105. tl = this.n2l(left) + top;
  5106. br = this.n2l(right) + bottom;
  5107. return {
  5108. top: top,
  5109. left: left,
  5110. bottom: bottom,
  5111. right: right,
  5112. sheetName: sheetName,
  5113. tl: {
  5114. address: tl,
  5115. col: left,
  5116. row: top,
  5117. $col$row: "$".concat(this.n2l(left), "$").concat(top),
  5118. sheetName: sheetName
  5119. },
  5120. br: {
  5121. address: br,
  5122. col: right,
  5123. row: bottom,
  5124. $col$row: "$".concat(this.n2l(right), "$").concat(bottom),
  5125. sheetName: sheetName
  5126. },
  5127. dimensions: "".concat(tl, ":").concat(br)
  5128. };
  5129. }
  5130. if (reference.startsWith('#')) {
  5131. return sheetName ? {
  5132. sheetName: sheetName,
  5133. error: reference
  5134. } : {
  5135. error: reference
  5136. };
  5137. }
  5138. var address = this.decodeAddress(reference);
  5139. return sheetName ? _objectSpread({
  5140. sheetName: sheetName
  5141. }, address) : address;
  5142. },
  5143. // convert row,col into address string
  5144. encodeAddress: function encodeAddress(row, col) {
  5145. return colCache.n2l(col) + row;
  5146. },
  5147. // convert row,col into string address or t,l,b,r into range
  5148. encode: function encode() {
  5149. switch (arguments.length) {
  5150. case 2:
  5151. return colCache.encodeAddress(arguments[0], arguments[1]);
  5152. case 4:
  5153. return "".concat(colCache.encodeAddress(arguments[0], arguments[1]), ":").concat(colCache.encodeAddress(arguments[2], arguments[3]));
  5154. default:
  5155. throw new Error('Can only encode with 2 or 4 arguments');
  5156. }
  5157. },
  5158. // return true if address is contained within range
  5159. inRange: function inRange(range, address) {
  5160. var _range = _slicedToArray(range, 5),
  5161. left = _range[0],
  5162. top = _range[1],
  5163. right = _range[3],
  5164. bottom = _range[4];
  5165. var _address = _slicedToArray(address, 2),
  5166. col = _address[0],
  5167. row = _address[1];
  5168. return col >= left && col <= right && row >= top && row <= bottom;
  5169. }
  5170. };
  5171. module.exports = colCache;
  5172. }, {}], 20: [function (require, module, exports) {
  5173. (function (Buffer) {
  5174. 'use strict';
  5175. var crypto = require('crypto');
  5176. var Encryptor = {
  5177. /**
  5178. * Calculate a hash of the concatenated buffers with the given algorithm.
  5179. * @param {string} algorithm - The hash algorithm.
  5180. * @returns {Buffer} The hash
  5181. */
  5182. hash: function hash(algorithm) {
  5183. var hash = crypto.createHash(algorithm);
  5184. for (var _len = arguments.length, buffers = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  5185. buffers[_key - 1] = arguments[_key];
  5186. }
  5187. hash.update(Buffer.concat(buffers));
  5188. return hash.digest();
  5189. },
  5190. /**
  5191. * Convert a password into an encryption key
  5192. * @param {string} password - The password
  5193. * @param {string} hashAlgorithm - The hash algoritm
  5194. * @param {string} saltValue - The salt value
  5195. * @param {number} spinCount - The spin count
  5196. * @param {number} keyBits - The length of the key in bits
  5197. * @param {Buffer} blockKey - The block key
  5198. * @returns {Buffer} The encryption key
  5199. */
  5200. convertPasswordToHash: function convertPasswordToHash(password, hashAlgorithm, saltValue, spinCount) {
  5201. hashAlgorithm = hashAlgorithm.toLowerCase();
  5202. var hashes = crypto.getHashes();
  5203. if (hashes.indexOf(hashAlgorithm) < 0) {
  5204. throw new Error("Hash algorithm '".concat(hashAlgorithm, "' not supported!"));
  5205. } // Password must be in unicode buffer
  5206. var passwordBuffer = Buffer.from(password, 'utf16le'); // Generate the initial hash
  5207. var key = this.hash(hashAlgorithm, Buffer.from(saltValue, 'base64'), passwordBuffer); // Now regenerate until spin count
  5208. for (var i = 0; i < spinCount; i++) {
  5209. var iterator = Buffer.alloc(4); // this is the 'special' element of Excel password hashing
  5210. // that stops us from using crypto.pbkdf2()
  5211. iterator.writeUInt32LE(i, 0);
  5212. key = this.hash(hashAlgorithm, key, iterator);
  5213. }
  5214. return key.toString('base64');
  5215. },
  5216. /**
  5217. * Generates cryptographically strong pseudo-random data.
  5218. * @param size The size argument is a number indicating the number of bytes to generate.
  5219. */
  5220. randomBytes: function randomBytes(size) {
  5221. return crypto.randomBytes(size);
  5222. }
  5223. };
  5224. module.exports = Encryptor;
  5225. }).call(this, require("buffer").Buffer)
  5226. }, { "buffer": 216, "crypto": 335 }], 21: [function (require, module, exports) {
  5227. "use strict";
  5228. function _awaitAsyncGenerator(value) { return new _AwaitValue(value); }
  5229. function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; }
  5230. function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen.return !== "function") { this.return = undefined; } }
  5231. if (typeof Symbol === "function" && Symbol.asyncIterator) { _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; }; }
  5232. _AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };
  5233. _AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); };
  5234. _AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); };
  5235. function _AwaitValue(value) { this.wrapped = value; }
  5236. function _asyncIterator(iterable) { var method; if (typeof Symbol !== "undefined") { if (Symbol.asyncIterator) { method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { method = iterable[Symbol.iterator]; if (method != null) return method.call(iterable); } } throw new TypeError("Object is not async iterable"); }
  5237. var _require = require('saxes'),
  5238. SaxesParser = _require.SaxesParser;
  5239. var _require2 = require('readable-stream'),
  5240. PassThrough = _require2.PassThrough;
  5241. var _require3 = require('./browser-buffer-decode'),
  5242. bufferToString = _require3.bufferToString;
  5243. module.exports = /*#__PURE__*/function () {
  5244. var _ref = _wrapAsyncGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(iterable) {
  5245. var saxesParser, error, events, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk;
  5246. return regeneratorRuntime.wrap(function _callee$(_context) {
  5247. while (1) {
  5248. switch (_context.prev = _context.next) {
  5249. case 0:
  5250. // TODO: Remove once node v8 is deprecated
  5251. // Detect and upgrade old streams
  5252. if (iterable.pipe && !iterable[Symbol.asyncIterator]) {
  5253. iterable = iterable.pipe(new PassThrough());
  5254. }
  5255. saxesParser = new SaxesParser();
  5256. saxesParser.on('error', function (err) {
  5257. error = err;
  5258. });
  5259. events = [];
  5260. saxesParser.on('opentag', function (value) {
  5261. return events.push({
  5262. eventType: 'opentag',
  5263. value: value
  5264. });
  5265. });
  5266. saxesParser.on('text', function (value) {
  5267. return events.push({
  5268. eventType: 'text',
  5269. value: value
  5270. });
  5271. });
  5272. saxesParser.on('closetag', function (value) {
  5273. return events.push({
  5274. eventType: 'closetag',
  5275. value: value
  5276. });
  5277. });
  5278. _iteratorNormalCompletion = true;
  5279. _didIteratorError = false;
  5280. _context.prev = 9;
  5281. _iterator = _asyncIterator(iterable);
  5282. case 11:
  5283. _context.next = 13;
  5284. return _awaitAsyncGenerator(_iterator.next());
  5285. case 13:
  5286. _step = _context.sent;
  5287. _iteratorNormalCompletion = _step.done;
  5288. _context.next = 17;
  5289. return _awaitAsyncGenerator(_step.value);
  5290. case 17:
  5291. _value = _context.sent;
  5292. if (_iteratorNormalCompletion) {
  5293. _context.next = 29;
  5294. break;
  5295. }
  5296. chunk = _value;
  5297. saxesParser.write(bufferToString(chunk)); // saxesParser.write and saxesParser.on() are synchronous,
  5298. // so we can only reach the below line once all events have been emitted
  5299. if (!error) {
  5300. _context.next = 23;
  5301. break;
  5302. }
  5303. throw error;
  5304. case 23:
  5305. _context.next = 25;
  5306. return events;
  5307. case 25:
  5308. events = [];
  5309. case 26:
  5310. _iteratorNormalCompletion = true;
  5311. _context.next = 11;
  5312. break;
  5313. case 29:
  5314. _context.next = 35;
  5315. break;
  5316. case 31:
  5317. _context.prev = 31;
  5318. _context.t0 = _context["catch"](9);
  5319. _didIteratorError = true;
  5320. _iteratorError = _context.t0;
  5321. case 35:
  5322. _context.prev = 35;
  5323. _context.prev = 36;
  5324. if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
  5325. _context.next = 40;
  5326. break;
  5327. }
  5328. _context.next = 40;
  5329. return _awaitAsyncGenerator(_iterator.return());
  5330. case 40:
  5331. _context.prev = 40;
  5332. if (!_didIteratorError) {
  5333. _context.next = 43;
  5334. break;
  5335. }
  5336. throw _iteratorError;
  5337. case 43:
  5338. return _context.finish(40);
  5339. case 44:
  5340. return _context.finish(35);
  5341. case 45:
  5342. case "end":
  5343. return _context.stop();
  5344. }
  5345. }
  5346. }, _callee, null, [[9, 31, 35, 45], [36, , 40, 44]]);
  5347. }));
  5348. return function (_x) {
  5349. return _ref.apply(this, arguments);
  5350. };
  5351. }();
  5352. }, { "./browser-buffer-decode": 16, "readable-stream": 491, "saxes": 496 }], 22: [function (require, module, exports) {
  5353. "use strict";
  5354. var colCache = require('./col-cache'); // const cellRefRegex = /(([a-z_\-0-9]*)!)?[$]?([a-z]+)[$]?([1-9][0-9]*)/i;
  5355. var replacementCandidateRx = /(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi;
  5356. var CRrx = /^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;
  5357. function slideFormula(formula, fromCell, toCell) {
  5358. var offset = colCache.decode(fromCell);
  5359. var to = colCache.decode(toCell);
  5360. return formula.replace(replacementCandidateRx, function (refMatch, sheet, sheetMaybe, addrPart, trailingParen) {
  5361. if (trailingParen) {
  5362. return refMatch;
  5363. }
  5364. var match = CRrx.exec(addrPart);
  5365. if (match) {
  5366. var colDollar = match[1];
  5367. var colStr = match[2].toUpperCase();
  5368. var rowDollar = match[3];
  5369. var rowStr = match[4];
  5370. if (colStr.length > 3 || colStr.length === 3 && colStr > 'XFD') {
  5371. // > XFD is the highest col number in excel 2007 and beyond, so this is a named range
  5372. return refMatch;
  5373. }
  5374. var col = colCache.l2n(colStr);
  5375. var row = parseInt(rowStr, 10);
  5376. if (!colDollar) {
  5377. col += to.col - offset.col;
  5378. }
  5379. if (!rowDollar) {
  5380. row += to.row - offset.row;
  5381. }
  5382. var res = (sheet || '') + (colDollar || '') + colCache.n2l(col) + (rowDollar || '') + row;
  5383. return res;
  5384. }
  5385. return refMatch;
  5386. });
  5387. }
  5388. module.exports = {
  5389. slideFormula: slideFormula
  5390. };
  5391. }, { "./col-cache": 19 }], 23: [function (require, module, exports) {
  5392. (function (process, Buffer) {
  5393. "use strict";
  5394. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  5395. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  5396. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5397. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5398. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5399. /* eslint-disable max-classes-per-file */
  5400. var Stream = require('readable-stream');
  5401. var utils = require('./utils');
  5402. var StringBuf = require('./string-buf'); // =============================================================================
  5403. // data chunks - encapsulating incoming data
  5404. var StringChunk = /*#__PURE__*/function () {
  5405. function StringChunk(data, encoding) {
  5406. _classCallCheck(this, StringChunk);
  5407. this._data = data;
  5408. this._encoding = encoding;
  5409. }
  5410. _createClass(StringChunk, [{
  5411. key: "copy",
  5412. // copy to target buffer
  5413. value: function copy(target, targetOffset, offset, length) {
  5414. return this.toBuffer().copy(target, targetOffset, offset, length);
  5415. }
  5416. }, {
  5417. key: "toBuffer",
  5418. value: function toBuffer() {
  5419. if (!this._buffer) {
  5420. this._buffer = Buffer.from(this._data, this._encoding);
  5421. }
  5422. return this._buffer;
  5423. }
  5424. }, {
  5425. key: "length",
  5426. get: function get() {
  5427. return this.toBuffer().length;
  5428. }
  5429. }]);
  5430. return StringChunk;
  5431. }();
  5432. var StringBufChunk = /*#__PURE__*/function () {
  5433. function StringBufChunk(data) {
  5434. _classCallCheck(this, StringBufChunk);
  5435. this._data = data;
  5436. }
  5437. _createClass(StringBufChunk, [{
  5438. key: "copy",
  5439. // copy to target buffer
  5440. value: function copy(target, targetOffset, offset, length) {
  5441. // eslint-disable-next-line no-underscore-dangle
  5442. return this._data._buf.copy(target, targetOffset, offset, length);
  5443. }
  5444. }, {
  5445. key: "toBuffer",
  5446. value: function toBuffer() {
  5447. return this._data.toBuffer();
  5448. }
  5449. }, {
  5450. key: "length",
  5451. get: function get() {
  5452. return this._data.length;
  5453. }
  5454. }]);
  5455. return StringBufChunk;
  5456. }();
  5457. var BufferChunk = /*#__PURE__*/function () {
  5458. function BufferChunk(data) {
  5459. _classCallCheck(this, BufferChunk);
  5460. this._data = data;
  5461. }
  5462. _createClass(BufferChunk, [{
  5463. key: "copy",
  5464. // copy to target buffer
  5465. value: function copy(target, targetOffset, offset, length) {
  5466. this._data.copy(target, targetOffset, offset, length);
  5467. }
  5468. }, {
  5469. key: "toBuffer",
  5470. value: function toBuffer() {
  5471. return this._data;
  5472. }
  5473. }, {
  5474. key: "length",
  5475. get: function get() {
  5476. return this._data.length;
  5477. }
  5478. }]);
  5479. return BufferChunk;
  5480. }(); // =============================================================================
  5481. // ReadWriteBuf - a single buffer supporting simple read-write
  5482. var ReadWriteBuf = /*#__PURE__*/function () {
  5483. function ReadWriteBuf(size) {
  5484. _classCallCheck(this, ReadWriteBuf);
  5485. this.size = size; // the buffer
  5486. this.buffer = Buffer.alloc(size); // read index
  5487. this.iRead = 0; // write index
  5488. this.iWrite = 0;
  5489. }
  5490. _createClass(ReadWriteBuf, [{
  5491. key: "toBuffer",
  5492. value: function toBuffer() {
  5493. if (this.iRead === 0 && this.iWrite === this.size) {
  5494. return this.buffer;
  5495. }
  5496. var buf = Buffer.alloc(this.iWrite - this.iRead);
  5497. this.buffer.copy(buf, 0, this.iRead, this.iWrite);
  5498. return buf;
  5499. }
  5500. }, {
  5501. key: "read",
  5502. value: function read(size) {
  5503. var buf; // read size bytes from buffer and return buffer
  5504. if (size === 0) {
  5505. // special case - return null if no data requested
  5506. return null;
  5507. }
  5508. if (size === undefined || size >= this.length) {
  5509. // if no size specified or size is at least what we have then return all of the bytes
  5510. buf = this.toBuffer();
  5511. this.iRead = this.iWrite;
  5512. return buf;
  5513. } // otherwise return a chunk
  5514. buf = Buffer.alloc(size);
  5515. this.buffer.copy(buf, 0, this.iRead, size);
  5516. this.iRead += size;
  5517. return buf;
  5518. }
  5519. }, {
  5520. key: "write",
  5521. value: function write(chunk, offset, length) {
  5522. // write as many bytes from data from optional source offset
  5523. // and return number of bytes written
  5524. var size = Math.min(length, this.size - this.iWrite);
  5525. chunk.copy(this.buffer, this.iWrite, offset, offset + size);
  5526. this.iWrite += size;
  5527. return size;
  5528. }
  5529. }, {
  5530. key: "length",
  5531. get: function get() {
  5532. return this.iWrite - this.iRead;
  5533. }
  5534. }, {
  5535. key: "eod",
  5536. get: function get() {
  5537. return this.iRead === this.iWrite;
  5538. }
  5539. }, {
  5540. key: "full",
  5541. get: function get() {
  5542. return this.iWrite === this.size;
  5543. }
  5544. }]);
  5545. return ReadWriteBuf;
  5546. }(); // =============================================================================
  5547. // StreamBuf - a multi-purpose read-write stream
  5548. // As MemBuf - write as much data as you like. Then call toBuffer() to consolidate
  5549. // As StreamHub - pipe to multiple writables
  5550. // As readable stream - feed data into the writable part and have some other code read from it.
  5551. // Note: Not sure why but StreamBuf does not like JS "class" sugar. It fails the
  5552. // integration tests
  5553. var StreamBuf = function StreamBuf(options) {
  5554. options = options || {};
  5555. this.bufSize = options.bufSize || 1024 * 1024;
  5556. this.buffers = []; // batch mode fills a buffer completely before passing the data on
  5557. // to pipes or 'readable' event listeners
  5558. this.batch = options.batch || false;
  5559. this.corked = false; // where in the current writable buffer we're up to
  5560. this.inPos = 0; // where in the current readable buffer we've read up to
  5561. this.outPos = 0; // consuming pipe streams go here
  5562. this.pipes = []; // controls emit('data')
  5563. this.paused = false;
  5564. this.encoding = null;
  5565. };
  5566. utils.inherits(StreamBuf, Stream.Duplex, {
  5567. toBuffer: function toBuffer() {
  5568. switch (this.buffers.length) {
  5569. case 0:
  5570. return null;
  5571. case 1:
  5572. return this.buffers[0].toBuffer();
  5573. default:
  5574. return Buffer.concat(this.buffers.map(function (rwBuf) {
  5575. return rwBuf.toBuffer();
  5576. }));
  5577. }
  5578. },
  5579. // writable
  5580. // event drain - if write returns false (which it won't), indicates when safe to write again.
  5581. // finish - end() has been called
  5582. // pipe(src) - pipe() has been called on readable
  5583. // unpipe(src) - unpipe() has been called on readable
  5584. // error - duh
  5585. _getWritableBuffer: function _getWritableBuffer() {
  5586. if (this.buffers.length) {
  5587. var last = this.buffers[this.buffers.length - 1];
  5588. if (!last.full) {
  5589. return last;
  5590. }
  5591. }
  5592. var buf = new ReadWriteBuf(this.bufSize);
  5593. this.buffers.push(buf);
  5594. return buf;
  5595. },
  5596. _pipe: function _pipe(chunk) {
  5597. var _this = this;
  5598. return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
  5599. var write;
  5600. return regeneratorRuntime.wrap(function _callee$(_context) {
  5601. while (1) {
  5602. switch (_context.prev = _context.next) {
  5603. case 0:
  5604. write = function write(pipe) {
  5605. return new Promise(function (resolve) {
  5606. pipe.write(chunk.toBuffer(), function () {
  5607. resolve();
  5608. });
  5609. });
  5610. };
  5611. _context.next = 3;
  5612. return Promise.all(_this.pipes.map(write));
  5613. case 3:
  5614. case "end":
  5615. return _context.stop();
  5616. }
  5617. }
  5618. }, _callee);
  5619. }))();
  5620. },
  5621. _writeToBuffers: function _writeToBuffers(chunk) {
  5622. var inPos = 0;
  5623. var inLen = chunk.length;
  5624. while (inPos < inLen) {
  5625. // find writable buffer
  5626. var buffer = this._getWritableBuffer(); // write some data
  5627. inPos += buffer.write(chunk, inPos, inLen - inPos);
  5628. }
  5629. },
  5630. write: function write(data, encoding, callback) {
  5631. var _this2 = this;
  5632. return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
  5633. var chunk;
  5634. return regeneratorRuntime.wrap(function _callee2$(_context2) {
  5635. while (1) {
  5636. switch (_context2.prev = _context2.next) {
  5637. case 0:
  5638. if (encoding instanceof Function) {
  5639. callback = encoding;
  5640. encoding = 'utf8';
  5641. }
  5642. callback = callback || utils.nop; // encapsulate data into a chunk
  5643. if (!(data instanceof StringBuf)) {
  5644. _context2.next = 6;
  5645. break;
  5646. }
  5647. chunk = new StringBufChunk(data);
  5648. _context2.next = 15;
  5649. break;
  5650. case 6:
  5651. if (!(data instanceof Buffer)) {
  5652. _context2.next = 10;
  5653. break;
  5654. }
  5655. chunk = new BufferChunk(data);
  5656. _context2.next = 15;
  5657. break;
  5658. case 10:
  5659. if (!(typeof data === 'string' || data instanceof String || data instanceof ArrayBuffer)) {
  5660. _context2.next = 14;
  5661. break;
  5662. }
  5663. chunk = new StringChunk(data, encoding);
  5664. _context2.next = 15;
  5665. break;
  5666. case 14:
  5667. throw new Error('Chunk must be one of type String, Buffer or StringBuf.');
  5668. case 15:
  5669. if (!_this2.pipes.length) {
  5670. _context2.next = 31;
  5671. break;
  5672. }
  5673. if (!_this2.batch) {
  5674. _context2.next = 21;
  5675. break;
  5676. }
  5677. _this2._writeToBuffers(chunk);
  5678. while (!_this2.corked && _this2.buffers.length > 1) {
  5679. _this2._pipe(_this2.buffers.shift());
  5680. }
  5681. _context2.next = 29;
  5682. break;
  5683. case 21:
  5684. if (_this2.corked) {
  5685. _context2.next = 27;
  5686. break;
  5687. }
  5688. _context2.next = 24;
  5689. return _this2._pipe(chunk);
  5690. case 24:
  5691. callback();
  5692. _context2.next = 29;
  5693. break;
  5694. case 27:
  5695. _this2._writeToBuffers(chunk);
  5696. process.nextTick(callback);
  5697. case 29:
  5698. _context2.next = 34;
  5699. break;
  5700. case 31:
  5701. if (!_this2.paused) {
  5702. _this2.emit('data', chunk.toBuffer());
  5703. }
  5704. _this2._writeToBuffers(chunk);
  5705. _this2.emit('readable');
  5706. case 34:
  5707. return _context2.abrupt("return", true);
  5708. case 35:
  5709. case "end":
  5710. return _context2.stop();
  5711. }
  5712. }
  5713. }, _callee2);
  5714. }))();
  5715. },
  5716. cork: function cork() {
  5717. this.corked = true;
  5718. },
  5719. _flush: function _flush()
  5720. /* destination */ {
  5721. // if we have comsumers...
  5722. if (this.pipes.length) {
  5723. // and there's stuff not written
  5724. while (this.buffers.length) {
  5725. this._pipe(this.buffers.shift());
  5726. }
  5727. }
  5728. },
  5729. uncork: function uncork() {
  5730. this.corked = false;
  5731. this._flush();
  5732. },
  5733. end: function end(chunk, encoding, callback) {
  5734. var _this3 = this;
  5735. var writeComplete = function writeComplete(error) {
  5736. if (error) {
  5737. callback(error);
  5738. } else {
  5739. _this3._flush();
  5740. _this3.pipes.forEach(function (pipe) {
  5741. pipe.end();
  5742. });
  5743. _this3.emit('finish');
  5744. }
  5745. };
  5746. if (chunk) {
  5747. this.write(chunk, encoding, writeComplete);
  5748. } else {
  5749. writeComplete();
  5750. }
  5751. },
  5752. // readable
  5753. // event readable - some data is now available
  5754. // event data - switch to flowing mode - feeds chunks to handler
  5755. // event end - no more data
  5756. // event close - optional, indicates upstream close
  5757. // event error - duh
  5758. read: function read(size) {
  5759. var buffers; // read min(buffer, size || infinity)
  5760. if (size) {
  5761. buffers = [];
  5762. while (size && this.buffers.length && !this.buffers[0].eod) {
  5763. var first = this.buffers[0];
  5764. var buffer = first.read(size);
  5765. size -= buffer.length;
  5766. buffers.push(buffer);
  5767. if (first.eod && first.full) {
  5768. this.buffers.shift();
  5769. }
  5770. }
  5771. return Buffer.concat(buffers);
  5772. }
  5773. buffers = this.buffers.map(function (buf) {
  5774. return buf.toBuffer();
  5775. }).filter(Boolean);
  5776. this.buffers = [];
  5777. return Buffer.concat(buffers);
  5778. },
  5779. setEncoding: function setEncoding(encoding) {
  5780. // causes stream.read or stream.on('data) to return strings of encoding instead of Buffer objects
  5781. this.encoding = encoding;
  5782. },
  5783. pause: function pause() {
  5784. this.paused = true;
  5785. },
  5786. resume: function resume() {
  5787. this.paused = false;
  5788. },
  5789. isPaused: function isPaused() {
  5790. return !!this.paused;
  5791. },
  5792. pipe: function pipe(destination) {
  5793. // add destination to pipe list & write current buffer
  5794. this.pipes.push(destination);
  5795. if (!this.paused && this.buffers.length) {
  5796. this.end();
  5797. }
  5798. },
  5799. unpipe: function unpipe(destination) {
  5800. // remove destination from pipe list
  5801. this.pipes = this.pipes.filter(function (pipe) {
  5802. return pipe !== destination;
  5803. });
  5804. },
  5805. unshift: function unshift()
  5806. /* chunk */ {
  5807. // some numpty has read some data that's not for them and they want to put it back!
  5808. // Might implement this some day
  5809. throw new Error('Not Implemented');
  5810. },
  5811. wrap: function wrap()
  5812. /* stream */ {
  5813. // not implemented
  5814. throw new Error('Not Implemented');
  5815. }
  5816. });
  5817. module.exports = StreamBuf;
  5818. }).call(this, require('_process'), require("buffer").Buffer)
  5819. }, { "./string-buf": 24, "./utils": 26, "_process": 467, "buffer": 216, "readable-stream": 491 }], 24: [function (require, module, exports) {
  5820. (function (Buffer) {
  5821. "use strict";
  5822. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5823. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5824. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5825. // StringBuf - a way to keep string memory operations to a minimum
  5826. // while building the strings for the xml files
  5827. var StringBuf = /*#__PURE__*/function () {
  5828. function StringBuf(options) {
  5829. _classCallCheck(this, StringBuf);
  5830. this._buf = Buffer.alloc(options && options.size || 16384);
  5831. this._encoding = options && options.encoding || 'utf8'; // where in the buffer we are at
  5832. this._inPos = 0; // for use by toBuffer()
  5833. this._buffer = undefined;
  5834. }
  5835. _createClass(StringBuf, [{
  5836. key: "toBuffer",
  5837. value: function toBuffer() {
  5838. // return the current data as a single enclosing buffer
  5839. if (!this._buffer) {
  5840. this._buffer = Buffer.alloc(this.length);
  5841. this._buf.copy(this._buffer, 0, 0, this.length);
  5842. }
  5843. return this._buffer;
  5844. }
  5845. }, {
  5846. key: "reset",
  5847. value: function reset(position) {
  5848. position = position || 0;
  5849. this._buffer = undefined;
  5850. this._inPos = position;
  5851. }
  5852. }, {
  5853. key: "_grow",
  5854. value: function _grow(min) {
  5855. var size = this._buf.length * 2;
  5856. while (size < min) {
  5857. size *= 2;
  5858. }
  5859. var buf = Buffer.alloc(size);
  5860. this._buf.copy(buf, 0);
  5861. this._buf = buf;
  5862. }
  5863. }, {
  5864. key: "addText",
  5865. value: function addText(text) {
  5866. this._buffer = undefined;
  5867. var inPos = this._inPos + this._buf.write(text, this._inPos, this._encoding); // if we've hit (or nearing capacity), grow the buf
  5868. while (inPos >= this._buf.length - 4) {
  5869. this._grow(this._inPos + text.length); // keep trying to write until we've completely written the text
  5870. inPos = this._inPos + this._buf.write(text, this._inPos, this._encoding);
  5871. }
  5872. this._inPos = inPos;
  5873. }
  5874. }, {
  5875. key: "addStringBuf",
  5876. value: function addStringBuf(inBuf) {
  5877. if (inBuf.length) {
  5878. this._buffer = undefined;
  5879. if (this.length + inBuf.length > this.capacity) {
  5880. this._grow(this.length + inBuf.length);
  5881. } // eslint-disable-next-line no-underscore-dangle
  5882. inBuf._buf.copy(this._buf, this._inPos, 0, inBuf.length);
  5883. this._inPos += inBuf.length;
  5884. }
  5885. }
  5886. }, {
  5887. key: "length",
  5888. get: function get() {
  5889. return this._inPos;
  5890. }
  5891. }, {
  5892. key: "capacity",
  5893. get: function get() {
  5894. return this._buf.length;
  5895. }
  5896. }, {
  5897. key: "buffer",
  5898. get: function get() {
  5899. return this._buf;
  5900. }
  5901. }]);
  5902. return StringBuf;
  5903. }();
  5904. module.exports = StringBuf;
  5905. }).call(this, require("buffer").Buffer)
  5906. }, { "buffer": 216 }], 25: [function (require, module, exports) {
  5907. "use strict";
  5908. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5909. var toString = Object.prototype.toString;
  5910. var escapeHtmlRegex = /["&<>]/;
  5911. var _ = {
  5912. each: function each(obj, cb) {
  5913. if (obj) {
  5914. if (Array.isArray(obj)) {
  5915. obj.forEach(cb);
  5916. } else {
  5917. Object.keys(obj).forEach(function (key) {
  5918. cb(obj[key], key);
  5919. });
  5920. }
  5921. }
  5922. },
  5923. some: function some(obj, cb) {
  5924. if (obj) {
  5925. if (Array.isArray(obj)) {
  5926. return obj.some(cb);
  5927. }
  5928. return Object.keys(obj).some(function (key) {
  5929. return cb(obj[key], key);
  5930. });
  5931. }
  5932. return false;
  5933. },
  5934. every: function every(obj, cb) {
  5935. if (obj) {
  5936. if (Array.isArray(obj)) {
  5937. return obj.every(cb);
  5938. }
  5939. return Object.keys(obj).every(function (key) {
  5940. return cb(obj[key], key);
  5941. });
  5942. }
  5943. return true;
  5944. },
  5945. map: function map(obj, cb) {
  5946. if (obj) {
  5947. if (Array.isArray(obj)) {
  5948. return obj.map(cb);
  5949. }
  5950. return Object.keys(obj).map(function (key) {
  5951. return cb(obj[key], key);
  5952. });
  5953. }
  5954. return [];
  5955. },
  5956. keyBy: function keyBy(a, p) {
  5957. return a.reduce(function (o, v) {
  5958. o[v[p]] = v;
  5959. return o;
  5960. }, {});
  5961. },
  5962. isEqual: function isEqual(a, b) {
  5963. var aType = _typeof(a);
  5964. var bType = _typeof(b);
  5965. var aArray = Array.isArray(a);
  5966. var bArray = Array.isArray(b);
  5967. if (aType !== bType) {
  5968. return false;
  5969. }
  5970. switch (_typeof(a)) {
  5971. case 'object':
  5972. if (aArray || bArray) {
  5973. if (aArray && bArray) {
  5974. return a.length === b.length && a.every(function (aValue, index) {
  5975. var bValue = b[index];
  5976. return _.isEqual(aValue, bValue);
  5977. });
  5978. }
  5979. return false;
  5980. }
  5981. return _.every(a, function (aValue, key) {
  5982. var bValue = b[key];
  5983. return _.isEqual(aValue, bValue);
  5984. });
  5985. default:
  5986. return a === b;
  5987. }
  5988. },
  5989. escapeHtml: function escapeHtml(html) {
  5990. var regexResult = escapeHtmlRegex.exec(html);
  5991. if (!regexResult) return html;
  5992. var result = '';
  5993. var escape = '';
  5994. var lastIndex = 0;
  5995. var i = regexResult.index;
  5996. for (; i < html.length; i++) {
  5997. switch (html.charAt(i)) {
  5998. case '"':
  5999. escape = '&quot;';
  6000. break;
  6001. case '&':
  6002. escape = '&amp;';
  6003. break;
  6004. case "'":
  6005. escape = '&apos;';
  6006. break;
  6007. case '<':
  6008. escape = '&lt;';
  6009. break;
  6010. case '>':
  6011. escape = '&gt;';
  6012. break;
  6013. default:
  6014. continue;
  6015. }
  6016. if (lastIndex !== i) result += html.substring(lastIndex, i);
  6017. lastIndex = i + 1;
  6018. result += escape;
  6019. }
  6020. if (lastIndex !== i) return result + html.substring(lastIndex, i);
  6021. return result;
  6022. },
  6023. strcmp: function strcmp(a, b) {
  6024. if (a < b) return -1;
  6025. if (a > b) return 1;
  6026. return 0;
  6027. },
  6028. isUndefined: function isUndefined(val) {
  6029. return toString.call(val) === '[object Undefined]';
  6030. },
  6031. isObject: function isObject(val) {
  6032. return toString.call(val) === '[object Object]';
  6033. },
  6034. deepMerge: function deepMerge() {
  6035. var target = arguments[0] || {};
  6036. var length = arguments.length; // eslint-disable-next-line one-var
  6037. var src, clone, copyIsArray;
  6038. function assignValue(val, key) {
  6039. src = target[key];
  6040. copyIsArray = Array.isArray(val);
  6041. if (_.isObject(val) || copyIsArray) {
  6042. if (copyIsArray) {
  6043. copyIsArray = false;
  6044. clone = src && Array.isArray(src) ? src : [];
  6045. } else {
  6046. clone = src && _.isObject(src) ? src : {};
  6047. }
  6048. target[key] = _.deepMerge(clone, val);
  6049. } else if (!_.isUndefined(val)) {
  6050. target[key] = val;
  6051. }
  6052. }
  6053. for (var i = 0; i < length; i++) {
  6054. _.each(arguments[i], assignValue);
  6055. }
  6056. return target;
  6057. }
  6058. };
  6059. module.exports = _;
  6060. }, {}], 26: [function (require, module, exports) {
  6061. (function (global, setImmediate) {
  6062. "use strict";
  6063. var fs = require('fs'); // useful stuff
  6064. var inherits = function inherits(cls, superCtor, statics, prototype) {
  6065. // eslint-disable-next-line no-underscore-dangle
  6066. cls.super_ = superCtor;
  6067. if (!prototype) {
  6068. prototype = statics;
  6069. statics = null;
  6070. }
  6071. if (statics) {
  6072. Object.keys(statics).forEach(function (i) {
  6073. Object.defineProperty(cls, i, Object.getOwnPropertyDescriptor(statics, i));
  6074. });
  6075. }
  6076. var properties = {
  6077. constructor: {
  6078. value: cls,
  6079. enumerable: false,
  6080. writable: false,
  6081. configurable: true
  6082. }
  6083. };
  6084. if (prototype) {
  6085. Object.keys(prototype).forEach(function (i) {
  6086. properties[i] = Object.getOwnPropertyDescriptor(prototype, i);
  6087. });
  6088. }
  6089. cls.prototype = Object.create(superCtor.prototype, properties);
  6090. }; // eslint-disable-next-line no-control-regex
  6091. var xmlDecodeRegex = /[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/;
  6092. var utils = {
  6093. nop: function nop() { },
  6094. promiseImmediate: function promiseImmediate(value) {
  6095. return new Promise(function (resolve) {
  6096. if (global.setImmediate) {
  6097. setImmediate(function () {
  6098. resolve(value);
  6099. });
  6100. } else {
  6101. // poorman's setImmediate - must wait at least 1ms
  6102. setTimeout(function () {
  6103. resolve(value);
  6104. }, 1);
  6105. }
  6106. });
  6107. },
  6108. inherits: inherits,
  6109. dateToExcel: function dateToExcel(d, date1904) {
  6110. return 25569 + d.getTime() / (24 * 3600 * 1000) - (date1904 ? 1462 : 0);
  6111. },
  6112. excelToDate: function excelToDate(v, date1904) {
  6113. var millisecondSinceEpoch = Math.round((v - 25569 + (date1904 ? 1462 : 0)) * 24 * 3600 * 1000);
  6114. return new Date(millisecondSinceEpoch);
  6115. },
  6116. parsePath: function parsePath(filepath) {
  6117. var last = filepath.lastIndexOf('/');
  6118. return {
  6119. path: filepath.substring(0, last),
  6120. name: filepath.substring(last + 1)
  6121. };
  6122. },
  6123. getRelsPath: function getRelsPath(filepath) {
  6124. var path = utils.parsePath(filepath);
  6125. return "".concat(path.path, "/_rels/").concat(path.name, ".rels");
  6126. },
  6127. xmlEncode: function xmlEncode(text) {
  6128. var regexResult = xmlDecodeRegex.exec(text);
  6129. if (!regexResult) return text;
  6130. var result = '';
  6131. var escape = '';
  6132. var lastIndex = 0;
  6133. var i = regexResult.index;
  6134. for (; i < text.length; i++) {
  6135. var charCode = text.charCodeAt(i);
  6136. switch (charCode) {
  6137. case 34:
  6138. // "
  6139. escape = '&quot;';
  6140. break;
  6141. case 38:
  6142. // &
  6143. escape = '&amp;';
  6144. break;
  6145. case 39:
  6146. // '
  6147. escape = '&apos;';
  6148. break;
  6149. case 60:
  6150. // <
  6151. escape = '&lt;';
  6152. break;
  6153. case 62:
  6154. // >
  6155. escape = '&gt;';
  6156. break;
  6157. case 127:
  6158. escape = '';
  6159. break;
  6160. default:
  6161. {
  6162. if (charCode <= 31 && (charCode <= 8 || charCode >= 11 && charCode !== 13)) {
  6163. escape = '';
  6164. break;
  6165. }
  6166. continue;
  6167. }
  6168. }
  6169. if (lastIndex !== i) result += text.substring(lastIndex, i);
  6170. lastIndex = i + 1;
  6171. if (escape) result += escape;
  6172. }
  6173. if (lastIndex !== i) return result + text.substring(lastIndex, i);
  6174. return result;
  6175. },
  6176. xmlDecode: function xmlDecode(text) {
  6177. return text.replace(/&([a-z]*);/g, function (c) {
  6178. switch (c) {
  6179. case '&lt;':
  6180. return '<';
  6181. case '&gt;':
  6182. return '>';
  6183. case '&amp;':
  6184. return '&';
  6185. case '&apos;':
  6186. return '\'';
  6187. case '&quot;':
  6188. return '"';
  6189. default:
  6190. return c;
  6191. }
  6192. });
  6193. },
  6194. validInt: function validInt(value) {
  6195. var i = parseInt(value, 10);
  6196. return !Number.isNaN(i) ? i : 0;
  6197. },
  6198. isDateFmt: function isDateFmt(fmt) {
  6199. if (!fmt) {
  6200. return false;
  6201. } // must remove all chars inside quotes and []
  6202. fmt = fmt.replace(/\[[^\]]*]/g, '');
  6203. fmt = fmt.replace(/"[^"]*"/g, ''); // then check for date formatting chars
  6204. var result = fmt.match(/[ymdhMsb]+/) !== null;
  6205. return result;
  6206. },
  6207. fs: {
  6208. exists: function exists(path) {
  6209. return new Promise(function (resolve) {
  6210. fs.access(path, fs.constants.F_OK, function (err) {
  6211. resolve(!err);
  6212. });
  6213. });
  6214. }
  6215. },
  6216. toIsoDateString: function toIsoDateString(dt) {
  6217. return dt.toIsoString().subsstr(0, 10);
  6218. }
  6219. };
  6220. module.exports = utils;
  6221. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}, require("timers").setImmediate)
  6222. }, { "fs": 215, "timers": 521 }], 27: [function (require, module, exports) {
  6223. "use strict";
  6224. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6225. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6226. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6227. var _ = require('./under-dash');
  6228. var utils = require('./utils'); // constants
  6229. var OPEN_ANGLE = '<';
  6230. var CLOSE_ANGLE = '>';
  6231. var OPEN_ANGLE_SLASH = '</';
  6232. var CLOSE_SLASH_ANGLE = '/>';
  6233. var EQUALS_QUOTE = '="';
  6234. var QUOTE = '"';
  6235. var SPACE = ' ';
  6236. function pushAttribute(xml, name, value) {
  6237. xml.push(SPACE);
  6238. xml.push(name);
  6239. xml.push(EQUALS_QUOTE);
  6240. xml.push(utils.xmlEncode(value.toString()));
  6241. xml.push(QUOTE);
  6242. }
  6243. function pushAttributes(xml, attributes) {
  6244. if (attributes) {
  6245. _.each(attributes, function (value, name) {
  6246. if (value !== undefined) {
  6247. pushAttribute(xml, name, value);
  6248. }
  6249. });
  6250. }
  6251. }
  6252. var XmlStream = /*#__PURE__*/function () {
  6253. function XmlStream() {
  6254. _classCallCheck(this, XmlStream);
  6255. this._xml = [];
  6256. this._stack = [];
  6257. this._rollbacks = [];
  6258. }
  6259. _createClass(XmlStream, [{
  6260. key: "openXml",
  6261. value: function openXml(docAttributes) {
  6262. var xml = this._xml; // <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  6263. xml.push('<?xml');
  6264. pushAttributes(xml, docAttributes);
  6265. xml.push('?>\n');
  6266. }
  6267. }, {
  6268. key: "openNode",
  6269. value: function openNode(name, attributes) {
  6270. var parent = this.tos;
  6271. var xml = this._xml;
  6272. if (parent && this.open) {
  6273. xml.push(CLOSE_ANGLE);
  6274. }
  6275. this._stack.push(name); // start streaming node
  6276. xml.push(OPEN_ANGLE);
  6277. xml.push(name);
  6278. pushAttributes(xml, attributes);
  6279. this.leaf = true;
  6280. this.open = true;
  6281. }
  6282. }, {
  6283. key: "addAttribute",
  6284. value: function addAttribute(name, value) {
  6285. if (!this.open) {
  6286. throw new Error('Cannot write attributes to node if it is not open');
  6287. }
  6288. if (value !== undefined) {
  6289. pushAttribute(this._xml, name, value);
  6290. }
  6291. }
  6292. }, {
  6293. key: "addAttributes",
  6294. value: function addAttributes(attrs) {
  6295. if (!this.open) {
  6296. throw new Error('Cannot write attributes to node if it is not open');
  6297. }
  6298. pushAttributes(this._xml, attrs);
  6299. }
  6300. }, {
  6301. key: "writeText",
  6302. value: function writeText(text) {
  6303. var xml = this._xml;
  6304. if (this.open) {
  6305. xml.push(CLOSE_ANGLE);
  6306. this.open = false;
  6307. }
  6308. this.leaf = false;
  6309. xml.push(utils.xmlEncode(text.toString()));
  6310. }
  6311. }, {
  6312. key: "writeXml",
  6313. value: function writeXml(xml) {
  6314. if (this.open) {
  6315. this._xml.push(CLOSE_ANGLE);
  6316. this.open = false;
  6317. }
  6318. this.leaf = false;
  6319. this._xml.push(xml);
  6320. }
  6321. }, {
  6322. key: "closeNode",
  6323. value: function closeNode() {
  6324. var node = this._stack.pop();
  6325. var xml = this._xml;
  6326. if (this.leaf) {
  6327. xml.push(CLOSE_SLASH_ANGLE);
  6328. } else {
  6329. xml.push(OPEN_ANGLE_SLASH);
  6330. xml.push(node);
  6331. xml.push(CLOSE_ANGLE);
  6332. }
  6333. this.open = false;
  6334. this.leaf = false;
  6335. }
  6336. }, {
  6337. key: "leafNode",
  6338. value: function leafNode(name, attributes, text) {
  6339. this.openNode(name, attributes);
  6340. if (text !== undefined) {
  6341. // zeros need to be written
  6342. this.writeText(text);
  6343. }
  6344. this.closeNode();
  6345. }
  6346. }, {
  6347. key: "closeAll",
  6348. value: function closeAll() {
  6349. while (this._stack.length) {
  6350. this.closeNode();
  6351. }
  6352. }
  6353. }, {
  6354. key: "addRollback",
  6355. value: function addRollback() {
  6356. this._rollbacks.push({
  6357. xml: this._xml.length,
  6358. stack: this._stack.length,
  6359. leaf: this.leaf,
  6360. open: this.open
  6361. });
  6362. return this.cursor;
  6363. }
  6364. }, {
  6365. key: "commit",
  6366. value: function commit() {
  6367. this._rollbacks.pop();
  6368. }
  6369. }, {
  6370. key: "rollback",
  6371. value: function rollback() {
  6372. var r = this._rollbacks.pop();
  6373. if (this._xml.length > r.xml) {
  6374. this._xml.splice(r.xml, this._xml.length - r.xml);
  6375. }
  6376. if (this._stack.length > r.stack) {
  6377. this._stack.splice(r.stack, this._stack.length - r.stack);
  6378. }
  6379. this.leaf = r.leaf;
  6380. this.open = r.open;
  6381. }
  6382. }, {
  6383. key: "tos",
  6384. get: function get() {
  6385. return this._stack.length ? this._stack[this._stack.length - 1] : undefined;
  6386. }
  6387. }, {
  6388. key: "cursor",
  6389. get: function get() {
  6390. // handy way to track whether anything has been added
  6391. return this._xml.length;
  6392. }
  6393. }, {
  6394. key: "xml",
  6395. get: function get() {
  6396. this.closeAll();
  6397. return this._xml.join('');
  6398. }
  6399. }]);
  6400. return XmlStream;
  6401. }();
  6402. XmlStream.StdDocAttributes = {
  6403. version: '1.0',
  6404. encoding: 'UTF-8',
  6405. standalone: 'yes'
  6406. };
  6407. module.exports = XmlStream;
  6408. }, { "./under-dash": 25, "./utils": 26 }], 28: [function (require, module, exports) {
  6409. (function (process) {
  6410. "use strict";
  6411. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6412. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  6413. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  6414. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6415. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6416. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6417. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  6418. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  6419. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  6420. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  6421. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  6422. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  6423. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  6424. var events = require('events');
  6425. var JSZip = require('jszip');
  6426. var StreamBuf = require('./stream-buf');
  6427. var _require = require('./browser-buffer-encode'),
  6428. stringToBuffer = _require.stringToBuffer; // =============================================================================
  6429. // The ZipWriter class
  6430. // Packs streamed data into an output zip stream
  6431. var ZipWriter = /*#__PURE__*/function (_events$EventEmitter) {
  6432. _inherits(ZipWriter, _events$EventEmitter);
  6433. var _super = _createSuper(ZipWriter);
  6434. function ZipWriter(options) {
  6435. var _this;
  6436. _classCallCheck(this, ZipWriter);
  6437. _this = _super.call(this);
  6438. _this.options = Object.assign({
  6439. type: 'nodebuffer',
  6440. compression: 'DEFLATE'
  6441. }, options);
  6442. _this.zip = new JSZip();
  6443. _this.stream = new StreamBuf();
  6444. return _this;
  6445. }
  6446. _createClass(ZipWriter, [{
  6447. key: "append",
  6448. value: function append(data, options) {
  6449. if (options.hasOwnProperty('base64') && options.base64) {
  6450. this.zip.file(options.name, data, {
  6451. base64: true
  6452. });
  6453. } else {
  6454. // https://www.npmjs.com/package/process
  6455. if (process.browser && typeof data === 'string') {
  6456. // use TextEncoder in browser
  6457. data = stringToBuffer(data);
  6458. }
  6459. this.zip.file(options.name, data);
  6460. }
  6461. }
  6462. }, {
  6463. key: "finalize",
  6464. value: function () {
  6465. var _finalize = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
  6466. var content;
  6467. return regeneratorRuntime.wrap(function _callee$(_context) {
  6468. while (1) {
  6469. switch (_context.prev = _context.next) {
  6470. case 0:
  6471. _context.next = 2;
  6472. return this.zip.generateAsync(this.options);
  6473. case 2:
  6474. content = _context.sent;
  6475. this.stream.end(content);
  6476. this.emit('finish');
  6477. case 5:
  6478. case "end":
  6479. return _context.stop();
  6480. }
  6481. }
  6482. }, _callee, this);
  6483. }));
  6484. function finalize() {
  6485. return _finalize.apply(this, arguments);
  6486. }
  6487. return finalize;
  6488. }() // ==========================================================================
  6489. // Stream.Readable interface
  6490. }, {
  6491. key: "read",
  6492. value: function read(size) {
  6493. return this.stream.read(size);
  6494. }
  6495. }, {
  6496. key: "setEncoding",
  6497. value: function setEncoding(encoding) {
  6498. return this.stream.setEncoding(encoding);
  6499. }
  6500. }, {
  6501. key: "pause",
  6502. value: function pause() {
  6503. return this.stream.pause();
  6504. }
  6505. }, {
  6506. key: "resume",
  6507. value: function resume() {
  6508. return this.stream.resume();
  6509. }
  6510. }, {
  6511. key: "isPaused",
  6512. value: function isPaused() {
  6513. return this.stream.isPaused();
  6514. }
  6515. }, {
  6516. key: "pipe",
  6517. value: function pipe(destination, options) {
  6518. return this.stream.pipe(destination, options);
  6519. }
  6520. }, {
  6521. key: "unpipe",
  6522. value: function unpipe(destination) {
  6523. return this.stream.unpipe(destination);
  6524. }
  6525. }, {
  6526. key: "unshift",
  6527. value: function unshift(chunk) {
  6528. return this.stream.unshift(chunk);
  6529. }
  6530. }, {
  6531. key: "wrap",
  6532. value: function wrap(stream) {
  6533. return this.stream.wrap(stream);
  6534. }
  6535. }]);
  6536. return ZipWriter;
  6537. }(events.EventEmitter); // =============================================================================
  6538. module.exports = {
  6539. ZipWriter: ZipWriter
  6540. };
  6541. }).call(this, require('_process'))
  6542. }, { "./browser-buffer-encode": 17, "./stream-buf": 23, "_process": 467, "events": 367, "jszip": 399 }], 29: [function (require, module, exports) {
  6543. "use strict";
  6544. module.exports = {
  6545. 0: {
  6546. f: 'General'
  6547. },
  6548. 1: {
  6549. f: '0'
  6550. },
  6551. 2: {
  6552. f: '0.00'
  6553. },
  6554. 3: {
  6555. f: '#,##0'
  6556. },
  6557. 4: {
  6558. f: '#,##0.00'
  6559. },
  6560. 9: {
  6561. f: '0%'
  6562. },
  6563. 10: {
  6564. f: '0.00%'
  6565. },
  6566. 11: {
  6567. f: '0.00E+00'
  6568. },
  6569. 12: {
  6570. f: '# ?/?'
  6571. },
  6572. 13: {
  6573. f: '# ??/??'
  6574. },
  6575. 14: {
  6576. f: 'mm-dd-yy'
  6577. },
  6578. 15: {
  6579. f: 'd-mmm-yy'
  6580. },
  6581. 16: {
  6582. f: 'd-mmm'
  6583. },
  6584. 17: {
  6585. f: 'mmm-yy'
  6586. },
  6587. 18: {
  6588. f: 'h:mm AM/PM'
  6589. },
  6590. 19: {
  6591. f: 'h:mm:ss AM/PM'
  6592. },
  6593. 20: {
  6594. f: 'h:mm'
  6595. },
  6596. 21: {
  6597. f: 'h:mm:ss'
  6598. },
  6599. 22: {
  6600. f: 'm/d/yy "h":mm'
  6601. },
  6602. 27: {
  6603. 'zh-tw': '[$-404]e/m/d',
  6604. 'zh-cn': 'yyyy"年"m"月"',
  6605. 'ja-jp': '[$-411]ge.m.d',
  6606. 'ko-kr': 'yyyy"年" mm"月" dd"日"'
  6607. },
  6608. 28: {
  6609. 'zh-tw': '[$-404]e"年"m"月"d"日"',
  6610. 'zh-cn': 'm"月"d"日"',
  6611. 'ja-jp': '[$-411]ggge"年"m"月"d"日"',
  6612. 'ko-kr': 'mm-dd'
  6613. },
  6614. 29: {
  6615. 'zh-tw': '[$-404]e"年"m"月"d"日"',
  6616. 'zh-cn': 'm"月"d"日"',
  6617. 'ja-jp': '[$-411]ggge"年"m"月"d"日"',
  6618. 'ko-kr': 'mm-dd'
  6619. },
  6620. 30: {
  6621. 'zh-tw': 'm/d/yy ',
  6622. 'zh-cn': 'm-d-yy',
  6623. 'ja-jp': 'm/d/yy',
  6624. 'ko-kr': 'mm-dd-yy'
  6625. },
  6626. 31: {
  6627. 'zh-tw': 'yyyy"年"m"月"d"日"',
  6628. 'zh-cn': 'yyyy"年"m"月"d"日"',
  6629. 'ja-jp': 'yyyy"年"m"月"d"日"',
  6630. 'ko-kr': 'yyyy"년" mm"월" dd"일"'
  6631. },
  6632. 32: {
  6633. 'zh-tw': 'hh"時"mm"分"',
  6634. 'zh-cn': 'h"时"mm"分"',
  6635. 'ja-jp': 'h"時"mm"分"',
  6636. 'ko-kr': 'h"시" mm"분"'
  6637. },
  6638. 33: {
  6639. 'zh-tw': 'hh"時"mm"分"ss"秒"',
  6640. 'zh-cn': 'h"时"mm"分"ss"秒"',
  6641. 'ja-jp': 'h"時"mm"分"ss"秒"',
  6642. 'ko-kr': 'h"시" mm"분" ss"초"'
  6643. },
  6644. 34: {
  6645. 'zh-tw': '上午/下午 hh"時"mm"分"',
  6646. 'zh-cn': '上午/下午 h"时"mm"分"',
  6647. 'ja-jp': 'yyyy"年"m"月"',
  6648. 'ko-kr': 'yyyy-mm-dd'
  6649. },
  6650. 35: {
  6651. 'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"',
  6652. 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"',
  6653. 'ja-jp': 'm"月"d"日"',
  6654. 'ko-kr': 'yyyy-mm-dd'
  6655. },
  6656. 36: {
  6657. 'zh-tw': '[$-404]e/m/d',
  6658. 'zh-cn': 'yyyy"年"m"月"',
  6659. 'ja-jp': '[$-411]ge.m.d',
  6660. 'ko-kr': 'yyyy"年" mm"月" dd"日"'
  6661. },
  6662. 37: {
  6663. f: '#,##0 ;(#,##0)'
  6664. },
  6665. 38: {
  6666. f: '#,##0 ;[Red](#,##0)'
  6667. },
  6668. 39: {
  6669. f: '#,##0.00 ;(#,##0.00)'
  6670. },
  6671. 40: {
  6672. f: '#,##0.00 ;[Red](#,##0.00)'
  6673. },
  6674. 45: {
  6675. f: 'mm:ss'
  6676. },
  6677. 46: {
  6678. f: '[h]:mm:ss'
  6679. },
  6680. 47: {
  6681. f: 'mmss.0'
  6682. },
  6683. 48: {
  6684. f: '##0.0E+0'
  6685. },
  6686. 49: {
  6687. f: '@'
  6688. },
  6689. 50: {
  6690. 'zh-tw': '[$-404]e/m/d',
  6691. 'zh-cn': 'yyyy"年"m"月"',
  6692. 'ja-jp': '[$-411]ge.m.d',
  6693. 'ko-kr': 'yyyy"年" mm"月" dd"日"'
  6694. },
  6695. 51: {
  6696. 'zh-tw': '[$-404]e"年"m"月"d"日"',
  6697. 'zh-cn': 'm"月"d"日"',
  6698. 'ja-jp': '[$-411]ggge"年"m"月"d"日"',
  6699. 'ko-kr': 'mm-dd'
  6700. },
  6701. 52: {
  6702. 'zh-tw': '上午/下午 hh"時"mm"分"',
  6703. 'zh-cn': 'yyyy"年"m"月"',
  6704. 'ja-jp': 'yyyy"年"m"月"',
  6705. 'ko-kr': 'yyyy-mm-dd'
  6706. },
  6707. 53: {
  6708. 'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"',
  6709. 'zh-cn': 'm"月"d"日"',
  6710. 'ja-jp': 'm"月"d"日"',
  6711. 'ko-kr': 'yyyy-mm-dd'
  6712. },
  6713. 54: {
  6714. 'zh-tw': '[$-404]e"年"m"月"d"日"',
  6715. 'zh-cn': 'm"月"d"日"',
  6716. 'ja-jp': '[$-411]ggge"年"m"月"d"日"',
  6717. 'ko-kr': 'mm-dd'
  6718. },
  6719. 55: {
  6720. 'zh-tw': '上午/下午 hh"時"mm"分"',
  6721. 'zh-cn': '上午/下午 h"时"mm"分"',
  6722. 'ja-jp': 'yyyy"年"m"月"',
  6723. 'ko-kr': 'yyyy-mm-dd'
  6724. },
  6725. 56: {
  6726. 'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"',
  6727. 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"',
  6728. 'ja-jp': 'm"月"d"日"',
  6729. 'ko-kr': 'yyyy-mm-dd'
  6730. },
  6731. 57: {
  6732. 'zh-tw': '[$-404]e/m/d',
  6733. 'zh-cn': 'yyyy"年"m"月"',
  6734. 'ja-jp': '[$-411]ge.m.d',
  6735. 'ko-kr': 'yyyy"年" mm"月" dd"日"'
  6736. },
  6737. 58: {
  6738. 'zh-tw': '[$-404]e"年"m"月"d"日"',
  6739. 'zh-cn': 'm"月"d"日"',
  6740. 'ja-jp': '[$-411]ggge"年"m"月"d"日"',
  6741. 'ko-kr': 'mm-dd'
  6742. },
  6743. 59: {
  6744. 'th-th': 't0'
  6745. },
  6746. 60: {
  6747. 'th-th': 't0.00'
  6748. },
  6749. 61: {
  6750. 'th-th': 't#,##0'
  6751. },
  6752. 62: {
  6753. 'th-th': 't#,##0.00'
  6754. },
  6755. 67: {
  6756. 'th-th': 't0%'
  6757. },
  6758. 68: {
  6759. 'th-th': 't0.00%'
  6760. },
  6761. 69: {
  6762. 'th-th': 't# ?/?'
  6763. },
  6764. 70: {
  6765. 'th-th': 't# ??/??'
  6766. },
  6767. 81: {
  6768. 'th-th': 'd/m/bb'
  6769. }
  6770. };
  6771. }, {}], 30: [function (require, module, exports) {
  6772. 'use strict';
  6773. module.exports = {
  6774. OfficeDocument: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
  6775. Worksheet: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet',
  6776. CalcChain: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain',
  6777. SharedStrings: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings',
  6778. Styles: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
  6779. Theme: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
  6780. Hyperlink: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
  6781. Image: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
  6782. CoreProperties: 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
  6783. ExtenderProperties: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
  6784. Comments: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments',
  6785. VmlDrawing: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
  6786. Table: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/table'
  6787. };
  6788. }, {}], 31: [function (require, module, exports) {
  6789. "use strict";
  6790. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() { }; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  6791. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6792. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6793. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  6794. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  6795. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6796. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6797. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6798. function _asyncIterator(iterable) { var method; if (typeof Symbol !== "undefined") { if (Symbol.asyncIterator) { method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { method = iterable[Symbol.iterator]; if (method != null) return method.call(iterable); } } throw new TypeError("Object is not async iterable"); }
  6799. var parseSax = require('../../utils/parse-sax');
  6800. var XmlStream = require('../../utils/xml-stream');
  6801. /* 'virtual' methods used as a form of documentation */
  6802. /* eslint-disable class-methods-use-this */
  6803. // Base class for Xforms
  6804. var BaseXform = /*#__PURE__*/function () {
  6805. function BaseXform() {
  6806. _classCallCheck(this, BaseXform);
  6807. }
  6808. _createClass(BaseXform, [{
  6809. key: "prepare",
  6810. // constructor(/* model, name */) {}
  6811. // ============================================================
  6812. // Virtual Interface
  6813. value: function prepare()
  6814. /* model, options */ {// optional preparation (mutation) of model so it is ready for write
  6815. }
  6816. }, {
  6817. key: "render",
  6818. value: function render()
  6819. /* xmlStream, model */ {// convert model to xml
  6820. }
  6821. }, {
  6822. key: "parseOpen",
  6823. value: function parseOpen(node) {// XML node opened
  6824. }
  6825. }, {
  6826. key: "parseText",
  6827. value: function parseText(text) {// chunk of text encountered for current node
  6828. }
  6829. }, {
  6830. key: "parseClose",
  6831. value: function parseClose(name) {// XML node closed
  6832. }
  6833. }, {
  6834. key: "reconcile",
  6835. value: function reconcile(model, options) {// optional post-parse step (opposite to prepare)
  6836. } // ============================================================
  6837. }, {
  6838. key: "reset",
  6839. value: function reset() {
  6840. // to make sure parses don't bleed to next iteration
  6841. this.model = null; // if we have a map - reset them too
  6842. if (this.map) {
  6843. Object.values(this.map).forEach(function (xform) {
  6844. if (xform instanceof BaseXform) {
  6845. xform.reset();
  6846. } else if (xform.xform) {
  6847. xform.xform.reset();
  6848. }
  6849. });
  6850. }
  6851. }
  6852. }, {
  6853. key: "mergeModel",
  6854. value: function mergeModel(obj) {
  6855. // set obj's props to this.model
  6856. this.model = Object.assign(this.model || {}, obj);
  6857. }
  6858. }, {
  6859. key: "parse",
  6860. value: function () {
  6861. var _parse = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(saxParser) {
  6862. var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, events, _iterator2, _step2, _step2$value, eventType, value;
  6863. return regeneratorRuntime.wrap(function _callee$(_context) {
  6864. while (1) {
  6865. switch (_context.prev = _context.next) {
  6866. case 0:
  6867. _iteratorNormalCompletion = true;
  6868. _didIteratorError = false;
  6869. _context.prev = 2;
  6870. _iterator = _asyncIterator(saxParser);
  6871. case 4:
  6872. _context.next = 6;
  6873. return _iterator.next();
  6874. case 6:
  6875. _step = _context.sent;
  6876. _iteratorNormalCompletion = _step.done;
  6877. _context.next = 10;
  6878. return _step.value;
  6879. case 10:
  6880. _value = _context.sent;
  6881. if (_iteratorNormalCompletion) {
  6882. _context.next = 42;
  6883. break;
  6884. }
  6885. events = _value;
  6886. _iterator2 = _createForOfIteratorHelper(events);
  6887. _context.prev = 14;
  6888. _iterator2.s();
  6889. case 16:
  6890. if ((_step2 = _iterator2.n()).done) {
  6891. _context.next = 31;
  6892. break;
  6893. }
  6894. _step2$value = _step2.value, eventType = _step2$value.eventType, value = _step2$value.value;
  6895. if (!(eventType === 'opentag')) {
  6896. _context.next = 22;
  6897. break;
  6898. }
  6899. this.parseOpen(value);
  6900. _context.next = 29;
  6901. break;
  6902. case 22:
  6903. if (!(eventType === 'text')) {
  6904. _context.next = 26;
  6905. break;
  6906. }
  6907. this.parseText(value);
  6908. _context.next = 29;
  6909. break;
  6910. case 26:
  6911. if (!(eventType === 'closetag')) {
  6912. _context.next = 29;
  6913. break;
  6914. }
  6915. if (this.parseClose(value.name)) {
  6916. _context.next = 29;
  6917. break;
  6918. }
  6919. return _context.abrupt("return", this.model);
  6920. case 29:
  6921. _context.next = 16;
  6922. break;
  6923. case 31:
  6924. _context.next = 36;
  6925. break;
  6926. case 33:
  6927. _context.prev = 33;
  6928. _context.t0 = _context["catch"](14);
  6929. _iterator2.e(_context.t0);
  6930. case 36:
  6931. _context.prev = 36;
  6932. _iterator2.f();
  6933. return _context.finish(36);
  6934. case 39:
  6935. _iteratorNormalCompletion = true;
  6936. _context.next = 4;
  6937. break;
  6938. case 42:
  6939. _context.next = 48;
  6940. break;
  6941. case 44:
  6942. _context.prev = 44;
  6943. _context.t1 = _context["catch"](2);
  6944. _didIteratorError = true;
  6945. _iteratorError = _context.t1;
  6946. case 48:
  6947. _context.prev = 48;
  6948. _context.prev = 49;
  6949. if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
  6950. _context.next = 53;
  6951. break;
  6952. }
  6953. _context.next = 53;
  6954. return _iterator.return();
  6955. case 53:
  6956. _context.prev = 53;
  6957. if (!_didIteratorError) {
  6958. _context.next = 56;
  6959. break;
  6960. }
  6961. throw _iteratorError;
  6962. case 56:
  6963. return _context.finish(53);
  6964. case 57:
  6965. return _context.finish(48);
  6966. case 58:
  6967. return _context.abrupt("return", this.model);
  6968. case 59:
  6969. case "end":
  6970. return _context.stop();
  6971. }
  6972. }
  6973. }, _callee, this, [[2, 44, 48, 58], [14, 33, 36, 39], [49, , 53, 57]]);
  6974. }));
  6975. function parse(_x) {
  6976. return _parse.apply(this, arguments);
  6977. }
  6978. return parse;
  6979. }()
  6980. }, {
  6981. key: "parseStream",
  6982. value: function () {
  6983. var _parseStream = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(stream) {
  6984. return regeneratorRuntime.wrap(function _callee2$(_context2) {
  6985. while (1) {
  6986. switch (_context2.prev = _context2.next) {
  6987. case 0:
  6988. return _context2.abrupt("return", this.parse(parseSax(stream)));
  6989. case 1:
  6990. case "end":
  6991. return _context2.stop();
  6992. }
  6993. }
  6994. }, _callee2, this);
  6995. }));
  6996. function parseStream(_x2) {
  6997. return _parseStream.apply(this, arguments);
  6998. }
  6999. return parseStream;
  7000. }()
  7001. }, {
  7002. key: "toXml",
  7003. value: function toXml(model) {
  7004. var xmlStream = new XmlStream();
  7005. this.render(xmlStream, model);
  7006. return xmlStream.xml;
  7007. } // ============================================================
  7008. // Useful Utilities
  7009. }, {
  7010. key: "xml",
  7011. get: function get() {
  7012. // convenience function to get the xml of this.model
  7013. // useful for manager types that are built during the prepare phase
  7014. return this.toXml(this.model);
  7015. }
  7016. }], [{
  7017. key: "toAttribute",
  7018. value: function toAttribute(value, dflt) {
  7019. var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7020. if (value === undefined) {
  7021. if (always) {
  7022. return dflt;
  7023. }
  7024. } else if (always || value !== dflt) {
  7025. return value.toString();
  7026. }
  7027. return undefined;
  7028. }
  7029. }, {
  7030. key: "toStringAttribute",
  7031. value: function toStringAttribute(value, dflt) {
  7032. var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7033. return BaseXform.toAttribute(value, dflt, always);
  7034. }
  7035. }, {
  7036. key: "toStringValue",
  7037. value: function toStringValue(attr, dflt) {
  7038. return attr === undefined ? dflt : attr;
  7039. }
  7040. }, {
  7041. key: "toBoolAttribute",
  7042. value: function toBoolAttribute(value, dflt) {
  7043. var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7044. if (value === undefined) {
  7045. if (always) {
  7046. return dflt;
  7047. }
  7048. } else if (always || value !== dflt) {
  7049. return value ? '1' : '0';
  7050. }
  7051. return undefined;
  7052. }
  7053. }, {
  7054. key: "toBoolValue",
  7055. value: function toBoolValue(attr, dflt) {
  7056. return attr === undefined ? dflt : attr === '1';
  7057. }
  7058. }, {
  7059. key: "toIntAttribute",
  7060. value: function toIntAttribute(value, dflt) {
  7061. var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7062. return BaseXform.toAttribute(value, dflt, always);
  7063. }
  7064. }, {
  7065. key: "toIntValue",
  7066. value: function toIntValue(attr, dflt) {
  7067. return attr === undefined ? dflt : parseInt(attr, 10);
  7068. }
  7069. }, {
  7070. key: "toFloatAttribute",
  7071. value: function toFloatAttribute(value, dflt) {
  7072. var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7073. return BaseXform.toAttribute(value, dflt, always);
  7074. }
  7075. }, {
  7076. key: "toFloatValue",
  7077. value: function toFloatValue(attr, dflt) {
  7078. return attr === undefined ? dflt : parseFloat(attr);
  7079. }
  7080. }]);
  7081. return BaseXform;
  7082. }();
  7083. module.exports = BaseXform;
  7084. }, { "../../utils/parse-sax": 21, "../../utils/xml-stream": 27 }], 32: [function (require, module, exports) {
  7085. "use strict";
  7086. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7087. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7088. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7089. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7090. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7091. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7092. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7093. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7094. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7095. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  7096. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7097. var BaseXform = require('../base-xform');
  7098. var colCache = require('../../../utils/col-cache');
  7099. var DefinedNamesXform = /*#__PURE__*/function (_BaseXform) {
  7100. _inherits(DefinedNamesXform, _BaseXform);
  7101. var _super = _createSuper(DefinedNamesXform);
  7102. function DefinedNamesXform() {
  7103. _classCallCheck(this, DefinedNamesXform);
  7104. return _super.apply(this, arguments);
  7105. }
  7106. _createClass(DefinedNamesXform, [{
  7107. key: "render",
  7108. value: function render(xmlStream, model) {
  7109. // <definedNames>
  7110. // <definedName name="name">name.ranges.join(',')</definedName>
  7111. // <definedName name="_xlnm.Print_Area" localSheetId="0">name.ranges.join(',')</definedName>
  7112. // </definedNames>
  7113. xmlStream.openNode('definedName', {
  7114. name: model.name,
  7115. localSheetId: model.localSheetId
  7116. });
  7117. xmlStream.writeText(model.ranges.join(','));
  7118. xmlStream.closeNode();
  7119. }
  7120. }, {
  7121. key: "parseOpen",
  7122. value: function parseOpen(node) {
  7123. switch (node.name) {
  7124. case 'definedName':
  7125. this._parsedName = node.attributes.name;
  7126. this._parsedLocalSheetId = node.attributes.localSheetId;
  7127. this._parsedText = [];
  7128. return true;
  7129. default:
  7130. return false;
  7131. }
  7132. }
  7133. }, {
  7134. key: "parseText",
  7135. value: function parseText(text) {
  7136. this._parsedText.push(text);
  7137. }
  7138. }, {
  7139. key: "parseClose",
  7140. value: function parseClose() {
  7141. this.model = {
  7142. name: this._parsedName,
  7143. ranges: extractRanges(this._parsedText.join(''))
  7144. };
  7145. if (this._parsedLocalSheetId !== undefined) {
  7146. this.model.localSheetId = parseInt(this._parsedLocalSheetId, 10);
  7147. }
  7148. return false;
  7149. }
  7150. }]);
  7151. return DefinedNamesXform;
  7152. }(BaseXform);
  7153. function isValidRange(range) {
  7154. try {
  7155. colCache.decodeEx(range);
  7156. return true;
  7157. } catch (err) {
  7158. return false;
  7159. }
  7160. }
  7161. function extractRanges(parsedText) {
  7162. var ranges = [];
  7163. var quotesOpened = false;
  7164. var last = '';
  7165. parsedText.split(',').forEach(function (item) {
  7166. if (!item) {
  7167. return;
  7168. }
  7169. var quotes = (item.match(/'/g) || []).length;
  7170. if (!quotes) {
  7171. if (quotesOpened) {
  7172. last += "".concat(item, ",");
  7173. } else if (isValidRange(item)) {
  7174. ranges.push(item);
  7175. }
  7176. return;
  7177. }
  7178. var quotesEven = quotes % 2 === 0;
  7179. if (!quotesOpened && quotesEven && isValidRange(item)) {
  7180. ranges.push(item);
  7181. } else if (quotesOpened && !quotesEven) {
  7182. quotesOpened = false;
  7183. if (isValidRange(last + item)) {
  7184. ranges.push(last + item);
  7185. }
  7186. last = '';
  7187. } else {
  7188. quotesOpened = true;
  7189. last += "".concat(item, ",");
  7190. }
  7191. });
  7192. return ranges;
  7193. }
  7194. module.exports = DefinedNamesXform;
  7195. }, { "../../../utils/col-cache": 19, "../base-xform": 31 }], 33: [function (require, module, exports) {
  7196. "use strict";
  7197. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7198. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7199. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7200. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7201. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7202. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7203. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7204. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7205. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7206. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  7207. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7208. var utils = require('../../../utils/utils');
  7209. var BaseXform = require('../base-xform');
  7210. var WorksheetXform = /*#__PURE__*/function (_BaseXform) {
  7211. _inherits(WorksheetXform, _BaseXform);
  7212. var _super = _createSuper(WorksheetXform);
  7213. function WorksheetXform() {
  7214. _classCallCheck(this, WorksheetXform);
  7215. return _super.apply(this, arguments);
  7216. }
  7217. _createClass(WorksheetXform, [{
  7218. key: "render",
  7219. value: function render(xmlStream, model) {
  7220. xmlStream.leafNode('sheet', {
  7221. sheetId: model.id,
  7222. name: model.name,
  7223. state: model.state,
  7224. 'r:id': model.rId
  7225. });
  7226. }
  7227. }, {
  7228. key: "parseOpen",
  7229. value: function parseOpen(node) {
  7230. if (node.name === 'sheet') {
  7231. this.model = {
  7232. name: utils.xmlDecode(node.attributes.name),
  7233. id: parseInt(node.attributes.sheetId, 10),
  7234. state: node.attributes.state,
  7235. rId: node.attributes['r:id']
  7236. };
  7237. return true;
  7238. }
  7239. return false;
  7240. }
  7241. }, {
  7242. key: "parseText",
  7243. value: function parseText() { }
  7244. }, {
  7245. key: "parseClose",
  7246. value: function parseClose() {
  7247. return false;
  7248. }
  7249. }]);
  7250. return WorksheetXform;
  7251. }(BaseXform);
  7252. module.exports = WorksheetXform;
  7253. }, { "../../../utils/utils": 26, "../base-xform": 31 }], 34: [function (require, module, exports) {
  7254. "use strict";
  7255. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7256. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7257. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7258. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7259. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7260. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7261. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7262. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7263. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7264. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  7265. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7266. var BaseXform = require('../base-xform');
  7267. var WorkbookCalcPropertiesXform = /*#__PURE__*/function (_BaseXform) {
  7268. _inherits(WorkbookCalcPropertiesXform, _BaseXform);
  7269. var _super = _createSuper(WorkbookCalcPropertiesXform);
  7270. function WorkbookCalcPropertiesXform() {
  7271. _classCallCheck(this, WorkbookCalcPropertiesXform);
  7272. return _super.apply(this, arguments);
  7273. }
  7274. _createClass(WorkbookCalcPropertiesXform, [{
  7275. key: "render",
  7276. value: function render(xmlStream, model) {
  7277. xmlStream.leafNode('calcPr', {
  7278. calcId: 171027,
  7279. fullCalcOnLoad: model.fullCalcOnLoad ? 1 : undefined
  7280. });
  7281. }
  7282. }, {
  7283. key: "parseOpen",
  7284. value: function parseOpen(node) {
  7285. if (node.name === 'calcPr') {
  7286. this.model = {};
  7287. return true;
  7288. }
  7289. return false;
  7290. }
  7291. }, {
  7292. key: "parseText",
  7293. value: function parseText() { }
  7294. }, {
  7295. key: "parseClose",
  7296. value: function parseClose() {
  7297. return false;
  7298. }
  7299. }]);
  7300. return WorkbookCalcPropertiesXform;
  7301. }(BaseXform);
  7302. module.exports = WorkbookCalcPropertiesXform;
  7303. }, { "../base-xform": 31 }], 35: [function (require, module, exports) {
  7304. "use strict";
  7305. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7306. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7307. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7308. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7309. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7310. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7311. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7312. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7313. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7314. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  7315. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7316. var BaseXform = require('../base-xform');
  7317. var WorksheetPropertiesXform = /*#__PURE__*/function (_BaseXform) {
  7318. _inherits(WorksheetPropertiesXform, _BaseXform);
  7319. var _super = _createSuper(WorksheetPropertiesXform);
  7320. function WorksheetPropertiesXform() {
  7321. _classCallCheck(this, WorksheetPropertiesXform);
  7322. return _super.apply(this, arguments);
  7323. }
  7324. _createClass(WorksheetPropertiesXform, [{
  7325. key: "render",
  7326. value: function render(xmlStream, model) {
  7327. xmlStream.leafNode('workbookPr', {
  7328. date1904: model.date1904 ? 1 : undefined,
  7329. defaultThemeVersion: 164011,
  7330. filterPrivacy: 1
  7331. });
  7332. }
  7333. }, {
  7334. key: "parseOpen",
  7335. value: function parseOpen(node) {
  7336. if (node.name === 'workbookPr') {
  7337. this.model = {
  7338. date1904: node.attributes.date1904 === '1'
  7339. };
  7340. return true;
  7341. }
  7342. return false;
  7343. }
  7344. }, {
  7345. key: "parseText",
  7346. value: function parseText() { }
  7347. }, {
  7348. key: "parseClose",
  7349. value: function parseClose() {
  7350. return false;
  7351. }
  7352. }]);
  7353. return WorksheetPropertiesXform;
  7354. }(BaseXform);
  7355. module.exports = WorksheetPropertiesXform;
  7356. }, { "../base-xform": 31 }], 36: [function (require, module, exports) {
  7357. "use strict";
  7358. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7359. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7360. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7361. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7362. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7363. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7364. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7365. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7366. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7367. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  7368. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7369. var BaseXform = require('../base-xform');
  7370. var WorkbookViewXform = /*#__PURE__*/function (_BaseXform) {
  7371. _inherits(WorkbookViewXform, _BaseXform);
  7372. var _super = _createSuper(WorkbookViewXform);
  7373. function WorkbookViewXform() {
  7374. _classCallCheck(this, WorkbookViewXform);
  7375. return _super.apply(this, arguments);
  7376. }
  7377. _createClass(WorkbookViewXform, [{
  7378. key: "render",
  7379. value: function render(xmlStream, model) {
  7380. var attributes = {
  7381. xWindow: model.x || 0,
  7382. yWindow: model.y || 0,
  7383. windowWidth: model.width || 12000,
  7384. windowHeight: model.height || 24000,
  7385. firstSheet: model.firstSheet,
  7386. activeTab: model.activeTab
  7387. };
  7388. if (model.visibility && model.visibility !== 'visible') {
  7389. attributes.visibility = model.visibility;
  7390. }
  7391. xmlStream.leafNode('workbookView', attributes);
  7392. }
  7393. }, {
  7394. key: "parseOpen",
  7395. value: function parseOpen(node) {
  7396. if (node.name === 'workbookView') {
  7397. var model = this.model = {};
  7398. var addS = function addS(name, value, dflt) {
  7399. var s = value !== undefined ? model[name] = value : dflt;
  7400. if (s !== undefined) {
  7401. model[name] = s;
  7402. }
  7403. };
  7404. var addN = function addN(name, value, dflt) {
  7405. var n = value !== undefined ? model[name] = parseInt(value, 10) : dflt;
  7406. if (n !== undefined) {
  7407. model[name] = n;
  7408. }
  7409. };
  7410. addN('x', node.attributes.xWindow, 0);
  7411. addN('y', node.attributes.yWindow, 0);
  7412. addN('width', node.attributes.windowWidth, 25000);
  7413. addN('height', node.attributes.windowHeight, 10000);
  7414. addS('visibility', node.attributes.visibility, 'visible');
  7415. addN('activeTab', node.attributes.activeTab, undefined);
  7416. addN('firstSheet', node.attributes.firstSheet, undefined);
  7417. return true;
  7418. }
  7419. return false;
  7420. }
  7421. }, {
  7422. key: "parseText",
  7423. value: function parseText() { }
  7424. }, {
  7425. key: "parseClose",
  7426. value: function parseClose() {
  7427. return false;
  7428. }
  7429. }]);
  7430. return WorkbookViewXform;
  7431. }(BaseXform);
  7432. module.exports = WorkbookViewXform;
  7433. }, { "../base-xform": 31 }], 37: [function (require, module, exports) {
  7434. "use strict";
  7435. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7436. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7437. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7438. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7439. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7440. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7441. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7442. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7443. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7444. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  7445. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7446. var _ = require('../../../utils/under-dash');
  7447. var colCache = require('../../../utils/col-cache');
  7448. var XmlStream = require('../../../utils/xml-stream');
  7449. var BaseXform = require('../base-xform');
  7450. var StaticXform = require('../static-xform');
  7451. var ListXform = require('../list-xform');
  7452. var DefinedNameXform = require('./defined-name-xform');
  7453. var SheetXform = require('./sheet-xform');
  7454. var WorkbookViewXform = require('./workbook-view-xform');
  7455. var WorkbookPropertiesXform = require('./workbook-properties-xform');
  7456. var WorkbookCalcPropertiesXform = require('./workbook-calc-properties-xform');
  7457. var WorkbookXform = /*#__PURE__*/function (_BaseXform) {
  7458. _inherits(WorkbookXform, _BaseXform);
  7459. var _super = _createSuper(WorkbookXform);
  7460. function WorkbookXform() {
  7461. var _this;
  7462. _classCallCheck(this, WorkbookXform);
  7463. _this = _super.call(this);
  7464. _this.map = {
  7465. fileVersion: WorkbookXform.STATIC_XFORMS.fileVersion,
  7466. workbookPr: new WorkbookPropertiesXform(),
  7467. bookViews: new ListXform({
  7468. tag: 'bookViews',
  7469. count: false,
  7470. childXform: new WorkbookViewXform()
  7471. }),
  7472. sheets: new ListXform({
  7473. tag: 'sheets',
  7474. count: false,
  7475. childXform: new SheetXform()
  7476. }),
  7477. definedNames: new ListXform({
  7478. tag: 'definedNames',
  7479. count: false,
  7480. childXform: new DefinedNameXform()
  7481. }),
  7482. calcPr: new WorkbookCalcPropertiesXform()
  7483. };
  7484. return _this;
  7485. }
  7486. _createClass(WorkbookXform, [{
  7487. key: "prepare",
  7488. value: function prepare(model) {
  7489. model.sheets = model.worksheets; // collate all the print areas from all of the sheets and add them to the defined names
  7490. var printAreas = [];
  7491. var index = 0; // sheets is sparse array - calc index manually
  7492. model.sheets.forEach(function (sheet) {
  7493. if (sheet.pageSetup && sheet.pageSetup.printArea) {
  7494. sheet.pageSetup.printArea.split('&&').forEach(function (printArea) {
  7495. var printAreaComponents = printArea.split(':');
  7496. var definedName = {
  7497. name: '_xlnm.Print_Area',
  7498. ranges: ["'".concat(sheet.name, "'!$").concat(printAreaComponents[0], ":$").concat(printAreaComponents[1])],
  7499. localSheetId: index
  7500. };
  7501. printAreas.push(definedName);
  7502. });
  7503. }
  7504. if (sheet.pageSetup && (sheet.pageSetup.printTitlesRow || sheet.pageSetup.printTitlesColumn)) {
  7505. var ranges = [];
  7506. if (sheet.pageSetup.printTitlesColumn) {
  7507. var titlesColumns = sheet.pageSetup.printTitlesColumn.split(':');
  7508. ranges.push("'".concat(sheet.name, "'!$").concat(titlesColumns[0], ":$").concat(titlesColumns[1]));
  7509. }
  7510. if (sheet.pageSetup.printTitlesRow) {
  7511. var titlesRows = sheet.pageSetup.printTitlesRow.split(':');
  7512. ranges.push("'".concat(sheet.name, "'!$").concat(titlesRows[0], ":$").concat(titlesRows[1]));
  7513. }
  7514. var definedName = {
  7515. name: '_xlnm.Print_Titles',
  7516. ranges: ranges,
  7517. localSheetId: index
  7518. };
  7519. printAreas.push(definedName);
  7520. }
  7521. index++;
  7522. });
  7523. if (printAreas.length) {
  7524. model.definedNames = model.definedNames.concat(printAreas);
  7525. }
  7526. (model.media || []).forEach(function (medium, i) {
  7527. // assign name
  7528. medium.name = medium.type + (i + 1);
  7529. });
  7530. }
  7531. }, {
  7532. key: "render",
  7533. value: function render(xmlStream, model) {
  7534. xmlStream.openXml(XmlStream.StdDocAttributes);
  7535. xmlStream.openNode('workbook', WorkbookXform.WORKBOOK_ATTRIBUTES);
  7536. this.map.fileVersion.render(xmlStream);
  7537. this.map.workbookPr.render(xmlStream, model.properties);
  7538. this.map.bookViews.render(xmlStream, model.views);
  7539. this.map.sheets.render(xmlStream, model.sheets);
  7540. this.map.definedNames.render(xmlStream, model.definedNames);
  7541. this.map.calcPr.render(xmlStream, model.calcProperties);
  7542. xmlStream.closeNode();
  7543. }
  7544. }, {
  7545. key: "parseOpen",
  7546. value: function parseOpen(node) {
  7547. if (this.parser) {
  7548. this.parser.parseOpen(node);
  7549. return true;
  7550. }
  7551. switch (node.name) {
  7552. case 'workbook':
  7553. return true;
  7554. default:
  7555. this.parser = this.map[node.name];
  7556. if (this.parser) {
  7557. this.parser.parseOpen(node);
  7558. }
  7559. return true;
  7560. }
  7561. }
  7562. }, {
  7563. key: "parseText",
  7564. value: function parseText(text) {
  7565. if (this.parser) {
  7566. this.parser.parseText(text);
  7567. }
  7568. }
  7569. }, {
  7570. key: "parseClose",
  7571. value: function parseClose(name) {
  7572. if (this.parser) {
  7573. if (!this.parser.parseClose(name)) {
  7574. this.parser = undefined;
  7575. }
  7576. return true;
  7577. }
  7578. switch (name) {
  7579. case 'workbook':
  7580. this.model = {
  7581. sheets: this.map.sheets.model,
  7582. properties: this.map.workbookPr.model || {},
  7583. views: this.map.bookViews.model,
  7584. calcProperties: {}
  7585. };
  7586. if (this.map.definedNames.model) {
  7587. this.model.definedNames = this.map.definedNames.model;
  7588. }
  7589. return false;
  7590. default:
  7591. // not quite sure how we get here!
  7592. return true;
  7593. }
  7594. }
  7595. }, {
  7596. key: "reconcile",
  7597. value: function reconcile(model) {
  7598. var rels = (model.workbookRels || []).reduce(function (map, rel) {
  7599. map[rel.Id] = rel;
  7600. return map;
  7601. }, {}); // reconcile sheet ids, rIds and names
  7602. var worksheets = [];
  7603. var worksheet;
  7604. var index = 0;
  7605. (model.sheets || []).forEach(function (sheet) {
  7606. var rel = rels[sheet.rId];
  7607. if (!rel) {
  7608. return;
  7609. } // if rel.Target start with `[space]/xl/` or `/xl/` , then it will be replaced with `''` and spliced behind `xl/`,
  7610. // otherwise it will be spliced directly behind `xl/`. i.g.
  7611. worksheet = model.worksheetHash["xl/".concat(rel.Target.replace(/^(\s|\/xl\/)+/, ''))]; // If there are "chartsheets" in the file, rel.Target will
  7612. // come out as chartsheets/sheet1.xml or similar here, and
  7613. // that won't be in model.worksheetHash.
  7614. // As we don't have the infrastructure to support chartsheets,
  7615. // we will ignore them for now:
  7616. if (worksheet) {
  7617. worksheet.name = sheet.name;
  7618. worksheet.id = sheet.id;
  7619. worksheet.state = sheet.state;
  7620. worksheets[index++] = worksheet;
  7621. }
  7622. }); // reconcile print areas
  7623. var definedNames = [];
  7624. _.each(model.definedNames, function (definedName) {
  7625. if (definedName.name === '_xlnm.Print_Area') {
  7626. worksheet = worksheets[definedName.localSheetId];
  7627. if (worksheet) {
  7628. if (!worksheet.pageSetup) {
  7629. worksheet.pageSetup = {};
  7630. }
  7631. var range = colCache.decodeEx(definedName.ranges[0]);
  7632. worksheet.pageSetup.printArea = worksheet.pageSetup.printArea ? "".concat(worksheet.pageSetup.printArea, "&&").concat(range.dimensions) : range.dimensions;
  7633. }
  7634. } else if (definedName.name === '_xlnm.Print_Titles') {
  7635. worksheet = worksheets[definedName.localSheetId];
  7636. if (worksheet) {
  7637. if (!worksheet.pageSetup) {
  7638. worksheet.pageSetup = {};
  7639. }
  7640. var rangeString = definedName.ranges.join(',');
  7641. var dollarRegex = /\$/g;
  7642. var rowRangeRegex = /\$\d+:\$\d+/;
  7643. var rowRangeMatches = rangeString.match(rowRangeRegex);
  7644. if (rowRangeMatches && rowRangeMatches.length) {
  7645. var _range = rowRangeMatches[0];
  7646. worksheet.pageSetup.printTitlesRow = _range.replace(dollarRegex, '');
  7647. }
  7648. var columnRangeRegex = /\$[A-Z]+:\$[A-Z]+/;
  7649. var columnRangeMatches = rangeString.match(columnRangeRegex);
  7650. if (columnRangeMatches && columnRangeMatches.length) {
  7651. var _range2 = columnRangeMatches[0];
  7652. worksheet.pageSetup.printTitlesColumn = _range2.replace(dollarRegex, '');
  7653. }
  7654. }
  7655. } else {
  7656. definedNames.push(definedName);
  7657. }
  7658. });
  7659. model.definedNames = definedNames; // used by sheets to build their image models
  7660. model.media.forEach(function (media, i) {
  7661. media.index = i;
  7662. });
  7663. }
  7664. }]);
  7665. return WorkbookXform;
  7666. }(BaseXform);
  7667. WorkbookXform.WORKBOOK_ATTRIBUTES = {
  7668. xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
  7669. 'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
  7670. 'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
  7671. 'mc:Ignorable': 'x15',
  7672. 'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main'
  7673. };
  7674. WorkbookXform.STATIC_XFORMS = {
  7675. fileVersion: new StaticXform({
  7676. tag: 'fileVersion',
  7677. $: {
  7678. appName: 'xl',
  7679. lastEdited: 5,
  7680. lowestEdited: 5,
  7681. rupBuild: 9303
  7682. }
  7683. })
  7684. };
  7685. module.exports = WorkbookXform;
  7686. }, { "../../../utils/col-cache": 19, "../../../utils/under-dash": 25, "../../../utils/xml-stream": 27, "../base-xform": 31, "../list-xform": 70, "../static-xform": 119, "./defined-name-xform": 32, "./sheet-xform": 33, "./workbook-calc-properties-xform": 34, "./workbook-properties-xform": 35, "./workbook-view-xform": 36 }], 38: [function (require, module, exports) {
  7687. "use strict";
  7688. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  7689. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  7690. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  7691. var RichTextXform = require('../strings/rich-text-xform');
  7692. var utils = require('../../../utils/utils');
  7693. var BaseXform = require('../base-xform');
  7694. /**
  7695. <comment ref="B1" authorId="0">
  7696. <text>
  7697. <r>
  7698. <rPr>
  7699. <b/>
  7700. <sz val="9"/>
  7701. <rFont val="宋体"/>
  7702. <charset val="134"/>
  7703. </rPr>
  7704. <t>51422:</t>
  7705. </r>
  7706. <r>
  7707. <rPr>
  7708. <sz val="9"/>
  7709. <rFont val="宋体"/>
  7710. <charset val="134"/>
  7711. </rPr>
  7712. <t xml:space="preserve">&#10;test</t>
  7713. </r>
  7714. </text>
  7715. </comment>
  7716. */
  7717. var CommentXform = module.exports = function (model) {
  7718. this.model = model;
  7719. };
  7720. utils.inherits(CommentXform, BaseXform, {
  7721. get tag() {
  7722. return 'r';
  7723. },
  7724. get richTextXform() {
  7725. if (!this._richTextXform) {
  7726. this._richTextXform = new RichTextXform();
  7727. }
  7728. return this._richTextXform;
  7729. },
  7730. render: function render(xmlStream, model) {
  7731. var _this = this;
  7732. model = model || this.model;
  7733. xmlStream.openNode('comment', {
  7734. ref: model.ref,
  7735. authorId: 0
  7736. });
  7737. xmlStream.openNode('text');
  7738. if (model && model.note && model.note.texts) {
  7739. model.note.texts.forEach(function (text) {
  7740. _this.richTextXform.render(xmlStream, text);
  7741. });
  7742. }
  7743. xmlStream.closeNode();
  7744. xmlStream.closeNode();
  7745. },
  7746. parseOpen: function parseOpen(node) {
  7747. if (this.parser) {
  7748. this.parser.parseOpen(node);
  7749. return true;
  7750. }
  7751. switch (node.name) {
  7752. case 'comment':
  7753. this.model = _objectSpread({
  7754. type: 'note',
  7755. note: {
  7756. texts: []
  7757. }
  7758. }, node.attributes);
  7759. return true;
  7760. case 'r':
  7761. this.parser = this.richTextXform;
  7762. this.parser.parseOpen(node);
  7763. return true;
  7764. default:
  7765. return false;
  7766. }
  7767. },
  7768. parseText: function parseText(text) {
  7769. if (this.parser) {
  7770. this.parser.parseText(text);
  7771. }
  7772. },
  7773. parseClose: function parseClose(name) {
  7774. switch (name) {
  7775. case 'comment':
  7776. return false;
  7777. case 'r':
  7778. this.model.note.texts.push(this.parser.model);
  7779. this.parser = undefined;
  7780. return true;
  7781. default:
  7782. if (this.parser) {
  7783. this.parser.parseClose(name);
  7784. }
  7785. return true;
  7786. }
  7787. }
  7788. });
  7789. }, { "../../../utils/utils": 26, "../base-xform": 31, "../strings/rich-text-xform": 121 }], 39: [function (require, module, exports) {
  7790. "use strict";
  7791. var XmlStream = require('../../../utils/xml-stream');
  7792. var utils = require('../../../utils/utils');
  7793. var BaseXform = require('../base-xform');
  7794. var CommentXform = require('./comment-xform');
  7795. var CommentsXform = module.exports = function () {
  7796. this.map = {
  7797. comment: new CommentXform()
  7798. };
  7799. };
  7800. utils.inherits(CommentsXform, BaseXform, {
  7801. COMMENTS_ATTRIBUTES: {
  7802. xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'
  7803. }
  7804. }, {
  7805. render: function render(xmlStream, model) {
  7806. var _this = this;
  7807. model = model || this.model;
  7808. xmlStream.openXml(XmlStream.StdDocAttributes);
  7809. xmlStream.openNode('comments', CommentsXform.COMMENTS_ATTRIBUTES); // authors
  7810. // TODO: support authors properly
  7811. xmlStream.openNode('authors');
  7812. xmlStream.leafNode('author', null, 'Author');
  7813. xmlStream.closeNode(); // comments
  7814. xmlStream.openNode('commentList');
  7815. model.comments.forEach(function (comment) {
  7816. _this.map.comment.render(xmlStream, comment);
  7817. });
  7818. xmlStream.closeNode();
  7819. xmlStream.closeNode();
  7820. },
  7821. parseOpen: function parseOpen(node) {
  7822. if (this.parser) {
  7823. this.parser.parseOpen(node);
  7824. return true;
  7825. }
  7826. switch (node.name) {
  7827. case 'commentList':
  7828. this.model = {
  7829. comments: []
  7830. };
  7831. return true;
  7832. case 'comment':
  7833. this.parser = this.map.comment;
  7834. this.parser.parseOpen(node);
  7835. return true;
  7836. default:
  7837. return false;
  7838. }
  7839. },
  7840. parseText: function parseText(text) {
  7841. if (this.parser) {
  7842. this.parser.parseText(text);
  7843. }
  7844. },
  7845. parseClose: function parseClose(name) {
  7846. switch (name) {
  7847. case 'commentList':
  7848. return false;
  7849. case 'comment':
  7850. this.model.comments.push(this.parser.model);
  7851. this.parser = undefined;
  7852. return true;
  7853. default:
  7854. if (this.parser) {
  7855. this.parser.parseClose(name);
  7856. }
  7857. return true;
  7858. }
  7859. }
  7860. });
  7861. }, { "../../../utils/utils": 26, "../../../utils/xml-stream": 27, "../base-xform": 31, "./comment-xform": 38 }], 40: [function (require, module, exports) {
  7862. "use strict";
  7863. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7864. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7865. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7866. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7867. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7868. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7869. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7870. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7871. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7872. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  7873. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7874. var BaseXform = require('../../base-xform');
  7875. var VmlPositionXform = /*#__PURE__*/function (_BaseXform) {
  7876. _inherits(VmlPositionXform, _BaseXform);
  7877. var _super = _createSuper(VmlPositionXform);
  7878. function VmlPositionXform(model) {
  7879. var _this;
  7880. _classCallCheck(this, VmlPositionXform);
  7881. _this = _super.call(this);
  7882. _this._model = model;
  7883. return _this;
  7884. }
  7885. _createClass(VmlPositionXform, [{
  7886. key: "render",
  7887. value: function render(xmlStream, model, type) {
  7888. if (model === type[2]) {
  7889. xmlStream.leafNode(this.tag);
  7890. } else if (this.tag === 'x:SizeWithCells' && model === type[1]) {
  7891. xmlStream.leafNode(this.tag);
  7892. }
  7893. }
  7894. }, {
  7895. key: "parseOpen",
  7896. value: function parseOpen(node) {
  7897. switch (node.name) {
  7898. case this.tag:
  7899. this.model = {};
  7900. this.model[this.tag] = true;
  7901. return true;
  7902. default:
  7903. return false;
  7904. }
  7905. }
  7906. }, {
  7907. key: "parseText",
  7908. value: function parseText() { }
  7909. }, {
  7910. key: "parseClose",
  7911. value: function parseClose() {
  7912. return false;
  7913. }
  7914. }, {
  7915. key: "tag",
  7916. get: function get() {
  7917. return this._model && this._model.tag;
  7918. }
  7919. }]);
  7920. return VmlPositionXform;
  7921. }(BaseXform);
  7922. module.exports = VmlPositionXform;
  7923. }, { "../../base-xform": 31 }], 41: [function (require, module, exports) {
  7924. "use strict";
  7925. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7926. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7927. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7928. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7929. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7930. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7931. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7932. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7933. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7934. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  7935. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7936. var BaseXform = require('../../base-xform');
  7937. var VmlProtectionXform = /*#__PURE__*/function (_BaseXform) {
  7938. _inherits(VmlProtectionXform, _BaseXform);
  7939. var _super = _createSuper(VmlProtectionXform);
  7940. function VmlProtectionXform(model) {
  7941. var _this;
  7942. _classCallCheck(this, VmlProtectionXform);
  7943. _this = _super.call(this);
  7944. _this._model = model;
  7945. return _this;
  7946. }
  7947. _createClass(VmlProtectionXform, [{
  7948. key: "render",
  7949. value: function render(xmlStream, model) {
  7950. xmlStream.leafNode(this.tag, null, model);
  7951. }
  7952. }, {
  7953. key: "parseOpen",
  7954. value: function parseOpen(node) {
  7955. switch (node.name) {
  7956. case this.tag:
  7957. this.text = '';
  7958. return true;
  7959. default:
  7960. return false;
  7961. }
  7962. }
  7963. }, {
  7964. key: "parseText",
  7965. value: function parseText(text) {
  7966. this.text = text;
  7967. }
  7968. }, {
  7969. key: "parseClose",
  7970. value: function parseClose() {
  7971. return false;
  7972. }
  7973. }, {
  7974. key: "tag",
  7975. get: function get() {
  7976. return this._model && this._model.tag;
  7977. }
  7978. }]);
  7979. return VmlProtectionXform;
  7980. }(BaseXform);
  7981. module.exports = VmlProtectionXform;
  7982. }, { "../../base-xform": 31 }], 42: [function (require, module, exports) {
  7983. "use strict";
  7984. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7985. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7986. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7987. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7988. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7989. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7990. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7991. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7992. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7993. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  7994. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7995. var BaseXform = require('../base-xform'); // render the triangle in the cell for the comment
  7996. var VmlAnchorXform = /*#__PURE__*/function (_BaseXform) {
  7997. _inherits(VmlAnchorXform, _BaseXform);
  7998. var _super = _createSuper(VmlAnchorXform);
  7999. function VmlAnchorXform() {
  8000. _classCallCheck(this, VmlAnchorXform);
  8001. return _super.apply(this, arguments);
  8002. }
  8003. _createClass(VmlAnchorXform, [{
  8004. key: "getAnchorRect",
  8005. value: function getAnchorRect(anchor) {
  8006. var l = Math.floor(anchor.left);
  8007. var lf = Math.floor((anchor.left - l) * 68);
  8008. var t = Math.floor(anchor.top);
  8009. var tf = Math.floor((anchor.top - t) * 18);
  8010. var r = Math.floor(anchor.right);
  8011. var rf = Math.floor((anchor.right - r) * 68);
  8012. var b = Math.floor(anchor.bottom);
  8013. var bf = Math.floor((anchor.bottom - b) * 18);
  8014. return [l, lf, t, tf, r, rf, b, bf];
  8015. }
  8016. }, {
  8017. key: "getDefaultRect",
  8018. value: function getDefaultRect(ref) {
  8019. var l = ref.col;
  8020. var lf = 6;
  8021. var t = Math.max(ref.row - 2, 0);
  8022. var tf = 14;
  8023. var r = l + 2;
  8024. var rf = 2;
  8025. var b = t + 4;
  8026. var bf = 16;
  8027. return [l, lf, t, tf, r, rf, b, bf];
  8028. }
  8029. }, {
  8030. key: "render",
  8031. value: function render(xmlStream, model) {
  8032. var rect = model.anchor ? this.getAnchorRect(model.anchor) : this.getDefaultRect(model.refAddress);
  8033. xmlStream.leafNode('x:Anchor', null, rect.join(', '));
  8034. }
  8035. }, {
  8036. key: "parseOpen",
  8037. value: function parseOpen(node) {
  8038. switch (node.name) {
  8039. case this.tag:
  8040. this.text = '';
  8041. return true;
  8042. default:
  8043. return false;
  8044. }
  8045. }
  8046. }, {
  8047. key: "parseText",
  8048. value: function parseText(text) {
  8049. this.text = text;
  8050. }
  8051. }, {
  8052. key: "parseClose",
  8053. value: function parseClose() {
  8054. return false;
  8055. }
  8056. }, {
  8057. key: "tag",
  8058. get: function get() {
  8059. return 'x:Anchor';
  8060. }
  8061. }]);
  8062. return VmlAnchorXform;
  8063. }(BaseXform);
  8064. module.exports = VmlAnchorXform;
  8065. }, { "../base-xform": 31 }], 43: [function (require, module, exports) {
  8066. "use strict";
  8067. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8068. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8069. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8070. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8071. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8072. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8073. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8074. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8075. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8076. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8077. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8078. var BaseXform = require('../base-xform');
  8079. var VmlAnchorXform = require('./vml-anchor-xform');
  8080. var VmlProtectionXform = require('./style/vml-protection-xform');
  8081. var VmlPositionXform = require('./style/vml-position-xform');
  8082. var POSITION_TYPE = ['twoCells', 'oneCells', 'absolute'];
  8083. var VmlClientDataXform = /*#__PURE__*/function (_BaseXform) {
  8084. _inherits(VmlClientDataXform, _BaseXform);
  8085. var _super = _createSuper(VmlClientDataXform);
  8086. function VmlClientDataXform() {
  8087. var _this;
  8088. _classCallCheck(this, VmlClientDataXform);
  8089. _this = _super.call(this);
  8090. _this.map = {
  8091. 'x:Anchor': new VmlAnchorXform(),
  8092. 'x:Locked': new VmlProtectionXform({
  8093. tag: 'x:Locked'
  8094. }),
  8095. 'x:LockText': new VmlProtectionXform({
  8096. tag: 'x:LockText'
  8097. }),
  8098. 'x:SizeWithCells': new VmlPositionXform({
  8099. tag: 'x:SizeWithCells'
  8100. }),
  8101. 'x:MoveWithCells': new VmlPositionXform({
  8102. tag: 'x:MoveWithCells'
  8103. })
  8104. };
  8105. return _this;
  8106. }
  8107. _createClass(VmlClientDataXform, [{
  8108. key: "render",
  8109. value: function render(xmlStream, model) {
  8110. var _model$note = model.note,
  8111. protection = _model$note.protection,
  8112. editAs = _model$note.editAs;
  8113. xmlStream.openNode(this.tag, {
  8114. ObjectType: 'Note'
  8115. });
  8116. this.map['x:MoveWithCells'].render(xmlStream, editAs, POSITION_TYPE);
  8117. this.map['x:SizeWithCells'].render(xmlStream, editAs, POSITION_TYPE);
  8118. this.map['x:Anchor'].render(xmlStream, model);
  8119. this.map['x:Locked'].render(xmlStream, protection.locked);
  8120. xmlStream.leafNode('x:AutoFill', null, 'False');
  8121. this.map['x:LockText'].render(xmlStream, protection.lockText);
  8122. xmlStream.leafNode('x:Row', null, model.refAddress.row - 1);
  8123. xmlStream.leafNode('x:Column', null, model.refAddress.col - 1);
  8124. xmlStream.closeNode();
  8125. }
  8126. }, {
  8127. key: "parseOpen",
  8128. value: function parseOpen(node) {
  8129. switch (node.name) {
  8130. case this.tag:
  8131. this.reset();
  8132. this.model = {
  8133. anchor: [],
  8134. protection: {},
  8135. editAs: ''
  8136. };
  8137. break;
  8138. default:
  8139. this.parser = this.map[node.name];
  8140. if (this.parser) {
  8141. this.parser.parseOpen(node);
  8142. }
  8143. break;
  8144. }
  8145. return true;
  8146. }
  8147. }, {
  8148. key: "parseText",
  8149. value: function parseText(text) {
  8150. if (this.parser) {
  8151. this.parser.parseText(text);
  8152. }
  8153. }
  8154. }, {
  8155. key: "parseClose",
  8156. value: function parseClose(name) {
  8157. if (this.parser) {
  8158. if (!this.parser.parseClose(name)) {
  8159. this.parser = undefined;
  8160. }
  8161. return true;
  8162. }
  8163. switch (name) {
  8164. case this.tag:
  8165. this.normalizeModel();
  8166. return false;
  8167. default:
  8168. return true;
  8169. }
  8170. }
  8171. }, {
  8172. key: "normalizeModel",
  8173. value: function normalizeModel() {
  8174. var position = Object.assign({}, this.map['x:MoveWithCells'].model, this.map['x:SizeWithCells'].model);
  8175. var len = Object.keys(position).length;
  8176. this.model.editAs = POSITION_TYPE[len];
  8177. this.model.anchor = this.map['x:Anchor'].text;
  8178. this.model.protection.locked = this.map['x:Locked'].text;
  8179. this.model.protection.lockText = this.map['x:LockText'].text;
  8180. }
  8181. }, {
  8182. key: "tag",
  8183. get: function get() {
  8184. return 'x:ClientData';
  8185. }
  8186. }]);
  8187. return VmlClientDataXform;
  8188. }(BaseXform);
  8189. module.exports = VmlClientDataXform;
  8190. }, { "../base-xform": 31, "./style/vml-position-xform": 40, "./style/vml-protection-xform": 41, "./vml-anchor-xform": 42 }], 44: [function (require, module, exports) {
  8191. "use strict";
  8192. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8193. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8194. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8195. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8196. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8197. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8198. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8199. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8200. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8201. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8202. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8203. var XmlStream = require('../../../utils/xml-stream');
  8204. var BaseXform = require('../base-xform');
  8205. var VmlShapeXform = require('./vml-shape-xform'); // This class is (currently) single purposed to insert the triangle
  8206. // drawing icons on commented cells
  8207. var VmlNotesXform = /*#__PURE__*/function (_BaseXform) {
  8208. _inherits(VmlNotesXform, _BaseXform);
  8209. var _super = _createSuper(VmlNotesXform);
  8210. function VmlNotesXform() {
  8211. var _this;
  8212. _classCallCheck(this, VmlNotesXform);
  8213. _this = _super.call(this);
  8214. _this.map = {
  8215. 'v:shape': new VmlShapeXform()
  8216. };
  8217. return _this;
  8218. }
  8219. _createClass(VmlNotesXform, [{
  8220. key: "render",
  8221. value: function render(xmlStream, model) {
  8222. var _this2 = this;
  8223. xmlStream.openXml(XmlStream.StdDocAttributes);
  8224. xmlStream.openNode(this.tag, VmlNotesXform.DRAWING_ATTRIBUTES);
  8225. xmlStream.openNode('o:shapelayout', {
  8226. 'v:ext': 'edit'
  8227. });
  8228. xmlStream.leafNode('o:idmap', {
  8229. 'v:ext': 'edit',
  8230. data: 1
  8231. });
  8232. xmlStream.closeNode();
  8233. xmlStream.openNode('v:shapetype', {
  8234. id: '_x0000_t202',
  8235. coordsize: '21600,21600',
  8236. 'o:spt': 202,
  8237. path: 'm,l,21600r21600,l21600,xe'
  8238. });
  8239. xmlStream.leafNode('v:stroke', {
  8240. joinstyle: 'miter'
  8241. });
  8242. xmlStream.leafNode('v:path', {
  8243. gradientshapeok: 't',
  8244. 'o:connecttype': 'rect'
  8245. });
  8246. xmlStream.closeNode();
  8247. model.comments.forEach(function (item, index) {
  8248. _this2.map['v:shape'].render(xmlStream, item, index);
  8249. });
  8250. xmlStream.closeNode();
  8251. }
  8252. }, {
  8253. key: "parseOpen",
  8254. value: function parseOpen(node) {
  8255. if (this.parser) {
  8256. this.parser.parseOpen(node);
  8257. return true;
  8258. }
  8259. switch (node.name) {
  8260. case this.tag:
  8261. this.reset();
  8262. this.model = {
  8263. comments: []
  8264. };
  8265. break;
  8266. default:
  8267. this.parser = this.map[node.name];
  8268. if (this.parser) {
  8269. this.parser.parseOpen(node);
  8270. }
  8271. break;
  8272. }
  8273. return true;
  8274. }
  8275. }, {
  8276. key: "parseText",
  8277. value: function parseText(text) {
  8278. if (this.parser) {
  8279. this.parser.parseText(text);
  8280. }
  8281. }
  8282. }, {
  8283. key: "parseClose",
  8284. value: function parseClose(name) {
  8285. if (this.parser) {
  8286. if (!this.parser.parseClose(name)) {
  8287. this.model.comments.push(this.parser.model);
  8288. this.parser = undefined;
  8289. }
  8290. return true;
  8291. }
  8292. switch (name) {
  8293. case this.tag:
  8294. return false;
  8295. default:
  8296. // could be some unrecognised tags
  8297. return true;
  8298. }
  8299. }
  8300. }, {
  8301. key: "reconcile",
  8302. value: function reconcile(model, options) {
  8303. var _this3 = this;
  8304. model.anchors.forEach(function (anchor) {
  8305. if (anchor.br) {
  8306. _this3.map['xdr:twoCellAnchor'].reconcile(anchor, options);
  8307. } else {
  8308. _this3.map['xdr:oneCellAnchor'].reconcile(anchor, options);
  8309. }
  8310. });
  8311. }
  8312. }, {
  8313. key: "tag",
  8314. get: function get() {
  8315. return 'xml';
  8316. }
  8317. }]);
  8318. return VmlNotesXform;
  8319. }(BaseXform);
  8320. VmlNotesXform.DRAWING_ATTRIBUTES = {
  8321. 'xmlns:v': 'urn:schemas-microsoft-com:vml',
  8322. 'xmlns:o': 'urn:schemas-microsoft-com:office:office',
  8323. 'xmlns:x': 'urn:schemas-microsoft-com:office:excel'
  8324. };
  8325. module.exports = VmlNotesXform;
  8326. }, { "../../../utils/xml-stream": 27, "../base-xform": 31, "./vml-shape-xform": 45 }], 45: [function (require, module, exports) {
  8327. "use strict";
  8328. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8329. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8330. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8331. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8332. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8333. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8334. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8335. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8336. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8337. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8338. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8339. var BaseXform = require('../base-xform');
  8340. var VmlTextboxXform = require('./vml-textbox-xform');
  8341. var VmlClientDataXform = require('./vml-client-data-xform');
  8342. var VmlShapeXform = /*#__PURE__*/function (_BaseXform) {
  8343. _inherits(VmlShapeXform, _BaseXform);
  8344. var _super = _createSuper(VmlShapeXform);
  8345. function VmlShapeXform() {
  8346. var _this;
  8347. _classCallCheck(this, VmlShapeXform);
  8348. _this = _super.call(this);
  8349. _this.map = {
  8350. 'v:textbox': new VmlTextboxXform(),
  8351. 'x:ClientData': new VmlClientDataXform()
  8352. };
  8353. return _this;
  8354. }
  8355. _createClass(VmlShapeXform, [{
  8356. key: "render",
  8357. value: function render(xmlStream, model, index) {
  8358. xmlStream.openNode('v:shape', VmlShapeXform.V_SHAPE_ATTRIBUTES(model, index));
  8359. xmlStream.leafNode('v:fill', {
  8360. color2: 'infoBackground [80]'
  8361. });
  8362. xmlStream.leafNode('v:shadow', {
  8363. color: 'none [81]',
  8364. obscured: 't'
  8365. });
  8366. xmlStream.leafNode('v:path', {
  8367. 'o:connecttype': 'none'
  8368. });
  8369. this.map['v:textbox'].render(xmlStream, model);
  8370. this.map['x:ClientData'].render(xmlStream, model);
  8371. xmlStream.closeNode();
  8372. }
  8373. }, {
  8374. key: "parseOpen",
  8375. value: function parseOpen(node) {
  8376. if (this.parser) {
  8377. this.parser.parseOpen(node);
  8378. return true;
  8379. }
  8380. switch (node.name) {
  8381. case this.tag:
  8382. this.reset();
  8383. this.model = {
  8384. margins: {
  8385. insetmode: node.attributes['o:insetmode']
  8386. },
  8387. anchor: '',
  8388. editAs: '',
  8389. protection: {}
  8390. };
  8391. break;
  8392. default:
  8393. this.parser = this.map[node.name];
  8394. if (this.parser) {
  8395. this.parser.parseOpen(node);
  8396. }
  8397. break;
  8398. }
  8399. return true;
  8400. }
  8401. }, {
  8402. key: "parseText",
  8403. value: function parseText(text) {
  8404. if (this.parser) {
  8405. this.parser.parseText(text);
  8406. }
  8407. }
  8408. }, {
  8409. key: "parseClose",
  8410. value: function parseClose(name) {
  8411. if (this.parser) {
  8412. if (!this.parser.parseClose(name)) {
  8413. this.parser = undefined;
  8414. }
  8415. return true;
  8416. }
  8417. switch (name) {
  8418. case this.tag:
  8419. this.model.margins.inset = this.map['v:textbox'].model && this.map['v:textbox'].model.inset;
  8420. this.model.protection = this.map['x:ClientData'].model && this.map['x:ClientData'].model.protection;
  8421. this.model.anchor = this.map['x:ClientData'].model && this.map['x:ClientData'].model.anchor;
  8422. this.model.editAs = this.map['x:ClientData'].model && this.map['x:ClientData'].model.editAs;
  8423. return false;
  8424. default:
  8425. return true;
  8426. }
  8427. }
  8428. }, {
  8429. key: "tag",
  8430. get: function get() {
  8431. return 'v:shape';
  8432. }
  8433. }]);
  8434. return VmlShapeXform;
  8435. }(BaseXform);
  8436. VmlShapeXform.V_SHAPE_ATTRIBUTES = function (model, index) {
  8437. return {
  8438. id: "_x0000_s".concat(1025 + index),
  8439. type: '#_x0000_t202',
  8440. style: 'position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden',
  8441. fillcolor: 'infoBackground [80]',
  8442. strokecolor: 'none [81]',
  8443. 'o:insetmode': model.note.margins && model.note.margins.insetmode
  8444. };
  8445. };
  8446. module.exports = VmlShapeXform;
  8447. }, { "../base-xform": 31, "./vml-client-data-xform": 43, "./vml-textbox-xform": 46 }], 46: [function (require, module, exports) {
  8448. "use strict";
  8449. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8450. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8451. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8452. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8453. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8454. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8455. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8456. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8457. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8458. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8459. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8460. var BaseXform = require('../base-xform');
  8461. var VmlTextboxXform = /*#__PURE__*/function (_BaseXform) {
  8462. _inherits(VmlTextboxXform, _BaseXform);
  8463. var _super = _createSuper(VmlTextboxXform);
  8464. function VmlTextboxXform() {
  8465. _classCallCheck(this, VmlTextboxXform);
  8466. return _super.apply(this, arguments);
  8467. }
  8468. _createClass(VmlTextboxXform, [{
  8469. key: "conversionUnit",
  8470. value: function conversionUnit(value, multiple, unit) {
  8471. return "".concat(parseFloat(value) * multiple.toFixed(2)).concat(unit);
  8472. }
  8473. }, {
  8474. key: "reverseConversionUnit",
  8475. value: function reverseConversionUnit(inset) {
  8476. var _this = this;
  8477. return (inset || '').split(',').map(function (margin) {
  8478. return Number(parseFloat(_this.conversionUnit(parseFloat(margin), 0.1, '')).toFixed(2));
  8479. });
  8480. }
  8481. }, {
  8482. key: "render",
  8483. value: function render(xmlStream, model) {
  8484. var _this2 = this;
  8485. var attributes = {
  8486. style: 'mso-direction-alt:auto'
  8487. };
  8488. if (model && model.note) {
  8489. var _ref = model.note && model.note.margins,
  8490. inset = _ref.inset;
  8491. if (Array.isArray(inset)) {
  8492. inset = inset.map(function (margin) {
  8493. return _this2.conversionUnit(margin, 10, 'mm');
  8494. }).join(',');
  8495. }
  8496. if (inset) {
  8497. attributes.inset = inset;
  8498. }
  8499. }
  8500. xmlStream.openNode('v:textbox', attributes);
  8501. xmlStream.leafNode('div', {
  8502. style: 'text-align:left'
  8503. });
  8504. xmlStream.closeNode();
  8505. }
  8506. }, {
  8507. key: "parseOpen",
  8508. value: function parseOpen(node) {
  8509. switch (node.name) {
  8510. case this.tag:
  8511. this.model = {
  8512. inset: this.reverseConversionUnit(node.attributes.inset)
  8513. };
  8514. return true;
  8515. default:
  8516. return true;
  8517. }
  8518. }
  8519. }, {
  8520. key: "parseText",
  8521. value: function parseText() { }
  8522. }, {
  8523. key: "parseClose",
  8524. value: function parseClose(name) {
  8525. switch (name) {
  8526. case this.tag:
  8527. return false;
  8528. default:
  8529. return true;
  8530. }
  8531. }
  8532. }, {
  8533. key: "tag",
  8534. get: function get() {
  8535. return 'v:textbox';
  8536. }
  8537. }]);
  8538. return VmlTextboxXform;
  8539. }(BaseXform);
  8540. module.exports = VmlTextboxXform;
  8541. }, { "../base-xform": 31 }], 47: [function (require, module, exports) {
  8542. "use strict";
  8543. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8544. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8545. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8546. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8547. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8548. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8549. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8550. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8551. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8552. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8553. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8554. var BaseXform = require('./base-xform');
  8555. /* 'virtual' methods used as a form of documentation */
  8556. /* eslint-disable class-methods-use-this */
  8557. // base class for xforms that are composed of other xforms
  8558. // offers some default implementations
  8559. var CompositeXform = /*#__PURE__*/function (_BaseXform) {
  8560. _inherits(CompositeXform, _BaseXform);
  8561. var _super = _createSuper(CompositeXform);
  8562. function CompositeXform() {
  8563. _classCallCheck(this, CompositeXform);
  8564. return _super.apply(this, arguments);
  8565. }
  8566. _createClass(CompositeXform, [{
  8567. key: "createNewModel",
  8568. value: function createNewModel(node) {
  8569. return {};
  8570. }
  8571. }, {
  8572. key: "parseOpen",
  8573. value: function parseOpen(node) {
  8574. // Typical pattern for composite xform
  8575. this.parser = this.parser || this.map[node.name];
  8576. if (this.parser) {
  8577. this.parser.parseOpen(node);
  8578. return true;
  8579. }
  8580. if (node.name === this.tag) {
  8581. this.model = this.createNewModel(node);
  8582. return true;
  8583. }
  8584. return false;
  8585. }
  8586. }, {
  8587. key: "parseText",
  8588. value: function parseText(text) {
  8589. // Default implementation. Send text to child parser
  8590. if (this.parser) {
  8591. this.parser.parseText(text);
  8592. }
  8593. }
  8594. }, {
  8595. key: "onParserClose",
  8596. value: function onParserClose(name, parser) {
  8597. // parseClose has seen a child parser close
  8598. // now need to incorporate into this.model somehow
  8599. this.model[name] = parser.model;
  8600. }
  8601. }, {
  8602. key: "parseClose",
  8603. value: function parseClose(name) {
  8604. // Default implementation
  8605. if (this.parser) {
  8606. if (!this.parser.parseClose(name)) {
  8607. this.onParserClose(name, this.parser);
  8608. this.parser = undefined;
  8609. }
  8610. return true;
  8611. }
  8612. return name !== this.tag;
  8613. }
  8614. }]);
  8615. return CompositeXform;
  8616. }(BaseXform);
  8617. module.exports = CompositeXform;
  8618. }, { "./base-xform": 31 }], 48: [function (require, module, exports) {
  8619. "use strict";
  8620. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8621. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8622. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8623. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8624. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8625. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8626. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8627. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8628. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8629. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8630. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8631. var BaseXform = require('../base-xform');
  8632. var AppHeadingPairsXform = /*#__PURE__*/function (_BaseXform) {
  8633. _inherits(AppHeadingPairsXform, _BaseXform);
  8634. var _super = _createSuper(AppHeadingPairsXform);
  8635. function AppHeadingPairsXform() {
  8636. _classCallCheck(this, AppHeadingPairsXform);
  8637. return _super.apply(this, arguments);
  8638. }
  8639. _createClass(AppHeadingPairsXform, [{
  8640. key: "render",
  8641. value: function render(xmlStream, model) {
  8642. xmlStream.openNode('HeadingPairs');
  8643. xmlStream.openNode('vt:vector', {
  8644. size: 2,
  8645. baseType: 'variant'
  8646. });
  8647. xmlStream.openNode('vt:variant');
  8648. xmlStream.leafNode('vt:lpstr', undefined, 'Worksheets');
  8649. xmlStream.closeNode();
  8650. xmlStream.openNode('vt:variant');
  8651. xmlStream.leafNode('vt:i4', undefined, model.length);
  8652. xmlStream.closeNode();
  8653. xmlStream.closeNode();
  8654. xmlStream.closeNode();
  8655. }
  8656. }, {
  8657. key: "parseOpen",
  8658. value: function parseOpen(node) {
  8659. // no parsing
  8660. return node.name === 'HeadingPairs';
  8661. }
  8662. }, {
  8663. key: "parseText",
  8664. value: function parseText() { }
  8665. }, {
  8666. key: "parseClose",
  8667. value: function parseClose(name) {
  8668. return name !== 'HeadingPairs';
  8669. }
  8670. }]);
  8671. return AppHeadingPairsXform;
  8672. }(BaseXform);
  8673. module.exports = AppHeadingPairsXform;
  8674. }, { "../base-xform": 31 }], 49: [function (require, module, exports) {
  8675. "use strict";
  8676. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8677. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8678. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8679. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8680. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8681. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8682. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8683. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8684. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8685. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8686. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8687. var BaseXform = require('../base-xform');
  8688. var AppTitlesOfPartsXform = /*#__PURE__*/function (_BaseXform) {
  8689. _inherits(AppTitlesOfPartsXform, _BaseXform);
  8690. var _super = _createSuper(AppTitlesOfPartsXform);
  8691. function AppTitlesOfPartsXform() {
  8692. _classCallCheck(this, AppTitlesOfPartsXform);
  8693. return _super.apply(this, arguments);
  8694. }
  8695. _createClass(AppTitlesOfPartsXform, [{
  8696. key: "render",
  8697. value: function render(xmlStream, model) {
  8698. xmlStream.openNode('TitlesOfParts');
  8699. xmlStream.openNode('vt:vector', {
  8700. size: model.length,
  8701. baseType: 'lpstr'
  8702. });
  8703. model.forEach(function (sheet) {
  8704. xmlStream.leafNode('vt:lpstr', undefined, sheet.name);
  8705. });
  8706. xmlStream.closeNode();
  8707. xmlStream.closeNode();
  8708. }
  8709. }, {
  8710. key: "parseOpen",
  8711. value: function parseOpen(node) {
  8712. // no parsing
  8713. return node.name === 'TitlesOfParts';
  8714. }
  8715. }, {
  8716. key: "parseText",
  8717. value: function parseText() { }
  8718. }, {
  8719. key: "parseClose",
  8720. value: function parseClose(name) {
  8721. return name !== 'TitlesOfParts';
  8722. }
  8723. }]);
  8724. return AppTitlesOfPartsXform;
  8725. }(BaseXform);
  8726. module.exports = AppTitlesOfPartsXform;
  8727. }, { "../base-xform": 31 }], 50: [function (require, module, exports) {
  8728. "use strict";
  8729. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8730. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8731. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8732. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8733. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8734. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8735. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8736. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8737. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8738. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8739. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8740. var XmlStream = require('../../../utils/xml-stream');
  8741. var BaseXform = require('../base-xform');
  8742. var StringXform = require('../simple/string-xform');
  8743. var AppHeadingPairsXform = require('./app-heading-pairs-xform');
  8744. var AppTitleOfPartsXform = require('./app-titles-of-parts-xform');
  8745. var AppXform = /*#__PURE__*/function (_BaseXform) {
  8746. _inherits(AppXform, _BaseXform);
  8747. var _super = _createSuper(AppXform);
  8748. function AppXform() {
  8749. var _this;
  8750. _classCallCheck(this, AppXform);
  8751. _this = _super.call(this);
  8752. _this.map = {
  8753. Company: new StringXform({
  8754. tag: 'Company'
  8755. }),
  8756. Manager: new StringXform({
  8757. tag: 'Manager'
  8758. }),
  8759. HeadingPairs: new AppHeadingPairsXform(),
  8760. TitleOfParts: new AppTitleOfPartsXform()
  8761. };
  8762. return _this;
  8763. }
  8764. _createClass(AppXform, [{
  8765. key: "render",
  8766. value: function render(xmlStream, model) {
  8767. xmlStream.openXml(XmlStream.StdDocAttributes);
  8768. xmlStream.openNode('Properties', AppXform.PROPERTY_ATTRIBUTES);
  8769. xmlStream.leafNode('Application', undefined, 'Microsoft Excel');
  8770. xmlStream.leafNode('DocSecurity', undefined, '0');
  8771. xmlStream.leafNode('ScaleCrop', undefined, 'false');
  8772. this.map.HeadingPairs.render(xmlStream, model.worksheets);
  8773. this.map.TitleOfParts.render(xmlStream, model.worksheets);
  8774. this.map.Company.render(xmlStream, model.company || '');
  8775. this.map.Manager.render(xmlStream, model.manager);
  8776. xmlStream.leafNode('LinksUpToDate', undefined, 'false');
  8777. xmlStream.leafNode('SharedDoc', undefined, 'false');
  8778. xmlStream.leafNode('HyperlinksChanged', undefined, 'false');
  8779. xmlStream.leafNode('AppVersion', undefined, '16.0300');
  8780. xmlStream.closeNode();
  8781. }
  8782. }, {
  8783. key: "parseOpen",
  8784. value: function parseOpen(node) {
  8785. if (this.parser) {
  8786. this.parser.parseOpen(node);
  8787. return true;
  8788. }
  8789. switch (node.name) {
  8790. case 'Properties':
  8791. return true;
  8792. default:
  8793. this.parser = this.map[node.name];
  8794. if (this.parser) {
  8795. this.parser.parseOpen(node);
  8796. return true;
  8797. } // there's a lot we don't bother to parse
  8798. return false;
  8799. }
  8800. }
  8801. }, {
  8802. key: "parseText",
  8803. value: function parseText(text) {
  8804. if (this.parser) {
  8805. this.parser.parseText(text);
  8806. }
  8807. }
  8808. }, {
  8809. key: "parseClose",
  8810. value: function parseClose(name) {
  8811. if (this.parser) {
  8812. if (!this.parser.parseClose(name)) {
  8813. this.parser = undefined;
  8814. }
  8815. return true;
  8816. }
  8817. switch (name) {
  8818. case 'Properties':
  8819. this.model = {
  8820. worksheets: this.map.TitleOfParts.model,
  8821. company: this.map.Company.model,
  8822. manager: this.map.Manager.model
  8823. };
  8824. return false;
  8825. default:
  8826. return true;
  8827. }
  8828. }
  8829. }]);
  8830. return AppXform;
  8831. }(BaseXform);
  8832. AppXform.DateFormat = function (dt) {
  8833. return dt.toISOString().replace(/[.]\d{3,6}/, '');
  8834. };
  8835. AppXform.DateAttrs = {
  8836. 'xsi:type': 'dcterms:W3CDTF'
  8837. };
  8838. AppXform.PROPERTY_ATTRIBUTES = {
  8839. xmlns: 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties',
  8840. 'xmlns:vt': 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'
  8841. };
  8842. module.exports = AppXform;
  8843. }, { "../../../utils/xml-stream": 27, "../base-xform": 31, "../simple/string-xform": 118, "./app-heading-pairs-xform": 48, "./app-titles-of-parts-xform": 49 }], 51: [function (require, module, exports) {
  8844. "use strict";
  8845. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8846. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8847. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8848. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8849. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8850. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8851. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8852. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8853. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8854. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8855. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8856. var XmlStream = require('../../../utils/xml-stream');
  8857. var BaseXform = require('../base-xform'); // used for rendering the [Content_Types].xml file
  8858. // not used for parsing
  8859. var ContentTypesXform = /*#__PURE__*/function (_BaseXform) {
  8860. _inherits(ContentTypesXform, _BaseXform);
  8861. var _super = _createSuper(ContentTypesXform);
  8862. function ContentTypesXform() {
  8863. _classCallCheck(this, ContentTypesXform);
  8864. return _super.apply(this, arguments);
  8865. }
  8866. _createClass(ContentTypesXform, [{
  8867. key: "render",
  8868. value: function render(xmlStream, model) {
  8869. xmlStream.openXml(XmlStream.StdDocAttributes);
  8870. xmlStream.openNode('Types', ContentTypesXform.PROPERTY_ATTRIBUTES);
  8871. var mediaHash = {};
  8872. (model.media || []).forEach(function (medium) {
  8873. if (medium.type === 'image') {
  8874. var imageType = medium.extension;
  8875. if (!mediaHash[imageType]) {
  8876. mediaHash[imageType] = true;
  8877. xmlStream.leafNode('Default', {
  8878. Extension: imageType,
  8879. ContentType: "image/".concat(imageType)
  8880. });
  8881. }
  8882. }
  8883. });
  8884. xmlStream.leafNode('Default', {
  8885. Extension: 'rels',
  8886. ContentType: 'application/vnd.openxmlformats-package.relationships+xml'
  8887. });
  8888. xmlStream.leafNode('Default', {
  8889. Extension: 'xml',
  8890. ContentType: 'application/xml'
  8891. });
  8892. xmlStream.leafNode('Override', {
  8893. PartName: '/xl/workbook.xml',
  8894. ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'
  8895. });
  8896. model.worksheets.forEach(function (worksheet) {
  8897. var name = "/xl/worksheets/sheet".concat(worksheet.id, ".xml");
  8898. xmlStream.leafNode('Override', {
  8899. PartName: name,
  8900. ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
  8901. });
  8902. });
  8903. xmlStream.leafNode('Override', {
  8904. PartName: '/xl/theme/theme1.xml',
  8905. ContentType: 'application/vnd.openxmlformats-officedocument.theme+xml'
  8906. });
  8907. xmlStream.leafNode('Override', {
  8908. PartName: '/xl/styles.xml',
  8909. ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'
  8910. });
  8911. var hasSharedStrings = model.sharedStrings && model.sharedStrings.count;
  8912. if (hasSharedStrings) {
  8913. xmlStream.leafNode('Override', {
  8914. PartName: '/xl/sharedStrings.xml',
  8915. ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
  8916. });
  8917. }
  8918. if (model.tables) {
  8919. model.tables.forEach(function (table) {
  8920. xmlStream.leafNode('Override', {
  8921. PartName: "/xl/tables/".concat(table.target),
  8922. ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml'
  8923. });
  8924. });
  8925. }
  8926. if (model.drawings) {
  8927. model.drawings.forEach(function (drawing) {
  8928. xmlStream.leafNode('Override', {
  8929. PartName: "/xl/drawings/".concat(drawing.name, ".xml"),
  8930. ContentType: 'application/vnd.openxmlformats-officedocument.drawing+xml'
  8931. });
  8932. });
  8933. }
  8934. if (model.commentRefs) {
  8935. xmlStream.leafNode('Default', {
  8936. Extension: 'vml',
  8937. ContentType: 'application/vnd.openxmlformats-officedocument.vmlDrawing'
  8938. });
  8939. model.commentRefs.forEach(function (_ref) {
  8940. var commentName = _ref.commentName;
  8941. xmlStream.leafNode('Override', {
  8942. PartName: "/xl/".concat(commentName, ".xml"),
  8943. ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
  8944. });
  8945. });
  8946. }
  8947. xmlStream.leafNode('Override', {
  8948. PartName: '/docProps/core.xml',
  8949. ContentType: 'application/vnd.openxmlformats-package.core-properties+xml'
  8950. });
  8951. xmlStream.leafNode('Override', {
  8952. PartName: '/docProps/app.xml',
  8953. ContentType: 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
  8954. });
  8955. xmlStream.closeNode();
  8956. }
  8957. }, {
  8958. key: "parseOpen",
  8959. value: function parseOpen() {
  8960. return false;
  8961. }
  8962. }, {
  8963. key: "parseText",
  8964. value: function parseText() { }
  8965. }, {
  8966. key: "parseClose",
  8967. value: function parseClose() {
  8968. return false;
  8969. }
  8970. }]);
  8971. return ContentTypesXform;
  8972. }(BaseXform);
  8973. ContentTypesXform.PROPERTY_ATTRIBUTES = {
  8974. xmlns: 'http://schemas.openxmlformats.org/package/2006/content-types'
  8975. };
  8976. module.exports = ContentTypesXform;
  8977. }, { "../../../utils/xml-stream": 27, "../base-xform": 31 }], 52: [function (require, module, exports) {
  8978. "use strict";
  8979. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8980. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8981. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8982. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8983. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8984. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8985. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8986. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8987. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8988. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  8989. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8990. var XmlStream = require('../../../utils/xml-stream');
  8991. var BaseXform = require('../base-xform');
  8992. var DateXform = require('../simple/date-xform');
  8993. var StringXform = require('../simple/string-xform');
  8994. var IntegerXform = require('../simple/integer-xform');
  8995. var CoreXform = /*#__PURE__*/function (_BaseXform) {
  8996. _inherits(CoreXform, _BaseXform);
  8997. var _super = _createSuper(CoreXform);
  8998. function CoreXform() {
  8999. var _this;
  9000. _classCallCheck(this, CoreXform);
  9001. _this = _super.call(this);
  9002. _this.map = {
  9003. 'dc:creator': new StringXform({
  9004. tag: 'dc:creator'
  9005. }),
  9006. 'dc:title': new StringXform({
  9007. tag: 'dc:title'
  9008. }),
  9009. 'dc:subject': new StringXform({
  9010. tag: 'dc:subject'
  9011. }),
  9012. 'dc:description': new StringXform({
  9013. tag: 'dc:description'
  9014. }),
  9015. 'dc:identifier': new StringXform({
  9016. tag: 'dc:identifier'
  9017. }),
  9018. 'dc:language': new StringXform({
  9019. tag: 'dc:language'
  9020. }),
  9021. 'cp:keywords': new StringXform({
  9022. tag: 'cp:keywords'
  9023. }),
  9024. 'cp:category': new StringXform({
  9025. tag: 'cp:category'
  9026. }),
  9027. 'cp:lastModifiedBy': new StringXform({
  9028. tag: 'cp:lastModifiedBy'
  9029. }),
  9030. 'cp:lastPrinted': new DateXform({
  9031. tag: 'cp:lastPrinted',
  9032. format: CoreXform.DateFormat
  9033. }),
  9034. 'cp:revision': new IntegerXform({
  9035. tag: 'cp:revision'
  9036. }),
  9037. 'cp:version': new StringXform({
  9038. tag: 'cp:version'
  9039. }),
  9040. 'cp:contentStatus': new StringXform({
  9041. tag: 'cp:contentStatus'
  9042. }),
  9043. 'cp:contentType': new StringXform({
  9044. tag: 'cp:contentType'
  9045. }),
  9046. 'dcterms:created': new DateXform({
  9047. tag: 'dcterms:created',
  9048. attrs: CoreXform.DateAttrs,
  9049. format: CoreXform.DateFormat
  9050. }),
  9051. 'dcterms:modified': new DateXform({
  9052. tag: 'dcterms:modified',
  9053. attrs: CoreXform.DateAttrs,
  9054. format: CoreXform.DateFormat
  9055. })
  9056. };
  9057. return _this;
  9058. }
  9059. _createClass(CoreXform, [{
  9060. key: "render",
  9061. value: function render(xmlStream, model) {
  9062. xmlStream.openXml(XmlStream.StdDocAttributes);
  9063. xmlStream.openNode('cp:coreProperties', CoreXform.CORE_PROPERTY_ATTRIBUTES);
  9064. this.map['dc:creator'].render(xmlStream, model.creator);
  9065. this.map['dc:title'].render(xmlStream, model.title);
  9066. this.map['dc:subject'].render(xmlStream, model.subject);
  9067. this.map['dc:description'].render(xmlStream, model.description);
  9068. this.map['dc:identifier'].render(xmlStream, model.identifier);
  9069. this.map['dc:language'].render(xmlStream, model.language);
  9070. this.map['cp:keywords'].render(xmlStream, model.keywords);
  9071. this.map['cp:category'].render(xmlStream, model.category);
  9072. this.map['cp:lastModifiedBy'].render(xmlStream, model.lastModifiedBy);
  9073. this.map['cp:lastPrinted'].render(xmlStream, model.lastPrinted);
  9074. this.map['cp:revision'].render(xmlStream, model.revision);
  9075. this.map['cp:version'].render(xmlStream, model.version);
  9076. this.map['cp:contentStatus'].render(xmlStream, model.contentStatus);
  9077. this.map['cp:contentType'].render(xmlStream, model.contentType);
  9078. this.map['dcterms:created'].render(xmlStream, model.created);
  9079. this.map['dcterms:modified'].render(xmlStream, model.modified);
  9080. xmlStream.closeNode();
  9081. }
  9082. }, {
  9083. key: "parseOpen",
  9084. value: function parseOpen(node) {
  9085. if (this.parser) {
  9086. this.parser.parseOpen(node);
  9087. return true;
  9088. }
  9089. switch (node.name) {
  9090. case 'cp:coreProperties':
  9091. case 'coreProperties':
  9092. return true;
  9093. default:
  9094. this.parser = this.map[node.name];
  9095. if (this.parser) {
  9096. this.parser.parseOpen(node);
  9097. return true;
  9098. }
  9099. throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(node)));
  9100. }
  9101. }
  9102. }, {
  9103. key: "parseText",
  9104. value: function parseText(text) {
  9105. if (this.parser) {
  9106. this.parser.parseText(text);
  9107. }
  9108. }
  9109. }, {
  9110. key: "parseClose",
  9111. value: function parseClose(name) {
  9112. if (this.parser) {
  9113. if (!this.parser.parseClose(name)) {
  9114. this.parser = undefined;
  9115. }
  9116. return true;
  9117. }
  9118. switch (name) {
  9119. case 'cp:coreProperties':
  9120. case 'coreProperties':
  9121. this.model = {
  9122. creator: this.map['dc:creator'].model,
  9123. title: this.map['dc:title'].model,
  9124. subject: this.map['dc:subject'].model,
  9125. description: this.map['dc:description'].model,
  9126. identifier: this.map['dc:identifier'].model,
  9127. language: this.map['dc:language'].model,
  9128. keywords: this.map['cp:keywords'].model,
  9129. category: this.map['cp:category'].model,
  9130. lastModifiedBy: this.map['cp:lastModifiedBy'].model,
  9131. lastPrinted: this.map['cp:lastPrinted'].model,
  9132. revision: this.map['cp:revision'].model,
  9133. contentStatus: this.map['cp:contentStatus'].model,
  9134. contentType: this.map['cp:contentType'].model,
  9135. created: this.map['dcterms:created'].model,
  9136. modified: this.map['dcterms:modified'].model
  9137. };
  9138. return false;
  9139. default:
  9140. throw new Error("Unexpected xml node in parseClose: ".concat(name));
  9141. }
  9142. }
  9143. }]);
  9144. return CoreXform;
  9145. }(BaseXform);
  9146. CoreXform.DateFormat = function (dt) {
  9147. return dt.toISOString().replace(/[.]\d{3}/, '');
  9148. };
  9149. CoreXform.DateAttrs = {
  9150. 'xsi:type': 'dcterms:W3CDTF'
  9151. };
  9152. CoreXform.CORE_PROPERTY_ATTRIBUTES = {
  9153. 'xmlns:cp': 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties',
  9154. 'xmlns:dc': 'http://purl.org/dc/elements/1.1/',
  9155. 'xmlns:dcterms': 'http://purl.org/dc/terms/',
  9156. 'xmlns:dcmitype': 'http://purl.org/dc/dcmitype/',
  9157. 'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance'
  9158. };
  9159. module.exports = CoreXform;
  9160. }, { "../../../utils/xml-stream": 27, "../base-xform": 31, "../simple/date-xform": 116, "../simple/integer-xform": 117, "../simple/string-xform": 118 }], 53: [function (require, module, exports) {
  9161. "use strict";
  9162. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9163. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9164. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9165. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9166. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9167. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9168. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9169. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9170. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9171. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9172. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9173. var BaseXform = require('../base-xform');
  9174. var RelationshipXform = /*#__PURE__*/function (_BaseXform) {
  9175. _inherits(RelationshipXform, _BaseXform);
  9176. var _super = _createSuper(RelationshipXform);
  9177. function RelationshipXform() {
  9178. _classCallCheck(this, RelationshipXform);
  9179. return _super.apply(this, arguments);
  9180. }
  9181. _createClass(RelationshipXform, [{
  9182. key: "render",
  9183. value: function render(xmlStream, model) {
  9184. xmlStream.leafNode('Relationship', model);
  9185. }
  9186. }, {
  9187. key: "parseOpen",
  9188. value: function parseOpen(node) {
  9189. switch (node.name) {
  9190. case 'Relationship':
  9191. this.model = node.attributes;
  9192. return true;
  9193. default:
  9194. return false;
  9195. }
  9196. }
  9197. }, {
  9198. key: "parseText",
  9199. value: function parseText() { }
  9200. }, {
  9201. key: "parseClose",
  9202. value: function parseClose() {
  9203. return false;
  9204. }
  9205. }]);
  9206. return RelationshipXform;
  9207. }(BaseXform);
  9208. module.exports = RelationshipXform;
  9209. }, { "../base-xform": 31 }], 54: [function (require, module, exports) {
  9210. "use strict";
  9211. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9212. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9213. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9214. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9215. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9216. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9217. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9218. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9219. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9220. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9221. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9222. var XmlStream = require('../../../utils/xml-stream');
  9223. var BaseXform = require('../base-xform');
  9224. var RelationshipXform = require('./relationship-xform');
  9225. var RelationshipsXform = /*#__PURE__*/function (_BaseXform) {
  9226. _inherits(RelationshipsXform, _BaseXform);
  9227. var _super = _createSuper(RelationshipsXform);
  9228. function RelationshipsXform() {
  9229. var _this;
  9230. _classCallCheck(this, RelationshipsXform);
  9231. _this = _super.call(this);
  9232. _this.map = {
  9233. Relationship: new RelationshipXform()
  9234. };
  9235. return _this;
  9236. }
  9237. _createClass(RelationshipsXform, [{
  9238. key: "render",
  9239. value: function render(xmlStream, model) {
  9240. var _this2 = this;
  9241. model = model || this._values;
  9242. xmlStream.openXml(XmlStream.StdDocAttributes);
  9243. xmlStream.openNode('Relationships', RelationshipsXform.RELATIONSHIPS_ATTRIBUTES);
  9244. model.forEach(function (relationship) {
  9245. _this2.map.Relationship.render(xmlStream, relationship);
  9246. });
  9247. xmlStream.closeNode();
  9248. }
  9249. }, {
  9250. key: "parseOpen",
  9251. value: function parseOpen(node) {
  9252. if (this.parser) {
  9253. this.parser.parseOpen(node);
  9254. return true;
  9255. }
  9256. switch (node.name) {
  9257. case 'Relationships':
  9258. this.model = [];
  9259. return true;
  9260. default:
  9261. this.parser = this.map[node.name];
  9262. if (this.parser) {
  9263. this.parser.parseOpen(node);
  9264. return true;
  9265. }
  9266. throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(node)));
  9267. }
  9268. }
  9269. }, {
  9270. key: "parseText",
  9271. value: function parseText(text) {
  9272. if (this.parser) {
  9273. this.parser.parseText(text);
  9274. }
  9275. }
  9276. }, {
  9277. key: "parseClose",
  9278. value: function parseClose(name) {
  9279. if (this.parser) {
  9280. if (!this.parser.parseClose(name)) {
  9281. this.model.push(this.parser.model);
  9282. this.parser = undefined;
  9283. }
  9284. return true;
  9285. }
  9286. switch (name) {
  9287. case 'Relationships':
  9288. return false;
  9289. default:
  9290. throw new Error("Unexpected xml node in parseClose: ".concat(name));
  9291. }
  9292. }
  9293. }]);
  9294. return RelationshipsXform;
  9295. }(BaseXform);
  9296. RelationshipsXform.RELATIONSHIPS_ATTRIBUTES = {
  9297. xmlns: 'http://schemas.openxmlformats.org/package/2006/relationships'
  9298. };
  9299. module.exports = RelationshipsXform;
  9300. }, { "../../../utils/xml-stream": 27, "../base-xform": 31, "./relationship-xform": 53 }], 55: [function (require, module, exports) {
  9301. "use strict";
  9302. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9303. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9304. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9305. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9306. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9307. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9308. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9309. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9310. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9311. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9312. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9313. var BaseXform = require('../base-xform');
  9314. var BaseCellAnchorXform = /*#__PURE__*/function (_BaseXform) {
  9315. _inherits(BaseCellAnchorXform, _BaseXform);
  9316. var _super = _createSuper(BaseCellAnchorXform);
  9317. function BaseCellAnchorXform() {
  9318. _classCallCheck(this, BaseCellAnchorXform);
  9319. return _super.apply(this, arguments);
  9320. }
  9321. _createClass(BaseCellAnchorXform, [{
  9322. key: "parseOpen",
  9323. value: function parseOpen(node) {
  9324. if (this.parser) {
  9325. this.parser.parseOpen(node);
  9326. return true;
  9327. }
  9328. switch (node.name) {
  9329. case this.tag:
  9330. this.reset();
  9331. this.model = {
  9332. range: {
  9333. editAs: node.attributes.editAs || 'oneCell'
  9334. }
  9335. };
  9336. break;
  9337. default:
  9338. this.parser = this.map[node.name];
  9339. if (this.parser) {
  9340. this.parser.parseOpen(node);
  9341. }
  9342. break;
  9343. }
  9344. return true;
  9345. }
  9346. }, {
  9347. key: "parseText",
  9348. value: function parseText(text) {
  9349. if (this.parser) {
  9350. this.parser.parseText(text);
  9351. }
  9352. }
  9353. }, {
  9354. key: "reconcilePicture",
  9355. value: function reconcilePicture(model, options) {
  9356. if (model && model.rId) {
  9357. var rel = options.rels[model.rId];
  9358. var match = rel.Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);
  9359. if (match) {
  9360. var name = match[1];
  9361. var mediaId = options.mediaIndex[name];
  9362. return options.media[mediaId];
  9363. }
  9364. }
  9365. return undefined;
  9366. }
  9367. }]);
  9368. return BaseCellAnchorXform;
  9369. }(BaseXform);
  9370. module.exports = BaseCellAnchorXform;
  9371. }, { "../base-xform": 31 }], 56: [function (require, module, exports) {
  9372. "use strict";
  9373. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9374. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9375. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9376. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9377. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9378. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9379. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9380. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9381. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9382. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9383. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9384. var BaseXform = require('../base-xform');
  9385. var BlipXform = require('./blip-xform');
  9386. var BlipFillXform = /*#__PURE__*/function (_BaseXform) {
  9387. _inherits(BlipFillXform, _BaseXform);
  9388. var _super = _createSuper(BlipFillXform);
  9389. function BlipFillXform() {
  9390. var _this;
  9391. _classCallCheck(this, BlipFillXform);
  9392. _this = _super.call(this);
  9393. _this.map = {
  9394. 'a:blip': new BlipXform()
  9395. };
  9396. return _this;
  9397. }
  9398. _createClass(BlipFillXform, [{
  9399. key: "render",
  9400. value: function render(xmlStream, model) {
  9401. xmlStream.openNode(this.tag);
  9402. this.map['a:blip'].render(xmlStream, model); // TODO: options for this + parsing
  9403. xmlStream.openNode('a:stretch');
  9404. xmlStream.leafNode('a:fillRect');
  9405. xmlStream.closeNode();
  9406. xmlStream.closeNode();
  9407. }
  9408. }, {
  9409. key: "parseOpen",
  9410. value: function parseOpen(node) {
  9411. if (this.parser) {
  9412. this.parser.parseOpen(node);
  9413. return true;
  9414. }
  9415. switch (node.name) {
  9416. case this.tag:
  9417. this.reset();
  9418. break;
  9419. default:
  9420. this.parser = this.map[node.name];
  9421. if (this.parser) {
  9422. this.parser.parseOpen(node);
  9423. }
  9424. break;
  9425. }
  9426. return true;
  9427. }
  9428. }, {
  9429. key: "parseText",
  9430. value: function parseText() { }
  9431. }, {
  9432. key: "parseClose",
  9433. value: function parseClose(name) {
  9434. if (this.parser) {
  9435. if (!this.parser.parseClose(name)) {
  9436. this.parser = undefined;
  9437. }
  9438. return true;
  9439. }
  9440. switch (name) {
  9441. case this.tag:
  9442. this.model = this.map['a:blip'].model;
  9443. return false;
  9444. default:
  9445. return true;
  9446. }
  9447. }
  9448. }, {
  9449. key: "tag",
  9450. get: function get() {
  9451. return 'xdr:blipFill';
  9452. }
  9453. }]);
  9454. return BlipFillXform;
  9455. }(BaseXform);
  9456. module.exports = BlipFillXform;
  9457. }, { "../base-xform": 31, "./blip-xform": 57 }], 57: [function (require, module, exports) {
  9458. "use strict";
  9459. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9460. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9461. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9462. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9463. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9464. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9465. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9466. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9467. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9468. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9469. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9470. var BaseXform = require('../base-xform');
  9471. var BlipXform = /*#__PURE__*/function (_BaseXform) {
  9472. _inherits(BlipXform, _BaseXform);
  9473. var _super = _createSuper(BlipXform);
  9474. function BlipXform() {
  9475. _classCallCheck(this, BlipXform);
  9476. return _super.apply(this, arguments);
  9477. }
  9478. _createClass(BlipXform, [{
  9479. key: "render",
  9480. value: function render(xmlStream, model) {
  9481. xmlStream.leafNode(this.tag, {
  9482. 'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
  9483. 'r:embed': model.rId,
  9484. cstate: 'print'
  9485. }); // TODO: handle children (e.g. a:extLst=>a:ext=>a14:useLocalDpi
  9486. }
  9487. }, {
  9488. key: "parseOpen",
  9489. value: function parseOpen(node) {
  9490. switch (node.name) {
  9491. case this.tag:
  9492. this.model = {
  9493. rId: node.attributes['r:embed']
  9494. };
  9495. return true;
  9496. default:
  9497. return true;
  9498. }
  9499. }
  9500. }, {
  9501. key: "parseText",
  9502. value: function parseText() { }
  9503. }, {
  9504. key: "parseClose",
  9505. value: function parseClose(name) {
  9506. switch (name) {
  9507. case this.tag:
  9508. return false;
  9509. default:
  9510. // unprocessed internal nodes
  9511. return true;
  9512. }
  9513. }
  9514. }, {
  9515. key: "tag",
  9516. get: function get() {
  9517. return 'a:blip';
  9518. }
  9519. }]);
  9520. return BlipXform;
  9521. }(BaseXform);
  9522. module.exports = BlipXform;
  9523. }, { "../base-xform": 31 }], 58: [function (require, module, exports) {
  9524. "use strict";
  9525. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9526. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9527. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9528. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9529. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9530. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9531. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9532. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9533. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9534. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9535. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9536. var BaseXform = require('../base-xform');
  9537. var CNvPicPrXform = /*#__PURE__*/function (_BaseXform) {
  9538. _inherits(CNvPicPrXform, _BaseXform);
  9539. var _super = _createSuper(CNvPicPrXform);
  9540. function CNvPicPrXform() {
  9541. _classCallCheck(this, CNvPicPrXform);
  9542. return _super.apply(this, arguments);
  9543. }
  9544. _createClass(CNvPicPrXform, [{
  9545. key: "render",
  9546. value: function render(xmlStream) {
  9547. xmlStream.openNode(this.tag);
  9548. xmlStream.leafNode('a:picLocks', {
  9549. noChangeAspect: '1'
  9550. });
  9551. xmlStream.closeNode();
  9552. }
  9553. }, {
  9554. key: "parseOpen",
  9555. value: function parseOpen(node) {
  9556. switch (node.name) {
  9557. case this.tag:
  9558. return true;
  9559. default:
  9560. return true;
  9561. }
  9562. }
  9563. }, {
  9564. key: "parseText",
  9565. value: function parseText() { }
  9566. }, {
  9567. key: "parseClose",
  9568. value: function parseClose(name) {
  9569. switch (name) {
  9570. case this.tag:
  9571. return false;
  9572. default:
  9573. // unprocessed internal nodes
  9574. return true;
  9575. }
  9576. }
  9577. }, {
  9578. key: "tag",
  9579. get: function get() {
  9580. return 'xdr:cNvPicPr';
  9581. }
  9582. }]);
  9583. return CNvPicPrXform;
  9584. }(BaseXform);
  9585. module.exports = CNvPicPrXform;
  9586. }, { "../base-xform": 31 }], 59: [function (require, module, exports) {
  9587. "use strict";
  9588. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9589. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9590. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9591. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9592. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9593. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9594. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9595. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9596. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9597. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9598. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9599. var BaseXform = require('../base-xform');
  9600. var HlickClickXform = require('./hlink-click-xform');
  9601. var ExtLstXform = require('./ext-lst-xform');
  9602. var CNvPrXform = /*#__PURE__*/function (_BaseXform) {
  9603. _inherits(CNvPrXform, _BaseXform);
  9604. var _super = _createSuper(CNvPrXform);
  9605. function CNvPrXform() {
  9606. var _this;
  9607. _classCallCheck(this, CNvPrXform);
  9608. _this = _super.call(this);
  9609. _this.map = {
  9610. 'a:hlinkClick': new HlickClickXform(),
  9611. 'a:extLst': new ExtLstXform()
  9612. };
  9613. return _this;
  9614. }
  9615. _createClass(CNvPrXform, [{
  9616. key: "render",
  9617. value: function render(xmlStream, model) {
  9618. xmlStream.openNode(this.tag, {
  9619. id: model.index,
  9620. name: "Picture ".concat(model.index)
  9621. });
  9622. this.map['a:hlinkClick'].render(xmlStream, model);
  9623. this.map['a:extLst'].render(xmlStream, model);
  9624. xmlStream.closeNode();
  9625. }
  9626. }, {
  9627. key: "parseOpen",
  9628. value: function parseOpen(node) {
  9629. if (this.parser) {
  9630. this.parser.parseOpen(node);
  9631. return true;
  9632. }
  9633. switch (node.name) {
  9634. case this.tag:
  9635. this.reset();
  9636. break;
  9637. default:
  9638. this.parser = this.map[node.name];
  9639. if (this.parser) {
  9640. this.parser.parseOpen(node);
  9641. }
  9642. break;
  9643. }
  9644. return true;
  9645. }
  9646. }, {
  9647. key: "parseText",
  9648. value: function parseText() { }
  9649. }, {
  9650. key: "parseClose",
  9651. value: function parseClose(name) {
  9652. if (this.parser) {
  9653. if (!this.parser.parseClose(name)) {
  9654. this.parser = undefined;
  9655. }
  9656. return true;
  9657. }
  9658. switch (name) {
  9659. case this.tag:
  9660. this.model = this.map['a:hlinkClick'].model;
  9661. return false;
  9662. default:
  9663. return true;
  9664. }
  9665. }
  9666. }, {
  9667. key: "tag",
  9668. get: function get() {
  9669. return 'xdr:cNvPr';
  9670. }
  9671. }]);
  9672. return CNvPrXform;
  9673. }(BaseXform);
  9674. module.exports = CNvPrXform;
  9675. }, { "../base-xform": 31, "./ext-lst-xform": 62, "./hlink-click-xform": 64 }], 60: [function (require, module, exports) {
  9676. "use strict";
  9677. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9678. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9679. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9680. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9681. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9682. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9683. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9684. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9685. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9686. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9687. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9688. var BaseXform = require('../base-xform');
  9689. var IntegerXform = require('../simple/integer-xform');
  9690. var CellPositionXform = /*#__PURE__*/function (_BaseXform) {
  9691. _inherits(CellPositionXform, _BaseXform);
  9692. var _super = _createSuper(CellPositionXform);
  9693. function CellPositionXform(options) {
  9694. var _this;
  9695. _classCallCheck(this, CellPositionXform);
  9696. _this = _super.call(this);
  9697. _this.tag = options.tag;
  9698. _this.map = {
  9699. 'xdr:col': new IntegerXform({
  9700. tag: 'xdr:col',
  9701. zero: true
  9702. }),
  9703. 'xdr:colOff': new IntegerXform({
  9704. tag: 'xdr:colOff',
  9705. zero: true
  9706. }),
  9707. 'xdr:row': new IntegerXform({
  9708. tag: 'xdr:row',
  9709. zero: true
  9710. }),
  9711. 'xdr:rowOff': new IntegerXform({
  9712. tag: 'xdr:rowOff',
  9713. zero: true
  9714. })
  9715. };
  9716. return _this;
  9717. }
  9718. _createClass(CellPositionXform, [{
  9719. key: "render",
  9720. value: function render(xmlStream, model) {
  9721. xmlStream.openNode(this.tag);
  9722. this.map['xdr:col'].render(xmlStream, model.nativeCol);
  9723. this.map['xdr:colOff'].render(xmlStream, model.nativeColOff);
  9724. this.map['xdr:row'].render(xmlStream, model.nativeRow);
  9725. this.map['xdr:rowOff'].render(xmlStream, model.nativeRowOff);
  9726. xmlStream.closeNode();
  9727. }
  9728. }, {
  9729. key: "parseOpen",
  9730. value: function parseOpen(node) {
  9731. if (this.parser) {
  9732. this.parser.parseOpen(node);
  9733. return true;
  9734. }
  9735. switch (node.name) {
  9736. case this.tag:
  9737. this.reset();
  9738. break;
  9739. default:
  9740. this.parser = this.map[node.name];
  9741. if (this.parser) {
  9742. this.parser.parseOpen(node);
  9743. }
  9744. break;
  9745. }
  9746. return true;
  9747. }
  9748. }, {
  9749. key: "parseText",
  9750. value: function parseText(text) {
  9751. if (this.parser) {
  9752. this.parser.parseText(text);
  9753. }
  9754. }
  9755. }, {
  9756. key: "parseClose",
  9757. value: function parseClose(name) {
  9758. if (this.parser) {
  9759. if (!this.parser.parseClose(name)) {
  9760. this.parser = undefined;
  9761. }
  9762. return true;
  9763. }
  9764. switch (name) {
  9765. case this.tag:
  9766. this.model = {
  9767. nativeCol: this.map['xdr:col'].model,
  9768. nativeColOff: this.map['xdr:colOff'].model,
  9769. nativeRow: this.map['xdr:row'].model,
  9770. nativeRowOff: this.map['xdr:rowOff'].model
  9771. };
  9772. return false;
  9773. default:
  9774. // not quite sure how we get here!
  9775. return true;
  9776. }
  9777. }
  9778. }]);
  9779. return CellPositionXform;
  9780. }(BaseXform);
  9781. module.exports = CellPositionXform;
  9782. }, { "../base-xform": 31, "../simple/integer-xform": 117 }], 61: [function (require, module, exports) {
  9783. "use strict";
  9784. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9785. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9786. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9787. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9788. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9789. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9790. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9791. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9792. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9793. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9794. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9795. var colCache = require('../../../utils/col-cache');
  9796. var XmlStream = require('../../../utils/xml-stream');
  9797. var BaseXform = require('../base-xform');
  9798. var TwoCellAnchorXform = require('./two-cell-anchor-xform');
  9799. var OneCellAnchorXform = require('./one-cell-anchor-xform');
  9800. function getAnchorType(model) {
  9801. var range = typeof model.range === 'string' ? colCache.decode(model.range) : model.range;
  9802. return range.br ? 'xdr:twoCellAnchor' : 'xdr:oneCellAnchor';
  9803. }
  9804. var DrawingXform = /*#__PURE__*/function (_BaseXform) {
  9805. _inherits(DrawingXform, _BaseXform);
  9806. var _super = _createSuper(DrawingXform);
  9807. function DrawingXform() {
  9808. var _this;
  9809. _classCallCheck(this, DrawingXform);
  9810. _this = _super.call(this);
  9811. _this.map = {
  9812. 'xdr:twoCellAnchor': new TwoCellAnchorXform(),
  9813. 'xdr:oneCellAnchor': new OneCellAnchorXform()
  9814. };
  9815. return _this;
  9816. }
  9817. _createClass(DrawingXform, [{
  9818. key: "prepare",
  9819. value: function prepare(model) {
  9820. var _this2 = this;
  9821. model.anchors.forEach(function (item, index) {
  9822. item.anchorType = getAnchorType(item);
  9823. var anchor = _this2.map[item.anchorType];
  9824. anchor.prepare(item, {
  9825. index: index
  9826. });
  9827. });
  9828. }
  9829. }, {
  9830. key: "render",
  9831. value: function render(xmlStream, model) {
  9832. var _this3 = this;
  9833. xmlStream.openXml(XmlStream.StdDocAttributes);
  9834. xmlStream.openNode(this.tag, DrawingXform.DRAWING_ATTRIBUTES);
  9835. model.anchors.forEach(function (item) {
  9836. var anchor = _this3.map[item.anchorType];
  9837. anchor.render(xmlStream, item);
  9838. });
  9839. xmlStream.closeNode();
  9840. }
  9841. }, {
  9842. key: "parseOpen",
  9843. value: function parseOpen(node) {
  9844. if (this.parser) {
  9845. this.parser.parseOpen(node);
  9846. return true;
  9847. }
  9848. switch (node.name) {
  9849. case this.tag:
  9850. this.reset();
  9851. this.model = {
  9852. anchors: []
  9853. };
  9854. break;
  9855. default:
  9856. this.parser = this.map[node.name];
  9857. if (this.parser) {
  9858. this.parser.parseOpen(node);
  9859. }
  9860. break;
  9861. }
  9862. return true;
  9863. }
  9864. }, {
  9865. key: "parseText",
  9866. value: function parseText(text) {
  9867. if (this.parser) {
  9868. this.parser.parseText(text);
  9869. }
  9870. }
  9871. }, {
  9872. key: "parseClose",
  9873. value: function parseClose(name) {
  9874. if (this.parser) {
  9875. if (!this.parser.parseClose(name)) {
  9876. this.model.anchors.push(this.parser.model);
  9877. this.parser = undefined;
  9878. }
  9879. return true;
  9880. }
  9881. switch (name) {
  9882. case this.tag:
  9883. return false;
  9884. default:
  9885. // could be some unrecognised tags
  9886. return true;
  9887. }
  9888. }
  9889. }, {
  9890. key: "reconcile",
  9891. value: function reconcile(model, options) {
  9892. var _this4 = this;
  9893. model.anchors.forEach(function (anchor) {
  9894. if (anchor.br) {
  9895. _this4.map['xdr:twoCellAnchor'].reconcile(anchor, options);
  9896. } else {
  9897. _this4.map['xdr:oneCellAnchor'].reconcile(anchor, options);
  9898. }
  9899. });
  9900. }
  9901. }, {
  9902. key: "tag",
  9903. get: function get() {
  9904. return 'xdr:wsDr';
  9905. }
  9906. }]);
  9907. return DrawingXform;
  9908. }(BaseXform);
  9909. DrawingXform.DRAWING_ATTRIBUTES = {
  9910. 'xmlns:xdr': 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing',
  9911. 'xmlns:a': 'http://schemas.openxmlformats.org/drawingml/2006/main'
  9912. };
  9913. module.exports = DrawingXform;
  9914. }, { "../../../utils/col-cache": 19, "../../../utils/xml-stream": 27, "../base-xform": 31, "./one-cell-anchor-xform": 66, "./two-cell-anchor-xform": 69 }], 62: [function (require, module, exports) {
  9915. "use strict";
  9916. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9917. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9918. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9919. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9920. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9921. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9922. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9923. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9924. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9925. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9926. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9927. var BaseXform = require('../base-xform');
  9928. var ExtLstXform = /*#__PURE__*/function (_BaseXform) {
  9929. _inherits(ExtLstXform, _BaseXform);
  9930. var _super = _createSuper(ExtLstXform);
  9931. function ExtLstXform() {
  9932. _classCallCheck(this, ExtLstXform);
  9933. return _super.apply(this, arguments);
  9934. }
  9935. _createClass(ExtLstXform, [{
  9936. key: "render",
  9937. value: function render(xmlStream) {
  9938. xmlStream.openNode(this.tag);
  9939. xmlStream.openNode('a:ext', {
  9940. uri: '{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}'
  9941. });
  9942. xmlStream.leafNode('a16:creationId', {
  9943. 'xmlns:a16': 'http://schemas.microsoft.com/office/drawing/2014/main',
  9944. id: '{00000000-0008-0000-0000-000002000000}'
  9945. });
  9946. xmlStream.closeNode();
  9947. xmlStream.closeNode();
  9948. }
  9949. }, {
  9950. key: "parseOpen",
  9951. value: function parseOpen(node) {
  9952. switch (node.name) {
  9953. case this.tag:
  9954. return true;
  9955. default:
  9956. return true;
  9957. }
  9958. }
  9959. }, {
  9960. key: "parseText",
  9961. value: function parseText() { }
  9962. }, {
  9963. key: "parseClose",
  9964. value: function parseClose(name) {
  9965. switch (name) {
  9966. case this.tag:
  9967. return false;
  9968. default:
  9969. // unprocessed internal nodes
  9970. return true;
  9971. }
  9972. }
  9973. }, {
  9974. key: "tag",
  9975. get: function get() {
  9976. return 'a:extLst';
  9977. }
  9978. }]);
  9979. return ExtLstXform;
  9980. }(BaseXform);
  9981. module.exports = ExtLstXform;
  9982. }, { "../base-xform": 31 }], 63: [function (require, module, exports) {
  9983. "use strict";
  9984. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9985. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9986. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9987. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9988. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9989. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9990. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9991. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9992. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9993. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  9994. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9995. var BaseXform = require('../base-xform');
  9996. /** https://en.wikipedia.org/wiki/Office_Open_XML_file_formats#DrawingML */
  9997. var EMU_PER_PIXEL_AT_96_DPI = 9525;
  9998. var ExtXform = /*#__PURE__*/function (_BaseXform) {
  9999. _inherits(ExtXform, _BaseXform);
  10000. var _super = _createSuper(ExtXform);
  10001. function ExtXform(options) {
  10002. var _this;
  10003. _classCallCheck(this, ExtXform);
  10004. _this = _super.call(this);
  10005. _this.tag = options.tag;
  10006. _this.map = {};
  10007. return _this;
  10008. }
  10009. _createClass(ExtXform, [{
  10010. key: "render",
  10011. value: function render(xmlStream, model) {
  10012. xmlStream.openNode(this.tag);
  10013. var width = Math.floor(model.width * EMU_PER_PIXEL_AT_96_DPI);
  10014. var height = Math.floor(model.height * EMU_PER_PIXEL_AT_96_DPI);
  10015. xmlStream.addAttribute('cx', width);
  10016. xmlStream.addAttribute('cy', height);
  10017. xmlStream.closeNode();
  10018. }
  10019. }, {
  10020. key: "parseOpen",
  10021. value: function parseOpen(node) {
  10022. if (node.name === this.tag) {
  10023. this.model = {
  10024. width: parseInt(node.attributes.cx || '0', 10) / EMU_PER_PIXEL_AT_96_DPI,
  10025. height: parseInt(node.attributes.cy || '0', 10) / EMU_PER_PIXEL_AT_96_DPI
  10026. };
  10027. return true;
  10028. }
  10029. return false;
  10030. }
  10031. }, {
  10032. key: "parseText",
  10033. value: function parseText()
  10034. /* text */ { }
  10035. }, {
  10036. key: "parseClose",
  10037. value: function parseClose()
  10038. /* name */ {
  10039. return false;
  10040. }
  10041. }]);
  10042. return ExtXform;
  10043. }(BaseXform);
  10044. module.exports = ExtXform;
  10045. }, { "../base-xform": 31 }], 64: [function (require, module, exports) {
  10046. "use strict";
  10047. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10048. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10049. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10050. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10051. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10052. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10053. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10054. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10055. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10056. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  10057. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10058. var BaseXform = require('../base-xform');
  10059. var HLinkClickXform = /*#__PURE__*/function (_BaseXform) {
  10060. _inherits(HLinkClickXform, _BaseXform);
  10061. var _super = _createSuper(HLinkClickXform);
  10062. function HLinkClickXform() {
  10063. _classCallCheck(this, HLinkClickXform);
  10064. return _super.apply(this, arguments);
  10065. }
  10066. _createClass(HLinkClickXform, [{
  10067. key: "render",
  10068. value: function render(xmlStream, model) {
  10069. if (!(model.hyperlinks && model.hyperlinks.rId)) {
  10070. return;
  10071. }
  10072. xmlStream.leafNode(this.tag, {
  10073. 'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
  10074. 'r:id': model.hyperlinks.rId,
  10075. tooltip: model.hyperlinks.tooltip
  10076. });
  10077. }
  10078. }, {
  10079. key: "parseOpen",
  10080. value: function parseOpen(node) {
  10081. switch (node.name) {
  10082. case this.tag:
  10083. this.model = {
  10084. hyperlinks: {
  10085. rId: node.attributes['r:id'],
  10086. tooltip: node.attributes.tooltip
  10087. }
  10088. };
  10089. return true;
  10090. default:
  10091. return true;
  10092. }
  10093. }
  10094. }, {
  10095. key: "parseText",
  10096. value: function parseText() { }
  10097. }, {
  10098. key: "parseClose",
  10099. value: function parseClose() {
  10100. return false;
  10101. }
  10102. }, {
  10103. key: "tag",
  10104. get: function get() {
  10105. return 'a:hlinkClick';
  10106. }
  10107. }]);
  10108. return HLinkClickXform;
  10109. }(BaseXform);
  10110. module.exports = HLinkClickXform;
  10111. }, { "../base-xform": 31 }], 65: [function (require, module, exports) {
  10112. "use strict";
  10113. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10114. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10115. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10116. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10117. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10118. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10119. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10120. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10121. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10122. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  10123. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10124. var BaseXform = require('../base-xform');
  10125. var CNvPrXform = require('./c-nv-pr-xform');
  10126. var CNvPicPrXform = require('./c-nv-pic-pr-xform');
  10127. var NvPicPrXform = /*#__PURE__*/function (_BaseXform) {
  10128. _inherits(NvPicPrXform, _BaseXform);
  10129. var _super = _createSuper(NvPicPrXform);
  10130. function NvPicPrXform() {
  10131. var _this;
  10132. _classCallCheck(this, NvPicPrXform);
  10133. _this = _super.call(this);
  10134. _this.map = {
  10135. 'xdr:cNvPr': new CNvPrXform(),
  10136. 'xdr:cNvPicPr': new CNvPicPrXform()
  10137. };
  10138. return _this;
  10139. }
  10140. _createClass(NvPicPrXform, [{
  10141. key: "render",
  10142. value: function render(xmlStream, model) {
  10143. xmlStream.openNode(this.tag);
  10144. this.map['xdr:cNvPr'].render(xmlStream, model);
  10145. this.map['xdr:cNvPicPr'].render(xmlStream, model);
  10146. xmlStream.closeNode();
  10147. }
  10148. }, {
  10149. key: "parseOpen",
  10150. value: function parseOpen(node) {
  10151. if (this.parser) {
  10152. this.parser.parseOpen(node);
  10153. return true;
  10154. }
  10155. switch (node.name) {
  10156. case this.tag:
  10157. this.reset();
  10158. break;
  10159. default:
  10160. this.parser = this.map[node.name];
  10161. if (this.parser) {
  10162. this.parser.parseOpen(node);
  10163. }
  10164. break;
  10165. }
  10166. return true;
  10167. }
  10168. }, {
  10169. key: "parseText",
  10170. value: function parseText() { }
  10171. }, {
  10172. key: "parseClose",
  10173. value: function parseClose(name) {
  10174. if (this.parser) {
  10175. if (!this.parser.parseClose(name)) {
  10176. this.parser = undefined;
  10177. }
  10178. return true;
  10179. }
  10180. switch (name) {
  10181. case this.tag:
  10182. this.model = this.map['xdr:cNvPr'].model;
  10183. return false;
  10184. default:
  10185. return true;
  10186. }
  10187. }
  10188. }, {
  10189. key: "tag",
  10190. get: function get() {
  10191. return 'xdr:nvPicPr';
  10192. }
  10193. }]);
  10194. return NvPicPrXform;
  10195. }(BaseXform);
  10196. module.exports = NvPicPrXform;
  10197. }, { "../base-xform": 31, "./c-nv-pic-pr-xform": 58, "./c-nv-pr-xform": 59 }], 66: [function (require, module, exports) {
  10198. "use strict";
  10199. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10200. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10201. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10202. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10203. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10204. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10205. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10206. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10207. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10208. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  10209. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10210. var BaseCellAnchorXform = require('./base-cell-anchor-xform');
  10211. var StaticXform = require('../static-xform');
  10212. var CellPositionXform = require('./cell-position-xform');
  10213. var ExtXform = require('./ext-xform');
  10214. var PicXform = require('./pic-xform');
  10215. var OneCellAnchorXform = /*#__PURE__*/function (_BaseCellAnchorXform) {
  10216. _inherits(OneCellAnchorXform, _BaseCellAnchorXform);
  10217. var _super = _createSuper(OneCellAnchorXform);
  10218. function OneCellAnchorXform() {
  10219. var _this;
  10220. _classCallCheck(this, OneCellAnchorXform);
  10221. _this = _super.call(this);
  10222. _this.map = {
  10223. 'xdr:from': new CellPositionXform({
  10224. tag: 'xdr:from'
  10225. }),
  10226. 'xdr:ext': new ExtXform({
  10227. tag: 'xdr:ext'
  10228. }),
  10229. 'xdr:pic': new PicXform(),
  10230. 'xdr:clientData': new StaticXform({
  10231. tag: 'xdr:clientData'
  10232. })
  10233. };
  10234. return _this;
  10235. }
  10236. _createClass(OneCellAnchorXform, [{
  10237. key: "prepare",
  10238. value: function prepare(model, options) {
  10239. this.map['xdr:pic'].prepare(model.picture, options);
  10240. }
  10241. }, {
  10242. key: "render",
  10243. value: function render(xmlStream, model) {
  10244. xmlStream.openNode(this.tag, {
  10245. editAs: model.range.editAs || 'oneCell'
  10246. });
  10247. this.map['xdr:from'].render(xmlStream, model.range.tl);
  10248. this.map['xdr:ext'].render(xmlStream, model.range.ext);
  10249. this.map['xdr:pic'].render(xmlStream, model.picture);
  10250. this.map['xdr:clientData'].render(xmlStream, {});
  10251. xmlStream.closeNode();
  10252. }
  10253. }, {
  10254. key: "parseClose",
  10255. value: function parseClose(name) {
  10256. if (this.parser) {
  10257. if (!this.parser.parseClose(name)) {
  10258. this.parser = undefined;
  10259. }
  10260. return true;
  10261. }
  10262. switch (name) {
  10263. case this.tag:
  10264. this.model.range.tl = this.map['xdr:from'].model;
  10265. this.model.range.ext = this.map['xdr:ext'].model;
  10266. this.model.picture = this.map['xdr:pic'].model;
  10267. return false;
  10268. default:
  10269. // could be some unrecognised tags
  10270. return true;
  10271. }
  10272. }
  10273. }, {
  10274. key: "reconcile",
  10275. value: function reconcile(model, options) {
  10276. model.medium = this.reconcilePicture(model.picture, options);
  10277. }
  10278. }, {
  10279. key: "tag",
  10280. get: function get() {
  10281. return 'xdr:oneCellAnchor';
  10282. }
  10283. }]);
  10284. return OneCellAnchorXform;
  10285. }(BaseCellAnchorXform);
  10286. module.exports = OneCellAnchorXform;
  10287. }, { "../static-xform": 119, "./base-cell-anchor-xform": 55, "./cell-position-xform": 60, "./ext-xform": 63, "./pic-xform": 67 }], 67: [function (require, module, exports) {
  10288. "use strict";
  10289. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10290. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10291. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10292. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10293. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10294. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10295. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10296. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10297. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10298. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  10299. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10300. var BaseXform = require('../base-xform');
  10301. var StaticXform = require('../static-xform');
  10302. var BlipFillXform = require('./blip-fill-xform');
  10303. var NvPicPrXform = require('./nv-pic-pr-xform');
  10304. var spPrJSON = require('./sp-pr');
  10305. var PicXform = /*#__PURE__*/function (_BaseXform) {
  10306. _inherits(PicXform, _BaseXform);
  10307. var _super = _createSuper(PicXform);
  10308. function PicXform() {
  10309. var _this;
  10310. _classCallCheck(this, PicXform);
  10311. _this = _super.call(this);
  10312. _this.map = {
  10313. 'xdr:nvPicPr': new NvPicPrXform(),
  10314. 'xdr:blipFill': new BlipFillXform(),
  10315. 'xdr:spPr': new StaticXform(spPrJSON)
  10316. };
  10317. return _this;
  10318. }
  10319. _createClass(PicXform, [{
  10320. key: "prepare",
  10321. value: function prepare(model, options) {
  10322. model.index = options.index + 1;
  10323. }
  10324. }, {
  10325. key: "render",
  10326. value: function render(xmlStream, model) {
  10327. xmlStream.openNode(this.tag);
  10328. this.map['xdr:nvPicPr'].render(xmlStream, model);
  10329. this.map['xdr:blipFill'].render(xmlStream, model);
  10330. this.map['xdr:spPr'].render(xmlStream, model);
  10331. xmlStream.closeNode();
  10332. }
  10333. }, {
  10334. key: "parseOpen",
  10335. value: function parseOpen(node) {
  10336. if (this.parser) {
  10337. this.parser.parseOpen(node);
  10338. return true;
  10339. }
  10340. switch (node.name) {
  10341. case this.tag:
  10342. this.reset();
  10343. break;
  10344. default:
  10345. this.parser = this.map[node.name];
  10346. if (this.parser) {
  10347. this.parser.parseOpen(node);
  10348. }
  10349. break;
  10350. }
  10351. return true;
  10352. }
  10353. }, {
  10354. key: "parseText",
  10355. value: function parseText() { }
  10356. }, {
  10357. key: "parseClose",
  10358. value: function parseClose(name) {
  10359. if (this.parser) {
  10360. if (!this.parser.parseClose(name)) {
  10361. this.mergeModel(this.parser.model);
  10362. this.parser = undefined;
  10363. }
  10364. return true;
  10365. }
  10366. switch (name) {
  10367. case this.tag:
  10368. return false;
  10369. default:
  10370. // not quite sure how we get here!
  10371. return true;
  10372. }
  10373. }
  10374. }, {
  10375. key: "tag",
  10376. get: function get() {
  10377. return 'xdr:pic';
  10378. }
  10379. }]);
  10380. return PicXform;
  10381. }(BaseXform);
  10382. module.exports = PicXform;
  10383. }, { "../base-xform": 31, "../static-xform": 119, "./blip-fill-xform": 56, "./nv-pic-pr-xform": 65, "./sp-pr": 68 }], 68: [function (require, module, exports) {
  10384. "use strict";
  10385. module.exports = {
  10386. tag: 'xdr:spPr',
  10387. c: [{
  10388. tag: 'a:xfrm',
  10389. c: [{
  10390. tag: 'a:off',
  10391. $: {
  10392. x: '0',
  10393. y: '0'
  10394. }
  10395. }, {
  10396. tag: 'a:ext',
  10397. $: {
  10398. cx: '0',
  10399. cy: '0'
  10400. }
  10401. }]
  10402. }, {
  10403. tag: 'a:prstGeom',
  10404. $: {
  10405. prst: 'rect'
  10406. },
  10407. c: [{
  10408. tag: 'a:avLst'
  10409. }]
  10410. }]
  10411. };
  10412. }, {}], 69: [function (require, module, exports) {
  10413. "use strict";
  10414. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10415. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10416. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10417. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10418. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10419. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10420. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10421. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10422. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10423. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  10424. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10425. var BaseCellAnchorXform = require('./base-cell-anchor-xform');
  10426. var StaticXform = require('../static-xform');
  10427. var CellPositionXform = require('./cell-position-xform');
  10428. var PicXform = require('./pic-xform');
  10429. var TwoCellAnchorXform = /*#__PURE__*/function (_BaseCellAnchorXform) {
  10430. _inherits(TwoCellAnchorXform, _BaseCellAnchorXform);
  10431. var _super = _createSuper(TwoCellAnchorXform);
  10432. function TwoCellAnchorXform() {
  10433. var _this;
  10434. _classCallCheck(this, TwoCellAnchorXform);
  10435. _this = _super.call(this);
  10436. _this.map = {
  10437. 'xdr:from': new CellPositionXform({
  10438. tag: 'xdr:from'
  10439. }),
  10440. 'xdr:to': new CellPositionXform({
  10441. tag: 'xdr:to'
  10442. }),
  10443. 'xdr:pic': new PicXform(),
  10444. 'xdr:clientData': new StaticXform({
  10445. tag: 'xdr:clientData'
  10446. })
  10447. };
  10448. return _this;
  10449. }
  10450. _createClass(TwoCellAnchorXform, [{
  10451. key: "prepare",
  10452. value: function prepare(model, options) {
  10453. this.map['xdr:pic'].prepare(model.picture, options);
  10454. }
  10455. }, {
  10456. key: "render",
  10457. value: function render(xmlStream, model) {
  10458. xmlStream.openNode(this.tag, {
  10459. editAs: model.range.editAs || 'oneCell'
  10460. });
  10461. this.map['xdr:from'].render(xmlStream, model.range.tl);
  10462. this.map['xdr:to'].render(xmlStream, model.range.br);
  10463. this.map['xdr:pic'].render(xmlStream, model.picture);
  10464. this.map['xdr:clientData'].render(xmlStream, {});
  10465. xmlStream.closeNode();
  10466. }
  10467. }, {
  10468. key: "parseClose",
  10469. value: function parseClose(name) {
  10470. if (this.parser) {
  10471. if (!this.parser.parseClose(name)) {
  10472. this.parser = undefined;
  10473. }
  10474. return true;
  10475. }
  10476. switch (name) {
  10477. case this.tag:
  10478. this.model.range.tl = this.map['xdr:from'].model;
  10479. this.model.range.br = this.map['xdr:to'].model;
  10480. this.model.picture = this.map['xdr:pic'].model;
  10481. return false;
  10482. default:
  10483. // could be some unrecognised tags
  10484. return true;
  10485. }
  10486. }
  10487. }, {
  10488. key: "reconcile",
  10489. value: function reconcile(model, options) {
  10490. model.medium = this.reconcilePicture(model.picture, options);
  10491. }
  10492. }, {
  10493. key: "tag",
  10494. get: function get() {
  10495. return 'xdr:twoCellAnchor';
  10496. }
  10497. }]);
  10498. return TwoCellAnchorXform;
  10499. }(BaseCellAnchorXform);
  10500. module.exports = TwoCellAnchorXform;
  10501. }, { "../static-xform": 119, "./base-cell-anchor-xform": 55, "./cell-position-xform": 60, "./pic-xform": 67 }], 70: [function (require, module, exports) {
  10502. "use strict";
  10503. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10504. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10505. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10506. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10507. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10508. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10509. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10510. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10511. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10512. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  10513. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10514. var BaseXform = require('./base-xform');
  10515. var ListXform = /*#__PURE__*/function (_BaseXform) {
  10516. _inherits(ListXform, _BaseXform);
  10517. var _super = _createSuper(ListXform);
  10518. function ListXform(options) {
  10519. var _this;
  10520. _classCallCheck(this, ListXform);
  10521. _this = _super.call(this);
  10522. _this.tag = options.tag;
  10523. _this.always = !!options.always;
  10524. _this.count = options.count;
  10525. _this.empty = options.empty;
  10526. _this.$count = options.$count || 'count';
  10527. _this.$ = options.$;
  10528. _this.childXform = options.childXform;
  10529. _this.maxItems = options.maxItems;
  10530. return _this;
  10531. }
  10532. _createClass(ListXform, [{
  10533. key: "prepare",
  10534. value: function prepare(model, options) {
  10535. var childXform = this.childXform;
  10536. if (model) {
  10537. model.forEach(function (childModel, index) {
  10538. options.index = index;
  10539. childXform.prepare(childModel, options);
  10540. });
  10541. }
  10542. }
  10543. }, {
  10544. key: "render",
  10545. value: function render(xmlStream, model) {
  10546. if (this.always || model && model.length) {
  10547. xmlStream.openNode(this.tag, this.$);
  10548. if (this.count) {
  10549. xmlStream.addAttribute(this.$count, model && model.length || 0);
  10550. }
  10551. var childXform = this.childXform;
  10552. (model || []).forEach(function (childModel, index) {
  10553. childXform.render(xmlStream, childModel, index);
  10554. });
  10555. xmlStream.closeNode();
  10556. } else if (this.empty) {
  10557. xmlStream.leafNode(this.tag);
  10558. }
  10559. }
  10560. }, {
  10561. key: "parseOpen",
  10562. value: function parseOpen(node) {
  10563. if (this.parser) {
  10564. this.parser.parseOpen(node);
  10565. return true;
  10566. }
  10567. switch (node.name) {
  10568. case this.tag:
  10569. this.model = [];
  10570. return true;
  10571. default:
  10572. if (this.childXform.parseOpen(node)) {
  10573. this.parser = this.childXform;
  10574. return true;
  10575. }
  10576. return false;
  10577. }
  10578. }
  10579. }, {
  10580. key: "parseText",
  10581. value: function parseText(text) {
  10582. if (this.parser) {
  10583. this.parser.parseText(text);
  10584. }
  10585. }
  10586. }, {
  10587. key: "parseClose",
  10588. value: function parseClose(name) {
  10589. if (this.parser) {
  10590. if (!this.parser.parseClose(name)) {
  10591. this.model.push(this.parser.model);
  10592. this.parser = undefined;
  10593. if (this.maxItems && this.model.length > this.maxItems) {
  10594. throw new Error("Max ".concat(this.childXform.tag, " count (").concat(this.maxItems, ") exceeded"));
  10595. }
  10596. }
  10597. return true;
  10598. }
  10599. return false;
  10600. }
  10601. }, {
  10602. key: "reconcile",
  10603. value: function reconcile(model, options) {
  10604. if (model) {
  10605. var childXform = this.childXform;
  10606. model.forEach(function (childModel) {
  10607. childXform.reconcile(childModel, options);
  10608. });
  10609. }
  10610. }
  10611. }]);
  10612. return ListXform;
  10613. }(BaseXform);
  10614. module.exports = ListXform;
  10615. }, { "./base-xform": 31 }], 71: [function (require, module, exports) {
  10616. "use strict";
  10617. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10618. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10619. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10620. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10621. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10622. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10623. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10624. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10625. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10626. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  10627. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10628. var colCache = require('../../../utils/col-cache');
  10629. var BaseXform = require('../base-xform');
  10630. var AutoFilterXform = /*#__PURE__*/function (_BaseXform) {
  10631. _inherits(AutoFilterXform, _BaseXform);
  10632. var _super = _createSuper(AutoFilterXform);
  10633. function AutoFilterXform() {
  10634. _classCallCheck(this, AutoFilterXform);
  10635. return _super.apply(this, arguments);
  10636. }
  10637. _createClass(AutoFilterXform, [{
  10638. key: "render",
  10639. value: function render(xmlStream, model) {
  10640. if (model) {
  10641. if (typeof model === 'string') {
  10642. // assume range
  10643. xmlStream.leafNode('autoFilter', {
  10644. ref: model
  10645. });
  10646. } else {
  10647. var getAddress = function getAddress(addr) {
  10648. if (typeof addr === 'string') {
  10649. return addr;
  10650. }
  10651. return colCache.getAddress(addr.row, addr.column).address;
  10652. };
  10653. var firstAddress = getAddress(model.from);
  10654. var secondAddress = getAddress(model.to);
  10655. if (firstAddress && secondAddress) {
  10656. xmlStream.leafNode('autoFilter', {
  10657. ref: "".concat(firstAddress, ":").concat(secondAddress)
  10658. });
  10659. }
  10660. }
  10661. }
  10662. }
  10663. }, {
  10664. key: "parseOpen",
  10665. value: function parseOpen(node) {
  10666. if (node.name === 'autoFilter') {
  10667. this.model = node.attributes.ref;
  10668. }
  10669. }
  10670. }, {
  10671. key: "tag",
  10672. get: function get() {
  10673. return 'autoFilter';
  10674. }
  10675. }]);
  10676. return AutoFilterXform;
  10677. }(BaseXform);
  10678. module.exports = AutoFilterXform;
  10679. }, { "../../../utils/col-cache": 19, "../base-xform": 31 }], 72: [function (require, module, exports) {
  10680. "use strict";
  10681. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10682. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  10683. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  10684. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  10685. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10686. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10687. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10688. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10689. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10690. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10691. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10692. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10693. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  10694. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10695. var utils = require('../../../utils/utils');
  10696. var BaseXform = require('../base-xform');
  10697. var Range = require('../../../doc/range');
  10698. var Enums = require('../../../doc/enums');
  10699. var RichTextXform = require('../strings/rich-text-xform');
  10700. function getValueType(v) {
  10701. if (v === null || v === undefined) {
  10702. return Enums.ValueType.Null;
  10703. }
  10704. if (v instanceof String || typeof v === 'string') {
  10705. return Enums.ValueType.String;
  10706. }
  10707. if (typeof v === 'number') {
  10708. return Enums.ValueType.Number;
  10709. }
  10710. if (typeof v === 'boolean') {
  10711. return Enums.ValueType.Boolean;
  10712. }
  10713. if (v instanceof Date) {
  10714. return Enums.ValueType.Date;
  10715. }
  10716. if (v.text && v.hyperlink) {
  10717. return Enums.ValueType.Hyperlink;
  10718. }
  10719. if (v.formula) {
  10720. return Enums.ValueType.Formula;
  10721. }
  10722. if (v.error) {
  10723. return Enums.ValueType.Error;
  10724. }
  10725. throw new Error('I could not understand type of value');
  10726. }
  10727. function getEffectiveCellType(cell) {
  10728. switch (cell.type) {
  10729. case Enums.ValueType.Formula:
  10730. return getValueType(cell.result);
  10731. default:
  10732. return cell.type;
  10733. }
  10734. }
  10735. var CellXform = /*#__PURE__*/function (_BaseXform) {
  10736. _inherits(CellXform, _BaseXform);
  10737. var _super = _createSuper(CellXform);
  10738. function CellXform() {
  10739. var _this;
  10740. _classCallCheck(this, CellXform);
  10741. _this = _super.call(this);
  10742. _this.richTextXForm = new RichTextXform();
  10743. return _this;
  10744. }
  10745. _createClass(CellXform, [{
  10746. key: "prepare",
  10747. value: function prepare(model, options) {
  10748. var styleId = options.styles.addStyleModel(model.style || {}, getEffectiveCellType(model));
  10749. if (styleId) {
  10750. model.styleId = styleId;
  10751. }
  10752. if (model.comment) {
  10753. options.comments.push(_objectSpread(_objectSpread({}, model.comment), {}, {
  10754. ref: model.address
  10755. }));
  10756. }
  10757. switch (model.type) {
  10758. case Enums.ValueType.String:
  10759. case Enums.ValueType.RichText:
  10760. if (options.sharedStrings) {
  10761. model.ssId = options.sharedStrings.add(model.value);
  10762. }
  10763. break;
  10764. case Enums.ValueType.Date:
  10765. if (options.date1904) {
  10766. model.date1904 = true;
  10767. }
  10768. break;
  10769. case Enums.ValueType.Hyperlink:
  10770. if (options.sharedStrings && model.text !== undefined && model.text !== null) {
  10771. model.ssId = options.sharedStrings.add(model.text);
  10772. }
  10773. options.hyperlinks.push({
  10774. address: model.address,
  10775. target: model.hyperlink,
  10776. tooltip: model.tooltip
  10777. });
  10778. break;
  10779. case Enums.ValueType.Merge:
  10780. options.merges.add(model);
  10781. break;
  10782. case Enums.ValueType.Formula:
  10783. if (options.date1904) {
  10784. // in case valueType is date
  10785. model.date1904 = true;
  10786. }
  10787. if (model.shareType === 'shared') {
  10788. model.si = options.siFormulae++;
  10789. }
  10790. if (model.formula) {
  10791. options.formulae[model.address] = model;
  10792. } else if (model.sharedFormula) {
  10793. var master = options.formulae[model.sharedFormula];
  10794. if (!master) {
  10795. throw new Error("Shared Formula master must exist above and or left of clone for cell ".concat(model.address));
  10796. }
  10797. if (master.si === undefined) {
  10798. master.shareType = 'shared';
  10799. master.si = options.siFormulae++;
  10800. master.range = new Range(master.address, model.address);
  10801. } else if (master.range) {
  10802. master.range.expandToAddress(model.address);
  10803. }
  10804. model.si = master.si;
  10805. }
  10806. break;
  10807. default:
  10808. break;
  10809. }
  10810. }
  10811. }, {
  10812. key: "renderFormula",
  10813. value: function renderFormula(xmlStream, model) {
  10814. var attrs = null;
  10815. switch (model.shareType) {
  10816. case 'shared':
  10817. attrs = {
  10818. t: 'shared',
  10819. ref: model.ref || model.range.range,
  10820. si: model.si
  10821. };
  10822. break;
  10823. case 'array':
  10824. attrs = {
  10825. t: 'array',
  10826. ref: model.ref
  10827. };
  10828. break;
  10829. default:
  10830. if (model.si !== undefined) {
  10831. attrs = {
  10832. t: 'shared',
  10833. si: model.si
  10834. };
  10835. }
  10836. break;
  10837. }
  10838. switch (getValueType(model.result)) {
  10839. case Enums.ValueType.Null:
  10840. // ?
  10841. xmlStream.leafNode('f', attrs, model.formula);
  10842. break;
  10843. case Enums.ValueType.String:
  10844. // oddly, formula results don't ever use shared strings
  10845. xmlStream.addAttribute('t', 'str');
  10846. xmlStream.leafNode('f', attrs, model.formula);
  10847. xmlStream.leafNode('v', null, model.result);
  10848. break;
  10849. case Enums.ValueType.Number:
  10850. xmlStream.leafNode('f', attrs, model.formula);
  10851. xmlStream.leafNode('v', null, model.result);
  10852. break;
  10853. case Enums.ValueType.Boolean:
  10854. xmlStream.addAttribute('t', 'b');
  10855. xmlStream.leafNode('f', attrs, model.formula);
  10856. xmlStream.leafNode('v', null, model.result ? 1 : 0);
  10857. break;
  10858. case Enums.ValueType.Error:
  10859. xmlStream.addAttribute('t', 'e');
  10860. xmlStream.leafNode('f', attrs, model.formula);
  10861. xmlStream.leafNode('v', null, model.result.error);
  10862. break;
  10863. case Enums.ValueType.Date:
  10864. xmlStream.leafNode('f', attrs, model.formula);
  10865. xmlStream.leafNode('v', null, utils.dateToExcel(model.result, model.date1904));
  10866. break;
  10867. // case Enums.ValueType.Hyperlink: // ??
  10868. // case Enums.ValueType.Formula:
  10869. default:
  10870. throw new Error('I could not understand type of value');
  10871. }
  10872. }
  10873. }, {
  10874. key: "render",
  10875. value: function render(xmlStream, model) {
  10876. var _this2 = this;
  10877. if (model.type === Enums.ValueType.Null && !model.styleId) {
  10878. // if null and no style, exit
  10879. return;
  10880. }
  10881. xmlStream.openNode('c');
  10882. xmlStream.addAttribute('r', model.address);
  10883. if (model.styleId) {
  10884. xmlStream.addAttribute('s', model.styleId);
  10885. }
  10886. switch (model.type) {
  10887. case Enums.ValueType.Null:
  10888. break;
  10889. case Enums.ValueType.Number:
  10890. xmlStream.leafNode('v', null, model.value);
  10891. break;
  10892. case Enums.ValueType.Boolean:
  10893. xmlStream.addAttribute('t', 'b');
  10894. xmlStream.leafNode('v', null, model.value ? '1' : '0');
  10895. break;
  10896. case Enums.ValueType.Error:
  10897. xmlStream.addAttribute('t', 'e');
  10898. xmlStream.leafNode('v', null, model.value.error);
  10899. break;
  10900. case Enums.ValueType.String:
  10901. case Enums.ValueType.RichText:
  10902. if (model.ssId !== undefined) {
  10903. xmlStream.addAttribute('t', 's');
  10904. xmlStream.leafNode('v', null, model.ssId);
  10905. } else if (model.value && model.value.richText) {
  10906. xmlStream.addAttribute('t', 'inlineStr');
  10907. xmlStream.openNode('is');
  10908. model.value.richText.forEach(function (text) {
  10909. _this2.richTextXForm.render(xmlStream, text);
  10910. });
  10911. xmlStream.closeNode('is');
  10912. } else {
  10913. xmlStream.addAttribute('t', 'str');
  10914. xmlStream.leafNode('v', null, model.value);
  10915. }
  10916. break;
  10917. case Enums.ValueType.Date:
  10918. xmlStream.leafNode('v', null, utils.dateToExcel(model.value, model.date1904));
  10919. break;
  10920. case Enums.ValueType.Hyperlink:
  10921. if (model.ssId !== undefined) {
  10922. xmlStream.addAttribute('t', 's');
  10923. xmlStream.leafNode('v', null, model.ssId);
  10924. } else {
  10925. xmlStream.addAttribute('t', 'str');
  10926. xmlStream.leafNode('v', null, model.text);
  10927. }
  10928. break;
  10929. case Enums.ValueType.Formula:
  10930. this.renderFormula(xmlStream, model);
  10931. break;
  10932. case Enums.ValueType.Merge:
  10933. // nothing to add
  10934. break;
  10935. default:
  10936. break;
  10937. }
  10938. xmlStream.closeNode(); // </c>
  10939. }
  10940. }, {
  10941. key: "parseOpen",
  10942. value: function parseOpen(node) {
  10943. if (this.parser) {
  10944. this.parser.parseOpen(node);
  10945. return true;
  10946. }
  10947. switch (node.name) {
  10948. case 'c':
  10949. // const address = colCache.decodeAddress(node.attributes.r);
  10950. this.model = {
  10951. address: node.attributes.r
  10952. };
  10953. this.t = node.attributes.t;
  10954. if (node.attributes.s) {
  10955. this.model.styleId = parseInt(node.attributes.s, 10);
  10956. }
  10957. return true;
  10958. case 'f':
  10959. this.currentNode = 'f';
  10960. this.model.si = node.attributes.si;
  10961. this.model.shareType = node.attributes.t;
  10962. this.model.ref = node.attributes.ref;
  10963. return true;
  10964. case 'v':
  10965. this.currentNode = 'v';
  10966. return true;
  10967. case 't':
  10968. this.currentNode = 't';
  10969. return true;
  10970. case 'r':
  10971. this.parser = this.richTextXForm;
  10972. this.parser.parseOpen(node);
  10973. return true;
  10974. default:
  10975. return false;
  10976. }
  10977. }
  10978. }, {
  10979. key: "parseText",
  10980. value: function parseText(text) {
  10981. if (this.parser) {
  10982. this.parser.parseText(text);
  10983. return;
  10984. }
  10985. switch (this.currentNode) {
  10986. case 'f':
  10987. this.model.formula = this.model.formula ? this.model.formula + text : text;
  10988. break;
  10989. case 'v':
  10990. case 't':
  10991. if (this.model.value && this.model.value.richText) {
  10992. this.model.value.richText.text = this.model.value.richText.text ? this.model.value.richText.text + text : text;
  10993. } else {
  10994. this.model.value = this.model.value ? this.model.value + text : text;
  10995. }
  10996. break;
  10997. default:
  10998. break;
  10999. }
  11000. }
  11001. }, {
  11002. key: "parseClose",
  11003. value: function parseClose(name) {
  11004. switch (name) {
  11005. case 'c':
  11006. {
  11007. var model = this.model; // first guess on cell type
  11008. if (model.formula || model.shareType) {
  11009. model.type = Enums.ValueType.Formula;
  11010. if (model.value) {
  11011. if (this.t === 'str') {
  11012. model.result = utils.xmlDecode(model.value);
  11013. } else if (this.t === 'b') {
  11014. model.result = parseInt(model.value, 10) !== 0;
  11015. } else if (this.t === 'e') {
  11016. model.result = {
  11017. error: model.value
  11018. };
  11019. } else {
  11020. model.result = parseFloat(model.value);
  11021. }
  11022. model.value = undefined;
  11023. }
  11024. } else if (model.value !== undefined) {
  11025. switch (this.t) {
  11026. case 's':
  11027. model.type = Enums.ValueType.String;
  11028. model.value = parseInt(model.value, 10);
  11029. break;
  11030. case 'str':
  11031. model.type = Enums.ValueType.String;
  11032. model.value = utils.xmlDecode(model.value);
  11033. break;
  11034. case 'inlineStr':
  11035. model.type = Enums.ValueType.String;
  11036. break;
  11037. case 'b':
  11038. model.type = Enums.ValueType.Boolean;
  11039. model.value = parseInt(model.value, 10) !== 0;
  11040. break;
  11041. case 'e':
  11042. model.type = Enums.ValueType.Error;
  11043. model.value = {
  11044. error: model.value
  11045. };
  11046. break;
  11047. default:
  11048. model.type = Enums.ValueType.Number;
  11049. model.value = parseFloat(model.value);
  11050. break;
  11051. }
  11052. } else if (model.styleId) {
  11053. model.type = Enums.ValueType.Null;
  11054. } else {
  11055. model.type = Enums.ValueType.Merge;
  11056. }
  11057. return false;
  11058. }
  11059. case 'f':
  11060. case 'v':
  11061. case 'is':
  11062. this.currentNode = undefined;
  11063. return true;
  11064. case 't':
  11065. if (this.parser) {
  11066. this.parser.parseClose(name);
  11067. return true;
  11068. }
  11069. this.currentNode = undefined;
  11070. return true;
  11071. case 'r':
  11072. this.model.value = this.model.value || {};
  11073. this.model.value.richText = this.model.value.richText || [];
  11074. this.model.value.richText.push(this.parser.model);
  11075. this.parser = undefined;
  11076. this.currentNode = undefined;
  11077. return true;
  11078. default:
  11079. if (this.parser) {
  11080. this.parser.parseClose(name);
  11081. return true;
  11082. }
  11083. return false;
  11084. }
  11085. }
  11086. }, {
  11087. key: "reconcile",
  11088. value: function reconcile(model, options) {
  11089. var style = model.styleId && options.styles && options.styles.getStyleModel(model.styleId);
  11090. if (style) {
  11091. model.style = style;
  11092. }
  11093. if (model.styleId !== undefined) {
  11094. model.styleId = undefined;
  11095. }
  11096. switch (model.type) {
  11097. case Enums.ValueType.String:
  11098. if (typeof model.value === 'number') {
  11099. if (options.sharedStrings) {
  11100. model.value = options.sharedStrings.getString(model.value);
  11101. }
  11102. }
  11103. if (model.value.richText) {
  11104. model.type = Enums.ValueType.RichText;
  11105. }
  11106. break;
  11107. case Enums.ValueType.Number:
  11108. if (style && utils.isDateFmt(style.numFmt)) {
  11109. model.type = Enums.ValueType.Date;
  11110. model.value = utils.excelToDate(model.value, options.date1904);
  11111. }
  11112. break;
  11113. case Enums.ValueType.Formula:
  11114. if (model.result !== undefined && style && utils.isDateFmt(style.numFmt)) {
  11115. model.result = utils.excelToDate(model.result, options.date1904);
  11116. }
  11117. if (model.shareType === 'shared') {
  11118. if (model.ref) {
  11119. // master
  11120. options.formulae[model.si] = model.address;
  11121. } else {
  11122. // slave
  11123. model.sharedFormula = options.formulae[model.si];
  11124. delete model.shareType;
  11125. }
  11126. delete model.si;
  11127. }
  11128. break;
  11129. default:
  11130. break;
  11131. } // look for hyperlink
  11132. var hyperlink = options.hyperlinkMap[model.address];
  11133. if (hyperlink) {
  11134. if (model.type === Enums.ValueType.Formula) {
  11135. model.text = model.result;
  11136. model.result = undefined;
  11137. } else {
  11138. model.text = model.value;
  11139. model.value = undefined;
  11140. }
  11141. model.type = Enums.ValueType.Hyperlink;
  11142. model.hyperlink = hyperlink;
  11143. }
  11144. var comment = options.commentsMap && options.commentsMap[model.address];
  11145. if (comment) {
  11146. model.comment = comment;
  11147. }
  11148. }
  11149. }, {
  11150. key: "tag",
  11151. get: function get() {
  11152. return 'c';
  11153. }
  11154. }]);
  11155. return CellXform;
  11156. }(BaseXform);
  11157. module.exports = CellXform;
  11158. }, { "../../../doc/enums": 7, "../../../doc/range": 10, "../../../utils/utils": 26, "../base-xform": 31, "../strings/rich-text-xform": 121 }], 73: [function (require, module, exports) {
  11159. "use strict";
  11160. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11161. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11162. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11163. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11164. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11165. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11166. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11167. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11168. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11169. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11170. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11171. var BaseXform = require('../../base-xform');
  11172. var CfIconExtXform = /*#__PURE__*/function (_BaseXform) {
  11173. _inherits(CfIconExtXform, _BaseXform);
  11174. var _super = _createSuper(CfIconExtXform);
  11175. function CfIconExtXform() {
  11176. _classCallCheck(this, CfIconExtXform);
  11177. return _super.apply(this, arguments);
  11178. }
  11179. _createClass(CfIconExtXform, [{
  11180. key: "render",
  11181. value: function render(xmlStream, model) {
  11182. xmlStream.leafNode(this.tag, {
  11183. iconSet: model.iconSet,
  11184. iconId: model.iconId
  11185. });
  11186. }
  11187. }, {
  11188. key: "parseOpen",
  11189. value: function parseOpen(_ref) {
  11190. var attributes = _ref.attributes;
  11191. this.model = {
  11192. iconSet: attributes.iconSet,
  11193. iconId: BaseXform.toIntValue(attributes.iconId)
  11194. };
  11195. }
  11196. }, {
  11197. key: "parseClose",
  11198. value: function parseClose(name) {
  11199. return name !== this.tag;
  11200. }
  11201. }, {
  11202. key: "tag",
  11203. get: function get() {
  11204. return 'x14:cfIcon';
  11205. }
  11206. }]);
  11207. return CfIconExtXform;
  11208. }(BaseXform);
  11209. module.exports = CfIconExtXform;
  11210. }, { "../../base-xform": 31 }], 74: [function (require, module, exports) {
  11211. "use strict";
  11212. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11213. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11214. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11215. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11216. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11217. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11218. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11219. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11220. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11221. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11222. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11223. var _require = require('uuid'),
  11224. uuidv4 = _require.v4;
  11225. var BaseXform = require('../../base-xform');
  11226. var CompositeXform = require('../../composite-xform');
  11227. var DatabarExtXform = require('./databar-ext-xform');
  11228. var IconSetExtXform = require('./icon-set-ext-xform');
  11229. var extIcons = {
  11230. '3Triangles': true,
  11231. '3Stars': true,
  11232. '5Boxes': true
  11233. };
  11234. var CfRuleExtXform = /*#__PURE__*/function (_CompositeXform) {
  11235. _inherits(CfRuleExtXform, _CompositeXform);
  11236. var _super = _createSuper(CfRuleExtXform);
  11237. function CfRuleExtXform() {
  11238. var _this;
  11239. _classCallCheck(this, CfRuleExtXform);
  11240. _this = _super.call(this);
  11241. _this.map = {
  11242. 'x14:dataBar': _this.databarXform = new DatabarExtXform(),
  11243. 'x14:iconSet': _this.iconSetXform = new IconSetExtXform()
  11244. };
  11245. return _this;
  11246. }
  11247. _createClass(CfRuleExtXform, [{
  11248. key: "prepare",
  11249. value: function prepare(model) {
  11250. if (CfRuleExtXform.isExt(model)) {
  11251. model.x14Id = "{".concat(uuidv4(), "}").toUpperCase();
  11252. }
  11253. }
  11254. }, {
  11255. key: "render",
  11256. value: function render(xmlStream, model) {
  11257. if (!CfRuleExtXform.isExt(model)) {
  11258. return;
  11259. }
  11260. switch (model.type) {
  11261. case 'dataBar':
  11262. this.renderDataBar(xmlStream, model);
  11263. break;
  11264. case 'iconSet':
  11265. this.renderIconSet(xmlStream, model);
  11266. break;
  11267. }
  11268. }
  11269. }, {
  11270. key: "renderDataBar",
  11271. value: function renderDataBar(xmlStream, model) {
  11272. xmlStream.openNode(this.tag, {
  11273. type: 'dataBar',
  11274. id: model.x14Id
  11275. });
  11276. this.databarXform.render(xmlStream, model);
  11277. xmlStream.closeNode();
  11278. }
  11279. }, {
  11280. key: "renderIconSet",
  11281. value: function renderIconSet(xmlStream, model) {
  11282. xmlStream.openNode(this.tag, {
  11283. type: 'iconSet',
  11284. priority: model.priority,
  11285. id: model.x14Id || "{".concat(uuidv4(), "}")
  11286. });
  11287. this.iconSetXform.render(xmlStream, model);
  11288. xmlStream.closeNode();
  11289. }
  11290. }, {
  11291. key: "createNewModel",
  11292. value: function createNewModel(_ref) {
  11293. var attributes = _ref.attributes;
  11294. return {
  11295. type: attributes.type,
  11296. x14Id: attributes.id,
  11297. priority: BaseXform.toIntValue(attributes.priority)
  11298. };
  11299. }
  11300. }, {
  11301. key: "onParserClose",
  11302. value: function onParserClose(name, parser) {
  11303. Object.assign(this.model, parser.model);
  11304. }
  11305. }, {
  11306. key: "tag",
  11307. get: function get() {
  11308. return 'x14:cfRule';
  11309. }
  11310. }], [{
  11311. key: "isExt",
  11312. value: function isExt(rule) {
  11313. // is this rule primitive?
  11314. if (rule.type === 'dataBar') {
  11315. return DatabarExtXform.isExt(rule);
  11316. }
  11317. if (rule.type === 'iconSet') {
  11318. if (rule.custom || extIcons[rule.iconSet]) {
  11319. return true;
  11320. }
  11321. }
  11322. return false;
  11323. }
  11324. }]);
  11325. return CfRuleExtXform;
  11326. }(CompositeXform);
  11327. module.exports = CfRuleExtXform;
  11328. }, { "../../base-xform": 31, "../../composite-xform": 47, "./databar-ext-xform": 78, "./icon-set-ext-xform": 80, "uuid": 526 }], 75: [function (require, module, exports) {
  11329. "use strict";
  11330. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11331. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11332. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11333. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11334. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11335. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11336. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11337. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11338. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11339. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11340. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11341. var CompositeXform = require('../../composite-xform');
  11342. var FExtXform = require('./f-ext-xform');
  11343. var CfvoExtXform = /*#__PURE__*/function (_CompositeXform) {
  11344. _inherits(CfvoExtXform, _CompositeXform);
  11345. var _super = _createSuper(CfvoExtXform);
  11346. function CfvoExtXform() {
  11347. var _this;
  11348. _classCallCheck(this, CfvoExtXform);
  11349. _this = _super.call(this);
  11350. _this.map = {
  11351. 'xm:f': _this.fExtXform = new FExtXform()
  11352. };
  11353. return _this;
  11354. }
  11355. _createClass(CfvoExtXform, [{
  11356. key: "render",
  11357. value: function render(xmlStream, model) {
  11358. xmlStream.openNode(this.tag, {
  11359. type: model.type
  11360. });
  11361. if (model.value !== undefined) {
  11362. this.fExtXform.render(xmlStream, model.value);
  11363. }
  11364. xmlStream.closeNode();
  11365. }
  11366. }, {
  11367. key: "createNewModel",
  11368. value: function createNewModel(node) {
  11369. return {
  11370. type: node.attributes.type
  11371. };
  11372. }
  11373. }, {
  11374. key: "onParserClose",
  11375. value: function onParserClose(name, parser) {
  11376. switch (name) {
  11377. case 'xm:f':
  11378. this.model.value = parser.model ? parseFloat(parser.model) : 0;
  11379. break;
  11380. }
  11381. }
  11382. }, {
  11383. key: "tag",
  11384. get: function get() {
  11385. return 'x14:cfvo';
  11386. }
  11387. }]);
  11388. return CfvoExtXform;
  11389. }(CompositeXform);
  11390. module.exports = CfvoExtXform;
  11391. }, { "../../composite-xform": 47, "./f-ext-xform": 79 }], 76: [function (require, module, exports) {
  11392. "use strict";
  11393. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11394. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11395. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11396. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11397. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11398. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11399. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11400. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11401. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11402. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11403. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11404. var CompositeXform = require('../../composite-xform');
  11405. var SqRefExtXform = require('./sqref-ext-xform');
  11406. var CfRuleExtXform = require('./cf-rule-ext-xform');
  11407. var ConditionalFormattingExtXform = /*#__PURE__*/function (_CompositeXform) {
  11408. _inherits(ConditionalFormattingExtXform, _CompositeXform);
  11409. var _super = _createSuper(ConditionalFormattingExtXform);
  11410. function ConditionalFormattingExtXform() {
  11411. var _this;
  11412. _classCallCheck(this, ConditionalFormattingExtXform);
  11413. _this = _super.call(this);
  11414. _this.map = {
  11415. 'xm:sqref': _this.sqRef = new SqRefExtXform(),
  11416. 'x14:cfRule': _this.cfRule = new CfRuleExtXform()
  11417. };
  11418. return _this;
  11419. }
  11420. _createClass(ConditionalFormattingExtXform, [{
  11421. key: "prepare",
  11422. value: function prepare(model, options) {
  11423. var _this2 = this;
  11424. model.rules.forEach(function (rule) {
  11425. _this2.cfRule.prepare(rule, options);
  11426. });
  11427. }
  11428. }, {
  11429. key: "render",
  11430. value: function render(xmlStream, model) {
  11431. var _this3 = this;
  11432. if (!model.rules.some(CfRuleExtXform.isExt)) {
  11433. return;
  11434. }
  11435. xmlStream.openNode(this.tag, {
  11436. 'xmlns:xm': 'http://schemas.microsoft.com/office/excel/2006/main'
  11437. });
  11438. model.rules.filter(CfRuleExtXform.isExt).forEach(function (rule) {
  11439. return _this3.cfRule.render(xmlStream, rule);
  11440. }); // for some odd reason, Excel needs the <xm:sqref> node to be after the rules
  11441. this.sqRef.render(xmlStream, model.ref);
  11442. xmlStream.closeNode();
  11443. }
  11444. }, {
  11445. key: "createNewModel",
  11446. value: function createNewModel() {
  11447. return {
  11448. rules: []
  11449. };
  11450. }
  11451. }, {
  11452. key: "onParserClose",
  11453. value: function onParserClose(name, parser) {
  11454. switch (name) {
  11455. case 'xm:sqref':
  11456. this.model.ref = parser.model;
  11457. break;
  11458. case 'x14:cfRule':
  11459. this.model.rules.push(parser.model);
  11460. break;
  11461. }
  11462. }
  11463. }, {
  11464. key: "tag",
  11465. get: function get() {
  11466. return 'x14:conditionalFormatting';
  11467. }
  11468. }]);
  11469. return ConditionalFormattingExtXform;
  11470. }(CompositeXform);
  11471. module.exports = ConditionalFormattingExtXform;
  11472. }, { "../../composite-xform": 47, "./cf-rule-ext-xform": 74, "./sqref-ext-xform": 81 }], 77: [function (require, module, exports) {
  11473. "use strict";
  11474. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11475. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11476. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11477. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11478. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11479. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11480. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11481. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11482. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11483. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11484. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11485. var CompositeXform = require('../../composite-xform');
  11486. var CfRuleExtXform = require('./cf-rule-ext-xform');
  11487. var ConditionalFormattingExtXform = require('./conditional-formatting-ext-xform');
  11488. var ConditionalFormattingsExtXform = /*#__PURE__*/function (_CompositeXform) {
  11489. _inherits(ConditionalFormattingsExtXform, _CompositeXform);
  11490. var _super = _createSuper(ConditionalFormattingsExtXform);
  11491. function ConditionalFormattingsExtXform() {
  11492. var _this;
  11493. _classCallCheck(this, ConditionalFormattingsExtXform);
  11494. _this = _super.call(this);
  11495. _this.map = {
  11496. 'x14:conditionalFormatting': _this.cfXform = new ConditionalFormattingExtXform()
  11497. };
  11498. return _this;
  11499. }
  11500. _createClass(ConditionalFormattingsExtXform, [{
  11501. key: "hasContent",
  11502. value: function hasContent(model) {
  11503. if (model.hasExtContent === undefined) {
  11504. model.hasExtContent = model.some(function (cf) {
  11505. return cf.rules.some(CfRuleExtXform.isExt);
  11506. });
  11507. }
  11508. return model.hasExtContent;
  11509. }
  11510. }, {
  11511. key: "prepare",
  11512. value: function prepare(model, options) {
  11513. var _this2 = this;
  11514. model.forEach(function (cf) {
  11515. _this2.cfXform.prepare(cf, options);
  11516. });
  11517. }
  11518. }, {
  11519. key: "render",
  11520. value: function render(xmlStream, model) {
  11521. var _this3 = this;
  11522. if (this.hasContent(model)) {
  11523. xmlStream.openNode(this.tag);
  11524. model.forEach(function (cf) {
  11525. return _this3.cfXform.render(xmlStream, cf);
  11526. });
  11527. xmlStream.closeNode();
  11528. }
  11529. }
  11530. }, {
  11531. key: "createNewModel",
  11532. value: function createNewModel() {
  11533. return [];
  11534. }
  11535. }, {
  11536. key: "onParserClose",
  11537. value: function onParserClose(name, parser) {
  11538. // model is array of conditional formatting objects
  11539. this.model.push(parser.model);
  11540. }
  11541. }, {
  11542. key: "tag",
  11543. get: function get() {
  11544. return 'x14:conditionalFormattings';
  11545. }
  11546. }]);
  11547. return ConditionalFormattingsExtXform;
  11548. }(CompositeXform);
  11549. module.exports = ConditionalFormattingsExtXform;
  11550. }, { "../../composite-xform": 47, "./cf-rule-ext-xform": 74, "./conditional-formatting-ext-xform": 76 }], 78: [function (require, module, exports) {
  11551. "use strict";
  11552. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11553. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  11554. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  11555. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  11556. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  11557. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  11558. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  11559. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11560. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11561. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11562. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11563. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11564. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11565. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11566. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11567. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11568. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11569. var BaseXform = require('../../base-xform');
  11570. var CompositeXform = require('../../composite-xform');
  11571. var ColorXform = require('../../style/color-xform');
  11572. var CfvoExtXform = require('./cfvo-ext-xform');
  11573. var DatabarExtXform = /*#__PURE__*/function (_CompositeXform) {
  11574. _inherits(DatabarExtXform, _CompositeXform);
  11575. var _super = _createSuper(DatabarExtXform);
  11576. function DatabarExtXform() {
  11577. var _this;
  11578. _classCallCheck(this, DatabarExtXform);
  11579. _this = _super.call(this);
  11580. _this.map = {
  11581. 'x14:cfvo': _this.cfvoXform = new CfvoExtXform(),
  11582. 'x14:borderColor': _this.borderColorXform = new ColorXform('x14:borderColor'),
  11583. 'x14:negativeBorderColor': _this.negativeBorderColorXform = new ColorXform('x14:negativeBorderColor'),
  11584. 'x14:negativeFillColor': _this.negativeFillColorXform = new ColorXform('x14:negativeFillColor'),
  11585. 'x14:axisColor': _this.axisColorXform = new ColorXform('x14:axisColor')
  11586. };
  11587. return _this;
  11588. }
  11589. _createClass(DatabarExtXform, [{
  11590. key: "render",
  11591. value: function render(xmlStream, model) {
  11592. var _this2 = this;
  11593. xmlStream.openNode(this.tag, {
  11594. minLength: BaseXform.toIntAttribute(model.minLength, 0, true),
  11595. maxLength: BaseXform.toIntAttribute(model.maxLength, 100, true),
  11596. border: BaseXform.toBoolAttribute(model.border, false),
  11597. gradient: BaseXform.toBoolAttribute(model.gradient, true),
  11598. negativeBarColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarColorSameAsPositive, true),
  11599. negativeBarBorderColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarBorderColorSameAsPositive, true),
  11600. axisPosition: BaseXform.toAttribute(model.axisPosition, 'auto'),
  11601. direction: BaseXform.toAttribute(model.direction, 'leftToRight')
  11602. });
  11603. model.cfvo.forEach(function (cfvo) {
  11604. _this2.cfvoXform.render(xmlStream, cfvo);
  11605. });
  11606. this.borderColorXform.render(xmlStream, model.borderColor);
  11607. this.negativeBorderColorXform.render(xmlStream, model.negativeBorderColor);
  11608. this.negativeFillColorXform.render(xmlStream, model.negativeFillColor);
  11609. this.axisColorXform.render(xmlStream, model.axisColor);
  11610. xmlStream.closeNode();
  11611. }
  11612. }, {
  11613. key: "createNewModel",
  11614. value: function createNewModel(_ref) {
  11615. var attributes = _ref.attributes;
  11616. return {
  11617. cfvo: [],
  11618. minLength: BaseXform.toIntValue(attributes.minLength, 0),
  11619. maxLength: BaseXform.toIntValue(attributes.maxLength, 100),
  11620. border: BaseXform.toBoolValue(attributes.border, false),
  11621. gradient: BaseXform.toBoolValue(attributes.gradient, true),
  11622. negativeBarColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarColorSameAsPositive, true),
  11623. negativeBarBorderColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarBorderColorSameAsPositive, true),
  11624. axisPosition: BaseXform.toStringValue(attributes.axisPosition, 'auto'),
  11625. direction: BaseXform.toStringValue(attributes.direction, 'leftToRight')
  11626. };
  11627. }
  11628. }, {
  11629. key: "onParserClose",
  11630. value: function onParserClose(name, parser) {
  11631. var _name$split = name.split(':'),
  11632. _name$split2 = _slicedToArray(_name$split, 2),
  11633. prop = _name$split2[1];
  11634. switch (prop) {
  11635. case 'cfvo':
  11636. this.model.cfvo.push(parser.model);
  11637. break;
  11638. default:
  11639. this.model[prop] = parser.model;
  11640. break;
  11641. }
  11642. }
  11643. }, {
  11644. key: "tag",
  11645. get: function get() {
  11646. return 'x14:dataBar';
  11647. }
  11648. }], [{
  11649. key: "isExt",
  11650. value: function isExt(rule) {
  11651. // not all databars need ext
  11652. // TODO: refine this
  11653. return !rule.gradient;
  11654. }
  11655. }]);
  11656. return DatabarExtXform;
  11657. }(CompositeXform);
  11658. module.exports = DatabarExtXform;
  11659. }, { "../../base-xform": 31, "../../composite-xform": 47, "../../style/color-xform": 127, "./cfvo-ext-xform": 75 }], 79: [function (require, module, exports) {
  11660. "use strict";
  11661. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11662. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11663. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11664. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11665. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11666. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11667. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11668. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11669. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11670. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11671. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11672. var BaseXform = require('../../base-xform');
  11673. var FExtXform = /*#__PURE__*/function (_BaseXform) {
  11674. _inherits(FExtXform, _BaseXform);
  11675. var _super = _createSuper(FExtXform);
  11676. function FExtXform() {
  11677. _classCallCheck(this, FExtXform);
  11678. return _super.apply(this, arguments);
  11679. }
  11680. _createClass(FExtXform, [{
  11681. key: "render",
  11682. value: function render(xmlStream, model) {
  11683. xmlStream.leafNode(this.tag, null, model);
  11684. }
  11685. }, {
  11686. key: "parseOpen",
  11687. value: function parseOpen() {
  11688. this.model = '';
  11689. }
  11690. }, {
  11691. key: "parseText",
  11692. value: function parseText(text) {
  11693. this.model += text;
  11694. }
  11695. }, {
  11696. key: "parseClose",
  11697. value: function parseClose(name) {
  11698. return name !== this.tag;
  11699. }
  11700. }, {
  11701. key: "tag",
  11702. get: function get() {
  11703. return 'xm:f';
  11704. }
  11705. }]);
  11706. return FExtXform;
  11707. }(BaseXform);
  11708. module.exports = FExtXform;
  11709. }, { "../../base-xform": 31 }], 80: [function (require, module, exports) {
  11710. "use strict";
  11711. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11712. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  11713. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  11714. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  11715. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  11716. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  11717. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  11718. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11719. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11720. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11721. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11722. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11723. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11724. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11725. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11726. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11727. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11728. var BaseXform = require('../../base-xform');
  11729. var CompositeXform = require('../../composite-xform');
  11730. var CfvoExtXform = require('./cfvo-ext-xform');
  11731. var CfIconExtXform = require('./cf-icon-ext-xform');
  11732. var IconSetExtXform = /*#__PURE__*/function (_CompositeXform) {
  11733. _inherits(IconSetExtXform, _CompositeXform);
  11734. var _super = _createSuper(IconSetExtXform);
  11735. function IconSetExtXform() {
  11736. var _this;
  11737. _classCallCheck(this, IconSetExtXform);
  11738. _this = _super.call(this);
  11739. _this.map = {
  11740. 'x14:cfvo': _this.cfvoXform = new CfvoExtXform(),
  11741. 'x14:cfIcon': _this.cfIconXform = new CfIconExtXform()
  11742. };
  11743. return _this;
  11744. }
  11745. _createClass(IconSetExtXform, [{
  11746. key: "render",
  11747. value: function render(xmlStream, model) {
  11748. var _this2 = this;
  11749. xmlStream.openNode(this.tag, {
  11750. iconSet: BaseXform.toStringAttribute(model.iconSet),
  11751. reverse: BaseXform.toBoolAttribute(model.reverse, false),
  11752. showValue: BaseXform.toBoolAttribute(model.showValue, true),
  11753. custom: BaseXform.toBoolAttribute(model.icons, false)
  11754. });
  11755. model.cfvo.forEach(function (cfvo) {
  11756. _this2.cfvoXform.render(xmlStream, cfvo);
  11757. });
  11758. if (model.icons) {
  11759. model.icons.forEach(function (icon, i) {
  11760. icon.iconId = i;
  11761. _this2.cfIconXform.render(xmlStream, icon);
  11762. });
  11763. }
  11764. xmlStream.closeNode();
  11765. }
  11766. }, {
  11767. key: "createNewModel",
  11768. value: function createNewModel(_ref) {
  11769. var attributes = _ref.attributes;
  11770. return {
  11771. cfvo: [],
  11772. iconSet: BaseXform.toStringValue(attributes.iconSet, '3TrafficLights'),
  11773. reverse: BaseXform.toBoolValue(attributes.reverse, false),
  11774. showValue: BaseXform.toBoolValue(attributes.showValue, true)
  11775. };
  11776. }
  11777. }, {
  11778. key: "onParserClose",
  11779. value: function onParserClose(name, parser) {
  11780. var _name$split = name.split(':'),
  11781. _name$split2 = _slicedToArray(_name$split, 2),
  11782. prop = _name$split2[1];
  11783. switch (prop) {
  11784. case 'cfvo':
  11785. this.model.cfvo.push(parser.model);
  11786. break;
  11787. case 'cfIcon':
  11788. if (!this.model.icons) {
  11789. this.model.icons = [];
  11790. }
  11791. this.model.icons.push(parser.model);
  11792. break;
  11793. default:
  11794. this.model[prop] = parser.model;
  11795. break;
  11796. }
  11797. }
  11798. }, {
  11799. key: "tag",
  11800. get: function get() {
  11801. return 'x14:iconSet';
  11802. }
  11803. }]);
  11804. return IconSetExtXform;
  11805. }(CompositeXform);
  11806. module.exports = IconSetExtXform;
  11807. }, { "../../base-xform": 31, "../../composite-xform": 47, "./cf-icon-ext-xform": 73, "./cfvo-ext-xform": 75 }], 81: [function (require, module, exports) {
  11808. "use strict";
  11809. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11810. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11811. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11812. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11813. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11814. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11815. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11816. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11817. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11818. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11819. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11820. var BaseXform = require('../../base-xform');
  11821. var SqrefExtXform = /*#__PURE__*/function (_BaseXform) {
  11822. _inherits(SqrefExtXform, _BaseXform);
  11823. var _super = _createSuper(SqrefExtXform);
  11824. function SqrefExtXform() {
  11825. _classCallCheck(this, SqrefExtXform);
  11826. return _super.apply(this, arguments);
  11827. }
  11828. _createClass(SqrefExtXform, [{
  11829. key: "render",
  11830. value: function render(xmlStream, model) {
  11831. xmlStream.leafNode(this.tag, null, model);
  11832. }
  11833. }, {
  11834. key: "parseOpen",
  11835. value: function parseOpen() {
  11836. this.model = '';
  11837. }
  11838. }, {
  11839. key: "parseText",
  11840. value: function parseText(text) {
  11841. this.model += text;
  11842. }
  11843. }, {
  11844. key: "parseClose",
  11845. value: function parseClose(name) {
  11846. return name !== this.tag;
  11847. }
  11848. }, {
  11849. key: "tag",
  11850. get: function get() {
  11851. return 'xm:sqref';
  11852. }
  11853. }]);
  11854. return SqrefExtXform;
  11855. }(BaseXform);
  11856. module.exports = SqrefExtXform;
  11857. }, { "../../base-xform": 31 }], 82: [function (require, module, exports) {
  11858. "use strict";
  11859. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11860. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  11861. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  11862. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  11863. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11864. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11865. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11866. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11867. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11868. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11869. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11870. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11871. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  11872. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11873. var BaseXform = require('../../base-xform');
  11874. var CompositeXform = require('../../composite-xform');
  11875. var Range = require('../../../../doc/range');
  11876. var DatabarXform = require('./databar-xform');
  11877. var ExtLstRefXform = require('./ext-lst-ref-xform');
  11878. var FormulaXform = require('./formula-xform');
  11879. var ColorScaleXform = require('./color-scale-xform');
  11880. var IconSetXform = require('./icon-set-xform');
  11881. var extIcons = {
  11882. '3Triangles': true,
  11883. '3Stars': true,
  11884. '5Boxes': true
  11885. };
  11886. var getTextFormula = function getTextFormula(model) {
  11887. if (model.formulae && model.formulae[0]) {
  11888. return model.formulae[0];
  11889. }
  11890. var range = new Range(model.ref);
  11891. var tl = range.tl;
  11892. switch (model.operator) {
  11893. case 'containsText':
  11894. return "NOT(ISERROR(SEARCH(\"".concat(model.text, "\",").concat(tl, ")))");
  11895. case 'containsBlanks':
  11896. return "LEN(TRIM(".concat(tl, "))=0");
  11897. case 'notContainsBlanks':
  11898. return "LEN(TRIM(".concat(tl, "))>0");
  11899. case 'containsErrors':
  11900. return "ISERROR(".concat(tl, ")");
  11901. case 'notContainsErrors':
  11902. return "NOT(ISERROR(".concat(tl, "))");
  11903. default:
  11904. return undefined;
  11905. }
  11906. };
  11907. var getTimePeriodFormula = function getTimePeriodFormula(model) {
  11908. if (model.formulae && model.formulae[0]) {
  11909. return model.formulae[0];
  11910. }
  11911. var range = new Range(model.ref);
  11912. var tl = range.tl;
  11913. switch (model.timePeriod) {
  11914. case 'thisWeek':
  11915. return "AND(TODAY()-ROUNDDOWN(".concat(tl, ",0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(").concat(tl, ",0)-TODAY()<=7-WEEKDAY(TODAY()))");
  11916. case 'lastWeek':
  11917. return "AND(TODAY()-ROUNDDOWN(".concat(tl, ",0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(").concat(tl, ",0)<(WEEKDAY(TODAY())+7))");
  11918. case 'nextWeek':
  11919. return "AND(ROUNDDOWN(".concat(tl, ",0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(").concat(tl, ",0)-TODAY()<(15-WEEKDAY(TODAY())))");
  11920. case 'yesterday':
  11921. return "FLOOR(".concat(tl, ",1)=TODAY()-1");
  11922. case 'today':
  11923. return "FLOOR(".concat(tl, ",1)=TODAY()");
  11924. case 'tomorrow':
  11925. return "FLOOR(".concat(tl, ",1)=TODAY()+1");
  11926. case 'last7Days':
  11927. return "AND(TODAY()-FLOOR(".concat(tl, ",1)<=6,FLOOR(").concat(tl, ",1)<=TODAY())");
  11928. case 'lastMonth':
  11929. return "AND(MONTH(".concat(tl, ")=MONTH(EDATE(TODAY(),0-1)),YEAR(").concat(tl, ")=YEAR(EDATE(TODAY(),0-1)))");
  11930. case 'thisMonth':
  11931. return "AND(MONTH(".concat(tl, ")=MONTH(TODAY()),YEAR(").concat(tl, ")=YEAR(TODAY()))");
  11932. case 'nextMonth':
  11933. return "AND(MONTH(".concat(tl, ")=MONTH(EDATE(TODAY(),0+1)),YEAR(").concat(tl, ")=YEAR(EDATE(TODAY(),0+1)))");
  11934. default:
  11935. return undefined;
  11936. }
  11937. };
  11938. var opType = function opType(attributes) {
  11939. var type = attributes.type,
  11940. operator = attributes.operator;
  11941. switch (type) {
  11942. case 'containsText':
  11943. case 'containsBlanks':
  11944. case 'notContainsBlanks':
  11945. case 'containsErrors':
  11946. case 'notContainsErrors':
  11947. return {
  11948. type: 'containsText',
  11949. operator: type
  11950. };
  11951. default:
  11952. return {
  11953. type: type,
  11954. operator: operator
  11955. };
  11956. }
  11957. };
  11958. var CfRuleXform = /*#__PURE__*/function (_CompositeXform) {
  11959. _inherits(CfRuleXform, _CompositeXform);
  11960. var _super = _createSuper(CfRuleXform);
  11961. function CfRuleXform() {
  11962. var _this;
  11963. _classCallCheck(this, CfRuleXform);
  11964. _this = _super.call(this);
  11965. _this.map = {
  11966. dataBar: _this.databarXform = new DatabarXform(),
  11967. extLst: _this.extLstRefXform = new ExtLstRefXform(),
  11968. formula: _this.formulaXform = new FormulaXform(),
  11969. colorScale: _this.colorScaleXform = new ColorScaleXform(),
  11970. iconSet: _this.iconSetXform = new IconSetXform()
  11971. };
  11972. return _this;
  11973. }
  11974. _createClass(CfRuleXform, [{
  11975. key: "render",
  11976. value: function render(xmlStream, model) {
  11977. switch (model.type) {
  11978. case 'expression':
  11979. this.renderExpression(xmlStream, model);
  11980. break;
  11981. case 'cellIs':
  11982. this.renderCellIs(xmlStream, model);
  11983. break;
  11984. case 'top10':
  11985. this.renderTop10(xmlStream, model);
  11986. break;
  11987. case 'aboveAverage':
  11988. this.renderAboveAverage(xmlStream, model);
  11989. break;
  11990. case 'dataBar':
  11991. this.renderDataBar(xmlStream, model);
  11992. break;
  11993. case 'colorScale':
  11994. this.renderColorScale(xmlStream, model);
  11995. break;
  11996. case 'iconSet':
  11997. this.renderIconSet(xmlStream, model);
  11998. break;
  11999. case 'containsText':
  12000. this.renderText(xmlStream, model);
  12001. break;
  12002. case 'timePeriod':
  12003. this.renderTimePeriod(xmlStream, model);
  12004. break;
  12005. }
  12006. }
  12007. }, {
  12008. key: "renderExpression",
  12009. value: function renderExpression(xmlStream, model) {
  12010. xmlStream.openNode(this.tag, {
  12011. type: 'expression',
  12012. dxfId: model.dxfId,
  12013. priority: model.priority
  12014. });
  12015. this.formulaXform.render(xmlStream, model.formulae[0]);
  12016. xmlStream.closeNode();
  12017. }
  12018. }, {
  12019. key: "renderCellIs",
  12020. value: function renderCellIs(xmlStream, model) {
  12021. var _this2 = this;
  12022. xmlStream.openNode(this.tag, {
  12023. type: 'cellIs',
  12024. dxfId: model.dxfId,
  12025. priority: model.priority,
  12026. operator: model.operator
  12027. });
  12028. model.formulae.forEach(function (formula) {
  12029. _this2.formulaXform.render(xmlStream, formula);
  12030. });
  12031. xmlStream.closeNode();
  12032. }
  12033. }, {
  12034. key: "renderTop10",
  12035. value: function renderTop10(xmlStream, model) {
  12036. xmlStream.leafNode(this.tag, {
  12037. type: 'top10',
  12038. dxfId: model.dxfId,
  12039. priority: model.priority,
  12040. percent: BaseXform.toBoolAttribute(model.percent, false),
  12041. bottom: BaseXform.toBoolAttribute(model.bottom, false),
  12042. rank: BaseXform.toIntValue(model.rank, 10, true)
  12043. });
  12044. }
  12045. }, {
  12046. key: "renderAboveAverage",
  12047. value: function renderAboveAverage(xmlStream, model) {
  12048. xmlStream.leafNode(this.tag, {
  12049. type: 'aboveAverage',
  12050. dxfId: model.dxfId,
  12051. priority: model.priority,
  12052. aboveAverage: BaseXform.toBoolAttribute(model.aboveAverage, true)
  12053. });
  12054. }
  12055. }, {
  12056. key: "renderDataBar",
  12057. value: function renderDataBar(xmlStream, model) {
  12058. xmlStream.openNode(this.tag, {
  12059. type: 'dataBar',
  12060. priority: model.priority
  12061. });
  12062. this.databarXform.render(xmlStream, model);
  12063. this.extLstRefXform.render(xmlStream, model);
  12064. xmlStream.closeNode();
  12065. }
  12066. }, {
  12067. key: "renderColorScale",
  12068. value: function renderColorScale(xmlStream, model) {
  12069. xmlStream.openNode(this.tag, {
  12070. type: 'colorScale',
  12071. priority: model.priority
  12072. });
  12073. this.colorScaleXform.render(xmlStream, model);
  12074. xmlStream.closeNode();
  12075. }
  12076. }, {
  12077. key: "renderIconSet",
  12078. value: function renderIconSet(xmlStream, model) {
  12079. // iconset is all primitive or all extLst
  12080. if (!CfRuleXform.isPrimitive(model)) {
  12081. return;
  12082. }
  12083. xmlStream.openNode(this.tag, {
  12084. type: 'iconSet',
  12085. priority: model.priority
  12086. });
  12087. this.iconSetXform.render(xmlStream, model);
  12088. xmlStream.closeNode();
  12089. }
  12090. }, {
  12091. key: "renderText",
  12092. value: function renderText(xmlStream, model) {
  12093. xmlStream.openNode(this.tag, {
  12094. type: model.operator,
  12095. dxfId: model.dxfId,
  12096. priority: model.priority,
  12097. operator: BaseXform.toStringAttribute(model.operator, 'containsText')
  12098. });
  12099. var formula = getTextFormula(model);
  12100. if (formula) {
  12101. this.formulaXform.render(xmlStream, formula);
  12102. }
  12103. xmlStream.closeNode();
  12104. }
  12105. }, {
  12106. key: "renderTimePeriod",
  12107. value: function renderTimePeriod(xmlStream, model) {
  12108. xmlStream.openNode(this.tag, {
  12109. type: 'timePeriod',
  12110. dxfId: model.dxfId,
  12111. priority: model.priority,
  12112. timePeriod: model.timePeriod
  12113. });
  12114. var formula = getTimePeriodFormula(model);
  12115. if (formula) {
  12116. this.formulaXform.render(xmlStream, formula);
  12117. }
  12118. xmlStream.closeNode();
  12119. }
  12120. }, {
  12121. key: "createNewModel",
  12122. value: function createNewModel(_ref) {
  12123. var attributes = _ref.attributes;
  12124. return _objectSpread(_objectSpread({}, opType(attributes)), {}, {
  12125. dxfId: BaseXform.toIntValue(attributes.dxfId),
  12126. priority: BaseXform.toIntValue(attributes.priority),
  12127. timePeriod: attributes.timePeriod,
  12128. percent: BaseXform.toBoolValue(attributes.percent),
  12129. bottom: BaseXform.toBoolValue(attributes.bottom),
  12130. rank: BaseXform.toIntValue(attributes.rank),
  12131. aboveAverage: BaseXform.toBoolValue(attributes.aboveAverage)
  12132. });
  12133. }
  12134. }, {
  12135. key: "onParserClose",
  12136. value: function onParserClose(name, parser) {
  12137. switch (name) {
  12138. case 'dataBar':
  12139. case 'extLst':
  12140. case 'colorScale':
  12141. case 'iconSet':
  12142. // merge parser model with ours
  12143. Object.assign(this.model, parser.model);
  12144. break;
  12145. case 'formula':
  12146. // except - formula is a string and appends to formulae
  12147. this.model.formulae = this.model.formulae || [];
  12148. this.model.formulae.push(parser.model);
  12149. break;
  12150. }
  12151. }
  12152. }, {
  12153. key: "tag",
  12154. get: function get() {
  12155. return 'cfRule';
  12156. }
  12157. }], [{
  12158. key: "isPrimitive",
  12159. value: function isPrimitive(rule) {
  12160. // is this rule primitive?
  12161. if (rule.type === 'iconSet') {
  12162. if (rule.custom || extIcons[rule.iconSet]) {
  12163. return false;
  12164. }
  12165. }
  12166. return true;
  12167. }
  12168. }]);
  12169. return CfRuleXform;
  12170. }(CompositeXform);
  12171. module.exports = CfRuleXform;
  12172. }, { "../../../../doc/range": 10, "../../base-xform": 31, "../../composite-xform": 47, "./color-scale-xform": 84, "./databar-xform": 87, "./ext-lst-ref-xform": 88, "./formula-xform": 89, "./icon-set-xform": 90 }], 83: [function (require, module, exports) {
  12173. "use strict";
  12174. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12175. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12176. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12177. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12178. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12179. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12180. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12181. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12182. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12183. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12184. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12185. var BaseXform = require('../../base-xform');
  12186. var CfvoXform = /*#__PURE__*/function (_BaseXform) {
  12187. _inherits(CfvoXform, _BaseXform);
  12188. var _super = _createSuper(CfvoXform);
  12189. function CfvoXform() {
  12190. _classCallCheck(this, CfvoXform);
  12191. return _super.apply(this, arguments);
  12192. }
  12193. _createClass(CfvoXform, [{
  12194. key: "render",
  12195. value: function render(xmlStream, model) {
  12196. xmlStream.leafNode(this.tag, {
  12197. type: model.type,
  12198. val: model.value
  12199. });
  12200. }
  12201. }, {
  12202. key: "parseOpen",
  12203. value: function parseOpen(node) {
  12204. this.model = {
  12205. type: node.attributes.type,
  12206. value: BaseXform.toFloatValue(node.attributes.val)
  12207. };
  12208. }
  12209. }, {
  12210. key: "parseClose",
  12211. value: function parseClose(name) {
  12212. return name !== this.tag;
  12213. }
  12214. }, {
  12215. key: "tag",
  12216. get: function get() {
  12217. return 'cfvo';
  12218. }
  12219. }]);
  12220. return CfvoXform;
  12221. }(BaseXform);
  12222. module.exports = CfvoXform;
  12223. }, { "../../base-xform": 31 }], 84: [function (require, module, exports) {
  12224. "use strict";
  12225. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12226. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12227. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12228. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12229. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12230. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12231. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12232. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12233. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12234. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12235. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12236. var CompositeXform = require('../../composite-xform');
  12237. var ColorXform = require('../../style/color-xform');
  12238. var CfvoXform = require('./cfvo-xform');
  12239. var ColorScaleXform = /*#__PURE__*/function (_CompositeXform) {
  12240. _inherits(ColorScaleXform, _CompositeXform);
  12241. var _super = _createSuper(ColorScaleXform);
  12242. function ColorScaleXform() {
  12243. var _this;
  12244. _classCallCheck(this, ColorScaleXform);
  12245. _this = _super.call(this);
  12246. _this.map = {
  12247. cfvo: _this.cfvoXform = new CfvoXform(),
  12248. color: _this.colorXform = new ColorXform()
  12249. };
  12250. return _this;
  12251. }
  12252. _createClass(ColorScaleXform, [{
  12253. key: "render",
  12254. value: function render(xmlStream, model) {
  12255. var _this2 = this;
  12256. xmlStream.openNode(this.tag);
  12257. model.cfvo.forEach(function (cfvo) {
  12258. _this2.cfvoXform.render(xmlStream, cfvo);
  12259. });
  12260. model.color.forEach(function (color) {
  12261. _this2.colorXform.render(xmlStream, color);
  12262. });
  12263. xmlStream.closeNode();
  12264. }
  12265. }, {
  12266. key: "createNewModel",
  12267. value: function createNewModel(node) {
  12268. return {
  12269. cfvo: [],
  12270. color: []
  12271. };
  12272. }
  12273. }, {
  12274. key: "onParserClose",
  12275. value: function onParserClose(name, parser) {
  12276. this.model[name].push(parser.model);
  12277. }
  12278. }, {
  12279. key: "tag",
  12280. get: function get() {
  12281. return 'colorScale';
  12282. }
  12283. }]);
  12284. return ColorScaleXform;
  12285. }(CompositeXform);
  12286. module.exports = ColorScaleXform;
  12287. }, { "../../composite-xform": 47, "../../style/color-xform": 127, "./cfvo-xform": 83 }], 85: [function (require, module, exports) {
  12288. "use strict";
  12289. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12290. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12291. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12292. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12293. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12294. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12295. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12296. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12297. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12298. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12299. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12300. var CompositeXform = require('../../composite-xform');
  12301. var CfRuleXform = require('./cf-rule-xform');
  12302. var ConditionalFormattingXform = /*#__PURE__*/function (_CompositeXform) {
  12303. _inherits(ConditionalFormattingXform, _CompositeXform);
  12304. var _super = _createSuper(ConditionalFormattingXform);
  12305. function ConditionalFormattingXform() {
  12306. var _this;
  12307. _classCallCheck(this, ConditionalFormattingXform);
  12308. _this = _super.call(this);
  12309. _this.map = {
  12310. cfRule: new CfRuleXform()
  12311. };
  12312. return _this;
  12313. }
  12314. _createClass(ConditionalFormattingXform, [{
  12315. key: "render",
  12316. value: function render(xmlStream, model) {
  12317. var _this2 = this;
  12318. // if there are no primitive rules, exit now
  12319. if (!model.rules.some(CfRuleXform.isPrimitive)) {
  12320. return;
  12321. }
  12322. xmlStream.openNode(this.tag, {
  12323. sqref: model.ref
  12324. });
  12325. model.rules.forEach(function (rule) {
  12326. if (CfRuleXform.isPrimitive(rule)) {
  12327. rule.ref = model.ref;
  12328. _this2.map.cfRule.render(xmlStream, rule);
  12329. }
  12330. });
  12331. xmlStream.closeNode();
  12332. }
  12333. }, {
  12334. key: "createNewModel",
  12335. value: function createNewModel(_ref) {
  12336. var attributes = _ref.attributes;
  12337. return {
  12338. ref: attributes.sqref,
  12339. rules: []
  12340. };
  12341. }
  12342. }, {
  12343. key: "onParserClose",
  12344. value: function onParserClose(name, parser) {
  12345. this.model.rules.push(parser.model);
  12346. }
  12347. }, {
  12348. key: "tag",
  12349. get: function get() {
  12350. return 'conditionalFormatting';
  12351. }
  12352. }]);
  12353. return ConditionalFormattingXform;
  12354. }(CompositeXform);
  12355. module.exports = ConditionalFormattingXform;
  12356. }, { "../../composite-xform": 47, "./cf-rule-xform": 82 }], 86: [function (require, module, exports) {
  12357. "use strict";
  12358. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12359. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  12360. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  12361. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  12362. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  12363. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  12364. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  12365. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12366. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12367. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12368. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12369. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12370. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12371. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12372. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12373. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12374. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12375. var BaseXform = require('../../base-xform');
  12376. var ConditionalFormattingXform = require('./conditional-formatting-xform');
  12377. var ConditionalFormattingsXform = /*#__PURE__*/function (_BaseXform) {
  12378. _inherits(ConditionalFormattingsXform, _BaseXform);
  12379. var _super = _createSuper(ConditionalFormattingsXform);
  12380. function ConditionalFormattingsXform() {
  12381. var _this;
  12382. _classCallCheck(this, ConditionalFormattingsXform);
  12383. _this = _super.call(this);
  12384. _this.cfXform = new ConditionalFormattingXform();
  12385. return _this;
  12386. }
  12387. _createClass(ConditionalFormattingsXform, [{
  12388. key: "reset",
  12389. value: function reset() {
  12390. this.model = [];
  12391. }
  12392. }, {
  12393. key: "prepare",
  12394. value: function prepare(model, options) {
  12395. // ensure each rule has a priority value
  12396. var nextPriority = model.reduce(function (p, cf) {
  12397. return Math.max.apply(Math, [p].concat(_toConsumableArray(cf.rules.map(function (rule) {
  12398. return rule.priority || 0;
  12399. }))));
  12400. }, 1);
  12401. model.forEach(function (cf) {
  12402. cf.rules.forEach(function (rule) {
  12403. if (!rule.priority) {
  12404. rule.priority = nextPriority++;
  12405. }
  12406. if (rule.style) {
  12407. rule.dxfId = options.styles.addDxfStyle(rule.style);
  12408. }
  12409. });
  12410. });
  12411. }
  12412. }, {
  12413. key: "render",
  12414. value: function render(xmlStream, model) {
  12415. var _this2 = this;
  12416. model.forEach(function (cf) {
  12417. _this2.cfXform.render(xmlStream, cf);
  12418. });
  12419. }
  12420. }, {
  12421. key: "parseOpen",
  12422. value: function parseOpen(node) {
  12423. if (this.parser) {
  12424. this.parser.parseOpen(node);
  12425. return true;
  12426. }
  12427. switch (node.name) {
  12428. case 'conditionalFormatting':
  12429. this.parser = this.cfXform;
  12430. this.parser.parseOpen(node);
  12431. return true;
  12432. default:
  12433. return false;
  12434. }
  12435. }
  12436. }, {
  12437. key: "parseText",
  12438. value: function parseText(text) {
  12439. if (this.parser) {
  12440. this.parser.parseText(text);
  12441. }
  12442. }
  12443. }, {
  12444. key: "parseClose",
  12445. value: function parseClose(name) {
  12446. if (this.parser) {
  12447. if (!this.parser.parseClose(name)) {
  12448. this.model.push(this.parser.model);
  12449. this.parser = undefined;
  12450. return false;
  12451. }
  12452. return true;
  12453. }
  12454. return false;
  12455. }
  12456. }, {
  12457. key: "reconcile",
  12458. value: function reconcile(model, options) {
  12459. model.forEach(function (cf) {
  12460. cf.rules.forEach(function (rule) {
  12461. if (rule.dxfId !== undefined) {
  12462. rule.style = options.styles.getDxfStyle(rule.dxfId);
  12463. delete rule.dxfId;
  12464. }
  12465. });
  12466. });
  12467. }
  12468. }, {
  12469. key: "tag",
  12470. get: function get() {
  12471. return 'conditionalFormatting';
  12472. }
  12473. }]);
  12474. return ConditionalFormattingsXform;
  12475. }(BaseXform);
  12476. module.exports = ConditionalFormattingsXform;
  12477. }, { "../../base-xform": 31, "./conditional-formatting-xform": 85 }], 87: [function (require, module, exports) {
  12478. "use strict";
  12479. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12480. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12481. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12482. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12483. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12484. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12485. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12486. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12487. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12488. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12489. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12490. var CompositeXform = require('../../composite-xform');
  12491. var ColorXform = require('../../style/color-xform');
  12492. var CfvoXform = require('./cfvo-xform');
  12493. var DatabarXform = /*#__PURE__*/function (_CompositeXform) {
  12494. _inherits(DatabarXform, _CompositeXform);
  12495. var _super = _createSuper(DatabarXform);
  12496. function DatabarXform() {
  12497. var _this;
  12498. _classCallCheck(this, DatabarXform);
  12499. _this = _super.call(this);
  12500. _this.map = {
  12501. cfvo: _this.cfvoXform = new CfvoXform(),
  12502. color: _this.colorXform = new ColorXform()
  12503. };
  12504. return _this;
  12505. }
  12506. _createClass(DatabarXform, [{
  12507. key: "render",
  12508. value: function render(xmlStream, model) {
  12509. var _this2 = this;
  12510. xmlStream.openNode(this.tag);
  12511. model.cfvo.forEach(function (cfvo) {
  12512. _this2.cfvoXform.render(xmlStream, cfvo);
  12513. });
  12514. this.colorXform.render(xmlStream, model.color);
  12515. xmlStream.closeNode();
  12516. }
  12517. }, {
  12518. key: "createNewModel",
  12519. value: function createNewModel() {
  12520. return {
  12521. cfvo: []
  12522. };
  12523. }
  12524. }, {
  12525. key: "onParserClose",
  12526. value: function onParserClose(name, parser) {
  12527. switch (name) {
  12528. case 'cfvo':
  12529. this.model.cfvo.push(parser.model);
  12530. break;
  12531. case 'color':
  12532. this.model.color = parser.model;
  12533. break;
  12534. }
  12535. }
  12536. }, {
  12537. key: "tag",
  12538. get: function get() {
  12539. return 'dataBar';
  12540. }
  12541. }]);
  12542. return DatabarXform;
  12543. }(CompositeXform);
  12544. module.exports = DatabarXform;
  12545. }, { "../../composite-xform": 47, "../../style/color-xform": 127, "./cfvo-xform": 83 }], 88: [function (require, module, exports) {
  12546. "use strict";
  12547. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12548. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12549. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12550. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12551. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12552. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12553. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12554. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12555. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12556. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12557. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12558. /* eslint-disable max-classes-per-file */
  12559. var BaseXform = require('../../base-xform');
  12560. var CompositeXform = require('../../composite-xform');
  12561. var X14IdXform = /*#__PURE__*/function (_BaseXform) {
  12562. _inherits(X14IdXform, _BaseXform);
  12563. var _super = _createSuper(X14IdXform);
  12564. function X14IdXform() {
  12565. _classCallCheck(this, X14IdXform);
  12566. return _super.apply(this, arguments);
  12567. }
  12568. _createClass(X14IdXform, [{
  12569. key: "render",
  12570. value: function render(xmlStream, model) {
  12571. xmlStream.leafNode(this.tag, null, model);
  12572. }
  12573. }, {
  12574. key: "parseOpen",
  12575. value: function parseOpen() {
  12576. this.model = '';
  12577. }
  12578. }, {
  12579. key: "parseText",
  12580. value: function parseText(text) {
  12581. this.model += text;
  12582. }
  12583. }, {
  12584. key: "parseClose",
  12585. value: function parseClose(name) {
  12586. return name !== this.tag;
  12587. }
  12588. }, {
  12589. key: "tag",
  12590. get: function get() {
  12591. return 'x14:id';
  12592. }
  12593. }]);
  12594. return X14IdXform;
  12595. }(BaseXform);
  12596. var ExtXform = /*#__PURE__*/function (_CompositeXform) {
  12597. _inherits(ExtXform, _CompositeXform);
  12598. var _super2 = _createSuper(ExtXform);
  12599. function ExtXform() {
  12600. var _this;
  12601. _classCallCheck(this, ExtXform);
  12602. _this = _super2.call(this);
  12603. _this.map = {
  12604. 'x14:id': _this.idXform = new X14IdXform()
  12605. };
  12606. return _this;
  12607. }
  12608. _createClass(ExtXform, [{
  12609. key: "render",
  12610. value: function render(xmlStream, model) {
  12611. xmlStream.openNode(this.tag, {
  12612. uri: '{B025F937-C7B1-47D3-B67F-A62EFF666E3E}',
  12613. 'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main'
  12614. });
  12615. this.idXform.render(xmlStream, model.x14Id);
  12616. xmlStream.closeNode();
  12617. }
  12618. }, {
  12619. key: "createNewModel",
  12620. value: function createNewModel() {
  12621. return {};
  12622. }
  12623. }, {
  12624. key: "onParserClose",
  12625. value: function onParserClose(name, parser) {
  12626. this.model.x14Id = parser.model;
  12627. }
  12628. }, {
  12629. key: "tag",
  12630. get: function get() {
  12631. return 'ext';
  12632. }
  12633. }]);
  12634. return ExtXform;
  12635. }(CompositeXform);
  12636. var ExtLstRefXform = /*#__PURE__*/function (_CompositeXform2) {
  12637. _inherits(ExtLstRefXform, _CompositeXform2);
  12638. var _super3 = _createSuper(ExtLstRefXform);
  12639. function ExtLstRefXform() {
  12640. var _this2;
  12641. _classCallCheck(this, ExtLstRefXform);
  12642. _this2 = _super3.call(this);
  12643. _this2.map = {
  12644. ext: new ExtXform()
  12645. };
  12646. return _this2;
  12647. }
  12648. _createClass(ExtLstRefXform, [{
  12649. key: "render",
  12650. value: function render(xmlStream, model) {
  12651. xmlStream.openNode(this.tag);
  12652. this.map.ext.render(xmlStream, model);
  12653. xmlStream.closeNode();
  12654. }
  12655. }, {
  12656. key: "createNewModel",
  12657. value: function createNewModel() {
  12658. return {};
  12659. }
  12660. }, {
  12661. key: "onParserClose",
  12662. value: function onParserClose(name, parser) {
  12663. Object.assign(this.model, parser.model);
  12664. }
  12665. }, {
  12666. key: "tag",
  12667. get: function get() {
  12668. return 'extLst';
  12669. }
  12670. }]);
  12671. return ExtLstRefXform;
  12672. }(CompositeXform);
  12673. module.exports = ExtLstRefXform;
  12674. }, { "../../base-xform": 31, "../../composite-xform": 47 }], 89: [function (require, module, exports) {
  12675. "use strict";
  12676. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12677. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12678. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12679. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12680. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12681. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12682. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12683. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12684. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12685. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12686. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12687. var BaseXform = require('../../base-xform');
  12688. var FormulaXform = /*#__PURE__*/function (_BaseXform) {
  12689. _inherits(FormulaXform, _BaseXform);
  12690. var _super = _createSuper(FormulaXform);
  12691. function FormulaXform() {
  12692. _classCallCheck(this, FormulaXform);
  12693. return _super.apply(this, arguments);
  12694. }
  12695. _createClass(FormulaXform, [{
  12696. key: "render",
  12697. value: function render(xmlStream, model) {
  12698. xmlStream.leafNode(this.tag, null, model);
  12699. }
  12700. }, {
  12701. key: "parseOpen",
  12702. value: function parseOpen() {
  12703. this.model = '';
  12704. }
  12705. }, {
  12706. key: "parseText",
  12707. value: function parseText(text) {
  12708. this.model += text;
  12709. }
  12710. }, {
  12711. key: "parseClose",
  12712. value: function parseClose(name) {
  12713. return name !== this.tag;
  12714. }
  12715. }, {
  12716. key: "tag",
  12717. get: function get() {
  12718. return 'formula';
  12719. }
  12720. }]);
  12721. return FormulaXform;
  12722. }(BaseXform);
  12723. module.exports = FormulaXform;
  12724. }, { "../../base-xform": 31 }], 90: [function (require, module, exports) {
  12725. "use strict";
  12726. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12727. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12728. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12729. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12730. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12731. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12732. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12733. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12734. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12735. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12736. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12737. var BaseXform = require('../../base-xform');
  12738. var CompositeXform = require('../../composite-xform');
  12739. var CfvoXform = require('./cfvo-xform');
  12740. var IconSetXform = /*#__PURE__*/function (_CompositeXform) {
  12741. _inherits(IconSetXform, _CompositeXform);
  12742. var _super = _createSuper(IconSetXform);
  12743. function IconSetXform() {
  12744. var _this;
  12745. _classCallCheck(this, IconSetXform);
  12746. _this = _super.call(this);
  12747. _this.map = {
  12748. cfvo: _this.cfvoXform = new CfvoXform()
  12749. };
  12750. return _this;
  12751. }
  12752. _createClass(IconSetXform, [{
  12753. key: "render",
  12754. value: function render(xmlStream, model) {
  12755. var _this2 = this;
  12756. xmlStream.openNode(this.tag, {
  12757. iconSet: BaseXform.toStringAttribute(model.iconSet, '3TrafficLights'),
  12758. reverse: BaseXform.toBoolAttribute(model.reverse, false),
  12759. showValue: BaseXform.toBoolAttribute(model.showValue, true)
  12760. });
  12761. model.cfvo.forEach(function (cfvo) {
  12762. _this2.cfvoXform.render(xmlStream, cfvo);
  12763. });
  12764. xmlStream.closeNode();
  12765. }
  12766. }, {
  12767. key: "createNewModel",
  12768. value: function createNewModel(_ref) {
  12769. var attributes = _ref.attributes;
  12770. return {
  12771. iconSet: BaseXform.toStringValue(attributes.iconSet, '3TrafficLights'),
  12772. reverse: BaseXform.toBoolValue(attributes.reverse),
  12773. showValue: BaseXform.toBoolValue(attributes.showValue),
  12774. cfvo: []
  12775. };
  12776. }
  12777. }, {
  12778. key: "onParserClose",
  12779. value: function onParserClose(name, parser) {
  12780. this.model[name].push(parser.model);
  12781. }
  12782. }, {
  12783. key: "tag",
  12784. get: function get() {
  12785. return 'iconSet';
  12786. }
  12787. }]);
  12788. return IconSetXform;
  12789. }(CompositeXform);
  12790. module.exports = IconSetXform;
  12791. }, { "../../base-xform": 31, "../../composite-xform": 47, "./cfvo-xform": 83 }], 91: [function (require, module, exports) {
  12792. "use strict";
  12793. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12794. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12795. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12796. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12797. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12798. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12799. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12800. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12801. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12802. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12803. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12804. var BaseXform = require('../base-xform');
  12805. var ColXform = /*#__PURE__*/function (_BaseXform) {
  12806. _inherits(ColXform, _BaseXform);
  12807. var _super = _createSuper(ColXform);
  12808. function ColXform() {
  12809. _classCallCheck(this, ColXform);
  12810. return _super.apply(this, arguments);
  12811. }
  12812. _createClass(ColXform, [{
  12813. key: "prepare",
  12814. value: function prepare(model, options) {
  12815. var styleId = options.styles.addStyleModel(model.style || {});
  12816. if (styleId) {
  12817. model.styleId = styleId;
  12818. }
  12819. }
  12820. }, {
  12821. key: "render",
  12822. value: function render(xmlStream, model) {
  12823. xmlStream.openNode('col');
  12824. xmlStream.addAttribute('min', model.min);
  12825. xmlStream.addAttribute('max', model.max);
  12826. if (model.width) {
  12827. xmlStream.addAttribute('width', model.width);
  12828. }
  12829. if (model.styleId) {
  12830. xmlStream.addAttribute('style', model.styleId);
  12831. }
  12832. if (model.hidden) {
  12833. xmlStream.addAttribute('hidden', '1');
  12834. }
  12835. if (model.bestFit) {
  12836. xmlStream.addAttribute('bestFit', '1');
  12837. }
  12838. if (model.outlineLevel) {
  12839. xmlStream.addAttribute('outlineLevel', model.outlineLevel);
  12840. }
  12841. if (model.collapsed) {
  12842. xmlStream.addAttribute('collapsed', '1');
  12843. }
  12844. xmlStream.addAttribute('customWidth', '1');
  12845. xmlStream.closeNode();
  12846. }
  12847. }, {
  12848. key: "parseOpen",
  12849. value: function parseOpen(node) {
  12850. if (node.name === 'col') {
  12851. var model = this.model = {
  12852. min: parseInt(node.attributes.min || '0', 10),
  12853. max: parseInt(node.attributes.max || '0', 10),
  12854. width: node.attributes.width === undefined ? undefined : parseFloat(node.attributes.width || '0')
  12855. };
  12856. if (node.attributes.style) {
  12857. model.styleId = parseInt(node.attributes.style, 10);
  12858. }
  12859. if (node.attributes.hidden === true || node.attributes.hidden === 'true' || node.attributes.hidden === 1 || node.attributes.hidden === '1') {
  12860. model.hidden = true;
  12861. }
  12862. if (node.attributes.bestFit) {
  12863. model.bestFit = true;
  12864. }
  12865. if (node.attributes.outlineLevel) {
  12866. model.outlineLevel = parseInt(node.attributes.outlineLevel, 10);
  12867. }
  12868. if (node.attributes.collapsed) {
  12869. model.collapsed = true;
  12870. }
  12871. return true;
  12872. }
  12873. return false;
  12874. }
  12875. }, {
  12876. key: "parseText",
  12877. value: function parseText() { }
  12878. }, {
  12879. key: "parseClose",
  12880. value: function parseClose() {
  12881. return false;
  12882. }
  12883. }, {
  12884. key: "reconcile",
  12885. value: function reconcile(model, options) {
  12886. // reconcile column styles
  12887. if (model.styleId) {
  12888. model.style = options.styles.getStyleModel(model.styleId);
  12889. }
  12890. }
  12891. }, {
  12892. key: "tag",
  12893. get: function get() {
  12894. return 'col';
  12895. }
  12896. }]);
  12897. return ColXform;
  12898. }(BaseXform);
  12899. module.exports = ColXform;
  12900. }, { "../base-xform": 31 }], 92: [function (require, module, exports) {
  12901. "use strict";
  12902. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12903. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12904. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12905. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12906. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12907. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12908. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12909. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12910. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12911. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  12912. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12913. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  12914. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  12915. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  12916. var _ = require('../../../utils/under-dash');
  12917. var utils = require('../../../utils/utils');
  12918. var colCache = require('../../../utils/col-cache');
  12919. var BaseXform = require('../base-xform');
  12920. var Range = require('../../../doc/range');
  12921. function assign(definedName, attributes, name, defaultValue) {
  12922. var value = attributes[name];
  12923. if (value !== undefined) {
  12924. definedName[name] = value;
  12925. } else if (defaultValue !== undefined) {
  12926. definedName[name] = defaultValue;
  12927. }
  12928. }
  12929. function parseBool(value) {
  12930. switch (value) {
  12931. case '1':
  12932. case 'true':
  12933. return true;
  12934. default:
  12935. return false;
  12936. }
  12937. }
  12938. function assignBool(definedName, attributes, name, defaultValue) {
  12939. var value = attributes[name];
  12940. if (value !== undefined) {
  12941. definedName[name] = parseBool(value);
  12942. } else if (defaultValue !== undefined) {
  12943. definedName[name] = defaultValue;
  12944. }
  12945. }
  12946. function optimiseDataValidations(model) {
  12947. // Squeeze alike data validations together into rectangular ranges
  12948. // to reduce file size and speed up Excel load time
  12949. var dvList = _.map(model, function (dataValidation, address) {
  12950. return {
  12951. address: address,
  12952. dataValidation: dataValidation,
  12953. marked: false
  12954. };
  12955. }).sort(function (a, b) {
  12956. return _.strcmp(a.address, b.address);
  12957. });
  12958. var dvMap = _.keyBy(dvList, 'address');
  12959. var matchCol = function matchCol(addr, height, col) {
  12960. for (var i = 0; i < height; i++) {
  12961. var otherAddress = colCache.encodeAddress(addr.row + i, col);
  12962. if (!model[otherAddress] || !_.isEqual(model[addr.address], model[otherAddress])) {
  12963. return false;
  12964. }
  12965. }
  12966. return true;
  12967. };
  12968. return dvList.map(function (dv) {
  12969. if (!dv.marked) {
  12970. var addr = colCache.decodeEx(dv.address);
  12971. if (addr.dimensions) {
  12972. dvMap[addr.dimensions].marked = true;
  12973. return _objectSpread(_objectSpread({}, dv.dataValidation), {}, {
  12974. sqref: dv.address
  12975. });
  12976. } // iterate downwards - finding matching cells
  12977. var height = 1;
  12978. var otherAddress = colCache.encodeAddress(addr.row + height, addr.col);
  12979. while (model[otherAddress] && _.isEqual(dv.dataValidation, model[otherAddress])) {
  12980. height++;
  12981. otherAddress = colCache.encodeAddress(addr.row + height, addr.col);
  12982. } // iterate rightwards...
  12983. var width = 1;
  12984. while (matchCol(addr, height, addr.col + width)) {
  12985. width++;
  12986. } // mark all included addresses
  12987. for (var i = 0; i < height; i++) {
  12988. for (var j = 0; j < width; j++) {
  12989. otherAddress = colCache.encodeAddress(addr.row + i, addr.col + j);
  12990. dvMap[otherAddress].marked = true;
  12991. }
  12992. }
  12993. if (height > 1 || width > 1) {
  12994. var bottom = addr.row + (height - 1);
  12995. var right = addr.col + (width - 1);
  12996. return _objectSpread(_objectSpread({}, dv.dataValidation), {}, {
  12997. sqref: "".concat(dv.address, ":").concat(colCache.encodeAddress(bottom, right))
  12998. });
  12999. }
  13000. return _objectSpread(_objectSpread({}, dv.dataValidation), {}, {
  13001. sqref: dv.address
  13002. });
  13003. }
  13004. return null;
  13005. }).filter(Boolean);
  13006. }
  13007. var DataValidationsXform = /*#__PURE__*/function (_BaseXform) {
  13008. _inherits(DataValidationsXform, _BaseXform);
  13009. var _super = _createSuper(DataValidationsXform);
  13010. function DataValidationsXform() {
  13011. _classCallCheck(this, DataValidationsXform);
  13012. return _super.apply(this, arguments);
  13013. }
  13014. _createClass(DataValidationsXform, [{
  13015. key: "render",
  13016. value: function render(xmlStream, model) {
  13017. var optimizedModel = optimiseDataValidations(model);
  13018. if (optimizedModel.length) {
  13019. xmlStream.openNode('dataValidations', {
  13020. count: optimizedModel.length
  13021. });
  13022. optimizedModel.forEach(function (value) {
  13023. xmlStream.openNode('dataValidation');
  13024. if (value.type !== 'any') {
  13025. xmlStream.addAttribute('type', value.type);
  13026. if (value.operator && value.type !== 'list' && value.operator !== 'between') {
  13027. xmlStream.addAttribute('operator', value.operator);
  13028. }
  13029. if (value.allowBlank) {
  13030. xmlStream.addAttribute('allowBlank', '1');
  13031. }
  13032. }
  13033. if (value.showInputMessage) {
  13034. xmlStream.addAttribute('showInputMessage', '1');
  13035. }
  13036. if (value.promptTitle) {
  13037. xmlStream.addAttribute('promptTitle', value.promptTitle);
  13038. }
  13039. if (value.prompt) {
  13040. xmlStream.addAttribute('prompt', value.prompt);
  13041. }
  13042. if (value.showErrorMessage) {
  13043. xmlStream.addAttribute('showErrorMessage', '1');
  13044. }
  13045. if (value.errorStyle) {
  13046. xmlStream.addAttribute('errorStyle', value.errorStyle);
  13047. }
  13048. if (value.errorTitle) {
  13049. xmlStream.addAttribute('errorTitle', value.errorTitle);
  13050. }
  13051. if (value.error) {
  13052. xmlStream.addAttribute('error', value.error);
  13053. }
  13054. xmlStream.addAttribute('sqref', value.sqref);
  13055. (value.formulae || []).forEach(function (formula, index) {
  13056. xmlStream.openNode("formula".concat(index + 1));
  13057. if (value.type === 'date') {
  13058. xmlStream.writeText(utils.dateToExcel(new Date(formula)));
  13059. } else {
  13060. xmlStream.writeText(formula);
  13061. }
  13062. xmlStream.closeNode();
  13063. });
  13064. xmlStream.closeNode();
  13065. });
  13066. xmlStream.closeNode();
  13067. }
  13068. }
  13069. }, {
  13070. key: "parseOpen",
  13071. value: function parseOpen(node) {
  13072. switch (node.name) {
  13073. case 'dataValidations':
  13074. this.model = {};
  13075. return true;
  13076. case 'dataValidation':
  13077. {
  13078. this._address = node.attributes.sqref;
  13079. var dataValidation = {
  13080. type: node.attributes.type || 'any',
  13081. formulae: []
  13082. };
  13083. if (node.attributes.type) {
  13084. assignBool(dataValidation, node.attributes, 'allowBlank');
  13085. }
  13086. assignBool(dataValidation, node.attributes, 'showInputMessage');
  13087. assignBool(dataValidation, node.attributes, 'showErrorMessage');
  13088. switch (dataValidation.type) {
  13089. case 'any':
  13090. case 'list':
  13091. case 'custom':
  13092. break;
  13093. default:
  13094. assign(dataValidation, node.attributes, 'operator', 'between');
  13095. break;
  13096. }
  13097. assign(dataValidation, node.attributes, 'promptTitle');
  13098. assign(dataValidation, node.attributes, 'prompt');
  13099. assign(dataValidation, node.attributes, 'errorStyle');
  13100. assign(dataValidation, node.attributes, 'errorTitle');
  13101. assign(dataValidation, node.attributes, 'error');
  13102. this._dataValidation = dataValidation;
  13103. return true;
  13104. }
  13105. case 'formula1':
  13106. case 'formula2':
  13107. this._formula = [];
  13108. return true;
  13109. default:
  13110. return false;
  13111. }
  13112. }
  13113. }, {
  13114. key: "parseText",
  13115. value: function parseText(text) {
  13116. if (this._formula) {
  13117. this._formula.push(text);
  13118. }
  13119. }
  13120. }, {
  13121. key: "parseClose",
  13122. value: function parseClose(name) {
  13123. var _this = this;
  13124. switch (name) {
  13125. case 'dataValidations':
  13126. return false;
  13127. case 'dataValidation':
  13128. {
  13129. if (!this._dataValidation.formulae || !this._dataValidation.formulae.length) {
  13130. delete this._dataValidation.formulae;
  13131. delete this._dataValidation.operator;
  13132. } // The four known cases: 1. E4:L9 N4:U9 2.E4 L9 3. N4:U9 4. E4
  13133. var list = this._address.split(/\s+/g) || [];
  13134. list.forEach(function (addr) {
  13135. if (addr.includes(':')) {
  13136. var range = new Range(addr);
  13137. range.forEachAddress(function (address) {
  13138. _this.model[address] = _this._dataValidation;
  13139. });
  13140. } else {
  13141. _this.model[addr] = _this._dataValidation;
  13142. }
  13143. });
  13144. return true;
  13145. }
  13146. case 'formula1':
  13147. case 'formula2':
  13148. {
  13149. var formula = this._formula.join('');
  13150. switch (this._dataValidation.type) {
  13151. case 'whole':
  13152. case 'textLength':
  13153. formula = parseInt(formula, 10);
  13154. break;
  13155. case 'decimal':
  13156. formula = parseFloat(formula);
  13157. break;
  13158. case 'date':
  13159. formula = utils.excelToDate(parseFloat(formula));
  13160. break;
  13161. default:
  13162. break;
  13163. }
  13164. this._dataValidation.formulae.push(formula);
  13165. this._formula = undefined;
  13166. return true;
  13167. }
  13168. default:
  13169. return true;
  13170. }
  13171. }
  13172. }, {
  13173. key: "tag",
  13174. get: function get() {
  13175. return 'dataValidations';
  13176. }
  13177. }]);
  13178. return DataValidationsXform;
  13179. }(BaseXform);
  13180. module.exports = DataValidationsXform;
  13181. }, { "../../../doc/range": 10, "../../../utils/col-cache": 19, "../../../utils/under-dash": 25, "../../../utils/utils": 26, "../base-xform": 31 }], 93: [function (require, module, exports) {
  13182. "use strict";
  13183. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13184. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13185. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13186. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13187. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13188. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13189. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13190. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13191. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13192. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13193. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13194. var BaseXform = require('../base-xform');
  13195. var DimensionXform = /*#__PURE__*/function (_BaseXform) {
  13196. _inherits(DimensionXform, _BaseXform);
  13197. var _super = _createSuper(DimensionXform);
  13198. function DimensionXform() {
  13199. _classCallCheck(this, DimensionXform);
  13200. return _super.apply(this, arguments);
  13201. }
  13202. _createClass(DimensionXform, [{
  13203. key: "render",
  13204. value: function render(xmlStream, model) {
  13205. if (model) {
  13206. xmlStream.leafNode('dimension', {
  13207. ref: model
  13208. });
  13209. }
  13210. }
  13211. }, {
  13212. key: "parseOpen",
  13213. value: function parseOpen(node) {
  13214. if (node.name === 'dimension') {
  13215. this.model = node.attributes.ref;
  13216. return true;
  13217. }
  13218. return false;
  13219. }
  13220. }, {
  13221. key: "parseText",
  13222. value: function parseText() { }
  13223. }, {
  13224. key: "parseClose",
  13225. value: function parseClose() {
  13226. return false;
  13227. }
  13228. }, {
  13229. key: "tag",
  13230. get: function get() {
  13231. return 'dimension';
  13232. }
  13233. }]);
  13234. return DimensionXform;
  13235. }(BaseXform);
  13236. module.exports = DimensionXform;
  13237. }, { "../base-xform": 31 }], 94: [function (require, module, exports) {
  13238. "use strict";
  13239. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13240. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13241. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13242. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13243. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13244. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13245. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13246. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13247. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13248. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13249. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13250. var BaseXform = require('../base-xform');
  13251. var DrawingXform = /*#__PURE__*/function (_BaseXform) {
  13252. _inherits(DrawingXform, _BaseXform);
  13253. var _super = _createSuper(DrawingXform);
  13254. function DrawingXform() {
  13255. _classCallCheck(this, DrawingXform);
  13256. return _super.apply(this, arguments);
  13257. }
  13258. _createClass(DrawingXform, [{
  13259. key: "render",
  13260. value: function render(xmlStream, model) {
  13261. if (model) {
  13262. xmlStream.leafNode(this.tag, {
  13263. 'r:id': model.rId
  13264. });
  13265. }
  13266. }
  13267. }, {
  13268. key: "parseOpen",
  13269. value: function parseOpen(node) {
  13270. switch (node.name) {
  13271. case this.tag:
  13272. this.model = {
  13273. rId: node.attributes['r:id']
  13274. };
  13275. return true;
  13276. default:
  13277. return false;
  13278. }
  13279. }
  13280. }, {
  13281. key: "parseText",
  13282. value: function parseText() { }
  13283. }, {
  13284. key: "parseClose",
  13285. value: function parseClose() {
  13286. return false;
  13287. }
  13288. }, {
  13289. key: "tag",
  13290. get: function get() {
  13291. return 'drawing';
  13292. }
  13293. }]);
  13294. return DrawingXform;
  13295. }(BaseXform);
  13296. module.exports = DrawingXform;
  13297. }, { "../base-xform": 31 }], 95: [function (require, module, exports) {
  13298. "use strict";
  13299. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13300. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13301. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13302. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13303. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13304. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13305. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13306. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13307. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13308. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13309. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13310. /* eslint-disable max-classes-per-file */
  13311. var CompositeXform = require('../composite-xform');
  13312. var ConditionalFormattingsExt = require('./cf-ext/conditional-formattings-ext-xform');
  13313. var ExtXform = /*#__PURE__*/function (_CompositeXform) {
  13314. _inherits(ExtXform, _CompositeXform);
  13315. var _super = _createSuper(ExtXform);
  13316. function ExtXform() {
  13317. var _this;
  13318. _classCallCheck(this, ExtXform);
  13319. _this = _super.call(this);
  13320. _this.map = {
  13321. 'x14:conditionalFormattings': _this.conditionalFormattings = new ConditionalFormattingsExt()
  13322. };
  13323. return _this;
  13324. }
  13325. _createClass(ExtXform, [{
  13326. key: "hasContent",
  13327. value: function hasContent(model) {
  13328. return this.conditionalFormattings.hasContent(model.conditionalFormattings);
  13329. }
  13330. }, {
  13331. key: "prepare",
  13332. value: function prepare(model, options) {
  13333. this.conditionalFormattings.prepare(model.conditionalFormattings, options);
  13334. }
  13335. }, {
  13336. key: "render",
  13337. value: function render(xmlStream, model) {
  13338. xmlStream.openNode('ext', {
  13339. uri: '{78C0D931-6437-407d-A8EE-F0AAD7539E65}',
  13340. 'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main'
  13341. });
  13342. this.conditionalFormattings.render(xmlStream, model.conditionalFormattings);
  13343. xmlStream.closeNode();
  13344. }
  13345. }, {
  13346. key: "createNewModel",
  13347. value: function createNewModel() {
  13348. return {};
  13349. }
  13350. }, {
  13351. key: "onParserClose",
  13352. value: function onParserClose(name, parser) {
  13353. this.model[name] = parser.model;
  13354. }
  13355. }, {
  13356. key: "tag",
  13357. get: function get() {
  13358. return 'ext';
  13359. }
  13360. }]);
  13361. return ExtXform;
  13362. }(CompositeXform);
  13363. var ExtLstXform = /*#__PURE__*/function (_CompositeXform2) {
  13364. _inherits(ExtLstXform, _CompositeXform2);
  13365. var _super2 = _createSuper(ExtLstXform);
  13366. function ExtLstXform() {
  13367. var _this2;
  13368. _classCallCheck(this, ExtLstXform);
  13369. _this2 = _super2.call(this);
  13370. _this2.map = {
  13371. ext: _this2.ext = new ExtXform()
  13372. };
  13373. return _this2;
  13374. }
  13375. _createClass(ExtLstXform, [{
  13376. key: "prepare",
  13377. value: function prepare(model, options) {
  13378. this.ext.prepare(model, options);
  13379. }
  13380. }, {
  13381. key: "hasContent",
  13382. value: function hasContent(model) {
  13383. return this.ext.hasContent(model);
  13384. }
  13385. }, {
  13386. key: "render",
  13387. value: function render(xmlStream, model) {
  13388. if (!this.hasContent(model)) {
  13389. return;
  13390. }
  13391. xmlStream.openNode('extLst');
  13392. this.ext.render(xmlStream, model);
  13393. xmlStream.closeNode();
  13394. }
  13395. }, {
  13396. key: "createNewModel",
  13397. value: function createNewModel() {
  13398. return {};
  13399. }
  13400. }, {
  13401. key: "onParserClose",
  13402. value: function onParserClose(name, parser) {
  13403. Object.assign(this.model, parser.model);
  13404. }
  13405. }, {
  13406. key: "tag",
  13407. get: function get() {
  13408. return 'extLst';
  13409. }
  13410. }]);
  13411. return ExtLstXform;
  13412. }(CompositeXform);
  13413. module.exports = ExtLstXform;
  13414. }, { "../composite-xform": 47, "./cf-ext/conditional-formattings-ext-xform": 77 }], 96: [function (require, module, exports) {
  13415. "use strict";
  13416. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13417. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13418. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13419. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13420. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13421. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13422. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13423. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13424. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13425. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13426. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13427. var BaseXform = require('../base-xform');
  13428. var HeaderFooterXform = /*#__PURE__*/function (_BaseXform) {
  13429. _inherits(HeaderFooterXform, _BaseXform);
  13430. var _super = _createSuper(HeaderFooterXform);
  13431. function HeaderFooterXform() {
  13432. _classCallCheck(this, HeaderFooterXform);
  13433. return _super.apply(this, arguments);
  13434. }
  13435. _createClass(HeaderFooterXform, [{
  13436. key: "render",
  13437. value: function render(xmlStream, model) {
  13438. if (model) {
  13439. xmlStream.addRollback();
  13440. var createTag = false;
  13441. xmlStream.openNode('headerFooter');
  13442. if (model.differentFirst) {
  13443. xmlStream.addAttribute('differentFirst', '1');
  13444. createTag = true;
  13445. }
  13446. if (model.differentOddEven) {
  13447. xmlStream.addAttribute('differentOddEven', '1');
  13448. createTag = true;
  13449. }
  13450. if (model.oddHeader && typeof model.oddHeader === 'string') {
  13451. xmlStream.leafNode('oddHeader', null, model.oddHeader);
  13452. createTag = true;
  13453. }
  13454. if (model.oddFooter && typeof model.oddFooter === 'string') {
  13455. xmlStream.leafNode('oddFooter', null, model.oddFooter);
  13456. createTag = true;
  13457. }
  13458. if (model.evenHeader && typeof model.evenHeader === 'string') {
  13459. xmlStream.leafNode('evenHeader', null, model.evenHeader);
  13460. createTag = true;
  13461. }
  13462. if (model.evenFooter && typeof model.evenFooter === 'string') {
  13463. xmlStream.leafNode('evenFooter', null, model.evenFooter);
  13464. createTag = true;
  13465. }
  13466. if (model.firstHeader && typeof model.firstHeader === 'string') {
  13467. xmlStream.leafNode('firstHeader', null, model.firstHeader);
  13468. createTag = true;
  13469. }
  13470. if (model.firstFooter && typeof model.firstFooter === 'string') {
  13471. xmlStream.leafNode('firstFooter', null, model.firstFooter);
  13472. createTag = true;
  13473. }
  13474. if (createTag) {
  13475. xmlStream.closeNode();
  13476. xmlStream.commit();
  13477. } else {
  13478. xmlStream.rollback();
  13479. }
  13480. }
  13481. }
  13482. }, {
  13483. key: "parseOpen",
  13484. value: function parseOpen(node) {
  13485. switch (node.name) {
  13486. case 'headerFooter':
  13487. this.model = {};
  13488. if (node.attributes.differentFirst) {
  13489. this.model.differentFirst = parseInt(node.attributes.differentFirst, 0) === 1;
  13490. }
  13491. if (node.attributes.differentOddEven) {
  13492. this.model.differentOddEven = parseInt(node.attributes.differentOddEven, 0) === 1;
  13493. }
  13494. return true;
  13495. case 'oddHeader':
  13496. this.currentNode = 'oddHeader';
  13497. return true;
  13498. case 'oddFooter':
  13499. this.currentNode = 'oddFooter';
  13500. return true;
  13501. case 'evenHeader':
  13502. this.currentNode = 'evenHeader';
  13503. return true;
  13504. case 'evenFooter':
  13505. this.currentNode = 'evenFooter';
  13506. return true;
  13507. case 'firstHeader':
  13508. this.currentNode = 'firstHeader';
  13509. return true;
  13510. case 'firstFooter':
  13511. this.currentNode = 'firstFooter';
  13512. return true;
  13513. default:
  13514. return false;
  13515. }
  13516. }
  13517. }, {
  13518. key: "parseText",
  13519. value: function parseText(text) {
  13520. switch (this.currentNode) {
  13521. case 'oddHeader':
  13522. this.model.oddHeader = text;
  13523. break;
  13524. case 'oddFooter':
  13525. this.model.oddFooter = text;
  13526. break;
  13527. case 'evenHeader':
  13528. this.model.evenHeader = text;
  13529. break;
  13530. case 'evenFooter':
  13531. this.model.evenFooter = text;
  13532. break;
  13533. case 'firstHeader':
  13534. this.model.firstHeader = text;
  13535. break;
  13536. case 'firstFooter':
  13537. this.model.firstFooter = text;
  13538. break;
  13539. default:
  13540. break;
  13541. }
  13542. }
  13543. }, {
  13544. key: "parseClose",
  13545. value: function parseClose() {
  13546. switch (this.currentNode) {
  13547. case 'oddHeader':
  13548. case 'oddFooter':
  13549. case 'evenHeader':
  13550. case 'evenFooter':
  13551. case 'firstHeader':
  13552. case 'firstFooter':
  13553. this.currentNode = undefined;
  13554. return true;
  13555. default:
  13556. return false;
  13557. }
  13558. }
  13559. }, {
  13560. key: "tag",
  13561. get: function get() {
  13562. return 'headerFooter';
  13563. }
  13564. }]);
  13565. return HeaderFooterXform;
  13566. }(BaseXform);
  13567. module.exports = HeaderFooterXform;
  13568. }, { "../base-xform": 31 }], 97: [function (require, module, exports) {
  13569. "use strict";
  13570. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13571. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13572. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13573. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13574. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13575. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13576. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13577. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13578. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13579. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13580. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13581. var BaseXform = require('../base-xform');
  13582. var HyperlinkXform = /*#__PURE__*/function (_BaseXform) {
  13583. _inherits(HyperlinkXform, _BaseXform);
  13584. var _super = _createSuper(HyperlinkXform);
  13585. function HyperlinkXform() {
  13586. _classCallCheck(this, HyperlinkXform);
  13587. return _super.apply(this, arguments);
  13588. }
  13589. _createClass(HyperlinkXform, [{
  13590. key: "render",
  13591. value: function render(xmlStream, model) {
  13592. xmlStream.leafNode('hyperlink', {
  13593. ref: model.address,
  13594. 'r:id': model.rId,
  13595. tooltip: model.tooltip
  13596. });
  13597. }
  13598. }, {
  13599. key: "parseOpen",
  13600. value: function parseOpen(node) {
  13601. if (node.name === 'hyperlink') {
  13602. this.model = {
  13603. address: node.attributes.ref,
  13604. rId: node.attributes['r:id'],
  13605. tooltip: node.attributes.tooltip
  13606. };
  13607. return true;
  13608. }
  13609. return false;
  13610. }
  13611. }, {
  13612. key: "parseText",
  13613. value: function parseText() { }
  13614. }, {
  13615. key: "parseClose",
  13616. value: function parseClose() {
  13617. return false;
  13618. }
  13619. }, {
  13620. key: "tag",
  13621. get: function get() {
  13622. return 'hyperlink';
  13623. }
  13624. }]);
  13625. return HyperlinkXform;
  13626. }(BaseXform);
  13627. module.exports = HyperlinkXform;
  13628. }, { "../base-xform": 31 }], 98: [function (require, module, exports) {
  13629. "use strict";
  13630. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13631. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13632. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13633. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13634. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13635. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13636. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13637. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13638. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13639. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13640. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13641. var BaseXform = require('../base-xform');
  13642. var MergeCellXform = /*#__PURE__*/function (_BaseXform) {
  13643. _inherits(MergeCellXform, _BaseXform);
  13644. var _super = _createSuper(MergeCellXform);
  13645. function MergeCellXform() {
  13646. _classCallCheck(this, MergeCellXform);
  13647. return _super.apply(this, arguments);
  13648. }
  13649. _createClass(MergeCellXform, [{
  13650. key: "render",
  13651. value: function render(xmlStream, model) {
  13652. xmlStream.leafNode('mergeCell', {
  13653. ref: model
  13654. });
  13655. }
  13656. }, {
  13657. key: "parseOpen",
  13658. value: function parseOpen(node) {
  13659. if (node.name === 'mergeCell') {
  13660. this.model = node.attributes.ref;
  13661. return true;
  13662. }
  13663. return false;
  13664. }
  13665. }, {
  13666. key: "parseText",
  13667. value: function parseText() { }
  13668. }, {
  13669. key: "parseClose",
  13670. value: function parseClose() {
  13671. return false;
  13672. }
  13673. }, {
  13674. key: "tag",
  13675. get: function get() {
  13676. return 'mergeCell';
  13677. }
  13678. }]);
  13679. return MergeCellXform;
  13680. }(BaseXform);
  13681. module.exports = MergeCellXform;
  13682. }, { "../base-xform": 31 }], 99: [function (require, module, exports) {
  13683. "use strict";
  13684. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13685. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13686. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13687. var _ = require('../../../utils/under-dash');
  13688. var Range = require('../../../doc/range');
  13689. var colCache = require('../../../utils/col-cache');
  13690. var Enums = require('../../../doc/enums');
  13691. var Merges = /*#__PURE__*/function () {
  13692. function Merges() {
  13693. _classCallCheck(this, Merges);
  13694. // optional mergeCells is array of ranges (like the xml)
  13695. this.merges = {};
  13696. }
  13697. _createClass(Merges, [{
  13698. key: "add",
  13699. value: function add(merge) {
  13700. // merge is {address, master}
  13701. if (this.merges[merge.master]) {
  13702. this.merges[merge.master].expandToAddress(merge.address);
  13703. } else {
  13704. var range = "".concat(merge.master, ":").concat(merge.address);
  13705. this.merges[merge.master] = new Range(range);
  13706. }
  13707. }
  13708. }, {
  13709. key: "reconcile",
  13710. value: function reconcile(mergeCells, rows) {
  13711. // reconcile merge list with merge cells
  13712. _.each(mergeCells, function (merge) {
  13713. var dimensions = colCache.decode(merge);
  13714. for (var i = dimensions.top; i <= dimensions.bottom; i++) {
  13715. var row = rows[i - 1];
  13716. for (var j = dimensions.left; j <= dimensions.right; j++) {
  13717. var cell = row.cells[j - 1];
  13718. if (!cell) {
  13719. // nulls are not included in document - so if master cell has no value - add a null one here
  13720. row.cells[j] = {
  13721. type: Enums.ValueType.Null,
  13722. address: colCache.encodeAddress(i, j)
  13723. };
  13724. } else if (cell.type === Enums.ValueType.Merge) {
  13725. cell.master = dimensions.tl;
  13726. }
  13727. }
  13728. }
  13729. });
  13730. }
  13731. }, {
  13732. key: "getMasterAddress",
  13733. value: function getMasterAddress(address) {
  13734. // if address has been merged, return its master's address. Assumes reconcile has been called
  13735. var range = this.hash[address];
  13736. return range && range.tl;
  13737. }
  13738. }, {
  13739. key: "mergeCells",
  13740. get: function get() {
  13741. return _.map(this.merges, function (merge) {
  13742. return merge.range;
  13743. });
  13744. }
  13745. }]);
  13746. return Merges;
  13747. }();
  13748. module.exports = Merges;
  13749. }, { "../../../doc/enums": 7, "../../../doc/range": 10, "../../../utils/col-cache": 19, "../../../utils/under-dash": 25 }], 100: [function (require, module, exports) {
  13750. "use strict";
  13751. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13752. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13753. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13754. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13755. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13756. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13757. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13758. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13759. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13760. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13761. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13762. var BaseXform = require('../base-xform');
  13763. var isDefined = function isDefined(attr) {
  13764. return typeof attr !== 'undefined';
  13765. };
  13766. var OutlinePropertiesXform = /*#__PURE__*/function (_BaseXform) {
  13767. _inherits(OutlinePropertiesXform, _BaseXform);
  13768. var _super = _createSuper(OutlinePropertiesXform);
  13769. function OutlinePropertiesXform() {
  13770. _classCallCheck(this, OutlinePropertiesXform);
  13771. return _super.apply(this, arguments);
  13772. }
  13773. _createClass(OutlinePropertiesXform, [{
  13774. key: "render",
  13775. value: function render(xmlStream, model) {
  13776. if (model && (isDefined(model.summaryBelow) || isDefined(model.summaryRight))) {
  13777. xmlStream.leafNode(this.tag, {
  13778. summaryBelow: isDefined(model.summaryBelow) ? Number(model.summaryBelow) : undefined,
  13779. summaryRight: isDefined(model.summaryRight) ? Number(model.summaryRight) : undefined
  13780. });
  13781. return true;
  13782. }
  13783. return false;
  13784. }
  13785. }, {
  13786. key: "parseOpen",
  13787. value: function parseOpen(node) {
  13788. if (node.name === this.tag) {
  13789. this.model = {
  13790. summaryBelow: isDefined(node.attributes.summaryBelow) ? Boolean(Number(node.attributes.summaryBelow)) : undefined,
  13791. summaryRight: isDefined(node.attributes.summaryRight) ? Boolean(Number(node.attributes.summaryRight)) : undefined
  13792. };
  13793. return true;
  13794. }
  13795. return false;
  13796. }
  13797. }, {
  13798. key: "parseText",
  13799. value: function parseText() { }
  13800. }, {
  13801. key: "parseClose",
  13802. value: function parseClose() {
  13803. return false;
  13804. }
  13805. }, {
  13806. key: "tag",
  13807. get: function get() {
  13808. return 'outlinePr';
  13809. }
  13810. }]);
  13811. return OutlinePropertiesXform;
  13812. }(BaseXform);
  13813. module.exports = OutlinePropertiesXform;
  13814. }, { "../base-xform": 31 }], 101: [function (require, module, exports) {
  13815. "use strict";
  13816. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13817. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13818. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13819. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13820. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13821. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13822. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13823. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13824. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13825. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13826. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13827. var BaseXform = require('../base-xform');
  13828. var PageBreaksXform = /*#__PURE__*/function (_BaseXform) {
  13829. _inherits(PageBreaksXform, _BaseXform);
  13830. var _super = _createSuper(PageBreaksXform);
  13831. function PageBreaksXform() {
  13832. _classCallCheck(this, PageBreaksXform);
  13833. return _super.apply(this, arguments);
  13834. }
  13835. _createClass(PageBreaksXform, [{
  13836. key: "render",
  13837. value: function render(xmlStream, model) {
  13838. xmlStream.leafNode('brk', model);
  13839. }
  13840. }, {
  13841. key: "parseOpen",
  13842. value: function parseOpen(node) {
  13843. if (node.name === 'brk') {
  13844. this.model = node.attributes.ref;
  13845. return true;
  13846. }
  13847. return false;
  13848. }
  13849. }, {
  13850. key: "parseText",
  13851. value: function parseText() { }
  13852. }, {
  13853. key: "parseClose",
  13854. value: function parseClose() {
  13855. return false;
  13856. }
  13857. }, {
  13858. key: "tag",
  13859. get: function get() {
  13860. return 'brk';
  13861. }
  13862. }]);
  13863. return PageBreaksXform;
  13864. }(BaseXform);
  13865. module.exports = PageBreaksXform;
  13866. }, { "../base-xform": 31 }], 102: [function (require, module, exports) {
  13867. "use strict";
  13868. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13869. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13870. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13871. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13872. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13873. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13874. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13875. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13876. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13877. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13878. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13879. var _ = require('../../../utils/under-dash');
  13880. var BaseXform = require('../base-xform');
  13881. var PageMarginsXform = /*#__PURE__*/function (_BaseXform) {
  13882. _inherits(PageMarginsXform, _BaseXform);
  13883. var _super = _createSuper(PageMarginsXform);
  13884. function PageMarginsXform() {
  13885. _classCallCheck(this, PageMarginsXform);
  13886. return _super.apply(this, arguments);
  13887. }
  13888. _createClass(PageMarginsXform, [{
  13889. key: "render",
  13890. value: function render(xmlStream, model) {
  13891. if (model) {
  13892. var attributes = {
  13893. left: model.left,
  13894. right: model.right,
  13895. top: model.top,
  13896. bottom: model.bottom,
  13897. header: model.header,
  13898. footer: model.footer
  13899. };
  13900. if (_.some(attributes, function (value) {
  13901. return value !== undefined;
  13902. })) {
  13903. xmlStream.leafNode(this.tag, attributes);
  13904. }
  13905. }
  13906. }
  13907. }, {
  13908. key: "parseOpen",
  13909. value: function parseOpen(node) {
  13910. switch (node.name) {
  13911. case this.tag:
  13912. this.model = {
  13913. left: parseFloat(node.attributes.left || 0.7),
  13914. right: parseFloat(node.attributes.right || 0.7),
  13915. top: parseFloat(node.attributes.top || 0.75),
  13916. bottom: parseFloat(node.attributes.bottom || 0.75),
  13917. header: parseFloat(node.attributes.header || 0.3),
  13918. footer: parseFloat(node.attributes.footer || 0.3)
  13919. };
  13920. return true;
  13921. default:
  13922. return false;
  13923. }
  13924. }
  13925. }, {
  13926. key: "parseText",
  13927. value: function parseText() { }
  13928. }, {
  13929. key: "parseClose",
  13930. value: function parseClose() {
  13931. return false;
  13932. }
  13933. }, {
  13934. key: "tag",
  13935. get: function get() {
  13936. return 'pageMargins';
  13937. }
  13938. }]);
  13939. return PageMarginsXform;
  13940. }(BaseXform);
  13941. module.exports = PageMarginsXform;
  13942. }, { "../../../utils/under-dash": 25, "../base-xform": 31 }], 103: [function (require, module, exports) {
  13943. "use strict";
  13944. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13945. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13946. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13947. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13948. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13949. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13950. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13951. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13952. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13953. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  13954. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13955. var BaseXform = require('../base-xform');
  13956. var PageSetupPropertiesXform = /*#__PURE__*/function (_BaseXform) {
  13957. _inherits(PageSetupPropertiesXform, _BaseXform);
  13958. var _super = _createSuper(PageSetupPropertiesXform);
  13959. function PageSetupPropertiesXform() {
  13960. _classCallCheck(this, PageSetupPropertiesXform);
  13961. return _super.apply(this, arguments);
  13962. }
  13963. _createClass(PageSetupPropertiesXform, [{
  13964. key: "render",
  13965. value: function render(xmlStream, model) {
  13966. if (model && model.fitToPage) {
  13967. xmlStream.leafNode(this.tag, {
  13968. fitToPage: model.fitToPage ? '1' : undefined
  13969. });
  13970. return true;
  13971. }
  13972. return false;
  13973. }
  13974. }, {
  13975. key: "parseOpen",
  13976. value: function parseOpen(node) {
  13977. if (node.name === this.tag) {
  13978. this.model = {
  13979. fitToPage: node.attributes.fitToPage === '1'
  13980. };
  13981. return true;
  13982. }
  13983. return false;
  13984. }
  13985. }, {
  13986. key: "parseText",
  13987. value: function parseText() { }
  13988. }, {
  13989. key: "parseClose",
  13990. value: function parseClose() {
  13991. return false;
  13992. }
  13993. }, {
  13994. key: "tag",
  13995. get: function get() {
  13996. return 'pageSetUpPr';
  13997. }
  13998. }]);
  13999. return PageSetupPropertiesXform;
  14000. }(BaseXform);
  14001. module.exports = PageSetupPropertiesXform;
  14002. }, { "../base-xform": 31 }], 104: [function (require, module, exports) {
  14003. "use strict";
  14004. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14005. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14006. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14007. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14008. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14009. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14010. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14011. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14012. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14013. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  14014. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14015. var _ = require('../../../utils/under-dash');
  14016. var BaseXform = require('../base-xform');
  14017. function booleanToXml(model) {
  14018. return model ? '1' : undefined;
  14019. }
  14020. function pageOrderToXml(model) {
  14021. switch (model) {
  14022. case 'overThenDown':
  14023. return model;
  14024. default:
  14025. return undefined;
  14026. }
  14027. }
  14028. function cellCommentsToXml(model) {
  14029. switch (model) {
  14030. case 'atEnd':
  14031. case 'asDisplyed':
  14032. return model;
  14033. default:
  14034. return undefined;
  14035. }
  14036. }
  14037. function errorsToXml(model) {
  14038. switch (model) {
  14039. case 'dash':
  14040. case 'blank':
  14041. case 'NA':
  14042. return model;
  14043. default:
  14044. return undefined;
  14045. }
  14046. }
  14047. function pageSizeToModel(value) {
  14048. return value !== undefined ? parseInt(value, 10) : undefined;
  14049. }
  14050. var PageSetupXform = /*#__PURE__*/function (_BaseXform) {
  14051. _inherits(PageSetupXform, _BaseXform);
  14052. var _super = _createSuper(PageSetupXform);
  14053. function PageSetupXform() {
  14054. _classCallCheck(this, PageSetupXform);
  14055. return _super.apply(this, arguments);
  14056. }
  14057. _createClass(PageSetupXform, [{
  14058. key: "render",
  14059. value: function render(xmlStream, model) {
  14060. if (model) {
  14061. var attributes = {
  14062. paperSize: model.paperSize,
  14063. orientation: model.orientation,
  14064. horizontalDpi: model.horizontalDpi,
  14065. verticalDpi: model.verticalDpi,
  14066. pageOrder: pageOrderToXml(model.pageOrder),
  14067. blackAndWhite: booleanToXml(model.blackAndWhite),
  14068. draft: booleanToXml(model.draft),
  14069. cellComments: cellCommentsToXml(model.cellComments),
  14070. errors: errorsToXml(model.errors),
  14071. scale: model.scale,
  14072. fitToWidth: model.fitToWidth,
  14073. fitToHeight: model.fitToHeight,
  14074. firstPageNumber: model.firstPageNumber,
  14075. useFirstPageNumber: booleanToXml(model.firstPageNumber),
  14076. usePrinterDefaults: booleanToXml(model.usePrinterDefaults),
  14077. copies: model.copies
  14078. };
  14079. if (_.some(attributes, function (value) {
  14080. return value !== undefined;
  14081. })) {
  14082. xmlStream.leafNode(this.tag, attributes);
  14083. }
  14084. }
  14085. }
  14086. }, {
  14087. key: "parseOpen",
  14088. value: function parseOpen(node) {
  14089. switch (node.name) {
  14090. case this.tag:
  14091. this.model = {
  14092. paperSize: pageSizeToModel(node.attributes.paperSize),
  14093. orientation: node.attributes.orientation || 'portrait',
  14094. horizontalDpi: parseInt(node.attributes.horizontalDpi || '4294967295', 10),
  14095. verticalDpi: parseInt(node.attributes.verticalDpi || '4294967295', 10),
  14096. pageOrder: node.attributes.pageOrder || 'downThenOver',
  14097. blackAndWhite: node.attributes.blackAndWhite === '1',
  14098. draft: node.attributes.draft === '1',
  14099. cellComments: node.attributes.cellComments || 'None',
  14100. errors: node.attributes.errors || 'displayed',
  14101. scale: parseInt(node.attributes.scale || '100', 10),
  14102. fitToWidth: parseInt(node.attributes.fitToWidth || '1', 10),
  14103. fitToHeight: parseInt(node.attributes.fitToHeight || '1', 10),
  14104. firstPageNumber: parseInt(node.attributes.firstPageNumber || '1', 10),
  14105. useFirstPageNumber: node.attributes.useFirstPageNumber === '1',
  14106. usePrinterDefaults: node.attributes.usePrinterDefaults === '1',
  14107. copies: parseInt(node.attributes.copies || '1', 10)
  14108. };
  14109. return true;
  14110. default:
  14111. return false;
  14112. }
  14113. }
  14114. }, {
  14115. key: "parseText",
  14116. value: function parseText() { }
  14117. }, {
  14118. key: "parseClose",
  14119. value: function parseClose() {
  14120. return false;
  14121. }
  14122. }, {
  14123. key: "tag",
  14124. get: function get() {
  14125. return 'pageSetup';
  14126. }
  14127. }]);
  14128. return PageSetupXform;
  14129. }(BaseXform);
  14130. module.exports = PageSetupXform;
  14131. }, { "../../../utils/under-dash": 25, "../base-xform": 31 }], 105: [function (require, module, exports) {
  14132. "use strict";
  14133. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14134. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14135. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14136. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14137. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14138. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14139. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14140. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14141. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14142. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  14143. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14144. var BaseXform = require('../base-xform');
  14145. var PictureXform = /*#__PURE__*/function (_BaseXform) {
  14146. _inherits(PictureXform, _BaseXform);
  14147. var _super = _createSuper(PictureXform);
  14148. function PictureXform() {
  14149. _classCallCheck(this, PictureXform);
  14150. return _super.apply(this, arguments);
  14151. }
  14152. _createClass(PictureXform, [{
  14153. key: "render",
  14154. value: function render(xmlStream, model) {
  14155. if (model) {
  14156. xmlStream.leafNode(this.tag, {
  14157. 'r:id': model.rId
  14158. });
  14159. }
  14160. }
  14161. }, {
  14162. key: "parseOpen",
  14163. value: function parseOpen(node) {
  14164. switch (node.name) {
  14165. case this.tag:
  14166. this.model = {
  14167. rId: node.attributes['r:id']
  14168. };
  14169. return true;
  14170. default:
  14171. return false;
  14172. }
  14173. }
  14174. }, {
  14175. key: "parseText",
  14176. value: function parseText() { }
  14177. }, {
  14178. key: "parseClose",
  14179. value: function parseClose() {
  14180. return false;
  14181. }
  14182. }, {
  14183. key: "tag",
  14184. get: function get() {
  14185. return 'picture';
  14186. }
  14187. }]);
  14188. return PictureXform;
  14189. }(BaseXform);
  14190. module.exports = PictureXform;
  14191. }, { "../base-xform": 31 }], 106: [function (require, module, exports) {
  14192. "use strict";
  14193. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14194. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14195. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14196. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14197. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14198. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14199. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14200. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14201. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14202. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  14203. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14204. var _ = require('../../../utils/under-dash');
  14205. var BaseXform = require('../base-xform');
  14206. function booleanToXml(model) {
  14207. return model ? '1' : undefined;
  14208. }
  14209. var PrintOptionsXform = /*#__PURE__*/function (_BaseXform) {
  14210. _inherits(PrintOptionsXform, _BaseXform);
  14211. var _super = _createSuper(PrintOptionsXform);
  14212. function PrintOptionsXform() {
  14213. _classCallCheck(this, PrintOptionsXform);
  14214. return _super.apply(this, arguments);
  14215. }
  14216. _createClass(PrintOptionsXform, [{
  14217. key: "render",
  14218. value: function render(xmlStream, model) {
  14219. if (model) {
  14220. var attributes = {
  14221. headings: booleanToXml(model.showRowColHeaders),
  14222. gridLines: booleanToXml(model.showGridLines),
  14223. horizontalCentered: booleanToXml(model.horizontalCentered),
  14224. verticalCentered: booleanToXml(model.verticalCentered)
  14225. };
  14226. if (_.some(attributes, function (value) {
  14227. return value !== undefined;
  14228. })) {
  14229. xmlStream.leafNode(this.tag, attributes);
  14230. }
  14231. }
  14232. }
  14233. }, {
  14234. key: "parseOpen",
  14235. value: function parseOpen(node) {
  14236. switch (node.name) {
  14237. case this.tag:
  14238. this.model = {
  14239. showRowColHeaders: node.attributes.headings === '1',
  14240. showGridLines: node.attributes.gridLines === '1',
  14241. horizontalCentered: node.attributes.horizontalCentered === '1',
  14242. verticalCentered: node.attributes.verticalCentered === '1'
  14243. };
  14244. return true;
  14245. default:
  14246. return false;
  14247. }
  14248. }
  14249. }, {
  14250. key: "parseText",
  14251. value: function parseText() { }
  14252. }, {
  14253. key: "parseClose",
  14254. value: function parseClose() {
  14255. return false;
  14256. }
  14257. }, {
  14258. key: "tag",
  14259. get: function get() {
  14260. return 'printOptions';
  14261. }
  14262. }]);
  14263. return PrintOptionsXform;
  14264. }(BaseXform);
  14265. module.exports = PrintOptionsXform;
  14266. }, { "../../../utils/under-dash": 25, "../base-xform": 31 }], 107: [function (require, module, exports) {
  14267. 'use strict';
  14268. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14269. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14270. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14271. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14272. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14273. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14274. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14275. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14276. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14277. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  14278. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14279. var PageBreaksXform = require('./page-breaks-xform');
  14280. var ListXform = require('../list-xform');
  14281. var RowBreaksXform = /*#__PURE__*/function (_ListXform) {
  14282. _inherits(RowBreaksXform, _ListXform);
  14283. var _super = _createSuper(RowBreaksXform);
  14284. function RowBreaksXform() {
  14285. _classCallCheck(this, RowBreaksXform);
  14286. var options = {
  14287. tag: 'rowBreaks',
  14288. count: true,
  14289. childXform: new PageBreaksXform()
  14290. };
  14291. return _super.call(this, options);
  14292. } // get tag() { return 'rowBreaks'; }
  14293. _createClass(RowBreaksXform, [{
  14294. key: "render",
  14295. value: function render(xmlStream, model) {
  14296. if (model && model.length) {
  14297. xmlStream.openNode(this.tag, this.$);
  14298. if (this.count) {
  14299. xmlStream.addAttribute(this.$count, model.length);
  14300. xmlStream.addAttribute('manualBreakCount', model.length);
  14301. }
  14302. var childXform = this.childXform;
  14303. model.forEach(function (childModel) {
  14304. childXform.render(xmlStream, childModel);
  14305. });
  14306. xmlStream.closeNode();
  14307. } else if (this.empty) {
  14308. xmlStream.leafNode(this.tag);
  14309. }
  14310. }
  14311. }]);
  14312. return RowBreaksXform;
  14313. }(ListXform);
  14314. module.exports = RowBreaksXform;
  14315. }, { "../list-xform": 70, "./page-breaks-xform": 101 }], 108: [function (require, module, exports) {
  14316. "use strict";
  14317. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14318. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14319. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14320. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14321. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14322. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14323. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14324. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14325. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14326. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  14327. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14328. var BaseXform = require('../base-xform');
  14329. var CellXform = require('./cell-xform');
  14330. var RowXform = /*#__PURE__*/function (_BaseXform) {
  14331. _inherits(RowXform, _BaseXform);
  14332. var _super = _createSuper(RowXform);
  14333. function RowXform(options) {
  14334. var _this;
  14335. _classCallCheck(this, RowXform);
  14336. _this = _super.call(this);
  14337. _this.maxItems = options && options.maxItems;
  14338. _this.map = {
  14339. c: new CellXform()
  14340. };
  14341. return _this;
  14342. }
  14343. _createClass(RowXform, [{
  14344. key: "prepare",
  14345. value: function prepare(model, options) {
  14346. var styleId = options.styles.addStyleModel(model.style);
  14347. if (styleId) {
  14348. model.styleId = styleId;
  14349. }
  14350. var cellXform = this.map.c;
  14351. model.cells.forEach(function (cellModel) {
  14352. cellXform.prepare(cellModel, options);
  14353. });
  14354. }
  14355. }, {
  14356. key: "render",
  14357. value: function render(xmlStream, model, options) {
  14358. xmlStream.openNode('row');
  14359. xmlStream.addAttribute('r', model.number);
  14360. if (model.height) {
  14361. xmlStream.addAttribute('ht', model.height);
  14362. xmlStream.addAttribute('customHeight', '1');
  14363. }
  14364. if (model.hidden) {
  14365. xmlStream.addAttribute('hidden', '1');
  14366. }
  14367. if (model.min > 0 && model.max > 0 && model.min <= model.max) {
  14368. xmlStream.addAttribute('spans', "".concat(model.min, ":").concat(model.max));
  14369. }
  14370. if (model.styleId) {
  14371. xmlStream.addAttribute('s', model.styleId);
  14372. xmlStream.addAttribute('customFormat', '1');
  14373. }
  14374. xmlStream.addAttribute('x14ac:dyDescent', '0.25');
  14375. if (model.outlineLevel) {
  14376. xmlStream.addAttribute('outlineLevel', model.outlineLevel);
  14377. }
  14378. if (model.collapsed) {
  14379. xmlStream.addAttribute('collapsed', '1');
  14380. }
  14381. var cellXform = this.map.c;
  14382. model.cells.forEach(function (cellModel) {
  14383. cellXform.render(xmlStream, cellModel, options);
  14384. });
  14385. xmlStream.closeNode();
  14386. }
  14387. }, {
  14388. key: "parseOpen",
  14389. value: function parseOpen(node) {
  14390. if (this.parser) {
  14391. this.parser.parseOpen(node);
  14392. return true;
  14393. }
  14394. if (node.name === 'row') {
  14395. this.numRowsSeen += 1;
  14396. var spans = node.attributes.spans ? node.attributes.spans.split(':').map(function (span) {
  14397. return parseInt(span, 10);
  14398. }) : [undefined, undefined];
  14399. var model = this.model = {
  14400. number: parseInt(node.attributes.r, 10),
  14401. min: spans[0],
  14402. max: spans[1],
  14403. cells: []
  14404. };
  14405. if (node.attributes.s) {
  14406. model.styleId = parseInt(node.attributes.s, 10);
  14407. }
  14408. if (node.attributes.hidden === true || node.attributes.hidden === 'true' || node.attributes.hidden === 1 || node.attributes.hidden === '1') {
  14409. model.hidden = true;
  14410. }
  14411. if (node.attributes.bestFit) {
  14412. model.bestFit = true;
  14413. }
  14414. if (node.attributes.ht) {
  14415. model.height = parseFloat(node.attributes.ht);
  14416. }
  14417. if (node.attributes.outlineLevel) {
  14418. model.outlineLevel = parseInt(node.attributes.outlineLevel, 10);
  14419. }
  14420. if (node.attributes.collapsed) {
  14421. model.collapsed = true;
  14422. }
  14423. return true;
  14424. }
  14425. this.parser = this.map[node.name];
  14426. if (this.parser) {
  14427. this.parser.parseOpen(node);
  14428. return true;
  14429. }
  14430. return false;
  14431. }
  14432. }, {
  14433. key: "parseText",
  14434. value: function parseText(text) {
  14435. if (this.parser) {
  14436. this.parser.parseText(text);
  14437. }
  14438. }
  14439. }, {
  14440. key: "parseClose",
  14441. value: function parseClose(name) {
  14442. if (this.parser) {
  14443. if (!this.parser.parseClose(name)) {
  14444. this.model.cells.push(this.parser.model);
  14445. if (this.maxItems && this.model.cells.length > this.maxItems) {
  14446. throw new Error("Max column count (".concat(this.maxItems, ") exceeded"));
  14447. }
  14448. this.parser = undefined;
  14449. }
  14450. return true;
  14451. }
  14452. return false;
  14453. }
  14454. }, {
  14455. key: "reconcile",
  14456. value: function reconcile(model, options) {
  14457. model.style = model.styleId ? options.styles.getStyleModel(model.styleId) : {};
  14458. if (model.styleId !== undefined) {
  14459. model.styleId = undefined;
  14460. }
  14461. var cellXform = this.map.c;
  14462. model.cells.forEach(function (cellModel) {
  14463. cellXform.reconcile(cellModel, options);
  14464. });
  14465. }
  14466. }, {
  14467. key: "tag",
  14468. get: function get() {
  14469. return 'row';
  14470. }
  14471. }]);
  14472. return RowXform;
  14473. }(BaseXform);
  14474. module.exports = RowXform;
  14475. }, { "../base-xform": 31, "./cell-xform": 72 }], 109: [function (require, module, exports) {
  14476. "use strict";
  14477. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14478. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14479. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14480. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14481. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14482. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14483. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14484. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14485. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14486. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  14487. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14488. var _ = require('../../../utils/under-dash');
  14489. var BaseXform = require('../base-xform');
  14490. var SheetFormatPropertiesXform = /*#__PURE__*/function (_BaseXform) {
  14491. _inherits(SheetFormatPropertiesXform, _BaseXform);
  14492. var _super = _createSuper(SheetFormatPropertiesXform);
  14493. function SheetFormatPropertiesXform() {
  14494. _classCallCheck(this, SheetFormatPropertiesXform);
  14495. return _super.apply(this, arguments);
  14496. }
  14497. _createClass(SheetFormatPropertiesXform, [{
  14498. key: "render",
  14499. value: function render(xmlStream, model) {
  14500. if (model) {
  14501. var attributes = {
  14502. defaultRowHeight: model.defaultRowHeight,
  14503. outlineLevelRow: model.outlineLevelRow,
  14504. outlineLevelCol: model.outlineLevelCol,
  14505. 'x14ac:dyDescent': model.dyDescent
  14506. };
  14507. if (model.defaultColWidth) {
  14508. attributes.defaultColWidth = model.defaultColWidth;
  14509. } // default value for 'defaultRowHeight' is 15, this should not be 'custom'
  14510. if (!model.defaultRowHeight || model.defaultRowHeight !== 15) {
  14511. attributes.customHeight = '1';
  14512. }
  14513. if (_.some(attributes, function (value) {
  14514. return value !== undefined;
  14515. })) {
  14516. xmlStream.leafNode('sheetFormatPr', attributes);
  14517. }
  14518. }
  14519. }
  14520. }, {
  14521. key: "parseOpen",
  14522. value: function parseOpen(node) {
  14523. if (node.name === 'sheetFormatPr') {
  14524. this.model = {
  14525. defaultRowHeight: parseFloat(node.attributes.defaultRowHeight || '0'),
  14526. dyDescent: parseFloat(node.attributes['x14ac:dyDescent'] || '0'),
  14527. outlineLevelRow: parseInt(node.attributes.outlineLevelRow || '0', 10),
  14528. outlineLevelCol: parseInt(node.attributes.outlineLevelCol || '0', 10)
  14529. };
  14530. if (node.attributes.defaultColWidth) {
  14531. this.model.defaultColWidth = parseFloat(node.attributes.defaultColWidth);
  14532. }
  14533. return true;
  14534. }
  14535. return false;
  14536. }
  14537. }, {
  14538. key: "parseText",
  14539. value: function parseText() { }
  14540. }, {
  14541. key: "parseClose",
  14542. value: function parseClose() {
  14543. return false;
  14544. }
  14545. }, {
  14546. key: "tag",
  14547. get: function get() {
  14548. return 'sheetFormatPr';
  14549. }
  14550. }]);
  14551. return SheetFormatPropertiesXform;
  14552. }(BaseXform);
  14553. module.exports = SheetFormatPropertiesXform;
  14554. }, { "../../../utils/under-dash": 25, "../base-xform": 31 }], 110: [function (require, module, exports) {
  14555. "use strict";
  14556. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14557. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14558. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14559. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14560. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14561. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14562. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14563. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14564. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14565. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  14566. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14567. var BaseXform = require('../base-xform');
  14568. var ColorXform = require('../style/color-xform');
  14569. var PageSetupPropertiesXform = require('./page-setup-properties-xform');
  14570. var OutlinePropertiesXform = require('./outline-properties-xform');
  14571. var SheetPropertiesXform = /*#__PURE__*/function (_BaseXform) {
  14572. _inherits(SheetPropertiesXform, _BaseXform);
  14573. var _super = _createSuper(SheetPropertiesXform);
  14574. function SheetPropertiesXform() {
  14575. var _this;
  14576. _classCallCheck(this, SheetPropertiesXform);
  14577. _this = _super.call(this);
  14578. _this.map = {
  14579. tabColor: new ColorXform('tabColor'),
  14580. pageSetUpPr: new PageSetupPropertiesXform(),
  14581. outlinePr: new OutlinePropertiesXform()
  14582. };
  14583. return _this;
  14584. }
  14585. _createClass(SheetPropertiesXform, [{
  14586. key: "render",
  14587. value: function render(xmlStream, model) {
  14588. if (model) {
  14589. xmlStream.addRollback();
  14590. xmlStream.openNode('sheetPr');
  14591. var inner = false;
  14592. inner = this.map.tabColor.render(xmlStream, model.tabColor) || inner;
  14593. inner = this.map.pageSetUpPr.render(xmlStream, model.pageSetup) || inner;
  14594. inner = this.map.outlinePr.render(xmlStream, model.outlineProperties) || inner;
  14595. if (inner) {
  14596. xmlStream.closeNode();
  14597. xmlStream.commit();
  14598. } else {
  14599. xmlStream.rollback();
  14600. }
  14601. }
  14602. }
  14603. }, {
  14604. key: "parseOpen",
  14605. value: function parseOpen(node) {
  14606. if (this.parser) {
  14607. this.parser.parseOpen(node);
  14608. return true;
  14609. }
  14610. if (node.name === this.tag) {
  14611. this.reset();
  14612. return true;
  14613. }
  14614. if (this.map[node.name]) {
  14615. this.parser = this.map[node.name];
  14616. this.parser.parseOpen(node);
  14617. return true;
  14618. }
  14619. return false;
  14620. }
  14621. }, {
  14622. key: "parseText",
  14623. value: function parseText(text) {
  14624. if (this.parser) {
  14625. this.parser.parseText(text);
  14626. return true;
  14627. }
  14628. return false;
  14629. }
  14630. }, {
  14631. key: "parseClose",
  14632. value: function parseClose(name) {
  14633. if (this.parser) {
  14634. if (!this.parser.parseClose(name)) {
  14635. this.parser = undefined;
  14636. }
  14637. return true;
  14638. }
  14639. if (this.map.tabColor.model || this.map.pageSetUpPr.model || this.map.outlinePr.model) {
  14640. this.model = {};
  14641. if (this.map.tabColor.model) {
  14642. this.model.tabColor = this.map.tabColor.model;
  14643. }
  14644. if (this.map.pageSetUpPr.model) {
  14645. this.model.pageSetup = this.map.pageSetUpPr.model;
  14646. }
  14647. if (this.map.outlinePr.model) {
  14648. this.model.outlineProperties = this.map.outlinePr.model;
  14649. }
  14650. } else {
  14651. this.model = null;
  14652. }
  14653. return false;
  14654. }
  14655. }, {
  14656. key: "tag",
  14657. get: function get() {
  14658. return 'sheetPr';
  14659. }
  14660. }]);
  14661. return SheetPropertiesXform;
  14662. }(BaseXform);
  14663. module.exports = SheetPropertiesXform;
  14664. }, { "../base-xform": 31, "../style/color-xform": 127, "./outline-properties-xform": 100, "./page-setup-properties-xform": 103 }], 111: [function (require, module, exports) {
  14665. "use strict";
  14666. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14667. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14668. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14669. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14670. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14671. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14672. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14673. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14674. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14675. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  14676. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14677. var _ = require('../../../utils/under-dash');
  14678. var BaseXform = require('../base-xform');
  14679. function booleanToXml(model, value) {
  14680. return model ? value : undefined;
  14681. }
  14682. function xmlToBoolean(value, equals) {
  14683. return value === equals ? true : undefined;
  14684. }
  14685. var SheetProtectionXform = /*#__PURE__*/function (_BaseXform) {
  14686. _inherits(SheetProtectionXform, _BaseXform);
  14687. var _super = _createSuper(SheetProtectionXform);
  14688. function SheetProtectionXform() {
  14689. _classCallCheck(this, SheetProtectionXform);
  14690. return _super.apply(this, arguments);
  14691. }
  14692. _createClass(SheetProtectionXform, [{
  14693. key: "render",
  14694. value: function render(xmlStream, model) {
  14695. if (model) {
  14696. var attributes = {
  14697. sheet: booleanToXml(model.sheet, '1'),
  14698. selectLockedCells: model.selectLockedCells === false ? '1' : undefined,
  14699. selectUnlockedCells: model.selectUnlockedCells === false ? '1' : undefined,
  14700. formatCells: booleanToXml(model.formatCells, '0'),
  14701. formatColumns: booleanToXml(model.formatColumns, '0'),
  14702. formatRows: booleanToXml(model.formatRows, '0'),
  14703. insertColumns: booleanToXml(model.insertColumns, '0'),
  14704. insertRows: booleanToXml(model.insertRows, '0'),
  14705. insertHyperlinks: booleanToXml(model.insertHyperlinks, '0'),
  14706. deleteColumns: booleanToXml(model.deleteColumns, '0'),
  14707. deleteRows: booleanToXml(model.deleteRows, '0'),
  14708. sort: booleanToXml(model.sort, '0'),
  14709. autoFilter: booleanToXml(model.autoFilter, '0'),
  14710. pivotTables: booleanToXml(model.pivotTables, '0')
  14711. };
  14712. if (model.sheet) {
  14713. attributes.algorithmName = model.algorithmName;
  14714. attributes.hashValue = model.hashValue;
  14715. attributes.saltValue = model.saltValue;
  14716. attributes.spinCount = model.spinCount;
  14717. attributes.objects = booleanToXml(model.objects === false, '1');
  14718. attributes.scenarios = booleanToXml(model.scenarios === false, '1');
  14719. }
  14720. if (_.some(attributes, function (value) {
  14721. return value !== undefined;
  14722. })) {
  14723. xmlStream.leafNode(this.tag, attributes);
  14724. }
  14725. }
  14726. }
  14727. }, {
  14728. key: "parseOpen",
  14729. value: function parseOpen(node) {
  14730. switch (node.name) {
  14731. case this.tag:
  14732. this.model = {
  14733. sheet: xmlToBoolean(node.attributes.sheet, '1'),
  14734. objects: node.attributes.objects === '1' ? false : undefined,
  14735. scenarios: node.attributes.scenarios === '1' ? false : undefined,
  14736. selectLockedCells: node.attributes.selectLockedCells === '1' ? false : undefined,
  14737. selectUnlockedCells: node.attributes.selectUnlockedCells === '1' ? false : undefined,
  14738. formatCells: xmlToBoolean(node.attributes.formatCells, '0'),
  14739. formatColumns: xmlToBoolean(node.attributes.formatColumns, '0'),
  14740. formatRows: xmlToBoolean(node.attributes.formatRows, '0'),
  14741. insertColumns: xmlToBoolean(node.attributes.insertColumns, '0'),
  14742. insertRows: xmlToBoolean(node.attributes.insertRows, '0'),
  14743. insertHyperlinks: xmlToBoolean(node.attributes.insertHyperlinks, '0'),
  14744. deleteColumns: xmlToBoolean(node.attributes.deleteColumns, '0'),
  14745. deleteRows: xmlToBoolean(node.attributes.deleteRows, '0'),
  14746. sort: xmlToBoolean(node.attributes.sort, '0'),
  14747. autoFilter: xmlToBoolean(node.attributes.autoFilter, '0'),
  14748. pivotTables: xmlToBoolean(node.attributes.pivotTables, '0')
  14749. };
  14750. if (node.attributes.algorithmName) {
  14751. this.model.algorithmName = node.attributes.algorithmName;
  14752. this.model.hashValue = node.attributes.hashValue;
  14753. this.model.saltValue = node.attributes.saltValue;
  14754. this.model.spinCount = parseInt(node.attributes.spinCount, 10);
  14755. }
  14756. return true;
  14757. default:
  14758. return false;
  14759. }
  14760. }
  14761. }, {
  14762. key: "parseText",
  14763. value: function parseText() { }
  14764. }, {
  14765. key: "parseClose",
  14766. value: function parseClose() {
  14767. return false;
  14768. }
  14769. }, {
  14770. key: "tag",
  14771. get: function get() {
  14772. return 'sheetProtection';
  14773. }
  14774. }]);
  14775. return SheetProtectionXform;
  14776. }(BaseXform);
  14777. module.exports = SheetProtectionXform;
  14778. }, { "../../../utils/under-dash": 25, "../base-xform": 31 }], 112: [function (require, module, exports) {
  14779. "use strict";
  14780. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14781. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14782. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14783. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14784. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14785. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14786. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14787. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14788. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14789. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  14790. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14791. var colCache = require('../../../utils/col-cache');
  14792. var BaseXform = require('../base-xform');
  14793. var VIEW_STATES = {
  14794. frozen: 'frozen',
  14795. frozenSplit: 'frozen',
  14796. split: 'split'
  14797. };
  14798. var SheetViewXform = /*#__PURE__*/function (_BaseXform) {
  14799. _inherits(SheetViewXform, _BaseXform);
  14800. var _super = _createSuper(SheetViewXform);
  14801. function SheetViewXform() {
  14802. _classCallCheck(this, SheetViewXform);
  14803. return _super.apply(this, arguments);
  14804. }
  14805. _createClass(SheetViewXform, [{
  14806. key: "prepare",
  14807. value: function prepare(model) {
  14808. switch (model.state) {
  14809. case 'frozen':
  14810. case 'split':
  14811. break;
  14812. default:
  14813. model.state = 'normal';
  14814. break;
  14815. }
  14816. }
  14817. }, {
  14818. key: "render",
  14819. value: function render(xmlStream, model) {
  14820. xmlStream.openNode('sheetView', {
  14821. workbookViewId: model.workbookViewId || 0
  14822. });
  14823. var add = function add(name, value, included) {
  14824. if (included) {
  14825. xmlStream.addAttribute(name, value);
  14826. }
  14827. };
  14828. add('rightToLeft', '1', model.rightToLeft === true);
  14829. add('tabSelected', '1', model.tabSelected);
  14830. add('showRuler', '0', model.showRuler === false);
  14831. add('showRowColHeaders', '0', model.showRowColHeaders === false);
  14832. add('showGridLines', '0', model.showGridLines === false);
  14833. add('zoomScale', model.zoomScale, model.zoomScale);
  14834. add('zoomScaleNormal', model.zoomScaleNormal, model.zoomScaleNormal);
  14835. add('view', model.style, model.style);
  14836. var topLeftCell;
  14837. var xSplit;
  14838. var ySplit;
  14839. var activePane;
  14840. switch (model.state) {
  14841. case 'frozen':
  14842. xSplit = model.xSplit || 0;
  14843. ySplit = model.ySplit || 0;
  14844. topLeftCell = model.topLeftCell || colCache.getAddress(ySplit + 1, xSplit + 1).address;
  14845. activePane = model.xSplit && model.ySplit && 'bottomRight' || model.xSplit && 'topRight' || 'bottomLeft';
  14846. xmlStream.leafNode('pane', {
  14847. xSplit: model.xSplit || undefined,
  14848. ySplit: model.ySplit || undefined,
  14849. topLeftCell: topLeftCell,
  14850. activePane: activePane,
  14851. state: 'frozen'
  14852. });
  14853. xmlStream.leafNode('selection', {
  14854. pane: activePane,
  14855. activeCell: model.activeCell,
  14856. sqref: model.activeCell
  14857. });
  14858. break;
  14859. case 'split':
  14860. if (model.activePane === 'topLeft') {
  14861. model.activePane = undefined;
  14862. }
  14863. xmlStream.leafNode('pane', {
  14864. xSplit: model.xSplit || undefined,
  14865. ySplit: model.ySplit || undefined,
  14866. topLeftCell: model.topLeftCell,
  14867. activePane: model.activePane
  14868. });
  14869. xmlStream.leafNode('selection', {
  14870. pane: model.activePane,
  14871. activeCell: model.activeCell,
  14872. sqref: model.activeCell
  14873. });
  14874. break;
  14875. case 'normal':
  14876. if (model.activeCell) {
  14877. xmlStream.leafNode('selection', {
  14878. activeCell: model.activeCell,
  14879. sqref: model.activeCell
  14880. });
  14881. }
  14882. break;
  14883. default:
  14884. break;
  14885. }
  14886. xmlStream.closeNode();
  14887. }
  14888. }, {
  14889. key: "parseOpen",
  14890. value: function parseOpen(node) {
  14891. switch (node.name) {
  14892. case 'sheetView':
  14893. this.sheetView = {
  14894. workbookViewId: parseInt(node.attributes.workbookViewId, 10),
  14895. rightToLeft: node.attributes.rightToLeft === '1',
  14896. tabSelected: node.attributes.tabSelected === '1',
  14897. showRuler: !(node.attributes.showRuler === '0'),
  14898. showRowColHeaders: !(node.attributes.showRowColHeaders === '0'),
  14899. showGridLines: !(node.attributes.showGridLines === '0'),
  14900. zoomScale: parseInt(node.attributes.zoomScale || '100', 10),
  14901. zoomScaleNormal: parseInt(node.attributes.zoomScaleNormal || '100', 10),
  14902. style: node.attributes.view
  14903. };
  14904. this.pane = undefined;
  14905. this.selections = {};
  14906. return true;
  14907. case 'pane':
  14908. this.pane = {
  14909. xSplit: parseInt(node.attributes.xSplit || '0', 10),
  14910. ySplit: parseInt(node.attributes.ySplit || '0', 10),
  14911. topLeftCell: node.attributes.topLeftCell,
  14912. activePane: node.attributes.activePane || 'topLeft',
  14913. state: node.attributes.state
  14914. };
  14915. return true;
  14916. case 'selection':
  14917. {
  14918. var name = node.attributes.pane || 'topLeft';
  14919. this.selections[name] = {
  14920. pane: name,
  14921. activeCell: node.attributes.activeCell
  14922. };
  14923. return true;
  14924. }
  14925. default:
  14926. return false;
  14927. }
  14928. }
  14929. }, {
  14930. key: "parseText",
  14931. value: function parseText() { }
  14932. }, {
  14933. key: "parseClose",
  14934. value: function parseClose(name) {
  14935. var model;
  14936. var selection;
  14937. switch (name) {
  14938. case 'sheetView':
  14939. if (this.sheetView && this.pane) {
  14940. model = this.model = {
  14941. workbookViewId: this.sheetView.workbookViewId,
  14942. rightToLeft: this.sheetView.rightToLeft,
  14943. state: VIEW_STATES[this.pane.state] || 'split',
  14944. // split is default
  14945. xSplit: this.pane.xSplit,
  14946. ySplit: this.pane.ySplit,
  14947. topLeftCell: this.pane.topLeftCell,
  14948. showRuler: this.sheetView.showRuler,
  14949. showRowColHeaders: this.sheetView.showRowColHeaders,
  14950. showGridLines: this.sheetView.showGridLines,
  14951. zoomScale: this.sheetView.zoomScale,
  14952. zoomScaleNormal: this.sheetView.zoomScaleNormal
  14953. };
  14954. if (this.model.state === 'split') {
  14955. model.activePane = this.pane.activePane;
  14956. }
  14957. selection = this.selections[this.pane.activePane];
  14958. if (selection && selection.activeCell) {
  14959. model.activeCell = selection.activeCell;
  14960. }
  14961. if (this.sheetView.style) {
  14962. model.style = this.sheetView.style;
  14963. }
  14964. } else {
  14965. model = this.model = {
  14966. workbookViewId: this.sheetView.workbookViewId,
  14967. rightToLeft: this.sheetView.rightToLeft,
  14968. state: 'normal',
  14969. showRuler: this.sheetView.showRuler,
  14970. showRowColHeaders: this.sheetView.showRowColHeaders,
  14971. showGridLines: this.sheetView.showGridLines,
  14972. zoomScale: this.sheetView.zoomScale,
  14973. zoomScaleNormal: this.sheetView.zoomScaleNormal
  14974. };
  14975. selection = this.selections.topLeft;
  14976. if (selection && selection.activeCell) {
  14977. model.activeCell = selection.activeCell;
  14978. }
  14979. if (this.sheetView.style) {
  14980. model.style = this.sheetView.style;
  14981. }
  14982. }
  14983. return false;
  14984. default:
  14985. return true;
  14986. }
  14987. }
  14988. }, {
  14989. key: "reconcile",
  14990. value: function reconcile() { }
  14991. }, {
  14992. key: "tag",
  14993. get: function get() {
  14994. return 'sheetView';
  14995. }
  14996. }]);
  14997. return SheetViewXform;
  14998. }(BaseXform);
  14999. module.exports = SheetViewXform;
  15000. }, { "../../../utils/col-cache": 19, "../base-xform": 31 }], 113: [function (require, module, exports) {
  15001. "use strict";
  15002. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15003. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15004. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15005. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15006. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15007. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15008. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  15009. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15010. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15011. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  15012. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15013. var BaseXform = require('../base-xform');
  15014. var TablePartXform = /*#__PURE__*/function (_BaseXform) {
  15015. _inherits(TablePartXform, _BaseXform);
  15016. var _super = _createSuper(TablePartXform);
  15017. function TablePartXform() {
  15018. _classCallCheck(this, TablePartXform);
  15019. return _super.apply(this, arguments);
  15020. }
  15021. _createClass(TablePartXform, [{
  15022. key: "render",
  15023. value: function render(xmlStream, model) {
  15024. if (model) {
  15025. xmlStream.leafNode(this.tag, {
  15026. 'r:id': model.rId
  15027. });
  15028. }
  15029. }
  15030. }, {
  15031. key: "parseOpen",
  15032. value: function parseOpen(node) {
  15033. switch (node.name) {
  15034. case this.tag:
  15035. this.model = {
  15036. rId: node.attributes['r:id']
  15037. };
  15038. return true;
  15039. default:
  15040. return false;
  15041. }
  15042. }
  15043. }, {
  15044. key: "parseText",
  15045. value: function parseText() { }
  15046. }, {
  15047. key: "parseClose",
  15048. value: function parseClose() {
  15049. return false;
  15050. }
  15051. }, {
  15052. key: "tag",
  15053. get: function get() {
  15054. return 'tablePart';
  15055. }
  15056. }]);
  15057. return TablePartXform;
  15058. }(BaseXform);
  15059. module.exports = TablePartXform;
  15060. }, { "../base-xform": 31 }], 114: [function (require, module, exports) {
  15061. "use strict";
  15062. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15063. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15064. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15065. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15066. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15067. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15068. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  15069. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15070. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15071. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  15072. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15073. var _ = require('../../../utils/under-dash');
  15074. var colCache = require('../../../utils/col-cache');
  15075. var XmlStream = require('../../../utils/xml-stream');
  15076. var RelType = require('../../rel-type');
  15077. var Merges = require('./merges');
  15078. var BaseXform = require('../base-xform');
  15079. var ListXform = require('../list-xform');
  15080. var RowXform = require('./row-xform');
  15081. var ColXform = require('./col-xform');
  15082. var DimensionXform = require('./dimension-xform');
  15083. var HyperlinkXform = require('./hyperlink-xform');
  15084. var MergeCellXform = require('./merge-cell-xform');
  15085. var DataValidationsXform = require('./data-validations-xform');
  15086. var SheetPropertiesXform = require('./sheet-properties-xform');
  15087. var SheetFormatPropertiesXform = require('./sheet-format-properties-xform');
  15088. var SheetViewXform = require('./sheet-view-xform');
  15089. var SheetProtectionXform = require('./sheet-protection-xform');
  15090. var PageMarginsXform = require('./page-margins-xform');
  15091. var PageSetupXform = require('./page-setup-xform');
  15092. var PrintOptionsXform = require('./print-options-xform');
  15093. var AutoFilterXform = require('./auto-filter-xform');
  15094. var PictureXform = require('./picture-xform');
  15095. var DrawingXform = require('./drawing-xform');
  15096. var TablePartXform = require('./table-part-xform');
  15097. var RowBreaksXform = require('./row-breaks-xform');
  15098. var HeaderFooterXform = require('./header-footer-xform');
  15099. var ConditionalFormattingsXform = require('./cf/conditional-formattings-xform');
  15100. var ExtListXform = require('./ext-lst-xform');
  15101. var mergeRule = function mergeRule(rule, extRule) {
  15102. Object.keys(extRule).forEach(function (key) {
  15103. var value = rule[key];
  15104. var extValue = extRule[key];
  15105. if (value === undefined && extValue !== undefined) {
  15106. rule[key] = extValue;
  15107. }
  15108. });
  15109. };
  15110. var mergeConditionalFormattings = function mergeConditionalFormattings(model, extModel) {
  15111. // conditional formattings are rendered in worksheet.conditionalFormatting and also in
  15112. // worksheet.extLst.ext.x14:conditionalFormattings
  15113. // some (e.g. dataBar) are even spread across both!
  15114. if (!extModel || !extModel.length) {
  15115. return model;
  15116. }
  15117. if (!model || !model.length) {
  15118. return extModel;
  15119. } // index model rules by x14Id
  15120. var cfMap = {};
  15121. var ruleMap = {};
  15122. model.forEach(function (cf) {
  15123. cfMap[cf.ref] = cf;
  15124. cf.rules.forEach(function (rule) {
  15125. var x14Id = rule.x14Id;
  15126. if (x14Id) {
  15127. ruleMap[x14Id] = rule;
  15128. }
  15129. });
  15130. });
  15131. extModel.forEach(function (extCf) {
  15132. extCf.rules.forEach(function (extRule) {
  15133. var rule = ruleMap[extRule.x14Id];
  15134. if (rule) {
  15135. // merge with matching rule
  15136. mergeRule(rule, extRule);
  15137. } else if (cfMap[extCf.ref]) {
  15138. // reuse existing cf ref
  15139. cfMap[extCf.ref].rules.push(extRule);
  15140. } else {
  15141. // create new cf
  15142. model.push({
  15143. ref: extCf.ref,
  15144. rules: [extRule]
  15145. });
  15146. }
  15147. });
  15148. }); // need to cope with rules in extModel that don't exist in model
  15149. return model;
  15150. };
  15151. var WorkSheetXform = /*#__PURE__*/function (_BaseXform) {
  15152. _inherits(WorkSheetXform, _BaseXform);
  15153. var _super = _createSuper(WorkSheetXform);
  15154. function WorkSheetXform(options) {
  15155. var _this;
  15156. _classCallCheck(this, WorkSheetXform);
  15157. _this = _super.call(this);
  15158. var _ref = options || {},
  15159. maxRows = _ref.maxRows,
  15160. maxCols = _ref.maxCols;
  15161. _this.map = {
  15162. sheetPr: new SheetPropertiesXform(),
  15163. dimension: new DimensionXform(),
  15164. sheetViews: new ListXform({
  15165. tag: 'sheetViews',
  15166. count: false,
  15167. childXform: new SheetViewXform()
  15168. }),
  15169. sheetFormatPr: new SheetFormatPropertiesXform(),
  15170. cols: new ListXform({
  15171. tag: 'cols',
  15172. count: false,
  15173. childXform: new ColXform()
  15174. }),
  15175. sheetData: new ListXform({
  15176. tag: 'sheetData',
  15177. count: false,
  15178. empty: true,
  15179. childXform: new RowXform({
  15180. maxItems: maxCols
  15181. }),
  15182. maxItems: maxRows
  15183. }),
  15184. autoFilter: new AutoFilterXform(),
  15185. mergeCells: new ListXform({
  15186. tag: 'mergeCells',
  15187. count: true,
  15188. childXform: new MergeCellXform()
  15189. }),
  15190. rowBreaks: new RowBreaksXform(),
  15191. hyperlinks: new ListXform({
  15192. tag: 'hyperlinks',
  15193. count: false,
  15194. childXform: new HyperlinkXform()
  15195. }),
  15196. pageMargins: new PageMarginsXform(),
  15197. dataValidations: new DataValidationsXform(),
  15198. pageSetup: new PageSetupXform(),
  15199. headerFooter: new HeaderFooterXform(),
  15200. printOptions: new PrintOptionsXform(),
  15201. picture: new PictureXform(),
  15202. drawing: new DrawingXform(),
  15203. sheetProtection: new SheetProtectionXform(),
  15204. tableParts: new ListXform({
  15205. tag: 'tableParts',
  15206. count: true,
  15207. childXform: new TablePartXform()
  15208. }),
  15209. conditionalFormatting: new ConditionalFormattingsXform(),
  15210. extLst: new ExtListXform()
  15211. };
  15212. return _this;
  15213. }
  15214. _createClass(WorkSheetXform, [{
  15215. key: "prepare",
  15216. value: function prepare(model, options) {
  15217. var _this2 = this;
  15218. options.merges = new Merges();
  15219. model.hyperlinks = options.hyperlinks = [];
  15220. model.comments = options.comments = [];
  15221. options.formulae = {};
  15222. options.siFormulae = 0;
  15223. this.map.cols.prepare(model.cols, options);
  15224. this.map.sheetData.prepare(model.rows, options);
  15225. this.map.conditionalFormatting.prepare(model.conditionalFormattings, options);
  15226. model.mergeCells = options.merges.mergeCells; // prepare relationships
  15227. var rels = model.rels = [];
  15228. function nextRid(r) {
  15229. return "rId".concat(r.length + 1);
  15230. }
  15231. model.hyperlinks.forEach(function (hyperlink) {
  15232. var rId = nextRid(rels);
  15233. hyperlink.rId = rId;
  15234. rels.push({
  15235. Id: rId,
  15236. Type: RelType.Hyperlink,
  15237. Target: hyperlink.target,
  15238. TargetMode: 'External'
  15239. });
  15240. }); // prepare comment relationships
  15241. if (model.comments.length > 0) {
  15242. var comment = {
  15243. Id: nextRid(rels),
  15244. Type: RelType.Comments,
  15245. Target: "../comments".concat(model.id, ".xml")
  15246. };
  15247. rels.push(comment);
  15248. var vmlDrawing = {
  15249. Id: nextRid(rels),
  15250. Type: RelType.VmlDrawing,
  15251. Target: "../drawings/vmlDrawing".concat(model.id, ".vml")
  15252. };
  15253. rels.push(vmlDrawing);
  15254. model.comments.forEach(function (item) {
  15255. item.refAddress = colCache.decodeAddress(item.ref);
  15256. });
  15257. options.commentRefs.push({
  15258. commentName: "comments".concat(model.id),
  15259. vmlDrawing: "vmlDrawing".concat(model.id)
  15260. });
  15261. }
  15262. var drawingRelsHash = [];
  15263. var bookImage;
  15264. model.media.forEach(function (medium) {
  15265. if (medium.type === 'background') {
  15266. var rId = nextRid(rels);
  15267. bookImage = options.media[medium.imageId];
  15268. rels.push({
  15269. Id: rId,
  15270. Type: RelType.Image,
  15271. Target: "../media/".concat(bookImage.name, ".").concat(bookImage.extension)
  15272. });
  15273. model.background = {
  15274. rId: rId
  15275. };
  15276. model.image = options.media[medium.imageId];
  15277. } else if (medium.type === 'image') {
  15278. var drawing = model.drawing;
  15279. bookImage = options.media[medium.imageId];
  15280. if (!drawing) {
  15281. drawing = model.drawing = {
  15282. rId: nextRid(rels),
  15283. name: "drawing".concat(++options.drawingsCount),
  15284. anchors: [],
  15285. rels: []
  15286. };
  15287. options.drawings.push(drawing);
  15288. rels.push({
  15289. Id: drawing.rId,
  15290. Type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing',
  15291. Target: "../drawings/".concat(drawing.name, ".xml")
  15292. });
  15293. }
  15294. var rIdImage = _this2.preImageId === medium.imageId ? drawingRelsHash[medium.imageId] : drawingRelsHash[drawing.rels.length];
  15295. if (!rIdImage) {
  15296. rIdImage = nextRid(drawing.rels);
  15297. drawingRelsHash[drawing.rels.length] = rIdImage;
  15298. drawing.rels.push({
  15299. Id: rIdImage,
  15300. Type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
  15301. Target: "../media/".concat(bookImage.name, ".").concat(bookImage.extension)
  15302. });
  15303. }
  15304. var anchor = {
  15305. picture: {
  15306. rId: rIdImage
  15307. },
  15308. range: medium.range
  15309. };
  15310. if (medium.hyperlinks && medium.hyperlinks.hyperlink) {
  15311. var rIdHyperLink = nextRid(drawing.rels);
  15312. drawingRelsHash[drawing.rels.length] = rIdHyperLink;
  15313. anchor.picture.hyperlinks = {
  15314. tooltip: medium.hyperlinks.tooltip,
  15315. rId: rIdHyperLink
  15316. };
  15317. drawing.rels.push({
  15318. Id: rIdHyperLink,
  15319. Type: RelType.Hyperlink,
  15320. Target: medium.hyperlinks.hyperlink,
  15321. TargetMode: 'External'
  15322. });
  15323. }
  15324. _this2.preImageId = medium.imageId;
  15325. drawing.anchors.push(anchor);
  15326. }
  15327. }); // prepare tables
  15328. model.tables.forEach(function (table) {
  15329. // relationships
  15330. var rId = nextRid(rels);
  15331. table.rId = rId;
  15332. rels.push({
  15333. Id: rId,
  15334. Type: RelType.Table,
  15335. Target: "../tables/".concat(table.target)
  15336. }); // dynamic styles
  15337. table.columns.forEach(function (column) {
  15338. var style = column.style;
  15339. if (style) {
  15340. column.dxfId = options.styles.addDxfStyle(style);
  15341. }
  15342. });
  15343. }); // prepare ext items
  15344. this.map.extLst.prepare(model, options);
  15345. }
  15346. }, {
  15347. key: "render",
  15348. value: function render(xmlStream, model) {
  15349. xmlStream.openXml(XmlStream.StdDocAttributes);
  15350. xmlStream.openNode('worksheet', WorkSheetXform.WORKSHEET_ATTRIBUTES);
  15351. var sheetFormatPropertiesModel = model.properties ? {
  15352. defaultRowHeight: model.properties.defaultRowHeight,
  15353. dyDescent: model.properties.dyDescent,
  15354. outlineLevelCol: model.properties.outlineLevelCol,
  15355. outlineLevelRow: model.properties.outlineLevelRow
  15356. } : undefined;
  15357. if (model.properties && model.properties.defaultColWidth) {
  15358. sheetFormatPropertiesModel.defaultColWidth = model.properties.defaultColWidth;
  15359. }
  15360. var sheetPropertiesModel = {
  15361. outlineProperties: model.properties && model.properties.outlineProperties,
  15362. tabColor: model.properties && model.properties.tabColor,
  15363. pageSetup: model.pageSetup && model.pageSetup.fitToPage ? {
  15364. fitToPage: model.pageSetup.fitToPage
  15365. } : undefined
  15366. };
  15367. var pageMarginsModel = model.pageSetup && model.pageSetup.margins;
  15368. var printOptionsModel = {
  15369. showRowColHeaders: model.pageSetup && model.pageSetup.showRowColHeaders,
  15370. showGridLines: model.pageSetup && model.pageSetup.showGridLines,
  15371. horizontalCentered: model.pageSetup && model.pageSetup.horizontalCentered,
  15372. verticalCentered: model.pageSetup && model.pageSetup.verticalCentered
  15373. };
  15374. var sheetProtectionModel = model.sheetProtection;
  15375. this.map.sheetPr.render(xmlStream, sheetPropertiesModel);
  15376. this.map.dimension.render(xmlStream, model.dimensions);
  15377. this.map.sheetViews.render(xmlStream, model.views);
  15378. this.map.sheetFormatPr.render(xmlStream, sheetFormatPropertiesModel);
  15379. this.map.cols.render(xmlStream, model.cols);
  15380. this.map.sheetData.render(xmlStream, model.rows);
  15381. this.map.sheetProtection.render(xmlStream, sheetProtectionModel); // Note: must be after sheetData and before autoFilter
  15382. this.map.autoFilter.render(xmlStream, model.autoFilter);
  15383. this.map.mergeCells.render(xmlStream, model.mergeCells);
  15384. this.map.conditionalFormatting.render(xmlStream, model.conditionalFormattings); // Note: must be before dataValidations
  15385. this.map.dataValidations.render(xmlStream, model.dataValidations); // For some reason hyperlinks have to be after the data validations
  15386. this.map.hyperlinks.render(xmlStream, model.hyperlinks);
  15387. this.map.printOptions.render(xmlStream, printOptionsModel); // Note: must be before pageMargins
  15388. this.map.pageMargins.render(xmlStream, pageMarginsModel);
  15389. this.map.pageSetup.render(xmlStream, model.pageSetup);
  15390. this.map.headerFooter.render(xmlStream, model.headerFooter);
  15391. this.map.rowBreaks.render(xmlStream, model.rowBreaks);
  15392. this.map.drawing.render(xmlStream, model.drawing); // Note: must be after rowBreaks
  15393. this.map.picture.render(xmlStream, model.background); // Note: must be after drawing
  15394. this.map.tableParts.render(xmlStream, model.tables);
  15395. this.map.extLst.render(xmlStream, model);
  15396. if (model.rels) {
  15397. // add a <legacyDrawing /> node for each comment
  15398. model.rels.forEach(function (rel) {
  15399. if (rel.Type === RelType.VmlDrawing) {
  15400. xmlStream.leafNode('legacyDrawing', {
  15401. 'r:id': rel.Id
  15402. });
  15403. }
  15404. });
  15405. }
  15406. xmlStream.closeNode();
  15407. }
  15408. }, {
  15409. key: "parseOpen",
  15410. value: function parseOpen(node) {
  15411. if (this.parser) {
  15412. this.parser.parseOpen(node);
  15413. return true;
  15414. }
  15415. if (node.name === 'worksheet') {
  15416. _.each(this.map, function (xform) {
  15417. xform.reset();
  15418. });
  15419. return true;
  15420. }
  15421. this.parser = this.map[node.name];
  15422. if (this.parser) {
  15423. this.parser.parseOpen(node);
  15424. }
  15425. return true;
  15426. }
  15427. }, {
  15428. key: "parseText",
  15429. value: function parseText(text) {
  15430. if (this.parser) {
  15431. this.parser.parseText(text);
  15432. }
  15433. }
  15434. }, {
  15435. key: "parseClose",
  15436. value: function parseClose(name) {
  15437. if (this.parser) {
  15438. if (!this.parser.parseClose(name)) {
  15439. this.parser = undefined;
  15440. }
  15441. return true;
  15442. }
  15443. switch (name) {
  15444. case 'worksheet':
  15445. {
  15446. var properties = this.map.sheetFormatPr.model || {};
  15447. if (this.map.sheetPr.model && this.map.sheetPr.model.tabColor) {
  15448. properties.tabColor = this.map.sheetPr.model.tabColor;
  15449. }
  15450. if (this.map.sheetPr.model && this.map.sheetPr.model.outlineProperties) {
  15451. properties.outlineProperties = this.map.sheetPr.model.outlineProperties;
  15452. }
  15453. var sheetProperties = {
  15454. fitToPage: this.map.sheetPr.model && this.map.sheetPr.model.pageSetup && this.map.sheetPr.model.pageSetup.fitToPage || false,
  15455. margins: this.map.pageMargins.model
  15456. };
  15457. var pageSetup = Object.assign(sheetProperties, this.map.pageSetup.model, this.map.printOptions.model);
  15458. var conditionalFormattings = mergeConditionalFormattings(this.map.conditionalFormatting.model, this.map.extLst.model && this.map.extLst.model['x14:conditionalFormattings']);
  15459. this.model = {
  15460. dimensions: this.map.dimension.model,
  15461. cols: this.map.cols.model,
  15462. rows: this.map.sheetData.model,
  15463. mergeCells: this.map.mergeCells.model,
  15464. hyperlinks: this.map.hyperlinks.model,
  15465. dataValidations: this.map.dataValidations.model,
  15466. properties: properties,
  15467. views: this.map.sheetViews.model,
  15468. pageSetup: pageSetup,
  15469. headerFooter: this.map.headerFooter.model,
  15470. background: this.map.picture.model,
  15471. drawing: this.map.drawing.model,
  15472. tables: this.map.tableParts.model,
  15473. conditionalFormattings: conditionalFormattings
  15474. };
  15475. if (this.map.autoFilter.model) {
  15476. this.model.autoFilter = this.map.autoFilter.model;
  15477. }
  15478. if (this.map.sheetProtection.model) {
  15479. this.model.sheetProtection = this.map.sheetProtection.model;
  15480. }
  15481. return false;
  15482. }
  15483. default:
  15484. // not quite sure how we get here!
  15485. return true;
  15486. }
  15487. }
  15488. }, {
  15489. key: "reconcile",
  15490. value: function reconcile(model, options) {
  15491. // options.merges = new Merges();
  15492. // options.merges.reconcile(model.mergeCells, model.rows);
  15493. var rels = (model.relationships || []).reduce(function (h, rel) {
  15494. h[rel.Id] = rel;
  15495. if (rel.Type === RelType.Comments) {
  15496. model.comments = options.comments[rel.Target].comments;
  15497. }
  15498. if (rel.Type === RelType.VmlDrawing && model.comments && model.comments.length) {
  15499. var vmlComment = options.vmlDrawings[rel.Target].comments;
  15500. model.comments.forEach(function (comment, index) {
  15501. comment.note = Object.assign({}, comment.note, vmlComment[index]);
  15502. });
  15503. }
  15504. return h;
  15505. }, {});
  15506. options.commentsMap = (model.comments || []).reduce(function (h, comment) {
  15507. if (comment.ref) {
  15508. h[comment.ref] = comment;
  15509. }
  15510. return h;
  15511. }, {});
  15512. options.hyperlinkMap = (model.hyperlinks || []).reduce(function (h, hyperlink) {
  15513. if (hyperlink.rId) {
  15514. h[hyperlink.address] = rels[hyperlink.rId].Target;
  15515. }
  15516. return h;
  15517. }, {});
  15518. options.formulae = {}; // compact the rows and cells
  15519. model.rows = model.rows && model.rows.filter(Boolean) || [];
  15520. model.rows.forEach(function (row) {
  15521. row.cells = row.cells && row.cells.filter(Boolean) || [];
  15522. });
  15523. this.map.cols.reconcile(model.cols, options);
  15524. this.map.sheetData.reconcile(model.rows, options);
  15525. this.map.conditionalFormatting.reconcile(model.conditionalFormattings, options);
  15526. model.media = [];
  15527. if (model.drawing) {
  15528. var drawingRel = rels[model.drawing.rId];
  15529. var match = drawingRel.Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);
  15530. if (match) {
  15531. var drawingName = match[1];
  15532. var drawing = options.drawings[drawingName];
  15533. drawing.anchors.forEach(function (anchor) {
  15534. if (anchor.medium) {
  15535. var image = {
  15536. type: 'image',
  15537. imageId: anchor.medium.index,
  15538. range: anchor.range,
  15539. hyperlinks: anchor.picture.hyperlinks
  15540. };
  15541. model.media.push(image);
  15542. }
  15543. });
  15544. }
  15545. }
  15546. var backgroundRel = model.background && rels[model.background.rId];
  15547. if (backgroundRel) {
  15548. var target = backgroundRel.Target.split('/media/')[1];
  15549. var imageId = options.mediaIndex && options.mediaIndex[target];
  15550. if (imageId !== undefined) {
  15551. model.media.push({
  15552. type: 'background',
  15553. imageId: imageId
  15554. });
  15555. }
  15556. }
  15557. model.tables = (model.tables || []).map(function (tablePart) {
  15558. var rel = rels[tablePart.rId];
  15559. return options.tables[rel.Target];
  15560. });
  15561. delete model.relationships;
  15562. delete model.hyperlinks;
  15563. delete model.comments;
  15564. }
  15565. }]);
  15566. return WorkSheetXform;
  15567. }(BaseXform);
  15568. WorkSheetXform.WORKSHEET_ATTRIBUTES = {
  15569. xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
  15570. 'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
  15571. 'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
  15572. 'mc:Ignorable': 'x14ac',
  15573. 'xmlns:x14ac': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'
  15574. };
  15575. module.exports = WorkSheetXform;
  15576. }, { "../../../utils/col-cache": 19, "../../../utils/under-dash": 25, "../../../utils/xml-stream": 27, "../../rel-type": 30, "../base-xform": 31, "../list-xform": 70, "./auto-filter-xform": 71, "./cf/conditional-formattings-xform": 86, "./col-xform": 91, "./data-validations-xform": 92, "./dimension-xform": 93, "./drawing-xform": 94, "./ext-lst-xform": 95, "./header-footer-xform": 96, "./hyperlink-xform": 97, "./merge-cell-xform": 98, "./merges": 99, "./page-margins-xform": 102, "./page-setup-xform": 104, "./picture-xform": 105, "./print-options-xform": 106, "./row-breaks-xform": 107, "./row-xform": 108, "./sheet-format-properties-xform": 109, "./sheet-properties-xform": 110, "./sheet-protection-xform": 111, "./sheet-view-xform": 112, "./table-part-xform": 113 }], 115: [function (require, module, exports) {
  15577. "use strict";
  15578. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15579. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15580. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15581. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15582. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15583. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15584. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  15585. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15586. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15587. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  15588. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15589. var BaseXform = require('../base-xform');
  15590. var BooleanXform = /*#__PURE__*/function (_BaseXform) {
  15591. _inherits(BooleanXform, _BaseXform);
  15592. var _super = _createSuper(BooleanXform);
  15593. function BooleanXform(options) {
  15594. var _this;
  15595. _classCallCheck(this, BooleanXform);
  15596. _this = _super.call(this);
  15597. _this.tag = options.tag;
  15598. _this.attr = options.attr;
  15599. return _this;
  15600. }
  15601. _createClass(BooleanXform, [{
  15602. key: "render",
  15603. value: function render(xmlStream, model) {
  15604. if (model) {
  15605. xmlStream.openNode(this.tag);
  15606. xmlStream.closeNode();
  15607. }
  15608. }
  15609. }, {
  15610. key: "parseOpen",
  15611. value: function parseOpen(node) {
  15612. if (node.name === this.tag) {
  15613. this.model = true;
  15614. }
  15615. }
  15616. }, {
  15617. key: "parseText",
  15618. value: function parseText() { }
  15619. }, {
  15620. key: "parseClose",
  15621. value: function parseClose() {
  15622. return false;
  15623. }
  15624. }]);
  15625. return BooleanXform;
  15626. }(BaseXform);
  15627. module.exports = BooleanXform;
  15628. }, { "../base-xform": 31 }], 116: [function (require, module, exports) {
  15629. "use strict";
  15630. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15631. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15632. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15633. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15634. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15635. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15636. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  15637. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15638. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15639. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  15640. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15641. var BaseXform = require('../base-xform');
  15642. var DateXform = /*#__PURE__*/function (_BaseXform) {
  15643. _inherits(DateXform, _BaseXform);
  15644. var _super = _createSuper(DateXform);
  15645. function DateXform(options) {
  15646. var _this;
  15647. _classCallCheck(this, DateXform);
  15648. _this = _super.call(this);
  15649. _this.tag = options.tag;
  15650. _this.attr = options.attr;
  15651. _this.attrs = options.attrs;
  15652. _this._format = options.format || function (dt) {
  15653. try {
  15654. if (Number.isNaN(dt.getTime())) return '';
  15655. return dt.toISOString();
  15656. } catch (e) {
  15657. return '';
  15658. }
  15659. };
  15660. _this._parse = options.parse || function (str) {
  15661. return new Date(str);
  15662. };
  15663. return _this;
  15664. }
  15665. _createClass(DateXform, [{
  15666. key: "render",
  15667. value: function render(xmlStream, model) {
  15668. if (model) {
  15669. xmlStream.openNode(this.tag);
  15670. if (this.attrs) {
  15671. xmlStream.addAttributes(this.attrs);
  15672. }
  15673. if (this.attr) {
  15674. xmlStream.addAttribute(this.attr, this._format(model));
  15675. } else {
  15676. xmlStream.writeText(this._format(model));
  15677. }
  15678. xmlStream.closeNode();
  15679. }
  15680. }
  15681. }, {
  15682. key: "parseOpen",
  15683. value: function parseOpen(node) {
  15684. if (node.name === this.tag) {
  15685. if (this.attr) {
  15686. this.model = this._parse(node.attributes[this.attr]);
  15687. } else {
  15688. this.text = [];
  15689. }
  15690. }
  15691. }
  15692. }, {
  15693. key: "parseText",
  15694. value: function parseText(text) {
  15695. if (!this.attr) {
  15696. this.text.push(text);
  15697. }
  15698. }
  15699. }, {
  15700. key: "parseClose",
  15701. value: function parseClose() {
  15702. if (!this.attr) {
  15703. this.model = this._parse(this.text.join(''));
  15704. }
  15705. return false;
  15706. }
  15707. }]);
  15708. return DateXform;
  15709. }(BaseXform);
  15710. module.exports = DateXform;
  15711. }, { "../base-xform": 31 }], 117: [function (require, module, exports) {
  15712. "use strict";
  15713. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15714. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15715. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15716. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15717. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15718. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15719. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  15720. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15721. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15722. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  15723. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15724. var BaseXform = require('../base-xform');
  15725. var IntegerXform = /*#__PURE__*/function (_BaseXform) {
  15726. _inherits(IntegerXform, _BaseXform);
  15727. var _super = _createSuper(IntegerXform);
  15728. function IntegerXform(options) {
  15729. var _this;
  15730. _classCallCheck(this, IntegerXform);
  15731. _this = _super.call(this);
  15732. _this.tag = options.tag;
  15733. _this.attr = options.attr;
  15734. _this.attrs = options.attrs; // option to render zero
  15735. _this.zero = options.zero;
  15736. return _this;
  15737. }
  15738. _createClass(IntegerXform, [{
  15739. key: "render",
  15740. value: function render(xmlStream, model) {
  15741. // int is different to float in that zero is not rendered
  15742. if (model || this.zero) {
  15743. xmlStream.openNode(this.tag);
  15744. if (this.attrs) {
  15745. xmlStream.addAttributes(this.attrs);
  15746. }
  15747. if (this.attr) {
  15748. xmlStream.addAttribute(this.attr, model);
  15749. } else {
  15750. xmlStream.writeText(model);
  15751. }
  15752. xmlStream.closeNode();
  15753. }
  15754. }
  15755. }, {
  15756. key: "parseOpen",
  15757. value: function parseOpen(node) {
  15758. if (node.name === this.tag) {
  15759. if (this.attr) {
  15760. this.model = parseInt(node.attributes[this.attr], 10);
  15761. } else {
  15762. this.text = [];
  15763. }
  15764. return true;
  15765. }
  15766. return false;
  15767. }
  15768. }, {
  15769. key: "parseText",
  15770. value: function parseText(text) {
  15771. if (!this.attr) {
  15772. this.text.push(text);
  15773. }
  15774. }
  15775. }, {
  15776. key: "parseClose",
  15777. value: function parseClose() {
  15778. if (!this.attr) {
  15779. this.model = parseInt(this.text.join('') || 0, 10);
  15780. }
  15781. return false;
  15782. }
  15783. }]);
  15784. return IntegerXform;
  15785. }(BaseXform);
  15786. module.exports = IntegerXform;
  15787. }, { "../base-xform": 31 }], 118: [function (require, module, exports) {
  15788. "use strict";
  15789. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15790. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15791. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15792. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15793. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15794. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15795. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  15796. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15797. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15798. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  15799. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15800. var BaseXform = require('../base-xform');
  15801. var StringXform = /*#__PURE__*/function (_BaseXform) {
  15802. _inherits(StringXform, _BaseXform);
  15803. var _super = _createSuper(StringXform);
  15804. function StringXform(options) {
  15805. var _this;
  15806. _classCallCheck(this, StringXform);
  15807. _this = _super.call(this);
  15808. _this.tag = options.tag;
  15809. _this.attr = options.attr;
  15810. _this.attrs = options.attrs;
  15811. return _this;
  15812. }
  15813. _createClass(StringXform, [{
  15814. key: "render",
  15815. value: function render(xmlStream, model) {
  15816. if (model !== undefined) {
  15817. xmlStream.openNode(this.tag);
  15818. if (this.attrs) {
  15819. xmlStream.addAttributes(this.attrs);
  15820. }
  15821. if (this.attr) {
  15822. xmlStream.addAttribute(this.attr, model);
  15823. } else {
  15824. xmlStream.writeText(model);
  15825. }
  15826. xmlStream.closeNode();
  15827. }
  15828. }
  15829. }, {
  15830. key: "parseOpen",
  15831. value: function parseOpen(node) {
  15832. if (node.name === this.tag) {
  15833. if (this.attr) {
  15834. this.model = node.attributes[this.attr];
  15835. } else {
  15836. this.text = [];
  15837. }
  15838. }
  15839. }
  15840. }, {
  15841. key: "parseText",
  15842. value: function parseText(text) {
  15843. if (!this.attr) {
  15844. this.text.push(text);
  15845. }
  15846. }
  15847. }, {
  15848. key: "parseClose",
  15849. value: function parseClose() {
  15850. if (!this.attr) {
  15851. this.model = this.text.join('');
  15852. }
  15853. return false;
  15854. }
  15855. }]);
  15856. return StringXform;
  15857. }(BaseXform);
  15858. module.exports = StringXform;
  15859. }, { "../base-xform": 31 }], 119: [function (require, module, exports) {
  15860. "use strict";
  15861. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15862. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15863. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15864. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15865. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15866. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15867. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  15868. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15869. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15870. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  15871. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15872. var BaseXform = require('./base-xform');
  15873. var XmlStream = require('../../utils/xml-stream'); // const model = {
  15874. // tag: 'name',
  15875. // $: {attr: 'value'},
  15876. // c: [
  15877. // { tag: 'child' }
  15878. // ],
  15879. // t: 'some text'
  15880. // };
  15881. function build(xmlStream, model) {
  15882. xmlStream.openNode(model.tag, model.$);
  15883. if (model.c) {
  15884. model.c.forEach(function (child) {
  15885. build(xmlStream, child);
  15886. });
  15887. }
  15888. if (model.t) {
  15889. xmlStream.writeText(model.t);
  15890. }
  15891. xmlStream.closeNode();
  15892. }
  15893. var StaticXform = /*#__PURE__*/function (_BaseXform) {
  15894. _inherits(StaticXform, _BaseXform);
  15895. var _super = _createSuper(StaticXform);
  15896. function StaticXform(model) {
  15897. var _this;
  15898. _classCallCheck(this, StaticXform);
  15899. _this = _super.call(this); // This class is an optimisation for static (unimportant and unchanging) xml
  15900. // It is stateless - apart from its static model and so can be used as a singleton
  15901. // Being stateless - it will only track entry to and exit from it's root xml tag during parsing and nothing else
  15902. // Known issues:
  15903. // since stateless - parseOpen always returns true. Parent xform must know when to start using this xform
  15904. // if the root tag is recursive, the parsing will behave unpredictably
  15905. _this._model = model;
  15906. return _this;
  15907. }
  15908. _createClass(StaticXform, [{
  15909. key: "render",
  15910. value: function render(xmlStream) {
  15911. if (!this._xml) {
  15912. var stream = new XmlStream();
  15913. build(stream, this._model);
  15914. this._xml = stream.xml;
  15915. }
  15916. xmlStream.writeXml(this._xml);
  15917. }
  15918. }, {
  15919. key: "parseOpen",
  15920. value: function parseOpen() {
  15921. return true;
  15922. }
  15923. }, {
  15924. key: "parseText",
  15925. value: function parseText() { }
  15926. }, {
  15927. key: "parseClose",
  15928. value: function parseClose(name) {
  15929. switch (name) {
  15930. case this._model.tag:
  15931. return false;
  15932. default:
  15933. return true;
  15934. }
  15935. }
  15936. }]);
  15937. return StaticXform;
  15938. }(BaseXform);
  15939. module.exports = StaticXform;
  15940. }, { "../../utils/xml-stream": 27, "./base-xform": 31 }], 120: [function (require, module, exports) {
  15941. "use strict";
  15942. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15943. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15944. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15945. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15946. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15947. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15948. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  15949. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15950. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15951. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  15952. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15953. var TextXform = require('./text-xform');
  15954. var RichTextXform = require('./rich-text-xform');
  15955. var BaseXform = require('../base-xform'); // <rPh sb="0" eb="1">
  15956. // <t>(its pronounciation in KATAKANA)</t>
  15957. // </rPh>
  15958. var PhoneticTextXform = /*#__PURE__*/function (_BaseXform) {
  15959. _inherits(PhoneticTextXform, _BaseXform);
  15960. var _super = _createSuper(PhoneticTextXform);
  15961. function PhoneticTextXform() {
  15962. var _this;
  15963. _classCallCheck(this, PhoneticTextXform);
  15964. _this = _super.call(this);
  15965. _this.map = {
  15966. r: new RichTextXform(),
  15967. t: new TextXform()
  15968. };
  15969. return _this;
  15970. }
  15971. _createClass(PhoneticTextXform, [{
  15972. key: "render",
  15973. value: function render(xmlStream, model) {
  15974. xmlStream.openNode(this.tag, {
  15975. sb: model.sb || 0,
  15976. eb: model.eb || 0
  15977. });
  15978. if (model && model.hasOwnProperty('richText') && model.richText) {
  15979. var r = this.map.r;
  15980. model.richText.forEach(function (text) {
  15981. r.render(xmlStream, text);
  15982. });
  15983. } else if (model) {
  15984. this.map.t.render(xmlStream, model.text);
  15985. }
  15986. xmlStream.closeNode();
  15987. }
  15988. }, {
  15989. key: "parseOpen",
  15990. value: function parseOpen(node) {
  15991. var name = node.name;
  15992. if (this.parser) {
  15993. this.parser.parseOpen(node);
  15994. return true;
  15995. }
  15996. if (name === this.tag) {
  15997. this.model = {
  15998. sb: parseInt(node.attributes.sb, 10),
  15999. eb: parseInt(node.attributes.eb, 10)
  16000. };
  16001. return true;
  16002. }
  16003. this.parser = this.map[name];
  16004. if (this.parser) {
  16005. this.parser.parseOpen(node);
  16006. return true;
  16007. }
  16008. return false;
  16009. }
  16010. }, {
  16011. key: "parseText",
  16012. value: function parseText(text) {
  16013. if (this.parser) {
  16014. this.parser.parseText(text);
  16015. }
  16016. }
  16017. }, {
  16018. key: "parseClose",
  16019. value: function parseClose(name) {
  16020. if (this.parser) {
  16021. if (!this.parser.parseClose(name)) {
  16022. switch (name) {
  16023. case 'r':
  16024. {
  16025. var rt = this.model.richText;
  16026. if (!rt) {
  16027. rt = this.model.richText = [];
  16028. }
  16029. rt.push(this.parser.model);
  16030. break;
  16031. }
  16032. case 't':
  16033. this.model.text = this.parser.model;
  16034. break;
  16035. default:
  16036. break;
  16037. }
  16038. this.parser = undefined;
  16039. }
  16040. return true;
  16041. }
  16042. switch (name) {
  16043. case this.tag:
  16044. return false;
  16045. default:
  16046. return true;
  16047. }
  16048. }
  16049. }, {
  16050. key: "tag",
  16051. get: function get() {
  16052. return 'rPh';
  16053. }
  16054. }]);
  16055. return PhoneticTextXform;
  16056. }(BaseXform);
  16057. module.exports = PhoneticTextXform;
  16058. }, { "../base-xform": 31, "./rich-text-xform": 121, "./text-xform": 124 }], 121: [function (require, module, exports) {
  16059. "use strict";
  16060. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16061. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16062. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16063. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16064. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16065. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16066. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16067. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16068. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16069. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  16070. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16071. var TextXform = require('./text-xform');
  16072. var FontXform = require('../style/font-xform');
  16073. var BaseXform = require('../base-xform'); // <r>
  16074. // <rPr>
  16075. // <sz val="11"/>
  16076. // <color theme="1" tint="5"/>
  16077. // <rFont val="Calibri"/>
  16078. // <family val="2"/>
  16079. // <scheme val="minor"/>
  16080. // </rPr>
  16081. // <t xml:space="preserve"> is </t>
  16082. // </r>
  16083. var RichTextXform = /*#__PURE__*/function (_BaseXform) {
  16084. _inherits(RichTextXform, _BaseXform);
  16085. var _super = _createSuper(RichTextXform);
  16086. function RichTextXform(model) {
  16087. var _this;
  16088. _classCallCheck(this, RichTextXform);
  16089. _this = _super.call(this);
  16090. _this.model = model;
  16091. return _this;
  16092. }
  16093. _createClass(RichTextXform, [{
  16094. key: "render",
  16095. value: function render(xmlStream, model) {
  16096. model = model || this.model;
  16097. xmlStream.openNode('r');
  16098. if (model.font) {
  16099. this.fontXform.render(xmlStream, model.font);
  16100. }
  16101. this.textXform.render(xmlStream, model.text);
  16102. xmlStream.closeNode();
  16103. }
  16104. }, {
  16105. key: "parseOpen",
  16106. value: function parseOpen(node) {
  16107. if (this.parser) {
  16108. this.parser.parseOpen(node);
  16109. return true;
  16110. }
  16111. switch (node.name) {
  16112. case 'r':
  16113. this.model = {};
  16114. return true;
  16115. case 't':
  16116. this.parser = this.textXform;
  16117. this.parser.parseOpen(node);
  16118. return true;
  16119. case 'rPr':
  16120. this.parser = this.fontXform;
  16121. this.parser.parseOpen(node);
  16122. return true;
  16123. default:
  16124. return false;
  16125. }
  16126. }
  16127. }, {
  16128. key: "parseText",
  16129. value: function parseText(text) {
  16130. if (this.parser) {
  16131. this.parser.parseText(text);
  16132. }
  16133. }
  16134. }, {
  16135. key: "parseClose",
  16136. value: function parseClose(name) {
  16137. switch (name) {
  16138. case 'r':
  16139. return false;
  16140. case 't':
  16141. this.model.text = this.parser.model;
  16142. this.parser = undefined;
  16143. return true;
  16144. case 'rPr':
  16145. this.model.font = this.parser.model;
  16146. this.parser = undefined;
  16147. return true;
  16148. default:
  16149. if (this.parser) {
  16150. this.parser.parseClose(name);
  16151. }
  16152. return true;
  16153. }
  16154. }
  16155. }, {
  16156. key: "tag",
  16157. get: function get() {
  16158. return 'r';
  16159. }
  16160. }, {
  16161. key: "textXform",
  16162. get: function get() {
  16163. return this._textXform || (this._textXform = new TextXform());
  16164. }
  16165. }, {
  16166. key: "fontXform",
  16167. get: function get() {
  16168. return this._fontXform || (this._fontXform = new FontXform(RichTextXform.FONT_OPTIONS));
  16169. }
  16170. }]);
  16171. return RichTextXform;
  16172. }(BaseXform);
  16173. RichTextXform.FONT_OPTIONS = {
  16174. tagName: 'rPr',
  16175. fontNameTag: 'rFont'
  16176. };
  16177. module.exports = RichTextXform;
  16178. }, { "../base-xform": 31, "../style/font-xform": 130, "./text-xform": 124 }], 122: [function (require, module, exports) {
  16179. "use strict";
  16180. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16181. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16182. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16183. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16184. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16185. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16186. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16187. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16188. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16189. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  16190. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16191. var TextXform = require('./text-xform');
  16192. var RichTextXform = require('./rich-text-xform');
  16193. var PhoneticTextXform = require('./phonetic-text-xform');
  16194. var BaseXform = require('../base-xform'); // <si>
  16195. // <r></r><r></r>...
  16196. // </si>
  16197. // <si>
  16198. // <t></t>
  16199. // </si>
  16200. var SharedStringXform = /*#__PURE__*/function (_BaseXform) {
  16201. _inherits(SharedStringXform, _BaseXform);
  16202. var _super = _createSuper(SharedStringXform);
  16203. function SharedStringXform(model) {
  16204. var _this;
  16205. _classCallCheck(this, SharedStringXform);
  16206. _this = _super.call(this);
  16207. _this.model = model;
  16208. _this.map = {
  16209. r: new RichTextXform(),
  16210. t: new TextXform(),
  16211. rPh: new PhoneticTextXform()
  16212. };
  16213. return _this;
  16214. }
  16215. _createClass(SharedStringXform, [{
  16216. key: "render",
  16217. value: function render(xmlStream, model) {
  16218. var _this2 = this;
  16219. xmlStream.openNode(this.tag);
  16220. if (model && model.hasOwnProperty('richText') && model.richText) {
  16221. if (model.richText.length) {
  16222. model.richText.forEach(function (text) {
  16223. _this2.map.r.render(xmlStream, text);
  16224. });
  16225. } else {
  16226. this.map.t.render(xmlStream, '');
  16227. }
  16228. } else if (model !== undefined && model !== null) {
  16229. this.map.t.render(xmlStream, model);
  16230. }
  16231. xmlStream.closeNode();
  16232. }
  16233. }, {
  16234. key: "parseOpen",
  16235. value: function parseOpen(node) {
  16236. var name = node.name;
  16237. if (this.parser) {
  16238. this.parser.parseOpen(node);
  16239. return true;
  16240. }
  16241. if (name === this.tag) {
  16242. this.model = {};
  16243. return true;
  16244. }
  16245. this.parser = this.map[name];
  16246. if (this.parser) {
  16247. this.parser.parseOpen(node);
  16248. return true;
  16249. }
  16250. return false;
  16251. }
  16252. }, {
  16253. key: "parseText",
  16254. value: function parseText(text) {
  16255. if (this.parser) {
  16256. this.parser.parseText(text);
  16257. }
  16258. }
  16259. }, {
  16260. key: "parseClose",
  16261. value: function parseClose(name) {
  16262. if (this.parser) {
  16263. if (!this.parser.parseClose(name)) {
  16264. switch (name) {
  16265. case 'r':
  16266. {
  16267. var rt = this.model.richText;
  16268. if (!rt) {
  16269. rt = this.model.richText = [];
  16270. }
  16271. rt.push(this.parser.model);
  16272. break;
  16273. }
  16274. case 't':
  16275. this.model = this.parser.model;
  16276. break;
  16277. default:
  16278. break;
  16279. }
  16280. this.parser = undefined;
  16281. }
  16282. return true;
  16283. }
  16284. switch (name) {
  16285. case this.tag:
  16286. return false;
  16287. default:
  16288. return true;
  16289. }
  16290. }
  16291. }, {
  16292. key: "tag",
  16293. get: function get() {
  16294. return 'si';
  16295. }
  16296. }]);
  16297. return SharedStringXform;
  16298. }(BaseXform);
  16299. module.exports = SharedStringXform;
  16300. }, { "../base-xform": 31, "./phonetic-text-xform": 120, "./rich-text-xform": 121, "./text-xform": 124 }], 123: [function (require, module, exports) {
  16301. "use strict";
  16302. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16303. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16304. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16305. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16306. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16307. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16308. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16309. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16310. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16311. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  16312. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16313. var XmlStream = require('../../../utils/xml-stream');
  16314. var BaseXform = require('../base-xform');
  16315. var SharedStringXform = require('./shared-string-xform');
  16316. var SharedStringsXform = /*#__PURE__*/function (_BaseXform) {
  16317. _inherits(SharedStringsXform, _BaseXform);
  16318. var _super = _createSuper(SharedStringsXform);
  16319. function SharedStringsXform(model) {
  16320. var _this;
  16321. _classCallCheck(this, SharedStringsXform);
  16322. _this = _super.call(this);
  16323. _this.model = model || {
  16324. values: [],
  16325. count: 0
  16326. };
  16327. _this.hash = Object.create(null);
  16328. _this.rich = Object.create(null);
  16329. return _this;
  16330. }
  16331. _createClass(SharedStringsXform, [{
  16332. key: "getString",
  16333. value: function getString(index) {
  16334. return this.model.values[index];
  16335. }
  16336. }, {
  16337. key: "add",
  16338. value: function add(value) {
  16339. return value.richText ? this.addRichText(value) : this.addText(value);
  16340. }
  16341. }, {
  16342. key: "addText",
  16343. value: function addText(value) {
  16344. var index = this.hash[value];
  16345. if (index === undefined) {
  16346. index = this.hash[value] = this.model.values.length;
  16347. this.model.values.push(value);
  16348. }
  16349. this.model.count++;
  16350. return index;
  16351. }
  16352. }, {
  16353. key: "addRichText",
  16354. value: function addRichText(value) {
  16355. // TODO: add WeakMap here
  16356. var xml = this.sharedStringXform.toXml(value);
  16357. var index = this.rich[xml];
  16358. if (index === undefined) {
  16359. index = this.rich[xml] = this.model.values.length;
  16360. this.model.values.push(value);
  16361. }
  16362. this.model.count++;
  16363. return index;
  16364. } // <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  16365. // <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="<%=totalRefs%>" uniqueCount="<%=count%>">
  16366. // <si><t><%=text%></t></si>
  16367. // <si><r><rPr></rPr><t></t></r></si>
  16368. // </sst>
  16369. }, {
  16370. key: "render",
  16371. value: function render(xmlStream, model) {
  16372. model = model || this._values;
  16373. xmlStream.openXml(XmlStream.StdDocAttributes);
  16374. xmlStream.openNode('sst', {
  16375. xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
  16376. count: model.count,
  16377. uniqueCount: model.values.length
  16378. });
  16379. var sx = this.sharedStringXform;
  16380. model.values.forEach(function (sharedString) {
  16381. sx.render(xmlStream, sharedString);
  16382. });
  16383. xmlStream.closeNode();
  16384. }
  16385. }, {
  16386. key: "parseOpen",
  16387. value: function parseOpen(node) {
  16388. if (this.parser) {
  16389. this.parser.parseOpen(node);
  16390. return true;
  16391. }
  16392. switch (node.name) {
  16393. case 'sst':
  16394. return true;
  16395. case 'si':
  16396. this.parser = this.sharedStringXform;
  16397. this.parser.parseOpen(node);
  16398. return true;
  16399. default:
  16400. throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(node)));
  16401. }
  16402. }
  16403. }, {
  16404. key: "parseText",
  16405. value: function parseText(text) {
  16406. if (this.parser) {
  16407. this.parser.parseText(text);
  16408. }
  16409. }
  16410. }, {
  16411. key: "parseClose",
  16412. value: function parseClose(name) {
  16413. if (this.parser) {
  16414. if (!this.parser.parseClose(name)) {
  16415. this.model.values.push(this.parser.model);
  16416. this.model.count++;
  16417. this.parser = undefined;
  16418. }
  16419. return true;
  16420. }
  16421. switch (name) {
  16422. case 'sst':
  16423. return false;
  16424. default:
  16425. throw new Error("Unexpected xml node in parseClose: ".concat(name));
  16426. }
  16427. }
  16428. }, {
  16429. key: "sharedStringXform",
  16430. get: function get() {
  16431. return this._sharedStringXform || (this._sharedStringXform = new SharedStringXform());
  16432. }
  16433. }, {
  16434. key: "values",
  16435. get: function get() {
  16436. return this.model.values;
  16437. }
  16438. }, {
  16439. key: "uniqueCount",
  16440. get: function get() {
  16441. return this.model.values.length;
  16442. }
  16443. }, {
  16444. key: "count",
  16445. get: function get() {
  16446. return this.model.count;
  16447. }
  16448. }]);
  16449. return SharedStringsXform;
  16450. }(BaseXform);
  16451. module.exports = SharedStringsXform;
  16452. }, { "../../../utils/xml-stream": 27, "../base-xform": 31, "./shared-string-xform": 122 }], 124: [function (require, module, exports) {
  16453. "use strict";
  16454. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16455. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16456. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16457. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16458. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16459. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16460. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16461. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16462. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16463. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  16464. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16465. var BaseXform = require('../base-xform'); // <t xml:space="preserve"> is </t>
  16466. var TextXform = /*#__PURE__*/function (_BaseXform) {
  16467. _inherits(TextXform, _BaseXform);
  16468. var _super = _createSuper(TextXform);
  16469. function TextXform() {
  16470. _classCallCheck(this, TextXform);
  16471. return _super.apply(this, arguments);
  16472. }
  16473. _createClass(TextXform, [{
  16474. key: "render",
  16475. value: function render(xmlStream, model) {
  16476. xmlStream.openNode('t');
  16477. if (/^\s|\n|\s$/.test(model)) {
  16478. xmlStream.addAttribute('xml:space', 'preserve');
  16479. }
  16480. xmlStream.writeText(model);
  16481. xmlStream.closeNode();
  16482. }
  16483. }, {
  16484. key: "parseOpen",
  16485. value: function parseOpen(node) {
  16486. switch (node.name) {
  16487. case 't':
  16488. this._text = [];
  16489. return true;
  16490. default:
  16491. return false;
  16492. }
  16493. }
  16494. }, {
  16495. key: "parseText",
  16496. value: function parseText(text) {
  16497. this._text.push(text);
  16498. }
  16499. }, {
  16500. key: "parseClose",
  16501. value: function parseClose() {
  16502. return false;
  16503. }
  16504. }, {
  16505. key: "tag",
  16506. get: function get() {
  16507. return 't';
  16508. }
  16509. }, {
  16510. key: "model",
  16511. get: function get() {
  16512. return this._text.join('').replace(/_x([0-9A-F]{4})_/g, function ($0, $1) {
  16513. return String.fromCharCode(parseInt($1, 16));
  16514. });
  16515. }
  16516. }]);
  16517. return TextXform;
  16518. }(BaseXform);
  16519. module.exports = TextXform;
  16520. }, { "../base-xform": 31 }], 125: [function (require, module, exports) {
  16521. "use strict";
  16522. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16523. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16524. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16525. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16526. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16527. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16528. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16529. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16530. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16531. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  16532. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16533. var Enums = require('../../../doc/enums');
  16534. var utils = require('../../../utils/utils');
  16535. var BaseXform = require('../base-xform');
  16536. var validation = {
  16537. horizontalValues: ['left', 'center', 'right', 'fill', 'centerContinuous', 'distributed', 'justify'].reduce(function (p, v) {
  16538. p[v] = true;
  16539. return p;
  16540. }, {}),
  16541. horizontal: function horizontal(value) {
  16542. return this.horizontalValues[value] ? value : undefined;
  16543. },
  16544. verticalValues: ['top', 'middle', 'bottom', 'distributed', 'justify'].reduce(function (p, v) {
  16545. p[v] = true;
  16546. return p;
  16547. }, {}),
  16548. vertical: function vertical(value) {
  16549. if (value === 'middle') return 'center';
  16550. return this.verticalValues[value] ? value : undefined;
  16551. },
  16552. wrapText: function wrapText(value) {
  16553. return value ? true : undefined;
  16554. },
  16555. shrinkToFit: function shrinkToFit(value) {
  16556. return value ? true : undefined;
  16557. },
  16558. textRotation: function textRotation(value) {
  16559. switch (value) {
  16560. case 'vertical':
  16561. return value;
  16562. default:
  16563. value = utils.validInt(value);
  16564. return value >= -90 && value <= 90 ? value : undefined;
  16565. }
  16566. },
  16567. indent: function indent(value) {
  16568. value = utils.validInt(value);
  16569. return Math.max(0, value);
  16570. },
  16571. readingOrder: function readingOrder(value) {
  16572. switch (value) {
  16573. case 'ltr':
  16574. return Enums.ReadingOrder.LeftToRight;
  16575. case 'rtl':
  16576. return Enums.ReadingOrder.RightToLeft;
  16577. default:
  16578. return undefined;
  16579. }
  16580. }
  16581. };
  16582. var textRotationXform = {
  16583. toXml: function toXml(textRotation) {
  16584. textRotation = validation.textRotation(textRotation);
  16585. if (textRotation) {
  16586. if (textRotation === 'vertical') {
  16587. return 255;
  16588. }
  16589. var tr = Math.round(textRotation);
  16590. if (tr >= 0 && tr <= 90) {
  16591. return tr;
  16592. }
  16593. if (tr < 0 && tr >= -90) {
  16594. return 90 - tr;
  16595. }
  16596. }
  16597. return undefined;
  16598. },
  16599. toModel: function toModel(textRotation) {
  16600. var tr = utils.validInt(textRotation);
  16601. if (tr !== undefined) {
  16602. if (tr === 255) {
  16603. return 'vertical';
  16604. }
  16605. if (tr >= 0 && tr <= 90) {
  16606. return tr;
  16607. }
  16608. if (tr > 90 && tr <= 180) {
  16609. return 90 - tr;
  16610. }
  16611. }
  16612. return undefined;
  16613. }
  16614. }; // Alignment encapsulates translation from style.alignment model to/from xlsx
  16615. var AlignmentXform = /*#__PURE__*/function (_BaseXform) {
  16616. _inherits(AlignmentXform, _BaseXform);
  16617. var _super = _createSuper(AlignmentXform);
  16618. function AlignmentXform() {
  16619. _classCallCheck(this, AlignmentXform);
  16620. return _super.apply(this, arguments);
  16621. }
  16622. _createClass(AlignmentXform, [{
  16623. key: "render",
  16624. value: function render(xmlStream, model) {
  16625. xmlStream.addRollback();
  16626. xmlStream.openNode('alignment');
  16627. var isValid = false;
  16628. function add(name, value) {
  16629. if (value) {
  16630. xmlStream.addAttribute(name, value);
  16631. isValid = true;
  16632. }
  16633. }
  16634. add('horizontal', validation.horizontal(model.horizontal));
  16635. add('vertical', validation.vertical(model.vertical));
  16636. add('wrapText', validation.wrapText(model.wrapText) ? '1' : false);
  16637. add('shrinkToFit', validation.shrinkToFit(model.shrinkToFit) ? '1' : false);
  16638. add('indent', validation.indent(model.indent));
  16639. add('textRotation', textRotationXform.toXml(model.textRotation));
  16640. add('readingOrder', validation.readingOrder(model.readingOrder));
  16641. xmlStream.closeNode();
  16642. if (isValid) {
  16643. xmlStream.commit();
  16644. } else {
  16645. xmlStream.rollback();
  16646. }
  16647. }
  16648. }, {
  16649. key: "parseOpen",
  16650. value: function parseOpen(node) {
  16651. var model = {};
  16652. var valid = false;
  16653. function add(truthy, name, value) {
  16654. if (truthy) {
  16655. model[name] = value;
  16656. valid = true;
  16657. }
  16658. }
  16659. add(node.attributes.horizontal, 'horizontal', node.attributes.horizontal);
  16660. add(node.attributes.vertical, 'vertical', node.attributes.vertical === 'center' ? 'middle' : node.attributes.vertical);
  16661. add(node.attributes.wrapText, 'wrapText', !!node.attributes.wrapText);
  16662. add(node.attributes.shrinkToFit, 'shrinkToFit', !!node.attributes.shrinkToFit);
  16663. add(node.attributes.indent, 'indent', parseInt(node.attributes.indent, 10));
  16664. add(node.attributes.textRotation, 'textRotation', textRotationXform.toModel(node.attributes.textRotation));
  16665. add(node.attributes.readingOrder, 'readingOrder', node.attributes.readingOrder === '2' ? 'rtl' : 'ltr');
  16666. this.model = valid ? model : null;
  16667. }
  16668. }, {
  16669. key: "parseText",
  16670. value: function parseText() { }
  16671. }, {
  16672. key: "parseClose",
  16673. value: function parseClose() {
  16674. return false;
  16675. }
  16676. }, {
  16677. key: "tag",
  16678. get: function get() {
  16679. return 'alignment';
  16680. }
  16681. }]);
  16682. return AlignmentXform;
  16683. }(BaseXform);
  16684. module.exports = AlignmentXform;
  16685. }, { "../../../doc/enums": 7, "../../../utils/utils": 26, "../base-xform": 31 }], 126: [function (require, module, exports) {
  16686. "use strict";
  16687. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  16688. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  16689. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  16690. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16691. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16692. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16693. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16694. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16695. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16696. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16697. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16698. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16699. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  16700. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16701. /* eslint-disable max-classes-per-file */
  16702. var BaseXform = require('../base-xform');
  16703. var ColorXform = require('./color-xform');
  16704. var EdgeXform = /*#__PURE__*/function (_BaseXform) {
  16705. _inherits(EdgeXform, _BaseXform);
  16706. var _super = _createSuper(EdgeXform);
  16707. function EdgeXform(name) {
  16708. var _this;
  16709. _classCallCheck(this, EdgeXform);
  16710. _this = _super.call(this);
  16711. _this.name = name;
  16712. _this.map = {
  16713. color: new ColorXform()
  16714. };
  16715. return _this;
  16716. }
  16717. _createClass(EdgeXform, [{
  16718. key: "render",
  16719. value: function render(xmlStream, model, defaultColor) {
  16720. var color = model && model.color || defaultColor || this.defaultColor;
  16721. xmlStream.openNode(this.name);
  16722. if (model && model.style) {
  16723. xmlStream.addAttribute('style', model.style);
  16724. if (color) {
  16725. this.map.color.render(xmlStream, color);
  16726. }
  16727. }
  16728. xmlStream.closeNode();
  16729. }
  16730. }, {
  16731. key: "parseOpen",
  16732. value: function parseOpen(node) {
  16733. if (this.parser) {
  16734. this.parser.parseOpen(node);
  16735. return true;
  16736. }
  16737. switch (node.name) {
  16738. case this.name:
  16739. {
  16740. var style = node.attributes.style;
  16741. if (style) {
  16742. this.model = {
  16743. style: style
  16744. };
  16745. } else {
  16746. this.model = undefined;
  16747. }
  16748. return true;
  16749. }
  16750. case 'color':
  16751. this.parser = this.map.color;
  16752. this.parser.parseOpen(node);
  16753. return true;
  16754. default:
  16755. return false;
  16756. }
  16757. }
  16758. }, {
  16759. key: "parseText",
  16760. value: function parseText(text) {
  16761. if (this.parser) {
  16762. this.parser.parseText(text);
  16763. }
  16764. }
  16765. }, {
  16766. key: "parseClose",
  16767. value: function parseClose(name) {
  16768. if (this.parser) {
  16769. if (!this.parser.parseClose(name)) {
  16770. this.parser = undefined;
  16771. }
  16772. return true;
  16773. }
  16774. if (name === this.name) {
  16775. if (this.map.color.model) {
  16776. if (!this.model) {
  16777. this.model = {};
  16778. }
  16779. this.model.color = this.map.color.model;
  16780. }
  16781. }
  16782. return false;
  16783. }
  16784. }, {
  16785. key: "validStyle",
  16786. value: function validStyle(value) {
  16787. return EdgeXform.validStyleValues[value];
  16788. }
  16789. }, {
  16790. key: "tag",
  16791. get: function get() {
  16792. return this.name;
  16793. }
  16794. }]);
  16795. return EdgeXform;
  16796. }(BaseXform);
  16797. EdgeXform.validStyleValues = ['thin', 'dotted', 'dashDot', 'hair', 'dashDotDot', 'slantDashDot', 'mediumDashed', 'mediumDashDotDot', 'mediumDashDot', 'medium', 'double', 'thick'].reduce(function (p, v) {
  16798. p[v] = true;
  16799. return p;
  16800. }, {}); // Border encapsulates translation from border model to/from xlsx
  16801. var BorderXform = /*#__PURE__*/function (_BaseXform2) {
  16802. _inherits(BorderXform, _BaseXform2);
  16803. var _super2 = _createSuper(BorderXform);
  16804. function BorderXform() {
  16805. var _this2;
  16806. _classCallCheck(this, BorderXform);
  16807. _this2 = _super2.call(this);
  16808. _this2.map = {
  16809. top: new EdgeXform('top'),
  16810. left: new EdgeXform('left'),
  16811. bottom: new EdgeXform('bottom'),
  16812. right: new EdgeXform('right'),
  16813. diagonal: new EdgeXform('diagonal')
  16814. };
  16815. return _this2;
  16816. }
  16817. _createClass(BorderXform, [{
  16818. key: "render",
  16819. value: function render(xmlStream, model) {
  16820. var color = model.color;
  16821. xmlStream.openNode('border');
  16822. if (model.diagonal && model.diagonal.style) {
  16823. if (model.diagonal.up) {
  16824. xmlStream.addAttribute('diagonalUp', '1');
  16825. }
  16826. if (model.diagonal.down) {
  16827. xmlStream.addAttribute('diagonalDown', '1');
  16828. }
  16829. }
  16830. function add(edgeModel, edgeXform) {
  16831. if (edgeModel && !edgeModel.color && model.color) {
  16832. // don't mess with incoming models
  16833. edgeModel = _objectSpread(_objectSpread({}, edgeModel), {}, {
  16834. color: model.color
  16835. });
  16836. }
  16837. edgeXform.render(xmlStream, edgeModel, color);
  16838. }
  16839. add(model.left, this.map.left);
  16840. add(model.right, this.map.right);
  16841. add(model.top, this.map.top);
  16842. add(model.bottom, this.map.bottom);
  16843. add(model.diagonal, this.map.diagonal);
  16844. xmlStream.closeNode();
  16845. }
  16846. }, {
  16847. key: "parseOpen",
  16848. value: function parseOpen(node) {
  16849. if (this.parser) {
  16850. this.parser.parseOpen(node);
  16851. return true;
  16852. }
  16853. switch (node.name) {
  16854. case 'border':
  16855. this.reset();
  16856. this.diagonalUp = !!node.attributes.diagonalUp;
  16857. this.diagonalDown = !!node.attributes.diagonalDown;
  16858. return true;
  16859. default:
  16860. this.parser = this.map[node.name];
  16861. if (this.parser) {
  16862. this.parser.parseOpen(node);
  16863. return true;
  16864. }
  16865. return false;
  16866. }
  16867. }
  16868. }, {
  16869. key: "parseText",
  16870. value: function parseText(text) {
  16871. if (this.parser) {
  16872. this.parser.parseText(text);
  16873. }
  16874. }
  16875. }, {
  16876. key: "parseClose",
  16877. value: function parseClose(name) {
  16878. if (this.parser) {
  16879. if (!this.parser.parseClose(name)) {
  16880. this.parser = undefined;
  16881. }
  16882. return true;
  16883. }
  16884. if (name === 'border') {
  16885. var model = this.model = {};
  16886. var add = function add(key, edgeModel, extensions) {
  16887. if (edgeModel) {
  16888. if (extensions) {
  16889. Object.assign(edgeModel, extensions);
  16890. }
  16891. model[key] = edgeModel;
  16892. }
  16893. };
  16894. add('left', this.map.left.model);
  16895. add('right', this.map.right.model);
  16896. add('top', this.map.top.model);
  16897. add('bottom', this.map.bottom.model);
  16898. add('diagonal', this.map.diagonal.model, {
  16899. up: this.diagonalUp,
  16900. down: this.diagonalDown
  16901. });
  16902. }
  16903. return false;
  16904. }
  16905. }]);
  16906. return BorderXform;
  16907. }(BaseXform);
  16908. module.exports = BorderXform;
  16909. }, { "../base-xform": 31, "./color-xform": 127 }], 127: [function (require, module, exports) {
  16910. "use strict";
  16911. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16912. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16913. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16914. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16915. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16916. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16917. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16918. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16919. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16920. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  16921. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16922. var BaseXform = require('../base-xform'); // Color encapsulates translation from color model to/from xlsx
  16923. var ColorXform = /*#__PURE__*/function (_BaseXform) {
  16924. _inherits(ColorXform, _BaseXform);
  16925. var _super = _createSuper(ColorXform);
  16926. function ColorXform(name) {
  16927. var _this;
  16928. _classCallCheck(this, ColorXform);
  16929. _this = _super.call(this); // this.name controls the xm node name
  16930. _this.name = name || 'color';
  16931. return _this;
  16932. }
  16933. _createClass(ColorXform, [{
  16934. key: "render",
  16935. value: function render(xmlStream, model) {
  16936. if (model) {
  16937. xmlStream.openNode(this.name);
  16938. if (model.argb) {
  16939. xmlStream.addAttribute('rgb', model.argb);
  16940. } else if (model.theme !== undefined) {
  16941. xmlStream.addAttribute('theme', model.theme);
  16942. if (model.tint !== undefined) {
  16943. xmlStream.addAttribute('tint', model.tint);
  16944. }
  16945. } else if (model.indexed !== undefined) {
  16946. xmlStream.addAttribute('indexed', model.indexed);
  16947. } else {
  16948. xmlStream.addAttribute('auto', '1');
  16949. }
  16950. xmlStream.closeNode();
  16951. return true;
  16952. }
  16953. return false;
  16954. }
  16955. }, {
  16956. key: "parseOpen",
  16957. value: function parseOpen(node) {
  16958. if (node.name === this.name) {
  16959. if (node.attributes.rgb) {
  16960. this.model = {
  16961. argb: node.attributes.rgb
  16962. };
  16963. } else if (node.attributes.theme) {
  16964. this.model = {
  16965. theme: parseInt(node.attributes.theme, 10)
  16966. };
  16967. if (node.attributes.tint) {
  16968. this.model.tint = parseFloat(node.attributes.tint);
  16969. }
  16970. } else if (node.attributes.indexed) {
  16971. this.model = {
  16972. indexed: parseInt(node.attributes.indexed, 10)
  16973. };
  16974. } else {
  16975. this.model = undefined;
  16976. }
  16977. return true;
  16978. }
  16979. return false;
  16980. }
  16981. }, {
  16982. key: "parseText",
  16983. value: function parseText() { }
  16984. }, {
  16985. key: "parseClose",
  16986. value: function parseClose() {
  16987. return false;
  16988. }
  16989. }, {
  16990. key: "tag",
  16991. get: function get() {
  16992. return this.name;
  16993. }
  16994. }]);
  16995. return ColorXform;
  16996. }(BaseXform);
  16997. module.exports = ColorXform;
  16998. }, { "../base-xform": 31 }], 128: [function (require, module, exports) {
  16999. "use strict";
  17000. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  17001. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17002. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  17003. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17004. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  17005. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17006. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  17007. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17008. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17009. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  17010. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17011. var BaseXform = require('../base-xform');
  17012. var AlignmentXform = require('./alignment-xform');
  17013. var BorderXform = require('./border-xform');
  17014. var FillXform = require('./fill-xform');
  17015. var FontXform = require('./font-xform');
  17016. var NumFmtXform = require('./numfmt-xform');
  17017. var ProtectionXform = require('./protection-xform'); // <xf numFmtId="[numFmtId]" fontId="[fontId]" fillId="[fillId]" borderId="[xf.borderId]" xfId="[xfId]">
  17018. // Optional <alignment>
  17019. // Optional <protection>
  17020. // </xf>
  17021. // Style assists translation from style model to/from xlsx
  17022. var DxfXform = /*#__PURE__*/function (_BaseXform) {
  17023. _inherits(DxfXform, _BaseXform);
  17024. var _super = _createSuper(DxfXform);
  17025. function DxfXform() {
  17026. var _this;
  17027. _classCallCheck(this, DxfXform);
  17028. _this = _super.call(this);
  17029. _this.map = {
  17030. alignment: new AlignmentXform(),
  17031. border: new BorderXform(),
  17032. fill: new FillXform(),
  17033. font: new FontXform(),
  17034. numFmt: new NumFmtXform(),
  17035. protection: new ProtectionXform()
  17036. };
  17037. return _this;
  17038. }
  17039. _createClass(DxfXform, [{
  17040. key: "render",
  17041. // how do we generate dxfid?
  17042. value: function render(xmlStream, model) {
  17043. xmlStream.openNode(this.tag);
  17044. if (model.alignment) {
  17045. this.map.alignment.render(xmlStream, model.alignment);
  17046. }
  17047. if (model.border) {
  17048. this.map.border.render(xmlStream, model.border);
  17049. }
  17050. if (model.fill) {
  17051. this.map.fill.render(xmlStream, model.fill);
  17052. }
  17053. if (model.font) {
  17054. this.map.font.render(xmlStream, model.font);
  17055. }
  17056. if (model.numFmt) {
  17057. this.map.numFmt.render(xmlStream, model.numFmt);
  17058. }
  17059. if (model.protection) {
  17060. this.map.protection.render(xmlStream, model.protection);
  17061. }
  17062. xmlStream.closeNode();
  17063. }
  17064. }, {
  17065. key: "parseOpen",
  17066. value: function parseOpen(node) {
  17067. if (this.parser) {
  17068. this.parser.parseOpen(node);
  17069. return true;
  17070. }
  17071. switch (node.name) {
  17072. case this.tag:
  17073. // this node is often repeated. Need to reset children
  17074. this.reset();
  17075. return true;
  17076. default:
  17077. this.parser = this.map[node.name];
  17078. if (this.parser) {
  17079. this.parser.parseOpen(node);
  17080. }
  17081. return true;
  17082. }
  17083. }
  17084. }, {
  17085. key: "parseText",
  17086. value: function parseText(text) {
  17087. if (this.parser) {
  17088. this.parser.parseText(text);
  17089. }
  17090. }
  17091. }, {
  17092. key: "parseClose",
  17093. value: function parseClose(name) {
  17094. if (this.parser) {
  17095. if (!this.parser.parseClose(name)) {
  17096. this.parser = undefined;
  17097. }
  17098. return true;
  17099. }
  17100. if (name === this.tag) {
  17101. this.model = {
  17102. alignment: this.map.alignment.model,
  17103. border: this.map.border.model,
  17104. fill: this.map.fill.model,
  17105. font: this.map.font.model,
  17106. numFmt: this.map.numFmt.model,
  17107. protection: this.map.protection.model
  17108. };
  17109. return false;
  17110. }
  17111. return true;
  17112. }
  17113. }, {
  17114. key: "tag",
  17115. get: function get() {
  17116. return 'dxf';
  17117. }
  17118. }]);
  17119. return DxfXform;
  17120. }(BaseXform);
  17121. module.exports = DxfXform;
  17122. }, { "../base-xform": 31, "./alignment-xform": 125, "./border-xform": 126, "./fill-xform": 129, "./font-xform": 130, "./numfmt-xform": 131, "./protection-xform": 132 }], 129: [function (require, module, exports) {
  17123. "use strict";
  17124. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  17125. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17126. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  17127. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17128. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  17129. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17130. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  17131. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17132. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17133. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  17134. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17135. /* eslint-disable max-classes-per-file */
  17136. var BaseXform = require('../base-xform');
  17137. var ColorXform = require('./color-xform');
  17138. var StopXform = /*#__PURE__*/function (_BaseXform) {
  17139. _inherits(StopXform, _BaseXform);
  17140. var _super = _createSuper(StopXform);
  17141. function StopXform() {
  17142. var _this;
  17143. _classCallCheck(this, StopXform);
  17144. _this = _super.call(this);
  17145. _this.map = {
  17146. color: new ColorXform()
  17147. };
  17148. return _this;
  17149. }
  17150. _createClass(StopXform, [{
  17151. key: "render",
  17152. value: function render(xmlStream, model) {
  17153. xmlStream.openNode('stop');
  17154. xmlStream.addAttribute('position', model.position);
  17155. this.map.color.render(xmlStream, model.color);
  17156. xmlStream.closeNode();
  17157. }
  17158. }, {
  17159. key: "parseOpen",
  17160. value: function parseOpen(node) {
  17161. if (this.parser) {
  17162. this.parser.parseOpen(node);
  17163. return true;
  17164. }
  17165. switch (node.name) {
  17166. case 'stop':
  17167. this.model = {
  17168. position: parseFloat(node.attributes.position)
  17169. };
  17170. return true;
  17171. case 'color':
  17172. this.parser = this.map.color;
  17173. this.parser.parseOpen(node);
  17174. return true;
  17175. default:
  17176. return false;
  17177. }
  17178. }
  17179. }, {
  17180. key: "parseText",
  17181. value: function parseText() { }
  17182. }, {
  17183. key: "parseClose",
  17184. value: function parseClose(name) {
  17185. if (this.parser) {
  17186. if (!this.parser.parseClose(name)) {
  17187. this.model.color = this.parser.model;
  17188. this.parser = undefined;
  17189. }
  17190. return true;
  17191. }
  17192. return false;
  17193. }
  17194. }, {
  17195. key: "tag",
  17196. get: function get() {
  17197. return 'stop';
  17198. }
  17199. }]);
  17200. return StopXform;
  17201. }(BaseXform);
  17202. var PatternFillXform = /*#__PURE__*/function (_BaseXform2) {
  17203. _inherits(PatternFillXform, _BaseXform2);
  17204. var _super2 = _createSuper(PatternFillXform);
  17205. function PatternFillXform() {
  17206. var _this2;
  17207. _classCallCheck(this, PatternFillXform);
  17208. _this2 = _super2.call(this);
  17209. _this2.map = {
  17210. fgColor: new ColorXform('fgColor'),
  17211. bgColor: new ColorXform('bgColor')
  17212. };
  17213. return _this2;
  17214. }
  17215. _createClass(PatternFillXform, [{
  17216. key: "render",
  17217. value: function render(xmlStream, model) {
  17218. xmlStream.openNode('patternFill');
  17219. xmlStream.addAttribute('patternType', model.pattern);
  17220. if (model.fgColor) {
  17221. this.map.fgColor.render(xmlStream, model.fgColor);
  17222. }
  17223. if (model.bgColor) {
  17224. this.map.bgColor.render(xmlStream, model.bgColor);
  17225. }
  17226. xmlStream.closeNode();
  17227. }
  17228. }, {
  17229. key: "parseOpen",
  17230. value: function parseOpen(node) {
  17231. if (this.parser) {
  17232. this.parser.parseOpen(node);
  17233. return true;
  17234. }
  17235. switch (node.name) {
  17236. case 'patternFill':
  17237. this.model = {
  17238. type: 'pattern',
  17239. pattern: node.attributes.patternType
  17240. };
  17241. return true;
  17242. default:
  17243. this.parser = this.map[node.name];
  17244. if (this.parser) {
  17245. this.parser.parseOpen(node);
  17246. return true;
  17247. }
  17248. return false;
  17249. }
  17250. }
  17251. }, {
  17252. key: "parseText",
  17253. value: function parseText(text) {
  17254. if (this.parser) {
  17255. this.parser.parseText(text);
  17256. }
  17257. }
  17258. }, {
  17259. key: "parseClose",
  17260. value: function parseClose(name) {
  17261. if (this.parser) {
  17262. if (!this.parser.parseClose(name)) {
  17263. if (this.parser.model) {
  17264. this.model[name] = this.parser.model;
  17265. }
  17266. this.parser = undefined;
  17267. }
  17268. return true;
  17269. }
  17270. return false;
  17271. }
  17272. }, {
  17273. key: "name",
  17274. get: function get() {
  17275. return 'pattern';
  17276. }
  17277. }, {
  17278. key: "tag",
  17279. get: function get() {
  17280. return 'patternFill';
  17281. }
  17282. }]);
  17283. return PatternFillXform;
  17284. }(BaseXform);
  17285. var GradientFillXform = /*#__PURE__*/function (_BaseXform3) {
  17286. _inherits(GradientFillXform, _BaseXform3);
  17287. var _super3 = _createSuper(GradientFillXform);
  17288. function GradientFillXform() {
  17289. var _this3;
  17290. _classCallCheck(this, GradientFillXform);
  17291. _this3 = _super3.call(this);
  17292. _this3.map = {
  17293. stop: new StopXform()
  17294. }; // if (model) {
  17295. // this.gradient = model.gradient;
  17296. // if (model.center) {
  17297. // this.center = model.center;
  17298. // }
  17299. // if (model.degree !== undefined) {
  17300. // this.degree = model.degree;
  17301. // }
  17302. // this.stops = model.stops.map(function(stop) { return new StopXform(stop); });
  17303. // } else {
  17304. // this.stops = [];
  17305. // }
  17306. return _this3;
  17307. }
  17308. _createClass(GradientFillXform, [{
  17309. key: "render",
  17310. value: function render(xmlStream, model) {
  17311. xmlStream.openNode('gradientFill');
  17312. switch (model.gradient) {
  17313. case 'angle':
  17314. xmlStream.addAttribute('degree', model.degree);
  17315. break;
  17316. case 'path':
  17317. xmlStream.addAttribute('type', 'path');
  17318. if (model.center.left) {
  17319. xmlStream.addAttribute('left', model.center.left);
  17320. if (model.center.right === undefined) {
  17321. xmlStream.addAttribute('right', model.center.left);
  17322. }
  17323. }
  17324. if (model.center.right) {
  17325. xmlStream.addAttribute('right', model.center.right);
  17326. }
  17327. if (model.center.top) {
  17328. xmlStream.addAttribute('top', model.center.top);
  17329. if (model.center.bottom === undefined) {
  17330. xmlStream.addAttribute('bottom', model.center.top);
  17331. }
  17332. }
  17333. if (model.center.bottom) {
  17334. xmlStream.addAttribute('bottom', model.center.bottom);
  17335. }
  17336. break;
  17337. default:
  17338. break;
  17339. }
  17340. var stopXform = this.map.stop;
  17341. model.stops.forEach(function (stopModel) {
  17342. stopXform.render(xmlStream, stopModel);
  17343. });
  17344. xmlStream.closeNode();
  17345. }
  17346. }, {
  17347. key: "parseOpen",
  17348. value: function parseOpen(node) {
  17349. if (this.parser) {
  17350. this.parser.parseOpen(node);
  17351. return true;
  17352. }
  17353. switch (node.name) {
  17354. case 'gradientFill':
  17355. {
  17356. var model = this.model = {
  17357. stops: []
  17358. };
  17359. if (node.attributes.degree) {
  17360. model.gradient = 'angle';
  17361. model.degree = parseInt(node.attributes.degree, 10);
  17362. } else if (node.attributes.type === 'path') {
  17363. model.gradient = 'path';
  17364. model.center = {
  17365. left: node.attributes.left ? parseFloat(node.attributes.left) : 0,
  17366. top: node.attributes.top ? parseFloat(node.attributes.top) : 0
  17367. };
  17368. if (node.attributes.right !== node.attributes.left) {
  17369. model.center.right = node.attributes.right ? parseFloat(node.attributes.right) : 0;
  17370. }
  17371. if (node.attributes.bottom !== node.attributes.top) {
  17372. model.center.bottom = node.attributes.bottom ? parseFloat(node.attributes.bottom) : 0;
  17373. }
  17374. }
  17375. return true;
  17376. }
  17377. case 'stop':
  17378. this.parser = this.map.stop;
  17379. this.parser.parseOpen(node);
  17380. return true;
  17381. default:
  17382. return false;
  17383. }
  17384. }
  17385. }, {
  17386. key: "parseText",
  17387. value: function parseText(text) {
  17388. if (this.parser) {
  17389. this.parser.parseText(text);
  17390. }
  17391. }
  17392. }, {
  17393. key: "parseClose",
  17394. value: function parseClose(name) {
  17395. if (this.parser) {
  17396. if (!this.parser.parseClose(name)) {
  17397. this.model.stops.push(this.parser.model);
  17398. this.parser = undefined;
  17399. }
  17400. return true;
  17401. }
  17402. return false;
  17403. }
  17404. }, {
  17405. key: "name",
  17406. get: function get() {
  17407. return 'gradient';
  17408. }
  17409. }, {
  17410. key: "tag",
  17411. get: function get() {
  17412. return 'gradientFill';
  17413. }
  17414. }]);
  17415. return GradientFillXform;
  17416. }(BaseXform); // Fill encapsulates translation from fill model to/from xlsx
  17417. var FillXform = /*#__PURE__*/function (_BaseXform4) {
  17418. _inherits(FillXform, _BaseXform4);
  17419. var _super4 = _createSuper(FillXform);
  17420. function FillXform() {
  17421. var _this4;
  17422. _classCallCheck(this, FillXform);
  17423. _this4 = _super4.call(this);
  17424. _this4.map = {
  17425. patternFill: new PatternFillXform(),
  17426. gradientFill: new GradientFillXform()
  17427. };
  17428. return _this4;
  17429. }
  17430. _createClass(FillXform, [{
  17431. key: "render",
  17432. value: function render(xmlStream, model) {
  17433. xmlStream.addRollback();
  17434. xmlStream.openNode('fill');
  17435. switch (model.type) {
  17436. case 'pattern':
  17437. this.map.patternFill.render(xmlStream, model);
  17438. break;
  17439. case 'gradient':
  17440. this.map.gradientFill.render(xmlStream, model);
  17441. break;
  17442. default:
  17443. xmlStream.rollback();
  17444. return;
  17445. }
  17446. xmlStream.closeNode();
  17447. xmlStream.commit();
  17448. }
  17449. }, {
  17450. key: "parseOpen",
  17451. value: function parseOpen(node) {
  17452. if (this.parser) {
  17453. this.parser.parseOpen(node);
  17454. return true;
  17455. }
  17456. switch (node.name) {
  17457. case 'fill':
  17458. this.model = {};
  17459. return true;
  17460. default:
  17461. this.parser = this.map[node.name];
  17462. if (this.parser) {
  17463. this.parser.parseOpen(node);
  17464. return true;
  17465. }
  17466. return false;
  17467. }
  17468. }
  17469. }, {
  17470. key: "parseText",
  17471. value: function parseText(text) {
  17472. if (this.parser) {
  17473. this.parser.parseText(text);
  17474. }
  17475. }
  17476. }, {
  17477. key: "parseClose",
  17478. value: function parseClose(name) {
  17479. if (this.parser) {
  17480. if (!this.parser.parseClose(name)) {
  17481. this.model = this.parser.model;
  17482. this.model.type = this.parser.name;
  17483. this.parser = undefined;
  17484. }
  17485. return true;
  17486. }
  17487. return false;
  17488. }
  17489. }, {
  17490. key: "validStyle",
  17491. value: function validStyle(value) {
  17492. return FillXform.validPatternValues[value];
  17493. }
  17494. }, {
  17495. key: "tag",
  17496. get: function get() {
  17497. return 'fill';
  17498. }
  17499. }]);
  17500. return FillXform;
  17501. }(BaseXform);
  17502. FillXform.validPatternValues = ['none', 'solid', 'darkVertical', 'darkGray', 'mediumGray', 'lightGray', 'gray125', 'gray0625', 'darkHorizontal', 'darkVertical', 'darkDown', 'darkUp', 'darkGrid', 'darkTrellis', 'lightHorizontal', 'lightVertical', 'lightDown', 'lightUp', 'lightGrid', 'lightTrellis', 'lightGrid'].reduce(function (p, v) {
  17503. p[v] = true;
  17504. return p;
  17505. }, {});
  17506. FillXform.StopXform = StopXform;
  17507. FillXform.PatternFillXform = PatternFillXform;
  17508. FillXform.GradientFillXform = GradientFillXform;
  17509. module.exports = FillXform;
  17510. }, { "../base-xform": 31, "./color-xform": 127 }], 130: [function (require, module, exports) {
  17511. 'use strict';
  17512. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  17513. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17514. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  17515. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17516. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  17517. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17518. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  17519. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17520. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17521. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  17522. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17523. var ColorXform = require('./color-xform');
  17524. var BooleanXform = require('../simple/boolean-xform');
  17525. var IntegerXform = require('../simple/integer-xform');
  17526. var StringXform = require('../simple/string-xform');
  17527. var UnderlineXform = require('./underline-xform');
  17528. var _ = require('../../../utils/under-dash');
  17529. var BaseXform = require('../base-xform'); // Font encapsulates translation from font model to xlsx
  17530. var FontXform = /*#__PURE__*/function (_BaseXform) {
  17531. _inherits(FontXform, _BaseXform);
  17532. var _super = _createSuper(FontXform);
  17533. function FontXform(options) {
  17534. var _this;
  17535. _classCallCheck(this, FontXform);
  17536. _this = _super.call(this);
  17537. _this.options = options || FontXform.OPTIONS;
  17538. _this.map = {
  17539. b: {
  17540. prop: 'bold',
  17541. xform: new BooleanXform({
  17542. tag: 'b',
  17543. attr: 'val'
  17544. })
  17545. },
  17546. i: {
  17547. prop: 'italic',
  17548. xform: new BooleanXform({
  17549. tag: 'i',
  17550. attr: 'val'
  17551. })
  17552. },
  17553. u: {
  17554. prop: 'underline',
  17555. xform: new UnderlineXform()
  17556. },
  17557. charset: {
  17558. prop: 'charset',
  17559. xform: new IntegerXform({
  17560. tag: 'charset',
  17561. attr: 'val'
  17562. })
  17563. },
  17564. color: {
  17565. prop: 'color',
  17566. xform: new ColorXform()
  17567. },
  17568. condense: {
  17569. prop: 'condense',
  17570. xform: new BooleanXform({
  17571. tag: 'condense',
  17572. attr: 'val'
  17573. })
  17574. },
  17575. extend: {
  17576. prop: 'extend',
  17577. xform: new BooleanXform({
  17578. tag: 'extend',
  17579. attr: 'val'
  17580. })
  17581. },
  17582. family: {
  17583. prop: 'family',
  17584. xform: new IntegerXform({
  17585. tag: 'family',
  17586. attr: 'val'
  17587. })
  17588. },
  17589. outline: {
  17590. prop: 'outline',
  17591. xform: new BooleanXform({
  17592. tag: 'outline',
  17593. attr: 'val'
  17594. })
  17595. },
  17596. vertAlign: {
  17597. prop: 'vertAlign',
  17598. xform: new StringXform({
  17599. tag: 'vertAlign',
  17600. attr: 'val'
  17601. })
  17602. },
  17603. scheme: {
  17604. prop: 'scheme',
  17605. xform: new StringXform({
  17606. tag: 'scheme',
  17607. attr: 'val'
  17608. })
  17609. },
  17610. shadow: {
  17611. prop: 'shadow',
  17612. xform: new BooleanXform({
  17613. tag: 'shadow',
  17614. attr: 'val'
  17615. })
  17616. },
  17617. strike: {
  17618. prop: 'strike',
  17619. xform: new BooleanXform({
  17620. tag: 'strike',
  17621. attr: 'val'
  17622. })
  17623. },
  17624. sz: {
  17625. prop: 'size',
  17626. xform: new IntegerXform({
  17627. tag: 'sz',
  17628. attr: 'val'
  17629. })
  17630. }
  17631. };
  17632. _this.map[_this.options.fontNameTag] = {
  17633. prop: 'name',
  17634. xform: new StringXform({
  17635. tag: _this.options.fontNameTag,
  17636. attr: 'val'
  17637. })
  17638. };
  17639. return _this;
  17640. }
  17641. _createClass(FontXform, [{
  17642. key: "render",
  17643. value: function render(xmlStream, model) {
  17644. var map = this.map;
  17645. xmlStream.openNode(this.options.tagName);
  17646. _.each(this.map, function (defn, tag) {
  17647. map[tag].xform.render(xmlStream, model[defn.prop]);
  17648. });
  17649. xmlStream.closeNode();
  17650. }
  17651. }, {
  17652. key: "parseOpen",
  17653. value: function parseOpen(node) {
  17654. if (this.parser) {
  17655. this.parser.parseOpen(node);
  17656. return true;
  17657. }
  17658. if (this.map[node.name]) {
  17659. this.parser = this.map[node.name].xform;
  17660. return this.parser.parseOpen(node);
  17661. }
  17662. switch (node.name) {
  17663. case this.options.tagName:
  17664. this.model = {};
  17665. return true;
  17666. default:
  17667. return false;
  17668. }
  17669. }
  17670. }, {
  17671. key: "parseText",
  17672. value: function parseText(text) {
  17673. if (this.parser) {
  17674. this.parser.parseText(text);
  17675. }
  17676. }
  17677. }, {
  17678. key: "parseClose",
  17679. value: function parseClose(name) {
  17680. if (this.parser && !this.parser.parseClose(name)) {
  17681. var item = this.map[name];
  17682. if (this.parser.model) {
  17683. this.model[item.prop] = this.parser.model;
  17684. }
  17685. this.parser = undefined;
  17686. return true;
  17687. }
  17688. switch (name) {
  17689. case this.options.tagName:
  17690. return false;
  17691. default:
  17692. return true;
  17693. }
  17694. }
  17695. }, {
  17696. key: "tag",
  17697. get: function get() {
  17698. return this.options.tagName;
  17699. }
  17700. }]);
  17701. return FontXform;
  17702. }(BaseXform);
  17703. FontXform.OPTIONS = {
  17704. tagName: 'font',
  17705. fontNameTag: 'name'
  17706. };
  17707. module.exports = FontXform;
  17708. }, { "../../../utils/under-dash": 25, "../base-xform": 31, "../simple/boolean-xform": 115, "../simple/integer-xform": 117, "../simple/string-xform": 118, "./color-xform": 127, "./underline-xform": 135 }], 131: [function (require, module, exports) {
  17709. "use strict";
  17710. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  17711. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17712. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  17713. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17714. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  17715. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17716. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  17717. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17718. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17719. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  17720. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17721. var _ = require('../../../utils/under-dash');
  17722. var defaultNumFormats = require('../../defaultnumformats');
  17723. var BaseXform = require('../base-xform');
  17724. function hashDefaultFormats() {
  17725. var hash = {};
  17726. _.each(defaultNumFormats, function (dnf, id) {
  17727. if (dnf.f) {
  17728. hash[dnf.f] = parseInt(id, 10);
  17729. } // at some point, add the other cultures here...
  17730. });
  17731. return hash;
  17732. }
  17733. var defaultFmtHash = hashDefaultFormats(); // NumFmt encapsulates translation between number format and xlsx
  17734. var NumFmtXform = /*#__PURE__*/function (_BaseXform) {
  17735. _inherits(NumFmtXform, _BaseXform);
  17736. var _super = _createSuper(NumFmtXform);
  17737. function NumFmtXform(id, formatCode) {
  17738. var _this;
  17739. _classCallCheck(this, NumFmtXform);
  17740. _this = _super.call(this);
  17741. _this.id = id;
  17742. _this.formatCode = formatCode;
  17743. return _this;
  17744. }
  17745. _createClass(NumFmtXform, [{
  17746. key: "render",
  17747. value: function render(xmlStream, model) {
  17748. xmlStream.leafNode('numFmt', {
  17749. numFmtId: model.id,
  17750. formatCode: model.formatCode
  17751. });
  17752. }
  17753. }, {
  17754. key: "parseOpen",
  17755. value: function parseOpen(node) {
  17756. switch (node.name) {
  17757. case 'numFmt':
  17758. this.model = {
  17759. id: parseInt(node.attributes.numFmtId, 10),
  17760. formatCode: node.attributes.formatCode.replace(/[\\](.)/g, '$1')
  17761. };
  17762. return true;
  17763. default:
  17764. return false;
  17765. }
  17766. }
  17767. }, {
  17768. key: "parseText",
  17769. value: function parseText() { }
  17770. }, {
  17771. key: "parseClose",
  17772. value: function parseClose() {
  17773. return false;
  17774. }
  17775. }, {
  17776. key: "tag",
  17777. get: function get() {
  17778. return 'numFmt';
  17779. }
  17780. }]);
  17781. return NumFmtXform;
  17782. }(BaseXform);
  17783. NumFmtXform.getDefaultFmtId = function getDefaultFmtId(formatCode) {
  17784. return defaultFmtHash[formatCode];
  17785. };
  17786. NumFmtXform.getDefaultFmtCode = function getDefaultFmtCode(numFmtId) {
  17787. return defaultNumFormats[numFmtId] && defaultNumFormats[numFmtId].f;
  17788. };
  17789. module.exports = NumFmtXform;
  17790. }, { "../../../utils/under-dash": 25, "../../defaultnumformats": 29, "../base-xform": 31 }], 132: [function (require, module, exports) {
  17791. "use strict";
  17792. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  17793. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17794. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  17795. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17796. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  17797. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17798. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  17799. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17800. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17801. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  17802. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17803. var BaseXform = require('../base-xform');
  17804. var validation = {
  17805. boolean: function boolean(value, dflt) {
  17806. if (value === undefined) {
  17807. return dflt;
  17808. }
  17809. return value;
  17810. }
  17811. }; // Protection encapsulates translation from style.protection model to/from xlsx
  17812. var ProtectionXform = /*#__PURE__*/function (_BaseXform) {
  17813. _inherits(ProtectionXform, _BaseXform);
  17814. var _super = _createSuper(ProtectionXform);
  17815. function ProtectionXform() {
  17816. _classCallCheck(this, ProtectionXform);
  17817. return _super.apply(this, arguments);
  17818. }
  17819. _createClass(ProtectionXform, [{
  17820. key: "render",
  17821. value: function render(xmlStream, model) {
  17822. xmlStream.addRollback();
  17823. xmlStream.openNode('protection');
  17824. var isValid = false;
  17825. function add(name, value) {
  17826. if (value !== undefined) {
  17827. xmlStream.addAttribute(name, value);
  17828. isValid = true;
  17829. }
  17830. }
  17831. add('locked', validation.boolean(model.locked, true) ? undefined : '0');
  17832. add('hidden', validation.boolean(model.hidden, false) ? '1' : undefined);
  17833. xmlStream.closeNode();
  17834. if (isValid) {
  17835. xmlStream.commit();
  17836. } else {
  17837. xmlStream.rollback();
  17838. }
  17839. }
  17840. }, {
  17841. key: "parseOpen",
  17842. value: function parseOpen(node) {
  17843. var model = {
  17844. locked: !(node.attributes.locked === '0'),
  17845. hidden: node.attributes.hidden === '1'
  17846. }; // only want to record models that differ from defaults
  17847. var isSignificant = !model.locked || model.hidden;
  17848. this.model = isSignificant ? model : null;
  17849. }
  17850. }, {
  17851. key: "parseText",
  17852. value: function parseText() { }
  17853. }, {
  17854. key: "parseClose",
  17855. value: function parseClose() {
  17856. return false;
  17857. }
  17858. }, {
  17859. key: "tag",
  17860. get: function get() {
  17861. return 'protection';
  17862. }
  17863. }]);
  17864. return ProtectionXform;
  17865. }(BaseXform);
  17866. module.exports = ProtectionXform;
  17867. }, { "../base-xform": 31 }], 133: [function (require, module, exports) {
  17868. "use strict";
  17869. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  17870. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17871. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  17872. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17873. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  17874. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17875. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  17876. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17877. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17878. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  17879. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17880. var BaseXform = require('../base-xform');
  17881. var AlignmentXform = require('./alignment-xform');
  17882. var ProtectionXform = require('./protection-xform'); // <xf numFmtId="[numFmtId]" fontId="[fontId]" fillId="[fillId]" borderId="[xf.borderId]" xfId="[xfId]">
  17883. // Optional <alignment>
  17884. // Optional <protection>
  17885. // </xf>
  17886. // Style assists translation from style model to/from xlsx
  17887. var StyleXform = /*#__PURE__*/function (_BaseXform) {
  17888. _inherits(StyleXform, _BaseXform);
  17889. var _super = _createSuper(StyleXform);
  17890. function StyleXform(options) {
  17891. var _this;
  17892. _classCallCheck(this, StyleXform);
  17893. _this = _super.call(this);
  17894. _this.xfId = !!(options && options.xfId);
  17895. _this.map = {
  17896. alignment: new AlignmentXform(),
  17897. protection: new ProtectionXform()
  17898. };
  17899. return _this;
  17900. }
  17901. _createClass(StyleXform, [{
  17902. key: "render",
  17903. value: function render(xmlStream, model) {
  17904. xmlStream.openNode('xf', {
  17905. numFmtId: model.numFmtId || 0,
  17906. fontId: model.fontId || 0,
  17907. fillId: model.fillId || 0,
  17908. borderId: model.borderId || 0
  17909. });
  17910. if (this.xfId) {
  17911. xmlStream.addAttribute('xfId', model.xfId || 0);
  17912. }
  17913. if (model.numFmtId) {
  17914. xmlStream.addAttribute('applyNumberFormat', '1');
  17915. }
  17916. if (model.fontId) {
  17917. xmlStream.addAttribute('applyFont', '1');
  17918. }
  17919. if (model.fillId) {
  17920. xmlStream.addAttribute('applyFill', '1');
  17921. }
  17922. if (model.borderId) {
  17923. xmlStream.addAttribute('applyBorder', '1');
  17924. }
  17925. if (model.alignment) {
  17926. xmlStream.addAttribute('applyAlignment', '1');
  17927. }
  17928. if (model.protection) {
  17929. xmlStream.addAttribute('applyProtection', '1');
  17930. }
  17931. /**
  17932. * Rendering tags causes close of XML stream.
  17933. * Therefore adding attributes must be done before rendering tags.
  17934. */
  17935. if (model.alignment) {
  17936. this.map.alignment.render(xmlStream, model.alignment);
  17937. }
  17938. if (model.protection) {
  17939. this.map.protection.render(xmlStream, model.protection);
  17940. }
  17941. xmlStream.closeNode();
  17942. }
  17943. }, {
  17944. key: "parseOpen",
  17945. value: function parseOpen(node) {
  17946. if (this.parser) {
  17947. this.parser.parseOpen(node);
  17948. return true;
  17949. } // used during sax parsing of xml to build font object
  17950. switch (node.name) {
  17951. case 'xf':
  17952. this.model = {
  17953. numFmtId: parseInt(node.attributes.numFmtId, 10),
  17954. fontId: parseInt(node.attributes.fontId, 10),
  17955. fillId: parseInt(node.attributes.fillId, 10),
  17956. borderId: parseInt(node.attributes.borderId, 10)
  17957. };
  17958. if (this.xfId) {
  17959. this.model.xfId = parseInt(node.attributes.xfId, 10);
  17960. }
  17961. return true;
  17962. case 'alignment':
  17963. this.parser = this.map.alignment;
  17964. this.parser.parseOpen(node);
  17965. return true;
  17966. case 'protection':
  17967. this.parser = this.map.protection;
  17968. this.parser.parseOpen(node);
  17969. return true;
  17970. default:
  17971. return false;
  17972. }
  17973. }
  17974. }, {
  17975. key: "parseText",
  17976. value: function parseText(text) {
  17977. if (this.parser) {
  17978. this.parser.parseText(text);
  17979. }
  17980. }
  17981. }, {
  17982. key: "parseClose",
  17983. value: function parseClose(name) {
  17984. if (this.parser) {
  17985. if (!this.parser.parseClose(name)) {
  17986. if (this.map.protection === this.parser) {
  17987. this.model.protection = this.parser.model;
  17988. } else {
  17989. this.model.alignment = this.parser.model;
  17990. }
  17991. this.parser = undefined;
  17992. }
  17993. return true;
  17994. }
  17995. return name !== 'xf';
  17996. }
  17997. }, {
  17998. key: "tag",
  17999. get: function get() {
  18000. return 'xf';
  18001. }
  18002. }]);
  18003. return StyleXform;
  18004. }(BaseXform);
  18005. module.exports = StyleXform;
  18006. }, { "../base-xform": 31, "./alignment-xform": 125, "./protection-xform": 132 }], 134: [function (require, module, exports) {
  18007. "use strict";
  18008. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18009. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18010. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  18011. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18012. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  18013. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  18014. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  18015. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18016. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18017. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  18018. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18019. /* eslint-disable max-classes-per-file */
  18020. var Enums = require('../../../doc/enums');
  18021. var XmlStream = require('../../../utils/xml-stream');
  18022. var BaseXform = require('../base-xform');
  18023. var StaticXform = require('../static-xform');
  18024. var ListXform = require('../list-xform');
  18025. var FontXform = require('./font-xform');
  18026. var FillXform = require('./fill-xform');
  18027. var BorderXform = require('./border-xform');
  18028. var NumFmtXform = require('./numfmt-xform');
  18029. var StyleXform = require('./style-xform');
  18030. var DxfXform = require('./dxf-xform'); // custom numfmt ids start here
  18031. var NUMFMT_BASE = 164; // =============================================================================
  18032. // StylesXform is used to generate and parse the styles.xml file
  18033. // it manages the collections of fonts, number formats, alignments, etc
  18034. var StylesXform = /*#__PURE__*/function (_BaseXform) {
  18035. _inherits(StylesXform, _BaseXform);
  18036. var _super = _createSuper(StylesXform);
  18037. function StylesXform(initialise) {
  18038. var _this;
  18039. _classCallCheck(this, StylesXform);
  18040. _this = _super.call(this);
  18041. _this.map = {
  18042. numFmts: new ListXform({
  18043. tag: 'numFmts',
  18044. count: true,
  18045. childXform: new NumFmtXform()
  18046. }),
  18047. fonts: new ListXform({
  18048. tag: 'fonts',
  18049. count: true,
  18050. childXform: new FontXform(),
  18051. $: {
  18052. 'x14ac:knownFonts': 1
  18053. }
  18054. }),
  18055. fills: new ListXform({
  18056. tag: 'fills',
  18057. count: true,
  18058. childXform: new FillXform()
  18059. }),
  18060. borders: new ListXform({
  18061. tag: 'borders',
  18062. count: true,
  18063. childXform: new BorderXform()
  18064. }),
  18065. cellStyleXfs: new ListXform({
  18066. tag: 'cellStyleXfs',
  18067. count: true,
  18068. childXform: new StyleXform()
  18069. }),
  18070. cellXfs: new ListXform({
  18071. tag: 'cellXfs',
  18072. count: true,
  18073. childXform: new StyleXform({
  18074. xfId: true
  18075. })
  18076. }),
  18077. dxfs: new ListXform({
  18078. tag: 'dxfs',
  18079. always: true,
  18080. count: true,
  18081. childXform: new DxfXform()
  18082. }),
  18083. // for style manager
  18084. numFmt: new NumFmtXform(),
  18085. font: new FontXform(),
  18086. fill: new FillXform(),
  18087. border: new BorderXform(),
  18088. style: new StyleXform({
  18089. xfId: true
  18090. }),
  18091. cellStyles: StylesXform.STATIC_XFORMS.cellStyles,
  18092. tableStyles: StylesXform.STATIC_XFORMS.tableStyles,
  18093. extLst: StylesXform.STATIC_XFORMS.extLst
  18094. };
  18095. if (initialise) {
  18096. // StylesXform also acts as style manager and is used to build up styles-model during worksheet processing
  18097. _this.init();
  18098. }
  18099. return _this;
  18100. }
  18101. _createClass(StylesXform, [{
  18102. key: "initIndex",
  18103. value: function initIndex() {
  18104. this.index = {
  18105. style: {},
  18106. numFmt: {},
  18107. numFmtNextId: 164,
  18108. // start custom format ids here
  18109. font: {},
  18110. border: {},
  18111. fill: {}
  18112. };
  18113. }
  18114. }, {
  18115. key: "init",
  18116. value: function init() {
  18117. // Prepare for Style Manager role
  18118. this.model = {
  18119. styles: [],
  18120. numFmts: [],
  18121. fonts: [],
  18122. borders: [],
  18123. fills: [],
  18124. dxfs: []
  18125. };
  18126. this.initIndex(); // default (zero) border
  18127. this._addBorder({}); // add default (all zero) style
  18128. this._addStyle({
  18129. numFmtId: 0,
  18130. fontId: 0,
  18131. fillId: 0,
  18132. borderId: 0,
  18133. xfId: 0
  18134. }); // add default fills
  18135. this._addFill({
  18136. type: 'pattern',
  18137. pattern: 'none'
  18138. });
  18139. this._addFill({
  18140. type: 'pattern',
  18141. pattern: 'gray125'
  18142. });
  18143. this.weakMap = new WeakMap();
  18144. }
  18145. }, {
  18146. key: "render",
  18147. value: function render(xmlStream, model) {
  18148. model = model || this.model; //
  18149. // <fonts count="2" x14ac:knownFonts="1">
  18150. xmlStream.openXml(XmlStream.StdDocAttributes);
  18151. xmlStream.openNode('styleSheet', StylesXform.STYLESHEET_ATTRIBUTES);
  18152. if (this.index) {
  18153. // model has been built by style manager role (contains xml)
  18154. if (model.numFmts && model.numFmts.length) {
  18155. xmlStream.openNode('numFmts', {
  18156. count: model.numFmts.length
  18157. });
  18158. model.numFmts.forEach(function (numFmtXml) {
  18159. xmlStream.writeXml(numFmtXml);
  18160. });
  18161. xmlStream.closeNode();
  18162. }
  18163. if (!model.fonts.length) {
  18164. // default (zero) font
  18165. this._addFont({
  18166. size: 11,
  18167. color: {
  18168. theme: 1
  18169. },
  18170. name: 'Calibri',
  18171. family: 2,
  18172. scheme: 'minor'
  18173. });
  18174. }
  18175. xmlStream.openNode('fonts', {
  18176. count: model.fonts.length,
  18177. 'x14ac:knownFonts': 1
  18178. });
  18179. model.fonts.forEach(function (fontXml) {
  18180. xmlStream.writeXml(fontXml);
  18181. });
  18182. xmlStream.closeNode();
  18183. xmlStream.openNode('fills', {
  18184. count: model.fills.length
  18185. });
  18186. model.fills.forEach(function (fillXml) {
  18187. xmlStream.writeXml(fillXml);
  18188. });
  18189. xmlStream.closeNode();
  18190. xmlStream.openNode('borders', {
  18191. count: model.borders.length
  18192. });
  18193. model.borders.forEach(function (borderXml) {
  18194. xmlStream.writeXml(borderXml);
  18195. });
  18196. xmlStream.closeNode();
  18197. this.map.cellStyleXfs.render(xmlStream, [{
  18198. numFmtId: 0,
  18199. fontId: 0,
  18200. fillId: 0,
  18201. borderId: 0,
  18202. xfId: 0
  18203. }]);
  18204. xmlStream.openNode('cellXfs', {
  18205. count: model.styles.length
  18206. });
  18207. model.styles.forEach(function (styleXml) {
  18208. xmlStream.writeXml(styleXml);
  18209. });
  18210. xmlStream.closeNode();
  18211. } else {
  18212. // model is plain JSON and needs to be xformed
  18213. this.map.numFmts.render(xmlStream, model.numFmts);
  18214. this.map.fonts.render(xmlStream, model.fonts);
  18215. this.map.fills.render(xmlStream, model.fills);
  18216. this.map.borders.render(xmlStream, model.borders);
  18217. this.map.cellStyleXfs.render(xmlStream, [{
  18218. numFmtId: 0,
  18219. fontId: 0,
  18220. fillId: 0,
  18221. borderId: 0,
  18222. xfId: 0
  18223. }]);
  18224. this.map.cellXfs.render(xmlStream, model.styles);
  18225. }
  18226. StylesXform.STATIC_XFORMS.cellStyles.render(xmlStream);
  18227. this.map.dxfs.render(xmlStream, model.dxfs);
  18228. StylesXform.STATIC_XFORMS.tableStyles.render(xmlStream);
  18229. StylesXform.STATIC_XFORMS.extLst.render(xmlStream);
  18230. xmlStream.closeNode();
  18231. }
  18232. }, {
  18233. key: "parseOpen",
  18234. value: function parseOpen(node) {
  18235. if (this.parser) {
  18236. this.parser.parseOpen(node);
  18237. return true;
  18238. }
  18239. switch (node.name) {
  18240. case 'styleSheet':
  18241. this.initIndex();
  18242. return true;
  18243. default:
  18244. this.parser = this.map[node.name];
  18245. if (this.parser) {
  18246. this.parser.parseOpen(node);
  18247. }
  18248. return true;
  18249. }
  18250. }
  18251. }, {
  18252. key: "parseText",
  18253. value: function parseText(text) {
  18254. if (this.parser) {
  18255. this.parser.parseText(text);
  18256. }
  18257. }
  18258. }, {
  18259. key: "parseClose",
  18260. value: function parseClose(name) {
  18261. var _this2 = this;
  18262. if (this.parser) {
  18263. if (!this.parser.parseClose(name)) {
  18264. this.parser = undefined;
  18265. }
  18266. return true;
  18267. }
  18268. switch (name) {
  18269. case 'styleSheet':
  18270. {
  18271. this.model = {};
  18272. var add = function add(propName, xform) {
  18273. if (xform.model && xform.model.length) {
  18274. _this2.model[propName] = xform.model;
  18275. }
  18276. };
  18277. add('numFmts', this.map.numFmts);
  18278. add('fonts', this.map.fonts);
  18279. add('fills', this.map.fills);
  18280. add('borders', this.map.borders);
  18281. add('styles', this.map.cellXfs);
  18282. add('dxfs', this.map.dxfs); // index numFmts
  18283. this.index = {
  18284. model: [],
  18285. numFmt: []
  18286. };
  18287. if (this.model.numFmts) {
  18288. var numFmtIndex = this.index.numFmt;
  18289. this.model.numFmts.forEach(function (numFmt) {
  18290. numFmtIndex[numFmt.id] = numFmt.formatCode;
  18291. });
  18292. }
  18293. return false;
  18294. }
  18295. default:
  18296. // not quite sure how we get here!
  18297. return true;
  18298. }
  18299. } // add a cell's style model to the collection
  18300. // each style property is processed and cross-referenced, etc.
  18301. // the styleId is returned. Note: cellType is used when numFmt not defined
  18302. }, {
  18303. key: "addStyleModel",
  18304. value: function addStyleModel(model, cellType) {
  18305. if (!model) {
  18306. return 0;
  18307. } // if we have no default font, add it here now
  18308. if (!this.model.fonts.length) {
  18309. // default (zero) font
  18310. this._addFont({
  18311. size: 11,
  18312. color: {
  18313. theme: 1
  18314. },
  18315. name: 'Calibri',
  18316. family: 2,
  18317. scheme: 'minor'
  18318. });
  18319. } // if we have seen this style object before, assume it has the same styleId
  18320. if (this.weakMap && this.weakMap.has(model)) {
  18321. return this.weakMap.get(model);
  18322. }
  18323. var style = {};
  18324. cellType = cellType || Enums.ValueType.Number;
  18325. if (model.numFmt) {
  18326. style.numFmtId = this._addNumFmtStr(model.numFmt);
  18327. } else {
  18328. switch (cellType) {
  18329. case Enums.ValueType.Number:
  18330. style.numFmtId = this._addNumFmtStr('General');
  18331. break;
  18332. case Enums.ValueType.Date:
  18333. style.numFmtId = this._addNumFmtStr('mm-dd-yy');
  18334. break;
  18335. default:
  18336. break;
  18337. }
  18338. }
  18339. if (model.font) {
  18340. style.fontId = this._addFont(model.font);
  18341. }
  18342. if (model.border) {
  18343. style.borderId = this._addBorder(model.border);
  18344. }
  18345. if (model.fill) {
  18346. style.fillId = this._addFill(model.fill);
  18347. }
  18348. if (model.alignment) {
  18349. style.alignment = model.alignment;
  18350. }
  18351. if (model.protection) {
  18352. style.protection = model.protection;
  18353. }
  18354. var styleId = this._addStyle(style);
  18355. if (this.weakMap) {
  18356. this.weakMap.set(model, styleId);
  18357. }
  18358. return styleId;
  18359. } // given a styleId (i.e. s="n"), get the cell's style model
  18360. // objects are shared where possible.
  18361. }, {
  18362. key: "getStyleModel",
  18363. value: function getStyleModel(id) {
  18364. // if the style doesn't exist return null
  18365. var style = this.model.styles[id];
  18366. if (!style) return null; // have we built this model before?
  18367. var model = this.index.model[id];
  18368. if (model) return model; // build a new model
  18369. model = this.index.model[id] = {}; // -------------------------------------------------------
  18370. // number format
  18371. if (style.numFmtId) {
  18372. var numFmt = this.index.numFmt[style.numFmtId] || NumFmtXform.getDefaultFmtCode(style.numFmtId);
  18373. if (numFmt) {
  18374. model.numFmt = numFmt;
  18375. }
  18376. }
  18377. function addStyle(name, group, styleId) {
  18378. if (styleId || styleId === 0) {
  18379. var part = group[styleId];
  18380. if (part) {
  18381. model[name] = part;
  18382. }
  18383. }
  18384. }
  18385. addStyle('font', this.model.fonts, style.fontId);
  18386. addStyle('border', this.model.borders, style.borderId);
  18387. addStyle('fill', this.model.fills, style.fillId); // -------------------------------------------------------
  18388. // alignment
  18389. if (style.alignment) {
  18390. model.alignment = style.alignment;
  18391. } // -------------------------------------------------------
  18392. // protection
  18393. if (style.protection) {
  18394. model.protection = style.protection;
  18395. }
  18396. return model;
  18397. }
  18398. }, {
  18399. key: "addDxfStyle",
  18400. value: function addDxfStyle(style) {
  18401. this.model.dxfs.push(style);
  18402. return this.model.dxfs.length - 1;
  18403. }
  18404. }, {
  18405. key: "getDxfStyle",
  18406. value: function getDxfStyle(id) {
  18407. return this.model.dxfs[id];
  18408. } // =========================================================================
  18409. // Private Interface
  18410. }, {
  18411. key: "_addStyle",
  18412. value: function _addStyle(style) {
  18413. var xml = this.map.style.toXml(style);
  18414. var index = this.index.style[xml];
  18415. if (index === undefined) {
  18416. index = this.index.style[xml] = this.model.styles.length;
  18417. this.model.styles.push(xml);
  18418. }
  18419. return index;
  18420. } // =========================================================================
  18421. // Number Formats
  18422. }, {
  18423. key: "_addNumFmtStr",
  18424. value: function _addNumFmtStr(formatCode) {
  18425. // check if default format
  18426. var index = NumFmtXform.getDefaultFmtId(formatCode);
  18427. if (index !== undefined) return index; // check if already in
  18428. index = this.index.numFmt[formatCode];
  18429. if (index !== undefined) return index;
  18430. index = this.index.numFmt[formatCode] = NUMFMT_BASE + this.model.numFmts.length;
  18431. var xml = this.map.numFmt.toXml({
  18432. id: index,
  18433. formatCode: formatCode
  18434. });
  18435. this.model.numFmts.push(xml);
  18436. return index;
  18437. } // =========================================================================
  18438. // Fonts
  18439. }, {
  18440. key: "_addFont",
  18441. value: function _addFont(font) {
  18442. var xml = this.map.font.toXml(font);
  18443. var index = this.index.font[xml];
  18444. if (index === undefined) {
  18445. index = this.index.font[xml] = this.model.fonts.length;
  18446. this.model.fonts.push(xml);
  18447. }
  18448. return index;
  18449. } // =========================================================================
  18450. // Borders
  18451. }, {
  18452. key: "_addBorder",
  18453. value: function _addBorder(border) {
  18454. var xml = this.map.border.toXml(border);
  18455. var index = this.index.border[xml];
  18456. if (index === undefined) {
  18457. index = this.index.border[xml] = this.model.borders.length;
  18458. this.model.borders.push(xml);
  18459. }
  18460. return index;
  18461. } // =========================================================================
  18462. // Fills
  18463. }, {
  18464. key: "_addFill",
  18465. value: function _addFill(fill) {
  18466. var xml = this.map.fill.toXml(fill);
  18467. var index = this.index.fill[xml];
  18468. if (index === undefined) {
  18469. index = this.index.fill[xml] = this.model.fills.length;
  18470. this.model.fills.push(xml);
  18471. }
  18472. return index;
  18473. } // =========================================================================
  18474. }]);
  18475. return StylesXform;
  18476. }(BaseXform);
  18477. StylesXform.STYLESHEET_ATTRIBUTES = {
  18478. xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
  18479. 'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
  18480. 'mc:Ignorable': 'x14ac x16r2',
  18481. 'xmlns:x14ac': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac',
  18482. 'xmlns:x16r2': 'http://schemas.microsoft.com/office/spreadsheetml/2015/02/main'
  18483. };
  18484. StylesXform.STATIC_XFORMS = {
  18485. cellStyles: new StaticXform({
  18486. tag: 'cellStyles',
  18487. $: {
  18488. count: 1
  18489. },
  18490. c: [{
  18491. tag: 'cellStyle',
  18492. $: {
  18493. name: 'Normal',
  18494. xfId: 0,
  18495. builtinId: 0
  18496. }
  18497. }]
  18498. }),
  18499. dxfs: new StaticXform({
  18500. tag: 'dxfs',
  18501. $: {
  18502. count: 0
  18503. }
  18504. }),
  18505. tableStyles: new StaticXform({
  18506. tag: 'tableStyles',
  18507. $: {
  18508. count: 0,
  18509. defaultTableStyle: 'TableStyleMedium2',
  18510. defaultPivotStyle: 'PivotStyleLight16'
  18511. }
  18512. }),
  18513. extLst: new StaticXform({
  18514. tag: 'extLst',
  18515. c: [{
  18516. tag: 'ext',
  18517. $: {
  18518. uri: '{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}',
  18519. 'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main'
  18520. },
  18521. c: [{
  18522. tag: 'x14:slicerStyles',
  18523. $: {
  18524. defaultSlicerStyle: 'SlicerStyleLight1'
  18525. }
  18526. }]
  18527. }, {
  18528. tag: 'ext',
  18529. $: {
  18530. uri: '{9260A510-F301-46a8-8635-F512D64BE5F5}',
  18531. 'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main'
  18532. },
  18533. c: [{
  18534. tag: 'x15:timelineStyles',
  18535. $: {
  18536. defaultTimelineStyle: 'TimeSlicerStyleLight1'
  18537. }
  18538. }]
  18539. }]
  18540. })
  18541. }; // the stylemanager mock acts like StyleManager except that it always returns 0 or {}
  18542. var StylesXformMock = /*#__PURE__*/function (_StylesXform) {
  18543. _inherits(StylesXformMock, _StylesXform);
  18544. var _super2 = _createSuper(StylesXformMock);
  18545. function StylesXformMock() {
  18546. var _this3;
  18547. _classCallCheck(this, StylesXformMock);
  18548. _this3 = _super2.call(this);
  18549. _this3.model = {
  18550. styles: [{
  18551. numFmtId: 0,
  18552. fontId: 0,
  18553. fillId: 0,
  18554. borderId: 0,
  18555. xfId: 0
  18556. }],
  18557. numFmts: [],
  18558. fonts: [{
  18559. size: 11,
  18560. color: {
  18561. theme: 1
  18562. },
  18563. name: 'Calibri',
  18564. family: 2,
  18565. scheme: 'minor'
  18566. }],
  18567. borders: [{}],
  18568. fills: [{
  18569. type: 'pattern',
  18570. pattern: 'none'
  18571. }, {
  18572. type: 'pattern',
  18573. pattern: 'gray125'
  18574. }]
  18575. };
  18576. return _this3;
  18577. } // =========================================================================
  18578. // Style Manager Interface
  18579. // override normal behaviour - consume and dispose
  18580. _createClass(StylesXformMock, [{
  18581. key: "parseStream",
  18582. value: function parseStream(stream) {
  18583. stream.autodrain();
  18584. return Promise.resolve();
  18585. } // add a cell's style model to the collection
  18586. // each style property is processed and cross-referenced, etc.
  18587. // the styleId is returned. Note: cellType is used when numFmt not defined
  18588. }, {
  18589. key: "addStyleModel",
  18590. value: function addStyleModel(model, cellType) {
  18591. switch (cellType) {
  18592. case Enums.ValueType.Date:
  18593. return this.dateStyleId;
  18594. default:
  18595. return 0;
  18596. }
  18597. }
  18598. }, {
  18599. key: "getStyleModel",
  18600. // given a styleId (i.e. s="n"), get the cell's style model
  18601. // objects are shared where possible.
  18602. value: function getStyleModel()
  18603. /* id */ {
  18604. return {};
  18605. }
  18606. }, {
  18607. key: "dateStyleId",
  18608. get: function get() {
  18609. if (!this._dateStyleId) {
  18610. var dateStyle = {
  18611. numFmtId: NumFmtXform.getDefaultFmtId('mm-dd-yy')
  18612. };
  18613. this._dateStyleId = this.model.styles.length;
  18614. this.model.styles.push(dateStyle);
  18615. }
  18616. return this._dateStyleId;
  18617. }
  18618. }]);
  18619. return StylesXformMock;
  18620. }(StylesXform);
  18621. StylesXform.Mock = StylesXformMock;
  18622. module.exports = StylesXform;
  18623. }, { "../../../doc/enums": 7, "../../../utils/xml-stream": 27, "../base-xform": 31, "../list-xform": 70, "../static-xform": 119, "./border-xform": 126, "./dxf-xform": 128, "./fill-xform": 129, "./font-xform": 130, "./numfmt-xform": 131, "./style-xform": 133 }], 135: [function (require, module, exports) {
  18624. "use strict";
  18625. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18626. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18627. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  18628. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18629. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  18630. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  18631. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  18632. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18633. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18634. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  18635. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18636. var BaseXform = require('../base-xform');
  18637. var UnderlineXform = /*#__PURE__*/function (_BaseXform) {
  18638. _inherits(UnderlineXform, _BaseXform);
  18639. var _super = _createSuper(UnderlineXform);
  18640. function UnderlineXform(model) {
  18641. var _this;
  18642. _classCallCheck(this, UnderlineXform);
  18643. _this = _super.call(this);
  18644. _this.model = model;
  18645. return _this;
  18646. }
  18647. _createClass(UnderlineXform, [{
  18648. key: "render",
  18649. value: function render(xmlStream, model) {
  18650. model = model || this.model;
  18651. if (model === true) {
  18652. xmlStream.leafNode('u');
  18653. } else {
  18654. var attr = UnderlineXform.Attributes[model];
  18655. if (attr) {
  18656. xmlStream.leafNode('u', attr);
  18657. }
  18658. }
  18659. }
  18660. }, {
  18661. key: "parseOpen",
  18662. value: function parseOpen(node) {
  18663. if (node.name === 'u') {
  18664. this.model = node.attributes.val || true;
  18665. }
  18666. }
  18667. }, {
  18668. key: "parseText",
  18669. value: function parseText() { }
  18670. }, {
  18671. key: "parseClose",
  18672. value: function parseClose() {
  18673. return false;
  18674. }
  18675. }, {
  18676. key: "tag",
  18677. get: function get() {
  18678. return 'u';
  18679. }
  18680. }]);
  18681. return UnderlineXform;
  18682. }(BaseXform);
  18683. UnderlineXform.Attributes = {
  18684. single: {},
  18685. double: {
  18686. val: 'double'
  18687. },
  18688. singleAccounting: {
  18689. val: 'singleAccounting'
  18690. },
  18691. doubleAccounting: {
  18692. val: 'doubleAccounting'
  18693. }
  18694. };
  18695. module.exports = UnderlineXform;
  18696. }, { "../base-xform": 31 }], 136: [function (require, module, exports) {
  18697. "use strict";
  18698. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18699. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18700. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  18701. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18702. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  18703. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  18704. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  18705. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18706. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18707. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  18708. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18709. var BaseXform = require('../base-xform');
  18710. var FilterColumnXform = require('./filter-column-xform');
  18711. var AutoFilterXform = /*#__PURE__*/function (_BaseXform) {
  18712. _inherits(AutoFilterXform, _BaseXform);
  18713. var _super = _createSuper(AutoFilterXform);
  18714. function AutoFilterXform() {
  18715. var _this;
  18716. _classCallCheck(this, AutoFilterXform);
  18717. _this = _super.call(this);
  18718. _this.map = {
  18719. filterColumn: new FilterColumnXform()
  18720. };
  18721. return _this;
  18722. }
  18723. _createClass(AutoFilterXform, [{
  18724. key: "prepare",
  18725. value: function prepare(model) {
  18726. var _this2 = this;
  18727. model.columns.forEach(function (column, index) {
  18728. _this2.map.filterColumn.prepare(column, {
  18729. index: index
  18730. });
  18731. });
  18732. }
  18733. }, {
  18734. key: "render",
  18735. value: function render(xmlStream, model) {
  18736. var _this3 = this;
  18737. xmlStream.openNode(this.tag, {
  18738. ref: model.autoFilterRef
  18739. });
  18740. model.columns.forEach(function (column) {
  18741. _this3.map.filterColumn.render(xmlStream, column);
  18742. });
  18743. xmlStream.closeNode();
  18744. return true;
  18745. }
  18746. }, {
  18747. key: "parseOpen",
  18748. value: function parseOpen(node) {
  18749. if (this.parser) {
  18750. this.parser.parseOpen(node);
  18751. return true;
  18752. }
  18753. switch (node.name) {
  18754. case this.tag:
  18755. this.model = {
  18756. autoFilterRef: node.attributes.ref,
  18757. columns: []
  18758. };
  18759. return true;
  18760. default:
  18761. this.parser = this.map[node.name];
  18762. if (this.parser) {
  18763. this.parseOpen(node);
  18764. return true;
  18765. }
  18766. throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(node)));
  18767. }
  18768. }
  18769. }, {
  18770. key: "parseText",
  18771. value: function parseText(text) {
  18772. if (this.parser) {
  18773. this.parser.parseText(text);
  18774. }
  18775. }
  18776. }, {
  18777. key: "parseClose",
  18778. value: function parseClose(name) {
  18779. if (this.parser) {
  18780. if (!this.parser.parseClose(name)) {
  18781. this.model.columns.push(this.parser.model);
  18782. this.parser = undefined;
  18783. }
  18784. return true;
  18785. }
  18786. switch (name) {
  18787. case this.tag:
  18788. return false;
  18789. default:
  18790. throw new Error("Unexpected xml node in parseClose: ".concat(name));
  18791. }
  18792. }
  18793. }, {
  18794. key: "tag",
  18795. get: function get() {
  18796. return 'autoFilter';
  18797. }
  18798. }]);
  18799. return AutoFilterXform;
  18800. }(BaseXform);
  18801. module.exports = AutoFilterXform;
  18802. }, { "../base-xform": 31, "./filter-column-xform": 137 }], 137: [function (require, module, exports) {
  18803. "use strict";
  18804. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18805. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18806. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  18807. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18808. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  18809. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  18810. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  18811. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18812. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18813. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  18814. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18815. var BaseXform = require('../base-xform');
  18816. var FilterColumnXform = /*#__PURE__*/function (_BaseXform) {
  18817. _inherits(FilterColumnXform, _BaseXform);
  18818. var _super = _createSuper(FilterColumnXform);
  18819. function FilterColumnXform() {
  18820. _classCallCheck(this, FilterColumnXform);
  18821. return _super.apply(this, arguments);
  18822. }
  18823. _createClass(FilterColumnXform, [{
  18824. key: "prepare",
  18825. value: function prepare(model, options) {
  18826. model.colId = options.index.toString();
  18827. }
  18828. }, {
  18829. key: "render",
  18830. value: function render(xmlStream, model) {
  18831. xmlStream.leafNode(this.tag, {
  18832. colId: model.colId,
  18833. hiddenButton: model.filterButton ? '0' : '1'
  18834. });
  18835. return true;
  18836. }
  18837. }, {
  18838. key: "parseOpen",
  18839. value: function parseOpen(node) {
  18840. if (node.name === this.tag) {
  18841. var attributes = node.attributes;
  18842. this.model = {
  18843. filterButton: attributes.hiddenButton === '0'
  18844. };
  18845. return true;
  18846. }
  18847. return false;
  18848. }
  18849. }, {
  18850. key: "parseText",
  18851. value: function parseText() { }
  18852. }, {
  18853. key: "parseClose",
  18854. value: function parseClose() {
  18855. return false;
  18856. }
  18857. }, {
  18858. key: "tag",
  18859. get: function get() {
  18860. return 'filterColumn';
  18861. }
  18862. }]);
  18863. return FilterColumnXform;
  18864. }(BaseXform);
  18865. module.exports = FilterColumnXform;
  18866. }, { "../base-xform": 31 }], 138: [function (require, module, exports) {
  18867. "use strict";
  18868. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18869. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18870. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  18871. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18872. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  18873. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  18874. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  18875. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18876. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18877. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  18878. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18879. var BaseXform = require('../base-xform');
  18880. var TableColumnXform = /*#__PURE__*/function (_BaseXform) {
  18881. _inherits(TableColumnXform, _BaseXform);
  18882. var _super = _createSuper(TableColumnXform);
  18883. function TableColumnXform() {
  18884. _classCallCheck(this, TableColumnXform);
  18885. return _super.apply(this, arguments);
  18886. }
  18887. _createClass(TableColumnXform, [{
  18888. key: "prepare",
  18889. value: function prepare(model, options) {
  18890. model.id = options.index + 1;
  18891. }
  18892. }, {
  18893. key: "render",
  18894. value: function render(xmlStream, model) {
  18895. xmlStream.leafNode(this.tag, {
  18896. id: model.id.toString(),
  18897. name: model.name,
  18898. totalsRowLabel: model.totalsRowLabel,
  18899. totalsRowFunction: model.totalsRowFunction,
  18900. dxfId: model.dxfId
  18901. });
  18902. return true;
  18903. }
  18904. }, {
  18905. key: "parseOpen",
  18906. value: function parseOpen(node) {
  18907. if (node.name === this.tag) {
  18908. var attributes = node.attributes;
  18909. this.model = {
  18910. name: attributes.name,
  18911. totalsRowLabel: attributes.totalsRowLabel,
  18912. totalsRowFunction: attributes.totalsRowFunction,
  18913. dxfId: attributes.dxfId
  18914. };
  18915. return true;
  18916. }
  18917. return false;
  18918. }
  18919. }, {
  18920. key: "parseText",
  18921. value: function parseText() { }
  18922. }, {
  18923. key: "parseClose",
  18924. value: function parseClose() {
  18925. return false;
  18926. }
  18927. }, {
  18928. key: "tag",
  18929. get: function get() {
  18930. return 'tableColumn';
  18931. }
  18932. }]);
  18933. return TableColumnXform;
  18934. }(BaseXform);
  18935. module.exports = TableColumnXform;
  18936. }, { "../base-xform": 31 }], 139: [function (require, module, exports) {
  18937. "use strict";
  18938. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18939. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18940. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  18941. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18942. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  18943. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  18944. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  18945. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18946. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18947. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  18948. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18949. var BaseXform = require('../base-xform');
  18950. var TableStyleInfoXform = /*#__PURE__*/function (_BaseXform) {
  18951. _inherits(TableStyleInfoXform, _BaseXform);
  18952. var _super = _createSuper(TableStyleInfoXform);
  18953. function TableStyleInfoXform() {
  18954. _classCallCheck(this, TableStyleInfoXform);
  18955. return _super.apply(this, arguments);
  18956. }
  18957. _createClass(TableStyleInfoXform, [{
  18958. key: "render",
  18959. value: function render(xmlStream, model) {
  18960. xmlStream.leafNode(this.tag, {
  18961. name: model.theme ? model.theme : undefined,
  18962. showFirstColumn: model.showFirstColumn ? '1' : '0',
  18963. showLastColumn: model.showLastColumn ? '1' : '0',
  18964. showRowStripes: model.showRowStripes ? '1' : '0',
  18965. showColumnStripes: model.showColumnStripes ? '1' : '0'
  18966. });
  18967. return true;
  18968. }
  18969. }, {
  18970. key: "parseOpen",
  18971. value: function parseOpen(node) {
  18972. if (node.name === this.tag) {
  18973. var attributes = node.attributes;
  18974. this.model = {
  18975. theme: attributes.name ? attributes.name : null,
  18976. showFirstColumn: attributes.showFirstColumn === '1',
  18977. showLastColumn: attributes.showLastColumn === '1',
  18978. showRowStripes: attributes.showRowStripes === '1',
  18979. showColumnStripes: attributes.showColumnStripes === '1'
  18980. };
  18981. return true;
  18982. }
  18983. return false;
  18984. }
  18985. }, {
  18986. key: "parseText",
  18987. value: function parseText() { }
  18988. }, {
  18989. key: "parseClose",
  18990. value: function parseClose() {
  18991. return false;
  18992. }
  18993. }, {
  18994. key: "tag",
  18995. get: function get() {
  18996. return 'tableStyleInfo';
  18997. }
  18998. }]);
  18999. return TableStyleInfoXform;
  19000. }(BaseXform);
  19001. module.exports = TableStyleInfoXform;
  19002. }, { "../base-xform": 31 }], 140: [function (require, module, exports) {
  19003. "use strict";
  19004. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  19005. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  19006. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  19007. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  19008. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19009. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  19010. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  19011. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  19012. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  19013. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  19014. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  19015. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  19016. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  19017. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  19018. var XmlStream = require('../../../utils/xml-stream');
  19019. var BaseXform = require('../base-xform');
  19020. var ListXform = require('../list-xform');
  19021. var AutoFilterXform = require('./auto-filter-xform');
  19022. var TableColumnXform = require('./table-column-xform');
  19023. var TableStyleInfoXform = require('./table-style-info-xform');
  19024. var TableXform = /*#__PURE__*/function (_BaseXform) {
  19025. _inherits(TableXform, _BaseXform);
  19026. var _super = _createSuper(TableXform);
  19027. function TableXform() {
  19028. var _this;
  19029. _classCallCheck(this, TableXform);
  19030. _this = _super.call(this);
  19031. _this.map = {
  19032. autoFilter: new AutoFilterXform(),
  19033. tableColumns: new ListXform({
  19034. tag: 'tableColumns',
  19035. count: true,
  19036. empty: true,
  19037. childXform: new TableColumnXform()
  19038. }),
  19039. tableStyleInfo: new TableStyleInfoXform()
  19040. };
  19041. return _this;
  19042. }
  19043. _createClass(TableXform, [{
  19044. key: "prepare",
  19045. value: function prepare(model, options) {
  19046. this.map.autoFilter.prepare(model);
  19047. this.map.tableColumns.prepare(model.columns, options);
  19048. }
  19049. }, {
  19050. key: "render",
  19051. value: function render(xmlStream, model) {
  19052. xmlStream.openXml(XmlStream.StdDocAttributes);
  19053. xmlStream.openNode(this.tag, _objectSpread(_objectSpread({}, TableXform.TABLE_ATTRIBUTES), {}, {
  19054. id: model.id,
  19055. name: model.name,
  19056. displayName: model.displayName || model.name,
  19057. ref: model.tableRef,
  19058. totalsRowCount: model.totalsRow ? '1' : undefined,
  19059. totalsRowShown: model.totalsRow ? undefined : '1',
  19060. headerRowCount: model.headerRow ? '1' : '0'
  19061. }));
  19062. this.map.autoFilter.render(xmlStream, model);
  19063. this.map.tableColumns.render(xmlStream, model.columns);
  19064. this.map.tableStyleInfo.render(xmlStream, model.style);
  19065. xmlStream.closeNode();
  19066. }
  19067. }, {
  19068. key: "parseOpen",
  19069. value: function parseOpen(node) {
  19070. if (this.parser) {
  19071. this.parser.parseOpen(node);
  19072. return true;
  19073. }
  19074. var name = node.name,
  19075. attributes = node.attributes;
  19076. switch (name) {
  19077. case this.tag:
  19078. this.reset();
  19079. this.model = {
  19080. name: attributes.name,
  19081. displayName: attributes.displayName || attributes.name,
  19082. tableRef: attributes.ref,
  19083. totalsRow: attributes.totalsRowCount === '1',
  19084. headerRow: attributes.headerRowCount === '1'
  19085. };
  19086. break;
  19087. default:
  19088. this.parser = this.map[node.name];
  19089. if (this.parser) {
  19090. this.parser.parseOpen(node);
  19091. }
  19092. break;
  19093. }
  19094. return true;
  19095. }
  19096. }, {
  19097. key: "parseText",
  19098. value: function parseText(text) {
  19099. if (this.parser) {
  19100. this.parser.parseText(text);
  19101. }
  19102. }
  19103. }, {
  19104. key: "parseClose",
  19105. value: function parseClose(name) {
  19106. var _this2 = this;
  19107. if (this.parser) {
  19108. if (!this.parser.parseClose(name)) {
  19109. this.parser = undefined;
  19110. }
  19111. return true;
  19112. }
  19113. switch (name) {
  19114. case this.tag:
  19115. this.model.columns = this.map.tableColumns.model;
  19116. if (this.map.autoFilter.model) {
  19117. this.model.autoFilterRef = this.map.autoFilter.model.autoFilterRef;
  19118. this.map.autoFilter.model.columns.forEach(function (column, index) {
  19119. _this2.model.columns[index].filterButton = column.filterButton;
  19120. });
  19121. }
  19122. this.model.style = this.map.tableStyleInfo.model;
  19123. return false;
  19124. default:
  19125. // could be some unrecognised tags
  19126. return true;
  19127. }
  19128. }
  19129. }, {
  19130. key: "reconcile",
  19131. value: function reconcile(model, options) {
  19132. // fetch the dfxs from styles
  19133. model.columns.forEach(function (column) {
  19134. if (column.dxfId !== undefined) {
  19135. column.style = options.styles.getDxfStyle(column.dxfId);
  19136. }
  19137. });
  19138. }
  19139. }, {
  19140. key: "tag",
  19141. get: function get() {
  19142. return 'table';
  19143. }
  19144. }]);
  19145. return TableXform;
  19146. }(BaseXform);
  19147. TableXform.TABLE_ATTRIBUTES = {
  19148. xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
  19149. 'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
  19150. 'mc:Ignorable': 'xr xr3',
  19151. 'xmlns:xr': 'http://schemas.microsoft.com/office/spreadsheetml/2014/revision',
  19152. 'xmlns:xr3': 'http://schemas.microsoft.com/office/spreadsheetml/2016/revision3' // 'xr:uid': '{00000000-000C-0000-FFFF-FFFF00000000}',
  19153. };
  19154. module.exports = TableXform;
  19155. }, { "../../../utils/xml-stream": 27, "../base-xform": 31, "../list-xform": 70, "./auto-filter-xform": 136, "./table-column-xform": 138, "./table-style-info-xform": 139 }], 141: [function (require, module, exports) {
  19156. (function (process, Buffer) {
  19157. "use strict";
  19158. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  19159. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  19160. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19161. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  19162. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  19163. function _asyncIterator(iterable) { var method; if (typeof Symbol !== "undefined") { if (Symbol.asyncIterator) { method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { method = iterable[Symbol.iterator]; if (method != null) return method.call(iterable); } } throw new TypeError("Object is not async iterable"); }
  19164. var fs = require('fs');
  19165. var JSZip = require('jszip');
  19166. var _require = require('readable-stream'),
  19167. PassThrough = _require.PassThrough;
  19168. var ZipStream = require('../utils/zip-stream');
  19169. var StreamBuf = require('../utils/stream-buf');
  19170. var utils = require('../utils/utils');
  19171. var XmlStream = require('../utils/xml-stream');
  19172. var _require2 = require('../utils/browser-buffer-decode'),
  19173. bufferToString = _require2.bufferToString;
  19174. var StylesXform = require('./xform/style/styles-xform');
  19175. var CoreXform = require('./xform/core/core-xform');
  19176. var SharedStringsXform = require('./xform/strings/shared-strings-xform');
  19177. var RelationshipsXform = require('./xform/core/relationships-xform');
  19178. var ContentTypesXform = require('./xform/core/content-types-xform');
  19179. var AppXform = require('./xform/core/app-xform');
  19180. var WorkbookXform = require('./xform/book/workbook-xform');
  19181. var WorksheetXform = require('./xform/sheet/worksheet-xform');
  19182. var DrawingXform = require('./xform/drawing/drawing-xform');
  19183. var TableXform = require('./xform/table/table-xform');
  19184. var CommentsXform = require('./xform/comment/comments-xform');
  19185. var VmlNotesXform = require('./xform/comment/vml-notes-xform');
  19186. var theme1Xml = require('./xml/theme1.js');
  19187. function fsReadFileAsync(filename, options) {
  19188. return new Promise(function (resolve, reject) {
  19189. fs.readFile(filename, options, function (error, data) {
  19190. if (error) {
  19191. reject(error);
  19192. } else {
  19193. resolve(data);
  19194. }
  19195. });
  19196. });
  19197. }
  19198. var XLSX = /*#__PURE__*/function () {
  19199. function XLSX(workbook) {
  19200. _classCallCheck(this, XLSX);
  19201. this.workbook = workbook;
  19202. } // ===============================================================================
  19203. // Workbook
  19204. // =========================================================================
  19205. // Read
  19206. _createClass(XLSX, [{
  19207. key: "readFile",
  19208. value: function () {
  19209. var _readFile = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(filename, options) {
  19210. var stream, workbook;
  19211. return regeneratorRuntime.wrap(function _callee$(_context) {
  19212. while (1) {
  19213. switch (_context.prev = _context.next) {
  19214. case 0:
  19215. _context.next = 2;
  19216. return utils.fs.exists(filename);
  19217. case 2:
  19218. if (_context.sent) {
  19219. _context.next = 4;
  19220. break;
  19221. }
  19222. throw new Error("File not found: ".concat(filename));
  19223. case 4:
  19224. stream = fs.createReadStream(filename);
  19225. _context.prev = 5;
  19226. _context.next = 8;
  19227. return this.read(stream, options);
  19228. case 8:
  19229. workbook = _context.sent;
  19230. stream.close();
  19231. return _context.abrupt("return", workbook);
  19232. case 13:
  19233. _context.prev = 13;
  19234. _context.t0 = _context["catch"](5);
  19235. stream.close();
  19236. throw _context.t0;
  19237. case 17:
  19238. case "end":
  19239. return _context.stop();
  19240. }
  19241. }
  19242. }, _callee, this, [[5, 13]]);
  19243. }));
  19244. function readFile(_x, _x2) {
  19245. return _readFile.apply(this, arguments);
  19246. }
  19247. return readFile;
  19248. }()
  19249. }, {
  19250. key: "parseRels",
  19251. value: function parseRels(stream) {
  19252. var xform = new RelationshipsXform();
  19253. return xform.parseStream(stream);
  19254. }
  19255. }, {
  19256. key: "parseWorkbook",
  19257. value: function parseWorkbook(stream) {
  19258. var xform = new WorkbookXform();
  19259. return xform.parseStream(stream);
  19260. }
  19261. }, {
  19262. key: "parseSharedStrings",
  19263. value: function parseSharedStrings(stream) {
  19264. var xform = new SharedStringsXform();
  19265. return xform.parseStream(stream);
  19266. }
  19267. }, {
  19268. key: "reconcile",
  19269. value: function reconcile(model, options) {
  19270. var workbookXform = new WorkbookXform();
  19271. var worksheetXform = new WorksheetXform(options);
  19272. var drawingXform = new DrawingXform();
  19273. var tableXform = new TableXform();
  19274. workbookXform.reconcile(model); // reconcile drawings with their rels
  19275. var drawingOptions = {
  19276. media: model.media,
  19277. mediaIndex: model.mediaIndex
  19278. };
  19279. Object.keys(model.drawings).forEach(function (name) {
  19280. var drawing = model.drawings[name];
  19281. var drawingRel = model.drawingRels[name];
  19282. if (drawingRel) {
  19283. drawingOptions.rels = drawingRel.reduce(function (o, rel) {
  19284. o[rel.Id] = rel;
  19285. return o;
  19286. }, {});
  19287. (drawing.anchors || []).forEach(function (anchor) {
  19288. var hyperlinks = anchor.picture && anchor.picture.hyperlinks;
  19289. if (hyperlinks && drawingOptions.rels[hyperlinks.rId]) {
  19290. hyperlinks.hyperlink = drawingOptions.rels[hyperlinks.rId].Target;
  19291. delete hyperlinks.rId;
  19292. }
  19293. });
  19294. drawingXform.reconcile(drawing, drawingOptions);
  19295. }
  19296. }); // reconcile tables with the default styles
  19297. var tableOptions = {
  19298. styles: model.styles
  19299. };
  19300. Object.values(model.tables).forEach(function (table) {
  19301. tableXform.reconcile(table, tableOptions);
  19302. });
  19303. var sheetOptions = {
  19304. styles: model.styles,
  19305. sharedStrings: model.sharedStrings,
  19306. media: model.media,
  19307. mediaIndex: model.mediaIndex,
  19308. date1904: model.properties && model.properties.date1904,
  19309. drawings: model.drawings,
  19310. comments: model.comments,
  19311. tables: model.tables,
  19312. vmlDrawings: model.vmlDrawings
  19313. };
  19314. model.worksheets.forEach(function (worksheet) {
  19315. worksheet.relationships = model.worksheetRels[worksheet.sheetNo];
  19316. worksheetXform.reconcile(worksheet, sheetOptions);
  19317. }); // delete unnecessary parts
  19318. delete model.worksheetHash;
  19319. delete model.worksheetRels;
  19320. delete model.globalRels;
  19321. delete model.sharedStrings;
  19322. delete model.workbookRels;
  19323. delete model.sheetDefs;
  19324. delete model.styles;
  19325. delete model.mediaIndex;
  19326. delete model.drawings;
  19327. delete model.drawingRels;
  19328. delete model.vmlDrawings;
  19329. }
  19330. }, {
  19331. key: "_processWorksheetEntry",
  19332. value: function () {
  19333. var _processWorksheetEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(stream, model, sheetNo, options, path) {
  19334. var xform, worksheet;
  19335. return regeneratorRuntime.wrap(function _callee2$(_context2) {
  19336. while (1) {
  19337. switch (_context2.prev = _context2.next) {
  19338. case 0:
  19339. xform = new WorksheetXform(options);
  19340. _context2.next = 3;
  19341. return xform.parseStream(stream);
  19342. case 3:
  19343. worksheet = _context2.sent;
  19344. worksheet.sheetNo = sheetNo;
  19345. model.worksheetHash[path] = worksheet;
  19346. model.worksheets.push(worksheet);
  19347. case 7:
  19348. case "end":
  19349. return _context2.stop();
  19350. }
  19351. }
  19352. }, _callee2);
  19353. }));
  19354. function _processWorksheetEntry(_x3, _x4, _x5, _x6, _x7) {
  19355. return _processWorksheetEntry2.apply(this, arguments);
  19356. }
  19357. return _processWorksheetEntry;
  19358. }()
  19359. }, {
  19360. key: "_processCommentEntry",
  19361. value: function () {
  19362. var _processCommentEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(stream, model, name) {
  19363. var xform, comments;
  19364. return regeneratorRuntime.wrap(function _callee3$(_context3) {
  19365. while (1) {
  19366. switch (_context3.prev = _context3.next) {
  19367. case 0:
  19368. xform = new CommentsXform();
  19369. _context3.next = 3;
  19370. return xform.parseStream(stream);
  19371. case 3:
  19372. comments = _context3.sent;
  19373. model.comments["../".concat(name, ".xml")] = comments;
  19374. case 5:
  19375. case "end":
  19376. return _context3.stop();
  19377. }
  19378. }
  19379. }, _callee3);
  19380. }));
  19381. function _processCommentEntry(_x8, _x9, _x10) {
  19382. return _processCommentEntry2.apply(this, arguments);
  19383. }
  19384. return _processCommentEntry;
  19385. }()
  19386. }, {
  19387. key: "_processTableEntry",
  19388. value: function () {
  19389. var _processTableEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(stream, model, name) {
  19390. var xform, table;
  19391. return regeneratorRuntime.wrap(function _callee4$(_context4) {
  19392. while (1) {
  19393. switch (_context4.prev = _context4.next) {
  19394. case 0:
  19395. xform = new TableXform();
  19396. _context4.next = 3;
  19397. return xform.parseStream(stream);
  19398. case 3:
  19399. table = _context4.sent;
  19400. model.tables["../tables/".concat(name, ".xml")] = table;
  19401. case 5:
  19402. case "end":
  19403. return _context4.stop();
  19404. }
  19405. }
  19406. }, _callee4);
  19407. }));
  19408. function _processTableEntry(_x11, _x12, _x13) {
  19409. return _processTableEntry2.apply(this, arguments);
  19410. }
  19411. return _processTableEntry;
  19412. }()
  19413. }, {
  19414. key: "_processWorksheetRelsEntry",
  19415. value: function () {
  19416. var _processWorksheetRelsEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(stream, model, sheetNo) {
  19417. var xform, relationships;
  19418. return regeneratorRuntime.wrap(function _callee5$(_context5) {
  19419. while (1) {
  19420. switch (_context5.prev = _context5.next) {
  19421. case 0:
  19422. xform = new RelationshipsXform();
  19423. _context5.next = 3;
  19424. return xform.parseStream(stream);
  19425. case 3:
  19426. relationships = _context5.sent;
  19427. model.worksheetRels[sheetNo] = relationships;
  19428. case 5:
  19429. case "end":
  19430. return _context5.stop();
  19431. }
  19432. }
  19433. }, _callee5);
  19434. }));
  19435. function _processWorksheetRelsEntry(_x14, _x15, _x16) {
  19436. return _processWorksheetRelsEntry2.apply(this, arguments);
  19437. }
  19438. return _processWorksheetRelsEntry;
  19439. }()
  19440. }, {
  19441. key: "_processMediaEntry",
  19442. value: function () {
  19443. var _processMediaEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(entry, model, filename) {
  19444. var lastDot, extension, name;
  19445. return regeneratorRuntime.wrap(function _callee6$(_context6) {
  19446. while (1) {
  19447. switch (_context6.prev = _context6.next) {
  19448. case 0:
  19449. lastDot = filename.lastIndexOf('.'); // if we can't determine extension, ignore it
  19450. if (!(lastDot >= 1)) {
  19451. _context6.next = 6;
  19452. break;
  19453. }
  19454. extension = filename.substr(lastDot + 1);
  19455. name = filename.substr(0, lastDot);
  19456. _context6.next = 6;
  19457. return new Promise(function (resolve, reject) {
  19458. var streamBuf = new StreamBuf();
  19459. streamBuf.on('finish', function () {
  19460. model.mediaIndex[filename] = model.media.length;
  19461. model.mediaIndex[name] = model.media.length;
  19462. var medium = {
  19463. type: 'image',
  19464. name: name,
  19465. extension: extension,
  19466. buffer: streamBuf.toBuffer()
  19467. };
  19468. model.media.push(medium);
  19469. resolve();
  19470. });
  19471. entry.on('error', function (error) {
  19472. reject(error);
  19473. });
  19474. entry.pipe(streamBuf);
  19475. });
  19476. case 6:
  19477. case "end":
  19478. return _context6.stop();
  19479. }
  19480. }
  19481. }, _callee6);
  19482. }));
  19483. function _processMediaEntry(_x17, _x18, _x19) {
  19484. return _processMediaEntry2.apply(this, arguments);
  19485. }
  19486. return _processMediaEntry;
  19487. }()
  19488. }, {
  19489. key: "_processDrawingEntry",
  19490. value: function () {
  19491. var _processDrawingEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(entry, model, name) {
  19492. var xform, drawing;
  19493. return regeneratorRuntime.wrap(function _callee7$(_context7) {
  19494. while (1) {
  19495. switch (_context7.prev = _context7.next) {
  19496. case 0:
  19497. xform = new DrawingXform();
  19498. _context7.next = 3;
  19499. return xform.parseStream(entry);
  19500. case 3:
  19501. drawing = _context7.sent;
  19502. model.drawings[name] = drawing;
  19503. case 5:
  19504. case "end":
  19505. return _context7.stop();
  19506. }
  19507. }
  19508. }, _callee7);
  19509. }));
  19510. function _processDrawingEntry(_x20, _x21, _x22) {
  19511. return _processDrawingEntry2.apply(this, arguments);
  19512. }
  19513. return _processDrawingEntry;
  19514. }()
  19515. }, {
  19516. key: "_processDrawingRelsEntry",
  19517. value: function () {
  19518. var _processDrawingRelsEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(entry, model, name) {
  19519. var xform, relationships;
  19520. return regeneratorRuntime.wrap(function _callee8$(_context8) {
  19521. while (1) {
  19522. switch (_context8.prev = _context8.next) {
  19523. case 0:
  19524. xform = new RelationshipsXform();
  19525. _context8.next = 3;
  19526. return xform.parseStream(entry);
  19527. case 3:
  19528. relationships = _context8.sent;
  19529. model.drawingRels[name] = relationships;
  19530. case 5:
  19531. case "end":
  19532. return _context8.stop();
  19533. }
  19534. }
  19535. }, _callee8);
  19536. }));
  19537. function _processDrawingRelsEntry(_x23, _x24, _x25) {
  19538. return _processDrawingRelsEntry2.apply(this, arguments);
  19539. }
  19540. return _processDrawingRelsEntry;
  19541. }()
  19542. }, {
  19543. key: "_processVmlDrawingEntry",
  19544. value: function () {
  19545. var _processVmlDrawingEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(entry, model, name) {
  19546. var xform, vmlDrawing;
  19547. return regeneratorRuntime.wrap(function _callee9$(_context9) {
  19548. while (1) {
  19549. switch (_context9.prev = _context9.next) {
  19550. case 0:
  19551. xform = new VmlNotesXform();
  19552. _context9.next = 3;
  19553. return xform.parseStream(entry);
  19554. case 3:
  19555. vmlDrawing = _context9.sent;
  19556. model.vmlDrawings["../drawings/".concat(name, ".vml")] = vmlDrawing;
  19557. case 5:
  19558. case "end":
  19559. return _context9.stop();
  19560. }
  19561. }
  19562. }, _callee9);
  19563. }));
  19564. function _processVmlDrawingEntry(_x26, _x27, _x28) {
  19565. return _processVmlDrawingEntry2.apply(this, arguments);
  19566. }
  19567. return _processVmlDrawingEntry;
  19568. }()
  19569. }, {
  19570. key: "_processThemeEntry",
  19571. value: function () {
  19572. var _processThemeEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(entry, model, name) {
  19573. return regeneratorRuntime.wrap(function _callee10$(_context10) {
  19574. while (1) {
  19575. switch (_context10.prev = _context10.next) {
  19576. case 0:
  19577. _context10.next = 2;
  19578. return new Promise(function (resolve, reject) {
  19579. // TODO: stream entry into buffer and store the xml in the model.themes[]
  19580. var stream = new StreamBuf();
  19581. entry.on('error', reject);
  19582. stream.on('error', reject);
  19583. stream.on('finish', function () {
  19584. model.themes[name] = stream.read().toString();
  19585. resolve();
  19586. });
  19587. entry.pipe(stream);
  19588. });
  19589. case 2:
  19590. case "end":
  19591. return _context10.stop();
  19592. }
  19593. }
  19594. }, _callee10);
  19595. }));
  19596. function _processThemeEntry(_x29, _x30, _x31) {
  19597. return _processThemeEntry2.apply(this, arguments);
  19598. }
  19599. return _processThemeEntry;
  19600. }()
  19601. /**
  19602. * @deprecated since version 4.0. You should use `#read` instead. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md
  19603. */
  19604. }, {
  19605. key: "createInputStream",
  19606. value: function createInputStream() {
  19607. throw new Error('`XLSX#createInputStream` is deprecated. You should use `XLSX#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md');
  19608. }
  19609. }, {
  19610. key: "read",
  19611. value: function () {
  19612. var _read = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(stream, options) {
  19613. var chunks, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk;
  19614. return regeneratorRuntime.wrap(function _callee11$(_context11) {
  19615. while (1) {
  19616. switch (_context11.prev = _context11.next) {
  19617. case 0:
  19618. // TODO: Remove once node v8 is deprecated
  19619. // Detect and upgrade old streams
  19620. if (!stream[Symbol.asyncIterator] && stream.pipe) {
  19621. stream = stream.pipe(new PassThrough());
  19622. }
  19623. chunks = [];
  19624. _iteratorNormalCompletion = true;
  19625. _didIteratorError = false;
  19626. _context11.prev = 4;
  19627. _iterator = _asyncIterator(stream);
  19628. case 6:
  19629. _context11.next = 8;
  19630. return _iterator.next();
  19631. case 8:
  19632. _step = _context11.sent;
  19633. _iteratorNormalCompletion = _step.done;
  19634. _context11.next = 12;
  19635. return _step.value;
  19636. case 12:
  19637. _value = _context11.sent;
  19638. if (_iteratorNormalCompletion) {
  19639. _context11.next = 19;
  19640. break;
  19641. }
  19642. chunk = _value;
  19643. chunks.push(chunk);
  19644. case 16:
  19645. _iteratorNormalCompletion = true;
  19646. _context11.next = 6;
  19647. break;
  19648. case 19:
  19649. _context11.next = 25;
  19650. break;
  19651. case 21:
  19652. _context11.prev = 21;
  19653. _context11.t0 = _context11["catch"](4);
  19654. _didIteratorError = true;
  19655. _iteratorError = _context11.t0;
  19656. case 25:
  19657. _context11.prev = 25;
  19658. _context11.prev = 26;
  19659. if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
  19660. _context11.next = 30;
  19661. break;
  19662. }
  19663. _context11.next = 30;
  19664. return _iterator.return();
  19665. case 30:
  19666. _context11.prev = 30;
  19667. if (!_didIteratorError) {
  19668. _context11.next = 33;
  19669. break;
  19670. }
  19671. throw _iteratorError;
  19672. case 33:
  19673. return _context11.finish(30);
  19674. case 34:
  19675. return _context11.finish(25);
  19676. case 35:
  19677. return _context11.abrupt("return", this.load(Buffer.concat(chunks), options));
  19678. case 36:
  19679. case "end":
  19680. return _context11.stop();
  19681. }
  19682. }
  19683. }, _callee11, this, [[4, 21, 25, 35], [26, , 30, 34]]);
  19684. }));
  19685. function read(_x32, _x33) {
  19686. return _read.apply(this, arguments);
  19687. }
  19688. return read;
  19689. }()
  19690. }, {
  19691. key: "load",
  19692. value: function () {
  19693. var _load = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(data, options) {
  19694. var buffer, model, zip, _i, _Object$values, entry, entryName, stream, content, chunkSize, i, workbook, appXform, appProperties, coreXform, coreProperties, match;
  19695. return regeneratorRuntime.wrap(function _callee12$(_context12) {
  19696. while (1) {
  19697. switch (_context12.prev = _context12.next) {
  19698. case 0:
  19699. if (options && options.base64) {
  19700. buffer = Buffer.from(data.toString(), 'base64');
  19701. } else {
  19702. buffer = data;
  19703. }
  19704. model = {
  19705. worksheets: [],
  19706. worksheetHash: {},
  19707. worksheetRels: [],
  19708. themes: {},
  19709. media: [],
  19710. mediaIndex: {},
  19711. drawings: {},
  19712. drawingRels: {},
  19713. comments: {},
  19714. tables: {},
  19715. vmlDrawings: {}
  19716. };
  19717. _context12.next = 4;
  19718. return JSZip.loadAsync(buffer);
  19719. case 4:
  19720. zip = _context12.sent;
  19721. _i = 0, _Object$values = Object.values(zip.files);
  19722. case 6:
  19723. if (!(_i < _Object$values.length)) {
  19724. _context12.next = 126;
  19725. break;
  19726. }
  19727. entry = _Object$values[_i];
  19728. if (entry.dir) {
  19729. _context12.next = 123;
  19730. break;
  19731. }
  19732. entryName = entry.name;
  19733. if (entryName[0] === '/') {
  19734. entryName = entryName.substr(1);
  19735. }
  19736. stream = void 0;
  19737. if (!(entryName.match(/xl\/media\//) || // themes are not parsed as stream
  19738. entryName.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/))) {
  19739. _context12.next = 21;
  19740. break;
  19741. }
  19742. stream = new PassThrough();
  19743. _context12.t0 = stream;
  19744. _context12.next = 17;
  19745. return entry.async('nodebuffer');
  19746. case 17:
  19747. _context12.t1 = _context12.sent;
  19748. _context12.t0.write.call(_context12.t0, _context12.t1);
  19749. _context12.next = 36;
  19750. break;
  19751. case 21:
  19752. // use object mode to avoid buffer-string convention
  19753. stream = new PassThrough({
  19754. writableObjectMode: true,
  19755. readableObjectMode: true
  19756. });
  19757. content = void 0; // https://www.npmjs.com/package/process
  19758. if (!process.browser) {
  19759. _context12.next = 31;
  19760. break;
  19761. }
  19762. _context12.t2 = bufferToString;
  19763. _context12.next = 27;
  19764. return entry.async('nodebuffer');
  19765. case 27:
  19766. _context12.t3 = _context12.sent;
  19767. content = (0, _context12.t2)(_context12.t3);
  19768. _context12.next = 34;
  19769. break;
  19770. case 31:
  19771. _context12.next = 33;
  19772. return entry.async('string');
  19773. case 33:
  19774. content = _context12.sent;
  19775. case 34:
  19776. chunkSize = 16 * 1024;
  19777. for (i = 0; i < content.length; i += chunkSize) {
  19778. stream.write(content.substring(i, i + chunkSize));
  19779. }
  19780. case 36:
  19781. stream.end();
  19782. _context12.t4 = entryName;
  19783. _context12.next = _context12.t4 === '_rels/.rels' ? 40 : _context12.t4 === 'xl/workbook.xml' ? 44 : _context12.t4 === 'xl/_rels/workbook.xml.rels' ? 53 : _context12.t4 === 'xl/sharedStrings.xml' ? 57 : _context12.t4 === 'xl/styles.xml' ? 61 : _context12.t4 === 'docProps/app.xml' ? 65 : _context12.t4 === 'docProps/core.xml' ? 72 : 78;
  19784. break;
  19785. case 40:
  19786. _context12.next = 42;
  19787. return this.parseRels(stream);
  19788. case 42:
  19789. model.globalRels = _context12.sent;
  19790. return _context12.abrupt("break", 123);
  19791. case 44:
  19792. _context12.next = 46;
  19793. return this.parseWorkbook(stream);
  19794. case 46:
  19795. workbook = _context12.sent;
  19796. model.sheets = workbook.sheets;
  19797. model.definedNames = workbook.definedNames;
  19798. model.views = workbook.views;
  19799. model.properties = workbook.properties;
  19800. model.calcProperties = workbook.calcProperties;
  19801. return _context12.abrupt("break", 123);
  19802. case 53:
  19803. _context12.next = 55;
  19804. return this.parseRels(stream);
  19805. case 55:
  19806. model.workbookRels = _context12.sent;
  19807. return _context12.abrupt("break", 123);
  19808. case 57:
  19809. model.sharedStrings = new SharedStringsXform();
  19810. _context12.next = 60;
  19811. return model.sharedStrings.parseStream(stream);
  19812. case 60:
  19813. return _context12.abrupt("break", 123);
  19814. case 61:
  19815. model.styles = new StylesXform();
  19816. _context12.next = 64;
  19817. return model.styles.parseStream(stream);
  19818. case 64:
  19819. return _context12.abrupt("break", 123);
  19820. case 65:
  19821. appXform = new AppXform();
  19822. _context12.next = 68;
  19823. return appXform.parseStream(stream);
  19824. case 68:
  19825. appProperties = _context12.sent;
  19826. model.company = appProperties.company;
  19827. model.manager = appProperties.manager;
  19828. return _context12.abrupt("break", 123);
  19829. case 72:
  19830. coreXform = new CoreXform();
  19831. _context12.next = 75;
  19832. return coreXform.parseStream(stream);
  19833. case 75:
  19834. coreProperties = _context12.sent;
  19835. Object.assign(model, coreProperties);
  19836. return _context12.abrupt("break", 123);
  19837. case 78:
  19838. match = entryName.match(/xl\/worksheets\/sheet(\d+)[.]xml/);
  19839. if (!match) {
  19840. _context12.next = 83;
  19841. break;
  19842. }
  19843. _context12.next = 82;
  19844. return this._processWorksheetEntry(stream, model, match[1], options, entryName);
  19845. case 82:
  19846. return _context12.abrupt("break", 123);
  19847. case 83:
  19848. match = entryName.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml.rels/);
  19849. if (!match) {
  19850. _context12.next = 88;
  19851. break;
  19852. }
  19853. _context12.next = 87;
  19854. return this._processWorksheetRelsEntry(stream, model, match[1]);
  19855. case 87:
  19856. return _context12.abrupt("break", 123);
  19857. case 88:
  19858. match = entryName.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/);
  19859. if (!match) {
  19860. _context12.next = 93;
  19861. break;
  19862. }
  19863. _context12.next = 92;
  19864. return this._processThemeEntry(stream, model, match[1]);
  19865. case 92:
  19866. return _context12.abrupt("break", 123);
  19867. case 93:
  19868. match = entryName.match(/xl\/media\/([a-zA-Z0-9]+[.][a-zA-Z0-9]{3,4})$/);
  19869. if (!match) {
  19870. _context12.next = 98;
  19871. break;
  19872. }
  19873. _context12.next = 97;
  19874. return this._processMediaEntry(stream, model, match[1]);
  19875. case 97:
  19876. return _context12.abrupt("break", 123);
  19877. case 98:
  19878. match = entryName.match(/xl\/drawings\/([a-zA-Z0-9]+)[.]xml/);
  19879. if (!match) {
  19880. _context12.next = 103;
  19881. break;
  19882. }
  19883. _context12.next = 102;
  19884. return this._processDrawingEntry(stream, model, match[1]);
  19885. case 102:
  19886. return _context12.abrupt("break", 123);
  19887. case 103:
  19888. match = entryName.match(/xl\/(comments\d+)[.]xml/);
  19889. if (!match) {
  19890. _context12.next = 108;
  19891. break;
  19892. }
  19893. _context12.next = 107;
  19894. return this._processCommentEntry(stream, model, match[1]);
  19895. case 107:
  19896. return _context12.abrupt("break", 123);
  19897. case 108:
  19898. match = entryName.match(/xl\/tables\/(table\d+)[.]xml/);
  19899. if (!match) {
  19900. _context12.next = 113;
  19901. break;
  19902. }
  19903. _context12.next = 112;
  19904. return this._processTableEntry(stream, model, match[1]);
  19905. case 112:
  19906. return _context12.abrupt("break", 123);
  19907. case 113:
  19908. match = entryName.match(/xl\/drawings\/_rels\/([a-zA-Z0-9]+)[.]xml[.]rels/);
  19909. if (!match) {
  19910. _context12.next = 118;
  19911. break;
  19912. }
  19913. _context12.next = 117;
  19914. return this._processDrawingRelsEntry(stream, model, match[1]);
  19915. case 117:
  19916. return _context12.abrupt("break", 123);
  19917. case 118:
  19918. match = entryName.match(/xl\/drawings\/(vmlDrawing\d+)[.]vml/);
  19919. if (!match) {
  19920. _context12.next = 123;
  19921. break;
  19922. }
  19923. _context12.next = 122;
  19924. return this._processVmlDrawingEntry(stream, model, match[1]);
  19925. case 122:
  19926. return _context12.abrupt("break", 123);
  19927. case 123:
  19928. _i++;
  19929. _context12.next = 6;
  19930. break;
  19931. case 126:
  19932. this.reconcile(model, options); // apply model
  19933. this.workbook.model = model;
  19934. return _context12.abrupt("return", this.workbook);
  19935. case 129:
  19936. case "end":
  19937. return _context12.stop();
  19938. }
  19939. }
  19940. }, _callee12, this);
  19941. }));
  19942. function load(_x34, _x35) {
  19943. return _load.apply(this, arguments);
  19944. }
  19945. return load;
  19946. }() // =========================================================================
  19947. // Write
  19948. }, {
  19949. key: "addMedia",
  19950. value: function () {
  19951. var _addMedia = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(zip, model) {
  19952. return regeneratorRuntime.wrap(function _callee14$(_context14) {
  19953. while (1) {
  19954. switch (_context14.prev = _context14.next) {
  19955. case 0:
  19956. _context14.next = 2;
  19957. return Promise.all(model.media.map( /*#__PURE__*/function () {
  19958. var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(medium) {
  19959. var filename, data, dataimg64, content;
  19960. return regeneratorRuntime.wrap(function _callee13$(_context13) {
  19961. while (1) {
  19962. switch (_context13.prev = _context13.next) {
  19963. case 0:
  19964. if (!(medium.type === 'image')) {
  19965. _context13.next = 13;
  19966. break;
  19967. }
  19968. filename = "xl/media/".concat(medium.name, ".").concat(medium.extension);
  19969. if (!medium.filename) {
  19970. _context13.next = 7;
  19971. break;
  19972. }
  19973. _context13.next = 5;
  19974. return fsReadFileAsync(medium.filename);
  19975. case 5:
  19976. data = _context13.sent;
  19977. return _context13.abrupt("return", zip.append(data, {
  19978. name: filename
  19979. }));
  19980. case 7:
  19981. if (!medium.buffer) {
  19982. _context13.next = 9;
  19983. break;
  19984. }
  19985. return _context13.abrupt("return", zip.append(medium.buffer, {
  19986. name: filename
  19987. }));
  19988. case 9:
  19989. if (!medium.base64) {
  19990. _context13.next = 13;
  19991. break;
  19992. }
  19993. dataimg64 = medium.base64;
  19994. content = dataimg64.substring(dataimg64.indexOf(',') + 1);
  19995. return _context13.abrupt("return", zip.append(content, {
  19996. name: filename,
  19997. base64: true
  19998. }));
  19999. case 13:
  20000. throw new Error('Unsupported media');
  20001. case 14:
  20002. case "end":
  20003. return _context13.stop();
  20004. }
  20005. }
  20006. }, _callee13);
  20007. }));
  20008. return function (_x38) {
  20009. return _ref.apply(this, arguments);
  20010. };
  20011. }()));
  20012. case 2:
  20013. case "end":
  20014. return _context14.stop();
  20015. }
  20016. }
  20017. }, _callee14);
  20018. }));
  20019. function addMedia(_x36, _x37) {
  20020. return _addMedia.apply(this, arguments);
  20021. }
  20022. return addMedia;
  20023. }()
  20024. }, {
  20025. key: "addDrawings",
  20026. value: function addDrawings(zip, model) {
  20027. var drawingXform = new DrawingXform();
  20028. var relsXform = new RelationshipsXform();
  20029. model.worksheets.forEach(function (worksheet) {
  20030. var drawing = worksheet.drawing;
  20031. if (drawing) {
  20032. drawingXform.prepare(drawing, {});
  20033. var xml = drawingXform.toXml(drawing);
  20034. zip.append(xml, {
  20035. name: "xl/drawings/".concat(drawing.name, ".xml")
  20036. });
  20037. xml = relsXform.toXml(drawing.rels);
  20038. zip.append(xml, {
  20039. name: "xl/drawings/_rels/".concat(drawing.name, ".xml.rels")
  20040. });
  20041. }
  20042. });
  20043. }
  20044. }, {
  20045. key: "addTables",
  20046. value: function addTables(zip, model) {
  20047. var tableXform = new TableXform();
  20048. model.worksheets.forEach(function (worksheet) {
  20049. var tables = worksheet.tables;
  20050. tables.forEach(function (table) {
  20051. tableXform.prepare(table, {});
  20052. var tableXml = tableXform.toXml(table);
  20053. zip.append(tableXml, {
  20054. name: "xl/tables/".concat(table.target)
  20055. });
  20056. });
  20057. });
  20058. }
  20059. }, {
  20060. key: "addContentTypes",
  20061. value: function () {
  20062. var _addContentTypes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(zip, model) {
  20063. var xform, xml;
  20064. return regeneratorRuntime.wrap(function _callee15$(_context15) {
  20065. while (1) {
  20066. switch (_context15.prev = _context15.next) {
  20067. case 0:
  20068. xform = new ContentTypesXform();
  20069. xml = xform.toXml(model);
  20070. zip.append(xml, {
  20071. name: '[Content_Types].xml'
  20072. });
  20073. case 3:
  20074. case "end":
  20075. return _context15.stop();
  20076. }
  20077. }
  20078. }, _callee15);
  20079. }));
  20080. function addContentTypes(_x39, _x40) {
  20081. return _addContentTypes.apply(this, arguments);
  20082. }
  20083. return addContentTypes;
  20084. }()
  20085. }, {
  20086. key: "addApp",
  20087. value: function () {
  20088. var _addApp = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(zip, model) {
  20089. var xform, xml;
  20090. return regeneratorRuntime.wrap(function _callee16$(_context16) {
  20091. while (1) {
  20092. switch (_context16.prev = _context16.next) {
  20093. case 0:
  20094. xform = new AppXform();
  20095. xml = xform.toXml(model);
  20096. zip.append(xml, {
  20097. name: 'docProps/app.xml'
  20098. });
  20099. case 3:
  20100. case "end":
  20101. return _context16.stop();
  20102. }
  20103. }
  20104. }, _callee16);
  20105. }));
  20106. function addApp(_x41, _x42) {
  20107. return _addApp.apply(this, arguments);
  20108. }
  20109. return addApp;
  20110. }()
  20111. }, {
  20112. key: "addCore",
  20113. value: function () {
  20114. var _addCore = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(zip, model) {
  20115. var coreXform;
  20116. return regeneratorRuntime.wrap(function _callee17$(_context17) {
  20117. while (1) {
  20118. switch (_context17.prev = _context17.next) {
  20119. case 0:
  20120. coreXform = new CoreXform();
  20121. zip.append(coreXform.toXml(model), {
  20122. name: 'docProps/core.xml'
  20123. });
  20124. case 2:
  20125. case "end":
  20126. return _context17.stop();
  20127. }
  20128. }
  20129. }, _callee17);
  20130. }));
  20131. function addCore(_x43, _x44) {
  20132. return _addCore.apply(this, arguments);
  20133. }
  20134. return addCore;
  20135. }()
  20136. }, {
  20137. key: "addThemes",
  20138. value: function () {
  20139. var _addThemes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18(zip, model) {
  20140. var themes;
  20141. return regeneratorRuntime.wrap(function _callee18$(_context18) {
  20142. while (1) {
  20143. switch (_context18.prev = _context18.next) {
  20144. case 0:
  20145. themes = model.themes || {
  20146. theme1: theme1Xml
  20147. };
  20148. Object.keys(themes).forEach(function (name) {
  20149. var xml = themes[name];
  20150. var path = "xl/theme/".concat(name, ".xml");
  20151. zip.append(xml, {
  20152. name: path
  20153. });
  20154. });
  20155. case 2:
  20156. case "end":
  20157. return _context18.stop();
  20158. }
  20159. }
  20160. }, _callee18);
  20161. }));
  20162. function addThemes(_x45, _x46) {
  20163. return _addThemes.apply(this, arguments);
  20164. }
  20165. return addThemes;
  20166. }()
  20167. }, {
  20168. key: "addOfficeRels",
  20169. value: function () {
  20170. var _addOfficeRels = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19(zip) {
  20171. var xform, xml;
  20172. return regeneratorRuntime.wrap(function _callee19$(_context19) {
  20173. while (1) {
  20174. switch (_context19.prev = _context19.next) {
  20175. case 0:
  20176. xform = new RelationshipsXform();
  20177. xml = xform.toXml([{
  20178. Id: 'rId1',
  20179. Type: XLSX.RelType.OfficeDocument,
  20180. Target: 'xl/workbook.xml'
  20181. }, {
  20182. Id: 'rId2',
  20183. Type: XLSX.RelType.CoreProperties,
  20184. Target: 'docProps/core.xml'
  20185. }, {
  20186. Id: 'rId3',
  20187. Type: XLSX.RelType.ExtenderProperties,
  20188. Target: 'docProps/app.xml'
  20189. }]);
  20190. zip.append(xml, {
  20191. name: '_rels/.rels'
  20192. });
  20193. case 3:
  20194. case "end":
  20195. return _context19.stop();
  20196. }
  20197. }
  20198. }, _callee19);
  20199. }));
  20200. function addOfficeRels(_x47) {
  20201. return _addOfficeRels.apply(this, arguments);
  20202. }
  20203. return addOfficeRels;
  20204. }()
  20205. }, {
  20206. key: "addWorkbookRels",
  20207. value: function () {
  20208. var _addWorkbookRels = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(zip, model) {
  20209. var count, relationships, xform, xml;
  20210. return regeneratorRuntime.wrap(function _callee20$(_context20) {
  20211. while (1) {
  20212. switch (_context20.prev = _context20.next) {
  20213. case 0:
  20214. count = 1;
  20215. relationships = [{
  20216. Id: "rId".concat(count++),
  20217. Type: XLSX.RelType.Styles,
  20218. Target: 'styles.xml'
  20219. }, {
  20220. Id: "rId".concat(count++),
  20221. Type: XLSX.RelType.Theme,
  20222. Target: 'theme/theme1.xml'
  20223. }];
  20224. if (model.sharedStrings.count) {
  20225. relationships.push({
  20226. Id: "rId".concat(count++),
  20227. Type: XLSX.RelType.SharedStrings,
  20228. Target: 'sharedStrings.xml'
  20229. });
  20230. }
  20231. model.worksheets.forEach(function (worksheet) {
  20232. worksheet.rId = "rId".concat(count++);
  20233. relationships.push({
  20234. Id: worksheet.rId,
  20235. Type: XLSX.RelType.Worksheet,
  20236. Target: "worksheets/sheet".concat(worksheet.id, ".xml")
  20237. });
  20238. });
  20239. xform = new RelationshipsXform();
  20240. xml = xform.toXml(relationships);
  20241. zip.append(xml, {
  20242. name: 'xl/_rels/workbook.xml.rels'
  20243. });
  20244. case 7:
  20245. case "end":
  20246. return _context20.stop();
  20247. }
  20248. }
  20249. }, _callee20);
  20250. }));
  20251. function addWorkbookRels(_x48, _x49) {
  20252. return _addWorkbookRels.apply(this, arguments);
  20253. }
  20254. return addWorkbookRels;
  20255. }()
  20256. }, {
  20257. key: "addSharedStrings",
  20258. value: function () {
  20259. var _addSharedStrings = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21(zip, model) {
  20260. return regeneratorRuntime.wrap(function _callee21$(_context21) {
  20261. while (1) {
  20262. switch (_context21.prev = _context21.next) {
  20263. case 0:
  20264. if (model.sharedStrings && model.sharedStrings.count) {
  20265. zip.append(model.sharedStrings.xml, {
  20266. name: 'xl/sharedStrings.xml'
  20267. });
  20268. }
  20269. case 1:
  20270. case "end":
  20271. return _context21.stop();
  20272. }
  20273. }
  20274. }, _callee21);
  20275. }));
  20276. function addSharedStrings(_x50, _x51) {
  20277. return _addSharedStrings.apply(this, arguments);
  20278. }
  20279. return addSharedStrings;
  20280. }()
  20281. }, {
  20282. key: "addStyles",
  20283. value: function () {
  20284. var _addStyles = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22(zip, model) {
  20285. var xml;
  20286. return regeneratorRuntime.wrap(function _callee22$(_context22) {
  20287. while (1) {
  20288. switch (_context22.prev = _context22.next) {
  20289. case 0:
  20290. xml = model.styles.xml;
  20291. if (xml) {
  20292. zip.append(xml, {
  20293. name: 'xl/styles.xml'
  20294. });
  20295. }
  20296. case 2:
  20297. case "end":
  20298. return _context22.stop();
  20299. }
  20300. }
  20301. }, _callee22);
  20302. }));
  20303. function addStyles(_x52, _x53) {
  20304. return _addStyles.apply(this, arguments);
  20305. }
  20306. return addStyles;
  20307. }()
  20308. }, {
  20309. key: "addWorkbook",
  20310. value: function () {
  20311. var _addWorkbook = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(zip, model) {
  20312. var xform;
  20313. return regeneratorRuntime.wrap(function _callee23$(_context23) {
  20314. while (1) {
  20315. switch (_context23.prev = _context23.next) {
  20316. case 0:
  20317. xform = new WorkbookXform();
  20318. zip.append(xform.toXml(model), {
  20319. name: 'xl/workbook.xml'
  20320. });
  20321. case 2:
  20322. case "end":
  20323. return _context23.stop();
  20324. }
  20325. }
  20326. }, _callee23);
  20327. }));
  20328. function addWorkbook(_x54, _x55) {
  20329. return _addWorkbook.apply(this, arguments);
  20330. }
  20331. return addWorkbook;
  20332. }()
  20333. }, {
  20334. key: "addWorksheets",
  20335. value: function () {
  20336. var _addWorksheets = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24(zip, model) {
  20337. var worksheetXform, relationshipsXform, commentsXform, vmlNotesXform;
  20338. return regeneratorRuntime.wrap(function _callee24$(_context24) {
  20339. while (1) {
  20340. switch (_context24.prev = _context24.next) {
  20341. case 0:
  20342. // preparation phase
  20343. worksheetXform = new WorksheetXform();
  20344. relationshipsXform = new RelationshipsXform();
  20345. commentsXform = new CommentsXform();
  20346. vmlNotesXform = new VmlNotesXform(); // write sheets
  20347. model.worksheets.forEach(function (worksheet) {
  20348. var xmlStream = new XmlStream();
  20349. worksheetXform.render(xmlStream, worksheet);
  20350. zip.append(xmlStream.xml, {
  20351. name: "xl/worksheets/sheet".concat(worksheet.id, ".xml")
  20352. });
  20353. if (worksheet.rels && worksheet.rels.length) {
  20354. xmlStream = new XmlStream();
  20355. relationshipsXform.render(xmlStream, worksheet.rels);
  20356. zip.append(xmlStream.xml, {
  20357. name: "xl/worksheets/_rels/sheet".concat(worksheet.id, ".xml.rels")
  20358. });
  20359. }
  20360. if (worksheet.comments.length > 0) {
  20361. xmlStream = new XmlStream();
  20362. commentsXform.render(xmlStream, worksheet);
  20363. zip.append(xmlStream.xml, {
  20364. name: "xl/comments".concat(worksheet.id, ".xml")
  20365. });
  20366. xmlStream = new XmlStream();
  20367. vmlNotesXform.render(xmlStream, worksheet);
  20368. zip.append(xmlStream.xml, {
  20369. name: "xl/drawings/vmlDrawing".concat(worksheet.id, ".vml")
  20370. });
  20371. }
  20372. });
  20373. case 5:
  20374. case "end":
  20375. return _context24.stop();
  20376. }
  20377. }
  20378. }, _callee24);
  20379. }));
  20380. function addWorksheets(_x56, _x57) {
  20381. return _addWorksheets.apply(this, arguments);
  20382. }
  20383. return addWorksheets;
  20384. }()
  20385. }, {
  20386. key: "_finalize",
  20387. value: function _finalize(zip) {
  20388. var _this = this;
  20389. return new Promise(function (resolve, reject) {
  20390. zip.on('finish', function () {
  20391. resolve(_this);
  20392. });
  20393. zip.on('error', reject);
  20394. zip.finalize();
  20395. });
  20396. }
  20397. }, {
  20398. key: "prepareModel",
  20399. value: function prepareModel(model, options) {
  20400. // ensure following properties have sane values
  20401. model.creator = model.creator || 'ExcelJS';
  20402. model.lastModifiedBy = model.lastModifiedBy || 'ExcelJS';
  20403. model.created = model.created || new Date();
  20404. model.modified = model.modified || new Date();
  20405. model.useSharedStrings = options.useSharedStrings !== undefined ? options.useSharedStrings : true;
  20406. model.useStyles = options.useStyles !== undefined ? options.useStyles : true; // Manage the shared strings
  20407. model.sharedStrings = new SharedStringsXform(); // add a style manager to handle cell formats, fonts, etc.
  20408. model.styles = model.useStyles ? new StylesXform(true) : new StylesXform.Mock(); // prepare all of the things before the render
  20409. var workbookXform = new WorkbookXform();
  20410. var worksheetXform = new WorksheetXform();
  20411. workbookXform.prepare(model);
  20412. var worksheetOptions = {
  20413. sharedStrings: model.sharedStrings,
  20414. styles: model.styles,
  20415. date1904: model.properties.date1904,
  20416. drawingsCount: 0,
  20417. media: model.media
  20418. };
  20419. worksheetOptions.drawings = model.drawings = [];
  20420. worksheetOptions.commentRefs = model.commentRefs = [];
  20421. var tableCount = 0;
  20422. model.tables = [];
  20423. model.worksheets.forEach(function (worksheet) {
  20424. // assign unique filenames to tables
  20425. worksheet.tables.forEach(function (table) {
  20426. tableCount++;
  20427. table.target = "table".concat(tableCount, ".xml");
  20428. table.id = tableCount;
  20429. model.tables.push(table);
  20430. });
  20431. worksheetXform.prepare(worksheet, worksheetOptions);
  20432. }); // TODO: workbook drawing list
  20433. }
  20434. }, {
  20435. key: "write",
  20436. value: function () {
  20437. var _write = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25(stream, options) {
  20438. var model, zip;
  20439. return regeneratorRuntime.wrap(function _callee25$(_context25) {
  20440. while (1) {
  20441. switch (_context25.prev = _context25.next) {
  20442. case 0:
  20443. options = options || {};
  20444. model = this.workbook.model;
  20445. zip = new ZipStream.ZipWriter(options.zip);
  20446. zip.pipe(stream);
  20447. this.prepareModel(model, options); // render
  20448. _context25.next = 7;
  20449. return this.addContentTypes(zip, model);
  20450. case 7:
  20451. _context25.next = 9;
  20452. return this.addOfficeRels(zip, model);
  20453. case 9:
  20454. _context25.next = 11;
  20455. return this.addWorkbookRels(zip, model);
  20456. case 11:
  20457. _context25.next = 13;
  20458. return this.addWorksheets(zip, model);
  20459. case 13:
  20460. _context25.next = 15;
  20461. return this.addSharedStrings(zip, model);
  20462. case 15:
  20463. _context25.next = 17;
  20464. return this.addDrawings(zip, model);
  20465. case 17:
  20466. _context25.next = 19;
  20467. return this.addTables(zip, model);
  20468. case 19:
  20469. _context25.next = 21;
  20470. return Promise.all([this.addThemes(zip, model), this.addStyles(zip, model)]);
  20471. case 21:
  20472. _context25.next = 23;
  20473. return this.addMedia(zip, model);
  20474. case 23:
  20475. _context25.next = 25;
  20476. return Promise.all([this.addApp(zip, model), this.addCore(zip, model)]);
  20477. case 25:
  20478. _context25.next = 27;
  20479. return this.addWorkbook(zip, model);
  20480. case 27:
  20481. return _context25.abrupt("return", this._finalize(zip));
  20482. case 28:
  20483. case "end":
  20484. return _context25.stop();
  20485. }
  20486. }
  20487. }, _callee25, this);
  20488. }));
  20489. function write(_x58, _x59) {
  20490. return _write.apply(this, arguments);
  20491. }
  20492. return write;
  20493. }()
  20494. }, {
  20495. key: "writeFile",
  20496. value: function writeFile(filename, options) {
  20497. var _this2 = this;
  20498. var stream = fs.createWriteStream(filename);
  20499. return new Promise(function (resolve, reject) {
  20500. stream.on('finish', function () {
  20501. resolve();
  20502. });
  20503. stream.on('error', function (error) {
  20504. reject(error);
  20505. });
  20506. _this2.write(stream, options).then(function () {
  20507. stream.end();
  20508. });
  20509. });
  20510. }
  20511. }, {
  20512. key: "writeBuffer",
  20513. value: function () {
  20514. var _writeBuffer = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26(options) {
  20515. var stream;
  20516. return regeneratorRuntime.wrap(function _callee26$(_context26) {
  20517. while (1) {
  20518. switch (_context26.prev = _context26.next) {
  20519. case 0:
  20520. stream = new StreamBuf();
  20521. _context26.next = 3;
  20522. return this.write(stream, options);
  20523. case 3:
  20524. return _context26.abrupt("return", stream.read());
  20525. case 4:
  20526. case "end":
  20527. return _context26.stop();
  20528. }
  20529. }
  20530. }, _callee26, this);
  20531. }));
  20532. function writeBuffer(_x60) {
  20533. return _writeBuffer.apply(this, arguments);
  20534. }
  20535. return writeBuffer;
  20536. }()
  20537. }]);
  20538. return XLSX;
  20539. }();
  20540. XLSX.RelType = require('./rel-type');
  20541. module.exports = XLSX;
  20542. }).call(this, require('_process'), require("buffer").Buffer)
  20543. }, { "../utils/browser-buffer-decode": 16, "../utils/stream-buf": 23, "../utils/utils": 26, "../utils/xml-stream": 27, "../utils/zip-stream": 28, "./rel-type": 30, "./xform/book/workbook-xform": 37, "./xform/comment/comments-xform": 39, "./xform/comment/vml-notes-xform": 44, "./xform/core/app-xform": 50, "./xform/core/content-types-xform": 51, "./xform/core/core-xform": 52, "./xform/core/relationships-xform": 54, "./xform/drawing/drawing-xform": 61, "./xform/sheet/worksheet-xform": 114, "./xform/strings/shared-strings-xform": 123, "./xform/style/styles-xform": 134, "./xform/table/table-xform": 140, "./xml/theme1.js": 142, "_process": 467, "buffer": 216, "fs": 215, "jszip": 399, "readable-stream": 491 }], 142: [function (require, module, exports) {
  20544. "use strict";
  20545. /* eslint-disable */
  20546. module.exports = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>';
  20547. }, {}], 143: [function (require, module, exports) {
  20548. (function (Buffer) {
  20549. "use strict";
  20550. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  20551. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20552. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  20553. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20554. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  20555. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  20556. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  20557. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  20558. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  20559. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  20560. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  20561. Object.defineProperty(exports, "__esModule", {
  20562. value: true
  20563. });
  20564. exports.CsvFormatterStream = void 0;
  20565. var stream_1 = require("stream");
  20566. var formatter_1 = require("./formatter");
  20567. var CsvFormatterStream = /*#__PURE__*/function (_stream_1$Transform) {
  20568. _inherits(CsvFormatterStream, _stream_1$Transform);
  20569. var _super = _createSuper(CsvFormatterStream);
  20570. function CsvFormatterStream(formatterOptions) {
  20571. var _this;
  20572. _classCallCheck(this, CsvFormatterStream);
  20573. _this = _super.call(this, {
  20574. writableObjectMode: formatterOptions.objectMode
  20575. });
  20576. _this.hasWrittenBOM = false;
  20577. _this.formatterOptions = formatterOptions;
  20578. _this.rowFormatter = new formatter_1.RowFormatter(formatterOptions); // if writeBOM is false then set to true
  20579. // if writeBOM is true then set to false by default so it is written out
  20580. _this.hasWrittenBOM = !formatterOptions.writeBOM;
  20581. return _this;
  20582. }
  20583. _createClass(CsvFormatterStream, [{
  20584. key: "transform",
  20585. value: function transform(transformFunction) {
  20586. this.rowFormatter.rowTransform = transformFunction;
  20587. return this;
  20588. }
  20589. }, {
  20590. key: "_transform",
  20591. value: function _transform(row, encoding, cb) {
  20592. var _this2 = this;
  20593. var cbCalled = false;
  20594. try {
  20595. if (!this.hasWrittenBOM) {
  20596. this.push(this.formatterOptions.BOM);
  20597. this.hasWrittenBOM = true;
  20598. }
  20599. this.rowFormatter.format(row, function (err, rows) {
  20600. if (err) {
  20601. cbCalled = true;
  20602. return cb(err);
  20603. }
  20604. if (rows) {
  20605. rows.forEach(function (r) {
  20606. _this2.push(Buffer.from(r, 'utf8'));
  20607. });
  20608. }
  20609. cbCalled = true;
  20610. return cb();
  20611. });
  20612. } catch (e) {
  20613. if (cbCalled) {
  20614. throw e;
  20615. }
  20616. cb(e);
  20617. }
  20618. }
  20619. }, {
  20620. key: "_flush",
  20621. value: function _flush(cb) {
  20622. var _this3 = this;
  20623. this.rowFormatter.finish(function (err, rows) {
  20624. if (err) {
  20625. return cb(err);
  20626. }
  20627. if (rows) {
  20628. rows.forEach(function (r) {
  20629. _this3.push(Buffer.from(r, 'utf8'));
  20630. });
  20631. }
  20632. return cb();
  20633. });
  20634. }
  20635. }]);
  20636. return CsvFormatterStream;
  20637. }(stream_1.Transform);
  20638. exports.CsvFormatterStream = CsvFormatterStream;
  20639. }).call(this, require("buffer").Buffer)
  20640. }, { "./formatter": 147, "buffer": 216, "stream": 506 }], 144: [function (require, module, exports) {
  20641. "use strict";
  20642. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20643. Object.defineProperty(exports, "__esModule", {
  20644. value: true
  20645. });
  20646. exports.FormatterOptions = void 0;
  20647. var FormatterOptions = function FormatterOptions() {
  20648. var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  20649. _classCallCheck(this, FormatterOptions);
  20650. var _a;
  20651. this.objectMode = true;
  20652. this.delimiter = ',';
  20653. this.rowDelimiter = '\n';
  20654. this.quote = '"';
  20655. this.escape = this.quote;
  20656. this.quoteColumns = false;
  20657. this.quoteHeaders = this.quoteColumns;
  20658. this.headers = null;
  20659. this.includeEndRowDelimiter = false;
  20660. this.writeBOM = false;
  20661. this.BOM = "\uFEFF";
  20662. this.alwaysWriteHeaders = false;
  20663. Object.assign(this, opts || {});
  20664. if (typeof (opts === null || opts === void 0 ? void 0 : opts.quoteHeaders) === 'undefined') {
  20665. this.quoteHeaders = this.quoteColumns;
  20666. }
  20667. if ((opts === null || opts === void 0 ? void 0 : opts.quote) === true) {
  20668. this.quote = '"';
  20669. } else if ((opts === null || opts === void 0 ? void 0 : opts.quote) === false) {
  20670. this.quote = '';
  20671. }
  20672. if (typeof (opts === null || opts === void 0 ? void 0 : opts.escape) !== 'string') {
  20673. this.escape = this.quote;
  20674. }
  20675. this.shouldWriteHeaders = !!this.headers && ((_a = opts.writeHeaders) !== null && _a !== void 0 ? _a : true);
  20676. this.headers = Array.isArray(this.headers) ? this.headers : null;
  20677. this.escapedQuote = "".concat(this.escape).concat(this.quote);
  20678. };
  20679. exports.FormatterOptions = FormatterOptions;
  20680. }, {}], 145: [function (require, module, exports) {
  20681. "use strict";
  20682. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20683. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  20684. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20685. var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  20686. return mod && mod.__esModule ? mod : {
  20687. "default": mod
  20688. };
  20689. };
  20690. Object.defineProperty(exports, "__esModule", {
  20691. value: true
  20692. });
  20693. exports.FieldFormatter = void 0;
  20694. var lodash_isboolean_1 = __importDefault(require("lodash.isboolean"));
  20695. var lodash_isnil_1 = __importDefault(require("lodash.isnil"));
  20696. var lodash_escaperegexp_1 = __importDefault(require("lodash.escaperegexp"));
  20697. var FieldFormatter = /*#__PURE__*/function () {
  20698. function FieldFormatter(formatterOptions) {
  20699. _classCallCheck(this, FieldFormatter);
  20700. this._headers = null;
  20701. this.formatterOptions = formatterOptions;
  20702. if (formatterOptions.headers !== null) {
  20703. this.headers = formatterOptions.headers;
  20704. }
  20705. this.REPLACE_REGEXP = new RegExp(formatterOptions.quote, 'g');
  20706. var escapePattern = "[".concat(formatterOptions.delimiter).concat(lodash_escaperegexp_1.default(formatterOptions.rowDelimiter), "|\r|\n']");
  20707. this.ESCAPE_REGEXP = new RegExp(escapePattern);
  20708. }
  20709. _createClass(FieldFormatter, [{
  20710. key: "shouldQuote",
  20711. value: function shouldQuote(fieldIndex, isHeader) {
  20712. var quoteConfig = isHeader ? this.formatterOptions.quoteHeaders : this.formatterOptions.quoteColumns;
  20713. if (lodash_isboolean_1.default(quoteConfig)) {
  20714. return quoteConfig;
  20715. }
  20716. if (Array.isArray(quoteConfig)) {
  20717. return quoteConfig[fieldIndex];
  20718. }
  20719. if (this._headers !== null) {
  20720. return quoteConfig[this._headers[fieldIndex]];
  20721. }
  20722. return false;
  20723. }
  20724. }, {
  20725. key: "format",
  20726. value: function format(field, fieldIndex, isHeader) {
  20727. var preparedField = "".concat(lodash_isnil_1.default(field) ? '' : field).replace(/\0/g, '');
  20728. var formatterOptions = this.formatterOptions;
  20729. if (formatterOptions.quote !== '') {
  20730. var shouldEscape = preparedField.indexOf(formatterOptions.quote) !== -1;
  20731. if (shouldEscape) {
  20732. return this.quoteField(preparedField.replace(this.REPLACE_REGEXP, formatterOptions.escapedQuote));
  20733. }
  20734. }
  20735. var hasEscapeCharacters = preparedField.search(this.ESCAPE_REGEXP) !== -1;
  20736. if (hasEscapeCharacters || this.shouldQuote(fieldIndex, isHeader)) {
  20737. return this.quoteField(preparedField);
  20738. }
  20739. return preparedField;
  20740. }
  20741. }, {
  20742. key: "quoteField",
  20743. value: function quoteField(field) {
  20744. var quote = this.formatterOptions.quote;
  20745. return "".concat(quote).concat(field).concat(quote);
  20746. }
  20747. }, {
  20748. key: "headers",
  20749. set: function set(headers) {
  20750. this._headers = headers;
  20751. }
  20752. }]);
  20753. return FieldFormatter;
  20754. }();
  20755. exports.FieldFormatter = FieldFormatter;
  20756. }, { "lodash.escaperegexp": 426, "lodash.isboolean": 428, "lodash.isnil": 431 }], 146: [function (require, module, exports) {
  20757. "use strict";
  20758. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20759. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  20760. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20761. var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  20762. return mod && mod.__esModule ? mod : {
  20763. "default": mod
  20764. };
  20765. };
  20766. Object.defineProperty(exports, "__esModule", {
  20767. value: true
  20768. });
  20769. exports.RowFormatter = void 0;
  20770. var lodash_isfunction_1 = __importDefault(require("lodash.isfunction"));
  20771. var lodash_isequal_1 = __importDefault(require("lodash.isequal"));
  20772. var FieldFormatter_1 = require("./FieldFormatter");
  20773. var types_1 = require("../types");
  20774. var RowFormatter = /*#__PURE__*/function () {
  20775. function RowFormatter(formatterOptions) {
  20776. _classCallCheck(this, RowFormatter);
  20777. this.rowCount = 0;
  20778. this.formatterOptions = formatterOptions;
  20779. this.fieldFormatter = new FieldFormatter_1.FieldFormatter(formatterOptions);
  20780. this.headers = formatterOptions.headers;
  20781. this.shouldWriteHeaders = formatterOptions.shouldWriteHeaders;
  20782. this.hasWrittenHeaders = false;
  20783. if (this.headers !== null) {
  20784. this.fieldFormatter.headers = this.headers;
  20785. }
  20786. if (formatterOptions.transform) {
  20787. this.rowTransform = formatterOptions.transform;
  20788. }
  20789. }
  20790. _createClass(RowFormatter, [{
  20791. key: "format",
  20792. value: function format(row, cb) {
  20793. var _this = this;
  20794. this.callTransformer(row, function (err, transformedRow) {
  20795. if (err) {
  20796. return cb(err);
  20797. }
  20798. if (!row) {
  20799. return cb(null);
  20800. }
  20801. var rows = [];
  20802. if (transformedRow) {
  20803. var _this$checkHeaders = _this.checkHeaders(transformedRow),
  20804. shouldFormatColumns = _this$checkHeaders.shouldFormatColumns,
  20805. headers = _this$checkHeaders.headers;
  20806. if (_this.shouldWriteHeaders && headers && !_this.hasWrittenHeaders) {
  20807. rows.push(_this.formatColumns(headers, true));
  20808. _this.hasWrittenHeaders = true;
  20809. }
  20810. if (shouldFormatColumns) {
  20811. var columns = _this.gatherColumns(transformedRow);
  20812. rows.push(_this.formatColumns(columns, false));
  20813. }
  20814. }
  20815. return cb(null, rows);
  20816. });
  20817. }
  20818. }, {
  20819. key: "finish",
  20820. value: function finish(cb) {
  20821. var rows = []; // check if we should write headers and we didnt get any rows
  20822. if (this.formatterOptions.alwaysWriteHeaders && this.rowCount === 0) {
  20823. if (!this.headers) {
  20824. return cb(new Error('`alwaysWriteHeaders` option is set to true but `headers` option not provided.'));
  20825. }
  20826. rows.push(this.formatColumns(this.headers, true));
  20827. }
  20828. if (this.formatterOptions.includeEndRowDelimiter) {
  20829. rows.push(this.formatterOptions.rowDelimiter);
  20830. }
  20831. return cb(null, rows);
  20832. } // check if we need to write header return true if we should also write a row
  20833. // could be false if headers is true and the header row(first item) is passed in
  20834. }, {
  20835. key: "checkHeaders",
  20836. value: function checkHeaders(row) {
  20837. if (this.headers) {
  20838. // either the headers were provided by the user or we have already gathered them.
  20839. return {
  20840. shouldFormatColumns: true,
  20841. headers: this.headers
  20842. };
  20843. }
  20844. var headers = RowFormatter.gatherHeaders(row);
  20845. this.headers = headers;
  20846. this.fieldFormatter.headers = headers;
  20847. if (!this.shouldWriteHeaders) {
  20848. // if we are not supposed to write the headers then
  20849. // always format the columns
  20850. return {
  20851. shouldFormatColumns: true,
  20852. headers: null
  20853. };
  20854. } // if the row is equal to headers dont format
  20855. return {
  20856. shouldFormatColumns: !lodash_isequal_1.default(headers, row),
  20857. headers: headers
  20858. };
  20859. } // todo change this method to unknown[]
  20860. }, {
  20861. key: "gatherColumns",
  20862. value: function gatherColumns(row) {
  20863. if (this.headers === null) {
  20864. throw new Error('Headers is currently null');
  20865. }
  20866. if (!Array.isArray(row)) {
  20867. return this.headers.map(function (header) {
  20868. return row[header];
  20869. });
  20870. }
  20871. if (RowFormatter.isHashArray(row)) {
  20872. return this.headers.map(function (header, i) {
  20873. var col = row[i];
  20874. if (col) {
  20875. return col[1];
  20876. }
  20877. return '';
  20878. });
  20879. }
  20880. return this.headers.map(function (header, i) {
  20881. return row[i];
  20882. });
  20883. }
  20884. }, {
  20885. key: "callTransformer",
  20886. value: function callTransformer(row, cb) {
  20887. if (!this._rowTransform) {
  20888. return cb(null, row);
  20889. }
  20890. return this._rowTransform(row, cb);
  20891. }
  20892. }, {
  20893. key: "formatColumns",
  20894. value: function formatColumns(columns, isHeadersRow) {
  20895. var _this2 = this;
  20896. var formattedCols = columns.map(function (field, i) {
  20897. return _this2.fieldFormatter.format(field, i, isHeadersRow);
  20898. }).join(this.formatterOptions.delimiter);
  20899. var rowCount = this.rowCount;
  20900. this.rowCount += 1;
  20901. if (rowCount) {
  20902. return [this.formatterOptions.rowDelimiter, formattedCols].join('');
  20903. }
  20904. return formattedCols;
  20905. }
  20906. }, {
  20907. key: "rowTransform",
  20908. set: function set(transformFunction) {
  20909. if (!lodash_isfunction_1.default(transformFunction)) {
  20910. throw new TypeError('The transform should be a function');
  20911. }
  20912. this._rowTransform = RowFormatter.createTransform(transformFunction);
  20913. }
  20914. }], [{
  20915. key: "isHashArray",
  20916. value: function isHashArray(row) {
  20917. if (Array.isArray(row)) {
  20918. return Array.isArray(row[0]) && row[0].length === 2;
  20919. }
  20920. return false;
  20921. } // get headers from a row item
  20922. }, {
  20923. key: "gatherHeaders",
  20924. value: function gatherHeaders(row) {
  20925. if (RowFormatter.isHashArray(row)) {
  20926. // lets assume a multi-dimesional array with item 0 being the header
  20927. return row.map(function (it) {
  20928. return it[0];
  20929. });
  20930. }
  20931. if (Array.isArray(row)) {
  20932. return row;
  20933. }
  20934. return Object.keys(row);
  20935. }
  20936. }, {
  20937. key: "createTransform",
  20938. value: function createTransform(transformFunction) {
  20939. if (types_1.isSyncTransform(transformFunction)) {
  20940. return function (row, cb) {
  20941. var transformedRow = null;
  20942. try {
  20943. transformedRow = transformFunction(row);
  20944. } catch (e) {
  20945. return cb(e);
  20946. }
  20947. return cb(null, transformedRow);
  20948. };
  20949. }
  20950. return function (row, cb) {
  20951. transformFunction(row, cb);
  20952. };
  20953. }
  20954. }]);
  20955. return RowFormatter;
  20956. }();
  20957. exports.RowFormatter = RowFormatter;
  20958. }, { "../types": 149, "./FieldFormatter": 145, "lodash.isequal": 429, "lodash.isfunction": 430 }], 147: [function (require, module, exports) {
  20959. "use strict";
  20960. Object.defineProperty(exports, "__esModule", {
  20961. value: true
  20962. });
  20963. var RowFormatter_1 = require("./RowFormatter");
  20964. Object.defineProperty(exports, "RowFormatter", {
  20965. enumerable: true,
  20966. get: function get() {
  20967. return RowFormatter_1.RowFormatter;
  20968. }
  20969. });
  20970. var FieldFormatter_1 = require("./FieldFormatter");
  20971. Object.defineProperty(exports, "FieldFormatter", {
  20972. enumerable: true,
  20973. get: function get() {
  20974. return FieldFormatter_1.FieldFormatter;
  20975. }
  20976. });
  20977. }, { "./FieldFormatter": 145, "./RowFormatter": 146 }], 148: [function (require, module, exports) {
  20978. (function (Buffer) {
  20979. "use strict";
  20980. var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
  20981. if (k2 === undefined) k2 = k;
  20982. Object.defineProperty(o, k2, {
  20983. enumerable: true,
  20984. get: function get() {
  20985. return m[k];
  20986. }
  20987. });
  20988. } : function (o, m, k, k2) {
  20989. if (k2 === undefined) k2 = k;
  20990. o[k2] = m[k];
  20991. });
  20992. var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) {
  20993. Object.defineProperty(o, "default", {
  20994. enumerable: true,
  20995. value: v
  20996. });
  20997. } : function (o, v) {
  20998. o["default"] = v;
  20999. });
  21000. var __importStar = void 0 && (void 0).__importStar || function (mod) {
  21001. if (mod && mod.__esModule) return mod;
  21002. var result = {};
  21003. if (mod != null) for (var k in mod) {
  21004. if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  21005. }
  21006. __setModuleDefault(result, mod);
  21007. return result;
  21008. };
  21009. var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
  21010. for (var p in m) {
  21011. if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
  21012. }
  21013. };
  21014. Object.defineProperty(exports, "__esModule", {
  21015. value: true
  21016. });
  21017. exports.writeToPath = exports.writeToString = exports.writeToBuffer = exports.writeToStream = exports.write = exports.format = void 0;
  21018. var util_1 = require("util");
  21019. var stream_1 = require("stream");
  21020. var fs = __importStar(require("fs"));
  21021. var FormatterOptions_1 = require("./FormatterOptions");
  21022. var CsvFormatterStream_1 = require("./CsvFormatterStream");
  21023. __exportStar(require("./types"), exports);
  21024. var CsvFormatterStream_2 = require("./CsvFormatterStream");
  21025. Object.defineProperty(exports, "CsvFormatterStream", {
  21026. enumerable: true,
  21027. get: function get() {
  21028. return CsvFormatterStream_2.CsvFormatterStream;
  21029. }
  21030. });
  21031. var FormatterOptions_2 = require("./FormatterOptions");
  21032. Object.defineProperty(exports, "FormatterOptions", {
  21033. enumerable: true,
  21034. get: function get() {
  21035. return FormatterOptions_2.FormatterOptions;
  21036. }
  21037. });
  21038. exports.format = function (options) {
  21039. return new CsvFormatterStream_1.CsvFormatterStream(new FormatterOptions_1.FormatterOptions(options));
  21040. };
  21041. exports.write = function (rows, options) {
  21042. var csvStream = exports.format(options);
  21043. var promiseWrite = util_1.promisify(function (row, cb) {
  21044. csvStream.write(row, undefined, cb);
  21045. });
  21046. rows.reduce(function (prev, row) {
  21047. return prev.then(function () {
  21048. return promiseWrite(row);
  21049. });
  21050. }, Promise.resolve()).then(function () {
  21051. return csvStream.end();
  21052. }).catch(function (err) {
  21053. csvStream.emit('error', err);
  21054. });
  21055. return csvStream;
  21056. };
  21057. exports.writeToStream = function (ws, rows, options) {
  21058. return exports.write(rows, options).pipe(ws);
  21059. };
  21060. exports.writeToBuffer = function (rows) {
  21061. var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  21062. var buffers = [];
  21063. var ws = new stream_1.Writable({
  21064. write: function write(data, enc, writeCb) {
  21065. buffers.push(data);
  21066. writeCb();
  21067. }
  21068. });
  21069. return new Promise(function (res, rej) {
  21070. ws.on('error', rej).on('finish', function () {
  21071. return res(Buffer.concat(buffers));
  21072. });
  21073. exports.write(rows, opts).pipe(ws);
  21074. });
  21075. };
  21076. exports.writeToString = function (rows, options) {
  21077. return exports.writeToBuffer(rows, options).then(function (buffer) {
  21078. return buffer.toString();
  21079. });
  21080. };
  21081. exports.writeToPath = function (path, rows, options) {
  21082. var stream = fs.createWriteStream(path, {
  21083. encoding: 'utf8'
  21084. });
  21085. return exports.write(rows, options).pipe(stream);
  21086. };
  21087. }).call(this, require("buffer").Buffer)
  21088. }, { "./CsvFormatterStream": 143, "./FormatterOptions": 144, "./types": 149, "buffer": 216, "fs": 215, "stream": 506, "util": 525 }], 149: [function (require, module, exports) {
  21089. "use strict";
  21090. /* eslint-disable @typescript-eslint/no-explicit-any */
  21091. Object.defineProperty(exports, "__esModule", {
  21092. value: true
  21093. });
  21094. exports.isSyncTransform = void 0;
  21095. exports.isSyncTransform = function (transform) {
  21096. return transform.length === 1;
  21097. };
  21098. }, {}], 150: [function (require, module, exports) {
  21099. (function (setImmediate) {
  21100. "use strict";
  21101. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  21102. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21103. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  21104. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21105. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  21106. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  21107. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  21108. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  21109. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  21110. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  21111. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  21112. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); return true; } catch (e) { return false; } }
  21113. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  21114. Object.defineProperty(exports, "__esModule", {
  21115. value: true
  21116. });
  21117. exports.CsvParserStream = void 0;
  21118. var string_decoder_1 = require("string_decoder");
  21119. var stream_1 = require("stream");
  21120. var transforms_1 = require("./transforms");
  21121. var parser_1 = require("./parser");
  21122. var CsvParserStream = /*#__PURE__*/function (_stream_1$Transform) {
  21123. _inherits(CsvParserStream, _stream_1$Transform);
  21124. var _super = _createSuper(CsvParserStream);
  21125. function CsvParserStream(parserOptions) {
  21126. var _this;
  21127. _classCallCheck(this, CsvParserStream);
  21128. _this = _super.call(this, {
  21129. objectMode: parserOptions.objectMode
  21130. });
  21131. _this.lines = '';
  21132. _this.rowCount = 0;
  21133. _this.parsedRowCount = 0;
  21134. _this.parsedLineCount = 0;
  21135. _this.endEmitted = false;
  21136. _this.headersEmitted = false;
  21137. _this.parserOptions = parserOptions;
  21138. _this.parser = new parser_1.Parser(parserOptions);
  21139. _this.headerTransformer = new transforms_1.HeaderTransformer(parserOptions);
  21140. _this.decoder = new string_decoder_1.StringDecoder(parserOptions.encoding);
  21141. _this.rowTransformerValidator = new transforms_1.RowTransformerValidator();
  21142. return _this;
  21143. }
  21144. _createClass(CsvParserStream, [{
  21145. key: "transform",
  21146. value: function transform(transformFunction) {
  21147. this.rowTransformerValidator.rowTransform = transformFunction;
  21148. return this;
  21149. }
  21150. }, {
  21151. key: "validate",
  21152. value: function validate(validateFunction) {
  21153. this.rowTransformerValidator.rowValidator = validateFunction;
  21154. return this;
  21155. } // eslint-disable-next-line @typescript-eslint/no-explicit-any
  21156. }, {
  21157. key: "emit",
  21158. value: function emit(event) {
  21159. var _get2;
  21160. if (event === 'end') {
  21161. if (!this.endEmitted) {
  21162. this.endEmitted = true;
  21163. _get(_getPrototypeOf(CsvParserStream.prototype), "emit", this).call(this, 'end', this.rowCount);
  21164. }
  21165. return false;
  21166. }
  21167. for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  21168. rest[_key - 1] = arguments[_key];
  21169. }
  21170. return (_get2 = _get(_getPrototypeOf(CsvParserStream.prototype), "emit", this)).call.apply(_get2, [this, event].concat(rest));
  21171. }
  21172. }, {
  21173. key: "_transform",
  21174. value: function _transform(data, encoding, done) {
  21175. // if we have hit our maxRows parsing limit then skip parsing
  21176. if (this.hasHitRowLimit) {
  21177. return done();
  21178. }
  21179. try {
  21180. var lines = this.lines;
  21181. var newLine = lines + this.decoder.write(data);
  21182. var rows = this.parse(newLine, true);
  21183. return this.processRows(rows, done);
  21184. } catch (e) {
  21185. return done(e);
  21186. }
  21187. }
  21188. }, {
  21189. key: "_flush",
  21190. value: function _flush(done) {
  21191. // if we have hit our maxRows parsing limit then skip parsing
  21192. if (this.hasHitRowLimit) {
  21193. return done();
  21194. }
  21195. try {
  21196. var newLine = this.lines + this.decoder.end();
  21197. var rows = this.parse(newLine, false);
  21198. return this.processRows(rows, done);
  21199. } catch (e) {
  21200. return done(e);
  21201. }
  21202. }
  21203. }, {
  21204. key: "parse",
  21205. value: function parse(data, hasMoreData) {
  21206. if (!data) {
  21207. return [];
  21208. }
  21209. var _this$parser$parse = this.parser.parse(data, hasMoreData),
  21210. line = _this$parser$parse.line,
  21211. rows = _this$parser$parse.rows;
  21212. this.lines = line;
  21213. return rows;
  21214. }
  21215. }, {
  21216. key: "processRows",
  21217. value: function processRows(rows, cb) {
  21218. var _this2 = this;
  21219. var rowsLength = rows.length;
  21220. var iterate = function iterate(i) {
  21221. var callNext = function callNext(err) {
  21222. if (err) {
  21223. return cb(err);
  21224. }
  21225. if (i % 100 === 0) {
  21226. // incase the transform are sync insert a next tick to prevent stack overflow
  21227. setImmediate(function () {
  21228. return iterate(i + 1);
  21229. });
  21230. return undefined;
  21231. }
  21232. return iterate(i + 1);
  21233. };
  21234. _this2.checkAndEmitHeaders(); // if we have emitted all rows or we have hit the maxRows limit option
  21235. // then end
  21236. if (i >= rowsLength || _this2.hasHitRowLimit) {
  21237. return cb();
  21238. }
  21239. _this2.parsedLineCount += 1;
  21240. if (_this2.shouldSkipLine) {
  21241. return callNext();
  21242. }
  21243. var row = rows[i];
  21244. _this2.rowCount += 1;
  21245. _this2.parsedRowCount += 1;
  21246. var nextRowCount = _this2.rowCount;
  21247. return _this2.transformRow(row, function (err, transformResult) {
  21248. if (err) {
  21249. _this2.rowCount -= 1;
  21250. return callNext(err);
  21251. }
  21252. if (!transformResult) {
  21253. return callNext(new Error('expected transform result'));
  21254. }
  21255. if (!transformResult.isValid) {
  21256. _this2.emit('data-invalid', transformResult.row, nextRowCount, transformResult.reason);
  21257. } else if (transformResult.row) {
  21258. return _this2.pushRow(transformResult.row, callNext);
  21259. }
  21260. return callNext();
  21261. });
  21262. };
  21263. iterate(0);
  21264. }
  21265. }, {
  21266. key: "transformRow",
  21267. value: function transformRow(parsedRow, cb) {
  21268. var _this3 = this;
  21269. try {
  21270. this.headerTransformer.transform(parsedRow, function (err, withHeaders) {
  21271. if (err) {
  21272. return cb(err);
  21273. }
  21274. if (!withHeaders) {
  21275. return cb(new Error('Expected result from header transform'));
  21276. }
  21277. if (!withHeaders.isValid) {
  21278. if (_this3.shouldEmitRows) {
  21279. return cb(null, {
  21280. isValid: false,
  21281. row: parsedRow
  21282. });
  21283. } // skipped because of skipRows option remove from total row count
  21284. return _this3.skipRow(cb);
  21285. }
  21286. if (withHeaders.row) {
  21287. if (_this3.shouldEmitRows) {
  21288. return _this3.rowTransformerValidator.transformAndValidate(withHeaders.row, cb);
  21289. } // skipped because of skipRows option remove from total row count
  21290. return _this3.skipRow(cb);
  21291. } // this is a header row dont include in the rowCount or parsedRowCount
  21292. _this3.rowCount -= 1;
  21293. _this3.parsedRowCount -= 1;
  21294. return cb(null, {
  21295. row: null,
  21296. isValid: true
  21297. });
  21298. });
  21299. } catch (e) {
  21300. cb(e);
  21301. }
  21302. }
  21303. }, {
  21304. key: "checkAndEmitHeaders",
  21305. value: function checkAndEmitHeaders() {
  21306. if (!this.headersEmitted && this.headerTransformer.headers) {
  21307. this.headersEmitted = true;
  21308. this.emit('headers', this.headerTransformer.headers);
  21309. }
  21310. }
  21311. }, {
  21312. key: "skipRow",
  21313. value: function skipRow(cb) {
  21314. // skipped because of skipRows option remove from total row count
  21315. this.rowCount -= 1;
  21316. return cb(null, {
  21317. row: null,
  21318. isValid: true
  21319. });
  21320. }
  21321. }, {
  21322. key: "pushRow",
  21323. value: function pushRow(row, cb) {
  21324. try {
  21325. if (!this.parserOptions.objectMode) {
  21326. this.push(JSON.stringify(row));
  21327. } else {
  21328. this.push(row);
  21329. }
  21330. cb();
  21331. } catch (e) {
  21332. cb(e);
  21333. }
  21334. }
  21335. }, {
  21336. key: "hasHitRowLimit",
  21337. get: function get() {
  21338. return this.parserOptions.limitRows && this.rowCount >= this.parserOptions.maxRows;
  21339. }
  21340. }, {
  21341. key: "shouldEmitRows",
  21342. get: function get() {
  21343. return this.parsedRowCount > this.parserOptions.skipRows;
  21344. }
  21345. }, {
  21346. key: "shouldSkipLine",
  21347. get: function get() {
  21348. return this.parsedLineCount <= this.parserOptions.skipLines;
  21349. }
  21350. }]);
  21351. return CsvParserStream;
  21352. }(stream_1.Transform);
  21353. exports.CsvParserStream = CsvParserStream;
  21354. }).call(this, require("timers").setImmediate)
  21355. }, { "./parser": 162, "./transforms": 165, "stream": 506, "string_decoder": 520, "timers": 521 }], 151: [function (require, module, exports) {
  21356. "use strict";
  21357. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21358. var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  21359. return mod && mod.__esModule ? mod : {
  21360. "default": mod
  21361. };
  21362. };
  21363. Object.defineProperty(exports, "__esModule", {
  21364. value: true
  21365. });
  21366. exports.ParserOptions = void 0;
  21367. var lodash_escaperegexp_1 = __importDefault(require("lodash.escaperegexp"));
  21368. var lodash_isnil_1 = __importDefault(require("lodash.isnil"));
  21369. var ParserOptions = function ParserOptions(opts) {
  21370. _classCallCheck(this, ParserOptions);
  21371. var _a;
  21372. this.objectMode = true;
  21373. this.delimiter = ',';
  21374. this.ignoreEmpty = false;
  21375. this.quote = '"';
  21376. this.escape = null;
  21377. this.escapeChar = this.quote;
  21378. this.comment = null;
  21379. this.supportsComments = false;
  21380. this.ltrim = false;
  21381. this.rtrim = false;
  21382. this.trim = false;
  21383. this.headers = null;
  21384. this.renameHeaders = false;
  21385. this.strictColumnHandling = false;
  21386. this.discardUnmappedColumns = false;
  21387. this.carriageReturn = '\r';
  21388. this.encoding = 'utf8';
  21389. this.limitRows = false;
  21390. this.maxRows = 0;
  21391. this.skipLines = 0;
  21392. this.skipRows = 0;
  21393. Object.assign(this, opts || {});
  21394. if (this.delimiter.length > 1) {
  21395. throw new Error('delimiter option must be one character long');
  21396. }
  21397. this.escapedDelimiter = lodash_escaperegexp_1.default(this.delimiter);
  21398. this.escapeChar = (_a = this.escape) !== null && _a !== void 0 ? _a : this.quote;
  21399. this.supportsComments = !lodash_isnil_1.default(this.comment);
  21400. this.NEXT_TOKEN_REGEXP = new RegExp("([^\\s]|\\r\\n|\\n|\\r|".concat(this.escapedDelimiter, ")"));
  21401. if (this.maxRows > 0) {
  21402. this.limitRows = true;
  21403. }
  21404. };
  21405. exports.ParserOptions = ParserOptions;
  21406. }, { "lodash.escaperegexp": 426, "lodash.isnil": 431 }], 152: [function (require, module, exports) {
  21407. "use strict";
  21408. var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
  21409. if (k2 === undefined) k2 = k;
  21410. Object.defineProperty(o, k2, {
  21411. enumerable: true,
  21412. get: function get() {
  21413. return m[k];
  21414. }
  21415. });
  21416. } : function (o, m, k, k2) {
  21417. if (k2 === undefined) k2 = k;
  21418. o[k2] = m[k];
  21419. });
  21420. var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) {
  21421. Object.defineProperty(o, "default", {
  21422. enumerable: true,
  21423. value: v
  21424. });
  21425. } : function (o, v) {
  21426. o["default"] = v;
  21427. });
  21428. var __importStar = void 0 && (void 0).__importStar || function (mod) {
  21429. if (mod && mod.__esModule) return mod;
  21430. var result = {};
  21431. if (mod != null) for (var k in mod) {
  21432. if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  21433. }
  21434. __setModuleDefault(result, mod);
  21435. return result;
  21436. };
  21437. var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
  21438. for (var p in m) {
  21439. if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
  21440. }
  21441. };
  21442. Object.defineProperty(exports, "__esModule", {
  21443. value: true
  21444. });
  21445. exports.parseString = exports.parseFile = exports.parseStream = exports.parse = void 0;
  21446. var fs = __importStar(require("fs"));
  21447. var stream_1 = require("stream");
  21448. var ParserOptions_1 = require("./ParserOptions");
  21449. var CsvParserStream_1 = require("./CsvParserStream");
  21450. __exportStar(require("./types"), exports);
  21451. var CsvParserStream_2 = require("./CsvParserStream");
  21452. Object.defineProperty(exports, "CsvParserStream", {
  21453. enumerable: true,
  21454. get: function get() {
  21455. return CsvParserStream_2.CsvParserStream;
  21456. }
  21457. });
  21458. var ParserOptions_2 = require("./ParserOptions");
  21459. Object.defineProperty(exports, "ParserOptions", {
  21460. enumerable: true,
  21461. get: function get() {
  21462. return ParserOptions_2.ParserOptions;
  21463. }
  21464. });
  21465. exports.parse = function (args) {
  21466. return new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(args));
  21467. };
  21468. exports.parseStream = function (stream, options) {
  21469. return stream.pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
  21470. };
  21471. exports.parseFile = function (location) {
  21472. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  21473. return fs.createReadStream(location).pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
  21474. };
  21475. exports.parseString = function (string, options) {
  21476. var rs = new stream_1.Readable();
  21477. rs.push(string);
  21478. rs.push(null);
  21479. return rs.pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
  21480. };
  21481. }, { "./CsvParserStream": 150, "./ParserOptions": 151, "./types": 166, "fs": 215, "stream": 506 }], 153: [function (require, module, exports) {
  21482. "use strict";
  21483. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21484. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  21485. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21486. Object.defineProperty(exports, "__esModule", {
  21487. value: true
  21488. });
  21489. exports.Parser = void 0;
  21490. var Scanner_1 = require("./Scanner");
  21491. var RowParser_1 = require("./RowParser");
  21492. var Token_1 = require("./Token");
  21493. var EMPTY_ROW_REGEXP = /^\s*(?:''|"")?\s*(?:,\s*(?:''|"")?\s*)*$/;
  21494. var Parser = /*#__PURE__*/function () {
  21495. function Parser(parserOptions) {
  21496. _classCallCheck(this, Parser);
  21497. this.parserOptions = parserOptions;
  21498. this.rowParser = new RowParser_1.RowParser(this.parserOptions);
  21499. }
  21500. _createClass(Parser, [{
  21501. key: "parse",
  21502. value: function parse(line, hasMoreData) {
  21503. var scanner = new Scanner_1.Scanner({
  21504. line: Parser.removeBOM(line),
  21505. parserOptions: this.parserOptions,
  21506. hasMoreData: hasMoreData
  21507. });
  21508. if (this.parserOptions.supportsComments) {
  21509. return this.parseWithComments(scanner);
  21510. }
  21511. return this.parseWithoutComments(scanner);
  21512. }
  21513. }, {
  21514. key: "parseWithoutComments",
  21515. value: function parseWithoutComments(scanner) {
  21516. var rows = [];
  21517. var shouldContinue = true;
  21518. while (shouldContinue) {
  21519. shouldContinue = this.parseRow(scanner, rows);
  21520. }
  21521. return {
  21522. line: scanner.line,
  21523. rows: rows
  21524. };
  21525. }
  21526. }, {
  21527. key: "parseWithComments",
  21528. value: function parseWithComments(scanner) {
  21529. var parserOptions = this.parserOptions;
  21530. var rows = [];
  21531. for (var nextToken = scanner.nextCharacterToken; nextToken !== null; nextToken = scanner.nextCharacterToken) {
  21532. if (Token_1.Token.isTokenComment(nextToken, parserOptions)) {
  21533. var cursor = scanner.advancePastLine();
  21534. if (cursor === null) {
  21535. return {
  21536. line: scanner.lineFromCursor,
  21537. rows: rows
  21538. };
  21539. }
  21540. if (!scanner.hasMoreCharacters) {
  21541. return {
  21542. line: scanner.lineFromCursor,
  21543. rows: rows
  21544. };
  21545. }
  21546. scanner.truncateToCursor();
  21547. } else if (!this.parseRow(scanner, rows)) {
  21548. break;
  21549. }
  21550. }
  21551. return {
  21552. line: scanner.line,
  21553. rows: rows
  21554. };
  21555. }
  21556. }, {
  21557. key: "parseRow",
  21558. value: function parseRow(scanner, rows) {
  21559. var nextToken = scanner.nextNonSpaceToken;
  21560. if (!nextToken) {
  21561. return false;
  21562. }
  21563. var row = this.rowParser.parse(scanner);
  21564. if (row === null) {
  21565. return false;
  21566. }
  21567. if (this.parserOptions.ignoreEmpty && EMPTY_ROW_REGEXP.test(row.join(''))) {
  21568. return true;
  21569. }
  21570. rows.push(row);
  21571. return true;
  21572. }
  21573. }], [{
  21574. key: "removeBOM",
  21575. value: function removeBOM(line) {
  21576. // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
  21577. // conversion translates it to FEFF (UTF-16 BOM)
  21578. if (line && line.charCodeAt(0) === 0xfeff) {
  21579. return line.slice(1);
  21580. }
  21581. return line;
  21582. }
  21583. }]);
  21584. return Parser;
  21585. }();
  21586. exports.Parser = Parser;
  21587. }, { "./RowParser": 154, "./Scanner": 155, "./Token": 156 }], 154: [function (require, module, exports) {
  21588. "use strict";
  21589. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21590. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  21591. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21592. Object.defineProperty(exports, "__esModule", {
  21593. value: true
  21594. });
  21595. exports.RowParser = void 0;
  21596. var column_1 = require("./column");
  21597. var Token_1 = require("./Token");
  21598. var _Token_1$Token = Token_1.Token,
  21599. isTokenRowDelimiter = _Token_1$Token.isTokenRowDelimiter,
  21600. isTokenCarriageReturn = _Token_1$Token.isTokenCarriageReturn,
  21601. isTokenDelimiter = _Token_1$Token.isTokenDelimiter;
  21602. var RowParser = /*#__PURE__*/function () {
  21603. function RowParser(parserOptions) {
  21604. _classCallCheck(this, RowParser);
  21605. this.parserOptions = parserOptions;
  21606. this.columnParser = new column_1.ColumnParser(parserOptions);
  21607. }
  21608. _createClass(RowParser, [{
  21609. key: "parse",
  21610. value: function parse(scanner) {
  21611. var parserOptions = this.parserOptions;
  21612. var hasMoreData = scanner.hasMoreData;
  21613. var currentScanner = scanner;
  21614. var columns = [];
  21615. var currentToken = this.getStartToken(currentScanner, columns);
  21616. while (currentToken) {
  21617. if (isTokenRowDelimiter(currentToken)) {
  21618. currentScanner.advancePastToken(currentToken); // if ends with CR and there is more data, keep unparsed due to possible
  21619. // coming LF in CRLF
  21620. if (!currentScanner.hasMoreCharacters && isTokenCarriageReturn(currentToken, parserOptions) && hasMoreData) {
  21621. return null;
  21622. }
  21623. currentScanner.truncateToCursor();
  21624. return columns;
  21625. }
  21626. if (!this.shouldSkipColumnParse(currentScanner, currentToken, columns)) {
  21627. var item = this.columnParser.parse(currentScanner);
  21628. if (item === null) {
  21629. return null;
  21630. }
  21631. columns.push(item);
  21632. }
  21633. currentToken = currentScanner.nextNonSpaceToken;
  21634. }
  21635. if (!hasMoreData) {
  21636. currentScanner.truncateToCursor();
  21637. return columns;
  21638. }
  21639. return null;
  21640. }
  21641. }, {
  21642. key: "getStartToken",
  21643. value: function getStartToken(scanner, columns) {
  21644. var currentToken = scanner.nextNonSpaceToken;
  21645. if (currentToken !== null && isTokenDelimiter(currentToken, this.parserOptions)) {
  21646. columns.push('');
  21647. return scanner.nextNonSpaceToken;
  21648. }
  21649. return currentToken;
  21650. }
  21651. }, {
  21652. key: "shouldSkipColumnParse",
  21653. value: function shouldSkipColumnParse(scanner, currentToken, columns) {
  21654. var parserOptions = this.parserOptions;
  21655. if (isTokenDelimiter(currentToken, parserOptions)) {
  21656. scanner.advancePastToken(currentToken); // if the delimiter is at the end of a line
  21657. var nextToken = scanner.nextCharacterToken;
  21658. if (!scanner.hasMoreCharacters || nextToken !== null && isTokenRowDelimiter(nextToken)) {
  21659. columns.push('');
  21660. return true;
  21661. }
  21662. if (nextToken !== null && isTokenDelimiter(nextToken, parserOptions)) {
  21663. columns.push('');
  21664. return true;
  21665. }
  21666. }
  21667. return false;
  21668. }
  21669. }]);
  21670. return RowParser;
  21671. }();
  21672. exports.RowParser = RowParser;
  21673. }, { "./Token": 156, "./column": 161 }], 155: [function (require, module, exports) {
  21674. "use strict";
  21675. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21676. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  21677. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21678. Object.defineProperty(exports, "__esModule", {
  21679. value: true
  21680. });
  21681. exports.Scanner = void 0;
  21682. var Token_1 = require("./Token");
  21683. var ROW_DELIMITER = /((?:\r\n)|\n|\r)/;
  21684. var Scanner = /*#__PURE__*/function () {
  21685. function Scanner(args) {
  21686. _classCallCheck(this, Scanner);
  21687. this.cursor = 0;
  21688. this.line = args.line;
  21689. this.lineLength = this.line.length;
  21690. this.parserOptions = args.parserOptions;
  21691. this.hasMoreData = args.hasMoreData;
  21692. this.cursor = args.cursor || 0;
  21693. }
  21694. _createClass(Scanner, [{
  21695. key: "advancePastLine",
  21696. value: function advancePastLine() {
  21697. var match = ROW_DELIMITER.exec(this.lineFromCursor);
  21698. if (!match) {
  21699. if (this.hasMoreData) {
  21700. return null;
  21701. }
  21702. this.cursor = this.lineLength;
  21703. return this;
  21704. }
  21705. this.cursor += (match.index || 0) + match[0].length;
  21706. return this;
  21707. }
  21708. }, {
  21709. key: "advanceTo",
  21710. value: function advanceTo(cursor) {
  21711. this.cursor = cursor;
  21712. return this;
  21713. }
  21714. }, {
  21715. key: "advanceToToken",
  21716. value: function advanceToToken(token) {
  21717. this.cursor = token.startCursor;
  21718. return this;
  21719. }
  21720. }, {
  21721. key: "advancePastToken",
  21722. value: function advancePastToken(token) {
  21723. this.cursor = token.endCursor + 1;
  21724. return this;
  21725. }
  21726. }, {
  21727. key: "truncateToCursor",
  21728. value: function truncateToCursor() {
  21729. this.line = this.lineFromCursor;
  21730. this.lineLength = this.line.length;
  21731. this.cursor = 0;
  21732. return this;
  21733. }
  21734. }, {
  21735. key: "hasMoreCharacters",
  21736. get: function get() {
  21737. return this.lineLength > this.cursor;
  21738. }
  21739. }, {
  21740. key: "nextNonSpaceToken",
  21741. get: function get() {
  21742. var lineFromCursor = this.lineFromCursor;
  21743. var regex = this.parserOptions.NEXT_TOKEN_REGEXP;
  21744. if (lineFromCursor.search(regex) === -1) {
  21745. return null;
  21746. }
  21747. var match = regex.exec(lineFromCursor);
  21748. if (match == null) {
  21749. return null;
  21750. }
  21751. var token = match[1];
  21752. var startCursor = this.cursor + (match.index || 0);
  21753. return new Token_1.Token({
  21754. token: token,
  21755. startCursor: startCursor,
  21756. endCursor: startCursor + token.length - 1
  21757. });
  21758. }
  21759. }, {
  21760. key: "nextCharacterToken",
  21761. get: function get() {
  21762. var cursor = this.cursor,
  21763. lineLength = this.lineLength;
  21764. if (lineLength <= cursor) {
  21765. return null;
  21766. }
  21767. return new Token_1.Token({
  21768. token: this.line[cursor],
  21769. startCursor: cursor,
  21770. endCursor: cursor
  21771. });
  21772. }
  21773. }, {
  21774. key: "lineFromCursor",
  21775. get: function get() {
  21776. return this.line.substr(this.cursor);
  21777. }
  21778. }]);
  21779. return Scanner;
  21780. }();
  21781. exports.Scanner = Scanner;
  21782. }, { "./Token": 156 }], 156: [function (require, module, exports) {
  21783. "use strict";
  21784. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21785. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  21786. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21787. Object.defineProperty(exports, "__esModule", {
  21788. value: true
  21789. });
  21790. exports.Token = void 0;
  21791. var Token = /*#__PURE__*/function () {
  21792. function Token(tokenArgs) {
  21793. _classCallCheck(this, Token);
  21794. this.token = tokenArgs.token;
  21795. this.startCursor = tokenArgs.startCursor;
  21796. this.endCursor = tokenArgs.endCursor;
  21797. }
  21798. _createClass(Token, null, [{
  21799. key: "isTokenRowDelimiter",
  21800. value: function isTokenRowDelimiter(token) {
  21801. var content = token.token;
  21802. return content === '\r' || content === '\n' || content === '\r\n';
  21803. }
  21804. }, {
  21805. key: "isTokenCarriageReturn",
  21806. value: function isTokenCarriageReturn(token, parserOptions) {
  21807. return token.token === parserOptions.carriageReturn;
  21808. }
  21809. }, {
  21810. key: "isTokenComment",
  21811. value: function isTokenComment(token, parserOptions) {
  21812. return parserOptions.supportsComments && !!token && token.token === parserOptions.comment;
  21813. }
  21814. }, {
  21815. key: "isTokenEscapeCharacter",
  21816. value: function isTokenEscapeCharacter(token, parserOptions) {
  21817. return token.token === parserOptions.escapeChar;
  21818. }
  21819. }, {
  21820. key: "isTokenQuote",
  21821. value: function isTokenQuote(token, parserOptions) {
  21822. return token.token === parserOptions.quote;
  21823. }
  21824. }, {
  21825. key: "isTokenDelimiter",
  21826. value: function isTokenDelimiter(token, parserOptions) {
  21827. return token.token === parserOptions.delimiter;
  21828. }
  21829. }]);
  21830. return Token;
  21831. }();
  21832. exports.Token = Token;
  21833. }, {}], 157: [function (require, module, exports) {
  21834. "use strict";
  21835. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21836. Object.defineProperty(exports, "__esModule", {
  21837. value: true
  21838. });
  21839. exports.ColumnFormatter = void 0;
  21840. var ColumnFormatter = function ColumnFormatter(parserOptions) {
  21841. _classCallCheck(this, ColumnFormatter);
  21842. if (parserOptions.trim) {
  21843. this.format = function (col) {
  21844. return col.trim();
  21845. };
  21846. } else if (parserOptions.ltrim) {
  21847. this.format = function (col) {
  21848. return col.trimLeft();
  21849. };
  21850. } else if (parserOptions.rtrim) {
  21851. this.format = function (col) {
  21852. return col.trimRight();
  21853. };
  21854. } else {
  21855. this.format = function (col) {
  21856. return col;
  21857. };
  21858. }
  21859. };
  21860. exports.ColumnFormatter = ColumnFormatter;
  21861. }, {}], 158: [function (require, module, exports) {
  21862. "use strict";
  21863. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21864. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  21865. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21866. Object.defineProperty(exports, "__esModule", {
  21867. value: true
  21868. });
  21869. exports.ColumnParser = void 0;
  21870. var NonQuotedColumnParser_1 = require("./NonQuotedColumnParser");
  21871. var QuotedColumnParser_1 = require("./QuotedColumnParser");
  21872. var Token_1 = require("../Token");
  21873. var ColumnParser = /*#__PURE__*/function () {
  21874. function ColumnParser(parserOptions) {
  21875. _classCallCheck(this, ColumnParser);
  21876. this.parserOptions = parserOptions;
  21877. this.quotedColumnParser = new QuotedColumnParser_1.QuotedColumnParser(parserOptions);
  21878. this.nonQuotedColumnParser = new NonQuotedColumnParser_1.NonQuotedColumnParser(parserOptions);
  21879. }
  21880. _createClass(ColumnParser, [{
  21881. key: "parse",
  21882. value: function parse(scanner) {
  21883. var nextNonSpaceToken = scanner.nextNonSpaceToken;
  21884. if (nextNonSpaceToken !== null && Token_1.Token.isTokenQuote(nextNonSpaceToken, this.parserOptions)) {
  21885. scanner.advanceToToken(nextNonSpaceToken);
  21886. return this.quotedColumnParser.parse(scanner);
  21887. }
  21888. return this.nonQuotedColumnParser.parse(scanner);
  21889. }
  21890. }]);
  21891. return ColumnParser;
  21892. }();
  21893. exports.ColumnParser = ColumnParser;
  21894. }, { "../Token": 156, "./NonQuotedColumnParser": 159, "./QuotedColumnParser": 160 }], 159: [function (require, module, exports) {
  21895. "use strict";
  21896. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21897. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  21898. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21899. Object.defineProperty(exports, "__esModule", {
  21900. value: true
  21901. });
  21902. exports.NonQuotedColumnParser = void 0;
  21903. var ColumnFormatter_1 = require("./ColumnFormatter");
  21904. var Token_1 = require("../Token");
  21905. var _Token_1$Token = Token_1.Token,
  21906. isTokenDelimiter = _Token_1$Token.isTokenDelimiter,
  21907. isTokenRowDelimiter = _Token_1$Token.isTokenRowDelimiter;
  21908. var NonQuotedColumnParser = /*#__PURE__*/function () {
  21909. function NonQuotedColumnParser(parserOptions) {
  21910. _classCallCheck(this, NonQuotedColumnParser);
  21911. this.parserOptions = parserOptions;
  21912. this.columnFormatter = new ColumnFormatter_1.ColumnFormatter(parserOptions);
  21913. }
  21914. _createClass(NonQuotedColumnParser, [{
  21915. key: "parse",
  21916. value: function parse(scanner) {
  21917. if (!scanner.hasMoreCharacters) {
  21918. return null;
  21919. }
  21920. var parserOptions = this.parserOptions;
  21921. var characters = [];
  21922. var nextToken = scanner.nextCharacterToken;
  21923. for (; nextToken; nextToken = scanner.nextCharacterToken) {
  21924. if (isTokenDelimiter(nextToken, parserOptions) || isTokenRowDelimiter(nextToken)) {
  21925. break;
  21926. }
  21927. characters.push(nextToken.token);
  21928. scanner.advancePastToken(nextToken);
  21929. }
  21930. return this.columnFormatter.format(characters.join(''));
  21931. }
  21932. }]);
  21933. return NonQuotedColumnParser;
  21934. }();
  21935. exports.NonQuotedColumnParser = NonQuotedColumnParser;
  21936. }, { "../Token": 156, "./ColumnFormatter": 157 }], 160: [function (require, module, exports) {
  21937. "use strict";
  21938. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21939. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  21940. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21941. Object.defineProperty(exports, "__esModule", {
  21942. value: true
  21943. });
  21944. exports.QuotedColumnParser = void 0;
  21945. var ColumnFormatter_1 = require("./ColumnFormatter");
  21946. var Token_1 = require("../Token");
  21947. var _Token_1$Token = Token_1.Token,
  21948. isTokenDelimiter = _Token_1$Token.isTokenDelimiter,
  21949. isTokenRowDelimiter = _Token_1$Token.isTokenRowDelimiter,
  21950. isTokenEscapeCharacter = _Token_1$Token.isTokenEscapeCharacter,
  21951. isTokenQuote = _Token_1$Token.isTokenQuote;
  21952. var QuotedColumnParser = /*#__PURE__*/function () {
  21953. function QuotedColumnParser(parserOptions) {
  21954. _classCallCheck(this, QuotedColumnParser);
  21955. this.parserOptions = parserOptions;
  21956. this.columnFormatter = new ColumnFormatter_1.ColumnFormatter(parserOptions);
  21957. }
  21958. _createClass(QuotedColumnParser, [{
  21959. key: "parse",
  21960. value: function parse(scanner) {
  21961. if (!scanner.hasMoreCharacters) {
  21962. return null;
  21963. }
  21964. var originalCursor = scanner.cursor;
  21965. var _this$gatherDataBetwe = this.gatherDataBetweenQuotes(scanner),
  21966. foundClosingQuote = _this$gatherDataBetwe.foundClosingQuote,
  21967. col = _this$gatherDataBetwe.col;
  21968. if (!foundClosingQuote) {
  21969. // reset the cursor to the original
  21970. scanner.advanceTo(originalCursor); // if we didnt find a closing quote but we potentially have more data then skip the parsing
  21971. // and return the original scanner.
  21972. if (!scanner.hasMoreData) {
  21973. throw new Error("Parse Error: missing closing: '".concat(this.parserOptions.quote || '', "' in line: at '").concat(scanner.lineFromCursor.replace(/[\r\n]/g, "\\n'"), "'"));
  21974. }
  21975. return null;
  21976. }
  21977. this.checkForMalformedColumn(scanner);
  21978. return col;
  21979. }
  21980. }, {
  21981. key: "gatherDataBetweenQuotes",
  21982. value: function gatherDataBetweenQuotes(scanner) {
  21983. var parserOptions = this.parserOptions;
  21984. var foundStartingQuote = false;
  21985. var foundClosingQuote = false;
  21986. var characters = [];
  21987. var nextToken = scanner.nextCharacterToken;
  21988. for (; !foundClosingQuote && nextToken !== null; nextToken = scanner.nextCharacterToken) {
  21989. var isQuote = isTokenQuote(nextToken, parserOptions); // ignore first quote
  21990. if (!foundStartingQuote && isQuote) {
  21991. foundStartingQuote = true;
  21992. } else if (foundStartingQuote) {
  21993. if (isTokenEscapeCharacter(nextToken, parserOptions)) {
  21994. // advance past the escape character so we can get the next one in line
  21995. scanner.advancePastToken(nextToken);
  21996. var tokenFollowingEscape = scanner.nextCharacterToken; // if the character following the escape is a quote character then just add
  21997. // the quote and advance to that character
  21998. if (tokenFollowingEscape !== null && (isTokenQuote(tokenFollowingEscape, parserOptions) || isTokenEscapeCharacter(tokenFollowingEscape, parserOptions))) {
  21999. characters.push(tokenFollowingEscape.token);
  22000. nextToken = tokenFollowingEscape;
  22001. } else if (isQuote) {
  22002. // if the escape is also a quote then we found our closing quote and finish early
  22003. foundClosingQuote = true;
  22004. } else {
  22005. // other wise add the escape token to the characters since it wast escaping anything
  22006. characters.push(nextToken.token);
  22007. }
  22008. } else if (isQuote) {
  22009. // we found our closing quote!
  22010. foundClosingQuote = true;
  22011. } else {
  22012. // add the token to the characters
  22013. characters.push(nextToken.token);
  22014. }
  22015. }
  22016. scanner.advancePastToken(nextToken);
  22017. }
  22018. return {
  22019. col: this.columnFormatter.format(characters.join('')),
  22020. foundClosingQuote: foundClosingQuote
  22021. };
  22022. }
  22023. }, {
  22024. key: "checkForMalformedColumn",
  22025. value: function checkForMalformedColumn(scanner) {
  22026. var parserOptions = this.parserOptions;
  22027. var nextNonSpaceToken = scanner.nextNonSpaceToken;
  22028. if (nextNonSpaceToken) {
  22029. var isNextTokenADelimiter = isTokenDelimiter(nextNonSpaceToken, parserOptions);
  22030. var isNextTokenARowDelimiter = isTokenRowDelimiter(nextNonSpaceToken);
  22031. if (!(isNextTokenADelimiter || isNextTokenARowDelimiter)) {
  22032. // if the final quote was NOT followed by a column (,) or row(\n) delimiter then its a bad column
  22033. // tldr: only part of the column was quoted
  22034. var linePreview = scanner.lineFromCursor.substr(0, 10).replace(/[\r\n]/g, "\\n'");
  22035. throw new Error("Parse Error: expected: '".concat(parserOptions.escapedDelimiter, "' OR new line got: '").concat(nextNonSpaceToken.token, "'. at '").concat(linePreview));
  22036. }
  22037. scanner.advanceToToken(nextNonSpaceToken);
  22038. } else if (!scanner.hasMoreData) {
  22039. scanner.advancePastLine();
  22040. }
  22041. }
  22042. }]);
  22043. return QuotedColumnParser;
  22044. }();
  22045. exports.QuotedColumnParser = QuotedColumnParser;
  22046. }, { "../Token": 156, "./ColumnFormatter": 157 }], 161: [function (require, module, exports) {
  22047. "use strict";
  22048. Object.defineProperty(exports, "__esModule", {
  22049. value: true
  22050. });
  22051. var ColumnParser_1 = require("./ColumnParser");
  22052. Object.defineProperty(exports, "ColumnParser", {
  22053. enumerable: true,
  22054. get: function get() {
  22055. return ColumnParser_1.ColumnParser;
  22056. }
  22057. });
  22058. var NonQuotedColumnParser_1 = require("./NonQuotedColumnParser");
  22059. Object.defineProperty(exports, "NonQuotedColumnParser", {
  22060. enumerable: true,
  22061. get: function get() {
  22062. return NonQuotedColumnParser_1.NonQuotedColumnParser;
  22063. }
  22064. });
  22065. var QuotedColumnParser_1 = require("./QuotedColumnParser");
  22066. Object.defineProperty(exports, "QuotedColumnParser", {
  22067. enumerable: true,
  22068. get: function get() {
  22069. return QuotedColumnParser_1.QuotedColumnParser;
  22070. }
  22071. });
  22072. var ColumnFormatter_1 = require("./ColumnFormatter");
  22073. Object.defineProperty(exports, "ColumnFormatter", {
  22074. enumerable: true,
  22075. get: function get() {
  22076. return ColumnFormatter_1.ColumnFormatter;
  22077. }
  22078. });
  22079. }, { "./ColumnFormatter": 157, "./ColumnParser": 158, "./NonQuotedColumnParser": 159, "./QuotedColumnParser": 160 }], 162: [function (require, module, exports) {
  22080. "use strict";
  22081. Object.defineProperty(exports, "__esModule", {
  22082. value: true
  22083. });
  22084. var Parser_1 = require("./Parser");
  22085. Object.defineProperty(exports, "Parser", {
  22086. enumerable: true,
  22087. get: function get() {
  22088. return Parser_1.Parser;
  22089. }
  22090. });
  22091. var RowParser_1 = require("./RowParser");
  22092. Object.defineProperty(exports, "RowParser", {
  22093. enumerable: true,
  22094. get: function get() {
  22095. return RowParser_1.RowParser;
  22096. }
  22097. });
  22098. var Scanner_1 = require("./Scanner");
  22099. Object.defineProperty(exports, "Scanner", {
  22100. enumerable: true,
  22101. get: function get() {
  22102. return Scanner_1.Scanner;
  22103. }
  22104. });
  22105. var Token_1 = require("./Token");
  22106. Object.defineProperty(exports, "Token", {
  22107. enumerable: true,
  22108. get: function get() {
  22109. return Token_1.Token;
  22110. }
  22111. });
  22112. var column_1 = require("./column");
  22113. Object.defineProperty(exports, "ColumnParser", {
  22114. enumerable: true,
  22115. get: function get() {
  22116. return column_1.ColumnParser;
  22117. }
  22118. });
  22119. Object.defineProperty(exports, "NonQuotedColumnParser", {
  22120. enumerable: true,
  22121. get: function get() {
  22122. return column_1.NonQuotedColumnParser;
  22123. }
  22124. });
  22125. Object.defineProperty(exports, "QuotedColumnParser", {
  22126. enumerable: true,
  22127. get: function get() {
  22128. return column_1.QuotedColumnParser;
  22129. }
  22130. });
  22131. }, { "./Parser": 153, "./RowParser": 154, "./Scanner": 155, "./Token": 156, "./column": 161 }], 163: [function (require, module, exports) {
  22132. "use strict";
  22133. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22134. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  22135. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  22136. var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  22137. return mod && mod.__esModule ? mod : {
  22138. "default": mod
  22139. };
  22140. };
  22141. Object.defineProperty(exports, "__esModule", {
  22142. value: true
  22143. });
  22144. exports.HeaderTransformer = void 0;
  22145. var lodash_isundefined_1 = __importDefault(require("lodash.isundefined"));
  22146. var lodash_isfunction_1 = __importDefault(require("lodash.isfunction"));
  22147. var lodash_uniq_1 = __importDefault(require("lodash.uniq"));
  22148. var lodash_groupby_1 = __importDefault(require("lodash.groupby"));
  22149. var HeaderTransformer = /*#__PURE__*/function () {
  22150. function HeaderTransformer(parserOptions) {
  22151. _classCallCheck(this, HeaderTransformer);
  22152. this.headers = null;
  22153. this.receivedHeaders = false;
  22154. this.shouldUseFirstRow = false;
  22155. this.processedFirstRow = false;
  22156. this.headersLength = 0;
  22157. this.parserOptions = parserOptions;
  22158. if (parserOptions.headers === true) {
  22159. this.shouldUseFirstRow = true;
  22160. } else if (Array.isArray(parserOptions.headers)) {
  22161. this.setHeaders(parserOptions.headers);
  22162. } else if (lodash_isfunction_1.default(parserOptions.headers)) {
  22163. this.headersTransform = parserOptions.headers;
  22164. }
  22165. }
  22166. _createClass(HeaderTransformer, [{
  22167. key: "transform",
  22168. value: function transform(row, cb) {
  22169. if (!this.shouldMapRow(row)) {
  22170. return cb(null, {
  22171. row: null,
  22172. isValid: true
  22173. });
  22174. }
  22175. return cb(null, this.processRow(row));
  22176. }
  22177. }, {
  22178. key: "shouldMapRow",
  22179. value: function shouldMapRow(row) {
  22180. var parserOptions = this.parserOptions;
  22181. if (!this.headersTransform && parserOptions.renameHeaders && !this.processedFirstRow) {
  22182. if (!this.receivedHeaders) {
  22183. throw new Error('Error renaming headers: new headers must be provided in an array');
  22184. }
  22185. this.processedFirstRow = true;
  22186. return false;
  22187. }
  22188. if (!this.receivedHeaders && Array.isArray(row)) {
  22189. if (this.headersTransform) {
  22190. this.setHeaders(this.headersTransform(row));
  22191. } else if (this.shouldUseFirstRow) {
  22192. this.setHeaders(row);
  22193. } else {
  22194. // dont do anything with the headers if we didnt receive a transform or shouldnt use the first row.
  22195. return true;
  22196. }
  22197. return false;
  22198. }
  22199. return true;
  22200. }
  22201. }, {
  22202. key: "processRow",
  22203. value: function processRow(row) {
  22204. if (!this.headers) {
  22205. return {
  22206. row: row,
  22207. isValid: true
  22208. };
  22209. }
  22210. var parserOptions = this.parserOptions;
  22211. if (!parserOptions.discardUnmappedColumns && row.length > this.headersLength) {
  22212. if (!parserOptions.strictColumnHandling) {
  22213. throw new Error("Unexpected Error: column header mismatch expected: ".concat(this.headersLength, " columns got: ").concat(row.length));
  22214. }
  22215. return {
  22216. row: row,
  22217. isValid: false,
  22218. reason: "Column header mismatch expected: ".concat(this.headersLength, " columns got: ").concat(row.length)
  22219. };
  22220. }
  22221. if (parserOptions.strictColumnHandling && row.length < this.headersLength) {
  22222. return {
  22223. row: row,
  22224. isValid: false,
  22225. reason: "Column header mismatch expected: ".concat(this.headersLength, " columns got: ").concat(row.length)
  22226. };
  22227. }
  22228. return {
  22229. row: this.mapHeaders(row),
  22230. isValid: true
  22231. };
  22232. }
  22233. }, {
  22234. key: "mapHeaders",
  22235. value: function mapHeaders(row) {
  22236. var rowMap = {};
  22237. var headers = this.headers,
  22238. headersLength = this.headersLength;
  22239. for (var i = 0; i < headersLength; i += 1) {
  22240. var header = headers[i];
  22241. if (!lodash_isundefined_1.default(header)) {
  22242. var val = row[i]; // eslint-disable-next-line no-param-reassign
  22243. if (lodash_isundefined_1.default(val)) {
  22244. rowMap[header] = '';
  22245. } else {
  22246. rowMap[header] = val;
  22247. }
  22248. }
  22249. }
  22250. return rowMap;
  22251. }
  22252. }, {
  22253. key: "setHeaders",
  22254. value: function setHeaders(headers) {
  22255. var _a;
  22256. var filteredHeaders = headers.filter(function (h) {
  22257. return !!h;
  22258. });
  22259. if (lodash_uniq_1.default(filteredHeaders).length !== filteredHeaders.length) {
  22260. var grouped = lodash_groupby_1.default(filteredHeaders);
  22261. var duplicates = Object.keys(grouped).filter(function (dup) {
  22262. return grouped[dup].length > 1;
  22263. });
  22264. throw new Error("Duplicate headers found ".concat(JSON.stringify(duplicates)));
  22265. }
  22266. this.headers = headers;
  22267. this.receivedHeaders = true;
  22268. this.headersLength = ((_a = this.headers) === null || _a === void 0 ? void 0 : _a.length) || 0;
  22269. }
  22270. }]);
  22271. return HeaderTransformer;
  22272. }();
  22273. exports.HeaderTransformer = HeaderTransformer;
  22274. }, { "lodash.groupby": 427, "lodash.isfunction": 430, "lodash.isundefined": 432, "lodash.uniq": 433 }], 164: [function (require, module, exports) {
  22275. "use strict";
  22276. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22277. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  22278. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  22279. var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  22280. return mod && mod.__esModule ? mod : {
  22281. "default": mod
  22282. };
  22283. };
  22284. Object.defineProperty(exports, "__esModule", {
  22285. value: true
  22286. });
  22287. exports.RowTransformerValidator = void 0;
  22288. var lodash_isfunction_1 = __importDefault(require("lodash.isfunction"));
  22289. var types_1 = require("../types");
  22290. var RowTransformerValidator = /*#__PURE__*/function () {
  22291. function RowTransformerValidator() {
  22292. _classCallCheck(this, RowTransformerValidator);
  22293. this._rowTransform = null;
  22294. this._rowValidator = null;
  22295. }
  22296. _createClass(RowTransformerValidator, [{
  22297. key: "transformAndValidate",
  22298. value: function transformAndValidate(row, cb) {
  22299. var _this = this;
  22300. return this.callTransformer(row, function (transformErr, transformedRow) {
  22301. if (transformErr) {
  22302. return cb(transformErr);
  22303. }
  22304. if (!transformedRow) {
  22305. return cb(null, {
  22306. row: null,
  22307. isValid: true
  22308. });
  22309. }
  22310. return _this.callValidator(transformedRow, function (validateErr, validationResult) {
  22311. if (validateErr) {
  22312. return cb(validateErr);
  22313. }
  22314. if (validationResult && !validationResult.isValid) {
  22315. return cb(null, {
  22316. row: transformedRow,
  22317. isValid: false,
  22318. reason: validationResult.reason
  22319. });
  22320. }
  22321. return cb(null, {
  22322. row: transformedRow,
  22323. isValid: true
  22324. });
  22325. });
  22326. });
  22327. }
  22328. }, {
  22329. key: "callTransformer",
  22330. value: function callTransformer(row, cb) {
  22331. if (!this._rowTransform) {
  22332. return cb(null, row);
  22333. }
  22334. return this._rowTransform(row, cb);
  22335. }
  22336. }, {
  22337. key: "callValidator",
  22338. value: function callValidator(row, cb) {
  22339. if (!this._rowValidator) {
  22340. return cb(null, {
  22341. row: row,
  22342. isValid: true
  22343. });
  22344. }
  22345. return this._rowValidator(row, cb);
  22346. }
  22347. }, {
  22348. key: "rowTransform",
  22349. set: function set(transformFunction) {
  22350. if (!lodash_isfunction_1.default(transformFunction)) {
  22351. throw new TypeError('The transform should be a function');
  22352. }
  22353. this._rowTransform = RowTransformerValidator.createTransform(transformFunction);
  22354. }
  22355. }, {
  22356. key: "rowValidator",
  22357. set: function set(validateFunction) {
  22358. if (!lodash_isfunction_1.default(validateFunction)) {
  22359. throw new TypeError('The validate should be a function');
  22360. }
  22361. this._rowValidator = RowTransformerValidator.createValidator(validateFunction);
  22362. }
  22363. }], [{
  22364. key: "createTransform",
  22365. value: function createTransform(transformFunction) {
  22366. if (types_1.isSyncTransform(transformFunction)) {
  22367. return function (row, cb) {
  22368. var transformed = null;
  22369. try {
  22370. transformed = transformFunction(row);
  22371. } catch (e) {
  22372. return cb(e);
  22373. }
  22374. return cb(null, transformed);
  22375. };
  22376. }
  22377. return transformFunction;
  22378. }
  22379. }, {
  22380. key: "createValidator",
  22381. value: function createValidator(validateFunction) {
  22382. if (types_1.isSyncValidate(validateFunction)) {
  22383. return function (row, cb) {
  22384. cb(null, {
  22385. row: row,
  22386. isValid: validateFunction(row)
  22387. });
  22388. };
  22389. }
  22390. return function (row, cb) {
  22391. validateFunction(row, function (err, isValid, reason) {
  22392. if (err) {
  22393. return cb(err);
  22394. }
  22395. if (isValid) {
  22396. return cb(null, {
  22397. row: row,
  22398. isValid: isValid,
  22399. reason: reason
  22400. });
  22401. }
  22402. return cb(null, {
  22403. row: row,
  22404. isValid: false,
  22405. reason: reason
  22406. });
  22407. });
  22408. };
  22409. }
  22410. }]);
  22411. return RowTransformerValidator;
  22412. }();
  22413. exports.RowTransformerValidator = RowTransformerValidator;
  22414. }, { "../types": 166, "lodash.isfunction": 430 }], 165: [function (require, module, exports) {
  22415. "use strict";
  22416. Object.defineProperty(exports, "__esModule", {
  22417. value: true
  22418. });
  22419. var RowTransformerValidator_1 = require("./RowTransformerValidator");
  22420. Object.defineProperty(exports, "RowTransformerValidator", {
  22421. enumerable: true,
  22422. get: function get() {
  22423. return RowTransformerValidator_1.RowTransformerValidator;
  22424. }
  22425. });
  22426. var HeaderTransformer_1 = require("./HeaderTransformer");
  22427. Object.defineProperty(exports, "HeaderTransformer", {
  22428. enumerable: true,
  22429. get: function get() {
  22430. return HeaderTransformer_1.HeaderTransformer;
  22431. }
  22432. });
  22433. }, { "./HeaderTransformer": 163, "./RowTransformerValidator": 164 }], 166: [function (require, module, exports) {
  22434. "use strict";
  22435. Object.defineProperty(exports, "__esModule", {
  22436. value: true
  22437. });
  22438. exports.isSyncValidate = exports.isSyncTransform = void 0;
  22439. exports.isSyncTransform = function (transform) {
  22440. return transform.length === 1;
  22441. };
  22442. exports.isSyncValidate = function (validate) {
  22443. return validate.length === 1;
  22444. };
  22445. }, {}], 167: [function (require, module, exports) {
  22446. 'use strict';
  22447. var asn1 = exports;
  22448. asn1.bignum = require('bn.js');
  22449. asn1.define = require('./asn1/api').define;
  22450. asn1.base = require('./asn1/base');
  22451. asn1.constants = require('./asn1/constants');
  22452. asn1.decoders = require('./asn1/decoders');
  22453. asn1.encoders = require('./asn1/encoders');
  22454. }, { "./asn1/api": 168, "./asn1/base": 170, "./asn1/constants": 174, "./asn1/decoders": 176, "./asn1/encoders": 179, "bn.js": 181 }], 168: [function (require, module, exports) {
  22455. 'use strict';
  22456. var encoders = require('./encoders');
  22457. var decoders = require('./decoders');
  22458. var inherits = require('inherits');
  22459. var api = exports;
  22460. api.define = function define(name, body) {
  22461. return new Entity(name, body);
  22462. };
  22463. function Entity(name, body) {
  22464. this.name = name;
  22465. this.body = body;
  22466. this.decoders = {};
  22467. this.encoders = {};
  22468. }
  22469. Entity.prototype._createNamed = function createNamed(Base) {
  22470. var name = this.name;
  22471. function Generated(entity) {
  22472. this._initNamed(entity, name);
  22473. }
  22474. inherits(Generated, Base);
  22475. Generated.prototype._initNamed = function _initNamed(entity, name) {
  22476. Base.call(this, entity, name);
  22477. };
  22478. return new Generated(this);
  22479. };
  22480. Entity.prototype._getDecoder = function _getDecoder(enc) {
  22481. enc = enc || 'der'; // Lazily create decoder
  22482. if (!this.decoders.hasOwnProperty(enc)) this.decoders[enc] = this._createNamed(decoders[enc]);
  22483. return this.decoders[enc];
  22484. };
  22485. Entity.prototype.decode = function decode(data, enc, options) {
  22486. return this._getDecoder(enc).decode(data, options);
  22487. };
  22488. Entity.prototype._getEncoder = function _getEncoder(enc) {
  22489. enc = enc || 'der'; // Lazily create encoder
  22490. if (!this.encoders.hasOwnProperty(enc)) this.encoders[enc] = this._createNamed(encoders[enc]);
  22491. return this.encoders[enc];
  22492. };
  22493. Entity.prototype.encode = function encode(data, enc,
  22494. /* internal */
  22495. reporter) {
  22496. return this._getEncoder(enc).encode(data, reporter);
  22497. };
  22498. }, { "./decoders": 176, "./encoders": 179, "inherits": 387 }], 169: [function (require, module, exports) {
  22499. 'use strict';
  22500. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  22501. var inherits = require('inherits');
  22502. var Reporter = require('../base/reporter').Reporter;
  22503. var Buffer = require('safer-buffer').Buffer;
  22504. function DecoderBuffer(base, options) {
  22505. Reporter.call(this, options);
  22506. if (!Buffer.isBuffer(base)) {
  22507. this.error('Input not Buffer');
  22508. return;
  22509. }
  22510. this.base = base;
  22511. this.offset = 0;
  22512. this.length = base.length;
  22513. }
  22514. inherits(DecoderBuffer, Reporter);
  22515. exports.DecoderBuffer = DecoderBuffer;
  22516. DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) {
  22517. if (data instanceof DecoderBuffer) {
  22518. return true;
  22519. } // Or accept compatible API
  22520. var isCompatible = _typeof(data) === 'object' && Buffer.isBuffer(data.base) && data.constructor.name === 'DecoderBuffer' && typeof data.offset === 'number' && typeof data.length === 'number' && typeof data.save === 'function' && typeof data.restore === 'function' && typeof data.isEmpty === 'function' && typeof data.readUInt8 === 'function' && typeof data.skip === 'function' && typeof data.raw === 'function';
  22521. return isCompatible;
  22522. };
  22523. DecoderBuffer.prototype.save = function save() {
  22524. return {
  22525. offset: this.offset,
  22526. reporter: Reporter.prototype.save.call(this)
  22527. };
  22528. };
  22529. DecoderBuffer.prototype.restore = function restore(save) {
  22530. // Return skipped data
  22531. var res = new DecoderBuffer(this.base);
  22532. res.offset = save.offset;
  22533. res.length = this.offset;
  22534. this.offset = save.offset;
  22535. Reporter.prototype.restore.call(this, save.reporter);
  22536. return res;
  22537. };
  22538. DecoderBuffer.prototype.isEmpty = function isEmpty() {
  22539. return this.offset === this.length;
  22540. };
  22541. DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
  22542. if (this.offset + 1 <= this.length) return this.base.readUInt8(this.offset++, true); else return this.error(fail || 'DecoderBuffer overrun');
  22543. };
  22544. DecoderBuffer.prototype.skip = function skip(bytes, fail) {
  22545. if (!(this.offset + bytes <= this.length)) return this.error(fail || 'DecoderBuffer overrun');
  22546. var res = new DecoderBuffer(this.base); // Share reporter state
  22547. res._reporterState = this._reporterState;
  22548. res.offset = this.offset;
  22549. res.length = this.offset + bytes;
  22550. this.offset += bytes;
  22551. return res;
  22552. };
  22553. DecoderBuffer.prototype.raw = function raw(save) {
  22554. return this.base.slice(save ? save.offset : this.offset, this.length);
  22555. };
  22556. function EncoderBuffer(value, reporter) {
  22557. if (Array.isArray(value)) {
  22558. this.length = 0;
  22559. this.value = value.map(function (item) {
  22560. if (!EncoderBuffer.isEncoderBuffer(item)) item = new EncoderBuffer(item, reporter);
  22561. this.length += item.length;
  22562. return item;
  22563. }, this);
  22564. } else if (typeof value === 'number') {
  22565. if (!(0 <= value && value <= 0xff)) return reporter.error('non-byte EncoderBuffer value');
  22566. this.value = value;
  22567. this.length = 1;
  22568. } else if (typeof value === 'string') {
  22569. this.value = value;
  22570. this.length = Buffer.byteLength(value);
  22571. } else if (Buffer.isBuffer(value)) {
  22572. this.value = value;
  22573. this.length = value.length;
  22574. } else {
  22575. return reporter.error('Unsupported type: ' + _typeof(value));
  22576. }
  22577. }
  22578. exports.EncoderBuffer = EncoderBuffer;
  22579. EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) {
  22580. if (data instanceof EncoderBuffer) {
  22581. return true;
  22582. } // Or accept compatible API
  22583. var isCompatible = _typeof(data) === 'object' && data.constructor.name === 'EncoderBuffer' && typeof data.length === 'number' && typeof data.join === 'function';
  22584. return isCompatible;
  22585. };
  22586. EncoderBuffer.prototype.join = function join(out, offset) {
  22587. if (!out) out = Buffer.alloc(this.length);
  22588. if (!offset) offset = 0;
  22589. if (this.length === 0) return out;
  22590. if (Array.isArray(this.value)) {
  22591. this.value.forEach(function (item) {
  22592. item.join(out, offset);
  22593. offset += item.length;
  22594. });
  22595. } else {
  22596. if (typeof this.value === 'number') out[offset] = this.value; else if (typeof this.value === 'string') out.write(this.value, offset); else if (Buffer.isBuffer(this.value)) this.value.copy(out, offset);
  22597. offset += this.length;
  22598. }
  22599. return out;
  22600. };
  22601. }, { "../base/reporter": 172, "inherits": 387, "safer-buffer": 495 }], 170: [function (require, module, exports) {
  22602. 'use strict';
  22603. var base = exports;
  22604. base.Reporter = require('./reporter').Reporter;
  22605. base.DecoderBuffer = require('./buffer').DecoderBuffer;
  22606. base.EncoderBuffer = require('./buffer').EncoderBuffer;
  22607. base.Node = require('./node');
  22608. }, { "./buffer": 169, "./node": 171, "./reporter": 172 }], 171: [function (require, module, exports) {
  22609. 'use strict';
  22610. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  22611. var Reporter = require('../base/reporter').Reporter;
  22612. var EncoderBuffer = require('../base/buffer').EncoderBuffer;
  22613. var DecoderBuffer = require('../base/buffer').DecoderBuffer;
  22614. var assert = require('minimalistic-assert'); // Supported tags
  22615. var tags = ['seq', 'seqof', 'set', 'setof', 'objid', 'bool', 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc', 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr']; // Public methods list
  22616. var methods = ['key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', 'any', 'contains'].concat(tags); // Overrided methods list
  22617. var overrided = ['_peekTag', '_decodeTag', '_use', '_decodeStr', '_decodeObjid', '_decodeTime', '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime', '_encodeNull', '_encodeInt', '_encodeBool'];
  22618. function Node(enc, parent, name) {
  22619. var state = {};
  22620. this._baseState = state;
  22621. state.name = name;
  22622. state.enc = enc;
  22623. state.parent = parent || null;
  22624. state.children = null; // State
  22625. state.tag = null;
  22626. state.args = null;
  22627. state.reverseArgs = null;
  22628. state.choice = null;
  22629. state.optional = false;
  22630. state.any = false;
  22631. state.obj = false;
  22632. state.use = null;
  22633. state.useDecoder = null;
  22634. state.key = null;
  22635. state['default'] = null;
  22636. state.explicit = null;
  22637. state.implicit = null;
  22638. state.contains = null; // Should create new instance on each method
  22639. if (!state.parent) {
  22640. state.children = [];
  22641. this._wrap();
  22642. }
  22643. }
  22644. module.exports = Node;
  22645. var stateProps = ['enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', 'implicit', 'contains'];
  22646. Node.prototype.clone = function clone() {
  22647. var state = this._baseState;
  22648. var cstate = {};
  22649. stateProps.forEach(function (prop) {
  22650. cstate[prop] = state[prop];
  22651. });
  22652. var res = new this.constructor(cstate.parent);
  22653. res._baseState = cstate;
  22654. return res;
  22655. };
  22656. Node.prototype._wrap = function wrap() {
  22657. var state = this._baseState;
  22658. methods.forEach(function (method) {
  22659. this[method] = function _wrappedMethod() {
  22660. var clone = new this.constructor(this);
  22661. state.children.push(clone);
  22662. return clone[method].apply(clone, arguments);
  22663. };
  22664. }, this);
  22665. };
  22666. Node.prototype._init = function init(body) {
  22667. var state = this._baseState;
  22668. assert(state.parent === null);
  22669. body.call(this); // Filter children
  22670. state.children = state.children.filter(function (child) {
  22671. return child._baseState.parent === this;
  22672. }, this);
  22673. assert.equal(state.children.length, 1, 'Root node can have only one child');
  22674. };
  22675. Node.prototype._useArgs = function useArgs(args) {
  22676. var state = this._baseState; // Filter children and args
  22677. var children = args.filter(function (arg) {
  22678. return arg instanceof this.constructor;
  22679. }, this);
  22680. args = args.filter(function (arg) {
  22681. return !(arg instanceof this.constructor);
  22682. }, this);
  22683. if (children.length !== 0) {
  22684. assert(state.children === null);
  22685. state.children = children; // Replace parent to maintain backward link
  22686. children.forEach(function (child) {
  22687. child._baseState.parent = this;
  22688. }, this);
  22689. }
  22690. if (args.length !== 0) {
  22691. assert(state.args === null);
  22692. state.args = args;
  22693. state.reverseArgs = args.map(function (arg) {
  22694. if (_typeof(arg) !== 'object' || arg.constructor !== Object) return arg;
  22695. var res = {};
  22696. Object.keys(arg).forEach(function (key) {
  22697. if (key == (key | 0)) key |= 0;
  22698. var value = arg[key];
  22699. res[value] = key;
  22700. });
  22701. return res;
  22702. });
  22703. }
  22704. }; //
  22705. // Overrided methods
  22706. //
  22707. overrided.forEach(function (method) {
  22708. Node.prototype[method] = function _overrided() {
  22709. var state = this._baseState;
  22710. throw new Error(method + ' not implemented for encoding: ' + state.enc);
  22711. };
  22712. }); //
  22713. // Public methods
  22714. //
  22715. tags.forEach(function (tag) {
  22716. Node.prototype[tag] = function _tagMethod() {
  22717. var state = this._baseState;
  22718. var args = Array.prototype.slice.call(arguments);
  22719. assert(state.tag === null);
  22720. state.tag = tag;
  22721. this._useArgs(args);
  22722. return this;
  22723. };
  22724. });
  22725. Node.prototype.use = function use(item) {
  22726. assert(item);
  22727. var state = this._baseState;
  22728. assert(state.use === null);
  22729. state.use = item;
  22730. return this;
  22731. };
  22732. Node.prototype.optional = function optional() {
  22733. var state = this._baseState;
  22734. state.optional = true;
  22735. return this;
  22736. };
  22737. Node.prototype.def = function def(val) {
  22738. var state = this._baseState;
  22739. assert(state['default'] === null);
  22740. state['default'] = val;
  22741. state.optional = true;
  22742. return this;
  22743. };
  22744. Node.prototype.explicit = function explicit(num) {
  22745. var state = this._baseState;
  22746. assert(state.explicit === null && state.implicit === null);
  22747. state.explicit = num;
  22748. return this;
  22749. };
  22750. Node.prototype.implicit = function implicit(num) {
  22751. var state = this._baseState;
  22752. assert(state.explicit === null && state.implicit === null);
  22753. state.implicit = num;
  22754. return this;
  22755. };
  22756. Node.prototype.obj = function obj() {
  22757. var state = this._baseState;
  22758. var args = Array.prototype.slice.call(arguments);
  22759. state.obj = true;
  22760. if (args.length !== 0) this._useArgs(args);
  22761. return this;
  22762. };
  22763. Node.prototype.key = function key(newKey) {
  22764. var state = this._baseState;
  22765. assert(state.key === null);
  22766. state.key = newKey;
  22767. return this;
  22768. };
  22769. Node.prototype.any = function any() {
  22770. var state = this._baseState;
  22771. state.any = true;
  22772. return this;
  22773. };
  22774. Node.prototype.choice = function choice(obj) {
  22775. var state = this._baseState;
  22776. assert(state.choice === null);
  22777. state.choice = obj;
  22778. this._useArgs(Object.keys(obj).map(function (key) {
  22779. return obj[key];
  22780. }));
  22781. return this;
  22782. };
  22783. Node.prototype.contains = function contains(item) {
  22784. var state = this._baseState;
  22785. assert(state.use === null);
  22786. state.contains = item;
  22787. return this;
  22788. }; //
  22789. // Decoding
  22790. //
  22791. Node.prototype._decode = function decode(input, options) {
  22792. var state = this._baseState; // Decode root node
  22793. if (state.parent === null) return input.wrapResult(state.children[0]._decode(input, options));
  22794. var result = state['default'];
  22795. var present = true;
  22796. var prevKey = null;
  22797. if (state.key !== null) prevKey = input.enterKey(state.key); // Check if tag is there
  22798. if (state.optional) {
  22799. var tag = null;
  22800. if (state.explicit !== null) tag = state.explicit; else if (state.implicit !== null) tag = state.implicit; else if (state.tag !== null) tag = state.tag;
  22801. if (tag === null && !state.any) {
  22802. // Trial and Error
  22803. var save = input.save();
  22804. try {
  22805. if (state.choice === null) this._decodeGeneric(state.tag, input, options); else this._decodeChoice(input, options);
  22806. present = true;
  22807. } catch (e) {
  22808. present = false;
  22809. }
  22810. input.restore(save);
  22811. } else {
  22812. present = this._peekTag(input, tag, state.any);
  22813. if (input.isError(present)) return present;
  22814. }
  22815. } // Push object on stack
  22816. var prevObj;
  22817. if (state.obj && present) prevObj = input.enterObject();
  22818. if (present) {
  22819. // Unwrap explicit values
  22820. if (state.explicit !== null) {
  22821. var explicit = this._decodeTag(input, state.explicit);
  22822. if (input.isError(explicit)) return explicit;
  22823. input = explicit;
  22824. }
  22825. var start = input.offset; // Unwrap implicit and normal values
  22826. if (state.use === null && state.choice === null) {
  22827. var _save;
  22828. if (state.any) _save = input.save();
  22829. var body = this._decodeTag(input, state.implicit !== null ? state.implicit : state.tag, state.any);
  22830. if (input.isError(body)) return body;
  22831. if (state.any) result = input.raw(_save); else input = body;
  22832. }
  22833. if (options && options.track && state.tag !== null) options.track(input.path(), start, input.length, 'tagged');
  22834. if (options && options.track && state.tag !== null) options.track(input.path(), input.offset, input.length, 'content'); // Select proper method for tag
  22835. if (state.any) {// no-op
  22836. } else if (state.choice === null) {
  22837. result = this._decodeGeneric(state.tag, input, options);
  22838. } else {
  22839. result = this._decodeChoice(input, options);
  22840. }
  22841. if (input.isError(result)) return result; // Decode children
  22842. if (!state.any && state.choice === null && state.children !== null) {
  22843. state.children.forEach(function decodeChildren(child) {
  22844. // NOTE: We are ignoring errors here, to let parser continue with other
  22845. // parts of encoded data
  22846. child._decode(input, options);
  22847. });
  22848. } // Decode contained/encoded by schema, only in bit or octet strings
  22849. if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
  22850. var data = new DecoderBuffer(result);
  22851. result = this._getUse(state.contains, input._reporterState.obj)._decode(data, options);
  22852. }
  22853. } // Pop object
  22854. if (state.obj && present) result = input.leaveObject(prevObj); // Set key
  22855. if (state.key !== null && (result !== null || present === true)) input.leaveKey(prevKey, state.key, result); else if (prevKey !== null) input.exitKey(prevKey);
  22856. return result;
  22857. };
  22858. Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
  22859. var state = this._baseState;
  22860. if (tag === 'seq' || tag === 'set') return null;
  22861. if (tag === 'seqof' || tag === 'setof') return this._decodeList(input, tag, state.args[0], options); else if (/str$/.test(tag)) return this._decodeStr(input, tag, options); else if (tag === 'objid' && state.args) return this._decodeObjid(input, state.args[0], state.args[1], options); else if (tag === 'objid') return this._decodeObjid(input, null, null, options); else if (tag === 'gentime' || tag === 'utctime') return this._decodeTime(input, tag, options); else if (tag === 'null_') return this._decodeNull(input, options); else if (tag === 'bool') return this._decodeBool(input, options); else if (tag === 'objDesc') return this._decodeStr(input, tag, options); else if (tag === 'int' || tag === 'enum') return this._decodeInt(input, state.args && state.args[0], options);
  22862. if (state.use !== null) {
  22863. return this._getUse(state.use, input._reporterState.obj)._decode(input, options);
  22864. } else {
  22865. return input.error('unknown tag: ' + tag);
  22866. }
  22867. };
  22868. Node.prototype._getUse = function _getUse(entity, obj) {
  22869. var state = this._baseState; // Create altered use decoder if implicit is set
  22870. state.useDecoder = this._use(entity, obj);
  22871. assert(state.useDecoder._baseState.parent === null);
  22872. state.useDecoder = state.useDecoder._baseState.children[0];
  22873. if (state.implicit !== state.useDecoder._baseState.implicit) {
  22874. state.useDecoder = state.useDecoder.clone();
  22875. state.useDecoder._baseState.implicit = state.implicit;
  22876. }
  22877. return state.useDecoder;
  22878. };
  22879. Node.prototype._decodeChoice = function decodeChoice(input, options) {
  22880. var state = this._baseState;
  22881. var result = null;
  22882. var match = false;
  22883. Object.keys(state.choice).some(function (key) {
  22884. var save = input.save();
  22885. var node = state.choice[key];
  22886. try {
  22887. var value = node._decode(input, options);
  22888. if (input.isError(value)) return false;
  22889. result = {
  22890. type: key,
  22891. value: value
  22892. };
  22893. match = true;
  22894. } catch (e) {
  22895. input.restore(save);
  22896. return false;
  22897. }
  22898. return true;
  22899. }, this);
  22900. if (!match) return input.error('Choice not matched');
  22901. return result;
  22902. }; //
  22903. // Encoding
  22904. //
  22905. Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
  22906. return new EncoderBuffer(data, this.reporter);
  22907. };
  22908. Node.prototype._encode = function encode(data, reporter, parent) {
  22909. var state = this._baseState;
  22910. if (state['default'] !== null && state['default'] === data) return;
  22911. var result = this._encodeValue(data, reporter, parent);
  22912. if (result === undefined) return;
  22913. if (this._skipDefault(result, reporter, parent)) return;
  22914. return result;
  22915. };
  22916. Node.prototype._encodeValue = function encode(data, reporter, parent) {
  22917. var state = this._baseState; // Decode root node
  22918. if (state.parent === null) return state.children[0]._encode(data, reporter || new Reporter());
  22919. var result = null; // Set reporter to share it with a child class
  22920. this.reporter = reporter; // Check if data is there
  22921. if (state.optional && data === undefined) {
  22922. if (state['default'] !== null) data = state['default']; else return;
  22923. } // Encode children first
  22924. var content = null;
  22925. var primitive = false;
  22926. if (state.any) {
  22927. // Anything that was given is translated to buffer
  22928. result = this._createEncoderBuffer(data);
  22929. } else if (state.choice) {
  22930. result = this._encodeChoice(data, reporter);
  22931. } else if (state.contains) {
  22932. content = this._getUse(state.contains, parent)._encode(data, reporter);
  22933. primitive = true;
  22934. } else if (state.children) {
  22935. content = state.children.map(function (child) {
  22936. if (child._baseState.tag === 'null_') return child._encode(null, reporter, data);
  22937. if (child._baseState.key === null) return reporter.error('Child should have a key');
  22938. var prevKey = reporter.enterKey(child._baseState.key);
  22939. if (_typeof(data) !== 'object') return reporter.error('Child expected, but input is not object');
  22940. var res = child._encode(data[child._baseState.key], reporter, data);
  22941. reporter.leaveKey(prevKey);
  22942. return res;
  22943. }, this).filter(function (child) {
  22944. return child;
  22945. });
  22946. content = this._createEncoderBuffer(content);
  22947. } else {
  22948. if (state.tag === 'seqof' || state.tag === 'setof') {
  22949. // TODO(indutny): this should be thrown on DSL level
  22950. if (!(state.args && state.args.length === 1)) return reporter.error('Too many args for : ' + state.tag);
  22951. if (!Array.isArray(data)) return reporter.error('seqof/setof, but data is not Array');
  22952. var child = this.clone();
  22953. child._baseState.implicit = null;
  22954. content = this._createEncoderBuffer(data.map(function (item) {
  22955. var state = this._baseState;
  22956. return this._getUse(state.args[0], data)._encode(item, reporter);
  22957. }, child));
  22958. } else if (state.use !== null) {
  22959. result = this._getUse(state.use, parent)._encode(data, reporter);
  22960. } else {
  22961. content = this._encodePrimitive(state.tag, data);
  22962. primitive = true;
  22963. }
  22964. } // Encode data itself
  22965. if (!state.any && state.choice === null) {
  22966. var tag = state.implicit !== null ? state.implicit : state.tag;
  22967. var cls = state.implicit === null ? 'universal' : 'context';
  22968. if (tag === null) {
  22969. if (state.use === null) reporter.error('Tag could be omitted only for .use()');
  22970. } else {
  22971. if (state.use === null) result = this._encodeComposite(tag, primitive, cls, content);
  22972. }
  22973. } // Wrap in explicit
  22974. if (state.explicit !== null) result = this._encodeComposite(state.explicit, false, 'context', result);
  22975. return result;
  22976. };
  22977. Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
  22978. var state = this._baseState;
  22979. var node = state.choice[data.type];
  22980. if (!node) {
  22981. assert(false, data.type + ' not found in ' + JSON.stringify(Object.keys(state.choice)));
  22982. }
  22983. return node._encode(data.value, reporter);
  22984. };
  22985. Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
  22986. var state = this._baseState;
  22987. if (/str$/.test(tag)) return this._encodeStr(data, tag); else if (tag === 'objid' && state.args) return this._encodeObjid(data, state.reverseArgs[0], state.args[1]); else if (tag === 'objid') return this._encodeObjid(data, null, null); else if (tag === 'gentime' || tag === 'utctime') return this._encodeTime(data, tag); else if (tag === 'null_') return this._encodeNull(); else if (tag === 'int' || tag === 'enum') return this._encodeInt(data, state.args && state.reverseArgs[0]); else if (tag === 'bool') return this._encodeBool(data); else if (tag === 'objDesc') return this._encodeStr(data, tag); else throw new Error('Unsupported tag: ' + tag);
  22988. };
  22989. Node.prototype._isNumstr = function isNumstr(str) {
  22990. return /^[0-9 ]*$/.test(str);
  22991. };
  22992. Node.prototype._isPrintstr = function isPrintstr(str) {
  22993. return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str);
  22994. };
  22995. }, { "../base/buffer": 169, "../base/reporter": 172, "minimalistic-assert": 437 }], 172: [function (require, module, exports) {
  22996. 'use strict';
  22997. var inherits = require('inherits');
  22998. function Reporter(options) {
  22999. this._reporterState = {
  23000. obj: null,
  23001. path: [],
  23002. options: options || {},
  23003. errors: []
  23004. };
  23005. }
  23006. exports.Reporter = Reporter;
  23007. Reporter.prototype.isError = function isError(obj) {
  23008. return obj instanceof ReporterError;
  23009. };
  23010. Reporter.prototype.save = function save() {
  23011. var state = this._reporterState;
  23012. return {
  23013. obj: state.obj,
  23014. pathLen: state.path.length
  23015. };
  23016. };
  23017. Reporter.prototype.restore = function restore(data) {
  23018. var state = this._reporterState;
  23019. state.obj = data.obj;
  23020. state.path = state.path.slice(0, data.pathLen);
  23021. };
  23022. Reporter.prototype.enterKey = function enterKey(key) {
  23023. return this._reporterState.path.push(key);
  23024. };
  23025. Reporter.prototype.exitKey = function exitKey(index) {
  23026. var state = this._reporterState;
  23027. state.path = state.path.slice(0, index - 1);
  23028. };
  23029. Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
  23030. var state = this._reporterState;
  23031. this.exitKey(index);
  23032. if (state.obj !== null) state.obj[key] = value;
  23033. };
  23034. Reporter.prototype.path = function path() {
  23035. return this._reporterState.path.join('/');
  23036. };
  23037. Reporter.prototype.enterObject = function enterObject() {
  23038. var state = this._reporterState;
  23039. var prev = state.obj;
  23040. state.obj = {};
  23041. return prev;
  23042. };
  23043. Reporter.prototype.leaveObject = function leaveObject(prev) {
  23044. var state = this._reporterState;
  23045. var now = state.obj;
  23046. state.obj = prev;
  23047. return now;
  23048. };
  23049. Reporter.prototype.error = function error(msg) {
  23050. var err;
  23051. var state = this._reporterState;
  23052. var inherited = msg instanceof ReporterError;
  23053. if (inherited) {
  23054. err = msg;
  23055. } else {
  23056. err = new ReporterError(state.path.map(function (elem) {
  23057. return '[' + JSON.stringify(elem) + ']';
  23058. }).join(''), msg.message || msg, msg.stack);
  23059. }
  23060. if (!state.options.partial) throw err;
  23061. if (!inherited) state.errors.push(err);
  23062. return err;
  23063. };
  23064. Reporter.prototype.wrapResult = function wrapResult(result) {
  23065. var state = this._reporterState;
  23066. if (!state.options.partial) return result;
  23067. return {
  23068. result: this.isError(result) ? null : result,
  23069. errors: state.errors
  23070. };
  23071. };
  23072. function ReporterError(path, msg) {
  23073. this.path = path;
  23074. this.rethrow(msg);
  23075. }
  23076. inherits(ReporterError, Error);
  23077. ReporterError.prototype.rethrow = function rethrow(msg) {
  23078. this.message = msg + ' at: ' + (this.path || '(shallow)');
  23079. if (Error.captureStackTrace) Error.captureStackTrace(this, ReporterError);
  23080. if (!this.stack) {
  23081. try {
  23082. // IE only adds stack when thrown
  23083. throw new Error(this.message);
  23084. } catch (e) {
  23085. this.stack = e.stack;
  23086. }
  23087. }
  23088. return this;
  23089. };
  23090. }, { "inherits": 387 }], 173: [function (require, module, exports) {
  23091. 'use strict'; // Helper
  23092. function reverse(map) {
  23093. var res = {};
  23094. Object.keys(map).forEach(function (key) {
  23095. // Convert key to integer if it is stringified
  23096. if ((key | 0) == key) key = key | 0;
  23097. var value = map[key];
  23098. res[value] = key;
  23099. });
  23100. return res;
  23101. }
  23102. exports.tagClass = {
  23103. 0: 'universal',
  23104. 1: 'application',
  23105. 2: 'context',
  23106. 3: 'private'
  23107. };
  23108. exports.tagClassByName = reverse(exports.tagClass);
  23109. exports.tag = {
  23110. 0x00: 'end',
  23111. 0x01: 'bool',
  23112. 0x02: 'int',
  23113. 0x03: 'bitstr',
  23114. 0x04: 'octstr',
  23115. 0x05: 'null_',
  23116. 0x06: 'objid',
  23117. 0x07: 'objDesc',
  23118. 0x08: 'external',
  23119. 0x09: 'real',
  23120. 0x0a: 'enum',
  23121. 0x0b: 'embed',
  23122. 0x0c: 'utf8str',
  23123. 0x0d: 'relativeOid',
  23124. 0x10: 'seq',
  23125. 0x11: 'set',
  23126. 0x12: 'numstr',
  23127. 0x13: 'printstr',
  23128. 0x14: 't61str',
  23129. 0x15: 'videostr',
  23130. 0x16: 'ia5str',
  23131. 0x17: 'utctime',
  23132. 0x18: 'gentime',
  23133. 0x19: 'graphstr',
  23134. 0x1a: 'iso646str',
  23135. 0x1b: 'genstr',
  23136. 0x1c: 'unistr',
  23137. 0x1d: 'charstr',
  23138. 0x1e: 'bmpstr'
  23139. };
  23140. exports.tagByName = reverse(exports.tag);
  23141. }, {}], 174: [function (require, module, exports) {
  23142. 'use strict';
  23143. var constants = exports; // Helper
  23144. constants._reverse = function reverse(map) {
  23145. var res = {};
  23146. Object.keys(map).forEach(function (key) {
  23147. // Convert key to integer if it is stringified
  23148. if ((key | 0) == key) key = key | 0;
  23149. var value = map[key];
  23150. res[value] = key;
  23151. });
  23152. return res;
  23153. };
  23154. constants.der = require('./der');
  23155. }, { "./der": 173 }], 175: [function (require, module, exports) {
  23156. 'use strict';
  23157. var inherits = require('inherits');
  23158. var bignum = require('bn.js');
  23159. var DecoderBuffer = require('../base/buffer').DecoderBuffer;
  23160. var Node = require('../base/node'); // Import DER constants
  23161. var der = require('../constants/der');
  23162. function DERDecoder(entity) {
  23163. this.enc = 'der';
  23164. this.name = entity.name;
  23165. this.entity = entity; // Construct base tree
  23166. this.tree = new DERNode();
  23167. this.tree._init(entity.body);
  23168. }
  23169. module.exports = DERDecoder;
  23170. DERDecoder.prototype.decode = function decode(data, options) {
  23171. if (!DecoderBuffer.isDecoderBuffer(data)) {
  23172. data = new DecoderBuffer(data, options);
  23173. }
  23174. return this.tree._decode(data, options);
  23175. }; // Tree methods
  23176. function DERNode(parent) {
  23177. Node.call(this, 'der', parent);
  23178. }
  23179. inherits(DERNode, Node);
  23180. DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
  23181. if (buffer.isEmpty()) return false;
  23182. var state = buffer.save();
  23183. var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
  23184. if (buffer.isError(decodedTag)) return decodedTag;
  23185. buffer.restore(state);
  23186. return decodedTag.tag === tag || decodedTag.tagStr === tag || decodedTag.tagStr + 'of' === tag || any;
  23187. };
  23188. DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
  23189. var decodedTag = derDecodeTag(buffer, 'Failed to decode tag of "' + tag + '"');
  23190. if (buffer.isError(decodedTag)) return decodedTag;
  23191. var len = derDecodeLen(buffer, decodedTag.primitive, 'Failed to get length of "' + tag + '"'); // Failure
  23192. if (buffer.isError(len)) return len;
  23193. if (!any && decodedTag.tag !== tag && decodedTag.tagStr !== tag && decodedTag.tagStr + 'of' !== tag) {
  23194. return buffer.error('Failed to match tag: "' + tag + '"');
  23195. }
  23196. if (decodedTag.primitive || len !== null) return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); // Indefinite length... find END tag
  23197. var state = buffer.save();
  23198. var res = this._skipUntilEnd(buffer, 'Failed to skip indefinite length body: "' + this.tag + '"');
  23199. if (buffer.isError(res)) return res;
  23200. len = buffer.offset - state.offset;
  23201. buffer.restore(state);
  23202. return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
  23203. };
  23204. DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
  23205. for (; ;) {
  23206. var tag = derDecodeTag(buffer, fail);
  23207. if (buffer.isError(tag)) return tag;
  23208. var len = derDecodeLen(buffer, tag.primitive, fail);
  23209. if (buffer.isError(len)) return len;
  23210. var res = void 0;
  23211. if (tag.primitive || len !== null) res = buffer.skip(len); else res = this._skipUntilEnd(buffer, fail); // Failure
  23212. if (buffer.isError(res)) return res;
  23213. if (tag.tagStr === 'end') break;
  23214. }
  23215. };
  23216. DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, options) {
  23217. var result = [];
  23218. while (!buffer.isEmpty()) {
  23219. var possibleEnd = this._peekTag(buffer, 'end');
  23220. if (buffer.isError(possibleEnd)) return possibleEnd;
  23221. var res = decoder.decode(buffer, 'der', options);
  23222. if (buffer.isError(res) && possibleEnd) break;
  23223. result.push(res);
  23224. }
  23225. return result;
  23226. };
  23227. DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
  23228. if (tag === 'bitstr') {
  23229. var unused = buffer.readUInt8();
  23230. if (buffer.isError(unused)) return unused;
  23231. return {
  23232. unused: unused,
  23233. data: buffer.raw()
  23234. };
  23235. } else if (tag === 'bmpstr') {
  23236. var raw = buffer.raw();
  23237. if (raw.length % 2 === 1) return buffer.error('Decoding of string type: bmpstr length mismatch');
  23238. var str = '';
  23239. for (var i = 0; i < raw.length / 2; i++) {
  23240. str += String.fromCharCode(raw.readUInt16BE(i * 2));
  23241. }
  23242. return str;
  23243. } else if (tag === 'numstr') {
  23244. var numstr = buffer.raw().toString('ascii');
  23245. if (!this._isNumstr(numstr)) {
  23246. return buffer.error('Decoding of string type: ' + 'numstr unsupported characters');
  23247. }
  23248. return numstr;
  23249. } else if (tag === 'octstr') {
  23250. return buffer.raw();
  23251. } else if (tag === 'objDesc') {
  23252. return buffer.raw();
  23253. } else if (tag === 'printstr') {
  23254. var printstr = buffer.raw().toString('ascii');
  23255. if (!this._isPrintstr(printstr)) {
  23256. return buffer.error('Decoding of string type: ' + 'printstr unsupported characters');
  23257. }
  23258. return printstr;
  23259. } else if (/str$/.test(tag)) {
  23260. return buffer.raw().toString();
  23261. } else {
  23262. return buffer.error('Decoding of string type: ' + tag + ' unsupported');
  23263. }
  23264. };
  23265. DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
  23266. var result;
  23267. var identifiers = [];
  23268. var ident = 0;
  23269. var subident = 0;
  23270. while (!buffer.isEmpty()) {
  23271. subident = buffer.readUInt8();
  23272. ident <<= 7;
  23273. ident |= subident & 0x7f;
  23274. if ((subident & 0x80) === 0) {
  23275. identifiers.push(ident);
  23276. ident = 0;
  23277. }
  23278. }
  23279. if (subident & 0x80) identifiers.push(ident);
  23280. var first = identifiers[0] / 40 | 0;
  23281. var second = identifiers[0] % 40;
  23282. if (relative) result = identifiers; else result = [first, second].concat(identifiers.slice(1));
  23283. if (values) {
  23284. var tmp = values[result.join(' ')];
  23285. if (tmp === undefined) tmp = values[result.join('.')];
  23286. if (tmp !== undefined) result = tmp;
  23287. }
  23288. return result;
  23289. };
  23290. DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
  23291. var str = buffer.raw().toString();
  23292. var year;
  23293. var mon;
  23294. var day;
  23295. var hour;
  23296. var min;
  23297. var sec;
  23298. if (tag === 'gentime') {
  23299. year = str.slice(0, 4) | 0;
  23300. mon = str.slice(4, 6) | 0;
  23301. day = str.slice(6, 8) | 0;
  23302. hour = str.slice(8, 10) | 0;
  23303. min = str.slice(10, 12) | 0;
  23304. sec = str.slice(12, 14) | 0;
  23305. } else if (tag === 'utctime') {
  23306. year = str.slice(0, 2) | 0;
  23307. mon = str.slice(2, 4) | 0;
  23308. day = str.slice(4, 6) | 0;
  23309. hour = str.slice(6, 8) | 0;
  23310. min = str.slice(8, 10) | 0;
  23311. sec = str.slice(10, 12) | 0;
  23312. if (year < 70) year = 2000 + year; else year = 1900 + year;
  23313. } else {
  23314. return buffer.error('Decoding ' + tag + ' time is not supported yet');
  23315. }
  23316. return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
  23317. };
  23318. DERNode.prototype._decodeNull = function decodeNull() {
  23319. return null;
  23320. };
  23321. DERNode.prototype._decodeBool = function decodeBool(buffer) {
  23322. var res = buffer.readUInt8();
  23323. if (buffer.isError(res)) return res; else return res !== 0;
  23324. };
  23325. DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
  23326. // Bigint, return as it is (assume big endian)
  23327. var raw = buffer.raw();
  23328. var res = new bignum(raw);
  23329. if (values) res = values[res.toString(10)] || res;
  23330. return res;
  23331. };
  23332. DERNode.prototype._use = function use(entity, obj) {
  23333. if (typeof entity === 'function') entity = entity(obj);
  23334. return entity._getDecoder('der').tree;
  23335. }; // Utility methods
  23336. function derDecodeTag(buf, fail) {
  23337. var tag = buf.readUInt8(fail);
  23338. if (buf.isError(tag)) return tag;
  23339. var cls = der.tagClass[tag >> 6];
  23340. var primitive = (tag & 0x20) === 0; // Multi-octet tag - load
  23341. if ((tag & 0x1f) === 0x1f) {
  23342. var oct = tag;
  23343. tag = 0;
  23344. while ((oct & 0x80) === 0x80) {
  23345. oct = buf.readUInt8(fail);
  23346. if (buf.isError(oct)) return oct;
  23347. tag <<= 7;
  23348. tag |= oct & 0x7f;
  23349. }
  23350. } else {
  23351. tag &= 0x1f;
  23352. }
  23353. var tagStr = der.tag[tag];
  23354. return {
  23355. cls: cls,
  23356. primitive: primitive,
  23357. tag: tag,
  23358. tagStr: tagStr
  23359. };
  23360. }
  23361. function derDecodeLen(buf, primitive, fail) {
  23362. var len = buf.readUInt8(fail);
  23363. if (buf.isError(len)) return len; // Indefinite form
  23364. if (!primitive && len === 0x80) return null; // Definite form
  23365. if ((len & 0x80) === 0) {
  23366. // Short form
  23367. return len;
  23368. } // Long form
  23369. var num = len & 0x7f;
  23370. if (num > 4) return buf.error('length octect is too long');
  23371. len = 0;
  23372. for (var i = 0; i < num; i++) {
  23373. len <<= 8;
  23374. var j = buf.readUInt8(fail);
  23375. if (buf.isError(j)) return j;
  23376. len |= j;
  23377. }
  23378. return len;
  23379. }
  23380. }, { "../base/buffer": 169, "../base/node": 171, "../constants/der": 173, "bn.js": 181, "inherits": 387 }], 176: [function (require, module, exports) {
  23381. 'use strict';
  23382. var decoders = exports;
  23383. decoders.der = require('./der');
  23384. decoders.pem = require('./pem');
  23385. }, { "./der": 175, "./pem": 177 }], 177: [function (require, module, exports) {
  23386. 'use strict';
  23387. var inherits = require('inherits');
  23388. var Buffer = require('safer-buffer').Buffer;
  23389. var DERDecoder = require('./der');
  23390. function PEMDecoder(entity) {
  23391. DERDecoder.call(this, entity);
  23392. this.enc = 'pem';
  23393. }
  23394. inherits(PEMDecoder, DERDecoder);
  23395. module.exports = PEMDecoder;
  23396. PEMDecoder.prototype.decode = function decode(data, options) {
  23397. var lines = data.toString().split(/[\r\n]+/g);
  23398. var label = options.label.toUpperCase();
  23399. var re = /^-----(BEGIN|END) ([^-]+)-----$/;
  23400. var start = -1;
  23401. var end = -1;
  23402. for (var i = 0; i < lines.length; i++) {
  23403. var match = lines[i].match(re);
  23404. if (match === null) continue;
  23405. if (match[2] !== label) continue;
  23406. if (start === -1) {
  23407. if (match[1] !== 'BEGIN') break;
  23408. start = i;
  23409. } else {
  23410. if (match[1] !== 'END') break;
  23411. end = i;
  23412. break;
  23413. }
  23414. }
  23415. if (start === -1 || end === -1) throw new Error('PEM section not found for: ' + label);
  23416. var base64 = lines.slice(start + 1, end).join(''); // Remove excessive symbols
  23417. base64.replace(/[^a-z0-9+/=]+/gi, '');
  23418. var input = Buffer.from(base64, 'base64');
  23419. return DERDecoder.prototype.decode.call(this, input, options);
  23420. };
  23421. }, { "./der": 175, "inherits": 387, "safer-buffer": 495 }], 178: [function (require, module, exports) {
  23422. 'use strict';
  23423. var inherits = require('inherits');
  23424. var Buffer = require('safer-buffer').Buffer;
  23425. var Node = require('../base/node'); // Import DER constants
  23426. var der = require('../constants/der');
  23427. function DEREncoder(entity) {
  23428. this.enc = 'der';
  23429. this.name = entity.name;
  23430. this.entity = entity; // Construct base tree
  23431. this.tree = new DERNode();
  23432. this.tree._init(entity.body);
  23433. }
  23434. module.exports = DEREncoder;
  23435. DEREncoder.prototype.encode = function encode(data, reporter) {
  23436. return this.tree._encode(data, reporter).join();
  23437. }; // Tree methods
  23438. function DERNode(parent) {
  23439. Node.call(this, 'der', parent);
  23440. }
  23441. inherits(DERNode, Node);
  23442. DERNode.prototype._encodeComposite = function encodeComposite(tag, primitive, cls, content) {
  23443. var encodedTag = encodeTag(tag, primitive, cls, this.reporter); // Short form
  23444. if (content.length < 0x80) {
  23445. var _header = Buffer.alloc(2);
  23446. _header[0] = encodedTag;
  23447. _header[1] = content.length;
  23448. return this._createEncoderBuffer([_header, content]);
  23449. } // Long form
  23450. // Count octets required to store length
  23451. var lenOctets = 1;
  23452. for (var i = content.length; i >= 0x100; i >>= 8) {
  23453. lenOctets++;
  23454. }
  23455. var header = Buffer.alloc(1 + 1 + lenOctets);
  23456. header[0] = encodedTag;
  23457. header[1] = 0x80 | lenOctets;
  23458. for (var _i = 1 + lenOctets, j = content.length; j > 0; _i--, j >>= 8) {
  23459. header[_i] = j & 0xff;
  23460. }
  23461. return this._createEncoderBuffer([header, content]);
  23462. };
  23463. DERNode.prototype._encodeStr = function encodeStr(str, tag) {
  23464. if (tag === 'bitstr') {
  23465. return this._createEncoderBuffer([str.unused | 0, str.data]);
  23466. } else if (tag === 'bmpstr') {
  23467. var buf = Buffer.alloc(str.length * 2);
  23468. for (var i = 0; i < str.length; i++) {
  23469. buf.writeUInt16BE(str.charCodeAt(i), i * 2);
  23470. }
  23471. return this._createEncoderBuffer(buf);
  23472. } else if (tag === 'numstr') {
  23473. if (!this._isNumstr(str)) {
  23474. return this.reporter.error('Encoding of string type: numstr supports ' + 'only digits and space');
  23475. }
  23476. return this._createEncoderBuffer(str);
  23477. } else if (tag === 'printstr') {
  23478. if (!this._isPrintstr(str)) {
  23479. return 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');
  23480. }
  23481. return this._createEncoderBuffer(str);
  23482. } else if (/str$/.test(tag)) {
  23483. return this._createEncoderBuffer(str);
  23484. } else if (tag === 'objDesc') {
  23485. return this._createEncoderBuffer(str);
  23486. } else {
  23487. return this.reporter.error('Encoding of string type: ' + tag + ' unsupported');
  23488. }
  23489. };
  23490. DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
  23491. if (typeof id === 'string') {
  23492. if (!values) return this.reporter.error('string objid given, but no values map found');
  23493. if (!values.hasOwnProperty(id)) return this.reporter.error('objid not found in values map');
  23494. id = values[id].split(/[\s.]+/g);
  23495. for (var i = 0; i < id.length; i++) {
  23496. id[i] |= 0;
  23497. }
  23498. } else if (Array.isArray(id)) {
  23499. id = id.slice();
  23500. for (var _i2 = 0; _i2 < id.length; _i2++) {
  23501. id[_i2] |= 0;
  23502. }
  23503. }
  23504. if (!Array.isArray(id)) {
  23505. return this.reporter.error('objid() should be either array or string, ' + 'got: ' + JSON.stringify(id));
  23506. }
  23507. if (!relative) {
  23508. if (id[1] >= 40) return this.reporter.error('Second objid identifier OOB');
  23509. id.splice(0, 2, id[0] * 40 + id[1]);
  23510. } // Count number of octets
  23511. var size = 0;
  23512. for (var _i3 = 0; _i3 < id.length; _i3++) {
  23513. var ident = id[_i3];
  23514. for (size++; ident >= 0x80; ident >>= 7) {
  23515. size++;
  23516. }
  23517. }
  23518. var objid = Buffer.alloc(size);
  23519. var offset = objid.length - 1;
  23520. for (var _i4 = id.length - 1; _i4 >= 0; _i4--) {
  23521. var _ident = id[_i4];
  23522. objid[offset--] = _ident & 0x7f;
  23523. while ((_ident >>= 7) > 0) {
  23524. objid[offset--] = 0x80 | _ident & 0x7f;
  23525. }
  23526. }
  23527. return this._createEncoderBuffer(objid);
  23528. };
  23529. function two(num) {
  23530. if (num < 10) return '0' + num; else return num;
  23531. }
  23532. DERNode.prototype._encodeTime = function encodeTime(time, tag) {
  23533. var str;
  23534. var date = new Date(time);
  23535. if (tag === 'gentime') {
  23536. str = [two(date.getUTCFullYear()), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), two(date.getUTCMinutes()), two(date.getUTCSeconds()), 'Z'].join('');
  23537. } else if (tag === 'utctime') {
  23538. str = [two(date.getUTCFullYear() % 100), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), two(date.getUTCMinutes()), two(date.getUTCSeconds()), 'Z'].join('');
  23539. } else {
  23540. this.reporter.error('Encoding ' + tag + ' time is not supported yet');
  23541. }
  23542. return this._encodeStr(str, 'octstr');
  23543. };
  23544. DERNode.prototype._encodeNull = function encodeNull() {
  23545. return this._createEncoderBuffer('');
  23546. };
  23547. DERNode.prototype._encodeInt = function encodeInt(num, values) {
  23548. if (typeof num === 'string') {
  23549. if (!values) return this.reporter.error('String int or enum given, but no values map');
  23550. if (!values.hasOwnProperty(num)) {
  23551. return this.reporter.error('Values map doesn\'t contain: ' + JSON.stringify(num));
  23552. }
  23553. num = values[num];
  23554. } // Bignum, assume big endian
  23555. if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
  23556. var numArray = num.toArray();
  23557. if (!num.sign && numArray[0] & 0x80) {
  23558. numArray.unshift(0);
  23559. }
  23560. num = Buffer.from(numArray);
  23561. }
  23562. if (Buffer.isBuffer(num)) {
  23563. var _size = num.length;
  23564. if (num.length === 0) _size++;
  23565. var _out = Buffer.alloc(_size);
  23566. num.copy(_out);
  23567. if (num.length === 0) _out[0] = 0;
  23568. return this._createEncoderBuffer(_out);
  23569. }
  23570. if (num < 0x80) return this._createEncoderBuffer(num);
  23571. if (num < 0x100) return this._createEncoderBuffer([0, num]);
  23572. var size = 1;
  23573. for (var i = num; i >= 0x100; i >>= 8) {
  23574. size++;
  23575. }
  23576. var out = new Array(size);
  23577. for (var _i5 = out.length - 1; _i5 >= 0; _i5--) {
  23578. out[_i5] = num & 0xff;
  23579. num >>= 8;
  23580. }
  23581. if (out[0] & 0x80) {
  23582. out.unshift(0);
  23583. }
  23584. return this._createEncoderBuffer(Buffer.from(out));
  23585. };
  23586. DERNode.prototype._encodeBool = function encodeBool(value) {
  23587. return this._createEncoderBuffer(value ? 0xff : 0);
  23588. };
  23589. DERNode.prototype._use = function use(entity, obj) {
  23590. if (typeof entity === 'function') entity = entity(obj);
  23591. return entity._getEncoder('der').tree;
  23592. };
  23593. DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
  23594. var state = this._baseState;
  23595. var i;
  23596. if (state['default'] === null) return false;
  23597. var data = dataBuffer.join();
  23598. if (state.defaultBuffer === undefined) state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
  23599. if (data.length !== state.defaultBuffer.length) return false;
  23600. for (i = 0; i < data.length; i++) {
  23601. if (data[i] !== state.defaultBuffer[i]) return false;
  23602. }
  23603. return true;
  23604. }; // Utility methods
  23605. function encodeTag(tag, primitive, cls, reporter) {
  23606. var res;
  23607. if (tag === 'seqof') tag = 'seq'; else if (tag === 'setof') tag = 'set';
  23608. if (der.tagByName.hasOwnProperty(tag)) res = der.tagByName[tag]; else if (typeof tag === 'number' && (tag | 0) === tag) res = tag; else return reporter.error('Unknown tag: ' + tag);
  23609. if (res >= 0x1f) return reporter.error('Multi-octet tag encoding unsupported');
  23610. if (!primitive) res |= 0x20;
  23611. res |= der.tagClassByName[cls || 'universal'] << 6;
  23612. return res;
  23613. }
  23614. }, { "../base/node": 171, "../constants/der": 173, "inherits": 387, "safer-buffer": 495 }], 179: [function (require, module, exports) {
  23615. 'use strict';
  23616. var encoders = exports;
  23617. encoders.der = require('./der');
  23618. encoders.pem = require('./pem');
  23619. }, { "./der": 178, "./pem": 180 }], 180: [function (require, module, exports) {
  23620. 'use strict';
  23621. var inherits = require('inherits');
  23622. var DEREncoder = require('./der');
  23623. function PEMEncoder(entity) {
  23624. DEREncoder.call(this, entity);
  23625. this.enc = 'pem';
  23626. }
  23627. inherits(PEMEncoder, DEREncoder);
  23628. module.exports = PEMEncoder;
  23629. PEMEncoder.prototype.encode = function encode(data, options) {
  23630. var buf = DEREncoder.prototype.encode.call(this, data);
  23631. var p = buf.toString('base64');
  23632. var out = ['-----BEGIN ' + options.label + '-----'];
  23633. for (var i = 0; i < p.length; i += 64) {
  23634. out.push(p.slice(i, i + 64));
  23635. }
  23636. out.push('-----END ' + options.label + '-----');
  23637. return out.join('\n');
  23638. };
  23639. }, { "./der": 178, "inherits": 387 }], 181: [function (require, module, exports) {
  23640. "use strict";
  23641. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  23642. (function (module, exports) {
  23643. 'use strict'; // Utils
  23644. function assert(val, msg) {
  23645. if (!val) throw new Error(msg || 'Assertion failed');
  23646. } // Could use `inherits` module, but don't want to move from single file
  23647. // architecture yet.
  23648. function inherits(ctor, superCtor) {
  23649. ctor.super_ = superCtor;
  23650. var TempCtor = function TempCtor() { };
  23651. TempCtor.prototype = superCtor.prototype;
  23652. ctor.prototype = new TempCtor();
  23653. ctor.prototype.constructor = ctor;
  23654. } // BN
  23655. function BN(number, base, endian) {
  23656. if (BN.isBN(number)) {
  23657. return number;
  23658. }
  23659. this.negative = 0;
  23660. this.words = null;
  23661. this.length = 0; // Reduction context
  23662. this.red = null;
  23663. if (number !== null) {
  23664. if (base === 'le' || base === 'be') {
  23665. endian = base;
  23666. base = 10;
  23667. }
  23668. this._init(number || 0, base || 10, endian || 'be');
  23669. }
  23670. }
  23671. if (_typeof(module) === 'object') {
  23672. module.exports = BN;
  23673. } else {
  23674. exports.BN = BN;
  23675. }
  23676. BN.BN = BN;
  23677. BN.wordSize = 26;
  23678. var Buffer;
  23679. try {
  23680. Buffer = require('buffer').Buffer;
  23681. } catch (e) { }
  23682. BN.isBN = function isBN(num) {
  23683. if (num instanceof BN) {
  23684. return true;
  23685. }
  23686. return num !== null && _typeof(num) === 'object' && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  23687. };
  23688. BN.max = function max(left, right) {
  23689. if (left.cmp(right) > 0) return left;
  23690. return right;
  23691. };
  23692. BN.min = function min(left, right) {
  23693. if (left.cmp(right) < 0) return left;
  23694. return right;
  23695. };
  23696. BN.prototype._init = function init(number, base, endian) {
  23697. if (typeof number === 'number') {
  23698. return this._initNumber(number, base, endian);
  23699. }
  23700. if (_typeof(number) === 'object') {
  23701. return this._initArray(number, base, endian);
  23702. }
  23703. if (base === 'hex') {
  23704. base = 16;
  23705. }
  23706. assert(base === (base | 0) && base >= 2 && base <= 36);
  23707. number = number.toString().replace(/\s+/g, '');
  23708. var start = 0;
  23709. if (number[0] === '-') {
  23710. start++;
  23711. }
  23712. if (base === 16) {
  23713. this._parseHex(number, start);
  23714. } else {
  23715. this._parseBase(number, base, start);
  23716. }
  23717. if (number[0] === '-') {
  23718. this.negative = 1;
  23719. }
  23720. this.strip();
  23721. if (endian !== 'le') return;
  23722. this._initArray(this.toArray(), base, endian);
  23723. };
  23724. BN.prototype._initNumber = function _initNumber(number, base, endian) {
  23725. if (number < 0) {
  23726. this.negative = 1;
  23727. number = -number;
  23728. }
  23729. if (number < 0x4000000) {
  23730. this.words = [number & 0x3ffffff];
  23731. this.length = 1;
  23732. } else if (number < 0x10000000000000) {
  23733. this.words = [number & 0x3ffffff, number / 0x4000000 & 0x3ffffff];
  23734. this.length = 2;
  23735. } else {
  23736. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  23737. this.words = [number & 0x3ffffff, number / 0x4000000 & 0x3ffffff, 1];
  23738. this.length = 3;
  23739. }
  23740. if (endian !== 'le') return; // Reverse the bytes
  23741. this._initArray(this.toArray(), base, endian);
  23742. };
  23743. BN.prototype._initArray = function _initArray(number, base, endian) {
  23744. // Perhaps a Uint8Array
  23745. assert(typeof number.length === 'number');
  23746. if (number.length <= 0) {
  23747. this.words = [0];
  23748. this.length = 1;
  23749. return this;
  23750. }
  23751. this.length = Math.ceil(number.length / 3);
  23752. this.words = new Array(this.length);
  23753. for (var i = 0; i < this.length; i++) {
  23754. this.words[i] = 0;
  23755. }
  23756. var j, w;
  23757. var off = 0;
  23758. if (endian === 'be') {
  23759. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  23760. w = number[i] | number[i - 1] << 8 | number[i - 2] << 16;
  23761. this.words[j] |= w << off & 0x3ffffff;
  23762. this.words[j + 1] = w >>> 26 - off & 0x3ffffff;
  23763. off += 24;
  23764. if (off >= 26) {
  23765. off -= 26;
  23766. j++;
  23767. }
  23768. }
  23769. } else if (endian === 'le') {
  23770. for (i = 0, j = 0; i < number.length; i += 3) {
  23771. w = number[i] | number[i + 1] << 8 | number[i + 2] << 16;
  23772. this.words[j] |= w << off & 0x3ffffff;
  23773. this.words[j + 1] = w >>> 26 - off & 0x3ffffff;
  23774. off += 24;
  23775. if (off >= 26) {
  23776. off -= 26;
  23777. j++;
  23778. }
  23779. }
  23780. }
  23781. return this.strip();
  23782. };
  23783. function parseHex(str, start, end) {
  23784. var r = 0;
  23785. var len = Math.min(str.length, end);
  23786. for (var i = start; i < len; i++) {
  23787. var c = str.charCodeAt(i) - 48;
  23788. r <<= 4; // 'a' - 'f'
  23789. if (c >= 49 && c <= 54) {
  23790. r |= c - 49 + 0xa; // 'A' - 'F'
  23791. } else if (c >= 17 && c <= 22) {
  23792. r |= c - 17 + 0xa; // '0' - '9'
  23793. } else {
  23794. r |= c & 0xf;
  23795. }
  23796. }
  23797. return r;
  23798. }
  23799. BN.prototype._parseHex = function _parseHex(number, start) {
  23800. // Create possibly bigger array to ensure that it fits the number
  23801. this.length = Math.ceil((number.length - start) / 6);
  23802. this.words = new Array(this.length);
  23803. for (var i = 0; i < this.length; i++) {
  23804. this.words[i] = 0;
  23805. }
  23806. var j, w; // Scan 24-bit chunks and add them to the number
  23807. var off = 0;
  23808. for (i = number.length - 6, j = 0; i >= start; i -= 6) {
  23809. w = parseHex(number, i, i + 6);
  23810. this.words[j] |= w << off & 0x3ffffff; // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
  23811. this.words[j + 1] |= w >>> 26 - off & 0x3fffff;
  23812. off += 24;
  23813. if (off >= 26) {
  23814. off -= 26;
  23815. j++;
  23816. }
  23817. }
  23818. if (i + 6 !== start) {
  23819. w = parseHex(number, start, i + 6);
  23820. this.words[j] |= w << off & 0x3ffffff;
  23821. this.words[j + 1] |= w >>> 26 - off & 0x3fffff;
  23822. }
  23823. this.strip();
  23824. };
  23825. function parseBase(str, start, end, mul) {
  23826. var r = 0;
  23827. var len = Math.min(str.length, end);
  23828. for (var i = start; i < len; i++) {
  23829. var c = str.charCodeAt(i) - 48;
  23830. r *= mul; // 'a'
  23831. if (c >= 49) {
  23832. r += c - 49 + 0xa; // 'A'
  23833. } else if (c >= 17) {
  23834. r += c - 17 + 0xa; // '0' - '9'
  23835. } else {
  23836. r += c;
  23837. }
  23838. }
  23839. return r;
  23840. }
  23841. BN.prototype._parseBase = function _parseBase(number, base, start) {
  23842. // Initialize as zero
  23843. this.words = [0];
  23844. this.length = 1; // Find length of limb in base
  23845. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  23846. limbLen++;
  23847. }
  23848. limbLen--;
  23849. limbPow = limbPow / base | 0;
  23850. var total = number.length - start;
  23851. var mod = total % limbLen;
  23852. var end = Math.min(total, total - mod) + start;
  23853. var word = 0;
  23854. for (var i = start; i < end; i += limbLen) {
  23855. word = parseBase(number, i, i + limbLen, base);
  23856. this.imuln(limbPow);
  23857. if (this.words[0] + word < 0x4000000) {
  23858. this.words[0] += word;
  23859. } else {
  23860. this._iaddn(word);
  23861. }
  23862. }
  23863. if (mod !== 0) {
  23864. var pow = 1;
  23865. word = parseBase(number, i, number.length, base);
  23866. for (i = 0; i < mod; i++) {
  23867. pow *= base;
  23868. }
  23869. this.imuln(pow);
  23870. if (this.words[0] + word < 0x4000000) {
  23871. this.words[0] += word;
  23872. } else {
  23873. this._iaddn(word);
  23874. }
  23875. }
  23876. };
  23877. BN.prototype.copy = function copy(dest) {
  23878. dest.words = new Array(this.length);
  23879. for (var i = 0; i < this.length; i++) {
  23880. dest.words[i] = this.words[i];
  23881. }
  23882. dest.length = this.length;
  23883. dest.negative = this.negative;
  23884. dest.red = this.red;
  23885. };
  23886. BN.prototype.clone = function clone() {
  23887. var r = new BN(null);
  23888. this.copy(r);
  23889. return r;
  23890. };
  23891. BN.prototype._expand = function _expand(size) {
  23892. while (this.length < size) {
  23893. this.words[this.length++] = 0;
  23894. }
  23895. return this;
  23896. }; // Remove leading `0` from `this`
  23897. BN.prototype.strip = function strip() {
  23898. while (this.length > 1 && this.words[this.length - 1] === 0) {
  23899. this.length--;
  23900. }
  23901. return this._normSign();
  23902. };
  23903. BN.prototype._normSign = function _normSign() {
  23904. // -0 = 0
  23905. if (this.length === 1 && this.words[0] === 0) {
  23906. this.negative = 0;
  23907. }
  23908. return this;
  23909. };
  23910. BN.prototype.inspect = function inspect() {
  23911. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  23912. };
  23913. /*
  23914. var zeros = [];
  23915. var groupSizes = [];
  23916. var groupBases = [];
  23917. var s = '';
  23918. var i = -1;
  23919. while (++i < BN.wordSize) {
  23920. zeros[i] = s;
  23921. s += '0';
  23922. }
  23923. groupSizes[0] = 0;
  23924. groupSizes[1] = 0;
  23925. groupBases[0] = 0;
  23926. groupBases[1] = 0;
  23927. var base = 2 - 1;
  23928. while (++base < 36 + 1) {
  23929. var groupSize = 0;
  23930. var groupBase = 1;
  23931. while (groupBase < (1 << BN.wordSize) / base) {
  23932. groupBase *= base;
  23933. groupSize += 1;
  23934. }
  23935. groupSizes[base] = groupSize;
  23936. groupBases[base] = groupBase;
  23937. }
  23938. */
  23939. var zeros = ['', '0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '000000000', '0000000000', '00000000000', '000000000000', '0000000000000', '00000000000000', '000000000000000', '0000000000000000', '00000000000000000', '000000000000000000', '0000000000000000000', '00000000000000000000', '000000000000000000000', '0000000000000000000000', '00000000000000000000000', '000000000000000000000000', '0000000000000000000000000'];
  23940. var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5];
  23941. var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176];
  23942. BN.prototype.toString = function toString(base, padding) {
  23943. base = base || 10;
  23944. padding = padding | 0 || 1;
  23945. var out;
  23946. if (base === 16 || base === 'hex') {
  23947. out = '';
  23948. var off = 0;
  23949. var carry = 0;
  23950. for (var i = 0; i < this.length; i++) {
  23951. var w = this.words[i];
  23952. var word = ((w << off | carry) & 0xffffff).toString(16);
  23953. carry = w >>> 24 - off & 0xffffff;
  23954. if (carry !== 0 || i !== this.length - 1) {
  23955. out = zeros[6 - word.length] + word + out;
  23956. } else {
  23957. out = word + out;
  23958. }
  23959. off += 2;
  23960. if (off >= 26) {
  23961. off -= 26;
  23962. i--;
  23963. }
  23964. }
  23965. if (carry !== 0) {
  23966. out = carry.toString(16) + out;
  23967. }
  23968. while (out.length % padding !== 0) {
  23969. out = '0' + out;
  23970. }
  23971. if (this.negative !== 0) {
  23972. out = '-' + out;
  23973. }
  23974. return out;
  23975. }
  23976. if (base === (base | 0) && base >= 2 && base <= 36) {
  23977. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  23978. var groupSize = groupSizes[base]; // var groupBase = Math.pow(base, groupSize);
  23979. var groupBase = groupBases[base];
  23980. out = '';
  23981. var c = this.clone();
  23982. c.negative = 0;
  23983. while (!c.isZero()) {
  23984. var r = c.modn(groupBase).toString(base);
  23985. c = c.idivn(groupBase);
  23986. if (!c.isZero()) {
  23987. out = zeros[groupSize - r.length] + r + out;
  23988. } else {
  23989. out = r + out;
  23990. }
  23991. }
  23992. if (this.isZero()) {
  23993. out = '0' + out;
  23994. }
  23995. while (out.length % padding !== 0) {
  23996. out = '0' + out;
  23997. }
  23998. if (this.negative !== 0) {
  23999. out = '-' + out;
  24000. }
  24001. return out;
  24002. }
  24003. assert(false, 'Base should be between 2 and 36');
  24004. };
  24005. BN.prototype.toNumber = function toNumber() {
  24006. var ret = this.words[0];
  24007. if (this.length === 2) {
  24008. ret += this.words[1] * 0x4000000;
  24009. } else if (this.length === 3 && this.words[2] === 0x01) {
  24010. // NOTE: at this stage it is known that the top bit is set
  24011. ret += 0x10000000000000 + this.words[1] * 0x4000000;
  24012. } else if (this.length > 2) {
  24013. assert(false, 'Number can only safely store up to 53 bits');
  24014. }
  24015. return this.negative !== 0 ? -ret : ret;
  24016. };
  24017. BN.prototype.toJSON = function toJSON() {
  24018. return this.toString(16);
  24019. };
  24020. BN.prototype.toBuffer = function toBuffer(endian, length) {
  24021. assert(typeof Buffer !== 'undefined');
  24022. return this.toArrayLike(Buffer, endian, length);
  24023. };
  24024. BN.prototype.toArray = function toArray(endian, length) {
  24025. return this.toArrayLike(Array, endian, length);
  24026. };
  24027. BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
  24028. var byteLength = this.byteLength();
  24029. var reqLength = length || Math.max(1, byteLength);
  24030. assert(byteLength <= reqLength, 'byte array longer than desired length');
  24031. assert(reqLength > 0, 'Requested array length <= 0');
  24032. this.strip();
  24033. var littleEndian = endian === 'le';
  24034. var res = new ArrayType(reqLength);
  24035. var b, i;
  24036. var q = this.clone();
  24037. if (!littleEndian) {
  24038. // Assume big-endian
  24039. for (i = 0; i < reqLength - byteLength; i++) {
  24040. res[i] = 0;
  24041. }
  24042. for (i = 0; !q.isZero(); i++) {
  24043. b = q.andln(0xff);
  24044. q.iushrn(8);
  24045. res[reqLength - i - 1] = b;
  24046. }
  24047. } else {
  24048. for (i = 0; !q.isZero(); i++) {
  24049. b = q.andln(0xff);
  24050. q.iushrn(8);
  24051. res[i] = b;
  24052. }
  24053. for (; i < reqLength; i++) {
  24054. res[i] = 0;
  24055. }
  24056. }
  24057. return res;
  24058. };
  24059. if (Math.clz32) {
  24060. BN.prototype._countBits = function _countBits(w) {
  24061. return 32 - Math.clz32(w);
  24062. };
  24063. } else {
  24064. BN.prototype._countBits = function _countBits(w) {
  24065. var t = w;
  24066. var r = 0;
  24067. if (t >= 0x1000) {
  24068. r += 13;
  24069. t >>>= 13;
  24070. }
  24071. if (t >= 0x40) {
  24072. r += 7;
  24073. t >>>= 7;
  24074. }
  24075. if (t >= 0x8) {
  24076. r += 4;
  24077. t >>>= 4;
  24078. }
  24079. if (t >= 0x02) {
  24080. r += 2;
  24081. t >>>= 2;
  24082. }
  24083. return r + t;
  24084. };
  24085. }
  24086. BN.prototype._zeroBits = function _zeroBits(w) {
  24087. // Short-cut
  24088. if (w === 0) return 26;
  24089. var t = w;
  24090. var r = 0;
  24091. if ((t & 0x1fff) === 0) {
  24092. r += 13;
  24093. t >>>= 13;
  24094. }
  24095. if ((t & 0x7f) === 0) {
  24096. r += 7;
  24097. t >>>= 7;
  24098. }
  24099. if ((t & 0xf) === 0) {
  24100. r += 4;
  24101. t >>>= 4;
  24102. }
  24103. if ((t & 0x3) === 0) {
  24104. r += 2;
  24105. t >>>= 2;
  24106. }
  24107. if ((t & 0x1) === 0) {
  24108. r++;
  24109. }
  24110. return r;
  24111. }; // Return number of used bits in a BN
  24112. BN.prototype.bitLength = function bitLength() {
  24113. var w = this.words[this.length - 1];
  24114. var hi = this._countBits(w);
  24115. return (this.length - 1) * 26 + hi;
  24116. };
  24117. function toBitArray(num) {
  24118. var w = new Array(num.bitLength());
  24119. for (var bit = 0; bit < w.length; bit++) {
  24120. var off = bit / 26 | 0;
  24121. var wbit = bit % 26;
  24122. w[bit] = (num.words[off] & 1 << wbit) >>> wbit;
  24123. }
  24124. return w;
  24125. } // Number of trailing zero bits
  24126. BN.prototype.zeroBits = function zeroBits() {
  24127. if (this.isZero()) return 0;
  24128. var r = 0;
  24129. for (var i = 0; i < this.length; i++) {
  24130. var b = this._zeroBits(this.words[i]);
  24131. r += b;
  24132. if (b !== 26) break;
  24133. }
  24134. return r;
  24135. };
  24136. BN.prototype.byteLength = function byteLength() {
  24137. return Math.ceil(this.bitLength() / 8);
  24138. };
  24139. BN.prototype.toTwos = function toTwos(width) {
  24140. if (this.negative !== 0) {
  24141. return this.abs().inotn(width).iaddn(1);
  24142. }
  24143. return this.clone();
  24144. };
  24145. BN.prototype.fromTwos = function fromTwos(width) {
  24146. if (this.testn(width - 1)) {
  24147. return this.notn(width).iaddn(1).ineg();
  24148. }
  24149. return this.clone();
  24150. };
  24151. BN.prototype.isNeg = function isNeg() {
  24152. return this.negative !== 0;
  24153. }; // Return negative clone of `this`
  24154. BN.prototype.neg = function neg() {
  24155. return this.clone().ineg();
  24156. };
  24157. BN.prototype.ineg = function ineg() {
  24158. if (!this.isZero()) {
  24159. this.negative ^= 1;
  24160. }
  24161. return this;
  24162. }; // Or `num` with `this` in-place
  24163. BN.prototype.iuor = function iuor(num) {
  24164. while (this.length < num.length) {
  24165. this.words[this.length++] = 0;
  24166. }
  24167. for (var i = 0; i < num.length; i++) {
  24168. this.words[i] = this.words[i] | num.words[i];
  24169. }
  24170. return this.strip();
  24171. };
  24172. BN.prototype.ior = function ior(num) {
  24173. assert((this.negative | num.negative) === 0);
  24174. return this.iuor(num);
  24175. }; // Or `num` with `this`
  24176. BN.prototype.or = function or(num) {
  24177. if (this.length > num.length) return this.clone().ior(num);
  24178. return num.clone().ior(this);
  24179. };
  24180. BN.prototype.uor = function uor(num) {
  24181. if (this.length > num.length) return this.clone().iuor(num);
  24182. return num.clone().iuor(this);
  24183. }; // And `num` with `this` in-place
  24184. BN.prototype.iuand = function iuand(num) {
  24185. // b = min-length(num, this)
  24186. var b;
  24187. if (this.length > num.length) {
  24188. b = num;
  24189. } else {
  24190. b = this;
  24191. }
  24192. for (var i = 0; i < b.length; i++) {
  24193. this.words[i] = this.words[i] & num.words[i];
  24194. }
  24195. this.length = b.length;
  24196. return this.strip();
  24197. };
  24198. BN.prototype.iand = function iand(num) {
  24199. assert((this.negative | num.negative) === 0);
  24200. return this.iuand(num);
  24201. }; // And `num` with `this`
  24202. BN.prototype.and = function and(num) {
  24203. if (this.length > num.length) return this.clone().iand(num);
  24204. return num.clone().iand(this);
  24205. };
  24206. BN.prototype.uand = function uand(num) {
  24207. if (this.length > num.length) return this.clone().iuand(num);
  24208. return num.clone().iuand(this);
  24209. }; // Xor `num` with `this` in-place
  24210. BN.prototype.iuxor = function iuxor(num) {
  24211. // a.length > b.length
  24212. var a;
  24213. var b;
  24214. if (this.length > num.length) {
  24215. a = this;
  24216. b = num;
  24217. } else {
  24218. a = num;
  24219. b = this;
  24220. }
  24221. for (var i = 0; i < b.length; i++) {
  24222. this.words[i] = a.words[i] ^ b.words[i];
  24223. }
  24224. if (this !== a) {
  24225. for (; i < a.length; i++) {
  24226. this.words[i] = a.words[i];
  24227. }
  24228. }
  24229. this.length = a.length;
  24230. return this.strip();
  24231. };
  24232. BN.prototype.ixor = function ixor(num) {
  24233. assert((this.negative | num.negative) === 0);
  24234. return this.iuxor(num);
  24235. }; // Xor `num` with `this`
  24236. BN.prototype.xor = function xor(num) {
  24237. if (this.length > num.length) return this.clone().ixor(num);
  24238. return num.clone().ixor(this);
  24239. };
  24240. BN.prototype.uxor = function uxor(num) {
  24241. if (this.length > num.length) return this.clone().iuxor(num);
  24242. return num.clone().iuxor(this);
  24243. }; // Not ``this`` with ``width`` bitwidth
  24244. BN.prototype.inotn = function inotn(width) {
  24245. assert(typeof width === 'number' && width >= 0);
  24246. var bytesNeeded = Math.ceil(width / 26) | 0;
  24247. var bitsLeft = width % 26; // Extend the buffer with leading zeroes
  24248. this._expand(bytesNeeded);
  24249. if (bitsLeft > 0) {
  24250. bytesNeeded--;
  24251. } // Handle complete words
  24252. for (var i = 0; i < bytesNeeded; i++) {
  24253. this.words[i] = ~this.words[i] & 0x3ffffff;
  24254. } // Handle the residue
  24255. if (bitsLeft > 0) {
  24256. this.words[i] = ~this.words[i] & 0x3ffffff >> 26 - bitsLeft;
  24257. } // And remove leading zeroes
  24258. return this.strip();
  24259. };
  24260. BN.prototype.notn = function notn(width) {
  24261. return this.clone().inotn(width);
  24262. }; // Set `bit` of `this`
  24263. BN.prototype.setn = function setn(bit, val) {
  24264. assert(typeof bit === 'number' && bit >= 0);
  24265. var off = bit / 26 | 0;
  24266. var wbit = bit % 26;
  24267. this._expand(off + 1);
  24268. if (val) {
  24269. this.words[off] = this.words[off] | 1 << wbit;
  24270. } else {
  24271. this.words[off] = this.words[off] & ~(1 << wbit);
  24272. }
  24273. return this.strip();
  24274. }; // Add `num` to `this` in-place
  24275. BN.prototype.iadd = function iadd(num) {
  24276. var r; // negative + positive
  24277. if (this.negative !== 0 && num.negative === 0) {
  24278. this.negative = 0;
  24279. r = this.isub(num);
  24280. this.negative ^= 1;
  24281. return this._normSign(); // positive + negative
  24282. } else if (this.negative === 0 && num.negative !== 0) {
  24283. num.negative = 0;
  24284. r = this.isub(num);
  24285. num.negative = 1;
  24286. return r._normSign();
  24287. } // a.length > b.length
  24288. var a, b;
  24289. if (this.length > num.length) {
  24290. a = this;
  24291. b = num;
  24292. } else {
  24293. a = num;
  24294. b = this;
  24295. }
  24296. var carry = 0;
  24297. for (var i = 0; i < b.length; i++) {
  24298. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  24299. this.words[i] = r & 0x3ffffff;
  24300. carry = r >>> 26;
  24301. }
  24302. for (; carry !== 0 && i < a.length; i++) {
  24303. r = (a.words[i] | 0) + carry;
  24304. this.words[i] = r & 0x3ffffff;
  24305. carry = r >>> 26;
  24306. }
  24307. this.length = a.length;
  24308. if (carry !== 0) {
  24309. this.words[this.length] = carry;
  24310. this.length++; // Copy the rest of the words
  24311. } else if (a !== this) {
  24312. for (; i < a.length; i++) {
  24313. this.words[i] = a.words[i];
  24314. }
  24315. }
  24316. return this;
  24317. }; // Add `num` to `this`
  24318. BN.prototype.add = function add(num) {
  24319. var res;
  24320. if (num.negative !== 0 && this.negative === 0) {
  24321. num.negative = 0;
  24322. res = this.sub(num);
  24323. num.negative ^= 1;
  24324. return res;
  24325. } else if (num.negative === 0 && this.negative !== 0) {
  24326. this.negative = 0;
  24327. res = num.sub(this);
  24328. this.negative = 1;
  24329. return res;
  24330. }
  24331. if (this.length > num.length) return this.clone().iadd(num);
  24332. return num.clone().iadd(this);
  24333. }; // Subtract `num` from `this` in-place
  24334. BN.prototype.isub = function isub(num) {
  24335. // this - (-num) = this + num
  24336. if (num.negative !== 0) {
  24337. num.negative = 0;
  24338. var r = this.iadd(num);
  24339. num.negative = 1;
  24340. return r._normSign(); // -this - num = -(this + num)
  24341. } else if (this.negative !== 0) {
  24342. this.negative = 0;
  24343. this.iadd(num);
  24344. this.negative = 1;
  24345. return this._normSign();
  24346. } // At this point both numbers are positive
  24347. var cmp = this.cmp(num); // Optimization - zeroify
  24348. if (cmp === 0) {
  24349. this.negative = 0;
  24350. this.length = 1;
  24351. this.words[0] = 0;
  24352. return this;
  24353. } // a > b
  24354. var a, b;
  24355. if (cmp > 0) {
  24356. a = this;
  24357. b = num;
  24358. } else {
  24359. a = num;
  24360. b = this;
  24361. }
  24362. var carry = 0;
  24363. for (var i = 0; i < b.length; i++) {
  24364. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  24365. carry = r >> 26;
  24366. this.words[i] = r & 0x3ffffff;
  24367. }
  24368. for (; carry !== 0 && i < a.length; i++) {
  24369. r = (a.words[i] | 0) + carry;
  24370. carry = r >> 26;
  24371. this.words[i] = r & 0x3ffffff;
  24372. } // Copy rest of the words
  24373. if (carry === 0 && i < a.length && a !== this) {
  24374. for (; i < a.length; i++) {
  24375. this.words[i] = a.words[i];
  24376. }
  24377. }
  24378. this.length = Math.max(this.length, i);
  24379. if (a !== this) {
  24380. this.negative = 1;
  24381. }
  24382. return this.strip();
  24383. }; // Subtract `num` from `this`
  24384. BN.prototype.sub = function sub(num) {
  24385. return this.clone().isub(num);
  24386. };
  24387. function smallMulTo(self, num, out) {
  24388. out.negative = num.negative ^ self.negative;
  24389. var len = self.length + num.length | 0;
  24390. out.length = len;
  24391. len = len - 1 | 0; // Peel one iteration (compiler can't do it, because of code complexity)
  24392. var a = self.words[0] | 0;
  24393. var b = num.words[0] | 0;
  24394. var r = a * b;
  24395. var lo = r & 0x3ffffff;
  24396. var carry = r / 0x4000000 | 0;
  24397. out.words[0] = lo;
  24398. for (var k = 1; k < len; k++) {
  24399. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  24400. // note that ncarry could be >= 0x3ffffff
  24401. var ncarry = carry >>> 26;
  24402. var rword = carry & 0x3ffffff;
  24403. var maxJ = Math.min(k, num.length - 1);
  24404. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  24405. var i = k - j | 0;
  24406. a = self.words[i] | 0;
  24407. b = num.words[j] | 0;
  24408. r = a * b + rword;
  24409. ncarry += r / 0x4000000 | 0;
  24410. rword = r & 0x3ffffff;
  24411. }
  24412. out.words[k] = rword | 0;
  24413. carry = ncarry | 0;
  24414. }
  24415. if (carry !== 0) {
  24416. out.words[k] = carry | 0;
  24417. } else {
  24418. out.length--;
  24419. }
  24420. return out.strip();
  24421. } // TODO(indutny): it may be reasonable to omit it for users who don't need
  24422. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  24423. // multiplication (like elliptic secp256k1).
  24424. var comb10MulTo = function comb10MulTo(self, num, out) {
  24425. var a = self.words;
  24426. var b = num.words;
  24427. var o = out.words;
  24428. var c = 0;
  24429. var lo;
  24430. var mid;
  24431. var hi;
  24432. var a0 = a[0] | 0;
  24433. var al0 = a0 & 0x1fff;
  24434. var ah0 = a0 >>> 13;
  24435. var a1 = a[1] | 0;
  24436. var al1 = a1 & 0x1fff;
  24437. var ah1 = a1 >>> 13;
  24438. var a2 = a[2] | 0;
  24439. var al2 = a2 & 0x1fff;
  24440. var ah2 = a2 >>> 13;
  24441. var a3 = a[3] | 0;
  24442. var al3 = a3 & 0x1fff;
  24443. var ah3 = a3 >>> 13;
  24444. var a4 = a[4] | 0;
  24445. var al4 = a4 & 0x1fff;
  24446. var ah4 = a4 >>> 13;
  24447. var a5 = a[5] | 0;
  24448. var al5 = a5 & 0x1fff;
  24449. var ah5 = a5 >>> 13;
  24450. var a6 = a[6] | 0;
  24451. var al6 = a6 & 0x1fff;
  24452. var ah6 = a6 >>> 13;
  24453. var a7 = a[7] | 0;
  24454. var al7 = a7 & 0x1fff;
  24455. var ah7 = a7 >>> 13;
  24456. var a8 = a[8] | 0;
  24457. var al8 = a8 & 0x1fff;
  24458. var ah8 = a8 >>> 13;
  24459. var a9 = a[9] | 0;
  24460. var al9 = a9 & 0x1fff;
  24461. var ah9 = a9 >>> 13;
  24462. var b0 = b[0] | 0;
  24463. var bl0 = b0 & 0x1fff;
  24464. var bh0 = b0 >>> 13;
  24465. var b1 = b[1] | 0;
  24466. var bl1 = b1 & 0x1fff;
  24467. var bh1 = b1 >>> 13;
  24468. var b2 = b[2] | 0;
  24469. var bl2 = b2 & 0x1fff;
  24470. var bh2 = b2 >>> 13;
  24471. var b3 = b[3] | 0;
  24472. var bl3 = b3 & 0x1fff;
  24473. var bh3 = b3 >>> 13;
  24474. var b4 = b[4] | 0;
  24475. var bl4 = b4 & 0x1fff;
  24476. var bh4 = b4 >>> 13;
  24477. var b5 = b[5] | 0;
  24478. var bl5 = b5 & 0x1fff;
  24479. var bh5 = b5 >>> 13;
  24480. var b6 = b[6] | 0;
  24481. var bl6 = b6 & 0x1fff;
  24482. var bh6 = b6 >>> 13;
  24483. var b7 = b[7] | 0;
  24484. var bl7 = b7 & 0x1fff;
  24485. var bh7 = b7 >>> 13;
  24486. var b8 = b[8] | 0;
  24487. var bl8 = b8 & 0x1fff;
  24488. var bh8 = b8 >>> 13;
  24489. var b9 = b[9] | 0;
  24490. var bl9 = b9 & 0x1fff;
  24491. var bh9 = b9 >>> 13;
  24492. out.negative = self.negative ^ num.negative;
  24493. out.length = 19;
  24494. /* k = 0 */
  24495. lo = Math.imul(al0, bl0);
  24496. mid = Math.imul(al0, bh0);
  24497. mid = mid + Math.imul(ah0, bl0) | 0;
  24498. hi = Math.imul(ah0, bh0);
  24499. var w0 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24500. c = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0;
  24501. w0 &= 0x3ffffff;
  24502. /* k = 1 */
  24503. lo = Math.imul(al1, bl0);
  24504. mid = Math.imul(al1, bh0);
  24505. mid = mid + Math.imul(ah1, bl0) | 0;
  24506. hi = Math.imul(ah1, bh0);
  24507. lo = lo + Math.imul(al0, bl1) | 0;
  24508. mid = mid + Math.imul(al0, bh1) | 0;
  24509. mid = mid + Math.imul(ah0, bl1) | 0;
  24510. hi = hi + Math.imul(ah0, bh1) | 0;
  24511. var w1 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24512. c = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0;
  24513. w1 &= 0x3ffffff;
  24514. /* k = 2 */
  24515. lo = Math.imul(al2, bl0);
  24516. mid = Math.imul(al2, bh0);
  24517. mid = mid + Math.imul(ah2, bl0) | 0;
  24518. hi = Math.imul(ah2, bh0);
  24519. lo = lo + Math.imul(al1, bl1) | 0;
  24520. mid = mid + Math.imul(al1, bh1) | 0;
  24521. mid = mid + Math.imul(ah1, bl1) | 0;
  24522. hi = hi + Math.imul(ah1, bh1) | 0;
  24523. lo = lo + Math.imul(al0, bl2) | 0;
  24524. mid = mid + Math.imul(al0, bh2) | 0;
  24525. mid = mid + Math.imul(ah0, bl2) | 0;
  24526. hi = hi + Math.imul(ah0, bh2) | 0;
  24527. var w2 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24528. c = (hi + (mid >>> 13) | 0) + (w2 >>> 26) | 0;
  24529. w2 &= 0x3ffffff;
  24530. /* k = 3 */
  24531. lo = Math.imul(al3, bl0);
  24532. mid = Math.imul(al3, bh0);
  24533. mid = mid + Math.imul(ah3, bl0) | 0;
  24534. hi = Math.imul(ah3, bh0);
  24535. lo = lo + Math.imul(al2, bl1) | 0;
  24536. mid = mid + Math.imul(al2, bh1) | 0;
  24537. mid = mid + Math.imul(ah2, bl1) | 0;
  24538. hi = hi + Math.imul(ah2, bh1) | 0;
  24539. lo = lo + Math.imul(al1, bl2) | 0;
  24540. mid = mid + Math.imul(al1, bh2) | 0;
  24541. mid = mid + Math.imul(ah1, bl2) | 0;
  24542. hi = hi + Math.imul(ah1, bh2) | 0;
  24543. lo = lo + Math.imul(al0, bl3) | 0;
  24544. mid = mid + Math.imul(al0, bh3) | 0;
  24545. mid = mid + Math.imul(ah0, bl3) | 0;
  24546. hi = hi + Math.imul(ah0, bh3) | 0;
  24547. var w3 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24548. c = (hi + (mid >>> 13) | 0) + (w3 >>> 26) | 0;
  24549. w3 &= 0x3ffffff;
  24550. /* k = 4 */
  24551. lo = Math.imul(al4, bl0);
  24552. mid = Math.imul(al4, bh0);
  24553. mid = mid + Math.imul(ah4, bl0) | 0;
  24554. hi = Math.imul(ah4, bh0);
  24555. lo = lo + Math.imul(al3, bl1) | 0;
  24556. mid = mid + Math.imul(al3, bh1) | 0;
  24557. mid = mid + Math.imul(ah3, bl1) | 0;
  24558. hi = hi + Math.imul(ah3, bh1) | 0;
  24559. lo = lo + Math.imul(al2, bl2) | 0;
  24560. mid = mid + Math.imul(al2, bh2) | 0;
  24561. mid = mid + Math.imul(ah2, bl2) | 0;
  24562. hi = hi + Math.imul(ah2, bh2) | 0;
  24563. lo = lo + Math.imul(al1, bl3) | 0;
  24564. mid = mid + Math.imul(al1, bh3) | 0;
  24565. mid = mid + Math.imul(ah1, bl3) | 0;
  24566. hi = hi + Math.imul(ah1, bh3) | 0;
  24567. lo = lo + Math.imul(al0, bl4) | 0;
  24568. mid = mid + Math.imul(al0, bh4) | 0;
  24569. mid = mid + Math.imul(ah0, bl4) | 0;
  24570. hi = hi + Math.imul(ah0, bh4) | 0;
  24571. var w4 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24572. c = (hi + (mid >>> 13) | 0) + (w4 >>> 26) | 0;
  24573. w4 &= 0x3ffffff;
  24574. /* k = 5 */
  24575. lo = Math.imul(al5, bl0);
  24576. mid = Math.imul(al5, bh0);
  24577. mid = mid + Math.imul(ah5, bl0) | 0;
  24578. hi = Math.imul(ah5, bh0);
  24579. lo = lo + Math.imul(al4, bl1) | 0;
  24580. mid = mid + Math.imul(al4, bh1) | 0;
  24581. mid = mid + Math.imul(ah4, bl1) | 0;
  24582. hi = hi + Math.imul(ah4, bh1) | 0;
  24583. lo = lo + Math.imul(al3, bl2) | 0;
  24584. mid = mid + Math.imul(al3, bh2) | 0;
  24585. mid = mid + Math.imul(ah3, bl2) | 0;
  24586. hi = hi + Math.imul(ah3, bh2) | 0;
  24587. lo = lo + Math.imul(al2, bl3) | 0;
  24588. mid = mid + Math.imul(al2, bh3) | 0;
  24589. mid = mid + Math.imul(ah2, bl3) | 0;
  24590. hi = hi + Math.imul(ah2, bh3) | 0;
  24591. lo = lo + Math.imul(al1, bl4) | 0;
  24592. mid = mid + Math.imul(al1, bh4) | 0;
  24593. mid = mid + Math.imul(ah1, bl4) | 0;
  24594. hi = hi + Math.imul(ah1, bh4) | 0;
  24595. lo = lo + Math.imul(al0, bl5) | 0;
  24596. mid = mid + Math.imul(al0, bh5) | 0;
  24597. mid = mid + Math.imul(ah0, bl5) | 0;
  24598. hi = hi + Math.imul(ah0, bh5) | 0;
  24599. var w5 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24600. c = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0;
  24601. w5 &= 0x3ffffff;
  24602. /* k = 6 */
  24603. lo = Math.imul(al6, bl0);
  24604. mid = Math.imul(al6, bh0);
  24605. mid = mid + Math.imul(ah6, bl0) | 0;
  24606. hi = Math.imul(ah6, bh0);
  24607. lo = lo + Math.imul(al5, bl1) | 0;
  24608. mid = mid + Math.imul(al5, bh1) | 0;
  24609. mid = mid + Math.imul(ah5, bl1) | 0;
  24610. hi = hi + Math.imul(ah5, bh1) | 0;
  24611. lo = lo + Math.imul(al4, bl2) | 0;
  24612. mid = mid + Math.imul(al4, bh2) | 0;
  24613. mid = mid + Math.imul(ah4, bl2) | 0;
  24614. hi = hi + Math.imul(ah4, bh2) | 0;
  24615. lo = lo + Math.imul(al3, bl3) | 0;
  24616. mid = mid + Math.imul(al3, bh3) | 0;
  24617. mid = mid + Math.imul(ah3, bl3) | 0;
  24618. hi = hi + Math.imul(ah3, bh3) | 0;
  24619. lo = lo + Math.imul(al2, bl4) | 0;
  24620. mid = mid + Math.imul(al2, bh4) | 0;
  24621. mid = mid + Math.imul(ah2, bl4) | 0;
  24622. hi = hi + Math.imul(ah2, bh4) | 0;
  24623. lo = lo + Math.imul(al1, bl5) | 0;
  24624. mid = mid + Math.imul(al1, bh5) | 0;
  24625. mid = mid + Math.imul(ah1, bl5) | 0;
  24626. hi = hi + Math.imul(ah1, bh5) | 0;
  24627. lo = lo + Math.imul(al0, bl6) | 0;
  24628. mid = mid + Math.imul(al0, bh6) | 0;
  24629. mid = mid + Math.imul(ah0, bl6) | 0;
  24630. hi = hi + Math.imul(ah0, bh6) | 0;
  24631. var w6 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24632. c = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0;
  24633. w6 &= 0x3ffffff;
  24634. /* k = 7 */
  24635. lo = Math.imul(al7, bl0);
  24636. mid = Math.imul(al7, bh0);
  24637. mid = mid + Math.imul(ah7, bl0) | 0;
  24638. hi = Math.imul(ah7, bh0);
  24639. lo = lo + Math.imul(al6, bl1) | 0;
  24640. mid = mid + Math.imul(al6, bh1) | 0;
  24641. mid = mid + Math.imul(ah6, bl1) | 0;
  24642. hi = hi + Math.imul(ah6, bh1) | 0;
  24643. lo = lo + Math.imul(al5, bl2) | 0;
  24644. mid = mid + Math.imul(al5, bh2) | 0;
  24645. mid = mid + Math.imul(ah5, bl2) | 0;
  24646. hi = hi + Math.imul(ah5, bh2) | 0;
  24647. lo = lo + Math.imul(al4, bl3) | 0;
  24648. mid = mid + Math.imul(al4, bh3) | 0;
  24649. mid = mid + Math.imul(ah4, bl3) | 0;
  24650. hi = hi + Math.imul(ah4, bh3) | 0;
  24651. lo = lo + Math.imul(al3, bl4) | 0;
  24652. mid = mid + Math.imul(al3, bh4) | 0;
  24653. mid = mid + Math.imul(ah3, bl4) | 0;
  24654. hi = hi + Math.imul(ah3, bh4) | 0;
  24655. lo = lo + Math.imul(al2, bl5) | 0;
  24656. mid = mid + Math.imul(al2, bh5) | 0;
  24657. mid = mid + Math.imul(ah2, bl5) | 0;
  24658. hi = hi + Math.imul(ah2, bh5) | 0;
  24659. lo = lo + Math.imul(al1, bl6) | 0;
  24660. mid = mid + Math.imul(al1, bh6) | 0;
  24661. mid = mid + Math.imul(ah1, bl6) | 0;
  24662. hi = hi + Math.imul(ah1, bh6) | 0;
  24663. lo = lo + Math.imul(al0, bl7) | 0;
  24664. mid = mid + Math.imul(al0, bh7) | 0;
  24665. mid = mid + Math.imul(ah0, bl7) | 0;
  24666. hi = hi + Math.imul(ah0, bh7) | 0;
  24667. var w7 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24668. c = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0;
  24669. w7 &= 0x3ffffff;
  24670. /* k = 8 */
  24671. lo = Math.imul(al8, bl0);
  24672. mid = Math.imul(al8, bh0);
  24673. mid = mid + Math.imul(ah8, bl0) | 0;
  24674. hi = Math.imul(ah8, bh0);
  24675. lo = lo + Math.imul(al7, bl1) | 0;
  24676. mid = mid + Math.imul(al7, bh1) | 0;
  24677. mid = mid + Math.imul(ah7, bl1) | 0;
  24678. hi = hi + Math.imul(ah7, bh1) | 0;
  24679. lo = lo + Math.imul(al6, bl2) | 0;
  24680. mid = mid + Math.imul(al6, bh2) | 0;
  24681. mid = mid + Math.imul(ah6, bl2) | 0;
  24682. hi = hi + Math.imul(ah6, bh2) | 0;
  24683. lo = lo + Math.imul(al5, bl3) | 0;
  24684. mid = mid + Math.imul(al5, bh3) | 0;
  24685. mid = mid + Math.imul(ah5, bl3) | 0;
  24686. hi = hi + Math.imul(ah5, bh3) | 0;
  24687. lo = lo + Math.imul(al4, bl4) | 0;
  24688. mid = mid + Math.imul(al4, bh4) | 0;
  24689. mid = mid + Math.imul(ah4, bl4) | 0;
  24690. hi = hi + Math.imul(ah4, bh4) | 0;
  24691. lo = lo + Math.imul(al3, bl5) | 0;
  24692. mid = mid + Math.imul(al3, bh5) | 0;
  24693. mid = mid + Math.imul(ah3, bl5) | 0;
  24694. hi = hi + Math.imul(ah3, bh5) | 0;
  24695. lo = lo + Math.imul(al2, bl6) | 0;
  24696. mid = mid + Math.imul(al2, bh6) | 0;
  24697. mid = mid + Math.imul(ah2, bl6) | 0;
  24698. hi = hi + Math.imul(ah2, bh6) | 0;
  24699. lo = lo + Math.imul(al1, bl7) | 0;
  24700. mid = mid + Math.imul(al1, bh7) | 0;
  24701. mid = mid + Math.imul(ah1, bl7) | 0;
  24702. hi = hi + Math.imul(ah1, bh7) | 0;
  24703. lo = lo + Math.imul(al0, bl8) | 0;
  24704. mid = mid + Math.imul(al0, bh8) | 0;
  24705. mid = mid + Math.imul(ah0, bl8) | 0;
  24706. hi = hi + Math.imul(ah0, bh8) | 0;
  24707. var w8 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24708. c = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0;
  24709. w8 &= 0x3ffffff;
  24710. /* k = 9 */
  24711. lo = Math.imul(al9, bl0);
  24712. mid = Math.imul(al9, bh0);
  24713. mid = mid + Math.imul(ah9, bl0) | 0;
  24714. hi = Math.imul(ah9, bh0);
  24715. lo = lo + Math.imul(al8, bl1) | 0;
  24716. mid = mid + Math.imul(al8, bh1) | 0;
  24717. mid = mid + Math.imul(ah8, bl1) | 0;
  24718. hi = hi + Math.imul(ah8, bh1) | 0;
  24719. lo = lo + Math.imul(al7, bl2) | 0;
  24720. mid = mid + Math.imul(al7, bh2) | 0;
  24721. mid = mid + Math.imul(ah7, bl2) | 0;
  24722. hi = hi + Math.imul(ah7, bh2) | 0;
  24723. lo = lo + Math.imul(al6, bl3) | 0;
  24724. mid = mid + Math.imul(al6, bh3) | 0;
  24725. mid = mid + Math.imul(ah6, bl3) | 0;
  24726. hi = hi + Math.imul(ah6, bh3) | 0;
  24727. lo = lo + Math.imul(al5, bl4) | 0;
  24728. mid = mid + Math.imul(al5, bh4) | 0;
  24729. mid = mid + Math.imul(ah5, bl4) | 0;
  24730. hi = hi + Math.imul(ah5, bh4) | 0;
  24731. lo = lo + Math.imul(al4, bl5) | 0;
  24732. mid = mid + Math.imul(al4, bh5) | 0;
  24733. mid = mid + Math.imul(ah4, bl5) | 0;
  24734. hi = hi + Math.imul(ah4, bh5) | 0;
  24735. lo = lo + Math.imul(al3, bl6) | 0;
  24736. mid = mid + Math.imul(al3, bh6) | 0;
  24737. mid = mid + Math.imul(ah3, bl6) | 0;
  24738. hi = hi + Math.imul(ah3, bh6) | 0;
  24739. lo = lo + Math.imul(al2, bl7) | 0;
  24740. mid = mid + Math.imul(al2, bh7) | 0;
  24741. mid = mid + Math.imul(ah2, bl7) | 0;
  24742. hi = hi + Math.imul(ah2, bh7) | 0;
  24743. lo = lo + Math.imul(al1, bl8) | 0;
  24744. mid = mid + Math.imul(al1, bh8) | 0;
  24745. mid = mid + Math.imul(ah1, bl8) | 0;
  24746. hi = hi + Math.imul(ah1, bh8) | 0;
  24747. lo = lo + Math.imul(al0, bl9) | 0;
  24748. mid = mid + Math.imul(al0, bh9) | 0;
  24749. mid = mid + Math.imul(ah0, bl9) | 0;
  24750. hi = hi + Math.imul(ah0, bh9) | 0;
  24751. var w9 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24752. c = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0;
  24753. w9 &= 0x3ffffff;
  24754. /* k = 10 */
  24755. lo = Math.imul(al9, bl1);
  24756. mid = Math.imul(al9, bh1);
  24757. mid = mid + Math.imul(ah9, bl1) | 0;
  24758. hi = Math.imul(ah9, bh1);
  24759. lo = lo + Math.imul(al8, bl2) | 0;
  24760. mid = mid + Math.imul(al8, bh2) | 0;
  24761. mid = mid + Math.imul(ah8, bl2) | 0;
  24762. hi = hi + Math.imul(ah8, bh2) | 0;
  24763. lo = lo + Math.imul(al7, bl3) | 0;
  24764. mid = mid + Math.imul(al7, bh3) | 0;
  24765. mid = mid + Math.imul(ah7, bl3) | 0;
  24766. hi = hi + Math.imul(ah7, bh3) | 0;
  24767. lo = lo + Math.imul(al6, bl4) | 0;
  24768. mid = mid + Math.imul(al6, bh4) | 0;
  24769. mid = mid + Math.imul(ah6, bl4) | 0;
  24770. hi = hi + Math.imul(ah6, bh4) | 0;
  24771. lo = lo + Math.imul(al5, bl5) | 0;
  24772. mid = mid + Math.imul(al5, bh5) | 0;
  24773. mid = mid + Math.imul(ah5, bl5) | 0;
  24774. hi = hi + Math.imul(ah5, bh5) | 0;
  24775. lo = lo + Math.imul(al4, bl6) | 0;
  24776. mid = mid + Math.imul(al4, bh6) | 0;
  24777. mid = mid + Math.imul(ah4, bl6) | 0;
  24778. hi = hi + Math.imul(ah4, bh6) | 0;
  24779. lo = lo + Math.imul(al3, bl7) | 0;
  24780. mid = mid + Math.imul(al3, bh7) | 0;
  24781. mid = mid + Math.imul(ah3, bl7) | 0;
  24782. hi = hi + Math.imul(ah3, bh7) | 0;
  24783. lo = lo + Math.imul(al2, bl8) | 0;
  24784. mid = mid + Math.imul(al2, bh8) | 0;
  24785. mid = mid + Math.imul(ah2, bl8) | 0;
  24786. hi = hi + Math.imul(ah2, bh8) | 0;
  24787. lo = lo + Math.imul(al1, bl9) | 0;
  24788. mid = mid + Math.imul(al1, bh9) | 0;
  24789. mid = mid + Math.imul(ah1, bl9) | 0;
  24790. hi = hi + Math.imul(ah1, bh9) | 0;
  24791. var w10 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24792. c = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0;
  24793. w10 &= 0x3ffffff;
  24794. /* k = 11 */
  24795. lo = Math.imul(al9, bl2);
  24796. mid = Math.imul(al9, bh2);
  24797. mid = mid + Math.imul(ah9, bl2) | 0;
  24798. hi = Math.imul(ah9, bh2);
  24799. lo = lo + Math.imul(al8, bl3) | 0;
  24800. mid = mid + Math.imul(al8, bh3) | 0;
  24801. mid = mid + Math.imul(ah8, bl3) | 0;
  24802. hi = hi + Math.imul(ah8, bh3) | 0;
  24803. lo = lo + Math.imul(al7, bl4) | 0;
  24804. mid = mid + Math.imul(al7, bh4) | 0;
  24805. mid = mid + Math.imul(ah7, bl4) | 0;
  24806. hi = hi + Math.imul(ah7, bh4) | 0;
  24807. lo = lo + Math.imul(al6, bl5) | 0;
  24808. mid = mid + Math.imul(al6, bh5) | 0;
  24809. mid = mid + Math.imul(ah6, bl5) | 0;
  24810. hi = hi + Math.imul(ah6, bh5) | 0;
  24811. lo = lo + Math.imul(al5, bl6) | 0;
  24812. mid = mid + Math.imul(al5, bh6) | 0;
  24813. mid = mid + Math.imul(ah5, bl6) | 0;
  24814. hi = hi + Math.imul(ah5, bh6) | 0;
  24815. lo = lo + Math.imul(al4, bl7) | 0;
  24816. mid = mid + Math.imul(al4, bh7) | 0;
  24817. mid = mid + Math.imul(ah4, bl7) | 0;
  24818. hi = hi + Math.imul(ah4, bh7) | 0;
  24819. lo = lo + Math.imul(al3, bl8) | 0;
  24820. mid = mid + Math.imul(al3, bh8) | 0;
  24821. mid = mid + Math.imul(ah3, bl8) | 0;
  24822. hi = hi + Math.imul(ah3, bh8) | 0;
  24823. lo = lo + Math.imul(al2, bl9) | 0;
  24824. mid = mid + Math.imul(al2, bh9) | 0;
  24825. mid = mid + Math.imul(ah2, bl9) | 0;
  24826. hi = hi + Math.imul(ah2, bh9) | 0;
  24827. var w11 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24828. c = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0;
  24829. w11 &= 0x3ffffff;
  24830. /* k = 12 */
  24831. lo = Math.imul(al9, bl3);
  24832. mid = Math.imul(al9, bh3);
  24833. mid = mid + Math.imul(ah9, bl3) | 0;
  24834. hi = Math.imul(ah9, bh3);
  24835. lo = lo + Math.imul(al8, bl4) | 0;
  24836. mid = mid + Math.imul(al8, bh4) | 0;
  24837. mid = mid + Math.imul(ah8, bl4) | 0;
  24838. hi = hi + Math.imul(ah8, bh4) | 0;
  24839. lo = lo + Math.imul(al7, bl5) | 0;
  24840. mid = mid + Math.imul(al7, bh5) | 0;
  24841. mid = mid + Math.imul(ah7, bl5) | 0;
  24842. hi = hi + Math.imul(ah7, bh5) | 0;
  24843. lo = lo + Math.imul(al6, bl6) | 0;
  24844. mid = mid + Math.imul(al6, bh6) | 0;
  24845. mid = mid + Math.imul(ah6, bl6) | 0;
  24846. hi = hi + Math.imul(ah6, bh6) | 0;
  24847. lo = lo + Math.imul(al5, bl7) | 0;
  24848. mid = mid + Math.imul(al5, bh7) | 0;
  24849. mid = mid + Math.imul(ah5, bl7) | 0;
  24850. hi = hi + Math.imul(ah5, bh7) | 0;
  24851. lo = lo + Math.imul(al4, bl8) | 0;
  24852. mid = mid + Math.imul(al4, bh8) | 0;
  24853. mid = mid + Math.imul(ah4, bl8) | 0;
  24854. hi = hi + Math.imul(ah4, bh8) | 0;
  24855. lo = lo + Math.imul(al3, bl9) | 0;
  24856. mid = mid + Math.imul(al3, bh9) | 0;
  24857. mid = mid + Math.imul(ah3, bl9) | 0;
  24858. hi = hi + Math.imul(ah3, bh9) | 0;
  24859. var w12 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24860. c = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0;
  24861. w12 &= 0x3ffffff;
  24862. /* k = 13 */
  24863. lo = Math.imul(al9, bl4);
  24864. mid = Math.imul(al9, bh4);
  24865. mid = mid + Math.imul(ah9, bl4) | 0;
  24866. hi = Math.imul(ah9, bh4);
  24867. lo = lo + Math.imul(al8, bl5) | 0;
  24868. mid = mid + Math.imul(al8, bh5) | 0;
  24869. mid = mid + Math.imul(ah8, bl5) | 0;
  24870. hi = hi + Math.imul(ah8, bh5) | 0;
  24871. lo = lo + Math.imul(al7, bl6) | 0;
  24872. mid = mid + Math.imul(al7, bh6) | 0;
  24873. mid = mid + Math.imul(ah7, bl6) | 0;
  24874. hi = hi + Math.imul(ah7, bh6) | 0;
  24875. lo = lo + Math.imul(al6, bl7) | 0;
  24876. mid = mid + Math.imul(al6, bh7) | 0;
  24877. mid = mid + Math.imul(ah6, bl7) | 0;
  24878. hi = hi + Math.imul(ah6, bh7) | 0;
  24879. lo = lo + Math.imul(al5, bl8) | 0;
  24880. mid = mid + Math.imul(al5, bh8) | 0;
  24881. mid = mid + Math.imul(ah5, bl8) | 0;
  24882. hi = hi + Math.imul(ah5, bh8) | 0;
  24883. lo = lo + Math.imul(al4, bl9) | 0;
  24884. mid = mid + Math.imul(al4, bh9) | 0;
  24885. mid = mid + Math.imul(ah4, bl9) | 0;
  24886. hi = hi + Math.imul(ah4, bh9) | 0;
  24887. var w13 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24888. c = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0;
  24889. w13 &= 0x3ffffff;
  24890. /* k = 14 */
  24891. lo = Math.imul(al9, bl5);
  24892. mid = Math.imul(al9, bh5);
  24893. mid = mid + Math.imul(ah9, bl5) | 0;
  24894. hi = Math.imul(ah9, bh5);
  24895. lo = lo + Math.imul(al8, bl6) | 0;
  24896. mid = mid + Math.imul(al8, bh6) | 0;
  24897. mid = mid + Math.imul(ah8, bl6) | 0;
  24898. hi = hi + Math.imul(ah8, bh6) | 0;
  24899. lo = lo + Math.imul(al7, bl7) | 0;
  24900. mid = mid + Math.imul(al7, bh7) | 0;
  24901. mid = mid + Math.imul(ah7, bl7) | 0;
  24902. hi = hi + Math.imul(ah7, bh7) | 0;
  24903. lo = lo + Math.imul(al6, bl8) | 0;
  24904. mid = mid + Math.imul(al6, bh8) | 0;
  24905. mid = mid + Math.imul(ah6, bl8) | 0;
  24906. hi = hi + Math.imul(ah6, bh8) | 0;
  24907. lo = lo + Math.imul(al5, bl9) | 0;
  24908. mid = mid + Math.imul(al5, bh9) | 0;
  24909. mid = mid + Math.imul(ah5, bl9) | 0;
  24910. hi = hi + Math.imul(ah5, bh9) | 0;
  24911. var w14 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24912. c = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0;
  24913. w14 &= 0x3ffffff;
  24914. /* k = 15 */
  24915. lo = Math.imul(al9, bl6);
  24916. mid = Math.imul(al9, bh6);
  24917. mid = mid + Math.imul(ah9, bl6) | 0;
  24918. hi = Math.imul(ah9, bh6);
  24919. lo = lo + Math.imul(al8, bl7) | 0;
  24920. mid = mid + Math.imul(al8, bh7) | 0;
  24921. mid = mid + Math.imul(ah8, bl7) | 0;
  24922. hi = hi + Math.imul(ah8, bh7) | 0;
  24923. lo = lo + Math.imul(al7, bl8) | 0;
  24924. mid = mid + Math.imul(al7, bh8) | 0;
  24925. mid = mid + Math.imul(ah7, bl8) | 0;
  24926. hi = hi + Math.imul(ah7, bh8) | 0;
  24927. lo = lo + Math.imul(al6, bl9) | 0;
  24928. mid = mid + Math.imul(al6, bh9) | 0;
  24929. mid = mid + Math.imul(ah6, bl9) | 0;
  24930. hi = hi + Math.imul(ah6, bh9) | 0;
  24931. var w15 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24932. c = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0;
  24933. w15 &= 0x3ffffff;
  24934. /* k = 16 */
  24935. lo = Math.imul(al9, bl7);
  24936. mid = Math.imul(al9, bh7);
  24937. mid = mid + Math.imul(ah9, bl7) | 0;
  24938. hi = Math.imul(ah9, bh7);
  24939. lo = lo + Math.imul(al8, bl8) | 0;
  24940. mid = mid + Math.imul(al8, bh8) | 0;
  24941. mid = mid + Math.imul(ah8, bl8) | 0;
  24942. hi = hi + Math.imul(ah8, bh8) | 0;
  24943. lo = lo + Math.imul(al7, bl9) | 0;
  24944. mid = mid + Math.imul(al7, bh9) | 0;
  24945. mid = mid + Math.imul(ah7, bl9) | 0;
  24946. hi = hi + Math.imul(ah7, bh9) | 0;
  24947. var w16 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24948. c = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0;
  24949. w16 &= 0x3ffffff;
  24950. /* k = 17 */
  24951. lo = Math.imul(al9, bl8);
  24952. mid = Math.imul(al9, bh8);
  24953. mid = mid + Math.imul(ah9, bl8) | 0;
  24954. hi = Math.imul(ah9, bh8);
  24955. lo = lo + Math.imul(al8, bl9) | 0;
  24956. mid = mid + Math.imul(al8, bh9) | 0;
  24957. mid = mid + Math.imul(ah8, bl9) | 0;
  24958. hi = hi + Math.imul(ah8, bh9) | 0;
  24959. var w17 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24960. c = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0;
  24961. w17 &= 0x3ffffff;
  24962. /* k = 18 */
  24963. lo = Math.imul(al9, bl9);
  24964. mid = Math.imul(al9, bh9);
  24965. mid = mid + Math.imul(ah9, bl9) | 0;
  24966. hi = Math.imul(ah9, bh9);
  24967. var w18 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  24968. c = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0;
  24969. w18 &= 0x3ffffff;
  24970. o[0] = w0;
  24971. o[1] = w1;
  24972. o[2] = w2;
  24973. o[3] = w3;
  24974. o[4] = w4;
  24975. o[5] = w5;
  24976. o[6] = w6;
  24977. o[7] = w7;
  24978. o[8] = w8;
  24979. o[9] = w9;
  24980. o[10] = w10;
  24981. o[11] = w11;
  24982. o[12] = w12;
  24983. o[13] = w13;
  24984. o[14] = w14;
  24985. o[15] = w15;
  24986. o[16] = w16;
  24987. o[17] = w17;
  24988. o[18] = w18;
  24989. if (c !== 0) {
  24990. o[19] = c;
  24991. out.length++;
  24992. }
  24993. return out;
  24994. }; // Polyfill comb
  24995. if (!Math.imul) {
  24996. comb10MulTo = smallMulTo;
  24997. }
  24998. function bigMulTo(self, num, out) {
  24999. out.negative = num.negative ^ self.negative;
  25000. out.length = self.length + num.length;
  25001. var carry = 0;
  25002. var hncarry = 0;
  25003. for (var k = 0; k < out.length - 1; k++) {
  25004. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  25005. // note that ncarry could be >= 0x3ffffff
  25006. var ncarry = hncarry;
  25007. hncarry = 0;
  25008. var rword = carry & 0x3ffffff;
  25009. var maxJ = Math.min(k, num.length - 1);
  25010. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  25011. var i = k - j;
  25012. var a = self.words[i] | 0;
  25013. var b = num.words[j] | 0;
  25014. var r = a * b;
  25015. var lo = r & 0x3ffffff;
  25016. ncarry = ncarry + (r / 0x4000000 | 0) | 0;
  25017. lo = lo + rword | 0;
  25018. rword = lo & 0x3ffffff;
  25019. ncarry = ncarry + (lo >>> 26) | 0;
  25020. hncarry += ncarry >>> 26;
  25021. ncarry &= 0x3ffffff;
  25022. }
  25023. out.words[k] = rword;
  25024. carry = ncarry;
  25025. ncarry = hncarry;
  25026. }
  25027. if (carry !== 0) {
  25028. out.words[k] = carry;
  25029. } else {
  25030. out.length--;
  25031. }
  25032. return out.strip();
  25033. }
  25034. function jumboMulTo(self, num, out) {
  25035. var fftm = new FFTM();
  25036. return fftm.mulp(self, num, out);
  25037. }
  25038. BN.prototype.mulTo = function mulTo(num, out) {
  25039. var res;
  25040. var len = this.length + num.length;
  25041. if (this.length === 10 && num.length === 10) {
  25042. res = comb10MulTo(this, num, out);
  25043. } else if (len < 63) {
  25044. res = smallMulTo(this, num, out);
  25045. } else if (len < 1024) {
  25046. res = bigMulTo(this, num, out);
  25047. } else {
  25048. res = jumboMulTo(this, num, out);
  25049. }
  25050. return res;
  25051. }; // Cooley-Tukey algorithm for FFT
  25052. // slightly revisited to rely on looping instead of recursion
  25053. function FFTM(x, y) {
  25054. this.x = x;
  25055. this.y = y;
  25056. }
  25057. FFTM.prototype.makeRBT = function makeRBT(N) {
  25058. var t = new Array(N);
  25059. var l = BN.prototype._countBits(N) - 1;
  25060. for (var i = 0; i < N; i++) {
  25061. t[i] = this.revBin(i, l, N);
  25062. }
  25063. return t;
  25064. }; // Returns binary-reversed representation of `x`
  25065. FFTM.prototype.revBin = function revBin(x, l, N) {
  25066. if (x === 0 || x === N - 1) return x;
  25067. var rb = 0;
  25068. for (var i = 0; i < l; i++) {
  25069. rb |= (x & 1) << l - i - 1;
  25070. x >>= 1;
  25071. }
  25072. return rb;
  25073. }; // Performs "tweedling" phase, therefore 'emulating'
  25074. // behaviour of the recursive algorithm
  25075. FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N) {
  25076. for (var i = 0; i < N; i++) {
  25077. rtws[i] = rws[rbt[i]];
  25078. itws[i] = iws[rbt[i]];
  25079. }
  25080. };
  25081. FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N, rbt) {
  25082. this.permute(rbt, rws, iws, rtws, itws, N);
  25083. for (var s = 1; s < N; s <<= 1) {
  25084. var l = s << 1;
  25085. var rtwdf = Math.cos(2 * Math.PI / l);
  25086. var itwdf = Math.sin(2 * Math.PI / l);
  25087. for (var p = 0; p < N; p += l) {
  25088. var rtwdf_ = rtwdf;
  25089. var itwdf_ = itwdf;
  25090. for (var j = 0; j < s; j++) {
  25091. var re = rtws[p + j];
  25092. var ie = itws[p + j];
  25093. var ro = rtws[p + j + s];
  25094. var io = itws[p + j + s];
  25095. var rx = rtwdf_ * ro - itwdf_ * io;
  25096. io = rtwdf_ * io + itwdf_ * ro;
  25097. ro = rx;
  25098. rtws[p + j] = re + ro;
  25099. itws[p + j] = ie + io;
  25100. rtws[p + j + s] = re - ro;
  25101. itws[p + j + s] = ie - io;
  25102. /* jshint maxdepth : false */
  25103. if (j !== l) {
  25104. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  25105. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  25106. rtwdf_ = rx;
  25107. }
  25108. }
  25109. }
  25110. }
  25111. };
  25112. FFTM.prototype.guessLen13b = function guessLen13b(n, m) {
  25113. var N = Math.max(m, n) | 1;
  25114. var odd = N & 1;
  25115. var i = 0;
  25116. for (N = N / 2 | 0; N; N = N >>> 1) {
  25117. i++;
  25118. }
  25119. return 1 << i + 1 + odd;
  25120. };
  25121. FFTM.prototype.conjugate = function conjugate(rws, iws, N) {
  25122. if (N <= 1) return;
  25123. for (var i = 0; i < N / 2; i++) {
  25124. var t = rws[i];
  25125. rws[i] = rws[N - i - 1];
  25126. rws[N - i - 1] = t;
  25127. t = iws[i];
  25128. iws[i] = -iws[N - i - 1];
  25129. iws[N - i - 1] = -t;
  25130. }
  25131. };
  25132. FFTM.prototype.normalize13b = function normalize13b(ws, N) {
  25133. var carry = 0;
  25134. for (var i = 0; i < N / 2; i++) {
  25135. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + Math.round(ws[2 * i] / N) + carry;
  25136. ws[i] = w & 0x3ffffff;
  25137. if (w < 0x4000000) {
  25138. carry = 0;
  25139. } else {
  25140. carry = w / 0x4000000 | 0;
  25141. }
  25142. }
  25143. return ws;
  25144. };
  25145. FFTM.prototype.convert13b = function convert13b(ws, len, rws, N) {
  25146. var carry = 0;
  25147. for (var i = 0; i < len; i++) {
  25148. carry = carry + (ws[i] | 0);
  25149. rws[2 * i] = carry & 0x1fff;
  25150. carry = carry >>> 13;
  25151. rws[2 * i + 1] = carry & 0x1fff;
  25152. carry = carry >>> 13;
  25153. } // Pad with zeroes
  25154. for (i = 2 * len; i < N; ++i) {
  25155. rws[i] = 0;
  25156. }
  25157. assert(carry === 0);
  25158. assert((carry & ~0x1fff) === 0);
  25159. };
  25160. FFTM.prototype.stub = function stub(N) {
  25161. var ph = new Array(N);
  25162. for (var i = 0; i < N; i++) {
  25163. ph[i] = 0;
  25164. }
  25165. return ph;
  25166. };
  25167. FFTM.prototype.mulp = function mulp(x, y, out) {
  25168. var N = 2 * this.guessLen13b(x.length, y.length);
  25169. var rbt = this.makeRBT(N);
  25170. var _ = this.stub(N);
  25171. var rws = new Array(N);
  25172. var rwst = new Array(N);
  25173. var iwst = new Array(N);
  25174. var nrws = new Array(N);
  25175. var nrwst = new Array(N);
  25176. var niwst = new Array(N);
  25177. var rmws = out.words;
  25178. rmws.length = N;
  25179. this.convert13b(x.words, x.length, rws, N);
  25180. this.convert13b(y.words, y.length, nrws, N);
  25181. this.transform(rws, _, rwst, iwst, N, rbt);
  25182. this.transform(nrws, _, nrwst, niwst, N, rbt);
  25183. for (var i = 0; i < N; i++) {
  25184. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  25185. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  25186. rwst[i] = rx;
  25187. }
  25188. this.conjugate(rwst, iwst, N);
  25189. this.transform(rwst, iwst, rmws, _, N, rbt);
  25190. this.conjugate(rmws, _, N);
  25191. this.normalize13b(rmws, N);
  25192. out.negative = x.negative ^ y.negative;
  25193. out.length = x.length + y.length;
  25194. return out.strip();
  25195. }; // Multiply `this` by `num`
  25196. BN.prototype.mul = function mul(num) {
  25197. var out = new BN(null);
  25198. out.words = new Array(this.length + num.length);
  25199. return this.mulTo(num, out);
  25200. }; // Multiply employing FFT
  25201. BN.prototype.mulf = function mulf(num) {
  25202. var out = new BN(null);
  25203. out.words = new Array(this.length + num.length);
  25204. return jumboMulTo(this, num, out);
  25205. }; // In-place Multiplication
  25206. BN.prototype.imul = function imul(num) {
  25207. return this.clone().mulTo(num, this);
  25208. };
  25209. BN.prototype.imuln = function imuln(num) {
  25210. assert(typeof num === 'number');
  25211. assert(num < 0x4000000); // Carry
  25212. var carry = 0;
  25213. for (var i = 0; i < this.length; i++) {
  25214. var w = (this.words[i] | 0) * num;
  25215. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  25216. carry >>= 26;
  25217. carry += w / 0x4000000 | 0; // NOTE: lo is 27bit maximum
  25218. carry += lo >>> 26;
  25219. this.words[i] = lo & 0x3ffffff;
  25220. }
  25221. if (carry !== 0) {
  25222. this.words[i] = carry;
  25223. this.length++;
  25224. }
  25225. return this;
  25226. };
  25227. BN.prototype.muln = function muln(num) {
  25228. return this.clone().imuln(num);
  25229. }; // `this` * `this`
  25230. BN.prototype.sqr = function sqr() {
  25231. return this.mul(this);
  25232. }; // `this` * `this` in-place
  25233. BN.prototype.isqr = function isqr() {
  25234. return this.imul(this.clone());
  25235. }; // Math.pow(`this`, `num`)
  25236. BN.prototype.pow = function pow(num) {
  25237. var w = toBitArray(num);
  25238. if (w.length === 0) return new BN(1); // Skip leading zeroes
  25239. var res = this;
  25240. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  25241. if (w[i] !== 0) break;
  25242. }
  25243. if (++i < w.length) {
  25244. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  25245. if (w[i] === 0) continue;
  25246. res = res.mul(q);
  25247. }
  25248. }
  25249. return res;
  25250. }; // Shift-left in-place
  25251. BN.prototype.iushln = function iushln(bits) {
  25252. assert(typeof bits === 'number' && bits >= 0);
  25253. var r = bits % 26;
  25254. var s = (bits - r) / 26;
  25255. var carryMask = 0x3ffffff >>> 26 - r << 26 - r;
  25256. var i;
  25257. if (r !== 0) {
  25258. var carry = 0;
  25259. for (i = 0; i < this.length; i++) {
  25260. var newCarry = this.words[i] & carryMask;
  25261. var c = (this.words[i] | 0) - newCarry << r;
  25262. this.words[i] = c | carry;
  25263. carry = newCarry >>> 26 - r;
  25264. }
  25265. if (carry) {
  25266. this.words[i] = carry;
  25267. this.length++;
  25268. }
  25269. }
  25270. if (s !== 0) {
  25271. for (i = this.length - 1; i >= 0; i--) {
  25272. this.words[i + s] = this.words[i];
  25273. }
  25274. for (i = 0; i < s; i++) {
  25275. this.words[i] = 0;
  25276. }
  25277. this.length += s;
  25278. }
  25279. return this.strip();
  25280. };
  25281. BN.prototype.ishln = function ishln(bits) {
  25282. // TODO(indutny): implement me
  25283. assert(this.negative === 0);
  25284. return this.iushln(bits);
  25285. }; // Shift-right in-place
  25286. // NOTE: `hint` is a lowest bit before trailing zeroes
  25287. // NOTE: if `extended` is present - it will be filled with destroyed bits
  25288. BN.prototype.iushrn = function iushrn(bits, hint, extended) {
  25289. assert(typeof bits === 'number' && bits >= 0);
  25290. var h;
  25291. if (hint) {
  25292. h = (hint - hint % 26) / 26;
  25293. } else {
  25294. h = 0;
  25295. }
  25296. var r = bits % 26;
  25297. var s = Math.min((bits - r) / 26, this.length);
  25298. var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;
  25299. var maskedWords = extended;
  25300. h -= s;
  25301. h = Math.max(0, h); // Extended mode, copy masked part
  25302. if (maskedWords) {
  25303. for (var i = 0; i < s; i++) {
  25304. maskedWords.words[i] = this.words[i];
  25305. }
  25306. maskedWords.length = s;
  25307. }
  25308. if (s === 0) {// No-op, we should not move anything at all
  25309. } else if (this.length > s) {
  25310. this.length -= s;
  25311. for (i = 0; i < this.length; i++) {
  25312. this.words[i] = this.words[i + s];
  25313. }
  25314. } else {
  25315. this.words[0] = 0;
  25316. this.length = 1;
  25317. }
  25318. var carry = 0;
  25319. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  25320. var word = this.words[i] | 0;
  25321. this.words[i] = carry << 26 - r | word >>> r;
  25322. carry = word & mask;
  25323. } // Push carried bits as a mask
  25324. if (maskedWords && carry !== 0) {
  25325. maskedWords.words[maskedWords.length++] = carry;
  25326. }
  25327. if (this.length === 0) {
  25328. this.words[0] = 0;
  25329. this.length = 1;
  25330. }
  25331. return this.strip();
  25332. };
  25333. BN.prototype.ishrn = function ishrn(bits, hint, extended) {
  25334. // TODO(indutny): implement me
  25335. assert(this.negative === 0);
  25336. return this.iushrn(bits, hint, extended);
  25337. }; // Shift-left
  25338. BN.prototype.shln = function shln(bits) {
  25339. return this.clone().ishln(bits);
  25340. };
  25341. BN.prototype.ushln = function ushln(bits) {
  25342. return this.clone().iushln(bits);
  25343. }; // Shift-right
  25344. BN.prototype.shrn = function shrn(bits) {
  25345. return this.clone().ishrn(bits);
  25346. };
  25347. BN.prototype.ushrn = function ushrn(bits) {
  25348. return this.clone().iushrn(bits);
  25349. }; // Test if n bit is set
  25350. BN.prototype.testn = function testn(bit) {
  25351. assert(typeof bit === 'number' && bit >= 0);
  25352. var r = bit % 26;
  25353. var s = (bit - r) / 26;
  25354. var q = 1 << r; // Fast case: bit is much higher than all existing words
  25355. if (this.length <= s) return false; // Check bit and return
  25356. var w = this.words[s];
  25357. return !!(w & q);
  25358. }; // Return only lowers bits of number (in-place)
  25359. BN.prototype.imaskn = function imaskn(bits) {
  25360. assert(typeof bits === 'number' && bits >= 0);
  25361. var r = bits % 26;
  25362. var s = (bits - r) / 26;
  25363. assert(this.negative === 0, 'imaskn works only with positive numbers');
  25364. if (this.length <= s) {
  25365. return this;
  25366. }
  25367. if (r !== 0) {
  25368. s++;
  25369. }
  25370. this.length = Math.min(s, this.length);
  25371. if (r !== 0) {
  25372. var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;
  25373. this.words[this.length - 1] &= mask;
  25374. }
  25375. return this.strip();
  25376. }; // Return only lowers bits of number
  25377. BN.prototype.maskn = function maskn(bits) {
  25378. return this.clone().imaskn(bits);
  25379. }; // Add plain number `num` to `this`
  25380. BN.prototype.iaddn = function iaddn(num) {
  25381. assert(typeof num === 'number');
  25382. assert(num < 0x4000000);
  25383. if (num < 0) return this.isubn(-num); // Possible sign change
  25384. if (this.negative !== 0) {
  25385. if (this.length === 1 && (this.words[0] | 0) < num) {
  25386. this.words[0] = num - (this.words[0] | 0);
  25387. this.negative = 0;
  25388. return this;
  25389. }
  25390. this.negative = 0;
  25391. this.isubn(num);
  25392. this.negative = 1;
  25393. return this;
  25394. } // Add without checks
  25395. return this._iaddn(num);
  25396. };
  25397. BN.prototype._iaddn = function _iaddn(num) {
  25398. this.words[0] += num; // Carry
  25399. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  25400. this.words[i] -= 0x4000000;
  25401. if (i === this.length - 1) {
  25402. this.words[i + 1] = 1;
  25403. } else {
  25404. this.words[i + 1]++;
  25405. }
  25406. }
  25407. this.length = Math.max(this.length, i + 1);
  25408. return this;
  25409. }; // Subtract plain number `num` from `this`
  25410. BN.prototype.isubn = function isubn(num) {
  25411. assert(typeof num === 'number');
  25412. assert(num < 0x4000000);
  25413. if (num < 0) return this.iaddn(-num);
  25414. if (this.negative !== 0) {
  25415. this.negative = 0;
  25416. this.iaddn(num);
  25417. this.negative = 1;
  25418. return this;
  25419. }
  25420. this.words[0] -= num;
  25421. if (this.length === 1 && this.words[0] < 0) {
  25422. this.words[0] = -this.words[0];
  25423. this.negative = 1;
  25424. } else {
  25425. // Carry
  25426. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  25427. this.words[i] += 0x4000000;
  25428. this.words[i + 1] -= 1;
  25429. }
  25430. }
  25431. return this.strip();
  25432. };
  25433. BN.prototype.addn = function addn(num) {
  25434. return this.clone().iaddn(num);
  25435. };
  25436. BN.prototype.subn = function subn(num) {
  25437. return this.clone().isubn(num);
  25438. };
  25439. BN.prototype.iabs = function iabs() {
  25440. this.negative = 0;
  25441. return this;
  25442. };
  25443. BN.prototype.abs = function abs() {
  25444. return this.clone().iabs();
  25445. };
  25446. BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
  25447. var len = num.length + shift;
  25448. var i;
  25449. this._expand(len);
  25450. var w;
  25451. var carry = 0;
  25452. for (i = 0; i < num.length; i++) {
  25453. w = (this.words[i + shift] | 0) + carry;
  25454. var right = (num.words[i] | 0) * mul;
  25455. w -= right & 0x3ffffff;
  25456. carry = (w >> 26) - (right / 0x4000000 | 0);
  25457. this.words[i + shift] = w & 0x3ffffff;
  25458. }
  25459. for (; i < this.length - shift; i++) {
  25460. w = (this.words[i + shift] | 0) + carry;
  25461. carry = w >> 26;
  25462. this.words[i + shift] = w & 0x3ffffff;
  25463. }
  25464. if (carry === 0) return this.strip(); // Subtraction overflow
  25465. assert(carry === -1);
  25466. carry = 0;
  25467. for (i = 0; i < this.length; i++) {
  25468. w = -(this.words[i] | 0) + carry;
  25469. carry = w >> 26;
  25470. this.words[i] = w & 0x3ffffff;
  25471. }
  25472. this.negative = 1;
  25473. return this.strip();
  25474. };
  25475. BN.prototype._wordDiv = function _wordDiv(num, mode) {
  25476. var shift = this.length - num.length;
  25477. var a = this.clone();
  25478. var b = num; // Normalize
  25479. var bhi = b.words[b.length - 1] | 0;
  25480. var bhiBits = this._countBits(bhi);
  25481. shift = 26 - bhiBits;
  25482. if (shift !== 0) {
  25483. b = b.ushln(shift);
  25484. a.iushln(shift);
  25485. bhi = b.words[b.length - 1] | 0;
  25486. } // Initialize quotient
  25487. var m = a.length - b.length;
  25488. var q;
  25489. if (mode !== 'mod') {
  25490. q = new BN(null);
  25491. q.length = m + 1;
  25492. q.words = new Array(q.length);
  25493. for (var i = 0; i < q.length; i++) {
  25494. q.words[i] = 0;
  25495. }
  25496. }
  25497. var diff = a.clone()._ishlnsubmul(b, 1, m);
  25498. if (diff.negative === 0) {
  25499. a = diff;
  25500. if (q) {
  25501. q.words[m] = 1;
  25502. }
  25503. }
  25504. for (var j = m - 1; j >= 0; j--) {
  25505. var qj = (a.words[b.length + j] | 0) * 0x4000000 + (a.words[b.length + j - 1] | 0); // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  25506. // (0x7ffffff)
  25507. qj = Math.min(qj / bhi | 0, 0x3ffffff);
  25508. a._ishlnsubmul(b, qj, j);
  25509. while (a.negative !== 0) {
  25510. qj--;
  25511. a.negative = 0;
  25512. a._ishlnsubmul(b, 1, j);
  25513. if (!a.isZero()) {
  25514. a.negative ^= 1;
  25515. }
  25516. }
  25517. if (q) {
  25518. q.words[j] = qj;
  25519. }
  25520. }
  25521. if (q) {
  25522. q.strip();
  25523. }
  25524. a.strip(); // Denormalize
  25525. if (mode !== 'div' && shift !== 0) {
  25526. a.iushrn(shift);
  25527. }
  25528. return {
  25529. div: q || null,
  25530. mod: a
  25531. };
  25532. }; // NOTE: 1) `mode` can be set to `mod` to request mod only,
  25533. // to `div` to request div only, or be absent to
  25534. // request both div & mod
  25535. // 2) `positive` is true if unsigned mod is requested
  25536. BN.prototype.divmod = function divmod(num, mode, positive) {
  25537. assert(!num.isZero());
  25538. if (this.isZero()) {
  25539. return {
  25540. div: new BN(0),
  25541. mod: new BN(0)
  25542. };
  25543. }
  25544. var div, mod, res;
  25545. if (this.negative !== 0 && num.negative === 0) {
  25546. res = this.neg().divmod(num, mode);
  25547. if (mode !== 'mod') {
  25548. div = res.div.neg();
  25549. }
  25550. if (mode !== 'div') {
  25551. mod = res.mod.neg();
  25552. if (positive && mod.negative !== 0) {
  25553. mod.iadd(num);
  25554. }
  25555. }
  25556. return {
  25557. div: div,
  25558. mod: mod
  25559. };
  25560. }
  25561. if (this.negative === 0 && num.negative !== 0) {
  25562. res = this.divmod(num.neg(), mode);
  25563. if (mode !== 'mod') {
  25564. div = res.div.neg();
  25565. }
  25566. return {
  25567. div: div,
  25568. mod: res.mod
  25569. };
  25570. }
  25571. if ((this.negative & num.negative) !== 0) {
  25572. res = this.neg().divmod(num.neg(), mode);
  25573. if (mode !== 'div') {
  25574. mod = res.mod.neg();
  25575. if (positive && mod.negative !== 0) {
  25576. mod.isub(num);
  25577. }
  25578. }
  25579. return {
  25580. div: res.div,
  25581. mod: mod
  25582. };
  25583. } // Both numbers are positive at this point
  25584. // Strip both numbers to approximate shift value
  25585. if (num.length > this.length || this.cmp(num) < 0) {
  25586. return {
  25587. div: new BN(0),
  25588. mod: this
  25589. };
  25590. } // Very short reduction
  25591. if (num.length === 1) {
  25592. if (mode === 'div') {
  25593. return {
  25594. div: this.divn(num.words[0]),
  25595. mod: null
  25596. };
  25597. }
  25598. if (mode === 'mod') {
  25599. return {
  25600. div: null,
  25601. mod: new BN(this.modn(num.words[0]))
  25602. };
  25603. }
  25604. return {
  25605. div: this.divn(num.words[0]),
  25606. mod: new BN(this.modn(num.words[0]))
  25607. };
  25608. }
  25609. return this._wordDiv(num, mode);
  25610. }; // Find `this` / `num`
  25611. BN.prototype.div = function div(num) {
  25612. return this.divmod(num, 'div', false).div;
  25613. }; // Find `this` % `num`
  25614. BN.prototype.mod = function mod(num) {
  25615. return this.divmod(num, 'mod', false).mod;
  25616. };
  25617. BN.prototype.umod = function umod(num) {
  25618. return this.divmod(num, 'mod', true).mod;
  25619. }; // Find Round(`this` / `num`)
  25620. BN.prototype.divRound = function divRound(num) {
  25621. var dm = this.divmod(num); // Fast case - exact division
  25622. if (dm.mod.isZero()) return dm.div;
  25623. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  25624. var half = num.ushrn(1);
  25625. var r2 = num.andln(1);
  25626. var cmp = mod.cmp(half); // Round down
  25627. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; // Round up
  25628. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  25629. };
  25630. BN.prototype.modn = function modn(num) {
  25631. assert(num <= 0x3ffffff);
  25632. var p = (1 << 26) % num;
  25633. var acc = 0;
  25634. for (var i = this.length - 1; i >= 0; i--) {
  25635. acc = (p * acc + (this.words[i] | 0)) % num;
  25636. }
  25637. return acc;
  25638. }; // In-place division by number
  25639. BN.prototype.idivn = function idivn(num) {
  25640. assert(num <= 0x3ffffff);
  25641. var carry = 0;
  25642. for (var i = this.length - 1; i >= 0; i--) {
  25643. var w = (this.words[i] | 0) + carry * 0x4000000;
  25644. this.words[i] = w / num | 0;
  25645. carry = w % num;
  25646. }
  25647. return this.strip();
  25648. };
  25649. BN.prototype.divn = function divn(num) {
  25650. return this.clone().idivn(num);
  25651. };
  25652. BN.prototype.egcd = function egcd(p) {
  25653. assert(p.negative === 0);
  25654. assert(!p.isZero());
  25655. var x = this;
  25656. var y = p.clone();
  25657. if (x.negative !== 0) {
  25658. x = x.umod(p);
  25659. } else {
  25660. x = x.clone();
  25661. } // A * x + B * y = x
  25662. var A = new BN(1);
  25663. var B = new BN(0); // C * x + D * y = y
  25664. var C = new BN(0);
  25665. var D = new BN(1);
  25666. var g = 0;
  25667. while (x.isEven() && y.isEven()) {
  25668. x.iushrn(1);
  25669. y.iushrn(1);
  25670. ++g;
  25671. }
  25672. var yp = y.clone();
  25673. var xp = x.clone();
  25674. while (!x.isZero()) {
  25675. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1) {
  25676. ;
  25677. }
  25678. if (i > 0) {
  25679. x.iushrn(i);
  25680. while (i-- > 0) {
  25681. if (A.isOdd() || B.isOdd()) {
  25682. A.iadd(yp);
  25683. B.isub(xp);
  25684. }
  25685. A.iushrn(1);
  25686. B.iushrn(1);
  25687. }
  25688. }
  25689. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1) {
  25690. ;
  25691. }
  25692. if (j > 0) {
  25693. y.iushrn(j);
  25694. while (j-- > 0) {
  25695. if (C.isOdd() || D.isOdd()) {
  25696. C.iadd(yp);
  25697. D.isub(xp);
  25698. }
  25699. C.iushrn(1);
  25700. D.iushrn(1);
  25701. }
  25702. }
  25703. if (x.cmp(y) >= 0) {
  25704. x.isub(y);
  25705. A.isub(C);
  25706. B.isub(D);
  25707. } else {
  25708. y.isub(x);
  25709. C.isub(A);
  25710. D.isub(B);
  25711. }
  25712. }
  25713. return {
  25714. a: C,
  25715. b: D,
  25716. gcd: y.iushln(g)
  25717. };
  25718. }; // This is reduced incarnation of the binary EEA
  25719. // above, designated to invert members of the
  25720. // _prime_ fields F(p) at a maximal speed
  25721. BN.prototype._invmp = function _invmp(p) {
  25722. assert(p.negative === 0);
  25723. assert(!p.isZero());
  25724. var a = this;
  25725. var b = p.clone();
  25726. if (a.negative !== 0) {
  25727. a = a.umod(p);
  25728. } else {
  25729. a = a.clone();
  25730. }
  25731. var x1 = new BN(1);
  25732. var x2 = new BN(0);
  25733. var delta = b.clone();
  25734. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  25735. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) {
  25736. ;
  25737. }
  25738. if (i > 0) {
  25739. a.iushrn(i);
  25740. while (i-- > 0) {
  25741. if (x1.isOdd()) {
  25742. x1.iadd(delta);
  25743. }
  25744. x1.iushrn(1);
  25745. }
  25746. }
  25747. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1) {
  25748. ;
  25749. }
  25750. if (j > 0) {
  25751. b.iushrn(j);
  25752. while (j-- > 0) {
  25753. if (x2.isOdd()) {
  25754. x2.iadd(delta);
  25755. }
  25756. x2.iushrn(1);
  25757. }
  25758. }
  25759. if (a.cmp(b) >= 0) {
  25760. a.isub(b);
  25761. x1.isub(x2);
  25762. } else {
  25763. b.isub(a);
  25764. x2.isub(x1);
  25765. }
  25766. }
  25767. var res;
  25768. if (a.cmpn(1) === 0) {
  25769. res = x1;
  25770. } else {
  25771. res = x2;
  25772. }
  25773. if (res.cmpn(0) < 0) {
  25774. res.iadd(p);
  25775. }
  25776. return res;
  25777. };
  25778. BN.prototype.gcd = function gcd(num) {
  25779. if (this.isZero()) return num.abs();
  25780. if (num.isZero()) return this.abs();
  25781. var a = this.clone();
  25782. var b = num.clone();
  25783. a.negative = 0;
  25784. b.negative = 0; // Remove common factor of two
  25785. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  25786. a.iushrn(1);
  25787. b.iushrn(1);
  25788. }
  25789. do {
  25790. while (a.isEven()) {
  25791. a.iushrn(1);
  25792. }
  25793. while (b.isEven()) {
  25794. b.iushrn(1);
  25795. }
  25796. var r = a.cmp(b);
  25797. if (r < 0) {
  25798. // Swap `a` and `b` to make `a` always bigger than `b`
  25799. var t = a;
  25800. a = b;
  25801. b = t;
  25802. } else if (r === 0 || b.cmpn(1) === 0) {
  25803. break;
  25804. }
  25805. a.isub(b);
  25806. } while (true);
  25807. return b.iushln(shift);
  25808. }; // Invert number in the field F(num)
  25809. BN.prototype.invm = function invm(num) {
  25810. return this.egcd(num).a.umod(num);
  25811. };
  25812. BN.prototype.isEven = function isEven() {
  25813. return (this.words[0] & 1) === 0;
  25814. };
  25815. BN.prototype.isOdd = function isOdd() {
  25816. return (this.words[0] & 1) === 1;
  25817. }; // And first word and num
  25818. BN.prototype.andln = function andln(num) {
  25819. return this.words[0] & num;
  25820. }; // Increment at the bit position in-line
  25821. BN.prototype.bincn = function bincn(bit) {
  25822. assert(typeof bit === 'number');
  25823. var r = bit % 26;
  25824. var s = (bit - r) / 26;
  25825. var q = 1 << r; // Fast case: bit is much higher than all existing words
  25826. if (this.length <= s) {
  25827. this._expand(s + 1);
  25828. this.words[s] |= q;
  25829. return this;
  25830. } // Add bit and propagate, if needed
  25831. var carry = q;
  25832. for (var i = s; carry !== 0 && i < this.length; i++) {
  25833. var w = this.words[i] | 0;
  25834. w += carry;
  25835. carry = w >>> 26;
  25836. w &= 0x3ffffff;
  25837. this.words[i] = w;
  25838. }
  25839. if (carry !== 0) {
  25840. this.words[i] = carry;
  25841. this.length++;
  25842. }
  25843. return this;
  25844. };
  25845. BN.prototype.isZero = function isZero() {
  25846. return this.length === 1 && this.words[0] === 0;
  25847. };
  25848. BN.prototype.cmpn = function cmpn(num) {
  25849. var negative = num < 0;
  25850. if (this.negative !== 0 && !negative) return -1;
  25851. if (this.negative === 0 && negative) return 1;
  25852. this.strip();
  25853. var res;
  25854. if (this.length > 1) {
  25855. res = 1;
  25856. } else {
  25857. if (negative) {
  25858. num = -num;
  25859. }
  25860. assert(num <= 0x3ffffff, 'Number is too big');
  25861. var w = this.words[0] | 0;
  25862. res = w === num ? 0 : w < num ? -1 : 1;
  25863. }
  25864. if (this.negative !== 0) return -res | 0;
  25865. return res;
  25866. }; // Compare two numbers and return:
  25867. // 1 - if `this` > `num`
  25868. // 0 - if `this` == `num`
  25869. // -1 - if `this` < `num`
  25870. BN.prototype.cmp = function cmp(num) {
  25871. if (this.negative !== 0 && num.negative === 0) return -1;
  25872. if (this.negative === 0 && num.negative !== 0) return 1;
  25873. var res = this.ucmp(num);
  25874. if (this.negative !== 0) return -res | 0;
  25875. return res;
  25876. }; // Unsigned comparison
  25877. BN.prototype.ucmp = function ucmp(num) {
  25878. // At this point both numbers have the same sign
  25879. if (this.length > num.length) return 1;
  25880. if (this.length < num.length) return -1;
  25881. var res = 0;
  25882. for (var i = this.length - 1; i >= 0; i--) {
  25883. var a = this.words[i] | 0;
  25884. var b = num.words[i] | 0;
  25885. if (a === b) continue;
  25886. if (a < b) {
  25887. res = -1;
  25888. } else if (a > b) {
  25889. res = 1;
  25890. }
  25891. break;
  25892. }
  25893. return res;
  25894. };
  25895. BN.prototype.gtn = function gtn(num) {
  25896. return this.cmpn(num) === 1;
  25897. };
  25898. BN.prototype.gt = function gt(num) {
  25899. return this.cmp(num) === 1;
  25900. };
  25901. BN.prototype.gten = function gten(num) {
  25902. return this.cmpn(num) >= 0;
  25903. };
  25904. BN.prototype.gte = function gte(num) {
  25905. return this.cmp(num) >= 0;
  25906. };
  25907. BN.prototype.ltn = function ltn(num) {
  25908. return this.cmpn(num) === -1;
  25909. };
  25910. BN.prototype.lt = function lt(num) {
  25911. return this.cmp(num) === -1;
  25912. };
  25913. BN.prototype.lten = function lten(num) {
  25914. return this.cmpn(num) <= 0;
  25915. };
  25916. BN.prototype.lte = function lte(num) {
  25917. return this.cmp(num) <= 0;
  25918. };
  25919. BN.prototype.eqn = function eqn(num) {
  25920. return this.cmpn(num) === 0;
  25921. };
  25922. BN.prototype.eq = function eq(num) {
  25923. return this.cmp(num) === 0;
  25924. }; //
  25925. // A reduce context, could be using montgomery or something better, depending
  25926. // on the `m` itself.
  25927. //
  25928. BN.red = function red(num) {
  25929. return new Red(num);
  25930. };
  25931. BN.prototype.toRed = function toRed(ctx) {
  25932. assert(!this.red, 'Already a number in reduction context');
  25933. assert(this.negative === 0, 'red works only with positives');
  25934. return ctx.convertTo(this)._forceRed(ctx);
  25935. };
  25936. BN.prototype.fromRed = function fromRed() {
  25937. assert(this.red, 'fromRed works only with numbers in reduction context');
  25938. return this.red.convertFrom(this);
  25939. };
  25940. BN.prototype._forceRed = function _forceRed(ctx) {
  25941. this.red = ctx;
  25942. return this;
  25943. };
  25944. BN.prototype.forceRed = function forceRed(ctx) {
  25945. assert(!this.red, 'Already a number in reduction context');
  25946. return this._forceRed(ctx);
  25947. };
  25948. BN.prototype.redAdd = function redAdd(num) {
  25949. assert(this.red, 'redAdd works only with red numbers');
  25950. return this.red.add(this, num);
  25951. };
  25952. BN.prototype.redIAdd = function redIAdd(num) {
  25953. assert(this.red, 'redIAdd works only with red numbers');
  25954. return this.red.iadd(this, num);
  25955. };
  25956. BN.prototype.redSub = function redSub(num) {
  25957. assert(this.red, 'redSub works only with red numbers');
  25958. return this.red.sub(this, num);
  25959. };
  25960. BN.prototype.redISub = function redISub(num) {
  25961. assert(this.red, 'redISub works only with red numbers');
  25962. return this.red.isub(this, num);
  25963. };
  25964. BN.prototype.redShl = function redShl(num) {
  25965. assert(this.red, 'redShl works only with red numbers');
  25966. return this.red.shl(this, num);
  25967. };
  25968. BN.prototype.redMul = function redMul(num) {
  25969. assert(this.red, 'redMul works only with red numbers');
  25970. this.red._verify2(this, num);
  25971. return this.red.mul(this, num);
  25972. };
  25973. BN.prototype.redIMul = function redIMul(num) {
  25974. assert(this.red, 'redMul works only with red numbers');
  25975. this.red._verify2(this, num);
  25976. return this.red.imul(this, num);
  25977. };
  25978. BN.prototype.redSqr = function redSqr() {
  25979. assert(this.red, 'redSqr works only with red numbers');
  25980. this.red._verify1(this);
  25981. return this.red.sqr(this);
  25982. };
  25983. BN.prototype.redISqr = function redISqr() {
  25984. assert(this.red, 'redISqr works only with red numbers');
  25985. this.red._verify1(this);
  25986. return this.red.isqr(this);
  25987. }; // Square root over p
  25988. BN.prototype.redSqrt = function redSqrt() {
  25989. assert(this.red, 'redSqrt works only with red numbers');
  25990. this.red._verify1(this);
  25991. return this.red.sqrt(this);
  25992. };
  25993. BN.prototype.redInvm = function redInvm() {
  25994. assert(this.red, 'redInvm works only with red numbers');
  25995. this.red._verify1(this);
  25996. return this.red.invm(this);
  25997. }; // Return negative clone of `this` % `red modulo`
  25998. BN.prototype.redNeg = function redNeg() {
  25999. assert(this.red, 'redNeg works only with red numbers');
  26000. this.red._verify1(this);
  26001. return this.red.neg(this);
  26002. };
  26003. BN.prototype.redPow = function redPow(num) {
  26004. assert(this.red && !num.red, 'redPow(normalNum)');
  26005. this.red._verify1(this);
  26006. return this.red.pow(this, num);
  26007. }; // Prime numbers with efficient reduction
  26008. var primes = {
  26009. k256: null,
  26010. p224: null,
  26011. p192: null,
  26012. p25519: null
  26013. }; // Pseudo-Mersenne prime
  26014. function MPrime(name, p) {
  26015. // P = 2 ^ N - K
  26016. this.name = name;
  26017. this.p = new BN(p, 16);
  26018. this.n = this.p.bitLength();
  26019. this.k = new BN(1).iushln(this.n).isub(this.p);
  26020. this.tmp = this._tmp();
  26021. }
  26022. MPrime.prototype._tmp = function _tmp() {
  26023. var tmp = new BN(null);
  26024. tmp.words = new Array(Math.ceil(this.n / 13));
  26025. return tmp;
  26026. };
  26027. MPrime.prototype.ireduce = function ireduce(num) {
  26028. // Assumes that `num` is less than `P^2`
  26029. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  26030. var r = num;
  26031. var rlen;
  26032. do {
  26033. this.split(r, this.tmp);
  26034. r = this.imulK(r);
  26035. r = r.iadd(this.tmp);
  26036. rlen = r.bitLength();
  26037. } while (rlen > this.n);
  26038. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  26039. if (cmp === 0) {
  26040. r.words[0] = 0;
  26041. r.length = 1;
  26042. } else if (cmp > 0) {
  26043. r.isub(this.p);
  26044. } else {
  26045. if (r.strip !== undefined) {
  26046. // r is BN v4 instance
  26047. r.strip();
  26048. } else {
  26049. // r is BN v5 instance
  26050. r._strip();
  26051. }
  26052. }
  26053. return r;
  26054. };
  26055. MPrime.prototype.split = function split(input, out) {
  26056. input.iushrn(this.n, 0, out);
  26057. };
  26058. MPrime.prototype.imulK = function imulK(num) {
  26059. return num.imul(this.k);
  26060. };
  26061. function K256() {
  26062. MPrime.call(this, 'k256', 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  26063. }
  26064. inherits(K256, MPrime);
  26065. K256.prototype.split = function split(input, output) {
  26066. // 256 = 9 * 26 + 22
  26067. var mask = 0x3fffff;
  26068. var outLen = Math.min(input.length, 9);
  26069. for (var i = 0; i < outLen; i++) {
  26070. output.words[i] = input.words[i];
  26071. }
  26072. output.length = outLen;
  26073. if (input.length <= 9) {
  26074. input.words[0] = 0;
  26075. input.length = 1;
  26076. return;
  26077. } // Shift by 9 limbs
  26078. var prev = input.words[9];
  26079. output.words[output.length++] = prev & mask;
  26080. for (i = 10; i < input.length; i++) {
  26081. var next = input.words[i] | 0;
  26082. input.words[i - 10] = (next & mask) << 4 | prev >>> 22;
  26083. prev = next;
  26084. }
  26085. prev >>>= 22;
  26086. input.words[i - 10] = prev;
  26087. if (prev === 0 && input.length > 10) {
  26088. input.length -= 10;
  26089. } else {
  26090. input.length -= 9;
  26091. }
  26092. };
  26093. K256.prototype.imulK = function imulK(num) {
  26094. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  26095. num.words[num.length] = 0;
  26096. num.words[num.length + 1] = 0;
  26097. num.length += 2; // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  26098. var lo = 0;
  26099. for (var i = 0; i < num.length; i++) {
  26100. var w = num.words[i] | 0;
  26101. lo += w * 0x3d1;
  26102. num.words[i] = lo & 0x3ffffff;
  26103. lo = w * 0x40 + (lo / 0x4000000 | 0);
  26104. } // Fast length reduction
  26105. if (num.words[num.length - 1] === 0) {
  26106. num.length--;
  26107. if (num.words[num.length - 1] === 0) {
  26108. num.length--;
  26109. }
  26110. }
  26111. return num;
  26112. };
  26113. function P224() {
  26114. MPrime.call(this, 'p224', 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  26115. }
  26116. inherits(P224, MPrime);
  26117. function P192() {
  26118. MPrime.call(this, 'p192', 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  26119. }
  26120. inherits(P192, MPrime);
  26121. function P25519() {
  26122. // 2 ^ 255 - 19
  26123. MPrime.call(this, '25519', '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  26124. }
  26125. inherits(P25519, MPrime);
  26126. P25519.prototype.imulK = function imulK(num) {
  26127. // K = 0x13
  26128. var carry = 0;
  26129. for (var i = 0; i < num.length; i++) {
  26130. var hi = (num.words[i] | 0) * 0x13 + carry;
  26131. var lo = hi & 0x3ffffff;
  26132. hi >>>= 26;
  26133. num.words[i] = lo;
  26134. carry = hi;
  26135. }
  26136. if (carry !== 0) {
  26137. num.words[num.length++] = carry;
  26138. }
  26139. return num;
  26140. }; // Exported mostly for testing purposes, use plain name instead
  26141. BN._prime = function prime(name) {
  26142. // Cached version of prime
  26143. if (primes[name]) return primes[name];
  26144. var prime;
  26145. if (name === 'k256') {
  26146. prime = new K256();
  26147. } else if (name === 'p224') {
  26148. prime = new P224();
  26149. } else if (name === 'p192') {
  26150. prime = new P192();
  26151. } else if (name === 'p25519') {
  26152. prime = new P25519();
  26153. } else {
  26154. throw new Error('Unknown prime ' + name);
  26155. }
  26156. primes[name] = prime;
  26157. return prime;
  26158. }; //
  26159. // Base reduction engine
  26160. //
  26161. function Red(m) {
  26162. if (typeof m === 'string') {
  26163. var prime = BN._prime(m);
  26164. this.m = prime.p;
  26165. this.prime = prime;
  26166. } else {
  26167. assert(m.gtn(1), 'modulus must be greater than 1');
  26168. this.m = m;
  26169. this.prime = null;
  26170. }
  26171. }
  26172. Red.prototype._verify1 = function _verify1(a) {
  26173. assert(a.negative === 0, 'red works only with positives');
  26174. assert(a.red, 'red works only with red numbers');
  26175. };
  26176. Red.prototype._verify2 = function _verify2(a, b) {
  26177. assert((a.negative | b.negative) === 0, 'red works only with positives');
  26178. assert(a.red && a.red === b.red, 'red works only with red numbers');
  26179. };
  26180. Red.prototype.imod = function imod(a) {
  26181. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  26182. return a.umod(this.m)._forceRed(this);
  26183. };
  26184. Red.prototype.neg = function neg(a) {
  26185. if (a.isZero()) {
  26186. return a.clone();
  26187. }
  26188. return this.m.sub(a)._forceRed(this);
  26189. };
  26190. Red.prototype.add = function add(a, b) {
  26191. this._verify2(a, b);
  26192. var res = a.add(b);
  26193. if (res.cmp(this.m) >= 0) {
  26194. res.isub(this.m);
  26195. }
  26196. return res._forceRed(this);
  26197. };
  26198. Red.prototype.iadd = function iadd(a, b) {
  26199. this._verify2(a, b);
  26200. var res = a.iadd(b);
  26201. if (res.cmp(this.m) >= 0) {
  26202. res.isub(this.m);
  26203. }
  26204. return res;
  26205. };
  26206. Red.prototype.sub = function sub(a, b) {
  26207. this._verify2(a, b);
  26208. var res = a.sub(b);
  26209. if (res.cmpn(0) < 0) {
  26210. res.iadd(this.m);
  26211. }
  26212. return res._forceRed(this);
  26213. };
  26214. Red.prototype.isub = function isub(a, b) {
  26215. this._verify2(a, b);
  26216. var res = a.isub(b);
  26217. if (res.cmpn(0) < 0) {
  26218. res.iadd(this.m);
  26219. }
  26220. return res;
  26221. };
  26222. Red.prototype.shl = function shl(a, num) {
  26223. this._verify1(a);
  26224. return this.imod(a.ushln(num));
  26225. };
  26226. Red.prototype.imul = function imul(a, b) {
  26227. this._verify2(a, b);
  26228. return this.imod(a.imul(b));
  26229. };
  26230. Red.prototype.mul = function mul(a, b) {
  26231. this._verify2(a, b);
  26232. return this.imod(a.mul(b));
  26233. };
  26234. Red.prototype.isqr = function isqr(a) {
  26235. return this.imul(a, a.clone());
  26236. };
  26237. Red.prototype.sqr = function sqr(a) {
  26238. return this.mul(a, a);
  26239. };
  26240. Red.prototype.sqrt = function sqrt(a) {
  26241. if (a.isZero()) return a.clone();
  26242. var mod3 = this.m.andln(3);
  26243. assert(mod3 % 2 === 1); // Fast case
  26244. if (mod3 === 3) {
  26245. var pow = this.m.add(new BN(1)).iushrn(2);
  26246. return this.pow(a, pow);
  26247. } // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  26248. //
  26249. // Find Q and S, that Q * 2 ^ S = (P - 1)
  26250. var q = this.m.subn(1);
  26251. var s = 0;
  26252. while (!q.isZero() && q.andln(1) === 0) {
  26253. s++;
  26254. q.iushrn(1);
  26255. }
  26256. assert(!q.isZero());
  26257. var one = new BN(1).toRed(this);
  26258. var nOne = one.redNeg(); // Find quadratic non-residue
  26259. // NOTE: Max is such because of generalized Riemann hypothesis.
  26260. var lpow = this.m.subn(1).iushrn(1);
  26261. var z = this.m.bitLength();
  26262. z = new BN(2 * z * z).toRed(this);
  26263. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  26264. z.redIAdd(nOne);
  26265. }
  26266. var c = this.pow(z, q);
  26267. var r = this.pow(a, q.addn(1).iushrn(1));
  26268. var t = this.pow(a, q);
  26269. var m = s;
  26270. while (t.cmp(one) !== 0) {
  26271. var tmp = t;
  26272. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  26273. tmp = tmp.redSqr();
  26274. }
  26275. assert(i < m);
  26276. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  26277. r = r.redMul(b);
  26278. c = b.redSqr();
  26279. t = t.redMul(c);
  26280. m = i;
  26281. }
  26282. return r;
  26283. };
  26284. Red.prototype.invm = function invm(a) {
  26285. var inv = a._invmp(this.m);
  26286. if (inv.negative !== 0) {
  26287. inv.negative = 0;
  26288. return this.imod(inv).redNeg();
  26289. } else {
  26290. return this.imod(inv);
  26291. }
  26292. };
  26293. Red.prototype.pow = function pow(a, num) {
  26294. if (num.isZero()) return new BN(1).toRed(this);
  26295. if (num.cmpn(1) === 0) return a.clone();
  26296. var windowSize = 4;
  26297. var wnd = new Array(1 << windowSize);
  26298. wnd[0] = new BN(1).toRed(this);
  26299. wnd[1] = a;
  26300. for (var i = 2; i < wnd.length; i++) {
  26301. wnd[i] = this.mul(wnd[i - 1], a);
  26302. }
  26303. var res = wnd[0];
  26304. var current = 0;
  26305. var currentLen = 0;
  26306. var start = num.bitLength() % 26;
  26307. if (start === 0) {
  26308. start = 26;
  26309. }
  26310. for (i = num.length - 1; i >= 0; i--) {
  26311. var word = num.words[i];
  26312. for (var j = start - 1; j >= 0; j--) {
  26313. var bit = word >> j & 1;
  26314. if (res !== wnd[0]) {
  26315. res = this.sqr(res);
  26316. }
  26317. if (bit === 0 && current === 0) {
  26318. currentLen = 0;
  26319. continue;
  26320. }
  26321. current <<= 1;
  26322. current |= bit;
  26323. currentLen++;
  26324. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  26325. res = this.mul(res, wnd[current]);
  26326. currentLen = 0;
  26327. current = 0;
  26328. }
  26329. start = 26;
  26330. }
  26331. return res;
  26332. };
  26333. Red.prototype.convertTo = function convertTo(num) {
  26334. var r = num.umod(this.m);
  26335. return r === num ? r.clone() : r;
  26336. };
  26337. Red.prototype.convertFrom = function convertFrom(num) {
  26338. var res = num.clone();
  26339. res.red = null;
  26340. return res;
  26341. }; //
  26342. // Montgomery method engine
  26343. //
  26344. BN.mont = function mont(num) {
  26345. return new Mont(num);
  26346. };
  26347. function Mont(m) {
  26348. Red.call(this, m);
  26349. this.shift = this.m.bitLength();
  26350. if (this.shift % 26 !== 0) {
  26351. this.shift += 26 - this.shift % 26;
  26352. }
  26353. this.r = new BN(1).iushln(this.shift);
  26354. this.r2 = this.imod(this.r.sqr());
  26355. this.rinv = this.r._invmp(this.m);
  26356. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  26357. this.minv = this.minv.umod(this.r);
  26358. this.minv = this.r.sub(this.minv);
  26359. }
  26360. inherits(Mont, Red);
  26361. Mont.prototype.convertTo = function convertTo(num) {
  26362. return this.imod(num.ushln(this.shift));
  26363. };
  26364. Mont.prototype.convertFrom = function convertFrom(num) {
  26365. var r = this.imod(num.mul(this.rinv));
  26366. r.red = null;
  26367. return r;
  26368. };
  26369. Mont.prototype.imul = function imul(a, b) {
  26370. if (a.isZero() || b.isZero()) {
  26371. a.words[0] = 0;
  26372. a.length = 1;
  26373. return a;
  26374. }
  26375. var t = a.imul(b);
  26376. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  26377. var u = t.isub(c).iushrn(this.shift);
  26378. var res = u;
  26379. if (u.cmp(this.m) >= 0) {
  26380. res = u.isub(this.m);
  26381. } else if (u.cmpn(0) < 0) {
  26382. res = u.iadd(this.m);
  26383. }
  26384. return res._forceRed(this);
  26385. };
  26386. Mont.prototype.mul = function mul(a, b) {
  26387. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  26388. var t = a.mul(b);
  26389. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  26390. var u = t.isub(c).iushrn(this.shift);
  26391. var res = u;
  26392. if (u.cmp(this.m) >= 0) {
  26393. res = u.isub(this.m);
  26394. } else if (u.cmpn(0) < 0) {
  26395. res = u.iadd(this.m);
  26396. }
  26397. return res._forceRed(this);
  26398. };
  26399. Mont.prototype.invm = function invm(a) {
  26400. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  26401. var res = this.imod(a._invmp(this.m).mul(this.r2));
  26402. return res._forceRed(this);
  26403. };
  26404. })(typeof module === 'undefined' || module, void 0);
  26405. }, { "buffer": 185 }], 182: [function (require, module, exports) {
  26406. 'use strict';
  26407. exports.byteLength = byteLength;
  26408. exports.toByteArray = toByteArray;
  26409. exports.fromByteArray = fromByteArray;
  26410. var lookup = [];
  26411. var revLookup = [];
  26412. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  26413. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  26414. for (var i = 0, len = code.length; i < len; ++i) {
  26415. lookup[i] = code[i];
  26416. revLookup[code.charCodeAt(i)] = i;
  26417. } // Support decoding URL-safe base64 strings, as Node.js does.
  26418. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  26419. revLookup['-'.charCodeAt(0)] = 62;
  26420. revLookup['_'.charCodeAt(0)] = 63;
  26421. function getLens(b64) {
  26422. var len = b64.length;
  26423. if (len % 4 > 0) {
  26424. throw new Error('Invalid string. Length must be a multiple of 4');
  26425. } // Trim off extra bytes after placeholder bytes are found
  26426. // See: https://github.com/beatgammit/base64-js/issues/42
  26427. var validLen = b64.indexOf('=');
  26428. if (validLen === -1) validLen = len;
  26429. var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
  26430. return [validLen, placeHoldersLen];
  26431. } // base64 is 4/3 + up to two characters of the original data
  26432. function byteLength(b64) {
  26433. var lens = getLens(b64);
  26434. var validLen = lens[0];
  26435. var placeHoldersLen = lens[1];
  26436. return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
  26437. }
  26438. function _byteLength(b64, validLen, placeHoldersLen) {
  26439. return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
  26440. }
  26441. function toByteArray(b64) {
  26442. var tmp;
  26443. var lens = getLens(b64);
  26444. var validLen = lens[0];
  26445. var placeHoldersLen = lens[1];
  26446. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
  26447. var curByte = 0; // if there are placeholders, only get up to the last complete 4 chars
  26448. var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
  26449. var i;
  26450. for (i = 0; i < len; i += 4) {
  26451. tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
  26452. arr[curByte++] = tmp >> 16 & 0xFF;
  26453. arr[curByte++] = tmp >> 8 & 0xFF;
  26454. arr[curByte++] = tmp & 0xFF;
  26455. }
  26456. if (placeHoldersLen === 2) {
  26457. tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
  26458. arr[curByte++] = tmp & 0xFF;
  26459. }
  26460. if (placeHoldersLen === 1) {
  26461. tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
  26462. arr[curByte++] = tmp >> 8 & 0xFF;
  26463. arr[curByte++] = tmp & 0xFF;
  26464. }
  26465. return arr;
  26466. }
  26467. function tripletToBase64(num) {
  26468. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
  26469. }
  26470. function encodeChunk(uint8, start, end) {
  26471. var tmp;
  26472. var output = [];
  26473. for (var i = start; i < end; i += 3) {
  26474. tmp = (uint8[i] << 16 & 0xFF0000) + (uint8[i + 1] << 8 & 0xFF00) + (uint8[i + 2] & 0xFF);
  26475. output.push(tripletToBase64(tmp));
  26476. }
  26477. return output.join('');
  26478. }
  26479. function fromByteArray(uint8) {
  26480. var tmp;
  26481. var len = uint8.length;
  26482. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  26483. var parts = [];
  26484. var maxChunkLength = 16383; // must be multiple of 3
  26485. // go through the array every three bytes, we'll deal with trailing stuff later
  26486. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  26487. parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
  26488. } // pad the end with zeros, but make sure to not forget the extra bytes
  26489. if (extraBytes === 1) {
  26490. tmp = uint8[len - 1];
  26491. parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 0x3F] + '==');
  26492. } else if (extraBytes === 2) {
  26493. tmp = (uint8[len - 2] << 8) + uint8[len - 1];
  26494. parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 0x3F] + lookup[tmp << 2 & 0x3F] + '=');
  26495. }
  26496. return parts.join('');
  26497. }
  26498. }, {}], 183: [function (require, module, exports) {
  26499. "use strict";
  26500. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  26501. (function (module, exports) {
  26502. 'use strict'; // Utils
  26503. function assert(val, msg) {
  26504. if (!val) throw new Error(msg || 'Assertion failed');
  26505. } // Could use `inherits` module, but don't want to move from single file
  26506. // architecture yet.
  26507. function inherits(ctor, superCtor) {
  26508. ctor.super_ = superCtor;
  26509. var TempCtor = function TempCtor() { };
  26510. TempCtor.prototype = superCtor.prototype;
  26511. ctor.prototype = new TempCtor();
  26512. ctor.prototype.constructor = ctor;
  26513. } // BN
  26514. function BN(number, base, endian) {
  26515. if (BN.isBN(number)) {
  26516. return number;
  26517. }
  26518. this.negative = 0;
  26519. this.words = null;
  26520. this.length = 0; // Reduction context
  26521. this.red = null;
  26522. if (number !== null) {
  26523. if (base === 'le' || base === 'be') {
  26524. endian = base;
  26525. base = 10;
  26526. }
  26527. this._init(number || 0, base || 10, endian || 'be');
  26528. }
  26529. }
  26530. if (_typeof(module) === 'object') {
  26531. module.exports = BN;
  26532. } else {
  26533. exports.BN = BN;
  26534. }
  26535. BN.BN = BN;
  26536. BN.wordSize = 26;
  26537. var Buffer;
  26538. try {
  26539. Buffer = require('buffer').Buffer;
  26540. } catch (e) { }
  26541. BN.isBN = function isBN(num) {
  26542. if (num instanceof BN) {
  26543. return true;
  26544. }
  26545. return num !== null && _typeof(num) === 'object' && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  26546. };
  26547. BN.max = function max(left, right) {
  26548. if (left.cmp(right) > 0) return left;
  26549. return right;
  26550. };
  26551. BN.min = function min(left, right) {
  26552. if (left.cmp(right) < 0) return left;
  26553. return right;
  26554. };
  26555. BN.prototype._init = function init(number, base, endian) {
  26556. if (typeof number === 'number') {
  26557. return this._initNumber(number, base, endian);
  26558. }
  26559. if (_typeof(number) === 'object') {
  26560. return this._initArray(number, base, endian);
  26561. }
  26562. if (base === 'hex') {
  26563. base = 16;
  26564. }
  26565. assert(base === (base | 0) && base >= 2 && base <= 36);
  26566. number = number.toString().replace(/\s+/g, '');
  26567. var start = 0;
  26568. if (number[0] === '-') {
  26569. start++;
  26570. }
  26571. if (base === 16) {
  26572. this._parseHex(number, start);
  26573. } else {
  26574. this._parseBase(number, base, start);
  26575. }
  26576. if (number[0] === '-') {
  26577. this.negative = 1;
  26578. }
  26579. this._strip();
  26580. if (endian !== 'le') return;
  26581. this._initArray(this.toArray(), base, endian);
  26582. };
  26583. BN.prototype._initNumber = function _initNumber(number, base, endian) {
  26584. if (number < 0) {
  26585. this.negative = 1;
  26586. number = -number;
  26587. }
  26588. if (number < 0x4000000) {
  26589. this.words = [number & 0x3ffffff];
  26590. this.length = 1;
  26591. } else if (number < 0x10000000000000) {
  26592. this.words = [number & 0x3ffffff, number / 0x4000000 & 0x3ffffff];
  26593. this.length = 2;
  26594. } else {
  26595. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  26596. this.words = [number & 0x3ffffff, number / 0x4000000 & 0x3ffffff, 1];
  26597. this.length = 3;
  26598. }
  26599. if (endian !== 'le') return; // Reverse the bytes
  26600. this._initArray(this.toArray(), base, endian);
  26601. };
  26602. BN.prototype._initArray = function _initArray(number, base, endian) {
  26603. // Perhaps a Uint8Array
  26604. assert(typeof number.length === 'number');
  26605. if (number.length <= 0) {
  26606. this.words = [0];
  26607. this.length = 1;
  26608. return this;
  26609. }
  26610. this.length = Math.ceil(number.length / 3);
  26611. this.words = new Array(this.length);
  26612. for (var i = 0; i < this.length; i++) {
  26613. this.words[i] = 0;
  26614. }
  26615. var j, w;
  26616. var off = 0;
  26617. if (endian === 'be') {
  26618. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  26619. w = number[i] | number[i - 1] << 8 | number[i - 2] << 16;
  26620. this.words[j] |= w << off & 0x3ffffff;
  26621. this.words[j + 1] = w >>> 26 - off & 0x3ffffff;
  26622. off += 24;
  26623. if (off >= 26) {
  26624. off -= 26;
  26625. j++;
  26626. }
  26627. }
  26628. } else if (endian === 'le') {
  26629. for (i = 0, j = 0; i < number.length; i += 3) {
  26630. w = number[i] | number[i + 1] << 8 | number[i + 2] << 16;
  26631. this.words[j] |= w << off & 0x3ffffff;
  26632. this.words[j + 1] = w >>> 26 - off & 0x3ffffff;
  26633. off += 24;
  26634. if (off >= 26) {
  26635. off -= 26;
  26636. j++;
  26637. }
  26638. }
  26639. }
  26640. return this._strip();
  26641. };
  26642. function parseHex(str, start, end) {
  26643. var r = 0;
  26644. var len = Math.min(str.length, end);
  26645. var z = 0;
  26646. for (var i = start; i < len; i++) {
  26647. var c = str.charCodeAt(i) - 48;
  26648. r <<= 4;
  26649. var b; // 'a' - 'f'
  26650. if (c >= 49 && c <= 54) {
  26651. b = c - 49 + 0xa; // 'A' - 'F'
  26652. } else if (c >= 17 && c <= 22) {
  26653. b = c - 17 + 0xa; // '0' - '9'
  26654. } else {
  26655. b = c;
  26656. }
  26657. r |= b;
  26658. z |= b;
  26659. }
  26660. assert(!(z & 0xf0), 'Invalid character in ' + str);
  26661. return r;
  26662. }
  26663. BN.prototype._parseHex = function _parseHex(number, start) {
  26664. // Create possibly bigger array to ensure that it fits the number
  26665. this.length = Math.ceil((number.length - start) / 6);
  26666. this.words = new Array(this.length);
  26667. for (var i = 0; i < this.length; i++) {
  26668. this.words[i] = 0;
  26669. }
  26670. var j, w; // Scan 24-bit chunks and add them to the number
  26671. var off = 0;
  26672. for (i = number.length - 6, j = 0; i >= start; i -= 6) {
  26673. w = parseHex(number, i, i + 6);
  26674. this.words[j] |= w << off & 0x3ffffff; // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
  26675. this.words[j + 1] |= w >>> 26 - off & 0x3fffff;
  26676. off += 24;
  26677. if (off >= 26) {
  26678. off -= 26;
  26679. j++;
  26680. }
  26681. }
  26682. if (i + 6 !== start) {
  26683. w = parseHex(number, start, i + 6);
  26684. this.words[j] |= w << off & 0x3ffffff;
  26685. this.words[j + 1] |= w >>> 26 - off & 0x3fffff;
  26686. }
  26687. this._strip();
  26688. };
  26689. function parseBase(str, start, end, mul) {
  26690. var r = 0;
  26691. var b = 0;
  26692. var len = Math.min(str.length, end);
  26693. for (var i = start; i < len; i++) {
  26694. var c = str.charCodeAt(i) - 48;
  26695. r *= mul; // 'a'
  26696. if (c >= 49) {
  26697. b = c - 49 + 0xa; // 'A'
  26698. } else if (c >= 17) {
  26699. b = c - 17 + 0xa; // '0' - '9'
  26700. } else {
  26701. b = c;
  26702. }
  26703. assert(c >= 0 && b < mul, 'Invalid character');
  26704. r += b;
  26705. }
  26706. return r;
  26707. }
  26708. BN.prototype._parseBase = function _parseBase(number, base, start) {
  26709. // Initialize as zero
  26710. this.words = [0];
  26711. this.length = 1; // Find length of limb in base
  26712. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  26713. limbLen++;
  26714. }
  26715. limbLen--;
  26716. limbPow = limbPow / base | 0;
  26717. var total = number.length - start;
  26718. var mod = total % limbLen;
  26719. var end = Math.min(total, total - mod) + start;
  26720. var word = 0;
  26721. for (var i = start; i < end; i += limbLen) {
  26722. word = parseBase(number, i, i + limbLen, base);
  26723. this.imuln(limbPow);
  26724. if (this.words[0] + word < 0x4000000) {
  26725. this.words[0] += word;
  26726. } else {
  26727. this._iaddn(word);
  26728. }
  26729. }
  26730. if (mod !== 0) {
  26731. var pow = 1;
  26732. word = parseBase(number, i, number.length, base);
  26733. for (i = 0; i < mod; i++) {
  26734. pow *= base;
  26735. }
  26736. this.imuln(pow);
  26737. if (this.words[0] + word < 0x4000000) {
  26738. this.words[0] += word;
  26739. } else {
  26740. this._iaddn(word);
  26741. }
  26742. }
  26743. };
  26744. BN.prototype.copy = function copy(dest) {
  26745. dest.words = new Array(this.length);
  26746. for (var i = 0; i < this.length; i++) {
  26747. dest.words[i] = this.words[i];
  26748. }
  26749. dest.length = this.length;
  26750. dest.negative = this.negative;
  26751. dest.red = this.red;
  26752. };
  26753. function move(dest, src) {
  26754. dest.words = src.words;
  26755. dest.length = src.length;
  26756. dest.negative = src.negative;
  26757. dest.red = src.red;
  26758. }
  26759. BN.prototype._move = function _move(dest) {
  26760. move(dest, this);
  26761. };
  26762. BN.prototype.clone = function clone() {
  26763. var r = new BN(null);
  26764. this.copy(r);
  26765. return r;
  26766. };
  26767. BN.prototype._expand = function _expand(size) {
  26768. while (this.length < size) {
  26769. this.words[this.length++] = 0;
  26770. }
  26771. return this;
  26772. }; // Remove leading `0` from `this`
  26773. BN.prototype._strip = function strip() {
  26774. while (this.length > 1 && this.words[this.length - 1] === 0) {
  26775. this.length--;
  26776. }
  26777. return this._normSign();
  26778. };
  26779. BN.prototype._normSign = function _normSign() {
  26780. // -0 = 0
  26781. if (this.length === 1 && this.words[0] === 0) {
  26782. this.negative = 0;
  26783. }
  26784. return this;
  26785. }; // Check Symbol.for because not everywhere where Symbol defined
  26786. // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility
  26787. if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') {
  26788. try {
  26789. BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect;
  26790. } catch (e) {
  26791. BN.prototype.inspect = inspect;
  26792. }
  26793. } else {
  26794. BN.prototype.inspect = inspect;
  26795. }
  26796. function inspect() {
  26797. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  26798. }
  26799. /*
  26800. var zeros = [];
  26801. var groupSizes = [];
  26802. var groupBases = [];
  26803. var s = '';
  26804. var i = -1;
  26805. while (++i < BN.wordSize) {
  26806. zeros[i] = s;
  26807. s += '0';
  26808. }
  26809. groupSizes[0] = 0;
  26810. groupSizes[1] = 0;
  26811. groupBases[0] = 0;
  26812. groupBases[1] = 0;
  26813. var base = 2 - 1;
  26814. while (++base < 36 + 1) {
  26815. var groupSize = 0;
  26816. var groupBase = 1;
  26817. while (groupBase < (1 << BN.wordSize) / base) {
  26818. groupBase *= base;
  26819. groupSize += 1;
  26820. }
  26821. groupSizes[base] = groupSize;
  26822. groupBases[base] = groupBase;
  26823. }
  26824. */
  26825. var zeros = ['', '0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '000000000', '0000000000', '00000000000', '000000000000', '0000000000000', '00000000000000', '000000000000000', '0000000000000000', '00000000000000000', '000000000000000000', '0000000000000000000', '00000000000000000000', '000000000000000000000', '0000000000000000000000', '00000000000000000000000', '000000000000000000000000', '0000000000000000000000000'];
  26826. var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5];
  26827. var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176];
  26828. BN.prototype.toString = function toString(base, padding) {
  26829. base = base || 10;
  26830. padding = padding | 0 || 1;
  26831. var out;
  26832. if (base === 16 || base === 'hex') {
  26833. out = '';
  26834. var off = 0;
  26835. var carry = 0;
  26836. for (var i = 0; i < this.length; i++) {
  26837. var w = this.words[i];
  26838. var word = ((w << off | carry) & 0xffffff).toString(16);
  26839. carry = w >>> 24 - off & 0xffffff;
  26840. if (carry !== 0 || i !== this.length - 1) {
  26841. out = zeros[6 - word.length] + word + out;
  26842. } else {
  26843. out = word + out;
  26844. }
  26845. off += 2;
  26846. if (off >= 26) {
  26847. off -= 26;
  26848. i--;
  26849. }
  26850. }
  26851. if (carry !== 0) {
  26852. out = carry.toString(16) + out;
  26853. }
  26854. while (out.length % padding !== 0) {
  26855. out = '0' + out;
  26856. }
  26857. if (this.negative !== 0) {
  26858. out = '-' + out;
  26859. }
  26860. return out;
  26861. }
  26862. if (base === (base | 0) && base >= 2 && base <= 36) {
  26863. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  26864. var groupSize = groupSizes[base]; // var groupBase = Math.pow(base, groupSize);
  26865. var groupBase = groupBases[base];
  26866. out = '';
  26867. var c = this.clone();
  26868. c.negative = 0;
  26869. while (!c.isZero()) {
  26870. var r = c.modrn(groupBase).toString(base);
  26871. c = c.idivn(groupBase);
  26872. if (!c.isZero()) {
  26873. out = zeros[groupSize - r.length] + r + out;
  26874. } else {
  26875. out = r + out;
  26876. }
  26877. }
  26878. if (this.isZero()) {
  26879. out = '0' + out;
  26880. }
  26881. while (out.length % padding !== 0) {
  26882. out = '0' + out;
  26883. }
  26884. if (this.negative !== 0) {
  26885. out = '-' + out;
  26886. }
  26887. return out;
  26888. }
  26889. assert(false, 'Base should be between 2 and 36');
  26890. };
  26891. BN.prototype.toNumber = function toNumber() {
  26892. var ret = this.words[0];
  26893. if (this.length === 2) {
  26894. ret += this.words[1] * 0x4000000;
  26895. } else if (this.length === 3 && this.words[2] === 0x01) {
  26896. // NOTE: at this stage it is known that the top bit is set
  26897. ret += 0x10000000000000 + this.words[1] * 0x4000000;
  26898. } else if (this.length > 2) {
  26899. assert(false, 'Number can only safely store up to 53 bits');
  26900. }
  26901. return this.negative !== 0 ? -ret : ret;
  26902. };
  26903. BN.prototype.toJSON = function toJSON() {
  26904. return this.toString(16, 2);
  26905. };
  26906. if (Buffer) {
  26907. BN.prototype.toBuffer = function toBuffer(endian, length) {
  26908. return this.toArrayLike(Buffer, endian, length);
  26909. };
  26910. }
  26911. BN.prototype.toArray = function toArray(endian, length) {
  26912. return this.toArrayLike(Array, endian, length);
  26913. };
  26914. var allocate = function allocate(ArrayType, size) {
  26915. if (ArrayType.allocUnsafe) {
  26916. return ArrayType.allocUnsafe(size);
  26917. }
  26918. return new ArrayType(size);
  26919. };
  26920. BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
  26921. this._strip();
  26922. var byteLength = this.byteLength();
  26923. var reqLength = length || Math.max(1, byteLength);
  26924. assert(byteLength <= reqLength, 'byte array longer than desired length');
  26925. assert(reqLength > 0, 'Requested array length <= 0');
  26926. var res = allocate(ArrayType, reqLength);
  26927. var postfix = endian === 'le' ? 'LE' : 'BE';
  26928. this['_toArrayLike' + postfix](res, byteLength);
  26929. return res;
  26930. };
  26931. BN.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
  26932. var position = 0;
  26933. var carry = 0;
  26934. for (var i = 0, shift = 0; i < this.length; i++) {
  26935. var word = this.words[i] << shift | carry;
  26936. res[position++] = word & 0xff;
  26937. if (position < res.length) {
  26938. res[position++] = word >> 8 & 0xff;
  26939. }
  26940. if (position < res.length) {
  26941. res[position++] = word >> 16 & 0xff;
  26942. }
  26943. if (shift === 6) {
  26944. if (position < res.length) {
  26945. res[position++] = word >> 24 & 0xff;
  26946. }
  26947. carry = 0;
  26948. shift = 0;
  26949. } else {
  26950. carry = word >>> 24;
  26951. shift += 2;
  26952. }
  26953. }
  26954. if (position < res.length) {
  26955. res[position++] = carry;
  26956. while (position < res.length) {
  26957. res[position++] = 0;
  26958. }
  26959. }
  26960. };
  26961. BN.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
  26962. var position = res.length - 1;
  26963. var carry = 0;
  26964. for (var i = 0, shift = 0; i < this.length; i++) {
  26965. var word = this.words[i] << shift | carry;
  26966. res[position--] = word & 0xff;
  26967. if (position >= 0) {
  26968. res[position--] = word >> 8 & 0xff;
  26969. }
  26970. if (position >= 0) {
  26971. res[position--] = word >> 16 & 0xff;
  26972. }
  26973. if (shift === 6) {
  26974. if (position >= 0) {
  26975. res[position--] = word >> 24 & 0xff;
  26976. }
  26977. carry = 0;
  26978. shift = 0;
  26979. } else {
  26980. carry = word >>> 24;
  26981. shift += 2;
  26982. }
  26983. }
  26984. if (position >= 0) {
  26985. res[position--] = carry;
  26986. while (position >= 0) {
  26987. res[position--] = 0;
  26988. }
  26989. }
  26990. };
  26991. if (Math.clz32) {
  26992. BN.prototype._countBits = function _countBits(w) {
  26993. return 32 - Math.clz32(w);
  26994. };
  26995. } else {
  26996. BN.prototype._countBits = function _countBits(w) {
  26997. var t = w;
  26998. var r = 0;
  26999. if (t >= 0x1000) {
  27000. r += 13;
  27001. t >>>= 13;
  27002. }
  27003. if (t >= 0x40) {
  27004. r += 7;
  27005. t >>>= 7;
  27006. }
  27007. if (t >= 0x8) {
  27008. r += 4;
  27009. t >>>= 4;
  27010. }
  27011. if (t >= 0x02) {
  27012. r += 2;
  27013. t >>>= 2;
  27014. }
  27015. return r + t;
  27016. };
  27017. }
  27018. BN.prototype._zeroBits = function _zeroBits(w) {
  27019. // Short-cut
  27020. if (w === 0) return 26;
  27021. var t = w;
  27022. var r = 0;
  27023. if ((t & 0x1fff) === 0) {
  27024. r += 13;
  27025. t >>>= 13;
  27026. }
  27027. if ((t & 0x7f) === 0) {
  27028. r += 7;
  27029. t >>>= 7;
  27030. }
  27031. if ((t & 0xf) === 0) {
  27032. r += 4;
  27033. t >>>= 4;
  27034. }
  27035. if ((t & 0x3) === 0) {
  27036. r += 2;
  27037. t >>>= 2;
  27038. }
  27039. if ((t & 0x1) === 0) {
  27040. r++;
  27041. }
  27042. return r;
  27043. }; // Return number of used bits in a BN
  27044. BN.prototype.bitLength = function bitLength() {
  27045. var w = this.words[this.length - 1];
  27046. var hi = this._countBits(w);
  27047. return (this.length - 1) * 26 + hi;
  27048. };
  27049. function toBitArray(num) {
  27050. var w = new Array(num.bitLength());
  27051. for (var bit = 0; bit < w.length; bit++) {
  27052. var off = bit / 26 | 0;
  27053. var wbit = bit % 26;
  27054. w[bit] = num.words[off] >>> wbit & 0x01;
  27055. }
  27056. return w;
  27057. } // Number of trailing zero bits
  27058. BN.prototype.zeroBits = function zeroBits() {
  27059. if (this.isZero()) return 0;
  27060. var r = 0;
  27061. for (var i = 0; i < this.length; i++) {
  27062. var b = this._zeroBits(this.words[i]);
  27063. r += b;
  27064. if (b !== 26) break;
  27065. }
  27066. return r;
  27067. };
  27068. BN.prototype.byteLength = function byteLength() {
  27069. return Math.ceil(this.bitLength() / 8);
  27070. };
  27071. BN.prototype.toTwos = function toTwos(width) {
  27072. if (this.negative !== 0) {
  27073. return this.abs().inotn(width).iaddn(1);
  27074. }
  27075. return this.clone();
  27076. };
  27077. BN.prototype.fromTwos = function fromTwos(width) {
  27078. if (this.testn(width - 1)) {
  27079. return this.notn(width).iaddn(1).ineg();
  27080. }
  27081. return this.clone();
  27082. };
  27083. BN.prototype.isNeg = function isNeg() {
  27084. return this.negative !== 0;
  27085. }; // Return negative clone of `this`
  27086. BN.prototype.neg = function neg() {
  27087. return this.clone().ineg();
  27088. };
  27089. BN.prototype.ineg = function ineg() {
  27090. if (!this.isZero()) {
  27091. this.negative ^= 1;
  27092. }
  27093. return this;
  27094. }; // Or `num` with `this` in-place
  27095. BN.prototype.iuor = function iuor(num) {
  27096. while (this.length < num.length) {
  27097. this.words[this.length++] = 0;
  27098. }
  27099. for (var i = 0; i < num.length; i++) {
  27100. this.words[i] = this.words[i] | num.words[i];
  27101. }
  27102. return this._strip();
  27103. };
  27104. BN.prototype.ior = function ior(num) {
  27105. assert((this.negative | num.negative) === 0);
  27106. return this.iuor(num);
  27107. }; // Or `num` with `this`
  27108. BN.prototype.or = function or(num) {
  27109. if (this.length > num.length) return this.clone().ior(num);
  27110. return num.clone().ior(this);
  27111. };
  27112. BN.prototype.uor = function uor(num) {
  27113. if (this.length > num.length) return this.clone().iuor(num);
  27114. return num.clone().iuor(this);
  27115. }; // And `num` with `this` in-place
  27116. BN.prototype.iuand = function iuand(num) {
  27117. // b = min-length(num, this)
  27118. var b;
  27119. if (this.length > num.length) {
  27120. b = num;
  27121. } else {
  27122. b = this;
  27123. }
  27124. for (var i = 0; i < b.length; i++) {
  27125. this.words[i] = this.words[i] & num.words[i];
  27126. }
  27127. this.length = b.length;
  27128. return this._strip();
  27129. };
  27130. BN.prototype.iand = function iand(num) {
  27131. assert((this.negative | num.negative) === 0);
  27132. return this.iuand(num);
  27133. }; // And `num` with `this`
  27134. BN.prototype.and = function and(num) {
  27135. if (this.length > num.length) return this.clone().iand(num);
  27136. return num.clone().iand(this);
  27137. };
  27138. BN.prototype.uand = function uand(num) {
  27139. if (this.length > num.length) return this.clone().iuand(num);
  27140. return num.clone().iuand(this);
  27141. }; // Xor `num` with `this` in-place
  27142. BN.prototype.iuxor = function iuxor(num) {
  27143. // a.length > b.length
  27144. var a;
  27145. var b;
  27146. if (this.length > num.length) {
  27147. a = this;
  27148. b = num;
  27149. } else {
  27150. a = num;
  27151. b = this;
  27152. }
  27153. for (var i = 0; i < b.length; i++) {
  27154. this.words[i] = a.words[i] ^ b.words[i];
  27155. }
  27156. if (this !== a) {
  27157. for (; i < a.length; i++) {
  27158. this.words[i] = a.words[i];
  27159. }
  27160. }
  27161. this.length = a.length;
  27162. return this._strip();
  27163. };
  27164. BN.prototype.ixor = function ixor(num) {
  27165. assert((this.negative | num.negative) === 0);
  27166. return this.iuxor(num);
  27167. }; // Xor `num` with `this`
  27168. BN.prototype.xor = function xor(num) {
  27169. if (this.length > num.length) return this.clone().ixor(num);
  27170. return num.clone().ixor(this);
  27171. };
  27172. BN.prototype.uxor = function uxor(num) {
  27173. if (this.length > num.length) return this.clone().iuxor(num);
  27174. return num.clone().iuxor(this);
  27175. }; // Not ``this`` with ``width`` bitwidth
  27176. BN.prototype.inotn = function inotn(width) {
  27177. assert(typeof width === 'number' && width >= 0);
  27178. var bytesNeeded = Math.ceil(width / 26) | 0;
  27179. var bitsLeft = width % 26; // Extend the buffer with leading zeroes
  27180. this._expand(bytesNeeded);
  27181. if (bitsLeft > 0) {
  27182. bytesNeeded--;
  27183. } // Handle complete words
  27184. for (var i = 0; i < bytesNeeded; i++) {
  27185. this.words[i] = ~this.words[i] & 0x3ffffff;
  27186. } // Handle the residue
  27187. if (bitsLeft > 0) {
  27188. this.words[i] = ~this.words[i] & 0x3ffffff >> 26 - bitsLeft;
  27189. } // And remove leading zeroes
  27190. return this._strip();
  27191. };
  27192. BN.prototype.notn = function notn(width) {
  27193. return this.clone().inotn(width);
  27194. }; // Set `bit` of `this`
  27195. BN.prototype.setn = function setn(bit, val) {
  27196. assert(typeof bit === 'number' && bit >= 0);
  27197. var off = bit / 26 | 0;
  27198. var wbit = bit % 26;
  27199. this._expand(off + 1);
  27200. if (val) {
  27201. this.words[off] = this.words[off] | 1 << wbit;
  27202. } else {
  27203. this.words[off] = this.words[off] & ~(1 << wbit);
  27204. }
  27205. return this._strip();
  27206. }; // Add `num` to `this` in-place
  27207. BN.prototype.iadd = function iadd(num) {
  27208. var r; // negative + positive
  27209. if (this.negative !== 0 && num.negative === 0) {
  27210. this.negative = 0;
  27211. r = this.isub(num);
  27212. this.negative ^= 1;
  27213. return this._normSign(); // positive + negative
  27214. } else if (this.negative === 0 && num.negative !== 0) {
  27215. num.negative = 0;
  27216. r = this.isub(num);
  27217. num.negative = 1;
  27218. return r._normSign();
  27219. } // a.length > b.length
  27220. var a, b;
  27221. if (this.length > num.length) {
  27222. a = this;
  27223. b = num;
  27224. } else {
  27225. a = num;
  27226. b = this;
  27227. }
  27228. var carry = 0;
  27229. for (var i = 0; i < b.length; i++) {
  27230. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  27231. this.words[i] = r & 0x3ffffff;
  27232. carry = r >>> 26;
  27233. }
  27234. for (; carry !== 0 && i < a.length; i++) {
  27235. r = (a.words[i] | 0) + carry;
  27236. this.words[i] = r & 0x3ffffff;
  27237. carry = r >>> 26;
  27238. }
  27239. this.length = a.length;
  27240. if (carry !== 0) {
  27241. this.words[this.length] = carry;
  27242. this.length++; // Copy the rest of the words
  27243. } else if (a !== this) {
  27244. for (; i < a.length; i++) {
  27245. this.words[i] = a.words[i];
  27246. }
  27247. }
  27248. return this;
  27249. }; // Add `num` to `this`
  27250. BN.prototype.add = function add(num) {
  27251. var res;
  27252. if (num.negative !== 0 && this.negative === 0) {
  27253. num.negative = 0;
  27254. res = this.sub(num);
  27255. num.negative ^= 1;
  27256. return res;
  27257. } else if (num.negative === 0 && this.negative !== 0) {
  27258. this.negative = 0;
  27259. res = num.sub(this);
  27260. this.negative = 1;
  27261. return res;
  27262. }
  27263. if (this.length > num.length) return this.clone().iadd(num);
  27264. return num.clone().iadd(this);
  27265. }; // Subtract `num` from `this` in-place
  27266. BN.prototype.isub = function isub(num) {
  27267. // this - (-num) = this + num
  27268. if (num.negative !== 0) {
  27269. num.negative = 0;
  27270. var r = this.iadd(num);
  27271. num.negative = 1;
  27272. return r._normSign(); // -this - num = -(this + num)
  27273. } else if (this.negative !== 0) {
  27274. this.negative = 0;
  27275. this.iadd(num);
  27276. this.negative = 1;
  27277. return this._normSign();
  27278. } // At this point both numbers are positive
  27279. var cmp = this.cmp(num); // Optimization - zeroify
  27280. if (cmp === 0) {
  27281. this.negative = 0;
  27282. this.length = 1;
  27283. this.words[0] = 0;
  27284. return this;
  27285. } // a > b
  27286. var a, b;
  27287. if (cmp > 0) {
  27288. a = this;
  27289. b = num;
  27290. } else {
  27291. a = num;
  27292. b = this;
  27293. }
  27294. var carry = 0;
  27295. for (var i = 0; i < b.length; i++) {
  27296. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  27297. carry = r >> 26;
  27298. this.words[i] = r & 0x3ffffff;
  27299. }
  27300. for (; carry !== 0 && i < a.length; i++) {
  27301. r = (a.words[i] | 0) + carry;
  27302. carry = r >> 26;
  27303. this.words[i] = r & 0x3ffffff;
  27304. } // Copy rest of the words
  27305. if (carry === 0 && i < a.length && a !== this) {
  27306. for (; i < a.length; i++) {
  27307. this.words[i] = a.words[i];
  27308. }
  27309. }
  27310. this.length = Math.max(this.length, i);
  27311. if (a !== this) {
  27312. this.negative = 1;
  27313. }
  27314. return this._strip();
  27315. }; // Subtract `num` from `this`
  27316. BN.prototype.sub = function sub(num) {
  27317. return this.clone().isub(num);
  27318. };
  27319. function smallMulTo(self, num, out) {
  27320. out.negative = num.negative ^ self.negative;
  27321. var len = self.length + num.length | 0;
  27322. out.length = len;
  27323. len = len - 1 | 0; // Peel one iteration (compiler can't do it, because of code complexity)
  27324. var a = self.words[0] | 0;
  27325. var b = num.words[0] | 0;
  27326. var r = a * b;
  27327. var lo = r & 0x3ffffff;
  27328. var carry = r / 0x4000000 | 0;
  27329. out.words[0] = lo;
  27330. for (var k = 1; k < len; k++) {
  27331. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  27332. // note that ncarry could be >= 0x3ffffff
  27333. var ncarry = carry >>> 26;
  27334. var rword = carry & 0x3ffffff;
  27335. var maxJ = Math.min(k, num.length - 1);
  27336. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  27337. var i = k - j | 0;
  27338. a = self.words[i] | 0;
  27339. b = num.words[j] | 0;
  27340. r = a * b + rword;
  27341. ncarry += r / 0x4000000 | 0;
  27342. rword = r & 0x3ffffff;
  27343. }
  27344. out.words[k] = rword | 0;
  27345. carry = ncarry | 0;
  27346. }
  27347. if (carry !== 0) {
  27348. out.words[k] = carry | 0;
  27349. } else {
  27350. out.length--;
  27351. }
  27352. return out._strip();
  27353. } // TODO(indutny): it may be reasonable to omit it for users who don't need
  27354. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  27355. // multiplication (like elliptic secp256k1).
  27356. var comb10MulTo = function comb10MulTo(self, num, out) {
  27357. var a = self.words;
  27358. var b = num.words;
  27359. var o = out.words;
  27360. var c = 0;
  27361. var lo;
  27362. var mid;
  27363. var hi;
  27364. var a0 = a[0] | 0;
  27365. var al0 = a0 & 0x1fff;
  27366. var ah0 = a0 >>> 13;
  27367. var a1 = a[1] | 0;
  27368. var al1 = a1 & 0x1fff;
  27369. var ah1 = a1 >>> 13;
  27370. var a2 = a[2] | 0;
  27371. var al2 = a2 & 0x1fff;
  27372. var ah2 = a2 >>> 13;
  27373. var a3 = a[3] | 0;
  27374. var al3 = a3 & 0x1fff;
  27375. var ah3 = a3 >>> 13;
  27376. var a4 = a[4] | 0;
  27377. var al4 = a4 & 0x1fff;
  27378. var ah4 = a4 >>> 13;
  27379. var a5 = a[5] | 0;
  27380. var al5 = a5 & 0x1fff;
  27381. var ah5 = a5 >>> 13;
  27382. var a6 = a[6] | 0;
  27383. var al6 = a6 & 0x1fff;
  27384. var ah6 = a6 >>> 13;
  27385. var a7 = a[7] | 0;
  27386. var al7 = a7 & 0x1fff;
  27387. var ah7 = a7 >>> 13;
  27388. var a8 = a[8] | 0;
  27389. var al8 = a8 & 0x1fff;
  27390. var ah8 = a8 >>> 13;
  27391. var a9 = a[9] | 0;
  27392. var al9 = a9 & 0x1fff;
  27393. var ah9 = a9 >>> 13;
  27394. var b0 = b[0] | 0;
  27395. var bl0 = b0 & 0x1fff;
  27396. var bh0 = b0 >>> 13;
  27397. var b1 = b[1] | 0;
  27398. var bl1 = b1 & 0x1fff;
  27399. var bh1 = b1 >>> 13;
  27400. var b2 = b[2] | 0;
  27401. var bl2 = b2 & 0x1fff;
  27402. var bh2 = b2 >>> 13;
  27403. var b3 = b[3] | 0;
  27404. var bl3 = b3 & 0x1fff;
  27405. var bh3 = b3 >>> 13;
  27406. var b4 = b[4] | 0;
  27407. var bl4 = b4 & 0x1fff;
  27408. var bh4 = b4 >>> 13;
  27409. var b5 = b[5] | 0;
  27410. var bl5 = b5 & 0x1fff;
  27411. var bh5 = b5 >>> 13;
  27412. var b6 = b[6] | 0;
  27413. var bl6 = b6 & 0x1fff;
  27414. var bh6 = b6 >>> 13;
  27415. var b7 = b[7] | 0;
  27416. var bl7 = b7 & 0x1fff;
  27417. var bh7 = b7 >>> 13;
  27418. var b8 = b[8] | 0;
  27419. var bl8 = b8 & 0x1fff;
  27420. var bh8 = b8 >>> 13;
  27421. var b9 = b[9] | 0;
  27422. var bl9 = b9 & 0x1fff;
  27423. var bh9 = b9 >>> 13;
  27424. out.negative = self.negative ^ num.negative;
  27425. out.length = 19;
  27426. /* k = 0 */
  27427. lo = Math.imul(al0, bl0);
  27428. mid = Math.imul(al0, bh0);
  27429. mid = mid + Math.imul(ah0, bl0) | 0;
  27430. hi = Math.imul(ah0, bh0);
  27431. var w0 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27432. c = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0;
  27433. w0 &= 0x3ffffff;
  27434. /* k = 1 */
  27435. lo = Math.imul(al1, bl0);
  27436. mid = Math.imul(al1, bh0);
  27437. mid = mid + Math.imul(ah1, bl0) | 0;
  27438. hi = Math.imul(ah1, bh0);
  27439. lo = lo + Math.imul(al0, bl1) | 0;
  27440. mid = mid + Math.imul(al0, bh1) | 0;
  27441. mid = mid + Math.imul(ah0, bl1) | 0;
  27442. hi = hi + Math.imul(ah0, bh1) | 0;
  27443. var w1 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27444. c = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0;
  27445. w1 &= 0x3ffffff;
  27446. /* k = 2 */
  27447. lo = Math.imul(al2, bl0);
  27448. mid = Math.imul(al2, bh0);
  27449. mid = mid + Math.imul(ah2, bl0) | 0;
  27450. hi = Math.imul(ah2, bh0);
  27451. lo = lo + Math.imul(al1, bl1) | 0;
  27452. mid = mid + Math.imul(al1, bh1) | 0;
  27453. mid = mid + Math.imul(ah1, bl1) | 0;
  27454. hi = hi + Math.imul(ah1, bh1) | 0;
  27455. lo = lo + Math.imul(al0, bl2) | 0;
  27456. mid = mid + Math.imul(al0, bh2) | 0;
  27457. mid = mid + Math.imul(ah0, bl2) | 0;
  27458. hi = hi + Math.imul(ah0, bh2) | 0;
  27459. var w2 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27460. c = (hi + (mid >>> 13) | 0) + (w2 >>> 26) | 0;
  27461. w2 &= 0x3ffffff;
  27462. /* k = 3 */
  27463. lo = Math.imul(al3, bl0);
  27464. mid = Math.imul(al3, bh0);
  27465. mid = mid + Math.imul(ah3, bl0) | 0;
  27466. hi = Math.imul(ah3, bh0);
  27467. lo = lo + Math.imul(al2, bl1) | 0;
  27468. mid = mid + Math.imul(al2, bh1) | 0;
  27469. mid = mid + Math.imul(ah2, bl1) | 0;
  27470. hi = hi + Math.imul(ah2, bh1) | 0;
  27471. lo = lo + Math.imul(al1, bl2) | 0;
  27472. mid = mid + Math.imul(al1, bh2) | 0;
  27473. mid = mid + Math.imul(ah1, bl2) | 0;
  27474. hi = hi + Math.imul(ah1, bh2) | 0;
  27475. lo = lo + Math.imul(al0, bl3) | 0;
  27476. mid = mid + Math.imul(al0, bh3) | 0;
  27477. mid = mid + Math.imul(ah0, bl3) | 0;
  27478. hi = hi + Math.imul(ah0, bh3) | 0;
  27479. var w3 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27480. c = (hi + (mid >>> 13) | 0) + (w3 >>> 26) | 0;
  27481. w3 &= 0x3ffffff;
  27482. /* k = 4 */
  27483. lo = Math.imul(al4, bl0);
  27484. mid = Math.imul(al4, bh0);
  27485. mid = mid + Math.imul(ah4, bl0) | 0;
  27486. hi = Math.imul(ah4, bh0);
  27487. lo = lo + Math.imul(al3, bl1) | 0;
  27488. mid = mid + Math.imul(al3, bh1) | 0;
  27489. mid = mid + Math.imul(ah3, bl1) | 0;
  27490. hi = hi + Math.imul(ah3, bh1) | 0;
  27491. lo = lo + Math.imul(al2, bl2) | 0;
  27492. mid = mid + Math.imul(al2, bh2) | 0;
  27493. mid = mid + Math.imul(ah2, bl2) | 0;
  27494. hi = hi + Math.imul(ah2, bh2) | 0;
  27495. lo = lo + Math.imul(al1, bl3) | 0;
  27496. mid = mid + Math.imul(al1, bh3) | 0;
  27497. mid = mid + Math.imul(ah1, bl3) | 0;
  27498. hi = hi + Math.imul(ah1, bh3) | 0;
  27499. lo = lo + Math.imul(al0, bl4) | 0;
  27500. mid = mid + Math.imul(al0, bh4) | 0;
  27501. mid = mid + Math.imul(ah0, bl4) | 0;
  27502. hi = hi + Math.imul(ah0, bh4) | 0;
  27503. var w4 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27504. c = (hi + (mid >>> 13) | 0) + (w4 >>> 26) | 0;
  27505. w4 &= 0x3ffffff;
  27506. /* k = 5 */
  27507. lo = Math.imul(al5, bl0);
  27508. mid = Math.imul(al5, bh0);
  27509. mid = mid + Math.imul(ah5, bl0) | 0;
  27510. hi = Math.imul(ah5, bh0);
  27511. lo = lo + Math.imul(al4, bl1) | 0;
  27512. mid = mid + Math.imul(al4, bh1) | 0;
  27513. mid = mid + Math.imul(ah4, bl1) | 0;
  27514. hi = hi + Math.imul(ah4, bh1) | 0;
  27515. lo = lo + Math.imul(al3, bl2) | 0;
  27516. mid = mid + Math.imul(al3, bh2) | 0;
  27517. mid = mid + Math.imul(ah3, bl2) | 0;
  27518. hi = hi + Math.imul(ah3, bh2) | 0;
  27519. lo = lo + Math.imul(al2, bl3) | 0;
  27520. mid = mid + Math.imul(al2, bh3) | 0;
  27521. mid = mid + Math.imul(ah2, bl3) | 0;
  27522. hi = hi + Math.imul(ah2, bh3) | 0;
  27523. lo = lo + Math.imul(al1, bl4) | 0;
  27524. mid = mid + Math.imul(al1, bh4) | 0;
  27525. mid = mid + Math.imul(ah1, bl4) | 0;
  27526. hi = hi + Math.imul(ah1, bh4) | 0;
  27527. lo = lo + Math.imul(al0, bl5) | 0;
  27528. mid = mid + Math.imul(al0, bh5) | 0;
  27529. mid = mid + Math.imul(ah0, bl5) | 0;
  27530. hi = hi + Math.imul(ah0, bh5) | 0;
  27531. var w5 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27532. c = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0;
  27533. w5 &= 0x3ffffff;
  27534. /* k = 6 */
  27535. lo = Math.imul(al6, bl0);
  27536. mid = Math.imul(al6, bh0);
  27537. mid = mid + Math.imul(ah6, bl0) | 0;
  27538. hi = Math.imul(ah6, bh0);
  27539. lo = lo + Math.imul(al5, bl1) | 0;
  27540. mid = mid + Math.imul(al5, bh1) | 0;
  27541. mid = mid + Math.imul(ah5, bl1) | 0;
  27542. hi = hi + Math.imul(ah5, bh1) | 0;
  27543. lo = lo + Math.imul(al4, bl2) | 0;
  27544. mid = mid + Math.imul(al4, bh2) | 0;
  27545. mid = mid + Math.imul(ah4, bl2) | 0;
  27546. hi = hi + Math.imul(ah4, bh2) | 0;
  27547. lo = lo + Math.imul(al3, bl3) | 0;
  27548. mid = mid + Math.imul(al3, bh3) | 0;
  27549. mid = mid + Math.imul(ah3, bl3) | 0;
  27550. hi = hi + Math.imul(ah3, bh3) | 0;
  27551. lo = lo + Math.imul(al2, bl4) | 0;
  27552. mid = mid + Math.imul(al2, bh4) | 0;
  27553. mid = mid + Math.imul(ah2, bl4) | 0;
  27554. hi = hi + Math.imul(ah2, bh4) | 0;
  27555. lo = lo + Math.imul(al1, bl5) | 0;
  27556. mid = mid + Math.imul(al1, bh5) | 0;
  27557. mid = mid + Math.imul(ah1, bl5) | 0;
  27558. hi = hi + Math.imul(ah1, bh5) | 0;
  27559. lo = lo + Math.imul(al0, bl6) | 0;
  27560. mid = mid + Math.imul(al0, bh6) | 0;
  27561. mid = mid + Math.imul(ah0, bl6) | 0;
  27562. hi = hi + Math.imul(ah0, bh6) | 0;
  27563. var w6 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27564. c = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0;
  27565. w6 &= 0x3ffffff;
  27566. /* k = 7 */
  27567. lo = Math.imul(al7, bl0);
  27568. mid = Math.imul(al7, bh0);
  27569. mid = mid + Math.imul(ah7, bl0) | 0;
  27570. hi = Math.imul(ah7, bh0);
  27571. lo = lo + Math.imul(al6, bl1) | 0;
  27572. mid = mid + Math.imul(al6, bh1) | 0;
  27573. mid = mid + Math.imul(ah6, bl1) | 0;
  27574. hi = hi + Math.imul(ah6, bh1) | 0;
  27575. lo = lo + Math.imul(al5, bl2) | 0;
  27576. mid = mid + Math.imul(al5, bh2) | 0;
  27577. mid = mid + Math.imul(ah5, bl2) | 0;
  27578. hi = hi + Math.imul(ah5, bh2) | 0;
  27579. lo = lo + Math.imul(al4, bl3) | 0;
  27580. mid = mid + Math.imul(al4, bh3) | 0;
  27581. mid = mid + Math.imul(ah4, bl3) | 0;
  27582. hi = hi + Math.imul(ah4, bh3) | 0;
  27583. lo = lo + Math.imul(al3, bl4) | 0;
  27584. mid = mid + Math.imul(al3, bh4) | 0;
  27585. mid = mid + Math.imul(ah3, bl4) | 0;
  27586. hi = hi + Math.imul(ah3, bh4) | 0;
  27587. lo = lo + Math.imul(al2, bl5) | 0;
  27588. mid = mid + Math.imul(al2, bh5) | 0;
  27589. mid = mid + Math.imul(ah2, bl5) | 0;
  27590. hi = hi + Math.imul(ah2, bh5) | 0;
  27591. lo = lo + Math.imul(al1, bl6) | 0;
  27592. mid = mid + Math.imul(al1, bh6) | 0;
  27593. mid = mid + Math.imul(ah1, bl6) | 0;
  27594. hi = hi + Math.imul(ah1, bh6) | 0;
  27595. lo = lo + Math.imul(al0, bl7) | 0;
  27596. mid = mid + Math.imul(al0, bh7) | 0;
  27597. mid = mid + Math.imul(ah0, bl7) | 0;
  27598. hi = hi + Math.imul(ah0, bh7) | 0;
  27599. var w7 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27600. c = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0;
  27601. w7 &= 0x3ffffff;
  27602. /* k = 8 */
  27603. lo = Math.imul(al8, bl0);
  27604. mid = Math.imul(al8, bh0);
  27605. mid = mid + Math.imul(ah8, bl0) | 0;
  27606. hi = Math.imul(ah8, bh0);
  27607. lo = lo + Math.imul(al7, bl1) | 0;
  27608. mid = mid + Math.imul(al7, bh1) | 0;
  27609. mid = mid + Math.imul(ah7, bl1) | 0;
  27610. hi = hi + Math.imul(ah7, bh1) | 0;
  27611. lo = lo + Math.imul(al6, bl2) | 0;
  27612. mid = mid + Math.imul(al6, bh2) | 0;
  27613. mid = mid + Math.imul(ah6, bl2) | 0;
  27614. hi = hi + Math.imul(ah6, bh2) | 0;
  27615. lo = lo + Math.imul(al5, bl3) | 0;
  27616. mid = mid + Math.imul(al5, bh3) | 0;
  27617. mid = mid + Math.imul(ah5, bl3) | 0;
  27618. hi = hi + Math.imul(ah5, bh3) | 0;
  27619. lo = lo + Math.imul(al4, bl4) | 0;
  27620. mid = mid + Math.imul(al4, bh4) | 0;
  27621. mid = mid + Math.imul(ah4, bl4) | 0;
  27622. hi = hi + Math.imul(ah4, bh4) | 0;
  27623. lo = lo + Math.imul(al3, bl5) | 0;
  27624. mid = mid + Math.imul(al3, bh5) | 0;
  27625. mid = mid + Math.imul(ah3, bl5) | 0;
  27626. hi = hi + Math.imul(ah3, bh5) | 0;
  27627. lo = lo + Math.imul(al2, bl6) | 0;
  27628. mid = mid + Math.imul(al2, bh6) | 0;
  27629. mid = mid + Math.imul(ah2, bl6) | 0;
  27630. hi = hi + Math.imul(ah2, bh6) | 0;
  27631. lo = lo + Math.imul(al1, bl7) | 0;
  27632. mid = mid + Math.imul(al1, bh7) | 0;
  27633. mid = mid + Math.imul(ah1, bl7) | 0;
  27634. hi = hi + Math.imul(ah1, bh7) | 0;
  27635. lo = lo + Math.imul(al0, bl8) | 0;
  27636. mid = mid + Math.imul(al0, bh8) | 0;
  27637. mid = mid + Math.imul(ah0, bl8) | 0;
  27638. hi = hi + Math.imul(ah0, bh8) | 0;
  27639. var w8 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27640. c = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0;
  27641. w8 &= 0x3ffffff;
  27642. /* k = 9 */
  27643. lo = Math.imul(al9, bl0);
  27644. mid = Math.imul(al9, bh0);
  27645. mid = mid + Math.imul(ah9, bl0) | 0;
  27646. hi = Math.imul(ah9, bh0);
  27647. lo = lo + Math.imul(al8, bl1) | 0;
  27648. mid = mid + Math.imul(al8, bh1) | 0;
  27649. mid = mid + Math.imul(ah8, bl1) | 0;
  27650. hi = hi + Math.imul(ah8, bh1) | 0;
  27651. lo = lo + Math.imul(al7, bl2) | 0;
  27652. mid = mid + Math.imul(al7, bh2) | 0;
  27653. mid = mid + Math.imul(ah7, bl2) | 0;
  27654. hi = hi + Math.imul(ah7, bh2) | 0;
  27655. lo = lo + Math.imul(al6, bl3) | 0;
  27656. mid = mid + Math.imul(al6, bh3) | 0;
  27657. mid = mid + Math.imul(ah6, bl3) | 0;
  27658. hi = hi + Math.imul(ah6, bh3) | 0;
  27659. lo = lo + Math.imul(al5, bl4) | 0;
  27660. mid = mid + Math.imul(al5, bh4) | 0;
  27661. mid = mid + Math.imul(ah5, bl4) | 0;
  27662. hi = hi + Math.imul(ah5, bh4) | 0;
  27663. lo = lo + Math.imul(al4, bl5) | 0;
  27664. mid = mid + Math.imul(al4, bh5) | 0;
  27665. mid = mid + Math.imul(ah4, bl5) | 0;
  27666. hi = hi + Math.imul(ah4, bh5) | 0;
  27667. lo = lo + Math.imul(al3, bl6) | 0;
  27668. mid = mid + Math.imul(al3, bh6) | 0;
  27669. mid = mid + Math.imul(ah3, bl6) | 0;
  27670. hi = hi + Math.imul(ah3, bh6) | 0;
  27671. lo = lo + Math.imul(al2, bl7) | 0;
  27672. mid = mid + Math.imul(al2, bh7) | 0;
  27673. mid = mid + Math.imul(ah2, bl7) | 0;
  27674. hi = hi + Math.imul(ah2, bh7) | 0;
  27675. lo = lo + Math.imul(al1, bl8) | 0;
  27676. mid = mid + Math.imul(al1, bh8) | 0;
  27677. mid = mid + Math.imul(ah1, bl8) | 0;
  27678. hi = hi + Math.imul(ah1, bh8) | 0;
  27679. lo = lo + Math.imul(al0, bl9) | 0;
  27680. mid = mid + Math.imul(al0, bh9) | 0;
  27681. mid = mid + Math.imul(ah0, bl9) | 0;
  27682. hi = hi + Math.imul(ah0, bh9) | 0;
  27683. var w9 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27684. c = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0;
  27685. w9 &= 0x3ffffff;
  27686. /* k = 10 */
  27687. lo = Math.imul(al9, bl1);
  27688. mid = Math.imul(al9, bh1);
  27689. mid = mid + Math.imul(ah9, bl1) | 0;
  27690. hi = Math.imul(ah9, bh1);
  27691. lo = lo + Math.imul(al8, bl2) | 0;
  27692. mid = mid + Math.imul(al8, bh2) | 0;
  27693. mid = mid + Math.imul(ah8, bl2) | 0;
  27694. hi = hi + Math.imul(ah8, bh2) | 0;
  27695. lo = lo + Math.imul(al7, bl3) | 0;
  27696. mid = mid + Math.imul(al7, bh3) | 0;
  27697. mid = mid + Math.imul(ah7, bl3) | 0;
  27698. hi = hi + Math.imul(ah7, bh3) | 0;
  27699. lo = lo + Math.imul(al6, bl4) | 0;
  27700. mid = mid + Math.imul(al6, bh4) | 0;
  27701. mid = mid + Math.imul(ah6, bl4) | 0;
  27702. hi = hi + Math.imul(ah6, bh4) | 0;
  27703. lo = lo + Math.imul(al5, bl5) | 0;
  27704. mid = mid + Math.imul(al5, bh5) | 0;
  27705. mid = mid + Math.imul(ah5, bl5) | 0;
  27706. hi = hi + Math.imul(ah5, bh5) | 0;
  27707. lo = lo + Math.imul(al4, bl6) | 0;
  27708. mid = mid + Math.imul(al4, bh6) | 0;
  27709. mid = mid + Math.imul(ah4, bl6) | 0;
  27710. hi = hi + Math.imul(ah4, bh6) | 0;
  27711. lo = lo + Math.imul(al3, bl7) | 0;
  27712. mid = mid + Math.imul(al3, bh7) | 0;
  27713. mid = mid + Math.imul(ah3, bl7) | 0;
  27714. hi = hi + Math.imul(ah3, bh7) | 0;
  27715. lo = lo + Math.imul(al2, bl8) | 0;
  27716. mid = mid + Math.imul(al2, bh8) | 0;
  27717. mid = mid + Math.imul(ah2, bl8) | 0;
  27718. hi = hi + Math.imul(ah2, bh8) | 0;
  27719. lo = lo + Math.imul(al1, bl9) | 0;
  27720. mid = mid + Math.imul(al1, bh9) | 0;
  27721. mid = mid + Math.imul(ah1, bl9) | 0;
  27722. hi = hi + Math.imul(ah1, bh9) | 0;
  27723. var w10 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27724. c = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0;
  27725. w10 &= 0x3ffffff;
  27726. /* k = 11 */
  27727. lo = Math.imul(al9, bl2);
  27728. mid = Math.imul(al9, bh2);
  27729. mid = mid + Math.imul(ah9, bl2) | 0;
  27730. hi = Math.imul(ah9, bh2);
  27731. lo = lo + Math.imul(al8, bl3) | 0;
  27732. mid = mid + Math.imul(al8, bh3) | 0;
  27733. mid = mid + Math.imul(ah8, bl3) | 0;
  27734. hi = hi + Math.imul(ah8, bh3) | 0;
  27735. lo = lo + Math.imul(al7, bl4) | 0;
  27736. mid = mid + Math.imul(al7, bh4) | 0;
  27737. mid = mid + Math.imul(ah7, bl4) | 0;
  27738. hi = hi + Math.imul(ah7, bh4) | 0;
  27739. lo = lo + Math.imul(al6, bl5) | 0;
  27740. mid = mid + Math.imul(al6, bh5) | 0;
  27741. mid = mid + Math.imul(ah6, bl5) | 0;
  27742. hi = hi + Math.imul(ah6, bh5) | 0;
  27743. lo = lo + Math.imul(al5, bl6) | 0;
  27744. mid = mid + Math.imul(al5, bh6) | 0;
  27745. mid = mid + Math.imul(ah5, bl6) | 0;
  27746. hi = hi + Math.imul(ah5, bh6) | 0;
  27747. lo = lo + Math.imul(al4, bl7) | 0;
  27748. mid = mid + Math.imul(al4, bh7) | 0;
  27749. mid = mid + Math.imul(ah4, bl7) | 0;
  27750. hi = hi + Math.imul(ah4, bh7) | 0;
  27751. lo = lo + Math.imul(al3, bl8) | 0;
  27752. mid = mid + Math.imul(al3, bh8) | 0;
  27753. mid = mid + Math.imul(ah3, bl8) | 0;
  27754. hi = hi + Math.imul(ah3, bh8) | 0;
  27755. lo = lo + Math.imul(al2, bl9) | 0;
  27756. mid = mid + Math.imul(al2, bh9) | 0;
  27757. mid = mid + Math.imul(ah2, bl9) | 0;
  27758. hi = hi + Math.imul(ah2, bh9) | 0;
  27759. var w11 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27760. c = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0;
  27761. w11 &= 0x3ffffff;
  27762. /* k = 12 */
  27763. lo = Math.imul(al9, bl3);
  27764. mid = Math.imul(al9, bh3);
  27765. mid = mid + Math.imul(ah9, bl3) | 0;
  27766. hi = Math.imul(ah9, bh3);
  27767. lo = lo + Math.imul(al8, bl4) | 0;
  27768. mid = mid + Math.imul(al8, bh4) | 0;
  27769. mid = mid + Math.imul(ah8, bl4) | 0;
  27770. hi = hi + Math.imul(ah8, bh4) | 0;
  27771. lo = lo + Math.imul(al7, bl5) | 0;
  27772. mid = mid + Math.imul(al7, bh5) | 0;
  27773. mid = mid + Math.imul(ah7, bl5) | 0;
  27774. hi = hi + Math.imul(ah7, bh5) | 0;
  27775. lo = lo + Math.imul(al6, bl6) | 0;
  27776. mid = mid + Math.imul(al6, bh6) | 0;
  27777. mid = mid + Math.imul(ah6, bl6) | 0;
  27778. hi = hi + Math.imul(ah6, bh6) | 0;
  27779. lo = lo + Math.imul(al5, bl7) | 0;
  27780. mid = mid + Math.imul(al5, bh7) | 0;
  27781. mid = mid + Math.imul(ah5, bl7) | 0;
  27782. hi = hi + Math.imul(ah5, bh7) | 0;
  27783. lo = lo + Math.imul(al4, bl8) | 0;
  27784. mid = mid + Math.imul(al4, bh8) | 0;
  27785. mid = mid + Math.imul(ah4, bl8) | 0;
  27786. hi = hi + Math.imul(ah4, bh8) | 0;
  27787. lo = lo + Math.imul(al3, bl9) | 0;
  27788. mid = mid + Math.imul(al3, bh9) | 0;
  27789. mid = mid + Math.imul(ah3, bl9) | 0;
  27790. hi = hi + Math.imul(ah3, bh9) | 0;
  27791. var w12 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27792. c = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0;
  27793. w12 &= 0x3ffffff;
  27794. /* k = 13 */
  27795. lo = Math.imul(al9, bl4);
  27796. mid = Math.imul(al9, bh4);
  27797. mid = mid + Math.imul(ah9, bl4) | 0;
  27798. hi = Math.imul(ah9, bh4);
  27799. lo = lo + Math.imul(al8, bl5) | 0;
  27800. mid = mid + Math.imul(al8, bh5) | 0;
  27801. mid = mid + Math.imul(ah8, bl5) | 0;
  27802. hi = hi + Math.imul(ah8, bh5) | 0;
  27803. lo = lo + Math.imul(al7, bl6) | 0;
  27804. mid = mid + Math.imul(al7, bh6) | 0;
  27805. mid = mid + Math.imul(ah7, bl6) | 0;
  27806. hi = hi + Math.imul(ah7, bh6) | 0;
  27807. lo = lo + Math.imul(al6, bl7) | 0;
  27808. mid = mid + Math.imul(al6, bh7) | 0;
  27809. mid = mid + Math.imul(ah6, bl7) | 0;
  27810. hi = hi + Math.imul(ah6, bh7) | 0;
  27811. lo = lo + Math.imul(al5, bl8) | 0;
  27812. mid = mid + Math.imul(al5, bh8) | 0;
  27813. mid = mid + Math.imul(ah5, bl8) | 0;
  27814. hi = hi + Math.imul(ah5, bh8) | 0;
  27815. lo = lo + Math.imul(al4, bl9) | 0;
  27816. mid = mid + Math.imul(al4, bh9) | 0;
  27817. mid = mid + Math.imul(ah4, bl9) | 0;
  27818. hi = hi + Math.imul(ah4, bh9) | 0;
  27819. var w13 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27820. c = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0;
  27821. w13 &= 0x3ffffff;
  27822. /* k = 14 */
  27823. lo = Math.imul(al9, bl5);
  27824. mid = Math.imul(al9, bh5);
  27825. mid = mid + Math.imul(ah9, bl5) | 0;
  27826. hi = Math.imul(ah9, bh5);
  27827. lo = lo + Math.imul(al8, bl6) | 0;
  27828. mid = mid + Math.imul(al8, bh6) | 0;
  27829. mid = mid + Math.imul(ah8, bl6) | 0;
  27830. hi = hi + Math.imul(ah8, bh6) | 0;
  27831. lo = lo + Math.imul(al7, bl7) | 0;
  27832. mid = mid + Math.imul(al7, bh7) | 0;
  27833. mid = mid + Math.imul(ah7, bl7) | 0;
  27834. hi = hi + Math.imul(ah7, bh7) | 0;
  27835. lo = lo + Math.imul(al6, bl8) | 0;
  27836. mid = mid + Math.imul(al6, bh8) | 0;
  27837. mid = mid + Math.imul(ah6, bl8) | 0;
  27838. hi = hi + Math.imul(ah6, bh8) | 0;
  27839. lo = lo + Math.imul(al5, bl9) | 0;
  27840. mid = mid + Math.imul(al5, bh9) | 0;
  27841. mid = mid + Math.imul(ah5, bl9) | 0;
  27842. hi = hi + Math.imul(ah5, bh9) | 0;
  27843. var w14 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27844. c = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0;
  27845. w14 &= 0x3ffffff;
  27846. /* k = 15 */
  27847. lo = Math.imul(al9, bl6);
  27848. mid = Math.imul(al9, bh6);
  27849. mid = mid + Math.imul(ah9, bl6) | 0;
  27850. hi = Math.imul(ah9, bh6);
  27851. lo = lo + Math.imul(al8, bl7) | 0;
  27852. mid = mid + Math.imul(al8, bh7) | 0;
  27853. mid = mid + Math.imul(ah8, bl7) | 0;
  27854. hi = hi + Math.imul(ah8, bh7) | 0;
  27855. lo = lo + Math.imul(al7, bl8) | 0;
  27856. mid = mid + Math.imul(al7, bh8) | 0;
  27857. mid = mid + Math.imul(ah7, bl8) | 0;
  27858. hi = hi + Math.imul(ah7, bh8) | 0;
  27859. lo = lo + Math.imul(al6, bl9) | 0;
  27860. mid = mid + Math.imul(al6, bh9) | 0;
  27861. mid = mid + Math.imul(ah6, bl9) | 0;
  27862. hi = hi + Math.imul(ah6, bh9) | 0;
  27863. var w15 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27864. c = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0;
  27865. w15 &= 0x3ffffff;
  27866. /* k = 16 */
  27867. lo = Math.imul(al9, bl7);
  27868. mid = Math.imul(al9, bh7);
  27869. mid = mid + Math.imul(ah9, bl7) | 0;
  27870. hi = Math.imul(ah9, bh7);
  27871. lo = lo + Math.imul(al8, bl8) | 0;
  27872. mid = mid + Math.imul(al8, bh8) | 0;
  27873. mid = mid + Math.imul(ah8, bl8) | 0;
  27874. hi = hi + Math.imul(ah8, bh8) | 0;
  27875. lo = lo + Math.imul(al7, bl9) | 0;
  27876. mid = mid + Math.imul(al7, bh9) | 0;
  27877. mid = mid + Math.imul(ah7, bl9) | 0;
  27878. hi = hi + Math.imul(ah7, bh9) | 0;
  27879. var w16 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27880. c = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0;
  27881. w16 &= 0x3ffffff;
  27882. /* k = 17 */
  27883. lo = Math.imul(al9, bl8);
  27884. mid = Math.imul(al9, bh8);
  27885. mid = mid + Math.imul(ah9, bl8) | 0;
  27886. hi = Math.imul(ah9, bh8);
  27887. lo = lo + Math.imul(al8, bl9) | 0;
  27888. mid = mid + Math.imul(al8, bh9) | 0;
  27889. mid = mid + Math.imul(ah8, bl9) | 0;
  27890. hi = hi + Math.imul(ah8, bh9) | 0;
  27891. var w17 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27892. c = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0;
  27893. w17 &= 0x3ffffff;
  27894. /* k = 18 */
  27895. lo = Math.imul(al9, bl9);
  27896. mid = Math.imul(al9, bh9);
  27897. mid = mid + Math.imul(ah9, bl9) | 0;
  27898. hi = Math.imul(ah9, bh9);
  27899. var w18 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
  27900. c = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0;
  27901. w18 &= 0x3ffffff;
  27902. o[0] = w0;
  27903. o[1] = w1;
  27904. o[2] = w2;
  27905. o[3] = w3;
  27906. o[4] = w4;
  27907. o[5] = w5;
  27908. o[6] = w6;
  27909. o[7] = w7;
  27910. o[8] = w8;
  27911. o[9] = w9;
  27912. o[10] = w10;
  27913. o[11] = w11;
  27914. o[12] = w12;
  27915. o[13] = w13;
  27916. o[14] = w14;
  27917. o[15] = w15;
  27918. o[16] = w16;
  27919. o[17] = w17;
  27920. o[18] = w18;
  27921. if (c !== 0) {
  27922. o[19] = c;
  27923. out.length++;
  27924. }
  27925. return out;
  27926. }; // Polyfill comb
  27927. if (!Math.imul) {
  27928. comb10MulTo = smallMulTo;
  27929. }
  27930. function bigMulTo(self, num, out) {
  27931. out.negative = num.negative ^ self.negative;
  27932. out.length = self.length + num.length;
  27933. var carry = 0;
  27934. var hncarry = 0;
  27935. for (var k = 0; k < out.length - 1; k++) {
  27936. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  27937. // note that ncarry could be >= 0x3ffffff
  27938. var ncarry = hncarry;
  27939. hncarry = 0;
  27940. var rword = carry & 0x3ffffff;
  27941. var maxJ = Math.min(k, num.length - 1);
  27942. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  27943. var i = k - j;
  27944. var a = self.words[i] | 0;
  27945. var b = num.words[j] | 0;
  27946. var r = a * b;
  27947. var lo = r & 0x3ffffff;
  27948. ncarry = ncarry + (r / 0x4000000 | 0) | 0;
  27949. lo = lo + rword | 0;
  27950. rword = lo & 0x3ffffff;
  27951. ncarry = ncarry + (lo >>> 26) | 0;
  27952. hncarry += ncarry >>> 26;
  27953. ncarry &= 0x3ffffff;
  27954. }
  27955. out.words[k] = rword;
  27956. carry = ncarry;
  27957. ncarry = hncarry;
  27958. }
  27959. if (carry !== 0) {
  27960. out.words[k] = carry;
  27961. } else {
  27962. out.length--;
  27963. }
  27964. return out._strip();
  27965. }
  27966. function jumboMulTo(self, num, out) {
  27967. // Temporary disable, see https://github.com/indutny/bn.js/issues/211
  27968. // var fftm = new FFTM();
  27969. // return fftm.mulp(self, num, out);
  27970. return bigMulTo(self, num, out);
  27971. }
  27972. BN.prototype.mulTo = function mulTo(num, out) {
  27973. var res;
  27974. var len = this.length + num.length;
  27975. if (this.length === 10 && num.length === 10) {
  27976. res = comb10MulTo(this, num, out);
  27977. } else if (len < 63) {
  27978. res = smallMulTo(this, num, out);
  27979. } else if (len < 1024) {
  27980. res = bigMulTo(this, num, out);
  27981. } else {
  27982. res = jumboMulTo(this, num, out);
  27983. }
  27984. return res;
  27985. }; // Cooley-Tukey algorithm for FFT
  27986. // slightly revisited to rely on looping instead of recursion
  27987. function FFTM(x, y) {
  27988. this.x = x;
  27989. this.y = y;
  27990. }
  27991. FFTM.prototype.makeRBT = function makeRBT(N) {
  27992. var t = new Array(N);
  27993. var l = BN.prototype._countBits(N) - 1;
  27994. for (var i = 0; i < N; i++) {
  27995. t[i] = this.revBin(i, l, N);
  27996. }
  27997. return t;
  27998. }; // Returns binary-reversed representation of `x`
  27999. FFTM.prototype.revBin = function revBin(x, l, N) {
  28000. if (x === 0 || x === N - 1) return x;
  28001. var rb = 0;
  28002. for (var i = 0; i < l; i++) {
  28003. rb |= (x & 1) << l - i - 1;
  28004. x >>= 1;
  28005. }
  28006. return rb;
  28007. }; // Performs "tweedling" phase, therefore 'emulating'
  28008. // behaviour of the recursive algorithm
  28009. FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N) {
  28010. for (var i = 0; i < N; i++) {
  28011. rtws[i] = rws[rbt[i]];
  28012. itws[i] = iws[rbt[i]];
  28013. }
  28014. };
  28015. FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N, rbt) {
  28016. this.permute(rbt, rws, iws, rtws, itws, N);
  28017. for (var s = 1; s < N; s <<= 1) {
  28018. var l = s << 1;
  28019. var rtwdf = Math.cos(2 * Math.PI / l);
  28020. var itwdf = Math.sin(2 * Math.PI / l);
  28021. for (var p = 0; p < N; p += l) {
  28022. var rtwdf_ = rtwdf;
  28023. var itwdf_ = itwdf;
  28024. for (var j = 0; j < s; j++) {
  28025. var re = rtws[p + j];
  28026. var ie = itws[p + j];
  28027. var ro = rtws[p + j + s];
  28028. var io = itws[p + j + s];
  28029. var rx = rtwdf_ * ro - itwdf_ * io;
  28030. io = rtwdf_ * io + itwdf_ * ro;
  28031. ro = rx;
  28032. rtws[p + j] = re + ro;
  28033. itws[p + j] = ie + io;
  28034. rtws[p + j + s] = re - ro;
  28035. itws[p + j + s] = ie - io;
  28036. /* jshint maxdepth : false */
  28037. if (j !== l) {
  28038. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  28039. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  28040. rtwdf_ = rx;
  28041. }
  28042. }
  28043. }
  28044. }
  28045. };
  28046. FFTM.prototype.guessLen13b = function guessLen13b(n, m) {
  28047. var N = Math.max(m, n) | 1;
  28048. var odd = N & 1;
  28049. var i = 0;
  28050. for (N = N / 2 | 0; N; N = N >>> 1) {
  28051. i++;
  28052. }
  28053. return 1 << i + 1 + odd;
  28054. };
  28055. FFTM.prototype.conjugate = function conjugate(rws, iws, N) {
  28056. if (N <= 1) return;
  28057. for (var i = 0; i < N / 2; i++) {
  28058. var t = rws[i];
  28059. rws[i] = rws[N - i - 1];
  28060. rws[N - i - 1] = t;
  28061. t = iws[i];
  28062. iws[i] = -iws[N - i - 1];
  28063. iws[N - i - 1] = -t;
  28064. }
  28065. };
  28066. FFTM.prototype.normalize13b = function normalize13b(ws, N) {
  28067. var carry = 0;
  28068. for (var i = 0; i < N / 2; i++) {
  28069. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + Math.round(ws[2 * i] / N) + carry;
  28070. ws[i] = w & 0x3ffffff;
  28071. if (w < 0x4000000) {
  28072. carry = 0;
  28073. } else {
  28074. carry = w / 0x4000000 | 0;
  28075. }
  28076. }
  28077. return ws;
  28078. };
  28079. FFTM.prototype.convert13b = function convert13b(ws, len, rws, N) {
  28080. var carry = 0;
  28081. for (var i = 0; i < len; i++) {
  28082. carry = carry + (ws[i] | 0);
  28083. rws[2 * i] = carry & 0x1fff;
  28084. carry = carry >>> 13;
  28085. rws[2 * i + 1] = carry & 0x1fff;
  28086. carry = carry >>> 13;
  28087. } // Pad with zeroes
  28088. for (i = 2 * len; i < N; ++i) {
  28089. rws[i] = 0;
  28090. }
  28091. assert(carry === 0);
  28092. assert((carry & ~0x1fff) === 0);
  28093. };
  28094. FFTM.prototype.stub = function stub(N) {
  28095. var ph = new Array(N);
  28096. for (var i = 0; i < N; i++) {
  28097. ph[i] = 0;
  28098. }
  28099. return ph;
  28100. };
  28101. FFTM.prototype.mulp = function mulp(x, y, out) {
  28102. var N = 2 * this.guessLen13b(x.length, y.length);
  28103. var rbt = this.makeRBT(N);
  28104. var _ = this.stub(N);
  28105. var rws = new Array(N);
  28106. var rwst = new Array(N);
  28107. var iwst = new Array(N);
  28108. var nrws = new Array(N);
  28109. var nrwst = new Array(N);
  28110. var niwst = new Array(N);
  28111. var rmws = out.words;
  28112. rmws.length = N;
  28113. this.convert13b(x.words, x.length, rws, N);
  28114. this.convert13b(y.words, y.length, nrws, N);
  28115. this.transform(rws, _, rwst, iwst, N, rbt);
  28116. this.transform(nrws, _, nrwst, niwst, N, rbt);
  28117. for (var i = 0; i < N; i++) {
  28118. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  28119. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  28120. rwst[i] = rx;
  28121. }
  28122. this.conjugate(rwst, iwst, N);
  28123. this.transform(rwst, iwst, rmws, _, N, rbt);
  28124. this.conjugate(rmws, _, N);
  28125. this.normalize13b(rmws, N);
  28126. out.negative = x.negative ^ y.negative;
  28127. out.length = x.length + y.length;
  28128. return out._strip();
  28129. }; // Multiply `this` by `num`
  28130. BN.prototype.mul = function mul(num) {
  28131. var out = new BN(null);
  28132. out.words = new Array(this.length + num.length);
  28133. return this.mulTo(num, out);
  28134. }; // Multiply employing FFT
  28135. BN.prototype.mulf = function mulf(num) {
  28136. var out = new BN(null);
  28137. out.words = new Array(this.length + num.length);
  28138. return jumboMulTo(this, num, out);
  28139. }; // In-place Multiplication
  28140. BN.prototype.imul = function imul(num) {
  28141. return this.clone().mulTo(num, this);
  28142. };
  28143. BN.prototype.imuln = function imuln(num) {
  28144. var isNegNum = num < 0;
  28145. if (isNegNum) num = -num;
  28146. assert(typeof num === 'number');
  28147. assert(num < 0x4000000); // Carry
  28148. var carry = 0;
  28149. for (var i = 0; i < this.length; i++) {
  28150. var w = (this.words[i] | 0) * num;
  28151. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  28152. carry >>= 26;
  28153. carry += w / 0x4000000 | 0; // NOTE: lo is 27bit maximum
  28154. carry += lo >>> 26;
  28155. this.words[i] = lo & 0x3ffffff;
  28156. }
  28157. if (carry !== 0) {
  28158. this.words[i] = carry;
  28159. this.length++;
  28160. }
  28161. return isNegNum ? this.ineg() : this;
  28162. };
  28163. BN.prototype.muln = function muln(num) {
  28164. return this.clone().imuln(num);
  28165. }; // `this` * `this`
  28166. BN.prototype.sqr = function sqr() {
  28167. return this.mul(this);
  28168. }; // `this` * `this` in-place
  28169. BN.prototype.isqr = function isqr() {
  28170. return this.imul(this.clone());
  28171. }; // Math.pow(`this`, `num`)
  28172. BN.prototype.pow = function pow(num) {
  28173. var w = toBitArray(num);
  28174. if (w.length === 0) return new BN(1); // Skip leading zeroes
  28175. var res = this;
  28176. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  28177. if (w[i] !== 0) break;
  28178. }
  28179. if (++i < w.length) {
  28180. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  28181. if (w[i] === 0) continue;
  28182. res = res.mul(q);
  28183. }
  28184. }
  28185. return res;
  28186. }; // Shift-left in-place
  28187. BN.prototype.iushln = function iushln(bits) {
  28188. assert(typeof bits === 'number' && bits >= 0);
  28189. var r = bits % 26;
  28190. var s = (bits - r) / 26;
  28191. var carryMask = 0x3ffffff >>> 26 - r << 26 - r;
  28192. var i;
  28193. if (r !== 0) {
  28194. var carry = 0;
  28195. for (i = 0; i < this.length; i++) {
  28196. var newCarry = this.words[i] & carryMask;
  28197. var c = (this.words[i] | 0) - newCarry << r;
  28198. this.words[i] = c | carry;
  28199. carry = newCarry >>> 26 - r;
  28200. }
  28201. if (carry) {
  28202. this.words[i] = carry;
  28203. this.length++;
  28204. }
  28205. }
  28206. if (s !== 0) {
  28207. for (i = this.length - 1; i >= 0; i--) {
  28208. this.words[i + s] = this.words[i];
  28209. }
  28210. for (i = 0; i < s; i++) {
  28211. this.words[i] = 0;
  28212. }
  28213. this.length += s;
  28214. }
  28215. return this._strip();
  28216. };
  28217. BN.prototype.ishln = function ishln(bits) {
  28218. // TODO(indutny): implement me
  28219. assert(this.negative === 0);
  28220. return this.iushln(bits);
  28221. }; // Shift-right in-place
  28222. // NOTE: `hint` is a lowest bit before trailing zeroes
  28223. // NOTE: if `extended` is present - it will be filled with destroyed bits
  28224. BN.prototype.iushrn = function iushrn(bits, hint, extended) {
  28225. assert(typeof bits === 'number' && bits >= 0);
  28226. var h;
  28227. if (hint) {
  28228. h = (hint - hint % 26) / 26;
  28229. } else {
  28230. h = 0;
  28231. }
  28232. var r = bits % 26;
  28233. var s = Math.min((bits - r) / 26, this.length);
  28234. var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;
  28235. var maskedWords = extended;
  28236. h -= s;
  28237. h = Math.max(0, h); // Extended mode, copy masked part
  28238. if (maskedWords) {
  28239. for (var i = 0; i < s; i++) {
  28240. maskedWords.words[i] = this.words[i];
  28241. }
  28242. maskedWords.length = s;
  28243. }
  28244. if (s === 0) {// No-op, we should not move anything at all
  28245. } else if (this.length > s) {
  28246. this.length -= s;
  28247. for (i = 0; i < this.length; i++) {
  28248. this.words[i] = this.words[i + s];
  28249. }
  28250. } else {
  28251. this.words[0] = 0;
  28252. this.length = 1;
  28253. }
  28254. var carry = 0;
  28255. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  28256. var word = this.words[i] | 0;
  28257. this.words[i] = carry << 26 - r | word >>> r;
  28258. carry = word & mask;
  28259. } // Push carried bits as a mask
  28260. if (maskedWords && carry !== 0) {
  28261. maskedWords.words[maskedWords.length++] = carry;
  28262. }
  28263. if (this.length === 0) {
  28264. this.words[0] = 0;
  28265. this.length = 1;
  28266. }
  28267. return this._strip();
  28268. };
  28269. BN.prototype.ishrn = function ishrn(bits, hint, extended) {
  28270. // TODO(indutny): implement me
  28271. assert(this.negative === 0);
  28272. return this.iushrn(bits, hint, extended);
  28273. }; // Shift-left
  28274. BN.prototype.shln = function shln(bits) {
  28275. return this.clone().ishln(bits);
  28276. };
  28277. BN.prototype.ushln = function ushln(bits) {
  28278. return this.clone().iushln(bits);
  28279. }; // Shift-right
  28280. BN.prototype.shrn = function shrn(bits) {
  28281. return this.clone().ishrn(bits);
  28282. };
  28283. BN.prototype.ushrn = function ushrn(bits) {
  28284. return this.clone().iushrn(bits);
  28285. }; // Test if n bit is set
  28286. BN.prototype.testn = function testn(bit) {
  28287. assert(typeof bit === 'number' && bit >= 0);
  28288. var r = bit % 26;
  28289. var s = (bit - r) / 26;
  28290. var q = 1 << r; // Fast case: bit is much higher than all existing words
  28291. if (this.length <= s) return false; // Check bit and return
  28292. var w = this.words[s];
  28293. return !!(w & q);
  28294. }; // Return only lowers bits of number (in-place)
  28295. BN.prototype.imaskn = function imaskn(bits) {
  28296. assert(typeof bits === 'number' && bits >= 0);
  28297. var r = bits % 26;
  28298. var s = (bits - r) / 26;
  28299. assert(this.negative === 0, 'imaskn works only with positive numbers');
  28300. if (this.length <= s) {
  28301. return this;
  28302. }
  28303. if (r !== 0) {
  28304. s++;
  28305. }
  28306. this.length = Math.min(s, this.length);
  28307. if (r !== 0) {
  28308. var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;
  28309. this.words[this.length - 1] &= mask;
  28310. }
  28311. return this._strip();
  28312. }; // Return only lowers bits of number
  28313. BN.prototype.maskn = function maskn(bits) {
  28314. return this.clone().imaskn(bits);
  28315. }; // Add plain number `num` to `this`
  28316. BN.prototype.iaddn = function iaddn(num) {
  28317. assert(typeof num === 'number');
  28318. assert(num < 0x4000000);
  28319. if (num < 0) return this.isubn(-num); // Possible sign change
  28320. if (this.negative !== 0) {
  28321. if (this.length === 1 && (this.words[0] | 0) <= num) {
  28322. this.words[0] = num - (this.words[0] | 0);
  28323. this.negative = 0;
  28324. return this;
  28325. }
  28326. this.negative = 0;
  28327. this.isubn(num);
  28328. this.negative = 1;
  28329. return this;
  28330. } // Add without checks
  28331. return this._iaddn(num);
  28332. };
  28333. BN.prototype._iaddn = function _iaddn(num) {
  28334. this.words[0] += num; // Carry
  28335. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  28336. this.words[i] -= 0x4000000;
  28337. if (i === this.length - 1) {
  28338. this.words[i + 1] = 1;
  28339. } else {
  28340. this.words[i + 1]++;
  28341. }
  28342. }
  28343. this.length = Math.max(this.length, i + 1);
  28344. return this;
  28345. }; // Subtract plain number `num` from `this`
  28346. BN.prototype.isubn = function isubn(num) {
  28347. assert(typeof num === 'number');
  28348. assert(num < 0x4000000);
  28349. if (num < 0) return this.iaddn(-num);
  28350. if (this.negative !== 0) {
  28351. this.negative = 0;
  28352. this.iaddn(num);
  28353. this.negative = 1;
  28354. return this;
  28355. }
  28356. this.words[0] -= num;
  28357. if (this.length === 1 && this.words[0] < 0) {
  28358. this.words[0] = -this.words[0];
  28359. this.negative = 1;
  28360. } else {
  28361. // Carry
  28362. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  28363. this.words[i] += 0x4000000;
  28364. this.words[i + 1] -= 1;
  28365. }
  28366. }
  28367. return this._strip();
  28368. };
  28369. BN.prototype.addn = function addn(num) {
  28370. return this.clone().iaddn(num);
  28371. };
  28372. BN.prototype.subn = function subn(num) {
  28373. return this.clone().isubn(num);
  28374. };
  28375. BN.prototype.iabs = function iabs() {
  28376. this.negative = 0;
  28377. return this;
  28378. };
  28379. BN.prototype.abs = function abs() {
  28380. return this.clone().iabs();
  28381. };
  28382. BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
  28383. var len = num.length + shift;
  28384. var i;
  28385. this._expand(len);
  28386. var w;
  28387. var carry = 0;
  28388. for (i = 0; i < num.length; i++) {
  28389. w = (this.words[i + shift] | 0) + carry;
  28390. var right = (num.words[i] | 0) * mul;
  28391. w -= right & 0x3ffffff;
  28392. carry = (w >> 26) - (right / 0x4000000 | 0);
  28393. this.words[i + shift] = w & 0x3ffffff;
  28394. }
  28395. for (; i < this.length - shift; i++) {
  28396. w = (this.words[i + shift] | 0) + carry;
  28397. carry = w >> 26;
  28398. this.words[i + shift] = w & 0x3ffffff;
  28399. }
  28400. if (carry === 0) return this._strip(); // Subtraction overflow
  28401. assert(carry === -1);
  28402. carry = 0;
  28403. for (i = 0; i < this.length; i++) {
  28404. w = -(this.words[i] | 0) + carry;
  28405. carry = w >> 26;
  28406. this.words[i] = w & 0x3ffffff;
  28407. }
  28408. this.negative = 1;
  28409. return this._strip();
  28410. };
  28411. BN.prototype._wordDiv = function _wordDiv(num, mode) {
  28412. var shift = this.length - num.length;
  28413. var a = this.clone();
  28414. var b = num; // Normalize
  28415. var bhi = b.words[b.length - 1] | 0;
  28416. var bhiBits = this._countBits(bhi);
  28417. shift = 26 - bhiBits;
  28418. if (shift !== 0) {
  28419. b = b.ushln(shift);
  28420. a.iushln(shift);
  28421. bhi = b.words[b.length - 1] | 0;
  28422. } // Initialize quotient
  28423. var m = a.length - b.length;
  28424. var q;
  28425. if (mode !== 'mod') {
  28426. q = new BN(null);
  28427. q.length = m + 1;
  28428. q.words = new Array(q.length);
  28429. for (var i = 0; i < q.length; i++) {
  28430. q.words[i] = 0;
  28431. }
  28432. }
  28433. var diff = a.clone()._ishlnsubmul(b, 1, m);
  28434. if (diff.negative === 0) {
  28435. a = diff;
  28436. if (q) {
  28437. q.words[m] = 1;
  28438. }
  28439. }
  28440. for (var j = m - 1; j >= 0; j--) {
  28441. var qj = (a.words[b.length + j] | 0) * 0x4000000 + (a.words[b.length + j - 1] | 0); // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  28442. // (0x7ffffff)
  28443. qj = Math.min(qj / bhi | 0, 0x3ffffff);
  28444. a._ishlnsubmul(b, qj, j);
  28445. while (a.negative !== 0) {
  28446. qj--;
  28447. a.negative = 0;
  28448. a._ishlnsubmul(b, 1, j);
  28449. if (!a.isZero()) {
  28450. a.negative ^= 1;
  28451. }
  28452. }
  28453. if (q) {
  28454. q.words[j] = qj;
  28455. }
  28456. }
  28457. if (q) {
  28458. q._strip();
  28459. }
  28460. a._strip(); // Denormalize
  28461. if (mode !== 'div' && shift !== 0) {
  28462. a.iushrn(shift);
  28463. }
  28464. return {
  28465. div: q || null,
  28466. mod: a
  28467. };
  28468. }; // NOTE: 1) `mode` can be set to `mod` to request mod only,
  28469. // to `div` to request div only, or be absent to
  28470. // request both div & mod
  28471. // 2) `positive` is true if unsigned mod is requested
  28472. BN.prototype.divmod = function divmod(num, mode, positive) {
  28473. assert(!num.isZero());
  28474. if (this.isZero()) {
  28475. return {
  28476. div: new BN(0),
  28477. mod: new BN(0)
  28478. };
  28479. }
  28480. var div, mod, res;
  28481. if (this.negative !== 0 && num.negative === 0) {
  28482. res = this.neg().divmod(num, mode);
  28483. if (mode !== 'mod') {
  28484. div = res.div.neg();
  28485. }
  28486. if (mode !== 'div') {
  28487. mod = res.mod.neg();
  28488. if (positive && mod.negative !== 0) {
  28489. mod.iadd(num);
  28490. }
  28491. }
  28492. return {
  28493. div: div,
  28494. mod: mod
  28495. };
  28496. }
  28497. if (this.negative === 0 && num.negative !== 0) {
  28498. res = this.divmod(num.neg(), mode);
  28499. if (mode !== 'mod') {
  28500. div = res.div.neg();
  28501. }
  28502. return {
  28503. div: div,
  28504. mod: res.mod
  28505. };
  28506. }
  28507. if ((this.negative & num.negative) !== 0) {
  28508. res = this.neg().divmod(num.neg(), mode);
  28509. if (mode !== 'div') {
  28510. mod = res.mod.neg();
  28511. if (positive && mod.negative !== 0) {
  28512. mod.isub(num);
  28513. }
  28514. }
  28515. return {
  28516. div: res.div,
  28517. mod: mod
  28518. };
  28519. } // Both numbers are positive at this point
  28520. // Strip both numbers to approximate shift value
  28521. if (num.length > this.length || this.cmp(num) < 0) {
  28522. return {
  28523. div: new BN(0),
  28524. mod: this
  28525. };
  28526. } // Very short reduction
  28527. if (num.length === 1) {
  28528. if (mode === 'div') {
  28529. return {
  28530. div: this.divn(num.words[0]),
  28531. mod: null
  28532. };
  28533. }
  28534. if (mode === 'mod') {
  28535. return {
  28536. div: null,
  28537. mod: new BN(this.modrn(num.words[0]))
  28538. };
  28539. }
  28540. return {
  28541. div: this.divn(num.words[0]),
  28542. mod: new BN(this.modrn(num.words[0]))
  28543. };
  28544. }
  28545. return this._wordDiv(num, mode);
  28546. }; // Find `this` / `num`
  28547. BN.prototype.div = function div(num) {
  28548. return this.divmod(num, 'div', false).div;
  28549. }; // Find `this` % `num`
  28550. BN.prototype.mod = function mod(num) {
  28551. return this.divmod(num, 'mod', false).mod;
  28552. };
  28553. BN.prototype.umod = function umod(num) {
  28554. return this.divmod(num, 'mod', true).mod;
  28555. }; // Find Round(`this` / `num`)
  28556. BN.prototype.divRound = function divRound(num) {
  28557. var dm = this.divmod(num); // Fast case - exact division
  28558. if (dm.mod.isZero()) return dm.div;
  28559. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  28560. var half = num.ushrn(1);
  28561. var r2 = num.andln(1);
  28562. var cmp = mod.cmp(half); // Round down
  28563. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; // Round up
  28564. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  28565. };
  28566. BN.prototype.modrn = function modrn(num) {
  28567. var isNegNum = num < 0;
  28568. if (isNegNum) num = -num;
  28569. assert(num <= 0x3ffffff);
  28570. var p = (1 << 26) % num;
  28571. var acc = 0;
  28572. for (var i = this.length - 1; i >= 0; i--) {
  28573. acc = (p * acc + (this.words[i] | 0)) % num;
  28574. }
  28575. return isNegNum ? -acc : acc;
  28576. }; // WARNING: DEPRECATED
  28577. BN.prototype.modn = function modn(num) {
  28578. return this.modrn(num);
  28579. }; // In-place division by number
  28580. BN.prototype.idivn = function idivn(num) {
  28581. var isNegNum = num < 0;
  28582. if (isNegNum) num = -num;
  28583. assert(num <= 0x3ffffff);
  28584. var carry = 0;
  28585. for (var i = this.length - 1; i >= 0; i--) {
  28586. var w = (this.words[i] | 0) + carry * 0x4000000;
  28587. this.words[i] = w / num | 0;
  28588. carry = w % num;
  28589. }
  28590. this._strip();
  28591. return isNegNum ? this.ineg() : this;
  28592. };
  28593. BN.prototype.divn = function divn(num) {
  28594. return this.clone().idivn(num);
  28595. };
  28596. BN.prototype.egcd = function egcd(p) {
  28597. assert(p.negative === 0);
  28598. assert(!p.isZero());
  28599. var x = this;
  28600. var y = p.clone();
  28601. if (x.negative !== 0) {
  28602. x = x.umod(p);
  28603. } else {
  28604. x = x.clone();
  28605. } // A * x + B * y = x
  28606. var A = new BN(1);
  28607. var B = new BN(0); // C * x + D * y = y
  28608. var C = new BN(0);
  28609. var D = new BN(1);
  28610. var g = 0;
  28611. while (x.isEven() && y.isEven()) {
  28612. x.iushrn(1);
  28613. y.iushrn(1);
  28614. ++g;
  28615. }
  28616. var yp = y.clone();
  28617. var xp = x.clone();
  28618. while (!x.isZero()) {
  28619. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1) {
  28620. ;
  28621. }
  28622. if (i > 0) {
  28623. x.iushrn(i);
  28624. while (i-- > 0) {
  28625. if (A.isOdd() || B.isOdd()) {
  28626. A.iadd(yp);
  28627. B.isub(xp);
  28628. }
  28629. A.iushrn(1);
  28630. B.iushrn(1);
  28631. }
  28632. }
  28633. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1) {
  28634. ;
  28635. }
  28636. if (j > 0) {
  28637. y.iushrn(j);
  28638. while (j-- > 0) {
  28639. if (C.isOdd() || D.isOdd()) {
  28640. C.iadd(yp);
  28641. D.isub(xp);
  28642. }
  28643. C.iushrn(1);
  28644. D.iushrn(1);
  28645. }
  28646. }
  28647. if (x.cmp(y) >= 0) {
  28648. x.isub(y);
  28649. A.isub(C);
  28650. B.isub(D);
  28651. } else {
  28652. y.isub(x);
  28653. C.isub(A);
  28654. D.isub(B);
  28655. }
  28656. }
  28657. return {
  28658. a: C,
  28659. b: D,
  28660. gcd: y.iushln(g)
  28661. };
  28662. }; // This is reduced incarnation of the binary EEA
  28663. // above, designated to invert members of the
  28664. // _prime_ fields F(p) at a maximal speed
  28665. BN.prototype._invmp = function _invmp(p) {
  28666. assert(p.negative === 0);
  28667. assert(!p.isZero());
  28668. var a = this;
  28669. var b = p.clone();
  28670. if (a.negative !== 0) {
  28671. a = a.umod(p);
  28672. } else {
  28673. a = a.clone();
  28674. }
  28675. var x1 = new BN(1);
  28676. var x2 = new BN(0);
  28677. var delta = b.clone();
  28678. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  28679. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) {
  28680. ;
  28681. }
  28682. if (i > 0) {
  28683. a.iushrn(i);
  28684. while (i-- > 0) {
  28685. if (x1.isOdd()) {
  28686. x1.iadd(delta);
  28687. }
  28688. x1.iushrn(1);
  28689. }
  28690. }
  28691. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1) {
  28692. ;
  28693. }
  28694. if (j > 0) {
  28695. b.iushrn(j);
  28696. while (j-- > 0) {
  28697. if (x2.isOdd()) {
  28698. x2.iadd(delta);
  28699. }
  28700. x2.iushrn(1);
  28701. }
  28702. }
  28703. if (a.cmp(b) >= 0) {
  28704. a.isub(b);
  28705. x1.isub(x2);
  28706. } else {
  28707. b.isub(a);
  28708. x2.isub(x1);
  28709. }
  28710. }
  28711. var res;
  28712. if (a.cmpn(1) === 0) {
  28713. res = x1;
  28714. } else {
  28715. res = x2;
  28716. }
  28717. if (res.cmpn(0) < 0) {
  28718. res.iadd(p);
  28719. }
  28720. return res;
  28721. };
  28722. BN.prototype.gcd = function gcd(num) {
  28723. if (this.isZero()) return num.abs();
  28724. if (num.isZero()) return this.abs();
  28725. var a = this.clone();
  28726. var b = num.clone();
  28727. a.negative = 0;
  28728. b.negative = 0; // Remove common factor of two
  28729. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  28730. a.iushrn(1);
  28731. b.iushrn(1);
  28732. }
  28733. do {
  28734. while (a.isEven()) {
  28735. a.iushrn(1);
  28736. }
  28737. while (b.isEven()) {
  28738. b.iushrn(1);
  28739. }
  28740. var r = a.cmp(b);
  28741. if (r < 0) {
  28742. // Swap `a` and `b` to make `a` always bigger than `b`
  28743. var t = a;
  28744. a = b;
  28745. b = t;
  28746. } else if (r === 0 || b.cmpn(1) === 0) {
  28747. break;
  28748. }
  28749. a.isub(b);
  28750. } while (true);
  28751. return b.iushln(shift);
  28752. }; // Invert number in the field F(num)
  28753. BN.prototype.invm = function invm(num) {
  28754. return this.egcd(num).a.umod(num);
  28755. };
  28756. BN.prototype.isEven = function isEven() {
  28757. return (this.words[0] & 1) === 0;
  28758. };
  28759. BN.prototype.isOdd = function isOdd() {
  28760. return (this.words[0] & 1) === 1;
  28761. }; // And first word and num
  28762. BN.prototype.andln = function andln(num) {
  28763. return this.words[0] & num;
  28764. }; // Increment at the bit position in-line
  28765. BN.prototype.bincn = function bincn(bit) {
  28766. assert(typeof bit === 'number');
  28767. var r = bit % 26;
  28768. var s = (bit - r) / 26;
  28769. var q = 1 << r; // Fast case: bit is much higher than all existing words
  28770. if (this.length <= s) {
  28771. this._expand(s + 1);
  28772. this.words[s] |= q;
  28773. return this;
  28774. } // Add bit and propagate, if needed
  28775. var carry = q;
  28776. for (var i = s; carry !== 0 && i < this.length; i++) {
  28777. var w = this.words[i] | 0;
  28778. w += carry;
  28779. carry = w >>> 26;
  28780. w &= 0x3ffffff;
  28781. this.words[i] = w;
  28782. }
  28783. if (carry !== 0) {
  28784. this.words[i] = carry;
  28785. this.length++;
  28786. }
  28787. return this;
  28788. };
  28789. BN.prototype.isZero = function isZero() {
  28790. return this.length === 1 && this.words[0] === 0;
  28791. };
  28792. BN.prototype.cmpn = function cmpn(num) {
  28793. var negative = num < 0;
  28794. if (this.negative !== 0 && !negative) return -1;
  28795. if (this.negative === 0 && negative) return 1;
  28796. this._strip();
  28797. var res;
  28798. if (this.length > 1) {
  28799. res = 1;
  28800. } else {
  28801. if (negative) {
  28802. num = -num;
  28803. }
  28804. assert(num <= 0x3ffffff, 'Number is too big');
  28805. var w = this.words[0] | 0;
  28806. res = w === num ? 0 : w < num ? -1 : 1;
  28807. }
  28808. if (this.negative !== 0) return -res | 0;
  28809. return res;
  28810. }; // Compare two numbers and return:
  28811. // 1 - if `this` > `num`
  28812. // 0 - if `this` == `num`
  28813. // -1 - if `this` < `num`
  28814. BN.prototype.cmp = function cmp(num) {
  28815. if (this.negative !== 0 && num.negative === 0) return -1;
  28816. if (this.negative === 0 && num.negative !== 0) return 1;
  28817. var res = this.ucmp(num);
  28818. if (this.negative !== 0) return -res | 0;
  28819. return res;
  28820. }; // Unsigned comparison
  28821. BN.prototype.ucmp = function ucmp(num) {
  28822. // At this point both numbers have the same sign
  28823. if (this.length > num.length) return 1;
  28824. if (this.length < num.length) return -1;
  28825. var res = 0;
  28826. for (var i = this.length - 1; i >= 0; i--) {
  28827. var a = this.words[i] | 0;
  28828. var b = num.words[i] | 0;
  28829. if (a === b) continue;
  28830. if (a < b) {
  28831. res = -1;
  28832. } else if (a > b) {
  28833. res = 1;
  28834. }
  28835. break;
  28836. }
  28837. return res;
  28838. };
  28839. BN.prototype.gtn = function gtn(num) {
  28840. return this.cmpn(num) === 1;
  28841. };
  28842. BN.prototype.gt = function gt(num) {
  28843. return this.cmp(num) === 1;
  28844. };
  28845. BN.prototype.gten = function gten(num) {
  28846. return this.cmpn(num) >= 0;
  28847. };
  28848. BN.prototype.gte = function gte(num) {
  28849. return this.cmp(num) >= 0;
  28850. };
  28851. BN.prototype.ltn = function ltn(num) {
  28852. return this.cmpn(num) === -1;
  28853. };
  28854. BN.prototype.lt = function lt(num) {
  28855. return this.cmp(num) === -1;
  28856. };
  28857. BN.prototype.lten = function lten(num) {
  28858. return this.cmpn(num) <= 0;
  28859. };
  28860. BN.prototype.lte = function lte(num) {
  28861. return this.cmp(num) <= 0;
  28862. };
  28863. BN.prototype.eqn = function eqn(num) {
  28864. return this.cmpn(num) === 0;
  28865. };
  28866. BN.prototype.eq = function eq(num) {
  28867. return this.cmp(num) === 0;
  28868. }; //
  28869. // A reduce context, could be using montgomery or something better, depending
  28870. // on the `m` itself.
  28871. //
  28872. BN.red = function red(num) {
  28873. return new Red(num);
  28874. };
  28875. BN.prototype.toRed = function toRed(ctx) {
  28876. assert(!this.red, 'Already a number in reduction context');
  28877. assert(this.negative === 0, 'red works only with positives');
  28878. return ctx.convertTo(this)._forceRed(ctx);
  28879. };
  28880. BN.prototype.fromRed = function fromRed() {
  28881. assert(this.red, 'fromRed works only with numbers in reduction context');
  28882. return this.red.convertFrom(this);
  28883. };
  28884. BN.prototype._forceRed = function _forceRed(ctx) {
  28885. this.red = ctx;
  28886. return this;
  28887. };
  28888. BN.prototype.forceRed = function forceRed(ctx) {
  28889. assert(!this.red, 'Already a number in reduction context');
  28890. return this._forceRed(ctx);
  28891. };
  28892. BN.prototype.redAdd = function redAdd(num) {
  28893. assert(this.red, 'redAdd works only with red numbers');
  28894. return this.red.add(this, num);
  28895. };
  28896. BN.prototype.redIAdd = function redIAdd(num) {
  28897. assert(this.red, 'redIAdd works only with red numbers');
  28898. return this.red.iadd(this, num);
  28899. };
  28900. BN.prototype.redSub = function redSub(num) {
  28901. assert(this.red, 'redSub works only with red numbers');
  28902. return this.red.sub(this, num);
  28903. };
  28904. BN.prototype.redISub = function redISub(num) {
  28905. assert(this.red, 'redISub works only with red numbers');
  28906. return this.red.isub(this, num);
  28907. };
  28908. BN.prototype.redShl = function redShl(num) {
  28909. assert(this.red, 'redShl works only with red numbers');
  28910. return this.red.shl(this, num);
  28911. };
  28912. BN.prototype.redMul = function redMul(num) {
  28913. assert(this.red, 'redMul works only with red numbers');
  28914. this.red._verify2(this, num);
  28915. return this.red.mul(this, num);
  28916. };
  28917. BN.prototype.redIMul = function redIMul(num) {
  28918. assert(this.red, 'redMul works only with red numbers');
  28919. this.red._verify2(this, num);
  28920. return this.red.imul(this, num);
  28921. };
  28922. BN.prototype.redSqr = function redSqr() {
  28923. assert(this.red, 'redSqr works only with red numbers');
  28924. this.red._verify1(this);
  28925. return this.red.sqr(this);
  28926. };
  28927. BN.prototype.redISqr = function redISqr() {
  28928. assert(this.red, 'redISqr works only with red numbers');
  28929. this.red._verify1(this);
  28930. return this.red.isqr(this);
  28931. }; // Square root over p
  28932. BN.prototype.redSqrt = function redSqrt() {
  28933. assert(this.red, 'redSqrt works only with red numbers');
  28934. this.red._verify1(this);
  28935. return this.red.sqrt(this);
  28936. };
  28937. BN.prototype.redInvm = function redInvm() {
  28938. assert(this.red, 'redInvm works only with red numbers');
  28939. this.red._verify1(this);
  28940. return this.red.invm(this);
  28941. }; // Return negative clone of `this` % `red modulo`
  28942. BN.prototype.redNeg = function redNeg() {
  28943. assert(this.red, 'redNeg works only with red numbers');
  28944. this.red._verify1(this);
  28945. return this.red.neg(this);
  28946. };
  28947. BN.prototype.redPow = function redPow(num) {
  28948. assert(this.red && !num.red, 'redPow(normalNum)');
  28949. this.red._verify1(this);
  28950. return this.red.pow(this, num);
  28951. }; // Prime numbers with efficient reduction
  28952. var primes = {
  28953. k256: null,
  28954. p224: null,
  28955. p192: null,
  28956. p25519: null
  28957. }; // Pseudo-Mersenne prime
  28958. function MPrime(name, p) {
  28959. // P = 2 ^ N - K
  28960. this.name = name;
  28961. this.p = new BN(p, 16);
  28962. this.n = this.p.bitLength();
  28963. this.k = new BN(1).iushln(this.n).isub(this.p);
  28964. this.tmp = this._tmp();
  28965. }
  28966. MPrime.prototype._tmp = function _tmp() {
  28967. var tmp = new BN(null);
  28968. tmp.words = new Array(Math.ceil(this.n / 13));
  28969. return tmp;
  28970. };
  28971. MPrime.prototype.ireduce = function ireduce(num) {
  28972. // Assumes that `num` is less than `P^2`
  28973. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  28974. var r = num;
  28975. var rlen;
  28976. do {
  28977. this.split(r, this.tmp);
  28978. r = this.imulK(r);
  28979. r = r.iadd(this.tmp);
  28980. rlen = r.bitLength();
  28981. } while (rlen > this.n);
  28982. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  28983. if (cmp === 0) {
  28984. r.words[0] = 0;
  28985. r.length = 1;
  28986. } else if (cmp > 0) {
  28987. r.isub(this.p);
  28988. } else {
  28989. if (r.strip !== undefined) {
  28990. // r is a BN v4 instance
  28991. r.strip();
  28992. } else {
  28993. // r is a BN v5 instance
  28994. r._strip();
  28995. }
  28996. }
  28997. return r;
  28998. };
  28999. MPrime.prototype.split = function split(input, out) {
  29000. input.iushrn(this.n, 0, out);
  29001. };
  29002. MPrime.prototype.imulK = function imulK(num) {
  29003. return num.imul(this.k);
  29004. };
  29005. function K256() {
  29006. MPrime.call(this, 'k256', 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  29007. }
  29008. inherits(K256, MPrime);
  29009. K256.prototype.split = function split(input, output) {
  29010. // 256 = 9 * 26 + 22
  29011. var mask = 0x3fffff;
  29012. var outLen = Math.min(input.length, 9);
  29013. for (var i = 0; i < outLen; i++) {
  29014. output.words[i] = input.words[i];
  29015. }
  29016. output.length = outLen;
  29017. if (input.length <= 9) {
  29018. input.words[0] = 0;
  29019. input.length = 1;
  29020. return;
  29021. } // Shift by 9 limbs
  29022. var prev = input.words[9];
  29023. output.words[output.length++] = prev & mask;
  29024. for (i = 10; i < input.length; i++) {
  29025. var next = input.words[i] | 0;
  29026. input.words[i - 10] = (next & mask) << 4 | prev >>> 22;
  29027. prev = next;
  29028. }
  29029. prev >>>= 22;
  29030. input.words[i - 10] = prev;
  29031. if (prev === 0 && input.length > 10) {
  29032. input.length -= 10;
  29033. } else {
  29034. input.length -= 9;
  29035. }
  29036. };
  29037. K256.prototype.imulK = function imulK(num) {
  29038. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  29039. num.words[num.length] = 0;
  29040. num.words[num.length + 1] = 0;
  29041. num.length += 2; // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  29042. var lo = 0;
  29043. for (var i = 0; i < num.length; i++) {
  29044. var w = num.words[i] | 0;
  29045. lo += w * 0x3d1;
  29046. num.words[i] = lo & 0x3ffffff;
  29047. lo = w * 0x40 + (lo / 0x4000000 | 0);
  29048. } // Fast length reduction
  29049. if (num.words[num.length - 1] === 0) {
  29050. num.length--;
  29051. if (num.words[num.length - 1] === 0) {
  29052. num.length--;
  29053. }
  29054. }
  29055. return num;
  29056. };
  29057. function P224() {
  29058. MPrime.call(this, 'p224', 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  29059. }
  29060. inherits(P224, MPrime);
  29061. function P192() {
  29062. MPrime.call(this, 'p192', 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  29063. }
  29064. inherits(P192, MPrime);
  29065. function P25519() {
  29066. // 2 ^ 255 - 19
  29067. MPrime.call(this, '25519', '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  29068. }
  29069. inherits(P25519, MPrime);
  29070. P25519.prototype.imulK = function imulK(num) {
  29071. // K = 0x13
  29072. var carry = 0;
  29073. for (var i = 0; i < num.length; i++) {
  29074. var hi = (num.words[i] | 0) * 0x13 + carry;
  29075. var lo = hi & 0x3ffffff;
  29076. hi >>>= 26;
  29077. num.words[i] = lo;
  29078. carry = hi;
  29079. }
  29080. if (carry !== 0) {
  29081. num.words[num.length++] = carry;
  29082. }
  29083. return num;
  29084. }; // Exported mostly for testing purposes, use plain name instead
  29085. BN._prime = function prime(name) {
  29086. // Cached version of prime
  29087. if (primes[name]) return primes[name];
  29088. var prime;
  29089. if (name === 'k256') {
  29090. prime = new K256();
  29091. } else if (name === 'p224') {
  29092. prime = new P224();
  29093. } else if (name === 'p192') {
  29094. prime = new P192();
  29095. } else if (name === 'p25519') {
  29096. prime = new P25519();
  29097. } else {
  29098. throw new Error('Unknown prime ' + name);
  29099. }
  29100. primes[name] = prime;
  29101. return prime;
  29102. }; //
  29103. // Base reduction engine
  29104. //
  29105. function Red(m) {
  29106. if (typeof m === 'string') {
  29107. var prime = BN._prime(m);
  29108. this.m = prime.p;
  29109. this.prime = prime;
  29110. } else {
  29111. assert(m.gtn(1), 'modulus must be greater than 1');
  29112. this.m = m;
  29113. this.prime = null;
  29114. }
  29115. }
  29116. Red.prototype._verify1 = function _verify1(a) {
  29117. assert(a.negative === 0, 'red works only with positives');
  29118. assert(a.red, 'red works only with red numbers');
  29119. };
  29120. Red.prototype._verify2 = function _verify2(a, b) {
  29121. assert((a.negative | b.negative) === 0, 'red works only with positives');
  29122. assert(a.red && a.red === b.red, 'red works only with red numbers');
  29123. };
  29124. Red.prototype.imod = function imod(a) {
  29125. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  29126. move(a, a.umod(this.m)._forceRed(this));
  29127. return a;
  29128. };
  29129. Red.prototype.neg = function neg(a) {
  29130. if (a.isZero()) {
  29131. return a.clone();
  29132. }
  29133. return this.m.sub(a)._forceRed(this);
  29134. };
  29135. Red.prototype.add = function add(a, b) {
  29136. this._verify2(a, b);
  29137. var res = a.add(b);
  29138. if (res.cmp(this.m) >= 0) {
  29139. res.isub(this.m);
  29140. }
  29141. return res._forceRed(this);
  29142. };
  29143. Red.prototype.iadd = function iadd(a, b) {
  29144. this._verify2(a, b);
  29145. var res = a.iadd(b);
  29146. if (res.cmp(this.m) >= 0) {
  29147. res.isub(this.m);
  29148. }
  29149. return res;
  29150. };
  29151. Red.prototype.sub = function sub(a, b) {
  29152. this._verify2(a, b);
  29153. var res = a.sub(b);
  29154. if (res.cmpn(0) < 0) {
  29155. res.iadd(this.m);
  29156. }
  29157. return res._forceRed(this);
  29158. };
  29159. Red.prototype.isub = function isub(a, b) {
  29160. this._verify2(a, b);
  29161. var res = a.isub(b);
  29162. if (res.cmpn(0) < 0) {
  29163. res.iadd(this.m);
  29164. }
  29165. return res;
  29166. };
  29167. Red.prototype.shl = function shl(a, num) {
  29168. this._verify1(a);
  29169. return this.imod(a.ushln(num));
  29170. };
  29171. Red.prototype.imul = function imul(a, b) {
  29172. this._verify2(a, b);
  29173. return this.imod(a.imul(b));
  29174. };
  29175. Red.prototype.mul = function mul(a, b) {
  29176. this._verify2(a, b);
  29177. return this.imod(a.mul(b));
  29178. };
  29179. Red.prototype.isqr = function isqr(a) {
  29180. return this.imul(a, a.clone());
  29181. };
  29182. Red.prototype.sqr = function sqr(a) {
  29183. return this.mul(a, a);
  29184. };
  29185. Red.prototype.sqrt = function sqrt(a) {
  29186. if (a.isZero()) return a.clone();
  29187. var mod3 = this.m.andln(3);
  29188. assert(mod3 % 2 === 1); // Fast case
  29189. if (mod3 === 3) {
  29190. var pow = this.m.add(new BN(1)).iushrn(2);
  29191. return this.pow(a, pow);
  29192. } // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  29193. //
  29194. // Find Q and S, that Q * 2 ^ S = (P - 1)
  29195. var q = this.m.subn(1);
  29196. var s = 0;
  29197. while (!q.isZero() && q.andln(1) === 0) {
  29198. s++;
  29199. q.iushrn(1);
  29200. }
  29201. assert(!q.isZero());
  29202. var one = new BN(1).toRed(this);
  29203. var nOne = one.redNeg(); // Find quadratic non-residue
  29204. // NOTE: Max is such because of generalized Riemann hypothesis.
  29205. var lpow = this.m.subn(1).iushrn(1);
  29206. var z = this.m.bitLength();
  29207. z = new BN(2 * z * z).toRed(this);
  29208. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  29209. z.redIAdd(nOne);
  29210. }
  29211. var c = this.pow(z, q);
  29212. var r = this.pow(a, q.addn(1).iushrn(1));
  29213. var t = this.pow(a, q);
  29214. var m = s;
  29215. while (t.cmp(one) !== 0) {
  29216. var tmp = t;
  29217. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  29218. tmp = tmp.redSqr();
  29219. }
  29220. assert(i < m);
  29221. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  29222. r = r.redMul(b);
  29223. c = b.redSqr();
  29224. t = t.redMul(c);
  29225. m = i;
  29226. }
  29227. return r;
  29228. };
  29229. Red.prototype.invm = function invm(a) {
  29230. var inv = a._invmp(this.m);
  29231. if (inv.negative !== 0) {
  29232. inv.negative = 0;
  29233. return this.imod(inv).redNeg();
  29234. } else {
  29235. return this.imod(inv);
  29236. }
  29237. };
  29238. Red.prototype.pow = function pow(a, num) {
  29239. if (num.isZero()) return new BN(1).toRed(this);
  29240. if (num.cmpn(1) === 0) return a.clone();
  29241. var windowSize = 4;
  29242. var wnd = new Array(1 << windowSize);
  29243. wnd[0] = new BN(1).toRed(this);
  29244. wnd[1] = a;
  29245. for (var i = 2; i < wnd.length; i++) {
  29246. wnd[i] = this.mul(wnd[i - 1], a);
  29247. }
  29248. var res = wnd[0];
  29249. var current = 0;
  29250. var currentLen = 0;
  29251. var start = num.bitLength() % 26;
  29252. if (start === 0) {
  29253. start = 26;
  29254. }
  29255. for (i = num.length - 1; i >= 0; i--) {
  29256. var word = num.words[i];
  29257. for (var j = start - 1; j >= 0; j--) {
  29258. var bit = word >> j & 1;
  29259. if (res !== wnd[0]) {
  29260. res = this.sqr(res);
  29261. }
  29262. if (bit === 0 && current === 0) {
  29263. currentLen = 0;
  29264. continue;
  29265. }
  29266. current <<= 1;
  29267. current |= bit;
  29268. currentLen++;
  29269. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  29270. res = this.mul(res, wnd[current]);
  29271. currentLen = 0;
  29272. current = 0;
  29273. }
  29274. start = 26;
  29275. }
  29276. return res;
  29277. };
  29278. Red.prototype.convertTo = function convertTo(num) {
  29279. var r = num.umod(this.m);
  29280. return r === num ? r.clone() : r;
  29281. };
  29282. Red.prototype.convertFrom = function convertFrom(num) {
  29283. var res = num.clone();
  29284. res.red = null;
  29285. return res;
  29286. }; //
  29287. // Montgomery method engine
  29288. //
  29289. BN.mont = function mont(num) {
  29290. return new Mont(num);
  29291. };
  29292. function Mont(m) {
  29293. Red.call(this, m);
  29294. this.shift = this.m.bitLength();
  29295. if (this.shift % 26 !== 0) {
  29296. this.shift += 26 - this.shift % 26;
  29297. }
  29298. this.r = new BN(1).iushln(this.shift);
  29299. this.r2 = this.imod(this.r.sqr());
  29300. this.rinv = this.r._invmp(this.m);
  29301. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  29302. this.minv = this.minv.umod(this.r);
  29303. this.minv = this.r.sub(this.minv);
  29304. }
  29305. inherits(Mont, Red);
  29306. Mont.prototype.convertTo = function convertTo(num) {
  29307. return this.imod(num.ushln(this.shift));
  29308. };
  29309. Mont.prototype.convertFrom = function convertFrom(num) {
  29310. var r = this.imod(num.mul(this.rinv));
  29311. r.red = null;
  29312. return r;
  29313. };
  29314. Mont.prototype.imul = function imul(a, b) {
  29315. if (a.isZero() || b.isZero()) {
  29316. a.words[0] = 0;
  29317. a.length = 1;
  29318. return a;
  29319. }
  29320. var t = a.imul(b);
  29321. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  29322. var u = t.isub(c).iushrn(this.shift);
  29323. var res = u;
  29324. if (u.cmp(this.m) >= 0) {
  29325. res = u.isub(this.m);
  29326. } else if (u.cmpn(0) < 0) {
  29327. res = u.iadd(this.m);
  29328. }
  29329. return res._forceRed(this);
  29330. };
  29331. Mont.prototype.mul = function mul(a, b) {
  29332. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  29333. var t = a.mul(b);
  29334. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  29335. var u = t.isub(c).iushrn(this.shift);
  29336. var res = u;
  29337. if (u.cmp(this.m) >= 0) {
  29338. res = u.isub(this.m);
  29339. } else if (u.cmpn(0) < 0) {
  29340. res = u.iadd(this.m);
  29341. }
  29342. return res._forceRed(this);
  29343. };
  29344. Mont.prototype.invm = function invm(a) {
  29345. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  29346. var res = this.imod(a._invmp(this.m).mul(this.r2));
  29347. return res._forceRed(this);
  29348. };
  29349. })(typeof module === 'undefined' || module, void 0);
  29350. }, { "buffer": 185 }], 184: [function (require, module, exports) {
  29351. "use strict";
  29352. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  29353. var r;
  29354. module.exports = function rand(len) {
  29355. if (!r) r = new Rand(null);
  29356. return r.generate(len);
  29357. };
  29358. function Rand(rand) {
  29359. this.rand = rand;
  29360. }
  29361. module.exports.Rand = Rand;
  29362. Rand.prototype.generate = function generate(len) {
  29363. return this._rand(len);
  29364. }; // Emulate crypto API using randy
  29365. Rand.prototype._rand = function _rand(n) {
  29366. if (this.rand.getBytes) return this.rand.getBytes(n);
  29367. var res = new Uint8Array(n);
  29368. for (var i = 0; i < res.length; i++) {
  29369. res[i] = this.rand.getByte();
  29370. }
  29371. return res;
  29372. };
  29373. if ((typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object') {
  29374. if (self.crypto && self.crypto.getRandomValues) {
  29375. // Modern browsers
  29376. Rand.prototype._rand = function _rand(n) {
  29377. var arr = new Uint8Array(n);
  29378. self.crypto.getRandomValues(arr);
  29379. return arr;
  29380. };
  29381. } else if (self.msCrypto && self.msCrypto.getRandomValues) {
  29382. // IE
  29383. Rand.prototype._rand = function _rand(n) {
  29384. var arr = new Uint8Array(n);
  29385. self.msCrypto.getRandomValues(arr);
  29386. return arr;
  29387. }; // Safari's WebWorkers do not have `crypto`
  29388. } else if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object') {
  29389. // Old junk
  29390. Rand.prototype._rand = function () {
  29391. throw new Error('Not implemented yet');
  29392. };
  29393. }
  29394. } else {
  29395. // Node.js or Web worker with no crypto support
  29396. try {
  29397. var crypto = require('crypto');
  29398. if (typeof crypto.randomBytes !== 'function') throw new Error('Not supported');
  29399. Rand.prototype._rand = function _rand(n) {
  29400. return crypto.randomBytes(n);
  29401. };
  29402. } catch (e) { }
  29403. }
  29404. }, { "crypto": 185 }], 185: [function (require, module, exports) {
  29405. "use strict";
  29406. }, {}], 186: [function (require, module, exports) {
  29407. "use strict";
  29408. // based on the aes implimentation in triple sec
  29409. // https://github.com/keybase/triplesec
  29410. // which is in turn based on the one from crypto-js
  29411. // https://code.google.com/p/crypto-js/
  29412. var Buffer = require('safe-buffer').Buffer;
  29413. function asUInt32Array(buf) {
  29414. if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
  29415. var len = buf.length / 4 | 0;
  29416. var out = new Array(len);
  29417. for (var i = 0; i < len; i++) {
  29418. out[i] = buf.readUInt32BE(i * 4);
  29419. }
  29420. return out;
  29421. }
  29422. function scrubVec(v) {
  29423. for (var i = 0; i < v.length; v++) {
  29424. v[i] = 0;
  29425. }
  29426. }
  29427. function cryptBlock(M, keySchedule, SUB_MIX, SBOX, nRounds) {
  29428. var SUB_MIX0 = SUB_MIX[0];
  29429. var SUB_MIX1 = SUB_MIX[1];
  29430. var SUB_MIX2 = SUB_MIX[2];
  29431. var SUB_MIX3 = SUB_MIX[3];
  29432. var s0 = M[0] ^ keySchedule[0];
  29433. var s1 = M[1] ^ keySchedule[1];
  29434. var s2 = M[2] ^ keySchedule[2];
  29435. var s3 = M[3] ^ keySchedule[3];
  29436. var t0, t1, t2, t3;
  29437. var ksRow = 4;
  29438. for (var round = 1; round < nRounds; round++) {
  29439. t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[s1 >>> 16 & 0xff] ^ SUB_MIX2[s2 >>> 8 & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++];
  29440. t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[s2 >>> 16 & 0xff] ^ SUB_MIX2[s3 >>> 8 & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++];
  29441. t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[s3 >>> 16 & 0xff] ^ SUB_MIX2[s0 >>> 8 & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++];
  29442. t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[s0 >>> 16 & 0xff] ^ SUB_MIX2[s1 >>> 8 & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++];
  29443. s0 = t0;
  29444. s1 = t1;
  29445. s2 = t2;
  29446. s3 = t3;
  29447. }
  29448. t0 = (SBOX[s0 >>> 24] << 24 | SBOX[s1 >>> 16 & 0xff] << 16 | SBOX[s2 >>> 8 & 0xff] << 8 | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  29449. t1 = (SBOX[s1 >>> 24] << 24 | SBOX[s2 >>> 16 & 0xff] << 16 | SBOX[s3 >>> 8 & 0xff] << 8 | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  29450. t2 = (SBOX[s2 >>> 24] << 24 | SBOX[s3 >>> 16 & 0xff] << 16 | SBOX[s0 >>> 8 & 0xff] << 8 | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  29451. t3 = (SBOX[s3 >>> 24] << 24 | SBOX[s0 >>> 16 & 0xff] << 16 | SBOX[s1 >>> 8 & 0xff] << 8 | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  29452. t0 = t0 >>> 0;
  29453. t1 = t1 >>> 0;
  29454. t2 = t2 >>> 0;
  29455. t3 = t3 >>> 0;
  29456. return [t0, t1, t2, t3];
  29457. } // AES constants
  29458. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  29459. var G = function () {
  29460. // Compute double table
  29461. var d = new Array(256);
  29462. for (var j = 0; j < 256; j++) {
  29463. if (j < 128) {
  29464. d[j] = j << 1;
  29465. } else {
  29466. d[j] = j << 1 ^ 0x11b;
  29467. }
  29468. }
  29469. var SBOX = [];
  29470. var INV_SBOX = [];
  29471. var SUB_MIX = [[], [], [], []];
  29472. var INV_SUB_MIX = [[], [], [], []]; // Walk GF(2^8)
  29473. var x = 0;
  29474. var xi = 0;
  29475. for (var i = 0; i < 256; ++i) {
  29476. // Compute sbox
  29477. var sx = xi ^ xi << 1 ^ xi << 2 ^ xi << 3 ^ xi << 4;
  29478. sx = sx >>> 8 ^ sx & 0xff ^ 0x63;
  29479. SBOX[x] = sx;
  29480. INV_SBOX[sx] = x; // Compute multiplication
  29481. var x2 = d[x];
  29482. var x4 = d[x2];
  29483. var x8 = d[x4]; // Compute sub bytes, mix columns tables
  29484. var t = d[sx] * 0x101 ^ sx * 0x1010100;
  29485. SUB_MIX[0][x] = t << 24 | t >>> 8;
  29486. SUB_MIX[1][x] = t << 16 | t >>> 16;
  29487. SUB_MIX[2][x] = t << 8 | t >>> 24;
  29488. SUB_MIX[3][x] = t; // Compute inv sub bytes, inv mix columns tables
  29489. t = x8 * 0x1010101 ^ x4 * 0x10001 ^ x2 * 0x101 ^ x * 0x1010100;
  29490. INV_SUB_MIX[0][sx] = t << 24 | t >>> 8;
  29491. INV_SUB_MIX[1][sx] = t << 16 | t >>> 16;
  29492. INV_SUB_MIX[2][sx] = t << 8 | t >>> 24;
  29493. INV_SUB_MIX[3][sx] = t;
  29494. if (x === 0) {
  29495. x = xi = 1;
  29496. } else {
  29497. x = x2 ^ d[d[d[x8 ^ x2]]];
  29498. xi ^= d[d[xi]];
  29499. }
  29500. }
  29501. return {
  29502. SBOX: SBOX,
  29503. INV_SBOX: INV_SBOX,
  29504. SUB_MIX: SUB_MIX,
  29505. INV_SUB_MIX: INV_SUB_MIX
  29506. };
  29507. }();
  29508. function AES(key) {
  29509. this._key = asUInt32Array(key);
  29510. this._reset();
  29511. }
  29512. AES.blockSize = 4 * 4;
  29513. AES.keySize = 256 / 8;
  29514. AES.prototype.blockSize = AES.blockSize;
  29515. AES.prototype.keySize = AES.keySize;
  29516. AES.prototype._reset = function () {
  29517. var keyWords = this._key;
  29518. var keySize = keyWords.length;
  29519. var nRounds = keySize + 6;
  29520. var ksRows = (nRounds + 1) * 4;
  29521. var keySchedule = [];
  29522. for (var k = 0; k < keySize; k++) {
  29523. keySchedule[k] = keyWords[k];
  29524. }
  29525. for (k = keySize; k < ksRows; k++) {
  29526. var t = keySchedule[k - 1];
  29527. if (k % keySize === 0) {
  29528. t = t << 8 | t >>> 24;
  29529. t = G.SBOX[t >>> 24] << 24 | G.SBOX[t >>> 16 & 0xff] << 16 | G.SBOX[t >>> 8 & 0xff] << 8 | G.SBOX[t & 0xff];
  29530. t ^= RCON[k / keySize | 0] << 24;
  29531. } else if (keySize > 6 && k % keySize === 4) {
  29532. t = G.SBOX[t >>> 24] << 24 | G.SBOX[t >>> 16 & 0xff] << 16 | G.SBOX[t >>> 8 & 0xff] << 8 | G.SBOX[t & 0xff];
  29533. }
  29534. keySchedule[k] = keySchedule[k - keySize] ^ t;
  29535. }
  29536. var invKeySchedule = [];
  29537. for (var ik = 0; ik < ksRows; ik++) {
  29538. var ksR = ksRows - ik;
  29539. var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)];
  29540. if (ik < 4 || ksR <= 4) {
  29541. invKeySchedule[ik] = tt;
  29542. } else {
  29543. invKeySchedule[ik] = G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^ G.INV_SUB_MIX[1][G.SBOX[tt >>> 16 & 0xff]] ^ G.INV_SUB_MIX[2][G.SBOX[tt >>> 8 & 0xff]] ^ G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]];
  29544. }
  29545. }
  29546. this._nRounds = nRounds;
  29547. this._keySchedule = keySchedule;
  29548. this._invKeySchedule = invKeySchedule;
  29549. };
  29550. AES.prototype.encryptBlockRaw = function (M) {
  29551. M = asUInt32Array(M);
  29552. return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds);
  29553. };
  29554. AES.prototype.encryptBlock = function (M) {
  29555. var out = this.encryptBlockRaw(M);
  29556. var buf = Buffer.allocUnsafe(16);
  29557. buf.writeUInt32BE(out[0], 0);
  29558. buf.writeUInt32BE(out[1], 4);
  29559. buf.writeUInt32BE(out[2], 8);
  29560. buf.writeUInt32BE(out[3], 12);
  29561. return buf;
  29562. };
  29563. AES.prototype.decryptBlock = function (M) {
  29564. M = asUInt32Array(M); // swap
  29565. var m1 = M[1];
  29566. M[1] = M[3];
  29567. M[3] = m1;
  29568. var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds);
  29569. var buf = Buffer.allocUnsafe(16);
  29570. buf.writeUInt32BE(out[0], 0);
  29571. buf.writeUInt32BE(out[3], 4);
  29572. buf.writeUInt32BE(out[2], 8);
  29573. buf.writeUInt32BE(out[1], 12);
  29574. return buf;
  29575. };
  29576. AES.prototype.scrub = function () {
  29577. scrubVec(this._keySchedule);
  29578. scrubVec(this._invKeySchedule);
  29579. scrubVec(this._key);
  29580. };
  29581. module.exports.AES = AES;
  29582. }, { "safe-buffer": 494 }], 187: [function (require, module, exports) {
  29583. "use strict";
  29584. var aes = require('./aes');
  29585. var Buffer = require('safe-buffer').Buffer;
  29586. var Transform = require('cipher-base');
  29587. var inherits = require('inherits');
  29588. var GHASH = require('./ghash');
  29589. var xor = require('buffer-xor');
  29590. var incr32 = require('./incr32');
  29591. function xorTest(a, b) {
  29592. var out = 0;
  29593. if (a.length !== b.length) out++;
  29594. var len = Math.min(a.length, b.length);
  29595. for (var i = 0; i < len; ++i) {
  29596. out += a[i] ^ b[i];
  29597. }
  29598. return out;
  29599. }
  29600. function calcIv(self, iv, ck) {
  29601. if (iv.length === 12) {
  29602. self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])]);
  29603. return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])]);
  29604. }
  29605. var ghash = new GHASH(ck);
  29606. var len = iv.length;
  29607. var toPad = len % 16;
  29608. ghash.update(iv);
  29609. if (toPad) {
  29610. toPad = 16 - toPad;
  29611. ghash.update(Buffer.alloc(toPad, 0));
  29612. }
  29613. ghash.update(Buffer.alloc(8, 0));
  29614. var ivBits = len * 8;
  29615. var tail = Buffer.alloc(8);
  29616. tail.writeUIntBE(ivBits, 0, 8);
  29617. ghash.update(tail);
  29618. self._finID = ghash.state;
  29619. var out = Buffer.from(self._finID);
  29620. incr32(out);
  29621. return out;
  29622. }
  29623. function StreamCipher(mode, key, iv, decrypt) {
  29624. Transform.call(this);
  29625. var h = Buffer.alloc(4, 0);
  29626. this._cipher = new aes.AES(key);
  29627. var ck = this._cipher.encryptBlock(h);
  29628. this._ghash = new GHASH(ck);
  29629. iv = calcIv(this, iv, ck);
  29630. this._prev = Buffer.from(iv);
  29631. this._cache = Buffer.allocUnsafe(0);
  29632. this._secCache = Buffer.allocUnsafe(0);
  29633. this._decrypt = decrypt;
  29634. this._alen = 0;
  29635. this._len = 0;
  29636. this._mode = mode;
  29637. this._authTag = null;
  29638. this._called = false;
  29639. }
  29640. inherits(StreamCipher, Transform);
  29641. StreamCipher.prototype._update = function (chunk) {
  29642. if (!this._called && this._alen) {
  29643. var rump = 16 - this._alen % 16;
  29644. if (rump < 16) {
  29645. rump = Buffer.alloc(rump, 0);
  29646. this._ghash.update(rump);
  29647. }
  29648. }
  29649. this._called = true;
  29650. var out = this._mode.encrypt(this, chunk);
  29651. if (this._decrypt) {
  29652. this._ghash.update(chunk);
  29653. } else {
  29654. this._ghash.update(out);
  29655. }
  29656. this._len += chunk.length;
  29657. return out;
  29658. };
  29659. StreamCipher.prototype._final = function () {
  29660. if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data');
  29661. var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID));
  29662. if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data');
  29663. this._authTag = tag;
  29664. this._cipher.scrub();
  29665. };
  29666. StreamCipher.prototype.getAuthTag = function getAuthTag() {
  29667. if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state');
  29668. return this._authTag;
  29669. };
  29670. StreamCipher.prototype.setAuthTag = function setAuthTag(tag) {
  29671. if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state');
  29672. this._authTag = tag;
  29673. };
  29674. StreamCipher.prototype.setAAD = function setAAD(buf) {
  29675. if (this._called) throw new Error('Attempting to set AAD in unsupported state');
  29676. this._ghash.update(buf);
  29677. this._alen += buf.length;
  29678. };
  29679. module.exports = StreamCipher;
  29680. }, { "./aes": 186, "./ghash": 191, "./incr32": 192, "buffer-xor": 217, "cipher-base": 218, "inherits": 387, "safe-buffer": 494 }], 188: [function (require, module, exports) {
  29681. "use strict";
  29682. var ciphers = require('./encrypter');
  29683. var deciphers = require('./decrypter');
  29684. var modes = require('./modes/list.json');
  29685. function getCiphers() {
  29686. return Object.keys(modes);
  29687. }
  29688. exports.createCipher = exports.Cipher = ciphers.createCipher;
  29689. exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv;
  29690. exports.createDecipher = exports.Decipher = deciphers.createDecipher;
  29691. exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv;
  29692. exports.listCiphers = exports.getCiphers = getCiphers;
  29693. }, { "./decrypter": 189, "./encrypter": 190, "./modes/list.json": 200 }], 189: [function (require, module, exports) {
  29694. "use strict";
  29695. var AuthCipher = require('./authCipher');
  29696. var Buffer = require('safe-buffer').Buffer;
  29697. var MODES = require('./modes');
  29698. var StreamCipher = require('./streamCipher');
  29699. var Transform = require('cipher-base');
  29700. var aes = require('./aes');
  29701. var ebtk = require('evp_bytestokey');
  29702. var inherits = require('inherits');
  29703. function Decipher(mode, key, iv) {
  29704. Transform.call(this);
  29705. this._cache = new Splitter();
  29706. this._last = void 0;
  29707. this._cipher = new aes.AES(key);
  29708. this._prev = Buffer.from(iv);
  29709. this._mode = mode;
  29710. this._autopadding = true;
  29711. }
  29712. inherits(Decipher, Transform);
  29713. Decipher.prototype._update = function (data) {
  29714. this._cache.add(data);
  29715. var chunk;
  29716. var thing;
  29717. var out = [];
  29718. while (chunk = this._cache.get(this._autopadding)) {
  29719. thing = this._mode.decrypt(this, chunk);
  29720. out.push(thing);
  29721. }
  29722. return Buffer.concat(out);
  29723. };
  29724. Decipher.prototype._final = function () {
  29725. var chunk = this._cache.flush();
  29726. if (this._autopadding) {
  29727. return unpad(this._mode.decrypt(this, chunk));
  29728. } else if (chunk) {
  29729. throw new Error('data not multiple of block length');
  29730. }
  29731. };
  29732. Decipher.prototype.setAutoPadding = function (setTo) {
  29733. this._autopadding = !!setTo;
  29734. return this;
  29735. };
  29736. function Splitter() {
  29737. this.cache = Buffer.allocUnsafe(0);
  29738. }
  29739. Splitter.prototype.add = function (data) {
  29740. this.cache = Buffer.concat([this.cache, data]);
  29741. };
  29742. Splitter.prototype.get = function (autoPadding) {
  29743. var out;
  29744. if (autoPadding) {
  29745. if (this.cache.length > 16) {
  29746. out = this.cache.slice(0, 16);
  29747. this.cache = this.cache.slice(16);
  29748. return out;
  29749. }
  29750. } else {
  29751. if (this.cache.length >= 16) {
  29752. out = this.cache.slice(0, 16);
  29753. this.cache = this.cache.slice(16);
  29754. return out;
  29755. }
  29756. }
  29757. return null;
  29758. };
  29759. Splitter.prototype.flush = function () {
  29760. if (this.cache.length) return this.cache;
  29761. };
  29762. function unpad(last) {
  29763. var padded = last[15];
  29764. if (padded < 1 || padded > 16) {
  29765. throw new Error('unable to decrypt data');
  29766. }
  29767. var i = -1;
  29768. while (++i < padded) {
  29769. if (last[i + (16 - padded)] !== padded) {
  29770. throw new Error('unable to decrypt data');
  29771. }
  29772. }
  29773. if (padded === 16) return;
  29774. return last.slice(0, 16 - padded);
  29775. }
  29776. function createDecipheriv(suite, password, iv) {
  29777. var config = MODES[suite.toLowerCase()];
  29778. if (!config) throw new TypeError('invalid suite type');
  29779. if (typeof iv === 'string') iv = Buffer.from(iv);
  29780. if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length);
  29781. if (typeof password === 'string') password = Buffer.from(password);
  29782. if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length);
  29783. if (config.type === 'stream') {
  29784. return new StreamCipher(config.module, password, iv, true);
  29785. } else if (config.type === 'auth') {
  29786. return new AuthCipher(config.module, password, iv, true);
  29787. }
  29788. return new Decipher(config.module, password, iv);
  29789. }
  29790. function createDecipher(suite, password) {
  29791. var config = MODES[suite.toLowerCase()];
  29792. if (!config) throw new TypeError('invalid suite type');
  29793. var keys = ebtk(password, false, config.key, config.iv);
  29794. return createDecipheriv(suite, keys.key, keys.iv);
  29795. }
  29796. exports.createDecipher = createDecipher;
  29797. exports.createDecipheriv = createDecipheriv;
  29798. }, { "./aes": 186, "./authCipher": 187, "./modes": 199, "./streamCipher": 202, "cipher-base": 218, "evp_bytestokey": 368, "inherits": 387, "safe-buffer": 494 }], 190: [function (require, module, exports) {
  29799. "use strict";
  29800. var MODES = require('./modes');
  29801. var AuthCipher = require('./authCipher');
  29802. var Buffer = require('safe-buffer').Buffer;
  29803. var StreamCipher = require('./streamCipher');
  29804. var Transform = require('cipher-base');
  29805. var aes = require('./aes');
  29806. var ebtk = require('evp_bytestokey');
  29807. var inherits = require('inherits');
  29808. function Cipher(mode, key, iv) {
  29809. Transform.call(this);
  29810. this._cache = new Splitter();
  29811. this._cipher = new aes.AES(key);
  29812. this._prev = Buffer.from(iv);
  29813. this._mode = mode;
  29814. this._autopadding = true;
  29815. }
  29816. inherits(Cipher, Transform);
  29817. Cipher.prototype._update = function (data) {
  29818. this._cache.add(data);
  29819. var chunk;
  29820. var thing;
  29821. var out = [];
  29822. while (chunk = this._cache.get()) {
  29823. thing = this._mode.encrypt(this, chunk);
  29824. out.push(thing);
  29825. }
  29826. return Buffer.concat(out);
  29827. };
  29828. var PADDING = Buffer.alloc(16, 0x10);
  29829. Cipher.prototype._final = function () {
  29830. var chunk = this._cache.flush();
  29831. if (this._autopadding) {
  29832. chunk = this._mode.encrypt(this, chunk);
  29833. this._cipher.scrub();
  29834. return chunk;
  29835. }
  29836. if (!chunk.equals(PADDING)) {
  29837. this._cipher.scrub();
  29838. throw new Error('data not multiple of block length');
  29839. }
  29840. };
  29841. Cipher.prototype.setAutoPadding = function (setTo) {
  29842. this._autopadding = !!setTo;
  29843. return this;
  29844. };
  29845. function Splitter() {
  29846. this.cache = Buffer.allocUnsafe(0);
  29847. }
  29848. Splitter.prototype.add = function (data) {
  29849. this.cache = Buffer.concat([this.cache, data]);
  29850. };
  29851. Splitter.prototype.get = function () {
  29852. if (this.cache.length > 15) {
  29853. var out = this.cache.slice(0, 16);
  29854. this.cache = this.cache.slice(16);
  29855. return out;
  29856. }
  29857. return null;
  29858. };
  29859. Splitter.prototype.flush = function () {
  29860. var len = 16 - this.cache.length;
  29861. var padBuff = Buffer.allocUnsafe(len);
  29862. var i = -1;
  29863. while (++i < len) {
  29864. padBuff.writeUInt8(len, i);
  29865. }
  29866. return Buffer.concat([this.cache, padBuff]);
  29867. };
  29868. function createCipheriv(suite, password, iv) {
  29869. var config = MODES[suite.toLowerCase()];
  29870. if (!config) throw new TypeError('invalid suite type');
  29871. if (typeof password === 'string') password = Buffer.from(password);
  29872. if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length);
  29873. if (typeof iv === 'string') iv = Buffer.from(iv);
  29874. if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length);
  29875. if (config.type === 'stream') {
  29876. return new StreamCipher(config.module, password, iv);
  29877. } else if (config.type === 'auth') {
  29878. return new AuthCipher(config.module, password, iv);
  29879. }
  29880. return new Cipher(config.module, password, iv);
  29881. }
  29882. function createCipher(suite, password) {
  29883. var config = MODES[suite.toLowerCase()];
  29884. if (!config) throw new TypeError('invalid suite type');
  29885. var keys = ebtk(password, false, config.key, config.iv);
  29886. return createCipheriv(suite, keys.key, keys.iv);
  29887. }
  29888. exports.createCipheriv = createCipheriv;
  29889. exports.createCipher = createCipher;
  29890. }, { "./aes": 186, "./authCipher": 187, "./modes": 199, "./streamCipher": 202, "cipher-base": 218, "evp_bytestokey": 368, "inherits": 387, "safe-buffer": 494 }], 191: [function (require, module, exports) {
  29891. "use strict";
  29892. var Buffer = require('safe-buffer').Buffer;
  29893. var ZEROES = Buffer.alloc(16, 0);
  29894. function toArray(buf) {
  29895. return [buf.readUInt32BE(0), buf.readUInt32BE(4), buf.readUInt32BE(8), buf.readUInt32BE(12)];
  29896. }
  29897. function fromArray(out) {
  29898. var buf = Buffer.allocUnsafe(16);
  29899. buf.writeUInt32BE(out[0] >>> 0, 0);
  29900. buf.writeUInt32BE(out[1] >>> 0, 4);
  29901. buf.writeUInt32BE(out[2] >>> 0, 8);
  29902. buf.writeUInt32BE(out[3] >>> 0, 12);
  29903. return buf;
  29904. }
  29905. function GHASH(key) {
  29906. this.h = key;
  29907. this.state = Buffer.alloc(16, 0);
  29908. this.cache = Buffer.allocUnsafe(0);
  29909. } // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
  29910. // by Juho Vähä-Herttua
  29911. GHASH.prototype.ghash = function (block) {
  29912. var i = -1;
  29913. while (++i < block.length) {
  29914. this.state[i] ^= block[i];
  29915. }
  29916. this._multiply();
  29917. };
  29918. GHASH.prototype._multiply = function () {
  29919. var Vi = toArray(this.h);
  29920. var Zi = [0, 0, 0, 0];
  29921. var j, xi, lsbVi;
  29922. var i = -1;
  29923. while (++i < 128) {
  29924. xi = (this.state[~~(i / 8)] & 1 << 7 - i % 8) !== 0;
  29925. if (xi) {
  29926. // Z_i+1 = Z_i ^ V_i
  29927. Zi[0] ^= Vi[0];
  29928. Zi[1] ^= Vi[1];
  29929. Zi[2] ^= Vi[2];
  29930. Zi[3] ^= Vi[3];
  29931. } // Store the value of LSB(V_i)
  29932. lsbVi = (Vi[3] & 1) !== 0; // V_i+1 = V_i >> 1
  29933. for (j = 3; j > 0; j--) {
  29934. Vi[j] = Vi[j] >>> 1 | (Vi[j - 1] & 1) << 31;
  29935. }
  29936. Vi[0] = Vi[0] >>> 1; // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
  29937. if (lsbVi) {
  29938. Vi[0] = Vi[0] ^ 0xe1 << 24;
  29939. }
  29940. }
  29941. this.state = fromArray(Zi);
  29942. };
  29943. GHASH.prototype.update = function (buf) {
  29944. this.cache = Buffer.concat([this.cache, buf]);
  29945. var chunk;
  29946. while (this.cache.length >= 16) {
  29947. chunk = this.cache.slice(0, 16);
  29948. this.cache = this.cache.slice(16);
  29949. this.ghash(chunk);
  29950. }
  29951. };
  29952. GHASH.prototype.final = function (abl, bl) {
  29953. if (this.cache.length) {
  29954. this.ghash(Buffer.concat([this.cache, ZEROES], 16));
  29955. }
  29956. this.ghash(fromArray([0, abl, 0, bl]));
  29957. return this.state;
  29958. };
  29959. module.exports = GHASH;
  29960. }, { "safe-buffer": 494 }], 192: [function (require, module, exports) {
  29961. "use strict";
  29962. function incr32(iv) {
  29963. var len = iv.length;
  29964. var item;
  29965. while (len--) {
  29966. item = iv.readUInt8(len);
  29967. if (item === 255) {
  29968. iv.writeUInt8(0, len);
  29969. } else {
  29970. item++;
  29971. iv.writeUInt8(item, len);
  29972. break;
  29973. }
  29974. }
  29975. }
  29976. module.exports = incr32;
  29977. }, {}], 193: [function (require, module, exports) {
  29978. "use strict";
  29979. var xor = require('buffer-xor');
  29980. exports.encrypt = function (self, block) {
  29981. var data = xor(block, self._prev);
  29982. self._prev = self._cipher.encryptBlock(data);
  29983. return self._prev;
  29984. };
  29985. exports.decrypt = function (self, block) {
  29986. var pad = self._prev;
  29987. self._prev = block;
  29988. var out = self._cipher.decryptBlock(block);
  29989. return xor(out, pad);
  29990. };
  29991. }, { "buffer-xor": 217 }], 194: [function (require, module, exports) {
  29992. "use strict";
  29993. var Buffer = require('safe-buffer').Buffer;
  29994. var xor = require('buffer-xor');
  29995. function encryptStart(self, data, decrypt) {
  29996. var len = data.length;
  29997. var out = xor(data, self._cache);
  29998. self._cache = self._cache.slice(len);
  29999. self._prev = Buffer.concat([self._prev, decrypt ? data : out]);
  30000. return out;
  30001. }
  30002. exports.encrypt = function (self, data, decrypt) {
  30003. var out = Buffer.allocUnsafe(0);
  30004. var len;
  30005. while (data.length) {
  30006. if (self._cache.length === 0) {
  30007. self._cache = self._cipher.encryptBlock(self._prev);
  30008. self._prev = Buffer.allocUnsafe(0);
  30009. }
  30010. if (self._cache.length <= data.length) {
  30011. len = self._cache.length;
  30012. out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)]);
  30013. data = data.slice(len);
  30014. } else {
  30015. out = Buffer.concat([out, encryptStart(self, data, decrypt)]);
  30016. break;
  30017. }
  30018. }
  30019. return out;
  30020. };
  30021. }, { "buffer-xor": 217, "safe-buffer": 494 }], 195: [function (require, module, exports) {
  30022. "use strict";
  30023. var Buffer = require('safe-buffer').Buffer;
  30024. function encryptByte(self, byteParam, decrypt) {
  30025. var pad;
  30026. var i = -1;
  30027. var len = 8;
  30028. var out = 0;
  30029. var bit, value;
  30030. while (++i < len) {
  30031. pad = self._cipher.encryptBlock(self._prev);
  30032. bit = byteParam & 1 << 7 - i ? 0x80 : 0;
  30033. value = pad[0] ^ bit;
  30034. out += (value & 0x80) >> i % 8;
  30035. self._prev = shiftIn(self._prev, decrypt ? bit : value);
  30036. }
  30037. return out;
  30038. }
  30039. function shiftIn(buffer, value) {
  30040. var len = buffer.length;
  30041. var i = -1;
  30042. var out = Buffer.allocUnsafe(buffer.length);
  30043. buffer = Buffer.concat([buffer, Buffer.from([value])]);
  30044. while (++i < len) {
  30045. out[i] = buffer[i] << 1 | buffer[i + 1] >> 7;
  30046. }
  30047. return out;
  30048. }
  30049. exports.encrypt = function (self, chunk, decrypt) {
  30050. var len = chunk.length;
  30051. var out = Buffer.allocUnsafe(len);
  30052. var i = -1;
  30053. while (++i < len) {
  30054. out[i] = encryptByte(self, chunk[i], decrypt);
  30055. }
  30056. return out;
  30057. };
  30058. }, { "safe-buffer": 494 }], 196: [function (require, module, exports) {
  30059. "use strict";
  30060. var Buffer = require('safe-buffer').Buffer;
  30061. function encryptByte(self, byteParam, decrypt) {
  30062. var pad = self._cipher.encryptBlock(self._prev);
  30063. var out = pad[0] ^ byteParam;
  30064. self._prev = Buffer.concat([self._prev.slice(1), Buffer.from([decrypt ? byteParam : out])]);
  30065. return out;
  30066. }
  30067. exports.encrypt = function (self, chunk, decrypt) {
  30068. var len = chunk.length;
  30069. var out = Buffer.allocUnsafe(len);
  30070. var i = -1;
  30071. while (++i < len) {
  30072. out[i] = encryptByte(self, chunk[i], decrypt);
  30073. }
  30074. return out;
  30075. };
  30076. }, { "safe-buffer": 494 }], 197: [function (require, module, exports) {
  30077. "use strict";
  30078. var xor = require('buffer-xor');
  30079. var Buffer = require('safe-buffer').Buffer;
  30080. var incr32 = require('../incr32');
  30081. function getBlock(self) {
  30082. var out = self._cipher.encryptBlockRaw(self._prev);
  30083. incr32(self._prev);
  30084. return out;
  30085. }
  30086. var blockSize = 16;
  30087. exports.encrypt = function (self, chunk) {
  30088. var chunkNum = Math.ceil(chunk.length / blockSize);
  30089. var start = self._cache.length;
  30090. self._cache = Buffer.concat([self._cache, Buffer.allocUnsafe(chunkNum * blockSize)]);
  30091. for (var i = 0; i < chunkNum; i++) {
  30092. var out = getBlock(self);
  30093. var offset = start + i * blockSize;
  30094. self._cache.writeUInt32BE(out[0], offset + 0);
  30095. self._cache.writeUInt32BE(out[1], offset + 4);
  30096. self._cache.writeUInt32BE(out[2], offset + 8);
  30097. self._cache.writeUInt32BE(out[3], offset + 12);
  30098. }
  30099. var pad = self._cache.slice(0, chunk.length);
  30100. self._cache = self._cache.slice(chunk.length);
  30101. return xor(chunk, pad);
  30102. };
  30103. }, { "../incr32": 192, "buffer-xor": 217, "safe-buffer": 494 }], 198: [function (require, module, exports) {
  30104. "use strict";
  30105. exports.encrypt = function (self, block) {
  30106. return self._cipher.encryptBlock(block);
  30107. };
  30108. exports.decrypt = function (self, block) {
  30109. return self._cipher.decryptBlock(block);
  30110. };
  30111. }, {}], 199: [function (require, module, exports) {
  30112. "use strict";
  30113. var modeModules = {
  30114. ECB: require('./ecb'),
  30115. CBC: require('./cbc'),
  30116. CFB: require('./cfb'),
  30117. CFB8: require('./cfb8'),
  30118. CFB1: require('./cfb1'),
  30119. OFB: require('./ofb'),
  30120. CTR: require('./ctr'),
  30121. GCM: require('./ctr')
  30122. };
  30123. var modes = require('./list.json');
  30124. for (var key in modes) {
  30125. modes[key].module = modeModules[modes[key].mode];
  30126. }
  30127. module.exports = modes;
  30128. }, { "./cbc": 193, "./cfb": 194, "./cfb1": 195, "./cfb8": 196, "./ctr": 197, "./ecb": 198, "./list.json": 200, "./ofb": 201 }], 200: [function (require, module, exports) {
  30129. module.exports = {
  30130. "aes-128-ecb": {
  30131. "cipher": "AES",
  30132. "key": 128,
  30133. "iv": 0,
  30134. "mode": "ECB",
  30135. "type": "block"
  30136. },
  30137. "aes-192-ecb": {
  30138. "cipher": "AES",
  30139. "key": 192,
  30140. "iv": 0,
  30141. "mode": "ECB",
  30142. "type": "block"
  30143. },
  30144. "aes-256-ecb": {
  30145. "cipher": "AES",
  30146. "key": 256,
  30147. "iv": 0,
  30148. "mode": "ECB",
  30149. "type": "block"
  30150. },
  30151. "aes-128-cbc": {
  30152. "cipher": "AES",
  30153. "key": 128,
  30154. "iv": 16,
  30155. "mode": "CBC",
  30156. "type": "block"
  30157. },
  30158. "aes-192-cbc": {
  30159. "cipher": "AES",
  30160. "key": 192,
  30161. "iv": 16,
  30162. "mode": "CBC",
  30163. "type": "block"
  30164. },
  30165. "aes-256-cbc": {
  30166. "cipher": "AES",
  30167. "key": 256,
  30168. "iv": 16,
  30169. "mode": "CBC",
  30170. "type": "block"
  30171. },
  30172. "aes128": {
  30173. "cipher": "AES",
  30174. "key": 128,
  30175. "iv": 16,
  30176. "mode": "CBC",
  30177. "type": "block"
  30178. },
  30179. "aes192": {
  30180. "cipher": "AES",
  30181. "key": 192,
  30182. "iv": 16,
  30183. "mode": "CBC",
  30184. "type": "block"
  30185. },
  30186. "aes256": {
  30187. "cipher": "AES",
  30188. "key": 256,
  30189. "iv": 16,
  30190. "mode": "CBC",
  30191. "type": "block"
  30192. },
  30193. "aes-128-cfb": {
  30194. "cipher": "AES",
  30195. "key": 128,
  30196. "iv": 16,
  30197. "mode": "CFB",
  30198. "type": "stream"
  30199. },
  30200. "aes-192-cfb": {
  30201. "cipher": "AES",
  30202. "key": 192,
  30203. "iv": 16,
  30204. "mode": "CFB",
  30205. "type": "stream"
  30206. },
  30207. "aes-256-cfb": {
  30208. "cipher": "AES",
  30209. "key": 256,
  30210. "iv": 16,
  30211. "mode": "CFB",
  30212. "type": "stream"
  30213. },
  30214. "aes-128-cfb8": {
  30215. "cipher": "AES",
  30216. "key": 128,
  30217. "iv": 16,
  30218. "mode": "CFB8",
  30219. "type": "stream"
  30220. },
  30221. "aes-192-cfb8": {
  30222. "cipher": "AES",
  30223. "key": 192,
  30224. "iv": 16,
  30225. "mode": "CFB8",
  30226. "type": "stream"
  30227. },
  30228. "aes-256-cfb8": {
  30229. "cipher": "AES",
  30230. "key": 256,
  30231. "iv": 16,
  30232. "mode": "CFB8",
  30233. "type": "stream"
  30234. },
  30235. "aes-128-cfb1": {
  30236. "cipher": "AES",
  30237. "key": 128,
  30238. "iv": 16,
  30239. "mode": "CFB1",
  30240. "type": "stream"
  30241. },
  30242. "aes-192-cfb1": {
  30243. "cipher": "AES",
  30244. "key": 192,
  30245. "iv": 16,
  30246. "mode": "CFB1",
  30247. "type": "stream"
  30248. },
  30249. "aes-256-cfb1": {
  30250. "cipher": "AES",
  30251. "key": 256,
  30252. "iv": 16,
  30253. "mode": "CFB1",
  30254. "type": "stream"
  30255. },
  30256. "aes-128-ofb": {
  30257. "cipher": "AES",
  30258. "key": 128,
  30259. "iv": 16,
  30260. "mode": "OFB",
  30261. "type": "stream"
  30262. },
  30263. "aes-192-ofb": {
  30264. "cipher": "AES",
  30265. "key": 192,
  30266. "iv": 16,
  30267. "mode": "OFB",
  30268. "type": "stream"
  30269. },
  30270. "aes-256-ofb": {
  30271. "cipher": "AES",
  30272. "key": 256,
  30273. "iv": 16,
  30274. "mode": "OFB",
  30275. "type": "stream"
  30276. },
  30277. "aes-128-ctr": {
  30278. "cipher": "AES",
  30279. "key": 128,
  30280. "iv": 16,
  30281. "mode": "CTR",
  30282. "type": "stream"
  30283. },
  30284. "aes-192-ctr": {
  30285. "cipher": "AES",
  30286. "key": 192,
  30287. "iv": 16,
  30288. "mode": "CTR",
  30289. "type": "stream"
  30290. },
  30291. "aes-256-ctr": {
  30292. "cipher": "AES",
  30293. "key": 256,
  30294. "iv": 16,
  30295. "mode": "CTR",
  30296. "type": "stream"
  30297. },
  30298. "aes-128-gcm": {
  30299. "cipher": "AES",
  30300. "key": 128,
  30301. "iv": 12,
  30302. "mode": "GCM",
  30303. "type": "auth"
  30304. },
  30305. "aes-192-gcm": {
  30306. "cipher": "AES",
  30307. "key": 192,
  30308. "iv": 12,
  30309. "mode": "GCM",
  30310. "type": "auth"
  30311. },
  30312. "aes-256-gcm": {
  30313. "cipher": "AES",
  30314. "key": 256,
  30315. "iv": 12,
  30316. "mode": "GCM",
  30317. "type": "auth"
  30318. }
  30319. }
  30320. }, {}], 201: [function (require, module, exports) {
  30321. (function (Buffer) {
  30322. "use strict";
  30323. var xor = require('buffer-xor');
  30324. function getBlock(self) {
  30325. self._prev = self._cipher.encryptBlock(self._prev);
  30326. return self._prev;
  30327. }
  30328. exports.encrypt = function (self, chunk) {
  30329. while (self._cache.length < chunk.length) {
  30330. self._cache = Buffer.concat([self._cache, getBlock(self)]);
  30331. }
  30332. var pad = self._cache.slice(0, chunk.length);
  30333. self._cache = self._cache.slice(chunk.length);
  30334. return xor(chunk, pad);
  30335. };
  30336. }).call(this, require("buffer").Buffer)
  30337. }, { "buffer": 216, "buffer-xor": 217 }], 202: [function (require, module, exports) {
  30338. "use strict";
  30339. var aes = require('./aes');
  30340. var Buffer = require('safe-buffer').Buffer;
  30341. var Transform = require('cipher-base');
  30342. var inherits = require('inherits');
  30343. function StreamCipher(mode, key, iv, decrypt) {
  30344. Transform.call(this);
  30345. this._cipher = new aes.AES(key);
  30346. this._prev = Buffer.from(iv);
  30347. this._cache = Buffer.allocUnsafe(0);
  30348. this._secCache = Buffer.allocUnsafe(0);
  30349. this._decrypt = decrypt;
  30350. this._mode = mode;
  30351. }
  30352. inherits(StreamCipher, Transform);
  30353. StreamCipher.prototype._update = function (chunk) {
  30354. return this._mode.encrypt(this, chunk, this._decrypt);
  30355. };
  30356. StreamCipher.prototype._final = function () {
  30357. this._cipher.scrub();
  30358. };
  30359. module.exports = StreamCipher;
  30360. }, { "./aes": 186, "cipher-base": 218, "inherits": 387, "safe-buffer": 494 }], 203: [function (require, module, exports) {
  30361. "use strict";
  30362. var DES = require('browserify-des');
  30363. var aes = require('browserify-aes/browser');
  30364. var aesModes = require('browserify-aes/modes');
  30365. var desModes = require('browserify-des/modes');
  30366. var ebtk = require('evp_bytestokey');
  30367. function createCipher(suite, password) {
  30368. suite = suite.toLowerCase();
  30369. var keyLen, ivLen;
  30370. if (aesModes[suite]) {
  30371. keyLen = aesModes[suite].key;
  30372. ivLen = aesModes[suite].iv;
  30373. } else if (desModes[suite]) {
  30374. keyLen = desModes[suite].key * 8;
  30375. ivLen = desModes[suite].iv;
  30376. } else {
  30377. throw new TypeError('invalid suite type');
  30378. }
  30379. var keys = ebtk(password, false, keyLen, ivLen);
  30380. return createCipheriv(suite, keys.key, keys.iv);
  30381. }
  30382. function createDecipher(suite, password) {
  30383. suite = suite.toLowerCase();
  30384. var keyLen, ivLen;
  30385. if (aesModes[suite]) {
  30386. keyLen = aesModes[suite].key;
  30387. ivLen = aesModes[suite].iv;
  30388. } else if (desModes[suite]) {
  30389. keyLen = desModes[suite].key * 8;
  30390. ivLen = desModes[suite].iv;
  30391. } else {
  30392. throw new TypeError('invalid suite type');
  30393. }
  30394. var keys = ebtk(password, false, keyLen, ivLen);
  30395. return createDecipheriv(suite, keys.key, keys.iv);
  30396. }
  30397. function createCipheriv(suite, key, iv) {
  30398. suite = suite.toLowerCase();
  30399. if (aesModes[suite]) return aes.createCipheriv(suite, key, iv);
  30400. if (desModes[suite]) return new DES({
  30401. key: key,
  30402. iv: iv,
  30403. mode: suite
  30404. });
  30405. throw new TypeError('invalid suite type');
  30406. }
  30407. function createDecipheriv(suite, key, iv) {
  30408. suite = suite.toLowerCase();
  30409. if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv);
  30410. if (desModes[suite]) return new DES({
  30411. key: key,
  30412. iv: iv,
  30413. mode: suite,
  30414. decrypt: true
  30415. });
  30416. throw new TypeError('invalid suite type');
  30417. }
  30418. function getCiphers() {
  30419. return Object.keys(desModes).concat(aes.getCiphers());
  30420. }
  30421. exports.createCipher = exports.Cipher = createCipher;
  30422. exports.createCipheriv = exports.Cipheriv = createCipheriv;
  30423. exports.createDecipher = exports.Decipher = createDecipher;
  30424. exports.createDecipheriv = exports.Decipheriv = createDecipheriv;
  30425. exports.listCiphers = exports.getCiphers = getCiphers;
  30426. }, { "browserify-aes/browser": 188, "browserify-aes/modes": 199, "browserify-des": 204, "browserify-des/modes": 205, "evp_bytestokey": 368 }], 204: [function (require, module, exports) {
  30427. "use strict";
  30428. var CipherBase = require('cipher-base');
  30429. var des = require('des.js');
  30430. var inherits = require('inherits');
  30431. var Buffer = require('safe-buffer').Buffer;
  30432. var modes = {
  30433. 'des-ede3-cbc': des.CBC.instantiate(des.EDE),
  30434. 'des-ede3': des.EDE,
  30435. 'des-ede-cbc': des.CBC.instantiate(des.EDE),
  30436. 'des-ede': des.EDE,
  30437. 'des-cbc': des.CBC.instantiate(des.DES),
  30438. 'des-ecb': des.DES
  30439. };
  30440. modes.des = modes['des-cbc'];
  30441. modes.des3 = modes['des-ede3-cbc'];
  30442. module.exports = DES;
  30443. inherits(DES, CipherBase);
  30444. function DES(opts) {
  30445. CipherBase.call(this);
  30446. var modeName = opts.mode.toLowerCase();
  30447. var mode = modes[modeName];
  30448. var type;
  30449. if (opts.decrypt) {
  30450. type = 'decrypt';
  30451. } else {
  30452. type = 'encrypt';
  30453. }
  30454. var key = opts.key;
  30455. if (!Buffer.isBuffer(key)) {
  30456. key = Buffer.from(key);
  30457. }
  30458. if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
  30459. key = Buffer.concat([key, key.slice(0, 8)]);
  30460. }
  30461. var iv = opts.iv;
  30462. if (!Buffer.isBuffer(iv)) {
  30463. iv = Buffer.from(iv);
  30464. }
  30465. this._des = mode.create({
  30466. key: key,
  30467. iv: iv,
  30468. type: type
  30469. });
  30470. }
  30471. DES.prototype._update = function (data) {
  30472. return Buffer.from(this._des.update(data));
  30473. };
  30474. DES.prototype._final = function () {
  30475. return Buffer.from(this._des.final());
  30476. };
  30477. }, { "cipher-base": 218, "des.js": 339, "inherits": 387, "safe-buffer": 494 }], 205: [function (require, module, exports) {
  30478. "use strict";
  30479. exports['des-ecb'] = {
  30480. key: 8,
  30481. iv: 0
  30482. };
  30483. exports['des-cbc'] = exports.des = {
  30484. key: 8,
  30485. iv: 8
  30486. };
  30487. exports['des-ede3-cbc'] = exports.des3 = {
  30488. key: 24,
  30489. iv: 8
  30490. };
  30491. exports['des-ede3'] = {
  30492. key: 24,
  30493. iv: 0
  30494. };
  30495. exports['des-ede-cbc'] = {
  30496. key: 16,
  30497. iv: 8
  30498. };
  30499. exports['des-ede'] = {
  30500. key: 16,
  30501. iv: 0
  30502. };
  30503. }, {}], 206: [function (require, module, exports) {
  30504. (function (Buffer) {
  30505. "use strict";
  30506. var bn = require('bn.js');
  30507. var randomBytes = require('randombytes');
  30508. module.exports = crt;
  30509. function blind(priv) {
  30510. var r = getr(priv);
  30511. var blinder = r.toRed(bn.mont(priv.modulus)).redPow(new bn(priv.publicExponent)).fromRed();
  30512. return {
  30513. blinder: blinder,
  30514. unblinder: r.invm(priv.modulus)
  30515. };
  30516. }
  30517. function crt(msg, priv) {
  30518. var blinds = blind(priv);
  30519. var len = priv.modulus.byteLength();
  30520. var mod = bn.mont(priv.modulus);
  30521. var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
  30522. var c1 = blinded.toRed(bn.mont(priv.prime1));
  30523. var c2 = blinded.toRed(bn.mont(priv.prime2));
  30524. var qinv = priv.coefficient;
  30525. var p = priv.prime1;
  30526. var q = priv.prime2;
  30527. var m1 = c1.redPow(priv.exponent1);
  30528. var m2 = c2.redPow(priv.exponent2);
  30529. m1 = m1.fromRed();
  30530. m2 = m2.fromRed();
  30531. var h = m1.isub(m2).imul(qinv).umod(p);
  30532. h.imul(q);
  30533. m2.iadd(h);
  30534. return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
  30535. }
  30536. crt.getr = getr;
  30537. function getr(priv) {
  30538. var len = priv.modulus.byteLength();
  30539. var r = new bn(randomBytes(len));
  30540. while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
  30541. r = new bn(randomBytes(len));
  30542. }
  30543. return r;
  30544. }
  30545. }).call(this, require("buffer").Buffer)
  30546. }, { "bn.js": 207, "buffer": 216, "randombytes": 475 }], 207: [function (require, module, exports) {
  30547. arguments[4][181][0].apply(exports, arguments)
  30548. }, { "buffer": 185, "dup": 181 }], 208: [function (require, module, exports) {
  30549. "use strict";
  30550. module.exports = require('./browser/algorithms.json');
  30551. }, { "./browser/algorithms.json": 209 }], 209: [function (require, module, exports) {
  30552. module.exports = {
  30553. "sha224WithRSAEncryption": {
  30554. "sign": "rsa",
  30555. "hash": "sha224",
  30556. "id": "302d300d06096086480165030402040500041c"
  30557. },
  30558. "RSA-SHA224": {
  30559. "sign": "ecdsa/rsa",
  30560. "hash": "sha224",
  30561. "id": "302d300d06096086480165030402040500041c"
  30562. },
  30563. "sha256WithRSAEncryption": {
  30564. "sign": "rsa",
  30565. "hash": "sha256",
  30566. "id": "3031300d060960864801650304020105000420"
  30567. },
  30568. "RSA-SHA256": {
  30569. "sign": "ecdsa/rsa",
  30570. "hash": "sha256",
  30571. "id": "3031300d060960864801650304020105000420"
  30572. },
  30573. "sha384WithRSAEncryption": {
  30574. "sign": "rsa",
  30575. "hash": "sha384",
  30576. "id": "3041300d060960864801650304020205000430"
  30577. },
  30578. "RSA-SHA384": {
  30579. "sign": "ecdsa/rsa",
  30580. "hash": "sha384",
  30581. "id": "3041300d060960864801650304020205000430"
  30582. },
  30583. "sha512WithRSAEncryption": {
  30584. "sign": "rsa",
  30585. "hash": "sha512",
  30586. "id": "3051300d060960864801650304020305000440"
  30587. },
  30588. "RSA-SHA512": {
  30589. "sign": "ecdsa/rsa",
  30590. "hash": "sha512",
  30591. "id": "3051300d060960864801650304020305000440"
  30592. },
  30593. "RSA-SHA1": {
  30594. "sign": "rsa",
  30595. "hash": "sha1",
  30596. "id": "3021300906052b0e03021a05000414"
  30597. },
  30598. "ecdsa-with-SHA1": {
  30599. "sign": "ecdsa",
  30600. "hash": "sha1",
  30601. "id": ""
  30602. },
  30603. "sha256": {
  30604. "sign": "ecdsa",
  30605. "hash": "sha256",
  30606. "id": ""
  30607. },
  30608. "sha224": {
  30609. "sign": "ecdsa",
  30610. "hash": "sha224",
  30611. "id": ""
  30612. },
  30613. "sha384": {
  30614. "sign": "ecdsa",
  30615. "hash": "sha384",
  30616. "id": ""
  30617. },
  30618. "sha512": {
  30619. "sign": "ecdsa",
  30620. "hash": "sha512",
  30621. "id": ""
  30622. },
  30623. "DSA-SHA": {
  30624. "sign": "dsa",
  30625. "hash": "sha1",
  30626. "id": ""
  30627. },
  30628. "DSA-SHA1": {
  30629. "sign": "dsa",
  30630. "hash": "sha1",
  30631. "id": ""
  30632. },
  30633. "DSA": {
  30634. "sign": "dsa",
  30635. "hash": "sha1",
  30636. "id": ""
  30637. },
  30638. "DSA-WITH-SHA224": {
  30639. "sign": "dsa",
  30640. "hash": "sha224",
  30641. "id": ""
  30642. },
  30643. "DSA-SHA224": {
  30644. "sign": "dsa",
  30645. "hash": "sha224",
  30646. "id": ""
  30647. },
  30648. "DSA-WITH-SHA256": {
  30649. "sign": "dsa",
  30650. "hash": "sha256",
  30651. "id": ""
  30652. },
  30653. "DSA-SHA256": {
  30654. "sign": "dsa",
  30655. "hash": "sha256",
  30656. "id": ""
  30657. },
  30658. "DSA-WITH-SHA384": {
  30659. "sign": "dsa",
  30660. "hash": "sha384",
  30661. "id": ""
  30662. },
  30663. "DSA-SHA384": {
  30664. "sign": "dsa",
  30665. "hash": "sha384",
  30666. "id": ""
  30667. },
  30668. "DSA-WITH-SHA512": {
  30669. "sign": "dsa",
  30670. "hash": "sha512",
  30671. "id": ""
  30672. },
  30673. "DSA-SHA512": {
  30674. "sign": "dsa",
  30675. "hash": "sha512",
  30676. "id": ""
  30677. },
  30678. "DSA-RIPEMD160": {
  30679. "sign": "dsa",
  30680. "hash": "rmd160",
  30681. "id": ""
  30682. },
  30683. "ripemd160WithRSA": {
  30684. "sign": "rsa",
  30685. "hash": "rmd160",
  30686. "id": "3021300906052b2403020105000414"
  30687. },
  30688. "RSA-RIPEMD160": {
  30689. "sign": "rsa",
  30690. "hash": "rmd160",
  30691. "id": "3021300906052b2403020105000414"
  30692. },
  30693. "md5WithRSAEncryption": {
  30694. "sign": "rsa",
  30695. "hash": "md5",
  30696. "id": "3020300c06082a864886f70d020505000410"
  30697. },
  30698. "RSA-MD5": {
  30699. "sign": "rsa",
  30700. "hash": "md5",
  30701. "id": "3020300c06082a864886f70d020505000410"
  30702. }
  30703. }
  30704. }, {}], 210: [function (require, module, exports) {
  30705. module.exports = {
  30706. "1.3.132.0.10": "secp256k1",
  30707. "1.3.132.0.33": "p224",
  30708. "1.2.840.10045.3.1.1": "p192",
  30709. "1.2.840.10045.3.1.7": "p256",
  30710. "1.3.132.0.34": "p384",
  30711. "1.3.132.0.35": "p521"
  30712. }
  30713. }, {}], 211: [function (require, module, exports) {
  30714. "use strict";
  30715. var Buffer = require('safe-buffer').Buffer;
  30716. var createHash = require('create-hash');
  30717. var stream = require('readable-stream');
  30718. var inherits = require('inherits');
  30719. var sign = require('./sign');
  30720. var verify = require('./verify');
  30721. var algorithms = require('./algorithms.json');
  30722. Object.keys(algorithms).forEach(function (key) {
  30723. algorithms[key].id = Buffer.from(algorithms[key].id, 'hex');
  30724. algorithms[key.toLowerCase()] = algorithms[key];
  30725. });
  30726. function Sign(algorithm) {
  30727. stream.Writable.call(this);
  30728. var data = algorithms[algorithm];
  30729. if (!data) throw new Error('Unknown message digest');
  30730. this._hashType = data.hash;
  30731. this._hash = createHash(data.hash);
  30732. this._tag = data.id;
  30733. this._signType = data.sign;
  30734. }
  30735. inherits(Sign, stream.Writable);
  30736. Sign.prototype._write = function _write(data, _, done) {
  30737. this._hash.update(data);
  30738. done();
  30739. };
  30740. Sign.prototype.update = function update(data, enc) {
  30741. if (typeof data === 'string') data = Buffer.from(data, enc);
  30742. this._hash.update(data);
  30743. return this;
  30744. };
  30745. Sign.prototype.sign = function signMethod(key, enc) {
  30746. this.end();
  30747. var hash = this._hash.digest();
  30748. var sig = sign(hash, key, this._hashType, this._signType, this._tag);
  30749. return enc ? sig.toString(enc) : sig;
  30750. };
  30751. function Verify(algorithm) {
  30752. stream.Writable.call(this);
  30753. var data = algorithms[algorithm];
  30754. if (!data) throw new Error('Unknown message digest');
  30755. this._hash = createHash(data.hash);
  30756. this._tag = data.id;
  30757. this._signType = data.sign;
  30758. }
  30759. inherits(Verify, stream.Writable);
  30760. Verify.prototype._write = function _write(data, _, done) {
  30761. this._hash.update(data);
  30762. done();
  30763. };
  30764. Verify.prototype.update = function update(data, enc) {
  30765. if (typeof data === 'string') data = Buffer.from(data, enc);
  30766. this._hash.update(data);
  30767. return this;
  30768. };
  30769. Verify.prototype.verify = function verifyMethod(key, sig, enc) {
  30770. if (typeof sig === 'string') sig = Buffer.from(sig, enc);
  30771. this.end();
  30772. var hash = this._hash.digest();
  30773. return verify(sig, hash, key, this._signType, this._tag);
  30774. };
  30775. function createSign(algorithm) {
  30776. return new Sign(algorithm);
  30777. }
  30778. function createVerify(algorithm) {
  30779. return new Verify(algorithm);
  30780. }
  30781. module.exports = {
  30782. Sign: createSign,
  30783. Verify: createVerify,
  30784. createSign: createSign,
  30785. createVerify: createVerify
  30786. };
  30787. }, { "./algorithms.json": 209, "./sign": 212, "./verify": 213, "create-hash": 331, "inherits": 387, "readable-stream": 491, "safe-buffer": 214 }], 212: [function (require, module, exports) {
  30788. "use strict";
  30789. // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
  30790. var Buffer = require('safe-buffer').Buffer;
  30791. var createHmac = require('create-hmac');
  30792. var crt = require('browserify-rsa');
  30793. var EC = require('elliptic').ec;
  30794. var BN = require('bn.js');
  30795. var parseKeys = require('parse-asn1');
  30796. var curves = require('./curves.json');
  30797. function sign(hash, key, hashType, signType, tag) {
  30798. var priv = parseKeys(key);
  30799. if (priv.curve) {
  30800. // rsa keys can be interpreted as ecdsa ones in openssl
  30801. if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type');
  30802. return ecSign(hash, priv);
  30803. } else if (priv.type === 'dsa') {
  30804. if (signType !== 'dsa') throw new Error('wrong private key type');
  30805. return dsaSign(hash, priv, hashType);
  30806. } else {
  30807. if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type');
  30808. }
  30809. hash = Buffer.concat([tag, hash]);
  30810. var len = priv.modulus.byteLength();
  30811. var pad = [0, 1];
  30812. while (hash.length + pad.length + 1 < len) {
  30813. pad.push(0xff);
  30814. }
  30815. pad.push(0x00);
  30816. var i = -1;
  30817. while (++i < hash.length) {
  30818. pad.push(hash[i]);
  30819. }
  30820. var out = crt(pad, priv);
  30821. return out;
  30822. }
  30823. function ecSign(hash, priv) {
  30824. var curveId = curves[priv.curve.join('.')];
  30825. if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'));
  30826. var curve = new EC(curveId);
  30827. var key = curve.keyFromPrivate(priv.privateKey);
  30828. var out = key.sign(hash);
  30829. return Buffer.from(out.toDER());
  30830. }
  30831. function dsaSign(hash, priv, algo) {
  30832. var x = priv.params.priv_key;
  30833. var p = priv.params.p;
  30834. var q = priv.params.q;
  30835. var g = priv.params.g;
  30836. var r = new BN(0);
  30837. var k;
  30838. var H = bits2int(hash, q).mod(q);
  30839. var s = false;
  30840. var kv = getKey(x, q, hash, algo);
  30841. while (s === false) {
  30842. k = makeKey(q, kv, algo);
  30843. r = makeR(g, k, p, q);
  30844. s = k.invm(q).imul(H.add(x.mul(r))).mod(q);
  30845. if (s.cmpn(0) === 0) {
  30846. s = false;
  30847. r = new BN(0);
  30848. }
  30849. }
  30850. return toDER(r, s);
  30851. }
  30852. function toDER(r, s) {
  30853. r = r.toArray();
  30854. s = s.toArray(); // Pad values
  30855. if (r[0] & 0x80) r = [0].concat(r);
  30856. if (s[0] & 0x80) s = [0].concat(s);
  30857. var total = r.length + s.length + 4;
  30858. var res = [0x30, total, 0x02, r.length];
  30859. res = res.concat(r, [0x02, s.length], s);
  30860. return Buffer.from(res);
  30861. }
  30862. function getKey(x, q, hash, algo) {
  30863. x = Buffer.from(x.toArray());
  30864. if (x.length < q.byteLength()) {
  30865. var zeros = Buffer.alloc(q.byteLength() - x.length);
  30866. x = Buffer.concat([zeros, x]);
  30867. }
  30868. var hlen = hash.length;
  30869. var hbits = bits2octets(hash, q);
  30870. var v = Buffer.alloc(hlen);
  30871. v.fill(1);
  30872. var k = Buffer.alloc(hlen);
  30873. k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest();
  30874. v = createHmac(algo, k).update(v).digest();
  30875. k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest();
  30876. v = createHmac(algo, k).update(v).digest();
  30877. return {
  30878. k: k,
  30879. v: v
  30880. };
  30881. }
  30882. function bits2int(obits, q) {
  30883. var bits = new BN(obits);
  30884. var shift = (obits.length << 3) - q.bitLength();
  30885. if (shift > 0) bits.ishrn(shift);
  30886. return bits;
  30887. }
  30888. function bits2octets(bits, q) {
  30889. bits = bits2int(bits, q);
  30890. bits = bits.mod(q);
  30891. var out = Buffer.from(bits.toArray());
  30892. if (out.length < q.byteLength()) {
  30893. var zeros = Buffer.alloc(q.byteLength() - out.length);
  30894. out = Buffer.concat([zeros, out]);
  30895. }
  30896. return out;
  30897. }
  30898. function makeKey(q, kv, algo) {
  30899. var t;
  30900. var k;
  30901. do {
  30902. t = Buffer.alloc(0);
  30903. while (t.length * 8 < q.bitLength()) {
  30904. kv.v = createHmac(algo, kv.k).update(kv.v).digest();
  30905. t = Buffer.concat([t, kv.v]);
  30906. }
  30907. k = bits2int(t, q);
  30908. kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest();
  30909. kv.v = createHmac(algo, kv.k).update(kv.v).digest();
  30910. } while (k.cmp(q) !== -1);
  30911. return k;
  30912. }
  30913. function makeR(g, k, p, q) {
  30914. return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q);
  30915. }
  30916. module.exports = sign;
  30917. module.exports.getKey = getKey;
  30918. module.exports.makeKey = makeKey;
  30919. }, { "./curves.json": 210, "bn.js": 183, "browserify-rsa": 206, "create-hmac": 333, "elliptic": 350, "parse-asn1": 459, "safe-buffer": 214 }], 213: [function (require, module, exports) {
  30920. "use strict";
  30921. // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
  30922. var Buffer = require('safe-buffer').Buffer;
  30923. var BN = require('bn.js');
  30924. var EC = require('elliptic').ec;
  30925. var parseKeys = require('parse-asn1');
  30926. var curves = require('./curves.json');
  30927. function verify(sig, hash, key, signType, tag) {
  30928. var pub = parseKeys(key);
  30929. if (pub.type === 'ec') {
  30930. // rsa keys can be interpreted as ecdsa ones in openssl
  30931. if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type');
  30932. return ecVerify(sig, hash, pub);
  30933. } else if (pub.type === 'dsa') {
  30934. if (signType !== 'dsa') throw new Error('wrong public key type');
  30935. return dsaVerify(sig, hash, pub);
  30936. } else {
  30937. if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type');
  30938. }
  30939. hash = Buffer.concat([tag, hash]);
  30940. var len = pub.modulus.byteLength();
  30941. var pad = [1];
  30942. var padNum = 0;
  30943. while (hash.length + pad.length + 2 < len) {
  30944. pad.push(0xff);
  30945. padNum++;
  30946. }
  30947. pad.push(0x00);
  30948. var i = -1;
  30949. while (++i < hash.length) {
  30950. pad.push(hash[i]);
  30951. }
  30952. pad = Buffer.from(pad);
  30953. var red = BN.mont(pub.modulus);
  30954. sig = new BN(sig).toRed(red);
  30955. sig = sig.redPow(new BN(pub.publicExponent));
  30956. sig = Buffer.from(sig.fromRed().toArray());
  30957. var out = padNum < 8 ? 1 : 0;
  30958. len = Math.min(sig.length, pad.length);
  30959. if (sig.length !== pad.length) out = 1;
  30960. i = -1;
  30961. while (++i < len) {
  30962. out |= sig[i] ^ pad[i];
  30963. }
  30964. return out === 0;
  30965. }
  30966. function ecVerify(sig, hash, pub) {
  30967. var curveId = curves[pub.data.algorithm.curve.join('.')];
  30968. if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'));
  30969. var curve = new EC(curveId);
  30970. var pubkey = pub.data.subjectPrivateKey.data;
  30971. return curve.verify(hash, sig, pubkey);
  30972. }
  30973. function dsaVerify(sig, hash, pub) {
  30974. var p = pub.data.p;
  30975. var q = pub.data.q;
  30976. var g = pub.data.g;
  30977. var y = pub.data.pub_key;
  30978. var unpacked = parseKeys.signature.decode(sig, 'der');
  30979. var s = unpacked.s;
  30980. var r = unpacked.r;
  30981. checkValue(s, q);
  30982. checkValue(r, q);
  30983. var montp = BN.mont(p);
  30984. var w = s.invm(q);
  30985. var v = g.toRed(montp).redPow(new BN(hash).mul(w).mod(q)).fromRed().mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()).mod(p).mod(q);
  30986. return v.cmp(r) === 0;
  30987. }
  30988. function checkValue(b, q) {
  30989. if (b.cmpn(0) <= 0) throw new Error('invalid sig');
  30990. if (b.cmp(q) >= q) throw new Error('invalid sig');
  30991. }
  30992. module.exports = verify;
  30993. }, { "./curves.json": 210, "bn.js": 183, "elliptic": 350, "parse-asn1": 459, "safe-buffer": 214 }], 214: [function (require, module, exports) {
  30994. "use strict";
  30995. /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  30996. /* eslint-disable node/no-deprecated-api */
  30997. var buffer = require('buffer');
  30998. var Buffer = buffer.Buffer; // alternative to using Object.keys for old browsers
  30999. function copyProps(src, dst) {
  31000. for (var key in src) {
  31001. dst[key] = src[key];
  31002. }
  31003. }
  31004. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  31005. module.exports = buffer;
  31006. } else {
  31007. // Copy properties from require('buffer')
  31008. copyProps(buffer, exports);
  31009. exports.Buffer = SafeBuffer;
  31010. }
  31011. function SafeBuffer(arg, encodingOrOffset, length) {
  31012. return Buffer(arg, encodingOrOffset, length);
  31013. }
  31014. SafeBuffer.prototype = Object.create(Buffer.prototype); // Copy static methods from Buffer
  31015. copyProps(Buffer, SafeBuffer);
  31016. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  31017. if (typeof arg === 'number') {
  31018. throw new TypeError('Argument must not be a number');
  31019. }
  31020. return Buffer(arg, encodingOrOffset, length);
  31021. };
  31022. SafeBuffer.alloc = function (size, fill, encoding) {
  31023. if (typeof size !== 'number') {
  31024. throw new TypeError('Argument must be a number');
  31025. }
  31026. var buf = Buffer(size);
  31027. if (fill !== undefined) {
  31028. if (typeof encoding === 'string') {
  31029. buf.fill(fill, encoding);
  31030. } else {
  31031. buf.fill(fill);
  31032. }
  31033. } else {
  31034. buf.fill(0);
  31035. }
  31036. return buf;
  31037. };
  31038. SafeBuffer.allocUnsafe = function (size) {
  31039. if (typeof size !== 'number') {
  31040. throw new TypeError('Argument must be a number');
  31041. }
  31042. return Buffer(size);
  31043. };
  31044. SafeBuffer.allocUnsafeSlow = function (size) {
  31045. if (typeof size !== 'number') {
  31046. throw new TypeError('Argument must be a number');
  31047. }
  31048. return buffer.SlowBuffer(size);
  31049. };
  31050. }, { "buffer": 216 }], 215: [function (require, module, exports) {
  31051. arguments[4][185][0].apply(exports, arguments)
  31052. }, { "dup": 185 }], 216: [function (require, module, exports) {
  31053. (function (Buffer) {
  31054. /*!
  31055. * The buffer module from node.js, for the browser.
  31056. *
  31057. * @author Feross Aboukhadijeh <https://feross.org>
  31058. * @license MIT
  31059. */
  31060. /* eslint-disable no-proto */
  31061. 'use strict';
  31062. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  31063. var base64 = require('base64-js');
  31064. var ieee754 = require('ieee754');
  31065. exports.Buffer = Buffer;
  31066. exports.SlowBuffer = SlowBuffer;
  31067. exports.INSPECT_MAX_BYTES = 50;
  31068. var K_MAX_LENGTH = 0x7fffffff;
  31069. exports.kMaxLength = K_MAX_LENGTH;
  31070. /**
  31071. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  31072. * === true Use Uint8Array implementation (fastest)
  31073. * === false Print warning and recommend using `buffer` v4.x which has an Object
  31074. * implementation (most compatible, even IE6)
  31075. *
  31076. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  31077. * Opera 11.6+, iOS 4.2+.
  31078. *
  31079. * We report that the browser does not support typed arrays if the are not subclassable
  31080. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  31081. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  31082. * for __proto__ and has a buggy typed array implementation.
  31083. */
  31084. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
  31085. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && typeof console.error === 'function') {
  31086. console.error('This browser lacks typed array (Uint8Array) support which is required by ' + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.');
  31087. }
  31088. function typedArraySupport() {
  31089. // Can typed array instances can be augmented?
  31090. try {
  31091. var arr = new Uint8Array(1);
  31092. arr.__proto__ = {
  31093. __proto__: Uint8Array.prototype,
  31094. foo: function foo() {
  31095. return 42;
  31096. }
  31097. };
  31098. return arr.foo() === 42;
  31099. } catch (e) {
  31100. return false;
  31101. }
  31102. }
  31103. Object.defineProperty(Buffer.prototype, 'parent', {
  31104. enumerable: true,
  31105. get: function get() {
  31106. if (!Buffer.isBuffer(this)) return undefined;
  31107. return this.buffer;
  31108. }
  31109. });
  31110. Object.defineProperty(Buffer.prototype, 'offset', {
  31111. enumerable: true,
  31112. get: function get() {
  31113. if (!Buffer.isBuffer(this)) return undefined;
  31114. return this.byteOffset;
  31115. }
  31116. });
  31117. function createBuffer(length) {
  31118. if (length > K_MAX_LENGTH) {
  31119. throw new RangeError('The value "' + length + '" is invalid for option "size"');
  31120. } // Return an augmented `Uint8Array` instance
  31121. var buf = new Uint8Array(length);
  31122. buf.__proto__ = Buffer.prototype;
  31123. return buf;
  31124. }
  31125. /**
  31126. * The Buffer constructor returns instances of `Uint8Array` that have their
  31127. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  31128. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  31129. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  31130. * returns a single octet.
  31131. *
  31132. * The `Uint8Array` prototype remains unmodified.
  31133. */
  31134. function Buffer(arg, encodingOrOffset, length) {
  31135. // Common case.
  31136. if (typeof arg === 'number') {
  31137. if (typeof encodingOrOffset === 'string') {
  31138. throw new TypeError('The "string" argument must be of type string. Received type number');
  31139. }
  31140. return allocUnsafe(arg);
  31141. }
  31142. return from(arg, encodingOrOffset, length);
  31143. } // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  31144. if (typeof Symbol !== 'undefined' && Symbol.species != null && Buffer[Symbol.species] === Buffer) {
  31145. Object.defineProperty(Buffer, Symbol.species, {
  31146. value: null,
  31147. configurable: true,
  31148. enumerable: false,
  31149. writable: false
  31150. });
  31151. }
  31152. Buffer.poolSize = 8192; // not used by this implementation
  31153. function from(value, encodingOrOffset, length) {
  31154. if (typeof value === 'string') {
  31155. return fromString(value, encodingOrOffset);
  31156. }
  31157. if (ArrayBuffer.isView(value)) {
  31158. return fromArrayLike(value);
  31159. }
  31160. if (value == null) {
  31161. throw TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value));
  31162. }
  31163. if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
  31164. return fromArrayBuffer(value, encodingOrOffset, length);
  31165. }
  31166. if (typeof value === 'number') {
  31167. throw new TypeError('The "value" argument must not be of type number. Received type number');
  31168. }
  31169. var valueOf = value.valueOf && value.valueOf();
  31170. if (valueOf != null && valueOf !== value) {
  31171. return Buffer.from(valueOf, encodingOrOffset, length);
  31172. }
  31173. var b = fromObject(value);
  31174. if (b) return b;
  31175. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === 'function') {
  31176. return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length);
  31177. }
  31178. throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value));
  31179. }
  31180. /**
  31181. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  31182. * if value is a number.
  31183. * Buffer.from(str[, encoding])
  31184. * Buffer.from(array)
  31185. * Buffer.from(buffer)
  31186. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  31187. **/
  31188. Buffer.from = function (value, encodingOrOffset, length) {
  31189. return from(value, encodingOrOffset, length);
  31190. }; // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  31191. // https://github.com/feross/buffer/pull/148
  31192. Buffer.prototype.__proto__ = Uint8Array.prototype;
  31193. Buffer.__proto__ = Uint8Array;
  31194. function assertSize(size) {
  31195. if (typeof size !== 'number') {
  31196. throw new TypeError('"size" argument must be of type number');
  31197. } else if (size < 0) {
  31198. throw new RangeError('The value "' + size + '" is invalid for option "size"');
  31199. }
  31200. }
  31201. function alloc(size, fill, encoding) {
  31202. assertSize(size);
  31203. if (size <= 0) {
  31204. return createBuffer(size);
  31205. }
  31206. if (fill !== undefined) {
  31207. // Only pay attention to encoding if it's a string. This
  31208. // prevents accidentally sending in a number that would
  31209. // be interpretted as a start offset.
  31210. return typeof encoding === 'string' ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
  31211. }
  31212. return createBuffer(size);
  31213. }
  31214. /**
  31215. * Creates a new filled Buffer instance.
  31216. * alloc(size[, fill[, encoding]])
  31217. **/
  31218. Buffer.alloc = function (size, fill, encoding) {
  31219. return alloc(size, fill, encoding);
  31220. };
  31221. function allocUnsafe(size) {
  31222. assertSize(size);
  31223. return createBuffer(size < 0 ? 0 : checked(size) | 0);
  31224. }
  31225. /**
  31226. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  31227. * */
  31228. Buffer.allocUnsafe = function (size) {
  31229. return allocUnsafe(size);
  31230. };
  31231. /**
  31232. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  31233. */
  31234. Buffer.allocUnsafeSlow = function (size) {
  31235. return allocUnsafe(size);
  31236. };
  31237. function fromString(string, encoding) {
  31238. if (typeof encoding !== 'string' || encoding === '') {
  31239. encoding = 'utf8';
  31240. }
  31241. if (!Buffer.isEncoding(encoding)) {
  31242. throw new TypeError('Unknown encoding: ' + encoding);
  31243. }
  31244. var length = byteLength(string, encoding) | 0;
  31245. var buf = createBuffer(length);
  31246. var actual = buf.write(string, encoding);
  31247. if (actual !== length) {
  31248. // Writing a hex string, for example, that contains invalid characters will
  31249. // cause everything after the first invalid character to be ignored. (e.g.
  31250. // 'abxxcd' will be treated as 'ab')
  31251. buf = buf.slice(0, actual);
  31252. }
  31253. return buf;
  31254. }
  31255. function fromArrayLike(array) {
  31256. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  31257. var buf = createBuffer(length);
  31258. for (var i = 0; i < length; i += 1) {
  31259. buf[i] = array[i] & 255;
  31260. }
  31261. return buf;
  31262. }
  31263. function fromArrayBuffer(array, byteOffset, length) {
  31264. if (byteOffset < 0 || array.byteLength < byteOffset) {
  31265. throw new RangeError('"offset" is outside of buffer bounds');
  31266. }
  31267. if (array.byteLength < byteOffset + (length || 0)) {
  31268. throw new RangeError('"length" is outside of buffer bounds');
  31269. }
  31270. var buf;
  31271. if (byteOffset === undefined && length === undefined) {
  31272. buf = new Uint8Array(array);
  31273. } else if (length === undefined) {
  31274. buf = new Uint8Array(array, byteOffset);
  31275. } else {
  31276. buf = new Uint8Array(array, byteOffset, length);
  31277. } // Return an augmented `Uint8Array` instance
  31278. buf.__proto__ = Buffer.prototype;
  31279. return buf;
  31280. }
  31281. function fromObject(obj) {
  31282. if (Buffer.isBuffer(obj)) {
  31283. var len = checked(obj.length) | 0;
  31284. var buf = createBuffer(len);
  31285. if (buf.length === 0) {
  31286. return buf;
  31287. }
  31288. obj.copy(buf, 0, 0, len);
  31289. return buf;
  31290. }
  31291. if (obj.length !== undefined) {
  31292. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  31293. return createBuffer(0);
  31294. }
  31295. return fromArrayLike(obj);
  31296. }
  31297. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  31298. return fromArrayLike(obj.data);
  31299. }
  31300. }
  31301. function checked(length) {
  31302. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  31303. // length is NaN (which is otherwise coerced to zero.)
  31304. if (length >= K_MAX_LENGTH) {
  31305. throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes');
  31306. }
  31307. return length | 0;
  31308. }
  31309. function SlowBuffer(length) {
  31310. if (+length != length) {
  31311. // eslint-disable-line eqeqeq
  31312. length = 0;
  31313. }
  31314. return Buffer.alloc(+length);
  31315. }
  31316. Buffer.isBuffer = function isBuffer(b) {
  31317. return b != null && b._isBuffer === true && b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false
  31318. };
  31319. Buffer.compare = function compare(a, b) {
  31320. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
  31321. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
  31322. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  31323. throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
  31324. }
  31325. if (a === b) return 0;
  31326. var x = a.length;
  31327. var y = b.length;
  31328. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  31329. if (a[i] !== b[i]) {
  31330. x = a[i];
  31331. y = b[i];
  31332. break;
  31333. }
  31334. }
  31335. if (x < y) return -1;
  31336. if (y < x) return 1;
  31337. return 0;
  31338. };
  31339. Buffer.isEncoding = function isEncoding(encoding) {
  31340. switch (String(encoding).toLowerCase()) {
  31341. case 'hex':
  31342. case 'utf8':
  31343. case 'utf-8':
  31344. case 'ascii':
  31345. case 'latin1':
  31346. case 'binary':
  31347. case 'base64':
  31348. case 'ucs2':
  31349. case 'ucs-2':
  31350. case 'utf16le':
  31351. case 'utf-16le':
  31352. return true;
  31353. default:
  31354. return false;
  31355. }
  31356. };
  31357. Buffer.concat = function concat(list, length) {
  31358. if (!Array.isArray(list)) {
  31359. throw new TypeError('"list" argument must be an Array of Buffers');
  31360. }
  31361. if (list.length === 0) {
  31362. return Buffer.alloc(0);
  31363. }
  31364. var i;
  31365. if (length === undefined) {
  31366. length = 0;
  31367. for (i = 0; i < list.length; ++i) {
  31368. length += list[i].length;
  31369. }
  31370. }
  31371. var buffer = Buffer.allocUnsafe(length);
  31372. var pos = 0;
  31373. for (i = 0; i < list.length; ++i) {
  31374. var buf = list[i];
  31375. if (isInstance(buf, Uint8Array)) {
  31376. buf = Buffer.from(buf);
  31377. }
  31378. if (!Buffer.isBuffer(buf)) {
  31379. throw new TypeError('"list" argument must be an Array of Buffers');
  31380. }
  31381. buf.copy(buffer, pos);
  31382. pos += buf.length;
  31383. }
  31384. return buffer;
  31385. };
  31386. function byteLength(string, encoding) {
  31387. if (Buffer.isBuffer(string)) {
  31388. return string.length;
  31389. }
  31390. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  31391. return string.byteLength;
  31392. }
  31393. if (typeof string !== 'string') {
  31394. throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + 'Received type ' + _typeof(string));
  31395. }
  31396. var len = string.length;
  31397. var mustMatch = arguments.length > 2 && arguments[2] === true;
  31398. if (!mustMatch && len === 0) return 0; // Use a for loop to avoid recursion
  31399. var loweredCase = false;
  31400. for (; ;) {
  31401. switch (encoding) {
  31402. case 'ascii':
  31403. case 'latin1':
  31404. case 'binary':
  31405. return len;
  31406. case 'utf8':
  31407. case 'utf-8':
  31408. return utf8ToBytes(string).length;
  31409. case 'ucs2':
  31410. case 'ucs-2':
  31411. case 'utf16le':
  31412. case 'utf-16le':
  31413. return len * 2;
  31414. case 'hex':
  31415. return len >>> 1;
  31416. case 'base64':
  31417. return base64ToBytes(string).length;
  31418. default:
  31419. if (loweredCase) {
  31420. return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8
  31421. }
  31422. encoding = ('' + encoding).toLowerCase();
  31423. loweredCase = true;
  31424. }
  31425. }
  31426. }
  31427. Buffer.byteLength = byteLength;
  31428. function slowToString(encoding, start, end) {
  31429. var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  31430. // property of a typed array.
  31431. // This behaves neither like String nor Uint8Array in that we set start/end
  31432. // to their upper/lower bounds if the value passed is out of range.
  31433. // undefined is handled specially as per ECMA-262 6th Edition,
  31434. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  31435. if (start === undefined || start < 0) {
  31436. start = 0;
  31437. } // Return early if start > this.length. Done here to prevent potential uint32
  31438. // coercion fail below.
  31439. if (start > this.length) {
  31440. return '';
  31441. }
  31442. if (end === undefined || end > this.length) {
  31443. end = this.length;
  31444. }
  31445. if (end <= 0) {
  31446. return '';
  31447. } // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  31448. end >>>= 0;
  31449. start >>>= 0;
  31450. if (end <= start) {
  31451. return '';
  31452. }
  31453. if (!encoding) encoding = 'utf8';
  31454. while (true) {
  31455. switch (encoding) {
  31456. case 'hex':
  31457. return hexSlice(this, start, end);
  31458. case 'utf8':
  31459. case 'utf-8':
  31460. return utf8Slice(this, start, end);
  31461. case 'ascii':
  31462. return asciiSlice(this, start, end);
  31463. case 'latin1':
  31464. case 'binary':
  31465. return latin1Slice(this, start, end);
  31466. case 'base64':
  31467. return base64Slice(this, start, end);
  31468. case 'ucs2':
  31469. case 'ucs-2':
  31470. case 'utf16le':
  31471. case 'utf-16le':
  31472. return utf16leSlice(this, start, end);
  31473. default:
  31474. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
  31475. encoding = (encoding + '').toLowerCase();
  31476. loweredCase = true;
  31477. }
  31478. }
  31479. } // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  31480. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  31481. // reliably in a browserify context because there could be multiple different
  31482. // copies of the 'buffer' package in use. This method works even for Buffer
  31483. // instances that were created from another copy of the `buffer` package.
  31484. // See: https://github.com/feross/buffer/issues/154
  31485. Buffer.prototype._isBuffer = true;
  31486. function swap(b, n, m) {
  31487. var i = b[n];
  31488. b[n] = b[m];
  31489. b[m] = i;
  31490. }
  31491. Buffer.prototype.swap16 = function swap16() {
  31492. var len = this.length;
  31493. if (len % 2 !== 0) {
  31494. throw new RangeError('Buffer size must be a multiple of 16-bits');
  31495. }
  31496. for (var i = 0; i < len; i += 2) {
  31497. swap(this, i, i + 1);
  31498. }
  31499. return this;
  31500. };
  31501. Buffer.prototype.swap32 = function swap32() {
  31502. var len = this.length;
  31503. if (len % 4 !== 0) {
  31504. throw new RangeError('Buffer size must be a multiple of 32-bits');
  31505. }
  31506. for (var i = 0; i < len; i += 4) {
  31507. swap(this, i, i + 3);
  31508. swap(this, i + 1, i + 2);
  31509. }
  31510. return this;
  31511. };
  31512. Buffer.prototype.swap64 = function swap64() {
  31513. var len = this.length;
  31514. if (len % 8 !== 0) {
  31515. throw new RangeError('Buffer size must be a multiple of 64-bits');
  31516. }
  31517. for (var i = 0; i < len; i += 8) {
  31518. swap(this, i, i + 7);
  31519. swap(this, i + 1, i + 6);
  31520. swap(this, i + 2, i + 5);
  31521. swap(this, i + 3, i + 4);
  31522. }
  31523. return this;
  31524. };
  31525. Buffer.prototype.toString = function toString() {
  31526. var length = this.length;
  31527. if (length === 0) return '';
  31528. if (arguments.length === 0) return utf8Slice(this, 0, length);
  31529. return slowToString.apply(this, arguments);
  31530. };
  31531. Buffer.prototype.toLocaleString = Buffer.prototype.toString;
  31532. Buffer.prototype.equals = function equals(b) {
  31533. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer');
  31534. if (this === b) return true;
  31535. return Buffer.compare(this, b) === 0;
  31536. };
  31537. Buffer.prototype.inspect = function inspect() {
  31538. var str = '';
  31539. var max = exports.INSPECT_MAX_BYTES;
  31540. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
  31541. if (this.length > max) str += ' ... ';
  31542. return '<Buffer ' + str + '>';
  31543. };
  31544. Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
  31545. if (isInstance(target, Uint8Array)) {
  31546. target = Buffer.from(target, target.offset, target.byteLength);
  31547. }
  31548. if (!Buffer.isBuffer(target)) {
  31549. throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. ' + 'Received type ' + _typeof(target));
  31550. }
  31551. if (start === undefined) {
  31552. start = 0;
  31553. }
  31554. if (end === undefined) {
  31555. end = target ? target.length : 0;
  31556. }
  31557. if (thisStart === undefined) {
  31558. thisStart = 0;
  31559. }
  31560. if (thisEnd === undefined) {
  31561. thisEnd = this.length;
  31562. }
  31563. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  31564. throw new RangeError('out of range index');
  31565. }
  31566. if (thisStart >= thisEnd && start >= end) {
  31567. return 0;
  31568. }
  31569. if (thisStart >= thisEnd) {
  31570. return -1;
  31571. }
  31572. if (start >= end) {
  31573. return 1;
  31574. }
  31575. start >>>= 0;
  31576. end >>>= 0;
  31577. thisStart >>>= 0;
  31578. thisEnd >>>= 0;
  31579. if (this === target) return 0;
  31580. var x = thisEnd - thisStart;
  31581. var y = end - start;
  31582. var len = Math.min(x, y);
  31583. var thisCopy = this.slice(thisStart, thisEnd);
  31584. var targetCopy = target.slice(start, end);
  31585. for (var i = 0; i < len; ++i) {
  31586. if (thisCopy[i] !== targetCopy[i]) {
  31587. x = thisCopy[i];
  31588. y = targetCopy[i];
  31589. break;
  31590. }
  31591. }
  31592. if (x < y) return -1;
  31593. if (y < x) return 1;
  31594. return 0;
  31595. }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  31596. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  31597. //
  31598. // Arguments:
  31599. // - buffer - a Buffer to search
  31600. // - val - a string, Buffer, or number
  31601. // - byteOffset - an index into `buffer`; will be clamped to an int32
  31602. // - encoding - an optional encoding, relevant is val is a string
  31603. // - dir - true for indexOf, false for lastIndexOf
  31604. function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
  31605. // Empty buffer means no match
  31606. if (buffer.length === 0) return -1; // Normalize byteOffset
  31607. if (typeof byteOffset === 'string') {
  31608. encoding = byteOffset;
  31609. byteOffset = 0;
  31610. } else if (byteOffset > 0x7fffffff) {
  31611. byteOffset = 0x7fffffff;
  31612. } else if (byteOffset < -0x80000000) {
  31613. byteOffset = -0x80000000;
  31614. }
  31615. byteOffset = +byteOffset; // Coerce to Number.
  31616. if (numberIsNaN(byteOffset)) {
  31617. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  31618. byteOffset = dir ? 0 : buffer.length - 1;
  31619. } // Normalize byteOffset: negative offsets start from the end of the buffer
  31620. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  31621. if (byteOffset >= buffer.length) {
  31622. if (dir) return -1; else byteOffset = buffer.length - 1;
  31623. } else if (byteOffset < 0) {
  31624. if (dir) byteOffset = 0; else return -1;
  31625. } // Normalize val
  31626. if (typeof val === 'string') {
  31627. val = Buffer.from(val, encoding);
  31628. } // Finally, search either indexOf (if dir is true) or lastIndexOf
  31629. if (Buffer.isBuffer(val)) {
  31630. // Special case: looking for empty string/buffer always fails
  31631. if (val.length === 0) {
  31632. return -1;
  31633. }
  31634. return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
  31635. } else if (typeof val === 'number') {
  31636. val = val & 0xFF; // Search for a byte value [0-255]
  31637. if (typeof Uint8Array.prototype.indexOf === 'function') {
  31638. if (dir) {
  31639. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
  31640. } else {
  31641. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
  31642. }
  31643. }
  31644. return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
  31645. }
  31646. throw new TypeError('val must be string, number or Buffer');
  31647. }
  31648. function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
  31649. var indexSize = 1;
  31650. var arrLength = arr.length;
  31651. var valLength = val.length;
  31652. if (encoding !== undefined) {
  31653. encoding = String(encoding).toLowerCase();
  31654. if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') {
  31655. if (arr.length < 2 || val.length < 2) {
  31656. return -1;
  31657. }
  31658. indexSize = 2;
  31659. arrLength /= 2;
  31660. valLength /= 2;
  31661. byteOffset /= 2;
  31662. }
  31663. }
  31664. function read(buf, i) {
  31665. if (indexSize === 1) {
  31666. return buf[i];
  31667. } else {
  31668. return buf.readUInt16BE(i * indexSize);
  31669. }
  31670. }
  31671. var i;
  31672. if (dir) {
  31673. var foundIndex = -1;
  31674. for (i = byteOffset; i < arrLength; i++) {
  31675. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  31676. if (foundIndex === -1) foundIndex = i;
  31677. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
  31678. } else {
  31679. if (foundIndex !== -1) i -= i - foundIndex;
  31680. foundIndex = -1;
  31681. }
  31682. }
  31683. } else {
  31684. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  31685. for (i = byteOffset; i >= 0; i--) {
  31686. var found = true;
  31687. for (var j = 0; j < valLength; j++) {
  31688. if (read(arr, i + j) !== read(val, j)) {
  31689. found = false;
  31690. break;
  31691. }
  31692. }
  31693. if (found) return i;
  31694. }
  31695. }
  31696. return -1;
  31697. }
  31698. Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
  31699. return this.indexOf(val, byteOffset, encoding) !== -1;
  31700. };
  31701. Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
  31702. return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
  31703. };
  31704. Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
  31705. return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
  31706. };
  31707. function hexWrite(buf, string, offset, length) {
  31708. offset = Number(offset) || 0;
  31709. var remaining = buf.length - offset;
  31710. if (!length) {
  31711. length = remaining;
  31712. } else {
  31713. length = Number(length);
  31714. if (length > remaining) {
  31715. length = remaining;
  31716. }
  31717. }
  31718. var strLen = string.length;
  31719. if (length > strLen / 2) {
  31720. length = strLen / 2;
  31721. }
  31722. for (var i = 0; i < length; ++i) {
  31723. var parsed = parseInt(string.substr(i * 2, 2), 16);
  31724. if (numberIsNaN(parsed)) return i;
  31725. buf[offset + i] = parsed;
  31726. }
  31727. return i;
  31728. }
  31729. function utf8Write(buf, string, offset, length) {
  31730. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
  31731. }
  31732. function asciiWrite(buf, string, offset, length) {
  31733. return blitBuffer(asciiToBytes(string), buf, offset, length);
  31734. }
  31735. function latin1Write(buf, string, offset, length) {
  31736. return asciiWrite(buf, string, offset, length);
  31737. }
  31738. function base64Write(buf, string, offset, length) {
  31739. return blitBuffer(base64ToBytes(string), buf, offset, length);
  31740. }
  31741. function ucs2Write(buf, string, offset, length) {
  31742. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
  31743. }
  31744. Buffer.prototype.write = function write(string, offset, length, encoding) {
  31745. // Buffer#write(string)
  31746. if (offset === undefined) {
  31747. encoding = 'utf8';
  31748. length = this.length;
  31749. offset = 0; // Buffer#write(string, encoding)
  31750. } else if (length === undefined && typeof offset === 'string') {
  31751. encoding = offset;
  31752. length = this.length;
  31753. offset = 0; // Buffer#write(string, offset[, length][, encoding])
  31754. } else if (isFinite(offset)) {
  31755. offset = offset >>> 0;
  31756. if (isFinite(length)) {
  31757. length = length >>> 0;
  31758. if (encoding === undefined) encoding = 'utf8';
  31759. } else {
  31760. encoding = length;
  31761. length = undefined;
  31762. }
  31763. } else {
  31764. throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');
  31765. }
  31766. var remaining = this.length - offset;
  31767. if (length === undefined || length > remaining) length = remaining;
  31768. if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
  31769. throw new RangeError('Attempt to write outside buffer bounds');
  31770. }
  31771. if (!encoding) encoding = 'utf8';
  31772. var loweredCase = false;
  31773. for (; ;) {
  31774. switch (encoding) {
  31775. case 'hex':
  31776. return hexWrite(this, string, offset, length);
  31777. case 'utf8':
  31778. case 'utf-8':
  31779. return utf8Write(this, string, offset, length);
  31780. case 'ascii':
  31781. return asciiWrite(this, string, offset, length);
  31782. case 'latin1':
  31783. case 'binary':
  31784. return latin1Write(this, string, offset, length);
  31785. case 'base64':
  31786. // Warning: maxLength not taken into account in base64Write
  31787. return base64Write(this, string, offset, length);
  31788. case 'ucs2':
  31789. case 'ucs-2':
  31790. case 'utf16le':
  31791. case 'utf-16le':
  31792. return ucs2Write(this, string, offset, length);
  31793. default:
  31794. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
  31795. encoding = ('' + encoding).toLowerCase();
  31796. loweredCase = true;
  31797. }
  31798. }
  31799. };
  31800. Buffer.prototype.toJSON = function toJSON() {
  31801. return {
  31802. type: 'Buffer',
  31803. data: Array.prototype.slice.call(this._arr || this, 0)
  31804. };
  31805. };
  31806. function base64Slice(buf, start, end) {
  31807. if (start === 0 && end === buf.length) {
  31808. return base64.fromByteArray(buf);
  31809. } else {
  31810. return base64.fromByteArray(buf.slice(start, end));
  31811. }
  31812. }
  31813. function utf8Slice(buf, start, end) {
  31814. end = Math.min(buf.length, end);
  31815. var res = [];
  31816. var i = start;
  31817. while (i < end) {
  31818. var firstByte = buf[i];
  31819. var codePoint = null;
  31820. var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1;
  31821. if (i + bytesPerSequence <= end) {
  31822. var secondByte, thirdByte, fourthByte, tempCodePoint;
  31823. switch (bytesPerSequence) {
  31824. case 1:
  31825. if (firstByte < 0x80) {
  31826. codePoint = firstByte;
  31827. }
  31828. break;
  31829. case 2:
  31830. secondByte = buf[i + 1];
  31831. if ((secondByte & 0xC0) === 0x80) {
  31832. tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F;
  31833. if (tempCodePoint > 0x7F) {
  31834. codePoint = tempCodePoint;
  31835. }
  31836. }
  31837. break;
  31838. case 3:
  31839. secondByte = buf[i + 1];
  31840. thirdByte = buf[i + 2];
  31841. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  31842. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F;
  31843. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  31844. codePoint = tempCodePoint;
  31845. }
  31846. }
  31847. break;
  31848. case 4:
  31849. secondByte = buf[i + 1];
  31850. thirdByte = buf[i + 2];
  31851. fourthByte = buf[i + 3];
  31852. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  31853. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F;
  31854. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  31855. codePoint = tempCodePoint;
  31856. }
  31857. }
  31858. }
  31859. }
  31860. if (codePoint === null) {
  31861. // we did not generate a valid codePoint so insert a
  31862. // replacement char (U+FFFD) and advance only 1 byte
  31863. codePoint = 0xFFFD;
  31864. bytesPerSequence = 1;
  31865. } else if (codePoint > 0xFFFF) {
  31866. // encode to utf16 (surrogate pair dance)
  31867. codePoint -= 0x10000;
  31868. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  31869. codePoint = 0xDC00 | codePoint & 0x3FF;
  31870. }
  31871. res.push(codePoint);
  31872. i += bytesPerSequence;
  31873. }
  31874. return decodeCodePointsArray(res);
  31875. } // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  31876. // the lowest limit is Chrome, with 0x10000 args.
  31877. // We go 1 magnitude less, for safety
  31878. var MAX_ARGUMENTS_LENGTH = 0x1000;
  31879. function decodeCodePointsArray(codePoints) {
  31880. var len = codePoints.length;
  31881. if (len <= MAX_ARGUMENTS_LENGTH) {
  31882. return String.fromCharCode.apply(String, codePoints); // avoid extra slice()
  31883. } // Decode in chunks to avoid "call stack size exceeded".
  31884. var res = '';
  31885. var i = 0;
  31886. while (i < len) {
  31887. res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
  31888. }
  31889. return res;
  31890. }
  31891. function asciiSlice(buf, start, end) {
  31892. var ret = '';
  31893. end = Math.min(buf.length, end);
  31894. for (var i = start; i < end; ++i) {
  31895. ret += String.fromCharCode(buf[i] & 0x7F);
  31896. }
  31897. return ret;
  31898. }
  31899. function latin1Slice(buf, start, end) {
  31900. var ret = '';
  31901. end = Math.min(buf.length, end);
  31902. for (var i = start; i < end; ++i) {
  31903. ret += String.fromCharCode(buf[i]);
  31904. }
  31905. return ret;
  31906. }
  31907. function hexSlice(buf, start, end) {
  31908. var len = buf.length;
  31909. if (!start || start < 0) start = 0;
  31910. if (!end || end < 0 || end > len) end = len;
  31911. var out = '';
  31912. for (var i = start; i < end; ++i) {
  31913. out += toHex(buf[i]);
  31914. }
  31915. return out;
  31916. }
  31917. function utf16leSlice(buf, start, end) {
  31918. var bytes = buf.slice(start, end);
  31919. var res = '';
  31920. for (var i = 0; i < bytes.length; i += 2) {
  31921. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  31922. }
  31923. return res;
  31924. }
  31925. Buffer.prototype.slice = function slice(start, end) {
  31926. var len = this.length;
  31927. start = ~~start;
  31928. end = end === undefined ? len : ~~end;
  31929. if (start < 0) {
  31930. start += len;
  31931. if (start < 0) start = 0;
  31932. } else if (start > len) {
  31933. start = len;
  31934. }
  31935. if (end < 0) {
  31936. end += len;
  31937. if (end < 0) end = 0;
  31938. } else if (end > len) {
  31939. end = len;
  31940. }
  31941. if (end < start) end = start;
  31942. var newBuf = this.subarray(start, end); // Return an augmented `Uint8Array` instance
  31943. newBuf.__proto__ = Buffer.prototype;
  31944. return newBuf;
  31945. };
  31946. /*
  31947. * Need to make sure that buffer isn't trying to write out of bounds.
  31948. */
  31949. function checkOffset(offset, ext, length) {
  31950. if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint');
  31951. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length');
  31952. }
  31953. Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
  31954. offset = offset >>> 0;
  31955. byteLength = byteLength >>> 0;
  31956. if (!noAssert) checkOffset(offset, byteLength, this.length);
  31957. var val = this[offset];
  31958. var mul = 1;
  31959. var i = 0;
  31960. while (++i < byteLength && (mul *= 0x100)) {
  31961. val += this[offset + i] * mul;
  31962. }
  31963. return val;
  31964. };
  31965. Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
  31966. offset = offset >>> 0;
  31967. byteLength = byteLength >>> 0;
  31968. if (!noAssert) {
  31969. checkOffset(offset, byteLength, this.length);
  31970. }
  31971. var val = this[offset + --byteLength];
  31972. var mul = 1;
  31973. while (byteLength > 0 && (mul *= 0x100)) {
  31974. val += this[offset + --byteLength] * mul;
  31975. }
  31976. return val;
  31977. };
  31978. Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
  31979. offset = offset >>> 0;
  31980. if (!noAssert) checkOffset(offset, 1, this.length);
  31981. return this[offset];
  31982. };
  31983. Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
  31984. offset = offset >>> 0;
  31985. if (!noAssert) checkOffset(offset, 2, this.length);
  31986. return this[offset] | this[offset + 1] << 8;
  31987. };
  31988. Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
  31989. offset = offset >>> 0;
  31990. if (!noAssert) checkOffset(offset, 2, this.length);
  31991. return this[offset] << 8 | this[offset + 1];
  31992. };
  31993. Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
  31994. offset = offset >>> 0;
  31995. if (!noAssert) checkOffset(offset, 4, this.length);
  31996. return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000;
  31997. };
  31998. Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
  31999. offset = offset >>> 0;
  32000. if (!noAssert) checkOffset(offset, 4, this.length);
  32001. return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
  32002. };
  32003. Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
  32004. offset = offset >>> 0;
  32005. byteLength = byteLength >>> 0;
  32006. if (!noAssert) checkOffset(offset, byteLength, this.length);
  32007. var val = this[offset];
  32008. var mul = 1;
  32009. var i = 0;
  32010. while (++i < byteLength && (mul *= 0x100)) {
  32011. val += this[offset + i] * mul;
  32012. }
  32013. mul *= 0x80;
  32014. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  32015. return val;
  32016. };
  32017. Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
  32018. offset = offset >>> 0;
  32019. byteLength = byteLength >>> 0;
  32020. if (!noAssert) checkOffset(offset, byteLength, this.length);
  32021. var i = byteLength;
  32022. var mul = 1;
  32023. var val = this[offset + --i];
  32024. while (i > 0 && (mul *= 0x100)) {
  32025. val += this[offset + --i] * mul;
  32026. }
  32027. mul *= 0x80;
  32028. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  32029. return val;
  32030. };
  32031. Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
  32032. offset = offset >>> 0;
  32033. if (!noAssert) checkOffset(offset, 1, this.length);
  32034. if (!(this[offset] & 0x80)) return this[offset];
  32035. return (0xff - this[offset] + 1) * -1;
  32036. };
  32037. Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
  32038. offset = offset >>> 0;
  32039. if (!noAssert) checkOffset(offset, 2, this.length);
  32040. var val = this[offset] | this[offset + 1] << 8;
  32041. return val & 0x8000 ? val | 0xFFFF0000 : val;
  32042. };
  32043. Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
  32044. offset = offset >>> 0;
  32045. if (!noAssert) checkOffset(offset, 2, this.length);
  32046. var val = this[offset + 1] | this[offset] << 8;
  32047. return val & 0x8000 ? val | 0xFFFF0000 : val;
  32048. };
  32049. Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
  32050. offset = offset >>> 0;
  32051. if (!noAssert) checkOffset(offset, 4, this.length);
  32052. return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
  32053. };
  32054. Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
  32055. offset = offset >>> 0;
  32056. if (!noAssert) checkOffset(offset, 4, this.length);
  32057. return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
  32058. };
  32059. Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
  32060. offset = offset >>> 0;
  32061. if (!noAssert) checkOffset(offset, 4, this.length);
  32062. return ieee754.read(this, offset, true, 23, 4);
  32063. };
  32064. Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
  32065. offset = offset >>> 0;
  32066. if (!noAssert) checkOffset(offset, 4, this.length);
  32067. return ieee754.read(this, offset, false, 23, 4);
  32068. };
  32069. Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
  32070. offset = offset >>> 0;
  32071. if (!noAssert) checkOffset(offset, 8, this.length);
  32072. return ieee754.read(this, offset, true, 52, 8);
  32073. };
  32074. Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
  32075. offset = offset >>> 0;
  32076. if (!noAssert) checkOffset(offset, 8, this.length);
  32077. return ieee754.read(this, offset, false, 52, 8);
  32078. };
  32079. function checkInt(buf, value, offset, ext, max, min) {
  32080. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
  32081. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
  32082. if (offset + ext > buf.length) throw new RangeError('Index out of range');
  32083. }
  32084. Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
  32085. value = +value;
  32086. offset = offset >>> 0;
  32087. byteLength = byteLength >>> 0;
  32088. if (!noAssert) {
  32089. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  32090. checkInt(this, value, offset, byteLength, maxBytes, 0);
  32091. }
  32092. var mul = 1;
  32093. var i = 0;
  32094. this[offset] = value & 0xFF;
  32095. while (++i < byteLength && (mul *= 0x100)) {
  32096. this[offset + i] = value / mul & 0xFF;
  32097. }
  32098. return offset + byteLength;
  32099. };
  32100. Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
  32101. value = +value;
  32102. offset = offset >>> 0;
  32103. byteLength = byteLength >>> 0;
  32104. if (!noAssert) {
  32105. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  32106. checkInt(this, value, offset, byteLength, maxBytes, 0);
  32107. }
  32108. var i = byteLength - 1;
  32109. var mul = 1;
  32110. this[offset + i] = value & 0xFF;
  32111. while (--i >= 0 && (mul *= 0x100)) {
  32112. this[offset + i] = value / mul & 0xFF;
  32113. }
  32114. return offset + byteLength;
  32115. };
  32116. Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
  32117. value = +value;
  32118. offset = offset >>> 0;
  32119. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  32120. this[offset] = value & 0xff;
  32121. return offset + 1;
  32122. };
  32123. Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
  32124. value = +value;
  32125. offset = offset >>> 0;
  32126. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  32127. this[offset] = value & 0xff;
  32128. this[offset + 1] = value >>> 8;
  32129. return offset + 2;
  32130. };
  32131. Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
  32132. value = +value;
  32133. offset = offset >>> 0;
  32134. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  32135. this[offset] = value >>> 8;
  32136. this[offset + 1] = value & 0xff;
  32137. return offset + 2;
  32138. };
  32139. Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
  32140. value = +value;
  32141. offset = offset >>> 0;
  32142. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  32143. this[offset + 3] = value >>> 24;
  32144. this[offset + 2] = value >>> 16;
  32145. this[offset + 1] = value >>> 8;
  32146. this[offset] = value & 0xff;
  32147. return offset + 4;
  32148. };
  32149. Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
  32150. value = +value;
  32151. offset = offset >>> 0;
  32152. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  32153. this[offset] = value >>> 24;
  32154. this[offset + 1] = value >>> 16;
  32155. this[offset + 2] = value >>> 8;
  32156. this[offset + 3] = value & 0xff;
  32157. return offset + 4;
  32158. };
  32159. Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
  32160. value = +value;
  32161. offset = offset >>> 0;
  32162. if (!noAssert) {
  32163. var limit = Math.pow(2, 8 * byteLength - 1);
  32164. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  32165. }
  32166. var i = 0;
  32167. var mul = 1;
  32168. var sub = 0;
  32169. this[offset] = value & 0xFF;
  32170. while (++i < byteLength && (mul *= 0x100)) {
  32171. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  32172. sub = 1;
  32173. }
  32174. this[offset + i] = (value / mul >> 0) - sub & 0xFF;
  32175. }
  32176. return offset + byteLength;
  32177. };
  32178. Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
  32179. value = +value;
  32180. offset = offset >>> 0;
  32181. if (!noAssert) {
  32182. var limit = Math.pow(2, 8 * byteLength - 1);
  32183. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  32184. }
  32185. var i = byteLength - 1;
  32186. var mul = 1;
  32187. var sub = 0;
  32188. this[offset + i] = value & 0xFF;
  32189. while (--i >= 0 && (mul *= 0x100)) {
  32190. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  32191. sub = 1;
  32192. }
  32193. this[offset + i] = (value / mul >> 0) - sub & 0xFF;
  32194. }
  32195. return offset + byteLength;
  32196. };
  32197. Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
  32198. value = +value;
  32199. offset = offset >>> 0;
  32200. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
  32201. if (value < 0) value = 0xff + value + 1;
  32202. this[offset] = value & 0xff;
  32203. return offset + 1;
  32204. };
  32205. Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
  32206. value = +value;
  32207. offset = offset >>> 0;
  32208. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  32209. this[offset] = value & 0xff;
  32210. this[offset + 1] = value >>> 8;
  32211. return offset + 2;
  32212. };
  32213. Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
  32214. value = +value;
  32215. offset = offset >>> 0;
  32216. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  32217. this[offset] = value >>> 8;
  32218. this[offset + 1] = value & 0xff;
  32219. return offset + 2;
  32220. };
  32221. Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
  32222. value = +value;
  32223. offset = offset >>> 0;
  32224. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  32225. this[offset] = value & 0xff;
  32226. this[offset + 1] = value >>> 8;
  32227. this[offset + 2] = value >>> 16;
  32228. this[offset + 3] = value >>> 24;
  32229. return offset + 4;
  32230. };
  32231. Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
  32232. value = +value;
  32233. offset = offset >>> 0;
  32234. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  32235. if (value < 0) value = 0xffffffff + value + 1;
  32236. this[offset] = value >>> 24;
  32237. this[offset + 1] = value >>> 16;
  32238. this[offset + 2] = value >>> 8;
  32239. this[offset + 3] = value & 0xff;
  32240. return offset + 4;
  32241. };
  32242. function checkIEEE754(buf, value, offset, ext, max, min) {
  32243. if (offset + ext > buf.length) throw new RangeError('Index out of range');
  32244. if (offset < 0) throw new RangeError('Index out of range');
  32245. }
  32246. function writeFloat(buf, value, offset, littleEndian, noAssert) {
  32247. value = +value;
  32248. offset = offset >>> 0;
  32249. if (!noAssert) {
  32250. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38);
  32251. }
  32252. ieee754.write(buf, value, offset, littleEndian, 23, 4);
  32253. return offset + 4;
  32254. }
  32255. Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
  32256. return writeFloat(this, value, offset, true, noAssert);
  32257. };
  32258. Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
  32259. return writeFloat(this, value, offset, false, noAssert);
  32260. };
  32261. function writeDouble(buf, value, offset, littleEndian, noAssert) {
  32262. value = +value;
  32263. offset = offset >>> 0;
  32264. if (!noAssert) {
  32265. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308);
  32266. }
  32267. ieee754.write(buf, value, offset, littleEndian, 52, 8);
  32268. return offset + 8;
  32269. }
  32270. Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
  32271. return writeDouble(this, value, offset, true, noAssert);
  32272. };
  32273. Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
  32274. return writeDouble(this, value, offset, false, noAssert);
  32275. }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  32276. Buffer.prototype.copy = function copy(target, targetStart, start, end) {
  32277. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer');
  32278. if (!start) start = 0;
  32279. if (!end && end !== 0) end = this.length;
  32280. if (targetStart >= target.length) targetStart = target.length;
  32281. if (!targetStart) targetStart = 0;
  32282. if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done
  32283. if (end === start) return 0;
  32284. if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions
  32285. if (targetStart < 0) {
  32286. throw new RangeError('targetStart out of bounds');
  32287. }
  32288. if (start < 0 || start >= this.length) throw new RangeError('Index out of range');
  32289. if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob?
  32290. if (end > this.length) end = this.length;
  32291. if (target.length - targetStart < end - start) {
  32292. end = target.length - targetStart + start;
  32293. }
  32294. var len = end - start;
  32295. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  32296. // Use built-in when available, missing from IE11
  32297. this.copyWithin(targetStart, start, end);
  32298. } else if (this === target && start < targetStart && targetStart < end) {
  32299. // descending copy from end
  32300. for (var i = len - 1; i >= 0; --i) {
  32301. target[i + targetStart] = this[i + start];
  32302. }
  32303. } else {
  32304. Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
  32305. }
  32306. return len;
  32307. }; // Usage:
  32308. // buffer.fill(number[, offset[, end]])
  32309. // buffer.fill(buffer[, offset[, end]])
  32310. // buffer.fill(string[, offset[, end]][, encoding])
  32311. Buffer.prototype.fill = function fill(val, start, end, encoding) {
  32312. // Handle string cases:
  32313. if (typeof val === 'string') {
  32314. if (typeof start === 'string') {
  32315. encoding = start;
  32316. start = 0;
  32317. end = this.length;
  32318. } else if (typeof end === 'string') {
  32319. encoding = end;
  32320. end = this.length;
  32321. }
  32322. if (encoding !== undefined && typeof encoding !== 'string') {
  32323. throw new TypeError('encoding must be a string');
  32324. }
  32325. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  32326. throw new TypeError('Unknown encoding: ' + encoding);
  32327. }
  32328. if (val.length === 1) {
  32329. var code = val.charCodeAt(0);
  32330. if (encoding === 'utf8' && code < 128 || encoding === 'latin1') {
  32331. // Fast path: If `val` fits into a single byte, use that numeric value.
  32332. val = code;
  32333. }
  32334. }
  32335. } else if (typeof val === 'number') {
  32336. val = val & 255;
  32337. } // Invalid ranges are not set to a default, so can range check early.
  32338. if (start < 0 || this.length < start || this.length < end) {
  32339. throw new RangeError('Out of range index');
  32340. }
  32341. if (end <= start) {
  32342. return this;
  32343. }
  32344. start = start >>> 0;
  32345. end = end === undefined ? this.length : end >>> 0;
  32346. if (!val) val = 0;
  32347. var i;
  32348. if (typeof val === 'number') {
  32349. for (i = start; i < end; ++i) {
  32350. this[i] = val;
  32351. }
  32352. } else {
  32353. var bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding);
  32354. var len = bytes.length;
  32355. if (len === 0) {
  32356. throw new TypeError('The value "' + val + '" is invalid for argument "value"');
  32357. }
  32358. for (i = 0; i < end - start; ++i) {
  32359. this[i + start] = bytes[i % len];
  32360. }
  32361. }
  32362. return this;
  32363. }; // HELPER FUNCTIONS
  32364. // ================
  32365. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
  32366. function base64clean(str) {
  32367. // Node takes equal signs as end of the Base64 encoding
  32368. str = str.split('=')[0]; // Node strips out invalid characters like \n and \t from the string, base64-js does not
  32369. str = str.trim().replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to ''
  32370. if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  32371. while (str.length % 4 !== 0) {
  32372. str = str + '=';
  32373. }
  32374. return str;
  32375. }
  32376. function toHex(n) {
  32377. if (n < 16) return '0' + n.toString(16);
  32378. return n.toString(16);
  32379. }
  32380. function utf8ToBytes(string, units) {
  32381. units = units || Infinity;
  32382. var codePoint;
  32383. var length = string.length;
  32384. var leadSurrogate = null;
  32385. var bytes = [];
  32386. for (var i = 0; i < length; ++i) {
  32387. codePoint = string.charCodeAt(i); // is surrogate component
  32388. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  32389. // last char was a lead
  32390. if (!leadSurrogate) {
  32391. // no lead yet
  32392. if (codePoint > 0xDBFF) {
  32393. // unexpected trail
  32394. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  32395. continue;
  32396. } else if (i + 1 === length) {
  32397. // unpaired lead
  32398. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  32399. continue;
  32400. } // valid lead
  32401. leadSurrogate = codePoint;
  32402. continue;
  32403. } // 2 leads in a row
  32404. if (codePoint < 0xDC00) {
  32405. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  32406. leadSurrogate = codePoint;
  32407. continue;
  32408. } // valid surrogate pair
  32409. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  32410. } else if (leadSurrogate) {
  32411. // valid bmp char, but last char was a lead
  32412. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  32413. }
  32414. leadSurrogate = null; // encode utf8
  32415. if (codePoint < 0x80) {
  32416. if ((units -= 1) < 0) break;
  32417. bytes.push(codePoint);
  32418. } else if (codePoint < 0x800) {
  32419. if ((units -= 2) < 0) break;
  32420. bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80);
  32421. } else if (codePoint < 0x10000) {
  32422. if ((units -= 3) < 0) break;
  32423. bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
  32424. } else if (codePoint < 0x110000) {
  32425. if ((units -= 4) < 0) break;
  32426. bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
  32427. } else {
  32428. throw new Error('Invalid code point');
  32429. }
  32430. }
  32431. return bytes;
  32432. }
  32433. function asciiToBytes(str) {
  32434. var byteArray = [];
  32435. for (var i = 0; i < str.length; ++i) {
  32436. // Node's code seems to be doing this and not & 0x7F..
  32437. byteArray.push(str.charCodeAt(i) & 0xFF);
  32438. }
  32439. return byteArray;
  32440. }
  32441. function utf16leToBytes(str, units) {
  32442. var c, hi, lo;
  32443. var byteArray = [];
  32444. for (var i = 0; i < str.length; ++i) {
  32445. if ((units -= 2) < 0) break;
  32446. c = str.charCodeAt(i);
  32447. hi = c >> 8;
  32448. lo = c % 256;
  32449. byteArray.push(lo);
  32450. byteArray.push(hi);
  32451. }
  32452. return byteArray;
  32453. }
  32454. function base64ToBytes(str) {
  32455. return base64.toByteArray(base64clean(str));
  32456. }
  32457. function blitBuffer(src, dst, offset, length) {
  32458. for (var i = 0; i < length; ++i) {
  32459. if (i + offset >= dst.length || i >= src.length) break;
  32460. dst[i + offset] = src[i];
  32461. }
  32462. return i;
  32463. } // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  32464. // the `instanceof` check but they should be treated as of that type.
  32465. // See: https://github.com/feross/buffer/issues/166
  32466. function isInstance(obj, type) {
  32467. return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
  32468. }
  32469. function numberIsNaN(obj) {
  32470. // For IE11 support
  32471. return obj !== obj; // eslint-disable-line no-self-compare
  32472. }
  32473. }).call(this, require("buffer").Buffer)
  32474. }, { "base64-js": 182, "buffer": 216, "ieee754": 385 }], 217: [function (require, module, exports) {
  32475. (function (Buffer) {
  32476. "use strict";
  32477. module.exports = function xor(a, b) {
  32478. var length = Math.min(a.length, b.length);
  32479. var buffer = new Buffer(length);
  32480. for (var i = 0; i < length; ++i) {
  32481. buffer[i] = a[i] ^ b[i];
  32482. }
  32483. return buffer;
  32484. };
  32485. }).call(this, require("buffer").Buffer)
  32486. }, { "buffer": 216 }], 218: [function (require, module, exports) {
  32487. "use strict";
  32488. var Buffer = require('safe-buffer').Buffer;
  32489. var Transform = require('stream').Transform;
  32490. var StringDecoder = require('string_decoder').StringDecoder;
  32491. var inherits = require('inherits');
  32492. function CipherBase(hashMode) {
  32493. Transform.call(this);
  32494. this.hashMode = typeof hashMode === 'string';
  32495. if (this.hashMode) {
  32496. this[hashMode] = this._finalOrDigest;
  32497. } else {
  32498. this.final = this._finalOrDigest;
  32499. }
  32500. if (this._final) {
  32501. this.__final = this._final;
  32502. this._final = null;
  32503. }
  32504. this._decoder = null;
  32505. this._encoding = null;
  32506. }
  32507. inherits(CipherBase, Transform);
  32508. CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
  32509. if (typeof data === 'string') {
  32510. data = Buffer.from(data, inputEnc);
  32511. }
  32512. var outData = this._update(data);
  32513. if (this.hashMode) return this;
  32514. if (outputEnc) {
  32515. outData = this._toString(outData, outputEnc);
  32516. }
  32517. return outData;
  32518. };
  32519. CipherBase.prototype.setAutoPadding = function () { };
  32520. CipherBase.prototype.getAuthTag = function () {
  32521. throw new Error('trying to get auth tag in unsupported state');
  32522. };
  32523. CipherBase.prototype.setAuthTag = function () {
  32524. throw new Error('trying to set auth tag in unsupported state');
  32525. };
  32526. CipherBase.prototype.setAAD = function () {
  32527. throw new Error('trying to set aad in unsupported state');
  32528. };
  32529. CipherBase.prototype._transform = function (data, _, next) {
  32530. var err;
  32531. try {
  32532. if (this.hashMode) {
  32533. this._update(data);
  32534. } else {
  32535. this.push(this._update(data));
  32536. }
  32537. } catch (e) {
  32538. err = e;
  32539. } finally {
  32540. next(err);
  32541. }
  32542. };
  32543. CipherBase.prototype._flush = function (done) {
  32544. var err;
  32545. try {
  32546. this.push(this.__final());
  32547. } catch (e) {
  32548. err = e;
  32549. }
  32550. done(err);
  32551. };
  32552. CipherBase.prototype._finalOrDigest = function (outputEnc) {
  32553. var outData = this.__final() || Buffer.alloc(0);
  32554. if (outputEnc) {
  32555. outData = this._toString(outData, outputEnc, true);
  32556. }
  32557. return outData;
  32558. };
  32559. CipherBase.prototype._toString = function (value, enc, fin) {
  32560. if (!this._decoder) {
  32561. this._decoder = new StringDecoder(enc);
  32562. this._encoding = enc;
  32563. }
  32564. if (this._encoding !== enc) throw new Error('can\'t switch encodings');
  32565. var out = this._decoder.write(value);
  32566. if (fin) {
  32567. out += this._decoder.end();
  32568. }
  32569. return out;
  32570. };
  32571. module.exports = CipherBase;
  32572. }, { "inherits": 387, "safe-buffer": 494, "stream": 506, "string_decoder": 520 }], 219: [function (require, module, exports) {
  32573. module.exports = function (it) {
  32574. if (typeof it != 'function') {
  32575. throw TypeError(String(it) + ' is not a function');
  32576. } return it;
  32577. };
  32578. }, {}], 220: [function (require, module, exports) {
  32579. var isObject = require('../internals/is-object');
  32580. module.exports = function (it) {
  32581. if (!isObject(it) && it !== null) {
  32582. throw TypeError("Can't set " + String(it) + ' as a prototype');
  32583. } return it;
  32584. };
  32585. }, { "../internals/is-object": 263 }], 221: [function (require, module, exports) {
  32586. var wellKnownSymbol = require('../internals/well-known-symbol');
  32587. var create = require('../internals/object-create');
  32588. var definePropertyModule = require('../internals/object-define-property');
  32589. var UNSCOPABLES = wellKnownSymbol('unscopables');
  32590. var ArrayPrototype = Array.prototype;
  32591. // Array.prototype[@@unscopables]
  32592. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  32593. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  32594. definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
  32595. configurable: true,
  32596. value: create(null)
  32597. });
  32598. }
  32599. // add a key to Array.prototype[@@unscopables]
  32600. module.exports = function (key) {
  32601. ArrayPrototype[UNSCOPABLES][key] = true;
  32602. };
  32603. }, { "../internals/object-create": 276, "../internals/object-define-property": 278, "../internals/well-known-symbol": 314 }], 222: [function (require, module, exports) {
  32604. module.exports = function (it, Constructor, name) {
  32605. if (!(it instanceof Constructor)) {
  32606. throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
  32607. } return it;
  32608. };
  32609. }, {}], 223: [function (require, module, exports) {
  32610. var isObject = require('../internals/is-object');
  32611. module.exports = function (it) {
  32612. if (!isObject(it)) {
  32613. throw TypeError(String(it) + ' is not an object');
  32614. } return it;
  32615. };
  32616. }, { "../internals/is-object": 263 }], 224: [function (require, module, exports) {
  32617. var toIndexedObject = require('../internals/to-indexed-object');
  32618. var toLength = require('../internals/to-length');
  32619. var toAbsoluteIndex = require('../internals/to-absolute-index');
  32620. // `Array.prototype.{ indexOf, includes }` methods implementation
  32621. var createMethod = function (IS_INCLUDES) {
  32622. return function ($this, el, fromIndex) {
  32623. var O = toIndexedObject($this);
  32624. var length = toLength(O.length);
  32625. var index = toAbsoluteIndex(fromIndex, length);
  32626. var value;
  32627. // Array#includes uses SameValueZero equality algorithm
  32628. // eslint-disable-next-line no-self-compare
  32629. if (IS_INCLUDES && el != el) while (length > index) {
  32630. value = O[index++];
  32631. // eslint-disable-next-line no-self-compare
  32632. if (value != value) return true;
  32633. // Array#indexOf ignores holes, Array#includes - not
  32634. } else for (; length > index; index++) {
  32635. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  32636. } return !IS_INCLUDES && -1;
  32637. };
  32638. };
  32639. module.exports = {
  32640. // `Array.prototype.includes` method
  32641. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  32642. includes: createMethod(true),
  32643. // `Array.prototype.indexOf` method
  32644. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  32645. indexOf: createMethod(false)
  32646. };
  32647. }, { "../internals/to-absolute-index": 304, "../internals/to-indexed-object": 305, "../internals/to-length": 307 }], 225: [function (require, module, exports) {
  32648. var bind = require('../internals/function-bind-context');
  32649. var IndexedObject = require('../internals/indexed-object');
  32650. var toObject = require('../internals/to-object');
  32651. var toLength = require('../internals/to-length');
  32652. var arraySpeciesCreate = require('../internals/array-species-create');
  32653. var push = [].push;
  32654. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  32655. var createMethod = function (TYPE) {
  32656. var IS_MAP = TYPE == 1;
  32657. var IS_FILTER = TYPE == 2;
  32658. var IS_SOME = TYPE == 3;
  32659. var IS_EVERY = TYPE == 4;
  32660. var IS_FIND_INDEX = TYPE == 6;
  32661. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  32662. return function ($this, callbackfn, that, specificCreate) {
  32663. var O = toObject($this);
  32664. var self = IndexedObject(O);
  32665. var boundFunction = bind(callbackfn, that, 3);
  32666. var length = toLength(self.length);
  32667. var index = 0;
  32668. var create = specificCreate || arraySpeciesCreate;
  32669. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  32670. var value, result;
  32671. for (; length > index; index++) if (NO_HOLES || index in self) {
  32672. value = self[index];
  32673. result = boundFunction(value, index, O);
  32674. if (TYPE) {
  32675. if (IS_MAP) target[index] = result; // map
  32676. else if (result) switch (TYPE) {
  32677. case 3: return true; // some
  32678. case 5: return value; // find
  32679. case 6: return index; // findIndex
  32680. case 2: push.call(target, value); // filter
  32681. } else if (IS_EVERY) return false; // every
  32682. }
  32683. }
  32684. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  32685. };
  32686. };
  32687. module.exports = {
  32688. // `Array.prototype.forEach` method
  32689. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  32690. forEach: createMethod(0),
  32691. // `Array.prototype.map` method
  32692. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  32693. map: createMethod(1),
  32694. // `Array.prototype.filter` method
  32695. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  32696. filter: createMethod(2),
  32697. // `Array.prototype.some` method
  32698. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  32699. some: createMethod(3),
  32700. // `Array.prototype.every` method
  32701. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  32702. every: createMethod(4),
  32703. // `Array.prototype.find` method
  32704. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  32705. find: createMethod(5),
  32706. // `Array.prototype.findIndex` method
  32707. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  32708. findIndex: createMethod(6)
  32709. };
  32710. }, { "../internals/array-species-create": 227, "../internals/function-bind-context": 248, "../internals/indexed-object": 257, "../internals/to-length": 307, "../internals/to-object": 308 }], 226: [function (require, module, exports) {
  32711. var DESCRIPTORS = require('../internals/descriptors');
  32712. var fails = require('../internals/fails');
  32713. var has = require('../internals/has');
  32714. var defineProperty = Object.defineProperty;
  32715. var cache = {};
  32716. var thrower = function (it) { throw it; };
  32717. module.exports = function (METHOD_NAME, options) {
  32718. if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];
  32719. if (!options) options = {};
  32720. var method = [][METHOD_NAME];
  32721. var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;
  32722. var argument0 = has(options, 0) ? options[0] : thrower;
  32723. var argument1 = has(options, 1) ? options[1] : undefined;
  32724. return cache[METHOD_NAME] = !!method && !fails(function () {
  32725. if (ACCESSORS && !DESCRIPTORS) return true;
  32726. var O = { length: -1 };
  32727. if (ACCESSORS) defineProperty(O, 1, { enumerable: true, get: thrower });
  32728. else O[1] = 1;
  32729. method.call(O, argument0, argument1);
  32730. });
  32731. };
  32732. }, { "../internals/descriptors": 240, "../internals/fails": 247, "../internals/has": 252 }], 227: [function (require, module, exports) {
  32733. var isObject = require('../internals/is-object');
  32734. var isArray = require('../internals/is-array');
  32735. var wellKnownSymbol = require('../internals/well-known-symbol');
  32736. var SPECIES = wellKnownSymbol('species');
  32737. // `ArraySpeciesCreate` abstract operation
  32738. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  32739. module.exports = function (originalArray, length) {
  32740. var C;
  32741. if (isArray(originalArray)) {
  32742. C = originalArray.constructor;
  32743. // cross-realm fallback
  32744. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  32745. else if (isObject(C)) {
  32746. C = C[SPECIES];
  32747. if (C === null) C = undefined;
  32748. }
  32749. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  32750. };
  32751. }, { "../internals/is-array": 261, "../internals/is-object": 263, "../internals/well-known-symbol": 314 }], 228: [function (require, module, exports) {
  32752. var anObject = require('../internals/an-object');
  32753. // call something on iterator step with safe closing on error
  32754. module.exports = function (iterator, fn, value, ENTRIES) {
  32755. try {
  32756. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  32757. // 7.4.6 IteratorClose(iterator, completion)
  32758. } catch (error) {
  32759. var returnMethod = iterator['return'];
  32760. if (returnMethod !== undefined) anObject(returnMethod.call(iterator));
  32761. throw error;
  32762. }
  32763. };
  32764. }, { "../internals/an-object": 223 }], 229: [function (require, module, exports) {
  32765. var wellKnownSymbol = require('../internals/well-known-symbol');
  32766. var ITERATOR = wellKnownSymbol('iterator');
  32767. var SAFE_CLOSING = false;
  32768. try {
  32769. var called = 0;
  32770. var iteratorWithReturn = {
  32771. next: function () {
  32772. return { done: !!called++ };
  32773. },
  32774. 'return': function () {
  32775. SAFE_CLOSING = true;
  32776. }
  32777. };
  32778. iteratorWithReturn[ITERATOR] = function () {
  32779. return this;
  32780. };
  32781. // eslint-disable-next-line no-throw-literal
  32782. Array.from(iteratorWithReturn, function () { throw 2; });
  32783. } catch (error) { /* empty */ }
  32784. module.exports = function (exec, SKIP_CLOSING) {
  32785. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  32786. var ITERATION_SUPPORT = false;
  32787. try {
  32788. var object = {};
  32789. object[ITERATOR] = function () {
  32790. return {
  32791. next: function () {
  32792. return { done: ITERATION_SUPPORT = true };
  32793. }
  32794. };
  32795. };
  32796. exec(object);
  32797. } catch (error) { /* empty */ }
  32798. return ITERATION_SUPPORT;
  32799. };
  32800. }, { "../internals/well-known-symbol": 314 }], 230: [function (require, module, exports) {
  32801. var toString = {}.toString;
  32802. module.exports = function (it) {
  32803. return toString.call(it).slice(8, -1);
  32804. };
  32805. }, {}], 231: [function (require, module, exports) {
  32806. var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');
  32807. var classofRaw = require('../internals/classof-raw');
  32808. var wellKnownSymbol = require('../internals/well-known-symbol');
  32809. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  32810. // ES3 wrong here
  32811. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  32812. // fallback for IE11 Script Access Denied error
  32813. var tryGet = function (it, key) {
  32814. try {
  32815. return it[key];
  32816. } catch (error) { /* empty */ }
  32817. };
  32818. // getting tag from ES6+ `Object.prototype.toString`
  32819. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  32820. var O, tag, result;
  32821. return it === undefined ? 'Undefined' : it === null ? 'Null'
  32822. // @@toStringTag case
  32823. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
  32824. // builtinTag case
  32825. : CORRECT_ARGUMENTS ? classofRaw(O)
  32826. // ES3 arguments fallback
  32827. : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  32828. };
  32829. }, { "../internals/classof-raw": 230, "../internals/to-string-tag-support": 310, "../internals/well-known-symbol": 314 }], 232: [function (require, module, exports) {
  32830. var has = require('../internals/has');
  32831. var ownKeys = require('../internals/own-keys');
  32832. var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
  32833. var definePropertyModule = require('../internals/object-define-property');
  32834. module.exports = function (target, source) {
  32835. var keys = ownKeys(source);
  32836. var defineProperty = definePropertyModule.f;
  32837. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  32838. for (var i = 0; i < keys.length; i++) {
  32839. var key = keys[i];
  32840. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  32841. }
  32842. };
  32843. }, { "../internals/has": 252, "../internals/object-define-property": 278, "../internals/object-get-own-property-descriptor": 279, "../internals/own-keys": 289 }], 233: [function (require, module, exports) {
  32844. var wellKnownSymbol = require('../internals/well-known-symbol');
  32845. var MATCH = wellKnownSymbol('match');
  32846. module.exports = function (METHOD_NAME) {
  32847. var regexp = /./;
  32848. try {
  32849. '/./'[METHOD_NAME](regexp);
  32850. } catch (e) {
  32851. try {
  32852. regexp[MATCH] = false;
  32853. return '/./'[METHOD_NAME](regexp);
  32854. } catch (f) { /* empty */ }
  32855. } return false;
  32856. };
  32857. }, { "../internals/well-known-symbol": 314 }], 234: [function (require, module, exports) {
  32858. var fails = require('../internals/fails');
  32859. module.exports = !fails(function () {
  32860. function F() { /* empty */ }
  32861. F.prototype.constructor = null;
  32862. return Object.getPrototypeOf(new F()) !== F.prototype;
  32863. });
  32864. }, { "../internals/fails": 247 }], 235: [function (require, module, exports) {
  32865. 'use strict';
  32866. var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;
  32867. var create = require('../internals/object-create');
  32868. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  32869. var setToStringTag = require('../internals/set-to-string-tag');
  32870. var Iterators = require('../internals/iterators');
  32871. var returnThis = function () { return this; };
  32872. module.exports = function (IteratorConstructor, NAME, next) {
  32873. var TO_STRING_TAG = NAME + ' Iterator';
  32874. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) });
  32875. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  32876. Iterators[TO_STRING_TAG] = returnThis;
  32877. return IteratorConstructor;
  32878. };
  32879. }, { "../internals/create-property-descriptor": 237, "../internals/iterators": 268, "../internals/iterators-core": 267, "../internals/object-create": 276, "../internals/set-to-string-tag": 298 }], 236: [function (require, module, exports) {
  32880. var DESCRIPTORS = require('../internals/descriptors');
  32881. var definePropertyModule = require('../internals/object-define-property');
  32882. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  32883. module.exports = DESCRIPTORS ? function (object, key, value) {
  32884. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  32885. } : function (object, key, value) {
  32886. object[key] = value;
  32887. return object;
  32888. };
  32889. }, { "../internals/create-property-descriptor": 237, "../internals/descriptors": 240, "../internals/object-define-property": 278 }], 237: [function (require, module, exports) {
  32890. module.exports = function (bitmap, value) {
  32891. return {
  32892. enumerable: !(bitmap & 1),
  32893. configurable: !(bitmap & 2),
  32894. writable: !(bitmap & 4),
  32895. value: value
  32896. };
  32897. };
  32898. }, {}], 238: [function (require, module, exports) {
  32899. 'use strict';
  32900. var $ = require('../internals/export');
  32901. var createIteratorConstructor = require('../internals/create-iterator-constructor');
  32902. var getPrototypeOf = require('../internals/object-get-prototype-of');
  32903. var setPrototypeOf = require('../internals/object-set-prototype-of');
  32904. var setToStringTag = require('../internals/set-to-string-tag');
  32905. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  32906. var redefine = require('../internals/redefine');
  32907. var wellKnownSymbol = require('../internals/well-known-symbol');
  32908. var IS_PURE = require('../internals/is-pure');
  32909. var Iterators = require('../internals/iterators');
  32910. var IteratorsCore = require('../internals/iterators-core');
  32911. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  32912. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  32913. var ITERATOR = wellKnownSymbol('iterator');
  32914. var KEYS = 'keys';
  32915. var VALUES = 'values';
  32916. var ENTRIES = 'entries';
  32917. var returnThis = function () { return this; };
  32918. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  32919. createIteratorConstructor(IteratorConstructor, NAME, next);
  32920. var getIterationMethod = function (KIND) {
  32921. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  32922. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
  32923. switch (KIND) {
  32924. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  32925. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  32926. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  32927. } return function () { return new IteratorConstructor(this); };
  32928. };
  32929. var TO_STRING_TAG = NAME + ' Iterator';
  32930. var INCORRECT_VALUES_NAME = false;
  32931. var IterablePrototype = Iterable.prototype;
  32932. var nativeIterator = IterablePrototype[ITERATOR]
  32933. || IterablePrototype['@@iterator']
  32934. || DEFAULT && IterablePrototype[DEFAULT];
  32935. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  32936. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  32937. var CurrentIteratorPrototype, methods, KEY;
  32938. // fix native
  32939. if (anyNativeIterator) {
  32940. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  32941. if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  32942. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  32943. if (setPrototypeOf) {
  32944. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  32945. } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {
  32946. createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis);
  32947. }
  32948. }
  32949. // Set @@toStringTag to native iterators
  32950. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  32951. if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
  32952. }
  32953. }
  32954. // fix Array#{values, @@iterator}.name in V8 / FF
  32955. if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  32956. INCORRECT_VALUES_NAME = true;
  32957. defaultIterator = function values() { return nativeIterator.call(this); };
  32958. }
  32959. // define iterator
  32960. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  32961. createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator);
  32962. }
  32963. Iterators[NAME] = defaultIterator;
  32964. // export additional methods
  32965. if (DEFAULT) {
  32966. methods = {
  32967. values: getIterationMethod(VALUES),
  32968. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  32969. entries: getIterationMethod(ENTRIES)
  32970. };
  32971. if (FORCED) for (KEY in methods) {
  32972. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  32973. redefine(IterablePrototype, KEY, methods[KEY]);
  32974. }
  32975. } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
  32976. }
  32977. return methods;
  32978. };
  32979. }, { "../internals/create-iterator-constructor": 235, "../internals/create-non-enumerable-property": 236, "../internals/export": 246, "../internals/is-pure": 264, "../internals/iterators": 268, "../internals/iterators-core": 267, "../internals/object-get-prototype-of": 283, "../internals/object-set-prototype-of": 287, "../internals/redefine": 294, "../internals/set-to-string-tag": 298, "../internals/well-known-symbol": 314 }], 239: [function (require, module, exports) {
  32980. var path = require('../internals/path');
  32981. var has = require('../internals/has');
  32982. var wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');
  32983. var defineProperty = require('../internals/object-define-property').f;
  32984. module.exports = function (NAME) {
  32985. var Symbol = path.Symbol || (path.Symbol = {});
  32986. if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {
  32987. value: wrappedWellKnownSymbolModule.f(NAME)
  32988. });
  32989. };
  32990. }, { "../internals/has": 252, "../internals/object-define-property": 278, "../internals/path": 290, "../internals/well-known-symbol-wrapped": 313 }], 240: [function (require, module, exports) {
  32991. var fails = require('../internals/fails');
  32992. // Thank's IE8 for his funny defineProperty
  32993. module.exports = !fails(function () {
  32994. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  32995. });
  32996. }, { "../internals/fails": 247 }], 241: [function (require, module, exports) {
  32997. var global = require('../internals/global');
  32998. var isObject = require('../internals/is-object');
  32999. var document = global.document;
  33000. // typeof document.createElement is 'object' in old IE
  33001. var EXISTS = isObject(document) && isObject(document.createElement);
  33002. module.exports = function (it) {
  33003. return EXISTS ? document.createElement(it) : {};
  33004. };
  33005. }, { "../internals/global": 251, "../internals/is-object": 263 }], 242: [function (require, module, exports) {
  33006. var userAgent = require('../internals/engine-user-agent');
  33007. module.exports = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent);
  33008. }, { "../internals/engine-user-agent": 243 }], 243: [function (require, module, exports) {
  33009. var getBuiltIn = require('../internals/get-built-in');
  33010. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  33011. }, { "../internals/get-built-in": 249 }], 244: [function (require, module, exports) {
  33012. var global = require('../internals/global');
  33013. var userAgent = require('../internals/engine-user-agent');
  33014. var process = global.process;
  33015. var versions = process && process.versions;
  33016. var v8 = versions && versions.v8;
  33017. var match, version;
  33018. if (v8) {
  33019. match = v8.split('.');
  33020. version = match[0] + match[1];
  33021. } else if (userAgent) {
  33022. match = userAgent.match(/Edge\/(\d+)/);
  33023. if (!match || match[1] >= 74) {
  33024. match = userAgent.match(/Chrome\/(\d+)/);
  33025. if (match) version = match[1];
  33026. }
  33027. }
  33028. module.exports = version && +version;
  33029. }, { "../internals/engine-user-agent": 243, "../internals/global": 251 }], 245: [function (require, module, exports) {
  33030. // IE8- don't enum bug keys
  33031. module.exports = [
  33032. 'constructor',
  33033. 'hasOwnProperty',
  33034. 'isPrototypeOf',
  33035. 'propertyIsEnumerable',
  33036. 'toLocaleString',
  33037. 'toString',
  33038. 'valueOf'
  33039. ];
  33040. }, {}], 246: [function (require, module, exports) {
  33041. var global = require('../internals/global');
  33042. var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
  33043. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  33044. var redefine = require('../internals/redefine');
  33045. var setGlobal = require('../internals/set-global');
  33046. var copyConstructorProperties = require('../internals/copy-constructor-properties');
  33047. var isForced = require('../internals/is-forced');
  33048. /*
  33049. options.target - name of the target object
  33050. options.global - target is the global object
  33051. options.stat - export as static methods of target
  33052. options.proto - export as prototype methods of target
  33053. options.real - real prototype method for the `pure` version
  33054. options.forced - export even if the native feature is available
  33055. options.bind - bind methods to the target, required for the `pure` version
  33056. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  33057. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  33058. options.sham - add a flag to not completely full polyfills
  33059. options.enumerable - export as enumerable property
  33060. options.noTargetGet - prevent calling a getter on target
  33061. */
  33062. module.exports = function (options, source) {
  33063. var TARGET = options.target;
  33064. var GLOBAL = options.global;
  33065. var STATIC = options.stat;
  33066. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  33067. if (GLOBAL) {
  33068. target = global;
  33069. } else if (STATIC) {
  33070. target = global[TARGET] || setGlobal(TARGET, {});
  33071. } else {
  33072. target = (global[TARGET] || {}).prototype;
  33073. }
  33074. if (target) for (key in source) {
  33075. sourceProperty = source[key];
  33076. if (options.noTargetGet) {
  33077. descriptor = getOwnPropertyDescriptor(target, key);
  33078. targetProperty = descriptor && descriptor.value;
  33079. } else targetProperty = target[key];
  33080. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  33081. // contained in target
  33082. if (!FORCED && targetProperty !== undefined) {
  33083. if (typeof sourceProperty === typeof targetProperty) continue;
  33084. copyConstructorProperties(sourceProperty, targetProperty);
  33085. }
  33086. // add a flag to not completely full polyfills
  33087. if (options.sham || (targetProperty && targetProperty.sham)) {
  33088. createNonEnumerableProperty(sourceProperty, 'sham', true);
  33089. }
  33090. // extend global
  33091. redefine(target, key, sourceProperty, options);
  33092. }
  33093. };
  33094. }, { "../internals/copy-constructor-properties": 232, "../internals/create-non-enumerable-property": 236, "../internals/global": 251, "../internals/is-forced": 262, "../internals/object-get-own-property-descriptor": 279, "../internals/redefine": 294, "../internals/set-global": 296 }], 247: [function (require, module, exports) {
  33095. module.exports = function (exec) {
  33096. try {
  33097. return !!exec();
  33098. } catch (error) {
  33099. return true;
  33100. }
  33101. };
  33102. }, {}], 248: [function (require, module, exports) {
  33103. var aFunction = require('../internals/a-function');
  33104. // optional / simple context binding
  33105. module.exports = function (fn, that, length) {
  33106. aFunction(fn);
  33107. if (that === undefined) return fn;
  33108. switch (length) {
  33109. case 0: return function () {
  33110. return fn.call(that);
  33111. };
  33112. case 1: return function (a) {
  33113. return fn.call(that, a);
  33114. };
  33115. case 2: return function (a, b) {
  33116. return fn.call(that, a, b);
  33117. };
  33118. case 3: return function (a, b, c) {
  33119. return fn.call(that, a, b, c);
  33120. };
  33121. }
  33122. return function (/* ...args */) {
  33123. return fn.apply(that, arguments);
  33124. };
  33125. };
  33126. }, { "../internals/a-function": 219 }], 249: [function (require, module, exports) {
  33127. var path = require('../internals/path');
  33128. var global = require('../internals/global');
  33129. var aFunction = function (variable) {
  33130. return typeof variable == 'function' ? variable : undefined;
  33131. };
  33132. module.exports = function (namespace, method) {
  33133. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
  33134. : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  33135. };
  33136. }, { "../internals/global": 251, "../internals/path": 290 }], 250: [function (require, module, exports) {
  33137. var classof = require('../internals/classof');
  33138. var Iterators = require('../internals/iterators');
  33139. var wellKnownSymbol = require('../internals/well-known-symbol');
  33140. var ITERATOR = wellKnownSymbol('iterator');
  33141. module.exports = function (it) {
  33142. if (it != undefined) return it[ITERATOR]
  33143. || it['@@iterator']
  33144. || Iterators[classof(it)];
  33145. };
  33146. }, { "../internals/classof": 231, "../internals/iterators": 268, "../internals/well-known-symbol": 314 }], 251: [function (require, module, exports) {
  33147. (function (global) {
  33148. var check = function (it) {
  33149. return it && it.Math == Math && it;
  33150. };
  33151. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  33152. module.exports =
  33153. // eslint-disable-next-line no-undef
  33154. check(typeof globalThis == 'object' && globalThis) ||
  33155. check(typeof window == 'object' && window) ||
  33156. check(typeof self == 'object' && self) ||
  33157. check(typeof global == 'object' && global) ||
  33158. // eslint-disable-next-line no-new-func
  33159. Function('return this')();
  33160. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  33161. }, {}], 252: [function (require, module, exports) {
  33162. var hasOwnProperty = {}.hasOwnProperty;
  33163. module.exports = function (it, key) {
  33164. return hasOwnProperty.call(it, key);
  33165. };
  33166. }, {}], 253: [function (require, module, exports) {
  33167. module.exports = {};
  33168. }, {}], 254: [function (require, module, exports) {
  33169. var global = require('../internals/global');
  33170. module.exports = function (a, b) {
  33171. var console = global.console;
  33172. if (console && console.error) {
  33173. arguments.length === 1 ? console.error(a) : console.error(a, b);
  33174. }
  33175. };
  33176. }, { "../internals/global": 251 }], 255: [function (require, module, exports) {
  33177. var getBuiltIn = require('../internals/get-built-in');
  33178. module.exports = getBuiltIn('document', 'documentElement');
  33179. }, { "../internals/get-built-in": 249 }], 256: [function (require, module, exports) {
  33180. var DESCRIPTORS = require('../internals/descriptors');
  33181. var fails = require('../internals/fails');
  33182. var createElement = require('../internals/document-create-element');
  33183. // Thank's IE8 for his funny defineProperty
  33184. module.exports = !DESCRIPTORS && !fails(function () {
  33185. return Object.defineProperty(createElement('div'), 'a', {
  33186. get: function () { return 7; }
  33187. }).a != 7;
  33188. });
  33189. }, { "../internals/descriptors": 240, "../internals/document-create-element": 241, "../internals/fails": 247 }], 257: [function (require, module, exports) {
  33190. var fails = require('../internals/fails');
  33191. var classof = require('../internals/classof-raw');
  33192. var split = ''.split;
  33193. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  33194. module.exports = fails(function () {
  33195. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  33196. // eslint-disable-next-line no-prototype-builtins
  33197. return !Object('z').propertyIsEnumerable(0);
  33198. }) ? function (it) {
  33199. return classof(it) == 'String' ? split.call(it, '') : Object(it);
  33200. } : Object;
  33201. }, { "../internals/classof-raw": 230, "../internals/fails": 247 }], 258: [function (require, module, exports) {
  33202. var store = require('../internals/shared-store');
  33203. var functionToString = Function.toString;
  33204. // this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper
  33205. if (typeof store.inspectSource != 'function') {
  33206. store.inspectSource = function (it) {
  33207. return functionToString.call(it);
  33208. };
  33209. }
  33210. module.exports = store.inspectSource;
  33211. }, { "../internals/shared-store": 300 }], 259: [function (require, module, exports) {
  33212. var NATIVE_WEAK_MAP = require('../internals/native-weak-map');
  33213. var global = require('../internals/global');
  33214. var isObject = require('../internals/is-object');
  33215. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  33216. var objectHas = require('../internals/has');
  33217. var sharedKey = require('../internals/shared-key');
  33218. var hiddenKeys = require('../internals/hidden-keys');
  33219. var WeakMap = global.WeakMap;
  33220. var set, get, has;
  33221. var enforce = function (it) {
  33222. return has(it) ? get(it) : set(it, {});
  33223. };
  33224. var getterFor = function (TYPE) {
  33225. return function (it) {
  33226. var state;
  33227. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  33228. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  33229. } return state;
  33230. };
  33231. };
  33232. if (NATIVE_WEAK_MAP) {
  33233. var store = new WeakMap();
  33234. var wmget = store.get;
  33235. var wmhas = store.has;
  33236. var wmset = store.set;
  33237. set = function (it, metadata) {
  33238. wmset.call(store, it, metadata);
  33239. return metadata;
  33240. };
  33241. get = function (it) {
  33242. return wmget.call(store, it) || {};
  33243. };
  33244. has = function (it) {
  33245. return wmhas.call(store, it);
  33246. };
  33247. } else {
  33248. var STATE = sharedKey('state');
  33249. hiddenKeys[STATE] = true;
  33250. set = function (it, metadata) {
  33251. createNonEnumerableProperty(it, STATE, metadata);
  33252. return metadata;
  33253. };
  33254. get = function (it) {
  33255. return objectHas(it, STATE) ? it[STATE] : {};
  33256. };
  33257. has = function (it) {
  33258. return objectHas(it, STATE);
  33259. };
  33260. }
  33261. module.exports = {
  33262. set: set,
  33263. get: get,
  33264. has: has,
  33265. enforce: enforce,
  33266. getterFor: getterFor
  33267. };
  33268. }, { "../internals/create-non-enumerable-property": 236, "../internals/global": 251, "../internals/has": 252, "../internals/hidden-keys": 253, "../internals/is-object": 263, "../internals/native-weak-map": 272, "../internals/shared-key": 299 }], 260: [function (require, module, exports) {
  33269. var wellKnownSymbol = require('../internals/well-known-symbol');
  33270. var Iterators = require('../internals/iterators');
  33271. var ITERATOR = wellKnownSymbol('iterator');
  33272. var ArrayPrototype = Array.prototype;
  33273. // check on default Array iterator
  33274. module.exports = function (it) {
  33275. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  33276. };
  33277. }, { "../internals/iterators": 268, "../internals/well-known-symbol": 314 }], 261: [function (require, module, exports) {
  33278. var classof = require('../internals/classof-raw');
  33279. // `IsArray` abstract operation
  33280. // https://tc39.github.io/ecma262/#sec-isarray
  33281. module.exports = Array.isArray || function isArray(arg) {
  33282. return classof(arg) == 'Array';
  33283. };
  33284. }, { "../internals/classof-raw": 230 }], 262: [function (require, module, exports) {
  33285. var fails = require('../internals/fails');
  33286. var replacement = /#|\.prototype\./;
  33287. var isForced = function (feature, detection) {
  33288. var value = data[normalize(feature)];
  33289. return value == POLYFILL ? true
  33290. : value == NATIVE ? false
  33291. : typeof detection == 'function' ? fails(detection)
  33292. : !!detection;
  33293. };
  33294. var normalize = isForced.normalize = function (string) {
  33295. return String(string).replace(replacement, '.').toLowerCase();
  33296. };
  33297. var data = isForced.data = {};
  33298. var NATIVE = isForced.NATIVE = 'N';
  33299. var POLYFILL = isForced.POLYFILL = 'P';
  33300. module.exports = isForced;
  33301. }, { "../internals/fails": 247 }], 263: [function (require, module, exports) {
  33302. module.exports = function (it) {
  33303. return typeof it === 'object' ? it !== null : typeof it === 'function';
  33304. };
  33305. }, {}], 264: [function (require, module, exports) {
  33306. module.exports = false;
  33307. }, {}], 265: [function (require, module, exports) {
  33308. var isObject = require('../internals/is-object');
  33309. var classof = require('../internals/classof-raw');
  33310. var wellKnownSymbol = require('../internals/well-known-symbol');
  33311. var MATCH = wellKnownSymbol('match');
  33312. // `IsRegExp` abstract operation
  33313. // https://tc39.github.io/ecma262/#sec-isregexp
  33314. module.exports = function (it) {
  33315. var isRegExp;
  33316. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  33317. };
  33318. }, { "../internals/classof-raw": 230, "../internals/is-object": 263, "../internals/well-known-symbol": 314 }], 266: [function (require, module, exports) {
  33319. var anObject = require('../internals/an-object');
  33320. var isArrayIteratorMethod = require('../internals/is-array-iterator-method');
  33321. var toLength = require('../internals/to-length');
  33322. var bind = require('../internals/function-bind-context');
  33323. var getIteratorMethod = require('../internals/get-iterator-method');
  33324. var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
  33325. var Result = function (stopped, result) {
  33326. this.stopped = stopped;
  33327. this.result = result;
  33328. };
  33329. var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {
  33330. var boundFunction = bind(fn, that, AS_ENTRIES ? 2 : 1);
  33331. var iterator, iterFn, index, length, result, next, step;
  33332. if (IS_ITERATOR) {
  33333. iterator = iterable;
  33334. } else {
  33335. iterFn = getIteratorMethod(iterable);
  33336. if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
  33337. // optimisation for array iterators
  33338. if (isArrayIteratorMethod(iterFn)) {
  33339. for (index = 0, length = toLength(iterable.length); length > index; index++) {
  33340. result = AS_ENTRIES
  33341. ? boundFunction(anObject(step = iterable[index])[0], step[1])
  33342. : boundFunction(iterable[index]);
  33343. if (result && result instanceof Result) return result;
  33344. } return new Result(false);
  33345. }
  33346. iterator = iterFn.call(iterable);
  33347. }
  33348. next = iterator.next;
  33349. while (!(step = next.call(iterator)).done) {
  33350. result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);
  33351. if (typeof result == 'object' && result && result instanceof Result) return result;
  33352. } return new Result(false);
  33353. };
  33354. iterate.stop = function (result) {
  33355. return new Result(true, result);
  33356. };
  33357. }, { "../internals/an-object": 223, "../internals/call-with-safe-iteration-closing": 228, "../internals/function-bind-context": 248, "../internals/get-iterator-method": 250, "../internals/is-array-iterator-method": 260, "../internals/to-length": 307 }], 267: [function (require, module, exports) {
  33358. 'use strict';
  33359. var getPrototypeOf = require('../internals/object-get-prototype-of');
  33360. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  33361. var has = require('../internals/has');
  33362. var wellKnownSymbol = require('../internals/well-known-symbol');
  33363. var IS_PURE = require('../internals/is-pure');
  33364. var ITERATOR = wellKnownSymbol('iterator');
  33365. var BUGGY_SAFARI_ITERATORS = false;
  33366. var returnThis = function () { return this; };
  33367. // `%IteratorPrototype%` object
  33368. // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
  33369. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  33370. if ([].keys) {
  33371. arrayIterator = [].keys();
  33372. // Safari 8 has buggy iterators w/o `next`
  33373. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  33374. else {
  33375. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  33376. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  33377. }
  33378. }
  33379. if (IteratorPrototype == undefined) IteratorPrototype = {};
  33380. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  33381. if (!IS_PURE && !has(IteratorPrototype, ITERATOR)) {
  33382. createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
  33383. }
  33384. module.exports = {
  33385. IteratorPrototype: IteratorPrototype,
  33386. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  33387. };
  33388. }, { "../internals/create-non-enumerable-property": 236, "../internals/has": 252, "../internals/is-pure": 264, "../internals/object-get-prototype-of": 283, "../internals/well-known-symbol": 314 }], 268: [function (require, module, exports) {
  33389. arguments[4][253][0].apply(exports, arguments)
  33390. }, { "dup": 253 }], 269: [function (require, module, exports) {
  33391. var global = require('../internals/global');
  33392. var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
  33393. var classof = require('../internals/classof-raw');
  33394. var macrotask = require('../internals/task').set;
  33395. var IS_IOS = require('../internals/engine-is-ios');
  33396. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  33397. var process = global.process;
  33398. var Promise = global.Promise;
  33399. var IS_NODE = classof(process) == 'process';
  33400. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  33401. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  33402. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  33403. var flush, head, last, notify, toggle, node, promise, then;
  33404. // modern engines have queueMicrotask method
  33405. if (!queueMicrotask) {
  33406. flush = function () {
  33407. var parent, fn;
  33408. if (IS_NODE && (parent = process.domain)) parent.exit();
  33409. while (head) {
  33410. fn = head.fn;
  33411. head = head.next;
  33412. try {
  33413. fn();
  33414. } catch (error) {
  33415. if (head) notify();
  33416. else last = undefined;
  33417. throw error;
  33418. }
  33419. } last = undefined;
  33420. if (parent) parent.enter();
  33421. };
  33422. // Node.js
  33423. if (IS_NODE) {
  33424. notify = function () {
  33425. process.nextTick(flush);
  33426. };
  33427. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  33428. } else if (MutationObserver && !IS_IOS) {
  33429. toggle = true;
  33430. node = document.createTextNode('');
  33431. new MutationObserver(flush).observe(node, { characterData: true });
  33432. notify = function () {
  33433. node.data = toggle = !toggle;
  33434. };
  33435. // environments with maybe non-completely correct, but existent Promise
  33436. } else if (Promise && Promise.resolve) {
  33437. // Promise.resolve without an argument throws an error in LG WebOS 2
  33438. promise = Promise.resolve(undefined);
  33439. then = promise.then;
  33440. notify = function () {
  33441. then.call(promise, flush);
  33442. };
  33443. // for other environments - macrotask based on:
  33444. // - setImmediate
  33445. // - MessageChannel
  33446. // - window.postMessag
  33447. // - onreadystatechange
  33448. // - setTimeout
  33449. } else {
  33450. notify = function () {
  33451. // strange IE + webpack dev server bug - use .call(global)
  33452. macrotask.call(global, flush);
  33453. };
  33454. }
  33455. }
  33456. module.exports = queueMicrotask || function (fn) {
  33457. var task = { fn: fn, next: undefined };
  33458. if (last) last.next = task;
  33459. if (!head) {
  33460. head = task;
  33461. notify();
  33462. } last = task;
  33463. };
  33464. }, { "../internals/classof-raw": 230, "../internals/engine-is-ios": 242, "../internals/global": 251, "../internals/object-get-own-property-descriptor": 279, "../internals/task": 303 }], 270: [function (require, module, exports) {
  33465. var global = require('../internals/global');
  33466. module.exports = global.Promise;
  33467. }, { "../internals/global": 251 }], 271: [function (require, module, exports) {
  33468. var fails = require('../internals/fails');
  33469. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  33470. // Chrome 38 Symbol has incorrect toString conversion
  33471. // eslint-disable-next-line no-undef
  33472. return !String(Symbol());
  33473. });
  33474. }, { "../internals/fails": 247 }], 272: [function (require, module, exports) {
  33475. var global = require('../internals/global');
  33476. var inspectSource = require('../internals/inspect-source');
  33477. var WeakMap = global.WeakMap;
  33478. module.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));
  33479. }, { "../internals/global": 251, "../internals/inspect-source": 258 }], 273: [function (require, module, exports) {
  33480. 'use strict';
  33481. var aFunction = require('../internals/a-function');
  33482. var PromiseCapability = function (C) {
  33483. var resolve, reject;
  33484. this.promise = new C(function ($$resolve, $$reject) {
  33485. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  33486. resolve = $$resolve;
  33487. reject = $$reject;
  33488. });
  33489. this.resolve = aFunction(resolve);
  33490. this.reject = aFunction(reject);
  33491. };
  33492. // 25.4.1.5 NewPromiseCapability(C)
  33493. module.exports.f = function (C) {
  33494. return new PromiseCapability(C);
  33495. };
  33496. }, { "../internals/a-function": 219 }], 274: [function (require, module, exports) {
  33497. var isRegExp = require('../internals/is-regexp');
  33498. module.exports = function (it) {
  33499. if (isRegExp(it)) {
  33500. throw TypeError("The method doesn't accept regular expressions");
  33501. } return it;
  33502. };
  33503. }, { "../internals/is-regexp": 265 }], 275: [function (require, module, exports) {
  33504. 'use strict';
  33505. var DESCRIPTORS = require('../internals/descriptors');
  33506. var fails = require('../internals/fails');
  33507. var objectKeys = require('../internals/object-keys');
  33508. var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
  33509. var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
  33510. var toObject = require('../internals/to-object');
  33511. var IndexedObject = require('../internals/indexed-object');
  33512. var nativeAssign = Object.assign;
  33513. var defineProperty = Object.defineProperty;
  33514. // `Object.assign` method
  33515. // https://tc39.github.io/ecma262/#sec-object.assign
  33516. module.exports = !nativeAssign || fails(function () {
  33517. // should have correct order of operations (Edge bug)
  33518. if (DESCRIPTORS && nativeAssign({ b: 1 }, nativeAssign(defineProperty({}, 'a', {
  33519. enumerable: true,
  33520. get: function () {
  33521. defineProperty(this, 'b', {
  33522. value: 3,
  33523. enumerable: false
  33524. });
  33525. }
  33526. }), { b: 2 })).b !== 1) return true;
  33527. // should work with symbols and should have deterministic property order (V8 bug)
  33528. var A = {};
  33529. var B = {};
  33530. // eslint-disable-next-line no-undef
  33531. var symbol = Symbol();
  33532. var alphabet = 'abcdefghijklmnopqrst';
  33533. A[symbol] = 7;
  33534. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  33535. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  33536. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  33537. var T = toObject(target);
  33538. var argumentsLength = arguments.length;
  33539. var index = 1;
  33540. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  33541. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  33542. while (argumentsLength > index) {
  33543. var S = IndexedObject(arguments[index++]);
  33544. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  33545. var length = keys.length;
  33546. var j = 0;
  33547. var key;
  33548. while (length > j) {
  33549. key = keys[j++];
  33550. if (!DESCRIPTORS || propertyIsEnumerable.call(S, key)) T[key] = S[key];
  33551. }
  33552. } return T;
  33553. } : nativeAssign;
  33554. }, { "../internals/descriptors": 240, "../internals/fails": 247, "../internals/indexed-object": 257, "../internals/object-get-own-property-symbols": 282, "../internals/object-keys": 285, "../internals/object-property-is-enumerable": 286, "../internals/to-object": 308 }], 276: [function (require, module, exports) {
  33555. var anObject = require('../internals/an-object');
  33556. var defineProperties = require('../internals/object-define-properties');
  33557. var enumBugKeys = require('../internals/enum-bug-keys');
  33558. var hiddenKeys = require('../internals/hidden-keys');
  33559. var html = require('../internals/html');
  33560. var documentCreateElement = require('../internals/document-create-element');
  33561. var sharedKey = require('../internals/shared-key');
  33562. var GT = '>';
  33563. var LT = '<';
  33564. var PROTOTYPE = 'prototype';
  33565. var SCRIPT = 'script';
  33566. var IE_PROTO = sharedKey('IE_PROTO');
  33567. var EmptyConstructor = function () { /* empty */ };
  33568. var scriptTag = function (content) {
  33569. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  33570. };
  33571. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  33572. var NullProtoObjectViaActiveX = function (activeXDocument) {
  33573. activeXDocument.write(scriptTag(''));
  33574. activeXDocument.close();
  33575. var temp = activeXDocument.parentWindow.Object;
  33576. activeXDocument = null; // avoid memory leak
  33577. return temp;
  33578. };
  33579. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  33580. var NullProtoObjectViaIFrame = function () {
  33581. // Thrash, waste and sodomy: IE GC bug
  33582. var iframe = documentCreateElement('iframe');
  33583. var JS = 'java' + SCRIPT + ':';
  33584. var iframeDocument;
  33585. iframe.style.display = 'none';
  33586. html.appendChild(iframe);
  33587. // https://github.com/zloirock/core-js/issues/475
  33588. iframe.src = String(JS);
  33589. iframeDocument = iframe.contentWindow.document;
  33590. iframeDocument.open();
  33591. iframeDocument.write(scriptTag('document.F=Object'));
  33592. iframeDocument.close();
  33593. return iframeDocument.F;
  33594. };
  33595. // Check for document.domain and active x support
  33596. // No need to use active x approach when document.domain is not set
  33597. // see https://github.com/es-shims/es5-shim/issues/150
  33598. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  33599. // avoid IE GC bug
  33600. var activeXDocument;
  33601. var NullProtoObject = function () {
  33602. try {
  33603. /* global ActiveXObject */
  33604. activeXDocument = document.domain && new ActiveXObject('htmlfile');
  33605. } catch (error) { /* ignore */ }
  33606. NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
  33607. var length = enumBugKeys.length;
  33608. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  33609. return NullProtoObject();
  33610. };
  33611. hiddenKeys[IE_PROTO] = true;
  33612. // `Object.create` method
  33613. // https://tc39.github.io/ecma262/#sec-object.create
  33614. module.exports = Object.create || function create(O, Properties) {
  33615. var result;
  33616. if (O !== null) {
  33617. EmptyConstructor[PROTOTYPE] = anObject(O);
  33618. result = new EmptyConstructor();
  33619. EmptyConstructor[PROTOTYPE] = null;
  33620. // add "__proto__" for Object.getPrototypeOf polyfill
  33621. result[IE_PROTO] = O;
  33622. } else result = NullProtoObject();
  33623. return Properties === undefined ? result : defineProperties(result, Properties);
  33624. };
  33625. }, { "../internals/an-object": 223, "../internals/document-create-element": 241, "../internals/enum-bug-keys": 245, "../internals/hidden-keys": 253, "../internals/html": 255, "../internals/object-define-properties": 277, "../internals/shared-key": 299 }], 277: [function (require, module, exports) {
  33626. var DESCRIPTORS = require('../internals/descriptors');
  33627. var definePropertyModule = require('../internals/object-define-property');
  33628. var anObject = require('../internals/an-object');
  33629. var objectKeys = require('../internals/object-keys');
  33630. // `Object.defineProperties` method
  33631. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  33632. module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  33633. anObject(O);
  33634. var keys = objectKeys(Properties);
  33635. var length = keys.length;
  33636. var index = 0;
  33637. var key;
  33638. while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);
  33639. return O;
  33640. };
  33641. }, { "../internals/an-object": 223, "../internals/descriptors": 240, "../internals/object-define-property": 278, "../internals/object-keys": 285 }], 278: [function (require, module, exports) {
  33642. var DESCRIPTORS = require('../internals/descriptors');
  33643. var IE8_DOM_DEFINE = require('../internals/ie8-dom-define');
  33644. var anObject = require('../internals/an-object');
  33645. var toPrimitive = require('../internals/to-primitive');
  33646. var nativeDefineProperty = Object.defineProperty;
  33647. // `Object.defineProperty` method
  33648. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  33649. exports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  33650. anObject(O);
  33651. P = toPrimitive(P, true);
  33652. anObject(Attributes);
  33653. if (IE8_DOM_DEFINE) try {
  33654. return nativeDefineProperty(O, P, Attributes);
  33655. } catch (error) { /* empty */ }
  33656. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  33657. if ('value' in Attributes) O[P] = Attributes.value;
  33658. return O;
  33659. };
  33660. }, { "../internals/an-object": 223, "../internals/descriptors": 240, "../internals/ie8-dom-define": 256, "../internals/to-primitive": 309 }], 279: [function (require, module, exports) {
  33661. var DESCRIPTORS = require('../internals/descriptors');
  33662. var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
  33663. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  33664. var toIndexedObject = require('../internals/to-indexed-object');
  33665. var toPrimitive = require('../internals/to-primitive');
  33666. var has = require('../internals/has');
  33667. var IE8_DOM_DEFINE = require('../internals/ie8-dom-define');
  33668. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  33669. // `Object.getOwnPropertyDescriptor` method
  33670. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
  33671. exports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  33672. O = toIndexedObject(O);
  33673. P = toPrimitive(P, true);
  33674. if (IE8_DOM_DEFINE) try {
  33675. return nativeGetOwnPropertyDescriptor(O, P);
  33676. } catch (error) { /* empty */ }
  33677. if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);
  33678. };
  33679. }, { "../internals/create-property-descriptor": 237, "../internals/descriptors": 240, "../internals/has": 252, "../internals/ie8-dom-define": 256, "../internals/object-property-is-enumerable": 286, "../internals/to-indexed-object": 305, "../internals/to-primitive": 309 }], 280: [function (require, module, exports) {
  33680. var toIndexedObject = require('../internals/to-indexed-object');
  33681. var nativeGetOwnPropertyNames = require('../internals/object-get-own-property-names').f;
  33682. var toString = {}.toString;
  33683. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  33684. ? Object.getOwnPropertyNames(window) : [];
  33685. var getWindowNames = function (it) {
  33686. try {
  33687. return nativeGetOwnPropertyNames(it);
  33688. } catch (error) {
  33689. return windowNames.slice();
  33690. }
  33691. };
  33692. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  33693. module.exports.f = function getOwnPropertyNames(it) {
  33694. return windowNames && toString.call(it) == '[object Window]'
  33695. ? getWindowNames(it)
  33696. : nativeGetOwnPropertyNames(toIndexedObject(it));
  33697. };
  33698. }, { "../internals/object-get-own-property-names": 281, "../internals/to-indexed-object": 305 }], 281: [function (require, module, exports) {
  33699. var internalObjectKeys = require('../internals/object-keys-internal');
  33700. var enumBugKeys = require('../internals/enum-bug-keys');
  33701. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  33702. // `Object.getOwnPropertyNames` method
  33703. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  33704. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  33705. return internalObjectKeys(O, hiddenKeys);
  33706. };
  33707. }, { "../internals/enum-bug-keys": 245, "../internals/object-keys-internal": 284 }], 282: [function (require, module, exports) {
  33708. exports.f = Object.getOwnPropertySymbols;
  33709. }, {}], 283: [function (require, module, exports) {
  33710. var has = require('../internals/has');
  33711. var toObject = require('../internals/to-object');
  33712. var sharedKey = require('../internals/shared-key');
  33713. var CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');
  33714. var IE_PROTO = sharedKey('IE_PROTO');
  33715. var ObjectPrototype = Object.prototype;
  33716. // `Object.getPrototypeOf` method
  33717. // https://tc39.github.io/ecma262/#sec-object.getprototypeof
  33718. module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
  33719. O = toObject(O);
  33720. if (has(O, IE_PROTO)) return O[IE_PROTO];
  33721. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  33722. return O.constructor.prototype;
  33723. } return O instanceof Object ? ObjectPrototype : null;
  33724. };
  33725. }, { "../internals/correct-prototype-getter": 234, "../internals/has": 252, "../internals/shared-key": 299, "../internals/to-object": 308 }], 284: [function (require, module, exports) {
  33726. var has = require('../internals/has');
  33727. var toIndexedObject = require('../internals/to-indexed-object');
  33728. var indexOf = require('../internals/array-includes').indexOf;
  33729. var hiddenKeys = require('../internals/hidden-keys');
  33730. module.exports = function (object, names) {
  33731. var O = toIndexedObject(object);
  33732. var i = 0;
  33733. var result = [];
  33734. var key;
  33735. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  33736. // Don't enum bug & hidden keys
  33737. while (names.length > i) if (has(O, key = names[i++])) {
  33738. ~indexOf(result, key) || result.push(key);
  33739. }
  33740. return result;
  33741. };
  33742. }, { "../internals/array-includes": 224, "../internals/has": 252, "../internals/hidden-keys": 253, "../internals/to-indexed-object": 305 }], 285: [function (require, module, exports) {
  33743. var internalObjectKeys = require('../internals/object-keys-internal');
  33744. var enumBugKeys = require('../internals/enum-bug-keys');
  33745. // `Object.keys` method
  33746. // https://tc39.github.io/ecma262/#sec-object.keys
  33747. module.exports = Object.keys || function keys(O) {
  33748. return internalObjectKeys(O, enumBugKeys);
  33749. };
  33750. }, { "../internals/enum-bug-keys": 245, "../internals/object-keys-internal": 284 }], 286: [function (require, module, exports) {
  33751. 'use strict';
  33752. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  33753. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  33754. // Nashorn ~ JDK8 bug
  33755. var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  33756. // `Object.prototype.propertyIsEnumerable` method implementation
  33757. // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
  33758. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  33759. var descriptor = getOwnPropertyDescriptor(this, V);
  33760. return !!descriptor && descriptor.enumerable;
  33761. } : nativePropertyIsEnumerable;
  33762. }, {}], 287: [function (require, module, exports) {
  33763. var anObject = require('../internals/an-object');
  33764. var aPossiblePrototype = require('../internals/a-possible-prototype');
  33765. // `Object.setPrototypeOf` method
  33766. // https://tc39.github.io/ecma262/#sec-object.setprototypeof
  33767. // Works with __proto__ only. Old v8 can't work with null proto objects.
  33768. /* eslint-disable no-proto */
  33769. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  33770. var CORRECT_SETTER = false;
  33771. var test = {};
  33772. var setter;
  33773. try {
  33774. setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
  33775. setter.call(test, []);
  33776. CORRECT_SETTER = test instanceof Array;
  33777. } catch (error) { /* empty */ }
  33778. return function setPrototypeOf(O, proto) {
  33779. anObject(O);
  33780. aPossiblePrototype(proto);
  33781. if (CORRECT_SETTER) setter.call(O, proto);
  33782. else O.__proto__ = proto;
  33783. return O;
  33784. };
  33785. }() : undefined);
  33786. }, { "../internals/a-possible-prototype": 220, "../internals/an-object": 223 }], 288: [function (require, module, exports) {
  33787. var DESCRIPTORS = require('../internals/descriptors');
  33788. var objectKeys = require('../internals/object-keys');
  33789. var toIndexedObject = require('../internals/to-indexed-object');
  33790. var propertyIsEnumerable = require('../internals/object-property-is-enumerable').f;
  33791. // `Object.{ entries, values }` methods implementation
  33792. var createMethod = function (TO_ENTRIES) {
  33793. return function (it) {
  33794. var O = toIndexedObject(it);
  33795. var keys = objectKeys(O);
  33796. var length = keys.length;
  33797. var i = 0;
  33798. var result = [];
  33799. var key;
  33800. while (length > i) {
  33801. key = keys[i++];
  33802. if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {
  33803. result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
  33804. }
  33805. }
  33806. return result;
  33807. };
  33808. };
  33809. module.exports = {
  33810. // `Object.entries` method
  33811. // https://tc39.github.io/ecma262/#sec-object.entries
  33812. entries: createMethod(true),
  33813. // `Object.values` method
  33814. // https://tc39.github.io/ecma262/#sec-object.values
  33815. values: createMethod(false)
  33816. };
  33817. }, { "../internals/descriptors": 240, "../internals/object-keys": 285, "../internals/object-property-is-enumerable": 286, "../internals/to-indexed-object": 305 }], 289: [function (require, module, exports) {
  33818. var getBuiltIn = require('../internals/get-built-in');
  33819. var getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');
  33820. var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
  33821. var anObject = require('../internals/an-object');
  33822. // all object keys, includes non-enumerable and symbols
  33823. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  33824. var keys = getOwnPropertyNamesModule.f(anObject(it));
  33825. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  33826. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  33827. };
  33828. }, { "../internals/an-object": 223, "../internals/get-built-in": 249, "../internals/object-get-own-property-names": 281, "../internals/object-get-own-property-symbols": 282 }], 290: [function (require, module, exports) {
  33829. var global = require('../internals/global');
  33830. module.exports = global;
  33831. }, { "../internals/global": 251 }], 291: [function (require, module, exports) {
  33832. module.exports = function (exec) {
  33833. try {
  33834. return { error: false, value: exec() };
  33835. } catch (error) {
  33836. return { error: true, value: error };
  33837. }
  33838. };
  33839. }, {}], 292: [function (require, module, exports) {
  33840. var anObject = require('../internals/an-object');
  33841. var isObject = require('../internals/is-object');
  33842. var newPromiseCapability = require('../internals/new-promise-capability');
  33843. module.exports = function (C, x) {
  33844. anObject(C);
  33845. if (isObject(x) && x.constructor === C) return x;
  33846. var promiseCapability = newPromiseCapability.f(C);
  33847. var resolve = promiseCapability.resolve;
  33848. resolve(x);
  33849. return promiseCapability.promise;
  33850. };
  33851. }, { "../internals/an-object": 223, "../internals/is-object": 263, "../internals/new-promise-capability": 273 }], 293: [function (require, module, exports) {
  33852. var redefine = require('../internals/redefine');
  33853. module.exports = function (target, src, options) {
  33854. for (var key in src) redefine(target, key, src[key], options);
  33855. return target;
  33856. };
  33857. }, { "../internals/redefine": 294 }], 294: [function (require, module, exports) {
  33858. var global = require('../internals/global');
  33859. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  33860. var has = require('../internals/has');
  33861. var setGlobal = require('../internals/set-global');
  33862. var inspectSource = require('../internals/inspect-source');
  33863. var InternalStateModule = require('../internals/internal-state');
  33864. var getInternalState = InternalStateModule.get;
  33865. var enforceInternalState = InternalStateModule.enforce;
  33866. var TEMPLATE = String(String).split('String');
  33867. (module.exports = function (O, key, value, options) {
  33868. var unsafe = options ? !!options.unsafe : false;
  33869. var simple = options ? !!options.enumerable : false;
  33870. var noTargetGet = options ? !!options.noTargetGet : false;
  33871. if (typeof value == 'function') {
  33872. if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);
  33873. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  33874. }
  33875. if (O === global) {
  33876. if (simple) O[key] = value;
  33877. else setGlobal(key, value);
  33878. return;
  33879. } else if (!unsafe) {
  33880. delete O[key];
  33881. } else if (!noTargetGet && O[key]) {
  33882. simple = true;
  33883. }
  33884. if (simple) O[key] = value;
  33885. else createNonEnumerableProperty(O, key, value);
  33886. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  33887. })(Function.prototype, 'toString', function toString() {
  33888. return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
  33889. });
  33890. }, { "../internals/create-non-enumerable-property": 236, "../internals/global": 251, "../internals/has": 252, "../internals/inspect-source": 258, "../internals/internal-state": 259, "../internals/set-global": 296 }], 295: [function (require, module, exports) {
  33891. // `RequireObjectCoercible` abstract operation
  33892. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  33893. module.exports = function (it) {
  33894. if (it == undefined) throw TypeError("Can't call method on " + it);
  33895. return it;
  33896. };
  33897. }, {}], 296: [function (require, module, exports) {
  33898. var global = require('../internals/global');
  33899. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  33900. module.exports = function (key, value) {
  33901. try {
  33902. createNonEnumerableProperty(global, key, value);
  33903. } catch (error) {
  33904. global[key] = value;
  33905. } return value;
  33906. };
  33907. }, { "../internals/create-non-enumerable-property": 236, "../internals/global": 251 }], 297: [function (require, module, exports) {
  33908. 'use strict';
  33909. var getBuiltIn = require('../internals/get-built-in');
  33910. var definePropertyModule = require('../internals/object-define-property');
  33911. var wellKnownSymbol = require('../internals/well-known-symbol');
  33912. var DESCRIPTORS = require('../internals/descriptors');
  33913. var SPECIES = wellKnownSymbol('species');
  33914. module.exports = function (CONSTRUCTOR_NAME) {
  33915. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  33916. var defineProperty = definePropertyModule.f;
  33917. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  33918. defineProperty(Constructor, SPECIES, {
  33919. configurable: true,
  33920. get: function () { return this; }
  33921. });
  33922. }
  33923. };
  33924. }, { "../internals/descriptors": 240, "../internals/get-built-in": 249, "../internals/object-define-property": 278, "../internals/well-known-symbol": 314 }], 298: [function (require, module, exports) {
  33925. var defineProperty = require('../internals/object-define-property').f;
  33926. var has = require('../internals/has');
  33927. var wellKnownSymbol = require('../internals/well-known-symbol');
  33928. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  33929. module.exports = function (it, TAG, STATIC) {
  33930. if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
  33931. defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG });
  33932. }
  33933. };
  33934. }, { "../internals/has": 252, "../internals/object-define-property": 278, "../internals/well-known-symbol": 314 }], 299: [function (require, module, exports) {
  33935. var shared = require('../internals/shared');
  33936. var uid = require('../internals/uid');
  33937. var keys = shared('keys');
  33938. module.exports = function (key) {
  33939. return keys[key] || (keys[key] = uid(key));
  33940. };
  33941. }, { "../internals/shared": 301, "../internals/uid": 311 }], 300: [function (require, module, exports) {
  33942. var global = require('../internals/global');
  33943. var setGlobal = require('../internals/set-global');
  33944. var SHARED = '__core-js_shared__';
  33945. var store = global[SHARED] || setGlobal(SHARED, {});
  33946. module.exports = store;
  33947. }, { "../internals/global": 251, "../internals/set-global": 296 }], 301: [function (require, module, exports) {
  33948. var IS_PURE = require('../internals/is-pure');
  33949. var store = require('../internals/shared-store');
  33950. (module.exports = function (key, value) {
  33951. return store[key] || (store[key] = value !== undefined ? value : {});
  33952. })('versions', []).push({
  33953. version: '3.6.5',
  33954. mode: IS_PURE ? 'pure' : 'global',
  33955. copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
  33956. });
  33957. }, { "../internals/is-pure": 264, "../internals/shared-store": 300 }], 302: [function (require, module, exports) {
  33958. var anObject = require('../internals/an-object');
  33959. var aFunction = require('../internals/a-function');
  33960. var wellKnownSymbol = require('../internals/well-known-symbol');
  33961. var SPECIES = wellKnownSymbol('species');
  33962. // `SpeciesConstructor` abstract operation
  33963. // https://tc39.github.io/ecma262/#sec-speciesconstructor
  33964. module.exports = function (O, defaultConstructor) {
  33965. var C = anObject(O).constructor;
  33966. var S;
  33967. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);
  33968. };
  33969. }, { "../internals/a-function": 219, "../internals/an-object": 223, "../internals/well-known-symbol": 314 }], 303: [function (require, module, exports) {
  33970. var global = require('../internals/global');
  33971. var fails = require('../internals/fails');
  33972. var classof = require('../internals/classof-raw');
  33973. var bind = require('../internals/function-bind-context');
  33974. var html = require('../internals/html');
  33975. var createElement = require('../internals/document-create-element');
  33976. var IS_IOS = require('../internals/engine-is-ios');
  33977. var location = global.location;
  33978. var set = global.setImmediate;
  33979. var clear = global.clearImmediate;
  33980. var process = global.process;
  33981. var MessageChannel = global.MessageChannel;
  33982. var Dispatch = global.Dispatch;
  33983. var counter = 0;
  33984. var queue = {};
  33985. var ONREADYSTATECHANGE = 'onreadystatechange';
  33986. var defer, channel, port;
  33987. var run = function (id) {
  33988. // eslint-disable-next-line no-prototype-builtins
  33989. if (queue.hasOwnProperty(id)) {
  33990. var fn = queue[id];
  33991. delete queue[id];
  33992. fn();
  33993. }
  33994. };
  33995. var runner = function (id) {
  33996. return function () {
  33997. run(id);
  33998. };
  33999. };
  34000. var listener = function (event) {
  34001. run(event.data);
  34002. };
  34003. var post = function (id) {
  34004. // old engines have not location.origin
  34005. global.postMessage(id + '', location.protocol + '//' + location.host);
  34006. };
  34007. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  34008. if (!set || !clear) {
  34009. set = function setImmediate(fn) {
  34010. var args = [];
  34011. var i = 1;
  34012. while (arguments.length > i) args.push(arguments[i++]);
  34013. queue[++counter] = function () {
  34014. // eslint-disable-next-line no-new-func
  34015. (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
  34016. };
  34017. defer(counter);
  34018. return counter;
  34019. };
  34020. clear = function clearImmediate(id) {
  34021. delete queue[id];
  34022. };
  34023. // Node.js 0.8-
  34024. if (classof(process) == 'process') {
  34025. defer = function (id) {
  34026. process.nextTick(runner(id));
  34027. };
  34028. // Sphere (JS game engine) Dispatch API
  34029. } else if (Dispatch && Dispatch.now) {
  34030. defer = function (id) {
  34031. Dispatch.now(runner(id));
  34032. };
  34033. // Browsers with MessageChannel, includes WebWorkers
  34034. // except iOS - https://github.com/zloirock/core-js/issues/624
  34035. } else if (MessageChannel && !IS_IOS) {
  34036. channel = new MessageChannel();
  34037. port = channel.port2;
  34038. channel.port1.onmessage = listener;
  34039. defer = bind(port.postMessage, port, 1);
  34040. // Browsers with postMessage, skip WebWorkers
  34041. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  34042. } else if (
  34043. global.addEventListener &&
  34044. typeof postMessage == 'function' &&
  34045. !global.importScripts &&
  34046. !fails(post) &&
  34047. location.protocol !== 'file:'
  34048. ) {
  34049. defer = post;
  34050. global.addEventListener('message', listener, false);
  34051. // IE8-
  34052. } else if (ONREADYSTATECHANGE in createElement('script')) {
  34053. defer = function (id) {
  34054. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  34055. html.removeChild(this);
  34056. run(id);
  34057. };
  34058. };
  34059. // Rest old browsers
  34060. } else {
  34061. defer = function (id) {
  34062. setTimeout(runner(id), 0);
  34063. };
  34064. }
  34065. }
  34066. module.exports = {
  34067. set: set,
  34068. clear: clear
  34069. };
  34070. }, { "../internals/classof-raw": 230, "../internals/document-create-element": 241, "../internals/engine-is-ios": 242, "../internals/fails": 247, "../internals/function-bind-context": 248, "../internals/global": 251, "../internals/html": 255 }], 304: [function (require, module, exports) {
  34071. var toInteger = require('../internals/to-integer');
  34072. var max = Math.max;
  34073. var min = Math.min;
  34074. // Helper for a popular repeating case of the spec:
  34075. // Let integer be ? ToInteger(index).
  34076. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  34077. module.exports = function (index, length) {
  34078. var integer = toInteger(index);
  34079. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  34080. };
  34081. }, { "../internals/to-integer": 306 }], 305: [function (require, module, exports) {
  34082. // toObject with fallback for non-array-like ES3 strings
  34083. var IndexedObject = require('../internals/indexed-object');
  34084. var requireObjectCoercible = require('../internals/require-object-coercible');
  34085. module.exports = function (it) {
  34086. return IndexedObject(requireObjectCoercible(it));
  34087. };
  34088. }, { "../internals/indexed-object": 257, "../internals/require-object-coercible": 295 }], 306: [function (require, module, exports) {
  34089. var ceil = Math.ceil;
  34090. var floor = Math.floor;
  34091. // `ToInteger` abstract operation
  34092. // https://tc39.github.io/ecma262/#sec-tointeger
  34093. module.exports = function (argument) {
  34094. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  34095. };
  34096. }, {}], 307: [function (require, module, exports) {
  34097. var toInteger = require('../internals/to-integer');
  34098. var min = Math.min;
  34099. // `ToLength` abstract operation
  34100. // https://tc39.github.io/ecma262/#sec-tolength
  34101. module.exports = function (argument) {
  34102. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  34103. };
  34104. }, { "../internals/to-integer": 306 }], 308: [function (require, module, exports) {
  34105. var requireObjectCoercible = require('../internals/require-object-coercible');
  34106. // `ToObject` abstract operation
  34107. // https://tc39.github.io/ecma262/#sec-toobject
  34108. module.exports = function (argument) {
  34109. return Object(requireObjectCoercible(argument));
  34110. };
  34111. }, { "../internals/require-object-coercible": 295 }], 309: [function (require, module, exports) {
  34112. var isObject = require('../internals/is-object');
  34113. // `ToPrimitive` abstract operation
  34114. // https://tc39.github.io/ecma262/#sec-toprimitive
  34115. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  34116. // and the second argument - flag - preferred type is a string
  34117. module.exports = function (input, PREFERRED_STRING) {
  34118. if (!isObject(input)) return input;
  34119. var fn, val;
  34120. if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  34121. if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
  34122. if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  34123. throw TypeError("Can't convert object to primitive value");
  34124. };
  34125. }, { "../internals/is-object": 263 }], 310: [function (require, module, exports) {
  34126. var wellKnownSymbol = require('../internals/well-known-symbol');
  34127. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  34128. var test = {};
  34129. test[TO_STRING_TAG] = 'z';
  34130. module.exports = String(test) === '[object z]';
  34131. }, { "../internals/well-known-symbol": 314 }], 311: [function (require, module, exports) {
  34132. var id = 0;
  34133. var postfix = Math.random();
  34134. module.exports = function (key) {
  34135. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  34136. };
  34137. }, {}], 312: [function (require, module, exports) {
  34138. var NATIVE_SYMBOL = require('../internals/native-symbol');
  34139. module.exports = NATIVE_SYMBOL
  34140. // eslint-disable-next-line no-undef
  34141. && !Symbol.sham
  34142. // eslint-disable-next-line no-undef
  34143. && typeof Symbol.iterator == 'symbol';
  34144. }, { "../internals/native-symbol": 271 }], 313: [function (require, module, exports) {
  34145. var wellKnownSymbol = require('../internals/well-known-symbol');
  34146. exports.f = wellKnownSymbol;
  34147. }, { "../internals/well-known-symbol": 314 }], 314: [function (require, module, exports) {
  34148. var global = require('../internals/global');
  34149. var shared = require('../internals/shared');
  34150. var has = require('../internals/has');
  34151. var uid = require('../internals/uid');
  34152. var NATIVE_SYMBOL = require('../internals/native-symbol');
  34153. var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');
  34154. var WellKnownSymbolsStore = shared('wks');
  34155. var Symbol = global.Symbol;
  34156. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  34157. module.exports = function (name) {
  34158. if (!has(WellKnownSymbolsStore, name)) {
  34159. if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];
  34160. else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  34161. } return WellKnownSymbolsStore[name];
  34162. };
  34163. }, { "../internals/global": 251, "../internals/has": 252, "../internals/native-symbol": 271, "../internals/shared": 301, "../internals/uid": 311, "../internals/use-symbol-as-uid": 312 }], 315: [function (require, module, exports) {
  34164. 'use strict';
  34165. var $ = require('../internals/export');
  34166. var $findIndex = require('../internals/array-iteration').findIndex;
  34167. var addToUnscopables = require('../internals/add-to-unscopables');
  34168. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  34169. var FIND_INDEX = 'findIndex';
  34170. var SKIPS_HOLES = true;
  34171. var USES_TO_LENGTH = arrayMethodUsesToLength(FIND_INDEX);
  34172. // Shouldn't skip holes
  34173. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });
  34174. // `Array.prototype.findIndex` method
  34175. // https://tc39.github.io/ecma262/#sec-array.prototype.findindex
  34176. $({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {
  34177. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  34178. return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  34179. }
  34180. });
  34181. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  34182. addToUnscopables(FIND_INDEX);
  34183. }, { "../internals/add-to-unscopables": 221, "../internals/array-iteration": 225, "../internals/array-method-uses-to-length": 226, "../internals/export": 246 }], 316: [function (require, module, exports) {
  34184. 'use strict';
  34185. var $ = require('../internals/export');
  34186. var $find = require('../internals/array-iteration').find;
  34187. var addToUnscopables = require('../internals/add-to-unscopables');
  34188. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  34189. var FIND = 'find';
  34190. var SKIPS_HOLES = true;
  34191. var USES_TO_LENGTH = arrayMethodUsesToLength(FIND);
  34192. // Shouldn't skip holes
  34193. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  34194. // `Array.prototype.find` method
  34195. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  34196. $({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {
  34197. find: function find(callbackfn /* , that = undefined */) {
  34198. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  34199. }
  34200. });
  34201. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  34202. addToUnscopables(FIND);
  34203. }, { "../internals/add-to-unscopables": 221, "../internals/array-iteration": 225, "../internals/array-method-uses-to-length": 226, "../internals/export": 246 }], 317: [function (require, module, exports) {
  34204. 'use strict';
  34205. var $ = require('../internals/export');
  34206. var $includes = require('../internals/array-includes').includes;
  34207. var addToUnscopables = require('../internals/add-to-unscopables');
  34208. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  34209. var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  34210. // `Array.prototype.includes` method
  34211. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  34212. $({ target: 'Array', proto: true, forced: !USES_TO_LENGTH }, {
  34213. includes: function includes(el /* , fromIndex = 0 */) {
  34214. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  34215. }
  34216. });
  34217. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  34218. addToUnscopables('includes');
  34219. }, { "../internals/add-to-unscopables": 221, "../internals/array-includes": 224, "../internals/array-method-uses-to-length": 226, "../internals/export": 246 }], 318: [function (require, module, exports) {
  34220. 'use strict';
  34221. var toIndexedObject = require('../internals/to-indexed-object');
  34222. var addToUnscopables = require('../internals/add-to-unscopables');
  34223. var Iterators = require('../internals/iterators');
  34224. var InternalStateModule = require('../internals/internal-state');
  34225. var defineIterator = require('../internals/define-iterator');
  34226. var ARRAY_ITERATOR = 'Array Iterator';
  34227. var setInternalState = InternalStateModule.set;
  34228. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  34229. // `Array.prototype.entries` method
  34230. // https://tc39.github.io/ecma262/#sec-array.prototype.entries
  34231. // `Array.prototype.keys` method
  34232. // https://tc39.github.io/ecma262/#sec-array.prototype.keys
  34233. // `Array.prototype.values` method
  34234. // https://tc39.github.io/ecma262/#sec-array.prototype.values
  34235. // `Array.prototype[@@iterator]` method
  34236. // https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator
  34237. // `CreateArrayIterator` internal method
  34238. // https://tc39.github.io/ecma262/#sec-createarrayiterator
  34239. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  34240. setInternalState(this, {
  34241. type: ARRAY_ITERATOR,
  34242. target: toIndexedObject(iterated), // target
  34243. index: 0, // next index
  34244. kind: kind // kind
  34245. });
  34246. // `%ArrayIteratorPrototype%.next` method
  34247. // https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
  34248. }, function () {
  34249. var state = getInternalState(this);
  34250. var target = state.target;
  34251. var kind = state.kind;
  34252. var index = state.index++;
  34253. if (!target || index >= target.length) {
  34254. state.target = undefined;
  34255. return { value: undefined, done: true };
  34256. }
  34257. if (kind == 'keys') return { value: index, done: false };
  34258. if (kind == 'values') return { value: target[index], done: false };
  34259. return { value: [index, target[index]], done: false };
  34260. }, 'values');
  34261. // argumentsList[@@iterator] is %ArrayProto_values%
  34262. // https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject
  34263. // https://tc39.github.io/ecma262/#sec-createmappedargumentsobject
  34264. Iterators.Arguments = Iterators.Array;
  34265. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  34266. addToUnscopables('keys');
  34267. addToUnscopables('values');
  34268. addToUnscopables('entries');
  34269. }, { "../internals/add-to-unscopables": 221, "../internals/define-iterator": 238, "../internals/internal-state": 259, "../internals/iterators": 268, "../internals/to-indexed-object": 305 }], 319: [function (require, module, exports) {
  34270. var $ = require('../internals/export');
  34271. // `Number.isNaN` method
  34272. // https://tc39.github.io/ecma262/#sec-number.isnan
  34273. $({ target: 'Number', stat: true }, {
  34274. isNaN: function isNaN(number) {
  34275. // eslint-disable-next-line no-self-compare
  34276. return number != number;
  34277. }
  34278. });
  34279. }, { "../internals/export": 246 }], 320: [function (require, module, exports) {
  34280. var $ = require('../internals/export');
  34281. var assign = require('../internals/object-assign');
  34282. // `Object.assign` method
  34283. // https://tc39.github.io/ecma262/#sec-object.assign
  34284. $({ target: 'Object', stat: true, forced: Object.assign !== assign }, {
  34285. assign: assign
  34286. });
  34287. }, { "../internals/export": 246, "../internals/object-assign": 275 }], 321: [function (require, module, exports) {
  34288. var $ = require('../internals/export');
  34289. var toObject = require('../internals/to-object');
  34290. var nativeKeys = require('../internals/object-keys');
  34291. var fails = require('../internals/fails');
  34292. var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
  34293. // `Object.keys` method
  34294. // https://tc39.github.io/ecma262/#sec-object.keys
  34295. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  34296. keys: function keys(it) {
  34297. return nativeKeys(toObject(it));
  34298. }
  34299. });
  34300. }, { "../internals/export": 246, "../internals/fails": 247, "../internals/object-keys": 285, "../internals/to-object": 308 }], 322: [function (require, module, exports) {
  34301. var $ = require('../internals/export');
  34302. var $values = require('../internals/object-to-array').values;
  34303. // `Object.values` method
  34304. // https://tc39.github.io/ecma262/#sec-object.values
  34305. $({ target: 'Object', stat: true }, {
  34306. values: function values(O) {
  34307. return $values(O);
  34308. }
  34309. });
  34310. }, { "../internals/export": 246, "../internals/object-to-array": 288 }], 323: [function (require, module, exports) {
  34311. 'use strict';
  34312. var $ = require('../internals/export');
  34313. var IS_PURE = require('../internals/is-pure');
  34314. var global = require('../internals/global');
  34315. var getBuiltIn = require('../internals/get-built-in');
  34316. var NativePromise = require('../internals/native-promise-constructor');
  34317. var redefine = require('../internals/redefine');
  34318. var redefineAll = require('../internals/redefine-all');
  34319. var setToStringTag = require('../internals/set-to-string-tag');
  34320. var setSpecies = require('../internals/set-species');
  34321. var isObject = require('../internals/is-object');
  34322. var aFunction = require('../internals/a-function');
  34323. var anInstance = require('../internals/an-instance');
  34324. var classof = require('../internals/classof-raw');
  34325. var inspectSource = require('../internals/inspect-source');
  34326. var iterate = require('../internals/iterate');
  34327. var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');
  34328. var speciesConstructor = require('../internals/species-constructor');
  34329. var task = require('../internals/task').set;
  34330. var microtask = require('../internals/microtask');
  34331. var promiseResolve = require('../internals/promise-resolve');
  34332. var hostReportErrors = require('../internals/host-report-errors');
  34333. var newPromiseCapabilityModule = require('../internals/new-promise-capability');
  34334. var perform = require('../internals/perform');
  34335. var InternalStateModule = require('../internals/internal-state');
  34336. var isForced = require('../internals/is-forced');
  34337. var wellKnownSymbol = require('../internals/well-known-symbol');
  34338. var V8_VERSION = require('../internals/engine-v8-version');
  34339. var SPECIES = wellKnownSymbol('species');
  34340. var PROMISE = 'Promise';
  34341. var getInternalState = InternalStateModule.get;
  34342. var setInternalState = InternalStateModule.set;
  34343. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  34344. var PromiseConstructor = NativePromise;
  34345. var TypeError = global.TypeError;
  34346. var document = global.document;
  34347. var process = global.process;
  34348. var $fetch = getBuiltIn('fetch');
  34349. var newPromiseCapability = newPromiseCapabilityModule.f;
  34350. var newGenericPromiseCapability = newPromiseCapability;
  34351. var IS_NODE = classof(process) == 'process';
  34352. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  34353. var UNHANDLED_REJECTION = 'unhandledrejection';
  34354. var REJECTION_HANDLED = 'rejectionhandled';
  34355. var PENDING = 0;
  34356. var FULFILLED = 1;
  34357. var REJECTED = 2;
  34358. var HANDLED = 1;
  34359. var UNHANDLED = 2;
  34360. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  34361. var FORCED = isForced(PROMISE, function () {
  34362. var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
  34363. if (!GLOBAL_CORE_JS_PROMISE) {
  34364. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  34365. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  34366. // We can't detect it synchronously, so just check versions
  34367. if (V8_VERSION === 66) return true;
  34368. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  34369. if (!IS_NODE && typeof PromiseRejectionEvent != 'function') return true;
  34370. }
  34371. // We need Promise#finally in the pure version for preventing prototype pollution
  34372. if (IS_PURE && !PromiseConstructor.prototype['finally']) return true;
  34373. // We can't use @@species feature detection in V8 since it causes
  34374. // deoptimization and performance degradation
  34375. // https://github.com/zloirock/core-js/issues/679
  34376. if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false;
  34377. // Detect correctness of subclassing with @@species support
  34378. var promise = PromiseConstructor.resolve(1);
  34379. var FakePromise = function (exec) {
  34380. exec(function () { /* empty */ }, function () { /* empty */ });
  34381. };
  34382. var constructor = promise.constructor = {};
  34383. constructor[SPECIES] = FakePromise;
  34384. return !(promise.then(function () { /* empty */ }) instanceof FakePromise);
  34385. });
  34386. var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
  34387. PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
  34388. });
  34389. // helpers
  34390. var isThenable = function (it) {
  34391. var then;
  34392. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  34393. };
  34394. var notify = function (promise, state, isReject) {
  34395. if (state.notified) return;
  34396. state.notified = true;
  34397. var chain = state.reactions;
  34398. microtask(function () {
  34399. var value = state.value;
  34400. var ok = state.state == FULFILLED;
  34401. var index = 0;
  34402. // variable length - can't use forEach
  34403. while (chain.length > index) {
  34404. var reaction = chain[index++];
  34405. var handler = ok ? reaction.ok : reaction.fail;
  34406. var resolve = reaction.resolve;
  34407. var reject = reaction.reject;
  34408. var domain = reaction.domain;
  34409. var result, then, exited;
  34410. try {
  34411. if (handler) {
  34412. if (!ok) {
  34413. if (state.rejection === UNHANDLED) onHandleUnhandled(promise, state);
  34414. state.rejection = HANDLED;
  34415. }
  34416. if (handler === true) result = value;
  34417. else {
  34418. if (domain) domain.enter();
  34419. result = handler(value); // can throw
  34420. if (domain) {
  34421. domain.exit();
  34422. exited = true;
  34423. }
  34424. }
  34425. if (result === reaction.promise) {
  34426. reject(TypeError('Promise-chain cycle'));
  34427. } else if (then = isThenable(result)) {
  34428. then.call(result, resolve, reject);
  34429. } else resolve(result);
  34430. } else reject(value);
  34431. } catch (error) {
  34432. if (domain && !exited) domain.exit();
  34433. reject(error);
  34434. }
  34435. }
  34436. state.reactions = [];
  34437. state.notified = false;
  34438. if (isReject && !state.rejection) onUnhandled(promise, state);
  34439. });
  34440. };
  34441. var dispatchEvent = function (name, promise, reason) {
  34442. var event, handler;
  34443. if (DISPATCH_EVENT) {
  34444. event = document.createEvent('Event');
  34445. event.promise = promise;
  34446. event.reason = reason;
  34447. event.initEvent(name, false, true);
  34448. global.dispatchEvent(event);
  34449. } else event = { promise: promise, reason: reason };
  34450. if (handler = global['on' + name]) handler(event);
  34451. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  34452. };
  34453. var onUnhandled = function (promise, state) {
  34454. task.call(global, function () {
  34455. var value = state.value;
  34456. var IS_UNHANDLED = isUnhandled(state);
  34457. var result;
  34458. if (IS_UNHANDLED) {
  34459. result = perform(function () {
  34460. if (IS_NODE) {
  34461. process.emit('unhandledRejection', value, promise);
  34462. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  34463. });
  34464. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  34465. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  34466. if (result.error) throw result.value;
  34467. }
  34468. });
  34469. };
  34470. var isUnhandled = function (state) {
  34471. return state.rejection !== HANDLED && !state.parent;
  34472. };
  34473. var onHandleUnhandled = function (promise, state) {
  34474. task.call(global, function () {
  34475. if (IS_NODE) {
  34476. process.emit('rejectionHandled', promise);
  34477. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  34478. });
  34479. };
  34480. var bind = function (fn, promise, state, unwrap) {
  34481. return function (value) {
  34482. fn(promise, state, value, unwrap);
  34483. };
  34484. };
  34485. var internalReject = function (promise, state, value, unwrap) {
  34486. if (state.done) return;
  34487. state.done = true;
  34488. if (unwrap) state = unwrap;
  34489. state.value = value;
  34490. state.state = REJECTED;
  34491. notify(promise, state, true);
  34492. };
  34493. var internalResolve = function (promise, state, value, unwrap) {
  34494. if (state.done) return;
  34495. state.done = true;
  34496. if (unwrap) state = unwrap;
  34497. try {
  34498. if (promise === value) throw TypeError("Promise can't be resolved itself");
  34499. var then = isThenable(value);
  34500. if (then) {
  34501. microtask(function () {
  34502. var wrapper = { done: false };
  34503. try {
  34504. then.call(value,
  34505. bind(internalResolve, promise, wrapper, state),
  34506. bind(internalReject, promise, wrapper, state)
  34507. );
  34508. } catch (error) {
  34509. internalReject(promise, wrapper, error, state);
  34510. }
  34511. });
  34512. } else {
  34513. state.value = value;
  34514. state.state = FULFILLED;
  34515. notify(promise, state, false);
  34516. }
  34517. } catch (error) {
  34518. internalReject(promise, { done: false }, error, state);
  34519. }
  34520. };
  34521. // constructor polyfill
  34522. if (FORCED) {
  34523. // 25.4.3.1 Promise(executor)
  34524. PromiseConstructor = function Promise(executor) {
  34525. anInstance(this, PromiseConstructor, PROMISE);
  34526. aFunction(executor);
  34527. Internal.call(this);
  34528. var state = getInternalState(this);
  34529. try {
  34530. executor(bind(internalResolve, this, state), bind(internalReject, this, state));
  34531. } catch (error) {
  34532. internalReject(this, state, error);
  34533. }
  34534. };
  34535. // eslint-disable-next-line no-unused-vars
  34536. Internal = function Promise(executor) {
  34537. setInternalState(this, {
  34538. type: PROMISE,
  34539. done: false,
  34540. notified: false,
  34541. parent: false,
  34542. reactions: [],
  34543. rejection: false,
  34544. state: PENDING,
  34545. value: undefined
  34546. });
  34547. };
  34548. Internal.prototype = redefineAll(PromiseConstructor.prototype, {
  34549. // `Promise.prototype.then` method
  34550. // https://tc39.github.io/ecma262/#sec-promise.prototype.then
  34551. then: function then(onFulfilled, onRejected) {
  34552. var state = getInternalPromiseState(this);
  34553. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  34554. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  34555. reaction.fail = typeof onRejected == 'function' && onRejected;
  34556. reaction.domain = IS_NODE ? process.domain : undefined;
  34557. state.parent = true;
  34558. state.reactions.push(reaction);
  34559. if (state.state != PENDING) notify(this, state, false);
  34560. return reaction.promise;
  34561. },
  34562. // `Promise.prototype.catch` method
  34563. // https://tc39.github.io/ecma262/#sec-promise.prototype.catch
  34564. 'catch': function (onRejected) {
  34565. return this.then(undefined, onRejected);
  34566. }
  34567. });
  34568. OwnPromiseCapability = function () {
  34569. var promise = new Internal();
  34570. var state = getInternalState(promise);
  34571. this.promise = promise;
  34572. this.resolve = bind(internalResolve, promise, state);
  34573. this.reject = bind(internalReject, promise, state);
  34574. };
  34575. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  34576. return C === PromiseConstructor || C === PromiseWrapper
  34577. ? new OwnPromiseCapability(C)
  34578. : newGenericPromiseCapability(C);
  34579. };
  34580. if (!IS_PURE && typeof NativePromise == 'function') {
  34581. nativeThen = NativePromise.prototype.then;
  34582. // wrap native Promise#then for native async functions
  34583. redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {
  34584. var that = this;
  34585. return new PromiseConstructor(function (resolve, reject) {
  34586. nativeThen.call(that, resolve, reject);
  34587. }).then(onFulfilled, onRejected);
  34588. // https://github.com/zloirock/core-js/issues/640
  34589. }, { unsafe: true });
  34590. // wrap fetch result
  34591. if (typeof $fetch == 'function') $({ global: true, enumerable: true, forced: true }, {
  34592. // eslint-disable-next-line no-unused-vars
  34593. fetch: function fetch(input /* , init */) {
  34594. return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
  34595. }
  34596. });
  34597. }
  34598. }
  34599. $({ global: true, wrap: true, forced: FORCED }, {
  34600. Promise: PromiseConstructor
  34601. });
  34602. setToStringTag(PromiseConstructor, PROMISE, false, true);
  34603. setSpecies(PROMISE);
  34604. PromiseWrapper = getBuiltIn(PROMISE);
  34605. // statics
  34606. $({ target: PROMISE, stat: true, forced: FORCED }, {
  34607. // `Promise.reject` method
  34608. // https://tc39.github.io/ecma262/#sec-promise.reject
  34609. reject: function reject(r) {
  34610. var capability = newPromiseCapability(this);
  34611. capability.reject.call(undefined, r);
  34612. return capability.promise;
  34613. }
  34614. });
  34615. $({ target: PROMISE, stat: true, forced: IS_PURE || FORCED }, {
  34616. // `Promise.resolve` method
  34617. // https://tc39.github.io/ecma262/#sec-promise.resolve
  34618. resolve: function resolve(x) {
  34619. return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
  34620. }
  34621. });
  34622. $({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
  34623. // `Promise.all` method
  34624. // https://tc39.github.io/ecma262/#sec-promise.all
  34625. all: function all(iterable) {
  34626. var C = this;
  34627. var capability = newPromiseCapability(C);
  34628. var resolve = capability.resolve;
  34629. var reject = capability.reject;
  34630. var result = perform(function () {
  34631. var $promiseResolve = aFunction(C.resolve);
  34632. var values = [];
  34633. var counter = 0;
  34634. var remaining = 1;
  34635. iterate(iterable, function (promise) {
  34636. var index = counter++;
  34637. var alreadyCalled = false;
  34638. values.push(undefined);
  34639. remaining++;
  34640. $promiseResolve.call(C, promise).then(function (value) {
  34641. if (alreadyCalled) return;
  34642. alreadyCalled = true;
  34643. values[index] = value;
  34644. --remaining || resolve(values);
  34645. }, reject);
  34646. });
  34647. --remaining || resolve(values);
  34648. });
  34649. if (result.error) reject(result.value);
  34650. return capability.promise;
  34651. },
  34652. // `Promise.race` method
  34653. // https://tc39.github.io/ecma262/#sec-promise.race
  34654. race: function race(iterable) {
  34655. var C = this;
  34656. var capability = newPromiseCapability(C);
  34657. var reject = capability.reject;
  34658. var result = perform(function () {
  34659. var $promiseResolve = aFunction(C.resolve);
  34660. iterate(iterable, function (promise) {
  34661. $promiseResolve.call(C, promise).then(capability.resolve, reject);
  34662. });
  34663. });
  34664. if (result.error) reject(result.value);
  34665. return capability.promise;
  34666. }
  34667. });
  34668. }, { "../internals/a-function": 219, "../internals/an-instance": 222, "../internals/check-correctness-of-iteration": 229, "../internals/classof-raw": 230, "../internals/engine-v8-version": 244, "../internals/export": 246, "../internals/get-built-in": 249, "../internals/global": 251, "../internals/host-report-errors": 254, "../internals/inspect-source": 258, "../internals/internal-state": 259, "../internals/is-forced": 262, "../internals/is-object": 263, "../internals/is-pure": 264, "../internals/iterate": 266, "../internals/microtask": 269, "../internals/native-promise-constructor": 270, "../internals/new-promise-capability": 273, "../internals/perform": 291, "../internals/promise-resolve": 292, "../internals/redefine": 294, "../internals/redefine-all": 293, "../internals/set-species": 297, "../internals/set-to-string-tag": 298, "../internals/species-constructor": 302, "../internals/task": 303, "../internals/well-known-symbol": 314 }], 324: [function (require, module, exports) {
  34669. var $ = require('../internals/export');
  34670. var toAbsoluteIndex = require('../internals/to-absolute-index');
  34671. var fromCharCode = String.fromCharCode;
  34672. var nativeFromCodePoint = String.fromCodePoint;
  34673. // length should be 1, old FF problem
  34674. var INCORRECT_LENGTH = !!nativeFromCodePoint && nativeFromCodePoint.length != 1;
  34675. // `String.fromCodePoint` method
  34676. // https://tc39.github.io/ecma262/#sec-string.fromcodepoint
  34677. $({ target: 'String', stat: true, forced: INCORRECT_LENGTH }, {
  34678. fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
  34679. var elements = [];
  34680. var length = arguments.length;
  34681. var i = 0;
  34682. var code;
  34683. while (length > i) {
  34684. code = +arguments[i++];
  34685. if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point');
  34686. elements.push(code < 0x10000
  34687. ? fromCharCode(code)
  34688. : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00)
  34689. );
  34690. } return elements.join('');
  34691. }
  34692. });
  34693. }, { "../internals/export": 246, "../internals/to-absolute-index": 304 }], 325: [function (require, module, exports) {
  34694. 'use strict';
  34695. var $ = require('../internals/export');
  34696. var notARegExp = require('../internals/not-a-regexp');
  34697. var requireObjectCoercible = require('../internals/require-object-coercible');
  34698. var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');
  34699. // `String.prototype.includes` method
  34700. // https://tc39.github.io/ecma262/#sec-string.prototype.includes
  34701. $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
  34702. includes: function includes(searchString /* , position = 0 */) {
  34703. return !!~String(requireObjectCoercible(this))
  34704. .indexOf(notARegExp(searchString), arguments.length > 1 ? arguments[1] : undefined);
  34705. }
  34706. });
  34707. }, { "../internals/correct-is-regexp-logic": 233, "../internals/export": 246, "../internals/not-a-regexp": 274, "../internals/require-object-coercible": 295 }], 326: [function (require, module, exports) {
  34708. var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
  34709. // `Symbol.asyncIterator` well-known symbol
  34710. // https://tc39.github.io/ecma262/#sec-symbol.asynciterator
  34711. defineWellKnownSymbol('asyncIterator');
  34712. }, { "../internals/define-well-known-symbol": 239 }], 327: [function (require, module, exports) {
  34713. 'use strict';
  34714. var $ = require('../internals/export');
  34715. var global = require('../internals/global');
  34716. var getBuiltIn = require('../internals/get-built-in');
  34717. var IS_PURE = require('../internals/is-pure');
  34718. var DESCRIPTORS = require('../internals/descriptors');
  34719. var NATIVE_SYMBOL = require('../internals/native-symbol');
  34720. var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');
  34721. var fails = require('../internals/fails');
  34722. var has = require('../internals/has');
  34723. var isArray = require('../internals/is-array');
  34724. var isObject = require('../internals/is-object');
  34725. var anObject = require('../internals/an-object');
  34726. var toObject = require('../internals/to-object');
  34727. var toIndexedObject = require('../internals/to-indexed-object');
  34728. var toPrimitive = require('../internals/to-primitive');
  34729. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  34730. var nativeObjectCreate = require('../internals/object-create');
  34731. var objectKeys = require('../internals/object-keys');
  34732. var getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');
  34733. var getOwnPropertyNamesExternal = require('../internals/object-get-own-property-names-external');
  34734. var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
  34735. var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
  34736. var definePropertyModule = require('../internals/object-define-property');
  34737. var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
  34738. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  34739. var redefine = require('../internals/redefine');
  34740. var shared = require('../internals/shared');
  34741. var sharedKey = require('../internals/shared-key');
  34742. var hiddenKeys = require('../internals/hidden-keys');
  34743. var uid = require('../internals/uid');
  34744. var wellKnownSymbol = require('../internals/well-known-symbol');
  34745. var wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');
  34746. var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
  34747. var setToStringTag = require('../internals/set-to-string-tag');
  34748. var InternalStateModule = require('../internals/internal-state');
  34749. var $forEach = require('../internals/array-iteration').forEach;
  34750. var HIDDEN = sharedKey('hidden');
  34751. var SYMBOL = 'Symbol';
  34752. var PROTOTYPE = 'prototype';
  34753. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  34754. var setInternalState = InternalStateModule.set;
  34755. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  34756. var ObjectPrototype = Object[PROTOTYPE];
  34757. var $Symbol = global.Symbol;
  34758. var $stringify = getBuiltIn('JSON', 'stringify');
  34759. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  34760. var nativeDefineProperty = definePropertyModule.f;
  34761. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  34762. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  34763. var AllSymbols = shared('symbols');
  34764. var ObjectPrototypeSymbols = shared('op-symbols');
  34765. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  34766. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  34767. var WellKnownSymbolsStore = shared('wks');
  34768. var QObject = global.QObject;
  34769. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  34770. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  34771. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  34772. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  34773. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  34774. get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
  34775. })).a != 7;
  34776. }) ? function (O, P, Attributes) {
  34777. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  34778. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  34779. nativeDefineProperty(O, P, Attributes);
  34780. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  34781. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  34782. }
  34783. } : nativeDefineProperty;
  34784. var wrap = function (tag, description) {
  34785. var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);
  34786. setInternalState(symbol, {
  34787. type: SYMBOL,
  34788. tag: tag,
  34789. description: description
  34790. });
  34791. if (!DESCRIPTORS) symbol.description = description;
  34792. return symbol;
  34793. };
  34794. var isSymbol = USE_SYMBOL_AS_UID ? function (it) {
  34795. return typeof it == 'symbol';
  34796. } : function (it) {
  34797. return Object(it) instanceof $Symbol;
  34798. };
  34799. var $defineProperty = function defineProperty(O, P, Attributes) {
  34800. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  34801. anObject(O);
  34802. var key = toPrimitive(P, true);
  34803. anObject(Attributes);
  34804. if (has(AllSymbols, key)) {
  34805. if (!Attributes.enumerable) {
  34806. if (!has(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  34807. O[HIDDEN][key] = true;
  34808. } else {
  34809. if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  34810. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  34811. } return setSymbolDescriptor(O, key, Attributes);
  34812. } return nativeDefineProperty(O, key, Attributes);
  34813. };
  34814. var $defineProperties = function defineProperties(O, Properties) {
  34815. anObject(O);
  34816. var properties = toIndexedObject(Properties);
  34817. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  34818. $forEach(keys, function (key) {
  34819. if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);
  34820. });
  34821. return O;
  34822. };
  34823. var $create = function create(O, Properties) {
  34824. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  34825. };
  34826. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  34827. var P = toPrimitive(V, true);
  34828. var enumerable = nativePropertyIsEnumerable.call(this, P);
  34829. if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false;
  34830. return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
  34831. };
  34832. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  34833. var it = toIndexedObject(O);
  34834. var key = toPrimitive(P, true);
  34835. if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;
  34836. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  34837. if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {
  34838. descriptor.enumerable = true;
  34839. }
  34840. return descriptor;
  34841. };
  34842. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  34843. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  34844. var result = [];
  34845. $forEach(names, function (key) {
  34846. if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key);
  34847. });
  34848. return result;
  34849. };
  34850. var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
  34851. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  34852. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  34853. var result = [];
  34854. $forEach(names, function (key) {
  34855. if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {
  34856. result.push(AllSymbols[key]);
  34857. }
  34858. });
  34859. return result;
  34860. };
  34861. // `Symbol` constructor
  34862. // https://tc39.github.io/ecma262/#sec-symbol-constructor
  34863. if (!NATIVE_SYMBOL) {
  34864. $Symbol = function Symbol() {
  34865. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');
  34866. var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);
  34867. var tag = uid(description);
  34868. var setter = function (value) {
  34869. if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);
  34870. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  34871. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  34872. };
  34873. if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  34874. return wrap(tag, description);
  34875. };
  34876. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  34877. return getInternalState(this).tag;
  34878. });
  34879. redefine($Symbol, 'withoutSetter', function (description) {
  34880. return wrap(uid(description), description);
  34881. });
  34882. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  34883. definePropertyModule.f = $defineProperty;
  34884. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  34885. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  34886. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  34887. wrappedWellKnownSymbolModule.f = function (name) {
  34888. return wrap(wellKnownSymbol(name), name);
  34889. };
  34890. if (DESCRIPTORS) {
  34891. // https://github.com/tc39/proposal-Symbol-description
  34892. nativeDefineProperty($Symbol[PROTOTYPE], 'description', {
  34893. configurable: true,
  34894. get: function description() {
  34895. return getInternalState(this).description;
  34896. }
  34897. });
  34898. if (!IS_PURE) {
  34899. redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  34900. }
  34901. }
  34902. }
  34903. $({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
  34904. Symbol: $Symbol
  34905. });
  34906. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  34907. defineWellKnownSymbol(name);
  34908. });
  34909. $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
  34910. // `Symbol.for` method
  34911. // https://tc39.github.io/ecma262/#sec-symbol.for
  34912. 'for': function (key) {
  34913. var string = String(key);
  34914. if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  34915. var symbol = $Symbol(string);
  34916. StringToSymbolRegistry[string] = symbol;
  34917. SymbolToStringRegistry[symbol] = string;
  34918. return symbol;
  34919. },
  34920. // `Symbol.keyFor` method
  34921. // https://tc39.github.io/ecma262/#sec-symbol.keyfor
  34922. keyFor: function keyFor(sym) {
  34923. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
  34924. if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  34925. },
  34926. useSetter: function () { USE_SETTER = true; },
  34927. useSimple: function () { USE_SETTER = false; }
  34928. });
  34929. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
  34930. // `Object.create` method
  34931. // https://tc39.github.io/ecma262/#sec-object.create
  34932. create: $create,
  34933. // `Object.defineProperty` method
  34934. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  34935. defineProperty: $defineProperty,
  34936. // `Object.defineProperties` method
  34937. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  34938. defineProperties: $defineProperties,
  34939. // `Object.getOwnPropertyDescriptor` method
  34940. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
  34941. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  34942. });
  34943. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
  34944. // `Object.getOwnPropertyNames` method
  34945. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  34946. getOwnPropertyNames: $getOwnPropertyNames,
  34947. // `Object.getOwnPropertySymbols` method
  34948. // https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols
  34949. getOwnPropertySymbols: $getOwnPropertySymbols
  34950. });
  34951. // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  34952. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  34953. $({ target: 'Object', stat: true, forced: fails(function () { getOwnPropertySymbolsModule.f(1); }) }, {
  34954. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  34955. return getOwnPropertySymbolsModule.f(toObject(it));
  34956. }
  34957. });
  34958. // `JSON.stringify` method behavior with symbols
  34959. // https://tc39.github.io/ecma262/#sec-json.stringify
  34960. if ($stringify) {
  34961. var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {
  34962. var symbol = $Symbol();
  34963. // MS Edge converts symbol values to JSON as {}
  34964. return $stringify([symbol]) != '[null]'
  34965. // WebKit converts symbol values to JSON as null
  34966. || $stringify({ a: symbol }) != '{}'
  34967. // V8 throws on boxed symbols
  34968. || $stringify(Object(symbol)) != '{}';
  34969. });
  34970. $({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {
  34971. // eslint-disable-next-line no-unused-vars
  34972. stringify: function stringify(it, replacer, space) {
  34973. var args = [it];
  34974. var index = 1;
  34975. var $replacer;
  34976. while (arguments.length > index) args.push(arguments[index++]);
  34977. $replacer = replacer;
  34978. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  34979. if (!isArray(replacer)) replacer = function (key, value) {
  34980. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  34981. if (!isSymbol(value)) return value;
  34982. };
  34983. args[1] = replacer;
  34984. return $stringify.apply(null, args);
  34985. }
  34986. });
  34987. }
  34988. // `Symbol.prototype[@@toPrimitive]` method
  34989. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive
  34990. if (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) {
  34991. createNonEnumerableProperty($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  34992. }
  34993. // `Symbol.prototype[@@toStringTag]` property
  34994. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@tostringtag
  34995. setToStringTag($Symbol, SYMBOL);
  34996. hiddenKeys[HIDDEN] = true;
  34997. }, { "../internals/an-object": 223, "../internals/array-iteration": 225, "../internals/create-non-enumerable-property": 236, "../internals/create-property-descriptor": 237, "../internals/define-well-known-symbol": 239, "../internals/descriptors": 240, "../internals/export": 246, "../internals/fails": 247, "../internals/get-built-in": 249, "../internals/global": 251, "../internals/has": 252, "../internals/hidden-keys": 253, "../internals/internal-state": 259, "../internals/is-array": 261, "../internals/is-object": 263, "../internals/is-pure": 264, "../internals/native-symbol": 271, "../internals/object-create": 276, "../internals/object-define-property": 278, "../internals/object-get-own-property-descriptor": 279, "../internals/object-get-own-property-names": 281, "../internals/object-get-own-property-names-external": 280, "../internals/object-get-own-property-symbols": 282, "../internals/object-keys": 285, "../internals/object-property-is-enumerable": 286, "../internals/redefine": 294, "../internals/set-to-string-tag": 298, "../internals/shared": 301, "../internals/shared-key": 299, "../internals/to-indexed-object": 305, "../internals/to-object": 308, "../internals/to-primitive": 309, "../internals/uid": 311, "../internals/use-symbol-as-uid": 312, "../internals/well-known-symbol": 314, "../internals/well-known-symbol-wrapped": 313 }], 328: [function (require, module, exports) {
  34998. (function (Buffer) {
  34999. "use strict";
  35000. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  35001. // Copyright Joyent, Inc. and other Node contributors.
  35002. //
  35003. // Permission is hereby granted, free of charge, to any person obtaining a
  35004. // copy of this software and associated documentation files (the
  35005. // "Software"), to deal in the Software without restriction, including
  35006. // without limitation the rights to use, copy, modify, merge, publish,
  35007. // distribute, sublicense, and/or sell copies of the Software, and to permit
  35008. // persons to whom the Software is furnished to do so, subject to the
  35009. // following conditions:
  35010. //
  35011. // The above copyright notice and this permission notice shall be included
  35012. // in all copies or substantial portions of the Software.
  35013. //
  35014. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  35015. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  35016. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  35017. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  35018. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  35019. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  35020. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  35021. // NOTE: These type checking functions intentionally don't use `instanceof`
  35022. // because it is fragile and can be easily faked with `Object.create()`.
  35023. function isArray(arg) {
  35024. if (Array.isArray) {
  35025. return Array.isArray(arg);
  35026. }
  35027. return objectToString(arg) === '[object Array]';
  35028. }
  35029. exports.isArray = isArray;
  35030. function isBoolean(arg) {
  35031. return typeof arg === 'boolean';
  35032. }
  35033. exports.isBoolean = isBoolean;
  35034. function isNull(arg) {
  35035. return arg === null;
  35036. }
  35037. exports.isNull = isNull;
  35038. function isNullOrUndefined(arg) {
  35039. return arg == null;
  35040. }
  35041. exports.isNullOrUndefined = isNullOrUndefined;
  35042. function isNumber(arg) {
  35043. return typeof arg === 'number';
  35044. }
  35045. exports.isNumber = isNumber;
  35046. function isString(arg) {
  35047. return typeof arg === 'string';
  35048. }
  35049. exports.isString = isString;
  35050. function isSymbol(arg) {
  35051. return _typeof(arg) === 'symbol';
  35052. }
  35053. exports.isSymbol = isSymbol;
  35054. function isUndefined(arg) {
  35055. return arg === void 0;
  35056. }
  35057. exports.isUndefined = isUndefined;
  35058. function isRegExp(re) {
  35059. return objectToString(re) === '[object RegExp]';
  35060. }
  35061. exports.isRegExp = isRegExp;
  35062. function isObject(arg) {
  35063. return _typeof(arg) === 'object' && arg !== null;
  35064. }
  35065. exports.isObject = isObject;
  35066. function isDate(d) {
  35067. return objectToString(d) === '[object Date]';
  35068. }
  35069. exports.isDate = isDate;
  35070. function isError(e) {
  35071. return objectToString(e) === '[object Error]' || e instanceof Error;
  35072. }
  35073. exports.isError = isError;
  35074. function isFunction(arg) {
  35075. return typeof arg === 'function';
  35076. }
  35077. exports.isFunction = isFunction;
  35078. function isPrimitive(arg) {
  35079. return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || _typeof(arg) === 'symbol' || // ES6 symbol
  35080. typeof arg === 'undefined';
  35081. }
  35082. exports.isPrimitive = isPrimitive;
  35083. exports.isBuffer = Buffer.isBuffer;
  35084. function objectToString(o) {
  35085. return Object.prototype.toString.call(o);
  35086. }
  35087. }).call(this, { "isBuffer": require("../../is-buffer/index.js") })
  35088. }, { "../../is-buffer/index.js": 388 }], 329: [function (require, module, exports) {
  35089. (function (Buffer) {
  35090. "use strict";
  35091. var elliptic = require('elliptic');
  35092. var BN = require('bn.js');
  35093. module.exports = function createECDH(curve) {
  35094. return new ECDH(curve);
  35095. };
  35096. var aliases = {
  35097. secp256k1: {
  35098. name: 'secp256k1',
  35099. byteLength: 32
  35100. },
  35101. secp224r1: {
  35102. name: 'p224',
  35103. byteLength: 28
  35104. },
  35105. prime256v1: {
  35106. name: 'p256',
  35107. byteLength: 32
  35108. },
  35109. prime192v1: {
  35110. name: 'p192',
  35111. byteLength: 24
  35112. },
  35113. ed25519: {
  35114. name: 'ed25519',
  35115. byteLength: 32
  35116. },
  35117. secp384r1: {
  35118. name: 'p384',
  35119. byteLength: 48
  35120. },
  35121. secp521r1: {
  35122. name: 'p521',
  35123. byteLength: 66
  35124. }
  35125. };
  35126. aliases.p224 = aliases.secp224r1;
  35127. aliases.p256 = aliases.secp256r1 = aliases.prime256v1;
  35128. aliases.p192 = aliases.secp192r1 = aliases.prime192v1;
  35129. aliases.p384 = aliases.secp384r1;
  35130. aliases.p521 = aliases.secp521r1;
  35131. function ECDH(curve) {
  35132. this.curveType = aliases[curve];
  35133. if (!this.curveType) {
  35134. this.curveType = {
  35135. name: curve
  35136. };
  35137. }
  35138. this.curve = new elliptic.ec(this.curveType.name); // eslint-disable-line new-cap
  35139. this.keys = void 0;
  35140. }
  35141. ECDH.prototype.generateKeys = function (enc, format) {
  35142. this.keys = this.curve.genKeyPair();
  35143. return this.getPublicKey(enc, format);
  35144. };
  35145. ECDH.prototype.computeSecret = function (other, inenc, enc) {
  35146. inenc = inenc || 'utf8';
  35147. if (!Buffer.isBuffer(other)) {
  35148. other = new Buffer(other, inenc);
  35149. }
  35150. var otherPub = this.curve.keyFromPublic(other).getPublic();
  35151. var out = otherPub.mul(this.keys.getPrivate()).getX();
  35152. return formatReturnValue(out, enc, this.curveType.byteLength);
  35153. };
  35154. ECDH.prototype.getPublicKey = function (enc, format) {
  35155. var key = this.keys.getPublic(format === 'compressed', true);
  35156. if (format === 'hybrid') {
  35157. if (key[key.length - 1] % 2) {
  35158. key[0] = 7;
  35159. } else {
  35160. key[0] = 6;
  35161. }
  35162. }
  35163. return formatReturnValue(key, enc);
  35164. };
  35165. ECDH.prototype.getPrivateKey = function (enc) {
  35166. return formatReturnValue(this.keys.getPrivate(), enc);
  35167. };
  35168. ECDH.prototype.setPublicKey = function (pub, enc) {
  35169. enc = enc || 'utf8';
  35170. if (!Buffer.isBuffer(pub)) {
  35171. pub = new Buffer(pub, enc);
  35172. }
  35173. this.keys._importPublic(pub);
  35174. return this;
  35175. };
  35176. ECDH.prototype.setPrivateKey = function (priv, enc) {
  35177. enc = enc || 'utf8';
  35178. if (!Buffer.isBuffer(priv)) {
  35179. priv = new Buffer(priv, enc);
  35180. }
  35181. var _priv = new BN(priv);
  35182. _priv = _priv.toString(16);
  35183. this.keys = this.curve.genKeyPair();
  35184. this.keys._importPrivate(_priv);
  35185. return this;
  35186. };
  35187. function formatReturnValue(bn, enc, len) {
  35188. if (!Array.isArray(bn)) {
  35189. bn = bn.toArray();
  35190. }
  35191. var buf = new Buffer(bn);
  35192. if (len && buf.length < len) {
  35193. var zeros = new Buffer(len - buf.length);
  35194. zeros.fill(0);
  35195. buf = Buffer.concat([zeros, buf]);
  35196. }
  35197. if (!enc) {
  35198. return buf;
  35199. } else {
  35200. return buf.toString(enc);
  35201. }
  35202. }
  35203. }).call(this, require("buffer").Buffer)
  35204. }, { "bn.js": 330, "buffer": 216, "elliptic": 350 }], 330: [function (require, module, exports) {
  35205. arguments[4][181][0].apply(exports, arguments)
  35206. }, { "buffer": 185, "dup": 181 }], 331: [function (require, module, exports) {
  35207. 'use strict';
  35208. var inherits = require('inherits');
  35209. var MD5 = require('md5.js');
  35210. var RIPEMD160 = require('ripemd160');
  35211. var sha = require('sha.js');
  35212. var Base = require('cipher-base');
  35213. function Hash(hash) {
  35214. Base.call(this, 'digest');
  35215. this._hash = hash;
  35216. }
  35217. inherits(Hash, Base);
  35218. Hash.prototype._update = function (data) {
  35219. this._hash.update(data);
  35220. };
  35221. Hash.prototype._final = function () {
  35222. return this._hash.digest();
  35223. };
  35224. module.exports = function createHash(alg) {
  35225. alg = alg.toLowerCase();
  35226. if (alg === 'md5') return new MD5();
  35227. if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160();
  35228. return new Hash(sha(alg));
  35229. };
  35230. }, { "cipher-base": 218, "inherits": 387, "md5.js": 434, "ripemd160": 493, "sha.js": 499 }], 332: [function (require, module, exports) {
  35231. "use strict";
  35232. var MD5 = require('md5.js');
  35233. module.exports = function (buffer) {
  35234. return new MD5().update(buffer).digest();
  35235. };
  35236. }, { "md5.js": 434 }], 333: [function (require, module, exports) {
  35237. 'use strict';
  35238. var inherits = require('inherits');
  35239. var Legacy = require('./legacy');
  35240. var Base = require('cipher-base');
  35241. var Buffer = require('safe-buffer').Buffer;
  35242. var md5 = require('create-hash/md5');
  35243. var RIPEMD160 = require('ripemd160');
  35244. var sha = require('sha.js');
  35245. var ZEROS = Buffer.alloc(128);
  35246. function Hmac(alg, key) {
  35247. Base.call(this, 'digest');
  35248. if (typeof key === 'string') {
  35249. key = Buffer.from(key);
  35250. }
  35251. var blocksize = alg === 'sha512' || alg === 'sha384' ? 128 : 64;
  35252. this._alg = alg;
  35253. this._key = key;
  35254. if (key.length > blocksize) {
  35255. var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg);
  35256. key = hash.update(key).digest();
  35257. } else if (key.length < blocksize) {
  35258. key = Buffer.concat([key, ZEROS], blocksize);
  35259. }
  35260. var ipad = this._ipad = Buffer.allocUnsafe(blocksize);
  35261. var opad = this._opad = Buffer.allocUnsafe(blocksize);
  35262. for (var i = 0; i < blocksize; i++) {
  35263. ipad[i] = key[i] ^ 0x36;
  35264. opad[i] = key[i] ^ 0x5C;
  35265. }
  35266. this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg);
  35267. this._hash.update(ipad);
  35268. }
  35269. inherits(Hmac, Base);
  35270. Hmac.prototype._update = function (data) {
  35271. this._hash.update(data);
  35272. };
  35273. Hmac.prototype._final = function () {
  35274. var h = this._hash.digest();
  35275. var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg);
  35276. return hash.update(this._opad).update(h).digest();
  35277. };
  35278. module.exports = function createHmac(alg, key) {
  35279. alg = alg.toLowerCase();
  35280. if (alg === 'rmd160' || alg === 'ripemd160') {
  35281. return new Hmac('rmd160', key);
  35282. }
  35283. if (alg === 'md5') {
  35284. return new Legacy(md5, key);
  35285. }
  35286. return new Hmac(alg, key);
  35287. };
  35288. }, { "./legacy": 334, "cipher-base": 218, "create-hash/md5": 332, "inherits": 387, "ripemd160": 493, "safe-buffer": 494, "sha.js": 499 }], 334: [function (require, module, exports) {
  35289. 'use strict';
  35290. var inherits = require('inherits');
  35291. var Buffer = require('safe-buffer').Buffer;
  35292. var Base = require('cipher-base');
  35293. var ZEROS = Buffer.alloc(128);
  35294. var blocksize = 64;
  35295. function Hmac(alg, key) {
  35296. Base.call(this, 'digest');
  35297. if (typeof key === 'string') {
  35298. key = Buffer.from(key);
  35299. }
  35300. this._alg = alg;
  35301. this._key = key;
  35302. if (key.length > blocksize) {
  35303. key = alg(key);
  35304. } else if (key.length < blocksize) {
  35305. key = Buffer.concat([key, ZEROS], blocksize);
  35306. }
  35307. var ipad = this._ipad = Buffer.allocUnsafe(blocksize);
  35308. var opad = this._opad = Buffer.allocUnsafe(blocksize);
  35309. for (var i = 0; i < blocksize; i++) {
  35310. ipad[i] = key[i] ^ 0x36;
  35311. opad[i] = key[i] ^ 0x5C;
  35312. }
  35313. this._hash = [ipad];
  35314. }
  35315. inherits(Hmac, Base);
  35316. Hmac.prototype._update = function (data) {
  35317. this._hash.push(data);
  35318. };
  35319. Hmac.prototype._final = function () {
  35320. var h = this._alg(Buffer.concat(this._hash));
  35321. return this._alg(Buffer.concat([this._opad, h]));
  35322. };
  35323. module.exports = Hmac;
  35324. }, { "cipher-base": 218, "inherits": 387, "safe-buffer": 494 }], 335: [function (require, module, exports) {
  35325. 'use strict';
  35326. exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes');
  35327. exports.createHash = exports.Hash = require('create-hash');
  35328. exports.createHmac = exports.Hmac = require('create-hmac');
  35329. var algos = require('browserify-sign/algos');
  35330. var algoKeys = Object.keys(algos);
  35331. var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys);
  35332. exports.getHashes = function () {
  35333. return hashes;
  35334. };
  35335. var p = require('pbkdf2');
  35336. exports.pbkdf2 = p.pbkdf2;
  35337. exports.pbkdf2Sync = p.pbkdf2Sync;
  35338. var aes = require('browserify-cipher');
  35339. exports.Cipher = aes.Cipher;
  35340. exports.createCipher = aes.createCipher;
  35341. exports.Cipheriv = aes.Cipheriv;
  35342. exports.createCipheriv = aes.createCipheriv;
  35343. exports.Decipher = aes.Decipher;
  35344. exports.createDecipher = aes.createDecipher;
  35345. exports.Decipheriv = aes.Decipheriv;
  35346. exports.createDecipheriv = aes.createDecipheriv;
  35347. exports.getCiphers = aes.getCiphers;
  35348. exports.listCiphers = aes.listCiphers;
  35349. var dh = require('diffie-hellman');
  35350. exports.DiffieHellmanGroup = dh.DiffieHellmanGroup;
  35351. exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup;
  35352. exports.getDiffieHellman = dh.getDiffieHellman;
  35353. exports.createDiffieHellman = dh.createDiffieHellman;
  35354. exports.DiffieHellman = dh.DiffieHellman;
  35355. var sign = require('browserify-sign');
  35356. exports.createSign = sign.createSign;
  35357. exports.Sign = sign.Sign;
  35358. exports.createVerify = sign.createVerify;
  35359. exports.Verify = sign.Verify;
  35360. exports.createECDH = require('create-ecdh');
  35361. var publicEncrypt = require('public-encrypt');
  35362. exports.publicEncrypt = publicEncrypt.publicEncrypt;
  35363. exports.privateEncrypt = publicEncrypt.privateEncrypt;
  35364. exports.publicDecrypt = publicEncrypt.publicDecrypt;
  35365. exports.privateDecrypt = publicEncrypt.privateDecrypt; // the least I can do is make error messages for the rest of the node.js/crypto api.
  35366. // ;[
  35367. // 'createCredentials'
  35368. // ].forEach(function (name) {
  35369. // exports[name] = function () {
  35370. // throw new Error([
  35371. // 'sorry, ' + name + ' is not implemented yet',
  35372. // 'we accept pull requests',
  35373. // 'https://github.com/crypto-browserify/crypto-browserify'
  35374. // ].join('\n'))
  35375. // }
  35376. // })
  35377. var rf = require('randomfill');
  35378. exports.randomFill = rf.randomFill;
  35379. exports.randomFillSync = rf.randomFillSync;
  35380. exports.createCredentials = function () {
  35381. throw new Error(['sorry, createCredentials is not implemented yet', 'we accept pull requests', 'https://github.com/crypto-browserify/crypto-browserify'].join('\n'));
  35382. };
  35383. exports.constants = {
  35384. 'DH_CHECK_P_NOT_SAFE_PRIME': 2,
  35385. 'DH_CHECK_P_NOT_PRIME': 1,
  35386. 'DH_UNABLE_TO_CHECK_GENERATOR': 4,
  35387. 'DH_NOT_SUITABLE_GENERATOR': 8,
  35388. 'NPN_ENABLED': 1,
  35389. 'ALPN_ENABLED': 1,
  35390. 'RSA_PKCS1_PADDING': 1,
  35391. 'RSA_SSLV23_PADDING': 2,
  35392. 'RSA_NO_PADDING': 3,
  35393. 'RSA_PKCS1_OAEP_PADDING': 4,
  35394. 'RSA_X931_PADDING': 5,
  35395. 'RSA_PKCS1_PSS_PADDING': 6,
  35396. 'POINT_CONVERSION_COMPRESSED': 2,
  35397. 'POINT_CONVERSION_UNCOMPRESSED': 4,
  35398. 'POINT_CONVERSION_HYBRID': 6
  35399. };
  35400. }, { "browserify-cipher": 203, "browserify-sign": 211, "browserify-sign/algos": 208, "create-ecdh": 329, "create-hash": 331, "create-hmac": 333, "diffie-hellman": 345, "pbkdf2": 460, "public-encrypt": 468, "randombytes": 475, "randomfill": 476 }], 336: [function (require, module, exports) {
  35401. "use strict";
  35402. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  35403. !function (t, e) {
  35404. "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : t.dayjs = e();
  35405. }(void 0, function () {
  35406. "use strict";
  35407. var t = "millisecond",
  35408. e = "second",
  35409. n = "minute",
  35410. r = "hour",
  35411. i = "day",
  35412. s = "week",
  35413. u = "month",
  35414. a = "quarter",
  35415. o = "year",
  35416. f = "date",
  35417. h = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d+)?$/,
  35418. c = /\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,
  35419. d = function d(t, e, n) {
  35420. var r = String(t);
  35421. return !r || r.length >= e ? t : "" + Array(e + 1 - r.length).join(n) + t;
  35422. },
  35423. $ = {
  35424. s: d,
  35425. z: function z(t) {
  35426. var e = -t.utcOffset(),
  35427. n = Math.abs(e),
  35428. r = Math.floor(n / 60),
  35429. i = n % 60;
  35430. return (e <= 0 ? "+" : "-") + d(r, 2, "0") + ":" + d(i, 2, "0");
  35431. },
  35432. m: function t(e, n) {
  35433. if (e.date() < n.date()) return -t(n, e);
  35434. var r = 12 * (n.year() - e.year()) + (n.month() - e.month()),
  35435. i = e.add(r, u),
  35436. s = n - i < 0,
  35437. a = e.add(r + (s ? -1 : 1), u);
  35438. return +(-(r + (n - i) / (s ? i - a : a - i)) || 0);
  35439. },
  35440. a: function a(t) {
  35441. return t < 0 ? Math.ceil(t) || 0 : Math.floor(t);
  35442. },
  35443. p: function p(h) {
  35444. return {
  35445. M: u,
  35446. y: o,
  35447. w: s,
  35448. d: i,
  35449. D: f,
  35450. h: r,
  35451. m: n,
  35452. s: e,
  35453. ms: t,
  35454. Q: a
  35455. }[h] || String(h || "").toLowerCase().replace(/s$/, "");
  35456. },
  35457. u: function u(t) {
  35458. return void 0 === t;
  35459. }
  35460. },
  35461. l = {
  35462. name: "en",
  35463. weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
  35464. months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_")
  35465. },
  35466. y = "en",
  35467. M = {};
  35468. M[y] = l;
  35469. var m = function m(t) {
  35470. return t instanceof S;
  35471. },
  35472. D = function D(t, e, n) {
  35473. var r;
  35474. if (!t) return y;
  35475. if ("string" == typeof t) M[t] && (r = t), e && (M[t] = e, r = t); else {
  35476. var i = t.name;
  35477. M[i] = t, r = i;
  35478. }
  35479. return !n && r && (y = r), r || !n && y;
  35480. },
  35481. v = function v(t, e) {
  35482. if (m(t)) return t.clone();
  35483. var n = "object" == _typeof(e) ? e : {};
  35484. return n.date = t, n.args = arguments, new S(n);
  35485. },
  35486. g = $;
  35487. g.l = D, g.i = m, g.w = function (t, e) {
  35488. return v(t, {
  35489. locale: e.$L,
  35490. utc: e.$u,
  35491. $offset: e.$offset
  35492. });
  35493. };
  35494. var S = function () {
  35495. function d(t) {
  35496. this.$L = this.$L || D(t.locale, null, !0), this.parse(t);
  35497. }
  35498. var $ = d.prototype;
  35499. return $.parse = function (t) {
  35500. this.$d = function (t) {
  35501. var e = t.date,
  35502. n = t.utc;
  35503. if (null === e) return new Date(NaN);
  35504. if (g.u(e)) return new Date();
  35505. if (e instanceof Date) return new Date(e);
  35506. if ("string" == typeof e && !/Z$/i.test(e)) {
  35507. var r = e.match(h);
  35508. if (r) {
  35509. var i = r[2] - 1 || 0,
  35510. s = (r[7] || "0").substring(0, 3);
  35511. return n ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s)) : new Date(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s);
  35512. }
  35513. }
  35514. return new Date(e);
  35515. }(t), this.init();
  35516. }, $.init = function () {
  35517. var t = this.$d;
  35518. this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds();
  35519. }, $.$utils = function () {
  35520. return g;
  35521. }, $.isValid = function () {
  35522. return !("Invalid Date" === this.$d.toString());
  35523. }, $.isSame = function (t, e) {
  35524. var n = v(t);
  35525. return this.startOf(e) <= n && n <= this.endOf(e);
  35526. }, $.isAfter = function (t, e) {
  35527. return v(t) < this.startOf(e);
  35528. }, $.isBefore = function (t, e) {
  35529. return this.endOf(e) < v(t);
  35530. }, $.$g = function (t, e, n) {
  35531. return g.u(t) ? this[e] : this.set(n, t);
  35532. }, $.unix = function () {
  35533. return Math.floor(this.valueOf() / 1e3);
  35534. }, $.valueOf = function () {
  35535. return this.$d.getTime();
  35536. }, $.startOf = function (t, a) {
  35537. var h = this,
  35538. c = !!g.u(a) || a,
  35539. d = g.p(t),
  35540. $ = function $(t, e) {
  35541. var n = g.w(h.$u ? Date.UTC(h.$y, e, t) : new Date(h.$y, e, t), h);
  35542. return c ? n : n.endOf(i);
  35543. },
  35544. l = function l(t, e) {
  35545. return g.w(h.toDate()[t].apply(h.toDate("s"), (c ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e)), h);
  35546. },
  35547. y = this.$W,
  35548. M = this.$M,
  35549. m = this.$D,
  35550. D = "set" + (this.$u ? "UTC" : "");
  35551. switch (d) {
  35552. case o:
  35553. return c ? $(1, 0) : $(31, 11);
  35554. case u:
  35555. return c ? $(1, M) : $(0, M + 1);
  35556. case s:
  35557. var v = this.$locale().weekStart || 0,
  35558. S = (y < v ? y + 7 : y) - v;
  35559. return $(c ? m - S : m + (6 - S), M);
  35560. case i:
  35561. case f:
  35562. return l(D + "Hours", 0);
  35563. case r:
  35564. return l(D + "Minutes", 1);
  35565. case n:
  35566. return l(D + "Seconds", 2);
  35567. case e:
  35568. return l(D + "Milliseconds", 3);
  35569. default:
  35570. return this.clone();
  35571. }
  35572. }, $.endOf = function (t) {
  35573. return this.startOf(t, !1);
  35574. }, $.$set = function (s, a) {
  35575. var h,
  35576. c = g.p(s),
  35577. d = "set" + (this.$u ? "UTC" : ""),
  35578. $ = (h = {}, h[i] = d + "Date", h[f] = d + "Date", h[u] = d + "Month", h[o] = d + "FullYear", h[r] = d + "Hours", h[n] = d + "Minutes", h[e] = d + "Seconds", h[t] = d + "Milliseconds", h)[c],
  35579. l = c === i ? this.$D + (a - this.$W) : a;
  35580. if (c === u || c === o) {
  35581. var y = this.clone().set(f, 1);
  35582. y.$d[$](l), y.init(), this.$d = y.set(f, Math.min(this.$D, y.daysInMonth())).$d;
  35583. } else $ && this.$d[$](l);
  35584. return this.init(), this;
  35585. }, $.set = function (t, e) {
  35586. return this.clone().$set(t, e);
  35587. }, $.get = function (t) {
  35588. return this[g.p(t)]();
  35589. }, $.add = function (t, a) {
  35590. var f,
  35591. h = this;
  35592. t = Number(t);
  35593. var c = g.p(a),
  35594. d = function d(e) {
  35595. var n = v(h);
  35596. return g.w(n.date(n.date() + Math.round(e * t)), h);
  35597. };
  35598. if (c === u) return this.set(u, this.$M + t);
  35599. if (c === o) return this.set(o, this.$y + t);
  35600. if (c === i) return d(1);
  35601. if (c === s) return d(7);
  35602. var $ = (f = {}, f[n] = 6e4, f[r] = 36e5, f[e] = 1e3, f)[c] || 1,
  35603. l = this.$d.getTime() + t * $;
  35604. return g.w(l, this);
  35605. }, $.subtract = function (t, e) {
  35606. return this.add(-1 * t, e);
  35607. }, $.format = function (t) {
  35608. var e = this;
  35609. if (!this.isValid()) return "Invalid Date";
  35610. var n = t || "YYYY-MM-DDTHH:mm:ssZ",
  35611. r = g.z(this),
  35612. i = this.$locale(),
  35613. s = this.$H,
  35614. u = this.$m,
  35615. a = this.$M,
  35616. o = i.weekdays,
  35617. f = i.months,
  35618. h = function h(t, r, i, s) {
  35619. return t && (t[r] || t(e, n)) || i[r].substr(0, s);
  35620. },
  35621. d = function d(t) {
  35622. return g.s(s % 12 || 12, t, "0");
  35623. },
  35624. $ = i.meridiem || function (t, e, n) {
  35625. var r = t < 12 ? "AM" : "PM";
  35626. return n ? r.toLowerCase() : r;
  35627. },
  35628. l = {
  35629. YY: String(this.$y).slice(-2),
  35630. YYYY: this.$y,
  35631. M: a + 1,
  35632. MM: g.s(a + 1, 2, "0"),
  35633. MMM: h(i.monthsShort, a, f, 3),
  35634. MMMM: h(f, a),
  35635. D: this.$D,
  35636. DD: g.s(this.$D, 2, "0"),
  35637. d: String(this.$W),
  35638. dd: h(i.weekdaysMin, this.$W, o, 2),
  35639. ddd: h(i.weekdaysShort, this.$W, o, 3),
  35640. dddd: o[this.$W],
  35641. H: String(s),
  35642. HH: g.s(s, 2, "0"),
  35643. h: d(1),
  35644. hh: d(2),
  35645. a: $(s, u, !0),
  35646. A: $(s, u, !1),
  35647. m: String(u),
  35648. mm: g.s(u, 2, "0"),
  35649. s: String(this.$s),
  35650. ss: g.s(this.$s, 2, "0"),
  35651. SSS: g.s(this.$ms, 3, "0"),
  35652. Z: r
  35653. };
  35654. return n.replace(c, function (t, e) {
  35655. return e || l[t] || r.replace(":", "");
  35656. });
  35657. }, $.utcOffset = function () {
  35658. return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
  35659. }, $.diff = function (t, f, h) {
  35660. var c,
  35661. d = g.p(f),
  35662. $ = v(t),
  35663. l = 6e4 * ($.utcOffset() - this.utcOffset()),
  35664. y = this - $,
  35665. M = g.m(this, $);
  35666. return M = (c = {}, c[o] = M / 12, c[u] = M, c[a] = M / 3, c[s] = (y - l) / 6048e5, c[i] = (y - l) / 864e5, c[r] = y / 36e5, c[n] = y / 6e4, c[e] = y / 1e3, c)[d] || y, h ? M : g.a(M);
  35667. }, $.daysInMonth = function () {
  35668. return this.endOf(u).$D;
  35669. }, $.$locale = function () {
  35670. return M[this.$L];
  35671. }, $.locale = function (t, e) {
  35672. if (!t) return this.$L;
  35673. var n = this.clone(),
  35674. r = D(t, e, !0);
  35675. return r && (n.$L = r), n;
  35676. }, $.clone = function () {
  35677. return g.w(this.$d, this);
  35678. }, $.toDate = function () {
  35679. return new Date(this.valueOf());
  35680. }, $.toJSON = function () {
  35681. return this.isValid() ? this.toISOString() : null;
  35682. }, $.toISOString = function () {
  35683. return this.$d.toISOString();
  35684. }, $.toString = function () {
  35685. return this.$d.toUTCString();
  35686. }, d;
  35687. }(),
  35688. p = S.prototype;
  35689. return v.prototype = p, [["$ms", t], ["$s", e], ["$m", n], ["$H", r], ["$W", i], ["$M", u], ["$y", o], ["$D", f]].forEach(function (t) {
  35690. p[t[1]] = function (e) {
  35691. return this.$g(e, t[0], t[1]);
  35692. };
  35693. }), v.extend = function (t, e) {
  35694. return t(e, S, v), v;
  35695. }, v.locale = D, v.isDayjs = m, v.unix = function (t) {
  35696. return v(1e3 * t);
  35697. }, v.en = M[y], v.Ls = M, v;
  35698. });
  35699. }, {}], 337: [function (require, module, exports) {
  35700. "use strict";
  35701. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  35702. !function (t, e) {
  35703. "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : t.dayjs_plugin_customParseFormat = e();
  35704. }(void 0, function () {
  35705. "use strict";
  35706. var t,
  35707. e = /(\[[^[]*\])|([-:/.()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,
  35708. n = /\d\d/,
  35709. r = /\d\d?/,
  35710. o = /\d*[^\s\d-:/()]+/;
  35711. var i = function i(t) {
  35712. return function (e) {
  35713. this[t] = +e;
  35714. };
  35715. },
  35716. s = [/[+-]\d\d:?\d\d/, function (t) {
  35717. var e, n;
  35718. (this.zone || (this.zone = {})).offset = (e = t.match(/([+-]|\d\d)/g), 0 === (n = 60 * e[1] + +e[2]) ? 0 : "+" === e[0] ? -n : n);
  35719. }],
  35720. a = function a(e) {
  35721. var n = t[e];
  35722. return n && (n.indexOf ? n : n.s.concat(n.f));
  35723. },
  35724. h = {
  35725. A: [/[AP]M/, function (t) {
  35726. this.afternoon = "PM" === t;
  35727. }],
  35728. a: [/[ap]m/, function (t) {
  35729. this.afternoon = "pm" === t;
  35730. }],
  35731. S: [/\d/, function (t) {
  35732. this.milliseconds = 100 * +t;
  35733. }],
  35734. SS: [n, function (t) {
  35735. this.milliseconds = 10 * +t;
  35736. }],
  35737. SSS: [/\d{3}/, function (t) {
  35738. this.milliseconds = +t;
  35739. }],
  35740. s: [r, i("seconds")],
  35741. ss: [r, i("seconds")],
  35742. m: [r, i("minutes")],
  35743. mm: [r, i("minutes")],
  35744. H: [r, i("hours")],
  35745. h: [r, i("hours")],
  35746. HH: [r, i("hours")],
  35747. hh: [r, i("hours")],
  35748. D: [r, i("day")],
  35749. DD: [n, i("day")],
  35750. Do: [o, function (e) {
  35751. var n = t.ordinal,
  35752. r = e.match(/\d+/);
  35753. if (this.day = r[0], n) for (var o = 1; o <= 31; o += 1) {
  35754. n(o).replace(/\[|\]/g, "") === e && (this.day = o);
  35755. }
  35756. }],
  35757. M: [r, i("month")],
  35758. MM: [n, i("month")],
  35759. MMM: [o, function (t) {
  35760. var e = a("months"),
  35761. n = (a("monthsShort") || e.map(function (t) {
  35762. return t.substr(0, 3);
  35763. })).indexOf(t) + 1;
  35764. if (n < 1) throw new Error();
  35765. this.month = n % 12 || n;
  35766. }],
  35767. MMMM: [o, function (t) {
  35768. var e = a("months").indexOf(t) + 1;
  35769. if (e < 1) throw new Error();
  35770. this.month = e % 12 || e;
  35771. }],
  35772. Y: [/[+-]?\d+/, i("year")],
  35773. YY: [n, function (t) {
  35774. t = +t, this.year = t + (t > 68 ? 1900 : 2e3);
  35775. }],
  35776. YYYY: [/\d{4}/, i("year")],
  35777. Z: s,
  35778. ZZ: s
  35779. };
  35780. var f = function f(t, n, r) {
  35781. try {
  35782. var o = function (t) {
  35783. for (var n = t.match(e), r = n.length, o = 0; o < r; o += 1) {
  35784. var i = n[o],
  35785. s = h[i],
  35786. a = s && s[0],
  35787. f = s && s[1];
  35788. n[o] = f ? {
  35789. regex: a,
  35790. parser: f
  35791. } : i.replace(/^\[|\]$/g, "");
  35792. }
  35793. return function (t) {
  35794. for (var e = {}, o = 0, i = 0; o < r; o += 1) {
  35795. var s = n[o];
  35796. if ("string" == typeof s) i += s.length; else {
  35797. var a = s.regex,
  35798. h = s.parser,
  35799. f = t.substr(i),
  35800. u = a.exec(f)[0];
  35801. h.call(e, u), t = t.replace(u, "");
  35802. }
  35803. }
  35804. return function (t) {
  35805. var e = t.afternoon;
  35806. if (void 0 !== e) {
  35807. var n = t.hours;
  35808. e ? n < 12 && (t.hours += 12) : 12 === n && (t.hours = 0), delete t.afternoon;
  35809. }
  35810. }(e), e;
  35811. };
  35812. }(n)(t),
  35813. i = o.year,
  35814. s = o.month,
  35815. a = o.day,
  35816. f = o.hours,
  35817. u = o.minutes,
  35818. d = o.seconds,
  35819. c = o.milliseconds,
  35820. l = o.zone,
  35821. m = new Date(),
  35822. v = a || (i || s ? 1 : m.getDate()),
  35823. p = i || m.getFullYear(),
  35824. y = 0;
  35825. i && !s || (y = s > 0 ? s - 1 : m.getMonth());
  35826. var D = f || 0,
  35827. M = u || 0,
  35828. g = d || 0,
  35829. Y = c || 0;
  35830. return l ? new Date(Date.UTC(p, y, v, D, M, g, Y + 60 * l.offset * 1e3)) : r ? new Date(Date.UTC(p, y, v, D, M, g, Y)) : new Date(p, y, v, D, M, g, Y);
  35831. } catch (t) {
  35832. return new Date("");
  35833. }
  35834. };
  35835. return function (e, n, r) {
  35836. var o = n.prototype,
  35837. i = o.parse;
  35838. o.parse = function (e) {
  35839. var n = e.date,
  35840. o = e.utc,
  35841. s = e.args;
  35842. this.$u = o;
  35843. var a = s[1];
  35844. if ("string" == typeof a) {
  35845. var h = !0 === s[2],
  35846. u = !0 === s[3],
  35847. d = h || u,
  35848. c = s[2];
  35849. u && (c = s[2]), h || (t = c ? r.Ls[c] : this.$locale()), this.$d = f(n, a, o), this.init(), c && !0 !== c && (this.$L = this.locale(c).$L), d && n !== this.format(a) && (this.$d = new Date(""));
  35850. } else if (a instanceof Array) for (var l = a.length, m = 1; m <= l; m += 1) {
  35851. s[1] = a[m - 1];
  35852. var v = r.apply(this, s);
  35853. if (v.isValid()) {
  35854. this.$d = v.$d, this.$L = v.$L, this.init();
  35855. break;
  35856. }
  35857. m === l && (this.$d = new Date(""));
  35858. } else i.call(this, e);
  35859. };
  35860. };
  35861. });
  35862. }, {}], 338: [function (require, module, exports) {
  35863. "use strict";
  35864. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  35865. !function (t, i) {
  35866. "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? module.exports = i() : "function" == typeof define && define.amd ? define(i) : t.dayjs_plugin_utc = i();
  35867. }(void 0, function () {
  35868. "use strict";
  35869. return function (t, i, e) {
  35870. var s = new Date().getTimezoneOffset(),
  35871. n = i.prototype;
  35872. e.utc = function (t) {
  35873. return new i({
  35874. date: t,
  35875. utc: !0,
  35876. args: arguments
  35877. });
  35878. }, n.utc = function () {
  35879. return e(this.toDate(), {
  35880. locale: this.$L,
  35881. utc: !0
  35882. });
  35883. }, n.local = function () {
  35884. return e(this.toDate(), {
  35885. locale: this.$L,
  35886. utc: !1
  35887. });
  35888. };
  35889. var u = n.parse;
  35890. n.parse = function (t) {
  35891. t.utc && (this.$u = !0), this.$utils().u(t.$offset) || (this.$offset = t.$offset), u.call(this, t);
  35892. };
  35893. var o = n.init;
  35894. n.init = function () {
  35895. if (this.$u) {
  35896. var t = this.$d;
  35897. this.$y = t.getUTCFullYear(), this.$M = t.getUTCMonth(), this.$D = t.getUTCDate(), this.$W = t.getUTCDay(), this.$H = t.getUTCHours(), this.$m = t.getUTCMinutes(), this.$s = t.getUTCSeconds(), this.$ms = t.getUTCMilliseconds();
  35898. } else o.call(this);
  35899. };
  35900. var f = n.utcOffset;
  35901. n.utcOffset = function (t, i) {
  35902. var e = this.$utils().u;
  35903. if (e(t)) return this.$u ? 0 : e(this.$offset) ? f.call(this) : this.$offset;
  35904. var n = Math.abs(t) <= 16 ? 60 * t : t,
  35905. u = this;
  35906. return i ? (u.$offset = n, u.$u = 0 === t, u) : (0 !== t ? (u = this.local().add(n + s, "minute")).$offset = n : u = this.utc(), u);
  35907. };
  35908. var r = n.format;
  35909. n.format = function (t) {
  35910. var i = t || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : "");
  35911. return r.call(this, i);
  35912. }, n.valueOf = function () {
  35913. var t = this.$utils().u(this.$offset) ? 0 : this.$offset + s;
  35914. return this.$d.valueOf() - 6e4 * t;
  35915. }, n.isUTC = function () {
  35916. return !!this.$u;
  35917. }, n.toISOString = function () {
  35918. return this.toDate().toISOString();
  35919. }, n.toString = function () {
  35920. return this.toDate().toUTCString();
  35921. };
  35922. var a = n.toDate;
  35923. n.toDate = function (t) {
  35924. return "s" === t && this.$offset ? e(this.format("YYYY-MM-DD")).toDate() : a.call(this);
  35925. };
  35926. var c = n.diff;
  35927. n.diff = function (t, i, s) {
  35928. var n = this.local(),
  35929. u = e(t).local();
  35930. return c.call(n, u, i, s);
  35931. };
  35932. };
  35933. });
  35934. }, {}], 339: [function (require, module, exports) {
  35935. 'use strict';
  35936. exports.utils = require('./des/utils');
  35937. exports.Cipher = require('./des/cipher');
  35938. exports.DES = require('./des/des');
  35939. exports.CBC = require('./des/cbc');
  35940. exports.EDE = require('./des/ede');
  35941. }, { "./des/cbc": 340, "./des/cipher": 341, "./des/des": 342, "./des/ede": 343, "./des/utils": 344 }], 340: [function (require, module, exports) {
  35942. 'use strict';
  35943. var assert = require('minimalistic-assert');
  35944. var inherits = require('inherits');
  35945. var proto = {};
  35946. function CBCState(iv) {
  35947. assert.equal(iv.length, 8, 'Invalid IV length');
  35948. this.iv = new Array(8);
  35949. for (var i = 0; i < this.iv.length; i++) {
  35950. this.iv[i] = iv[i];
  35951. }
  35952. }
  35953. function instantiate(Base) {
  35954. function CBC(options) {
  35955. Base.call(this, options);
  35956. this._cbcInit();
  35957. }
  35958. inherits(CBC, Base);
  35959. var keys = Object.keys(proto);
  35960. for (var i = 0; i < keys.length; i++) {
  35961. var key = keys[i];
  35962. CBC.prototype[key] = proto[key];
  35963. }
  35964. CBC.create = function create(options) {
  35965. return new CBC(options);
  35966. };
  35967. return CBC;
  35968. }
  35969. exports.instantiate = instantiate;
  35970. proto._cbcInit = function _cbcInit() {
  35971. var state = new CBCState(this.options.iv);
  35972. this._cbcState = state;
  35973. };
  35974. proto._update = function _update(inp, inOff, out, outOff) {
  35975. var state = this._cbcState;
  35976. var superProto = this.constructor.super_.prototype;
  35977. var iv = state.iv;
  35978. if (this.type === 'encrypt') {
  35979. for (var i = 0; i < this.blockSize; i++) {
  35980. iv[i] ^= inp[inOff + i];
  35981. }
  35982. superProto._update.call(this, iv, 0, out, outOff);
  35983. for (var i = 0; i < this.blockSize; i++) {
  35984. iv[i] = out[outOff + i];
  35985. }
  35986. } else {
  35987. superProto._update.call(this, inp, inOff, out, outOff);
  35988. for (var i = 0; i < this.blockSize; i++) {
  35989. out[outOff + i] ^= iv[i];
  35990. }
  35991. for (var i = 0; i < this.blockSize; i++) {
  35992. iv[i] = inp[inOff + i];
  35993. }
  35994. }
  35995. };
  35996. }, { "inherits": 387, "minimalistic-assert": 437 }], 341: [function (require, module, exports) {
  35997. 'use strict';
  35998. var assert = require('minimalistic-assert');
  35999. function Cipher(options) {
  36000. this.options = options;
  36001. this.type = this.options.type;
  36002. this.blockSize = 8;
  36003. this._init();
  36004. this.buffer = new Array(this.blockSize);
  36005. this.bufferOff = 0;
  36006. }
  36007. module.exports = Cipher;
  36008. Cipher.prototype._init = function _init() {// Might be overrided
  36009. };
  36010. Cipher.prototype.update = function update(data) {
  36011. if (data.length === 0) return [];
  36012. if (this.type === 'decrypt') return this._updateDecrypt(data); else return this._updateEncrypt(data);
  36013. };
  36014. Cipher.prototype._buffer = function _buffer(data, off) {
  36015. // Append data to buffer
  36016. var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
  36017. for (var i = 0; i < min; i++) {
  36018. this.buffer[this.bufferOff + i] = data[off + i];
  36019. }
  36020. this.bufferOff += min; // Shift next
  36021. return min;
  36022. };
  36023. Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
  36024. this._update(this.buffer, 0, out, off);
  36025. this.bufferOff = 0;
  36026. return this.blockSize;
  36027. };
  36028. Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
  36029. var inputOff = 0;
  36030. var outputOff = 0;
  36031. var count = (this.bufferOff + data.length) / this.blockSize | 0;
  36032. var out = new Array(count * this.blockSize);
  36033. if (this.bufferOff !== 0) {
  36034. inputOff += this._buffer(data, inputOff);
  36035. if (this.bufferOff === this.buffer.length) outputOff += this._flushBuffer(out, outputOff);
  36036. } // Write blocks
  36037. var max = data.length - (data.length - inputOff) % this.blockSize;
  36038. for (; inputOff < max; inputOff += this.blockSize) {
  36039. this._update(data, inputOff, out, outputOff);
  36040. outputOff += this.blockSize;
  36041. } // Queue rest
  36042. for (; inputOff < data.length; inputOff++, this.bufferOff++) {
  36043. this.buffer[this.bufferOff] = data[inputOff];
  36044. }
  36045. return out;
  36046. };
  36047. Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
  36048. var inputOff = 0;
  36049. var outputOff = 0;
  36050. var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
  36051. var out = new Array(count * this.blockSize); // TODO(indutny): optimize it, this is far from optimal
  36052. for (; count > 0; count--) {
  36053. inputOff += this._buffer(data, inputOff);
  36054. outputOff += this._flushBuffer(out, outputOff);
  36055. } // Buffer rest of the input
  36056. inputOff += this._buffer(data, inputOff);
  36057. return out;
  36058. };
  36059. Cipher.prototype.final = function final(buffer) {
  36060. var first;
  36061. if (buffer) first = this.update(buffer);
  36062. var last;
  36063. if (this.type === 'encrypt') last = this._finalEncrypt(); else last = this._finalDecrypt();
  36064. if (first) return first.concat(last); else return last;
  36065. };
  36066. Cipher.prototype._pad = function _pad(buffer, off) {
  36067. if (off === 0) return false;
  36068. while (off < buffer.length) {
  36069. buffer[off++] = 0;
  36070. }
  36071. return true;
  36072. };
  36073. Cipher.prototype._finalEncrypt = function _finalEncrypt() {
  36074. if (!this._pad(this.buffer, this.bufferOff)) return [];
  36075. var out = new Array(this.blockSize);
  36076. this._update(this.buffer, 0, out, 0);
  36077. return out;
  36078. };
  36079. Cipher.prototype._unpad = function _unpad(buffer) {
  36080. return buffer;
  36081. };
  36082. Cipher.prototype._finalDecrypt = function _finalDecrypt() {
  36083. assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
  36084. var out = new Array(this.blockSize);
  36085. this._flushBuffer(out, 0);
  36086. return this._unpad(out);
  36087. };
  36088. }, { "minimalistic-assert": 437 }], 342: [function (require, module, exports) {
  36089. 'use strict';
  36090. var assert = require('minimalistic-assert');
  36091. var inherits = require('inherits');
  36092. var utils = require('./utils');
  36093. var Cipher = require('./cipher');
  36094. function DESState() {
  36095. this.tmp = new Array(2);
  36096. this.keys = null;
  36097. }
  36098. function DES(options) {
  36099. Cipher.call(this, options);
  36100. var state = new DESState();
  36101. this._desState = state;
  36102. this.deriveKeys(state, options.key);
  36103. }
  36104. inherits(DES, Cipher);
  36105. module.exports = DES;
  36106. DES.create = function create(options) {
  36107. return new DES(options);
  36108. };
  36109. var shiftTable = [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1];
  36110. DES.prototype.deriveKeys = function deriveKeys(state, key) {
  36111. state.keys = new Array(16 * 2);
  36112. assert.equal(key.length, this.blockSize, 'Invalid key length');
  36113. var kL = utils.readUInt32BE(key, 0);
  36114. var kR = utils.readUInt32BE(key, 4);
  36115. utils.pc1(kL, kR, state.tmp, 0);
  36116. kL = state.tmp[0];
  36117. kR = state.tmp[1];
  36118. for (var i = 0; i < state.keys.length; i += 2) {
  36119. var shift = shiftTable[i >>> 1];
  36120. kL = utils.r28shl(kL, shift);
  36121. kR = utils.r28shl(kR, shift);
  36122. utils.pc2(kL, kR, state.keys, i);
  36123. }
  36124. };
  36125. DES.prototype._update = function _update(inp, inOff, out, outOff) {
  36126. var state = this._desState;
  36127. var l = utils.readUInt32BE(inp, inOff);
  36128. var r = utils.readUInt32BE(inp, inOff + 4); // Initial Permutation
  36129. utils.ip(l, r, state.tmp, 0);
  36130. l = state.tmp[0];
  36131. r = state.tmp[1];
  36132. if (this.type === 'encrypt') this._encrypt(state, l, r, state.tmp, 0); else this._decrypt(state, l, r, state.tmp, 0);
  36133. l = state.tmp[0];
  36134. r = state.tmp[1];
  36135. utils.writeUInt32BE(out, l, outOff);
  36136. utils.writeUInt32BE(out, r, outOff + 4);
  36137. };
  36138. DES.prototype._pad = function _pad(buffer, off) {
  36139. var value = buffer.length - off;
  36140. for (var i = off; i < buffer.length; i++) {
  36141. buffer[i] = value;
  36142. }
  36143. return true;
  36144. };
  36145. DES.prototype._unpad = function _unpad(buffer) {
  36146. var pad = buffer[buffer.length - 1];
  36147. for (var i = buffer.length - pad; i < buffer.length; i++) {
  36148. assert.equal(buffer[i], pad);
  36149. }
  36150. return buffer.slice(0, buffer.length - pad);
  36151. };
  36152. DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
  36153. var l = lStart;
  36154. var r = rStart; // Apply f() x16 times
  36155. for (var i = 0; i < state.keys.length; i += 2) {
  36156. var keyL = state.keys[i];
  36157. var keyR = state.keys[i + 1]; // f(r, k)
  36158. utils.expand(r, state.tmp, 0);
  36159. keyL ^= state.tmp[0];
  36160. keyR ^= state.tmp[1];
  36161. var s = utils.substitute(keyL, keyR);
  36162. var f = utils.permute(s);
  36163. var t = r;
  36164. r = (l ^ f) >>> 0;
  36165. l = t;
  36166. } // Reverse Initial Permutation
  36167. utils.rip(r, l, out, off);
  36168. };
  36169. DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
  36170. var l = rStart;
  36171. var r = lStart; // Apply f() x16 times
  36172. for (var i = state.keys.length - 2; i >= 0; i -= 2) {
  36173. var keyL = state.keys[i];
  36174. var keyR = state.keys[i + 1]; // f(r, k)
  36175. utils.expand(l, state.tmp, 0);
  36176. keyL ^= state.tmp[0];
  36177. keyR ^= state.tmp[1];
  36178. var s = utils.substitute(keyL, keyR);
  36179. var f = utils.permute(s);
  36180. var t = l;
  36181. l = (r ^ f) >>> 0;
  36182. r = t;
  36183. } // Reverse Initial Permutation
  36184. utils.rip(l, r, out, off);
  36185. };
  36186. }, { "./cipher": 341, "./utils": 344, "inherits": 387, "minimalistic-assert": 437 }], 343: [function (require, module, exports) {
  36187. 'use strict';
  36188. var assert = require('minimalistic-assert');
  36189. var inherits = require('inherits');
  36190. var Cipher = require('./cipher');
  36191. var DES = require('./des');
  36192. function EDEState(type, key) {
  36193. assert.equal(key.length, 24, 'Invalid key length');
  36194. var k1 = key.slice(0, 8);
  36195. var k2 = key.slice(8, 16);
  36196. var k3 = key.slice(16, 24);
  36197. if (type === 'encrypt') {
  36198. this.ciphers = [DES.create({
  36199. type: 'encrypt',
  36200. key: k1
  36201. }), DES.create({
  36202. type: 'decrypt',
  36203. key: k2
  36204. }), DES.create({
  36205. type: 'encrypt',
  36206. key: k3
  36207. })];
  36208. } else {
  36209. this.ciphers = [DES.create({
  36210. type: 'decrypt',
  36211. key: k3
  36212. }), DES.create({
  36213. type: 'encrypt',
  36214. key: k2
  36215. }), DES.create({
  36216. type: 'decrypt',
  36217. key: k1
  36218. })];
  36219. }
  36220. }
  36221. function EDE(options) {
  36222. Cipher.call(this, options);
  36223. var state = new EDEState(this.type, this.options.key);
  36224. this._edeState = state;
  36225. }
  36226. inherits(EDE, Cipher);
  36227. module.exports = EDE;
  36228. EDE.create = function create(options) {
  36229. return new EDE(options);
  36230. };
  36231. EDE.prototype._update = function _update(inp, inOff, out, outOff) {
  36232. var state = this._edeState;
  36233. state.ciphers[0]._update(inp, inOff, out, outOff);
  36234. state.ciphers[1]._update(out, outOff, out, outOff);
  36235. state.ciphers[2]._update(out, outOff, out, outOff);
  36236. };
  36237. EDE.prototype._pad = DES.prototype._pad;
  36238. EDE.prototype._unpad = DES.prototype._unpad;
  36239. }, { "./cipher": 341, "./des": 342, "inherits": 387, "minimalistic-assert": 437 }], 344: [function (require, module, exports) {
  36240. 'use strict';
  36241. exports.readUInt32BE = function readUInt32BE(bytes, off) {
  36242. var res = bytes[0 + off] << 24 | bytes[1 + off] << 16 | bytes[2 + off] << 8 | bytes[3 + off];
  36243. return res >>> 0;
  36244. };
  36245. exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
  36246. bytes[0 + off] = value >>> 24;
  36247. bytes[1 + off] = value >>> 16 & 0xff;
  36248. bytes[2 + off] = value >>> 8 & 0xff;
  36249. bytes[3 + off] = value & 0xff;
  36250. };
  36251. exports.ip = function ip(inL, inR, out, off) {
  36252. var outL = 0;
  36253. var outR = 0;
  36254. for (var i = 6; i >= 0; i -= 2) {
  36255. for (var j = 0; j <= 24; j += 8) {
  36256. outL <<= 1;
  36257. outL |= inR >>> j + i & 1;
  36258. }
  36259. for (var j = 0; j <= 24; j += 8) {
  36260. outL <<= 1;
  36261. outL |= inL >>> j + i & 1;
  36262. }
  36263. }
  36264. for (var i = 6; i >= 0; i -= 2) {
  36265. for (var j = 1; j <= 25; j += 8) {
  36266. outR <<= 1;
  36267. outR |= inR >>> j + i & 1;
  36268. }
  36269. for (var j = 1; j <= 25; j += 8) {
  36270. outR <<= 1;
  36271. outR |= inL >>> j + i & 1;
  36272. }
  36273. }
  36274. out[off + 0] = outL >>> 0;
  36275. out[off + 1] = outR >>> 0;
  36276. };
  36277. exports.rip = function rip(inL, inR, out, off) {
  36278. var outL = 0;
  36279. var outR = 0;
  36280. for (var i = 0; i < 4; i++) {
  36281. for (var j = 24; j >= 0; j -= 8) {
  36282. outL <<= 1;
  36283. outL |= inR >>> j + i & 1;
  36284. outL <<= 1;
  36285. outL |= inL >>> j + i & 1;
  36286. }
  36287. }
  36288. for (var i = 4; i < 8; i++) {
  36289. for (var j = 24; j >= 0; j -= 8) {
  36290. outR <<= 1;
  36291. outR |= inR >>> j + i & 1;
  36292. outR <<= 1;
  36293. outR |= inL >>> j + i & 1;
  36294. }
  36295. }
  36296. out[off + 0] = outL >>> 0;
  36297. out[off + 1] = outR >>> 0;
  36298. };
  36299. exports.pc1 = function pc1(inL, inR, out, off) {
  36300. var outL = 0;
  36301. var outR = 0; // 7, 15, 23, 31, 39, 47, 55, 63
  36302. // 6, 14, 22, 30, 39, 47, 55, 63
  36303. // 5, 13, 21, 29, 39, 47, 55, 63
  36304. // 4, 12, 20, 28
  36305. for (var i = 7; i >= 5; i--) {
  36306. for (var j = 0; j <= 24; j += 8) {
  36307. outL <<= 1;
  36308. outL |= inR >> j + i & 1;
  36309. }
  36310. for (var j = 0; j <= 24; j += 8) {
  36311. outL <<= 1;
  36312. outL |= inL >> j + i & 1;
  36313. }
  36314. }
  36315. for (var j = 0; j <= 24; j += 8) {
  36316. outL <<= 1;
  36317. outL |= inR >> j + i & 1;
  36318. } // 1, 9, 17, 25, 33, 41, 49, 57
  36319. // 2, 10, 18, 26, 34, 42, 50, 58
  36320. // 3, 11, 19, 27, 35, 43, 51, 59
  36321. // 36, 44, 52, 60
  36322. for (var i = 1; i <= 3; i++) {
  36323. for (var j = 0; j <= 24; j += 8) {
  36324. outR <<= 1;
  36325. outR |= inR >> j + i & 1;
  36326. }
  36327. for (var j = 0; j <= 24; j += 8) {
  36328. outR <<= 1;
  36329. outR |= inL >> j + i & 1;
  36330. }
  36331. }
  36332. for (var j = 0; j <= 24; j += 8) {
  36333. outR <<= 1;
  36334. outR |= inL >> j + i & 1;
  36335. }
  36336. out[off + 0] = outL >>> 0;
  36337. out[off + 1] = outR >>> 0;
  36338. };
  36339. exports.r28shl = function r28shl(num, shift) {
  36340. return num << shift & 0xfffffff | num >>> 28 - shift;
  36341. };
  36342. var pc2table = [// inL => outL
  36343. 14, 11, 17, 4, 27, 23, 25, 0, 13, 22, 7, 18, 5, 9, 16, 24, 2, 20, 12, 21, 1, 8, 15, 26, // inR => outR
  36344. 15, 4, 25, 19, 9, 1, 26, 16, 5, 11, 23, 8, 12, 7, 17, 0, 22, 3, 10, 14, 6, 20, 27, 24];
  36345. exports.pc2 = function pc2(inL, inR, out, off) {
  36346. var outL = 0;
  36347. var outR = 0;
  36348. var len = pc2table.length >>> 1;
  36349. for (var i = 0; i < len; i++) {
  36350. outL <<= 1;
  36351. outL |= inL >>> pc2table[i] & 0x1;
  36352. }
  36353. for (var i = len; i < pc2table.length; i++) {
  36354. outR <<= 1;
  36355. outR |= inR >>> pc2table[i] & 0x1;
  36356. }
  36357. out[off + 0] = outL >>> 0;
  36358. out[off + 1] = outR >>> 0;
  36359. };
  36360. exports.expand = function expand(r, out, off) {
  36361. var outL = 0;
  36362. var outR = 0;
  36363. outL = (r & 1) << 5 | r >>> 27;
  36364. for (var i = 23; i >= 15; i -= 4) {
  36365. outL <<= 6;
  36366. outL |= r >>> i & 0x3f;
  36367. }
  36368. for (var i = 11; i >= 3; i -= 4) {
  36369. outR |= r >>> i & 0x3f;
  36370. outR <<= 6;
  36371. }
  36372. outR |= (r & 0x1f) << 1 | r >>> 31;
  36373. out[off + 0] = outL >>> 0;
  36374. out[off + 1] = outR >>> 0;
  36375. };
  36376. var sTable = [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];
  36377. exports.substitute = function substitute(inL, inR) {
  36378. var out = 0;
  36379. for (var i = 0; i < 4; i++) {
  36380. var b = inL >>> 18 - i * 6 & 0x3f;
  36381. var sb = sTable[i * 0x40 + b];
  36382. out <<= 4;
  36383. out |= sb;
  36384. }
  36385. for (var i = 0; i < 4; i++) {
  36386. var b = inR >>> 18 - i * 6 & 0x3f;
  36387. var sb = sTable[4 * 0x40 + i * 0x40 + b];
  36388. out <<= 4;
  36389. out |= sb;
  36390. }
  36391. return out >>> 0;
  36392. };
  36393. var permuteTable = [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];
  36394. exports.permute = function permute(num) {
  36395. var out = 0;
  36396. for (var i = 0; i < permuteTable.length; i++) {
  36397. out <<= 1;
  36398. out |= num >>> permuteTable[i] & 0x1;
  36399. }
  36400. return out >>> 0;
  36401. };
  36402. exports.padSplit = function padSplit(num, size, group) {
  36403. var str = num.toString(2);
  36404. while (str.length < size) {
  36405. str = '0' + str;
  36406. }
  36407. var out = [];
  36408. for (var i = 0; i < size; i += group) {
  36409. out.push(str.slice(i, i + group));
  36410. }
  36411. return out.join(' ');
  36412. };
  36413. }, {}], 345: [function (require, module, exports) {
  36414. (function (Buffer) {
  36415. "use strict";
  36416. var generatePrime = require('./lib/generatePrime');
  36417. var primes = require('./lib/primes.json');
  36418. var DH = require('./lib/dh');
  36419. function getDiffieHellman(mod) {
  36420. var prime = new Buffer(primes[mod].prime, 'hex');
  36421. var gen = new Buffer(primes[mod].gen, 'hex');
  36422. return new DH(prime, gen);
  36423. }
  36424. var ENCODINGS = {
  36425. 'binary': true,
  36426. 'hex': true,
  36427. 'base64': true
  36428. };
  36429. function createDiffieHellman(prime, enc, generator, genc) {
  36430. if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
  36431. return createDiffieHellman(prime, 'binary', enc, generator);
  36432. }
  36433. enc = enc || 'binary';
  36434. genc = genc || 'binary';
  36435. generator = generator || new Buffer([2]);
  36436. if (!Buffer.isBuffer(generator)) {
  36437. generator = new Buffer(generator, genc);
  36438. }
  36439. if (typeof prime === 'number') {
  36440. return new DH(generatePrime(prime, generator), generator, true);
  36441. }
  36442. if (!Buffer.isBuffer(prime)) {
  36443. prime = new Buffer(prime, enc);
  36444. }
  36445. return new DH(prime, generator, true);
  36446. }
  36447. exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman;
  36448. exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman;
  36449. }).call(this, require("buffer").Buffer)
  36450. }, { "./lib/dh": 346, "./lib/generatePrime": 347, "./lib/primes.json": 348, "buffer": 216 }], 346: [function (require, module, exports) {
  36451. (function (Buffer) {
  36452. "use strict";
  36453. var BN = require('bn.js');
  36454. var MillerRabin = require('miller-rabin');
  36455. var millerRabin = new MillerRabin();
  36456. var TWENTYFOUR = new BN(24);
  36457. var ELEVEN = new BN(11);
  36458. var TEN = new BN(10);
  36459. var THREE = new BN(3);
  36460. var SEVEN = new BN(7);
  36461. var primes = require('./generatePrime');
  36462. var randomBytes = require('randombytes');
  36463. module.exports = DH;
  36464. function setPublicKey(pub, enc) {
  36465. enc = enc || 'utf8';
  36466. if (!Buffer.isBuffer(pub)) {
  36467. pub = new Buffer(pub, enc);
  36468. }
  36469. this._pub = new BN(pub);
  36470. return this;
  36471. }
  36472. function setPrivateKey(priv, enc) {
  36473. enc = enc || 'utf8';
  36474. if (!Buffer.isBuffer(priv)) {
  36475. priv = new Buffer(priv, enc);
  36476. }
  36477. this._priv = new BN(priv);
  36478. return this;
  36479. }
  36480. var primeCache = {};
  36481. function checkPrime(prime, generator) {
  36482. var gen = generator.toString('hex');
  36483. var hex = [gen, prime.toString(16)].join('_');
  36484. if (hex in primeCache) {
  36485. return primeCache[hex];
  36486. }
  36487. var error = 0;
  36488. if (prime.isEven() || !primes.simpleSieve || !primes.fermatTest(prime) || !millerRabin.test(prime)) {
  36489. //not a prime so +1
  36490. error += 1;
  36491. if (gen === '02' || gen === '05') {
  36492. // we'd be able to check the generator
  36493. // it would fail so +8
  36494. error += 8;
  36495. } else {
  36496. //we wouldn't be able to test the generator
  36497. // so +4
  36498. error += 4;
  36499. }
  36500. primeCache[hex] = error;
  36501. return error;
  36502. }
  36503. if (!millerRabin.test(prime.shrn(1))) {
  36504. //not a safe prime
  36505. error += 2;
  36506. }
  36507. var rem;
  36508. switch (gen) {
  36509. case '02':
  36510. if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
  36511. // unsuidable generator
  36512. error += 8;
  36513. }
  36514. break;
  36515. case '05':
  36516. rem = prime.mod(TEN);
  36517. if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
  36518. // prime mod 10 needs to equal 3 or 7
  36519. error += 8;
  36520. }
  36521. break;
  36522. default:
  36523. error += 4;
  36524. }
  36525. primeCache[hex] = error;
  36526. return error;
  36527. }
  36528. function DH(prime, generator, malleable) {
  36529. this.setGenerator(generator);
  36530. this.__prime = new BN(prime);
  36531. this._prime = BN.mont(this.__prime);
  36532. this._primeLen = prime.length;
  36533. this._pub = undefined;
  36534. this._priv = undefined;
  36535. this._primeCode = undefined;
  36536. if (malleable) {
  36537. this.setPublicKey = setPublicKey;
  36538. this.setPrivateKey = setPrivateKey;
  36539. } else {
  36540. this._primeCode = 8;
  36541. }
  36542. }
  36543. Object.defineProperty(DH.prototype, 'verifyError', {
  36544. enumerable: true,
  36545. get: function get() {
  36546. if (typeof this._primeCode !== 'number') {
  36547. this._primeCode = checkPrime(this.__prime, this.__gen);
  36548. }
  36549. return this._primeCode;
  36550. }
  36551. });
  36552. DH.prototype.generateKeys = function () {
  36553. if (!this._priv) {
  36554. this._priv = new BN(randomBytes(this._primeLen));
  36555. }
  36556. this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
  36557. return this.getPublicKey();
  36558. };
  36559. DH.prototype.computeSecret = function (other) {
  36560. other = new BN(other);
  36561. other = other.toRed(this._prime);
  36562. var secret = other.redPow(this._priv).fromRed();
  36563. var out = new Buffer(secret.toArray());
  36564. var prime = this.getPrime();
  36565. if (out.length < prime.length) {
  36566. var front = new Buffer(prime.length - out.length);
  36567. front.fill(0);
  36568. out = Buffer.concat([front, out]);
  36569. }
  36570. return out;
  36571. };
  36572. DH.prototype.getPublicKey = function getPublicKey(enc) {
  36573. return formatReturnValue(this._pub, enc);
  36574. };
  36575. DH.prototype.getPrivateKey = function getPrivateKey(enc) {
  36576. return formatReturnValue(this._priv, enc);
  36577. };
  36578. DH.prototype.getPrime = function (enc) {
  36579. return formatReturnValue(this.__prime, enc);
  36580. };
  36581. DH.prototype.getGenerator = function (enc) {
  36582. return formatReturnValue(this._gen, enc);
  36583. };
  36584. DH.prototype.setGenerator = function (gen, enc) {
  36585. enc = enc || 'utf8';
  36586. if (!Buffer.isBuffer(gen)) {
  36587. gen = new Buffer(gen, enc);
  36588. }
  36589. this.__gen = gen;
  36590. this._gen = new BN(gen);
  36591. return this;
  36592. };
  36593. function formatReturnValue(bn, enc) {
  36594. var buf = new Buffer(bn.toArray());
  36595. if (!enc) {
  36596. return buf;
  36597. } else {
  36598. return buf.toString(enc);
  36599. }
  36600. }
  36601. }).call(this, require("buffer").Buffer)
  36602. }, { "./generatePrime": 347, "bn.js": 349, "buffer": 216, "miller-rabin": 435, "randombytes": 475 }], 347: [function (require, module, exports) {
  36603. "use strict";
  36604. var randomBytes = require('randombytes');
  36605. module.exports = findPrime;
  36606. findPrime.simpleSieve = simpleSieve;
  36607. findPrime.fermatTest = fermatTest;
  36608. var BN = require('bn.js');
  36609. var TWENTYFOUR = new BN(24);
  36610. var MillerRabin = require('miller-rabin');
  36611. var millerRabin = new MillerRabin();
  36612. var ONE = new BN(1);
  36613. var TWO = new BN(2);
  36614. var FIVE = new BN(5);
  36615. var SIXTEEN = new BN(16);
  36616. var EIGHT = new BN(8);
  36617. var TEN = new BN(10);
  36618. var THREE = new BN(3);
  36619. var SEVEN = new BN(7);
  36620. var ELEVEN = new BN(11);
  36621. var FOUR = new BN(4);
  36622. var TWELVE = new BN(12);
  36623. var primes = null;
  36624. function _getPrimes() {
  36625. if (primes !== null) return primes;
  36626. var limit = 0x100000;
  36627. var res = [];
  36628. res[0] = 2;
  36629. for (var i = 1, k = 3; k < limit; k += 2) {
  36630. var sqrt = Math.ceil(Math.sqrt(k));
  36631. for (var j = 0; j < i && res[j] <= sqrt; j++) {
  36632. if (k % res[j] === 0) break;
  36633. }
  36634. if (i !== j && res[j] <= sqrt) continue;
  36635. res[i++] = k;
  36636. }
  36637. primes = res;
  36638. return res;
  36639. }
  36640. function simpleSieve(p) {
  36641. var primes = _getPrimes();
  36642. for (var i = 0; i < primes.length; i++) {
  36643. if (p.modn(primes[i]) === 0) {
  36644. if (p.cmpn(primes[i]) === 0) {
  36645. return true;
  36646. } else {
  36647. return false;
  36648. }
  36649. }
  36650. }
  36651. return true;
  36652. }
  36653. function fermatTest(p) {
  36654. var red = BN.mont(p);
  36655. return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
  36656. }
  36657. function findPrime(bits, gen) {
  36658. if (bits < 16) {
  36659. // this is what openssl does
  36660. if (gen === 2 || gen === 5) {
  36661. return new BN([0x8c, 0x7b]);
  36662. } else {
  36663. return new BN([0x8c, 0x27]);
  36664. }
  36665. }
  36666. gen = new BN(gen);
  36667. var num, n2;
  36668. while (true) {
  36669. num = new BN(randomBytes(Math.ceil(bits / 8)));
  36670. while (num.bitLength() > bits) {
  36671. num.ishrn(1);
  36672. }
  36673. if (num.isEven()) {
  36674. num.iadd(ONE);
  36675. }
  36676. if (!num.testn(1)) {
  36677. num.iadd(TWO);
  36678. }
  36679. if (!gen.cmp(TWO)) {
  36680. while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
  36681. num.iadd(FOUR);
  36682. }
  36683. } else if (!gen.cmp(FIVE)) {
  36684. while (num.mod(TEN).cmp(THREE)) {
  36685. num.iadd(FOUR);
  36686. }
  36687. }
  36688. n2 = num.shrn(1);
  36689. if (simpleSieve(n2) && simpleSieve(num) && fermatTest(n2) && fermatTest(num) && millerRabin.test(n2) && millerRabin.test(num)) {
  36690. return num;
  36691. }
  36692. }
  36693. }
  36694. }, { "bn.js": 349, "miller-rabin": 435, "randombytes": 475 }], 348: [function (require, module, exports) {
  36695. module.exports = {
  36696. "modp1": {
  36697. "gen": "02",
  36698. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
  36699. },
  36700. "modp2": {
  36701. "gen": "02",
  36702. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
  36703. },
  36704. "modp5": {
  36705. "gen": "02",
  36706. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"
  36707. },
  36708. "modp14": {
  36709. "gen": "02",
  36710. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"
  36711. },
  36712. "modp15": {
  36713. "gen": "02",
  36714. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"
  36715. },
  36716. "modp16": {
  36717. "gen": "02",
  36718. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"
  36719. },
  36720. "modp17": {
  36721. "gen": "02",
  36722. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"
  36723. },
  36724. "modp18": {
  36725. "gen": "02",
  36726. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
  36727. }
  36728. }
  36729. }, {}], 349: [function (require, module, exports) {
  36730. arguments[4][181][0].apply(exports, arguments)
  36731. }, { "buffer": 185, "dup": 181 }], 350: [function (require, module, exports) {
  36732. 'use strict';
  36733. var elliptic = exports;
  36734. elliptic.version = require('../package.json').version;
  36735. elliptic.utils = require('./elliptic/utils');
  36736. elliptic.rand = require('brorand');
  36737. elliptic.curve = require('./elliptic/curve');
  36738. elliptic.curves = require('./elliptic/curves'); // Protocols
  36739. elliptic.ec = require('./elliptic/ec');
  36740. elliptic.eddsa = require('./elliptic/eddsa');
  36741. }, { "../package.json": 366, "./elliptic/curve": 353, "./elliptic/curves": 356, "./elliptic/ec": 357, "./elliptic/eddsa": 360, "./elliptic/utils": 364, "brorand": 184 }], 351: [function (require, module, exports) {
  36742. 'use strict';
  36743. var BN = require('bn.js');
  36744. var utils = require('../utils');
  36745. var getNAF = utils.getNAF;
  36746. var getJSF = utils.getJSF;
  36747. var assert = utils.assert;
  36748. function BaseCurve(type, conf) {
  36749. this.type = type;
  36750. this.p = new BN(conf.p, 16); // Use Montgomery, when there is no fast reduction for the prime
  36751. this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); // Useful for many curves
  36752. this.zero = new BN(0).toRed(this.red);
  36753. this.one = new BN(1).toRed(this.red);
  36754. this.two = new BN(2).toRed(this.red); // Curve configuration, optional
  36755. this.n = conf.n && new BN(conf.n, 16);
  36756. this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); // Temporary arrays
  36757. this._wnafT1 = new Array(4);
  36758. this._wnafT2 = new Array(4);
  36759. this._wnafT3 = new Array(4);
  36760. this._wnafT4 = new Array(4);
  36761. this._bitLength = this.n ? this.n.bitLength() : 0; // Generalized Greg Maxwell's trick
  36762. var adjustCount = this.n && this.p.div(this.n);
  36763. if (!adjustCount || adjustCount.cmpn(100) > 0) {
  36764. this.redN = null;
  36765. } else {
  36766. this._maxwellTrick = true;
  36767. this.redN = this.n.toRed(this.red);
  36768. }
  36769. }
  36770. module.exports = BaseCurve;
  36771. BaseCurve.prototype.point = function point() {
  36772. throw new Error('Not implemented');
  36773. };
  36774. BaseCurve.prototype.validate = function validate() {
  36775. throw new Error('Not implemented');
  36776. };
  36777. BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
  36778. assert(p.precomputed);
  36779. var doubles = p._getDoubles();
  36780. var naf = getNAF(k, 1, this._bitLength);
  36781. var I = (1 << doubles.step + 1) - (doubles.step % 2 === 0 ? 2 : 1);
  36782. I /= 3; // Translate into more windowed form
  36783. var repr = [];
  36784. for (var j = 0; j < naf.length; j += doubles.step) {
  36785. var nafW = 0;
  36786. for (var k = j + doubles.step - 1; k >= j; k--) {
  36787. nafW = (nafW << 1) + naf[k];
  36788. }
  36789. repr.push(nafW);
  36790. }
  36791. var a = this.jpoint(null, null, null);
  36792. var b = this.jpoint(null, null, null);
  36793. for (var i = I; i > 0; i--) {
  36794. for (var j = 0; j < repr.length; j++) {
  36795. var nafW = repr[j];
  36796. if (nafW === i) b = b.mixedAdd(doubles.points[j]); else if (nafW === -i) b = b.mixedAdd(doubles.points[j].neg());
  36797. }
  36798. a = a.add(b);
  36799. }
  36800. return a.toP();
  36801. };
  36802. BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
  36803. var w = 4; // Precompute window
  36804. var nafPoints = p._getNAFPoints(w);
  36805. w = nafPoints.wnd;
  36806. var wnd = nafPoints.points; // Get NAF form
  36807. var naf = getNAF(k, w, this._bitLength); // Add `this`*(N+1) for every w-NAF index
  36808. var acc = this.jpoint(null, null, null);
  36809. for (var i = naf.length - 1; i >= 0; i--) {
  36810. // Count zeroes
  36811. for (var k = 0; i >= 0 && naf[i] === 0; i--) {
  36812. k++;
  36813. }
  36814. if (i >= 0) k++;
  36815. acc = acc.dblp(k);
  36816. if (i < 0) break;
  36817. var z = naf[i];
  36818. assert(z !== 0);
  36819. if (p.type === 'affine') {
  36820. // J +- P
  36821. if (z > 0) acc = acc.mixedAdd(wnd[z - 1 >> 1]); else acc = acc.mixedAdd(wnd[-z - 1 >> 1].neg());
  36822. } else {
  36823. // J +- J
  36824. if (z > 0) acc = acc.add(wnd[z - 1 >> 1]); else acc = acc.add(wnd[-z - 1 >> 1].neg());
  36825. }
  36826. }
  36827. return p.type === 'affine' ? acc.toP() : acc;
  36828. };
  36829. BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, points, coeffs, len, jacobianResult) {
  36830. var wndWidth = this._wnafT1;
  36831. var wnd = this._wnafT2;
  36832. var naf = this._wnafT3; // Fill all arrays
  36833. var max = 0;
  36834. for (var i = 0; i < len; i++) {
  36835. var p = points[i];
  36836. var nafPoints = p._getNAFPoints(defW);
  36837. wndWidth[i] = nafPoints.wnd;
  36838. wnd[i] = nafPoints.points;
  36839. } // Comb small window NAFs
  36840. for (var i = len - 1; i >= 1; i -= 2) {
  36841. var a = i - 1;
  36842. var b = i;
  36843. if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
  36844. naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength);
  36845. naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength);
  36846. max = Math.max(naf[a].length, max);
  36847. max = Math.max(naf[b].length, max);
  36848. continue;
  36849. }
  36850. var comb = [points[a],
  36851. /* 1 */
  36852. null,
  36853. /* 3 */
  36854. null,
  36855. /* 5 */
  36856. points[b]
  36857. /* 7 */
  36858. ]; // Try to avoid Projective points, if possible
  36859. if (points[a].y.cmp(points[b].y) === 0) {
  36860. comb[1] = points[a].add(points[b]);
  36861. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  36862. } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
  36863. comb[1] = points[a].toJ().mixedAdd(points[b]);
  36864. comb[2] = points[a].add(points[b].neg());
  36865. } else {
  36866. comb[1] = points[a].toJ().mixedAdd(points[b]);
  36867. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  36868. }
  36869. var index = [-3,
  36870. /* -1 -1 */
  36871. -1,
  36872. /* -1 0 */
  36873. -5,
  36874. /* -1 1 */
  36875. -7,
  36876. /* 0 -1 */
  36877. 0,
  36878. /* 0 0 */
  36879. 7,
  36880. /* 0 1 */
  36881. 5,
  36882. /* 1 -1 */
  36883. 1,
  36884. /* 1 0 */
  36885. 3
  36886. /* 1 1 */
  36887. ];
  36888. var jsf = getJSF(coeffs[a], coeffs[b]);
  36889. max = Math.max(jsf[0].length, max);
  36890. naf[a] = new Array(max);
  36891. naf[b] = new Array(max);
  36892. for (var j = 0; j < max; j++) {
  36893. var ja = jsf[0][j] | 0;
  36894. var jb = jsf[1][j] | 0;
  36895. naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
  36896. naf[b][j] = 0;
  36897. wnd[a] = comb;
  36898. }
  36899. }
  36900. var acc = this.jpoint(null, null, null);
  36901. var tmp = this._wnafT4;
  36902. for (var i = max; i >= 0; i--) {
  36903. var k = 0;
  36904. while (i >= 0) {
  36905. var zero = true;
  36906. for (var j = 0; j < len; j++) {
  36907. tmp[j] = naf[j][i] | 0;
  36908. if (tmp[j] !== 0) zero = false;
  36909. }
  36910. if (!zero) break;
  36911. k++;
  36912. i--;
  36913. }
  36914. if (i >= 0) k++;
  36915. acc = acc.dblp(k);
  36916. if (i < 0) break;
  36917. for (var j = 0; j < len; j++) {
  36918. var z = tmp[j];
  36919. var p;
  36920. if (z === 0) continue; else if (z > 0) p = wnd[j][z - 1 >> 1]; else if (z < 0) p = wnd[j][-z - 1 >> 1].neg();
  36921. if (p.type === 'affine') acc = acc.mixedAdd(p); else acc = acc.add(p);
  36922. }
  36923. } // Zeroify references
  36924. for (var i = 0; i < len; i++) {
  36925. wnd[i] = null;
  36926. }
  36927. if (jacobianResult) return acc; else return acc.toP();
  36928. };
  36929. function BasePoint(curve, type) {
  36930. this.curve = curve;
  36931. this.type = type;
  36932. this.precomputed = null;
  36933. }
  36934. BaseCurve.BasePoint = BasePoint;
  36935. BasePoint.prototype.eq = function eq()
  36936. /*other*/ {
  36937. throw new Error('Not implemented');
  36938. };
  36939. BasePoint.prototype.validate = function validate() {
  36940. return this.curve.validate(this);
  36941. };
  36942. BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  36943. bytes = utils.toArray(bytes, enc);
  36944. var len = this.p.byteLength(); // uncompressed, hybrid-odd, hybrid-even
  36945. if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && bytes.length - 1 === 2 * len) {
  36946. if (bytes[0] === 0x06) assert(bytes[bytes.length - 1] % 2 === 0); else if (bytes[0] === 0x07) assert(bytes[bytes.length - 1] % 2 === 1);
  36947. var res = this.point(bytes.slice(1, 1 + len), bytes.slice(1 + len, 1 + 2 * len));
  36948. return res;
  36949. } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && bytes.length - 1 === len) {
  36950. return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
  36951. }
  36952. throw new Error('Unknown point format');
  36953. };
  36954. BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
  36955. return this.encode(enc, true);
  36956. };
  36957. BasePoint.prototype._encode = function _encode(compact) {
  36958. var len = this.curve.p.byteLength();
  36959. var x = this.getX().toArray('be', len);
  36960. if (compact) return [this.getY().isEven() ? 0x02 : 0x03].concat(x);
  36961. return [0x04].concat(x, this.getY().toArray('be', len));
  36962. };
  36963. BasePoint.prototype.encode = function encode(enc, compact) {
  36964. return utils.encode(this._encode(compact), enc);
  36965. };
  36966. BasePoint.prototype.precompute = function precompute(power) {
  36967. if (this.precomputed) return this;
  36968. var precomputed = {
  36969. doubles: null,
  36970. naf: null,
  36971. beta: null
  36972. };
  36973. precomputed.naf = this._getNAFPoints(8);
  36974. precomputed.doubles = this._getDoubles(4, power);
  36975. precomputed.beta = this._getBeta();
  36976. this.precomputed = precomputed;
  36977. return this;
  36978. };
  36979. BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
  36980. if (!this.precomputed) return false;
  36981. var doubles = this.precomputed.doubles;
  36982. if (!doubles) return false;
  36983. return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
  36984. };
  36985. BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
  36986. if (this.precomputed && this.precomputed.doubles) return this.precomputed.doubles;
  36987. var doubles = [this];
  36988. var acc = this;
  36989. for (var i = 0; i < power; i += step) {
  36990. for (var j = 0; j < step; j++) {
  36991. acc = acc.dbl();
  36992. }
  36993. doubles.push(acc);
  36994. }
  36995. return {
  36996. step: step,
  36997. points: doubles
  36998. };
  36999. };
  37000. BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
  37001. if (this.precomputed && this.precomputed.naf) return this.precomputed.naf;
  37002. var res = [this];
  37003. var max = (1 << wnd) - 1;
  37004. var dbl = max === 1 ? null : this.dbl();
  37005. for (var i = 1; i < max; i++) {
  37006. res[i] = res[i - 1].add(dbl);
  37007. }
  37008. return {
  37009. wnd: wnd,
  37010. points: res
  37011. };
  37012. };
  37013. BasePoint.prototype._getBeta = function _getBeta() {
  37014. return null;
  37015. };
  37016. BasePoint.prototype.dblp = function dblp(k) {
  37017. var r = this;
  37018. for (var i = 0; i < k; i++) {
  37019. r = r.dbl();
  37020. }
  37021. return r;
  37022. };
  37023. }, { "../utils": 364, "bn.js": 365 }], 352: [function (require, module, exports) {
  37024. 'use strict';
  37025. var utils = require('../utils');
  37026. var BN = require('bn.js');
  37027. var inherits = require('inherits');
  37028. var Base = require('./base');
  37029. var assert = utils.assert;
  37030. function EdwardsCurve(conf) {
  37031. // NOTE: Important as we are creating point in Base.call()
  37032. this.twisted = (conf.a | 0) !== 1;
  37033. this.mOneA = this.twisted && (conf.a | 0) === -1;
  37034. this.extended = this.mOneA;
  37035. Base.call(this, 'edwards', conf);
  37036. this.a = new BN(conf.a, 16).umod(this.red.m);
  37037. this.a = this.a.toRed(this.red);
  37038. this.c = new BN(conf.c, 16).toRed(this.red);
  37039. this.c2 = this.c.redSqr();
  37040. this.d = new BN(conf.d, 16).toRed(this.red);
  37041. this.dd = this.d.redAdd(this.d);
  37042. assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
  37043. this.oneC = (conf.c | 0) === 1;
  37044. }
  37045. inherits(EdwardsCurve, Base);
  37046. module.exports = EdwardsCurve;
  37047. EdwardsCurve.prototype._mulA = function _mulA(num) {
  37048. if (this.mOneA) return num.redNeg(); else return this.a.redMul(num);
  37049. };
  37050. EdwardsCurve.prototype._mulC = function _mulC(num) {
  37051. if (this.oneC) return num; else return this.c.redMul(num);
  37052. }; // Just for compatibility with Short curve
  37053. EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
  37054. return this.point(x, y, z, t);
  37055. };
  37056. EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
  37057. x = new BN(x, 16);
  37058. if (!x.red) x = x.toRed(this.red);
  37059. var x2 = x.redSqr();
  37060. var rhs = this.c2.redSub(this.a.redMul(x2));
  37061. var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
  37062. var y2 = rhs.redMul(lhs.redInvm());
  37063. var y = y2.redSqrt();
  37064. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) throw new Error('invalid point');
  37065. var isOdd = y.fromRed().isOdd();
  37066. if (odd && !isOdd || !odd && isOdd) y = y.redNeg();
  37067. return this.point(x, y);
  37068. };
  37069. EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
  37070. y = new BN(y, 16);
  37071. if (!y.red) y = y.toRed(this.red); // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
  37072. var y2 = y.redSqr();
  37073. var lhs = y2.redSub(this.c2);
  37074. var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
  37075. var x2 = lhs.redMul(rhs.redInvm());
  37076. if (x2.cmp(this.zero) === 0) {
  37077. if (odd) throw new Error('invalid point'); else return this.point(this.zero, y);
  37078. }
  37079. var x = x2.redSqrt();
  37080. if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) throw new Error('invalid point');
  37081. if (x.fromRed().isOdd() !== odd) x = x.redNeg();
  37082. return this.point(x, y);
  37083. };
  37084. EdwardsCurve.prototype.validate = function validate(point) {
  37085. if (point.isInfinity()) return true; // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
  37086. point.normalize();
  37087. var x2 = point.x.redSqr();
  37088. var y2 = point.y.redSqr();
  37089. var lhs = x2.redMul(this.a).redAdd(y2);
  37090. var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
  37091. return lhs.cmp(rhs) === 0;
  37092. };
  37093. function Point(curve, x, y, z, t) {
  37094. Base.BasePoint.call(this, curve, 'projective');
  37095. if (x === null && y === null && z === null) {
  37096. this.x = this.curve.zero;
  37097. this.y = this.curve.one;
  37098. this.z = this.curve.one;
  37099. this.t = this.curve.zero;
  37100. this.zOne = true;
  37101. } else {
  37102. this.x = new BN(x, 16);
  37103. this.y = new BN(y, 16);
  37104. this.z = z ? new BN(z, 16) : this.curve.one;
  37105. this.t = t && new BN(t, 16);
  37106. if (!this.x.red) this.x = this.x.toRed(this.curve.red);
  37107. if (!this.y.red) this.y = this.y.toRed(this.curve.red);
  37108. if (!this.z.red) this.z = this.z.toRed(this.curve.red);
  37109. if (this.t && !this.t.red) this.t = this.t.toRed(this.curve.red);
  37110. this.zOne = this.z === this.curve.one; // Use extended coordinates
  37111. if (this.curve.extended && !this.t) {
  37112. this.t = this.x.redMul(this.y);
  37113. if (!this.zOne) this.t = this.t.redMul(this.z.redInvm());
  37114. }
  37115. }
  37116. }
  37117. inherits(Point, Base.BasePoint);
  37118. EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  37119. return Point.fromJSON(this, obj);
  37120. };
  37121. EdwardsCurve.prototype.point = function point(x, y, z, t) {
  37122. return new Point(this, x, y, z, t);
  37123. };
  37124. Point.fromJSON = function fromJSON(curve, obj) {
  37125. return new Point(curve, obj[0], obj[1], obj[2]);
  37126. };
  37127. Point.prototype.inspect = function inspect() {
  37128. if (this.isInfinity()) return '<EC Point Infinity>';
  37129. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) + ' y: ' + this.y.fromRed().toString(16, 2) + ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  37130. };
  37131. Point.prototype.isInfinity = function isInfinity() {
  37132. // XXX This code assumes that zero is always zero in red
  37133. return this.x.cmpn(0) === 0 && (this.y.cmp(this.z) === 0 || this.zOne && this.y.cmp(this.curve.c) === 0);
  37134. };
  37135. Point.prototype._extDbl = function _extDbl() {
  37136. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  37137. // #doubling-dbl-2008-hwcd
  37138. // 4M + 4S
  37139. // A = X1^2
  37140. var a = this.x.redSqr(); // B = Y1^2
  37141. var b = this.y.redSqr(); // C = 2 * Z1^2
  37142. var c = this.z.redSqr();
  37143. c = c.redIAdd(c); // D = a * A
  37144. var d = this.curve._mulA(a); // E = (X1 + Y1)^2 - A - B
  37145. var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); // G = D + B
  37146. var g = d.redAdd(b); // F = G - C
  37147. var f = g.redSub(c); // H = D - B
  37148. var h = d.redSub(b); // X3 = E * F
  37149. var nx = e.redMul(f); // Y3 = G * H
  37150. var ny = g.redMul(h); // T3 = E * H
  37151. var nt = e.redMul(h); // Z3 = F * G
  37152. var nz = f.redMul(g);
  37153. return this.curve.point(nx, ny, nz, nt);
  37154. };
  37155. Point.prototype._projDbl = function _projDbl() {
  37156. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  37157. // #doubling-dbl-2008-bbjlp
  37158. // #doubling-dbl-2007-bl
  37159. // and others
  37160. // Generally 3M + 4S or 2M + 4S
  37161. // B = (X1 + Y1)^2
  37162. var b = this.x.redAdd(this.y).redSqr(); // C = X1^2
  37163. var c = this.x.redSqr(); // D = Y1^2
  37164. var d = this.y.redSqr();
  37165. var nx;
  37166. var ny;
  37167. var nz;
  37168. if (this.curve.twisted) {
  37169. // E = a * C
  37170. var e = this.curve._mulA(c); // F = E + D
  37171. var f = e.redAdd(d);
  37172. if (this.zOne) {
  37173. // X3 = (B - C - D) * (F - 2)
  37174. nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); // Y3 = F * (E - D)
  37175. ny = f.redMul(e.redSub(d)); // Z3 = F^2 - 2 * F
  37176. nz = f.redSqr().redSub(f).redSub(f);
  37177. } else {
  37178. // H = Z1^2
  37179. var h = this.z.redSqr(); // J = F - 2 * H
  37180. var j = f.redSub(h).redISub(h); // X3 = (B-C-D)*J
  37181. nx = b.redSub(c).redISub(d).redMul(j); // Y3 = F * (E - D)
  37182. ny = f.redMul(e.redSub(d)); // Z3 = F * J
  37183. nz = f.redMul(j);
  37184. }
  37185. } else {
  37186. // E = C + D
  37187. var e = c.redAdd(d); // H = (c * Z1)^2
  37188. var h = this.curve._mulC(this.z).redSqr(); // J = E - 2 * H
  37189. var j = e.redSub(h).redSub(h); // X3 = c * (B - E) * J
  37190. nx = this.curve._mulC(b.redISub(e)).redMul(j); // Y3 = c * E * (C - D)
  37191. ny = this.curve._mulC(e).redMul(c.redISub(d)); // Z3 = E * J
  37192. nz = e.redMul(j);
  37193. }
  37194. return this.curve.point(nx, ny, nz);
  37195. };
  37196. Point.prototype.dbl = function dbl() {
  37197. if (this.isInfinity()) return this; // Double in extended coordinates
  37198. if (this.curve.extended) return this._extDbl(); else return this._projDbl();
  37199. };
  37200. Point.prototype._extAdd = function _extAdd(p) {
  37201. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  37202. // #addition-add-2008-hwcd-3
  37203. // 8M
  37204. // A = (Y1 - X1) * (Y2 - X2)
  37205. var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); // B = (Y1 + X1) * (Y2 + X2)
  37206. var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); // C = T1 * k * T2
  37207. var c = this.t.redMul(this.curve.dd).redMul(p.t); // D = Z1 * 2 * Z2
  37208. var d = this.z.redMul(p.z.redAdd(p.z)); // E = B - A
  37209. var e = b.redSub(a); // F = D - C
  37210. var f = d.redSub(c); // G = D + C
  37211. var g = d.redAdd(c); // H = B + A
  37212. var h = b.redAdd(a); // X3 = E * F
  37213. var nx = e.redMul(f); // Y3 = G * H
  37214. var ny = g.redMul(h); // T3 = E * H
  37215. var nt = e.redMul(h); // Z3 = F * G
  37216. var nz = f.redMul(g);
  37217. return this.curve.point(nx, ny, nz, nt);
  37218. };
  37219. Point.prototype._projAdd = function _projAdd(p) {
  37220. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  37221. // #addition-add-2008-bbjlp
  37222. // #addition-add-2007-bl
  37223. // 10M + 1S
  37224. // A = Z1 * Z2
  37225. var a = this.z.redMul(p.z); // B = A^2
  37226. var b = a.redSqr(); // C = X1 * X2
  37227. var c = this.x.redMul(p.x); // D = Y1 * Y2
  37228. var d = this.y.redMul(p.y); // E = d * C * D
  37229. var e = this.curve.d.redMul(c).redMul(d); // F = B - E
  37230. var f = b.redSub(e); // G = B + E
  37231. var g = b.redAdd(e); // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
  37232. var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
  37233. var nx = a.redMul(f).redMul(tmp);
  37234. var ny;
  37235. var nz;
  37236. if (this.curve.twisted) {
  37237. // Y3 = A * G * (D - a * C)
  37238. ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); // Z3 = F * G
  37239. nz = f.redMul(g);
  37240. } else {
  37241. // Y3 = A * G * (D - C)
  37242. ny = a.redMul(g).redMul(d.redSub(c)); // Z3 = c * F * G
  37243. nz = this.curve._mulC(f).redMul(g);
  37244. }
  37245. return this.curve.point(nx, ny, nz);
  37246. };
  37247. Point.prototype.add = function add(p) {
  37248. if (this.isInfinity()) return p;
  37249. if (p.isInfinity()) return this;
  37250. if (this.curve.extended) return this._extAdd(p); else return this._projAdd(p);
  37251. };
  37252. Point.prototype.mul = function mul(k) {
  37253. if (this._hasDoubles(k)) return this.curve._fixedNafMul(this, k); else return this.curve._wnafMul(this, k);
  37254. };
  37255. Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
  37256. return this.curve._wnafMulAdd(1, [this, p], [k1, k2], 2, false);
  37257. };
  37258. Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
  37259. return this.curve._wnafMulAdd(1, [this, p], [k1, k2], 2, true);
  37260. };
  37261. Point.prototype.normalize = function normalize() {
  37262. if (this.zOne) return this; // Normalize coordinates
  37263. var zi = this.z.redInvm();
  37264. this.x = this.x.redMul(zi);
  37265. this.y = this.y.redMul(zi);
  37266. if (this.t) this.t = this.t.redMul(zi);
  37267. this.z = this.curve.one;
  37268. this.zOne = true;
  37269. return this;
  37270. };
  37271. Point.prototype.neg = function neg() {
  37272. return this.curve.point(this.x.redNeg(), this.y, this.z, this.t && this.t.redNeg());
  37273. };
  37274. Point.prototype.getX = function getX() {
  37275. this.normalize();
  37276. return this.x.fromRed();
  37277. };
  37278. Point.prototype.getY = function getY() {
  37279. this.normalize();
  37280. return this.y.fromRed();
  37281. };
  37282. Point.prototype.eq = function eq(other) {
  37283. return this === other || this.getX().cmp(other.getX()) === 0 && this.getY().cmp(other.getY()) === 0;
  37284. };
  37285. Point.prototype.eqXToP = function eqXToP(x) {
  37286. var rx = x.toRed(this.curve.red).redMul(this.z);
  37287. if (this.x.cmp(rx) === 0) return true;
  37288. var xc = x.clone();
  37289. var t = this.curve.redN.redMul(this.z);
  37290. for (; ;) {
  37291. xc.iadd(this.curve.n);
  37292. if (xc.cmp(this.curve.p) >= 0) return false;
  37293. rx.redIAdd(t);
  37294. if (this.x.cmp(rx) === 0) return true;
  37295. }
  37296. }; // Compatibility with BaseCurve
  37297. Point.prototype.toP = Point.prototype.normalize;
  37298. Point.prototype.mixedAdd = Point.prototype.add;
  37299. }, { "../utils": 364, "./base": 351, "bn.js": 365, "inherits": 387 }], 353: [function (require, module, exports) {
  37300. 'use strict';
  37301. var curve = exports;
  37302. curve.base = require('./base');
  37303. curve.short = require('./short');
  37304. curve.mont = require('./mont');
  37305. curve.edwards = require('./edwards');
  37306. }, { "./base": 351, "./edwards": 352, "./mont": 354, "./short": 355 }], 354: [function (require, module, exports) {
  37307. 'use strict';
  37308. var BN = require('bn.js');
  37309. var inherits = require('inherits');
  37310. var Base = require('./base');
  37311. var utils = require('../utils');
  37312. function MontCurve(conf) {
  37313. Base.call(this, 'mont', conf);
  37314. this.a = new BN(conf.a, 16).toRed(this.red);
  37315. this.b = new BN(conf.b, 16).toRed(this.red);
  37316. this.i4 = new BN(4).toRed(this.red).redInvm();
  37317. this.two = new BN(2).toRed(this.red);
  37318. this.a24 = this.i4.redMul(this.a.redAdd(this.two));
  37319. }
  37320. inherits(MontCurve, Base);
  37321. module.exports = MontCurve;
  37322. MontCurve.prototype.validate = function validate(point) {
  37323. var x = point.normalize().x;
  37324. var x2 = x.redSqr();
  37325. var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
  37326. var y = rhs.redSqrt();
  37327. return y.redSqr().cmp(rhs) === 0;
  37328. };
  37329. function Point(curve, x, z) {
  37330. Base.BasePoint.call(this, curve, 'projective');
  37331. if (x === null && z === null) {
  37332. this.x = this.curve.one;
  37333. this.z = this.curve.zero;
  37334. } else {
  37335. this.x = new BN(x, 16);
  37336. this.z = new BN(z, 16);
  37337. if (!this.x.red) this.x = this.x.toRed(this.curve.red);
  37338. if (!this.z.red) this.z = this.z.toRed(this.curve.red);
  37339. }
  37340. }
  37341. inherits(Point, Base.BasePoint);
  37342. MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  37343. return this.point(utils.toArray(bytes, enc), 1);
  37344. };
  37345. MontCurve.prototype.point = function point(x, z) {
  37346. return new Point(this, x, z);
  37347. };
  37348. MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  37349. return Point.fromJSON(this, obj);
  37350. };
  37351. Point.prototype.precompute = function precompute() {// No-op
  37352. };
  37353. Point.prototype._encode = function _encode() {
  37354. return this.getX().toArray('be', this.curve.p.byteLength());
  37355. };
  37356. Point.fromJSON = function fromJSON(curve, obj) {
  37357. return new Point(curve, obj[0], obj[1] || curve.one);
  37358. };
  37359. Point.prototype.inspect = function inspect() {
  37360. if (this.isInfinity()) return '<EC Point Infinity>';
  37361. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) + ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  37362. };
  37363. Point.prototype.isInfinity = function isInfinity() {
  37364. // XXX This code assumes that zero is always zero in red
  37365. return this.z.cmpn(0) === 0;
  37366. };
  37367. Point.prototype.dbl = function dbl() {
  37368. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
  37369. // 2M + 2S + 4A
  37370. // A = X1 + Z1
  37371. var a = this.x.redAdd(this.z); // AA = A^2
  37372. var aa = a.redSqr(); // B = X1 - Z1
  37373. var b = this.x.redSub(this.z); // BB = B^2
  37374. var bb = b.redSqr(); // C = AA - BB
  37375. var c = aa.redSub(bb); // X3 = AA * BB
  37376. var nx = aa.redMul(bb); // Z3 = C * (BB + A24 * C)
  37377. var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
  37378. return this.curve.point(nx, nz);
  37379. };
  37380. Point.prototype.add = function add() {
  37381. throw new Error('Not supported on Montgomery curve');
  37382. };
  37383. Point.prototype.diffAdd = function diffAdd(p, diff) {
  37384. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
  37385. // 4M + 2S + 6A
  37386. // A = X2 + Z2
  37387. var a = this.x.redAdd(this.z); // B = X2 - Z2
  37388. var b = this.x.redSub(this.z); // C = X3 + Z3
  37389. var c = p.x.redAdd(p.z); // D = X3 - Z3
  37390. var d = p.x.redSub(p.z); // DA = D * A
  37391. var da = d.redMul(a); // CB = C * B
  37392. var cb = c.redMul(b); // X5 = Z1 * (DA + CB)^2
  37393. var nx = diff.z.redMul(da.redAdd(cb).redSqr()); // Z5 = X1 * (DA - CB)^2
  37394. var nz = diff.x.redMul(da.redISub(cb).redSqr());
  37395. return this.curve.point(nx, nz);
  37396. };
  37397. Point.prototype.mul = function mul(k) {
  37398. var t = k.clone();
  37399. var a = this; // (N / 2) * Q + Q
  37400. var b = this.curve.point(null, null); // (N / 2) * Q
  37401. var c = this; // Q
  37402. for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) {
  37403. bits.push(t.andln(1));
  37404. }
  37405. for (var i = bits.length - 1; i >= 0; i--) {
  37406. if (bits[i] === 0) {
  37407. // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
  37408. a = a.diffAdd(b, c); // N * Q = 2 * ((N / 2) * Q + Q))
  37409. b = b.dbl();
  37410. } else {
  37411. // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
  37412. b = a.diffAdd(b, c); // N * Q + Q = 2 * ((N / 2) * Q + Q)
  37413. a = a.dbl();
  37414. }
  37415. }
  37416. return b;
  37417. };
  37418. Point.prototype.mulAdd = function mulAdd() {
  37419. throw new Error('Not supported on Montgomery curve');
  37420. };
  37421. Point.prototype.jumlAdd = function jumlAdd() {
  37422. throw new Error('Not supported on Montgomery curve');
  37423. };
  37424. Point.prototype.eq = function eq(other) {
  37425. return this.getX().cmp(other.getX()) === 0;
  37426. };
  37427. Point.prototype.normalize = function normalize() {
  37428. this.x = this.x.redMul(this.z.redInvm());
  37429. this.z = this.curve.one;
  37430. return this;
  37431. };
  37432. Point.prototype.getX = function getX() {
  37433. // Normalize coordinates
  37434. this.normalize();
  37435. return this.x.fromRed();
  37436. };
  37437. }, { "../utils": 364, "./base": 351, "bn.js": 365, "inherits": 387 }], 355: [function (require, module, exports) {
  37438. 'use strict';
  37439. var utils = require('../utils');
  37440. var BN = require('bn.js');
  37441. var inherits = require('inherits');
  37442. var Base = require('./base');
  37443. var assert = utils.assert;
  37444. function ShortCurve(conf) {
  37445. Base.call(this, 'short', conf);
  37446. this.a = new BN(conf.a, 16).toRed(this.red);
  37447. this.b = new BN(conf.b, 16).toRed(this.red);
  37448. this.tinv = this.two.redInvm();
  37449. this.zeroA = this.a.fromRed().cmpn(0) === 0;
  37450. this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; // If the curve is endomorphic, precalculate beta and lambda
  37451. this.endo = this._getEndomorphism(conf);
  37452. this._endoWnafT1 = new Array(4);
  37453. this._endoWnafT2 = new Array(4);
  37454. }
  37455. inherits(ShortCurve, Base);
  37456. module.exports = ShortCurve;
  37457. ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
  37458. // No efficient endomorphism
  37459. if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) return; // Compute beta and lambda, that lambda * P = (beta * Px; Py)
  37460. var beta;
  37461. var lambda;
  37462. if (conf.beta) {
  37463. beta = new BN(conf.beta, 16).toRed(this.red);
  37464. } else {
  37465. var betas = this._getEndoRoots(this.p); // Choose the smallest beta
  37466. beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
  37467. beta = beta.toRed(this.red);
  37468. }
  37469. if (conf.lambda) {
  37470. lambda = new BN(conf.lambda, 16);
  37471. } else {
  37472. // Choose the lambda that is matching selected beta
  37473. var lambdas = this._getEndoRoots(this.n);
  37474. if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
  37475. lambda = lambdas[0];
  37476. } else {
  37477. lambda = lambdas[1];
  37478. assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
  37479. }
  37480. } // Get basis vectors, used for balanced length-two representation
  37481. var basis;
  37482. if (conf.basis) {
  37483. basis = conf.basis.map(function (vec) {
  37484. return {
  37485. a: new BN(vec.a, 16),
  37486. b: new BN(vec.b, 16)
  37487. };
  37488. });
  37489. } else {
  37490. basis = this._getEndoBasis(lambda);
  37491. }
  37492. return {
  37493. beta: beta,
  37494. lambda: lambda,
  37495. basis: basis
  37496. };
  37497. };
  37498. ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
  37499. // Find roots of for x^2 + x + 1 in F
  37500. // Root = (-1 +- Sqrt(-3)) / 2
  37501. //
  37502. var red = num === this.p ? this.red : BN.mont(num);
  37503. var tinv = new BN(2).toRed(red).redInvm();
  37504. var ntinv = tinv.redNeg();
  37505. var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
  37506. var l1 = ntinv.redAdd(s).fromRed();
  37507. var l2 = ntinv.redSub(s).fromRed();
  37508. return [l1, l2];
  37509. };
  37510. ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
  37511. // aprxSqrt >= sqrt(this.n)
  37512. var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); // 3.74
  37513. // Run EGCD, until r(L + 1) < aprxSqrt
  37514. var u = lambda;
  37515. var v = this.n.clone();
  37516. var x1 = new BN(1);
  37517. var y1 = new BN(0);
  37518. var x2 = new BN(0);
  37519. var y2 = new BN(1); // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
  37520. var a0;
  37521. var b0; // First vector
  37522. var a1;
  37523. var b1; // Second vector
  37524. var a2;
  37525. var b2;
  37526. var prevR;
  37527. var i = 0;
  37528. var r;
  37529. var x;
  37530. while (u.cmpn(0) !== 0) {
  37531. var q = v.div(u);
  37532. r = v.sub(q.mul(u));
  37533. x = x2.sub(q.mul(x1));
  37534. var y = y2.sub(q.mul(y1));
  37535. if (!a1 && r.cmp(aprxSqrt) < 0) {
  37536. a0 = prevR.neg();
  37537. b0 = x1;
  37538. a1 = r.neg();
  37539. b1 = x;
  37540. } else if (a1 && ++i === 2) {
  37541. break;
  37542. }
  37543. prevR = r;
  37544. v = u;
  37545. u = r;
  37546. x2 = x1;
  37547. x1 = x;
  37548. y2 = y1;
  37549. y1 = y;
  37550. }
  37551. a2 = r.neg();
  37552. b2 = x;
  37553. var len1 = a1.sqr().add(b1.sqr());
  37554. var len2 = a2.sqr().add(b2.sqr());
  37555. if (len2.cmp(len1) >= 0) {
  37556. a2 = a0;
  37557. b2 = b0;
  37558. } // Normalize signs
  37559. if (a1.negative) {
  37560. a1 = a1.neg();
  37561. b1 = b1.neg();
  37562. }
  37563. if (a2.negative) {
  37564. a2 = a2.neg();
  37565. b2 = b2.neg();
  37566. }
  37567. return [{
  37568. a: a1,
  37569. b: b1
  37570. }, {
  37571. a: a2,
  37572. b: b2
  37573. }];
  37574. };
  37575. ShortCurve.prototype._endoSplit = function _endoSplit(k) {
  37576. var basis = this.endo.basis;
  37577. var v1 = basis[0];
  37578. var v2 = basis[1];
  37579. var c1 = v2.b.mul(k).divRound(this.n);
  37580. var c2 = v1.b.neg().mul(k).divRound(this.n);
  37581. var p1 = c1.mul(v1.a);
  37582. var p2 = c2.mul(v2.a);
  37583. var q1 = c1.mul(v1.b);
  37584. var q2 = c2.mul(v2.b); // Calculate answer
  37585. var k1 = k.sub(p1).sub(p2);
  37586. var k2 = q1.add(q2).neg();
  37587. return {
  37588. k1: k1,
  37589. k2: k2
  37590. };
  37591. };
  37592. ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
  37593. x = new BN(x, 16);
  37594. if (!x.red) x = x.toRed(this.red);
  37595. var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
  37596. var y = y2.redSqrt();
  37597. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) throw new Error('invalid point'); // XXX Is there any way to tell if the number is odd without converting it
  37598. // to non-red form?
  37599. var isOdd = y.fromRed().isOdd();
  37600. if (odd && !isOdd || !odd && isOdd) y = y.redNeg();
  37601. return this.point(x, y);
  37602. };
  37603. ShortCurve.prototype.validate = function validate(point) {
  37604. if (point.inf) return true;
  37605. var x = point.x;
  37606. var y = point.y;
  37607. var ax = this.a.redMul(x);
  37608. var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
  37609. return y.redSqr().redISub(rhs).cmpn(0) === 0;
  37610. };
  37611. ShortCurve.prototype._endoWnafMulAdd = function _endoWnafMulAdd(points, coeffs, jacobianResult) {
  37612. var npoints = this._endoWnafT1;
  37613. var ncoeffs = this._endoWnafT2;
  37614. for (var i = 0; i < points.length; i++) {
  37615. var split = this._endoSplit(coeffs[i]);
  37616. var p = points[i];
  37617. var beta = p._getBeta();
  37618. if (split.k1.negative) {
  37619. split.k1.ineg();
  37620. p = p.neg(true);
  37621. }
  37622. if (split.k2.negative) {
  37623. split.k2.ineg();
  37624. beta = beta.neg(true);
  37625. }
  37626. npoints[i * 2] = p;
  37627. npoints[i * 2 + 1] = beta;
  37628. ncoeffs[i * 2] = split.k1;
  37629. ncoeffs[i * 2 + 1] = split.k2;
  37630. }
  37631. var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); // Clean-up references to points and coefficients
  37632. for (var j = 0; j < i * 2; j++) {
  37633. npoints[j] = null;
  37634. ncoeffs[j] = null;
  37635. }
  37636. return res;
  37637. };
  37638. function Point(curve, x, y, isRed) {
  37639. Base.BasePoint.call(this, curve, 'affine');
  37640. if (x === null && y === null) {
  37641. this.x = null;
  37642. this.y = null;
  37643. this.inf = true;
  37644. } else {
  37645. this.x = new BN(x, 16);
  37646. this.y = new BN(y, 16); // Force redgomery representation when loading from JSON
  37647. if (isRed) {
  37648. this.x.forceRed(this.curve.red);
  37649. this.y.forceRed(this.curve.red);
  37650. }
  37651. if (!this.x.red) this.x = this.x.toRed(this.curve.red);
  37652. if (!this.y.red) this.y = this.y.toRed(this.curve.red);
  37653. this.inf = false;
  37654. }
  37655. }
  37656. inherits(Point, Base.BasePoint);
  37657. ShortCurve.prototype.point = function point(x, y, isRed) {
  37658. return new Point(this, x, y, isRed);
  37659. };
  37660. ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
  37661. return Point.fromJSON(this, obj, red);
  37662. };
  37663. Point.prototype._getBeta = function _getBeta() {
  37664. if (!this.curve.endo) return;
  37665. var pre = this.precomputed;
  37666. if (pre && pre.beta) return pre.beta;
  37667. var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
  37668. if (pre) {
  37669. var curve = this.curve;
  37670. var endoMul = function endoMul(p) {
  37671. return curve.point(p.x.redMul(curve.endo.beta), p.y);
  37672. };
  37673. pre.beta = beta;
  37674. beta.precomputed = {
  37675. beta: null,
  37676. naf: pre.naf && {
  37677. wnd: pre.naf.wnd,
  37678. points: pre.naf.points.map(endoMul)
  37679. },
  37680. doubles: pre.doubles && {
  37681. step: pre.doubles.step,
  37682. points: pre.doubles.points.map(endoMul)
  37683. }
  37684. };
  37685. }
  37686. return beta;
  37687. };
  37688. Point.prototype.toJSON = function toJSON() {
  37689. if (!this.precomputed) return [this.x, this.y];
  37690. return [this.x, this.y, this.precomputed && {
  37691. doubles: this.precomputed.doubles && {
  37692. step: this.precomputed.doubles.step,
  37693. points: this.precomputed.doubles.points.slice(1)
  37694. },
  37695. naf: this.precomputed.naf && {
  37696. wnd: this.precomputed.naf.wnd,
  37697. points: this.precomputed.naf.points.slice(1)
  37698. }
  37699. }];
  37700. };
  37701. Point.fromJSON = function fromJSON(curve, obj, red) {
  37702. if (typeof obj === 'string') obj = JSON.parse(obj);
  37703. var res = curve.point(obj[0], obj[1], red);
  37704. if (!obj[2]) return res;
  37705. function obj2point(obj) {
  37706. return curve.point(obj[0], obj[1], red);
  37707. }
  37708. var pre = obj[2];
  37709. res.precomputed = {
  37710. beta: null,
  37711. doubles: pre.doubles && {
  37712. step: pre.doubles.step,
  37713. points: [res].concat(pre.doubles.points.map(obj2point))
  37714. },
  37715. naf: pre.naf && {
  37716. wnd: pre.naf.wnd,
  37717. points: [res].concat(pre.naf.points.map(obj2point))
  37718. }
  37719. };
  37720. return res;
  37721. };
  37722. Point.prototype.inspect = function inspect() {
  37723. if (this.isInfinity()) return '<EC Point Infinity>';
  37724. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) + ' y: ' + this.y.fromRed().toString(16, 2) + '>';
  37725. };
  37726. Point.prototype.isInfinity = function isInfinity() {
  37727. return this.inf;
  37728. };
  37729. Point.prototype.add = function add(p) {
  37730. // O + P = P
  37731. if (this.inf) return p; // P + O = P
  37732. if (p.inf) return this; // P + P = 2P
  37733. if (this.eq(p)) return this.dbl(); // P + (-P) = O
  37734. if (this.neg().eq(p)) return this.curve.point(null, null); // P + Q = O
  37735. if (this.x.cmp(p.x) === 0) return this.curve.point(null, null);
  37736. var c = this.y.redSub(p.y);
  37737. if (c.cmpn(0) !== 0) c = c.redMul(this.x.redSub(p.x).redInvm());
  37738. var nx = c.redSqr().redISub(this.x).redISub(p.x);
  37739. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  37740. return this.curve.point(nx, ny);
  37741. };
  37742. Point.prototype.dbl = function dbl() {
  37743. if (this.inf) return this; // 2P = O
  37744. var ys1 = this.y.redAdd(this.y);
  37745. if (ys1.cmpn(0) === 0) return this.curve.point(null, null);
  37746. var a = this.curve.a;
  37747. var x2 = this.x.redSqr();
  37748. var dyinv = ys1.redInvm();
  37749. var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
  37750. var nx = c.redSqr().redISub(this.x.redAdd(this.x));
  37751. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  37752. return this.curve.point(nx, ny);
  37753. };
  37754. Point.prototype.getX = function getX() {
  37755. return this.x.fromRed();
  37756. };
  37757. Point.prototype.getY = function getY() {
  37758. return this.y.fromRed();
  37759. };
  37760. Point.prototype.mul = function mul(k) {
  37761. k = new BN(k, 16);
  37762. if (this.isInfinity()) return this; else if (this._hasDoubles(k)) return this.curve._fixedNafMul(this, k); else if (this.curve.endo) return this.curve._endoWnafMulAdd([this], [k]); else return this.curve._wnafMul(this, k);
  37763. };
  37764. Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
  37765. var points = [this, p2];
  37766. var coeffs = [k1, k2];
  37767. if (this.curve.endo) return this.curve._endoWnafMulAdd(points, coeffs); else return this.curve._wnafMulAdd(1, points, coeffs, 2);
  37768. };
  37769. Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
  37770. var points = [this, p2];
  37771. var coeffs = [k1, k2];
  37772. if (this.curve.endo) return this.curve._endoWnafMulAdd(points, coeffs, true); else return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
  37773. };
  37774. Point.prototype.eq = function eq(p) {
  37775. return this === p || this.inf === p.inf && (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
  37776. };
  37777. Point.prototype.neg = function neg(_precompute) {
  37778. if (this.inf) return this;
  37779. var res = this.curve.point(this.x, this.y.redNeg());
  37780. if (_precompute && this.precomputed) {
  37781. var pre = this.precomputed;
  37782. var negate = function negate(p) {
  37783. return p.neg();
  37784. };
  37785. res.precomputed = {
  37786. naf: pre.naf && {
  37787. wnd: pre.naf.wnd,
  37788. points: pre.naf.points.map(negate)
  37789. },
  37790. doubles: pre.doubles && {
  37791. step: pre.doubles.step,
  37792. points: pre.doubles.points.map(negate)
  37793. }
  37794. };
  37795. }
  37796. return res;
  37797. };
  37798. Point.prototype.toJ = function toJ() {
  37799. if (this.inf) return this.curve.jpoint(null, null, null);
  37800. var res = this.curve.jpoint(this.x, this.y, this.curve.one);
  37801. return res;
  37802. };
  37803. function JPoint(curve, x, y, z) {
  37804. Base.BasePoint.call(this, curve, 'jacobian');
  37805. if (x === null && y === null && z === null) {
  37806. this.x = this.curve.one;
  37807. this.y = this.curve.one;
  37808. this.z = new BN(0);
  37809. } else {
  37810. this.x = new BN(x, 16);
  37811. this.y = new BN(y, 16);
  37812. this.z = new BN(z, 16);
  37813. }
  37814. if (!this.x.red) this.x = this.x.toRed(this.curve.red);
  37815. if (!this.y.red) this.y = this.y.toRed(this.curve.red);
  37816. if (!this.z.red) this.z = this.z.toRed(this.curve.red);
  37817. this.zOne = this.z === this.curve.one;
  37818. }
  37819. inherits(JPoint, Base.BasePoint);
  37820. ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
  37821. return new JPoint(this, x, y, z);
  37822. };
  37823. JPoint.prototype.toP = function toP() {
  37824. if (this.isInfinity()) return this.curve.point(null, null);
  37825. var zinv = this.z.redInvm();
  37826. var zinv2 = zinv.redSqr();
  37827. var ax = this.x.redMul(zinv2);
  37828. var ay = this.y.redMul(zinv2).redMul(zinv);
  37829. return this.curve.point(ax, ay);
  37830. };
  37831. JPoint.prototype.neg = function neg() {
  37832. return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
  37833. };
  37834. JPoint.prototype.add = function add(p) {
  37835. // O + P = P
  37836. if (this.isInfinity()) return p; // P + O = P
  37837. if (p.isInfinity()) return this; // 12M + 4S + 7A
  37838. var pz2 = p.z.redSqr();
  37839. var z2 = this.z.redSqr();
  37840. var u1 = this.x.redMul(pz2);
  37841. var u2 = p.x.redMul(z2);
  37842. var s1 = this.y.redMul(pz2.redMul(p.z));
  37843. var s2 = p.y.redMul(z2.redMul(this.z));
  37844. var h = u1.redSub(u2);
  37845. var r = s1.redSub(s2);
  37846. if (h.cmpn(0) === 0) {
  37847. if (r.cmpn(0) !== 0) return this.curve.jpoint(null, null, null); else return this.dbl();
  37848. }
  37849. var h2 = h.redSqr();
  37850. var h3 = h2.redMul(h);
  37851. var v = u1.redMul(h2);
  37852. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  37853. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  37854. var nz = this.z.redMul(p.z).redMul(h);
  37855. return this.curve.jpoint(nx, ny, nz);
  37856. };
  37857. JPoint.prototype.mixedAdd = function mixedAdd(p) {
  37858. // O + P = P
  37859. if (this.isInfinity()) return p.toJ(); // P + O = P
  37860. if (p.isInfinity()) return this; // 8M + 3S + 7A
  37861. var z2 = this.z.redSqr();
  37862. var u1 = this.x;
  37863. var u2 = p.x.redMul(z2);
  37864. var s1 = this.y;
  37865. var s2 = p.y.redMul(z2).redMul(this.z);
  37866. var h = u1.redSub(u2);
  37867. var r = s1.redSub(s2);
  37868. if (h.cmpn(0) === 0) {
  37869. if (r.cmpn(0) !== 0) return this.curve.jpoint(null, null, null); else return this.dbl();
  37870. }
  37871. var h2 = h.redSqr();
  37872. var h3 = h2.redMul(h);
  37873. var v = u1.redMul(h2);
  37874. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  37875. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  37876. var nz = this.z.redMul(h);
  37877. return this.curve.jpoint(nx, ny, nz);
  37878. };
  37879. JPoint.prototype.dblp = function dblp(pow) {
  37880. if (pow === 0) return this;
  37881. if (this.isInfinity()) return this;
  37882. if (!pow) return this.dbl();
  37883. if (this.curve.zeroA || this.curve.threeA) {
  37884. var r = this;
  37885. for (var i = 0; i < pow; i++) {
  37886. r = r.dbl();
  37887. }
  37888. return r;
  37889. } // 1M + 2S + 1A + N * (4S + 5M + 8A)
  37890. // N = 1 => 6M + 6S + 9A
  37891. var a = this.curve.a;
  37892. var tinv = this.curve.tinv;
  37893. var jx = this.x;
  37894. var jy = this.y;
  37895. var jz = this.z;
  37896. var jz4 = jz.redSqr().redSqr(); // Reuse results
  37897. var jyd = jy.redAdd(jy);
  37898. for (var i = 0; i < pow; i++) {
  37899. var jx2 = jx.redSqr();
  37900. var jyd2 = jyd.redSqr();
  37901. var jyd4 = jyd2.redSqr();
  37902. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  37903. var t1 = jx.redMul(jyd2);
  37904. var nx = c.redSqr().redISub(t1.redAdd(t1));
  37905. var t2 = t1.redISub(nx);
  37906. var dny = c.redMul(t2);
  37907. dny = dny.redIAdd(dny).redISub(jyd4);
  37908. var nz = jyd.redMul(jz);
  37909. if (i + 1 < pow) jz4 = jz4.redMul(jyd4);
  37910. jx = nx;
  37911. jz = nz;
  37912. jyd = dny;
  37913. }
  37914. return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
  37915. };
  37916. JPoint.prototype.dbl = function dbl() {
  37917. if (this.isInfinity()) return this;
  37918. if (this.curve.zeroA) return this._zeroDbl(); else if (this.curve.threeA) return this._threeDbl(); else return this._dbl();
  37919. };
  37920. JPoint.prototype._zeroDbl = function _zeroDbl() {
  37921. var nx;
  37922. var ny;
  37923. var nz; // Z = 1
  37924. if (this.zOne) {
  37925. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  37926. // #doubling-mdbl-2007-bl
  37927. // 1M + 5S + 14A
  37928. // XX = X1^2
  37929. var xx = this.x.redSqr(); // YY = Y1^2
  37930. var yy = this.y.redSqr(); // YYYY = YY^2
  37931. var yyyy = yy.redSqr(); // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  37932. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  37933. s = s.redIAdd(s); // M = 3 * XX + a; a = 0
  37934. var m = xx.redAdd(xx).redIAdd(xx); // T = M ^ 2 - 2*S
  37935. var t = m.redSqr().redISub(s).redISub(s); // 8 * YYYY
  37936. var yyyy8 = yyyy.redIAdd(yyyy);
  37937. yyyy8 = yyyy8.redIAdd(yyyy8);
  37938. yyyy8 = yyyy8.redIAdd(yyyy8); // X3 = T
  37939. nx = t; // Y3 = M * (S - T) - 8 * YYYY
  37940. ny = m.redMul(s.redISub(t)).redISub(yyyy8); // Z3 = 2*Y1
  37941. nz = this.y.redAdd(this.y);
  37942. } else {
  37943. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  37944. // #doubling-dbl-2009-l
  37945. // 2M + 5S + 13A
  37946. // A = X1^2
  37947. var a = this.x.redSqr(); // B = Y1^2
  37948. var b = this.y.redSqr(); // C = B^2
  37949. var c = b.redSqr(); // D = 2 * ((X1 + B)^2 - A - C)
  37950. var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
  37951. d = d.redIAdd(d); // E = 3 * A
  37952. var e = a.redAdd(a).redIAdd(a); // F = E^2
  37953. var f = e.redSqr(); // 8 * C
  37954. var c8 = c.redIAdd(c);
  37955. c8 = c8.redIAdd(c8);
  37956. c8 = c8.redIAdd(c8); // X3 = F - 2 * D
  37957. nx = f.redISub(d).redISub(d); // Y3 = E * (D - X3) - 8 * C
  37958. ny = e.redMul(d.redISub(nx)).redISub(c8); // Z3 = 2 * Y1 * Z1
  37959. nz = this.y.redMul(this.z);
  37960. nz = nz.redIAdd(nz);
  37961. }
  37962. return this.curve.jpoint(nx, ny, nz);
  37963. };
  37964. JPoint.prototype._threeDbl = function _threeDbl() {
  37965. var nx;
  37966. var ny;
  37967. var nz; // Z = 1
  37968. if (this.zOne) {
  37969. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
  37970. // #doubling-mdbl-2007-bl
  37971. // 1M + 5S + 15A
  37972. // XX = X1^2
  37973. var xx = this.x.redSqr(); // YY = Y1^2
  37974. var yy = this.y.redSqr(); // YYYY = YY^2
  37975. var yyyy = yy.redSqr(); // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  37976. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  37977. s = s.redIAdd(s); // M = 3 * XX + a
  37978. var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); // T = M^2 - 2 * S
  37979. var t = m.redSqr().redISub(s).redISub(s); // X3 = T
  37980. nx = t; // Y3 = M * (S - T) - 8 * YYYY
  37981. var yyyy8 = yyyy.redIAdd(yyyy);
  37982. yyyy8 = yyyy8.redIAdd(yyyy8);
  37983. yyyy8 = yyyy8.redIAdd(yyyy8);
  37984. ny = m.redMul(s.redISub(t)).redISub(yyyy8); // Z3 = 2 * Y1
  37985. nz = this.y.redAdd(this.y);
  37986. } else {
  37987. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
  37988. // 3M + 5S
  37989. // delta = Z1^2
  37990. var delta = this.z.redSqr(); // gamma = Y1^2
  37991. var gamma = this.y.redSqr(); // beta = X1 * gamma
  37992. var beta = this.x.redMul(gamma); // alpha = 3 * (X1 - delta) * (X1 + delta)
  37993. var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
  37994. alpha = alpha.redAdd(alpha).redIAdd(alpha); // X3 = alpha^2 - 8 * beta
  37995. var beta4 = beta.redIAdd(beta);
  37996. beta4 = beta4.redIAdd(beta4);
  37997. var beta8 = beta4.redAdd(beta4);
  37998. nx = alpha.redSqr().redISub(beta8); // Z3 = (Y1 + Z1)^2 - gamma - delta
  37999. nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
  38000. var ggamma8 = gamma.redSqr();
  38001. ggamma8 = ggamma8.redIAdd(ggamma8);
  38002. ggamma8 = ggamma8.redIAdd(ggamma8);
  38003. ggamma8 = ggamma8.redIAdd(ggamma8);
  38004. ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
  38005. }
  38006. return this.curve.jpoint(nx, ny, nz);
  38007. };
  38008. JPoint.prototype._dbl = function _dbl() {
  38009. var a = this.curve.a; // 4M + 6S + 10A
  38010. var jx = this.x;
  38011. var jy = this.y;
  38012. var jz = this.z;
  38013. var jz4 = jz.redSqr().redSqr();
  38014. var jx2 = jx.redSqr();
  38015. var jy2 = jy.redSqr();
  38016. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  38017. var jxd4 = jx.redAdd(jx);
  38018. jxd4 = jxd4.redIAdd(jxd4);
  38019. var t1 = jxd4.redMul(jy2);
  38020. var nx = c.redSqr().redISub(t1.redAdd(t1));
  38021. var t2 = t1.redISub(nx);
  38022. var jyd8 = jy2.redSqr();
  38023. jyd8 = jyd8.redIAdd(jyd8);
  38024. jyd8 = jyd8.redIAdd(jyd8);
  38025. jyd8 = jyd8.redIAdd(jyd8);
  38026. var ny = c.redMul(t2).redISub(jyd8);
  38027. var nz = jy.redAdd(jy).redMul(jz);
  38028. return this.curve.jpoint(nx, ny, nz);
  38029. };
  38030. JPoint.prototype.trpl = function trpl() {
  38031. if (!this.curve.zeroA) return this.dbl().add(this); // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
  38032. // 5M + 10S + ...
  38033. // XX = X1^2
  38034. var xx = this.x.redSqr(); // YY = Y1^2
  38035. var yy = this.y.redSqr(); // ZZ = Z1^2
  38036. var zz = this.z.redSqr(); // YYYY = YY^2
  38037. var yyyy = yy.redSqr(); // M = 3 * XX + a * ZZ2; a = 0
  38038. var m = xx.redAdd(xx).redIAdd(xx); // MM = M^2
  38039. var mm = m.redSqr(); // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
  38040. var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  38041. e = e.redIAdd(e);
  38042. e = e.redAdd(e).redIAdd(e);
  38043. e = e.redISub(mm); // EE = E^2
  38044. var ee = e.redSqr(); // T = 16*YYYY
  38045. var t = yyyy.redIAdd(yyyy);
  38046. t = t.redIAdd(t);
  38047. t = t.redIAdd(t);
  38048. t = t.redIAdd(t); // U = (M + E)^2 - MM - EE - T
  38049. var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); // X3 = 4 * (X1 * EE - 4 * YY * U)
  38050. var yyu4 = yy.redMul(u);
  38051. yyu4 = yyu4.redIAdd(yyu4);
  38052. yyu4 = yyu4.redIAdd(yyu4);
  38053. var nx = this.x.redMul(ee).redISub(yyu4);
  38054. nx = nx.redIAdd(nx);
  38055. nx = nx.redIAdd(nx); // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
  38056. var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
  38057. ny = ny.redIAdd(ny);
  38058. ny = ny.redIAdd(ny);
  38059. ny = ny.redIAdd(ny); // Z3 = (Z1 + E)^2 - ZZ - EE
  38060. var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
  38061. return this.curve.jpoint(nx, ny, nz);
  38062. };
  38063. JPoint.prototype.mul = function mul(k, kbase) {
  38064. k = new BN(k, kbase);
  38065. return this.curve._wnafMul(this, k);
  38066. };
  38067. JPoint.prototype.eq = function eq(p) {
  38068. if (p.type === 'affine') return this.eq(p.toJ());
  38069. if (this === p) return true; // x1 * z2^2 == x2 * z1^2
  38070. var z2 = this.z.redSqr();
  38071. var pz2 = p.z.redSqr();
  38072. if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) return false; // y1 * z2^3 == y2 * z1^3
  38073. var z3 = z2.redMul(this.z);
  38074. var pz3 = pz2.redMul(p.z);
  38075. return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
  38076. };
  38077. JPoint.prototype.eqXToP = function eqXToP(x) {
  38078. var zs = this.z.redSqr();
  38079. var rx = x.toRed(this.curve.red).redMul(zs);
  38080. if (this.x.cmp(rx) === 0) return true;
  38081. var xc = x.clone();
  38082. var t = this.curve.redN.redMul(zs);
  38083. for (; ;) {
  38084. xc.iadd(this.curve.n);
  38085. if (xc.cmp(this.curve.p) >= 0) return false;
  38086. rx.redIAdd(t);
  38087. if (this.x.cmp(rx) === 0) return true;
  38088. }
  38089. };
  38090. JPoint.prototype.inspect = function inspect() {
  38091. if (this.isInfinity()) return '<EC JPoint Infinity>';
  38092. return '<EC JPoint x: ' + this.x.toString(16, 2) + ' y: ' + this.y.toString(16, 2) + ' z: ' + this.z.toString(16, 2) + '>';
  38093. };
  38094. JPoint.prototype.isInfinity = function isInfinity() {
  38095. // XXX This code assumes that zero is always zero in red
  38096. return this.z.cmpn(0) === 0;
  38097. };
  38098. }, { "../utils": 364, "./base": 351, "bn.js": 365, "inherits": 387 }], 356: [function (require, module, exports) {
  38099. 'use strict';
  38100. var curves = exports;
  38101. var hash = require('hash.js');
  38102. var curve = require('./curve');
  38103. var utils = require('./utils');
  38104. var assert = utils.assert;
  38105. function PresetCurve(options) {
  38106. if (options.type === 'short') this.curve = new curve.short(options); else if (options.type === 'edwards') this.curve = new curve.edwards(options); else this.curve = new curve.mont(options);
  38107. this.g = this.curve.g;
  38108. this.n = this.curve.n;
  38109. this.hash = options.hash;
  38110. assert(this.g.validate(), 'Invalid curve');
  38111. assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
  38112. }
  38113. curves.PresetCurve = PresetCurve;
  38114. function defineCurve(name, options) {
  38115. Object.defineProperty(curves, name, {
  38116. configurable: true,
  38117. enumerable: true,
  38118. get: function get() {
  38119. var curve = new PresetCurve(options);
  38120. Object.defineProperty(curves, name, {
  38121. configurable: true,
  38122. enumerable: true,
  38123. value: curve
  38124. });
  38125. return curve;
  38126. }
  38127. });
  38128. }
  38129. defineCurve('p192', {
  38130. type: 'short',
  38131. prime: 'p192',
  38132. p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
  38133. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
  38134. b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
  38135. n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
  38136. hash: hash.sha256,
  38137. gRed: false,
  38138. g: ['188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811']
  38139. });
  38140. defineCurve('p224', {
  38141. type: 'short',
  38142. prime: 'p224',
  38143. p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
  38144. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
  38145. b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
  38146. n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
  38147. hash: hash.sha256,
  38148. gRed: false,
  38149. g: ['b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34']
  38150. });
  38151. defineCurve('p256', {
  38152. type: 'short',
  38153. prime: null,
  38154. p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
  38155. a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
  38156. b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
  38157. n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
  38158. hash: hash.sha256,
  38159. gRed: false,
  38160. g: ['6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5']
  38161. });
  38162. defineCurve('p384', {
  38163. type: 'short',
  38164. prime: null,
  38165. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'fffffffe ffffffff 00000000 00000000 ffffffff',
  38166. a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'fffffffe ffffffff 00000000 00000000 fffffffc',
  38167. b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
  38168. n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
  38169. hash: hash.sha384,
  38170. gRed: false,
  38171. g: ['aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + '5502f25d bf55296c 3a545e38 72760ab7', '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f']
  38172. });
  38173. defineCurve('p521', {
  38174. type: 'short',
  38175. prime: null,
  38176. p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff ffffffff ffffffff ffffffff',
  38177. a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff ffffffff ffffffff fffffffc',
  38178. b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
  38179. n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
  38180. hash: hash.sha512,
  38181. gRed: false,
  38182. g: ['000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + '3fad0761 353c7086 a272c240 88be9476 9fd16650']
  38183. });
  38184. defineCurve('curve25519', {
  38185. type: 'mont',
  38186. prime: 'p25519',
  38187. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  38188. a: '76d06',
  38189. b: '1',
  38190. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  38191. hash: hash.sha256,
  38192. gRed: false,
  38193. g: ['9']
  38194. });
  38195. defineCurve('ed25519', {
  38196. type: 'edwards',
  38197. prime: 'p25519',
  38198. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  38199. a: '-1',
  38200. c: '1',
  38201. // -121665 * (121666^(-1)) (mod P)
  38202. d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
  38203. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  38204. hash: hash.sha256,
  38205. gRed: false,
  38206. g: ['216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', // 4/5
  38207. '6666666666666666666666666666666666666666666666666666666666666658']
  38208. });
  38209. var pre;
  38210. try {
  38211. pre = require('./precomputed/secp256k1');
  38212. } catch (e) {
  38213. pre = undefined;
  38214. }
  38215. defineCurve('secp256k1', {
  38216. type: 'short',
  38217. prime: 'k256',
  38218. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
  38219. a: '0',
  38220. b: '7',
  38221. n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
  38222. h: '1',
  38223. hash: hash.sha256,
  38224. // Precomputed endomorphism
  38225. beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
  38226. lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
  38227. basis: [{
  38228. a: '3086d221a7d46bcde86c90e49284eb15',
  38229. b: '-e4437ed6010e88286f547fa90abfe4c3'
  38230. }, {
  38231. a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
  38232. b: '3086d221a7d46bcde86c90e49284eb15'
  38233. }],
  38234. gRed: false,
  38235. g: ['79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', pre]
  38236. });
  38237. }, { "./curve": 353, "./precomputed/secp256k1": 363, "./utils": 364, "hash.js": 372 }], 357: [function (require, module, exports) {
  38238. 'use strict';
  38239. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38240. var BN = require('bn.js');
  38241. var HmacDRBG = require('hmac-drbg');
  38242. var utils = require('../utils');
  38243. var curves = require('../curves');
  38244. var rand = require('brorand');
  38245. var assert = utils.assert;
  38246. var KeyPair = require('./key');
  38247. var Signature = require('./signature');
  38248. function EC(options) {
  38249. if (!(this instanceof EC)) return new EC(options); // Shortcut `elliptic.ec(curve-name)`
  38250. if (typeof options === 'string') {
  38251. assert(curves.hasOwnProperty(options), 'Unknown curve ' + options);
  38252. options = curves[options];
  38253. } // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
  38254. if (options instanceof curves.PresetCurve) options = {
  38255. curve: options
  38256. };
  38257. this.curve = options.curve.curve;
  38258. this.n = this.curve.n;
  38259. this.nh = this.n.ushrn(1);
  38260. this.g = this.curve.g; // Point on curve
  38261. this.g = options.curve.g;
  38262. this.g.precompute(options.curve.n.bitLength() + 1); // Hash for function for DRBG
  38263. this.hash = options.hash || options.curve.hash;
  38264. }
  38265. module.exports = EC;
  38266. EC.prototype.keyPair = function keyPair(options) {
  38267. return new KeyPair(this, options);
  38268. };
  38269. EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
  38270. return KeyPair.fromPrivate(this, priv, enc);
  38271. };
  38272. EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
  38273. return KeyPair.fromPublic(this, pub, enc);
  38274. };
  38275. EC.prototype.genKeyPair = function genKeyPair(options) {
  38276. if (!options) options = {}; // Instantiate Hmac_DRBG
  38277. var drbg = new HmacDRBG({
  38278. hash: this.hash,
  38279. pers: options.pers,
  38280. persEnc: options.persEnc || 'utf8',
  38281. entropy: options.entropy || rand(this.hash.hmacStrength),
  38282. entropyEnc: options.entropy && options.entropyEnc || 'utf8',
  38283. nonce: this.n.toArray()
  38284. });
  38285. var bytes = this.n.byteLength();
  38286. var ns2 = this.n.sub(new BN(2));
  38287. do {
  38288. var priv = new BN(drbg.generate(bytes));
  38289. if (priv.cmp(ns2) > 0) continue;
  38290. priv.iaddn(1);
  38291. return this.keyFromPrivate(priv);
  38292. } while (true);
  38293. };
  38294. EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
  38295. var delta = msg.byteLength() * 8 - this.n.bitLength();
  38296. if (delta > 0) msg = msg.ushrn(delta);
  38297. if (!truncOnly && msg.cmp(this.n) >= 0) return msg.sub(this.n); else return msg;
  38298. };
  38299. EC.prototype.sign = function sign(msg, key, enc, options) {
  38300. if (_typeof(enc) === 'object') {
  38301. options = enc;
  38302. enc = null;
  38303. }
  38304. if (!options) options = {};
  38305. key = this.keyFromPrivate(key, enc);
  38306. msg = this._truncateToN(new BN(msg, 16)); // Zero-extend key to provide enough entropy
  38307. var bytes = this.n.byteLength();
  38308. var bkey = key.getPrivate().toArray('be', bytes); // Zero-extend nonce to have the same byte size as N
  38309. var nonce = msg.toArray('be', bytes); // Instantiate Hmac_DRBG
  38310. var drbg = new HmacDRBG({
  38311. hash: this.hash,
  38312. entropy: bkey,
  38313. nonce: nonce,
  38314. pers: options.pers,
  38315. persEnc: options.persEnc || 'utf8'
  38316. }); // Number of bytes to generate
  38317. var ns1 = this.n.sub(new BN(1));
  38318. for (var iter = 0; true; iter++) {
  38319. var k = options.k ? options.k(iter) : new BN(drbg.generate(this.n.byteLength()));
  38320. k = this._truncateToN(k, true);
  38321. if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) continue;
  38322. var kp = this.g.mul(k);
  38323. if (kp.isInfinity()) continue;
  38324. var kpX = kp.getX();
  38325. var r = kpX.umod(this.n);
  38326. if (r.cmpn(0) === 0) continue;
  38327. var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
  38328. s = s.umod(this.n);
  38329. if (s.cmpn(0) === 0) continue;
  38330. var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | (kpX.cmp(r) !== 0 ? 2 : 0); // Use complement of `s`, if it is > `n / 2`
  38331. if (options.canonical && s.cmp(this.nh) > 0) {
  38332. s = this.n.sub(s);
  38333. recoveryParam ^= 1;
  38334. }
  38335. return new Signature({
  38336. r: r,
  38337. s: s,
  38338. recoveryParam: recoveryParam
  38339. });
  38340. }
  38341. };
  38342. EC.prototype.verify = function verify(msg, signature, key, enc) {
  38343. msg = this._truncateToN(new BN(msg, 16));
  38344. key = this.keyFromPublic(key, enc);
  38345. signature = new Signature(signature, 'hex'); // Perform primitive values validation
  38346. var r = signature.r;
  38347. var s = signature.s;
  38348. if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) return false;
  38349. if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) return false; // Validate signature
  38350. var sinv = s.invm(this.n);
  38351. var u1 = sinv.mul(msg).umod(this.n);
  38352. var u2 = sinv.mul(r).umod(this.n);
  38353. if (!this.curve._maxwellTrick) {
  38354. var p = this.g.mulAdd(u1, key.getPublic(), u2);
  38355. if (p.isInfinity()) return false;
  38356. return p.getX().umod(this.n).cmp(r) === 0;
  38357. } // NOTE: Greg Maxwell's trick, inspired by:
  38358. // https://git.io/vad3K
  38359. var p = this.g.jmulAdd(u1, key.getPublic(), u2);
  38360. if (p.isInfinity()) return false; // Compare `p.x` of Jacobian point with `r`,
  38361. // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
  38362. // inverse of `p.z^2`
  38363. return p.eqXToP(r);
  38364. };
  38365. EC.prototype.recoverPubKey = function (msg, signature, j, enc) {
  38366. assert((3 & j) === j, 'The recovery param is more than two bits');
  38367. signature = new Signature(signature, enc);
  38368. var n = this.n;
  38369. var e = new BN(msg);
  38370. var r = signature.r;
  38371. var s = signature.s; // A set LSB signifies that the y-coordinate is odd
  38372. var isYOdd = j & 1;
  38373. var isSecondKey = j >> 1;
  38374. if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) throw new Error('Unable to find sencond key candinate'); // 1.1. Let x = r + jn.
  38375. if (isSecondKey) r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); else r = this.curve.pointFromX(r, isYOdd);
  38376. var rInv = signature.r.invm(n);
  38377. var s1 = n.sub(e).mul(rInv).umod(n);
  38378. var s2 = s.mul(rInv).umod(n); // 1.6.1 Compute Q = r^-1 (sR - eG)
  38379. // Q = r^-1 (sR + -eG)
  38380. return this.g.mulAdd(s1, r, s2);
  38381. };
  38382. EC.prototype.getKeyRecoveryParam = function (e, signature, Q, enc) {
  38383. signature = new Signature(signature, enc);
  38384. if (signature.recoveryParam !== null) return signature.recoveryParam;
  38385. for (var i = 0; i < 4; i++) {
  38386. var Qprime;
  38387. try {
  38388. Qprime = this.recoverPubKey(e, signature, i);
  38389. } catch (e) {
  38390. continue;
  38391. }
  38392. if (Qprime.eq(Q)) return i;
  38393. }
  38394. throw new Error('Unable to find valid recovery factor');
  38395. };
  38396. }, { "../curves": 356, "../utils": 364, "./key": 358, "./signature": 359, "bn.js": 365, "brorand": 184, "hmac-drbg": 384 }], 358: [function (require, module, exports) {
  38397. 'use strict';
  38398. var BN = require('bn.js');
  38399. var utils = require('../utils');
  38400. var assert = utils.assert;
  38401. function KeyPair(ec, options) {
  38402. this.ec = ec;
  38403. this.priv = null;
  38404. this.pub = null; // KeyPair(ec, { priv: ..., pub: ... })
  38405. if (options.priv) this._importPrivate(options.priv, options.privEnc);
  38406. if (options.pub) this._importPublic(options.pub, options.pubEnc);
  38407. }
  38408. module.exports = KeyPair;
  38409. KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
  38410. if (pub instanceof KeyPair) return pub;
  38411. return new KeyPair(ec, {
  38412. pub: pub,
  38413. pubEnc: enc
  38414. });
  38415. };
  38416. KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
  38417. if (priv instanceof KeyPair) return priv;
  38418. return new KeyPair(ec, {
  38419. priv: priv,
  38420. privEnc: enc
  38421. });
  38422. };
  38423. KeyPair.prototype.validate = function validate() {
  38424. var pub = this.getPublic();
  38425. if (pub.isInfinity()) return {
  38426. result: false,
  38427. reason: 'Invalid public key'
  38428. };
  38429. if (!pub.validate()) return {
  38430. result: false,
  38431. reason: 'Public key is not a point'
  38432. };
  38433. if (!pub.mul(this.ec.curve.n).isInfinity()) return {
  38434. result: false,
  38435. reason: 'Public key * N != O'
  38436. };
  38437. return {
  38438. result: true,
  38439. reason: null
  38440. };
  38441. };
  38442. KeyPair.prototype.getPublic = function getPublic(compact, enc) {
  38443. // compact is optional argument
  38444. if (typeof compact === 'string') {
  38445. enc = compact;
  38446. compact = null;
  38447. }
  38448. if (!this.pub) this.pub = this.ec.g.mul(this.priv);
  38449. if (!enc) return this.pub;
  38450. return this.pub.encode(enc, compact);
  38451. };
  38452. KeyPair.prototype.getPrivate = function getPrivate(enc) {
  38453. if (enc === 'hex') return this.priv.toString(16, 2); else return this.priv;
  38454. };
  38455. KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
  38456. this.priv = new BN(key, enc || 16); // Ensure that the priv won't be bigger than n, otherwise we may fail
  38457. // in fixed multiplication method
  38458. this.priv = this.priv.umod(this.ec.curve.n);
  38459. };
  38460. KeyPair.prototype._importPublic = function _importPublic(key, enc) {
  38461. if (key.x || key.y) {
  38462. // Montgomery points only have an `x` coordinate.
  38463. // Weierstrass/Edwards points on the other hand have both `x` and
  38464. // `y` coordinates.
  38465. if (this.ec.curve.type === 'mont') {
  38466. assert(key.x, 'Need x coordinate');
  38467. } else if (this.ec.curve.type === 'short' || this.ec.curve.type === 'edwards') {
  38468. assert(key.x && key.y, 'Need both x and y coordinate');
  38469. }
  38470. this.pub = this.ec.curve.point(key.x, key.y);
  38471. return;
  38472. }
  38473. this.pub = this.ec.curve.decodePoint(key, enc);
  38474. }; // ECDH
  38475. KeyPair.prototype.derive = function derive(pub) {
  38476. return pub.mul(this.priv).getX();
  38477. }; // ECDSA
  38478. KeyPair.prototype.sign = function sign(msg, enc, options) {
  38479. return this.ec.sign(msg, this, enc, options);
  38480. };
  38481. KeyPair.prototype.verify = function verify(msg, signature) {
  38482. return this.ec.verify(msg, signature, this);
  38483. };
  38484. KeyPair.prototype.inspect = function inspect() {
  38485. return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) + ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
  38486. };
  38487. }, { "../utils": 364, "bn.js": 365 }], 359: [function (require, module, exports) {
  38488. 'use strict';
  38489. var BN = require('bn.js');
  38490. var utils = require('../utils');
  38491. var assert = utils.assert;
  38492. function Signature(options, enc) {
  38493. if (options instanceof Signature) return options;
  38494. if (this._importDER(options, enc)) return;
  38495. assert(options.r && options.s, 'Signature without r or s');
  38496. this.r = new BN(options.r, 16);
  38497. this.s = new BN(options.s, 16);
  38498. if (options.recoveryParam === undefined) this.recoveryParam = null; else this.recoveryParam = options.recoveryParam;
  38499. }
  38500. module.exports = Signature;
  38501. function Position() {
  38502. this.place = 0;
  38503. }
  38504. function getLength(buf, p) {
  38505. var initial = buf[p.place++];
  38506. if (!(initial & 0x80)) {
  38507. return initial;
  38508. }
  38509. var octetLen = initial & 0xf; // Indefinite length or overflow
  38510. if (octetLen === 0 || octetLen > 4) {
  38511. return false;
  38512. }
  38513. var val = 0;
  38514. for (var i = 0, off = p.place; i < octetLen; i++, off++) {
  38515. val <<= 8;
  38516. val |= buf[off];
  38517. val >>>= 0;
  38518. } // Leading zeroes
  38519. if (val <= 0x7f) {
  38520. return false;
  38521. }
  38522. p.place = off;
  38523. return val;
  38524. }
  38525. function rmPadding(buf) {
  38526. var i = 0;
  38527. var len = buf.length - 1;
  38528. while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
  38529. i++;
  38530. }
  38531. if (i === 0) {
  38532. return buf;
  38533. }
  38534. return buf.slice(i);
  38535. }
  38536. Signature.prototype._importDER = function _importDER(data, enc) {
  38537. data = utils.toArray(data, enc);
  38538. var p = new Position();
  38539. if (data[p.place++] !== 0x30) {
  38540. return false;
  38541. }
  38542. var len = getLength(data, p);
  38543. if (len === false) {
  38544. return false;
  38545. }
  38546. if (len + p.place !== data.length) {
  38547. return false;
  38548. }
  38549. if (data[p.place++] !== 0x02) {
  38550. return false;
  38551. }
  38552. var rlen = getLength(data, p);
  38553. if (rlen === false) {
  38554. return false;
  38555. }
  38556. var r = data.slice(p.place, rlen + p.place);
  38557. p.place += rlen;
  38558. if (data[p.place++] !== 0x02) {
  38559. return false;
  38560. }
  38561. var slen = getLength(data, p);
  38562. if (slen === false) {
  38563. return false;
  38564. }
  38565. if (data.length !== slen + p.place) {
  38566. return false;
  38567. }
  38568. var s = data.slice(p.place, slen + p.place);
  38569. if (r[0] === 0) {
  38570. if (r[1] & 0x80) {
  38571. r = r.slice(1);
  38572. } else {
  38573. // Leading zeroes
  38574. return false;
  38575. }
  38576. }
  38577. if (s[0] === 0) {
  38578. if (s[1] & 0x80) {
  38579. s = s.slice(1);
  38580. } else {
  38581. // Leading zeroes
  38582. return false;
  38583. }
  38584. }
  38585. this.r = new BN(r);
  38586. this.s = new BN(s);
  38587. this.recoveryParam = null;
  38588. return true;
  38589. };
  38590. function constructLength(arr, len) {
  38591. if (len < 0x80) {
  38592. arr.push(len);
  38593. return;
  38594. }
  38595. var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
  38596. arr.push(octets | 0x80);
  38597. while (--octets) {
  38598. arr.push(len >>> (octets << 3) & 0xff);
  38599. }
  38600. arr.push(len);
  38601. }
  38602. Signature.prototype.toDER = function toDER(enc) {
  38603. var r = this.r.toArray();
  38604. var s = this.s.toArray(); // Pad values
  38605. if (r[0] & 0x80) r = [0].concat(r); // Pad values
  38606. if (s[0] & 0x80) s = [0].concat(s);
  38607. r = rmPadding(r);
  38608. s = rmPadding(s);
  38609. while (!s[0] && !(s[1] & 0x80)) {
  38610. s = s.slice(1);
  38611. }
  38612. var arr = [0x02];
  38613. constructLength(arr, r.length);
  38614. arr = arr.concat(r);
  38615. arr.push(0x02);
  38616. constructLength(arr, s.length);
  38617. var backHalf = arr.concat(s);
  38618. var res = [0x30];
  38619. constructLength(res, backHalf.length);
  38620. res = res.concat(backHalf);
  38621. return utils.encode(res, enc);
  38622. };
  38623. }, { "../utils": 364, "bn.js": 365 }], 360: [function (require, module, exports) {
  38624. 'use strict';
  38625. var hash = require('hash.js');
  38626. var curves = require('../curves');
  38627. var utils = require('../utils');
  38628. var assert = utils.assert;
  38629. var parseBytes = utils.parseBytes;
  38630. var KeyPair = require('./key');
  38631. var Signature = require('./signature');
  38632. function EDDSA(curve) {
  38633. assert(curve === 'ed25519', 'only tested with ed25519 so far');
  38634. if (!(this instanceof EDDSA)) return new EDDSA(curve);
  38635. var curve = curves[curve].curve;
  38636. this.curve = curve;
  38637. this.g = curve.g;
  38638. this.g.precompute(curve.n.bitLength() + 1);
  38639. this.pointClass = curve.point().constructor;
  38640. this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
  38641. this.hash = hash.sha512;
  38642. }
  38643. module.exports = EDDSA;
  38644. /**
  38645. * @param {Array|String} message - message bytes
  38646. * @param {Array|String|KeyPair} secret - secret bytes or a keypair
  38647. * @returns {Signature} - signature
  38648. */
  38649. EDDSA.prototype.sign = function sign(message, secret) {
  38650. message = parseBytes(message);
  38651. var key = this.keyFromSecret(secret);
  38652. var r = this.hashInt(key.messagePrefix(), message);
  38653. var R = this.g.mul(r);
  38654. var Rencoded = this.encodePoint(R);
  38655. var s_ = this.hashInt(Rencoded, key.pubBytes(), message).mul(key.priv());
  38656. var S = r.add(s_).umod(this.curve.n);
  38657. return this.makeSignature({
  38658. R: R,
  38659. S: S,
  38660. Rencoded: Rencoded
  38661. });
  38662. };
  38663. /**
  38664. * @param {Array} message - message bytes
  38665. * @param {Array|String|Signature} sig - sig bytes
  38666. * @param {Array|String|Point|KeyPair} pub - public key
  38667. * @returns {Boolean} - true if public key matches sig of message
  38668. */
  38669. EDDSA.prototype.verify = function verify(message, sig, pub) {
  38670. message = parseBytes(message);
  38671. sig = this.makeSignature(sig);
  38672. var key = this.keyFromPublic(pub);
  38673. var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
  38674. var SG = this.g.mul(sig.S());
  38675. var RplusAh = sig.R().add(key.pub().mul(h));
  38676. return RplusAh.eq(SG);
  38677. };
  38678. EDDSA.prototype.hashInt = function hashInt() {
  38679. var hash = this.hash();
  38680. for (var i = 0; i < arguments.length; i++) {
  38681. hash.update(arguments[i]);
  38682. }
  38683. return utils.intFromLE(hash.digest()).umod(this.curve.n);
  38684. };
  38685. EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
  38686. return KeyPair.fromPublic(this, pub);
  38687. };
  38688. EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
  38689. return KeyPair.fromSecret(this, secret);
  38690. };
  38691. EDDSA.prototype.makeSignature = function makeSignature(sig) {
  38692. if (sig instanceof Signature) return sig;
  38693. return new Signature(this, sig);
  38694. };
  38695. /**
  38696. * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
  38697. *
  38698. * EDDSA defines methods for encoding and decoding points and integers. These are
  38699. * helper convenience methods, that pass along to utility functions implied
  38700. * parameters.
  38701. *
  38702. */
  38703. EDDSA.prototype.encodePoint = function encodePoint(point) {
  38704. var enc = point.getY().toArray('le', this.encodingLength);
  38705. enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
  38706. return enc;
  38707. };
  38708. EDDSA.prototype.decodePoint = function decodePoint(bytes) {
  38709. bytes = utils.parseBytes(bytes);
  38710. var lastIx = bytes.length - 1;
  38711. var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
  38712. var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
  38713. var y = utils.intFromLE(normed);
  38714. return this.curve.pointFromY(y, xIsOdd);
  38715. };
  38716. EDDSA.prototype.encodeInt = function encodeInt(num) {
  38717. return num.toArray('le', this.encodingLength);
  38718. };
  38719. EDDSA.prototype.decodeInt = function decodeInt(bytes) {
  38720. return utils.intFromLE(bytes);
  38721. };
  38722. EDDSA.prototype.isPoint = function isPoint(val) {
  38723. return val instanceof this.pointClass;
  38724. };
  38725. }, { "../curves": 356, "../utils": 364, "./key": 361, "./signature": 362, "hash.js": 372 }], 361: [function (require, module, exports) {
  38726. 'use strict';
  38727. var utils = require('../utils');
  38728. var assert = utils.assert;
  38729. var parseBytes = utils.parseBytes;
  38730. var cachedProperty = utils.cachedProperty;
  38731. /**
  38732. * @param {EDDSA} eddsa - instance
  38733. * @param {Object} params - public/private key parameters
  38734. *
  38735. * @param {Array<Byte>} [params.secret] - secret seed bytes
  38736. * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
  38737. * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
  38738. *
  38739. */
  38740. function KeyPair(eddsa, params) {
  38741. this.eddsa = eddsa;
  38742. this._secret = parseBytes(params.secret);
  38743. if (eddsa.isPoint(params.pub)) this._pub = params.pub; else this._pubBytes = parseBytes(params.pub);
  38744. }
  38745. KeyPair.fromPublic = function fromPublic(eddsa, pub) {
  38746. if (pub instanceof KeyPair) return pub;
  38747. return new KeyPair(eddsa, {
  38748. pub: pub
  38749. });
  38750. };
  38751. KeyPair.fromSecret = function fromSecret(eddsa, secret) {
  38752. if (secret instanceof KeyPair) return secret;
  38753. return new KeyPair(eddsa, {
  38754. secret: secret
  38755. });
  38756. };
  38757. KeyPair.prototype.secret = function secret() {
  38758. return this._secret;
  38759. };
  38760. cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
  38761. return this.eddsa.encodePoint(this.pub());
  38762. });
  38763. cachedProperty(KeyPair, 'pub', function pub() {
  38764. if (this._pubBytes) return this.eddsa.decodePoint(this._pubBytes);
  38765. return this.eddsa.g.mul(this.priv());
  38766. });
  38767. cachedProperty(KeyPair, 'privBytes', function privBytes() {
  38768. var eddsa = this.eddsa;
  38769. var hash = this.hash();
  38770. var lastIx = eddsa.encodingLength - 1;
  38771. var a = hash.slice(0, eddsa.encodingLength);
  38772. a[0] &= 248;
  38773. a[lastIx] &= 127;
  38774. a[lastIx] |= 64;
  38775. return a;
  38776. });
  38777. cachedProperty(KeyPair, 'priv', function priv() {
  38778. return this.eddsa.decodeInt(this.privBytes());
  38779. });
  38780. cachedProperty(KeyPair, 'hash', function hash() {
  38781. return this.eddsa.hash().update(this.secret()).digest();
  38782. });
  38783. cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
  38784. return this.hash().slice(this.eddsa.encodingLength);
  38785. });
  38786. KeyPair.prototype.sign = function sign(message) {
  38787. assert(this._secret, 'KeyPair can only verify');
  38788. return this.eddsa.sign(message, this);
  38789. };
  38790. KeyPair.prototype.verify = function verify(message, sig) {
  38791. return this.eddsa.verify(message, sig, this);
  38792. };
  38793. KeyPair.prototype.getSecret = function getSecret(enc) {
  38794. assert(this._secret, 'KeyPair is public only');
  38795. return utils.encode(this.secret(), enc);
  38796. };
  38797. KeyPair.prototype.getPublic = function getPublic(enc) {
  38798. return utils.encode(this.pubBytes(), enc);
  38799. };
  38800. module.exports = KeyPair;
  38801. }, { "../utils": 364 }], 362: [function (require, module, exports) {
  38802. 'use strict';
  38803. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38804. var BN = require('bn.js');
  38805. var utils = require('../utils');
  38806. var assert = utils.assert;
  38807. var cachedProperty = utils.cachedProperty;
  38808. var parseBytes = utils.parseBytes;
  38809. /**
  38810. * @param {EDDSA} eddsa - eddsa instance
  38811. * @param {Array<Bytes>|Object} sig -
  38812. * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
  38813. * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
  38814. * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
  38815. * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
  38816. */
  38817. function Signature(eddsa, sig) {
  38818. this.eddsa = eddsa;
  38819. if (_typeof(sig) !== 'object') sig = parseBytes(sig);
  38820. if (Array.isArray(sig)) {
  38821. sig = {
  38822. R: sig.slice(0, eddsa.encodingLength),
  38823. S: sig.slice(eddsa.encodingLength)
  38824. };
  38825. }
  38826. assert(sig.R && sig.S, 'Signature without R or S');
  38827. if (eddsa.isPoint(sig.R)) this._R = sig.R;
  38828. if (sig.S instanceof BN) this._S = sig.S;
  38829. this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
  38830. this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
  38831. }
  38832. cachedProperty(Signature, 'S', function S() {
  38833. return this.eddsa.decodeInt(this.Sencoded());
  38834. });
  38835. cachedProperty(Signature, 'R', function R() {
  38836. return this.eddsa.decodePoint(this.Rencoded());
  38837. });
  38838. cachedProperty(Signature, 'Rencoded', function Rencoded() {
  38839. return this.eddsa.encodePoint(this.R());
  38840. });
  38841. cachedProperty(Signature, 'Sencoded', function Sencoded() {
  38842. return this.eddsa.encodeInt(this.S());
  38843. });
  38844. Signature.prototype.toBytes = function toBytes() {
  38845. return this.Rencoded().concat(this.Sencoded());
  38846. };
  38847. Signature.prototype.toHex = function toHex() {
  38848. return utils.encode(this.toBytes(), 'hex').toUpperCase();
  38849. };
  38850. module.exports = Signature;
  38851. }, { "../utils": 364, "bn.js": 365 }], 363: [function (require, module, exports) {
  38852. "use strict";
  38853. module.exports = {
  38854. doubles: {
  38855. step: 4,
  38856. points: [['e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'], ['8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'], ['175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'], ['363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'], ['8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'], ['723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'], ['eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'], ['100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'], ['e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'], ['feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'], ['da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'], ['53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'], ['8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'], ['385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'], ['6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'], ['3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'], ['85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'], ['948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'], ['6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'], ['e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'], ['e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'], ['213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'], ['4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'], ['fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'], ['76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'], ['c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'], ['d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'], ['b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'], ['e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'], ['a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'], ['90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'], ['8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'], ['e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'], ['8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'], ['e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'], ['b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'], ['d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'], ['324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'], ['4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'], ['9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'], ['6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'], ['a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'], ['7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'], ['928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'], ['85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'], ['ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'], ['827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'], ['eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'], ['e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'], ['1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'], ['146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'], ['fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'], ['da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'], ['a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'], ['174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'], ['959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'], ['d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'], ['64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'], ['8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'], ['13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'], ['bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'], ['8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'], ['8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'], ['dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'], ['f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82']]
  38857. },
  38858. naf: {
  38859. wnd: 7,
  38860. points: [['f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'], ['2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'], ['5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'], ['acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'], ['774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'], ['f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'], ['d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'], ['defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'], ['2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'], ['352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'], ['2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'], ['9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'], ['daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'], ['c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'], ['6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'], ['1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'], ['605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'], ['62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'], ['80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'], ['7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'], ['d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'], ['49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'], ['77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'], ['f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'], ['463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'], ['f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'], ['caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'], ['2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'], ['7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'], ['754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'], ['e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'], ['186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'], ['df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'], ['5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'], ['290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'], ['af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'], ['766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'], ['59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'], ['f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'], ['7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'], ['948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'], ['7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'], ['3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'], ['d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'], ['1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'], ['733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'], ['15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'], ['a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'], ['e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'], ['311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'], ['34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'], ['f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'], ['d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'], ['32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'], ['7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'], ['ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'], ['16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'], ['eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'], ['78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'], ['494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'], ['a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'], ['c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'], ['841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'], ['5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'], ['36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'], ['336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'], ['8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'], ['1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'], ['85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'], ['29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'], ['a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'], ['4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'], ['d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'], ['ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'], ['af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'], ['e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'], ['591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'], ['11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'], ['3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'], ['cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'], ['c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'], ['c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'], ['a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'], ['347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'], ['da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'], ['c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'], ['4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'], ['3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'], ['cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'], ['b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'], ['d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'], ['48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'], ['dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'], ['6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'], ['e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'], ['eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'], ['13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'], ['ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'], ['b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'], ['ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'], ['8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'], ['52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'], ['e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'], ['7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'], ['5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'], ['32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'], ['e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'], ['8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'], ['4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'], ['3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'], ['674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'], ['d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'], ['30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'], ['be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'], ['93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'], ['b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'], ['d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'], ['d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'], ['463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'], ['7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'], ['74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'], ['30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'], ['9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'], ['176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'], ['75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'], ['809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'], ['1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9']]
  38861. }
  38862. };
  38863. }, {}], 364: [function (require, module, exports) {
  38864. 'use strict';
  38865. var utils = exports;
  38866. var BN = require('bn.js');
  38867. var minAssert = require('minimalistic-assert');
  38868. var minUtils = require('minimalistic-crypto-utils');
  38869. utils.assert = minAssert;
  38870. utils.toArray = minUtils.toArray;
  38871. utils.zero2 = minUtils.zero2;
  38872. utils.toHex = minUtils.toHex;
  38873. utils.encode = minUtils.encode; // Represent num in a w-NAF form
  38874. function getNAF(num, w, bits) {
  38875. var naf = new Array(Math.max(num.bitLength(), bits) + 1);
  38876. naf.fill(0);
  38877. var ws = 1 << w + 1;
  38878. var k = num.clone();
  38879. for (var i = 0; i < naf.length; i++) {
  38880. var z;
  38881. var mod = k.andln(ws - 1);
  38882. if (k.isOdd()) {
  38883. if (mod > (ws >> 1) - 1) z = (ws >> 1) - mod; else z = mod;
  38884. k.isubn(z);
  38885. } else {
  38886. z = 0;
  38887. }
  38888. naf[i] = z;
  38889. k.iushrn(1);
  38890. }
  38891. return naf;
  38892. }
  38893. utils.getNAF = getNAF; // Represent k1, k2 in a Joint Sparse Form
  38894. function getJSF(k1, k2) {
  38895. var jsf = [[], []];
  38896. k1 = k1.clone();
  38897. k2 = k2.clone();
  38898. var d1 = 0;
  38899. var d2 = 0;
  38900. while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
  38901. // First phase
  38902. var m14 = k1.andln(3) + d1 & 3;
  38903. var m24 = k2.andln(3) + d2 & 3;
  38904. if (m14 === 3) m14 = -1;
  38905. if (m24 === 3) m24 = -1;
  38906. var u1;
  38907. if ((m14 & 1) === 0) {
  38908. u1 = 0;
  38909. } else {
  38910. var m8 = k1.andln(7) + d1 & 7;
  38911. if ((m8 === 3 || m8 === 5) && m24 === 2) u1 = -m14; else u1 = m14;
  38912. }
  38913. jsf[0].push(u1);
  38914. var u2;
  38915. if ((m24 & 1) === 0) {
  38916. u2 = 0;
  38917. } else {
  38918. var m8 = k2.andln(7) + d2 & 7;
  38919. if ((m8 === 3 || m8 === 5) && m14 === 2) u2 = -m24; else u2 = m24;
  38920. }
  38921. jsf[1].push(u2); // Second phase
  38922. if (2 * d1 === u1 + 1) d1 = 1 - d1;
  38923. if (2 * d2 === u2 + 1) d2 = 1 - d2;
  38924. k1.iushrn(1);
  38925. k2.iushrn(1);
  38926. }
  38927. return jsf;
  38928. }
  38929. utils.getJSF = getJSF;
  38930. function cachedProperty(obj, name, computer) {
  38931. var key = '_' + name;
  38932. obj.prototype[name] = function cachedProperty() {
  38933. return this[key] !== undefined ? this[key] : this[key] = computer.call(this);
  38934. };
  38935. }
  38936. utils.cachedProperty = cachedProperty;
  38937. function parseBytes(bytes) {
  38938. return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : bytes;
  38939. }
  38940. utils.parseBytes = parseBytes;
  38941. function intFromLE(bytes) {
  38942. return new BN(bytes, 'hex', 'le');
  38943. }
  38944. utils.intFromLE = intFromLE;
  38945. }, { "bn.js": 365, "minimalistic-assert": 437, "minimalistic-crypto-utils": 438 }], 365: [function (require, module, exports) {
  38946. arguments[4][181][0].apply(exports, arguments)
  38947. }, { "buffer": 185, "dup": 181 }], 366: [function (require, module, exports) {
  38948. module.exports = {
  38949. "_from": "elliptic@^6.5.3",
  38950. "_id": "elliptic@6.5.3",
  38951. "_inBundle": false,
  38952. "_integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
  38953. "_location": "/elliptic",
  38954. "_phantomChildren": {},
  38955. "_requested": {
  38956. "type": "range",
  38957. "registry": true,
  38958. "raw": "elliptic@^6.5.3",
  38959. "name": "elliptic",
  38960. "escapedName": "elliptic",
  38961. "rawSpec": "^6.5.3",
  38962. "saveSpec": null,
  38963. "fetchSpec": "^6.5.3"
  38964. },
  38965. "_requiredBy": [
  38966. "/browserify-sign",
  38967. "/create-ecdh"
  38968. ],
  38969. "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
  38970. "_shasum": "cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6",
  38971. "_spec": "elliptic@^6.5.3",
  38972. "_where": "/mnt/d/dev/git/exceljs/node_modules/browserify-sign",
  38973. "author": {
  38974. "name": "Fedor Indutny",
  38975. "email": "fedor@indutny.com"
  38976. },
  38977. "bugs": {
  38978. "url": "https://github.com/indutny/elliptic/issues"
  38979. },
  38980. "bundleDependencies": false,
  38981. "dependencies": {
  38982. "bn.js": "^4.4.0",
  38983. "brorand": "^1.0.1",
  38984. "hash.js": "^1.0.0",
  38985. "hmac-drbg": "^1.0.0",
  38986. "inherits": "^2.0.1",
  38987. "minimalistic-assert": "^1.0.0",
  38988. "minimalistic-crypto-utils": "^1.0.0"
  38989. },
  38990. "deprecated": false,
  38991. "description": "EC cryptography",
  38992. "devDependencies": {
  38993. "brfs": "^1.4.3",
  38994. "coveralls": "^3.0.8",
  38995. "grunt": "^1.0.4",
  38996. "grunt-browserify": "^5.0.0",
  38997. "grunt-cli": "^1.2.0",
  38998. "grunt-contrib-connect": "^1.0.0",
  38999. "grunt-contrib-copy": "^1.0.0",
  39000. "grunt-contrib-uglify": "^1.0.1",
  39001. "grunt-mocha-istanbul": "^3.0.1",
  39002. "grunt-saucelabs": "^9.0.1",
  39003. "istanbul": "^0.4.2",
  39004. "jscs": "^3.0.7",
  39005. "jshint": "^2.10.3",
  39006. "mocha": "^6.2.2"
  39007. },
  39008. "files": [
  39009. "lib"
  39010. ],
  39011. "homepage": "https://github.com/indutny/elliptic",
  39012. "keywords": [
  39013. "EC",
  39014. "Elliptic",
  39015. "curve",
  39016. "Cryptography"
  39017. ],
  39018. "license": "MIT",
  39019. "main": "lib/elliptic.js",
  39020. "name": "elliptic",
  39021. "repository": {
  39022. "type": "git",
  39023. "url": "git+ssh://git@github.com/indutny/elliptic.git"
  39024. },
  39025. "scripts": {
  39026. "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
  39027. "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
  39028. "lint": "npm run jscs && npm run jshint",
  39029. "test": "npm run lint && npm run unit",
  39030. "unit": "istanbul test _mocha --reporter=spec test/index.js",
  39031. "version": "grunt dist && git add dist/"
  39032. },
  39033. "version": "6.5.3"
  39034. }
  39035. }, {}], 367: [function (require, module, exports) {
  39036. "use strict";
  39037. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  39038. // Copyright Joyent, Inc. and other Node contributors.
  39039. //
  39040. // Permission is hereby granted, free of charge, to any person obtaining a
  39041. // copy of this software and associated documentation files (the
  39042. // "Software"), to deal in the Software without restriction, including
  39043. // without limitation the rights to use, copy, modify, merge, publish,
  39044. // distribute, sublicense, and/or sell copies of the Software, and to permit
  39045. // persons to whom the Software is furnished to do so, subject to the
  39046. // following conditions:
  39047. //
  39048. // The above copyright notice and this permission notice shall be included
  39049. // in all copies or substantial portions of the Software.
  39050. //
  39051. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  39052. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39053. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  39054. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  39055. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  39056. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  39057. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  39058. var objectCreate = Object.create || objectCreatePolyfill;
  39059. var objectKeys = Object.keys || objectKeysPolyfill;
  39060. var bind = Function.prototype.bind || functionBindPolyfill;
  39061. function EventEmitter() {
  39062. if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
  39063. this._events = objectCreate(null);
  39064. this._eventsCount = 0;
  39065. }
  39066. this._maxListeners = this._maxListeners || undefined;
  39067. }
  39068. module.exports = EventEmitter; // Backwards-compat with node 0.10.x
  39069. EventEmitter.EventEmitter = EventEmitter;
  39070. EventEmitter.prototype._events = undefined;
  39071. EventEmitter.prototype._maxListeners = undefined; // By default EventEmitters will print a warning if more than 10 listeners are
  39072. // added to it. This is a useful default which helps finding memory leaks.
  39073. var defaultMaxListeners = 10;
  39074. var hasDefineProperty;
  39075. try {
  39076. var o = {};
  39077. if (Object.defineProperty) Object.defineProperty(o, 'x', {
  39078. value: 0
  39079. });
  39080. hasDefineProperty = o.x === 0;
  39081. } catch (err) {
  39082. hasDefineProperty = false;
  39083. }
  39084. if (hasDefineProperty) {
  39085. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  39086. enumerable: true,
  39087. get: function get() {
  39088. return defaultMaxListeners;
  39089. },
  39090. set: function set(arg) {
  39091. // check whether the input is a positive number (whose value is zero or
  39092. // greater and not a NaN).
  39093. if (typeof arg !== 'number' || arg < 0 || arg !== arg) throw new TypeError('"defaultMaxListeners" must be a positive number');
  39094. defaultMaxListeners = arg;
  39095. }
  39096. });
  39097. } else {
  39098. EventEmitter.defaultMaxListeners = defaultMaxListeners;
  39099. } // Obviously not all Emitters should be limited to 10. This function allows
  39100. // that to be increased. Set to zero for unlimited.
  39101. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  39102. if (typeof n !== 'number' || n < 0 || isNaN(n)) throw new TypeError('"n" argument must be a positive number');
  39103. this._maxListeners = n;
  39104. return this;
  39105. };
  39106. function $getMaxListeners(that) {
  39107. if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners;
  39108. return that._maxListeners;
  39109. }
  39110. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  39111. return $getMaxListeners(this);
  39112. }; // These standalone emit* functions are used to optimize calling of event
  39113. // handlers for fast cases because emit() itself often has a variable number of
  39114. // arguments and can be deoptimized because of that. These functions always have
  39115. // the same number of arguments and thus do not get deoptimized, so the code
  39116. // inside them can execute faster.
  39117. function emitNone(handler, isFn, self) {
  39118. if (isFn) handler.call(self); else {
  39119. var len = handler.length;
  39120. var listeners = arrayClone(handler, len);
  39121. for (var i = 0; i < len; ++i) {
  39122. listeners[i].call(self);
  39123. }
  39124. }
  39125. }
  39126. function emitOne(handler, isFn, self, arg1) {
  39127. if (isFn) handler.call(self, arg1); else {
  39128. var len = handler.length;
  39129. var listeners = arrayClone(handler, len);
  39130. for (var i = 0; i < len; ++i) {
  39131. listeners[i].call(self, arg1);
  39132. }
  39133. }
  39134. }
  39135. function emitTwo(handler, isFn, self, arg1, arg2) {
  39136. if (isFn) handler.call(self, arg1, arg2); else {
  39137. var len = handler.length;
  39138. var listeners = arrayClone(handler, len);
  39139. for (var i = 0; i < len; ++i) {
  39140. listeners[i].call(self, arg1, arg2);
  39141. }
  39142. }
  39143. }
  39144. function emitThree(handler, isFn, self, arg1, arg2, arg3) {
  39145. if (isFn) handler.call(self, arg1, arg2, arg3); else {
  39146. var len = handler.length;
  39147. var listeners = arrayClone(handler, len);
  39148. for (var i = 0; i < len; ++i) {
  39149. listeners[i].call(self, arg1, arg2, arg3);
  39150. }
  39151. }
  39152. }
  39153. function emitMany(handler, isFn, self, args) {
  39154. if (isFn) handler.apply(self, args); else {
  39155. var len = handler.length;
  39156. var listeners = arrayClone(handler, len);
  39157. for (var i = 0; i < len; ++i) {
  39158. listeners[i].apply(self, args);
  39159. }
  39160. }
  39161. }
  39162. EventEmitter.prototype.emit = function emit(type) {
  39163. var er, handler, len, args, i, events;
  39164. var doError = type === 'error';
  39165. events = this._events;
  39166. if (events) doError = doError && events.error == null; else if (!doError) return false; // If there is no 'error' event listener then throw.
  39167. if (doError) {
  39168. if (arguments.length > 1) er = arguments[1];
  39169. if (er instanceof Error) {
  39170. throw er; // Unhandled 'error' event
  39171. } else {
  39172. // At least give some kind of context to the user
  39173. var err = new Error('Unhandled "error" event. (' + er + ')');
  39174. err.context = er;
  39175. throw err;
  39176. }
  39177. return false;
  39178. }
  39179. handler = events[type];
  39180. if (!handler) return false;
  39181. var isFn = typeof handler === 'function';
  39182. len = arguments.length;
  39183. switch (len) {
  39184. // fast cases
  39185. case 1:
  39186. emitNone(handler, isFn, this);
  39187. break;
  39188. case 2:
  39189. emitOne(handler, isFn, this, arguments[1]);
  39190. break;
  39191. case 3:
  39192. emitTwo(handler, isFn, this, arguments[1], arguments[2]);
  39193. break;
  39194. case 4:
  39195. emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
  39196. break;
  39197. // slower
  39198. default:
  39199. args = new Array(len - 1);
  39200. for (i = 1; i < len; i++) {
  39201. args[i - 1] = arguments[i];
  39202. }
  39203. emitMany(handler, isFn, this, args);
  39204. }
  39205. return true;
  39206. };
  39207. function _addListener(target, type, listener, prepend) {
  39208. var m;
  39209. var events;
  39210. var existing;
  39211. if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
  39212. events = target._events;
  39213. if (!events) {
  39214. events = target._events = objectCreate(null);
  39215. target._eventsCount = 0;
  39216. } else {
  39217. // To avoid recursion in the case that type === "newListener"! Before
  39218. // adding it to the listeners, first emit "newListener".
  39219. if (events.newListener) {
  39220. target.emit('newListener', type, listener.listener ? listener.listener : listener); // Re-assign `events` because a newListener handler could have caused the
  39221. // this._events to be assigned to a new object
  39222. events = target._events;
  39223. }
  39224. existing = events[type];
  39225. }
  39226. if (!existing) {
  39227. // Optimize the case of one listener. Don't need the extra array object.
  39228. existing = events[type] = listener;
  39229. ++target._eventsCount;
  39230. } else {
  39231. if (typeof existing === 'function') {
  39232. // Adding the second element, need to change to array.
  39233. existing = events[type] = prepend ? [listener, existing] : [existing, listener];
  39234. } else {
  39235. // If we've already got an array, just append.
  39236. if (prepend) {
  39237. existing.unshift(listener);
  39238. } else {
  39239. existing.push(listener);
  39240. }
  39241. } // Check for listener leak
  39242. if (!existing.warned) {
  39243. m = $getMaxListeners(target);
  39244. if (m && m > 0 && existing.length > m) {
  39245. existing.warned = true;
  39246. var w = new Error('Possible EventEmitter memory leak detected. ' + existing.length + ' "' + String(type) + '" listeners ' + 'added. Use emitter.setMaxListeners() to ' + 'increase limit.');
  39247. w.name = 'MaxListenersExceededWarning';
  39248. w.emitter = target;
  39249. w.type = type;
  39250. w.count = existing.length;
  39251. if ((typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.warn) {
  39252. console.warn('%s: %s', w.name, w.message);
  39253. }
  39254. }
  39255. }
  39256. }
  39257. return target;
  39258. }
  39259. EventEmitter.prototype.addListener = function addListener(type, listener) {
  39260. return _addListener(this, type, listener, false);
  39261. };
  39262. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  39263. EventEmitter.prototype.prependListener = function prependListener(type, listener) {
  39264. return _addListener(this, type, listener, true);
  39265. };
  39266. function onceWrapper() {
  39267. if (!this.fired) {
  39268. this.target.removeListener(this.type, this.wrapFn);
  39269. this.fired = true;
  39270. switch (arguments.length) {
  39271. case 0:
  39272. return this.listener.call(this.target);
  39273. case 1:
  39274. return this.listener.call(this.target, arguments[0]);
  39275. case 2:
  39276. return this.listener.call(this.target, arguments[0], arguments[1]);
  39277. case 3:
  39278. return this.listener.call(this.target, arguments[0], arguments[1], arguments[2]);
  39279. default:
  39280. var args = new Array(arguments.length);
  39281. for (var i = 0; i < args.length; ++i) {
  39282. args[i] = arguments[i];
  39283. }
  39284. this.listener.apply(this.target, args);
  39285. }
  39286. }
  39287. }
  39288. function _onceWrap(target, type, listener) {
  39289. var state = {
  39290. fired: false,
  39291. wrapFn: undefined,
  39292. target: target,
  39293. type: type,
  39294. listener: listener
  39295. };
  39296. var wrapped = bind.call(onceWrapper, state);
  39297. wrapped.listener = listener;
  39298. state.wrapFn = wrapped;
  39299. return wrapped;
  39300. }
  39301. EventEmitter.prototype.once = function once(type, listener) {
  39302. if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
  39303. this.on(type, _onceWrap(this, type, listener));
  39304. return this;
  39305. };
  39306. EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
  39307. if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
  39308. this.prependListener(type, _onceWrap(this, type, listener));
  39309. return this;
  39310. }; // Emits a 'removeListener' event if and only if the listener was removed.
  39311. EventEmitter.prototype.removeListener = function removeListener(type, listener) {
  39312. var list, events, position, i, originalListener;
  39313. if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
  39314. events = this._events;
  39315. if (!events) return this;
  39316. list = events[type];
  39317. if (!list) return this;
  39318. if (list === listener || list.listener === listener) {
  39319. if (--this._eventsCount === 0) this._events = objectCreate(null); else {
  39320. delete events[type];
  39321. if (events.removeListener) this.emit('removeListener', type, list.listener || listener);
  39322. }
  39323. } else if (typeof list !== 'function') {
  39324. position = -1;
  39325. for (i = list.length - 1; i >= 0; i--) {
  39326. if (list[i] === listener || list[i].listener === listener) {
  39327. originalListener = list[i].listener;
  39328. position = i;
  39329. break;
  39330. }
  39331. }
  39332. if (position < 0) return this;
  39333. if (position === 0) list.shift(); else spliceOne(list, position);
  39334. if (list.length === 1) events[type] = list[0];
  39335. if (events.removeListener) this.emit('removeListener', type, originalListener || listener);
  39336. }
  39337. return this;
  39338. };
  39339. EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
  39340. var listeners, events, i;
  39341. events = this._events;
  39342. if (!events) return this; // not listening for removeListener, no need to emit
  39343. if (!events.removeListener) {
  39344. if (arguments.length === 0) {
  39345. this._events = objectCreate(null);
  39346. this._eventsCount = 0;
  39347. } else if (events[type]) {
  39348. if (--this._eventsCount === 0) this._events = objectCreate(null); else delete events[type];
  39349. }
  39350. return this;
  39351. } // emit removeListener for all listeners on all events
  39352. if (arguments.length === 0) {
  39353. var keys = objectKeys(events);
  39354. var key;
  39355. for (i = 0; i < keys.length; ++i) {
  39356. key = keys[i];
  39357. if (key === 'removeListener') continue;
  39358. this.removeAllListeners(key);
  39359. }
  39360. this.removeAllListeners('removeListener');
  39361. this._events = objectCreate(null);
  39362. this._eventsCount = 0;
  39363. return this;
  39364. }
  39365. listeners = events[type];
  39366. if (typeof listeners === 'function') {
  39367. this.removeListener(type, listeners);
  39368. } else if (listeners) {
  39369. // LIFO order
  39370. for (i = listeners.length - 1; i >= 0; i--) {
  39371. this.removeListener(type, listeners[i]);
  39372. }
  39373. }
  39374. return this;
  39375. };
  39376. function _listeners(target, type, unwrap) {
  39377. var events = target._events;
  39378. if (!events) return [];
  39379. var evlistener = events[type];
  39380. if (!evlistener) return [];
  39381. if (typeof evlistener === 'function') return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  39382. return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  39383. }
  39384. EventEmitter.prototype.listeners = function listeners(type) {
  39385. return _listeners(this, type, true);
  39386. };
  39387. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  39388. return _listeners(this, type, false);
  39389. };
  39390. EventEmitter.listenerCount = function (emitter, type) {
  39391. if (typeof emitter.listenerCount === 'function') {
  39392. return emitter.listenerCount(type);
  39393. } else {
  39394. return listenerCount.call(emitter, type);
  39395. }
  39396. };
  39397. EventEmitter.prototype.listenerCount = listenerCount;
  39398. function listenerCount(type) {
  39399. var events = this._events;
  39400. if (events) {
  39401. var evlistener = events[type];
  39402. if (typeof evlistener === 'function') {
  39403. return 1;
  39404. } else if (evlistener) {
  39405. return evlistener.length;
  39406. }
  39407. }
  39408. return 0;
  39409. }
  39410. EventEmitter.prototype.eventNames = function eventNames() {
  39411. return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
  39412. }; // About 1.5x faster than the two-arg version of Array#splice().
  39413. function spliceOne(list, index) {
  39414. for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
  39415. list[i] = list[k];
  39416. }
  39417. list.pop();
  39418. }
  39419. function arrayClone(arr, n) {
  39420. var copy = new Array(n);
  39421. for (var i = 0; i < n; ++i) {
  39422. copy[i] = arr[i];
  39423. }
  39424. return copy;
  39425. }
  39426. function unwrapListeners(arr) {
  39427. var ret = new Array(arr.length);
  39428. for (var i = 0; i < ret.length; ++i) {
  39429. ret[i] = arr[i].listener || arr[i];
  39430. }
  39431. return ret;
  39432. }
  39433. function objectCreatePolyfill(proto) {
  39434. var F = function F() { };
  39435. F.prototype = proto;
  39436. return new F();
  39437. }
  39438. function objectKeysPolyfill(obj) {
  39439. var keys = [];
  39440. for (var k in obj) {
  39441. if (Object.prototype.hasOwnProperty.call(obj, k)) {
  39442. keys.push(k);
  39443. }
  39444. }
  39445. return k;
  39446. }
  39447. function functionBindPolyfill(context) {
  39448. var fn = this;
  39449. return function () {
  39450. return fn.apply(context, arguments);
  39451. };
  39452. }
  39453. }, {}], 368: [function (require, module, exports) {
  39454. "use strict";
  39455. var Buffer = require('safe-buffer').Buffer;
  39456. var MD5 = require('md5.js');
  39457. /* eslint-disable camelcase */
  39458. function EVP_BytesToKey(password, salt, keyBits, ivLen) {
  39459. if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary');
  39460. if (salt) {
  39461. if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary');
  39462. if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length');
  39463. }
  39464. var keyLen = keyBits / 8;
  39465. var key = Buffer.alloc(keyLen);
  39466. var iv = Buffer.alloc(ivLen || 0);
  39467. var tmp = Buffer.alloc(0);
  39468. while (keyLen > 0 || ivLen > 0) {
  39469. var hash = new MD5();
  39470. hash.update(tmp);
  39471. hash.update(password);
  39472. if (salt) hash.update(salt);
  39473. tmp = hash.digest();
  39474. var used = 0;
  39475. if (keyLen > 0) {
  39476. var keyStart = key.length - keyLen;
  39477. used = Math.min(keyLen, tmp.length);
  39478. tmp.copy(key, keyStart, 0, used);
  39479. keyLen -= used;
  39480. }
  39481. if (used < tmp.length && ivLen > 0) {
  39482. var ivStart = iv.length - ivLen;
  39483. var length = Math.min(ivLen, tmp.length - used);
  39484. tmp.copy(iv, ivStart, used, used + length);
  39485. ivLen -= length;
  39486. }
  39487. }
  39488. tmp.fill(0);
  39489. return {
  39490. key: key,
  39491. iv: iv
  39492. };
  39493. }
  39494. module.exports = EVP_BytesToKey;
  39495. }, { "md5.js": 434, "safe-buffer": 494 }], 369: [function (require, module, exports) {
  39496. "use strict";
  39497. Object.defineProperty(exports, "__esModule", {
  39498. value: true
  39499. });
  39500. var format_1 = require("@fast-csv/format");
  39501. Object.defineProperty(exports, "format", {
  39502. enumerable: true,
  39503. get: function get() {
  39504. return format_1.format;
  39505. }
  39506. });
  39507. Object.defineProperty(exports, "write", {
  39508. enumerable: true,
  39509. get: function get() {
  39510. return format_1.write;
  39511. }
  39512. });
  39513. Object.defineProperty(exports, "writeToStream", {
  39514. enumerable: true,
  39515. get: function get() {
  39516. return format_1.writeToStream;
  39517. }
  39518. });
  39519. Object.defineProperty(exports, "writeToBuffer", {
  39520. enumerable: true,
  39521. get: function get() {
  39522. return format_1.writeToBuffer;
  39523. }
  39524. });
  39525. Object.defineProperty(exports, "writeToString", {
  39526. enumerable: true,
  39527. get: function get() {
  39528. return format_1.writeToString;
  39529. }
  39530. });
  39531. Object.defineProperty(exports, "writeToPath", {
  39532. enumerable: true,
  39533. get: function get() {
  39534. return format_1.writeToPath;
  39535. }
  39536. });
  39537. Object.defineProperty(exports, "CsvFormatterStream", {
  39538. enumerable: true,
  39539. get: function get() {
  39540. return format_1.CsvFormatterStream;
  39541. }
  39542. });
  39543. Object.defineProperty(exports, "FormatterOptions", {
  39544. enumerable: true,
  39545. get: function get() {
  39546. return format_1.FormatterOptions;
  39547. }
  39548. });
  39549. var parse_1 = require("@fast-csv/parse");
  39550. Object.defineProperty(exports, "parse", {
  39551. enumerable: true,
  39552. get: function get() {
  39553. return parse_1.parse;
  39554. }
  39555. });
  39556. Object.defineProperty(exports, "parseString", {
  39557. enumerable: true,
  39558. get: function get() {
  39559. return parse_1.parseString;
  39560. }
  39561. });
  39562. Object.defineProperty(exports, "parseStream", {
  39563. enumerable: true,
  39564. get: function get() {
  39565. return parse_1.parseStream;
  39566. }
  39567. });
  39568. Object.defineProperty(exports, "parseFile", {
  39569. enumerable: true,
  39570. get: function get() {
  39571. return parse_1.parseFile;
  39572. }
  39573. });
  39574. Object.defineProperty(exports, "ParserOptions", {
  39575. enumerable: true,
  39576. get: function get() {
  39577. return parse_1.ParserOptions;
  39578. }
  39579. });
  39580. Object.defineProperty(exports, "CsvParserStream", {
  39581. enumerable: true,
  39582. get: function get() {
  39583. return parse_1.CsvParserStream;
  39584. }
  39585. });
  39586. }, { "@fast-csv/format": 148, "@fast-csv/parse": 152 }], 370: [function (require, module, exports) {
  39587. 'use strict';
  39588. var Buffer = require('safe-buffer').Buffer;
  39589. var Transform = require('readable-stream').Transform;
  39590. var inherits = require('inherits');
  39591. function throwIfNotStringOrBuffer(val, prefix) {
  39592. if (!Buffer.isBuffer(val) && typeof val !== 'string') {
  39593. throw new TypeError(prefix + ' must be a string or a buffer');
  39594. }
  39595. }
  39596. function HashBase(blockSize) {
  39597. Transform.call(this);
  39598. this._block = Buffer.allocUnsafe(blockSize);
  39599. this._blockSize = blockSize;
  39600. this._blockOffset = 0;
  39601. this._length = [0, 0, 0, 0];
  39602. this._finalized = false;
  39603. }
  39604. inherits(HashBase, Transform);
  39605. HashBase.prototype._transform = function (chunk, encoding, callback) {
  39606. var error = null;
  39607. try {
  39608. this.update(chunk, encoding);
  39609. } catch (err) {
  39610. error = err;
  39611. }
  39612. callback(error);
  39613. };
  39614. HashBase.prototype._flush = function (callback) {
  39615. var error = null;
  39616. try {
  39617. this.push(this.digest());
  39618. } catch (err) {
  39619. error = err;
  39620. }
  39621. callback(error);
  39622. };
  39623. HashBase.prototype.update = function (data, encoding) {
  39624. throwIfNotStringOrBuffer(data, 'Data');
  39625. if (this._finalized) throw new Error('Digest already called');
  39626. if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding); // consume data
  39627. var block = this._block;
  39628. var offset = 0;
  39629. while (this._blockOffset + data.length - offset >= this._blockSize) {
  39630. for (var i = this._blockOffset; i < this._blockSize;) {
  39631. block[i++] = data[offset++];
  39632. }
  39633. this._update();
  39634. this._blockOffset = 0;
  39635. }
  39636. while (offset < data.length) {
  39637. block[this._blockOffset++] = data[offset++];
  39638. } // update length
  39639. for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
  39640. this._length[j] += carry;
  39641. carry = this._length[j] / 0x0100000000 | 0;
  39642. if (carry > 0) this._length[j] -= 0x0100000000 * carry;
  39643. }
  39644. return this;
  39645. };
  39646. HashBase.prototype._update = function () {
  39647. throw new Error('_update is not implemented');
  39648. };
  39649. HashBase.prototype.digest = function (encoding) {
  39650. if (this._finalized) throw new Error('Digest already called');
  39651. this._finalized = true;
  39652. var digest = this._digest();
  39653. if (encoding !== undefined) digest = digest.toString(encoding); // reset state
  39654. this._block.fill(0);
  39655. this._blockOffset = 0;
  39656. for (var i = 0; i < 4; ++i) {
  39657. this._length[i] = 0;
  39658. }
  39659. return digest;
  39660. };
  39661. HashBase.prototype._digest = function () {
  39662. throw new Error('_digest is not implemented');
  39663. };
  39664. module.exports = HashBase;
  39665. }, { "inherits": 387, "readable-stream": 491, "safe-buffer": 371 }], 371: [function (require, module, exports) {
  39666. arguments[4][214][0].apply(exports, arguments)
  39667. }, { "buffer": 216, "dup": 214 }], 372: [function (require, module, exports) {
  39668. "use strict";
  39669. var hash = exports;
  39670. hash.utils = require('./hash/utils');
  39671. hash.common = require('./hash/common');
  39672. hash.sha = require('./hash/sha');
  39673. hash.ripemd = require('./hash/ripemd');
  39674. hash.hmac = require('./hash/hmac'); // Proxy hash functions to the main object
  39675. hash.sha1 = hash.sha.sha1;
  39676. hash.sha256 = hash.sha.sha256;
  39677. hash.sha224 = hash.sha.sha224;
  39678. hash.sha384 = hash.sha.sha384;
  39679. hash.sha512 = hash.sha.sha512;
  39680. hash.ripemd160 = hash.ripemd.ripemd160;
  39681. }, { "./hash/common": 373, "./hash/hmac": 374, "./hash/ripemd": 375, "./hash/sha": 376, "./hash/utils": 383 }], 373: [function (require, module, exports) {
  39682. 'use strict';
  39683. var utils = require('./utils');
  39684. var assert = require('minimalistic-assert');
  39685. function BlockHash() {
  39686. this.pending = null;
  39687. this.pendingTotal = 0;
  39688. this.blockSize = this.constructor.blockSize;
  39689. this.outSize = this.constructor.outSize;
  39690. this.hmacStrength = this.constructor.hmacStrength;
  39691. this.padLength = this.constructor.padLength / 8;
  39692. this.endian = 'big';
  39693. this._delta8 = this.blockSize / 8;
  39694. this._delta32 = this.blockSize / 32;
  39695. }
  39696. exports.BlockHash = BlockHash;
  39697. BlockHash.prototype.update = function update(msg, enc) {
  39698. // Convert message to array, pad it, and join into 32bit blocks
  39699. msg = utils.toArray(msg, enc);
  39700. if (!this.pending) this.pending = msg; else this.pending = this.pending.concat(msg);
  39701. this.pendingTotal += msg.length; // Enough data, try updating
  39702. if (this.pending.length >= this._delta8) {
  39703. msg = this.pending; // Process pending data in blocks
  39704. var r = msg.length % this._delta8;
  39705. this.pending = msg.slice(msg.length - r, msg.length);
  39706. if (this.pending.length === 0) this.pending = null;
  39707. msg = utils.join32(msg, 0, msg.length - r, this.endian);
  39708. for (var i = 0; i < msg.length; i += this._delta32) {
  39709. this._update(msg, i, i + this._delta32);
  39710. }
  39711. }
  39712. return this;
  39713. };
  39714. BlockHash.prototype.digest = function digest(enc) {
  39715. this.update(this._pad());
  39716. assert(this.pending === null);
  39717. return this._digest(enc);
  39718. };
  39719. BlockHash.prototype._pad = function pad() {
  39720. var len = this.pendingTotal;
  39721. var bytes = this._delta8;
  39722. var k = bytes - (len + this.padLength) % bytes;
  39723. var res = new Array(k + this.padLength);
  39724. res[0] = 0x80;
  39725. for (var i = 1; i < k; i++) {
  39726. res[i] = 0;
  39727. } // Append length
  39728. len <<= 3;
  39729. if (this.endian === 'big') {
  39730. for (var t = 8; t < this.padLength; t++) {
  39731. res[i++] = 0;
  39732. }
  39733. res[i++] = 0;
  39734. res[i++] = 0;
  39735. res[i++] = 0;
  39736. res[i++] = 0;
  39737. res[i++] = len >>> 24 & 0xff;
  39738. res[i++] = len >>> 16 & 0xff;
  39739. res[i++] = len >>> 8 & 0xff;
  39740. res[i++] = len & 0xff;
  39741. } else {
  39742. res[i++] = len & 0xff;
  39743. res[i++] = len >>> 8 & 0xff;
  39744. res[i++] = len >>> 16 & 0xff;
  39745. res[i++] = len >>> 24 & 0xff;
  39746. res[i++] = 0;
  39747. res[i++] = 0;
  39748. res[i++] = 0;
  39749. res[i++] = 0;
  39750. for (t = 8; t < this.padLength; t++) {
  39751. res[i++] = 0;
  39752. }
  39753. }
  39754. return res;
  39755. };
  39756. }, { "./utils": 383, "minimalistic-assert": 437 }], 374: [function (require, module, exports) {
  39757. 'use strict';
  39758. var utils = require('./utils');
  39759. var assert = require('minimalistic-assert');
  39760. function Hmac(hash, key, enc) {
  39761. if (!(this instanceof Hmac)) return new Hmac(hash, key, enc);
  39762. this.Hash = hash;
  39763. this.blockSize = hash.blockSize / 8;
  39764. this.outSize = hash.outSize / 8;
  39765. this.inner = null;
  39766. this.outer = null;
  39767. this._init(utils.toArray(key, enc));
  39768. }
  39769. module.exports = Hmac;
  39770. Hmac.prototype._init = function init(key) {
  39771. // Shorten key, if needed
  39772. if (key.length > this.blockSize) key = new this.Hash().update(key).digest();
  39773. assert(key.length <= this.blockSize); // Add padding to key
  39774. for (var i = key.length; i < this.blockSize; i++) {
  39775. key.push(0);
  39776. }
  39777. for (i = 0; i < key.length; i++) {
  39778. key[i] ^= 0x36;
  39779. }
  39780. this.inner = new this.Hash().update(key); // 0x36 ^ 0x5c = 0x6a
  39781. for (i = 0; i < key.length; i++) {
  39782. key[i] ^= 0x6a;
  39783. }
  39784. this.outer = new this.Hash().update(key);
  39785. };
  39786. Hmac.prototype.update = function update(msg, enc) {
  39787. this.inner.update(msg, enc);
  39788. return this;
  39789. };
  39790. Hmac.prototype.digest = function digest(enc) {
  39791. this.outer.update(this.inner.digest());
  39792. return this.outer.digest(enc);
  39793. };
  39794. }, { "./utils": 383, "minimalistic-assert": 437 }], 375: [function (require, module, exports) {
  39795. 'use strict';
  39796. var utils = require('./utils');
  39797. var common = require('./common');
  39798. var rotl32 = utils.rotl32;
  39799. var sum32 = utils.sum32;
  39800. var sum32_3 = utils.sum32_3;
  39801. var sum32_4 = utils.sum32_4;
  39802. var BlockHash = common.BlockHash;
  39803. function RIPEMD160() {
  39804. if (!(this instanceof RIPEMD160)) return new RIPEMD160();
  39805. BlockHash.call(this);
  39806. this.h = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
  39807. this.endian = 'little';
  39808. }
  39809. utils.inherits(RIPEMD160, BlockHash);
  39810. exports.ripemd160 = RIPEMD160;
  39811. RIPEMD160.blockSize = 512;
  39812. RIPEMD160.outSize = 160;
  39813. RIPEMD160.hmacStrength = 192;
  39814. RIPEMD160.padLength = 64;
  39815. RIPEMD160.prototype._update = function update(msg, start) {
  39816. var A = this.h[0];
  39817. var B = this.h[1];
  39818. var C = this.h[2];
  39819. var D = this.h[3];
  39820. var E = this.h[4];
  39821. var Ah = A;
  39822. var Bh = B;
  39823. var Ch = C;
  39824. var Dh = D;
  39825. var Eh = E;
  39826. for (var j = 0; j < 80; j++) {
  39827. var T = sum32(rotl32(sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)), s[j]), E);
  39828. A = E;
  39829. E = D;
  39830. D = rotl32(C, 10);
  39831. C = B;
  39832. B = T;
  39833. T = sum32(rotl32(sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), sh[j]), Eh);
  39834. Ah = Eh;
  39835. Eh = Dh;
  39836. Dh = rotl32(Ch, 10);
  39837. Ch = Bh;
  39838. Bh = T;
  39839. }
  39840. T = sum32_3(this.h[1], C, Dh);
  39841. this.h[1] = sum32_3(this.h[2], D, Eh);
  39842. this.h[2] = sum32_3(this.h[3], E, Ah);
  39843. this.h[3] = sum32_3(this.h[4], A, Bh);
  39844. this.h[4] = sum32_3(this.h[0], B, Ch);
  39845. this.h[0] = T;
  39846. };
  39847. RIPEMD160.prototype._digest = function digest(enc) {
  39848. if (enc === 'hex') return utils.toHex32(this.h, 'little'); else return utils.split32(this.h, 'little');
  39849. };
  39850. function f(j, x, y, z) {
  39851. if (j <= 15) return x ^ y ^ z; else if (j <= 31) return x & y | ~x & z; else if (j <= 47) return (x | ~y) ^ z; else if (j <= 63) return x & z | y & ~z; else return x ^ (y | ~z);
  39852. }
  39853. function K(j) {
  39854. if (j <= 15) return 0x00000000; else if (j <= 31) return 0x5a827999; else if (j <= 47) return 0x6ed9eba1; else if (j <= 63) return 0x8f1bbcdc; else return 0xa953fd4e;
  39855. }
  39856. function Kh(j) {
  39857. if (j <= 15) return 0x50a28be6; else if (j <= 31) return 0x5c4dd124; else if (j <= 47) return 0x6d703ef3; else if (j <= 63) return 0x7a6d76e9; else return 0x00000000;
  39858. }
  39859. var r = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
  39860. var rh = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
  39861. var s = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6];
  39862. var sh = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11];
  39863. }, { "./common": 373, "./utils": 383 }], 376: [function (require, module, exports) {
  39864. 'use strict';
  39865. exports.sha1 = require('./sha/1');
  39866. exports.sha224 = require('./sha/224');
  39867. exports.sha256 = require('./sha/256');
  39868. exports.sha384 = require('./sha/384');
  39869. exports.sha512 = require('./sha/512');
  39870. }, { "./sha/1": 377, "./sha/224": 378, "./sha/256": 379, "./sha/384": 380, "./sha/512": 381 }], 377: [function (require, module, exports) {
  39871. 'use strict';
  39872. var utils = require('../utils');
  39873. var common = require('../common');
  39874. var shaCommon = require('./common');
  39875. var rotl32 = utils.rotl32;
  39876. var sum32 = utils.sum32;
  39877. var sum32_5 = utils.sum32_5;
  39878. var ft_1 = shaCommon.ft_1;
  39879. var BlockHash = common.BlockHash;
  39880. var sha1_K = [0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6];
  39881. function SHA1() {
  39882. if (!(this instanceof SHA1)) return new SHA1();
  39883. BlockHash.call(this);
  39884. this.h = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
  39885. this.W = new Array(80);
  39886. }
  39887. utils.inherits(SHA1, BlockHash);
  39888. module.exports = SHA1;
  39889. SHA1.blockSize = 512;
  39890. SHA1.outSize = 160;
  39891. SHA1.hmacStrength = 80;
  39892. SHA1.padLength = 64;
  39893. SHA1.prototype._update = function _update(msg, start) {
  39894. var W = this.W;
  39895. for (var i = 0; i < 16; i++) {
  39896. W[i] = msg[start + i];
  39897. }
  39898. for (; i < W.length; i++) {
  39899. W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
  39900. }
  39901. var a = this.h[0];
  39902. var b = this.h[1];
  39903. var c = this.h[2];
  39904. var d = this.h[3];
  39905. var e = this.h[4];
  39906. for (i = 0; i < W.length; i++) {
  39907. var s = ~~(i / 20);
  39908. var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
  39909. e = d;
  39910. d = c;
  39911. c = rotl32(b, 30);
  39912. b = a;
  39913. a = t;
  39914. }
  39915. this.h[0] = sum32(this.h[0], a);
  39916. this.h[1] = sum32(this.h[1], b);
  39917. this.h[2] = sum32(this.h[2], c);
  39918. this.h[3] = sum32(this.h[3], d);
  39919. this.h[4] = sum32(this.h[4], e);
  39920. };
  39921. SHA1.prototype._digest = function digest(enc) {
  39922. if (enc === 'hex') return utils.toHex32(this.h, 'big'); else return utils.split32(this.h, 'big');
  39923. };
  39924. }, { "../common": 373, "../utils": 383, "./common": 382 }], 378: [function (require, module, exports) {
  39925. 'use strict';
  39926. var utils = require('../utils');
  39927. var SHA256 = require('./256');
  39928. function SHA224() {
  39929. if (!(this instanceof SHA224)) return new SHA224();
  39930. SHA256.call(this);
  39931. this.h = [0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4];
  39932. }
  39933. utils.inherits(SHA224, SHA256);
  39934. module.exports = SHA224;
  39935. SHA224.blockSize = 512;
  39936. SHA224.outSize = 224;
  39937. SHA224.hmacStrength = 192;
  39938. SHA224.padLength = 64;
  39939. SHA224.prototype._digest = function digest(enc) {
  39940. // Just truncate output
  39941. if (enc === 'hex') return utils.toHex32(this.h.slice(0, 7), 'big'); else return utils.split32(this.h.slice(0, 7), 'big');
  39942. };
  39943. }, { "../utils": 383, "./256": 379 }], 379: [function (require, module, exports) {
  39944. 'use strict';
  39945. var utils = require('../utils');
  39946. var common = require('../common');
  39947. var shaCommon = require('./common');
  39948. var assert = require('minimalistic-assert');
  39949. var sum32 = utils.sum32;
  39950. var sum32_4 = utils.sum32_4;
  39951. var sum32_5 = utils.sum32_5;
  39952. var ch32 = shaCommon.ch32;
  39953. var maj32 = shaCommon.maj32;
  39954. var s0_256 = shaCommon.s0_256;
  39955. var s1_256 = shaCommon.s1_256;
  39956. var g0_256 = shaCommon.g0_256;
  39957. var g1_256 = shaCommon.g1_256;
  39958. var BlockHash = common.BlockHash;
  39959. var sha256_K = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];
  39960. function SHA256() {
  39961. if (!(this instanceof SHA256)) return new SHA256();
  39962. BlockHash.call(this);
  39963. this.h = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
  39964. this.k = sha256_K;
  39965. this.W = new Array(64);
  39966. }
  39967. utils.inherits(SHA256, BlockHash);
  39968. module.exports = SHA256;
  39969. SHA256.blockSize = 512;
  39970. SHA256.outSize = 256;
  39971. SHA256.hmacStrength = 192;
  39972. SHA256.padLength = 64;
  39973. SHA256.prototype._update = function _update(msg, start) {
  39974. var W = this.W;
  39975. for (var i = 0; i < 16; i++) {
  39976. W[i] = msg[start + i];
  39977. }
  39978. for (; i < W.length; i++) {
  39979. W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
  39980. }
  39981. var a = this.h[0];
  39982. var b = this.h[1];
  39983. var c = this.h[2];
  39984. var d = this.h[3];
  39985. var e = this.h[4];
  39986. var f = this.h[5];
  39987. var g = this.h[6];
  39988. var h = this.h[7];
  39989. assert(this.k.length === W.length);
  39990. for (i = 0; i < W.length; i++) {
  39991. var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
  39992. var T2 = sum32(s0_256(a), maj32(a, b, c));
  39993. h = g;
  39994. g = f;
  39995. f = e;
  39996. e = sum32(d, T1);
  39997. d = c;
  39998. c = b;
  39999. b = a;
  40000. a = sum32(T1, T2);
  40001. }
  40002. this.h[0] = sum32(this.h[0], a);
  40003. this.h[1] = sum32(this.h[1], b);
  40004. this.h[2] = sum32(this.h[2], c);
  40005. this.h[3] = sum32(this.h[3], d);
  40006. this.h[4] = sum32(this.h[4], e);
  40007. this.h[5] = sum32(this.h[5], f);
  40008. this.h[6] = sum32(this.h[6], g);
  40009. this.h[7] = sum32(this.h[7], h);
  40010. };
  40011. SHA256.prototype._digest = function digest(enc) {
  40012. if (enc === 'hex') return utils.toHex32(this.h, 'big'); else return utils.split32(this.h, 'big');
  40013. };
  40014. }, { "../common": 373, "../utils": 383, "./common": 382, "minimalistic-assert": 437 }], 380: [function (require, module, exports) {
  40015. 'use strict';
  40016. var utils = require('../utils');
  40017. var SHA512 = require('./512');
  40018. function SHA384() {
  40019. if (!(this instanceof SHA384)) return new SHA384();
  40020. SHA512.call(this);
  40021. this.h = [0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939, 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4];
  40022. }
  40023. utils.inherits(SHA384, SHA512);
  40024. module.exports = SHA384;
  40025. SHA384.blockSize = 1024;
  40026. SHA384.outSize = 384;
  40027. SHA384.hmacStrength = 192;
  40028. SHA384.padLength = 128;
  40029. SHA384.prototype._digest = function digest(enc) {
  40030. if (enc === 'hex') return utils.toHex32(this.h.slice(0, 12), 'big'); else return utils.split32(this.h.slice(0, 12), 'big');
  40031. };
  40032. }, { "../utils": 383, "./512": 381 }], 381: [function (require, module, exports) {
  40033. 'use strict';
  40034. var utils = require('../utils');
  40035. var common = require('../common');
  40036. var assert = require('minimalistic-assert');
  40037. var rotr64_hi = utils.rotr64_hi;
  40038. var rotr64_lo = utils.rotr64_lo;
  40039. var shr64_hi = utils.shr64_hi;
  40040. var shr64_lo = utils.shr64_lo;
  40041. var sum64 = utils.sum64;
  40042. var sum64_hi = utils.sum64_hi;
  40043. var sum64_lo = utils.sum64_lo;
  40044. var sum64_4_hi = utils.sum64_4_hi;
  40045. var sum64_4_lo = utils.sum64_4_lo;
  40046. var sum64_5_hi = utils.sum64_5_hi;
  40047. var sum64_5_lo = utils.sum64_5_lo;
  40048. var BlockHash = common.BlockHash;
  40049. var sha512_K = [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817];
  40050. function SHA512() {
  40051. if (!(this instanceof SHA512)) return new SHA512();
  40052. BlockHash.call(this);
  40053. this.h = [0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1, 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179];
  40054. this.k = sha512_K;
  40055. this.W = new Array(160);
  40056. }
  40057. utils.inherits(SHA512, BlockHash);
  40058. module.exports = SHA512;
  40059. SHA512.blockSize = 1024;
  40060. SHA512.outSize = 512;
  40061. SHA512.hmacStrength = 192;
  40062. SHA512.padLength = 128;
  40063. SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
  40064. var W = this.W; // 32 x 32bit words
  40065. for (var i = 0; i < 32; i++) {
  40066. W[i] = msg[start + i];
  40067. }
  40068. for (; i < W.length; i += 2) {
  40069. var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
  40070. var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
  40071. var c1_hi = W[i - 14]; // i - 7
  40072. var c1_lo = W[i - 13];
  40073. var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
  40074. var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
  40075. var c3_hi = W[i - 32]; // i - 16
  40076. var c3_lo = W[i - 31];
  40077. W[i] = sum64_4_hi(c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo);
  40078. W[i + 1] = sum64_4_lo(c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo);
  40079. }
  40080. };
  40081. SHA512.prototype._update = function _update(msg, start) {
  40082. this._prepareBlock(msg, start);
  40083. var W = this.W;
  40084. var ah = this.h[0];
  40085. var al = this.h[1];
  40086. var bh = this.h[2];
  40087. var bl = this.h[3];
  40088. var ch = this.h[4];
  40089. var cl = this.h[5];
  40090. var dh = this.h[6];
  40091. var dl = this.h[7];
  40092. var eh = this.h[8];
  40093. var el = this.h[9];
  40094. var fh = this.h[10];
  40095. var fl = this.h[11];
  40096. var gh = this.h[12];
  40097. var gl = this.h[13];
  40098. var hh = this.h[14];
  40099. var hl = this.h[15];
  40100. assert(this.k.length === W.length);
  40101. for (var i = 0; i < W.length; i += 2) {
  40102. var c0_hi = hh;
  40103. var c0_lo = hl;
  40104. var c1_hi = s1_512_hi(eh, el);
  40105. var c1_lo = s1_512_lo(eh, el);
  40106. var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
  40107. var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
  40108. var c3_hi = this.k[i];
  40109. var c3_lo = this.k[i + 1];
  40110. var c4_hi = W[i];
  40111. var c4_lo = W[i + 1];
  40112. var T1_hi = sum64_5_hi(c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo, c4_hi, c4_lo);
  40113. var T1_lo = sum64_5_lo(c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo, c4_hi, c4_lo);
  40114. c0_hi = s0_512_hi(ah, al);
  40115. c0_lo = s0_512_lo(ah, al);
  40116. c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
  40117. c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
  40118. var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
  40119. var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
  40120. hh = gh;
  40121. hl = gl;
  40122. gh = fh;
  40123. gl = fl;
  40124. fh = eh;
  40125. fl = el;
  40126. eh = sum64_hi(dh, dl, T1_hi, T1_lo);
  40127. el = sum64_lo(dl, dl, T1_hi, T1_lo);
  40128. dh = ch;
  40129. dl = cl;
  40130. ch = bh;
  40131. cl = bl;
  40132. bh = ah;
  40133. bl = al;
  40134. ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
  40135. al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
  40136. }
  40137. sum64(this.h, 0, ah, al);
  40138. sum64(this.h, 2, bh, bl);
  40139. sum64(this.h, 4, ch, cl);
  40140. sum64(this.h, 6, dh, dl);
  40141. sum64(this.h, 8, eh, el);
  40142. sum64(this.h, 10, fh, fl);
  40143. sum64(this.h, 12, gh, gl);
  40144. sum64(this.h, 14, hh, hl);
  40145. };
  40146. SHA512.prototype._digest = function digest(enc) {
  40147. if (enc === 'hex') return utils.toHex32(this.h, 'big'); else return utils.split32(this.h, 'big');
  40148. };
  40149. function ch64_hi(xh, xl, yh, yl, zh) {
  40150. var r = xh & yh ^ ~xh & zh;
  40151. if (r < 0) r += 0x100000000;
  40152. return r;
  40153. }
  40154. function ch64_lo(xh, xl, yh, yl, zh, zl) {
  40155. var r = xl & yl ^ ~xl & zl;
  40156. if (r < 0) r += 0x100000000;
  40157. return r;
  40158. }
  40159. function maj64_hi(xh, xl, yh, yl, zh) {
  40160. var r = xh & yh ^ xh & zh ^ yh & zh;
  40161. if (r < 0) r += 0x100000000;
  40162. return r;
  40163. }
  40164. function maj64_lo(xh, xl, yh, yl, zh, zl) {
  40165. var r = xl & yl ^ xl & zl ^ yl & zl;
  40166. if (r < 0) r += 0x100000000;
  40167. return r;
  40168. }
  40169. function s0_512_hi(xh, xl) {
  40170. var c0_hi = rotr64_hi(xh, xl, 28);
  40171. var c1_hi = rotr64_hi(xl, xh, 2); // 34
  40172. var c2_hi = rotr64_hi(xl, xh, 7); // 39
  40173. var r = c0_hi ^ c1_hi ^ c2_hi;
  40174. if (r < 0) r += 0x100000000;
  40175. return r;
  40176. }
  40177. function s0_512_lo(xh, xl) {
  40178. var c0_lo = rotr64_lo(xh, xl, 28);
  40179. var c1_lo = rotr64_lo(xl, xh, 2); // 34
  40180. var c2_lo = rotr64_lo(xl, xh, 7); // 39
  40181. var r = c0_lo ^ c1_lo ^ c2_lo;
  40182. if (r < 0) r += 0x100000000;
  40183. return r;
  40184. }
  40185. function s1_512_hi(xh, xl) {
  40186. var c0_hi = rotr64_hi(xh, xl, 14);
  40187. var c1_hi = rotr64_hi(xh, xl, 18);
  40188. var c2_hi = rotr64_hi(xl, xh, 9); // 41
  40189. var r = c0_hi ^ c1_hi ^ c2_hi;
  40190. if (r < 0) r += 0x100000000;
  40191. return r;
  40192. }
  40193. function s1_512_lo(xh, xl) {
  40194. var c0_lo = rotr64_lo(xh, xl, 14);
  40195. var c1_lo = rotr64_lo(xh, xl, 18);
  40196. var c2_lo = rotr64_lo(xl, xh, 9); // 41
  40197. var r = c0_lo ^ c1_lo ^ c2_lo;
  40198. if (r < 0) r += 0x100000000;
  40199. return r;
  40200. }
  40201. function g0_512_hi(xh, xl) {
  40202. var c0_hi = rotr64_hi(xh, xl, 1);
  40203. var c1_hi = rotr64_hi(xh, xl, 8);
  40204. var c2_hi = shr64_hi(xh, xl, 7);
  40205. var r = c0_hi ^ c1_hi ^ c2_hi;
  40206. if (r < 0) r += 0x100000000;
  40207. return r;
  40208. }
  40209. function g0_512_lo(xh, xl) {
  40210. var c0_lo = rotr64_lo(xh, xl, 1);
  40211. var c1_lo = rotr64_lo(xh, xl, 8);
  40212. var c2_lo = shr64_lo(xh, xl, 7);
  40213. var r = c0_lo ^ c1_lo ^ c2_lo;
  40214. if (r < 0) r += 0x100000000;
  40215. return r;
  40216. }
  40217. function g1_512_hi(xh, xl) {
  40218. var c0_hi = rotr64_hi(xh, xl, 19);
  40219. var c1_hi = rotr64_hi(xl, xh, 29); // 61
  40220. var c2_hi = shr64_hi(xh, xl, 6);
  40221. var r = c0_hi ^ c1_hi ^ c2_hi;
  40222. if (r < 0) r += 0x100000000;
  40223. return r;
  40224. }
  40225. function g1_512_lo(xh, xl) {
  40226. var c0_lo = rotr64_lo(xh, xl, 19);
  40227. var c1_lo = rotr64_lo(xl, xh, 29); // 61
  40228. var c2_lo = shr64_lo(xh, xl, 6);
  40229. var r = c0_lo ^ c1_lo ^ c2_lo;
  40230. if (r < 0) r += 0x100000000;
  40231. return r;
  40232. }
  40233. }, { "../common": 373, "../utils": 383, "minimalistic-assert": 437 }], 382: [function (require, module, exports) {
  40234. 'use strict';
  40235. var utils = require('../utils');
  40236. var rotr32 = utils.rotr32;
  40237. function ft_1(s, x, y, z) {
  40238. if (s === 0) return ch32(x, y, z);
  40239. if (s === 1 || s === 3) return p32(x, y, z);
  40240. if (s === 2) return maj32(x, y, z);
  40241. }
  40242. exports.ft_1 = ft_1;
  40243. function ch32(x, y, z) {
  40244. return x & y ^ ~x & z;
  40245. }
  40246. exports.ch32 = ch32;
  40247. function maj32(x, y, z) {
  40248. return x & y ^ x & z ^ y & z;
  40249. }
  40250. exports.maj32 = maj32;
  40251. function p32(x, y, z) {
  40252. return x ^ y ^ z;
  40253. }
  40254. exports.p32 = p32;
  40255. function s0_256(x) {
  40256. return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
  40257. }
  40258. exports.s0_256 = s0_256;
  40259. function s1_256(x) {
  40260. return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
  40261. }
  40262. exports.s1_256 = s1_256;
  40263. function g0_256(x) {
  40264. return rotr32(x, 7) ^ rotr32(x, 18) ^ x >>> 3;
  40265. }
  40266. exports.g0_256 = g0_256;
  40267. function g1_256(x) {
  40268. return rotr32(x, 17) ^ rotr32(x, 19) ^ x >>> 10;
  40269. }
  40270. exports.g1_256 = g1_256;
  40271. }, { "../utils": 383 }], 383: [function (require, module, exports) {
  40272. 'use strict';
  40273. var assert = require('minimalistic-assert');
  40274. var inherits = require('inherits');
  40275. exports.inherits = inherits;
  40276. function isSurrogatePair(msg, i) {
  40277. if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
  40278. return false;
  40279. }
  40280. if (i < 0 || i + 1 >= msg.length) {
  40281. return false;
  40282. }
  40283. return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
  40284. }
  40285. function toArray(msg, enc) {
  40286. if (Array.isArray(msg)) return msg.slice();
  40287. if (!msg) return [];
  40288. var res = [];
  40289. if (typeof msg === 'string') {
  40290. if (!enc) {
  40291. // Inspired by stringToUtf8ByteArray() in closure-library by Google
  40292. // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
  40293. // Apache License 2.0
  40294. // https://github.com/google/closure-library/blob/master/LICENSE
  40295. var p = 0;
  40296. for (var i = 0; i < msg.length; i++) {
  40297. var c = msg.charCodeAt(i);
  40298. if (c < 128) {
  40299. res[p++] = c;
  40300. } else if (c < 2048) {
  40301. res[p++] = c >> 6 | 192;
  40302. res[p++] = c & 63 | 128;
  40303. } else if (isSurrogatePair(msg, i)) {
  40304. c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
  40305. res[p++] = c >> 18 | 240;
  40306. res[p++] = c >> 12 & 63 | 128;
  40307. res[p++] = c >> 6 & 63 | 128;
  40308. res[p++] = c & 63 | 128;
  40309. } else {
  40310. res[p++] = c >> 12 | 224;
  40311. res[p++] = c >> 6 & 63 | 128;
  40312. res[p++] = c & 63 | 128;
  40313. }
  40314. }
  40315. } else if (enc === 'hex') {
  40316. msg = msg.replace(/[^a-z0-9]+/ig, '');
  40317. if (msg.length % 2 !== 0) msg = '0' + msg;
  40318. for (i = 0; i < msg.length; i += 2) {
  40319. res.push(parseInt(msg[i] + msg[i + 1], 16));
  40320. }
  40321. }
  40322. } else {
  40323. for (i = 0; i < msg.length; i++) {
  40324. res[i] = msg[i] | 0;
  40325. }
  40326. }
  40327. return res;
  40328. }
  40329. exports.toArray = toArray;
  40330. function toHex(msg) {
  40331. var res = '';
  40332. for (var i = 0; i < msg.length; i++) {
  40333. res += zero2(msg[i].toString(16));
  40334. }
  40335. return res;
  40336. }
  40337. exports.toHex = toHex;
  40338. function htonl(w) {
  40339. var res = w >>> 24 | w >>> 8 & 0xff00 | w << 8 & 0xff0000 | (w & 0xff) << 24;
  40340. return res >>> 0;
  40341. }
  40342. exports.htonl = htonl;
  40343. function toHex32(msg, endian) {
  40344. var res = '';
  40345. for (var i = 0; i < msg.length; i++) {
  40346. var w = msg[i];
  40347. if (endian === 'little') w = htonl(w);
  40348. res += zero8(w.toString(16));
  40349. }
  40350. return res;
  40351. }
  40352. exports.toHex32 = toHex32;
  40353. function zero2(word) {
  40354. if (word.length === 1) return '0' + word; else return word;
  40355. }
  40356. exports.zero2 = zero2;
  40357. function zero8(word) {
  40358. if (word.length === 7) return '0' + word; else if (word.length === 6) return '00' + word; else if (word.length === 5) return '000' + word; else if (word.length === 4) return '0000' + word; else if (word.length === 3) return '00000' + word; else if (word.length === 2) return '000000' + word; else if (word.length === 1) return '0000000' + word; else return word;
  40359. }
  40360. exports.zero8 = zero8;
  40361. function join32(msg, start, end, endian) {
  40362. var len = end - start;
  40363. assert(len % 4 === 0);
  40364. var res = new Array(len / 4);
  40365. for (var i = 0, k = start; i < res.length; i++, k += 4) {
  40366. var w;
  40367. if (endian === 'big') w = msg[k] << 24 | msg[k + 1] << 16 | msg[k + 2] << 8 | msg[k + 3]; else w = msg[k + 3] << 24 | msg[k + 2] << 16 | msg[k + 1] << 8 | msg[k];
  40368. res[i] = w >>> 0;
  40369. }
  40370. return res;
  40371. }
  40372. exports.join32 = join32;
  40373. function split32(msg, endian) {
  40374. var res = new Array(msg.length * 4);
  40375. for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
  40376. var m = msg[i];
  40377. if (endian === 'big') {
  40378. res[k] = m >>> 24;
  40379. res[k + 1] = m >>> 16 & 0xff;
  40380. res[k + 2] = m >>> 8 & 0xff;
  40381. res[k + 3] = m & 0xff;
  40382. } else {
  40383. res[k + 3] = m >>> 24;
  40384. res[k + 2] = m >>> 16 & 0xff;
  40385. res[k + 1] = m >>> 8 & 0xff;
  40386. res[k] = m & 0xff;
  40387. }
  40388. }
  40389. return res;
  40390. }
  40391. exports.split32 = split32;
  40392. function rotr32(w, b) {
  40393. return w >>> b | w << 32 - b;
  40394. }
  40395. exports.rotr32 = rotr32;
  40396. function rotl32(w, b) {
  40397. return w << b | w >>> 32 - b;
  40398. }
  40399. exports.rotl32 = rotl32;
  40400. function sum32(a, b) {
  40401. return a + b >>> 0;
  40402. }
  40403. exports.sum32 = sum32;
  40404. function sum32_3(a, b, c) {
  40405. return a + b + c >>> 0;
  40406. }
  40407. exports.sum32_3 = sum32_3;
  40408. function sum32_4(a, b, c, d) {
  40409. return a + b + c + d >>> 0;
  40410. }
  40411. exports.sum32_4 = sum32_4;
  40412. function sum32_5(a, b, c, d, e) {
  40413. return a + b + c + d + e >>> 0;
  40414. }
  40415. exports.sum32_5 = sum32_5;
  40416. function sum64(buf, pos, ah, al) {
  40417. var bh = buf[pos];
  40418. var bl = buf[pos + 1];
  40419. var lo = al + bl >>> 0;
  40420. var hi = (lo < al ? 1 : 0) + ah + bh;
  40421. buf[pos] = hi >>> 0;
  40422. buf[pos + 1] = lo;
  40423. }
  40424. exports.sum64 = sum64;
  40425. function sum64_hi(ah, al, bh, bl) {
  40426. var lo = al + bl >>> 0;
  40427. var hi = (lo < al ? 1 : 0) + ah + bh;
  40428. return hi >>> 0;
  40429. }
  40430. exports.sum64_hi = sum64_hi;
  40431. function sum64_lo(ah, al, bh, bl) {
  40432. var lo = al + bl;
  40433. return lo >>> 0;
  40434. }
  40435. exports.sum64_lo = sum64_lo;
  40436. function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
  40437. var carry = 0;
  40438. var lo = al;
  40439. lo = lo + bl >>> 0;
  40440. carry += lo < al ? 1 : 0;
  40441. lo = lo + cl >>> 0;
  40442. carry += lo < cl ? 1 : 0;
  40443. lo = lo + dl >>> 0;
  40444. carry += lo < dl ? 1 : 0;
  40445. var hi = ah + bh + ch + dh + carry;
  40446. return hi >>> 0;
  40447. }
  40448. exports.sum64_4_hi = sum64_4_hi;
  40449. function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
  40450. var lo = al + bl + cl + dl;
  40451. return lo >>> 0;
  40452. }
  40453. exports.sum64_4_lo = sum64_4_lo;
  40454. function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  40455. var carry = 0;
  40456. var lo = al;
  40457. lo = lo + bl >>> 0;
  40458. carry += lo < al ? 1 : 0;
  40459. lo = lo + cl >>> 0;
  40460. carry += lo < cl ? 1 : 0;
  40461. lo = lo + dl >>> 0;
  40462. carry += lo < dl ? 1 : 0;
  40463. lo = lo + el >>> 0;
  40464. carry += lo < el ? 1 : 0;
  40465. var hi = ah + bh + ch + dh + eh + carry;
  40466. return hi >>> 0;
  40467. }
  40468. exports.sum64_5_hi = sum64_5_hi;
  40469. function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  40470. var lo = al + bl + cl + dl + el;
  40471. return lo >>> 0;
  40472. }
  40473. exports.sum64_5_lo = sum64_5_lo;
  40474. function rotr64_hi(ah, al, num) {
  40475. var r = al << 32 - num | ah >>> num;
  40476. return r >>> 0;
  40477. }
  40478. exports.rotr64_hi = rotr64_hi;
  40479. function rotr64_lo(ah, al, num) {
  40480. var r = ah << 32 - num | al >>> num;
  40481. return r >>> 0;
  40482. }
  40483. exports.rotr64_lo = rotr64_lo;
  40484. function shr64_hi(ah, al, num) {
  40485. return ah >>> num;
  40486. }
  40487. exports.shr64_hi = shr64_hi;
  40488. function shr64_lo(ah, al, num) {
  40489. var r = ah << 32 - num | al >>> num;
  40490. return r >>> 0;
  40491. }
  40492. exports.shr64_lo = shr64_lo;
  40493. }, { "inherits": 387, "minimalistic-assert": 437 }], 384: [function (require, module, exports) {
  40494. 'use strict';
  40495. var hash = require('hash.js');
  40496. var utils = require('minimalistic-crypto-utils');
  40497. var assert = require('minimalistic-assert');
  40498. function HmacDRBG(options) {
  40499. if (!(this instanceof HmacDRBG)) return new HmacDRBG(options);
  40500. this.hash = options.hash;
  40501. this.predResist = !!options.predResist;
  40502. this.outLen = this.hash.outSize;
  40503. this.minEntropy = options.minEntropy || this.hash.hmacStrength;
  40504. this._reseed = null;
  40505. this.reseedInterval = null;
  40506. this.K = null;
  40507. this.V = null;
  40508. var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
  40509. var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
  40510. var pers = utils.toArray(options.pers, options.persEnc || 'hex');
  40511. assert(entropy.length >= this.minEntropy / 8, 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  40512. this._init(entropy, nonce, pers);
  40513. }
  40514. module.exports = HmacDRBG;
  40515. HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
  40516. var seed = entropy.concat(nonce).concat(pers);
  40517. this.K = new Array(this.outLen / 8);
  40518. this.V = new Array(this.outLen / 8);
  40519. for (var i = 0; i < this.V.length; i++) {
  40520. this.K[i] = 0x00;
  40521. this.V[i] = 0x01;
  40522. }
  40523. this._update(seed);
  40524. this._reseed = 1;
  40525. this.reseedInterval = 0x1000000000000; // 2^48
  40526. };
  40527. HmacDRBG.prototype._hmac = function hmac() {
  40528. return new hash.hmac(this.hash, this.K);
  40529. };
  40530. HmacDRBG.prototype._update = function update(seed) {
  40531. var kmac = this._hmac().update(this.V).update([0x00]);
  40532. if (seed) kmac = kmac.update(seed);
  40533. this.K = kmac.digest();
  40534. this.V = this._hmac().update(this.V).digest();
  40535. if (!seed) return;
  40536. this.K = this._hmac().update(this.V).update([0x01]).update(seed).digest();
  40537. this.V = this._hmac().update(this.V).digest();
  40538. };
  40539. HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
  40540. // Optional entropy enc
  40541. if (typeof entropyEnc !== 'string') {
  40542. addEnc = add;
  40543. add = entropyEnc;
  40544. entropyEnc = null;
  40545. }
  40546. entropy = utils.toArray(entropy, entropyEnc);
  40547. add = utils.toArray(add, addEnc);
  40548. assert(entropy.length >= this.minEntropy / 8, 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  40549. this._update(entropy.concat(add || []));
  40550. this._reseed = 1;
  40551. };
  40552. HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
  40553. if (this._reseed > this.reseedInterval) throw new Error('Reseed is required'); // Optional encoding
  40554. if (typeof enc !== 'string') {
  40555. addEnc = add;
  40556. add = enc;
  40557. enc = null;
  40558. } // Optional additional data
  40559. if (add) {
  40560. add = utils.toArray(add, addEnc || 'hex');
  40561. this._update(add);
  40562. }
  40563. var temp = [];
  40564. while (temp.length < len) {
  40565. this.V = this._hmac().update(this.V).digest();
  40566. temp = temp.concat(this.V);
  40567. }
  40568. var res = temp.slice(0, len);
  40569. this._update(add);
  40570. this._reseed++;
  40571. return utils.encode(res, enc);
  40572. };
  40573. }, { "hash.js": 372, "minimalistic-assert": 437, "minimalistic-crypto-utils": 438 }], 385: [function (require, module, exports) {
  40574. "use strict";
  40575. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  40576. var e, m;
  40577. var eLen = nBytes * 8 - mLen - 1;
  40578. var eMax = (1 << eLen) - 1;
  40579. var eBias = eMax >> 1;
  40580. var nBits = -7;
  40581. var i = isLE ? nBytes - 1 : 0;
  40582. var d = isLE ? -1 : 1;
  40583. var s = buffer[offset + i];
  40584. i += d;
  40585. e = s & (1 << -nBits) - 1;
  40586. s >>= -nBits;
  40587. nBits += eLen;
  40588. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) { }
  40589. m = e & (1 << -nBits) - 1;
  40590. e >>= -nBits;
  40591. nBits += mLen;
  40592. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) { }
  40593. if (e === 0) {
  40594. e = 1 - eBias;
  40595. } else if (e === eMax) {
  40596. return m ? NaN : (s ? -1 : 1) * Infinity;
  40597. } else {
  40598. m = m + Math.pow(2, mLen);
  40599. e = e - eBias;
  40600. }
  40601. return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
  40602. };
  40603. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  40604. var e, m, c;
  40605. var eLen = nBytes * 8 - mLen - 1;
  40606. var eMax = (1 << eLen) - 1;
  40607. var eBias = eMax >> 1;
  40608. var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
  40609. var i = isLE ? 0 : nBytes - 1;
  40610. var d = isLE ? 1 : -1;
  40611. var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
  40612. value = Math.abs(value);
  40613. if (isNaN(value) || value === Infinity) {
  40614. m = isNaN(value) ? 1 : 0;
  40615. e = eMax;
  40616. } else {
  40617. e = Math.floor(Math.log(value) / Math.LN2);
  40618. if (value * (c = Math.pow(2, -e)) < 1) {
  40619. e--;
  40620. c *= 2;
  40621. }
  40622. if (e + eBias >= 1) {
  40623. value += rt / c;
  40624. } else {
  40625. value += rt * Math.pow(2, 1 - eBias);
  40626. }
  40627. if (value * c >= 2) {
  40628. e++;
  40629. c /= 2;
  40630. }
  40631. if (e + eBias >= eMax) {
  40632. m = 0;
  40633. e = eMax;
  40634. } else if (e + eBias >= 1) {
  40635. m = (value * c - 1) * Math.pow(2, mLen);
  40636. e = e + eBias;
  40637. } else {
  40638. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  40639. e = 0;
  40640. }
  40641. }
  40642. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) { }
  40643. e = e << mLen | m;
  40644. eLen += mLen;
  40645. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) { }
  40646. buffer[offset + i - d] |= s * 128;
  40647. };
  40648. }, {}], 386: [function (require, module, exports) {
  40649. (function (global) {
  40650. 'use strict';
  40651. var Mutation = global.MutationObserver || global.WebKitMutationObserver;
  40652. var scheduleDrain;
  40653. {
  40654. if (Mutation) {
  40655. var called = 0;
  40656. var observer = new Mutation(nextTick);
  40657. var element = global.document.createTextNode('');
  40658. observer.observe(element, {
  40659. characterData: true
  40660. });
  40661. scheduleDrain = function scheduleDrain() {
  40662. element.data = called = ++called % 2;
  40663. };
  40664. } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {
  40665. var channel = new global.MessageChannel();
  40666. channel.port1.onmessage = nextTick;
  40667. scheduleDrain = function scheduleDrain() {
  40668. channel.port2.postMessage(0);
  40669. };
  40670. } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {
  40671. scheduleDrain = function scheduleDrain() {
  40672. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  40673. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  40674. var scriptEl = global.document.createElement('script');
  40675. scriptEl.onreadystatechange = function () {
  40676. nextTick();
  40677. scriptEl.onreadystatechange = null;
  40678. scriptEl.parentNode.removeChild(scriptEl);
  40679. scriptEl = null;
  40680. };
  40681. global.document.documentElement.appendChild(scriptEl);
  40682. };
  40683. } else {
  40684. scheduleDrain = function scheduleDrain() {
  40685. setTimeout(nextTick, 0);
  40686. };
  40687. }
  40688. }
  40689. var draining;
  40690. var queue = []; //named nextTick for less confusing stack traces
  40691. function nextTick() {
  40692. draining = true;
  40693. var i, oldQueue;
  40694. var len = queue.length;
  40695. while (len) {
  40696. oldQueue = queue;
  40697. queue = [];
  40698. i = -1;
  40699. while (++i < len) {
  40700. oldQueue[i]();
  40701. }
  40702. len = queue.length;
  40703. }
  40704. draining = false;
  40705. }
  40706. module.exports = immediate;
  40707. function immediate(task) {
  40708. if (queue.push(task) === 1 && !draining) {
  40709. scheduleDrain();
  40710. }
  40711. }
  40712. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  40713. }, {}], 387: [function (require, module, exports) {
  40714. "use strict";
  40715. if (typeof Object.create === 'function') {
  40716. // implementation from standard node.js 'util' module
  40717. module.exports = function inherits(ctor, superCtor) {
  40718. if (superCtor) {
  40719. ctor.super_ = superCtor;
  40720. ctor.prototype = Object.create(superCtor.prototype, {
  40721. constructor: {
  40722. value: ctor,
  40723. enumerable: false,
  40724. writable: true,
  40725. configurable: true
  40726. }
  40727. });
  40728. }
  40729. };
  40730. } else {
  40731. // old school shim for old browsers
  40732. module.exports = function inherits(ctor, superCtor) {
  40733. if (superCtor) {
  40734. ctor.super_ = superCtor;
  40735. var TempCtor = function TempCtor() { };
  40736. TempCtor.prototype = superCtor.prototype;
  40737. ctor.prototype = new TempCtor();
  40738. ctor.prototype.constructor = ctor;
  40739. }
  40740. };
  40741. }
  40742. }, {}], 388: [function (require, module, exports) {
  40743. "use strict";
  40744. /*!
  40745. * Determine if an object is a Buffer
  40746. *
  40747. * @author Feross Aboukhadijeh <https://feross.org>
  40748. * @license MIT
  40749. */
  40750. // The _isBuffer check is for Safari 5-7 support, because it's missing
  40751. // Object.prototype.constructor. Remove this eventually
  40752. module.exports = function (obj) {
  40753. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer);
  40754. };
  40755. function isBuffer(obj) {
  40756. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj);
  40757. } // For Node v0.10 support. Remove this eventually.
  40758. function isSlowBuffer(obj) {
  40759. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0));
  40760. }
  40761. }, {}], 389: [function (require, module, exports) {
  40762. "use strict";
  40763. var toString = {}.toString;
  40764. module.exports = Array.isArray || function (arr) {
  40765. return toString.call(arr) == '[object Array]';
  40766. };
  40767. }, {}], 390: [function (require, module, exports) {
  40768. 'use strict';
  40769. var utils = require('./utils');
  40770. var support = require('./support'); // private property
  40771. var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; // public method for encoding
  40772. exports.encode = function (input) {
  40773. var output = [];
  40774. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  40775. var i = 0,
  40776. len = input.length,
  40777. remainingBytes = len;
  40778. var isArray = utils.getTypeOf(input) !== "string";
  40779. while (i < input.length) {
  40780. remainingBytes = len - i;
  40781. if (!isArray) {
  40782. chr1 = input.charCodeAt(i++);
  40783. chr2 = i < len ? input.charCodeAt(i++) : 0;
  40784. chr3 = i < len ? input.charCodeAt(i++) : 0;
  40785. } else {
  40786. chr1 = input[i++];
  40787. chr2 = i < len ? input[i++] : 0;
  40788. chr3 = i < len ? input[i++] : 0;
  40789. }
  40790. enc1 = chr1 >> 2;
  40791. enc2 = (chr1 & 3) << 4 | chr2 >> 4;
  40792. enc3 = remainingBytes > 1 ? (chr2 & 15) << 2 | chr3 >> 6 : 64;
  40793. enc4 = remainingBytes > 2 ? chr3 & 63 : 64;
  40794. output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4));
  40795. }
  40796. return output.join("");
  40797. }; // public method for decoding
  40798. exports.decode = function (input) {
  40799. var chr1, chr2, chr3;
  40800. var enc1, enc2, enc3, enc4;
  40801. var i = 0,
  40802. resultIndex = 0;
  40803. var dataUrlPrefix = "data:";
  40804. if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) {
  40805. // This is a common error: people give a data url
  40806. // (data:image/png;base64,iVBOR...) with a {base64: true} and
  40807. // wonders why things don't work.
  40808. // We can detect that the string input looks like a data url but we
  40809. // *can't* be sure it is one: removing everything up to the comma would
  40810. // be too dangerous.
  40811. throw new Error("Invalid base64 input, it looks like a data url.");
  40812. }
  40813. input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  40814. var totalLength = input.length * 3 / 4;
  40815. if (input.charAt(input.length - 1) === _keyStr.charAt(64)) {
  40816. totalLength--;
  40817. }
  40818. if (input.charAt(input.length - 2) === _keyStr.charAt(64)) {
  40819. totalLength--;
  40820. }
  40821. if (totalLength % 1 !== 0) {
  40822. // totalLength is not an integer, the length does not match a valid
  40823. // base64 content. That can happen if:
  40824. // - the input is not a base64 content
  40825. // - the input is *almost* a base64 content, with a extra chars at the
  40826. // beginning or at the end
  40827. // - the input uses a base64 variant (base64url for example)
  40828. throw new Error("Invalid base64 input, bad content length.");
  40829. }
  40830. var output;
  40831. if (support.uint8array) {
  40832. output = new Uint8Array(totalLength | 0);
  40833. } else {
  40834. output = new Array(totalLength | 0);
  40835. }
  40836. while (i < input.length) {
  40837. enc1 = _keyStr.indexOf(input.charAt(i++));
  40838. enc2 = _keyStr.indexOf(input.charAt(i++));
  40839. enc3 = _keyStr.indexOf(input.charAt(i++));
  40840. enc4 = _keyStr.indexOf(input.charAt(i++));
  40841. chr1 = enc1 << 2 | enc2 >> 4;
  40842. chr2 = (enc2 & 15) << 4 | enc3 >> 2;
  40843. chr3 = (enc3 & 3) << 6 | enc4;
  40844. output[resultIndex++] = chr1;
  40845. if (enc3 !== 64) {
  40846. output[resultIndex++] = chr2;
  40847. }
  40848. if (enc4 !== 64) {
  40849. output[resultIndex++] = chr3;
  40850. }
  40851. }
  40852. return output;
  40853. };
  40854. }, { "./support": 419, "./utils": 421 }], 391: [function (require, module, exports) {
  40855. 'use strict';
  40856. var external = require("./external");
  40857. var DataWorker = require('./stream/DataWorker');
  40858. var DataLengthProbe = require('./stream/DataLengthProbe');
  40859. var Crc32Probe = require('./stream/Crc32Probe');
  40860. var DataLengthProbe = require('./stream/DataLengthProbe');
  40861. /**
  40862. * Represent a compressed object, with everything needed to decompress it.
  40863. * @constructor
  40864. * @param {number} compressedSize the size of the data compressed.
  40865. * @param {number} uncompressedSize the size of the data after decompression.
  40866. * @param {number} crc32 the crc32 of the decompressed file.
  40867. * @param {object} compression the type of compression, see lib/compressions.js.
  40868. * @param {String|ArrayBuffer|Uint8Array|Buffer} data the compressed data.
  40869. */
  40870. function CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) {
  40871. this.compressedSize = compressedSize;
  40872. this.uncompressedSize = uncompressedSize;
  40873. this.crc32 = crc32;
  40874. this.compression = compression;
  40875. this.compressedContent = data;
  40876. }
  40877. CompressedObject.prototype = {
  40878. /**
  40879. * Create a worker to get the uncompressed content.
  40880. * @return {GenericWorker} the worker.
  40881. */
  40882. getContentWorker: function getContentWorker() {
  40883. var worker = new DataWorker(external.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new DataLengthProbe("data_length"));
  40884. var that = this;
  40885. worker.on("end", function () {
  40886. if (this.streamInfo['data_length'] !== that.uncompressedSize) {
  40887. throw new Error("Bug : uncompressed data size mismatch");
  40888. }
  40889. });
  40890. return worker;
  40891. },
  40892. /**
  40893. * Create a worker to get the compressed content.
  40894. * @return {GenericWorker} the worker.
  40895. */
  40896. getCompressedWorker: function getCompressedWorker() {
  40897. return new DataWorker(external.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression);
  40898. }
  40899. };
  40900. /**
  40901. * Chain the given worker with other workers to compress the content with the
  40902. * given compression.
  40903. * @param {GenericWorker} uncompressedWorker the worker to pipe.
  40904. * @param {Object} compression the compression object.
  40905. * @param {Object} compressionOptions the options to use when compressing.
  40906. * @return {GenericWorker} the new worker compressing the content.
  40907. */
  40908. CompressedObject.createWorkerFrom = function (uncompressedWorker, compression, compressionOptions) {
  40909. return uncompressedWorker.pipe(new Crc32Probe()).pipe(new DataLengthProbe("uncompressedSize")).pipe(compression.compressWorker(compressionOptions)).pipe(new DataLengthProbe("compressedSize")).withStreamInfo("compression", compression);
  40910. };
  40911. module.exports = CompressedObject;
  40912. }, { "./external": 395, "./stream/Crc32Probe": 414, "./stream/DataLengthProbe": 415, "./stream/DataWorker": 416 }], 392: [function (require, module, exports) {
  40913. 'use strict';
  40914. var GenericWorker = require("./stream/GenericWorker");
  40915. exports.STORE = {
  40916. magic: "\x00\x00",
  40917. compressWorker: function compressWorker(compressionOptions) {
  40918. return new GenericWorker("STORE compression");
  40919. },
  40920. uncompressWorker: function uncompressWorker() {
  40921. return new GenericWorker("STORE decompression");
  40922. }
  40923. };
  40924. exports.DEFLATE = require('./flate');
  40925. }, { "./flate": 396, "./stream/GenericWorker": 417 }], 393: [function (require, module, exports) {
  40926. 'use strict';
  40927. var utils = require('./utils');
  40928. /**
  40929. * The following functions come from pako, from pako/lib/zlib/crc32.js
  40930. * released under the MIT license, see pako https://github.com/nodeca/pako/
  40931. */
  40932. // Use ordinary array, since untyped makes no boost here
  40933. function makeTable() {
  40934. var c,
  40935. table = [];
  40936. for (var n = 0; n < 256; n++) {
  40937. c = n;
  40938. for (var k = 0; k < 8; k++) {
  40939. c = c & 1 ? 0xEDB88320 ^ c >>> 1 : c >>> 1;
  40940. }
  40941. table[n] = c;
  40942. }
  40943. return table;
  40944. } // Create table on load. Just 255 signed longs. Not a problem.
  40945. var crcTable = makeTable();
  40946. function crc32(crc, buf, len, pos) {
  40947. var t = crcTable,
  40948. end = pos + len;
  40949. crc = crc ^ -1;
  40950. for (var i = pos; i < end; i++) {
  40951. crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 0xFF];
  40952. }
  40953. return crc ^ -1; // >>> 0;
  40954. } // That's all for the pako functions.
  40955. /**
  40956. * Compute the crc32 of a string.
  40957. * This is almost the same as the function crc32, but for strings. Using the
  40958. * same function for the two use cases leads to horrible performances.
  40959. * @param {Number} crc the starting value of the crc.
  40960. * @param {String} str the string to use.
  40961. * @param {Number} len the length of the string.
  40962. * @param {Number} pos the starting position for the crc32 computation.
  40963. * @return {Number} the computed crc32.
  40964. */
  40965. function crc32str(crc, str, len, pos) {
  40966. var t = crcTable,
  40967. end = pos + len;
  40968. crc = crc ^ -1;
  40969. for (var i = pos; i < end; i++) {
  40970. crc = crc >>> 8 ^ t[(crc ^ str.charCodeAt(i)) & 0xFF];
  40971. }
  40972. return crc ^ -1; // >>> 0;
  40973. }
  40974. module.exports = function crc32wrapper(input, crc) {
  40975. if (typeof input === "undefined" || !input.length) {
  40976. return 0;
  40977. }
  40978. var isArray = utils.getTypeOf(input) !== "string";
  40979. if (isArray) {
  40980. return crc32(crc | 0, input, input.length, 0);
  40981. } else {
  40982. return crc32str(crc | 0, input, input.length, 0);
  40983. }
  40984. };
  40985. }, { "./utils": 421 }], 394: [function (require, module, exports) {
  40986. 'use strict';
  40987. exports.base64 = false;
  40988. exports.binary = false;
  40989. exports.dir = false;
  40990. exports.createFolders = true;
  40991. exports.date = null;
  40992. exports.compression = null;
  40993. exports.compressionOptions = null;
  40994. exports.comment = null;
  40995. exports.unixPermissions = null;
  40996. exports.dosPermissions = null;
  40997. }, {}], 395: [function (require, module, exports) {
  40998. /* global Promise */
  40999. 'use strict'; // load the global object first:
  41000. // - it should be better integrated in the system (unhandledRejection in node)
  41001. // - the environment may have a custom Promise implementation (see zone.js)
  41002. var ES6Promise = null;
  41003. if (typeof Promise !== "undefined") {
  41004. ES6Promise = Promise;
  41005. } else {
  41006. ES6Promise = require("lie");
  41007. }
  41008. /**
  41009. * Let the user use/change some implementations.
  41010. */
  41011. module.exports = {
  41012. Promise: ES6Promise
  41013. };
  41014. }, { "lie": 425 }], 396: [function (require, module, exports) {
  41015. 'use strict';
  41016. var USE_TYPEDARRAY = typeof Uint8Array !== 'undefined' && typeof Uint16Array !== 'undefined' && typeof Uint32Array !== 'undefined';
  41017. var pako = require("pako");
  41018. var utils = require("./utils");
  41019. var GenericWorker = require("./stream/GenericWorker");
  41020. var ARRAY_TYPE = USE_TYPEDARRAY ? "uint8array" : "array";
  41021. exports.magic = "\x08\x00";
  41022. /**
  41023. * Create a worker that uses pako to inflate/deflate.
  41024. * @constructor
  41025. * @param {String} action the name of the pako function to call : either "Deflate" or "Inflate".
  41026. * @param {Object} options the options to use when (de)compressing.
  41027. */
  41028. function FlateWorker(action, options) {
  41029. GenericWorker.call(this, "FlateWorker/" + action);
  41030. this._pako = null;
  41031. this._pakoAction = action;
  41032. this._pakoOptions = options; // the `meta` object from the last chunk received
  41033. // this allow this worker to pass around metadata
  41034. this.meta = {};
  41035. }
  41036. utils.inherits(FlateWorker, GenericWorker);
  41037. /**
  41038. * @see GenericWorker.processChunk
  41039. */
  41040. FlateWorker.prototype.processChunk = function (chunk) {
  41041. this.meta = chunk.meta;
  41042. if (this._pako === null) {
  41043. this._createPako();
  41044. }
  41045. this._pako.push(utils.transformTo(ARRAY_TYPE, chunk.data), false);
  41046. };
  41047. /**
  41048. * @see GenericWorker.flush
  41049. */
  41050. FlateWorker.prototype.flush = function () {
  41051. GenericWorker.prototype.flush.call(this);
  41052. if (this._pako === null) {
  41053. this._createPako();
  41054. }
  41055. this._pako.push([], true);
  41056. };
  41057. /**
  41058. * @see GenericWorker.cleanUp
  41059. */
  41060. FlateWorker.prototype.cleanUp = function () {
  41061. GenericWorker.prototype.cleanUp.call(this);
  41062. this._pako = null;
  41063. };
  41064. /**
  41065. * Create the _pako object.
  41066. * TODO: lazy-loading this object isn't the best solution but it's the
  41067. * quickest. The best solution is to lazy-load the worker list. See also the
  41068. * issue #446.
  41069. */
  41070. FlateWorker.prototype._createPako = function () {
  41071. this._pako = new pako[this._pakoAction]({
  41072. raw: true,
  41073. level: this._pakoOptions.level || -1 // default compression
  41074. });
  41075. var self = this;
  41076. this._pako.onData = function (data) {
  41077. self.push({
  41078. data: data,
  41079. meta: self.meta
  41080. });
  41081. };
  41082. };
  41083. exports.compressWorker = function (compressionOptions) {
  41084. return new FlateWorker("Deflate", compressionOptions);
  41085. };
  41086. exports.uncompressWorker = function () {
  41087. return new FlateWorker("Inflate", {});
  41088. };
  41089. }, { "./stream/GenericWorker": 417, "./utils": 421, "pako": 439 }], 397: [function (require, module, exports) {
  41090. 'use strict';
  41091. var utils = require('../utils');
  41092. var GenericWorker = require('../stream/GenericWorker');
  41093. var utf8 = require('../utf8');
  41094. var crc32 = require('../crc32');
  41095. var signature = require('../signature');
  41096. /**
  41097. * Transform an integer into a string in hexadecimal.
  41098. * @private
  41099. * @param {number} dec the number to convert.
  41100. * @param {number} bytes the number of bytes to generate.
  41101. * @returns {string} the result.
  41102. */
  41103. var decToHex = function decToHex(dec, bytes) {
  41104. var hex = "",
  41105. i;
  41106. for (i = 0; i < bytes; i++) {
  41107. hex += String.fromCharCode(dec & 0xff);
  41108. dec = dec >>> 8;
  41109. }
  41110. return hex;
  41111. };
  41112. /**
  41113. * Generate the UNIX part of the external file attributes.
  41114. * @param {Object} unixPermissions the unix permissions or null.
  41115. * @param {Boolean} isDir true if the entry is a directory, false otherwise.
  41116. * @return {Number} a 32 bit integer.
  41117. *
  41118. * adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :
  41119. *
  41120. * TTTTsstrwxrwxrwx0000000000ADVSHR
  41121. * ^^^^____________________________ file type, see zipinfo.c (UNX_*)
  41122. * ^^^_________________________ setuid, setgid, sticky
  41123. * ^^^^^^^^^________________ permissions
  41124. * ^^^^^^^^^^______ not used ?
  41125. * ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only
  41126. */
  41127. var generateUnixExternalFileAttr = function generateUnixExternalFileAttr(unixPermissions, isDir) {
  41128. var result = unixPermissions;
  41129. if (!unixPermissions) {
  41130. // I can't use octal values in strict mode, hence the hexa.
  41131. // 040775 => 0x41fd
  41132. // 0100664 => 0x81b4
  41133. result = isDir ? 0x41fd : 0x81b4;
  41134. }
  41135. return (result & 0xFFFF) << 16;
  41136. };
  41137. /**
  41138. * Generate the DOS part of the external file attributes.
  41139. * @param {Object} dosPermissions the dos permissions or null.
  41140. * @param {Boolean} isDir true if the entry is a directory, false otherwise.
  41141. * @return {Number} a 32 bit integer.
  41142. *
  41143. * Bit 0 Read-Only
  41144. * Bit 1 Hidden
  41145. * Bit 2 System
  41146. * Bit 3 Volume Label
  41147. * Bit 4 Directory
  41148. * Bit 5 Archive
  41149. */
  41150. var generateDosExternalFileAttr = function generateDosExternalFileAttr(dosPermissions, isDir) {
  41151. // the dir flag is already set for compatibility
  41152. return (dosPermissions || 0) & 0x3F;
  41153. };
  41154. /**
  41155. * Generate the various parts used in the construction of the final zip file.
  41156. * @param {Object} streamInfo the hash with information about the compressed file.
  41157. * @param {Boolean} streamedContent is the content streamed ?
  41158. * @param {Boolean} streamingEnded is the stream finished ?
  41159. * @param {number} offset the current offset from the start of the zip file.
  41160. * @param {String} platform let's pretend we are this platform (change platform dependents fields)
  41161. * @param {Function} encodeFileName the function to encode the file name / comment.
  41162. * @return {Object} the zip parts.
  41163. */
  41164. var generateZipParts = function generateZipParts(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) {
  41165. var file = streamInfo['file'],
  41166. compression = streamInfo['compression'],
  41167. useCustomEncoding = encodeFileName !== utf8.utf8encode,
  41168. encodedFileName = utils.transformTo("string", encodeFileName(file.name)),
  41169. utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)),
  41170. comment = file.comment,
  41171. encodedComment = utils.transformTo("string", encodeFileName(comment)),
  41172. utfEncodedComment = utils.transformTo("string", utf8.utf8encode(comment)),
  41173. useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,
  41174. useUTF8ForComment = utfEncodedComment.length !== comment.length,
  41175. dosTime,
  41176. dosDate,
  41177. extraFields = "",
  41178. unicodePathExtraField = "",
  41179. unicodeCommentExtraField = "",
  41180. dir = file.dir,
  41181. date = file.date;
  41182. var dataInfo = {
  41183. crc32: 0,
  41184. compressedSize: 0,
  41185. uncompressedSize: 0
  41186. }; // if the content is streamed, the sizes/crc32 are only available AFTER
  41187. // the end of the stream.
  41188. if (!streamedContent || streamingEnded) {
  41189. dataInfo.crc32 = streamInfo['crc32'];
  41190. dataInfo.compressedSize = streamInfo['compressedSize'];
  41191. dataInfo.uncompressedSize = streamInfo['uncompressedSize'];
  41192. }
  41193. var bitflag = 0;
  41194. if (streamedContent) {
  41195. // Bit 3: the sizes/crc32 are set to zero in the local header.
  41196. // The correct values are put in the data descriptor immediately
  41197. // following the compressed data.
  41198. bitflag |= 0x0008;
  41199. }
  41200. if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) {
  41201. // Bit 11: Language encoding flag (EFS).
  41202. bitflag |= 0x0800;
  41203. }
  41204. var extFileAttr = 0;
  41205. var versionMadeBy = 0;
  41206. if (dir) {
  41207. // dos or unix, we set the dos dir flag
  41208. extFileAttr |= 0x00010;
  41209. }
  41210. if (platform === "UNIX") {
  41211. versionMadeBy = 0x031E; // UNIX, version 3.0
  41212. extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);
  41213. } else {
  41214. // DOS or other, fallback to DOS
  41215. versionMadeBy = 0x0014; // DOS, version 2.0
  41216. extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);
  41217. } // date
  41218. // @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html
  41219. // @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html
  41220. // @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html
  41221. dosTime = date.getUTCHours();
  41222. dosTime = dosTime << 6;
  41223. dosTime = dosTime | date.getUTCMinutes();
  41224. dosTime = dosTime << 5;
  41225. dosTime = dosTime | date.getUTCSeconds() / 2;
  41226. dosDate = date.getUTCFullYear() - 1980;
  41227. dosDate = dosDate << 4;
  41228. dosDate = dosDate | date.getUTCMonth() + 1;
  41229. dosDate = dosDate << 5;
  41230. dosDate = dosDate | date.getUTCDate();
  41231. if (useUTF8ForFileName) {
  41232. // set the unicode path extra field. unzip needs at least one extra
  41233. // field to correctly handle unicode path, so using the path is as good
  41234. // as any other information. This could improve the situation with
  41235. // other archive managers too.
  41236. // This field is usually used without the utf8 flag, with a non
  41237. // unicode path in the header (winrar, winzip). This helps (a bit)
  41238. // with the messy Windows' default compressed folders feature but
  41239. // breaks on p7zip which doesn't seek the unicode path extra field.
  41240. // So for now, UTF-8 everywhere !
  41241. unicodePathExtraField = // Version
  41242. decToHex(1, 1) + // NameCRC32
  41243. decToHex(crc32(encodedFileName), 4) + // UnicodeName
  41244. utfEncodedFileName;
  41245. extraFields += // Info-ZIP Unicode Path Extra Field
  41246. "\x75\x70" + // size
  41247. decToHex(unicodePathExtraField.length, 2) + // content
  41248. unicodePathExtraField;
  41249. }
  41250. if (useUTF8ForComment) {
  41251. unicodeCommentExtraField = // Version
  41252. decToHex(1, 1) + // CommentCRC32
  41253. decToHex(crc32(encodedComment), 4) + // UnicodeName
  41254. utfEncodedComment;
  41255. extraFields += // Info-ZIP Unicode Path Extra Field
  41256. "\x75\x63" + // size
  41257. decToHex(unicodeCommentExtraField.length, 2) + // content
  41258. unicodeCommentExtraField;
  41259. }
  41260. var header = ""; // version needed to extract
  41261. header += "\x0A\x00"; // general purpose bit flag
  41262. header += decToHex(bitflag, 2); // compression method
  41263. header += compression.magic; // last mod file time
  41264. header += decToHex(dosTime, 2); // last mod file date
  41265. header += decToHex(dosDate, 2); // crc-32
  41266. header += decToHex(dataInfo.crc32, 4); // compressed size
  41267. header += decToHex(dataInfo.compressedSize, 4); // uncompressed size
  41268. header += decToHex(dataInfo.uncompressedSize, 4); // file name length
  41269. header += decToHex(encodedFileName.length, 2); // extra field length
  41270. header += decToHex(extraFields.length, 2);
  41271. var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields;
  41272. var dirRecord = signature.CENTRAL_FILE_HEADER + // version made by (00: DOS)
  41273. decToHex(versionMadeBy, 2) + // file header (common to file and central directory)
  41274. header + // file comment length
  41275. decToHex(encodedComment.length, 2) + // disk number start
  41276. "\x00\x00" + // internal file attributes TODO
  41277. "\x00\x00" + // external file attributes
  41278. decToHex(extFileAttr, 4) + // relative offset of local header
  41279. decToHex(offset, 4) + // file name
  41280. encodedFileName + // extra field
  41281. extraFields + // file comment
  41282. encodedComment;
  41283. return {
  41284. fileRecord: fileRecord,
  41285. dirRecord: dirRecord
  41286. };
  41287. };
  41288. /**
  41289. * Generate the EOCD record.
  41290. * @param {Number} entriesCount the number of entries in the zip file.
  41291. * @param {Number} centralDirLength the length (in bytes) of the central dir.
  41292. * @param {Number} localDirLength the length (in bytes) of the local dir.
  41293. * @param {String} comment the zip file comment as a binary string.
  41294. * @param {Function} encodeFileName the function to encode the comment.
  41295. * @return {String} the EOCD record.
  41296. */
  41297. var generateCentralDirectoryEnd = function generateCentralDirectoryEnd(entriesCount, centralDirLength, localDirLength, comment, encodeFileName) {
  41298. var dirEnd = "";
  41299. var encodedComment = utils.transformTo("string", encodeFileName(comment)); // end of central dir signature
  41300. dirEnd = signature.CENTRAL_DIRECTORY_END + // number of this disk
  41301. "\x00\x00" + // number of the disk with the start of the central directory
  41302. "\x00\x00" + // total number of entries in the central directory on this disk
  41303. decToHex(entriesCount, 2) + // total number of entries in the central directory
  41304. decToHex(entriesCount, 2) + // size of the central directory 4 bytes
  41305. decToHex(centralDirLength, 4) + // offset of start of central directory with respect to the starting disk number
  41306. decToHex(localDirLength, 4) + // .ZIP file comment length
  41307. decToHex(encodedComment.length, 2) + // .ZIP file comment
  41308. encodedComment;
  41309. return dirEnd;
  41310. };
  41311. /**
  41312. * Generate data descriptors for a file entry.
  41313. * @param {Object} streamInfo the hash generated by a worker, containing information
  41314. * on the file entry.
  41315. * @return {String} the data descriptors.
  41316. */
  41317. var generateDataDescriptors = function generateDataDescriptors(streamInfo) {
  41318. var descriptor = "";
  41319. descriptor = signature.DATA_DESCRIPTOR + // crc-32 4 bytes
  41320. decToHex(streamInfo['crc32'], 4) + // compressed size 4 bytes
  41321. decToHex(streamInfo['compressedSize'], 4) + // uncompressed size 4 bytes
  41322. decToHex(streamInfo['uncompressedSize'], 4);
  41323. return descriptor;
  41324. };
  41325. /**
  41326. * A worker to concatenate other workers to create a zip file.
  41327. * @param {Boolean} streamFiles `true` to stream the content of the files,
  41328. * `false` to accumulate it.
  41329. * @param {String} comment the comment to use.
  41330. * @param {String} platform the platform to use, "UNIX" or "DOS".
  41331. * @param {Function} encodeFileName the function to encode file names and comments.
  41332. */
  41333. function ZipFileWorker(streamFiles, comment, platform, encodeFileName) {
  41334. GenericWorker.call(this, "ZipFileWorker"); // The number of bytes written so far. This doesn't count accumulated chunks.
  41335. this.bytesWritten = 0; // The comment of the zip file
  41336. this.zipComment = comment; // The platform "generating" the zip file.
  41337. this.zipPlatform = platform; // the function to encode file names and comments.
  41338. this.encodeFileName = encodeFileName; // Should we stream the content of the files ?
  41339. this.streamFiles = streamFiles; // If `streamFiles` is false, we will need to accumulate the content of the
  41340. // files to calculate sizes / crc32 (and write them *before* the content).
  41341. // This boolean indicates if we are accumulating chunks (it will change a lot
  41342. // during the lifetime of this worker).
  41343. this.accumulate = false; // The buffer receiving chunks when accumulating content.
  41344. this.contentBuffer = []; // The list of generated directory records.
  41345. this.dirRecords = []; // The offset (in bytes) from the beginning of the zip file for the current source.
  41346. this.currentSourceOffset = 0; // The total number of entries in this zip file.
  41347. this.entriesCount = 0; // the name of the file currently being added, null when handling the end of the zip file.
  41348. // Used for the emitted metadata.
  41349. this.currentFile = null;
  41350. this._sources = [];
  41351. }
  41352. utils.inherits(ZipFileWorker, GenericWorker);
  41353. /**
  41354. * @see GenericWorker.push
  41355. */
  41356. ZipFileWorker.prototype.push = function (chunk) {
  41357. var currentFilePercent = chunk.meta.percent || 0;
  41358. var entriesCount = this.entriesCount;
  41359. var remainingFiles = this._sources.length;
  41360. if (this.accumulate) {
  41361. this.contentBuffer.push(chunk);
  41362. } else {
  41363. this.bytesWritten += chunk.data.length;
  41364. GenericWorker.prototype.push.call(this, {
  41365. data: chunk.data,
  41366. meta: {
  41367. currentFile: this.currentFile,
  41368. percent: entriesCount ? (currentFilePercent + 100 * (entriesCount - remainingFiles - 1)) / entriesCount : 100
  41369. }
  41370. });
  41371. }
  41372. };
  41373. /**
  41374. * The worker started a new source (an other worker).
  41375. * @param {Object} streamInfo the streamInfo object from the new source.
  41376. */
  41377. ZipFileWorker.prototype.openedSource = function (streamInfo) {
  41378. this.currentSourceOffset = this.bytesWritten;
  41379. this.currentFile = streamInfo['file'].name;
  41380. var streamedContent = this.streamFiles && !streamInfo['file'].dir; // don't stream folders (because they don't have any content)
  41381. if (streamedContent) {
  41382. var record = generateZipParts(streamInfo, streamedContent, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
  41383. this.push({
  41384. data: record.fileRecord,
  41385. meta: {
  41386. percent: 0
  41387. }
  41388. });
  41389. } else {
  41390. // we need to wait for the whole file before pushing anything
  41391. this.accumulate = true;
  41392. }
  41393. };
  41394. /**
  41395. * The worker finished a source (an other worker).
  41396. * @param {Object} streamInfo the streamInfo object from the finished source.
  41397. */
  41398. ZipFileWorker.prototype.closedSource = function (streamInfo) {
  41399. this.accumulate = false;
  41400. var streamedContent = this.streamFiles && !streamInfo['file'].dir;
  41401. var record = generateZipParts(streamInfo, streamedContent, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
  41402. this.dirRecords.push(record.dirRecord);
  41403. if (streamedContent) {
  41404. // after the streamed file, we put data descriptors
  41405. this.push({
  41406. data: generateDataDescriptors(streamInfo),
  41407. meta: {
  41408. percent: 100
  41409. }
  41410. });
  41411. } else {
  41412. // the content wasn't streamed, we need to push everything now
  41413. // first the file record, then the content
  41414. this.push({
  41415. data: record.fileRecord,
  41416. meta: {
  41417. percent: 0
  41418. }
  41419. });
  41420. while (this.contentBuffer.length) {
  41421. this.push(this.contentBuffer.shift());
  41422. }
  41423. }
  41424. this.currentFile = null;
  41425. };
  41426. /**
  41427. * @see GenericWorker.flush
  41428. */
  41429. ZipFileWorker.prototype.flush = function () {
  41430. var localDirLength = this.bytesWritten;
  41431. for (var i = 0; i < this.dirRecords.length; i++) {
  41432. this.push({
  41433. data: this.dirRecords[i],
  41434. meta: {
  41435. percent: 100
  41436. }
  41437. });
  41438. }
  41439. var centralDirLength = this.bytesWritten - localDirLength;
  41440. var dirEnd = generateCentralDirectoryEnd(this.dirRecords.length, centralDirLength, localDirLength, this.zipComment, this.encodeFileName);
  41441. this.push({
  41442. data: dirEnd,
  41443. meta: {
  41444. percent: 100
  41445. }
  41446. });
  41447. };
  41448. /**
  41449. * Prepare the next source to be read.
  41450. */
  41451. ZipFileWorker.prototype.prepareNextSource = function () {
  41452. this.previous = this._sources.shift();
  41453. this.openedSource(this.previous.streamInfo);
  41454. if (this.isPaused) {
  41455. this.previous.pause();
  41456. } else {
  41457. this.previous.resume();
  41458. }
  41459. };
  41460. /**
  41461. * @see GenericWorker.registerPrevious
  41462. */
  41463. ZipFileWorker.prototype.registerPrevious = function (previous) {
  41464. this._sources.push(previous);
  41465. var self = this;
  41466. previous.on('data', function (chunk) {
  41467. self.processChunk(chunk);
  41468. });
  41469. previous.on('end', function () {
  41470. self.closedSource(self.previous.streamInfo);
  41471. if (self._sources.length) {
  41472. self.prepareNextSource();
  41473. } else {
  41474. self.end();
  41475. }
  41476. });
  41477. previous.on('error', function (e) {
  41478. self.error(e);
  41479. });
  41480. return this;
  41481. };
  41482. /**
  41483. * @see GenericWorker.resume
  41484. */
  41485. ZipFileWorker.prototype.resume = function () {
  41486. if (!GenericWorker.prototype.resume.call(this)) {
  41487. return false;
  41488. }
  41489. if (!this.previous && this._sources.length) {
  41490. this.prepareNextSource();
  41491. return true;
  41492. }
  41493. if (!this.previous && !this._sources.length && !this.generatedError) {
  41494. this.end();
  41495. return true;
  41496. }
  41497. };
  41498. /**
  41499. * @see GenericWorker.error
  41500. */
  41501. ZipFileWorker.prototype.error = function (e) {
  41502. var sources = this._sources;
  41503. if (!GenericWorker.prototype.error.call(this, e)) {
  41504. return false;
  41505. }
  41506. for (var i = 0; i < sources.length; i++) {
  41507. try {
  41508. sources[i].error(e);
  41509. } catch (e) {// the `error` exploded, nothing to do
  41510. }
  41511. }
  41512. return true;
  41513. };
  41514. /**
  41515. * @see GenericWorker.lock
  41516. */
  41517. ZipFileWorker.prototype.lock = function () {
  41518. GenericWorker.prototype.lock.call(this);
  41519. var sources = this._sources;
  41520. for (var i = 0; i < sources.length; i++) {
  41521. sources[i].lock();
  41522. }
  41523. };
  41524. module.exports = ZipFileWorker;
  41525. }, { "../crc32": 393, "../signature": 412, "../stream/GenericWorker": 417, "../utf8": 420, "../utils": 421 }], 398: [function (require, module, exports) {
  41526. 'use strict';
  41527. var compressions = require('../compressions');
  41528. var ZipFileWorker = require('./ZipFileWorker');
  41529. /**
  41530. * Find the compression to use.
  41531. * @param {String} fileCompression the compression defined at the file level, if any.
  41532. * @param {String} zipCompression the compression defined at the load() level.
  41533. * @return {Object} the compression object to use.
  41534. */
  41535. var getCompression = function getCompression(fileCompression, zipCompression) {
  41536. var compressionName = fileCompression || zipCompression;
  41537. var compression = compressions[compressionName];
  41538. if (!compression) {
  41539. throw new Error(compressionName + " is not a valid compression method !");
  41540. }
  41541. return compression;
  41542. };
  41543. /**
  41544. * Create a worker to generate a zip file.
  41545. * @param {JSZip} zip the JSZip instance at the right root level.
  41546. * @param {Object} options to generate the zip file.
  41547. * @param {String} comment the comment to use.
  41548. */
  41549. exports.generateWorker = function (zip, options, comment) {
  41550. var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName);
  41551. var entriesCount = 0;
  41552. try {
  41553. zip.forEach(function (relativePath, file) {
  41554. entriesCount++;
  41555. var compression = getCompression(file.options.compression, options.compression);
  41556. var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};
  41557. var dir = file.dir,
  41558. date = file.date;
  41559. file._compressWorker(compression, compressionOptions).withStreamInfo("file", {
  41560. name: relativePath,
  41561. dir: dir,
  41562. date: date,
  41563. comment: file.comment || "",
  41564. unixPermissions: file.unixPermissions,
  41565. dosPermissions: file.dosPermissions
  41566. }).pipe(zipFileWorker);
  41567. });
  41568. zipFileWorker.entriesCount = entriesCount;
  41569. } catch (e) {
  41570. zipFileWorker.error(e);
  41571. }
  41572. return zipFileWorker;
  41573. };
  41574. }, { "../compressions": 392, "./ZipFileWorker": 397 }], 399: [function (require, module, exports) {
  41575. 'use strict';
  41576. /**
  41577. * Representation a of zip file in js
  41578. * @constructor
  41579. */
  41580. function JSZip() {
  41581. // if this constructor is used without `new`, it adds `new` before itself:
  41582. if (!(this instanceof JSZip)) {
  41583. return new JSZip();
  41584. }
  41585. if (arguments.length) {
  41586. throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
  41587. } // object containing the files :
  41588. // {
  41589. // "folder/" : {...},
  41590. // "folder/data.txt" : {...}
  41591. // }
  41592. this.files = {};
  41593. this.comment = null; // Where we are in the hierarchy
  41594. this.root = "";
  41595. this.clone = function () {
  41596. var newObj = new JSZip();
  41597. for (var i in this) {
  41598. if (typeof this[i] !== "function") {
  41599. newObj[i] = this[i];
  41600. }
  41601. }
  41602. return newObj;
  41603. };
  41604. }
  41605. JSZip.prototype = require('./object');
  41606. JSZip.prototype.loadAsync = require('./load');
  41607. JSZip.support = require('./support');
  41608. JSZip.defaults = require('./defaults'); // TODO find a better way to handle this version,
  41609. // a require('package.json').version doesn't work with webpack, see #327
  41610. JSZip.version = "3.5.0";
  41611. JSZip.loadAsync = function (content, options) {
  41612. return new JSZip().loadAsync(content, options);
  41613. };
  41614. JSZip.external = require("./external");
  41615. module.exports = JSZip;
  41616. }, { "./defaults": 394, "./external": 395, "./load": 400, "./object": 404, "./support": 419 }], 400: [function (require, module, exports) {
  41617. 'use strict';
  41618. var utils = require('./utils');
  41619. var external = require("./external");
  41620. var utf8 = require('./utf8');
  41621. var utils = require('./utils');
  41622. var ZipEntries = require('./zipEntries');
  41623. var Crc32Probe = require('./stream/Crc32Probe');
  41624. var nodejsUtils = require("./nodejsUtils");
  41625. /**
  41626. * Check the CRC32 of an entry.
  41627. * @param {ZipEntry} zipEntry the zip entry to check.
  41628. * @return {Promise} the result.
  41629. */
  41630. function checkEntryCRC32(zipEntry) {
  41631. return new external.Promise(function (resolve, reject) {
  41632. var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
  41633. worker.on("error", function (e) {
  41634. reject(e);
  41635. }).on("end", function () {
  41636. if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {
  41637. reject(new Error("Corrupted zip : CRC32 mismatch"));
  41638. } else {
  41639. resolve();
  41640. }
  41641. }).resume();
  41642. });
  41643. }
  41644. module.exports = function (data, options) {
  41645. var zip = this;
  41646. options = utils.extend(options || {}, {
  41647. base64: false,
  41648. checkCRC32: false,
  41649. optimizedBinaryString: false,
  41650. createFolders: false,
  41651. decodeFileName: utf8.utf8decode
  41652. });
  41653. if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
  41654. return external.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file."));
  41655. }
  41656. return utils.prepareContent("the loaded zip file", data, true, options.optimizedBinaryString, options.base64).then(function (data) {
  41657. var zipEntries = new ZipEntries(options);
  41658. zipEntries.load(data);
  41659. return zipEntries;
  41660. }).then(function checkCRC32(zipEntries) {
  41661. var promises = [external.Promise.resolve(zipEntries)];
  41662. var files = zipEntries.files;
  41663. if (options.checkCRC32) {
  41664. for (var i = 0; i < files.length; i++) {
  41665. promises.push(checkEntryCRC32(files[i]));
  41666. }
  41667. }
  41668. return external.Promise.all(promises);
  41669. }).then(function addFiles(results) {
  41670. var zipEntries = results.shift();
  41671. var files = zipEntries.files;
  41672. for (var i = 0; i < files.length; i++) {
  41673. var input = files[i];
  41674. zip.file(input.fileNameStr, input.decompressed, {
  41675. binary: true,
  41676. optimizedBinaryString: true,
  41677. date: input.date,
  41678. dir: input.dir,
  41679. comment: input.fileCommentStr.length ? input.fileCommentStr : null,
  41680. unixPermissions: input.unixPermissions,
  41681. dosPermissions: input.dosPermissions,
  41682. createFolders: options.createFolders
  41683. });
  41684. }
  41685. if (zipEntries.zipComment.length) {
  41686. zip.comment = zipEntries.zipComment;
  41687. }
  41688. return zip;
  41689. });
  41690. };
  41691. }, { "./external": 395, "./nodejsUtils": 403, "./stream/Crc32Probe": 414, "./utf8": 420, "./utils": 421, "./zipEntries": 422 }], 401: [function (require, module, exports) {
  41692. "use strict";
  41693. var utils = require('../utils');
  41694. var GenericWorker = require('../stream/GenericWorker');
  41695. /**
  41696. * A worker that use a nodejs stream as source.
  41697. * @constructor
  41698. * @param {String} filename the name of the file entry for this stream.
  41699. * @param {Readable} stream the nodejs stream.
  41700. */
  41701. function NodejsStreamInputAdapter(filename, stream) {
  41702. GenericWorker.call(this, "Nodejs stream input adapter for " + filename);
  41703. this._upstreamEnded = false;
  41704. this._bindStream(stream);
  41705. }
  41706. utils.inherits(NodejsStreamInputAdapter, GenericWorker);
  41707. /**
  41708. * Prepare the stream and bind the callbacks on it.
  41709. * Do this ASAP on node 0.10 ! A lazy binding doesn't always work.
  41710. * @param {Stream} stream the nodejs stream to use.
  41711. */
  41712. NodejsStreamInputAdapter.prototype._bindStream = function (stream) {
  41713. var self = this;
  41714. this._stream = stream;
  41715. stream.pause();
  41716. stream.on("data", function (chunk) {
  41717. self.push({
  41718. data: chunk,
  41719. meta: {
  41720. percent: 0
  41721. }
  41722. });
  41723. }).on("error", function (e) {
  41724. if (self.isPaused) {
  41725. this.generatedError = e;
  41726. } else {
  41727. self.error(e);
  41728. }
  41729. }).on("end", function () {
  41730. if (self.isPaused) {
  41731. self._upstreamEnded = true;
  41732. } else {
  41733. self.end();
  41734. }
  41735. });
  41736. };
  41737. NodejsStreamInputAdapter.prototype.pause = function () {
  41738. if (!GenericWorker.prototype.pause.call(this)) {
  41739. return false;
  41740. }
  41741. this._stream.pause();
  41742. return true;
  41743. };
  41744. NodejsStreamInputAdapter.prototype.resume = function () {
  41745. if (!GenericWorker.prototype.resume.call(this)) {
  41746. return false;
  41747. }
  41748. if (this._upstreamEnded) {
  41749. this.end();
  41750. } else {
  41751. this._stream.resume();
  41752. }
  41753. return true;
  41754. };
  41755. module.exports = NodejsStreamInputAdapter;
  41756. }, { "../stream/GenericWorker": 417, "../utils": 421 }], 402: [function (require, module, exports) {
  41757. 'use strict';
  41758. var Readable = require('readable-stream').Readable;
  41759. var utils = require('../utils');
  41760. utils.inherits(NodejsStreamOutputAdapter, Readable);
  41761. /**
  41762. * A nodejs stream using a worker as source.
  41763. * @see the SourceWrapper in http://nodejs.org/api/stream.html
  41764. * @constructor
  41765. * @param {StreamHelper} helper the helper wrapping the worker
  41766. * @param {Object} options the nodejs stream options
  41767. * @param {Function} updateCb the update callback.
  41768. */
  41769. function NodejsStreamOutputAdapter(helper, options, updateCb) {
  41770. Readable.call(this, options);
  41771. this._helper = helper;
  41772. var self = this;
  41773. helper.on("data", function (data, meta) {
  41774. if (!self.push(data)) {
  41775. self._helper.pause();
  41776. }
  41777. if (updateCb) {
  41778. updateCb(meta);
  41779. }
  41780. }).on("error", function (e) {
  41781. self.emit('error', e);
  41782. }).on("end", function () {
  41783. self.push(null);
  41784. });
  41785. }
  41786. NodejsStreamOutputAdapter.prototype._read = function () {
  41787. this._helper.resume();
  41788. };
  41789. module.exports = NodejsStreamOutputAdapter;
  41790. }, { "../utils": 421, "readable-stream": 405 }], 403: [function (require, module, exports) {
  41791. (function (Buffer) {
  41792. 'use strict';
  41793. module.exports = {
  41794. /**
  41795. * True if this is running in Nodejs, will be undefined in a browser.
  41796. * In a browser, browserify won't include this file and the whole module
  41797. * will be resolved an empty object.
  41798. */
  41799. isNode: typeof Buffer !== "undefined",
  41800. /**
  41801. * Create a new nodejs Buffer from an existing content.
  41802. * @param {Object} data the data to pass to the constructor.
  41803. * @param {String} encoding the encoding to use.
  41804. * @return {Buffer} a new Buffer.
  41805. */
  41806. newBufferFrom: function newBufferFrom(data, encoding) {
  41807. if (Buffer.from && Buffer.from !== Uint8Array.from) {
  41808. return Buffer.from(data, encoding);
  41809. } else {
  41810. if (typeof data === "number") {
  41811. // Safeguard for old Node.js versions. On newer versions,
  41812. // Buffer.from(number) / Buffer(number, encoding) already throw.
  41813. throw new Error("The \"data\" argument must not be a number");
  41814. }
  41815. return new Buffer(data, encoding);
  41816. }
  41817. },
  41818. /**
  41819. * Create a new nodejs Buffer with the specified size.
  41820. * @param {Integer} size the size of the buffer.
  41821. * @return {Buffer} a new Buffer.
  41822. */
  41823. allocBuffer: function allocBuffer(size) {
  41824. if (Buffer.alloc) {
  41825. return Buffer.alloc(size);
  41826. } else {
  41827. var buf = new Buffer(size);
  41828. buf.fill(0);
  41829. return buf;
  41830. }
  41831. },
  41832. /**
  41833. * Find out if an object is a Buffer.
  41834. * @param {Object} b the object to test.
  41835. * @return {Boolean} true if the object is a Buffer, false otherwise.
  41836. */
  41837. isBuffer: function isBuffer(b) {
  41838. return Buffer.isBuffer(b);
  41839. },
  41840. isStream: function isStream(obj) {
  41841. return obj && typeof obj.on === "function" && typeof obj.pause === "function" && typeof obj.resume === "function";
  41842. }
  41843. };
  41844. }).call(this, require("buffer").Buffer)
  41845. }, { "buffer": 216 }], 404: [function (require, module, exports) {
  41846. 'use strict';
  41847. var utf8 = require('./utf8');
  41848. var utils = require('./utils');
  41849. var GenericWorker = require('./stream/GenericWorker');
  41850. var StreamHelper = require('./stream/StreamHelper');
  41851. var defaults = require('./defaults');
  41852. var CompressedObject = require('./compressedObject');
  41853. var ZipObject = require('./zipObject');
  41854. var generate = require("./generate");
  41855. var nodejsUtils = require("./nodejsUtils");
  41856. var NodejsStreamInputAdapter = require("./nodejs/NodejsStreamInputAdapter");
  41857. /**
  41858. * Add a file in the current folder.
  41859. * @private
  41860. * @param {string} name the name of the file
  41861. * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file
  41862. * @param {Object} originalOptions the options of the file
  41863. * @return {Object} the new file.
  41864. */
  41865. var fileAdd = function fileAdd(name, data, originalOptions) {
  41866. // be sure sub folders exist
  41867. var dataType = utils.getTypeOf(data),
  41868. parent;
  41869. /*
  41870. * Correct options.
  41871. */
  41872. var o = utils.extend(originalOptions || {}, defaults);
  41873. o.date = o.date || new Date();
  41874. if (o.compression !== null) {
  41875. o.compression = o.compression.toUpperCase();
  41876. }
  41877. if (typeof o.unixPermissions === "string") {
  41878. o.unixPermissions = parseInt(o.unixPermissions, 8);
  41879. } // UNX_IFDIR 0040000 see zipinfo.c
  41880. if (o.unixPermissions && o.unixPermissions & 0x4000) {
  41881. o.dir = true;
  41882. } // Bit 4 Directory
  41883. if (o.dosPermissions && o.dosPermissions & 0x0010) {
  41884. o.dir = true;
  41885. }
  41886. if (o.dir) {
  41887. name = forceTrailingSlash(name);
  41888. }
  41889. if (o.createFolders && (parent = parentFolder(name))) {
  41890. folderAdd.call(this, parent, true);
  41891. }
  41892. var isUnicodeString = dataType === "string" && o.binary === false && o.base64 === false;
  41893. if (!originalOptions || typeof originalOptions.binary === "undefined") {
  41894. o.binary = !isUnicodeString;
  41895. }
  41896. var isCompressedEmpty = data instanceof CompressedObject && data.uncompressedSize === 0;
  41897. if (isCompressedEmpty || o.dir || !data || data.length === 0) {
  41898. o.base64 = false;
  41899. o.binary = true;
  41900. data = "";
  41901. o.compression = "STORE";
  41902. dataType = "string";
  41903. }
  41904. /*
  41905. * Convert content to fit.
  41906. */
  41907. var zipObjectContent = null;
  41908. if (data instanceof CompressedObject || data instanceof GenericWorker) {
  41909. zipObjectContent = data;
  41910. } else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
  41911. zipObjectContent = new NodejsStreamInputAdapter(name, data);
  41912. } else {
  41913. zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64);
  41914. }
  41915. var object = new ZipObject(name, zipObjectContent, o);
  41916. this.files[name] = object;
  41917. /*
  41918. TODO: we can't throw an exception because we have async promises
  41919. (we can have a promise of a Date() for example) but returning a
  41920. promise is useless because file(name, data) returns the JSZip
  41921. object for chaining. Should we break that to allow the user
  41922. to catch the error ?
  41923. return external.Promise.resolve(zipObjectContent)
  41924. .then(function () {
  41925. return object;
  41926. });
  41927. */
  41928. };
  41929. /**
  41930. * Find the parent folder of the path.
  41931. * @private
  41932. * @param {string} path the path to use
  41933. * @return {string} the parent folder, or ""
  41934. */
  41935. var parentFolder = function parentFolder(path) {
  41936. if (path.slice(-1) === '/') {
  41937. path = path.substring(0, path.length - 1);
  41938. }
  41939. var lastSlash = path.lastIndexOf('/');
  41940. return lastSlash > 0 ? path.substring(0, lastSlash) : "";
  41941. };
  41942. /**
  41943. * Returns the path with a slash at the end.
  41944. * @private
  41945. * @param {String} path the path to check.
  41946. * @return {String} the path with a trailing slash.
  41947. */
  41948. var forceTrailingSlash = function forceTrailingSlash(path) {
  41949. // Check the name ends with a /
  41950. if (path.slice(-1) !== "/") {
  41951. path += "/"; // IE doesn't like substr(-1)
  41952. }
  41953. return path;
  41954. };
  41955. /**
  41956. * Add a (sub) folder in the current folder.
  41957. * @private
  41958. * @param {string} name the folder's name
  41959. * @param {boolean=} [createFolders] If true, automatically create sub
  41960. * folders. Defaults to false.
  41961. * @return {Object} the new folder.
  41962. */
  41963. var folderAdd = function folderAdd(name, createFolders) {
  41964. createFolders = typeof createFolders !== 'undefined' ? createFolders : defaults.createFolders;
  41965. name = forceTrailingSlash(name); // Does this folder already exist?
  41966. if (!this.files[name]) {
  41967. fileAdd.call(this, name, null, {
  41968. dir: true,
  41969. createFolders: createFolders
  41970. });
  41971. }
  41972. return this.files[name];
  41973. };
  41974. /**
  41975. * Cross-window, cross-Node-context regular expression detection
  41976. * @param {Object} object Anything
  41977. * @return {Boolean} true if the object is a regular expression,
  41978. * false otherwise
  41979. */
  41980. function isRegExp(object) {
  41981. return Object.prototype.toString.call(object) === "[object RegExp]";
  41982. } // return the actual prototype of JSZip
  41983. var out = {
  41984. /**
  41985. * @see loadAsync
  41986. */
  41987. load: function load() {
  41988. throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
  41989. },
  41990. /**
  41991. * Call a callback function for each entry at this folder level.
  41992. * @param {Function} cb the callback function:
  41993. * function (relativePath, file) {...}
  41994. * It takes 2 arguments : the relative path and the file.
  41995. */
  41996. forEach: function forEach(cb) {
  41997. var filename, relativePath, file;
  41998. for (filename in this.files) {
  41999. if (!this.files.hasOwnProperty(filename)) {
  42000. continue;
  42001. }
  42002. file = this.files[filename];
  42003. relativePath = filename.slice(this.root.length, filename.length);
  42004. if (relativePath && filename.slice(0, this.root.length) === this.root) {
  42005. // the file is in the current root
  42006. cb(relativePath, file); // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn...
  42007. }
  42008. }
  42009. },
  42010. /**
  42011. * Filter nested files/folders with the specified function.
  42012. * @param {Function} search the predicate to use :
  42013. * function (relativePath, file) {...}
  42014. * It takes 2 arguments : the relative path and the file.
  42015. * @return {Array} An array of matching elements.
  42016. */
  42017. filter: function filter(search) {
  42018. var result = [];
  42019. this.forEach(function (relativePath, entry) {
  42020. if (search(relativePath, entry)) {
  42021. // the file matches the function
  42022. result.push(entry);
  42023. }
  42024. });
  42025. return result;
  42026. },
  42027. /**
  42028. * Add a file to the zip file, or search a file.
  42029. * @param {string|RegExp} name The name of the file to add (if data is defined),
  42030. * the name of the file to find (if no data) or a regex to match files.
  42031. * @param {String|ArrayBuffer|Uint8Array|Buffer} data The file data, either raw or base64 encoded
  42032. * @param {Object} o File options
  42033. * @return {JSZip|Object|Array} this JSZip object (when adding a file),
  42034. * a file (when searching by string) or an array of files (when searching by regex).
  42035. */
  42036. file: function file(name, data, o) {
  42037. if (arguments.length === 1) {
  42038. if (isRegExp(name)) {
  42039. var regexp = name;
  42040. return this.filter(function (relativePath, file) {
  42041. return !file.dir && regexp.test(relativePath);
  42042. });
  42043. } else {
  42044. // text
  42045. var obj = this.files[this.root + name];
  42046. if (obj && !obj.dir) {
  42047. return obj;
  42048. } else {
  42049. return null;
  42050. }
  42051. }
  42052. } else {
  42053. // more than one argument : we have data !
  42054. name = this.root + name;
  42055. fileAdd.call(this, name, data, o);
  42056. }
  42057. return this;
  42058. },
  42059. /**
  42060. * Add a directory to the zip file, or search.
  42061. * @param {String|RegExp} arg The name of the directory to add, or a regex to search folders.
  42062. * @return {JSZip} an object with the new directory as the root, or an array containing matching folders.
  42063. */
  42064. folder: function folder(arg) {
  42065. if (!arg) {
  42066. return this;
  42067. }
  42068. if (isRegExp(arg)) {
  42069. return this.filter(function (relativePath, file) {
  42070. return file.dir && arg.test(relativePath);
  42071. });
  42072. } // else, name is a new folder
  42073. var name = this.root + arg;
  42074. var newFolder = folderAdd.call(this, name); // Allow chaining by returning a new object with this folder as the root
  42075. var ret = this.clone();
  42076. ret.root = newFolder.name;
  42077. return ret;
  42078. },
  42079. /**
  42080. * Delete a file, or a directory and all sub-files, from the zip
  42081. * @param {string} name the name of the file to delete
  42082. * @return {JSZip} this JSZip object
  42083. */
  42084. remove: function remove(name) {
  42085. name = this.root + name;
  42086. var file = this.files[name];
  42087. if (!file) {
  42088. // Look for any folders
  42089. if (name.slice(-1) !== "/") {
  42090. name += "/";
  42091. }
  42092. file = this.files[name];
  42093. }
  42094. if (file && !file.dir) {
  42095. // file
  42096. delete this.files[name];
  42097. } else {
  42098. // maybe a folder, delete recursively
  42099. var kids = this.filter(function (relativePath, file) {
  42100. return file.name.slice(0, name.length) === name;
  42101. });
  42102. for (var i = 0; i < kids.length; i++) {
  42103. delete this.files[kids[i].name];
  42104. }
  42105. }
  42106. return this;
  42107. },
  42108. /**
  42109. * Generate the complete zip file
  42110. * @param {Object} options the options to generate the zip file :
  42111. * - compression, "STORE" by default.
  42112. * - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
  42113. * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file
  42114. */
  42115. generate: function generate(options) {
  42116. throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
  42117. },
  42118. /**
  42119. * Generate the complete zip file as an internal stream.
  42120. * @param {Object} options the options to generate the zip file :
  42121. * - compression, "STORE" by default.
  42122. * - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
  42123. * @return {StreamHelper} the streamed zip file.
  42124. */
  42125. generateInternalStream: function generateInternalStream(options) {
  42126. var worker,
  42127. opts = {};
  42128. try {
  42129. opts = utils.extend(options || {}, {
  42130. streamFiles: false,
  42131. compression: "STORE",
  42132. compressionOptions: null,
  42133. type: "",
  42134. platform: "DOS",
  42135. comment: null,
  42136. mimeType: 'application/zip',
  42137. encodeFileName: utf8.utf8encode
  42138. });
  42139. opts.type = opts.type.toLowerCase();
  42140. opts.compression = opts.compression.toUpperCase(); // "binarystring" is preferred but the internals use "string".
  42141. if (opts.type === "binarystring") {
  42142. opts.type = "string";
  42143. }
  42144. if (!opts.type) {
  42145. throw new Error("No output type specified.");
  42146. }
  42147. utils.checkSupport(opts.type); // accept nodejs `process.platform`
  42148. if (opts.platform === 'darwin' || opts.platform === 'freebsd' || opts.platform === 'linux' || opts.platform === 'sunos') {
  42149. opts.platform = "UNIX";
  42150. }
  42151. if (opts.platform === 'win32') {
  42152. opts.platform = "DOS";
  42153. }
  42154. var comment = opts.comment || this.comment || "";
  42155. worker = generate.generateWorker(this, opts, comment);
  42156. } catch (e) {
  42157. worker = new GenericWorker("error");
  42158. worker.error(e);
  42159. }
  42160. return new StreamHelper(worker, opts.type || "string", opts.mimeType);
  42161. },
  42162. /**
  42163. * Generate the complete zip file asynchronously.
  42164. * @see generateInternalStream
  42165. */
  42166. generateAsync: function generateAsync(options, onUpdate) {
  42167. return this.generateInternalStream(options).accumulate(onUpdate);
  42168. },
  42169. /**
  42170. * Generate the complete zip file asynchronously.
  42171. * @see generateInternalStream
  42172. */
  42173. generateNodeStream: function generateNodeStream(options, onUpdate) {
  42174. options = options || {};
  42175. if (!options.type) {
  42176. options.type = "nodebuffer";
  42177. }
  42178. return this.generateInternalStream(options).toNodejsStream(onUpdate);
  42179. }
  42180. };
  42181. module.exports = out;
  42182. }, { "./compressedObject": 391, "./defaults": 394, "./generate": 398, "./nodejs/NodejsStreamInputAdapter": 401, "./nodejsUtils": 403, "./stream/GenericWorker": 417, "./stream/StreamHelper": 418, "./utf8": 420, "./utils": 421, "./zipObject": 424 }], 405: [function (require, module, exports) {
  42183. "use strict";
  42184. /*
  42185. * This file is used by module bundlers (browserify/webpack/etc) when
  42186. * including a stream implementation. We use "readable-stream" to get a
  42187. * consistent behavior between nodejs versions but bundlers often have a shim
  42188. * for "stream". Using this shim greatly improve the compatibility and greatly
  42189. * reduce the final size of the bundle (only one stream implementation, not
  42190. * two).
  42191. */
  42192. module.exports = require("stream");
  42193. }, { "stream": 506 }], 406: [function (require, module, exports) {
  42194. 'use strict';
  42195. var DataReader = require('./DataReader');
  42196. var utils = require('../utils');
  42197. function ArrayReader(data) {
  42198. DataReader.call(this, data);
  42199. for (var i = 0; i < this.data.length; i++) {
  42200. data[i] = data[i] & 0xFF;
  42201. }
  42202. }
  42203. utils.inherits(ArrayReader, DataReader);
  42204. /**
  42205. * @see DataReader.byteAt
  42206. */
  42207. ArrayReader.prototype.byteAt = function (i) {
  42208. return this.data[this.zero + i];
  42209. };
  42210. /**
  42211. * @see DataReader.lastIndexOfSignature
  42212. */
  42213. ArrayReader.prototype.lastIndexOfSignature = function (sig) {
  42214. var sig0 = sig.charCodeAt(0),
  42215. sig1 = sig.charCodeAt(1),
  42216. sig2 = sig.charCodeAt(2),
  42217. sig3 = sig.charCodeAt(3);
  42218. for (var i = this.length - 4; i >= 0; --i) {
  42219. if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {
  42220. return i - this.zero;
  42221. }
  42222. }
  42223. return -1;
  42224. };
  42225. /**
  42226. * @see DataReader.readAndCheckSignature
  42227. */
  42228. ArrayReader.prototype.readAndCheckSignature = function (sig) {
  42229. var sig0 = sig.charCodeAt(0),
  42230. sig1 = sig.charCodeAt(1),
  42231. sig2 = sig.charCodeAt(2),
  42232. sig3 = sig.charCodeAt(3),
  42233. data = this.readData(4);
  42234. return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3];
  42235. };
  42236. /**
  42237. * @see DataReader.readData
  42238. */
  42239. ArrayReader.prototype.readData = function (size) {
  42240. this.checkOffset(size);
  42241. if (size === 0) {
  42242. return [];
  42243. }
  42244. var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
  42245. this.index += size;
  42246. return result;
  42247. };
  42248. module.exports = ArrayReader;
  42249. }, { "../utils": 421, "./DataReader": 407 }], 407: [function (require, module, exports) {
  42250. 'use strict';
  42251. var utils = require('../utils');
  42252. function DataReader(data) {
  42253. this.data = data; // type : see implementation
  42254. this.length = data.length;
  42255. this.index = 0;
  42256. this.zero = 0;
  42257. }
  42258. DataReader.prototype = {
  42259. /**
  42260. * Check that the offset will not go too far.
  42261. * @param {string} offset the additional offset to check.
  42262. * @throws {Error} an Error if the offset is out of bounds.
  42263. */
  42264. checkOffset: function checkOffset(offset) {
  42265. this.checkIndex(this.index + offset);
  42266. },
  42267. /**
  42268. * Check that the specified index will not be too far.
  42269. * @param {string} newIndex the index to check.
  42270. * @throws {Error} an Error if the index is out of bounds.
  42271. */
  42272. checkIndex: function checkIndex(newIndex) {
  42273. if (this.length < this.zero + newIndex || newIndex < 0) {
  42274. throw new Error("End of data reached (data length = " + this.length + ", asked index = " + newIndex + "). Corrupted zip ?");
  42275. }
  42276. },
  42277. /**
  42278. * Change the index.
  42279. * @param {number} newIndex The new index.
  42280. * @throws {Error} if the new index is out of the data.
  42281. */
  42282. setIndex: function setIndex(newIndex) {
  42283. this.checkIndex(newIndex);
  42284. this.index = newIndex;
  42285. },
  42286. /**
  42287. * Skip the next n bytes.
  42288. * @param {number} n the number of bytes to skip.
  42289. * @throws {Error} if the new index is out of the data.
  42290. */
  42291. skip: function skip(n) {
  42292. this.setIndex(this.index + n);
  42293. },
  42294. /**
  42295. * Get the byte at the specified index.
  42296. * @param {number} i the index to use.
  42297. * @return {number} a byte.
  42298. */
  42299. byteAt: function byteAt(i) {// see implementations
  42300. },
  42301. /**
  42302. * Get the next number with a given byte size.
  42303. * @param {number} size the number of bytes to read.
  42304. * @return {number} the corresponding number.
  42305. */
  42306. readInt: function readInt(size) {
  42307. var result = 0,
  42308. i;
  42309. this.checkOffset(size);
  42310. for (i = this.index + size - 1; i >= this.index; i--) {
  42311. result = (result << 8) + this.byteAt(i);
  42312. }
  42313. this.index += size;
  42314. return result;
  42315. },
  42316. /**
  42317. * Get the next string with a given byte size.
  42318. * @param {number} size the number of bytes to read.
  42319. * @return {string} the corresponding string.
  42320. */
  42321. readString: function readString(size) {
  42322. return utils.transformTo("string", this.readData(size));
  42323. },
  42324. /**
  42325. * Get raw data without conversion, <size> bytes.
  42326. * @param {number} size the number of bytes to read.
  42327. * @return {Object} the raw data, implementation specific.
  42328. */
  42329. readData: function readData(size) {// see implementations
  42330. },
  42331. /**
  42332. * Find the last occurrence of a zip signature (4 bytes).
  42333. * @param {string} sig the signature to find.
  42334. * @return {number} the index of the last occurrence, -1 if not found.
  42335. */
  42336. lastIndexOfSignature: function lastIndexOfSignature(sig) {// see implementations
  42337. },
  42338. /**
  42339. * Read the signature (4 bytes) at the current position and compare it with sig.
  42340. * @param {string} sig the expected signature
  42341. * @return {boolean} true if the signature matches, false otherwise.
  42342. */
  42343. readAndCheckSignature: function readAndCheckSignature(sig) {// see implementations
  42344. },
  42345. /**
  42346. * Get the next date.
  42347. * @return {Date} the date.
  42348. */
  42349. readDate: function readDate() {
  42350. var dostime = this.readInt(4);
  42351. return new Date(Date.UTC((dostime >> 25 & 0x7f) + 1980, // year
  42352. (dostime >> 21 & 0x0f) - 1, // month
  42353. dostime >> 16 & 0x1f, // day
  42354. dostime >> 11 & 0x1f, // hour
  42355. dostime >> 5 & 0x3f, // minute
  42356. (dostime & 0x1f) << 1)); // second
  42357. }
  42358. };
  42359. module.exports = DataReader;
  42360. }, { "../utils": 421 }], 408: [function (require, module, exports) {
  42361. 'use strict';
  42362. var Uint8ArrayReader = require('./Uint8ArrayReader');
  42363. var utils = require('../utils');
  42364. function NodeBufferReader(data) {
  42365. Uint8ArrayReader.call(this, data);
  42366. }
  42367. utils.inherits(NodeBufferReader, Uint8ArrayReader);
  42368. /**
  42369. * @see DataReader.readData
  42370. */
  42371. NodeBufferReader.prototype.readData = function (size) {
  42372. this.checkOffset(size);
  42373. var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
  42374. this.index += size;
  42375. return result;
  42376. };
  42377. module.exports = NodeBufferReader;
  42378. }, { "../utils": 421, "./Uint8ArrayReader": 410 }], 409: [function (require, module, exports) {
  42379. 'use strict';
  42380. var DataReader = require('./DataReader');
  42381. var utils = require('../utils');
  42382. function StringReader(data) {
  42383. DataReader.call(this, data);
  42384. }
  42385. utils.inherits(StringReader, DataReader);
  42386. /**
  42387. * @see DataReader.byteAt
  42388. */
  42389. StringReader.prototype.byteAt = function (i) {
  42390. return this.data.charCodeAt(this.zero + i);
  42391. };
  42392. /**
  42393. * @see DataReader.lastIndexOfSignature
  42394. */
  42395. StringReader.prototype.lastIndexOfSignature = function (sig) {
  42396. return this.data.lastIndexOf(sig) - this.zero;
  42397. };
  42398. /**
  42399. * @see DataReader.readAndCheckSignature
  42400. */
  42401. StringReader.prototype.readAndCheckSignature = function (sig) {
  42402. var data = this.readData(4);
  42403. return sig === data;
  42404. };
  42405. /**
  42406. * @see DataReader.readData
  42407. */
  42408. StringReader.prototype.readData = function (size) {
  42409. this.checkOffset(size); // this will work because the constructor applied the "& 0xff" mask.
  42410. var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
  42411. this.index += size;
  42412. return result;
  42413. };
  42414. module.exports = StringReader;
  42415. }, { "../utils": 421, "./DataReader": 407 }], 410: [function (require, module, exports) {
  42416. 'use strict';
  42417. var ArrayReader = require('./ArrayReader');
  42418. var utils = require('../utils');
  42419. function Uint8ArrayReader(data) {
  42420. ArrayReader.call(this, data);
  42421. }
  42422. utils.inherits(Uint8ArrayReader, ArrayReader);
  42423. /**
  42424. * @see DataReader.readData
  42425. */
  42426. Uint8ArrayReader.prototype.readData = function (size) {
  42427. this.checkOffset(size);
  42428. if (size === 0) {
  42429. // in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].
  42430. return new Uint8Array(0);
  42431. }
  42432. var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);
  42433. this.index += size;
  42434. return result;
  42435. };
  42436. module.exports = Uint8ArrayReader;
  42437. }, { "../utils": 421, "./ArrayReader": 406 }], 411: [function (require, module, exports) {
  42438. 'use strict';
  42439. var utils = require('../utils');
  42440. var support = require('../support');
  42441. var ArrayReader = require('./ArrayReader');
  42442. var StringReader = require('./StringReader');
  42443. var NodeBufferReader = require('./NodeBufferReader');
  42444. var Uint8ArrayReader = require('./Uint8ArrayReader');
  42445. /**
  42446. * Create a reader adapted to the data.
  42447. * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read.
  42448. * @return {DataReader} the data reader.
  42449. */
  42450. module.exports = function (data) {
  42451. var type = utils.getTypeOf(data);
  42452. utils.checkSupport(type);
  42453. if (type === "string" && !support.uint8array) {
  42454. return new StringReader(data);
  42455. }
  42456. if (type === "nodebuffer") {
  42457. return new NodeBufferReader(data);
  42458. }
  42459. if (support.uint8array) {
  42460. return new Uint8ArrayReader(utils.transformTo("uint8array", data));
  42461. }
  42462. return new ArrayReader(utils.transformTo("array", data));
  42463. };
  42464. }, { "../support": 419, "../utils": 421, "./ArrayReader": 406, "./NodeBufferReader": 408, "./StringReader": 409, "./Uint8ArrayReader": 410 }], 412: [function (require, module, exports) {
  42465. 'use strict';
  42466. exports.LOCAL_FILE_HEADER = "PK\x03\x04";
  42467. exports.CENTRAL_FILE_HEADER = "PK\x01\x02";
  42468. exports.CENTRAL_DIRECTORY_END = "PK\x05\x06";
  42469. exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x06\x07";
  42470. exports.ZIP64_CENTRAL_DIRECTORY_END = "PK\x06\x06";
  42471. exports.DATA_DESCRIPTOR = "PK\x07\x08";
  42472. }, {}], 413: [function (require, module, exports) {
  42473. 'use strict';
  42474. var GenericWorker = require('./GenericWorker');
  42475. var utils = require('../utils');
  42476. /**
  42477. * A worker which convert chunks to a specified type.
  42478. * @constructor
  42479. * @param {String} destType the destination type.
  42480. */
  42481. function ConvertWorker(destType) {
  42482. GenericWorker.call(this, "ConvertWorker to " + destType);
  42483. this.destType = destType;
  42484. }
  42485. utils.inherits(ConvertWorker, GenericWorker);
  42486. /**
  42487. * @see GenericWorker.processChunk
  42488. */
  42489. ConvertWorker.prototype.processChunk = function (chunk) {
  42490. this.push({
  42491. data: utils.transformTo(this.destType, chunk.data),
  42492. meta: chunk.meta
  42493. });
  42494. };
  42495. module.exports = ConvertWorker;
  42496. }, { "../utils": 421, "./GenericWorker": 417 }], 414: [function (require, module, exports) {
  42497. 'use strict';
  42498. var GenericWorker = require('./GenericWorker');
  42499. var crc32 = require('../crc32');
  42500. var utils = require('../utils');
  42501. /**
  42502. * A worker which calculate the crc32 of the data flowing through.
  42503. * @constructor
  42504. */
  42505. function Crc32Probe() {
  42506. GenericWorker.call(this, "Crc32Probe");
  42507. this.withStreamInfo("crc32", 0);
  42508. }
  42509. utils.inherits(Crc32Probe, GenericWorker);
  42510. /**
  42511. * @see GenericWorker.processChunk
  42512. */
  42513. Crc32Probe.prototype.processChunk = function (chunk) {
  42514. this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0);
  42515. this.push(chunk);
  42516. };
  42517. module.exports = Crc32Probe;
  42518. }, { "../crc32": 393, "../utils": 421, "./GenericWorker": 417 }], 415: [function (require, module, exports) {
  42519. 'use strict';
  42520. var utils = require('../utils');
  42521. var GenericWorker = require('./GenericWorker');
  42522. /**
  42523. * A worker which calculate the total length of the data flowing through.
  42524. * @constructor
  42525. * @param {String} propName the name used to expose the length
  42526. */
  42527. function DataLengthProbe(propName) {
  42528. GenericWorker.call(this, "DataLengthProbe for " + propName);
  42529. this.propName = propName;
  42530. this.withStreamInfo(propName, 0);
  42531. }
  42532. utils.inherits(DataLengthProbe, GenericWorker);
  42533. /**
  42534. * @see GenericWorker.processChunk
  42535. */
  42536. DataLengthProbe.prototype.processChunk = function (chunk) {
  42537. if (chunk) {
  42538. var length = this.streamInfo[this.propName] || 0;
  42539. this.streamInfo[this.propName] = length + chunk.data.length;
  42540. }
  42541. GenericWorker.prototype.processChunk.call(this, chunk);
  42542. };
  42543. module.exports = DataLengthProbe;
  42544. }, { "../utils": 421, "./GenericWorker": 417 }], 416: [function (require, module, exports) {
  42545. 'use strict';
  42546. var utils = require('../utils');
  42547. var GenericWorker = require('./GenericWorker'); // the size of the generated chunks
  42548. // TODO expose this as a public variable
  42549. var DEFAULT_BLOCK_SIZE = 16 * 1024;
  42550. /**
  42551. * A worker that reads a content and emits chunks.
  42552. * @constructor
  42553. * @param {Promise} dataP the promise of the data to split
  42554. */
  42555. function DataWorker(dataP) {
  42556. GenericWorker.call(this, "DataWorker");
  42557. var self = this;
  42558. this.dataIsReady = false;
  42559. this.index = 0;
  42560. this.max = 0;
  42561. this.data = null;
  42562. this.type = "";
  42563. this._tickScheduled = false;
  42564. dataP.then(function (data) {
  42565. self.dataIsReady = true;
  42566. self.data = data;
  42567. self.max = data && data.length || 0;
  42568. self.type = utils.getTypeOf(data);
  42569. if (!self.isPaused) {
  42570. self._tickAndRepeat();
  42571. }
  42572. }, function (e) {
  42573. self.error(e);
  42574. });
  42575. }
  42576. utils.inherits(DataWorker, GenericWorker);
  42577. /**
  42578. * @see GenericWorker.cleanUp
  42579. */
  42580. DataWorker.prototype.cleanUp = function () {
  42581. GenericWorker.prototype.cleanUp.call(this);
  42582. this.data = null;
  42583. };
  42584. /**
  42585. * @see GenericWorker.resume
  42586. */
  42587. DataWorker.prototype.resume = function () {
  42588. if (!GenericWorker.prototype.resume.call(this)) {
  42589. return false;
  42590. }
  42591. if (!this._tickScheduled && this.dataIsReady) {
  42592. this._tickScheduled = true;
  42593. utils.delay(this._tickAndRepeat, [], this);
  42594. }
  42595. return true;
  42596. };
  42597. /**
  42598. * Trigger a tick a schedule an other call to this function.
  42599. */
  42600. DataWorker.prototype._tickAndRepeat = function () {
  42601. this._tickScheduled = false;
  42602. if (this.isPaused || this.isFinished) {
  42603. return;
  42604. }
  42605. this._tick();
  42606. if (!this.isFinished) {
  42607. utils.delay(this._tickAndRepeat, [], this);
  42608. this._tickScheduled = true;
  42609. }
  42610. };
  42611. /**
  42612. * Read and push a chunk.
  42613. */
  42614. DataWorker.prototype._tick = function () {
  42615. if (this.isPaused || this.isFinished) {
  42616. return false;
  42617. }
  42618. var size = DEFAULT_BLOCK_SIZE;
  42619. var data = null,
  42620. nextIndex = Math.min(this.max, this.index + size);
  42621. if (this.index >= this.max) {
  42622. // EOF
  42623. return this.end();
  42624. } else {
  42625. switch (this.type) {
  42626. case "string":
  42627. data = this.data.substring(this.index, nextIndex);
  42628. break;
  42629. case "uint8array":
  42630. data = this.data.subarray(this.index, nextIndex);
  42631. break;
  42632. case "array":
  42633. case "nodebuffer":
  42634. data = this.data.slice(this.index, nextIndex);
  42635. break;
  42636. }
  42637. this.index = nextIndex;
  42638. return this.push({
  42639. data: data,
  42640. meta: {
  42641. percent: this.max ? this.index / this.max * 100 : 0
  42642. }
  42643. });
  42644. }
  42645. };
  42646. module.exports = DataWorker;
  42647. }, { "../utils": 421, "./GenericWorker": 417 }], 417: [function (require, module, exports) {
  42648. 'use strict';
  42649. /**
  42650. * A worker that does nothing but passing chunks to the next one. This is like
  42651. * a nodejs stream but with some differences. On the good side :
  42652. * - it works on IE 6-9 without any issue / polyfill
  42653. * - it weights less than the full dependencies bundled with browserify
  42654. * - it forwards errors (no need to declare an error handler EVERYWHERE)
  42655. *
  42656. * A chunk is an object with 2 attributes : `meta` and `data`. The former is an
  42657. * object containing anything (`percent` for example), see each worker for more
  42658. * details. The latter is the real data (String, Uint8Array, etc).
  42659. *
  42660. * @constructor
  42661. * @param {String} name the name of the stream (mainly used for debugging purposes)
  42662. */
  42663. function GenericWorker(name) {
  42664. // the name of the worker
  42665. this.name = name || "default"; // an object containing metadata about the workers chain
  42666. this.streamInfo = {}; // an error which happened when the worker was paused
  42667. this.generatedError = null; // an object containing metadata to be merged by this worker into the general metadata
  42668. this.extraStreamInfo = {}; // true if the stream is paused (and should not do anything), false otherwise
  42669. this.isPaused = true; // true if the stream is finished (and should not do anything), false otherwise
  42670. this.isFinished = false; // true if the stream is locked to prevent further structure updates (pipe), false otherwise
  42671. this.isLocked = false; // the event listeners
  42672. this._listeners = {
  42673. 'data': [],
  42674. 'end': [],
  42675. 'error': []
  42676. }; // the previous worker, if any
  42677. this.previous = null;
  42678. }
  42679. GenericWorker.prototype = {
  42680. /**
  42681. * Push a chunk to the next workers.
  42682. * @param {Object} chunk the chunk to push
  42683. */
  42684. push: function push(chunk) {
  42685. this.emit("data", chunk);
  42686. },
  42687. /**
  42688. * End the stream.
  42689. * @return {Boolean} true if this call ended the worker, false otherwise.
  42690. */
  42691. end: function end() {
  42692. if (this.isFinished) {
  42693. return false;
  42694. }
  42695. this.flush();
  42696. try {
  42697. this.emit("end");
  42698. this.cleanUp();
  42699. this.isFinished = true;
  42700. } catch (e) {
  42701. this.emit("error", e);
  42702. }
  42703. return true;
  42704. },
  42705. /**
  42706. * End the stream with an error.
  42707. * @param {Error} e the error which caused the premature end.
  42708. * @return {Boolean} true if this call ended the worker with an error, false otherwise.
  42709. */
  42710. error: function error(e) {
  42711. if (this.isFinished) {
  42712. return false;
  42713. }
  42714. if (this.isPaused) {
  42715. this.generatedError = e;
  42716. } else {
  42717. this.isFinished = true;
  42718. this.emit("error", e); // in the workers chain exploded in the middle of the chain,
  42719. // the error event will go downward but we also need to notify
  42720. // workers upward that there has been an error.
  42721. if (this.previous) {
  42722. this.previous.error(e);
  42723. }
  42724. this.cleanUp();
  42725. }
  42726. return true;
  42727. },
  42728. /**
  42729. * Add a callback on an event.
  42730. * @param {String} name the name of the event (data, end, error)
  42731. * @param {Function} listener the function to call when the event is triggered
  42732. * @return {GenericWorker} the current object for chainability
  42733. */
  42734. on: function on(name, listener) {
  42735. this._listeners[name].push(listener);
  42736. return this;
  42737. },
  42738. /**
  42739. * Clean any references when a worker is ending.
  42740. */
  42741. cleanUp: function cleanUp() {
  42742. this.streamInfo = this.generatedError = this.extraStreamInfo = null;
  42743. this._listeners = [];
  42744. },
  42745. /**
  42746. * Trigger an event. This will call registered callback with the provided arg.
  42747. * @param {String} name the name of the event (data, end, error)
  42748. * @param {Object} arg the argument to call the callback with.
  42749. */
  42750. emit: function emit(name, arg) {
  42751. if (this._listeners[name]) {
  42752. for (var i = 0; i < this._listeners[name].length; i++) {
  42753. this._listeners[name][i].call(this, arg);
  42754. }
  42755. }
  42756. },
  42757. /**
  42758. * Chain a worker with an other.
  42759. * @param {Worker} next the worker receiving events from the current one.
  42760. * @return {worker} the next worker for chainability
  42761. */
  42762. pipe: function pipe(next) {
  42763. return next.registerPrevious(this);
  42764. },
  42765. /**
  42766. * Same as `pipe` in the other direction.
  42767. * Using an API with `pipe(next)` is very easy.
  42768. * Implementing the API with the point of view of the next one registering
  42769. * a source is easier, see the ZipFileWorker.
  42770. * @param {Worker} previous the previous worker, sending events to this one
  42771. * @return {Worker} the current worker for chainability
  42772. */
  42773. registerPrevious: function registerPrevious(previous) {
  42774. if (this.isLocked) {
  42775. throw new Error("The stream '" + this + "' has already been used.");
  42776. } // sharing the streamInfo...
  42777. this.streamInfo = previous.streamInfo; // ... and adding our own bits
  42778. this.mergeStreamInfo();
  42779. this.previous = previous;
  42780. var self = this;
  42781. previous.on('data', function (chunk) {
  42782. self.processChunk(chunk);
  42783. });
  42784. previous.on('end', function () {
  42785. self.end();
  42786. });
  42787. previous.on('error', function (e) {
  42788. self.error(e);
  42789. });
  42790. return this;
  42791. },
  42792. /**
  42793. * Pause the stream so it doesn't send events anymore.
  42794. * @return {Boolean} true if this call paused the worker, false otherwise.
  42795. */
  42796. pause: function pause() {
  42797. if (this.isPaused || this.isFinished) {
  42798. return false;
  42799. }
  42800. this.isPaused = true;
  42801. if (this.previous) {
  42802. this.previous.pause();
  42803. }
  42804. return true;
  42805. },
  42806. /**
  42807. * Resume a paused stream.
  42808. * @return {Boolean} true if this call resumed the worker, false otherwise.
  42809. */
  42810. resume: function resume() {
  42811. if (!this.isPaused || this.isFinished) {
  42812. return false;
  42813. }
  42814. this.isPaused = false; // if true, the worker tried to resume but failed
  42815. var withError = false;
  42816. if (this.generatedError) {
  42817. this.error(this.generatedError);
  42818. withError = true;
  42819. }
  42820. if (this.previous) {
  42821. this.previous.resume();
  42822. }
  42823. return !withError;
  42824. },
  42825. /**
  42826. * Flush any remaining bytes as the stream is ending.
  42827. */
  42828. flush: function flush() { },
  42829. /**
  42830. * Process a chunk. This is usually the method overridden.
  42831. * @param {Object} chunk the chunk to process.
  42832. */
  42833. processChunk: function processChunk(chunk) {
  42834. this.push(chunk);
  42835. },
  42836. /**
  42837. * Add a key/value to be added in the workers chain streamInfo once activated.
  42838. * @param {String} key the key to use
  42839. * @param {Object} value the associated value
  42840. * @return {Worker} the current worker for chainability
  42841. */
  42842. withStreamInfo: function withStreamInfo(key, value) {
  42843. this.extraStreamInfo[key] = value;
  42844. this.mergeStreamInfo();
  42845. return this;
  42846. },
  42847. /**
  42848. * Merge this worker's streamInfo into the chain's streamInfo.
  42849. */
  42850. mergeStreamInfo: function mergeStreamInfo() {
  42851. for (var key in this.extraStreamInfo) {
  42852. if (!this.extraStreamInfo.hasOwnProperty(key)) {
  42853. continue;
  42854. }
  42855. this.streamInfo[key] = this.extraStreamInfo[key];
  42856. }
  42857. },
  42858. /**
  42859. * Lock the stream to prevent further updates on the workers chain.
  42860. * After calling this method, all calls to pipe will fail.
  42861. */
  42862. lock: function lock() {
  42863. if (this.isLocked) {
  42864. throw new Error("The stream '" + this + "' has already been used.");
  42865. }
  42866. this.isLocked = true;
  42867. if (this.previous) {
  42868. this.previous.lock();
  42869. }
  42870. },
  42871. /**
  42872. *
  42873. * Pretty print the workers chain.
  42874. */
  42875. toString: function toString() {
  42876. var me = "Worker " + this.name;
  42877. if (this.previous) {
  42878. return this.previous + " -> " + me;
  42879. } else {
  42880. return me;
  42881. }
  42882. }
  42883. };
  42884. module.exports = GenericWorker;
  42885. }, {}], 418: [function (require, module, exports) {
  42886. (function (Buffer) {
  42887. 'use strict';
  42888. var utils = require('../utils');
  42889. var ConvertWorker = require('./ConvertWorker');
  42890. var GenericWorker = require('./GenericWorker');
  42891. var base64 = require('../base64');
  42892. var support = require("../support");
  42893. var external = require("../external");
  42894. var NodejsStreamOutputAdapter = null;
  42895. if (support.nodestream) {
  42896. try {
  42897. NodejsStreamOutputAdapter = require('../nodejs/NodejsStreamOutputAdapter');
  42898. } catch (e) { }
  42899. }
  42900. /**
  42901. * Apply the final transformation of the data. If the user wants a Blob for
  42902. * example, it's easier to work with an U8intArray and finally do the
  42903. * ArrayBuffer/Blob conversion.
  42904. * @param {String} type the name of the final type
  42905. * @param {String|Uint8Array|Buffer} content the content to transform
  42906. * @param {String} mimeType the mime type of the content, if applicable.
  42907. * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the content in the right format.
  42908. */
  42909. function transformZipOutput(type, content, mimeType) {
  42910. switch (type) {
  42911. case "blob":
  42912. return utils.newBlob(utils.transformTo("arraybuffer", content), mimeType);
  42913. case "base64":
  42914. return base64.encode(content);
  42915. default:
  42916. return utils.transformTo(type, content);
  42917. }
  42918. }
  42919. /**
  42920. * Concatenate an array of data of the given type.
  42921. * @param {String} type the type of the data in the given array.
  42922. * @param {Array} dataArray the array containing the data chunks to concatenate
  42923. * @return {String|Uint8Array|Buffer} the concatenated data
  42924. * @throws Error if the asked type is unsupported
  42925. */
  42926. function concat(type, dataArray) {
  42927. var i,
  42928. index = 0,
  42929. res = null,
  42930. totalLength = 0;
  42931. for (i = 0; i < dataArray.length; i++) {
  42932. totalLength += dataArray[i].length;
  42933. }
  42934. switch (type) {
  42935. case "string":
  42936. return dataArray.join("");
  42937. case "array":
  42938. return Array.prototype.concat.apply([], dataArray);
  42939. case "uint8array":
  42940. res = new Uint8Array(totalLength);
  42941. for (i = 0; i < dataArray.length; i++) {
  42942. res.set(dataArray[i], index);
  42943. index += dataArray[i].length;
  42944. }
  42945. return res;
  42946. case "nodebuffer":
  42947. return Buffer.concat(dataArray);
  42948. default:
  42949. throw new Error("concat : unsupported type '" + type + "'");
  42950. }
  42951. }
  42952. /**
  42953. * Listen a StreamHelper, accumulate its content and concatenate it into a
  42954. * complete block.
  42955. * @param {StreamHelper} helper the helper to use.
  42956. * @param {Function} updateCallback a callback called on each update. Called
  42957. * with one arg :
  42958. * - the metadata linked to the update received.
  42959. * @return Promise the promise for the accumulation.
  42960. */
  42961. function _accumulate(helper, updateCallback) {
  42962. return new external.Promise(function (resolve, reject) {
  42963. var dataArray = [];
  42964. var chunkType = helper._internalType,
  42965. resultType = helper._outputType,
  42966. mimeType = helper._mimeType;
  42967. helper.on('data', function (data, meta) {
  42968. dataArray.push(data);
  42969. if (updateCallback) {
  42970. updateCallback(meta);
  42971. }
  42972. }).on('error', function (err) {
  42973. dataArray = [];
  42974. reject(err);
  42975. }).on('end', function () {
  42976. try {
  42977. var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType);
  42978. resolve(result);
  42979. } catch (e) {
  42980. reject(e);
  42981. }
  42982. dataArray = [];
  42983. }).resume();
  42984. });
  42985. }
  42986. /**
  42987. * An helper to easily use workers outside of JSZip.
  42988. * @constructor
  42989. * @param {Worker} worker the worker to wrap
  42990. * @param {String} outputType the type of data expected by the use
  42991. * @param {String} mimeType the mime type of the content, if applicable.
  42992. */
  42993. function StreamHelper(worker, outputType, mimeType) {
  42994. var internalType = outputType;
  42995. switch (outputType) {
  42996. case "blob":
  42997. case "arraybuffer":
  42998. internalType = "uint8array";
  42999. break;
  43000. case "base64":
  43001. internalType = "string";
  43002. break;
  43003. }
  43004. try {
  43005. // the type used internally
  43006. this._internalType = internalType; // the type used to output results
  43007. this._outputType = outputType; // the mime type
  43008. this._mimeType = mimeType;
  43009. utils.checkSupport(internalType);
  43010. this._worker = worker.pipe(new ConvertWorker(internalType)); // the last workers can be rewired without issues but we need to
  43011. // prevent any updates on previous workers.
  43012. worker.lock();
  43013. } catch (e) {
  43014. this._worker = new GenericWorker("error");
  43015. this._worker.error(e);
  43016. }
  43017. }
  43018. StreamHelper.prototype = {
  43019. /**
  43020. * Listen a StreamHelper, accumulate its content and concatenate it into a
  43021. * complete block.
  43022. * @param {Function} updateCb the update callback.
  43023. * @return Promise the promise for the accumulation.
  43024. */
  43025. accumulate: function accumulate(updateCb) {
  43026. return _accumulate(this, updateCb);
  43027. },
  43028. /**
  43029. * Add a listener on an event triggered on a stream.
  43030. * @param {String} evt the name of the event
  43031. * @param {Function} fn the listener
  43032. * @return {StreamHelper} the current helper.
  43033. */
  43034. on: function on(evt, fn) {
  43035. var self = this;
  43036. if (evt === "data") {
  43037. this._worker.on(evt, function (chunk) {
  43038. fn.call(self, chunk.data, chunk.meta);
  43039. });
  43040. } else {
  43041. this._worker.on(evt, function () {
  43042. utils.delay(fn, arguments, self);
  43043. });
  43044. }
  43045. return this;
  43046. },
  43047. /**
  43048. * Resume the flow of chunks.
  43049. * @return {StreamHelper} the current helper.
  43050. */
  43051. resume: function resume() {
  43052. utils.delay(this._worker.resume, [], this._worker);
  43053. return this;
  43054. },
  43055. /**
  43056. * Pause the flow of chunks.
  43057. * @return {StreamHelper} the current helper.
  43058. */
  43059. pause: function pause() {
  43060. this._worker.pause();
  43061. return this;
  43062. },
  43063. /**
  43064. * Return a nodejs stream for this helper.
  43065. * @param {Function} updateCb the update callback.
  43066. * @return {NodejsStreamOutputAdapter} the nodejs stream.
  43067. */
  43068. toNodejsStream: function toNodejsStream(updateCb) {
  43069. utils.checkSupport("nodestream");
  43070. if (this._outputType !== "nodebuffer") {
  43071. // an object stream containing blob/arraybuffer/uint8array/string
  43072. // is strange and I don't know if it would be useful.
  43073. // I you find this comment and have a good usecase, please open a
  43074. // bug report !
  43075. throw new Error(this._outputType + " is not supported by this method");
  43076. }
  43077. return new NodejsStreamOutputAdapter(this, {
  43078. objectMode: this._outputType !== "nodebuffer"
  43079. }, updateCb);
  43080. }
  43081. };
  43082. module.exports = StreamHelper;
  43083. }).call(this, require("buffer").Buffer)
  43084. }, { "../base64": 390, "../external": 395, "../nodejs/NodejsStreamOutputAdapter": 402, "../support": 419, "../utils": 421, "./ConvertWorker": 413, "./GenericWorker": 417, "buffer": 216 }], 419: [function (require, module, exports) {
  43085. (function (Buffer) {
  43086. 'use strict';
  43087. exports.base64 = true;
  43088. exports.array = true;
  43089. exports.string = true;
  43090. exports.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
  43091. exports.nodebuffer = typeof Buffer !== "undefined"; // contains true if JSZip can read/generate Uint8Array, false otherwise.
  43092. exports.uint8array = typeof Uint8Array !== "undefined";
  43093. if (typeof ArrayBuffer === "undefined") {
  43094. exports.blob = false;
  43095. } else {
  43096. var buffer = new ArrayBuffer(0);
  43097. try {
  43098. exports.blob = new Blob([buffer], {
  43099. type: "application/zip"
  43100. }).size === 0;
  43101. } catch (e) {
  43102. try {
  43103. var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
  43104. var builder = new Builder();
  43105. builder.append(buffer);
  43106. exports.blob = builder.getBlob('application/zip').size === 0;
  43107. } catch (e) {
  43108. exports.blob = false;
  43109. }
  43110. }
  43111. }
  43112. try {
  43113. exports.nodestream = !!require('readable-stream').Readable;
  43114. } catch (e) {
  43115. exports.nodestream = false;
  43116. }
  43117. }).call(this, require("buffer").Buffer)
  43118. }, { "buffer": 216, "readable-stream": 405 }], 420: [function (require, module, exports) {
  43119. 'use strict';
  43120. var utils = require('./utils');
  43121. var support = require('./support');
  43122. var nodejsUtils = require('./nodejsUtils');
  43123. var GenericWorker = require('./stream/GenericWorker');
  43124. /**
  43125. * The following functions come from pako, from pako/lib/utils/strings
  43126. * released under the MIT license, see pako https://github.com/nodeca/pako/
  43127. */
  43128. // Table with utf8 lengths (calculated by first byte of sequence)
  43129. // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
  43130. // because max possible codepoint is 0x10ffff
  43131. var _utf8len = new Array(256);
  43132. for (var i = 0; i < 256; i++) {
  43133. _utf8len[i] = i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1;
  43134. }
  43135. _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
  43136. // convert string to array (typed, when possible)
  43137. var string2buf = function string2buf(str) {
  43138. var buf,
  43139. c,
  43140. c2,
  43141. m_pos,
  43142. i,
  43143. str_len = str.length,
  43144. buf_len = 0; // count binary size
  43145. for (m_pos = 0; m_pos < str_len; m_pos++) {
  43146. c = str.charCodeAt(m_pos);
  43147. if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {
  43148. c2 = str.charCodeAt(m_pos + 1);
  43149. if ((c2 & 0xfc00) === 0xdc00) {
  43150. c = 0x10000 + (c - 0xd800 << 10) + (c2 - 0xdc00);
  43151. m_pos++;
  43152. }
  43153. }
  43154. buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
  43155. } // allocate buffer
  43156. if (support.uint8array) {
  43157. buf = new Uint8Array(buf_len);
  43158. } else {
  43159. buf = new Array(buf_len);
  43160. } // convert
  43161. for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
  43162. c = str.charCodeAt(m_pos);
  43163. if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {
  43164. c2 = str.charCodeAt(m_pos + 1);
  43165. if ((c2 & 0xfc00) === 0xdc00) {
  43166. c = 0x10000 + (c - 0xd800 << 10) + (c2 - 0xdc00);
  43167. m_pos++;
  43168. }
  43169. }
  43170. if (c < 0x80) {
  43171. /* one byte */
  43172. buf[i++] = c;
  43173. } else if (c < 0x800) {
  43174. /* two bytes */
  43175. buf[i++] = 0xC0 | c >>> 6;
  43176. buf[i++] = 0x80 | c & 0x3f;
  43177. } else if (c < 0x10000) {
  43178. /* three bytes */
  43179. buf[i++] = 0xE0 | c >>> 12;
  43180. buf[i++] = 0x80 | c >>> 6 & 0x3f;
  43181. buf[i++] = 0x80 | c & 0x3f;
  43182. } else {
  43183. /* four bytes */
  43184. buf[i++] = 0xf0 | c >>> 18;
  43185. buf[i++] = 0x80 | c >>> 12 & 0x3f;
  43186. buf[i++] = 0x80 | c >>> 6 & 0x3f;
  43187. buf[i++] = 0x80 | c & 0x3f;
  43188. }
  43189. }
  43190. return buf;
  43191. }; // Calculate max possible position in utf8 buffer,
  43192. // that will not break sequence. If that's not possible
  43193. // - (very small limits) return max size as is.
  43194. //
  43195. // buf[] - utf8 bytes array
  43196. // max - length limit (mandatory);
  43197. var utf8border = function utf8border(buf, max) {
  43198. var pos;
  43199. max = max || buf.length;
  43200. if (max > buf.length) {
  43201. max = buf.length;
  43202. } // go back from last position, until start of sequence found
  43203. pos = max - 1;
  43204. while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) {
  43205. pos--;
  43206. } // Fuckup - very small and broken sequence,
  43207. // return max, because we should return something anyway.
  43208. if (pos < 0) {
  43209. return max;
  43210. } // If we came to start of buffer - that means vuffer is too small,
  43211. // return max too.
  43212. if (pos === 0) {
  43213. return max;
  43214. }
  43215. return pos + _utf8len[buf[pos]] > max ? pos : max;
  43216. }; // convert array to string
  43217. var buf2string = function buf2string(buf) {
  43218. var str, i, out, c, c_len;
  43219. var len = buf.length; // Reserve max possible length (2 words per char)
  43220. // NB: by unknown reasons, Array is significantly faster for
  43221. // String.fromCharCode.apply than Uint16Array.
  43222. var utf16buf = new Array(len * 2);
  43223. for (out = 0, i = 0; i < len;) {
  43224. c = buf[i++]; // quick process ascii
  43225. if (c < 0x80) {
  43226. utf16buf[out++] = c;
  43227. continue;
  43228. }
  43229. c_len = _utf8len[c]; // skip 5 & 6 byte codes
  43230. if (c_len > 4) {
  43231. utf16buf[out++] = 0xfffd;
  43232. i += c_len - 1;
  43233. continue;
  43234. } // apply mask on first byte
  43235. c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; // join the rest
  43236. while (c_len > 1 && i < len) {
  43237. c = c << 6 | buf[i++] & 0x3f;
  43238. c_len--;
  43239. } // terminated by end of string?
  43240. if (c_len > 1) {
  43241. utf16buf[out++] = 0xfffd;
  43242. continue;
  43243. }
  43244. if (c < 0x10000) {
  43245. utf16buf[out++] = c;
  43246. } else {
  43247. c -= 0x10000;
  43248. utf16buf[out++] = 0xd800 | c >> 10 & 0x3ff;
  43249. utf16buf[out++] = 0xdc00 | c & 0x3ff;
  43250. }
  43251. } // shrinkBuf(utf16buf, out)
  43252. if (utf16buf.length !== out) {
  43253. if (utf16buf.subarray) {
  43254. utf16buf = utf16buf.subarray(0, out);
  43255. } else {
  43256. utf16buf.length = out;
  43257. }
  43258. } // return String.fromCharCode.apply(null, utf16buf);
  43259. return utils.applyFromCharCode(utf16buf);
  43260. }; // That's all for the pako functions.
  43261. /**
  43262. * Transform a javascript string into an array (typed if possible) of bytes,
  43263. * UTF-8 encoded.
  43264. * @param {String} str the string to encode
  43265. * @return {Array|Uint8Array|Buffer} the UTF-8 encoded string.
  43266. */
  43267. exports.utf8encode = function utf8encode(str) {
  43268. if (support.nodebuffer) {
  43269. return nodejsUtils.newBufferFrom(str, "utf-8");
  43270. }
  43271. return string2buf(str);
  43272. };
  43273. /**
  43274. * Transform a bytes array (or a representation) representing an UTF-8 encoded
  43275. * string into a javascript string.
  43276. * @param {Array|Uint8Array|Buffer} buf the data de decode
  43277. * @return {String} the decoded string.
  43278. */
  43279. exports.utf8decode = function utf8decode(buf) {
  43280. if (support.nodebuffer) {
  43281. return utils.transformTo("nodebuffer", buf).toString("utf-8");
  43282. }
  43283. buf = utils.transformTo(support.uint8array ? "uint8array" : "array", buf);
  43284. return buf2string(buf);
  43285. };
  43286. /**
  43287. * A worker to decode utf8 encoded binary chunks into string chunks.
  43288. * @constructor
  43289. */
  43290. function Utf8DecodeWorker() {
  43291. GenericWorker.call(this, "utf-8 decode"); // the last bytes if a chunk didn't end with a complete codepoint.
  43292. this.leftOver = null;
  43293. }
  43294. utils.inherits(Utf8DecodeWorker, GenericWorker);
  43295. /**
  43296. * @see GenericWorker.processChunk
  43297. */
  43298. Utf8DecodeWorker.prototype.processChunk = function (chunk) {
  43299. var data = utils.transformTo(support.uint8array ? "uint8array" : "array", chunk.data); // 1st step, re-use what's left of the previous chunk
  43300. if (this.leftOver && this.leftOver.length) {
  43301. if (support.uint8array) {
  43302. var previousData = data;
  43303. data = new Uint8Array(previousData.length + this.leftOver.length);
  43304. data.set(this.leftOver, 0);
  43305. data.set(previousData, this.leftOver.length);
  43306. } else {
  43307. data = this.leftOver.concat(data);
  43308. }
  43309. this.leftOver = null;
  43310. }
  43311. var nextBoundary = utf8border(data);
  43312. var usableData = data;
  43313. if (nextBoundary !== data.length) {
  43314. if (support.uint8array) {
  43315. usableData = data.subarray(0, nextBoundary);
  43316. this.leftOver = data.subarray(nextBoundary, data.length);
  43317. } else {
  43318. usableData = data.slice(0, nextBoundary);
  43319. this.leftOver = data.slice(nextBoundary, data.length);
  43320. }
  43321. }
  43322. this.push({
  43323. data: exports.utf8decode(usableData),
  43324. meta: chunk.meta
  43325. });
  43326. };
  43327. /**
  43328. * @see GenericWorker.flush
  43329. */
  43330. Utf8DecodeWorker.prototype.flush = function () {
  43331. if (this.leftOver && this.leftOver.length) {
  43332. this.push({
  43333. data: exports.utf8decode(this.leftOver),
  43334. meta: {}
  43335. });
  43336. this.leftOver = null;
  43337. }
  43338. };
  43339. exports.Utf8DecodeWorker = Utf8DecodeWorker;
  43340. /**
  43341. * A worker to endcode string chunks into utf8 encoded binary chunks.
  43342. * @constructor
  43343. */
  43344. function Utf8EncodeWorker() {
  43345. GenericWorker.call(this, "utf-8 encode");
  43346. }
  43347. utils.inherits(Utf8EncodeWorker, GenericWorker);
  43348. /**
  43349. * @see GenericWorker.processChunk
  43350. */
  43351. Utf8EncodeWorker.prototype.processChunk = function (chunk) {
  43352. this.push({
  43353. data: exports.utf8encode(chunk.data),
  43354. meta: chunk.meta
  43355. });
  43356. };
  43357. exports.Utf8EncodeWorker = Utf8EncodeWorker;
  43358. }, { "./nodejsUtils": 403, "./stream/GenericWorker": 417, "./support": 419, "./utils": 421 }], 421: [function (require, module, exports) {
  43359. 'use strict';
  43360. var support = require('./support');
  43361. var base64 = require('./base64');
  43362. var nodejsUtils = require('./nodejsUtils');
  43363. var setImmediate = require('set-immediate-shim');
  43364. var external = require("./external");
  43365. /**
  43366. * Convert a string that pass as a "binary string": it should represent a byte
  43367. * array but may have > 255 char codes. Be sure to take only the first byte
  43368. * and returns the byte array.
  43369. * @param {String} str the string to transform.
  43370. * @return {Array|Uint8Array} the string in a binary format.
  43371. */
  43372. function string2binary(str) {
  43373. var result = null;
  43374. if (support.uint8array) {
  43375. result = new Uint8Array(str.length);
  43376. } else {
  43377. result = new Array(str.length);
  43378. }
  43379. return stringToArrayLike(str, result);
  43380. }
  43381. /**
  43382. * Create a new blob with the given content and the given type.
  43383. * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use
  43384. * an Uint8Array because the stock browser of android 4 won't accept it (it
  43385. * will be silently converted to a string, "[object Uint8Array]").
  43386. *
  43387. * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:
  43388. * when a large amount of Array is used to create the Blob, the amount of
  43389. * memory consumed is nearly 100 times the original data amount.
  43390. *
  43391. * @param {String} type the mime type of the blob.
  43392. * @return {Blob} the created blob.
  43393. */
  43394. exports.newBlob = function (part, type) {
  43395. exports.checkSupport("blob");
  43396. try {
  43397. // Blob constructor
  43398. return new Blob([part], {
  43399. type: type
  43400. });
  43401. } catch (e) {
  43402. try {
  43403. // deprecated, browser only, old way
  43404. var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
  43405. var builder = new Builder();
  43406. builder.append(part);
  43407. return builder.getBlob(type);
  43408. } catch (e) {
  43409. // well, fuck ?!
  43410. throw new Error("Bug : can't construct the Blob.");
  43411. }
  43412. }
  43413. };
  43414. /**
  43415. * The identity function.
  43416. * @param {Object} input the input.
  43417. * @return {Object} the same input.
  43418. */
  43419. function identity(input) {
  43420. return input;
  43421. }
  43422. /**
  43423. * Fill in an array with a string.
  43424. * @param {String} str the string to use.
  43425. * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).
  43426. * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.
  43427. */
  43428. function stringToArrayLike(str, array) {
  43429. for (var i = 0; i < str.length; ++i) {
  43430. array[i] = str.charCodeAt(i) & 0xFF;
  43431. }
  43432. return array;
  43433. }
  43434. /**
  43435. * An helper for the function arrayLikeToString.
  43436. * This contains static information and functions that
  43437. * can be optimized by the browser JIT compiler.
  43438. */
  43439. var arrayToStringHelper = {
  43440. /**
  43441. * Transform an array of int into a string, chunk by chunk.
  43442. * See the performances notes on arrayLikeToString.
  43443. * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
  43444. * @param {String} type the type of the array.
  43445. * @param {Integer} chunk the chunk size.
  43446. * @return {String} the resulting string.
  43447. * @throws Error if the chunk is too big for the stack.
  43448. */
  43449. stringifyByChunk: function stringifyByChunk(array, type, chunk) {
  43450. var result = [],
  43451. k = 0,
  43452. len = array.length; // shortcut
  43453. if (len <= chunk) {
  43454. return String.fromCharCode.apply(null, array);
  43455. }
  43456. while (k < len) {
  43457. if (type === "array" || type === "nodebuffer") {
  43458. result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
  43459. } else {
  43460. result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
  43461. }
  43462. k += chunk;
  43463. }
  43464. return result.join("");
  43465. },
  43466. /**
  43467. * Call String.fromCharCode on every item in the array.
  43468. * This is the naive implementation, which generate A LOT of intermediate string.
  43469. * This should be used when everything else fail.
  43470. * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
  43471. * @return {String} the result.
  43472. */
  43473. stringifyByChar: function stringifyByChar(array) {
  43474. var resultStr = "";
  43475. for (var i = 0; i < array.length; i++) {
  43476. resultStr += String.fromCharCode(array[i]);
  43477. }
  43478. return resultStr;
  43479. },
  43480. applyCanBeUsed: {
  43481. /**
  43482. * true if the browser accepts to use String.fromCharCode on Uint8Array
  43483. */
  43484. uint8array: function () {
  43485. try {
  43486. return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;
  43487. } catch (e) {
  43488. return false;
  43489. }
  43490. }(),
  43491. /**
  43492. * true if the browser accepts to use String.fromCharCode on nodejs Buffer.
  43493. */
  43494. nodebuffer: function () {
  43495. try {
  43496. return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;
  43497. } catch (e) {
  43498. return false;
  43499. }
  43500. }()
  43501. }
  43502. };
  43503. /**
  43504. * Transform an array-like object to a string.
  43505. * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
  43506. * @return {String} the result.
  43507. */
  43508. function arrayLikeToString(array) {
  43509. // Performances notes :
  43510. // --------------------
  43511. // String.fromCharCode.apply(null, array) is the fastest, see
  43512. // see http://jsperf.com/converting-a-uint8array-to-a-string/2
  43513. // but the stack is limited (and we can get huge arrays !).
  43514. //
  43515. // result += String.fromCharCode(array[i]); generate too many strings !
  43516. //
  43517. // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
  43518. // TODO : we now have workers that split the work. Do we still need that ?
  43519. var chunk = 65536,
  43520. type = exports.getTypeOf(array),
  43521. canUseApply = true;
  43522. if (type === "uint8array") {
  43523. canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;
  43524. } else if (type === "nodebuffer") {
  43525. canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;
  43526. }
  43527. if (canUseApply) {
  43528. while (chunk > 1) {
  43529. try {
  43530. return arrayToStringHelper.stringifyByChunk(array, type, chunk);
  43531. } catch (e) {
  43532. chunk = Math.floor(chunk / 2);
  43533. }
  43534. }
  43535. } // no apply or chunk error : slow and painful algorithm
  43536. // default browser on android 4.*
  43537. return arrayToStringHelper.stringifyByChar(array);
  43538. }
  43539. exports.applyFromCharCode = arrayLikeToString;
  43540. /**
  43541. * Copy the data from an array-like to an other array-like.
  43542. * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.
  43543. * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.
  43544. * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.
  43545. */
  43546. function arrayLikeToArrayLike(arrayFrom, arrayTo) {
  43547. for (var i = 0; i < arrayFrom.length; i++) {
  43548. arrayTo[i] = arrayFrom[i];
  43549. }
  43550. return arrayTo;
  43551. } // a matrix containing functions to transform everything into everything.
  43552. var transform = {}; // string to ?
  43553. transform["string"] = {
  43554. "string": identity,
  43555. "array": function array(input) {
  43556. return stringToArrayLike(input, new Array(input.length));
  43557. },
  43558. "arraybuffer": function arraybuffer(input) {
  43559. return transform["string"]["uint8array"](input).buffer;
  43560. },
  43561. "uint8array": function uint8array(input) {
  43562. return stringToArrayLike(input, new Uint8Array(input.length));
  43563. },
  43564. "nodebuffer": function nodebuffer(input) {
  43565. return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));
  43566. }
  43567. }; // array to ?
  43568. transform["array"] = {
  43569. "string": arrayLikeToString,
  43570. "array": identity,
  43571. "arraybuffer": function arraybuffer(input) {
  43572. return new Uint8Array(input).buffer;
  43573. },
  43574. "uint8array": function uint8array(input) {
  43575. return new Uint8Array(input);
  43576. },
  43577. "nodebuffer": function nodebuffer(input) {
  43578. return nodejsUtils.newBufferFrom(input);
  43579. }
  43580. }; // arraybuffer to ?
  43581. transform["arraybuffer"] = {
  43582. "string": function string(input) {
  43583. return arrayLikeToString(new Uint8Array(input));
  43584. },
  43585. "array": function array(input) {
  43586. return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
  43587. },
  43588. "arraybuffer": identity,
  43589. "uint8array": function uint8array(input) {
  43590. return new Uint8Array(input);
  43591. },
  43592. "nodebuffer": function nodebuffer(input) {
  43593. return nodejsUtils.newBufferFrom(new Uint8Array(input));
  43594. }
  43595. }; // uint8array to ?
  43596. transform["uint8array"] = {
  43597. "string": arrayLikeToString,
  43598. "array": function array(input) {
  43599. return arrayLikeToArrayLike(input, new Array(input.length));
  43600. },
  43601. "arraybuffer": function arraybuffer(input) {
  43602. return input.buffer;
  43603. },
  43604. "uint8array": identity,
  43605. "nodebuffer": function nodebuffer(input) {
  43606. return nodejsUtils.newBufferFrom(input);
  43607. }
  43608. }; // nodebuffer to ?
  43609. transform["nodebuffer"] = {
  43610. "string": arrayLikeToString,
  43611. "array": function array(input) {
  43612. return arrayLikeToArrayLike(input, new Array(input.length));
  43613. },
  43614. "arraybuffer": function arraybuffer(input) {
  43615. return transform["nodebuffer"]["uint8array"](input).buffer;
  43616. },
  43617. "uint8array": function uint8array(input) {
  43618. return arrayLikeToArrayLike(input, new Uint8Array(input.length));
  43619. },
  43620. "nodebuffer": identity
  43621. };
  43622. /**
  43623. * Transform an input into any type.
  43624. * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.
  43625. * If no output type is specified, the unmodified input will be returned.
  43626. * @param {String} outputType the output type.
  43627. * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.
  43628. * @throws {Error} an Error if the browser doesn't support the requested output type.
  43629. */
  43630. exports.transformTo = function (outputType, input) {
  43631. if (!input) {
  43632. // undefined, null, etc
  43633. // an empty string won't harm.
  43634. input = "";
  43635. }
  43636. if (!outputType) {
  43637. return input;
  43638. }
  43639. exports.checkSupport(outputType);
  43640. var inputType = exports.getTypeOf(input);
  43641. var result = transform[inputType][outputType](input);
  43642. return result;
  43643. };
  43644. /**
  43645. * Return the type of the input.
  43646. * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.
  43647. * @param {Object} input the input to identify.
  43648. * @return {String} the (lowercase) type of the input.
  43649. */
  43650. exports.getTypeOf = function (input) {
  43651. if (typeof input === "string") {
  43652. return "string";
  43653. }
  43654. if (Object.prototype.toString.call(input) === "[object Array]") {
  43655. return "array";
  43656. }
  43657. if (support.nodebuffer && nodejsUtils.isBuffer(input)) {
  43658. return "nodebuffer";
  43659. }
  43660. if (support.uint8array && input instanceof Uint8Array) {
  43661. return "uint8array";
  43662. }
  43663. if (support.arraybuffer && input instanceof ArrayBuffer) {
  43664. return "arraybuffer";
  43665. }
  43666. };
  43667. /**
  43668. * Throw an exception if the type is not supported.
  43669. * @param {String} type the type to check.
  43670. * @throws {Error} an Error if the browser doesn't support the requested type.
  43671. */
  43672. exports.checkSupport = function (type) {
  43673. var supported = support[type.toLowerCase()];
  43674. if (!supported) {
  43675. throw new Error(type + " is not supported by this platform");
  43676. }
  43677. };
  43678. exports.MAX_VALUE_16BITS = 65535;
  43679. exports.MAX_VALUE_32BITS = -1; // well, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" is parsed as -1
  43680. /**
  43681. * Prettify a string read as binary.
  43682. * @param {string} str the string to prettify.
  43683. * @return {string} a pretty string.
  43684. */
  43685. exports.pretty = function (str) {
  43686. var res = '',
  43687. code,
  43688. i;
  43689. for (i = 0; i < (str || "").length; i++) {
  43690. code = str.charCodeAt(i);
  43691. res += '\\x' + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
  43692. }
  43693. return res;
  43694. };
  43695. /**
  43696. * Defer the call of a function.
  43697. * @param {Function} callback the function to call asynchronously.
  43698. * @param {Array} args the arguments to give to the callback.
  43699. */
  43700. exports.delay = function (callback, args, self) {
  43701. setImmediate(function () {
  43702. callback.apply(self || null, args || []);
  43703. });
  43704. };
  43705. /**
  43706. * Extends a prototype with an other, without calling a constructor with
  43707. * side effects. Inspired by nodejs' `utils.inherits`
  43708. * @param {Function} ctor the constructor to augment
  43709. * @param {Function} superCtor the parent constructor to use
  43710. */
  43711. exports.inherits = function (ctor, superCtor) {
  43712. var Obj = function Obj() { };
  43713. Obj.prototype = superCtor.prototype;
  43714. ctor.prototype = new Obj();
  43715. };
  43716. /**
  43717. * Merge the objects passed as parameters into a new one.
  43718. * @private
  43719. * @param {...Object} var_args All objects to merge.
  43720. * @return {Object} a new object with the data of the others.
  43721. */
  43722. exports.extend = function () {
  43723. var result = {},
  43724. i,
  43725. attr;
  43726. for (i = 0; i < arguments.length; i++) {
  43727. // arguments is not enumerable in some browsers
  43728. for (attr in arguments[i]) {
  43729. if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") {
  43730. result[attr] = arguments[i][attr];
  43731. }
  43732. }
  43733. }
  43734. return result;
  43735. };
  43736. /**
  43737. * Transform arbitrary content into a Promise.
  43738. * @param {String} name a name for the content being processed.
  43739. * @param {Object} inputData the content to process.
  43740. * @param {Boolean} isBinary true if the content is not an unicode string
  43741. * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character.
  43742. * @param {Boolean} isBase64 true if the string content is encoded with base64.
  43743. * @return {Promise} a promise in a format usable by JSZip.
  43744. */
  43745. exports.prepareContent = function (name, inputData, isBinary, isOptimizedBinaryString, isBase64) {
  43746. // if inputData is already a promise, this flatten it.
  43747. var promise = external.Promise.resolve(inputData).then(function (data) {
  43748. var isBlob = support.blob && (data instanceof Blob || ['[object File]', '[object Blob]'].indexOf(Object.prototype.toString.call(data)) !== -1);
  43749. if (isBlob && typeof FileReader !== "undefined") {
  43750. return new external.Promise(function (resolve, reject) {
  43751. var reader = new FileReader();
  43752. reader.onload = function (e) {
  43753. resolve(e.target.result);
  43754. };
  43755. reader.onerror = function (e) {
  43756. reject(e.target.error);
  43757. };
  43758. reader.readAsArrayBuffer(data);
  43759. });
  43760. } else {
  43761. return data;
  43762. }
  43763. });
  43764. return promise.then(function (data) {
  43765. var dataType = exports.getTypeOf(data);
  43766. if (!dataType) {
  43767. return external.Promise.reject(new Error("Can't read the data of '" + name + "'. Is it " + "in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));
  43768. } // special case : it's way easier to work with Uint8Array than with ArrayBuffer
  43769. if (dataType === "arraybuffer") {
  43770. data = exports.transformTo("uint8array", data);
  43771. } else if (dataType === "string") {
  43772. if (isBase64) {
  43773. data = base64.decode(data);
  43774. } else if (isBinary) {
  43775. // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask
  43776. if (isOptimizedBinaryString !== true) {
  43777. // this is a string, not in a base64 format.
  43778. // Be sure that this is a correct "binary string"
  43779. data = string2binary(data);
  43780. }
  43781. }
  43782. }
  43783. return data;
  43784. });
  43785. };
  43786. }, { "./base64": 390, "./external": 395, "./nodejsUtils": 403, "./support": 419, "set-immediate-shim": 497 }], 422: [function (require, module, exports) {
  43787. 'use strict';
  43788. var readerFor = require('./reader/readerFor');
  43789. var utils = require('./utils');
  43790. var sig = require('./signature');
  43791. var ZipEntry = require('./zipEntry');
  43792. var utf8 = require('./utf8');
  43793. var support = require('./support'); // class ZipEntries {{{
  43794. /**
  43795. * All the entries in the zip file.
  43796. * @constructor
  43797. * @param {Object} loadOptions Options for loading the stream.
  43798. */
  43799. function ZipEntries(loadOptions) {
  43800. this.files = [];
  43801. this.loadOptions = loadOptions;
  43802. }
  43803. ZipEntries.prototype = {
  43804. /**
  43805. * Check that the reader is on the specified signature.
  43806. * @param {string} expectedSignature the expected signature.
  43807. * @throws {Error} if it is an other signature.
  43808. */
  43809. checkSignature: function checkSignature(expectedSignature) {
  43810. if (!this.reader.readAndCheckSignature(expectedSignature)) {
  43811. this.reader.index -= 4;
  43812. var signature = this.reader.readString(4);
  43813. throw new Error("Corrupted zip or bug: unexpected signature " + "(" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")");
  43814. }
  43815. },
  43816. /**
  43817. * Check if the given signature is at the given index.
  43818. * @param {number} askedIndex the index to check.
  43819. * @param {string} expectedSignature the signature to expect.
  43820. * @return {boolean} true if the signature is here, false otherwise.
  43821. */
  43822. isSignature: function isSignature(askedIndex, expectedSignature) {
  43823. var currentIndex = this.reader.index;
  43824. this.reader.setIndex(askedIndex);
  43825. var signature = this.reader.readString(4);
  43826. var result = signature === expectedSignature;
  43827. this.reader.setIndex(currentIndex);
  43828. return result;
  43829. },
  43830. /**
  43831. * Read the end of the central directory.
  43832. */
  43833. readBlockEndOfCentral: function readBlockEndOfCentral() {
  43834. this.diskNumber = this.reader.readInt(2);
  43835. this.diskWithCentralDirStart = this.reader.readInt(2);
  43836. this.centralDirRecordsOnThisDisk = this.reader.readInt(2);
  43837. this.centralDirRecords = this.reader.readInt(2);
  43838. this.centralDirSize = this.reader.readInt(4);
  43839. this.centralDirOffset = this.reader.readInt(4);
  43840. this.zipCommentLength = this.reader.readInt(2); // warning : the encoding depends of the system locale
  43841. // On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.
  43842. // On a windows machine, this field is encoded with the localized windows code page.
  43843. var zipComment = this.reader.readData(this.zipCommentLength);
  43844. var decodeParamType = support.uint8array ? "uint8array" : "array"; // To get consistent behavior with the generation part, we will assume that
  43845. // this is utf8 encoded unless specified otherwise.
  43846. var decodeContent = utils.transformTo(decodeParamType, zipComment);
  43847. this.zipComment = this.loadOptions.decodeFileName(decodeContent);
  43848. },
  43849. /**
  43850. * Read the end of the Zip 64 central directory.
  43851. * Not merged with the method readEndOfCentral :
  43852. * The end of central can coexist with its Zip64 brother,
  43853. * I don't want to read the wrong number of bytes !
  43854. */
  43855. readBlockZip64EndOfCentral: function readBlockZip64EndOfCentral() {
  43856. this.zip64EndOfCentralSize = this.reader.readInt(8);
  43857. this.reader.skip(4); // this.versionMadeBy = this.reader.readString(2);
  43858. // this.versionNeeded = this.reader.readInt(2);
  43859. this.diskNumber = this.reader.readInt(4);
  43860. this.diskWithCentralDirStart = this.reader.readInt(4);
  43861. this.centralDirRecordsOnThisDisk = this.reader.readInt(8);
  43862. this.centralDirRecords = this.reader.readInt(8);
  43863. this.centralDirSize = this.reader.readInt(8);
  43864. this.centralDirOffset = this.reader.readInt(8);
  43865. this.zip64ExtensibleData = {};
  43866. var extraDataSize = this.zip64EndOfCentralSize - 44,
  43867. index = 0,
  43868. extraFieldId,
  43869. extraFieldLength,
  43870. extraFieldValue;
  43871. while (index < extraDataSize) {
  43872. extraFieldId = this.reader.readInt(2);
  43873. extraFieldLength = this.reader.readInt(4);
  43874. extraFieldValue = this.reader.readData(extraFieldLength);
  43875. this.zip64ExtensibleData[extraFieldId] = {
  43876. id: extraFieldId,
  43877. length: extraFieldLength,
  43878. value: extraFieldValue
  43879. };
  43880. }
  43881. },
  43882. /**
  43883. * Read the end of the Zip 64 central directory locator.
  43884. */
  43885. readBlockZip64EndOfCentralLocator: function readBlockZip64EndOfCentralLocator() {
  43886. this.diskWithZip64CentralDirStart = this.reader.readInt(4);
  43887. this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);
  43888. this.disksCount = this.reader.readInt(4);
  43889. if (this.disksCount > 1) {
  43890. throw new Error("Multi-volumes zip are not supported");
  43891. }
  43892. },
  43893. /**
  43894. * Read the local files, based on the offset read in the central part.
  43895. */
  43896. readLocalFiles: function readLocalFiles() {
  43897. var i, file;
  43898. for (i = 0; i < this.files.length; i++) {
  43899. file = this.files[i];
  43900. this.reader.setIndex(file.localHeaderOffset);
  43901. this.checkSignature(sig.LOCAL_FILE_HEADER);
  43902. file.readLocalPart(this.reader);
  43903. file.handleUTF8();
  43904. file.processAttributes();
  43905. }
  43906. },
  43907. /**
  43908. * Read the central directory.
  43909. */
  43910. readCentralDir: function readCentralDir() {
  43911. var file;
  43912. this.reader.setIndex(this.centralDirOffset);
  43913. while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) {
  43914. file = new ZipEntry({
  43915. zip64: this.zip64
  43916. }, this.loadOptions);
  43917. file.readCentralPart(this.reader);
  43918. this.files.push(file);
  43919. }
  43920. if (this.centralDirRecords !== this.files.length) {
  43921. if (this.centralDirRecords !== 0 && this.files.length === 0) {
  43922. // We expected some records but couldn't find ANY.
  43923. // This is really suspicious, as if something went wrong.
  43924. throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
  43925. } else {// We found some records but not all.
  43926. // Something is wrong but we got something for the user: no error here.
  43927. // console.warn("expected", this.centralDirRecords, "records in central dir, got", this.files.length);
  43928. }
  43929. }
  43930. },
  43931. /**
  43932. * Read the end of central directory.
  43933. */
  43934. readEndOfCentral: function readEndOfCentral() {
  43935. var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
  43936. if (offset < 0) {
  43937. // Check if the content is a truncated zip or complete garbage.
  43938. // A "LOCAL_FILE_HEADER" is not required at the beginning (auto
  43939. // extractible zip for example) but it can give a good hint.
  43940. // If an ajax request was used without responseType, we will also
  43941. // get unreadable data.
  43942. var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);
  43943. if (isGarbage) {
  43944. throw new Error("Can't find end of central directory : is this a zip file ? " + "If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");
  43945. } else {
  43946. throw new Error("Corrupted zip: can't find end of central directory");
  43947. }
  43948. }
  43949. this.reader.setIndex(offset);
  43950. var endOfCentralDirOffset = offset;
  43951. this.checkSignature(sig.CENTRAL_DIRECTORY_END);
  43952. this.readBlockEndOfCentral();
  43953. /* extract from the zip spec :
  43954. 4) If one of the fields in the end of central directory
  43955. record is too small to hold required data, the field
  43956. should be set to -1 (0xFFFF or 0xFFFFFFFF) and the
  43957. ZIP64 format record should be created.
  43958. 5) The end of central directory record and the
  43959. Zip64 end of central directory locator record must
  43960. reside on the same disk when splitting or spanning
  43961. an archive.
  43962. */
  43963. if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {
  43964. this.zip64 = true;
  43965. /*
  43966. Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from
  43967. the zip file can fit into a 32bits integer. This cannot be solved : JavaScript represents
  43968. all numbers as 64-bit double precision IEEE 754 floating point numbers.
  43969. So, we have 53bits for integers and bitwise operations treat everything as 32bits.
  43970. see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators
  43971. and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5
  43972. */
  43973. // should look for a zip64 EOCD locator
  43974. offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
  43975. if (offset < 0) {
  43976. throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");
  43977. }
  43978. this.reader.setIndex(offset);
  43979. this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
  43980. this.readBlockZip64EndOfCentralLocator(); // now the zip64 EOCD record
  43981. if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {
  43982. // console.warn("ZIP64 end of central directory not where expected.");
  43983. this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
  43984. if (this.relativeOffsetEndOfZip64CentralDir < 0) {
  43985. throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");
  43986. }
  43987. }
  43988. this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);
  43989. this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
  43990. this.readBlockZip64EndOfCentral();
  43991. }
  43992. var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;
  43993. if (this.zip64) {
  43994. expectedEndOfCentralDirOffset += 20; // end of central dir 64 locator
  43995. expectedEndOfCentralDirOffset += 12
  43996. /* should not include the leading 12 bytes */
  43997. + this.zip64EndOfCentralSize;
  43998. }
  43999. var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;
  44000. if (extraBytes > 0) {
  44001. // console.warn(extraBytes, "extra bytes at beginning or within zipfile");
  44002. if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {// The offsets seem wrong, but we have something at the specified offset.
  44003. // So… we keep it.
  44004. } else {
  44005. // the offset is wrong, update the "zero" of the reader
  44006. // this happens if data has been prepended (crx files for example)
  44007. this.reader.zero = extraBytes;
  44008. }
  44009. } else if (extraBytes < 0) {
  44010. throw new Error("Corrupted zip: missing " + Math.abs(extraBytes) + " bytes.");
  44011. }
  44012. },
  44013. prepareReader: function prepareReader(data) {
  44014. this.reader = readerFor(data);
  44015. },
  44016. /**
  44017. * Read a zip file and create ZipEntries.
  44018. * @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.
  44019. */
  44020. load: function load(data) {
  44021. this.prepareReader(data);
  44022. this.readEndOfCentral();
  44023. this.readCentralDir();
  44024. this.readLocalFiles();
  44025. }
  44026. }; // }}} end of ZipEntries
  44027. module.exports = ZipEntries;
  44028. }, { "./reader/readerFor": 411, "./signature": 412, "./support": 419, "./utf8": 420, "./utils": 421, "./zipEntry": 423 }], 423: [function (require, module, exports) {
  44029. 'use strict';
  44030. var readerFor = require('./reader/readerFor');
  44031. var utils = require('./utils');
  44032. var CompressedObject = require('./compressedObject');
  44033. var crc32fn = require('./crc32');
  44034. var utf8 = require('./utf8');
  44035. var compressions = require('./compressions');
  44036. var support = require('./support');
  44037. var MADE_BY_DOS = 0x00;
  44038. var MADE_BY_UNIX = 0x03;
  44039. /**
  44040. * Find a compression registered in JSZip.
  44041. * @param {string} compressionMethod the method magic to find.
  44042. * @return {Object|null} the JSZip compression object, null if none found.
  44043. */
  44044. var findCompression = function findCompression(compressionMethod) {
  44045. for (var method in compressions) {
  44046. if (!compressions.hasOwnProperty(method)) {
  44047. continue;
  44048. }
  44049. if (compressions[method].magic === compressionMethod) {
  44050. return compressions[method];
  44051. }
  44052. }
  44053. return null;
  44054. }; // class ZipEntry {{{
  44055. /**
  44056. * An entry in the zip file.
  44057. * @constructor
  44058. * @param {Object} options Options of the current file.
  44059. * @param {Object} loadOptions Options for loading the stream.
  44060. */
  44061. function ZipEntry(options, loadOptions) {
  44062. this.options = options;
  44063. this.loadOptions = loadOptions;
  44064. }
  44065. ZipEntry.prototype = {
  44066. /**
  44067. * say if the file is encrypted.
  44068. * @return {boolean} true if the file is encrypted, false otherwise.
  44069. */
  44070. isEncrypted: function isEncrypted() {
  44071. // bit 1 is set
  44072. return (this.bitFlag & 0x0001) === 0x0001;
  44073. },
  44074. /**
  44075. * say if the file has utf-8 filename/comment.
  44076. * @return {boolean} true if the filename/comment is in utf-8, false otherwise.
  44077. */
  44078. useUTF8: function useUTF8() {
  44079. // bit 11 is set
  44080. return (this.bitFlag & 0x0800) === 0x0800;
  44081. },
  44082. /**
  44083. * Read the local part of a zip file and add the info in this object.
  44084. * @param {DataReader} reader the reader to use.
  44085. */
  44086. readLocalPart: function readLocalPart(reader) {
  44087. var compression, localExtraFieldsLength; // we already know everything from the central dir !
  44088. // If the central dir data are false, we are doomed.
  44089. // On the bright side, the local part is scary : zip64, data descriptors, both, etc.
  44090. // The less data we get here, the more reliable this should be.
  44091. // Let's skip the whole header and dash to the data !
  44092. reader.skip(22); // in some zip created on windows, the filename stored in the central dir contains \ instead of /.
  44093. // Strangely, the filename here is OK.
  44094. // I would love to treat these zip files as corrupted (see http://www.info-zip.org/FAQ.html#backslashes
  44095. // or APPNOTE#4.4.17.1, "All slashes MUST be forward slashes '/'") but there are a lot of bad zip generators...
  44096. // Search "unzip mismatching "local" filename continuing with "central" filename version" on
  44097. // the internet.
  44098. //
  44099. // I think I see the logic here : the central directory is used to display
  44100. // content and the local directory is used to extract the files. Mixing / and \
  44101. // may be used to display \ to windows users and use / when extracting the files.
  44102. // Unfortunately, this lead also to some issues : http://seclists.org/fulldisclosure/2009/Sep/394
  44103. this.fileNameLength = reader.readInt(2);
  44104. localExtraFieldsLength = reader.readInt(2); // can't be sure this will be the same as the central dir
  44105. // the fileName is stored as binary data, the handleUTF8 method will take care of the encoding.
  44106. this.fileName = reader.readData(this.fileNameLength);
  44107. reader.skip(localExtraFieldsLength);
  44108. if (this.compressedSize === -1 || this.uncompressedSize === -1) {
  44109. throw new Error("Bug or corrupted zip : didn't get enough information from the central directory " + "(compressedSize === -1 || uncompressedSize === -1)");
  44110. }
  44111. compression = findCompression(this.compressionMethod);
  44112. if (compression === null) {
  44113. // no compression found
  44114. throw new Error("Corrupted zip : compression " + utils.pretty(this.compressionMethod) + " unknown (inner file : " + utils.transformTo("string", this.fileName) + ")");
  44115. }
  44116. this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize));
  44117. },
  44118. /**
  44119. * Read the central part of a zip file and add the info in this object.
  44120. * @param {DataReader} reader the reader to use.
  44121. */
  44122. readCentralPart: function readCentralPart(reader) {
  44123. this.versionMadeBy = reader.readInt(2);
  44124. reader.skip(2); // this.versionNeeded = reader.readInt(2);
  44125. this.bitFlag = reader.readInt(2);
  44126. this.compressionMethod = reader.readString(2);
  44127. this.date = reader.readDate();
  44128. this.crc32 = reader.readInt(4);
  44129. this.compressedSize = reader.readInt(4);
  44130. this.uncompressedSize = reader.readInt(4);
  44131. var fileNameLength = reader.readInt(2);
  44132. this.extraFieldsLength = reader.readInt(2);
  44133. this.fileCommentLength = reader.readInt(2);
  44134. this.diskNumberStart = reader.readInt(2);
  44135. this.internalFileAttributes = reader.readInt(2);
  44136. this.externalFileAttributes = reader.readInt(4);
  44137. this.localHeaderOffset = reader.readInt(4);
  44138. if (this.isEncrypted()) {
  44139. throw new Error("Encrypted zip are not supported");
  44140. } // will be read in the local part, see the comments there
  44141. reader.skip(fileNameLength);
  44142. this.readExtraFields(reader);
  44143. this.parseZIP64ExtraField(reader);
  44144. this.fileComment = reader.readData(this.fileCommentLength);
  44145. },
  44146. /**
  44147. * Parse the external file attributes and get the unix/dos permissions.
  44148. */
  44149. processAttributes: function processAttributes() {
  44150. this.unixPermissions = null;
  44151. this.dosPermissions = null;
  44152. var madeBy = this.versionMadeBy >> 8; // Check if we have the DOS directory flag set.
  44153. // We look for it in the DOS and UNIX permissions
  44154. // but some unknown platform could set it as a compatibility flag.
  44155. this.dir = this.externalFileAttributes & 0x0010 ? true : false;
  44156. if (madeBy === MADE_BY_DOS) {
  44157. // first 6 bits (0 to 5)
  44158. this.dosPermissions = this.externalFileAttributes & 0x3F;
  44159. }
  44160. if (madeBy === MADE_BY_UNIX) {
  44161. this.unixPermissions = this.externalFileAttributes >> 16 & 0xFFFF; // the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);
  44162. } // fail safe : if the name ends with a / it probably means a folder
  44163. if (!this.dir && this.fileNameStr.slice(-1) === '/') {
  44164. this.dir = true;
  44165. }
  44166. },
  44167. /**
  44168. * Parse the ZIP64 extra field and merge the info in the current ZipEntry.
  44169. * @param {DataReader} reader the reader to use.
  44170. */
  44171. parseZIP64ExtraField: function parseZIP64ExtraField(reader) {
  44172. if (!this.extraFields[0x0001]) {
  44173. return;
  44174. } // should be something, preparing the extra reader
  44175. var extraReader = readerFor(this.extraFields[0x0001].value); // I really hope that these 64bits integer can fit in 32 bits integer, because js
  44176. // won't let us have more.
  44177. if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
  44178. this.uncompressedSize = extraReader.readInt(8);
  44179. }
  44180. if (this.compressedSize === utils.MAX_VALUE_32BITS) {
  44181. this.compressedSize = extraReader.readInt(8);
  44182. }
  44183. if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
  44184. this.localHeaderOffset = extraReader.readInt(8);
  44185. }
  44186. if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
  44187. this.diskNumberStart = extraReader.readInt(4);
  44188. }
  44189. },
  44190. /**
  44191. * Read the central part of a zip file and add the info in this object.
  44192. * @param {DataReader} reader the reader to use.
  44193. */
  44194. readExtraFields: function readExtraFields(reader) {
  44195. var end = reader.index + this.extraFieldsLength,
  44196. extraFieldId,
  44197. extraFieldLength,
  44198. extraFieldValue;
  44199. if (!this.extraFields) {
  44200. this.extraFields = {};
  44201. }
  44202. while (reader.index + 4 < end) {
  44203. extraFieldId = reader.readInt(2);
  44204. extraFieldLength = reader.readInt(2);
  44205. extraFieldValue = reader.readData(extraFieldLength);
  44206. this.extraFields[extraFieldId] = {
  44207. id: extraFieldId,
  44208. length: extraFieldLength,
  44209. value: extraFieldValue
  44210. };
  44211. }
  44212. reader.setIndex(end);
  44213. },
  44214. /**
  44215. * Apply an UTF8 transformation if needed.
  44216. */
  44217. handleUTF8: function handleUTF8() {
  44218. var decodeParamType = support.uint8array ? "uint8array" : "array";
  44219. if (this.useUTF8()) {
  44220. this.fileNameStr = utf8.utf8decode(this.fileName);
  44221. this.fileCommentStr = utf8.utf8decode(this.fileComment);
  44222. } else {
  44223. var upath = this.findExtraFieldUnicodePath();
  44224. if (upath !== null) {
  44225. this.fileNameStr = upath;
  44226. } else {
  44227. // ASCII text or unsupported code page
  44228. var fileNameByteArray = utils.transformTo(decodeParamType, this.fileName);
  44229. this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray);
  44230. }
  44231. var ucomment = this.findExtraFieldUnicodeComment();
  44232. if (ucomment !== null) {
  44233. this.fileCommentStr = ucomment;
  44234. } else {
  44235. // ASCII text or unsupported code page
  44236. var commentByteArray = utils.transformTo(decodeParamType, this.fileComment);
  44237. this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray);
  44238. }
  44239. }
  44240. },
  44241. /**
  44242. * Find the unicode path declared in the extra field, if any.
  44243. * @return {String} the unicode path, null otherwise.
  44244. */
  44245. findExtraFieldUnicodePath: function findExtraFieldUnicodePath() {
  44246. var upathField = this.extraFields[0x7075];
  44247. if (upathField) {
  44248. var extraReader = readerFor(upathField.value); // wrong version
  44249. if (extraReader.readInt(1) !== 1) {
  44250. return null;
  44251. } // the crc of the filename changed, this field is out of date.
  44252. if (crc32fn(this.fileName) !== extraReader.readInt(4)) {
  44253. return null;
  44254. }
  44255. return utf8.utf8decode(extraReader.readData(upathField.length - 5));
  44256. }
  44257. return null;
  44258. },
  44259. /**
  44260. * Find the unicode comment declared in the extra field, if any.
  44261. * @return {String} the unicode comment, null otherwise.
  44262. */
  44263. findExtraFieldUnicodeComment: function findExtraFieldUnicodeComment() {
  44264. var ucommentField = this.extraFields[0x6375];
  44265. if (ucommentField) {
  44266. var extraReader = readerFor(ucommentField.value); // wrong version
  44267. if (extraReader.readInt(1) !== 1) {
  44268. return null;
  44269. } // the crc of the comment changed, this field is out of date.
  44270. if (crc32fn(this.fileComment) !== extraReader.readInt(4)) {
  44271. return null;
  44272. }
  44273. return utf8.utf8decode(extraReader.readData(ucommentField.length - 5));
  44274. }
  44275. return null;
  44276. }
  44277. };
  44278. module.exports = ZipEntry;
  44279. }, { "./compressedObject": 391, "./compressions": 392, "./crc32": 393, "./reader/readerFor": 411, "./support": 419, "./utf8": 420, "./utils": 421 }], 424: [function (require, module, exports) {
  44280. 'use strict';
  44281. var StreamHelper = require('./stream/StreamHelper');
  44282. var DataWorker = require('./stream/DataWorker');
  44283. var utf8 = require('./utf8');
  44284. var CompressedObject = require('./compressedObject');
  44285. var GenericWorker = require('./stream/GenericWorker');
  44286. /**
  44287. * A simple object representing a file in the zip file.
  44288. * @constructor
  44289. * @param {string} name the name of the file
  44290. * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data
  44291. * @param {Object} options the options of the file
  44292. */
  44293. var ZipObject = function ZipObject(name, data, options) {
  44294. this.name = name;
  44295. this.dir = options.dir;
  44296. this.date = options.date;
  44297. this.comment = options.comment;
  44298. this.unixPermissions = options.unixPermissions;
  44299. this.dosPermissions = options.dosPermissions;
  44300. this._data = data;
  44301. this._dataBinary = options.binary; // keep only the compression
  44302. this.options = {
  44303. compression: options.compression,
  44304. compressionOptions: options.compressionOptions
  44305. };
  44306. };
  44307. ZipObject.prototype = {
  44308. /**
  44309. * Create an internal stream for the content of this object.
  44310. * @param {String} type the type of each chunk.
  44311. * @return StreamHelper the stream.
  44312. */
  44313. internalStream: function internalStream(type) {
  44314. var result = null,
  44315. outputType = "string";
  44316. try {
  44317. if (!type) {
  44318. throw new Error("No output type specified.");
  44319. }
  44320. outputType = type.toLowerCase();
  44321. var askUnicodeString = outputType === "string" || outputType === "text";
  44322. if (outputType === "binarystring" || outputType === "text") {
  44323. outputType = "string";
  44324. }
  44325. result = this._decompressWorker();
  44326. var isUnicodeString = !this._dataBinary;
  44327. if (isUnicodeString && !askUnicodeString) {
  44328. result = result.pipe(new utf8.Utf8EncodeWorker());
  44329. }
  44330. if (!isUnicodeString && askUnicodeString) {
  44331. result = result.pipe(new utf8.Utf8DecodeWorker());
  44332. }
  44333. } catch (e) {
  44334. result = new GenericWorker("error");
  44335. result.error(e);
  44336. }
  44337. return new StreamHelper(result, outputType, "");
  44338. },
  44339. /**
  44340. * Prepare the content in the asked type.
  44341. * @param {String} type the type of the result.
  44342. * @param {Function} onUpdate a function to call on each internal update.
  44343. * @return Promise the promise of the result.
  44344. */
  44345. async: function async(type, onUpdate) {
  44346. return this.internalStream(type).accumulate(onUpdate);
  44347. },
  44348. /**
  44349. * Prepare the content as a nodejs stream.
  44350. * @param {String} type the type of each chunk.
  44351. * @param {Function} onUpdate a function to call on each internal update.
  44352. * @return Stream the stream.
  44353. */
  44354. nodeStream: function nodeStream(type, onUpdate) {
  44355. return this.internalStream(type || "nodebuffer").toNodejsStream(onUpdate);
  44356. },
  44357. /**
  44358. * Return a worker for the compressed content.
  44359. * @private
  44360. * @param {Object} compression the compression object to use.
  44361. * @param {Object} compressionOptions the options to use when compressing.
  44362. * @return Worker the worker.
  44363. */
  44364. _compressWorker: function _compressWorker(compression, compressionOptions) {
  44365. if (this._data instanceof CompressedObject && this._data.compression.magic === compression.magic) {
  44366. return this._data.getCompressedWorker();
  44367. } else {
  44368. var result = this._decompressWorker();
  44369. if (!this._dataBinary) {
  44370. result = result.pipe(new utf8.Utf8EncodeWorker());
  44371. }
  44372. return CompressedObject.createWorkerFrom(result, compression, compressionOptions);
  44373. }
  44374. },
  44375. /**
  44376. * Return a worker for the decompressed content.
  44377. * @private
  44378. * @return Worker the worker.
  44379. */
  44380. _decompressWorker: function _decompressWorker() {
  44381. if (this._data instanceof CompressedObject) {
  44382. return this._data.getContentWorker();
  44383. } else if (this._data instanceof GenericWorker) {
  44384. return this._data;
  44385. } else {
  44386. return new DataWorker(this._data);
  44387. }
  44388. }
  44389. };
  44390. var removedMethods = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"];
  44391. var removedFn = function removedFn() {
  44392. throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
  44393. };
  44394. for (var i = 0; i < removedMethods.length; i++) {
  44395. ZipObject.prototype[removedMethods[i]] = removedFn;
  44396. }
  44397. module.exports = ZipObject;
  44398. }, { "./compressedObject": 391, "./stream/DataWorker": 416, "./stream/GenericWorker": 417, "./stream/StreamHelper": 418, "./utf8": 420 }], 425: [function (require, module, exports) {
  44399. 'use strict';
  44400. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  44401. var immediate = require('immediate');
  44402. /* istanbul ignore next */
  44403. function INTERNAL() { }
  44404. var handlers = {};
  44405. var REJECTED = ['REJECTED'];
  44406. var FULFILLED = ['FULFILLED'];
  44407. var PENDING = ['PENDING'];
  44408. module.exports = Promise;
  44409. function Promise(resolver) {
  44410. if (typeof resolver !== 'function') {
  44411. throw new TypeError('resolver must be a function');
  44412. }
  44413. this.state = PENDING;
  44414. this.queue = [];
  44415. this.outcome = void 0;
  44416. if (resolver !== INTERNAL) {
  44417. safelyResolveThenable(this, resolver);
  44418. }
  44419. }
  44420. Promise.prototype["finally"] = function (callback) {
  44421. if (typeof callback !== 'function') {
  44422. return this;
  44423. }
  44424. var p = this.constructor;
  44425. return this.then(resolve, reject);
  44426. function resolve(value) {
  44427. function yes() {
  44428. return value;
  44429. }
  44430. return p.resolve(callback()).then(yes);
  44431. }
  44432. function reject(reason) {
  44433. function no() {
  44434. throw reason;
  44435. }
  44436. return p.resolve(callback()).then(no);
  44437. }
  44438. };
  44439. Promise.prototype["catch"] = function (onRejected) {
  44440. return this.then(null, onRejected);
  44441. };
  44442. Promise.prototype.then = function (onFulfilled, onRejected) {
  44443. if (typeof onFulfilled !== 'function' && this.state === FULFILLED || typeof onRejected !== 'function' && this.state === REJECTED) {
  44444. return this;
  44445. }
  44446. var promise = new this.constructor(INTERNAL);
  44447. if (this.state !== PENDING) {
  44448. var resolver = this.state === FULFILLED ? onFulfilled : onRejected;
  44449. unwrap(promise, resolver, this.outcome);
  44450. } else {
  44451. this.queue.push(new QueueItem(promise, onFulfilled, onRejected));
  44452. }
  44453. return promise;
  44454. };
  44455. function QueueItem(promise, onFulfilled, onRejected) {
  44456. this.promise = promise;
  44457. if (typeof onFulfilled === 'function') {
  44458. this.onFulfilled = onFulfilled;
  44459. this.callFulfilled = this.otherCallFulfilled;
  44460. }
  44461. if (typeof onRejected === 'function') {
  44462. this.onRejected = onRejected;
  44463. this.callRejected = this.otherCallRejected;
  44464. }
  44465. }
  44466. QueueItem.prototype.callFulfilled = function (value) {
  44467. handlers.resolve(this.promise, value);
  44468. };
  44469. QueueItem.prototype.otherCallFulfilled = function (value) {
  44470. unwrap(this.promise, this.onFulfilled, value);
  44471. };
  44472. QueueItem.prototype.callRejected = function (value) {
  44473. handlers.reject(this.promise, value);
  44474. };
  44475. QueueItem.prototype.otherCallRejected = function (value) {
  44476. unwrap(this.promise, this.onRejected, value);
  44477. };
  44478. function unwrap(promise, func, value) {
  44479. immediate(function () {
  44480. var returnValue;
  44481. try {
  44482. returnValue = func(value);
  44483. } catch (e) {
  44484. return handlers.reject(promise, e);
  44485. }
  44486. if (returnValue === promise) {
  44487. handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));
  44488. } else {
  44489. handlers.resolve(promise, returnValue);
  44490. }
  44491. });
  44492. }
  44493. handlers.resolve = function (self, value) {
  44494. var result = tryCatch(getThen, value);
  44495. if (result.status === 'error') {
  44496. return handlers.reject(self, result.value);
  44497. }
  44498. var thenable = result.value;
  44499. if (thenable) {
  44500. safelyResolveThenable(self, thenable);
  44501. } else {
  44502. self.state = FULFILLED;
  44503. self.outcome = value;
  44504. var i = -1;
  44505. var len = self.queue.length;
  44506. while (++i < len) {
  44507. self.queue[i].callFulfilled(value);
  44508. }
  44509. }
  44510. return self;
  44511. };
  44512. handlers.reject = function (self, error) {
  44513. self.state = REJECTED;
  44514. self.outcome = error;
  44515. var i = -1;
  44516. var len = self.queue.length;
  44517. while (++i < len) {
  44518. self.queue[i].callRejected(error);
  44519. }
  44520. return self;
  44521. };
  44522. function getThen(obj) {
  44523. // Make sure we only access the accessor once as required by the spec
  44524. var then = obj && obj.then;
  44525. if (obj && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof then === 'function') {
  44526. return function appyThen() {
  44527. then.apply(obj, arguments);
  44528. };
  44529. }
  44530. }
  44531. function safelyResolveThenable(self, thenable) {
  44532. // Either fulfill, reject or reject with error
  44533. var called = false;
  44534. function onError(value) {
  44535. if (called) {
  44536. return;
  44537. }
  44538. called = true;
  44539. handlers.reject(self, value);
  44540. }
  44541. function onSuccess(value) {
  44542. if (called) {
  44543. return;
  44544. }
  44545. called = true;
  44546. handlers.resolve(self, value);
  44547. }
  44548. function tryToUnwrap() {
  44549. thenable(onSuccess, onError);
  44550. }
  44551. var result = tryCatch(tryToUnwrap);
  44552. if (result.status === 'error') {
  44553. onError(result.value);
  44554. }
  44555. }
  44556. function tryCatch(func, value) {
  44557. var out = {};
  44558. try {
  44559. out.value = func(value);
  44560. out.status = 'success';
  44561. } catch (e) {
  44562. out.status = 'error';
  44563. out.value = e;
  44564. }
  44565. return out;
  44566. }
  44567. Promise.resolve = resolve;
  44568. function resolve(value) {
  44569. if (value instanceof this) {
  44570. return value;
  44571. }
  44572. return handlers.resolve(new this(INTERNAL), value);
  44573. }
  44574. Promise.reject = reject;
  44575. function reject(reason) {
  44576. var promise = new this(INTERNAL);
  44577. return handlers.reject(promise, reason);
  44578. }
  44579. Promise.all = all;
  44580. function all(iterable) {
  44581. var self = this;
  44582. if (Object.prototype.toString.call(iterable) !== '[object Array]') {
  44583. return this.reject(new TypeError('must be an array'));
  44584. }
  44585. var len = iterable.length;
  44586. var called = false;
  44587. if (!len) {
  44588. return this.resolve([]);
  44589. }
  44590. var values = new Array(len);
  44591. var resolved = 0;
  44592. var i = -1;
  44593. var promise = new this(INTERNAL);
  44594. while (++i < len) {
  44595. allResolver(iterable[i], i);
  44596. }
  44597. return promise;
  44598. function allResolver(value, i) {
  44599. self.resolve(value).then(resolveFromAll, function (error) {
  44600. if (!called) {
  44601. called = true;
  44602. handlers.reject(promise, error);
  44603. }
  44604. });
  44605. function resolveFromAll(outValue) {
  44606. values[i] = outValue;
  44607. if (++resolved === len && !called) {
  44608. called = true;
  44609. handlers.resolve(promise, values);
  44610. }
  44611. }
  44612. }
  44613. }
  44614. Promise.race = race;
  44615. function race(iterable) {
  44616. var self = this;
  44617. if (Object.prototype.toString.call(iterable) !== '[object Array]') {
  44618. return this.reject(new TypeError('must be an array'));
  44619. }
  44620. var len = iterable.length;
  44621. var called = false;
  44622. if (!len) {
  44623. return this.resolve([]);
  44624. }
  44625. var i = -1;
  44626. var promise = new this(INTERNAL);
  44627. while (++i < len) {
  44628. resolver(iterable[i]);
  44629. }
  44630. return promise;
  44631. function resolver(value) {
  44632. self.resolve(value).then(function (response) {
  44633. if (!called) {
  44634. called = true;
  44635. handlers.resolve(promise, response);
  44636. }
  44637. }, function (error) {
  44638. if (!called) {
  44639. called = true;
  44640. handlers.reject(promise, error);
  44641. }
  44642. });
  44643. }
  44644. }
  44645. }, { "immediate": 386 }], 426: [function (require, module, exports) {
  44646. (function (global) {
  44647. "use strict";
  44648. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  44649. /**
  44650. * lodash (Custom Build) <https://lodash.com/>
  44651. * Build: `lodash modularize exports="npm" -o ./`
  44652. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  44653. * Released under MIT license <https://lodash.com/license>
  44654. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  44655. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  44656. */
  44657. /** Used as references for various `Number` constants. */
  44658. var INFINITY = 1 / 0;
  44659. /** `Object#toString` result references. */
  44660. var symbolTag = '[object Symbol]';
  44661. /**
  44662. * Used to match `RegExp`
  44663. * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
  44664. */
  44665. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  44666. reHasRegExpChar = RegExp(reRegExpChar.source);
  44667. /** Detect free variable `global` from Node.js. */
  44668. var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
  44669. /** Detect free variable `self`. */
  44670. var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
  44671. /** Used as a reference to the global object. */
  44672. var root = freeGlobal || freeSelf || Function('return this')();
  44673. /** Used for built-in method references. */
  44674. var objectProto = Object.prototype;
  44675. /**
  44676. * Used to resolve the
  44677. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  44678. * of values.
  44679. */
  44680. var objectToString = objectProto.toString;
  44681. /** Built-in value references. */
  44682. var _Symbol = root.Symbol;
  44683. /** Used to convert symbols to primitives and strings. */
  44684. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  44685. symbolToString = symbolProto ? symbolProto.toString : undefined;
  44686. /**
  44687. * The base implementation of `_.toString` which doesn't convert nullish
  44688. * values to empty strings.
  44689. *
  44690. * @private
  44691. * @param {*} value The value to process.
  44692. * @returns {string} Returns the string.
  44693. */
  44694. function baseToString(value) {
  44695. // Exit early for strings to avoid a performance hit in some environments.
  44696. if (typeof value == 'string') {
  44697. return value;
  44698. }
  44699. if (isSymbol(value)) {
  44700. return symbolToString ? symbolToString.call(value) : '';
  44701. }
  44702. var result = value + '';
  44703. return result == '0' && 1 / value == -INFINITY ? '-0' : result;
  44704. }
  44705. /**
  44706. * Checks if `value` is object-like. A value is object-like if it's not `null`
  44707. * and has a `typeof` result of "object".
  44708. *
  44709. * @static
  44710. * @memberOf _
  44711. * @since 4.0.0
  44712. * @category Lang
  44713. * @param {*} value The value to check.
  44714. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  44715. * @example
  44716. *
  44717. * _.isObjectLike({});
  44718. * // => true
  44719. *
  44720. * _.isObjectLike([1, 2, 3]);
  44721. * // => true
  44722. *
  44723. * _.isObjectLike(_.noop);
  44724. * // => false
  44725. *
  44726. * _.isObjectLike(null);
  44727. * // => false
  44728. */
  44729. function isObjectLike(value) {
  44730. return !!value && _typeof(value) == 'object';
  44731. }
  44732. /**
  44733. * Checks if `value` is classified as a `Symbol` primitive or object.
  44734. *
  44735. * @static
  44736. * @memberOf _
  44737. * @since 4.0.0
  44738. * @category Lang
  44739. * @param {*} value The value to check.
  44740. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  44741. * @example
  44742. *
  44743. * _.isSymbol(Symbol.iterator);
  44744. * // => true
  44745. *
  44746. * _.isSymbol('abc');
  44747. * // => false
  44748. */
  44749. function isSymbol(value) {
  44750. return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
  44751. }
  44752. /**
  44753. * Converts `value` to a string. An empty string is returned for `null`
  44754. * and `undefined` values. The sign of `-0` is preserved.
  44755. *
  44756. * @static
  44757. * @memberOf _
  44758. * @since 4.0.0
  44759. * @category Lang
  44760. * @param {*} value The value to process.
  44761. * @returns {string} Returns the string.
  44762. * @example
  44763. *
  44764. * _.toString(null);
  44765. * // => ''
  44766. *
  44767. * _.toString(-0);
  44768. * // => '-0'
  44769. *
  44770. * _.toString([1, 2, 3]);
  44771. * // => '1,2,3'
  44772. */
  44773. function toString(value) {
  44774. return value == null ? '' : baseToString(value);
  44775. }
  44776. /**
  44777. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  44778. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  44779. *
  44780. * @static
  44781. * @memberOf _
  44782. * @since 3.0.0
  44783. * @category String
  44784. * @param {string} [string=''] The string to escape.
  44785. * @returns {string} Returns the escaped string.
  44786. * @example
  44787. *
  44788. * _.escapeRegExp('[lodash](https://lodash.com/)');
  44789. * // => '\[lodash\]\(https://lodash\.com/\)'
  44790. */
  44791. function escapeRegExp(string) {
  44792. string = toString(string);
  44793. return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, '\\$&') : string;
  44794. }
  44795. module.exports = escapeRegExp;
  44796. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  44797. }, {}], 427: [function (require, module, exports) {
  44798. (function (global) {
  44799. "use strict";
  44800. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  44801. /**
  44802. * lodash (Custom Build) <https://lodash.com/>
  44803. * Build: `lodash modularize exports="npm" -o ./`
  44804. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  44805. * Released under MIT license <https://lodash.com/license>
  44806. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  44807. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  44808. */
  44809. /** Used as the size to enable large array optimizations. */
  44810. var LARGE_ARRAY_SIZE = 200;
  44811. /** Used as the `TypeError` message for "Functions" methods. */
  44812. var FUNC_ERROR_TEXT = 'Expected a function';
  44813. /** Used to stand-in for `undefined` hash values. */
  44814. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  44815. /** Used to compose bitmasks for comparison styles. */
  44816. var UNORDERED_COMPARE_FLAG = 1,
  44817. PARTIAL_COMPARE_FLAG = 2;
  44818. /** Used as references for various `Number` constants. */
  44819. var INFINITY = 1 / 0,
  44820. MAX_SAFE_INTEGER = 9007199254740991;
  44821. /** `Object#toString` result references. */
  44822. var argsTag = '[object Arguments]',
  44823. arrayTag = '[object Array]',
  44824. boolTag = '[object Boolean]',
  44825. dateTag = '[object Date]',
  44826. errorTag = '[object Error]',
  44827. funcTag = '[object Function]',
  44828. genTag = '[object GeneratorFunction]',
  44829. mapTag = '[object Map]',
  44830. numberTag = '[object Number]',
  44831. objectTag = '[object Object]',
  44832. promiseTag = '[object Promise]',
  44833. regexpTag = '[object RegExp]',
  44834. setTag = '[object Set]',
  44835. stringTag = '[object String]',
  44836. symbolTag = '[object Symbol]',
  44837. weakMapTag = '[object WeakMap]';
  44838. var arrayBufferTag = '[object ArrayBuffer]',
  44839. dataViewTag = '[object DataView]',
  44840. float32Tag = '[object Float32Array]',
  44841. float64Tag = '[object Float64Array]',
  44842. int8Tag = '[object Int8Array]',
  44843. int16Tag = '[object Int16Array]',
  44844. int32Tag = '[object Int32Array]',
  44845. uint8Tag = '[object Uint8Array]',
  44846. uint8ClampedTag = '[object Uint8ClampedArray]',
  44847. uint16Tag = '[object Uint16Array]',
  44848. uint32Tag = '[object Uint32Array]';
  44849. /** Used to match property names within property paths. */
  44850. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  44851. reIsPlainProp = /^\w*$/,
  44852. reLeadingDot = /^\./,
  44853. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  44854. /**
  44855. * Used to match `RegExp`
  44856. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  44857. */
  44858. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  44859. /** Used to match backslashes in property paths. */
  44860. var reEscapeChar = /\\(\\)?/g;
  44861. /** Used to detect host constructors (Safari). */
  44862. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  44863. /** Used to detect unsigned integer values. */
  44864. var reIsUint = /^(?:0|[1-9]\d*)$/;
  44865. /** Used to identify `toStringTag` values of typed arrays. */
  44866. var typedArrayTags = {};
  44867. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  44868. typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  44869. /** Detect free variable `global` from Node.js. */
  44870. var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
  44871. /** Detect free variable `self`. */
  44872. var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
  44873. /** Used as a reference to the global object. */
  44874. var root = freeGlobal || freeSelf || Function('return this')();
  44875. /** Detect free variable `exports`. */
  44876. var freeExports = (typeof exports === "undefined" ? "undefined" : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;
  44877. /** Detect free variable `module`. */
  44878. var freeModule = freeExports && (typeof module === "undefined" ? "undefined" : _typeof(module)) == 'object' && module && !module.nodeType && module;
  44879. /** Detect the popular CommonJS extension `module.exports`. */
  44880. var moduleExports = freeModule && freeModule.exports === freeExports;
  44881. /** Detect free variable `process` from Node.js. */
  44882. var freeProcess = moduleExports && freeGlobal.process;
  44883. /** Used to access faster Node.js helpers. */
  44884. var nodeUtil = function () {
  44885. try {
  44886. return freeProcess && freeProcess.binding('util');
  44887. } catch (e) { }
  44888. }();
  44889. /* Node.js helper references. */
  44890. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  44891. /**
  44892. * A specialized version of `baseAggregator` for arrays.
  44893. *
  44894. * @private
  44895. * @param {Array} [array] The array to iterate over.
  44896. * @param {Function} setter The function to set `accumulator` values.
  44897. * @param {Function} iteratee The iteratee to transform keys.
  44898. * @param {Object} accumulator The initial aggregated object.
  44899. * @returns {Function} Returns `accumulator`.
  44900. */
  44901. function arrayAggregator(array, setter, iteratee, accumulator) {
  44902. var index = -1,
  44903. length = array ? array.length : 0;
  44904. while (++index < length) {
  44905. var value = array[index];
  44906. setter(accumulator, value, iteratee(value), array);
  44907. }
  44908. return accumulator;
  44909. }
  44910. /**
  44911. * A specialized version of `_.some` for arrays without support for iteratee
  44912. * shorthands.
  44913. *
  44914. * @private
  44915. * @param {Array} [array] The array to iterate over.
  44916. * @param {Function} predicate The function invoked per iteration.
  44917. * @returns {boolean} Returns `true` if any element passes the predicate check,
  44918. * else `false`.
  44919. */
  44920. function arraySome(array, predicate) {
  44921. var index = -1,
  44922. length = array ? array.length : 0;
  44923. while (++index < length) {
  44924. if (predicate(array[index], index, array)) {
  44925. return true;
  44926. }
  44927. }
  44928. return false;
  44929. }
  44930. /**
  44931. * The base implementation of `_.property` without support for deep paths.
  44932. *
  44933. * @private
  44934. * @param {string} key The key of the property to get.
  44935. * @returns {Function} Returns the new accessor function.
  44936. */
  44937. function baseProperty(key) {
  44938. return function (object) {
  44939. return object == null ? undefined : object[key];
  44940. };
  44941. }
  44942. /**
  44943. * The base implementation of `_.times` without support for iteratee shorthands
  44944. * or max array length checks.
  44945. *
  44946. * @private
  44947. * @param {number} n The number of times to invoke `iteratee`.
  44948. * @param {Function} iteratee The function invoked per iteration.
  44949. * @returns {Array} Returns the array of results.
  44950. */
  44951. function baseTimes(n, iteratee) {
  44952. var index = -1,
  44953. result = Array(n);
  44954. while (++index < n) {
  44955. result[index] = iteratee(index);
  44956. }
  44957. return result;
  44958. }
  44959. /**
  44960. * The base implementation of `_.unary` without support for storing metadata.
  44961. *
  44962. * @private
  44963. * @param {Function} func The function to cap arguments for.
  44964. * @returns {Function} Returns the new capped function.
  44965. */
  44966. function baseUnary(func) {
  44967. return function (value) {
  44968. return func(value);
  44969. };
  44970. }
  44971. /**
  44972. * Gets the value at `key` of `object`.
  44973. *
  44974. * @private
  44975. * @param {Object} [object] The object to query.
  44976. * @param {string} key The key of the property to get.
  44977. * @returns {*} Returns the property value.
  44978. */
  44979. function getValue(object, key) {
  44980. return object == null ? undefined : object[key];
  44981. }
  44982. /**
  44983. * Checks if `value` is a host object in IE < 9.
  44984. *
  44985. * @private
  44986. * @param {*} value The value to check.
  44987. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  44988. */
  44989. function isHostObject(value) {
  44990. // Many host objects are `Object` objects that can coerce to strings
  44991. // despite having improperly defined `toString` methods.
  44992. var result = false;
  44993. if (value != null && typeof value.toString != 'function') {
  44994. try {
  44995. result = !!(value + '');
  44996. } catch (e) { }
  44997. }
  44998. return result;
  44999. }
  45000. /**
  45001. * Converts `map` to its key-value pairs.
  45002. *
  45003. * @private
  45004. * @param {Object} map The map to convert.
  45005. * @returns {Array} Returns the key-value pairs.
  45006. */
  45007. function mapToArray(map) {
  45008. var index = -1,
  45009. result = Array(map.size);
  45010. map.forEach(function (value, key) {
  45011. result[++index] = [key, value];
  45012. });
  45013. return result;
  45014. }
  45015. /**
  45016. * Creates a unary function that invokes `func` with its argument transformed.
  45017. *
  45018. * @private
  45019. * @param {Function} func The function to wrap.
  45020. * @param {Function} transform The argument transform.
  45021. * @returns {Function} Returns the new function.
  45022. */
  45023. function overArg(func, transform) {
  45024. return function (arg) {
  45025. return func(transform(arg));
  45026. };
  45027. }
  45028. /**
  45029. * Converts `set` to an array of its values.
  45030. *
  45031. * @private
  45032. * @param {Object} set The set to convert.
  45033. * @returns {Array} Returns the values.
  45034. */
  45035. function setToArray(set) {
  45036. var index = -1,
  45037. result = Array(set.size);
  45038. set.forEach(function (value) {
  45039. result[++index] = value;
  45040. });
  45041. return result;
  45042. }
  45043. /** Used for built-in method references. */
  45044. var arrayProto = Array.prototype,
  45045. funcProto = Function.prototype,
  45046. objectProto = Object.prototype;
  45047. /** Used to detect overreaching core-js shims. */
  45048. var coreJsData = root['__core-js_shared__'];
  45049. /** Used to detect methods masquerading as native. */
  45050. var maskSrcKey = function () {
  45051. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  45052. return uid ? 'Symbol(src)_1.' + uid : '';
  45053. }();
  45054. /** Used to resolve the decompiled source of functions. */
  45055. var funcToString = funcProto.toString;
  45056. /** Used to check objects for own properties. */
  45057. var hasOwnProperty = objectProto.hasOwnProperty;
  45058. /**
  45059. * Used to resolve the
  45060. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  45061. * of values.
  45062. */
  45063. var objectToString = objectProto.toString;
  45064. /** Used to detect if a method is native. */
  45065. var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  45066. /** Built-in value references. */
  45067. var _Symbol = root.Symbol,
  45068. Uint8Array = root.Uint8Array,
  45069. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  45070. splice = arrayProto.splice;
  45071. /* Built-in method references for those with the same name as other `lodash` methods. */
  45072. var nativeKeys = overArg(Object.keys, Object);
  45073. /* Built-in method references that are verified to be native. */
  45074. var DataView = getNative(root, 'DataView'),
  45075. Map = getNative(root, 'Map'),
  45076. Promise = getNative(root, 'Promise'),
  45077. Set = getNative(root, 'Set'),
  45078. WeakMap = getNative(root, 'WeakMap'),
  45079. nativeCreate = getNative(Object, 'create');
  45080. /** Used to detect maps, sets, and weakmaps. */
  45081. var dataViewCtorString = toSource(DataView),
  45082. mapCtorString = toSource(Map),
  45083. promiseCtorString = toSource(Promise),
  45084. setCtorString = toSource(Set),
  45085. weakMapCtorString = toSource(WeakMap);
  45086. /** Used to convert symbols to primitives and strings. */
  45087. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  45088. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  45089. symbolToString = symbolProto ? symbolProto.toString : undefined;
  45090. /**
  45091. * Creates a hash object.
  45092. *
  45093. * @private
  45094. * @constructor
  45095. * @param {Array} [entries] The key-value pairs to cache.
  45096. */
  45097. function Hash(entries) {
  45098. var index = -1,
  45099. length = entries ? entries.length : 0;
  45100. this.clear();
  45101. while (++index < length) {
  45102. var entry = entries[index];
  45103. this.set(entry[0], entry[1]);
  45104. }
  45105. }
  45106. /**
  45107. * Removes all key-value entries from the hash.
  45108. *
  45109. * @private
  45110. * @name clear
  45111. * @memberOf Hash
  45112. */
  45113. function hashClear() {
  45114. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  45115. }
  45116. /**
  45117. * Removes `key` and its value from the hash.
  45118. *
  45119. * @private
  45120. * @name delete
  45121. * @memberOf Hash
  45122. * @param {Object} hash The hash to modify.
  45123. * @param {string} key The key of the value to remove.
  45124. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  45125. */
  45126. function hashDelete(key) {
  45127. return this.has(key) && delete this.__data__[key];
  45128. }
  45129. /**
  45130. * Gets the hash value for `key`.
  45131. *
  45132. * @private
  45133. * @name get
  45134. * @memberOf Hash
  45135. * @param {string} key The key of the value to get.
  45136. * @returns {*} Returns the entry value.
  45137. */
  45138. function hashGet(key) {
  45139. var data = this.__data__;
  45140. if (nativeCreate) {
  45141. var result = data[key];
  45142. return result === HASH_UNDEFINED ? undefined : result;
  45143. }
  45144. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  45145. }
  45146. /**
  45147. * Checks if a hash value for `key` exists.
  45148. *
  45149. * @private
  45150. * @name has
  45151. * @memberOf Hash
  45152. * @param {string} key The key of the entry to check.
  45153. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  45154. */
  45155. function hashHas(key) {
  45156. var data = this.__data__;
  45157. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  45158. }
  45159. /**
  45160. * Sets the hash `key` to `value`.
  45161. *
  45162. * @private
  45163. * @name set
  45164. * @memberOf Hash
  45165. * @param {string} key The key of the value to set.
  45166. * @param {*} value The value to set.
  45167. * @returns {Object} Returns the hash instance.
  45168. */
  45169. function hashSet(key, value) {
  45170. var data = this.__data__;
  45171. data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
  45172. return this;
  45173. } // Add methods to `Hash`.
  45174. Hash.prototype.clear = hashClear;
  45175. Hash.prototype['delete'] = hashDelete;
  45176. Hash.prototype.get = hashGet;
  45177. Hash.prototype.has = hashHas;
  45178. Hash.prototype.set = hashSet;
  45179. /**
  45180. * Creates an list cache object.
  45181. *
  45182. * @private
  45183. * @constructor
  45184. * @param {Array} [entries] The key-value pairs to cache.
  45185. */
  45186. function ListCache(entries) {
  45187. var index = -1,
  45188. length = entries ? entries.length : 0;
  45189. this.clear();
  45190. while (++index < length) {
  45191. var entry = entries[index];
  45192. this.set(entry[0], entry[1]);
  45193. }
  45194. }
  45195. /**
  45196. * Removes all key-value entries from the list cache.
  45197. *
  45198. * @private
  45199. * @name clear
  45200. * @memberOf ListCache
  45201. */
  45202. function listCacheClear() {
  45203. this.__data__ = [];
  45204. }
  45205. /**
  45206. * Removes `key` and its value from the list cache.
  45207. *
  45208. * @private
  45209. * @name delete
  45210. * @memberOf ListCache
  45211. * @param {string} key The key of the value to remove.
  45212. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  45213. */
  45214. function listCacheDelete(key) {
  45215. var data = this.__data__,
  45216. index = assocIndexOf(data, key);
  45217. if (index < 0) {
  45218. return false;
  45219. }
  45220. var lastIndex = data.length - 1;
  45221. if (index == lastIndex) {
  45222. data.pop();
  45223. } else {
  45224. splice.call(data, index, 1);
  45225. }
  45226. return true;
  45227. }
  45228. /**
  45229. * Gets the list cache value for `key`.
  45230. *
  45231. * @private
  45232. * @name get
  45233. * @memberOf ListCache
  45234. * @param {string} key The key of the value to get.
  45235. * @returns {*} Returns the entry value.
  45236. */
  45237. function listCacheGet(key) {
  45238. var data = this.__data__,
  45239. index = assocIndexOf(data, key);
  45240. return index < 0 ? undefined : data[index][1];
  45241. }
  45242. /**
  45243. * Checks if a list cache value for `key` exists.
  45244. *
  45245. * @private
  45246. * @name has
  45247. * @memberOf ListCache
  45248. * @param {string} key The key of the entry to check.
  45249. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  45250. */
  45251. function listCacheHas(key) {
  45252. return assocIndexOf(this.__data__, key) > -1;
  45253. }
  45254. /**
  45255. * Sets the list cache `key` to `value`.
  45256. *
  45257. * @private
  45258. * @name set
  45259. * @memberOf ListCache
  45260. * @param {string} key The key of the value to set.
  45261. * @param {*} value The value to set.
  45262. * @returns {Object} Returns the list cache instance.
  45263. */
  45264. function listCacheSet(key, value) {
  45265. var data = this.__data__,
  45266. index = assocIndexOf(data, key);
  45267. if (index < 0) {
  45268. data.push([key, value]);
  45269. } else {
  45270. data[index][1] = value;
  45271. }
  45272. return this;
  45273. } // Add methods to `ListCache`.
  45274. ListCache.prototype.clear = listCacheClear;
  45275. ListCache.prototype['delete'] = listCacheDelete;
  45276. ListCache.prototype.get = listCacheGet;
  45277. ListCache.prototype.has = listCacheHas;
  45278. ListCache.prototype.set = listCacheSet;
  45279. /**
  45280. * Creates a map cache object to store key-value pairs.
  45281. *
  45282. * @private
  45283. * @constructor
  45284. * @param {Array} [entries] The key-value pairs to cache.
  45285. */
  45286. function MapCache(entries) {
  45287. var index = -1,
  45288. length = entries ? entries.length : 0;
  45289. this.clear();
  45290. while (++index < length) {
  45291. var entry = entries[index];
  45292. this.set(entry[0], entry[1]);
  45293. }
  45294. }
  45295. /**
  45296. * Removes all key-value entries from the map.
  45297. *
  45298. * @private
  45299. * @name clear
  45300. * @memberOf MapCache
  45301. */
  45302. function mapCacheClear() {
  45303. this.__data__ = {
  45304. 'hash': new Hash(),
  45305. 'map': new (Map || ListCache)(),
  45306. 'string': new Hash()
  45307. };
  45308. }
  45309. /**
  45310. * Removes `key` and its value from the map.
  45311. *
  45312. * @private
  45313. * @name delete
  45314. * @memberOf MapCache
  45315. * @param {string} key The key of the value to remove.
  45316. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  45317. */
  45318. function mapCacheDelete(key) {
  45319. return getMapData(this, key)['delete'](key);
  45320. }
  45321. /**
  45322. * Gets the map value for `key`.
  45323. *
  45324. * @private
  45325. * @name get
  45326. * @memberOf MapCache
  45327. * @param {string} key The key of the value to get.
  45328. * @returns {*} Returns the entry value.
  45329. */
  45330. function mapCacheGet(key) {
  45331. return getMapData(this, key).get(key);
  45332. }
  45333. /**
  45334. * Checks if a map value for `key` exists.
  45335. *
  45336. * @private
  45337. * @name has
  45338. * @memberOf MapCache
  45339. * @param {string} key The key of the entry to check.
  45340. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  45341. */
  45342. function mapCacheHas(key) {
  45343. return getMapData(this, key).has(key);
  45344. }
  45345. /**
  45346. * Sets the map `key` to `value`.
  45347. *
  45348. * @private
  45349. * @name set
  45350. * @memberOf MapCache
  45351. * @param {string} key The key of the value to set.
  45352. * @param {*} value The value to set.
  45353. * @returns {Object} Returns the map cache instance.
  45354. */
  45355. function mapCacheSet(key, value) {
  45356. getMapData(this, key).set(key, value);
  45357. return this;
  45358. } // Add methods to `MapCache`.
  45359. MapCache.prototype.clear = mapCacheClear;
  45360. MapCache.prototype['delete'] = mapCacheDelete;
  45361. MapCache.prototype.get = mapCacheGet;
  45362. MapCache.prototype.has = mapCacheHas;
  45363. MapCache.prototype.set = mapCacheSet;
  45364. /**
  45365. *
  45366. * Creates an array cache object to store unique values.
  45367. *
  45368. * @private
  45369. * @constructor
  45370. * @param {Array} [values] The values to cache.
  45371. */
  45372. function SetCache(values) {
  45373. var index = -1,
  45374. length = values ? values.length : 0;
  45375. this.__data__ = new MapCache();
  45376. while (++index < length) {
  45377. this.add(values[index]);
  45378. }
  45379. }
  45380. /**
  45381. * Adds `value` to the array cache.
  45382. *
  45383. * @private
  45384. * @name add
  45385. * @memberOf SetCache
  45386. * @alias push
  45387. * @param {*} value The value to cache.
  45388. * @returns {Object} Returns the cache instance.
  45389. */
  45390. function setCacheAdd(value) {
  45391. this.__data__.set(value, HASH_UNDEFINED);
  45392. return this;
  45393. }
  45394. /**
  45395. * Checks if `value` is in the array cache.
  45396. *
  45397. * @private
  45398. * @name has
  45399. * @memberOf SetCache
  45400. * @param {*} value The value to search for.
  45401. * @returns {number} Returns `true` if `value` is found, else `false`.
  45402. */
  45403. function setCacheHas(value) {
  45404. return this.__data__.has(value);
  45405. } // Add methods to `SetCache`.
  45406. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  45407. SetCache.prototype.has = setCacheHas;
  45408. /**
  45409. * Creates a stack cache object to store key-value pairs.
  45410. *
  45411. * @private
  45412. * @constructor
  45413. * @param {Array} [entries] The key-value pairs to cache.
  45414. */
  45415. function Stack(entries) {
  45416. this.__data__ = new ListCache(entries);
  45417. }
  45418. /**
  45419. * Removes all key-value entries from the stack.
  45420. *
  45421. * @private
  45422. * @name clear
  45423. * @memberOf Stack
  45424. */
  45425. function stackClear() {
  45426. this.__data__ = new ListCache();
  45427. }
  45428. /**
  45429. * Removes `key` and its value from the stack.
  45430. *
  45431. * @private
  45432. * @name delete
  45433. * @memberOf Stack
  45434. * @param {string} key The key of the value to remove.
  45435. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  45436. */
  45437. function stackDelete(key) {
  45438. return this.__data__['delete'](key);
  45439. }
  45440. /**
  45441. * Gets the stack value for `key`.
  45442. *
  45443. * @private
  45444. * @name get
  45445. * @memberOf Stack
  45446. * @param {string} key The key of the value to get.
  45447. * @returns {*} Returns the entry value.
  45448. */
  45449. function stackGet(key) {
  45450. return this.__data__.get(key);
  45451. }
  45452. /**
  45453. * Checks if a stack value for `key` exists.
  45454. *
  45455. * @private
  45456. * @name has
  45457. * @memberOf Stack
  45458. * @param {string} key The key of the entry to check.
  45459. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  45460. */
  45461. function stackHas(key) {
  45462. return this.__data__.has(key);
  45463. }
  45464. /**
  45465. * Sets the stack `key` to `value`.
  45466. *
  45467. * @private
  45468. * @name set
  45469. * @memberOf Stack
  45470. * @param {string} key The key of the value to set.
  45471. * @param {*} value The value to set.
  45472. * @returns {Object} Returns the stack cache instance.
  45473. */
  45474. function stackSet(key, value) {
  45475. var cache = this.__data__;
  45476. if (cache instanceof ListCache) {
  45477. var pairs = cache.__data__;
  45478. if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
  45479. pairs.push([key, value]);
  45480. return this;
  45481. }
  45482. cache = this.__data__ = new MapCache(pairs);
  45483. }
  45484. cache.set(key, value);
  45485. return this;
  45486. } // Add methods to `Stack`.
  45487. Stack.prototype.clear = stackClear;
  45488. Stack.prototype['delete'] = stackDelete;
  45489. Stack.prototype.get = stackGet;
  45490. Stack.prototype.has = stackHas;
  45491. Stack.prototype.set = stackSet;
  45492. /**
  45493. * Creates an array of the enumerable property names of the array-like `value`.
  45494. *
  45495. * @private
  45496. * @param {*} value The value to query.
  45497. * @param {boolean} inherited Specify returning inherited property names.
  45498. * @returns {Array} Returns the array of property names.
  45499. */
  45500. function arrayLikeKeys(value, inherited) {
  45501. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  45502. // Safari 9 makes `arguments.length` enumerable in strict mode.
  45503. var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : [];
  45504. var length = result.length,
  45505. skipIndexes = !!length;
  45506. for (var key in value) {
  45507. if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
  45508. result.push(key);
  45509. }
  45510. }
  45511. return result;
  45512. }
  45513. /**
  45514. * Gets the index at which the `key` is found in `array` of key-value pairs.
  45515. *
  45516. * @private
  45517. * @param {Array} array The array to inspect.
  45518. * @param {*} key The key to search for.
  45519. * @returns {number} Returns the index of the matched value, else `-1`.
  45520. */
  45521. function assocIndexOf(array, key) {
  45522. var length = array.length;
  45523. while (length--) {
  45524. if (eq(array[length][0], key)) {
  45525. return length;
  45526. }
  45527. }
  45528. return -1;
  45529. }
  45530. /**
  45531. * Aggregates elements of `collection` on `accumulator` with keys transformed
  45532. * by `iteratee` and values set by `setter`.
  45533. *
  45534. * @private
  45535. * @param {Array|Object} collection The collection to iterate over.
  45536. * @param {Function} setter The function to set `accumulator` values.
  45537. * @param {Function} iteratee The iteratee to transform keys.
  45538. * @param {Object} accumulator The initial aggregated object.
  45539. * @returns {Function} Returns `accumulator`.
  45540. */
  45541. function baseAggregator(collection, setter, iteratee, accumulator) {
  45542. baseEach(collection, function (value, key, collection) {
  45543. setter(accumulator, value, iteratee(value), collection);
  45544. });
  45545. return accumulator;
  45546. }
  45547. /**
  45548. * The base implementation of `_.forEach` without support for iteratee shorthands.
  45549. *
  45550. * @private
  45551. * @param {Array|Object} collection The collection to iterate over.
  45552. * @param {Function} iteratee The function invoked per iteration.
  45553. * @returns {Array|Object} Returns `collection`.
  45554. */
  45555. var baseEach = createBaseEach(baseForOwn);
  45556. /**
  45557. * The base implementation of `baseForOwn` which iterates over `object`
  45558. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  45559. * Iteratee functions may exit iteration early by explicitly returning `false`.
  45560. *
  45561. * @private
  45562. * @param {Object} object The object to iterate over.
  45563. * @param {Function} iteratee The function invoked per iteration.
  45564. * @param {Function} keysFunc The function to get the keys of `object`.
  45565. * @returns {Object} Returns `object`.
  45566. */
  45567. var baseFor = createBaseFor();
  45568. /**
  45569. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  45570. *
  45571. * @private
  45572. * @param {Object} object The object to iterate over.
  45573. * @param {Function} iteratee The function invoked per iteration.
  45574. * @returns {Object} Returns `object`.
  45575. */
  45576. function baseForOwn(object, iteratee) {
  45577. return object && baseFor(object, iteratee, keys);
  45578. }
  45579. /**
  45580. * The base implementation of `_.get` without support for default values.
  45581. *
  45582. * @private
  45583. * @param {Object} object The object to query.
  45584. * @param {Array|string} path The path of the property to get.
  45585. * @returns {*} Returns the resolved value.
  45586. */
  45587. function baseGet(object, path) {
  45588. path = isKey(path, object) ? [path] : castPath(path);
  45589. var index = 0,
  45590. length = path.length;
  45591. while (object != null && index < length) {
  45592. object = object[toKey(path[index++])];
  45593. }
  45594. return index && index == length ? object : undefined;
  45595. }
  45596. /**
  45597. * The base implementation of `getTag`.
  45598. *
  45599. * @private
  45600. * @param {*} value The value to query.
  45601. * @returns {string} Returns the `toStringTag`.
  45602. */
  45603. function baseGetTag(value) {
  45604. return objectToString.call(value);
  45605. }
  45606. /**
  45607. * The base implementation of `_.hasIn` without support for deep paths.
  45608. *
  45609. * @private
  45610. * @param {Object} [object] The object to query.
  45611. * @param {Array|string} key The key to check.
  45612. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  45613. */
  45614. function baseHasIn(object, key) {
  45615. return object != null && key in Object(object);
  45616. }
  45617. /**
  45618. * The base implementation of `_.isEqual` which supports partial comparisons
  45619. * and tracks traversed objects.
  45620. *
  45621. * @private
  45622. * @param {*} value The value to compare.
  45623. * @param {*} other The other value to compare.
  45624. * @param {Function} [customizer] The function to customize comparisons.
  45625. * @param {boolean} [bitmask] The bitmask of comparison flags.
  45626. * The bitmask may be composed of the following flags:
  45627. * 1 - Unordered comparison
  45628. * 2 - Partial comparison
  45629. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  45630. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  45631. */
  45632. function baseIsEqual(value, other, customizer, bitmask, stack) {
  45633. if (value === other) {
  45634. return true;
  45635. }
  45636. if (value == null || other == null || !isObject(value) && !isObjectLike(other)) {
  45637. return value !== value && other !== other;
  45638. }
  45639. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  45640. }
  45641. /**
  45642. * A specialized version of `baseIsEqual` for arrays and objects which performs
  45643. * deep comparisons and tracks traversed objects enabling objects with circular
  45644. * references to be compared.
  45645. *
  45646. * @private
  45647. * @param {Object} object The object to compare.
  45648. * @param {Object} other The other object to compare.
  45649. * @param {Function} equalFunc The function to determine equivalents of values.
  45650. * @param {Function} [customizer] The function to customize comparisons.
  45651. * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
  45652. * for more details.
  45653. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  45654. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  45655. */
  45656. function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
  45657. var objIsArr = isArray(object),
  45658. othIsArr = isArray(other),
  45659. objTag = arrayTag,
  45660. othTag = arrayTag;
  45661. if (!objIsArr) {
  45662. objTag = getTag(object);
  45663. objTag = objTag == argsTag ? objectTag : objTag;
  45664. }
  45665. if (!othIsArr) {
  45666. othTag = getTag(other);
  45667. othTag = othTag == argsTag ? objectTag : othTag;
  45668. }
  45669. var objIsObj = objTag == objectTag && !isHostObject(object),
  45670. othIsObj = othTag == objectTag && !isHostObject(other),
  45671. isSameTag = objTag == othTag;
  45672. if (isSameTag && !objIsObj) {
  45673. stack || (stack = new Stack());
  45674. return objIsArr || isTypedArray(object) ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
  45675. }
  45676. if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
  45677. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  45678. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  45679. if (objIsWrapped || othIsWrapped) {
  45680. var objUnwrapped = objIsWrapped ? object.value() : object,
  45681. othUnwrapped = othIsWrapped ? other.value() : other;
  45682. stack || (stack = new Stack());
  45683. return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
  45684. }
  45685. }
  45686. if (!isSameTag) {
  45687. return false;
  45688. }
  45689. stack || (stack = new Stack());
  45690. return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
  45691. }
  45692. /**
  45693. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  45694. *
  45695. * @private
  45696. * @param {Object} object The object to inspect.
  45697. * @param {Object} source The object of property values to match.
  45698. * @param {Array} matchData The property names, values, and compare flags to match.
  45699. * @param {Function} [customizer] The function to customize comparisons.
  45700. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  45701. */
  45702. function baseIsMatch(object, source, matchData, customizer) {
  45703. var index = matchData.length,
  45704. length = index,
  45705. noCustomizer = !customizer;
  45706. if (object == null) {
  45707. return !length;
  45708. }
  45709. object = Object(object);
  45710. while (index--) {
  45711. var data = matchData[index];
  45712. if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
  45713. return false;
  45714. }
  45715. }
  45716. while (++index < length) {
  45717. data = matchData[index];
  45718. var key = data[0],
  45719. objValue = object[key],
  45720. srcValue = data[1];
  45721. if (noCustomizer && data[2]) {
  45722. if (objValue === undefined && !(key in object)) {
  45723. return false;
  45724. }
  45725. } else {
  45726. var stack = new Stack();
  45727. if (customizer) {
  45728. var result = customizer(objValue, srcValue, key, object, source, stack);
  45729. }
  45730. if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) {
  45731. return false;
  45732. }
  45733. }
  45734. }
  45735. return true;
  45736. }
  45737. /**
  45738. * The base implementation of `_.isNative` without bad shim checks.
  45739. *
  45740. * @private
  45741. * @param {*} value The value to check.
  45742. * @returns {boolean} Returns `true` if `value` is a native function,
  45743. * else `false`.
  45744. */
  45745. function baseIsNative(value) {
  45746. if (!isObject(value) || isMasked(value)) {
  45747. return false;
  45748. }
  45749. var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
  45750. return pattern.test(toSource(value));
  45751. }
  45752. /**
  45753. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  45754. *
  45755. * @private
  45756. * @param {*} value The value to check.
  45757. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  45758. */
  45759. function baseIsTypedArray(value) {
  45760. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  45761. }
  45762. /**
  45763. * The base implementation of `_.iteratee`.
  45764. *
  45765. * @private
  45766. * @param {*} [value=_.identity] The value to convert to an iteratee.
  45767. * @returns {Function} Returns the iteratee.
  45768. */
  45769. function baseIteratee(value) {
  45770. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  45771. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  45772. if (typeof value == 'function') {
  45773. return value;
  45774. }
  45775. if (value == null) {
  45776. return identity;
  45777. }
  45778. if (_typeof(value) == 'object') {
  45779. return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
  45780. }
  45781. return property(value);
  45782. }
  45783. /**
  45784. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  45785. *
  45786. * @private
  45787. * @param {Object} object The object to query.
  45788. * @returns {Array} Returns the array of property names.
  45789. */
  45790. function baseKeys(object) {
  45791. if (!isPrototype(object)) {
  45792. return nativeKeys(object);
  45793. }
  45794. var result = [];
  45795. for (var key in Object(object)) {
  45796. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  45797. result.push(key);
  45798. }
  45799. }
  45800. return result;
  45801. }
  45802. /**
  45803. * The base implementation of `_.matches` which doesn't clone `source`.
  45804. *
  45805. * @private
  45806. * @param {Object} source The object of property values to match.
  45807. * @returns {Function} Returns the new spec function.
  45808. */
  45809. function baseMatches(source) {
  45810. var matchData = getMatchData(source);
  45811. if (matchData.length == 1 && matchData[0][2]) {
  45812. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  45813. }
  45814. return function (object) {
  45815. return object === source || baseIsMatch(object, source, matchData);
  45816. };
  45817. }
  45818. /**
  45819. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  45820. *
  45821. * @private
  45822. * @param {string} path The path of the property to get.
  45823. * @param {*} srcValue The value to match.
  45824. * @returns {Function} Returns the new spec function.
  45825. */
  45826. function baseMatchesProperty(path, srcValue) {
  45827. if (isKey(path) && isStrictComparable(srcValue)) {
  45828. return matchesStrictComparable(toKey(path), srcValue);
  45829. }
  45830. return function (object) {
  45831. var objValue = get(object, path);
  45832. return objValue === undefined && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
  45833. };
  45834. }
  45835. /**
  45836. * A specialized version of `baseProperty` which supports deep paths.
  45837. *
  45838. * @private
  45839. * @param {Array|string} path The path of the property to get.
  45840. * @returns {Function} Returns the new accessor function.
  45841. */
  45842. function basePropertyDeep(path) {
  45843. return function (object) {
  45844. return baseGet(object, path);
  45845. };
  45846. }
  45847. /**
  45848. * The base implementation of `_.toString` which doesn't convert nullish
  45849. * values to empty strings.
  45850. *
  45851. * @private
  45852. * @param {*} value The value to process.
  45853. * @returns {string} Returns the string.
  45854. */
  45855. function baseToString(value) {
  45856. // Exit early for strings to avoid a performance hit in some environments.
  45857. if (typeof value == 'string') {
  45858. return value;
  45859. }
  45860. if (isSymbol(value)) {
  45861. return symbolToString ? symbolToString.call(value) : '';
  45862. }
  45863. var result = value + '';
  45864. return result == '0' && 1 / value == -INFINITY ? '-0' : result;
  45865. }
  45866. /**
  45867. * Casts `value` to a path array if it's not one.
  45868. *
  45869. * @private
  45870. * @param {*} value The value to inspect.
  45871. * @returns {Array} Returns the cast property path array.
  45872. */
  45873. function castPath(value) {
  45874. return isArray(value) ? value : stringToPath(value);
  45875. }
  45876. /**
  45877. * Creates a function like `_.groupBy`.
  45878. *
  45879. * @private
  45880. * @param {Function} setter The function to set accumulator values.
  45881. * @param {Function} [initializer] The accumulator object initializer.
  45882. * @returns {Function} Returns the new aggregator function.
  45883. */
  45884. function createAggregator(setter, initializer) {
  45885. return function (collection, iteratee) {
  45886. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  45887. accumulator = initializer ? initializer() : {};
  45888. return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
  45889. };
  45890. }
  45891. /**
  45892. * Creates a `baseEach` or `baseEachRight` function.
  45893. *
  45894. * @private
  45895. * @param {Function} eachFunc The function to iterate over a collection.
  45896. * @param {boolean} [fromRight] Specify iterating from right to left.
  45897. * @returns {Function} Returns the new base function.
  45898. */
  45899. function createBaseEach(eachFunc, fromRight) {
  45900. return function (collection, iteratee) {
  45901. if (collection == null) {
  45902. return collection;
  45903. }
  45904. if (!isArrayLike(collection)) {
  45905. return eachFunc(collection, iteratee);
  45906. }
  45907. var length = collection.length,
  45908. index = fromRight ? length : -1,
  45909. iterable = Object(collection);
  45910. while (fromRight ? index-- : ++index < length) {
  45911. if (iteratee(iterable[index], index, iterable) === false) {
  45912. break;
  45913. }
  45914. }
  45915. return collection;
  45916. };
  45917. }
  45918. /**
  45919. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  45920. *
  45921. * @private
  45922. * @param {boolean} [fromRight] Specify iterating from right to left.
  45923. * @returns {Function} Returns the new base function.
  45924. */
  45925. function createBaseFor(fromRight) {
  45926. return function (object, iteratee, keysFunc) {
  45927. var index = -1,
  45928. iterable = Object(object),
  45929. props = keysFunc(object),
  45930. length = props.length;
  45931. while (length--) {
  45932. var key = props[fromRight ? length : ++index];
  45933. if (iteratee(iterable[key], key, iterable) === false) {
  45934. break;
  45935. }
  45936. }
  45937. return object;
  45938. };
  45939. }
  45940. /**
  45941. * A specialized version of `baseIsEqualDeep` for arrays with support for
  45942. * partial deep comparisons.
  45943. *
  45944. * @private
  45945. * @param {Array} array The array to compare.
  45946. * @param {Array} other The other array to compare.
  45947. * @param {Function} equalFunc The function to determine equivalents of values.
  45948. * @param {Function} customizer The function to customize comparisons.
  45949. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  45950. * for more details.
  45951. * @param {Object} stack Tracks traversed `array` and `other` objects.
  45952. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  45953. */
  45954. function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
  45955. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  45956. arrLength = array.length,
  45957. othLength = other.length;
  45958. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  45959. return false;
  45960. } // Assume cyclic values are equal.
  45961. var stacked = stack.get(array);
  45962. if (stacked && stack.get(other)) {
  45963. return stacked == other;
  45964. }
  45965. var index = -1,
  45966. result = true,
  45967. seen = bitmask & UNORDERED_COMPARE_FLAG ? new SetCache() : undefined;
  45968. stack.set(array, other);
  45969. stack.set(other, array); // Ignore non-index properties.
  45970. while (++index < arrLength) {
  45971. var arrValue = array[index],
  45972. othValue = other[index];
  45973. if (customizer) {
  45974. var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
  45975. }
  45976. if (compared !== undefined) {
  45977. if (compared) {
  45978. continue;
  45979. }
  45980. result = false;
  45981. break;
  45982. } // Recursively compare arrays (susceptible to call stack limits).
  45983. if (seen) {
  45984. if (!arraySome(other, function (othValue, othIndex) {
  45985. if (!seen.has(othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  45986. return seen.add(othIndex);
  45987. }
  45988. })) {
  45989. result = false;
  45990. break;
  45991. }
  45992. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  45993. result = false;
  45994. break;
  45995. }
  45996. }
  45997. stack['delete'](array);
  45998. stack['delete'](other);
  45999. return result;
  46000. }
  46001. /**
  46002. * A specialized version of `baseIsEqualDeep` for comparing objects of
  46003. * the same `toStringTag`.
  46004. *
  46005. * **Note:** This function only supports comparing values with tags of
  46006. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  46007. *
  46008. * @private
  46009. * @param {Object} object The object to compare.
  46010. * @param {Object} other The other object to compare.
  46011. * @param {string} tag The `toStringTag` of the objects to compare.
  46012. * @param {Function} equalFunc The function to determine equivalents of values.
  46013. * @param {Function} customizer The function to customize comparisons.
  46014. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  46015. * for more details.
  46016. * @param {Object} stack Tracks traversed `object` and `other` objects.
  46017. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  46018. */
  46019. function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
  46020. switch (tag) {
  46021. case dataViewTag:
  46022. if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
  46023. return false;
  46024. }
  46025. object = object.buffer;
  46026. other = other.buffer;
  46027. case arrayBufferTag:
  46028. if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  46029. return false;
  46030. }
  46031. return true;
  46032. case boolTag:
  46033. case dateTag:
  46034. case numberTag:
  46035. // Coerce booleans to `1` or `0` and dates to milliseconds.
  46036. // Invalid dates are coerced to `NaN`.
  46037. return eq(+object, +other);
  46038. case errorTag:
  46039. return object.name == other.name && object.message == other.message;
  46040. case regexpTag:
  46041. case stringTag:
  46042. // Coerce regexes to strings and treat strings, primitives and objects,
  46043. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  46044. // for more details.
  46045. return object == other + '';
  46046. case mapTag:
  46047. var convert = mapToArray;
  46048. case setTag:
  46049. var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
  46050. convert || (convert = setToArray);
  46051. if (object.size != other.size && !isPartial) {
  46052. return false;
  46053. } // Assume cyclic values are equal.
  46054. var stacked = stack.get(object);
  46055. if (stacked) {
  46056. return stacked == other;
  46057. }
  46058. bitmask |= UNORDERED_COMPARE_FLAG; // Recursively compare objects (susceptible to call stack limits).
  46059. stack.set(object, other);
  46060. var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
  46061. stack['delete'](object);
  46062. return result;
  46063. case symbolTag:
  46064. if (symbolValueOf) {
  46065. return symbolValueOf.call(object) == symbolValueOf.call(other);
  46066. }
  46067. }
  46068. return false;
  46069. }
  46070. /**
  46071. * A specialized version of `baseIsEqualDeep` for objects with support for
  46072. * partial deep comparisons.
  46073. *
  46074. * @private
  46075. * @param {Object} object The object to compare.
  46076. * @param {Object} other The other object to compare.
  46077. * @param {Function} equalFunc The function to determine equivalents of values.
  46078. * @param {Function} customizer The function to customize comparisons.
  46079. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  46080. * for more details.
  46081. * @param {Object} stack Tracks traversed `object` and `other` objects.
  46082. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  46083. */
  46084. function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
  46085. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  46086. objProps = keys(object),
  46087. objLength = objProps.length,
  46088. othProps = keys(other),
  46089. othLength = othProps.length;
  46090. if (objLength != othLength && !isPartial) {
  46091. return false;
  46092. }
  46093. var index = objLength;
  46094. while (index--) {
  46095. var key = objProps[index];
  46096. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  46097. return false;
  46098. }
  46099. } // Assume cyclic values are equal.
  46100. var stacked = stack.get(object);
  46101. if (stacked && stack.get(other)) {
  46102. return stacked == other;
  46103. }
  46104. var result = true;
  46105. stack.set(object, other);
  46106. stack.set(other, object);
  46107. var skipCtor = isPartial;
  46108. while (++index < objLength) {
  46109. key = objProps[index];
  46110. var objValue = object[key],
  46111. othValue = other[key];
  46112. if (customizer) {
  46113. var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
  46114. } // Recursively compare objects (susceptible to call stack limits).
  46115. if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack) : compared)) {
  46116. result = false;
  46117. break;
  46118. }
  46119. skipCtor || (skipCtor = key == 'constructor');
  46120. }
  46121. if (result && !skipCtor) {
  46122. var objCtor = object.constructor,
  46123. othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
  46124. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  46125. result = false;
  46126. }
  46127. }
  46128. stack['delete'](object);
  46129. stack['delete'](other);
  46130. return result;
  46131. }
  46132. /**
  46133. * Gets the data for `map`.
  46134. *
  46135. * @private
  46136. * @param {Object} map The map to query.
  46137. * @param {string} key The reference key.
  46138. * @returns {*} Returns the map data.
  46139. */
  46140. function getMapData(map, key) {
  46141. var data = map.__data__;
  46142. return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
  46143. }
  46144. /**
  46145. * Gets the property names, values, and compare flags of `object`.
  46146. *
  46147. * @private
  46148. * @param {Object} object The object to query.
  46149. * @returns {Array} Returns the match data of `object`.
  46150. */
  46151. function getMatchData(object) {
  46152. var result = keys(object),
  46153. length = result.length;
  46154. while (length--) {
  46155. var key = result[length],
  46156. value = object[key];
  46157. result[length] = [key, value, isStrictComparable(value)];
  46158. }
  46159. return result;
  46160. }
  46161. /**
  46162. * Gets the native function at `key` of `object`.
  46163. *
  46164. * @private
  46165. * @param {Object} object The object to query.
  46166. * @param {string} key The key of the method to get.
  46167. * @returns {*} Returns the function if it's native, else `undefined`.
  46168. */
  46169. function getNative(object, key) {
  46170. var value = getValue(object, key);
  46171. return baseIsNative(value) ? value : undefined;
  46172. }
  46173. /**
  46174. * Gets the `toStringTag` of `value`.
  46175. *
  46176. * @private
  46177. * @param {*} value The value to query.
  46178. * @returns {string} Returns the `toStringTag`.
  46179. */
  46180. var getTag = baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11,
  46181. // for data views in Edge < 14, and promises in Node.js.
  46182. if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise && getTag(Promise.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
  46183. getTag = function getTag(value) {
  46184. var result = objectToString.call(value),
  46185. Ctor = result == objectTag ? value.constructor : undefined,
  46186. ctorString = Ctor ? toSource(Ctor) : undefined;
  46187. if (ctorString) {
  46188. switch (ctorString) {
  46189. case dataViewCtorString:
  46190. return dataViewTag;
  46191. case mapCtorString:
  46192. return mapTag;
  46193. case promiseCtorString:
  46194. return promiseTag;
  46195. case setCtorString:
  46196. return setTag;
  46197. case weakMapCtorString:
  46198. return weakMapTag;
  46199. }
  46200. }
  46201. return result;
  46202. };
  46203. }
  46204. /**
  46205. * Checks if `path` exists on `object`.
  46206. *
  46207. * @private
  46208. * @param {Object} object The object to query.
  46209. * @param {Array|string} path The path to check.
  46210. * @param {Function} hasFunc The function to check properties.
  46211. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  46212. */
  46213. function hasPath(object, path, hasFunc) {
  46214. path = isKey(path, object) ? [path] : castPath(path);
  46215. var result,
  46216. index = -1,
  46217. length = path.length;
  46218. while (++index < length) {
  46219. var key = toKey(path[index]);
  46220. if (!(result = object != null && hasFunc(object, key))) {
  46221. break;
  46222. }
  46223. object = object[key];
  46224. }
  46225. if (result) {
  46226. return result;
  46227. }
  46228. var length = object ? object.length : 0;
  46229. return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
  46230. }
  46231. /**
  46232. * Checks if `value` is a valid array-like index.
  46233. *
  46234. * @private
  46235. * @param {*} value The value to check.
  46236. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  46237. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  46238. */
  46239. function isIndex(value, length) {
  46240. length = length == null ? MAX_SAFE_INTEGER : length;
  46241. return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
  46242. }
  46243. /**
  46244. * Checks if `value` is a property name and not a property path.
  46245. *
  46246. * @private
  46247. * @param {*} value The value to check.
  46248. * @param {Object} [object] The object to query keys on.
  46249. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  46250. */
  46251. function isKey(value, object) {
  46252. if (isArray(value)) {
  46253. return false;
  46254. }
  46255. var type = _typeof(value);
  46256. if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) {
  46257. return true;
  46258. }
  46259. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
  46260. }
  46261. /**
  46262. * Checks if `value` is suitable for use as unique object key.
  46263. *
  46264. * @private
  46265. * @param {*} value The value to check.
  46266. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  46267. */
  46268. function isKeyable(value) {
  46269. var type = _typeof(value);
  46270. return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
  46271. }
  46272. /**
  46273. * Checks if `func` has its source masked.
  46274. *
  46275. * @private
  46276. * @param {Function} func The function to check.
  46277. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  46278. */
  46279. function isMasked(func) {
  46280. return !!maskSrcKey && maskSrcKey in func;
  46281. }
  46282. /**
  46283. * Checks if `value` is likely a prototype object.
  46284. *
  46285. * @private
  46286. * @param {*} value The value to check.
  46287. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  46288. */
  46289. function isPrototype(value) {
  46290. var Ctor = value && value.constructor,
  46291. proto = typeof Ctor == 'function' && Ctor.prototype || objectProto;
  46292. return value === proto;
  46293. }
  46294. /**
  46295. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  46296. *
  46297. * @private
  46298. * @param {*} value The value to check.
  46299. * @returns {boolean} Returns `true` if `value` if suitable for strict
  46300. * equality comparisons, else `false`.
  46301. */
  46302. function isStrictComparable(value) {
  46303. return value === value && !isObject(value);
  46304. }
  46305. /**
  46306. * A specialized version of `matchesProperty` for source values suitable
  46307. * for strict equality comparisons, i.e. `===`.
  46308. *
  46309. * @private
  46310. * @param {string} key The key of the property to get.
  46311. * @param {*} srcValue The value to match.
  46312. * @returns {Function} Returns the new spec function.
  46313. */
  46314. function matchesStrictComparable(key, srcValue) {
  46315. return function (object) {
  46316. if (object == null) {
  46317. return false;
  46318. }
  46319. return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
  46320. };
  46321. }
  46322. /**
  46323. * Converts `string` to a property path array.
  46324. *
  46325. * @private
  46326. * @param {string} string The string to convert.
  46327. * @returns {Array} Returns the property path array.
  46328. */
  46329. var stringToPath = memoize(function (string) {
  46330. string = toString(string);
  46331. var result = [];
  46332. if (reLeadingDot.test(string)) {
  46333. result.push('');
  46334. }
  46335. string.replace(rePropName, function (match, number, quote, string) {
  46336. result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
  46337. });
  46338. return result;
  46339. });
  46340. /**
  46341. * Converts `value` to a string key if it's not a string or symbol.
  46342. *
  46343. * @private
  46344. * @param {*} value The value to inspect.
  46345. * @returns {string|symbol} Returns the key.
  46346. */
  46347. function toKey(value) {
  46348. if (typeof value == 'string' || isSymbol(value)) {
  46349. return value;
  46350. }
  46351. var result = value + '';
  46352. return result == '0' && 1 / value == -INFINITY ? '-0' : result;
  46353. }
  46354. /**
  46355. * Converts `func` to its source code.
  46356. *
  46357. * @private
  46358. * @param {Function} func The function to process.
  46359. * @returns {string} Returns the source code.
  46360. */
  46361. function toSource(func) {
  46362. if (func != null) {
  46363. try {
  46364. return funcToString.call(func);
  46365. } catch (e) { }
  46366. try {
  46367. return func + '';
  46368. } catch (e) { }
  46369. }
  46370. return '';
  46371. }
  46372. /**
  46373. * Creates an object composed of keys generated from the results of running
  46374. * each element of `collection` thru `iteratee`. The order of grouped values
  46375. * is determined by the order they occur in `collection`. The corresponding
  46376. * value of each key is an array of elements responsible for generating the
  46377. * key. The iteratee is invoked with one argument: (value).
  46378. *
  46379. * @static
  46380. * @memberOf _
  46381. * @since 0.1.0
  46382. * @category Collection
  46383. * @param {Array|Object} collection The collection to iterate over.
  46384. * @param {Function} [iteratee=_.identity]
  46385. * The iteratee to transform keys.
  46386. * @returns {Object} Returns the composed aggregate object.
  46387. * @example
  46388. *
  46389. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  46390. * // => { '4': [4.2], '6': [6.1, 6.3] }
  46391. *
  46392. * // The `_.property` iteratee shorthand.
  46393. * _.groupBy(['one', 'two', 'three'], 'length');
  46394. * // => { '3': ['one', 'two'], '5': ['three'] }
  46395. */
  46396. var groupBy = createAggregator(function (result, value, key) {
  46397. if (hasOwnProperty.call(result, key)) {
  46398. result[key].push(value);
  46399. } else {
  46400. result[key] = [value];
  46401. }
  46402. });
  46403. /**
  46404. * Creates a function that memoizes the result of `func`. If `resolver` is
  46405. * provided, it determines the cache key for storing the result based on the
  46406. * arguments provided to the memoized function. By default, the first argument
  46407. * provided to the memoized function is used as the map cache key. The `func`
  46408. * is invoked with the `this` binding of the memoized function.
  46409. *
  46410. * **Note:** The cache is exposed as the `cache` property on the memoized
  46411. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  46412. * constructor with one whose instances implement the
  46413. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  46414. * method interface of `delete`, `get`, `has`, and `set`.
  46415. *
  46416. * @static
  46417. * @memberOf _
  46418. * @since 0.1.0
  46419. * @category Function
  46420. * @param {Function} func The function to have its output memoized.
  46421. * @param {Function} [resolver] The function to resolve the cache key.
  46422. * @returns {Function} Returns the new memoized function.
  46423. * @example
  46424. *
  46425. * var object = { 'a': 1, 'b': 2 };
  46426. * var other = { 'c': 3, 'd': 4 };
  46427. *
  46428. * var values = _.memoize(_.values);
  46429. * values(object);
  46430. * // => [1, 2]
  46431. *
  46432. * values(other);
  46433. * // => [3, 4]
  46434. *
  46435. * object.a = 2;
  46436. * values(object);
  46437. * // => [1, 2]
  46438. *
  46439. * // Modify the result cache.
  46440. * values.cache.set(object, ['a', 'b']);
  46441. * values(object);
  46442. * // => ['a', 'b']
  46443. *
  46444. * // Replace `_.memoize.Cache`.
  46445. * _.memoize.Cache = WeakMap;
  46446. */
  46447. function memoize(func, resolver) {
  46448. if (typeof func != 'function' || resolver && typeof resolver != 'function') {
  46449. throw new TypeError(FUNC_ERROR_TEXT);
  46450. }
  46451. var memoized = function memoized() {
  46452. var args = arguments,
  46453. key = resolver ? resolver.apply(this, args) : args[0],
  46454. cache = memoized.cache;
  46455. if (cache.has(key)) {
  46456. return cache.get(key);
  46457. }
  46458. var result = func.apply(this, args);
  46459. memoized.cache = cache.set(key, result);
  46460. return result;
  46461. };
  46462. memoized.cache = new (memoize.Cache || MapCache)();
  46463. return memoized;
  46464. } // Assign cache to `_.memoize`.
  46465. memoize.Cache = MapCache;
  46466. /**
  46467. * Performs a
  46468. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  46469. * comparison between two values to determine if they are equivalent.
  46470. *
  46471. * @static
  46472. * @memberOf _
  46473. * @since 4.0.0
  46474. * @category Lang
  46475. * @param {*} value The value to compare.
  46476. * @param {*} other The other value to compare.
  46477. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  46478. * @example
  46479. *
  46480. * var object = { 'a': 1 };
  46481. * var other = { 'a': 1 };
  46482. *
  46483. * _.eq(object, object);
  46484. * // => true
  46485. *
  46486. * _.eq(object, other);
  46487. * // => false
  46488. *
  46489. * _.eq('a', 'a');
  46490. * // => true
  46491. *
  46492. * _.eq('a', Object('a'));
  46493. * // => false
  46494. *
  46495. * _.eq(NaN, NaN);
  46496. * // => true
  46497. */
  46498. function eq(value, other) {
  46499. return value === other || value !== value && other !== other;
  46500. }
  46501. /**
  46502. * Checks if `value` is likely an `arguments` object.
  46503. *
  46504. * @static
  46505. * @memberOf _
  46506. * @since 0.1.0
  46507. * @category Lang
  46508. * @param {*} value The value to check.
  46509. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  46510. * else `false`.
  46511. * @example
  46512. *
  46513. * _.isArguments(function() { return arguments; }());
  46514. * // => true
  46515. *
  46516. * _.isArguments([1, 2, 3]);
  46517. * // => false
  46518. */
  46519. function isArguments(value) {
  46520. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  46521. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  46522. }
  46523. /**
  46524. * Checks if `value` is classified as an `Array` object.
  46525. *
  46526. * @static
  46527. * @memberOf _
  46528. * @since 0.1.0
  46529. * @category Lang
  46530. * @param {*} value The value to check.
  46531. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  46532. * @example
  46533. *
  46534. * _.isArray([1, 2, 3]);
  46535. * // => true
  46536. *
  46537. * _.isArray(document.body.children);
  46538. * // => false
  46539. *
  46540. * _.isArray('abc');
  46541. * // => false
  46542. *
  46543. * _.isArray(_.noop);
  46544. * // => false
  46545. */
  46546. var isArray = Array.isArray;
  46547. /**
  46548. * Checks if `value` is array-like. A value is considered array-like if it's
  46549. * not a function and has a `value.length` that's an integer greater than or
  46550. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  46551. *
  46552. * @static
  46553. * @memberOf _
  46554. * @since 4.0.0
  46555. * @category Lang
  46556. * @param {*} value The value to check.
  46557. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  46558. * @example
  46559. *
  46560. * _.isArrayLike([1, 2, 3]);
  46561. * // => true
  46562. *
  46563. * _.isArrayLike(document.body.children);
  46564. * // => true
  46565. *
  46566. * _.isArrayLike('abc');
  46567. * // => true
  46568. *
  46569. * _.isArrayLike(_.noop);
  46570. * // => false
  46571. */
  46572. function isArrayLike(value) {
  46573. return value != null && isLength(value.length) && !isFunction(value);
  46574. }
  46575. /**
  46576. * This method is like `_.isArrayLike` except that it also checks if `value`
  46577. * is an object.
  46578. *
  46579. * @static
  46580. * @memberOf _
  46581. * @since 4.0.0
  46582. * @category Lang
  46583. * @param {*} value The value to check.
  46584. * @returns {boolean} Returns `true` if `value` is an array-like object,
  46585. * else `false`.
  46586. * @example
  46587. *
  46588. * _.isArrayLikeObject([1, 2, 3]);
  46589. * // => true
  46590. *
  46591. * _.isArrayLikeObject(document.body.children);
  46592. * // => true
  46593. *
  46594. * _.isArrayLikeObject('abc');
  46595. * // => false
  46596. *
  46597. * _.isArrayLikeObject(_.noop);
  46598. * // => false
  46599. */
  46600. function isArrayLikeObject(value) {
  46601. return isObjectLike(value) && isArrayLike(value);
  46602. }
  46603. /**
  46604. * Checks if `value` is classified as a `Function` object.
  46605. *
  46606. * @static
  46607. * @memberOf _
  46608. * @since 0.1.0
  46609. * @category Lang
  46610. * @param {*} value The value to check.
  46611. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  46612. * @example
  46613. *
  46614. * _.isFunction(_);
  46615. * // => true
  46616. *
  46617. * _.isFunction(/abc/);
  46618. * // => false
  46619. */
  46620. function isFunction(value) {
  46621. // The use of `Object#toString` avoids issues with the `typeof` operator
  46622. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  46623. var tag = isObject(value) ? objectToString.call(value) : '';
  46624. return tag == funcTag || tag == genTag;
  46625. }
  46626. /**
  46627. * Checks if `value` is a valid array-like length.
  46628. *
  46629. * **Note:** This method is loosely based on
  46630. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  46631. *
  46632. * @static
  46633. * @memberOf _
  46634. * @since 4.0.0
  46635. * @category Lang
  46636. * @param {*} value The value to check.
  46637. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  46638. * @example
  46639. *
  46640. * _.isLength(3);
  46641. * // => true
  46642. *
  46643. * _.isLength(Number.MIN_VALUE);
  46644. * // => false
  46645. *
  46646. * _.isLength(Infinity);
  46647. * // => false
  46648. *
  46649. * _.isLength('3');
  46650. * // => false
  46651. */
  46652. function isLength(value) {
  46653. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  46654. }
  46655. /**
  46656. * Checks if `value` is the
  46657. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  46658. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  46659. *
  46660. * @static
  46661. * @memberOf _
  46662. * @since 0.1.0
  46663. * @category Lang
  46664. * @param {*} value The value to check.
  46665. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  46666. * @example
  46667. *
  46668. * _.isObject({});
  46669. * // => true
  46670. *
  46671. * _.isObject([1, 2, 3]);
  46672. * // => true
  46673. *
  46674. * _.isObject(_.noop);
  46675. * // => true
  46676. *
  46677. * _.isObject(null);
  46678. * // => false
  46679. */
  46680. function isObject(value) {
  46681. var type = _typeof(value);
  46682. return !!value && (type == 'object' || type == 'function');
  46683. }
  46684. /**
  46685. * Checks if `value` is object-like. A value is object-like if it's not `null`
  46686. * and has a `typeof` result of "object".
  46687. *
  46688. * @static
  46689. * @memberOf _
  46690. * @since 4.0.0
  46691. * @category Lang
  46692. * @param {*} value The value to check.
  46693. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  46694. * @example
  46695. *
  46696. * _.isObjectLike({});
  46697. * // => true
  46698. *
  46699. * _.isObjectLike([1, 2, 3]);
  46700. * // => true
  46701. *
  46702. * _.isObjectLike(_.noop);
  46703. * // => false
  46704. *
  46705. * _.isObjectLike(null);
  46706. * // => false
  46707. */
  46708. function isObjectLike(value) {
  46709. return !!value && _typeof(value) == 'object';
  46710. }
  46711. /**
  46712. * Checks if `value` is classified as a `Symbol` primitive or object.
  46713. *
  46714. * @static
  46715. * @memberOf _
  46716. * @since 4.0.0
  46717. * @category Lang
  46718. * @param {*} value The value to check.
  46719. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  46720. * @example
  46721. *
  46722. * _.isSymbol(Symbol.iterator);
  46723. * // => true
  46724. *
  46725. * _.isSymbol('abc');
  46726. * // => false
  46727. */
  46728. function isSymbol(value) {
  46729. return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
  46730. }
  46731. /**
  46732. * Checks if `value` is classified as a typed array.
  46733. *
  46734. * @static
  46735. * @memberOf _
  46736. * @since 3.0.0
  46737. * @category Lang
  46738. * @param {*} value The value to check.
  46739. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  46740. * @example
  46741. *
  46742. * _.isTypedArray(new Uint8Array);
  46743. * // => true
  46744. *
  46745. * _.isTypedArray([]);
  46746. * // => false
  46747. */
  46748. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  46749. /**
  46750. * Converts `value` to a string. An empty string is returned for `null`
  46751. * and `undefined` values. The sign of `-0` is preserved.
  46752. *
  46753. * @static
  46754. * @memberOf _
  46755. * @since 4.0.0
  46756. * @category Lang
  46757. * @param {*} value The value to process.
  46758. * @returns {string} Returns the string.
  46759. * @example
  46760. *
  46761. * _.toString(null);
  46762. * // => ''
  46763. *
  46764. * _.toString(-0);
  46765. * // => '-0'
  46766. *
  46767. * _.toString([1, 2, 3]);
  46768. * // => '1,2,3'
  46769. */
  46770. function toString(value) {
  46771. return value == null ? '' : baseToString(value);
  46772. }
  46773. /**
  46774. * Gets the value at `path` of `object`. If the resolved value is
  46775. * `undefined`, the `defaultValue` is returned in its place.
  46776. *
  46777. * @static
  46778. * @memberOf _
  46779. * @since 3.7.0
  46780. * @category Object
  46781. * @param {Object} object The object to query.
  46782. * @param {Array|string} path The path of the property to get.
  46783. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  46784. * @returns {*} Returns the resolved value.
  46785. * @example
  46786. *
  46787. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  46788. *
  46789. * _.get(object, 'a[0].b.c');
  46790. * // => 3
  46791. *
  46792. * _.get(object, ['a', '0', 'b', 'c']);
  46793. * // => 3
  46794. *
  46795. * _.get(object, 'a.b.c', 'default');
  46796. * // => 'default'
  46797. */
  46798. function get(object, path, defaultValue) {
  46799. var result = object == null ? undefined : baseGet(object, path);
  46800. return result === undefined ? defaultValue : result;
  46801. }
  46802. /**
  46803. * Checks if `path` is a direct or inherited property of `object`.
  46804. *
  46805. * @static
  46806. * @memberOf _
  46807. * @since 4.0.0
  46808. * @category Object
  46809. * @param {Object} object The object to query.
  46810. * @param {Array|string} path The path to check.
  46811. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  46812. * @example
  46813. *
  46814. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  46815. *
  46816. * _.hasIn(object, 'a');
  46817. * // => true
  46818. *
  46819. * _.hasIn(object, 'a.b');
  46820. * // => true
  46821. *
  46822. * _.hasIn(object, ['a', 'b']);
  46823. * // => true
  46824. *
  46825. * _.hasIn(object, 'b');
  46826. * // => false
  46827. */
  46828. function hasIn(object, path) {
  46829. return object != null && hasPath(object, path, baseHasIn);
  46830. }
  46831. /**
  46832. * Creates an array of the own enumerable property names of `object`.
  46833. *
  46834. * **Note:** Non-object values are coerced to objects. See the
  46835. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  46836. * for more details.
  46837. *
  46838. * @static
  46839. * @since 0.1.0
  46840. * @memberOf _
  46841. * @category Object
  46842. * @param {Object} object The object to query.
  46843. * @returns {Array} Returns the array of property names.
  46844. * @example
  46845. *
  46846. * function Foo() {
  46847. * this.a = 1;
  46848. * this.b = 2;
  46849. * }
  46850. *
  46851. * Foo.prototype.c = 3;
  46852. *
  46853. * _.keys(new Foo);
  46854. * // => ['a', 'b'] (iteration order is not guaranteed)
  46855. *
  46856. * _.keys('hi');
  46857. * // => ['0', '1']
  46858. */
  46859. function keys(object) {
  46860. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  46861. }
  46862. /**
  46863. * This method returns the first argument it receives.
  46864. *
  46865. * @static
  46866. * @since 0.1.0
  46867. * @memberOf _
  46868. * @category Util
  46869. * @param {*} value Any value.
  46870. * @returns {*} Returns `value`.
  46871. * @example
  46872. *
  46873. * var object = { 'a': 1 };
  46874. *
  46875. * console.log(_.identity(object) === object);
  46876. * // => true
  46877. */
  46878. function identity(value) {
  46879. return value;
  46880. }
  46881. /**
  46882. * Creates a function that returns the value at `path` of a given object.
  46883. *
  46884. * @static
  46885. * @memberOf _
  46886. * @since 2.4.0
  46887. * @category Util
  46888. * @param {Array|string} path The path of the property to get.
  46889. * @returns {Function} Returns the new accessor function.
  46890. * @example
  46891. *
  46892. * var objects = [
  46893. * { 'a': { 'b': 2 } },
  46894. * { 'a': { 'b': 1 } }
  46895. * ];
  46896. *
  46897. * _.map(objects, _.property('a.b'));
  46898. * // => [2, 1]
  46899. *
  46900. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  46901. * // => [1, 2]
  46902. */
  46903. function property(path) {
  46904. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  46905. }
  46906. module.exports = groupBy;
  46907. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  46908. }, {}], 428: [function (require, module, exports) {
  46909. "use strict";
  46910. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  46911. /**
  46912. * lodash 3.0.3 (Custom Build) <https://lodash.com/>
  46913. * Build: `lodash modularize exports="npm" -o ./`
  46914. * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
  46915. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  46916. * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  46917. * Available under MIT license <https://lodash.com/license>
  46918. */
  46919. /** `Object#toString` result references. */
  46920. var boolTag = '[object Boolean]';
  46921. /** Used for built-in method references. */
  46922. var objectProto = Object.prototype;
  46923. /**
  46924. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  46925. * of values.
  46926. */
  46927. var objectToString = objectProto.toString;
  46928. /**
  46929. * Checks if `value` is classified as a boolean primitive or object.
  46930. *
  46931. * @static
  46932. * @memberOf _
  46933. * @category Lang
  46934. * @param {*} value The value to check.
  46935. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  46936. * @example
  46937. *
  46938. * _.isBoolean(false);
  46939. * // => true
  46940. *
  46941. * _.isBoolean(null);
  46942. * // => false
  46943. */
  46944. function isBoolean(value) {
  46945. return value === true || value === false || isObjectLike(value) && objectToString.call(value) == boolTag;
  46946. }
  46947. /**
  46948. * Checks if `value` is object-like. A value is object-like if it's not `null`
  46949. * and has a `typeof` result of "object".
  46950. *
  46951. * @static
  46952. * @memberOf _
  46953. * @category Lang
  46954. * @param {*} value The value to check.
  46955. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  46956. * @example
  46957. *
  46958. * _.isObjectLike({});
  46959. * // => true
  46960. *
  46961. * _.isObjectLike([1, 2, 3]);
  46962. * // => true
  46963. *
  46964. * _.isObjectLike(_.noop);
  46965. * // => false
  46966. *
  46967. * _.isObjectLike(null);
  46968. * // => false
  46969. */
  46970. function isObjectLike(value) {
  46971. return !!value && _typeof(value) == 'object';
  46972. }
  46973. module.exports = isBoolean;
  46974. }, {}], 429: [function (require, module, exports) {
  46975. (function (global) {
  46976. "use strict";
  46977. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  46978. /**
  46979. * Lodash (Custom Build) <https://lodash.com/>
  46980. * Build: `lodash modularize exports="npm" -o ./`
  46981. * Copyright JS Foundation and other contributors <https://js.foundation/>
  46982. * Released under MIT license <https://lodash.com/license>
  46983. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  46984. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  46985. */
  46986. /** Used as the size to enable large array optimizations. */
  46987. var LARGE_ARRAY_SIZE = 200;
  46988. /** Used to stand-in for `undefined` hash values. */
  46989. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  46990. /** Used to compose bitmasks for value comparisons. */
  46991. var COMPARE_PARTIAL_FLAG = 1,
  46992. COMPARE_UNORDERED_FLAG = 2;
  46993. /** Used as references for various `Number` constants. */
  46994. var MAX_SAFE_INTEGER = 9007199254740991;
  46995. /** `Object#toString` result references. */
  46996. var argsTag = '[object Arguments]',
  46997. arrayTag = '[object Array]',
  46998. asyncTag = '[object AsyncFunction]',
  46999. boolTag = '[object Boolean]',
  47000. dateTag = '[object Date]',
  47001. errorTag = '[object Error]',
  47002. funcTag = '[object Function]',
  47003. genTag = '[object GeneratorFunction]',
  47004. mapTag = '[object Map]',
  47005. numberTag = '[object Number]',
  47006. nullTag = '[object Null]',
  47007. objectTag = '[object Object]',
  47008. promiseTag = '[object Promise]',
  47009. proxyTag = '[object Proxy]',
  47010. regexpTag = '[object RegExp]',
  47011. setTag = '[object Set]',
  47012. stringTag = '[object String]',
  47013. symbolTag = '[object Symbol]',
  47014. undefinedTag = '[object Undefined]',
  47015. weakMapTag = '[object WeakMap]';
  47016. var arrayBufferTag = '[object ArrayBuffer]',
  47017. dataViewTag = '[object DataView]',
  47018. float32Tag = '[object Float32Array]',
  47019. float64Tag = '[object Float64Array]',
  47020. int8Tag = '[object Int8Array]',
  47021. int16Tag = '[object Int16Array]',
  47022. int32Tag = '[object Int32Array]',
  47023. uint8Tag = '[object Uint8Array]',
  47024. uint8ClampedTag = '[object Uint8ClampedArray]',
  47025. uint16Tag = '[object Uint16Array]',
  47026. uint32Tag = '[object Uint32Array]';
  47027. /**
  47028. * Used to match `RegExp`
  47029. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  47030. */
  47031. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  47032. /** Used to detect host constructors (Safari). */
  47033. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  47034. /** Used to detect unsigned integer values. */
  47035. var reIsUint = /^(?:0|[1-9]\d*)$/;
  47036. /** Used to identify `toStringTag` values of typed arrays. */
  47037. var typedArrayTags = {};
  47038. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  47039. typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  47040. /** Detect free variable `global` from Node.js. */
  47041. var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
  47042. /** Detect free variable `self`. */
  47043. var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
  47044. /** Used as a reference to the global object. */
  47045. var root = freeGlobal || freeSelf || Function('return this')();
  47046. /** Detect free variable `exports`. */
  47047. var freeExports = (typeof exports === "undefined" ? "undefined" : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;
  47048. /** Detect free variable `module`. */
  47049. var freeModule = freeExports && (typeof module === "undefined" ? "undefined" : _typeof(module)) == 'object' && module && !module.nodeType && module;
  47050. /** Detect the popular CommonJS extension `module.exports`. */
  47051. var moduleExports = freeModule && freeModule.exports === freeExports;
  47052. /** Detect free variable `process` from Node.js. */
  47053. var freeProcess = moduleExports && freeGlobal.process;
  47054. /** Used to access faster Node.js helpers. */
  47055. var nodeUtil = function () {
  47056. try {
  47057. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  47058. } catch (e) { }
  47059. }();
  47060. /* Node.js helper references. */
  47061. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  47062. /**
  47063. * A specialized version of `_.filter` for arrays without support for
  47064. * iteratee shorthands.
  47065. *
  47066. * @private
  47067. * @param {Array} [array] The array to iterate over.
  47068. * @param {Function} predicate The function invoked per iteration.
  47069. * @returns {Array} Returns the new filtered array.
  47070. */
  47071. function arrayFilter(array, predicate) {
  47072. var index = -1,
  47073. length = array == null ? 0 : array.length,
  47074. resIndex = 0,
  47075. result = [];
  47076. while (++index < length) {
  47077. var value = array[index];
  47078. if (predicate(value, index, array)) {
  47079. result[resIndex++] = value;
  47080. }
  47081. }
  47082. return result;
  47083. }
  47084. /**
  47085. * Appends the elements of `values` to `array`.
  47086. *
  47087. * @private
  47088. * @param {Array} array The array to modify.
  47089. * @param {Array} values The values to append.
  47090. * @returns {Array} Returns `array`.
  47091. */
  47092. function arrayPush(array, values) {
  47093. var index = -1,
  47094. length = values.length,
  47095. offset = array.length;
  47096. while (++index < length) {
  47097. array[offset + index] = values[index];
  47098. }
  47099. return array;
  47100. }
  47101. /**
  47102. * A specialized version of `_.some` for arrays without support for iteratee
  47103. * shorthands.
  47104. *
  47105. * @private
  47106. * @param {Array} [array] The array to iterate over.
  47107. * @param {Function} predicate The function invoked per iteration.
  47108. * @returns {boolean} Returns `true` if any element passes the predicate check,
  47109. * else `false`.
  47110. */
  47111. function arraySome(array, predicate) {
  47112. var index = -1,
  47113. length = array == null ? 0 : array.length;
  47114. while (++index < length) {
  47115. if (predicate(array[index], index, array)) {
  47116. return true;
  47117. }
  47118. }
  47119. return false;
  47120. }
  47121. /**
  47122. * The base implementation of `_.times` without support for iteratee shorthands
  47123. * or max array length checks.
  47124. *
  47125. * @private
  47126. * @param {number} n The number of times to invoke `iteratee`.
  47127. * @param {Function} iteratee The function invoked per iteration.
  47128. * @returns {Array} Returns the array of results.
  47129. */
  47130. function baseTimes(n, iteratee) {
  47131. var index = -1,
  47132. result = Array(n);
  47133. while (++index < n) {
  47134. result[index] = iteratee(index);
  47135. }
  47136. return result;
  47137. }
  47138. /**
  47139. * The base implementation of `_.unary` without support for storing metadata.
  47140. *
  47141. * @private
  47142. * @param {Function} func The function to cap arguments for.
  47143. * @returns {Function} Returns the new capped function.
  47144. */
  47145. function baseUnary(func) {
  47146. return function (value) {
  47147. return func(value);
  47148. };
  47149. }
  47150. /**
  47151. * Checks if a `cache` value for `key` exists.
  47152. *
  47153. * @private
  47154. * @param {Object} cache The cache to query.
  47155. * @param {string} key The key of the entry to check.
  47156. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  47157. */
  47158. function cacheHas(cache, key) {
  47159. return cache.has(key);
  47160. }
  47161. /**
  47162. * Gets the value at `key` of `object`.
  47163. *
  47164. * @private
  47165. * @param {Object} [object] The object to query.
  47166. * @param {string} key The key of the property to get.
  47167. * @returns {*} Returns the property value.
  47168. */
  47169. function getValue(object, key) {
  47170. return object == null ? undefined : object[key];
  47171. }
  47172. /**
  47173. * Converts `map` to its key-value pairs.
  47174. *
  47175. * @private
  47176. * @param {Object} map The map to convert.
  47177. * @returns {Array} Returns the key-value pairs.
  47178. */
  47179. function mapToArray(map) {
  47180. var index = -1,
  47181. result = Array(map.size);
  47182. map.forEach(function (value, key) {
  47183. result[++index] = [key, value];
  47184. });
  47185. return result;
  47186. }
  47187. /**
  47188. * Creates a unary function that invokes `func` with its argument transformed.
  47189. *
  47190. * @private
  47191. * @param {Function} func The function to wrap.
  47192. * @param {Function} transform The argument transform.
  47193. * @returns {Function} Returns the new function.
  47194. */
  47195. function overArg(func, transform) {
  47196. return function (arg) {
  47197. return func(transform(arg));
  47198. };
  47199. }
  47200. /**
  47201. * Converts `set` to an array of its values.
  47202. *
  47203. * @private
  47204. * @param {Object} set The set to convert.
  47205. * @returns {Array} Returns the values.
  47206. */
  47207. function setToArray(set) {
  47208. var index = -1,
  47209. result = Array(set.size);
  47210. set.forEach(function (value) {
  47211. result[++index] = value;
  47212. });
  47213. return result;
  47214. }
  47215. /** Used for built-in method references. */
  47216. var arrayProto = Array.prototype,
  47217. funcProto = Function.prototype,
  47218. objectProto = Object.prototype;
  47219. /** Used to detect overreaching core-js shims. */
  47220. var coreJsData = root['__core-js_shared__'];
  47221. /** Used to resolve the decompiled source of functions. */
  47222. var funcToString = funcProto.toString;
  47223. /** Used to check objects for own properties. */
  47224. var hasOwnProperty = objectProto.hasOwnProperty;
  47225. /** Used to detect methods masquerading as native. */
  47226. var maskSrcKey = function () {
  47227. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  47228. return uid ? 'Symbol(src)_1.' + uid : '';
  47229. }();
  47230. /**
  47231. * Used to resolve the
  47232. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  47233. * of values.
  47234. */
  47235. var nativeObjectToString = objectProto.toString;
  47236. /** Used to detect if a method is native. */
  47237. var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  47238. /** Built-in value references. */
  47239. var Buffer = moduleExports ? root.Buffer : undefined,
  47240. _Symbol = root.Symbol,
  47241. Uint8Array = root.Uint8Array,
  47242. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  47243. splice = arrayProto.splice,
  47244. symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  47245. /* Built-in method references for those with the same name as other `lodash` methods. */
  47246. var nativeGetSymbols = Object.getOwnPropertySymbols,
  47247. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  47248. nativeKeys = overArg(Object.keys, Object);
  47249. /* Built-in method references that are verified to be native. */
  47250. var DataView = getNative(root, 'DataView'),
  47251. Map = getNative(root, 'Map'),
  47252. Promise = getNative(root, 'Promise'),
  47253. Set = getNative(root, 'Set'),
  47254. WeakMap = getNative(root, 'WeakMap'),
  47255. nativeCreate = getNative(Object, 'create');
  47256. /** Used to detect maps, sets, and weakmaps. */
  47257. var dataViewCtorString = toSource(DataView),
  47258. mapCtorString = toSource(Map),
  47259. promiseCtorString = toSource(Promise),
  47260. setCtorString = toSource(Set),
  47261. weakMapCtorString = toSource(WeakMap);
  47262. /** Used to convert symbols to primitives and strings. */
  47263. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  47264. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  47265. /**
  47266. * Creates a hash object.
  47267. *
  47268. * @private
  47269. * @constructor
  47270. * @param {Array} [entries] The key-value pairs to cache.
  47271. */
  47272. function Hash(entries) {
  47273. var index = -1,
  47274. length = entries == null ? 0 : entries.length;
  47275. this.clear();
  47276. while (++index < length) {
  47277. var entry = entries[index];
  47278. this.set(entry[0], entry[1]);
  47279. }
  47280. }
  47281. /**
  47282. * Removes all key-value entries from the hash.
  47283. *
  47284. * @private
  47285. * @name clear
  47286. * @memberOf Hash
  47287. */
  47288. function hashClear() {
  47289. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  47290. this.size = 0;
  47291. }
  47292. /**
  47293. * Removes `key` and its value from the hash.
  47294. *
  47295. * @private
  47296. * @name delete
  47297. * @memberOf Hash
  47298. * @param {Object} hash The hash to modify.
  47299. * @param {string} key The key of the value to remove.
  47300. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  47301. */
  47302. function hashDelete(key) {
  47303. var result = this.has(key) && delete this.__data__[key];
  47304. this.size -= result ? 1 : 0;
  47305. return result;
  47306. }
  47307. /**
  47308. * Gets the hash value for `key`.
  47309. *
  47310. * @private
  47311. * @name get
  47312. * @memberOf Hash
  47313. * @param {string} key The key of the value to get.
  47314. * @returns {*} Returns the entry value.
  47315. */
  47316. function hashGet(key) {
  47317. var data = this.__data__;
  47318. if (nativeCreate) {
  47319. var result = data[key];
  47320. return result === HASH_UNDEFINED ? undefined : result;
  47321. }
  47322. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  47323. }
  47324. /**
  47325. * Checks if a hash value for `key` exists.
  47326. *
  47327. * @private
  47328. * @name has
  47329. * @memberOf Hash
  47330. * @param {string} key The key of the entry to check.
  47331. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  47332. */
  47333. function hashHas(key) {
  47334. var data = this.__data__;
  47335. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  47336. }
  47337. /**
  47338. * Sets the hash `key` to `value`.
  47339. *
  47340. * @private
  47341. * @name set
  47342. * @memberOf Hash
  47343. * @param {string} key The key of the value to set.
  47344. * @param {*} value The value to set.
  47345. * @returns {Object} Returns the hash instance.
  47346. */
  47347. function hashSet(key, value) {
  47348. var data = this.__data__;
  47349. this.size += this.has(key) ? 0 : 1;
  47350. data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
  47351. return this;
  47352. } // Add methods to `Hash`.
  47353. Hash.prototype.clear = hashClear;
  47354. Hash.prototype['delete'] = hashDelete;
  47355. Hash.prototype.get = hashGet;
  47356. Hash.prototype.has = hashHas;
  47357. Hash.prototype.set = hashSet;
  47358. /**
  47359. * Creates an list cache object.
  47360. *
  47361. * @private
  47362. * @constructor
  47363. * @param {Array} [entries] The key-value pairs to cache.
  47364. */
  47365. function ListCache(entries) {
  47366. var index = -1,
  47367. length = entries == null ? 0 : entries.length;
  47368. this.clear();
  47369. while (++index < length) {
  47370. var entry = entries[index];
  47371. this.set(entry[0], entry[1]);
  47372. }
  47373. }
  47374. /**
  47375. * Removes all key-value entries from the list cache.
  47376. *
  47377. * @private
  47378. * @name clear
  47379. * @memberOf ListCache
  47380. */
  47381. function listCacheClear() {
  47382. this.__data__ = [];
  47383. this.size = 0;
  47384. }
  47385. /**
  47386. * Removes `key` and its value from the list cache.
  47387. *
  47388. * @private
  47389. * @name delete
  47390. * @memberOf ListCache
  47391. * @param {string} key The key of the value to remove.
  47392. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  47393. */
  47394. function listCacheDelete(key) {
  47395. var data = this.__data__,
  47396. index = assocIndexOf(data, key);
  47397. if (index < 0) {
  47398. return false;
  47399. }
  47400. var lastIndex = data.length - 1;
  47401. if (index == lastIndex) {
  47402. data.pop();
  47403. } else {
  47404. splice.call(data, index, 1);
  47405. }
  47406. --this.size;
  47407. return true;
  47408. }
  47409. /**
  47410. * Gets the list cache value for `key`.
  47411. *
  47412. * @private
  47413. * @name get
  47414. * @memberOf ListCache
  47415. * @param {string} key The key of the value to get.
  47416. * @returns {*} Returns the entry value.
  47417. */
  47418. function listCacheGet(key) {
  47419. var data = this.__data__,
  47420. index = assocIndexOf(data, key);
  47421. return index < 0 ? undefined : data[index][1];
  47422. }
  47423. /**
  47424. * Checks if a list cache value for `key` exists.
  47425. *
  47426. * @private
  47427. * @name has
  47428. * @memberOf ListCache
  47429. * @param {string} key The key of the entry to check.
  47430. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  47431. */
  47432. function listCacheHas(key) {
  47433. return assocIndexOf(this.__data__, key) > -1;
  47434. }
  47435. /**
  47436. * Sets the list cache `key` to `value`.
  47437. *
  47438. * @private
  47439. * @name set
  47440. * @memberOf ListCache
  47441. * @param {string} key The key of the value to set.
  47442. * @param {*} value The value to set.
  47443. * @returns {Object} Returns the list cache instance.
  47444. */
  47445. function listCacheSet(key, value) {
  47446. var data = this.__data__,
  47447. index = assocIndexOf(data, key);
  47448. if (index < 0) {
  47449. ++this.size;
  47450. data.push([key, value]);
  47451. } else {
  47452. data[index][1] = value;
  47453. }
  47454. return this;
  47455. } // Add methods to `ListCache`.
  47456. ListCache.prototype.clear = listCacheClear;
  47457. ListCache.prototype['delete'] = listCacheDelete;
  47458. ListCache.prototype.get = listCacheGet;
  47459. ListCache.prototype.has = listCacheHas;
  47460. ListCache.prototype.set = listCacheSet;
  47461. /**
  47462. * Creates a map cache object to store key-value pairs.
  47463. *
  47464. * @private
  47465. * @constructor
  47466. * @param {Array} [entries] The key-value pairs to cache.
  47467. */
  47468. function MapCache(entries) {
  47469. var index = -1,
  47470. length = entries == null ? 0 : entries.length;
  47471. this.clear();
  47472. while (++index < length) {
  47473. var entry = entries[index];
  47474. this.set(entry[0], entry[1]);
  47475. }
  47476. }
  47477. /**
  47478. * Removes all key-value entries from the map.
  47479. *
  47480. * @private
  47481. * @name clear
  47482. * @memberOf MapCache
  47483. */
  47484. function mapCacheClear() {
  47485. this.size = 0;
  47486. this.__data__ = {
  47487. 'hash': new Hash(),
  47488. 'map': new (Map || ListCache)(),
  47489. 'string': new Hash()
  47490. };
  47491. }
  47492. /**
  47493. * Removes `key` and its value from the map.
  47494. *
  47495. * @private
  47496. * @name delete
  47497. * @memberOf MapCache
  47498. * @param {string} key The key of the value to remove.
  47499. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  47500. */
  47501. function mapCacheDelete(key) {
  47502. var result = getMapData(this, key)['delete'](key);
  47503. this.size -= result ? 1 : 0;
  47504. return result;
  47505. }
  47506. /**
  47507. * Gets the map value for `key`.
  47508. *
  47509. * @private
  47510. * @name get
  47511. * @memberOf MapCache
  47512. * @param {string} key The key of the value to get.
  47513. * @returns {*} Returns the entry value.
  47514. */
  47515. function mapCacheGet(key) {
  47516. return getMapData(this, key).get(key);
  47517. }
  47518. /**
  47519. * Checks if a map value for `key` exists.
  47520. *
  47521. * @private
  47522. * @name has
  47523. * @memberOf MapCache
  47524. * @param {string} key The key of the entry to check.
  47525. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  47526. */
  47527. function mapCacheHas(key) {
  47528. return getMapData(this, key).has(key);
  47529. }
  47530. /**
  47531. * Sets the map `key` to `value`.
  47532. *
  47533. * @private
  47534. * @name set
  47535. * @memberOf MapCache
  47536. * @param {string} key The key of the value to set.
  47537. * @param {*} value The value to set.
  47538. * @returns {Object} Returns the map cache instance.
  47539. */
  47540. function mapCacheSet(key, value) {
  47541. var data = getMapData(this, key),
  47542. size = data.size;
  47543. data.set(key, value);
  47544. this.size += data.size == size ? 0 : 1;
  47545. return this;
  47546. } // Add methods to `MapCache`.
  47547. MapCache.prototype.clear = mapCacheClear;
  47548. MapCache.prototype['delete'] = mapCacheDelete;
  47549. MapCache.prototype.get = mapCacheGet;
  47550. MapCache.prototype.has = mapCacheHas;
  47551. MapCache.prototype.set = mapCacheSet;
  47552. /**
  47553. *
  47554. * Creates an array cache object to store unique values.
  47555. *
  47556. * @private
  47557. * @constructor
  47558. * @param {Array} [values] The values to cache.
  47559. */
  47560. function SetCache(values) {
  47561. var index = -1,
  47562. length = values == null ? 0 : values.length;
  47563. this.__data__ = new MapCache();
  47564. while (++index < length) {
  47565. this.add(values[index]);
  47566. }
  47567. }
  47568. /**
  47569. * Adds `value` to the array cache.
  47570. *
  47571. * @private
  47572. * @name add
  47573. * @memberOf SetCache
  47574. * @alias push
  47575. * @param {*} value The value to cache.
  47576. * @returns {Object} Returns the cache instance.
  47577. */
  47578. function setCacheAdd(value) {
  47579. this.__data__.set(value, HASH_UNDEFINED);
  47580. return this;
  47581. }
  47582. /**
  47583. * Checks if `value` is in the array cache.
  47584. *
  47585. * @private
  47586. * @name has
  47587. * @memberOf SetCache
  47588. * @param {*} value The value to search for.
  47589. * @returns {number} Returns `true` if `value` is found, else `false`.
  47590. */
  47591. function setCacheHas(value) {
  47592. return this.__data__.has(value);
  47593. } // Add methods to `SetCache`.
  47594. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  47595. SetCache.prototype.has = setCacheHas;
  47596. /**
  47597. * Creates a stack cache object to store key-value pairs.
  47598. *
  47599. * @private
  47600. * @constructor
  47601. * @param {Array} [entries] The key-value pairs to cache.
  47602. */
  47603. function Stack(entries) {
  47604. var data = this.__data__ = new ListCache(entries);
  47605. this.size = data.size;
  47606. }
  47607. /**
  47608. * Removes all key-value entries from the stack.
  47609. *
  47610. * @private
  47611. * @name clear
  47612. * @memberOf Stack
  47613. */
  47614. function stackClear() {
  47615. this.__data__ = new ListCache();
  47616. this.size = 0;
  47617. }
  47618. /**
  47619. * Removes `key` and its value from the stack.
  47620. *
  47621. * @private
  47622. * @name delete
  47623. * @memberOf Stack
  47624. * @param {string} key The key of the value to remove.
  47625. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  47626. */
  47627. function stackDelete(key) {
  47628. var data = this.__data__,
  47629. result = data['delete'](key);
  47630. this.size = data.size;
  47631. return result;
  47632. }
  47633. /**
  47634. * Gets the stack value for `key`.
  47635. *
  47636. * @private
  47637. * @name get
  47638. * @memberOf Stack
  47639. * @param {string} key The key of the value to get.
  47640. * @returns {*} Returns the entry value.
  47641. */
  47642. function stackGet(key) {
  47643. return this.__data__.get(key);
  47644. }
  47645. /**
  47646. * Checks if a stack value for `key` exists.
  47647. *
  47648. * @private
  47649. * @name has
  47650. * @memberOf Stack
  47651. * @param {string} key The key of the entry to check.
  47652. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  47653. */
  47654. function stackHas(key) {
  47655. return this.__data__.has(key);
  47656. }
  47657. /**
  47658. * Sets the stack `key` to `value`.
  47659. *
  47660. * @private
  47661. * @name set
  47662. * @memberOf Stack
  47663. * @param {string} key The key of the value to set.
  47664. * @param {*} value The value to set.
  47665. * @returns {Object} Returns the stack cache instance.
  47666. */
  47667. function stackSet(key, value) {
  47668. var data = this.__data__;
  47669. if (data instanceof ListCache) {
  47670. var pairs = data.__data__;
  47671. if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
  47672. pairs.push([key, value]);
  47673. this.size = ++data.size;
  47674. return this;
  47675. }
  47676. data = this.__data__ = new MapCache(pairs);
  47677. }
  47678. data.set(key, value);
  47679. this.size = data.size;
  47680. return this;
  47681. } // Add methods to `Stack`.
  47682. Stack.prototype.clear = stackClear;
  47683. Stack.prototype['delete'] = stackDelete;
  47684. Stack.prototype.get = stackGet;
  47685. Stack.prototype.has = stackHas;
  47686. Stack.prototype.set = stackSet;
  47687. /**
  47688. * Creates an array of the enumerable property names of the array-like `value`.
  47689. *
  47690. * @private
  47691. * @param {*} value The value to query.
  47692. * @param {boolean} inherited Specify returning inherited property names.
  47693. * @returns {Array} Returns the array of property names.
  47694. */
  47695. function arrayLikeKeys(value, inherited) {
  47696. var isArr = isArray(value),
  47697. isArg = !isArr && isArguments(value),
  47698. isBuff = !isArr && !isArg && isBuffer(value),
  47699. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  47700. skipIndexes = isArr || isArg || isBuff || isType,
  47701. result = skipIndexes ? baseTimes(value.length, String) : [],
  47702. length = result.length;
  47703. for (var key in value) {
  47704. if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode.
  47705. key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers.
  47706. isBuff && (key == 'offset' || key == 'parent') || // PhantomJS 2 has enumerable non-index properties on typed arrays.
  47707. isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties.
  47708. isIndex(key, length)))) {
  47709. result.push(key);
  47710. }
  47711. }
  47712. return result;
  47713. }
  47714. /**
  47715. * Gets the index at which the `key` is found in `array` of key-value pairs.
  47716. *
  47717. * @private
  47718. * @param {Array} array The array to inspect.
  47719. * @param {*} key The key to search for.
  47720. * @returns {number} Returns the index of the matched value, else `-1`.
  47721. */
  47722. function assocIndexOf(array, key) {
  47723. var length = array.length;
  47724. while (length--) {
  47725. if (eq(array[length][0], key)) {
  47726. return length;
  47727. }
  47728. }
  47729. return -1;
  47730. }
  47731. /**
  47732. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  47733. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  47734. * symbols of `object`.
  47735. *
  47736. * @private
  47737. * @param {Object} object The object to query.
  47738. * @param {Function} keysFunc The function to get the keys of `object`.
  47739. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  47740. * @returns {Array} Returns the array of property names and symbols.
  47741. */
  47742. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  47743. var result = keysFunc(object);
  47744. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  47745. }
  47746. /**
  47747. * The base implementation of `getTag` without fallbacks for buggy environments.
  47748. *
  47749. * @private
  47750. * @param {*} value The value to query.
  47751. * @returns {string} Returns the `toStringTag`.
  47752. */
  47753. function baseGetTag(value) {
  47754. if (value == null) {
  47755. return value === undefined ? undefinedTag : nullTag;
  47756. }
  47757. return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
  47758. }
  47759. /**
  47760. * The base implementation of `_.isArguments`.
  47761. *
  47762. * @private
  47763. * @param {*} value The value to check.
  47764. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  47765. */
  47766. function baseIsArguments(value) {
  47767. return isObjectLike(value) && baseGetTag(value) == argsTag;
  47768. }
  47769. /**
  47770. * The base implementation of `_.isEqual` which supports partial comparisons
  47771. * and tracks traversed objects.
  47772. *
  47773. * @private
  47774. * @param {*} value The value to compare.
  47775. * @param {*} other The other value to compare.
  47776. * @param {boolean} bitmask The bitmask flags.
  47777. * 1 - Unordered comparison
  47778. * 2 - Partial comparison
  47779. * @param {Function} [customizer] The function to customize comparisons.
  47780. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  47781. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  47782. */
  47783. function baseIsEqual(value, other, bitmask, customizer, stack) {
  47784. if (value === other) {
  47785. return true;
  47786. }
  47787. if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
  47788. return value !== value && other !== other;
  47789. }
  47790. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  47791. }
  47792. /**
  47793. * A specialized version of `baseIsEqual` for arrays and objects which performs
  47794. * deep comparisons and tracks traversed objects enabling objects with circular
  47795. * references to be compared.
  47796. *
  47797. * @private
  47798. * @param {Object} object The object to compare.
  47799. * @param {Object} other The other object to compare.
  47800. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  47801. * @param {Function} customizer The function to customize comparisons.
  47802. * @param {Function} equalFunc The function to determine equivalents of values.
  47803. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  47804. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  47805. */
  47806. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  47807. var objIsArr = isArray(object),
  47808. othIsArr = isArray(other),
  47809. objTag = objIsArr ? arrayTag : getTag(object),
  47810. othTag = othIsArr ? arrayTag : getTag(other);
  47811. objTag = objTag == argsTag ? objectTag : objTag;
  47812. othTag = othTag == argsTag ? objectTag : othTag;
  47813. var objIsObj = objTag == objectTag,
  47814. othIsObj = othTag == objectTag,
  47815. isSameTag = objTag == othTag;
  47816. if (isSameTag && isBuffer(object)) {
  47817. if (!isBuffer(other)) {
  47818. return false;
  47819. }
  47820. objIsArr = true;
  47821. objIsObj = false;
  47822. }
  47823. if (isSameTag && !objIsObj) {
  47824. stack || (stack = new Stack());
  47825. return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  47826. }
  47827. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  47828. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  47829. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  47830. if (objIsWrapped || othIsWrapped) {
  47831. var objUnwrapped = objIsWrapped ? object.value() : object,
  47832. othUnwrapped = othIsWrapped ? other.value() : other;
  47833. stack || (stack = new Stack());
  47834. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  47835. }
  47836. }
  47837. if (!isSameTag) {
  47838. return false;
  47839. }
  47840. stack || (stack = new Stack());
  47841. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  47842. }
  47843. /**
  47844. * The base implementation of `_.isNative` without bad shim checks.
  47845. *
  47846. * @private
  47847. * @param {*} value The value to check.
  47848. * @returns {boolean} Returns `true` if `value` is a native function,
  47849. * else `false`.
  47850. */
  47851. function baseIsNative(value) {
  47852. if (!isObject(value) || isMasked(value)) {
  47853. return false;
  47854. }
  47855. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  47856. return pattern.test(toSource(value));
  47857. }
  47858. /**
  47859. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  47860. *
  47861. * @private
  47862. * @param {*} value The value to check.
  47863. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  47864. */
  47865. function baseIsTypedArray(value) {
  47866. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  47867. }
  47868. /**
  47869. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  47870. *
  47871. * @private
  47872. * @param {Object} object The object to query.
  47873. * @returns {Array} Returns the array of property names.
  47874. */
  47875. function baseKeys(object) {
  47876. if (!isPrototype(object)) {
  47877. return nativeKeys(object);
  47878. }
  47879. var result = [];
  47880. for (var key in Object(object)) {
  47881. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  47882. result.push(key);
  47883. }
  47884. }
  47885. return result;
  47886. }
  47887. /**
  47888. * A specialized version of `baseIsEqualDeep` for arrays with support for
  47889. * partial deep comparisons.
  47890. *
  47891. * @private
  47892. * @param {Array} array The array to compare.
  47893. * @param {Array} other The other array to compare.
  47894. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  47895. * @param {Function} customizer The function to customize comparisons.
  47896. * @param {Function} equalFunc The function to determine equivalents of values.
  47897. * @param {Object} stack Tracks traversed `array` and `other` objects.
  47898. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  47899. */
  47900. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  47901. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  47902. arrLength = array.length,
  47903. othLength = other.length;
  47904. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  47905. return false;
  47906. } // Assume cyclic values are equal.
  47907. var stacked = stack.get(array);
  47908. if (stacked && stack.get(other)) {
  47909. return stacked == other;
  47910. }
  47911. var index = -1,
  47912. result = true,
  47913. seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : undefined;
  47914. stack.set(array, other);
  47915. stack.set(other, array); // Ignore non-index properties.
  47916. while (++index < arrLength) {
  47917. var arrValue = array[index],
  47918. othValue = other[index];
  47919. if (customizer) {
  47920. var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
  47921. }
  47922. if (compared !== undefined) {
  47923. if (compared) {
  47924. continue;
  47925. }
  47926. result = false;
  47927. break;
  47928. } // Recursively compare arrays (susceptible to call stack limits).
  47929. if (seen) {
  47930. if (!arraySome(other, function (othValue, othIndex) {
  47931. if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  47932. return seen.push(othIndex);
  47933. }
  47934. })) {
  47935. result = false;
  47936. break;
  47937. }
  47938. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  47939. result = false;
  47940. break;
  47941. }
  47942. }
  47943. stack['delete'](array);
  47944. stack['delete'](other);
  47945. return result;
  47946. }
  47947. /**
  47948. * A specialized version of `baseIsEqualDeep` for comparing objects of
  47949. * the same `toStringTag`.
  47950. *
  47951. * **Note:** This function only supports comparing values with tags of
  47952. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  47953. *
  47954. * @private
  47955. * @param {Object} object The object to compare.
  47956. * @param {Object} other The other object to compare.
  47957. * @param {string} tag The `toStringTag` of the objects to compare.
  47958. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  47959. * @param {Function} customizer The function to customize comparisons.
  47960. * @param {Function} equalFunc The function to determine equivalents of values.
  47961. * @param {Object} stack Tracks traversed `object` and `other` objects.
  47962. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  47963. */
  47964. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  47965. switch (tag) {
  47966. case dataViewTag:
  47967. if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
  47968. return false;
  47969. }
  47970. object = object.buffer;
  47971. other = other.buffer;
  47972. case arrayBufferTag:
  47973. if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  47974. return false;
  47975. }
  47976. return true;
  47977. case boolTag:
  47978. case dateTag:
  47979. case numberTag:
  47980. // Coerce booleans to `1` or `0` and dates to milliseconds.
  47981. // Invalid dates are coerced to `NaN`.
  47982. return eq(+object, +other);
  47983. case errorTag:
  47984. return object.name == other.name && object.message == other.message;
  47985. case regexpTag:
  47986. case stringTag:
  47987. // Coerce regexes to strings and treat strings, primitives and objects,
  47988. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  47989. // for more details.
  47990. return object == other + '';
  47991. case mapTag:
  47992. var convert = mapToArray;
  47993. case setTag:
  47994. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  47995. convert || (convert = setToArray);
  47996. if (object.size != other.size && !isPartial) {
  47997. return false;
  47998. } // Assume cyclic values are equal.
  47999. var stacked = stack.get(object);
  48000. if (stacked) {
  48001. return stacked == other;
  48002. }
  48003. bitmask |= COMPARE_UNORDERED_FLAG; // Recursively compare objects (susceptible to call stack limits).
  48004. stack.set(object, other);
  48005. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  48006. stack['delete'](object);
  48007. return result;
  48008. case symbolTag:
  48009. if (symbolValueOf) {
  48010. return symbolValueOf.call(object) == symbolValueOf.call(other);
  48011. }
  48012. }
  48013. return false;
  48014. }
  48015. /**
  48016. * A specialized version of `baseIsEqualDeep` for objects with support for
  48017. * partial deep comparisons.
  48018. *
  48019. * @private
  48020. * @param {Object} object The object to compare.
  48021. * @param {Object} other The other object to compare.
  48022. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  48023. * @param {Function} customizer The function to customize comparisons.
  48024. * @param {Function} equalFunc The function to determine equivalents of values.
  48025. * @param {Object} stack Tracks traversed `object` and `other` objects.
  48026. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  48027. */
  48028. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  48029. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  48030. objProps = getAllKeys(object),
  48031. objLength = objProps.length,
  48032. othProps = getAllKeys(other),
  48033. othLength = othProps.length;
  48034. if (objLength != othLength && !isPartial) {
  48035. return false;
  48036. }
  48037. var index = objLength;
  48038. while (index--) {
  48039. var key = objProps[index];
  48040. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  48041. return false;
  48042. }
  48043. } // Assume cyclic values are equal.
  48044. var stacked = stack.get(object);
  48045. if (stacked && stack.get(other)) {
  48046. return stacked == other;
  48047. }
  48048. var result = true;
  48049. stack.set(object, other);
  48050. stack.set(other, object);
  48051. var skipCtor = isPartial;
  48052. while (++index < objLength) {
  48053. key = objProps[index];
  48054. var objValue = object[key],
  48055. othValue = other[key];
  48056. if (customizer) {
  48057. var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
  48058. } // Recursively compare objects (susceptible to call stack limits).
  48059. if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
  48060. result = false;
  48061. break;
  48062. }
  48063. skipCtor || (skipCtor = key == 'constructor');
  48064. }
  48065. if (result && !skipCtor) {
  48066. var objCtor = object.constructor,
  48067. othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
  48068. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  48069. result = false;
  48070. }
  48071. }
  48072. stack['delete'](object);
  48073. stack['delete'](other);
  48074. return result;
  48075. }
  48076. /**
  48077. * Creates an array of own enumerable property names and symbols of `object`.
  48078. *
  48079. * @private
  48080. * @param {Object} object The object to query.
  48081. * @returns {Array} Returns the array of property names and symbols.
  48082. */
  48083. function getAllKeys(object) {
  48084. return baseGetAllKeys(object, keys, getSymbols);
  48085. }
  48086. /**
  48087. * Gets the data for `map`.
  48088. *
  48089. * @private
  48090. * @param {Object} map The map to query.
  48091. * @param {string} key The reference key.
  48092. * @returns {*} Returns the map data.
  48093. */
  48094. function getMapData(map, key) {
  48095. var data = map.__data__;
  48096. return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
  48097. }
  48098. /**
  48099. * Gets the native function at `key` of `object`.
  48100. *
  48101. * @private
  48102. * @param {Object} object The object to query.
  48103. * @param {string} key The key of the method to get.
  48104. * @returns {*} Returns the function if it's native, else `undefined`.
  48105. */
  48106. function getNative(object, key) {
  48107. var value = getValue(object, key);
  48108. return baseIsNative(value) ? value : undefined;
  48109. }
  48110. /**
  48111. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  48112. *
  48113. * @private
  48114. * @param {*} value The value to query.
  48115. * @returns {string} Returns the raw `toStringTag`.
  48116. */
  48117. function getRawTag(value) {
  48118. var isOwn = hasOwnProperty.call(value, symToStringTag),
  48119. tag = value[symToStringTag];
  48120. try {
  48121. value[symToStringTag] = undefined;
  48122. var unmasked = true;
  48123. } catch (e) { }
  48124. var result = nativeObjectToString.call(value);
  48125. if (unmasked) {
  48126. if (isOwn) {
  48127. value[symToStringTag] = tag;
  48128. } else {
  48129. delete value[symToStringTag];
  48130. }
  48131. }
  48132. return result;
  48133. }
  48134. /**
  48135. * Creates an array of the own enumerable symbols of `object`.
  48136. *
  48137. * @private
  48138. * @param {Object} object The object to query.
  48139. * @returns {Array} Returns the array of symbols.
  48140. */
  48141. var getSymbols = !nativeGetSymbols ? stubArray : function (object) {
  48142. if (object == null) {
  48143. return [];
  48144. }
  48145. object = Object(object);
  48146. return arrayFilter(nativeGetSymbols(object), function (symbol) {
  48147. return propertyIsEnumerable.call(object, symbol);
  48148. });
  48149. };
  48150. /**
  48151. * Gets the `toStringTag` of `value`.
  48152. *
  48153. * @private
  48154. * @param {*} value The value to query.
  48155. * @returns {string} Returns the `toStringTag`.
  48156. */
  48157. var getTag = baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  48158. if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise && getTag(Promise.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
  48159. getTag = function getTag(value) {
  48160. var result = baseGetTag(value),
  48161. Ctor = result == objectTag ? value.constructor : undefined,
  48162. ctorString = Ctor ? toSource(Ctor) : '';
  48163. if (ctorString) {
  48164. switch (ctorString) {
  48165. case dataViewCtorString:
  48166. return dataViewTag;
  48167. case mapCtorString:
  48168. return mapTag;
  48169. case promiseCtorString:
  48170. return promiseTag;
  48171. case setCtorString:
  48172. return setTag;
  48173. case weakMapCtorString:
  48174. return weakMapTag;
  48175. }
  48176. }
  48177. return result;
  48178. };
  48179. }
  48180. /**
  48181. * Checks if `value` is a valid array-like index.
  48182. *
  48183. * @private
  48184. * @param {*} value The value to check.
  48185. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  48186. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  48187. */
  48188. function isIndex(value, length) {
  48189. length = length == null ? MAX_SAFE_INTEGER : length;
  48190. return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
  48191. }
  48192. /**
  48193. * Checks if `value` is suitable for use as unique object key.
  48194. *
  48195. * @private
  48196. * @param {*} value The value to check.
  48197. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  48198. */
  48199. function isKeyable(value) {
  48200. var type = _typeof(value);
  48201. return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
  48202. }
  48203. /**
  48204. * Checks if `func` has its source masked.
  48205. *
  48206. * @private
  48207. * @param {Function} func The function to check.
  48208. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  48209. */
  48210. function isMasked(func) {
  48211. return !!maskSrcKey && maskSrcKey in func;
  48212. }
  48213. /**
  48214. * Checks if `value` is likely a prototype object.
  48215. *
  48216. * @private
  48217. * @param {*} value The value to check.
  48218. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  48219. */
  48220. function isPrototype(value) {
  48221. var Ctor = value && value.constructor,
  48222. proto = typeof Ctor == 'function' && Ctor.prototype || objectProto;
  48223. return value === proto;
  48224. }
  48225. /**
  48226. * Converts `value` to a string using `Object.prototype.toString`.
  48227. *
  48228. * @private
  48229. * @param {*} value The value to convert.
  48230. * @returns {string} Returns the converted string.
  48231. */
  48232. function objectToString(value) {
  48233. return nativeObjectToString.call(value);
  48234. }
  48235. /**
  48236. * Converts `func` to its source code.
  48237. *
  48238. * @private
  48239. * @param {Function} func The function to convert.
  48240. * @returns {string} Returns the source code.
  48241. */
  48242. function toSource(func) {
  48243. if (func != null) {
  48244. try {
  48245. return funcToString.call(func);
  48246. } catch (e) { }
  48247. try {
  48248. return func + '';
  48249. } catch (e) { }
  48250. }
  48251. return '';
  48252. }
  48253. /**
  48254. * Performs a
  48255. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  48256. * comparison between two values to determine if they are equivalent.
  48257. *
  48258. * @static
  48259. * @memberOf _
  48260. * @since 4.0.0
  48261. * @category Lang
  48262. * @param {*} value The value to compare.
  48263. * @param {*} other The other value to compare.
  48264. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  48265. * @example
  48266. *
  48267. * var object = { 'a': 1 };
  48268. * var other = { 'a': 1 };
  48269. *
  48270. * _.eq(object, object);
  48271. * // => true
  48272. *
  48273. * _.eq(object, other);
  48274. * // => false
  48275. *
  48276. * _.eq('a', 'a');
  48277. * // => true
  48278. *
  48279. * _.eq('a', Object('a'));
  48280. * // => false
  48281. *
  48282. * _.eq(NaN, NaN);
  48283. * // => true
  48284. */
  48285. function eq(value, other) {
  48286. return value === other || value !== value && other !== other;
  48287. }
  48288. /**
  48289. * Checks if `value` is likely an `arguments` object.
  48290. *
  48291. * @static
  48292. * @memberOf _
  48293. * @since 0.1.0
  48294. * @category Lang
  48295. * @param {*} value The value to check.
  48296. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  48297. * else `false`.
  48298. * @example
  48299. *
  48300. * _.isArguments(function() { return arguments; }());
  48301. * // => true
  48302. *
  48303. * _.isArguments([1, 2, 3]);
  48304. * // => false
  48305. */
  48306. var isArguments = baseIsArguments(function () {
  48307. return arguments;
  48308. }()) ? baseIsArguments : function (value) {
  48309. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  48310. };
  48311. /**
  48312. * Checks if `value` is classified as an `Array` object.
  48313. *
  48314. * @static
  48315. * @memberOf _
  48316. * @since 0.1.0
  48317. * @category Lang
  48318. * @param {*} value The value to check.
  48319. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  48320. * @example
  48321. *
  48322. * _.isArray([1, 2, 3]);
  48323. * // => true
  48324. *
  48325. * _.isArray(document.body.children);
  48326. * // => false
  48327. *
  48328. * _.isArray('abc');
  48329. * // => false
  48330. *
  48331. * _.isArray(_.noop);
  48332. * // => false
  48333. */
  48334. var isArray = Array.isArray;
  48335. /**
  48336. * Checks if `value` is array-like. A value is considered array-like if it's
  48337. * not a function and has a `value.length` that's an integer greater than or
  48338. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  48339. *
  48340. * @static
  48341. * @memberOf _
  48342. * @since 4.0.0
  48343. * @category Lang
  48344. * @param {*} value The value to check.
  48345. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  48346. * @example
  48347. *
  48348. * _.isArrayLike([1, 2, 3]);
  48349. * // => true
  48350. *
  48351. * _.isArrayLike(document.body.children);
  48352. * // => true
  48353. *
  48354. * _.isArrayLike('abc');
  48355. * // => true
  48356. *
  48357. * _.isArrayLike(_.noop);
  48358. * // => false
  48359. */
  48360. function isArrayLike(value) {
  48361. return value != null && isLength(value.length) && !isFunction(value);
  48362. }
  48363. /**
  48364. * Checks if `value` is a buffer.
  48365. *
  48366. * @static
  48367. * @memberOf _
  48368. * @since 4.3.0
  48369. * @category Lang
  48370. * @param {*} value The value to check.
  48371. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  48372. * @example
  48373. *
  48374. * _.isBuffer(new Buffer(2));
  48375. * // => true
  48376. *
  48377. * _.isBuffer(new Uint8Array(2));
  48378. * // => false
  48379. */
  48380. var isBuffer = nativeIsBuffer || stubFalse;
  48381. /**
  48382. * Performs a deep comparison between two values to determine if they are
  48383. * equivalent.
  48384. *
  48385. * **Note:** This method supports comparing arrays, array buffers, booleans,
  48386. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  48387. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  48388. * by their own, not inherited, enumerable properties. Functions and DOM
  48389. * nodes are compared by strict equality, i.e. `===`.
  48390. *
  48391. * @static
  48392. * @memberOf _
  48393. * @since 0.1.0
  48394. * @category Lang
  48395. * @param {*} value The value to compare.
  48396. * @param {*} other The other value to compare.
  48397. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  48398. * @example
  48399. *
  48400. * var object = { 'a': 1 };
  48401. * var other = { 'a': 1 };
  48402. *
  48403. * _.isEqual(object, other);
  48404. * // => true
  48405. *
  48406. * object === other;
  48407. * // => false
  48408. */
  48409. function isEqual(value, other) {
  48410. return baseIsEqual(value, other);
  48411. }
  48412. /**
  48413. * Checks if `value` is classified as a `Function` object.
  48414. *
  48415. * @static
  48416. * @memberOf _
  48417. * @since 0.1.0
  48418. * @category Lang
  48419. * @param {*} value The value to check.
  48420. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  48421. * @example
  48422. *
  48423. * _.isFunction(_);
  48424. * // => true
  48425. *
  48426. * _.isFunction(/abc/);
  48427. * // => false
  48428. */
  48429. function isFunction(value) {
  48430. if (!isObject(value)) {
  48431. return false;
  48432. } // The use of `Object#toString` avoids issues with the `typeof` operator
  48433. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  48434. var tag = baseGetTag(value);
  48435. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  48436. }
  48437. /**
  48438. * Checks if `value` is a valid array-like length.
  48439. *
  48440. * **Note:** This method is loosely based on
  48441. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  48442. *
  48443. * @static
  48444. * @memberOf _
  48445. * @since 4.0.0
  48446. * @category Lang
  48447. * @param {*} value The value to check.
  48448. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  48449. * @example
  48450. *
  48451. * _.isLength(3);
  48452. * // => true
  48453. *
  48454. * _.isLength(Number.MIN_VALUE);
  48455. * // => false
  48456. *
  48457. * _.isLength(Infinity);
  48458. * // => false
  48459. *
  48460. * _.isLength('3');
  48461. * // => false
  48462. */
  48463. function isLength(value) {
  48464. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  48465. }
  48466. /**
  48467. * Checks if `value` is the
  48468. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  48469. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  48470. *
  48471. * @static
  48472. * @memberOf _
  48473. * @since 0.1.0
  48474. * @category Lang
  48475. * @param {*} value The value to check.
  48476. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  48477. * @example
  48478. *
  48479. * _.isObject({});
  48480. * // => true
  48481. *
  48482. * _.isObject([1, 2, 3]);
  48483. * // => true
  48484. *
  48485. * _.isObject(_.noop);
  48486. * // => true
  48487. *
  48488. * _.isObject(null);
  48489. * // => false
  48490. */
  48491. function isObject(value) {
  48492. var type = _typeof(value);
  48493. return value != null && (type == 'object' || type == 'function');
  48494. }
  48495. /**
  48496. * Checks if `value` is object-like. A value is object-like if it's not `null`
  48497. * and has a `typeof` result of "object".
  48498. *
  48499. * @static
  48500. * @memberOf _
  48501. * @since 4.0.0
  48502. * @category Lang
  48503. * @param {*} value The value to check.
  48504. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  48505. * @example
  48506. *
  48507. * _.isObjectLike({});
  48508. * // => true
  48509. *
  48510. * _.isObjectLike([1, 2, 3]);
  48511. * // => true
  48512. *
  48513. * _.isObjectLike(_.noop);
  48514. * // => false
  48515. *
  48516. * _.isObjectLike(null);
  48517. * // => false
  48518. */
  48519. function isObjectLike(value) {
  48520. return value != null && _typeof(value) == 'object';
  48521. }
  48522. /**
  48523. * Checks if `value` is classified as a typed array.
  48524. *
  48525. * @static
  48526. * @memberOf _
  48527. * @since 3.0.0
  48528. * @category Lang
  48529. * @param {*} value The value to check.
  48530. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  48531. * @example
  48532. *
  48533. * _.isTypedArray(new Uint8Array);
  48534. * // => true
  48535. *
  48536. * _.isTypedArray([]);
  48537. * // => false
  48538. */
  48539. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  48540. /**
  48541. * Creates an array of the own enumerable property names of `object`.
  48542. *
  48543. * **Note:** Non-object values are coerced to objects. See the
  48544. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  48545. * for more details.
  48546. *
  48547. * @static
  48548. * @since 0.1.0
  48549. * @memberOf _
  48550. * @category Object
  48551. * @param {Object} object The object to query.
  48552. * @returns {Array} Returns the array of property names.
  48553. * @example
  48554. *
  48555. * function Foo() {
  48556. * this.a = 1;
  48557. * this.b = 2;
  48558. * }
  48559. *
  48560. * Foo.prototype.c = 3;
  48561. *
  48562. * _.keys(new Foo);
  48563. * // => ['a', 'b'] (iteration order is not guaranteed)
  48564. *
  48565. * _.keys('hi');
  48566. * // => ['0', '1']
  48567. */
  48568. function keys(object) {
  48569. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  48570. }
  48571. /**
  48572. * This method returns a new empty array.
  48573. *
  48574. * @static
  48575. * @memberOf _
  48576. * @since 4.13.0
  48577. * @category Util
  48578. * @returns {Array} Returns the new empty array.
  48579. * @example
  48580. *
  48581. * var arrays = _.times(2, _.stubArray);
  48582. *
  48583. * console.log(arrays);
  48584. * // => [[], []]
  48585. *
  48586. * console.log(arrays[0] === arrays[1]);
  48587. * // => false
  48588. */
  48589. function stubArray() {
  48590. return [];
  48591. }
  48592. /**
  48593. * This method returns `false`.
  48594. *
  48595. * @static
  48596. * @memberOf _
  48597. * @since 4.13.0
  48598. * @category Util
  48599. * @returns {boolean} Returns `false`.
  48600. * @example
  48601. *
  48602. * _.times(2, _.stubFalse);
  48603. * // => [false, false]
  48604. */
  48605. function stubFalse() {
  48606. return false;
  48607. }
  48608. module.exports = isEqual;
  48609. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  48610. }, {}], 430: [function (require, module, exports) {
  48611. (function (global) {
  48612. "use strict";
  48613. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  48614. /**
  48615. * Lodash (Custom Build) <https://lodash.com/>
  48616. * Build: `lodash modularize exports="npm" -o ./`
  48617. * Copyright JS Foundation and other contributors <https://js.foundation/>
  48618. * Released under MIT license <https://lodash.com/license>
  48619. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  48620. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  48621. */
  48622. /** `Object#toString` result references. */
  48623. var asyncTag = '[object AsyncFunction]',
  48624. funcTag = '[object Function]',
  48625. genTag = '[object GeneratorFunction]',
  48626. nullTag = '[object Null]',
  48627. proxyTag = '[object Proxy]',
  48628. undefinedTag = '[object Undefined]';
  48629. /** Detect free variable `global` from Node.js. */
  48630. var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
  48631. /** Detect free variable `self`. */
  48632. var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
  48633. /** Used as a reference to the global object. */
  48634. var root = freeGlobal || freeSelf || Function('return this')();
  48635. /** Used for built-in method references. */
  48636. var objectProto = Object.prototype;
  48637. /** Used to check objects for own properties. */
  48638. var hasOwnProperty = objectProto.hasOwnProperty;
  48639. /**
  48640. * Used to resolve the
  48641. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  48642. * of values.
  48643. */
  48644. var nativeObjectToString = objectProto.toString;
  48645. /** Built-in value references. */
  48646. var _Symbol = root.Symbol,
  48647. symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  48648. /**
  48649. * The base implementation of `getTag` without fallbacks for buggy environments.
  48650. *
  48651. * @private
  48652. * @param {*} value The value to query.
  48653. * @returns {string} Returns the `toStringTag`.
  48654. */
  48655. function baseGetTag(value) {
  48656. if (value == null) {
  48657. return value === undefined ? undefinedTag : nullTag;
  48658. }
  48659. return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
  48660. }
  48661. /**
  48662. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  48663. *
  48664. * @private
  48665. * @param {*} value The value to query.
  48666. * @returns {string} Returns the raw `toStringTag`.
  48667. */
  48668. function getRawTag(value) {
  48669. var isOwn = hasOwnProperty.call(value, symToStringTag),
  48670. tag = value[symToStringTag];
  48671. try {
  48672. value[symToStringTag] = undefined;
  48673. var unmasked = true;
  48674. } catch (e) { }
  48675. var result = nativeObjectToString.call(value);
  48676. if (unmasked) {
  48677. if (isOwn) {
  48678. value[symToStringTag] = tag;
  48679. } else {
  48680. delete value[symToStringTag];
  48681. }
  48682. }
  48683. return result;
  48684. }
  48685. /**
  48686. * Converts `value` to a string using `Object.prototype.toString`.
  48687. *
  48688. * @private
  48689. * @param {*} value The value to convert.
  48690. * @returns {string} Returns the converted string.
  48691. */
  48692. function objectToString(value) {
  48693. return nativeObjectToString.call(value);
  48694. }
  48695. /**
  48696. * Checks if `value` is classified as a `Function` object.
  48697. *
  48698. * @static
  48699. * @memberOf _
  48700. * @since 0.1.0
  48701. * @category Lang
  48702. * @param {*} value The value to check.
  48703. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  48704. * @example
  48705. *
  48706. * _.isFunction(_);
  48707. * // => true
  48708. *
  48709. * _.isFunction(/abc/);
  48710. * // => false
  48711. */
  48712. function isFunction(value) {
  48713. if (!isObject(value)) {
  48714. return false;
  48715. } // The use of `Object#toString` avoids issues with the `typeof` operator
  48716. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  48717. var tag = baseGetTag(value);
  48718. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  48719. }
  48720. /**
  48721. * Checks if `value` is the
  48722. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  48723. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  48724. *
  48725. * @static
  48726. * @memberOf _
  48727. * @since 0.1.0
  48728. * @category Lang
  48729. * @param {*} value The value to check.
  48730. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  48731. * @example
  48732. *
  48733. * _.isObject({});
  48734. * // => true
  48735. *
  48736. * _.isObject([1, 2, 3]);
  48737. * // => true
  48738. *
  48739. * _.isObject(_.noop);
  48740. * // => true
  48741. *
  48742. * _.isObject(null);
  48743. * // => false
  48744. */
  48745. function isObject(value) {
  48746. var type = _typeof(value);
  48747. return value != null && (type == 'object' || type == 'function');
  48748. }
  48749. module.exports = isFunction;
  48750. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  48751. }, {}], 431: [function (require, module, exports) {
  48752. "use strict";
  48753. /**
  48754. * lodash 4.0.0 (Custom Build) <https://lodash.com/>
  48755. * Build: `lodash modularize exports="npm" -o ./`
  48756. * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
  48757. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  48758. * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  48759. * Available under MIT license <https://lodash.com/license>
  48760. */
  48761. /**
  48762. * Checks if `value` is `null` or `undefined`.
  48763. *
  48764. * @static
  48765. * @memberOf _
  48766. * @category Lang
  48767. * @param {*} value The value to check.
  48768. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  48769. * @example
  48770. *
  48771. * _.isNil(null);
  48772. * // => true
  48773. *
  48774. * _.isNil(void 0);
  48775. * // => true
  48776. *
  48777. * _.isNil(NaN);
  48778. * // => false
  48779. */
  48780. function isNil(value) {
  48781. return value == null;
  48782. }
  48783. module.exports = isNil;
  48784. }, {}], 432: [function (require, module, exports) {
  48785. "use strict";
  48786. /**
  48787. * lodash 3.0.1 (Custom Build) <https://lodash.com/>
  48788. * Build: `lodash modern modularize exports="npm" -o ./`
  48789. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  48790. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  48791. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  48792. * Available under MIT license <https://lodash.com/license>
  48793. */
  48794. /**
  48795. * Checks if `value` is `undefined`.
  48796. *
  48797. * @static
  48798. * @memberOf _
  48799. * @category Lang
  48800. * @param {*} value The value to check.
  48801. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  48802. * @example
  48803. *
  48804. * _.isUndefined(void 0);
  48805. * // => true
  48806. *
  48807. * _.isUndefined(null);
  48808. * // => false
  48809. */
  48810. function isUndefined(value) {
  48811. return value === undefined;
  48812. }
  48813. module.exports = isUndefined;
  48814. }, {}], 433: [function (require, module, exports) {
  48815. (function (global) {
  48816. "use strict";
  48817. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  48818. /**
  48819. * lodash (Custom Build) <https://lodash.com/>
  48820. * Build: `lodash modularize exports="npm" -o ./`
  48821. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  48822. * Released under MIT license <https://lodash.com/license>
  48823. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  48824. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  48825. */
  48826. /** Used as the size to enable large array optimizations. */
  48827. var LARGE_ARRAY_SIZE = 200;
  48828. /** Used to stand-in for `undefined` hash values. */
  48829. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  48830. /** Used as references for various `Number` constants. */
  48831. var INFINITY = 1 / 0;
  48832. /** `Object#toString` result references. */
  48833. var funcTag = '[object Function]',
  48834. genTag = '[object GeneratorFunction]';
  48835. /**
  48836. * Used to match `RegExp`
  48837. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  48838. */
  48839. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  48840. /** Used to detect host constructors (Safari). */
  48841. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  48842. /** Detect free variable `global` from Node.js. */
  48843. var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
  48844. /** Detect free variable `self`. */
  48845. var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
  48846. /** Used as a reference to the global object. */
  48847. var root = freeGlobal || freeSelf || Function('return this')();
  48848. /**
  48849. * A specialized version of `_.includes` for arrays without support for
  48850. * specifying an index to search from.
  48851. *
  48852. * @private
  48853. * @param {Array} [array] The array to inspect.
  48854. * @param {*} target The value to search for.
  48855. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  48856. */
  48857. function arrayIncludes(array, value) {
  48858. var length = array ? array.length : 0;
  48859. return !!length && baseIndexOf(array, value, 0) > -1;
  48860. }
  48861. /**
  48862. * This function is like `arrayIncludes` except that it accepts a comparator.
  48863. *
  48864. * @private
  48865. * @param {Array} [array] The array to inspect.
  48866. * @param {*} target The value to search for.
  48867. * @param {Function} comparator The comparator invoked per element.
  48868. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  48869. */
  48870. function arrayIncludesWith(array, value, comparator) {
  48871. var index = -1,
  48872. length = array ? array.length : 0;
  48873. while (++index < length) {
  48874. if (comparator(value, array[index])) {
  48875. return true;
  48876. }
  48877. }
  48878. return false;
  48879. }
  48880. /**
  48881. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  48882. * support for iteratee shorthands.
  48883. *
  48884. * @private
  48885. * @param {Array} array The array to inspect.
  48886. * @param {Function} predicate The function invoked per iteration.
  48887. * @param {number} fromIndex The index to search from.
  48888. * @param {boolean} [fromRight] Specify iterating from right to left.
  48889. * @returns {number} Returns the index of the matched value, else `-1`.
  48890. */
  48891. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  48892. var length = array.length,
  48893. index = fromIndex + (fromRight ? 1 : -1);
  48894. while (fromRight ? index-- : ++index < length) {
  48895. if (predicate(array[index], index, array)) {
  48896. return index;
  48897. }
  48898. }
  48899. return -1;
  48900. }
  48901. /**
  48902. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  48903. *
  48904. * @private
  48905. * @param {Array} array The array to inspect.
  48906. * @param {*} value The value to search for.
  48907. * @param {number} fromIndex The index to search from.
  48908. * @returns {number} Returns the index of the matched value, else `-1`.
  48909. */
  48910. function baseIndexOf(array, value, fromIndex) {
  48911. if (value !== value) {
  48912. return baseFindIndex(array, baseIsNaN, fromIndex);
  48913. }
  48914. var index = fromIndex - 1,
  48915. length = array.length;
  48916. while (++index < length) {
  48917. if (array[index] === value) {
  48918. return index;
  48919. }
  48920. }
  48921. return -1;
  48922. }
  48923. /**
  48924. * The base implementation of `_.isNaN` without support for number objects.
  48925. *
  48926. * @private
  48927. * @param {*} value The value to check.
  48928. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  48929. */
  48930. function baseIsNaN(value) {
  48931. return value !== value;
  48932. }
  48933. /**
  48934. * Checks if a cache value for `key` exists.
  48935. *
  48936. * @private
  48937. * @param {Object} cache The cache to query.
  48938. * @param {string} key The key of the entry to check.
  48939. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  48940. */
  48941. function cacheHas(cache, key) {
  48942. return cache.has(key);
  48943. }
  48944. /**
  48945. * Gets the value at `key` of `object`.
  48946. *
  48947. * @private
  48948. * @param {Object} [object] The object to query.
  48949. * @param {string} key The key of the property to get.
  48950. * @returns {*} Returns the property value.
  48951. */
  48952. function getValue(object, key) {
  48953. return object == null ? undefined : object[key];
  48954. }
  48955. /**
  48956. * Checks if `value` is a host object in IE < 9.
  48957. *
  48958. * @private
  48959. * @param {*} value The value to check.
  48960. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  48961. */
  48962. function isHostObject(value) {
  48963. // Many host objects are `Object` objects that can coerce to strings
  48964. // despite having improperly defined `toString` methods.
  48965. var result = false;
  48966. if (value != null && typeof value.toString != 'function') {
  48967. try {
  48968. result = !!(value + '');
  48969. } catch (e) { }
  48970. }
  48971. return result;
  48972. }
  48973. /**
  48974. * Converts `set` to an array of its values.
  48975. *
  48976. * @private
  48977. * @param {Object} set The set to convert.
  48978. * @returns {Array} Returns the values.
  48979. */
  48980. function setToArray(set) {
  48981. var index = -1,
  48982. result = Array(set.size);
  48983. set.forEach(function (value) {
  48984. result[++index] = value;
  48985. });
  48986. return result;
  48987. }
  48988. /** Used for built-in method references. */
  48989. var arrayProto = Array.prototype,
  48990. funcProto = Function.prototype,
  48991. objectProto = Object.prototype;
  48992. /** Used to detect overreaching core-js shims. */
  48993. var coreJsData = root['__core-js_shared__'];
  48994. /** Used to detect methods masquerading as native. */
  48995. var maskSrcKey = function () {
  48996. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  48997. return uid ? 'Symbol(src)_1.' + uid : '';
  48998. }();
  48999. /** Used to resolve the decompiled source of functions. */
  49000. var funcToString = funcProto.toString;
  49001. /** Used to check objects for own properties. */
  49002. var hasOwnProperty = objectProto.hasOwnProperty;
  49003. /**
  49004. * Used to resolve the
  49005. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  49006. * of values.
  49007. */
  49008. var objectToString = objectProto.toString;
  49009. /** Used to detect if a method is native. */
  49010. var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  49011. /** Built-in value references. */
  49012. var splice = arrayProto.splice;
  49013. /* Built-in method references that are verified to be native. */
  49014. var Map = getNative(root, 'Map'),
  49015. Set = getNative(root, 'Set'),
  49016. nativeCreate = getNative(Object, 'create');
  49017. /**
  49018. * Creates a hash object.
  49019. *
  49020. * @private
  49021. * @constructor
  49022. * @param {Array} [entries] The key-value pairs to cache.
  49023. */
  49024. function Hash(entries) {
  49025. var index = -1,
  49026. length = entries ? entries.length : 0;
  49027. this.clear();
  49028. while (++index < length) {
  49029. var entry = entries[index];
  49030. this.set(entry[0], entry[1]);
  49031. }
  49032. }
  49033. /**
  49034. * Removes all key-value entries from the hash.
  49035. *
  49036. * @private
  49037. * @name clear
  49038. * @memberOf Hash
  49039. */
  49040. function hashClear() {
  49041. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  49042. }
  49043. /**
  49044. * Removes `key` and its value from the hash.
  49045. *
  49046. * @private
  49047. * @name delete
  49048. * @memberOf Hash
  49049. * @param {Object} hash The hash to modify.
  49050. * @param {string} key The key of the value to remove.
  49051. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  49052. */
  49053. function hashDelete(key) {
  49054. return this.has(key) && delete this.__data__[key];
  49055. }
  49056. /**
  49057. * Gets the hash value for `key`.
  49058. *
  49059. * @private
  49060. * @name get
  49061. * @memberOf Hash
  49062. * @param {string} key The key of the value to get.
  49063. * @returns {*} Returns the entry value.
  49064. */
  49065. function hashGet(key) {
  49066. var data = this.__data__;
  49067. if (nativeCreate) {
  49068. var result = data[key];
  49069. return result === HASH_UNDEFINED ? undefined : result;
  49070. }
  49071. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  49072. }
  49073. /**
  49074. * Checks if a hash value for `key` exists.
  49075. *
  49076. * @private
  49077. * @name has
  49078. * @memberOf Hash
  49079. * @param {string} key The key of the entry to check.
  49080. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  49081. */
  49082. function hashHas(key) {
  49083. var data = this.__data__;
  49084. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  49085. }
  49086. /**
  49087. * Sets the hash `key` to `value`.
  49088. *
  49089. * @private
  49090. * @name set
  49091. * @memberOf Hash
  49092. * @param {string} key The key of the value to set.
  49093. * @param {*} value The value to set.
  49094. * @returns {Object} Returns the hash instance.
  49095. */
  49096. function hashSet(key, value) {
  49097. var data = this.__data__;
  49098. data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
  49099. return this;
  49100. } // Add methods to `Hash`.
  49101. Hash.prototype.clear = hashClear;
  49102. Hash.prototype['delete'] = hashDelete;
  49103. Hash.prototype.get = hashGet;
  49104. Hash.prototype.has = hashHas;
  49105. Hash.prototype.set = hashSet;
  49106. /**
  49107. * Creates an list cache object.
  49108. *
  49109. * @private
  49110. * @constructor
  49111. * @param {Array} [entries] The key-value pairs to cache.
  49112. */
  49113. function ListCache(entries) {
  49114. var index = -1,
  49115. length = entries ? entries.length : 0;
  49116. this.clear();
  49117. while (++index < length) {
  49118. var entry = entries[index];
  49119. this.set(entry[0], entry[1]);
  49120. }
  49121. }
  49122. /**
  49123. * Removes all key-value entries from the list cache.
  49124. *
  49125. * @private
  49126. * @name clear
  49127. * @memberOf ListCache
  49128. */
  49129. function listCacheClear() {
  49130. this.__data__ = [];
  49131. }
  49132. /**
  49133. * Removes `key` and its value from the list cache.
  49134. *
  49135. * @private
  49136. * @name delete
  49137. * @memberOf ListCache
  49138. * @param {string} key The key of the value to remove.
  49139. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  49140. */
  49141. function listCacheDelete(key) {
  49142. var data = this.__data__,
  49143. index = assocIndexOf(data, key);
  49144. if (index < 0) {
  49145. return false;
  49146. }
  49147. var lastIndex = data.length - 1;
  49148. if (index == lastIndex) {
  49149. data.pop();
  49150. } else {
  49151. splice.call(data, index, 1);
  49152. }
  49153. return true;
  49154. }
  49155. /**
  49156. * Gets the list cache value for `key`.
  49157. *
  49158. * @private
  49159. * @name get
  49160. * @memberOf ListCache
  49161. * @param {string} key The key of the value to get.
  49162. * @returns {*} Returns the entry value.
  49163. */
  49164. function listCacheGet(key) {
  49165. var data = this.__data__,
  49166. index = assocIndexOf(data, key);
  49167. return index < 0 ? undefined : data[index][1];
  49168. }
  49169. /**
  49170. * Checks if a list cache value for `key` exists.
  49171. *
  49172. * @private
  49173. * @name has
  49174. * @memberOf ListCache
  49175. * @param {string} key The key of the entry to check.
  49176. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  49177. */
  49178. function listCacheHas(key) {
  49179. return assocIndexOf(this.__data__, key) > -1;
  49180. }
  49181. /**
  49182. * Sets the list cache `key` to `value`.
  49183. *
  49184. * @private
  49185. * @name set
  49186. * @memberOf ListCache
  49187. * @param {string} key The key of the value to set.
  49188. * @param {*} value The value to set.
  49189. * @returns {Object} Returns the list cache instance.
  49190. */
  49191. function listCacheSet(key, value) {
  49192. var data = this.__data__,
  49193. index = assocIndexOf(data, key);
  49194. if (index < 0) {
  49195. data.push([key, value]);
  49196. } else {
  49197. data[index][1] = value;
  49198. }
  49199. return this;
  49200. } // Add methods to `ListCache`.
  49201. ListCache.prototype.clear = listCacheClear;
  49202. ListCache.prototype['delete'] = listCacheDelete;
  49203. ListCache.prototype.get = listCacheGet;
  49204. ListCache.prototype.has = listCacheHas;
  49205. ListCache.prototype.set = listCacheSet;
  49206. /**
  49207. * Creates a map cache object to store key-value pairs.
  49208. *
  49209. * @private
  49210. * @constructor
  49211. * @param {Array} [entries] The key-value pairs to cache.
  49212. */
  49213. function MapCache(entries) {
  49214. var index = -1,
  49215. length = entries ? entries.length : 0;
  49216. this.clear();
  49217. while (++index < length) {
  49218. var entry = entries[index];
  49219. this.set(entry[0], entry[1]);
  49220. }
  49221. }
  49222. /**
  49223. * Removes all key-value entries from the map.
  49224. *
  49225. * @private
  49226. * @name clear
  49227. * @memberOf MapCache
  49228. */
  49229. function mapCacheClear() {
  49230. this.__data__ = {
  49231. 'hash': new Hash(),
  49232. 'map': new (Map || ListCache)(),
  49233. 'string': new Hash()
  49234. };
  49235. }
  49236. /**
  49237. * Removes `key` and its value from the map.
  49238. *
  49239. * @private
  49240. * @name delete
  49241. * @memberOf MapCache
  49242. * @param {string} key The key of the value to remove.
  49243. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  49244. */
  49245. function mapCacheDelete(key) {
  49246. return getMapData(this, key)['delete'](key);
  49247. }
  49248. /**
  49249. * Gets the map value for `key`.
  49250. *
  49251. * @private
  49252. * @name get
  49253. * @memberOf MapCache
  49254. * @param {string} key The key of the value to get.
  49255. * @returns {*} Returns the entry value.
  49256. */
  49257. function mapCacheGet(key) {
  49258. return getMapData(this, key).get(key);
  49259. }
  49260. /**
  49261. * Checks if a map value for `key` exists.
  49262. *
  49263. * @private
  49264. * @name has
  49265. * @memberOf MapCache
  49266. * @param {string} key The key of the entry to check.
  49267. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  49268. */
  49269. function mapCacheHas(key) {
  49270. return getMapData(this, key).has(key);
  49271. }
  49272. /**
  49273. * Sets the map `key` to `value`.
  49274. *
  49275. * @private
  49276. * @name set
  49277. * @memberOf MapCache
  49278. * @param {string} key The key of the value to set.
  49279. * @param {*} value The value to set.
  49280. * @returns {Object} Returns the map cache instance.
  49281. */
  49282. function mapCacheSet(key, value) {
  49283. getMapData(this, key).set(key, value);
  49284. return this;
  49285. } // Add methods to `MapCache`.
  49286. MapCache.prototype.clear = mapCacheClear;
  49287. MapCache.prototype['delete'] = mapCacheDelete;
  49288. MapCache.prototype.get = mapCacheGet;
  49289. MapCache.prototype.has = mapCacheHas;
  49290. MapCache.prototype.set = mapCacheSet;
  49291. /**
  49292. *
  49293. * Creates an array cache object to store unique values.
  49294. *
  49295. * @private
  49296. * @constructor
  49297. * @param {Array} [values] The values to cache.
  49298. */
  49299. function SetCache(values) {
  49300. var index = -1,
  49301. length = values ? values.length : 0;
  49302. this.__data__ = new MapCache();
  49303. while (++index < length) {
  49304. this.add(values[index]);
  49305. }
  49306. }
  49307. /**
  49308. * Adds `value` to the array cache.
  49309. *
  49310. * @private
  49311. * @name add
  49312. * @memberOf SetCache
  49313. * @alias push
  49314. * @param {*} value The value to cache.
  49315. * @returns {Object} Returns the cache instance.
  49316. */
  49317. function setCacheAdd(value) {
  49318. this.__data__.set(value, HASH_UNDEFINED);
  49319. return this;
  49320. }
  49321. /**
  49322. * Checks if `value` is in the array cache.
  49323. *
  49324. * @private
  49325. * @name has
  49326. * @memberOf SetCache
  49327. * @param {*} value The value to search for.
  49328. * @returns {number} Returns `true` if `value` is found, else `false`.
  49329. */
  49330. function setCacheHas(value) {
  49331. return this.__data__.has(value);
  49332. } // Add methods to `SetCache`.
  49333. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  49334. SetCache.prototype.has = setCacheHas;
  49335. /**
  49336. * Gets the index at which the `key` is found in `array` of key-value pairs.
  49337. *
  49338. * @private
  49339. * @param {Array} array The array to inspect.
  49340. * @param {*} key The key to search for.
  49341. * @returns {number} Returns the index of the matched value, else `-1`.
  49342. */
  49343. function assocIndexOf(array, key) {
  49344. var length = array.length;
  49345. while (length--) {
  49346. if (eq(array[length][0], key)) {
  49347. return length;
  49348. }
  49349. }
  49350. return -1;
  49351. }
  49352. /**
  49353. * The base implementation of `_.isNative` without bad shim checks.
  49354. *
  49355. * @private
  49356. * @param {*} value The value to check.
  49357. * @returns {boolean} Returns `true` if `value` is a native function,
  49358. * else `false`.
  49359. */
  49360. function baseIsNative(value) {
  49361. if (!isObject(value) || isMasked(value)) {
  49362. return false;
  49363. }
  49364. var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
  49365. return pattern.test(toSource(value));
  49366. }
  49367. /**
  49368. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  49369. *
  49370. * @private
  49371. * @param {Array} array The array to inspect.
  49372. * @param {Function} [iteratee] The iteratee invoked per element.
  49373. * @param {Function} [comparator] The comparator invoked per element.
  49374. * @returns {Array} Returns the new duplicate free array.
  49375. */
  49376. function baseUniq(array, iteratee, comparator) {
  49377. var index = -1,
  49378. includes = arrayIncludes,
  49379. length = array.length,
  49380. isCommon = true,
  49381. result = [],
  49382. seen = result;
  49383. if (comparator) {
  49384. isCommon = false;
  49385. includes = arrayIncludesWith;
  49386. } else if (length >= LARGE_ARRAY_SIZE) {
  49387. var set = iteratee ? null : createSet(array);
  49388. if (set) {
  49389. return setToArray(set);
  49390. }
  49391. isCommon = false;
  49392. includes = cacheHas;
  49393. seen = new SetCache();
  49394. } else {
  49395. seen = iteratee ? [] : result;
  49396. }
  49397. outer: while (++index < length) {
  49398. var value = array[index],
  49399. computed = iteratee ? iteratee(value) : value;
  49400. value = comparator || value !== 0 ? value : 0;
  49401. if (isCommon && computed === computed) {
  49402. var seenIndex = seen.length;
  49403. while (seenIndex--) {
  49404. if (seen[seenIndex] === computed) {
  49405. continue outer;
  49406. }
  49407. }
  49408. if (iteratee) {
  49409. seen.push(computed);
  49410. }
  49411. result.push(value);
  49412. } else if (!includes(seen, computed, comparator)) {
  49413. if (seen !== result) {
  49414. seen.push(computed);
  49415. }
  49416. result.push(value);
  49417. }
  49418. }
  49419. return result;
  49420. }
  49421. /**
  49422. * Creates a set object of `values`.
  49423. *
  49424. * @private
  49425. * @param {Array} values The values to add to the set.
  49426. * @returns {Object} Returns the new set.
  49427. */
  49428. var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY) ? noop : function (values) {
  49429. return new Set(values);
  49430. };
  49431. /**
  49432. * Gets the data for `map`.
  49433. *
  49434. * @private
  49435. * @param {Object} map The map to query.
  49436. * @param {string} key The reference key.
  49437. * @returns {*} Returns the map data.
  49438. */
  49439. function getMapData(map, key) {
  49440. var data = map.__data__;
  49441. return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
  49442. }
  49443. /**
  49444. * Gets the native function at `key` of `object`.
  49445. *
  49446. * @private
  49447. * @param {Object} object The object to query.
  49448. * @param {string} key The key of the method to get.
  49449. * @returns {*} Returns the function if it's native, else `undefined`.
  49450. */
  49451. function getNative(object, key) {
  49452. var value = getValue(object, key);
  49453. return baseIsNative(value) ? value : undefined;
  49454. }
  49455. /**
  49456. * Checks if `value` is suitable for use as unique object key.
  49457. *
  49458. * @private
  49459. * @param {*} value The value to check.
  49460. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  49461. */
  49462. function isKeyable(value) {
  49463. var type = _typeof(value);
  49464. return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
  49465. }
  49466. /**
  49467. * Checks if `func` has its source masked.
  49468. *
  49469. * @private
  49470. * @param {Function} func The function to check.
  49471. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  49472. */
  49473. function isMasked(func) {
  49474. return !!maskSrcKey && maskSrcKey in func;
  49475. }
  49476. /**
  49477. * Converts `func` to its source code.
  49478. *
  49479. * @private
  49480. * @param {Function} func The function to process.
  49481. * @returns {string} Returns the source code.
  49482. */
  49483. function toSource(func) {
  49484. if (func != null) {
  49485. try {
  49486. return funcToString.call(func);
  49487. } catch (e) { }
  49488. try {
  49489. return func + '';
  49490. } catch (e) { }
  49491. }
  49492. return '';
  49493. }
  49494. /**
  49495. * Creates a duplicate-free version of an array, using
  49496. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  49497. * for equality comparisons, in which only the first occurrence of each
  49498. * element is kept.
  49499. *
  49500. * @static
  49501. * @memberOf _
  49502. * @since 0.1.0
  49503. * @category Array
  49504. * @param {Array} array The array to inspect.
  49505. * @returns {Array} Returns the new duplicate free array.
  49506. * @example
  49507. *
  49508. * _.uniq([2, 1, 2]);
  49509. * // => [2, 1]
  49510. */
  49511. function uniq(array) {
  49512. return array && array.length ? baseUniq(array) : [];
  49513. }
  49514. /**
  49515. * Performs a
  49516. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  49517. * comparison between two values to determine if they are equivalent.
  49518. *
  49519. * @static
  49520. * @memberOf _
  49521. * @since 4.0.0
  49522. * @category Lang
  49523. * @param {*} value The value to compare.
  49524. * @param {*} other The other value to compare.
  49525. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  49526. * @example
  49527. *
  49528. * var object = { 'a': 1 };
  49529. * var other = { 'a': 1 };
  49530. *
  49531. * _.eq(object, object);
  49532. * // => true
  49533. *
  49534. * _.eq(object, other);
  49535. * // => false
  49536. *
  49537. * _.eq('a', 'a');
  49538. * // => true
  49539. *
  49540. * _.eq('a', Object('a'));
  49541. * // => false
  49542. *
  49543. * _.eq(NaN, NaN);
  49544. * // => true
  49545. */
  49546. function eq(value, other) {
  49547. return value === other || value !== value && other !== other;
  49548. }
  49549. /**
  49550. * Checks if `value` is classified as a `Function` object.
  49551. *
  49552. * @static
  49553. * @memberOf _
  49554. * @since 0.1.0
  49555. * @category Lang
  49556. * @param {*} value The value to check.
  49557. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  49558. * @example
  49559. *
  49560. * _.isFunction(_);
  49561. * // => true
  49562. *
  49563. * _.isFunction(/abc/);
  49564. * // => false
  49565. */
  49566. function isFunction(value) {
  49567. // The use of `Object#toString` avoids issues with the `typeof` operator
  49568. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  49569. var tag = isObject(value) ? objectToString.call(value) : '';
  49570. return tag == funcTag || tag == genTag;
  49571. }
  49572. /**
  49573. * Checks if `value` is the
  49574. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  49575. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  49576. *
  49577. * @static
  49578. * @memberOf _
  49579. * @since 0.1.0
  49580. * @category Lang
  49581. * @param {*} value The value to check.
  49582. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  49583. * @example
  49584. *
  49585. * _.isObject({});
  49586. * // => true
  49587. *
  49588. * _.isObject([1, 2, 3]);
  49589. * // => true
  49590. *
  49591. * _.isObject(_.noop);
  49592. * // => true
  49593. *
  49594. * _.isObject(null);
  49595. * // => false
  49596. */
  49597. function isObject(value) {
  49598. var type = _typeof(value);
  49599. return !!value && (type == 'object' || type == 'function');
  49600. }
  49601. /**
  49602. * This method returns `undefined`.
  49603. *
  49604. * @static
  49605. * @memberOf _
  49606. * @since 2.3.0
  49607. * @category Util
  49608. * @example
  49609. *
  49610. * _.times(2, _.noop);
  49611. * // => [undefined, undefined]
  49612. */
  49613. function noop() {// No operation performed.
  49614. }
  49615. module.exports = uniq;
  49616. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  49617. }, {}], 434: [function (require, module, exports) {
  49618. 'use strict';
  49619. var inherits = require('inherits');
  49620. var HashBase = require('hash-base');
  49621. var Buffer = require('safe-buffer').Buffer;
  49622. var ARRAY16 = new Array(16);
  49623. function MD5() {
  49624. HashBase.call(this, 64); // state
  49625. this._a = 0x67452301;
  49626. this._b = 0xefcdab89;
  49627. this._c = 0x98badcfe;
  49628. this._d = 0x10325476;
  49629. }
  49630. inherits(MD5, HashBase);
  49631. MD5.prototype._update = function () {
  49632. var M = ARRAY16;
  49633. for (var i = 0; i < 16; ++i) {
  49634. M[i] = this._block.readInt32LE(i * 4);
  49635. }
  49636. var a = this._a;
  49637. var b = this._b;
  49638. var c = this._c;
  49639. var d = this._d;
  49640. a = fnF(a, b, c, d, M[0], 0xd76aa478, 7);
  49641. d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12);
  49642. c = fnF(c, d, a, b, M[2], 0x242070db, 17);
  49643. b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22);
  49644. a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7);
  49645. d = fnF(d, a, b, c, M[5], 0x4787c62a, 12);
  49646. c = fnF(c, d, a, b, M[6], 0xa8304613, 17);
  49647. b = fnF(b, c, d, a, M[7], 0xfd469501, 22);
  49648. a = fnF(a, b, c, d, M[8], 0x698098d8, 7);
  49649. d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12);
  49650. c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17);
  49651. b = fnF(b, c, d, a, M[11], 0x895cd7be, 22);
  49652. a = fnF(a, b, c, d, M[12], 0x6b901122, 7);
  49653. d = fnF(d, a, b, c, M[13], 0xfd987193, 12);
  49654. c = fnF(c, d, a, b, M[14], 0xa679438e, 17);
  49655. b = fnF(b, c, d, a, M[15], 0x49b40821, 22);
  49656. a = fnG(a, b, c, d, M[1], 0xf61e2562, 5);
  49657. d = fnG(d, a, b, c, M[6], 0xc040b340, 9);
  49658. c = fnG(c, d, a, b, M[11], 0x265e5a51, 14);
  49659. b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20);
  49660. a = fnG(a, b, c, d, M[5], 0xd62f105d, 5);
  49661. d = fnG(d, a, b, c, M[10], 0x02441453, 9);
  49662. c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14);
  49663. b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20);
  49664. a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5);
  49665. d = fnG(d, a, b, c, M[14], 0xc33707d6, 9);
  49666. c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14);
  49667. b = fnG(b, c, d, a, M[8], 0x455a14ed, 20);
  49668. a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5);
  49669. d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9);
  49670. c = fnG(c, d, a, b, M[7], 0x676f02d9, 14);
  49671. b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20);
  49672. a = fnH(a, b, c, d, M[5], 0xfffa3942, 4);
  49673. d = fnH(d, a, b, c, M[8], 0x8771f681, 11);
  49674. c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16);
  49675. b = fnH(b, c, d, a, M[14], 0xfde5380c, 23);
  49676. a = fnH(a, b, c, d, M[1], 0xa4beea44, 4);
  49677. d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11);
  49678. c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16);
  49679. b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23);
  49680. a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4);
  49681. d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11);
  49682. c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16);
  49683. b = fnH(b, c, d, a, M[6], 0x04881d05, 23);
  49684. a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4);
  49685. d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11);
  49686. c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16);
  49687. b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23);
  49688. a = fnI(a, b, c, d, M[0], 0xf4292244, 6);
  49689. d = fnI(d, a, b, c, M[7], 0x432aff97, 10);
  49690. c = fnI(c, d, a, b, M[14], 0xab9423a7, 15);
  49691. b = fnI(b, c, d, a, M[5], 0xfc93a039, 21);
  49692. a = fnI(a, b, c, d, M[12], 0x655b59c3, 6);
  49693. d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10);
  49694. c = fnI(c, d, a, b, M[10], 0xffeff47d, 15);
  49695. b = fnI(b, c, d, a, M[1], 0x85845dd1, 21);
  49696. a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6);
  49697. d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10);
  49698. c = fnI(c, d, a, b, M[6], 0xa3014314, 15);
  49699. b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21);
  49700. a = fnI(a, b, c, d, M[4], 0xf7537e82, 6);
  49701. d = fnI(d, a, b, c, M[11], 0xbd3af235, 10);
  49702. c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15);
  49703. b = fnI(b, c, d, a, M[9], 0xeb86d391, 21);
  49704. this._a = this._a + a | 0;
  49705. this._b = this._b + b | 0;
  49706. this._c = this._c + c | 0;
  49707. this._d = this._d + d | 0;
  49708. };
  49709. MD5.prototype._digest = function () {
  49710. // create padding and handle blocks
  49711. this._block[this._blockOffset++] = 0x80;
  49712. if (this._blockOffset > 56) {
  49713. this._block.fill(0, this._blockOffset, 64);
  49714. this._update();
  49715. this._blockOffset = 0;
  49716. }
  49717. this._block.fill(0, this._blockOffset, 56);
  49718. this._block.writeUInt32LE(this._length[0], 56);
  49719. this._block.writeUInt32LE(this._length[1], 60);
  49720. this._update(); // produce result
  49721. var buffer = Buffer.allocUnsafe(16);
  49722. buffer.writeInt32LE(this._a, 0);
  49723. buffer.writeInt32LE(this._b, 4);
  49724. buffer.writeInt32LE(this._c, 8);
  49725. buffer.writeInt32LE(this._d, 12);
  49726. return buffer;
  49727. };
  49728. function rotl(x, n) {
  49729. return x << n | x >>> 32 - n;
  49730. }
  49731. function fnF(a, b, c, d, m, k, s) {
  49732. return rotl(a + (b & c | ~b & d) + m + k | 0, s) + b | 0;
  49733. }
  49734. function fnG(a, b, c, d, m, k, s) {
  49735. return rotl(a + (b & d | c & ~d) + m + k | 0, s) + b | 0;
  49736. }
  49737. function fnH(a, b, c, d, m, k, s) {
  49738. return rotl(a + (b ^ c ^ d) + m + k | 0, s) + b | 0;
  49739. }
  49740. function fnI(a, b, c, d, m, k, s) {
  49741. return rotl(a + (c ^ (b | ~d)) + m + k | 0, s) + b | 0;
  49742. }
  49743. module.exports = MD5;
  49744. }, { "hash-base": 370, "inherits": 387, "safe-buffer": 494 }], 435: [function (require, module, exports) {
  49745. "use strict";
  49746. var bn = require('bn.js');
  49747. var brorand = require('brorand');
  49748. function MillerRabin(rand) {
  49749. this.rand = rand || new brorand.Rand();
  49750. }
  49751. module.exports = MillerRabin;
  49752. MillerRabin.create = function create(rand) {
  49753. return new MillerRabin(rand);
  49754. };
  49755. MillerRabin.prototype._randbelow = function _randbelow(n) {
  49756. var len = n.bitLength();
  49757. var min_bytes = Math.ceil(len / 8); // Generage random bytes until a number less than n is found.
  49758. // This ensures that 0..n-1 have an equal probability of being selected.
  49759. do {
  49760. var a = new bn(this.rand.generate(min_bytes));
  49761. } while (a.cmp(n) >= 0);
  49762. return a;
  49763. };
  49764. MillerRabin.prototype._randrange = function _randrange(start, stop) {
  49765. // Generate a random number greater than or equal to start and less than stop.
  49766. var size = stop.sub(start);
  49767. return start.add(this._randbelow(size));
  49768. };
  49769. MillerRabin.prototype.test = function test(n, k, cb) {
  49770. var len = n.bitLength();
  49771. var red = bn.mont(n);
  49772. var rone = new bn(1).toRed(red);
  49773. if (!k) k = Math.max(1, len / 48 | 0); // Find d and s, (n - 1) = (2 ^ s) * d;
  49774. var n1 = n.subn(1);
  49775. for (var s = 0; !n1.testn(s); s++) { }
  49776. var d = n.shrn(s);
  49777. var rn1 = n1.toRed(red);
  49778. var prime = true;
  49779. for (; k > 0; k--) {
  49780. var a = this._randrange(new bn(2), n1);
  49781. if (cb) cb(a);
  49782. var x = a.toRed(red).redPow(d);
  49783. if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) continue;
  49784. for (var i = 1; i < s; i++) {
  49785. x = x.redSqr();
  49786. if (x.cmp(rone) === 0) return false;
  49787. if (x.cmp(rn1) === 0) break;
  49788. }
  49789. if (i === s) return false;
  49790. }
  49791. return prime;
  49792. };
  49793. MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
  49794. var len = n.bitLength();
  49795. var red = bn.mont(n);
  49796. var rone = new bn(1).toRed(red);
  49797. if (!k) k = Math.max(1, len / 48 | 0); // Find d and s, (n - 1) = (2 ^ s) * d;
  49798. var n1 = n.subn(1);
  49799. for (var s = 0; !n1.testn(s); s++) { }
  49800. var d = n.shrn(s);
  49801. var rn1 = n1.toRed(red);
  49802. for (; k > 0; k--) {
  49803. var a = this._randrange(new bn(2), n1);
  49804. var g = n.gcd(a);
  49805. if (g.cmpn(1) !== 0) return g;
  49806. var x = a.toRed(red).redPow(d);
  49807. if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) continue;
  49808. for (var i = 1; i < s; i++) {
  49809. x = x.redSqr();
  49810. if (x.cmp(rone) === 0) return x.fromRed().subn(1).gcd(n);
  49811. if (x.cmp(rn1) === 0) break;
  49812. }
  49813. if (i === s) {
  49814. x = x.redSqr();
  49815. return x.fromRed().subn(1).gcd(n);
  49816. }
  49817. }
  49818. return false;
  49819. };
  49820. }, { "bn.js": 436, "brorand": 184 }], 436: [function (require, module, exports) {
  49821. arguments[4][181][0].apply(exports, arguments)
  49822. }, { "buffer": 185, "dup": 181 }], 437: [function (require, module, exports) {
  49823. "use strict";
  49824. module.exports = assert;
  49825. function assert(val, msg) {
  49826. if (!val) throw new Error(msg || 'Assertion failed');
  49827. }
  49828. assert.equal = function assertEqual(l, r, msg) {
  49829. if (l != r) throw new Error(msg || 'Assertion failed: ' + l + ' != ' + r);
  49830. };
  49831. }, {}], 438: [function (require, module, exports) {
  49832. 'use strict';
  49833. var utils = exports;
  49834. function toArray(msg, enc) {
  49835. if (Array.isArray(msg)) return msg.slice();
  49836. if (!msg) return [];
  49837. var res = [];
  49838. if (typeof msg !== 'string') {
  49839. for (var i = 0; i < msg.length; i++) {
  49840. res[i] = msg[i] | 0;
  49841. }
  49842. return res;
  49843. }
  49844. if (enc === 'hex') {
  49845. msg = msg.replace(/[^a-z0-9]+/ig, '');
  49846. if (msg.length % 2 !== 0) msg = '0' + msg;
  49847. for (var i = 0; i < msg.length; i += 2) {
  49848. res.push(parseInt(msg[i] + msg[i + 1], 16));
  49849. }
  49850. } else {
  49851. for (var i = 0; i < msg.length; i++) {
  49852. var c = msg.charCodeAt(i);
  49853. var hi = c >> 8;
  49854. var lo = c & 0xff;
  49855. if (hi) res.push(hi, lo); else res.push(lo);
  49856. }
  49857. }
  49858. return res;
  49859. }
  49860. utils.toArray = toArray;
  49861. function zero2(word) {
  49862. if (word.length === 1) return '0' + word; else return word;
  49863. }
  49864. utils.zero2 = zero2;
  49865. function toHex(msg) {
  49866. var res = '';
  49867. for (var i = 0; i < msg.length; i++) {
  49868. res += zero2(msg[i].toString(16));
  49869. }
  49870. return res;
  49871. }
  49872. utils.toHex = toHex;
  49873. utils.encode = function encode(arr, enc) {
  49874. if (enc === 'hex') return toHex(arr); else return arr;
  49875. };
  49876. }, {}], 439: [function (require, module, exports) {
  49877. // Top level file is just a mixin of submodules & constants
  49878. 'use strict';
  49879. var assign = require('./lib/utils/common').assign;
  49880. var deflate = require('./lib/deflate');
  49881. var inflate = require('./lib/inflate');
  49882. var constants = require('./lib/zlib/constants');
  49883. var pako = {};
  49884. assign(pako, deflate, inflate, constants);
  49885. module.exports = pako;
  49886. }, { "./lib/deflate": 440, "./lib/inflate": 441, "./lib/utils/common": 442, "./lib/zlib/constants": 445 }], 440: [function (require, module, exports) {
  49887. 'use strict';
  49888. var zlib_deflate = require('./zlib/deflate');
  49889. var utils = require('./utils/common');
  49890. var strings = require('./utils/strings');
  49891. var msg = require('./zlib/messages');
  49892. var ZStream = require('./zlib/zstream');
  49893. var toString = Object.prototype.toString;
  49894. /* Public constants ==========================================================*/
  49895. /* ===========================================================================*/
  49896. var Z_NO_FLUSH = 0;
  49897. var Z_FINISH = 4;
  49898. var Z_OK = 0;
  49899. var Z_STREAM_END = 1;
  49900. var Z_SYNC_FLUSH = 2;
  49901. var Z_DEFAULT_COMPRESSION = -1;
  49902. var Z_DEFAULT_STRATEGY = 0;
  49903. var Z_DEFLATED = 8;
  49904. /* ===========================================================================*/
  49905. /**
  49906. * class Deflate
  49907. *
  49908. * Generic JS-style wrapper for zlib calls. If you don't need
  49909. * streaming behaviour - use more simple functions: [[deflate]],
  49910. * [[deflateRaw]] and [[gzip]].
  49911. **/
  49912. /* internal
  49913. * Deflate.chunks -> Array
  49914. *
  49915. * Chunks of output data, if [[Deflate#onData]] not overridden.
  49916. **/
  49917. /**
  49918. * Deflate.result -> Uint8Array|Array
  49919. *
  49920. * Compressed result, generated by default [[Deflate#onData]]
  49921. * and [[Deflate#onEnd]] handlers. Filled after you push last chunk
  49922. * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you
  49923. * push a chunk with explicit flush (call [[Deflate#push]] with
  49924. * `Z_SYNC_FLUSH` param).
  49925. **/
  49926. /**
  49927. * Deflate.err -> Number
  49928. *
  49929. * Error code after deflate finished. 0 (Z_OK) on success.
  49930. * You will not need it in real life, because deflate errors
  49931. * are possible only on wrong options or bad `onData` / `onEnd`
  49932. * custom handlers.
  49933. **/
  49934. /**
  49935. * Deflate.msg -> String
  49936. *
  49937. * Error message, if [[Deflate.err]] != 0
  49938. **/
  49939. /**
  49940. * new Deflate(options)
  49941. * - options (Object): zlib deflate options.
  49942. *
  49943. * Creates new deflator instance with specified params. Throws exception
  49944. * on bad params. Supported options:
  49945. *
  49946. * - `level`
  49947. * - `windowBits`
  49948. * - `memLevel`
  49949. * - `strategy`
  49950. * - `dictionary`
  49951. *
  49952. * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
  49953. * for more information on these.
  49954. *
  49955. * Additional options, for internal needs:
  49956. *
  49957. * - `chunkSize` - size of generated data chunks (16K by default)
  49958. * - `raw` (Boolean) - do raw deflate
  49959. * - `gzip` (Boolean) - create gzip wrapper
  49960. * - `to` (String) - if equal to 'string', then result will be "binary string"
  49961. * (each char code [0..255])
  49962. * - `header` (Object) - custom header for gzip
  49963. * - `text` (Boolean) - true if compressed data believed to be text
  49964. * - `time` (Number) - modification time, unix timestamp
  49965. * - `os` (Number) - operation system code
  49966. * - `extra` (Array) - array of bytes with extra data (max 65536)
  49967. * - `name` (String) - file name (binary string)
  49968. * - `comment` (String) - comment (binary string)
  49969. * - `hcrc` (Boolean) - true if header crc should be added
  49970. *
  49971. * ##### Example:
  49972. *
  49973. * ```javascript
  49974. * var pako = require('pako')
  49975. * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
  49976. * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
  49977. *
  49978. * var deflate = new pako.Deflate({ level: 3});
  49979. *
  49980. * deflate.push(chunk1, false);
  49981. * deflate.push(chunk2, true); // true -> last chunk
  49982. *
  49983. * if (deflate.err) { throw new Error(deflate.err); }
  49984. *
  49985. * console.log(deflate.result);
  49986. * ```
  49987. **/
  49988. function Deflate(options) {
  49989. if (!(this instanceof Deflate)) return new Deflate(options);
  49990. this.options = utils.assign({
  49991. level: Z_DEFAULT_COMPRESSION,
  49992. method: Z_DEFLATED,
  49993. chunkSize: 16384,
  49994. windowBits: 15,
  49995. memLevel: 8,
  49996. strategy: Z_DEFAULT_STRATEGY,
  49997. to: ''
  49998. }, options || {});
  49999. var opt = this.options;
  50000. if (opt.raw && opt.windowBits > 0) {
  50001. opt.windowBits = -opt.windowBits;
  50002. } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {
  50003. opt.windowBits += 16;
  50004. }
  50005. this.err = 0; // error code, if happens (0 = Z_OK)
  50006. this.msg = ''; // error message
  50007. this.ended = false; // used to avoid multiple onEnd() calls
  50008. this.chunks = []; // chunks of compressed data
  50009. this.strm = new ZStream();
  50010. this.strm.avail_out = 0;
  50011. var status = zlib_deflate.deflateInit2(this.strm, opt.level, opt.method, opt.windowBits, opt.memLevel, opt.strategy);
  50012. if (status !== Z_OK) {
  50013. throw new Error(msg[status]);
  50014. }
  50015. if (opt.header) {
  50016. zlib_deflate.deflateSetHeader(this.strm, opt.header);
  50017. }
  50018. if (opt.dictionary) {
  50019. var dict; // Convert data if needed
  50020. if (typeof opt.dictionary === 'string') {
  50021. // If we need to compress text, change encoding to utf8.
  50022. dict = strings.string2buf(opt.dictionary);
  50023. } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
  50024. dict = new Uint8Array(opt.dictionary);
  50025. } else {
  50026. dict = opt.dictionary;
  50027. }
  50028. status = zlib_deflate.deflateSetDictionary(this.strm, dict);
  50029. if (status !== Z_OK) {
  50030. throw new Error(msg[status]);
  50031. }
  50032. this._dict_set = true;
  50033. }
  50034. }
  50035. /**
  50036. * Deflate#push(data[, mode]) -> Boolean
  50037. * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be
  50038. * converted to utf8 byte sequence.
  50039. * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
  50040. * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.
  50041. *
  50042. * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with
  50043. * new compressed chunks. Returns `true` on success. The last data block must have
  50044. * mode Z_FINISH (or `true`). That will flush internal pending buffers and call
  50045. * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you
  50046. * can use mode Z_SYNC_FLUSH, keeping the compression context.
  50047. *
  50048. * On fail call [[Deflate#onEnd]] with error code and return false.
  50049. *
  50050. * We strongly recommend to use `Uint8Array` on input for best speed (output
  50051. * array format is detected automatically). Also, don't skip last param and always
  50052. * use the same type in your code (boolean or number). That will improve JS speed.
  50053. *
  50054. * For regular `Array`-s make sure all elements are [0..255].
  50055. *
  50056. * ##### Example
  50057. *
  50058. * ```javascript
  50059. * push(chunk, false); // push one of data chunks
  50060. * ...
  50061. * push(chunk, true); // push last chunk
  50062. * ```
  50063. **/
  50064. Deflate.prototype.push = function (data, mode) {
  50065. var strm = this.strm;
  50066. var chunkSize = this.options.chunkSize;
  50067. var status, _mode;
  50068. if (this.ended) {
  50069. return false;
  50070. }
  50071. _mode = mode === ~~mode ? mode : mode === true ? Z_FINISH : Z_NO_FLUSH; // Convert data if needed
  50072. if (typeof data === 'string') {
  50073. // If we need to compress text, change encoding to utf8.
  50074. strm.input = strings.string2buf(data);
  50075. } else if (toString.call(data) === '[object ArrayBuffer]') {
  50076. strm.input = new Uint8Array(data);
  50077. } else {
  50078. strm.input = data;
  50079. }
  50080. strm.next_in = 0;
  50081. strm.avail_in = strm.input.length;
  50082. do {
  50083. if (strm.avail_out === 0) {
  50084. strm.output = new utils.Buf8(chunkSize);
  50085. strm.next_out = 0;
  50086. strm.avail_out = chunkSize;
  50087. }
  50088. status = zlib_deflate.deflate(strm, _mode);
  50089. /* no bad return value */
  50090. if (status !== Z_STREAM_END && status !== Z_OK) {
  50091. this.onEnd(status);
  50092. this.ended = true;
  50093. return false;
  50094. }
  50095. if (strm.avail_out === 0 || strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH)) {
  50096. if (this.options.to === 'string') {
  50097. this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));
  50098. } else {
  50099. this.onData(utils.shrinkBuf(strm.output, strm.next_out));
  50100. }
  50101. }
  50102. } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END); // Finalize on the last chunk.
  50103. if (_mode === Z_FINISH) {
  50104. status = zlib_deflate.deflateEnd(this.strm);
  50105. this.onEnd(status);
  50106. this.ended = true;
  50107. return status === Z_OK;
  50108. } // callback interim results if Z_SYNC_FLUSH.
  50109. if (_mode === Z_SYNC_FLUSH) {
  50110. this.onEnd(Z_OK);
  50111. strm.avail_out = 0;
  50112. return true;
  50113. }
  50114. return true;
  50115. };
  50116. /**
  50117. * Deflate#onData(chunk) -> Void
  50118. * - chunk (Uint8Array|Array|String): output data. Type of array depends
  50119. * on js engine support. When string output requested, each chunk
  50120. * will be string.
  50121. *
  50122. * By default, stores data blocks in `chunks[]` property and glue
  50123. * those in `onEnd`. Override this handler, if you need another behaviour.
  50124. **/
  50125. Deflate.prototype.onData = function (chunk) {
  50126. this.chunks.push(chunk);
  50127. };
  50128. /**
  50129. * Deflate#onEnd(status) -> Void
  50130. * - status (Number): deflate status. 0 (Z_OK) on success,
  50131. * other if not.
  50132. *
  50133. * Called once after you tell deflate that the input stream is
  50134. * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
  50135. * or if an error happened. By default - join collected chunks,
  50136. * free memory and fill `results` / `err` properties.
  50137. **/
  50138. Deflate.prototype.onEnd = function (status) {
  50139. // On success - join
  50140. if (status === Z_OK) {
  50141. if (this.options.to === 'string') {
  50142. this.result = this.chunks.join('');
  50143. } else {
  50144. this.result = utils.flattenChunks(this.chunks);
  50145. }
  50146. }
  50147. this.chunks = [];
  50148. this.err = status;
  50149. this.msg = this.strm.msg;
  50150. };
  50151. /**
  50152. * deflate(data[, options]) -> Uint8Array|Array|String
  50153. * - data (Uint8Array|Array|String): input data to compress.
  50154. * - options (Object): zlib deflate options.
  50155. *
  50156. * Compress `data` with deflate algorithm and `options`.
  50157. *
  50158. * Supported options are:
  50159. *
  50160. * - level
  50161. * - windowBits
  50162. * - memLevel
  50163. * - strategy
  50164. * - dictionary
  50165. *
  50166. * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
  50167. * for more information on these.
  50168. *
  50169. * Sugar (options):
  50170. *
  50171. * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
  50172. * negative windowBits implicitly.
  50173. * - `to` (String) - if equal to 'string', then result will be "binary string"
  50174. * (each char code [0..255])
  50175. *
  50176. * ##### Example:
  50177. *
  50178. * ```javascript
  50179. * var pako = require('pako')
  50180. * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);
  50181. *
  50182. * console.log(pako.deflate(data));
  50183. * ```
  50184. **/
  50185. function deflate(input, options) {
  50186. var deflator = new Deflate(options);
  50187. deflator.push(input, true); // That will never happens, if you don't cheat with options :)
  50188. if (deflator.err) {
  50189. throw deflator.msg || msg[deflator.err];
  50190. }
  50191. return deflator.result;
  50192. }
  50193. /**
  50194. * deflateRaw(data[, options]) -> Uint8Array|Array|String
  50195. * - data (Uint8Array|Array|String): input data to compress.
  50196. * - options (Object): zlib deflate options.
  50197. *
  50198. * The same as [[deflate]], but creates raw data, without wrapper
  50199. * (header and adler32 crc).
  50200. **/
  50201. function deflateRaw(input, options) {
  50202. options = options || {};
  50203. options.raw = true;
  50204. return deflate(input, options);
  50205. }
  50206. /**
  50207. * gzip(data[, options]) -> Uint8Array|Array|String
  50208. * - data (Uint8Array|Array|String): input data to compress.
  50209. * - options (Object): zlib deflate options.
  50210. *
  50211. * The same as [[deflate]], but create gzip wrapper instead of
  50212. * deflate one.
  50213. **/
  50214. function gzip(input, options) {
  50215. options = options || {};
  50216. options.gzip = true;
  50217. return deflate(input, options);
  50218. }
  50219. exports.Deflate = Deflate;
  50220. exports.deflate = deflate;
  50221. exports.deflateRaw = deflateRaw;
  50222. exports.gzip = gzip;
  50223. }, { "./utils/common": 442, "./utils/strings": 443, "./zlib/deflate": 447, "./zlib/messages": 452, "./zlib/zstream": 454 }], 441: [function (require, module, exports) {
  50224. 'use strict';
  50225. var zlib_inflate = require('./zlib/inflate');
  50226. var utils = require('./utils/common');
  50227. var strings = require('./utils/strings');
  50228. var c = require('./zlib/constants');
  50229. var msg = require('./zlib/messages');
  50230. var ZStream = require('./zlib/zstream');
  50231. var GZheader = require('./zlib/gzheader');
  50232. var toString = Object.prototype.toString;
  50233. /**
  50234. * class Inflate
  50235. *
  50236. * Generic JS-style wrapper for zlib calls. If you don't need
  50237. * streaming behaviour - use more simple functions: [[inflate]]
  50238. * and [[inflateRaw]].
  50239. **/
  50240. /* internal
  50241. * inflate.chunks -> Array
  50242. *
  50243. * Chunks of output data, if [[Inflate#onData]] not overridden.
  50244. **/
  50245. /**
  50246. * Inflate.result -> Uint8Array|Array|String
  50247. *
  50248. * Uncompressed result, generated by default [[Inflate#onData]]
  50249. * and [[Inflate#onEnd]] handlers. Filled after you push last chunk
  50250. * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you
  50251. * push a chunk with explicit flush (call [[Inflate#push]] with
  50252. * `Z_SYNC_FLUSH` param).
  50253. **/
  50254. /**
  50255. * Inflate.err -> Number
  50256. *
  50257. * Error code after inflate finished. 0 (Z_OK) on success.
  50258. * Should be checked if broken data possible.
  50259. **/
  50260. /**
  50261. * Inflate.msg -> String
  50262. *
  50263. * Error message, if [[Inflate.err]] != 0
  50264. **/
  50265. /**
  50266. * new Inflate(options)
  50267. * - options (Object): zlib inflate options.
  50268. *
  50269. * Creates new inflator instance with specified params. Throws exception
  50270. * on bad params. Supported options:
  50271. *
  50272. * - `windowBits`
  50273. * - `dictionary`
  50274. *
  50275. * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
  50276. * for more information on these.
  50277. *
  50278. * Additional options, for internal needs:
  50279. *
  50280. * - `chunkSize` - size of generated data chunks (16K by default)
  50281. * - `raw` (Boolean) - do raw inflate
  50282. * - `to` (String) - if equal to 'string', then result will be converted
  50283. * from utf8 to utf16 (javascript) string. When string output requested,
  50284. * chunk length can differ from `chunkSize`, depending on content.
  50285. *
  50286. * By default, when no options set, autodetect deflate/gzip data format via
  50287. * wrapper header.
  50288. *
  50289. * ##### Example:
  50290. *
  50291. * ```javascript
  50292. * var pako = require('pako')
  50293. * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
  50294. * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
  50295. *
  50296. * var inflate = new pako.Inflate({ level: 3});
  50297. *
  50298. * inflate.push(chunk1, false);
  50299. * inflate.push(chunk2, true); // true -> last chunk
  50300. *
  50301. * if (inflate.err) { throw new Error(inflate.err); }
  50302. *
  50303. * console.log(inflate.result);
  50304. * ```
  50305. **/
  50306. function Inflate(options) {
  50307. if (!(this instanceof Inflate)) return new Inflate(options);
  50308. this.options = utils.assign({
  50309. chunkSize: 16384,
  50310. windowBits: 0,
  50311. to: ''
  50312. }, options || {});
  50313. var opt = this.options; // Force window size for `raw` data, if not set directly,
  50314. // because we have no header for autodetect.
  50315. if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
  50316. opt.windowBits = -opt.windowBits;
  50317. if (opt.windowBits === 0) {
  50318. opt.windowBits = -15;
  50319. }
  50320. } // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
  50321. if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
  50322. opt.windowBits += 32;
  50323. } // Gzip header has no info about windows size, we can do autodetect only
  50324. // for deflate. So, if window size not set, force it to max when gzip possible
  50325. if (opt.windowBits > 15 && opt.windowBits < 48) {
  50326. // bit 3 (16) -> gzipped data
  50327. // bit 4 (32) -> autodetect gzip/deflate
  50328. if ((opt.windowBits & 15) === 0) {
  50329. opt.windowBits |= 15;
  50330. }
  50331. }
  50332. this.err = 0; // error code, if happens (0 = Z_OK)
  50333. this.msg = ''; // error message
  50334. this.ended = false; // used to avoid multiple onEnd() calls
  50335. this.chunks = []; // chunks of compressed data
  50336. this.strm = new ZStream();
  50337. this.strm.avail_out = 0;
  50338. var status = zlib_inflate.inflateInit2(this.strm, opt.windowBits);
  50339. if (status !== c.Z_OK) {
  50340. throw new Error(msg[status]);
  50341. }
  50342. this.header = new GZheader();
  50343. zlib_inflate.inflateGetHeader(this.strm, this.header); // Setup dictionary
  50344. if (opt.dictionary) {
  50345. // Convert data if needed
  50346. if (typeof opt.dictionary === 'string') {
  50347. opt.dictionary = strings.string2buf(opt.dictionary);
  50348. } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
  50349. opt.dictionary = new Uint8Array(opt.dictionary);
  50350. }
  50351. if (opt.raw) {
  50352. //In raw mode we need to set the dictionary early
  50353. status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);
  50354. if (status !== c.Z_OK) {
  50355. throw new Error(msg[status]);
  50356. }
  50357. }
  50358. }
  50359. }
  50360. /**
  50361. * Inflate#push(data[, mode]) -> Boolean
  50362. * - data (Uint8Array|Array|ArrayBuffer|String): input data
  50363. * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
  50364. * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.
  50365. *
  50366. * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with
  50367. * new output chunks. Returns `true` on success. The last data block must have
  50368. * mode Z_FINISH (or `true`). That will flush internal pending buffers and call
  50369. * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you
  50370. * can use mode Z_SYNC_FLUSH, keeping the decompression context.
  50371. *
  50372. * On fail call [[Inflate#onEnd]] with error code and return false.
  50373. *
  50374. * We strongly recommend to use `Uint8Array` on input for best speed (output
  50375. * format is detected automatically). Also, don't skip last param and always
  50376. * use the same type in your code (boolean or number). That will improve JS speed.
  50377. *
  50378. * For regular `Array`-s make sure all elements are [0..255].
  50379. *
  50380. * ##### Example
  50381. *
  50382. * ```javascript
  50383. * push(chunk, false); // push one of data chunks
  50384. * ...
  50385. * push(chunk, true); // push last chunk
  50386. * ```
  50387. **/
  50388. Inflate.prototype.push = function (data, mode) {
  50389. var strm = this.strm;
  50390. var chunkSize = this.options.chunkSize;
  50391. var dictionary = this.options.dictionary;
  50392. var status, _mode;
  50393. var next_out_utf8, tail, utf8str; // Flag to properly process Z_BUF_ERROR on testing inflate call
  50394. // when we check that all output data was flushed.
  50395. var allowBufError = false;
  50396. if (this.ended) {
  50397. return false;
  50398. }
  50399. _mode = mode === ~~mode ? mode : mode === true ? c.Z_FINISH : c.Z_NO_FLUSH; // Convert data if needed
  50400. if (typeof data === 'string') {
  50401. // Only binary strings can be decompressed on practice
  50402. strm.input = strings.binstring2buf(data);
  50403. } else if (toString.call(data) === '[object ArrayBuffer]') {
  50404. strm.input = new Uint8Array(data);
  50405. } else {
  50406. strm.input = data;
  50407. }
  50408. strm.next_in = 0;
  50409. strm.avail_in = strm.input.length;
  50410. do {
  50411. if (strm.avail_out === 0) {
  50412. strm.output = new utils.Buf8(chunkSize);
  50413. strm.next_out = 0;
  50414. strm.avail_out = chunkSize;
  50415. }
  50416. status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH);
  50417. /* no bad return value */
  50418. if (status === c.Z_NEED_DICT && dictionary) {
  50419. status = zlib_inflate.inflateSetDictionary(this.strm, dictionary);
  50420. }
  50421. if (status === c.Z_BUF_ERROR && allowBufError === true) {
  50422. status = c.Z_OK;
  50423. allowBufError = false;
  50424. }
  50425. if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
  50426. this.onEnd(status);
  50427. this.ended = true;
  50428. return false;
  50429. }
  50430. if (strm.next_out) {
  50431. if (strm.avail_out === 0 || status === c.Z_STREAM_END || strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH)) {
  50432. if (this.options.to === 'string') {
  50433. next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
  50434. tail = strm.next_out - next_out_utf8;
  50435. utf8str = strings.buf2string(strm.output, next_out_utf8); // move tail
  50436. strm.next_out = tail;
  50437. strm.avail_out = chunkSize - tail;
  50438. if (tail) {
  50439. utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0);
  50440. }
  50441. this.onData(utf8str);
  50442. } else {
  50443. this.onData(utils.shrinkBuf(strm.output, strm.next_out));
  50444. }
  50445. }
  50446. } // When no more input data, we should check that internal inflate buffers
  50447. // are flushed. The only way to do it when avail_out = 0 - run one more
  50448. // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.
  50449. // Here we set flag to process this error properly.
  50450. //
  50451. // NOTE. Deflate does not return error in this case and does not needs such
  50452. // logic.
  50453. if (strm.avail_in === 0 && strm.avail_out === 0) {
  50454. allowBufError = true;
  50455. }
  50456. } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
  50457. if (status === c.Z_STREAM_END) {
  50458. _mode = c.Z_FINISH;
  50459. } // Finalize on the last chunk.
  50460. if (_mode === c.Z_FINISH) {
  50461. status = zlib_inflate.inflateEnd(this.strm);
  50462. this.onEnd(status);
  50463. this.ended = true;
  50464. return status === c.Z_OK;
  50465. } // callback interim results if Z_SYNC_FLUSH.
  50466. if (_mode === c.Z_SYNC_FLUSH) {
  50467. this.onEnd(c.Z_OK);
  50468. strm.avail_out = 0;
  50469. return true;
  50470. }
  50471. return true;
  50472. };
  50473. /**
  50474. * Inflate#onData(chunk) -> Void
  50475. * - chunk (Uint8Array|Array|String): output data. Type of array depends
  50476. * on js engine support. When string output requested, each chunk
  50477. * will be string.
  50478. *
  50479. * By default, stores data blocks in `chunks[]` property and glue
  50480. * those in `onEnd`. Override this handler, if you need another behaviour.
  50481. **/
  50482. Inflate.prototype.onData = function (chunk) {
  50483. this.chunks.push(chunk);
  50484. };
  50485. /**
  50486. * Inflate#onEnd(status) -> Void
  50487. * - status (Number): inflate status. 0 (Z_OK) on success,
  50488. * other if not.
  50489. *
  50490. * Called either after you tell inflate that the input stream is
  50491. * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
  50492. * or if an error happened. By default - join collected chunks,
  50493. * free memory and fill `results` / `err` properties.
  50494. **/
  50495. Inflate.prototype.onEnd = function (status) {
  50496. // On success - join
  50497. if (status === c.Z_OK) {
  50498. if (this.options.to === 'string') {
  50499. // Glue & convert here, until we teach pako to send
  50500. // utf8 aligned strings to onData
  50501. this.result = this.chunks.join('');
  50502. } else {
  50503. this.result = utils.flattenChunks(this.chunks);
  50504. }
  50505. }
  50506. this.chunks = [];
  50507. this.err = status;
  50508. this.msg = this.strm.msg;
  50509. };
  50510. /**
  50511. * inflate(data[, options]) -> Uint8Array|Array|String
  50512. * - data (Uint8Array|Array|String): input data to decompress.
  50513. * - options (Object): zlib inflate options.
  50514. *
  50515. * Decompress `data` with inflate/ungzip and `options`. Autodetect
  50516. * format via wrapper header by default. That's why we don't provide
  50517. * separate `ungzip` method.
  50518. *
  50519. * Supported options are:
  50520. *
  50521. * - windowBits
  50522. *
  50523. * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
  50524. * for more information.
  50525. *
  50526. * Sugar (options):
  50527. *
  50528. * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
  50529. * negative windowBits implicitly.
  50530. * - `to` (String) - if equal to 'string', then result will be converted
  50531. * from utf8 to utf16 (javascript) string. When string output requested,
  50532. * chunk length can differ from `chunkSize`, depending on content.
  50533. *
  50534. *
  50535. * ##### Example:
  50536. *
  50537. * ```javascript
  50538. * var pako = require('pako')
  50539. * , input = pako.deflate([1,2,3,4,5,6,7,8,9])
  50540. * , output;
  50541. *
  50542. * try {
  50543. * output = pako.inflate(input);
  50544. * } catch (err)
  50545. * console.log(err);
  50546. * }
  50547. * ```
  50548. **/
  50549. function inflate(input, options) {
  50550. var inflator = new Inflate(options);
  50551. inflator.push(input, true); // That will never happens, if you don't cheat with options :)
  50552. if (inflator.err) {
  50553. throw inflator.msg || msg[inflator.err];
  50554. }
  50555. return inflator.result;
  50556. }
  50557. /**
  50558. * inflateRaw(data[, options]) -> Uint8Array|Array|String
  50559. * - data (Uint8Array|Array|String): input data to decompress.
  50560. * - options (Object): zlib inflate options.
  50561. *
  50562. * The same as [[inflate]], but creates raw data, without wrapper
  50563. * (header and adler32 crc).
  50564. **/
  50565. function inflateRaw(input, options) {
  50566. options = options || {};
  50567. options.raw = true;
  50568. return inflate(input, options);
  50569. }
  50570. /**
  50571. * ungzip(data[, options]) -> Uint8Array|Array|String
  50572. * - data (Uint8Array|Array|String): input data to decompress.
  50573. * - options (Object): zlib inflate options.
  50574. *
  50575. * Just shortcut to [[inflate]], because it autodetects format
  50576. * by header.content. Done for convenience.
  50577. **/
  50578. exports.Inflate = Inflate;
  50579. exports.inflate = inflate;
  50580. exports.inflateRaw = inflateRaw;
  50581. exports.ungzip = inflate;
  50582. }, { "./utils/common": 442, "./utils/strings": 443, "./zlib/constants": 445, "./zlib/gzheader": 448, "./zlib/inflate": 450, "./zlib/messages": 452, "./zlib/zstream": 454 }], 442: [function (require, module, exports) {
  50583. 'use strict';
  50584. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  50585. var TYPED_OK = typeof Uint8Array !== 'undefined' && typeof Uint16Array !== 'undefined' && typeof Int32Array !== 'undefined';
  50586. function _has(obj, key) {
  50587. return Object.prototype.hasOwnProperty.call(obj, key);
  50588. }
  50589. exports.assign = function (obj
  50590. /*from1, from2, from3, ...*/
  50591. ) {
  50592. var sources = Array.prototype.slice.call(arguments, 1);
  50593. while (sources.length) {
  50594. var source = sources.shift();
  50595. if (!source) {
  50596. continue;
  50597. }
  50598. if (_typeof(source) !== 'object') {
  50599. throw new TypeError(source + 'must be non-object');
  50600. }
  50601. for (var p in source) {
  50602. if (_has(source, p)) {
  50603. obj[p] = source[p];
  50604. }
  50605. }
  50606. }
  50607. return obj;
  50608. }; // reduce buffer size, avoiding mem copy
  50609. exports.shrinkBuf = function (buf, size) {
  50610. if (buf.length === size) {
  50611. return buf;
  50612. }
  50613. if (buf.subarray) {
  50614. return buf.subarray(0, size);
  50615. }
  50616. buf.length = size;
  50617. return buf;
  50618. };
  50619. var fnTyped = {
  50620. arraySet: function arraySet(dest, src, src_offs, len, dest_offs) {
  50621. if (src.subarray && dest.subarray) {
  50622. dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
  50623. return;
  50624. } // Fallback to ordinary array
  50625. for (var i = 0; i < len; i++) {
  50626. dest[dest_offs + i] = src[src_offs + i];
  50627. }
  50628. },
  50629. // Join array of chunks to single array.
  50630. flattenChunks: function flattenChunks(chunks) {
  50631. var i, l, len, pos, chunk, result; // calculate data length
  50632. len = 0;
  50633. for (i = 0, l = chunks.length; i < l; i++) {
  50634. len += chunks[i].length;
  50635. } // join chunks
  50636. result = new Uint8Array(len);
  50637. pos = 0;
  50638. for (i = 0, l = chunks.length; i < l; i++) {
  50639. chunk = chunks[i];
  50640. result.set(chunk, pos);
  50641. pos += chunk.length;
  50642. }
  50643. return result;
  50644. }
  50645. };
  50646. var fnUntyped = {
  50647. arraySet: function arraySet(dest, src, src_offs, len, dest_offs) {
  50648. for (var i = 0; i < len; i++) {
  50649. dest[dest_offs + i] = src[src_offs + i];
  50650. }
  50651. },
  50652. // Join array of chunks to single array.
  50653. flattenChunks: function flattenChunks(chunks) {
  50654. return [].concat.apply([], chunks);
  50655. }
  50656. }; // Enable/Disable typed arrays use, for testing
  50657. //
  50658. exports.setTyped = function (on) {
  50659. if (on) {
  50660. exports.Buf8 = Uint8Array;
  50661. exports.Buf16 = Uint16Array;
  50662. exports.Buf32 = Int32Array;
  50663. exports.assign(exports, fnTyped);
  50664. } else {
  50665. exports.Buf8 = Array;
  50666. exports.Buf16 = Array;
  50667. exports.Buf32 = Array;
  50668. exports.assign(exports, fnUntyped);
  50669. }
  50670. };
  50671. exports.setTyped(TYPED_OK);
  50672. }, {}], 443: [function (require, module, exports) {
  50673. // String encode/decode helpers
  50674. 'use strict';
  50675. var utils = require('./common'); // Quick check if we can use fast array to bin string conversion
  50676. //
  50677. // - apply(Array) can fail on Android 2.2
  50678. // - apply(Uint8Array) can fail on iOS 5.1 Safari
  50679. //
  50680. var STR_APPLY_OK = true;
  50681. var STR_APPLY_UIA_OK = true;
  50682. try {
  50683. String.fromCharCode.apply(null, [0]);
  50684. } catch (__) {
  50685. STR_APPLY_OK = false;
  50686. }
  50687. try {
  50688. String.fromCharCode.apply(null, new Uint8Array(1));
  50689. } catch (__) {
  50690. STR_APPLY_UIA_OK = false;
  50691. } // Table with utf8 lengths (calculated by first byte of sequence)
  50692. // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
  50693. // because max possible codepoint is 0x10ffff
  50694. var _utf8len = new utils.Buf8(256);
  50695. for (var q = 0; q < 256; q++) {
  50696. _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;
  50697. }
  50698. _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
  50699. // convert string to array (typed, when possible)
  50700. exports.string2buf = function (str) {
  50701. var buf,
  50702. c,
  50703. c2,
  50704. m_pos,
  50705. i,
  50706. str_len = str.length,
  50707. buf_len = 0; // count binary size
  50708. for (m_pos = 0; m_pos < str_len; m_pos++) {
  50709. c = str.charCodeAt(m_pos);
  50710. if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {
  50711. c2 = str.charCodeAt(m_pos + 1);
  50712. if ((c2 & 0xfc00) === 0xdc00) {
  50713. c = 0x10000 + (c - 0xd800 << 10) + (c2 - 0xdc00);
  50714. m_pos++;
  50715. }
  50716. }
  50717. buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
  50718. } // allocate buffer
  50719. buf = new utils.Buf8(buf_len); // convert
  50720. for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
  50721. c = str.charCodeAt(m_pos);
  50722. if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {
  50723. c2 = str.charCodeAt(m_pos + 1);
  50724. if ((c2 & 0xfc00) === 0xdc00) {
  50725. c = 0x10000 + (c - 0xd800 << 10) + (c2 - 0xdc00);
  50726. m_pos++;
  50727. }
  50728. }
  50729. if (c < 0x80) {
  50730. /* one byte */
  50731. buf[i++] = c;
  50732. } else if (c < 0x800) {
  50733. /* two bytes */
  50734. buf[i++] = 0xC0 | c >>> 6;
  50735. buf[i++] = 0x80 | c & 0x3f;
  50736. } else if (c < 0x10000) {
  50737. /* three bytes */
  50738. buf[i++] = 0xE0 | c >>> 12;
  50739. buf[i++] = 0x80 | c >>> 6 & 0x3f;
  50740. buf[i++] = 0x80 | c & 0x3f;
  50741. } else {
  50742. /* four bytes */
  50743. buf[i++] = 0xf0 | c >>> 18;
  50744. buf[i++] = 0x80 | c >>> 12 & 0x3f;
  50745. buf[i++] = 0x80 | c >>> 6 & 0x3f;
  50746. buf[i++] = 0x80 | c & 0x3f;
  50747. }
  50748. }
  50749. return buf;
  50750. }; // Helper (used in 2 places)
  50751. function buf2binstring(buf, len) {
  50752. // On Chrome, the arguments in a function call that are allowed is `65534`.
  50753. // If the length of the buffer is smaller than that, we can use this optimization,
  50754. // otherwise we will take a slower path.
  50755. if (len < 65534) {
  50756. if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) {
  50757. return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));
  50758. }
  50759. }
  50760. var result = '';
  50761. for (var i = 0; i < len; i++) {
  50762. result += String.fromCharCode(buf[i]);
  50763. }
  50764. return result;
  50765. } // Convert byte array to binary string
  50766. exports.buf2binstring = function (buf) {
  50767. return buf2binstring(buf, buf.length);
  50768. }; // Convert binary string (typed, when possible)
  50769. exports.binstring2buf = function (str) {
  50770. var buf = new utils.Buf8(str.length);
  50771. for (var i = 0, len = buf.length; i < len; i++) {
  50772. buf[i] = str.charCodeAt(i);
  50773. }
  50774. return buf;
  50775. }; // convert array to string
  50776. exports.buf2string = function (buf, max) {
  50777. var i, out, c, c_len;
  50778. var len = max || buf.length; // Reserve max possible length (2 words per char)
  50779. // NB: by unknown reasons, Array is significantly faster for
  50780. // String.fromCharCode.apply than Uint16Array.
  50781. var utf16buf = new Array(len * 2);
  50782. for (out = 0, i = 0; i < len;) {
  50783. c = buf[i++]; // quick process ascii
  50784. if (c < 0x80) {
  50785. utf16buf[out++] = c;
  50786. continue;
  50787. }
  50788. c_len = _utf8len[c]; // skip 5 & 6 byte codes
  50789. if (c_len > 4) {
  50790. utf16buf[out++] = 0xfffd;
  50791. i += c_len - 1;
  50792. continue;
  50793. } // apply mask on first byte
  50794. c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; // join the rest
  50795. while (c_len > 1 && i < len) {
  50796. c = c << 6 | buf[i++] & 0x3f;
  50797. c_len--;
  50798. } // terminated by end of string?
  50799. if (c_len > 1) {
  50800. utf16buf[out++] = 0xfffd;
  50801. continue;
  50802. }
  50803. if (c < 0x10000) {
  50804. utf16buf[out++] = c;
  50805. } else {
  50806. c -= 0x10000;
  50807. utf16buf[out++] = 0xd800 | c >> 10 & 0x3ff;
  50808. utf16buf[out++] = 0xdc00 | c & 0x3ff;
  50809. }
  50810. }
  50811. return buf2binstring(utf16buf, out);
  50812. }; // Calculate max possible position in utf8 buffer,
  50813. // that will not break sequence. If that's not possible
  50814. // - (very small limits) return max size as is.
  50815. //
  50816. // buf[] - utf8 bytes array
  50817. // max - length limit (mandatory);
  50818. exports.utf8border = function (buf, max) {
  50819. var pos;
  50820. max = max || buf.length;
  50821. if (max > buf.length) {
  50822. max = buf.length;
  50823. } // go back from last position, until start of sequence found
  50824. pos = max - 1;
  50825. while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) {
  50826. pos--;
  50827. } // Very small and broken sequence,
  50828. // return max, because we should return something anyway.
  50829. if (pos < 0) {
  50830. return max;
  50831. } // If we came to start of buffer - that means buffer is too small,
  50832. // return max too.
  50833. if (pos === 0) {
  50834. return max;
  50835. }
  50836. return pos + _utf8len[buf[pos]] > max ? pos : max;
  50837. };
  50838. }, { "./common": 442 }], 444: [function (require, module, exports) {
  50839. 'use strict'; // Note: adler32 takes 12% for level 0 and 2% for level 6.
  50840. // It isn't worth it to make additional optimizations as in original.
  50841. // Small size is preferable.
  50842. // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  50843. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  50844. //
  50845. // This software is provided 'as-is', without any express or implied
  50846. // warranty. In no event will the authors be held liable for any damages
  50847. // arising from the use of this software.
  50848. //
  50849. // Permission is granted to anyone to use this software for any purpose,
  50850. // including commercial applications, and to alter it and redistribute it
  50851. // freely, subject to the following restrictions:
  50852. //
  50853. // 1. The origin of this software must not be misrepresented; you must not
  50854. // claim that you wrote the original software. If you use this software
  50855. // in a product, an acknowledgment in the product documentation would be
  50856. // appreciated but is not required.
  50857. // 2. Altered source versions must be plainly marked as such, and must not be
  50858. // misrepresented as being the original software.
  50859. // 3. This notice may not be removed or altered from any source distribution.
  50860. function adler32(adler, buf, len, pos) {
  50861. var s1 = adler & 0xffff | 0,
  50862. s2 = adler >>> 16 & 0xffff | 0,
  50863. n = 0;
  50864. while (len !== 0) {
  50865. // Set limit ~ twice less than 5552, to keep
  50866. // s2 in 31-bits, because we force signed ints.
  50867. // in other case %= will fail.
  50868. n = len > 2000 ? 2000 : len;
  50869. len -= n;
  50870. do {
  50871. s1 = s1 + buf[pos++] | 0;
  50872. s2 = s2 + s1 | 0;
  50873. } while (--n);
  50874. s1 %= 65521;
  50875. s2 %= 65521;
  50876. }
  50877. return s1 | s2 << 16 | 0;
  50878. }
  50879. module.exports = adler32;
  50880. }, {}], 445: [function (require, module, exports) {
  50881. 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  50882. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  50883. //
  50884. // This software is provided 'as-is', without any express or implied
  50885. // warranty. In no event will the authors be held liable for any damages
  50886. // arising from the use of this software.
  50887. //
  50888. // Permission is granted to anyone to use this software for any purpose,
  50889. // including commercial applications, and to alter it and redistribute it
  50890. // freely, subject to the following restrictions:
  50891. //
  50892. // 1. The origin of this software must not be misrepresented; you must not
  50893. // claim that you wrote the original software. If you use this software
  50894. // in a product, an acknowledgment in the product documentation would be
  50895. // appreciated but is not required.
  50896. // 2. Altered source versions must be plainly marked as such, and must not be
  50897. // misrepresented as being the original software.
  50898. // 3. This notice may not be removed or altered from any source distribution.
  50899. module.exports = {
  50900. /* Allowed flush values; see deflate() and inflate() below for details */
  50901. Z_NO_FLUSH: 0,
  50902. Z_PARTIAL_FLUSH: 1,
  50903. Z_SYNC_FLUSH: 2,
  50904. Z_FULL_FLUSH: 3,
  50905. Z_FINISH: 4,
  50906. Z_BLOCK: 5,
  50907. Z_TREES: 6,
  50908. /* Return codes for the compression/decompression functions. Negative values
  50909. * are errors, positive values are used for special but normal events.
  50910. */
  50911. Z_OK: 0,
  50912. Z_STREAM_END: 1,
  50913. Z_NEED_DICT: 2,
  50914. Z_ERRNO: -1,
  50915. Z_STREAM_ERROR: -2,
  50916. Z_DATA_ERROR: -3,
  50917. //Z_MEM_ERROR: -4,
  50918. Z_BUF_ERROR: -5,
  50919. //Z_VERSION_ERROR: -6,
  50920. /* compression levels */
  50921. Z_NO_COMPRESSION: 0,
  50922. Z_BEST_SPEED: 1,
  50923. Z_BEST_COMPRESSION: 9,
  50924. Z_DEFAULT_COMPRESSION: -1,
  50925. Z_FILTERED: 1,
  50926. Z_HUFFMAN_ONLY: 2,
  50927. Z_RLE: 3,
  50928. Z_FIXED: 4,
  50929. Z_DEFAULT_STRATEGY: 0,
  50930. /* Possible values of the data_type field (though see inflate()) */
  50931. Z_BINARY: 0,
  50932. Z_TEXT: 1,
  50933. //Z_ASCII: 1, // = Z_TEXT (deprecated)
  50934. Z_UNKNOWN: 2,
  50935. /* The deflate compression method */
  50936. Z_DEFLATED: 8 //Z_NULL: null // Use -1 or null inline, depending on var type
  50937. };
  50938. }, {}], 446: [function (require, module, exports) {
  50939. 'use strict'; // Note: we can't get significant speed boost here.
  50940. // So write code to minimize size - no pregenerated tables
  50941. // and array tools dependencies.
  50942. // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  50943. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  50944. //
  50945. // This software is provided 'as-is', without any express or implied
  50946. // warranty. In no event will the authors be held liable for any damages
  50947. // arising from the use of this software.
  50948. //
  50949. // Permission is granted to anyone to use this software for any purpose,
  50950. // including commercial applications, and to alter it and redistribute it
  50951. // freely, subject to the following restrictions:
  50952. //
  50953. // 1. The origin of this software must not be misrepresented; you must not
  50954. // claim that you wrote the original software. If you use this software
  50955. // in a product, an acknowledgment in the product documentation would be
  50956. // appreciated but is not required.
  50957. // 2. Altered source versions must be plainly marked as such, and must not be
  50958. // misrepresented as being the original software.
  50959. // 3. This notice may not be removed or altered from any source distribution.
  50960. // Use ordinary array, since untyped makes no boost here
  50961. function makeTable() {
  50962. var c,
  50963. table = [];
  50964. for (var n = 0; n < 256; n++) {
  50965. c = n;
  50966. for (var k = 0; k < 8; k++) {
  50967. c = c & 1 ? 0xEDB88320 ^ c >>> 1 : c >>> 1;
  50968. }
  50969. table[n] = c;
  50970. }
  50971. return table;
  50972. } // Create table on load. Just 255 signed longs. Not a problem.
  50973. var crcTable = makeTable();
  50974. function crc32(crc, buf, len, pos) {
  50975. var t = crcTable,
  50976. end = pos + len;
  50977. crc ^= -1;
  50978. for (var i = pos; i < end; i++) {
  50979. crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 0xFF];
  50980. }
  50981. return crc ^ -1; // >>> 0;
  50982. }
  50983. module.exports = crc32;
  50984. }, {}], 447: [function (require, module, exports) {
  50985. 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  50986. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  50987. //
  50988. // This software is provided 'as-is', without any express or implied
  50989. // warranty. In no event will the authors be held liable for any damages
  50990. // arising from the use of this software.
  50991. //
  50992. // Permission is granted to anyone to use this software for any purpose,
  50993. // including commercial applications, and to alter it and redistribute it
  50994. // freely, subject to the following restrictions:
  50995. //
  50996. // 1. The origin of this software must not be misrepresented; you must not
  50997. // claim that you wrote the original software. If you use this software
  50998. // in a product, an acknowledgment in the product documentation would be
  50999. // appreciated but is not required.
  51000. // 2. Altered source versions must be plainly marked as such, and must not be
  51001. // misrepresented as being the original software.
  51002. // 3. This notice may not be removed or altered from any source distribution.
  51003. var utils = require('../utils/common');
  51004. var trees = require('./trees');
  51005. var adler32 = require('./adler32');
  51006. var crc32 = require('./crc32');
  51007. var msg = require('./messages');
  51008. /* Public constants ==========================================================*/
  51009. /* ===========================================================================*/
  51010. /* Allowed flush values; see deflate() and inflate() below for details */
  51011. var Z_NO_FLUSH = 0;
  51012. var Z_PARTIAL_FLUSH = 1; //var Z_SYNC_FLUSH = 2;
  51013. var Z_FULL_FLUSH = 3;
  51014. var Z_FINISH = 4;
  51015. var Z_BLOCK = 5; //var Z_TREES = 6;
  51016. /* Return codes for the compression/decompression functions. Negative values
  51017. * are errors, positive values are used for special but normal events.
  51018. */
  51019. var Z_OK = 0;
  51020. var Z_STREAM_END = 1; //var Z_NEED_DICT = 2;
  51021. //var Z_ERRNO = -1;
  51022. var Z_STREAM_ERROR = -2;
  51023. var Z_DATA_ERROR = -3; //var Z_MEM_ERROR = -4;
  51024. var Z_BUF_ERROR = -5; //var Z_VERSION_ERROR = -6;
  51025. /* compression levels */
  51026. //var Z_NO_COMPRESSION = 0;
  51027. //var Z_BEST_SPEED = 1;
  51028. //var Z_BEST_COMPRESSION = 9;
  51029. var Z_DEFAULT_COMPRESSION = -1;
  51030. var Z_FILTERED = 1;
  51031. var Z_HUFFMAN_ONLY = 2;
  51032. var Z_RLE = 3;
  51033. var Z_FIXED = 4;
  51034. var Z_DEFAULT_STRATEGY = 0;
  51035. /* Possible values of the data_type field (though see inflate()) */
  51036. //var Z_BINARY = 0;
  51037. //var Z_TEXT = 1;
  51038. //var Z_ASCII = 1; // = Z_TEXT
  51039. var Z_UNKNOWN = 2;
  51040. /* The deflate compression method */
  51041. var Z_DEFLATED = 8;
  51042. /*============================================================================*/
  51043. var MAX_MEM_LEVEL = 9;
  51044. /* Maximum value for memLevel in deflateInit2 */
  51045. var MAX_WBITS = 15;
  51046. /* 32K LZ77 window */
  51047. var DEF_MEM_LEVEL = 8;
  51048. var LENGTH_CODES = 29;
  51049. /* number of length codes, not counting the special END_BLOCK code */
  51050. var LITERALS = 256;
  51051. /* number of literal bytes 0..255 */
  51052. var L_CODES = LITERALS + 1 + LENGTH_CODES;
  51053. /* number of Literal or Length codes, including the END_BLOCK code */
  51054. var D_CODES = 30;
  51055. /* number of distance codes */
  51056. var BL_CODES = 19;
  51057. /* number of codes used to transfer the bit lengths */
  51058. var HEAP_SIZE = 2 * L_CODES + 1;
  51059. /* maximum heap size */
  51060. var MAX_BITS = 15;
  51061. /* All codes must not exceed MAX_BITS bits */
  51062. var MIN_MATCH = 3;
  51063. var MAX_MATCH = 258;
  51064. var MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;
  51065. var PRESET_DICT = 0x20;
  51066. var INIT_STATE = 42;
  51067. var EXTRA_STATE = 69;
  51068. var NAME_STATE = 73;
  51069. var COMMENT_STATE = 91;
  51070. var HCRC_STATE = 103;
  51071. var BUSY_STATE = 113;
  51072. var FINISH_STATE = 666;
  51073. var BS_NEED_MORE = 1;
  51074. /* block not completed, need more input or more output */
  51075. var BS_BLOCK_DONE = 2;
  51076. /* block flush performed */
  51077. var BS_FINISH_STARTED = 3;
  51078. /* finish started, need only more output at next deflate */
  51079. var BS_FINISH_DONE = 4;
  51080. /* finish done, accept no more input or output */
  51081. var OS_CODE = 0x03; // Unix :) . Don't detect, use this default.
  51082. function err(strm, errorCode) {
  51083. strm.msg = msg[errorCode];
  51084. return errorCode;
  51085. }
  51086. function rank(f) {
  51087. return (f << 1) - (f > 4 ? 9 : 0);
  51088. }
  51089. function zero(buf) {
  51090. var len = buf.length;
  51091. while (--len >= 0) {
  51092. buf[len] = 0;
  51093. }
  51094. }
  51095. /* =========================================================================
  51096. * Flush as much pending output as possible. All deflate() output goes
  51097. * through this function so some applications may wish to modify it
  51098. * to avoid allocating a large strm->output buffer and copying into it.
  51099. * (See also read_buf()).
  51100. */
  51101. function flush_pending(strm) {
  51102. var s = strm.state; //_tr_flush_bits(s);
  51103. var len = s.pending;
  51104. if (len > strm.avail_out) {
  51105. len = strm.avail_out;
  51106. }
  51107. if (len === 0) {
  51108. return;
  51109. }
  51110. utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);
  51111. strm.next_out += len;
  51112. s.pending_out += len;
  51113. strm.total_out += len;
  51114. strm.avail_out -= len;
  51115. s.pending -= len;
  51116. if (s.pending === 0) {
  51117. s.pending_out = 0;
  51118. }
  51119. }
  51120. function flush_block_only(s, last) {
  51121. trees._tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);
  51122. s.block_start = s.strstart;
  51123. flush_pending(s.strm);
  51124. }
  51125. function put_byte(s, b) {
  51126. s.pending_buf[s.pending++] = b;
  51127. }
  51128. /* =========================================================================
  51129. * Put a short in the pending buffer. The 16-bit value is put in MSB order.
  51130. * IN assertion: the stream state is correct and there is enough room in
  51131. * pending_buf.
  51132. */
  51133. function putShortMSB(s, b) {
  51134. // put_byte(s, (Byte)(b >> 8));
  51135. // put_byte(s, (Byte)(b & 0xff));
  51136. s.pending_buf[s.pending++] = b >>> 8 & 0xff;
  51137. s.pending_buf[s.pending++] = b & 0xff;
  51138. }
  51139. /* ===========================================================================
  51140. * Read a new buffer from the current input stream, update the adler32
  51141. * and total number of bytes read. All deflate() input goes through
  51142. * this function so some applications may wish to modify it to avoid
  51143. * allocating a large strm->input buffer and copying from it.
  51144. * (See also flush_pending()).
  51145. */
  51146. function read_buf(strm, buf, start, size) {
  51147. var len = strm.avail_in;
  51148. if (len > size) {
  51149. len = size;
  51150. }
  51151. if (len === 0) {
  51152. return 0;
  51153. }
  51154. strm.avail_in -= len; // zmemcpy(buf, strm->next_in, len);
  51155. utils.arraySet(buf, strm.input, strm.next_in, len, start);
  51156. if (strm.state.wrap === 1) {
  51157. strm.adler = adler32(strm.adler, buf, len, start);
  51158. } else if (strm.state.wrap === 2) {
  51159. strm.adler = crc32(strm.adler, buf, len, start);
  51160. }
  51161. strm.next_in += len;
  51162. strm.total_in += len;
  51163. return len;
  51164. }
  51165. /* ===========================================================================
  51166. * Set match_start to the longest match starting at the given string and
  51167. * return its length. Matches shorter or equal to prev_length are discarded,
  51168. * in which case the result is equal to prev_length and match_start is
  51169. * garbage.
  51170. * IN assertions: cur_match is the head of the hash chain for the current
  51171. * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
  51172. * OUT assertion: the match length is not greater than s->lookahead.
  51173. */
  51174. function longest_match(s, cur_match) {
  51175. var chain_length = s.max_chain_length;
  51176. /* max hash chain length */
  51177. var scan = s.strstart;
  51178. /* current string */
  51179. var match;
  51180. /* matched string */
  51181. var len;
  51182. /* length of current match */
  51183. var best_len = s.prev_length;
  51184. /* best match length so far */
  51185. var nice_match = s.nice_match;
  51186. /* stop if match long enough */
  51187. var limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0
  51188. /*NIL*/
  51189. ;
  51190. var _win = s.window; // shortcut
  51191. var wmask = s.w_mask;
  51192. var prev = s.prev;
  51193. /* Stop when cur_match becomes <= limit. To simplify the code,
  51194. * we prevent matches with the string of window index 0.
  51195. */
  51196. var strend = s.strstart + MAX_MATCH;
  51197. var scan_end1 = _win[scan + best_len - 1];
  51198. var scan_end = _win[scan + best_len];
  51199. /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
  51200. * It is easy to get rid of this optimization if necessary.
  51201. */
  51202. // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
  51203. /* Do not waste too much time if we already have a good match: */
  51204. if (s.prev_length >= s.good_match) {
  51205. chain_length >>= 2;
  51206. }
  51207. /* Do not look for matches beyond the end of the input. This is necessary
  51208. * to make deflate deterministic.
  51209. */
  51210. if (nice_match > s.lookahead) {
  51211. nice_match = s.lookahead;
  51212. } // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
  51213. do {
  51214. // Assert(cur_match < s->strstart, "no future");
  51215. match = cur_match;
  51216. /* Skip to next match if the match length cannot increase
  51217. * or if the match length is less than 2. Note that the checks below
  51218. * for insufficient lookahead only occur occasionally for performance
  51219. * reasons. Therefore uninitialized memory will be accessed, and
  51220. * conditional jumps will be made that depend on those values.
  51221. * However the length of the match is limited to the lookahead, so
  51222. * the output of deflate is not affected by the uninitialized values.
  51223. */
  51224. if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {
  51225. continue;
  51226. }
  51227. /* The check at best_len-1 can be removed because it will be made
  51228. * again later. (This heuristic is not always a win.)
  51229. * It is not necessary to compare scan[2] and match[2] since they
  51230. * are always equal when the other bytes match, given that
  51231. * the hash keys are equal and that HASH_BITS >= 8.
  51232. */
  51233. scan += 2;
  51234. match++; // Assert(*scan == *match, "match[2]?");
  51235. /* We check for insufficient lookahead only every 8th comparison;
  51236. * the 256th check will be made at strstart+258.
  51237. */
  51238. do {
  51239. /*jshint noempty:false*/
  51240. } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend); // Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
  51241. len = MAX_MATCH - (strend - scan);
  51242. scan = strend - MAX_MATCH;
  51243. if (len > best_len) {
  51244. s.match_start = cur_match;
  51245. best_len = len;
  51246. if (len >= nice_match) {
  51247. break;
  51248. }
  51249. scan_end1 = _win[scan + best_len - 1];
  51250. scan_end = _win[scan + best_len];
  51251. }
  51252. } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);
  51253. if (best_len <= s.lookahead) {
  51254. return best_len;
  51255. }
  51256. return s.lookahead;
  51257. }
  51258. /* ===========================================================================
  51259. * Fill the window when the lookahead becomes insufficient.
  51260. * Updates strstart and lookahead.
  51261. *
  51262. * IN assertion: lookahead < MIN_LOOKAHEAD
  51263. * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
  51264. * At least one byte has been read, or avail_in == 0; reads are
  51265. * performed for at least two bytes (required for the zip translate_eol
  51266. * option -- not supported here).
  51267. */
  51268. function fill_window(s) {
  51269. var _w_size = s.w_size;
  51270. var p, n, m, more, str; //Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
  51271. do {
  51272. more = s.window_size - s.lookahead - s.strstart; // JS ints have 32 bit, block below not needed
  51273. /* Deal with !@#$% 64K limit: */
  51274. //if (sizeof(int) <= 2) {
  51275. // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
  51276. // more = wsize;
  51277. //
  51278. // } else if (more == (unsigned)(-1)) {
  51279. // /* Very unlikely, but possible on 16 bit machine if
  51280. // * strstart == 0 && lookahead == 1 (input done a byte at time)
  51281. // */
  51282. // more--;
  51283. // }
  51284. //}
  51285. /* If the window is almost full and there is insufficient lookahead,
  51286. * move the upper half to the lower one to make room in the upper half.
  51287. */
  51288. if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
  51289. utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
  51290. s.match_start -= _w_size;
  51291. s.strstart -= _w_size;
  51292. /* we now have strstart >= MAX_DIST */
  51293. s.block_start -= _w_size;
  51294. /* Slide the hash table (could be avoided with 32 bit values
  51295. at the expense of memory usage). We slide even when level == 0
  51296. to keep the hash table consistent if we switch back to level > 0
  51297. later. (Using level 0 permanently is not an optimal usage of
  51298. zlib, so we don't care about this pathological case.)
  51299. */
  51300. n = s.hash_size;
  51301. p = n;
  51302. do {
  51303. m = s.head[--p];
  51304. s.head[p] = m >= _w_size ? m - _w_size : 0;
  51305. } while (--n);
  51306. n = _w_size;
  51307. p = n;
  51308. do {
  51309. m = s.prev[--p];
  51310. s.prev[p] = m >= _w_size ? m - _w_size : 0;
  51311. /* If n is not on any hash chain, prev[n] is garbage but
  51312. * its value will never be used.
  51313. */
  51314. } while (--n);
  51315. more += _w_size;
  51316. }
  51317. if (s.strm.avail_in === 0) {
  51318. break;
  51319. }
  51320. /* If there was no sliding:
  51321. * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
  51322. * more == window_size - lookahead - strstart
  51323. * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
  51324. * => more >= window_size - 2*WSIZE + 2
  51325. * In the BIG_MEM or MMAP case (not yet supported),
  51326. * window_size == input_size + MIN_LOOKAHEAD &&
  51327. * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
  51328. * Otherwise, window_size == 2*WSIZE so more >= 2.
  51329. * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
  51330. */
  51331. //Assert(more >= 2, "more < 2");
  51332. n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
  51333. s.lookahead += n;
  51334. /* Initialize the hash value now that we have some input: */
  51335. if (s.lookahead + s.insert >= MIN_MATCH) {
  51336. str = s.strstart - s.insert;
  51337. s.ins_h = s.window[str];
  51338. /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */
  51339. s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + 1]) & s.hash_mask; //#if MIN_MATCH != 3
  51340. // Call update_hash() MIN_MATCH-3 more times
  51341. //#endif
  51342. while (s.insert) {
  51343. /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
  51344. s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
  51345. s.prev[str & s.w_mask] = s.head[s.ins_h];
  51346. s.head[s.ins_h] = str;
  51347. str++;
  51348. s.insert--;
  51349. if (s.lookahead + s.insert < MIN_MATCH) {
  51350. break;
  51351. }
  51352. }
  51353. }
  51354. /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
  51355. * but this is not important since only literal bytes will be emitted.
  51356. */
  51357. } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
  51358. /* If the WIN_INIT bytes after the end of the current data have never been
  51359. * written, then zero those bytes in order to avoid memory check reports of
  51360. * the use of uninitialized (or uninitialised as Julian writes) bytes by
  51361. * the longest match routines. Update the high water mark for the next
  51362. * time through here. WIN_INIT is set to MAX_MATCH since the longest match
  51363. * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
  51364. */
  51365. // if (s.high_water < s.window_size) {
  51366. // var curr = s.strstart + s.lookahead;
  51367. // var init = 0;
  51368. //
  51369. // if (s.high_water < curr) {
  51370. // /* Previous high water mark below current data -- zero WIN_INIT
  51371. // * bytes or up to end of window, whichever is less.
  51372. // */
  51373. // init = s.window_size - curr;
  51374. // if (init > WIN_INIT)
  51375. // init = WIN_INIT;
  51376. // zmemzero(s->window + curr, (unsigned)init);
  51377. // s->high_water = curr + init;
  51378. // }
  51379. // else if (s->high_water < (ulg)curr + WIN_INIT) {
  51380. // /* High water mark at or above current data, but below current data
  51381. // * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
  51382. // * to end of window, whichever is less.
  51383. // */
  51384. // init = (ulg)curr + WIN_INIT - s->high_water;
  51385. // if (init > s->window_size - s->high_water)
  51386. // init = s->window_size - s->high_water;
  51387. // zmemzero(s->window + s->high_water, (unsigned)init);
  51388. // s->high_water += init;
  51389. // }
  51390. // }
  51391. //
  51392. // Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
  51393. // "not enough room for search");
  51394. }
  51395. /* ===========================================================================
  51396. * Copy without compression as much as possible from the input stream, return
  51397. * the current block state.
  51398. * This function does not insert new strings in the dictionary since
  51399. * uncompressible data is probably not useful. This function is used
  51400. * only for the level=0 compression option.
  51401. * NOTE: this function should be optimized to avoid extra copying from
  51402. * window to pending_buf.
  51403. */
  51404. function deflate_stored(s, flush) {
  51405. /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
  51406. * to pending_buf_size, and each stored block has a 5 byte header:
  51407. */
  51408. var max_block_size = 0xffff;
  51409. if (max_block_size > s.pending_buf_size - 5) {
  51410. max_block_size = s.pending_buf_size - 5;
  51411. }
  51412. /* Copy as much as possible from input to output: */
  51413. for (; ;) {
  51414. /* Fill the window as much as possible: */
  51415. if (s.lookahead <= 1) {
  51416. //Assert(s->strstart < s->w_size+MAX_DIST(s) ||
  51417. // s->block_start >= (long)s->w_size, "slide too late");
  51418. // if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||
  51419. // s.block_start >= s.w_size)) {
  51420. // throw new Error("slide too late");
  51421. // }
  51422. fill_window(s);
  51423. if (s.lookahead === 0 && flush === Z_NO_FLUSH) {
  51424. return BS_NEED_MORE;
  51425. }
  51426. if (s.lookahead === 0) {
  51427. break;
  51428. }
  51429. /* flush the current block */
  51430. } //Assert(s->block_start >= 0L, "block gone");
  51431. // if (s.block_start < 0) throw new Error("block gone");
  51432. s.strstart += s.lookahead;
  51433. s.lookahead = 0;
  51434. /* Emit a stored block if pending_buf will be full: */
  51435. var max_start = s.block_start + max_block_size;
  51436. if (s.strstart === 0 || s.strstart >= max_start) {
  51437. /* strstart == 0 is possible when wraparound on 16-bit machine */
  51438. s.lookahead = s.strstart - max_start;
  51439. s.strstart = max_start;
  51440. /*** FLUSH_BLOCK(s, 0); ***/
  51441. flush_block_only(s, false);
  51442. if (s.strm.avail_out === 0) {
  51443. return BS_NEED_MORE;
  51444. }
  51445. /***/
  51446. }
  51447. /* Flush if we may have to slide, otherwise block_start may become
  51448. * negative and the data will be gone:
  51449. */
  51450. if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) {
  51451. /*** FLUSH_BLOCK(s, 0); ***/
  51452. flush_block_only(s, false);
  51453. if (s.strm.avail_out === 0) {
  51454. return BS_NEED_MORE;
  51455. }
  51456. /***/
  51457. }
  51458. }
  51459. s.insert = 0;
  51460. if (flush === Z_FINISH) {
  51461. /*** FLUSH_BLOCK(s, 1); ***/
  51462. flush_block_only(s, true);
  51463. if (s.strm.avail_out === 0) {
  51464. return BS_FINISH_STARTED;
  51465. }
  51466. /***/
  51467. return BS_FINISH_DONE;
  51468. }
  51469. if (s.strstart > s.block_start) {
  51470. /*** FLUSH_BLOCK(s, 0); ***/
  51471. flush_block_only(s, false);
  51472. if (s.strm.avail_out === 0) {
  51473. return BS_NEED_MORE;
  51474. }
  51475. /***/
  51476. }
  51477. return BS_NEED_MORE;
  51478. }
  51479. /* ===========================================================================
  51480. * Compress as much as possible from the input stream, return the current
  51481. * block state.
  51482. * This function does not perform lazy evaluation of matches and inserts
  51483. * new strings in the dictionary only for unmatched strings or for short
  51484. * matches. It is used only for the fast compression options.
  51485. */
  51486. function deflate_fast(s, flush) {
  51487. var hash_head;
  51488. /* head of the hash chain */
  51489. var bflush;
  51490. /* set if current block must be flushed */
  51491. for (; ;) {
  51492. /* Make sure that we always have enough lookahead, except
  51493. * at the end of the input file. We need MAX_MATCH bytes
  51494. * for the next match, plus MIN_MATCH bytes to insert the
  51495. * string following the next match.
  51496. */
  51497. if (s.lookahead < MIN_LOOKAHEAD) {
  51498. fill_window(s);
  51499. if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
  51500. return BS_NEED_MORE;
  51501. }
  51502. if (s.lookahead === 0) {
  51503. break;
  51504. /* flush the current block */
  51505. }
  51506. }
  51507. /* Insert the string window[strstart .. strstart+2] in the
  51508. * dictionary, and set hash_head to the head of the hash chain:
  51509. */
  51510. hash_head = 0
  51511. /*NIL*/
  51512. ;
  51513. if (s.lookahead >= MIN_MATCH) {
  51514. /*** INSERT_STRING(s, s.strstart, hash_head); ***/
  51515. s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
  51516. hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
  51517. s.head[s.ins_h] = s.strstart;
  51518. /***/
  51519. }
  51520. /* Find the longest match, discarding those <= prev_length.
  51521. * At this point we have always match_length < MIN_MATCH
  51522. */
  51523. if (hash_head !== 0
  51524. /*NIL*/
  51525. && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {
  51526. /* To simplify the code, we prevent matches with the string
  51527. * of window index 0 (in particular we have to avoid a match
  51528. * of the string with itself at the start of the input file).
  51529. */
  51530. s.match_length = longest_match(s, hash_head);
  51531. /* longest_match() sets match_start */
  51532. }
  51533. if (s.match_length >= MIN_MATCH) {
  51534. // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only
  51535. /*** _tr_tally_dist(s, s.strstart - s.match_start,
  51536. s.match_length - MIN_MATCH, bflush); ***/
  51537. bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);
  51538. s.lookahead -= s.match_length;
  51539. /* Insert new strings in the hash table only if the match length
  51540. * is not too large. This saves time but degrades compression.
  51541. */
  51542. if (s.match_length <= s.max_lazy_match
  51543. /*max_insert_length*/
  51544. && s.lookahead >= MIN_MATCH) {
  51545. s.match_length--;
  51546. /* string at strstart already in table */
  51547. do {
  51548. s.strstart++;
  51549. /*** INSERT_STRING(s, s.strstart, hash_head); ***/
  51550. s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
  51551. hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
  51552. s.head[s.ins_h] = s.strstart;
  51553. /***/
  51554. /* strstart never exceeds WSIZE-MAX_MATCH, so there are
  51555. * always MIN_MATCH bytes ahead.
  51556. */
  51557. } while (--s.match_length !== 0);
  51558. s.strstart++;
  51559. } else {
  51560. s.strstart += s.match_length;
  51561. s.match_length = 0;
  51562. s.ins_h = s.window[s.strstart];
  51563. /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */
  51564. s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + 1]) & s.hash_mask; //#if MIN_MATCH != 3
  51565. // Call UPDATE_HASH() MIN_MATCH-3 more times
  51566. //#endif
  51567. /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
  51568. * matter since it will be recomputed at next deflate call.
  51569. */
  51570. }
  51571. } else {
  51572. /* No match, output a literal byte */
  51573. //Tracevv((stderr,"%c", s.window[s.strstart]));
  51574. /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
  51575. bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
  51576. s.lookahead--;
  51577. s.strstart++;
  51578. }
  51579. if (bflush) {
  51580. /*** FLUSH_BLOCK(s, 0); ***/
  51581. flush_block_only(s, false);
  51582. if (s.strm.avail_out === 0) {
  51583. return BS_NEED_MORE;
  51584. }
  51585. /***/
  51586. }
  51587. }
  51588. s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
  51589. if (flush === Z_FINISH) {
  51590. /*** FLUSH_BLOCK(s, 1); ***/
  51591. flush_block_only(s, true);
  51592. if (s.strm.avail_out === 0) {
  51593. return BS_FINISH_STARTED;
  51594. }
  51595. /***/
  51596. return BS_FINISH_DONE;
  51597. }
  51598. if (s.last_lit) {
  51599. /*** FLUSH_BLOCK(s, 0); ***/
  51600. flush_block_only(s, false);
  51601. if (s.strm.avail_out === 0) {
  51602. return BS_NEED_MORE;
  51603. }
  51604. /***/
  51605. }
  51606. return BS_BLOCK_DONE;
  51607. }
  51608. /* ===========================================================================
  51609. * Same as above, but achieves better compression. We use a lazy
  51610. * evaluation for matches: a match is finally adopted only if there is
  51611. * no better match at the next window position.
  51612. */
  51613. function deflate_slow(s, flush) {
  51614. var hash_head;
  51615. /* head of hash chain */
  51616. var bflush;
  51617. /* set if current block must be flushed */
  51618. var max_insert;
  51619. /* Process the input block. */
  51620. for (; ;) {
  51621. /* Make sure that we always have enough lookahead, except
  51622. * at the end of the input file. We need MAX_MATCH bytes
  51623. * for the next match, plus MIN_MATCH bytes to insert the
  51624. * string following the next match.
  51625. */
  51626. if (s.lookahead < MIN_LOOKAHEAD) {
  51627. fill_window(s);
  51628. if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
  51629. return BS_NEED_MORE;
  51630. }
  51631. if (s.lookahead === 0) {
  51632. break;
  51633. }
  51634. /* flush the current block */
  51635. }
  51636. /* Insert the string window[strstart .. strstart+2] in the
  51637. * dictionary, and set hash_head to the head of the hash chain:
  51638. */
  51639. hash_head = 0
  51640. /*NIL*/
  51641. ;
  51642. if (s.lookahead >= MIN_MATCH) {
  51643. /*** INSERT_STRING(s, s.strstart, hash_head); ***/
  51644. s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
  51645. hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
  51646. s.head[s.ins_h] = s.strstart;
  51647. /***/
  51648. }
  51649. /* Find the longest match, discarding those <= prev_length.
  51650. */
  51651. s.prev_length = s.match_length;
  51652. s.prev_match = s.match_start;
  51653. s.match_length = MIN_MATCH - 1;
  51654. if (hash_head !== 0
  51655. /*NIL*/
  51656. && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD
  51657. /*MAX_DIST(s)*/
  51658. ) {
  51659. /* To simplify the code, we prevent matches with the string
  51660. * of window index 0 (in particular we have to avoid a match
  51661. * of the string with itself at the start of the input file).
  51662. */
  51663. s.match_length = longest_match(s, hash_head);
  51664. /* longest_match() sets match_start */
  51665. if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096
  51666. /*TOO_FAR*/
  51667. )) {
  51668. /* If prev_match is also MIN_MATCH, match_start is garbage
  51669. * but we will ignore the current match anyway.
  51670. */
  51671. s.match_length = MIN_MATCH - 1;
  51672. }
  51673. }
  51674. /* If there was a match at the previous step and the current
  51675. * match is not better, output the previous match:
  51676. */
  51677. if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {
  51678. max_insert = s.strstart + s.lookahead - MIN_MATCH;
  51679. /* Do not insert strings in hash table beyond this. */
  51680. //check_match(s, s.strstart-1, s.prev_match, s.prev_length);
  51681. /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,
  51682. s.prev_length - MIN_MATCH, bflush);***/
  51683. bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);
  51684. /* Insert in hash table all strings up to the end of the match.
  51685. * strstart-1 and strstart are already inserted. If there is not
  51686. * enough lookahead, the last two strings are not inserted in
  51687. * the hash table.
  51688. */
  51689. s.lookahead -= s.prev_length - 1;
  51690. s.prev_length -= 2;
  51691. do {
  51692. if (++s.strstart <= max_insert) {
  51693. /*** INSERT_STRING(s, s.strstart, hash_head); ***/
  51694. s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
  51695. hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
  51696. s.head[s.ins_h] = s.strstart;
  51697. /***/
  51698. }
  51699. } while (--s.prev_length !== 0);
  51700. s.match_available = 0;
  51701. s.match_length = MIN_MATCH - 1;
  51702. s.strstart++;
  51703. if (bflush) {
  51704. /*** FLUSH_BLOCK(s, 0); ***/
  51705. flush_block_only(s, false);
  51706. if (s.strm.avail_out === 0) {
  51707. return BS_NEED_MORE;
  51708. }
  51709. /***/
  51710. }
  51711. } else if (s.match_available) {
  51712. /* If there was no match at the previous position, output a
  51713. * single literal. If there was a match but the current match
  51714. * is longer, truncate the previous match to a single literal.
  51715. */
  51716. //Tracevv((stderr,"%c", s->window[s->strstart-1]));
  51717. /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
  51718. bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
  51719. if (bflush) {
  51720. /*** FLUSH_BLOCK_ONLY(s, 0) ***/
  51721. flush_block_only(s, false);
  51722. /***/
  51723. }
  51724. s.strstart++;
  51725. s.lookahead--;
  51726. if (s.strm.avail_out === 0) {
  51727. return BS_NEED_MORE;
  51728. }
  51729. } else {
  51730. /* There is no previous match to compare with, wait for
  51731. * the next step to decide.
  51732. */
  51733. s.match_available = 1;
  51734. s.strstart++;
  51735. s.lookahead--;
  51736. }
  51737. } //Assert (flush != Z_NO_FLUSH, "no flush?");
  51738. if (s.match_available) {
  51739. //Tracevv((stderr,"%c", s->window[s->strstart-1]));
  51740. /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
  51741. bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
  51742. s.match_available = 0;
  51743. }
  51744. s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
  51745. if (flush === Z_FINISH) {
  51746. /*** FLUSH_BLOCK(s, 1); ***/
  51747. flush_block_only(s, true);
  51748. if (s.strm.avail_out === 0) {
  51749. return BS_FINISH_STARTED;
  51750. }
  51751. /***/
  51752. return BS_FINISH_DONE;
  51753. }
  51754. if (s.last_lit) {
  51755. /*** FLUSH_BLOCK(s, 0); ***/
  51756. flush_block_only(s, false);
  51757. if (s.strm.avail_out === 0) {
  51758. return BS_NEED_MORE;
  51759. }
  51760. /***/
  51761. }
  51762. return BS_BLOCK_DONE;
  51763. }
  51764. /* ===========================================================================
  51765. * For Z_RLE, simply look for runs of bytes, generate matches only of distance
  51766. * one. Do not maintain a hash table. (It will be regenerated if this run of
  51767. * deflate switches away from Z_RLE.)
  51768. */
  51769. function deflate_rle(s, flush) {
  51770. var bflush;
  51771. /* set if current block must be flushed */
  51772. var prev;
  51773. /* byte at distance one to match */
  51774. var scan, strend;
  51775. /* scan goes up to strend for length of run */
  51776. var _win = s.window;
  51777. for (; ;) {
  51778. /* Make sure that we always have enough lookahead, except
  51779. * at the end of the input file. We need MAX_MATCH bytes
  51780. * for the longest run, plus one for the unrolled loop.
  51781. */
  51782. if (s.lookahead <= MAX_MATCH) {
  51783. fill_window(s);
  51784. if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {
  51785. return BS_NEED_MORE;
  51786. }
  51787. if (s.lookahead === 0) {
  51788. break;
  51789. }
  51790. /* flush the current block */
  51791. }
  51792. /* See how many times the previous byte repeats */
  51793. s.match_length = 0;
  51794. if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
  51795. scan = s.strstart - 1;
  51796. prev = _win[scan];
  51797. if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {
  51798. strend = s.strstart + MAX_MATCH;
  51799. do {
  51800. /*jshint noempty:false*/
  51801. } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);
  51802. s.match_length = MAX_MATCH - (strend - scan);
  51803. if (s.match_length > s.lookahead) {
  51804. s.match_length = s.lookahead;
  51805. }
  51806. } //Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
  51807. }
  51808. /* Emit match if have run of MIN_MATCH or longer, else emit literal */
  51809. if (s.match_length >= MIN_MATCH) {
  51810. //check_match(s, s.strstart, s.strstart - 1, s.match_length);
  51811. /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/
  51812. bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);
  51813. s.lookahead -= s.match_length;
  51814. s.strstart += s.match_length;
  51815. s.match_length = 0;
  51816. } else {
  51817. /* No match, output a literal byte */
  51818. //Tracevv((stderr,"%c", s->window[s->strstart]));
  51819. /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
  51820. bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
  51821. s.lookahead--;
  51822. s.strstart++;
  51823. }
  51824. if (bflush) {
  51825. /*** FLUSH_BLOCK(s, 0); ***/
  51826. flush_block_only(s, false);
  51827. if (s.strm.avail_out === 0) {
  51828. return BS_NEED_MORE;
  51829. }
  51830. /***/
  51831. }
  51832. }
  51833. s.insert = 0;
  51834. if (flush === Z_FINISH) {
  51835. /*** FLUSH_BLOCK(s, 1); ***/
  51836. flush_block_only(s, true);
  51837. if (s.strm.avail_out === 0) {
  51838. return BS_FINISH_STARTED;
  51839. }
  51840. /***/
  51841. return BS_FINISH_DONE;
  51842. }
  51843. if (s.last_lit) {
  51844. /*** FLUSH_BLOCK(s, 0); ***/
  51845. flush_block_only(s, false);
  51846. if (s.strm.avail_out === 0) {
  51847. return BS_NEED_MORE;
  51848. }
  51849. /***/
  51850. }
  51851. return BS_BLOCK_DONE;
  51852. }
  51853. /* ===========================================================================
  51854. * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
  51855. * (It will be regenerated if this run of deflate switches away from Huffman.)
  51856. */
  51857. function deflate_huff(s, flush) {
  51858. var bflush;
  51859. /* set if current block must be flushed */
  51860. for (; ;) {
  51861. /* Make sure that we have a literal to write. */
  51862. if (s.lookahead === 0) {
  51863. fill_window(s);
  51864. if (s.lookahead === 0) {
  51865. if (flush === Z_NO_FLUSH) {
  51866. return BS_NEED_MORE;
  51867. }
  51868. break;
  51869. /* flush the current block */
  51870. }
  51871. }
  51872. /* Output a literal byte */
  51873. s.match_length = 0; //Tracevv((stderr,"%c", s->window[s->strstart]));
  51874. /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
  51875. bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
  51876. s.lookahead--;
  51877. s.strstart++;
  51878. if (bflush) {
  51879. /*** FLUSH_BLOCK(s, 0); ***/
  51880. flush_block_only(s, false);
  51881. if (s.strm.avail_out === 0) {
  51882. return BS_NEED_MORE;
  51883. }
  51884. /***/
  51885. }
  51886. }
  51887. s.insert = 0;
  51888. if (flush === Z_FINISH) {
  51889. /*** FLUSH_BLOCK(s, 1); ***/
  51890. flush_block_only(s, true);
  51891. if (s.strm.avail_out === 0) {
  51892. return BS_FINISH_STARTED;
  51893. }
  51894. /***/
  51895. return BS_FINISH_DONE;
  51896. }
  51897. if (s.last_lit) {
  51898. /*** FLUSH_BLOCK(s, 0); ***/
  51899. flush_block_only(s, false);
  51900. if (s.strm.avail_out === 0) {
  51901. return BS_NEED_MORE;
  51902. }
  51903. /***/
  51904. }
  51905. return BS_BLOCK_DONE;
  51906. }
  51907. /* Values for max_lazy_match, good_match and max_chain_length, depending on
  51908. * the desired pack level (0..9). The values given below have been tuned to
  51909. * exclude worst case performance for pathological files. Better values may be
  51910. * found for specific files.
  51911. */
  51912. function Config(good_length, max_lazy, nice_length, max_chain, func) {
  51913. this.good_length = good_length;
  51914. this.max_lazy = max_lazy;
  51915. this.nice_length = nice_length;
  51916. this.max_chain = max_chain;
  51917. this.func = func;
  51918. }
  51919. var configuration_table;
  51920. configuration_table = [
  51921. /* good lazy nice chain */
  51922. new Config(0, 0, 0, 0, deflate_stored),
  51923. /* 0 store only */
  51924. new Config(4, 4, 8, 4, deflate_fast),
  51925. /* 1 max speed, no lazy matches */
  51926. new Config(4, 5, 16, 8, deflate_fast),
  51927. /* 2 */
  51928. new Config(4, 6, 32, 32, deflate_fast),
  51929. /* 3 */
  51930. new Config(4, 4, 16, 16, deflate_slow),
  51931. /* 4 lazy matches */
  51932. new Config(8, 16, 32, 32, deflate_slow),
  51933. /* 5 */
  51934. new Config(8, 16, 128, 128, deflate_slow),
  51935. /* 6 */
  51936. new Config(8, 32, 128, 256, deflate_slow),
  51937. /* 7 */
  51938. new Config(32, 128, 258, 1024, deflate_slow),
  51939. /* 8 */
  51940. new Config(32, 258, 258, 4096, deflate_slow)
  51941. /* 9 max compression */
  51942. ];
  51943. /* ===========================================================================
  51944. * Initialize the "longest match" routines for a new zlib stream
  51945. */
  51946. function lm_init(s) {
  51947. s.window_size = 2 * s.w_size;
  51948. /*** CLEAR_HASH(s); ***/
  51949. zero(s.head); // Fill with NIL (= 0);
  51950. /* Set the default configuration parameters:
  51951. */
  51952. s.max_lazy_match = configuration_table[s.level].max_lazy;
  51953. s.good_match = configuration_table[s.level].good_length;
  51954. s.nice_match = configuration_table[s.level].nice_length;
  51955. s.max_chain_length = configuration_table[s.level].max_chain;
  51956. s.strstart = 0;
  51957. s.block_start = 0;
  51958. s.lookahead = 0;
  51959. s.insert = 0;
  51960. s.match_length = s.prev_length = MIN_MATCH - 1;
  51961. s.match_available = 0;
  51962. s.ins_h = 0;
  51963. }
  51964. function DeflateState() {
  51965. this.strm = null;
  51966. /* pointer back to this zlib stream */
  51967. this.status = 0;
  51968. /* as the name implies */
  51969. this.pending_buf = null;
  51970. /* output still pending */
  51971. this.pending_buf_size = 0;
  51972. /* size of pending_buf */
  51973. this.pending_out = 0;
  51974. /* next pending byte to output to the stream */
  51975. this.pending = 0;
  51976. /* nb of bytes in the pending buffer */
  51977. this.wrap = 0;
  51978. /* bit 0 true for zlib, bit 1 true for gzip */
  51979. this.gzhead = null;
  51980. /* gzip header information to write */
  51981. this.gzindex = 0;
  51982. /* where in extra, name, or comment */
  51983. this.method = Z_DEFLATED;
  51984. /* can only be DEFLATED */
  51985. this.last_flush = -1;
  51986. /* value of flush param for previous deflate call */
  51987. this.w_size = 0;
  51988. /* LZ77 window size (32K by default) */
  51989. this.w_bits = 0;
  51990. /* log2(w_size) (8..16) */
  51991. this.w_mask = 0;
  51992. /* w_size - 1 */
  51993. this.window = null;
  51994. /* Sliding window. Input bytes are read into the second half of the window,
  51995. * and move to the first half later to keep a dictionary of at least wSize
  51996. * bytes. With this organization, matches are limited to a distance of
  51997. * wSize-MAX_MATCH bytes, but this ensures that IO is always
  51998. * performed with a length multiple of the block size.
  51999. */
  52000. this.window_size = 0;
  52001. /* Actual size of window: 2*wSize, except when the user input buffer
  52002. * is directly used as sliding window.
  52003. */
  52004. this.prev = null;
  52005. /* Link to older string with same hash index. To limit the size of this
  52006. * array to 64K, this link is maintained only for the last 32K strings.
  52007. * An index in this array is thus a window index modulo 32K.
  52008. */
  52009. this.head = null;
  52010. /* Heads of the hash chains or NIL. */
  52011. this.ins_h = 0;
  52012. /* hash index of string to be inserted */
  52013. this.hash_size = 0;
  52014. /* number of elements in hash table */
  52015. this.hash_bits = 0;
  52016. /* log2(hash_size) */
  52017. this.hash_mask = 0;
  52018. /* hash_size-1 */
  52019. this.hash_shift = 0;
  52020. /* Number of bits by which ins_h must be shifted at each input
  52021. * step. It must be such that after MIN_MATCH steps, the oldest
  52022. * byte no longer takes part in the hash key, that is:
  52023. * hash_shift * MIN_MATCH >= hash_bits
  52024. */
  52025. this.block_start = 0;
  52026. /* Window position at the beginning of the current output block. Gets
  52027. * negative when the window is moved backwards.
  52028. */
  52029. this.match_length = 0;
  52030. /* length of best match */
  52031. this.prev_match = 0;
  52032. /* previous match */
  52033. this.match_available = 0;
  52034. /* set if previous match exists */
  52035. this.strstart = 0;
  52036. /* start of string to insert */
  52037. this.match_start = 0;
  52038. /* start of matching string */
  52039. this.lookahead = 0;
  52040. /* number of valid bytes ahead in window */
  52041. this.prev_length = 0;
  52042. /* Length of the best match at previous step. Matches not greater than this
  52043. * are discarded. This is used in the lazy match evaluation.
  52044. */
  52045. this.max_chain_length = 0;
  52046. /* To speed up deflation, hash chains are never searched beyond this
  52047. * length. A higher limit improves compression ratio but degrades the
  52048. * speed.
  52049. */
  52050. this.max_lazy_match = 0;
  52051. /* Attempt to find a better match only when the current match is strictly
  52052. * smaller than this value. This mechanism is used only for compression
  52053. * levels >= 4.
  52054. */
  52055. // That's alias to max_lazy_match, don't use directly
  52056. //this.max_insert_length = 0;
  52057. /* Insert new strings in the hash table only if the match length is not
  52058. * greater than this length. This saves time but degrades compression.
  52059. * max_insert_length is used only for compression levels <= 3.
  52060. */
  52061. this.level = 0;
  52062. /* compression level (1..9) */
  52063. this.strategy = 0;
  52064. /* favor or force Huffman coding*/
  52065. this.good_match = 0;
  52066. /* Use a faster search when the previous match is longer than this */
  52067. this.nice_match = 0;
  52068. /* Stop searching when current match exceeds this */
  52069. /* used by trees.c: */
  52070. /* Didn't use ct_data typedef below to suppress compiler warning */
  52071. // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
  52072. // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
  52073. // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
  52074. // Use flat array of DOUBLE size, with interleaved fata,
  52075. // because JS does not support effective
  52076. this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);
  52077. this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);
  52078. this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);
  52079. zero(this.dyn_ltree);
  52080. zero(this.dyn_dtree);
  52081. zero(this.bl_tree);
  52082. this.l_desc = null;
  52083. /* desc. for literal tree */
  52084. this.d_desc = null;
  52085. /* desc. for distance tree */
  52086. this.bl_desc = null;
  52087. /* desc. for bit length tree */
  52088. //ush bl_count[MAX_BITS+1];
  52089. this.bl_count = new utils.Buf16(MAX_BITS + 1);
  52090. /* number of codes at each bit length for an optimal tree */
  52091. //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
  52092. this.heap = new utils.Buf16(2 * L_CODES + 1);
  52093. /* heap used to build the Huffman trees */
  52094. zero(this.heap);
  52095. this.heap_len = 0;
  52096. /* number of elements in the heap */
  52097. this.heap_max = 0;
  52098. /* element of largest frequency */
  52099. /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
  52100. * The same heap array is used to build all trees.
  52101. */
  52102. this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];
  52103. zero(this.depth);
  52104. /* Depth of each subtree used as tie breaker for trees of equal frequency
  52105. */
  52106. this.l_buf = 0;
  52107. /* buffer index for literals or lengths */
  52108. this.lit_bufsize = 0;
  52109. /* Size of match buffer for literals/lengths. There are 4 reasons for
  52110. * limiting lit_bufsize to 64K:
  52111. * - frequencies can be kept in 16 bit counters
  52112. * - if compression is not successful for the first block, all input
  52113. * data is still in the window so we can still emit a stored block even
  52114. * when input comes from standard input. (This can also be done for
  52115. * all blocks if lit_bufsize is not greater than 32K.)
  52116. * - if compression is not successful for a file smaller than 64K, we can
  52117. * even emit a stored file instead of a stored block (saving 5 bytes).
  52118. * This is applicable only for zip (not gzip or zlib).
  52119. * - creating new Huffman trees less frequently may not provide fast
  52120. * adaptation to changes in the input data statistics. (Take for
  52121. * example a binary file with poorly compressible code followed by
  52122. * a highly compressible string table.) Smaller buffer sizes give
  52123. * fast adaptation but have of course the overhead of transmitting
  52124. * trees more frequently.
  52125. * - I can't count above 4
  52126. */
  52127. this.last_lit = 0;
  52128. /* running index in l_buf */
  52129. this.d_buf = 0;
  52130. /* Buffer index for distances. To simplify the code, d_buf and l_buf have
  52131. * the same number of elements. To use different lengths, an extra flag
  52132. * array would be necessary.
  52133. */
  52134. this.opt_len = 0;
  52135. /* bit length of current block with optimal trees */
  52136. this.static_len = 0;
  52137. /* bit length of current block with static trees */
  52138. this.matches = 0;
  52139. /* number of string matches in current block */
  52140. this.insert = 0;
  52141. /* bytes at end of window left to insert */
  52142. this.bi_buf = 0;
  52143. /* Output buffer. bits are inserted starting at the bottom (least
  52144. * significant bits).
  52145. */
  52146. this.bi_valid = 0;
  52147. /* Number of valid bits in bi_buf. All bits above the last valid bit
  52148. * are always zero.
  52149. */
  52150. // Used for window memory init. We safely ignore it for JS. That makes
  52151. // sense only for pointers and memory check tools.
  52152. //this.high_water = 0;
  52153. /* High water mark offset in window for initialized bytes -- bytes above
  52154. * this are set to zero in order to avoid memory check warnings when
  52155. * longest match routines access bytes past the input. This is then
  52156. * updated to the new high water mark.
  52157. */
  52158. }
  52159. function deflateResetKeep(strm) {
  52160. var s;
  52161. if (!strm || !strm.state) {
  52162. return err(strm, Z_STREAM_ERROR);
  52163. }
  52164. strm.total_in = strm.total_out = 0;
  52165. strm.data_type = Z_UNKNOWN;
  52166. s = strm.state;
  52167. s.pending = 0;
  52168. s.pending_out = 0;
  52169. if (s.wrap < 0) {
  52170. s.wrap = -s.wrap;
  52171. /* was made negative by deflate(..., Z_FINISH); */
  52172. }
  52173. s.status = s.wrap ? INIT_STATE : BUSY_STATE;
  52174. strm.adler = s.wrap === 2 ? 0 // crc32(0, Z_NULL, 0)
  52175. : 1; // adler32(0, Z_NULL, 0)
  52176. s.last_flush = Z_NO_FLUSH;
  52177. trees._tr_init(s);
  52178. return Z_OK;
  52179. }
  52180. function deflateReset(strm) {
  52181. var ret = deflateResetKeep(strm);
  52182. if (ret === Z_OK) {
  52183. lm_init(strm.state);
  52184. }
  52185. return ret;
  52186. }
  52187. function deflateSetHeader(strm, head) {
  52188. if (!strm || !strm.state) {
  52189. return Z_STREAM_ERROR;
  52190. }
  52191. if (strm.state.wrap !== 2) {
  52192. return Z_STREAM_ERROR;
  52193. }
  52194. strm.state.gzhead = head;
  52195. return Z_OK;
  52196. }
  52197. function deflateInit2(strm, level, method, windowBits, memLevel, strategy) {
  52198. if (!strm) {
  52199. // === Z_NULL
  52200. return Z_STREAM_ERROR;
  52201. }
  52202. var wrap = 1;
  52203. if (level === Z_DEFAULT_COMPRESSION) {
  52204. level = 6;
  52205. }
  52206. if (windowBits < 0) {
  52207. /* suppress zlib wrapper */
  52208. wrap = 0;
  52209. windowBits = -windowBits;
  52210. } else if (windowBits > 15) {
  52211. wrap = 2;
  52212. /* write gzip wrapper instead */
  52213. windowBits -= 16;
  52214. }
  52215. if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
  52216. return err(strm, Z_STREAM_ERROR);
  52217. }
  52218. if (windowBits === 8) {
  52219. windowBits = 9;
  52220. }
  52221. /* until 256-byte window bug fixed */
  52222. var s = new DeflateState();
  52223. strm.state = s;
  52224. s.strm = strm;
  52225. s.wrap = wrap;
  52226. s.gzhead = null;
  52227. s.w_bits = windowBits;
  52228. s.w_size = 1 << s.w_bits;
  52229. s.w_mask = s.w_size - 1;
  52230. s.hash_bits = memLevel + 7;
  52231. s.hash_size = 1 << s.hash_bits;
  52232. s.hash_mask = s.hash_size - 1;
  52233. s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);
  52234. s.window = new utils.Buf8(s.w_size * 2);
  52235. s.head = new utils.Buf16(s.hash_size);
  52236. s.prev = new utils.Buf16(s.w_size); // Don't need mem init magic for JS.
  52237. //s.high_water = 0; /* nothing written to s->window yet */
  52238. s.lit_bufsize = 1 << memLevel + 6;
  52239. /* 16K elements by default */
  52240. s.pending_buf_size = s.lit_bufsize * 4; //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
  52241. //s->pending_buf = (uchf *) overlay;
  52242. s.pending_buf = new utils.Buf8(s.pending_buf_size); // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)
  52243. //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
  52244. s.d_buf = 1 * s.lit_bufsize; //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
  52245. s.l_buf = (1 + 2) * s.lit_bufsize;
  52246. s.level = level;
  52247. s.strategy = strategy;
  52248. s.method = method;
  52249. return deflateReset(strm);
  52250. }
  52251. function deflateInit(strm, level) {
  52252. return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
  52253. }
  52254. function deflate(strm, flush) {
  52255. var old_flush, s;
  52256. var beg, val; // for gzip header write only
  52257. if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) {
  52258. return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;
  52259. }
  52260. s = strm.state;
  52261. if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE && flush !== Z_FINISH) {
  52262. return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR);
  52263. }
  52264. s.strm = strm;
  52265. /* just in case */
  52266. old_flush = s.last_flush;
  52267. s.last_flush = flush;
  52268. /* Write the header */
  52269. if (s.status === INIT_STATE) {
  52270. if (s.wrap === 2) {
  52271. // GZIP header
  52272. strm.adler = 0; //crc32(0L, Z_NULL, 0);
  52273. put_byte(s, 31);
  52274. put_byte(s, 139);
  52275. put_byte(s, 8);
  52276. if (!s.gzhead) {
  52277. // s->gzhead == Z_NULL
  52278. put_byte(s, 0);
  52279. put_byte(s, 0);
  52280. put_byte(s, 0);
  52281. put_byte(s, 0);
  52282. put_byte(s, 0);
  52283. put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);
  52284. put_byte(s, OS_CODE);
  52285. s.status = BUSY_STATE;
  52286. } else {
  52287. put_byte(s, (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16));
  52288. put_byte(s, s.gzhead.time & 0xff);
  52289. put_byte(s, s.gzhead.time >> 8 & 0xff);
  52290. put_byte(s, s.gzhead.time >> 16 & 0xff);
  52291. put_byte(s, s.gzhead.time >> 24 & 0xff);
  52292. put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);
  52293. put_byte(s, s.gzhead.os & 0xff);
  52294. if (s.gzhead.extra && s.gzhead.extra.length) {
  52295. put_byte(s, s.gzhead.extra.length & 0xff);
  52296. put_byte(s, s.gzhead.extra.length >> 8 & 0xff);
  52297. }
  52298. if (s.gzhead.hcrc) {
  52299. strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);
  52300. }
  52301. s.gzindex = 0;
  52302. s.status = EXTRA_STATE;
  52303. }
  52304. } else // DEFLATE header
  52305. {
  52306. var header = Z_DEFLATED + (s.w_bits - 8 << 4) << 8;
  52307. var level_flags = -1;
  52308. if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
  52309. level_flags = 0;
  52310. } else if (s.level < 6) {
  52311. level_flags = 1;
  52312. } else if (s.level === 6) {
  52313. level_flags = 2;
  52314. } else {
  52315. level_flags = 3;
  52316. }
  52317. header |= level_flags << 6;
  52318. if (s.strstart !== 0) {
  52319. header |= PRESET_DICT;
  52320. }
  52321. header += 31 - header % 31;
  52322. s.status = BUSY_STATE;
  52323. putShortMSB(s, header);
  52324. /* Save the adler32 of the preset dictionary: */
  52325. if (s.strstart !== 0) {
  52326. putShortMSB(s, strm.adler >>> 16);
  52327. putShortMSB(s, strm.adler & 0xffff);
  52328. }
  52329. strm.adler = 1; // adler32(0L, Z_NULL, 0);
  52330. }
  52331. } //#ifdef GZIP
  52332. if (s.status === EXTRA_STATE) {
  52333. if (s.gzhead.extra
  52334. /* != Z_NULL*/
  52335. ) {
  52336. beg = s.pending;
  52337. /* start of bytes to update crc */
  52338. while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {
  52339. if (s.pending === s.pending_buf_size) {
  52340. if (s.gzhead.hcrc && s.pending > beg) {
  52341. strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
  52342. }
  52343. flush_pending(strm);
  52344. beg = s.pending;
  52345. if (s.pending === s.pending_buf_size) {
  52346. break;
  52347. }
  52348. }
  52349. put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);
  52350. s.gzindex++;
  52351. }
  52352. if (s.gzhead.hcrc && s.pending > beg) {
  52353. strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
  52354. }
  52355. if (s.gzindex === s.gzhead.extra.length) {
  52356. s.gzindex = 0;
  52357. s.status = NAME_STATE;
  52358. }
  52359. } else {
  52360. s.status = NAME_STATE;
  52361. }
  52362. }
  52363. if (s.status === NAME_STATE) {
  52364. if (s.gzhead.name
  52365. /* != Z_NULL*/
  52366. ) {
  52367. beg = s.pending;
  52368. /* start of bytes to update crc */
  52369. //int val;
  52370. do {
  52371. if (s.pending === s.pending_buf_size) {
  52372. if (s.gzhead.hcrc && s.pending > beg) {
  52373. strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
  52374. }
  52375. flush_pending(strm);
  52376. beg = s.pending;
  52377. if (s.pending === s.pending_buf_size) {
  52378. val = 1;
  52379. break;
  52380. }
  52381. } // JS specific: little magic to add zero terminator to end of string
  52382. if (s.gzindex < s.gzhead.name.length) {
  52383. val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;
  52384. } else {
  52385. val = 0;
  52386. }
  52387. put_byte(s, val);
  52388. } while (val !== 0);
  52389. if (s.gzhead.hcrc && s.pending > beg) {
  52390. strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
  52391. }
  52392. if (val === 0) {
  52393. s.gzindex = 0;
  52394. s.status = COMMENT_STATE;
  52395. }
  52396. } else {
  52397. s.status = COMMENT_STATE;
  52398. }
  52399. }
  52400. if (s.status === COMMENT_STATE) {
  52401. if (s.gzhead.comment
  52402. /* != Z_NULL*/
  52403. ) {
  52404. beg = s.pending;
  52405. /* start of bytes to update crc */
  52406. //int val;
  52407. do {
  52408. if (s.pending === s.pending_buf_size) {
  52409. if (s.gzhead.hcrc && s.pending > beg) {
  52410. strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
  52411. }
  52412. flush_pending(strm);
  52413. beg = s.pending;
  52414. if (s.pending === s.pending_buf_size) {
  52415. val = 1;
  52416. break;
  52417. }
  52418. } // JS specific: little magic to add zero terminator to end of string
  52419. if (s.gzindex < s.gzhead.comment.length) {
  52420. val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;
  52421. } else {
  52422. val = 0;
  52423. }
  52424. put_byte(s, val);
  52425. } while (val !== 0);
  52426. if (s.gzhead.hcrc && s.pending > beg) {
  52427. strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
  52428. }
  52429. if (val === 0) {
  52430. s.status = HCRC_STATE;
  52431. }
  52432. } else {
  52433. s.status = HCRC_STATE;
  52434. }
  52435. }
  52436. if (s.status === HCRC_STATE) {
  52437. if (s.gzhead.hcrc) {
  52438. if (s.pending + 2 > s.pending_buf_size) {
  52439. flush_pending(strm);
  52440. }
  52441. if (s.pending + 2 <= s.pending_buf_size) {
  52442. put_byte(s, strm.adler & 0xff);
  52443. put_byte(s, strm.adler >> 8 & 0xff);
  52444. strm.adler = 0; //crc32(0L, Z_NULL, 0);
  52445. s.status = BUSY_STATE;
  52446. }
  52447. } else {
  52448. s.status = BUSY_STATE;
  52449. }
  52450. } //#endif
  52451. /* Flush as much pending output as possible */
  52452. if (s.pending !== 0) {
  52453. flush_pending(strm);
  52454. if (strm.avail_out === 0) {
  52455. /* Since avail_out is 0, deflate will be called again with
  52456. * more output space, but possibly with both pending and
  52457. * avail_in equal to zero. There won't be anything to do,
  52458. * but this is not an error situation so make sure we
  52459. * return OK instead of BUF_ERROR at next call of deflate:
  52460. */
  52461. s.last_flush = -1;
  52462. return Z_OK;
  52463. }
  52464. /* Make sure there is something to do and avoid duplicate consecutive
  52465. * flushes. For repeated and useless calls with Z_FINISH, we keep
  52466. * returning Z_STREAM_END instead of Z_BUF_ERROR.
  52467. */
  52468. } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH) {
  52469. return err(strm, Z_BUF_ERROR);
  52470. }
  52471. /* User must not provide more input after the first FINISH: */
  52472. if (s.status === FINISH_STATE && strm.avail_in !== 0) {
  52473. return err(strm, Z_BUF_ERROR);
  52474. }
  52475. /* Start a new block or continue the current one.
  52476. */
  52477. if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH && s.status !== FINISH_STATE) {
  52478. var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);
  52479. if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
  52480. s.status = FINISH_STATE;
  52481. }
  52482. if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {
  52483. if (strm.avail_out === 0) {
  52484. s.last_flush = -1;
  52485. /* avoid BUF_ERROR next call, see above */
  52486. }
  52487. return Z_OK;
  52488. /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
  52489. * of deflate should use the same flush parameter to make sure
  52490. * that the flush is complete. So we don't have to output an
  52491. * empty block here, this will be done at next call. This also
  52492. * ensures that for a very small output buffer, we emit at most
  52493. * one empty block.
  52494. */
  52495. }
  52496. if (bstate === BS_BLOCK_DONE) {
  52497. if (flush === Z_PARTIAL_FLUSH) {
  52498. trees._tr_align(s);
  52499. } else if (flush !== Z_BLOCK) {
  52500. /* FULL_FLUSH or SYNC_FLUSH */
  52501. trees._tr_stored_block(s, 0, 0, false);
  52502. /* For a full flush, this empty block will be recognized
  52503. * as a special marker by inflate_sync().
  52504. */
  52505. if (flush === Z_FULL_FLUSH) {
  52506. /*** CLEAR_HASH(s); ***/
  52507. /* forget history */
  52508. zero(s.head); // Fill with NIL (= 0);
  52509. if (s.lookahead === 0) {
  52510. s.strstart = 0;
  52511. s.block_start = 0;
  52512. s.insert = 0;
  52513. }
  52514. }
  52515. }
  52516. flush_pending(strm);
  52517. if (strm.avail_out === 0) {
  52518. s.last_flush = -1;
  52519. /* avoid BUF_ERROR at next call, see above */
  52520. return Z_OK;
  52521. }
  52522. }
  52523. } //Assert(strm->avail_out > 0, "bug2");
  52524. //if (strm.avail_out <= 0) { throw new Error("bug2");}
  52525. if (flush !== Z_FINISH) {
  52526. return Z_OK;
  52527. }
  52528. if (s.wrap <= 0) {
  52529. return Z_STREAM_END;
  52530. }
  52531. /* Write the trailer */
  52532. if (s.wrap === 2) {
  52533. put_byte(s, strm.adler & 0xff);
  52534. put_byte(s, strm.adler >> 8 & 0xff);
  52535. put_byte(s, strm.adler >> 16 & 0xff);
  52536. put_byte(s, strm.adler >> 24 & 0xff);
  52537. put_byte(s, strm.total_in & 0xff);
  52538. put_byte(s, strm.total_in >> 8 & 0xff);
  52539. put_byte(s, strm.total_in >> 16 & 0xff);
  52540. put_byte(s, strm.total_in >> 24 & 0xff);
  52541. } else {
  52542. putShortMSB(s, strm.adler >>> 16);
  52543. putShortMSB(s, strm.adler & 0xffff);
  52544. }
  52545. flush_pending(strm);
  52546. /* If avail_out is zero, the application will call deflate again
  52547. * to flush the rest.
  52548. */
  52549. if (s.wrap > 0) {
  52550. s.wrap = -s.wrap;
  52551. }
  52552. /* write the trailer only once! */
  52553. return s.pending !== 0 ? Z_OK : Z_STREAM_END;
  52554. }
  52555. function deflateEnd(strm) {
  52556. var status;
  52557. if (!strm
  52558. /*== Z_NULL*/
  52559. || !strm.state
  52560. /*== Z_NULL*/
  52561. ) {
  52562. return Z_STREAM_ERROR;
  52563. }
  52564. status = strm.state.status;
  52565. if (status !== INIT_STATE && status !== EXTRA_STATE && status !== NAME_STATE && status !== COMMENT_STATE && status !== HCRC_STATE && status !== BUSY_STATE && status !== FINISH_STATE) {
  52566. return err(strm, Z_STREAM_ERROR);
  52567. }
  52568. strm.state = null;
  52569. return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;
  52570. }
  52571. /* =========================================================================
  52572. * Initializes the compression dictionary from the given byte
  52573. * sequence without producing any compressed output.
  52574. */
  52575. function deflateSetDictionary(strm, dictionary) {
  52576. var dictLength = dictionary.length;
  52577. var s;
  52578. var str, n;
  52579. var wrap;
  52580. var avail;
  52581. var next;
  52582. var input;
  52583. var tmpDict;
  52584. if (!strm
  52585. /*== Z_NULL*/
  52586. || !strm.state
  52587. /*== Z_NULL*/
  52588. ) {
  52589. return Z_STREAM_ERROR;
  52590. }
  52591. s = strm.state;
  52592. wrap = s.wrap;
  52593. if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {
  52594. return Z_STREAM_ERROR;
  52595. }
  52596. /* when using zlib wrappers, compute Adler-32 for provided dictionary */
  52597. if (wrap === 1) {
  52598. /* adler32(strm->adler, dictionary, dictLength); */
  52599. strm.adler = adler32(strm.adler, dictionary, dictLength, 0);
  52600. }
  52601. s.wrap = 0;
  52602. /* avoid computing Adler-32 in read_buf */
  52603. /* if dictionary would fill window, just replace the history */
  52604. if (dictLength >= s.w_size) {
  52605. if (wrap === 0) {
  52606. /* already empty otherwise */
  52607. /*** CLEAR_HASH(s); ***/
  52608. zero(s.head); // Fill with NIL (= 0);
  52609. s.strstart = 0;
  52610. s.block_start = 0;
  52611. s.insert = 0;
  52612. }
  52613. /* use the tail */
  52614. // dictionary = dictionary.slice(dictLength - s.w_size);
  52615. tmpDict = new utils.Buf8(s.w_size);
  52616. utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);
  52617. dictionary = tmpDict;
  52618. dictLength = s.w_size;
  52619. }
  52620. /* insert dictionary into window and hash */
  52621. avail = strm.avail_in;
  52622. next = strm.next_in;
  52623. input = strm.input;
  52624. strm.avail_in = dictLength;
  52625. strm.next_in = 0;
  52626. strm.input = dictionary;
  52627. fill_window(s);
  52628. while (s.lookahead >= MIN_MATCH) {
  52629. str = s.strstart;
  52630. n = s.lookahead - (MIN_MATCH - 1);
  52631. do {
  52632. /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
  52633. s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
  52634. s.prev[str & s.w_mask] = s.head[s.ins_h];
  52635. s.head[s.ins_h] = str;
  52636. str++;
  52637. } while (--n);
  52638. s.strstart = str;
  52639. s.lookahead = MIN_MATCH - 1;
  52640. fill_window(s);
  52641. }
  52642. s.strstart += s.lookahead;
  52643. s.block_start = s.strstart;
  52644. s.insert = s.lookahead;
  52645. s.lookahead = 0;
  52646. s.match_length = s.prev_length = MIN_MATCH - 1;
  52647. s.match_available = 0;
  52648. strm.next_in = next;
  52649. strm.input = input;
  52650. strm.avail_in = avail;
  52651. s.wrap = wrap;
  52652. return Z_OK;
  52653. }
  52654. exports.deflateInit = deflateInit;
  52655. exports.deflateInit2 = deflateInit2;
  52656. exports.deflateReset = deflateReset;
  52657. exports.deflateResetKeep = deflateResetKeep;
  52658. exports.deflateSetHeader = deflateSetHeader;
  52659. exports.deflate = deflate;
  52660. exports.deflateEnd = deflateEnd;
  52661. exports.deflateSetDictionary = deflateSetDictionary;
  52662. exports.deflateInfo = 'pako deflate (from Nodeca project)';
  52663. /* Not implemented
  52664. exports.deflateBound = deflateBound;
  52665. exports.deflateCopy = deflateCopy;
  52666. exports.deflateParams = deflateParams;
  52667. exports.deflatePending = deflatePending;
  52668. exports.deflatePrime = deflatePrime;
  52669. exports.deflateTune = deflateTune;
  52670. */
  52671. }, { "../utils/common": 442, "./adler32": 444, "./crc32": 446, "./messages": 452, "./trees": 453 }], 448: [function (require, module, exports) {
  52672. 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  52673. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  52674. //
  52675. // This software is provided 'as-is', without any express or implied
  52676. // warranty. In no event will the authors be held liable for any damages
  52677. // arising from the use of this software.
  52678. //
  52679. // Permission is granted to anyone to use this software for any purpose,
  52680. // including commercial applications, and to alter it and redistribute it
  52681. // freely, subject to the following restrictions:
  52682. //
  52683. // 1. The origin of this software must not be misrepresented; you must not
  52684. // claim that you wrote the original software. If you use this software
  52685. // in a product, an acknowledgment in the product documentation would be
  52686. // appreciated but is not required.
  52687. // 2. Altered source versions must be plainly marked as such, and must not be
  52688. // misrepresented as being the original software.
  52689. // 3. This notice may not be removed or altered from any source distribution.
  52690. function GZheader() {
  52691. /* true if compressed data believed to be text */
  52692. this.text = 0;
  52693. /* modification time */
  52694. this.time = 0;
  52695. /* extra flags (not used when writing a gzip file) */
  52696. this.xflags = 0;
  52697. /* operating system */
  52698. this.os = 0;
  52699. /* pointer to extra field or Z_NULL if none */
  52700. this.extra = null;
  52701. /* extra field length (valid if extra != Z_NULL) */
  52702. this.extra_len = 0; // Actually, we don't need it in JS,
  52703. // but leave for few code modifications
  52704. //
  52705. // Setup limits is not necessary because in js we should not preallocate memory
  52706. // for inflate use constant limit in 65536 bytes
  52707. //
  52708. /* space at extra (only when reading header) */
  52709. // this.extra_max = 0;
  52710. /* pointer to zero-terminated file name or Z_NULL */
  52711. this.name = '';
  52712. /* space at name (only when reading header) */
  52713. // this.name_max = 0;
  52714. /* pointer to zero-terminated comment or Z_NULL */
  52715. this.comment = '';
  52716. /* space at comment (only when reading header) */
  52717. // this.comm_max = 0;
  52718. /* true if there was or will be a header crc */
  52719. this.hcrc = 0;
  52720. /* true when done reading gzip header (not used when writing a gzip file) */
  52721. this.done = false;
  52722. }
  52723. module.exports = GZheader;
  52724. }, {}], 449: [function (require, module, exports) {
  52725. 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  52726. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  52727. //
  52728. // This software is provided 'as-is', without any express or implied
  52729. // warranty. In no event will the authors be held liable for any damages
  52730. // arising from the use of this software.
  52731. //
  52732. // Permission is granted to anyone to use this software for any purpose,
  52733. // including commercial applications, and to alter it and redistribute it
  52734. // freely, subject to the following restrictions:
  52735. //
  52736. // 1. The origin of this software must not be misrepresented; you must not
  52737. // claim that you wrote the original software. If you use this software
  52738. // in a product, an acknowledgment in the product documentation would be
  52739. // appreciated but is not required.
  52740. // 2. Altered source versions must be plainly marked as such, and must not be
  52741. // misrepresented as being the original software.
  52742. // 3. This notice may not be removed or altered from any source distribution.
  52743. // See state defs from inflate.js
  52744. var BAD = 30;
  52745. /* got a data error -- remain here until reset */
  52746. var TYPE = 12;
  52747. /* i: waiting for type bits, including last-flag bit */
  52748. /*
  52749. Decode literal, length, and distance codes and write out the resulting
  52750. literal and match bytes until either not enough input or output is
  52751. available, an end-of-block is encountered, or a data error is encountered.
  52752. When large enough input and output buffers are supplied to inflate(), for
  52753. example, a 16K input buffer and a 64K output buffer, more than 95% of the
  52754. inflate execution time is spent in this routine.
  52755. Entry assumptions:
  52756. state.mode === LEN
  52757. strm.avail_in >= 6
  52758. strm.avail_out >= 258
  52759. start >= strm.avail_out
  52760. state.bits < 8
  52761. On return, state.mode is one of:
  52762. LEN -- ran out of enough output space or enough available input
  52763. TYPE -- reached end of block code, inflate() to interpret next block
  52764. BAD -- error in block data
  52765. Notes:
  52766. - The maximum input bits used by a length/distance pair is 15 bits for the
  52767. length code, 5 bits for the length extra, 15 bits for the distance code,
  52768. and 13 bits for the distance extra. This totals 48 bits, or six bytes.
  52769. Therefore if strm.avail_in >= 6, then there is enough input to avoid
  52770. checking for available input while decoding.
  52771. - The maximum bytes that a single length/distance pair can output is 258
  52772. bytes, which is the maximum length that can be coded. inflate_fast()
  52773. requires strm.avail_out >= 258 for each loop to avoid checking for
  52774. output space.
  52775. */
  52776. module.exports = function inflate_fast(strm, start) {
  52777. var state;
  52778. var _in;
  52779. /* local strm.input */
  52780. var last;
  52781. /* have enough input while in < last */
  52782. var _out;
  52783. /* local strm.output */
  52784. var beg;
  52785. /* inflate()'s initial strm.output */
  52786. var end;
  52787. /* while out < end, enough space available */
  52788. //#ifdef INFLATE_STRICT
  52789. var dmax;
  52790. /* maximum distance from zlib header */
  52791. //#endif
  52792. var wsize;
  52793. /* window size or zero if not using window */
  52794. var whave;
  52795. /* valid bytes in the window */
  52796. var wnext;
  52797. /* window write index */
  52798. // Use `s_window` instead `window`, avoid conflict with instrumentation tools
  52799. var s_window;
  52800. /* allocated sliding window, if wsize != 0 */
  52801. var hold;
  52802. /* local strm.hold */
  52803. var bits;
  52804. /* local strm.bits */
  52805. var lcode;
  52806. /* local strm.lencode */
  52807. var dcode;
  52808. /* local strm.distcode */
  52809. var lmask;
  52810. /* mask for first level of length codes */
  52811. var dmask;
  52812. /* mask for first level of distance codes */
  52813. var here;
  52814. /* retrieved table entry */
  52815. var op;
  52816. /* code bits, operation, extra bits, or */
  52817. /* window position, window bytes to copy */
  52818. var len;
  52819. /* match length, unused bytes */
  52820. var dist;
  52821. /* match distance */
  52822. var from;
  52823. /* where to copy match from */
  52824. var from_source;
  52825. var input, output; // JS specific, because we have no pointers
  52826. /* copy state to local variables */
  52827. state = strm.state; //here = state.here;
  52828. _in = strm.next_in;
  52829. input = strm.input;
  52830. last = _in + (strm.avail_in - 5);
  52831. _out = strm.next_out;
  52832. output = strm.output;
  52833. beg = _out - (start - strm.avail_out);
  52834. end = _out + (strm.avail_out - 257); //#ifdef INFLATE_STRICT
  52835. dmax = state.dmax; //#endif
  52836. wsize = state.wsize;
  52837. whave = state.whave;
  52838. wnext = state.wnext;
  52839. s_window = state.window;
  52840. hold = state.hold;
  52841. bits = state.bits;
  52842. lcode = state.lencode;
  52843. dcode = state.distcode;
  52844. lmask = (1 << state.lenbits) - 1;
  52845. dmask = (1 << state.distbits) - 1;
  52846. /* decode literals and length/distances until end-of-block or not enough
  52847. input data or output space */
  52848. top: do {
  52849. if (bits < 15) {
  52850. hold += input[_in++] << bits;
  52851. bits += 8;
  52852. hold += input[_in++] << bits;
  52853. bits += 8;
  52854. }
  52855. here = lcode[hold & lmask];
  52856. dolen: for (; ;) {
  52857. // Goto emulation
  52858. op = here >>> 24
  52859. /*here.bits*/
  52860. ;
  52861. hold >>>= op;
  52862. bits -= op;
  52863. op = here >>> 16 & 0xff
  52864. /*here.op*/
  52865. ;
  52866. if (op === 0) {
  52867. /* literal */
  52868. //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
  52869. // "inflate: literal '%c'\n" :
  52870. // "inflate: literal 0x%02x\n", here.val));
  52871. output[_out++] = here & 0xffff
  52872. /*here.val*/
  52873. ;
  52874. } else if (op & 16) {
  52875. /* length base */
  52876. len = here & 0xffff
  52877. /*here.val*/
  52878. ;
  52879. op &= 15;
  52880. /* number of extra bits */
  52881. if (op) {
  52882. if (bits < op) {
  52883. hold += input[_in++] << bits;
  52884. bits += 8;
  52885. }
  52886. len += hold & (1 << op) - 1;
  52887. hold >>>= op;
  52888. bits -= op;
  52889. } //Tracevv((stderr, "inflate: length %u\n", len));
  52890. if (bits < 15) {
  52891. hold += input[_in++] << bits;
  52892. bits += 8;
  52893. hold += input[_in++] << bits;
  52894. bits += 8;
  52895. }
  52896. here = dcode[hold & dmask];
  52897. dodist: for (; ;) {
  52898. // goto emulation
  52899. op = here >>> 24
  52900. /*here.bits*/
  52901. ;
  52902. hold >>>= op;
  52903. bits -= op;
  52904. op = here >>> 16 & 0xff
  52905. /*here.op*/
  52906. ;
  52907. if (op & 16) {
  52908. /* distance base */
  52909. dist = here & 0xffff
  52910. /*here.val*/
  52911. ;
  52912. op &= 15;
  52913. /* number of extra bits */
  52914. if (bits < op) {
  52915. hold += input[_in++] << bits;
  52916. bits += 8;
  52917. if (bits < op) {
  52918. hold += input[_in++] << bits;
  52919. bits += 8;
  52920. }
  52921. }
  52922. dist += hold & (1 << op) - 1; //#ifdef INFLATE_STRICT
  52923. if (dist > dmax) {
  52924. strm.msg = 'invalid distance too far back';
  52925. state.mode = BAD;
  52926. break top;
  52927. } //#endif
  52928. hold >>>= op;
  52929. bits -= op; //Tracevv((stderr, "inflate: distance %u\n", dist));
  52930. op = _out - beg;
  52931. /* max distance in output */
  52932. if (dist > op) {
  52933. /* see if copy from window */
  52934. op = dist - op;
  52935. /* distance back in window */
  52936. if (op > whave) {
  52937. if (state.sane) {
  52938. strm.msg = 'invalid distance too far back';
  52939. state.mode = BAD;
  52940. break top;
  52941. } // (!) This block is disabled in zlib defaults,
  52942. // don't enable it for binary compatibility
  52943. //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
  52944. // if (len <= op - whave) {
  52945. // do {
  52946. // output[_out++] = 0;
  52947. // } while (--len);
  52948. // continue top;
  52949. // }
  52950. // len -= op - whave;
  52951. // do {
  52952. // output[_out++] = 0;
  52953. // } while (--op > whave);
  52954. // if (op === 0) {
  52955. // from = _out - dist;
  52956. // do {
  52957. // output[_out++] = output[from++];
  52958. // } while (--len);
  52959. // continue top;
  52960. // }
  52961. //#endif
  52962. }
  52963. from = 0; // window index
  52964. from_source = s_window;
  52965. if (wnext === 0) {
  52966. /* very common case */
  52967. from += wsize - op;
  52968. if (op < len) {
  52969. /* some from window */
  52970. len -= op;
  52971. do {
  52972. output[_out++] = s_window[from++];
  52973. } while (--op);
  52974. from = _out - dist;
  52975. /* rest from output */
  52976. from_source = output;
  52977. }
  52978. } else if (wnext < op) {
  52979. /* wrap around window */
  52980. from += wsize + wnext - op;
  52981. op -= wnext;
  52982. if (op < len) {
  52983. /* some from end of window */
  52984. len -= op;
  52985. do {
  52986. output[_out++] = s_window[from++];
  52987. } while (--op);
  52988. from = 0;
  52989. if (wnext < len) {
  52990. /* some from start of window */
  52991. op = wnext;
  52992. len -= op;
  52993. do {
  52994. output[_out++] = s_window[from++];
  52995. } while (--op);
  52996. from = _out - dist;
  52997. /* rest from output */
  52998. from_source = output;
  52999. }
  53000. }
  53001. } else {
  53002. /* contiguous in window */
  53003. from += wnext - op;
  53004. if (op < len) {
  53005. /* some from window */
  53006. len -= op;
  53007. do {
  53008. output[_out++] = s_window[from++];
  53009. } while (--op);
  53010. from = _out - dist;
  53011. /* rest from output */
  53012. from_source = output;
  53013. }
  53014. }
  53015. while (len > 2) {
  53016. output[_out++] = from_source[from++];
  53017. output[_out++] = from_source[from++];
  53018. output[_out++] = from_source[from++];
  53019. len -= 3;
  53020. }
  53021. if (len) {
  53022. output[_out++] = from_source[from++];
  53023. if (len > 1) {
  53024. output[_out++] = from_source[from++];
  53025. }
  53026. }
  53027. } else {
  53028. from = _out - dist;
  53029. /* copy direct from output */
  53030. do {
  53031. /* minimum length is three */
  53032. output[_out++] = output[from++];
  53033. output[_out++] = output[from++];
  53034. output[_out++] = output[from++];
  53035. len -= 3;
  53036. } while (len > 2);
  53037. if (len) {
  53038. output[_out++] = output[from++];
  53039. if (len > 1) {
  53040. output[_out++] = output[from++];
  53041. }
  53042. }
  53043. }
  53044. } else if ((op & 64) === 0) {
  53045. /* 2nd level distance code */
  53046. here = dcode[(here & 0xffff) + (
  53047. /*here.val*/
  53048. hold & (1 << op) - 1)];
  53049. continue dodist;
  53050. } else {
  53051. strm.msg = 'invalid distance code';
  53052. state.mode = BAD;
  53053. break top;
  53054. }
  53055. break; // need to emulate goto via "continue"
  53056. }
  53057. } else if ((op & 64) === 0) {
  53058. /* 2nd level length code */
  53059. here = lcode[(here & 0xffff) + (
  53060. /*here.val*/
  53061. hold & (1 << op) - 1)];
  53062. continue dolen;
  53063. } else if (op & 32) {
  53064. /* end-of-block */
  53065. //Tracevv((stderr, "inflate: end of block\n"));
  53066. state.mode = TYPE;
  53067. break top;
  53068. } else {
  53069. strm.msg = 'invalid literal/length code';
  53070. state.mode = BAD;
  53071. break top;
  53072. }
  53073. break; // need to emulate goto via "continue"
  53074. }
  53075. } while (_in < last && _out < end);
  53076. /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
  53077. len = bits >> 3;
  53078. _in -= len;
  53079. bits -= len << 3;
  53080. hold &= (1 << bits) - 1;
  53081. /* update state and return */
  53082. strm.next_in = _in;
  53083. strm.next_out = _out;
  53084. strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
  53085. strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
  53086. state.hold = hold;
  53087. state.bits = bits;
  53088. return;
  53089. };
  53090. }, {}], 450: [function (require, module, exports) {
  53091. 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  53092. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  53093. //
  53094. // This software is provided 'as-is', without any express or implied
  53095. // warranty. In no event will the authors be held liable for any damages
  53096. // arising from the use of this software.
  53097. //
  53098. // Permission is granted to anyone to use this software for any purpose,
  53099. // including commercial applications, and to alter it and redistribute it
  53100. // freely, subject to the following restrictions:
  53101. //
  53102. // 1. The origin of this software must not be misrepresented; you must not
  53103. // claim that you wrote the original software. If you use this software
  53104. // in a product, an acknowledgment in the product documentation would be
  53105. // appreciated but is not required.
  53106. // 2. Altered source versions must be plainly marked as such, and must not be
  53107. // misrepresented as being the original software.
  53108. // 3. This notice may not be removed or altered from any source distribution.
  53109. var utils = require('../utils/common');
  53110. var adler32 = require('./adler32');
  53111. var crc32 = require('./crc32');
  53112. var inflate_fast = require('./inffast');
  53113. var inflate_table = require('./inftrees');
  53114. var CODES = 0;
  53115. var LENS = 1;
  53116. var DISTS = 2;
  53117. /* Public constants ==========================================================*/
  53118. /* ===========================================================================*/
  53119. /* Allowed flush values; see deflate() and inflate() below for details */
  53120. //var Z_NO_FLUSH = 0;
  53121. //var Z_PARTIAL_FLUSH = 1;
  53122. //var Z_SYNC_FLUSH = 2;
  53123. //var Z_FULL_FLUSH = 3;
  53124. var Z_FINISH = 4;
  53125. var Z_BLOCK = 5;
  53126. var Z_TREES = 6;
  53127. /* Return codes for the compression/decompression functions. Negative values
  53128. * are errors, positive values are used for special but normal events.
  53129. */
  53130. var Z_OK = 0;
  53131. var Z_STREAM_END = 1;
  53132. var Z_NEED_DICT = 2; //var Z_ERRNO = -1;
  53133. var Z_STREAM_ERROR = -2;
  53134. var Z_DATA_ERROR = -3;
  53135. var Z_MEM_ERROR = -4;
  53136. var Z_BUF_ERROR = -5; //var Z_VERSION_ERROR = -6;
  53137. /* The deflate compression method */
  53138. var Z_DEFLATED = 8;
  53139. /* STATES ====================================================================*/
  53140. /* ===========================================================================*/
  53141. var HEAD = 1;
  53142. /* i: waiting for magic header */
  53143. var FLAGS = 2;
  53144. /* i: waiting for method and flags (gzip) */
  53145. var TIME = 3;
  53146. /* i: waiting for modification time (gzip) */
  53147. var OS = 4;
  53148. /* i: waiting for extra flags and operating system (gzip) */
  53149. var EXLEN = 5;
  53150. /* i: waiting for extra length (gzip) */
  53151. var EXTRA = 6;
  53152. /* i: waiting for extra bytes (gzip) */
  53153. var NAME = 7;
  53154. /* i: waiting for end of file name (gzip) */
  53155. var COMMENT = 8;
  53156. /* i: waiting for end of comment (gzip) */
  53157. var HCRC = 9;
  53158. /* i: waiting for header crc (gzip) */
  53159. var DICTID = 10;
  53160. /* i: waiting for dictionary check value */
  53161. var DICT = 11;
  53162. /* waiting for inflateSetDictionary() call */
  53163. var TYPE = 12;
  53164. /* i: waiting for type bits, including last-flag bit */
  53165. var TYPEDO = 13;
  53166. /* i: same, but skip check to exit inflate on new block */
  53167. var STORED = 14;
  53168. /* i: waiting for stored size (length and complement) */
  53169. var COPY_ = 15;
  53170. /* i/o: same as COPY below, but only first time in */
  53171. var COPY = 16;
  53172. /* i/o: waiting for input or output to copy stored block */
  53173. var TABLE = 17;
  53174. /* i: waiting for dynamic block table lengths */
  53175. var LENLENS = 18;
  53176. /* i: waiting for code length code lengths */
  53177. var CODELENS = 19;
  53178. /* i: waiting for length/lit and distance code lengths */
  53179. var LEN_ = 20;
  53180. /* i: same as LEN below, but only first time in */
  53181. var LEN = 21;
  53182. /* i: waiting for length/lit/eob code */
  53183. var LENEXT = 22;
  53184. /* i: waiting for length extra bits */
  53185. var DIST = 23;
  53186. /* i: waiting for distance code */
  53187. var DISTEXT = 24;
  53188. /* i: waiting for distance extra bits */
  53189. var MATCH = 25;
  53190. /* o: waiting for output space to copy string */
  53191. var LIT = 26;
  53192. /* o: waiting for output space to write literal */
  53193. var CHECK = 27;
  53194. /* i: waiting for 32-bit check value */
  53195. var LENGTH = 28;
  53196. /* i: waiting for 32-bit length (gzip) */
  53197. var DONE = 29;
  53198. /* finished check, done -- remain here until reset */
  53199. var BAD = 30;
  53200. /* got a data error -- remain here until reset */
  53201. var MEM = 31;
  53202. /* got an inflate() memory error -- remain here until reset */
  53203. var SYNC = 32;
  53204. /* looking for synchronization bytes to restart inflate() */
  53205. /* ===========================================================================*/
  53206. var ENOUGH_LENS = 852;
  53207. var ENOUGH_DISTS = 592; //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
  53208. var MAX_WBITS = 15;
  53209. /* 32K LZ77 window */
  53210. var DEF_WBITS = MAX_WBITS;
  53211. function zswap32(q) {
  53212. return (q >>> 24 & 0xff) + (q >>> 8 & 0xff00) + ((q & 0xff00) << 8) + ((q & 0xff) << 24);
  53213. }
  53214. function InflateState() {
  53215. this.mode = 0;
  53216. /* current inflate mode */
  53217. this.last = false;
  53218. /* true if processing last block */
  53219. this.wrap = 0;
  53220. /* bit 0 true for zlib, bit 1 true for gzip */
  53221. this.havedict = false;
  53222. /* true if dictionary provided */
  53223. this.flags = 0;
  53224. /* gzip header method and flags (0 if zlib) */
  53225. this.dmax = 0;
  53226. /* zlib header max distance (INFLATE_STRICT) */
  53227. this.check = 0;
  53228. /* protected copy of check value */
  53229. this.total = 0;
  53230. /* protected copy of output count */
  53231. // TODO: may be {}
  53232. this.head = null;
  53233. /* where to save gzip header information */
  53234. /* sliding window */
  53235. this.wbits = 0;
  53236. /* log base 2 of requested window size */
  53237. this.wsize = 0;
  53238. /* window size or zero if not using window */
  53239. this.whave = 0;
  53240. /* valid bytes in the window */
  53241. this.wnext = 0;
  53242. /* window write index */
  53243. this.window = null;
  53244. /* allocated sliding window, if needed */
  53245. /* bit accumulator */
  53246. this.hold = 0;
  53247. /* input bit accumulator */
  53248. this.bits = 0;
  53249. /* number of bits in "in" */
  53250. /* for string and stored block copying */
  53251. this.length = 0;
  53252. /* literal or length of data to copy */
  53253. this.offset = 0;
  53254. /* distance back to copy string from */
  53255. /* for table and code decoding */
  53256. this.extra = 0;
  53257. /* extra bits needed */
  53258. /* fixed and dynamic code tables */
  53259. this.lencode = null;
  53260. /* starting table for length/literal codes */
  53261. this.distcode = null;
  53262. /* starting table for distance codes */
  53263. this.lenbits = 0;
  53264. /* index bits for lencode */
  53265. this.distbits = 0;
  53266. /* index bits for distcode */
  53267. /* dynamic table building */
  53268. this.ncode = 0;
  53269. /* number of code length code lengths */
  53270. this.nlen = 0;
  53271. /* number of length code lengths */
  53272. this.ndist = 0;
  53273. /* number of distance code lengths */
  53274. this.have = 0;
  53275. /* number of code lengths in lens[] */
  53276. this.next = null;
  53277. /* next available space in codes[] */
  53278. this.lens = new utils.Buf16(320);
  53279. /* temporary storage for code lengths */
  53280. this.work = new utils.Buf16(288);
  53281. /* work area for code table building */
  53282. /*
  53283. because we don't have pointers in js, we use lencode and distcode directly
  53284. as buffers so we don't need codes
  53285. */
  53286. //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */
  53287. this.lendyn = null;
  53288. /* dynamic table for length/literal codes (JS specific) */
  53289. this.distdyn = null;
  53290. /* dynamic table for distance codes (JS specific) */
  53291. this.sane = 0;
  53292. /* if false, allow invalid distance too far */
  53293. this.back = 0;
  53294. /* bits back of last unprocessed length/lit */
  53295. this.was = 0;
  53296. /* initial length of match */
  53297. }
  53298. function inflateResetKeep(strm) {
  53299. var state;
  53300. if (!strm || !strm.state) {
  53301. return Z_STREAM_ERROR;
  53302. }
  53303. state = strm.state;
  53304. strm.total_in = strm.total_out = state.total = 0;
  53305. strm.msg = '';
  53306. /*Z_NULL*/
  53307. if (state.wrap) {
  53308. /* to support ill-conceived Java test suite */
  53309. strm.adler = state.wrap & 1;
  53310. }
  53311. state.mode = HEAD;
  53312. state.last = 0;
  53313. state.havedict = 0;
  53314. state.dmax = 32768;
  53315. state.head = null
  53316. /*Z_NULL*/
  53317. ;
  53318. state.hold = 0;
  53319. state.bits = 0; //state.lencode = state.distcode = state.next = state.codes;
  53320. state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
  53321. state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
  53322. state.sane = 1;
  53323. state.back = -1; //Tracev((stderr, "inflate: reset\n"));
  53324. return Z_OK;
  53325. }
  53326. function inflateReset(strm) {
  53327. var state;
  53328. if (!strm || !strm.state) {
  53329. return Z_STREAM_ERROR;
  53330. }
  53331. state = strm.state;
  53332. state.wsize = 0;
  53333. state.whave = 0;
  53334. state.wnext = 0;
  53335. return inflateResetKeep(strm);
  53336. }
  53337. function inflateReset2(strm, windowBits) {
  53338. var wrap;
  53339. var state;
  53340. /* get the state */
  53341. if (!strm || !strm.state) {
  53342. return Z_STREAM_ERROR;
  53343. }
  53344. state = strm.state;
  53345. /* extract wrap request from windowBits parameter */
  53346. if (windowBits < 0) {
  53347. wrap = 0;
  53348. windowBits = -windowBits;
  53349. } else {
  53350. wrap = (windowBits >> 4) + 1;
  53351. if (windowBits < 48) {
  53352. windowBits &= 15;
  53353. }
  53354. }
  53355. /* set number of window bits, free window if different */
  53356. if (windowBits && (windowBits < 8 || windowBits > 15)) {
  53357. return Z_STREAM_ERROR;
  53358. }
  53359. if (state.window !== null && state.wbits !== windowBits) {
  53360. state.window = null;
  53361. }
  53362. /* update state and reset the rest of it */
  53363. state.wrap = wrap;
  53364. state.wbits = windowBits;
  53365. return inflateReset(strm);
  53366. }
  53367. function inflateInit2(strm, windowBits) {
  53368. var ret;
  53369. var state;
  53370. if (!strm) {
  53371. return Z_STREAM_ERROR;
  53372. } //strm.msg = Z_NULL; /* in case we return an error */
  53373. state = new InflateState(); //if (state === Z_NULL) return Z_MEM_ERROR;
  53374. //Tracev((stderr, "inflate: allocated\n"));
  53375. strm.state = state;
  53376. state.window = null
  53377. /*Z_NULL*/
  53378. ;
  53379. ret = inflateReset2(strm, windowBits);
  53380. if (ret !== Z_OK) {
  53381. strm.state = null
  53382. /*Z_NULL*/
  53383. ;
  53384. }
  53385. return ret;
  53386. }
  53387. function inflateInit(strm) {
  53388. return inflateInit2(strm, DEF_WBITS);
  53389. }
  53390. /*
  53391. Return state with length and distance decoding tables and index sizes set to
  53392. fixed code decoding. Normally this returns fixed tables from inffixed.h.
  53393. If BUILDFIXED is defined, then instead this routine builds the tables the
  53394. first time it's called, and returns those tables the first time and
  53395. thereafter. This reduces the size of the code by about 2K bytes, in
  53396. exchange for a little execution time. However, BUILDFIXED should not be
  53397. used for threaded applications, since the rewriting of the tables and virgin
  53398. may not be thread-safe.
  53399. */
  53400. var virgin = true;
  53401. var lenfix, distfix; // We have no pointers in JS, so keep tables separate
  53402. function fixedtables(state) {
  53403. /* build fixed huffman tables if first call (may not be thread safe) */
  53404. if (virgin) {
  53405. var sym;
  53406. lenfix = new utils.Buf32(512);
  53407. distfix = new utils.Buf32(32);
  53408. /* literal/length table */
  53409. sym = 0;
  53410. while (sym < 144) {
  53411. state.lens[sym++] = 8;
  53412. }
  53413. while (sym < 256) {
  53414. state.lens[sym++] = 9;
  53415. }
  53416. while (sym < 280) {
  53417. state.lens[sym++] = 7;
  53418. }
  53419. while (sym < 288) {
  53420. state.lens[sym++] = 8;
  53421. }
  53422. inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, {
  53423. bits: 9
  53424. });
  53425. /* distance table */
  53426. sym = 0;
  53427. while (sym < 32) {
  53428. state.lens[sym++] = 5;
  53429. }
  53430. inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, {
  53431. bits: 5
  53432. });
  53433. /* do this just once */
  53434. virgin = false;
  53435. }
  53436. state.lencode = lenfix;
  53437. state.lenbits = 9;
  53438. state.distcode = distfix;
  53439. state.distbits = 5;
  53440. }
  53441. /*
  53442. Update the window with the last wsize (normally 32K) bytes written before
  53443. returning. If window does not exist yet, create it. This is only called
  53444. when a window is already in use, or when output has been written during this
  53445. inflate call, but the end of the deflate stream has not been reached yet.
  53446. It is also called to create a window for dictionary data when a dictionary
  53447. is loaded.
  53448. Providing output buffers larger than 32K to inflate() should provide a speed
  53449. advantage, since only the last 32K of output is copied to the sliding window
  53450. upon return from inflate(), and since all distances after the first 32K of
  53451. output will fall in the output data, making match copies simpler and faster.
  53452. The advantage may be dependent on the size of the processor's data caches.
  53453. */
  53454. function updatewindow(strm, src, end, copy) {
  53455. var dist;
  53456. var state = strm.state;
  53457. /* if it hasn't been done already, allocate space for the window */
  53458. if (state.window === null) {
  53459. state.wsize = 1 << state.wbits;
  53460. state.wnext = 0;
  53461. state.whave = 0;
  53462. state.window = new utils.Buf8(state.wsize);
  53463. }
  53464. /* copy state->wsize or less output bytes into the circular window */
  53465. if (copy >= state.wsize) {
  53466. utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
  53467. state.wnext = 0;
  53468. state.whave = state.wsize;
  53469. } else {
  53470. dist = state.wsize - state.wnext;
  53471. if (dist > copy) {
  53472. dist = copy;
  53473. } //zmemcpy(state->window + state->wnext, end - copy, dist);
  53474. utils.arraySet(state.window, src, end - copy, dist, state.wnext);
  53475. copy -= dist;
  53476. if (copy) {
  53477. //zmemcpy(state->window, end - copy, copy);
  53478. utils.arraySet(state.window, src, end - copy, copy, 0);
  53479. state.wnext = copy;
  53480. state.whave = state.wsize;
  53481. } else {
  53482. state.wnext += dist;
  53483. if (state.wnext === state.wsize) {
  53484. state.wnext = 0;
  53485. }
  53486. if (state.whave < state.wsize) {
  53487. state.whave += dist;
  53488. }
  53489. }
  53490. }
  53491. return 0;
  53492. }
  53493. function inflate(strm, flush) {
  53494. var state;
  53495. var input, output; // input/output buffers
  53496. var next;
  53497. /* next input INDEX */
  53498. var put;
  53499. /* next output INDEX */
  53500. var have, left;
  53501. /* available input and output */
  53502. var hold;
  53503. /* bit buffer */
  53504. var bits;
  53505. /* bits in bit buffer */
  53506. var _in, _out;
  53507. /* save starting available input and output */
  53508. var copy;
  53509. /* number of stored or match bytes to copy */
  53510. var from;
  53511. /* where to copy match bytes from */
  53512. var from_source;
  53513. var here = 0;
  53514. /* current decoding table entry */
  53515. var here_bits, here_op, here_val; // paked "here" denormalized (JS specific)
  53516. //var last; /* parent table entry */
  53517. var last_bits, last_op, last_val; // paked "last" denormalized (JS specific)
  53518. var len;
  53519. /* length to copy for repeats, bits to drop */
  53520. var ret;
  53521. /* return code */
  53522. var hbuf = new utils.Buf8(4);
  53523. /* buffer for gzip header crc calculation */
  53524. var opts;
  53525. var n; // temporary var for NEED_BITS
  53526. var order =
  53527. /* permutation of code lengths */
  53528. [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  53529. if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
  53530. return Z_STREAM_ERROR;
  53531. }
  53532. state = strm.state;
  53533. if (state.mode === TYPE) {
  53534. state.mode = TYPEDO;
  53535. }
  53536. /* skip check */
  53537. //--- LOAD() ---
  53538. put = strm.next_out;
  53539. output = strm.output;
  53540. left = strm.avail_out;
  53541. next = strm.next_in;
  53542. input = strm.input;
  53543. have = strm.avail_in;
  53544. hold = state.hold;
  53545. bits = state.bits; //---
  53546. _in = have;
  53547. _out = left;
  53548. ret = Z_OK;
  53549. inf_leave: // goto emulation
  53550. for (; ;) {
  53551. switch (state.mode) {
  53552. case HEAD:
  53553. if (state.wrap === 0) {
  53554. state.mode = TYPEDO;
  53555. break;
  53556. } //=== NEEDBITS(16);
  53557. while (bits < 16) {
  53558. if (have === 0) {
  53559. break inf_leave;
  53560. }
  53561. have--;
  53562. hold += input[next++] << bits;
  53563. bits += 8;
  53564. } //===//
  53565. if (state.wrap & 2 && hold === 0x8b1f) {
  53566. /* gzip header */
  53567. state.check = 0
  53568. /*crc32(0L, Z_NULL, 0)*/
  53569. ; //=== CRC2(state.check, hold);
  53570. hbuf[0] = hold & 0xff;
  53571. hbuf[1] = hold >>> 8 & 0xff;
  53572. state.check = crc32(state.check, hbuf, 2, 0); //===//
  53573. //=== INITBITS();
  53574. hold = 0;
  53575. bits = 0; //===//
  53576. state.mode = FLAGS;
  53577. break;
  53578. }
  53579. state.flags = 0;
  53580. /* expect zlib header */
  53581. if (state.head) {
  53582. state.head.done = false;
  53583. }
  53584. if (!(state.wrap & 1) ||
  53585. /* check if zlib header allowed */
  53586. (((hold & 0xff) <<
  53587. /*BITS(8)*/
  53588. 8) + (hold >> 8)) % 31) {
  53589. strm.msg = 'incorrect header check';
  53590. state.mode = BAD;
  53591. break;
  53592. }
  53593. if ((hold & 0x0f) !==
  53594. /*BITS(4)*/
  53595. Z_DEFLATED) {
  53596. strm.msg = 'unknown compression method';
  53597. state.mode = BAD;
  53598. break;
  53599. } //--- DROPBITS(4) ---//
  53600. hold >>>= 4;
  53601. bits -= 4; //---//
  53602. len = (hold & 0x0f) +
  53603. /*BITS(4)*/
  53604. 8;
  53605. if (state.wbits === 0) {
  53606. state.wbits = len;
  53607. } else if (len > state.wbits) {
  53608. strm.msg = 'invalid window size';
  53609. state.mode = BAD;
  53610. break;
  53611. }
  53612. state.dmax = 1 << len; //Tracev((stderr, "inflate: zlib header ok\n"));
  53613. strm.adler = state.check = 1
  53614. /*adler32(0L, Z_NULL, 0)*/
  53615. ;
  53616. state.mode = hold & 0x200 ? DICTID : TYPE; //=== INITBITS();
  53617. hold = 0;
  53618. bits = 0; //===//
  53619. break;
  53620. case FLAGS:
  53621. //=== NEEDBITS(16); */
  53622. while (bits < 16) {
  53623. if (have === 0) {
  53624. break inf_leave;
  53625. }
  53626. have--;
  53627. hold += input[next++] << bits;
  53628. bits += 8;
  53629. } //===//
  53630. state.flags = hold;
  53631. if ((state.flags & 0xff) !== Z_DEFLATED) {
  53632. strm.msg = 'unknown compression method';
  53633. state.mode = BAD;
  53634. break;
  53635. }
  53636. if (state.flags & 0xe000) {
  53637. strm.msg = 'unknown header flags set';
  53638. state.mode = BAD;
  53639. break;
  53640. }
  53641. if (state.head) {
  53642. state.head.text = hold >> 8 & 1;
  53643. }
  53644. if (state.flags & 0x0200) {
  53645. //=== CRC2(state.check, hold);
  53646. hbuf[0] = hold & 0xff;
  53647. hbuf[1] = hold >>> 8 & 0xff;
  53648. state.check = crc32(state.check, hbuf, 2, 0); //===//
  53649. } //=== INITBITS();
  53650. hold = 0;
  53651. bits = 0; //===//
  53652. state.mode = TIME;
  53653. /* falls through */
  53654. case TIME:
  53655. //=== NEEDBITS(32); */
  53656. while (bits < 32) {
  53657. if (have === 0) {
  53658. break inf_leave;
  53659. }
  53660. have--;
  53661. hold += input[next++] << bits;
  53662. bits += 8;
  53663. } //===//
  53664. if (state.head) {
  53665. state.head.time = hold;
  53666. }
  53667. if (state.flags & 0x0200) {
  53668. //=== CRC4(state.check, hold)
  53669. hbuf[0] = hold & 0xff;
  53670. hbuf[1] = hold >>> 8 & 0xff;
  53671. hbuf[2] = hold >>> 16 & 0xff;
  53672. hbuf[3] = hold >>> 24 & 0xff;
  53673. state.check = crc32(state.check, hbuf, 4, 0); //===
  53674. } //=== INITBITS();
  53675. hold = 0;
  53676. bits = 0; //===//
  53677. state.mode = OS;
  53678. /* falls through */
  53679. case OS:
  53680. //=== NEEDBITS(16); */
  53681. while (bits < 16) {
  53682. if (have === 0) {
  53683. break inf_leave;
  53684. }
  53685. have--;
  53686. hold += input[next++] << bits;
  53687. bits += 8;
  53688. } //===//
  53689. if (state.head) {
  53690. state.head.xflags = hold & 0xff;
  53691. state.head.os = hold >> 8;
  53692. }
  53693. if (state.flags & 0x0200) {
  53694. //=== CRC2(state.check, hold);
  53695. hbuf[0] = hold & 0xff;
  53696. hbuf[1] = hold >>> 8 & 0xff;
  53697. state.check = crc32(state.check, hbuf, 2, 0); //===//
  53698. } //=== INITBITS();
  53699. hold = 0;
  53700. bits = 0; //===//
  53701. state.mode = EXLEN;
  53702. /* falls through */
  53703. case EXLEN:
  53704. if (state.flags & 0x0400) {
  53705. //=== NEEDBITS(16); */
  53706. while (bits < 16) {
  53707. if (have === 0) {
  53708. break inf_leave;
  53709. }
  53710. have--;
  53711. hold += input[next++] << bits;
  53712. bits += 8;
  53713. } //===//
  53714. state.length = hold;
  53715. if (state.head) {
  53716. state.head.extra_len = hold;
  53717. }
  53718. if (state.flags & 0x0200) {
  53719. //=== CRC2(state.check, hold);
  53720. hbuf[0] = hold & 0xff;
  53721. hbuf[1] = hold >>> 8 & 0xff;
  53722. state.check = crc32(state.check, hbuf, 2, 0); //===//
  53723. } //=== INITBITS();
  53724. hold = 0;
  53725. bits = 0; //===//
  53726. } else if (state.head) {
  53727. state.head.extra = null
  53728. /*Z_NULL*/
  53729. ;
  53730. }
  53731. state.mode = EXTRA;
  53732. /* falls through */
  53733. case EXTRA:
  53734. if (state.flags & 0x0400) {
  53735. copy = state.length;
  53736. if (copy > have) {
  53737. copy = have;
  53738. }
  53739. if (copy) {
  53740. if (state.head) {
  53741. len = state.head.extra_len - state.length;
  53742. if (!state.head.extra) {
  53743. // Use untyped array for more convenient processing later
  53744. state.head.extra = new Array(state.head.extra_len);
  53745. }
  53746. utils.arraySet(state.head.extra, input, next, // extra field is limited to 65536 bytes
  53747. // - no need for additional size check
  53748. copy,
  53749. /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
  53750. len); //zmemcpy(state.head.extra + len, next,
  53751. // len + copy > state.head.extra_max ?
  53752. // state.head.extra_max - len : copy);
  53753. }
  53754. if (state.flags & 0x0200) {
  53755. state.check = crc32(state.check, input, copy, next);
  53756. }
  53757. have -= copy;
  53758. next += copy;
  53759. state.length -= copy;
  53760. }
  53761. if (state.length) {
  53762. break inf_leave;
  53763. }
  53764. }
  53765. state.length = 0;
  53766. state.mode = NAME;
  53767. /* falls through */
  53768. case NAME:
  53769. if (state.flags & 0x0800) {
  53770. if (have === 0) {
  53771. break inf_leave;
  53772. }
  53773. copy = 0;
  53774. do {
  53775. // TODO: 2 or 1 bytes?
  53776. len = input[next + copy++];
  53777. /* use constant limit because in js we should not preallocate memory */
  53778. if (state.head && len && state.length < 65536
  53779. /*state.head.name_max*/
  53780. ) {
  53781. state.head.name += String.fromCharCode(len);
  53782. }
  53783. } while (len && copy < have);
  53784. if (state.flags & 0x0200) {
  53785. state.check = crc32(state.check, input, copy, next);
  53786. }
  53787. have -= copy;
  53788. next += copy;
  53789. if (len) {
  53790. break inf_leave;
  53791. }
  53792. } else if (state.head) {
  53793. state.head.name = null;
  53794. }
  53795. state.length = 0;
  53796. state.mode = COMMENT;
  53797. /* falls through */
  53798. case COMMENT:
  53799. if (state.flags & 0x1000) {
  53800. if (have === 0) {
  53801. break inf_leave;
  53802. }
  53803. copy = 0;
  53804. do {
  53805. len = input[next + copy++];
  53806. /* use constant limit because in js we should not preallocate memory */
  53807. if (state.head && len && state.length < 65536
  53808. /*state.head.comm_max*/
  53809. ) {
  53810. state.head.comment += String.fromCharCode(len);
  53811. }
  53812. } while (len && copy < have);
  53813. if (state.flags & 0x0200) {
  53814. state.check = crc32(state.check, input, copy, next);
  53815. }
  53816. have -= copy;
  53817. next += copy;
  53818. if (len) {
  53819. break inf_leave;
  53820. }
  53821. } else if (state.head) {
  53822. state.head.comment = null;
  53823. }
  53824. state.mode = HCRC;
  53825. /* falls through */
  53826. case HCRC:
  53827. if (state.flags & 0x0200) {
  53828. //=== NEEDBITS(16); */
  53829. while (bits < 16) {
  53830. if (have === 0) {
  53831. break inf_leave;
  53832. }
  53833. have--;
  53834. hold += input[next++] << bits;
  53835. bits += 8;
  53836. } //===//
  53837. if (hold !== (state.check & 0xffff)) {
  53838. strm.msg = 'header crc mismatch';
  53839. state.mode = BAD;
  53840. break;
  53841. } //=== INITBITS();
  53842. hold = 0;
  53843. bits = 0; //===//
  53844. }
  53845. if (state.head) {
  53846. state.head.hcrc = state.flags >> 9 & 1;
  53847. state.head.done = true;
  53848. }
  53849. strm.adler = state.check = 0;
  53850. state.mode = TYPE;
  53851. break;
  53852. case DICTID:
  53853. //=== NEEDBITS(32); */
  53854. while (bits < 32) {
  53855. if (have === 0) {
  53856. break inf_leave;
  53857. }
  53858. have--;
  53859. hold += input[next++] << bits;
  53860. bits += 8;
  53861. } //===//
  53862. strm.adler = state.check = zswap32(hold); //=== INITBITS();
  53863. hold = 0;
  53864. bits = 0; //===//
  53865. state.mode = DICT;
  53866. /* falls through */
  53867. case DICT:
  53868. if (state.havedict === 0) {
  53869. //--- RESTORE() ---
  53870. strm.next_out = put;
  53871. strm.avail_out = left;
  53872. strm.next_in = next;
  53873. strm.avail_in = have;
  53874. state.hold = hold;
  53875. state.bits = bits; //---
  53876. return Z_NEED_DICT;
  53877. }
  53878. strm.adler = state.check = 1
  53879. /*adler32(0L, Z_NULL, 0)*/
  53880. ;
  53881. state.mode = TYPE;
  53882. /* falls through */
  53883. case TYPE:
  53884. if (flush === Z_BLOCK || flush === Z_TREES) {
  53885. break inf_leave;
  53886. }
  53887. /* falls through */
  53888. case TYPEDO:
  53889. if (state.last) {
  53890. //--- BYTEBITS() ---//
  53891. hold >>>= bits & 7;
  53892. bits -= bits & 7; //---//
  53893. state.mode = CHECK;
  53894. break;
  53895. } //=== NEEDBITS(3); */
  53896. while (bits < 3) {
  53897. if (have === 0) {
  53898. break inf_leave;
  53899. }
  53900. have--;
  53901. hold += input[next++] << bits;
  53902. bits += 8;
  53903. } //===//
  53904. state.last = hold & 0x01
  53905. /*BITS(1)*/
  53906. ; //--- DROPBITS(1) ---//
  53907. hold >>>= 1;
  53908. bits -= 1; //---//
  53909. switch (hold & 0x03) {
  53910. /*BITS(2)*/
  53911. case 0:
  53912. /* stored block */
  53913. //Tracev((stderr, "inflate: stored block%s\n",
  53914. // state.last ? " (last)" : ""));
  53915. state.mode = STORED;
  53916. break;
  53917. case 1:
  53918. /* fixed block */
  53919. fixedtables(state); //Tracev((stderr, "inflate: fixed codes block%s\n",
  53920. // state.last ? " (last)" : ""));
  53921. state.mode = LEN_;
  53922. /* decode codes */
  53923. if (flush === Z_TREES) {
  53924. //--- DROPBITS(2) ---//
  53925. hold >>>= 2;
  53926. bits -= 2; //---//
  53927. break inf_leave;
  53928. }
  53929. break;
  53930. case 2:
  53931. /* dynamic block */
  53932. //Tracev((stderr, "inflate: dynamic codes block%s\n",
  53933. // state.last ? " (last)" : ""));
  53934. state.mode = TABLE;
  53935. break;
  53936. case 3:
  53937. strm.msg = 'invalid block type';
  53938. state.mode = BAD;
  53939. } //--- DROPBITS(2) ---//
  53940. hold >>>= 2;
  53941. bits -= 2; //---//
  53942. break;
  53943. case STORED:
  53944. //--- BYTEBITS() ---// /* go to byte boundary */
  53945. hold >>>= bits & 7;
  53946. bits -= bits & 7; //---//
  53947. //=== NEEDBITS(32); */
  53948. while (bits < 32) {
  53949. if (have === 0) {
  53950. break inf_leave;
  53951. }
  53952. have--;
  53953. hold += input[next++] << bits;
  53954. bits += 8;
  53955. } //===//
  53956. if ((hold & 0xffff) !== (hold >>> 16 ^ 0xffff)) {
  53957. strm.msg = 'invalid stored block lengths';
  53958. state.mode = BAD;
  53959. break;
  53960. }
  53961. state.length = hold & 0xffff; //Tracev((stderr, "inflate: stored length %u\n",
  53962. // state.length));
  53963. //=== INITBITS();
  53964. hold = 0;
  53965. bits = 0; //===//
  53966. state.mode = COPY_;
  53967. if (flush === Z_TREES) {
  53968. break inf_leave;
  53969. }
  53970. /* falls through */
  53971. case COPY_:
  53972. state.mode = COPY;
  53973. /* falls through */
  53974. case COPY:
  53975. copy = state.length;
  53976. if (copy) {
  53977. if (copy > have) {
  53978. copy = have;
  53979. }
  53980. if (copy > left) {
  53981. copy = left;
  53982. }
  53983. if (copy === 0) {
  53984. break inf_leave;
  53985. } //--- zmemcpy(put, next, copy); ---
  53986. utils.arraySet(output, input, next, copy, put); //---//
  53987. have -= copy;
  53988. next += copy;
  53989. left -= copy;
  53990. put += copy;
  53991. state.length -= copy;
  53992. break;
  53993. } //Tracev((stderr, "inflate: stored end\n"));
  53994. state.mode = TYPE;
  53995. break;
  53996. case TABLE:
  53997. //=== NEEDBITS(14); */
  53998. while (bits < 14) {
  53999. if (have === 0) {
  54000. break inf_leave;
  54001. }
  54002. have--;
  54003. hold += input[next++] << bits;
  54004. bits += 8;
  54005. } //===//
  54006. state.nlen = (hold & 0x1f) +
  54007. /*BITS(5)*/
  54008. 257; //--- DROPBITS(5) ---//
  54009. hold >>>= 5;
  54010. bits -= 5; //---//
  54011. state.ndist = (hold & 0x1f) +
  54012. /*BITS(5)*/
  54013. 1; //--- DROPBITS(5) ---//
  54014. hold >>>= 5;
  54015. bits -= 5; //---//
  54016. state.ncode = (hold & 0x0f) +
  54017. /*BITS(4)*/
  54018. 4; //--- DROPBITS(4) ---//
  54019. hold >>>= 4;
  54020. bits -= 4; //---//
  54021. //#ifndef PKZIP_BUG_WORKAROUND
  54022. if (state.nlen > 286 || state.ndist > 30) {
  54023. strm.msg = 'too many length or distance symbols';
  54024. state.mode = BAD;
  54025. break;
  54026. } //#endif
  54027. //Tracev((stderr, "inflate: table sizes ok\n"));
  54028. state.have = 0;
  54029. state.mode = LENLENS;
  54030. /* falls through */
  54031. case LENLENS:
  54032. while (state.have < state.ncode) {
  54033. //=== NEEDBITS(3);
  54034. while (bits < 3) {
  54035. if (have === 0) {
  54036. break inf_leave;
  54037. }
  54038. have--;
  54039. hold += input[next++] << bits;
  54040. bits += 8;
  54041. } //===//
  54042. state.lens[order[state.have++]] = hold & 0x07; //BITS(3);
  54043. //--- DROPBITS(3) ---//
  54044. hold >>>= 3;
  54045. bits -= 3; //---//
  54046. }
  54047. while (state.have < 19) {
  54048. state.lens[order[state.have++]] = 0;
  54049. } // We have separate tables & no pointers. 2 commented lines below not needed.
  54050. //state.next = state.codes;
  54051. //state.lencode = state.next;
  54052. // Switch to use dynamic table
  54053. state.lencode = state.lendyn;
  54054. state.lenbits = 7;
  54055. opts = {
  54056. bits: state.lenbits
  54057. };
  54058. ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
  54059. state.lenbits = opts.bits;
  54060. if (ret) {
  54061. strm.msg = 'invalid code lengths set';
  54062. state.mode = BAD;
  54063. break;
  54064. } //Tracev((stderr, "inflate: code lengths ok\n"));
  54065. state.have = 0;
  54066. state.mode = CODELENS;
  54067. /* falls through */
  54068. case CODELENS:
  54069. while (state.have < state.nlen + state.ndist) {
  54070. for (; ;) {
  54071. here = state.lencode[hold & (1 << state.lenbits) - 1];
  54072. /*BITS(state.lenbits)*/
  54073. here_bits = here >>> 24;
  54074. here_op = here >>> 16 & 0xff;
  54075. here_val = here & 0xffff;
  54076. if (here_bits <= bits) {
  54077. break;
  54078. } //--- PULLBYTE() ---//
  54079. if (have === 0) {
  54080. break inf_leave;
  54081. }
  54082. have--;
  54083. hold += input[next++] << bits;
  54084. bits += 8; //---//
  54085. }
  54086. if (here_val < 16) {
  54087. //--- DROPBITS(here.bits) ---//
  54088. hold >>>= here_bits;
  54089. bits -= here_bits; //---//
  54090. state.lens[state.have++] = here_val;
  54091. } else {
  54092. if (here_val === 16) {
  54093. //=== NEEDBITS(here.bits + 2);
  54094. n = here_bits + 2;
  54095. while (bits < n) {
  54096. if (have === 0) {
  54097. break inf_leave;
  54098. }
  54099. have--;
  54100. hold += input[next++] << bits;
  54101. bits += 8;
  54102. } //===//
  54103. //--- DROPBITS(here.bits) ---//
  54104. hold >>>= here_bits;
  54105. bits -= here_bits; //---//
  54106. if (state.have === 0) {
  54107. strm.msg = 'invalid bit length repeat';
  54108. state.mode = BAD;
  54109. break;
  54110. }
  54111. len = state.lens[state.have - 1];
  54112. copy = 3 + (hold & 0x03); //BITS(2);
  54113. //--- DROPBITS(2) ---//
  54114. hold >>>= 2;
  54115. bits -= 2; //---//
  54116. } else if (here_val === 17) {
  54117. //=== NEEDBITS(here.bits + 3);
  54118. n = here_bits + 3;
  54119. while (bits < n) {
  54120. if (have === 0) {
  54121. break inf_leave;
  54122. }
  54123. have--;
  54124. hold += input[next++] << bits;
  54125. bits += 8;
  54126. } //===//
  54127. //--- DROPBITS(here.bits) ---//
  54128. hold >>>= here_bits;
  54129. bits -= here_bits; //---//
  54130. len = 0;
  54131. copy = 3 + (hold & 0x07); //BITS(3);
  54132. //--- DROPBITS(3) ---//
  54133. hold >>>= 3;
  54134. bits -= 3; //---//
  54135. } else {
  54136. //=== NEEDBITS(here.bits + 7);
  54137. n = here_bits + 7;
  54138. while (bits < n) {
  54139. if (have === 0) {
  54140. break inf_leave;
  54141. }
  54142. have--;
  54143. hold += input[next++] << bits;
  54144. bits += 8;
  54145. } //===//
  54146. //--- DROPBITS(here.bits) ---//
  54147. hold >>>= here_bits;
  54148. bits -= here_bits; //---//
  54149. len = 0;
  54150. copy = 11 + (hold & 0x7f); //BITS(7);
  54151. //--- DROPBITS(7) ---//
  54152. hold >>>= 7;
  54153. bits -= 7; //---//
  54154. }
  54155. if (state.have + copy > state.nlen + state.ndist) {
  54156. strm.msg = 'invalid bit length repeat';
  54157. state.mode = BAD;
  54158. break;
  54159. }
  54160. while (copy--) {
  54161. state.lens[state.have++] = len;
  54162. }
  54163. }
  54164. }
  54165. /* handle error breaks in while */
  54166. if (state.mode === BAD) {
  54167. break;
  54168. }
  54169. /* check for end-of-block code (better have one) */
  54170. if (state.lens[256] === 0) {
  54171. strm.msg = 'invalid code -- missing end-of-block';
  54172. state.mode = BAD;
  54173. break;
  54174. }
  54175. /* build code tables -- note: do not change the lenbits or distbits
  54176. values here (9 and 6) without reading the comments in inftrees.h
  54177. concerning the ENOUGH constants, which depend on those values */
  54178. state.lenbits = 9;
  54179. opts = {
  54180. bits: state.lenbits
  54181. };
  54182. ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); // We have separate tables & no pointers. 2 commented lines below not needed.
  54183. // state.next_index = opts.table_index;
  54184. state.lenbits = opts.bits; // state.lencode = state.next;
  54185. if (ret) {
  54186. strm.msg = 'invalid literal/lengths set';
  54187. state.mode = BAD;
  54188. break;
  54189. }
  54190. state.distbits = 6; //state.distcode.copy(state.codes);
  54191. // Switch to use dynamic table
  54192. state.distcode = state.distdyn;
  54193. opts = {
  54194. bits: state.distbits
  54195. };
  54196. ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); // We have separate tables & no pointers. 2 commented lines below not needed.
  54197. // state.next_index = opts.table_index;
  54198. state.distbits = opts.bits; // state.distcode = state.next;
  54199. if (ret) {
  54200. strm.msg = 'invalid distances set';
  54201. state.mode = BAD;
  54202. break;
  54203. } //Tracev((stderr, 'inflate: codes ok\n'));
  54204. state.mode = LEN_;
  54205. if (flush === Z_TREES) {
  54206. break inf_leave;
  54207. }
  54208. /* falls through */
  54209. case LEN_:
  54210. state.mode = LEN;
  54211. /* falls through */
  54212. case LEN:
  54213. if (have >= 6 && left >= 258) {
  54214. //--- RESTORE() ---
  54215. strm.next_out = put;
  54216. strm.avail_out = left;
  54217. strm.next_in = next;
  54218. strm.avail_in = have;
  54219. state.hold = hold;
  54220. state.bits = bits; //---
  54221. inflate_fast(strm, _out); //--- LOAD() ---
  54222. put = strm.next_out;
  54223. output = strm.output;
  54224. left = strm.avail_out;
  54225. next = strm.next_in;
  54226. input = strm.input;
  54227. have = strm.avail_in;
  54228. hold = state.hold;
  54229. bits = state.bits; //---
  54230. if (state.mode === TYPE) {
  54231. state.back = -1;
  54232. }
  54233. break;
  54234. }
  54235. state.back = 0;
  54236. for (; ;) {
  54237. here = state.lencode[hold & (1 << state.lenbits) - 1];
  54238. /*BITS(state.lenbits)*/
  54239. here_bits = here >>> 24;
  54240. here_op = here >>> 16 & 0xff;
  54241. here_val = here & 0xffff;
  54242. if (here_bits <= bits) {
  54243. break;
  54244. } //--- PULLBYTE() ---//
  54245. if (have === 0) {
  54246. break inf_leave;
  54247. }
  54248. have--;
  54249. hold += input[next++] << bits;
  54250. bits += 8; //---//
  54251. }
  54252. if (here_op && (here_op & 0xf0) === 0) {
  54253. last_bits = here_bits;
  54254. last_op = here_op;
  54255. last_val = here_val;
  54256. for (; ;) {
  54257. here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >>
  54258. /*BITS(last.bits + last.op)*/
  54259. last_bits)];
  54260. here_bits = here >>> 24;
  54261. here_op = here >>> 16 & 0xff;
  54262. here_val = here & 0xffff;
  54263. if (last_bits + here_bits <= bits) {
  54264. break;
  54265. } //--- PULLBYTE() ---//
  54266. if (have === 0) {
  54267. break inf_leave;
  54268. }
  54269. have--;
  54270. hold += input[next++] << bits;
  54271. bits += 8; //---//
  54272. } //--- DROPBITS(last.bits) ---//
  54273. hold >>>= last_bits;
  54274. bits -= last_bits; //---//
  54275. state.back += last_bits;
  54276. } //--- DROPBITS(here.bits) ---//
  54277. hold >>>= here_bits;
  54278. bits -= here_bits; //---//
  54279. state.back += here_bits;
  54280. state.length = here_val;
  54281. if (here_op === 0) {
  54282. //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
  54283. // "inflate: literal '%c'\n" :
  54284. // "inflate: literal 0x%02x\n", here.val));
  54285. state.mode = LIT;
  54286. break;
  54287. }
  54288. if (here_op & 32) {
  54289. //Tracevv((stderr, "inflate: end of block\n"));
  54290. state.back = -1;
  54291. state.mode = TYPE;
  54292. break;
  54293. }
  54294. if (here_op & 64) {
  54295. strm.msg = 'invalid literal/length code';
  54296. state.mode = BAD;
  54297. break;
  54298. }
  54299. state.extra = here_op & 15;
  54300. state.mode = LENEXT;
  54301. /* falls through */
  54302. case LENEXT:
  54303. if (state.extra) {
  54304. //=== NEEDBITS(state.extra);
  54305. n = state.extra;
  54306. while (bits < n) {
  54307. if (have === 0) {
  54308. break inf_leave;
  54309. }
  54310. have--;
  54311. hold += input[next++] << bits;
  54312. bits += 8;
  54313. } //===//
  54314. state.length += hold & (1 << state.extra) - 1
  54315. /*BITS(state.extra)*/
  54316. ; //--- DROPBITS(state.extra) ---//
  54317. hold >>>= state.extra;
  54318. bits -= state.extra; //---//
  54319. state.back += state.extra;
  54320. } //Tracevv((stderr, "inflate: length %u\n", state.length));
  54321. state.was = state.length;
  54322. state.mode = DIST;
  54323. /* falls through */
  54324. case DIST:
  54325. for (; ;) {
  54326. here = state.distcode[hold & (1 << state.distbits) - 1];
  54327. /*BITS(state.distbits)*/
  54328. here_bits = here >>> 24;
  54329. here_op = here >>> 16 & 0xff;
  54330. here_val = here & 0xffff;
  54331. if (here_bits <= bits) {
  54332. break;
  54333. } //--- PULLBYTE() ---//
  54334. if (have === 0) {
  54335. break inf_leave;
  54336. }
  54337. have--;
  54338. hold += input[next++] << bits;
  54339. bits += 8; //---//
  54340. }
  54341. if ((here_op & 0xf0) === 0) {
  54342. last_bits = here_bits;
  54343. last_op = here_op;
  54344. last_val = here_val;
  54345. for (; ;) {
  54346. here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >>
  54347. /*BITS(last.bits + last.op)*/
  54348. last_bits)];
  54349. here_bits = here >>> 24;
  54350. here_op = here >>> 16 & 0xff;
  54351. here_val = here & 0xffff;
  54352. if (last_bits + here_bits <= bits) {
  54353. break;
  54354. } //--- PULLBYTE() ---//
  54355. if (have === 0) {
  54356. break inf_leave;
  54357. }
  54358. have--;
  54359. hold += input[next++] << bits;
  54360. bits += 8; //---//
  54361. } //--- DROPBITS(last.bits) ---//
  54362. hold >>>= last_bits;
  54363. bits -= last_bits; //---//
  54364. state.back += last_bits;
  54365. } //--- DROPBITS(here.bits) ---//
  54366. hold >>>= here_bits;
  54367. bits -= here_bits; //---//
  54368. state.back += here_bits;
  54369. if (here_op & 64) {
  54370. strm.msg = 'invalid distance code';
  54371. state.mode = BAD;
  54372. break;
  54373. }
  54374. state.offset = here_val;
  54375. state.extra = here_op & 15;
  54376. state.mode = DISTEXT;
  54377. /* falls through */
  54378. case DISTEXT:
  54379. if (state.extra) {
  54380. //=== NEEDBITS(state.extra);
  54381. n = state.extra;
  54382. while (bits < n) {
  54383. if (have === 0) {
  54384. break inf_leave;
  54385. }
  54386. have--;
  54387. hold += input[next++] << bits;
  54388. bits += 8;
  54389. } //===//
  54390. state.offset += hold & (1 << state.extra) - 1
  54391. /*BITS(state.extra)*/
  54392. ; //--- DROPBITS(state.extra) ---//
  54393. hold >>>= state.extra;
  54394. bits -= state.extra; //---//
  54395. state.back += state.extra;
  54396. } //#ifdef INFLATE_STRICT
  54397. if (state.offset > state.dmax) {
  54398. strm.msg = 'invalid distance too far back';
  54399. state.mode = BAD;
  54400. break;
  54401. } //#endif
  54402. //Tracevv((stderr, "inflate: distance %u\n", state.offset));
  54403. state.mode = MATCH;
  54404. /* falls through */
  54405. case MATCH:
  54406. if (left === 0) {
  54407. break inf_leave;
  54408. }
  54409. copy = _out - left;
  54410. if (state.offset > copy) {
  54411. /* copy from window */
  54412. copy = state.offset - copy;
  54413. if (copy > state.whave) {
  54414. if (state.sane) {
  54415. strm.msg = 'invalid distance too far back';
  54416. state.mode = BAD;
  54417. break;
  54418. } // (!) This block is disabled in zlib defaults,
  54419. // don't enable it for binary compatibility
  54420. //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
  54421. // Trace((stderr, "inflate.c too far\n"));
  54422. // copy -= state.whave;
  54423. // if (copy > state.length) { copy = state.length; }
  54424. // if (copy > left) { copy = left; }
  54425. // left -= copy;
  54426. // state.length -= copy;
  54427. // do {
  54428. // output[put++] = 0;
  54429. // } while (--copy);
  54430. // if (state.length === 0) { state.mode = LEN; }
  54431. // break;
  54432. //#endif
  54433. }
  54434. if (copy > state.wnext) {
  54435. copy -= state.wnext;
  54436. from = state.wsize - copy;
  54437. } else {
  54438. from = state.wnext - copy;
  54439. }
  54440. if (copy > state.length) {
  54441. copy = state.length;
  54442. }
  54443. from_source = state.window;
  54444. } else {
  54445. /* copy from output */
  54446. from_source = output;
  54447. from = put - state.offset;
  54448. copy = state.length;
  54449. }
  54450. if (copy > left) {
  54451. copy = left;
  54452. }
  54453. left -= copy;
  54454. state.length -= copy;
  54455. do {
  54456. output[put++] = from_source[from++];
  54457. } while (--copy);
  54458. if (state.length === 0) {
  54459. state.mode = LEN;
  54460. }
  54461. break;
  54462. case LIT:
  54463. if (left === 0) {
  54464. break inf_leave;
  54465. }
  54466. output[put++] = state.length;
  54467. left--;
  54468. state.mode = LEN;
  54469. break;
  54470. case CHECK:
  54471. if (state.wrap) {
  54472. //=== NEEDBITS(32);
  54473. while (bits < 32) {
  54474. if (have === 0) {
  54475. break inf_leave;
  54476. }
  54477. have--; // Use '|' instead of '+' to make sure that result is signed
  54478. hold |= input[next++] << bits;
  54479. bits += 8;
  54480. } //===//
  54481. _out -= left;
  54482. strm.total_out += _out;
  54483. state.total += _out;
  54484. if (_out) {
  54485. strm.adler = state.check =
  54486. /*UPDATE(state.check, put - _out, _out);*/
  54487. state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out);
  54488. }
  54489. _out = left; // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
  54490. if ((state.flags ? hold : zswap32(hold)) !== state.check) {
  54491. strm.msg = 'incorrect data check';
  54492. state.mode = BAD;
  54493. break;
  54494. } //=== INITBITS();
  54495. hold = 0;
  54496. bits = 0; //===//
  54497. //Tracev((stderr, "inflate: check matches trailer\n"));
  54498. }
  54499. state.mode = LENGTH;
  54500. /* falls through */
  54501. case LENGTH:
  54502. if (state.wrap && state.flags) {
  54503. //=== NEEDBITS(32);
  54504. while (bits < 32) {
  54505. if (have === 0) {
  54506. break inf_leave;
  54507. }
  54508. have--;
  54509. hold += input[next++] << bits;
  54510. bits += 8;
  54511. } //===//
  54512. if (hold !== (state.total & 0xffffffff)) {
  54513. strm.msg = 'incorrect length check';
  54514. state.mode = BAD;
  54515. break;
  54516. } //=== INITBITS();
  54517. hold = 0;
  54518. bits = 0; //===//
  54519. //Tracev((stderr, "inflate: length matches trailer\n"));
  54520. }
  54521. state.mode = DONE;
  54522. /* falls through */
  54523. case DONE:
  54524. ret = Z_STREAM_END;
  54525. break inf_leave;
  54526. case BAD:
  54527. ret = Z_DATA_ERROR;
  54528. break inf_leave;
  54529. case MEM:
  54530. return Z_MEM_ERROR;
  54531. case SYNC:
  54532. /* falls through */
  54533. default:
  54534. return Z_STREAM_ERROR;
  54535. }
  54536. } // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
  54537. /*
  54538. Return from inflate(), updating the total counts and the check value.
  54539. If there was no progress during the inflate() call, return a buffer
  54540. error. Call updatewindow() to create and/or update the window state.
  54541. Note: a memory error from inflate() is non-recoverable.
  54542. */
  54543. //--- RESTORE() ---
  54544. strm.next_out = put;
  54545. strm.avail_out = left;
  54546. strm.next_in = next;
  54547. strm.avail_in = have;
  54548. state.hold = hold;
  54549. state.bits = bits; //---
  54550. if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) {
  54551. if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
  54552. state.mode = MEM;
  54553. return Z_MEM_ERROR;
  54554. }
  54555. }
  54556. _in -= strm.avail_in;
  54557. _out -= strm.avail_out;
  54558. strm.total_in += _in;
  54559. strm.total_out += _out;
  54560. state.total += _out;
  54561. if (state.wrap && _out) {
  54562. strm.adler = state.check =
  54563. /*UPDATE(state.check, strm.next_out - _out, _out);*/
  54564. state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out);
  54565. }
  54566. strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
  54567. if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) {
  54568. ret = Z_BUF_ERROR;
  54569. }
  54570. return ret;
  54571. }
  54572. function inflateEnd(strm) {
  54573. if (!strm || !strm.state
  54574. /*|| strm->zfree == (free_func)0*/
  54575. ) {
  54576. return Z_STREAM_ERROR;
  54577. }
  54578. var state = strm.state;
  54579. if (state.window) {
  54580. state.window = null;
  54581. }
  54582. strm.state = null;
  54583. return Z_OK;
  54584. }
  54585. function inflateGetHeader(strm, head) {
  54586. var state;
  54587. /* check state */
  54588. if (!strm || !strm.state) {
  54589. return Z_STREAM_ERROR;
  54590. }
  54591. state = strm.state;
  54592. if ((state.wrap & 2) === 0) {
  54593. return Z_STREAM_ERROR;
  54594. }
  54595. /* save header structure */
  54596. state.head = head;
  54597. head.done = false;
  54598. return Z_OK;
  54599. }
  54600. function inflateSetDictionary(strm, dictionary) {
  54601. var dictLength = dictionary.length;
  54602. var state;
  54603. var dictid;
  54604. var ret;
  54605. /* check state */
  54606. if (!strm
  54607. /* == Z_NULL */
  54608. || !strm.state
  54609. /* == Z_NULL */
  54610. ) {
  54611. return Z_STREAM_ERROR;
  54612. }
  54613. state = strm.state;
  54614. if (state.wrap !== 0 && state.mode !== DICT) {
  54615. return Z_STREAM_ERROR;
  54616. }
  54617. /* check for correct dictionary identifier */
  54618. if (state.mode === DICT) {
  54619. dictid = 1;
  54620. /* adler32(0, null, 0)*/
  54621. /* dictid = adler32(dictid, dictionary, dictLength); */
  54622. dictid = adler32(dictid, dictionary, dictLength, 0);
  54623. if (dictid !== state.check) {
  54624. return Z_DATA_ERROR;
  54625. }
  54626. }
  54627. /* copy dictionary to window using updatewindow(), which will amend the
  54628. existing dictionary if appropriate */
  54629. ret = updatewindow(strm, dictionary, dictLength, dictLength);
  54630. if (ret) {
  54631. state.mode = MEM;
  54632. return Z_MEM_ERROR;
  54633. }
  54634. state.havedict = 1; // Tracev((stderr, "inflate: dictionary set\n"));
  54635. return Z_OK;
  54636. }
  54637. exports.inflateReset = inflateReset;
  54638. exports.inflateReset2 = inflateReset2;
  54639. exports.inflateResetKeep = inflateResetKeep;
  54640. exports.inflateInit = inflateInit;
  54641. exports.inflateInit2 = inflateInit2;
  54642. exports.inflate = inflate;
  54643. exports.inflateEnd = inflateEnd;
  54644. exports.inflateGetHeader = inflateGetHeader;
  54645. exports.inflateSetDictionary = inflateSetDictionary;
  54646. exports.inflateInfo = 'pako inflate (from Nodeca project)';
  54647. /* Not implemented
  54648. exports.inflateCopy = inflateCopy;
  54649. exports.inflateGetDictionary = inflateGetDictionary;
  54650. exports.inflateMark = inflateMark;
  54651. exports.inflatePrime = inflatePrime;
  54652. exports.inflateSync = inflateSync;
  54653. exports.inflateSyncPoint = inflateSyncPoint;
  54654. exports.inflateUndermine = inflateUndermine;
  54655. */
  54656. }, { "../utils/common": 442, "./adler32": 444, "./crc32": 446, "./inffast": 449, "./inftrees": 451 }], 451: [function (require, module, exports) {
  54657. 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  54658. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  54659. //
  54660. // This software is provided 'as-is', without any express or implied
  54661. // warranty. In no event will the authors be held liable for any damages
  54662. // arising from the use of this software.
  54663. //
  54664. // Permission is granted to anyone to use this software for any purpose,
  54665. // including commercial applications, and to alter it and redistribute it
  54666. // freely, subject to the following restrictions:
  54667. //
  54668. // 1. The origin of this software must not be misrepresented; you must not
  54669. // claim that you wrote the original software. If you use this software
  54670. // in a product, an acknowledgment in the product documentation would be
  54671. // appreciated but is not required.
  54672. // 2. Altered source versions must be plainly marked as such, and must not be
  54673. // misrepresented as being the original software.
  54674. // 3. This notice may not be removed or altered from any source distribution.
  54675. var utils = require('../utils/common');
  54676. var MAXBITS = 15;
  54677. var ENOUGH_LENS = 852;
  54678. var ENOUGH_DISTS = 592; //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
  54679. var CODES = 0;
  54680. var LENS = 1;
  54681. var DISTS = 2;
  54682. var lbase = [
  54683. /* Length codes 257..285 base */
  54684. 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0];
  54685. var lext = [
  54686. /* Length codes 257..285 extra */
  54687. 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78];
  54688. var dbase = [
  54689. /* Distance codes 0..29 base */
  54690. 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0];
  54691. var dext = [
  54692. /* Distance codes 0..29 extra */
  54693. 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64];
  54694. module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) {
  54695. var bits = opts.bits; //here = opts.here; /* table entry for duplication */
  54696. var len = 0;
  54697. /* a code's length in bits */
  54698. var sym = 0;
  54699. /* index of code symbols */
  54700. var min = 0,
  54701. max = 0;
  54702. /* minimum and maximum code lengths */
  54703. var root = 0;
  54704. /* number of index bits for root table */
  54705. var curr = 0;
  54706. /* number of index bits for current table */
  54707. var drop = 0;
  54708. /* code bits to drop for sub-table */
  54709. var left = 0;
  54710. /* number of prefix codes available */
  54711. var used = 0;
  54712. /* code entries in table used */
  54713. var huff = 0;
  54714. /* Huffman code */
  54715. var incr;
  54716. /* for incrementing code, index */
  54717. var fill;
  54718. /* index for replicating entries */
  54719. var low;
  54720. /* low bits for current root entry */
  54721. var mask;
  54722. /* mask for low root bits */
  54723. var next;
  54724. /* next available space in table */
  54725. var base = null;
  54726. /* base value table to use */
  54727. var base_index = 0; // var shoextra; /* extra bits table to use */
  54728. var end;
  54729. /* use base and extra for symbol > end */
  54730. var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
  54731. var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
  54732. var extra = null;
  54733. var extra_index = 0;
  54734. var here_bits, here_op, here_val;
  54735. /*
  54736. Process a set of code lengths to create a canonical Huffman code. The
  54737. code lengths are lens[0..codes-1]. Each length corresponds to the
  54738. symbols 0..codes-1. The Huffman code is generated by first sorting the
  54739. symbols by length from short to long, and retaining the symbol order
  54740. for codes with equal lengths. Then the code starts with all zero bits
  54741. for the first code of the shortest length, and the codes are integer
  54742. increments for the same length, and zeros are appended as the length
  54743. increases. For the deflate format, these bits are stored backwards
  54744. from their more natural integer increment ordering, and so when the
  54745. decoding tables are built in the large loop below, the integer codes
  54746. are incremented backwards.
  54747. This routine assumes, but does not check, that all of the entries in
  54748. lens[] are in the range 0..MAXBITS. The caller must assure this.
  54749. 1..MAXBITS is interpreted as that code length. zero means that that
  54750. symbol does not occur in this code.
  54751. The codes are sorted by computing a count of codes for each length,
  54752. creating from that a table of starting indices for each length in the
  54753. sorted table, and then entering the symbols in order in the sorted
  54754. table. The sorted table is work[], with that space being provided by
  54755. the caller.
  54756. The length counts are used for other purposes as well, i.e. finding
  54757. the minimum and maximum length codes, determining if there are any
  54758. codes at all, checking for a valid set of lengths, and looking ahead
  54759. at length counts to determine sub-table sizes when building the
  54760. decoding tables.
  54761. */
  54762. /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
  54763. for (len = 0; len <= MAXBITS; len++) {
  54764. count[len] = 0;
  54765. }
  54766. for (sym = 0; sym < codes; sym++) {
  54767. count[lens[lens_index + sym]]++;
  54768. }
  54769. /* bound code lengths, force root to be within code lengths */
  54770. root = bits;
  54771. for (max = MAXBITS; max >= 1; max--) {
  54772. if (count[max] !== 0) {
  54773. break;
  54774. }
  54775. }
  54776. if (root > max) {
  54777. root = max;
  54778. }
  54779. if (max === 0) {
  54780. /* no symbols to code at all */
  54781. //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */
  54782. //table.bits[opts.table_index] = 1; //here.bits = (var char)1;
  54783. //table.val[opts.table_index++] = 0; //here.val = (var short)0;
  54784. table[table_index++] = 1 << 24 | 64 << 16 | 0; //table.op[opts.table_index] = 64;
  54785. //table.bits[opts.table_index] = 1;
  54786. //table.val[opts.table_index++] = 0;
  54787. table[table_index++] = 1 << 24 | 64 << 16 | 0;
  54788. opts.bits = 1;
  54789. return 0;
  54790. /* no symbols, but wait for decoding to report error */
  54791. }
  54792. for (min = 1; min < max; min++) {
  54793. if (count[min] !== 0) {
  54794. break;
  54795. }
  54796. }
  54797. if (root < min) {
  54798. root = min;
  54799. }
  54800. /* check for an over-subscribed or incomplete set of lengths */
  54801. left = 1;
  54802. for (len = 1; len <= MAXBITS; len++) {
  54803. left <<= 1;
  54804. left -= count[len];
  54805. if (left < 0) {
  54806. return -1;
  54807. }
  54808. /* over-subscribed */
  54809. }
  54810. if (left > 0 && (type === CODES || max !== 1)) {
  54811. return -1;
  54812. /* incomplete set */
  54813. }
  54814. /* generate offsets into symbol table for each length for sorting */
  54815. offs[1] = 0;
  54816. for (len = 1; len < MAXBITS; len++) {
  54817. offs[len + 1] = offs[len] + count[len];
  54818. }
  54819. /* sort symbols by length, by symbol order within each length */
  54820. for (sym = 0; sym < codes; sym++) {
  54821. if (lens[lens_index + sym] !== 0) {
  54822. work[offs[lens[lens_index + sym]]++] = sym;
  54823. }
  54824. }
  54825. /*
  54826. Create and fill in decoding tables. In this loop, the table being
  54827. filled is at next and has curr index bits. The code being used is huff
  54828. with length len. That code is converted to an index by dropping drop
  54829. bits off of the bottom. For codes where len is less than drop + curr,
  54830. those top drop + curr - len bits are incremented through all values to
  54831. fill the table with replicated entries.
  54832. root is the number of index bits for the root table. When len exceeds
  54833. root, sub-tables are created pointed to by the root entry with an index
  54834. of the low root bits of huff. This is saved in low to check for when a
  54835. new sub-table should be started. drop is zero when the root table is
  54836. being filled, and drop is root when sub-tables are being filled.
  54837. When a new sub-table is needed, it is necessary to look ahead in the
  54838. code lengths to determine what size sub-table is needed. The length
  54839. counts are used for this, and so count[] is decremented as codes are
  54840. entered in the tables.
  54841. used keeps track of how many table entries have been allocated from the
  54842. provided *table space. It is checked for LENS and DIST tables against
  54843. the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
  54844. the initial root table size constants. See the comments in inftrees.h
  54845. for more information.
  54846. sym increments through all symbols, and the loop terminates when
  54847. all codes of length max, i.e. all codes, have been processed. This
  54848. routine permits incomplete codes, so another loop after this one fills
  54849. in the rest of the decoding tables with invalid code markers.
  54850. */
  54851. /* set up for code type */
  54852. // poor man optimization - use if-else instead of switch,
  54853. // to avoid deopts in old v8
  54854. if (type === CODES) {
  54855. base = extra = work;
  54856. /* dummy value--not used */
  54857. end = 19;
  54858. } else if (type === LENS) {
  54859. base = lbase;
  54860. base_index -= 257;
  54861. extra = lext;
  54862. extra_index -= 257;
  54863. end = 256;
  54864. } else {
  54865. /* DISTS */
  54866. base = dbase;
  54867. extra = dext;
  54868. end = -1;
  54869. }
  54870. /* initialize opts for loop */
  54871. huff = 0;
  54872. /* starting code */
  54873. sym = 0;
  54874. /* starting code symbol */
  54875. len = min;
  54876. /* starting code length */
  54877. next = table_index;
  54878. /* current table to fill in */
  54879. curr = root;
  54880. /* current table index bits */
  54881. drop = 0;
  54882. /* current bits to drop from code for index */
  54883. low = -1;
  54884. /* trigger new sub-table when len > root */
  54885. used = 1 << root;
  54886. /* use root table entries */
  54887. mask = used - 1;
  54888. /* mask for comparing low */
  54889. /* check available table space */
  54890. if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
  54891. return 1;
  54892. }
  54893. /* process all codes and make table entries */
  54894. for (; ;) {
  54895. /* create table entry */
  54896. here_bits = len - drop;
  54897. if (work[sym] < end) {
  54898. here_op = 0;
  54899. here_val = work[sym];
  54900. } else if (work[sym] > end) {
  54901. here_op = extra[extra_index + work[sym]];
  54902. here_val = base[base_index + work[sym]];
  54903. } else {
  54904. here_op = 32 + 64;
  54905. /* end of block */
  54906. here_val = 0;
  54907. }
  54908. /* replicate for those indices with low len bits equal to huff */
  54909. incr = 1 << len - drop;
  54910. fill = 1 << curr;
  54911. min = fill;
  54912. /* save offset to next table */
  54913. do {
  54914. fill -= incr;
  54915. table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
  54916. } while (fill !== 0);
  54917. /* backwards increment the len-bit code huff */
  54918. incr = 1 << len - 1;
  54919. while (huff & incr) {
  54920. incr >>= 1;
  54921. }
  54922. if (incr !== 0) {
  54923. huff &= incr - 1;
  54924. huff += incr;
  54925. } else {
  54926. huff = 0;
  54927. }
  54928. /* go to next symbol, update count, len */
  54929. sym++;
  54930. if (--count[len] === 0) {
  54931. if (len === max) {
  54932. break;
  54933. }
  54934. len = lens[lens_index + work[sym]];
  54935. }
  54936. /* create new sub-table if needed */
  54937. if (len > root && (huff & mask) !== low) {
  54938. /* if first time, transition to sub-tables */
  54939. if (drop === 0) {
  54940. drop = root;
  54941. }
  54942. /* increment past last table */
  54943. next += min;
  54944. /* here min is 1 << curr */
  54945. /* determine length of next table */
  54946. curr = len - drop;
  54947. left = 1 << curr;
  54948. while (curr + drop < max) {
  54949. left -= count[curr + drop];
  54950. if (left <= 0) {
  54951. break;
  54952. }
  54953. curr++;
  54954. left <<= 1;
  54955. }
  54956. /* check for enough space */
  54957. used += 1 << curr;
  54958. if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
  54959. return 1;
  54960. }
  54961. /* point entry in root table to sub-table */
  54962. low = huff & mask;
  54963. /*table.op[low] = curr;
  54964. table.bits[low] = root;
  54965. table.val[low] = next - opts.table_index;*/
  54966. table[low] = root << 24 | curr << 16 | next - table_index | 0;
  54967. }
  54968. }
  54969. /* fill in remaining table entry if code is incomplete (guaranteed to have
  54970. at most one remaining entry, since if the code is incomplete, the
  54971. maximum code length that was allowed to get this far is one bit) */
  54972. if (huff !== 0) {
  54973. //table.op[next + huff] = 64; /* invalid code marker */
  54974. //table.bits[next + huff] = len - drop;
  54975. //table.val[next + huff] = 0;
  54976. table[next + huff] = len - drop << 24 | 64 << 16 | 0;
  54977. }
  54978. /* set return parameters */
  54979. //opts.table_index += used;
  54980. opts.bits = root;
  54981. return 0;
  54982. };
  54983. }, { "../utils/common": 442 }], 452: [function (require, module, exports) {
  54984. 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  54985. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  54986. //
  54987. // This software is provided 'as-is', without any express or implied
  54988. // warranty. In no event will the authors be held liable for any damages
  54989. // arising from the use of this software.
  54990. //
  54991. // Permission is granted to anyone to use this software for any purpose,
  54992. // including commercial applications, and to alter it and redistribute it
  54993. // freely, subject to the following restrictions:
  54994. //
  54995. // 1. The origin of this software must not be misrepresented; you must not
  54996. // claim that you wrote the original software. If you use this software
  54997. // in a product, an acknowledgment in the product documentation would be
  54998. // appreciated but is not required.
  54999. // 2. Altered source versions must be plainly marked as such, and must not be
  55000. // misrepresented as being the original software.
  55001. // 3. This notice may not be removed or altered from any source distribution.
  55002. module.exports = {
  55003. 2: 'need dictionary',
  55004. /* Z_NEED_DICT 2 */
  55005. 1: 'stream end',
  55006. /* Z_STREAM_END 1 */
  55007. 0: '',
  55008. /* Z_OK 0 */
  55009. '-1': 'file error',
  55010. /* Z_ERRNO (-1) */
  55011. '-2': 'stream error',
  55012. /* Z_STREAM_ERROR (-2) */
  55013. '-3': 'data error',
  55014. /* Z_DATA_ERROR (-3) */
  55015. '-4': 'insufficient memory',
  55016. /* Z_MEM_ERROR (-4) */
  55017. '-5': 'buffer error',
  55018. /* Z_BUF_ERROR (-5) */
  55019. '-6': 'incompatible version'
  55020. /* Z_VERSION_ERROR (-6) */
  55021. };
  55022. }, {}], 453: [function (require, module, exports) {
  55023. 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  55024. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  55025. //
  55026. // This software is provided 'as-is', without any express or implied
  55027. // warranty. In no event will the authors be held liable for any damages
  55028. // arising from the use of this software.
  55029. //
  55030. // Permission is granted to anyone to use this software for any purpose,
  55031. // including commercial applications, and to alter it and redistribute it
  55032. // freely, subject to the following restrictions:
  55033. //
  55034. // 1. The origin of this software must not be misrepresented; you must not
  55035. // claim that you wrote the original software. If you use this software
  55036. // in a product, an acknowledgment in the product documentation would be
  55037. // appreciated but is not required.
  55038. // 2. Altered source versions must be plainly marked as such, and must not be
  55039. // misrepresented as being the original software.
  55040. // 3. This notice may not be removed or altered from any source distribution.
  55041. /* eslint-disable space-unary-ops */
  55042. var utils = require('../utils/common');
  55043. /* Public constants ==========================================================*/
  55044. /* ===========================================================================*/
  55045. //var Z_FILTERED = 1;
  55046. //var Z_HUFFMAN_ONLY = 2;
  55047. //var Z_RLE = 3;
  55048. var Z_FIXED = 4; //var Z_DEFAULT_STRATEGY = 0;
  55049. /* Possible values of the data_type field (though see inflate()) */
  55050. var Z_BINARY = 0;
  55051. var Z_TEXT = 1; //var Z_ASCII = 1; // = Z_TEXT
  55052. var Z_UNKNOWN = 2;
  55053. /*============================================================================*/
  55054. function zero(buf) {
  55055. var len = buf.length;
  55056. while (--len >= 0) {
  55057. buf[len] = 0;
  55058. }
  55059. } // From zutil.h
  55060. var STORED_BLOCK = 0;
  55061. var STATIC_TREES = 1;
  55062. var DYN_TREES = 2;
  55063. /* The three kinds of block type */
  55064. var MIN_MATCH = 3;
  55065. var MAX_MATCH = 258;
  55066. /* The minimum and maximum match lengths */
  55067. // From deflate.h
  55068. /* ===========================================================================
  55069. * Internal compression state.
  55070. */
  55071. var LENGTH_CODES = 29;
  55072. /* number of length codes, not counting the special END_BLOCK code */
  55073. var LITERALS = 256;
  55074. /* number of literal bytes 0..255 */
  55075. var L_CODES = LITERALS + 1 + LENGTH_CODES;
  55076. /* number of Literal or Length codes, including the END_BLOCK code */
  55077. var D_CODES = 30;
  55078. /* number of distance codes */
  55079. var BL_CODES = 19;
  55080. /* number of codes used to transfer the bit lengths */
  55081. var HEAP_SIZE = 2 * L_CODES + 1;
  55082. /* maximum heap size */
  55083. var MAX_BITS = 15;
  55084. /* All codes must not exceed MAX_BITS bits */
  55085. var Buf_size = 16;
  55086. /* size of bit buffer in bi_buf */
  55087. /* ===========================================================================
  55088. * Constants
  55089. */
  55090. var MAX_BL_BITS = 7;
  55091. /* Bit length codes must not exceed MAX_BL_BITS bits */
  55092. var END_BLOCK = 256;
  55093. /* end of block literal code */
  55094. var REP_3_6 = 16;
  55095. /* repeat previous bit length 3-6 times (2 bits of repeat count) */
  55096. var REPZ_3_10 = 17;
  55097. /* repeat a zero length 3-10 times (3 bits of repeat count) */
  55098. var REPZ_11_138 = 18;
  55099. /* repeat a zero length 11-138 times (7 bits of repeat count) */
  55100. /* eslint-disable comma-spacing,array-bracket-spacing */
  55101. var extra_lbits =
  55102. /* extra bits for each length code */
  55103. [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0];
  55104. var extra_dbits =
  55105. /* extra bits for each distance code */
  55106. [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
  55107. var extra_blbits =
  55108. /* extra bits for each bit length code */
  55109. [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7];
  55110. var bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  55111. /* eslint-enable comma-spacing,array-bracket-spacing */
  55112. /* The lengths of the bit length codes are sent in order of decreasing
  55113. * probability, to avoid transmitting the lengths for unused bit length codes.
  55114. */
  55115. /* ===========================================================================
  55116. * Local data. These are initialized only once.
  55117. */
  55118. // We pre-fill arrays with 0 to avoid uninitialized gaps
  55119. var DIST_CODE_LEN = 512;
  55120. /* see definition of array dist_code below */
  55121. // !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1
  55122. var static_ltree = new Array((L_CODES + 2) * 2);
  55123. zero(static_ltree);
  55124. /* The static literal tree. Since the bit lengths are imposed, there is no
  55125. * need for the L_CODES extra codes used during heap construction. However
  55126. * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
  55127. * below).
  55128. */
  55129. var static_dtree = new Array(D_CODES * 2);
  55130. zero(static_dtree);
  55131. /* The static distance tree. (Actually a trivial tree since all codes use
  55132. * 5 bits.)
  55133. */
  55134. var _dist_code = new Array(DIST_CODE_LEN);
  55135. zero(_dist_code);
  55136. /* Distance codes. The first 256 values correspond to the distances
  55137. * 3 .. 258, the last 256 values correspond to the top 8 bits of
  55138. * the 15 bit distances.
  55139. */
  55140. var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);
  55141. zero(_length_code);
  55142. /* length code for each normalized match length (0 == MIN_MATCH) */
  55143. var base_length = new Array(LENGTH_CODES);
  55144. zero(base_length);
  55145. /* First normalized length for each code (0 = MIN_MATCH) */
  55146. var base_dist = new Array(D_CODES);
  55147. zero(base_dist);
  55148. /* First normalized distance for each code (0 = distance of 1) */
  55149. function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {
  55150. this.static_tree = static_tree;
  55151. /* static tree or NULL */
  55152. this.extra_bits = extra_bits;
  55153. /* extra bits for each code or NULL */
  55154. this.extra_base = extra_base;
  55155. /* base index for extra_bits */
  55156. this.elems = elems;
  55157. /* max number of elements in the tree */
  55158. this.max_length = max_length;
  55159. /* max bit length for the codes */
  55160. // show if `static_tree` has data or dummy - needed for monomorphic objects
  55161. this.has_stree = static_tree && static_tree.length;
  55162. }
  55163. var static_l_desc;
  55164. var static_d_desc;
  55165. var static_bl_desc;
  55166. function TreeDesc(dyn_tree, stat_desc) {
  55167. this.dyn_tree = dyn_tree;
  55168. /* the dynamic tree */
  55169. this.max_code = 0;
  55170. /* largest code with non zero frequency */
  55171. this.stat_desc = stat_desc;
  55172. /* the corresponding static tree */
  55173. }
  55174. function d_code(dist) {
  55175. return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
  55176. }
  55177. /* ===========================================================================
  55178. * Output a short LSB first on the stream.
  55179. * IN assertion: there is enough room in pendingBuf.
  55180. */
  55181. function put_short(s, w) {
  55182. // put_byte(s, (uch)((w) & 0xff));
  55183. // put_byte(s, (uch)((ush)(w) >> 8));
  55184. s.pending_buf[s.pending++] = w & 0xff;
  55185. s.pending_buf[s.pending++] = w >>> 8 & 0xff;
  55186. }
  55187. /* ===========================================================================
  55188. * Send a value on a given number of bits.
  55189. * IN assertion: length <= 16 and value fits in length bits.
  55190. */
  55191. function send_bits(s, value, length) {
  55192. if (s.bi_valid > Buf_size - length) {
  55193. s.bi_buf |= value << s.bi_valid & 0xffff;
  55194. put_short(s, s.bi_buf);
  55195. s.bi_buf = value >> Buf_size - s.bi_valid;
  55196. s.bi_valid += length - Buf_size;
  55197. } else {
  55198. s.bi_buf |= value << s.bi_valid & 0xffff;
  55199. s.bi_valid += length;
  55200. }
  55201. }
  55202. function send_code(s, c, tree) {
  55203. send_bits(s, tree[c * 2]
  55204. /*.Code*/
  55205. , tree[c * 2 + 1]
  55206. /*.Len*/
  55207. );
  55208. }
  55209. /* ===========================================================================
  55210. * Reverse the first len bits of a code, using straightforward code (a faster
  55211. * method would use a table)
  55212. * IN assertion: 1 <= len <= 15
  55213. */
  55214. function bi_reverse(code, len) {
  55215. var res = 0;
  55216. do {
  55217. res |= code & 1;
  55218. code >>>= 1;
  55219. res <<= 1;
  55220. } while (--len > 0);
  55221. return res >>> 1;
  55222. }
  55223. /* ===========================================================================
  55224. * Flush the bit buffer, keeping at most 7 bits in it.
  55225. */
  55226. function bi_flush(s) {
  55227. if (s.bi_valid === 16) {
  55228. put_short(s, s.bi_buf);
  55229. s.bi_buf = 0;
  55230. s.bi_valid = 0;
  55231. } else if (s.bi_valid >= 8) {
  55232. s.pending_buf[s.pending++] = s.bi_buf & 0xff;
  55233. s.bi_buf >>= 8;
  55234. s.bi_valid -= 8;
  55235. }
  55236. }
  55237. /* ===========================================================================
  55238. * Compute the optimal bit lengths for a tree and update the total bit length
  55239. * for the current block.
  55240. * IN assertion: the fields freq and dad are set, heap[heap_max] and
  55241. * above are the tree nodes sorted by increasing frequency.
  55242. * OUT assertions: the field len is set to the optimal bit length, the
  55243. * array bl_count contains the frequencies for each bit length.
  55244. * The length opt_len is updated; static_len is also updated if stree is
  55245. * not null.
  55246. */
  55247. function gen_bitlen(s, desc) // deflate_state *s;
  55248. // tree_desc *desc; /* the tree descriptor */
  55249. {
  55250. var tree = desc.dyn_tree;
  55251. var max_code = desc.max_code;
  55252. var stree = desc.stat_desc.static_tree;
  55253. var has_stree = desc.stat_desc.has_stree;
  55254. var extra = desc.stat_desc.extra_bits;
  55255. var base = desc.stat_desc.extra_base;
  55256. var max_length = desc.stat_desc.max_length;
  55257. var h;
  55258. /* heap index */
  55259. var n, m;
  55260. /* iterate over the tree elements */
  55261. var bits;
  55262. /* bit length */
  55263. var xbits;
  55264. /* extra bits */
  55265. var f;
  55266. /* frequency */
  55267. var overflow = 0;
  55268. /* number of elements with bit length too large */
  55269. for (bits = 0; bits <= MAX_BITS; bits++) {
  55270. s.bl_count[bits] = 0;
  55271. }
  55272. /* In a first pass, compute the optimal bit lengths (which may
  55273. * overflow in the case of the bit length tree).
  55274. */
  55275. tree[s.heap[s.heap_max] * 2 + 1]
  55276. /*.Len*/
  55277. = 0;
  55278. /* root of the heap */
  55279. for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {
  55280. n = s.heap[h];
  55281. bits = tree[tree[n * 2 + 1]
  55282. /*.Dad*/
  55283. * 2 + 1]
  55284. /*.Len*/
  55285. + 1;
  55286. if (bits > max_length) {
  55287. bits = max_length;
  55288. overflow++;
  55289. }
  55290. tree[n * 2 + 1]
  55291. /*.Len*/
  55292. = bits;
  55293. /* We overwrite tree[n].Dad which is no longer needed */
  55294. if (n > max_code) {
  55295. continue;
  55296. }
  55297. /* not a leaf node */
  55298. s.bl_count[bits]++;
  55299. xbits = 0;
  55300. if (n >= base) {
  55301. xbits = extra[n - base];
  55302. }
  55303. f = tree[n * 2]
  55304. /*.Freq*/
  55305. ;
  55306. s.opt_len += f * (bits + xbits);
  55307. if (has_stree) {
  55308. s.static_len += f * (stree[n * 2 + 1]
  55309. /*.Len*/
  55310. + xbits);
  55311. }
  55312. }
  55313. if (overflow === 0) {
  55314. return;
  55315. } // Trace((stderr,"\nbit length overflow\n"));
  55316. /* This happens for example on obj2 and pic of the Calgary corpus */
  55317. /* Find the first bit length which could increase: */
  55318. do {
  55319. bits = max_length - 1;
  55320. while (s.bl_count[bits] === 0) {
  55321. bits--;
  55322. }
  55323. s.bl_count[bits]--;
  55324. /* move one leaf down the tree */
  55325. s.bl_count[bits + 1] += 2;
  55326. /* move one overflow item as its brother */
  55327. s.bl_count[max_length]--;
  55328. /* The brother of the overflow item also moves one step up,
  55329. * but this does not affect bl_count[max_length]
  55330. */
  55331. overflow -= 2;
  55332. } while (overflow > 0);
  55333. /* Now recompute all bit lengths, scanning in increasing frequency.
  55334. * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
  55335. * lengths instead of fixing only the wrong ones. This idea is taken
  55336. * from 'ar' written by Haruhiko Okumura.)
  55337. */
  55338. for (bits = max_length; bits !== 0; bits--) {
  55339. n = s.bl_count[bits];
  55340. while (n !== 0) {
  55341. m = s.heap[--h];
  55342. if (m > max_code) {
  55343. continue;
  55344. }
  55345. if (tree[m * 2 + 1]
  55346. /*.Len*/
  55347. !== bits) {
  55348. // Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
  55349. s.opt_len += (bits - tree[m * 2 + 1]
  55350. /*.Len*/
  55351. ) * tree[m * 2]
  55352. /*.Freq*/
  55353. ;
  55354. tree[m * 2 + 1]
  55355. /*.Len*/
  55356. = bits;
  55357. }
  55358. n--;
  55359. }
  55360. }
  55361. }
  55362. /* ===========================================================================
  55363. * Generate the codes for a given tree and bit counts (which need not be
  55364. * optimal).
  55365. * IN assertion: the array bl_count contains the bit length statistics for
  55366. * the given tree and the field len is set for all tree elements.
  55367. * OUT assertion: the field code is set for all tree elements of non
  55368. * zero code length.
  55369. */
  55370. function gen_codes(tree, max_code, bl_count) // ct_data *tree; /* the tree to decorate */
  55371. // int max_code; /* largest code with non zero frequency */
  55372. // ushf *bl_count; /* number of codes at each bit length */
  55373. {
  55374. var next_code = new Array(MAX_BITS + 1);
  55375. /* next code value for each bit length */
  55376. var code = 0;
  55377. /* running code value */
  55378. var bits;
  55379. /* bit index */
  55380. var n;
  55381. /* code index */
  55382. /* The distribution counts are first used to generate the code values
  55383. * without bit reversal.
  55384. */
  55385. for (bits = 1; bits <= MAX_BITS; bits++) {
  55386. next_code[bits] = code = code + bl_count[bits - 1] << 1;
  55387. }
  55388. /* Check that the bit counts in bl_count are consistent. The last code
  55389. * must be all ones.
  55390. */
  55391. //Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
  55392. // "inconsistent bit counts");
  55393. //Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
  55394. for (n = 0; n <= max_code; n++) {
  55395. var len = tree[n * 2 + 1]
  55396. /*.Len*/
  55397. ;
  55398. if (len === 0) {
  55399. continue;
  55400. }
  55401. /* Now reverse the bits */
  55402. tree[n * 2]
  55403. /*.Code*/
  55404. = bi_reverse(next_code[len]++, len); //Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
  55405. // n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
  55406. }
  55407. }
  55408. /* ===========================================================================
  55409. * Initialize the various 'constant' tables.
  55410. */
  55411. function tr_static_init() {
  55412. var n;
  55413. /* iterates over tree elements */
  55414. var bits;
  55415. /* bit counter */
  55416. var length;
  55417. /* length value */
  55418. var code;
  55419. /* code value */
  55420. var dist;
  55421. /* distance index */
  55422. var bl_count = new Array(MAX_BITS + 1);
  55423. /* number of codes at each bit length for an optimal tree */
  55424. // do check in _tr_init()
  55425. //if (static_init_done) return;
  55426. /* For some embedded targets, global variables are not initialized: */
  55427. /*#ifdef NO_INIT_GLOBAL_POINTERS
  55428. static_l_desc.static_tree = static_ltree;
  55429. static_l_desc.extra_bits = extra_lbits;
  55430. static_d_desc.static_tree = static_dtree;
  55431. static_d_desc.extra_bits = extra_dbits;
  55432. static_bl_desc.extra_bits = extra_blbits;
  55433. #endif*/
  55434. /* Initialize the mapping length (0..255) -> length code (0..28) */
  55435. length = 0;
  55436. for (code = 0; code < LENGTH_CODES - 1; code++) {
  55437. base_length[code] = length;
  55438. for (n = 0; n < 1 << extra_lbits[code]; n++) {
  55439. _length_code[length++] = code;
  55440. }
  55441. } //Assert (length == 256, "tr_static_init: length != 256");
  55442. /* Note that the length 255 (match length 258) can be represented
  55443. * in two different ways: code 284 + 5 bits or code 285, so we
  55444. * overwrite length_code[255] to use the best encoding:
  55445. */
  55446. _length_code[length - 1] = code;
  55447. /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
  55448. dist = 0;
  55449. for (code = 0; code < 16; code++) {
  55450. base_dist[code] = dist;
  55451. for (n = 0; n < 1 << extra_dbits[code]; n++) {
  55452. _dist_code[dist++] = code;
  55453. }
  55454. } //Assert (dist == 256, "tr_static_init: dist != 256");
  55455. dist >>= 7;
  55456. /* from now on, all distances are divided by 128 */
  55457. for (; code < D_CODES; code++) {
  55458. base_dist[code] = dist << 7;
  55459. for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {
  55460. _dist_code[256 + dist++] = code;
  55461. }
  55462. } //Assert (dist == 256, "tr_static_init: 256+dist != 512");
  55463. /* Construct the codes of the static literal tree */
  55464. for (bits = 0; bits <= MAX_BITS; bits++) {
  55465. bl_count[bits] = 0;
  55466. }
  55467. n = 0;
  55468. while (n <= 143) {
  55469. static_ltree[n * 2 + 1]
  55470. /*.Len*/
  55471. = 8;
  55472. n++;
  55473. bl_count[8]++;
  55474. }
  55475. while (n <= 255) {
  55476. static_ltree[n * 2 + 1]
  55477. /*.Len*/
  55478. = 9;
  55479. n++;
  55480. bl_count[9]++;
  55481. }
  55482. while (n <= 279) {
  55483. static_ltree[n * 2 + 1]
  55484. /*.Len*/
  55485. = 7;
  55486. n++;
  55487. bl_count[7]++;
  55488. }
  55489. while (n <= 287) {
  55490. static_ltree[n * 2 + 1]
  55491. /*.Len*/
  55492. = 8;
  55493. n++;
  55494. bl_count[8]++;
  55495. }
  55496. /* Codes 286 and 287 do not exist, but we must include them in the
  55497. * tree construction to get a canonical Huffman tree (longest code
  55498. * all ones)
  55499. */
  55500. gen_codes(static_ltree, L_CODES + 1, bl_count);
  55501. /* The static distance tree is trivial: */
  55502. for (n = 0; n < D_CODES; n++) {
  55503. static_dtree[n * 2 + 1]
  55504. /*.Len*/
  55505. = 5;
  55506. static_dtree[n * 2]
  55507. /*.Code*/
  55508. = bi_reverse(n, 5);
  55509. } // Now data ready and we can init static trees
  55510. static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);
  55511. static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);
  55512. static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); //static_init_done = true;
  55513. }
  55514. /* ===========================================================================
  55515. * Initialize a new block.
  55516. */
  55517. function init_block(s) {
  55518. var n;
  55519. /* iterates over tree elements */
  55520. /* Initialize the trees. */
  55521. for (n = 0; n < L_CODES; n++) {
  55522. s.dyn_ltree[n * 2]
  55523. /*.Freq*/
  55524. = 0;
  55525. }
  55526. for (n = 0; n < D_CODES; n++) {
  55527. s.dyn_dtree[n * 2]
  55528. /*.Freq*/
  55529. = 0;
  55530. }
  55531. for (n = 0; n < BL_CODES; n++) {
  55532. s.bl_tree[n * 2]
  55533. /*.Freq*/
  55534. = 0;
  55535. }
  55536. s.dyn_ltree[END_BLOCK * 2]
  55537. /*.Freq*/
  55538. = 1;
  55539. s.opt_len = s.static_len = 0;
  55540. s.last_lit = s.matches = 0;
  55541. }
  55542. /* ===========================================================================
  55543. * Flush the bit buffer and align the output on a byte boundary
  55544. */
  55545. function bi_windup(s) {
  55546. if (s.bi_valid > 8) {
  55547. put_short(s, s.bi_buf);
  55548. } else if (s.bi_valid > 0) {
  55549. //put_byte(s, (Byte)s->bi_buf);
  55550. s.pending_buf[s.pending++] = s.bi_buf;
  55551. }
  55552. s.bi_buf = 0;
  55553. s.bi_valid = 0;
  55554. }
  55555. /* ===========================================================================
  55556. * Copy a stored block, storing first the length and its
  55557. * one's complement if requested.
  55558. */
  55559. function copy_block(s, buf, len, header) //DeflateState *s;
  55560. //charf *buf; /* the input data */
  55561. //unsigned len; /* its length */
  55562. //int header; /* true if block header must be written */
  55563. {
  55564. bi_windup(s);
  55565. /* align on byte boundary */
  55566. if (header) {
  55567. put_short(s, len);
  55568. put_short(s, ~len);
  55569. } // while (len--) {
  55570. // put_byte(s, *buf++);
  55571. // }
  55572. utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);
  55573. s.pending += len;
  55574. }
  55575. /* ===========================================================================
  55576. * Compares to subtrees, using the tree depth as tie breaker when
  55577. * the subtrees have equal frequency. This minimizes the worst case length.
  55578. */
  55579. function smaller(tree, n, m, depth) {
  55580. var _n2 = n * 2;
  55581. var _m2 = m * 2;
  55582. return tree[_n2]
  55583. /*.Freq*/
  55584. < tree[_m2]
  55585. /*.Freq*/
  55586. || tree[_n2]
  55587. /*.Freq*/
  55588. === tree[_m2]
  55589. /*.Freq*/
  55590. && depth[n] <= depth[m];
  55591. }
  55592. /* ===========================================================================
  55593. * Restore the heap property by moving down the tree starting at node k,
  55594. * exchanging a node with the smallest of its two sons if necessary, stopping
  55595. * when the heap property is re-established (each father smaller than its
  55596. * two sons).
  55597. */
  55598. function pqdownheap(s, tree, k) // deflate_state *s;
  55599. // ct_data *tree; /* the tree to restore */
  55600. // int k; /* node to move down */
  55601. {
  55602. var v = s.heap[k];
  55603. var j = k << 1;
  55604. /* left son of k */
  55605. while (j <= s.heap_len) {
  55606. /* Set j to the smallest of the two sons: */
  55607. if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
  55608. j++;
  55609. }
  55610. /* Exit if v is smaller than both sons */
  55611. if (smaller(tree, v, s.heap[j], s.depth)) {
  55612. break;
  55613. }
  55614. /* Exchange v with the smallest son */
  55615. s.heap[k] = s.heap[j];
  55616. k = j;
  55617. /* And continue down the tree, setting j to the left son of k */
  55618. j <<= 1;
  55619. }
  55620. s.heap[k] = v;
  55621. } // inlined manually
  55622. // var SMALLEST = 1;
  55623. /* ===========================================================================
  55624. * Send the block data compressed using the given Huffman trees
  55625. */
  55626. function compress_block(s, ltree, dtree) // deflate_state *s;
  55627. // const ct_data *ltree; /* literal tree */
  55628. // const ct_data *dtree; /* distance tree */
  55629. {
  55630. var dist;
  55631. /* distance of matched string */
  55632. var lc;
  55633. /* match length or unmatched char (if dist == 0) */
  55634. var lx = 0;
  55635. /* running index in l_buf */
  55636. var code;
  55637. /* the code to send */
  55638. var extra;
  55639. /* number of extra bits to send */
  55640. if (s.last_lit !== 0) {
  55641. do {
  55642. dist = s.pending_buf[s.d_buf + lx * 2] << 8 | s.pending_buf[s.d_buf + lx * 2 + 1];
  55643. lc = s.pending_buf[s.l_buf + lx];
  55644. lx++;
  55645. if (dist === 0) {
  55646. send_code(s, lc, ltree);
  55647. /* send a literal byte */
  55648. //Tracecv(isgraph(lc), (stderr," '%c' ", lc));
  55649. } else {
  55650. /* Here, lc is the match length - MIN_MATCH */
  55651. code = _length_code[lc];
  55652. send_code(s, code + LITERALS + 1, ltree);
  55653. /* send the length code */
  55654. extra = extra_lbits[code];
  55655. if (extra !== 0) {
  55656. lc -= base_length[code];
  55657. send_bits(s, lc, extra);
  55658. /* send the extra length bits */
  55659. }
  55660. dist--;
  55661. /* dist is now the match distance - 1 */
  55662. code = d_code(dist); //Assert (code < D_CODES, "bad d_code");
  55663. send_code(s, code, dtree);
  55664. /* send the distance code */
  55665. extra = extra_dbits[code];
  55666. if (extra !== 0) {
  55667. dist -= base_dist[code];
  55668. send_bits(s, dist, extra);
  55669. /* send the extra distance bits */
  55670. }
  55671. }
  55672. /* literal or match pair ? */
  55673. /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
  55674. //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
  55675. // "pendingBuf overflow");
  55676. } while (lx < s.last_lit);
  55677. }
  55678. send_code(s, END_BLOCK, ltree);
  55679. }
  55680. /* ===========================================================================
  55681. * Construct one Huffman tree and assigns the code bit strings and lengths.
  55682. * Update the total bit length for the current block.
  55683. * IN assertion: the field freq is set for all tree elements.
  55684. * OUT assertions: the fields len and code are set to the optimal bit length
  55685. * and corresponding code. The length opt_len is updated; static_len is
  55686. * also updated if stree is not null. The field max_code is set.
  55687. */
  55688. function build_tree(s, desc) // deflate_state *s;
  55689. // tree_desc *desc; /* the tree descriptor */
  55690. {
  55691. var tree = desc.dyn_tree;
  55692. var stree = desc.stat_desc.static_tree;
  55693. var has_stree = desc.stat_desc.has_stree;
  55694. var elems = desc.stat_desc.elems;
  55695. var n, m;
  55696. /* iterate over heap elements */
  55697. var max_code = -1;
  55698. /* largest code with non zero frequency */
  55699. var node;
  55700. /* new node being created */
  55701. /* Construct the initial heap, with least frequent element in
  55702. * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
  55703. * heap[0] is not used.
  55704. */
  55705. s.heap_len = 0;
  55706. s.heap_max = HEAP_SIZE;
  55707. for (n = 0; n < elems; n++) {
  55708. if (tree[n * 2]
  55709. /*.Freq*/
  55710. !== 0) {
  55711. s.heap[++s.heap_len] = max_code = n;
  55712. s.depth[n] = 0;
  55713. } else {
  55714. tree[n * 2 + 1]
  55715. /*.Len*/
  55716. = 0;
  55717. }
  55718. }
  55719. /* The pkzip format requires that at least one distance code exists,
  55720. * and that at least one bit should be sent even if there is only one
  55721. * possible code. So to avoid special checks later on we force at least
  55722. * two codes of non zero frequency.
  55723. */
  55724. while (s.heap_len < 2) {
  55725. node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;
  55726. tree[node * 2]
  55727. /*.Freq*/
  55728. = 1;
  55729. s.depth[node] = 0;
  55730. s.opt_len--;
  55731. if (has_stree) {
  55732. s.static_len -= stree[node * 2 + 1]
  55733. /*.Len*/
  55734. ;
  55735. }
  55736. /* node is 0 or 1 so it does not have extra bits */
  55737. }
  55738. desc.max_code = max_code;
  55739. /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
  55740. * establish sub-heaps of increasing lengths:
  55741. */
  55742. for (n = s.heap_len >> 1
  55743. /*int /2*/
  55744. ; n >= 1; n--) {
  55745. pqdownheap(s, tree, n);
  55746. }
  55747. /* Construct the Huffman tree by repeatedly combining the least two
  55748. * frequent nodes.
  55749. */
  55750. node = elems;
  55751. /* next internal node of the tree */
  55752. do {
  55753. //pqremove(s, tree, n); /* n = node of least frequency */
  55754. /*** pqremove ***/
  55755. n = s.heap[1
  55756. /*SMALLEST*/
  55757. ];
  55758. s.heap[1
  55759. /*SMALLEST*/
  55760. ] = s.heap[s.heap_len--];
  55761. pqdownheap(s, tree, 1
  55762. /*SMALLEST*/
  55763. );
  55764. /***/
  55765. m = s.heap[1
  55766. /*SMALLEST*/
  55767. ];
  55768. /* m = node of next least frequency */
  55769. s.heap[--s.heap_max] = n;
  55770. /* keep the nodes sorted by frequency */
  55771. s.heap[--s.heap_max] = m;
  55772. /* Create a new node father of n and m */
  55773. tree[node * 2]
  55774. /*.Freq*/
  55775. = tree[n * 2]
  55776. /*.Freq*/
  55777. + tree[m * 2]
  55778. /*.Freq*/
  55779. ;
  55780. s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
  55781. tree[n * 2 + 1]
  55782. /*.Dad*/
  55783. = tree[m * 2 + 1]
  55784. /*.Dad*/
  55785. = node;
  55786. /* and insert the new node in the heap */
  55787. s.heap[1
  55788. /*SMALLEST*/
  55789. ] = node++;
  55790. pqdownheap(s, tree, 1
  55791. /*SMALLEST*/
  55792. );
  55793. } while (s.heap_len >= 2);
  55794. s.heap[--s.heap_max] = s.heap[1
  55795. /*SMALLEST*/
  55796. ];
  55797. /* At this point, the fields freq and dad are set. We can now
  55798. * generate the bit lengths.
  55799. */
  55800. gen_bitlen(s, desc);
  55801. /* The field len is now set, we can generate the bit codes */
  55802. gen_codes(tree, max_code, s.bl_count);
  55803. }
  55804. /* ===========================================================================
  55805. * Scan a literal or distance tree to determine the frequencies of the codes
  55806. * in the bit length tree.
  55807. */
  55808. function scan_tree(s, tree, max_code) // deflate_state *s;
  55809. // ct_data *tree; /* the tree to be scanned */
  55810. // int max_code; /* and its largest code of non zero frequency */
  55811. {
  55812. var n;
  55813. /* iterates over all tree elements */
  55814. var prevlen = -1;
  55815. /* last emitted length */
  55816. var curlen;
  55817. /* length of current code */
  55818. var nextlen = tree[0 * 2 + 1]
  55819. /*.Len*/
  55820. ;
  55821. /* length of next code */
  55822. var count = 0;
  55823. /* repeat count of the current code */
  55824. var max_count = 7;
  55825. /* max repeat count */
  55826. var min_count = 4;
  55827. /* min repeat count */
  55828. if (nextlen === 0) {
  55829. max_count = 138;
  55830. min_count = 3;
  55831. }
  55832. tree[(max_code + 1) * 2 + 1]
  55833. /*.Len*/
  55834. = 0xffff;
  55835. /* guard */
  55836. for (n = 0; n <= max_code; n++) {
  55837. curlen = nextlen;
  55838. nextlen = tree[(n + 1) * 2 + 1]
  55839. /*.Len*/
  55840. ;
  55841. if (++count < max_count && curlen === nextlen) {
  55842. continue;
  55843. } else if (count < min_count) {
  55844. s.bl_tree[curlen * 2]
  55845. /*.Freq*/
  55846. += count;
  55847. } else if (curlen !== 0) {
  55848. if (curlen !== prevlen) {
  55849. s.bl_tree[curlen * 2] /*.Freq*/++;
  55850. }
  55851. s.bl_tree[REP_3_6 * 2] /*.Freq*/++;
  55852. } else if (count <= 10) {
  55853. s.bl_tree[REPZ_3_10 * 2] /*.Freq*/++;
  55854. } else {
  55855. s.bl_tree[REPZ_11_138 * 2] /*.Freq*/++;
  55856. }
  55857. count = 0;
  55858. prevlen = curlen;
  55859. if (nextlen === 0) {
  55860. max_count = 138;
  55861. min_count = 3;
  55862. } else if (curlen === nextlen) {
  55863. max_count = 6;
  55864. min_count = 3;
  55865. } else {
  55866. max_count = 7;
  55867. min_count = 4;
  55868. }
  55869. }
  55870. }
  55871. /* ===========================================================================
  55872. * Send a literal or distance tree in compressed form, using the codes in
  55873. * bl_tree.
  55874. */
  55875. function send_tree(s, tree, max_code) // deflate_state *s;
  55876. // ct_data *tree; /* the tree to be scanned */
  55877. // int max_code; /* and its largest code of non zero frequency */
  55878. {
  55879. var n;
  55880. /* iterates over all tree elements */
  55881. var prevlen = -1;
  55882. /* last emitted length */
  55883. var curlen;
  55884. /* length of current code */
  55885. var nextlen = tree[0 * 2 + 1]
  55886. /*.Len*/
  55887. ;
  55888. /* length of next code */
  55889. var count = 0;
  55890. /* repeat count of the current code */
  55891. var max_count = 7;
  55892. /* max repeat count */
  55893. var min_count = 4;
  55894. /* min repeat count */
  55895. /* tree[max_code+1].Len = -1; */
  55896. /* guard already set */
  55897. if (nextlen === 0) {
  55898. max_count = 138;
  55899. min_count = 3;
  55900. }
  55901. for (n = 0; n <= max_code; n++) {
  55902. curlen = nextlen;
  55903. nextlen = tree[(n + 1) * 2 + 1]
  55904. /*.Len*/
  55905. ;
  55906. if (++count < max_count && curlen === nextlen) {
  55907. continue;
  55908. } else if (count < min_count) {
  55909. do {
  55910. send_code(s, curlen, s.bl_tree);
  55911. } while (--count !== 0);
  55912. } else if (curlen !== 0) {
  55913. if (curlen !== prevlen) {
  55914. send_code(s, curlen, s.bl_tree);
  55915. count--;
  55916. } //Assert(count >= 3 && count <= 6, " 3_6?");
  55917. send_code(s, REP_3_6, s.bl_tree);
  55918. send_bits(s, count - 3, 2);
  55919. } else if (count <= 10) {
  55920. send_code(s, REPZ_3_10, s.bl_tree);
  55921. send_bits(s, count - 3, 3);
  55922. } else {
  55923. send_code(s, REPZ_11_138, s.bl_tree);
  55924. send_bits(s, count - 11, 7);
  55925. }
  55926. count = 0;
  55927. prevlen = curlen;
  55928. if (nextlen === 0) {
  55929. max_count = 138;
  55930. min_count = 3;
  55931. } else if (curlen === nextlen) {
  55932. max_count = 6;
  55933. min_count = 3;
  55934. } else {
  55935. max_count = 7;
  55936. min_count = 4;
  55937. }
  55938. }
  55939. }
  55940. /* ===========================================================================
  55941. * Construct the Huffman tree for the bit lengths and return the index in
  55942. * bl_order of the last bit length code to send.
  55943. */
  55944. function build_bl_tree(s) {
  55945. var max_blindex;
  55946. /* index of last bit length code of non zero freq */
  55947. /* Determine the bit length frequencies for literal and distance trees */
  55948. scan_tree(s, s.dyn_ltree, s.l_desc.max_code);
  55949. scan_tree(s, s.dyn_dtree, s.d_desc.max_code);
  55950. /* Build the bit length tree: */
  55951. build_tree(s, s.bl_desc);
  55952. /* opt_len now includes the length of the tree representations, except
  55953. * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
  55954. */
  55955. /* Determine the number of bit length codes to send. The pkzip format
  55956. * requires that at least 4 bit length codes be sent. (appnote.txt says
  55957. * 3 but the actual value used is 4.)
  55958. */
  55959. for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {
  55960. if (s.bl_tree[bl_order[max_blindex] * 2 + 1]
  55961. /*.Len*/
  55962. !== 0) {
  55963. break;
  55964. }
  55965. }
  55966. /* Update opt_len to include the bit length tree and counts */
  55967. s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; //Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
  55968. // s->opt_len, s->static_len));
  55969. return max_blindex;
  55970. }
  55971. /* ===========================================================================
  55972. * Send the header for a block using dynamic Huffman trees: the counts, the
  55973. * lengths of the bit length codes, the literal tree and the distance tree.
  55974. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
  55975. */
  55976. function send_all_trees(s, lcodes, dcodes, blcodes) // deflate_state *s;
  55977. // int lcodes, dcodes, blcodes; /* number of codes for each tree */
  55978. {
  55979. var rank;
  55980. /* index in bl_order */
  55981. //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
  55982. //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
  55983. // "too many codes");
  55984. //Tracev((stderr, "\nbl counts: "));
  55985. send_bits(s, lcodes - 257, 5);
  55986. /* not +255 as stated in appnote.txt */
  55987. send_bits(s, dcodes - 1, 5);
  55988. send_bits(s, blcodes - 4, 4);
  55989. /* not -3 as stated in appnote.txt */
  55990. for (rank = 0; rank < blcodes; rank++) {
  55991. //Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
  55992. send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]
  55993. /*.Len*/
  55994. , 3);
  55995. } //Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
  55996. send_tree(s, s.dyn_ltree, lcodes - 1);
  55997. /* literal tree */
  55998. //Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
  55999. send_tree(s, s.dyn_dtree, dcodes - 1);
  56000. /* distance tree */
  56001. //Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
  56002. }
  56003. /* ===========================================================================
  56004. * Check if the data type is TEXT or BINARY, using the following algorithm:
  56005. * - TEXT if the two conditions below are satisfied:
  56006. * a) There are no non-portable control characters belonging to the
  56007. * "black list" (0..6, 14..25, 28..31).
  56008. * b) There is at least one printable character belonging to the
  56009. * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
  56010. * - BINARY otherwise.
  56011. * - The following partially-portable control characters form a
  56012. * "gray list" that is ignored in this detection algorithm:
  56013. * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
  56014. * IN assertion: the fields Freq of dyn_ltree are set.
  56015. */
  56016. function detect_data_type(s) {
  56017. /* black_mask is the bit mask of black-listed bytes
  56018. * set bits 0..6, 14..25, and 28..31
  56019. * 0xf3ffc07f = binary 11110011111111111100000001111111
  56020. */
  56021. var black_mask = 0xf3ffc07f;
  56022. var n;
  56023. /* Check for non-textual ("black-listed") bytes. */
  56024. for (n = 0; n <= 31; n++, black_mask >>>= 1) {
  56025. if (black_mask & 1 && s.dyn_ltree[n * 2]
  56026. /*.Freq*/
  56027. !== 0) {
  56028. return Z_BINARY;
  56029. }
  56030. }
  56031. /* Check for textual ("white-listed") bytes. */
  56032. if (s.dyn_ltree[9 * 2]
  56033. /*.Freq*/
  56034. !== 0 || s.dyn_ltree[10 * 2]
  56035. /*.Freq*/
  56036. !== 0 || s.dyn_ltree[13 * 2]
  56037. /*.Freq*/
  56038. !== 0) {
  56039. return Z_TEXT;
  56040. }
  56041. for (n = 32; n < LITERALS; n++) {
  56042. if (s.dyn_ltree[n * 2]
  56043. /*.Freq*/
  56044. !== 0) {
  56045. return Z_TEXT;
  56046. }
  56047. }
  56048. /* There are no "black-listed" or "white-listed" bytes:
  56049. * this stream either is empty or has tolerated ("gray-listed") bytes only.
  56050. */
  56051. return Z_BINARY;
  56052. }
  56053. var static_init_done = false;
  56054. /* ===========================================================================
  56055. * Initialize the tree data structures for a new zlib stream.
  56056. */
  56057. function _tr_init(s) {
  56058. if (!static_init_done) {
  56059. tr_static_init();
  56060. static_init_done = true;
  56061. }
  56062. s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);
  56063. s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);
  56064. s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);
  56065. s.bi_buf = 0;
  56066. s.bi_valid = 0;
  56067. /* Initialize the first block of the first file: */
  56068. init_block(s);
  56069. }
  56070. /* ===========================================================================
  56071. * Send a stored block
  56072. */
  56073. function _tr_stored_block(s, buf, stored_len, last) //DeflateState *s;
  56074. //charf *buf; /* input block */
  56075. //ulg stored_len; /* length of input block */
  56076. //int last; /* one if this is the last block for a file */
  56077. {
  56078. send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);
  56079. /* send block type */
  56080. copy_block(s, buf, stored_len, true);
  56081. /* with header */
  56082. }
  56083. /* ===========================================================================
  56084. * Send one empty static block to give enough lookahead for inflate.
  56085. * This takes 10 bits, of which 7 may remain in the bit buffer.
  56086. */
  56087. function _tr_align(s) {
  56088. send_bits(s, STATIC_TREES << 1, 3);
  56089. send_code(s, END_BLOCK, static_ltree);
  56090. bi_flush(s);
  56091. }
  56092. /* ===========================================================================
  56093. * Determine the best encoding for the current block: dynamic trees, static
  56094. * trees or store, and output the encoded block to the zip file.
  56095. */
  56096. function _tr_flush_block(s, buf, stored_len, last) //DeflateState *s;
  56097. //charf *buf; /* input block, or NULL if too old */
  56098. //ulg stored_len; /* length of input block */
  56099. //int last; /* one if this is the last block for a file */
  56100. {
  56101. var opt_lenb, static_lenb;
  56102. /* opt_len and static_len in bytes */
  56103. var max_blindex = 0;
  56104. /* index of last bit length code of non zero freq */
  56105. /* Build the Huffman trees unless a stored block is forced */
  56106. if (s.level > 0) {
  56107. /* Check if the file is binary or text */
  56108. if (s.strm.data_type === Z_UNKNOWN) {
  56109. s.strm.data_type = detect_data_type(s);
  56110. }
  56111. /* Construct the literal and distance trees */
  56112. build_tree(s, s.l_desc); // Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
  56113. // s->static_len));
  56114. build_tree(s, s.d_desc); // Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
  56115. // s->static_len));
  56116. /* At this point, opt_len and static_len are the total bit lengths of
  56117. * the compressed block data, excluding the tree representations.
  56118. */
  56119. /* Build the bit length tree for the above two trees, and get the index
  56120. * in bl_order of the last bit length code to send.
  56121. */
  56122. max_blindex = build_bl_tree(s);
  56123. /* Determine the best encoding. Compute the block lengths in bytes. */
  56124. opt_lenb = s.opt_len + 3 + 7 >>> 3;
  56125. static_lenb = s.static_len + 3 + 7 >>> 3; // Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
  56126. // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
  56127. // s->last_lit));
  56128. if (static_lenb <= opt_lenb) {
  56129. opt_lenb = static_lenb;
  56130. }
  56131. } else {
  56132. // Assert(buf != (char*)0, "lost buf");
  56133. opt_lenb = static_lenb = stored_len + 5;
  56134. /* force a stored block */
  56135. }
  56136. if (stored_len + 4 <= opt_lenb && buf !== -1) {
  56137. /* 4: two words for the lengths */
  56138. /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
  56139. * Otherwise we can't have processed more than WSIZE input bytes since
  56140. * the last block flush, because compression would have been
  56141. * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
  56142. * transform a block into a stored block.
  56143. */
  56144. _tr_stored_block(s, buf, stored_len, last);
  56145. } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {
  56146. send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);
  56147. compress_block(s, static_ltree, static_dtree);
  56148. } else {
  56149. send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);
  56150. send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);
  56151. compress_block(s, s.dyn_ltree, s.dyn_dtree);
  56152. } // Assert (s->compressed_len == s->bits_sent, "bad compressed size");
  56153. /* The above check is made mod 2^32, for files larger than 512 MB
  56154. * and uLong implemented on 32 bits.
  56155. */
  56156. init_block(s);
  56157. if (last) {
  56158. bi_windup(s);
  56159. } // Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
  56160. // s->compressed_len-7*last));
  56161. }
  56162. /* ===========================================================================
  56163. * Save the match info and tally the frequency counts. Return true if
  56164. * the current block must be flushed.
  56165. */
  56166. function _tr_tally(s, dist, lc) // deflate_state *s;
  56167. // unsigned dist; /* distance of matched string */
  56168. // unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
  56169. {
  56170. //var out_length, in_length, dcode;
  56171. s.pending_buf[s.d_buf + s.last_lit * 2] = dist >>> 8 & 0xff;
  56172. s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;
  56173. s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;
  56174. s.last_lit++;
  56175. if (dist === 0) {
  56176. /* lc is the unmatched char */
  56177. s.dyn_ltree[lc * 2] /*.Freq*/++;
  56178. } else {
  56179. s.matches++;
  56180. /* Here, lc is the match length - MIN_MATCH */
  56181. dist--;
  56182. /* dist = match distance - 1 */
  56183. //Assert((ush)dist < (ush)MAX_DIST(s) &&
  56184. // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
  56185. // (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
  56186. s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2] /*.Freq*/++;
  56187. s.dyn_dtree[d_code(dist) * 2] /*.Freq*/++;
  56188. } // (!) This block is disabled in zlib defaults,
  56189. // don't enable it for binary compatibility
  56190. //#ifdef TRUNCATE_BLOCK
  56191. // /* Try to guess if it is profitable to stop the current block here */
  56192. // if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {
  56193. // /* Compute an upper bound for the compressed length */
  56194. // out_length = s.last_lit*8;
  56195. // in_length = s.strstart - s.block_start;
  56196. //
  56197. // for (dcode = 0; dcode < D_CODES; dcode++) {
  56198. // out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);
  56199. // }
  56200. // out_length >>>= 3;
  56201. // //Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
  56202. // // s->last_lit, in_length, out_length,
  56203. // // 100L - out_length*100L/in_length));
  56204. // if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {
  56205. // return true;
  56206. // }
  56207. // }
  56208. //#endif
  56209. return s.last_lit === s.lit_bufsize - 1;
  56210. /* We avoid equality with lit_bufsize because of wraparound at 64K
  56211. * on 16 bit machines and because stored blocks are restricted to
  56212. * 64K-1 bytes.
  56213. */
  56214. }
  56215. exports._tr_init = _tr_init;
  56216. exports._tr_stored_block = _tr_stored_block;
  56217. exports._tr_flush_block = _tr_flush_block;
  56218. exports._tr_tally = _tr_tally;
  56219. exports._tr_align = _tr_align;
  56220. }, { "../utils/common": 442 }], 454: [function (require, module, exports) {
  56221. 'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
  56222. // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
  56223. //
  56224. // This software is provided 'as-is', without any express or implied
  56225. // warranty. In no event will the authors be held liable for any damages
  56226. // arising from the use of this software.
  56227. //
  56228. // Permission is granted to anyone to use this software for any purpose,
  56229. // including commercial applications, and to alter it and redistribute it
  56230. // freely, subject to the following restrictions:
  56231. //
  56232. // 1. The origin of this software must not be misrepresented; you must not
  56233. // claim that you wrote the original software. If you use this software
  56234. // in a product, an acknowledgment in the product documentation would be
  56235. // appreciated but is not required.
  56236. // 2. Altered source versions must be plainly marked as such, and must not be
  56237. // misrepresented as being the original software.
  56238. // 3. This notice may not be removed or altered from any source distribution.
  56239. function ZStream() {
  56240. /* next input byte */
  56241. this.input = null; // JS specific, because we have no pointers
  56242. this.next_in = 0;
  56243. /* number of bytes available at input */
  56244. this.avail_in = 0;
  56245. /* total number of input bytes read so far */
  56246. this.total_in = 0;
  56247. /* next output byte should be put there */
  56248. this.output = null; // JS specific, because we have no pointers
  56249. this.next_out = 0;
  56250. /* remaining free space at output */
  56251. this.avail_out = 0;
  56252. /* total number of bytes output so far */
  56253. this.total_out = 0;
  56254. /* last error message, NULL if no error */
  56255. this.msg = ''
  56256. /*Z_NULL*/
  56257. ;
  56258. /* not visible by applications */
  56259. this.state = null;
  56260. /* best guess about the data type: binary or text */
  56261. this.data_type = 2
  56262. /*Z_UNKNOWN*/
  56263. ;
  56264. /* adler32 value of the uncompressed data */
  56265. this.adler = 0;
  56266. }
  56267. module.exports = ZStream;
  56268. }, {}], 455: [function (require, module, exports) {
  56269. module.exports = {
  56270. "2.16.840.1.101.3.4.1.1": "aes-128-ecb",
  56271. "2.16.840.1.101.3.4.1.2": "aes-128-cbc",
  56272. "2.16.840.1.101.3.4.1.3": "aes-128-ofb",
  56273. "2.16.840.1.101.3.4.1.4": "aes-128-cfb",
  56274. "2.16.840.1.101.3.4.1.21": "aes-192-ecb",
  56275. "2.16.840.1.101.3.4.1.22": "aes-192-cbc",
  56276. "2.16.840.1.101.3.4.1.23": "aes-192-ofb",
  56277. "2.16.840.1.101.3.4.1.24": "aes-192-cfb",
  56278. "2.16.840.1.101.3.4.1.41": "aes-256-ecb",
  56279. "2.16.840.1.101.3.4.1.42": "aes-256-cbc",
  56280. "2.16.840.1.101.3.4.1.43": "aes-256-ofb",
  56281. "2.16.840.1.101.3.4.1.44": "aes-256-cfb"
  56282. }
  56283. }, {}], 456: [function (require, module, exports) {
  56284. // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
  56285. // Fedor, you are amazing.
  56286. 'use strict';
  56287. var asn1 = require('asn1.js');
  56288. exports.certificate = require('./certificate');
  56289. var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
  56290. this.seq().obj(this.key('version').int(), this.key('modulus').int(), this.key('publicExponent').int(), this.key('privateExponent').int(), this.key('prime1').int(), this.key('prime2').int(), this.key('exponent1').int(), this.key('exponent2').int(), this.key('coefficient').int());
  56291. });
  56292. exports.RSAPrivateKey = RSAPrivateKey;
  56293. var RSAPublicKey = asn1.define('RSAPublicKey', function () {
  56294. this.seq().obj(this.key('modulus').int(), this.key('publicExponent').int());
  56295. });
  56296. exports.RSAPublicKey = RSAPublicKey;
  56297. var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
  56298. this.seq().obj(this.key('algorithm').use(AlgorithmIdentifier), this.key('subjectPublicKey').bitstr());
  56299. });
  56300. exports.PublicKey = PublicKey;
  56301. var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
  56302. this.seq().obj(this.key('algorithm').objid(), this.key('none').null_().optional(), this.key('curve').objid().optional(), this.key('params').seq().obj(this.key('p').int(), this.key('q').int(), this.key('g').int()).optional());
  56303. });
  56304. var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
  56305. this.seq().obj(this.key('version').int(), this.key('algorithm').use(AlgorithmIdentifier), this.key('subjectPrivateKey').octstr());
  56306. });
  56307. exports.PrivateKey = PrivateKeyInfo;
  56308. var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
  56309. this.seq().obj(this.key('algorithm').seq().obj(this.key('id').objid(), this.key('decrypt').seq().obj(this.key('kde').seq().obj(this.key('id').objid(), this.key('kdeparams').seq().obj(this.key('salt').octstr(), this.key('iters').int())), this.key('cipher').seq().obj(this.key('algo').objid(), this.key('iv').octstr()))), this.key('subjectPrivateKey').octstr());
  56310. });
  56311. exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo;
  56312. var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
  56313. this.seq().obj(this.key('version').int(), this.key('p').int(), this.key('q').int(), this.key('g').int(), this.key('pub_key').int(), this.key('priv_key').int());
  56314. });
  56315. exports.DSAPrivateKey = DSAPrivateKey;
  56316. exports.DSAparam = asn1.define('DSAparam', function () {
  56317. this.int();
  56318. });
  56319. var ECPrivateKey = asn1.define('ECPrivateKey', function () {
  56320. this.seq().obj(this.key('version').int(), this.key('privateKey').octstr(), this.key('parameters').optional().explicit(0).use(ECParameters), this.key('publicKey').optional().explicit(1).bitstr());
  56321. });
  56322. exports.ECPrivateKey = ECPrivateKey;
  56323. var ECParameters = asn1.define('ECParameters', function () {
  56324. this.choice({
  56325. namedCurve: this.objid()
  56326. });
  56327. });
  56328. exports.signature = asn1.define('signature', function () {
  56329. this.seq().obj(this.key('r').int(), this.key('s').int());
  56330. });
  56331. }, { "./certificate": 457, "asn1.js": 167 }], 457: [function (require, module, exports) {
  56332. // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
  56333. // thanks to @Rantanen
  56334. 'use strict';
  56335. var asn = require('asn1.js');
  56336. var Time = asn.define('Time', function () {
  56337. this.choice({
  56338. utcTime: this.utctime(),
  56339. generalTime: this.gentime()
  56340. });
  56341. });
  56342. var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
  56343. this.seq().obj(this.key('type').objid(), this.key('value').any());
  56344. });
  56345. var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
  56346. this.seq().obj(this.key('algorithm').objid(), this.key('parameters').optional(), this.key('curve').objid().optional());
  56347. });
  56348. var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
  56349. this.seq().obj(this.key('algorithm').use(AlgorithmIdentifier), this.key('subjectPublicKey').bitstr());
  56350. });
  56351. var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
  56352. this.setof(AttributeTypeValue);
  56353. });
  56354. var RDNSequence = asn.define('RDNSequence', function () {
  56355. this.seqof(RelativeDistinguishedName);
  56356. });
  56357. var Name = asn.define('Name', function () {
  56358. this.choice({
  56359. rdnSequence: this.use(RDNSequence)
  56360. });
  56361. });
  56362. var Validity = asn.define('Validity', function () {
  56363. this.seq().obj(this.key('notBefore').use(Time), this.key('notAfter').use(Time));
  56364. });
  56365. var Extension = asn.define('Extension', function () {
  56366. this.seq().obj(this.key('extnID').objid(), this.key('critical').bool().def(false), this.key('extnValue').octstr());
  56367. });
  56368. var TBSCertificate = asn.define('TBSCertificate', function () {
  56369. this.seq().obj(this.key('version').explicit(0).int().optional(), this.key('serialNumber').int(), this.key('signature').use(AlgorithmIdentifier), this.key('issuer').use(Name), this.key('validity').use(Validity), this.key('subject').use(Name), this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), this.key('issuerUniqueID').implicit(1).bitstr().optional(), this.key('subjectUniqueID').implicit(2).bitstr().optional(), this.key('extensions').explicit(3).seqof(Extension).optional());
  56370. });
  56371. var X509Certificate = asn.define('X509Certificate', function () {
  56372. this.seq().obj(this.key('tbsCertificate').use(TBSCertificate), this.key('signatureAlgorithm').use(AlgorithmIdentifier), this.key('signatureValue').bitstr());
  56373. });
  56374. module.exports = X509Certificate;
  56375. }, { "asn1.js": 167 }], 458: [function (require, module, exports) {
  56376. "use strict";
  56377. // adapted from https://github.com/apatil/pemstrip
  56378. var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m;
  56379. var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m;
  56380. var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m;
  56381. var evp = require('evp_bytestokey');
  56382. var ciphers = require('browserify-aes');
  56383. var Buffer = require('safe-buffer').Buffer;
  56384. module.exports = function (okey, password) {
  56385. var key = okey.toString();
  56386. var match = key.match(findProc);
  56387. var decrypted;
  56388. if (!match) {
  56389. var match2 = key.match(fullRegex);
  56390. decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64');
  56391. } else {
  56392. var suite = 'aes' + match[1];
  56393. var iv = Buffer.from(match[2], 'hex');
  56394. var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64');
  56395. var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key;
  56396. var out = [];
  56397. var cipher = ciphers.createDecipheriv(suite, cipherKey, iv);
  56398. out.push(cipher.update(cipherText));
  56399. out.push(cipher.final());
  56400. decrypted = Buffer.concat(out);
  56401. }
  56402. var tag = key.match(startRegex)[1];
  56403. return {
  56404. tag: tag,
  56405. data: decrypted
  56406. };
  56407. };
  56408. }, { "browserify-aes": 188, "evp_bytestokey": 368, "safe-buffer": 494 }], 459: [function (require, module, exports) {
  56409. "use strict";
  56410. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  56411. var asn1 = require('./asn1');
  56412. var aesid = require('./aesid.json');
  56413. var fixProc = require('./fixProc');
  56414. var ciphers = require('browserify-aes');
  56415. var compat = require('pbkdf2');
  56416. var Buffer = require('safe-buffer').Buffer;
  56417. module.exports = parseKeys;
  56418. function parseKeys(buffer) {
  56419. var password;
  56420. if (_typeof(buffer) === 'object' && !Buffer.isBuffer(buffer)) {
  56421. password = buffer.passphrase;
  56422. buffer = buffer.key;
  56423. }
  56424. if (typeof buffer === 'string') {
  56425. buffer = Buffer.from(buffer);
  56426. }
  56427. var stripped = fixProc(buffer, password);
  56428. var type = stripped.tag;
  56429. var data = stripped.data;
  56430. var subtype, ndata;
  56431. switch (type) {
  56432. case 'CERTIFICATE':
  56433. ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo;
  56434. // falls through
  56435. case 'PUBLIC KEY':
  56436. if (!ndata) {
  56437. ndata = asn1.PublicKey.decode(data, 'der');
  56438. }
  56439. subtype = ndata.algorithm.algorithm.join('.');
  56440. switch (subtype) {
  56441. case '1.2.840.113549.1.1.1':
  56442. return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der');
  56443. case '1.2.840.10045.2.1':
  56444. ndata.subjectPrivateKey = ndata.subjectPublicKey;
  56445. return {
  56446. type: 'ec',
  56447. data: ndata
  56448. };
  56449. case '1.2.840.10040.4.1':
  56450. ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der');
  56451. return {
  56452. type: 'dsa',
  56453. data: ndata.algorithm.params
  56454. };
  56455. default:
  56456. throw new Error('unknown key id ' + subtype);
  56457. }
  56458. // throw new Error('unknown key type ' + type)
  56459. case 'ENCRYPTED PRIVATE KEY':
  56460. data = asn1.EncryptedPrivateKey.decode(data, 'der');
  56461. data = decrypt(data, password);
  56462. // falls through
  56463. case 'PRIVATE KEY':
  56464. ndata = asn1.PrivateKey.decode(data, 'der');
  56465. subtype = ndata.algorithm.algorithm.join('.');
  56466. switch (subtype) {
  56467. case '1.2.840.113549.1.1.1':
  56468. return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der');
  56469. case '1.2.840.10045.2.1':
  56470. return {
  56471. curve: ndata.algorithm.curve,
  56472. privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
  56473. };
  56474. case '1.2.840.10040.4.1':
  56475. ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der');
  56476. return {
  56477. type: 'dsa',
  56478. params: ndata.algorithm.params
  56479. };
  56480. default:
  56481. throw new Error('unknown key id ' + subtype);
  56482. }
  56483. // throw new Error('unknown key type ' + type)
  56484. case 'RSA PUBLIC KEY':
  56485. return asn1.RSAPublicKey.decode(data, 'der');
  56486. case 'RSA PRIVATE KEY':
  56487. return asn1.RSAPrivateKey.decode(data, 'der');
  56488. case 'DSA PRIVATE KEY':
  56489. return {
  56490. type: 'dsa',
  56491. params: asn1.DSAPrivateKey.decode(data, 'der')
  56492. };
  56493. case 'EC PRIVATE KEY':
  56494. data = asn1.ECPrivateKey.decode(data, 'der');
  56495. return {
  56496. curve: data.parameters.value,
  56497. privateKey: data.privateKey
  56498. };
  56499. default:
  56500. throw new Error('unknown key type ' + type);
  56501. }
  56502. }
  56503. parseKeys.signature = asn1.signature;
  56504. function decrypt(data, password) {
  56505. var salt = data.algorithm.decrypt.kde.kdeparams.salt;
  56506. var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10);
  56507. var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')];
  56508. var iv = data.algorithm.decrypt.cipher.iv;
  56509. var cipherText = data.subjectPrivateKey;
  56510. var keylen = parseInt(algo.split('-')[1], 10) / 8;
  56511. var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1');
  56512. var cipher = ciphers.createDecipheriv(algo, key, iv);
  56513. var out = [];
  56514. out.push(cipher.update(cipherText));
  56515. out.push(cipher.final());
  56516. return Buffer.concat(out);
  56517. }
  56518. }, { "./aesid.json": 455, "./asn1": 456, "./fixProc": 458, "browserify-aes": 188, "pbkdf2": 460, "safe-buffer": 494 }], 460: [function (require, module, exports) {
  56519. "use strict";
  56520. exports.pbkdf2 = require('./lib/async');
  56521. exports.pbkdf2Sync = require('./lib/sync');
  56522. }, { "./lib/async": 461, "./lib/sync": 464 }], 461: [function (require, module, exports) {
  56523. (function (process, global) {
  56524. "use strict";
  56525. var Buffer = require('safe-buffer').Buffer;
  56526. var checkParameters = require('./precondition');
  56527. var defaultEncoding = require('./default-encoding');
  56528. var sync = require('./sync');
  56529. var toBuffer = require('./to-buffer');
  56530. var ZERO_BUF;
  56531. var subtle = global.crypto && global.crypto.subtle;
  56532. var toBrowser = {
  56533. sha: 'SHA-1',
  56534. 'sha-1': 'SHA-1',
  56535. sha1: 'SHA-1',
  56536. sha256: 'SHA-256',
  56537. 'sha-256': 'SHA-256',
  56538. sha384: 'SHA-384',
  56539. 'sha-384': 'SHA-384',
  56540. 'sha-512': 'SHA-512',
  56541. sha512: 'SHA-512'
  56542. };
  56543. var checks = [];
  56544. function checkNative(algo) {
  56545. if (global.process && !global.process.browser) {
  56546. return Promise.resolve(false);
  56547. }
  56548. if (!subtle || !subtle.importKey || !subtle.deriveBits) {
  56549. return Promise.resolve(false);
  56550. }
  56551. if (checks[algo] !== undefined) {
  56552. return checks[algo];
  56553. }
  56554. ZERO_BUF = ZERO_BUF || Buffer.alloc(8);
  56555. var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo).then(function () {
  56556. return true;
  56557. }).catch(function () {
  56558. return false;
  56559. });
  56560. checks[algo] = prom;
  56561. return prom;
  56562. }
  56563. function browserPbkdf2(password, salt, iterations, length, algo) {
  56564. return subtle.importKey('raw', password, {
  56565. name: 'PBKDF2'
  56566. }, false, ['deriveBits']).then(function (key) {
  56567. return subtle.deriveBits({
  56568. name: 'PBKDF2',
  56569. salt: salt,
  56570. iterations: iterations,
  56571. hash: {
  56572. name: algo
  56573. }
  56574. }, key, length << 3);
  56575. }).then(function (res) {
  56576. return Buffer.from(res);
  56577. });
  56578. }
  56579. function resolvePromise(promise, callback) {
  56580. promise.then(function (out) {
  56581. process.nextTick(function () {
  56582. callback(null, out);
  56583. });
  56584. }, function (e) {
  56585. process.nextTick(function () {
  56586. callback(e);
  56587. });
  56588. });
  56589. }
  56590. module.exports = function (password, salt, iterations, keylen, digest, callback) {
  56591. if (typeof digest === 'function') {
  56592. callback = digest;
  56593. digest = undefined;
  56594. }
  56595. digest = digest || 'sha1';
  56596. var algo = toBrowser[digest.toLowerCase()];
  56597. if (!algo || typeof global.Promise !== 'function') {
  56598. return process.nextTick(function () {
  56599. var out;
  56600. try {
  56601. out = sync(password, salt, iterations, keylen, digest);
  56602. } catch (e) {
  56603. return callback(e);
  56604. }
  56605. callback(null, out);
  56606. });
  56607. }
  56608. checkParameters(iterations, keylen);
  56609. password = toBuffer(password, defaultEncoding, 'Password');
  56610. salt = toBuffer(salt, defaultEncoding, 'Salt');
  56611. if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2');
  56612. resolvePromise(checkNative(algo).then(function (resp) {
  56613. if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo);
  56614. return sync(password, salt, iterations, keylen, digest);
  56615. }), callback);
  56616. };
  56617. }).call(this, require('_process'), typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  56618. }, { "./default-encoding": 462, "./precondition": 463, "./sync": 464, "./to-buffer": 465, "_process": 467, "safe-buffer": 494 }], 462: [function (require, module, exports) {
  56619. (function (process) {
  56620. "use strict";
  56621. var defaultEncoding;
  56622. /* istanbul ignore next */
  56623. if (process.browser) {
  56624. defaultEncoding = 'utf-8';
  56625. } else if (process.version) {
  56626. var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10);
  56627. defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary';
  56628. } else {
  56629. defaultEncoding = 'utf-8';
  56630. }
  56631. module.exports = defaultEncoding;
  56632. }).call(this, require('_process'))
  56633. }, { "_process": 467 }], 463: [function (require, module, exports) {
  56634. "use strict";
  56635. var MAX_ALLOC = Math.pow(2, 30) - 1; // default in iojs
  56636. module.exports = function (iterations, keylen) {
  56637. if (typeof iterations !== 'number') {
  56638. throw new TypeError('Iterations not a number');
  56639. }
  56640. if (iterations < 0) {
  56641. throw new TypeError('Bad iterations');
  56642. }
  56643. if (typeof keylen !== 'number') {
  56644. throw new TypeError('Key length not a number');
  56645. }
  56646. if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) {
  56647. /* eslint no-self-compare: 0 */
  56648. throw new TypeError('Bad key length');
  56649. }
  56650. };
  56651. }, {}], 464: [function (require, module, exports) {
  56652. "use strict";
  56653. var md5 = require('create-hash/md5');
  56654. var RIPEMD160 = require('ripemd160');
  56655. var sha = require('sha.js');
  56656. var Buffer = require('safe-buffer').Buffer;
  56657. var checkParameters = require('./precondition');
  56658. var defaultEncoding = require('./default-encoding');
  56659. var toBuffer = require('./to-buffer');
  56660. var ZEROS = Buffer.alloc(128);
  56661. var sizes = {
  56662. md5: 16,
  56663. sha1: 20,
  56664. sha224: 28,
  56665. sha256: 32,
  56666. sha384: 48,
  56667. sha512: 64,
  56668. rmd160: 20,
  56669. ripemd160: 20
  56670. };
  56671. function Hmac(alg, key, saltLen) {
  56672. var hash = getDigest(alg);
  56673. var blocksize = alg === 'sha512' || alg === 'sha384' ? 128 : 64;
  56674. if (key.length > blocksize) {
  56675. key = hash(key);
  56676. } else if (key.length < blocksize) {
  56677. key = Buffer.concat([key, ZEROS], blocksize);
  56678. }
  56679. var ipad = Buffer.allocUnsafe(blocksize + sizes[alg]);
  56680. var opad = Buffer.allocUnsafe(blocksize + sizes[alg]);
  56681. for (var i = 0; i < blocksize; i++) {
  56682. ipad[i] = key[i] ^ 0x36;
  56683. opad[i] = key[i] ^ 0x5C;
  56684. }
  56685. var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4);
  56686. ipad.copy(ipad1, 0, 0, blocksize);
  56687. this.ipad1 = ipad1;
  56688. this.ipad2 = ipad;
  56689. this.opad = opad;
  56690. this.alg = alg;
  56691. this.blocksize = blocksize;
  56692. this.hash = hash;
  56693. this.size = sizes[alg];
  56694. }
  56695. Hmac.prototype.run = function (data, ipad) {
  56696. data.copy(ipad, this.blocksize);
  56697. var h = this.hash(ipad);
  56698. h.copy(this.opad, this.blocksize);
  56699. return this.hash(this.opad);
  56700. };
  56701. function getDigest(alg) {
  56702. function shaFunc(data) {
  56703. return sha(alg).update(data).digest();
  56704. }
  56705. function rmd160Func(data) {
  56706. return new RIPEMD160().update(data).digest();
  56707. }
  56708. if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func;
  56709. if (alg === 'md5') return md5;
  56710. return shaFunc;
  56711. }
  56712. function pbkdf2(password, salt, iterations, keylen, digest) {
  56713. checkParameters(iterations, keylen);
  56714. password = toBuffer(password, defaultEncoding, 'Password');
  56715. salt = toBuffer(salt, defaultEncoding, 'Salt');
  56716. digest = digest || 'sha1';
  56717. var hmac = new Hmac(digest, password, salt.length);
  56718. var DK = Buffer.allocUnsafe(keylen);
  56719. var block1 = Buffer.allocUnsafe(salt.length + 4);
  56720. salt.copy(block1, 0, 0, salt.length);
  56721. var destPos = 0;
  56722. var hLen = sizes[digest];
  56723. var l = Math.ceil(keylen / hLen);
  56724. for (var i = 1; i <= l; i++) {
  56725. block1.writeUInt32BE(i, salt.length);
  56726. var T = hmac.run(block1, hmac.ipad1);
  56727. var U = T;
  56728. for (var j = 1; j < iterations; j++) {
  56729. U = hmac.run(U, hmac.ipad2);
  56730. for (var k = 0; k < hLen; k++) {
  56731. T[k] ^= U[k];
  56732. }
  56733. }
  56734. T.copy(DK, destPos);
  56735. destPos += hLen;
  56736. }
  56737. return DK;
  56738. }
  56739. module.exports = pbkdf2;
  56740. }, { "./default-encoding": 462, "./precondition": 463, "./to-buffer": 465, "create-hash/md5": 332, "ripemd160": 493, "safe-buffer": 494, "sha.js": 499 }], 465: [function (require, module, exports) {
  56741. "use strict";
  56742. var Buffer = require('safe-buffer').Buffer;
  56743. module.exports = function (thing, encoding, name) {
  56744. if (Buffer.isBuffer(thing)) {
  56745. return thing;
  56746. } else if (typeof thing === 'string') {
  56747. return Buffer.from(thing, encoding);
  56748. } else if (ArrayBuffer.isView(thing)) {
  56749. return Buffer.from(thing.buffer);
  56750. } else {
  56751. throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView');
  56752. }
  56753. };
  56754. }, { "safe-buffer": 494 }], 466: [function (require, module, exports) {
  56755. (function (process) {
  56756. 'use strict';
  56757. if (typeof process === 'undefined' || !process.version || process.version.indexOf('v0.') === 0 || process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  56758. module.exports = {
  56759. nextTick: nextTick
  56760. };
  56761. } else {
  56762. module.exports = process;
  56763. }
  56764. function nextTick(fn, arg1, arg2, arg3) {
  56765. if (typeof fn !== 'function') {
  56766. throw new TypeError('"callback" argument must be a function');
  56767. }
  56768. var len = arguments.length;
  56769. var args, i;
  56770. switch (len) {
  56771. case 0:
  56772. case 1:
  56773. return process.nextTick(fn);
  56774. case 2:
  56775. return process.nextTick(function afterTickOne() {
  56776. fn.call(null, arg1);
  56777. });
  56778. case 3:
  56779. return process.nextTick(function afterTickTwo() {
  56780. fn.call(null, arg1, arg2);
  56781. });
  56782. case 4:
  56783. return process.nextTick(function afterTickThree() {
  56784. fn.call(null, arg1, arg2, arg3);
  56785. });
  56786. default:
  56787. args = new Array(len - 1);
  56788. i = 0;
  56789. while (i < args.length) {
  56790. args[i++] = arguments[i];
  56791. }
  56792. return process.nextTick(function afterTick() {
  56793. fn.apply(null, args);
  56794. });
  56795. }
  56796. }
  56797. }).call(this, require('_process'))
  56798. }, { "_process": 467 }], 467: [function (require, module, exports) {
  56799. "use strict";
  56800. // shim for using process in browser
  56801. var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it
  56802. // don't break things. But we need to wrap it in a try catch in case it is
  56803. // wrapped in strict mode code which doesn't define any globals. It's inside a
  56804. // function because try/catches deoptimize in certain engines.
  56805. var cachedSetTimeout;
  56806. var cachedClearTimeout;
  56807. function defaultSetTimout() {
  56808. throw new Error('setTimeout has not been defined');
  56809. }
  56810. function defaultClearTimeout() {
  56811. throw new Error('clearTimeout has not been defined');
  56812. }
  56813. (function () {
  56814. try {
  56815. if (typeof setTimeout === 'function') {
  56816. cachedSetTimeout = setTimeout;
  56817. } else {
  56818. cachedSetTimeout = defaultSetTimout;
  56819. }
  56820. } catch (e) {
  56821. cachedSetTimeout = defaultSetTimout;
  56822. }
  56823. try {
  56824. if (typeof clearTimeout === 'function') {
  56825. cachedClearTimeout = clearTimeout;
  56826. } else {
  56827. cachedClearTimeout = defaultClearTimeout;
  56828. }
  56829. } catch (e) {
  56830. cachedClearTimeout = defaultClearTimeout;
  56831. }
  56832. })();
  56833. function runTimeout(fun) {
  56834. if (cachedSetTimeout === setTimeout) {
  56835. //normal enviroments in sane situations
  56836. return setTimeout(fun, 0);
  56837. } // if setTimeout wasn't available but was latter defined
  56838. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  56839. cachedSetTimeout = setTimeout;
  56840. return setTimeout(fun, 0);
  56841. }
  56842. try {
  56843. // when when somebody has screwed with setTimeout but no I.E. maddness
  56844. return cachedSetTimeout(fun, 0);
  56845. } catch (e) {
  56846. try {
  56847. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  56848. return cachedSetTimeout.call(null, fun, 0);
  56849. } catch (e) {
  56850. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  56851. return cachedSetTimeout.call(this, fun, 0);
  56852. }
  56853. }
  56854. }
  56855. function runClearTimeout(marker) {
  56856. if (cachedClearTimeout === clearTimeout) {
  56857. //normal enviroments in sane situations
  56858. return clearTimeout(marker);
  56859. } // if clearTimeout wasn't available but was latter defined
  56860. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  56861. cachedClearTimeout = clearTimeout;
  56862. return clearTimeout(marker);
  56863. }
  56864. try {
  56865. // when when somebody has screwed with setTimeout but no I.E. maddness
  56866. return cachedClearTimeout(marker);
  56867. } catch (e) {
  56868. try {
  56869. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  56870. return cachedClearTimeout.call(null, marker);
  56871. } catch (e) {
  56872. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  56873. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  56874. return cachedClearTimeout.call(this, marker);
  56875. }
  56876. }
  56877. }
  56878. var queue = [];
  56879. var draining = false;
  56880. var currentQueue;
  56881. var queueIndex = -1;
  56882. function cleanUpNextTick() {
  56883. if (!draining || !currentQueue) {
  56884. return;
  56885. }
  56886. draining = false;
  56887. if (currentQueue.length) {
  56888. queue = currentQueue.concat(queue);
  56889. } else {
  56890. queueIndex = -1;
  56891. }
  56892. if (queue.length) {
  56893. drainQueue();
  56894. }
  56895. }
  56896. function drainQueue() {
  56897. if (draining) {
  56898. return;
  56899. }
  56900. var timeout = runTimeout(cleanUpNextTick);
  56901. draining = true;
  56902. var len = queue.length;
  56903. while (len) {
  56904. currentQueue = queue;
  56905. queue = [];
  56906. while (++queueIndex < len) {
  56907. if (currentQueue) {
  56908. currentQueue[queueIndex].run();
  56909. }
  56910. }
  56911. queueIndex = -1;
  56912. len = queue.length;
  56913. }
  56914. currentQueue = null;
  56915. draining = false;
  56916. runClearTimeout(timeout);
  56917. }
  56918. process.nextTick = function (fun) {
  56919. var args = new Array(arguments.length - 1);
  56920. if (arguments.length > 1) {
  56921. for (var i = 1; i < arguments.length; i++) {
  56922. args[i - 1] = arguments[i];
  56923. }
  56924. }
  56925. queue.push(new Item(fun, args));
  56926. if (queue.length === 1 && !draining) {
  56927. runTimeout(drainQueue);
  56928. }
  56929. }; // v8 likes predictible objects
  56930. function Item(fun, array) {
  56931. this.fun = fun;
  56932. this.array = array;
  56933. }
  56934. Item.prototype.run = function () {
  56935. this.fun.apply(null, this.array);
  56936. };
  56937. process.title = 'browser';
  56938. process.browser = true;
  56939. process.env = {};
  56940. process.argv = [];
  56941. process.version = ''; // empty string to avoid regexp issues
  56942. process.versions = {};
  56943. function noop() { }
  56944. process.on = noop;
  56945. process.addListener = noop;
  56946. process.once = noop;
  56947. process.off = noop;
  56948. process.removeListener = noop;
  56949. process.removeAllListeners = noop;
  56950. process.emit = noop;
  56951. process.prependListener = noop;
  56952. process.prependOnceListener = noop;
  56953. process.listeners = function (name) {
  56954. return [];
  56955. };
  56956. process.binding = function (name) {
  56957. throw new Error('process.binding is not supported');
  56958. };
  56959. process.cwd = function () {
  56960. return '/';
  56961. };
  56962. process.chdir = function (dir) {
  56963. throw new Error('process.chdir is not supported');
  56964. };
  56965. process.umask = function () {
  56966. return 0;
  56967. };
  56968. }, {}], 468: [function (require, module, exports) {
  56969. "use strict";
  56970. exports.publicEncrypt = require('./publicEncrypt');
  56971. exports.privateDecrypt = require('./privateDecrypt');
  56972. exports.privateEncrypt = function privateEncrypt(key, buf) {
  56973. return exports.publicEncrypt(key, buf, true);
  56974. };
  56975. exports.publicDecrypt = function publicDecrypt(key, buf) {
  56976. return exports.privateDecrypt(key, buf, true);
  56977. };
  56978. }, { "./privateDecrypt": 471, "./publicEncrypt": 472 }], 469: [function (require, module, exports) {
  56979. "use strict";
  56980. var createHash = require('create-hash');
  56981. var Buffer = require('safe-buffer').Buffer;
  56982. module.exports = function (seed, len) {
  56983. var t = Buffer.alloc(0);
  56984. var i = 0;
  56985. var c;
  56986. while (t.length < len) {
  56987. c = i2ops(i++);
  56988. t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]);
  56989. }
  56990. return t.slice(0, len);
  56991. };
  56992. function i2ops(c) {
  56993. var out = Buffer.allocUnsafe(4);
  56994. out.writeUInt32BE(c, 0);
  56995. return out;
  56996. }
  56997. }, { "create-hash": 331, "safe-buffer": 494 }], 470: [function (require, module, exports) {
  56998. arguments[4][181][0].apply(exports, arguments)
  56999. }, { "buffer": 185, "dup": 181 }], 471: [function (require, module, exports) {
  57000. "use strict";
  57001. var parseKeys = require('parse-asn1');
  57002. var mgf = require('./mgf');
  57003. var xor = require('./xor');
  57004. var BN = require('bn.js');
  57005. var crt = require('browserify-rsa');
  57006. var createHash = require('create-hash');
  57007. var withPublic = require('./withPublic');
  57008. var Buffer = require('safe-buffer').Buffer;
  57009. module.exports = function privateDecrypt(privateKey, enc, reverse) {
  57010. var padding;
  57011. if (privateKey.padding) {
  57012. padding = privateKey.padding;
  57013. } else if (reverse) {
  57014. padding = 1;
  57015. } else {
  57016. padding = 4;
  57017. }
  57018. var key = parseKeys(privateKey);
  57019. var k = key.modulus.byteLength();
  57020. if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) {
  57021. throw new Error('decryption error');
  57022. }
  57023. var msg;
  57024. if (reverse) {
  57025. msg = withPublic(new BN(enc), key);
  57026. } else {
  57027. msg = crt(enc, key);
  57028. }
  57029. var zBuffer = Buffer.alloc(k - msg.length);
  57030. msg = Buffer.concat([zBuffer, msg], k);
  57031. if (padding === 4) {
  57032. return oaep(key, msg);
  57033. } else if (padding === 1) {
  57034. return pkcs1(key, msg, reverse);
  57035. } else if (padding === 3) {
  57036. return msg;
  57037. } else {
  57038. throw new Error('unknown padding');
  57039. }
  57040. };
  57041. function oaep(key, msg) {
  57042. var k = key.modulus.byteLength();
  57043. var iHash = createHash('sha1').update(Buffer.alloc(0)).digest();
  57044. var hLen = iHash.length;
  57045. if (msg[0] !== 0) {
  57046. throw new Error('decryption error');
  57047. }
  57048. var maskedSeed = msg.slice(1, hLen + 1);
  57049. var maskedDb = msg.slice(hLen + 1);
  57050. var seed = xor(maskedSeed, mgf(maskedDb, hLen));
  57051. var db = xor(maskedDb, mgf(seed, k - hLen - 1));
  57052. if (compare(iHash, db.slice(0, hLen))) {
  57053. throw new Error('decryption error');
  57054. }
  57055. var i = hLen;
  57056. while (db[i] === 0) {
  57057. i++;
  57058. }
  57059. if (db[i++] !== 1) {
  57060. throw new Error('decryption error');
  57061. }
  57062. return db.slice(i);
  57063. }
  57064. function pkcs1(key, msg, reverse) {
  57065. var p1 = msg.slice(0, 2);
  57066. var i = 2;
  57067. var status = 0;
  57068. while (msg[i++] !== 0) {
  57069. if (i >= msg.length) {
  57070. status++;
  57071. break;
  57072. }
  57073. }
  57074. var ps = msg.slice(2, i - 1);
  57075. if (p1.toString('hex') !== '0002' && !reverse || p1.toString('hex') !== '0001' && reverse) {
  57076. status++;
  57077. }
  57078. if (ps.length < 8) {
  57079. status++;
  57080. }
  57081. if (status) {
  57082. throw new Error('decryption error');
  57083. }
  57084. return msg.slice(i);
  57085. }
  57086. function compare(a, b) {
  57087. a = Buffer.from(a);
  57088. b = Buffer.from(b);
  57089. var dif = 0;
  57090. var len = a.length;
  57091. if (a.length !== b.length) {
  57092. dif++;
  57093. len = Math.min(a.length, b.length);
  57094. }
  57095. var i = -1;
  57096. while (++i < len) {
  57097. dif += a[i] ^ b[i];
  57098. }
  57099. return dif;
  57100. }
  57101. }, { "./mgf": 469, "./withPublic": 473, "./xor": 474, "bn.js": 470, "browserify-rsa": 206, "create-hash": 331, "parse-asn1": 459, "safe-buffer": 494 }], 472: [function (require, module, exports) {
  57102. "use strict";
  57103. var parseKeys = require('parse-asn1');
  57104. var randomBytes = require('randombytes');
  57105. var createHash = require('create-hash');
  57106. var mgf = require('./mgf');
  57107. var xor = require('./xor');
  57108. var BN = require('bn.js');
  57109. var withPublic = require('./withPublic');
  57110. var crt = require('browserify-rsa');
  57111. var Buffer = require('safe-buffer').Buffer;
  57112. module.exports = function publicEncrypt(publicKey, msg, reverse) {
  57113. var padding;
  57114. if (publicKey.padding) {
  57115. padding = publicKey.padding;
  57116. } else if (reverse) {
  57117. padding = 1;
  57118. } else {
  57119. padding = 4;
  57120. }
  57121. var key = parseKeys(publicKey);
  57122. var paddedMsg;
  57123. if (padding === 4) {
  57124. paddedMsg = oaep(key, msg);
  57125. } else if (padding === 1) {
  57126. paddedMsg = pkcs1(key, msg, reverse);
  57127. } else if (padding === 3) {
  57128. paddedMsg = new BN(msg);
  57129. if (paddedMsg.cmp(key.modulus) >= 0) {
  57130. throw new Error('data too long for modulus');
  57131. }
  57132. } else {
  57133. throw new Error('unknown padding');
  57134. }
  57135. if (reverse) {
  57136. return crt(paddedMsg, key);
  57137. } else {
  57138. return withPublic(paddedMsg, key);
  57139. }
  57140. };
  57141. function oaep(key, msg) {
  57142. var k = key.modulus.byteLength();
  57143. var mLen = msg.length;
  57144. var iHash = createHash('sha1').update(Buffer.alloc(0)).digest();
  57145. var hLen = iHash.length;
  57146. var hLen2 = 2 * hLen;
  57147. if (mLen > k - hLen2 - 2) {
  57148. throw new Error('message too long');
  57149. }
  57150. var ps = Buffer.alloc(k - mLen - hLen2 - 2);
  57151. var dblen = k - hLen - 1;
  57152. var seed = randomBytes(hLen);
  57153. var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen));
  57154. var maskedSeed = xor(seed, mgf(maskedDb, hLen));
  57155. return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k));
  57156. }
  57157. function pkcs1(key, msg, reverse) {
  57158. var mLen = msg.length;
  57159. var k = key.modulus.byteLength();
  57160. if (mLen > k - 11) {
  57161. throw new Error('message too long');
  57162. }
  57163. var ps;
  57164. if (reverse) {
  57165. ps = Buffer.alloc(k - mLen - 3, 0xff);
  57166. } else {
  57167. ps = nonZero(k - mLen - 3);
  57168. }
  57169. return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k));
  57170. }
  57171. function nonZero(len) {
  57172. var out = Buffer.allocUnsafe(len);
  57173. var i = 0;
  57174. var cache = randomBytes(len * 2);
  57175. var cur = 0;
  57176. var num;
  57177. while (i < len) {
  57178. if (cur === cache.length) {
  57179. cache = randomBytes(len * 2);
  57180. cur = 0;
  57181. }
  57182. num = cache[cur++];
  57183. if (num) {
  57184. out[i++] = num;
  57185. }
  57186. }
  57187. return out;
  57188. }
  57189. }, { "./mgf": 469, "./withPublic": 473, "./xor": 474, "bn.js": 470, "browserify-rsa": 206, "create-hash": 331, "parse-asn1": 459, "randombytes": 475, "safe-buffer": 494 }], 473: [function (require, module, exports) {
  57190. "use strict";
  57191. var BN = require('bn.js');
  57192. var Buffer = require('safe-buffer').Buffer;
  57193. function withPublic(paddedMsg, key) {
  57194. return Buffer.from(paddedMsg.toRed(BN.mont(key.modulus)).redPow(new BN(key.publicExponent)).fromRed().toArray());
  57195. }
  57196. module.exports = withPublic;
  57197. }, { "bn.js": 470, "safe-buffer": 494 }], 474: [function (require, module, exports) {
  57198. "use strict";
  57199. module.exports = function xor(a, b) {
  57200. var len = a.length;
  57201. var i = -1;
  57202. while (++i < len) {
  57203. a[i] ^= b[i];
  57204. }
  57205. return a;
  57206. };
  57207. }, {}], 475: [function (require, module, exports) {
  57208. (function (process, global) {
  57209. 'use strict'; // limit of Crypto.getRandomValues()
  57210. // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
  57211. var MAX_BYTES = 65536; // Node supports requesting up to this number of bytes
  57212. // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
  57213. var MAX_UINT32 = 4294967295;
  57214. function oldBrowser() {
  57215. throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11');
  57216. }
  57217. var Buffer = require('safe-buffer').Buffer;
  57218. var crypto = global.crypto || global.msCrypto;
  57219. if (crypto && crypto.getRandomValues) {
  57220. module.exports = randomBytes;
  57221. } else {
  57222. module.exports = oldBrowser;
  57223. }
  57224. function randomBytes(size, cb) {
  57225. // phantomjs needs to throw
  57226. if (size > MAX_UINT32) throw new RangeError('requested too many random bytes');
  57227. var bytes = Buffer.allocUnsafe(size);
  57228. if (size > 0) {
  57229. // getRandomValues fails on IE if size == 0
  57230. if (size > MAX_BYTES) {
  57231. // this is the max bytes crypto.getRandomValues
  57232. // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
  57233. for (var generated = 0; generated < size; generated += MAX_BYTES) {
  57234. // buffer.slice automatically checks if the end is past the end of
  57235. // the buffer so we don't have to here
  57236. crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
  57237. }
  57238. } else {
  57239. crypto.getRandomValues(bytes);
  57240. }
  57241. }
  57242. if (typeof cb === 'function') {
  57243. return process.nextTick(function () {
  57244. cb(null, bytes);
  57245. });
  57246. }
  57247. return bytes;
  57248. }
  57249. }).call(this, require('_process'), typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  57250. }, { "_process": 467, "safe-buffer": 494 }], 476: [function (require, module, exports) {
  57251. (function (process, global) {
  57252. 'use strict';
  57253. function oldBrowser() {
  57254. throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11');
  57255. }
  57256. var safeBuffer = require('safe-buffer');
  57257. var randombytes = require('randombytes');
  57258. var Buffer = safeBuffer.Buffer;
  57259. var kBufferMaxLength = safeBuffer.kMaxLength;
  57260. var crypto = global.crypto || global.msCrypto;
  57261. var kMaxUint32 = Math.pow(2, 32) - 1;
  57262. function assertOffset(offset, length) {
  57263. if (typeof offset !== 'number' || offset !== offset) {
  57264. // eslint-disable-line no-self-compare
  57265. throw new TypeError('offset must be a number');
  57266. }
  57267. if (offset > kMaxUint32 || offset < 0) {
  57268. throw new TypeError('offset must be a uint32');
  57269. }
  57270. if (offset > kBufferMaxLength || offset > length) {
  57271. throw new RangeError('offset out of range');
  57272. }
  57273. }
  57274. function assertSize(size, offset, length) {
  57275. if (typeof size !== 'number' || size !== size) {
  57276. // eslint-disable-line no-self-compare
  57277. throw new TypeError('size must be a number');
  57278. }
  57279. if (size > kMaxUint32 || size < 0) {
  57280. throw new TypeError('size must be a uint32');
  57281. }
  57282. if (size + offset > length || size > kBufferMaxLength) {
  57283. throw new RangeError('buffer too small');
  57284. }
  57285. }
  57286. if (crypto && crypto.getRandomValues || !process.browser) {
  57287. exports.randomFill = randomFill;
  57288. exports.randomFillSync = randomFillSync;
  57289. } else {
  57290. exports.randomFill = oldBrowser;
  57291. exports.randomFillSync = oldBrowser;
  57292. }
  57293. function randomFill(buf, offset, size, cb) {
  57294. if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
  57295. throw new TypeError('"buf" argument must be a Buffer or Uint8Array');
  57296. }
  57297. if (typeof offset === 'function') {
  57298. cb = offset;
  57299. offset = 0;
  57300. size = buf.length;
  57301. } else if (typeof size === 'function') {
  57302. cb = size;
  57303. size = buf.length - offset;
  57304. } else if (typeof cb !== 'function') {
  57305. throw new TypeError('"cb" argument must be a function');
  57306. }
  57307. assertOffset(offset, buf.length);
  57308. assertSize(size, offset, buf.length);
  57309. return actualFill(buf, offset, size, cb);
  57310. }
  57311. function actualFill(buf, offset, size, cb) {
  57312. if (process.browser) {
  57313. var ourBuf = buf.buffer;
  57314. var uint = new Uint8Array(ourBuf, offset, size);
  57315. crypto.getRandomValues(uint);
  57316. if (cb) {
  57317. process.nextTick(function () {
  57318. cb(null, buf);
  57319. });
  57320. return;
  57321. }
  57322. return buf;
  57323. }
  57324. if (cb) {
  57325. randombytes(size, function (err, bytes) {
  57326. if (err) {
  57327. return cb(err);
  57328. }
  57329. bytes.copy(buf, offset);
  57330. cb(null, buf);
  57331. });
  57332. return;
  57333. }
  57334. var bytes = randombytes(size);
  57335. bytes.copy(buf, offset);
  57336. return buf;
  57337. }
  57338. function randomFillSync(buf, offset, size) {
  57339. if (typeof offset === 'undefined') {
  57340. offset = 0;
  57341. }
  57342. if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
  57343. throw new TypeError('"buf" argument must be a Buffer or Uint8Array');
  57344. }
  57345. assertOffset(offset, buf.length);
  57346. if (size === undefined) size = buf.length - offset;
  57347. assertSize(size, offset, buf.length);
  57348. return actualFill(buf, offset, size);
  57349. }
  57350. }).call(this, require('_process'), typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  57351. }, { "_process": 467, "randombytes": 475, "safe-buffer": 494 }], 477: [function (require, module, exports) {
  57352. 'use strict';
  57353. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  57354. function _inheritsLoose(subClass, superClass) {
  57355. subClass.prototype = Object.create(superClass.prototype);
  57356. subClass.prototype.constructor = subClass;
  57357. subClass.__proto__ = superClass;
  57358. }
  57359. var codes = {};
  57360. function createErrorType(code, message, Base) {
  57361. if (!Base) {
  57362. Base = Error;
  57363. }
  57364. function getMessage(arg1, arg2, arg3) {
  57365. if (typeof message === 'string') {
  57366. return message;
  57367. } else {
  57368. return message(arg1, arg2, arg3);
  57369. }
  57370. }
  57371. var NodeError = /*#__PURE__*/function (_Base) {
  57372. _inheritsLoose(NodeError, _Base);
  57373. function NodeError(arg1, arg2, arg3) {
  57374. return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
  57375. }
  57376. return NodeError;
  57377. }(Base);
  57378. NodeError.prototype.name = Base.name;
  57379. NodeError.prototype.code = code;
  57380. codes[code] = NodeError;
  57381. } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
  57382. function oneOf(expected, thing) {
  57383. if (Array.isArray(expected)) {
  57384. var len = expected.length;
  57385. expected = expected.map(function (i) {
  57386. return String(i);
  57387. });
  57388. if (len > 2) {
  57389. return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
  57390. } else if (len === 2) {
  57391. return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
  57392. } else {
  57393. return "of ".concat(thing, " ").concat(expected[0]);
  57394. }
  57395. } else {
  57396. return "of ".concat(thing, " ").concat(String(expected));
  57397. }
  57398. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
  57399. function startsWith(str, search, pos) {
  57400. return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
  57401. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
  57402. function endsWith(str, search, this_len) {
  57403. if (this_len === undefined || this_len > str.length) {
  57404. this_len = str.length;
  57405. }
  57406. return str.substring(this_len - search.length, this_len) === search;
  57407. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
  57408. function includes(str, search, start) {
  57409. if (typeof start !== 'number') {
  57410. start = 0;
  57411. }
  57412. if (start + search.length > str.length) {
  57413. return false;
  57414. } else {
  57415. return str.indexOf(search, start) !== -1;
  57416. }
  57417. }
  57418. createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
  57419. return 'The value "' + value + '" is invalid for option "' + name + '"';
  57420. }, TypeError);
  57421. createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
  57422. // determiner: 'must be' or 'must not be'
  57423. var determiner;
  57424. if (typeof expected === 'string' && startsWith(expected, 'not ')) {
  57425. determiner = 'must not be';
  57426. expected = expected.replace(/^not /, '');
  57427. } else {
  57428. determiner = 'must be';
  57429. }
  57430. var msg;
  57431. if (endsWith(name, ' argument')) {
  57432. // For cases like 'first argument'
  57433. msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  57434. } else {
  57435. var type = includes(name, '.') ? 'property' : 'argument';
  57436. msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  57437. }
  57438. msg += ". Received type ".concat(_typeof(actual));
  57439. return msg;
  57440. }, TypeError);
  57441. createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
  57442. createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
  57443. return 'The ' + name + ' method is not implemented';
  57444. });
  57445. createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
  57446. createErrorType('ERR_STREAM_DESTROYED', function (name) {
  57447. return 'Cannot call ' + name + ' after a stream was destroyed';
  57448. });
  57449. createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
  57450. createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
  57451. createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
  57452. createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
  57453. createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
  57454. return 'Unknown encoding: ' + arg;
  57455. }, TypeError);
  57456. createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
  57457. module.exports.codes = codes;
  57458. }, {}], 478: [function (require, module, exports) {
  57459. (function (process) {
  57460. // Copyright Joyent, Inc. and other Node contributors.
  57461. //
  57462. // Permission is hereby granted, free of charge, to any person obtaining a
  57463. // copy of this software and associated documentation files (the
  57464. // "Software"), to deal in the Software without restriction, including
  57465. // without limitation the rights to use, copy, modify, merge, publish,
  57466. // distribute, sublicense, and/or sell copies of the Software, and to permit
  57467. // persons to whom the Software is furnished to do so, subject to the
  57468. // following conditions:
  57469. //
  57470. // The above copyright notice and this permission notice shall be included
  57471. // in all copies or substantial portions of the Software.
  57472. //
  57473. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  57474. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  57475. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  57476. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  57477. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  57478. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  57479. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  57480. // a duplex stream is just a stream that is both readable and writable.
  57481. // Since JS doesn't have multiple prototypal inheritance, this class
  57482. // prototypally inherits from Readable, and then parasitically from
  57483. // Writable.
  57484. 'use strict';
  57485. /*<replacement>*/
  57486. var objectKeys = Object.keys || function (obj) {
  57487. var keys = [];
  57488. for (var key in obj) {
  57489. keys.push(key);
  57490. }
  57491. return keys;
  57492. };
  57493. /*</replacement>*/
  57494. module.exports = Duplex;
  57495. var Readable = require('./_stream_readable');
  57496. var Writable = require('./_stream_writable');
  57497. require('inherits')(Duplex, Readable);
  57498. {
  57499. // Allow the keys array to be GC'ed.
  57500. var keys = objectKeys(Writable.prototype);
  57501. for (var v = 0; v < keys.length; v++) {
  57502. var method = keys[v];
  57503. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  57504. }
  57505. }
  57506. function Duplex(options) {
  57507. if (!(this instanceof Duplex)) return new Duplex(options);
  57508. Readable.call(this, options);
  57509. Writable.call(this, options);
  57510. this.allowHalfOpen = true;
  57511. if (options) {
  57512. if (options.readable === false) this.readable = false;
  57513. if (options.writable === false) this.writable = false;
  57514. if (options.allowHalfOpen === false) {
  57515. this.allowHalfOpen = false;
  57516. this.once('end', onend);
  57517. }
  57518. }
  57519. }
  57520. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  57521. // making it explicit this property is not enumerable
  57522. // because otherwise some prototype manipulation in
  57523. // userland will fail
  57524. enumerable: false,
  57525. get: function get() {
  57526. return this._writableState.highWaterMark;
  57527. }
  57528. });
  57529. Object.defineProperty(Duplex.prototype, 'writableBuffer', {
  57530. // making it explicit this property is not enumerable
  57531. // because otherwise some prototype manipulation in
  57532. // userland will fail
  57533. enumerable: false,
  57534. get: function get() {
  57535. return this._writableState && this._writableState.getBuffer();
  57536. }
  57537. });
  57538. Object.defineProperty(Duplex.prototype, 'writableLength', {
  57539. // making it explicit this property is not enumerable
  57540. // because otherwise some prototype manipulation in
  57541. // userland will fail
  57542. enumerable: false,
  57543. get: function get() {
  57544. return this._writableState.length;
  57545. }
  57546. }); // the no-half-open enforcer
  57547. function onend() {
  57548. // If the writable side ended, then we're ok.
  57549. if (this._writableState.ended) return; // no more data can be written.
  57550. // But allow more writes to happen in this tick.
  57551. process.nextTick(onEndNT, this);
  57552. }
  57553. function onEndNT(self) {
  57554. self.end();
  57555. }
  57556. Object.defineProperty(Duplex.prototype, 'destroyed', {
  57557. // making it explicit this property is not enumerable
  57558. // because otherwise some prototype manipulation in
  57559. // userland will fail
  57560. enumerable: false,
  57561. get: function get() {
  57562. if (this._readableState === undefined || this._writableState === undefined) {
  57563. return false;
  57564. }
  57565. return this._readableState.destroyed && this._writableState.destroyed;
  57566. },
  57567. set: function set(value) {
  57568. // we ignore the value if the stream
  57569. // has not been initialized yet
  57570. if (this._readableState === undefined || this._writableState === undefined) {
  57571. return;
  57572. } // backward compatibility, the user is explicitly
  57573. // managing destroyed
  57574. this._readableState.destroyed = value;
  57575. this._writableState.destroyed = value;
  57576. }
  57577. });
  57578. }).call(this, require('_process'))
  57579. }, { "./_stream_readable": 480, "./_stream_writable": 482, "_process": 467, "inherits": 387 }], 479: [function (require, module, exports) {
  57580. // Copyright Joyent, Inc. and other Node contributors.
  57581. //
  57582. // Permission is hereby granted, free of charge, to any person obtaining a
  57583. // copy of this software and associated documentation files (the
  57584. // "Software"), to deal in the Software without restriction, including
  57585. // without limitation the rights to use, copy, modify, merge, publish,
  57586. // distribute, sublicense, and/or sell copies of the Software, and to permit
  57587. // persons to whom the Software is furnished to do so, subject to the
  57588. // following conditions:
  57589. //
  57590. // The above copyright notice and this permission notice shall be included
  57591. // in all copies or substantial portions of the Software.
  57592. //
  57593. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  57594. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  57595. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  57596. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  57597. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  57598. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  57599. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  57600. // a passthrough stream.
  57601. // basically just the most minimal sort of Transform stream.
  57602. // Every written chunk gets output as-is.
  57603. 'use strict';
  57604. module.exports = PassThrough;
  57605. var Transform = require('./_stream_transform');
  57606. require('inherits')(PassThrough, Transform);
  57607. function PassThrough(options) {
  57608. if (!(this instanceof PassThrough)) return new PassThrough(options);
  57609. Transform.call(this, options);
  57610. }
  57611. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  57612. cb(null, chunk);
  57613. };
  57614. }, { "./_stream_transform": 481, "inherits": 387 }], 480: [function (require, module, exports) {
  57615. (function (process, global) {
  57616. // Copyright Joyent, Inc. and other Node contributors.
  57617. //
  57618. // Permission is hereby granted, free of charge, to any person obtaining a
  57619. // copy of this software and associated documentation files (the
  57620. // "Software"), to deal in the Software without restriction, including
  57621. // without limitation the rights to use, copy, modify, merge, publish,
  57622. // distribute, sublicense, and/or sell copies of the Software, and to permit
  57623. // persons to whom the Software is furnished to do so, subject to the
  57624. // following conditions:
  57625. //
  57626. // The above copyright notice and this permission notice shall be included
  57627. // in all copies or substantial portions of the Software.
  57628. //
  57629. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  57630. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  57631. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  57632. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  57633. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  57634. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  57635. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  57636. 'use strict';
  57637. module.exports = Readable;
  57638. /*<replacement>*/
  57639. var Duplex;
  57640. /*</replacement>*/
  57641. Readable.ReadableState = ReadableState;
  57642. /*<replacement>*/
  57643. var EE = require('events').EventEmitter;
  57644. var EElistenerCount = function EElistenerCount(emitter, type) {
  57645. return emitter.listeners(type).length;
  57646. };
  57647. /*</replacement>*/
  57648. /*<replacement>*/
  57649. var Stream = require('./internal/streams/stream');
  57650. /*</replacement>*/
  57651. var Buffer = require('buffer').Buffer;
  57652. var OurUint8Array = global.Uint8Array || function () { };
  57653. function _uint8ArrayToBuffer(chunk) {
  57654. return Buffer.from(chunk);
  57655. }
  57656. function _isUint8Array(obj) {
  57657. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  57658. }
  57659. /*<replacement>*/
  57660. var debugUtil = require('util');
  57661. var debug;
  57662. if (debugUtil && debugUtil.debuglog) {
  57663. debug = debugUtil.debuglog('stream');
  57664. } else {
  57665. debug = function debug() { };
  57666. }
  57667. /*</replacement>*/
  57668. var BufferList = require('./internal/streams/buffer_list');
  57669. var destroyImpl = require('./internal/streams/destroy');
  57670. var _require = require('./internal/streams/state'),
  57671. getHighWaterMark = _require.getHighWaterMark;
  57672. var _require$codes = require('../errors').codes,
  57673. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  57674. ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
  57675. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  57676. ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.
  57677. var StringDecoder;
  57678. var createReadableStreamAsyncIterator;
  57679. var from;
  57680. require('inherits')(Readable, Stream);
  57681. var errorOrDestroy = destroyImpl.errorOrDestroy;
  57682. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  57683. function prependListener(emitter, event, fn) {
  57684. // Sadly this is not cacheable as some libraries bundle their own
  57685. // event emitter implementation with them.
  57686. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any
  57687. // userland ones. NEVER DO THIS. This is here only because this code needs
  57688. // to continue to work with older versions of Node.js that do not include
  57689. // the prependListener() method. The goal is to eventually remove this hack.
  57690. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn); else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn); else emitter._events[event] = [fn, emitter._events[event]];
  57691. }
  57692. function ReadableState(options, stream, isDuplex) {
  57693. Duplex = Duplex || require('./_stream_duplex');
  57694. options = options || {}; // Duplex streams are both readable and writable, but share
  57695. // the same options object.
  57696. // However, some cases require setting options to different
  57697. // values for the readable and the writable sides of the duplex stream.
  57698. // These options can be provided separately as readableXXX and writableXXX.
  57699. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to
  57700. // make all the buffer merging and length checks go away
  57701. this.objectMode = !!options.objectMode;
  57702. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
  57703. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  57704. this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the
  57705. // linked list can remove elements from the beginning faster than
  57706. // array.shift()
  57707. this.buffer = new BufferList();
  57708. this.length = 0;
  57709. this.pipes = null;
  57710. this.pipesCount = 0;
  57711. this.flowing = null;
  57712. this.ended = false;
  57713. this.endEmitted = false;
  57714. this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted
  57715. // immediately, or on a later tick. We set this to true at first, because
  57716. // any actions that shouldn't happen until "later" should generally also
  57717. // not happen before the first read call.
  57718. this.sync = true; // whenever we return null, then we set a flag to say
  57719. // that we're awaiting a 'readable' event emission.
  57720. this.needReadable = false;
  57721. this.emittedReadable = false;
  57722. this.readableListening = false;
  57723. this.resumeScheduled = false;
  57724. this.paused = true; // Should close be emitted on destroy. Defaults to true.
  57725. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')
  57726. this.autoDestroy = !!options.autoDestroy; // has it been destroyed
  57727. this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string
  57728. // encoding is 'binary' so we have to make this configurable.
  57729. // Everything else in the universe uses 'utf8', though.
  57730. this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s
  57731. this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
  57732. this.readingMore = false;
  57733. this.decoder = null;
  57734. this.encoding = null;
  57735. if (options.encoding) {
  57736. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  57737. this.decoder = new StringDecoder(options.encoding);
  57738. this.encoding = options.encoding;
  57739. }
  57740. }
  57741. function Readable(options) {
  57742. Duplex = Duplex || require('./_stream_duplex');
  57743. if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside
  57744. // the ReadableState constructor, at least with V8 6.5
  57745. var isDuplex = this instanceof Duplex;
  57746. this._readableState = new ReadableState(options, this, isDuplex); // legacy
  57747. this.readable = true;
  57748. if (options) {
  57749. if (typeof options.read === 'function') this._read = options.read;
  57750. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  57751. }
  57752. Stream.call(this);
  57753. }
  57754. Object.defineProperty(Readable.prototype, 'destroyed', {
  57755. // making it explicit this property is not enumerable
  57756. // because otherwise some prototype manipulation in
  57757. // userland will fail
  57758. enumerable: false,
  57759. get: function get() {
  57760. if (this._readableState === undefined) {
  57761. return false;
  57762. }
  57763. return this._readableState.destroyed;
  57764. },
  57765. set: function set(value) {
  57766. // we ignore the value if the stream
  57767. // has not been initialized yet
  57768. if (!this._readableState) {
  57769. return;
  57770. } // backward compatibility, the user is explicitly
  57771. // managing destroyed
  57772. this._readableState.destroyed = value;
  57773. }
  57774. });
  57775. Readable.prototype.destroy = destroyImpl.destroy;
  57776. Readable.prototype._undestroy = destroyImpl.undestroy;
  57777. Readable.prototype._destroy = function (err, cb) {
  57778. cb(err);
  57779. }; // Manually shove something into the read() buffer.
  57780. // This returns true if the highWaterMark has not been hit yet,
  57781. // similar to how Writable.write() returns true if you should
  57782. // write() some more.
  57783. Readable.prototype.push = function (chunk, encoding) {
  57784. var state = this._readableState;
  57785. var skipChunkCheck;
  57786. if (!state.objectMode) {
  57787. if (typeof chunk === 'string') {
  57788. encoding = encoding || state.defaultEncoding;
  57789. if (encoding !== state.encoding) {
  57790. chunk = Buffer.from(chunk, encoding);
  57791. encoding = '';
  57792. }
  57793. skipChunkCheck = true;
  57794. }
  57795. } else {
  57796. skipChunkCheck = true;
  57797. }
  57798. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  57799. }; // Unshift should *always* be something directly out of read()
  57800. Readable.prototype.unshift = function (chunk) {
  57801. return readableAddChunk(this, chunk, null, true, false);
  57802. };
  57803. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  57804. debug('readableAddChunk', chunk);
  57805. var state = stream._readableState;
  57806. if (chunk === null) {
  57807. state.reading = false;
  57808. onEofChunk(stream, state);
  57809. } else {
  57810. var er;
  57811. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  57812. if (er) {
  57813. errorOrDestroy(stream, er);
  57814. } else if (state.objectMode || chunk && chunk.length > 0) {
  57815. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  57816. chunk = _uint8ArrayToBuffer(chunk);
  57817. }
  57818. if (addToFront) {
  57819. if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT()); else addChunk(stream, state, chunk, true);
  57820. } else if (state.ended) {
  57821. errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
  57822. } else if (state.destroyed) {
  57823. return false;
  57824. } else {
  57825. state.reading = false;
  57826. if (state.decoder && !encoding) {
  57827. chunk = state.decoder.write(chunk);
  57828. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false); else maybeReadMore(stream, state);
  57829. } else {
  57830. addChunk(stream, state, chunk, false);
  57831. }
  57832. }
  57833. } else if (!addToFront) {
  57834. state.reading = false;
  57835. maybeReadMore(stream, state);
  57836. }
  57837. } // We can push more data if we are below the highWaterMark.
  57838. // Also, if we have no data yet, we can stand some more bytes.
  57839. // This is to work around cases where hwm=0, such as the repl.
  57840. return !state.ended && (state.length < state.highWaterMark || state.length === 0);
  57841. }
  57842. function addChunk(stream, state, chunk, addToFront) {
  57843. if (state.flowing && state.length === 0 && !state.sync) {
  57844. state.awaitDrain = 0;
  57845. stream.emit('data', chunk);
  57846. } else {
  57847. // update the buffer info.
  57848. state.length += state.objectMode ? 1 : chunk.length;
  57849. if (addToFront) state.buffer.unshift(chunk); else state.buffer.push(chunk);
  57850. if (state.needReadable) emitReadable(stream);
  57851. }
  57852. maybeReadMore(stream, state);
  57853. }
  57854. function chunkInvalid(state, chunk) {
  57855. var er;
  57856. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  57857. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
  57858. }
  57859. return er;
  57860. }
  57861. Readable.prototype.isPaused = function () {
  57862. return this._readableState.flowing === false;
  57863. }; // backwards compatibility.
  57864. Readable.prototype.setEncoding = function (enc) {
  57865. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  57866. var decoder = new StringDecoder(enc);
  57867. this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8
  57868. this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:
  57869. var p = this._readableState.buffer.head;
  57870. var content = '';
  57871. while (p !== null) {
  57872. content += decoder.write(p.data);
  57873. p = p.next;
  57874. }
  57875. this._readableState.buffer.clear();
  57876. if (content !== '') this._readableState.buffer.push(content);
  57877. this._readableState.length = content.length;
  57878. return this;
  57879. }; // Don't raise the hwm > 1GB
  57880. var MAX_HWM = 0x40000000;
  57881. function computeNewHighWaterMark(n) {
  57882. if (n >= MAX_HWM) {
  57883. // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
  57884. n = MAX_HWM;
  57885. } else {
  57886. // Get the next highest power of 2 to prevent increasing hwm excessively in
  57887. // tiny amounts
  57888. n--;
  57889. n |= n >>> 1;
  57890. n |= n >>> 2;
  57891. n |= n >>> 4;
  57892. n |= n >>> 8;
  57893. n |= n >>> 16;
  57894. n++;
  57895. }
  57896. return n;
  57897. } // This function is designed to be inlinable, so please take care when making
  57898. // changes to the function body.
  57899. function howMuchToRead(n, state) {
  57900. if (n <= 0 || state.length === 0 && state.ended) return 0;
  57901. if (state.objectMode) return 1;
  57902. if (n !== n) {
  57903. // Only flow one buffer at a time
  57904. if (state.flowing && state.length) return state.buffer.head.data.length; else return state.length;
  57905. } // If we're asking for more than the current hwm, then raise the hwm.
  57906. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  57907. if (n <= state.length) return n; // Don't have enough
  57908. if (!state.ended) {
  57909. state.needReadable = true;
  57910. return 0;
  57911. }
  57912. return state.length;
  57913. } // you can override either this method, or the async _read(n) below.
  57914. Readable.prototype.read = function (n) {
  57915. debug('read', n);
  57916. n = parseInt(n, 10);
  57917. var state = this._readableState;
  57918. var nOrig = n;
  57919. if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we
  57920. // already have a bunch of data in the buffer, then just trigger
  57921. // the 'readable' event and move on.
  57922. if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
  57923. debug('read: emitReadable', state.length, state.ended);
  57924. if (state.length === 0 && state.ended) endReadable(this); else emitReadable(this);
  57925. return null;
  57926. }
  57927. n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.
  57928. if (n === 0 && state.ended) {
  57929. if (state.length === 0) endReadable(this);
  57930. return null;
  57931. } // All the actual chunk generation logic needs to be
  57932. // *below* the call to _read. The reason is that in certain
  57933. // synthetic stream cases, such as passthrough streams, _read
  57934. // may be a completely synchronous operation which may change
  57935. // the state of the read buffer, providing enough data when
  57936. // before there was *not* enough.
  57937. //
  57938. // So, the steps are:
  57939. // 1. Figure out what the state of things will be after we do
  57940. // a read from the buffer.
  57941. //
  57942. // 2. If that resulting state will trigger a _read, then call _read.
  57943. // Note that this may be asynchronous, or synchronous. Yes, it is
  57944. // deeply ugly to write APIs this way, but that still doesn't mean
  57945. // that the Readable class should behave improperly, as streams are
  57946. // designed to be sync/async agnostic.
  57947. // Take note if the _read call is sync or async (ie, if the read call
  57948. // has returned yet), so that we know whether or not it's safe to emit
  57949. // 'readable' etc.
  57950. //
  57951. // 3. Actually pull the requested chunks out of the buffer and return.
  57952. // if we need a readable event, then we need to do some reading.
  57953. var doRead = state.needReadable;
  57954. debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some
  57955. if (state.length === 0 || state.length - n < state.highWaterMark) {
  57956. doRead = true;
  57957. debug('length less than watermark', doRead);
  57958. } // however, if we've ended, then there's no point, and if we're already
  57959. // reading, then it's unnecessary.
  57960. if (state.ended || state.reading) {
  57961. doRead = false;
  57962. debug('reading or ended', doRead);
  57963. } else if (doRead) {
  57964. debug('do read');
  57965. state.reading = true;
  57966. state.sync = true; // if the length is currently zero, then we *need* a readable event.
  57967. if (state.length === 0) state.needReadable = true; // call internal read method
  57968. this._read(state.highWaterMark);
  57969. state.sync = false; // If _read pushed data synchronously, then `reading` will be false,
  57970. // and we need to re-evaluate how much data we can return to the user.
  57971. if (!state.reading) n = howMuchToRead(nOrig, state);
  57972. }
  57973. var ret;
  57974. if (n > 0) ret = fromList(n, state); else ret = null;
  57975. if (ret === null) {
  57976. state.needReadable = state.length <= state.highWaterMark;
  57977. n = 0;
  57978. } else {
  57979. state.length -= n;
  57980. state.awaitDrain = 0;
  57981. }
  57982. if (state.length === 0) {
  57983. // If we have nothing in the buffer, then we want to know
  57984. // as soon as we *do* get something into the buffer.
  57985. if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.
  57986. if (nOrig !== n && state.ended) endReadable(this);
  57987. }
  57988. if (ret !== null) this.emit('data', ret);
  57989. return ret;
  57990. };
  57991. function onEofChunk(stream, state) {
  57992. debug('onEofChunk');
  57993. if (state.ended) return;
  57994. if (state.decoder) {
  57995. var chunk = state.decoder.end();
  57996. if (chunk && chunk.length) {
  57997. state.buffer.push(chunk);
  57998. state.length += state.objectMode ? 1 : chunk.length;
  57999. }
  58000. }
  58001. state.ended = true;
  58002. if (state.sync) {
  58003. // if we are sync, wait until next tick to emit the data.
  58004. // Otherwise we risk emitting data in the flow()
  58005. // the readable code triggers during a read() call
  58006. emitReadable(stream);
  58007. } else {
  58008. // emit 'readable' now to make sure it gets picked up.
  58009. state.needReadable = false;
  58010. if (!state.emittedReadable) {
  58011. state.emittedReadable = true;
  58012. emitReadable_(stream);
  58013. }
  58014. }
  58015. } // Don't emit readable right away in sync mode, because this can trigger
  58016. // another read() call => stack overflow. This way, it might trigger
  58017. // a nextTick recursion warning, but that's not so bad.
  58018. function emitReadable(stream) {
  58019. var state = stream._readableState;
  58020. debug('emitReadable', state.needReadable, state.emittedReadable);
  58021. state.needReadable = false;
  58022. if (!state.emittedReadable) {
  58023. debug('emitReadable', state.flowing);
  58024. state.emittedReadable = true;
  58025. process.nextTick(emitReadable_, stream);
  58026. }
  58027. }
  58028. function emitReadable_(stream) {
  58029. var state = stream._readableState;
  58030. debug('emitReadable_', state.destroyed, state.length, state.ended);
  58031. if (!state.destroyed && (state.length || state.ended)) {
  58032. stream.emit('readable');
  58033. state.emittedReadable = false;
  58034. } // The stream needs another readable event if
  58035. // 1. It is not flowing, as the flow mechanism will take
  58036. // care of it.
  58037. // 2. It is not ended.
  58038. // 3. It is below the highWaterMark, so we can schedule
  58039. // another readable later.
  58040. state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
  58041. flow(stream);
  58042. } // at this point, the user has presumably seen the 'readable' event,
  58043. // and called read() to consume some data. that may have triggered
  58044. // in turn another _read(n) call, in which case reading = true if
  58045. // it's in progress.
  58046. // However, if we're not ended, or reading, and the length < hwm,
  58047. // then go ahead and try to read some more preemptively.
  58048. function maybeReadMore(stream, state) {
  58049. if (!state.readingMore) {
  58050. state.readingMore = true;
  58051. process.nextTick(maybeReadMore_, stream, state);
  58052. }
  58053. }
  58054. function maybeReadMore_(stream, state) {
  58055. // Attempt to read more data if we should.
  58056. //
  58057. // The conditions for reading more data are (one of):
  58058. // - Not enough data buffered (state.length < state.highWaterMark). The loop
  58059. // is responsible for filling the buffer with enough data if such data
  58060. // is available. If highWaterMark is 0 and we are not in the flowing mode
  58061. // we should _not_ attempt to buffer any extra data. We'll get more data
  58062. // when the stream consumer calls read() instead.
  58063. // - No data in the buffer, and the stream is in flowing mode. In this mode
  58064. // the loop below is responsible for ensuring read() is called. Failing to
  58065. // call read here would abort the flow and there's no other mechanism for
  58066. // continuing the flow if the stream consumer has just subscribed to the
  58067. // 'data' event.
  58068. //
  58069. // In addition to the above conditions to keep reading data, the following
  58070. // conditions prevent the data from being read:
  58071. // - The stream has ended (state.ended).
  58072. // - There is already a pending 'read' operation (state.reading). This is a
  58073. // case where the the stream has called the implementation defined _read()
  58074. // method, but they are processing the call asynchronously and have _not_
  58075. // called push() with new data. In this case we skip performing more
  58076. // read()s. The execution ends in this method again after the _read() ends
  58077. // up calling push() with more data.
  58078. while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
  58079. var len = state.length;
  58080. debug('maybeReadMore read 0');
  58081. stream.read(0);
  58082. if (len === state.length) // didn't get any data, stop spinning.
  58083. break;
  58084. }
  58085. state.readingMore = false;
  58086. } // abstract method. to be overridden in specific implementation classes.
  58087. // call cb(er, data) where data is <= n in length.
  58088. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  58089. // arbitrary, and perhaps not very meaningful.
  58090. Readable.prototype._read = function (n) {
  58091. errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
  58092. };
  58093. Readable.prototype.pipe = function (dest, pipeOpts) {
  58094. var src = this;
  58095. var state = this._readableState;
  58096. switch (state.pipesCount) {
  58097. case 0:
  58098. state.pipes = dest;
  58099. break;
  58100. case 1:
  58101. state.pipes = [state.pipes, dest];
  58102. break;
  58103. default:
  58104. state.pipes.push(dest);
  58105. break;
  58106. }
  58107. state.pipesCount += 1;
  58108. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  58109. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  58110. var endFn = doEnd ? onend : unpipe;
  58111. if (state.endEmitted) process.nextTick(endFn); else src.once('end', endFn);
  58112. dest.on('unpipe', onunpipe);
  58113. function onunpipe(readable, unpipeInfo) {
  58114. debug('onunpipe');
  58115. if (readable === src) {
  58116. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  58117. unpipeInfo.hasUnpiped = true;
  58118. cleanup();
  58119. }
  58120. }
  58121. }
  58122. function onend() {
  58123. debug('onend');
  58124. dest.end();
  58125. } // when the dest drains, it reduces the awaitDrain counter
  58126. // on the source. This would be more elegant with a .once()
  58127. // handler in flow(), but adding and removing repeatedly is
  58128. // too slow.
  58129. var ondrain = pipeOnDrain(src);
  58130. dest.on('drain', ondrain);
  58131. var cleanedUp = false;
  58132. function cleanup() {
  58133. debug('cleanup'); // cleanup event handlers once the pipe is broken
  58134. dest.removeListener('close', onclose);
  58135. dest.removeListener('finish', onfinish);
  58136. dest.removeListener('drain', ondrain);
  58137. dest.removeListener('error', onerror);
  58138. dest.removeListener('unpipe', onunpipe);
  58139. src.removeListener('end', onend);
  58140. src.removeListener('end', unpipe);
  58141. src.removeListener('data', ondata);
  58142. cleanedUp = true; // if the reader is waiting for a drain event from this
  58143. // specific writer, then it would cause it to never start
  58144. // flowing again.
  58145. // So, if this is awaiting a drain, then we just call it now.
  58146. // If we don't know, then assume that we are waiting for one.
  58147. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  58148. }
  58149. src.on('data', ondata);
  58150. function ondata(chunk) {
  58151. debug('ondata');
  58152. var ret = dest.write(chunk);
  58153. debug('dest.write', ret);
  58154. if (ret === false) {
  58155. // If the user unpiped during `dest.write()`, it is possible
  58156. // to get stuck in a permanently paused state if that write
  58157. // also returned false.
  58158. // => Check whether `dest` is still a piping destination.
  58159. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  58160. debug('false write response, pause', state.awaitDrain);
  58161. state.awaitDrain++;
  58162. }
  58163. src.pause();
  58164. }
  58165. } // if the dest has an error, then stop piping into it.
  58166. // however, don't suppress the throwing behavior for this.
  58167. function onerror(er) {
  58168. debug('onerror', er);
  58169. unpipe();
  58170. dest.removeListener('error', onerror);
  58171. if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
  58172. } // Make sure our error handler is attached before userland ones.
  58173. prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.
  58174. function onclose() {
  58175. dest.removeListener('finish', onfinish);
  58176. unpipe();
  58177. }
  58178. dest.once('close', onclose);
  58179. function onfinish() {
  58180. debug('onfinish');
  58181. dest.removeListener('close', onclose);
  58182. unpipe();
  58183. }
  58184. dest.once('finish', onfinish);
  58185. function unpipe() {
  58186. debug('unpipe');
  58187. src.unpipe(dest);
  58188. } // tell the dest that it's being piped to
  58189. dest.emit('pipe', src); // start the flow if it hasn't been started already.
  58190. if (!state.flowing) {
  58191. debug('pipe resume');
  58192. src.resume();
  58193. }
  58194. return dest;
  58195. };
  58196. function pipeOnDrain(src) {
  58197. return function pipeOnDrainFunctionResult() {
  58198. var state = src._readableState;
  58199. debug('pipeOnDrain', state.awaitDrain);
  58200. if (state.awaitDrain) state.awaitDrain--;
  58201. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  58202. state.flowing = true;
  58203. flow(src);
  58204. }
  58205. };
  58206. }
  58207. Readable.prototype.unpipe = function (dest) {
  58208. var state = this._readableState;
  58209. var unpipeInfo = {
  58210. hasUnpiped: false
  58211. }; // if we're not piping anywhere, then do nothing.
  58212. if (state.pipesCount === 0) return this; // just one destination. most common case.
  58213. if (state.pipesCount === 1) {
  58214. // passed in one, but it's not the right one.
  58215. if (dest && dest !== state.pipes) return this;
  58216. if (!dest) dest = state.pipes; // got a match.
  58217. state.pipes = null;
  58218. state.pipesCount = 0;
  58219. state.flowing = false;
  58220. if (dest) dest.emit('unpipe', this, unpipeInfo);
  58221. return this;
  58222. } // slow case. multiple pipe destinations.
  58223. if (!dest) {
  58224. // remove all.
  58225. var dests = state.pipes;
  58226. var len = state.pipesCount;
  58227. state.pipes = null;
  58228. state.pipesCount = 0;
  58229. state.flowing = false;
  58230. for (var i = 0; i < len; i++) {
  58231. dests[i].emit('unpipe', this, {
  58232. hasUnpiped: false
  58233. });
  58234. }
  58235. return this;
  58236. } // try to find the right one.
  58237. var index = indexOf(state.pipes, dest);
  58238. if (index === -1) return this;
  58239. state.pipes.splice(index, 1);
  58240. state.pipesCount -= 1;
  58241. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  58242. dest.emit('unpipe', this, unpipeInfo);
  58243. return this;
  58244. }; // set up data events if they are asked for
  58245. // Ensure readable listeners eventually get something
  58246. Readable.prototype.on = function (ev, fn) {
  58247. var res = Stream.prototype.on.call(this, ev, fn);
  58248. var state = this._readableState;
  58249. if (ev === 'data') {
  58250. // update readableListening so that resume() may be a no-op
  58251. // a few lines down. This is needed to support once('readable').
  58252. state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused
  58253. if (state.flowing !== false) this.resume();
  58254. } else if (ev === 'readable') {
  58255. if (!state.endEmitted && !state.readableListening) {
  58256. state.readableListening = state.needReadable = true;
  58257. state.flowing = false;
  58258. state.emittedReadable = false;
  58259. debug('on readable', state.length, state.reading);
  58260. if (state.length) {
  58261. emitReadable(this);
  58262. } else if (!state.reading) {
  58263. process.nextTick(nReadingNextTick, this);
  58264. }
  58265. }
  58266. }
  58267. return res;
  58268. };
  58269. Readable.prototype.addListener = Readable.prototype.on;
  58270. Readable.prototype.removeListener = function (ev, fn) {
  58271. var res = Stream.prototype.removeListener.call(this, ev, fn);
  58272. if (ev === 'readable') {
  58273. // We need to check if there is someone still listening to
  58274. // readable and reset the state. However this needs to happen
  58275. // after readable has been emitted but before I/O (nextTick) to
  58276. // support once('readable', fn) cycles. This means that calling
  58277. // resume within the same tick will have no
  58278. // effect.
  58279. process.nextTick(updateReadableListening, this);
  58280. }
  58281. return res;
  58282. };
  58283. Readable.prototype.removeAllListeners = function (ev) {
  58284. var res = Stream.prototype.removeAllListeners.apply(this, arguments);
  58285. if (ev === 'readable' || ev === undefined) {
  58286. // We need to check if there is someone still listening to
  58287. // readable and reset the state. However this needs to happen
  58288. // after readable has been emitted but before I/O (nextTick) to
  58289. // support once('readable', fn) cycles. This means that calling
  58290. // resume within the same tick will have no
  58291. // effect.
  58292. process.nextTick(updateReadableListening, this);
  58293. }
  58294. return res;
  58295. };
  58296. function updateReadableListening(self) {
  58297. var state = self._readableState;
  58298. state.readableListening = self.listenerCount('readable') > 0;
  58299. if (state.resumeScheduled && !state.paused) {
  58300. // flowing needs to be set to true now, otherwise
  58301. // the upcoming resume will not flow.
  58302. state.flowing = true; // crude way to check if we should resume
  58303. } else if (self.listenerCount('data') > 0) {
  58304. self.resume();
  58305. }
  58306. }
  58307. function nReadingNextTick(self) {
  58308. debug('readable nexttick read 0');
  58309. self.read(0);
  58310. } // pause() and resume() are remnants of the legacy readable stream API
  58311. // If the user uses them, then switch into old mode.
  58312. Readable.prototype.resume = function () {
  58313. var state = this._readableState;
  58314. if (!state.flowing) {
  58315. debug('resume'); // we flow only if there is no one listening
  58316. // for readable, but we still have to call
  58317. // resume()
  58318. state.flowing = !state.readableListening;
  58319. resume(this, state);
  58320. }
  58321. state.paused = false;
  58322. return this;
  58323. };
  58324. function resume(stream, state) {
  58325. if (!state.resumeScheduled) {
  58326. state.resumeScheduled = true;
  58327. process.nextTick(resume_, stream, state);
  58328. }
  58329. }
  58330. function resume_(stream, state) {
  58331. debug('resume', state.reading);
  58332. if (!state.reading) {
  58333. stream.read(0);
  58334. }
  58335. state.resumeScheduled = false;
  58336. stream.emit('resume');
  58337. flow(stream);
  58338. if (state.flowing && !state.reading) stream.read(0);
  58339. }
  58340. Readable.prototype.pause = function () {
  58341. debug('call pause flowing=%j', this._readableState.flowing);
  58342. if (this._readableState.flowing !== false) {
  58343. debug('pause');
  58344. this._readableState.flowing = false;
  58345. this.emit('pause');
  58346. }
  58347. this._readableState.paused = true;
  58348. return this;
  58349. };
  58350. function flow(stream) {
  58351. var state = stream._readableState;
  58352. debug('flow', state.flowing);
  58353. while (state.flowing && stream.read() !== null) {
  58354. ;
  58355. }
  58356. } // wrap an old-style stream as the async data source.
  58357. // This is *not* part of the readable stream interface.
  58358. // It is an ugly unfortunate mess of history.
  58359. Readable.prototype.wrap = function (stream) {
  58360. var _this = this;
  58361. var state = this._readableState;
  58362. var paused = false;
  58363. stream.on('end', function () {
  58364. debug('wrapped end');
  58365. if (state.decoder && !state.ended) {
  58366. var chunk = state.decoder.end();
  58367. if (chunk && chunk.length) _this.push(chunk);
  58368. }
  58369. _this.push(null);
  58370. });
  58371. stream.on('data', function (chunk) {
  58372. debug('wrapped data');
  58373. if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode
  58374. if (state.objectMode && (chunk === null || chunk === undefined)) return; else if (!state.objectMode && (!chunk || !chunk.length)) return;
  58375. var ret = _this.push(chunk);
  58376. if (!ret) {
  58377. paused = true;
  58378. stream.pause();
  58379. }
  58380. }); // proxy all the other methods.
  58381. // important when wrapping filters and duplexes.
  58382. for (var i in stream) {
  58383. if (this[i] === undefined && typeof stream[i] === 'function') {
  58384. this[i] = function methodWrap(method) {
  58385. return function methodWrapReturnFunction() {
  58386. return stream[method].apply(stream, arguments);
  58387. };
  58388. }(i);
  58389. }
  58390. } // proxy certain important events.
  58391. for (var n = 0; n < kProxyEvents.length; n++) {
  58392. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  58393. } // when we try to consume some more bytes, simply unpause the
  58394. // underlying stream.
  58395. this._read = function (n) {
  58396. debug('wrapped _read', n);
  58397. if (paused) {
  58398. paused = false;
  58399. stream.resume();
  58400. }
  58401. };
  58402. return this;
  58403. };
  58404. if (typeof Symbol === 'function') {
  58405. Readable.prototype[Symbol.asyncIterator] = function () {
  58406. if (createReadableStreamAsyncIterator === undefined) {
  58407. createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');
  58408. }
  58409. return createReadableStreamAsyncIterator(this);
  58410. };
  58411. }
  58412. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  58413. // making it explicit this property is not enumerable
  58414. // because otherwise some prototype manipulation in
  58415. // userland will fail
  58416. enumerable: false,
  58417. get: function get() {
  58418. return this._readableState.highWaterMark;
  58419. }
  58420. });
  58421. Object.defineProperty(Readable.prototype, 'readableBuffer', {
  58422. // making it explicit this property is not enumerable
  58423. // because otherwise some prototype manipulation in
  58424. // userland will fail
  58425. enumerable: false,
  58426. get: function get() {
  58427. return this._readableState && this._readableState.buffer;
  58428. }
  58429. });
  58430. Object.defineProperty(Readable.prototype, 'readableFlowing', {
  58431. // making it explicit this property is not enumerable
  58432. // because otherwise some prototype manipulation in
  58433. // userland will fail
  58434. enumerable: false,
  58435. get: function get() {
  58436. return this._readableState.flowing;
  58437. },
  58438. set: function set(state) {
  58439. if (this._readableState) {
  58440. this._readableState.flowing = state;
  58441. }
  58442. }
  58443. }); // exposed for testing purposes only.
  58444. Readable._fromList = fromList;
  58445. Object.defineProperty(Readable.prototype, 'readableLength', {
  58446. // making it explicit this property is not enumerable
  58447. // because otherwise some prototype manipulation in
  58448. // userland will fail
  58449. enumerable: false,
  58450. get: function get() {
  58451. return this._readableState.length;
  58452. }
  58453. }); // Pluck off n bytes from an array of buffers.
  58454. // Length is the combined lengths of all the buffers in the list.
  58455. // This function is designed to be inlinable, so please take care when making
  58456. // changes to the function body.
  58457. function fromList(n, state) {
  58458. // nothing buffered
  58459. if (state.length === 0) return null;
  58460. var ret;
  58461. if (state.objectMode) ret = state.buffer.shift(); else if (!n || n >= state.length) {
  58462. // read it all, truncate the list
  58463. if (state.decoder) ret = state.buffer.join(''); else if (state.buffer.length === 1) ret = state.buffer.first(); else ret = state.buffer.concat(state.length);
  58464. state.buffer.clear();
  58465. } else {
  58466. // read part of list
  58467. ret = state.buffer.consume(n, state.decoder);
  58468. }
  58469. return ret;
  58470. }
  58471. function endReadable(stream) {
  58472. var state = stream._readableState;
  58473. debug('endReadable', state.endEmitted);
  58474. if (!state.endEmitted) {
  58475. state.ended = true;
  58476. process.nextTick(endReadableNT, state, stream);
  58477. }
  58478. }
  58479. function endReadableNT(state, stream) {
  58480. debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.
  58481. if (!state.endEmitted && state.length === 0) {
  58482. state.endEmitted = true;
  58483. stream.readable = false;
  58484. stream.emit('end');
  58485. if (state.autoDestroy) {
  58486. // In case of duplex streams we need a way to detect
  58487. // if the writable side is ready for autoDestroy as well
  58488. var wState = stream._writableState;
  58489. if (!wState || wState.autoDestroy && wState.finished) {
  58490. stream.destroy();
  58491. }
  58492. }
  58493. }
  58494. }
  58495. if (typeof Symbol === 'function') {
  58496. Readable.from = function (iterable, opts) {
  58497. if (from === undefined) {
  58498. from = require('./internal/streams/from');
  58499. }
  58500. return from(Readable, iterable, opts);
  58501. };
  58502. }
  58503. function indexOf(xs, x) {
  58504. for (var i = 0, l = xs.length; i < l; i++) {
  58505. if (xs[i] === x) return i;
  58506. }
  58507. return -1;
  58508. }
  58509. }).call(this, require('_process'), typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  58510. }, { "../errors": 477, "./_stream_duplex": 478, "./internal/streams/async_iterator": 483, "./internal/streams/buffer_list": 484, "./internal/streams/destroy": 485, "./internal/streams/from": 487, "./internal/streams/state": 489, "./internal/streams/stream": 490, "_process": 467, "buffer": 216, "events": 367, "inherits": 387, "string_decoder/": 520, "util": 185 }], 481: [function (require, module, exports) {
  58511. // Copyright Joyent, Inc. and other Node contributors.
  58512. //
  58513. // Permission is hereby granted, free of charge, to any person obtaining a
  58514. // copy of this software and associated documentation files (the
  58515. // "Software"), to deal in the Software without restriction, including
  58516. // without limitation the rights to use, copy, modify, merge, publish,
  58517. // distribute, sublicense, and/or sell copies of the Software, and to permit
  58518. // persons to whom the Software is furnished to do so, subject to the
  58519. // following conditions:
  58520. //
  58521. // The above copyright notice and this permission notice shall be included
  58522. // in all copies or substantial portions of the Software.
  58523. //
  58524. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  58525. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  58526. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  58527. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  58528. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  58529. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  58530. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  58531. // a transform stream is a readable/writable stream where you do
  58532. // something with the data. Sometimes it's called a "filter",
  58533. // but that's not a great name for it, since that implies a thing where
  58534. // some bits pass through, and others are simply ignored. (That would
  58535. // be a valid example of a transform, of course.)
  58536. //
  58537. // While the output is causally related to the input, it's not a
  58538. // necessarily symmetric or synchronous transformation. For example,
  58539. // a zlib stream might take multiple plain-text writes(), and then
  58540. // emit a single compressed chunk some time in the future.
  58541. //
  58542. // Here's how this works:
  58543. //
  58544. // The Transform stream has all the aspects of the readable and writable
  58545. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  58546. // internally, and returns false if there's a lot of pending writes
  58547. // buffered up. When you call read(), that calls _read(n) until
  58548. // there's enough pending readable data buffered up.
  58549. //
  58550. // In a transform stream, the written data is placed in a buffer. When
  58551. // _read(n) is called, it transforms the queued up data, calling the
  58552. // buffered _write cb's as it consumes chunks. If consuming a single
  58553. // written chunk would result in multiple output chunks, then the first
  58554. // outputted bit calls the readcb, and subsequent chunks just go into
  58555. // the read buffer, and will cause it to emit 'readable' if necessary.
  58556. //
  58557. // This way, back-pressure is actually determined by the reading side,
  58558. // since _read has to be called to start processing a new chunk. However,
  58559. // a pathological inflate type of transform can cause excessive buffering
  58560. // here. For example, imagine a stream where every byte of input is
  58561. // interpreted as an integer from 0-255, and then results in that many
  58562. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  58563. // 1kb of data being output. In this case, you could write a very small
  58564. // amount of input, and end up with a very large amount of output. In
  58565. // such a pathological inflating mechanism, there'd be no way to tell
  58566. // the system to stop doing the transform. A single 4MB write could
  58567. // cause the system to run out of memory.
  58568. //
  58569. // However, even in such a pathological case, only a single written chunk
  58570. // would be consumed, and then the rest would wait (un-transformed) until
  58571. // the results of the previous transformed chunk were consumed.
  58572. 'use strict';
  58573. module.exports = Transform;
  58574. var _require$codes = require('../errors').codes,
  58575. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  58576. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  58577. ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
  58578. ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
  58579. var Duplex = require('./_stream_duplex');
  58580. require('inherits')(Transform, Duplex);
  58581. function afterTransform(er, data) {
  58582. var ts = this._transformState;
  58583. ts.transforming = false;
  58584. var cb = ts.writecb;
  58585. if (cb === null) {
  58586. return this.emit('error', new ERR_MULTIPLE_CALLBACK());
  58587. }
  58588. ts.writechunk = null;
  58589. ts.writecb = null;
  58590. if (data != null) // single equals check for both `null` and `undefined`
  58591. this.push(data);
  58592. cb(er);
  58593. var rs = this._readableState;
  58594. rs.reading = false;
  58595. if (rs.needReadable || rs.length < rs.highWaterMark) {
  58596. this._read(rs.highWaterMark);
  58597. }
  58598. }
  58599. function Transform(options) {
  58600. if (!(this instanceof Transform)) return new Transform(options);
  58601. Duplex.call(this, options);
  58602. this._transformState = {
  58603. afterTransform: afterTransform.bind(this),
  58604. needTransform: false,
  58605. transforming: false,
  58606. writecb: null,
  58607. writechunk: null,
  58608. writeencoding: null
  58609. }; // start out asking for a readable event once data is transformed.
  58610. this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
  58611. // that Readable wants before the first _read call, so unset the
  58612. // sync guard flag.
  58613. this._readableState.sync = false;
  58614. if (options) {
  58615. if (typeof options.transform === 'function') this._transform = options.transform;
  58616. if (typeof options.flush === 'function') this._flush = options.flush;
  58617. } // When the writable side finishes, then flush out anything remaining.
  58618. this.on('prefinish', prefinish);
  58619. }
  58620. function prefinish() {
  58621. var _this = this;
  58622. if (typeof this._flush === 'function' && !this._readableState.destroyed) {
  58623. this._flush(function (er, data) {
  58624. done(_this, er, data);
  58625. });
  58626. } else {
  58627. done(this, null, null);
  58628. }
  58629. }
  58630. Transform.prototype.push = function (chunk, encoding) {
  58631. this._transformState.needTransform = false;
  58632. return Duplex.prototype.push.call(this, chunk, encoding);
  58633. }; // This is the part where you do stuff!
  58634. // override this function in implementation classes.
  58635. // 'chunk' is an input chunk.
  58636. //
  58637. // Call `push(newChunk)` to pass along transformed output
  58638. // to the readable side. You may call 'push' zero or more times.
  58639. //
  58640. // Call `cb(err)` when you are done with this chunk. If you pass
  58641. // an error, then that'll put the hurt on the whole operation. If you
  58642. // never call cb(), then you'll never get another chunk.
  58643. Transform.prototype._transform = function (chunk, encoding, cb) {
  58644. cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
  58645. };
  58646. Transform.prototype._write = function (chunk, encoding, cb) {
  58647. var ts = this._transformState;
  58648. ts.writecb = cb;
  58649. ts.writechunk = chunk;
  58650. ts.writeencoding = encoding;
  58651. if (!ts.transforming) {
  58652. var rs = this._readableState;
  58653. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  58654. }
  58655. }; // Doesn't matter what the args are here.
  58656. // _transform does all the work.
  58657. // That we got here means that the readable side wants more data.
  58658. Transform.prototype._read = function (n) {
  58659. var ts = this._transformState;
  58660. if (ts.writechunk !== null && !ts.transforming) {
  58661. ts.transforming = true;
  58662. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  58663. } else {
  58664. // mark that we need a transform, so that any data that comes in
  58665. // will get processed, now that we've asked for it.
  58666. ts.needTransform = true;
  58667. }
  58668. };
  58669. Transform.prototype._destroy = function (err, cb) {
  58670. Duplex.prototype._destroy.call(this, err, function (err2) {
  58671. cb(err2);
  58672. });
  58673. };
  58674. function done(stream, er, data) {
  58675. if (er) return stream.emit('error', er);
  58676. if (data != null) // single equals check for both `null` and `undefined`
  58677. stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
  58678. // if there's nothing in the write buffer, then that means
  58679. // that nothing more will ever be provided
  58680. if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
  58681. if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
  58682. return stream.push(null);
  58683. }
  58684. }, { "../errors": 477, "./_stream_duplex": 478, "inherits": 387 }], 482: [function (require, module, exports) {
  58685. (function (process, global) {
  58686. // Copyright Joyent, Inc. and other Node contributors.
  58687. //
  58688. // Permission is hereby granted, free of charge, to any person obtaining a
  58689. // copy of this software and associated documentation files (the
  58690. // "Software"), to deal in the Software without restriction, including
  58691. // without limitation the rights to use, copy, modify, merge, publish,
  58692. // distribute, sublicense, and/or sell copies of the Software, and to permit
  58693. // persons to whom the Software is furnished to do so, subject to the
  58694. // following conditions:
  58695. //
  58696. // The above copyright notice and this permission notice shall be included
  58697. // in all copies or substantial portions of the Software.
  58698. //
  58699. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  58700. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  58701. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  58702. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  58703. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  58704. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  58705. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  58706. // A bit simpler than readable streams.
  58707. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  58708. // the drain event emission and buffering.
  58709. 'use strict';
  58710. module.exports = Writable;
  58711. /* <replacement> */
  58712. function WriteReq(chunk, encoding, cb) {
  58713. this.chunk = chunk;
  58714. this.encoding = encoding;
  58715. this.callback = cb;
  58716. this.next = null;
  58717. } // It seems a linked list but it is not
  58718. // there will be only 2 of these for each stream
  58719. function CorkedRequest(state) {
  58720. var _this = this;
  58721. this.next = null;
  58722. this.entry = null;
  58723. this.finish = function () {
  58724. onCorkedFinish(_this, state);
  58725. };
  58726. }
  58727. /* </replacement> */
  58728. /*<replacement>*/
  58729. var Duplex;
  58730. /*</replacement>*/
  58731. Writable.WritableState = WritableState;
  58732. /*<replacement>*/
  58733. var internalUtil = {
  58734. deprecate: require('util-deprecate')
  58735. };
  58736. /*</replacement>*/
  58737. /*<replacement>*/
  58738. var Stream = require('./internal/streams/stream');
  58739. /*</replacement>*/
  58740. var Buffer = require('buffer').Buffer;
  58741. var OurUint8Array = global.Uint8Array || function () { };
  58742. function _uint8ArrayToBuffer(chunk) {
  58743. return Buffer.from(chunk);
  58744. }
  58745. function _isUint8Array(obj) {
  58746. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  58747. }
  58748. var destroyImpl = require('./internal/streams/destroy');
  58749. var _require = require('./internal/streams/state'),
  58750. getHighWaterMark = _require.getHighWaterMark;
  58751. var _require$codes = require('../errors').codes,
  58752. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  58753. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  58754. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  58755. ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
  58756. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
  58757. ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
  58758. ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
  58759. ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
  58760. var errorOrDestroy = destroyImpl.errorOrDestroy;
  58761. require('inherits')(Writable, Stream);
  58762. function nop() { }
  58763. function WritableState(options, stream, isDuplex) {
  58764. Duplex = Duplex || require('./_stream_duplex');
  58765. options = options || {}; // Duplex streams are both readable and writable, but share
  58766. // the same options object.
  58767. // However, some cases require setting options to different
  58768. // values for the readable and the writable sides of the duplex stream,
  58769. // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
  58770. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
  58771. // contains buffers or objects.
  58772. this.objectMode = !!options.objectMode;
  58773. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
  58774. // Note: 0 is a valid value, means that we always return false if
  58775. // the entire buffer is not flushed immediately on write()
  58776. this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called
  58777. this.finalCalled = false; // drain event flag.
  58778. this.needDrain = false; // at the start of calling end()
  58779. this.ending = false; // when end() has been called, and returned
  58780. this.ended = false; // when 'finish' is emitted
  58781. this.finished = false; // has it been destroyed
  58782. this.destroyed = false; // should we decode strings into buffers before passing to _write?
  58783. // this is here so that some node-core streams can optimize string
  58784. // handling at a lower level.
  58785. var noDecode = options.decodeStrings === false;
  58786. this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string
  58787. // encoding is 'binary' so we have to make this configurable.
  58788. // Everything else in the universe uses 'utf8', though.
  58789. this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
  58790. // of how much we're waiting to get pushed to some underlying
  58791. // socket or file.
  58792. this.length = 0; // a flag to see when we're in the middle of a write.
  58793. this.writing = false; // when true all writes will be buffered until .uncork() call
  58794. this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
  58795. // or on a later tick. We set this to true at first, because any
  58796. // actions that shouldn't happen until "later" should generally also
  58797. // not happen before the first write call.
  58798. this.sync = true; // a flag to know if we're processing previously buffered items, which
  58799. // may call the _write() callback in the same tick, so that we don't
  58800. // end up in an overlapped onwrite situation.
  58801. this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
  58802. this.onwrite = function (er) {
  58803. onwrite(stream, er);
  58804. }; // the callback that the user supplies to write(chunk,encoding,cb)
  58805. this.writecb = null; // the amount that is being written when _write is called.
  58806. this.writelen = 0;
  58807. this.bufferedRequest = null;
  58808. this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
  58809. // this must be 0 before 'finish' can be emitted
  58810. this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
  58811. // This is relevant for synchronous Transform streams
  58812. this.prefinished = false; // True if the error was already emitted and should not be thrown again
  58813. this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.
  58814. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')
  58815. this.autoDestroy = !!options.autoDestroy; // count buffered requests
  58816. this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
  58817. // one allocated and free to use, and we maintain at most two
  58818. this.corkedRequestsFree = new CorkedRequest(this);
  58819. }
  58820. WritableState.prototype.getBuffer = function getBuffer() {
  58821. var current = this.bufferedRequest;
  58822. var out = [];
  58823. while (current) {
  58824. out.push(current);
  58825. current = current.next;
  58826. }
  58827. return out;
  58828. };
  58829. (function () {
  58830. try {
  58831. Object.defineProperty(WritableState.prototype, 'buffer', {
  58832. get: internalUtil.deprecate(function writableStateBufferGetter() {
  58833. return this.getBuffer();
  58834. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  58835. });
  58836. } catch (_) { }
  58837. })(); // Test _writableState for inheritance to account for Duplex streams,
  58838. // whose prototype chain only points to Readable.
  58839. var realHasInstance;
  58840. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  58841. realHasInstance = Function.prototype[Symbol.hasInstance];
  58842. Object.defineProperty(Writable, Symbol.hasInstance, {
  58843. value: function value(object) {
  58844. if (realHasInstance.call(this, object)) return true;
  58845. if (this !== Writable) return false;
  58846. return object && object._writableState instanceof WritableState;
  58847. }
  58848. });
  58849. } else {
  58850. realHasInstance = function realHasInstance(object) {
  58851. return object instanceof this;
  58852. };
  58853. }
  58854. function Writable(options) {
  58855. Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.
  58856. // `realHasInstance` is necessary because using plain `instanceof`
  58857. // would return false, as no `_writableState` property is attached.
  58858. // Trying to use the custom `instanceof` for Writable here will also break the
  58859. // Node.js LazyTransform implementation, which has a non-trivial getter for
  58860. // `_writableState` that would lead to infinite recursion.
  58861. // Checking for a Stream.Duplex instance is faster here instead of inside
  58862. // the WritableState constructor, at least with V8 6.5
  58863. var isDuplex = this instanceof Duplex;
  58864. if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
  58865. this._writableState = new WritableState(options, this, isDuplex); // legacy.
  58866. this.writable = true;
  58867. if (options) {
  58868. if (typeof options.write === 'function') this._write = options.write;
  58869. if (typeof options.writev === 'function') this._writev = options.writev;
  58870. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  58871. if (typeof options.final === 'function') this._final = options.final;
  58872. }
  58873. Stream.call(this);
  58874. } // Otherwise people can pipe Writable streams, which is just wrong.
  58875. Writable.prototype.pipe = function () {
  58876. errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
  58877. };
  58878. function writeAfterEnd(stream, cb) {
  58879. var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb
  58880. errorOrDestroy(stream, er);
  58881. process.nextTick(cb, er);
  58882. } // Checks that a user-supplied chunk is valid, especially for the particular
  58883. // mode the stream is in. Currently this means that `null` is never accepted
  58884. // and undefined/non-string values are only allowed in object mode.
  58885. function validChunk(stream, state, chunk, cb) {
  58886. var er;
  58887. if (chunk === null) {
  58888. er = new ERR_STREAM_NULL_VALUES();
  58889. } else if (typeof chunk !== 'string' && !state.objectMode) {
  58890. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
  58891. }
  58892. if (er) {
  58893. errorOrDestroy(stream, er);
  58894. process.nextTick(cb, er);
  58895. return false;
  58896. }
  58897. return true;
  58898. }
  58899. Writable.prototype.write = function (chunk, encoding, cb) {
  58900. var state = this._writableState;
  58901. var ret = false;
  58902. var isBuf = !state.objectMode && _isUint8Array(chunk);
  58903. if (isBuf && !Buffer.isBuffer(chunk)) {
  58904. chunk = _uint8ArrayToBuffer(chunk);
  58905. }
  58906. if (typeof encoding === 'function') {
  58907. cb = encoding;
  58908. encoding = null;
  58909. }
  58910. if (isBuf) encoding = 'buffer'; else if (!encoding) encoding = state.defaultEncoding;
  58911. if (typeof cb !== 'function') cb = nop;
  58912. if (state.ending) writeAfterEnd(this, cb); else if (isBuf || validChunk(this, state, chunk, cb)) {
  58913. state.pendingcb++;
  58914. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  58915. }
  58916. return ret;
  58917. };
  58918. Writable.prototype.cork = function () {
  58919. this._writableState.corked++;
  58920. };
  58921. Writable.prototype.uncork = function () {
  58922. var state = this._writableState;
  58923. if (state.corked) {
  58924. state.corked--;
  58925. if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  58926. }
  58927. };
  58928. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  58929. // node::ParseEncoding() requires lower case.
  58930. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  58931. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
  58932. this._writableState.defaultEncoding = encoding;
  58933. return this;
  58934. };
  58935. Object.defineProperty(Writable.prototype, 'writableBuffer', {
  58936. // making it explicit this property is not enumerable
  58937. // because otherwise some prototype manipulation in
  58938. // userland will fail
  58939. enumerable: false,
  58940. get: function get() {
  58941. return this._writableState && this._writableState.getBuffer();
  58942. }
  58943. });
  58944. function decodeChunk(state, chunk, encoding) {
  58945. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  58946. chunk = Buffer.from(chunk, encoding);
  58947. }
  58948. return chunk;
  58949. }
  58950. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  58951. // making it explicit this property is not enumerable
  58952. // because otherwise some prototype manipulation in
  58953. // userland will fail
  58954. enumerable: false,
  58955. get: function get() {
  58956. return this._writableState.highWaterMark;
  58957. }
  58958. }); // if we're already writing something, then just put this
  58959. // in the queue, and wait our turn. Otherwise, call _write
  58960. // If we return false, then we need a drain event, so set that flag.
  58961. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  58962. if (!isBuf) {
  58963. var newChunk = decodeChunk(state, chunk, encoding);
  58964. if (chunk !== newChunk) {
  58965. isBuf = true;
  58966. encoding = 'buffer';
  58967. chunk = newChunk;
  58968. }
  58969. }
  58970. var len = state.objectMode ? 1 : chunk.length;
  58971. state.length += len;
  58972. var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
  58973. if (!ret) state.needDrain = true;
  58974. if (state.writing || state.corked) {
  58975. var last = state.lastBufferedRequest;
  58976. state.lastBufferedRequest = {
  58977. chunk: chunk,
  58978. encoding: encoding,
  58979. isBuf: isBuf,
  58980. callback: cb,
  58981. next: null
  58982. };
  58983. if (last) {
  58984. last.next = state.lastBufferedRequest;
  58985. } else {
  58986. state.bufferedRequest = state.lastBufferedRequest;
  58987. }
  58988. state.bufferedRequestCount += 1;
  58989. } else {
  58990. doWrite(stream, state, false, len, chunk, encoding, cb);
  58991. }
  58992. return ret;
  58993. }
  58994. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  58995. state.writelen = len;
  58996. state.writecb = cb;
  58997. state.writing = true;
  58998. state.sync = true;
  58999. if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write')); else if (writev) stream._writev(chunk, state.onwrite); else stream._write(chunk, encoding, state.onwrite);
  59000. state.sync = false;
  59001. }
  59002. function onwriteError(stream, state, sync, er, cb) {
  59003. --state.pendingcb;
  59004. if (sync) {
  59005. // defer the callback if we are being called synchronously
  59006. // to avoid piling up things on the stack
  59007. process.nextTick(cb, er); // this can emit finish, and it will always happen
  59008. // after error
  59009. process.nextTick(finishMaybe, stream, state);
  59010. stream._writableState.errorEmitted = true;
  59011. errorOrDestroy(stream, er);
  59012. } else {
  59013. // the caller expect this to happen before if
  59014. // it is async
  59015. cb(er);
  59016. stream._writableState.errorEmitted = true;
  59017. errorOrDestroy(stream, er); // this can emit finish, but finish must
  59018. // always follow error
  59019. finishMaybe(stream, state);
  59020. }
  59021. }
  59022. function onwriteStateUpdate(state) {
  59023. state.writing = false;
  59024. state.writecb = null;
  59025. state.length -= state.writelen;
  59026. state.writelen = 0;
  59027. }
  59028. function onwrite(stream, er) {
  59029. var state = stream._writableState;
  59030. var sync = state.sync;
  59031. var cb = state.writecb;
  59032. if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
  59033. onwriteStateUpdate(state);
  59034. if (er) onwriteError(stream, state, sync, er, cb); else {
  59035. // Check if we're actually ready to finish, but don't emit yet
  59036. var finished = needFinish(state) || stream.destroyed;
  59037. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  59038. clearBuffer(stream, state);
  59039. }
  59040. if (sync) {
  59041. process.nextTick(afterWrite, stream, state, finished, cb);
  59042. } else {
  59043. afterWrite(stream, state, finished, cb);
  59044. }
  59045. }
  59046. }
  59047. function afterWrite(stream, state, finished, cb) {
  59048. if (!finished) onwriteDrain(stream, state);
  59049. state.pendingcb--;
  59050. cb();
  59051. finishMaybe(stream, state);
  59052. } // Must force callback to be called on nextTick, so that we don't
  59053. // emit 'drain' before the write() consumer gets the 'false' return
  59054. // value, and has a chance to attach a 'drain' listener.
  59055. function onwriteDrain(stream, state) {
  59056. if (state.length === 0 && state.needDrain) {
  59057. state.needDrain = false;
  59058. stream.emit('drain');
  59059. }
  59060. } // if there's something in the buffer waiting, then process it
  59061. function clearBuffer(stream, state) {
  59062. state.bufferProcessing = true;
  59063. var entry = state.bufferedRequest;
  59064. if (stream._writev && entry && entry.next) {
  59065. // Fast case, write everything using _writev()
  59066. var l = state.bufferedRequestCount;
  59067. var buffer = new Array(l);
  59068. var holder = state.corkedRequestsFree;
  59069. holder.entry = entry;
  59070. var count = 0;
  59071. var allBuffers = true;
  59072. while (entry) {
  59073. buffer[count] = entry;
  59074. if (!entry.isBuf) allBuffers = false;
  59075. entry = entry.next;
  59076. count += 1;
  59077. }
  59078. buffer.allBuffers = allBuffers;
  59079. doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
  59080. // as the hot path ends with doWrite
  59081. state.pendingcb++;
  59082. state.lastBufferedRequest = null;
  59083. if (holder.next) {
  59084. state.corkedRequestsFree = holder.next;
  59085. holder.next = null;
  59086. } else {
  59087. state.corkedRequestsFree = new CorkedRequest(state);
  59088. }
  59089. state.bufferedRequestCount = 0;
  59090. } else {
  59091. // Slow case, write chunks one-by-one
  59092. while (entry) {
  59093. var chunk = entry.chunk;
  59094. var encoding = entry.encoding;
  59095. var cb = entry.callback;
  59096. var len = state.objectMode ? 1 : chunk.length;
  59097. doWrite(stream, state, false, len, chunk, encoding, cb);
  59098. entry = entry.next;
  59099. state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
  59100. // it means that we need to wait until it does.
  59101. // also, that means that the chunk and cb are currently
  59102. // being processed, so move the buffer counter past them.
  59103. if (state.writing) {
  59104. break;
  59105. }
  59106. }
  59107. if (entry === null) state.lastBufferedRequest = null;
  59108. }
  59109. state.bufferedRequest = entry;
  59110. state.bufferProcessing = false;
  59111. }
  59112. Writable.prototype._write = function (chunk, encoding, cb) {
  59113. cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
  59114. };
  59115. Writable.prototype._writev = null;
  59116. Writable.prototype.end = function (chunk, encoding, cb) {
  59117. var state = this._writableState;
  59118. if (typeof chunk === 'function') {
  59119. cb = chunk;
  59120. chunk = null;
  59121. encoding = null;
  59122. } else if (typeof encoding === 'function') {
  59123. cb = encoding;
  59124. encoding = null;
  59125. }
  59126. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
  59127. if (state.corked) {
  59128. state.corked = 1;
  59129. this.uncork();
  59130. } // ignore unnecessary end() calls.
  59131. if (!state.ending) endWritable(this, state, cb);
  59132. return this;
  59133. };
  59134. Object.defineProperty(Writable.prototype, 'writableLength', {
  59135. // making it explicit this property is not enumerable
  59136. // because otherwise some prototype manipulation in
  59137. // userland will fail
  59138. enumerable: false,
  59139. get: function get() {
  59140. return this._writableState.length;
  59141. }
  59142. });
  59143. function needFinish(state) {
  59144. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  59145. }
  59146. function callFinal(stream, state) {
  59147. stream._final(function (err) {
  59148. state.pendingcb--;
  59149. if (err) {
  59150. errorOrDestroy(stream, err);
  59151. }
  59152. state.prefinished = true;
  59153. stream.emit('prefinish');
  59154. finishMaybe(stream, state);
  59155. });
  59156. }
  59157. function prefinish(stream, state) {
  59158. if (!state.prefinished && !state.finalCalled) {
  59159. if (typeof stream._final === 'function' && !state.destroyed) {
  59160. state.pendingcb++;
  59161. state.finalCalled = true;
  59162. process.nextTick(callFinal, stream, state);
  59163. } else {
  59164. state.prefinished = true;
  59165. stream.emit('prefinish');
  59166. }
  59167. }
  59168. }
  59169. function finishMaybe(stream, state) {
  59170. var need = needFinish(state);
  59171. if (need) {
  59172. prefinish(stream, state);
  59173. if (state.pendingcb === 0) {
  59174. state.finished = true;
  59175. stream.emit('finish');
  59176. if (state.autoDestroy) {
  59177. // In case of duplex streams we need a way to detect
  59178. // if the readable side is ready for autoDestroy as well
  59179. var rState = stream._readableState;
  59180. if (!rState || rState.autoDestroy && rState.endEmitted) {
  59181. stream.destroy();
  59182. }
  59183. }
  59184. }
  59185. }
  59186. return need;
  59187. }
  59188. function endWritable(stream, state, cb) {
  59189. state.ending = true;
  59190. finishMaybe(stream, state);
  59191. if (cb) {
  59192. if (state.finished) process.nextTick(cb); else stream.once('finish', cb);
  59193. }
  59194. state.ended = true;
  59195. stream.writable = false;
  59196. }
  59197. function onCorkedFinish(corkReq, state, err) {
  59198. var entry = corkReq.entry;
  59199. corkReq.entry = null;
  59200. while (entry) {
  59201. var cb = entry.callback;
  59202. state.pendingcb--;
  59203. cb(err);
  59204. entry = entry.next;
  59205. } // reuse the free corkReq.
  59206. state.corkedRequestsFree.next = corkReq;
  59207. }
  59208. Object.defineProperty(Writable.prototype, 'destroyed', {
  59209. // making it explicit this property is not enumerable
  59210. // because otherwise some prototype manipulation in
  59211. // userland will fail
  59212. enumerable: false,
  59213. get: function get() {
  59214. if (this._writableState === undefined) {
  59215. return false;
  59216. }
  59217. return this._writableState.destroyed;
  59218. },
  59219. set: function set(value) {
  59220. // we ignore the value if the stream
  59221. // has not been initialized yet
  59222. if (!this._writableState) {
  59223. return;
  59224. } // backward compatibility, the user is explicitly
  59225. // managing destroyed
  59226. this._writableState.destroyed = value;
  59227. }
  59228. });
  59229. Writable.prototype.destroy = destroyImpl.destroy;
  59230. Writable.prototype._undestroy = destroyImpl.undestroy;
  59231. Writable.prototype._destroy = function (err, cb) {
  59232. cb(err);
  59233. };
  59234. }).call(this, require('_process'), typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  59235. }, { "../errors": 477, "./_stream_duplex": 478, "./internal/streams/destroy": 485, "./internal/streams/state": 489, "./internal/streams/stream": 490, "_process": 467, "buffer": 216, "inherits": 387, "util-deprecate": 522 }], 483: [function (require, module, exports) {
  59236. (function (process) {
  59237. 'use strict';
  59238. var _Object$setPrototypeO;
  59239. function _defineProperty(obj, key, value) {
  59240. if (key in obj) {
  59241. Object.defineProperty(obj, key, {
  59242. value: value,
  59243. enumerable: true,
  59244. configurable: true,
  59245. writable: true
  59246. });
  59247. } else {
  59248. obj[key] = value;
  59249. }
  59250. return obj;
  59251. }
  59252. var finished = require('./end-of-stream');
  59253. var kLastResolve = Symbol('lastResolve');
  59254. var kLastReject = Symbol('lastReject');
  59255. var kError = Symbol('error');
  59256. var kEnded = Symbol('ended');
  59257. var kLastPromise = Symbol('lastPromise');
  59258. var kHandlePromise = Symbol('handlePromise');
  59259. var kStream = Symbol('stream');
  59260. function createIterResult(value, done) {
  59261. return {
  59262. value: value,
  59263. done: done
  59264. };
  59265. }
  59266. function readAndResolve(iter) {
  59267. var resolve = iter[kLastResolve];
  59268. if (resolve !== null) {
  59269. var data = iter[kStream].read(); // we defer if data is null
  59270. // we can be expecting either 'end' or
  59271. // 'error'
  59272. if (data !== null) {
  59273. iter[kLastPromise] = null;
  59274. iter[kLastResolve] = null;
  59275. iter[kLastReject] = null;
  59276. resolve(createIterResult(data, false));
  59277. }
  59278. }
  59279. }
  59280. function onReadable(iter) {
  59281. // we wait for the next tick, because it might
  59282. // emit an error with process.nextTick
  59283. process.nextTick(readAndResolve, iter);
  59284. }
  59285. function wrapForNext(lastPromise, iter) {
  59286. return function (resolve, reject) {
  59287. lastPromise.then(function () {
  59288. if (iter[kEnded]) {
  59289. resolve(createIterResult(undefined, true));
  59290. return;
  59291. }
  59292. iter[kHandlePromise](resolve, reject);
  59293. }, reject);
  59294. };
  59295. }
  59296. var AsyncIteratorPrototype = Object.getPrototypeOf(function () { });
  59297. var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
  59298. get stream() {
  59299. return this[kStream];
  59300. },
  59301. next: function next() {
  59302. var _this = this; // if we have detected an error in the meanwhile
  59303. // reject straight away
  59304. var error = this[kError];
  59305. if (error !== null) {
  59306. return Promise.reject(error);
  59307. }
  59308. if (this[kEnded]) {
  59309. return Promise.resolve(createIterResult(undefined, true));
  59310. }
  59311. if (this[kStream].destroyed) {
  59312. // We need to defer via nextTick because if .destroy(err) is
  59313. // called, the error will be emitted via nextTick, and
  59314. // we cannot guarantee that there is no error lingering around
  59315. // waiting to be emitted.
  59316. return new Promise(function (resolve, reject) {
  59317. process.nextTick(function () {
  59318. if (_this[kError]) {
  59319. reject(_this[kError]);
  59320. } else {
  59321. resolve(createIterResult(undefined, true));
  59322. }
  59323. });
  59324. });
  59325. } // if we have multiple next() calls
  59326. // we will wait for the previous Promise to finish
  59327. // this logic is optimized to support for await loops,
  59328. // where next() is only called once at a time
  59329. var lastPromise = this[kLastPromise];
  59330. var promise;
  59331. if (lastPromise) {
  59332. promise = new Promise(wrapForNext(lastPromise, this));
  59333. } else {
  59334. // fast path needed to support multiple this.push()
  59335. // without triggering the next() queue
  59336. var data = this[kStream].read();
  59337. if (data !== null) {
  59338. return Promise.resolve(createIterResult(data, false));
  59339. }
  59340. promise = new Promise(this[kHandlePromise]);
  59341. }
  59342. this[kLastPromise] = promise;
  59343. return promise;
  59344. }
  59345. }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
  59346. return this;
  59347. }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
  59348. var _this2 = this; // destroy(err, cb) is a private API
  59349. // we can guarantee we have that here, because we control the
  59350. // Readable class this is attached to
  59351. return new Promise(function (resolve, reject) {
  59352. _this2[kStream].destroy(null, function (err) {
  59353. if (err) {
  59354. reject(err);
  59355. return;
  59356. }
  59357. resolve(createIterResult(undefined, true));
  59358. });
  59359. });
  59360. }), _Object$setPrototypeO), AsyncIteratorPrototype);
  59361. var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
  59362. var _Object$create;
  59363. var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
  59364. value: stream,
  59365. writable: true
  59366. }), _defineProperty(_Object$create, kLastResolve, {
  59367. value: null,
  59368. writable: true
  59369. }), _defineProperty(_Object$create, kLastReject, {
  59370. value: null,
  59371. writable: true
  59372. }), _defineProperty(_Object$create, kError, {
  59373. value: null,
  59374. writable: true
  59375. }), _defineProperty(_Object$create, kEnded, {
  59376. value: stream._readableState.endEmitted,
  59377. writable: true
  59378. }), _defineProperty(_Object$create, kHandlePromise, {
  59379. value: function value(resolve, reject) {
  59380. var data = iterator[kStream].read();
  59381. if (data) {
  59382. iterator[kLastPromise] = null;
  59383. iterator[kLastResolve] = null;
  59384. iterator[kLastReject] = null;
  59385. resolve(createIterResult(data, false));
  59386. } else {
  59387. iterator[kLastResolve] = resolve;
  59388. iterator[kLastReject] = reject;
  59389. }
  59390. },
  59391. writable: true
  59392. }), _Object$create));
  59393. iterator[kLastPromise] = null;
  59394. finished(stream, function (err) {
  59395. if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
  59396. var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise
  59397. // returned by next() and store the error
  59398. if (reject !== null) {
  59399. iterator[kLastPromise] = null;
  59400. iterator[kLastResolve] = null;
  59401. iterator[kLastReject] = null;
  59402. reject(err);
  59403. }
  59404. iterator[kError] = err;
  59405. return;
  59406. }
  59407. var resolve = iterator[kLastResolve];
  59408. if (resolve !== null) {
  59409. iterator[kLastPromise] = null;
  59410. iterator[kLastResolve] = null;
  59411. iterator[kLastReject] = null;
  59412. resolve(createIterResult(undefined, true));
  59413. }
  59414. iterator[kEnded] = true;
  59415. });
  59416. stream.on('readable', onReadable.bind(null, iterator));
  59417. return iterator;
  59418. };
  59419. module.exports = createReadableStreamAsyncIterator;
  59420. }).call(this, require('_process'))
  59421. }, { "./end-of-stream": 486, "_process": 467 }], 484: [function (require, module, exports) {
  59422. 'use strict';
  59423. function ownKeys(object, enumerableOnly) {
  59424. var keys = Object.keys(object);
  59425. if (Object.getOwnPropertySymbols) {
  59426. var symbols = Object.getOwnPropertySymbols(object);
  59427. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  59428. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  59429. });
  59430. keys.push.apply(keys, symbols);
  59431. }
  59432. return keys;
  59433. }
  59434. function _objectSpread(target) {
  59435. for (var i = 1; i < arguments.length; i++) {
  59436. var source = arguments[i] != null ? arguments[i] : {};
  59437. if (i % 2) {
  59438. ownKeys(Object(source), true).forEach(function (key) {
  59439. _defineProperty(target, key, source[key]);
  59440. });
  59441. } else if (Object.getOwnPropertyDescriptors) {
  59442. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  59443. } else {
  59444. ownKeys(Object(source)).forEach(function (key) {
  59445. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  59446. });
  59447. }
  59448. }
  59449. return target;
  59450. }
  59451. function _defineProperty(obj, key, value) {
  59452. if (key in obj) {
  59453. Object.defineProperty(obj, key, {
  59454. value: value,
  59455. enumerable: true,
  59456. configurable: true,
  59457. writable: true
  59458. });
  59459. } else {
  59460. obj[key] = value;
  59461. }
  59462. return obj;
  59463. }
  59464. function _classCallCheck(instance, Constructor) {
  59465. if (!(instance instanceof Constructor)) {
  59466. throw new TypeError("Cannot call a class as a function");
  59467. }
  59468. }
  59469. function _defineProperties(target, props) {
  59470. for (var i = 0; i < props.length; i++) {
  59471. var descriptor = props[i];
  59472. descriptor.enumerable = descriptor.enumerable || false;
  59473. descriptor.configurable = true;
  59474. if ("value" in descriptor) descriptor.writable = true;
  59475. Object.defineProperty(target, descriptor.key, descriptor);
  59476. }
  59477. }
  59478. function _createClass(Constructor, protoProps, staticProps) {
  59479. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  59480. if (staticProps) _defineProperties(Constructor, staticProps);
  59481. return Constructor;
  59482. }
  59483. var _require = require('buffer'),
  59484. Buffer = _require.Buffer;
  59485. var _require2 = require('util'),
  59486. inspect = _require2.inspect;
  59487. var custom = inspect && inspect.custom || 'inspect';
  59488. function copyBuffer(src, target, offset) {
  59489. Buffer.prototype.copy.call(src, target, offset);
  59490. }
  59491. module.exports = /*#__PURE__*/function () {
  59492. function BufferList() {
  59493. _classCallCheck(this, BufferList);
  59494. this.head = null;
  59495. this.tail = null;
  59496. this.length = 0;
  59497. }
  59498. _createClass(BufferList, [{
  59499. key: "push",
  59500. value: function push(v) {
  59501. var entry = {
  59502. data: v,
  59503. next: null
  59504. };
  59505. if (this.length > 0) this.tail.next = entry; else this.head = entry;
  59506. this.tail = entry;
  59507. ++this.length;
  59508. }
  59509. }, {
  59510. key: "unshift",
  59511. value: function unshift(v) {
  59512. var entry = {
  59513. data: v,
  59514. next: this.head
  59515. };
  59516. if (this.length === 0) this.tail = entry;
  59517. this.head = entry;
  59518. ++this.length;
  59519. }
  59520. }, {
  59521. key: "shift",
  59522. value: function shift() {
  59523. if (this.length === 0) return;
  59524. var ret = this.head.data;
  59525. if (this.length === 1) this.head = this.tail = null; else this.head = this.head.next;
  59526. --this.length;
  59527. return ret;
  59528. }
  59529. }, {
  59530. key: "clear",
  59531. value: function clear() {
  59532. this.head = this.tail = null;
  59533. this.length = 0;
  59534. }
  59535. }, {
  59536. key: "join",
  59537. value: function join(s) {
  59538. if (this.length === 0) return '';
  59539. var p = this.head;
  59540. var ret = '' + p.data;
  59541. while (p = p.next) {
  59542. ret += s + p.data;
  59543. }
  59544. return ret;
  59545. }
  59546. }, {
  59547. key: "concat",
  59548. value: function concat(n) {
  59549. if (this.length === 0) return Buffer.alloc(0);
  59550. var ret = Buffer.allocUnsafe(n >>> 0);
  59551. var p = this.head;
  59552. var i = 0;
  59553. while (p) {
  59554. copyBuffer(p.data, ret, i);
  59555. i += p.data.length;
  59556. p = p.next;
  59557. }
  59558. return ret;
  59559. } // Consumes a specified amount of bytes or characters from the buffered data.
  59560. }, {
  59561. key: "consume",
  59562. value: function consume(n, hasStrings) {
  59563. var ret;
  59564. if (n < this.head.data.length) {
  59565. // `slice` is the same for buffers and strings.
  59566. ret = this.head.data.slice(0, n);
  59567. this.head.data = this.head.data.slice(n);
  59568. } else if (n === this.head.data.length) {
  59569. // First chunk is a perfect match.
  59570. ret = this.shift();
  59571. } else {
  59572. // Result spans more than one buffer.
  59573. ret = hasStrings ? this._getString(n) : this._getBuffer(n);
  59574. }
  59575. return ret;
  59576. }
  59577. }, {
  59578. key: "first",
  59579. value: function first() {
  59580. return this.head.data;
  59581. } // Consumes a specified amount of characters from the buffered data.
  59582. }, {
  59583. key: "_getString",
  59584. value: function _getString(n) {
  59585. var p = this.head;
  59586. var c = 1;
  59587. var ret = p.data;
  59588. n -= ret.length;
  59589. while (p = p.next) {
  59590. var str = p.data;
  59591. var nb = n > str.length ? str.length : n;
  59592. if (nb === str.length) ret += str; else ret += str.slice(0, n);
  59593. n -= nb;
  59594. if (n === 0) {
  59595. if (nb === str.length) {
  59596. ++c;
  59597. if (p.next) this.head = p.next; else this.head = this.tail = null;
  59598. } else {
  59599. this.head = p;
  59600. p.data = str.slice(nb);
  59601. }
  59602. break;
  59603. }
  59604. ++c;
  59605. }
  59606. this.length -= c;
  59607. return ret;
  59608. } // Consumes a specified amount of bytes from the buffered data.
  59609. }, {
  59610. key: "_getBuffer",
  59611. value: function _getBuffer(n) {
  59612. var ret = Buffer.allocUnsafe(n);
  59613. var p = this.head;
  59614. var c = 1;
  59615. p.data.copy(ret);
  59616. n -= p.data.length;
  59617. while (p = p.next) {
  59618. var buf = p.data;
  59619. var nb = n > buf.length ? buf.length : n;
  59620. buf.copy(ret, ret.length - n, 0, nb);
  59621. n -= nb;
  59622. if (n === 0) {
  59623. if (nb === buf.length) {
  59624. ++c;
  59625. if (p.next) this.head = p.next; else this.head = this.tail = null;
  59626. } else {
  59627. this.head = p;
  59628. p.data = buf.slice(nb);
  59629. }
  59630. break;
  59631. }
  59632. ++c;
  59633. }
  59634. this.length -= c;
  59635. return ret;
  59636. } // Make sure the linked list only shows the minimal necessary information.
  59637. }, {
  59638. key: custom,
  59639. value: function value(_, options) {
  59640. return inspect(this, _objectSpread({}, options, {
  59641. // Only inspect one level.
  59642. depth: 0,
  59643. // It should not recurse.
  59644. customInspect: false
  59645. }));
  59646. }
  59647. }]);
  59648. return BufferList;
  59649. }();
  59650. }, { "buffer": 216, "util": 185 }], 485: [function (require, module, exports) {
  59651. (function (process) {
  59652. 'use strict'; // undocumented cb() API, needed for core, not for public API
  59653. function destroy(err, cb) {
  59654. var _this = this;
  59655. var readableDestroyed = this._readableState && this._readableState.destroyed;
  59656. var writableDestroyed = this._writableState && this._writableState.destroyed;
  59657. if (readableDestroyed || writableDestroyed) {
  59658. if (cb) {
  59659. cb(err);
  59660. } else if (err) {
  59661. if (!this._writableState) {
  59662. process.nextTick(emitErrorNT, this, err);
  59663. } else if (!this._writableState.errorEmitted) {
  59664. this._writableState.errorEmitted = true;
  59665. process.nextTick(emitErrorNT, this, err);
  59666. }
  59667. }
  59668. return this;
  59669. } // we set destroyed to true before firing error callbacks in order
  59670. // to make it re-entrance safe in case destroy() is called within callbacks
  59671. if (this._readableState) {
  59672. this._readableState.destroyed = true;
  59673. } // if this is a duplex stream mark the writable part as destroyed as well
  59674. if (this._writableState) {
  59675. this._writableState.destroyed = true;
  59676. }
  59677. this._destroy(err || null, function (err) {
  59678. if (!cb && err) {
  59679. if (!_this._writableState) {
  59680. process.nextTick(emitErrorAndCloseNT, _this, err);
  59681. } else if (!_this._writableState.errorEmitted) {
  59682. _this._writableState.errorEmitted = true;
  59683. process.nextTick(emitErrorAndCloseNT, _this, err);
  59684. } else {
  59685. process.nextTick(emitCloseNT, _this);
  59686. }
  59687. } else if (cb) {
  59688. process.nextTick(emitCloseNT, _this);
  59689. cb(err);
  59690. } else {
  59691. process.nextTick(emitCloseNT, _this);
  59692. }
  59693. });
  59694. return this;
  59695. }
  59696. function emitErrorAndCloseNT(self, err) {
  59697. emitErrorNT(self, err);
  59698. emitCloseNT(self);
  59699. }
  59700. function emitCloseNT(self) {
  59701. if (self._writableState && !self._writableState.emitClose) return;
  59702. if (self._readableState && !self._readableState.emitClose) return;
  59703. self.emit('close');
  59704. }
  59705. function undestroy() {
  59706. if (this._readableState) {
  59707. this._readableState.destroyed = false;
  59708. this._readableState.reading = false;
  59709. this._readableState.ended = false;
  59710. this._readableState.endEmitted = false;
  59711. }
  59712. if (this._writableState) {
  59713. this._writableState.destroyed = false;
  59714. this._writableState.ended = false;
  59715. this._writableState.ending = false;
  59716. this._writableState.finalCalled = false;
  59717. this._writableState.prefinished = false;
  59718. this._writableState.finished = false;
  59719. this._writableState.errorEmitted = false;
  59720. }
  59721. }
  59722. function emitErrorNT(self, err) {
  59723. self.emit('error', err);
  59724. }
  59725. function errorOrDestroy(stream, err) {
  59726. // We have tests that rely on errors being emitted
  59727. // in the same tick, so changing this is semver major.
  59728. // For now when you opt-in to autoDestroy we allow
  59729. // the error to be emitted nextTick. In a future
  59730. // semver major update we should change the default to this.
  59731. var rState = stream._readableState;
  59732. var wState = stream._writableState;
  59733. if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err); else stream.emit('error', err);
  59734. }
  59735. module.exports = {
  59736. destroy: destroy,
  59737. undestroy: undestroy,
  59738. errorOrDestroy: errorOrDestroy
  59739. };
  59740. }).call(this, require('_process'))
  59741. }, { "_process": 467 }], 486: [function (require, module, exports) {
  59742. // Ported from https://github.com/mafintosh/end-of-stream with
  59743. // permission from the author, Mathias Buus (@mafintosh).
  59744. 'use strict';
  59745. var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;
  59746. function once(callback) {
  59747. var called = false;
  59748. return function () {
  59749. if (called) return;
  59750. called = true;
  59751. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  59752. args[_key] = arguments[_key];
  59753. }
  59754. callback.apply(this, args);
  59755. };
  59756. }
  59757. function noop() { }
  59758. function isRequest(stream) {
  59759. return stream.setHeader && typeof stream.abort === 'function';
  59760. }
  59761. function eos(stream, opts, callback) {
  59762. if (typeof opts === 'function') return eos(stream, null, opts);
  59763. if (!opts) opts = {};
  59764. callback = once(callback || noop);
  59765. var readable = opts.readable || opts.readable !== false && stream.readable;
  59766. var writable = opts.writable || opts.writable !== false && stream.writable;
  59767. var onlegacyfinish = function onlegacyfinish() {
  59768. if (!stream.writable) onfinish();
  59769. };
  59770. var writableEnded = stream._writableState && stream._writableState.finished;
  59771. var onfinish = function onfinish() {
  59772. writable = false;
  59773. writableEnded = true;
  59774. if (!readable) callback.call(stream);
  59775. };
  59776. var readableEnded = stream._readableState && stream._readableState.endEmitted;
  59777. var onend = function onend() {
  59778. readable = false;
  59779. readableEnded = true;
  59780. if (!writable) callback.call(stream);
  59781. };
  59782. var onerror = function onerror(err) {
  59783. callback.call(stream, err);
  59784. };
  59785. var onclose = function onclose() {
  59786. var err;
  59787. if (readable && !readableEnded) {
  59788. if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  59789. return callback.call(stream, err);
  59790. }
  59791. if (writable && !writableEnded) {
  59792. if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  59793. return callback.call(stream, err);
  59794. }
  59795. };
  59796. var onrequest = function onrequest() {
  59797. stream.req.on('finish', onfinish);
  59798. };
  59799. if (isRequest(stream)) {
  59800. stream.on('complete', onfinish);
  59801. stream.on('abort', onclose);
  59802. if (stream.req) onrequest(); else stream.on('request', onrequest);
  59803. } else if (writable && !stream._writableState) {
  59804. // legacy streams
  59805. stream.on('end', onlegacyfinish);
  59806. stream.on('close', onlegacyfinish);
  59807. }
  59808. stream.on('end', onend);
  59809. stream.on('finish', onfinish);
  59810. if (opts.error !== false) stream.on('error', onerror);
  59811. stream.on('close', onclose);
  59812. return function () {
  59813. stream.removeListener('complete', onfinish);
  59814. stream.removeListener('abort', onclose);
  59815. stream.removeListener('request', onrequest);
  59816. if (stream.req) stream.req.removeListener('finish', onfinish);
  59817. stream.removeListener('end', onlegacyfinish);
  59818. stream.removeListener('close', onlegacyfinish);
  59819. stream.removeListener('finish', onfinish);
  59820. stream.removeListener('end', onend);
  59821. stream.removeListener('error', onerror);
  59822. stream.removeListener('close', onclose);
  59823. };
  59824. }
  59825. module.exports = eos;
  59826. }, { "../../../errors": 477 }], 487: [function (require, module, exports) {
  59827. "use strict";
  59828. module.exports = function () {
  59829. throw new Error('Readable.from is not available in the browser');
  59830. };
  59831. }, {}], 488: [function (require, module, exports) {
  59832. // Ported from https://github.com/mafintosh/pump with
  59833. // permission from the author, Mathias Buus (@mafintosh).
  59834. 'use strict';
  59835. var eos;
  59836. function once(callback) {
  59837. var called = false;
  59838. return function () {
  59839. if (called) return;
  59840. called = true;
  59841. callback.apply(void 0, arguments);
  59842. };
  59843. }
  59844. var _require$codes = require('../../../errors').codes,
  59845. ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
  59846. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
  59847. function noop(err) {
  59848. // Rethrow the error if it exists to avoid swallowing it
  59849. if (err) throw err;
  59850. }
  59851. function isRequest(stream) {
  59852. return stream.setHeader && typeof stream.abort === 'function';
  59853. }
  59854. function destroyer(stream, reading, writing, callback) {
  59855. callback = once(callback);
  59856. var closed = false;
  59857. stream.on('close', function () {
  59858. closed = true;
  59859. });
  59860. if (eos === undefined) eos = require('./end-of-stream');
  59861. eos(stream, {
  59862. readable: reading,
  59863. writable: writing
  59864. }, function (err) {
  59865. if (err) return callback(err);
  59866. closed = true;
  59867. callback();
  59868. });
  59869. var destroyed = false;
  59870. return function (err) {
  59871. if (closed) return;
  59872. if (destroyed) return;
  59873. destroyed = true; // request.destroy just do .end - .abort is what we want
  59874. if (isRequest(stream)) return stream.abort();
  59875. if (typeof stream.destroy === 'function') return stream.destroy();
  59876. callback(err || new ERR_STREAM_DESTROYED('pipe'));
  59877. };
  59878. }
  59879. function call(fn) {
  59880. fn();
  59881. }
  59882. function pipe(from, to) {
  59883. return from.pipe(to);
  59884. }
  59885. function popCallback(streams) {
  59886. if (!streams.length) return noop;
  59887. if (typeof streams[streams.length - 1] !== 'function') return noop;
  59888. return streams.pop();
  59889. }
  59890. function pipeline() {
  59891. for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
  59892. streams[_key] = arguments[_key];
  59893. }
  59894. var callback = popCallback(streams);
  59895. if (Array.isArray(streams[0])) streams = streams[0];
  59896. if (streams.length < 2) {
  59897. throw new ERR_MISSING_ARGS('streams');
  59898. }
  59899. var error;
  59900. var destroys = streams.map(function (stream, i) {
  59901. var reading = i < streams.length - 1;
  59902. var writing = i > 0;
  59903. return destroyer(stream, reading, writing, function (err) {
  59904. if (!error) error = err;
  59905. if (err) destroys.forEach(call);
  59906. if (reading) return;
  59907. destroys.forEach(call);
  59908. callback(error);
  59909. });
  59910. });
  59911. return streams.reduce(pipe);
  59912. }
  59913. module.exports = pipeline;
  59914. }, { "../../../errors": 477, "./end-of-stream": 486 }], 489: [function (require, module, exports) {
  59915. 'use strict';
  59916. var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;
  59917. function highWaterMarkFrom(options, isDuplex, duplexKey) {
  59918. return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
  59919. }
  59920. function getHighWaterMark(state, options, duplexKey, isDuplex) {
  59921. var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
  59922. if (hwm != null) {
  59923. if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
  59924. var name = isDuplex ? duplexKey : 'highWaterMark';
  59925. throw new ERR_INVALID_OPT_VALUE(name, hwm);
  59926. }
  59927. return Math.floor(hwm);
  59928. } // Default value
  59929. return state.objectMode ? 16 : 16 * 1024;
  59930. }
  59931. module.exports = {
  59932. getHighWaterMark: getHighWaterMark
  59933. };
  59934. }, { "../../../errors": 477 }], 490: [function (require, module, exports) {
  59935. "use strict";
  59936. module.exports = require('events').EventEmitter;
  59937. }, { "events": 367 }], 491: [function (require, module, exports) {
  59938. "use strict";
  59939. exports = module.exports = require('./lib/_stream_readable.js');
  59940. exports.Stream = exports;
  59941. exports.Readable = exports;
  59942. exports.Writable = require('./lib/_stream_writable.js');
  59943. exports.Duplex = require('./lib/_stream_duplex.js');
  59944. exports.Transform = require('./lib/_stream_transform.js');
  59945. exports.PassThrough = require('./lib/_stream_passthrough.js');
  59946. exports.finished = require('./lib/internal/streams/end-of-stream.js');
  59947. exports.pipeline = require('./lib/internal/streams/pipeline.js');
  59948. }, { "./lib/_stream_duplex.js": 478, "./lib/_stream_passthrough.js": 479, "./lib/_stream_readable.js": 480, "./lib/_stream_transform.js": 481, "./lib/_stream_writable.js": 482, "./lib/internal/streams/end-of-stream.js": 486, "./lib/internal/streams/pipeline.js": 488 }], 492: [function (require, module, exports) {
  59949. "use strict";
  59950. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  59951. /**
  59952. * Copyright (c) 2014-present, Facebook, Inc.
  59953. *
  59954. * This source code is licensed under the MIT license found in the
  59955. * LICENSE file in the root directory of this source tree.
  59956. */
  59957. var runtime = function (exports) {
  59958. "use strict";
  59959. var Op = Object.prototype;
  59960. var hasOwn = Op.hasOwnProperty;
  59961. var undefined; // More compressible than void 0.
  59962. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  59963. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  59964. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  59965. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  59966. function define(obj, key, value) {
  59967. Object.defineProperty(obj, key, {
  59968. value: value,
  59969. enumerable: true,
  59970. configurable: true,
  59971. writable: true
  59972. });
  59973. return obj[key];
  59974. }
  59975. try {
  59976. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  59977. define({}, "");
  59978. } catch (err) {
  59979. define = function define(obj, key, value) {
  59980. return obj[key] = value;
  59981. };
  59982. }
  59983. function wrap(innerFn, outerFn, self, tryLocsList) {
  59984. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  59985. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  59986. var generator = Object.create(protoGenerator.prototype);
  59987. var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
  59988. // .throw, and .return methods.
  59989. generator._invoke = makeInvokeMethod(innerFn, self, context);
  59990. return generator;
  59991. }
  59992. exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
  59993. // record like context.tryEntries[i].completion. This interface could
  59994. // have been (and was previously) designed to take a closure to be
  59995. // invoked without arguments, but in all the cases we care about we
  59996. // already have an existing method we want to call, so there's no need
  59997. // to create a new function object. We can even get away with assuming
  59998. // the method takes exactly one argument, since that happens to be true
  59999. // in every case, so we don't have to touch the arguments object. The
  60000. // only additional allocation required is the completion record, which
  60001. // has a stable shape and so hopefully should be cheap to allocate.
  60002. function tryCatch(fn, obj, arg) {
  60003. try {
  60004. return {
  60005. type: "normal",
  60006. arg: fn.call(obj, arg)
  60007. };
  60008. } catch (err) {
  60009. return {
  60010. type: "throw",
  60011. arg: err
  60012. };
  60013. }
  60014. }
  60015. var GenStateSuspendedStart = "suspendedStart";
  60016. var GenStateSuspendedYield = "suspendedYield";
  60017. var GenStateExecuting = "executing";
  60018. var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
  60019. // breaking out of the dispatch switch statement.
  60020. var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
  60021. // .constructor.prototype properties for functions that return Generator
  60022. // objects. For full spec compliance, you may wish to configure your
  60023. // minifier not to mangle the names of these two functions.
  60024. function Generator() { }
  60025. function GeneratorFunction() { }
  60026. function GeneratorFunctionPrototype() { } // This is a polyfill for %IteratorPrototype% for environments that
  60027. // don't natively support it.
  60028. var IteratorPrototype = {};
  60029. IteratorPrototype[iteratorSymbol] = function () {
  60030. return this;
  60031. };
  60032. var getProto = Object.getPrototypeOf;
  60033. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  60034. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  60035. // This environment has a native %IteratorPrototype%; use it instead
  60036. // of the polyfill.
  60037. IteratorPrototype = NativeIteratorPrototype;
  60038. }
  60039. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  60040. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  60041. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  60042. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
  60043. // Iterator interface in terms of a single ._invoke method.
  60044. function defineIteratorMethods(prototype) {
  60045. ["next", "throw", "return"].forEach(function (method) {
  60046. define(prototype, method, function (arg) {
  60047. return this._invoke(method, arg);
  60048. });
  60049. });
  60050. }
  60051. exports.isGeneratorFunction = function (genFun) {
  60052. var ctor = typeof genFun === "function" && genFun.constructor;
  60053. return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
  60054. // do is to check its .name property.
  60055. (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  60056. };
  60057. exports.mark = function (genFun) {
  60058. if (Object.setPrototypeOf) {
  60059. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  60060. } else {
  60061. genFun.__proto__ = GeneratorFunctionPrototype;
  60062. define(genFun, toStringTagSymbol, "GeneratorFunction");
  60063. }
  60064. genFun.prototype = Object.create(Gp);
  60065. return genFun;
  60066. }; // Within the body of any async function, `await x` is transformed to
  60067. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  60068. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  60069. // meant to be awaited.
  60070. exports.awrap = function (arg) {
  60071. return {
  60072. __await: arg
  60073. };
  60074. };
  60075. function AsyncIterator(generator, PromiseImpl) {
  60076. function invoke(method, arg, resolve, reject) {
  60077. var record = tryCatch(generator[method], generator, arg);
  60078. if (record.type === "throw") {
  60079. reject(record.arg);
  60080. } else {
  60081. var result = record.arg;
  60082. var value = result.value;
  60083. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  60084. return PromiseImpl.resolve(value.__await).then(function (value) {
  60085. invoke("next", value, resolve, reject);
  60086. }, function (err) {
  60087. invoke("throw", err, resolve, reject);
  60088. });
  60089. }
  60090. return PromiseImpl.resolve(value).then(function (unwrapped) {
  60091. // When a yielded Promise is resolved, its final value becomes
  60092. // the .value of the Promise<{value,done}> result for the
  60093. // current iteration.
  60094. result.value = unwrapped;
  60095. resolve(result);
  60096. }, function (error) {
  60097. // If a rejected Promise was yielded, throw the rejection back
  60098. // into the async generator function so it can be handled there.
  60099. return invoke("throw", error, resolve, reject);
  60100. });
  60101. }
  60102. }
  60103. var previousPromise;
  60104. function enqueue(method, arg) {
  60105. function callInvokeWithMethodAndArg() {
  60106. return new PromiseImpl(function (resolve, reject) {
  60107. invoke(method, arg, resolve, reject);
  60108. });
  60109. }
  60110. return previousPromise = // If enqueue has been called before, then we want to wait until
  60111. // all previous Promises have been resolved before calling invoke,
  60112. // so that results are always delivered in the correct order. If
  60113. // enqueue has not been called before, then it is important to
  60114. // call invoke immediately, without waiting on a callback to fire,
  60115. // so that the async generator function has the opportunity to do
  60116. // any necessary setup in a predictable way. This predictability
  60117. // is why the Promise constructor synchronously invokes its
  60118. // executor callback, and why async functions synchronously
  60119. // execute code before the first await. Since we implement simple
  60120. // async functions in terms of async generators, it is especially
  60121. // important to get this right, even though it requires care.
  60122. previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
  60123. // invocations of the iterator.
  60124. callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  60125. } // Define the unified helper method that is used to implement .next,
  60126. // .throw, and .return (see defineIteratorMethods).
  60127. this._invoke = enqueue;
  60128. }
  60129. defineIteratorMethods(AsyncIterator.prototype);
  60130. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  60131. return this;
  60132. };
  60133. exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
  60134. // AsyncIterator objects; they just return a Promise for the value of
  60135. // the final result produced by the iterator.
  60136. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  60137. if (PromiseImpl === void 0) PromiseImpl = Promise;
  60138. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  60139. return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
  60140. : iter.next().then(function (result) {
  60141. return result.done ? result.value : iter.next();
  60142. });
  60143. };
  60144. function makeInvokeMethod(innerFn, self, context) {
  60145. var state = GenStateSuspendedStart;
  60146. return function invoke(method, arg) {
  60147. if (state === GenStateExecuting) {
  60148. throw new Error("Generator is already running");
  60149. }
  60150. if (state === GenStateCompleted) {
  60151. if (method === "throw") {
  60152. throw arg;
  60153. } // Be forgiving, per 25.3.3.3.3 of the spec:
  60154. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  60155. return doneResult();
  60156. }
  60157. context.method = method;
  60158. context.arg = arg;
  60159. while (true) {
  60160. var delegate = context.delegate;
  60161. if (delegate) {
  60162. var delegateResult = maybeInvokeDelegate(delegate, context);
  60163. if (delegateResult) {
  60164. if (delegateResult === ContinueSentinel) continue;
  60165. return delegateResult;
  60166. }
  60167. }
  60168. if (context.method === "next") {
  60169. // Setting context._sent for legacy support of Babel's
  60170. // function.sent implementation.
  60171. context.sent = context._sent = context.arg;
  60172. } else if (context.method === "throw") {
  60173. if (state === GenStateSuspendedStart) {
  60174. state = GenStateCompleted;
  60175. throw context.arg;
  60176. }
  60177. context.dispatchException(context.arg);
  60178. } else if (context.method === "return") {
  60179. context.abrupt("return", context.arg);
  60180. }
  60181. state = GenStateExecuting;
  60182. var record = tryCatch(innerFn, self, context);
  60183. if (record.type === "normal") {
  60184. // If an exception is thrown from innerFn, we leave state ===
  60185. // GenStateExecuting and loop back for another invocation.
  60186. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  60187. if (record.arg === ContinueSentinel) {
  60188. continue;
  60189. }
  60190. return {
  60191. value: record.arg,
  60192. done: context.done
  60193. };
  60194. } else if (record.type === "throw") {
  60195. state = GenStateCompleted; // Dispatch the exception by looping back around to the
  60196. // context.dispatchException(context.arg) call above.
  60197. context.method = "throw";
  60198. context.arg = record.arg;
  60199. }
  60200. }
  60201. };
  60202. } // Call delegate.iterator[context.method](context.arg) and handle the
  60203. // result, either by returning a { value, done } result from the
  60204. // delegate iterator, or by modifying context.method and context.arg,
  60205. // setting context.delegate to null, and returning the ContinueSentinel.
  60206. function maybeInvokeDelegate(delegate, context) {
  60207. var method = delegate.iterator[context.method];
  60208. if (method === undefined) {
  60209. // A .throw or .return when the delegate iterator has no .throw
  60210. // method always terminates the yield* loop.
  60211. context.delegate = null;
  60212. if (context.method === "throw") {
  60213. // Note: ["return"] must be used for ES3 parsing compatibility.
  60214. if (delegate.iterator["return"]) {
  60215. // If the delegate iterator has a return method, give it a
  60216. // chance to clean up.
  60217. context.method = "return";
  60218. context.arg = undefined;
  60219. maybeInvokeDelegate(delegate, context);
  60220. if (context.method === "throw") {
  60221. // If maybeInvokeDelegate(context) changed context.method from
  60222. // "return" to "throw", let that override the TypeError below.
  60223. return ContinueSentinel;
  60224. }
  60225. }
  60226. context.method = "throw";
  60227. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  60228. }
  60229. return ContinueSentinel;
  60230. }
  60231. var record = tryCatch(method, delegate.iterator, context.arg);
  60232. if (record.type === "throw") {
  60233. context.method = "throw";
  60234. context.arg = record.arg;
  60235. context.delegate = null;
  60236. return ContinueSentinel;
  60237. }
  60238. var info = record.arg;
  60239. if (!info) {
  60240. context.method = "throw";
  60241. context.arg = new TypeError("iterator result is not an object");
  60242. context.delegate = null;
  60243. return ContinueSentinel;
  60244. }
  60245. if (info.done) {
  60246. // Assign the result of the finished delegate to the temporary
  60247. // variable specified by delegate.resultName (see delegateYield).
  60248. context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
  60249. context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
  60250. // exception, let the outer generator proceed normally. If
  60251. // context.method was "next", forget context.arg since it has been
  60252. // "consumed" by the delegate iterator. If context.method was
  60253. // "return", allow the original .return call to continue in the
  60254. // outer generator.
  60255. if (context.method !== "return") {
  60256. context.method = "next";
  60257. context.arg = undefined;
  60258. }
  60259. } else {
  60260. // Re-yield the result returned by the delegate method.
  60261. return info;
  60262. } // The delegate iterator is finished, so forget it and continue with
  60263. // the outer generator.
  60264. context.delegate = null;
  60265. return ContinueSentinel;
  60266. } // Define Generator.prototype.{next,throw,return} in terms of the
  60267. // unified ._invoke helper method.
  60268. defineIteratorMethods(Gp);
  60269. define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
  60270. // @@iterator function is called on it. Some browsers' implementations of the
  60271. // iterator prototype chain incorrectly implement this, causing the Generator
  60272. // object to not be returned from this call. This ensures that doesn't happen.
  60273. // See https://github.com/facebook/regenerator/issues/274 for more details.
  60274. Gp[iteratorSymbol] = function () {
  60275. return this;
  60276. };
  60277. Gp.toString = function () {
  60278. return "[object Generator]";
  60279. };
  60280. function pushTryEntry(locs) {
  60281. var entry = {
  60282. tryLoc: locs[0]
  60283. };
  60284. if (1 in locs) {
  60285. entry.catchLoc = locs[1];
  60286. }
  60287. if (2 in locs) {
  60288. entry.finallyLoc = locs[2];
  60289. entry.afterLoc = locs[3];
  60290. }
  60291. this.tryEntries.push(entry);
  60292. }
  60293. function resetTryEntry(entry) {
  60294. var record = entry.completion || {};
  60295. record.type = "normal";
  60296. delete record.arg;
  60297. entry.completion = record;
  60298. }
  60299. function Context(tryLocsList) {
  60300. // The root entry object (effectively a try statement without a catch
  60301. // or a finally block) gives us a place to store values thrown from
  60302. // locations where there is no enclosing try statement.
  60303. this.tryEntries = [{
  60304. tryLoc: "root"
  60305. }];
  60306. tryLocsList.forEach(pushTryEntry, this);
  60307. this.reset(true);
  60308. }
  60309. exports.keys = function (object) {
  60310. var keys = [];
  60311. for (var key in object) {
  60312. keys.push(key);
  60313. }
  60314. keys.reverse(); // Rather than returning an object with a next method, we keep
  60315. // things simple and return the next function itself.
  60316. return function next() {
  60317. while (keys.length) {
  60318. var key = keys.pop();
  60319. if (key in object) {
  60320. next.value = key;
  60321. next.done = false;
  60322. return next;
  60323. }
  60324. } // To avoid creating an additional object, we just hang the .value
  60325. // and .done properties off the next function object itself. This
  60326. // also ensures that the minifier will not anonymize the function.
  60327. next.done = true;
  60328. return next;
  60329. };
  60330. };
  60331. function values(iterable) {
  60332. if (iterable) {
  60333. var iteratorMethod = iterable[iteratorSymbol];
  60334. if (iteratorMethod) {
  60335. return iteratorMethod.call(iterable);
  60336. }
  60337. if (typeof iterable.next === "function") {
  60338. return iterable;
  60339. }
  60340. if (!isNaN(iterable.length)) {
  60341. var i = -1,
  60342. next = function next() {
  60343. while (++i < iterable.length) {
  60344. if (hasOwn.call(iterable, i)) {
  60345. next.value = iterable[i];
  60346. next.done = false;
  60347. return next;
  60348. }
  60349. }
  60350. next.value = undefined;
  60351. next.done = true;
  60352. return next;
  60353. };
  60354. return next.next = next;
  60355. }
  60356. } // Return an iterator with no values.
  60357. return {
  60358. next: doneResult
  60359. };
  60360. }
  60361. exports.values = values;
  60362. function doneResult() {
  60363. return {
  60364. value: undefined,
  60365. done: true
  60366. };
  60367. }
  60368. Context.prototype = {
  60369. constructor: Context,
  60370. reset: function reset(skipTempReset) {
  60371. this.prev = 0;
  60372. this.next = 0; // Resetting context._sent for legacy support of Babel's
  60373. // function.sent implementation.
  60374. this.sent = this._sent = undefined;
  60375. this.done = false;
  60376. this.delegate = null;
  60377. this.method = "next";
  60378. this.arg = undefined;
  60379. this.tryEntries.forEach(resetTryEntry);
  60380. if (!skipTempReset) {
  60381. for (var name in this) {
  60382. // Not sure about the optimal order of these conditions:
  60383. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  60384. this[name] = undefined;
  60385. }
  60386. }
  60387. }
  60388. },
  60389. stop: function stop() {
  60390. this.done = true;
  60391. var rootEntry = this.tryEntries[0];
  60392. var rootRecord = rootEntry.completion;
  60393. if (rootRecord.type === "throw") {
  60394. throw rootRecord.arg;
  60395. }
  60396. return this.rval;
  60397. },
  60398. dispatchException: function dispatchException(exception) {
  60399. if (this.done) {
  60400. throw exception;
  60401. }
  60402. var context = this;
  60403. function handle(loc, caught) {
  60404. record.type = "throw";
  60405. record.arg = exception;
  60406. context.next = loc;
  60407. if (caught) {
  60408. // If the dispatched exception was caught by a catch block,
  60409. // then let that catch block handle the exception normally.
  60410. context.method = "next";
  60411. context.arg = undefined;
  60412. }
  60413. return !!caught;
  60414. }
  60415. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  60416. var entry = this.tryEntries[i];
  60417. var record = entry.completion;
  60418. if (entry.tryLoc === "root") {
  60419. // Exception thrown outside of any try block that could handle
  60420. // it, so set the completion value of the entire function to
  60421. // throw the exception.
  60422. return handle("end");
  60423. }
  60424. if (entry.tryLoc <= this.prev) {
  60425. var hasCatch = hasOwn.call(entry, "catchLoc");
  60426. var hasFinally = hasOwn.call(entry, "finallyLoc");
  60427. if (hasCatch && hasFinally) {
  60428. if (this.prev < entry.catchLoc) {
  60429. return handle(entry.catchLoc, true);
  60430. } else if (this.prev < entry.finallyLoc) {
  60431. return handle(entry.finallyLoc);
  60432. }
  60433. } else if (hasCatch) {
  60434. if (this.prev < entry.catchLoc) {
  60435. return handle(entry.catchLoc, true);
  60436. }
  60437. } else if (hasFinally) {
  60438. if (this.prev < entry.finallyLoc) {
  60439. return handle(entry.finallyLoc);
  60440. }
  60441. } else {
  60442. throw new Error("try statement without catch or finally");
  60443. }
  60444. }
  60445. }
  60446. },
  60447. abrupt: function abrupt(type, arg) {
  60448. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  60449. var entry = this.tryEntries[i];
  60450. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  60451. var finallyEntry = entry;
  60452. break;
  60453. }
  60454. }
  60455. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  60456. // Ignore the finally entry if control is not jumping to a
  60457. // location outside the try/catch block.
  60458. finallyEntry = null;
  60459. }
  60460. var record = finallyEntry ? finallyEntry.completion : {};
  60461. record.type = type;
  60462. record.arg = arg;
  60463. if (finallyEntry) {
  60464. this.method = "next";
  60465. this.next = finallyEntry.finallyLoc;
  60466. return ContinueSentinel;
  60467. }
  60468. return this.complete(record);
  60469. },
  60470. complete: function complete(record, afterLoc) {
  60471. if (record.type === "throw") {
  60472. throw record.arg;
  60473. }
  60474. if (record.type === "break" || record.type === "continue") {
  60475. this.next = record.arg;
  60476. } else if (record.type === "return") {
  60477. this.rval = this.arg = record.arg;
  60478. this.method = "return";
  60479. this.next = "end";
  60480. } else if (record.type === "normal" && afterLoc) {
  60481. this.next = afterLoc;
  60482. }
  60483. return ContinueSentinel;
  60484. },
  60485. finish: function finish(finallyLoc) {
  60486. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  60487. var entry = this.tryEntries[i];
  60488. if (entry.finallyLoc === finallyLoc) {
  60489. this.complete(entry.completion, entry.afterLoc);
  60490. resetTryEntry(entry);
  60491. return ContinueSentinel;
  60492. }
  60493. }
  60494. },
  60495. "catch": function _catch(tryLoc) {
  60496. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  60497. var entry = this.tryEntries[i];
  60498. if (entry.tryLoc === tryLoc) {
  60499. var record = entry.completion;
  60500. if (record.type === "throw") {
  60501. var thrown = record.arg;
  60502. resetTryEntry(entry);
  60503. }
  60504. return thrown;
  60505. }
  60506. } // The context.catch method must only be called with a location
  60507. // argument that corresponds to a known catch block.
  60508. throw new Error("illegal catch attempt");
  60509. },
  60510. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  60511. this.delegate = {
  60512. iterator: values(iterable),
  60513. resultName: resultName,
  60514. nextLoc: nextLoc
  60515. };
  60516. if (this.method === "next") {
  60517. // Deliberately forget the last sent value so that we don't
  60518. // accidentally pass it on to the delegate.
  60519. this.arg = undefined;
  60520. }
  60521. return ContinueSentinel;
  60522. }
  60523. }; // Regardless of whether this script is executing as a CommonJS module
  60524. // or not, return the runtime object so that we can declare the variable
  60525. // regeneratorRuntime in the outer scope, which allows this module to be
  60526. // injected easily by `bin/regenerator --include-runtime script.js`.
  60527. return exports;
  60528. }( // If this script is executing as a CommonJS module, use module.exports
  60529. // as the regeneratorRuntime namespace. Otherwise create a new empty
  60530. // object. Either way, the resulting object will be used to initialize
  60531. // the regeneratorRuntime variable at the top of this file.
  60532. (typeof module === "undefined" ? "undefined" : _typeof(module)) === "object" ? module.exports : {});
  60533. try {
  60534. regeneratorRuntime = runtime;
  60535. } catch (accidentalStrictMode) {
  60536. // This module should not be running in strict mode, so the above
  60537. // assignment should always work unless something is misconfigured. Just
  60538. // in case runtime.js accidentally runs in strict mode, we can escape
  60539. // strict mode using a global Function call. This could conceivably fail
  60540. // if a Content Security Policy forbids using Function, but in that case
  60541. // the proper solution is to fix the accidental strict mode problem. If
  60542. // you've misconfigured your bundler to force strict mode and applied a
  60543. // CSP to forbid Function, and you're not willing to fix either of those
  60544. // problems, please detail your unique predicament in a GitHub issue.
  60545. Function("r", "regeneratorRuntime = r")(runtime);
  60546. }
  60547. }, {}], 493: [function (require, module, exports) {
  60548. 'use strict';
  60549. var Buffer = require('buffer').Buffer;
  60550. var inherits = require('inherits');
  60551. var HashBase = require('hash-base');
  60552. var ARRAY16 = new Array(16);
  60553. var zl = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
  60554. var zr = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
  60555. var sl = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6];
  60556. var sr = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11];
  60557. var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e];
  60558. var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000];
  60559. function RIPEMD160() {
  60560. HashBase.call(this, 64); // state
  60561. this._a = 0x67452301;
  60562. this._b = 0xefcdab89;
  60563. this._c = 0x98badcfe;
  60564. this._d = 0x10325476;
  60565. this._e = 0xc3d2e1f0;
  60566. }
  60567. inherits(RIPEMD160, HashBase);
  60568. RIPEMD160.prototype._update = function () {
  60569. var words = ARRAY16;
  60570. for (var j = 0; j < 16; ++j) {
  60571. words[j] = this._block.readInt32LE(j * 4);
  60572. }
  60573. var al = this._a | 0;
  60574. var bl = this._b | 0;
  60575. var cl = this._c | 0;
  60576. var dl = this._d | 0;
  60577. var el = this._e | 0;
  60578. var ar = this._a | 0;
  60579. var br = this._b | 0;
  60580. var cr = this._c | 0;
  60581. var dr = this._d | 0;
  60582. var er = this._e | 0; // computation
  60583. for (var i = 0; i < 80; i += 1) {
  60584. var tl;
  60585. var tr;
  60586. if (i < 16) {
  60587. tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i]);
  60588. tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i]);
  60589. } else if (i < 32) {
  60590. tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i]);
  60591. tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i]);
  60592. } else if (i < 48) {
  60593. tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i]);
  60594. tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i]);
  60595. } else if (i < 64) {
  60596. tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i]);
  60597. tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i]);
  60598. } else {
  60599. // if (i<80) {
  60600. tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i]);
  60601. tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i]);
  60602. }
  60603. al = el;
  60604. el = dl;
  60605. dl = rotl(cl, 10);
  60606. cl = bl;
  60607. bl = tl;
  60608. ar = er;
  60609. er = dr;
  60610. dr = rotl(cr, 10);
  60611. cr = br;
  60612. br = tr;
  60613. } // update state
  60614. var t = this._b + cl + dr | 0;
  60615. this._b = this._c + dl + er | 0;
  60616. this._c = this._d + el + ar | 0;
  60617. this._d = this._e + al + br | 0;
  60618. this._e = this._a + bl + cr | 0;
  60619. this._a = t;
  60620. };
  60621. RIPEMD160.prototype._digest = function () {
  60622. // create padding and handle blocks
  60623. this._block[this._blockOffset++] = 0x80;
  60624. if (this._blockOffset > 56) {
  60625. this._block.fill(0, this._blockOffset, 64);
  60626. this._update();
  60627. this._blockOffset = 0;
  60628. }
  60629. this._block.fill(0, this._blockOffset, 56);
  60630. this._block.writeUInt32LE(this._length[0], 56);
  60631. this._block.writeUInt32LE(this._length[1], 60);
  60632. this._update(); // produce result
  60633. var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20);
  60634. buffer.writeInt32LE(this._a, 0);
  60635. buffer.writeInt32LE(this._b, 4);
  60636. buffer.writeInt32LE(this._c, 8);
  60637. buffer.writeInt32LE(this._d, 12);
  60638. buffer.writeInt32LE(this._e, 16);
  60639. return buffer;
  60640. };
  60641. function rotl(x, n) {
  60642. return x << n | x >>> 32 - n;
  60643. }
  60644. function fn1(a, b, c, d, e, m, k, s) {
  60645. return rotl(a + (b ^ c ^ d) + m + k | 0, s) + e | 0;
  60646. }
  60647. function fn2(a, b, c, d, e, m, k, s) {
  60648. return rotl(a + (b & c | ~b & d) + m + k | 0, s) + e | 0;
  60649. }
  60650. function fn3(a, b, c, d, e, m, k, s) {
  60651. return rotl(a + ((b | ~c) ^ d) + m + k | 0, s) + e | 0;
  60652. }
  60653. function fn4(a, b, c, d, e, m, k, s) {
  60654. return rotl(a + (b & d | c & ~d) + m + k | 0, s) + e | 0;
  60655. }
  60656. function fn5(a, b, c, d, e, m, k, s) {
  60657. return rotl(a + (b ^ (c | ~d)) + m + k | 0, s) + e | 0;
  60658. }
  60659. module.exports = RIPEMD160;
  60660. }, { "buffer": 216, "hash-base": 370, "inherits": 387 }], 494: [function (require, module, exports) {
  60661. "use strict";
  60662. /* eslint-disable node/no-deprecated-api */
  60663. var buffer = require('buffer');
  60664. var Buffer = buffer.Buffer; // alternative to using Object.keys for old browsers
  60665. function copyProps(src, dst) {
  60666. for (var key in src) {
  60667. dst[key] = src[key];
  60668. }
  60669. }
  60670. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  60671. module.exports = buffer;
  60672. } else {
  60673. // Copy properties from require('buffer')
  60674. copyProps(buffer, exports);
  60675. exports.Buffer = SafeBuffer;
  60676. }
  60677. function SafeBuffer(arg, encodingOrOffset, length) {
  60678. return Buffer(arg, encodingOrOffset, length);
  60679. } // Copy static methods from Buffer
  60680. copyProps(Buffer, SafeBuffer);
  60681. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  60682. if (typeof arg === 'number') {
  60683. throw new TypeError('Argument must not be a number');
  60684. }
  60685. return Buffer(arg, encodingOrOffset, length);
  60686. };
  60687. SafeBuffer.alloc = function (size, fill, encoding) {
  60688. if (typeof size !== 'number') {
  60689. throw new TypeError('Argument must be a number');
  60690. }
  60691. var buf = Buffer(size);
  60692. if (fill !== undefined) {
  60693. if (typeof encoding === 'string') {
  60694. buf.fill(fill, encoding);
  60695. } else {
  60696. buf.fill(fill);
  60697. }
  60698. } else {
  60699. buf.fill(0);
  60700. }
  60701. return buf;
  60702. };
  60703. SafeBuffer.allocUnsafe = function (size) {
  60704. if (typeof size !== 'number') {
  60705. throw new TypeError('Argument must be a number');
  60706. }
  60707. return Buffer(size);
  60708. };
  60709. SafeBuffer.allocUnsafeSlow = function (size) {
  60710. if (typeof size !== 'number') {
  60711. throw new TypeError('Argument must be a number');
  60712. }
  60713. return buffer.SlowBuffer(size);
  60714. };
  60715. }, { "buffer": 216 }], 495: [function (require, module, exports) {
  60716. (function (process) {
  60717. /* eslint-disable node/no-deprecated-api */
  60718. 'use strict';
  60719. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  60720. var buffer = require('buffer');
  60721. var Buffer = buffer.Buffer;
  60722. var safer = {};
  60723. var key;
  60724. for (key in buffer) {
  60725. if (!buffer.hasOwnProperty(key)) continue;
  60726. if (key === 'SlowBuffer' || key === 'Buffer') continue;
  60727. safer[key] = buffer[key];
  60728. }
  60729. var Safer = safer.Buffer = {};
  60730. for (key in Buffer) {
  60731. if (!Buffer.hasOwnProperty(key)) continue;
  60732. if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue;
  60733. Safer[key] = Buffer[key];
  60734. }
  60735. safer.Buffer.prototype = Buffer.prototype;
  60736. if (!Safer.from || Safer.from === Uint8Array.from) {
  60737. Safer.from = function (value, encodingOrOffset, length) {
  60738. if (typeof value === 'number') {
  60739. throw new TypeError('The "value" argument must not be of type number. Received type ' + _typeof(value));
  60740. }
  60741. if (value && typeof value.length === 'undefined') {
  60742. throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + _typeof(value));
  60743. }
  60744. return Buffer(value, encodingOrOffset, length);
  60745. };
  60746. }
  60747. if (!Safer.alloc) {
  60748. Safer.alloc = function (size, fill, encoding) {
  60749. if (typeof size !== 'number') {
  60750. throw new TypeError('The "size" argument must be of type number. Received type ' + _typeof(size));
  60751. }
  60752. if (size < 0 || size >= 2 * (1 << 30)) {
  60753. throw new RangeError('The value "' + size + '" is invalid for option "size"');
  60754. }
  60755. var buf = Buffer(size);
  60756. if (!fill || fill.length === 0) {
  60757. buf.fill(0);
  60758. } else if (typeof encoding === 'string') {
  60759. buf.fill(fill, encoding);
  60760. } else {
  60761. buf.fill(fill);
  60762. }
  60763. return buf;
  60764. };
  60765. }
  60766. if (!safer.kStringMaxLength) {
  60767. try {
  60768. safer.kStringMaxLength = process.binding('buffer').kStringMaxLength;
  60769. } catch (e) {// we can't determine kStringMaxLength in environments where process.binding
  60770. // is unsupported, so let's not set it
  60771. }
  60772. }
  60773. if (!safer.constants) {
  60774. safer.constants = {
  60775. MAX_LENGTH: safer.kMaxLength
  60776. };
  60777. if (safer.kStringMaxLength) {
  60778. safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength;
  60779. }
  60780. }
  60781. module.exports = safer;
  60782. }).call(this, require('_process'))
  60783. }, { "_process": 467, "buffer": 216 }], 496: [function (require, module, exports) {
  60784. "use strict";
  60785. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() { }; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  60786. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  60787. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  60788. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  60789. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  60790. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  60791. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  60792. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  60793. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  60794. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  60795. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  60796. Object.defineProperty(exports, "__esModule", {
  60797. value: true
  60798. });
  60799. var ed5 = require("xmlchars/xml/1.0/ed5");
  60800. var ed2 = require("xmlchars/xml/1.1/ed2");
  60801. var NSed3 = require("xmlchars/xmlns/1.0/ed3");
  60802. var isS = ed5.isS;
  60803. var isChar10 = ed5.isChar;
  60804. var isNameStartChar = ed5.isNameStartChar;
  60805. var isNameChar = ed5.isNameChar;
  60806. var S_LIST = ed5.S_LIST;
  60807. var NAME_RE = ed5.NAME_RE;
  60808. var isChar11 = ed2.isChar;
  60809. var isNCNameStartChar = NSed3.isNCNameStartChar;
  60810. var isNCNameChar = NSed3.isNCNameChar;
  60811. var NC_NAME_RE = NSed3.NC_NAME_RE;
  60812. var XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
  60813. var XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
  60814. var rootNS = {
  60815. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  60816. __proto__: null,
  60817. xml: XML_NAMESPACE,
  60818. xmlns: XMLNS_NAMESPACE
  60819. };
  60820. var XML_ENTITIES = {
  60821. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  60822. __proto__: null,
  60823. amp: "&",
  60824. gt: ">",
  60825. lt: "<",
  60826. quot: "\"",
  60827. apos: "'"
  60828. }; // EOC: end-of-chunk
  60829. var EOC = -1;
  60830. var NL_LIKE = -2;
  60831. var S_BEGIN = 0; // Initial state.
  60832. var S_BEGIN_WHITESPACE = 1; // leading whitespace
  60833. var S_DOCTYPE = 2; // <!DOCTYPE
  60834. var S_DOCTYPE_QUOTE = 3; // <!DOCTYPE "//blah
  60835. var S_DTD = 4; // <!DOCTYPE "//blah" [ ...
  60836. var S_DTD_QUOTED = 5; // <!DOCTYPE "//blah" [ "foo
  60837. var S_DTD_OPEN_WAKA = 6;
  60838. var S_DTD_OPEN_WAKA_BANG = 7;
  60839. var S_DTD_COMMENT = 8; // <!--
  60840. var S_DTD_COMMENT_ENDING = 9; // <!-- blah -
  60841. var S_DTD_COMMENT_ENDED = 10; // <!-- blah --
  60842. var S_DTD_PI = 11; // <?
  60843. var S_DTD_PI_ENDING = 12; // <?hi "there" ?
  60844. var S_TEXT = 13; // general stuff
  60845. var S_ENTITY = 14; // &amp and such
  60846. var S_OPEN_WAKA = 15; // <
  60847. var S_OPEN_WAKA_BANG = 16; // <!...
  60848. var S_COMMENT = 17; // <!--
  60849. var S_COMMENT_ENDING = 18; // <!-- blah -
  60850. var S_COMMENT_ENDED = 19; // <!-- blah --
  60851. var S_CDATA = 20; // <![CDATA[ something
  60852. var S_CDATA_ENDING = 21; // ]
  60853. var S_CDATA_ENDING_2 = 22; // ]]
  60854. var S_PI_FIRST_CHAR = 23; // <?hi, first char
  60855. var S_PI_REST = 24; // <?hi, rest of the name
  60856. var S_PI_BODY = 25; // <?hi there
  60857. var S_PI_ENDING = 26; // <?hi "there" ?
  60858. var S_XML_DECL_NAME_START = 27; // <?xml
  60859. var S_XML_DECL_NAME = 28; // <?xml foo
  60860. var S_XML_DECL_EQ = 29; // <?xml foo=
  60861. var S_XML_DECL_VALUE_START = 30; // <?xml foo=
  60862. var S_XML_DECL_VALUE = 31; // <?xml foo="bar"
  60863. var S_XML_DECL_SEPARATOR = 32; // <?xml foo="bar"
  60864. var S_XML_DECL_ENDING = 33; // <?xml ... ?
  60865. var S_OPEN_TAG = 34; // <strong
  60866. var S_OPEN_TAG_SLASH = 35; // <strong /
  60867. var S_ATTRIB = 36; // <a
  60868. var S_ATTRIB_NAME = 37; // <a foo
  60869. var S_ATTRIB_NAME_SAW_WHITE = 38; // <a foo _
  60870. var S_ATTRIB_VALUE = 39; // <a foo=
  60871. var S_ATTRIB_VALUE_QUOTED = 40; // <a foo="bar
  60872. var S_ATTRIB_VALUE_CLOSED = 41; // <a foo="bar"
  60873. var S_ATTRIB_VALUE_UNQUOTED = 42; // <a foo=bar
  60874. var S_CLOSE_TAG = 43; // </a
  60875. var S_CLOSE_TAG_SAW_WHITE = 44; // </a >
  60876. var TAB = 9;
  60877. var NL = 0xA;
  60878. var CR = 0xD;
  60879. var SPACE = 0x20;
  60880. var BANG = 0x21;
  60881. var DQUOTE = 0x22;
  60882. var AMP = 0x26;
  60883. var SQUOTE = 0x27;
  60884. var MINUS = 0x2D;
  60885. var FORWARD_SLASH = 0x2F;
  60886. var SEMICOLON = 0x3B;
  60887. var LESS = 0x3C;
  60888. var EQUAL = 0x3D;
  60889. var GREATER = 0x3E;
  60890. var QUESTION = 0x3F;
  60891. var OPEN_BRACKET = 0x5B;
  60892. var CLOSE_BRACKET = 0x5D;
  60893. var NEL = 0x85;
  60894. var LS = 0x2028; // Line Separator
  60895. var isQuote = function isQuote(c) {
  60896. return c === DQUOTE || c === SQUOTE;
  60897. };
  60898. var QUOTES = [DQUOTE, SQUOTE];
  60899. var DOCTYPE_TERMINATOR = [].concat(QUOTES, [OPEN_BRACKET, GREATER]);
  60900. var DTD_TERMINATOR = [].concat(QUOTES, [LESS, CLOSE_BRACKET]);
  60901. var XML_DECL_NAME_TERMINATOR = [EQUAL, QUESTION].concat(_toConsumableArray(S_LIST));
  60902. var ATTRIB_VALUE_UNQUOTED_TERMINATOR = [].concat(_toConsumableArray(S_LIST), [GREATER, AMP, LESS]);
  60903. function nsPairCheck(parser, prefix, uri) {
  60904. switch (prefix) {
  60905. case "xml":
  60906. if (uri !== XML_NAMESPACE) {
  60907. parser.fail("xml prefix must be bound to ".concat(XML_NAMESPACE, "."));
  60908. }
  60909. break;
  60910. case "xmlns":
  60911. if (uri !== XMLNS_NAMESPACE) {
  60912. parser.fail("xmlns prefix must be bound to ".concat(XMLNS_NAMESPACE, "."));
  60913. }
  60914. break;
  60915. default:
  60916. }
  60917. switch (uri) {
  60918. case XMLNS_NAMESPACE:
  60919. parser.fail(prefix === "" ? "the default namespace may not be set to ".concat(uri, ".") : "may not assign a prefix (even \"xmlns\") to the URI ".concat(XMLNS_NAMESPACE, "."));
  60920. break;
  60921. case XML_NAMESPACE:
  60922. switch (prefix) {
  60923. case "xml":
  60924. // Assinging the XML namespace to "xml" is fine.
  60925. break;
  60926. case "":
  60927. parser.fail("the default namespace may not be set to ".concat(uri, "."));
  60928. break;
  60929. default:
  60930. parser.fail("may not assign the xml namespace to another prefix.");
  60931. }
  60932. break;
  60933. default:
  60934. }
  60935. }
  60936. function nsMappingCheck(parser, mapping) {
  60937. for (var _i = 0, _Object$keys = Object.keys(mapping); _i < _Object$keys.length; _i++) {
  60938. var local = _Object$keys[_i];
  60939. nsPairCheck(parser, local, mapping[local]);
  60940. }
  60941. }
  60942. var isNCName = function isNCName(name) {
  60943. return NC_NAME_RE.test(name);
  60944. };
  60945. var isName = function isName(name) {
  60946. return NAME_RE.test(name);
  60947. };
  60948. var FORBIDDEN_START = 0;
  60949. var FORBIDDEN_BRACKET = 1;
  60950. var FORBIDDEN_BRACKET_BRACKET = 2;
  60951. /**
  60952. * The list of supported events.
  60953. */
  60954. exports.EVENTS = ["xmldecl", "text", "processinginstruction", "doctype", "comment", "opentagstart", "attribute", "opentag", "closetag", "cdata", "error", "end", "ready"];
  60955. var EVENT_NAME_TO_HANDLER_NAME = {
  60956. xmldecl: "xmldeclHandler",
  60957. text: "textHandler",
  60958. processinginstruction: "piHandler",
  60959. doctype: "doctypeHandler",
  60960. comment: "commentHandler",
  60961. opentagstart: "openTagStartHandler",
  60962. attribute: "attributeHandler",
  60963. opentag: "openTagHandler",
  60964. closetag: "closeTagHandler",
  60965. cdata: "cdataHandler",
  60966. error: "errorHandler",
  60967. end: "endHandler",
  60968. ready: "readyHandler"
  60969. };
  60970. var SaxesParser = /*#__PURE__*/function () {
  60971. /**
  60972. * @param opt The parser options.
  60973. */
  60974. function SaxesParser(opt) {
  60975. _classCallCheck(this, SaxesParser);
  60976. this.opt = opt !== null && opt !== void 0 ? opt : {};
  60977. this.fragmentOpt = !!this.opt.fragment;
  60978. var xmlnsOpt = this.xmlnsOpt = !!this.opt.xmlns;
  60979. this.trackPosition = this.opt.position !== false;
  60980. this.fileName = this.opt.fileName;
  60981. if (xmlnsOpt) {
  60982. // This is the function we use to perform name checks on PIs and entities.
  60983. // When namespaces are used, colons are not allowed in PI target names or
  60984. // entity names. So the check depends on whether namespaces are used. See:
  60985. //
  60986. // https://www.w3.org/XML/xml-names-19990114-errata.html
  60987. // NE08
  60988. //
  60989. this.nameStartCheck = isNCNameStartChar;
  60990. this.nameCheck = isNCNameChar;
  60991. this.isName = isNCName; // eslint-disable-next-line @typescript-eslint/unbound-method
  60992. this.processAttribs = this.processAttribsNS; // eslint-disable-next-line @typescript-eslint/unbound-method
  60993. this.pushAttrib = this.pushAttribNS; // eslint-disable-next-line @typescript-eslint/no-explicit-any
  60994. this.ns = Object.assign({
  60995. __proto__: null
  60996. }, rootNS);
  60997. var additional = this.opt.additionalNamespaces;
  60998. if (additional != null) {
  60999. nsMappingCheck(this, additional);
  61000. Object.assign(this.ns, additional);
  61001. }
  61002. } else {
  61003. this.nameStartCheck = isNameStartChar;
  61004. this.nameCheck = isNameChar;
  61005. this.isName = isName; // eslint-disable-next-line @typescript-eslint/unbound-method
  61006. this.processAttribs = this.processAttribsPlain; // eslint-disable-next-line @typescript-eslint/unbound-method
  61007. this.pushAttrib = this.pushAttribPlain;
  61008. } //
  61009. // The order of the members in this table needs to correspond to the state
  61010. // numbers given to the states that correspond to the methods being recorded
  61011. // here.
  61012. //
  61013. this.stateTable = [
  61014. /* eslint-disable @typescript-eslint/unbound-method */
  61015. this.sBegin, this.sBeginWhitespace, this.sDoctype, this.sDoctypeQuote, this.sDTD, this.sDTDQuoted, this.sDTDOpenWaka, this.sDTDOpenWakaBang, this.sDTDComment, this.sDTDCommentEnding, this.sDTDCommentEnded, this.sDTDPI, this.sDTDPIEnding, this.sText, this.sEntity, this.sOpenWaka, this.sOpenWakaBang, this.sComment, this.sCommentEnding, this.sCommentEnded, this.sCData, this.sCDataEnding, this.sCDataEnding2, this.sPIFirstChar, this.sPIRest, this.sPIBody, this.sPIEnding, this.sXMLDeclNameStart, this.sXMLDeclName, this.sXMLDeclEq, this.sXMLDeclValueStart, this.sXMLDeclValue, this.sXMLDeclSeparator, this.sXMLDeclEnding, this.sOpenTag, this.sOpenTagSlash, this.sAttrib, this.sAttribName, this.sAttribNameSawWhite, this.sAttribValue, this.sAttribValueQuoted, this.sAttribValueClosed, this.sAttribValueUnquoted, this.sCloseTag, this.sCloseTagSawWhite];
  61016. this._init();
  61017. }
  61018. /**
  61019. * Indicates whether or not the parser is closed. If ``true``, wait for
  61020. * the ``ready`` event to write again.
  61021. */
  61022. _createClass(SaxesParser, [{
  61023. key: "_init",
  61024. value: function _init() {
  61025. var _a;
  61026. this.openWakaBang = "";
  61027. this.text = "";
  61028. this.name = "";
  61029. this.piTarget = "";
  61030. this.entity = "";
  61031. this.q = null;
  61032. this.tags = [];
  61033. this.tag = null;
  61034. this.topNS = null;
  61035. this.chunk = "";
  61036. this.chunkPosition = 0;
  61037. this.i = 0;
  61038. this.prevI = 0;
  61039. this.carriedFromPrevious = undefined;
  61040. this.forbiddenState = FORBIDDEN_START;
  61041. this.attribList = []; // The logic is organized so as to minimize the need to check
  61042. // this.opt.fragment while parsing.
  61043. var fragmentOpt = this.fragmentOpt;
  61044. this.state = fragmentOpt ? S_TEXT : S_BEGIN; // We want these to be all true if we are dealing with a fragment.
  61045. this.reportedTextBeforeRoot = this.reportedTextAfterRoot = this.closedRoot = this.sawRoot = fragmentOpt; // An XML declaration is intially possible only when parsing whole
  61046. // documents.
  61047. this.xmlDeclPossible = !fragmentOpt;
  61048. this.xmlDeclExpects = ["version"];
  61049. this.entityReturnState = undefined;
  61050. var defaultXMLVersion = this.opt.defaultXMLVersion;
  61051. if (defaultXMLVersion === undefined) {
  61052. if (this.opt.forceXMLVersion === true) {
  61053. throw new Error("forceXMLVersion set but defaultXMLVersion is not set");
  61054. }
  61055. defaultXMLVersion = "1.0";
  61056. }
  61057. this.setXMLVersion(defaultXMLVersion);
  61058. this.positionAtNewLine = 0;
  61059. this.doctype = false;
  61060. this._closed = false;
  61061. this.xmlDecl = {
  61062. version: undefined,
  61063. encoding: undefined,
  61064. standalone: undefined
  61065. };
  61066. this.line = 1;
  61067. this.column = 0;
  61068. this.ENTITIES = Object.create(XML_ENTITIES); // eslint-disable-next-line no-unused-expressions
  61069. (_a = this.readyHandler) === null || _a === void 0 ? void 0 : _a.call(this);
  61070. }
  61071. /**
  61072. * The stream position the parser is currently looking at. This field is
  61073. * zero-based.
  61074. *
  61075. * This field is not based on counting Unicode characters but is to be
  61076. * interpreted as a plain index into a JavaScript string.
  61077. */
  61078. }, {
  61079. key: "on",
  61080. /**
  61081. * Set an event listener on an event. The parser supports one handler per
  61082. * event type. If you try to set an event handler over an existing handler,
  61083. * the old handler is silently overwritten.
  61084. *
  61085. * @param name The event to listen to.
  61086. *
  61087. * @param handler The handler to set.
  61088. */
  61089. value: function on(name, handler) {
  61090. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  61091. this[EVENT_NAME_TO_HANDLER_NAME[name]] = handler;
  61092. }
  61093. /**
  61094. * Unset an event handler.
  61095. *
  61096. * @parma name The event to stop listening to.
  61097. */
  61098. }, {
  61099. key: "off",
  61100. value: function off(name) {
  61101. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  61102. this[EVENT_NAME_TO_HANDLER_NAME[name]] = undefined;
  61103. }
  61104. /**
  61105. * Make an error object. The error object will have a message that contains
  61106. * the ``fileName`` option passed at the creation of the parser. If position
  61107. * tracking was turned on, it will also have line and column number
  61108. * information.
  61109. *
  61110. * @param message The message describing the error to report.
  61111. *
  61112. * @returns An error object with a properly formatted message.
  61113. */
  61114. }, {
  61115. key: "makeError",
  61116. value: function makeError(message) {
  61117. var _a;
  61118. var msg = (_a = this.fileName) !== null && _a !== void 0 ? _a : "";
  61119. if (this.trackPosition) {
  61120. if (msg.length > 0) {
  61121. msg += ":";
  61122. }
  61123. msg += "".concat(this.line, ":").concat(this.column);
  61124. }
  61125. if (msg.length > 0) {
  61126. msg += ": ";
  61127. }
  61128. return new Error(msg + message);
  61129. }
  61130. /**
  61131. * Report a parsing error. This method is made public so that client code may
  61132. * check for issues that are outside the scope of this project and can report
  61133. * errors.
  61134. *
  61135. * @param message The error to report.
  61136. *
  61137. * @returns this
  61138. */
  61139. }, {
  61140. key: "fail",
  61141. value: function fail(message) {
  61142. var err = this.makeError(message);
  61143. var handler = this.errorHandler;
  61144. if (handler === undefined) {
  61145. throw err;
  61146. } else {
  61147. handler(err);
  61148. }
  61149. return this;
  61150. }
  61151. /**
  61152. * Write a XML data to the parser.
  61153. *
  61154. * @param chunk The XML data to write.
  61155. *
  61156. * @returns this
  61157. */
  61158. }, {
  61159. key: "write",
  61160. value: function write(chunk) {
  61161. if (this.closed) {
  61162. return this.fail("cannot write after close; assign an onready handler.");
  61163. }
  61164. var end = false;
  61165. if (chunk === null) {
  61166. // We cannot return immediately because carriedFromPrevious may need
  61167. // processing.
  61168. end = true;
  61169. chunk = "";
  61170. } else if (_typeof(chunk) === "object") {
  61171. chunk = chunk.toString();
  61172. } // We checked if performing a pre-decomposition of the string into an array
  61173. // of single complete characters (``Array.from(chunk)``) would be faster
  61174. // than the current repeated calls to ``charCodeAt``. As of August 2018, it
  61175. // isn't. (There may be Node-specific code that would perform faster than
  61176. // ``Array.from`` but don't want to be dependent on Node.)
  61177. if (this.carriedFromPrevious !== undefined) {
  61178. // The previous chunk had char we must carry over.
  61179. chunk = "".concat(this.carriedFromPrevious).concat(chunk);
  61180. this.carriedFromPrevious = undefined;
  61181. }
  61182. var limit = chunk.length;
  61183. var lastCode = chunk.charCodeAt(limit - 1);
  61184. if (!end && ( // A trailing CR or surrogate must be carried over to the next
  61185. // chunk.
  61186. lastCode === CR || lastCode >= 0xD800 && lastCode <= 0xDBFF)) {
  61187. // The chunk ends with a character that must be carried over. We cannot
  61188. // know how to handle it until we get the next chunk or the end of the
  61189. // stream. So save it for later.
  61190. this.carriedFromPrevious = chunk[limit - 1];
  61191. limit--;
  61192. chunk = chunk.slice(0, limit);
  61193. }
  61194. var stateTable = this.stateTable;
  61195. this.chunk = chunk;
  61196. this.i = 0;
  61197. while (this.i < limit) {
  61198. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  61199. stateTable[this.state].call(this);
  61200. }
  61201. this.chunkPosition += limit;
  61202. return end ? this.end() : this;
  61203. }
  61204. /**
  61205. * Close the current stream. Perform final well-formedness checks and reset
  61206. * the parser tstate.
  61207. *
  61208. * @returns this
  61209. */
  61210. }, {
  61211. key: "close",
  61212. value: function close() {
  61213. return this.write(null);
  61214. }
  61215. /**
  61216. * Get a single code point out of the current chunk. This updates the current
  61217. * position if we do position tracking.
  61218. *
  61219. * This is the algorithm to use for XML 1.0.
  61220. *
  61221. * @returns The character read.
  61222. */
  61223. }, {
  61224. key: "getCode10",
  61225. value: function getCode10() {
  61226. var chunk = this.chunk,
  61227. i = this.i;
  61228. this.prevI = i; // Yes, we do this instead of doing this.i++. Doing it this way, we do not
  61229. // read this.i again, which is a bit faster.
  61230. this.i = i + 1;
  61231. if (i >= chunk.length) {
  61232. return EOC;
  61233. } // Using charCodeAt and handling the surrogates ourselves is faster
  61234. // than using codePointAt.
  61235. var code = chunk.charCodeAt(i);
  61236. this.column++;
  61237. if (code < 0xD800) {
  61238. if (code >= SPACE || code === TAB) {
  61239. return code;
  61240. }
  61241. switch (code) {
  61242. case NL:
  61243. this.line++;
  61244. this.column = 0;
  61245. this.positionAtNewLine = this.position;
  61246. return NL;
  61247. case CR:
  61248. // We may get NaN if we read past the end of the chunk, which is fine.
  61249. if (chunk.charCodeAt(i + 1) === NL) {
  61250. // A \r\n sequence is converted to \n so we have to skip over the
  61251. // next character. We already know it has a size of 1 so ++ is fine
  61252. // here.
  61253. this.i = i + 2;
  61254. } // Otherwise, a \r is just converted to \n, so we don't have to skip
  61255. // ahead.
  61256. // In either case, \r becomes \n.
  61257. this.line++;
  61258. this.column = 0;
  61259. this.positionAtNewLine = this.position;
  61260. return NL_LIKE;
  61261. default:
  61262. // If we get here, then code < SPACE and it is not NL CR or TAB.
  61263. this.fail("disallowed character.");
  61264. return code;
  61265. }
  61266. }
  61267. if (code > 0xDBFF) {
  61268. // This is a specialized version of isChar10 that takes into account
  61269. // that in this context code > 0xDBFF and code <= 0xFFFF. So it does not
  61270. // test cases that don't need testing.
  61271. if (!(code >= 0xE000 && code <= 0xFFFD)) {
  61272. this.fail("disallowed character.");
  61273. }
  61274. return code;
  61275. }
  61276. var final = 0x10000 + (code - 0xD800) * 0x400 + (chunk.charCodeAt(i + 1) - 0xDC00);
  61277. this.i = i + 2; // This is a specialized version of isChar10 that takes into account that in
  61278. // this context necessarily final >= 0x10000.
  61279. if (final > 0x10FFFF) {
  61280. this.fail("disallowed character.");
  61281. }
  61282. return final;
  61283. }
  61284. /**
  61285. * Get a single code point out of the current chunk. This updates the current
  61286. * position if we do position tracking.
  61287. *
  61288. * This is the algorithm to use for XML 1.1.
  61289. *
  61290. * @returns {number} The character read.
  61291. */
  61292. }, {
  61293. key: "getCode11",
  61294. value: function getCode11() {
  61295. var chunk = this.chunk,
  61296. i = this.i;
  61297. this.prevI = i; // Yes, we do this instead of doing this.i++. Doing it this way, we do not
  61298. // read this.i again, which is a bit faster.
  61299. this.i = i + 1;
  61300. if (i >= chunk.length) {
  61301. return EOC;
  61302. } // Using charCodeAt and handling the surrogates ourselves is faster
  61303. // than using codePointAt.
  61304. var code = chunk.charCodeAt(i);
  61305. this.column++;
  61306. if (code < 0xD800) {
  61307. if (code > 0x1F && code < 0x7F || code > 0x9F && code !== LS || code === TAB) {
  61308. return code;
  61309. }
  61310. switch (code) {
  61311. case NL:
  61312. // 0xA
  61313. this.line++;
  61314. this.column = 0;
  61315. this.positionAtNewLine = this.position;
  61316. return NL;
  61317. case CR:
  61318. {
  61319. // 0xD
  61320. // We may get NaN if we read past the end of the chunk, which is
  61321. // fine.
  61322. var next = chunk.charCodeAt(i + 1);
  61323. if (next === NL || next === NEL) {
  61324. // A CR NL or CR NEL sequence is converted to NL so we have to skip
  61325. // over the next character. We already know it has a size of 1.
  61326. this.i = i + 2;
  61327. } // Otherwise, a CR is just converted to NL, no skip.
  61328. }
  61329. /* yes, fall through */
  61330. case NEL: // 0x85
  61331. case LS:
  61332. // Ox2028
  61333. this.line++;
  61334. this.column = 0;
  61335. this.positionAtNewLine = this.position;
  61336. return NL_LIKE;
  61337. default:
  61338. this.fail("disallowed character.");
  61339. return code;
  61340. }
  61341. }
  61342. if (code > 0xDBFF) {
  61343. // This is a specialized version of isCharAndNotRestricted that takes into
  61344. // account that in this context code > 0xDBFF and code <= 0xFFFF. So it
  61345. // does not test cases that don't need testing.
  61346. if (!(code >= 0xE000 && code <= 0xFFFD)) {
  61347. this.fail("disallowed character.");
  61348. }
  61349. return code;
  61350. }
  61351. var final = 0x10000 + (code - 0xD800) * 0x400 + (chunk.charCodeAt(i + 1) - 0xDC00);
  61352. this.i = i + 2; // This is a specialized version of isCharAndNotRestricted that takes into
  61353. // account that in this context necessarily final >= 0x10000.
  61354. if (final > 0x10FFFF) {
  61355. this.fail("disallowed character.");
  61356. }
  61357. return final;
  61358. }
  61359. /**
  61360. * Like ``getCode`` but with the return value normalized so that ``NL`` is
  61361. * returned for ``NL_LIKE``.
  61362. */
  61363. }, {
  61364. key: "getCodeNorm",
  61365. value: function getCodeNorm() {
  61366. var c = this.getCode();
  61367. return c === NL_LIKE ? NL : c;
  61368. }
  61369. }, {
  61370. key: "unget",
  61371. value: function unget() {
  61372. this.i = this.prevI;
  61373. this.column--;
  61374. }
  61375. /**
  61376. * Capture characters into a buffer until encountering one of a set of
  61377. * characters.
  61378. *
  61379. * @param chars An array of codepoints. Encountering a character in the array
  61380. * ends the capture. (``chars`` may safely contain ``NL``.)
  61381. *
  61382. * @return The character code that made the capture end, or ``EOC`` if we hit
  61383. * the end of the chunk. The return value cannot be NL_LIKE: NL is returned
  61384. * instead.
  61385. */
  61386. }, {
  61387. key: "captureTo",
  61388. value: function captureTo(chars) {
  61389. var start = this.i;
  61390. var chunk = this.chunk; // eslint-disable-next-line no-constant-condition
  61391. while (true) {
  61392. var c = this.getCode();
  61393. var isNLLike = c === NL_LIKE;
  61394. var final = isNLLike ? NL : c;
  61395. if (final === EOC || chars.includes(final)) {
  61396. this.text += chunk.slice(start, this.prevI);
  61397. return final;
  61398. }
  61399. if (isNLLike) {
  61400. this.text += "".concat(chunk.slice(start, this.prevI), "\n");
  61401. start = this.i;
  61402. }
  61403. }
  61404. }
  61405. /**
  61406. * Capture characters into a buffer until encountering a character.
  61407. *
  61408. * @param char The codepoint that ends the capture. **NOTE ``char`` MAY NOT
  61409. * CONTAIN ``NL``.** Passing ``NL`` will result in buggy behavior.
  61410. *
  61411. * @return ``true`` if we ran into the character. Otherwise, we ran into the
  61412. * end of the current chunk.
  61413. */
  61414. }, {
  61415. key: "captureToChar",
  61416. value: function captureToChar(char) {
  61417. var start = this.i;
  61418. var chunk = this.chunk; // eslint-disable-next-line no-constant-condition
  61419. while (true) {
  61420. var c = this.getCode();
  61421. switch (c) {
  61422. case NL_LIKE:
  61423. this.text += "".concat(chunk.slice(start, this.prevI), "\n");
  61424. start = this.i;
  61425. c = NL;
  61426. break;
  61427. case EOC:
  61428. this.text += chunk.slice(start);
  61429. return false;
  61430. default:
  61431. }
  61432. if (c === char) {
  61433. this.text += chunk.slice(start, this.prevI);
  61434. return true;
  61435. }
  61436. }
  61437. }
  61438. /**
  61439. * Capture characters that satisfy ``isNameChar`` into the ``name`` field of
  61440. * this parser.
  61441. *
  61442. * @return The character code that made the test fail, or ``EOC`` if we hit
  61443. * the end of the chunk. The return value cannot be NL_LIKE: NL is returned
  61444. * instead.
  61445. */
  61446. }, {
  61447. key: "captureNameChars",
  61448. value: function captureNameChars() {
  61449. var chunk = this.chunk,
  61450. start = this.i; // eslint-disable-next-line no-constant-condition
  61451. while (true) {
  61452. var c = this.getCode();
  61453. if (c === EOC) {
  61454. this.name += chunk.slice(start);
  61455. return EOC;
  61456. } // NL is not a name char so we don't have to test specifically for it.
  61457. if (!isNameChar(c)) {
  61458. this.name += chunk.slice(start, this.prevI);
  61459. return c === NL_LIKE ? NL : c;
  61460. }
  61461. }
  61462. }
  61463. /**
  61464. * Skip white spaces.
  61465. *
  61466. * @return The character that ended the skip, or ``EOC`` if we hit
  61467. * the end of the chunk. The return value cannot be NL_LIKE: NL is returned
  61468. * instead.
  61469. */
  61470. }, {
  61471. key: "skipSpaces",
  61472. value: function skipSpaces() {
  61473. // eslint-disable-next-line no-constant-condition
  61474. while (true) {
  61475. var c = this.getCodeNorm();
  61476. if (c === EOC || !isS(c)) {
  61477. return c;
  61478. }
  61479. }
  61480. }
  61481. }, {
  61482. key: "setXMLVersion",
  61483. value: function setXMLVersion(version) {
  61484. this.currentXMLVersion = version;
  61485. /* eslint-disable @typescript-eslint/unbound-method */
  61486. if (version === "1.0") {
  61487. this.isChar = isChar10;
  61488. this.getCode = this.getCode10;
  61489. } else {
  61490. this.isChar = isChar11;
  61491. this.getCode = this.getCode11;
  61492. }
  61493. /* eslint-enable @typescript-eslint/unbound-method */
  61494. } // STATE ENGINE METHODS
  61495. // This needs to be a state separate from S_BEGIN_WHITESPACE because we want
  61496. // to be sure never to come back to this state later.
  61497. }, {
  61498. key: "sBegin",
  61499. value: function sBegin() {
  61500. // We are essentially peeking at the first character of the chunk. Since
  61501. // S_BEGIN can be in effect only when we start working on the first chunk,
  61502. // the index at which we must look is necessarily 0. Note also that the
  61503. // following test does not depend on decoding surrogates.
  61504. // If the initial character is 0xFEFF, ignore it.
  61505. if (this.chunk.charCodeAt(0) === 0xFEFF) {
  61506. this.i++;
  61507. this.column++;
  61508. }
  61509. this.state = S_BEGIN_WHITESPACE;
  61510. }
  61511. }, {
  61512. key: "sBeginWhitespace",
  61513. value: function sBeginWhitespace() {
  61514. // We need to know whether we've encountered spaces or not because as soon
  61515. // as we run into a space, an XML declaration is no longer possible. Rather
  61516. // than slow down skipSpaces even in places where we don't care whether it
  61517. // skipped anything or not, we check whether prevI is equal to the value of
  61518. // i from before we skip spaces.
  61519. var iBefore = this.i;
  61520. var c = this.skipSpaces();
  61521. if (this.prevI !== iBefore) {
  61522. this.xmlDeclPossible = false;
  61523. }
  61524. switch (c) {
  61525. case LESS:
  61526. this.state = S_OPEN_WAKA; // We could naively call closeText but in this state, it is not normal
  61527. // to have text be filled with any data.
  61528. if (this.text.length !== 0) {
  61529. throw new Error("no-empty text at start");
  61530. }
  61531. break;
  61532. case EOC:
  61533. break;
  61534. default:
  61535. this.unget();
  61536. this.state = S_TEXT;
  61537. this.xmlDeclPossible = false;
  61538. }
  61539. }
  61540. }, {
  61541. key: "sDoctype",
  61542. value: function sDoctype() {
  61543. var _a;
  61544. var c = this.captureTo(DOCTYPE_TERMINATOR);
  61545. switch (c) {
  61546. case GREATER:
  61547. {
  61548. // eslint-disable-next-line no-unused-expressions
  61549. (_a = this.doctypeHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.text);
  61550. this.text = "";
  61551. this.state = S_TEXT;
  61552. this.doctype = true; // just remember that we saw it.
  61553. break;
  61554. }
  61555. case EOC:
  61556. break;
  61557. default:
  61558. this.text += String.fromCodePoint(c);
  61559. if (c === OPEN_BRACKET) {
  61560. this.state = S_DTD;
  61561. } else if (isQuote(c)) {
  61562. this.state = S_DOCTYPE_QUOTE;
  61563. this.q = c;
  61564. }
  61565. }
  61566. }
  61567. }, {
  61568. key: "sDoctypeQuote",
  61569. value: function sDoctypeQuote() {
  61570. var q = this.q;
  61571. if (this.captureToChar(q)) {
  61572. this.text += String.fromCodePoint(q);
  61573. this.q = null;
  61574. this.state = S_DOCTYPE;
  61575. }
  61576. }
  61577. }, {
  61578. key: "sDTD",
  61579. value: function sDTD() {
  61580. var c = this.captureTo(DTD_TERMINATOR);
  61581. if (c === EOC) {
  61582. return;
  61583. }
  61584. this.text += String.fromCodePoint(c);
  61585. if (c === CLOSE_BRACKET) {
  61586. this.state = S_DOCTYPE;
  61587. } else if (c === LESS) {
  61588. this.state = S_DTD_OPEN_WAKA;
  61589. } else if (isQuote(c)) {
  61590. this.state = S_DTD_QUOTED;
  61591. this.q = c;
  61592. }
  61593. }
  61594. }, {
  61595. key: "sDTDQuoted",
  61596. value: function sDTDQuoted() {
  61597. var q = this.q;
  61598. if (this.captureToChar(q)) {
  61599. this.text += String.fromCodePoint(q);
  61600. this.state = S_DTD;
  61601. this.q = null;
  61602. }
  61603. }
  61604. }, {
  61605. key: "sDTDOpenWaka",
  61606. value: function sDTDOpenWaka() {
  61607. var c = this.getCodeNorm();
  61608. this.text += String.fromCodePoint(c);
  61609. switch (c) {
  61610. case BANG:
  61611. this.state = S_DTD_OPEN_WAKA_BANG;
  61612. this.openWakaBang = "";
  61613. break;
  61614. case QUESTION:
  61615. this.state = S_DTD_PI;
  61616. break;
  61617. default:
  61618. this.state = S_DTD;
  61619. }
  61620. }
  61621. }, {
  61622. key: "sDTDOpenWakaBang",
  61623. value: function sDTDOpenWakaBang() {
  61624. var char = String.fromCodePoint(this.getCodeNorm());
  61625. var owb = this.openWakaBang += char;
  61626. this.text += char;
  61627. if (owb !== "-") {
  61628. this.state = owb === "--" ? S_DTD_COMMENT : S_DTD;
  61629. this.openWakaBang = "";
  61630. }
  61631. }
  61632. }, {
  61633. key: "sDTDComment",
  61634. value: function sDTDComment() {
  61635. if (this.captureToChar(MINUS)) {
  61636. this.text += "-";
  61637. this.state = S_DTD_COMMENT_ENDING;
  61638. }
  61639. }
  61640. }, {
  61641. key: "sDTDCommentEnding",
  61642. value: function sDTDCommentEnding() {
  61643. var c = this.getCodeNorm();
  61644. this.text += String.fromCodePoint(c);
  61645. this.state = c === MINUS ? S_DTD_COMMENT_ENDED : S_DTD_COMMENT;
  61646. }
  61647. }, {
  61648. key: "sDTDCommentEnded",
  61649. value: function sDTDCommentEnded() {
  61650. var c = this.getCodeNorm();
  61651. this.text += String.fromCodePoint(c);
  61652. if (c === GREATER) {
  61653. this.state = S_DTD;
  61654. } else {
  61655. this.fail("malformed comment."); // <!-- blah -- bloo --> will be recorded as
  61656. // a comment of " blah -- bloo "
  61657. this.state = S_DTD_COMMENT;
  61658. }
  61659. }
  61660. }, {
  61661. key: "sDTDPI",
  61662. value: function sDTDPI() {
  61663. if (this.captureToChar(QUESTION)) {
  61664. this.text += "?";
  61665. this.state = S_DTD_PI_ENDING;
  61666. }
  61667. }
  61668. }, {
  61669. key: "sDTDPIEnding",
  61670. value: function sDTDPIEnding() {
  61671. var c = this.getCodeNorm();
  61672. this.text += String.fromCodePoint(c);
  61673. if (c === GREATER) {
  61674. this.state = S_DTD;
  61675. }
  61676. }
  61677. }, {
  61678. key: "sText",
  61679. value: function sText() {
  61680. //
  61681. // We did try a version of saxes where the S_TEXT state was split in two
  61682. // states: one for text inside the root element, and one for text
  61683. // outside. This was avoiding having to test this.tags.length to decide
  61684. // what implementation to actually use.
  61685. //
  61686. // Peformance testing on gigabyte-size files did not show any advantage to
  61687. // using the two states solution instead of the current one. Conversely, it
  61688. // made the code a bit more complicated elsewhere. For instance, a comment
  61689. // can appear before the root element so when a comment ended it was
  61690. // necessary to determine whether to return to the S_TEXT state or to the
  61691. // new text-outside-root state.
  61692. //
  61693. if (this.tags.length !== 0) {
  61694. this.handleTextInRoot();
  61695. } else {
  61696. this.handleTextOutsideRoot();
  61697. }
  61698. }
  61699. }, {
  61700. key: "sEntity",
  61701. value: function sEntity() {
  61702. // This is essentially a specialized version of captureToChar(SEMICOLON...)
  61703. var start = this.i;
  61704. var chunk = this.chunk; // eslint-disable-next-line no-labels, no-restricted-syntax
  61705. loop: // eslint-disable-next-line no-constant-condition
  61706. while (true) {
  61707. switch (this.getCode()) {
  61708. case NL_LIKE:
  61709. this.entity += "".concat(chunk.slice(start, this.prevI), "\n");
  61710. start = this.i;
  61711. break;
  61712. case SEMICOLON:
  61713. {
  61714. var entityReturnState = this.entityReturnState;
  61715. var entity = this.entity + chunk.slice(start, this.prevI);
  61716. this.state = entityReturnState;
  61717. var parsed = void 0;
  61718. if (entity === "") {
  61719. this.fail("empty entity name.");
  61720. parsed = "&;";
  61721. } else {
  61722. parsed = this.parseEntity(entity);
  61723. this.entity = "";
  61724. }
  61725. if (entityReturnState !== S_TEXT || this.textHandler !== undefined) {
  61726. this.text += parsed;
  61727. } // eslint-disable-next-line no-labels
  61728. break loop;
  61729. }
  61730. case EOC:
  61731. this.entity += chunk.slice(start); // eslint-disable-next-line no-labels
  61732. break loop;
  61733. default:
  61734. }
  61735. }
  61736. }
  61737. }, {
  61738. key: "sOpenWaka",
  61739. value: function sOpenWaka() {
  61740. // Reminder: a state handler is called with at least one character
  61741. // available in the current chunk. So the first call to get code inside of
  61742. // a state handler cannot return ``EOC``. That's why we don't test
  61743. // for it.
  61744. var c = this.getCode(); // either a /, ?, !, or text is coming next.
  61745. if (isNameStartChar(c)) {
  61746. this.state = S_OPEN_TAG;
  61747. this.unget();
  61748. this.xmlDeclPossible = false;
  61749. } else {
  61750. switch (c) {
  61751. case FORWARD_SLASH:
  61752. this.state = S_CLOSE_TAG;
  61753. this.xmlDeclPossible = false;
  61754. break;
  61755. case BANG:
  61756. this.state = S_OPEN_WAKA_BANG;
  61757. this.openWakaBang = "";
  61758. this.xmlDeclPossible = false;
  61759. break;
  61760. case QUESTION:
  61761. this.state = S_PI_FIRST_CHAR;
  61762. break;
  61763. default:
  61764. this.fail("disallowed character in tag name");
  61765. this.state = S_TEXT;
  61766. this.xmlDeclPossible = false;
  61767. }
  61768. }
  61769. }
  61770. }, {
  61771. key: "sOpenWakaBang",
  61772. value: function sOpenWakaBang() {
  61773. this.openWakaBang += String.fromCodePoint(this.getCodeNorm());
  61774. switch (this.openWakaBang) {
  61775. case "[CDATA[":
  61776. if (!this.sawRoot && !this.reportedTextBeforeRoot) {
  61777. this.fail("text data outside of root node.");
  61778. this.reportedTextBeforeRoot = true;
  61779. }
  61780. if (this.closedRoot && !this.reportedTextAfterRoot) {
  61781. this.fail("text data outside of root node.");
  61782. this.reportedTextAfterRoot = true;
  61783. }
  61784. this.state = S_CDATA;
  61785. this.openWakaBang = "";
  61786. break;
  61787. case "--":
  61788. this.state = S_COMMENT;
  61789. this.openWakaBang = "";
  61790. break;
  61791. case "DOCTYPE":
  61792. this.state = S_DOCTYPE;
  61793. if (this.doctype || this.sawRoot) {
  61794. this.fail("inappropriately located doctype declaration.");
  61795. }
  61796. this.openWakaBang = "";
  61797. break;
  61798. default:
  61799. // 7 happens to be the maximum length of the string that can possibly
  61800. // match one of the cases above.
  61801. if (this.openWakaBang.length >= 7) {
  61802. this.fail("incorrect syntax.");
  61803. }
  61804. }
  61805. }
  61806. }, {
  61807. key: "sComment",
  61808. value: function sComment() {
  61809. if (this.captureToChar(MINUS)) {
  61810. this.state = S_COMMENT_ENDING;
  61811. }
  61812. }
  61813. }, {
  61814. key: "sCommentEnding",
  61815. value: function sCommentEnding() {
  61816. var _a;
  61817. var c = this.getCodeNorm();
  61818. if (c === MINUS) {
  61819. this.state = S_COMMENT_ENDED; // eslint-disable-next-line no-unused-expressions
  61820. (_a = this.commentHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.text);
  61821. this.text = "";
  61822. } else {
  61823. this.text += "-".concat(String.fromCodePoint(c));
  61824. this.state = S_COMMENT;
  61825. }
  61826. }
  61827. }, {
  61828. key: "sCommentEnded",
  61829. value: function sCommentEnded() {
  61830. var c = this.getCodeNorm();
  61831. if (c !== GREATER) {
  61832. this.fail("malformed comment."); // <!-- blah -- bloo --> will be recorded as
  61833. // a comment of " blah -- bloo "
  61834. this.text += "--".concat(String.fromCodePoint(c));
  61835. this.state = S_COMMENT;
  61836. } else {
  61837. this.state = S_TEXT;
  61838. }
  61839. }
  61840. }, {
  61841. key: "sCData",
  61842. value: function sCData() {
  61843. if (this.captureToChar(CLOSE_BRACKET)) {
  61844. this.state = S_CDATA_ENDING;
  61845. }
  61846. }
  61847. }, {
  61848. key: "sCDataEnding",
  61849. value: function sCDataEnding() {
  61850. var c = this.getCodeNorm();
  61851. if (c === CLOSE_BRACKET) {
  61852. this.state = S_CDATA_ENDING_2;
  61853. } else {
  61854. this.text += "]".concat(String.fromCodePoint(c));
  61855. this.state = S_CDATA;
  61856. }
  61857. }
  61858. }, {
  61859. key: "sCDataEnding2",
  61860. value: function sCDataEnding2() {
  61861. var _a;
  61862. var c = this.getCodeNorm();
  61863. switch (c) {
  61864. case GREATER:
  61865. {
  61866. // eslint-disable-next-line no-unused-expressions
  61867. (_a = this.cdataHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.text);
  61868. this.text = "";
  61869. this.state = S_TEXT;
  61870. break;
  61871. }
  61872. case CLOSE_BRACKET:
  61873. this.text += "]";
  61874. break;
  61875. default:
  61876. this.text += "]]".concat(String.fromCodePoint(c));
  61877. this.state = S_CDATA;
  61878. }
  61879. } // We need this separate state to check the first character fo the pi target
  61880. // with this.nameStartCheck which allows less characters than this.nameCheck.
  61881. }, {
  61882. key: "sPIFirstChar",
  61883. value: function sPIFirstChar() {
  61884. var c = this.getCodeNorm(); // This is first because in the case where the file is well-formed this is
  61885. // the branch taken. We optimize for well-formedness.
  61886. if (this.nameStartCheck(c)) {
  61887. this.piTarget += String.fromCodePoint(c);
  61888. this.state = S_PI_REST;
  61889. } else if (c === QUESTION || isS(c)) {
  61890. this.fail("processing instruction without a target.");
  61891. this.state = c === QUESTION ? S_PI_ENDING : S_PI_BODY;
  61892. } else {
  61893. this.fail("disallowed character in processing instruction name.");
  61894. this.piTarget += String.fromCodePoint(c);
  61895. this.state = S_PI_REST;
  61896. }
  61897. }
  61898. }, {
  61899. key: "sPIRest",
  61900. value: function sPIRest() {
  61901. // Capture characters into a piTarget while ``this.nameCheck`` run on the
  61902. // character read returns true.
  61903. var chunk = this.chunk,
  61904. start = this.i; // eslint-disable-next-line no-constant-condition
  61905. while (true) {
  61906. var c = this.getCodeNorm();
  61907. if (c === EOC) {
  61908. this.piTarget += chunk.slice(start);
  61909. return;
  61910. } // NL cannot satisfy this.nameCheck so we don't have to test specifically
  61911. // for it.
  61912. if (!this.nameCheck(c)) {
  61913. this.piTarget += chunk.slice(start, this.prevI);
  61914. var isQuestion = c === QUESTION;
  61915. if (isQuestion || isS(c)) {
  61916. if (this.piTarget === "xml") {
  61917. if (!this.xmlDeclPossible) {
  61918. this.fail("an XML declaration must be at the start of the document.");
  61919. }
  61920. this.state = isQuestion ? S_XML_DECL_ENDING : S_XML_DECL_NAME_START;
  61921. } else {
  61922. this.state = isQuestion ? S_PI_ENDING : S_PI_BODY;
  61923. }
  61924. } else {
  61925. this.fail("disallowed character in processing instruction name.");
  61926. this.piTarget += String.fromCodePoint(c);
  61927. }
  61928. break;
  61929. }
  61930. }
  61931. }
  61932. }, {
  61933. key: "sPIBody",
  61934. value: function sPIBody() {
  61935. if (this.text.length === 0) {
  61936. var c = this.getCodeNorm();
  61937. if (c === QUESTION) {
  61938. this.state = S_PI_ENDING;
  61939. } else if (!isS(c)) {
  61940. this.text = String.fromCodePoint(c);
  61941. }
  61942. } // The question mark character is not valid inside any of the XML
  61943. // declaration name/value pairs.
  61944. else if (this.captureToChar(QUESTION)) {
  61945. this.state = S_PI_ENDING;
  61946. }
  61947. }
  61948. }, {
  61949. key: "sPIEnding",
  61950. value: function sPIEnding() {
  61951. var _a;
  61952. var c = this.getCodeNorm();
  61953. if (c === GREATER) {
  61954. var piTarget = this.piTarget;
  61955. if (piTarget.toLowerCase() === "xml") {
  61956. this.fail("the XML declaration must appear at the start of the document.");
  61957. } // eslint-disable-next-line no-unused-expressions
  61958. (_a = this.piHandler) === null || _a === void 0 ? void 0 : _a.call(this, {
  61959. target: piTarget,
  61960. body: this.text
  61961. });
  61962. this.piTarget = this.text = "";
  61963. this.state = S_TEXT;
  61964. } else if (c === QUESTION) {
  61965. // We ran into ?? as part of a processing instruction. We initially took
  61966. // the first ? as a sign that the PI was ending, but it is not. So we have
  61967. // to add it to the body but we take the new ? as a sign that the PI is
  61968. // ending.
  61969. this.text += "?";
  61970. } else {
  61971. this.text += "?".concat(String.fromCodePoint(c));
  61972. this.state = S_PI_BODY;
  61973. }
  61974. this.xmlDeclPossible = false;
  61975. }
  61976. }, {
  61977. key: "sXMLDeclNameStart",
  61978. value: function sXMLDeclNameStart() {
  61979. var c = this.skipSpaces(); // The question mark character is not valid inside any of the XML
  61980. // declaration name/value pairs.
  61981. if (c === QUESTION) {
  61982. // It is valid to go to S_XML_DECL_ENDING from this state.
  61983. this.state = S_XML_DECL_ENDING;
  61984. return;
  61985. }
  61986. if (c !== EOC) {
  61987. this.state = S_XML_DECL_NAME;
  61988. this.name = String.fromCodePoint(c);
  61989. }
  61990. }
  61991. }, {
  61992. key: "sXMLDeclName",
  61993. value: function sXMLDeclName() {
  61994. var c = this.captureTo(XML_DECL_NAME_TERMINATOR); // The question mark character is not valid inside any of the XML
  61995. // declaration name/value pairs.
  61996. if (c === QUESTION) {
  61997. this.state = S_XML_DECL_ENDING;
  61998. this.name += this.text;
  61999. this.text = "";
  62000. this.fail("XML declaration is incomplete.");
  62001. return;
  62002. }
  62003. if (!(isS(c) || c === EQUAL)) {
  62004. return;
  62005. }
  62006. this.name += this.text;
  62007. this.text = "";
  62008. if (!this.xmlDeclExpects.includes(this.name)) {
  62009. switch (this.name.length) {
  62010. case 0:
  62011. this.fail("did not expect any more name/value pairs.");
  62012. break;
  62013. case 1:
  62014. this.fail("expected the name ".concat(this.xmlDeclExpects[0], "."));
  62015. break;
  62016. default:
  62017. this.fail("expected one of ".concat(this.xmlDeclExpects.join(", ")));
  62018. }
  62019. }
  62020. this.state = c === EQUAL ? S_XML_DECL_VALUE_START : S_XML_DECL_EQ;
  62021. }
  62022. }, {
  62023. key: "sXMLDeclEq",
  62024. value: function sXMLDeclEq() {
  62025. var c = this.getCodeNorm(); // The question mark character is not valid inside any of the XML
  62026. // declaration name/value pairs.
  62027. if (c === QUESTION) {
  62028. this.state = S_XML_DECL_ENDING;
  62029. this.fail("XML declaration is incomplete.");
  62030. return;
  62031. }
  62032. if (isS(c)) {
  62033. return;
  62034. }
  62035. if (c !== EQUAL) {
  62036. this.fail("value required.");
  62037. }
  62038. this.state = S_XML_DECL_VALUE_START;
  62039. }
  62040. }, {
  62041. key: "sXMLDeclValueStart",
  62042. value: function sXMLDeclValueStart() {
  62043. var c = this.getCodeNorm(); // The question mark character is not valid inside any of the XML
  62044. // declaration name/value pairs.
  62045. if (c === QUESTION) {
  62046. this.state = S_XML_DECL_ENDING;
  62047. this.fail("XML declaration is incomplete.");
  62048. return;
  62049. }
  62050. if (isS(c)) {
  62051. return;
  62052. }
  62053. if (!isQuote(c)) {
  62054. this.fail("value must be quoted.");
  62055. this.q = SPACE;
  62056. } else {
  62057. this.q = c;
  62058. }
  62059. this.state = S_XML_DECL_VALUE;
  62060. }
  62061. }, {
  62062. key: "sXMLDeclValue",
  62063. value: function sXMLDeclValue() {
  62064. var c = this.captureTo([this.q, QUESTION]); // The question mark character is not valid inside any of the XML
  62065. // declaration name/value pairs.
  62066. if (c === QUESTION) {
  62067. this.state = S_XML_DECL_ENDING;
  62068. this.text = "";
  62069. this.fail("XML declaration is incomplete.");
  62070. return;
  62071. }
  62072. if (c === EOC) {
  62073. return;
  62074. }
  62075. var value = this.text;
  62076. this.text = "";
  62077. switch (this.name) {
  62078. case "version":
  62079. {
  62080. this.xmlDeclExpects = ["encoding", "standalone"];
  62081. var version = value;
  62082. this.xmlDecl.version = version; // This is the test specified by XML 1.0 but it is fine for XML 1.1.
  62083. if (!/^1\.[0-9]+$/.test(version)) {
  62084. this.fail("version number must match /^1\\.[0-9]+$/.");
  62085. } // When forceXMLVersion is set, the XML declaration is ignored.
  62086. else if (!this.opt.forceXMLVersion) {
  62087. this.setXMLVersion(version);
  62088. }
  62089. break;
  62090. }
  62091. case "encoding":
  62092. if (!/^[A-Za-z][A-Za-z0-9._-]*$/.test(value)) {
  62093. this.fail("encoding value must match \
  62094. /^[A-Za-z0-9][A-Za-z0-9._-]*$/.");
  62095. }
  62096. this.xmlDeclExpects = ["standalone"];
  62097. this.xmlDecl.encoding = value;
  62098. break;
  62099. case "standalone":
  62100. if (value !== "yes" && value !== "no") {
  62101. this.fail("standalone value must match \"yes\" or \"no\".");
  62102. }
  62103. this.xmlDeclExpects = [];
  62104. this.xmlDecl.standalone = value;
  62105. break;
  62106. default: // We don't need to raise an error here since we've already raised one
  62107. // when checking what name was expected.
  62108. }
  62109. this.name = "";
  62110. this.state = S_XML_DECL_SEPARATOR;
  62111. }
  62112. }, {
  62113. key: "sXMLDeclSeparator",
  62114. value: function sXMLDeclSeparator() {
  62115. var c = this.getCodeNorm(); // The question mark character is not valid inside any of the XML
  62116. // declaration name/value pairs.
  62117. if (c === QUESTION) {
  62118. // It is valid to go to S_XML_DECL_ENDING from this state.
  62119. this.state = S_XML_DECL_ENDING;
  62120. return;
  62121. }
  62122. if (!isS(c)) {
  62123. this.fail("whitespace required.");
  62124. this.unget();
  62125. }
  62126. this.state = S_XML_DECL_NAME_START;
  62127. }
  62128. }, {
  62129. key: "sXMLDeclEnding",
  62130. value: function sXMLDeclEnding() {
  62131. var _a;
  62132. var c = this.getCodeNorm();
  62133. if (c === GREATER) {
  62134. if (this.piTarget !== "xml") {
  62135. this.fail("processing instructions are not allowed before root.");
  62136. } else if (this.name !== "version" && this.xmlDeclExpects.includes("version")) {
  62137. this.fail("XML declaration must contain a version.");
  62138. } // eslint-disable-next-line no-unused-expressions
  62139. (_a = this.xmldeclHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.xmlDecl);
  62140. this.name = "";
  62141. this.piTarget = this.text = "";
  62142. this.state = S_TEXT;
  62143. } else {
  62144. // We got here because the previous character was a ?, but the question
  62145. // mark character is not valid inside any of the XML declaration
  62146. // name/value pairs.
  62147. this.fail("The character ? is disallowed anywhere in XML declarations.");
  62148. }
  62149. this.xmlDeclPossible = false;
  62150. }
  62151. }, {
  62152. key: "sOpenTag",
  62153. value: function sOpenTag() {
  62154. var _a;
  62155. var c = this.captureNameChars();
  62156. if (c === EOC) {
  62157. return;
  62158. }
  62159. var tag = this.tag = {
  62160. name: this.name,
  62161. attributes: Object.create(null)
  62162. };
  62163. this.name = "";
  62164. if (this.xmlnsOpt) {
  62165. this.topNS = tag.ns = Object.create(null);
  62166. } // eslint-disable-next-line no-unused-expressions
  62167. (_a = this.openTagStartHandler) === null || _a === void 0 ? void 0 : _a.call(this, tag);
  62168. this.sawRoot = true;
  62169. if (!this.fragmentOpt && this.closedRoot) {
  62170. this.fail("documents may contain only one root.");
  62171. }
  62172. switch (c) {
  62173. case GREATER:
  62174. this.openTag();
  62175. break;
  62176. case FORWARD_SLASH:
  62177. this.state = S_OPEN_TAG_SLASH;
  62178. break;
  62179. default:
  62180. if (!isS(c)) {
  62181. this.fail("disallowed character in tag name.");
  62182. }
  62183. this.state = S_ATTRIB;
  62184. }
  62185. }
  62186. }, {
  62187. key: "sOpenTagSlash",
  62188. value: function sOpenTagSlash() {
  62189. if (this.getCode() === GREATER) {
  62190. this.openSelfClosingTag();
  62191. } else {
  62192. this.fail("forward-slash in opening tag not followed by >.");
  62193. this.state = S_ATTRIB;
  62194. }
  62195. }
  62196. }, {
  62197. key: "sAttrib",
  62198. value: function sAttrib() {
  62199. var c = this.skipSpaces();
  62200. if (c === EOC) {
  62201. return;
  62202. }
  62203. if (isNameStartChar(c)) {
  62204. this.unget();
  62205. this.state = S_ATTRIB_NAME;
  62206. } else if (c === GREATER) {
  62207. this.openTag();
  62208. } else if (c === FORWARD_SLASH) {
  62209. this.state = S_OPEN_TAG_SLASH;
  62210. } else {
  62211. this.fail("disallowed character in attribute name.");
  62212. }
  62213. }
  62214. }, {
  62215. key: "sAttribName",
  62216. value: function sAttribName() {
  62217. var c = this.captureNameChars();
  62218. if (c === EQUAL) {
  62219. this.state = S_ATTRIB_VALUE;
  62220. } else if (isS(c)) {
  62221. this.state = S_ATTRIB_NAME_SAW_WHITE;
  62222. } else if (c === GREATER) {
  62223. this.fail("attribute without value.");
  62224. this.pushAttrib(this.name, this.name);
  62225. this.name = this.text = "";
  62226. this.openTag();
  62227. } else if (c !== EOC) {
  62228. this.fail("disallowed character in attribute name.");
  62229. }
  62230. }
  62231. }, {
  62232. key: "sAttribNameSawWhite",
  62233. value: function sAttribNameSawWhite() {
  62234. var c = this.skipSpaces();
  62235. switch (c) {
  62236. case EOC:
  62237. return;
  62238. case EQUAL:
  62239. this.state = S_ATTRIB_VALUE;
  62240. break;
  62241. default:
  62242. this.fail("attribute without value."); // Should we do this???
  62243. // this.tag.attributes[this.name] = "";
  62244. this.text = "";
  62245. this.name = "";
  62246. if (c === GREATER) {
  62247. this.openTag();
  62248. } else if (isNameStartChar(c)) {
  62249. this.unget();
  62250. this.state = S_ATTRIB_NAME;
  62251. } else {
  62252. this.fail("disallowed character in attribute name.");
  62253. this.state = S_ATTRIB;
  62254. }
  62255. }
  62256. }
  62257. }, {
  62258. key: "sAttribValue",
  62259. value: function sAttribValue() {
  62260. var c = this.getCodeNorm();
  62261. if (isQuote(c)) {
  62262. this.q = c;
  62263. this.state = S_ATTRIB_VALUE_QUOTED;
  62264. } else if (!isS(c)) {
  62265. this.fail("unquoted attribute value.");
  62266. this.state = S_ATTRIB_VALUE_UNQUOTED;
  62267. this.unget();
  62268. }
  62269. }
  62270. }, {
  62271. key: "sAttribValueQuoted",
  62272. value: function sAttribValueQuoted() {
  62273. // We deliberately do not use captureTo here. The specialized code we use
  62274. // here is faster than using captureTo.
  62275. var q = this.q,
  62276. chunk = this.chunk;
  62277. var start = this.i; // eslint-disable-next-line no-constant-condition
  62278. while (true) {
  62279. switch (this.getCode()) {
  62280. case q:
  62281. this.pushAttrib(this.name, this.text + chunk.slice(start, this.prevI));
  62282. this.name = this.text = "";
  62283. this.q = null;
  62284. this.state = S_ATTRIB_VALUE_CLOSED;
  62285. return;
  62286. case AMP:
  62287. this.text += chunk.slice(start, this.prevI);
  62288. this.state = S_ENTITY;
  62289. this.entityReturnState = S_ATTRIB_VALUE_QUOTED;
  62290. return;
  62291. case NL:
  62292. case NL_LIKE:
  62293. case TAB:
  62294. this.text += "".concat(chunk.slice(start, this.prevI), " ");
  62295. start = this.i;
  62296. break;
  62297. case LESS:
  62298. this.text += chunk.slice(start, this.prevI);
  62299. this.fail("disallowed character.");
  62300. return;
  62301. case EOC:
  62302. this.text += chunk.slice(start);
  62303. return;
  62304. default:
  62305. }
  62306. }
  62307. }
  62308. }, {
  62309. key: "sAttribValueClosed",
  62310. value: function sAttribValueClosed() {
  62311. var c = this.getCodeNorm();
  62312. if (isS(c)) {
  62313. this.state = S_ATTRIB;
  62314. } else if (c === GREATER) {
  62315. this.openTag();
  62316. } else if (c === FORWARD_SLASH) {
  62317. this.state = S_OPEN_TAG_SLASH;
  62318. } else if (isNameStartChar(c)) {
  62319. this.fail("no whitespace between attributes.");
  62320. this.unget();
  62321. this.state = S_ATTRIB_NAME;
  62322. } else {
  62323. this.fail("disallowed character in attribute name.");
  62324. }
  62325. }
  62326. }, {
  62327. key: "sAttribValueUnquoted",
  62328. value: function sAttribValueUnquoted() {
  62329. // We don't do anything regarding EOL or space handling for unquoted
  62330. // attributes. We already have failed by the time we get here, and the
  62331. // contract that saxes upholds states that upon failure, it is not safe to
  62332. // rely on the data passed to event handlers (other than
  62333. // ``onerror``). Passing "bad" data is not a problem.
  62334. var c = this.captureTo(ATTRIB_VALUE_UNQUOTED_TERMINATOR);
  62335. switch (c) {
  62336. case AMP:
  62337. this.state = S_ENTITY;
  62338. this.entityReturnState = S_ATTRIB_VALUE_UNQUOTED;
  62339. break;
  62340. case LESS:
  62341. this.fail("disallowed character.");
  62342. break;
  62343. case EOC:
  62344. break;
  62345. default:
  62346. if (this.text.includes("]]>")) {
  62347. this.fail("the string \"]]>\" is disallowed in char data.");
  62348. }
  62349. this.pushAttrib(this.name, this.text);
  62350. this.name = this.text = "";
  62351. if (c === GREATER) {
  62352. this.openTag();
  62353. } else {
  62354. this.state = S_ATTRIB;
  62355. }
  62356. }
  62357. }
  62358. }, {
  62359. key: "sCloseTag",
  62360. value: function sCloseTag() {
  62361. var c = this.captureNameChars();
  62362. if (c === GREATER) {
  62363. this.closeTag();
  62364. } else if (isS(c)) {
  62365. this.state = S_CLOSE_TAG_SAW_WHITE;
  62366. } else if (c !== EOC) {
  62367. this.fail("disallowed character in closing tag.");
  62368. }
  62369. }
  62370. }, {
  62371. key: "sCloseTagSawWhite",
  62372. value: function sCloseTagSawWhite() {
  62373. switch (this.skipSpaces()) {
  62374. case GREATER:
  62375. this.closeTag();
  62376. break;
  62377. case EOC:
  62378. break;
  62379. default:
  62380. this.fail("disallowed character in closing tag.");
  62381. }
  62382. } // END OF STATE ENGINE METHODS
  62383. }, {
  62384. key: "handleTextInRoot",
  62385. value: function handleTextInRoot() {
  62386. // This is essentially a specialized version of captureTo which is optimized
  62387. // for performing the ]]> check. A previous version of this code, checked
  62388. // ``this.text`` for the presence of ]]>. It simplified the code but was
  62389. // very costly when character data contained a lot of entities to be parsed.
  62390. //
  62391. // Since we are using a specialized loop, we also keep track of the presence
  62392. // of ]]> in text data. The sequence ]]> is forbidden to appear as-is.
  62393. //
  62394. var start = this.i,
  62395. forbiddenState = this.forbiddenState;
  62396. var chunk = this.chunk,
  62397. handler = this.textHandler; // eslint-disable-next-line no-labels, no-restricted-syntax
  62398. scanLoop: // eslint-disable-next-line no-constant-condition
  62399. while (true) {
  62400. switch (this.getCode()) {
  62401. case LESS:
  62402. {
  62403. this.state = S_OPEN_WAKA;
  62404. if (handler !== undefined) {
  62405. var text = this.text;
  62406. var slice = chunk.slice(start, this.prevI);
  62407. if (text.length !== 0) {
  62408. handler(text + slice);
  62409. this.text = "";
  62410. } else if (slice.length !== 0) {
  62411. handler(slice);
  62412. }
  62413. }
  62414. forbiddenState = FORBIDDEN_START; // eslint-disable-next-line no-labels
  62415. break scanLoop;
  62416. }
  62417. case AMP:
  62418. this.state = S_ENTITY;
  62419. this.entityReturnState = S_TEXT;
  62420. if (handler !== undefined) {
  62421. this.text += chunk.slice(start, this.prevI);
  62422. }
  62423. forbiddenState = FORBIDDEN_START; // eslint-disable-next-line no-labels
  62424. break scanLoop;
  62425. case CLOSE_BRACKET:
  62426. switch (forbiddenState) {
  62427. case FORBIDDEN_START:
  62428. forbiddenState = FORBIDDEN_BRACKET;
  62429. break;
  62430. case FORBIDDEN_BRACKET:
  62431. forbiddenState = FORBIDDEN_BRACKET_BRACKET;
  62432. break;
  62433. case FORBIDDEN_BRACKET_BRACKET:
  62434. break;
  62435. default:
  62436. throw new Error("impossible state");
  62437. }
  62438. break;
  62439. case GREATER:
  62440. if (forbiddenState === FORBIDDEN_BRACKET_BRACKET) {
  62441. this.fail("the string \"]]>\" is disallowed in char data.");
  62442. }
  62443. forbiddenState = FORBIDDEN_START;
  62444. break;
  62445. case NL_LIKE:
  62446. if (handler !== undefined) {
  62447. this.text += "".concat(chunk.slice(start, this.prevI), "\n");
  62448. }
  62449. start = this.i;
  62450. forbiddenState = FORBIDDEN_START;
  62451. break;
  62452. case EOC:
  62453. if (handler !== undefined) {
  62454. this.text += chunk.slice(start);
  62455. } // eslint-disable-next-line no-labels
  62456. break scanLoop;
  62457. default:
  62458. forbiddenState = FORBIDDEN_START;
  62459. }
  62460. }
  62461. this.forbiddenState = forbiddenState;
  62462. }
  62463. }, {
  62464. key: "handleTextOutsideRoot",
  62465. value: function handleTextOutsideRoot() {
  62466. // This is essentially a specialized version of captureTo which is optimized
  62467. // for a specialized task. We keep track of the presence of non-space
  62468. // characters in the text since these are errors when appearing outside the
  62469. // document root element.
  62470. var start = this.i;
  62471. var chunk = this.chunk,
  62472. handler = this.textHandler;
  62473. var nonSpace = false; // eslint-disable-next-line no-labels, no-restricted-syntax
  62474. outRootLoop: // eslint-disable-next-line no-constant-condition
  62475. while (true) {
  62476. var code = this.getCode();
  62477. switch (code) {
  62478. case LESS:
  62479. {
  62480. this.state = S_OPEN_WAKA;
  62481. if (handler !== undefined) {
  62482. var text = this.text;
  62483. var slice = chunk.slice(start, this.prevI);
  62484. if (text.length !== 0) {
  62485. handler(text + slice);
  62486. this.text = "";
  62487. } else if (slice.length !== 0) {
  62488. handler(slice);
  62489. }
  62490. } // eslint-disable-next-line no-labels
  62491. break outRootLoop;
  62492. }
  62493. case AMP:
  62494. this.state = S_ENTITY;
  62495. this.entityReturnState = S_TEXT;
  62496. if (handler !== undefined) {
  62497. this.text += chunk.slice(start, this.prevI);
  62498. }
  62499. nonSpace = true; // eslint-disable-next-line no-labels
  62500. break outRootLoop;
  62501. case NL_LIKE:
  62502. if (handler !== undefined) {
  62503. this.text += "".concat(chunk.slice(start, this.prevI), "\n");
  62504. }
  62505. start = this.i;
  62506. break;
  62507. case EOC:
  62508. if (handler !== undefined) {
  62509. this.text += chunk.slice(start);
  62510. } // eslint-disable-next-line no-labels
  62511. break outRootLoop;
  62512. default:
  62513. if (!isS(code)) {
  62514. nonSpace = true;
  62515. }
  62516. }
  62517. }
  62518. if (!nonSpace) {
  62519. return;
  62520. } // We use the reportedTextBeforeRoot and reportedTextAfterRoot flags
  62521. // to avoid reporting errors for every single character that is out of
  62522. // place.
  62523. if (!this.sawRoot && !this.reportedTextBeforeRoot) {
  62524. this.fail("text data outside of root node.");
  62525. this.reportedTextBeforeRoot = true;
  62526. }
  62527. if (this.closedRoot && !this.reportedTextAfterRoot) {
  62528. this.fail("text data outside of root node.");
  62529. this.reportedTextAfterRoot = true;
  62530. }
  62531. }
  62532. }, {
  62533. key: "pushAttribNS",
  62534. value: function pushAttribNS(name, value) {
  62535. var _a;
  62536. var _this$qname = this.qname(name),
  62537. prefix = _this$qname.prefix,
  62538. local = _this$qname.local;
  62539. var attr = {
  62540. name: name,
  62541. prefix: prefix,
  62542. local: local,
  62543. value: value
  62544. };
  62545. this.attribList.push(attr); // eslint-disable-next-line no-unused-expressions
  62546. (_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this, attr);
  62547. if (prefix === "xmlns") {
  62548. var trimmed = value.trim();
  62549. if (this.currentXMLVersion === "1.0" && trimmed === "") {
  62550. this.fail("invalid attempt to undefine prefix in XML 1.0");
  62551. }
  62552. this.topNS[local] = trimmed;
  62553. nsPairCheck(this, local, trimmed);
  62554. } else if (name === "xmlns") {
  62555. var _trimmed = value.trim();
  62556. this.topNS[""] = _trimmed;
  62557. nsPairCheck(this, "", _trimmed);
  62558. }
  62559. }
  62560. }, {
  62561. key: "pushAttribPlain",
  62562. value: function pushAttribPlain(name, value) {
  62563. var _a;
  62564. var attr = {
  62565. name: name,
  62566. value: value
  62567. };
  62568. this.attribList.push(attr); // eslint-disable-next-line no-unused-expressions
  62569. (_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this, attr);
  62570. }
  62571. /**
  62572. * End parsing. This performs final well-formedness checks and resets the
  62573. * parser to a clean state.
  62574. *
  62575. * @returns this
  62576. */
  62577. }, {
  62578. key: "end",
  62579. value: function end() {
  62580. var _a, _b;
  62581. if (!this.sawRoot) {
  62582. this.fail("document must contain a root element.");
  62583. }
  62584. var tags = this.tags;
  62585. while (tags.length > 0) {
  62586. var tag = tags.pop();
  62587. this.fail("unclosed tag: ".concat(tag.name));
  62588. }
  62589. if (this.state !== S_BEGIN && this.state !== S_TEXT) {
  62590. this.fail("unexpected end.");
  62591. }
  62592. var text = this.text;
  62593. if (text.length !== 0) {
  62594. // eslint-disable-next-line no-unused-expressions
  62595. (_a = this.textHandler) === null || _a === void 0 ? void 0 : _a.call(this, text);
  62596. this.text = "";
  62597. }
  62598. this._closed = true; // eslint-disable-next-line no-unused-expressions
  62599. (_b = this.endHandler) === null || _b === void 0 ? void 0 : _b.call(this);
  62600. this._init();
  62601. return this;
  62602. }
  62603. /**
  62604. * Resolve a namespace prefix.
  62605. *
  62606. * @param prefix The prefix to resolve.
  62607. *
  62608. * @returns The namespace URI or ``undefined`` if the prefix is not defined.
  62609. */
  62610. }, {
  62611. key: "resolve",
  62612. value: function resolve(prefix) {
  62613. var _a, _b;
  62614. var uri = this.topNS[prefix];
  62615. if (uri !== undefined) {
  62616. return uri;
  62617. }
  62618. var tags = this.tags;
  62619. for (var index = tags.length - 1; index >= 0; index--) {
  62620. uri = tags[index].ns[prefix];
  62621. if (uri !== undefined) {
  62622. return uri;
  62623. }
  62624. }
  62625. uri = this.ns[prefix];
  62626. if (uri !== undefined) {
  62627. return uri;
  62628. }
  62629. return (_b = (_a = this.opt).resolvePrefix) === null || _b === void 0 ? void 0 : _b.call(_a, prefix);
  62630. }
  62631. /**
  62632. * Parse a qname into its prefix and local name parts.
  62633. *
  62634. * @param name The name to parse
  62635. *
  62636. * @returns
  62637. */
  62638. }, {
  62639. key: "qname",
  62640. value: function qname(name) {
  62641. // This is faster than using name.split(":").
  62642. var colon = name.indexOf(":");
  62643. if (colon === -1) {
  62644. return {
  62645. prefix: "",
  62646. local: name
  62647. };
  62648. }
  62649. var local = name.slice(colon + 1);
  62650. var prefix = name.slice(0, colon);
  62651. if (prefix === "" || local === "" || local.includes(":")) {
  62652. this.fail("malformed name: ".concat(name, "."));
  62653. }
  62654. return {
  62655. prefix: prefix,
  62656. local: local
  62657. };
  62658. }
  62659. }, {
  62660. key: "processAttribsNS",
  62661. value: function processAttribsNS() {
  62662. var _a;
  62663. var attribList = this.attribList;
  62664. var tag = this.tag;
  62665. {
  62666. // add namespace info to tag
  62667. var _this$qname2 = this.qname(tag.name),
  62668. prefix = _this$qname2.prefix,
  62669. local = _this$qname2.local;
  62670. tag.prefix = prefix;
  62671. tag.local = local;
  62672. var uri = tag.uri = (_a = this.resolve(prefix)) !== null && _a !== void 0 ? _a : "";
  62673. if (prefix !== "") {
  62674. if (prefix === "xmlns") {
  62675. this.fail("tags may not have \"xmlns\" as prefix.");
  62676. }
  62677. if (uri === "") {
  62678. this.fail("unbound namespace prefix: ".concat(JSON.stringify(prefix), "."));
  62679. tag.uri = prefix;
  62680. }
  62681. }
  62682. }
  62683. if (attribList.length === 0) {
  62684. return;
  62685. }
  62686. var attributes = tag.attributes;
  62687. var seen = new Set(); // Note: do not apply default ns to attributes:
  62688. // http://www.w3.org/TR/REC-xml-names/#defaulting
  62689. var _iterator = _createForOfIteratorHelper(attribList),
  62690. _step;
  62691. try {
  62692. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  62693. var attr = _step.value;
  62694. var name = attr.name,
  62695. _prefix = attr.prefix,
  62696. _local = attr.local;
  62697. var _uri = void 0;
  62698. var eqname = void 0;
  62699. if (_prefix === "") {
  62700. _uri = name === "xmlns" ? XMLNS_NAMESPACE : "";
  62701. eqname = name;
  62702. } else {
  62703. _uri = this.resolve(_prefix); // if there's any attributes with an undefined namespace,
  62704. // then fail on them now.
  62705. if (_uri === undefined) {
  62706. this.fail("unbound namespace prefix: ".concat(JSON.stringify(_prefix), "."));
  62707. _uri = _prefix;
  62708. }
  62709. eqname = "{".concat(_uri, "}").concat(_local);
  62710. }
  62711. if (seen.has(eqname)) {
  62712. this.fail("duplicate attribute: ".concat(eqname, "."));
  62713. }
  62714. seen.add(eqname);
  62715. attr.uri = _uri;
  62716. attributes[name] = attr;
  62717. }
  62718. } catch (err) {
  62719. _iterator.e(err);
  62720. } finally {
  62721. _iterator.f();
  62722. }
  62723. this.attribList = [];
  62724. }
  62725. }, {
  62726. key: "processAttribsPlain",
  62727. value: function processAttribsPlain() {
  62728. var attribList = this.attribList; // eslint-disable-next-line prefer-destructuring
  62729. var attributes = this.tag.attributes;
  62730. var _iterator2 = _createForOfIteratorHelper(attribList),
  62731. _step2;
  62732. try {
  62733. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  62734. var _step2$value = _step2.value,
  62735. name = _step2$value.name,
  62736. value = _step2$value.value;
  62737. if (attributes[name] !== undefined) {
  62738. this.fail("duplicate attribute: ".concat(name, "."));
  62739. }
  62740. attributes[name] = value;
  62741. }
  62742. } catch (err) {
  62743. _iterator2.e(err);
  62744. } finally {
  62745. _iterator2.f();
  62746. }
  62747. this.attribList = [];
  62748. }
  62749. /**
  62750. * Handle a complete open tag. This parser code calls this once it has seen
  62751. * the whole tag. This method checks for well-formeness and then emits
  62752. * ``onopentag``.
  62753. */
  62754. }, {
  62755. key: "openTag",
  62756. value: function openTag() {
  62757. var _a;
  62758. this.processAttribs();
  62759. var tags = this.tags;
  62760. var tag = this.tag;
  62761. tag.isSelfClosing = false; // There cannot be any pending text here due to the onopentagstart that was
  62762. // necessarily emitted before we get here. So we do not check text.
  62763. // eslint-disable-next-line no-unused-expressions
  62764. (_a = this.openTagHandler) === null || _a === void 0 ? void 0 : _a.call(this, tag);
  62765. tags.push(tag);
  62766. this.state = S_TEXT;
  62767. this.name = "";
  62768. }
  62769. /**
  62770. * Handle a complete self-closing tag. This parser code calls this once it has
  62771. * seen the whole tag. This method checks for well-formeness and then emits
  62772. * ``onopentag`` and ``onclosetag``.
  62773. */
  62774. }, {
  62775. key: "openSelfClosingTag",
  62776. value: function openSelfClosingTag() {
  62777. var _a, _b, _c;
  62778. this.processAttribs();
  62779. var tags = this.tags;
  62780. var tag = this.tag;
  62781. tag.isSelfClosing = true; // There cannot be any pending text here due to the onopentagstart that was
  62782. // necessarily emitted before we get here. So we do not check text.
  62783. // eslint-disable-next-line no-unused-expressions
  62784. (_a = this.openTagHandler) === null || _a === void 0 ? void 0 : _a.call(this, tag); // eslint-disable-next-line no-unused-expressions
  62785. (_b = this.closeTagHandler) === null || _b === void 0 ? void 0 : _b.call(this, tag);
  62786. var top = this.tag = (_c = tags[tags.length - 1]) !== null && _c !== void 0 ? _c : null;
  62787. if (top === null) {
  62788. this.closedRoot = true;
  62789. }
  62790. this.state = S_TEXT;
  62791. this.name = "";
  62792. }
  62793. /**
  62794. * Handle a complete close tag. This parser code calls this once it has seen
  62795. * the whole tag. This method checks for well-formeness and then emits
  62796. * ``onclosetag``.
  62797. */
  62798. }, {
  62799. key: "closeTag",
  62800. value: function closeTag() {
  62801. var tags = this.tags,
  62802. name = this.name; // Our state after this will be S_TEXT, no matter what, and we can clear
  62803. // tagName now.
  62804. this.state = S_TEXT;
  62805. this.name = "";
  62806. if (name === "") {
  62807. this.fail("weird empty close tag.");
  62808. this.text += "</>";
  62809. return;
  62810. }
  62811. var handler = this.closeTagHandler;
  62812. var l = tags.length;
  62813. while (l-- > 0) {
  62814. var tag = this.tag = tags.pop();
  62815. this.topNS = tag.ns; // eslint-disable-next-line no-unused-expressions
  62816. handler === null || handler === void 0 ? void 0 : handler(tag);
  62817. if (tag.name === name) {
  62818. break;
  62819. }
  62820. this.fail("unexpected close tag.");
  62821. }
  62822. if (l === 0) {
  62823. this.closedRoot = true;
  62824. } else if (l < 0) {
  62825. this.fail("unmatched closing tag: ".concat(name, "."));
  62826. this.text += "</".concat(name, ">");
  62827. }
  62828. }
  62829. /**
  62830. * Resolves an entity. Makes any necessary well-formedness checks.
  62831. *
  62832. * @param entity The entity to resolve.
  62833. *
  62834. * @returns The parsed entity.
  62835. */
  62836. }, {
  62837. key: "parseEntity",
  62838. value: function parseEntity(entity) {
  62839. // startsWith would be significantly slower for this test.
  62840. // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
  62841. if (entity[0] !== "#") {
  62842. var defined = this.ENTITIES[entity];
  62843. if (defined !== undefined) {
  62844. return defined;
  62845. }
  62846. this.fail(this.isName(entity) ? "undefined entity." : "disallowed character in entity name.");
  62847. return "&".concat(entity, ";");
  62848. }
  62849. var num = NaN;
  62850. if (entity[1] === "x" && /^#x[0-9a-f]+$/i.test(entity)) {
  62851. num = parseInt(entity.slice(2), 16);
  62852. } else if (/^#[0-9]+$/.test(entity)) {
  62853. num = parseInt(entity.slice(1), 10);
  62854. } // The character reference is required to match the CHAR production.
  62855. if (!this.isChar(num)) {
  62856. this.fail("malformed character entity.");
  62857. return "&".concat(entity, ";");
  62858. }
  62859. return String.fromCodePoint(num);
  62860. }
  62861. }, {
  62862. key: "closed",
  62863. get: function get() {
  62864. return this._closed;
  62865. }
  62866. }, {
  62867. key: "position",
  62868. get: function get() {
  62869. return this.chunkPosition + this.i;
  62870. }
  62871. /**
  62872. * The column number of the next character to be read by the parser. *
  62873. * This field is zero-based. (The first column in a line is 0.)
  62874. *
  62875. * This field reports the index at which the next character would be in the
  62876. * line if the line were represented as a JavaScript string. Note that this
  62877. * *can* be different to a count based on the number of *Unicode characters*
  62878. * due to how JavaScript handles astral plane characters.
  62879. *
  62880. * See [[column]] for a number that corresponds to a count of Unicode
  62881. * characters.
  62882. */
  62883. }, {
  62884. key: "columnIndex",
  62885. get: function get() {
  62886. return this.position - this.positionAtNewLine;
  62887. }
  62888. }]);
  62889. return SaxesParser;
  62890. }();
  62891. exports.SaxesParser = SaxesParser;
  62892. }, { "xmlchars/xml/1.0/ed5": 541, "xmlchars/xml/1.1/ed2": 542, "xmlchars/xmlns/1.0/ed3": 543 }], 497: [function (require, module, exports) {
  62893. (function (setImmediate) {
  62894. 'use strict';
  62895. module.exports = typeof setImmediate === 'function' ? setImmediate : function setImmediate() {
  62896. var args = [].slice.apply(arguments);
  62897. args.splice(1, 0, 0);
  62898. setTimeout.apply(null, args);
  62899. };
  62900. }).call(this, require("timers").setImmediate)
  62901. }, { "timers": 521 }], 498: [function (require, module, exports) {
  62902. "use strict";
  62903. var Buffer = require('safe-buffer').Buffer; // prototype class for hash functions
  62904. function Hash(blockSize, finalSize) {
  62905. this._block = Buffer.alloc(blockSize);
  62906. this._finalSize = finalSize;
  62907. this._blockSize = blockSize;
  62908. this._len = 0;
  62909. }
  62910. Hash.prototype.update = function (data, enc) {
  62911. if (typeof data === 'string') {
  62912. enc = enc || 'utf8';
  62913. data = Buffer.from(data, enc);
  62914. }
  62915. var block = this._block;
  62916. var blockSize = this._blockSize;
  62917. var length = data.length;
  62918. var accum = this._len;
  62919. for (var offset = 0; offset < length;) {
  62920. var assigned = accum % blockSize;
  62921. var remainder = Math.min(length - offset, blockSize - assigned);
  62922. for (var i = 0; i < remainder; i++) {
  62923. block[assigned + i] = data[offset + i];
  62924. }
  62925. accum += remainder;
  62926. offset += remainder;
  62927. if (accum % blockSize === 0) {
  62928. this._update(block);
  62929. }
  62930. }
  62931. this._len += length;
  62932. return this;
  62933. };
  62934. Hash.prototype.digest = function (enc) {
  62935. var rem = this._len % this._blockSize;
  62936. this._block[rem] = 0x80; // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
  62937. // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
  62938. this._block.fill(0, rem + 1);
  62939. if (rem >= this._finalSize) {
  62940. this._update(this._block);
  62941. this._block.fill(0);
  62942. }
  62943. var bits = this._len * 8; // uint32
  62944. if (bits <= 0xffffffff) {
  62945. this._block.writeUInt32BE(bits, this._blockSize - 4); // uint64
  62946. } else {
  62947. var lowBits = (bits & 0xffffffff) >>> 0;
  62948. var highBits = (bits - lowBits) / 0x100000000;
  62949. this._block.writeUInt32BE(highBits, this._blockSize - 8);
  62950. this._block.writeUInt32BE(lowBits, this._blockSize - 4);
  62951. }
  62952. this._update(this._block);
  62953. var hash = this._hash();
  62954. return enc ? hash.toString(enc) : hash;
  62955. };
  62956. Hash.prototype._update = function () {
  62957. throw new Error('_update must be implemented by subclass');
  62958. };
  62959. module.exports = Hash;
  62960. }, { "safe-buffer": 494 }], 499: [function (require, module, exports) {
  62961. "use strict";
  62962. var _exports = module.exports = function SHA(algorithm) {
  62963. algorithm = algorithm.toLowerCase();
  62964. var Algorithm = _exports[algorithm];
  62965. if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)');
  62966. return new Algorithm();
  62967. };
  62968. _exports.sha = require('./sha');
  62969. _exports.sha1 = require('./sha1');
  62970. _exports.sha224 = require('./sha224');
  62971. _exports.sha256 = require('./sha256');
  62972. _exports.sha384 = require('./sha384');
  62973. _exports.sha512 = require('./sha512');
  62974. }, { "./sha": 500, "./sha1": 501, "./sha224": 502, "./sha256": 503, "./sha384": 504, "./sha512": 505 }], 500: [function (require, module, exports) {
  62975. "use strict";
  62976. /*
  62977. * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
  62978. * in FIPS PUB 180-1
  62979. * This source code is derived from sha1.js of the same repository.
  62980. * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
  62981. * operation was added.
  62982. */
  62983. var inherits = require('inherits');
  62984. var Hash = require('./hash');
  62985. var Buffer = require('safe-buffer').Buffer;
  62986. var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0];
  62987. var W = new Array(80);
  62988. function Sha() {
  62989. this.init();
  62990. this._w = W;
  62991. Hash.call(this, 64, 56);
  62992. }
  62993. inherits(Sha, Hash);
  62994. Sha.prototype.init = function () {
  62995. this._a = 0x67452301;
  62996. this._b = 0xefcdab89;
  62997. this._c = 0x98badcfe;
  62998. this._d = 0x10325476;
  62999. this._e = 0xc3d2e1f0;
  63000. return this;
  63001. };
  63002. function rotl5(num) {
  63003. return num << 5 | num >>> 27;
  63004. }
  63005. function rotl30(num) {
  63006. return num << 30 | num >>> 2;
  63007. }
  63008. function ft(s, b, c, d) {
  63009. if (s === 0) return b & c | ~b & d;
  63010. if (s === 2) return b & c | b & d | c & d;
  63011. return b ^ c ^ d;
  63012. }
  63013. Sha.prototype._update = function (M) {
  63014. var W = this._w;
  63015. var a = this._a | 0;
  63016. var b = this._b | 0;
  63017. var c = this._c | 0;
  63018. var d = this._d | 0;
  63019. var e = this._e | 0;
  63020. for (var i = 0; i < 16; ++i) {
  63021. W[i] = M.readInt32BE(i * 4);
  63022. }
  63023. for (; i < 80; ++i) {
  63024. W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  63025. }
  63026. for (var j = 0; j < 80; ++j) {
  63027. var s = ~~(j / 20);
  63028. var t = rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s] | 0;
  63029. e = d;
  63030. d = c;
  63031. c = rotl30(b);
  63032. b = a;
  63033. a = t;
  63034. }
  63035. this._a = a + this._a | 0;
  63036. this._b = b + this._b | 0;
  63037. this._c = c + this._c | 0;
  63038. this._d = d + this._d | 0;
  63039. this._e = e + this._e | 0;
  63040. };
  63041. Sha.prototype._hash = function () {
  63042. var H = Buffer.allocUnsafe(20);
  63043. H.writeInt32BE(this._a | 0, 0);
  63044. H.writeInt32BE(this._b | 0, 4);
  63045. H.writeInt32BE(this._c | 0, 8);
  63046. H.writeInt32BE(this._d | 0, 12);
  63047. H.writeInt32BE(this._e | 0, 16);
  63048. return H;
  63049. };
  63050. module.exports = Sha;
  63051. }, { "./hash": 498, "inherits": 387, "safe-buffer": 494 }], 501: [function (require, module, exports) {
  63052. "use strict";
  63053. /*
  63054. * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
  63055. * in FIPS PUB 180-1
  63056. * Version 2.1a Copyright Paul Johnston 2000 - 2002.
  63057. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  63058. * Distributed under the BSD License
  63059. * See http://pajhome.org.uk/crypt/md5 for details.
  63060. */
  63061. var inherits = require('inherits');
  63062. var Hash = require('./hash');
  63063. var Buffer = require('safe-buffer').Buffer;
  63064. var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0];
  63065. var W = new Array(80);
  63066. function Sha1() {
  63067. this.init();
  63068. this._w = W;
  63069. Hash.call(this, 64, 56);
  63070. }
  63071. inherits(Sha1, Hash);
  63072. Sha1.prototype.init = function () {
  63073. this._a = 0x67452301;
  63074. this._b = 0xefcdab89;
  63075. this._c = 0x98badcfe;
  63076. this._d = 0x10325476;
  63077. this._e = 0xc3d2e1f0;
  63078. return this;
  63079. };
  63080. function rotl1(num) {
  63081. return num << 1 | num >>> 31;
  63082. }
  63083. function rotl5(num) {
  63084. return num << 5 | num >>> 27;
  63085. }
  63086. function rotl30(num) {
  63087. return num << 30 | num >>> 2;
  63088. }
  63089. function ft(s, b, c, d) {
  63090. if (s === 0) return b & c | ~b & d;
  63091. if (s === 2) return b & c | b & d | c & d;
  63092. return b ^ c ^ d;
  63093. }
  63094. Sha1.prototype._update = function (M) {
  63095. var W = this._w;
  63096. var a = this._a | 0;
  63097. var b = this._b | 0;
  63098. var c = this._c | 0;
  63099. var d = this._d | 0;
  63100. var e = this._e | 0;
  63101. for (var i = 0; i < 16; ++i) {
  63102. W[i] = M.readInt32BE(i * 4);
  63103. }
  63104. for (; i < 80; ++i) {
  63105. W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]);
  63106. }
  63107. for (var j = 0; j < 80; ++j) {
  63108. var s = ~~(j / 20);
  63109. var t = rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s] | 0;
  63110. e = d;
  63111. d = c;
  63112. c = rotl30(b);
  63113. b = a;
  63114. a = t;
  63115. }
  63116. this._a = a + this._a | 0;
  63117. this._b = b + this._b | 0;
  63118. this._c = c + this._c | 0;
  63119. this._d = d + this._d | 0;
  63120. this._e = e + this._e | 0;
  63121. };
  63122. Sha1.prototype._hash = function () {
  63123. var H = Buffer.allocUnsafe(20);
  63124. H.writeInt32BE(this._a | 0, 0);
  63125. H.writeInt32BE(this._b | 0, 4);
  63126. H.writeInt32BE(this._c | 0, 8);
  63127. H.writeInt32BE(this._d | 0, 12);
  63128. H.writeInt32BE(this._e | 0, 16);
  63129. return H;
  63130. };
  63131. module.exports = Sha1;
  63132. }, { "./hash": 498, "inherits": 387, "safe-buffer": 494 }], 502: [function (require, module, exports) {
  63133. "use strict";
  63134. /**
  63135. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  63136. * in FIPS 180-2
  63137. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  63138. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  63139. *
  63140. */
  63141. var inherits = require('inherits');
  63142. var Sha256 = require('./sha256');
  63143. var Hash = require('./hash');
  63144. var Buffer = require('safe-buffer').Buffer;
  63145. var W = new Array(64);
  63146. function Sha224() {
  63147. this.init();
  63148. this._w = W; // new Array(64)
  63149. Hash.call(this, 64, 56);
  63150. }
  63151. inherits(Sha224, Sha256);
  63152. Sha224.prototype.init = function () {
  63153. this._a = 0xc1059ed8;
  63154. this._b = 0x367cd507;
  63155. this._c = 0x3070dd17;
  63156. this._d = 0xf70e5939;
  63157. this._e = 0xffc00b31;
  63158. this._f = 0x68581511;
  63159. this._g = 0x64f98fa7;
  63160. this._h = 0xbefa4fa4;
  63161. return this;
  63162. };
  63163. Sha224.prototype._hash = function () {
  63164. var H = Buffer.allocUnsafe(28);
  63165. H.writeInt32BE(this._a, 0);
  63166. H.writeInt32BE(this._b, 4);
  63167. H.writeInt32BE(this._c, 8);
  63168. H.writeInt32BE(this._d, 12);
  63169. H.writeInt32BE(this._e, 16);
  63170. H.writeInt32BE(this._f, 20);
  63171. H.writeInt32BE(this._g, 24);
  63172. return H;
  63173. };
  63174. module.exports = Sha224;
  63175. }, { "./hash": 498, "./sha256": 503, "inherits": 387, "safe-buffer": 494 }], 503: [function (require, module, exports) {
  63176. "use strict";
  63177. /**
  63178. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  63179. * in FIPS 180-2
  63180. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  63181. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  63182. *
  63183. */
  63184. var inherits = require('inherits');
  63185. var Hash = require('./hash');
  63186. var Buffer = require('safe-buffer').Buffer;
  63187. var K = [0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2];
  63188. var W = new Array(64);
  63189. function Sha256() {
  63190. this.init();
  63191. this._w = W; // new Array(64)
  63192. Hash.call(this, 64, 56);
  63193. }
  63194. inherits(Sha256, Hash);
  63195. Sha256.prototype.init = function () {
  63196. this._a = 0x6a09e667;
  63197. this._b = 0xbb67ae85;
  63198. this._c = 0x3c6ef372;
  63199. this._d = 0xa54ff53a;
  63200. this._e = 0x510e527f;
  63201. this._f = 0x9b05688c;
  63202. this._g = 0x1f83d9ab;
  63203. this._h = 0x5be0cd19;
  63204. return this;
  63205. };
  63206. function ch(x, y, z) {
  63207. return z ^ x & (y ^ z);
  63208. }
  63209. function maj(x, y, z) {
  63210. return x & y | z & (x | y);
  63211. }
  63212. function sigma0(x) {
  63213. return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10);
  63214. }
  63215. function sigma1(x) {
  63216. return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7);
  63217. }
  63218. function gamma0(x) {
  63219. return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3;
  63220. }
  63221. function gamma1(x) {
  63222. return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ x >>> 10;
  63223. }
  63224. Sha256.prototype._update = function (M) {
  63225. var W = this._w;
  63226. var a = this._a | 0;
  63227. var b = this._b | 0;
  63228. var c = this._c | 0;
  63229. var d = this._d | 0;
  63230. var e = this._e | 0;
  63231. var f = this._f | 0;
  63232. var g = this._g | 0;
  63233. var h = this._h | 0;
  63234. for (var i = 0; i < 16; ++i) {
  63235. W[i] = M.readInt32BE(i * 4);
  63236. }
  63237. for (; i < 64; ++i) {
  63238. W[i] = gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16] | 0;
  63239. }
  63240. for (var j = 0; j < 64; ++j) {
  63241. var T1 = h + sigma1(e) + ch(e, f, g) + K[j] + W[j] | 0;
  63242. var T2 = sigma0(a) + maj(a, b, c) | 0;
  63243. h = g;
  63244. g = f;
  63245. f = e;
  63246. e = d + T1 | 0;
  63247. d = c;
  63248. c = b;
  63249. b = a;
  63250. a = T1 + T2 | 0;
  63251. }
  63252. this._a = a + this._a | 0;
  63253. this._b = b + this._b | 0;
  63254. this._c = c + this._c | 0;
  63255. this._d = d + this._d | 0;
  63256. this._e = e + this._e | 0;
  63257. this._f = f + this._f | 0;
  63258. this._g = g + this._g | 0;
  63259. this._h = h + this._h | 0;
  63260. };
  63261. Sha256.prototype._hash = function () {
  63262. var H = Buffer.allocUnsafe(32);
  63263. H.writeInt32BE(this._a, 0);
  63264. H.writeInt32BE(this._b, 4);
  63265. H.writeInt32BE(this._c, 8);
  63266. H.writeInt32BE(this._d, 12);
  63267. H.writeInt32BE(this._e, 16);
  63268. H.writeInt32BE(this._f, 20);
  63269. H.writeInt32BE(this._g, 24);
  63270. H.writeInt32BE(this._h, 28);
  63271. return H;
  63272. };
  63273. module.exports = Sha256;
  63274. }, { "./hash": 498, "inherits": 387, "safe-buffer": 494 }], 504: [function (require, module, exports) {
  63275. "use strict";
  63276. var inherits = require('inherits');
  63277. var SHA512 = require('./sha512');
  63278. var Hash = require('./hash');
  63279. var Buffer = require('safe-buffer').Buffer;
  63280. var W = new Array(160);
  63281. function Sha384() {
  63282. this.init();
  63283. this._w = W;
  63284. Hash.call(this, 128, 112);
  63285. }
  63286. inherits(Sha384, SHA512);
  63287. Sha384.prototype.init = function () {
  63288. this._ah = 0xcbbb9d5d;
  63289. this._bh = 0x629a292a;
  63290. this._ch = 0x9159015a;
  63291. this._dh = 0x152fecd8;
  63292. this._eh = 0x67332667;
  63293. this._fh = 0x8eb44a87;
  63294. this._gh = 0xdb0c2e0d;
  63295. this._hh = 0x47b5481d;
  63296. this._al = 0xc1059ed8;
  63297. this._bl = 0x367cd507;
  63298. this._cl = 0x3070dd17;
  63299. this._dl = 0xf70e5939;
  63300. this._el = 0xffc00b31;
  63301. this._fl = 0x68581511;
  63302. this._gl = 0x64f98fa7;
  63303. this._hl = 0xbefa4fa4;
  63304. return this;
  63305. };
  63306. Sha384.prototype._hash = function () {
  63307. var H = Buffer.allocUnsafe(48);
  63308. function writeInt64BE(h, l, offset) {
  63309. H.writeInt32BE(h, offset);
  63310. H.writeInt32BE(l, offset + 4);
  63311. }
  63312. writeInt64BE(this._ah, this._al, 0);
  63313. writeInt64BE(this._bh, this._bl, 8);
  63314. writeInt64BE(this._ch, this._cl, 16);
  63315. writeInt64BE(this._dh, this._dl, 24);
  63316. writeInt64BE(this._eh, this._el, 32);
  63317. writeInt64BE(this._fh, this._fl, 40);
  63318. return H;
  63319. };
  63320. module.exports = Sha384;
  63321. }, { "./hash": 498, "./sha512": 505, "inherits": 387, "safe-buffer": 494 }], 505: [function (require, module, exports) {
  63322. "use strict";
  63323. var inherits = require('inherits');
  63324. var Hash = require('./hash');
  63325. var Buffer = require('safe-buffer').Buffer;
  63326. var K = [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817];
  63327. var W = new Array(160);
  63328. function Sha512() {
  63329. this.init();
  63330. this._w = W;
  63331. Hash.call(this, 128, 112);
  63332. }
  63333. inherits(Sha512, Hash);
  63334. Sha512.prototype.init = function () {
  63335. this._ah = 0x6a09e667;
  63336. this._bh = 0xbb67ae85;
  63337. this._ch = 0x3c6ef372;
  63338. this._dh = 0xa54ff53a;
  63339. this._eh = 0x510e527f;
  63340. this._fh = 0x9b05688c;
  63341. this._gh = 0x1f83d9ab;
  63342. this._hh = 0x5be0cd19;
  63343. this._al = 0xf3bcc908;
  63344. this._bl = 0x84caa73b;
  63345. this._cl = 0xfe94f82b;
  63346. this._dl = 0x5f1d36f1;
  63347. this._el = 0xade682d1;
  63348. this._fl = 0x2b3e6c1f;
  63349. this._gl = 0xfb41bd6b;
  63350. this._hl = 0x137e2179;
  63351. return this;
  63352. };
  63353. function Ch(x, y, z) {
  63354. return z ^ x & (y ^ z);
  63355. }
  63356. function maj(x, y, z) {
  63357. return x & y | z & (x | y);
  63358. }
  63359. function sigma0(x, xl) {
  63360. return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25);
  63361. }
  63362. function sigma1(x, xl) {
  63363. return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23);
  63364. }
  63365. function Gamma0(x, xl) {
  63366. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ x >>> 7;
  63367. }
  63368. function Gamma0l(x, xl) {
  63369. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25);
  63370. }
  63371. function Gamma1(x, xl) {
  63372. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ x >>> 6;
  63373. }
  63374. function Gamma1l(x, xl) {
  63375. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26);
  63376. }
  63377. function getCarry(a, b) {
  63378. return a >>> 0 < b >>> 0 ? 1 : 0;
  63379. }
  63380. Sha512.prototype._update = function (M) {
  63381. var W = this._w;
  63382. var ah = this._ah | 0;
  63383. var bh = this._bh | 0;
  63384. var ch = this._ch | 0;
  63385. var dh = this._dh | 0;
  63386. var eh = this._eh | 0;
  63387. var fh = this._fh | 0;
  63388. var gh = this._gh | 0;
  63389. var hh = this._hh | 0;
  63390. var al = this._al | 0;
  63391. var bl = this._bl | 0;
  63392. var cl = this._cl | 0;
  63393. var dl = this._dl | 0;
  63394. var el = this._el | 0;
  63395. var fl = this._fl | 0;
  63396. var gl = this._gl | 0;
  63397. var hl = this._hl | 0;
  63398. for (var i = 0; i < 32; i += 2) {
  63399. W[i] = M.readInt32BE(i * 4);
  63400. W[i + 1] = M.readInt32BE(i * 4 + 4);
  63401. }
  63402. for (; i < 160; i += 2) {
  63403. var xh = W[i - 15 * 2];
  63404. var xl = W[i - 15 * 2 + 1];
  63405. var gamma0 = Gamma0(xh, xl);
  63406. var gamma0l = Gamma0l(xl, xh);
  63407. xh = W[i - 2 * 2];
  63408. xl = W[i - 2 * 2 + 1];
  63409. var gamma1 = Gamma1(xh, xl);
  63410. var gamma1l = Gamma1l(xl, xh); // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
  63411. var Wi7h = W[i - 7 * 2];
  63412. var Wi7l = W[i - 7 * 2 + 1];
  63413. var Wi16h = W[i - 16 * 2];
  63414. var Wi16l = W[i - 16 * 2 + 1];
  63415. var Wil = gamma0l + Wi7l | 0;
  63416. var Wih = gamma0 + Wi7h + getCarry(Wil, gamma0l) | 0;
  63417. Wil = Wil + gamma1l | 0;
  63418. Wih = Wih + gamma1 + getCarry(Wil, gamma1l) | 0;
  63419. Wil = Wil + Wi16l | 0;
  63420. Wih = Wih + Wi16h + getCarry(Wil, Wi16l) | 0;
  63421. W[i] = Wih;
  63422. W[i + 1] = Wil;
  63423. }
  63424. for (var j = 0; j < 160; j += 2) {
  63425. Wih = W[j];
  63426. Wil = W[j + 1];
  63427. var majh = maj(ah, bh, ch);
  63428. var majl = maj(al, bl, cl);
  63429. var sigma0h = sigma0(ah, al);
  63430. var sigma0l = sigma0(al, ah);
  63431. var sigma1h = sigma1(eh, el);
  63432. var sigma1l = sigma1(el, eh); // t1 = h + sigma1 + ch + K[j] + W[j]
  63433. var Kih = K[j];
  63434. var Kil = K[j + 1];
  63435. var chh = Ch(eh, fh, gh);
  63436. var chl = Ch(el, fl, gl);
  63437. var t1l = hl + sigma1l | 0;
  63438. var t1h = hh + sigma1h + getCarry(t1l, hl) | 0;
  63439. t1l = t1l + chl | 0;
  63440. t1h = t1h + chh + getCarry(t1l, chl) | 0;
  63441. t1l = t1l + Kil | 0;
  63442. t1h = t1h + Kih + getCarry(t1l, Kil) | 0;
  63443. t1l = t1l + Wil | 0;
  63444. t1h = t1h + Wih + getCarry(t1l, Wil) | 0; // t2 = sigma0 + maj
  63445. var t2l = sigma0l + majl | 0;
  63446. var t2h = sigma0h + majh + getCarry(t2l, sigma0l) | 0;
  63447. hh = gh;
  63448. hl = gl;
  63449. gh = fh;
  63450. gl = fl;
  63451. fh = eh;
  63452. fl = el;
  63453. el = dl + t1l | 0;
  63454. eh = dh + t1h + getCarry(el, dl) | 0;
  63455. dh = ch;
  63456. dl = cl;
  63457. ch = bh;
  63458. cl = bl;
  63459. bh = ah;
  63460. bl = al;
  63461. al = t1l + t2l | 0;
  63462. ah = t1h + t2h + getCarry(al, t1l) | 0;
  63463. }
  63464. this._al = this._al + al | 0;
  63465. this._bl = this._bl + bl | 0;
  63466. this._cl = this._cl + cl | 0;
  63467. this._dl = this._dl + dl | 0;
  63468. this._el = this._el + el | 0;
  63469. this._fl = this._fl + fl | 0;
  63470. this._gl = this._gl + gl | 0;
  63471. this._hl = this._hl + hl | 0;
  63472. this._ah = this._ah + ah + getCarry(this._al, al) | 0;
  63473. this._bh = this._bh + bh + getCarry(this._bl, bl) | 0;
  63474. this._ch = this._ch + ch + getCarry(this._cl, cl) | 0;
  63475. this._dh = this._dh + dh + getCarry(this._dl, dl) | 0;
  63476. this._eh = this._eh + eh + getCarry(this._el, el) | 0;
  63477. this._fh = this._fh + fh + getCarry(this._fl, fl) | 0;
  63478. this._gh = this._gh + gh + getCarry(this._gl, gl) | 0;
  63479. this._hh = this._hh + hh + getCarry(this._hl, hl) | 0;
  63480. };
  63481. Sha512.prototype._hash = function () {
  63482. var H = Buffer.allocUnsafe(64);
  63483. function writeInt64BE(h, l, offset) {
  63484. H.writeInt32BE(h, offset);
  63485. H.writeInt32BE(l, offset + 4);
  63486. }
  63487. writeInt64BE(this._ah, this._al, 0);
  63488. writeInt64BE(this._bh, this._bl, 8);
  63489. writeInt64BE(this._ch, this._cl, 16);
  63490. writeInt64BE(this._dh, this._dl, 24);
  63491. writeInt64BE(this._eh, this._el, 32);
  63492. writeInt64BE(this._fh, this._fl, 40);
  63493. writeInt64BE(this._gh, this._gl, 48);
  63494. writeInt64BE(this._hh, this._hl, 56);
  63495. return H;
  63496. };
  63497. module.exports = Sha512;
  63498. }, { "./hash": 498, "inherits": 387, "safe-buffer": 494 }], 506: [function (require, module, exports) {
  63499. "use strict";
  63500. // Copyright Joyent, Inc. and other Node contributors.
  63501. //
  63502. // Permission is hereby granted, free of charge, to any person obtaining a
  63503. // copy of this software and associated documentation files (the
  63504. // "Software"), to deal in the Software without restriction, including
  63505. // without limitation the rights to use, copy, modify, merge, publish,
  63506. // distribute, sublicense, and/or sell copies of the Software, and to permit
  63507. // persons to whom the Software is furnished to do so, subject to the
  63508. // following conditions:
  63509. //
  63510. // The above copyright notice and this permission notice shall be included
  63511. // in all copies or substantial portions of the Software.
  63512. //
  63513. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  63514. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  63515. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  63516. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  63517. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  63518. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  63519. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  63520. module.exports = Stream;
  63521. var EE = require('events').EventEmitter;
  63522. var inherits = require('inherits');
  63523. inherits(Stream, EE);
  63524. Stream.Readable = require('readable-stream/readable.js');
  63525. Stream.Writable = require('readable-stream/writable.js');
  63526. Stream.Duplex = require('readable-stream/duplex.js');
  63527. Stream.Transform = require('readable-stream/transform.js');
  63528. Stream.PassThrough = require('readable-stream/passthrough.js'); // Backwards-compat with node 0.4.x
  63529. Stream.Stream = Stream; // old-style streams. Note that the pipe method (the only relevant
  63530. // part of this class) is overridden in the Readable class.
  63531. function Stream() {
  63532. EE.call(this);
  63533. }
  63534. Stream.prototype.pipe = function (dest, options) {
  63535. var source = this;
  63536. function ondata(chunk) {
  63537. if (dest.writable) {
  63538. if (false === dest.write(chunk) && source.pause) {
  63539. source.pause();
  63540. }
  63541. }
  63542. }
  63543. source.on('data', ondata);
  63544. function ondrain() {
  63545. if (source.readable && source.resume) {
  63546. source.resume();
  63547. }
  63548. }
  63549. dest.on('drain', ondrain); // If the 'end' option is not supplied, dest.end() will be called when
  63550. // source gets the 'end' or 'close' events. Only dest.end() once.
  63551. if (!dest._isStdio && (!options || options.end !== false)) {
  63552. source.on('end', onend);
  63553. source.on('close', onclose);
  63554. }
  63555. var didOnEnd = false;
  63556. function onend() {
  63557. if (didOnEnd) return;
  63558. didOnEnd = true;
  63559. dest.end();
  63560. }
  63561. function onclose() {
  63562. if (didOnEnd) return;
  63563. didOnEnd = true;
  63564. if (typeof dest.destroy === 'function') dest.destroy();
  63565. } // don't leave dangling pipes when there are errors.
  63566. function onerror(er) {
  63567. cleanup();
  63568. if (EE.listenerCount(this, 'error') === 0) {
  63569. throw er; // Unhandled stream error in pipe.
  63570. }
  63571. }
  63572. source.on('error', onerror);
  63573. dest.on('error', onerror); // remove all the event listeners that were added.
  63574. function cleanup() {
  63575. source.removeListener('data', ondata);
  63576. dest.removeListener('drain', ondrain);
  63577. source.removeListener('end', onend);
  63578. source.removeListener('close', onclose);
  63579. source.removeListener('error', onerror);
  63580. dest.removeListener('error', onerror);
  63581. source.removeListener('end', cleanup);
  63582. source.removeListener('close', cleanup);
  63583. dest.removeListener('close', cleanup);
  63584. }
  63585. source.on('end', cleanup);
  63586. source.on('close', cleanup);
  63587. dest.on('close', cleanup);
  63588. dest.emit('pipe', source); // Allow for unix-like usage: A.pipe(B).pipe(C)
  63589. return dest;
  63590. };
  63591. }, { "events": 367, "inherits": 387, "readable-stream/duplex.js": 507, "readable-stream/passthrough.js": 516, "readable-stream/readable.js": 517, "readable-stream/transform.js": 518, "readable-stream/writable.js": 519 }], 507: [function (require, module, exports) {
  63592. "use strict";
  63593. module.exports = require('./lib/_stream_duplex.js');
  63594. }, { "./lib/_stream_duplex.js": 508 }], 508: [function (require, module, exports) {
  63595. // Copyright Joyent, Inc. and other Node contributors.
  63596. //
  63597. // Permission is hereby granted, free of charge, to any person obtaining a
  63598. // copy of this software and associated documentation files (the
  63599. // "Software"), to deal in the Software without restriction, including
  63600. // without limitation the rights to use, copy, modify, merge, publish,
  63601. // distribute, sublicense, and/or sell copies of the Software, and to permit
  63602. // persons to whom the Software is furnished to do so, subject to the
  63603. // following conditions:
  63604. //
  63605. // The above copyright notice and this permission notice shall be included
  63606. // in all copies or substantial portions of the Software.
  63607. //
  63608. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  63609. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  63610. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  63611. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  63612. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  63613. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  63614. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  63615. // a duplex stream is just a stream that is both readable and writable.
  63616. // Since JS doesn't have multiple prototypal inheritance, this class
  63617. // prototypally inherits from Readable, and then parasitically from
  63618. // Writable.
  63619. 'use strict';
  63620. /*<replacement>*/
  63621. var pna = require('process-nextick-args');
  63622. /*</replacement>*/
  63623. /*<replacement>*/
  63624. var objectKeys = Object.keys || function (obj) {
  63625. var keys = [];
  63626. for (var key in obj) {
  63627. keys.push(key);
  63628. }
  63629. return keys;
  63630. };
  63631. /*</replacement>*/
  63632. module.exports = Duplex;
  63633. /*<replacement>*/
  63634. var util = Object.create(require('core-util-is'));
  63635. util.inherits = require('inherits');
  63636. /*</replacement>*/
  63637. var Readable = require('./_stream_readable');
  63638. var Writable = require('./_stream_writable');
  63639. util.inherits(Duplex, Readable);
  63640. {
  63641. // avoid scope creep, the keys array can then be collected
  63642. var keys = objectKeys(Writable.prototype);
  63643. for (var v = 0; v < keys.length; v++) {
  63644. var method = keys[v];
  63645. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  63646. }
  63647. }
  63648. function Duplex(options) {
  63649. if (!(this instanceof Duplex)) return new Duplex(options);
  63650. Readable.call(this, options);
  63651. Writable.call(this, options);
  63652. if (options && options.readable === false) this.readable = false;
  63653. if (options && options.writable === false) this.writable = false;
  63654. this.allowHalfOpen = true;
  63655. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  63656. this.once('end', onend);
  63657. }
  63658. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  63659. // making it explicit this property is not enumerable
  63660. // because otherwise some prototype manipulation in
  63661. // userland will fail
  63662. enumerable: false,
  63663. get: function get() {
  63664. return this._writableState.highWaterMark;
  63665. }
  63666. }); // the no-half-open enforcer
  63667. function onend() {
  63668. // if we allow half-open state, or if the writable side ended,
  63669. // then we're ok.
  63670. if (this.allowHalfOpen || this._writableState.ended) return; // no more data can be written.
  63671. // But allow more writes to happen in this tick.
  63672. pna.nextTick(onEndNT, this);
  63673. }
  63674. function onEndNT(self) {
  63675. self.end();
  63676. }
  63677. Object.defineProperty(Duplex.prototype, 'destroyed', {
  63678. get: function get() {
  63679. if (this._readableState === undefined || this._writableState === undefined) {
  63680. return false;
  63681. }
  63682. return this._readableState.destroyed && this._writableState.destroyed;
  63683. },
  63684. set: function set(value) {
  63685. // we ignore the value if the stream
  63686. // has not been initialized yet
  63687. if (this._readableState === undefined || this._writableState === undefined) {
  63688. return;
  63689. } // backward compatibility, the user is explicitly
  63690. // managing destroyed
  63691. this._readableState.destroyed = value;
  63692. this._writableState.destroyed = value;
  63693. }
  63694. });
  63695. Duplex.prototype._destroy = function (err, cb) {
  63696. this.push(null);
  63697. this.end();
  63698. pna.nextTick(cb, err);
  63699. };
  63700. }, { "./_stream_readable": 510, "./_stream_writable": 512, "core-util-is": 328, "inherits": 387, "process-nextick-args": 466 }], 509: [function (require, module, exports) {
  63701. // Copyright Joyent, Inc. and other Node contributors.
  63702. //
  63703. // Permission is hereby granted, free of charge, to any person obtaining a
  63704. // copy of this software and associated documentation files (the
  63705. // "Software"), to deal in the Software without restriction, including
  63706. // without limitation the rights to use, copy, modify, merge, publish,
  63707. // distribute, sublicense, and/or sell copies of the Software, and to permit
  63708. // persons to whom the Software is furnished to do so, subject to the
  63709. // following conditions:
  63710. //
  63711. // The above copyright notice and this permission notice shall be included
  63712. // in all copies or substantial portions of the Software.
  63713. //
  63714. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  63715. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  63716. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  63717. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  63718. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  63719. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  63720. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  63721. // a passthrough stream.
  63722. // basically just the most minimal sort of Transform stream.
  63723. // Every written chunk gets output as-is.
  63724. 'use strict';
  63725. module.exports = PassThrough;
  63726. var Transform = require('./_stream_transform');
  63727. /*<replacement>*/
  63728. var util = Object.create(require('core-util-is'));
  63729. util.inherits = require('inherits');
  63730. /*</replacement>*/
  63731. util.inherits(PassThrough, Transform);
  63732. function PassThrough(options) {
  63733. if (!(this instanceof PassThrough)) return new PassThrough(options);
  63734. Transform.call(this, options);
  63735. }
  63736. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  63737. cb(null, chunk);
  63738. };
  63739. }, { "./_stream_transform": 511, "core-util-is": 328, "inherits": 387 }], 510: [function (require, module, exports) {
  63740. (function (process, global) {
  63741. // Copyright Joyent, Inc. and other Node contributors.
  63742. //
  63743. // Permission is hereby granted, free of charge, to any person obtaining a
  63744. // copy of this software and associated documentation files (the
  63745. // "Software"), to deal in the Software without restriction, including
  63746. // without limitation the rights to use, copy, modify, merge, publish,
  63747. // distribute, sublicense, and/or sell copies of the Software, and to permit
  63748. // persons to whom the Software is furnished to do so, subject to the
  63749. // following conditions:
  63750. //
  63751. // The above copyright notice and this permission notice shall be included
  63752. // in all copies or substantial portions of the Software.
  63753. //
  63754. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  63755. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  63756. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  63757. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  63758. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  63759. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  63760. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  63761. 'use strict';
  63762. /*<replacement>*/
  63763. var pna = require('process-nextick-args');
  63764. /*</replacement>*/
  63765. module.exports = Readable;
  63766. /*<replacement>*/
  63767. var isArray = require('isarray');
  63768. /*</replacement>*/
  63769. /*<replacement>*/
  63770. var Duplex;
  63771. /*</replacement>*/
  63772. Readable.ReadableState = ReadableState;
  63773. /*<replacement>*/
  63774. var EE = require('events').EventEmitter;
  63775. var EElistenerCount = function EElistenerCount(emitter, type) {
  63776. return emitter.listeners(type).length;
  63777. };
  63778. /*</replacement>*/
  63779. /*<replacement>*/
  63780. var Stream = require('./internal/streams/stream');
  63781. /*</replacement>*/
  63782. /*<replacement>*/
  63783. var Buffer = require('safe-buffer').Buffer;
  63784. var OurUint8Array = global.Uint8Array || function () { };
  63785. function _uint8ArrayToBuffer(chunk) {
  63786. return Buffer.from(chunk);
  63787. }
  63788. function _isUint8Array(obj) {
  63789. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  63790. }
  63791. /*</replacement>*/
  63792. /*<replacement>*/
  63793. var util = Object.create(require('core-util-is'));
  63794. util.inherits = require('inherits');
  63795. /*</replacement>*/
  63796. /*<replacement>*/
  63797. var debugUtil = require('util');
  63798. var debug = void 0;
  63799. if (debugUtil && debugUtil.debuglog) {
  63800. debug = debugUtil.debuglog('stream');
  63801. } else {
  63802. debug = function debug() { };
  63803. }
  63804. /*</replacement>*/
  63805. var BufferList = require('./internal/streams/BufferList');
  63806. var destroyImpl = require('./internal/streams/destroy');
  63807. var StringDecoder;
  63808. util.inherits(Readable, Stream);
  63809. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  63810. function prependListener(emitter, event, fn) {
  63811. // Sadly this is not cacheable as some libraries bundle their own
  63812. // event emitter implementation with them.
  63813. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any
  63814. // userland ones. NEVER DO THIS. This is here only because this code needs
  63815. // to continue to work with older versions of Node.js that do not include
  63816. // the prependListener() method. The goal is to eventually remove this hack.
  63817. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn); else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn); else emitter._events[event] = [fn, emitter._events[event]];
  63818. }
  63819. function ReadableState(options, stream) {
  63820. Duplex = Duplex || require('./_stream_duplex');
  63821. options = options || {}; // Duplex streams are both readable and writable, but share
  63822. // the same options object.
  63823. // However, some cases require setting options to different
  63824. // values for the readable and the writable sides of the duplex stream.
  63825. // These options can be provided separately as readableXXX and writableXXX.
  63826. var isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to
  63827. // make all the buffer merging and length checks go away
  63828. this.objectMode = !!options.objectMode;
  63829. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
  63830. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  63831. var hwm = options.highWaterMark;
  63832. var readableHwm = options.readableHighWaterMark;
  63833. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  63834. if (hwm || hwm === 0) this.highWaterMark = hwm; else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm; else this.highWaterMark = defaultHwm; // cast to ints.
  63835. this.highWaterMark = Math.floor(this.highWaterMark); // A linked list is used to store data chunks instead of an array because the
  63836. // linked list can remove elements from the beginning faster than
  63837. // array.shift()
  63838. this.buffer = new BufferList();
  63839. this.length = 0;
  63840. this.pipes = null;
  63841. this.pipesCount = 0;
  63842. this.flowing = null;
  63843. this.ended = false;
  63844. this.endEmitted = false;
  63845. this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted
  63846. // immediately, or on a later tick. We set this to true at first, because
  63847. // any actions that shouldn't happen until "later" should generally also
  63848. // not happen before the first read call.
  63849. this.sync = true; // whenever we return null, then we set a flag to say
  63850. // that we're awaiting a 'readable' event emission.
  63851. this.needReadable = false;
  63852. this.emittedReadable = false;
  63853. this.readableListening = false;
  63854. this.resumeScheduled = false; // has it been destroyed
  63855. this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string
  63856. // encoding is 'binary' so we have to make this configurable.
  63857. // Everything else in the universe uses 'utf8', though.
  63858. this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s
  63859. this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
  63860. this.readingMore = false;
  63861. this.decoder = null;
  63862. this.encoding = null;
  63863. if (options.encoding) {
  63864. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  63865. this.decoder = new StringDecoder(options.encoding);
  63866. this.encoding = options.encoding;
  63867. }
  63868. }
  63869. function Readable(options) {
  63870. Duplex = Duplex || require('./_stream_duplex');
  63871. if (!(this instanceof Readable)) return new Readable(options);
  63872. this._readableState = new ReadableState(options, this); // legacy
  63873. this.readable = true;
  63874. if (options) {
  63875. if (typeof options.read === 'function') this._read = options.read;
  63876. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  63877. }
  63878. Stream.call(this);
  63879. }
  63880. Object.defineProperty(Readable.prototype, 'destroyed', {
  63881. get: function get() {
  63882. if (this._readableState === undefined) {
  63883. return false;
  63884. }
  63885. return this._readableState.destroyed;
  63886. },
  63887. set: function set(value) {
  63888. // we ignore the value if the stream
  63889. // has not been initialized yet
  63890. if (!this._readableState) {
  63891. return;
  63892. } // backward compatibility, the user is explicitly
  63893. // managing destroyed
  63894. this._readableState.destroyed = value;
  63895. }
  63896. });
  63897. Readable.prototype.destroy = destroyImpl.destroy;
  63898. Readable.prototype._undestroy = destroyImpl.undestroy;
  63899. Readable.prototype._destroy = function (err, cb) {
  63900. this.push(null);
  63901. cb(err);
  63902. }; // Manually shove something into the read() buffer.
  63903. // This returns true if the highWaterMark has not been hit yet,
  63904. // similar to how Writable.write() returns true if you should
  63905. // write() some more.
  63906. Readable.prototype.push = function (chunk, encoding) {
  63907. var state = this._readableState;
  63908. var skipChunkCheck;
  63909. if (!state.objectMode) {
  63910. if (typeof chunk === 'string') {
  63911. encoding = encoding || state.defaultEncoding;
  63912. if (encoding !== state.encoding) {
  63913. chunk = Buffer.from(chunk, encoding);
  63914. encoding = '';
  63915. }
  63916. skipChunkCheck = true;
  63917. }
  63918. } else {
  63919. skipChunkCheck = true;
  63920. }
  63921. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  63922. }; // Unshift should *always* be something directly out of read()
  63923. Readable.prototype.unshift = function (chunk) {
  63924. return readableAddChunk(this, chunk, null, true, false);
  63925. };
  63926. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  63927. var state = stream._readableState;
  63928. if (chunk === null) {
  63929. state.reading = false;
  63930. onEofChunk(stream, state);
  63931. } else {
  63932. var er;
  63933. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  63934. if (er) {
  63935. stream.emit('error', er);
  63936. } else if (state.objectMode || chunk && chunk.length > 0) {
  63937. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  63938. chunk = _uint8ArrayToBuffer(chunk);
  63939. }
  63940. if (addToFront) {
  63941. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event')); else addChunk(stream, state, chunk, true);
  63942. } else if (state.ended) {
  63943. stream.emit('error', new Error('stream.push() after EOF'));
  63944. } else {
  63945. state.reading = false;
  63946. if (state.decoder && !encoding) {
  63947. chunk = state.decoder.write(chunk);
  63948. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false); else maybeReadMore(stream, state);
  63949. } else {
  63950. addChunk(stream, state, chunk, false);
  63951. }
  63952. }
  63953. } else if (!addToFront) {
  63954. state.reading = false;
  63955. }
  63956. }
  63957. return needMoreData(state);
  63958. }
  63959. function addChunk(stream, state, chunk, addToFront) {
  63960. if (state.flowing && state.length === 0 && !state.sync) {
  63961. stream.emit('data', chunk);
  63962. stream.read(0);
  63963. } else {
  63964. // update the buffer info.
  63965. state.length += state.objectMode ? 1 : chunk.length;
  63966. if (addToFront) state.buffer.unshift(chunk); else state.buffer.push(chunk);
  63967. if (state.needReadable) emitReadable(stream);
  63968. }
  63969. maybeReadMore(stream, state);
  63970. }
  63971. function chunkInvalid(state, chunk) {
  63972. var er;
  63973. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  63974. er = new TypeError('Invalid non-string/buffer chunk');
  63975. }
  63976. return er;
  63977. } // if it's past the high water mark, we can push in some more.
  63978. // Also, if we have no data yet, we can stand some
  63979. // more bytes. This is to work around cases where hwm=0,
  63980. // such as the repl. Also, if the push() triggered a
  63981. // readable event, and the user called read(largeNumber) such that
  63982. // needReadable was set, then we ought to push more, so that another
  63983. // 'readable' event will be triggered.
  63984. function needMoreData(state) {
  63985. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  63986. }
  63987. Readable.prototype.isPaused = function () {
  63988. return this._readableState.flowing === false;
  63989. }; // backwards compatibility.
  63990. Readable.prototype.setEncoding = function (enc) {
  63991. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  63992. this._readableState.decoder = new StringDecoder(enc);
  63993. this._readableState.encoding = enc;
  63994. return this;
  63995. }; // Don't raise the hwm > 8MB
  63996. var MAX_HWM = 0x800000;
  63997. function computeNewHighWaterMark(n) {
  63998. if (n >= MAX_HWM) {
  63999. n = MAX_HWM;
  64000. } else {
  64001. // Get the next highest power of 2 to prevent increasing hwm excessively in
  64002. // tiny amounts
  64003. n--;
  64004. n |= n >>> 1;
  64005. n |= n >>> 2;
  64006. n |= n >>> 4;
  64007. n |= n >>> 8;
  64008. n |= n >>> 16;
  64009. n++;
  64010. }
  64011. return n;
  64012. } // This function is designed to be inlinable, so please take care when making
  64013. // changes to the function body.
  64014. function howMuchToRead(n, state) {
  64015. if (n <= 0 || state.length === 0 && state.ended) return 0;
  64016. if (state.objectMode) return 1;
  64017. if (n !== n) {
  64018. // Only flow one buffer at a time
  64019. if (state.flowing && state.length) return state.buffer.head.data.length; else return state.length;
  64020. } // If we're asking for more than the current hwm, then raise the hwm.
  64021. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  64022. if (n <= state.length) return n; // Don't have enough
  64023. if (!state.ended) {
  64024. state.needReadable = true;
  64025. return 0;
  64026. }
  64027. return state.length;
  64028. } // you can override either this method, or the async _read(n) below.
  64029. Readable.prototype.read = function (n) {
  64030. debug('read', n);
  64031. n = parseInt(n, 10);
  64032. var state = this._readableState;
  64033. var nOrig = n;
  64034. if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we
  64035. // already have a bunch of data in the buffer, then just trigger
  64036. // the 'readable' event and move on.
  64037. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  64038. debug('read: emitReadable', state.length, state.ended);
  64039. if (state.length === 0 && state.ended) endReadable(this); else emitReadable(this);
  64040. return null;
  64041. }
  64042. n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.
  64043. if (n === 0 && state.ended) {
  64044. if (state.length === 0) endReadable(this);
  64045. return null;
  64046. } // All the actual chunk generation logic needs to be
  64047. // *below* the call to _read. The reason is that in certain
  64048. // synthetic stream cases, such as passthrough streams, _read
  64049. // may be a completely synchronous operation which may change
  64050. // the state of the read buffer, providing enough data when
  64051. // before there was *not* enough.
  64052. //
  64053. // So, the steps are:
  64054. // 1. Figure out what the state of things will be after we do
  64055. // a read from the buffer.
  64056. //
  64057. // 2. If that resulting state will trigger a _read, then call _read.
  64058. // Note that this may be asynchronous, or synchronous. Yes, it is
  64059. // deeply ugly to write APIs this way, but that still doesn't mean
  64060. // that the Readable class should behave improperly, as streams are
  64061. // designed to be sync/async agnostic.
  64062. // Take note if the _read call is sync or async (ie, if the read call
  64063. // has returned yet), so that we know whether or not it's safe to emit
  64064. // 'readable' etc.
  64065. //
  64066. // 3. Actually pull the requested chunks out of the buffer and return.
  64067. // if we need a readable event, then we need to do some reading.
  64068. var doRead = state.needReadable;
  64069. debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some
  64070. if (state.length === 0 || state.length - n < state.highWaterMark) {
  64071. doRead = true;
  64072. debug('length less than watermark', doRead);
  64073. } // however, if we've ended, then there's no point, and if we're already
  64074. // reading, then it's unnecessary.
  64075. if (state.ended || state.reading) {
  64076. doRead = false;
  64077. debug('reading or ended', doRead);
  64078. } else if (doRead) {
  64079. debug('do read');
  64080. state.reading = true;
  64081. state.sync = true; // if the length is currently zero, then we *need* a readable event.
  64082. if (state.length === 0) state.needReadable = true; // call internal read method
  64083. this._read(state.highWaterMark);
  64084. state.sync = false; // If _read pushed data synchronously, then `reading` will be false,
  64085. // and we need to re-evaluate how much data we can return to the user.
  64086. if (!state.reading) n = howMuchToRead(nOrig, state);
  64087. }
  64088. var ret;
  64089. if (n > 0) ret = fromList(n, state); else ret = null;
  64090. if (ret === null) {
  64091. state.needReadable = true;
  64092. n = 0;
  64093. } else {
  64094. state.length -= n;
  64095. }
  64096. if (state.length === 0) {
  64097. // If we have nothing in the buffer, then we want to know
  64098. // as soon as we *do* get something into the buffer.
  64099. if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.
  64100. if (nOrig !== n && state.ended) endReadable(this);
  64101. }
  64102. if (ret !== null) this.emit('data', ret);
  64103. return ret;
  64104. };
  64105. function onEofChunk(stream, state) {
  64106. if (state.ended) return;
  64107. if (state.decoder) {
  64108. var chunk = state.decoder.end();
  64109. if (chunk && chunk.length) {
  64110. state.buffer.push(chunk);
  64111. state.length += state.objectMode ? 1 : chunk.length;
  64112. }
  64113. }
  64114. state.ended = true; // emit 'readable' now to make sure it gets picked up.
  64115. emitReadable(stream);
  64116. } // Don't emit readable right away in sync mode, because this can trigger
  64117. // another read() call => stack overflow. This way, it might trigger
  64118. // a nextTick recursion warning, but that's not so bad.
  64119. function emitReadable(stream) {
  64120. var state = stream._readableState;
  64121. state.needReadable = false;
  64122. if (!state.emittedReadable) {
  64123. debug('emitReadable', state.flowing);
  64124. state.emittedReadable = true;
  64125. if (state.sync) pna.nextTick(emitReadable_, stream); else emitReadable_(stream);
  64126. }
  64127. }
  64128. function emitReadable_(stream) {
  64129. debug('emit readable');
  64130. stream.emit('readable');
  64131. flow(stream);
  64132. } // at this point, the user has presumably seen the 'readable' event,
  64133. // and called read() to consume some data. that may have triggered
  64134. // in turn another _read(n) call, in which case reading = true if
  64135. // it's in progress.
  64136. // However, if we're not ended, or reading, and the length < hwm,
  64137. // then go ahead and try to read some more preemptively.
  64138. function maybeReadMore(stream, state) {
  64139. if (!state.readingMore) {
  64140. state.readingMore = true;
  64141. pna.nextTick(maybeReadMore_, stream, state);
  64142. }
  64143. }
  64144. function maybeReadMore_(stream, state) {
  64145. var len = state.length;
  64146. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  64147. debug('maybeReadMore read 0');
  64148. stream.read(0);
  64149. if (len === state.length) // didn't get any data, stop spinning.
  64150. break; else len = state.length;
  64151. }
  64152. state.readingMore = false;
  64153. } // abstract method. to be overridden in specific implementation classes.
  64154. // call cb(er, data) where data is <= n in length.
  64155. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  64156. // arbitrary, and perhaps not very meaningful.
  64157. Readable.prototype._read = function (n) {
  64158. this.emit('error', new Error('_read() is not implemented'));
  64159. };
  64160. Readable.prototype.pipe = function (dest, pipeOpts) {
  64161. var src = this;
  64162. var state = this._readableState;
  64163. switch (state.pipesCount) {
  64164. case 0:
  64165. state.pipes = dest;
  64166. break;
  64167. case 1:
  64168. state.pipes = [state.pipes, dest];
  64169. break;
  64170. default:
  64171. state.pipes.push(dest);
  64172. break;
  64173. }
  64174. state.pipesCount += 1;
  64175. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  64176. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  64177. var endFn = doEnd ? onend : unpipe;
  64178. if (state.endEmitted) pna.nextTick(endFn); else src.once('end', endFn);
  64179. dest.on('unpipe', onunpipe);
  64180. function onunpipe(readable, unpipeInfo) {
  64181. debug('onunpipe');
  64182. if (readable === src) {
  64183. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  64184. unpipeInfo.hasUnpiped = true;
  64185. cleanup();
  64186. }
  64187. }
  64188. }
  64189. function onend() {
  64190. debug('onend');
  64191. dest.end();
  64192. } // when the dest drains, it reduces the awaitDrain counter
  64193. // on the source. This would be more elegant with a .once()
  64194. // handler in flow(), but adding and removing repeatedly is
  64195. // too slow.
  64196. var ondrain = pipeOnDrain(src);
  64197. dest.on('drain', ondrain);
  64198. var cleanedUp = false;
  64199. function cleanup() {
  64200. debug('cleanup'); // cleanup event handlers once the pipe is broken
  64201. dest.removeListener('close', onclose);
  64202. dest.removeListener('finish', onfinish);
  64203. dest.removeListener('drain', ondrain);
  64204. dest.removeListener('error', onerror);
  64205. dest.removeListener('unpipe', onunpipe);
  64206. src.removeListener('end', onend);
  64207. src.removeListener('end', unpipe);
  64208. src.removeListener('data', ondata);
  64209. cleanedUp = true; // if the reader is waiting for a drain event from this
  64210. // specific writer, then it would cause it to never start
  64211. // flowing again.
  64212. // So, if this is awaiting a drain, then we just call it now.
  64213. // If we don't know, then assume that we are waiting for one.
  64214. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  64215. } // If the user pushes more data while we're writing to dest then we'll end up
  64216. // in ondata again. However, we only want to increase awaitDrain once because
  64217. // dest will only emit one 'drain' event for the multiple writes.
  64218. // => Introduce a guard on increasing awaitDrain.
  64219. var increasedAwaitDrain = false;
  64220. src.on('data', ondata);
  64221. function ondata(chunk) {
  64222. debug('ondata');
  64223. increasedAwaitDrain = false;
  64224. var ret = dest.write(chunk);
  64225. if (false === ret && !increasedAwaitDrain) {
  64226. // If the user unpiped during `dest.write()`, it is possible
  64227. // to get stuck in a permanently paused state if that write
  64228. // also returned false.
  64229. // => Check whether `dest` is still a piping destination.
  64230. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  64231. debug('false write response, pause', src._readableState.awaitDrain);
  64232. src._readableState.awaitDrain++;
  64233. increasedAwaitDrain = true;
  64234. }
  64235. src.pause();
  64236. }
  64237. } // if the dest has an error, then stop piping into it.
  64238. // however, don't suppress the throwing behavior for this.
  64239. function onerror(er) {
  64240. debug('onerror', er);
  64241. unpipe();
  64242. dest.removeListener('error', onerror);
  64243. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  64244. } // Make sure our error handler is attached before userland ones.
  64245. prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.
  64246. function onclose() {
  64247. dest.removeListener('finish', onfinish);
  64248. unpipe();
  64249. }
  64250. dest.once('close', onclose);
  64251. function onfinish() {
  64252. debug('onfinish');
  64253. dest.removeListener('close', onclose);
  64254. unpipe();
  64255. }
  64256. dest.once('finish', onfinish);
  64257. function unpipe() {
  64258. debug('unpipe');
  64259. src.unpipe(dest);
  64260. } // tell the dest that it's being piped to
  64261. dest.emit('pipe', src); // start the flow if it hasn't been started already.
  64262. if (!state.flowing) {
  64263. debug('pipe resume');
  64264. src.resume();
  64265. }
  64266. return dest;
  64267. };
  64268. function pipeOnDrain(src) {
  64269. return function () {
  64270. var state = src._readableState;
  64271. debug('pipeOnDrain', state.awaitDrain);
  64272. if (state.awaitDrain) state.awaitDrain--;
  64273. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  64274. state.flowing = true;
  64275. flow(src);
  64276. }
  64277. };
  64278. }
  64279. Readable.prototype.unpipe = function (dest) {
  64280. var state = this._readableState;
  64281. var unpipeInfo = {
  64282. hasUnpiped: false
  64283. }; // if we're not piping anywhere, then do nothing.
  64284. if (state.pipesCount === 0) return this; // just one destination. most common case.
  64285. if (state.pipesCount === 1) {
  64286. // passed in one, but it's not the right one.
  64287. if (dest && dest !== state.pipes) return this;
  64288. if (!dest) dest = state.pipes; // got a match.
  64289. state.pipes = null;
  64290. state.pipesCount = 0;
  64291. state.flowing = false;
  64292. if (dest) dest.emit('unpipe', this, unpipeInfo);
  64293. return this;
  64294. } // slow case. multiple pipe destinations.
  64295. if (!dest) {
  64296. // remove all.
  64297. var dests = state.pipes;
  64298. var len = state.pipesCount;
  64299. state.pipes = null;
  64300. state.pipesCount = 0;
  64301. state.flowing = false;
  64302. for (var i = 0; i < len; i++) {
  64303. dests[i].emit('unpipe', this, unpipeInfo);
  64304. }
  64305. return this;
  64306. } // try to find the right one.
  64307. var index = indexOf(state.pipes, dest);
  64308. if (index === -1) return this;
  64309. state.pipes.splice(index, 1);
  64310. state.pipesCount -= 1;
  64311. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  64312. dest.emit('unpipe', this, unpipeInfo);
  64313. return this;
  64314. }; // set up data events if they are asked for
  64315. // Ensure readable listeners eventually get something
  64316. Readable.prototype.on = function (ev, fn) {
  64317. var res = Stream.prototype.on.call(this, ev, fn);
  64318. if (ev === 'data') {
  64319. // Start flowing on next tick if stream isn't explicitly paused
  64320. if (this._readableState.flowing !== false) this.resume();
  64321. } else if (ev === 'readable') {
  64322. var state = this._readableState;
  64323. if (!state.endEmitted && !state.readableListening) {
  64324. state.readableListening = state.needReadable = true;
  64325. state.emittedReadable = false;
  64326. if (!state.reading) {
  64327. pna.nextTick(nReadingNextTick, this);
  64328. } else if (state.length) {
  64329. emitReadable(this);
  64330. }
  64331. }
  64332. }
  64333. return res;
  64334. };
  64335. Readable.prototype.addListener = Readable.prototype.on;
  64336. function nReadingNextTick(self) {
  64337. debug('readable nexttick read 0');
  64338. self.read(0);
  64339. } // pause() and resume() are remnants of the legacy readable stream API
  64340. // If the user uses them, then switch into old mode.
  64341. Readable.prototype.resume = function () {
  64342. var state = this._readableState;
  64343. if (!state.flowing) {
  64344. debug('resume');
  64345. state.flowing = true;
  64346. resume(this, state);
  64347. }
  64348. return this;
  64349. };
  64350. function resume(stream, state) {
  64351. if (!state.resumeScheduled) {
  64352. state.resumeScheduled = true;
  64353. pna.nextTick(resume_, stream, state);
  64354. }
  64355. }
  64356. function resume_(stream, state) {
  64357. if (!state.reading) {
  64358. debug('resume read 0');
  64359. stream.read(0);
  64360. }
  64361. state.resumeScheduled = false;
  64362. state.awaitDrain = 0;
  64363. stream.emit('resume');
  64364. flow(stream);
  64365. if (state.flowing && !state.reading) stream.read(0);
  64366. }
  64367. Readable.prototype.pause = function () {
  64368. debug('call pause flowing=%j', this._readableState.flowing);
  64369. if (false !== this._readableState.flowing) {
  64370. debug('pause');
  64371. this._readableState.flowing = false;
  64372. this.emit('pause');
  64373. }
  64374. return this;
  64375. };
  64376. function flow(stream) {
  64377. var state = stream._readableState;
  64378. debug('flow', state.flowing);
  64379. while (state.flowing && stream.read() !== null) { }
  64380. } // wrap an old-style stream as the async data source.
  64381. // This is *not* part of the readable stream interface.
  64382. // It is an ugly unfortunate mess of history.
  64383. Readable.prototype.wrap = function (stream) {
  64384. var _this = this;
  64385. var state = this._readableState;
  64386. var paused = false;
  64387. stream.on('end', function () {
  64388. debug('wrapped end');
  64389. if (state.decoder && !state.ended) {
  64390. var chunk = state.decoder.end();
  64391. if (chunk && chunk.length) _this.push(chunk);
  64392. }
  64393. _this.push(null);
  64394. });
  64395. stream.on('data', function (chunk) {
  64396. debug('wrapped data');
  64397. if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode
  64398. if (state.objectMode && (chunk === null || chunk === undefined)) return; else if (!state.objectMode && (!chunk || !chunk.length)) return;
  64399. var ret = _this.push(chunk);
  64400. if (!ret) {
  64401. paused = true;
  64402. stream.pause();
  64403. }
  64404. }); // proxy all the other methods.
  64405. // important when wrapping filters and duplexes.
  64406. for (var i in stream) {
  64407. if (this[i] === undefined && typeof stream[i] === 'function') {
  64408. this[i] = function (method) {
  64409. return function () {
  64410. return stream[method].apply(stream, arguments);
  64411. };
  64412. }(i);
  64413. }
  64414. } // proxy certain important events.
  64415. for (var n = 0; n < kProxyEvents.length; n++) {
  64416. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  64417. } // when we try to consume some more bytes, simply unpause the
  64418. // underlying stream.
  64419. this._read = function (n) {
  64420. debug('wrapped _read', n);
  64421. if (paused) {
  64422. paused = false;
  64423. stream.resume();
  64424. }
  64425. };
  64426. return this;
  64427. };
  64428. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  64429. // making it explicit this property is not enumerable
  64430. // because otherwise some prototype manipulation in
  64431. // userland will fail
  64432. enumerable: false,
  64433. get: function get() {
  64434. return this._readableState.highWaterMark;
  64435. }
  64436. }); // exposed for testing purposes only.
  64437. Readable._fromList = fromList; // Pluck off n bytes from an array of buffers.
  64438. // Length is the combined lengths of all the buffers in the list.
  64439. // This function is designed to be inlinable, so please take care when making
  64440. // changes to the function body.
  64441. function fromList(n, state) {
  64442. // nothing buffered
  64443. if (state.length === 0) return null;
  64444. var ret;
  64445. if (state.objectMode) ret = state.buffer.shift(); else if (!n || n >= state.length) {
  64446. // read it all, truncate the list
  64447. if (state.decoder) ret = state.buffer.join(''); else if (state.buffer.length === 1) ret = state.buffer.head.data; else ret = state.buffer.concat(state.length);
  64448. state.buffer.clear();
  64449. } else {
  64450. // read part of list
  64451. ret = fromListPartial(n, state.buffer, state.decoder);
  64452. }
  64453. return ret;
  64454. } // Extracts only enough buffered data to satisfy the amount requested.
  64455. // This function is designed to be inlinable, so please take care when making
  64456. // changes to the function body.
  64457. function fromListPartial(n, list, hasStrings) {
  64458. var ret;
  64459. if (n < list.head.data.length) {
  64460. // slice is the same for buffers and strings
  64461. ret = list.head.data.slice(0, n);
  64462. list.head.data = list.head.data.slice(n);
  64463. } else if (n === list.head.data.length) {
  64464. // first chunk is a perfect match
  64465. ret = list.shift();
  64466. } else {
  64467. // result spans more than one buffer
  64468. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  64469. }
  64470. return ret;
  64471. } // Copies a specified amount of characters from the list of buffered data
  64472. // chunks.
  64473. // This function is designed to be inlinable, so please take care when making
  64474. // changes to the function body.
  64475. function copyFromBufferString(n, list) {
  64476. var p = list.head;
  64477. var c = 1;
  64478. var ret = p.data;
  64479. n -= ret.length;
  64480. while (p = p.next) {
  64481. var str = p.data;
  64482. var nb = n > str.length ? str.length : n;
  64483. if (nb === str.length) ret += str; else ret += str.slice(0, n);
  64484. n -= nb;
  64485. if (n === 0) {
  64486. if (nb === str.length) {
  64487. ++c;
  64488. if (p.next) list.head = p.next; else list.head = list.tail = null;
  64489. } else {
  64490. list.head = p;
  64491. p.data = str.slice(nb);
  64492. }
  64493. break;
  64494. }
  64495. ++c;
  64496. }
  64497. list.length -= c;
  64498. return ret;
  64499. } // Copies a specified amount of bytes from the list of buffered data chunks.
  64500. // This function is designed to be inlinable, so please take care when making
  64501. // changes to the function body.
  64502. function copyFromBuffer(n, list) {
  64503. var ret = Buffer.allocUnsafe(n);
  64504. var p = list.head;
  64505. var c = 1;
  64506. p.data.copy(ret);
  64507. n -= p.data.length;
  64508. while (p = p.next) {
  64509. var buf = p.data;
  64510. var nb = n > buf.length ? buf.length : n;
  64511. buf.copy(ret, ret.length - n, 0, nb);
  64512. n -= nb;
  64513. if (n === 0) {
  64514. if (nb === buf.length) {
  64515. ++c;
  64516. if (p.next) list.head = p.next; else list.head = list.tail = null;
  64517. } else {
  64518. list.head = p;
  64519. p.data = buf.slice(nb);
  64520. }
  64521. break;
  64522. }
  64523. ++c;
  64524. }
  64525. list.length -= c;
  64526. return ret;
  64527. }
  64528. function endReadable(stream) {
  64529. var state = stream._readableState; // If we get here before consuming all the bytes, then that is a
  64530. // bug in node. Should never happen.
  64531. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  64532. if (!state.endEmitted) {
  64533. state.ended = true;
  64534. pna.nextTick(endReadableNT, state, stream);
  64535. }
  64536. }
  64537. function endReadableNT(state, stream) {
  64538. // Check that we didn't get one last unshift.
  64539. if (!state.endEmitted && state.length === 0) {
  64540. state.endEmitted = true;
  64541. stream.readable = false;
  64542. stream.emit('end');
  64543. }
  64544. }
  64545. function indexOf(xs, x) {
  64546. for (var i = 0, l = xs.length; i < l; i++) {
  64547. if (xs[i] === x) return i;
  64548. }
  64549. return -1;
  64550. }
  64551. }).call(this, require('_process'), typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  64552. }, { "./_stream_duplex": 508, "./internal/streams/BufferList": 513, "./internal/streams/destroy": 514, "./internal/streams/stream": 515, "_process": 467, "core-util-is": 328, "events": 367, "inherits": 387, "isarray": 389, "process-nextick-args": 466, "safe-buffer": 494, "string_decoder/": 520, "util": 185 }], 511: [function (require, module, exports) {
  64553. // Copyright Joyent, Inc. and other Node contributors.
  64554. //
  64555. // Permission is hereby granted, free of charge, to any person obtaining a
  64556. // copy of this software and associated documentation files (the
  64557. // "Software"), to deal in the Software without restriction, including
  64558. // without limitation the rights to use, copy, modify, merge, publish,
  64559. // distribute, sublicense, and/or sell copies of the Software, and to permit
  64560. // persons to whom the Software is furnished to do so, subject to the
  64561. // following conditions:
  64562. //
  64563. // The above copyright notice and this permission notice shall be included
  64564. // in all copies or substantial portions of the Software.
  64565. //
  64566. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  64567. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  64568. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  64569. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  64570. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  64571. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  64572. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  64573. // a transform stream is a readable/writable stream where you do
  64574. // something with the data. Sometimes it's called a "filter",
  64575. // but that's not a great name for it, since that implies a thing where
  64576. // some bits pass through, and others are simply ignored. (That would
  64577. // be a valid example of a transform, of course.)
  64578. //
  64579. // While the output is causally related to the input, it's not a
  64580. // necessarily symmetric or synchronous transformation. For example,
  64581. // a zlib stream might take multiple plain-text writes(), and then
  64582. // emit a single compressed chunk some time in the future.
  64583. //
  64584. // Here's how this works:
  64585. //
  64586. // The Transform stream has all the aspects of the readable and writable
  64587. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  64588. // internally, and returns false if there's a lot of pending writes
  64589. // buffered up. When you call read(), that calls _read(n) until
  64590. // there's enough pending readable data buffered up.
  64591. //
  64592. // In a transform stream, the written data is placed in a buffer. When
  64593. // _read(n) is called, it transforms the queued up data, calling the
  64594. // buffered _write cb's as it consumes chunks. If consuming a single
  64595. // written chunk would result in multiple output chunks, then the first
  64596. // outputted bit calls the readcb, and subsequent chunks just go into
  64597. // the read buffer, and will cause it to emit 'readable' if necessary.
  64598. //
  64599. // This way, back-pressure is actually determined by the reading side,
  64600. // since _read has to be called to start processing a new chunk. However,
  64601. // a pathological inflate type of transform can cause excessive buffering
  64602. // here. For example, imagine a stream where every byte of input is
  64603. // interpreted as an integer from 0-255, and then results in that many
  64604. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  64605. // 1kb of data being output. In this case, you could write a very small
  64606. // amount of input, and end up with a very large amount of output. In
  64607. // such a pathological inflating mechanism, there'd be no way to tell
  64608. // the system to stop doing the transform. A single 4MB write could
  64609. // cause the system to run out of memory.
  64610. //
  64611. // However, even in such a pathological case, only a single written chunk
  64612. // would be consumed, and then the rest would wait (un-transformed) until
  64613. // the results of the previous transformed chunk were consumed.
  64614. 'use strict';
  64615. module.exports = Transform;
  64616. var Duplex = require('./_stream_duplex');
  64617. /*<replacement>*/
  64618. var util = Object.create(require('core-util-is'));
  64619. util.inherits = require('inherits');
  64620. /*</replacement>*/
  64621. util.inherits(Transform, Duplex);
  64622. function afterTransform(er, data) {
  64623. var ts = this._transformState;
  64624. ts.transforming = false;
  64625. var cb = ts.writecb;
  64626. if (!cb) {
  64627. return this.emit('error', new Error('write callback called multiple times'));
  64628. }
  64629. ts.writechunk = null;
  64630. ts.writecb = null;
  64631. if (data != null) // single equals check for both `null` and `undefined`
  64632. this.push(data);
  64633. cb(er);
  64634. var rs = this._readableState;
  64635. rs.reading = false;
  64636. if (rs.needReadable || rs.length < rs.highWaterMark) {
  64637. this._read(rs.highWaterMark);
  64638. }
  64639. }
  64640. function Transform(options) {
  64641. if (!(this instanceof Transform)) return new Transform(options);
  64642. Duplex.call(this, options);
  64643. this._transformState = {
  64644. afterTransform: afterTransform.bind(this),
  64645. needTransform: false,
  64646. transforming: false,
  64647. writecb: null,
  64648. writechunk: null,
  64649. writeencoding: null
  64650. }; // start out asking for a readable event once data is transformed.
  64651. this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
  64652. // that Readable wants before the first _read call, so unset the
  64653. // sync guard flag.
  64654. this._readableState.sync = false;
  64655. if (options) {
  64656. if (typeof options.transform === 'function') this._transform = options.transform;
  64657. if (typeof options.flush === 'function') this._flush = options.flush;
  64658. } // When the writable side finishes, then flush out anything remaining.
  64659. this.on('prefinish', prefinish);
  64660. }
  64661. function prefinish() {
  64662. var _this = this;
  64663. if (typeof this._flush === 'function') {
  64664. this._flush(function (er, data) {
  64665. done(_this, er, data);
  64666. });
  64667. } else {
  64668. done(this, null, null);
  64669. }
  64670. }
  64671. Transform.prototype.push = function (chunk, encoding) {
  64672. this._transformState.needTransform = false;
  64673. return Duplex.prototype.push.call(this, chunk, encoding);
  64674. }; // This is the part where you do stuff!
  64675. // override this function in implementation classes.
  64676. // 'chunk' is an input chunk.
  64677. //
  64678. // Call `push(newChunk)` to pass along transformed output
  64679. // to the readable side. You may call 'push' zero or more times.
  64680. //
  64681. // Call `cb(err)` when you are done with this chunk. If you pass
  64682. // an error, then that'll put the hurt on the whole operation. If you
  64683. // never call cb(), then you'll never get another chunk.
  64684. Transform.prototype._transform = function (chunk, encoding, cb) {
  64685. throw new Error('_transform() is not implemented');
  64686. };
  64687. Transform.prototype._write = function (chunk, encoding, cb) {
  64688. var ts = this._transformState;
  64689. ts.writecb = cb;
  64690. ts.writechunk = chunk;
  64691. ts.writeencoding = encoding;
  64692. if (!ts.transforming) {
  64693. var rs = this._readableState;
  64694. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  64695. }
  64696. }; // Doesn't matter what the args are here.
  64697. // _transform does all the work.
  64698. // That we got here means that the readable side wants more data.
  64699. Transform.prototype._read = function (n) {
  64700. var ts = this._transformState;
  64701. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  64702. ts.transforming = true;
  64703. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  64704. } else {
  64705. // mark that we need a transform, so that any data that comes in
  64706. // will get processed, now that we've asked for it.
  64707. ts.needTransform = true;
  64708. }
  64709. };
  64710. Transform.prototype._destroy = function (err, cb) {
  64711. var _this2 = this;
  64712. Duplex.prototype._destroy.call(this, err, function (err2) {
  64713. cb(err2);
  64714. _this2.emit('close');
  64715. });
  64716. };
  64717. function done(stream, er, data) {
  64718. if (er) return stream.emit('error', er);
  64719. if (data != null) // single equals check for both `null` and `undefined`
  64720. stream.push(data); // if there's nothing in the write buffer, then that means
  64721. // that nothing more will ever be provided
  64722. if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
  64723. if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
  64724. return stream.push(null);
  64725. }
  64726. }, { "./_stream_duplex": 508, "core-util-is": 328, "inherits": 387 }], 512: [function (require, module, exports) {
  64727. (function (process, global, setImmediate) {
  64728. // Copyright Joyent, Inc. and other Node contributors.
  64729. //
  64730. // Permission is hereby granted, free of charge, to any person obtaining a
  64731. // copy of this software and associated documentation files (the
  64732. // "Software"), to deal in the Software without restriction, including
  64733. // without limitation the rights to use, copy, modify, merge, publish,
  64734. // distribute, sublicense, and/or sell copies of the Software, and to permit
  64735. // persons to whom the Software is furnished to do so, subject to the
  64736. // following conditions:
  64737. //
  64738. // The above copyright notice and this permission notice shall be included
  64739. // in all copies or substantial portions of the Software.
  64740. //
  64741. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  64742. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  64743. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  64744. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  64745. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  64746. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  64747. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  64748. // A bit simpler than readable streams.
  64749. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  64750. // the drain event emission and buffering.
  64751. 'use strict';
  64752. /*<replacement>*/
  64753. var pna = require('process-nextick-args');
  64754. /*</replacement>*/
  64755. module.exports = Writable;
  64756. /* <replacement> */
  64757. function WriteReq(chunk, encoding, cb) {
  64758. this.chunk = chunk;
  64759. this.encoding = encoding;
  64760. this.callback = cb;
  64761. this.next = null;
  64762. } // It seems a linked list but it is not
  64763. // there will be only 2 of these for each stream
  64764. function CorkedRequest(state) {
  64765. var _this = this;
  64766. this.next = null;
  64767. this.entry = null;
  64768. this.finish = function () {
  64769. onCorkedFinish(_this, state);
  64770. };
  64771. }
  64772. /* </replacement> */
  64773. /*<replacement>*/
  64774. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
  64775. /*</replacement>*/
  64776. /*<replacement>*/
  64777. var Duplex;
  64778. /*</replacement>*/
  64779. Writable.WritableState = WritableState;
  64780. /*<replacement>*/
  64781. var util = Object.create(require('core-util-is'));
  64782. util.inherits = require('inherits');
  64783. /*</replacement>*/
  64784. /*<replacement>*/
  64785. var internalUtil = {
  64786. deprecate: require('util-deprecate')
  64787. };
  64788. /*</replacement>*/
  64789. /*<replacement>*/
  64790. var Stream = require('./internal/streams/stream');
  64791. /*</replacement>*/
  64792. /*<replacement>*/
  64793. var Buffer = require('safe-buffer').Buffer;
  64794. var OurUint8Array = global.Uint8Array || function () { };
  64795. function _uint8ArrayToBuffer(chunk) {
  64796. return Buffer.from(chunk);
  64797. }
  64798. function _isUint8Array(obj) {
  64799. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  64800. }
  64801. /*</replacement>*/
  64802. var destroyImpl = require('./internal/streams/destroy');
  64803. util.inherits(Writable, Stream);
  64804. function nop() { }
  64805. function WritableState(options, stream) {
  64806. Duplex = Duplex || require('./_stream_duplex');
  64807. options = options || {}; // Duplex streams are both readable and writable, but share
  64808. // the same options object.
  64809. // However, some cases require setting options to different
  64810. // values for the readable and the writable sides of the duplex stream.
  64811. // These options can be provided separately as readableXXX and writableXXX.
  64812. var isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
  64813. // contains buffers or objects.
  64814. this.objectMode = !!options.objectMode;
  64815. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
  64816. // Note: 0 is a valid value, means that we always return false if
  64817. // the entire buffer is not flushed immediately on write()
  64818. var hwm = options.highWaterMark;
  64819. var writableHwm = options.writableHighWaterMark;
  64820. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  64821. if (hwm || hwm === 0) this.highWaterMark = hwm; else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm; else this.highWaterMark = defaultHwm; // cast to ints.
  64822. this.highWaterMark = Math.floor(this.highWaterMark); // if _final has been called
  64823. this.finalCalled = false; // drain event flag.
  64824. this.needDrain = false; // at the start of calling end()
  64825. this.ending = false; // when end() has been called, and returned
  64826. this.ended = false; // when 'finish' is emitted
  64827. this.finished = false; // has it been destroyed
  64828. this.destroyed = false; // should we decode strings into buffers before passing to _write?
  64829. // this is here so that some node-core streams can optimize string
  64830. // handling at a lower level.
  64831. var noDecode = options.decodeStrings === false;
  64832. this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string
  64833. // encoding is 'binary' so we have to make this configurable.
  64834. // Everything else in the universe uses 'utf8', though.
  64835. this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
  64836. // of how much we're waiting to get pushed to some underlying
  64837. // socket or file.
  64838. this.length = 0; // a flag to see when we're in the middle of a write.
  64839. this.writing = false; // when true all writes will be buffered until .uncork() call
  64840. this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
  64841. // or on a later tick. We set this to true at first, because any
  64842. // actions that shouldn't happen until "later" should generally also
  64843. // not happen before the first write call.
  64844. this.sync = true; // a flag to know if we're processing previously buffered items, which
  64845. // may call the _write() callback in the same tick, so that we don't
  64846. // end up in an overlapped onwrite situation.
  64847. this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
  64848. this.onwrite = function (er) {
  64849. onwrite(stream, er);
  64850. }; // the callback that the user supplies to write(chunk,encoding,cb)
  64851. this.writecb = null; // the amount that is being written when _write is called.
  64852. this.writelen = 0;
  64853. this.bufferedRequest = null;
  64854. this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
  64855. // this must be 0 before 'finish' can be emitted
  64856. this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
  64857. // This is relevant for synchronous Transform streams
  64858. this.prefinished = false; // True if the error was already emitted and should not be thrown again
  64859. this.errorEmitted = false; // count buffered requests
  64860. this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
  64861. // one allocated and free to use, and we maintain at most two
  64862. this.corkedRequestsFree = new CorkedRequest(this);
  64863. }
  64864. WritableState.prototype.getBuffer = function getBuffer() {
  64865. var current = this.bufferedRequest;
  64866. var out = [];
  64867. while (current) {
  64868. out.push(current);
  64869. current = current.next;
  64870. }
  64871. return out;
  64872. };
  64873. (function () {
  64874. try {
  64875. Object.defineProperty(WritableState.prototype, 'buffer', {
  64876. get: internalUtil.deprecate(function () {
  64877. return this.getBuffer();
  64878. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  64879. });
  64880. } catch (_) { }
  64881. })(); // Test _writableState for inheritance to account for Duplex streams,
  64882. // whose prototype chain only points to Readable.
  64883. var realHasInstance;
  64884. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  64885. realHasInstance = Function.prototype[Symbol.hasInstance];
  64886. Object.defineProperty(Writable, Symbol.hasInstance, {
  64887. value: function value(object) {
  64888. if (realHasInstance.call(this, object)) return true;
  64889. if (this !== Writable) return false;
  64890. return object && object._writableState instanceof WritableState;
  64891. }
  64892. });
  64893. } else {
  64894. realHasInstance = function realHasInstance(object) {
  64895. return object instanceof this;
  64896. };
  64897. }
  64898. function Writable(options) {
  64899. Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.
  64900. // `realHasInstance` is necessary because using plain `instanceof`
  64901. // would return false, as no `_writableState` property is attached.
  64902. // Trying to use the custom `instanceof` for Writable here will also break the
  64903. // Node.js LazyTransform implementation, which has a non-trivial getter for
  64904. // `_writableState` that would lead to infinite recursion.
  64905. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  64906. return new Writable(options);
  64907. }
  64908. this._writableState = new WritableState(options, this); // legacy.
  64909. this.writable = true;
  64910. if (options) {
  64911. if (typeof options.write === 'function') this._write = options.write;
  64912. if (typeof options.writev === 'function') this._writev = options.writev;
  64913. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  64914. if (typeof options.final === 'function') this._final = options.final;
  64915. }
  64916. Stream.call(this);
  64917. } // Otherwise people can pipe Writable streams, which is just wrong.
  64918. Writable.prototype.pipe = function () {
  64919. this.emit('error', new Error('Cannot pipe, not readable'));
  64920. };
  64921. function writeAfterEnd(stream, cb) {
  64922. var er = new Error('write after end'); // TODO: defer error events consistently everywhere, not just the cb
  64923. stream.emit('error', er);
  64924. pna.nextTick(cb, er);
  64925. } // Checks that a user-supplied chunk is valid, especially for the particular
  64926. // mode the stream is in. Currently this means that `null` is never accepted
  64927. // and undefined/non-string values are only allowed in object mode.
  64928. function validChunk(stream, state, chunk, cb) {
  64929. var valid = true;
  64930. var er = false;
  64931. if (chunk === null) {
  64932. er = new TypeError('May not write null values to stream');
  64933. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  64934. er = new TypeError('Invalid non-string/buffer chunk');
  64935. }
  64936. if (er) {
  64937. stream.emit('error', er);
  64938. pna.nextTick(cb, er);
  64939. valid = false;
  64940. }
  64941. return valid;
  64942. }
  64943. Writable.prototype.write = function (chunk, encoding, cb) {
  64944. var state = this._writableState;
  64945. var ret = false;
  64946. var isBuf = !state.objectMode && _isUint8Array(chunk);
  64947. if (isBuf && !Buffer.isBuffer(chunk)) {
  64948. chunk = _uint8ArrayToBuffer(chunk);
  64949. }
  64950. if (typeof encoding === 'function') {
  64951. cb = encoding;
  64952. encoding = null;
  64953. }
  64954. if (isBuf) encoding = 'buffer'; else if (!encoding) encoding = state.defaultEncoding;
  64955. if (typeof cb !== 'function') cb = nop;
  64956. if (state.ended) writeAfterEnd(this, cb); else if (isBuf || validChunk(this, state, chunk, cb)) {
  64957. state.pendingcb++;
  64958. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  64959. }
  64960. return ret;
  64961. };
  64962. Writable.prototype.cork = function () {
  64963. var state = this._writableState;
  64964. state.corked++;
  64965. };
  64966. Writable.prototype.uncork = function () {
  64967. var state = this._writableState;
  64968. if (state.corked) {
  64969. state.corked--;
  64970. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  64971. }
  64972. };
  64973. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  64974. // node::ParseEncoding() requires lower case.
  64975. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  64976. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
  64977. this._writableState.defaultEncoding = encoding;
  64978. return this;
  64979. };
  64980. function decodeChunk(state, chunk, encoding) {
  64981. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  64982. chunk = Buffer.from(chunk, encoding);
  64983. }
  64984. return chunk;
  64985. }
  64986. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  64987. // making it explicit this property is not enumerable
  64988. // because otherwise some prototype manipulation in
  64989. // userland will fail
  64990. enumerable: false,
  64991. get: function get() {
  64992. return this._writableState.highWaterMark;
  64993. }
  64994. }); // if we're already writing something, then just put this
  64995. // in the queue, and wait our turn. Otherwise, call _write
  64996. // If we return false, then we need a drain event, so set that flag.
  64997. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  64998. if (!isBuf) {
  64999. var newChunk = decodeChunk(state, chunk, encoding);
  65000. if (chunk !== newChunk) {
  65001. isBuf = true;
  65002. encoding = 'buffer';
  65003. chunk = newChunk;
  65004. }
  65005. }
  65006. var len = state.objectMode ? 1 : chunk.length;
  65007. state.length += len;
  65008. var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
  65009. if (!ret) state.needDrain = true;
  65010. if (state.writing || state.corked) {
  65011. var last = state.lastBufferedRequest;
  65012. state.lastBufferedRequest = {
  65013. chunk: chunk,
  65014. encoding: encoding,
  65015. isBuf: isBuf,
  65016. callback: cb,
  65017. next: null
  65018. };
  65019. if (last) {
  65020. last.next = state.lastBufferedRequest;
  65021. } else {
  65022. state.bufferedRequest = state.lastBufferedRequest;
  65023. }
  65024. state.bufferedRequestCount += 1;
  65025. } else {
  65026. doWrite(stream, state, false, len, chunk, encoding, cb);
  65027. }
  65028. return ret;
  65029. }
  65030. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  65031. state.writelen = len;
  65032. state.writecb = cb;
  65033. state.writing = true;
  65034. state.sync = true;
  65035. if (writev) stream._writev(chunk, state.onwrite); else stream._write(chunk, encoding, state.onwrite);
  65036. state.sync = false;
  65037. }
  65038. function onwriteError(stream, state, sync, er, cb) {
  65039. --state.pendingcb;
  65040. if (sync) {
  65041. // defer the callback if we are being called synchronously
  65042. // to avoid piling up things on the stack
  65043. pna.nextTick(cb, er); // this can emit finish, and it will always happen
  65044. // after error
  65045. pna.nextTick(finishMaybe, stream, state);
  65046. stream._writableState.errorEmitted = true;
  65047. stream.emit('error', er);
  65048. } else {
  65049. // the caller expect this to happen before if
  65050. // it is async
  65051. cb(er);
  65052. stream._writableState.errorEmitted = true;
  65053. stream.emit('error', er); // this can emit finish, but finish must
  65054. // always follow error
  65055. finishMaybe(stream, state);
  65056. }
  65057. }
  65058. function onwriteStateUpdate(state) {
  65059. state.writing = false;
  65060. state.writecb = null;
  65061. state.length -= state.writelen;
  65062. state.writelen = 0;
  65063. }
  65064. function onwrite(stream, er) {
  65065. var state = stream._writableState;
  65066. var sync = state.sync;
  65067. var cb = state.writecb;
  65068. onwriteStateUpdate(state);
  65069. if (er) onwriteError(stream, state, sync, er, cb); else {
  65070. // Check if we're actually ready to finish, but don't emit yet
  65071. var finished = needFinish(state);
  65072. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  65073. clearBuffer(stream, state);
  65074. }
  65075. if (sync) {
  65076. /*<replacement>*/
  65077. asyncWrite(afterWrite, stream, state, finished, cb);
  65078. /*</replacement>*/
  65079. } else {
  65080. afterWrite(stream, state, finished, cb);
  65081. }
  65082. }
  65083. }
  65084. function afterWrite(stream, state, finished, cb) {
  65085. if (!finished) onwriteDrain(stream, state);
  65086. state.pendingcb--;
  65087. cb();
  65088. finishMaybe(stream, state);
  65089. } // Must force callback to be called on nextTick, so that we don't
  65090. // emit 'drain' before the write() consumer gets the 'false' return
  65091. // value, and has a chance to attach a 'drain' listener.
  65092. function onwriteDrain(stream, state) {
  65093. if (state.length === 0 && state.needDrain) {
  65094. state.needDrain = false;
  65095. stream.emit('drain');
  65096. }
  65097. } // if there's something in the buffer waiting, then process it
  65098. function clearBuffer(stream, state) {
  65099. state.bufferProcessing = true;
  65100. var entry = state.bufferedRequest;
  65101. if (stream._writev && entry && entry.next) {
  65102. // Fast case, write everything using _writev()
  65103. var l = state.bufferedRequestCount;
  65104. var buffer = new Array(l);
  65105. var holder = state.corkedRequestsFree;
  65106. holder.entry = entry;
  65107. var count = 0;
  65108. var allBuffers = true;
  65109. while (entry) {
  65110. buffer[count] = entry;
  65111. if (!entry.isBuf) allBuffers = false;
  65112. entry = entry.next;
  65113. count += 1;
  65114. }
  65115. buffer.allBuffers = allBuffers;
  65116. doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
  65117. // as the hot path ends with doWrite
  65118. state.pendingcb++;
  65119. state.lastBufferedRequest = null;
  65120. if (holder.next) {
  65121. state.corkedRequestsFree = holder.next;
  65122. holder.next = null;
  65123. } else {
  65124. state.corkedRequestsFree = new CorkedRequest(state);
  65125. }
  65126. state.bufferedRequestCount = 0;
  65127. } else {
  65128. // Slow case, write chunks one-by-one
  65129. while (entry) {
  65130. var chunk = entry.chunk;
  65131. var encoding = entry.encoding;
  65132. var cb = entry.callback;
  65133. var len = state.objectMode ? 1 : chunk.length;
  65134. doWrite(stream, state, false, len, chunk, encoding, cb);
  65135. entry = entry.next;
  65136. state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
  65137. // it means that we need to wait until it does.
  65138. // also, that means that the chunk and cb are currently
  65139. // being processed, so move the buffer counter past them.
  65140. if (state.writing) {
  65141. break;
  65142. }
  65143. }
  65144. if (entry === null) state.lastBufferedRequest = null;
  65145. }
  65146. state.bufferedRequest = entry;
  65147. state.bufferProcessing = false;
  65148. }
  65149. Writable.prototype._write = function (chunk, encoding, cb) {
  65150. cb(new Error('_write() is not implemented'));
  65151. };
  65152. Writable.prototype._writev = null;
  65153. Writable.prototype.end = function (chunk, encoding, cb) {
  65154. var state = this._writableState;
  65155. if (typeof chunk === 'function') {
  65156. cb = chunk;
  65157. chunk = null;
  65158. encoding = null;
  65159. } else if (typeof encoding === 'function') {
  65160. cb = encoding;
  65161. encoding = null;
  65162. }
  65163. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
  65164. if (state.corked) {
  65165. state.corked = 1;
  65166. this.uncork();
  65167. } // ignore unnecessary end() calls.
  65168. if (!state.ending && !state.finished) endWritable(this, state, cb);
  65169. };
  65170. function needFinish(state) {
  65171. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  65172. }
  65173. function callFinal(stream, state) {
  65174. stream._final(function (err) {
  65175. state.pendingcb--;
  65176. if (err) {
  65177. stream.emit('error', err);
  65178. }
  65179. state.prefinished = true;
  65180. stream.emit('prefinish');
  65181. finishMaybe(stream, state);
  65182. });
  65183. }
  65184. function prefinish(stream, state) {
  65185. if (!state.prefinished && !state.finalCalled) {
  65186. if (typeof stream._final === 'function') {
  65187. state.pendingcb++;
  65188. state.finalCalled = true;
  65189. pna.nextTick(callFinal, stream, state);
  65190. } else {
  65191. state.prefinished = true;
  65192. stream.emit('prefinish');
  65193. }
  65194. }
  65195. }
  65196. function finishMaybe(stream, state) {
  65197. var need = needFinish(state);
  65198. if (need) {
  65199. prefinish(stream, state);
  65200. if (state.pendingcb === 0) {
  65201. state.finished = true;
  65202. stream.emit('finish');
  65203. }
  65204. }
  65205. return need;
  65206. }
  65207. function endWritable(stream, state, cb) {
  65208. state.ending = true;
  65209. finishMaybe(stream, state);
  65210. if (cb) {
  65211. if (state.finished) pna.nextTick(cb); else stream.once('finish', cb);
  65212. }
  65213. state.ended = true;
  65214. stream.writable = false;
  65215. }
  65216. function onCorkedFinish(corkReq, state, err) {
  65217. var entry = corkReq.entry;
  65218. corkReq.entry = null;
  65219. while (entry) {
  65220. var cb = entry.callback;
  65221. state.pendingcb--;
  65222. cb(err);
  65223. entry = entry.next;
  65224. }
  65225. if (state.corkedRequestsFree) {
  65226. state.corkedRequestsFree.next = corkReq;
  65227. } else {
  65228. state.corkedRequestsFree = corkReq;
  65229. }
  65230. }
  65231. Object.defineProperty(Writable.prototype, 'destroyed', {
  65232. get: function get() {
  65233. if (this._writableState === undefined) {
  65234. return false;
  65235. }
  65236. return this._writableState.destroyed;
  65237. },
  65238. set: function set(value) {
  65239. // we ignore the value if the stream
  65240. // has not been initialized yet
  65241. if (!this._writableState) {
  65242. return;
  65243. } // backward compatibility, the user is explicitly
  65244. // managing destroyed
  65245. this._writableState.destroyed = value;
  65246. }
  65247. });
  65248. Writable.prototype.destroy = destroyImpl.destroy;
  65249. Writable.prototype._undestroy = destroyImpl.undestroy;
  65250. Writable.prototype._destroy = function (err, cb) {
  65251. this.end();
  65252. cb(err);
  65253. };
  65254. }).call(this, require('_process'), typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}, require("timers").setImmediate)
  65255. }, { "./_stream_duplex": 508, "./internal/streams/destroy": 514, "./internal/streams/stream": 515, "_process": 467, "core-util-is": 328, "inherits": 387, "process-nextick-args": 466, "safe-buffer": 494, "timers": 521, "util-deprecate": 522 }], 513: [function (require, module, exports) {
  65256. 'use strict';
  65257. function _classCallCheck(instance, Constructor) {
  65258. if (!(instance instanceof Constructor)) {
  65259. throw new TypeError("Cannot call a class as a function");
  65260. }
  65261. }
  65262. var Buffer = require('safe-buffer').Buffer;
  65263. var util = require('util');
  65264. function copyBuffer(src, target, offset) {
  65265. src.copy(target, offset);
  65266. }
  65267. module.exports = function () {
  65268. function BufferList() {
  65269. _classCallCheck(this, BufferList);
  65270. this.head = null;
  65271. this.tail = null;
  65272. this.length = 0;
  65273. }
  65274. BufferList.prototype.push = function push(v) {
  65275. var entry = {
  65276. data: v,
  65277. next: null
  65278. };
  65279. if (this.length > 0) this.tail.next = entry; else this.head = entry;
  65280. this.tail = entry;
  65281. ++this.length;
  65282. };
  65283. BufferList.prototype.unshift = function unshift(v) {
  65284. var entry = {
  65285. data: v,
  65286. next: this.head
  65287. };
  65288. if (this.length === 0) this.tail = entry;
  65289. this.head = entry;
  65290. ++this.length;
  65291. };
  65292. BufferList.prototype.shift = function shift() {
  65293. if (this.length === 0) return;
  65294. var ret = this.head.data;
  65295. if (this.length === 1) this.head = this.tail = null; else this.head = this.head.next;
  65296. --this.length;
  65297. return ret;
  65298. };
  65299. BufferList.prototype.clear = function clear() {
  65300. this.head = this.tail = null;
  65301. this.length = 0;
  65302. };
  65303. BufferList.prototype.join = function join(s) {
  65304. if (this.length === 0) return '';
  65305. var p = this.head;
  65306. var ret = '' + p.data;
  65307. while (p = p.next) {
  65308. ret += s + p.data;
  65309. }
  65310. return ret;
  65311. };
  65312. BufferList.prototype.concat = function concat(n) {
  65313. if (this.length === 0) return Buffer.alloc(0);
  65314. if (this.length === 1) return this.head.data;
  65315. var ret = Buffer.allocUnsafe(n >>> 0);
  65316. var p = this.head;
  65317. var i = 0;
  65318. while (p) {
  65319. copyBuffer(p.data, ret, i);
  65320. i += p.data.length;
  65321. p = p.next;
  65322. }
  65323. return ret;
  65324. };
  65325. return BufferList;
  65326. }();
  65327. if (util && util.inspect && util.inspect.custom) {
  65328. module.exports.prototype[util.inspect.custom] = function () {
  65329. var obj = util.inspect({
  65330. length: this.length
  65331. });
  65332. return this.constructor.name + ' ' + obj;
  65333. };
  65334. }
  65335. }, { "safe-buffer": 494, "util": 185 }], 514: [function (require, module, exports) {
  65336. 'use strict';
  65337. /*<replacement>*/
  65338. var pna = require('process-nextick-args');
  65339. /*</replacement>*/
  65340. // undocumented cb() API, needed for core, not for public API
  65341. function destroy(err, cb) {
  65342. var _this = this;
  65343. var readableDestroyed = this._readableState && this._readableState.destroyed;
  65344. var writableDestroyed = this._writableState && this._writableState.destroyed;
  65345. if (readableDestroyed || writableDestroyed) {
  65346. if (cb) {
  65347. cb(err);
  65348. } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
  65349. pna.nextTick(emitErrorNT, this, err);
  65350. }
  65351. return this;
  65352. } // we set destroyed to true before firing error callbacks in order
  65353. // to make it re-entrance safe in case destroy() is called within callbacks
  65354. if (this._readableState) {
  65355. this._readableState.destroyed = true;
  65356. } // if this is a duplex stream mark the writable part as destroyed as well
  65357. if (this._writableState) {
  65358. this._writableState.destroyed = true;
  65359. }
  65360. this._destroy(err || null, function (err) {
  65361. if (!cb && err) {
  65362. pna.nextTick(emitErrorNT, _this, err);
  65363. if (_this._writableState) {
  65364. _this._writableState.errorEmitted = true;
  65365. }
  65366. } else if (cb) {
  65367. cb(err);
  65368. }
  65369. });
  65370. return this;
  65371. }
  65372. function undestroy() {
  65373. if (this._readableState) {
  65374. this._readableState.destroyed = false;
  65375. this._readableState.reading = false;
  65376. this._readableState.ended = false;
  65377. this._readableState.endEmitted = false;
  65378. }
  65379. if (this._writableState) {
  65380. this._writableState.destroyed = false;
  65381. this._writableState.ended = false;
  65382. this._writableState.ending = false;
  65383. this._writableState.finished = false;
  65384. this._writableState.errorEmitted = false;
  65385. }
  65386. }
  65387. function emitErrorNT(self, err) {
  65388. self.emit('error', err);
  65389. }
  65390. module.exports = {
  65391. destroy: destroy,
  65392. undestroy: undestroy
  65393. };
  65394. }, { "process-nextick-args": 466 }], 515: [function (require, module, exports) {
  65395. arguments[4][490][0].apply(exports, arguments)
  65396. }, { "dup": 490, "events": 367 }], 516: [function (require, module, exports) {
  65397. "use strict";
  65398. module.exports = require('./readable').PassThrough;
  65399. }, { "./readable": 517 }], 517: [function (require, module, exports) {
  65400. "use strict";
  65401. exports = module.exports = require('./lib/_stream_readable.js');
  65402. exports.Stream = exports;
  65403. exports.Readable = exports;
  65404. exports.Writable = require('./lib/_stream_writable.js');
  65405. exports.Duplex = require('./lib/_stream_duplex.js');
  65406. exports.Transform = require('./lib/_stream_transform.js');
  65407. exports.PassThrough = require('./lib/_stream_passthrough.js');
  65408. }, { "./lib/_stream_duplex.js": 508, "./lib/_stream_passthrough.js": 509, "./lib/_stream_readable.js": 510, "./lib/_stream_transform.js": 511, "./lib/_stream_writable.js": 512 }], 518: [function (require, module, exports) {
  65409. "use strict";
  65410. module.exports = require('./readable').Transform;
  65411. }, { "./readable": 517 }], 519: [function (require, module, exports) {
  65412. "use strict";
  65413. module.exports = require('./lib/_stream_writable.js');
  65414. }, { "./lib/_stream_writable.js": 512 }], 520: [function (require, module, exports) {
  65415. // Copyright Joyent, Inc. and other Node contributors.
  65416. //
  65417. // Permission is hereby granted, free of charge, to any person obtaining a
  65418. // copy of this software and associated documentation files (the
  65419. // "Software"), to deal in the Software without restriction, including
  65420. // without limitation the rights to use, copy, modify, merge, publish,
  65421. // distribute, sublicense, and/or sell copies of the Software, and to permit
  65422. // persons to whom the Software is furnished to do so, subject to the
  65423. // following conditions:
  65424. //
  65425. // The above copyright notice and this permission notice shall be included
  65426. // in all copies or substantial portions of the Software.
  65427. //
  65428. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  65429. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  65430. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  65431. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  65432. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  65433. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  65434. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  65435. 'use strict';
  65436. /*<replacement>*/
  65437. var Buffer = require('safe-buffer').Buffer;
  65438. /*</replacement>*/
  65439. var isEncoding = Buffer.isEncoding || function (encoding) {
  65440. encoding = '' + encoding;
  65441. switch (encoding && encoding.toLowerCase()) {
  65442. case 'hex':
  65443. case 'utf8':
  65444. case 'utf-8':
  65445. case 'ascii':
  65446. case 'binary':
  65447. case 'base64':
  65448. case 'ucs2':
  65449. case 'ucs-2':
  65450. case 'utf16le':
  65451. case 'utf-16le':
  65452. case 'raw':
  65453. return true;
  65454. default:
  65455. return false;
  65456. }
  65457. };
  65458. function _normalizeEncoding(enc) {
  65459. if (!enc) return 'utf8';
  65460. var retried;
  65461. while (true) {
  65462. switch (enc) {
  65463. case 'utf8':
  65464. case 'utf-8':
  65465. return 'utf8';
  65466. case 'ucs2':
  65467. case 'ucs-2':
  65468. case 'utf16le':
  65469. case 'utf-16le':
  65470. return 'utf16le';
  65471. case 'latin1':
  65472. case 'binary':
  65473. return 'latin1';
  65474. case 'base64':
  65475. case 'ascii':
  65476. case 'hex':
  65477. return enc;
  65478. default:
  65479. if (retried) return; // undefined
  65480. enc = ('' + enc).toLowerCase();
  65481. retried = true;
  65482. }
  65483. }
  65484. }
  65485. ; // Do not cache `Buffer.isEncoding` when checking encoding names as some
  65486. // modules monkey-patch it to support additional encodings
  65487. function normalizeEncoding(enc) {
  65488. var nenc = _normalizeEncoding(enc);
  65489. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  65490. return nenc || enc;
  65491. } // StringDecoder provides an interface for efficiently splitting a series of
  65492. // buffers into a series of JS strings without breaking apart multi-byte
  65493. // characters.
  65494. exports.StringDecoder = StringDecoder;
  65495. function StringDecoder(encoding) {
  65496. this.encoding = normalizeEncoding(encoding);
  65497. var nb;
  65498. switch (this.encoding) {
  65499. case 'utf16le':
  65500. this.text = utf16Text;
  65501. this.end = utf16End;
  65502. nb = 4;
  65503. break;
  65504. case 'utf8':
  65505. this.fillLast = utf8FillLast;
  65506. nb = 4;
  65507. break;
  65508. case 'base64':
  65509. this.text = base64Text;
  65510. this.end = base64End;
  65511. nb = 3;
  65512. break;
  65513. default:
  65514. this.write = simpleWrite;
  65515. this.end = simpleEnd;
  65516. return;
  65517. }
  65518. this.lastNeed = 0;
  65519. this.lastTotal = 0;
  65520. this.lastChar = Buffer.allocUnsafe(nb);
  65521. }
  65522. StringDecoder.prototype.write = function (buf) {
  65523. if (buf.length === 0) return '';
  65524. var r;
  65525. var i;
  65526. if (this.lastNeed) {
  65527. r = this.fillLast(buf);
  65528. if (r === undefined) return '';
  65529. i = this.lastNeed;
  65530. this.lastNeed = 0;
  65531. } else {
  65532. i = 0;
  65533. }
  65534. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  65535. return r || '';
  65536. };
  65537. StringDecoder.prototype.end = utf8End; // Returns only complete characters in a Buffer
  65538. StringDecoder.prototype.text = utf8Text; // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  65539. StringDecoder.prototype.fillLast = function (buf) {
  65540. if (this.lastNeed <= buf.length) {
  65541. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  65542. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  65543. }
  65544. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  65545. this.lastNeed -= buf.length;
  65546. }; // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  65547. // continuation byte. If an invalid byte is detected, -2 is returned.
  65548. function utf8CheckByte(byte) {
  65549. if (byte <= 0x7F) return 0; else if (byte >> 5 === 0x06) return 2; else if (byte >> 4 === 0x0E) return 3; else if (byte >> 3 === 0x1E) return 4;
  65550. return byte >> 6 === 0x02 ? -1 : -2;
  65551. } // Checks at most 3 bytes at the end of a Buffer in order to detect an
  65552. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  65553. // needed to complete the UTF-8 character (if applicable) are returned.
  65554. function utf8CheckIncomplete(self, buf, i) {
  65555. var j = buf.length - 1;
  65556. if (j < i) return 0;
  65557. var nb = utf8CheckByte(buf[j]);
  65558. if (nb >= 0) {
  65559. if (nb > 0) self.lastNeed = nb - 1;
  65560. return nb;
  65561. }
  65562. if (--j < i || nb === -2) return 0;
  65563. nb = utf8CheckByte(buf[j]);
  65564. if (nb >= 0) {
  65565. if (nb > 0) self.lastNeed = nb - 2;
  65566. return nb;
  65567. }
  65568. if (--j < i || nb === -2) return 0;
  65569. nb = utf8CheckByte(buf[j]);
  65570. if (nb >= 0) {
  65571. if (nb > 0) {
  65572. if (nb === 2) nb = 0; else self.lastNeed = nb - 3;
  65573. }
  65574. return nb;
  65575. }
  65576. return 0;
  65577. } // Validates as many continuation bytes for a multi-byte UTF-8 character as
  65578. // needed or are available. If we see a non-continuation byte where we expect
  65579. // one, we "replace" the validated continuation bytes we've seen so far with
  65580. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  65581. // behavior. The continuation byte check is included three times in the case
  65582. // where all of the continuation bytes for a character exist in the same buffer.
  65583. // It is also done this way as a slight performance increase instead of using a
  65584. // loop.
  65585. function utf8CheckExtraBytes(self, buf, p) {
  65586. if ((buf[0] & 0xC0) !== 0x80) {
  65587. self.lastNeed = 0;
  65588. return "\uFFFD";
  65589. }
  65590. if (self.lastNeed > 1 && buf.length > 1) {
  65591. if ((buf[1] & 0xC0) !== 0x80) {
  65592. self.lastNeed = 1;
  65593. return "\uFFFD";
  65594. }
  65595. if (self.lastNeed > 2 && buf.length > 2) {
  65596. if ((buf[2] & 0xC0) !== 0x80) {
  65597. self.lastNeed = 2;
  65598. return "\uFFFD";
  65599. }
  65600. }
  65601. }
  65602. } // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  65603. function utf8FillLast(buf) {
  65604. var p = this.lastTotal - this.lastNeed;
  65605. var r = utf8CheckExtraBytes(this, buf, p);
  65606. if (r !== undefined) return r;
  65607. if (this.lastNeed <= buf.length) {
  65608. buf.copy(this.lastChar, p, 0, this.lastNeed);
  65609. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  65610. }
  65611. buf.copy(this.lastChar, p, 0, buf.length);
  65612. this.lastNeed -= buf.length;
  65613. } // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  65614. // partial character, the character's bytes are buffered until the required
  65615. // number of bytes are available.
  65616. function utf8Text(buf, i) {
  65617. var total = utf8CheckIncomplete(this, buf, i);
  65618. if (!this.lastNeed) return buf.toString('utf8', i);
  65619. this.lastTotal = total;
  65620. var end = buf.length - (total - this.lastNeed);
  65621. buf.copy(this.lastChar, 0, end);
  65622. return buf.toString('utf8', i, end);
  65623. } // For UTF-8, a replacement character is added when ending on a partial
  65624. // character.
  65625. function utf8End(buf) {
  65626. var r = buf && buf.length ? this.write(buf) : '';
  65627. if (this.lastNeed) return r + "\uFFFD";
  65628. return r;
  65629. } // UTF-16LE typically needs two bytes per character, but even if we have an even
  65630. // number of bytes available, we need to check if we end on a leading/high
  65631. // surrogate. In that case, we need to wait for the next two bytes in order to
  65632. // decode the last character properly.
  65633. function utf16Text(buf, i) {
  65634. if ((buf.length - i) % 2 === 0) {
  65635. var r = buf.toString('utf16le', i);
  65636. if (r) {
  65637. var c = r.charCodeAt(r.length - 1);
  65638. if (c >= 0xD800 && c <= 0xDBFF) {
  65639. this.lastNeed = 2;
  65640. this.lastTotal = 4;
  65641. this.lastChar[0] = buf[buf.length - 2];
  65642. this.lastChar[1] = buf[buf.length - 1];
  65643. return r.slice(0, -1);
  65644. }
  65645. }
  65646. return r;
  65647. }
  65648. this.lastNeed = 1;
  65649. this.lastTotal = 2;
  65650. this.lastChar[0] = buf[buf.length - 1];
  65651. return buf.toString('utf16le', i, buf.length - 1);
  65652. } // For UTF-16LE we do not explicitly append special replacement characters if we
  65653. // end on a partial character, we simply let v8 handle that.
  65654. function utf16End(buf) {
  65655. var r = buf && buf.length ? this.write(buf) : '';
  65656. if (this.lastNeed) {
  65657. var end = this.lastTotal - this.lastNeed;
  65658. return r + this.lastChar.toString('utf16le', 0, end);
  65659. }
  65660. return r;
  65661. }
  65662. function base64Text(buf, i) {
  65663. var n = (buf.length - i) % 3;
  65664. if (n === 0) return buf.toString('base64', i);
  65665. this.lastNeed = 3 - n;
  65666. this.lastTotal = 3;
  65667. if (n === 1) {
  65668. this.lastChar[0] = buf[buf.length - 1];
  65669. } else {
  65670. this.lastChar[0] = buf[buf.length - 2];
  65671. this.lastChar[1] = buf[buf.length - 1];
  65672. }
  65673. return buf.toString('base64', i, buf.length - n);
  65674. }
  65675. function base64End(buf) {
  65676. var r = buf && buf.length ? this.write(buf) : '';
  65677. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  65678. return r;
  65679. } // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  65680. function simpleWrite(buf) {
  65681. return buf.toString(this.encoding);
  65682. }
  65683. function simpleEnd(buf) {
  65684. return buf && buf.length ? this.write(buf) : '';
  65685. }
  65686. }, { "safe-buffer": 494 }], 521: [function (require, module, exports) {
  65687. (function (setImmediate, clearImmediate) {
  65688. "use strict";
  65689. var nextTick = require('process/browser.js').nextTick;
  65690. var apply = Function.prototype.apply;
  65691. var slice = Array.prototype.slice;
  65692. var immediateIds = {};
  65693. var nextImmediateId = 0; // DOM APIs, for completeness
  65694. exports.setTimeout = function () {
  65695. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  65696. };
  65697. exports.setInterval = function () {
  65698. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  65699. };
  65700. exports.clearTimeout = exports.clearInterval = function (timeout) {
  65701. timeout.close();
  65702. };
  65703. function Timeout(id, clearFn) {
  65704. this._id = id;
  65705. this._clearFn = clearFn;
  65706. }
  65707. Timeout.prototype.unref = Timeout.prototype.ref = function () { };
  65708. Timeout.prototype.close = function () {
  65709. this._clearFn.call(window, this._id);
  65710. }; // Does not start the time, just sets up the members needed.
  65711. exports.enroll = function (item, msecs) {
  65712. clearTimeout(item._idleTimeoutId);
  65713. item._idleTimeout = msecs;
  65714. };
  65715. exports.unenroll = function (item) {
  65716. clearTimeout(item._idleTimeoutId);
  65717. item._idleTimeout = -1;
  65718. };
  65719. exports._unrefActive = exports.active = function (item) {
  65720. clearTimeout(item._idleTimeoutId);
  65721. var msecs = item._idleTimeout;
  65722. if (msecs >= 0) {
  65723. item._idleTimeoutId = setTimeout(function onTimeout() {
  65724. if (item._onTimeout) item._onTimeout();
  65725. }, msecs);
  65726. }
  65727. }; // That's not how node.js implements it but the exposed api is the same.
  65728. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function (fn) {
  65729. var id = nextImmediateId++;
  65730. var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  65731. immediateIds[id] = true;
  65732. nextTick(function onNextTick() {
  65733. if (immediateIds[id]) {
  65734. // fn.call() is faster so we optimize for the common use-case
  65735. // @see http://jsperf.com/call-apply-segu
  65736. if (args) {
  65737. fn.apply(null, args);
  65738. } else {
  65739. fn.call(null);
  65740. } // Prevent ids from leaking
  65741. exports.clearImmediate(id);
  65742. }
  65743. });
  65744. return id;
  65745. };
  65746. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function (id) {
  65747. delete immediateIds[id];
  65748. };
  65749. }).call(this, require("timers").setImmediate, require("timers").clearImmediate)
  65750. }, { "process/browser.js": 467, "timers": 521 }], 522: [function (require, module, exports) {
  65751. (function (global) {
  65752. "use strict";
  65753. /**
  65754. * Module exports.
  65755. */
  65756. module.exports = deprecate;
  65757. /**
  65758. * Mark that a method should not be used.
  65759. * Returns a modified function which warns once by default.
  65760. *
  65761. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  65762. *
  65763. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  65764. * will throw an Error when invoked.
  65765. *
  65766. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  65767. * will invoke `console.trace()` instead of `console.error()`.
  65768. *
  65769. * @param {Function} fn - the function to deprecate
  65770. * @param {String} msg - the string to print to the console when `fn` is invoked
  65771. * @returns {Function} a new "deprecated" version of `fn`
  65772. * @api public
  65773. */
  65774. function deprecate(fn, msg) {
  65775. if (config('noDeprecation')) {
  65776. return fn;
  65777. }
  65778. var warned = false;
  65779. function deprecated() {
  65780. if (!warned) {
  65781. if (config('throwDeprecation')) {
  65782. throw new Error(msg);
  65783. } else if (config('traceDeprecation')) {
  65784. console.trace(msg);
  65785. } else {
  65786. console.warn(msg);
  65787. }
  65788. warned = true;
  65789. }
  65790. return fn.apply(this, arguments);
  65791. }
  65792. return deprecated;
  65793. }
  65794. /**
  65795. * Checks `localStorage` for boolean values for the given `name`.
  65796. *
  65797. * @param {String} name
  65798. * @returns {Boolean}
  65799. * @api private
  65800. */
  65801. function config(name) {
  65802. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  65803. try {
  65804. if (!global.localStorage) return false;
  65805. } catch (_) {
  65806. return false;
  65807. }
  65808. var val = global.localStorage[name];
  65809. if (null == val) return false;
  65810. return String(val).toLowerCase() === 'true';
  65811. }
  65812. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  65813. }, {}], 523: [function (require, module, exports) {
  65814. "use strict";
  65815. if (typeof Object.create === 'function') {
  65816. // implementation from standard node.js 'util' module
  65817. module.exports = function inherits(ctor, superCtor) {
  65818. ctor.super_ = superCtor;
  65819. ctor.prototype = Object.create(superCtor.prototype, {
  65820. constructor: {
  65821. value: ctor,
  65822. enumerable: false,
  65823. writable: true,
  65824. configurable: true
  65825. }
  65826. });
  65827. };
  65828. } else {
  65829. // old school shim for old browsers
  65830. module.exports = function inherits(ctor, superCtor) {
  65831. ctor.super_ = superCtor;
  65832. var TempCtor = function TempCtor() { };
  65833. TempCtor.prototype = superCtor.prototype;
  65834. ctor.prototype = new TempCtor();
  65835. ctor.prototype.constructor = ctor;
  65836. };
  65837. }
  65838. }, {}], 524: [function (require, module, exports) {
  65839. "use strict";
  65840. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  65841. module.exports = function isBuffer(arg) {
  65842. return arg && _typeof(arg) === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function';
  65843. };
  65844. }, {}], 525: [function (require, module, exports) {
  65845. (function (process, global) {
  65846. "use strict";
  65847. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  65848. // Copyright Joyent, Inc. and other Node contributors.
  65849. //
  65850. // Permission is hereby granted, free of charge, to any person obtaining a
  65851. // copy of this software and associated documentation files (the
  65852. // "Software"), to deal in the Software without restriction, including
  65853. // without limitation the rights to use, copy, modify, merge, publish,
  65854. // distribute, sublicense, and/or sell copies of the Software, and to permit
  65855. // persons to whom the Software is furnished to do so, subject to the
  65856. // following conditions:
  65857. //
  65858. // The above copyright notice and this permission notice shall be included
  65859. // in all copies or substantial portions of the Software.
  65860. //
  65861. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  65862. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  65863. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  65864. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  65865. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  65866. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  65867. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  65868. var formatRegExp = /%[sdj%]/g;
  65869. exports.format = function (f) {
  65870. if (!isString(f)) {
  65871. var objects = [];
  65872. for (var i = 0; i < arguments.length; i++) {
  65873. objects.push(inspect(arguments[i]));
  65874. }
  65875. return objects.join(' ');
  65876. }
  65877. var i = 1;
  65878. var args = arguments;
  65879. var len = args.length;
  65880. var str = String(f).replace(formatRegExp, function (x) {
  65881. if (x === '%%') return '%';
  65882. if (i >= len) return x;
  65883. switch (x) {
  65884. case '%s':
  65885. return String(args[i++]);
  65886. case '%d':
  65887. return Number(args[i++]);
  65888. case '%j':
  65889. try {
  65890. return JSON.stringify(args[i++]);
  65891. } catch (_) {
  65892. return '[Circular]';
  65893. }
  65894. default:
  65895. return x;
  65896. }
  65897. });
  65898. for (var x = args[i]; i < len; x = args[++i]) {
  65899. if (isNull(x) || !isObject(x)) {
  65900. str += ' ' + x;
  65901. } else {
  65902. str += ' ' + inspect(x);
  65903. }
  65904. }
  65905. return str;
  65906. }; // Mark that a method should not be used.
  65907. // Returns a modified function which warns once by default.
  65908. // If --no-deprecation is set, then it is a no-op.
  65909. exports.deprecate = function (fn, msg) {
  65910. // Allow for deprecating things in the process of starting up.
  65911. if (isUndefined(global.process)) {
  65912. return function () {
  65913. return exports.deprecate(fn, msg).apply(this, arguments);
  65914. };
  65915. }
  65916. if (process.noDeprecation === true) {
  65917. return fn;
  65918. }
  65919. var warned = false;
  65920. function deprecated() {
  65921. if (!warned) {
  65922. if (process.throwDeprecation) {
  65923. throw new Error(msg);
  65924. } else if (process.traceDeprecation) {
  65925. console.trace(msg);
  65926. } else {
  65927. console.error(msg);
  65928. }
  65929. warned = true;
  65930. }
  65931. return fn.apply(this, arguments);
  65932. }
  65933. return deprecated;
  65934. };
  65935. var debugs = {};
  65936. var debugEnviron;
  65937. exports.debuglog = function (set) {
  65938. if (isUndefined(debugEnviron)) debugEnviron = process.env.NODE_DEBUG || '';
  65939. set = set.toUpperCase();
  65940. if (!debugs[set]) {
  65941. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  65942. var pid = process.pid;
  65943. debugs[set] = function () {
  65944. var msg = exports.format.apply(exports, arguments);
  65945. console.error('%s %d: %s', set, pid, msg);
  65946. };
  65947. } else {
  65948. debugs[set] = function () { };
  65949. }
  65950. }
  65951. return debugs[set];
  65952. };
  65953. /**
  65954. * Echos the value of a value. Trys to print the value out
  65955. * in the best way possible given the different types.
  65956. *
  65957. * @param {Object} obj The object to print out.
  65958. * @param {Object} opts Optional options object that alters the output.
  65959. */
  65960. /* legacy: obj, showHidden, depth, colors*/
  65961. function inspect(obj, opts) {
  65962. // default options
  65963. var ctx = {
  65964. seen: [],
  65965. stylize: stylizeNoColor
  65966. }; // legacy...
  65967. if (arguments.length >= 3) ctx.depth = arguments[2];
  65968. if (arguments.length >= 4) ctx.colors = arguments[3];
  65969. if (isBoolean(opts)) {
  65970. // legacy...
  65971. ctx.showHidden = opts;
  65972. } else if (opts) {
  65973. // got an "options" object
  65974. exports._extend(ctx, opts);
  65975. } // set default options
  65976. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  65977. if (isUndefined(ctx.depth)) ctx.depth = 2;
  65978. if (isUndefined(ctx.colors)) ctx.colors = false;
  65979. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  65980. if (ctx.colors) ctx.stylize = stylizeWithColor;
  65981. return formatValue(ctx, obj, ctx.depth);
  65982. }
  65983. exports.inspect = inspect; // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  65984. inspect.colors = {
  65985. 'bold': [1, 22],
  65986. 'italic': [3, 23],
  65987. 'underline': [4, 24],
  65988. 'inverse': [7, 27],
  65989. 'white': [37, 39],
  65990. 'grey': [90, 39],
  65991. 'black': [30, 39],
  65992. 'blue': [34, 39],
  65993. 'cyan': [36, 39],
  65994. 'green': [32, 39],
  65995. 'magenta': [35, 39],
  65996. 'red': [31, 39],
  65997. 'yellow': [33, 39]
  65998. }; // Don't use 'blue' not visible on cmd.exe
  65999. inspect.styles = {
  66000. 'special': 'cyan',
  66001. 'number': 'yellow',
  66002. 'boolean': 'yellow',
  66003. 'undefined': 'grey',
  66004. 'null': 'bold',
  66005. 'string': 'green',
  66006. 'date': 'magenta',
  66007. // "name": intentionally not styling
  66008. 'regexp': 'red'
  66009. };
  66010. function stylizeWithColor(str, styleType) {
  66011. var style = inspect.styles[styleType];
  66012. if (style) {
  66013. return "\x1B[" + inspect.colors[style][0] + 'm' + str + "\x1B[" + inspect.colors[style][1] + 'm';
  66014. } else {
  66015. return str;
  66016. }
  66017. }
  66018. function stylizeNoColor(str, styleType) {
  66019. return str;
  66020. }
  66021. function arrayToHash(array) {
  66022. var hash = {};
  66023. array.forEach(function (val, idx) {
  66024. hash[val] = true;
  66025. });
  66026. return hash;
  66027. }
  66028. function formatValue(ctx, value, recurseTimes) {
  66029. // Provide a hook for user-specified inspect functions.
  66030. // Check that value is an object with an inspect function on it
  66031. if (ctx.customInspect && value && isFunction(value.inspect) && // Filter out the util module, it's inspect function is special
  66032. value.inspect !== exports.inspect && // Also filter out any prototype objects using the circular check.
  66033. !(value.constructor && value.constructor.prototype === value)) {
  66034. var ret = value.inspect(recurseTimes, ctx);
  66035. if (!isString(ret)) {
  66036. ret = formatValue(ctx, ret, recurseTimes);
  66037. }
  66038. return ret;
  66039. } // Primitive types cannot have properties
  66040. var primitive = formatPrimitive(ctx, value);
  66041. if (primitive) {
  66042. return primitive;
  66043. } // Look up the keys of the object.
  66044. var keys = Object.keys(value);
  66045. var visibleKeys = arrayToHash(keys);
  66046. if (ctx.showHidden) {
  66047. keys = Object.getOwnPropertyNames(value);
  66048. } // IE doesn't make error fields non-enumerable
  66049. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  66050. if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  66051. return formatError(value);
  66052. } // Some type of object without properties can be shortcutted.
  66053. if (keys.length === 0) {
  66054. if (isFunction(value)) {
  66055. var name = value.name ? ': ' + value.name : '';
  66056. return ctx.stylize('[Function' + name + ']', 'special');
  66057. }
  66058. if (isRegExp(value)) {
  66059. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  66060. }
  66061. if (isDate(value)) {
  66062. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  66063. }
  66064. if (isError(value)) {
  66065. return formatError(value);
  66066. }
  66067. }
  66068. var base = '',
  66069. array = false,
  66070. braces = ['{', '}']; // Make Array say that they are Array
  66071. if (isArray(value)) {
  66072. array = true;
  66073. braces = ['[', ']'];
  66074. } // Make functions say that they are functions
  66075. if (isFunction(value)) {
  66076. var n = value.name ? ': ' + value.name : '';
  66077. base = ' [Function' + n + ']';
  66078. } // Make RegExps say that they are RegExps
  66079. if (isRegExp(value)) {
  66080. base = ' ' + RegExp.prototype.toString.call(value);
  66081. } // Make dates with properties first say the date
  66082. if (isDate(value)) {
  66083. base = ' ' + Date.prototype.toUTCString.call(value);
  66084. } // Make error with message first say the error
  66085. if (isError(value)) {
  66086. base = ' ' + formatError(value);
  66087. }
  66088. if (keys.length === 0 && (!array || value.length == 0)) {
  66089. return braces[0] + base + braces[1];
  66090. }
  66091. if (recurseTimes < 0) {
  66092. if (isRegExp(value)) {
  66093. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  66094. } else {
  66095. return ctx.stylize('[Object]', 'special');
  66096. }
  66097. }
  66098. ctx.seen.push(value);
  66099. var output;
  66100. if (array) {
  66101. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  66102. } else {
  66103. output = keys.map(function (key) {
  66104. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  66105. });
  66106. }
  66107. ctx.seen.pop();
  66108. return reduceToSingleString(output, base, braces);
  66109. }
  66110. function formatPrimitive(ctx, value) {
  66111. if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
  66112. if (isString(value)) {
  66113. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
  66114. return ctx.stylize(simple, 'string');
  66115. }
  66116. if (isNumber(value)) return ctx.stylize('' + value, 'number');
  66117. if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here.
  66118. if (isNull(value)) return ctx.stylize('null', 'null');
  66119. }
  66120. function formatError(value) {
  66121. return '[' + Error.prototype.toString.call(value) + ']';
  66122. }
  66123. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  66124. var output = [];
  66125. for (var i = 0, l = value.length; i < l; ++i) {
  66126. if (hasOwnProperty(value, String(i))) {
  66127. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
  66128. } else {
  66129. output.push('');
  66130. }
  66131. }
  66132. keys.forEach(function (key) {
  66133. if (!key.match(/^\d+$/)) {
  66134. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
  66135. }
  66136. });
  66137. return output;
  66138. }
  66139. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  66140. var name, str, desc;
  66141. desc = Object.getOwnPropertyDescriptor(value, key) || {
  66142. value: value[key]
  66143. };
  66144. if (desc.get) {
  66145. if (desc.set) {
  66146. str = ctx.stylize('[Getter/Setter]', 'special');
  66147. } else {
  66148. str = ctx.stylize('[Getter]', 'special');
  66149. }
  66150. } else {
  66151. if (desc.set) {
  66152. str = ctx.stylize('[Setter]', 'special');
  66153. }
  66154. }
  66155. if (!hasOwnProperty(visibleKeys, key)) {
  66156. name = '[' + key + ']';
  66157. }
  66158. if (!str) {
  66159. if (ctx.seen.indexOf(desc.value) < 0) {
  66160. if (isNull(recurseTimes)) {
  66161. str = formatValue(ctx, desc.value, null);
  66162. } else {
  66163. str = formatValue(ctx, desc.value, recurseTimes - 1);
  66164. }
  66165. if (str.indexOf('\n') > -1) {
  66166. if (array) {
  66167. str = str.split('\n').map(function (line) {
  66168. return ' ' + line;
  66169. }).join('\n').substr(2);
  66170. } else {
  66171. str = '\n' + str.split('\n').map(function (line) {
  66172. return ' ' + line;
  66173. }).join('\n');
  66174. }
  66175. }
  66176. } else {
  66177. str = ctx.stylize('[Circular]', 'special');
  66178. }
  66179. }
  66180. if (isUndefined(name)) {
  66181. if (array && key.match(/^\d+$/)) {
  66182. return str;
  66183. }
  66184. name = JSON.stringify('' + key);
  66185. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  66186. name = name.substr(1, name.length - 2);
  66187. name = ctx.stylize(name, 'name');
  66188. } else {
  66189. name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
  66190. name = ctx.stylize(name, 'string');
  66191. }
  66192. }
  66193. return name + ': ' + str;
  66194. }
  66195. function reduceToSingleString(output, base, braces) {
  66196. var numLinesEst = 0;
  66197. var length = output.reduce(function (prev, cur) {
  66198. numLinesEst++;
  66199. if (cur.indexOf('\n') >= 0) numLinesEst++;
  66200. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  66201. }, 0);
  66202. if (length > 60) {
  66203. return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1];
  66204. }
  66205. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  66206. } // NOTE: These type checking functions intentionally don't use `instanceof`
  66207. // because it is fragile and can be easily faked with `Object.create()`.
  66208. function isArray(ar) {
  66209. return Array.isArray(ar);
  66210. }
  66211. exports.isArray = isArray;
  66212. function isBoolean(arg) {
  66213. return typeof arg === 'boolean';
  66214. }
  66215. exports.isBoolean = isBoolean;
  66216. function isNull(arg) {
  66217. return arg === null;
  66218. }
  66219. exports.isNull = isNull;
  66220. function isNullOrUndefined(arg) {
  66221. return arg == null;
  66222. }
  66223. exports.isNullOrUndefined = isNullOrUndefined;
  66224. function isNumber(arg) {
  66225. return typeof arg === 'number';
  66226. }
  66227. exports.isNumber = isNumber;
  66228. function isString(arg) {
  66229. return typeof arg === 'string';
  66230. }
  66231. exports.isString = isString;
  66232. function isSymbol(arg) {
  66233. return _typeof(arg) === 'symbol';
  66234. }
  66235. exports.isSymbol = isSymbol;
  66236. function isUndefined(arg) {
  66237. return arg === void 0;
  66238. }
  66239. exports.isUndefined = isUndefined;
  66240. function isRegExp(re) {
  66241. return isObject(re) && objectToString(re) === '[object RegExp]';
  66242. }
  66243. exports.isRegExp = isRegExp;
  66244. function isObject(arg) {
  66245. return _typeof(arg) === 'object' && arg !== null;
  66246. }
  66247. exports.isObject = isObject;
  66248. function isDate(d) {
  66249. return isObject(d) && objectToString(d) === '[object Date]';
  66250. }
  66251. exports.isDate = isDate;
  66252. function isError(e) {
  66253. return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error);
  66254. }
  66255. exports.isError = isError;
  66256. function isFunction(arg) {
  66257. return typeof arg === 'function';
  66258. }
  66259. exports.isFunction = isFunction;
  66260. function isPrimitive(arg) {
  66261. return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || _typeof(arg) === 'symbol' || // ES6 symbol
  66262. typeof arg === 'undefined';
  66263. }
  66264. exports.isPrimitive = isPrimitive;
  66265. exports.isBuffer = require('./support/isBuffer');
  66266. function objectToString(o) {
  66267. return Object.prototype.toString.call(o);
  66268. }
  66269. function pad(n) {
  66270. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  66271. }
  66272. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; // 26 Feb 16:19:34
  66273. function timestamp() {
  66274. var d = new Date();
  66275. var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':');
  66276. return [d.getDate(), months[d.getMonth()], time].join(' ');
  66277. } // log is just a thin wrapper to console.log that prepends a timestamp
  66278. exports.log = function () {
  66279. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  66280. };
  66281. /**
  66282. * Inherit the prototype methods from one constructor into another.
  66283. *
  66284. * The Function.prototype.inherits from lang.js rewritten as a standalone
  66285. * function (not on Function.prototype). NOTE: If this file is to be loaded
  66286. * during bootstrapping this function needs to be rewritten using some native
  66287. * functions as prototype setup using normal JavaScript does not work as
  66288. * expected during bootstrapping (see mirror.js in r114903).
  66289. *
  66290. * @param {function} ctor Constructor function which needs to inherit the
  66291. * prototype.
  66292. * @param {function} superCtor Constructor function to inherit prototype from.
  66293. */
  66294. exports.inherits = require('inherits');
  66295. exports._extend = function (origin, add) {
  66296. // Don't do anything if add isn't an object
  66297. if (!add || !isObject(add)) return origin;
  66298. var keys = Object.keys(add);
  66299. var i = keys.length;
  66300. while (i--) {
  66301. origin[keys[i]] = add[keys[i]];
  66302. }
  66303. return origin;
  66304. };
  66305. function hasOwnProperty(obj, prop) {
  66306. return Object.prototype.hasOwnProperty.call(obj, prop);
  66307. }
  66308. }).call(this, require('_process'), typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  66309. }, { "./support/isBuffer": 524, "_process": 467, "inherits": 523 }], 526: [function (require, module, exports) {
  66310. "use strict";
  66311. Object.defineProperty(exports, "__esModule", {
  66312. value: true
  66313. });
  66314. Object.defineProperty(exports, "v1", {
  66315. enumerable: true,
  66316. get: function get() {
  66317. return _v.default;
  66318. }
  66319. });
  66320. Object.defineProperty(exports, "v3", {
  66321. enumerable: true,
  66322. get: function get() {
  66323. return _v2.default;
  66324. }
  66325. });
  66326. Object.defineProperty(exports, "v4", {
  66327. enumerable: true,
  66328. get: function get() {
  66329. return _v3.default;
  66330. }
  66331. });
  66332. Object.defineProperty(exports, "v5", {
  66333. enumerable: true,
  66334. get: function get() {
  66335. return _v4.default;
  66336. }
  66337. });
  66338. Object.defineProperty(exports, "NIL", {
  66339. enumerable: true,
  66340. get: function get() {
  66341. return _nil.default;
  66342. }
  66343. });
  66344. Object.defineProperty(exports, "version", {
  66345. enumerable: true,
  66346. get: function get() {
  66347. return _version.default;
  66348. }
  66349. });
  66350. Object.defineProperty(exports, "validate", {
  66351. enumerable: true,
  66352. get: function get() {
  66353. return _validate.default;
  66354. }
  66355. });
  66356. Object.defineProperty(exports, "stringify", {
  66357. enumerable: true,
  66358. get: function get() {
  66359. return _stringify.default;
  66360. }
  66361. });
  66362. Object.defineProperty(exports, "parse", {
  66363. enumerable: true,
  66364. get: function get() {
  66365. return _parse.default;
  66366. }
  66367. });
  66368. var _v = _interopRequireDefault(require("./v1.js"));
  66369. var _v2 = _interopRequireDefault(require("./v3.js"));
  66370. var _v3 = _interopRequireDefault(require("./v4.js"));
  66371. var _v4 = _interopRequireDefault(require("./v5.js"));
  66372. var _nil = _interopRequireDefault(require("./nil.js"));
  66373. var _version = _interopRequireDefault(require("./version.js"));
  66374. var _validate = _interopRequireDefault(require("./validate.js"));
  66375. var _stringify = _interopRequireDefault(require("./stringify.js"));
  66376. var _parse = _interopRequireDefault(require("./parse.js"));
  66377. function _interopRequireDefault(obj) {
  66378. return obj && obj.__esModule ? obj : {
  66379. default: obj
  66380. };
  66381. }
  66382. }, { "./nil.js": 528, "./parse.js": 529, "./stringify.js": 533, "./v1.js": 534, "./v3.js": 535, "./v4.js": 537, "./v5.js": 538, "./validate.js": 539, "./version.js": 540 }], 527: [function (require, module, exports) {
  66383. "use strict";
  66384. Object.defineProperty(exports, "__esModule", {
  66385. value: true
  66386. });
  66387. exports.default = void 0;
  66388. /*
  66389. * Browser-compatible JavaScript MD5
  66390. *
  66391. * Modification of JavaScript MD5
  66392. * https://github.com/blueimp/JavaScript-MD5
  66393. *
  66394. * Copyright 2011, Sebastian Tschan
  66395. * https://blueimp.net
  66396. *
  66397. * Licensed under the MIT license:
  66398. * https://opensource.org/licenses/MIT
  66399. *
  66400. * Based on
  66401. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  66402. * Digest Algorithm, as defined in RFC 1321.
  66403. * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
  66404. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  66405. * Distributed under the BSD License
  66406. * See http://pajhome.org.uk/crypt/md5 for more info.
  66407. */
  66408. function md5(bytes) {
  66409. if (typeof bytes === 'string') {
  66410. var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  66411. bytes = new Uint8Array(msg.length);
  66412. for (var i = 0; i < msg.length; ++i) {
  66413. bytes[i] = msg.charCodeAt(i);
  66414. }
  66415. }
  66416. return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
  66417. }
  66418. /*
  66419. * Convert an array of little-endian words to an array of bytes
  66420. */
  66421. function md5ToHexEncodedArray(input) {
  66422. var output = [];
  66423. var length32 = input.length * 32;
  66424. var hexTab = '0123456789abcdef';
  66425. for (var i = 0; i < length32; i += 8) {
  66426. var x = input[i >> 5] >>> i % 32 & 0xff;
  66427. var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
  66428. output.push(hex);
  66429. }
  66430. return output;
  66431. }
  66432. /**
  66433. * Calculate output length with padding and bit length
  66434. */
  66435. function getOutputLength(inputLength8) {
  66436. return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
  66437. }
  66438. /*
  66439. * Calculate the MD5 of an array of little-endian words, and a bit length.
  66440. */
  66441. function wordsToMd5(x, len) {
  66442. /* append padding */
  66443. x[len >> 5] |= 0x80 << len % 32;
  66444. x[getOutputLength(len) - 1] = len;
  66445. var a = 1732584193;
  66446. var b = -271733879;
  66447. var c = -1732584194;
  66448. var d = 271733878;
  66449. for (var i = 0; i < x.length; i += 16) {
  66450. var olda = a;
  66451. var oldb = b;
  66452. var oldc = c;
  66453. var oldd = d;
  66454. a = md5ff(a, b, c, d, x[i], 7, -680876936);
  66455. d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
  66456. c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
  66457. b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
  66458. a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
  66459. d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
  66460. c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
  66461. b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
  66462. a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
  66463. d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
  66464. c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
  66465. b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
  66466. a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
  66467. d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
  66468. c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
  66469. b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
  66470. a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
  66471. d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
  66472. c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
  66473. b = md5gg(b, c, d, a, x[i], 20, -373897302);
  66474. a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
  66475. d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
  66476. c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
  66477. b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
  66478. a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
  66479. d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
  66480. c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
  66481. b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
  66482. a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
  66483. d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
  66484. c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
  66485. b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
  66486. a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
  66487. d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
  66488. c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
  66489. b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
  66490. a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
  66491. d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
  66492. c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
  66493. b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
  66494. a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
  66495. d = md5hh(d, a, b, c, x[i], 11, -358537222);
  66496. c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
  66497. b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
  66498. a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
  66499. d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
  66500. c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
  66501. b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
  66502. a = md5ii(a, b, c, d, x[i], 6, -198630844);
  66503. d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
  66504. c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
  66505. b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
  66506. a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
  66507. d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
  66508. c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
  66509. b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
  66510. a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
  66511. d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
  66512. c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
  66513. b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
  66514. a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
  66515. d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
  66516. c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
  66517. b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
  66518. a = safeAdd(a, olda);
  66519. b = safeAdd(b, oldb);
  66520. c = safeAdd(c, oldc);
  66521. d = safeAdd(d, oldd);
  66522. }
  66523. return [a, b, c, d];
  66524. }
  66525. /*
  66526. * Convert an array bytes to an array of little-endian words
  66527. * Characters >255 have their high-byte silently ignored.
  66528. */
  66529. function bytesToWords(input) {
  66530. if (input.length === 0) {
  66531. return [];
  66532. }
  66533. var length8 = input.length * 8;
  66534. var output = new Uint32Array(getOutputLength(length8));
  66535. for (var i = 0; i < length8; i += 8) {
  66536. output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
  66537. }
  66538. return output;
  66539. }
  66540. /*
  66541. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  66542. * to work around bugs in some JS interpreters.
  66543. */
  66544. function safeAdd(x, y) {
  66545. var lsw = (x & 0xffff) + (y & 0xffff);
  66546. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  66547. return msw << 16 | lsw & 0xffff;
  66548. }
  66549. /*
  66550. * Bitwise rotate a 32-bit number to the left.
  66551. */
  66552. function bitRotateLeft(num, cnt) {
  66553. return num << cnt | num >>> 32 - cnt;
  66554. }
  66555. /*
  66556. * These functions implement the four basic operations the algorithm uses.
  66557. */
  66558. function md5cmn(q, a, b, x, s, t) {
  66559. return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
  66560. }
  66561. function md5ff(a, b, c, d, x, s, t) {
  66562. return md5cmn(b & c | ~b & d, a, b, x, s, t);
  66563. }
  66564. function md5gg(a, b, c, d, x, s, t) {
  66565. return md5cmn(b & d | c & ~d, a, b, x, s, t);
  66566. }
  66567. function md5hh(a, b, c, d, x, s, t) {
  66568. return md5cmn(b ^ c ^ d, a, b, x, s, t);
  66569. }
  66570. function md5ii(a, b, c, d, x, s, t) {
  66571. return md5cmn(c ^ (b | ~d), a, b, x, s, t);
  66572. }
  66573. var _default = md5;
  66574. exports.default = _default;
  66575. }, {}], 528: [function (require, module, exports) {
  66576. "use strict";
  66577. Object.defineProperty(exports, "__esModule", {
  66578. value: true
  66579. });
  66580. exports.default = void 0;
  66581. var _default = '00000000-0000-0000-0000-000000000000';
  66582. exports.default = _default;
  66583. }, {}], 529: [function (require, module, exports) {
  66584. "use strict";
  66585. Object.defineProperty(exports, "__esModule", {
  66586. value: true
  66587. });
  66588. exports.default = void 0;
  66589. var _validate = _interopRequireDefault(require("./validate.js"));
  66590. function _interopRequireDefault(obj) {
  66591. return obj && obj.__esModule ? obj : {
  66592. default: obj
  66593. };
  66594. }
  66595. function parse(uuid) {
  66596. if (!(0, _validate.default)(uuid)) {
  66597. throw TypeError('Invalid UUID');
  66598. }
  66599. var v;
  66600. var arr = new Uint8Array(16); // Parse ########-....-....-....-............
  66601. arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
  66602. arr[1] = v >>> 16 & 0xff;
  66603. arr[2] = v >>> 8 & 0xff;
  66604. arr[3] = v & 0xff; // Parse ........-####-....-....-............
  66605. arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
  66606. arr[5] = v & 0xff; // Parse ........-....-####-....-............
  66607. arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
  66608. arr[7] = v & 0xff; // Parse ........-....-....-####-............
  66609. arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
  66610. arr[9] = v & 0xff; // Parse ........-....-....-....-############
  66611. // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
  66612. arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
  66613. arr[11] = v / 0x100000000 & 0xff;
  66614. arr[12] = v >>> 24 & 0xff;
  66615. arr[13] = v >>> 16 & 0xff;
  66616. arr[14] = v >>> 8 & 0xff;
  66617. arr[15] = v & 0xff;
  66618. return arr;
  66619. }
  66620. var _default = parse;
  66621. exports.default = _default;
  66622. }, { "./validate.js": 539 }], 530: [function (require, module, exports) {
  66623. "use strict";
  66624. Object.defineProperty(exports, "__esModule", {
  66625. value: true
  66626. });
  66627. exports.default = void 0;
  66628. var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
  66629. exports.default = _default;
  66630. }, {}], 531: [function (require, module, exports) {
  66631. "use strict";
  66632. Object.defineProperty(exports, "__esModule", {
  66633. value: true
  66634. });
  66635. exports.default = rng; // Unique ID creation requires a high quality random # generator. In the browser we therefore
  66636. // require the crypto API and do not support built-in fallback to lower quality random number
  66637. // generators (like Math.random()).
  66638. // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
  66639. // find the complete implementation of crypto (msCrypto) on IE11.
  66640. var getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
  66641. var rnds8 = new Uint8Array(16);
  66642. function rng() {
  66643. if (!getRandomValues) {
  66644. throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  66645. }
  66646. return getRandomValues(rnds8);
  66647. }
  66648. }, {}], 532: [function (require, module, exports) {
  66649. "use strict";
  66650. Object.defineProperty(exports, "__esModule", {
  66651. value: true
  66652. });
  66653. exports.default = void 0; // Adapted from Chris Veness' SHA1 code at
  66654. // http://www.movable-type.co.uk/scripts/sha1.html
  66655. function f(s, x, y, z) {
  66656. switch (s) {
  66657. case 0:
  66658. return x & y ^ ~x & z;
  66659. case 1:
  66660. return x ^ y ^ z;
  66661. case 2:
  66662. return x & y ^ x & z ^ y & z;
  66663. case 3:
  66664. return x ^ y ^ z;
  66665. }
  66666. }
  66667. function ROTL(x, n) {
  66668. return x << n | x >>> 32 - n;
  66669. }
  66670. function sha1(bytes) {
  66671. var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
  66672. var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
  66673. if (typeof bytes === 'string') {
  66674. var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  66675. bytes = [];
  66676. for (var i = 0; i < msg.length; ++i) {
  66677. bytes.push(msg.charCodeAt(i));
  66678. }
  66679. } else if (!Array.isArray(bytes)) {
  66680. // Convert Array-like to Array
  66681. bytes = Array.prototype.slice.call(bytes);
  66682. }
  66683. bytes.push(0x80);
  66684. var l = bytes.length / 4 + 2;
  66685. var N = Math.ceil(l / 16);
  66686. var M = new Array(N);
  66687. for (var _i = 0; _i < N; ++_i) {
  66688. var arr = new Uint32Array(16);
  66689. for (var j = 0; j < 16; ++j) {
  66690. arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
  66691. }
  66692. M[_i] = arr;
  66693. }
  66694. M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
  66695. M[N - 1][14] = Math.floor(M[N - 1][14]);
  66696. M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
  66697. for (var _i2 = 0; _i2 < N; ++_i2) {
  66698. var W = new Uint32Array(80);
  66699. for (var t = 0; t < 16; ++t) {
  66700. W[t] = M[_i2][t];
  66701. }
  66702. for (var _t = 16; _t < 80; ++_t) {
  66703. W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
  66704. }
  66705. var a = H[0];
  66706. var b = H[1];
  66707. var c = H[2];
  66708. var d = H[3];
  66709. var e = H[4];
  66710. for (var _t2 = 0; _t2 < 80; ++_t2) {
  66711. var s = Math.floor(_t2 / 20);
  66712. var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
  66713. e = d;
  66714. d = c;
  66715. c = ROTL(b, 30) >>> 0;
  66716. b = a;
  66717. a = T;
  66718. }
  66719. H[0] = H[0] + a >>> 0;
  66720. H[1] = H[1] + b >>> 0;
  66721. H[2] = H[2] + c >>> 0;
  66722. H[3] = H[3] + d >>> 0;
  66723. H[4] = H[4] + e >>> 0;
  66724. }
  66725. return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
  66726. }
  66727. var _default = sha1;
  66728. exports.default = _default;
  66729. }, {}], 533: [function (require, module, exports) {
  66730. "use strict";
  66731. Object.defineProperty(exports, "__esModule", {
  66732. value: true
  66733. });
  66734. exports.default = void 0;
  66735. var _validate = _interopRequireDefault(require("./validate.js"));
  66736. function _interopRequireDefault(obj) {
  66737. return obj && obj.__esModule ? obj : {
  66738. default: obj
  66739. };
  66740. }
  66741. /**
  66742. * Convert array of 16 byte values to UUID string format of the form:
  66743. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  66744. */
  66745. var byteToHex = [];
  66746. for (var i = 0; i < 256; ++i) {
  66747. byteToHex.push((i + 0x100).toString(16).substr(1));
  66748. }
  66749. function stringify(arr) {
  66750. var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  66751. // Note: Be careful editing this code! It's been tuned for performance
  66752. // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  66753. var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
  66754. // of the following:
  66755. // - One or more input array values don't map to a hex octet (leading to
  66756. // "undefined" in the uuid)
  66757. // - Invalid input values for the RFC `version` or `variant` fields
  66758. if (!(0, _validate.default)(uuid)) {
  66759. throw TypeError('Stringified UUID is invalid');
  66760. }
  66761. return uuid;
  66762. }
  66763. var _default = stringify;
  66764. exports.default = _default;
  66765. }, { "./validate.js": 539 }], 534: [function (require, module, exports) {
  66766. "use strict";
  66767. Object.defineProperty(exports, "__esModule", {
  66768. value: true
  66769. });
  66770. exports.default = void 0;
  66771. var _rng = _interopRequireDefault(require("./rng.js"));
  66772. var _stringify = _interopRequireDefault(require("./stringify.js"));
  66773. function _interopRequireDefault(obj) {
  66774. return obj && obj.__esModule ? obj : {
  66775. default: obj
  66776. };
  66777. } // **`v1()` - Generate time-based UUID**
  66778. //
  66779. // Inspired by https://github.com/LiosK/UUID.js
  66780. // and http://docs.python.org/library/uuid.html
  66781. var _nodeId;
  66782. var _clockseq; // Previous uuid creation time
  66783. var _lastMSecs = 0;
  66784. var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
  66785. function v1(options, buf, offset) {
  66786. var i = buf && offset || 0;
  66787. var b = buf || new Array(16);
  66788. options = options || {};
  66789. var node = options.node || _nodeId;
  66790. var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
  66791. // specified. We do this lazily to minimize issues related to insufficient
  66792. // system entropy. See #189
  66793. if (node == null || clockseq == null) {
  66794. var seedBytes = options.random || (options.rng || _rng.default)();
  66795. if (node == null) {
  66796. // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
  66797. node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
  66798. }
  66799. if (clockseq == null) {
  66800. // Per 4.2.2, randomize (14 bit) clockseq
  66801. clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
  66802. }
  66803. } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
  66804. // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
  66805. // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
  66806. // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
  66807. var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
  66808. // cycle to simulate higher resolution clock
  66809. var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
  66810. var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
  66811. if (dt < 0 && options.clockseq === undefined) {
  66812. clockseq = clockseq + 1 & 0x3fff;
  66813. } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
  66814. // time interval
  66815. if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
  66816. nsecs = 0;
  66817. } // Per 4.2.1.2 Throw error if too many uuids are requested
  66818. if (nsecs >= 10000) {
  66819. throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
  66820. }
  66821. _lastMSecs = msecs;
  66822. _lastNSecs = nsecs;
  66823. _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
  66824. msecs += 12219292800000; // `time_low`
  66825. var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
  66826. b[i++] = tl >>> 24 & 0xff;
  66827. b[i++] = tl >>> 16 & 0xff;
  66828. b[i++] = tl >>> 8 & 0xff;
  66829. b[i++] = tl & 0xff; // `time_mid`
  66830. var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
  66831. b[i++] = tmh >>> 8 & 0xff;
  66832. b[i++] = tmh & 0xff; // `time_high_and_version`
  66833. b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
  66834. b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
  66835. b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
  66836. b[i++] = clockseq & 0xff; // `node`
  66837. for (var n = 0; n < 6; ++n) {
  66838. b[i + n] = node[n];
  66839. }
  66840. return buf || (0, _stringify.default)(b);
  66841. }
  66842. var _default = v1;
  66843. exports.default = _default;
  66844. }, { "./rng.js": 531, "./stringify.js": 533 }], 535: [function (require, module, exports) {
  66845. "use strict";
  66846. Object.defineProperty(exports, "__esModule", {
  66847. value: true
  66848. });
  66849. exports.default = void 0;
  66850. var _v = _interopRequireDefault(require("./v35.js"));
  66851. var _md = _interopRequireDefault(require("./md5.js"));
  66852. function _interopRequireDefault(obj) {
  66853. return obj && obj.__esModule ? obj : {
  66854. default: obj
  66855. };
  66856. }
  66857. var v3 = (0, _v.default)('v3', 0x30, _md.default);
  66858. var _default = v3;
  66859. exports.default = _default;
  66860. }, { "./md5.js": 527, "./v35.js": 536 }], 536: [function (require, module, exports) {
  66861. "use strict";
  66862. Object.defineProperty(exports, "__esModule", {
  66863. value: true
  66864. });
  66865. exports.default = _default;
  66866. exports.URL = exports.DNS = void 0;
  66867. var _stringify = _interopRequireDefault(require("./stringify.js"));
  66868. var _parse = _interopRequireDefault(require("./parse.js"));
  66869. function _interopRequireDefault(obj) {
  66870. return obj && obj.__esModule ? obj : {
  66871. default: obj
  66872. };
  66873. }
  66874. function stringToBytes(str) {
  66875. str = unescape(encodeURIComponent(str)); // UTF8 escape
  66876. var bytes = [];
  66877. for (var i = 0; i < str.length; ++i) {
  66878. bytes.push(str.charCodeAt(i));
  66879. }
  66880. return bytes;
  66881. }
  66882. var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
  66883. exports.DNS = DNS;
  66884. var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
  66885. exports.URL = URL;
  66886. function _default(name, version, hashfunc) {
  66887. function generateUUID(value, namespace, buf, offset) {
  66888. if (typeof value === 'string') {
  66889. value = stringToBytes(value);
  66890. }
  66891. if (typeof namespace === 'string') {
  66892. namespace = (0, _parse.default)(namespace);
  66893. }
  66894. if (namespace.length !== 16) {
  66895. throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
  66896. } // Compute hash of namespace and value, Per 4.3
  66897. // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
  66898. // hashfunc([...namespace, ... value])`
  66899. var bytes = new Uint8Array(16 + value.length);
  66900. bytes.set(namespace);
  66901. bytes.set(value, namespace.length);
  66902. bytes = hashfunc(bytes);
  66903. bytes[6] = bytes[6] & 0x0f | version;
  66904. bytes[8] = bytes[8] & 0x3f | 0x80;
  66905. if (buf) {
  66906. offset = offset || 0;
  66907. for (var i = 0; i < 16; ++i) {
  66908. buf[offset + i] = bytes[i];
  66909. }
  66910. return buf;
  66911. }
  66912. return (0, _stringify.default)(bytes);
  66913. } // Function#name is not settable on some platforms (#270)
  66914. try {
  66915. generateUUID.name = name; // eslint-disable-next-line no-empty
  66916. } catch (err) { } // For CommonJS default export support
  66917. generateUUID.DNS = DNS;
  66918. generateUUID.URL = URL;
  66919. return generateUUID;
  66920. }
  66921. }, { "./parse.js": 529, "./stringify.js": 533 }], 537: [function (require, module, exports) {
  66922. "use strict";
  66923. Object.defineProperty(exports, "__esModule", {
  66924. value: true
  66925. });
  66926. exports.default = void 0;
  66927. var _rng = _interopRequireDefault(require("./rng.js"));
  66928. var _stringify = _interopRequireDefault(require("./stringify.js"));
  66929. function _interopRequireDefault(obj) {
  66930. return obj && obj.__esModule ? obj : {
  66931. default: obj
  66932. };
  66933. }
  66934. function v4(options, buf, offset) {
  66935. options = options || {};
  66936. var rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  66937. rnds[6] = rnds[6] & 0x0f | 0x40;
  66938. rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
  66939. if (buf) {
  66940. offset = offset || 0;
  66941. for (var i = 0; i < 16; ++i) {
  66942. buf[offset + i] = rnds[i];
  66943. }
  66944. return buf;
  66945. }
  66946. return (0, _stringify.default)(rnds);
  66947. }
  66948. var _default = v4;
  66949. exports.default = _default;
  66950. }, { "./rng.js": 531, "./stringify.js": 533 }], 538: [function (require, module, exports) {
  66951. "use strict";
  66952. Object.defineProperty(exports, "__esModule", {
  66953. value: true
  66954. });
  66955. exports.default = void 0;
  66956. var _v = _interopRequireDefault(require("./v35.js"));
  66957. var _sha = _interopRequireDefault(require("./sha1.js"));
  66958. function _interopRequireDefault(obj) {
  66959. return obj && obj.__esModule ? obj : {
  66960. default: obj
  66961. };
  66962. }
  66963. var v5 = (0, _v.default)('v5', 0x50, _sha.default);
  66964. var _default = v5;
  66965. exports.default = _default;
  66966. }, { "./sha1.js": 532, "./v35.js": 536 }], 539: [function (require, module, exports) {
  66967. "use strict";
  66968. Object.defineProperty(exports, "__esModule", {
  66969. value: true
  66970. });
  66971. exports.default = void 0;
  66972. var _regex = _interopRequireDefault(require("./regex.js"));
  66973. function _interopRequireDefault(obj) {
  66974. return obj && obj.__esModule ? obj : {
  66975. default: obj
  66976. };
  66977. }
  66978. function validate(uuid) {
  66979. return typeof uuid === 'string' && _regex.default.test(uuid);
  66980. }
  66981. var _default = validate;
  66982. exports.default = _default;
  66983. }, { "./regex.js": 530 }], 540: [function (require, module, exports) {
  66984. "use strict";
  66985. Object.defineProperty(exports, "__esModule", {
  66986. value: true
  66987. });
  66988. exports.default = void 0;
  66989. var _validate = _interopRequireDefault(require("./validate.js"));
  66990. function _interopRequireDefault(obj) {
  66991. return obj && obj.__esModule ? obj : {
  66992. default: obj
  66993. };
  66994. }
  66995. function version(uuid) {
  66996. if (!(0, _validate.default)(uuid)) {
  66997. throw TypeError('Invalid UUID');
  66998. }
  66999. return parseInt(uuid.substr(14, 1), 16);
  67000. }
  67001. var _default = version;
  67002. exports.default = _default;
  67003. }, { "./validate.js": 539 }], 541: [function (require, module, exports) {
  67004. "use strict";
  67005. /**
  67006. * Character classes and associated utilities for the 5th edition of XML 1.0.
  67007. *
  67008. * @author Louis-Dominique Dubeau
  67009. * @license MIT
  67010. * @copyright Louis-Dominique Dubeau
  67011. */
  67012. Object.defineProperty(exports, "__esModule", {
  67013. value: true
  67014. }); //
  67015. // Fragments.
  67016. //
  67017. exports.CHAR = "\t\n\r -\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF";
  67018. exports.S = " \t\r\n"; // tslint:disable-next-line:max-line-length
  67019. exports.NAME_START_CHAR = ":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\uD800\uDC00-\uDB7F\uDFFF";
  67020. exports.NAME_CHAR = "-" + exports.NAME_START_CHAR + ".0-9\xB7\u0300-\u036F\u203F-\u2040"; //
  67021. // Regular expressions.
  67022. //
  67023. // exports.CHAR_RE = new RegExp("^[" + exports.CHAR + "]$", "u");
  67024. // exports.S_RE = new RegExp("^[" + exports.S + "]+$", "u");
  67025. // exports.NAME_START_CHAR_RE = new RegExp("^[" + exports.NAME_START_CHAR + "]$", "u");
  67026. // exports.NAME_CHAR_RE = new RegExp("^[" + exports.NAME_CHAR + "]$", "u");
  67027. // exports.NAME_RE = new RegExp("^[" + exports.NAME_START_CHAR + "][" + exports.NAME_CHAR + "]*$", "u");
  67028. // exports.NMTOKEN_RE = new RegExp("^[" + exports.NAME_CHAR + "]+$", "u");
  67029. var TAB = 9;
  67030. var NL = 0xA;
  67031. var CR = 0xD;
  67032. var SPACE = 0x20; //
  67033. // Lists.
  67034. //
  67035. /** All characters in the ``S`` production. */
  67036. exports.S_LIST = [SPACE, NL, CR, TAB];
  67037. /**
  67038. * Determines whether a codepoint matches the ``CHAR`` production.
  67039. *
  67040. * @param c The code point.
  67041. *
  67042. * @returns ``true`` if the codepoint matches ``CHAR``.
  67043. */
  67044. function isChar(c) {
  67045. return c >= SPACE && c <= 0xD7FF || c === NL || c === CR || c === TAB || c >= 0xE000 && c <= 0xFFFD || c >= 0x10000 && c <= 0x10FFFF;
  67046. }
  67047. exports.isChar = isChar;
  67048. /**
  67049. * Determines whether a codepoint matches the ``S`` (space) production.
  67050. *
  67051. * @param c The code point.
  67052. *
  67053. * @returns ``true`` if the codepoint matches ``S``.
  67054. */
  67055. function isS(c) {
  67056. return c === SPACE || c === NL || c === CR || c === TAB;
  67057. }
  67058. exports.isS = isS;
  67059. /**
  67060. * Determines whether a codepoint matches the ``NAME_START_CHAR`` production.
  67061. *
  67062. * @param c The code point.
  67063. *
  67064. * @returns ``true`` if the codepoint matches ``NAME_START_CHAR``.
  67065. */
  67066. function isNameStartChar(c) {
  67067. return c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A || c === 0x3A || c === 0x5F || c === 0x200C || c === 0x200D || c >= 0xC0 && c <= 0xD6 || c >= 0xD8 && c <= 0xF6 || c >= 0x00F8 && c <= 0x02FF || c >= 0x0370 && c <= 0x037D || c >= 0x037F && c <= 0x1FFF || c >= 0x2070 && c <= 0x218F || c >= 0x2C00 && c <= 0x2FEF || c >= 0x3001 && c <= 0xD7FF || c >= 0xF900 && c <= 0xFDCF || c >= 0xFDF0 && c <= 0xFFFD || c >= 0x10000 && c <= 0xEFFFF;
  67068. }
  67069. exports.isNameStartChar = isNameStartChar;
  67070. /**
  67071. * Determines whether a codepoint matches the ``NAME_CHAR`` production.
  67072. *
  67073. * @param c The code point.
  67074. *
  67075. * @returns ``true`` if the codepoint matches ``NAME_CHAR``.
  67076. */
  67077. function isNameChar(c) {
  67078. return isNameStartChar(c) || c >= 0x30 && c <= 0x39 || c === 0x2D || c === 0x2E || c === 0xB7 || c >= 0x0300 && c <= 0x036F || c >= 0x203F && c <= 0x2040;
  67079. }
  67080. exports.isNameChar = isNameChar;
  67081. }, {}], 542: [function (require, module, exports) {
  67082. "use strict";
  67083. /**
  67084. * Character classes and associated utilities for the 2nd edition of XML 1.1.
  67085. *
  67086. * @author Louis-Dominique Dubeau
  67087. * @license MIT
  67088. * @copyright Louis-Dominique Dubeau
  67089. */
  67090. Object.defineProperty(exports, "__esModule", {
  67091. value: true
  67092. }); //
  67093. // Fragments.
  67094. //
  67095. exports.CHAR = "\x01-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF";
  67096. exports.RESTRICTED_CHAR = "\x01-\b\x0B\f\x0E-\x1F\x7F-\x84\x86-\x9F";
  67097. exports.S = " \t\r\n"; // tslint:disable-next-line:max-line-length
  67098. exports.NAME_START_CHAR = ":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\uD800\uDC00-\uDB7F\uDFFF";
  67099. exports.NAME_CHAR = "-" + exports.NAME_START_CHAR + ".0-9\xB7\u0300-\u036F\u203F-\u2040"; //
  67100. // Regular expressions.
  67101. //
  67102. // exports.CHAR_RE = new RegExp("^[" + exports.CHAR + "]$", "u");
  67103. // exports.RESTRICTED_CHAR_RE = new RegExp("^[" + exports.RESTRICTED_CHAR + "]$", "u");
  67104. // exports.S_RE = new RegExp("^[" + exports.S + "]+$", "u");
  67105. // exports.NAME_START_CHAR_RE = new RegExp("^[" + exports.NAME_START_CHAR + "]$", "u");
  67106. // exports.NAME_CHAR_RE = new RegExp("^[" + exports.NAME_CHAR + "]$", "u");
  67107. // exports.NAME_RE = new RegExp("^[" + exports.NAME_START_CHAR + "][" + exports.NAME_CHAR + "]*$", "u");
  67108. // exports.NMTOKEN_RE = new RegExp("^[" + exports.NAME_CHAR + "]+$", "u");
  67109. var TAB = 9;
  67110. var NL = 0xA;
  67111. var CR = 0xD;
  67112. var SPACE = 0x20; //
  67113. // Lists.
  67114. //
  67115. /** All characters in the ``S`` production. */
  67116. exports.S_LIST = [SPACE, NL, CR, TAB];
  67117. /**
  67118. * Determines whether a codepoint matches the ``CHAR`` production.
  67119. *
  67120. * @param c The code point.
  67121. *
  67122. * @returns ``true`` if the codepoint matches ``CHAR``.
  67123. */
  67124. function isChar(c) {
  67125. return c >= 0x0001 && c <= 0xD7FF || c >= 0xE000 && c <= 0xFFFD || c >= 0x10000 && c <= 0x10FFFF;
  67126. }
  67127. exports.isChar = isChar;
  67128. /**
  67129. * Determines whether a codepoint matches the ``RESTRICTED_CHAR`` production.
  67130. *
  67131. * @param c The code point.
  67132. *
  67133. * @returns ``true`` if the codepoint matches ``RESTRICTED_CHAR``.
  67134. */
  67135. function isRestrictedChar(c) {
  67136. return c >= 0x1 && c <= 0x8 || c === 0xB || c === 0xC || c >= 0xE && c <= 0x1F || c >= 0x7F && c <= 0x84 || c >= 0x86 && c <= 0x9F;
  67137. }
  67138. exports.isRestrictedChar = isRestrictedChar;
  67139. /**
  67140. * Determines whether a codepoint matches the ``CHAR`` production and does not
  67141. * match the ``RESTRICTED_CHAR`` production. ``isCharAndNotRestricted(x)`` is
  67142. * equivalent to ``isChar(x) && !isRestrictedChar(x)``. This function is faster
  67143. * than running the two-call equivalent.
  67144. *
  67145. * @param c The code point.
  67146. *
  67147. * @returns ``true`` if the codepoint matches ``CHAR`` and does not match
  67148. * ``RESTRICTED_CHAR``.
  67149. */
  67150. function isCharAndNotRestricted(c) {
  67151. return c === 0x9 || c === 0xA || c === 0xD || c > 0x1F && c < 0x7F || c === 0x85 || c > 0x9F && c <= 0xD7FF || c >= 0xE000 && c <= 0xFFFD || c >= 0x10000 && c <= 0x10FFFF;
  67152. }
  67153. exports.isCharAndNotRestricted = isCharAndNotRestricted;
  67154. /**
  67155. * Determines whether a codepoint matches the ``S`` (space) production.
  67156. *
  67157. * @param c The code point.
  67158. *
  67159. * @returns ``true`` if the codepoint matches ``S``.
  67160. */
  67161. function isS(c) {
  67162. return c === SPACE || c === NL || c === CR || c === TAB;
  67163. }
  67164. exports.isS = isS;
  67165. /**
  67166. * Determines whether a codepoint matches the ``NAME_START_CHAR`` production.
  67167. *
  67168. * @param c The code point.
  67169. *
  67170. * @returns ``true`` if the codepoint matches ``NAME_START_CHAR``.
  67171. */
  67172. // tslint:disable-next-line:cyclomatic-complexity
  67173. function isNameStartChar(c) {
  67174. return c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A || c === 0x3A || c === 0x5F || c === 0x200C || c === 0x200D || c >= 0xC0 && c <= 0xD6 || c >= 0xD8 && c <= 0xF6 || c >= 0x00F8 && c <= 0x02FF || c >= 0x0370 && c <= 0x037D || c >= 0x037F && c <= 0x1FFF || c >= 0x2070 && c <= 0x218F || c >= 0x2C00 && c <= 0x2FEF || c >= 0x3001 && c <= 0xD7FF || c >= 0xF900 && c <= 0xFDCF || c >= 0xFDF0 && c <= 0xFFFD || c >= 0x10000 && c <= 0xEFFFF;
  67175. }
  67176. exports.isNameStartChar = isNameStartChar;
  67177. /**
  67178. * Determines whether a codepoint matches the ``NAME_CHAR`` production.
  67179. *
  67180. * @param c The code point.
  67181. *
  67182. * @returns ``true`` if the codepoint matches ``NAME_CHAR``.
  67183. */
  67184. function isNameChar(c) {
  67185. return isNameStartChar(c) || c >= 0x30 && c <= 0x39 || c === 0x2D || c === 0x2E || c === 0xB7 || c >= 0x0300 && c <= 0x036F || c >= 0x203F && c <= 0x2040;
  67186. }
  67187. exports.isNameChar = isNameChar;
  67188. }, {}], 543: [function (require, module, exports) {
  67189. "use strict";
  67190. /**
  67191. * Character class utilities for XML NS 1.0 edition 3.
  67192. *
  67193. * @author Louis-Dominique Dubeau
  67194. * @license MIT
  67195. * @copyright Louis-Dominique Dubeau
  67196. */
  67197. Object.defineProperty(exports, "__esModule", {
  67198. value: true
  67199. }); //
  67200. // Fragments.
  67201. //
  67202. // tslint:disable-next-line:max-line-length
  67203. exports.NC_NAME_START_CHAR = "A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\uD800\uDC00-\uDB7F\uDFFF";
  67204. exports.NC_NAME_CHAR = "-" + exports.NC_NAME_START_CHAR + ".0-9\xB7\u0300-\u036F\u203F-\u2040"; //
  67205. // Regular expressions.
  67206. //
  67207. // exports.NC_NAME_START_CHAR_RE = new RegExp("^[" + exports.NC_NAME_START_CHAR + "]$", "u");
  67208. // exports.NC_NAME_CHAR_RE = new RegExp("^[" + exports.NC_NAME_CHAR + "]$", "u");
  67209. // exports.NC_NAME_RE = new RegExp("^[" + exports.NC_NAME_START_CHAR + "][" + exports.NC_NAME_CHAR + "]*$", "u");
  67210. /**
  67211. * Determines whether a codepoint matches [[NC_NAME_START_CHAR]].
  67212. *
  67213. * @param c The code point.
  67214. *
  67215. * @returns ``true`` if the codepoint matches.
  67216. */
  67217. // tslint:disable-next-line:cyclomatic-complexity
  67218. function isNCNameStartChar(c) {
  67219. return c >= 0x41 && c <= 0x5A || c === 0x5F || c >= 0x61 && c <= 0x7A || c >= 0xC0 && c <= 0xD6 || c >= 0xD8 && c <= 0xF6 || c >= 0x00F8 && c <= 0x02FF || c >= 0x0370 && c <= 0x037D || c >= 0x037F && c <= 0x1FFF || c >= 0x200C && c <= 0x200D || c >= 0x2070 && c <= 0x218F || c >= 0x2C00 && c <= 0x2FEF || c >= 0x3001 && c <= 0xD7FF || c >= 0xF900 && c <= 0xFDCF || c >= 0xFDF0 && c <= 0xFFFD || c >= 0x10000 && c <= 0xEFFFF;
  67220. }
  67221. exports.isNCNameStartChar = isNCNameStartChar;
  67222. /**
  67223. * Determines whether a codepoint matches [[NC_NAME_CHAR]].
  67224. *
  67225. * @param c The code point.
  67226. *
  67227. * @returns ``true`` if the codepoint matches.
  67228. */
  67229. function isNCNameChar(c) {
  67230. return isNCNameStartChar(c) || c === 0x2D || c === 0x2E || c >= 0x30 && c <= 0x39 || c === 0x00B7 || c >= 0x0300 && c <= 0x036F || c >= 0x203F && c <= 0x2040;
  67231. }
  67232. exports.isNCNameChar = isNCNameChar;
  67233. }, {}]
  67234. }, {}, [15])(15)
  67235. });
  67236. //# sourceMappingURL=exceljs.js.map