immutable.es.js 158 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015
  1. /**
  2. * MIT License
  3. *
  4. * Copyright (c) 2014-present, Lee Byron and other contributors.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. var DELETE = 'delete';
  25. // Constants describing the size of trie nodes.
  26. var SHIFT = 5; // Resulted in best performance after ______?
  27. var SIZE = 1 << SHIFT;
  28. var MASK = SIZE - 1;
  29. // A consistent shared value representing "not set" which equals nothing other
  30. // than itself, and nothing that could be provided externally.
  31. var NOT_SET = {};
  32. // Boolean references, Rough equivalent of `bool &`.
  33. function MakeRef() {
  34. return { value: false };
  35. }
  36. function SetRef(ref) {
  37. if (ref) {
  38. ref.value = true;
  39. }
  40. }
  41. // A function which returns a value representing an "owner" for transient writes
  42. // to tries. The return value will only ever equal itself, and will not equal
  43. // the return of any subsequent call of this function.
  44. function OwnerID() {}
  45. function ensureSize(iter) {
  46. if (iter.size === undefined) {
  47. iter.size = iter.__iterate(returnTrue);
  48. }
  49. return iter.size;
  50. }
  51. function wrapIndex(iter, index) {
  52. // This implements "is array index" which the ECMAString spec defines as:
  53. //
  54. // A String property name P is an array index if and only if
  55. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  56. // to 2^32−1.
  57. //
  58. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  59. if (typeof index !== 'number') {
  60. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  61. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  62. return NaN;
  63. }
  64. index = uint32Index;
  65. }
  66. return index < 0 ? ensureSize(iter) + index : index;
  67. }
  68. function returnTrue() {
  69. return true;
  70. }
  71. function wholeSlice(begin, end, size) {
  72. return (
  73. ((begin === 0 && !isNeg(begin)) ||
  74. (size !== undefined && begin <= -size)) &&
  75. (end === undefined || (size !== undefined && end >= size))
  76. );
  77. }
  78. function resolveBegin(begin, size) {
  79. return resolveIndex(begin, size, 0);
  80. }
  81. function resolveEnd(end, size) {
  82. return resolveIndex(end, size, size);
  83. }
  84. function resolveIndex(index, size, defaultIndex) {
  85. // Sanitize indices using this shorthand for ToInt32(argument)
  86. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  87. return index === undefined
  88. ? defaultIndex
  89. : isNeg(index)
  90. ? size === Infinity
  91. ? size
  92. : Math.max(0, size + index) | 0
  93. : size === undefined || size === index
  94. ? index
  95. : Math.min(size, index) | 0;
  96. }
  97. function isNeg(value) {
  98. // Account for -0 which is negative, but not less than 0.
  99. return value < 0 || (value === 0 && 1 / value === -Infinity);
  100. }
  101. var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
  102. function isCollection(maybeCollection) {
  103. return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
  104. }
  105. var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';
  106. function isKeyed(maybeKeyed) {
  107. return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
  108. }
  109. var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';
  110. function isIndexed(maybeIndexed) {
  111. return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
  112. }
  113. function isAssociative(maybeAssociative) {
  114. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  115. }
  116. var Collection = function Collection(value) {
  117. // eslint-disable-next-line no-constructor-return
  118. return isCollection(value) ? value : Seq(value);
  119. };
  120. var KeyedCollection = /*@__PURE__*/(function (Collection) {
  121. function KeyedCollection(value) {
  122. // eslint-disable-next-line no-constructor-return
  123. return isKeyed(value) ? value : KeyedSeq(value);
  124. }
  125. if ( Collection ) KeyedCollection.__proto__ = Collection;
  126. KeyedCollection.prototype = Object.create( Collection && Collection.prototype );
  127. KeyedCollection.prototype.constructor = KeyedCollection;
  128. return KeyedCollection;
  129. }(Collection));
  130. var IndexedCollection = /*@__PURE__*/(function (Collection) {
  131. function IndexedCollection(value) {
  132. // eslint-disable-next-line no-constructor-return
  133. return isIndexed(value) ? value : IndexedSeq(value);
  134. }
  135. if ( Collection ) IndexedCollection.__proto__ = Collection;
  136. IndexedCollection.prototype = Object.create( Collection && Collection.prototype );
  137. IndexedCollection.prototype.constructor = IndexedCollection;
  138. return IndexedCollection;
  139. }(Collection));
  140. var SetCollection = /*@__PURE__*/(function (Collection) {
  141. function SetCollection(value) {
  142. // eslint-disable-next-line no-constructor-return
  143. return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
  144. }
  145. if ( Collection ) SetCollection.__proto__ = Collection;
  146. SetCollection.prototype = Object.create( Collection && Collection.prototype );
  147. SetCollection.prototype.constructor = SetCollection;
  148. return SetCollection;
  149. }(Collection));
  150. Collection.Keyed = KeyedCollection;
  151. Collection.Indexed = IndexedCollection;
  152. Collection.Set = SetCollection;
  153. var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';
  154. function isSeq(maybeSeq) {
  155. return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
  156. }
  157. var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
  158. function isRecord(maybeRecord) {
  159. return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
  160. }
  161. function isImmutable(maybeImmutable) {
  162. return isCollection(maybeImmutable) || isRecord(maybeImmutable);
  163. }
  164. var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';
  165. function isOrdered(maybeOrdered) {
  166. return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
  167. }
  168. var ITERATE_KEYS = 0;
  169. var ITERATE_VALUES = 1;
  170. var ITERATE_ENTRIES = 2;
  171. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  172. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  173. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  174. var Iterator = function Iterator(next) {
  175. this.next = next;
  176. };
  177. Iterator.prototype.toString = function toString () {
  178. return '[Iterator]';
  179. };
  180. Iterator.KEYS = ITERATE_KEYS;
  181. Iterator.VALUES = ITERATE_VALUES;
  182. Iterator.ENTRIES = ITERATE_ENTRIES;
  183. Iterator.prototype.inspect = Iterator.prototype.toSource = function () {
  184. return this.toString();
  185. };
  186. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  187. return this;
  188. };
  189. function iteratorValue(type, k, v, iteratorResult) {
  190. var value = type === 0 ? k : type === 1 ? v : [k, v];
  191. iteratorResult
  192. ? (iteratorResult.value = value)
  193. : (iteratorResult = {
  194. value: value,
  195. done: false,
  196. });
  197. return iteratorResult;
  198. }
  199. function iteratorDone() {
  200. return { value: undefined, done: true };
  201. }
  202. function hasIterator(maybeIterable) {
  203. if (Array.isArray(maybeIterable)) {
  204. // IE11 trick as it does not support `Symbol.iterator`
  205. return true;
  206. }
  207. return !!getIteratorFn(maybeIterable);
  208. }
  209. function isIterator(maybeIterator) {
  210. return maybeIterator && typeof maybeIterator.next === 'function';
  211. }
  212. function getIterator(iterable) {
  213. var iteratorFn = getIteratorFn(iterable);
  214. return iteratorFn && iteratorFn.call(iterable);
  215. }
  216. function getIteratorFn(iterable) {
  217. var iteratorFn =
  218. iterable &&
  219. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  220. iterable[FAUX_ITERATOR_SYMBOL]);
  221. if (typeof iteratorFn === 'function') {
  222. return iteratorFn;
  223. }
  224. }
  225. function isEntriesIterable(maybeIterable) {
  226. var iteratorFn = getIteratorFn(maybeIterable);
  227. return iteratorFn && iteratorFn === maybeIterable.entries;
  228. }
  229. function isKeysIterable(maybeIterable) {
  230. var iteratorFn = getIteratorFn(maybeIterable);
  231. return iteratorFn && iteratorFn === maybeIterable.keys;
  232. }
  233. var hasOwnProperty = Object.prototype.hasOwnProperty;
  234. function isArrayLike(value) {
  235. if (Array.isArray(value) || typeof value === 'string') {
  236. return true;
  237. }
  238. return (
  239. value &&
  240. typeof value === 'object' &&
  241. Number.isInteger(value.length) &&
  242. value.length >= 0 &&
  243. (value.length === 0
  244. ? // Only {length: 0} is considered Array-like.
  245. Object.keys(value).length === 1
  246. : // An object is only Array-like if it has a property where the last value
  247. // in the array-like may be found (which could be undefined).
  248. value.hasOwnProperty(value.length - 1))
  249. );
  250. }
  251. var Seq = /*@__PURE__*/(function (Collection) {
  252. function Seq(value) {
  253. // eslint-disable-next-line no-constructor-return
  254. return value === undefined || value === null
  255. ? emptySequence()
  256. : isImmutable(value)
  257. ? value.toSeq()
  258. : seqFromValue(value);
  259. }
  260. if ( Collection ) Seq.__proto__ = Collection;
  261. Seq.prototype = Object.create( Collection && Collection.prototype );
  262. Seq.prototype.constructor = Seq;
  263. Seq.prototype.toSeq = function toSeq () {
  264. return this;
  265. };
  266. Seq.prototype.toString = function toString () {
  267. return this.__toString('Seq {', '}');
  268. };
  269. Seq.prototype.cacheResult = function cacheResult () {
  270. if (!this._cache && this.__iterateUncached) {
  271. this._cache = this.entrySeq().toArray();
  272. this.size = this._cache.length;
  273. }
  274. return this;
  275. };
  276. // abstract __iterateUncached(fn, reverse)
  277. Seq.prototype.__iterate = function __iterate (fn, reverse) {
  278. var cache = this._cache;
  279. if (cache) {
  280. var size = cache.length;
  281. var i = 0;
  282. while (i !== size) {
  283. var entry = cache[reverse ? size - ++i : i++];
  284. if (fn(entry[1], entry[0], this) === false) {
  285. break;
  286. }
  287. }
  288. return i;
  289. }
  290. return this.__iterateUncached(fn, reverse);
  291. };
  292. // abstract __iteratorUncached(type, reverse)
  293. Seq.prototype.__iterator = function __iterator (type, reverse) {
  294. var cache = this._cache;
  295. if (cache) {
  296. var size = cache.length;
  297. var i = 0;
  298. return new Iterator(function () {
  299. if (i === size) {
  300. return iteratorDone();
  301. }
  302. var entry = cache[reverse ? size - ++i : i++];
  303. return iteratorValue(type, entry[0], entry[1]);
  304. });
  305. }
  306. return this.__iteratorUncached(type, reverse);
  307. };
  308. return Seq;
  309. }(Collection));
  310. var KeyedSeq = /*@__PURE__*/(function (Seq) {
  311. function KeyedSeq(value) {
  312. // eslint-disable-next-line no-constructor-return
  313. return value === undefined || value === null
  314. ? emptySequence().toKeyedSeq()
  315. : isCollection(value)
  316. ? isKeyed(value)
  317. ? value.toSeq()
  318. : value.fromEntrySeq()
  319. : isRecord(value)
  320. ? value.toSeq()
  321. : keyedSeqFromValue(value);
  322. }
  323. if ( Seq ) KeyedSeq.__proto__ = Seq;
  324. KeyedSeq.prototype = Object.create( Seq && Seq.prototype );
  325. KeyedSeq.prototype.constructor = KeyedSeq;
  326. KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () {
  327. return this;
  328. };
  329. return KeyedSeq;
  330. }(Seq));
  331. var IndexedSeq = /*@__PURE__*/(function (Seq) {
  332. function IndexedSeq(value) {
  333. // eslint-disable-next-line no-constructor-return
  334. return value === undefined || value === null
  335. ? emptySequence()
  336. : isCollection(value)
  337. ? isKeyed(value)
  338. ? value.entrySeq()
  339. : value.toIndexedSeq()
  340. : isRecord(value)
  341. ? value.toSeq().entrySeq()
  342. : indexedSeqFromValue(value);
  343. }
  344. if ( Seq ) IndexedSeq.__proto__ = Seq;
  345. IndexedSeq.prototype = Object.create( Seq && Seq.prototype );
  346. IndexedSeq.prototype.constructor = IndexedSeq;
  347. IndexedSeq.of = function of (/*...values*/) {
  348. return IndexedSeq(arguments);
  349. };
  350. IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () {
  351. return this;
  352. };
  353. IndexedSeq.prototype.toString = function toString () {
  354. return this.__toString('Seq [', ']');
  355. };
  356. return IndexedSeq;
  357. }(Seq));
  358. var SetSeq = /*@__PURE__*/(function (Seq) {
  359. function SetSeq(value) {
  360. // eslint-disable-next-line no-constructor-return
  361. return (
  362. isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value)
  363. ).toSetSeq();
  364. }
  365. if ( Seq ) SetSeq.__proto__ = Seq;
  366. SetSeq.prototype = Object.create( Seq && Seq.prototype );
  367. SetSeq.prototype.constructor = SetSeq;
  368. SetSeq.of = function of (/*...values*/) {
  369. return SetSeq(arguments);
  370. };
  371. SetSeq.prototype.toSetSeq = function toSetSeq () {
  372. return this;
  373. };
  374. return SetSeq;
  375. }(Seq));
  376. Seq.isSeq = isSeq;
  377. Seq.Keyed = KeyedSeq;
  378. Seq.Set = SetSeq;
  379. Seq.Indexed = IndexedSeq;
  380. Seq.prototype[IS_SEQ_SYMBOL] = true;
  381. // #pragma Root Sequences
  382. var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {
  383. function ArraySeq(array) {
  384. this._array = array;
  385. this.size = array.length;
  386. }
  387. if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq;
  388. ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  389. ArraySeq.prototype.constructor = ArraySeq;
  390. ArraySeq.prototype.get = function get (index, notSetValue) {
  391. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  392. };
  393. ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {
  394. var array = this._array;
  395. var size = array.length;
  396. var i = 0;
  397. while (i !== size) {
  398. var ii = reverse ? size - ++i : i++;
  399. if (fn(array[ii], ii, this) === false) {
  400. break;
  401. }
  402. }
  403. return i;
  404. };
  405. ArraySeq.prototype.__iterator = function __iterator (type, reverse) {
  406. var array = this._array;
  407. var size = array.length;
  408. var i = 0;
  409. return new Iterator(function () {
  410. if (i === size) {
  411. return iteratorDone();
  412. }
  413. var ii = reverse ? size - ++i : i++;
  414. return iteratorValue(type, ii, array[ii]);
  415. });
  416. };
  417. return ArraySeq;
  418. }(IndexedSeq));
  419. var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {
  420. function ObjectSeq(object) {
  421. var keys = Object.keys(object).concat(
  422. Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : []
  423. );
  424. this._object = object;
  425. this._keys = keys;
  426. this.size = keys.length;
  427. }
  428. if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq;
  429. ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  430. ObjectSeq.prototype.constructor = ObjectSeq;
  431. ObjectSeq.prototype.get = function get (key, notSetValue) {
  432. if (notSetValue !== undefined && !this.has(key)) {
  433. return notSetValue;
  434. }
  435. return this._object[key];
  436. };
  437. ObjectSeq.prototype.has = function has (key) {
  438. return hasOwnProperty.call(this._object, key);
  439. };
  440. ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
  441. var object = this._object;
  442. var keys = this._keys;
  443. var size = keys.length;
  444. var i = 0;
  445. while (i !== size) {
  446. var key = keys[reverse ? size - ++i : i++];
  447. if (fn(object[key], key, this) === false) {
  448. break;
  449. }
  450. }
  451. return i;
  452. };
  453. ObjectSeq.prototype.__iterator = function __iterator (type, reverse) {
  454. var object = this._object;
  455. var keys = this._keys;
  456. var size = keys.length;
  457. var i = 0;
  458. return new Iterator(function () {
  459. if (i === size) {
  460. return iteratorDone();
  461. }
  462. var key = keys[reverse ? size - ++i : i++];
  463. return iteratorValue(type, key, object[key]);
  464. });
  465. };
  466. return ObjectSeq;
  467. }(KeyedSeq));
  468. ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
  469. var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {
  470. function CollectionSeq(collection) {
  471. this._collection = collection;
  472. this.size = collection.length || collection.size;
  473. }
  474. if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq;
  475. CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  476. CollectionSeq.prototype.constructor = CollectionSeq;
  477. CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
  478. if (reverse) {
  479. return this.cacheResult().__iterate(fn, reverse);
  480. }
  481. var collection = this._collection;
  482. var iterator = getIterator(collection);
  483. var iterations = 0;
  484. if (isIterator(iterator)) {
  485. var step;
  486. while (!(step = iterator.next()).done) {
  487. if (fn(step.value, iterations++, this) === false) {
  488. break;
  489. }
  490. }
  491. }
  492. return iterations;
  493. };
  494. CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {
  495. if (reverse) {
  496. return this.cacheResult().__iterator(type, reverse);
  497. }
  498. var collection = this._collection;
  499. var iterator = getIterator(collection);
  500. if (!isIterator(iterator)) {
  501. return new Iterator(iteratorDone);
  502. }
  503. var iterations = 0;
  504. return new Iterator(function () {
  505. var step = iterator.next();
  506. return step.done ? step : iteratorValue(type, iterations++, step.value);
  507. });
  508. };
  509. return CollectionSeq;
  510. }(IndexedSeq));
  511. // # pragma Helper functions
  512. var EMPTY_SEQ;
  513. function emptySequence() {
  514. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  515. }
  516. function keyedSeqFromValue(value) {
  517. var seq = maybeIndexedSeqFromValue(value);
  518. if (seq) {
  519. return seq.fromEntrySeq();
  520. }
  521. if (typeof value === 'object') {
  522. return new ObjectSeq(value);
  523. }
  524. throw new TypeError(
  525. 'Expected Array or collection object of [k, v] entries, or keyed object: ' +
  526. value
  527. );
  528. }
  529. function indexedSeqFromValue(value) {
  530. var seq = maybeIndexedSeqFromValue(value);
  531. if (seq) {
  532. return seq;
  533. }
  534. throw new TypeError(
  535. 'Expected Array or collection object of values: ' + value
  536. );
  537. }
  538. function seqFromValue(value) {
  539. var seq = maybeIndexedSeqFromValue(value);
  540. if (seq) {
  541. return isEntriesIterable(value)
  542. ? seq.fromEntrySeq()
  543. : isKeysIterable(value)
  544. ? seq.toSetSeq()
  545. : seq;
  546. }
  547. if (typeof value === 'object') {
  548. return new ObjectSeq(value);
  549. }
  550. throw new TypeError(
  551. 'Expected Array or collection object of values, or keyed object: ' + value
  552. );
  553. }
  554. function maybeIndexedSeqFromValue(value) {
  555. return isArrayLike(value)
  556. ? new ArraySeq(value)
  557. : hasIterator(value)
  558. ? new CollectionSeq(value)
  559. : undefined;
  560. }
  561. var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@';
  562. function isMap(maybeMap) {
  563. return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
  564. }
  565. function isOrderedMap(maybeOrderedMap) {
  566. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  567. }
  568. function isValueObject(maybeValue) {
  569. return Boolean(
  570. maybeValue &&
  571. typeof maybeValue.equals === 'function' &&
  572. typeof maybeValue.hashCode === 'function'
  573. );
  574. }
  575. /**
  576. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  577. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  578. *
  579. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  580. * value, which is different from the algorithm described by
  581. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  582. *
  583. * This is extended further to allow Objects to describe the values they
  584. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  585. *
  586. * Note: because of this extension, the key equality of Immutable.Map and the
  587. * value equality of Immutable.Set will differ from ES6 Map and Set.
  588. *
  589. * ### Defining custom values
  590. *
  591. * The easiest way to describe the value an object represents is by implementing
  592. * `valueOf`. For example, `Date` represents a value by returning a unix
  593. * timestamp for `valueOf`:
  594. *
  595. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  596. * var date2 = new Date(1234567890000);
  597. * date1.valueOf(); // 1234567890000
  598. * assert( date1 !== date2 );
  599. * assert( Immutable.is( date1, date2 ) );
  600. *
  601. * Note: overriding `valueOf` may have other implications if you use this object
  602. * where JavaScript expects a primitive, such as implicit string coercion.
  603. *
  604. * For more complex types, especially collections, implementing `valueOf` may
  605. * not be performant. An alternative is to implement `equals` and `hashCode`.
  606. *
  607. * `equals` takes another object, presumably of similar type, and returns true
  608. * if it is equal. Equality is symmetrical, so the same result should be
  609. * returned if this and the argument are flipped.
  610. *
  611. * assert( a.equals(b) === b.equals(a) );
  612. *
  613. * `hashCode` returns a 32bit integer number representing the object which will
  614. * be used to determine how to store the value object in a Map or Set. You must
  615. * provide both or neither methods, one must not exist without the other.
  616. *
  617. * Also, an important relationship between these methods must be upheld: if two
  618. * values are equal, they *must* return the same hashCode. If the values are not
  619. * equal, they might have the same hashCode; this is called a hash collision,
  620. * and while undesirable for performance reasons, it is acceptable.
  621. *
  622. * if (a.equals(b)) {
  623. * assert( a.hashCode() === b.hashCode() );
  624. * }
  625. *
  626. * All Immutable collections are Value Objects: they implement `equals()`
  627. * and `hashCode()`.
  628. */
  629. function is(valueA, valueB) {
  630. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  631. return true;
  632. }
  633. if (!valueA || !valueB) {
  634. return false;
  635. }
  636. if (
  637. typeof valueA.valueOf === 'function' &&
  638. typeof valueB.valueOf === 'function'
  639. ) {
  640. valueA = valueA.valueOf();
  641. valueB = valueB.valueOf();
  642. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  643. return true;
  644. }
  645. if (!valueA || !valueB) {
  646. return false;
  647. }
  648. }
  649. return !!(
  650. isValueObject(valueA) &&
  651. isValueObject(valueB) &&
  652. valueA.equals(valueB)
  653. );
  654. }
  655. var imul =
  656. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2
  657. ? Math.imul
  658. : function imul(a, b) {
  659. a |= 0; // int
  660. b |= 0; // int
  661. var c = a & 0xffff;
  662. var d = b & 0xffff;
  663. // Shift by 0 fixes the sign on the high part.
  664. return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int
  665. };
  666. // v8 has an optimization for storing 31-bit signed numbers.
  667. // Values which have either 00 or 11 as the high order bits qualify.
  668. // This function drops the highest order bit in a signed number, maintaining
  669. // the sign bit.
  670. function smi(i32) {
  671. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  672. }
  673. var defaultValueOf = Object.prototype.valueOf;
  674. function hash(o) {
  675. if (o == null) {
  676. return hashNullish(o);
  677. }
  678. if (typeof o.hashCode === 'function') {
  679. // Drop any high bits from accidentally long hash codes.
  680. return smi(o.hashCode(o));
  681. }
  682. var v = valueOf(o);
  683. if (v == null) {
  684. return hashNullish(v);
  685. }
  686. switch (typeof v) {
  687. case 'boolean':
  688. // The hash values for built-in constants are a 1 value for each 5-byte
  689. // shift region expect for the first, which encodes the value. This
  690. // reduces the odds of a hash collision for these common values.
  691. return v ? 0x42108421 : 0x42108420;
  692. case 'number':
  693. return hashNumber(v);
  694. case 'string':
  695. return v.length > STRING_HASH_CACHE_MIN_STRLEN
  696. ? cachedHashString(v)
  697. : hashString(v);
  698. case 'object':
  699. case 'function':
  700. return hashJSObj(v);
  701. case 'symbol':
  702. return hashSymbol(v);
  703. default:
  704. if (typeof v.toString === 'function') {
  705. return hashString(v.toString());
  706. }
  707. throw new Error('Value type ' + typeof v + ' cannot be hashed.');
  708. }
  709. }
  710. function hashNullish(nullish) {
  711. return nullish === null ? 0x42108422 : /* undefined */ 0x42108423;
  712. }
  713. // Compress arbitrarily large numbers into smi hashes.
  714. function hashNumber(n) {
  715. if (n !== n || n === Infinity) {
  716. return 0;
  717. }
  718. var hash = n | 0;
  719. if (hash !== n) {
  720. hash ^= n * 0xffffffff;
  721. }
  722. while (n > 0xffffffff) {
  723. n /= 0xffffffff;
  724. hash ^= n;
  725. }
  726. return smi(hash);
  727. }
  728. function cachedHashString(string) {
  729. var hashed = stringHashCache[string];
  730. if (hashed === undefined) {
  731. hashed = hashString(string);
  732. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  733. STRING_HASH_CACHE_SIZE = 0;
  734. stringHashCache = {};
  735. }
  736. STRING_HASH_CACHE_SIZE++;
  737. stringHashCache[string] = hashed;
  738. }
  739. return hashed;
  740. }
  741. // http://jsperf.com/hashing-strings
  742. function hashString(string) {
  743. // This is the hash from JVM
  744. // The hash code for a string is computed as
  745. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  746. // where s[i] is the ith character of the string and n is the length of
  747. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  748. // (exclusive) by dropping high bits.
  749. var hashed = 0;
  750. for (var ii = 0; ii < string.length; ii++) {
  751. hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
  752. }
  753. return smi(hashed);
  754. }
  755. function hashSymbol(sym) {
  756. var hashed = symbolMap[sym];
  757. if (hashed !== undefined) {
  758. return hashed;
  759. }
  760. hashed = nextHash();
  761. symbolMap[sym] = hashed;
  762. return hashed;
  763. }
  764. function hashJSObj(obj) {
  765. var hashed;
  766. if (usingWeakMap) {
  767. hashed = weakMap.get(obj);
  768. if (hashed !== undefined) {
  769. return hashed;
  770. }
  771. }
  772. hashed = obj[UID_HASH_KEY];
  773. if (hashed !== undefined) {
  774. return hashed;
  775. }
  776. if (!canDefineProperty) {
  777. hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  778. if (hashed !== undefined) {
  779. return hashed;
  780. }
  781. hashed = getIENodeHash(obj);
  782. if (hashed !== undefined) {
  783. return hashed;
  784. }
  785. }
  786. hashed = nextHash();
  787. if (usingWeakMap) {
  788. weakMap.set(obj, hashed);
  789. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  790. throw new Error('Non-extensible objects are not allowed as keys.');
  791. } else if (canDefineProperty) {
  792. Object.defineProperty(obj, UID_HASH_KEY, {
  793. enumerable: false,
  794. configurable: false,
  795. writable: false,
  796. value: hashed,
  797. });
  798. } else if (
  799. obj.propertyIsEnumerable !== undefined &&
  800. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable
  801. ) {
  802. // Since we can't define a non-enumerable property on the object
  803. // we'll hijack one of the less-used non-enumerable properties to
  804. // save our hash on it. Since this is a function it will not show up in
  805. // `JSON.stringify` which is what we want.
  806. obj.propertyIsEnumerable = function () {
  807. return this.constructor.prototype.propertyIsEnumerable.apply(
  808. this,
  809. arguments
  810. );
  811. };
  812. obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
  813. } else if (obj.nodeType !== undefined) {
  814. // At this point we couldn't get the IE `uniqueID` to use as a hash
  815. // and we couldn't use a non-enumerable property to exploit the
  816. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  817. // itself.
  818. obj[UID_HASH_KEY] = hashed;
  819. } else {
  820. throw new Error('Unable to set a non-enumerable property on object.');
  821. }
  822. return hashed;
  823. }
  824. // Get references to ES5 object methods.
  825. var isExtensible = Object.isExtensible;
  826. // True if Object.defineProperty works as expected. IE8 fails this test.
  827. var canDefineProperty = (function () {
  828. try {
  829. Object.defineProperty({}, '@', {});
  830. return true;
  831. } catch (e) {
  832. return false;
  833. }
  834. })();
  835. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  836. // and avoid memory leaks from the IE cloneNode bug.
  837. function getIENodeHash(node) {
  838. if (node && node.nodeType > 0) {
  839. switch (node.nodeType) {
  840. case 1: // Element
  841. return node.uniqueID;
  842. case 9: // Document
  843. return node.documentElement && node.documentElement.uniqueID;
  844. }
  845. }
  846. }
  847. function valueOf(obj) {
  848. return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function'
  849. ? obj.valueOf(obj)
  850. : obj;
  851. }
  852. function nextHash() {
  853. var nextHash = ++_objHashUID;
  854. if (_objHashUID & 0x40000000) {
  855. _objHashUID = 0;
  856. }
  857. return nextHash;
  858. }
  859. // If possible, use a WeakMap.
  860. var usingWeakMap = typeof WeakMap === 'function';
  861. var weakMap;
  862. if (usingWeakMap) {
  863. weakMap = new WeakMap();
  864. }
  865. var symbolMap = Object.create(null);
  866. var _objHashUID = 0;
  867. var UID_HASH_KEY = '__immutablehash__';
  868. if (typeof Symbol === 'function') {
  869. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  870. }
  871. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  872. var STRING_HASH_CACHE_MAX_SIZE = 255;
  873. var STRING_HASH_CACHE_SIZE = 0;
  874. var stringHashCache = {};
  875. var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) {
  876. function ToKeyedSequence(indexed, useKeys) {
  877. this._iter = indexed;
  878. this._useKeys = useKeys;
  879. this.size = indexed.size;
  880. }
  881. if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq;
  882. ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  883. ToKeyedSequence.prototype.constructor = ToKeyedSequence;
  884. ToKeyedSequence.prototype.get = function get (key, notSetValue) {
  885. return this._iter.get(key, notSetValue);
  886. };
  887. ToKeyedSequence.prototype.has = function has (key) {
  888. return this._iter.has(key);
  889. };
  890. ToKeyedSequence.prototype.valueSeq = function valueSeq () {
  891. return this._iter.valueSeq();
  892. };
  893. ToKeyedSequence.prototype.reverse = function reverse () {
  894. var this$1$1 = this;
  895. var reversedSequence = reverseFactory(this, true);
  896. if (!this._useKeys) {
  897. reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); };
  898. }
  899. return reversedSequence;
  900. };
  901. ToKeyedSequence.prototype.map = function map (mapper, context) {
  902. var this$1$1 = this;
  903. var mappedSequence = mapFactory(this, mapper, context);
  904. if (!this._useKeys) {
  905. mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); };
  906. }
  907. return mappedSequence;
  908. };
  909. ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  910. var this$1$1 = this;
  911. return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse);
  912. };
  913. ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {
  914. return this._iter.__iterator(type, reverse);
  915. };
  916. return ToKeyedSequence;
  917. }(KeyedSeq));
  918. ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
  919. var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) {
  920. function ToIndexedSequence(iter) {
  921. this._iter = iter;
  922. this.size = iter.size;
  923. }
  924. if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq;
  925. ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  926. ToIndexedSequence.prototype.constructor = ToIndexedSequence;
  927. ToIndexedSequence.prototype.includes = function includes (value) {
  928. return this._iter.includes(value);
  929. };
  930. ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  931. var this$1$1 = this;
  932. var i = 0;
  933. reverse && ensureSize(this);
  934. return this._iter.__iterate(
  935. function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); },
  936. reverse
  937. );
  938. };
  939. ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {
  940. var this$1$1 = this;
  941. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  942. var i = 0;
  943. reverse && ensureSize(this);
  944. return new Iterator(function () {
  945. var step = iterator.next();
  946. return step.done
  947. ? step
  948. : iteratorValue(
  949. type,
  950. reverse ? this$1$1.size - ++i : i++,
  951. step.value,
  952. step
  953. );
  954. });
  955. };
  956. return ToIndexedSequence;
  957. }(IndexedSeq));
  958. var ToSetSequence = /*@__PURE__*/(function (SetSeq) {
  959. function ToSetSequence(iter) {
  960. this._iter = iter;
  961. this.size = iter.size;
  962. }
  963. if ( SetSeq ) ToSetSequence.__proto__ = SetSeq;
  964. ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype );
  965. ToSetSequence.prototype.constructor = ToSetSequence;
  966. ToSetSequence.prototype.has = function has (key) {
  967. return this._iter.includes(key);
  968. };
  969. ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {
  970. var this$1$1 = this;
  971. return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse);
  972. };
  973. ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {
  974. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  975. return new Iterator(function () {
  976. var step = iterator.next();
  977. return step.done
  978. ? step
  979. : iteratorValue(type, step.value, step.value, step);
  980. });
  981. };
  982. return ToSetSequence;
  983. }(SetSeq));
  984. var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) {
  985. function FromEntriesSequence(entries) {
  986. this._iter = entries;
  987. this.size = entries.size;
  988. }
  989. if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq;
  990. FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  991. FromEntriesSequence.prototype.constructor = FromEntriesSequence;
  992. FromEntriesSequence.prototype.entrySeq = function entrySeq () {
  993. return this._iter.toSeq();
  994. };
  995. FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {
  996. var this$1$1 = this;
  997. return this._iter.__iterate(function (entry) {
  998. // Check if entry exists first so array access doesn't throw for holes
  999. // in the parent iteration.
  1000. if (entry) {
  1001. validateEntry(entry);
  1002. var indexedCollection = isCollection(entry);
  1003. return fn(
  1004. indexedCollection ? entry.get(1) : entry[1],
  1005. indexedCollection ? entry.get(0) : entry[0],
  1006. this$1$1
  1007. );
  1008. }
  1009. }, reverse);
  1010. };
  1011. FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) {
  1012. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  1013. return new Iterator(function () {
  1014. while (true) {
  1015. var step = iterator.next();
  1016. if (step.done) {
  1017. return step;
  1018. }
  1019. var entry = step.value;
  1020. // Check if entry exists first so array access doesn't throw for holes
  1021. // in the parent iteration.
  1022. if (entry) {
  1023. validateEntry(entry);
  1024. var indexedCollection = isCollection(entry);
  1025. return iteratorValue(
  1026. type,
  1027. indexedCollection ? entry.get(0) : entry[0],
  1028. indexedCollection ? entry.get(1) : entry[1],
  1029. step
  1030. );
  1031. }
  1032. }
  1033. });
  1034. };
  1035. return FromEntriesSequence;
  1036. }(KeyedSeq));
  1037. ToIndexedSequence.prototype.cacheResult =
  1038. ToKeyedSequence.prototype.cacheResult =
  1039. ToSetSequence.prototype.cacheResult =
  1040. FromEntriesSequence.prototype.cacheResult =
  1041. cacheResultThrough;
  1042. function flipFactory(collection) {
  1043. var flipSequence = makeSequence(collection);
  1044. flipSequence._iter = collection;
  1045. flipSequence.size = collection.size;
  1046. flipSequence.flip = function () { return collection; };
  1047. flipSequence.reverse = function () {
  1048. var reversedSequence = collection.reverse.apply(this); // super.reverse()
  1049. reversedSequence.flip = function () { return collection.reverse(); };
  1050. return reversedSequence;
  1051. };
  1052. flipSequence.has = function (key) { return collection.includes(key); };
  1053. flipSequence.includes = function (key) { return collection.has(key); };
  1054. flipSequence.cacheResult = cacheResultThrough;
  1055. flipSequence.__iterateUncached = function (fn, reverse) {
  1056. var this$1$1 = this;
  1057. return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse);
  1058. };
  1059. flipSequence.__iteratorUncached = function (type, reverse) {
  1060. if (type === ITERATE_ENTRIES) {
  1061. var iterator = collection.__iterator(type, reverse);
  1062. return new Iterator(function () {
  1063. var step = iterator.next();
  1064. if (!step.done) {
  1065. var k = step.value[0];
  1066. step.value[0] = step.value[1];
  1067. step.value[1] = k;
  1068. }
  1069. return step;
  1070. });
  1071. }
  1072. return collection.__iterator(
  1073. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  1074. reverse
  1075. );
  1076. };
  1077. return flipSequence;
  1078. }
  1079. function mapFactory(collection, mapper, context) {
  1080. var mappedSequence = makeSequence(collection);
  1081. mappedSequence.size = collection.size;
  1082. mappedSequence.has = function (key) { return collection.has(key); };
  1083. mappedSequence.get = function (key, notSetValue) {
  1084. var v = collection.get(key, NOT_SET);
  1085. return v === NOT_SET
  1086. ? notSetValue
  1087. : mapper.call(context, v, key, collection);
  1088. };
  1089. mappedSequence.__iterateUncached = function (fn, reverse) {
  1090. var this$1$1 = this;
  1091. return collection.__iterate(
  1092. function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; },
  1093. reverse
  1094. );
  1095. };
  1096. mappedSequence.__iteratorUncached = function (type, reverse) {
  1097. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1098. return new Iterator(function () {
  1099. var step = iterator.next();
  1100. if (step.done) {
  1101. return step;
  1102. }
  1103. var entry = step.value;
  1104. var key = entry[0];
  1105. return iteratorValue(
  1106. type,
  1107. key,
  1108. mapper.call(context, entry[1], key, collection),
  1109. step
  1110. );
  1111. });
  1112. };
  1113. return mappedSequence;
  1114. }
  1115. function reverseFactory(collection, useKeys) {
  1116. var this$1$1 = this;
  1117. var reversedSequence = makeSequence(collection);
  1118. reversedSequence._iter = collection;
  1119. reversedSequence.size = collection.size;
  1120. reversedSequence.reverse = function () { return collection; };
  1121. if (collection.flip) {
  1122. reversedSequence.flip = function () {
  1123. var flipSequence = flipFactory(collection);
  1124. flipSequence.reverse = function () { return collection.flip(); };
  1125. return flipSequence;
  1126. };
  1127. }
  1128. reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); };
  1129. reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); };
  1130. reversedSequence.includes = function (value) { return collection.includes(value); };
  1131. reversedSequence.cacheResult = cacheResultThrough;
  1132. reversedSequence.__iterate = function (fn, reverse) {
  1133. var this$1$1 = this;
  1134. var i = 0;
  1135. reverse && ensureSize(collection);
  1136. return collection.__iterate(
  1137. function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); },
  1138. !reverse
  1139. );
  1140. };
  1141. reversedSequence.__iterator = function (type, reverse) {
  1142. var i = 0;
  1143. reverse && ensureSize(collection);
  1144. var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse);
  1145. return new Iterator(function () {
  1146. var step = iterator.next();
  1147. if (step.done) {
  1148. return step;
  1149. }
  1150. var entry = step.value;
  1151. return iteratorValue(
  1152. type,
  1153. useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++,
  1154. entry[1],
  1155. step
  1156. );
  1157. });
  1158. };
  1159. return reversedSequence;
  1160. }
  1161. function filterFactory(collection, predicate, context, useKeys) {
  1162. var filterSequence = makeSequence(collection);
  1163. if (useKeys) {
  1164. filterSequence.has = function (key) {
  1165. var v = collection.get(key, NOT_SET);
  1166. return v !== NOT_SET && !!predicate.call(context, v, key, collection);
  1167. };
  1168. filterSequence.get = function (key, notSetValue) {
  1169. var v = collection.get(key, NOT_SET);
  1170. return v !== NOT_SET && predicate.call(context, v, key, collection)
  1171. ? v
  1172. : notSetValue;
  1173. };
  1174. }
  1175. filterSequence.__iterateUncached = function (fn, reverse) {
  1176. var this$1$1 = this;
  1177. var iterations = 0;
  1178. collection.__iterate(function (v, k, c) {
  1179. if (predicate.call(context, v, k, c)) {
  1180. iterations++;
  1181. return fn(v, useKeys ? k : iterations - 1, this$1$1);
  1182. }
  1183. }, reverse);
  1184. return iterations;
  1185. };
  1186. filterSequence.__iteratorUncached = function (type, reverse) {
  1187. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1188. var iterations = 0;
  1189. return new Iterator(function () {
  1190. while (true) {
  1191. var step = iterator.next();
  1192. if (step.done) {
  1193. return step;
  1194. }
  1195. var entry = step.value;
  1196. var key = entry[0];
  1197. var value = entry[1];
  1198. if (predicate.call(context, value, key, collection)) {
  1199. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  1200. }
  1201. }
  1202. });
  1203. };
  1204. return filterSequence;
  1205. }
  1206. function countByFactory(collection, grouper, context) {
  1207. var groups = Map().asMutable();
  1208. collection.__iterate(function (v, k) {
  1209. groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; });
  1210. });
  1211. return groups.asImmutable();
  1212. }
  1213. function groupByFactory(collection, grouper, context) {
  1214. var isKeyedIter = isKeyed(collection);
  1215. var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable();
  1216. collection.__iterate(function (v, k) {
  1217. groups.update(
  1218. grouper.call(context, v, k, collection),
  1219. function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); }
  1220. );
  1221. });
  1222. var coerce = collectionClass(collection);
  1223. return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable();
  1224. }
  1225. function partitionFactory(collection, predicate, context) {
  1226. var isKeyedIter = isKeyed(collection);
  1227. var groups = [[], []];
  1228. collection.__iterate(function (v, k) {
  1229. groups[predicate.call(context, v, k, collection) ? 1 : 0].push(
  1230. isKeyedIter ? [k, v] : v
  1231. );
  1232. });
  1233. var coerce = collectionClass(collection);
  1234. return groups.map(function (arr) { return reify(collection, coerce(arr)); });
  1235. }
  1236. function sliceFactory(collection, begin, end, useKeys) {
  1237. var originalSize = collection.size;
  1238. if (wholeSlice(begin, end, originalSize)) {
  1239. return collection;
  1240. }
  1241. // begin or end can not be resolved if they were provided as negative numbers and
  1242. // this collection's size is unknown. In that case, cache first so there is
  1243. // a known size and these do not resolve to NaN.
  1244. if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) {
  1245. return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys);
  1246. }
  1247. var resolvedBegin = resolveBegin(begin, originalSize);
  1248. var resolvedEnd = resolveEnd(end, originalSize);
  1249. // Note: resolvedEnd is undefined when the original sequence's length is
  1250. // unknown and this slice did not supply an end and should contain all
  1251. // elements after resolvedBegin.
  1252. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  1253. var resolvedSize = resolvedEnd - resolvedBegin;
  1254. var sliceSize;
  1255. if (resolvedSize === resolvedSize) {
  1256. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  1257. }
  1258. var sliceSeq = makeSequence(collection);
  1259. // If collection.size is undefined, the size of the realized sliceSeq is
  1260. // unknown at this point unless the number of items to slice is 0
  1261. sliceSeq.size =
  1262. sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined;
  1263. if (!useKeys && isSeq(collection) && sliceSize >= 0) {
  1264. sliceSeq.get = function (index, notSetValue) {
  1265. index = wrapIndex(this, index);
  1266. return index >= 0 && index < sliceSize
  1267. ? collection.get(index + resolvedBegin, notSetValue)
  1268. : notSetValue;
  1269. };
  1270. }
  1271. sliceSeq.__iterateUncached = function (fn, reverse) {
  1272. var this$1$1 = this;
  1273. if (sliceSize === 0) {
  1274. return 0;
  1275. }
  1276. if (reverse) {
  1277. return this.cacheResult().__iterate(fn, reverse);
  1278. }
  1279. var skipped = 0;
  1280. var isSkipping = true;
  1281. var iterations = 0;
  1282. collection.__iterate(function (v, k) {
  1283. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  1284. iterations++;
  1285. return (
  1286. fn(v, useKeys ? k : iterations - 1, this$1$1) !== false &&
  1287. iterations !== sliceSize
  1288. );
  1289. }
  1290. });
  1291. return iterations;
  1292. };
  1293. sliceSeq.__iteratorUncached = function (type, reverse) {
  1294. if (sliceSize !== 0 && reverse) {
  1295. return this.cacheResult().__iterator(type, reverse);
  1296. }
  1297. // Don't bother instantiating parent iterator if taking 0.
  1298. if (sliceSize === 0) {
  1299. return new Iterator(iteratorDone);
  1300. }
  1301. var iterator = collection.__iterator(type, reverse);
  1302. var skipped = 0;
  1303. var iterations = 0;
  1304. return new Iterator(function () {
  1305. while (skipped++ < resolvedBegin) {
  1306. iterator.next();
  1307. }
  1308. if (++iterations > sliceSize) {
  1309. return iteratorDone();
  1310. }
  1311. var step = iterator.next();
  1312. if (useKeys || type === ITERATE_VALUES || step.done) {
  1313. return step;
  1314. }
  1315. if (type === ITERATE_KEYS) {
  1316. return iteratorValue(type, iterations - 1, undefined, step);
  1317. }
  1318. return iteratorValue(type, iterations - 1, step.value[1], step);
  1319. });
  1320. };
  1321. return sliceSeq;
  1322. }
  1323. function takeWhileFactory(collection, predicate, context) {
  1324. var takeSequence = makeSequence(collection);
  1325. takeSequence.__iterateUncached = function (fn, reverse) {
  1326. var this$1$1 = this;
  1327. if (reverse) {
  1328. return this.cacheResult().__iterate(fn, reverse);
  1329. }
  1330. var iterations = 0;
  1331. collection.__iterate(
  1332. function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); }
  1333. );
  1334. return iterations;
  1335. };
  1336. takeSequence.__iteratorUncached = function (type, reverse) {
  1337. var this$1$1 = this;
  1338. if (reverse) {
  1339. return this.cacheResult().__iterator(type, reverse);
  1340. }
  1341. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1342. var iterating = true;
  1343. return new Iterator(function () {
  1344. if (!iterating) {
  1345. return iteratorDone();
  1346. }
  1347. var step = iterator.next();
  1348. if (step.done) {
  1349. return step;
  1350. }
  1351. var entry = step.value;
  1352. var k = entry[0];
  1353. var v = entry[1];
  1354. if (!predicate.call(context, v, k, this$1$1)) {
  1355. iterating = false;
  1356. return iteratorDone();
  1357. }
  1358. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  1359. });
  1360. };
  1361. return takeSequence;
  1362. }
  1363. function skipWhileFactory(collection, predicate, context, useKeys) {
  1364. var skipSequence = makeSequence(collection);
  1365. skipSequence.__iterateUncached = function (fn, reverse) {
  1366. var this$1$1 = this;
  1367. if (reverse) {
  1368. return this.cacheResult().__iterate(fn, reverse);
  1369. }
  1370. var isSkipping = true;
  1371. var iterations = 0;
  1372. collection.__iterate(function (v, k, c) {
  1373. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  1374. iterations++;
  1375. return fn(v, useKeys ? k : iterations - 1, this$1$1);
  1376. }
  1377. });
  1378. return iterations;
  1379. };
  1380. skipSequence.__iteratorUncached = function (type, reverse) {
  1381. var this$1$1 = this;
  1382. if (reverse) {
  1383. return this.cacheResult().__iterator(type, reverse);
  1384. }
  1385. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1386. var skipping = true;
  1387. var iterations = 0;
  1388. return new Iterator(function () {
  1389. var step;
  1390. var k;
  1391. var v;
  1392. do {
  1393. step = iterator.next();
  1394. if (step.done) {
  1395. if (useKeys || type === ITERATE_VALUES) {
  1396. return step;
  1397. }
  1398. if (type === ITERATE_KEYS) {
  1399. return iteratorValue(type, iterations++, undefined, step);
  1400. }
  1401. return iteratorValue(type, iterations++, step.value[1], step);
  1402. }
  1403. var entry = step.value;
  1404. k = entry[0];
  1405. v = entry[1];
  1406. skipping && (skipping = predicate.call(context, v, k, this$1$1));
  1407. } while (skipping);
  1408. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  1409. });
  1410. };
  1411. return skipSequence;
  1412. }
  1413. function concatFactory(collection, values) {
  1414. var isKeyedCollection = isKeyed(collection);
  1415. var iters = [collection]
  1416. .concat(values)
  1417. .map(function (v) {
  1418. if (!isCollection(v)) {
  1419. v = isKeyedCollection
  1420. ? keyedSeqFromValue(v)
  1421. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  1422. } else if (isKeyedCollection) {
  1423. v = KeyedCollection(v);
  1424. }
  1425. return v;
  1426. })
  1427. .filter(function (v) { return v.size !== 0; });
  1428. if (iters.length === 0) {
  1429. return collection;
  1430. }
  1431. if (iters.length === 1) {
  1432. var singleton = iters[0];
  1433. if (
  1434. singleton === collection ||
  1435. (isKeyedCollection && isKeyed(singleton)) ||
  1436. (isIndexed(collection) && isIndexed(singleton))
  1437. ) {
  1438. return singleton;
  1439. }
  1440. }
  1441. var concatSeq = new ArraySeq(iters);
  1442. if (isKeyedCollection) {
  1443. concatSeq = concatSeq.toKeyedSeq();
  1444. } else if (!isIndexed(collection)) {
  1445. concatSeq = concatSeq.toSetSeq();
  1446. }
  1447. concatSeq = concatSeq.flatten(true);
  1448. concatSeq.size = iters.reduce(function (sum, seq) {
  1449. if (sum !== undefined) {
  1450. var size = seq.size;
  1451. if (size !== undefined) {
  1452. return sum + size;
  1453. }
  1454. }
  1455. }, 0);
  1456. return concatSeq;
  1457. }
  1458. function flattenFactory(collection, depth, useKeys) {
  1459. var flatSequence = makeSequence(collection);
  1460. flatSequence.__iterateUncached = function (fn, reverse) {
  1461. if (reverse) {
  1462. return this.cacheResult().__iterate(fn, reverse);
  1463. }
  1464. var iterations = 0;
  1465. var stopped = false;
  1466. function flatDeep(iter, currentDepth) {
  1467. iter.__iterate(function (v, k) {
  1468. if ((!depth || currentDepth < depth) && isCollection(v)) {
  1469. flatDeep(v, currentDepth + 1);
  1470. } else {
  1471. iterations++;
  1472. if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) {
  1473. stopped = true;
  1474. }
  1475. }
  1476. return !stopped;
  1477. }, reverse);
  1478. }
  1479. flatDeep(collection, 0);
  1480. return iterations;
  1481. };
  1482. flatSequence.__iteratorUncached = function (type, reverse) {
  1483. if (reverse) {
  1484. return this.cacheResult().__iterator(type, reverse);
  1485. }
  1486. var iterator = collection.__iterator(type, reverse);
  1487. var stack = [];
  1488. var iterations = 0;
  1489. return new Iterator(function () {
  1490. while (iterator) {
  1491. var step = iterator.next();
  1492. if (step.done !== false) {
  1493. iterator = stack.pop();
  1494. continue;
  1495. }
  1496. var v = step.value;
  1497. if (type === ITERATE_ENTRIES) {
  1498. v = v[1];
  1499. }
  1500. if ((!depth || stack.length < depth) && isCollection(v)) {
  1501. stack.push(iterator);
  1502. iterator = v.__iterator(type, reverse);
  1503. } else {
  1504. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  1505. }
  1506. }
  1507. return iteratorDone();
  1508. });
  1509. };
  1510. return flatSequence;
  1511. }
  1512. function flatMapFactory(collection, mapper, context) {
  1513. var coerce = collectionClass(collection);
  1514. return collection
  1515. .toSeq()
  1516. .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); })
  1517. .flatten(true);
  1518. }
  1519. function interposeFactory(collection, separator) {
  1520. var interposedSequence = makeSequence(collection);
  1521. interposedSequence.size = collection.size && collection.size * 2 - 1;
  1522. interposedSequence.__iterateUncached = function (fn, reverse) {
  1523. var this$1$1 = this;
  1524. var iterations = 0;
  1525. collection.__iterate(
  1526. function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) &&
  1527. fn(v, iterations++, this$1$1) !== false; },
  1528. reverse
  1529. );
  1530. return iterations;
  1531. };
  1532. interposedSequence.__iteratorUncached = function (type, reverse) {
  1533. var iterator = collection.__iterator(ITERATE_VALUES, reverse);
  1534. var iterations = 0;
  1535. var step;
  1536. return new Iterator(function () {
  1537. if (!step || iterations % 2) {
  1538. step = iterator.next();
  1539. if (step.done) {
  1540. return step;
  1541. }
  1542. }
  1543. return iterations % 2
  1544. ? iteratorValue(type, iterations++, separator)
  1545. : iteratorValue(type, iterations++, step.value, step);
  1546. });
  1547. };
  1548. return interposedSequence;
  1549. }
  1550. function sortFactory(collection, comparator, mapper) {
  1551. if (!comparator) {
  1552. comparator = defaultComparator;
  1553. }
  1554. var isKeyedCollection = isKeyed(collection);
  1555. var index = 0;
  1556. var entries = collection
  1557. .toSeq()
  1558. .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; })
  1559. .valueSeq()
  1560. .toArray();
  1561. entries
  1562. .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; })
  1563. .forEach(
  1564. isKeyedCollection
  1565. ? function (v, i) {
  1566. entries[i].length = 2;
  1567. }
  1568. : function (v, i) {
  1569. entries[i] = v[1];
  1570. }
  1571. );
  1572. return isKeyedCollection
  1573. ? KeyedSeq(entries)
  1574. : isIndexed(collection)
  1575. ? IndexedSeq(entries)
  1576. : SetSeq(entries);
  1577. }
  1578. function maxFactory(collection, comparator, mapper) {
  1579. if (!comparator) {
  1580. comparator = defaultComparator;
  1581. }
  1582. if (mapper) {
  1583. var entry = collection
  1584. .toSeq()
  1585. .map(function (v, k) { return [v, mapper(v, k, collection)]; })
  1586. .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); });
  1587. return entry && entry[0];
  1588. }
  1589. return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); });
  1590. }
  1591. function maxCompare(comparator, a, b) {
  1592. var comp = comparator(b, a);
  1593. // b is considered the new max if the comparator declares them equal, but
  1594. // they are not equal and b is in fact a nullish value.
  1595. return (
  1596. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  1597. comp > 0
  1598. );
  1599. }
  1600. function zipWithFactory(keyIter, zipper, iters, zipAll) {
  1601. var zipSequence = makeSequence(keyIter);
  1602. var sizes = new ArraySeq(iters).map(function (i) { return i.size; });
  1603. zipSequence.size = zipAll ? sizes.max() : sizes.min();
  1604. // Note: this a generic base implementation of __iterate in terms of
  1605. // __iterator which may be more generically useful in the future.
  1606. zipSequence.__iterate = function (fn, reverse) {
  1607. /* generic:
  1608. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  1609. var step;
  1610. var iterations = 0;
  1611. while (!(step = iterator.next()).done) {
  1612. iterations++;
  1613. if (fn(step.value[1], step.value[0], this) === false) {
  1614. break;
  1615. }
  1616. }
  1617. return iterations;
  1618. */
  1619. // indexed:
  1620. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  1621. var step;
  1622. var iterations = 0;
  1623. while (!(step = iterator.next()).done) {
  1624. if (fn(step.value, iterations++, this) === false) {
  1625. break;
  1626. }
  1627. }
  1628. return iterations;
  1629. };
  1630. zipSequence.__iteratorUncached = function (type, reverse) {
  1631. var iterators = iters.map(
  1632. function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); }
  1633. );
  1634. var iterations = 0;
  1635. var isDone = false;
  1636. return new Iterator(function () {
  1637. var steps;
  1638. if (!isDone) {
  1639. steps = iterators.map(function (i) { return i.next(); });
  1640. isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; });
  1641. }
  1642. if (isDone) {
  1643. return iteratorDone();
  1644. }
  1645. return iteratorValue(
  1646. type,
  1647. iterations++,
  1648. zipper.apply(
  1649. null,
  1650. steps.map(function (s) { return s.value; })
  1651. )
  1652. );
  1653. });
  1654. };
  1655. return zipSequence;
  1656. }
  1657. // #pragma Helper Functions
  1658. function reify(iter, seq) {
  1659. return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq);
  1660. }
  1661. function validateEntry(entry) {
  1662. if (entry !== Object(entry)) {
  1663. throw new TypeError('Expected [K, V] tuple: ' + entry);
  1664. }
  1665. }
  1666. function collectionClass(collection) {
  1667. return isKeyed(collection)
  1668. ? KeyedCollection
  1669. : isIndexed(collection)
  1670. ? IndexedCollection
  1671. : SetCollection;
  1672. }
  1673. function makeSequence(collection) {
  1674. return Object.create(
  1675. (isKeyed(collection)
  1676. ? KeyedSeq
  1677. : isIndexed(collection)
  1678. ? IndexedSeq
  1679. : SetSeq
  1680. ).prototype
  1681. );
  1682. }
  1683. function cacheResultThrough() {
  1684. if (this._iter.cacheResult) {
  1685. this._iter.cacheResult();
  1686. this.size = this._iter.size;
  1687. return this;
  1688. }
  1689. return Seq.prototype.cacheResult.call(this);
  1690. }
  1691. function defaultComparator(a, b) {
  1692. if (a === undefined && b === undefined) {
  1693. return 0;
  1694. }
  1695. if (a === undefined) {
  1696. return 1;
  1697. }
  1698. if (b === undefined) {
  1699. return -1;
  1700. }
  1701. return a > b ? 1 : a < b ? -1 : 0;
  1702. }
  1703. function arrCopy(arr, offset) {
  1704. offset = offset || 0;
  1705. var len = Math.max(0, arr.length - offset);
  1706. var newArr = new Array(len);
  1707. for (var ii = 0; ii < len; ii++) {
  1708. newArr[ii] = arr[ii + offset];
  1709. }
  1710. return newArr;
  1711. }
  1712. function invariant(condition, error) {
  1713. if (!condition) { throw new Error(error); }
  1714. }
  1715. function assertNotInfinite(size) {
  1716. invariant(
  1717. size !== Infinity,
  1718. 'Cannot perform this action with an infinite size.'
  1719. );
  1720. }
  1721. function coerceKeyPath(keyPath) {
  1722. if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
  1723. return keyPath;
  1724. }
  1725. if (isOrdered(keyPath)) {
  1726. return keyPath.toArray();
  1727. }
  1728. throw new TypeError(
  1729. 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath
  1730. );
  1731. }
  1732. var toString = Object.prototype.toString;
  1733. function isPlainObject(value) {
  1734. // The base prototype's toString deals with Argument objects and native namespaces like Math
  1735. if (
  1736. !value ||
  1737. typeof value !== 'object' ||
  1738. toString.call(value) !== '[object Object]'
  1739. ) {
  1740. return false;
  1741. }
  1742. var proto = Object.getPrototypeOf(value);
  1743. if (proto === null) {
  1744. return true;
  1745. }
  1746. // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc)
  1747. var parentProto = proto;
  1748. var nextProto = Object.getPrototypeOf(proto);
  1749. while (nextProto !== null) {
  1750. parentProto = nextProto;
  1751. nextProto = Object.getPrototypeOf(parentProto);
  1752. }
  1753. return parentProto === proto;
  1754. }
  1755. /**
  1756. * Returns true if the value is a potentially-persistent data structure, either
  1757. * provided by Immutable.js or a plain Array or Object.
  1758. */
  1759. function isDataStructure(value) {
  1760. return (
  1761. typeof value === 'object' &&
  1762. (isImmutable(value) || Array.isArray(value) || isPlainObject(value))
  1763. );
  1764. }
  1765. function quoteString(value) {
  1766. try {
  1767. return typeof value === 'string' ? JSON.stringify(value) : String(value);
  1768. } catch (_ignoreError) {
  1769. return JSON.stringify(value);
  1770. }
  1771. }
  1772. function has(collection, key) {
  1773. return isImmutable(collection)
  1774. ? collection.has(key)
  1775. : isDataStructure(collection) && hasOwnProperty.call(collection, key);
  1776. }
  1777. function get(collection, key, notSetValue) {
  1778. return isImmutable(collection)
  1779. ? collection.get(key, notSetValue)
  1780. : !has(collection, key)
  1781. ? notSetValue
  1782. : typeof collection.get === 'function'
  1783. ? collection.get(key)
  1784. : collection[key];
  1785. }
  1786. function isProtoKey(key) {
  1787. return (
  1788. typeof key === 'string' && (key === '__proto__' || key === 'constructor')
  1789. );
  1790. }
  1791. function shallowCopy(from) {
  1792. if (Array.isArray(from)) {
  1793. return arrCopy(from);
  1794. }
  1795. var to = {};
  1796. for (var key in from) {
  1797. if (isProtoKey(key)) {
  1798. continue;
  1799. }
  1800. if (hasOwnProperty.call(from, key)) {
  1801. to[key] = from[key];
  1802. }
  1803. }
  1804. return to;
  1805. }
  1806. function remove(collection, key) {
  1807. if (!isDataStructure(collection)) {
  1808. throw new TypeError(
  1809. 'Cannot update non-data-structure value: ' + collection
  1810. );
  1811. }
  1812. if (isImmutable(collection)) {
  1813. if (!collection.remove) {
  1814. throw new TypeError(
  1815. 'Cannot update immutable value without .remove() method: ' + collection
  1816. );
  1817. }
  1818. return collection.remove(key);
  1819. }
  1820. if (!hasOwnProperty.call(collection, key)) {
  1821. return collection;
  1822. }
  1823. var collectionCopy = shallowCopy(collection);
  1824. if (Array.isArray(collectionCopy)) {
  1825. collectionCopy.splice(key, 1);
  1826. } else {
  1827. delete collectionCopy[key];
  1828. }
  1829. return collectionCopy;
  1830. }
  1831. function set(collection, key, value) {
  1832. if (isProtoKey(key)) {
  1833. return collection;
  1834. }
  1835. if (!isDataStructure(collection)) {
  1836. throw new TypeError(
  1837. 'Cannot update non-data-structure value: ' + collection
  1838. );
  1839. }
  1840. if (isImmutable(collection)) {
  1841. if (!collection.set) {
  1842. throw new TypeError(
  1843. 'Cannot update immutable value without .set() method: ' + collection
  1844. );
  1845. }
  1846. return collection.set(key, value);
  1847. }
  1848. if (hasOwnProperty.call(collection, key) && value === collection[key]) {
  1849. return collection;
  1850. }
  1851. var collectionCopy = shallowCopy(collection);
  1852. collectionCopy[key] = value;
  1853. return collectionCopy;
  1854. }
  1855. function updateIn$1(collection, keyPath, notSetValue, updater) {
  1856. if (!updater) {
  1857. updater = notSetValue;
  1858. notSetValue = undefined;
  1859. }
  1860. var updatedValue = updateInDeeply(
  1861. isImmutable(collection),
  1862. collection,
  1863. coerceKeyPath(keyPath),
  1864. 0,
  1865. notSetValue,
  1866. updater
  1867. );
  1868. return updatedValue === NOT_SET ? notSetValue : updatedValue;
  1869. }
  1870. function updateInDeeply(
  1871. inImmutable,
  1872. existing,
  1873. keyPath,
  1874. i,
  1875. notSetValue,
  1876. updater
  1877. ) {
  1878. var wasNotSet = existing === NOT_SET;
  1879. if (i === keyPath.length) {
  1880. var existingValue = wasNotSet ? notSetValue : existing;
  1881. var newValue = updater(existingValue);
  1882. return newValue === existingValue ? existing : newValue;
  1883. }
  1884. if (!wasNotSet && !isDataStructure(existing)) {
  1885. throw new TypeError(
  1886. 'Cannot update within non-data-structure value in path [' +
  1887. keyPath.slice(0, i).map(quoteString) +
  1888. ']: ' +
  1889. existing
  1890. );
  1891. }
  1892. var key = keyPath[i];
  1893. var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
  1894. var nextUpdated = updateInDeeply(
  1895. nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
  1896. nextExisting,
  1897. keyPath,
  1898. i + 1,
  1899. notSetValue,
  1900. updater
  1901. );
  1902. return nextUpdated === nextExisting
  1903. ? existing
  1904. : nextUpdated === NOT_SET
  1905. ? remove(existing, key)
  1906. : set(
  1907. wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
  1908. key,
  1909. nextUpdated
  1910. );
  1911. }
  1912. function setIn$1(collection, keyPath, value) {
  1913. return updateIn$1(collection, keyPath, NOT_SET, function () { return value; });
  1914. }
  1915. function setIn(keyPath, v) {
  1916. return setIn$1(this, keyPath, v);
  1917. }
  1918. function removeIn(collection, keyPath) {
  1919. return updateIn$1(collection, keyPath, function () { return NOT_SET; });
  1920. }
  1921. function deleteIn(keyPath) {
  1922. return removeIn(this, keyPath);
  1923. }
  1924. function update$1(collection, key, notSetValue, updater) {
  1925. return updateIn$1(collection, [key], notSetValue, updater);
  1926. }
  1927. function update(key, notSetValue, updater) {
  1928. return arguments.length === 1
  1929. ? key(this)
  1930. : update$1(this, key, notSetValue, updater);
  1931. }
  1932. function updateIn(keyPath, notSetValue, updater) {
  1933. return updateIn$1(this, keyPath, notSetValue, updater);
  1934. }
  1935. function merge$1() {
  1936. var iters = [], len = arguments.length;
  1937. while ( len-- ) iters[ len ] = arguments[ len ];
  1938. return mergeIntoKeyedWith(this, iters);
  1939. }
  1940. function mergeWith$1(merger) {
  1941. var iters = [], len = arguments.length - 1;
  1942. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1943. if (typeof merger !== 'function') {
  1944. throw new TypeError('Invalid merger function: ' + merger);
  1945. }
  1946. return mergeIntoKeyedWith(this, iters, merger);
  1947. }
  1948. function mergeIntoKeyedWith(collection, collections, merger) {
  1949. var iters = [];
  1950. for (var ii = 0; ii < collections.length; ii++) {
  1951. var collection$1 = KeyedCollection(collections[ii]);
  1952. if (collection$1.size !== 0) {
  1953. iters.push(collection$1);
  1954. }
  1955. }
  1956. if (iters.length === 0) {
  1957. return collection;
  1958. }
  1959. if (
  1960. collection.toSeq().size === 0 &&
  1961. !collection.__ownerID &&
  1962. iters.length === 1
  1963. ) {
  1964. return collection.constructor(iters[0]);
  1965. }
  1966. return collection.withMutations(function (collection) {
  1967. var mergeIntoCollection = merger
  1968. ? function (value, key) {
  1969. update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); }
  1970. );
  1971. }
  1972. : function (value, key) {
  1973. collection.set(key, value);
  1974. };
  1975. for (var ii = 0; ii < iters.length; ii++) {
  1976. iters[ii].forEach(mergeIntoCollection);
  1977. }
  1978. });
  1979. }
  1980. function merge(collection) {
  1981. var sources = [], len = arguments.length - 1;
  1982. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  1983. return mergeWithSources(collection, sources);
  1984. }
  1985. function mergeWith(merger, collection) {
  1986. var sources = [], len = arguments.length - 2;
  1987. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  1988. return mergeWithSources(collection, sources, merger);
  1989. }
  1990. function mergeDeep$1(collection) {
  1991. var sources = [], len = arguments.length - 1;
  1992. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  1993. return mergeDeepWithSources(collection, sources);
  1994. }
  1995. function mergeDeepWith$1(merger, collection) {
  1996. var sources = [], len = arguments.length - 2;
  1997. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  1998. return mergeDeepWithSources(collection, sources, merger);
  1999. }
  2000. function mergeDeepWithSources(collection, sources, merger) {
  2001. return mergeWithSources(collection, sources, deepMergerWith(merger));
  2002. }
  2003. function mergeWithSources(collection, sources, merger) {
  2004. if (!isDataStructure(collection)) {
  2005. throw new TypeError(
  2006. 'Cannot merge into non-data-structure value: ' + collection
  2007. );
  2008. }
  2009. if (isImmutable(collection)) {
  2010. return typeof merger === 'function' && collection.mergeWith
  2011. ? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
  2012. : collection.merge
  2013. ? collection.merge.apply(collection, sources)
  2014. : collection.concat.apply(collection, sources);
  2015. }
  2016. var isArray = Array.isArray(collection);
  2017. var merged = collection;
  2018. var Collection = isArray ? IndexedCollection : KeyedCollection;
  2019. var mergeItem = isArray
  2020. ? function (value) {
  2021. // Copy on write
  2022. if (merged === collection) {
  2023. merged = shallowCopy(merged);
  2024. }
  2025. merged.push(value);
  2026. }
  2027. : function (value, key) {
  2028. if (isProtoKey(key)) {
  2029. return;
  2030. }
  2031. var hasVal = hasOwnProperty.call(merged, key);
  2032. var nextVal =
  2033. hasVal && merger ? merger(merged[key], value, key) : value;
  2034. if (!hasVal || nextVal !== merged[key]) {
  2035. // Copy on write
  2036. if (merged === collection) {
  2037. merged = shallowCopy(merged);
  2038. }
  2039. merged[key] = nextVal;
  2040. }
  2041. };
  2042. for (var i = 0; i < sources.length; i++) {
  2043. Collection(sources[i]).forEach(mergeItem);
  2044. }
  2045. return merged;
  2046. }
  2047. function deepMergerWith(merger) {
  2048. function deepMerger(oldValue, newValue, key) {
  2049. return isDataStructure(oldValue) &&
  2050. isDataStructure(newValue) &&
  2051. areMergeable(oldValue, newValue)
  2052. ? mergeWithSources(oldValue, [newValue], deepMerger)
  2053. : merger
  2054. ? merger(oldValue, newValue, key)
  2055. : newValue;
  2056. }
  2057. return deepMerger;
  2058. }
  2059. /**
  2060. * It's unclear what the desired behavior is for merging two collections that
  2061. * fall into separate categories between keyed, indexed, or set-like, so we only
  2062. * consider them mergeable if they fall into the same category.
  2063. */
  2064. function areMergeable(oldDataStructure, newDataStructure) {
  2065. var oldSeq = Seq(oldDataStructure);
  2066. var newSeq = Seq(newDataStructure);
  2067. // This logic assumes that a sequence can only fall into one of the three
  2068. // categories mentioned above (since there's no `isSetLike()` method).
  2069. return (
  2070. isIndexed(oldSeq) === isIndexed(newSeq) &&
  2071. isKeyed(oldSeq) === isKeyed(newSeq)
  2072. );
  2073. }
  2074. function mergeDeep() {
  2075. var iters = [], len = arguments.length;
  2076. while ( len-- ) iters[ len ] = arguments[ len ];
  2077. return mergeDeepWithSources(this, iters);
  2078. }
  2079. function mergeDeepWith(merger) {
  2080. var iters = [], len = arguments.length - 1;
  2081. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  2082. return mergeDeepWithSources(this, iters, merger);
  2083. }
  2084. function mergeIn(keyPath) {
  2085. var iters = [], len = arguments.length - 1;
  2086. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  2087. return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
  2088. }
  2089. function mergeDeepIn(keyPath) {
  2090. var iters = [], len = arguments.length - 1;
  2091. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  2092. return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
  2093. );
  2094. }
  2095. function withMutations(fn) {
  2096. var mutable = this.asMutable();
  2097. fn(mutable);
  2098. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  2099. }
  2100. function asMutable() {
  2101. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  2102. }
  2103. function asImmutable() {
  2104. return this.__ensureOwner();
  2105. }
  2106. function wasAltered() {
  2107. return this.__altered;
  2108. }
  2109. var Map = /*@__PURE__*/(function (KeyedCollection) {
  2110. function Map(value) {
  2111. // eslint-disable-next-line no-constructor-return
  2112. return value === undefined || value === null
  2113. ? emptyMap()
  2114. : isMap(value) && !isOrdered(value)
  2115. ? value
  2116. : emptyMap().withMutations(function (map) {
  2117. var iter = KeyedCollection(value);
  2118. assertNotInfinite(iter.size);
  2119. iter.forEach(function (v, k) { return map.set(k, v); });
  2120. });
  2121. }
  2122. if ( KeyedCollection ) Map.__proto__ = KeyedCollection;
  2123. Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype );
  2124. Map.prototype.constructor = Map;
  2125. Map.of = function of () {
  2126. var keyValues = [], len = arguments.length;
  2127. while ( len-- ) keyValues[ len ] = arguments[ len ];
  2128. return emptyMap().withMutations(function (map) {
  2129. for (var i = 0; i < keyValues.length; i += 2) {
  2130. if (i + 1 >= keyValues.length) {
  2131. throw new Error('Missing value for key: ' + keyValues[i]);
  2132. }
  2133. map.set(keyValues[i], keyValues[i + 1]);
  2134. }
  2135. });
  2136. };
  2137. Map.prototype.toString = function toString () {
  2138. return this.__toString('Map {', '}');
  2139. };
  2140. // @pragma Access
  2141. Map.prototype.get = function get (k, notSetValue) {
  2142. return this._root
  2143. ? this._root.get(0, undefined, k, notSetValue)
  2144. : notSetValue;
  2145. };
  2146. // @pragma Modification
  2147. Map.prototype.set = function set (k, v) {
  2148. return updateMap(this, k, v);
  2149. };
  2150. Map.prototype.remove = function remove (k) {
  2151. return updateMap(this, k, NOT_SET);
  2152. };
  2153. Map.prototype.deleteAll = function deleteAll (keys) {
  2154. var collection = Collection(keys);
  2155. if (collection.size === 0) {
  2156. return this;
  2157. }
  2158. return this.withMutations(function (map) {
  2159. collection.forEach(function (key) { return map.remove(key); });
  2160. });
  2161. };
  2162. Map.prototype.clear = function clear () {
  2163. if (this.size === 0) {
  2164. return this;
  2165. }
  2166. if (this.__ownerID) {
  2167. this.size = 0;
  2168. this._root = null;
  2169. this.__hash = undefined;
  2170. this.__altered = true;
  2171. return this;
  2172. }
  2173. return emptyMap();
  2174. };
  2175. // @pragma Composition
  2176. Map.prototype.sort = function sort (comparator) {
  2177. // Late binding
  2178. return OrderedMap(sortFactory(this, comparator));
  2179. };
  2180. Map.prototype.sortBy = function sortBy (mapper, comparator) {
  2181. // Late binding
  2182. return OrderedMap(sortFactory(this, comparator, mapper));
  2183. };
  2184. Map.prototype.map = function map (mapper, context) {
  2185. var this$1$1 = this;
  2186. return this.withMutations(function (map) {
  2187. map.forEach(function (value, key) {
  2188. map.set(key, mapper.call(context, value, key, this$1$1));
  2189. });
  2190. });
  2191. };
  2192. // @pragma Mutability
  2193. Map.prototype.__iterator = function __iterator (type, reverse) {
  2194. return new MapIterator(this, type, reverse);
  2195. };
  2196. Map.prototype.__iterate = function __iterate (fn, reverse) {
  2197. var this$1$1 = this;
  2198. var iterations = 0;
  2199. this._root &&
  2200. this._root.iterate(function (entry) {
  2201. iterations++;
  2202. return fn(entry[1], entry[0], this$1$1);
  2203. }, reverse);
  2204. return iterations;
  2205. };
  2206. Map.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  2207. if (ownerID === this.__ownerID) {
  2208. return this;
  2209. }
  2210. if (!ownerID) {
  2211. if (this.size === 0) {
  2212. return emptyMap();
  2213. }
  2214. this.__ownerID = ownerID;
  2215. this.__altered = false;
  2216. return this;
  2217. }
  2218. return makeMap(this.size, this._root, ownerID, this.__hash);
  2219. };
  2220. return Map;
  2221. }(KeyedCollection));
  2222. Map.isMap = isMap;
  2223. var MapPrototype = Map.prototype;
  2224. MapPrototype[IS_MAP_SYMBOL] = true;
  2225. MapPrototype[DELETE] = MapPrototype.remove;
  2226. MapPrototype.removeAll = MapPrototype.deleteAll;
  2227. MapPrototype.setIn = setIn;
  2228. MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
  2229. MapPrototype.update = update;
  2230. MapPrototype.updateIn = updateIn;
  2231. MapPrototype.merge = MapPrototype.concat = merge$1;
  2232. MapPrototype.mergeWith = mergeWith$1;
  2233. MapPrototype.mergeDeep = mergeDeep;
  2234. MapPrototype.mergeDeepWith = mergeDeepWith;
  2235. MapPrototype.mergeIn = mergeIn;
  2236. MapPrototype.mergeDeepIn = mergeDeepIn;
  2237. MapPrototype.withMutations = withMutations;
  2238. MapPrototype.wasAltered = wasAltered;
  2239. MapPrototype.asImmutable = asImmutable;
  2240. MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
  2241. MapPrototype['@@transducer/step'] = function (result, arr) {
  2242. return result.set(arr[0], arr[1]);
  2243. };
  2244. MapPrototype['@@transducer/result'] = function (obj) {
  2245. return obj.asImmutable();
  2246. };
  2247. // #pragma Trie Nodes
  2248. var ArrayMapNode = function ArrayMapNode(ownerID, entries) {
  2249. this.ownerID = ownerID;
  2250. this.entries = entries;
  2251. };
  2252. ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2253. var entries = this.entries;
  2254. for (var ii = 0, len = entries.length; ii < len; ii++) {
  2255. if (is(key, entries[ii][0])) {
  2256. return entries[ii][1];
  2257. }
  2258. }
  2259. return notSetValue;
  2260. };
  2261. ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2262. var removed = value === NOT_SET;
  2263. var entries = this.entries;
  2264. var idx = 0;
  2265. var len = entries.length;
  2266. for (; idx < len; idx++) {
  2267. if (is(key, entries[idx][0])) {
  2268. break;
  2269. }
  2270. }
  2271. var exists = idx < len;
  2272. if (exists ? entries[idx][1] === value : removed) {
  2273. return this;
  2274. }
  2275. SetRef(didAlter);
  2276. (removed || !exists) && SetRef(didChangeSize);
  2277. if (removed && entries.length === 1) {
  2278. return; // undefined
  2279. }
  2280. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  2281. return createNodes(ownerID, entries, key, value);
  2282. }
  2283. var isEditable = ownerID && ownerID === this.ownerID;
  2284. var newEntries = isEditable ? entries : arrCopy(entries);
  2285. if (exists) {
  2286. if (removed) {
  2287. idx === len - 1
  2288. ? newEntries.pop()
  2289. : (newEntries[idx] = newEntries.pop());
  2290. } else {
  2291. newEntries[idx] = [key, value];
  2292. }
  2293. } else {
  2294. newEntries.push([key, value]);
  2295. }
  2296. if (isEditable) {
  2297. this.entries = newEntries;
  2298. return this;
  2299. }
  2300. return new ArrayMapNode(ownerID, newEntries);
  2301. };
  2302. var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) {
  2303. this.ownerID = ownerID;
  2304. this.bitmap = bitmap;
  2305. this.nodes = nodes;
  2306. };
  2307. BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2308. if (keyHash === undefined) {
  2309. keyHash = hash(key);
  2310. }
  2311. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  2312. var bitmap = this.bitmap;
  2313. return (bitmap & bit) === 0
  2314. ? notSetValue
  2315. : this.nodes[popCount(bitmap & (bit - 1))].get(
  2316. shift + SHIFT,
  2317. keyHash,
  2318. key,
  2319. notSetValue
  2320. );
  2321. };
  2322. BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2323. if (keyHash === undefined) {
  2324. keyHash = hash(key);
  2325. }
  2326. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2327. var bit = 1 << keyHashFrag;
  2328. var bitmap = this.bitmap;
  2329. var exists = (bitmap & bit) !== 0;
  2330. if (!exists && value === NOT_SET) {
  2331. return this;
  2332. }
  2333. var idx = popCount(bitmap & (bit - 1));
  2334. var nodes = this.nodes;
  2335. var node = exists ? nodes[idx] : undefined;
  2336. var newNode = updateNode(
  2337. node,
  2338. ownerID,
  2339. shift + SHIFT,
  2340. keyHash,
  2341. key,
  2342. value,
  2343. didChangeSize,
  2344. didAlter
  2345. );
  2346. if (newNode === node) {
  2347. return this;
  2348. }
  2349. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  2350. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  2351. }
  2352. if (
  2353. exists &&
  2354. !newNode &&
  2355. nodes.length === 2 &&
  2356. isLeafNode(nodes[idx ^ 1])
  2357. ) {
  2358. return nodes[idx ^ 1];
  2359. }
  2360. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  2361. return newNode;
  2362. }
  2363. var isEditable = ownerID && ownerID === this.ownerID;
  2364. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  2365. var newNodes = exists
  2366. ? newNode
  2367. ? setAt(nodes, idx, newNode, isEditable)
  2368. : spliceOut(nodes, idx, isEditable)
  2369. : spliceIn(nodes, idx, newNode, isEditable);
  2370. if (isEditable) {
  2371. this.bitmap = newBitmap;
  2372. this.nodes = newNodes;
  2373. return this;
  2374. }
  2375. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  2376. };
  2377. var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) {
  2378. this.ownerID = ownerID;
  2379. this.count = count;
  2380. this.nodes = nodes;
  2381. };
  2382. HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2383. if (keyHash === undefined) {
  2384. keyHash = hash(key);
  2385. }
  2386. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2387. var node = this.nodes[idx];
  2388. return node
  2389. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  2390. : notSetValue;
  2391. };
  2392. HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2393. if (keyHash === undefined) {
  2394. keyHash = hash(key);
  2395. }
  2396. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2397. var removed = value === NOT_SET;
  2398. var nodes = this.nodes;
  2399. var node = nodes[idx];
  2400. if (removed && !node) {
  2401. return this;
  2402. }
  2403. var newNode = updateNode(
  2404. node,
  2405. ownerID,
  2406. shift + SHIFT,
  2407. keyHash,
  2408. key,
  2409. value,
  2410. didChangeSize,
  2411. didAlter
  2412. );
  2413. if (newNode === node) {
  2414. return this;
  2415. }
  2416. var newCount = this.count;
  2417. if (!node) {
  2418. newCount++;
  2419. } else if (!newNode) {
  2420. newCount--;
  2421. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  2422. return packNodes(ownerID, nodes, newCount, idx);
  2423. }
  2424. }
  2425. var isEditable = ownerID && ownerID === this.ownerID;
  2426. var newNodes = setAt(nodes, idx, newNode, isEditable);
  2427. if (isEditable) {
  2428. this.count = newCount;
  2429. this.nodes = newNodes;
  2430. return this;
  2431. }
  2432. return new HashArrayMapNode(ownerID, newCount, newNodes);
  2433. };
  2434. var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) {
  2435. this.ownerID = ownerID;
  2436. this.keyHash = keyHash;
  2437. this.entries = entries;
  2438. };
  2439. HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2440. var entries = this.entries;
  2441. for (var ii = 0, len = entries.length; ii < len; ii++) {
  2442. if (is(key, entries[ii][0])) {
  2443. return entries[ii][1];
  2444. }
  2445. }
  2446. return notSetValue;
  2447. };
  2448. HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2449. if (keyHash === undefined) {
  2450. keyHash = hash(key);
  2451. }
  2452. var removed = value === NOT_SET;
  2453. if (keyHash !== this.keyHash) {
  2454. if (removed) {
  2455. return this;
  2456. }
  2457. SetRef(didAlter);
  2458. SetRef(didChangeSize);
  2459. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  2460. }
  2461. var entries = this.entries;
  2462. var idx = 0;
  2463. var len = entries.length;
  2464. for (; idx < len; idx++) {
  2465. if (is(key, entries[idx][0])) {
  2466. break;
  2467. }
  2468. }
  2469. var exists = idx < len;
  2470. if (exists ? entries[idx][1] === value : removed) {
  2471. return this;
  2472. }
  2473. SetRef(didAlter);
  2474. (removed || !exists) && SetRef(didChangeSize);
  2475. if (removed && len === 2) {
  2476. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  2477. }
  2478. var isEditable = ownerID && ownerID === this.ownerID;
  2479. var newEntries = isEditable ? entries : arrCopy(entries);
  2480. if (exists) {
  2481. if (removed) {
  2482. idx === len - 1
  2483. ? newEntries.pop()
  2484. : (newEntries[idx] = newEntries.pop());
  2485. } else {
  2486. newEntries[idx] = [key, value];
  2487. }
  2488. } else {
  2489. newEntries.push([key, value]);
  2490. }
  2491. if (isEditable) {
  2492. this.entries = newEntries;
  2493. return this;
  2494. }
  2495. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  2496. };
  2497. var ValueNode = function ValueNode(ownerID, keyHash, entry) {
  2498. this.ownerID = ownerID;
  2499. this.keyHash = keyHash;
  2500. this.entry = entry;
  2501. };
  2502. ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2503. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  2504. };
  2505. ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2506. var removed = value === NOT_SET;
  2507. var keyMatch = is(key, this.entry[0]);
  2508. if (keyMatch ? value === this.entry[1] : removed) {
  2509. return this;
  2510. }
  2511. SetRef(didAlter);
  2512. if (removed) {
  2513. SetRef(didChangeSize);
  2514. return; // undefined
  2515. }
  2516. if (keyMatch) {
  2517. if (ownerID && ownerID === this.ownerID) {
  2518. this.entry[1] = value;
  2519. return this;
  2520. }
  2521. return new ValueNode(ownerID, this.keyHash, [key, value]);
  2522. }
  2523. SetRef(didChangeSize);
  2524. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  2525. };
  2526. // #pragma Iterators
  2527. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate =
  2528. function (fn, reverse) {
  2529. var entries = this.entries;
  2530. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  2531. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  2532. return false;
  2533. }
  2534. }
  2535. };
  2536. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate =
  2537. function (fn, reverse) {
  2538. var nodes = this.nodes;
  2539. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  2540. var node = nodes[reverse ? maxIndex - ii : ii];
  2541. if (node && node.iterate(fn, reverse) === false) {
  2542. return false;
  2543. }
  2544. }
  2545. };
  2546. // eslint-disable-next-line no-unused-vars
  2547. ValueNode.prototype.iterate = function (fn, reverse) {
  2548. return fn(this.entry);
  2549. };
  2550. var MapIterator = /*@__PURE__*/(function (Iterator) {
  2551. function MapIterator(map, type, reverse) {
  2552. this._type = type;
  2553. this._reverse = reverse;
  2554. this._stack = map._root && mapIteratorFrame(map._root);
  2555. }
  2556. if ( Iterator ) MapIterator.__proto__ = Iterator;
  2557. MapIterator.prototype = Object.create( Iterator && Iterator.prototype );
  2558. MapIterator.prototype.constructor = MapIterator;
  2559. MapIterator.prototype.next = function next () {
  2560. var type = this._type;
  2561. var stack = this._stack;
  2562. while (stack) {
  2563. var node = stack.node;
  2564. var index = stack.index++;
  2565. var maxIndex = (void 0);
  2566. if (node.entry) {
  2567. if (index === 0) {
  2568. return mapIteratorValue(type, node.entry);
  2569. }
  2570. } else if (node.entries) {
  2571. maxIndex = node.entries.length - 1;
  2572. if (index <= maxIndex) {
  2573. return mapIteratorValue(
  2574. type,
  2575. node.entries[this._reverse ? maxIndex - index : index]
  2576. );
  2577. }
  2578. } else {
  2579. maxIndex = node.nodes.length - 1;
  2580. if (index <= maxIndex) {
  2581. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  2582. if (subNode) {
  2583. if (subNode.entry) {
  2584. return mapIteratorValue(type, subNode.entry);
  2585. }
  2586. stack = this._stack = mapIteratorFrame(subNode, stack);
  2587. }
  2588. continue;
  2589. }
  2590. }
  2591. stack = this._stack = this._stack.__prev;
  2592. }
  2593. return iteratorDone();
  2594. };
  2595. return MapIterator;
  2596. }(Iterator));
  2597. function mapIteratorValue(type, entry) {
  2598. return iteratorValue(type, entry[0], entry[1]);
  2599. }
  2600. function mapIteratorFrame(node, prev) {
  2601. return {
  2602. node: node,
  2603. index: 0,
  2604. __prev: prev,
  2605. };
  2606. }
  2607. function makeMap(size, root, ownerID, hash) {
  2608. var map = Object.create(MapPrototype);
  2609. map.size = size;
  2610. map._root = root;
  2611. map.__ownerID = ownerID;
  2612. map.__hash = hash;
  2613. map.__altered = false;
  2614. return map;
  2615. }
  2616. var EMPTY_MAP;
  2617. function emptyMap() {
  2618. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  2619. }
  2620. function updateMap(map, k, v) {
  2621. var newRoot;
  2622. var newSize;
  2623. if (!map._root) {
  2624. if (v === NOT_SET) {
  2625. return map;
  2626. }
  2627. newSize = 1;
  2628. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  2629. } else {
  2630. var didChangeSize = MakeRef();
  2631. var didAlter = MakeRef();
  2632. newRoot = updateNode(
  2633. map._root,
  2634. map.__ownerID,
  2635. 0,
  2636. undefined,
  2637. k,
  2638. v,
  2639. didChangeSize,
  2640. didAlter
  2641. );
  2642. if (!didAlter.value) {
  2643. return map;
  2644. }
  2645. newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  2646. }
  2647. if (map.__ownerID) {
  2648. map.size = newSize;
  2649. map._root = newRoot;
  2650. map.__hash = undefined;
  2651. map.__altered = true;
  2652. return map;
  2653. }
  2654. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  2655. }
  2656. function updateNode(
  2657. node,
  2658. ownerID,
  2659. shift,
  2660. keyHash,
  2661. key,
  2662. value,
  2663. didChangeSize,
  2664. didAlter
  2665. ) {
  2666. if (!node) {
  2667. if (value === NOT_SET) {
  2668. return node;
  2669. }
  2670. SetRef(didAlter);
  2671. SetRef(didChangeSize);
  2672. return new ValueNode(ownerID, keyHash, [key, value]);
  2673. }
  2674. return node.update(
  2675. ownerID,
  2676. shift,
  2677. keyHash,
  2678. key,
  2679. value,
  2680. didChangeSize,
  2681. didAlter
  2682. );
  2683. }
  2684. function isLeafNode(node) {
  2685. return (
  2686. node.constructor === ValueNode || node.constructor === HashCollisionNode
  2687. );
  2688. }
  2689. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  2690. if (node.keyHash === keyHash) {
  2691. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  2692. }
  2693. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  2694. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2695. var newNode;
  2696. var nodes =
  2697. idx1 === idx2
  2698. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  2699. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  2700. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  2701. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  2702. }
  2703. function createNodes(ownerID, entries, key, value) {
  2704. if (!ownerID) {
  2705. ownerID = new OwnerID();
  2706. }
  2707. var node = new ValueNode(ownerID, hash(key), [key, value]);
  2708. for (var ii = 0; ii < entries.length; ii++) {
  2709. var entry = entries[ii];
  2710. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  2711. }
  2712. return node;
  2713. }
  2714. function packNodes(ownerID, nodes, count, excluding) {
  2715. var bitmap = 0;
  2716. var packedII = 0;
  2717. var packedNodes = new Array(count);
  2718. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  2719. var node = nodes[ii];
  2720. if (node !== undefined && ii !== excluding) {
  2721. bitmap |= bit;
  2722. packedNodes[packedII++] = node;
  2723. }
  2724. }
  2725. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  2726. }
  2727. function expandNodes(ownerID, nodes, bitmap, including, node) {
  2728. var count = 0;
  2729. var expandedNodes = new Array(SIZE);
  2730. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  2731. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  2732. }
  2733. expandedNodes[including] = node;
  2734. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  2735. }
  2736. function popCount(x) {
  2737. x -= (x >> 1) & 0x55555555;
  2738. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  2739. x = (x + (x >> 4)) & 0x0f0f0f0f;
  2740. x += x >> 8;
  2741. x += x >> 16;
  2742. return x & 0x7f;
  2743. }
  2744. function setAt(array, idx, val, canEdit) {
  2745. var newArray = canEdit ? array : arrCopy(array);
  2746. newArray[idx] = val;
  2747. return newArray;
  2748. }
  2749. function spliceIn(array, idx, val, canEdit) {
  2750. var newLen = array.length + 1;
  2751. if (canEdit && idx + 1 === newLen) {
  2752. array[idx] = val;
  2753. return array;
  2754. }
  2755. var newArray = new Array(newLen);
  2756. var after = 0;
  2757. for (var ii = 0; ii < newLen; ii++) {
  2758. if (ii === idx) {
  2759. newArray[ii] = val;
  2760. after = -1;
  2761. } else {
  2762. newArray[ii] = array[ii + after];
  2763. }
  2764. }
  2765. return newArray;
  2766. }
  2767. function spliceOut(array, idx, canEdit) {
  2768. var newLen = array.length - 1;
  2769. if (canEdit && idx === newLen) {
  2770. array.pop();
  2771. return array;
  2772. }
  2773. var newArray = new Array(newLen);
  2774. var after = 0;
  2775. for (var ii = 0; ii < newLen; ii++) {
  2776. if (ii === idx) {
  2777. after = 1;
  2778. }
  2779. newArray[ii] = array[ii + after];
  2780. }
  2781. return newArray;
  2782. }
  2783. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  2784. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  2785. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  2786. var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@';
  2787. function isList(maybeList) {
  2788. return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
  2789. }
  2790. var List = /*@__PURE__*/(function (IndexedCollection) {
  2791. function List(value) {
  2792. var empty = emptyList();
  2793. if (value === undefined || value === null) {
  2794. // eslint-disable-next-line no-constructor-return
  2795. return empty;
  2796. }
  2797. if (isList(value)) {
  2798. // eslint-disable-next-line no-constructor-return
  2799. return value;
  2800. }
  2801. var iter = IndexedCollection(value);
  2802. var size = iter.size;
  2803. if (size === 0) {
  2804. // eslint-disable-next-line no-constructor-return
  2805. return empty;
  2806. }
  2807. assertNotInfinite(size);
  2808. if (size > 0 && size < SIZE) {
  2809. // eslint-disable-next-line no-constructor-return
  2810. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  2811. }
  2812. // eslint-disable-next-line no-constructor-return
  2813. return empty.withMutations(function (list) {
  2814. list.setSize(size);
  2815. iter.forEach(function (v, i) { return list.set(i, v); });
  2816. });
  2817. }
  2818. if ( IndexedCollection ) List.__proto__ = IndexedCollection;
  2819. List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype );
  2820. List.prototype.constructor = List;
  2821. List.of = function of (/*...values*/) {
  2822. return this(arguments);
  2823. };
  2824. List.prototype.toString = function toString () {
  2825. return this.__toString('List [', ']');
  2826. };
  2827. // @pragma Access
  2828. List.prototype.get = function get (index, notSetValue) {
  2829. index = wrapIndex(this, index);
  2830. if (index >= 0 && index < this.size) {
  2831. index += this._origin;
  2832. var node = listNodeFor(this, index);
  2833. return node && node.array[index & MASK];
  2834. }
  2835. return notSetValue;
  2836. };
  2837. // @pragma Modification
  2838. List.prototype.set = function set (index, value) {
  2839. return updateList(this, index, value);
  2840. };
  2841. List.prototype.remove = function remove (index) {
  2842. return !this.has(index)
  2843. ? this
  2844. : index === 0
  2845. ? this.shift()
  2846. : index === this.size - 1
  2847. ? this.pop()
  2848. : this.splice(index, 1);
  2849. };
  2850. List.prototype.insert = function insert (index, value) {
  2851. return this.splice(index, 0, value);
  2852. };
  2853. List.prototype.clear = function clear () {
  2854. if (this.size === 0) {
  2855. return this;
  2856. }
  2857. if (this.__ownerID) {
  2858. this.size = this._origin = this._capacity = 0;
  2859. this._level = SHIFT;
  2860. this._root = this._tail = this.__hash = undefined;
  2861. this.__altered = true;
  2862. return this;
  2863. }
  2864. return emptyList();
  2865. };
  2866. List.prototype.push = function push (/*...values*/) {
  2867. var values = arguments;
  2868. var oldSize = this.size;
  2869. return this.withMutations(function (list) {
  2870. setListBounds(list, 0, oldSize + values.length);
  2871. for (var ii = 0; ii < values.length; ii++) {
  2872. list.set(oldSize + ii, values[ii]);
  2873. }
  2874. });
  2875. };
  2876. List.prototype.pop = function pop () {
  2877. return setListBounds(this, 0, -1);
  2878. };
  2879. List.prototype.unshift = function unshift (/*...values*/) {
  2880. var values = arguments;
  2881. return this.withMutations(function (list) {
  2882. setListBounds(list, -values.length);
  2883. for (var ii = 0; ii < values.length; ii++) {
  2884. list.set(ii, values[ii]);
  2885. }
  2886. });
  2887. };
  2888. List.prototype.shift = function shift () {
  2889. return setListBounds(this, 1);
  2890. };
  2891. // @pragma Composition
  2892. List.prototype.concat = function concat (/*...collections*/) {
  2893. var arguments$1 = arguments;
  2894. var seqs = [];
  2895. for (var i = 0; i < arguments.length; i++) {
  2896. var argument = arguments$1[i];
  2897. var seq = IndexedCollection(
  2898. typeof argument !== 'string' && hasIterator(argument)
  2899. ? argument
  2900. : [argument]
  2901. );
  2902. if (seq.size !== 0) {
  2903. seqs.push(seq);
  2904. }
  2905. }
  2906. if (seqs.length === 0) {
  2907. return this;
  2908. }
  2909. if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
  2910. return this.constructor(seqs[0]);
  2911. }
  2912. return this.withMutations(function (list) {
  2913. seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
  2914. });
  2915. };
  2916. List.prototype.setSize = function setSize (size) {
  2917. return setListBounds(this, 0, size);
  2918. };
  2919. List.prototype.map = function map (mapper, context) {
  2920. var this$1$1 = this;
  2921. return this.withMutations(function (list) {
  2922. for (var i = 0; i < this$1$1.size; i++) {
  2923. list.set(i, mapper.call(context, list.get(i), i, this$1$1));
  2924. }
  2925. });
  2926. };
  2927. // @pragma Iteration
  2928. List.prototype.slice = function slice (begin, end) {
  2929. var size = this.size;
  2930. if (wholeSlice(begin, end, size)) {
  2931. return this;
  2932. }
  2933. return setListBounds(
  2934. this,
  2935. resolveBegin(begin, size),
  2936. resolveEnd(end, size)
  2937. );
  2938. };
  2939. List.prototype.__iterator = function __iterator (type, reverse) {
  2940. var index = reverse ? this.size : 0;
  2941. var values = iterateList(this, reverse);
  2942. return new Iterator(function () {
  2943. var value = values();
  2944. return value === DONE
  2945. ? iteratorDone()
  2946. : iteratorValue(type, reverse ? --index : index++, value);
  2947. });
  2948. };
  2949. List.prototype.__iterate = function __iterate (fn, reverse) {
  2950. var index = reverse ? this.size : 0;
  2951. var values = iterateList(this, reverse);
  2952. var value;
  2953. while ((value = values()) !== DONE) {
  2954. if (fn(value, reverse ? --index : index++, this) === false) {
  2955. break;
  2956. }
  2957. }
  2958. return index;
  2959. };
  2960. List.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  2961. if (ownerID === this.__ownerID) {
  2962. return this;
  2963. }
  2964. if (!ownerID) {
  2965. if (this.size === 0) {
  2966. return emptyList();
  2967. }
  2968. this.__ownerID = ownerID;
  2969. this.__altered = false;
  2970. return this;
  2971. }
  2972. return makeList(
  2973. this._origin,
  2974. this._capacity,
  2975. this._level,
  2976. this._root,
  2977. this._tail,
  2978. ownerID,
  2979. this.__hash
  2980. );
  2981. };
  2982. return List;
  2983. }(IndexedCollection));
  2984. List.isList = isList;
  2985. var ListPrototype = List.prototype;
  2986. ListPrototype[IS_LIST_SYMBOL] = true;
  2987. ListPrototype[DELETE] = ListPrototype.remove;
  2988. ListPrototype.merge = ListPrototype.concat;
  2989. ListPrototype.setIn = setIn;
  2990. ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
  2991. ListPrototype.update = update;
  2992. ListPrototype.updateIn = updateIn;
  2993. ListPrototype.mergeIn = mergeIn;
  2994. ListPrototype.mergeDeepIn = mergeDeepIn;
  2995. ListPrototype.withMutations = withMutations;
  2996. ListPrototype.wasAltered = wasAltered;
  2997. ListPrototype.asImmutable = asImmutable;
  2998. ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
  2999. ListPrototype['@@transducer/step'] = function (result, arr) {
  3000. return result.push(arr);
  3001. };
  3002. ListPrototype['@@transducer/result'] = function (obj) {
  3003. return obj.asImmutable();
  3004. };
  3005. var VNode = function VNode(array, ownerID) {
  3006. this.array = array;
  3007. this.ownerID = ownerID;
  3008. };
  3009. // TODO: seems like these methods are very similar
  3010. VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) {
  3011. if (index === level ? 1 << level : this.array.length === 0) {
  3012. return this;
  3013. }
  3014. var originIndex = (index >>> level) & MASK;
  3015. if (originIndex >= this.array.length) {
  3016. return new VNode([], ownerID);
  3017. }
  3018. var removingFirst = originIndex === 0;
  3019. var newChild;
  3020. if (level > 0) {
  3021. var oldChild = this.array[originIndex];
  3022. newChild =
  3023. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  3024. if (newChild === oldChild && removingFirst) {
  3025. return this;
  3026. }
  3027. }
  3028. if (removingFirst && !newChild) {
  3029. return this;
  3030. }
  3031. var editable = editableVNode(this, ownerID);
  3032. if (!removingFirst) {
  3033. for (var ii = 0; ii < originIndex; ii++) {
  3034. editable.array[ii] = undefined;
  3035. }
  3036. }
  3037. if (newChild) {
  3038. editable.array[originIndex] = newChild;
  3039. }
  3040. return editable;
  3041. };
  3042. VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) {
  3043. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  3044. return this;
  3045. }
  3046. var sizeIndex = ((index - 1) >>> level) & MASK;
  3047. if (sizeIndex >= this.array.length) {
  3048. return this;
  3049. }
  3050. var newChild;
  3051. if (level > 0) {
  3052. var oldChild = this.array[sizeIndex];
  3053. newChild =
  3054. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  3055. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  3056. return this;
  3057. }
  3058. }
  3059. var editable = editableVNode(this, ownerID);
  3060. editable.array.splice(sizeIndex + 1);
  3061. if (newChild) {
  3062. editable.array[sizeIndex] = newChild;
  3063. }
  3064. return editable;
  3065. };
  3066. var DONE = {};
  3067. function iterateList(list, reverse) {
  3068. var left = list._origin;
  3069. var right = list._capacity;
  3070. var tailPos = getTailOffset(right);
  3071. var tail = list._tail;
  3072. return iterateNodeOrLeaf(list._root, list._level, 0);
  3073. function iterateNodeOrLeaf(node, level, offset) {
  3074. return level === 0
  3075. ? iterateLeaf(node, offset)
  3076. : iterateNode(node, level, offset);
  3077. }
  3078. function iterateLeaf(node, offset) {
  3079. var array = offset === tailPos ? tail && tail.array : node && node.array;
  3080. var from = offset > left ? 0 : left - offset;
  3081. var to = right - offset;
  3082. if (to > SIZE) {
  3083. to = SIZE;
  3084. }
  3085. return function () {
  3086. if (from === to) {
  3087. return DONE;
  3088. }
  3089. var idx = reverse ? --to : from++;
  3090. return array && array[idx];
  3091. };
  3092. }
  3093. function iterateNode(node, level, offset) {
  3094. var values;
  3095. var array = node && node.array;
  3096. var from = offset > left ? 0 : (left - offset) >> level;
  3097. var to = ((right - offset) >> level) + 1;
  3098. if (to > SIZE) {
  3099. to = SIZE;
  3100. }
  3101. return function () {
  3102. while (true) {
  3103. if (values) {
  3104. var value = values();
  3105. if (value !== DONE) {
  3106. return value;
  3107. }
  3108. values = null;
  3109. }
  3110. if (from === to) {
  3111. return DONE;
  3112. }
  3113. var idx = reverse ? --to : from++;
  3114. values = iterateNodeOrLeaf(
  3115. array && array[idx],
  3116. level - SHIFT,
  3117. offset + (idx << level)
  3118. );
  3119. }
  3120. };
  3121. }
  3122. }
  3123. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  3124. var list = Object.create(ListPrototype);
  3125. list.size = capacity - origin;
  3126. list._origin = origin;
  3127. list._capacity = capacity;
  3128. list._level = level;
  3129. list._root = root;
  3130. list._tail = tail;
  3131. list.__ownerID = ownerID;
  3132. list.__hash = hash;
  3133. list.__altered = false;
  3134. return list;
  3135. }
  3136. var EMPTY_LIST;
  3137. function emptyList() {
  3138. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  3139. }
  3140. function updateList(list, index, value) {
  3141. index = wrapIndex(list, index);
  3142. if (index !== index) {
  3143. return list;
  3144. }
  3145. if (index >= list.size || index < 0) {
  3146. return list.withMutations(function (list) {
  3147. index < 0
  3148. ? setListBounds(list, index).set(0, value)
  3149. : setListBounds(list, 0, index + 1).set(index, value);
  3150. });
  3151. }
  3152. index += list._origin;
  3153. var newTail = list._tail;
  3154. var newRoot = list._root;
  3155. var didAlter = MakeRef();
  3156. if (index >= getTailOffset(list._capacity)) {
  3157. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  3158. } else {
  3159. newRoot = updateVNode(
  3160. newRoot,
  3161. list.__ownerID,
  3162. list._level,
  3163. index,
  3164. value,
  3165. didAlter
  3166. );
  3167. }
  3168. if (!didAlter.value) {
  3169. return list;
  3170. }
  3171. if (list.__ownerID) {
  3172. list._root = newRoot;
  3173. list._tail = newTail;
  3174. list.__hash = undefined;
  3175. list.__altered = true;
  3176. return list;
  3177. }
  3178. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  3179. }
  3180. function updateVNode(node, ownerID, level, index, value, didAlter) {
  3181. var idx = (index >>> level) & MASK;
  3182. var nodeHas = node && idx < node.array.length;
  3183. if (!nodeHas && value === undefined) {
  3184. return node;
  3185. }
  3186. var newNode;
  3187. if (level > 0) {
  3188. var lowerNode = node && node.array[idx];
  3189. var newLowerNode = updateVNode(
  3190. lowerNode,
  3191. ownerID,
  3192. level - SHIFT,
  3193. index,
  3194. value,
  3195. didAlter
  3196. );
  3197. if (newLowerNode === lowerNode) {
  3198. return node;
  3199. }
  3200. newNode = editableVNode(node, ownerID);
  3201. newNode.array[idx] = newLowerNode;
  3202. return newNode;
  3203. }
  3204. if (nodeHas && node.array[idx] === value) {
  3205. return node;
  3206. }
  3207. if (didAlter) {
  3208. SetRef(didAlter);
  3209. }
  3210. newNode = editableVNode(node, ownerID);
  3211. if (value === undefined && idx === newNode.array.length - 1) {
  3212. newNode.array.pop();
  3213. } else {
  3214. newNode.array[idx] = value;
  3215. }
  3216. return newNode;
  3217. }
  3218. function editableVNode(node, ownerID) {
  3219. if (ownerID && node && ownerID === node.ownerID) {
  3220. return node;
  3221. }
  3222. return new VNode(node ? node.array.slice() : [], ownerID);
  3223. }
  3224. function listNodeFor(list, rawIndex) {
  3225. if (rawIndex >= getTailOffset(list._capacity)) {
  3226. return list._tail;
  3227. }
  3228. if (rawIndex < 1 << (list._level + SHIFT)) {
  3229. var node = list._root;
  3230. var level = list._level;
  3231. while (node && level > 0) {
  3232. node = node.array[(rawIndex >>> level) & MASK];
  3233. level -= SHIFT;
  3234. }
  3235. return node;
  3236. }
  3237. }
  3238. function setListBounds(list, begin, end) {
  3239. // Sanitize begin & end using this shorthand for ToInt32(argument)
  3240. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  3241. if (begin !== undefined) {
  3242. begin |= 0;
  3243. }
  3244. if (end !== undefined) {
  3245. end |= 0;
  3246. }
  3247. var owner = list.__ownerID || new OwnerID();
  3248. var oldOrigin = list._origin;
  3249. var oldCapacity = list._capacity;
  3250. var newOrigin = oldOrigin + begin;
  3251. var newCapacity =
  3252. end === undefined
  3253. ? oldCapacity
  3254. : end < 0
  3255. ? oldCapacity + end
  3256. : oldOrigin + end;
  3257. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  3258. return list;
  3259. }
  3260. // If it's going to end after it starts, it's empty.
  3261. if (newOrigin >= newCapacity) {
  3262. return list.clear();
  3263. }
  3264. var newLevel = list._level;
  3265. var newRoot = list._root;
  3266. // New origin might need creating a higher root.
  3267. var offsetShift = 0;
  3268. while (newOrigin + offsetShift < 0) {
  3269. newRoot = new VNode(
  3270. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  3271. owner
  3272. );
  3273. newLevel += SHIFT;
  3274. offsetShift += 1 << newLevel;
  3275. }
  3276. if (offsetShift) {
  3277. newOrigin += offsetShift;
  3278. oldOrigin += offsetShift;
  3279. newCapacity += offsetShift;
  3280. oldCapacity += offsetShift;
  3281. }
  3282. var oldTailOffset = getTailOffset(oldCapacity);
  3283. var newTailOffset = getTailOffset(newCapacity);
  3284. // New size might need creating a higher root.
  3285. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  3286. newRoot = new VNode(
  3287. newRoot && newRoot.array.length ? [newRoot] : [],
  3288. owner
  3289. );
  3290. newLevel += SHIFT;
  3291. }
  3292. // Locate or create the new tail.
  3293. var oldTail = list._tail;
  3294. var newTail =
  3295. newTailOffset < oldTailOffset
  3296. ? listNodeFor(list, newCapacity - 1)
  3297. : newTailOffset > oldTailOffset
  3298. ? new VNode([], owner)
  3299. : oldTail;
  3300. // Merge Tail into tree.
  3301. if (
  3302. oldTail &&
  3303. newTailOffset > oldTailOffset &&
  3304. newOrigin < oldCapacity &&
  3305. oldTail.array.length
  3306. ) {
  3307. newRoot = editableVNode(newRoot, owner);
  3308. var node = newRoot;
  3309. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  3310. var idx = (oldTailOffset >>> level) & MASK;
  3311. node = node.array[idx] = editableVNode(node.array[idx], owner);
  3312. }
  3313. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  3314. }
  3315. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  3316. if (newCapacity < oldCapacity) {
  3317. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  3318. }
  3319. // If the new origin is within the tail, then we do not need a root.
  3320. if (newOrigin >= newTailOffset) {
  3321. newOrigin -= newTailOffset;
  3322. newCapacity -= newTailOffset;
  3323. newLevel = SHIFT;
  3324. newRoot = null;
  3325. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  3326. // Otherwise, if the root has been trimmed, garbage collect.
  3327. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  3328. offsetShift = 0;
  3329. // Identify the new top root node of the subtree of the old root.
  3330. while (newRoot) {
  3331. var beginIndex = (newOrigin >>> newLevel) & MASK;
  3332. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  3333. break;
  3334. }
  3335. if (beginIndex) {
  3336. offsetShift += (1 << newLevel) * beginIndex;
  3337. }
  3338. newLevel -= SHIFT;
  3339. newRoot = newRoot.array[beginIndex];
  3340. }
  3341. // Trim the new sides of the new root.
  3342. if (newRoot && newOrigin > oldOrigin) {
  3343. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  3344. }
  3345. if (newRoot && newTailOffset < oldTailOffset) {
  3346. newRoot = newRoot.removeAfter(
  3347. owner,
  3348. newLevel,
  3349. newTailOffset - offsetShift
  3350. );
  3351. }
  3352. if (offsetShift) {
  3353. newOrigin -= offsetShift;
  3354. newCapacity -= offsetShift;
  3355. }
  3356. }
  3357. if (list.__ownerID) {
  3358. list.size = newCapacity - newOrigin;
  3359. list._origin = newOrigin;
  3360. list._capacity = newCapacity;
  3361. list._level = newLevel;
  3362. list._root = newRoot;
  3363. list._tail = newTail;
  3364. list.__hash = undefined;
  3365. list.__altered = true;
  3366. return list;
  3367. }
  3368. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  3369. }
  3370. function getTailOffset(size) {
  3371. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  3372. }
  3373. var OrderedMap = /*@__PURE__*/(function (Map) {
  3374. function OrderedMap(value) {
  3375. // eslint-disable-next-line no-constructor-return
  3376. return value === undefined || value === null
  3377. ? emptyOrderedMap()
  3378. : isOrderedMap(value)
  3379. ? value
  3380. : emptyOrderedMap().withMutations(function (map) {
  3381. var iter = KeyedCollection(value);
  3382. assertNotInfinite(iter.size);
  3383. iter.forEach(function (v, k) { return map.set(k, v); });
  3384. });
  3385. }
  3386. if ( Map ) OrderedMap.__proto__ = Map;
  3387. OrderedMap.prototype = Object.create( Map && Map.prototype );
  3388. OrderedMap.prototype.constructor = OrderedMap;
  3389. OrderedMap.of = function of (/*...values*/) {
  3390. return this(arguments);
  3391. };
  3392. OrderedMap.prototype.toString = function toString () {
  3393. return this.__toString('OrderedMap {', '}');
  3394. };
  3395. // @pragma Access
  3396. OrderedMap.prototype.get = function get (k, notSetValue) {
  3397. var index = this._map.get(k);
  3398. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  3399. };
  3400. // @pragma Modification
  3401. OrderedMap.prototype.clear = function clear () {
  3402. if (this.size === 0) {
  3403. return this;
  3404. }
  3405. if (this.__ownerID) {
  3406. this.size = 0;
  3407. this._map.clear();
  3408. this._list.clear();
  3409. this.__altered = true;
  3410. return this;
  3411. }
  3412. return emptyOrderedMap();
  3413. };
  3414. OrderedMap.prototype.set = function set (k, v) {
  3415. return updateOrderedMap(this, k, v);
  3416. };
  3417. OrderedMap.prototype.remove = function remove (k) {
  3418. return updateOrderedMap(this, k, NOT_SET);
  3419. };
  3420. OrderedMap.prototype.__iterate = function __iterate (fn, reverse) {
  3421. var this$1$1 = this;
  3422. return this._list.__iterate(
  3423. function (entry) { return entry && fn(entry[1], entry[0], this$1$1); },
  3424. reverse
  3425. );
  3426. };
  3427. OrderedMap.prototype.__iterator = function __iterator (type, reverse) {
  3428. return this._list.fromEntrySeq().__iterator(type, reverse);
  3429. };
  3430. OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3431. if (ownerID === this.__ownerID) {
  3432. return this;
  3433. }
  3434. var newMap = this._map.__ensureOwner(ownerID);
  3435. var newList = this._list.__ensureOwner(ownerID);
  3436. if (!ownerID) {
  3437. if (this.size === 0) {
  3438. return emptyOrderedMap();
  3439. }
  3440. this.__ownerID = ownerID;
  3441. this.__altered = false;
  3442. this._map = newMap;
  3443. this._list = newList;
  3444. return this;
  3445. }
  3446. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  3447. };
  3448. return OrderedMap;
  3449. }(Map));
  3450. OrderedMap.isOrderedMap = isOrderedMap;
  3451. OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
  3452. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  3453. function makeOrderedMap(map, list, ownerID, hash) {
  3454. var omap = Object.create(OrderedMap.prototype);
  3455. omap.size = map ? map.size : 0;
  3456. omap._map = map;
  3457. omap._list = list;
  3458. omap.__ownerID = ownerID;
  3459. omap.__hash = hash;
  3460. omap.__altered = false;
  3461. return omap;
  3462. }
  3463. var EMPTY_ORDERED_MAP;
  3464. function emptyOrderedMap() {
  3465. return (
  3466. EMPTY_ORDERED_MAP ||
  3467. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  3468. );
  3469. }
  3470. function updateOrderedMap(omap, k, v) {
  3471. var map = omap._map;
  3472. var list = omap._list;
  3473. var i = map.get(k);
  3474. var has = i !== undefined;
  3475. var newMap;
  3476. var newList;
  3477. if (v === NOT_SET) {
  3478. // removed
  3479. if (!has) {
  3480. return omap;
  3481. }
  3482. if (list.size >= SIZE && list.size >= map.size * 2) {
  3483. newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; });
  3484. newMap = newList
  3485. .toKeyedSeq()
  3486. .map(function (entry) { return entry[0]; })
  3487. .flip()
  3488. .toMap();
  3489. if (omap.__ownerID) {
  3490. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  3491. }
  3492. } else {
  3493. newMap = map.remove(k);
  3494. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  3495. }
  3496. } else if (has) {
  3497. if (v === list.get(i)[1]) {
  3498. return omap;
  3499. }
  3500. newMap = map;
  3501. newList = list.set(i, [k, v]);
  3502. } else {
  3503. newMap = map.set(k, list.size);
  3504. newList = list.set(list.size, [k, v]);
  3505. }
  3506. if (omap.__ownerID) {
  3507. omap.size = newMap.size;
  3508. omap._map = newMap;
  3509. omap._list = newList;
  3510. omap.__hash = undefined;
  3511. omap.__altered = true;
  3512. return omap;
  3513. }
  3514. return makeOrderedMap(newMap, newList);
  3515. }
  3516. var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@';
  3517. function isStack(maybeStack) {
  3518. return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
  3519. }
  3520. var Stack = /*@__PURE__*/(function (IndexedCollection) {
  3521. function Stack(value) {
  3522. // eslint-disable-next-line no-constructor-return
  3523. return value === undefined || value === null
  3524. ? emptyStack()
  3525. : isStack(value)
  3526. ? value
  3527. : emptyStack().pushAll(value);
  3528. }
  3529. if ( IndexedCollection ) Stack.__proto__ = IndexedCollection;
  3530. Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype );
  3531. Stack.prototype.constructor = Stack;
  3532. Stack.of = function of (/*...values*/) {
  3533. return this(arguments);
  3534. };
  3535. Stack.prototype.toString = function toString () {
  3536. return this.__toString('Stack [', ']');
  3537. };
  3538. // @pragma Access
  3539. Stack.prototype.get = function get (index, notSetValue) {
  3540. var head = this._head;
  3541. index = wrapIndex(this, index);
  3542. while (head && index--) {
  3543. head = head.next;
  3544. }
  3545. return head ? head.value : notSetValue;
  3546. };
  3547. Stack.prototype.peek = function peek () {
  3548. return this._head && this._head.value;
  3549. };
  3550. // @pragma Modification
  3551. Stack.prototype.push = function push (/*...values*/) {
  3552. var arguments$1 = arguments;
  3553. if (arguments.length === 0) {
  3554. return this;
  3555. }
  3556. var newSize = this.size + arguments.length;
  3557. var head = this._head;
  3558. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  3559. head = {
  3560. value: arguments$1[ii],
  3561. next: head,
  3562. };
  3563. }
  3564. if (this.__ownerID) {
  3565. this.size = newSize;
  3566. this._head = head;
  3567. this.__hash = undefined;
  3568. this.__altered = true;
  3569. return this;
  3570. }
  3571. return makeStack(newSize, head);
  3572. };
  3573. Stack.prototype.pushAll = function pushAll (iter) {
  3574. iter = IndexedCollection(iter);
  3575. if (iter.size === 0) {
  3576. return this;
  3577. }
  3578. if (this.size === 0 && isStack(iter)) {
  3579. return iter;
  3580. }
  3581. assertNotInfinite(iter.size);
  3582. var newSize = this.size;
  3583. var head = this._head;
  3584. iter.__iterate(function (value) {
  3585. newSize++;
  3586. head = {
  3587. value: value,
  3588. next: head,
  3589. };
  3590. }, /* reverse */ true);
  3591. if (this.__ownerID) {
  3592. this.size = newSize;
  3593. this._head = head;
  3594. this.__hash = undefined;
  3595. this.__altered = true;
  3596. return this;
  3597. }
  3598. return makeStack(newSize, head);
  3599. };
  3600. Stack.prototype.pop = function pop () {
  3601. return this.slice(1);
  3602. };
  3603. Stack.prototype.clear = function clear () {
  3604. if (this.size === 0) {
  3605. return this;
  3606. }
  3607. if (this.__ownerID) {
  3608. this.size = 0;
  3609. this._head = undefined;
  3610. this.__hash = undefined;
  3611. this.__altered = true;
  3612. return this;
  3613. }
  3614. return emptyStack();
  3615. };
  3616. Stack.prototype.slice = function slice (begin, end) {
  3617. if (wholeSlice(begin, end, this.size)) {
  3618. return this;
  3619. }
  3620. var resolvedBegin = resolveBegin(begin, this.size);
  3621. var resolvedEnd = resolveEnd(end, this.size);
  3622. if (resolvedEnd !== this.size) {
  3623. // super.slice(begin, end);
  3624. return IndexedCollection.prototype.slice.call(this, begin, end);
  3625. }
  3626. var newSize = this.size - resolvedBegin;
  3627. var head = this._head;
  3628. while (resolvedBegin--) {
  3629. head = head.next;
  3630. }
  3631. if (this.__ownerID) {
  3632. this.size = newSize;
  3633. this._head = head;
  3634. this.__hash = undefined;
  3635. this.__altered = true;
  3636. return this;
  3637. }
  3638. return makeStack(newSize, head);
  3639. };
  3640. // @pragma Mutability
  3641. Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3642. if (ownerID === this.__ownerID) {
  3643. return this;
  3644. }
  3645. if (!ownerID) {
  3646. if (this.size === 0) {
  3647. return emptyStack();
  3648. }
  3649. this.__ownerID = ownerID;
  3650. this.__altered = false;
  3651. return this;
  3652. }
  3653. return makeStack(this.size, this._head, ownerID, this.__hash);
  3654. };
  3655. // @pragma Iteration
  3656. Stack.prototype.__iterate = function __iterate (fn, reverse) {
  3657. var this$1$1 = this;
  3658. if (reverse) {
  3659. return new ArraySeq(this.toArray()).__iterate(
  3660. function (v, k) { return fn(v, k, this$1$1); },
  3661. reverse
  3662. );
  3663. }
  3664. var iterations = 0;
  3665. var node = this._head;
  3666. while (node) {
  3667. if (fn(node.value, iterations++, this) === false) {
  3668. break;
  3669. }
  3670. node = node.next;
  3671. }
  3672. return iterations;
  3673. };
  3674. Stack.prototype.__iterator = function __iterator (type, reverse) {
  3675. if (reverse) {
  3676. return new ArraySeq(this.toArray()).__iterator(type, reverse);
  3677. }
  3678. var iterations = 0;
  3679. var node = this._head;
  3680. return new Iterator(function () {
  3681. if (node) {
  3682. var value = node.value;
  3683. node = node.next;
  3684. return iteratorValue(type, iterations++, value);
  3685. }
  3686. return iteratorDone();
  3687. });
  3688. };
  3689. return Stack;
  3690. }(IndexedCollection));
  3691. Stack.isStack = isStack;
  3692. var StackPrototype = Stack.prototype;
  3693. StackPrototype[IS_STACK_SYMBOL] = true;
  3694. StackPrototype.shift = StackPrototype.pop;
  3695. StackPrototype.unshift = StackPrototype.push;
  3696. StackPrototype.unshiftAll = StackPrototype.pushAll;
  3697. StackPrototype.withMutations = withMutations;
  3698. StackPrototype.wasAltered = wasAltered;
  3699. StackPrototype.asImmutable = asImmutable;
  3700. StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
  3701. StackPrototype['@@transducer/step'] = function (result, arr) {
  3702. return result.unshift(arr);
  3703. };
  3704. StackPrototype['@@transducer/result'] = function (obj) {
  3705. return obj.asImmutable();
  3706. };
  3707. function makeStack(size, head, ownerID, hash) {
  3708. var map = Object.create(StackPrototype);
  3709. map.size = size;
  3710. map._head = head;
  3711. map.__ownerID = ownerID;
  3712. map.__hash = hash;
  3713. map.__altered = false;
  3714. return map;
  3715. }
  3716. var EMPTY_STACK;
  3717. function emptyStack() {
  3718. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  3719. }
  3720. var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@';
  3721. function isSet(maybeSet) {
  3722. return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
  3723. }
  3724. function isOrderedSet(maybeOrderedSet) {
  3725. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  3726. }
  3727. function deepEqual(a, b) {
  3728. if (a === b) {
  3729. return true;
  3730. }
  3731. if (
  3732. !isCollection(b) ||
  3733. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  3734. (a.__hash !== undefined &&
  3735. b.__hash !== undefined &&
  3736. a.__hash !== b.__hash) ||
  3737. isKeyed(a) !== isKeyed(b) ||
  3738. isIndexed(a) !== isIndexed(b) ||
  3739. isOrdered(a) !== isOrdered(b)
  3740. ) {
  3741. return false;
  3742. }
  3743. if (a.size === 0 && b.size === 0) {
  3744. return true;
  3745. }
  3746. var notAssociative = !isAssociative(a);
  3747. if (isOrdered(a)) {
  3748. var entries = a.entries();
  3749. return (
  3750. b.every(function (v, k) {
  3751. var entry = entries.next().value;
  3752. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  3753. }) && entries.next().done
  3754. );
  3755. }
  3756. var flipped = false;
  3757. if (a.size === undefined) {
  3758. if (b.size === undefined) {
  3759. if (typeof a.cacheResult === 'function') {
  3760. a.cacheResult();
  3761. }
  3762. } else {
  3763. flipped = true;
  3764. var _ = a;
  3765. a = b;
  3766. b = _;
  3767. }
  3768. }
  3769. var allEqual = true;
  3770. var bSize = b.__iterate(function (v, k) {
  3771. if (
  3772. notAssociative
  3773. ? !a.has(v)
  3774. : flipped
  3775. ? !is(v, a.get(k, NOT_SET))
  3776. : !is(a.get(k, NOT_SET), v)
  3777. ) {
  3778. allEqual = false;
  3779. return false;
  3780. }
  3781. });
  3782. return allEqual && a.size === bSize;
  3783. }
  3784. function mixin(ctor, methods) {
  3785. var keyCopier = function (key) {
  3786. ctor.prototype[key] = methods[key];
  3787. };
  3788. Object.keys(methods).forEach(keyCopier);
  3789. Object.getOwnPropertySymbols &&
  3790. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  3791. return ctor;
  3792. }
  3793. function toJS(value) {
  3794. if (!value || typeof value !== 'object') {
  3795. return value;
  3796. }
  3797. if (!isCollection(value)) {
  3798. if (!isDataStructure(value)) {
  3799. return value;
  3800. }
  3801. value = Seq(value);
  3802. }
  3803. if (isKeyed(value)) {
  3804. var result$1 = {};
  3805. value.__iterate(function (v, k) {
  3806. if (isProtoKey(k)) {
  3807. return;
  3808. }
  3809. result$1[k] = toJS(v);
  3810. });
  3811. return result$1;
  3812. }
  3813. var result = [];
  3814. value.__iterate(function (v) {
  3815. result.push(toJS(v));
  3816. });
  3817. return result;
  3818. }
  3819. var Set = /*@__PURE__*/(function (SetCollection) {
  3820. function Set(value) {
  3821. // eslint-disable-next-line no-constructor-return
  3822. return value === undefined || value === null
  3823. ? emptySet()
  3824. : isSet(value) && !isOrdered(value)
  3825. ? value
  3826. : emptySet().withMutations(function (set) {
  3827. var iter = SetCollection(value);
  3828. assertNotInfinite(iter.size);
  3829. iter.forEach(function (v) { return set.add(v); });
  3830. });
  3831. }
  3832. if ( SetCollection ) Set.__proto__ = SetCollection;
  3833. Set.prototype = Object.create( SetCollection && SetCollection.prototype );
  3834. Set.prototype.constructor = Set;
  3835. Set.of = function of (/*...values*/) {
  3836. return this(arguments);
  3837. };
  3838. Set.fromKeys = function fromKeys (value) {
  3839. return this(KeyedCollection(value).keySeq());
  3840. };
  3841. Set.intersect = function intersect (sets) {
  3842. sets = Collection(sets).toArray();
  3843. return sets.length
  3844. ? SetPrototype.intersect.apply(Set(sets.pop()), sets)
  3845. : emptySet();
  3846. };
  3847. Set.union = function union (sets) {
  3848. sets = Collection(sets).toArray();
  3849. return sets.length
  3850. ? SetPrototype.union.apply(Set(sets.pop()), sets)
  3851. : emptySet();
  3852. };
  3853. Set.prototype.toString = function toString () {
  3854. return this.__toString('Set {', '}');
  3855. };
  3856. // @pragma Access
  3857. Set.prototype.has = function has (value) {
  3858. return this._map.has(value);
  3859. };
  3860. // @pragma Modification
  3861. Set.prototype.add = function add (value) {
  3862. return updateSet(this, this._map.set(value, value));
  3863. };
  3864. Set.prototype.remove = function remove (value) {
  3865. return updateSet(this, this._map.remove(value));
  3866. };
  3867. Set.prototype.clear = function clear () {
  3868. return updateSet(this, this._map.clear());
  3869. };
  3870. // @pragma Composition
  3871. Set.prototype.map = function map (mapper, context) {
  3872. var this$1$1 = this;
  3873. // keep track if the set is altered by the map function
  3874. var didChanges = false;
  3875. var newMap = updateSet(
  3876. this,
  3877. this._map.mapEntries(function (ref) {
  3878. var v = ref[1];
  3879. var mapped = mapper.call(context, v, v, this$1$1);
  3880. if (mapped !== v) {
  3881. didChanges = true;
  3882. }
  3883. return [mapped, mapped];
  3884. }, context)
  3885. );
  3886. return didChanges ? newMap : this;
  3887. };
  3888. Set.prototype.union = function union () {
  3889. var iters = [], len = arguments.length;
  3890. while ( len-- ) iters[ len ] = arguments[ len ];
  3891. iters = iters.filter(function (x) { return x.size !== 0; });
  3892. if (iters.length === 0) {
  3893. return this;
  3894. }
  3895. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  3896. return this.constructor(iters[0]);
  3897. }
  3898. return this.withMutations(function (set) {
  3899. for (var ii = 0; ii < iters.length; ii++) {
  3900. if (typeof iters[ii] === 'string') {
  3901. set.add(iters[ii]);
  3902. } else {
  3903. SetCollection(iters[ii]).forEach(function (value) { return set.add(value); });
  3904. }
  3905. }
  3906. });
  3907. };
  3908. Set.prototype.intersect = function intersect () {
  3909. var iters = [], len = arguments.length;
  3910. while ( len-- ) iters[ len ] = arguments[ len ];
  3911. if (iters.length === 0) {
  3912. return this;
  3913. }
  3914. iters = iters.map(function (iter) { return SetCollection(iter); });
  3915. var toRemove = [];
  3916. this.forEach(function (value) {
  3917. if (!iters.every(function (iter) { return iter.includes(value); })) {
  3918. toRemove.push(value);
  3919. }
  3920. });
  3921. return this.withMutations(function (set) {
  3922. toRemove.forEach(function (value) {
  3923. set.remove(value);
  3924. });
  3925. });
  3926. };
  3927. Set.prototype.subtract = function subtract () {
  3928. var iters = [], len = arguments.length;
  3929. while ( len-- ) iters[ len ] = arguments[ len ];
  3930. if (iters.length === 0) {
  3931. return this;
  3932. }
  3933. iters = iters.map(function (iter) { return SetCollection(iter); });
  3934. var toRemove = [];
  3935. this.forEach(function (value) {
  3936. if (iters.some(function (iter) { return iter.includes(value); })) {
  3937. toRemove.push(value);
  3938. }
  3939. });
  3940. return this.withMutations(function (set) {
  3941. toRemove.forEach(function (value) {
  3942. set.remove(value);
  3943. });
  3944. });
  3945. };
  3946. Set.prototype.sort = function sort (comparator) {
  3947. // Late binding
  3948. return OrderedSet(sortFactory(this, comparator));
  3949. };
  3950. Set.prototype.sortBy = function sortBy (mapper, comparator) {
  3951. // Late binding
  3952. return OrderedSet(sortFactory(this, comparator, mapper));
  3953. };
  3954. Set.prototype.wasAltered = function wasAltered () {
  3955. return this._map.wasAltered();
  3956. };
  3957. Set.prototype.__iterate = function __iterate (fn, reverse) {
  3958. var this$1$1 = this;
  3959. return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse);
  3960. };
  3961. Set.prototype.__iterator = function __iterator (type, reverse) {
  3962. return this._map.__iterator(type, reverse);
  3963. };
  3964. Set.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3965. if (ownerID === this.__ownerID) {
  3966. return this;
  3967. }
  3968. var newMap = this._map.__ensureOwner(ownerID);
  3969. if (!ownerID) {
  3970. if (this.size === 0) {
  3971. return this.__empty();
  3972. }
  3973. this.__ownerID = ownerID;
  3974. this._map = newMap;
  3975. return this;
  3976. }
  3977. return this.__make(newMap, ownerID);
  3978. };
  3979. return Set;
  3980. }(SetCollection));
  3981. Set.isSet = isSet;
  3982. var SetPrototype = Set.prototype;
  3983. SetPrototype[IS_SET_SYMBOL] = true;
  3984. SetPrototype[DELETE] = SetPrototype.remove;
  3985. SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
  3986. SetPrototype.withMutations = withMutations;
  3987. SetPrototype.asImmutable = asImmutable;
  3988. SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
  3989. SetPrototype['@@transducer/step'] = function (result, arr) {
  3990. return result.add(arr);
  3991. };
  3992. SetPrototype['@@transducer/result'] = function (obj) {
  3993. return obj.asImmutable();
  3994. };
  3995. SetPrototype.__empty = emptySet;
  3996. SetPrototype.__make = makeSet;
  3997. function updateSet(set, newMap) {
  3998. if (set.__ownerID) {
  3999. set.size = newMap.size;
  4000. set._map = newMap;
  4001. return set;
  4002. }
  4003. return newMap === set._map
  4004. ? set
  4005. : newMap.size === 0
  4006. ? set.__empty()
  4007. : set.__make(newMap);
  4008. }
  4009. function makeSet(map, ownerID) {
  4010. var set = Object.create(SetPrototype);
  4011. set.size = map ? map.size : 0;
  4012. set._map = map;
  4013. set.__ownerID = ownerID;
  4014. return set;
  4015. }
  4016. var EMPTY_SET;
  4017. function emptySet() {
  4018. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  4019. }
  4020. /**
  4021. * Returns a lazy seq of nums from start (inclusive) to end
  4022. * (exclusive), by step, where start defaults to 0, step to 1, and end to
  4023. * infinity. When start is equal to end, returns empty list.
  4024. */
  4025. var Range = /*@__PURE__*/(function (IndexedSeq) {
  4026. function Range(start, end, step) {
  4027. if (!(this instanceof Range)) {
  4028. // eslint-disable-next-line no-constructor-return
  4029. return new Range(start, end, step);
  4030. }
  4031. invariant(step !== 0, 'Cannot step a Range by 0');
  4032. start = start || 0;
  4033. if (end === undefined) {
  4034. end = Infinity;
  4035. }
  4036. step = step === undefined ? 1 : Math.abs(step);
  4037. if (end < start) {
  4038. step = -step;
  4039. }
  4040. this._start = start;
  4041. this._end = end;
  4042. this._step = step;
  4043. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  4044. if (this.size === 0) {
  4045. if (EMPTY_RANGE) {
  4046. // eslint-disable-next-line no-constructor-return
  4047. return EMPTY_RANGE;
  4048. }
  4049. EMPTY_RANGE = this;
  4050. }
  4051. }
  4052. if ( IndexedSeq ) Range.__proto__ = IndexedSeq;
  4053. Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  4054. Range.prototype.constructor = Range;
  4055. Range.prototype.toString = function toString () {
  4056. if (this.size === 0) {
  4057. return 'Range []';
  4058. }
  4059. return (
  4060. 'Range [ ' +
  4061. this._start +
  4062. '...' +
  4063. this._end +
  4064. (this._step !== 1 ? ' by ' + this._step : '') +
  4065. ' ]'
  4066. );
  4067. };
  4068. Range.prototype.get = function get (index, notSetValue) {
  4069. return this.has(index)
  4070. ? this._start + wrapIndex(this, index) * this._step
  4071. : notSetValue;
  4072. };
  4073. Range.prototype.includes = function includes (searchValue) {
  4074. var possibleIndex = (searchValue - this._start) / this._step;
  4075. return (
  4076. possibleIndex >= 0 &&
  4077. possibleIndex < this.size &&
  4078. possibleIndex === Math.floor(possibleIndex)
  4079. );
  4080. };
  4081. Range.prototype.slice = function slice (begin, end) {
  4082. if (wholeSlice(begin, end, this.size)) {
  4083. return this;
  4084. }
  4085. begin = resolveBegin(begin, this.size);
  4086. end = resolveEnd(end, this.size);
  4087. if (end <= begin) {
  4088. return new Range(0, 0);
  4089. }
  4090. return new Range(
  4091. this.get(begin, this._end),
  4092. this.get(end, this._end),
  4093. this._step
  4094. );
  4095. };
  4096. Range.prototype.indexOf = function indexOf (searchValue) {
  4097. var offsetValue = searchValue - this._start;
  4098. if (offsetValue % this._step === 0) {
  4099. var index = offsetValue / this._step;
  4100. if (index >= 0 && index < this.size) {
  4101. return index;
  4102. }
  4103. }
  4104. return -1;
  4105. };
  4106. Range.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  4107. return this.indexOf(searchValue);
  4108. };
  4109. Range.prototype.__iterate = function __iterate (fn, reverse) {
  4110. var size = this.size;
  4111. var step = this._step;
  4112. var value = reverse ? this._start + (size - 1) * step : this._start;
  4113. var i = 0;
  4114. while (i !== size) {
  4115. if (fn(value, reverse ? size - ++i : i++, this) === false) {
  4116. break;
  4117. }
  4118. value += reverse ? -step : step;
  4119. }
  4120. return i;
  4121. };
  4122. Range.prototype.__iterator = function __iterator (type, reverse) {
  4123. var size = this.size;
  4124. var step = this._step;
  4125. var value = reverse ? this._start + (size - 1) * step : this._start;
  4126. var i = 0;
  4127. return new Iterator(function () {
  4128. if (i === size) {
  4129. return iteratorDone();
  4130. }
  4131. var v = value;
  4132. value += reverse ? -step : step;
  4133. return iteratorValue(type, reverse ? size - ++i : i++, v);
  4134. });
  4135. };
  4136. Range.prototype.equals = function equals (other) {
  4137. return other instanceof Range
  4138. ? this._start === other._start &&
  4139. this._end === other._end &&
  4140. this._step === other._step
  4141. : deepEqual(this, other);
  4142. };
  4143. return Range;
  4144. }(IndexedSeq));
  4145. var EMPTY_RANGE;
  4146. function getIn$1(collection, searchKeyPath, notSetValue) {
  4147. var keyPath = coerceKeyPath(searchKeyPath);
  4148. var i = 0;
  4149. while (i !== keyPath.length) {
  4150. collection = get(collection, keyPath[i++], NOT_SET);
  4151. if (collection === NOT_SET) {
  4152. return notSetValue;
  4153. }
  4154. }
  4155. return collection;
  4156. }
  4157. function getIn(searchKeyPath, notSetValue) {
  4158. return getIn$1(this, searchKeyPath, notSetValue);
  4159. }
  4160. function hasIn$1(collection, keyPath) {
  4161. return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET;
  4162. }
  4163. function hasIn(searchKeyPath) {
  4164. return hasIn$1(this, searchKeyPath);
  4165. }
  4166. function toObject() {
  4167. assertNotInfinite(this.size);
  4168. var object = {};
  4169. this.__iterate(function (v, k) {
  4170. if (isProtoKey(k)) {
  4171. return;
  4172. }
  4173. object[k] = v;
  4174. });
  4175. return object;
  4176. }
  4177. // Note: all of these methods are deprecated.
  4178. Collection.isIterable = isCollection;
  4179. Collection.isKeyed = isKeyed;
  4180. Collection.isIndexed = isIndexed;
  4181. Collection.isAssociative = isAssociative;
  4182. Collection.isOrdered = isOrdered;
  4183. Collection.Iterator = Iterator;
  4184. mixin(Collection, {
  4185. // ### Conversion to other types
  4186. toArray: function toArray() {
  4187. assertNotInfinite(this.size);
  4188. var array = new Array(this.size || 0);
  4189. var useTuples = isKeyed(this);
  4190. var i = 0;
  4191. this.__iterate(function (v, k) {
  4192. // Keyed collections produce an array of tuples.
  4193. array[i++] = useTuples ? [k, v] : v;
  4194. });
  4195. return array;
  4196. },
  4197. toIndexedSeq: function toIndexedSeq() {
  4198. return new ToIndexedSequence(this);
  4199. },
  4200. toJS: function toJS$1() {
  4201. return toJS(this);
  4202. },
  4203. toKeyedSeq: function toKeyedSeq() {
  4204. return new ToKeyedSequence(this, true);
  4205. },
  4206. toMap: function toMap() {
  4207. // Use Late Binding here to solve the circular dependency.
  4208. return Map(this.toKeyedSeq());
  4209. },
  4210. toObject: toObject,
  4211. toOrderedMap: function toOrderedMap() {
  4212. // Use Late Binding here to solve the circular dependency.
  4213. return OrderedMap(this.toKeyedSeq());
  4214. },
  4215. toOrderedSet: function toOrderedSet() {
  4216. // Use Late Binding here to solve the circular dependency.
  4217. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  4218. },
  4219. toSet: function toSet() {
  4220. // Use Late Binding here to solve the circular dependency.
  4221. return Set(isKeyed(this) ? this.valueSeq() : this);
  4222. },
  4223. toSetSeq: function toSetSeq() {
  4224. return new ToSetSequence(this);
  4225. },
  4226. toSeq: function toSeq() {
  4227. return isIndexed(this)
  4228. ? this.toIndexedSeq()
  4229. : isKeyed(this)
  4230. ? this.toKeyedSeq()
  4231. : this.toSetSeq();
  4232. },
  4233. toStack: function toStack() {
  4234. // Use Late Binding here to solve the circular dependency.
  4235. return Stack(isKeyed(this) ? this.valueSeq() : this);
  4236. },
  4237. toList: function toList() {
  4238. // Use Late Binding here to solve the circular dependency.
  4239. return List(isKeyed(this) ? this.valueSeq() : this);
  4240. },
  4241. // ### Common JavaScript methods and properties
  4242. toString: function toString() {
  4243. return '[Collection]';
  4244. },
  4245. __toString: function __toString(head, tail) {
  4246. if (this.size === 0) {
  4247. return head + tail;
  4248. }
  4249. return (
  4250. head +
  4251. ' ' +
  4252. this.toSeq().map(this.__toStringMapper).join(', ') +
  4253. ' ' +
  4254. tail
  4255. );
  4256. },
  4257. // ### ES6 Collection methods (ES6 Array and Map)
  4258. concat: function concat() {
  4259. var values = [], len = arguments.length;
  4260. while ( len-- ) values[ len ] = arguments[ len ];
  4261. return reify(this, concatFactory(this, values));
  4262. },
  4263. includes: function includes(searchValue) {
  4264. return this.some(function (value) { return is(value, searchValue); });
  4265. },
  4266. entries: function entries() {
  4267. return this.__iterator(ITERATE_ENTRIES);
  4268. },
  4269. every: function every(predicate, context) {
  4270. assertNotInfinite(this.size);
  4271. var returnValue = true;
  4272. this.__iterate(function (v, k, c) {
  4273. if (!predicate.call(context, v, k, c)) {
  4274. returnValue = false;
  4275. return false;
  4276. }
  4277. });
  4278. return returnValue;
  4279. },
  4280. filter: function filter(predicate, context) {
  4281. return reify(this, filterFactory(this, predicate, context, true));
  4282. },
  4283. partition: function partition(predicate, context) {
  4284. return partitionFactory(this, predicate, context);
  4285. },
  4286. find: function find(predicate, context, notSetValue) {
  4287. var entry = this.findEntry(predicate, context);
  4288. return entry ? entry[1] : notSetValue;
  4289. },
  4290. forEach: function forEach(sideEffect, context) {
  4291. assertNotInfinite(this.size);
  4292. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  4293. },
  4294. join: function join(separator) {
  4295. assertNotInfinite(this.size);
  4296. separator = separator !== undefined ? '' + separator : ',';
  4297. var joined = '';
  4298. var isFirst = true;
  4299. this.__iterate(function (v) {
  4300. isFirst ? (isFirst = false) : (joined += separator);
  4301. joined += v !== null && v !== undefined ? v.toString() : '';
  4302. });
  4303. return joined;
  4304. },
  4305. keys: function keys() {
  4306. return this.__iterator(ITERATE_KEYS);
  4307. },
  4308. map: function map(mapper, context) {
  4309. return reify(this, mapFactory(this, mapper, context));
  4310. },
  4311. reduce: function reduce$1(reducer, initialReduction, context) {
  4312. return reduce(
  4313. this,
  4314. reducer,
  4315. initialReduction,
  4316. context,
  4317. arguments.length < 2,
  4318. false
  4319. );
  4320. },
  4321. reduceRight: function reduceRight(reducer, initialReduction, context) {
  4322. return reduce(
  4323. this,
  4324. reducer,
  4325. initialReduction,
  4326. context,
  4327. arguments.length < 2,
  4328. true
  4329. );
  4330. },
  4331. reverse: function reverse() {
  4332. return reify(this, reverseFactory(this, true));
  4333. },
  4334. slice: function slice(begin, end) {
  4335. return reify(this, sliceFactory(this, begin, end, true));
  4336. },
  4337. some: function some(predicate, context) {
  4338. assertNotInfinite(this.size);
  4339. var returnValue = false;
  4340. this.__iterate(function (v, k, c) {
  4341. if (predicate.call(context, v, k, c)) {
  4342. returnValue = true;
  4343. return false;
  4344. }
  4345. });
  4346. return returnValue;
  4347. },
  4348. sort: function sort(comparator) {
  4349. return reify(this, sortFactory(this, comparator));
  4350. },
  4351. values: function values() {
  4352. return this.__iterator(ITERATE_VALUES);
  4353. },
  4354. // ### More sequential methods
  4355. butLast: function butLast() {
  4356. return this.slice(0, -1);
  4357. },
  4358. isEmpty: function isEmpty() {
  4359. return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; });
  4360. },
  4361. count: function count(predicate, context) {
  4362. return ensureSize(
  4363. predicate ? this.toSeq().filter(predicate, context) : this
  4364. );
  4365. },
  4366. countBy: function countBy(grouper, context) {
  4367. return countByFactory(this, grouper, context);
  4368. },
  4369. equals: function equals(other) {
  4370. return deepEqual(this, other);
  4371. },
  4372. entrySeq: function entrySeq() {
  4373. var collection = this;
  4374. if (collection._cache) {
  4375. // We cache as an entries array, so we can just return the cache!
  4376. return new ArraySeq(collection._cache);
  4377. }
  4378. var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq();
  4379. entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
  4380. return entriesSequence;
  4381. },
  4382. filterNot: function filterNot(predicate, context) {
  4383. return this.filter(not(predicate), context);
  4384. },
  4385. findEntry: function findEntry(predicate, context, notSetValue) {
  4386. var found = notSetValue;
  4387. this.__iterate(function (v, k, c) {
  4388. if (predicate.call(context, v, k, c)) {
  4389. found = [k, v];
  4390. return false;
  4391. }
  4392. });
  4393. return found;
  4394. },
  4395. findKey: function findKey(predicate, context) {
  4396. var entry = this.findEntry(predicate, context);
  4397. return entry && entry[0];
  4398. },
  4399. findLast: function findLast(predicate, context, notSetValue) {
  4400. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  4401. },
  4402. findLastEntry: function findLastEntry(predicate, context, notSetValue) {
  4403. return this.toKeyedSeq()
  4404. .reverse()
  4405. .findEntry(predicate, context, notSetValue);
  4406. },
  4407. findLastKey: function findLastKey(predicate, context) {
  4408. return this.toKeyedSeq().reverse().findKey(predicate, context);
  4409. },
  4410. first: function first(notSetValue) {
  4411. return this.find(returnTrue, null, notSetValue);
  4412. },
  4413. flatMap: function flatMap(mapper, context) {
  4414. return reify(this, flatMapFactory(this, mapper, context));
  4415. },
  4416. flatten: function flatten(depth) {
  4417. return reify(this, flattenFactory(this, depth, true));
  4418. },
  4419. fromEntrySeq: function fromEntrySeq() {
  4420. return new FromEntriesSequence(this);
  4421. },
  4422. get: function get(searchKey, notSetValue) {
  4423. return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
  4424. },
  4425. getIn: getIn,
  4426. groupBy: function groupBy(grouper, context) {
  4427. return groupByFactory(this, grouper, context);
  4428. },
  4429. has: function has(searchKey) {
  4430. return this.get(searchKey, NOT_SET) !== NOT_SET;
  4431. },
  4432. hasIn: hasIn,
  4433. isSubset: function isSubset(iter) {
  4434. iter = typeof iter.includes === 'function' ? iter : Collection(iter);
  4435. return this.every(function (value) { return iter.includes(value); });
  4436. },
  4437. isSuperset: function isSuperset(iter) {
  4438. iter = typeof iter.isSubset === 'function' ? iter : Collection(iter);
  4439. return iter.isSubset(this);
  4440. },
  4441. keyOf: function keyOf(searchValue) {
  4442. return this.findKey(function (value) { return is(value, searchValue); });
  4443. },
  4444. keySeq: function keySeq() {
  4445. return this.toSeq().map(keyMapper).toIndexedSeq();
  4446. },
  4447. last: function last(notSetValue) {
  4448. return this.toSeq().reverse().first(notSetValue);
  4449. },
  4450. lastKeyOf: function lastKeyOf(searchValue) {
  4451. return this.toKeyedSeq().reverse().keyOf(searchValue);
  4452. },
  4453. max: function max(comparator) {
  4454. return maxFactory(this, comparator);
  4455. },
  4456. maxBy: function maxBy(mapper, comparator) {
  4457. return maxFactory(this, comparator, mapper);
  4458. },
  4459. min: function min(comparator) {
  4460. return maxFactory(
  4461. this,
  4462. comparator ? neg(comparator) : defaultNegComparator
  4463. );
  4464. },
  4465. minBy: function minBy(mapper, comparator) {
  4466. return maxFactory(
  4467. this,
  4468. comparator ? neg(comparator) : defaultNegComparator,
  4469. mapper
  4470. );
  4471. },
  4472. rest: function rest() {
  4473. return this.slice(1);
  4474. },
  4475. skip: function skip(amount) {
  4476. return amount === 0 ? this : this.slice(Math.max(0, amount));
  4477. },
  4478. skipLast: function skipLast(amount) {
  4479. return amount === 0 ? this : this.slice(0, -Math.max(0, amount));
  4480. },
  4481. skipWhile: function skipWhile(predicate, context) {
  4482. return reify(this, skipWhileFactory(this, predicate, context, true));
  4483. },
  4484. skipUntil: function skipUntil(predicate, context) {
  4485. return this.skipWhile(not(predicate), context);
  4486. },
  4487. sortBy: function sortBy(mapper, comparator) {
  4488. return reify(this, sortFactory(this, comparator, mapper));
  4489. },
  4490. take: function take(amount) {
  4491. return this.slice(0, Math.max(0, amount));
  4492. },
  4493. takeLast: function takeLast(amount) {
  4494. return this.slice(-Math.max(0, amount));
  4495. },
  4496. takeWhile: function takeWhile(predicate, context) {
  4497. return reify(this, takeWhileFactory(this, predicate, context));
  4498. },
  4499. takeUntil: function takeUntil(predicate, context) {
  4500. return this.takeWhile(not(predicate), context);
  4501. },
  4502. update: function update(fn) {
  4503. return fn(this);
  4504. },
  4505. valueSeq: function valueSeq() {
  4506. return this.toIndexedSeq();
  4507. },
  4508. // ### Hashable Object
  4509. hashCode: function hashCode() {
  4510. return this.__hash || (this.__hash = hashCollection(this));
  4511. },
  4512. // ### Internal
  4513. // abstract __iterate(fn, reverse)
  4514. // abstract __iterator(type, reverse)
  4515. });
  4516. var CollectionPrototype = Collection.prototype;
  4517. CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
  4518. CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
  4519. CollectionPrototype.toJSON = CollectionPrototype.toArray;
  4520. CollectionPrototype.__toStringMapper = quoteString;
  4521. CollectionPrototype.inspect = CollectionPrototype.toSource = function () {
  4522. return this.toString();
  4523. };
  4524. CollectionPrototype.chain = CollectionPrototype.flatMap;
  4525. CollectionPrototype.contains = CollectionPrototype.includes;
  4526. mixin(KeyedCollection, {
  4527. // ### More sequential methods
  4528. flip: function flip() {
  4529. return reify(this, flipFactory(this));
  4530. },
  4531. mapEntries: function mapEntries(mapper, context) {
  4532. var this$1$1 = this;
  4533. var iterations = 0;
  4534. return reify(
  4535. this,
  4536. this.toSeq()
  4537. .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); })
  4538. .fromEntrySeq()
  4539. );
  4540. },
  4541. mapKeys: function mapKeys(mapper, context) {
  4542. var this$1$1 = this;
  4543. return reify(
  4544. this,
  4545. this.toSeq()
  4546. .flip()
  4547. .map(function (k, v) { return mapper.call(context, k, v, this$1$1); })
  4548. .flip()
  4549. );
  4550. },
  4551. });
  4552. var KeyedCollectionPrototype = KeyedCollection.prototype;
  4553. KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
  4554. KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
  4555. KeyedCollectionPrototype.toJSON = toObject;
  4556. KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
  4557. mixin(IndexedCollection, {
  4558. // ### Conversion to other types
  4559. toKeyedSeq: function toKeyedSeq() {
  4560. return new ToKeyedSequence(this, false);
  4561. },
  4562. // ### ES6 Collection methods (ES6 Array and Map)
  4563. filter: function filter(predicate, context) {
  4564. return reify(this, filterFactory(this, predicate, context, false));
  4565. },
  4566. findIndex: function findIndex(predicate, context) {
  4567. var entry = this.findEntry(predicate, context);
  4568. return entry ? entry[0] : -1;
  4569. },
  4570. indexOf: function indexOf(searchValue) {
  4571. var key = this.keyOf(searchValue);
  4572. return key === undefined ? -1 : key;
  4573. },
  4574. lastIndexOf: function lastIndexOf(searchValue) {
  4575. var key = this.lastKeyOf(searchValue);
  4576. return key === undefined ? -1 : key;
  4577. },
  4578. reverse: function reverse() {
  4579. return reify(this, reverseFactory(this, false));
  4580. },
  4581. slice: function slice(begin, end) {
  4582. return reify(this, sliceFactory(this, begin, end, false));
  4583. },
  4584. splice: function splice(index, removeNum /*, ...values*/) {
  4585. var numArgs = arguments.length;
  4586. removeNum = Math.max(removeNum || 0, 0);
  4587. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  4588. return this;
  4589. }
  4590. // If index is negative, it should resolve relative to the size of the
  4591. // collection. However size may be expensive to compute if not cached, so
  4592. // only call count() if the number is in fact negative.
  4593. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  4594. var spliced = this.slice(0, index);
  4595. return reify(
  4596. this,
  4597. numArgs === 1
  4598. ? spliced
  4599. : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  4600. );
  4601. },
  4602. // ### More collection methods
  4603. findLastIndex: function findLastIndex(predicate, context) {
  4604. var entry = this.findLastEntry(predicate, context);
  4605. return entry ? entry[0] : -1;
  4606. },
  4607. first: function first(notSetValue) {
  4608. return this.get(0, notSetValue);
  4609. },
  4610. flatten: function flatten(depth) {
  4611. return reify(this, flattenFactory(this, depth, false));
  4612. },
  4613. get: function get(index, notSetValue) {
  4614. index = wrapIndex(this, index);
  4615. return index < 0 ||
  4616. this.size === Infinity ||
  4617. (this.size !== undefined && index > this.size)
  4618. ? notSetValue
  4619. : this.find(function (_, key) { return key === index; }, undefined, notSetValue);
  4620. },
  4621. has: function has(index) {
  4622. index = wrapIndex(this, index);
  4623. return (
  4624. index >= 0 &&
  4625. (this.size !== undefined
  4626. ? this.size === Infinity || index < this.size
  4627. : this.indexOf(index) !== -1)
  4628. );
  4629. },
  4630. interpose: function interpose(separator) {
  4631. return reify(this, interposeFactory(this, separator));
  4632. },
  4633. interleave: function interleave(/*...collections*/) {
  4634. var collections = [this].concat(arrCopy(arguments));
  4635. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections);
  4636. var interleaved = zipped.flatten(true);
  4637. if (zipped.size) {
  4638. interleaved.size = zipped.size * collections.length;
  4639. }
  4640. return reify(this, interleaved);
  4641. },
  4642. keySeq: function keySeq() {
  4643. return Range(0, this.size);
  4644. },
  4645. last: function last(notSetValue) {
  4646. return this.get(-1, notSetValue);
  4647. },
  4648. skipWhile: function skipWhile(predicate, context) {
  4649. return reify(this, skipWhileFactory(this, predicate, context, false));
  4650. },
  4651. zip: function zip(/*, ...collections */) {
  4652. var collections = [this].concat(arrCopy(arguments));
  4653. return reify(this, zipWithFactory(this, defaultZipper, collections));
  4654. },
  4655. zipAll: function zipAll(/*, ...collections */) {
  4656. var collections = [this].concat(arrCopy(arguments));
  4657. return reify(this, zipWithFactory(this, defaultZipper, collections, true));
  4658. },
  4659. zipWith: function zipWith(zipper /*, ...collections */) {
  4660. var collections = arrCopy(arguments);
  4661. collections[0] = this;
  4662. return reify(this, zipWithFactory(this, zipper, collections));
  4663. },
  4664. });
  4665. var IndexedCollectionPrototype = IndexedCollection.prototype;
  4666. IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
  4667. IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
  4668. mixin(SetCollection, {
  4669. // ### ES6 Collection methods (ES6 Array and Map)
  4670. get: function get(value, notSetValue) {
  4671. return this.has(value) ? value : notSetValue;
  4672. },
  4673. includes: function includes(value) {
  4674. return this.has(value);
  4675. },
  4676. // ### More sequential methods
  4677. keySeq: function keySeq() {
  4678. return this.valueSeq();
  4679. },
  4680. });
  4681. var SetCollectionPrototype = SetCollection.prototype;
  4682. SetCollectionPrototype.has = CollectionPrototype.includes;
  4683. SetCollectionPrototype.contains = SetCollectionPrototype.includes;
  4684. SetCollectionPrototype.keys = SetCollectionPrototype.values;
  4685. // Mixin subclasses
  4686. mixin(KeyedSeq, KeyedCollectionPrototype);
  4687. mixin(IndexedSeq, IndexedCollectionPrototype);
  4688. mixin(SetSeq, SetCollectionPrototype);
  4689. // #pragma Helper functions
  4690. function reduce(collection, reducer, reduction, context, useFirst, reverse) {
  4691. assertNotInfinite(collection.size);
  4692. collection.__iterate(function (v, k, c) {
  4693. if (useFirst) {
  4694. useFirst = false;
  4695. reduction = v;
  4696. } else {
  4697. reduction = reducer.call(context, reduction, v, k, c);
  4698. }
  4699. }, reverse);
  4700. return reduction;
  4701. }
  4702. function keyMapper(v, k) {
  4703. return k;
  4704. }
  4705. function entryMapper(v, k) {
  4706. return [k, v];
  4707. }
  4708. function not(predicate) {
  4709. return function () {
  4710. return !predicate.apply(this, arguments);
  4711. };
  4712. }
  4713. function neg(predicate) {
  4714. return function () {
  4715. return -predicate.apply(this, arguments);
  4716. };
  4717. }
  4718. function defaultZipper() {
  4719. return arrCopy(arguments);
  4720. }
  4721. function defaultNegComparator(a, b) {
  4722. return a < b ? 1 : a > b ? -1 : 0;
  4723. }
  4724. function hashCollection(collection) {
  4725. if (collection.size === Infinity) {
  4726. return 0;
  4727. }
  4728. var ordered = isOrdered(collection);
  4729. var keyed = isKeyed(collection);
  4730. var h = ordered ? 1 : 0;
  4731. var size = collection.__iterate(
  4732. keyed
  4733. ? ordered
  4734. ? function (v, k) {
  4735. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  4736. }
  4737. : function (v, k) {
  4738. h = (h + hashMerge(hash(v), hash(k))) | 0;
  4739. }
  4740. : ordered
  4741. ? function (v) {
  4742. h = (31 * h + hash(v)) | 0;
  4743. }
  4744. : function (v) {
  4745. h = (h + hash(v)) | 0;
  4746. }
  4747. );
  4748. return murmurHashOfSize(size, h);
  4749. }
  4750. function murmurHashOfSize(size, h) {
  4751. h = imul(h, 0xcc9e2d51);
  4752. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  4753. h = imul((h << 13) | (h >>> -13), 5);
  4754. h = ((h + 0xe6546b64) | 0) ^ size;
  4755. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  4756. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  4757. h = smi(h ^ (h >>> 16));
  4758. return h;
  4759. }
  4760. function hashMerge(a, b) {
  4761. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  4762. }
  4763. var OrderedSet = /*@__PURE__*/(function (Set) {
  4764. function OrderedSet(value) {
  4765. // eslint-disable-next-line no-constructor-return
  4766. return value === undefined || value === null
  4767. ? emptyOrderedSet()
  4768. : isOrderedSet(value)
  4769. ? value
  4770. : emptyOrderedSet().withMutations(function (set) {
  4771. var iter = SetCollection(value);
  4772. assertNotInfinite(iter.size);
  4773. iter.forEach(function (v) { return set.add(v); });
  4774. });
  4775. }
  4776. if ( Set ) OrderedSet.__proto__ = Set;
  4777. OrderedSet.prototype = Object.create( Set && Set.prototype );
  4778. OrderedSet.prototype.constructor = OrderedSet;
  4779. OrderedSet.of = function of (/*...values*/) {
  4780. return this(arguments);
  4781. };
  4782. OrderedSet.fromKeys = function fromKeys (value) {
  4783. return this(KeyedCollection(value).keySeq());
  4784. };
  4785. OrderedSet.prototype.toString = function toString () {
  4786. return this.__toString('OrderedSet {', '}');
  4787. };
  4788. return OrderedSet;
  4789. }(Set));
  4790. OrderedSet.isOrderedSet = isOrderedSet;
  4791. var OrderedSetPrototype = OrderedSet.prototype;
  4792. OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
  4793. OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
  4794. OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
  4795. OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll;
  4796. OrderedSetPrototype.__empty = emptyOrderedSet;
  4797. OrderedSetPrototype.__make = makeOrderedSet;
  4798. function makeOrderedSet(map, ownerID) {
  4799. var set = Object.create(OrderedSetPrototype);
  4800. set.size = map ? map.size : 0;
  4801. set._map = map;
  4802. set.__ownerID = ownerID;
  4803. return set;
  4804. }
  4805. var EMPTY_ORDERED_SET;
  4806. function emptyOrderedSet() {
  4807. return (
  4808. EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  4809. );
  4810. }
  4811. var PairSorting = {
  4812. LeftThenRight: -1,
  4813. RightThenLeft: +1,
  4814. };
  4815. function throwOnInvalidDefaultValues(defaultValues) {
  4816. if (isRecord(defaultValues)) {
  4817. throw new Error(
  4818. 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.'
  4819. );
  4820. }
  4821. if (isImmutable(defaultValues)) {
  4822. throw new Error(
  4823. 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.'
  4824. );
  4825. }
  4826. if (defaultValues === null || typeof defaultValues !== 'object') {
  4827. throw new Error(
  4828. 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.'
  4829. );
  4830. }
  4831. }
  4832. var Record = function Record(defaultValues, name) {
  4833. var hasInitialized;
  4834. throwOnInvalidDefaultValues(defaultValues);
  4835. var RecordType = function Record(values) {
  4836. var this$1$1 = this;
  4837. if (values instanceof RecordType) {
  4838. return values;
  4839. }
  4840. if (!(this instanceof RecordType)) {
  4841. return new RecordType(values);
  4842. }
  4843. if (!hasInitialized) {
  4844. hasInitialized = true;
  4845. var keys = Object.keys(defaultValues);
  4846. var indices = (RecordTypePrototype._indices = {});
  4847. // Deprecated: left to attempt not to break any external code which
  4848. // relies on a ._name property existing on record instances.
  4849. // Use Record.getDescriptiveName() instead
  4850. RecordTypePrototype._name = name;
  4851. RecordTypePrototype._keys = keys;
  4852. RecordTypePrototype._defaultValues = defaultValues;
  4853. for (var i = 0; i < keys.length; i++) {
  4854. var propName = keys[i];
  4855. indices[propName] = i;
  4856. if (RecordTypePrototype[propName]) {
  4857. /* eslint-disable no-console */
  4858. typeof console === 'object' &&
  4859. console.warn &&
  4860. console.warn(
  4861. 'Cannot define ' +
  4862. recordName(this) +
  4863. ' with property "' +
  4864. propName +
  4865. '" since that property name is part of the Record API.'
  4866. );
  4867. /* eslint-enable no-console */
  4868. } else {
  4869. setProp(RecordTypePrototype, propName);
  4870. }
  4871. }
  4872. }
  4873. this.__ownerID = undefined;
  4874. this._values = List().withMutations(function (l) {
  4875. l.setSize(this$1$1._keys.length);
  4876. KeyedCollection(values).forEach(function (v, k) {
  4877. l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v);
  4878. });
  4879. });
  4880. return this;
  4881. };
  4882. var RecordTypePrototype = (RecordType.prototype =
  4883. Object.create(RecordPrototype));
  4884. RecordTypePrototype.constructor = RecordType;
  4885. if (name) {
  4886. RecordType.displayName = name;
  4887. }
  4888. // eslint-disable-next-line no-constructor-return
  4889. return RecordType;
  4890. };
  4891. Record.prototype.toString = function toString () {
  4892. var str = recordName(this) + ' { ';
  4893. var keys = this._keys;
  4894. var k;
  4895. for (var i = 0, l = keys.length; i !== l; i++) {
  4896. k = keys[i];
  4897. str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k));
  4898. }
  4899. return str + ' }';
  4900. };
  4901. Record.prototype.equals = function equals (other) {
  4902. return (
  4903. this === other ||
  4904. (isRecord(other) && recordSeq(this).equals(recordSeq(other)))
  4905. );
  4906. };
  4907. Record.prototype.hashCode = function hashCode () {
  4908. return recordSeq(this).hashCode();
  4909. };
  4910. // @pragma Access
  4911. Record.prototype.has = function has (k) {
  4912. return this._indices.hasOwnProperty(k);
  4913. };
  4914. Record.prototype.get = function get (k, notSetValue) {
  4915. if (!this.has(k)) {
  4916. return notSetValue;
  4917. }
  4918. var index = this._indices[k];
  4919. var value = this._values.get(index);
  4920. return value === undefined ? this._defaultValues[k] : value;
  4921. };
  4922. // @pragma Modification
  4923. Record.prototype.set = function set (k, v) {
  4924. if (this.has(k)) {
  4925. var newValues = this._values.set(
  4926. this._indices[k],
  4927. v === this._defaultValues[k] ? undefined : v
  4928. );
  4929. if (newValues !== this._values && !this.__ownerID) {
  4930. return makeRecord(this, newValues);
  4931. }
  4932. }
  4933. return this;
  4934. };
  4935. Record.prototype.remove = function remove (k) {
  4936. return this.set(k);
  4937. };
  4938. Record.prototype.clear = function clear () {
  4939. var newValues = this._values.clear().setSize(this._keys.length);
  4940. return this.__ownerID ? this : makeRecord(this, newValues);
  4941. };
  4942. Record.prototype.wasAltered = function wasAltered () {
  4943. return this._values.wasAltered();
  4944. };
  4945. Record.prototype.toSeq = function toSeq () {
  4946. return recordSeq(this);
  4947. };
  4948. Record.prototype.toJS = function toJS$1 () {
  4949. return toJS(this);
  4950. };
  4951. Record.prototype.entries = function entries () {
  4952. return this.__iterator(ITERATE_ENTRIES);
  4953. };
  4954. Record.prototype.__iterator = function __iterator (type, reverse) {
  4955. return recordSeq(this).__iterator(type, reverse);
  4956. };
  4957. Record.prototype.__iterate = function __iterate (fn, reverse) {
  4958. return recordSeq(this).__iterate(fn, reverse);
  4959. };
  4960. Record.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  4961. if (ownerID === this.__ownerID) {
  4962. return this;
  4963. }
  4964. var newValues = this._values.__ensureOwner(ownerID);
  4965. if (!ownerID) {
  4966. this.__ownerID = ownerID;
  4967. this._values = newValues;
  4968. return this;
  4969. }
  4970. return makeRecord(this, newValues, ownerID);
  4971. };
  4972. Record.isRecord = isRecord;
  4973. Record.getDescriptiveName = recordName;
  4974. var RecordPrototype = Record.prototype;
  4975. RecordPrototype[IS_RECORD_SYMBOL] = true;
  4976. RecordPrototype[DELETE] = RecordPrototype.remove;
  4977. RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
  4978. RecordPrototype.getIn = getIn;
  4979. RecordPrototype.hasIn = CollectionPrototype.hasIn;
  4980. RecordPrototype.merge = merge$1;
  4981. RecordPrototype.mergeWith = mergeWith$1;
  4982. RecordPrototype.mergeIn = mergeIn;
  4983. RecordPrototype.mergeDeep = mergeDeep;
  4984. RecordPrototype.mergeDeepWith = mergeDeepWith;
  4985. RecordPrototype.mergeDeepIn = mergeDeepIn;
  4986. RecordPrototype.setIn = setIn;
  4987. RecordPrototype.update = update;
  4988. RecordPrototype.updateIn = updateIn;
  4989. RecordPrototype.withMutations = withMutations;
  4990. RecordPrototype.asMutable = asMutable;
  4991. RecordPrototype.asImmutable = asImmutable;
  4992. RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
  4993. RecordPrototype.toJSON = RecordPrototype.toObject =
  4994. CollectionPrototype.toObject;
  4995. RecordPrototype.inspect = RecordPrototype.toSource = function () {
  4996. return this.toString();
  4997. };
  4998. function makeRecord(likeRecord, values, ownerID) {
  4999. var record = Object.create(Object.getPrototypeOf(likeRecord));
  5000. record._values = values;
  5001. record.__ownerID = ownerID;
  5002. return record;
  5003. }
  5004. function recordName(record) {
  5005. return record.constructor.displayName || record.constructor.name || 'Record';
  5006. }
  5007. function recordSeq(record) {
  5008. return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; }));
  5009. }
  5010. function setProp(prototype, name) {
  5011. try {
  5012. Object.defineProperty(prototype, name, {
  5013. get: function () {
  5014. return this.get(name);
  5015. },
  5016. set: function (value) {
  5017. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  5018. this.set(name, value);
  5019. },
  5020. });
  5021. } catch (error) {
  5022. // Object.defineProperty failed. Probably IE8.
  5023. }
  5024. }
  5025. /**
  5026. * Returns a lazy Seq of `value` repeated `times` times. When `times` is
  5027. * undefined, returns an infinite sequence of `value`.
  5028. */
  5029. var Repeat = /*@__PURE__*/(function (IndexedSeq) {
  5030. function Repeat(value, times) {
  5031. if (!(this instanceof Repeat)) {
  5032. // eslint-disable-next-line no-constructor-return
  5033. return new Repeat(value, times);
  5034. }
  5035. this._value = value;
  5036. this.size = times === undefined ? Infinity : Math.max(0, times);
  5037. if (this.size === 0) {
  5038. if (EMPTY_REPEAT) {
  5039. // eslint-disable-next-line no-constructor-return
  5040. return EMPTY_REPEAT;
  5041. }
  5042. EMPTY_REPEAT = this;
  5043. }
  5044. }
  5045. if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq;
  5046. Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  5047. Repeat.prototype.constructor = Repeat;
  5048. Repeat.prototype.toString = function toString () {
  5049. if (this.size === 0) {
  5050. return 'Repeat []';
  5051. }
  5052. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  5053. };
  5054. Repeat.prototype.get = function get (index, notSetValue) {
  5055. return this.has(index) ? this._value : notSetValue;
  5056. };
  5057. Repeat.prototype.includes = function includes (searchValue) {
  5058. return is(this._value, searchValue);
  5059. };
  5060. Repeat.prototype.slice = function slice (begin, end) {
  5061. var size = this.size;
  5062. return wholeSlice(begin, end, size)
  5063. ? this
  5064. : new Repeat(
  5065. this._value,
  5066. resolveEnd(end, size) - resolveBegin(begin, size)
  5067. );
  5068. };
  5069. Repeat.prototype.reverse = function reverse () {
  5070. return this;
  5071. };
  5072. Repeat.prototype.indexOf = function indexOf (searchValue) {
  5073. if (is(this._value, searchValue)) {
  5074. return 0;
  5075. }
  5076. return -1;
  5077. };
  5078. Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  5079. if (is(this._value, searchValue)) {
  5080. return this.size;
  5081. }
  5082. return -1;
  5083. };
  5084. Repeat.prototype.__iterate = function __iterate (fn, reverse) {
  5085. var size = this.size;
  5086. var i = 0;
  5087. while (i !== size) {
  5088. if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
  5089. break;
  5090. }
  5091. }
  5092. return i;
  5093. };
  5094. Repeat.prototype.__iterator = function __iterator (type, reverse) {
  5095. var this$1$1 = this;
  5096. var size = this.size;
  5097. var i = 0;
  5098. return new Iterator(function () { return i === size
  5099. ? iteratorDone()
  5100. : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); }
  5101. );
  5102. };
  5103. Repeat.prototype.equals = function equals (other) {
  5104. return other instanceof Repeat
  5105. ? is(this._value, other._value)
  5106. : deepEqual(this, other);
  5107. };
  5108. return Repeat;
  5109. }(IndexedSeq));
  5110. var EMPTY_REPEAT;
  5111. function fromJS(value, converter) {
  5112. return fromJSWith(
  5113. [],
  5114. converter || defaultConverter,
  5115. value,
  5116. '',
  5117. converter && converter.length > 2 ? [] : undefined,
  5118. { '': value }
  5119. );
  5120. }
  5121. function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
  5122. if (
  5123. typeof value !== 'string' &&
  5124. !isImmutable(value) &&
  5125. (isArrayLike(value) || hasIterator(value) || isPlainObject(value))
  5126. ) {
  5127. if (~stack.indexOf(value)) {
  5128. throw new TypeError('Cannot convert circular structure to Immutable');
  5129. }
  5130. stack.push(value);
  5131. keyPath && key !== '' && keyPath.push(key);
  5132. var converted = converter.call(
  5133. parentValue,
  5134. key,
  5135. Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
  5136. ),
  5137. keyPath && keyPath.slice()
  5138. );
  5139. stack.pop();
  5140. keyPath && keyPath.pop();
  5141. return converted;
  5142. }
  5143. return value;
  5144. }
  5145. function defaultConverter(k, v) {
  5146. // Effectively the opposite of "Collection.toSeq()"
  5147. return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet();
  5148. }
  5149. var version = "4.3.8";
  5150. var Immutable = {
  5151. version: version,
  5152. Collection: Collection,
  5153. // Note: Iterable is deprecated
  5154. Iterable: Collection,
  5155. Seq: Seq,
  5156. Map: Map,
  5157. OrderedMap: OrderedMap,
  5158. List: List,
  5159. Stack: Stack,
  5160. Set: Set,
  5161. OrderedSet: OrderedSet,
  5162. PairSorting: PairSorting,
  5163. Record: Record,
  5164. Range: Range,
  5165. Repeat: Repeat,
  5166. is: is,
  5167. fromJS: fromJS,
  5168. hash: hash,
  5169. isImmutable: isImmutable,
  5170. isCollection: isCollection,
  5171. isKeyed: isKeyed,
  5172. isIndexed: isIndexed,
  5173. isAssociative: isAssociative,
  5174. isOrdered: isOrdered,
  5175. isValueObject: isValueObject,
  5176. isPlainObject: isPlainObject,
  5177. isSeq: isSeq,
  5178. isList: isList,
  5179. isMap: isMap,
  5180. isOrderedMap: isOrderedMap,
  5181. isStack: isStack,
  5182. isSet: isSet,
  5183. isOrderedSet: isOrderedSet,
  5184. isRecord: isRecord,
  5185. get: get,
  5186. getIn: getIn$1,
  5187. has: has,
  5188. hasIn: hasIn$1,
  5189. merge: merge,
  5190. mergeDeep: mergeDeep$1,
  5191. mergeWith: mergeWith,
  5192. mergeDeepWith: mergeDeepWith$1,
  5193. remove: remove,
  5194. removeIn: removeIn,
  5195. set: set,
  5196. setIn: setIn$1,
  5197. update: update$1,
  5198. updateIn: updateIn$1,
  5199. };
  5200. // Note: Iterable is deprecated
  5201. var Iterable = Collection;
  5202. export default Immutable;
  5203. export { Collection, Iterable, List, Map, OrderedMap, OrderedSet, PairSorting, Range, Record, Repeat, Seq, Set, Stack, fromJS, get, getIn$1 as getIn, has, hasIn$1 as hasIn, hash, is, isAssociative, isCollection, isImmutable, isIndexed, isKeyed, isList, isMap, isOrdered, isOrderedMap, isOrderedSet, isPlainObject, isRecord, isSeq, isSet, isStack, isValueObject, merge, mergeDeep$1 as mergeDeep, mergeDeepWith$1 as mergeDeepWith, mergeWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn$1 as updateIn, version };