kml-geojson-src.js 272 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024
  1. /*!
  2. * kml与geojson互转工具类
  3. * 版本信息:v1.1.0, hash值: 1cf0769e0dcb8c6a7e75
  4. * 编译日期:2021-08-11 18:07:46
  5. * 版权所有:Copyright by 木遥 https://github.com/muyao1987/kml-geojson
  6. *
  7. */
  8. (function webpackUniversalModuleDefinition(root, factory) {
  9. if(typeof exports === 'object' && typeof module === 'object')
  10. module.exports = factory();
  11. else if(typeof define === 'function' && define.amd)
  12. define("kgUtil", [], factory);
  13. else if(typeof exports === 'object')
  14. exports["kgUtil"] = factory();
  15. else
  16. root["kgUtil"] = factory();
  17. })(window, function() {
  18. return /******/ (function(modules) { // webpackBootstrap
  19. /******/ // The module cache
  20. /******/ var installedModules = {};
  21. /******/
  22. /******/ // The require function
  23. /******/ function __webpack_require__(moduleId) {
  24. /******/
  25. /******/ // Check if module is in cache
  26. /******/ if(installedModules[moduleId]) {
  27. /******/ return installedModules[moduleId].exports;
  28. /******/ }
  29. /******/ // Create a new module (and put it into the cache)
  30. /******/ var module = installedModules[moduleId] = {
  31. /******/ i: moduleId,
  32. /******/ l: false,
  33. /******/ exports: {}
  34. /******/ };
  35. /******/
  36. /******/ // Execute the module function
  37. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38. /******/
  39. /******/ // Flag the module as loaded
  40. /******/ module.l = true;
  41. /******/
  42. /******/ // Return the exports of the module
  43. /******/ return module.exports;
  44. /******/ }
  45. /******/
  46. /******/
  47. /******/ // expose the modules object (__webpack_modules__)
  48. /******/ __webpack_require__.m = modules;
  49. /******/
  50. /******/ // expose the module cache
  51. /******/ __webpack_require__.c = installedModules;
  52. /******/
  53. /******/ // define getter function for harmony exports
  54. /******/ __webpack_require__.d = function(exports, name, getter) {
  55. /******/ if(!__webpack_require__.o(exports, name)) {
  56. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  57. /******/ }
  58. /******/ };
  59. /******/
  60. /******/ // define __esModule on exports
  61. /******/ __webpack_require__.r = function(exports) {
  62. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  63. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  64. /******/ }
  65. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  66. /******/ };
  67. /******/
  68. /******/ // create a fake namespace object
  69. /******/ // mode & 1: value is a module id, require it
  70. /******/ // mode & 2: merge all properties of value into the ns
  71. /******/ // mode & 4: return value when already ns object
  72. /******/ // mode & 8|1: behave like require
  73. /******/ __webpack_require__.t = function(value, mode) {
  74. /******/ if(mode & 1) value = __webpack_require__(value);
  75. /******/ if(mode & 8) return value;
  76. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  77. /******/ var ns = Object.create(null);
  78. /******/ __webpack_require__.r(ns);
  79. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  80. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  81. /******/ return ns;
  82. /******/ };
  83. /******/
  84. /******/ // getDefaultExport function for compatibility with non-harmony modules
  85. /******/ __webpack_require__.n = function(module) {
  86. /******/ var getter = module && module.__esModule ?
  87. /******/ function getDefault() { return module['default']; } :
  88. /******/ function getModuleExports() { return module; };
  89. /******/ __webpack_require__.d(getter, 'a', getter);
  90. /******/ return getter;
  91. /******/ };
  92. /******/
  93. /******/ // Object.prototype.hasOwnProperty.call
  94. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  95. /******/
  96. /******/ // __webpack_public_path__
  97. /******/ __webpack_require__.p = "";
  98. /******/
  99. /******/
  100. /******/ // Load entry module and return exports
  101. /******/ return __webpack_require__(__webpack_require__.s = 16);
  102. /******/ })
  103. /************************************************************************/
  104. /******/ ([
  105. /* 0 */
  106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107. "use strict";
  108. /* WEBPACK VAR INJECTION */(function(process) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return kmlToGeoJSON; });
  109. /* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
  110. /* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__);
  111. // kml => geojson
  112. var removeSpace = /\s*/g,
  113. trimSpace = /^\s*|\s*$/g,
  114. splitSpace = /\s+/; // generate a short, numeric hash of a string
  115. function okhash(x) {
  116. if (!x || !x.length) return 0;
  117. for (var i = 0, h = 0; i < x.length; i++) {
  118. h = (h << 5) - h + x.charCodeAt(i) | 0;
  119. }
  120. return h;
  121. } // all Y children of X
  122. function get(x, y) {
  123. return x.getElementsByTagName(y);
  124. }
  125. function attr(x, y) {
  126. return x.getAttribute(y);
  127. }
  128. function attrf(x, y) {
  129. return parseFloat(attr(x, y));
  130. } // one Y child of X, if any, otherwise null
  131. function get1(x, y) {
  132. var n = get(x, y);
  133. return n.length ? n[0] : null;
  134. } // https://developer.mozilla.org/en-US/docs/Web/API/Node.normalize
  135. function norm(el) {
  136. if (el.normalize) {
  137. el.normalize();
  138. }
  139. return el;
  140. } // cast array x into numbers
  141. function numarray(x) {
  142. for (var j = 0, o = []; j < x.length; j++) {
  143. o[j] = parseFloat(x[j]);
  144. }
  145. return o;
  146. } // get the content of a text node, if any
  147. function nodeVal(x) {
  148. if (x) {
  149. norm(x);
  150. }
  151. return x && x.textContent || '';
  152. } // get the contents of multiple text nodes, if present
  153. // function getMulti(x, ys) {
  154. // var o = {},
  155. // n,
  156. // k
  157. // for (k = 0; k < ys.length; k++) {
  158. // n = get1(x, ys[k])
  159. // if (n) o[ys[k]] = nodeVal(n)
  160. // }
  161. // return o
  162. // }
  163. // add properties of Y to X, overwriting if present in both
  164. // function extend(x, y) {
  165. // for (var k in y) x[k] = y[k]
  166. // }
  167. // get one coordinate from a coordinate array, if any
  168. function coord1(v) {
  169. return numarray(v.replace(removeSpace, '').split(','));
  170. } // get all coordinates from a coordinate array as [[],[]]
  171. function coord(v) {
  172. var coords = v.replace(trimSpace, '').split(splitSpace),
  173. o = [];
  174. for (var i = 0; i < coords.length; i++) {
  175. o.push(coord1(coords[i]));
  176. }
  177. return o;
  178. } // function coordPair(x) {
  179. // var ll = [attrf(x, 'lon'), attrf(x, 'lat')],
  180. // ele = get1(x, 'ele'),
  181. // // handle namespaced attribute in browser
  182. // heartRate = get1(x, 'gpxtpx:hr') || get1(x, 'hr'),
  183. // time = get1(x, 'time'),
  184. // e
  185. // if (ele) {
  186. // e = parseFloat(nodeVal(ele))
  187. // if (!isNaN(e)) {
  188. // ll.push(e)
  189. // }
  190. // }
  191. // return {
  192. // coordinates: ll,
  193. // time: time ? nodeVal(time) : null,
  194. // heartRate: heartRate ? parseFloat(nodeVal(heartRate)) : null,
  195. // }
  196. // }
  197. // create a new feature collection parent object
  198. function fc() {
  199. return {
  200. type: 'FeatureCollection',
  201. features: []
  202. };
  203. }
  204. var serializer;
  205. if (typeof XMLSerializer !== 'undefined') {
  206. /* istanbul ignore next */
  207. serializer = new XMLSerializer(); // only require xmldom in a node environment
  208. } else if ((typeof exports === "undefined" ? "undefined" : _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default()(exports)) === 'object' && (typeof process === "undefined" ? "undefined" : _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default()(process)) === 'object' && !process.browser) {
  209. serializer = new (__webpack_require__(13).XMLSerializer)();
  210. }
  211. function xml2str(str) {
  212. // IE9 will create a new XMLSerializer but it'll crash immediately.
  213. // This line is ignored because we don't run coverage tests in IE9
  214. /* istanbul ignore next */
  215. if (str.xml !== undefined) return str.xml;
  216. return serializer.serializeToString(str);
  217. }
  218. function kmlToGeoJSON(doc) {
  219. var gj = fc(),
  220. // styleindex keeps track of hashed styles in order to match features
  221. styleIndex = {},
  222. styleByHash = {},
  223. // stylemapindex keeps track of style maps to expose in properties
  224. styleMapIndex = {},
  225. // atomic geospatial types supported by KML - MultiGeometry is
  226. // handled separately
  227. geotypes = ['Polygon', 'LineString', 'Point', 'Track', 'gx:Track'],
  228. // all root placemarks in the file
  229. placemarks = get(doc, 'Placemark'),
  230. styles = get(doc, 'Style'),
  231. styleMaps = get(doc, 'StyleMap');
  232. for (var k = 0; k < styles.length; k++) {
  233. var hash = okhash(xml2str(styles[k])).toString(16);
  234. styleIndex['#' + attr(styles[k], 'id')] = hash;
  235. styleByHash[hash] = styles[k];
  236. }
  237. for (var l = 0; l < styleMaps.length; l++) {
  238. styleIndex['#' + attr(styleMaps[l], 'id')] = okhash(xml2str(styleMaps[l])).toString(16);
  239. var pairs = get(styleMaps[l], 'Pair');
  240. var pairsMap = {};
  241. for (var m = 0; m < pairs.length; m++) {
  242. pairsMap[nodeVal(get1(pairs[m], 'key'))] = nodeVal(get1(pairs[m], 'styleUrl'));
  243. }
  244. styleMapIndex['#' + attr(styleMaps[l], 'id')] = pairsMap;
  245. }
  246. for (var j = 0; j < placemarks.length; j++) {
  247. gj.features = gj.features.concat(getPlacemark(placemarks[j]));
  248. }
  249. function kmlColor(v) {
  250. var color, opacity;
  251. v = v || '';
  252. if (v.substr(0, 1) === '#') {
  253. v = v.substr(1);
  254. }
  255. if (v.length === 6 || v.length === 3) {
  256. color = v;
  257. }
  258. if (v.length === 8) {
  259. opacity = parseInt(v.substr(0, 2), 16) / 255;
  260. color = '#' + v.substr(6, 2) + v.substr(4, 2) + v.substr(2, 2);
  261. }
  262. return [color, isNaN(opacity) ? undefined : opacity];
  263. }
  264. function gxCoord(v) {
  265. return numarray(v.split(' '));
  266. }
  267. function gxCoords(root) {
  268. var elems = get(root, 'coord', 'gx'),
  269. coords = [],
  270. times = [];
  271. if (elems.length === 0) elems = get(root, 'gx:coord');
  272. for (var i = 0; i < elems.length; i++) {
  273. coords.push(gxCoord(nodeVal(elems[i])));
  274. }
  275. var timeElems = get(root, 'when');
  276. for (var j = 0; j < timeElems.length; j++) {
  277. times.push(nodeVal(timeElems[j]));
  278. }
  279. return {
  280. coords: coords,
  281. times: times
  282. };
  283. }
  284. function getGeometry(root) {
  285. var geomNode,
  286. geomNodes,
  287. i,
  288. j,
  289. k,
  290. geoms = [],
  291. coordTimes = [];
  292. if (get1(root, 'MultiGeometry')) {
  293. return getGeometry(get1(root, 'MultiGeometry'));
  294. }
  295. if (get1(root, 'MultiTrack')) {
  296. return getGeometry(get1(root, 'MultiTrack'));
  297. }
  298. if (get1(root, 'gx:MultiTrack')) {
  299. return getGeometry(get1(root, 'gx:MultiTrack'));
  300. }
  301. for (i = 0; i < geotypes.length; i++) {
  302. geomNodes = get(root, geotypes[i]);
  303. if (geomNodes) {
  304. for (j = 0; j < geomNodes.length; j++) {
  305. geomNode = geomNodes[j];
  306. if (geotypes[i] === 'Point') {
  307. geoms.push({
  308. type: 'Point',
  309. coordinates: coord1(nodeVal(get1(geomNode, 'coordinates')))
  310. });
  311. } else if (geotypes[i] === 'LineString') {
  312. geoms.push({
  313. type: 'LineString',
  314. coordinates: coord(nodeVal(get1(geomNode, 'coordinates')))
  315. });
  316. } else if (geotypes[i] === 'Polygon') {
  317. var rings = get(geomNode, 'LinearRing'),
  318. coords = [];
  319. for (k = 0; k < rings.length; k++) {
  320. coords.push(coord(nodeVal(get1(rings[k], 'coordinates'))));
  321. }
  322. geoms.push({
  323. type: 'Polygon',
  324. coordinates: coords
  325. });
  326. } else if (geotypes[i] === 'Track' || geotypes[i] === 'gx:Track') {
  327. var track = gxCoords(geomNode);
  328. geoms.push({
  329. type: 'LineString',
  330. coordinates: track.coords
  331. });
  332. if (track.times.length) coordTimes.push(track.times);
  333. }
  334. }
  335. }
  336. }
  337. return {
  338. geoms: geoms,
  339. coordTimes: coordTimes
  340. };
  341. }
  342. function getPlacemark(root) {
  343. var geomsAndTimes = getGeometry(root),
  344. i,
  345. properties = {},
  346. name = nodeVal(get1(root, 'name')),
  347. styleUrl = nodeVal(get1(root, 'styleUrl')),
  348. description = nodeVal(get1(root, 'description')),
  349. timeSpan = get1(root, 'TimeSpan'),
  350. timeStamp = get1(root, 'TimeStamp'),
  351. extendedData = get1(root, 'ExtendedData'),
  352. lineStyle = get1(root, 'LineStyle'),
  353. polyStyle = get1(root, 'PolyStyle'),
  354. visibility = get1(root, 'visibility');
  355. if (!geomsAndTimes.geoms.length) return [];
  356. if (name) properties.name = name;
  357. if (styleUrl) {
  358. if (styleUrl[0] !== '#') {
  359. styleUrl = '#' + styleUrl;
  360. }
  361. properties.styleUrl = styleUrl;
  362. if (styleIndex[styleUrl]) {
  363. properties.styleHash = styleIndex[styleUrl];
  364. }
  365. if (styleMapIndex[styleUrl]) {
  366. properties.styleMapHash = styleMapIndex[styleUrl];
  367. properties.styleHash = styleIndex[styleMapIndex[styleUrl].normal];
  368. } // Try to populate the lineStyle or polyStyle since we got the style hash
  369. var style = styleByHash[properties.styleHash];
  370. if (style) {
  371. if (!lineStyle) lineStyle = get1(style, 'LineStyle');
  372. if (!polyStyle) polyStyle = get1(style, 'PolyStyle');
  373. }
  374. }
  375. if (description) properties.description = description;
  376. if (timeSpan) {
  377. var begin = nodeVal(get1(timeSpan, 'begin'));
  378. var end = nodeVal(get1(timeSpan, 'end'));
  379. properties.timespan = {
  380. begin: begin,
  381. end: end
  382. };
  383. }
  384. if (timeStamp) {
  385. properties.timestamp = nodeVal(get1(timeStamp, 'when'));
  386. }
  387. if (lineStyle) {
  388. var linestyles = kmlColor(nodeVal(get1(lineStyle, 'color'))),
  389. color = linestyles[0],
  390. opacity = linestyles[1],
  391. width = parseFloat(nodeVal(get1(lineStyle, 'width')));
  392. if (color) properties.stroke = color;
  393. if (!isNaN(opacity)) properties['stroke-opacity'] = opacity;
  394. if (!isNaN(width)) properties['stroke-width'] = width;
  395. }
  396. if (polyStyle) {
  397. var polystyles = kmlColor(nodeVal(get1(polyStyle, 'color'))),
  398. pcolor = polystyles[0],
  399. popacity = polystyles[1],
  400. fill = nodeVal(get1(polyStyle, 'fill')),
  401. outline = nodeVal(get1(polyStyle, 'outline'));
  402. if (pcolor) properties.fill = pcolor;
  403. if (!isNaN(popacity)) properties['fill-opacity'] = popacity;
  404. if (fill) properties['fill-opacity'] = fill === '1' ? properties['fill-opacity'] || 1 : 0;
  405. if (outline) properties['stroke-opacity'] = outline === '1' ? properties['stroke-opacity'] || 1 : 0;
  406. }
  407. if (extendedData) {
  408. var datas = get(extendedData, 'Data'),
  409. simpleDatas = get(extendedData, 'SimpleData');
  410. for (i = 0; i < datas.length; i++) {
  411. var _name = datas[i].getAttribute('name');
  412. var val = nodeVal(get1(datas[i], 'value'));
  413. try {
  414. val = JSON.parse(val);
  415. } catch (e) {}
  416. properties[_name] = val;
  417. }
  418. for (i = 0; i < simpleDatas.length; i++) {
  419. var _name2 = simpleDatas[i].getAttribute('name');
  420. var _val = nodeVal(simpleDatas[i]);
  421. try {
  422. _val = JSON.parse(_val);
  423. } catch (e) {}
  424. properties[_name2] = _val;
  425. }
  426. }
  427. if (visibility) {
  428. properties.visibility = nodeVal(visibility);
  429. }
  430. if (geomsAndTimes.coordTimes.length) {
  431. properties.coordTimes = geomsAndTimes.coordTimes.length === 1 ? geomsAndTimes.coordTimes[0] : geomsAndTimes.coordTimes;
  432. }
  433. var feature = {
  434. type: 'Feature',
  435. geometry: geomsAndTimes.geoms.length === 1 ? geomsAndTimes.geoms[0] : {
  436. type: 'GeometryCollection',
  437. geometries: geomsAndTimes.geoms
  438. },
  439. properties: properties
  440. };
  441. if (attr(root, 'id')) feature.id = attr(root, 'id');
  442. return [feature];
  443. }
  444. return gj;
  445. }
  446. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(3)))
  447. /***/ }),
  448. /* 1 */
  449. /***/ (function(module, exports) {
  450. var g;
  451. // This works in non-strict mode
  452. g = (function() {
  453. return this;
  454. })();
  455. try {
  456. // This works if eval is allowed (see CSP)
  457. g = g || new Function("return this")();
  458. } catch (e) {
  459. // This works if the window reference is available
  460. if (typeof window === "object") g = window;
  461. }
  462. // g can still be undefined, but nothing to do about it...
  463. // We return undefined, instead of nothing here, so it's
  464. // easier to handle this case. if(!global) { ...}
  465. module.exports = g;
  466. /***/ }),
  467. /* 2 */
  468. /***/ (function(module, exports) {
  469. function _typeof(obj) {
  470. "@babel/helpers - typeof";
  471. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  472. module.exports = _typeof = function _typeof(obj) {
  473. return typeof obj;
  474. };
  475. module.exports["default"] = module.exports, module.exports.__esModule = true;
  476. } else {
  477. module.exports = _typeof = function _typeof(obj) {
  478. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  479. };
  480. module.exports["default"] = module.exports, module.exports.__esModule = true;
  481. }
  482. return _typeof(obj);
  483. }
  484. module.exports = _typeof;
  485. module.exports["default"] = module.exports, module.exports.__esModule = true;
  486. /***/ }),
  487. /* 3 */
  488. /***/ (function(module, exports) {
  489. // shim for using process in browser
  490. var process = module.exports = {};
  491. // cached from whatever global is present so that test runners that stub it
  492. // don't break things. But we need to wrap it in a try catch in case it is
  493. // wrapped in strict mode code which doesn't define any globals. It's inside a
  494. // function because try/catches deoptimize in certain engines.
  495. var cachedSetTimeout;
  496. var cachedClearTimeout;
  497. function defaultSetTimout() {
  498. throw new Error('setTimeout has not been defined');
  499. }
  500. function defaultClearTimeout () {
  501. throw new Error('clearTimeout has not been defined');
  502. }
  503. (function () {
  504. try {
  505. if (typeof setTimeout === 'function') {
  506. cachedSetTimeout = setTimeout;
  507. } else {
  508. cachedSetTimeout = defaultSetTimout;
  509. }
  510. } catch (e) {
  511. cachedSetTimeout = defaultSetTimout;
  512. }
  513. try {
  514. if (typeof clearTimeout === 'function') {
  515. cachedClearTimeout = clearTimeout;
  516. } else {
  517. cachedClearTimeout = defaultClearTimeout;
  518. }
  519. } catch (e) {
  520. cachedClearTimeout = defaultClearTimeout;
  521. }
  522. } ())
  523. function runTimeout(fun) {
  524. if (cachedSetTimeout === setTimeout) {
  525. //normal enviroments in sane situations
  526. return setTimeout(fun, 0);
  527. }
  528. // if setTimeout wasn't available but was latter defined
  529. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  530. cachedSetTimeout = setTimeout;
  531. return setTimeout(fun, 0);
  532. }
  533. try {
  534. // when when somebody has screwed with setTimeout but no I.E. maddness
  535. return cachedSetTimeout(fun, 0);
  536. } catch(e){
  537. try {
  538. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  539. return cachedSetTimeout.call(null, fun, 0);
  540. } catch(e){
  541. // 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
  542. return cachedSetTimeout.call(this, fun, 0);
  543. }
  544. }
  545. }
  546. function runClearTimeout(marker) {
  547. if (cachedClearTimeout === clearTimeout) {
  548. //normal enviroments in sane situations
  549. return clearTimeout(marker);
  550. }
  551. // if clearTimeout wasn't available but was latter defined
  552. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  553. cachedClearTimeout = clearTimeout;
  554. return clearTimeout(marker);
  555. }
  556. try {
  557. // when when somebody has screwed with setTimeout but no I.E. maddness
  558. return cachedClearTimeout(marker);
  559. } catch (e){
  560. try {
  561. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  562. return cachedClearTimeout.call(null, marker);
  563. } catch (e){
  564. // 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.
  565. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  566. return cachedClearTimeout.call(this, marker);
  567. }
  568. }
  569. }
  570. var queue = [];
  571. var draining = false;
  572. var currentQueue;
  573. var queueIndex = -1;
  574. function cleanUpNextTick() {
  575. if (!draining || !currentQueue) {
  576. return;
  577. }
  578. draining = false;
  579. if (currentQueue.length) {
  580. queue = currentQueue.concat(queue);
  581. } else {
  582. queueIndex = -1;
  583. }
  584. if (queue.length) {
  585. drainQueue();
  586. }
  587. }
  588. function drainQueue() {
  589. if (draining) {
  590. return;
  591. }
  592. var timeout = runTimeout(cleanUpNextTick);
  593. draining = true;
  594. var len = queue.length;
  595. while(len) {
  596. currentQueue = queue;
  597. queue = [];
  598. while (++queueIndex < len) {
  599. if (currentQueue) {
  600. currentQueue[queueIndex].run();
  601. }
  602. }
  603. queueIndex = -1;
  604. len = queue.length;
  605. }
  606. currentQueue = null;
  607. draining = false;
  608. runClearTimeout(timeout);
  609. }
  610. process.nextTick = function (fun) {
  611. var args = new Array(arguments.length - 1);
  612. if (arguments.length > 1) {
  613. for (var i = 1; i < arguments.length; i++) {
  614. args[i - 1] = arguments[i];
  615. }
  616. }
  617. queue.push(new Item(fun, args));
  618. if (queue.length === 1 && !draining) {
  619. runTimeout(drainQueue);
  620. }
  621. };
  622. // v8 likes predictible objects
  623. function Item(fun, array) {
  624. this.fun = fun;
  625. this.array = array;
  626. }
  627. Item.prototype.run = function () {
  628. this.fun.apply(null, this.array);
  629. };
  630. process.title = 'browser';
  631. process.browser = true;
  632. process.env = {};
  633. process.argv = [];
  634. process.version = ''; // empty string to avoid regexp issues
  635. process.versions = {};
  636. function noop() {}
  637. process.on = noop;
  638. process.addListener = noop;
  639. process.once = noop;
  640. process.off = noop;
  641. process.removeListener = noop;
  642. process.removeAllListeners = noop;
  643. process.emit = noop;
  644. process.prependListener = noop;
  645. process.prependOnceListener = noop;
  646. process.listeners = function (name) { return [] }
  647. process.binding = function (name) {
  648. throw new Error('process.binding is not supported');
  649. };
  650. process.cwd = function () { return '/' };
  651. process.chdir = function (dir) {
  652. throw new Error('process.chdir is not supported');
  653. };
  654. process.umask = function() { return 0; };
  655. /***/ }),
  656. /* 4 */
  657. /***/ (function(module, exports) {
  658. function copy(src,dest){
  659. for(var p in src){
  660. dest[p] = src[p];
  661. }
  662. }
  663. /**
  664. ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
  665. ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
  666. */
  667. function _extends(Class,Super){
  668. var pt = Class.prototype;
  669. if(!(pt instanceof Super)){
  670. function t(){};
  671. t.prototype = Super.prototype;
  672. t = new t();
  673. copy(pt,t);
  674. Class.prototype = pt = t;
  675. }
  676. if(pt.constructor != Class){
  677. if(typeof Class != 'function'){
  678. console.error("unknow Class:"+Class)
  679. }
  680. pt.constructor = Class
  681. }
  682. }
  683. var htmlns = 'http://www.w3.org/1999/xhtml' ;
  684. // Node Types
  685. var NodeType = {}
  686. var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
  687. var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
  688. var TEXT_NODE = NodeType.TEXT_NODE = 3;
  689. var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
  690. var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
  691. var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
  692. var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
  693. var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
  694. var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
  695. var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
  696. var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
  697. var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
  698. // ExceptionCode
  699. var ExceptionCode = {}
  700. var ExceptionMessage = {};
  701. var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
  702. var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
  703. var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
  704. var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
  705. var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
  706. var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
  707. var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
  708. var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
  709. var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
  710. var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
  711. //level2
  712. var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
  713. var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
  714. var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
  715. var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
  716. var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
  717. /**
  718. * DOM Level 2
  719. * Object DOMException
  720. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
  721. * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
  722. */
  723. function DOMException(code, message) {
  724. if(message instanceof Error){
  725. var error = message;
  726. }else{
  727. error = this;
  728. Error.call(this, ExceptionMessage[code]);
  729. this.message = ExceptionMessage[code];
  730. if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
  731. }
  732. error.code = code;
  733. if(message) this.message = this.message + ": " + message;
  734. return error;
  735. };
  736. DOMException.prototype = Error.prototype;
  737. copy(ExceptionCode,DOMException)
  738. /**
  739. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
  740. * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
  741. * The items in the NodeList are accessible via an integral index, starting from 0.
  742. */
  743. function NodeList() {
  744. };
  745. NodeList.prototype = {
  746. /**
  747. * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
  748. * @standard level1
  749. */
  750. length:0,
  751. /**
  752. * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
  753. * @standard level1
  754. * @param index unsigned long
  755. * Index into the collection.
  756. * @return Node
  757. * The node at the indexth position in the NodeList, or null if that is not a valid index.
  758. */
  759. item: function(index) {
  760. return this[index] || null;
  761. },
  762. toString:function(isHTML,nodeFilter){
  763. for(var buf = [], i = 0;i<this.length;i++){
  764. serializeToString(this[i],buf,isHTML,nodeFilter);
  765. }
  766. return buf.join('');
  767. }
  768. };
  769. function LiveNodeList(node,refresh){
  770. this._node = node;
  771. this._refresh = refresh
  772. _updateLiveList(this);
  773. }
  774. function _updateLiveList(list){
  775. var inc = list._node._inc || list._node.ownerDocument._inc;
  776. if(list._inc != inc){
  777. var ls = list._refresh(list._node);
  778. //console.log(ls.length)
  779. __set__(list,'length',ls.length);
  780. copy(ls,list);
  781. list._inc = inc;
  782. }
  783. }
  784. LiveNodeList.prototype.item = function(i){
  785. _updateLiveList(this);
  786. return this[i];
  787. }
  788. _extends(LiveNodeList,NodeList);
  789. /**
  790. *
  791. * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
  792. * NamedNodeMap objects in the DOM are live.
  793. * used for attributes or DocumentType entities
  794. */
  795. function NamedNodeMap() {
  796. };
  797. function _findNodeIndex(list,node){
  798. var i = list.length;
  799. while(i--){
  800. if(list[i] === node){return i}
  801. }
  802. }
  803. function _addNamedNode(el,list,newAttr,oldAttr){
  804. if(oldAttr){
  805. list[_findNodeIndex(list,oldAttr)] = newAttr;
  806. }else{
  807. list[list.length++] = newAttr;
  808. }
  809. if(el){
  810. newAttr.ownerElement = el;
  811. var doc = el.ownerDocument;
  812. if(doc){
  813. oldAttr && _onRemoveAttribute(doc,el,oldAttr);
  814. _onAddAttribute(doc,el,newAttr);
  815. }
  816. }
  817. }
  818. function _removeNamedNode(el,list,attr){
  819. //console.log('remove attr:'+attr)
  820. var i = _findNodeIndex(list,attr);
  821. if(i>=0){
  822. var lastIndex = list.length-1
  823. while(i<lastIndex){
  824. list[i] = list[++i]
  825. }
  826. list.length = lastIndex;
  827. if(el){
  828. var doc = el.ownerDocument;
  829. if(doc){
  830. _onRemoveAttribute(doc,el,attr);
  831. attr.ownerElement = null;
  832. }
  833. }
  834. }else{
  835. throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
  836. }
  837. }
  838. NamedNodeMap.prototype = {
  839. length:0,
  840. item:NodeList.prototype.item,
  841. getNamedItem: function(key) {
  842. // if(key.indexOf(':')>0 || key == 'xmlns'){
  843. // return null;
  844. // }
  845. //console.log()
  846. var i = this.length;
  847. while(i--){
  848. var attr = this[i];
  849. //console.log(attr.nodeName,key)
  850. if(attr.nodeName == key){
  851. return attr;
  852. }
  853. }
  854. },
  855. setNamedItem: function(attr) {
  856. var el = attr.ownerElement;
  857. if(el && el!=this._ownerElement){
  858. throw new DOMException(INUSE_ATTRIBUTE_ERR);
  859. }
  860. var oldAttr = this.getNamedItem(attr.nodeName);
  861. _addNamedNode(this._ownerElement,this,attr,oldAttr);
  862. return oldAttr;
  863. },
  864. /* returns Node */
  865. setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
  866. var el = attr.ownerElement, oldAttr;
  867. if(el && el!=this._ownerElement){
  868. throw new DOMException(INUSE_ATTRIBUTE_ERR);
  869. }
  870. oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
  871. _addNamedNode(this._ownerElement,this,attr,oldAttr);
  872. return oldAttr;
  873. },
  874. /* returns Node */
  875. removeNamedItem: function(key) {
  876. var attr = this.getNamedItem(key);
  877. _removeNamedNode(this._ownerElement,this,attr);
  878. return attr;
  879. },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
  880. //for level2
  881. removeNamedItemNS:function(namespaceURI,localName){
  882. var attr = this.getNamedItemNS(namespaceURI,localName);
  883. _removeNamedNode(this._ownerElement,this,attr);
  884. return attr;
  885. },
  886. getNamedItemNS: function(namespaceURI, localName) {
  887. var i = this.length;
  888. while(i--){
  889. var node = this[i];
  890. if(node.localName == localName && node.namespaceURI == namespaceURI){
  891. return node;
  892. }
  893. }
  894. return null;
  895. }
  896. };
  897. /**
  898. * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490
  899. */
  900. function DOMImplementation(/* Object */ features) {
  901. this._features = {};
  902. if (features) {
  903. for (var feature in features) {
  904. this._features = features[feature];
  905. }
  906. }
  907. };
  908. DOMImplementation.prototype = {
  909. hasFeature: function(/* string */ feature, /* string */ version) {
  910. var versions = this._features[feature.toLowerCase()];
  911. if (versions && (!version || version in versions)) {
  912. return true;
  913. } else {
  914. return false;
  915. }
  916. },
  917. // Introduced in DOM Level 2:
  918. createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
  919. var doc = new Document();
  920. doc.implementation = this;
  921. doc.childNodes = new NodeList();
  922. doc.doctype = doctype;
  923. if(doctype){
  924. doc.appendChild(doctype);
  925. }
  926. if(qualifiedName){
  927. var root = doc.createElementNS(namespaceURI,qualifiedName);
  928. doc.appendChild(root);
  929. }
  930. return doc;
  931. },
  932. // Introduced in DOM Level 2:
  933. createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
  934. var node = new DocumentType();
  935. node.name = qualifiedName;
  936. node.nodeName = qualifiedName;
  937. node.publicId = publicId;
  938. node.systemId = systemId;
  939. // Introduced in DOM Level 2:
  940. //readonly attribute DOMString internalSubset;
  941. //TODO:..
  942. // readonly attribute NamedNodeMap entities;
  943. // readonly attribute NamedNodeMap notations;
  944. return node;
  945. }
  946. };
  947. /**
  948. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
  949. */
  950. function Node() {
  951. };
  952. Node.prototype = {
  953. firstChild : null,
  954. lastChild : null,
  955. previousSibling : null,
  956. nextSibling : null,
  957. attributes : null,
  958. parentNode : null,
  959. childNodes : null,
  960. ownerDocument : null,
  961. nodeValue : null,
  962. namespaceURI : null,
  963. prefix : null,
  964. localName : null,
  965. // Modified in DOM Level 2:
  966. insertBefore:function(newChild, refChild){//raises
  967. return _insertBefore(this,newChild,refChild);
  968. },
  969. replaceChild:function(newChild, oldChild){//raises
  970. this.insertBefore(newChild,oldChild);
  971. if(oldChild){
  972. this.removeChild(oldChild);
  973. }
  974. },
  975. removeChild:function(oldChild){
  976. return _removeChild(this,oldChild);
  977. },
  978. appendChild:function(newChild){
  979. return this.insertBefore(newChild,null);
  980. },
  981. hasChildNodes:function(){
  982. return this.firstChild != null;
  983. },
  984. cloneNode:function(deep){
  985. return cloneNode(this.ownerDocument||this,this,deep);
  986. },
  987. // Modified in DOM Level 2:
  988. normalize:function(){
  989. var child = this.firstChild;
  990. while(child){
  991. var next = child.nextSibling;
  992. if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
  993. this.removeChild(next);
  994. child.appendData(next.data);
  995. }else{
  996. child.normalize();
  997. child = next;
  998. }
  999. }
  1000. },
  1001. // Introduced in DOM Level 2:
  1002. isSupported:function(feature, version){
  1003. return this.ownerDocument.implementation.hasFeature(feature,version);
  1004. },
  1005. // Introduced in DOM Level 2:
  1006. hasAttributes:function(){
  1007. return this.attributes.length>0;
  1008. },
  1009. lookupPrefix:function(namespaceURI){
  1010. var el = this;
  1011. while(el){
  1012. var map = el._nsMap;
  1013. //console.dir(map)
  1014. if(map){
  1015. for(var n in map){
  1016. if(map[n] == namespaceURI){
  1017. return n;
  1018. }
  1019. }
  1020. }
  1021. el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
  1022. }
  1023. return null;
  1024. },
  1025. // Introduced in DOM Level 3:
  1026. lookupNamespaceURI:function(prefix){
  1027. var el = this;
  1028. while(el){
  1029. var map = el._nsMap;
  1030. //console.dir(map)
  1031. if(map){
  1032. if(prefix in map){
  1033. return map[prefix] ;
  1034. }
  1035. }
  1036. el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
  1037. }
  1038. return null;
  1039. },
  1040. // Introduced in DOM Level 3:
  1041. isDefaultNamespace:function(namespaceURI){
  1042. var prefix = this.lookupPrefix(namespaceURI);
  1043. return prefix == null;
  1044. }
  1045. };
  1046. function _xmlEncoder(c){
  1047. return c == '<' && '&lt;' ||
  1048. c == '>' && '&gt;' ||
  1049. c == '&' && '&amp;' ||
  1050. c == '"' && '&quot;' ||
  1051. '&#'+c.charCodeAt()+';'
  1052. }
  1053. copy(NodeType,Node);
  1054. copy(NodeType,Node.prototype);
  1055. /**
  1056. * @param callback return true for continue,false for break
  1057. * @return boolean true: break visit;
  1058. */
  1059. function _visitNode(node,callback){
  1060. if(callback(node)){
  1061. return true;
  1062. }
  1063. if(node = node.firstChild){
  1064. do{
  1065. if(_visitNode(node,callback)){return true}
  1066. }while(node=node.nextSibling)
  1067. }
  1068. }
  1069. function Document(){
  1070. }
  1071. function _onAddAttribute(doc,el,newAttr){
  1072. doc && doc._inc++;
  1073. var ns = newAttr.namespaceURI ;
  1074. if(ns == 'http://www.w3.org/2000/xmlns/'){
  1075. //update namespace
  1076. el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
  1077. }
  1078. }
  1079. function _onRemoveAttribute(doc,el,newAttr,remove){
  1080. doc && doc._inc++;
  1081. var ns = newAttr.namespaceURI ;
  1082. if(ns == 'http://www.w3.org/2000/xmlns/'){
  1083. //update namespace
  1084. delete el._nsMap[newAttr.prefix?newAttr.localName:'']
  1085. }
  1086. }
  1087. function _onUpdateChild(doc,el,newChild){
  1088. if(doc && doc._inc){
  1089. doc._inc++;
  1090. //update childNodes
  1091. var cs = el.childNodes;
  1092. if(newChild){
  1093. cs[cs.length++] = newChild;
  1094. }else{
  1095. //console.log(1)
  1096. var child = el.firstChild;
  1097. var i = 0;
  1098. while(child){
  1099. cs[i++] = child;
  1100. child =child.nextSibling;
  1101. }
  1102. cs.length = i;
  1103. }
  1104. }
  1105. }
  1106. /**
  1107. * attributes;
  1108. * children;
  1109. *
  1110. * writeable properties:
  1111. * nodeValue,Attr:value,CharacterData:data
  1112. * prefix
  1113. */
  1114. function _removeChild(parentNode,child){
  1115. var previous = child.previousSibling;
  1116. var next = child.nextSibling;
  1117. if(previous){
  1118. previous.nextSibling = next;
  1119. }else{
  1120. parentNode.firstChild = next
  1121. }
  1122. if(next){
  1123. next.previousSibling = previous;
  1124. }else{
  1125. parentNode.lastChild = previous;
  1126. }
  1127. _onUpdateChild(parentNode.ownerDocument,parentNode);
  1128. return child;
  1129. }
  1130. /**
  1131. * preformance key(refChild == null)
  1132. */
  1133. function _insertBefore(parentNode,newChild,nextChild){
  1134. var cp = newChild.parentNode;
  1135. if(cp){
  1136. cp.removeChild(newChild);//remove and update
  1137. }
  1138. if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
  1139. var newFirst = newChild.firstChild;
  1140. if (newFirst == null) {
  1141. return newChild;
  1142. }
  1143. var newLast = newChild.lastChild;
  1144. }else{
  1145. newFirst = newLast = newChild;
  1146. }
  1147. var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
  1148. newFirst.previousSibling = pre;
  1149. newLast.nextSibling = nextChild;
  1150. if(pre){
  1151. pre.nextSibling = newFirst;
  1152. }else{
  1153. parentNode.firstChild = newFirst;
  1154. }
  1155. if(nextChild == null){
  1156. parentNode.lastChild = newLast;
  1157. }else{
  1158. nextChild.previousSibling = newLast;
  1159. }
  1160. do{
  1161. newFirst.parentNode = parentNode;
  1162. }while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
  1163. _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
  1164. //console.log(parentNode.lastChild.nextSibling == null)
  1165. if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
  1166. newChild.firstChild = newChild.lastChild = null;
  1167. }
  1168. return newChild;
  1169. }
  1170. function _appendSingleChild(parentNode,newChild){
  1171. var cp = newChild.parentNode;
  1172. if(cp){
  1173. var pre = parentNode.lastChild;
  1174. cp.removeChild(newChild);//remove and update
  1175. var pre = parentNode.lastChild;
  1176. }
  1177. var pre = parentNode.lastChild;
  1178. newChild.parentNode = parentNode;
  1179. newChild.previousSibling = pre;
  1180. newChild.nextSibling = null;
  1181. if(pre){
  1182. pre.nextSibling = newChild;
  1183. }else{
  1184. parentNode.firstChild = newChild;
  1185. }
  1186. parentNode.lastChild = newChild;
  1187. _onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
  1188. return newChild;
  1189. //console.log("__aa",parentNode.lastChild.nextSibling == null)
  1190. }
  1191. Document.prototype = {
  1192. //implementation : null,
  1193. nodeName : '#document',
  1194. nodeType : DOCUMENT_NODE,
  1195. doctype : null,
  1196. documentElement : null,
  1197. _inc : 1,
  1198. insertBefore : function(newChild, refChild){//raises
  1199. if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
  1200. var child = newChild.firstChild;
  1201. while(child){
  1202. var next = child.nextSibling;
  1203. this.insertBefore(child,refChild);
  1204. child = next;
  1205. }
  1206. return newChild;
  1207. }
  1208. if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
  1209. this.documentElement = newChild;
  1210. }
  1211. return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
  1212. },
  1213. removeChild : function(oldChild){
  1214. if(this.documentElement == oldChild){
  1215. this.documentElement = null;
  1216. }
  1217. return _removeChild(this,oldChild);
  1218. },
  1219. // Introduced in DOM Level 2:
  1220. importNode : function(importedNode,deep){
  1221. return importNode(this,importedNode,deep);
  1222. },
  1223. // Introduced in DOM Level 2:
  1224. getElementById : function(id){
  1225. var rtv = null;
  1226. _visitNode(this.documentElement,function(node){
  1227. if(node.nodeType == ELEMENT_NODE){
  1228. if(node.getAttribute('id') == id){
  1229. rtv = node;
  1230. return true;
  1231. }
  1232. }
  1233. })
  1234. return rtv;
  1235. },
  1236. getElementsByClassName: function(className) {
  1237. var pattern = new RegExp("(^|\\s)" + className + "(\\s|$)");
  1238. return new LiveNodeList(this, function(base) {
  1239. var ls = [];
  1240. _visitNode(base.documentElement, function(node) {
  1241. if(node !== base && node.nodeType == ELEMENT_NODE) {
  1242. if(pattern.test(node.getAttribute('class'))) {
  1243. ls.push(node);
  1244. }
  1245. }
  1246. });
  1247. return ls;
  1248. });
  1249. },
  1250. //document factory method:
  1251. createElement : function(tagName){
  1252. var node = new Element();
  1253. node.ownerDocument = this;
  1254. node.nodeName = tagName;
  1255. node.tagName = tagName;
  1256. node.childNodes = new NodeList();
  1257. var attrs = node.attributes = new NamedNodeMap();
  1258. attrs._ownerElement = node;
  1259. return node;
  1260. },
  1261. createDocumentFragment : function(){
  1262. var node = new DocumentFragment();
  1263. node.ownerDocument = this;
  1264. node.childNodes = new NodeList();
  1265. return node;
  1266. },
  1267. createTextNode : function(data){
  1268. var node = new Text();
  1269. node.ownerDocument = this;
  1270. node.appendData(data)
  1271. return node;
  1272. },
  1273. createComment : function(data){
  1274. var node = new Comment();
  1275. node.ownerDocument = this;
  1276. node.appendData(data)
  1277. return node;
  1278. },
  1279. createCDATASection : function(data){
  1280. var node = new CDATASection();
  1281. node.ownerDocument = this;
  1282. node.appendData(data)
  1283. return node;
  1284. },
  1285. createProcessingInstruction : function(target,data){
  1286. var node = new ProcessingInstruction();
  1287. node.ownerDocument = this;
  1288. node.tagName = node.target = target;
  1289. node.nodeValue= node.data = data;
  1290. return node;
  1291. },
  1292. createAttribute : function(name){
  1293. var node = new Attr();
  1294. node.ownerDocument = this;
  1295. node.name = name;
  1296. node.nodeName = name;
  1297. node.localName = name;
  1298. node.specified = true;
  1299. return node;
  1300. },
  1301. createEntityReference : function(name){
  1302. var node = new EntityReference();
  1303. node.ownerDocument = this;
  1304. node.nodeName = name;
  1305. return node;
  1306. },
  1307. // Introduced in DOM Level 2:
  1308. createElementNS : function(namespaceURI,qualifiedName){
  1309. var node = new Element();
  1310. var pl = qualifiedName.split(':');
  1311. var attrs = node.attributes = new NamedNodeMap();
  1312. node.childNodes = new NodeList();
  1313. node.ownerDocument = this;
  1314. node.nodeName = qualifiedName;
  1315. node.tagName = qualifiedName;
  1316. node.namespaceURI = namespaceURI;
  1317. if(pl.length == 2){
  1318. node.prefix = pl[0];
  1319. node.localName = pl[1];
  1320. }else{
  1321. //el.prefix = null;
  1322. node.localName = qualifiedName;
  1323. }
  1324. attrs._ownerElement = node;
  1325. return node;
  1326. },
  1327. // Introduced in DOM Level 2:
  1328. createAttributeNS : function(namespaceURI,qualifiedName){
  1329. var node = new Attr();
  1330. var pl = qualifiedName.split(':');
  1331. node.ownerDocument = this;
  1332. node.nodeName = qualifiedName;
  1333. node.name = qualifiedName;
  1334. node.namespaceURI = namespaceURI;
  1335. node.specified = true;
  1336. if(pl.length == 2){
  1337. node.prefix = pl[0];
  1338. node.localName = pl[1];
  1339. }else{
  1340. //el.prefix = null;
  1341. node.localName = qualifiedName;
  1342. }
  1343. return node;
  1344. }
  1345. };
  1346. _extends(Document,Node);
  1347. function Element() {
  1348. this._nsMap = {};
  1349. };
  1350. Element.prototype = {
  1351. nodeType : ELEMENT_NODE,
  1352. hasAttribute : function(name){
  1353. return this.getAttributeNode(name)!=null;
  1354. },
  1355. getAttribute : function(name){
  1356. var attr = this.getAttributeNode(name);
  1357. return attr && attr.value || '';
  1358. },
  1359. getAttributeNode : function(name){
  1360. return this.attributes.getNamedItem(name);
  1361. },
  1362. setAttribute : function(name, value){
  1363. var attr = this.ownerDocument.createAttribute(name);
  1364. attr.value = attr.nodeValue = "" + value;
  1365. this.setAttributeNode(attr)
  1366. },
  1367. removeAttribute : function(name){
  1368. var attr = this.getAttributeNode(name)
  1369. attr && this.removeAttributeNode(attr);
  1370. },
  1371. //four real opeartion method
  1372. appendChild:function(newChild){
  1373. if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
  1374. return this.insertBefore(newChild,null);
  1375. }else{
  1376. return _appendSingleChild(this,newChild);
  1377. }
  1378. },
  1379. setAttributeNode : function(newAttr){
  1380. return this.attributes.setNamedItem(newAttr);
  1381. },
  1382. setAttributeNodeNS : function(newAttr){
  1383. return this.attributes.setNamedItemNS(newAttr);
  1384. },
  1385. removeAttributeNode : function(oldAttr){
  1386. //console.log(this == oldAttr.ownerElement)
  1387. return this.attributes.removeNamedItem(oldAttr.nodeName);
  1388. },
  1389. //get real attribute name,and remove it by removeAttributeNode
  1390. removeAttributeNS : function(namespaceURI, localName){
  1391. var old = this.getAttributeNodeNS(namespaceURI, localName);
  1392. old && this.removeAttributeNode(old);
  1393. },
  1394. hasAttributeNS : function(namespaceURI, localName){
  1395. return this.getAttributeNodeNS(namespaceURI, localName)!=null;
  1396. },
  1397. getAttributeNS : function(namespaceURI, localName){
  1398. var attr = this.getAttributeNodeNS(namespaceURI, localName);
  1399. return attr && attr.value || '';
  1400. },
  1401. setAttributeNS : function(namespaceURI, qualifiedName, value){
  1402. var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
  1403. attr.value = attr.nodeValue = "" + value;
  1404. this.setAttributeNode(attr)
  1405. },
  1406. getAttributeNodeNS : function(namespaceURI, localName){
  1407. return this.attributes.getNamedItemNS(namespaceURI, localName);
  1408. },
  1409. getElementsByTagName : function(tagName){
  1410. return new LiveNodeList(this,function(base){
  1411. var ls = [];
  1412. _visitNode(base,function(node){
  1413. if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
  1414. ls.push(node);
  1415. }
  1416. });
  1417. return ls;
  1418. });
  1419. },
  1420. getElementsByTagNameNS : function(namespaceURI, localName){
  1421. return new LiveNodeList(this,function(base){
  1422. var ls = [];
  1423. _visitNode(base,function(node){
  1424. if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
  1425. ls.push(node);
  1426. }
  1427. });
  1428. return ls;
  1429. });
  1430. }
  1431. };
  1432. Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
  1433. Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
  1434. _extends(Element,Node);
  1435. function Attr() {
  1436. };
  1437. Attr.prototype.nodeType = ATTRIBUTE_NODE;
  1438. _extends(Attr,Node);
  1439. function CharacterData() {
  1440. };
  1441. CharacterData.prototype = {
  1442. data : '',
  1443. substringData : function(offset, count) {
  1444. return this.data.substring(offset, offset+count);
  1445. },
  1446. appendData: function(text) {
  1447. text = this.data+text;
  1448. this.nodeValue = this.data = text;
  1449. this.length = text.length;
  1450. },
  1451. insertData: function(offset,text) {
  1452. this.replaceData(offset,0,text);
  1453. },
  1454. appendChild:function(newChild){
  1455. throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
  1456. },
  1457. deleteData: function(offset, count) {
  1458. this.replaceData(offset,count,"");
  1459. },
  1460. replaceData: function(offset, count, text) {
  1461. var start = this.data.substring(0,offset);
  1462. var end = this.data.substring(offset+count);
  1463. text = start + text + end;
  1464. this.nodeValue = this.data = text;
  1465. this.length = text.length;
  1466. }
  1467. }
  1468. _extends(CharacterData,Node);
  1469. function Text() {
  1470. };
  1471. Text.prototype = {
  1472. nodeName : "#text",
  1473. nodeType : TEXT_NODE,
  1474. splitText : function(offset) {
  1475. var text = this.data;
  1476. var newText = text.substring(offset);
  1477. text = text.substring(0, offset);
  1478. this.data = this.nodeValue = text;
  1479. this.length = text.length;
  1480. var newNode = this.ownerDocument.createTextNode(newText);
  1481. if(this.parentNode){
  1482. this.parentNode.insertBefore(newNode, this.nextSibling);
  1483. }
  1484. return newNode;
  1485. }
  1486. }
  1487. _extends(Text,CharacterData);
  1488. function Comment() {
  1489. };
  1490. Comment.prototype = {
  1491. nodeName : "#comment",
  1492. nodeType : COMMENT_NODE
  1493. }
  1494. _extends(Comment,CharacterData);
  1495. function CDATASection() {
  1496. };
  1497. CDATASection.prototype = {
  1498. nodeName : "#cdata-section",
  1499. nodeType : CDATA_SECTION_NODE
  1500. }
  1501. _extends(CDATASection,CharacterData);
  1502. function DocumentType() {
  1503. };
  1504. DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
  1505. _extends(DocumentType,Node);
  1506. function Notation() {
  1507. };
  1508. Notation.prototype.nodeType = NOTATION_NODE;
  1509. _extends(Notation,Node);
  1510. function Entity() {
  1511. };
  1512. Entity.prototype.nodeType = ENTITY_NODE;
  1513. _extends(Entity,Node);
  1514. function EntityReference() {
  1515. };
  1516. EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
  1517. _extends(EntityReference,Node);
  1518. function DocumentFragment() {
  1519. };
  1520. DocumentFragment.prototype.nodeName = "#document-fragment";
  1521. DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
  1522. _extends(DocumentFragment,Node);
  1523. function ProcessingInstruction() {
  1524. }
  1525. ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
  1526. _extends(ProcessingInstruction,Node);
  1527. function XMLSerializer(){}
  1528. XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
  1529. return nodeSerializeToString.call(node,isHtml,nodeFilter);
  1530. }
  1531. Node.prototype.toString = nodeSerializeToString;
  1532. function nodeSerializeToString(isHtml,nodeFilter){
  1533. var buf = [];
  1534. var refNode = this.nodeType == 9 && this.documentElement || this;
  1535. var prefix = refNode.prefix;
  1536. var uri = refNode.namespaceURI;
  1537. if(uri && prefix == null){
  1538. //console.log(prefix)
  1539. var prefix = refNode.lookupPrefix(uri);
  1540. if(prefix == null){
  1541. //isHTML = true;
  1542. var visibleNamespaces=[
  1543. {namespace:uri,prefix:null}
  1544. //{namespace:uri,prefix:''}
  1545. ]
  1546. }
  1547. }
  1548. serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
  1549. //console.log('###',this.nodeType,uri,prefix,buf.join(''))
  1550. return buf.join('');
  1551. }
  1552. function needNamespaceDefine(node,isHTML, visibleNamespaces) {
  1553. var prefix = node.prefix||'';
  1554. var uri = node.namespaceURI;
  1555. if (!prefix && !uri){
  1556. return false;
  1557. }
  1558. if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace"
  1559. || uri == 'http://www.w3.org/2000/xmlns/'){
  1560. return false;
  1561. }
  1562. var i = visibleNamespaces.length
  1563. //console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
  1564. while (i--) {
  1565. var ns = visibleNamespaces[i];
  1566. // get namespace prefix
  1567. //console.log(node.nodeType,node.tagName,ns.prefix,prefix)
  1568. if (ns.prefix == prefix){
  1569. return ns.namespace != uri;
  1570. }
  1571. }
  1572. //console.log(isHTML,uri,prefix=='')
  1573. //if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
  1574. // return false;
  1575. //}
  1576. //node.flag = '11111'
  1577. //console.error(3,true,node.flag,node.prefix,node.namespaceURI)
  1578. return true;
  1579. }
  1580. function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
  1581. if(nodeFilter){
  1582. node = nodeFilter(node);
  1583. if(node){
  1584. if(typeof node == 'string'){
  1585. buf.push(node);
  1586. return;
  1587. }
  1588. }else{
  1589. return;
  1590. }
  1591. //buf.sort.apply(attrs, attributeSorter);
  1592. }
  1593. switch(node.nodeType){
  1594. case ELEMENT_NODE:
  1595. if (!visibleNamespaces) visibleNamespaces = [];
  1596. var startVisibleNamespaces = visibleNamespaces.length;
  1597. var attrs = node.attributes;
  1598. var len = attrs.length;
  1599. var child = node.firstChild;
  1600. var nodeName = node.tagName;
  1601. isHTML = (htmlns === node.namespaceURI) ||isHTML
  1602. buf.push('<',nodeName);
  1603. for(var i=0;i<len;i++){
  1604. // add namespaces for attributes
  1605. var attr = attrs.item(i);
  1606. if (attr.prefix == 'xmlns') {
  1607. visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
  1608. }else if(attr.nodeName == 'xmlns'){
  1609. visibleNamespaces.push({ prefix: '', namespace: attr.value });
  1610. }
  1611. }
  1612. for(var i=0;i<len;i++){
  1613. var attr = attrs.item(i);
  1614. if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
  1615. var prefix = attr.prefix||'';
  1616. var uri = attr.namespaceURI;
  1617. var ns = prefix ? ' xmlns:' + prefix : " xmlns";
  1618. buf.push(ns, '="' , uri , '"');
  1619. visibleNamespaces.push({ prefix: prefix, namespace:uri });
  1620. }
  1621. serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
  1622. }
  1623. // add namespace for current node
  1624. if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
  1625. var prefix = node.prefix||'';
  1626. var uri = node.namespaceURI;
  1627. if (uri) {
  1628. // Avoid empty namespace value like xmlns:ds=""
  1629. // Empty namespace URL will we produce an invalid XML document
  1630. var ns = prefix ? ' xmlns:' + prefix : " xmlns";
  1631. buf.push(ns, '="' , uri , '"');
  1632. visibleNamespaces.push({ prefix: prefix, namespace:uri });
  1633. }
  1634. }
  1635. if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
  1636. buf.push('>');
  1637. //if is cdata child node
  1638. if(isHTML && /^script$/i.test(nodeName)){
  1639. while(child){
  1640. if(child.data){
  1641. buf.push(child.data);
  1642. }else{
  1643. serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
  1644. }
  1645. child = child.nextSibling;
  1646. }
  1647. }else
  1648. {
  1649. while(child){
  1650. serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
  1651. child = child.nextSibling;
  1652. }
  1653. }
  1654. buf.push('</',nodeName,'>');
  1655. }else{
  1656. buf.push('/>');
  1657. }
  1658. // remove added visible namespaces
  1659. //visibleNamespaces.length = startVisibleNamespaces;
  1660. return;
  1661. case DOCUMENT_NODE:
  1662. case DOCUMENT_FRAGMENT_NODE:
  1663. var child = node.firstChild;
  1664. while(child){
  1665. serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
  1666. child = child.nextSibling;
  1667. }
  1668. return;
  1669. case ATTRIBUTE_NODE:
  1670. /**
  1671. * Well-formedness constraint: No < in Attribute Values
  1672. * The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.
  1673. * @see https://www.w3.org/TR/xml/#CleanAttrVals
  1674. * @see https://www.w3.org/TR/xml/#NT-AttValue
  1675. */
  1676. return buf.push(' ', node.name, '="', node.value.replace(/[<&"]/g,_xmlEncoder), '"');
  1677. case TEXT_NODE:
  1678. /**
  1679. * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
  1680. * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
  1681. * If they are needed elsewhere, they must be escaped using either numeric character references or the strings
  1682. * `&amp;` and `&lt;` respectively.
  1683. * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility,
  1684. * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content,
  1685. * when that string is not marking the end of a CDATA section.
  1686. *
  1687. * In the content of elements, character data is any string of characters
  1688. * which does not contain the start-delimiter of any markup
  1689. * and does not include the CDATA-section-close delimiter, `]]>`.
  1690. *
  1691. * @see https://www.w3.org/TR/xml/#NT-CharData
  1692. */
  1693. return buf.push(node.data
  1694. .replace(/[<&]/g,_xmlEncoder)
  1695. .replace(/]]>/g, ']]&gt;')
  1696. );
  1697. case CDATA_SECTION_NODE:
  1698. return buf.push( '<![CDATA[',node.data,']]>');
  1699. case COMMENT_NODE:
  1700. return buf.push( "<!--",node.data,"-->");
  1701. case DOCUMENT_TYPE_NODE:
  1702. var pubid = node.publicId;
  1703. var sysid = node.systemId;
  1704. buf.push('<!DOCTYPE ',node.name);
  1705. if(pubid){
  1706. buf.push(' PUBLIC ', pubid);
  1707. if (sysid && sysid!='.') {
  1708. buf.push(' ', sysid);
  1709. }
  1710. buf.push('>');
  1711. }else if(sysid && sysid!='.'){
  1712. buf.push(' SYSTEM ', sysid, '>');
  1713. }else{
  1714. var sub = node.internalSubset;
  1715. if(sub){
  1716. buf.push(" [",sub,"]");
  1717. }
  1718. buf.push(">");
  1719. }
  1720. return;
  1721. case PROCESSING_INSTRUCTION_NODE:
  1722. return buf.push( "<?",node.target," ",node.data,"?>");
  1723. case ENTITY_REFERENCE_NODE:
  1724. return buf.push( '&',node.nodeName,';');
  1725. //case ENTITY_NODE:
  1726. //case NOTATION_NODE:
  1727. default:
  1728. buf.push('??',node.nodeName);
  1729. }
  1730. }
  1731. function importNode(doc,node,deep){
  1732. var node2;
  1733. switch (node.nodeType) {
  1734. case ELEMENT_NODE:
  1735. node2 = node.cloneNode(false);
  1736. node2.ownerDocument = doc;
  1737. //var attrs = node2.attributes;
  1738. //var len = attrs.length;
  1739. //for(var i=0;i<len;i++){
  1740. //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
  1741. //}
  1742. case DOCUMENT_FRAGMENT_NODE:
  1743. break;
  1744. case ATTRIBUTE_NODE:
  1745. deep = true;
  1746. break;
  1747. //case ENTITY_REFERENCE_NODE:
  1748. //case PROCESSING_INSTRUCTION_NODE:
  1749. ////case TEXT_NODE:
  1750. //case CDATA_SECTION_NODE:
  1751. //case COMMENT_NODE:
  1752. // deep = false;
  1753. // break;
  1754. //case DOCUMENT_NODE:
  1755. //case DOCUMENT_TYPE_NODE:
  1756. //cannot be imported.
  1757. //case ENTITY_NODE:
  1758. //case NOTATION_NODE:
  1759. //can not hit in level3
  1760. //default:throw e;
  1761. }
  1762. if(!node2){
  1763. node2 = node.cloneNode(false);//false
  1764. }
  1765. node2.ownerDocument = doc;
  1766. node2.parentNode = null;
  1767. if(deep){
  1768. var child = node.firstChild;
  1769. while(child){
  1770. node2.appendChild(importNode(doc,child,deep));
  1771. child = child.nextSibling;
  1772. }
  1773. }
  1774. return node2;
  1775. }
  1776. //
  1777. //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
  1778. // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
  1779. function cloneNode(doc,node,deep){
  1780. var node2 = new node.constructor();
  1781. for(var n in node){
  1782. var v = node[n];
  1783. if(typeof v != 'object' ){
  1784. if(v != node2[n]){
  1785. node2[n] = v;
  1786. }
  1787. }
  1788. }
  1789. if(node.childNodes){
  1790. node2.childNodes = new NodeList();
  1791. }
  1792. node2.ownerDocument = doc;
  1793. switch (node2.nodeType) {
  1794. case ELEMENT_NODE:
  1795. var attrs = node.attributes;
  1796. var attrs2 = node2.attributes = new NamedNodeMap();
  1797. var len = attrs.length
  1798. attrs2._ownerElement = node2;
  1799. for(var i=0;i<len;i++){
  1800. node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
  1801. }
  1802. break;;
  1803. case ATTRIBUTE_NODE:
  1804. deep = true;
  1805. }
  1806. if(deep){
  1807. var child = node.firstChild;
  1808. while(child){
  1809. node2.appendChild(cloneNode(doc,child,deep));
  1810. child = child.nextSibling;
  1811. }
  1812. }
  1813. return node2;
  1814. }
  1815. function __set__(object,key,value){
  1816. object[key] = value
  1817. }
  1818. //do dynamic
  1819. try{
  1820. if(Object.defineProperty){
  1821. Object.defineProperty(LiveNodeList.prototype,'length',{
  1822. get:function(){
  1823. _updateLiveList(this);
  1824. return this.$$length;
  1825. }
  1826. });
  1827. Object.defineProperty(Node.prototype,'textContent',{
  1828. get:function(){
  1829. return getTextContent(this);
  1830. },
  1831. set:function(data){
  1832. switch(this.nodeType){
  1833. case ELEMENT_NODE:
  1834. case DOCUMENT_FRAGMENT_NODE:
  1835. while(this.firstChild){
  1836. this.removeChild(this.firstChild);
  1837. }
  1838. if(data || String(data)){
  1839. this.appendChild(this.ownerDocument.createTextNode(data));
  1840. }
  1841. break;
  1842. default:
  1843. //TODO:
  1844. this.data = data;
  1845. this.value = data;
  1846. this.nodeValue = data;
  1847. }
  1848. }
  1849. })
  1850. function getTextContent(node){
  1851. switch(node.nodeType){
  1852. case ELEMENT_NODE:
  1853. case DOCUMENT_FRAGMENT_NODE:
  1854. var buf = [];
  1855. node = node.firstChild;
  1856. while(node){
  1857. if(node.nodeType!==7 && node.nodeType !==8){
  1858. buf.push(getTextContent(node));
  1859. }
  1860. node = node.nextSibling;
  1861. }
  1862. return buf.join('');
  1863. default:
  1864. return node.nodeValue;
  1865. }
  1866. }
  1867. __set__ = function(object,key,value){
  1868. //console.log(value)
  1869. object['$$'+key] = value
  1870. }
  1871. }
  1872. }catch(e){//ie8
  1873. }
  1874. //if(typeof require == 'function'){
  1875. exports.Node = Node;
  1876. exports.DOMException = DOMException;
  1877. exports.DOMImplementation = DOMImplementation;
  1878. exports.XMLSerializer = XMLSerializer;
  1879. //}
  1880. /***/ }),
  1881. /* 5 */
  1882. /***/ (function(module, exports, __webpack_require__) {
  1883. /* WEBPACK VAR INJECTION */(function(global, Buffer, setImmediate) {var require;var require;/*!
  1884. JSZip v3.7.0 - A JavaScript class for generating and reading zip files
  1885. <http://stuartk.com/jszip>
  1886. (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
  1887. Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
  1888. JSZip uses the library pako released under the MIT license :
  1889. https://github.com/nodeca/pako/blob/master/LICENSE
  1890. */
  1891. !function(e){if(true)module.exports=e();else {}}(function(){return function s(o,a,f){function u(r,e){if(!a[r]){if(!o[r]){var t="function"==typeof require&&require;if(!e&&__webpack_require__(12))return require(r,!0);if(d)return d(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[r]={exports:{}};o[r][0].call(i.exports,function(e){var t=o[r][1][e];return u(t||e)},i,i.exports,s,o,a,f)}return a[r].exports}for(var d="function"==typeof require&&require,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(h,t,n){(function(r){!function(e){"object"==typeof n&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:this).JSZip=e()}(function(){return function s(o,a,f){function u(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof h&&h;if(!e&&r)return r(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,s,o,a,f)}return a[t].exports}for(var d="function"==typeof h&&h,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(e,t,r){"use strict";var c=e("./utils"),h=e("./support"),p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(e){for(var t,r,n,i,s,o,a,f=[],u=0,d=e.length,h=d,l="string"!==c.getTypeOf(e);u<e.length;)h=d-u,n=l?(t=e[u++],r=u<d?e[u++]:0,u<d?e[u++]:0):(t=e.charCodeAt(u++),r=u<d?e.charCodeAt(u++):0,u<d?e.charCodeAt(u++):0),i=t>>2,s=(3&t)<<4|r>>4,o=1<h?(15&r)<<2|n>>6:64,a=2<h?63&n:64,f.push(p.charAt(i)+p.charAt(s)+p.charAt(o)+p.charAt(a));return f.join("")},r.decode=function(e){var t,r,n,i,s,o,a=0,f=0;if("data:"===e.substr(0,"data:".length))throw new Error("Invalid base64 input, it looks like a data url.");var u,d=3*(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"")).length/4;if(e.charAt(e.length-1)===p.charAt(64)&&d--,e.charAt(e.length-2)===p.charAt(64)&&d--,d%1!=0)throw new Error("Invalid base64 input, bad content length.");for(u=h.uint8array?new Uint8Array(0|d):new Array(0|d);a<e.length;)t=p.indexOf(e.charAt(a++))<<2|(i=p.indexOf(e.charAt(a++)))>>4,r=(15&i)<<4|(s=p.indexOf(e.charAt(a++)))>>2,n=(3&s)<<6|(o=p.indexOf(e.charAt(a++))),u[f++]=t,64!==s&&(u[f++]=r),64!==o&&(u[f++]=n);return u}},{"./support":30,"./utils":32}],2:[function(e,t,r){"use strict";var n=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),o=e("./stream/DataLengthProbe");function a(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}a.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,r){return e.pipe(new s).pipe(new o("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){"use strict";var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(e){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){"use strict";var n=e("./utils"),o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==n.getTypeOf(e)?function(e,t,r){var n=o,i=0+r;e^=-1;for(var s=0;s<i;s++)e=e>>>8^n[255&(e^t[s])];return-1^e}(0|t,e,e.length):function(e,t,r){var n=o,i=0+r;e^=-1;for(var s=0;s<i;s++)e=e>>>8^n[255&(e^t.charCodeAt(s))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){"use strict";var n;n="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:n}},{lie:37}],7:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),o=e("./stream/GenericWorker"),a=n?"uint8array":"array";function f(e,t){o.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic="\b\0",s.inherits(f,o),f.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(a,e.data),!1)},f.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},f.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},f.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(e){return new f("Deflate",e)},r.uncompressWorker=function(){return new f("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){"use strict";function O(e,t){var r,n="";for(r=0;r<t;r++)n+=String.fromCharCode(255&e),e>>>=8;return n}function i(e,t,r,n,i,s){var o,a,f=e.file,u=e.compression,d=s!==D.utf8encode,h=I.transformTo("string",s(f.name)),l=I.transformTo("string",D.utf8encode(f.name)),c=f.comment,p=I.transformTo("string",s(c)),m=I.transformTo("string",D.utf8encode(c)),_=l.length!==f.name.length,w=m.length!==c.length,v="",g="",y="",b=f.dir,k=f.date,x={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(x.crc32=e.crc32,x.compressedSize=e.compressedSize,x.uncompressedSize=e.uncompressedSize);var S=0;t&&(S|=8),d||!_&&!w||(S|=2048);var E,z=0,C=0;b&&(z|=16),"UNIX"===i?(C=798,z|=((E=f.unixPermissions)||(E=b?16893:33204),(65535&E)<<16)):(C=20,z|=63&(f.dosPermissions||0)),o=k.getUTCHours(),o<<=6,o|=k.getUTCMinutes(),o<<=5,o|=k.getUTCSeconds()/2,a=k.getUTCFullYear()-1980,a<<=4,a|=k.getUTCMonth()+1,a<<=5,a|=k.getUTCDate(),_&&(v+="up"+O((g=O(1,1)+O(B(h),4)+l).length,2)+g),w&&(v+="uc"+O((y=O(1,1)+O(B(p),4)+m).length,2)+y);var A="";return A+="\n\0",A+=O(S,2),A+=u.magic,A+=O(o,2),A+=O(a,2),A+=O(x.crc32,4),A+=O(x.compressedSize,4),A+=O(x.uncompressedSize,4),A+=O(h.length,2),A+=O(v.length,2),{fileRecord:T.LOCAL_FILE_HEADER+A+h+v,dirRecord:T.CENTRAL_FILE_HEADER+O(C,2)+A+O(p.length,2)+"\0\0\0\0"+O(z,4)+O(n,4)+h+v+p}}var I=e("../utils"),s=e("../stream/GenericWorker"),D=e("../utf8"),B=e("../crc32"),T=e("../signature");function n(e,t,r,n){s.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}I.inherits(n,s),n.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,s.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},n.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},n.prototype.closedSource=function(e){this.accumulate=!1;var t,r=this.streamFiles&&!e.file.dir,n=i(e,r,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),r)this.push({data:(t=e,T.DATA_DESCRIPTOR+O(t.crc32,4)+O(t.compressedSize,4)+O(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},n.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var r,n,i,s,o,a,f=this.bytesWritten-e,u=(r=this.dirRecords.length,n=f,i=e,s=this.zipComment,o=this.encodeFileName,a=I.transformTo("string",o(s)),T.CENTRAL_DIRECTORY_END+"\0\0\0\0"+O(r,2)+O(r,2)+O(n,4)+O(i,4)+O(a.length,2)+a);this.push({data:u,meta:{percent:100}})},n.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},n.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(e){t.error(e)}),this},n.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},n.prototype.error=function(e){var t=this._sources;if(!s.prototype.error.call(this,e))return!1;for(var r=0;r<t.length;r++)try{t[r].error(e)}catch(e){}return!0},n.prototype.lock=function(){s.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=n},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,r){"use strict";var u=e("../compressions"),n=e("./ZipFileWorker");r.generateWorker=function(e,o,t){var a=new n(o.streamFiles,t,o.platform,o.encodeFileName),f=0;try{e.forEach(function(e,t){f++;var r=function(e,t){var r=e||t,n=u[r];if(!n)throw new Error(r+" is not a valid compression method !");return n}(t.options.compression,o.compression),n=t.options.compressionOptions||o.compressionOptions||{},i=t.dir,s=t.date;t._compressWorker(r,n).withStreamInfo("file",{name:e,dir:i,date:s,comment:t.comment||"",unixPermissions:t.unixPermissions,dosPermissions:t.dosPermissions}).pipe(a)}),a.entriesCount=f}catch(e){a.error(e)}return a}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,r){"use strict";function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files={},this.comment=null,this.root="",this.clone=function(){var e=new n;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(n.prototype=e("./object")).loadAsync=e("./load"),n.support=e("./support"),n.defaults=e("./defaults"),n.version="3.5.0",n.loadAsync=function(e,t){return(new n).loadAsync(e,t)},n.external=e("./external"),t.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,r){"use strict";var n=e("./utils"),i=e("./external"),a=e("./utf8"),f=e("./zipEntries"),s=e("./stream/Crc32Probe"),u=e("./nodejsUtils");function d(n){return new i.Promise(function(e,t){var r=n.decompressed.getContentWorker().pipe(new s);r.on("error",function(e){t(e)}).on("end",function(){r.streamInfo.crc32!==n.decompressed.crc32?t(new Error("Corrupted zip : CRC32 mismatch")):e()}).resume()})}t.exports=function(e,s){var o=this;return s=n.extend(s||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),u.isNode&&u.isStream(e)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):n.prepareContent("the loaded zip file",e,!0,s.optimizedBinaryString,s.base64).then(function(e){var t=new f(s);return t.load(e),t}).then(function(e){var t=[i.Promise.resolve(e)],r=e.files;if(s.checkCRC32)for(var n=0;n<r.length;n++)t.push(d(r[n]));return i.Promise.all(t)}).then(function(e){for(var t=e.shift(),r=t.files,n=0;n<r.length;n++){var i=r[n];o.file(i.fileNameStr,i.decompressed,{binary:!0,optimizedBinaryString:!0,date:i.date,dir:i.dir,comment:i.fileCommentStr.length?i.fileCommentStr:null,unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions,createFolders:s.createFolders})}return t.zipComment.length&&(o.comment=t.zipComment),o})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../stream/GenericWorker");function s(e,t){i.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}n.inherits(s,i),s.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",function(e){t.push({data:e,meta:{percent:0}})}).on("error",function(e){t.isPaused?this.generatedError=e:t.error(e)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})},s.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=s},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,r){"use strict";var i=e("readable-stream").Readable;function n(e,t,r){i.call(this,t),this._helper=e;var n=this;e.on("data",function(e,t){n.push(e)||n._helper.pause(),r&&r(t)}).on("error",function(e){n.emit("error",e)}).on("end",function(){n.push(null)})}e("../utils").inherits(n,i),n.prototype._read=function(){this._helper.resume()},t.exports=n},{"../utils":32,"readable-stream":16}],14:[function(e,t,r){"use strict";t.exports={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,r){"use strict";function s(e,t,r){var n,i=d.getTypeOf(t),s=d.extend(r||{},l);s.date=s.date||new Date,null!==s.compression&&(s.compression=s.compression.toUpperCase()),"string"==typeof s.unixPermissions&&(s.unixPermissions=parseInt(s.unixPermissions,8)),s.unixPermissions&&16384&s.unixPermissions&&(s.dir=!0),s.dosPermissions&&16&s.dosPermissions&&(s.dir=!0),s.dir&&(e=u(e)),s.createFolders&&(n=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""}(e))&&w.call(this,n,!0);var o,a="string"===i&&!1===s.binary&&!1===s.base64;r&&void 0!==r.binary||(s.binary=!a),(t instanceof c&&0===t.uncompressedSize||s.dir||!t||0===t.length)&&(s.base64=!1,s.binary=!0,t="",s.compression="STORE",i="string"),o=t instanceof c||t instanceof h?t:m.isNode&&m.isStream(t)?new _(e,t):d.prepareContent(e,t,s.binary,s.optimizedBinaryString,s.base64);var f=new p(e,o,s);this.files[e]=f}function u(e){return"/"!==e.slice(-1)&&(e+="/"),e}var i=e("./utf8"),d=e("./utils"),h=e("./stream/GenericWorker"),o=e("./stream/StreamHelper"),l=e("./defaults"),c=e("./compressedObject"),p=e("./zipObject"),a=e("./generate"),m=e("./nodejsUtils"),_=e("./nodejs/NodejsStreamInputAdapter"),w=function(e,t){return t=void 0!==t?t:l.createFolders,e=u(e),this.files[e]||s.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function f(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var n={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,r,n;for(t in this.files)this.files.hasOwnProperty(t)&&(n=this.files[t],(r=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(r,n))},filter:function(r){var n=[];return this.forEach(function(e,t){r(e,t)&&n.push(t)}),n},file:function(e,t,r){if(1!==arguments.length)return e=this.root+e,s.call(this,e,t,r),this;if(f(e)){var n=e;return this.filter(function(e,t){return!t.dir&&n.test(e)})}var i=this.files[this.root+e];return i&&!i.dir?i:null},folder:function(r){if(!r)return this;if(f(r))return this.filter(function(e,t){return t.dir&&r.test(e)});var e=this.root+r,t=w.call(this,e),n=this.clone();return n.root=t.name,n},remove:function(r){r=this.root+r;var e=this.files[r];if(e||("/"!==r.slice(-1)&&(r+="/"),e=this.files[r]),e&&!e.dir)delete this.files[r];else for(var t=this.filter(function(e,t){return t.name.slice(0,r.length)===r}),n=0;n<t.length;n++)delete this.files[t[n].name];return this},generate:function(e){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,r={};try{if((r=d.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");d.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var n=r.comment||this.comment||"";t=a.generateWorker(this,r,n)}catch(e){(t=new h("error")).error(e)}return new o(t,r.type||"string",r.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.exports=n},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,r){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data[this.zero+e]},i.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),s=this.length-4;0<=s;--s)if(this.data[s]===t&&this.data[s+1]===r&&this.data[s+2]===n&&this.data[s+3]===i)return s-this.zero;return-1},i.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),s=this.readData(4);return t===s[0]&&r===s[1]&&n===s[2]&&i===s[3]},i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],18:[function(e,t,r){"use strict";var n=e("../utils");function i(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(e){},readInt:function(e){var t,r=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,r){"use strict";var n=e("./Uint8ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){"use strict";var n=e("./ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../support"),s=e("./ArrayReader"),o=e("./StringReader"),a=e("./NodeBufferReader"),f=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new a(e):i.uint8array?new f(n.transformTo("uint8array",e)):new s(n.transformTo("array",e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../utils");function s(e){n.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(s,n),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../crc32");function s(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,n),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}n.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}n.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){"use strict";function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r<this._listeners[e].length;r++)this._listeners[e][r].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.end()}),e.on("error",function(e){t.error(e)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)this.extraStreamInfo.hasOwnProperty(e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=n},{}],29:[function(e,t,r){"use strict";var u=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),d=e("../base64"),n=e("../support"),o=e("../external"),a=null;if(n.nodestream)try{a=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function f(e,t,r){var n=t;switch(t){case"blob":case"arraybuffer":n="uint8array";break;case"base64":n="string"}try{this._internalType=n,this._outputType=t,this._mimeType=r,u.checkSupport(n),this._worker=e.pipe(new i(n)),e.lock()}catch(e){this._worker=new s("error"),this._worker.error(e)}}f.prototype={accumulate:function(e){return a=this,f=e,new o.Promise(function(t,r){var n=[],i=a._internalType,s=a._outputType,o=a._mimeType;a.on("data",function(e,t){n.push(e),f&&f(t)}).on("error",function(e){n=[],r(e)}).on("end",function(){try{var e=function(e,t,r){switch(e){case"blob":return u.newBlob(u.transformTo("arraybuffer",t),r);case"base64":return d.encode(t);default:return u.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,s=0;for(r=0;r<t.length;r++)s+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(s),r=0;r<t.length;r++)i.set(t[r],n),n+=t[r].length;return i;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(i,n),o);t(e)}catch(e){r(e)}n=[]}).resume()});var a,f},on:function(e,t){var r=this;return"data"===e?this._worker.on(e,function(e){t.call(r,e.data,e.meta)}):this._worker.on(e,function(){u.delay(t,arguments,r)}),this},resume:function(){return u.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(u.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new a(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,r){"use strict";if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,r.nodebuffer="undefined"!=typeof Buffer,r.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)r.blob=!1;else{var n=new ArrayBuffer(0);try{r.blob=0===new Blob([n],{type:"application/zip"}).size}catch(e){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(n),r.blob=0===i.getBlob("application/zip").size}catch(e){r.blob=!1}}}try{r.nodestream=!!e("readable-stream").Readable}catch(e){r.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,s){"use strict";for(var a=e("./utils"),f=e("./support"),r=e("./nodejsUtils"),n=e("./stream/GenericWorker"),u=new Array(256),i=0;i<256;i++)u[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;function o(){n.call(this,"utf-8 decode"),this.leftOver=null}function d(){n.call(this,"utf-8 encode")}u[254]=u[254]=1,s.utf8encode=function(e){return f.nodebuffer?r.newBufferFrom(e,"utf-8"):function(e){var t,r,n,i,s,o=e.length,a=0;for(i=0;i<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),a+=r<128?1:r<2048?2:r<65536?3:4;for(t=f.uint8array?new Uint8Array(a):new Array(a),i=s=0;s<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t}(e)},s.utf8decode=function(e){return f.nodebuffer?a.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,n,i,s=e.length,o=new Array(2*s);for(t=r=0;t<s;)if((n=e[t++])<128)o[r++]=n;else if(4<(i=u[n]))o[r++]=65533,t+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&t<s;)n=n<<6|63&e[t++],i--;1<i?o[r++]=65533:n<65536?o[r++]=n:(n-=65536,o[r++]=55296|n>>10&1023,o[r++]=56320|1023&n)}return o.length!==r&&(o.subarray?o=o.subarray(0,r):o.length=r),a.applyFromCharCode(o)}(e=a.transformTo(f.uint8array?"uint8array":"array",e))},a.inherits(o,n),o.prototype.processChunk=function(e){var t=a.transformTo(f.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(f.uint8array){var r=t;(t=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),t.set(r,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var n=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}(t),i=t;n!==t.length&&(f.uint8array?(i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length)):(i=t.slice(0,n),this.leftOver=t.slice(n,t.length))),this.push({data:s.utf8decode(i),meta:e.meta})},o.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=o,a.inherits(d,n),d.prototype.processChunk=function(e){this.push({data:s.utf8encode(e.data),meta:e.meta})},s.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,a){"use strict";var f=e("./support"),u=e("./base64"),r=e("./nodejsUtils"),n=e("set-immediate-shim"),d=e("./external");function i(e){return e}function h(e,t){for(var r=0;r<e.length;++r)t[r]=255&e.charCodeAt(r);return t}a.newBlob=function(t,r){a.checkSupport("blob");try{return new Blob([t],{type:r})}catch(e){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return n.append(t),n.getBlob(r)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var s={stringifyByChunk:function(e,t,r){var n=[],i=0,s=e.length;if(s<=r)return String.fromCharCode.apply(null,e);for(;i<s;)"array"===t||"nodebuffer"===t?n.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+r,s)))):n.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+r,s)))),i+=r;return n.join("")},stringifyByChar:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return f.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return f.nodebuffer&&1===String.fromCharCode.apply(null,r.allocBuffer(1)).length}catch(e){return!1}}()}};function o(e){var t=65536,r=a.getTypeOf(e),n=!0;if("uint8array"===r?n=s.applyCanBeUsed.uint8array:"nodebuffer"===r&&(n=s.applyCanBeUsed.nodebuffer),n)for(;1<t;)try{return s.stringifyByChunk(e,r,t)}catch(e){t=Math.floor(t/2)}return s.stringifyByChar(e)}function l(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}a.applyFromCharCode=o;var c={};c.string={string:i,array:function(e){return h(e,new Array(e.length))},arraybuffer:function(e){return c.string.uint8array(e).buffer},uint8array:function(e){return h(e,new Uint8Array(e.length))},nodebuffer:function(e){return h(e,r.allocBuffer(e.length))}},c.array={string:o,array:i,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(e)}},c.arraybuffer={string:function(e){return o(new Uint8Array(e))},array:function(e){return l(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:i,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(new Uint8Array(e))}},c.uint8array={string:o,array:function(e){return l(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:i,nodebuffer:function(e){return r.newBufferFrom(e)}},c.nodebuffer={string:o,array:function(e){return l(e,new Array(e.length))},arraybuffer:function(e){return c.nodebuffer.uint8array(e).buffer},uint8array:function(e){return l(e,new Uint8Array(e.length))},nodebuffer:i},a.transformTo=function(e,t){if(t=t||"",!e)return t;a.checkSupport(e);var r=a.getTypeOf(t);return c[r][e](t)},a.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":f.nodebuffer&&r.isBuffer(e)?"nodebuffer":f.uint8array&&e instanceof Uint8Array?"uint8array":f.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},a.checkSupport=function(e){if(!f[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},a.MAX_VALUE_16BITS=65535,a.MAX_VALUE_32BITS=-1,a.pretty=function(e){var t,r,n="";for(r=0;r<(e||"").length;r++)n+="\\x"+((t=e.charCodeAt(r))<16?"0":"")+t.toString(16).toUpperCase();return n},a.delay=function(e,t,r){n(function(){e.apply(r||null,t||[])})},a.inherits=function(e,t){function r(){}r.prototype=t.prototype,e.prototype=new r},a.extend=function(){var e,t,r={};for(e=0;e<arguments.length;e++)for(t in arguments[e])arguments[e].hasOwnProperty(t)&&void 0===r[t]&&(r[t]=arguments[e][t]);return r},a.prepareContent=function(n,e,i,s,o){return d.Promise.resolve(e).then(function(n){return f.blob&&(n instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(n)))&&"undefined"!=typeof FileReader?new d.Promise(function(t,r){var e=new FileReader;e.onload=function(e){t(e.target.result)},e.onerror=function(e){r(e.target.error)},e.readAsArrayBuffer(n)}):n}).then(function(e){var t,r=a.getTypeOf(e);return r?("arraybuffer"===r?e=a.transformTo("uint8array",e):"string"===r&&(o?e=u.decode(e):i&&!0!==s&&(e=h(t=e,f.uint8array?new Uint8Array(t.length):new Array(t.length)))),e):d.Promise.reject(new Error("Can't read the data of '"+n+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,"set-immediate-shim":54}],33:[function(e,t,r){"use strict";var n=e("./reader/readerFor"),i=e("./utils"),s=e("./signature"),o=e("./zipEntry"),a=(e("./utf8"),e("./support"));function f(e){this.files=[],this.loadOptions=e}f.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(t)+", expected "+i.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var n=this.reader.readString(4)===t;return this.reader.setIndex(r),n},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=a.uint8array?"uint8array":"array",r=i.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,r,n=this.zip64EndOfCentralSize-44;0<n;)e=this.reader.readInt(2),t=this.reader.readInt(4),r=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)(e=new o({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,s.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):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");this.reader.setIndex(e);var t=e;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var n=t-r;if(0<n)this.isSignature(t,s.CENTRAL_FILE_HEADER)||(this.reader.zero=n);else if(n<0)throw new Error("Corrupted zip: missing "+Math.abs(n)+" bytes.")},prepareReader:function(e){this.reader=n(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=f},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utf8":31,"./utils":32,"./zipEntry":34}],34:[function(e,t,r){"use strict";var n=e("./reader/readerFor"),s=e("./utils"),i=e("./compressedObject"),o=e("./crc32"),a=e("./utf8"),f=e("./compressions"),u=e("./support");function d(e,t){this.options=e,this.loadOptions=t}d.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},readLocalPart:function(e){var t,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in f)if(f.hasOwnProperty(t)&&f[t].magic===e)return f[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=n(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<i;)t=e.readInt(2),r=e.readInt(2),n=e.readData(r),this.extraFields[t]={id:t,length:r,value:n};e.setIndex(i)},handleUTF8:function(){var e=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=a.utf8decode(this.fileName),this.fileCommentStr=a.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var r=s.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var n=this.findExtraFieldUnicodeComment();if(null!==n)this.fileCommentStr=n;else{var i=s.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(i)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=n(e.value);return 1!==t.readInt(1)?null:o(this.fileName)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=n(e.value);return 1!==t.readInt(1)?null:o(this.fileComment)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null}},t.exports=d},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,r){"use strict";function n(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}}var s=e("./stream/StreamHelper"),i=e("./stream/DataWorker"),o=e("./utf8"),a=e("./compressedObject"),f=e("./stream/GenericWorker");n.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw new Error("No output type specified.");var n="string"===(r=e.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),t=this._decompressWorker();var i=!this._dataBinary;i&&!n&&(t=t.pipe(new o.Utf8EncodeWorker)),!i&&n&&(t=t.pipe(new o.Utf8DecodeWorker))}catch(e){(t=new f("error")).error(e)}return new s(t,r,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof a&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new o.Utf8EncodeWorker)),a.createWorkerFrom(r,e,t)},_decompressWorker:function(){return this._data instanceof a?this._data.getContentWorker():this._data instanceof f?this._data:new i(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],d=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<u.length;h++)n.prototype[u[h]]=d;t.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,d,t){(function(t){"use strict";var r,n,e=t.MutationObserver||t.WebKitMutationObserver;if(e){var i=0,s=new e(u),o=t.document.createTextNode("");s.observe(o,{characterData:!0}),r=function(){o.data=i=++i%2}}else if(t.setImmediate||void 0===t.MessageChannel)r="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){u(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(u,0)};else{var a=new t.MessageChannel;a.port1.onmessage=u,r=function(){a.port2.postMessage(0)}}var f=[];function u(){var e,t;n=!0;for(var r=f.length;r;){for(t=f,f=[],e=-1;++e<r;)t[e]();r=f.length}n=!1}d.exports=function(e){1!==f.push(e)||n||r()}}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,r){"use strict";var i=e("immediate");function u(){}var d={},s=["REJECTED"],o=["FULFILLED"],n=["PENDING"];function a(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=n,this.queue=[],this.outcome=void 0,e!==u&&c(this,e)}function f(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function h(t,r,n){i(function(){var e;try{e=r(n)}catch(e){return d.reject(t,e)}e===t?d.reject(t,new TypeError("Cannot resolve promise with itself")):d.resolve(t,e)})}function l(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function c(t,e){var r=!1;function n(e){r||(r=!0,d.reject(t,e))}function i(e){r||(r=!0,d.resolve(t,e))}var s=p(function(){e(i,n)});"error"===s.status&&n(s.value)}function p(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}(t.exports=a).prototype.finally=function(t){if("function"!=typeof t)return this;var r=this.constructor;return this.then(function(e){return r.resolve(t()).then(function(){return e})},function(e){return r.resolve(t()).then(function(){throw e})})},a.prototype.catch=function(e){return this.then(null,e)},a.prototype.then=function(e,t){if("function"!=typeof e&&this.state===o||"function"!=typeof t&&this.state===s)return this;var r=new this.constructor(u);return this.state!==n?h(r,this.state===o?e:t,this.outcome):this.queue.push(new f(r,e,t)),r},f.prototype.callFulfilled=function(e){d.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){d.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},d.resolve=function(e,t){var r=p(l,t);if("error"===r.status)return d.reject(e,r.value);var n=r.value;if(n)c(e,n);else{e.state=o,e.outcome=t;for(var i=-1,s=e.queue.length;++i<s;)e.queue[i].callFulfilled(t)}return e},d.reject=function(e,t){e.state=s,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},a.resolve=function(e){return e instanceof this?e:d.resolve(new this(u),e)},a.reject=function(e){var t=new this(u);return d.reject(t,e)},a.all=function(e){var r=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var s=new Array(n),o=0,t=-1,a=new this(u);++t<n;)f(e[t],t);return a;function f(e,t){r.resolve(e).then(function(e){s[t]=e,++o!==n||i||(i=!0,d.resolve(a,s))},function(e){i||(i=!0,d.reject(a,e))})}},a.race=function(e){if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var t=e.length,r=!1;if(!t)return this.resolve([]);for(var n,i=-1,s=new this(u);++i<t;)n=e[i],this.resolve(n).then(function(e){r||(r=!0,d.resolve(s,e))},function(e){r||(r=!0,d.reject(s,e))});return s}},{immediate:36}],38:[function(e,t,r){"use strict";var n={};(0,e("./lib/utils/common").assign)(n,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,r){"use strict";var o=e("./zlib/deflate"),a=e("./utils/common"),f=e("./utils/strings"),i=e("./zlib/messages"),s=e("./zlib/zstream"),u=Object.prototype.toString,d=0,h=-1,l=0,c=8;function p(e){if(!(this instanceof p))return new p(e);this.options=a.assign({level:h,method:c,chunkSize:16384,windowBits:15,memLevel:8,strategy:l,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var r=o.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==d)throw new Error(i[r]);if(t.header&&o.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?f.string2buf(t.dictionary):"[object ArrayBuffer]"===u.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=o.deflateSetDictionary(this.strm,n))!==d)throw new Error(i[r]);this._dict_set=!0}}function n(e,t){var r=new p(t);if(r.push(e,!0),r.err)throw r.msg||i[r.err];return r.result}p.prototype.push=function(e,t){var r,n,i=this.strm,s=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=f.string2buf(e):"[object ArrayBuffer]"===u.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new a.Buf8(s),i.next_out=0,i.avail_out=s),1!==(r=o.deflate(i,n))&&r!==d)return this.onEnd(r),!(this.ended=!0);0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(f.buf2binstring(a.shrinkBuf(i.output,i.next_out))):this.onData(a.shrinkBuf(i.output,i.next_out)))}while((0<i.avail_in||0===i.avail_out)&&1!==r);return 4===n?(r=o.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===d):2!==n||(this.onEnd(d),!(i.avail_out=0))},p.prototype.onData=function(e){this.chunks.push(e)},p.prototype.onEnd=function(e){e===d&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Deflate=p,r.deflate=n,r.deflateRaw=function(e,t){return(t=t||{}).raw=!0,n(e,t)},r.gzip=function(e,t){return(t=t||{}).gzip=!0,n(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,r){"use strict";var l=e("./zlib/inflate"),c=e("./utils/common"),p=e("./utils/strings"),m=e("./zlib/constants"),n=e("./zlib/messages"),i=e("./zlib/zstream"),s=e("./zlib/gzheader"),_=Object.prototype.toString;function o(e){if(!(this instanceof o))return new o(e);this.options=c.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;var r=l.inflateInit2(this.strm,t.windowBits);if(r!==m.Z_OK)throw new Error(n[r]);this.header=new s,l.inflateGetHeader(this.strm,this.header)}function a(e,t){var r=new o(t);if(r.push(e,!0),r.err)throw r.msg||n[r.err];return r.result}o.prototype.push=function(e,t){var r,n,i,s,o,a,f=this.strm,u=this.options.chunkSize,d=this.options.dictionary,h=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?m.Z_FINISH:m.Z_NO_FLUSH,"string"==typeof e?f.input=p.binstring2buf(e):"[object ArrayBuffer]"===_.call(e)?f.input=new Uint8Array(e):f.input=e,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new c.Buf8(u),f.next_out=0,f.avail_out=u),(r=l.inflate(f,m.Z_NO_FLUSH))===m.Z_NEED_DICT&&d&&(a="string"==typeof d?p.string2buf(d):"[object ArrayBuffer]"===_.call(d)?new Uint8Array(d):d,r=l.inflateSetDictionary(this.strm,a)),r===m.Z_BUF_ERROR&&!0===h&&(r=m.Z_OK,h=!1),r!==m.Z_STREAM_END&&r!==m.Z_OK)return this.onEnd(r),!(this.ended=!0);f.next_out&&(0!==f.avail_out&&r!==m.Z_STREAM_END&&(0!==f.avail_in||n!==m.Z_FINISH&&n!==m.Z_SYNC_FLUSH)||("string"===this.options.to?(i=p.utf8border(f.output,f.next_out),s=f.next_out-i,o=p.buf2string(f.output,i),f.next_out=s,f.avail_out=u-s,s&&c.arraySet(f.output,f.output,i,s,0),this.onData(o)):this.onData(c.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(h=!0)}while((0<f.avail_in||0===f.avail_out)&&r!==m.Z_STREAM_END);return r===m.Z_STREAM_END&&(n=m.Z_FINISH),n===m.Z_FINISH?(r=l.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===m.Z_OK):n!==m.Z_SYNC_FLUSH||(this.onEnd(m.Z_OK),!(f.avail_out=0))},o.prototype.onData=function(e){this.chunks.push(e)},o.prototype.onEnd=function(e){e===m.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=c.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Inflate=o,r.inflate=a,r.inflateRaw=function(e,t){return(t=t||{}).raw=!0,a(e,t)},r.ungzip=a},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])}}return e},r.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var s=0;s<n;s++)e[i+s]=t[r+s]},flattenChunks:function(e){var t,r,n,i,s,o;for(t=n=0,r=e.length;t<r;t++)n+=e[t].length;for(o=new Uint8Array(n),t=i=0,r=e.length;t<r;t++)s=e[t],o.set(s,i),i+=s.length;return o}},s={arraySet:function(e,t,r,n,i){for(var s=0;s<n;s++)e[i+s]=t[r+s]},flattenChunks:function(e){return[].concat.apply([],e)}};r.setTyped=function(e){e?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,i)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,s))},r.setTyped(n)},{}],42:[function(e,t,r){"use strict";var f=e("./common"),i=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var u=new f.Buf8(256),n=0;n<256;n++)u[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function d(e,t){if(t<65537&&(e.subarray&&s||!e.subarray&&i))return String.fromCharCode.apply(null,f.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}u[254]=u[254]=1,r.string2buf=function(e){var t,r,n,i,s,o=e.length,a=0;for(i=0;i<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),a+=r<128?1:r<2048?2:r<65536?3:4;for(t=new f.Buf8(a),i=s=0;s<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.buf2binstring=function(e){return d(e,e.length)},r.binstring2buf=function(e){for(var t=new f.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},r.buf2string=function(e,t){var r,n,i,s,o=t||e.length,a=new Array(2*o);for(r=n=0;r<o;)if((i=e[r++])<128)a[n++]=i;else if(4<(s=u[i]))a[n++]=65533,r+=s-1;else{for(i&=2===s?31:3===s?15:7;1<s&&r<o;)i=i<<6|63&e[r++],s--;1<s?a[n++]=65533:i<65536?a[n++]=i:(i-=65536,a[n++]=55296|i>>10&1023,a[n++]=56320|1023&i)}return d(a,n)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}},{"./common":41}],43:[function(e,t,r){"use strict";t.exports=function(e,t,r,n){for(var i=65535&e|0,s=e>>>16&65535|0,o=0;0!==r;){for(r-=o=2e3<r?2e3:r;s=s+(i=i+t[n++]|0)|0,--o;);i%=65521,s%=65521}return i|s<<16|0}},{}],44:[function(e,t,r){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,r){"use strict";var a=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var i=a,s=n+r;e^=-1;for(var o=n;o<s;o++)e=e>>>8^i[255&(e^t[o])];return-1^e}},{}],46:[function(e,t,r){"use strict";var f,l=e("../utils/common"),u=e("./trees"),c=e("./adler32"),p=e("./crc32"),n=e("./messages"),d=0,h=0,m=-2,i=2,_=8,s=286,o=30,a=19,w=2*s+1,v=15,g=3,y=258,b=y+g+1,k=42,x=113;function S(e,t){return e.msg=n[t],t}function E(e){return(e<<1)-(4<e?9:0)}function z(e){for(var t=e.length;0<=--t;)e[t]=0}function C(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(l.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function A(e,t){u._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,C(e.strm)}function O(e,t){e.pending_buf[e.pending++]=t}function I(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function D(e,t){var r,n,i=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,f=e.strstart>e.w_size-b?e.strstart-(e.w_size-b):0,u=e.window,d=e.w_mask,h=e.prev,l=e.strstart+y,c=u[s+o-1],p=u[s+o];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(r=t)+o]===p&&u[r+o-1]===c&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&s<l);if(n=y-(l-s),s=l-y,o<n){if(e.match_start=t,a<=(o=n))break;c=u[s+o-1],p=u[s+o]}}}while((t=h[t&d])>f&&0!=--i);return o<=e.lookahead?o:e.lookahead}function B(e){var t,r,n,i,s,o,a,f,u,d,h=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=h+(h-b)){for(l.arraySet(e.window,e.window,h,h,0),e.match_start-=h,e.strstart-=h,e.block_start-=h,t=r=e.hash_size;n=e.head[--t],e.head[t]=h<=n?n-h:0,--r;);for(t=r=h;n=e.prev[--t],e.prev[t]=h<=n?n-h:0,--r;);i+=h}if(0===e.strm.avail_in)break;if(o=e.strm,a=e.window,f=e.strstart+e.lookahead,d=void 0,(u=i)<(d=o.avail_in)&&(d=u),r=0===d?0:(o.avail_in-=d,l.arraySet(a,o.input,o.next_in,d,f),1===o.state.wrap?o.adler=c(o.adler,a,d,f):2===o.state.wrap&&(o.adler=p(o.adler,a,d,f)),o.next_in+=d,o.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=g)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+g-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<g)););}while(e.lookahead<b&&0!==e.strm.avail_in)}function T(e,t){for(var r,n;;){if(e.lookahead<b){if(B(e),e.lookahead<b&&t===d)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=g&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+g-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-b&&(e.match_length=D(e,r)),e.match_length>=g)if(n=u._tr_tally(e,e.strstart-e.match_start,e.match_length-g),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=g){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+g-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(A(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<g-1?e.strstart:g-1,4===t?(A(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(A(e,!1),0===e.strm.avail_out)?1:2}function R(e,t){for(var r,n,i;;){if(e.lookahead<b){if(B(e),e.lookahead<b&&t===d)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=g&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+g-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=g-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-b&&(e.match_length=D(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===g&&4096<e.strstart-e.match_start)&&(e.match_length=g-1)),e.prev_length>=g&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-g,n=u._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-g),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+g-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=g-1,e.strstart++,n&&(A(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=u._tr_tally(e,0,e.window[e.strstart-1]))&&A(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=u._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<g-1?e.strstart:g-1,4===t?(A(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(A(e,!1),0===e.strm.avail_out)?1:2}function F(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function N(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=_,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new l.Buf16(2*w),this.dyn_dtree=new l.Buf16(2*(2*o+1)),this.bl_tree=new l.Buf16(2*(2*a+1)),z(this.dyn_ltree),z(this.dyn_dtree),z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new l.Buf16(v+1),this.heap=new l.Buf16(2*s+1),z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new l.Buf16(2*s+1),z(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function U(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=i,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?k:x,e.adler=2===t.wrap?0:1,t.last_flush=d,u._tr_init(t),h):S(e,m)}function L(e){var t,r=U(e);return r===h&&((t=e.state).window_size=2*t.w_size,z(t.head),t.max_lazy_match=f[t.level].max_lazy,t.good_match=f[t.level].good_length,t.nice_match=f[t.level].nice_length,t.max_chain_length=f[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=g-1,t.match_available=0,t.ins_h=0),r}function P(e,t,r,n,i,s){if(!e)return m;var o=1;if(-1===t&&(t=6),n<0?(o=0,n=-n):15<n&&(o=2,n-=16),i<1||9<i||r!==_||n<8||15<n||t<0||9<t||s<0||4<s)return S(e,m);8===n&&(n=9);var a=new N;return(e.state=a).strm=e,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+g-1)/g),a.window=new l.Buf8(2*a.w_size),a.head=new l.Buf16(a.hash_size),a.prev=new l.Buf16(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new l.Buf8(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=t,a.strategy=s,a.method=r,L(e)}f=[new F(0,0,0,0,function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(B(e),0===e.lookahead&&t===d)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,A(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-b&&(A(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(A(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(A(e,!1),e.strm.avail_out),1)}),new F(4,4,8,4,T),new F(4,5,16,8,T),new F(4,6,32,32,T),new F(4,4,16,16,R),new F(8,16,32,32,R),new F(8,16,128,128,R),new F(8,32,128,256,R),new F(32,128,258,1024,R),new F(32,258,258,4096,R)],r.deflateInit=function(e,t){return P(e,t,_,15,8,0)},r.deflateInit2=P,r.deflateReset=L,r.deflateResetKeep=U,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?m:(e.state.gzhead=t,h):m},r.deflate=function(e,t){var r,n,i,s;if(!e||!e.state||5<t||t<0)return e?S(e,m):m;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||666===n.status&&4!==t)return S(e,0===e.avail_out?-5:m);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===k)if(2===n.wrap)e.adler=0,O(n,31),O(n,139),O(n,8),n.gzhead?(O(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),O(n,255&n.gzhead.time),O(n,n.gzhead.time>>8&255),O(n,n.gzhead.time>>16&255),O(n,n.gzhead.time>>24&255),O(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),O(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(O(n,255&n.gzhead.extra.length),O(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=p(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(O(n,0),O(n,0),O(n,0),O(n,0),O(n,0),O(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),O(n,3),n.status=x);else{var o=_+(n.w_bits-8<<4)<<8;o|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(o|=32),o+=31-o%31,n.status=x,I(n,o),0!==n.strstart&&(I(n,e.adler>>>16),I(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),C(e),i=n.pending,n.pending!==n.pending_buf_size));)O(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),C(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,O(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),C(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,O(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&C(e),n.pending+2<=n.pending_buf_size&&(O(n,255&e.adler),O(n,e.adler>>8&255),e.adler=0,n.status=x)):n.status=x),0!==n.pending){if(C(e),0===e.avail_out)return n.last_flush=-1,h}else if(0===e.avail_in&&E(t)<=E(r)&&4!==t)return S(e,-5);if(666===n.status&&0!==e.avail_in)return S(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==d&&666!==n.status){var a=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(B(e),0===e.lookahead)){if(t===d)return 1;break}if(e.match_length=0,r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(A(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(A(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(A(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,s,o=e.window;;){if(e.lookahead<=y){if(B(e),e.lookahead<=y&&t===d)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=g&&0<e.strstart&&(n=o[i=e.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){s=e.strstart+y;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);e.match_length=y-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=g?(r=u._tr_tally(e,1,e.match_length-g),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(A(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(A(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(A(e,!1),0===e.strm.avail_out)?1:2}(n,t):f[n.level].func(n,t);if(3!==a&&4!==a||(n.status=666),1===a||3===a)return 0===e.avail_out&&(n.last_flush=-1),h;if(2===a&&(1===t?u._tr_align(n):5!==t&&(u._tr_stored_block(n,0,0,!1),3===t&&(z(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),C(e),0===e.avail_out))return n.last_flush=-1,h}return 4!==t?h:n.wrap<=0?1:(2===n.wrap?(O(n,255&e.adler),O(n,e.adler>>8&255),O(n,e.adler>>16&255),O(n,e.adler>>24&255),O(n,255&e.total_in),O(n,e.total_in>>8&255),O(n,e.total_in>>16&255),O(n,e.total_in>>24&255)):(I(n,e.adler>>>16),I(n,65535&e.adler)),C(e),0<n.wrap&&(n.wrap=-n.wrap),0!==n.pending?h:1)},r.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==k&&69!==t&&73!==t&&91!==t&&103!==t&&t!==x&&666!==t?S(e,m):(e.state=null,t===x?S(e,-3):h):m},r.deflateSetDictionary=function(e,t){var r,n,i,s,o,a,f,u,d=t.length;if(!e||!e.state)return m;if(2===(s=(r=e.state).wrap)||1===s&&r.status!==k||r.lookahead)return m;for(1===s&&(e.adler=c(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===s&&(z(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new l.Buf8(r.w_size),l.arraySet(u,t,d-r.w_size,r.w_size,0),t=u,d=r.w_size),o=e.avail_in,a=e.next_in,f=e.input,e.avail_in=d,e.next_in=0,e.input=t,B(r);r.lookahead>=g;){for(n=r.strstart,i=r.lookahead-(g-1);r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+g-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++,--i;);r.strstart=n,r.lookahead=g-1,B(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=g-1,r.match_available=0,e.next_in=a,e.input=f,e.avail_in=o,r.wrap=s,h},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,r){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,r){"use strict";t.exports=function(e,t){var r,n,i,s,o,a,f,u,d,h,l,c,p,m,_,w,v,g,y,b,k,x,S,E,z;r=e.state,n=e.next_in,E=e.input,i=n+(e.avail_in-5),s=e.next_out,z=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),f=r.dmax,u=r.wsize,d=r.whave,h=r.wnext,l=r.window,c=r.hold,p=r.bits,m=r.lencode,_=r.distcode,w=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;e:do{p<15&&(c+=E[n++]<<p,p+=8,c+=E[n++]<<p,p+=8),g=m[c&w];t:for(;;){if(c>>>=y=g>>>24,p-=y,0==(y=g>>>16&255))z[s++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=m[(65535&g)+(c&(1<<y)-1)];continue t}if(32&y){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&g,(y&=15)&&(p<y&&(c+=E[n++]<<p,p+=8),b+=c&(1<<y)-1,c>>>=y,p-=y),p<15&&(c+=E[n++]<<p,p+=8,c+=E[n++]<<p,p+=8),g=_[c&v];r:for(;;){if(c>>>=y=g>>>24,p-=y,!(16&(y=g>>>16&255))){if(0==(64&y)){g=_[(65535&g)+(c&(1<<y)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(k=65535&g,p<(y&=15)&&(c+=E[n++]<<p,(p+=8)<y&&(c+=E[n++]<<p,p+=8)),f<(k+=c&(1<<y)-1)){e.msg="invalid distance too far back",r.mode=30;break e}if(c>>>=y,p-=y,(y=s-o)<k){if(d<(y=k-y)&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(S=l,(x=0)===h){if(x+=u-y,y<b){for(b-=y;z[s++]=l[x++],--y;);x=s-k,S=z}}else if(h<y){if(x+=u+h-y,(y-=h)<b){for(b-=y;z[s++]=l[x++],--y;);if(x=0,h<b){for(b-=y=h;z[s++]=l[x++],--y;);x=s-k,S=z}}}else if(x+=h-y,y<b){for(b-=y;z[s++]=l[x++],--y;);x=s-k,S=z}for(;2<b;)z[s++]=S[x++],z[s++]=S[x++],z[s++]=S[x++],b-=3;b&&(z[s++]=S[x++],1<b&&(z[s++]=S[x++]))}else{for(x=s-k;z[s++]=z[x++],z[s++]=z[x++],z[s++]=z[x++],2<(b-=3););b&&(z[s++]=z[x++],1<b&&(z[s++]=z[x++]))}break}}break}}while(n<i&&s<a);n-=b=p>>3,c&=(1<<(p-=b<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=s<a?a-s+257:257-(s-a),r.hold=c,r.bits=p}},{}],49:[function(e,t,r){"use strict";var O=e("../utils/common"),I=e("./adler32"),D=e("./crc32"),B=e("./inffast"),T=e("./inftrees"),R=1,F=2,N=0,U=-2,L=1,n=852,i=592;function P(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new O.Buf16(320),this.work=new O.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function o(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=L,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new O.Buf32(n),t.distcode=t.distdyn=new O.Buf32(i),t.sane=1,t.back=-1,N):U}function a(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,o(e)):U}function f(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?U:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,a(e))):U}function u(e,t){var r,n;return e?(n=new s,(e.state=n).window=null,(r=f(e,t))!==N&&(e.state=null),r):U}var d,h,l=!0;function j(e){if(l){var t;for(d=new O.Buf32(512),h=new O.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(T(R,e.lens,0,288,d,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;T(F,e.lens,0,32,h,0,e.work,{bits:5}),l=!1}e.lencode=d,e.lenbits=9,e.distcode=h,e.distbits=5}function Z(e,t,r,n){var i,s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new O.Buf8(s.wsize)),n>=s.wsize?(O.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(n<(i=s.wsize-s.wnext)&&(i=n),O.arraySet(s.window,t,r-n,i,s.wnext),(n-=i)?(O.arraySet(s.window,t,r-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0}r.inflateReset=a,r.inflateReset2=f,r.inflateResetKeep=o,r.inflateInit=function(e){return u(e,15)},r.inflateInit2=u,r.inflate=function(e,t){var r,n,i,s,o,a,f,u,d,h,l,c,p,m,_,w,v,g,y,b,k,x,S,E,z=0,C=new O.Buf8(4),A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return U;12===(r=e.state).mode&&(r.mode=13),o=e.next_out,i=e.output,f=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,u=r.hold,d=r.bits,h=a,l=f,x=N;e:for(;;)switch(r.mode){case L:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if(2&r.wrap&&35615===u){C[r.check=0]=255&u,C[1]=u>>>8&255,r.check=D(r.check,C,2,0),d=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=30;break}if(d-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<k,e.adler=r.check=1,r.mode=512&u?10:12,d=u=0;break;case 2:for(;d<16;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if(r.flags=u,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(C[0]=255&u,C[1]=u>>>8&255,r.check=D(r.check,C,2,0)),d=u=0,r.mode=3;case 3:for(;d<32;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}r.head&&(r.head.time=u),512&r.flags&&(C[0]=255&u,C[1]=u>>>8&255,C[2]=u>>>16&255,C[3]=u>>>24&255,r.check=D(r.check,C,4,0)),d=u=0,r.mode=4;case 4:for(;d<16;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(C[0]=255&u,C[1]=u>>>8&255,r.check=D(r.check,C,2,0)),d=u=0,r.mode=5;case 5:if(1024&r.flags){for(;d<16;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(C[0]=255&u,C[1]=u>>>8&255,r.check=D(r.check,C,2,0)),d=u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(a<(c=r.length)&&(c=a),c&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),O.arraySet(r.head.extra,n,s,c,k)),512&r.flags&&(r.check=D(r.check,n,c,s)),a-=c,s+=c,r.length-=c),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===a)break e;for(c=0;k=n[s+c++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&c<a;);if(512&r.flags&&(r.check=D(r.check,n,c,s)),a-=c,s+=c,k)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===a)break e;for(c=0;k=n[s+c++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k)),k&&c<a;);if(512&r.flags&&(r.check=D(r.check,n,c,s)),a-=c,s+=c,k)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;d<16;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}d=u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;d<32;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}e.adler=r.check=P(u),d=u=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=o,e.avail_out=f,e.next_in=s,e.avail_in=a,r.hold=u,r.bits=d,2;e.adler=r.check=1,r.mode=12;case 12:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}switch(r.last=1&u,d-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==t)break;u>>>=2,d-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}u>>>=2,d-=2;break;case 14:for(u>>>=7&d,d-=7&d;d<32;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,d=u=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(c=r.length){if(a<c&&(c=a),f<c&&(c=f),0===c)break e;O.arraySet(i,n,s,c,o),a-=c,s+=c,f-=c,o+=c,r.length-=c;break}r.mode=12;break;case 17:for(;d<14;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if(r.nlen=257+(31&u),u>>>=5,d-=5,r.ndist=1+(31&u),u>>>=5,d-=5,r.ncode=4+(15&u),u>>>=4,d-=4,286<r.nlen||30<r.ndist){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}r.lens[A[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;w=(z=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,v=65535&z,!((_=z>>>24)<=d);){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if(v<16)u>>>=_,d-=_,r.lens[r.have++]=v;else{if(16===v){for(E=_+2;d<E;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if(u>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],c=3+(3&u),u>>>=2,d-=2}else if(17===v){for(E=_+3;d<E;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}d-=_,k=0,c=3+(7&(u>>>=_)),u>>>=3,d-=3}else{for(E=_+7;d<E;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}d-=_,k=0,c=11+(127&(u>>>=_)),u>>>=7,d-=7}if(r.have+c>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;c--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(R,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=a&&258<=f){e.next_out=o,e.avail_out=f,e.next_in=s,e.avail_in=a,r.hold=u,r.bits=d,B(e,l),o=e.next_out,i=e.output,f=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,u=r.hold,d=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;w=(z=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,v=65535&z,!((_=z>>>24)<=d);){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if(w&&0==(240&w)){for(g=_,y=w,b=v;w=(z=r.lencode[b+((u&(1<<g+y)-1)>>g)])>>>16&255,v=65535&z,!(g+(_=z>>>24)<=d);){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,r.length=v,0===w){r.mode=26;break}if(32&w){r.back=-1,r.mode=12;break}if(64&w){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&w,r.mode=22;case 22:if(r.extra){for(E=r.extra;d<E;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;w=(z=r.distcode[u&(1<<r.distbits)-1])>>>16&255,v=65535&z,!((_=z>>>24)<=d);){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if(0==(240&w)){for(g=_,y=w,b=v;w=(z=r.distcode[b+((u&(1<<g+y)-1)>>g)])>>>16&255,v=65535&z,!(g+(_=z>>>24)<=d);){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,64&w){e.msg="invalid distance code",r.mode=30;break}r.offset=v,r.extra=15&w,r.mode=24;case 24:if(r.extra){for(E=r.extra;d<E;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===f)break e;if(c=l-f,r.offset>c){if((c=r.offset-c)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p=c>r.wnext?(c-=r.wnext,r.wsize-c):r.wnext-c,c>r.length&&(c=r.length),m=r.window}else m=i,p=o-r.offset,c=r.length;for(f<c&&(c=f),f-=c,r.length-=c;i[o++]=m[p++],--c;);0===r.length&&(r.mode=21);break;case 26:if(0===f)break e;i[o++]=r.length,f--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===a)break e;a--,u|=n[s++]<<d,d+=8}if(l-=f,e.total_out+=l,r.total+=l,l&&(e.adler=r.check=r.flags?D(r.check,i,l,o-l):I(r.check,i,l,o-l)),l=f,(r.flags?u:P(u))!==r.check){e.msg="incorrect data check",r.mode=30;break}d=u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;d<32;){if(0===a)break e;a--,u+=n[s++]<<d,d+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=30;break}d=u=0}r.mode=29;case 29:x=1;break e;case 30:x=-3;break e;case 31:return-4;case 32:default:return U}return e.next_out=o,e.avail_out=f,e.next_in=s,e.avail_in=a,r.hold=u,r.bits=d,(r.wsize||l!==e.avail_out&&r.mode<30&&(r.mode<27||4!==t))&&Z(e,e.output,e.next_out,l-e.avail_out)?(r.mode=31,-4):(h-=e.avail_in,l-=e.avail_out,e.total_in+=h,e.total_out+=l,r.total+=l,r.wrap&&l&&(e.adler=r.check=r.flags?D(r.check,i,l,e.next_out-l):I(r.check,i,l,e.next_out-l)),e.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0==h&&0===l||4===t)&&x===N&&(x=-5),x)},r.inflateEnd=function(e){if(!e||!e.state)return U;var t=e.state;return t.window&&(t.window=null),e.state=null,N},r.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?U:((r.head=t).done=!1,N):U},r.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?U:11===r.mode&&I(1,t,n,0)!==r.check?-3:Z(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,N):U},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,r){"use strict";var R=e("../utils/common"),F=[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],N=[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],U=[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],L=[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];t.exports=function(e,t,r,n,i,s,o,a){var f,u,d,h,l,c,p,m,_,w=a.bits,v=0,g=0,y=0,b=0,k=0,x=0,S=0,E=0,z=0,C=0,A=null,O=0,I=new R.Buf16(16),D=new R.Buf16(16),B=null,T=0;for(v=0;v<=15;v++)I[v]=0;for(g=0;g<n;g++)I[t[r+g]]++;for(k=w,b=15;1<=b&&0===I[b];b--);if(b<k&&(k=b),0===b)return i[s++]=20971520,i[s++]=20971520,a.bits=1,0;for(y=1;y<b&&0===I[y];y++);for(k<y&&(k=y),v=E=1;v<=15;v++)if(E<<=1,(E-=I[v])<0)return-1;if(0<E&&(0===e||1!==b))return-1;for(D[1]=0,v=1;v<15;v++)D[v+1]=D[v]+I[v];for(g=0;g<n;g++)0!==t[r+g]&&(o[D[t[r+g]]++]=g);if(c=0===e?(A=B=o,19):1===e?(A=F,O-=257,B=N,T-=257,256):(A=U,B=L,-1),v=y,l=s,S=g=C=0,d=-1,h=(z=1<<(x=k))-1,1===e&&852<z||2===e&&592<z)return 1;for(;;){for(p=v-S,_=o[g]<c?(m=0,o[g]):o[g]>c?(m=B[T+o[g]],A[O+o[g]]):(m=96,0),f=1<<v-S,y=u=1<<x;i[l+(C>>S)+(u-=f)]=p<<24|m<<16|_|0,0!==u;);for(f=1<<v-1;C&f;)f>>=1;if(0!==f?(C&=f-1,C+=f):C=0,g++,0==--I[v]){if(v===b)break;v=t[r+o[g]]}if(k<v&&(C&h)!==d){for(0===S&&(S=k),l+=y,E=1<<(x=v-S);x+S<b&&!((E-=I[x+S])<=0);)x++,E<<=1;if(z+=1<<x,1===e&&852<z||2===e&&592<z)return 1;i[d=C&h]=k<<24|x<<16|l-s|0}}return 0!==C&&(i[l+C]=v-S<<24|64<<16|0),a.bits=k,0}},{"../utils/common":41}],51:[function(e,t,r){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,t,r){"use strict";var a=e("../utils/common");function n(e){for(var t=e.length;0<=--t;)e[t]=0}var _=15,i=16,f=[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],u=[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],o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],d=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],h=new Array(576);n(h);var l=new Array(60);n(l);var c=new Array(512);n(c);var p=new Array(256);n(p);var m=new Array(29);n(m);var w,v,g,y=new Array(30);function b(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function s(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function k(e){return e<256?c[e]:c[256+(e>>>7)]}function x(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function S(e,t,r){e.bi_valid>i-r?(e.bi_buf|=t<<e.bi_valid&65535,x(e,e.bi_buf),e.bi_buf=t>>i-e.bi_valid,e.bi_valid+=r-i):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function E(e,t,r){S(e,r[2*t],r[2*t+1])}function z(e,t){for(var r=0;r|=1&e,e>>>=1,r<<=1,0<--t;);return r>>>1}function C(e,t,r){var n,i,s=new Array(_+1),o=0;for(n=1;n<=_;n++)s[n]=o=o+r[n-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=z(s[a]++,a))}}function A(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function O(e){8<e.bi_valid?x(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function I(e,t,r,n){var i=2*t,s=2*r;return e[i]<e[s]||e[i]===e[s]&&n[t]<=n[r]}function D(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&I(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!I(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function B(e,t,r){var n,i,s,o,a=0;if(0!==e.last_lit)for(;n=e.pending_buf[e.d_buf+2*a]<<8|e.pending_buf[e.d_buf+2*a+1],i=e.pending_buf[e.l_buf+a],a++,0===n?E(e,i,t):(E(e,(s=p[i])+256+1,t),0!==(o=f[s])&&S(e,i-=m[s],o),E(e,s=k(--n),r),0!==(o=u[s])&&S(e,n-=y[s],o)),a<e.last_lit;);E(e,256,t)}function T(e,t){var r,n,i,s=t.dyn_tree,o=t.stat_desc.static_tree,a=t.stat_desc.has_stree,f=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<f;r++)0!==s[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):s[2*r+1]=0;for(;e.heap_len<2;)s[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,a&&(e.static_len-=o[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;1<=r;r--)D(e,s,r);for(i=f;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],D(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,D(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,o,a,f=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,h=t.stat_desc.has_stree,l=t.stat_desc.extra_bits,c=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(s=0;s<=_;s++)e.bl_count[s]=0;for(f[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)p<(s=f[2*f[2*(n=e.heap[r])+1]+1]+1)&&(s=p,m++),f[2*n+1]=s,u<n||(e.bl_count[s]++,o=0,c<=n&&(o=l[n-c]),a=f[2*n],e.opt_len+=a*(s+o),h&&(e.static_len+=a*(d[2*n+1]+o)));if(0!==m){do{for(s=p-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[p]--,m-=2}while(0<m);for(s=p;0!==s;s--)for(n=e.bl_count[s];0!==n;)u<(i=e.heap[--r])||(f[2*i+1]!==s&&(e.opt_len+=(s-f[2*i+1])*f[2*i],f[2*i+1]=s),n--)}}(e,t),C(s,u,e.bl_count)}function R(e,t,r){var n,i,s=-1,o=t[1],a=0,f=7,u=4;for(0===o&&(f=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=t[2*(n+1)+1],++a<f&&i===o||(a<u?e.bl_tree[2*i]+=a:0!==i?(i!==s&&e.bl_tree[2*i]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=i,u=(a=0)===o?(f=138,3):i===o?(f=6,3):(f=7,4))}function F(e,t,r){var n,i,s=-1,o=t[1],a=0,f=7,u=4;for(0===o&&(f=138,u=3),n=0;n<=r;n++)if(i=o,o=t[2*(n+1)+1],!(++a<f&&i===o)){if(a<u)for(;E(e,i,e.bl_tree),0!=--a;);else 0!==i?(i!==s&&(E(e,i,e.bl_tree),a--),E(e,16,e.bl_tree),S(e,a-3,2)):a<=10?(E(e,17,e.bl_tree),S(e,a-3,3)):(E(e,18,e.bl_tree),S(e,a-11,7));s=i,u=(a=0)===o?(f=138,3):i===o?(f=6,3):(f=7,4)}}n(y);var N=!1;function U(e,t,r,n){var i,s,o;S(e,0+(n?1:0),3),s=t,o=r,O(i=e),x(i,o),x(i,~o),a.arraySet(i.pending_buf,i.window,s,o,i.pending),i.pending+=o}r._tr_init=function(e){N||(function(){var e,t,r,n,i,s=new Array(_+1);for(n=r=0;n<28;n++)for(m[n]=r,e=0;e<1<<f[n];e++)p[r++]=n;for(p[r-1]=n,n=i=0;n<16;n++)for(y[n]=i,e=0;e<1<<u[n];e++)c[i++]=n;for(i>>=7;n<30;n++)for(y[n]=i<<7,e=0;e<1<<u[n]-7;e++)c[256+i++]=n;for(t=0;t<=_;t++)s[t]=0;for(e=0;e<=143;)h[2*e+1]=8,e++,s[8]++;for(;e<=255;)h[2*e+1]=9,e++,s[9]++;for(;e<=279;)h[2*e+1]=7,e++,s[7]++;for(;e<=287;)h[2*e+1]=8,e++,s[8]++;for(C(h,287,s),e=0;e<30;e++)l[2*e+1]=5,l[2*e]=z(e,5);w=new b(h,f,257,286,_),v=new b(l,u,0,30,_),g=new b(new Array(0),o,0,19,7)}(),N=!0),e.l_desc=new s(e.dyn_ltree,w),e.d_desc=new s(e.dyn_dtree,v),e.bl_desc=new s(e.bl_tree,g),e.bi_buf=0,e.bi_valid=0,A(e)},r._tr_stored_block=U,r._tr_flush_block=function(e,t,r,n){var i,s,o=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),T(e,e.l_desc),T(e,e.d_desc),o=function(e){var t;for(R(e,e.dyn_ltree,e.l_desc.max_code),R(e,e.dyn_dtree,e.d_desc.max_code),T(e,e.bl_desc),t=18;3<=t&&0===e.bl_tree[2*d[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?U(e,t,r,n):4===e.strategy||s===i?(S(e,2+(n?1:0),3),B(e,h,l)):(S(e,4+(n?1:0),3),function(e,t,r,n){var i;for(S(e,t-257,5),S(e,r-1,5),S(e,n-4,4),i=0;i<n;i++)S(e,e.bl_tree[2*d[i]+1],3);F(e,e.dyn_ltree,t-1),F(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),B(e,e.dyn_ltree,e.dyn_dtree)),A(e),n&&O(e)},r._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(p[r]+256+1)]++,e.dyn_dtree[2*k(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){var t;S(e,2,3),E(e,256,h),16===(t=e).bi_valid?(x(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,t,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}]},{},[10])(10)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)});
  1892. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1), __webpack_require__(6).Buffer, __webpack_require__(10).setImmediate))
  1893. /***/ }),
  1894. /* 6 */
  1895. /***/ (function(module, exports, __webpack_require__) {
  1896. "use strict";
  1897. /* WEBPACK VAR INJECTION */(function(global) {/*!
  1898. * The buffer module from node.js, for the browser.
  1899. *
  1900. * @author Feross Aboukhadijeh <http://feross.org>
  1901. * @license MIT
  1902. */
  1903. /* eslint-disable no-proto */
  1904. var base64 = __webpack_require__(7)
  1905. var ieee754 = __webpack_require__(8)
  1906. var isArray = __webpack_require__(9)
  1907. exports.Buffer = Buffer
  1908. exports.SlowBuffer = SlowBuffer
  1909. exports.INSPECT_MAX_BYTES = 50
  1910. /**
  1911. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  1912. * === true Use Uint8Array implementation (fastest)
  1913. * === false Use Object implementation (most compatible, even IE6)
  1914. *
  1915. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  1916. * Opera 11.6+, iOS 4.2+.
  1917. *
  1918. * Due to various browser bugs, sometimes the Object implementation will be used even
  1919. * when the browser supports typed arrays.
  1920. *
  1921. * Note:
  1922. *
  1923. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  1924. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  1925. *
  1926. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  1927. *
  1928. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  1929. * incorrect length in some situations.
  1930. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  1931. * get the Object implementation, which is slower but behaves correctly.
  1932. */
  1933. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  1934. ? global.TYPED_ARRAY_SUPPORT
  1935. : typedArraySupport()
  1936. /*
  1937. * Export kMaxLength after typed array support is determined.
  1938. */
  1939. exports.kMaxLength = kMaxLength()
  1940. function typedArraySupport () {
  1941. try {
  1942. var arr = new Uint8Array(1)
  1943. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  1944. return arr.foo() === 42 && // typed array instances can be augmented
  1945. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  1946. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  1947. } catch (e) {
  1948. return false
  1949. }
  1950. }
  1951. function kMaxLength () {
  1952. return Buffer.TYPED_ARRAY_SUPPORT
  1953. ? 0x7fffffff
  1954. : 0x3fffffff
  1955. }
  1956. function createBuffer (that, length) {
  1957. if (kMaxLength() < length) {
  1958. throw new RangeError('Invalid typed array length')
  1959. }
  1960. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1961. // Return an augmented `Uint8Array` instance, for best performance
  1962. that = new Uint8Array(length)
  1963. that.__proto__ = Buffer.prototype
  1964. } else {
  1965. // Fallback: Return an object instance of the Buffer class
  1966. if (that === null) {
  1967. that = new Buffer(length)
  1968. }
  1969. that.length = length
  1970. }
  1971. return that
  1972. }
  1973. /**
  1974. * The Buffer constructor returns instances of `Uint8Array` that have their
  1975. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  1976. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  1977. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  1978. * returns a single octet.
  1979. *
  1980. * The `Uint8Array` prototype remains unmodified.
  1981. */
  1982. function Buffer (arg, encodingOrOffset, length) {
  1983. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  1984. return new Buffer(arg, encodingOrOffset, length)
  1985. }
  1986. // Common case.
  1987. if (typeof arg === 'number') {
  1988. if (typeof encodingOrOffset === 'string') {
  1989. throw new Error(
  1990. 'If encoding is specified then the first argument must be a string'
  1991. )
  1992. }
  1993. return allocUnsafe(this, arg)
  1994. }
  1995. return from(this, arg, encodingOrOffset, length)
  1996. }
  1997. Buffer.poolSize = 8192 // not used by this implementation
  1998. // TODO: Legacy, not needed anymore. Remove in next major version.
  1999. Buffer._augment = function (arr) {
  2000. arr.__proto__ = Buffer.prototype
  2001. return arr
  2002. }
  2003. function from (that, value, encodingOrOffset, length) {
  2004. if (typeof value === 'number') {
  2005. throw new TypeError('"value" argument must not be a number')
  2006. }
  2007. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  2008. return fromArrayBuffer(that, value, encodingOrOffset, length)
  2009. }
  2010. if (typeof value === 'string') {
  2011. return fromString(that, value, encodingOrOffset)
  2012. }
  2013. return fromObject(that, value)
  2014. }
  2015. /**
  2016. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  2017. * if value is a number.
  2018. * Buffer.from(str[, encoding])
  2019. * Buffer.from(array)
  2020. * Buffer.from(buffer)
  2021. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  2022. **/
  2023. Buffer.from = function (value, encodingOrOffset, length) {
  2024. return from(null, value, encodingOrOffset, length)
  2025. }
  2026. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2027. Buffer.prototype.__proto__ = Uint8Array.prototype
  2028. Buffer.__proto__ = Uint8Array
  2029. if (typeof Symbol !== 'undefined' && Symbol.species &&
  2030. Buffer[Symbol.species] === Buffer) {
  2031. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  2032. Object.defineProperty(Buffer, Symbol.species, {
  2033. value: null,
  2034. configurable: true
  2035. })
  2036. }
  2037. }
  2038. function assertSize (size) {
  2039. if (typeof size !== 'number') {
  2040. throw new TypeError('"size" argument must be a number')
  2041. } else if (size < 0) {
  2042. throw new RangeError('"size" argument must not be negative')
  2043. }
  2044. }
  2045. function alloc (that, size, fill, encoding) {
  2046. assertSize(size)
  2047. if (size <= 0) {
  2048. return createBuffer(that, size)
  2049. }
  2050. if (fill !== undefined) {
  2051. // Only pay attention to encoding if it's a string. This
  2052. // prevents accidentally sending in a number that would
  2053. // be interpretted as a start offset.
  2054. return typeof encoding === 'string'
  2055. ? createBuffer(that, size).fill(fill, encoding)
  2056. : createBuffer(that, size).fill(fill)
  2057. }
  2058. return createBuffer(that, size)
  2059. }
  2060. /**
  2061. * Creates a new filled Buffer instance.
  2062. * alloc(size[, fill[, encoding]])
  2063. **/
  2064. Buffer.alloc = function (size, fill, encoding) {
  2065. return alloc(null, size, fill, encoding)
  2066. }
  2067. function allocUnsafe (that, size) {
  2068. assertSize(size)
  2069. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  2070. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  2071. for (var i = 0; i < size; ++i) {
  2072. that[i] = 0
  2073. }
  2074. }
  2075. return that
  2076. }
  2077. /**
  2078. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  2079. * */
  2080. Buffer.allocUnsafe = function (size) {
  2081. return allocUnsafe(null, size)
  2082. }
  2083. /**
  2084. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  2085. */
  2086. Buffer.allocUnsafeSlow = function (size) {
  2087. return allocUnsafe(null, size)
  2088. }
  2089. function fromString (that, string, encoding) {
  2090. if (typeof encoding !== 'string' || encoding === '') {
  2091. encoding = 'utf8'
  2092. }
  2093. if (!Buffer.isEncoding(encoding)) {
  2094. throw new TypeError('"encoding" must be a valid string encoding')
  2095. }
  2096. var length = byteLength(string, encoding) | 0
  2097. that = createBuffer(that, length)
  2098. var actual = that.write(string, encoding)
  2099. if (actual !== length) {
  2100. // Writing a hex string, for example, that contains invalid characters will
  2101. // cause everything after the first invalid character to be ignored. (e.g.
  2102. // 'abxxcd' will be treated as 'ab')
  2103. that = that.slice(0, actual)
  2104. }
  2105. return that
  2106. }
  2107. function fromArrayLike (that, array) {
  2108. var length = array.length < 0 ? 0 : checked(array.length) | 0
  2109. that = createBuffer(that, length)
  2110. for (var i = 0; i < length; i += 1) {
  2111. that[i] = array[i] & 255
  2112. }
  2113. return that
  2114. }
  2115. function fromArrayBuffer (that, array, byteOffset, length) {
  2116. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  2117. if (byteOffset < 0 || array.byteLength < byteOffset) {
  2118. throw new RangeError('\'offset\' is out of bounds')
  2119. }
  2120. if (array.byteLength < byteOffset + (length || 0)) {
  2121. throw new RangeError('\'length\' is out of bounds')
  2122. }
  2123. if (byteOffset === undefined && length === undefined) {
  2124. array = new Uint8Array(array)
  2125. } else if (length === undefined) {
  2126. array = new Uint8Array(array, byteOffset)
  2127. } else {
  2128. array = new Uint8Array(array, byteOffset, length)
  2129. }
  2130. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2131. // Return an augmented `Uint8Array` instance, for best performance
  2132. that = array
  2133. that.__proto__ = Buffer.prototype
  2134. } else {
  2135. // Fallback: Return an object instance of the Buffer class
  2136. that = fromArrayLike(that, array)
  2137. }
  2138. return that
  2139. }
  2140. function fromObject (that, obj) {
  2141. if (Buffer.isBuffer(obj)) {
  2142. var len = checked(obj.length) | 0
  2143. that = createBuffer(that, len)
  2144. if (that.length === 0) {
  2145. return that
  2146. }
  2147. obj.copy(that, 0, 0, len)
  2148. return that
  2149. }
  2150. if (obj) {
  2151. if ((typeof ArrayBuffer !== 'undefined' &&
  2152. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  2153. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  2154. return createBuffer(that, 0)
  2155. }
  2156. return fromArrayLike(that, obj)
  2157. }
  2158. if (obj.type === 'Buffer' && isArray(obj.data)) {
  2159. return fromArrayLike(that, obj.data)
  2160. }
  2161. }
  2162. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  2163. }
  2164. function checked (length) {
  2165. // Note: cannot use `length < kMaxLength()` here because that fails when
  2166. // length is NaN (which is otherwise coerced to zero.)
  2167. if (length >= kMaxLength()) {
  2168. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  2169. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  2170. }
  2171. return length | 0
  2172. }
  2173. function SlowBuffer (length) {
  2174. if (+length != length) { // eslint-disable-line eqeqeq
  2175. length = 0
  2176. }
  2177. return Buffer.alloc(+length)
  2178. }
  2179. Buffer.isBuffer = function isBuffer (b) {
  2180. return !!(b != null && b._isBuffer)
  2181. }
  2182. Buffer.compare = function compare (a, b) {
  2183. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  2184. throw new TypeError('Arguments must be Buffers')
  2185. }
  2186. if (a === b) return 0
  2187. var x = a.length
  2188. var y = b.length
  2189. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  2190. if (a[i] !== b[i]) {
  2191. x = a[i]
  2192. y = b[i]
  2193. break
  2194. }
  2195. }
  2196. if (x < y) return -1
  2197. if (y < x) return 1
  2198. return 0
  2199. }
  2200. Buffer.isEncoding = function isEncoding (encoding) {
  2201. switch (String(encoding).toLowerCase()) {
  2202. case 'hex':
  2203. case 'utf8':
  2204. case 'utf-8':
  2205. case 'ascii':
  2206. case 'latin1':
  2207. case 'binary':
  2208. case 'base64':
  2209. case 'ucs2':
  2210. case 'ucs-2':
  2211. case 'utf16le':
  2212. case 'utf-16le':
  2213. return true
  2214. default:
  2215. return false
  2216. }
  2217. }
  2218. Buffer.concat = function concat (list, length) {
  2219. if (!isArray(list)) {
  2220. throw new TypeError('"list" argument must be an Array of Buffers')
  2221. }
  2222. if (list.length === 0) {
  2223. return Buffer.alloc(0)
  2224. }
  2225. var i
  2226. if (length === undefined) {
  2227. length = 0
  2228. for (i = 0; i < list.length; ++i) {
  2229. length += list[i].length
  2230. }
  2231. }
  2232. var buffer = Buffer.allocUnsafe(length)
  2233. var pos = 0
  2234. for (i = 0; i < list.length; ++i) {
  2235. var buf = list[i]
  2236. if (!Buffer.isBuffer(buf)) {
  2237. throw new TypeError('"list" argument must be an Array of Buffers')
  2238. }
  2239. buf.copy(buffer, pos)
  2240. pos += buf.length
  2241. }
  2242. return buffer
  2243. }
  2244. function byteLength (string, encoding) {
  2245. if (Buffer.isBuffer(string)) {
  2246. return string.length
  2247. }
  2248. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  2249. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  2250. return string.byteLength
  2251. }
  2252. if (typeof string !== 'string') {
  2253. string = '' + string
  2254. }
  2255. var len = string.length
  2256. if (len === 0) return 0
  2257. // Use a for loop to avoid recursion
  2258. var loweredCase = false
  2259. for (;;) {
  2260. switch (encoding) {
  2261. case 'ascii':
  2262. case 'latin1':
  2263. case 'binary':
  2264. return len
  2265. case 'utf8':
  2266. case 'utf-8':
  2267. case undefined:
  2268. return utf8ToBytes(string).length
  2269. case 'ucs2':
  2270. case 'ucs-2':
  2271. case 'utf16le':
  2272. case 'utf-16le':
  2273. return len * 2
  2274. case 'hex':
  2275. return len >>> 1
  2276. case 'base64':
  2277. return base64ToBytes(string).length
  2278. default:
  2279. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  2280. encoding = ('' + encoding).toLowerCase()
  2281. loweredCase = true
  2282. }
  2283. }
  2284. }
  2285. Buffer.byteLength = byteLength
  2286. function slowToString (encoding, start, end) {
  2287. var loweredCase = false
  2288. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  2289. // property of a typed array.
  2290. // This behaves neither like String nor Uint8Array in that we set start/end
  2291. // to their upper/lower bounds if the value passed is out of range.
  2292. // undefined is handled specially as per ECMA-262 6th Edition,
  2293. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  2294. if (start === undefined || start < 0) {
  2295. start = 0
  2296. }
  2297. // Return early if start > this.length. Done here to prevent potential uint32
  2298. // coercion fail below.
  2299. if (start > this.length) {
  2300. return ''
  2301. }
  2302. if (end === undefined || end > this.length) {
  2303. end = this.length
  2304. }
  2305. if (end <= 0) {
  2306. return ''
  2307. }
  2308. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  2309. end >>>= 0
  2310. start >>>= 0
  2311. if (end <= start) {
  2312. return ''
  2313. }
  2314. if (!encoding) encoding = 'utf8'
  2315. while (true) {
  2316. switch (encoding) {
  2317. case 'hex':
  2318. return hexSlice(this, start, end)
  2319. case 'utf8':
  2320. case 'utf-8':
  2321. return utf8Slice(this, start, end)
  2322. case 'ascii':
  2323. return asciiSlice(this, start, end)
  2324. case 'latin1':
  2325. case 'binary':
  2326. return latin1Slice(this, start, end)
  2327. case 'base64':
  2328. return base64Slice(this, start, end)
  2329. case 'ucs2':
  2330. case 'ucs-2':
  2331. case 'utf16le':
  2332. case 'utf-16le':
  2333. return utf16leSlice(this, start, end)
  2334. default:
  2335. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  2336. encoding = (encoding + '').toLowerCase()
  2337. loweredCase = true
  2338. }
  2339. }
  2340. }
  2341. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  2342. // Buffer instances.
  2343. Buffer.prototype._isBuffer = true
  2344. function swap (b, n, m) {
  2345. var i = b[n]
  2346. b[n] = b[m]
  2347. b[m] = i
  2348. }
  2349. Buffer.prototype.swap16 = function swap16 () {
  2350. var len = this.length
  2351. if (len % 2 !== 0) {
  2352. throw new RangeError('Buffer size must be a multiple of 16-bits')
  2353. }
  2354. for (var i = 0; i < len; i += 2) {
  2355. swap(this, i, i + 1)
  2356. }
  2357. return this
  2358. }
  2359. Buffer.prototype.swap32 = function swap32 () {
  2360. var len = this.length
  2361. if (len % 4 !== 0) {
  2362. throw new RangeError('Buffer size must be a multiple of 32-bits')
  2363. }
  2364. for (var i = 0; i < len; i += 4) {
  2365. swap(this, i, i + 3)
  2366. swap(this, i + 1, i + 2)
  2367. }
  2368. return this
  2369. }
  2370. Buffer.prototype.swap64 = function swap64 () {
  2371. var len = this.length
  2372. if (len % 8 !== 0) {
  2373. throw new RangeError('Buffer size must be a multiple of 64-bits')
  2374. }
  2375. for (var i = 0; i < len; i += 8) {
  2376. swap(this, i, i + 7)
  2377. swap(this, i + 1, i + 6)
  2378. swap(this, i + 2, i + 5)
  2379. swap(this, i + 3, i + 4)
  2380. }
  2381. return this
  2382. }
  2383. Buffer.prototype.toString = function toString () {
  2384. var length = this.length | 0
  2385. if (length === 0) return ''
  2386. if (arguments.length === 0) return utf8Slice(this, 0, length)
  2387. return slowToString.apply(this, arguments)
  2388. }
  2389. Buffer.prototype.equals = function equals (b) {
  2390. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  2391. if (this === b) return true
  2392. return Buffer.compare(this, b) === 0
  2393. }
  2394. Buffer.prototype.inspect = function inspect () {
  2395. var str = ''
  2396. var max = exports.INSPECT_MAX_BYTES
  2397. if (this.length > 0) {
  2398. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  2399. if (this.length > max) str += ' ... '
  2400. }
  2401. return '<Buffer ' + str + '>'
  2402. }
  2403. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  2404. if (!Buffer.isBuffer(target)) {
  2405. throw new TypeError('Argument must be a Buffer')
  2406. }
  2407. if (start === undefined) {
  2408. start = 0
  2409. }
  2410. if (end === undefined) {
  2411. end = target ? target.length : 0
  2412. }
  2413. if (thisStart === undefined) {
  2414. thisStart = 0
  2415. }
  2416. if (thisEnd === undefined) {
  2417. thisEnd = this.length
  2418. }
  2419. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  2420. throw new RangeError('out of range index')
  2421. }
  2422. if (thisStart >= thisEnd && start >= end) {
  2423. return 0
  2424. }
  2425. if (thisStart >= thisEnd) {
  2426. return -1
  2427. }
  2428. if (start >= end) {
  2429. return 1
  2430. }
  2431. start >>>= 0
  2432. end >>>= 0
  2433. thisStart >>>= 0
  2434. thisEnd >>>= 0
  2435. if (this === target) return 0
  2436. var x = thisEnd - thisStart
  2437. var y = end - start
  2438. var len = Math.min(x, y)
  2439. var thisCopy = this.slice(thisStart, thisEnd)
  2440. var targetCopy = target.slice(start, end)
  2441. for (var i = 0; i < len; ++i) {
  2442. if (thisCopy[i] !== targetCopy[i]) {
  2443. x = thisCopy[i]
  2444. y = targetCopy[i]
  2445. break
  2446. }
  2447. }
  2448. if (x < y) return -1
  2449. if (y < x) return 1
  2450. return 0
  2451. }
  2452. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  2453. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  2454. //
  2455. // Arguments:
  2456. // - buffer - a Buffer to search
  2457. // - val - a string, Buffer, or number
  2458. // - byteOffset - an index into `buffer`; will be clamped to an int32
  2459. // - encoding - an optional encoding, relevant is val is a string
  2460. // - dir - true for indexOf, false for lastIndexOf
  2461. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  2462. // Empty buffer means no match
  2463. if (buffer.length === 0) return -1
  2464. // Normalize byteOffset
  2465. if (typeof byteOffset === 'string') {
  2466. encoding = byteOffset
  2467. byteOffset = 0
  2468. } else if (byteOffset > 0x7fffffff) {
  2469. byteOffset = 0x7fffffff
  2470. } else if (byteOffset < -0x80000000) {
  2471. byteOffset = -0x80000000
  2472. }
  2473. byteOffset = +byteOffset // Coerce to Number.
  2474. if (isNaN(byteOffset)) {
  2475. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  2476. byteOffset = dir ? 0 : (buffer.length - 1)
  2477. }
  2478. // Normalize byteOffset: negative offsets start from the end of the buffer
  2479. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  2480. if (byteOffset >= buffer.length) {
  2481. if (dir) return -1
  2482. else byteOffset = buffer.length - 1
  2483. } else if (byteOffset < 0) {
  2484. if (dir) byteOffset = 0
  2485. else return -1
  2486. }
  2487. // Normalize val
  2488. if (typeof val === 'string') {
  2489. val = Buffer.from(val, encoding)
  2490. }
  2491. // Finally, search either indexOf (if dir is true) or lastIndexOf
  2492. if (Buffer.isBuffer(val)) {
  2493. // Special case: looking for empty string/buffer always fails
  2494. if (val.length === 0) {
  2495. return -1
  2496. }
  2497. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  2498. } else if (typeof val === 'number') {
  2499. val = val & 0xFF // Search for a byte value [0-255]
  2500. if (Buffer.TYPED_ARRAY_SUPPORT &&
  2501. typeof Uint8Array.prototype.indexOf === 'function') {
  2502. if (dir) {
  2503. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  2504. } else {
  2505. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  2506. }
  2507. }
  2508. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  2509. }
  2510. throw new TypeError('val must be string, number or Buffer')
  2511. }
  2512. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  2513. var indexSize = 1
  2514. var arrLength = arr.length
  2515. var valLength = val.length
  2516. if (encoding !== undefined) {
  2517. encoding = String(encoding).toLowerCase()
  2518. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  2519. encoding === 'utf16le' || encoding === 'utf-16le') {
  2520. if (arr.length < 2 || val.length < 2) {
  2521. return -1
  2522. }
  2523. indexSize = 2
  2524. arrLength /= 2
  2525. valLength /= 2
  2526. byteOffset /= 2
  2527. }
  2528. }
  2529. function read (buf, i) {
  2530. if (indexSize === 1) {
  2531. return buf[i]
  2532. } else {
  2533. return buf.readUInt16BE(i * indexSize)
  2534. }
  2535. }
  2536. var i
  2537. if (dir) {
  2538. var foundIndex = -1
  2539. for (i = byteOffset; i < arrLength; i++) {
  2540. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  2541. if (foundIndex === -1) foundIndex = i
  2542. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  2543. } else {
  2544. if (foundIndex !== -1) i -= i - foundIndex
  2545. foundIndex = -1
  2546. }
  2547. }
  2548. } else {
  2549. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  2550. for (i = byteOffset; i >= 0; i--) {
  2551. var found = true
  2552. for (var j = 0; j < valLength; j++) {
  2553. if (read(arr, i + j) !== read(val, j)) {
  2554. found = false
  2555. break
  2556. }
  2557. }
  2558. if (found) return i
  2559. }
  2560. }
  2561. return -1
  2562. }
  2563. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  2564. return this.indexOf(val, byteOffset, encoding) !== -1
  2565. }
  2566. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  2567. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  2568. }
  2569. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  2570. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  2571. }
  2572. function hexWrite (buf, string, offset, length) {
  2573. offset = Number(offset) || 0
  2574. var remaining = buf.length - offset
  2575. if (!length) {
  2576. length = remaining
  2577. } else {
  2578. length = Number(length)
  2579. if (length > remaining) {
  2580. length = remaining
  2581. }
  2582. }
  2583. // must be an even number of digits
  2584. var strLen = string.length
  2585. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  2586. if (length > strLen / 2) {
  2587. length = strLen / 2
  2588. }
  2589. for (var i = 0; i < length; ++i) {
  2590. var parsed = parseInt(string.substr(i * 2, 2), 16)
  2591. if (isNaN(parsed)) return i
  2592. buf[offset + i] = parsed
  2593. }
  2594. return i
  2595. }
  2596. function utf8Write (buf, string, offset, length) {
  2597. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  2598. }
  2599. function asciiWrite (buf, string, offset, length) {
  2600. return blitBuffer(asciiToBytes(string), buf, offset, length)
  2601. }
  2602. function latin1Write (buf, string, offset, length) {
  2603. return asciiWrite(buf, string, offset, length)
  2604. }
  2605. function base64Write (buf, string, offset, length) {
  2606. return blitBuffer(base64ToBytes(string), buf, offset, length)
  2607. }
  2608. function ucs2Write (buf, string, offset, length) {
  2609. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  2610. }
  2611. Buffer.prototype.write = function write (string, offset, length, encoding) {
  2612. // Buffer#write(string)
  2613. if (offset === undefined) {
  2614. encoding = 'utf8'
  2615. length = this.length
  2616. offset = 0
  2617. // Buffer#write(string, encoding)
  2618. } else if (length === undefined && typeof offset === 'string') {
  2619. encoding = offset
  2620. length = this.length
  2621. offset = 0
  2622. // Buffer#write(string, offset[, length][, encoding])
  2623. } else if (isFinite(offset)) {
  2624. offset = offset | 0
  2625. if (isFinite(length)) {
  2626. length = length | 0
  2627. if (encoding === undefined) encoding = 'utf8'
  2628. } else {
  2629. encoding = length
  2630. length = undefined
  2631. }
  2632. // legacy write(string, encoding, offset, length) - remove in v0.13
  2633. } else {
  2634. throw new Error(
  2635. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  2636. )
  2637. }
  2638. var remaining = this.length - offset
  2639. if (length === undefined || length > remaining) length = remaining
  2640. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  2641. throw new RangeError('Attempt to write outside buffer bounds')
  2642. }
  2643. if (!encoding) encoding = 'utf8'
  2644. var loweredCase = false
  2645. for (;;) {
  2646. switch (encoding) {
  2647. case 'hex':
  2648. return hexWrite(this, string, offset, length)
  2649. case 'utf8':
  2650. case 'utf-8':
  2651. return utf8Write(this, string, offset, length)
  2652. case 'ascii':
  2653. return asciiWrite(this, string, offset, length)
  2654. case 'latin1':
  2655. case 'binary':
  2656. return latin1Write(this, string, offset, length)
  2657. case 'base64':
  2658. // Warning: maxLength not taken into account in base64Write
  2659. return base64Write(this, string, offset, length)
  2660. case 'ucs2':
  2661. case 'ucs-2':
  2662. case 'utf16le':
  2663. case 'utf-16le':
  2664. return ucs2Write(this, string, offset, length)
  2665. default:
  2666. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  2667. encoding = ('' + encoding).toLowerCase()
  2668. loweredCase = true
  2669. }
  2670. }
  2671. }
  2672. Buffer.prototype.toJSON = function toJSON () {
  2673. return {
  2674. type: 'Buffer',
  2675. data: Array.prototype.slice.call(this._arr || this, 0)
  2676. }
  2677. }
  2678. function base64Slice (buf, start, end) {
  2679. if (start === 0 && end === buf.length) {
  2680. return base64.fromByteArray(buf)
  2681. } else {
  2682. return base64.fromByteArray(buf.slice(start, end))
  2683. }
  2684. }
  2685. function utf8Slice (buf, start, end) {
  2686. end = Math.min(buf.length, end)
  2687. var res = []
  2688. var i = start
  2689. while (i < end) {
  2690. var firstByte = buf[i]
  2691. var codePoint = null
  2692. var bytesPerSequence = (firstByte > 0xEF) ? 4
  2693. : (firstByte > 0xDF) ? 3
  2694. : (firstByte > 0xBF) ? 2
  2695. : 1
  2696. if (i + bytesPerSequence <= end) {
  2697. var secondByte, thirdByte, fourthByte, tempCodePoint
  2698. switch (bytesPerSequence) {
  2699. case 1:
  2700. if (firstByte < 0x80) {
  2701. codePoint = firstByte
  2702. }
  2703. break
  2704. case 2:
  2705. secondByte = buf[i + 1]
  2706. if ((secondByte & 0xC0) === 0x80) {
  2707. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  2708. if (tempCodePoint > 0x7F) {
  2709. codePoint = tempCodePoint
  2710. }
  2711. }
  2712. break
  2713. case 3:
  2714. secondByte = buf[i + 1]
  2715. thirdByte = buf[i + 2]
  2716. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  2717. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  2718. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  2719. codePoint = tempCodePoint
  2720. }
  2721. }
  2722. break
  2723. case 4:
  2724. secondByte = buf[i + 1]
  2725. thirdByte = buf[i + 2]
  2726. fourthByte = buf[i + 3]
  2727. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  2728. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  2729. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  2730. codePoint = tempCodePoint
  2731. }
  2732. }
  2733. }
  2734. }
  2735. if (codePoint === null) {
  2736. // we did not generate a valid codePoint so insert a
  2737. // replacement char (U+FFFD) and advance only 1 byte
  2738. codePoint = 0xFFFD
  2739. bytesPerSequence = 1
  2740. } else if (codePoint > 0xFFFF) {
  2741. // encode to utf16 (surrogate pair dance)
  2742. codePoint -= 0x10000
  2743. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  2744. codePoint = 0xDC00 | codePoint & 0x3FF
  2745. }
  2746. res.push(codePoint)
  2747. i += bytesPerSequence
  2748. }
  2749. return decodeCodePointsArray(res)
  2750. }
  2751. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  2752. // the lowest limit is Chrome, with 0x10000 args.
  2753. // We go 1 magnitude less, for safety
  2754. var MAX_ARGUMENTS_LENGTH = 0x1000
  2755. function decodeCodePointsArray (codePoints) {
  2756. var len = codePoints.length
  2757. if (len <= MAX_ARGUMENTS_LENGTH) {
  2758. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  2759. }
  2760. // Decode in chunks to avoid "call stack size exceeded".
  2761. var res = ''
  2762. var i = 0
  2763. while (i < len) {
  2764. res += String.fromCharCode.apply(
  2765. String,
  2766. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  2767. )
  2768. }
  2769. return res
  2770. }
  2771. function asciiSlice (buf, start, end) {
  2772. var ret = ''
  2773. end = Math.min(buf.length, end)
  2774. for (var i = start; i < end; ++i) {
  2775. ret += String.fromCharCode(buf[i] & 0x7F)
  2776. }
  2777. return ret
  2778. }
  2779. function latin1Slice (buf, start, end) {
  2780. var ret = ''
  2781. end = Math.min(buf.length, end)
  2782. for (var i = start; i < end; ++i) {
  2783. ret += String.fromCharCode(buf[i])
  2784. }
  2785. return ret
  2786. }
  2787. function hexSlice (buf, start, end) {
  2788. var len = buf.length
  2789. if (!start || start < 0) start = 0
  2790. if (!end || end < 0 || end > len) end = len
  2791. var out = ''
  2792. for (var i = start; i < end; ++i) {
  2793. out += toHex(buf[i])
  2794. }
  2795. return out
  2796. }
  2797. function utf16leSlice (buf, start, end) {
  2798. var bytes = buf.slice(start, end)
  2799. var res = ''
  2800. for (var i = 0; i < bytes.length; i += 2) {
  2801. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  2802. }
  2803. return res
  2804. }
  2805. Buffer.prototype.slice = function slice (start, end) {
  2806. var len = this.length
  2807. start = ~~start
  2808. end = end === undefined ? len : ~~end
  2809. if (start < 0) {
  2810. start += len
  2811. if (start < 0) start = 0
  2812. } else if (start > len) {
  2813. start = len
  2814. }
  2815. if (end < 0) {
  2816. end += len
  2817. if (end < 0) end = 0
  2818. } else if (end > len) {
  2819. end = len
  2820. }
  2821. if (end < start) end = start
  2822. var newBuf
  2823. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2824. newBuf = this.subarray(start, end)
  2825. newBuf.__proto__ = Buffer.prototype
  2826. } else {
  2827. var sliceLen = end - start
  2828. newBuf = new Buffer(sliceLen, undefined)
  2829. for (var i = 0; i < sliceLen; ++i) {
  2830. newBuf[i] = this[i + start]
  2831. }
  2832. }
  2833. return newBuf
  2834. }
  2835. /*
  2836. * Need to make sure that buffer isn't trying to write out of bounds.
  2837. */
  2838. function checkOffset (offset, ext, length) {
  2839. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  2840. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  2841. }
  2842. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  2843. offset = offset | 0
  2844. byteLength = byteLength | 0
  2845. if (!noAssert) checkOffset(offset, byteLength, this.length)
  2846. var val = this[offset]
  2847. var mul = 1
  2848. var i = 0
  2849. while (++i < byteLength && (mul *= 0x100)) {
  2850. val += this[offset + i] * mul
  2851. }
  2852. return val
  2853. }
  2854. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  2855. offset = offset | 0
  2856. byteLength = byteLength | 0
  2857. if (!noAssert) {
  2858. checkOffset(offset, byteLength, this.length)
  2859. }
  2860. var val = this[offset + --byteLength]
  2861. var mul = 1
  2862. while (byteLength > 0 && (mul *= 0x100)) {
  2863. val += this[offset + --byteLength] * mul
  2864. }
  2865. return val
  2866. }
  2867. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  2868. if (!noAssert) checkOffset(offset, 1, this.length)
  2869. return this[offset]
  2870. }
  2871. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  2872. if (!noAssert) checkOffset(offset, 2, this.length)
  2873. return this[offset] | (this[offset + 1] << 8)
  2874. }
  2875. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  2876. if (!noAssert) checkOffset(offset, 2, this.length)
  2877. return (this[offset] << 8) | this[offset + 1]
  2878. }
  2879. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  2880. if (!noAssert) checkOffset(offset, 4, this.length)
  2881. return ((this[offset]) |
  2882. (this[offset + 1] << 8) |
  2883. (this[offset + 2] << 16)) +
  2884. (this[offset + 3] * 0x1000000)
  2885. }
  2886. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  2887. if (!noAssert) checkOffset(offset, 4, this.length)
  2888. return (this[offset] * 0x1000000) +
  2889. ((this[offset + 1] << 16) |
  2890. (this[offset + 2] << 8) |
  2891. this[offset + 3])
  2892. }
  2893. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  2894. offset = offset | 0
  2895. byteLength = byteLength | 0
  2896. if (!noAssert) checkOffset(offset, byteLength, this.length)
  2897. var val = this[offset]
  2898. var mul = 1
  2899. var i = 0
  2900. while (++i < byteLength && (mul *= 0x100)) {
  2901. val += this[offset + i] * mul
  2902. }
  2903. mul *= 0x80
  2904. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  2905. return val
  2906. }
  2907. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  2908. offset = offset | 0
  2909. byteLength = byteLength | 0
  2910. if (!noAssert) checkOffset(offset, byteLength, this.length)
  2911. var i = byteLength
  2912. var mul = 1
  2913. var val = this[offset + --i]
  2914. while (i > 0 && (mul *= 0x100)) {
  2915. val += this[offset + --i] * mul
  2916. }
  2917. mul *= 0x80
  2918. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  2919. return val
  2920. }
  2921. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  2922. if (!noAssert) checkOffset(offset, 1, this.length)
  2923. if (!(this[offset] & 0x80)) return (this[offset])
  2924. return ((0xff - this[offset] + 1) * -1)
  2925. }
  2926. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  2927. if (!noAssert) checkOffset(offset, 2, this.length)
  2928. var val = this[offset] | (this[offset + 1] << 8)
  2929. return (val & 0x8000) ? val | 0xFFFF0000 : val
  2930. }
  2931. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  2932. if (!noAssert) checkOffset(offset, 2, this.length)
  2933. var val = this[offset + 1] | (this[offset] << 8)
  2934. return (val & 0x8000) ? val | 0xFFFF0000 : val
  2935. }
  2936. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  2937. if (!noAssert) checkOffset(offset, 4, this.length)
  2938. return (this[offset]) |
  2939. (this[offset + 1] << 8) |
  2940. (this[offset + 2] << 16) |
  2941. (this[offset + 3] << 24)
  2942. }
  2943. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  2944. if (!noAssert) checkOffset(offset, 4, this.length)
  2945. return (this[offset] << 24) |
  2946. (this[offset + 1] << 16) |
  2947. (this[offset + 2] << 8) |
  2948. (this[offset + 3])
  2949. }
  2950. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  2951. if (!noAssert) checkOffset(offset, 4, this.length)
  2952. return ieee754.read(this, offset, true, 23, 4)
  2953. }
  2954. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  2955. if (!noAssert) checkOffset(offset, 4, this.length)
  2956. return ieee754.read(this, offset, false, 23, 4)
  2957. }
  2958. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  2959. if (!noAssert) checkOffset(offset, 8, this.length)
  2960. return ieee754.read(this, offset, true, 52, 8)
  2961. }
  2962. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  2963. if (!noAssert) checkOffset(offset, 8, this.length)
  2964. return ieee754.read(this, offset, false, 52, 8)
  2965. }
  2966. function checkInt (buf, value, offset, ext, max, min) {
  2967. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  2968. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  2969. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  2970. }
  2971. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  2972. value = +value
  2973. offset = offset | 0
  2974. byteLength = byteLength | 0
  2975. if (!noAssert) {
  2976. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  2977. checkInt(this, value, offset, byteLength, maxBytes, 0)
  2978. }
  2979. var mul = 1
  2980. var i = 0
  2981. this[offset] = value & 0xFF
  2982. while (++i < byteLength && (mul *= 0x100)) {
  2983. this[offset + i] = (value / mul) & 0xFF
  2984. }
  2985. return offset + byteLength
  2986. }
  2987. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  2988. value = +value
  2989. offset = offset | 0
  2990. byteLength = byteLength | 0
  2991. if (!noAssert) {
  2992. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  2993. checkInt(this, value, offset, byteLength, maxBytes, 0)
  2994. }
  2995. var i = byteLength - 1
  2996. var mul = 1
  2997. this[offset + i] = value & 0xFF
  2998. while (--i >= 0 && (mul *= 0x100)) {
  2999. this[offset + i] = (value / mul) & 0xFF
  3000. }
  3001. return offset + byteLength
  3002. }
  3003. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  3004. value = +value
  3005. offset = offset | 0
  3006. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  3007. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  3008. this[offset] = (value & 0xff)
  3009. return offset + 1
  3010. }
  3011. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  3012. if (value < 0) value = 0xffff + value + 1
  3013. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  3014. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  3015. (littleEndian ? i : 1 - i) * 8
  3016. }
  3017. }
  3018. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  3019. value = +value
  3020. offset = offset | 0
  3021. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  3022. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3023. this[offset] = (value & 0xff)
  3024. this[offset + 1] = (value >>> 8)
  3025. } else {
  3026. objectWriteUInt16(this, value, offset, true)
  3027. }
  3028. return offset + 2
  3029. }
  3030. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  3031. value = +value
  3032. offset = offset | 0
  3033. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  3034. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3035. this[offset] = (value >>> 8)
  3036. this[offset + 1] = (value & 0xff)
  3037. } else {
  3038. objectWriteUInt16(this, value, offset, false)
  3039. }
  3040. return offset + 2
  3041. }
  3042. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  3043. if (value < 0) value = 0xffffffff + value + 1
  3044. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  3045. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  3046. }
  3047. }
  3048. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  3049. value = +value
  3050. offset = offset | 0
  3051. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  3052. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3053. this[offset + 3] = (value >>> 24)
  3054. this[offset + 2] = (value >>> 16)
  3055. this[offset + 1] = (value >>> 8)
  3056. this[offset] = (value & 0xff)
  3057. } else {
  3058. objectWriteUInt32(this, value, offset, true)
  3059. }
  3060. return offset + 4
  3061. }
  3062. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  3063. value = +value
  3064. offset = offset | 0
  3065. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  3066. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3067. this[offset] = (value >>> 24)
  3068. this[offset + 1] = (value >>> 16)
  3069. this[offset + 2] = (value >>> 8)
  3070. this[offset + 3] = (value & 0xff)
  3071. } else {
  3072. objectWriteUInt32(this, value, offset, false)
  3073. }
  3074. return offset + 4
  3075. }
  3076. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  3077. value = +value
  3078. offset = offset | 0
  3079. if (!noAssert) {
  3080. var limit = Math.pow(2, 8 * byteLength - 1)
  3081. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  3082. }
  3083. var i = 0
  3084. var mul = 1
  3085. var sub = 0
  3086. this[offset] = value & 0xFF
  3087. while (++i < byteLength && (mul *= 0x100)) {
  3088. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  3089. sub = 1
  3090. }
  3091. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  3092. }
  3093. return offset + byteLength
  3094. }
  3095. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  3096. value = +value
  3097. offset = offset | 0
  3098. if (!noAssert) {
  3099. var limit = Math.pow(2, 8 * byteLength - 1)
  3100. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  3101. }
  3102. var i = byteLength - 1
  3103. var mul = 1
  3104. var sub = 0
  3105. this[offset + i] = value & 0xFF
  3106. while (--i >= 0 && (mul *= 0x100)) {
  3107. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  3108. sub = 1
  3109. }
  3110. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  3111. }
  3112. return offset + byteLength
  3113. }
  3114. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  3115. value = +value
  3116. offset = offset | 0
  3117. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  3118. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  3119. if (value < 0) value = 0xff + value + 1
  3120. this[offset] = (value & 0xff)
  3121. return offset + 1
  3122. }
  3123. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  3124. value = +value
  3125. offset = offset | 0
  3126. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  3127. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3128. this[offset] = (value & 0xff)
  3129. this[offset + 1] = (value >>> 8)
  3130. } else {
  3131. objectWriteUInt16(this, value, offset, true)
  3132. }
  3133. return offset + 2
  3134. }
  3135. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  3136. value = +value
  3137. offset = offset | 0
  3138. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  3139. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3140. this[offset] = (value >>> 8)
  3141. this[offset + 1] = (value & 0xff)
  3142. } else {
  3143. objectWriteUInt16(this, value, offset, false)
  3144. }
  3145. return offset + 2
  3146. }
  3147. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  3148. value = +value
  3149. offset = offset | 0
  3150. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  3151. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3152. this[offset] = (value & 0xff)
  3153. this[offset + 1] = (value >>> 8)
  3154. this[offset + 2] = (value >>> 16)
  3155. this[offset + 3] = (value >>> 24)
  3156. } else {
  3157. objectWriteUInt32(this, value, offset, true)
  3158. }
  3159. return offset + 4
  3160. }
  3161. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  3162. value = +value
  3163. offset = offset | 0
  3164. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  3165. if (value < 0) value = 0xffffffff + value + 1
  3166. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3167. this[offset] = (value >>> 24)
  3168. this[offset + 1] = (value >>> 16)
  3169. this[offset + 2] = (value >>> 8)
  3170. this[offset + 3] = (value & 0xff)
  3171. } else {
  3172. objectWriteUInt32(this, value, offset, false)
  3173. }
  3174. return offset + 4
  3175. }
  3176. function checkIEEE754 (buf, value, offset, ext, max, min) {
  3177. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  3178. if (offset < 0) throw new RangeError('Index out of range')
  3179. }
  3180. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  3181. if (!noAssert) {
  3182. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  3183. }
  3184. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  3185. return offset + 4
  3186. }
  3187. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  3188. return writeFloat(this, value, offset, true, noAssert)
  3189. }
  3190. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  3191. return writeFloat(this, value, offset, false, noAssert)
  3192. }
  3193. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  3194. if (!noAssert) {
  3195. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  3196. }
  3197. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  3198. return offset + 8
  3199. }
  3200. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  3201. return writeDouble(this, value, offset, true, noAssert)
  3202. }
  3203. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  3204. return writeDouble(this, value, offset, false, noAssert)
  3205. }
  3206. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  3207. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  3208. if (!start) start = 0
  3209. if (!end && end !== 0) end = this.length
  3210. if (targetStart >= target.length) targetStart = target.length
  3211. if (!targetStart) targetStart = 0
  3212. if (end > 0 && end < start) end = start
  3213. // Copy 0 bytes; we're done
  3214. if (end === start) return 0
  3215. if (target.length === 0 || this.length === 0) return 0
  3216. // Fatal error conditions
  3217. if (targetStart < 0) {
  3218. throw new RangeError('targetStart out of bounds')
  3219. }
  3220. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  3221. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  3222. // Are we oob?
  3223. if (end > this.length) end = this.length
  3224. if (target.length - targetStart < end - start) {
  3225. end = target.length - targetStart + start
  3226. }
  3227. var len = end - start
  3228. var i
  3229. if (this === target && start < targetStart && targetStart < end) {
  3230. // descending copy from end
  3231. for (i = len - 1; i >= 0; --i) {
  3232. target[i + targetStart] = this[i + start]
  3233. }
  3234. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  3235. // ascending copy from start
  3236. for (i = 0; i < len; ++i) {
  3237. target[i + targetStart] = this[i + start]
  3238. }
  3239. } else {
  3240. Uint8Array.prototype.set.call(
  3241. target,
  3242. this.subarray(start, start + len),
  3243. targetStart
  3244. )
  3245. }
  3246. return len
  3247. }
  3248. // Usage:
  3249. // buffer.fill(number[, offset[, end]])
  3250. // buffer.fill(buffer[, offset[, end]])
  3251. // buffer.fill(string[, offset[, end]][, encoding])
  3252. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  3253. // Handle string cases:
  3254. if (typeof val === 'string') {
  3255. if (typeof start === 'string') {
  3256. encoding = start
  3257. start = 0
  3258. end = this.length
  3259. } else if (typeof end === 'string') {
  3260. encoding = end
  3261. end = this.length
  3262. }
  3263. if (val.length === 1) {
  3264. var code = val.charCodeAt(0)
  3265. if (code < 256) {
  3266. val = code
  3267. }
  3268. }
  3269. if (encoding !== undefined && typeof encoding !== 'string') {
  3270. throw new TypeError('encoding must be a string')
  3271. }
  3272. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  3273. throw new TypeError('Unknown encoding: ' + encoding)
  3274. }
  3275. } else if (typeof val === 'number') {
  3276. val = val & 255
  3277. }
  3278. // Invalid ranges are not set to a default, so can range check early.
  3279. if (start < 0 || this.length < start || this.length < end) {
  3280. throw new RangeError('Out of range index')
  3281. }
  3282. if (end <= start) {
  3283. return this
  3284. }
  3285. start = start >>> 0
  3286. end = end === undefined ? this.length : end >>> 0
  3287. if (!val) val = 0
  3288. var i
  3289. if (typeof val === 'number') {
  3290. for (i = start; i < end; ++i) {
  3291. this[i] = val
  3292. }
  3293. } else {
  3294. var bytes = Buffer.isBuffer(val)
  3295. ? val
  3296. : utf8ToBytes(new Buffer(val, encoding).toString())
  3297. var len = bytes.length
  3298. for (i = 0; i < end - start; ++i) {
  3299. this[i + start] = bytes[i % len]
  3300. }
  3301. }
  3302. return this
  3303. }
  3304. // HELPER FUNCTIONS
  3305. // ================
  3306. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  3307. function base64clean (str) {
  3308. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  3309. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  3310. // Node converts strings with length < 2 to ''
  3311. if (str.length < 2) return ''
  3312. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  3313. while (str.length % 4 !== 0) {
  3314. str = str + '='
  3315. }
  3316. return str
  3317. }
  3318. function stringtrim (str) {
  3319. if (str.trim) return str.trim()
  3320. return str.replace(/^\s+|\s+$/g, '')
  3321. }
  3322. function toHex (n) {
  3323. if (n < 16) return '0' + n.toString(16)
  3324. return n.toString(16)
  3325. }
  3326. function utf8ToBytes (string, units) {
  3327. units = units || Infinity
  3328. var codePoint
  3329. var length = string.length
  3330. var leadSurrogate = null
  3331. var bytes = []
  3332. for (var i = 0; i < length; ++i) {
  3333. codePoint = string.charCodeAt(i)
  3334. // is surrogate component
  3335. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  3336. // last char was a lead
  3337. if (!leadSurrogate) {
  3338. // no lead yet
  3339. if (codePoint > 0xDBFF) {
  3340. // unexpected trail
  3341. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  3342. continue
  3343. } else if (i + 1 === length) {
  3344. // unpaired lead
  3345. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  3346. continue
  3347. }
  3348. // valid lead
  3349. leadSurrogate = codePoint
  3350. continue
  3351. }
  3352. // 2 leads in a row
  3353. if (codePoint < 0xDC00) {
  3354. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  3355. leadSurrogate = codePoint
  3356. continue
  3357. }
  3358. // valid surrogate pair
  3359. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  3360. } else if (leadSurrogate) {
  3361. // valid bmp char, but last char was a lead
  3362. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  3363. }
  3364. leadSurrogate = null
  3365. // encode utf8
  3366. if (codePoint < 0x80) {
  3367. if ((units -= 1) < 0) break
  3368. bytes.push(codePoint)
  3369. } else if (codePoint < 0x800) {
  3370. if ((units -= 2) < 0) break
  3371. bytes.push(
  3372. codePoint >> 0x6 | 0xC0,
  3373. codePoint & 0x3F | 0x80
  3374. )
  3375. } else if (codePoint < 0x10000) {
  3376. if ((units -= 3) < 0) break
  3377. bytes.push(
  3378. codePoint >> 0xC | 0xE0,
  3379. codePoint >> 0x6 & 0x3F | 0x80,
  3380. codePoint & 0x3F | 0x80
  3381. )
  3382. } else if (codePoint < 0x110000) {
  3383. if ((units -= 4) < 0) break
  3384. bytes.push(
  3385. codePoint >> 0x12 | 0xF0,
  3386. codePoint >> 0xC & 0x3F | 0x80,
  3387. codePoint >> 0x6 & 0x3F | 0x80,
  3388. codePoint & 0x3F | 0x80
  3389. )
  3390. } else {
  3391. throw new Error('Invalid code point')
  3392. }
  3393. }
  3394. return bytes
  3395. }
  3396. function asciiToBytes (str) {
  3397. var byteArray = []
  3398. for (var i = 0; i < str.length; ++i) {
  3399. // Node's code seems to be doing this and not & 0x7F..
  3400. byteArray.push(str.charCodeAt(i) & 0xFF)
  3401. }
  3402. return byteArray
  3403. }
  3404. function utf16leToBytes (str, units) {
  3405. var c, hi, lo
  3406. var byteArray = []
  3407. for (var i = 0; i < str.length; ++i) {
  3408. if ((units -= 2) < 0) break
  3409. c = str.charCodeAt(i)
  3410. hi = c >> 8
  3411. lo = c % 256
  3412. byteArray.push(lo)
  3413. byteArray.push(hi)
  3414. }
  3415. return byteArray
  3416. }
  3417. function base64ToBytes (str) {
  3418. return base64.toByteArray(base64clean(str))
  3419. }
  3420. function blitBuffer (src, dst, offset, length) {
  3421. for (var i = 0; i < length; ++i) {
  3422. if ((i + offset >= dst.length) || (i >= src.length)) break
  3423. dst[i + offset] = src[i]
  3424. }
  3425. return i
  3426. }
  3427. function isnan (val) {
  3428. return val !== val // eslint-disable-line no-self-compare
  3429. }
  3430. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
  3431. /***/ }),
  3432. /* 7 */
  3433. /***/ (function(module, exports, __webpack_require__) {
  3434. "use strict";
  3435. exports.byteLength = byteLength
  3436. exports.toByteArray = toByteArray
  3437. exports.fromByteArray = fromByteArray
  3438. var lookup = []
  3439. var revLookup = []
  3440. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  3441. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  3442. for (var i = 0, len = code.length; i < len; ++i) {
  3443. lookup[i] = code[i]
  3444. revLookup[code.charCodeAt(i)] = i
  3445. }
  3446. // Support decoding URL-safe base64 strings, as Node.js does.
  3447. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  3448. revLookup['-'.charCodeAt(0)] = 62
  3449. revLookup['_'.charCodeAt(0)] = 63
  3450. function getLens (b64) {
  3451. var len = b64.length
  3452. if (len % 4 > 0) {
  3453. throw new Error('Invalid string. Length must be a multiple of 4')
  3454. }
  3455. // Trim off extra bytes after placeholder bytes are found
  3456. // See: https://github.com/beatgammit/base64-js/issues/42
  3457. var validLen = b64.indexOf('=')
  3458. if (validLen === -1) validLen = len
  3459. var placeHoldersLen = validLen === len
  3460. ? 0
  3461. : 4 - (validLen % 4)
  3462. return [validLen, placeHoldersLen]
  3463. }
  3464. // base64 is 4/3 + up to two characters of the original data
  3465. function byteLength (b64) {
  3466. var lens = getLens(b64)
  3467. var validLen = lens[0]
  3468. var placeHoldersLen = lens[1]
  3469. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  3470. }
  3471. function _byteLength (b64, validLen, placeHoldersLen) {
  3472. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  3473. }
  3474. function toByteArray (b64) {
  3475. var tmp
  3476. var lens = getLens(b64)
  3477. var validLen = lens[0]
  3478. var placeHoldersLen = lens[1]
  3479. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  3480. var curByte = 0
  3481. // if there are placeholders, only get up to the last complete 4 chars
  3482. var len = placeHoldersLen > 0
  3483. ? validLen - 4
  3484. : validLen
  3485. var i
  3486. for (i = 0; i < len; i += 4) {
  3487. tmp =
  3488. (revLookup[b64.charCodeAt(i)] << 18) |
  3489. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  3490. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  3491. revLookup[b64.charCodeAt(i + 3)]
  3492. arr[curByte++] = (tmp >> 16) & 0xFF
  3493. arr[curByte++] = (tmp >> 8) & 0xFF
  3494. arr[curByte++] = tmp & 0xFF
  3495. }
  3496. if (placeHoldersLen === 2) {
  3497. tmp =
  3498. (revLookup[b64.charCodeAt(i)] << 2) |
  3499. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  3500. arr[curByte++] = tmp & 0xFF
  3501. }
  3502. if (placeHoldersLen === 1) {
  3503. tmp =
  3504. (revLookup[b64.charCodeAt(i)] << 10) |
  3505. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  3506. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  3507. arr[curByte++] = (tmp >> 8) & 0xFF
  3508. arr[curByte++] = tmp & 0xFF
  3509. }
  3510. return arr
  3511. }
  3512. function tripletToBase64 (num) {
  3513. return lookup[num >> 18 & 0x3F] +
  3514. lookup[num >> 12 & 0x3F] +
  3515. lookup[num >> 6 & 0x3F] +
  3516. lookup[num & 0x3F]
  3517. }
  3518. function encodeChunk (uint8, start, end) {
  3519. var tmp
  3520. var output = []
  3521. for (var i = start; i < end; i += 3) {
  3522. tmp =
  3523. ((uint8[i] << 16) & 0xFF0000) +
  3524. ((uint8[i + 1] << 8) & 0xFF00) +
  3525. (uint8[i + 2] & 0xFF)
  3526. output.push(tripletToBase64(tmp))
  3527. }
  3528. return output.join('')
  3529. }
  3530. function fromByteArray (uint8) {
  3531. var tmp
  3532. var len = uint8.length
  3533. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  3534. var parts = []
  3535. var maxChunkLength = 16383 // must be multiple of 3
  3536. // go through the array every three bytes, we'll deal with trailing stuff later
  3537. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  3538. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  3539. }
  3540. // pad the end with zeros, but make sure to not forget the extra bytes
  3541. if (extraBytes === 1) {
  3542. tmp = uint8[len - 1]
  3543. parts.push(
  3544. lookup[tmp >> 2] +
  3545. lookup[(tmp << 4) & 0x3F] +
  3546. '=='
  3547. )
  3548. } else if (extraBytes === 2) {
  3549. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  3550. parts.push(
  3551. lookup[tmp >> 10] +
  3552. lookup[(tmp >> 4) & 0x3F] +
  3553. lookup[(tmp << 2) & 0x3F] +
  3554. '='
  3555. )
  3556. }
  3557. return parts.join('')
  3558. }
  3559. /***/ }),
  3560. /* 8 */
  3561. /***/ (function(module, exports) {
  3562. /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
  3563. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  3564. var e, m
  3565. var eLen = (nBytes * 8) - mLen - 1
  3566. var eMax = (1 << eLen) - 1
  3567. var eBias = eMax >> 1
  3568. var nBits = -7
  3569. var i = isLE ? (nBytes - 1) : 0
  3570. var d = isLE ? -1 : 1
  3571. var s = buffer[offset + i]
  3572. i += d
  3573. e = s & ((1 << (-nBits)) - 1)
  3574. s >>= (-nBits)
  3575. nBits += eLen
  3576. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  3577. m = e & ((1 << (-nBits)) - 1)
  3578. e >>= (-nBits)
  3579. nBits += mLen
  3580. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  3581. if (e === 0) {
  3582. e = 1 - eBias
  3583. } else if (e === eMax) {
  3584. return m ? NaN : ((s ? -1 : 1) * Infinity)
  3585. } else {
  3586. m = m + Math.pow(2, mLen)
  3587. e = e - eBias
  3588. }
  3589. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  3590. }
  3591. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  3592. var e, m, c
  3593. var eLen = (nBytes * 8) - mLen - 1
  3594. var eMax = (1 << eLen) - 1
  3595. var eBias = eMax >> 1
  3596. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  3597. var i = isLE ? 0 : (nBytes - 1)
  3598. var d = isLE ? 1 : -1
  3599. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  3600. value = Math.abs(value)
  3601. if (isNaN(value) || value === Infinity) {
  3602. m = isNaN(value) ? 1 : 0
  3603. e = eMax
  3604. } else {
  3605. e = Math.floor(Math.log(value) / Math.LN2)
  3606. if (value * (c = Math.pow(2, -e)) < 1) {
  3607. e--
  3608. c *= 2
  3609. }
  3610. if (e + eBias >= 1) {
  3611. value += rt / c
  3612. } else {
  3613. value += rt * Math.pow(2, 1 - eBias)
  3614. }
  3615. if (value * c >= 2) {
  3616. e++
  3617. c /= 2
  3618. }
  3619. if (e + eBias >= eMax) {
  3620. m = 0
  3621. e = eMax
  3622. } else if (e + eBias >= 1) {
  3623. m = ((value * c) - 1) * Math.pow(2, mLen)
  3624. e = e + eBias
  3625. } else {
  3626. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  3627. e = 0
  3628. }
  3629. }
  3630. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  3631. e = (e << mLen) | m
  3632. eLen += mLen
  3633. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  3634. buffer[offset + i - d] |= s * 128
  3635. }
  3636. /***/ }),
  3637. /* 9 */
  3638. /***/ (function(module, exports) {
  3639. var toString = {}.toString;
  3640. module.exports = Array.isArray || function (arr) {
  3641. return toString.call(arr) == '[object Array]';
  3642. };
  3643. /***/ }),
  3644. /* 10 */
  3645. /***/ (function(module, exports, __webpack_require__) {
  3646. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  3647. (typeof self !== "undefined" && self) ||
  3648. window;
  3649. var apply = Function.prototype.apply;
  3650. // DOM APIs, for completeness
  3651. exports.setTimeout = function() {
  3652. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  3653. };
  3654. exports.setInterval = function() {
  3655. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  3656. };
  3657. exports.clearTimeout =
  3658. exports.clearInterval = function(timeout) {
  3659. if (timeout) {
  3660. timeout.close();
  3661. }
  3662. };
  3663. function Timeout(id, clearFn) {
  3664. this._id = id;
  3665. this._clearFn = clearFn;
  3666. }
  3667. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  3668. Timeout.prototype.close = function() {
  3669. this._clearFn.call(scope, this._id);
  3670. };
  3671. // Does not start the time, just sets up the members needed.
  3672. exports.enroll = function(item, msecs) {
  3673. clearTimeout(item._idleTimeoutId);
  3674. item._idleTimeout = msecs;
  3675. };
  3676. exports.unenroll = function(item) {
  3677. clearTimeout(item._idleTimeoutId);
  3678. item._idleTimeout = -1;
  3679. };
  3680. exports._unrefActive = exports.active = function(item) {
  3681. clearTimeout(item._idleTimeoutId);
  3682. var msecs = item._idleTimeout;
  3683. if (msecs >= 0) {
  3684. item._idleTimeoutId = setTimeout(function onTimeout() {
  3685. if (item._onTimeout)
  3686. item._onTimeout();
  3687. }, msecs);
  3688. }
  3689. };
  3690. // setimmediate attaches itself to the global object
  3691. __webpack_require__(11);
  3692. // On some exotic environments, it's not clear which object `setimmediate` was
  3693. // able to install onto. Search each possibility in the same order as the
  3694. // `setimmediate` library.
  3695. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  3696. (typeof global !== "undefined" && global.setImmediate) ||
  3697. (this && this.setImmediate);
  3698. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  3699. (typeof global !== "undefined" && global.clearImmediate) ||
  3700. (this && this.clearImmediate);
  3701. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
  3702. /***/ }),
  3703. /* 11 */
  3704. /***/ (function(module, exports, __webpack_require__) {
  3705. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  3706. "use strict";
  3707. if (global.setImmediate) {
  3708. return;
  3709. }
  3710. var nextHandle = 1; // Spec says greater than zero
  3711. var tasksByHandle = {};
  3712. var currentlyRunningATask = false;
  3713. var doc = global.document;
  3714. var registerImmediate;
  3715. function setImmediate(callback) {
  3716. // Callback can either be a function or a string
  3717. if (typeof callback !== "function") {
  3718. callback = new Function("" + callback);
  3719. }
  3720. // Copy function arguments
  3721. var args = new Array(arguments.length - 1);
  3722. for (var i = 0; i < args.length; i++) {
  3723. args[i] = arguments[i + 1];
  3724. }
  3725. // Store and register the task
  3726. var task = { callback: callback, args: args };
  3727. tasksByHandle[nextHandle] = task;
  3728. registerImmediate(nextHandle);
  3729. return nextHandle++;
  3730. }
  3731. function clearImmediate(handle) {
  3732. delete tasksByHandle[handle];
  3733. }
  3734. function run(task) {
  3735. var callback = task.callback;
  3736. var args = task.args;
  3737. switch (args.length) {
  3738. case 0:
  3739. callback();
  3740. break;
  3741. case 1:
  3742. callback(args[0]);
  3743. break;
  3744. case 2:
  3745. callback(args[0], args[1]);
  3746. break;
  3747. case 3:
  3748. callback(args[0], args[1], args[2]);
  3749. break;
  3750. default:
  3751. callback.apply(undefined, args);
  3752. break;
  3753. }
  3754. }
  3755. function runIfPresent(handle) {
  3756. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  3757. // So if we're currently running a task, we'll need to delay this invocation.
  3758. if (currentlyRunningATask) {
  3759. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  3760. // "too much recursion" error.
  3761. setTimeout(runIfPresent, 0, handle);
  3762. } else {
  3763. var task = tasksByHandle[handle];
  3764. if (task) {
  3765. currentlyRunningATask = true;
  3766. try {
  3767. run(task);
  3768. } finally {
  3769. clearImmediate(handle);
  3770. currentlyRunningATask = false;
  3771. }
  3772. }
  3773. }
  3774. }
  3775. function installNextTickImplementation() {
  3776. registerImmediate = function(handle) {
  3777. process.nextTick(function () { runIfPresent(handle); });
  3778. };
  3779. }
  3780. function canUsePostMessage() {
  3781. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  3782. // where `global.postMessage` means something completely different and can't be used for this purpose.
  3783. if (global.postMessage && !global.importScripts) {
  3784. var postMessageIsAsynchronous = true;
  3785. var oldOnMessage = global.onmessage;
  3786. global.onmessage = function() {
  3787. postMessageIsAsynchronous = false;
  3788. };
  3789. global.postMessage("", "*");
  3790. global.onmessage = oldOnMessage;
  3791. return postMessageIsAsynchronous;
  3792. }
  3793. }
  3794. function installPostMessageImplementation() {
  3795. // Installs an event handler on `global` for the `message` event: see
  3796. // * https://developer.mozilla.org/en/DOM/window.postMessage
  3797. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  3798. var messagePrefix = "setImmediate$" + Math.random() + "$";
  3799. var onGlobalMessage = function(event) {
  3800. if (event.source === global &&
  3801. typeof event.data === "string" &&
  3802. event.data.indexOf(messagePrefix) === 0) {
  3803. runIfPresent(+event.data.slice(messagePrefix.length));
  3804. }
  3805. };
  3806. if (global.addEventListener) {
  3807. global.addEventListener("message", onGlobalMessage, false);
  3808. } else {
  3809. global.attachEvent("onmessage", onGlobalMessage);
  3810. }
  3811. registerImmediate = function(handle) {
  3812. global.postMessage(messagePrefix + handle, "*");
  3813. };
  3814. }
  3815. function installMessageChannelImplementation() {
  3816. var channel = new MessageChannel();
  3817. channel.port1.onmessage = function(event) {
  3818. var handle = event.data;
  3819. runIfPresent(handle);
  3820. };
  3821. registerImmediate = function(handle) {
  3822. channel.port2.postMessage(handle);
  3823. };
  3824. }
  3825. function installReadyStateChangeImplementation() {
  3826. var html = doc.documentElement;
  3827. registerImmediate = function(handle) {
  3828. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  3829. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  3830. var script = doc.createElement("script");
  3831. script.onreadystatechange = function () {
  3832. runIfPresent(handle);
  3833. script.onreadystatechange = null;
  3834. html.removeChild(script);
  3835. script = null;
  3836. };
  3837. html.appendChild(script);
  3838. };
  3839. }
  3840. function installSetTimeoutImplementation() {
  3841. registerImmediate = function(handle) {
  3842. setTimeout(runIfPresent, 0, handle);
  3843. };
  3844. }
  3845. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  3846. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  3847. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  3848. // Don't get fooled by e.g. browserify environments.
  3849. if ({}.toString.call(global.process) === "[object process]") {
  3850. // For Node.js before 0.9
  3851. installNextTickImplementation();
  3852. } else if (canUsePostMessage()) {
  3853. // For non-IE10 modern browsers
  3854. installPostMessageImplementation();
  3855. } else if (global.MessageChannel) {
  3856. // For web workers, where supported
  3857. installMessageChannelImplementation();
  3858. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  3859. // For IE 6–8
  3860. installReadyStateChangeImplementation();
  3861. } else {
  3862. // For older browsers
  3863. installSetTimeoutImplementation();
  3864. }
  3865. attachTo.setImmediate = setImmediate;
  3866. attachTo.clearImmediate = clearImmediate;
  3867. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  3868. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1), __webpack_require__(3)))
  3869. /***/ }),
  3870. /* 12 */
  3871. /***/ (function(module, exports) {
  3872. function webpackEmptyContext(req) {
  3873. var e = new Error("Cannot find module '" + req + "'");
  3874. e.code = 'MODULE_NOT_FOUND';
  3875. throw e;
  3876. }
  3877. webpackEmptyContext.keys = function() { return []; };
  3878. webpackEmptyContext.resolve = webpackEmptyContext;
  3879. module.exports = webpackEmptyContext;
  3880. webpackEmptyContext.id = 12;
  3881. /***/ }),
  3882. /* 13 */
  3883. /***/ (function(module, exports, __webpack_require__) {
  3884. function DOMParser(options){
  3885. this.options = options ||{locator:{}};
  3886. }
  3887. DOMParser.prototype.parseFromString = function(source,mimeType){
  3888. var options = this.options;
  3889. var sax = new XMLReader();
  3890. var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
  3891. var errorHandler = options.errorHandler;
  3892. var locator = options.locator;
  3893. var defaultNSMap = options.xmlns||{};
  3894. var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
  3895. var entityMap = isHTML?htmlEntity.entityMap:{'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"};
  3896. if(locator){
  3897. domBuilder.setDocumentLocator(locator)
  3898. }
  3899. sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
  3900. sax.domBuilder = options.domBuilder || domBuilder;
  3901. if(isHTML){
  3902. defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
  3903. }
  3904. defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
  3905. if(source && typeof source === 'string'){
  3906. sax.parse(source,defaultNSMap,entityMap);
  3907. }else{
  3908. sax.errorHandler.error("invalid doc source");
  3909. }
  3910. return domBuilder.doc;
  3911. }
  3912. function buildErrorHandler(errorImpl,domBuilder,locator){
  3913. if(!errorImpl){
  3914. if(domBuilder instanceof DOMHandler){
  3915. return domBuilder;
  3916. }
  3917. errorImpl = domBuilder ;
  3918. }
  3919. var errorHandler = {}
  3920. var isCallback = errorImpl instanceof Function;
  3921. locator = locator||{}
  3922. function build(key){
  3923. var fn = errorImpl[key];
  3924. if(!fn && isCallback){
  3925. fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
  3926. }
  3927. errorHandler[key] = fn && function(msg){
  3928. fn('[xmldom '+key+']\t'+msg+_locator(locator));
  3929. }||function(){};
  3930. }
  3931. build('warning');
  3932. build('error');
  3933. build('fatalError');
  3934. return errorHandler;
  3935. }
  3936. //console.log('#\n\n\n\n\n\n\n####')
  3937. /**
  3938. * +ContentHandler+ErrorHandler
  3939. * +LexicalHandler+EntityResolver2
  3940. * -DeclHandler-DTDHandler
  3941. *
  3942. * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
  3943. * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
  3944. * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
  3945. */
  3946. function DOMHandler() {
  3947. this.cdata = false;
  3948. }
  3949. function position(locator,node){
  3950. node.lineNumber = locator.lineNumber;
  3951. node.columnNumber = locator.columnNumber;
  3952. }
  3953. /**
  3954. * @see org.xml.sax.ContentHandler#startDocument
  3955. * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
  3956. */
  3957. DOMHandler.prototype = {
  3958. startDocument : function() {
  3959. this.doc = new DOMImplementation().createDocument(null, null, null);
  3960. if (this.locator) {
  3961. this.doc.documentURI = this.locator.systemId;
  3962. }
  3963. },
  3964. startElement:function(namespaceURI, localName, qName, attrs) {
  3965. var doc = this.doc;
  3966. var el = doc.createElementNS(namespaceURI, qName||localName);
  3967. var len = attrs.length;
  3968. appendElement(this, el);
  3969. this.currentElement = el;
  3970. this.locator && position(this.locator,el)
  3971. for (var i = 0 ; i < len; i++) {
  3972. var namespaceURI = attrs.getURI(i);
  3973. var value = attrs.getValue(i);
  3974. var qName = attrs.getQName(i);
  3975. var attr = doc.createAttributeNS(namespaceURI, qName);
  3976. this.locator &&position(attrs.getLocator(i),attr);
  3977. attr.value = attr.nodeValue = value;
  3978. el.setAttributeNode(attr)
  3979. }
  3980. },
  3981. endElement:function(namespaceURI, localName, qName) {
  3982. var current = this.currentElement
  3983. var tagName = current.tagName;
  3984. this.currentElement = current.parentNode;
  3985. },
  3986. startPrefixMapping:function(prefix, uri) {
  3987. },
  3988. endPrefixMapping:function(prefix) {
  3989. },
  3990. processingInstruction:function(target, data) {
  3991. var ins = this.doc.createProcessingInstruction(target, data);
  3992. this.locator && position(this.locator,ins)
  3993. appendElement(this, ins);
  3994. },
  3995. ignorableWhitespace:function(ch, start, length) {
  3996. },
  3997. characters:function(chars, start, length) {
  3998. chars = _toString.apply(this,arguments)
  3999. //console.log(chars)
  4000. if(chars){
  4001. if (this.cdata) {
  4002. var charNode = this.doc.createCDATASection(chars);
  4003. } else {
  4004. var charNode = this.doc.createTextNode(chars);
  4005. }
  4006. if(this.currentElement){
  4007. this.currentElement.appendChild(charNode);
  4008. }else if(/^\s*$/.test(chars)){
  4009. this.doc.appendChild(charNode);
  4010. //process xml
  4011. }
  4012. this.locator && position(this.locator,charNode)
  4013. }
  4014. },
  4015. skippedEntity:function(name) {
  4016. },
  4017. endDocument:function() {
  4018. this.doc.normalize();
  4019. },
  4020. setDocumentLocator:function (locator) {
  4021. if(this.locator = locator){// && !('lineNumber' in locator)){
  4022. locator.lineNumber = 0;
  4023. }
  4024. },
  4025. //LexicalHandler
  4026. comment:function(chars, start, length) {
  4027. chars = _toString.apply(this,arguments)
  4028. var comm = this.doc.createComment(chars);
  4029. this.locator && position(this.locator,comm)
  4030. appendElement(this, comm);
  4031. },
  4032. startCDATA:function() {
  4033. //used in characters() methods
  4034. this.cdata = true;
  4035. },
  4036. endCDATA:function() {
  4037. this.cdata = false;
  4038. },
  4039. startDTD:function(name, publicId, systemId) {
  4040. var impl = this.doc.implementation;
  4041. if (impl && impl.createDocumentType) {
  4042. var dt = impl.createDocumentType(name, publicId, systemId);
  4043. this.locator && position(this.locator,dt)
  4044. appendElement(this, dt);
  4045. }
  4046. },
  4047. /**
  4048. * @see org.xml.sax.ErrorHandler
  4049. * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
  4050. */
  4051. warning:function(error) {
  4052. console.warn('[xmldom warning]\t'+error,_locator(this.locator));
  4053. },
  4054. error:function(error) {
  4055. console.error('[xmldom error]\t'+error,_locator(this.locator));
  4056. },
  4057. fatalError:function(error) {
  4058. throw new ParseError(error, this.locator);
  4059. }
  4060. }
  4061. function _locator(l){
  4062. if(l){
  4063. return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
  4064. }
  4065. }
  4066. function _toString(chars,start,length){
  4067. if(typeof chars == 'string'){
  4068. return chars.substr(start,length)
  4069. }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
  4070. if(chars.length >= start+length || start){
  4071. return new java.lang.String(chars,start,length)+'';
  4072. }
  4073. return chars;
  4074. }
  4075. }
  4076. /*
  4077. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
  4078. * used method of org.xml.sax.ext.LexicalHandler:
  4079. * #comment(chars, start, length)
  4080. * #startCDATA()
  4081. * #endCDATA()
  4082. * #startDTD(name, publicId, systemId)
  4083. *
  4084. *
  4085. * IGNORED method of org.xml.sax.ext.LexicalHandler:
  4086. * #endDTD()
  4087. * #startEntity(name)
  4088. * #endEntity(name)
  4089. *
  4090. *
  4091. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
  4092. * IGNORED method of org.xml.sax.ext.DeclHandler
  4093. * #attributeDecl(eName, aName, type, mode, value)
  4094. * #elementDecl(name, model)
  4095. * #externalEntityDecl(name, publicId, systemId)
  4096. * #internalEntityDecl(name, value)
  4097. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
  4098. * IGNORED method of org.xml.sax.EntityResolver2
  4099. * #resolveEntity(String name,String publicId,String baseURI,String systemId)
  4100. * #resolveEntity(publicId, systemId)
  4101. * #getExternalSubset(name, baseURI)
  4102. * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
  4103. * IGNORED method of org.xml.sax.DTDHandler
  4104. * #notationDecl(name, publicId, systemId) {};
  4105. * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
  4106. */
  4107. "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
  4108. DOMHandler.prototype[key] = function(){return null}
  4109. })
  4110. /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
  4111. function appendElement (hander,node) {
  4112. if (!hander.currentElement) {
  4113. hander.doc.appendChild(node);
  4114. } else {
  4115. hander.currentElement.appendChild(node);
  4116. }
  4117. }//appendChild and setAttributeNS are preformance key
  4118. //if(typeof require == 'function'){
  4119. var htmlEntity = __webpack_require__(14);
  4120. var sax = __webpack_require__(15);
  4121. var XMLReader = sax.XMLReader;
  4122. var ParseError = sax.ParseError;
  4123. var DOMImplementation = exports.DOMImplementation = __webpack_require__(4).DOMImplementation;
  4124. exports.XMLSerializer = __webpack_require__(4).XMLSerializer ;
  4125. exports.DOMParser = DOMParser;
  4126. exports.__DOMHandler = DOMHandler;
  4127. //}
  4128. /***/ }),
  4129. /* 14 */
  4130. /***/ (function(module, exports) {
  4131. exports.entityMap = {
  4132. lt: '<',
  4133. gt: '>',
  4134. amp: '&',
  4135. quot: '"',
  4136. apos: "'",
  4137. Agrave: "À",
  4138. Aacute: "Á",
  4139. Acirc: "Â",
  4140. Atilde: "Ã",
  4141. Auml: "Ä",
  4142. Aring: "Å",
  4143. AElig: "Æ",
  4144. Ccedil: "Ç",
  4145. Egrave: "È",
  4146. Eacute: "É",
  4147. Ecirc: "Ê",
  4148. Euml: "Ë",
  4149. Igrave: "Ì",
  4150. Iacute: "Í",
  4151. Icirc: "Î",
  4152. Iuml: "Ï",
  4153. ETH: "Ð",
  4154. Ntilde: "Ñ",
  4155. Ograve: "Ò",
  4156. Oacute: "Ó",
  4157. Ocirc: "Ô",
  4158. Otilde: "Õ",
  4159. Ouml: "Ö",
  4160. Oslash: "Ø",
  4161. Ugrave: "Ù",
  4162. Uacute: "Ú",
  4163. Ucirc: "Û",
  4164. Uuml: "Ü",
  4165. Yacute: "Ý",
  4166. THORN: "Þ",
  4167. szlig: "ß",
  4168. agrave: "à",
  4169. aacute: "á",
  4170. acirc: "â",
  4171. atilde: "ã",
  4172. auml: "ä",
  4173. aring: "å",
  4174. aelig: "æ",
  4175. ccedil: "ç",
  4176. egrave: "è",
  4177. eacute: "é",
  4178. ecirc: "ê",
  4179. euml: "ë",
  4180. igrave: "ì",
  4181. iacute: "í",
  4182. icirc: "î",
  4183. iuml: "ï",
  4184. eth: "ð",
  4185. ntilde: "ñ",
  4186. ograve: "ò",
  4187. oacute: "ó",
  4188. ocirc: "ô",
  4189. otilde: "õ",
  4190. ouml: "ö",
  4191. oslash: "ø",
  4192. ugrave: "ù",
  4193. uacute: "ú",
  4194. ucirc: "û",
  4195. uuml: "ü",
  4196. yacute: "ý",
  4197. thorn: "þ",
  4198. yuml: "ÿ",
  4199. nbsp: "\u00a0",
  4200. iexcl: "¡",
  4201. cent: "¢",
  4202. pound: "£",
  4203. curren: "¤",
  4204. yen: "¥",
  4205. brvbar: "¦",
  4206. sect: "§",
  4207. uml: "¨",
  4208. copy: "©",
  4209. ordf: "ª",
  4210. laquo: "«",
  4211. not: "¬",
  4212. shy: "­­",
  4213. reg: "®",
  4214. macr: "¯",
  4215. deg: "°",
  4216. plusmn: "±",
  4217. sup2: "²",
  4218. sup3: "³",
  4219. acute: "´",
  4220. micro: "µ",
  4221. para: "¶",
  4222. middot: "·",
  4223. cedil: "¸",
  4224. sup1: "¹",
  4225. ordm: "º",
  4226. raquo: "»",
  4227. frac14: "¼",
  4228. frac12: "½",
  4229. frac34: "¾",
  4230. iquest: "¿",
  4231. times: "×",
  4232. divide: "÷",
  4233. forall: "∀",
  4234. part: "∂",
  4235. exist: "∃",
  4236. empty: "∅",
  4237. nabla: "∇",
  4238. isin: "∈",
  4239. notin: "∉",
  4240. ni: "∋",
  4241. prod: "∏",
  4242. sum: "∑",
  4243. minus: "−",
  4244. lowast: "∗",
  4245. radic: "√",
  4246. prop: "∝",
  4247. infin: "∞",
  4248. ang: "∠",
  4249. and: "∧",
  4250. or: "∨",
  4251. cap: "∩",
  4252. cup: "∪",
  4253. 'int': "∫",
  4254. there4: "∴",
  4255. sim: "∼",
  4256. cong: "≅",
  4257. asymp: "≈",
  4258. ne: "≠",
  4259. equiv: "≡",
  4260. le: "≤",
  4261. ge: "≥",
  4262. sub: "⊂",
  4263. sup: "⊃",
  4264. nsub: "⊄",
  4265. sube: "⊆",
  4266. supe: "⊇",
  4267. oplus: "⊕",
  4268. otimes: "⊗",
  4269. perp: "⊥",
  4270. sdot: "⋅",
  4271. Alpha: "Α",
  4272. Beta: "Β",
  4273. Gamma: "Γ",
  4274. Delta: "Δ",
  4275. Epsilon: "Ε",
  4276. Zeta: "Ζ",
  4277. Eta: "Η",
  4278. Theta: "Θ",
  4279. Iota: "Ι",
  4280. Kappa: "Κ",
  4281. Lambda: "Λ",
  4282. Mu: "Μ",
  4283. Nu: "Ν",
  4284. Xi: "Ξ",
  4285. Omicron: "Ο",
  4286. Pi: "Π",
  4287. Rho: "Ρ",
  4288. Sigma: "Σ",
  4289. Tau: "Τ",
  4290. Upsilon: "Υ",
  4291. Phi: "Φ",
  4292. Chi: "Χ",
  4293. Psi: "Ψ",
  4294. Omega: "Ω",
  4295. alpha: "α",
  4296. beta: "β",
  4297. gamma: "γ",
  4298. delta: "δ",
  4299. epsilon: "ε",
  4300. zeta: "ζ",
  4301. eta: "η",
  4302. theta: "θ",
  4303. iota: "ι",
  4304. kappa: "κ",
  4305. lambda: "λ",
  4306. mu: "μ",
  4307. nu: "ν",
  4308. xi: "ξ",
  4309. omicron: "ο",
  4310. pi: "π",
  4311. rho: "ρ",
  4312. sigmaf: "ς",
  4313. sigma: "σ",
  4314. tau: "τ",
  4315. upsilon: "υ",
  4316. phi: "φ",
  4317. chi: "χ",
  4318. psi: "ψ",
  4319. omega: "ω",
  4320. thetasym: "ϑ",
  4321. upsih: "ϒ",
  4322. piv: "ϖ",
  4323. OElig: "Œ",
  4324. oelig: "œ",
  4325. Scaron: "Š",
  4326. scaron: "š",
  4327. Yuml: "Ÿ",
  4328. fnof: "ƒ",
  4329. circ: "ˆ",
  4330. tilde: "˜",
  4331. ensp: " ",
  4332. emsp: " ",
  4333. thinsp: " ",
  4334. zwnj: "‌",
  4335. zwj: "‍",
  4336. lrm: "‎",
  4337. rlm: "‏",
  4338. ndash: "–",
  4339. mdash: "—",
  4340. lsquo: "‘",
  4341. rsquo: "’",
  4342. sbquo: "‚",
  4343. ldquo: "“",
  4344. rdquo: "”",
  4345. bdquo: "„",
  4346. dagger: "†",
  4347. Dagger: "‡",
  4348. bull: "•",
  4349. hellip: "…",
  4350. permil: "‰",
  4351. prime: "′",
  4352. Prime: "″",
  4353. lsaquo: "‹",
  4354. rsaquo: "›",
  4355. oline: "‾",
  4356. euro: "€",
  4357. trade: "™",
  4358. larr: "←",
  4359. uarr: "↑",
  4360. rarr: "→",
  4361. darr: "↓",
  4362. harr: "↔",
  4363. crarr: "↵",
  4364. lceil: "⌈",
  4365. rceil: "⌉",
  4366. lfloor: "⌊",
  4367. rfloor: "⌋",
  4368. loz: "◊",
  4369. spades: "♠",
  4370. clubs: "♣",
  4371. hearts: "♥",
  4372. diams: "♦"
  4373. };
  4374. /***/ }),
  4375. /* 15 */
  4376. /***/ (function(module, exports) {
  4377. //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
  4378. //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
  4379. //[5] Name ::= NameStartChar (NameChar)*
  4380. var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
  4381. var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
  4382. var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
  4383. //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
  4384. //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
  4385. //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
  4386. //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
  4387. var S_TAG = 0;//tag name offerring
  4388. var S_ATTR = 1;//attr name offerring
  4389. var S_ATTR_SPACE=2;//attr name end and space offer
  4390. var S_EQ = 3;//=space?
  4391. var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
  4392. var S_ATTR_END = 5;//attr value end and no space(quot end)
  4393. var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
  4394. var S_TAG_CLOSE = 7;//closed el<el />
  4395. /**
  4396. * Creates an error that will not be caught by XMLReader aka the SAX parser.
  4397. *
  4398. * @param {string} message
  4399. * @param {any?} locator Optional, can provide details about the location in the source
  4400. * @constructor
  4401. */
  4402. function ParseError(message, locator) {
  4403. this.message = message
  4404. this.locator = locator
  4405. if(Error.captureStackTrace) Error.captureStackTrace(this, ParseError);
  4406. }
  4407. ParseError.prototype = new Error();
  4408. ParseError.prototype.name = ParseError.name
  4409. function XMLReader(){
  4410. }
  4411. XMLReader.prototype = {
  4412. parse:function(source,defaultNSMap,entityMap){
  4413. var domBuilder = this.domBuilder;
  4414. domBuilder.startDocument();
  4415. _copy(defaultNSMap ,defaultNSMap = {})
  4416. parse(source,defaultNSMap,entityMap,
  4417. domBuilder,this.errorHandler);
  4418. domBuilder.endDocument();
  4419. }
  4420. }
  4421. function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
  4422. function fixedFromCharCode(code) {
  4423. // String.prototype.fromCharCode does not supports
  4424. // > 2 bytes unicode chars directly
  4425. if (code > 0xffff) {
  4426. code -= 0x10000;
  4427. var surrogate1 = 0xd800 + (code >> 10)
  4428. , surrogate2 = 0xdc00 + (code & 0x3ff);
  4429. return String.fromCharCode(surrogate1, surrogate2);
  4430. } else {
  4431. return String.fromCharCode(code);
  4432. }
  4433. }
  4434. function entityReplacer(a){
  4435. var k = a.slice(1,-1);
  4436. if(k in entityMap){
  4437. return entityMap[k];
  4438. }else if(k.charAt(0) === '#'){
  4439. return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
  4440. }else{
  4441. errorHandler.error('entity not found:'+a);
  4442. return a;
  4443. }
  4444. }
  4445. function appendText(end){//has some bugs
  4446. if(end>start){
  4447. var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
  4448. locator&&position(start);
  4449. domBuilder.characters(xt,0,end-start);
  4450. start = end
  4451. }
  4452. }
  4453. function position(p,m){
  4454. while(p>=lineEnd && (m = linePattern.exec(source))){
  4455. lineStart = m.index;
  4456. lineEnd = lineStart + m[0].length;
  4457. locator.lineNumber++;
  4458. //console.log('line++:',locator,startPos,endPos)
  4459. }
  4460. locator.columnNumber = p-lineStart+1;
  4461. }
  4462. var lineStart = 0;
  4463. var lineEnd = 0;
  4464. var linePattern = /.*(?:\r\n?|\n)|.*$/g
  4465. var locator = domBuilder.locator;
  4466. var parseStack = [{currentNSMap:defaultNSMapCopy}]
  4467. var closeMap = {};
  4468. var start = 0;
  4469. while(true){
  4470. try{
  4471. var tagStart = source.indexOf('<',start);
  4472. if(tagStart<0){
  4473. if(!source.substr(start).match(/^\s*$/)){
  4474. var doc = domBuilder.doc;
  4475. var text = doc.createTextNode(source.substr(start));
  4476. doc.appendChild(text);
  4477. domBuilder.currentElement = text;
  4478. }
  4479. return;
  4480. }
  4481. if(tagStart>start){
  4482. appendText(tagStart);
  4483. }
  4484. switch(source.charAt(tagStart+1)){
  4485. case '/':
  4486. var end = source.indexOf('>',tagStart+3);
  4487. var tagName = source.substring(tagStart+2,end);
  4488. var config = parseStack.pop();
  4489. if(end<0){
  4490. tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
  4491. errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
  4492. end = tagStart+1+tagName.length;
  4493. }else if(tagName.match(/\s</)){
  4494. tagName = tagName.replace(/[\s<].*/,'');
  4495. errorHandler.error("end tag name: "+tagName+' maybe not complete');
  4496. end = tagStart+1+tagName.length;
  4497. }
  4498. var localNSMap = config.localNSMap;
  4499. var endMatch = config.tagName == tagName;
  4500. var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
  4501. if(endIgnoreCaseMach){
  4502. domBuilder.endElement(config.uri,config.localName,tagName);
  4503. if(localNSMap){
  4504. for(var prefix in localNSMap){
  4505. domBuilder.endPrefixMapping(prefix) ;
  4506. }
  4507. }
  4508. if(!endMatch){
  4509. errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName ); // No known test case
  4510. }
  4511. }else{
  4512. parseStack.push(config)
  4513. }
  4514. end++;
  4515. break;
  4516. // end elment
  4517. case '?':// <?...?>
  4518. locator&&position(tagStart);
  4519. end = parseInstruction(source,tagStart,domBuilder);
  4520. break;
  4521. case '!':// <!doctype,<![CDATA,<!--
  4522. locator&&position(tagStart);
  4523. end = parseDCC(source,tagStart,domBuilder,errorHandler);
  4524. break;
  4525. default:
  4526. locator&&position(tagStart);
  4527. var el = new ElementAttributes();
  4528. var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
  4529. //elStartEnd
  4530. var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
  4531. var len = el.length;
  4532. if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
  4533. el.closed = true;
  4534. if(!entityMap.nbsp){
  4535. errorHandler.warning('unclosed xml attribute');
  4536. }
  4537. }
  4538. if(locator && len){
  4539. var locator2 = copyLocator(locator,{});
  4540. //try{//attribute position fixed
  4541. for(var i = 0;i<len;i++){
  4542. var a = el[i];
  4543. position(a.offset);
  4544. a.locator = copyLocator(locator,{});
  4545. }
  4546. domBuilder.locator = locator2
  4547. if(appendElement(el,domBuilder,currentNSMap)){
  4548. parseStack.push(el)
  4549. }
  4550. domBuilder.locator = locator;
  4551. }else{
  4552. if(appendElement(el,domBuilder,currentNSMap)){
  4553. parseStack.push(el)
  4554. }
  4555. }
  4556. if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
  4557. end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
  4558. }else{
  4559. end++;
  4560. }
  4561. }
  4562. }catch(e){
  4563. if (e instanceof ParseError) {
  4564. throw e;
  4565. }
  4566. errorHandler.error('element parse error: '+e)
  4567. end = -1;
  4568. }
  4569. if(end>start){
  4570. start = end;
  4571. }else{
  4572. //TODO: 这里有可能sax回退,有位置错误风险
  4573. appendText(Math.max(tagStart,start)+1);
  4574. }
  4575. }
  4576. }
  4577. function copyLocator(f,t){
  4578. t.lineNumber = f.lineNumber;
  4579. t.columnNumber = f.columnNumber;
  4580. return t;
  4581. }
  4582. /**
  4583. * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
  4584. * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
  4585. */
  4586. function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
  4587. /**
  4588. * @param {string} qname
  4589. * @param {string} value
  4590. * @param {number} startIndex
  4591. */
  4592. function addAttribute(qname, value, startIndex) {
  4593. if (qname in el.attributeNames) errorHandler.fatalError('Attribute ' + qname + ' redefined')
  4594. el.addValue(qname, value, startIndex)
  4595. }
  4596. var attrName;
  4597. var value;
  4598. var p = ++start;
  4599. var s = S_TAG;//status
  4600. while(true){
  4601. var c = source.charAt(p);
  4602. switch(c){
  4603. case '=':
  4604. if(s === S_ATTR){//attrName
  4605. attrName = source.slice(start,p);
  4606. s = S_EQ;
  4607. }else if(s === S_ATTR_SPACE){
  4608. s = S_EQ;
  4609. }else{
  4610. //fatalError: equal must after attrName or space after attrName
  4611. throw new Error('attribute equal must after attrName'); // No known test case
  4612. }
  4613. break;
  4614. case '\'':
  4615. case '"':
  4616. if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
  4617. ){//equal
  4618. if(s === S_ATTR){
  4619. errorHandler.warning('attribute value must after "="')
  4620. attrName = source.slice(start,p)
  4621. }
  4622. start = p+1;
  4623. p = source.indexOf(c,start)
  4624. if(p>0){
  4625. value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
  4626. addAttribute(attrName, value, start-1);
  4627. s = S_ATTR_END;
  4628. }else{
  4629. //fatalError: no end quot match
  4630. throw new Error('attribute value no end \''+c+'\' match');
  4631. }
  4632. }else if(s == S_ATTR_NOQUOT_VALUE){
  4633. value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
  4634. //console.log(attrName,value,start,p)
  4635. addAttribute(attrName, value, start);
  4636. //console.dir(el)
  4637. errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
  4638. start = p+1;
  4639. s = S_ATTR_END
  4640. }else{
  4641. //fatalError: no equal before
  4642. throw new Error('attribute value must after "="'); // No known test case
  4643. }
  4644. break;
  4645. case '/':
  4646. switch(s){
  4647. case S_TAG:
  4648. el.setTagName(source.slice(start,p));
  4649. case S_ATTR_END:
  4650. case S_TAG_SPACE:
  4651. case S_TAG_CLOSE:
  4652. s =S_TAG_CLOSE;
  4653. el.closed = true;
  4654. case S_ATTR_NOQUOT_VALUE:
  4655. case S_ATTR:
  4656. case S_ATTR_SPACE:
  4657. break;
  4658. //case S_EQ:
  4659. default:
  4660. throw new Error("attribute invalid close char('/')") // No known test case
  4661. }
  4662. break;
  4663. case ''://end document
  4664. errorHandler.error('unexpected end of input');
  4665. if(s == S_TAG){
  4666. el.setTagName(source.slice(start,p));
  4667. }
  4668. return p;
  4669. case '>':
  4670. switch(s){
  4671. case S_TAG:
  4672. el.setTagName(source.slice(start,p));
  4673. case S_ATTR_END:
  4674. case S_TAG_SPACE:
  4675. case S_TAG_CLOSE:
  4676. break;//normal
  4677. case S_ATTR_NOQUOT_VALUE://Compatible state
  4678. case S_ATTR:
  4679. value = source.slice(start,p);
  4680. if(value.slice(-1) === '/'){
  4681. el.closed = true;
  4682. value = value.slice(0,-1)
  4683. }
  4684. case S_ATTR_SPACE:
  4685. if(s === S_ATTR_SPACE){
  4686. value = attrName;
  4687. }
  4688. if(s == S_ATTR_NOQUOT_VALUE){
  4689. errorHandler.warning('attribute "'+value+'" missed quot(")!');
  4690. addAttribute(attrName, value.replace(/&#?\w+;/g,entityReplacer), start)
  4691. }else{
  4692. if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
  4693. errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
  4694. }
  4695. addAttribute(value, value, start)
  4696. }
  4697. break;
  4698. case S_EQ:
  4699. throw new Error('attribute value missed!!');
  4700. }
  4701. // console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
  4702. return p;
  4703. /*xml space '\x20' | #x9 | #xD | #xA; */
  4704. case '\u0080':
  4705. c = ' ';
  4706. default:
  4707. if(c<= ' '){//space
  4708. switch(s){
  4709. case S_TAG:
  4710. el.setTagName(source.slice(start,p));//tagName
  4711. s = S_TAG_SPACE;
  4712. break;
  4713. case S_ATTR:
  4714. attrName = source.slice(start,p)
  4715. s = S_ATTR_SPACE;
  4716. break;
  4717. case S_ATTR_NOQUOT_VALUE:
  4718. var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
  4719. errorHandler.warning('attribute "'+value+'" missed quot(")!!');
  4720. addAttribute(attrName, value, start)
  4721. case S_ATTR_END:
  4722. s = S_TAG_SPACE;
  4723. break;
  4724. //case S_TAG_SPACE:
  4725. //case S_EQ:
  4726. //case S_ATTR_SPACE:
  4727. // void();break;
  4728. //case S_TAG_CLOSE:
  4729. //ignore warning
  4730. }
  4731. }else{//not space
  4732. //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
  4733. //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
  4734. switch(s){
  4735. //case S_TAG:void();break;
  4736. //case S_ATTR:void();break;
  4737. //case S_ATTR_NOQUOT_VALUE:void();break;
  4738. case S_ATTR_SPACE:
  4739. var tagName = el.tagName;
  4740. if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
  4741. errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
  4742. }
  4743. addAttribute(attrName, attrName, start);
  4744. start = p;
  4745. s = S_ATTR;
  4746. break;
  4747. case S_ATTR_END:
  4748. errorHandler.warning('attribute space is required"'+attrName+'"!!')
  4749. case S_TAG_SPACE:
  4750. s = S_ATTR;
  4751. start = p;
  4752. break;
  4753. case S_EQ:
  4754. s = S_ATTR_NOQUOT_VALUE;
  4755. start = p;
  4756. break;
  4757. case S_TAG_CLOSE:
  4758. throw new Error("elements closed character '/' and '>' must be connected to");
  4759. }
  4760. }
  4761. }//end outer switch
  4762. //console.log('p++',p)
  4763. p++;
  4764. }
  4765. }
  4766. /**
  4767. * @return true if has new namespace define
  4768. */
  4769. function appendElement(el,domBuilder,currentNSMap){
  4770. var tagName = el.tagName;
  4771. var localNSMap = null;
  4772. //var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
  4773. var i = el.length;
  4774. while(i--){
  4775. var a = el[i];
  4776. var qName = a.qName;
  4777. var value = a.value;
  4778. var nsp = qName.indexOf(':');
  4779. if(nsp>0){
  4780. var prefix = a.prefix = qName.slice(0,nsp);
  4781. var localName = qName.slice(nsp+1);
  4782. var nsPrefix = prefix === 'xmlns' && localName
  4783. }else{
  4784. localName = qName;
  4785. prefix = null
  4786. nsPrefix = qName === 'xmlns' && ''
  4787. }
  4788. //can not set prefix,because prefix !== ''
  4789. a.localName = localName ;
  4790. //prefix == null for no ns prefix attribute
  4791. if(nsPrefix !== false){//hack!!
  4792. if(localNSMap == null){
  4793. localNSMap = {}
  4794. //console.log(currentNSMap,0)
  4795. _copy(currentNSMap,currentNSMap={})
  4796. //console.log(currentNSMap,1)
  4797. }
  4798. currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
  4799. a.uri = 'http://www.w3.org/2000/xmlns/'
  4800. domBuilder.startPrefixMapping(nsPrefix, value)
  4801. }
  4802. }
  4803. var i = el.length;
  4804. while(i--){
  4805. a = el[i];
  4806. var prefix = a.prefix;
  4807. if(prefix){//no prefix attribute has no namespace
  4808. if(prefix === 'xml'){
  4809. a.uri = 'http://www.w3.org/XML/1998/namespace';
  4810. }if(prefix !== 'xmlns'){
  4811. a.uri = currentNSMap[prefix || '']
  4812. //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
  4813. }
  4814. }
  4815. }
  4816. var nsp = tagName.indexOf(':');
  4817. if(nsp>0){
  4818. prefix = el.prefix = tagName.slice(0,nsp);
  4819. localName = el.localName = tagName.slice(nsp+1);
  4820. }else{
  4821. prefix = null;//important!!
  4822. localName = el.localName = tagName;
  4823. }
  4824. //no prefix element has default namespace
  4825. var ns = el.uri = currentNSMap[prefix || ''];
  4826. domBuilder.startElement(ns,localName,tagName,el);
  4827. //endPrefixMapping and startPrefixMapping have not any help for dom builder
  4828. //localNSMap = null
  4829. if(el.closed){
  4830. domBuilder.endElement(ns,localName,tagName);
  4831. if(localNSMap){
  4832. for(prefix in localNSMap){
  4833. domBuilder.endPrefixMapping(prefix)
  4834. }
  4835. }
  4836. }else{
  4837. el.currentNSMap = currentNSMap;
  4838. el.localNSMap = localNSMap;
  4839. //parseStack.push(el);
  4840. return true;
  4841. }
  4842. }
  4843. function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
  4844. if(/^(?:script|textarea)$/i.test(tagName)){
  4845. var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
  4846. var text = source.substring(elStartEnd+1,elEndStart);
  4847. if(/[&<]/.test(text)){
  4848. if(/^script$/i.test(tagName)){
  4849. //if(!/\]\]>/.test(text)){
  4850. //lexHandler.startCDATA();
  4851. domBuilder.characters(text,0,text.length);
  4852. //lexHandler.endCDATA();
  4853. return elEndStart;
  4854. //}
  4855. }//}else{//text area
  4856. text = text.replace(/&#?\w+;/g,entityReplacer);
  4857. domBuilder.characters(text,0,text.length);
  4858. return elEndStart;
  4859. //}
  4860. }
  4861. }
  4862. return elStartEnd+1;
  4863. }
  4864. function fixSelfClosed(source,elStartEnd,tagName,closeMap){
  4865. //if(tagName in closeMap){
  4866. var pos = closeMap[tagName];
  4867. if(pos == null){
  4868. //console.log(tagName)
  4869. pos = source.lastIndexOf('</'+tagName+'>')
  4870. if(pos<elStartEnd){//忘记闭合
  4871. pos = source.lastIndexOf('</'+tagName)
  4872. }
  4873. closeMap[tagName] =pos
  4874. }
  4875. return pos<elStartEnd;
  4876. //}
  4877. }
  4878. function _copy(source,target){
  4879. for(var n in source){target[n] = source[n]}
  4880. }
  4881. function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
  4882. var next= source.charAt(start+2)
  4883. switch(next){
  4884. case '-':
  4885. if(source.charAt(start + 3) === '-'){
  4886. var end = source.indexOf('-->',start+4);
  4887. //append comment source.substring(4,end)//<!--
  4888. if(end>start){
  4889. domBuilder.comment(source,start+4,end-start-4);
  4890. return end+3;
  4891. }else{
  4892. errorHandler.error("Unclosed comment");
  4893. return -1;
  4894. }
  4895. }else{
  4896. //error
  4897. return -1;
  4898. }
  4899. default:
  4900. if(source.substr(start+3,6) == 'CDATA['){
  4901. var end = source.indexOf(']]>',start+9);
  4902. domBuilder.startCDATA();
  4903. domBuilder.characters(source,start+9,end-start-9);
  4904. domBuilder.endCDATA()
  4905. return end+3;
  4906. }
  4907. //<!DOCTYPE
  4908. //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
  4909. var matchs = split(source,start);
  4910. var len = matchs.length;
  4911. if(len>1 && /!doctype/i.test(matchs[0][0])){
  4912. var name = matchs[1][0];
  4913. var pubid = false;
  4914. var sysid = false;
  4915. if(len>3){
  4916. if(/^public$/i.test(matchs[2][0])){
  4917. pubid = matchs[3][0];
  4918. sysid = len>4 && matchs[4][0];
  4919. }else if(/^system$/i.test(matchs[2][0])){
  4920. sysid = matchs[3][0];
  4921. }
  4922. }
  4923. var lastMatch = matchs[len-1]
  4924. domBuilder.startDTD(name, pubid, sysid);
  4925. domBuilder.endDTD();
  4926. return lastMatch.index+lastMatch[0].length
  4927. }
  4928. }
  4929. return -1;
  4930. }
  4931. function parseInstruction(source,start,domBuilder){
  4932. var end = source.indexOf('?>',start);
  4933. if(end){
  4934. var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
  4935. if(match){
  4936. var len = match[0].length;
  4937. domBuilder.processingInstruction(match[1], match[2]) ;
  4938. return end+2;
  4939. }else{//error
  4940. return -1;
  4941. }
  4942. }
  4943. return -1;
  4944. }
  4945. function ElementAttributes(){
  4946. this.attributeNames = {}
  4947. }
  4948. ElementAttributes.prototype = {
  4949. setTagName:function(tagName){
  4950. if(!tagNamePattern.test(tagName)){
  4951. throw new Error('invalid tagName:'+tagName)
  4952. }
  4953. this.tagName = tagName
  4954. },
  4955. addValue:function(qName, value, offset) {
  4956. if(!tagNamePattern.test(qName)){
  4957. throw new Error('invalid attribute:'+qName)
  4958. }
  4959. this.attributeNames[qName] = this.length;
  4960. this[this.length++] = {qName:qName,value:value,offset:offset}
  4961. },
  4962. length:0,
  4963. getLocalName:function(i){return this[i].localName},
  4964. getLocator:function(i){return this[i].locator},
  4965. getQName:function(i){return this[i].qName},
  4966. getURI:function(i){return this[i].uri},
  4967. getValue:function(i){return this[i].value}
  4968. // ,getIndex:function(uri, localName)){
  4969. // if(localName){
  4970. //
  4971. // }else{
  4972. // var qName = uri
  4973. // }
  4974. // },
  4975. // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
  4976. // getType:function(uri,localName){}
  4977. // getType:function(i){},
  4978. }
  4979. function split(source,start){
  4980. var match;
  4981. var buf = [];
  4982. var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
  4983. reg.lastIndex = start;
  4984. reg.exec(source);//skip <
  4985. while(match = reg.exec(source)){
  4986. buf.push(match);
  4987. if(match[1])return buf;
  4988. }
  4989. }
  4990. exports.XMLReader = XMLReader;
  4991. exports.ParseError = ParseError;
  4992. /***/ }),
  4993. /* 16 */
  4994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4995. "use strict";
  4996. // ESM COMPAT FLAG
  4997. __webpack_require__.r(__webpack_exports__);
  4998. // EXPORTS
  4999. __webpack_require__.d(__webpack_exports__, "toKml", function() { return /* binding */ toKml; });
  5000. __webpack_require__.d(__webpack_exports__, "toGeoJSON", function() { return /* binding */ toGeoJSON; });
  5001. // EXTERNAL MODULE: ./node_modules/_jszip@3.7.0@jszip/dist/jszip.min.js
  5002. var jszip_min = __webpack_require__(5);
  5003. // EXTERNAL MODULE: ./src/conver/kmlToGeoJSON.js
  5004. var kmlToGeoJSON = __webpack_require__(0);
  5005. // CONCATENATED MODULE: ./src/conver/geoJSONToKml.js
  5006. //geojson => kml
  5007. function geoJSONToKml(geojson, options) {
  5008. options = options || {
  5009. documentName: undefined,
  5010. documentDescription: undefined,
  5011. name: 'name',
  5012. description: 'description',
  5013. simplestyle: false,
  5014. timestamp: 'timestamp'
  5015. };
  5016. return '<?xml version="1.0" encoding="UTF-8"?>' + tag('kml', tag('Document', documentName(options) + documentDescription(options) + root(geojson, options)), [['xmlns', 'http://www.opengis.net/kml/2.2']]);
  5017. }
  5018. function feature(options, styleHashesArray) {
  5019. return function (attr) {
  5020. if (!attr.properties || !geometry.valid(attr.geometry)) return '';
  5021. var geometryString = geometry.any(attr.geometry);
  5022. if (!geometryString) return '';
  5023. var styleDefinition = '',
  5024. styleReference = '';
  5025. if (options.simplestyle) {
  5026. var styleHash = hashStyle(attr.properties);
  5027. if (styleHash) {
  5028. if (geometry.isPoint(attr.geometry) && hasMarkerStyle(attr.properties)) {
  5029. if (styleHashesArray.indexOf(styleHash) === -1) {
  5030. styleDefinition = markerStyle(attr.properties, styleHash);
  5031. styleHashesArray.push(styleHash);
  5032. }
  5033. styleReference = tag('styleUrl', '#' + styleHash);
  5034. } else if ((geometry.isPolygon(attr.geometry) || geometry.isLine(attr.geometry)) && hasPolygonAndLineStyle(attr.properties)) {
  5035. if (styleHashesArray.indexOf(styleHash) === -1) {
  5036. styleDefinition = polygonAndLineStyle(attr.properties, styleHash);
  5037. styleHashesArray.push(styleHash);
  5038. }
  5039. styleReference = tag('styleUrl', '#' + styleHash);
  5040. } // Note that style of GeometryCollection / MultiGeometry is not supported
  5041. }
  5042. }
  5043. return styleDefinition + tag('Placemark', geoJSONToKml_name(attr.properties, options) + description(attr.properties, options) + extendeddata(attr.properties) + timestamp(attr.properties, options) + geometryString + styleReference);
  5044. };
  5045. }
  5046. function root(attr, options) {
  5047. if (!attr.type) return '';
  5048. var styleHashesArray = [];
  5049. switch (attr.type) {
  5050. case 'FeatureCollection':
  5051. if (!attr.features) return '';
  5052. return attr.features.map(feature(options, styleHashesArray)).join('');
  5053. case 'Feature':
  5054. return feature(options, styleHashesArray)(attr);
  5055. default:
  5056. return feature(options, styleHashesArray)({
  5057. type: 'Feature',
  5058. geometry: attr,
  5059. properties: {}
  5060. });
  5061. }
  5062. }
  5063. function documentName(options) {
  5064. return options.documentName !== undefined ? tag('name', options.documentName) : '';
  5065. }
  5066. function documentDescription(options) {
  5067. return options.documentDescription !== undefined ? tag('description', options.documentDescription) : '';
  5068. }
  5069. function geoJSONToKml_name(attr, options) {
  5070. return attr[options.name] ? tag('name', encode(attr[options.name])) : '';
  5071. }
  5072. function description(attr, options) {
  5073. return attr[options.description] ? tag('description', encode(attr[options.description])) : '';
  5074. }
  5075. function timestamp(attr, options) {
  5076. return attr[options.timestamp] ? tag('TimeStamp', tag('when', encode(attr[options.timestamp]))) : '';
  5077. } // ## Geometry Types
  5078. //
  5079. // https://developers.google.com/kml/documentation/kmlreference#geometry
  5080. var geometry = {
  5081. Point: function Point(attr) {
  5082. return tag('Point', tag('coordinates', attr.coordinates.join(',')));
  5083. },
  5084. LineString: function LineString(attr) {
  5085. return tag('LineString', tag('coordinates', linearring(attr.coordinates)));
  5086. },
  5087. Polygon: function Polygon(attr) {
  5088. if (!attr.coordinates.length) return '';
  5089. var outer = attr.coordinates[0],
  5090. inner = attr.coordinates.slice(1),
  5091. outerRing = tag('outerBoundaryIs', tag('LinearRing', tag('coordinates', linearring(outer)))),
  5092. innerRings = inner.map(function (i) {
  5093. return tag('innerBoundaryIs', tag('LinearRing', tag('coordinates', linearring(i))));
  5094. }).join('');
  5095. return tag('Polygon', outerRing + innerRings);
  5096. },
  5097. MultiPoint: function MultiPoint(attr) {
  5098. if (!attr.coordinates.length) return '';
  5099. return tag('MultiGeometry', attr.coordinates.map(function (c) {
  5100. return geometry.Point({
  5101. coordinates: c
  5102. });
  5103. }).join(''));
  5104. },
  5105. MultiPolygon: function MultiPolygon(attr) {
  5106. if (!attr.coordinates.length) return '';
  5107. return tag('MultiGeometry', attr.coordinates.map(function (c) {
  5108. return geometry.Polygon({
  5109. coordinates: c
  5110. });
  5111. }).join(''));
  5112. },
  5113. MultiLineString: function MultiLineString(attr) {
  5114. if (!attr.coordinates.length) return '';
  5115. return tag('MultiGeometry', attr.coordinates.map(function (c) {
  5116. return geometry.LineString({
  5117. coordinates: c
  5118. });
  5119. }).join(''));
  5120. },
  5121. GeometryCollection: function GeometryCollection(attr) {
  5122. return tag('MultiGeometry', attr.geometries.map(geometry.any).join(''));
  5123. },
  5124. valid: function valid(attr) {
  5125. return attr && attr.type && (attr.coordinates || attr.type === 'GeometryCollection' && attr.geometries && attr.geometries.every(geometry.valid));
  5126. },
  5127. any: function any(attr) {
  5128. if (geometry[attr.type]) {
  5129. return geometry[attr.type](attr);
  5130. } else {
  5131. return '';
  5132. }
  5133. },
  5134. isPoint: function isPoint(attr) {
  5135. return attr.type === 'Point' || attr.type === 'MultiPoint';
  5136. },
  5137. isPolygon: function isPolygon(attr) {
  5138. return attr.type === 'Polygon' || attr.type === 'MultiPolygon';
  5139. },
  5140. isLine: function isLine(attr) {
  5141. return attr.type === 'LineString' || attr.type === 'MultiLineString';
  5142. }
  5143. };
  5144. function linearring(attr) {
  5145. return attr.map(function (cds) {
  5146. return cds.join(',');
  5147. }).join(' ');
  5148. } // ## Data
  5149. function extendeddata(attr) {
  5150. var arr = [];
  5151. for (var i in attr) {
  5152. var val = attr[i];
  5153. if (isObject(val)) {
  5154. arr.push("<Data name =\"".concat(i, "\"><value>").concat(JSON.stringify(val), "</value></Data>"));
  5155. } else {
  5156. arr.push("<Data name =\"".concat(i, "\"><value>").concat(val, "</value></Data>"));
  5157. }
  5158. }
  5159. return tag('ExtendedData', arr.join(''));
  5160. }
  5161. function data(attr) {
  5162. return tag('Data', tag('value', encode(attr[1])), [['name', encode(attr[0])]]);
  5163. } // ## Marker style
  5164. function hasMarkerStyle(attr) {
  5165. return !!(attr['marker-size'] || attr['marker-symbol'] || attr['marker-color']);
  5166. }
  5167. function markerStyle(attr, styleHash) {
  5168. return tag('Style', tag('IconStyle', tag('Icon', tag('href', iconUrl(attr)))) + iconSize(attr), [['id', styleHash]]);
  5169. }
  5170. function iconUrl(attr) {
  5171. return attr['marker-symbol']; // var size = attr['marker-size'] || 'medium',
  5172. // symbol = attr['marker-symbol'] ? '-' + attr['marker-symbol'] : '',
  5173. // color = (attr['marker-color'] || '7e7e7e').replace('#', '')
  5174. // return 'https://api.tiles.mapbox.com/v3/marker/' + 'pin-' + size.charAt(0) + symbol + '+' + color + '.png'
  5175. }
  5176. function iconSize(attr) {
  5177. return tag('hotSpot', '', [['xunits', 'fraction'], ['yunits', 'fraction'], ['x', 0.5], ['y', 0.5]]);
  5178. } // ## Polygon and Line style
  5179. function hasPolygonAndLineStyle(attr) {
  5180. for (var key in attr) {
  5181. if ({
  5182. stroke: true,
  5183. 'stroke-opacity': true,
  5184. 'stroke-width': true,
  5185. fill: true,
  5186. 'fill-opacity': true
  5187. }[key]) return true;
  5188. }
  5189. }
  5190. function polygonAndLineStyle(attr, styleHash) {
  5191. var lineStyle = tag('LineStyle', [tag('color', hexToKmlColor(attr['stroke'], attr['stroke-opacity']) || 'ff555555') + tag('width', attr['stroke-width'] === undefined ? 2 : attr['stroke-width'])]);
  5192. var polyStyle = '';
  5193. if (attr['fill'] || attr['fill-opacity']) {
  5194. polyStyle = tag('PolyStyle', [tag('color', hexToKmlColor(attr['fill'], attr['fill-opacity']) || '88555555')]);
  5195. }
  5196. return tag('Style', lineStyle + polyStyle, [['id', styleHash]]);
  5197. } // ## Style helpers
  5198. function hashStyle(attr) {
  5199. var hash = '';
  5200. if (attr['marker-symbol']) hash = hash + 'ms' + attr['marker-symbol'];
  5201. if (attr['marker-color']) hash = hash + 'mc' + attr['marker-color'].replace('#', '');
  5202. if (attr['marker-size']) hash = hash + 'ms' + attr['marker-size'];
  5203. if (attr['stroke']) hash = hash + 's' + attr['stroke'].replace('#', '');
  5204. if (attr['stroke-width']) hash = hash + 'sw' + attr['stroke-width'].toString().replace('.', '');
  5205. if (attr['stroke-opacity']) hash = hash + 'mo' + attr['stroke-opacity'].toString().replace('.', '');
  5206. if (attr['fill']) hash = hash + 'f' + attr['fill'].replace('#', '');
  5207. if (attr['fill-opacity']) hash = hash + 'fo' + attr['fill-opacity'].toString().replace('.', '');
  5208. return hash;
  5209. }
  5210. function hexToKmlColor(hexColor, opacity) {
  5211. if (typeof hexColor !== 'string') return '';
  5212. hexColor = hexColor.replace('#', '').toLowerCase();
  5213. if (hexColor.length === 3) {
  5214. hexColor = hexColor[0] + hexColor[0] + hexColor[1] + hexColor[1] + hexColor[2] + hexColor[2];
  5215. } else if (hexColor.length !== 6) {
  5216. return '';
  5217. }
  5218. var r = hexColor[0] + hexColor[1];
  5219. var g = hexColor[2] + hexColor[3];
  5220. var b = hexColor[4] + hexColor[5];
  5221. var o = 'ff';
  5222. if (typeof opacity === 'number' && opacity >= 0.0 && opacity <= 1.0) {
  5223. o = (opacity * 255).toString(16);
  5224. if (o.indexOf('.') > -1) o = o.substr(0, o.indexOf('.'));
  5225. if (o.length < 2) o = '0' + o;
  5226. }
  5227. return o + b + g + r;
  5228. }
  5229. /**
  5230. * 判断对象是否为Object类型
  5231. * @param {*} obj 对象
  5232. * @returns {Boolean} 是否为Object类型
  5233. */
  5234. function isObject(obj) {
  5235. return Object.prototype.toString.call(obj) === '[object Object]';
  5236. }
  5237. /**
  5238. * @param {string} attr a string of attribute
  5239. * @returns {string}
  5240. */
  5241. function encode(attr) {
  5242. if (!attr) return '';
  5243. return attr.toString().replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
  5244. }
  5245. /**
  5246. * @param {array} attr an array of attributes
  5247. * @returns {string}
  5248. */
  5249. function attr(attributes) {
  5250. if (!Object.keys(attributes).length) return '';
  5251. return ' ' + Object.keys(attributes).map(function (key) {
  5252. return key + '="' + geoJSONToKml_escape(attributes[key]) + '"';
  5253. }).join(' ');
  5254. }
  5255. var escape_map = {
  5256. '>': '&gt;',
  5257. '<': '&lt;',
  5258. "'": '&apos;',
  5259. '"': '&quot;',
  5260. '&': '&amp;'
  5261. };
  5262. function geoJSONToKml_escape(string, ignore) {
  5263. var pattern;
  5264. if (string === null || string === undefined) return;
  5265. ignore = (ignore || '').replace(/[^&"<>\']/g, '');
  5266. pattern = '([&"<>\'])'.replace(new RegExp('[' + ignore + ']', 'g'), '');
  5267. return string.replace(new RegExp(pattern, 'g'), function (str, item) {
  5268. return escape_map[item];
  5269. });
  5270. }
  5271. /**
  5272. * @param {string} el element name
  5273. * @param {string} contents innerXML
  5274. * @param {array} attributes array of pairs
  5275. * @returns {string}
  5276. */
  5277. function tag(el, attributes, contents) {
  5278. if (Array.isArray(attributes) || typeof attributes === 'string') {
  5279. contents = attributes;
  5280. attributes = {};
  5281. }
  5282. if (Array.isArray(contents)) contents = '\n' + contents.map(function (content) {
  5283. return ' ' + content;
  5284. }).join('\n') + '\n';
  5285. return '<' + el + attr(attributes) + '>' + contents + '</' + el + '>';
  5286. }
  5287. // CONCATENATED MODULE: ./src/index.js
  5288. //geojson转kml
  5289. function toKml(geojson, options) {
  5290. if (geojson.features) {
  5291. geojson.features.forEach(function (feature) {
  5292. if (!feature.properties) return;
  5293. var style = feature.properties.style;
  5294. if (style) {
  5295. if (style.image) {
  5296. feature.properties['marker-symbol'] = style.image;
  5297. if (style.outlineColor) feature.properties['marker-color'] = style.outlineColor;
  5298. return;
  5299. }
  5300. if (style.color) {
  5301. feature.properties['fill'] = style.color;
  5302. if (style.opacity) feature.properties['fill-opacity'] = style.opacity;
  5303. }
  5304. if (style.outlineColor) {
  5305. var _style$outlineWidth, _ref, _style$outlineOpacity;
  5306. feature.properties['stroke'] = style.outlineColor;
  5307. feature.properties['stroke-width'] = (_style$outlineWidth = style.outlineWidth) !== null && _style$outlineWidth !== void 0 ? _style$outlineWidth : 1;
  5308. feature.properties['stroke-opacity'] = (_ref = (_style$outlineOpacity = style.outlineOpacity) !== null && _style$outlineOpacity !== void 0 ? _style$outlineOpacity : style.opacity) !== null && _ref !== void 0 ? _ref : 1.0;
  5309. }
  5310. }
  5311. });
  5312. }
  5313. return geoJSONToKml(geojson, options);
  5314. }
  5315. var getDom = function getDom(xml) {
  5316. return new DOMParser().parseFromString(xml, 'text/xml');
  5317. };
  5318. var getExtension = function getExtension(fileName) {
  5319. return fileName.split('.').pop();
  5320. };
  5321. var src_getKmlDom = function getKmlDom(kmzFile) {
  5322. var zip = new jszip_min();
  5323. return zip.loadAsync(kmzFile).then(function (zip) {
  5324. var kmlDom = null;
  5325. zip.forEach(function (relPath, file) {
  5326. if (getExtension(relPath) === 'kml' && kmlDom === null) {
  5327. kmlDom = file.async('string').then(getDom);
  5328. }
  5329. });
  5330. return kmlDom || Promise.reject('No kml file found');
  5331. });
  5332. }; //kml转geojson
  5333. function toGeoJSON(doc) {
  5334. if (!doc) return Promise.reject('参数不能为空');
  5335. if (isString(doc)) {
  5336. var extension = getExtension(doc);
  5337. if (extension === 'kml') {
  5338. return Cesium.Resource.fetchXML(doc).then(function (kmlDom) {
  5339. return Object(kmlToGeoJSON["a" /* kmlToGeoJSON */])(kmlDom);
  5340. });
  5341. } else if (extension === 'kmz') {
  5342. return Cesium.Resource.fetchBlob(doc).then(function (xml) {
  5343. return src_getKmlDom(xml);
  5344. }).then(function (kmlDom) {
  5345. return Object(kmlToGeoJSON["a" /* kmlToGeoJSON */])(kmlDom);
  5346. });
  5347. } else {
  5348. //直接传kml字符串文档
  5349. var geojson = Object(kmlToGeoJSON["a" /* kmlToGeoJSON */])(getDom(doc));
  5350. return Promise.resolve(geojson);
  5351. }
  5352. } else if (doc.getRootNode) {
  5353. //直接传docmect文档
  5354. var _geojson = Object(kmlToGeoJSON["a" /* kmlToGeoJSON */])(doc);
  5355. return Promise.resolve(_geojson);
  5356. } else {
  5357. //直接传blob
  5358. return src_getKmlDom(doc).then(function (kmlDom) {
  5359. return Object(kmlToGeoJSON["a" /* kmlToGeoJSON */])(kmlDom);
  5360. });
  5361. }
  5362. }
  5363. function isString(str) {
  5364. return typeof str == 'string' && str.constructor == String;
  5365. }
  5366. /***/ })
  5367. /******/ ]);
  5368. });