Nessuna descrizione

index.js 992KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var _rollupPluginBabelHelpers = require('../_rollupPluginBabelHelpers-0494a5d0.js');
  5. var React = require('react');
  6. var React__default = _interopDefault(React);
  7. require('react-dom');
  8. var styleInject_es = require('../style-inject.es-dcee06b6.js');
  9. var _commonjsHelpers = require('../_commonjsHelpers-72d386ba.js');
  10. var Draft = require('../Draft-4ccef031.js');
  11. var _reactDom_commonjsExternal = require('../_react-dom_commonjs-external-55867475.js');
  12. var server = _interopDefault(require('react-dom/server'));
  13. var immutable = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  14. /**
  15. * Copyright (c) 2014-2015, Facebook, Inc.
  16. * All rights reserved.
  17. *
  18. * This source code is licensed under the BSD-style license found in the
  19. * LICENSE file in the root directory of this source tree. An additional grant
  20. * of patent rights can be found in the PATENTS file in the same directory.
  21. */
  22. (function (global, factory) {
  23. module.exports = factory() ;
  24. }(_commonjsHelpers.commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
  25. function createClass(ctor, superClass) {
  26. if (superClass) {
  27. ctor.prototype = Object.create(superClass.prototype);
  28. }
  29. ctor.prototype.constructor = ctor;
  30. }
  31. function Iterable(value) {
  32. return isIterable(value) ? value : Seq(value);
  33. }
  34. createClass(KeyedIterable, Iterable);
  35. function KeyedIterable(value) {
  36. return isKeyed(value) ? value : KeyedSeq(value);
  37. }
  38. createClass(IndexedIterable, Iterable);
  39. function IndexedIterable(value) {
  40. return isIndexed(value) ? value : IndexedSeq(value);
  41. }
  42. createClass(SetIterable, Iterable);
  43. function SetIterable(value) {
  44. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  45. }
  46. function isIterable(maybeIterable) {
  47. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  48. }
  49. function isKeyed(maybeKeyed) {
  50. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  51. }
  52. function isIndexed(maybeIndexed) {
  53. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  54. }
  55. function isAssociative(maybeAssociative) {
  56. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  57. }
  58. function isOrdered(maybeOrdered) {
  59. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  60. }
  61. Iterable.isIterable = isIterable;
  62. Iterable.isKeyed = isKeyed;
  63. Iterable.isIndexed = isIndexed;
  64. Iterable.isAssociative = isAssociative;
  65. Iterable.isOrdered = isOrdered;
  66. Iterable.Keyed = KeyedIterable;
  67. Iterable.Indexed = IndexedIterable;
  68. Iterable.Set = SetIterable;
  69. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  70. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  71. var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  72. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  73. // Used for setting prototype methods that IE8 chokes on.
  74. var DELETE = 'delete';
  75. // Constants describing the size of trie nodes.
  76. var SHIFT = 5; // Resulted in best performance after ______?
  77. var SIZE = 1 << SHIFT;
  78. var MASK = SIZE - 1;
  79. // A consistent shared value representing "not set" which equals nothing other
  80. // than itself, and nothing that could be provided externally.
  81. var NOT_SET = {};
  82. // Boolean references, Rough equivalent of `bool &`.
  83. var CHANGE_LENGTH = { value: false };
  84. var DID_ALTER = { value: false };
  85. function MakeRef(ref) {
  86. ref.value = false;
  87. return ref;
  88. }
  89. function SetRef(ref) {
  90. ref && (ref.value = true);
  91. }
  92. // A function which returns a value representing an "owner" for transient writes
  93. // to tries. The return value will only ever equal itself, and will not equal
  94. // the return of any subsequent call of this function.
  95. function OwnerID() {}
  96. // http://jsperf.com/copy-array-inline
  97. function arrCopy(arr, offset) {
  98. offset = offset || 0;
  99. var len = Math.max(0, arr.length - offset);
  100. var newArr = new Array(len);
  101. for (var ii = 0; ii < len; ii++) {
  102. newArr[ii] = arr[ii + offset];
  103. }
  104. return newArr;
  105. }
  106. function ensureSize(iter) {
  107. if (iter.size === undefined) {
  108. iter.size = iter.__iterate(returnTrue);
  109. }
  110. return iter.size;
  111. }
  112. function wrapIndex(iter, index) {
  113. // This implements "is array index" which the ECMAString spec defines as:
  114. //
  115. // A String property name P is an array index if and only if
  116. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  117. // to 2^32−1.
  118. //
  119. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  120. if (typeof index !== 'number') {
  121. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  122. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  123. return NaN;
  124. }
  125. index = uint32Index;
  126. }
  127. return index < 0 ? ensureSize(iter) + index : index;
  128. }
  129. function returnTrue() {
  130. return true;
  131. }
  132. function wholeSlice(begin, end, size) {
  133. return (begin === 0 || (size !== undefined && begin <= -size)) &&
  134. (end === undefined || (size !== undefined && end >= size));
  135. }
  136. function resolveBegin(begin, size) {
  137. return resolveIndex(begin, size, 0);
  138. }
  139. function resolveEnd(end, size) {
  140. return resolveIndex(end, size, size);
  141. }
  142. function resolveIndex(index, size, defaultIndex) {
  143. return index === undefined ?
  144. defaultIndex :
  145. index < 0 ?
  146. Math.max(0, size + index) :
  147. size === undefined ?
  148. index :
  149. Math.min(size, index);
  150. }
  151. /* global Symbol */
  152. var ITERATE_KEYS = 0;
  153. var ITERATE_VALUES = 1;
  154. var ITERATE_ENTRIES = 2;
  155. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  156. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  157. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  158. function Iterator(next) {
  159. this.next = next;
  160. }
  161. Iterator.prototype.toString = function() {
  162. return '[Iterator]';
  163. };
  164. Iterator.KEYS = ITERATE_KEYS;
  165. Iterator.VALUES = ITERATE_VALUES;
  166. Iterator.ENTRIES = ITERATE_ENTRIES;
  167. Iterator.prototype.inspect =
  168. Iterator.prototype.toSource = function () { return this.toString(); };
  169. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  170. return this;
  171. };
  172. function iteratorValue(type, k, v, iteratorResult) {
  173. var value = type === 0 ? k : type === 1 ? v : [k, v];
  174. iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
  175. value: value, done: false
  176. });
  177. return iteratorResult;
  178. }
  179. function iteratorDone() {
  180. return { value: undefined, done: true };
  181. }
  182. function hasIterator(maybeIterable) {
  183. return !!getIteratorFn(maybeIterable);
  184. }
  185. function isIterator(maybeIterator) {
  186. return maybeIterator && typeof maybeIterator.next === 'function';
  187. }
  188. function getIterator(iterable) {
  189. var iteratorFn = getIteratorFn(iterable);
  190. return iteratorFn && iteratorFn.call(iterable);
  191. }
  192. function getIteratorFn(iterable) {
  193. var iteratorFn = iterable && (
  194. (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  195. iterable[FAUX_ITERATOR_SYMBOL]
  196. );
  197. if (typeof iteratorFn === 'function') {
  198. return iteratorFn;
  199. }
  200. }
  201. function isArrayLike(value) {
  202. return value && typeof value.length === 'number';
  203. }
  204. createClass(Seq, Iterable);
  205. function Seq(value) {
  206. return value === null || value === undefined ? emptySequence() :
  207. isIterable(value) ? value.toSeq() : seqFromValue(value);
  208. }
  209. Seq.of = function(/*...values*/) {
  210. return Seq(arguments);
  211. };
  212. Seq.prototype.toSeq = function() {
  213. return this;
  214. };
  215. Seq.prototype.toString = function() {
  216. return this.__toString('Seq {', '}');
  217. };
  218. Seq.prototype.cacheResult = function() {
  219. if (!this._cache && this.__iterateUncached) {
  220. this._cache = this.entrySeq().toArray();
  221. this.size = this._cache.length;
  222. }
  223. return this;
  224. };
  225. // abstract __iterateUncached(fn, reverse)
  226. Seq.prototype.__iterate = function(fn, reverse) {
  227. return seqIterate(this, fn, reverse, true);
  228. };
  229. // abstract __iteratorUncached(type, reverse)
  230. Seq.prototype.__iterator = function(type, reverse) {
  231. return seqIterator(this, type, reverse, true);
  232. };
  233. createClass(KeyedSeq, Seq);
  234. function KeyedSeq(value) {
  235. return value === null || value === undefined ?
  236. emptySequence().toKeyedSeq() :
  237. isIterable(value) ?
  238. (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
  239. keyedSeqFromValue(value);
  240. }
  241. KeyedSeq.prototype.toKeyedSeq = function() {
  242. return this;
  243. };
  244. createClass(IndexedSeq, Seq);
  245. function IndexedSeq(value) {
  246. return value === null || value === undefined ? emptySequence() :
  247. !isIterable(value) ? indexedSeqFromValue(value) :
  248. isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
  249. }
  250. IndexedSeq.of = function(/*...values*/) {
  251. return IndexedSeq(arguments);
  252. };
  253. IndexedSeq.prototype.toIndexedSeq = function() {
  254. return this;
  255. };
  256. IndexedSeq.prototype.toString = function() {
  257. return this.__toString('Seq [', ']');
  258. };
  259. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  260. return seqIterate(this, fn, reverse, false);
  261. };
  262. IndexedSeq.prototype.__iterator = function(type, reverse) {
  263. return seqIterator(this, type, reverse, false);
  264. };
  265. createClass(SetSeq, Seq);
  266. function SetSeq(value) {
  267. return (
  268. value === null || value === undefined ? emptySequence() :
  269. !isIterable(value) ? indexedSeqFromValue(value) :
  270. isKeyed(value) ? value.entrySeq() : value
  271. ).toSetSeq();
  272. }
  273. SetSeq.of = function(/*...values*/) {
  274. return SetSeq(arguments);
  275. };
  276. SetSeq.prototype.toSetSeq = function() {
  277. return this;
  278. };
  279. Seq.isSeq = isSeq;
  280. Seq.Keyed = KeyedSeq;
  281. Seq.Set = SetSeq;
  282. Seq.Indexed = IndexedSeq;
  283. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  284. Seq.prototype[IS_SEQ_SENTINEL] = true;
  285. createClass(ArraySeq, IndexedSeq);
  286. function ArraySeq(array) {
  287. this._array = array;
  288. this.size = array.length;
  289. }
  290. ArraySeq.prototype.get = function(index, notSetValue) {
  291. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  292. };
  293. ArraySeq.prototype.__iterate = function(fn, reverse) {
  294. var array = this._array;
  295. var maxIndex = array.length - 1;
  296. for (var ii = 0; ii <= maxIndex; ii++) {
  297. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  298. return ii + 1;
  299. }
  300. }
  301. return ii;
  302. };
  303. ArraySeq.prototype.__iterator = function(type, reverse) {
  304. var array = this._array;
  305. var maxIndex = array.length - 1;
  306. var ii = 0;
  307. return new Iterator(function()
  308. {return ii > maxIndex ?
  309. iteratorDone() :
  310. iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
  311. );
  312. };
  313. createClass(ObjectSeq, KeyedSeq);
  314. function ObjectSeq(object) {
  315. var keys = Object.keys(object);
  316. this._object = object;
  317. this._keys = keys;
  318. this.size = keys.length;
  319. }
  320. ObjectSeq.prototype.get = function(key, notSetValue) {
  321. if (notSetValue !== undefined && !this.has(key)) {
  322. return notSetValue;
  323. }
  324. return this._object[key];
  325. };
  326. ObjectSeq.prototype.has = function(key) {
  327. return this._object.hasOwnProperty(key);
  328. };
  329. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  330. var object = this._object;
  331. var keys = this._keys;
  332. var maxIndex = keys.length - 1;
  333. for (var ii = 0; ii <= maxIndex; ii++) {
  334. var key = keys[reverse ? maxIndex - ii : ii];
  335. if (fn(object[key], key, this) === false) {
  336. return ii + 1;
  337. }
  338. }
  339. return ii;
  340. };
  341. ObjectSeq.prototype.__iterator = function(type, reverse) {
  342. var object = this._object;
  343. var keys = this._keys;
  344. var maxIndex = keys.length - 1;
  345. var ii = 0;
  346. return new Iterator(function() {
  347. var key = keys[reverse ? maxIndex - ii : ii];
  348. return ii++ > maxIndex ?
  349. iteratorDone() :
  350. iteratorValue(type, key, object[key]);
  351. });
  352. };
  353. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  354. createClass(IterableSeq, IndexedSeq);
  355. function IterableSeq(iterable) {
  356. this._iterable = iterable;
  357. this.size = iterable.length || iterable.size;
  358. }
  359. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  360. if (reverse) {
  361. return this.cacheResult().__iterate(fn, reverse);
  362. }
  363. var iterable = this._iterable;
  364. var iterator = getIterator(iterable);
  365. var iterations = 0;
  366. if (isIterator(iterator)) {
  367. var step;
  368. while (!(step = iterator.next()).done) {
  369. if (fn(step.value, iterations++, this) === false) {
  370. break;
  371. }
  372. }
  373. }
  374. return iterations;
  375. };
  376. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  377. if (reverse) {
  378. return this.cacheResult().__iterator(type, reverse);
  379. }
  380. var iterable = this._iterable;
  381. var iterator = getIterator(iterable);
  382. if (!isIterator(iterator)) {
  383. return new Iterator(iteratorDone);
  384. }
  385. var iterations = 0;
  386. return new Iterator(function() {
  387. var step = iterator.next();
  388. return step.done ? step : iteratorValue(type, iterations++, step.value);
  389. });
  390. };
  391. createClass(IteratorSeq, IndexedSeq);
  392. function IteratorSeq(iterator) {
  393. this._iterator = iterator;
  394. this._iteratorCache = [];
  395. }
  396. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  397. if (reverse) {
  398. return this.cacheResult().__iterate(fn, reverse);
  399. }
  400. var iterator = this._iterator;
  401. var cache = this._iteratorCache;
  402. var iterations = 0;
  403. while (iterations < cache.length) {
  404. if (fn(cache[iterations], iterations++, this) === false) {
  405. return iterations;
  406. }
  407. }
  408. var step;
  409. while (!(step = iterator.next()).done) {
  410. var val = step.value;
  411. cache[iterations] = val;
  412. if (fn(val, iterations++, this) === false) {
  413. break;
  414. }
  415. }
  416. return iterations;
  417. };
  418. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  419. if (reverse) {
  420. return this.cacheResult().__iterator(type, reverse);
  421. }
  422. var iterator = this._iterator;
  423. var cache = this._iteratorCache;
  424. var iterations = 0;
  425. return new Iterator(function() {
  426. if (iterations >= cache.length) {
  427. var step = iterator.next();
  428. if (step.done) {
  429. return step;
  430. }
  431. cache[iterations] = step.value;
  432. }
  433. return iteratorValue(type, iterations, cache[iterations++]);
  434. });
  435. };
  436. // # pragma Helper functions
  437. function isSeq(maybeSeq) {
  438. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  439. }
  440. var EMPTY_SEQ;
  441. function emptySequence() {
  442. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  443. }
  444. function keyedSeqFromValue(value) {
  445. var seq =
  446. Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
  447. isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
  448. hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
  449. typeof value === 'object' ? new ObjectSeq(value) :
  450. undefined;
  451. if (!seq) {
  452. throw new TypeError(
  453. 'Expected Array or iterable object of [k, v] entries, '+
  454. 'or keyed object: ' + value
  455. );
  456. }
  457. return seq;
  458. }
  459. function indexedSeqFromValue(value) {
  460. var seq = maybeIndexedSeqFromValue(value);
  461. if (!seq) {
  462. throw new TypeError(
  463. 'Expected Array or iterable object of values: ' + value
  464. );
  465. }
  466. return seq;
  467. }
  468. function seqFromValue(value) {
  469. var seq = maybeIndexedSeqFromValue(value) ||
  470. (typeof value === 'object' && new ObjectSeq(value));
  471. if (!seq) {
  472. throw new TypeError(
  473. 'Expected Array or iterable object of values, or keyed object: ' + value
  474. );
  475. }
  476. return seq;
  477. }
  478. function maybeIndexedSeqFromValue(value) {
  479. return (
  480. isArrayLike(value) ? new ArraySeq(value) :
  481. isIterator(value) ? new IteratorSeq(value) :
  482. hasIterator(value) ? new IterableSeq(value) :
  483. undefined
  484. );
  485. }
  486. function seqIterate(seq, fn, reverse, useKeys) {
  487. var cache = seq._cache;
  488. if (cache) {
  489. var maxIndex = cache.length - 1;
  490. for (var ii = 0; ii <= maxIndex; ii++) {
  491. var entry = cache[reverse ? maxIndex - ii : ii];
  492. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  493. return ii + 1;
  494. }
  495. }
  496. return ii;
  497. }
  498. return seq.__iterateUncached(fn, reverse);
  499. }
  500. function seqIterator(seq, type, reverse, useKeys) {
  501. var cache = seq._cache;
  502. if (cache) {
  503. var maxIndex = cache.length - 1;
  504. var ii = 0;
  505. return new Iterator(function() {
  506. var entry = cache[reverse ? maxIndex - ii : ii];
  507. return ii++ > maxIndex ?
  508. iteratorDone() :
  509. iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  510. });
  511. }
  512. return seq.__iteratorUncached(type, reverse);
  513. }
  514. function fromJS(json, converter) {
  515. return converter ?
  516. fromJSWith(converter, json, '', {'': json}) :
  517. fromJSDefault(json);
  518. }
  519. function fromJSWith(converter, json, key, parentJSON) {
  520. if (Array.isArray(json)) {
  521. return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  522. }
  523. if (isPlainObj(json)) {
  524. return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  525. }
  526. return json;
  527. }
  528. function fromJSDefault(json) {
  529. if (Array.isArray(json)) {
  530. return IndexedSeq(json).map(fromJSDefault).toList();
  531. }
  532. if (isPlainObj(json)) {
  533. return KeyedSeq(json).map(fromJSDefault).toMap();
  534. }
  535. return json;
  536. }
  537. function isPlainObj(value) {
  538. return value && (value.constructor === Object || value.constructor === undefined);
  539. }
  540. /**
  541. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  542. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  543. *
  544. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  545. * value, which is different from the algorithm described by
  546. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  547. *
  548. * This is extended further to allow Objects to describe the values they
  549. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  550. *
  551. * Note: because of this extension, the key equality of Immutable.Map and the
  552. * value equality of Immutable.Set will differ from ES6 Map and Set.
  553. *
  554. * ### Defining custom values
  555. *
  556. * The easiest way to describe the value an object represents is by implementing
  557. * `valueOf`. For example, `Date` represents a value by returning a unix
  558. * timestamp for `valueOf`:
  559. *
  560. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  561. * var date2 = new Date(1234567890000);
  562. * date1.valueOf(); // 1234567890000
  563. * assert( date1 !== date2 );
  564. * assert( Immutable.is( date1, date2 ) );
  565. *
  566. * Note: overriding `valueOf` may have other implications if you use this object
  567. * where JavaScript expects a primitive, such as implicit string coercion.
  568. *
  569. * For more complex types, especially collections, implementing `valueOf` may
  570. * not be performant. An alternative is to implement `equals` and `hashCode`.
  571. *
  572. * `equals` takes another object, presumably of similar type, and returns true
  573. * if the it is equal. Equality is symmetrical, so the same result should be
  574. * returned if this and the argument are flipped.
  575. *
  576. * assert( a.equals(b) === b.equals(a) );
  577. *
  578. * `hashCode` returns a 32bit integer number representing the object which will
  579. * be used to determine how to store the value object in a Map or Set. You must
  580. * provide both or neither methods, one must not exist without the other.
  581. *
  582. * Also, an important relationship between these methods must be upheld: if two
  583. * values are equal, they *must* return the same hashCode. If the values are not
  584. * equal, they might have the same hashCode; this is called a hash collision,
  585. * and while undesirable for performance reasons, it is acceptable.
  586. *
  587. * if (a.equals(b)) {
  588. * assert( a.hashCode() === b.hashCode() );
  589. * }
  590. *
  591. * All Immutable collections implement `equals` and `hashCode`.
  592. *
  593. */
  594. function is(valueA, valueB) {
  595. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  596. return true;
  597. }
  598. if (!valueA || !valueB) {
  599. return false;
  600. }
  601. if (typeof valueA.valueOf === 'function' &&
  602. typeof valueB.valueOf === 'function') {
  603. valueA = valueA.valueOf();
  604. valueB = valueB.valueOf();
  605. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  606. return true;
  607. }
  608. if (!valueA || !valueB) {
  609. return false;
  610. }
  611. }
  612. if (typeof valueA.equals === 'function' &&
  613. typeof valueB.equals === 'function' &&
  614. valueA.equals(valueB)) {
  615. return true;
  616. }
  617. return false;
  618. }
  619. function deepEqual(a, b) {
  620. if (a === b) {
  621. return true;
  622. }
  623. if (
  624. !isIterable(b) ||
  625. a.size !== undefined && b.size !== undefined && a.size !== b.size ||
  626. a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
  627. isKeyed(a) !== isKeyed(b) ||
  628. isIndexed(a) !== isIndexed(b) ||
  629. isOrdered(a) !== isOrdered(b)
  630. ) {
  631. return false;
  632. }
  633. if (a.size === 0 && b.size === 0) {
  634. return true;
  635. }
  636. var notAssociative = !isAssociative(a);
  637. if (isOrdered(a)) {
  638. var entries = a.entries();
  639. return b.every(function(v, k) {
  640. var entry = entries.next().value;
  641. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  642. }) && entries.next().done;
  643. }
  644. var flipped = false;
  645. if (a.size === undefined) {
  646. if (b.size === undefined) {
  647. if (typeof a.cacheResult === 'function') {
  648. a.cacheResult();
  649. }
  650. } else {
  651. flipped = true;
  652. var _ = a;
  653. a = b;
  654. b = _;
  655. }
  656. }
  657. var allEqual = true;
  658. var bSize = b.__iterate(function(v, k) {
  659. if (notAssociative ? !a.has(v) :
  660. flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
  661. allEqual = false;
  662. return false;
  663. }
  664. });
  665. return allEqual && a.size === bSize;
  666. }
  667. createClass(Repeat, IndexedSeq);
  668. function Repeat(value, times) {
  669. if (!(this instanceof Repeat)) {
  670. return new Repeat(value, times);
  671. }
  672. this._value = value;
  673. this.size = times === undefined ? Infinity : Math.max(0, times);
  674. if (this.size === 0) {
  675. if (EMPTY_REPEAT) {
  676. return EMPTY_REPEAT;
  677. }
  678. EMPTY_REPEAT = this;
  679. }
  680. }
  681. Repeat.prototype.toString = function() {
  682. if (this.size === 0) {
  683. return 'Repeat []';
  684. }
  685. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  686. };
  687. Repeat.prototype.get = function(index, notSetValue) {
  688. return this.has(index) ? this._value : notSetValue;
  689. };
  690. Repeat.prototype.includes = function(searchValue) {
  691. return is(this._value, searchValue);
  692. };
  693. Repeat.prototype.slice = function(begin, end) {
  694. var size = this.size;
  695. return wholeSlice(begin, end, size) ? this :
  696. new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
  697. };
  698. Repeat.prototype.reverse = function() {
  699. return this;
  700. };
  701. Repeat.prototype.indexOf = function(searchValue) {
  702. if (is(this._value, searchValue)) {
  703. return 0;
  704. }
  705. return -1;
  706. };
  707. Repeat.prototype.lastIndexOf = function(searchValue) {
  708. if (is(this._value, searchValue)) {
  709. return this.size;
  710. }
  711. return -1;
  712. };
  713. Repeat.prototype.__iterate = function(fn, reverse) {
  714. for (var ii = 0; ii < this.size; ii++) {
  715. if (fn(this._value, ii, this) === false) {
  716. return ii + 1;
  717. }
  718. }
  719. return ii;
  720. };
  721. Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
  722. var ii = 0;
  723. return new Iterator(function()
  724. {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
  725. );
  726. };
  727. Repeat.prototype.equals = function(other) {
  728. return other instanceof Repeat ?
  729. is(this._value, other._value) :
  730. deepEqual(other);
  731. };
  732. var EMPTY_REPEAT;
  733. function invariant(condition, error) {
  734. if (!condition) throw new Error(error);
  735. }
  736. createClass(Range, IndexedSeq);
  737. function Range(start, end, step) {
  738. if (!(this instanceof Range)) {
  739. return new Range(start, end, step);
  740. }
  741. invariant(step !== 0, 'Cannot step a Range by 0');
  742. start = start || 0;
  743. if (end === undefined) {
  744. end = Infinity;
  745. }
  746. step = step === undefined ? 1 : Math.abs(step);
  747. if (end < start) {
  748. step = -step;
  749. }
  750. this._start = start;
  751. this._end = end;
  752. this._step = step;
  753. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  754. if (this.size === 0) {
  755. if (EMPTY_RANGE) {
  756. return EMPTY_RANGE;
  757. }
  758. EMPTY_RANGE = this;
  759. }
  760. }
  761. Range.prototype.toString = function() {
  762. if (this.size === 0) {
  763. return 'Range []';
  764. }
  765. return 'Range [ ' +
  766. this._start + '...' + this._end +
  767. (this._step > 1 ? ' by ' + this._step : '') +
  768. ' ]';
  769. };
  770. Range.prototype.get = function(index, notSetValue) {
  771. return this.has(index) ?
  772. this._start + wrapIndex(this, index) * this._step :
  773. notSetValue;
  774. };
  775. Range.prototype.includes = function(searchValue) {
  776. var possibleIndex = (searchValue - this._start) / this._step;
  777. return possibleIndex >= 0 &&
  778. possibleIndex < this.size &&
  779. possibleIndex === Math.floor(possibleIndex);
  780. };
  781. Range.prototype.slice = function(begin, end) {
  782. if (wholeSlice(begin, end, this.size)) {
  783. return this;
  784. }
  785. begin = resolveBegin(begin, this.size);
  786. end = resolveEnd(end, this.size);
  787. if (end <= begin) {
  788. return new Range(0, 0);
  789. }
  790. return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
  791. };
  792. Range.prototype.indexOf = function(searchValue) {
  793. var offsetValue = searchValue - this._start;
  794. if (offsetValue % this._step === 0) {
  795. var index = offsetValue / this._step;
  796. if (index >= 0 && index < this.size) {
  797. return index
  798. }
  799. }
  800. return -1;
  801. };
  802. Range.prototype.lastIndexOf = function(searchValue) {
  803. return this.indexOf(searchValue);
  804. };
  805. Range.prototype.__iterate = function(fn, reverse) {
  806. var maxIndex = this.size - 1;
  807. var step = this._step;
  808. var value = reverse ? this._start + maxIndex * step : this._start;
  809. for (var ii = 0; ii <= maxIndex; ii++) {
  810. if (fn(value, ii, this) === false) {
  811. return ii + 1;
  812. }
  813. value += reverse ? -step : step;
  814. }
  815. return ii;
  816. };
  817. Range.prototype.__iterator = function(type, reverse) {
  818. var maxIndex = this.size - 1;
  819. var step = this._step;
  820. var value = reverse ? this._start + maxIndex * step : this._start;
  821. var ii = 0;
  822. return new Iterator(function() {
  823. var v = value;
  824. value += reverse ? -step : step;
  825. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  826. });
  827. };
  828. Range.prototype.equals = function(other) {
  829. return other instanceof Range ?
  830. this._start === other._start &&
  831. this._end === other._end &&
  832. this._step === other._step :
  833. deepEqual(this, other);
  834. };
  835. var EMPTY_RANGE;
  836. createClass(Collection, Iterable);
  837. function Collection() {
  838. throw TypeError('Abstract');
  839. }
  840. createClass(KeyedCollection, Collection);function KeyedCollection() {}
  841. createClass(IndexedCollection, Collection);function IndexedCollection() {}
  842. createClass(SetCollection, Collection);function SetCollection() {}
  843. Collection.Keyed = KeyedCollection;
  844. Collection.Indexed = IndexedCollection;
  845. Collection.Set = SetCollection;
  846. var imul =
  847. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
  848. Math.imul :
  849. function imul(a, b) {
  850. a = a | 0; // int
  851. b = b | 0; // int
  852. var c = a & 0xffff;
  853. var d = b & 0xffff;
  854. // Shift by 0 fixes the sign on the high part.
  855. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
  856. };
  857. // v8 has an optimization for storing 31-bit signed numbers.
  858. // Values which have either 00 or 11 as the high order bits qualify.
  859. // This function drops the highest order bit in a signed number, maintaining
  860. // the sign bit.
  861. function smi(i32) {
  862. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
  863. }
  864. function hash(o) {
  865. if (o === false || o === null || o === undefined) {
  866. return 0;
  867. }
  868. if (typeof o.valueOf === 'function') {
  869. o = o.valueOf();
  870. if (o === false || o === null || o === undefined) {
  871. return 0;
  872. }
  873. }
  874. if (o === true) {
  875. return 1;
  876. }
  877. var type = typeof o;
  878. if (type === 'number') {
  879. var h = o | 0;
  880. if (h !== o) {
  881. h ^= o * 0xFFFFFFFF;
  882. }
  883. while (o > 0xFFFFFFFF) {
  884. o /= 0xFFFFFFFF;
  885. h ^= o;
  886. }
  887. return smi(h);
  888. }
  889. if (type === 'string') {
  890. return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
  891. }
  892. if (typeof o.hashCode === 'function') {
  893. return o.hashCode();
  894. }
  895. if (type === 'object') {
  896. return hashJSObj(o);
  897. }
  898. if (typeof o.toString === 'function') {
  899. return hashString(o.toString());
  900. }
  901. throw new Error('Value type ' + type + ' cannot be hashed.');
  902. }
  903. function cachedHashString(string) {
  904. var hash = stringHashCache[string];
  905. if (hash === undefined) {
  906. hash = hashString(string);
  907. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  908. STRING_HASH_CACHE_SIZE = 0;
  909. stringHashCache = {};
  910. }
  911. STRING_HASH_CACHE_SIZE++;
  912. stringHashCache[string] = hash;
  913. }
  914. return hash;
  915. }
  916. // http://jsperf.com/hashing-strings
  917. function hashString(string) {
  918. // This is the hash from JVM
  919. // The hash code for a string is computed as
  920. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  921. // where s[i] is the ith character of the string and n is the length of
  922. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  923. // (exclusive) by dropping high bits.
  924. var hash = 0;
  925. for (var ii = 0; ii < string.length; ii++) {
  926. hash = 31 * hash + string.charCodeAt(ii) | 0;
  927. }
  928. return smi(hash);
  929. }
  930. function hashJSObj(obj) {
  931. var hash;
  932. if (usingWeakMap) {
  933. hash = weakMap.get(obj);
  934. if (hash !== undefined) {
  935. return hash;
  936. }
  937. }
  938. hash = obj[UID_HASH_KEY];
  939. if (hash !== undefined) {
  940. return hash;
  941. }
  942. if (!canDefineProperty) {
  943. hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  944. if (hash !== undefined) {
  945. return hash;
  946. }
  947. hash = getIENodeHash(obj);
  948. if (hash !== undefined) {
  949. return hash;
  950. }
  951. }
  952. hash = ++objHashUID;
  953. if (objHashUID & 0x40000000) {
  954. objHashUID = 0;
  955. }
  956. if (usingWeakMap) {
  957. weakMap.set(obj, hash);
  958. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  959. throw new Error('Non-extensible objects are not allowed as keys.');
  960. } else if (canDefineProperty) {
  961. Object.defineProperty(obj, UID_HASH_KEY, {
  962. 'enumerable': false,
  963. 'configurable': false,
  964. 'writable': false,
  965. 'value': hash
  966. });
  967. } else if (obj.propertyIsEnumerable !== undefined &&
  968. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
  969. // Since we can't define a non-enumerable property on the object
  970. // we'll hijack one of the less-used non-enumerable properties to
  971. // save our hash on it. Since this is a function it will not show up in
  972. // `JSON.stringify` which is what we want.
  973. obj.propertyIsEnumerable = function() {
  974. return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
  975. };
  976. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  977. } else if (obj.nodeType !== undefined) {
  978. // At this point we couldn't get the IE `uniqueID` to use as a hash
  979. // and we couldn't use a non-enumerable property to exploit the
  980. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  981. // itself.
  982. obj[UID_HASH_KEY] = hash;
  983. } else {
  984. throw new Error('Unable to set a non-enumerable property on object.');
  985. }
  986. return hash;
  987. }
  988. // Get references to ES5 object methods.
  989. var isExtensible = Object.isExtensible;
  990. // True if Object.defineProperty works as expected. IE8 fails this test.
  991. var canDefineProperty = (function() {
  992. try {
  993. Object.defineProperty({}, '@', {});
  994. return true;
  995. } catch (e) {
  996. return false;
  997. }
  998. }());
  999. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  1000. // and avoid memory leaks from the IE cloneNode bug.
  1001. function getIENodeHash(node) {
  1002. if (node && node.nodeType > 0) {
  1003. switch (node.nodeType) {
  1004. case 1: // Element
  1005. return node.uniqueID;
  1006. case 9: // Document
  1007. return node.documentElement && node.documentElement.uniqueID;
  1008. }
  1009. }
  1010. }
  1011. // If possible, use a WeakMap.
  1012. var usingWeakMap = typeof WeakMap === 'function';
  1013. var weakMap;
  1014. if (usingWeakMap) {
  1015. weakMap = new WeakMap();
  1016. }
  1017. var objHashUID = 0;
  1018. var UID_HASH_KEY = '__immutablehash__';
  1019. if (typeof Symbol === 'function') {
  1020. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  1021. }
  1022. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  1023. var STRING_HASH_CACHE_MAX_SIZE = 255;
  1024. var STRING_HASH_CACHE_SIZE = 0;
  1025. var stringHashCache = {};
  1026. function assertNotInfinite(size) {
  1027. invariant(
  1028. size !== Infinity,
  1029. 'Cannot perform this action with an infinite size.'
  1030. );
  1031. }
  1032. createClass(Map, KeyedCollection);
  1033. // @pragma Construction
  1034. function Map(value) {
  1035. return value === null || value === undefined ? emptyMap() :
  1036. isMap(value) && !isOrdered(value) ? value :
  1037. emptyMap().withMutations(function(map ) {
  1038. var iter = KeyedIterable(value);
  1039. assertNotInfinite(iter.size);
  1040. iter.forEach(function(v, k) {return map.set(k, v)});
  1041. });
  1042. }
  1043. Map.prototype.toString = function() {
  1044. return this.__toString('Map {', '}');
  1045. };
  1046. // @pragma Access
  1047. Map.prototype.get = function(k, notSetValue) {
  1048. return this._root ?
  1049. this._root.get(0, undefined, k, notSetValue) :
  1050. notSetValue;
  1051. };
  1052. // @pragma Modification
  1053. Map.prototype.set = function(k, v) {
  1054. return updateMap(this, k, v);
  1055. };
  1056. Map.prototype.setIn = function(keyPath, v) {
  1057. return this.updateIn(keyPath, NOT_SET, function() {return v});
  1058. };
  1059. Map.prototype.remove = function(k) {
  1060. return updateMap(this, k, NOT_SET);
  1061. };
  1062. Map.prototype.deleteIn = function(keyPath) {
  1063. return this.updateIn(keyPath, function() {return NOT_SET});
  1064. };
  1065. Map.prototype.update = function(k, notSetValue, updater) {
  1066. return arguments.length === 1 ?
  1067. k(this) :
  1068. this.updateIn([k], notSetValue, updater);
  1069. };
  1070. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  1071. if (!updater) {
  1072. updater = notSetValue;
  1073. notSetValue = undefined;
  1074. }
  1075. var updatedValue = updateInDeepMap(
  1076. this,
  1077. forceIterator(keyPath),
  1078. notSetValue,
  1079. updater
  1080. );
  1081. return updatedValue === NOT_SET ? undefined : updatedValue;
  1082. };
  1083. Map.prototype.clear = function() {
  1084. if (this.size === 0) {
  1085. return this;
  1086. }
  1087. if (this.__ownerID) {
  1088. this.size = 0;
  1089. this._root = null;
  1090. this.__hash = undefined;
  1091. this.__altered = true;
  1092. return this;
  1093. }
  1094. return emptyMap();
  1095. };
  1096. // @pragma Composition
  1097. Map.prototype.merge = function(/*...iters*/) {
  1098. return mergeIntoMapWith(this, undefined, arguments);
  1099. };
  1100. Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  1101. return mergeIntoMapWith(this, merger, iters);
  1102. };
  1103. Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  1104. return this.updateIn(
  1105. keyPath,
  1106. emptyMap(),
  1107. function(m ) {return typeof m.merge === 'function' ?
  1108. m.merge.apply(m, iters) :
  1109. iters[iters.length - 1]}
  1110. );
  1111. };
  1112. Map.prototype.mergeDeep = function(/*...iters*/) {
  1113. return mergeIntoMapWith(this, deepMerger, arguments);
  1114. };
  1115. Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  1116. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  1117. };
  1118. Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  1119. return this.updateIn(
  1120. keyPath,
  1121. emptyMap(),
  1122. function(m ) {return typeof m.mergeDeep === 'function' ?
  1123. m.mergeDeep.apply(m, iters) :
  1124. iters[iters.length - 1]}
  1125. );
  1126. };
  1127. Map.prototype.sort = function(comparator) {
  1128. // Late binding
  1129. return OrderedMap(sortFactory(this, comparator));
  1130. };
  1131. Map.prototype.sortBy = function(mapper, comparator) {
  1132. // Late binding
  1133. return OrderedMap(sortFactory(this, comparator, mapper));
  1134. };
  1135. // @pragma Mutability
  1136. Map.prototype.withMutations = function(fn) {
  1137. var mutable = this.asMutable();
  1138. fn(mutable);
  1139. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  1140. };
  1141. Map.prototype.asMutable = function() {
  1142. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  1143. };
  1144. Map.prototype.asImmutable = function() {
  1145. return this.__ensureOwner();
  1146. };
  1147. Map.prototype.wasAltered = function() {
  1148. return this.__altered;
  1149. };
  1150. Map.prototype.__iterator = function(type, reverse) {
  1151. return new MapIterator(this, type, reverse);
  1152. };
  1153. Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  1154. var iterations = 0;
  1155. this._root && this._root.iterate(function(entry ) {
  1156. iterations++;
  1157. return fn(entry[1], entry[0], this$0);
  1158. }, reverse);
  1159. return iterations;
  1160. };
  1161. Map.prototype.__ensureOwner = function(ownerID) {
  1162. if (ownerID === this.__ownerID) {
  1163. return this;
  1164. }
  1165. if (!ownerID) {
  1166. this.__ownerID = ownerID;
  1167. this.__altered = false;
  1168. return this;
  1169. }
  1170. return makeMap(this.size, this._root, ownerID, this.__hash);
  1171. };
  1172. function isMap(maybeMap) {
  1173. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  1174. }
  1175. Map.isMap = isMap;
  1176. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  1177. var MapPrototype = Map.prototype;
  1178. MapPrototype[IS_MAP_SENTINEL] = true;
  1179. MapPrototype[DELETE] = MapPrototype.remove;
  1180. MapPrototype.removeIn = MapPrototype.deleteIn;
  1181. // #pragma Trie Nodes
  1182. function ArrayMapNode(ownerID, entries) {
  1183. this.ownerID = ownerID;
  1184. this.entries = entries;
  1185. }
  1186. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1187. var entries = this.entries;
  1188. for (var ii = 0, len = entries.length; ii < len; ii++) {
  1189. if (is(key, entries[ii][0])) {
  1190. return entries[ii][1];
  1191. }
  1192. }
  1193. return notSetValue;
  1194. };
  1195. ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1196. var removed = value === NOT_SET;
  1197. var entries = this.entries;
  1198. var idx = 0;
  1199. for (var len = entries.length; idx < len; idx++) {
  1200. if (is(key, entries[idx][0])) {
  1201. break;
  1202. }
  1203. }
  1204. var exists = idx < len;
  1205. if (exists ? entries[idx][1] === value : removed) {
  1206. return this;
  1207. }
  1208. SetRef(didAlter);
  1209. (removed || !exists) && SetRef(didChangeSize);
  1210. if (removed && entries.length === 1) {
  1211. return; // undefined
  1212. }
  1213. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  1214. return createNodes(ownerID, entries, key, value);
  1215. }
  1216. var isEditable = ownerID && ownerID === this.ownerID;
  1217. var newEntries = isEditable ? entries : arrCopy(entries);
  1218. if (exists) {
  1219. if (removed) {
  1220. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  1221. } else {
  1222. newEntries[idx] = [key, value];
  1223. }
  1224. } else {
  1225. newEntries.push([key, value]);
  1226. }
  1227. if (isEditable) {
  1228. this.entries = newEntries;
  1229. return this;
  1230. }
  1231. return new ArrayMapNode(ownerID, newEntries);
  1232. };
  1233. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  1234. this.ownerID = ownerID;
  1235. this.bitmap = bitmap;
  1236. this.nodes = nodes;
  1237. }
  1238. BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1239. if (keyHash === undefined) {
  1240. keyHash = hash(key);
  1241. }
  1242. var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
  1243. var bitmap = this.bitmap;
  1244. return (bitmap & bit) === 0 ? notSetValue :
  1245. this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
  1246. };
  1247. BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1248. if (keyHash === undefined) {
  1249. keyHash = hash(key);
  1250. }
  1251. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1252. var bit = 1 << keyHashFrag;
  1253. var bitmap = this.bitmap;
  1254. var exists = (bitmap & bit) !== 0;
  1255. if (!exists && value === NOT_SET) {
  1256. return this;
  1257. }
  1258. var idx = popCount(bitmap & (bit - 1));
  1259. var nodes = this.nodes;
  1260. var node = exists ? nodes[idx] : undefined;
  1261. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  1262. if (newNode === node) {
  1263. return this;
  1264. }
  1265. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  1266. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  1267. }
  1268. if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
  1269. return nodes[idx ^ 1];
  1270. }
  1271. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  1272. return newNode;
  1273. }
  1274. var isEditable = ownerID && ownerID === this.ownerID;
  1275. var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
  1276. var newNodes = exists ? newNode ?
  1277. setIn(nodes, idx, newNode, isEditable) :
  1278. spliceOut(nodes, idx, isEditable) :
  1279. spliceIn(nodes, idx, newNode, isEditable);
  1280. if (isEditable) {
  1281. this.bitmap = newBitmap;
  1282. this.nodes = newNodes;
  1283. return this;
  1284. }
  1285. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  1286. };
  1287. function HashArrayMapNode(ownerID, count, nodes) {
  1288. this.ownerID = ownerID;
  1289. this.count = count;
  1290. this.nodes = nodes;
  1291. }
  1292. HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1293. if (keyHash === undefined) {
  1294. keyHash = hash(key);
  1295. }
  1296. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1297. var node = this.nodes[idx];
  1298. return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
  1299. };
  1300. HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1301. if (keyHash === undefined) {
  1302. keyHash = hash(key);
  1303. }
  1304. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1305. var removed = value === NOT_SET;
  1306. var nodes = this.nodes;
  1307. var node = nodes[idx];
  1308. if (removed && !node) {
  1309. return this;
  1310. }
  1311. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  1312. if (newNode === node) {
  1313. return this;
  1314. }
  1315. var newCount = this.count;
  1316. if (!node) {
  1317. newCount++;
  1318. } else if (!newNode) {
  1319. newCount--;
  1320. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  1321. return packNodes(ownerID, nodes, newCount, idx);
  1322. }
  1323. }
  1324. var isEditable = ownerID && ownerID === this.ownerID;
  1325. var newNodes = setIn(nodes, idx, newNode, isEditable);
  1326. if (isEditable) {
  1327. this.count = newCount;
  1328. this.nodes = newNodes;
  1329. return this;
  1330. }
  1331. return new HashArrayMapNode(ownerID, newCount, newNodes);
  1332. };
  1333. function HashCollisionNode(ownerID, keyHash, entries) {
  1334. this.ownerID = ownerID;
  1335. this.keyHash = keyHash;
  1336. this.entries = entries;
  1337. }
  1338. HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1339. var entries = this.entries;
  1340. for (var ii = 0, len = entries.length; ii < len; ii++) {
  1341. if (is(key, entries[ii][0])) {
  1342. return entries[ii][1];
  1343. }
  1344. }
  1345. return notSetValue;
  1346. };
  1347. HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1348. if (keyHash === undefined) {
  1349. keyHash = hash(key);
  1350. }
  1351. var removed = value === NOT_SET;
  1352. if (keyHash !== this.keyHash) {
  1353. if (removed) {
  1354. return this;
  1355. }
  1356. SetRef(didAlter);
  1357. SetRef(didChangeSize);
  1358. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  1359. }
  1360. var entries = this.entries;
  1361. var idx = 0;
  1362. for (var len = entries.length; idx < len; idx++) {
  1363. if (is(key, entries[idx][0])) {
  1364. break;
  1365. }
  1366. }
  1367. var exists = idx < len;
  1368. if (exists ? entries[idx][1] === value : removed) {
  1369. return this;
  1370. }
  1371. SetRef(didAlter);
  1372. (removed || !exists) && SetRef(didChangeSize);
  1373. if (removed && len === 2) {
  1374. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  1375. }
  1376. var isEditable = ownerID && ownerID === this.ownerID;
  1377. var newEntries = isEditable ? entries : arrCopy(entries);
  1378. if (exists) {
  1379. if (removed) {
  1380. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  1381. } else {
  1382. newEntries[idx] = [key, value];
  1383. }
  1384. } else {
  1385. newEntries.push([key, value]);
  1386. }
  1387. if (isEditable) {
  1388. this.entries = newEntries;
  1389. return this;
  1390. }
  1391. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  1392. };
  1393. function ValueNode(ownerID, keyHash, entry) {
  1394. this.ownerID = ownerID;
  1395. this.keyHash = keyHash;
  1396. this.entry = entry;
  1397. }
  1398. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1399. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  1400. };
  1401. ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1402. var removed = value === NOT_SET;
  1403. var keyMatch = is(key, this.entry[0]);
  1404. if (keyMatch ? value === this.entry[1] : removed) {
  1405. return this;
  1406. }
  1407. SetRef(didAlter);
  1408. if (removed) {
  1409. SetRef(didChangeSize);
  1410. return; // undefined
  1411. }
  1412. if (keyMatch) {
  1413. if (ownerID && ownerID === this.ownerID) {
  1414. this.entry[1] = value;
  1415. return this;
  1416. }
  1417. return new ValueNode(ownerID, this.keyHash, [key, value]);
  1418. }
  1419. SetRef(didChangeSize);
  1420. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  1421. };
  1422. // #pragma Iterators
  1423. ArrayMapNode.prototype.iterate =
  1424. HashCollisionNode.prototype.iterate = function (fn, reverse) {
  1425. var entries = this.entries;
  1426. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  1427. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  1428. return false;
  1429. }
  1430. }
  1431. };
  1432. BitmapIndexedNode.prototype.iterate =
  1433. HashArrayMapNode.prototype.iterate = function (fn, reverse) {
  1434. var nodes = this.nodes;
  1435. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  1436. var node = nodes[reverse ? maxIndex - ii : ii];
  1437. if (node && node.iterate(fn, reverse) === false) {
  1438. return false;
  1439. }
  1440. }
  1441. };
  1442. ValueNode.prototype.iterate = function (fn, reverse) {
  1443. return fn(this.entry);
  1444. };
  1445. createClass(MapIterator, Iterator);
  1446. function MapIterator(map, type, reverse) {
  1447. this._type = type;
  1448. this._reverse = reverse;
  1449. this._stack = map._root && mapIteratorFrame(map._root);
  1450. }
  1451. MapIterator.prototype.next = function() {
  1452. var type = this._type;
  1453. var stack = this._stack;
  1454. while (stack) {
  1455. var node = stack.node;
  1456. var index = stack.index++;
  1457. var maxIndex;
  1458. if (node.entry) {
  1459. if (index === 0) {
  1460. return mapIteratorValue(type, node.entry);
  1461. }
  1462. } else if (node.entries) {
  1463. maxIndex = node.entries.length - 1;
  1464. if (index <= maxIndex) {
  1465. return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
  1466. }
  1467. } else {
  1468. maxIndex = node.nodes.length - 1;
  1469. if (index <= maxIndex) {
  1470. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  1471. if (subNode) {
  1472. if (subNode.entry) {
  1473. return mapIteratorValue(type, subNode.entry);
  1474. }
  1475. stack = this._stack = mapIteratorFrame(subNode, stack);
  1476. }
  1477. continue;
  1478. }
  1479. }
  1480. stack = this._stack = this._stack.__prev;
  1481. }
  1482. return iteratorDone();
  1483. };
  1484. function mapIteratorValue(type, entry) {
  1485. return iteratorValue(type, entry[0], entry[1]);
  1486. }
  1487. function mapIteratorFrame(node, prev) {
  1488. return {
  1489. node: node,
  1490. index: 0,
  1491. __prev: prev
  1492. };
  1493. }
  1494. function makeMap(size, root, ownerID, hash) {
  1495. var map = Object.create(MapPrototype);
  1496. map.size = size;
  1497. map._root = root;
  1498. map.__ownerID = ownerID;
  1499. map.__hash = hash;
  1500. map.__altered = false;
  1501. return map;
  1502. }
  1503. var EMPTY_MAP;
  1504. function emptyMap() {
  1505. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  1506. }
  1507. function updateMap(map, k, v) {
  1508. var newRoot;
  1509. var newSize;
  1510. if (!map._root) {
  1511. if (v === NOT_SET) {
  1512. return map;
  1513. }
  1514. newSize = 1;
  1515. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  1516. } else {
  1517. var didChangeSize = MakeRef(CHANGE_LENGTH);
  1518. var didAlter = MakeRef(DID_ALTER);
  1519. newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
  1520. if (!didAlter.value) {
  1521. return map;
  1522. }
  1523. newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
  1524. }
  1525. if (map.__ownerID) {
  1526. map.size = newSize;
  1527. map._root = newRoot;
  1528. map.__hash = undefined;
  1529. map.__altered = true;
  1530. return map;
  1531. }
  1532. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  1533. }
  1534. function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1535. if (!node) {
  1536. if (value === NOT_SET) {
  1537. return node;
  1538. }
  1539. SetRef(didAlter);
  1540. SetRef(didChangeSize);
  1541. return new ValueNode(ownerID, keyHash, [key, value]);
  1542. }
  1543. return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
  1544. }
  1545. function isLeafNode(node) {
  1546. return node.constructor === ValueNode || node.constructor === HashCollisionNode;
  1547. }
  1548. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  1549. if (node.keyHash === keyHash) {
  1550. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  1551. }
  1552. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  1553. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1554. var newNode;
  1555. var nodes = idx1 === idx2 ?
  1556. [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
  1557. ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
  1558. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  1559. }
  1560. function createNodes(ownerID, entries, key, value) {
  1561. if (!ownerID) {
  1562. ownerID = new OwnerID();
  1563. }
  1564. var node = new ValueNode(ownerID, hash(key), [key, value]);
  1565. for (var ii = 0; ii < entries.length; ii++) {
  1566. var entry = entries[ii];
  1567. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  1568. }
  1569. return node;
  1570. }
  1571. function packNodes(ownerID, nodes, count, excluding) {
  1572. var bitmap = 0;
  1573. var packedII = 0;
  1574. var packedNodes = new Array(count);
  1575. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  1576. var node = nodes[ii];
  1577. if (node !== undefined && ii !== excluding) {
  1578. bitmap |= bit;
  1579. packedNodes[packedII++] = node;
  1580. }
  1581. }
  1582. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  1583. }
  1584. function expandNodes(ownerID, nodes, bitmap, including, node) {
  1585. var count = 0;
  1586. var expandedNodes = new Array(SIZE);
  1587. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  1588. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  1589. }
  1590. expandedNodes[including] = node;
  1591. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  1592. }
  1593. function mergeIntoMapWith(map, merger, iterables) {
  1594. var iters = [];
  1595. for (var ii = 0; ii < iterables.length; ii++) {
  1596. var value = iterables[ii];
  1597. var iter = KeyedIterable(value);
  1598. if (!isIterable(value)) {
  1599. iter = iter.map(function(v ) {return fromJS(v)});
  1600. }
  1601. iters.push(iter);
  1602. }
  1603. return mergeIntoCollectionWith(map, merger, iters);
  1604. }
  1605. function deepMerger(existing, value, key) {
  1606. return existing && existing.mergeDeep && isIterable(value) ?
  1607. existing.mergeDeep(value) :
  1608. is(existing, value) ? existing : value;
  1609. }
  1610. function deepMergerWith(merger) {
  1611. return function(existing, value, key) {
  1612. if (existing && existing.mergeDeepWith && isIterable(value)) {
  1613. return existing.mergeDeepWith(merger, value);
  1614. }
  1615. var nextValue = merger(existing, value, key);
  1616. return is(existing, nextValue) ? existing : nextValue;
  1617. };
  1618. }
  1619. function mergeIntoCollectionWith(collection, merger, iters) {
  1620. iters = iters.filter(function(x ) {return x.size !== 0});
  1621. if (iters.length === 0) {
  1622. return collection;
  1623. }
  1624. if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
  1625. return collection.constructor(iters[0]);
  1626. }
  1627. return collection.withMutations(function(collection ) {
  1628. var mergeIntoMap = merger ?
  1629. function(value, key) {
  1630. collection.update(key, NOT_SET, function(existing )
  1631. {return existing === NOT_SET ? value : merger(existing, value, key)}
  1632. );
  1633. } :
  1634. function(value, key) {
  1635. collection.set(key, value);
  1636. };
  1637. for (var ii = 0; ii < iters.length; ii++) {
  1638. iters[ii].forEach(mergeIntoMap);
  1639. }
  1640. });
  1641. }
  1642. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  1643. var isNotSet = existing === NOT_SET;
  1644. var step = keyPathIter.next();
  1645. if (step.done) {
  1646. var existingValue = isNotSet ? notSetValue : existing;
  1647. var newValue = updater(existingValue);
  1648. return newValue === existingValue ? existing : newValue;
  1649. }
  1650. invariant(
  1651. isNotSet || (existing && existing.set),
  1652. 'invalid keyPath'
  1653. );
  1654. var key = step.value;
  1655. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  1656. var nextUpdated = updateInDeepMap(
  1657. nextExisting,
  1658. keyPathIter,
  1659. notSetValue,
  1660. updater
  1661. );
  1662. return nextUpdated === nextExisting ? existing :
  1663. nextUpdated === NOT_SET ? existing.remove(key) :
  1664. (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  1665. }
  1666. function popCount(x) {
  1667. x = x - ((x >> 1) & 0x55555555);
  1668. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  1669. x = (x + (x >> 4)) & 0x0f0f0f0f;
  1670. x = x + (x >> 8);
  1671. x = x + (x >> 16);
  1672. return x & 0x7f;
  1673. }
  1674. function setIn(array, idx, val, canEdit) {
  1675. var newArray = canEdit ? array : arrCopy(array);
  1676. newArray[idx] = val;
  1677. return newArray;
  1678. }
  1679. function spliceIn(array, idx, val, canEdit) {
  1680. var newLen = array.length + 1;
  1681. if (canEdit && idx + 1 === newLen) {
  1682. array[idx] = val;
  1683. return array;
  1684. }
  1685. var newArray = new Array(newLen);
  1686. var after = 0;
  1687. for (var ii = 0; ii < newLen; ii++) {
  1688. if (ii === idx) {
  1689. newArray[ii] = val;
  1690. after = -1;
  1691. } else {
  1692. newArray[ii] = array[ii + after];
  1693. }
  1694. }
  1695. return newArray;
  1696. }
  1697. function spliceOut(array, idx, canEdit) {
  1698. var newLen = array.length - 1;
  1699. if (canEdit && idx === newLen) {
  1700. array.pop();
  1701. return array;
  1702. }
  1703. var newArray = new Array(newLen);
  1704. var after = 0;
  1705. for (var ii = 0; ii < newLen; ii++) {
  1706. if (ii === idx) {
  1707. after = 1;
  1708. }
  1709. newArray[ii] = array[ii + after];
  1710. }
  1711. return newArray;
  1712. }
  1713. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  1714. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  1715. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  1716. createClass(List, IndexedCollection);
  1717. // @pragma Construction
  1718. function List(value) {
  1719. var empty = emptyList();
  1720. if (value === null || value === undefined) {
  1721. return empty;
  1722. }
  1723. if (isList(value)) {
  1724. return value;
  1725. }
  1726. var iter = IndexedIterable(value);
  1727. var size = iter.size;
  1728. if (size === 0) {
  1729. return empty;
  1730. }
  1731. assertNotInfinite(size);
  1732. if (size > 0 && size < SIZE) {
  1733. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  1734. }
  1735. return empty.withMutations(function(list ) {
  1736. list.setSize(size);
  1737. iter.forEach(function(v, i) {return list.set(i, v)});
  1738. });
  1739. }
  1740. List.of = function(/*...values*/) {
  1741. return this(arguments);
  1742. };
  1743. List.prototype.toString = function() {
  1744. return this.__toString('List [', ']');
  1745. };
  1746. // @pragma Access
  1747. List.prototype.get = function(index, notSetValue) {
  1748. index = wrapIndex(this, index);
  1749. if (index >= 0 && index < this.size) {
  1750. index += this._origin;
  1751. var node = listNodeFor(this, index);
  1752. return node && node.array[index & MASK];
  1753. }
  1754. return notSetValue;
  1755. };
  1756. // @pragma Modification
  1757. List.prototype.set = function(index, value) {
  1758. return updateList(this, index, value);
  1759. };
  1760. List.prototype.remove = function(index) {
  1761. return !this.has(index) ? this :
  1762. index === 0 ? this.shift() :
  1763. index === this.size - 1 ? this.pop() :
  1764. this.splice(index, 1);
  1765. };
  1766. List.prototype.insert = function(index, value) {
  1767. return this.splice(index, 0, value);
  1768. };
  1769. List.prototype.clear = function() {
  1770. if (this.size === 0) {
  1771. return this;
  1772. }
  1773. if (this.__ownerID) {
  1774. this.size = this._origin = this._capacity = 0;
  1775. this._level = SHIFT;
  1776. this._root = this._tail = null;
  1777. this.__hash = undefined;
  1778. this.__altered = true;
  1779. return this;
  1780. }
  1781. return emptyList();
  1782. };
  1783. List.prototype.push = function(/*...values*/) {
  1784. var values = arguments;
  1785. var oldSize = this.size;
  1786. return this.withMutations(function(list ) {
  1787. setListBounds(list, 0, oldSize + values.length);
  1788. for (var ii = 0; ii < values.length; ii++) {
  1789. list.set(oldSize + ii, values[ii]);
  1790. }
  1791. });
  1792. };
  1793. List.prototype.pop = function() {
  1794. return setListBounds(this, 0, -1);
  1795. };
  1796. List.prototype.unshift = function(/*...values*/) {
  1797. var values = arguments;
  1798. return this.withMutations(function(list ) {
  1799. setListBounds(list, -values.length);
  1800. for (var ii = 0; ii < values.length; ii++) {
  1801. list.set(ii, values[ii]);
  1802. }
  1803. });
  1804. };
  1805. List.prototype.shift = function() {
  1806. return setListBounds(this, 1);
  1807. };
  1808. // @pragma Composition
  1809. List.prototype.merge = function(/*...iters*/) {
  1810. return mergeIntoListWith(this, undefined, arguments);
  1811. };
  1812. List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  1813. return mergeIntoListWith(this, merger, iters);
  1814. };
  1815. List.prototype.mergeDeep = function(/*...iters*/) {
  1816. return mergeIntoListWith(this, deepMerger, arguments);
  1817. };
  1818. List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  1819. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  1820. };
  1821. List.prototype.setSize = function(size) {
  1822. return setListBounds(this, 0, size);
  1823. };
  1824. // @pragma Iteration
  1825. List.prototype.slice = function(begin, end) {
  1826. var size = this.size;
  1827. if (wholeSlice(begin, end, size)) {
  1828. return this;
  1829. }
  1830. return setListBounds(
  1831. this,
  1832. resolveBegin(begin, size),
  1833. resolveEnd(end, size)
  1834. );
  1835. };
  1836. List.prototype.__iterator = function(type, reverse) {
  1837. var index = 0;
  1838. var values = iterateList(this, reverse);
  1839. return new Iterator(function() {
  1840. var value = values();
  1841. return value === DONE ?
  1842. iteratorDone() :
  1843. iteratorValue(type, index++, value);
  1844. });
  1845. };
  1846. List.prototype.__iterate = function(fn, reverse) {
  1847. var index = 0;
  1848. var values = iterateList(this, reverse);
  1849. var value;
  1850. while ((value = values()) !== DONE) {
  1851. if (fn(value, index++, this) === false) {
  1852. break;
  1853. }
  1854. }
  1855. return index;
  1856. };
  1857. List.prototype.__ensureOwner = function(ownerID) {
  1858. if (ownerID === this.__ownerID) {
  1859. return this;
  1860. }
  1861. if (!ownerID) {
  1862. this.__ownerID = ownerID;
  1863. return this;
  1864. }
  1865. return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
  1866. };
  1867. function isList(maybeList) {
  1868. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  1869. }
  1870. List.isList = isList;
  1871. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  1872. var ListPrototype = List.prototype;
  1873. ListPrototype[IS_LIST_SENTINEL] = true;
  1874. ListPrototype[DELETE] = ListPrototype.remove;
  1875. ListPrototype.setIn = MapPrototype.setIn;
  1876. ListPrototype.deleteIn =
  1877. ListPrototype.removeIn = MapPrototype.removeIn;
  1878. ListPrototype.update = MapPrototype.update;
  1879. ListPrototype.updateIn = MapPrototype.updateIn;
  1880. ListPrototype.mergeIn = MapPrototype.mergeIn;
  1881. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  1882. ListPrototype.withMutations = MapPrototype.withMutations;
  1883. ListPrototype.asMutable = MapPrototype.asMutable;
  1884. ListPrototype.asImmutable = MapPrototype.asImmutable;
  1885. ListPrototype.wasAltered = MapPrototype.wasAltered;
  1886. function VNode(array, ownerID) {
  1887. this.array = array;
  1888. this.ownerID = ownerID;
  1889. }
  1890. // TODO: seems like these methods are very similar
  1891. VNode.prototype.removeBefore = function(ownerID, level, index) {
  1892. if (index === level ? 1 << level : this.array.length === 0) {
  1893. return this;
  1894. }
  1895. var originIndex = (index >>> level) & MASK;
  1896. if (originIndex >= this.array.length) {
  1897. return new VNode([], ownerID);
  1898. }
  1899. var removingFirst = originIndex === 0;
  1900. var newChild;
  1901. if (level > 0) {
  1902. var oldChild = this.array[originIndex];
  1903. newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  1904. if (newChild === oldChild && removingFirst) {
  1905. return this;
  1906. }
  1907. }
  1908. if (removingFirst && !newChild) {
  1909. return this;
  1910. }
  1911. var editable = editableVNode(this, ownerID);
  1912. if (!removingFirst) {
  1913. for (var ii = 0; ii < originIndex; ii++) {
  1914. editable.array[ii] = undefined;
  1915. }
  1916. }
  1917. if (newChild) {
  1918. editable.array[originIndex] = newChild;
  1919. }
  1920. return editable;
  1921. };
  1922. VNode.prototype.removeAfter = function(ownerID, level, index) {
  1923. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  1924. return this;
  1925. }
  1926. var sizeIndex = ((index - 1) >>> level) & MASK;
  1927. if (sizeIndex >= this.array.length) {
  1928. return this;
  1929. }
  1930. var newChild;
  1931. if (level > 0) {
  1932. var oldChild = this.array[sizeIndex];
  1933. newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  1934. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  1935. return this;
  1936. }
  1937. }
  1938. var editable = editableVNode(this, ownerID);
  1939. editable.array.splice(sizeIndex + 1);
  1940. if (newChild) {
  1941. editable.array[sizeIndex] = newChild;
  1942. }
  1943. return editable;
  1944. };
  1945. var DONE = {};
  1946. function iterateList(list, reverse) {
  1947. var left = list._origin;
  1948. var right = list._capacity;
  1949. var tailPos = getTailOffset(right);
  1950. var tail = list._tail;
  1951. return iterateNodeOrLeaf(list._root, list._level, 0);
  1952. function iterateNodeOrLeaf(node, level, offset) {
  1953. return level === 0 ?
  1954. iterateLeaf(node, offset) :
  1955. iterateNode(node, level, offset);
  1956. }
  1957. function iterateLeaf(node, offset) {
  1958. var array = offset === tailPos ? tail && tail.array : node && node.array;
  1959. var from = offset > left ? 0 : left - offset;
  1960. var to = right - offset;
  1961. if (to > SIZE) {
  1962. to = SIZE;
  1963. }
  1964. return function() {
  1965. if (from === to) {
  1966. return DONE;
  1967. }
  1968. var idx = reverse ? --to : from++;
  1969. return array && array[idx];
  1970. };
  1971. }
  1972. function iterateNode(node, level, offset) {
  1973. var values;
  1974. var array = node && node.array;
  1975. var from = offset > left ? 0 : (left - offset) >> level;
  1976. var to = ((right - offset) >> level) + 1;
  1977. if (to > SIZE) {
  1978. to = SIZE;
  1979. }
  1980. return function() {
  1981. do {
  1982. if (values) {
  1983. var value = values();
  1984. if (value !== DONE) {
  1985. return value;
  1986. }
  1987. values = null;
  1988. }
  1989. if (from === to) {
  1990. return DONE;
  1991. }
  1992. var idx = reverse ? --to : from++;
  1993. values = iterateNodeOrLeaf(
  1994. array && array[idx], level - SHIFT, offset + (idx << level)
  1995. );
  1996. } while (true);
  1997. };
  1998. }
  1999. }
  2000. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  2001. var list = Object.create(ListPrototype);
  2002. list.size = capacity - origin;
  2003. list._origin = origin;
  2004. list._capacity = capacity;
  2005. list._level = level;
  2006. list._root = root;
  2007. list._tail = tail;
  2008. list.__ownerID = ownerID;
  2009. list.__hash = hash;
  2010. list.__altered = false;
  2011. return list;
  2012. }
  2013. var EMPTY_LIST;
  2014. function emptyList() {
  2015. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  2016. }
  2017. function updateList(list, index, value) {
  2018. index = wrapIndex(list, index);
  2019. if (index !== index) {
  2020. return list;
  2021. }
  2022. if (index >= list.size || index < 0) {
  2023. return list.withMutations(function(list ) {
  2024. index < 0 ?
  2025. setListBounds(list, index).set(0, value) :
  2026. setListBounds(list, 0, index + 1).set(index, value);
  2027. });
  2028. }
  2029. index += list._origin;
  2030. var newTail = list._tail;
  2031. var newRoot = list._root;
  2032. var didAlter = MakeRef(DID_ALTER);
  2033. if (index >= getTailOffset(list._capacity)) {
  2034. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  2035. } else {
  2036. newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
  2037. }
  2038. if (!didAlter.value) {
  2039. return list;
  2040. }
  2041. if (list.__ownerID) {
  2042. list._root = newRoot;
  2043. list._tail = newTail;
  2044. list.__hash = undefined;
  2045. list.__altered = true;
  2046. return list;
  2047. }
  2048. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  2049. }
  2050. function updateVNode(node, ownerID, level, index, value, didAlter) {
  2051. var idx = (index >>> level) & MASK;
  2052. var nodeHas = node && idx < node.array.length;
  2053. if (!nodeHas && value === undefined) {
  2054. return node;
  2055. }
  2056. var newNode;
  2057. if (level > 0) {
  2058. var lowerNode = node && node.array[idx];
  2059. var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
  2060. if (newLowerNode === lowerNode) {
  2061. return node;
  2062. }
  2063. newNode = editableVNode(node, ownerID);
  2064. newNode.array[idx] = newLowerNode;
  2065. return newNode;
  2066. }
  2067. if (nodeHas && node.array[idx] === value) {
  2068. return node;
  2069. }
  2070. SetRef(didAlter);
  2071. newNode = editableVNode(node, ownerID);
  2072. if (value === undefined && idx === newNode.array.length - 1) {
  2073. newNode.array.pop();
  2074. } else {
  2075. newNode.array[idx] = value;
  2076. }
  2077. return newNode;
  2078. }
  2079. function editableVNode(node, ownerID) {
  2080. if (ownerID && node && ownerID === node.ownerID) {
  2081. return node;
  2082. }
  2083. return new VNode(node ? node.array.slice() : [], ownerID);
  2084. }
  2085. function listNodeFor(list, rawIndex) {
  2086. if (rawIndex >= getTailOffset(list._capacity)) {
  2087. return list._tail;
  2088. }
  2089. if (rawIndex < 1 << (list._level + SHIFT)) {
  2090. var node = list._root;
  2091. var level = list._level;
  2092. while (node && level > 0) {
  2093. node = node.array[(rawIndex >>> level) & MASK];
  2094. level -= SHIFT;
  2095. }
  2096. return node;
  2097. }
  2098. }
  2099. function setListBounds(list, begin, end) {
  2100. // Sanitize begin & end using this shorthand for ToInt32(argument)
  2101. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  2102. if (begin !== undefined) {
  2103. begin = begin | 0;
  2104. }
  2105. if (end !== undefined) {
  2106. end = end | 0;
  2107. }
  2108. var owner = list.__ownerID || new OwnerID();
  2109. var oldOrigin = list._origin;
  2110. var oldCapacity = list._capacity;
  2111. var newOrigin = oldOrigin + begin;
  2112. var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
  2113. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  2114. return list;
  2115. }
  2116. // If it's going to end after it starts, it's empty.
  2117. if (newOrigin >= newCapacity) {
  2118. return list.clear();
  2119. }
  2120. var newLevel = list._level;
  2121. var newRoot = list._root;
  2122. // New origin might need creating a higher root.
  2123. var offsetShift = 0;
  2124. while (newOrigin + offsetShift < 0) {
  2125. newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
  2126. newLevel += SHIFT;
  2127. offsetShift += 1 << newLevel;
  2128. }
  2129. if (offsetShift) {
  2130. newOrigin += offsetShift;
  2131. oldOrigin += offsetShift;
  2132. newCapacity += offsetShift;
  2133. oldCapacity += offsetShift;
  2134. }
  2135. var oldTailOffset = getTailOffset(oldCapacity);
  2136. var newTailOffset = getTailOffset(newCapacity);
  2137. // New size might need creating a higher root.
  2138. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  2139. newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
  2140. newLevel += SHIFT;
  2141. }
  2142. // Locate or create the new tail.
  2143. var oldTail = list._tail;
  2144. var newTail = newTailOffset < oldTailOffset ?
  2145. listNodeFor(list, newCapacity - 1) :
  2146. newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
  2147. // Merge Tail into tree.
  2148. if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
  2149. newRoot = editableVNode(newRoot, owner);
  2150. var node = newRoot;
  2151. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  2152. var idx = (oldTailOffset >>> level) & MASK;
  2153. node = node.array[idx] = editableVNode(node.array[idx], owner);
  2154. }
  2155. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  2156. }
  2157. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  2158. if (newCapacity < oldCapacity) {
  2159. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  2160. }
  2161. // If the new origin is within the tail, then we do not need a root.
  2162. if (newOrigin >= newTailOffset) {
  2163. newOrigin -= newTailOffset;
  2164. newCapacity -= newTailOffset;
  2165. newLevel = SHIFT;
  2166. newRoot = null;
  2167. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  2168. // Otherwise, if the root has been trimmed, garbage collect.
  2169. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  2170. offsetShift = 0;
  2171. // Identify the new top root node of the subtree of the old root.
  2172. while (newRoot) {
  2173. var beginIndex = (newOrigin >>> newLevel) & MASK;
  2174. if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
  2175. break;
  2176. }
  2177. if (beginIndex) {
  2178. offsetShift += (1 << newLevel) * beginIndex;
  2179. }
  2180. newLevel -= SHIFT;
  2181. newRoot = newRoot.array[beginIndex];
  2182. }
  2183. // Trim the new sides of the new root.
  2184. if (newRoot && newOrigin > oldOrigin) {
  2185. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  2186. }
  2187. if (newRoot && newTailOffset < oldTailOffset) {
  2188. newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
  2189. }
  2190. if (offsetShift) {
  2191. newOrigin -= offsetShift;
  2192. newCapacity -= offsetShift;
  2193. }
  2194. }
  2195. if (list.__ownerID) {
  2196. list.size = newCapacity - newOrigin;
  2197. list._origin = newOrigin;
  2198. list._capacity = newCapacity;
  2199. list._level = newLevel;
  2200. list._root = newRoot;
  2201. list._tail = newTail;
  2202. list.__hash = undefined;
  2203. list.__altered = true;
  2204. return list;
  2205. }
  2206. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  2207. }
  2208. function mergeIntoListWith(list, merger, iterables) {
  2209. var iters = [];
  2210. var maxSize = 0;
  2211. for (var ii = 0; ii < iterables.length; ii++) {
  2212. var value = iterables[ii];
  2213. var iter = IndexedIterable(value);
  2214. if (iter.size > maxSize) {
  2215. maxSize = iter.size;
  2216. }
  2217. if (!isIterable(value)) {
  2218. iter = iter.map(function(v ) {return fromJS(v)});
  2219. }
  2220. iters.push(iter);
  2221. }
  2222. if (maxSize > list.size) {
  2223. list = list.setSize(maxSize);
  2224. }
  2225. return mergeIntoCollectionWith(list, merger, iters);
  2226. }
  2227. function getTailOffset(size) {
  2228. return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
  2229. }
  2230. createClass(OrderedMap, Map);
  2231. // @pragma Construction
  2232. function OrderedMap(value) {
  2233. return value === null || value === undefined ? emptyOrderedMap() :
  2234. isOrderedMap(value) ? value :
  2235. emptyOrderedMap().withMutations(function(map ) {
  2236. var iter = KeyedIterable(value);
  2237. assertNotInfinite(iter.size);
  2238. iter.forEach(function(v, k) {return map.set(k, v)});
  2239. });
  2240. }
  2241. OrderedMap.of = function(/*...values*/) {
  2242. return this(arguments);
  2243. };
  2244. OrderedMap.prototype.toString = function() {
  2245. return this.__toString('OrderedMap {', '}');
  2246. };
  2247. // @pragma Access
  2248. OrderedMap.prototype.get = function(k, notSetValue) {
  2249. var index = this._map.get(k);
  2250. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  2251. };
  2252. // @pragma Modification
  2253. OrderedMap.prototype.clear = function() {
  2254. if (this.size === 0) {
  2255. return this;
  2256. }
  2257. if (this.__ownerID) {
  2258. this.size = 0;
  2259. this._map.clear();
  2260. this._list.clear();
  2261. return this;
  2262. }
  2263. return emptyOrderedMap();
  2264. };
  2265. OrderedMap.prototype.set = function(k, v) {
  2266. return updateOrderedMap(this, k, v);
  2267. };
  2268. OrderedMap.prototype.remove = function(k) {
  2269. return updateOrderedMap(this, k, NOT_SET);
  2270. };
  2271. OrderedMap.prototype.wasAltered = function() {
  2272. return this._map.wasAltered() || this._list.wasAltered();
  2273. };
  2274. OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2275. return this._list.__iterate(
  2276. function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
  2277. reverse
  2278. );
  2279. };
  2280. OrderedMap.prototype.__iterator = function(type, reverse) {
  2281. return this._list.fromEntrySeq().__iterator(type, reverse);
  2282. };
  2283. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  2284. if (ownerID === this.__ownerID) {
  2285. return this;
  2286. }
  2287. var newMap = this._map.__ensureOwner(ownerID);
  2288. var newList = this._list.__ensureOwner(ownerID);
  2289. if (!ownerID) {
  2290. this.__ownerID = ownerID;
  2291. this._map = newMap;
  2292. this._list = newList;
  2293. return this;
  2294. }
  2295. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  2296. };
  2297. function isOrderedMap(maybeOrderedMap) {
  2298. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  2299. }
  2300. OrderedMap.isOrderedMap = isOrderedMap;
  2301. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  2302. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  2303. function makeOrderedMap(map, list, ownerID, hash) {
  2304. var omap = Object.create(OrderedMap.prototype);
  2305. omap.size = map ? map.size : 0;
  2306. omap._map = map;
  2307. omap._list = list;
  2308. omap.__ownerID = ownerID;
  2309. omap.__hash = hash;
  2310. return omap;
  2311. }
  2312. var EMPTY_ORDERED_MAP;
  2313. function emptyOrderedMap() {
  2314. return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
  2315. }
  2316. function updateOrderedMap(omap, k, v) {
  2317. var map = omap._map;
  2318. var list = omap._list;
  2319. var i = map.get(k);
  2320. var has = i !== undefined;
  2321. var newMap;
  2322. var newList;
  2323. if (v === NOT_SET) { // removed
  2324. if (!has) {
  2325. return omap;
  2326. }
  2327. if (list.size >= SIZE && list.size >= map.size * 2) {
  2328. newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
  2329. newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
  2330. if (omap.__ownerID) {
  2331. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  2332. }
  2333. } else {
  2334. newMap = map.remove(k);
  2335. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  2336. }
  2337. } else {
  2338. if (has) {
  2339. if (v === list.get(i)[1]) {
  2340. return omap;
  2341. }
  2342. newMap = map;
  2343. newList = list.set(i, [k, v]);
  2344. } else {
  2345. newMap = map.set(k, list.size);
  2346. newList = list.set(list.size, [k, v]);
  2347. }
  2348. }
  2349. if (omap.__ownerID) {
  2350. omap.size = newMap.size;
  2351. omap._map = newMap;
  2352. omap._list = newList;
  2353. omap.__hash = undefined;
  2354. return omap;
  2355. }
  2356. return makeOrderedMap(newMap, newList);
  2357. }
  2358. createClass(ToKeyedSequence, KeyedSeq);
  2359. function ToKeyedSequence(indexed, useKeys) {
  2360. this._iter = indexed;
  2361. this._useKeys = useKeys;
  2362. this.size = indexed.size;
  2363. }
  2364. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  2365. return this._iter.get(key, notSetValue);
  2366. };
  2367. ToKeyedSequence.prototype.has = function(key) {
  2368. return this._iter.has(key);
  2369. };
  2370. ToKeyedSequence.prototype.valueSeq = function() {
  2371. return this._iter.valueSeq();
  2372. };
  2373. ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
  2374. var reversedSequence = reverseFactory(this, true);
  2375. if (!this._useKeys) {
  2376. reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
  2377. }
  2378. return reversedSequence;
  2379. };
  2380. ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
  2381. var mappedSequence = mapFactory(this, mapper, context);
  2382. if (!this._useKeys) {
  2383. mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
  2384. }
  2385. return mappedSequence;
  2386. };
  2387. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2388. var ii;
  2389. return this._iter.__iterate(
  2390. this._useKeys ?
  2391. function(v, k) {return fn(v, k, this$0)} :
  2392. ((ii = reverse ? resolveSize(this) : 0),
  2393. function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
  2394. reverse
  2395. );
  2396. };
  2397. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  2398. if (this._useKeys) {
  2399. return this._iter.__iterator(type, reverse);
  2400. }
  2401. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2402. var ii = reverse ? resolveSize(this) : 0;
  2403. return new Iterator(function() {
  2404. var step = iterator.next();
  2405. return step.done ? step :
  2406. iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  2407. });
  2408. };
  2409. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  2410. createClass(ToIndexedSequence, IndexedSeq);
  2411. function ToIndexedSequence(iter) {
  2412. this._iter = iter;
  2413. this.size = iter.size;
  2414. }
  2415. ToIndexedSequence.prototype.includes = function(value) {
  2416. return this._iter.includes(value);
  2417. };
  2418. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2419. var iterations = 0;
  2420. return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
  2421. };
  2422. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  2423. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2424. var iterations = 0;
  2425. return new Iterator(function() {
  2426. var step = iterator.next();
  2427. return step.done ? step :
  2428. iteratorValue(type, iterations++, step.value, step)
  2429. });
  2430. };
  2431. createClass(ToSetSequence, SetSeq);
  2432. function ToSetSequence(iter) {
  2433. this._iter = iter;
  2434. this.size = iter.size;
  2435. }
  2436. ToSetSequence.prototype.has = function(key) {
  2437. return this._iter.includes(key);
  2438. };
  2439. ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2440. return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
  2441. };
  2442. ToSetSequence.prototype.__iterator = function(type, reverse) {
  2443. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2444. return new Iterator(function() {
  2445. var step = iterator.next();
  2446. return step.done ? step :
  2447. iteratorValue(type, step.value, step.value, step);
  2448. });
  2449. };
  2450. createClass(FromEntriesSequence, KeyedSeq);
  2451. function FromEntriesSequence(entries) {
  2452. this._iter = entries;
  2453. this.size = entries.size;
  2454. }
  2455. FromEntriesSequence.prototype.entrySeq = function() {
  2456. return this._iter.toSeq();
  2457. };
  2458. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2459. return this._iter.__iterate(function(entry ) {
  2460. // Check if entry exists first so array access doesn't throw for holes
  2461. // in the parent iteration.
  2462. if (entry) {
  2463. validateEntry(entry);
  2464. var indexedIterable = isIterable(entry);
  2465. return fn(
  2466. indexedIterable ? entry.get(1) : entry[1],
  2467. indexedIterable ? entry.get(0) : entry[0],
  2468. this$0
  2469. );
  2470. }
  2471. }, reverse);
  2472. };
  2473. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  2474. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2475. return new Iterator(function() {
  2476. while (true) {
  2477. var step = iterator.next();
  2478. if (step.done) {
  2479. return step;
  2480. }
  2481. var entry = step.value;
  2482. // Check if entry exists first so array access doesn't throw for holes
  2483. // in the parent iteration.
  2484. if (entry) {
  2485. validateEntry(entry);
  2486. var indexedIterable = isIterable(entry);
  2487. return iteratorValue(
  2488. type,
  2489. indexedIterable ? entry.get(0) : entry[0],
  2490. indexedIterable ? entry.get(1) : entry[1],
  2491. step
  2492. );
  2493. }
  2494. }
  2495. });
  2496. };
  2497. ToIndexedSequence.prototype.cacheResult =
  2498. ToKeyedSequence.prototype.cacheResult =
  2499. ToSetSequence.prototype.cacheResult =
  2500. FromEntriesSequence.prototype.cacheResult =
  2501. cacheResultThrough;
  2502. function flipFactory(iterable) {
  2503. var flipSequence = makeSequence(iterable);
  2504. flipSequence._iter = iterable;
  2505. flipSequence.size = iterable.size;
  2506. flipSequence.flip = function() {return iterable};
  2507. flipSequence.reverse = function () {
  2508. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  2509. reversedSequence.flip = function() {return iterable.reverse()};
  2510. return reversedSequence;
  2511. };
  2512. flipSequence.has = function(key ) {return iterable.includes(key)};
  2513. flipSequence.includes = function(key ) {return iterable.has(key)};
  2514. flipSequence.cacheResult = cacheResultThrough;
  2515. flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  2516. return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
  2517. };
  2518. flipSequence.__iteratorUncached = function(type, reverse) {
  2519. if (type === ITERATE_ENTRIES) {
  2520. var iterator = iterable.__iterator(type, reverse);
  2521. return new Iterator(function() {
  2522. var step = iterator.next();
  2523. if (!step.done) {
  2524. var k = step.value[0];
  2525. step.value[0] = step.value[1];
  2526. step.value[1] = k;
  2527. }
  2528. return step;
  2529. });
  2530. }
  2531. return iterable.__iterator(
  2532. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  2533. reverse
  2534. );
  2535. };
  2536. return flipSequence;
  2537. }
  2538. function mapFactory(iterable, mapper, context) {
  2539. var mappedSequence = makeSequence(iterable);
  2540. mappedSequence.size = iterable.size;
  2541. mappedSequence.has = function(key ) {return iterable.has(key)};
  2542. mappedSequence.get = function(key, notSetValue) {
  2543. var v = iterable.get(key, NOT_SET);
  2544. return v === NOT_SET ?
  2545. notSetValue :
  2546. mapper.call(context, v, key, iterable);
  2547. };
  2548. mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  2549. return iterable.__iterate(
  2550. function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
  2551. reverse
  2552. );
  2553. };
  2554. mappedSequence.__iteratorUncached = function (type, reverse) {
  2555. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  2556. return new Iterator(function() {
  2557. var step = iterator.next();
  2558. if (step.done) {
  2559. return step;
  2560. }
  2561. var entry = step.value;
  2562. var key = entry[0];
  2563. return iteratorValue(
  2564. type,
  2565. key,
  2566. mapper.call(context, entry[1], key, iterable),
  2567. step
  2568. );
  2569. });
  2570. };
  2571. return mappedSequence;
  2572. }
  2573. function reverseFactory(iterable, useKeys) {
  2574. var reversedSequence = makeSequence(iterable);
  2575. reversedSequence._iter = iterable;
  2576. reversedSequence.size = iterable.size;
  2577. reversedSequence.reverse = function() {return iterable};
  2578. if (iterable.flip) {
  2579. reversedSequence.flip = function () {
  2580. var flipSequence = flipFactory(iterable);
  2581. flipSequence.reverse = function() {return iterable.flip()};
  2582. return flipSequence;
  2583. };
  2584. }
  2585. reversedSequence.get = function(key, notSetValue)
  2586. {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
  2587. reversedSequence.has = function(key )
  2588. {return iterable.has(useKeys ? key : -1 - key)};
  2589. reversedSequence.includes = function(value ) {return iterable.includes(value)};
  2590. reversedSequence.cacheResult = cacheResultThrough;
  2591. reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
  2592. return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
  2593. };
  2594. reversedSequence.__iterator =
  2595. function(type, reverse) {return iterable.__iterator(type, !reverse)};
  2596. return reversedSequence;
  2597. }
  2598. function filterFactory(iterable, predicate, context, useKeys) {
  2599. var filterSequence = makeSequence(iterable);
  2600. if (useKeys) {
  2601. filterSequence.has = function(key ) {
  2602. var v = iterable.get(key, NOT_SET);
  2603. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  2604. };
  2605. filterSequence.get = function(key, notSetValue) {
  2606. var v = iterable.get(key, NOT_SET);
  2607. return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
  2608. v : notSetValue;
  2609. };
  2610. }
  2611. filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  2612. var iterations = 0;
  2613. iterable.__iterate(function(v, k, c) {
  2614. if (predicate.call(context, v, k, c)) {
  2615. iterations++;
  2616. return fn(v, useKeys ? k : iterations - 1, this$0);
  2617. }
  2618. }, reverse);
  2619. return iterations;
  2620. };
  2621. filterSequence.__iteratorUncached = function (type, reverse) {
  2622. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  2623. var iterations = 0;
  2624. return new Iterator(function() {
  2625. while (true) {
  2626. var step = iterator.next();
  2627. if (step.done) {
  2628. return step;
  2629. }
  2630. var entry = step.value;
  2631. var key = entry[0];
  2632. var value = entry[1];
  2633. if (predicate.call(context, value, key, iterable)) {
  2634. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  2635. }
  2636. }
  2637. });
  2638. };
  2639. return filterSequence;
  2640. }
  2641. function countByFactory(iterable, grouper, context) {
  2642. var groups = Map().asMutable();
  2643. iterable.__iterate(function(v, k) {
  2644. groups.update(
  2645. grouper.call(context, v, k, iterable),
  2646. 0,
  2647. function(a ) {return a + 1}
  2648. );
  2649. });
  2650. return groups.asImmutable();
  2651. }
  2652. function groupByFactory(iterable, grouper, context) {
  2653. var isKeyedIter = isKeyed(iterable);
  2654. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  2655. iterable.__iterate(function(v, k) {
  2656. groups.update(
  2657. grouper.call(context, v, k, iterable),
  2658. function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
  2659. );
  2660. });
  2661. var coerce = iterableClass(iterable);
  2662. return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
  2663. }
  2664. function sliceFactory(iterable, begin, end, useKeys) {
  2665. var originalSize = iterable.size;
  2666. // Sanitize begin & end using this shorthand for ToInt32(argument)
  2667. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  2668. if (begin !== undefined) {
  2669. begin = begin | 0;
  2670. }
  2671. if (end !== undefined) {
  2672. end = end | 0;
  2673. }
  2674. if (wholeSlice(begin, end, originalSize)) {
  2675. return iterable;
  2676. }
  2677. var resolvedBegin = resolveBegin(begin, originalSize);
  2678. var resolvedEnd = resolveEnd(end, originalSize);
  2679. // begin or end will be NaN if they were provided as negative numbers and
  2680. // this iterable's size is unknown. In that case, cache first so there is
  2681. // a known size and these do not resolve to NaN.
  2682. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  2683. return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
  2684. }
  2685. // Note: resolvedEnd is undefined when the original sequence's length is
  2686. // unknown and this slice did not supply an end and should contain all
  2687. // elements after resolvedBegin.
  2688. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  2689. var resolvedSize = resolvedEnd - resolvedBegin;
  2690. var sliceSize;
  2691. if (resolvedSize === resolvedSize) {
  2692. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  2693. }
  2694. var sliceSeq = makeSequence(iterable);
  2695. // If iterable.size is undefined, the size of the realized sliceSeq is
  2696. // unknown at this point unless the number of items to slice is 0
  2697. sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
  2698. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  2699. sliceSeq.get = function (index, notSetValue) {
  2700. index = wrapIndex(this, index);
  2701. return index >= 0 && index < sliceSize ?
  2702. iterable.get(index + resolvedBegin, notSetValue) :
  2703. notSetValue;
  2704. };
  2705. }
  2706. sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
  2707. if (sliceSize === 0) {
  2708. return 0;
  2709. }
  2710. if (reverse) {
  2711. return this.cacheResult().__iterate(fn, reverse);
  2712. }
  2713. var skipped = 0;
  2714. var isSkipping = true;
  2715. var iterations = 0;
  2716. iterable.__iterate(function(v, k) {
  2717. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  2718. iterations++;
  2719. return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  2720. iterations !== sliceSize;
  2721. }
  2722. });
  2723. return iterations;
  2724. };
  2725. sliceSeq.__iteratorUncached = function(type, reverse) {
  2726. if (sliceSize !== 0 && reverse) {
  2727. return this.cacheResult().__iterator(type, reverse);
  2728. }
  2729. // Don't bother instantiating parent iterator if taking 0.
  2730. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  2731. var skipped = 0;
  2732. var iterations = 0;
  2733. return new Iterator(function() {
  2734. while (skipped++ < resolvedBegin) {
  2735. iterator.next();
  2736. }
  2737. if (++iterations > sliceSize) {
  2738. return iteratorDone();
  2739. }
  2740. var step = iterator.next();
  2741. if (useKeys || type === ITERATE_VALUES) {
  2742. return step;
  2743. } else if (type === ITERATE_KEYS) {
  2744. return iteratorValue(type, iterations - 1, undefined, step);
  2745. } else {
  2746. return iteratorValue(type, iterations - 1, step.value[1], step);
  2747. }
  2748. });
  2749. };
  2750. return sliceSeq;
  2751. }
  2752. function takeWhileFactory(iterable, predicate, context) {
  2753. var takeSequence = makeSequence(iterable);
  2754. takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  2755. if (reverse) {
  2756. return this.cacheResult().__iterate(fn, reverse);
  2757. }
  2758. var iterations = 0;
  2759. iterable.__iterate(function(v, k, c)
  2760. {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
  2761. );
  2762. return iterations;
  2763. };
  2764. takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  2765. if (reverse) {
  2766. return this.cacheResult().__iterator(type, reverse);
  2767. }
  2768. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  2769. var iterating = true;
  2770. return new Iterator(function() {
  2771. if (!iterating) {
  2772. return iteratorDone();
  2773. }
  2774. var step = iterator.next();
  2775. if (step.done) {
  2776. return step;
  2777. }
  2778. var entry = step.value;
  2779. var k = entry[0];
  2780. var v = entry[1];
  2781. if (!predicate.call(context, v, k, this$0)) {
  2782. iterating = false;
  2783. return iteratorDone();
  2784. }
  2785. return type === ITERATE_ENTRIES ? step :
  2786. iteratorValue(type, k, v, step);
  2787. });
  2788. };
  2789. return takeSequence;
  2790. }
  2791. function skipWhileFactory(iterable, predicate, context, useKeys) {
  2792. var skipSequence = makeSequence(iterable);
  2793. skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  2794. if (reverse) {
  2795. return this.cacheResult().__iterate(fn, reverse);
  2796. }
  2797. var isSkipping = true;
  2798. var iterations = 0;
  2799. iterable.__iterate(function(v, k, c) {
  2800. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  2801. iterations++;
  2802. return fn(v, useKeys ? k : iterations - 1, this$0);
  2803. }
  2804. });
  2805. return iterations;
  2806. };
  2807. skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  2808. if (reverse) {
  2809. return this.cacheResult().__iterator(type, reverse);
  2810. }
  2811. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  2812. var skipping = true;
  2813. var iterations = 0;
  2814. return new Iterator(function() {
  2815. var step, k, v;
  2816. do {
  2817. step = iterator.next();
  2818. if (step.done) {
  2819. if (useKeys || type === ITERATE_VALUES) {
  2820. return step;
  2821. } else if (type === ITERATE_KEYS) {
  2822. return iteratorValue(type, iterations++, undefined, step);
  2823. } else {
  2824. return iteratorValue(type, iterations++, step.value[1], step);
  2825. }
  2826. }
  2827. var entry = step.value;
  2828. k = entry[0];
  2829. v = entry[1];
  2830. skipping && (skipping = predicate.call(context, v, k, this$0));
  2831. } while (skipping);
  2832. return type === ITERATE_ENTRIES ? step :
  2833. iteratorValue(type, k, v, step);
  2834. });
  2835. };
  2836. return skipSequence;
  2837. }
  2838. function concatFactory(iterable, values) {
  2839. var isKeyedIterable = isKeyed(iterable);
  2840. var iters = [iterable].concat(values).map(function(v ) {
  2841. if (!isIterable(v)) {
  2842. v = isKeyedIterable ?
  2843. keyedSeqFromValue(v) :
  2844. indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  2845. } else if (isKeyedIterable) {
  2846. v = KeyedIterable(v);
  2847. }
  2848. return v;
  2849. }).filter(function(v ) {return v.size !== 0});
  2850. if (iters.length === 0) {
  2851. return iterable;
  2852. }
  2853. if (iters.length === 1) {
  2854. var singleton = iters[0];
  2855. if (singleton === iterable ||
  2856. isKeyedIterable && isKeyed(singleton) ||
  2857. isIndexed(iterable) && isIndexed(singleton)) {
  2858. return singleton;
  2859. }
  2860. }
  2861. var concatSeq = new ArraySeq(iters);
  2862. if (isKeyedIterable) {
  2863. concatSeq = concatSeq.toKeyedSeq();
  2864. } else if (!isIndexed(iterable)) {
  2865. concatSeq = concatSeq.toSetSeq();
  2866. }
  2867. concatSeq = concatSeq.flatten(true);
  2868. concatSeq.size = iters.reduce(
  2869. function(sum, seq) {
  2870. if (sum !== undefined) {
  2871. var size = seq.size;
  2872. if (size !== undefined) {
  2873. return sum + size;
  2874. }
  2875. }
  2876. },
  2877. 0
  2878. );
  2879. return concatSeq;
  2880. }
  2881. function flattenFactory(iterable, depth, useKeys) {
  2882. var flatSequence = makeSequence(iterable);
  2883. flatSequence.__iterateUncached = function(fn, reverse) {
  2884. var iterations = 0;
  2885. var stopped = false;
  2886. function flatDeep(iter, currentDepth) {var this$0 = this;
  2887. iter.__iterate(function(v, k) {
  2888. if ((!depth || currentDepth < depth) && isIterable(v)) {
  2889. flatDeep(v, currentDepth + 1);
  2890. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  2891. stopped = true;
  2892. }
  2893. return !stopped;
  2894. }, reverse);
  2895. }
  2896. flatDeep(iterable, 0);
  2897. return iterations;
  2898. };
  2899. flatSequence.__iteratorUncached = function(type, reverse) {
  2900. var iterator = iterable.__iterator(type, reverse);
  2901. var stack = [];
  2902. var iterations = 0;
  2903. return new Iterator(function() {
  2904. while (iterator) {
  2905. var step = iterator.next();
  2906. if (step.done !== false) {
  2907. iterator = stack.pop();
  2908. continue;
  2909. }
  2910. var v = step.value;
  2911. if (type === ITERATE_ENTRIES) {
  2912. v = v[1];
  2913. }
  2914. if ((!depth || stack.length < depth) && isIterable(v)) {
  2915. stack.push(iterator);
  2916. iterator = v.__iterator(type, reverse);
  2917. } else {
  2918. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  2919. }
  2920. }
  2921. return iteratorDone();
  2922. });
  2923. };
  2924. return flatSequence;
  2925. }
  2926. function flatMapFactory(iterable, mapper, context) {
  2927. var coerce = iterableClass(iterable);
  2928. return iterable.toSeq().map(
  2929. function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
  2930. ).flatten(true);
  2931. }
  2932. function interposeFactory(iterable, separator) {
  2933. var interposedSequence = makeSequence(iterable);
  2934. interposedSequence.size = iterable.size && iterable.size * 2 -1;
  2935. interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  2936. var iterations = 0;
  2937. iterable.__iterate(function(v, k)
  2938. {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
  2939. fn(v, iterations++, this$0) !== false},
  2940. reverse
  2941. );
  2942. return iterations;
  2943. };
  2944. interposedSequence.__iteratorUncached = function(type, reverse) {
  2945. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  2946. var iterations = 0;
  2947. var step;
  2948. return new Iterator(function() {
  2949. if (!step || iterations % 2) {
  2950. step = iterator.next();
  2951. if (step.done) {
  2952. return step;
  2953. }
  2954. }
  2955. return iterations % 2 ?
  2956. iteratorValue(type, iterations++, separator) :
  2957. iteratorValue(type, iterations++, step.value, step);
  2958. });
  2959. };
  2960. return interposedSequence;
  2961. }
  2962. function sortFactory(iterable, comparator, mapper) {
  2963. if (!comparator) {
  2964. comparator = defaultComparator;
  2965. }
  2966. var isKeyedIterable = isKeyed(iterable);
  2967. var index = 0;
  2968. var entries = iterable.toSeq().map(
  2969. function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
  2970. ).toArray();
  2971. entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
  2972. isKeyedIterable ?
  2973. function(v, i) { entries[i].length = 2; } :
  2974. function(v, i) { entries[i] = v[1]; }
  2975. );
  2976. return isKeyedIterable ? KeyedSeq(entries) :
  2977. isIndexed(iterable) ? IndexedSeq(entries) :
  2978. SetSeq(entries);
  2979. }
  2980. function maxFactory(iterable, comparator, mapper) {
  2981. if (!comparator) {
  2982. comparator = defaultComparator;
  2983. }
  2984. if (mapper) {
  2985. var entry = iterable.toSeq()
  2986. .map(function(v, k) {return [v, mapper(v, k, iterable)]})
  2987. .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
  2988. return entry && entry[0];
  2989. } else {
  2990. return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
  2991. }
  2992. }
  2993. function maxCompare(comparator, a, b) {
  2994. var comp = comparator(b, a);
  2995. // b is considered the new max if the comparator declares them equal, but
  2996. // they are not equal and b is in fact a nullish value.
  2997. return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
  2998. }
  2999. function zipWithFactory(keyIter, zipper, iters) {
  3000. var zipSequence = makeSequence(keyIter);
  3001. zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
  3002. // Note: this a generic base implementation of __iterate in terms of
  3003. // __iterator which may be more generically useful in the future.
  3004. zipSequence.__iterate = function(fn, reverse) {
  3005. /* generic:
  3006. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  3007. var step;
  3008. var iterations = 0;
  3009. while (!(step = iterator.next()).done) {
  3010. iterations++;
  3011. if (fn(step.value[1], step.value[0], this) === false) {
  3012. break;
  3013. }
  3014. }
  3015. return iterations;
  3016. */
  3017. // indexed:
  3018. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  3019. var step;
  3020. var iterations = 0;
  3021. while (!(step = iterator.next()).done) {
  3022. if (fn(step.value, iterations++, this) === false) {
  3023. break;
  3024. }
  3025. }
  3026. return iterations;
  3027. };
  3028. zipSequence.__iteratorUncached = function(type, reverse) {
  3029. var iterators = iters.map(function(i )
  3030. {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
  3031. );
  3032. var iterations = 0;
  3033. var isDone = false;
  3034. return new Iterator(function() {
  3035. var steps;
  3036. if (!isDone) {
  3037. steps = iterators.map(function(i ) {return i.next()});
  3038. isDone = steps.some(function(s ) {return s.done});
  3039. }
  3040. if (isDone) {
  3041. return iteratorDone();
  3042. }
  3043. return iteratorValue(
  3044. type,
  3045. iterations++,
  3046. zipper.apply(null, steps.map(function(s ) {return s.value}))
  3047. );
  3048. });
  3049. };
  3050. return zipSequence
  3051. }
  3052. // #pragma Helper Functions
  3053. function reify(iter, seq) {
  3054. return isSeq(iter) ? seq : iter.constructor(seq);
  3055. }
  3056. function validateEntry(entry) {
  3057. if (entry !== Object(entry)) {
  3058. throw new TypeError('Expected [K, V] tuple: ' + entry);
  3059. }
  3060. }
  3061. function resolveSize(iter) {
  3062. assertNotInfinite(iter.size);
  3063. return ensureSize(iter);
  3064. }
  3065. function iterableClass(iterable) {
  3066. return isKeyed(iterable) ? KeyedIterable :
  3067. isIndexed(iterable) ? IndexedIterable :
  3068. SetIterable;
  3069. }
  3070. function makeSequence(iterable) {
  3071. return Object.create(
  3072. (
  3073. isKeyed(iterable) ? KeyedSeq :
  3074. isIndexed(iterable) ? IndexedSeq :
  3075. SetSeq
  3076. ).prototype
  3077. );
  3078. }
  3079. function cacheResultThrough() {
  3080. if (this._iter.cacheResult) {
  3081. this._iter.cacheResult();
  3082. this.size = this._iter.size;
  3083. return this;
  3084. } else {
  3085. return Seq.prototype.cacheResult.call(this);
  3086. }
  3087. }
  3088. function defaultComparator(a, b) {
  3089. return a > b ? 1 : a < b ? -1 : 0;
  3090. }
  3091. function forceIterator(keyPath) {
  3092. var iter = getIterator(keyPath);
  3093. if (!iter) {
  3094. // Array might not be iterable in this environment, so we need a fallback
  3095. // to our wrapped type.
  3096. if (!isArrayLike(keyPath)) {
  3097. throw new TypeError('Expected iterable or array-like: ' + keyPath);
  3098. }
  3099. iter = getIterator(Iterable(keyPath));
  3100. }
  3101. return iter;
  3102. }
  3103. createClass(Record, KeyedCollection);
  3104. function Record(defaultValues, name) {
  3105. var hasInitialized;
  3106. var RecordType = function Record(values) {
  3107. if (values instanceof RecordType) {
  3108. return values;
  3109. }
  3110. if (!(this instanceof RecordType)) {
  3111. return new RecordType(values);
  3112. }
  3113. if (!hasInitialized) {
  3114. hasInitialized = true;
  3115. var keys = Object.keys(defaultValues);
  3116. setProps(RecordTypePrototype, keys);
  3117. RecordTypePrototype.size = keys.length;
  3118. RecordTypePrototype._name = name;
  3119. RecordTypePrototype._keys = keys;
  3120. RecordTypePrototype._defaultValues = defaultValues;
  3121. }
  3122. this._map = Map(values);
  3123. };
  3124. var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
  3125. RecordTypePrototype.constructor = RecordType;
  3126. return RecordType;
  3127. }
  3128. Record.prototype.toString = function() {
  3129. return this.__toString(recordName(this) + ' {', '}');
  3130. };
  3131. // @pragma Access
  3132. Record.prototype.has = function(k) {
  3133. return this._defaultValues.hasOwnProperty(k);
  3134. };
  3135. Record.prototype.get = function(k, notSetValue) {
  3136. if (!this.has(k)) {
  3137. return notSetValue;
  3138. }
  3139. var defaultVal = this._defaultValues[k];
  3140. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  3141. };
  3142. // @pragma Modification
  3143. Record.prototype.clear = function() {
  3144. if (this.__ownerID) {
  3145. this._map && this._map.clear();
  3146. return this;
  3147. }
  3148. var RecordType = this.constructor;
  3149. return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
  3150. };
  3151. Record.prototype.set = function(k, v) {
  3152. if (!this.has(k)) {
  3153. throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
  3154. }
  3155. var newMap = this._map && this._map.set(k, v);
  3156. if (this.__ownerID || newMap === this._map) {
  3157. return this;
  3158. }
  3159. return makeRecord(this, newMap);
  3160. };
  3161. Record.prototype.remove = function(k) {
  3162. if (!this.has(k)) {
  3163. return this;
  3164. }
  3165. var newMap = this._map && this._map.remove(k);
  3166. if (this.__ownerID || newMap === this._map) {
  3167. return this;
  3168. }
  3169. return makeRecord(this, newMap);
  3170. };
  3171. Record.prototype.wasAltered = function() {
  3172. return this._map.wasAltered();
  3173. };
  3174. Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
  3175. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
  3176. };
  3177. Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  3178. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
  3179. };
  3180. Record.prototype.__ensureOwner = function(ownerID) {
  3181. if (ownerID === this.__ownerID) {
  3182. return this;
  3183. }
  3184. var newMap = this._map && this._map.__ensureOwner(ownerID);
  3185. if (!ownerID) {
  3186. this.__ownerID = ownerID;
  3187. this._map = newMap;
  3188. return this;
  3189. }
  3190. return makeRecord(this, newMap, ownerID);
  3191. };
  3192. var RecordPrototype = Record.prototype;
  3193. RecordPrototype[DELETE] = RecordPrototype.remove;
  3194. RecordPrototype.deleteIn =
  3195. RecordPrototype.removeIn = MapPrototype.removeIn;
  3196. RecordPrototype.merge = MapPrototype.merge;
  3197. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  3198. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  3199. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  3200. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  3201. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  3202. RecordPrototype.setIn = MapPrototype.setIn;
  3203. RecordPrototype.update = MapPrototype.update;
  3204. RecordPrototype.updateIn = MapPrototype.updateIn;
  3205. RecordPrototype.withMutations = MapPrototype.withMutations;
  3206. RecordPrototype.asMutable = MapPrototype.asMutable;
  3207. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  3208. function makeRecord(likeRecord, map, ownerID) {
  3209. var record = Object.create(Object.getPrototypeOf(likeRecord));
  3210. record._map = map;
  3211. record.__ownerID = ownerID;
  3212. return record;
  3213. }
  3214. function recordName(record) {
  3215. return record._name || record.constructor.name || 'Record';
  3216. }
  3217. function setProps(prototype, names) {
  3218. try {
  3219. names.forEach(setProp.bind(undefined, prototype));
  3220. } catch (error) {
  3221. // Object.defineProperty failed. Probably IE8.
  3222. }
  3223. }
  3224. function setProp(prototype, name) {
  3225. Object.defineProperty(prototype, name, {
  3226. get: function() {
  3227. return this.get(name);
  3228. },
  3229. set: function(value) {
  3230. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  3231. this.set(name, value);
  3232. }
  3233. });
  3234. }
  3235. createClass(Set, SetCollection);
  3236. // @pragma Construction
  3237. function Set(value) {
  3238. return value === null || value === undefined ? emptySet() :
  3239. isSet(value) && !isOrdered(value) ? value :
  3240. emptySet().withMutations(function(set ) {
  3241. var iter = SetIterable(value);
  3242. assertNotInfinite(iter.size);
  3243. iter.forEach(function(v ) {return set.add(v)});
  3244. });
  3245. }
  3246. Set.of = function(/*...values*/) {
  3247. return this(arguments);
  3248. };
  3249. Set.fromKeys = function(value) {
  3250. return this(KeyedIterable(value).keySeq());
  3251. };
  3252. Set.prototype.toString = function() {
  3253. return this.__toString('Set {', '}');
  3254. };
  3255. // @pragma Access
  3256. Set.prototype.has = function(value) {
  3257. return this._map.has(value);
  3258. };
  3259. // @pragma Modification
  3260. Set.prototype.add = function(value) {
  3261. return updateSet(this, this._map.set(value, true));
  3262. };
  3263. Set.prototype.remove = function(value) {
  3264. return updateSet(this, this._map.remove(value));
  3265. };
  3266. Set.prototype.clear = function() {
  3267. return updateSet(this, this._map.clear());
  3268. };
  3269. // @pragma Composition
  3270. Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
  3271. iters = iters.filter(function(x ) {return x.size !== 0});
  3272. if (iters.length === 0) {
  3273. return this;
  3274. }
  3275. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  3276. return this.constructor(iters[0]);
  3277. }
  3278. return this.withMutations(function(set ) {
  3279. for (var ii = 0; ii < iters.length; ii++) {
  3280. SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
  3281. }
  3282. });
  3283. };
  3284. Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
  3285. if (iters.length === 0) {
  3286. return this;
  3287. }
  3288. iters = iters.map(function(iter ) {return SetIterable(iter)});
  3289. var originalSet = this;
  3290. return this.withMutations(function(set ) {
  3291. originalSet.forEach(function(value ) {
  3292. if (!iters.every(function(iter ) {return iter.includes(value)})) {
  3293. set.remove(value);
  3294. }
  3295. });
  3296. });
  3297. };
  3298. Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
  3299. if (iters.length === 0) {
  3300. return this;
  3301. }
  3302. iters = iters.map(function(iter ) {return SetIterable(iter)});
  3303. var originalSet = this;
  3304. return this.withMutations(function(set ) {
  3305. originalSet.forEach(function(value ) {
  3306. if (iters.some(function(iter ) {return iter.includes(value)})) {
  3307. set.remove(value);
  3308. }
  3309. });
  3310. });
  3311. };
  3312. Set.prototype.merge = function() {
  3313. return this.union.apply(this, arguments);
  3314. };
  3315. Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  3316. return this.union.apply(this, iters);
  3317. };
  3318. Set.prototype.sort = function(comparator) {
  3319. // Late binding
  3320. return OrderedSet(sortFactory(this, comparator));
  3321. };
  3322. Set.prototype.sortBy = function(mapper, comparator) {
  3323. // Late binding
  3324. return OrderedSet(sortFactory(this, comparator, mapper));
  3325. };
  3326. Set.prototype.wasAltered = function() {
  3327. return this._map.wasAltered();
  3328. };
  3329. Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  3330. return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
  3331. };
  3332. Set.prototype.__iterator = function(type, reverse) {
  3333. return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
  3334. };
  3335. Set.prototype.__ensureOwner = function(ownerID) {
  3336. if (ownerID === this.__ownerID) {
  3337. return this;
  3338. }
  3339. var newMap = this._map.__ensureOwner(ownerID);
  3340. if (!ownerID) {
  3341. this.__ownerID = ownerID;
  3342. this._map = newMap;
  3343. return this;
  3344. }
  3345. return this.__make(newMap, ownerID);
  3346. };
  3347. function isSet(maybeSet) {
  3348. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  3349. }
  3350. Set.isSet = isSet;
  3351. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  3352. var SetPrototype = Set.prototype;
  3353. SetPrototype[IS_SET_SENTINEL] = true;
  3354. SetPrototype[DELETE] = SetPrototype.remove;
  3355. SetPrototype.mergeDeep = SetPrototype.merge;
  3356. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  3357. SetPrototype.withMutations = MapPrototype.withMutations;
  3358. SetPrototype.asMutable = MapPrototype.asMutable;
  3359. SetPrototype.asImmutable = MapPrototype.asImmutable;
  3360. SetPrototype.__empty = emptySet;
  3361. SetPrototype.__make = makeSet;
  3362. function updateSet(set, newMap) {
  3363. if (set.__ownerID) {
  3364. set.size = newMap.size;
  3365. set._map = newMap;
  3366. return set;
  3367. }
  3368. return newMap === set._map ? set :
  3369. newMap.size === 0 ? set.__empty() :
  3370. set.__make(newMap);
  3371. }
  3372. function makeSet(map, ownerID) {
  3373. var set = Object.create(SetPrototype);
  3374. set.size = map ? map.size : 0;
  3375. set._map = map;
  3376. set.__ownerID = ownerID;
  3377. return set;
  3378. }
  3379. var EMPTY_SET;
  3380. function emptySet() {
  3381. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  3382. }
  3383. createClass(OrderedSet, Set);
  3384. // @pragma Construction
  3385. function OrderedSet(value) {
  3386. return value === null || value === undefined ? emptyOrderedSet() :
  3387. isOrderedSet(value) ? value :
  3388. emptyOrderedSet().withMutations(function(set ) {
  3389. var iter = SetIterable(value);
  3390. assertNotInfinite(iter.size);
  3391. iter.forEach(function(v ) {return set.add(v)});
  3392. });
  3393. }
  3394. OrderedSet.of = function(/*...values*/) {
  3395. return this(arguments);
  3396. };
  3397. OrderedSet.fromKeys = function(value) {
  3398. return this(KeyedIterable(value).keySeq());
  3399. };
  3400. OrderedSet.prototype.toString = function() {
  3401. return this.__toString('OrderedSet {', '}');
  3402. };
  3403. function isOrderedSet(maybeOrderedSet) {
  3404. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  3405. }
  3406. OrderedSet.isOrderedSet = isOrderedSet;
  3407. var OrderedSetPrototype = OrderedSet.prototype;
  3408. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  3409. OrderedSetPrototype.__empty = emptyOrderedSet;
  3410. OrderedSetPrototype.__make = makeOrderedSet;
  3411. function makeOrderedSet(map, ownerID) {
  3412. var set = Object.create(OrderedSetPrototype);
  3413. set.size = map ? map.size : 0;
  3414. set._map = map;
  3415. set.__ownerID = ownerID;
  3416. return set;
  3417. }
  3418. var EMPTY_ORDERED_SET;
  3419. function emptyOrderedSet() {
  3420. return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
  3421. }
  3422. createClass(Stack, IndexedCollection);
  3423. // @pragma Construction
  3424. function Stack(value) {
  3425. return value === null || value === undefined ? emptyStack() :
  3426. isStack(value) ? value :
  3427. emptyStack().unshiftAll(value);
  3428. }
  3429. Stack.of = function(/*...values*/) {
  3430. return this(arguments);
  3431. };
  3432. Stack.prototype.toString = function() {
  3433. return this.__toString('Stack [', ']');
  3434. };
  3435. // @pragma Access
  3436. Stack.prototype.get = function(index, notSetValue) {
  3437. var head = this._head;
  3438. index = wrapIndex(this, index);
  3439. while (head && index--) {
  3440. head = head.next;
  3441. }
  3442. return head ? head.value : notSetValue;
  3443. };
  3444. Stack.prototype.peek = function() {
  3445. return this._head && this._head.value;
  3446. };
  3447. // @pragma Modification
  3448. Stack.prototype.push = function(/*...values*/) {
  3449. if (arguments.length === 0) {
  3450. return this;
  3451. }
  3452. var newSize = this.size + arguments.length;
  3453. var head = this._head;
  3454. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  3455. head = {
  3456. value: arguments[ii],
  3457. next: head
  3458. };
  3459. }
  3460. if (this.__ownerID) {
  3461. this.size = newSize;
  3462. this._head = head;
  3463. this.__hash = undefined;
  3464. this.__altered = true;
  3465. return this;
  3466. }
  3467. return makeStack(newSize, head);
  3468. };
  3469. Stack.prototype.pushAll = function(iter) {
  3470. iter = IndexedIterable(iter);
  3471. if (iter.size === 0) {
  3472. return this;
  3473. }
  3474. assertNotInfinite(iter.size);
  3475. var newSize = this.size;
  3476. var head = this._head;
  3477. iter.reverse().forEach(function(value ) {
  3478. newSize++;
  3479. head = {
  3480. value: value,
  3481. next: head
  3482. };
  3483. });
  3484. if (this.__ownerID) {
  3485. this.size = newSize;
  3486. this._head = head;
  3487. this.__hash = undefined;
  3488. this.__altered = true;
  3489. return this;
  3490. }
  3491. return makeStack(newSize, head);
  3492. };
  3493. Stack.prototype.pop = function() {
  3494. return this.slice(1);
  3495. };
  3496. Stack.prototype.unshift = function(/*...values*/) {
  3497. return this.push.apply(this, arguments);
  3498. };
  3499. Stack.prototype.unshiftAll = function(iter) {
  3500. return this.pushAll(iter);
  3501. };
  3502. Stack.prototype.shift = function() {
  3503. return this.pop.apply(this, arguments);
  3504. };
  3505. Stack.prototype.clear = function() {
  3506. if (this.size === 0) {
  3507. return this;
  3508. }
  3509. if (this.__ownerID) {
  3510. this.size = 0;
  3511. this._head = undefined;
  3512. this.__hash = undefined;
  3513. this.__altered = true;
  3514. return this;
  3515. }
  3516. return emptyStack();
  3517. };
  3518. Stack.prototype.slice = function(begin, end) {
  3519. if (wholeSlice(begin, end, this.size)) {
  3520. return this;
  3521. }
  3522. var resolvedBegin = resolveBegin(begin, this.size);
  3523. var resolvedEnd = resolveEnd(end, this.size);
  3524. if (resolvedEnd !== this.size) {
  3525. // super.slice(begin, end);
  3526. return IndexedCollection.prototype.slice.call(this, begin, end);
  3527. }
  3528. var newSize = this.size - resolvedBegin;
  3529. var head = this._head;
  3530. while (resolvedBegin--) {
  3531. head = head.next;
  3532. }
  3533. if (this.__ownerID) {
  3534. this.size = newSize;
  3535. this._head = head;
  3536. this.__hash = undefined;
  3537. this.__altered = true;
  3538. return this;
  3539. }
  3540. return makeStack(newSize, head);
  3541. };
  3542. // @pragma Mutability
  3543. Stack.prototype.__ensureOwner = function(ownerID) {
  3544. if (ownerID === this.__ownerID) {
  3545. return this;
  3546. }
  3547. if (!ownerID) {
  3548. this.__ownerID = ownerID;
  3549. this.__altered = false;
  3550. return this;
  3551. }
  3552. return makeStack(this.size, this._head, ownerID, this.__hash);
  3553. };
  3554. // @pragma Iteration
  3555. Stack.prototype.__iterate = function(fn, reverse) {
  3556. if (reverse) {
  3557. return this.reverse().__iterate(fn);
  3558. }
  3559. var iterations = 0;
  3560. var node = this._head;
  3561. while (node) {
  3562. if (fn(node.value, iterations++, this) === false) {
  3563. break;
  3564. }
  3565. node = node.next;
  3566. }
  3567. return iterations;
  3568. };
  3569. Stack.prototype.__iterator = function(type, reverse) {
  3570. if (reverse) {
  3571. return this.reverse().__iterator(type);
  3572. }
  3573. var iterations = 0;
  3574. var node = this._head;
  3575. return new Iterator(function() {
  3576. if (node) {
  3577. var value = node.value;
  3578. node = node.next;
  3579. return iteratorValue(type, iterations++, value);
  3580. }
  3581. return iteratorDone();
  3582. });
  3583. };
  3584. function isStack(maybeStack) {
  3585. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  3586. }
  3587. Stack.isStack = isStack;
  3588. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  3589. var StackPrototype = Stack.prototype;
  3590. StackPrototype[IS_STACK_SENTINEL] = true;
  3591. StackPrototype.withMutations = MapPrototype.withMutations;
  3592. StackPrototype.asMutable = MapPrototype.asMutable;
  3593. StackPrototype.asImmutable = MapPrototype.asImmutable;
  3594. StackPrototype.wasAltered = MapPrototype.wasAltered;
  3595. function makeStack(size, head, ownerID, hash) {
  3596. var map = Object.create(StackPrototype);
  3597. map.size = size;
  3598. map._head = head;
  3599. map.__ownerID = ownerID;
  3600. map.__hash = hash;
  3601. map.__altered = false;
  3602. return map;
  3603. }
  3604. var EMPTY_STACK;
  3605. function emptyStack() {
  3606. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  3607. }
  3608. /**
  3609. * Contributes additional methods to a constructor
  3610. */
  3611. function mixin(ctor, methods) {
  3612. var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
  3613. Object.keys(methods).forEach(keyCopier);
  3614. Object.getOwnPropertySymbols &&
  3615. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  3616. return ctor;
  3617. }
  3618. Iterable.Iterator = Iterator;
  3619. mixin(Iterable, {
  3620. // ### Conversion to other types
  3621. toArray: function() {
  3622. assertNotInfinite(this.size);
  3623. var array = new Array(this.size || 0);
  3624. this.valueSeq().__iterate(function(v, i) { array[i] = v; });
  3625. return array;
  3626. },
  3627. toIndexedSeq: function() {
  3628. return new ToIndexedSequence(this);
  3629. },
  3630. toJS: function() {
  3631. return this.toSeq().map(
  3632. function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
  3633. ).__toJS();
  3634. },
  3635. toJSON: function() {
  3636. return this.toSeq().map(
  3637. function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
  3638. ).__toJS();
  3639. },
  3640. toKeyedSeq: function() {
  3641. return new ToKeyedSequence(this, true);
  3642. },
  3643. toMap: function() {
  3644. // Use Late Binding here to solve the circular dependency.
  3645. return Map(this.toKeyedSeq());
  3646. },
  3647. toObject: function() {
  3648. assertNotInfinite(this.size);
  3649. var object = {};
  3650. this.__iterate(function(v, k) { object[k] = v; });
  3651. return object;
  3652. },
  3653. toOrderedMap: function() {
  3654. // Use Late Binding here to solve the circular dependency.
  3655. return OrderedMap(this.toKeyedSeq());
  3656. },
  3657. toOrderedSet: function() {
  3658. // Use Late Binding here to solve the circular dependency.
  3659. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  3660. },
  3661. toSet: function() {
  3662. // Use Late Binding here to solve the circular dependency.
  3663. return Set(isKeyed(this) ? this.valueSeq() : this);
  3664. },
  3665. toSetSeq: function() {
  3666. return new ToSetSequence(this);
  3667. },
  3668. toSeq: function() {
  3669. return isIndexed(this) ? this.toIndexedSeq() :
  3670. isKeyed(this) ? this.toKeyedSeq() :
  3671. this.toSetSeq();
  3672. },
  3673. toStack: function() {
  3674. // Use Late Binding here to solve the circular dependency.
  3675. return Stack(isKeyed(this) ? this.valueSeq() : this);
  3676. },
  3677. toList: function() {
  3678. // Use Late Binding here to solve the circular dependency.
  3679. return List(isKeyed(this) ? this.valueSeq() : this);
  3680. },
  3681. // ### Common JavaScript methods and properties
  3682. toString: function() {
  3683. return '[Iterable]';
  3684. },
  3685. __toString: function(head, tail) {
  3686. if (this.size === 0) {
  3687. return head + tail;
  3688. }
  3689. return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
  3690. },
  3691. // ### ES6 Collection methods (ES6 Array and Map)
  3692. concat: function() {var values = SLICE$0.call(arguments, 0);
  3693. return reify(this, concatFactory(this, values));
  3694. },
  3695. includes: function(searchValue) {
  3696. return this.some(function(value ) {return is(value, searchValue)});
  3697. },
  3698. entries: function() {
  3699. return this.__iterator(ITERATE_ENTRIES);
  3700. },
  3701. every: function(predicate, context) {
  3702. assertNotInfinite(this.size);
  3703. var returnValue = true;
  3704. this.__iterate(function(v, k, c) {
  3705. if (!predicate.call(context, v, k, c)) {
  3706. returnValue = false;
  3707. return false;
  3708. }
  3709. });
  3710. return returnValue;
  3711. },
  3712. filter: function(predicate, context) {
  3713. return reify(this, filterFactory(this, predicate, context, true));
  3714. },
  3715. find: function(predicate, context, notSetValue) {
  3716. var entry = this.findEntry(predicate, context);
  3717. return entry ? entry[1] : notSetValue;
  3718. },
  3719. findEntry: function(predicate, context) {
  3720. var found;
  3721. this.__iterate(function(v, k, c) {
  3722. if (predicate.call(context, v, k, c)) {
  3723. found = [k, v];
  3724. return false;
  3725. }
  3726. });
  3727. return found;
  3728. },
  3729. findLastEntry: function(predicate, context) {
  3730. return this.toSeq().reverse().findEntry(predicate, context);
  3731. },
  3732. forEach: function(sideEffect, context) {
  3733. assertNotInfinite(this.size);
  3734. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  3735. },
  3736. join: function(separator) {
  3737. assertNotInfinite(this.size);
  3738. separator = separator !== undefined ? '' + separator : ',';
  3739. var joined = '';
  3740. var isFirst = true;
  3741. this.__iterate(function(v ) {
  3742. isFirst ? (isFirst = false) : (joined += separator);
  3743. joined += v !== null && v !== undefined ? v.toString() : '';
  3744. });
  3745. return joined;
  3746. },
  3747. keys: function() {
  3748. return this.__iterator(ITERATE_KEYS);
  3749. },
  3750. map: function(mapper, context) {
  3751. return reify(this, mapFactory(this, mapper, context));
  3752. },
  3753. reduce: function(reducer, initialReduction, context) {
  3754. assertNotInfinite(this.size);
  3755. var reduction;
  3756. var useFirst;
  3757. if (arguments.length < 2) {
  3758. useFirst = true;
  3759. } else {
  3760. reduction = initialReduction;
  3761. }
  3762. this.__iterate(function(v, k, c) {
  3763. if (useFirst) {
  3764. useFirst = false;
  3765. reduction = v;
  3766. } else {
  3767. reduction = reducer.call(context, reduction, v, k, c);
  3768. }
  3769. });
  3770. return reduction;
  3771. },
  3772. reduceRight: function(reducer, initialReduction, context) {
  3773. var reversed = this.toKeyedSeq().reverse();
  3774. return reversed.reduce.apply(reversed, arguments);
  3775. },
  3776. reverse: function() {
  3777. return reify(this, reverseFactory(this, true));
  3778. },
  3779. slice: function(begin, end) {
  3780. return reify(this, sliceFactory(this, begin, end, true));
  3781. },
  3782. some: function(predicate, context) {
  3783. return !this.every(not(predicate), context);
  3784. },
  3785. sort: function(comparator) {
  3786. return reify(this, sortFactory(this, comparator));
  3787. },
  3788. values: function() {
  3789. return this.__iterator(ITERATE_VALUES);
  3790. },
  3791. // ### More sequential methods
  3792. butLast: function() {
  3793. return this.slice(0, -1);
  3794. },
  3795. isEmpty: function() {
  3796. return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
  3797. },
  3798. count: function(predicate, context) {
  3799. return ensureSize(
  3800. predicate ? this.toSeq().filter(predicate, context) : this
  3801. );
  3802. },
  3803. countBy: function(grouper, context) {
  3804. return countByFactory(this, grouper, context);
  3805. },
  3806. equals: function(other) {
  3807. return deepEqual(this, other);
  3808. },
  3809. entrySeq: function() {
  3810. var iterable = this;
  3811. if (iterable._cache) {
  3812. // We cache as an entries array, so we can just return the cache!
  3813. return new ArraySeq(iterable._cache);
  3814. }
  3815. var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
  3816. entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
  3817. return entriesSequence;
  3818. },
  3819. filterNot: function(predicate, context) {
  3820. return this.filter(not(predicate), context);
  3821. },
  3822. findLast: function(predicate, context, notSetValue) {
  3823. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  3824. },
  3825. first: function() {
  3826. return this.find(returnTrue);
  3827. },
  3828. flatMap: function(mapper, context) {
  3829. return reify(this, flatMapFactory(this, mapper, context));
  3830. },
  3831. flatten: function(depth) {
  3832. return reify(this, flattenFactory(this, depth, true));
  3833. },
  3834. fromEntrySeq: function() {
  3835. return new FromEntriesSequence(this);
  3836. },
  3837. get: function(searchKey, notSetValue) {
  3838. return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
  3839. },
  3840. getIn: function(searchKeyPath, notSetValue) {
  3841. var nested = this;
  3842. // Note: in an ES6 environment, we would prefer:
  3843. // for (var key of searchKeyPath) {
  3844. var iter = forceIterator(searchKeyPath);
  3845. var step;
  3846. while (!(step = iter.next()).done) {
  3847. var key = step.value;
  3848. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  3849. if (nested === NOT_SET) {
  3850. return notSetValue;
  3851. }
  3852. }
  3853. return nested;
  3854. },
  3855. groupBy: function(grouper, context) {
  3856. return groupByFactory(this, grouper, context);
  3857. },
  3858. has: function(searchKey) {
  3859. return this.get(searchKey, NOT_SET) !== NOT_SET;
  3860. },
  3861. hasIn: function(searchKeyPath) {
  3862. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  3863. },
  3864. isSubset: function(iter) {
  3865. iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
  3866. return this.every(function(value ) {return iter.includes(value)});
  3867. },
  3868. isSuperset: function(iter) {
  3869. iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
  3870. return iter.isSubset(this);
  3871. },
  3872. keySeq: function() {
  3873. return this.toSeq().map(keyMapper).toIndexedSeq();
  3874. },
  3875. last: function() {
  3876. return this.toSeq().reverse().first();
  3877. },
  3878. max: function(comparator) {
  3879. return maxFactory(this, comparator);
  3880. },
  3881. maxBy: function(mapper, comparator) {
  3882. return maxFactory(this, comparator, mapper);
  3883. },
  3884. min: function(comparator) {
  3885. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
  3886. },
  3887. minBy: function(mapper, comparator) {
  3888. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
  3889. },
  3890. rest: function() {
  3891. return this.slice(1);
  3892. },
  3893. skip: function(amount) {
  3894. return this.slice(Math.max(0, amount));
  3895. },
  3896. skipLast: function(amount) {
  3897. return reify(this, this.toSeq().reverse().skip(amount).reverse());
  3898. },
  3899. skipWhile: function(predicate, context) {
  3900. return reify(this, skipWhileFactory(this, predicate, context, true));
  3901. },
  3902. skipUntil: function(predicate, context) {
  3903. return this.skipWhile(not(predicate), context);
  3904. },
  3905. sortBy: function(mapper, comparator) {
  3906. return reify(this, sortFactory(this, comparator, mapper));
  3907. },
  3908. take: function(amount) {
  3909. return this.slice(0, Math.max(0, amount));
  3910. },
  3911. takeLast: function(amount) {
  3912. return reify(this, this.toSeq().reverse().take(amount).reverse());
  3913. },
  3914. takeWhile: function(predicate, context) {
  3915. return reify(this, takeWhileFactory(this, predicate, context));
  3916. },
  3917. takeUntil: function(predicate, context) {
  3918. return this.takeWhile(not(predicate), context);
  3919. },
  3920. valueSeq: function() {
  3921. return this.toIndexedSeq();
  3922. },
  3923. // ### Hashable Object
  3924. hashCode: function() {
  3925. return this.__hash || (this.__hash = hashIterable(this));
  3926. }
  3927. // ### Internal
  3928. // abstract __iterate(fn, reverse)
  3929. // abstract __iterator(type, reverse)
  3930. });
  3931. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  3932. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  3933. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  3934. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  3935. var IterablePrototype = Iterable.prototype;
  3936. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  3937. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  3938. IterablePrototype.__toJS = IterablePrototype.toArray;
  3939. IterablePrototype.__toStringMapper = quoteString;
  3940. IterablePrototype.inspect =
  3941. IterablePrototype.toSource = function() { return this.toString(); };
  3942. IterablePrototype.chain = IterablePrototype.flatMap;
  3943. IterablePrototype.contains = IterablePrototype.includes;
  3944. // Temporary warning about using length
  3945. (function () {
  3946. try {
  3947. Object.defineProperty(IterablePrototype, 'length', {
  3948. get: function () {
  3949. if (!Iterable.noLengthWarning) {
  3950. var stack;
  3951. try {
  3952. throw new Error();
  3953. } catch (error) {
  3954. stack = error.stack;
  3955. }
  3956. if (stack.indexOf('_wrapObject') === -1) {
  3957. console && console.warn && console.warn(
  3958. 'iterable.length has been deprecated, '+
  3959. 'use iterable.size or iterable.count(). '+
  3960. 'This warning will become a silent error in a future version. ' +
  3961. stack
  3962. );
  3963. return this.size;
  3964. }
  3965. }
  3966. }
  3967. });
  3968. } catch (e) {}
  3969. })();
  3970. mixin(KeyedIterable, {
  3971. // ### More sequential methods
  3972. flip: function() {
  3973. return reify(this, flipFactory(this));
  3974. },
  3975. findKey: function(predicate, context) {
  3976. var entry = this.findEntry(predicate, context);
  3977. return entry && entry[0];
  3978. },
  3979. findLastKey: function(predicate, context) {
  3980. return this.toSeq().reverse().findKey(predicate, context);
  3981. },
  3982. keyOf: function(searchValue) {
  3983. return this.findKey(function(value ) {return is(value, searchValue)});
  3984. },
  3985. lastKeyOf: function(searchValue) {
  3986. return this.findLastKey(function(value ) {return is(value, searchValue)});
  3987. },
  3988. mapEntries: function(mapper, context) {var this$0 = this;
  3989. var iterations = 0;
  3990. return reify(this,
  3991. this.toSeq().map(
  3992. function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
  3993. ).fromEntrySeq()
  3994. );
  3995. },
  3996. mapKeys: function(mapper, context) {var this$0 = this;
  3997. return reify(this,
  3998. this.toSeq().flip().map(
  3999. function(k, v) {return mapper.call(context, k, v, this$0)}
  4000. ).flip()
  4001. );
  4002. }
  4003. });
  4004. var KeyedIterablePrototype = KeyedIterable.prototype;
  4005. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  4006. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  4007. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  4008. KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
  4009. mixin(IndexedIterable, {
  4010. // ### Conversion to other types
  4011. toKeyedSeq: function() {
  4012. return new ToKeyedSequence(this, false);
  4013. },
  4014. // ### ES6 Collection methods (ES6 Array and Map)
  4015. filter: function(predicate, context) {
  4016. return reify(this, filterFactory(this, predicate, context, false));
  4017. },
  4018. findIndex: function(predicate, context) {
  4019. var entry = this.findEntry(predicate, context);
  4020. return entry ? entry[0] : -1;
  4021. },
  4022. indexOf: function(searchValue) {
  4023. var key = this.toKeyedSeq().keyOf(searchValue);
  4024. return key === undefined ? -1 : key;
  4025. },
  4026. lastIndexOf: function(searchValue) {
  4027. var key = this.toKeyedSeq().reverse().keyOf(searchValue);
  4028. return key === undefined ? -1 : key;
  4029. // var index =
  4030. // return this.toSeq().reverse().indexOf(searchValue);
  4031. },
  4032. reverse: function() {
  4033. return reify(this, reverseFactory(this, false));
  4034. },
  4035. slice: function(begin, end) {
  4036. return reify(this, sliceFactory(this, begin, end, false));
  4037. },
  4038. splice: function(index, removeNum /*, ...values*/) {
  4039. var numArgs = arguments.length;
  4040. removeNum = Math.max(removeNum | 0, 0);
  4041. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  4042. return this;
  4043. }
  4044. // If index is negative, it should resolve relative to the size of the
  4045. // collection. However size may be expensive to compute if not cached, so
  4046. // only call count() if the number is in fact negative.
  4047. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  4048. var spliced = this.slice(0, index);
  4049. return reify(
  4050. this,
  4051. numArgs === 1 ?
  4052. spliced :
  4053. spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  4054. );
  4055. },
  4056. // ### More collection methods
  4057. findLastIndex: function(predicate, context) {
  4058. var key = this.toKeyedSeq().findLastKey(predicate, context);
  4059. return key === undefined ? -1 : key;
  4060. },
  4061. first: function() {
  4062. return this.get(0);
  4063. },
  4064. flatten: function(depth) {
  4065. return reify(this, flattenFactory(this, depth, false));
  4066. },
  4067. get: function(index, notSetValue) {
  4068. index = wrapIndex(this, index);
  4069. return (index < 0 || (this.size === Infinity ||
  4070. (this.size !== undefined && index > this.size))) ?
  4071. notSetValue :
  4072. this.find(function(_, key) {return key === index}, undefined, notSetValue);
  4073. },
  4074. has: function(index) {
  4075. index = wrapIndex(this, index);
  4076. return index >= 0 && (this.size !== undefined ?
  4077. this.size === Infinity || index < this.size :
  4078. this.indexOf(index) !== -1
  4079. );
  4080. },
  4081. interpose: function(separator) {
  4082. return reify(this, interposeFactory(this, separator));
  4083. },
  4084. interleave: function(/*...iterables*/) {
  4085. var iterables = [this].concat(arrCopy(arguments));
  4086. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  4087. var interleaved = zipped.flatten(true);
  4088. if (zipped.size) {
  4089. interleaved.size = zipped.size * iterables.length;
  4090. }
  4091. return reify(this, interleaved);
  4092. },
  4093. last: function() {
  4094. return this.get(-1);
  4095. },
  4096. skipWhile: function(predicate, context) {
  4097. return reify(this, skipWhileFactory(this, predicate, context, false));
  4098. },
  4099. zip: function(/*, ...iterables */) {
  4100. var iterables = [this].concat(arrCopy(arguments));
  4101. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  4102. },
  4103. zipWith: function(zipper/*, ...iterables */) {
  4104. var iterables = arrCopy(arguments);
  4105. iterables[0] = this;
  4106. return reify(this, zipWithFactory(this, zipper, iterables));
  4107. }
  4108. });
  4109. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  4110. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  4111. mixin(SetIterable, {
  4112. // ### ES6 Collection methods (ES6 Array and Map)
  4113. get: function(value, notSetValue) {
  4114. return this.has(value) ? value : notSetValue;
  4115. },
  4116. includes: function(value) {
  4117. return this.has(value);
  4118. },
  4119. // ### More sequential methods
  4120. keySeq: function() {
  4121. return this.valueSeq();
  4122. }
  4123. });
  4124. SetIterable.prototype.has = IterablePrototype.includes;
  4125. // Mixin subclasses
  4126. mixin(KeyedSeq, KeyedIterable.prototype);
  4127. mixin(IndexedSeq, IndexedIterable.prototype);
  4128. mixin(SetSeq, SetIterable.prototype);
  4129. mixin(KeyedCollection, KeyedIterable.prototype);
  4130. mixin(IndexedCollection, IndexedIterable.prototype);
  4131. mixin(SetCollection, SetIterable.prototype);
  4132. // #pragma Helper functions
  4133. function keyMapper(v, k) {
  4134. return k;
  4135. }
  4136. function entryMapper(v, k) {
  4137. return [k, v];
  4138. }
  4139. function not(predicate) {
  4140. return function() {
  4141. return !predicate.apply(this, arguments);
  4142. }
  4143. }
  4144. function neg(predicate) {
  4145. return function() {
  4146. return -predicate.apply(this, arguments);
  4147. }
  4148. }
  4149. function quoteString(value) {
  4150. return typeof value === 'string' ? JSON.stringify(value) : value;
  4151. }
  4152. function defaultZipper() {
  4153. return arrCopy(arguments);
  4154. }
  4155. function defaultNegComparator(a, b) {
  4156. return a < b ? 1 : a > b ? -1 : 0;
  4157. }
  4158. function hashIterable(iterable) {
  4159. if (iterable.size === Infinity) {
  4160. return 0;
  4161. }
  4162. var ordered = isOrdered(iterable);
  4163. var keyed = isKeyed(iterable);
  4164. var h = ordered ? 1 : 0;
  4165. var size = iterable.__iterate(
  4166. keyed ?
  4167. ordered ?
  4168. function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
  4169. function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
  4170. ordered ?
  4171. function(v ) { h = 31 * h + hash(v) | 0; } :
  4172. function(v ) { h = h + hash(v) | 0; }
  4173. );
  4174. return murmurHashOfSize(size, h);
  4175. }
  4176. function murmurHashOfSize(size, h) {
  4177. h = imul(h, 0xCC9E2D51);
  4178. h = imul(h << 15 | h >>> -15, 0x1B873593);
  4179. h = imul(h << 13 | h >>> -13, 5);
  4180. h = (h + 0xE6546B64 | 0) ^ size;
  4181. h = imul(h ^ h >>> 16, 0x85EBCA6B);
  4182. h = imul(h ^ h >>> 13, 0xC2B2AE35);
  4183. h = smi(h ^ h >>> 16);
  4184. return h;
  4185. }
  4186. function hashMerge(a, b) {
  4187. return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
  4188. }
  4189. var Immutable = {
  4190. Iterable: Iterable,
  4191. Seq: Seq,
  4192. Collection: Collection,
  4193. Map: Map,
  4194. OrderedMap: OrderedMap,
  4195. List: List,
  4196. Stack: Stack,
  4197. Set: Set,
  4198. OrderedSet: OrderedSet,
  4199. Record: Record,
  4200. Range: Range,
  4201. Repeat: Repeat,
  4202. is: is,
  4203. fromJS: fromJS
  4204. };
  4205. return Immutable;
  4206. }));
  4207. });
  4208. var draftjsUtils = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4209. !function(e,t){module.exports=t(Draft.Draft,immutable);}("undefined"!=typeof self?self:_commonjsHelpers.commonjsGlobal,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r});},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(t,n){t.exports=e;},function(e,t,n){function r(e){var t=e.getSelection(),n=e.getCurrentContent(),r=t.getStartKey(),o=t.getEndKey(),i=n.getBlockMap();return i.toSeq().skipUntil(function(e,t){return t===r}).takeUntil(function(e,t){return t===o}).concat([[o,i.get(o)]])}function o(e){return r(e).toList()}function i(e){if(e)return o(e).get(0)}function l(e){if(e){var t=i(e),n=e.getCurrentContent(),r=n.getBlockMap().toSeq().toList(),o=0;if(r.forEach(function(e,n){e.get("key")===t.get("key")&&(o=n-1);}),o>-1)return r.get(o)}}function c(e){return e?e.getCurrentContent().getBlockMap().toList():new v.List}function a(e){var t=o(e);if(!t.some(function(e){return e.type!==t.get(0).type}))return t.get(0).type}function f(e){var t=p.RichUtils.tryToRemoveBlockStyle(e);return t?p.EditorState.push(e,t,"change-block-type"):e}function u(e){var t="",n=e.getSelection(),r=n.getAnchorOffset(),i=n.getFocusOffset(),l=o(e);if(l.size>0){if(n.getIsBackward()){var c=r;r=i,i=c;}for(var a=0;a<l.size;a+=1){var f=0===a?r:0,u=a===l.size-1?i:l.get(a).getText().length;t+=l.get(a).getText().slice(f,u);}}return t}function s(e){var t=e.getCurrentContent(),n=e.getSelection(),r=p.Modifier.removeRange(t,n,"forward"),o=r.getSelectionAfter(),i=r.getBlockForKey(o.getStartKey());return r=p.Modifier.insertText(r,o,"\n",i.getInlineStyleAt(o.getStartOffset()),null),p.EditorState.push(e,r,"insert-fragment")}function g(e){var t=p.Modifier.splitBlock(e.getCurrentContent(),e.getSelection());return f(p.EditorState.push(e,t,"split-block"))}function d(e){var t=e.getCurrentContent().getBlockMap().toList(),n=e.getSelection().merge({anchorKey:t.first().get("key"),anchorOffset:0,focusKey:t.last().get("key"),focusOffset:t.last().getLength()}),r=p.Modifier.removeRange(e.getCurrentContent(),n,"forward");return p.EditorState.push(e,r,"remove-range")}function S(e,t){var n=p.Modifier.setBlockData(e.getCurrentContent(),e.getSelection(),t);return p.EditorState.push(e,n,"change-block-data")}function y(e){var t=new v.Map({}),n=o(e);if(n&&n.size>0)for(var r=0;r<n.size;r+=1){var i=function(e){var r=n.get(e).getData();if(!r||0===r.size)return t=t.clear(),"break";if(0===e)t=r;else if(t.forEach(function(e,n){r.get(n)&&r.get(n)===e||(t=t.delete(n));}),0===t.size)return t=t.clear(),"break"}(r);if("break"===i)break}return t}Object.defineProperty(t,"__esModule",{value:!0}),t.blockRenderMap=void 0,t.getSelectedBlocksMap=r,t.getSelectedBlocksList=o,t.getSelectedBlock=i,t.getBlockBeforeSelectedBlock=l,t.getAllBlocks=c,t.getSelectedBlocksType=a,t.removeSelectedBlocksStyle=f,t.getSelectionText=u,t.addLineBreakRemovingSelection=s,t.insertNewUnstyledBlock=g,t.clearEditorContent=d,t.setBlockData=S,t.getSelectedBlocksMetadata=y;var p=n(0),v=n(6),k=(0, v.Map)({code:{element:"pre"}});t.blockRenderMap=p.DefaultDraftBlockRenderMap.merge(k);},function(e,t,n){function r(e){if(e){var t=e.getType();return "unordered-list-item"===t||"ordered-list-item"===t}return !1}function o(e,t,n){var r=e.getSelection(),o=e.getCurrentContent(),i=o.getBlockMap(),l=(0, c.getSelectedBlocksMap)(e).map(function(e){var r=e.getDepth()+t;return r=Math.max(0,Math.min(r,n)),e.set("depth",r)});return i=i.merge(l),o.merge({blockMap:i,selectionBefore:r,selectionAfter:r})}function i(e,t,n){var r=e.getSelection(),i=void 0;i=r.getIsBackward()?r.getFocusKey():r.getAnchorKey();var c=e.getCurrentContent(),a=c.getBlockForKey(i),f=a.getType();if("unordered-list-item"!==f&&"ordered-list-item"!==f)return e;var u=c.getBlockBefore(i);if(!u)return e;if(u.getType()!==f)return e;var s=a.getDepth();if(1===t&&s===n)return e;var g=Math.min(u.getDepth()+1,n),d=o(e,t,g);return l.EditorState.push(e,d,"adjust-depth")}Object.defineProperty(t,"__esModule",{value:!0}),t.isListBlock=r,t.changeDepth=i;var l=n(0),c=n(1);},function(e,t,n){e.exports=n(4);},function(e,t,n){var r=n(5),o=n(1),i=n(7),l=function(e){return e&&e.__esModule?e:{default:e}}(i),c=n(2);e.exports={getSelectedBlocksMap:o.getSelectedBlocksMap,getSelectedBlocksList:o.getSelectedBlocksList,getSelectedBlock:o.getSelectedBlock,getBlockBeforeSelectedBlock:o.getBlockBeforeSelectedBlock,getAllBlocks:o.getAllBlocks,getSelectedBlocksType:o.getSelectedBlocksType,removeSelectedBlocksStyle:o.removeSelectedBlocksStyle,getSelectionText:o.getSelectionText,addLineBreakRemovingSelection:o.addLineBreakRemovingSelection,insertNewUnstyledBlock:o.insertNewUnstyledBlock,clearEditorContent:o.clearEditorContent,setBlockData:o.setBlockData,getSelectedBlocksMetadata:o.getSelectedBlocksMetadata,blockRenderMap:o.blockRenderMap,getEntityRange:r.getEntityRange,getCustomStyleMap:r.getCustomStyleMap,toggleCustomInlineStyle:r.toggleCustomInlineStyle,getSelectionEntity:r.getSelectionEntity,extractInlineStyle:r.extractInlineStyle,removeAllInlineStyles:r.removeAllInlineStyles,getSelectionInlineStyle:r.getSelectionInlineStyle,getSelectionCustomInlineStyle:r.getSelectionCustomInlineStyle,handleNewLine:l.default,isListBlock:c.isListBlock,changeDepth:c.changeDepth};},function(e,t,n){function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){var t=e.getSelection();if(t.isCollapsed()){var n={},r=e.getCurrentInlineStyle().toList().toJS();if(r)return ["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(e){n[e]=r.indexOf(e)>=0;}),n}var o=t.getStartOffset(),i=t.getEndOffset(),l=(0, p.getSelectedBlocksList)(e);if(l.size>0){var c=function(){for(var e={BOLD:!0,ITALIC:!0,UNDERLINE:!0,STRIKETHROUGH:!0,CODE:!0,SUPERSCRIPT:!0,SUBSCRIPT:!0},t=0;t<l.size;t+=1){var n=0===t?o:0,r=t===l.size-1?i:l.get(t).getText().length;n===r&&0===n?(n=1,r=2):n===r&&(n-=1);for(var c=n;c<r;c+=1)!function(n){var r=l.get(t).getInlineStyleAt(n);["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){e[t]=e[t]&&r.get(t)===t;});}(c);}return {v:e}}();if("object"===(void 0===c?"undefined":S(c)))return c.v}return {}}function i(e){var t=void 0,n=e.getSelection(),r=n.getStartOffset(),o=n.getEndOffset();r===o&&0===r?o=1:r===o&&(r-=1);for(var i=(0, p.getSelectedBlock)(e),l=r;l<o;l+=1){var c=i.getEntityAt(l);if(!c){t=void 0;break}if(l===r)t=c;else if(t!==c){t=void 0;break}}return t}function l(e,t){var n=(0, p.getSelectedBlock)(e),r=void 0;return n.findEntityRanges(function(e){return e.get("entity")===t},function(e,t){r={start:e,end:t,text:n.get("text").slice(e,t)};}),r}function c(e,t,n){var r=e.getSelection(),o=Object.keys(v[t]).reduce(function(e,t){return y.Modifier.removeInlineStyle(e,r,t)},e.getCurrentContent()),i=y.EditorState.push(e,o,"changeinline-style"),l=e.getCurrentInlineStyle();if(r.isCollapsed()&&(i=l.reduce(function(e,t){return y.RichUtils.toggleInlineStyle(e,t)},i)),"SUPERSCRIPT"===t||"SUBSCRIPT"==t)l.has(n)||(i=y.RichUtils.toggleInlineStyle(i,n));else{var c="bgcolor"===t?"backgroundColor":t;l.has(c+"-"+n)||(i=y.RichUtils.toggleInlineStyle(i,t.toLowerCase()+"-"+n),k(t,c,n));}return i}function a(e){if(e){e.getCurrentContent().getBlockMap().map(function(e){return e.get("characterList")}).toList().flatten().forEach(function(e){e&&0===e.indexOf("color-")?k("color","color",e.substr(6)):e&&0===e.indexOf("bgcolor-")?k("bgcolor","backgroundColor",e.substr(8)):e&&0===e.indexOf("fontsize-")?k("fontSize","fontSize",+e.substr(9)):e&&0===e.indexOf("fontfamily-")&&k("fontFamily","fontFamily",e.substr(11));});}}function f(e,t,n){var r=e.getInlineStyleAt(n).toList(),o=r.filter(function(e){return e.startsWith(t.toLowerCase())});if(o&&o.size>0)return o.get(0)}function u(e,t){var n=e.getCurrentInlineStyle().toList(),r=n.filter(function(e){return e.startsWith(t.toLowerCase())});if(r&&r.size>0)return r.get(0)}function s(e,t){if(e&&t&&t.length>0){var n=function(){var n=e.getSelection(),r={};if(n.isCollapsed())return t.forEach(function(t){r[t]=u(e,t);}),{v:r};var o=n.getStartOffset(),i=n.getEndOffset(),l=(0, p.getSelectedBlocksList)(e);if(l.size>0){for(var c=0;c<l.size;c+=1)!function(e){var n=0===e?o:0,c=e===l.size-1?i:l.get(e).getText().length;n===c&&0===n?(n=1,c=2):n===c&&(n-=1);for(var a=n;a<c;a+=1)!function(o){o===n?t.forEach(function(t){r[t]=f(l.get(e),t,o);}):t.forEach(function(t){r[t]&&r[t]!==f(l.get(e),t,o)&&(r[t]=void 0);});}(a);}(c);return {v:r}}}();if("object"===(void 0===n?"undefined":S(n)))return n.v}return {}}function g(e){var t=e.getCurrentInlineStyle(),n=e.getCurrentContent();return t.forEach(function(t){n=y.Modifier.removeInlineStyle(n,e.getSelection(),t);}),y.EditorState.push(e,n,"change-inline-style")}Object.defineProperty(t,"__esModule",{value:!0}),t.getCustomStyleMap=void 0;var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);}return e},S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.getSelectionInlineStyle=o,t.getSelectionEntity=i,t.getEntityRange=l,t.toggleCustomInlineStyle=c,t.extractInlineStyle=a,t.getSelectionCustomInlineStyle=s,t.removeAllInlineStyles=g;var y=n(0),p=n(1),v={color:{},bgcolor:{},fontSize:{},fontFamily:{},CODE:{fontFamily:"monospace",wordWrap:"break-word",background:"#f1f1f1",borderRadius:3,padding:"1px 3px"},SUPERSCRIPT:{fontSize:11,position:"relative",top:-8,display:"inline-flex"},SUBSCRIPT:{fontSize:11,position:"relative",bottom:-8,display:"inline-flex"}},k=function(e,t,n){v[e][e.toLowerCase()+"-"+n]=r({},""+t,n);};t.getCustomStyleMap=function(){return d({},v.color,v.bgcolor,v.fontSize,v.fontFamily,{CODE:v.CODE,SUPERSCRIPT:v.SUPERSCRIPT,SUBSCRIPT:v.SUBSCRIPT})};},function(e,n){e.exports=t;},function(e,t,n){function r(e){var t=e.getSelection();if(t.isCollapsed()){var n=e.getCurrentContent(),r=t.getStartKey(),o=n.getBlockForKey(r);if(!(0, a.isListBlock)(o)&&"unstyled"!==o.getType()&&o.getLength()===t.getStartOffset())return (0, c.insertNewUnstyledBlock)(e);if((0, a.isListBlock)(o)&&0===o.getLength()){var i=o.getDepth();if(0===i)return (0, c.removeSelectedBlocksStyle)(e);if(i>0)return (0, a.changeDepth)(e,-1,i)}}}function o(e){return 13===e.which&&(e.getModifierState("Shift")||e.getModifierState("Alt")||e.getModifierState("Control"))}function i(e,t){if(o(t)){return e.getSelection().isCollapsed()?l.RichUtils.insertSoftNewline(e):(0, c.addLineBreakRemovingSelection)(e)}return r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var l=n(0),c=n(1),a=n(2);}])});
  4210. });
  4211. _commonjsHelpers.unwrapExports(draftjsUtils);
  4212. var draftjsUtils_1 = draftjsUtils.draftjsUtils;
  4213. var interopRequireDefault = _commonjsHelpers.createCommonjsModule(function (module) {
  4214. function _interopRequireDefault(obj) {
  4215. return obj && obj.__esModule ? obj : {
  4216. "default": obj
  4217. };
  4218. }
  4219. module.exports = _interopRequireDefault;
  4220. });
  4221. _commonjsHelpers.unwrapExports(interopRequireDefault);
  4222. /**
  4223. * Copyright (c) 2013-present, Facebook, Inc.
  4224. *
  4225. * This source code is licensed under the MIT license found in the
  4226. * LICENSE file in the root directory of this source tree.
  4227. */
  4228. /**
  4229. * Use invariant() to assert state which your program assumes to be true.
  4230. *
  4231. * Provide sprintf-style format (only %s is supported) and arguments
  4232. * to provide information about what broke and what you were
  4233. * expecting.
  4234. *
  4235. * The invariant message will be stripped in production, but the invariant
  4236. * will remain to ensure logic does not differ in production.
  4237. */
  4238. var invariant = function(condition, format, a, b, c, d, e, f) {
  4239. if (process.env.NODE_ENV !== 'production') {
  4240. if (format === undefined) {
  4241. throw new Error('invariant requires an error message argument');
  4242. }
  4243. }
  4244. if (!condition) {
  4245. var error;
  4246. if (format === undefined) {
  4247. error = new Error(
  4248. 'Minified exception occurred; use the non-minified dev environment ' +
  4249. 'for the full error message and additional helpful warnings.'
  4250. );
  4251. } else {
  4252. var args = [a, b, c, d, e, f];
  4253. var argIndex = 0;
  4254. error = new Error(
  4255. format.replace(/%s/g, function() { return args[argIndex++]; })
  4256. );
  4257. error.name = 'Invariant Violation';
  4258. }
  4259. error.framesToPop = 1; // we don't care about invariant's own frame
  4260. throw error;
  4261. }
  4262. };
  4263. var browser = invariant;
  4264. function _arrayWithoutHoles(arr) {
  4265. if (Array.isArray(arr)) {
  4266. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  4267. arr2[i] = arr[i];
  4268. }
  4269. return arr2;
  4270. }
  4271. }
  4272. var arrayWithoutHoles = _arrayWithoutHoles;
  4273. function _iterableToArray(iter) {
  4274. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  4275. }
  4276. var iterableToArray = _iterableToArray;
  4277. function _nonIterableSpread() {
  4278. throw new TypeError("Invalid attempt to spread non-iterable instance");
  4279. }
  4280. var nonIterableSpread = _nonIterableSpread;
  4281. function _toConsumableArray(arr) {
  4282. return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
  4283. }
  4284. var toConsumableArray = _toConsumableArray;
  4285. var updateMutation_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4286. Object.defineProperty(exports, "__esModule", {
  4287. value: true
  4288. });
  4289. exports["default"] = updateMutation;
  4290. function updateMutation(mutation, originalOffset, originalLength, newLength, prefixLength, suffixLength) {
  4291. // three cases we can reasonably adjust - disjoint mutations that
  4292. // happen later on where the offset will need to be changed,
  4293. // mutations that completely contain the new one where we can adjust
  4294. // the length, and mutations that occur partially within the new one.
  4295. var lengthDiff = newLength - originalLength;
  4296. var mutationAfterChange = originalOffset + originalLength <= mutation.offset;
  4297. if (mutationAfterChange) {
  4298. return Object.assign({}, mutation, {
  4299. offset: mutation.offset + lengthDiff
  4300. });
  4301. }
  4302. var mutationContainsChange = originalOffset >= mutation.offset && originalOffset + originalLength <= mutation.offset + mutation.length;
  4303. if (mutationContainsChange) {
  4304. return Object.assign({}, mutation, {
  4305. length: mutation.length + lengthDiff
  4306. });
  4307. }
  4308. var mutationWithinPrefixChange = mutation.offset >= originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && prefixLength > 0;
  4309. if (mutationWithinPrefixChange) {
  4310. return Object.assign({}, mutation, {
  4311. offset: mutation.offset + prefixLength
  4312. });
  4313. }
  4314. var mutationContainsPrefix = mutation.offset < originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && mutation.offset + mutation.length > originalOffset && prefixLength > 0;
  4315. if (mutationContainsPrefix) {
  4316. return [Object.assign({}, mutation, {
  4317. length: originalOffset - mutation.offset
  4318. }), Object.assign({}, mutation, {
  4319. offset: originalOffset + prefixLength,
  4320. length: mutation.offset - originalOffset + mutation.length
  4321. })];
  4322. }
  4323. var mutationContainsSuffix = mutation.offset >= originalOffset && mutation.offset + mutation.length > originalOffset + originalLength && originalOffset + originalLength > mutation.offset && suffixLength > 0;
  4324. if (mutationContainsSuffix) {
  4325. return [Object.assign({}, mutation, {
  4326. offset: mutation.offset + prefixLength,
  4327. length: originalOffset + originalLength - mutation.offset
  4328. }), Object.assign({}, mutation, {
  4329. offset: originalOffset + originalLength + prefixLength + suffixLength,
  4330. length: mutation.offset + mutation.length - (originalOffset + originalLength)
  4331. })];
  4332. }
  4333. return mutation;
  4334. }
  4335. });
  4336. _commonjsHelpers.unwrapExports(updateMutation_1);
  4337. var rangeSort = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4338. Object.defineProperty(exports, "__esModule", {
  4339. value: true
  4340. });
  4341. exports["default"] = void 0;
  4342. var _default = function _default(r1, r2) {
  4343. if (r1.offset === r2.offset) {
  4344. return r2.length - r1.length;
  4345. }
  4346. return r1.offset - r2.offset;
  4347. };
  4348. exports["default"] = _default;
  4349. });
  4350. _commonjsHelpers.unwrapExports(rangeSort);
  4351. var encodeBlock = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4352. Object.defineProperty(exports, "__esModule", {
  4353. value: true
  4354. });
  4355. exports["default"] = void 0;
  4356. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  4357. var _updateMutation = interopRequireDefault(updateMutation_1);
  4358. var _rangeSort = interopRequireDefault(rangeSort);
  4359. var ENTITY_MAP = {
  4360. '&': '&amp;',
  4361. '<': '&lt;',
  4362. '>': '&gt;',
  4363. '"': '&quot;',
  4364. "'": '&#x27;',
  4365. '`': '&#x60;',
  4366. '\n': '<br/>'
  4367. };
  4368. var _default = function _default(block) {
  4369. var blockText = (0, _toConsumableArray2["default"])(block.text);
  4370. var entities = block.entityRanges.sort(_rangeSort["default"]);
  4371. var styles = block.inlineStyleRanges.sort(_rangeSort["default"]);
  4372. var resultText = '';
  4373. var _loop = function _loop(index) {
  4374. var _char = blockText[index];
  4375. if (ENTITY_MAP[_char] !== undefined) {
  4376. var encoded = ENTITY_MAP[_char];
  4377. var resultIndex = (0, _toConsumableArray2["default"])(resultText).length;
  4378. resultText += encoded;
  4379. var updateForChar = function updateForChar(mutation) {
  4380. return (0, _updateMutation["default"])(mutation, resultIndex, _char.length, encoded.length, 0, 0);
  4381. };
  4382. entities = entities.map(updateForChar);
  4383. styles = styles.map(updateForChar);
  4384. } else {
  4385. resultText += _char;
  4386. }
  4387. };
  4388. for (var index = 0; index < blockText.length; index++) {
  4389. _loop(index);
  4390. }
  4391. return Object.assign({}, block, {
  4392. text: resultText,
  4393. inlineStyleRanges: styles,
  4394. entityRanges: entities
  4395. });
  4396. };
  4397. exports["default"] = _default;
  4398. });
  4399. _commonjsHelpers.unwrapExports(encodeBlock);
  4400. var _typeof_1 = _commonjsHelpers.createCommonjsModule(function (module) {
  4401. function _typeof(obj) {
  4402. "@babel/helpers - typeof";
  4403. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  4404. module.exports = _typeof = function _typeof(obj) {
  4405. return typeof obj;
  4406. };
  4407. } else {
  4408. module.exports = _typeof = function _typeof(obj) {
  4409. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  4410. };
  4411. }
  4412. return _typeof(obj);
  4413. }
  4414. module.exports = _typeof;
  4415. });
  4416. var splitReactElement_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4417. Object.defineProperty(exports, "__esModule", {
  4418. value: true
  4419. });
  4420. exports["default"] = splitReactElement;
  4421. var _invariant = interopRequireDefault(browser);
  4422. var _react = interopRequireDefault(React__default);
  4423. var _server = interopRequireDefault(server);
  4424. // see http://w3c.github.io/html/syntax.html#writing-html-documents-elements
  4425. var VOID_TAGS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
  4426. function splitReactElement(element) {
  4427. if (VOID_TAGS.indexOf(element.type) !== -1) {
  4428. return _server["default"].renderToStaticMarkup(element);
  4429. }
  4430. var tags = _server["default"].renderToStaticMarkup(_react["default"].cloneElement(element, {}, '\r')).split('\r');
  4431. (0, _invariant["default"])(tags.length > 1, "convertToHTML: Element of type ".concat(element.type, " must render children"));
  4432. (0, _invariant["default"])(tags.length < 3, "convertToHTML: Element of type ".concat(element.type, " cannot use carriage return character"));
  4433. return {
  4434. start: tags[0],
  4435. end: tags[1]
  4436. };
  4437. }
  4438. });
  4439. _commonjsHelpers.unwrapExports(splitReactElement_1);
  4440. var getElementHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4441. Object.defineProperty(exports, "__esModule", {
  4442. value: true
  4443. });
  4444. exports["default"] = getElementHTML;
  4445. var _typeof2 = interopRequireDefault(_typeof_1);
  4446. var _invariant = interopRequireDefault(browser);
  4447. var _react = interopRequireDefault(React__default);
  4448. var _server = interopRequireDefault(server);
  4449. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  4450. function hasChildren(element) {
  4451. return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
  4452. }
  4453. function getElementHTML(element) {
  4454. var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4455. if (element === undefined || element === null) {
  4456. return element;
  4457. }
  4458. if (typeof element === 'string') {
  4459. return element;
  4460. }
  4461. if (_react["default"].isValidElement(element)) {
  4462. if (hasChildren(element)) {
  4463. return _server["default"].renderToStaticMarkup(element);
  4464. }
  4465. var tags = (0, _splitReactElement["default"])(element);
  4466. if (text !== null && (0, _typeof2["default"])(tags) === 'object') {
  4467. var start = tags.start,
  4468. end = tags.end;
  4469. return start + text + end;
  4470. }
  4471. return tags;
  4472. }
  4473. (0, _invariant["default"])(Object.prototype.hasOwnProperty.call(element, 'start') && Object.prototype.hasOwnProperty.call(element, 'end'), 'convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags');
  4474. if (text !== null) {
  4475. var _start = element.start,
  4476. _end = element.end;
  4477. return _start + text + _end;
  4478. }
  4479. return element;
  4480. }
  4481. });
  4482. _commonjsHelpers.unwrapExports(getElementHTML_1);
  4483. var getElementTagLength_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4484. Object.defineProperty(exports, "__esModule", {
  4485. value: true
  4486. });
  4487. exports["default"] = void 0;
  4488. var _typeof2 = interopRequireDefault(_typeof_1);
  4489. var _react = interopRequireDefault(React__default);
  4490. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  4491. var getElementTagLength = function getElementTagLength(element) {
  4492. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'start';
  4493. if (_react["default"].isValidElement(element)) {
  4494. var splitElement = (0, _splitReactElement["default"])(element);
  4495. if (typeof splitElement === 'string') {
  4496. return 0;
  4497. }
  4498. var length = splitElement[type].length;
  4499. var child = _react["default"].Children.toArray(element.props.children)[0];
  4500. return length + (child && _react["default"].isValidElement(child) ? getElementTagLength(child, type) : 0);
  4501. }
  4502. if ((0, _typeof2["default"])(element) === 'object') {
  4503. return element[type] ? element[type].length : 0;
  4504. }
  4505. return 0;
  4506. };
  4507. var _default = getElementTagLength;
  4508. exports["default"] = _default;
  4509. });
  4510. _commonjsHelpers.unwrapExports(getElementTagLength_1);
  4511. var blockEntities = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4512. Object.defineProperty(exports, "__esModule", {
  4513. value: true
  4514. });
  4515. exports["default"] = void 0;
  4516. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  4517. var _updateMutation = interopRequireDefault(updateMutation_1);
  4518. var _rangeSort = interopRequireDefault(rangeSort);
  4519. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  4520. var _getElementTagLength = interopRequireDefault(getElementTagLength_1);
  4521. var converter = function converter() {
  4522. var originalText = arguments.length > 1 ? arguments[1] : undefined;
  4523. return originalText;
  4524. };
  4525. var _default = function _default(block, entityMap) {
  4526. var entityConverter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : converter;
  4527. var resultText = (0, _toConsumableArray2["default"])(block.text);
  4528. var getEntityHTML = entityConverter;
  4529. if (entityConverter.__isMiddleware) {
  4530. getEntityHTML = entityConverter(converter);
  4531. }
  4532. if (Object.prototype.hasOwnProperty.call(block, 'entityRanges') && block.entityRanges.length > 0) {
  4533. var entities = block.entityRanges.sort(_rangeSort["default"]);
  4534. var styles = block.inlineStyleRanges;
  4535. var _loop = function _loop(index) {
  4536. var entityRange = entities[index];
  4537. var entity = entityMap[entityRange.key];
  4538. var originalText = resultText.slice(entityRange.offset, entityRange.offset + entityRange.length).join('');
  4539. var entityHTML = getEntityHTML(entity, originalText);
  4540. var converted = (0, _toConsumableArray2["default"])((0, _getElementHTML["default"])(entityHTML, originalText) || originalText);
  4541. var prefixLength = (0, _getElementTagLength["default"])(entityHTML, 'start');
  4542. var suffixLength = (0, _getElementTagLength["default"])(entityHTML, 'end');
  4543. var updateLaterMutation = function updateLaterMutation(mutation, mutationIndex) {
  4544. if (mutationIndex > index || Object.prototype.hasOwnProperty.call(mutation, 'style')) {
  4545. return (0, _updateMutation["default"])(mutation, entityRange.offset, entityRange.length, converted.length, prefixLength, suffixLength);
  4546. }
  4547. return mutation;
  4548. };
  4549. var updateLaterMutations = function updateLaterMutations(mutationList) {
  4550. return mutationList.reduce(function (acc, mutation, mutationIndex) {
  4551. var updatedMutation = updateLaterMutation(mutation, mutationIndex);
  4552. if (Array.isArray(updatedMutation)) {
  4553. return acc.concat(updatedMutation);
  4554. }
  4555. return acc.concat([updatedMutation]);
  4556. }, []);
  4557. };
  4558. entities = updateLaterMutations(entities);
  4559. styles = updateLaterMutations(styles);
  4560. resultText = [].concat((0, _toConsumableArray2["default"])(resultText.slice(0, entityRange.offset)), (0, _toConsumableArray2["default"])(converted), (0, _toConsumableArray2["default"])(resultText.slice(entityRange.offset + entityRange.length)));
  4561. };
  4562. for (var index = 0; index < entities.length; index++) {
  4563. _loop(index);
  4564. }
  4565. return Object.assign({}, block, {
  4566. text: resultText.join(''),
  4567. inlineStyleRanges: styles,
  4568. entityRanges: entities
  4569. });
  4570. }
  4571. return block;
  4572. };
  4573. exports["default"] = _default;
  4574. });
  4575. _commonjsHelpers.unwrapExports(blockEntities);
  4576. var styleObjectFunction = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4577. Object.defineProperty(exports, "__esModule", {
  4578. value: true
  4579. });
  4580. exports["default"] = void 0;
  4581. var _default = function _default(object) {
  4582. return function (style) {
  4583. if (typeof object === 'function') {
  4584. return object(style);
  4585. }
  4586. return object[style];
  4587. };
  4588. };
  4589. exports["default"] = _default;
  4590. });
  4591. _commonjsHelpers.unwrapExports(styleObjectFunction);
  4592. var accumulateFunction = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4593. Object.defineProperty(exports, "__esModule", {
  4594. value: true
  4595. });
  4596. exports["default"] = void 0;
  4597. var _default = function _default(newFn, rest) {
  4598. return function () {
  4599. var newResult = newFn.apply(void 0, arguments);
  4600. if (newResult !== undefined && newResult !== null) {
  4601. return newResult;
  4602. }
  4603. return rest.apply(void 0, arguments);
  4604. };
  4605. };
  4606. exports["default"] = _default;
  4607. });
  4608. _commonjsHelpers.unwrapExports(accumulateFunction);
  4609. var defaultInlineHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4610. Object.defineProperty(exports, "__esModule", {
  4611. value: true
  4612. });
  4613. exports["default"] = defaultInlineHTML;
  4614. var _react = interopRequireDefault(React__default);
  4615. function defaultInlineHTML(style) {
  4616. switch (style) {
  4617. case 'BOLD':
  4618. return _react["default"].createElement("strong", null);
  4619. case 'ITALIC':
  4620. return _react["default"].createElement("em", null);
  4621. case 'UNDERLINE':
  4622. return _react["default"].createElement("u", null);
  4623. case 'CODE':
  4624. return _react["default"].createElement("code", null);
  4625. default:
  4626. return {
  4627. start: '',
  4628. end: ''
  4629. };
  4630. }
  4631. }
  4632. });
  4633. _commonjsHelpers.unwrapExports(defaultInlineHTML_1);
  4634. var blockInlineStyles = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4635. Object.defineProperty(exports, "__esModule", {
  4636. value: true
  4637. });
  4638. exports["default"] = void 0;
  4639. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  4640. var _invariant = interopRequireDefault(browser);
  4641. var _styleObjectFunction = interopRequireDefault(styleObjectFunction);
  4642. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  4643. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  4644. var _rangeSort = interopRequireDefault(rangeSort);
  4645. var _defaultInlineHTML = interopRequireDefault(defaultInlineHTML_1);
  4646. var subtractStyles = function subtractStyles(original, toRemove) {
  4647. return original.filter(function (el) {
  4648. return !toRemove.some(function (elToRemove) {
  4649. return elToRemove.style === el.style;
  4650. });
  4651. });
  4652. };
  4653. var popEndingStyles = function popEndingStyles(styleStack, endingStyles) {
  4654. return endingStyles.reduceRight(function (stack, style) {
  4655. var styleToRemove = stack[stack.length - 1];
  4656. (0, _invariant["default"])(styleToRemove.style === style.style, "Style ".concat(styleToRemove.style, " to be removed doesn't match expected ").concat(style.style));
  4657. return stack.slice(0, -1);
  4658. }, styleStack);
  4659. };
  4660. var characterStyles = function characterStyles(offset, ranges) {
  4661. return ranges.filter(function (range) {
  4662. return offset >= range.offset && offset < range.offset + range.length;
  4663. });
  4664. };
  4665. var rangeIsSubset = function rangeIsSubset(firstRange, secondRange) {
  4666. // returns true if the second range is a subset of the first
  4667. var secondStartWithinFirst = firstRange.offset <= secondRange.offset;
  4668. var secondEndWithinFirst = firstRange.offset + firstRange.length >= secondRange.offset + secondRange.length;
  4669. return secondStartWithinFirst && secondEndWithinFirst;
  4670. };
  4671. var latestStyleLast = function latestStyleLast(s1, s2) {
  4672. // make sure longer-lasting styles are added first
  4673. var s2endIndex = s2.offset + s2.length;
  4674. var s1endIndex = s1.offset + s1.length;
  4675. return s2endIndex - s1endIndex;
  4676. };
  4677. var getStylesToReset = function getStylesToReset(remainingStyles, newStyles) {
  4678. var i = 0;
  4679. while (i < remainingStyles.length) {
  4680. if (newStyles.every(rangeIsSubset.bind(null, remainingStyles[i]))) {
  4681. i++;
  4682. } else {
  4683. return remainingStyles.slice(i);
  4684. }
  4685. }
  4686. return [];
  4687. };
  4688. var appendStartMarkup = function appendStartMarkup(inlineHTML, string, styleRange) {
  4689. return string + (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).start;
  4690. };
  4691. var prependEndMarkup = function prependEndMarkup(inlineHTML, string, styleRange) {
  4692. return (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).end + string;
  4693. };
  4694. var defaultCustomInlineHTML = function defaultCustomInlineHTML(next) {
  4695. return function (style) {
  4696. return next(style);
  4697. };
  4698. };
  4699. defaultCustomInlineHTML.__isMiddleware = true;
  4700. var _default = function _default(rawBlock) {
  4701. var customInlineHTML = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCustomInlineHTML;
  4702. (0, _invariant["default"])(rawBlock !== null && rawBlock !== undefined, 'Expected raw block to be non-null');
  4703. var inlineHTML;
  4704. if (customInlineHTML.__isMiddleware === true) {
  4705. inlineHTML = customInlineHTML(_defaultInlineHTML["default"]);
  4706. } else {
  4707. inlineHTML = (0, _accumulateFunction["default"])((0, _styleObjectFunction["default"])(customInlineHTML), (0, _styleObjectFunction["default"])(_defaultInlineHTML["default"]));
  4708. }
  4709. var result = '';
  4710. var styleStack = [];
  4711. var sortedRanges = rawBlock.inlineStyleRanges.sort(_rangeSort["default"]);
  4712. var originalTextArray = (0, _toConsumableArray2["default"])(rawBlock.text);
  4713. for (var i = 0; i < originalTextArray.length; i++) {
  4714. var styles = characterStyles(i, sortedRanges);
  4715. var endingStyles = subtractStyles(styleStack, styles);
  4716. var newStyles = subtractStyles(styles, styleStack);
  4717. var remainingStyles = subtractStyles(styleStack, endingStyles); // reset styles: look for any already existing styles that will need to
  4718. // end before styles that are being added on this character. to solve this
  4719. // close out those current tags and all nested children,
  4720. // then open new ones nested within the new styles.
  4721. var resetStyles = getStylesToReset(remainingStyles, newStyles);
  4722. var openingStyles = resetStyles.concat(newStyles).sort(latestStyleLast);
  4723. var openingStyleTags = openingStyles.reduce(appendStartMarkup.bind(null, inlineHTML), '');
  4724. var endingStyleTags = endingStyles.concat(resetStyles).reduce(prependEndMarkup.bind(null, inlineHTML), '');
  4725. result += endingStyleTags + openingStyleTags + originalTextArray[i];
  4726. styleStack = popEndingStyles(styleStack, resetStyles.concat(endingStyles));
  4727. styleStack = styleStack.concat(openingStyles);
  4728. (0, _invariant["default"])(styleStack.length === styles.length, "Character ".concat(i, ": ").concat(styleStack.length - styles.length, " styles left on stack that should no longer be there"));
  4729. }
  4730. result = styleStack.reduceRight(function (res, openStyle) {
  4731. return res + (0, _getElementHTML["default"])(inlineHTML(openStyle.style)).end;
  4732. }, result);
  4733. return result;
  4734. };
  4735. exports["default"] = _default;
  4736. });
  4737. _commonjsHelpers.unwrapExports(blockInlineStyles);
  4738. var blockTypeObjectFunction = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4739. Object.defineProperty(exports, "__esModule", {
  4740. value: true
  4741. });
  4742. exports["default"] = void 0;
  4743. var _default = function _default(typeObject) {
  4744. return function (block) {
  4745. if (typeof typeObject === 'function') {
  4746. // handle case where typeObject is already a function
  4747. return typeObject(block);
  4748. }
  4749. return typeObject[block.type];
  4750. };
  4751. };
  4752. exports["default"] = _default;
  4753. });
  4754. _commonjsHelpers.unwrapExports(blockTypeObjectFunction);
  4755. var getBlockTags_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4756. Object.defineProperty(exports, "__esModule", {
  4757. value: true
  4758. });
  4759. exports["default"] = getBlockTags;
  4760. var _invariant = interopRequireDefault(browser);
  4761. var _react = interopRequireDefault(React__default);
  4762. var _server = interopRequireDefault(server);
  4763. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  4764. function hasChildren(element) {
  4765. return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
  4766. }
  4767. function getBlockTags(blockHTML) {
  4768. (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
  4769. if (typeof blockHTML === 'string') {
  4770. return blockHTML;
  4771. }
  4772. if (_react["default"].isValidElement(blockHTML)) {
  4773. if (hasChildren(blockHTML)) {
  4774. return _server["default"].renderToStaticMarkup(blockHTML);
  4775. }
  4776. return (0, _splitReactElement["default"])(blockHTML);
  4777. }
  4778. if (Object.prototype.hasOwnProperty.call(blockHTML, 'element') && _react["default"].isValidElement(blockHTML.element)) {
  4779. return Object.assign({}, blockHTML, (0, _splitReactElement["default"])(blockHTML.element));
  4780. }
  4781. (0, _invariant["default"])(Object.prototype.hasOwnProperty.call(blockHTML, 'start') && Object.prototype.hasOwnProperty.call(blockHTML, 'end'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
  4782. return blockHTML;
  4783. }
  4784. });
  4785. _commonjsHelpers.unwrapExports(getBlockTags_1);
  4786. var getNestedBlockTags_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4787. Object.defineProperty(exports, "__esModule", {
  4788. value: true
  4789. });
  4790. exports["default"] = getNestedBlockTags;
  4791. var _invariant = interopRequireDefault(browser);
  4792. var _react = interopRequireDefault(React__default);
  4793. var _splitReactElement2 = interopRequireDefault(splitReactElement_1);
  4794. function getNestedBlockTags(blockHTML) {
  4795. (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
  4796. if (_react["default"].isValidElement(blockHTML.nest)) {
  4797. var _splitReactElement = (0, _splitReactElement2["default"])(blockHTML.nest),
  4798. start = _splitReactElement.start,
  4799. end = _splitReactElement.end;
  4800. return Object.assign({}, blockHTML, {
  4801. nestStart: start,
  4802. nestEnd: end
  4803. });
  4804. }
  4805. (0, _invariant["default"])(Object.prototype.hasOwnProperty.call(blockHTML, 'nestStart') && Object.prototype.hasOwnProperty.call(blockHTML, 'nestEnd'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
  4806. return blockHTML;
  4807. }
  4808. });
  4809. _commonjsHelpers.unwrapExports(getNestedBlockTags_1);
  4810. var defaultBlockHTML = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4811. Object.defineProperty(exports, "__esModule", {
  4812. value: true
  4813. });
  4814. exports["default"] = void 0;
  4815. var _react = interopRequireDefault(React__default);
  4816. var _default = {
  4817. unstyled: _react["default"].createElement("p", null),
  4818. paragraph: _react["default"].createElement("p", null),
  4819. 'header-one': _react["default"].createElement("h1", null),
  4820. 'header-two': _react["default"].createElement("h2", null),
  4821. 'header-three': _react["default"].createElement("h3", null),
  4822. 'header-four': _react["default"].createElement("h4", null),
  4823. 'header-five': _react["default"].createElement("h5", null),
  4824. 'header-six': _react["default"].createElement("h6", null),
  4825. blockquote: _react["default"].createElement("blockquote", null),
  4826. 'unordered-list-item': {
  4827. element: _react["default"].createElement("li", null),
  4828. nest: _react["default"].createElement("ul", null)
  4829. },
  4830. 'ordered-list-item': {
  4831. element: _react["default"].createElement("li", null),
  4832. nest: _react["default"].createElement("ol", null)
  4833. },
  4834. media: _react["default"].createElement("figure", null),
  4835. atomic: _react["default"].createElement("figure", null)
  4836. };
  4837. exports["default"] = _default;
  4838. });
  4839. _commonjsHelpers.unwrapExports(defaultBlockHTML);
  4840. var convertToHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4841. Object.defineProperty(exports, "__esModule", {
  4842. value: true
  4843. });
  4844. exports["default"] = void 0;
  4845. var _invariant = interopRequireDefault(browser);
  4846. var _react = interopRequireDefault(React__default);
  4847. var _server = interopRequireDefault(server);
  4848. var _encodeBlock = interopRequireDefault(encodeBlock);
  4849. var _blockEntities = interopRequireDefault(blockEntities);
  4850. var _blockInlineStyles = interopRequireDefault(blockInlineStyles);
  4851. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  4852. var _blockTypeObjectFunction = interopRequireDefault(blockTypeObjectFunction);
  4853. var _getBlockTags = interopRequireDefault(getBlockTags_1);
  4854. var _getNestedBlockTags = interopRequireDefault(getNestedBlockTags_1);
  4855. var _defaultBlockHTML = interopRequireDefault(defaultBlockHTML);
  4856. // import Immutable from 'immutable'; // eslint-disable-line no-unused-vars
  4857. var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {
  4858. return originalText;
  4859. };
  4860. var convertToHTML = function convertToHTML(_ref) {
  4861. var _ref$styleToHTML = _ref.styleToHTML,
  4862. styleToHTML = _ref$styleToHTML === void 0 ? {} : _ref$styleToHTML,
  4863. _ref$blockToHTML = _ref.blockToHTML,
  4864. blockToHTML = _ref$blockToHTML === void 0 ? {} : _ref$blockToHTML,
  4865. _ref$entityToHTML = _ref.entityToHTML,
  4866. entityToHTML = _ref$entityToHTML === void 0 ? defaultEntityToHTML : _ref$entityToHTML;
  4867. return function (contentState) {
  4868. (0, _invariant["default"])(contentState !== null && contentState !== undefined, 'Expected contentState to be non-null');
  4869. var getBlockHTML;
  4870. if (blockToHTML.__isMiddleware === true) {
  4871. getBlockHTML = blockToHTML((0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
  4872. } else {
  4873. getBlockHTML = (0, _accumulateFunction["default"])((0, _blockTypeObjectFunction["default"])(blockToHTML), (0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
  4874. }
  4875. var rawState = (0, Draft.Draft.convertToRaw)(contentState);
  4876. var listStack = [];
  4877. var result = rawState.blocks.map(function (block) {
  4878. var type = block.type,
  4879. depth = block.depth;
  4880. var closeNestTags = '';
  4881. var openNestTags = '';
  4882. var blockHTMLResult = getBlockHTML(block);
  4883. if (!blockHTMLResult) {
  4884. throw new Error("convertToHTML: missing HTML definition for block with type ".concat(block.type));
  4885. }
  4886. if (!blockHTMLResult.nest) {
  4887. // this block can't be nested, so reset all nesting if necessary
  4888. closeNestTags = listStack.reduceRight(function (string, nestedBlock) {
  4889. return string + (0, _getNestedBlockTags["default"])(getBlockHTML(nestedBlock)).nestEnd;
  4890. }, '');
  4891. listStack = [];
  4892. } else {
  4893. while (depth + 1 !== listStack.length || type !== listStack[depth].type) {
  4894. if (depth + 1 === listStack.length) {
  4895. // depth is right but doesn't match type
  4896. var blockToClose = listStack[depth];
  4897. closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(blockToClose)).nestEnd;
  4898. openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
  4899. listStack[depth] = block;
  4900. } else if (depth + 1 < listStack.length) {
  4901. var _blockToClose = listStack[listStack.length - 1];
  4902. closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(_blockToClose)).nestEnd;
  4903. listStack = listStack.slice(0, -1);
  4904. } else {
  4905. openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
  4906. listStack.push(block);
  4907. }
  4908. }
  4909. }
  4910. var innerHTML = (0, _blockInlineStyles["default"])((0, _blockEntities["default"])((0, _encodeBlock["default"])(block), rawState.entityMap, entityToHTML), styleToHTML);
  4911. var blockHTML = (0, _getBlockTags["default"])(getBlockHTML(block));
  4912. var html;
  4913. if (typeof blockHTML === 'string') {
  4914. html = blockHTML;
  4915. } else {
  4916. html = blockHTML.start + innerHTML + blockHTML.end;
  4917. }
  4918. if (innerHTML.length === 0 && Object.prototype.hasOwnProperty.call(blockHTML, 'empty')) {
  4919. if (_react["default"].isValidElement(blockHTML.empty)) {
  4920. html = _server["default"].renderToStaticMarkup(blockHTML.empty);
  4921. } else {
  4922. html = blockHTML.empty;
  4923. }
  4924. }
  4925. return closeNestTags + openNestTags + html;
  4926. }).join('');
  4927. result = listStack.reduce(function (res, nestBlock) {
  4928. return res + (0, _getNestedBlockTags["default"])(getBlockHTML(nestBlock)).nestEnd;
  4929. }, result);
  4930. return result;
  4931. };
  4932. };
  4933. var _default = function _default() {
  4934. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  4935. args[_key] = arguments[_key];
  4936. }
  4937. if (args.length === 1 && Object.prototype.hasOwnProperty.call(args[0], '_map') && args[0].getBlockMap != null) {
  4938. // skip higher-order function and use defaults
  4939. return convertToHTML({}).apply(void 0, args);
  4940. }
  4941. return convertToHTML.apply(void 0, args);
  4942. };
  4943. exports["default"] = _default;
  4944. });
  4945. _commonjsHelpers.unwrapExports(convertToHTML_1);
  4946. var immutable$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  4947. /**
  4948. * Copyright (c) 2014-2015, Facebook, Inc.
  4949. * All rights reserved.
  4950. *
  4951. * This source code is licensed under the BSD-style license found in the
  4952. * LICENSE file in the root directory of this source tree. An additional grant
  4953. * of patent rights can be found in the PATENTS file in the same directory.
  4954. */
  4955. (function (global, factory) {
  4956. module.exports = factory() ;
  4957. }(_commonjsHelpers.commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
  4958. function createClass(ctor, superClass) {
  4959. if (superClass) {
  4960. ctor.prototype = Object.create(superClass.prototype);
  4961. }
  4962. ctor.prototype.constructor = ctor;
  4963. }
  4964. function Iterable(value) {
  4965. return isIterable(value) ? value : Seq(value);
  4966. }
  4967. createClass(KeyedIterable, Iterable);
  4968. function KeyedIterable(value) {
  4969. return isKeyed(value) ? value : KeyedSeq(value);
  4970. }
  4971. createClass(IndexedIterable, Iterable);
  4972. function IndexedIterable(value) {
  4973. return isIndexed(value) ? value : IndexedSeq(value);
  4974. }
  4975. createClass(SetIterable, Iterable);
  4976. function SetIterable(value) {
  4977. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  4978. }
  4979. function isIterable(maybeIterable) {
  4980. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  4981. }
  4982. function isKeyed(maybeKeyed) {
  4983. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  4984. }
  4985. function isIndexed(maybeIndexed) {
  4986. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  4987. }
  4988. function isAssociative(maybeAssociative) {
  4989. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  4990. }
  4991. function isOrdered(maybeOrdered) {
  4992. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  4993. }
  4994. Iterable.isIterable = isIterable;
  4995. Iterable.isKeyed = isKeyed;
  4996. Iterable.isIndexed = isIndexed;
  4997. Iterable.isAssociative = isAssociative;
  4998. Iterable.isOrdered = isOrdered;
  4999. Iterable.Keyed = KeyedIterable;
  5000. Iterable.Indexed = IndexedIterable;
  5001. Iterable.Set = SetIterable;
  5002. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  5003. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  5004. var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  5005. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  5006. // Used for setting prototype methods that IE8 chokes on.
  5007. var DELETE = 'delete';
  5008. // Constants describing the size of trie nodes.
  5009. var SHIFT = 5; // Resulted in best performance after ______?
  5010. var SIZE = 1 << SHIFT;
  5011. var MASK = SIZE - 1;
  5012. // A consistent shared value representing "not set" which equals nothing other
  5013. // than itself, and nothing that could be provided externally.
  5014. var NOT_SET = {};
  5015. // Boolean references, Rough equivalent of `bool &`.
  5016. var CHANGE_LENGTH = { value: false };
  5017. var DID_ALTER = { value: false };
  5018. function MakeRef(ref) {
  5019. ref.value = false;
  5020. return ref;
  5021. }
  5022. function SetRef(ref) {
  5023. ref && (ref.value = true);
  5024. }
  5025. // A function which returns a value representing an "owner" for transient writes
  5026. // to tries. The return value will only ever equal itself, and will not equal
  5027. // the return of any subsequent call of this function.
  5028. function OwnerID() {}
  5029. // http://jsperf.com/copy-array-inline
  5030. function arrCopy(arr, offset) {
  5031. offset = offset || 0;
  5032. var len = Math.max(0, arr.length - offset);
  5033. var newArr = new Array(len);
  5034. for (var ii = 0; ii < len; ii++) {
  5035. newArr[ii] = arr[ii + offset];
  5036. }
  5037. return newArr;
  5038. }
  5039. function ensureSize(iter) {
  5040. if (iter.size === undefined) {
  5041. iter.size = iter.__iterate(returnTrue);
  5042. }
  5043. return iter.size;
  5044. }
  5045. function wrapIndex(iter, index) {
  5046. // This implements "is array index" which the ECMAString spec defines as:
  5047. //
  5048. // A String property name P is an array index if and only if
  5049. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  5050. // to 2^32−1.
  5051. //
  5052. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  5053. if (typeof index !== 'number') {
  5054. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  5055. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  5056. return NaN;
  5057. }
  5058. index = uint32Index;
  5059. }
  5060. return index < 0 ? ensureSize(iter) + index : index;
  5061. }
  5062. function returnTrue() {
  5063. return true;
  5064. }
  5065. function wholeSlice(begin, end, size) {
  5066. return (begin === 0 || (size !== undefined && begin <= -size)) &&
  5067. (end === undefined || (size !== undefined && end >= size));
  5068. }
  5069. function resolveBegin(begin, size) {
  5070. return resolveIndex(begin, size, 0);
  5071. }
  5072. function resolveEnd(end, size) {
  5073. return resolveIndex(end, size, size);
  5074. }
  5075. function resolveIndex(index, size, defaultIndex) {
  5076. return index === undefined ?
  5077. defaultIndex :
  5078. index < 0 ?
  5079. Math.max(0, size + index) :
  5080. size === undefined ?
  5081. index :
  5082. Math.min(size, index);
  5083. }
  5084. /* global Symbol */
  5085. var ITERATE_KEYS = 0;
  5086. var ITERATE_VALUES = 1;
  5087. var ITERATE_ENTRIES = 2;
  5088. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  5089. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  5090. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  5091. function Iterator(next) {
  5092. this.next = next;
  5093. }
  5094. Iterator.prototype.toString = function() {
  5095. return '[Iterator]';
  5096. };
  5097. Iterator.KEYS = ITERATE_KEYS;
  5098. Iterator.VALUES = ITERATE_VALUES;
  5099. Iterator.ENTRIES = ITERATE_ENTRIES;
  5100. Iterator.prototype.inspect =
  5101. Iterator.prototype.toSource = function () { return this.toString(); };
  5102. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  5103. return this;
  5104. };
  5105. function iteratorValue(type, k, v, iteratorResult) {
  5106. var value = type === 0 ? k : type === 1 ? v : [k, v];
  5107. iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
  5108. value: value, done: false
  5109. });
  5110. return iteratorResult;
  5111. }
  5112. function iteratorDone() {
  5113. return { value: undefined, done: true };
  5114. }
  5115. function hasIterator(maybeIterable) {
  5116. return !!getIteratorFn(maybeIterable);
  5117. }
  5118. function isIterator(maybeIterator) {
  5119. return maybeIterator && typeof maybeIterator.next === 'function';
  5120. }
  5121. function getIterator(iterable) {
  5122. var iteratorFn = getIteratorFn(iterable);
  5123. return iteratorFn && iteratorFn.call(iterable);
  5124. }
  5125. function getIteratorFn(iterable) {
  5126. var iteratorFn = iterable && (
  5127. (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  5128. iterable[FAUX_ITERATOR_SYMBOL]
  5129. );
  5130. if (typeof iteratorFn === 'function') {
  5131. return iteratorFn;
  5132. }
  5133. }
  5134. function isArrayLike(value) {
  5135. return value && typeof value.length === 'number';
  5136. }
  5137. createClass(Seq, Iterable);
  5138. function Seq(value) {
  5139. return value === null || value === undefined ? emptySequence() :
  5140. isIterable(value) ? value.toSeq() : seqFromValue(value);
  5141. }
  5142. Seq.of = function(/*...values*/) {
  5143. return Seq(arguments);
  5144. };
  5145. Seq.prototype.toSeq = function() {
  5146. return this;
  5147. };
  5148. Seq.prototype.toString = function() {
  5149. return this.__toString('Seq {', '}');
  5150. };
  5151. Seq.prototype.cacheResult = function() {
  5152. if (!this._cache && this.__iterateUncached) {
  5153. this._cache = this.entrySeq().toArray();
  5154. this.size = this._cache.length;
  5155. }
  5156. return this;
  5157. };
  5158. // abstract __iterateUncached(fn, reverse)
  5159. Seq.prototype.__iterate = function(fn, reverse) {
  5160. return seqIterate(this, fn, reverse, true);
  5161. };
  5162. // abstract __iteratorUncached(type, reverse)
  5163. Seq.prototype.__iterator = function(type, reverse) {
  5164. return seqIterator(this, type, reverse, true);
  5165. };
  5166. createClass(KeyedSeq, Seq);
  5167. function KeyedSeq(value) {
  5168. return value === null || value === undefined ?
  5169. emptySequence().toKeyedSeq() :
  5170. isIterable(value) ?
  5171. (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
  5172. keyedSeqFromValue(value);
  5173. }
  5174. KeyedSeq.prototype.toKeyedSeq = function() {
  5175. return this;
  5176. };
  5177. createClass(IndexedSeq, Seq);
  5178. function IndexedSeq(value) {
  5179. return value === null || value === undefined ? emptySequence() :
  5180. !isIterable(value) ? indexedSeqFromValue(value) :
  5181. isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
  5182. }
  5183. IndexedSeq.of = function(/*...values*/) {
  5184. return IndexedSeq(arguments);
  5185. };
  5186. IndexedSeq.prototype.toIndexedSeq = function() {
  5187. return this;
  5188. };
  5189. IndexedSeq.prototype.toString = function() {
  5190. return this.__toString('Seq [', ']');
  5191. };
  5192. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  5193. return seqIterate(this, fn, reverse, false);
  5194. };
  5195. IndexedSeq.prototype.__iterator = function(type, reverse) {
  5196. return seqIterator(this, type, reverse, false);
  5197. };
  5198. createClass(SetSeq, Seq);
  5199. function SetSeq(value) {
  5200. return (
  5201. value === null || value === undefined ? emptySequence() :
  5202. !isIterable(value) ? indexedSeqFromValue(value) :
  5203. isKeyed(value) ? value.entrySeq() : value
  5204. ).toSetSeq();
  5205. }
  5206. SetSeq.of = function(/*...values*/) {
  5207. return SetSeq(arguments);
  5208. };
  5209. SetSeq.prototype.toSetSeq = function() {
  5210. return this;
  5211. };
  5212. Seq.isSeq = isSeq;
  5213. Seq.Keyed = KeyedSeq;
  5214. Seq.Set = SetSeq;
  5215. Seq.Indexed = IndexedSeq;
  5216. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  5217. Seq.prototype[IS_SEQ_SENTINEL] = true;
  5218. createClass(ArraySeq, IndexedSeq);
  5219. function ArraySeq(array) {
  5220. this._array = array;
  5221. this.size = array.length;
  5222. }
  5223. ArraySeq.prototype.get = function(index, notSetValue) {
  5224. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  5225. };
  5226. ArraySeq.prototype.__iterate = function(fn, reverse) {
  5227. var array = this._array;
  5228. var maxIndex = array.length - 1;
  5229. for (var ii = 0; ii <= maxIndex; ii++) {
  5230. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  5231. return ii + 1;
  5232. }
  5233. }
  5234. return ii;
  5235. };
  5236. ArraySeq.prototype.__iterator = function(type, reverse) {
  5237. var array = this._array;
  5238. var maxIndex = array.length - 1;
  5239. var ii = 0;
  5240. return new Iterator(function()
  5241. {return ii > maxIndex ?
  5242. iteratorDone() :
  5243. iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
  5244. );
  5245. };
  5246. createClass(ObjectSeq, KeyedSeq);
  5247. function ObjectSeq(object) {
  5248. var keys = Object.keys(object);
  5249. this._object = object;
  5250. this._keys = keys;
  5251. this.size = keys.length;
  5252. }
  5253. ObjectSeq.prototype.get = function(key, notSetValue) {
  5254. if (notSetValue !== undefined && !this.has(key)) {
  5255. return notSetValue;
  5256. }
  5257. return this._object[key];
  5258. };
  5259. ObjectSeq.prototype.has = function(key) {
  5260. return this._object.hasOwnProperty(key);
  5261. };
  5262. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  5263. var object = this._object;
  5264. var keys = this._keys;
  5265. var maxIndex = keys.length - 1;
  5266. for (var ii = 0; ii <= maxIndex; ii++) {
  5267. var key = keys[reverse ? maxIndex - ii : ii];
  5268. if (fn(object[key], key, this) === false) {
  5269. return ii + 1;
  5270. }
  5271. }
  5272. return ii;
  5273. };
  5274. ObjectSeq.prototype.__iterator = function(type, reverse) {
  5275. var object = this._object;
  5276. var keys = this._keys;
  5277. var maxIndex = keys.length - 1;
  5278. var ii = 0;
  5279. return new Iterator(function() {
  5280. var key = keys[reverse ? maxIndex - ii : ii];
  5281. return ii++ > maxIndex ?
  5282. iteratorDone() :
  5283. iteratorValue(type, key, object[key]);
  5284. });
  5285. };
  5286. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  5287. createClass(IterableSeq, IndexedSeq);
  5288. function IterableSeq(iterable) {
  5289. this._iterable = iterable;
  5290. this.size = iterable.length || iterable.size;
  5291. }
  5292. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  5293. if (reverse) {
  5294. return this.cacheResult().__iterate(fn, reverse);
  5295. }
  5296. var iterable = this._iterable;
  5297. var iterator = getIterator(iterable);
  5298. var iterations = 0;
  5299. if (isIterator(iterator)) {
  5300. var step;
  5301. while (!(step = iterator.next()).done) {
  5302. if (fn(step.value, iterations++, this) === false) {
  5303. break;
  5304. }
  5305. }
  5306. }
  5307. return iterations;
  5308. };
  5309. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  5310. if (reverse) {
  5311. return this.cacheResult().__iterator(type, reverse);
  5312. }
  5313. var iterable = this._iterable;
  5314. var iterator = getIterator(iterable);
  5315. if (!isIterator(iterator)) {
  5316. return new Iterator(iteratorDone);
  5317. }
  5318. var iterations = 0;
  5319. return new Iterator(function() {
  5320. var step = iterator.next();
  5321. return step.done ? step : iteratorValue(type, iterations++, step.value);
  5322. });
  5323. };
  5324. createClass(IteratorSeq, IndexedSeq);
  5325. function IteratorSeq(iterator) {
  5326. this._iterator = iterator;
  5327. this._iteratorCache = [];
  5328. }
  5329. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  5330. if (reverse) {
  5331. return this.cacheResult().__iterate(fn, reverse);
  5332. }
  5333. var iterator = this._iterator;
  5334. var cache = this._iteratorCache;
  5335. var iterations = 0;
  5336. while (iterations < cache.length) {
  5337. if (fn(cache[iterations], iterations++, this) === false) {
  5338. return iterations;
  5339. }
  5340. }
  5341. var step;
  5342. while (!(step = iterator.next()).done) {
  5343. var val = step.value;
  5344. cache[iterations] = val;
  5345. if (fn(val, iterations++, this) === false) {
  5346. break;
  5347. }
  5348. }
  5349. return iterations;
  5350. };
  5351. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  5352. if (reverse) {
  5353. return this.cacheResult().__iterator(type, reverse);
  5354. }
  5355. var iterator = this._iterator;
  5356. var cache = this._iteratorCache;
  5357. var iterations = 0;
  5358. return new Iterator(function() {
  5359. if (iterations >= cache.length) {
  5360. var step = iterator.next();
  5361. if (step.done) {
  5362. return step;
  5363. }
  5364. cache[iterations] = step.value;
  5365. }
  5366. return iteratorValue(type, iterations, cache[iterations++]);
  5367. });
  5368. };
  5369. // # pragma Helper functions
  5370. function isSeq(maybeSeq) {
  5371. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  5372. }
  5373. var EMPTY_SEQ;
  5374. function emptySequence() {
  5375. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  5376. }
  5377. function keyedSeqFromValue(value) {
  5378. var seq =
  5379. Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
  5380. isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
  5381. hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
  5382. typeof value === 'object' ? new ObjectSeq(value) :
  5383. undefined;
  5384. if (!seq) {
  5385. throw new TypeError(
  5386. 'Expected Array or iterable object of [k, v] entries, '+
  5387. 'or keyed object: ' + value
  5388. );
  5389. }
  5390. return seq;
  5391. }
  5392. function indexedSeqFromValue(value) {
  5393. var seq = maybeIndexedSeqFromValue(value);
  5394. if (!seq) {
  5395. throw new TypeError(
  5396. 'Expected Array or iterable object of values: ' + value
  5397. );
  5398. }
  5399. return seq;
  5400. }
  5401. function seqFromValue(value) {
  5402. var seq = maybeIndexedSeqFromValue(value) ||
  5403. (typeof value === 'object' && new ObjectSeq(value));
  5404. if (!seq) {
  5405. throw new TypeError(
  5406. 'Expected Array or iterable object of values, or keyed object: ' + value
  5407. );
  5408. }
  5409. return seq;
  5410. }
  5411. function maybeIndexedSeqFromValue(value) {
  5412. return (
  5413. isArrayLike(value) ? new ArraySeq(value) :
  5414. isIterator(value) ? new IteratorSeq(value) :
  5415. hasIterator(value) ? new IterableSeq(value) :
  5416. undefined
  5417. );
  5418. }
  5419. function seqIterate(seq, fn, reverse, useKeys) {
  5420. var cache = seq._cache;
  5421. if (cache) {
  5422. var maxIndex = cache.length - 1;
  5423. for (var ii = 0; ii <= maxIndex; ii++) {
  5424. var entry = cache[reverse ? maxIndex - ii : ii];
  5425. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  5426. return ii + 1;
  5427. }
  5428. }
  5429. return ii;
  5430. }
  5431. return seq.__iterateUncached(fn, reverse);
  5432. }
  5433. function seqIterator(seq, type, reverse, useKeys) {
  5434. var cache = seq._cache;
  5435. if (cache) {
  5436. var maxIndex = cache.length - 1;
  5437. var ii = 0;
  5438. return new Iterator(function() {
  5439. var entry = cache[reverse ? maxIndex - ii : ii];
  5440. return ii++ > maxIndex ?
  5441. iteratorDone() :
  5442. iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  5443. });
  5444. }
  5445. return seq.__iteratorUncached(type, reverse);
  5446. }
  5447. function fromJS(json, converter) {
  5448. return converter ?
  5449. fromJSWith(converter, json, '', {'': json}) :
  5450. fromJSDefault(json);
  5451. }
  5452. function fromJSWith(converter, json, key, parentJSON) {
  5453. if (Array.isArray(json)) {
  5454. return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  5455. }
  5456. if (isPlainObj(json)) {
  5457. return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  5458. }
  5459. return json;
  5460. }
  5461. function fromJSDefault(json) {
  5462. if (Array.isArray(json)) {
  5463. return IndexedSeq(json).map(fromJSDefault).toList();
  5464. }
  5465. if (isPlainObj(json)) {
  5466. return KeyedSeq(json).map(fromJSDefault).toMap();
  5467. }
  5468. return json;
  5469. }
  5470. function isPlainObj(value) {
  5471. return value && (value.constructor === Object || value.constructor === undefined);
  5472. }
  5473. /**
  5474. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  5475. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  5476. *
  5477. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  5478. * value, which is different from the algorithm described by
  5479. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  5480. *
  5481. * This is extended further to allow Objects to describe the values they
  5482. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  5483. *
  5484. * Note: because of this extension, the key equality of Immutable.Map and the
  5485. * value equality of Immutable.Set will differ from ES6 Map and Set.
  5486. *
  5487. * ### Defining custom values
  5488. *
  5489. * The easiest way to describe the value an object represents is by implementing
  5490. * `valueOf`. For example, `Date` represents a value by returning a unix
  5491. * timestamp for `valueOf`:
  5492. *
  5493. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  5494. * var date2 = new Date(1234567890000);
  5495. * date1.valueOf(); // 1234567890000
  5496. * assert( date1 !== date2 );
  5497. * assert( Immutable.is( date1, date2 ) );
  5498. *
  5499. * Note: overriding `valueOf` may have other implications if you use this object
  5500. * where JavaScript expects a primitive, such as implicit string coercion.
  5501. *
  5502. * For more complex types, especially collections, implementing `valueOf` may
  5503. * not be performant. An alternative is to implement `equals` and `hashCode`.
  5504. *
  5505. * `equals` takes another object, presumably of similar type, and returns true
  5506. * if the it is equal. Equality is symmetrical, so the same result should be
  5507. * returned if this and the argument are flipped.
  5508. *
  5509. * assert( a.equals(b) === b.equals(a) );
  5510. *
  5511. * `hashCode` returns a 32bit integer number representing the object which will
  5512. * be used to determine how to store the value object in a Map or Set. You must
  5513. * provide both or neither methods, one must not exist without the other.
  5514. *
  5515. * Also, an important relationship between these methods must be upheld: if two
  5516. * values are equal, they *must* return the same hashCode. If the values are not
  5517. * equal, they might have the same hashCode; this is called a hash collision,
  5518. * and while undesirable for performance reasons, it is acceptable.
  5519. *
  5520. * if (a.equals(b)) {
  5521. * assert( a.hashCode() === b.hashCode() );
  5522. * }
  5523. *
  5524. * All Immutable collections implement `equals` and `hashCode`.
  5525. *
  5526. */
  5527. function is(valueA, valueB) {
  5528. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  5529. return true;
  5530. }
  5531. if (!valueA || !valueB) {
  5532. return false;
  5533. }
  5534. if (typeof valueA.valueOf === 'function' &&
  5535. typeof valueB.valueOf === 'function') {
  5536. valueA = valueA.valueOf();
  5537. valueB = valueB.valueOf();
  5538. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  5539. return true;
  5540. }
  5541. if (!valueA || !valueB) {
  5542. return false;
  5543. }
  5544. }
  5545. if (typeof valueA.equals === 'function' &&
  5546. typeof valueB.equals === 'function' &&
  5547. valueA.equals(valueB)) {
  5548. return true;
  5549. }
  5550. return false;
  5551. }
  5552. function deepEqual(a, b) {
  5553. if (a === b) {
  5554. return true;
  5555. }
  5556. if (
  5557. !isIterable(b) ||
  5558. a.size !== undefined && b.size !== undefined && a.size !== b.size ||
  5559. a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
  5560. isKeyed(a) !== isKeyed(b) ||
  5561. isIndexed(a) !== isIndexed(b) ||
  5562. isOrdered(a) !== isOrdered(b)
  5563. ) {
  5564. return false;
  5565. }
  5566. if (a.size === 0 && b.size === 0) {
  5567. return true;
  5568. }
  5569. var notAssociative = !isAssociative(a);
  5570. if (isOrdered(a)) {
  5571. var entries = a.entries();
  5572. return b.every(function(v, k) {
  5573. var entry = entries.next().value;
  5574. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  5575. }) && entries.next().done;
  5576. }
  5577. var flipped = false;
  5578. if (a.size === undefined) {
  5579. if (b.size === undefined) {
  5580. if (typeof a.cacheResult === 'function') {
  5581. a.cacheResult();
  5582. }
  5583. } else {
  5584. flipped = true;
  5585. var _ = a;
  5586. a = b;
  5587. b = _;
  5588. }
  5589. }
  5590. var allEqual = true;
  5591. var bSize = b.__iterate(function(v, k) {
  5592. if (notAssociative ? !a.has(v) :
  5593. flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
  5594. allEqual = false;
  5595. return false;
  5596. }
  5597. });
  5598. return allEqual && a.size === bSize;
  5599. }
  5600. createClass(Repeat, IndexedSeq);
  5601. function Repeat(value, times) {
  5602. if (!(this instanceof Repeat)) {
  5603. return new Repeat(value, times);
  5604. }
  5605. this._value = value;
  5606. this.size = times === undefined ? Infinity : Math.max(0, times);
  5607. if (this.size === 0) {
  5608. if (EMPTY_REPEAT) {
  5609. return EMPTY_REPEAT;
  5610. }
  5611. EMPTY_REPEAT = this;
  5612. }
  5613. }
  5614. Repeat.prototype.toString = function() {
  5615. if (this.size === 0) {
  5616. return 'Repeat []';
  5617. }
  5618. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  5619. };
  5620. Repeat.prototype.get = function(index, notSetValue) {
  5621. return this.has(index) ? this._value : notSetValue;
  5622. };
  5623. Repeat.prototype.includes = function(searchValue) {
  5624. return is(this._value, searchValue);
  5625. };
  5626. Repeat.prototype.slice = function(begin, end) {
  5627. var size = this.size;
  5628. return wholeSlice(begin, end, size) ? this :
  5629. new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
  5630. };
  5631. Repeat.prototype.reverse = function() {
  5632. return this;
  5633. };
  5634. Repeat.prototype.indexOf = function(searchValue) {
  5635. if (is(this._value, searchValue)) {
  5636. return 0;
  5637. }
  5638. return -1;
  5639. };
  5640. Repeat.prototype.lastIndexOf = function(searchValue) {
  5641. if (is(this._value, searchValue)) {
  5642. return this.size;
  5643. }
  5644. return -1;
  5645. };
  5646. Repeat.prototype.__iterate = function(fn, reverse) {
  5647. for (var ii = 0; ii < this.size; ii++) {
  5648. if (fn(this._value, ii, this) === false) {
  5649. return ii + 1;
  5650. }
  5651. }
  5652. return ii;
  5653. };
  5654. Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
  5655. var ii = 0;
  5656. return new Iterator(function()
  5657. {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
  5658. );
  5659. };
  5660. Repeat.prototype.equals = function(other) {
  5661. return other instanceof Repeat ?
  5662. is(this._value, other._value) :
  5663. deepEqual(other);
  5664. };
  5665. var EMPTY_REPEAT;
  5666. function invariant(condition, error) {
  5667. if (!condition) throw new Error(error);
  5668. }
  5669. createClass(Range, IndexedSeq);
  5670. function Range(start, end, step) {
  5671. if (!(this instanceof Range)) {
  5672. return new Range(start, end, step);
  5673. }
  5674. invariant(step !== 0, 'Cannot step a Range by 0');
  5675. start = start || 0;
  5676. if (end === undefined) {
  5677. end = Infinity;
  5678. }
  5679. step = step === undefined ? 1 : Math.abs(step);
  5680. if (end < start) {
  5681. step = -step;
  5682. }
  5683. this._start = start;
  5684. this._end = end;
  5685. this._step = step;
  5686. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  5687. if (this.size === 0) {
  5688. if (EMPTY_RANGE) {
  5689. return EMPTY_RANGE;
  5690. }
  5691. EMPTY_RANGE = this;
  5692. }
  5693. }
  5694. Range.prototype.toString = function() {
  5695. if (this.size === 0) {
  5696. return 'Range []';
  5697. }
  5698. return 'Range [ ' +
  5699. this._start + '...' + this._end +
  5700. (this._step > 1 ? ' by ' + this._step : '') +
  5701. ' ]';
  5702. };
  5703. Range.prototype.get = function(index, notSetValue) {
  5704. return this.has(index) ?
  5705. this._start + wrapIndex(this, index) * this._step :
  5706. notSetValue;
  5707. };
  5708. Range.prototype.includes = function(searchValue) {
  5709. var possibleIndex = (searchValue - this._start) / this._step;
  5710. return possibleIndex >= 0 &&
  5711. possibleIndex < this.size &&
  5712. possibleIndex === Math.floor(possibleIndex);
  5713. };
  5714. Range.prototype.slice = function(begin, end) {
  5715. if (wholeSlice(begin, end, this.size)) {
  5716. return this;
  5717. }
  5718. begin = resolveBegin(begin, this.size);
  5719. end = resolveEnd(end, this.size);
  5720. if (end <= begin) {
  5721. return new Range(0, 0);
  5722. }
  5723. return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
  5724. };
  5725. Range.prototype.indexOf = function(searchValue) {
  5726. var offsetValue = searchValue - this._start;
  5727. if (offsetValue % this._step === 0) {
  5728. var index = offsetValue / this._step;
  5729. if (index >= 0 && index < this.size) {
  5730. return index
  5731. }
  5732. }
  5733. return -1;
  5734. };
  5735. Range.prototype.lastIndexOf = function(searchValue) {
  5736. return this.indexOf(searchValue);
  5737. };
  5738. Range.prototype.__iterate = function(fn, reverse) {
  5739. var maxIndex = this.size - 1;
  5740. var step = this._step;
  5741. var value = reverse ? this._start + maxIndex * step : this._start;
  5742. for (var ii = 0; ii <= maxIndex; ii++) {
  5743. if (fn(value, ii, this) === false) {
  5744. return ii + 1;
  5745. }
  5746. value += reverse ? -step : step;
  5747. }
  5748. return ii;
  5749. };
  5750. Range.prototype.__iterator = function(type, reverse) {
  5751. var maxIndex = this.size - 1;
  5752. var step = this._step;
  5753. var value = reverse ? this._start + maxIndex * step : this._start;
  5754. var ii = 0;
  5755. return new Iterator(function() {
  5756. var v = value;
  5757. value += reverse ? -step : step;
  5758. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  5759. });
  5760. };
  5761. Range.prototype.equals = function(other) {
  5762. return other instanceof Range ?
  5763. this._start === other._start &&
  5764. this._end === other._end &&
  5765. this._step === other._step :
  5766. deepEqual(this, other);
  5767. };
  5768. var EMPTY_RANGE;
  5769. createClass(Collection, Iterable);
  5770. function Collection() {
  5771. throw TypeError('Abstract');
  5772. }
  5773. createClass(KeyedCollection, Collection);function KeyedCollection() {}
  5774. createClass(IndexedCollection, Collection);function IndexedCollection() {}
  5775. createClass(SetCollection, Collection);function SetCollection() {}
  5776. Collection.Keyed = KeyedCollection;
  5777. Collection.Indexed = IndexedCollection;
  5778. Collection.Set = SetCollection;
  5779. var imul =
  5780. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
  5781. Math.imul :
  5782. function imul(a, b) {
  5783. a = a | 0; // int
  5784. b = b | 0; // int
  5785. var c = a & 0xffff;
  5786. var d = b & 0xffff;
  5787. // Shift by 0 fixes the sign on the high part.
  5788. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
  5789. };
  5790. // v8 has an optimization for storing 31-bit signed numbers.
  5791. // Values which have either 00 or 11 as the high order bits qualify.
  5792. // This function drops the highest order bit in a signed number, maintaining
  5793. // the sign bit.
  5794. function smi(i32) {
  5795. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
  5796. }
  5797. function hash(o) {
  5798. if (o === false || o === null || o === undefined) {
  5799. return 0;
  5800. }
  5801. if (typeof o.valueOf === 'function') {
  5802. o = o.valueOf();
  5803. if (o === false || o === null || o === undefined) {
  5804. return 0;
  5805. }
  5806. }
  5807. if (o === true) {
  5808. return 1;
  5809. }
  5810. var type = typeof o;
  5811. if (type === 'number') {
  5812. var h = o | 0;
  5813. if (h !== o) {
  5814. h ^= o * 0xFFFFFFFF;
  5815. }
  5816. while (o > 0xFFFFFFFF) {
  5817. o /= 0xFFFFFFFF;
  5818. h ^= o;
  5819. }
  5820. return smi(h);
  5821. }
  5822. if (type === 'string') {
  5823. return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
  5824. }
  5825. if (typeof o.hashCode === 'function') {
  5826. return o.hashCode();
  5827. }
  5828. if (type === 'object') {
  5829. return hashJSObj(o);
  5830. }
  5831. if (typeof o.toString === 'function') {
  5832. return hashString(o.toString());
  5833. }
  5834. throw new Error('Value type ' + type + ' cannot be hashed.');
  5835. }
  5836. function cachedHashString(string) {
  5837. var hash = stringHashCache[string];
  5838. if (hash === undefined) {
  5839. hash = hashString(string);
  5840. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  5841. STRING_HASH_CACHE_SIZE = 0;
  5842. stringHashCache = {};
  5843. }
  5844. STRING_HASH_CACHE_SIZE++;
  5845. stringHashCache[string] = hash;
  5846. }
  5847. return hash;
  5848. }
  5849. // http://jsperf.com/hashing-strings
  5850. function hashString(string) {
  5851. // This is the hash from JVM
  5852. // The hash code for a string is computed as
  5853. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  5854. // where s[i] is the ith character of the string and n is the length of
  5855. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  5856. // (exclusive) by dropping high bits.
  5857. var hash = 0;
  5858. for (var ii = 0; ii < string.length; ii++) {
  5859. hash = 31 * hash + string.charCodeAt(ii) | 0;
  5860. }
  5861. return smi(hash);
  5862. }
  5863. function hashJSObj(obj) {
  5864. var hash;
  5865. if (usingWeakMap) {
  5866. hash = weakMap.get(obj);
  5867. if (hash !== undefined) {
  5868. return hash;
  5869. }
  5870. }
  5871. hash = obj[UID_HASH_KEY];
  5872. if (hash !== undefined) {
  5873. return hash;
  5874. }
  5875. if (!canDefineProperty) {
  5876. hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  5877. if (hash !== undefined) {
  5878. return hash;
  5879. }
  5880. hash = getIENodeHash(obj);
  5881. if (hash !== undefined) {
  5882. return hash;
  5883. }
  5884. }
  5885. hash = ++objHashUID;
  5886. if (objHashUID & 0x40000000) {
  5887. objHashUID = 0;
  5888. }
  5889. if (usingWeakMap) {
  5890. weakMap.set(obj, hash);
  5891. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  5892. throw new Error('Non-extensible objects are not allowed as keys.');
  5893. } else if (canDefineProperty) {
  5894. Object.defineProperty(obj, UID_HASH_KEY, {
  5895. 'enumerable': false,
  5896. 'configurable': false,
  5897. 'writable': false,
  5898. 'value': hash
  5899. });
  5900. } else if (obj.propertyIsEnumerable !== undefined &&
  5901. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
  5902. // Since we can't define a non-enumerable property on the object
  5903. // we'll hijack one of the less-used non-enumerable properties to
  5904. // save our hash on it. Since this is a function it will not show up in
  5905. // `JSON.stringify` which is what we want.
  5906. obj.propertyIsEnumerable = function() {
  5907. return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
  5908. };
  5909. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  5910. } else if (obj.nodeType !== undefined) {
  5911. // At this point we couldn't get the IE `uniqueID` to use as a hash
  5912. // and we couldn't use a non-enumerable property to exploit the
  5913. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  5914. // itself.
  5915. obj[UID_HASH_KEY] = hash;
  5916. } else {
  5917. throw new Error('Unable to set a non-enumerable property on object.');
  5918. }
  5919. return hash;
  5920. }
  5921. // Get references to ES5 object methods.
  5922. var isExtensible = Object.isExtensible;
  5923. // True if Object.defineProperty works as expected. IE8 fails this test.
  5924. var canDefineProperty = (function() {
  5925. try {
  5926. Object.defineProperty({}, '@', {});
  5927. return true;
  5928. } catch (e) {
  5929. return false;
  5930. }
  5931. }());
  5932. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  5933. // and avoid memory leaks from the IE cloneNode bug.
  5934. function getIENodeHash(node) {
  5935. if (node && node.nodeType > 0) {
  5936. switch (node.nodeType) {
  5937. case 1: // Element
  5938. return node.uniqueID;
  5939. case 9: // Document
  5940. return node.documentElement && node.documentElement.uniqueID;
  5941. }
  5942. }
  5943. }
  5944. // If possible, use a WeakMap.
  5945. var usingWeakMap = typeof WeakMap === 'function';
  5946. var weakMap;
  5947. if (usingWeakMap) {
  5948. weakMap = new WeakMap();
  5949. }
  5950. var objHashUID = 0;
  5951. var UID_HASH_KEY = '__immutablehash__';
  5952. if (typeof Symbol === 'function') {
  5953. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  5954. }
  5955. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  5956. var STRING_HASH_CACHE_MAX_SIZE = 255;
  5957. var STRING_HASH_CACHE_SIZE = 0;
  5958. var stringHashCache = {};
  5959. function assertNotInfinite(size) {
  5960. invariant(
  5961. size !== Infinity,
  5962. 'Cannot perform this action with an infinite size.'
  5963. );
  5964. }
  5965. createClass(Map, KeyedCollection);
  5966. // @pragma Construction
  5967. function Map(value) {
  5968. return value === null || value === undefined ? emptyMap() :
  5969. isMap(value) && !isOrdered(value) ? value :
  5970. emptyMap().withMutations(function(map ) {
  5971. var iter = KeyedIterable(value);
  5972. assertNotInfinite(iter.size);
  5973. iter.forEach(function(v, k) {return map.set(k, v)});
  5974. });
  5975. }
  5976. Map.prototype.toString = function() {
  5977. return this.__toString('Map {', '}');
  5978. };
  5979. // @pragma Access
  5980. Map.prototype.get = function(k, notSetValue) {
  5981. return this._root ?
  5982. this._root.get(0, undefined, k, notSetValue) :
  5983. notSetValue;
  5984. };
  5985. // @pragma Modification
  5986. Map.prototype.set = function(k, v) {
  5987. return updateMap(this, k, v);
  5988. };
  5989. Map.prototype.setIn = function(keyPath, v) {
  5990. return this.updateIn(keyPath, NOT_SET, function() {return v});
  5991. };
  5992. Map.prototype.remove = function(k) {
  5993. return updateMap(this, k, NOT_SET);
  5994. };
  5995. Map.prototype.deleteIn = function(keyPath) {
  5996. return this.updateIn(keyPath, function() {return NOT_SET});
  5997. };
  5998. Map.prototype.update = function(k, notSetValue, updater) {
  5999. return arguments.length === 1 ?
  6000. k(this) :
  6001. this.updateIn([k], notSetValue, updater);
  6002. };
  6003. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  6004. if (!updater) {
  6005. updater = notSetValue;
  6006. notSetValue = undefined;
  6007. }
  6008. var updatedValue = updateInDeepMap(
  6009. this,
  6010. forceIterator(keyPath),
  6011. notSetValue,
  6012. updater
  6013. );
  6014. return updatedValue === NOT_SET ? undefined : updatedValue;
  6015. };
  6016. Map.prototype.clear = function() {
  6017. if (this.size === 0) {
  6018. return this;
  6019. }
  6020. if (this.__ownerID) {
  6021. this.size = 0;
  6022. this._root = null;
  6023. this.__hash = undefined;
  6024. this.__altered = true;
  6025. return this;
  6026. }
  6027. return emptyMap();
  6028. };
  6029. // @pragma Composition
  6030. Map.prototype.merge = function(/*...iters*/) {
  6031. return mergeIntoMapWith(this, undefined, arguments);
  6032. };
  6033. Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  6034. return mergeIntoMapWith(this, merger, iters);
  6035. };
  6036. Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  6037. return this.updateIn(
  6038. keyPath,
  6039. emptyMap(),
  6040. function(m ) {return typeof m.merge === 'function' ?
  6041. m.merge.apply(m, iters) :
  6042. iters[iters.length - 1]}
  6043. );
  6044. };
  6045. Map.prototype.mergeDeep = function(/*...iters*/) {
  6046. return mergeIntoMapWith(this, deepMerger, arguments);
  6047. };
  6048. Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  6049. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  6050. };
  6051. Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  6052. return this.updateIn(
  6053. keyPath,
  6054. emptyMap(),
  6055. function(m ) {return typeof m.mergeDeep === 'function' ?
  6056. m.mergeDeep.apply(m, iters) :
  6057. iters[iters.length - 1]}
  6058. );
  6059. };
  6060. Map.prototype.sort = function(comparator) {
  6061. // Late binding
  6062. return OrderedMap(sortFactory(this, comparator));
  6063. };
  6064. Map.prototype.sortBy = function(mapper, comparator) {
  6065. // Late binding
  6066. return OrderedMap(sortFactory(this, comparator, mapper));
  6067. };
  6068. // @pragma Mutability
  6069. Map.prototype.withMutations = function(fn) {
  6070. var mutable = this.asMutable();
  6071. fn(mutable);
  6072. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  6073. };
  6074. Map.prototype.asMutable = function() {
  6075. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  6076. };
  6077. Map.prototype.asImmutable = function() {
  6078. return this.__ensureOwner();
  6079. };
  6080. Map.prototype.wasAltered = function() {
  6081. return this.__altered;
  6082. };
  6083. Map.prototype.__iterator = function(type, reverse) {
  6084. return new MapIterator(this, type, reverse);
  6085. };
  6086. Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  6087. var iterations = 0;
  6088. this._root && this._root.iterate(function(entry ) {
  6089. iterations++;
  6090. return fn(entry[1], entry[0], this$0);
  6091. }, reverse);
  6092. return iterations;
  6093. };
  6094. Map.prototype.__ensureOwner = function(ownerID) {
  6095. if (ownerID === this.__ownerID) {
  6096. return this;
  6097. }
  6098. if (!ownerID) {
  6099. this.__ownerID = ownerID;
  6100. this.__altered = false;
  6101. return this;
  6102. }
  6103. return makeMap(this.size, this._root, ownerID, this.__hash);
  6104. };
  6105. function isMap(maybeMap) {
  6106. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  6107. }
  6108. Map.isMap = isMap;
  6109. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  6110. var MapPrototype = Map.prototype;
  6111. MapPrototype[IS_MAP_SENTINEL] = true;
  6112. MapPrototype[DELETE] = MapPrototype.remove;
  6113. MapPrototype.removeIn = MapPrototype.deleteIn;
  6114. // #pragma Trie Nodes
  6115. function ArrayMapNode(ownerID, entries) {
  6116. this.ownerID = ownerID;
  6117. this.entries = entries;
  6118. }
  6119. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  6120. var entries = this.entries;
  6121. for (var ii = 0, len = entries.length; ii < len; ii++) {
  6122. if (is(key, entries[ii][0])) {
  6123. return entries[ii][1];
  6124. }
  6125. }
  6126. return notSetValue;
  6127. };
  6128. ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  6129. var removed = value === NOT_SET;
  6130. var entries = this.entries;
  6131. var idx = 0;
  6132. for (var len = entries.length; idx < len; idx++) {
  6133. if (is(key, entries[idx][0])) {
  6134. break;
  6135. }
  6136. }
  6137. var exists = idx < len;
  6138. if (exists ? entries[idx][1] === value : removed) {
  6139. return this;
  6140. }
  6141. SetRef(didAlter);
  6142. (removed || !exists) && SetRef(didChangeSize);
  6143. if (removed && entries.length === 1) {
  6144. return; // undefined
  6145. }
  6146. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  6147. return createNodes(ownerID, entries, key, value);
  6148. }
  6149. var isEditable = ownerID && ownerID === this.ownerID;
  6150. var newEntries = isEditable ? entries : arrCopy(entries);
  6151. if (exists) {
  6152. if (removed) {
  6153. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  6154. } else {
  6155. newEntries[idx] = [key, value];
  6156. }
  6157. } else {
  6158. newEntries.push([key, value]);
  6159. }
  6160. if (isEditable) {
  6161. this.entries = newEntries;
  6162. return this;
  6163. }
  6164. return new ArrayMapNode(ownerID, newEntries);
  6165. };
  6166. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  6167. this.ownerID = ownerID;
  6168. this.bitmap = bitmap;
  6169. this.nodes = nodes;
  6170. }
  6171. BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  6172. if (keyHash === undefined) {
  6173. keyHash = hash(key);
  6174. }
  6175. var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
  6176. var bitmap = this.bitmap;
  6177. return (bitmap & bit) === 0 ? notSetValue :
  6178. this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
  6179. };
  6180. BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  6181. if (keyHash === undefined) {
  6182. keyHash = hash(key);
  6183. }
  6184. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  6185. var bit = 1 << keyHashFrag;
  6186. var bitmap = this.bitmap;
  6187. var exists = (bitmap & bit) !== 0;
  6188. if (!exists && value === NOT_SET) {
  6189. return this;
  6190. }
  6191. var idx = popCount(bitmap & (bit - 1));
  6192. var nodes = this.nodes;
  6193. var node = exists ? nodes[idx] : undefined;
  6194. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  6195. if (newNode === node) {
  6196. return this;
  6197. }
  6198. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  6199. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  6200. }
  6201. if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
  6202. return nodes[idx ^ 1];
  6203. }
  6204. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  6205. return newNode;
  6206. }
  6207. var isEditable = ownerID && ownerID === this.ownerID;
  6208. var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
  6209. var newNodes = exists ? newNode ?
  6210. setIn(nodes, idx, newNode, isEditable) :
  6211. spliceOut(nodes, idx, isEditable) :
  6212. spliceIn(nodes, idx, newNode, isEditable);
  6213. if (isEditable) {
  6214. this.bitmap = newBitmap;
  6215. this.nodes = newNodes;
  6216. return this;
  6217. }
  6218. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  6219. };
  6220. function HashArrayMapNode(ownerID, count, nodes) {
  6221. this.ownerID = ownerID;
  6222. this.count = count;
  6223. this.nodes = nodes;
  6224. }
  6225. HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  6226. if (keyHash === undefined) {
  6227. keyHash = hash(key);
  6228. }
  6229. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  6230. var node = this.nodes[idx];
  6231. return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
  6232. };
  6233. HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  6234. if (keyHash === undefined) {
  6235. keyHash = hash(key);
  6236. }
  6237. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  6238. var removed = value === NOT_SET;
  6239. var nodes = this.nodes;
  6240. var node = nodes[idx];
  6241. if (removed && !node) {
  6242. return this;
  6243. }
  6244. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  6245. if (newNode === node) {
  6246. return this;
  6247. }
  6248. var newCount = this.count;
  6249. if (!node) {
  6250. newCount++;
  6251. } else if (!newNode) {
  6252. newCount--;
  6253. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  6254. return packNodes(ownerID, nodes, newCount, idx);
  6255. }
  6256. }
  6257. var isEditable = ownerID && ownerID === this.ownerID;
  6258. var newNodes = setIn(nodes, idx, newNode, isEditable);
  6259. if (isEditable) {
  6260. this.count = newCount;
  6261. this.nodes = newNodes;
  6262. return this;
  6263. }
  6264. return new HashArrayMapNode(ownerID, newCount, newNodes);
  6265. };
  6266. function HashCollisionNode(ownerID, keyHash, entries) {
  6267. this.ownerID = ownerID;
  6268. this.keyHash = keyHash;
  6269. this.entries = entries;
  6270. }
  6271. HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  6272. var entries = this.entries;
  6273. for (var ii = 0, len = entries.length; ii < len; ii++) {
  6274. if (is(key, entries[ii][0])) {
  6275. return entries[ii][1];
  6276. }
  6277. }
  6278. return notSetValue;
  6279. };
  6280. HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  6281. if (keyHash === undefined) {
  6282. keyHash = hash(key);
  6283. }
  6284. var removed = value === NOT_SET;
  6285. if (keyHash !== this.keyHash) {
  6286. if (removed) {
  6287. return this;
  6288. }
  6289. SetRef(didAlter);
  6290. SetRef(didChangeSize);
  6291. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  6292. }
  6293. var entries = this.entries;
  6294. var idx = 0;
  6295. for (var len = entries.length; idx < len; idx++) {
  6296. if (is(key, entries[idx][0])) {
  6297. break;
  6298. }
  6299. }
  6300. var exists = idx < len;
  6301. if (exists ? entries[idx][1] === value : removed) {
  6302. return this;
  6303. }
  6304. SetRef(didAlter);
  6305. (removed || !exists) && SetRef(didChangeSize);
  6306. if (removed && len === 2) {
  6307. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  6308. }
  6309. var isEditable = ownerID && ownerID === this.ownerID;
  6310. var newEntries = isEditable ? entries : arrCopy(entries);
  6311. if (exists) {
  6312. if (removed) {
  6313. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  6314. } else {
  6315. newEntries[idx] = [key, value];
  6316. }
  6317. } else {
  6318. newEntries.push([key, value]);
  6319. }
  6320. if (isEditable) {
  6321. this.entries = newEntries;
  6322. return this;
  6323. }
  6324. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  6325. };
  6326. function ValueNode(ownerID, keyHash, entry) {
  6327. this.ownerID = ownerID;
  6328. this.keyHash = keyHash;
  6329. this.entry = entry;
  6330. }
  6331. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  6332. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  6333. };
  6334. ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  6335. var removed = value === NOT_SET;
  6336. var keyMatch = is(key, this.entry[0]);
  6337. if (keyMatch ? value === this.entry[1] : removed) {
  6338. return this;
  6339. }
  6340. SetRef(didAlter);
  6341. if (removed) {
  6342. SetRef(didChangeSize);
  6343. return; // undefined
  6344. }
  6345. if (keyMatch) {
  6346. if (ownerID && ownerID === this.ownerID) {
  6347. this.entry[1] = value;
  6348. return this;
  6349. }
  6350. return new ValueNode(ownerID, this.keyHash, [key, value]);
  6351. }
  6352. SetRef(didChangeSize);
  6353. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  6354. };
  6355. // #pragma Iterators
  6356. ArrayMapNode.prototype.iterate =
  6357. HashCollisionNode.prototype.iterate = function (fn, reverse) {
  6358. var entries = this.entries;
  6359. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  6360. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  6361. return false;
  6362. }
  6363. }
  6364. };
  6365. BitmapIndexedNode.prototype.iterate =
  6366. HashArrayMapNode.prototype.iterate = function (fn, reverse) {
  6367. var nodes = this.nodes;
  6368. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  6369. var node = nodes[reverse ? maxIndex - ii : ii];
  6370. if (node && node.iterate(fn, reverse) === false) {
  6371. return false;
  6372. }
  6373. }
  6374. };
  6375. ValueNode.prototype.iterate = function (fn, reverse) {
  6376. return fn(this.entry);
  6377. };
  6378. createClass(MapIterator, Iterator);
  6379. function MapIterator(map, type, reverse) {
  6380. this._type = type;
  6381. this._reverse = reverse;
  6382. this._stack = map._root && mapIteratorFrame(map._root);
  6383. }
  6384. MapIterator.prototype.next = function() {
  6385. var type = this._type;
  6386. var stack = this._stack;
  6387. while (stack) {
  6388. var node = stack.node;
  6389. var index = stack.index++;
  6390. var maxIndex;
  6391. if (node.entry) {
  6392. if (index === 0) {
  6393. return mapIteratorValue(type, node.entry);
  6394. }
  6395. } else if (node.entries) {
  6396. maxIndex = node.entries.length - 1;
  6397. if (index <= maxIndex) {
  6398. return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
  6399. }
  6400. } else {
  6401. maxIndex = node.nodes.length - 1;
  6402. if (index <= maxIndex) {
  6403. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  6404. if (subNode) {
  6405. if (subNode.entry) {
  6406. return mapIteratorValue(type, subNode.entry);
  6407. }
  6408. stack = this._stack = mapIteratorFrame(subNode, stack);
  6409. }
  6410. continue;
  6411. }
  6412. }
  6413. stack = this._stack = this._stack.__prev;
  6414. }
  6415. return iteratorDone();
  6416. };
  6417. function mapIteratorValue(type, entry) {
  6418. return iteratorValue(type, entry[0], entry[1]);
  6419. }
  6420. function mapIteratorFrame(node, prev) {
  6421. return {
  6422. node: node,
  6423. index: 0,
  6424. __prev: prev
  6425. };
  6426. }
  6427. function makeMap(size, root, ownerID, hash) {
  6428. var map = Object.create(MapPrototype);
  6429. map.size = size;
  6430. map._root = root;
  6431. map.__ownerID = ownerID;
  6432. map.__hash = hash;
  6433. map.__altered = false;
  6434. return map;
  6435. }
  6436. var EMPTY_MAP;
  6437. function emptyMap() {
  6438. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  6439. }
  6440. function updateMap(map, k, v) {
  6441. var newRoot;
  6442. var newSize;
  6443. if (!map._root) {
  6444. if (v === NOT_SET) {
  6445. return map;
  6446. }
  6447. newSize = 1;
  6448. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  6449. } else {
  6450. var didChangeSize = MakeRef(CHANGE_LENGTH);
  6451. var didAlter = MakeRef(DID_ALTER);
  6452. newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
  6453. if (!didAlter.value) {
  6454. return map;
  6455. }
  6456. newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
  6457. }
  6458. if (map.__ownerID) {
  6459. map.size = newSize;
  6460. map._root = newRoot;
  6461. map.__hash = undefined;
  6462. map.__altered = true;
  6463. return map;
  6464. }
  6465. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  6466. }
  6467. function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  6468. if (!node) {
  6469. if (value === NOT_SET) {
  6470. return node;
  6471. }
  6472. SetRef(didAlter);
  6473. SetRef(didChangeSize);
  6474. return new ValueNode(ownerID, keyHash, [key, value]);
  6475. }
  6476. return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
  6477. }
  6478. function isLeafNode(node) {
  6479. return node.constructor === ValueNode || node.constructor === HashCollisionNode;
  6480. }
  6481. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  6482. if (node.keyHash === keyHash) {
  6483. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  6484. }
  6485. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  6486. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  6487. var newNode;
  6488. var nodes = idx1 === idx2 ?
  6489. [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
  6490. ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
  6491. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  6492. }
  6493. function createNodes(ownerID, entries, key, value) {
  6494. if (!ownerID) {
  6495. ownerID = new OwnerID();
  6496. }
  6497. var node = new ValueNode(ownerID, hash(key), [key, value]);
  6498. for (var ii = 0; ii < entries.length; ii++) {
  6499. var entry = entries[ii];
  6500. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  6501. }
  6502. return node;
  6503. }
  6504. function packNodes(ownerID, nodes, count, excluding) {
  6505. var bitmap = 0;
  6506. var packedII = 0;
  6507. var packedNodes = new Array(count);
  6508. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  6509. var node = nodes[ii];
  6510. if (node !== undefined && ii !== excluding) {
  6511. bitmap |= bit;
  6512. packedNodes[packedII++] = node;
  6513. }
  6514. }
  6515. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  6516. }
  6517. function expandNodes(ownerID, nodes, bitmap, including, node) {
  6518. var count = 0;
  6519. var expandedNodes = new Array(SIZE);
  6520. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  6521. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  6522. }
  6523. expandedNodes[including] = node;
  6524. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  6525. }
  6526. function mergeIntoMapWith(map, merger, iterables) {
  6527. var iters = [];
  6528. for (var ii = 0; ii < iterables.length; ii++) {
  6529. var value = iterables[ii];
  6530. var iter = KeyedIterable(value);
  6531. if (!isIterable(value)) {
  6532. iter = iter.map(function(v ) {return fromJS(v)});
  6533. }
  6534. iters.push(iter);
  6535. }
  6536. return mergeIntoCollectionWith(map, merger, iters);
  6537. }
  6538. function deepMerger(existing, value, key) {
  6539. return existing && existing.mergeDeep && isIterable(value) ?
  6540. existing.mergeDeep(value) :
  6541. is(existing, value) ? existing : value;
  6542. }
  6543. function deepMergerWith(merger) {
  6544. return function(existing, value, key) {
  6545. if (existing && existing.mergeDeepWith && isIterable(value)) {
  6546. return existing.mergeDeepWith(merger, value);
  6547. }
  6548. var nextValue = merger(existing, value, key);
  6549. return is(existing, nextValue) ? existing : nextValue;
  6550. };
  6551. }
  6552. function mergeIntoCollectionWith(collection, merger, iters) {
  6553. iters = iters.filter(function(x ) {return x.size !== 0});
  6554. if (iters.length === 0) {
  6555. return collection;
  6556. }
  6557. if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
  6558. return collection.constructor(iters[0]);
  6559. }
  6560. return collection.withMutations(function(collection ) {
  6561. var mergeIntoMap = merger ?
  6562. function(value, key) {
  6563. collection.update(key, NOT_SET, function(existing )
  6564. {return existing === NOT_SET ? value : merger(existing, value, key)}
  6565. );
  6566. } :
  6567. function(value, key) {
  6568. collection.set(key, value);
  6569. };
  6570. for (var ii = 0; ii < iters.length; ii++) {
  6571. iters[ii].forEach(mergeIntoMap);
  6572. }
  6573. });
  6574. }
  6575. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  6576. var isNotSet = existing === NOT_SET;
  6577. var step = keyPathIter.next();
  6578. if (step.done) {
  6579. var existingValue = isNotSet ? notSetValue : existing;
  6580. var newValue = updater(existingValue);
  6581. return newValue === existingValue ? existing : newValue;
  6582. }
  6583. invariant(
  6584. isNotSet || (existing && existing.set),
  6585. 'invalid keyPath'
  6586. );
  6587. var key = step.value;
  6588. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  6589. var nextUpdated = updateInDeepMap(
  6590. nextExisting,
  6591. keyPathIter,
  6592. notSetValue,
  6593. updater
  6594. );
  6595. return nextUpdated === nextExisting ? existing :
  6596. nextUpdated === NOT_SET ? existing.remove(key) :
  6597. (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  6598. }
  6599. function popCount(x) {
  6600. x = x - ((x >> 1) & 0x55555555);
  6601. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  6602. x = (x + (x >> 4)) & 0x0f0f0f0f;
  6603. x = x + (x >> 8);
  6604. x = x + (x >> 16);
  6605. return x & 0x7f;
  6606. }
  6607. function setIn(array, idx, val, canEdit) {
  6608. var newArray = canEdit ? array : arrCopy(array);
  6609. newArray[idx] = val;
  6610. return newArray;
  6611. }
  6612. function spliceIn(array, idx, val, canEdit) {
  6613. var newLen = array.length + 1;
  6614. if (canEdit && idx + 1 === newLen) {
  6615. array[idx] = val;
  6616. return array;
  6617. }
  6618. var newArray = new Array(newLen);
  6619. var after = 0;
  6620. for (var ii = 0; ii < newLen; ii++) {
  6621. if (ii === idx) {
  6622. newArray[ii] = val;
  6623. after = -1;
  6624. } else {
  6625. newArray[ii] = array[ii + after];
  6626. }
  6627. }
  6628. return newArray;
  6629. }
  6630. function spliceOut(array, idx, canEdit) {
  6631. var newLen = array.length - 1;
  6632. if (canEdit && idx === newLen) {
  6633. array.pop();
  6634. return array;
  6635. }
  6636. var newArray = new Array(newLen);
  6637. var after = 0;
  6638. for (var ii = 0; ii < newLen; ii++) {
  6639. if (ii === idx) {
  6640. after = 1;
  6641. }
  6642. newArray[ii] = array[ii + after];
  6643. }
  6644. return newArray;
  6645. }
  6646. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  6647. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  6648. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  6649. createClass(List, IndexedCollection);
  6650. // @pragma Construction
  6651. function List(value) {
  6652. var empty = emptyList();
  6653. if (value === null || value === undefined) {
  6654. return empty;
  6655. }
  6656. if (isList(value)) {
  6657. return value;
  6658. }
  6659. var iter = IndexedIterable(value);
  6660. var size = iter.size;
  6661. if (size === 0) {
  6662. return empty;
  6663. }
  6664. assertNotInfinite(size);
  6665. if (size > 0 && size < SIZE) {
  6666. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  6667. }
  6668. return empty.withMutations(function(list ) {
  6669. list.setSize(size);
  6670. iter.forEach(function(v, i) {return list.set(i, v)});
  6671. });
  6672. }
  6673. List.of = function(/*...values*/) {
  6674. return this(arguments);
  6675. };
  6676. List.prototype.toString = function() {
  6677. return this.__toString('List [', ']');
  6678. };
  6679. // @pragma Access
  6680. List.prototype.get = function(index, notSetValue) {
  6681. index = wrapIndex(this, index);
  6682. if (index >= 0 && index < this.size) {
  6683. index += this._origin;
  6684. var node = listNodeFor(this, index);
  6685. return node && node.array[index & MASK];
  6686. }
  6687. return notSetValue;
  6688. };
  6689. // @pragma Modification
  6690. List.prototype.set = function(index, value) {
  6691. return updateList(this, index, value);
  6692. };
  6693. List.prototype.remove = function(index) {
  6694. return !this.has(index) ? this :
  6695. index === 0 ? this.shift() :
  6696. index === this.size - 1 ? this.pop() :
  6697. this.splice(index, 1);
  6698. };
  6699. List.prototype.insert = function(index, value) {
  6700. return this.splice(index, 0, value);
  6701. };
  6702. List.prototype.clear = function() {
  6703. if (this.size === 0) {
  6704. return this;
  6705. }
  6706. if (this.__ownerID) {
  6707. this.size = this._origin = this._capacity = 0;
  6708. this._level = SHIFT;
  6709. this._root = this._tail = null;
  6710. this.__hash = undefined;
  6711. this.__altered = true;
  6712. return this;
  6713. }
  6714. return emptyList();
  6715. };
  6716. List.prototype.push = function(/*...values*/) {
  6717. var values = arguments;
  6718. var oldSize = this.size;
  6719. return this.withMutations(function(list ) {
  6720. setListBounds(list, 0, oldSize + values.length);
  6721. for (var ii = 0; ii < values.length; ii++) {
  6722. list.set(oldSize + ii, values[ii]);
  6723. }
  6724. });
  6725. };
  6726. List.prototype.pop = function() {
  6727. return setListBounds(this, 0, -1);
  6728. };
  6729. List.prototype.unshift = function(/*...values*/) {
  6730. var values = arguments;
  6731. return this.withMutations(function(list ) {
  6732. setListBounds(list, -values.length);
  6733. for (var ii = 0; ii < values.length; ii++) {
  6734. list.set(ii, values[ii]);
  6735. }
  6736. });
  6737. };
  6738. List.prototype.shift = function() {
  6739. return setListBounds(this, 1);
  6740. };
  6741. // @pragma Composition
  6742. List.prototype.merge = function(/*...iters*/) {
  6743. return mergeIntoListWith(this, undefined, arguments);
  6744. };
  6745. List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  6746. return mergeIntoListWith(this, merger, iters);
  6747. };
  6748. List.prototype.mergeDeep = function(/*...iters*/) {
  6749. return mergeIntoListWith(this, deepMerger, arguments);
  6750. };
  6751. List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  6752. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  6753. };
  6754. List.prototype.setSize = function(size) {
  6755. return setListBounds(this, 0, size);
  6756. };
  6757. // @pragma Iteration
  6758. List.prototype.slice = function(begin, end) {
  6759. var size = this.size;
  6760. if (wholeSlice(begin, end, size)) {
  6761. return this;
  6762. }
  6763. return setListBounds(
  6764. this,
  6765. resolveBegin(begin, size),
  6766. resolveEnd(end, size)
  6767. );
  6768. };
  6769. List.prototype.__iterator = function(type, reverse) {
  6770. var index = 0;
  6771. var values = iterateList(this, reverse);
  6772. return new Iterator(function() {
  6773. var value = values();
  6774. return value === DONE ?
  6775. iteratorDone() :
  6776. iteratorValue(type, index++, value);
  6777. });
  6778. };
  6779. List.prototype.__iterate = function(fn, reverse) {
  6780. var index = 0;
  6781. var values = iterateList(this, reverse);
  6782. var value;
  6783. while ((value = values()) !== DONE) {
  6784. if (fn(value, index++, this) === false) {
  6785. break;
  6786. }
  6787. }
  6788. return index;
  6789. };
  6790. List.prototype.__ensureOwner = function(ownerID) {
  6791. if (ownerID === this.__ownerID) {
  6792. return this;
  6793. }
  6794. if (!ownerID) {
  6795. this.__ownerID = ownerID;
  6796. return this;
  6797. }
  6798. return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
  6799. };
  6800. function isList(maybeList) {
  6801. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  6802. }
  6803. List.isList = isList;
  6804. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  6805. var ListPrototype = List.prototype;
  6806. ListPrototype[IS_LIST_SENTINEL] = true;
  6807. ListPrototype[DELETE] = ListPrototype.remove;
  6808. ListPrototype.setIn = MapPrototype.setIn;
  6809. ListPrototype.deleteIn =
  6810. ListPrototype.removeIn = MapPrototype.removeIn;
  6811. ListPrototype.update = MapPrototype.update;
  6812. ListPrototype.updateIn = MapPrototype.updateIn;
  6813. ListPrototype.mergeIn = MapPrototype.mergeIn;
  6814. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  6815. ListPrototype.withMutations = MapPrototype.withMutations;
  6816. ListPrototype.asMutable = MapPrototype.asMutable;
  6817. ListPrototype.asImmutable = MapPrototype.asImmutable;
  6818. ListPrototype.wasAltered = MapPrototype.wasAltered;
  6819. function VNode(array, ownerID) {
  6820. this.array = array;
  6821. this.ownerID = ownerID;
  6822. }
  6823. // TODO: seems like these methods are very similar
  6824. VNode.prototype.removeBefore = function(ownerID, level, index) {
  6825. if (index === level ? 1 << level : this.array.length === 0) {
  6826. return this;
  6827. }
  6828. var originIndex = (index >>> level) & MASK;
  6829. if (originIndex >= this.array.length) {
  6830. return new VNode([], ownerID);
  6831. }
  6832. var removingFirst = originIndex === 0;
  6833. var newChild;
  6834. if (level > 0) {
  6835. var oldChild = this.array[originIndex];
  6836. newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  6837. if (newChild === oldChild && removingFirst) {
  6838. return this;
  6839. }
  6840. }
  6841. if (removingFirst && !newChild) {
  6842. return this;
  6843. }
  6844. var editable = editableVNode(this, ownerID);
  6845. if (!removingFirst) {
  6846. for (var ii = 0; ii < originIndex; ii++) {
  6847. editable.array[ii] = undefined;
  6848. }
  6849. }
  6850. if (newChild) {
  6851. editable.array[originIndex] = newChild;
  6852. }
  6853. return editable;
  6854. };
  6855. VNode.prototype.removeAfter = function(ownerID, level, index) {
  6856. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  6857. return this;
  6858. }
  6859. var sizeIndex = ((index - 1) >>> level) & MASK;
  6860. if (sizeIndex >= this.array.length) {
  6861. return this;
  6862. }
  6863. var newChild;
  6864. if (level > 0) {
  6865. var oldChild = this.array[sizeIndex];
  6866. newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  6867. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  6868. return this;
  6869. }
  6870. }
  6871. var editable = editableVNode(this, ownerID);
  6872. editable.array.splice(sizeIndex + 1);
  6873. if (newChild) {
  6874. editable.array[sizeIndex] = newChild;
  6875. }
  6876. return editable;
  6877. };
  6878. var DONE = {};
  6879. function iterateList(list, reverse) {
  6880. var left = list._origin;
  6881. var right = list._capacity;
  6882. var tailPos = getTailOffset(right);
  6883. var tail = list._tail;
  6884. return iterateNodeOrLeaf(list._root, list._level, 0);
  6885. function iterateNodeOrLeaf(node, level, offset) {
  6886. return level === 0 ?
  6887. iterateLeaf(node, offset) :
  6888. iterateNode(node, level, offset);
  6889. }
  6890. function iterateLeaf(node, offset) {
  6891. var array = offset === tailPos ? tail && tail.array : node && node.array;
  6892. var from = offset > left ? 0 : left - offset;
  6893. var to = right - offset;
  6894. if (to > SIZE) {
  6895. to = SIZE;
  6896. }
  6897. return function() {
  6898. if (from === to) {
  6899. return DONE;
  6900. }
  6901. var idx = reverse ? --to : from++;
  6902. return array && array[idx];
  6903. };
  6904. }
  6905. function iterateNode(node, level, offset) {
  6906. var values;
  6907. var array = node && node.array;
  6908. var from = offset > left ? 0 : (left - offset) >> level;
  6909. var to = ((right - offset) >> level) + 1;
  6910. if (to > SIZE) {
  6911. to = SIZE;
  6912. }
  6913. return function() {
  6914. do {
  6915. if (values) {
  6916. var value = values();
  6917. if (value !== DONE) {
  6918. return value;
  6919. }
  6920. values = null;
  6921. }
  6922. if (from === to) {
  6923. return DONE;
  6924. }
  6925. var idx = reverse ? --to : from++;
  6926. values = iterateNodeOrLeaf(
  6927. array && array[idx], level - SHIFT, offset + (idx << level)
  6928. );
  6929. } while (true);
  6930. };
  6931. }
  6932. }
  6933. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  6934. var list = Object.create(ListPrototype);
  6935. list.size = capacity - origin;
  6936. list._origin = origin;
  6937. list._capacity = capacity;
  6938. list._level = level;
  6939. list._root = root;
  6940. list._tail = tail;
  6941. list.__ownerID = ownerID;
  6942. list.__hash = hash;
  6943. list.__altered = false;
  6944. return list;
  6945. }
  6946. var EMPTY_LIST;
  6947. function emptyList() {
  6948. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  6949. }
  6950. function updateList(list, index, value) {
  6951. index = wrapIndex(list, index);
  6952. if (index !== index) {
  6953. return list;
  6954. }
  6955. if (index >= list.size || index < 0) {
  6956. return list.withMutations(function(list ) {
  6957. index < 0 ?
  6958. setListBounds(list, index).set(0, value) :
  6959. setListBounds(list, 0, index + 1).set(index, value);
  6960. });
  6961. }
  6962. index += list._origin;
  6963. var newTail = list._tail;
  6964. var newRoot = list._root;
  6965. var didAlter = MakeRef(DID_ALTER);
  6966. if (index >= getTailOffset(list._capacity)) {
  6967. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  6968. } else {
  6969. newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
  6970. }
  6971. if (!didAlter.value) {
  6972. return list;
  6973. }
  6974. if (list.__ownerID) {
  6975. list._root = newRoot;
  6976. list._tail = newTail;
  6977. list.__hash = undefined;
  6978. list.__altered = true;
  6979. return list;
  6980. }
  6981. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  6982. }
  6983. function updateVNode(node, ownerID, level, index, value, didAlter) {
  6984. var idx = (index >>> level) & MASK;
  6985. var nodeHas = node && idx < node.array.length;
  6986. if (!nodeHas && value === undefined) {
  6987. return node;
  6988. }
  6989. var newNode;
  6990. if (level > 0) {
  6991. var lowerNode = node && node.array[idx];
  6992. var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
  6993. if (newLowerNode === lowerNode) {
  6994. return node;
  6995. }
  6996. newNode = editableVNode(node, ownerID);
  6997. newNode.array[idx] = newLowerNode;
  6998. return newNode;
  6999. }
  7000. if (nodeHas && node.array[idx] === value) {
  7001. return node;
  7002. }
  7003. SetRef(didAlter);
  7004. newNode = editableVNode(node, ownerID);
  7005. if (value === undefined && idx === newNode.array.length - 1) {
  7006. newNode.array.pop();
  7007. } else {
  7008. newNode.array[idx] = value;
  7009. }
  7010. return newNode;
  7011. }
  7012. function editableVNode(node, ownerID) {
  7013. if (ownerID && node && ownerID === node.ownerID) {
  7014. return node;
  7015. }
  7016. return new VNode(node ? node.array.slice() : [], ownerID);
  7017. }
  7018. function listNodeFor(list, rawIndex) {
  7019. if (rawIndex >= getTailOffset(list._capacity)) {
  7020. return list._tail;
  7021. }
  7022. if (rawIndex < 1 << (list._level + SHIFT)) {
  7023. var node = list._root;
  7024. var level = list._level;
  7025. while (node && level > 0) {
  7026. node = node.array[(rawIndex >>> level) & MASK];
  7027. level -= SHIFT;
  7028. }
  7029. return node;
  7030. }
  7031. }
  7032. function setListBounds(list, begin, end) {
  7033. // Sanitize begin & end using this shorthand for ToInt32(argument)
  7034. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  7035. if (begin !== undefined) {
  7036. begin = begin | 0;
  7037. }
  7038. if (end !== undefined) {
  7039. end = end | 0;
  7040. }
  7041. var owner = list.__ownerID || new OwnerID();
  7042. var oldOrigin = list._origin;
  7043. var oldCapacity = list._capacity;
  7044. var newOrigin = oldOrigin + begin;
  7045. var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
  7046. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  7047. return list;
  7048. }
  7049. // If it's going to end after it starts, it's empty.
  7050. if (newOrigin >= newCapacity) {
  7051. return list.clear();
  7052. }
  7053. var newLevel = list._level;
  7054. var newRoot = list._root;
  7055. // New origin might need creating a higher root.
  7056. var offsetShift = 0;
  7057. while (newOrigin + offsetShift < 0) {
  7058. newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
  7059. newLevel += SHIFT;
  7060. offsetShift += 1 << newLevel;
  7061. }
  7062. if (offsetShift) {
  7063. newOrigin += offsetShift;
  7064. oldOrigin += offsetShift;
  7065. newCapacity += offsetShift;
  7066. oldCapacity += offsetShift;
  7067. }
  7068. var oldTailOffset = getTailOffset(oldCapacity);
  7069. var newTailOffset = getTailOffset(newCapacity);
  7070. // New size might need creating a higher root.
  7071. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  7072. newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
  7073. newLevel += SHIFT;
  7074. }
  7075. // Locate or create the new tail.
  7076. var oldTail = list._tail;
  7077. var newTail = newTailOffset < oldTailOffset ?
  7078. listNodeFor(list, newCapacity - 1) :
  7079. newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
  7080. // Merge Tail into tree.
  7081. if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
  7082. newRoot = editableVNode(newRoot, owner);
  7083. var node = newRoot;
  7084. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  7085. var idx = (oldTailOffset >>> level) & MASK;
  7086. node = node.array[idx] = editableVNode(node.array[idx], owner);
  7087. }
  7088. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  7089. }
  7090. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  7091. if (newCapacity < oldCapacity) {
  7092. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  7093. }
  7094. // If the new origin is within the tail, then we do not need a root.
  7095. if (newOrigin >= newTailOffset) {
  7096. newOrigin -= newTailOffset;
  7097. newCapacity -= newTailOffset;
  7098. newLevel = SHIFT;
  7099. newRoot = null;
  7100. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  7101. // Otherwise, if the root has been trimmed, garbage collect.
  7102. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  7103. offsetShift = 0;
  7104. // Identify the new top root node of the subtree of the old root.
  7105. while (newRoot) {
  7106. var beginIndex = (newOrigin >>> newLevel) & MASK;
  7107. if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
  7108. break;
  7109. }
  7110. if (beginIndex) {
  7111. offsetShift += (1 << newLevel) * beginIndex;
  7112. }
  7113. newLevel -= SHIFT;
  7114. newRoot = newRoot.array[beginIndex];
  7115. }
  7116. // Trim the new sides of the new root.
  7117. if (newRoot && newOrigin > oldOrigin) {
  7118. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  7119. }
  7120. if (newRoot && newTailOffset < oldTailOffset) {
  7121. newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
  7122. }
  7123. if (offsetShift) {
  7124. newOrigin -= offsetShift;
  7125. newCapacity -= offsetShift;
  7126. }
  7127. }
  7128. if (list.__ownerID) {
  7129. list.size = newCapacity - newOrigin;
  7130. list._origin = newOrigin;
  7131. list._capacity = newCapacity;
  7132. list._level = newLevel;
  7133. list._root = newRoot;
  7134. list._tail = newTail;
  7135. list.__hash = undefined;
  7136. list.__altered = true;
  7137. return list;
  7138. }
  7139. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  7140. }
  7141. function mergeIntoListWith(list, merger, iterables) {
  7142. var iters = [];
  7143. var maxSize = 0;
  7144. for (var ii = 0; ii < iterables.length; ii++) {
  7145. var value = iterables[ii];
  7146. var iter = IndexedIterable(value);
  7147. if (iter.size > maxSize) {
  7148. maxSize = iter.size;
  7149. }
  7150. if (!isIterable(value)) {
  7151. iter = iter.map(function(v ) {return fromJS(v)});
  7152. }
  7153. iters.push(iter);
  7154. }
  7155. if (maxSize > list.size) {
  7156. list = list.setSize(maxSize);
  7157. }
  7158. return mergeIntoCollectionWith(list, merger, iters);
  7159. }
  7160. function getTailOffset(size) {
  7161. return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
  7162. }
  7163. createClass(OrderedMap, Map);
  7164. // @pragma Construction
  7165. function OrderedMap(value) {
  7166. return value === null || value === undefined ? emptyOrderedMap() :
  7167. isOrderedMap(value) ? value :
  7168. emptyOrderedMap().withMutations(function(map ) {
  7169. var iter = KeyedIterable(value);
  7170. assertNotInfinite(iter.size);
  7171. iter.forEach(function(v, k) {return map.set(k, v)});
  7172. });
  7173. }
  7174. OrderedMap.of = function(/*...values*/) {
  7175. return this(arguments);
  7176. };
  7177. OrderedMap.prototype.toString = function() {
  7178. return this.__toString('OrderedMap {', '}');
  7179. };
  7180. // @pragma Access
  7181. OrderedMap.prototype.get = function(k, notSetValue) {
  7182. var index = this._map.get(k);
  7183. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  7184. };
  7185. // @pragma Modification
  7186. OrderedMap.prototype.clear = function() {
  7187. if (this.size === 0) {
  7188. return this;
  7189. }
  7190. if (this.__ownerID) {
  7191. this.size = 0;
  7192. this._map.clear();
  7193. this._list.clear();
  7194. return this;
  7195. }
  7196. return emptyOrderedMap();
  7197. };
  7198. OrderedMap.prototype.set = function(k, v) {
  7199. return updateOrderedMap(this, k, v);
  7200. };
  7201. OrderedMap.prototype.remove = function(k) {
  7202. return updateOrderedMap(this, k, NOT_SET);
  7203. };
  7204. OrderedMap.prototype.wasAltered = function() {
  7205. return this._map.wasAltered() || this._list.wasAltered();
  7206. };
  7207. OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  7208. return this._list.__iterate(
  7209. function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
  7210. reverse
  7211. );
  7212. };
  7213. OrderedMap.prototype.__iterator = function(type, reverse) {
  7214. return this._list.fromEntrySeq().__iterator(type, reverse);
  7215. };
  7216. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  7217. if (ownerID === this.__ownerID) {
  7218. return this;
  7219. }
  7220. var newMap = this._map.__ensureOwner(ownerID);
  7221. var newList = this._list.__ensureOwner(ownerID);
  7222. if (!ownerID) {
  7223. this.__ownerID = ownerID;
  7224. this._map = newMap;
  7225. this._list = newList;
  7226. return this;
  7227. }
  7228. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  7229. };
  7230. function isOrderedMap(maybeOrderedMap) {
  7231. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  7232. }
  7233. OrderedMap.isOrderedMap = isOrderedMap;
  7234. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  7235. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  7236. function makeOrderedMap(map, list, ownerID, hash) {
  7237. var omap = Object.create(OrderedMap.prototype);
  7238. omap.size = map ? map.size : 0;
  7239. omap._map = map;
  7240. omap._list = list;
  7241. omap.__ownerID = ownerID;
  7242. omap.__hash = hash;
  7243. return omap;
  7244. }
  7245. var EMPTY_ORDERED_MAP;
  7246. function emptyOrderedMap() {
  7247. return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
  7248. }
  7249. function updateOrderedMap(omap, k, v) {
  7250. var map = omap._map;
  7251. var list = omap._list;
  7252. var i = map.get(k);
  7253. var has = i !== undefined;
  7254. var newMap;
  7255. var newList;
  7256. if (v === NOT_SET) { // removed
  7257. if (!has) {
  7258. return omap;
  7259. }
  7260. if (list.size >= SIZE && list.size >= map.size * 2) {
  7261. newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
  7262. newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
  7263. if (omap.__ownerID) {
  7264. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  7265. }
  7266. } else {
  7267. newMap = map.remove(k);
  7268. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  7269. }
  7270. } else {
  7271. if (has) {
  7272. if (v === list.get(i)[1]) {
  7273. return omap;
  7274. }
  7275. newMap = map;
  7276. newList = list.set(i, [k, v]);
  7277. } else {
  7278. newMap = map.set(k, list.size);
  7279. newList = list.set(list.size, [k, v]);
  7280. }
  7281. }
  7282. if (omap.__ownerID) {
  7283. omap.size = newMap.size;
  7284. omap._map = newMap;
  7285. omap._list = newList;
  7286. omap.__hash = undefined;
  7287. return omap;
  7288. }
  7289. return makeOrderedMap(newMap, newList);
  7290. }
  7291. createClass(ToKeyedSequence, KeyedSeq);
  7292. function ToKeyedSequence(indexed, useKeys) {
  7293. this._iter = indexed;
  7294. this._useKeys = useKeys;
  7295. this.size = indexed.size;
  7296. }
  7297. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  7298. return this._iter.get(key, notSetValue);
  7299. };
  7300. ToKeyedSequence.prototype.has = function(key) {
  7301. return this._iter.has(key);
  7302. };
  7303. ToKeyedSequence.prototype.valueSeq = function() {
  7304. return this._iter.valueSeq();
  7305. };
  7306. ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
  7307. var reversedSequence = reverseFactory(this, true);
  7308. if (!this._useKeys) {
  7309. reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
  7310. }
  7311. return reversedSequence;
  7312. };
  7313. ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
  7314. var mappedSequence = mapFactory(this, mapper, context);
  7315. if (!this._useKeys) {
  7316. mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
  7317. }
  7318. return mappedSequence;
  7319. };
  7320. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  7321. var ii;
  7322. return this._iter.__iterate(
  7323. this._useKeys ?
  7324. function(v, k) {return fn(v, k, this$0)} :
  7325. ((ii = reverse ? resolveSize(this) : 0),
  7326. function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
  7327. reverse
  7328. );
  7329. };
  7330. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  7331. if (this._useKeys) {
  7332. return this._iter.__iterator(type, reverse);
  7333. }
  7334. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  7335. var ii = reverse ? resolveSize(this) : 0;
  7336. return new Iterator(function() {
  7337. var step = iterator.next();
  7338. return step.done ? step :
  7339. iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  7340. });
  7341. };
  7342. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  7343. createClass(ToIndexedSequence, IndexedSeq);
  7344. function ToIndexedSequence(iter) {
  7345. this._iter = iter;
  7346. this.size = iter.size;
  7347. }
  7348. ToIndexedSequence.prototype.includes = function(value) {
  7349. return this._iter.includes(value);
  7350. };
  7351. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  7352. var iterations = 0;
  7353. return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
  7354. };
  7355. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  7356. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  7357. var iterations = 0;
  7358. return new Iterator(function() {
  7359. var step = iterator.next();
  7360. return step.done ? step :
  7361. iteratorValue(type, iterations++, step.value, step)
  7362. });
  7363. };
  7364. createClass(ToSetSequence, SetSeq);
  7365. function ToSetSequence(iter) {
  7366. this._iter = iter;
  7367. this.size = iter.size;
  7368. }
  7369. ToSetSequence.prototype.has = function(key) {
  7370. return this._iter.includes(key);
  7371. };
  7372. ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  7373. return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
  7374. };
  7375. ToSetSequence.prototype.__iterator = function(type, reverse) {
  7376. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  7377. return new Iterator(function() {
  7378. var step = iterator.next();
  7379. return step.done ? step :
  7380. iteratorValue(type, step.value, step.value, step);
  7381. });
  7382. };
  7383. createClass(FromEntriesSequence, KeyedSeq);
  7384. function FromEntriesSequence(entries) {
  7385. this._iter = entries;
  7386. this.size = entries.size;
  7387. }
  7388. FromEntriesSequence.prototype.entrySeq = function() {
  7389. return this._iter.toSeq();
  7390. };
  7391. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  7392. return this._iter.__iterate(function(entry ) {
  7393. // Check if entry exists first so array access doesn't throw for holes
  7394. // in the parent iteration.
  7395. if (entry) {
  7396. validateEntry(entry);
  7397. var indexedIterable = isIterable(entry);
  7398. return fn(
  7399. indexedIterable ? entry.get(1) : entry[1],
  7400. indexedIterable ? entry.get(0) : entry[0],
  7401. this$0
  7402. );
  7403. }
  7404. }, reverse);
  7405. };
  7406. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  7407. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  7408. return new Iterator(function() {
  7409. while (true) {
  7410. var step = iterator.next();
  7411. if (step.done) {
  7412. return step;
  7413. }
  7414. var entry = step.value;
  7415. // Check if entry exists first so array access doesn't throw for holes
  7416. // in the parent iteration.
  7417. if (entry) {
  7418. validateEntry(entry);
  7419. var indexedIterable = isIterable(entry);
  7420. return iteratorValue(
  7421. type,
  7422. indexedIterable ? entry.get(0) : entry[0],
  7423. indexedIterable ? entry.get(1) : entry[1],
  7424. step
  7425. );
  7426. }
  7427. }
  7428. });
  7429. };
  7430. ToIndexedSequence.prototype.cacheResult =
  7431. ToKeyedSequence.prototype.cacheResult =
  7432. ToSetSequence.prototype.cacheResult =
  7433. FromEntriesSequence.prototype.cacheResult =
  7434. cacheResultThrough;
  7435. function flipFactory(iterable) {
  7436. var flipSequence = makeSequence(iterable);
  7437. flipSequence._iter = iterable;
  7438. flipSequence.size = iterable.size;
  7439. flipSequence.flip = function() {return iterable};
  7440. flipSequence.reverse = function () {
  7441. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  7442. reversedSequence.flip = function() {return iterable.reverse()};
  7443. return reversedSequence;
  7444. };
  7445. flipSequence.has = function(key ) {return iterable.includes(key)};
  7446. flipSequence.includes = function(key ) {return iterable.has(key)};
  7447. flipSequence.cacheResult = cacheResultThrough;
  7448. flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  7449. return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
  7450. };
  7451. flipSequence.__iteratorUncached = function(type, reverse) {
  7452. if (type === ITERATE_ENTRIES) {
  7453. var iterator = iterable.__iterator(type, reverse);
  7454. return new Iterator(function() {
  7455. var step = iterator.next();
  7456. if (!step.done) {
  7457. var k = step.value[0];
  7458. step.value[0] = step.value[1];
  7459. step.value[1] = k;
  7460. }
  7461. return step;
  7462. });
  7463. }
  7464. return iterable.__iterator(
  7465. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  7466. reverse
  7467. );
  7468. };
  7469. return flipSequence;
  7470. }
  7471. function mapFactory(iterable, mapper, context) {
  7472. var mappedSequence = makeSequence(iterable);
  7473. mappedSequence.size = iterable.size;
  7474. mappedSequence.has = function(key ) {return iterable.has(key)};
  7475. mappedSequence.get = function(key, notSetValue) {
  7476. var v = iterable.get(key, NOT_SET);
  7477. return v === NOT_SET ?
  7478. notSetValue :
  7479. mapper.call(context, v, key, iterable);
  7480. };
  7481. mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  7482. return iterable.__iterate(
  7483. function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
  7484. reverse
  7485. );
  7486. };
  7487. mappedSequence.__iteratorUncached = function (type, reverse) {
  7488. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  7489. return new Iterator(function() {
  7490. var step = iterator.next();
  7491. if (step.done) {
  7492. return step;
  7493. }
  7494. var entry = step.value;
  7495. var key = entry[0];
  7496. return iteratorValue(
  7497. type,
  7498. key,
  7499. mapper.call(context, entry[1], key, iterable),
  7500. step
  7501. );
  7502. });
  7503. };
  7504. return mappedSequence;
  7505. }
  7506. function reverseFactory(iterable, useKeys) {
  7507. var reversedSequence = makeSequence(iterable);
  7508. reversedSequence._iter = iterable;
  7509. reversedSequence.size = iterable.size;
  7510. reversedSequence.reverse = function() {return iterable};
  7511. if (iterable.flip) {
  7512. reversedSequence.flip = function () {
  7513. var flipSequence = flipFactory(iterable);
  7514. flipSequence.reverse = function() {return iterable.flip()};
  7515. return flipSequence;
  7516. };
  7517. }
  7518. reversedSequence.get = function(key, notSetValue)
  7519. {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
  7520. reversedSequence.has = function(key )
  7521. {return iterable.has(useKeys ? key : -1 - key)};
  7522. reversedSequence.includes = function(value ) {return iterable.includes(value)};
  7523. reversedSequence.cacheResult = cacheResultThrough;
  7524. reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
  7525. return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
  7526. };
  7527. reversedSequence.__iterator =
  7528. function(type, reverse) {return iterable.__iterator(type, !reverse)};
  7529. return reversedSequence;
  7530. }
  7531. function filterFactory(iterable, predicate, context, useKeys) {
  7532. var filterSequence = makeSequence(iterable);
  7533. if (useKeys) {
  7534. filterSequence.has = function(key ) {
  7535. var v = iterable.get(key, NOT_SET);
  7536. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  7537. };
  7538. filterSequence.get = function(key, notSetValue) {
  7539. var v = iterable.get(key, NOT_SET);
  7540. return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
  7541. v : notSetValue;
  7542. };
  7543. }
  7544. filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  7545. var iterations = 0;
  7546. iterable.__iterate(function(v, k, c) {
  7547. if (predicate.call(context, v, k, c)) {
  7548. iterations++;
  7549. return fn(v, useKeys ? k : iterations - 1, this$0);
  7550. }
  7551. }, reverse);
  7552. return iterations;
  7553. };
  7554. filterSequence.__iteratorUncached = function (type, reverse) {
  7555. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  7556. var iterations = 0;
  7557. return new Iterator(function() {
  7558. while (true) {
  7559. var step = iterator.next();
  7560. if (step.done) {
  7561. return step;
  7562. }
  7563. var entry = step.value;
  7564. var key = entry[0];
  7565. var value = entry[1];
  7566. if (predicate.call(context, value, key, iterable)) {
  7567. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  7568. }
  7569. }
  7570. });
  7571. };
  7572. return filterSequence;
  7573. }
  7574. function countByFactory(iterable, grouper, context) {
  7575. var groups = Map().asMutable();
  7576. iterable.__iterate(function(v, k) {
  7577. groups.update(
  7578. grouper.call(context, v, k, iterable),
  7579. 0,
  7580. function(a ) {return a + 1}
  7581. );
  7582. });
  7583. return groups.asImmutable();
  7584. }
  7585. function groupByFactory(iterable, grouper, context) {
  7586. var isKeyedIter = isKeyed(iterable);
  7587. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  7588. iterable.__iterate(function(v, k) {
  7589. groups.update(
  7590. grouper.call(context, v, k, iterable),
  7591. function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
  7592. );
  7593. });
  7594. var coerce = iterableClass(iterable);
  7595. return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
  7596. }
  7597. function sliceFactory(iterable, begin, end, useKeys) {
  7598. var originalSize = iterable.size;
  7599. // Sanitize begin & end using this shorthand for ToInt32(argument)
  7600. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  7601. if (begin !== undefined) {
  7602. begin = begin | 0;
  7603. }
  7604. if (end !== undefined) {
  7605. end = end | 0;
  7606. }
  7607. if (wholeSlice(begin, end, originalSize)) {
  7608. return iterable;
  7609. }
  7610. var resolvedBegin = resolveBegin(begin, originalSize);
  7611. var resolvedEnd = resolveEnd(end, originalSize);
  7612. // begin or end will be NaN if they were provided as negative numbers and
  7613. // this iterable's size is unknown. In that case, cache first so there is
  7614. // a known size and these do not resolve to NaN.
  7615. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  7616. return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
  7617. }
  7618. // Note: resolvedEnd is undefined when the original sequence's length is
  7619. // unknown and this slice did not supply an end and should contain all
  7620. // elements after resolvedBegin.
  7621. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  7622. var resolvedSize = resolvedEnd - resolvedBegin;
  7623. var sliceSize;
  7624. if (resolvedSize === resolvedSize) {
  7625. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  7626. }
  7627. var sliceSeq = makeSequence(iterable);
  7628. // If iterable.size is undefined, the size of the realized sliceSeq is
  7629. // unknown at this point unless the number of items to slice is 0
  7630. sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
  7631. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  7632. sliceSeq.get = function (index, notSetValue) {
  7633. index = wrapIndex(this, index);
  7634. return index >= 0 && index < sliceSize ?
  7635. iterable.get(index + resolvedBegin, notSetValue) :
  7636. notSetValue;
  7637. };
  7638. }
  7639. sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
  7640. if (sliceSize === 0) {
  7641. return 0;
  7642. }
  7643. if (reverse) {
  7644. return this.cacheResult().__iterate(fn, reverse);
  7645. }
  7646. var skipped = 0;
  7647. var isSkipping = true;
  7648. var iterations = 0;
  7649. iterable.__iterate(function(v, k) {
  7650. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  7651. iterations++;
  7652. return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  7653. iterations !== sliceSize;
  7654. }
  7655. });
  7656. return iterations;
  7657. };
  7658. sliceSeq.__iteratorUncached = function(type, reverse) {
  7659. if (sliceSize !== 0 && reverse) {
  7660. return this.cacheResult().__iterator(type, reverse);
  7661. }
  7662. // Don't bother instantiating parent iterator if taking 0.
  7663. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  7664. var skipped = 0;
  7665. var iterations = 0;
  7666. return new Iterator(function() {
  7667. while (skipped++ < resolvedBegin) {
  7668. iterator.next();
  7669. }
  7670. if (++iterations > sliceSize) {
  7671. return iteratorDone();
  7672. }
  7673. var step = iterator.next();
  7674. if (useKeys || type === ITERATE_VALUES) {
  7675. return step;
  7676. } else if (type === ITERATE_KEYS) {
  7677. return iteratorValue(type, iterations - 1, undefined, step);
  7678. } else {
  7679. return iteratorValue(type, iterations - 1, step.value[1], step);
  7680. }
  7681. });
  7682. };
  7683. return sliceSeq;
  7684. }
  7685. function takeWhileFactory(iterable, predicate, context) {
  7686. var takeSequence = makeSequence(iterable);
  7687. takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  7688. if (reverse) {
  7689. return this.cacheResult().__iterate(fn, reverse);
  7690. }
  7691. var iterations = 0;
  7692. iterable.__iterate(function(v, k, c)
  7693. {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
  7694. );
  7695. return iterations;
  7696. };
  7697. takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  7698. if (reverse) {
  7699. return this.cacheResult().__iterator(type, reverse);
  7700. }
  7701. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  7702. var iterating = true;
  7703. return new Iterator(function() {
  7704. if (!iterating) {
  7705. return iteratorDone();
  7706. }
  7707. var step = iterator.next();
  7708. if (step.done) {
  7709. return step;
  7710. }
  7711. var entry = step.value;
  7712. var k = entry[0];
  7713. var v = entry[1];
  7714. if (!predicate.call(context, v, k, this$0)) {
  7715. iterating = false;
  7716. return iteratorDone();
  7717. }
  7718. return type === ITERATE_ENTRIES ? step :
  7719. iteratorValue(type, k, v, step);
  7720. });
  7721. };
  7722. return takeSequence;
  7723. }
  7724. function skipWhileFactory(iterable, predicate, context, useKeys) {
  7725. var skipSequence = makeSequence(iterable);
  7726. skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  7727. if (reverse) {
  7728. return this.cacheResult().__iterate(fn, reverse);
  7729. }
  7730. var isSkipping = true;
  7731. var iterations = 0;
  7732. iterable.__iterate(function(v, k, c) {
  7733. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  7734. iterations++;
  7735. return fn(v, useKeys ? k : iterations - 1, this$0);
  7736. }
  7737. });
  7738. return iterations;
  7739. };
  7740. skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  7741. if (reverse) {
  7742. return this.cacheResult().__iterator(type, reverse);
  7743. }
  7744. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  7745. var skipping = true;
  7746. var iterations = 0;
  7747. return new Iterator(function() {
  7748. var step, k, v;
  7749. do {
  7750. step = iterator.next();
  7751. if (step.done) {
  7752. if (useKeys || type === ITERATE_VALUES) {
  7753. return step;
  7754. } else if (type === ITERATE_KEYS) {
  7755. return iteratorValue(type, iterations++, undefined, step);
  7756. } else {
  7757. return iteratorValue(type, iterations++, step.value[1], step);
  7758. }
  7759. }
  7760. var entry = step.value;
  7761. k = entry[0];
  7762. v = entry[1];
  7763. skipping && (skipping = predicate.call(context, v, k, this$0));
  7764. } while (skipping);
  7765. return type === ITERATE_ENTRIES ? step :
  7766. iteratorValue(type, k, v, step);
  7767. });
  7768. };
  7769. return skipSequence;
  7770. }
  7771. function concatFactory(iterable, values) {
  7772. var isKeyedIterable = isKeyed(iterable);
  7773. var iters = [iterable].concat(values).map(function(v ) {
  7774. if (!isIterable(v)) {
  7775. v = isKeyedIterable ?
  7776. keyedSeqFromValue(v) :
  7777. indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  7778. } else if (isKeyedIterable) {
  7779. v = KeyedIterable(v);
  7780. }
  7781. return v;
  7782. }).filter(function(v ) {return v.size !== 0});
  7783. if (iters.length === 0) {
  7784. return iterable;
  7785. }
  7786. if (iters.length === 1) {
  7787. var singleton = iters[0];
  7788. if (singleton === iterable ||
  7789. isKeyedIterable && isKeyed(singleton) ||
  7790. isIndexed(iterable) && isIndexed(singleton)) {
  7791. return singleton;
  7792. }
  7793. }
  7794. var concatSeq = new ArraySeq(iters);
  7795. if (isKeyedIterable) {
  7796. concatSeq = concatSeq.toKeyedSeq();
  7797. } else if (!isIndexed(iterable)) {
  7798. concatSeq = concatSeq.toSetSeq();
  7799. }
  7800. concatSeq = concatSeq.flatten(true);
  7801. concatSeq.size = iters.reduce(
  7802. function(sum, seq) {
  7803. if (sum !== undefined) {
  7804. var size = seq.size;
  7805. if (size !== undefined) {
  7806. return sum + size;
  7807. }
  7808. }
  7809. },
  7810. 0
  7811. );
  7812. return concatSeq;
  7813. }
  7814. function flattenFactory(iterable, depth, useKeys) {
  7815. var flatSequence = makeSequence(iterable);
  7816. flatSequence.__iterateUncached = function(fn, reverse) {
  7817. var iterations = 0;
  7818. var stopped = false;
  7819. function flatDeep(iter, currentDepth) {var this$0 = this;
  7820. iter.__iterate(function(v, k) {
  7821. if ((!depth || currentDepth < depth) && isIterable(v)) {
  7822. flatDeep(v, currentDepth + 1);
  7823. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  7824. stopped = true;
  7825. }
  7826. return !stopped;
  7827. }, reverse);
  7828. }
  7829. flatDeep(iterable, 0);
  7830. return iterations;
  7831. };
  7832. flatSequence.__iteratorUncached = function(type, reverse) {
  7833. var iterator = iterable.__iterator(type, reverse);
  7834. var stack = [];
  7835. var iterations = 0;
  7836. return new Iterator(function() {
  7837. while (iterator) {
  7838. var step = iterator.next();
  7839. if (step.done !== false) {
  7840. iterator = stack.pop();
  7841. continue;
  7842. }
  7843. var v = step.value;
  7844. if (type === ITERATE_ENTRIES) {
  7845. v = v[1];
  7846. }
  7847. if ((!depth || stack.length < depth) && isIterable(v)) {
  7848. stack.push(iterator);
  7849. iterator = v.__iterator(type, reverse);
  7850. } else {
  7851. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  7852. }
  7853. }
  7854. return iteratorDone();
  7855. });
  7856. };
  7857. return flatSequence;
  7858. }
  7859. function flatMapFactory(iterable, mapper, context) {
  7860. var coerce = iterableClass(iterable);
  7861. return iterable.toSeq().map(
  7862. function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
  7863. ).flatten(true);
  7864. }
  7865. function interposeFactory(iterable, separator) {
  7866. var interposedSequence = makeSequence(iterable);
  7867. interposedSequence.size = iterable.size && iterable.size * 2 -1;
  7868. interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  7869. var iterations = 0;
  7870. iterable.__iterate(function(v, k)
  7871. {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
  7872. fn(v, iterations++, this$0) !== false},
  7873. reverse
  7874. );
  7875. return iterations;
  7876. };
  7877. interposedSequence.__iteratorUncached = function(type, reverse) {
  7878. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  7879. var iterations = 0;
  7880. var step;
  7881. return new Iterator(function() {
  7882. if (!step || iterations % 2) {
  7883. step = iterator.next();
  7884. if (step.done) {
  7885. return step;
  7886. }
  7887. }
  7888. return iterations % 2 ?
  7889. iteratorValue(type, iterations++, separator) :
  7890. iteratorValue(type, iterations++, step.value, step);
  7891. });
  7892. };
  7893. return interposedSequence;
  7894. }
  7895. function sortFactory(iterable, comparator, mapper) {
  7896. if (!comparator) {
  7897. comparator = defaultComparator;
  7898. }
  7899. var isKeyedIterable = isKeyed(iterable);
  7900. var index = 0;
  7901. var entries = iterable.toSeq().map(
  7902. function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
  7903. ).toArray();
  7904. entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
  7905. isKeyedIterable ?
  7906. function(v, i) { entries[i].length = 2; } :
  7907. function(v, i) { entries[i] = v[1]; }
  7908. );
  7909. return isKeyedIterable ? KeyedSeq(entries) :
  7910. isIndexed(iterable) ? IndexedSeq(entries) :
  7911. SetSeq(entries);
  7912. }
  7913. function maxFactory(iterable, comparator, mapper) {
  7914. if (!comparator) {
  7915. comparator = defaultComparator;
  7916. }
  7917. if (mapper) {
  7918. var entry = iterable.toSeq()
  7919. .map(function(v, k) {return [v, mapper(v, k, iterable)]})
  7920. .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
  7921. return entry && entry[0];
  7922. } else {
  7923. return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
  7924. }
  7925. }
  7926. function maxCompare(comparator, a, b) {
  7927. var comp = comparator(b, a);
  7928. // b is considered the new max if the comparator declares them equal, but
  7929. // they are not equal and b is in fact a nullish value.
  7930. return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
  7931. }
  7932. function zipWithFactory(keyIter, zipper, iters) {
  7933. var zipSequence = makeSequence(keyIter);
  7934. zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
  7935. // Note: this a generic base implementation of __iterate in terms of
  7936. // __iterator which may be more generically useful in the future.
  7937. zipSequence.__iterate = function(fn, reverse) {
  7938. /* generic:
  7939. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  7940. var step;
  7941. var iterations = 0;
  7942. while (!(step = iterator.next()).done) {
  7943. iterations++;
  7944. if (fn(step.value[1], step.value[0], this) === false) {
  7945. break;
  7946. }
  7947. }
  7948. return iterations;
  7949. */
  7950. // indexed:
  7951. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  7952. var step;
  7953. var iterations = 0;
  7954. while (!(step = iterator.next()).done) {
  7955. if (fn(step.value, iterations++, this) === false) {
  7956. break;
  7957. }
  7958. }
  7959. return iterations;
  7960. };
  7961. zipSequence.__iteratorUncached = function(type, reverse) {
  7962. var iterators = iters.map(function(i )
  7963. {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
  7964. );
  7965. var iterations = 0;
  7966. var isDone = false;
  7967. return new Iterator(function() {
  7968. var steps;
  7969. if (!isDone) {
  7970. steps = iterators.map(function(i ) {return i.next()});
  7971. isDone = steps.some(function(s ) {return s.done});
  7972. }
  7973. if (isDone) {
  7974. return iteratorDone();
  7975. }
  7976. return iteratorValue(
  7977. type,
  7978. iterations++,
  7979. zipper.apply(null, steps.map(function(s ) {return s.value}))
  7980. );
  7981. });
  7982. };
  7983. return zipSequence
  7984. }
  7985. // #pragma Helper Functions
  7986. function reify(iter, seq) {
  7987. return isSeq(iter) ? seq : iter.constructor(seq);
  7988. }
  7989. function validateEntry(entry) {
  7990. if (entry !== Object(entry)) {
  7991. throw new TypeError('Expected [K, V] tuple: ' + entry);
  7992. }
  7993. }
  7994. function resolveSize(iter) {
  7995. assertNotInfinite(iter.size);
  7996. return ensureSize(iter);
  7997. }
  7998. function iterableClass(iterable) {
  7999. return isKeyed(iterable) ? KeyedIterable :
  8000. isIndexed(iterable) ? IndexedIterable :
  8001. SetIterable;
  8002. }
  8003. function makeSequence(iterable) {
  8004. return Object.create(
  8005. (
  8006. isKeyed(iterable) ? KeyedSeq :
  8007. isIndexed(iterable) ? IndexedSeq :
  8008. SetSeq
  8009. ).prototype
  8010. );
  8011. }
  8012. function cacheResultThrough() {
  8013. if (this._iter.cacheResult) {
  8014. this._iter.cacheResult();
  8015. this.size = this._iter.size;
  8016. return this;
  8017. } else {
  8018. return Seq.prototype.cacheResult.call(this);
  8019. }
  8020. }
  8021. function defaultComparator(a, b) {
  8022. return a > b ? 1 : a < b ? -1 : 0;
  8023. }
  8024. function forceIterator(keyPath) {
  8025. var iter = getIterator(keyPath);
  8026. if (!iter) {
  8027. // Array might not be iterable in this environment, so we need a fallback
  8028. // to our wrapped type.
  8029. if (!isArrayLike(keyPath)) {
  8030. throw new TypeError('Expected iterable or array-like: ' + keyPath);
  8031. }
  8032. iter = getIterator(Iterable(keyPath));
  8033. }
  8034. return iter;
  8035. }
  8036. createClass(Record, KeyedCollection);
  8037. function Record(defaultValues, name) {
  8038. var hasInitialized;
  8039. var RecordType = function Record(values) {
  8040. if (values instanceof RecordType) {
  8041. return values;
  8042. }
  8043. if (!(this instanceof RecordType)) {
  8044. return new RecordType(values);
  8045. }
  8046. if (!hasInitialized) {
  8047. hasInitialized = true;
  8048. var keys = Object.keys(defaultValues);
  8049. setProps(RecordTypePrototype, keys);
  8050. RecordTypePrototype.size = keys.length;
  8051. RecordTypePrototype._name = name;
  8052. RecordTypePrototype._keys = keys;
  8053. RecordTypePrototype._defaultValues = defaultValues;
  8054. }
  8055. this._map = Map(values);
  8056. };
  8057. var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
  8058. RecordTypePrototype.constructor = RecordType;
  8059. return RecordType;
  8060. }
  8061. Record.prototype.toString = function() {
  8062. return this.__toString(recordName(this) + ' {', '}');
  8063. };
  8064. // @pragma Access
  8065. Record.prototype.has = function(k) {
  8066. return this._defaultValues.hasOwnProperty(k);
  8067. };
  8068. Record.prototype.get = function(k, notSetValue) {
  8069. if (!this.has(k)) {
  8070. return notSetValue;
  8071. }
  8072. var defaultVal = this._defaultValues[k];
  8073. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  8074. };
  8075. // @pragma Modification
  8076. Record.prototype.clear = function() {
  8077. if (this.__ownerID) {
  8078. this._map && this._map.clear();
  8079. return this;
  8080. }
  8081. var RecordType = this.constructor;
  8082. return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
  8083. };
  8084. Record.prototype.set = function(k, v) {
  8085. if (!this.has(k)) {
  8086. throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
  8087. }
  8088. var newMap = this._map && this._map.set(k, v);
  8089. if (this.__ownerID || newMap === this._map) {
  8090. return this;
  8091. }
  8092. return makeRecord(this, newMap);
  8093. };
  8094. Record.prototype.remove = function(k) {
  8095. if (!this.has(k)) {
  8096. return this;
  8097. }
  8098. var newMap = this._map && this._map.remove(k);
  8099. if (this.__ownerID || newMap === this._map) {
  8100. return this;
  8101. }
  8102. return makeRecord(this, newMap);
  8103. };
  8104. Record.prototype.wasAltered = function() {
  8105. return this._map.wasAltered();
  8106. };
  8107. Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
  8108. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
  8109. };
  8110. Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8111. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
  8112. };
  8113. Record.prototype.__ensureOwner = function(ownerID) {
  8114. if (ownerID === this.__ownerID) {
  8115. return this;
  8116. }
  8117. var newMap = this._map && this._map.__ensureOwner(ownerID);
  8118. if (!ownerID) {
  8119. this.__ownerID = ownerID;
  8120. this._map = newMap;
  8121. return this;
  8122. }
  8123. return makeRecord(this, newMap, ownerID);
  8124. };
  8125. var RecordPrototype = Record.prototype;
  8126. RecordPrototype[DELETE] = RecordPrototype.remove;
  8127. RecordPrototype.deleteIn =
  8128. RecordPrototype.removeIn = MapPrototype.removeIn;
  8129. RecordPrototype.merge = MapPrototype.merge;
  8130. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  8131. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  8132. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  8133. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  8134. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  8135. RecordPrototype.setIn = MapPrototype.setIn;
  8136. RecordPrototype.update = MapPrototype.update;
  8137. RecordPrototype.updateIn = MapPrototype.updateIn;
  8138. RecordPrototype.withMutations = MapPrototype.withMutations;
  8139. RecordPrototype.asMutable = MapPrototype.asMutable;
  8140. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  8141. function makeRecord(likeRecord, map, ownerID) {
  8142. var record = Object.create(Object.getPrototypeOf(likeRecord));
  8143. record._map = map;
  8144. record.__ownerID = ownerID;
  8145. return record;
  8146. }
  8147. function recordName(record) {
  8148. return record._name || record.constructor.name || 'Record';
  8149. }
  8150. function setProps(prototype, names) {
  8151. try {
  8152. names.forEach(setProp.bind(undefined, prototype));
  8153. } catch (error) {
  8154. // Object.defineProperty failed. Probably IE8.
  8155. }
  8156. }
  8157. function setProp(prototype, name) {
  8158. Object.defineProperty(prototype, name, {
  8159. get: function() {
  8160. return this.get(name);
  8161. },
  8162. set: function(value) {
  8163. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  8164. this.set(name, value);
  8165. }
  8166. });
  8167. }
  8168. createClass(Set, SetCollection);
  8169. // @pragma Construction
  8170. function Set(value) {
  8171. return value === null || value === undefined ? emptySet() :
  8172. isSet(value) && !isOrdered(value) ? value :
  8173. emptySet().withMutations(function(set ) {
  8174. var iter = SetIterable(value);
  8175. assertNotInfinite(iter.size);
  8176. iter.forEach(function(v ) {return set.add(v)});
  8177. });
  8178. }
  8179. Set.of = function(/*...values*/) {
  8180. return this(arguments);
  8181. };
  8182. Set.fromKeys = function(value) {
  8183. return this(KeyedIterable(value).keySeq());
  8184. };
  8185. Set.prototype.toString = function() {
  8186. return this.__toString('Set {', '}');
  8187. };
  8188. // @pragma Access
  8189. Set.prototype.has = function(value) {
  8190. return this._map.has(value);
  8191. };
  8192. // @pragma Modification
  8193. Set.prototype.add = function(value) {
  8194. return updateSet(this, this._map.set(value, true));
  8195. };
  8196. Set.prototype.remove = function(value) {
  8197. return updateSet(this, this._map.remove(value));
  8198. };
  8199. Set.prototype.clear = function() {
  8200. return updateSet(this, this._map.clear());
  8201. };
  8202. // @pragma Composition
  8203. Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
  8204. iters = iters.filter(function(x ) {return x.size !== 0});
  8205. if (iters.length === 0) {
  8206. return this;
  8207. }
  8208. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  8209. return this.constructor(iters[0]);
  8210. }
  8211. return this.withMutations(function(set ) {
  8212. for (var ii = 0; ii < iters.length; ii++) {
  8213. SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
  8214. }
  8215. });
  8216. };
  8217. Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
  8218. if (iters.length === 0) {
  8219. return this;
  8220. }
  8221. iters = iters.map(function(iter ) {return SetIterable(iter)});
  8222. var originalSet = this;
  8223. return this.withMutations(function(set ) {
  8224. originalSet.forEach(function(value ) {
  8225. if (!iters.every(function(iter ) {return iter.includes(value)})) {
  8226. set.remove(value);
  8227. }
  8228. });
  8229. });
  8230. };
  8231. Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
  8232. if (iters.length === 0) {
  8233. return this;
  8234. }
  8235. iters = iters.map(function(iter ) {return SetIterable(iter)});
  8236. var originalSet = this;
  8237. return this.withMutations(function(set ) {
  8238. originalSet.forEach(function(value ) {
  8239. if (iters.some(function(iter ) {return iter.includes(value)})) {
  8240. set.remove(value);
  8241. }
  8242. });
  8243. });
  8244. };
  8245. Set.prototype.merge = function() {
  8246. return this.union.apply(this, arguments);
  8247. };
  8248. Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  8249. return this.union.apply(this, iters);
  8250. };
  8251. Set.prototype.sort = function(comparator) {
  8252. // Late binding
  8253. return OrderedSet(sortFactory(this, comparator));
  8254. };
  8255. Set.prototype.sortBy = function(mapper, comparator) {
  8256. // Late binding
  8257. return OrderedSet(sortFactory(this, comparator, mapper));
  8258. };
  8259. Set.prototype.wasAltered = function() {
  8260. return this._map.wasAltered();
  8261. };
  8262. Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8263. return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
  8264. };
  8265. Set.prototype.__iterator = function(type, reverse) {
  8266. return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
  8267. };
  8268. Set.prototype.__ensureOwner = function(ownerID) {
  8269. if (ownerID === this.__ownerID) {
  8270. return this;
  8271. }
  8272. var newMap = this._map.__ensureOwner(ownerID);
  8273. if (!ownerID) {
  8274. this.__ownerID = ownerID;
  8275. this._map = newMap;
  8276. return this;
  8277. }
  8278. return this.__make(newMap, ownerID);
  8279. };
  8280. function isSet(maybeSet) {
  8281. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  8282. }
  8283. Set.isSet = isSet;
  8284. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  8285. var SetPrototype = Set.prototype;
  8286. SetPrototype[IS_SET_SENTINEL] = true;
  8287. SetPrototype[DELETE] = SetPrototype.remove;
  8288. SetPrototype.mergeDeep = SetPrototype.merge;
  8289. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  8290. SetPrototype.withMutations = MapPrototype.withMutations;
  8291. SetPrototype.asMutable = MapPrototype.asMutable;
  8292. SetPrototype.asImmutable = MapPrototype.asImmutable;
  8293. SetPrototype.__empty = emptySet;
  8294. SetPrototype.__make = makeSet;
  8295. function updateSet(set, newMap) {
  8296. if (set.__ownerID) {
  8297. set.size = newMap.size;
  8298. set._map = newMap;
  8299. return set;
  8300. }
  8301. return newMap === set._map ? set :
  8302. newMap.size === 0 ? set.__empty() :
  8303. set.__make(newMap);
  8304. }
  8305. function makeSet(map, ownerID) {
  8306. var set = Object.create(SetPrototype);
  8307. set.size = map ? map.size : 0;
  8308. set._map = map;
  8309. set.__ownerID = ownerID;
  8310. return set;
  8311. }
  8312. var EMPTY_SET;
  8313. function emptySet() {
  8314. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  8315. }
  8316. createClass(OrderedSet, Set);
  8317. // @pragma Construction
  8318. function OrderedSet(value) {
  8319. return value === null || value === undefined ? emptyOrderedSet() :
  8320. isOrderedSet(value) ? value :
  8321. emptyOrderedSet().withMutations(function(set ) {
  8322. var iter = SetIterable(value);
  8323. assertNotInfinite(iter.size);
  8324. iter.forEach(function(v ) {return set.add(v)});
  8325. });
  8326. }
  8327. OrderedSet.of = function(/*...values*/) {
  8328. return this(arguments);
  8329. };
  8330. OrderedSet.fromKeys = function(value) {
  8331. return this(KeyedIterable(value).keySeq());
  8332. };
  8333. OrderedSet.prototype.toString = function() {
  8334. return this.__toString('OrderedSet {', '}');
  8335. };
  8336. function isOrderedSet(maybeOrderedSet) {
  8337. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  8338. }
  8339. OrderedSet.isOrderedSet = isOrderedSet;
  8340. var OrderedSetPrototype = OrderedSet.prototype;
  8341. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  8342. OrderedSetPrototype.__empty = emptyOrderedSet;
  8343. OrderedSetPrototype.__make = makeOrderedSet;
  8344. function makeOrderedSet(map, ownerID) {
  8345. var set = Object.create(OrderedSetPrototype);
  8346. set.size = map ? map.size : 0;
  8347. set._map = map;
  8348. set.__ownerID = ownerID;
  8349. return set;
  8350. }
  8351. var EMPTY_ORDERED_SET;
  8352. function emptyOrderedSet() {
  8353. return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
  8354. }
  8355. createClass(Stack, IndexedCollection);
  8356. // @pragma Construction
  8357. function Stack(value) {
  8358. return value === null || value === undefined ? emptyStack() :
  8359. isStack(value) ? value :
  8360. emptyStack().unshiftAll(value);
  8361. }
  8362. Stack.of = function(/*...values*/) {
  8363. return this(arguments);
  8364. };
  8365. Stack.prototype.toString = function() {
  8366. return this.__toString('Stack [', ']');
  8367. };
  8368. // @pragma Access
  8369. Stack.prototype.get = function(index, notSetValue) {
  8370. var head = this._head;
  8371. index = wrapIndex(this, index);
  8372. while (head && index--) {
  8373. head = head.next;
  8374. }
  8375. return head ? head.value : notSetValue;
  8376. };
  8377. Stack.prototype.peek = function() {
  8378. return this._head && this._head.value;
  8379. };
  8380. // @pragma Modification
  8381. Stack.prototype.push = function(/*...values*/) {
  8382. if (arguments.length === 0) {
  8383. return this;
  8384. }
  8385. var newSize = this.size + arguments.length;
  8386. var head = this._head;
  8387. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  8388. head = {
  8389. value: arguments[ii],
  8390. next: head
  8391. };
  8392. }
  8393. if (this.__ownerID) {
  8394. this.size = newSize;
  8395. this._head = head;
  8396. this.__hash = undefined;
  8397. this.__altered = true;
  8398. return this;
  8399. }
  8400. return makeStack(newSize, head);
  8401. };
  8402. Stack.prototype.pushAll = function(iter) {
  8403. iter = IndexedIterable(iter);
  8404. if (iter.size === 0) {
  8405. return this;
  8406. }
  8407. assertNotInfinite(iter.size);
  8408. var newSize = this.size;
  8409. var head = this._head;
  8410. iter.reverse().forEach(function(value ) {
  8411. newSize++;
  8412. head = {
  8413. value: value,
  8414. next: head
  8415. };
  8416. });
  8417. if (this.__ownerID) {
  8418. this.size = newSize;
  8419. this._head = head;
  8420. this.__hash = undefined;
  8421. this.__altered = true;
  8422. return this;
  8423. }
  8424. return makeStack(newSize, head);
  8425. };
  8426. Stack.prototype.pop = function() {
  8427. return this.slice(1);
  8428. };
  8429. Stack.prototype.unshift = function(/*...values*/) {
  8430. return this.push.apply(this, arguments);
  8431. };
  8432. Stack.prototype.unshiftAll = function(iter) {
  8433. return this.pushAll(iter);
  8434. };
  8435. Stack.prototype.shift = function() {
  8436. return this.pop.apply(this, arguments);
  8437. };
  8438. Stack.prototype.clear = function() {
  8439. if (this.size === 0) {
  8440. return this;
  8441. }
  8442. if (this.__ownerID) {
  8443. this.size = 0;
  8444. this._head = undefined;
  8445. this.__hash = undefined;
  8446. this.__altered = true;
  8447. return this;
  8448. }
  8449. return emptyStack();
  8450. };
  8451. Stack.prototype.slice = function(begin, end) {
  8452. if (wholeSlice(begin, end, this.size)) {
  8453. return this;
  8454. }
  8455. var resolvedBegin = resolveBegin(begin, this.size);
  8456. var resolvedEnd = resolveEnd(end, this.size);
  8457. if (resolvedEnd !== this.size) {
  8458. // super.slice(begin, end);
  8459. return IndexedCollection.prototype.slice.call(this, begin, end);
  8460. }
  8461. var newSize = this.size - resolvedBegin;
  8462. var head = this._head;
  8463. while (resolvedBegin--) {
  8464. head = head.next;
  8465. }
  8466. if (this.__ownerID) {
  8467. this.size = newSize;
  8468. this._head = head;
  8469. this.__hash = undefined;
  8470. this.__altered = true;
  8471. return this;
  8472. }
  8473. return makeStack(newSize, head);
  8474. };
  8475. // @pragma Mutability
  8476. Stack.prototype.__ensureOwner = function(ownerID) {
  8477. if (ownerID === this.__ownerID) {
  8478. return this;
  8479. }
  8480. if (!ownerID) {
  8481. this.__ownerID = ownerID;
  8482. this.__altered = false;
  8483. return this;
  8484. }
  8485. return makeStack(this.size, this._head, ownerID, this.__hash);
  8486. };
  8487. // @pragma Iteration
  8488. Stack.prototype.__iterate = function(fn, reverse) {
  8489. if (reverse) {
  8490. return this.reverse().__iterate(fn);
  8491. }
  8492. var iterations = 0;
  8493. var node = this._head;
  8494. while (node) {
  8495. if (fn(node.value, iterations++, this) === false) {
  8496. break;
  8497. }
  8498. node = node.next;
  8499. }
  8500. return iterations;
  8501. };
  8502. Stack.prototype.__iterator = function(type, reverse) {
  8503. if (reverse) {
  8504. return this.reverse().__iterator(type);
  8505. }
  8506. var iterations = 0;
  8507. var node = this._head;
  8508. return new Iterator(function() {
  8509. if (node) {
  8510. var value = node.value;
  8511. node = node.next;
  8512. return iteratorValue(type, iterations++, value);
  8513. }
  8514. return iteratorDone();
  8515. });
  8516. };
  8517. function isStack(maybeStack) {
  8518. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  8519. }
  8520. Stack.isStack = isStack;
  8521. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  8522. var StackPrototype = Stack.prototype;
  8523. StackPrototype[IS_STACK_SENTINEL] = true;
  8524. StackPrototype.withMutations = MapPrototype.withMutations;
  8525. StackPrototype.asMutable = MapPrototype.asMutable;
  8526. StackPrototype.asImmutable = MapPrototype.asImmutable;
  8527. StackPrototype.wasAltered = MapPrototype.wasAltered;
  8528. function makeStack(size, head, ownerID, hash) {
  8529. var map = Object.create(StackPrototype);
  8530. map.size = size;
  8531. map._head = head;
  8532. map.__ownerID = ownerID;
  8533. map.__hash = hash;
  8534. map.__altered = false;
  8535. return map;
  8536. }
  8537. var EMPTY_STACK;
  8538. function emptyStack() {
  8539. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  8540. }
  8541. /**
  8542. * Contributes additional methods to a constructor
  8543. */
  8544. function mixin(ctor, methods) {
  8545. var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
  8546. Object.keys(methods).forEach(keyCopier);
  8547. Object.getOwnPropertySymbols &&
  8548. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  8549. return ctor;
  8550. }
  8551. Iterable.Iterator = Iterator;
  8552. mixin(Iterable, {
  8553. // ### Conversion to other types
  8554. toArray: function() {
  8555. assertNotInfinite(this.size);
  8556. var array = new Array(this.size || 0);
  8557. this.valueSeq().__iterate(function(v, i) { array[i] = v; });
  8558. return array;
  8559. },
  8560. toIndexedSeq: function() {
  8561. return new ToIndexedSequence(this);
  8562. },
  8563. toJS: function() {
  8564. return this.toSeq().map(
  8565. function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
  8566. ).__toJS();
  8567. },
  8568. toJSON: function() {
  8569. return this.toSeq().map(
  8570. function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
  8571. ).__toJS();
  8572. },
  8573. toKeyedSeq: function() {
  8574. return new ToKeyedSequence(this, true);
  8575. },
  8576. toMap: function() {
  8577. // Use Late Binding here to solve the circular dependency.
  8578. return Map(this.toKeyedSeq());
  8579. },
  8580. toObject: function() {
  8581. assertNotInfinite(this.size);
  8582. var object = {};
  8583. this.__iterate(function(v, k) { object[k] = v; });
  8584. return object;
  8585. },
  8586. toOrderedMap: function() {
  8587. // Use Late Binding here to solve the circular dependency.
  8588. return OrderedMap(this.toKeyedSeq());
  8589. },
  8590. toOrderedSet: function() {
  8591. // Use Late Binding here to solve the circular dependency.
  8592. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  8593. },
  8594. toSet: function() {
  8595. // Use Late Binding here to solve the circular dependency.
  8596. return Set(isKeyed(this) ? this.valueSeq() : this);
  8597. },
  8598. toSetSeq: function() {
  8599. return new ToSetSequence(this);
  8600. },
  8601. toSeq: function() {
  8602. return isIndexed(this) ? this.toIndexedSeq() :
  8603. isKeyed(this) ? this.toKeyedSeq() :
  8604. this.toSetSeq();
  8605. },
  8606. toStack: function() {
  8607. // Use Late Binding here to solve the circular dependency.
  8608. return Stack(isKeyed(this) ? this.valueSeq() : this);
  8609. },
  8610. toList: function() {
  8611. // Use Late Binding here to solve the circular dependency.
  8612. return List(isKeyed(this) ? this.valueSeq() : this);
  8613. },
  8614. // ### Common JavaScript methods and properties
  8615. toString: function() {
  8616. return '[Iterable]';
  8617. },
  8618. __toString: function(head, tail) {
  8619. if (this.size === 0) {
  8620. return head + tail;
  8621. }
  8622. return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
  8623. },
  8624. // ### ES6 Collection methods (ES6 Array and Map)
  8625. concat: function() {var values = SLICE$0.call(arguments, 0);
  8626. return reify(this, concatFactory(this, values));
  8627. },
  8628. includes: function(searchValue) {
  8629. return this.some(function(value ) {return is(value, searchValue)});
  8630. },
  8631. entries: function() {
  8632. return this.__iterator(ITERATE_ENTRIES);
  8633. },
  8634. every: function(predicate, context) {
  8635. assertNotInfinite(this.size);
  8636. var returnValue = true;
  8637. this.__iterate(function(v, k, c) {
  8638. if (!predicate.call(context, v, k, c)) {
  8639. returnValue = false;
  8640. return false;
  8641. }
  8642. });
  8643. return returnValue;
  8644. },
  8645. filter: function(predicate, context) {
  8646. return reify(this, filterFactory(this, predicate, context, true));
  8647. },
  8648. find: function(predicate, context, notSetValue) {
  8649. var entry = this.findEntry(predicate, context);
  8650. return entry ? entry[1] : notSetValue;
  8651. },
  8652. findEntry: function(predicate, context) {
  8653. var found;
  8654. this.__iterate(function(v, k, c) {
  8655. if (predicate.call(context, v, k, c)) {
  8656. found = [k, v];
  8657. return false;
  8658. }
  8659. });
  8660. return found;
  8661. },
  8662. findLastEntry: function(predicate, context) {
  8663. return this.toSeq().reverse().findEntry(predicate, context);
  8664. },
  8665. forEach: function(sideEffect, context) {
  8666. assertNotInfinite(this.size);
  8667. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  8668. },
  8669. join: function(separator) {
  8670. assertNotInfinite(this.size);
  8671. separator = separator !== undefined ? '' + separator : ',';
  8672. var joined = '';
  8673. var isFirst = true;
  8674. this.__iterate(function(v ) {
  8675. isFirst ? (isFirst = false) : (joined += separator);
  8676. joined += v !== null && v !== undefined ? v.toString() : '';
  8677. });
  8678. return joined;
  8679. },
  8680. keys: function() {
  8681. return this.__iterator(ITERATE_KEYS);
  8682. },
  8683. map: function(mapper, context) {
  8684. return reify(this, mapFactory(this, mapper, context));
  8685. },
  8686. reduce: function(reducer, initialReduction, context) {
  8687. assertNotInfinite(this.size);
  8688. var reduction;
  8689. var useFirst;
  8690. if (arguments.length < 2) {
  8691. useFirst = true;
  8692. } else {
  8693. reduction = initialReduction;
  8694. }
  8695. this.__iterate(function(v, k, c) {
  8696. if (useFirst) {
  8697. useFirst = false;
  8698. reduction = v;
  8699. } else {
  8700. reduction = reducer.call(context, reduction, v, k, c);
  8701. }
  8702. });
  8703. return reduction;
  8704. },
  8705. reduceRight: function(reducer, initialReduction, context) {
  8706. var reversed = this.toKeyedSeq().reverse();
  8707. return reversed.reduce.apply(reversed, arguments);
  8708. },
  8709. reverse: function() {
  8710. return reify(this, reverseFactory(this, true));
  8711. },
  8712. slice: function(begin, end) {
  8713. return reify(this, sliceFactory(this, begin, end, true));
  8714. },
  8715. some: function(predicate, context) {
  8716. return !this.every(not(predicate), context);
  8717. },
  8718. sort: function(comparator) {
  8719. return reify(this, sortFactory(this, comparator));
  8720. },
  8721. values: function() {
  8722. return this.__iterator(ITERATE_VALUES);
  8723. },
  8724. // ### More sequential methods
  8725. butLast: function() {
  8726. return this.slice(0, -1);
  8727. },
  8728. isEmpty: function() {
  8729. return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
  8730. },
  8731. count: function(predicate, context) {
  8732. return ensureSize(
  8733. predicate ? this.toSeq().filter(predicate, context) : this
  8734. );
  8735. },
  8736. countBy: function(grouper, context) {
  8737. return countByFactory(this, grouper, context);
  8738. },
  8739. equals: function(other) {
  8740. return deepEqual(this, other);
  8741. },
  8742. entrySeq: function() {
  8743. var iterable = this;
  8744. if (iterable._cache) {
  8745. // We cache as an entries array, so we can just return the cache!
  8746. return new ArraySeq(iterable._cache);
  8747. }
  8748. var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
  8749. entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
  8750. return entriesSequence;
  8751. },
  8752. filterNot: function(predicate, context) {
  8753. return this.filter(not(predicate), context);
  8754. },
  8755. findLast: function(predicate, context, notSetValue) {
  8756. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  8757. },
  8758. first: function() {
  8759. return this.find(returnTrue);
  8760. },
  8761. flatMap: function(mapper, context) {
  8762. return reify(this, flatMapFactory(this, mapper, context));
  8763. },
  8764. flatten: function(depth) {
  8765. return reify(this, flattenFactory(this, depth, true));
  8766. },
  8767. fromEntrySeq: function() {
  8768. return new FromEntriesSequence(this);
  8769. },
  8770. get: function(searchKey, notSetValue) {
  8771. return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
  8772. },
  8773. getIn: function(searchKeyPath, notSetValue) {
  8774. var nested = this;
  8775. // Note: in an ES6 environment, we would prefer:
  8776. // for (var key of searchKeyPath) {
  8777. var iter = forceIterator(searchKeyPath);
  8778. var step;
  8779. while (!(step = iter.next()).done) {
  8780. var key = step.value;
  8781. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  8782. if (nested === NOT_SET) {
  8783. return notSetValue;
  8784. }
  8785. }
  8786. return nested;
  8787. },
  8788. groupBy: function(grouper, context) {
  8789. return groupByFactory(this, grouper, context);
  8790. },
  8791. has: function(searchKey) {
  8792. return this.get(searchKey, NOT_SET) !== NOT_SET;
  8793. },
  8794. hasIn: function(searchKeyPath) {
  8795. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  8796. },
  8797. isSubset: function(iter) {
  8798. iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
  8799. return this.every(function(value ) {return iter.includes(value)});
  8800. },
  8801. isSuperset: function(iter) {
  8802. iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
  8803. return iter.isSubset(this);
  8804. },
  8805. keySeq: function() {
  8806. return this.toSeq().map(keyMapper).toIndexedSeq();
  8807. },
  8808. last: function() {
  8809. return this.toSeq().reverse().first();
  8810. },
  8811. max: function(comparator) {
  8812. return maxFactory(this, comparator);
  8813. },
  8814. maxBy: function(mapper, comparator) {
  8815. return maxFactory(this, comparator, mapper);
  8816. },
  8817. min: function(comparator) {
  8818. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
  8819. },
  8820. minBy: function(mapper, comparator) {
  8821. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
  8822. },
  8823. rest: function() {
  8824. return this.slice(1);
  8825. },
  8826. skip: function(amount) {
  8827. return this.slice(Math.max(0, amount));
  8828. },
  8829. skipLast: function(amount) {
  8830. return reify(this, this.toSeq().reverse().skip(amount).reverse());
  8831. },
  8832. skipWhile: function(predicate, context) {
  8833. return reify(this, skipWhileFactory(this, predicate, context, true));
  8834. },
  8835. skipUntil: function(predicate, context) {
  8836. return this.skipWhile(not(predicate), context);
  8837. },
  8838. sortBy: function(mapper, comparator) {
  8839. return reify(this, sortFactory(this, comparator, mapper));
  8840. },
  8841. take: function(amount) {
  8842. return this.slice(0, Math.max(0, amount));
  8843. },
  8844. takeLast: function(amount) {
  8845. return reify(this, this.toSeq().reverse().take(amount).reverse());
  8846. },
  8847. takeWhile: function(predicate, context) {
  8848. return reify(this, takeWhileFactory(this, predicate, context));
  8849. },
  8850. takeUntil: function(predicate, context) {
  8851. return this.takeWhile(not(predicate), context);
  8852. },
  8853. valueSeq: function() {
  8854. return this.toIndexedSeq();
  8855. },
  8856. // ### Hashable Object
  8857. hashCode: function() {
  8858. return this.__hash || (this.__hash = hashIterable(this));
  8859. }
  8860. // ### Internal
  8861. // abstract __iterate(fn, reverse)
  8862. // abstract __iterator(type, reverse)
  8863. });
  8864. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  8865. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  8866. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  8867. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  8868. var IterablePrototype = Iterable.prototype;
  8869. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  8870. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  8871. IterablePrototype.__toJS = IterablePrototype.toArray;
  8872. IterablePrototype.__toStringMapper = quoteString;
  8873. IterablePrototype.inspect =
  8874. IterablePrototype.toSource = function() { return this.toString(); };
  8875. IterablePrototype.chain = IterablePrototype.flatMap;
  8876. IterablePrototype.contains = IterablePrototype.includes;
  8877. // Temporary warning about using length
  8878. (function () {
  8879. try {
  8880. Object.defineProperty(IterablePrototype, 'length', {
  8881. get: function () {
  8882. if (!Iterable.noLengthWarning) {
  8883. var stack;
  8884. try {
  8885. throw new Error();
  8886. } catch (error) {
  8887. stack = error.stack;
  8888. }
  8889. if (stack.indexOf('_wrapObject') === -1) {
  8890. console && console.warn && console.warn(
  8891. 'iterable.length has been deprecated, '+
  8892. 'use iterable.size or iterable.count(). '+
  8893. 'This warning will become a silent error in a future version. ' +
  8894. stack
  8895. );
  8896. return this.size;
  8897. }
  8898. }
  8899. }
  8900. });
  8901. } catch (e) {}
  8902. })();
  8903. mixin(KeyedIterable, {
  8904. // ### More sequential methods
  8905. flip: function() {
  8906. return reify(this, flipFactory(this));
  8907. },
  8908. findKey: function(predicate, context) {
  8909. var entry = this.findEntry(predicate, context);
  8910. return entry && entry[0];
  8911. },
  8912. findLastKey: function(predicate, context) {
  8913. return this.toSeq().reverse().findKey(predicate, context);
  8914. },
  8915. keyOf: function(searchValue) {
  8916. return this.findKey(function(value ) {return is(value, searchValue)});
  8917. },
  8918. lastKeyOf: function(searchValue) {
  8919. return this.findLastKey(function(value ) {return is(value, searchValue)});
  8920. },
  8921. mapEntries: function(mapper, context) {var this$0 = this;
  8922. var iterations = 0;
  8923. return reify(this,
  8924. this.toSeq().map(
  8925. function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
  8926. ).fromEntrySeq()
  8927. );
  8928. },
  8929. mapKeys: function(mapper, context) {var this$0 = this;
  8930. return reify(this,
  8931. this.toSeq().flip().map(
  8932. function(k, v) {return mapper.call(context, k, v, this$0)}
  8933. ).flip()
  8934. );
  8935. }
  8936. });
  8937. var KeyedIterablePrototype = KeyedIterable.prototype;
  8938. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  8939. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  8940. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  8941. KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
  8942. mixin(IndexedIterable, {
  8943. // ### Conversion to other types
  8944. toKeyedSeq: function() {
  8945. return new ToKeyedSequence(this, false);
  8946. },
  8947. // ### ES6 Collection methods (ES6 Array and Map)
  8948. filter: function(predicate, context) {
  8949. return reify(this, filterFactory(this, predicate, context, false));
  8950. },
  8951. findIndex: function(predicate, context) {
  8952. var entry = this.findEntry(predicate, context);
  8953. return entry ? entry[0] : -1;
  8954. },
  8955. indexOf: function(searchValue) {
  8956. var key = this.toKeyedSeq().keyOf(searchValue);
  8957. return key === undefined ? -1 : key;
  8958. },
  8959. lastIndexOf: function(searchValue) {
  8960. var key = this.toKeyedSeq().reverse().keyOf(searchValue);
  8961. return key === undefined ? -1 : key;
  8962. // var index =
  8963. // return this.toSeq().reverse().indexOf(searchValue);
  8964. },
  8965. reverse: function() {
  8966. return reify(this, reverseFactory(this, false));
  8967. },
  8968. slice: function(begin, end) {
  8969. return reify(this, sliceFactory(this, begin, end, false));
  8970. },
  8971. splice: function(index, removeNum /*, ...values*/) {
  8972. var numArgs = arguments.length;
  8973. removeNum = Math.max(removeNum | 0, 0);
  8974. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  8975. return this;
  8976. }
  8977. // If index is negative, it should resolve relative to the size of the
  8978. // collection. However size may be expensive to compute if not cached, so
  8979. // only call count() if the number is in fact negative.
  8980. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  8981. var spliced = this.slice(0, index);
  8982. return reify(
  8983. this,
  8984. numArgs === 1 ?
  8985. spliced :
  8986. spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  8987. );
  8988. },
  8989. // ### More collection methods
  8990. findLastIndex: function(predicate, context) {
  8991. var key = this.toKeyedSeq().findLastKey(predicate, context);
  8992. return key === undefined ? -1 : key;
  8993. },
  8994. first: function() {
  8995. return this.get(0);
  8996. },
  8997. flatten: function(depth) {
  8998. return reify(this, flattenFactory(this, depth, false));
  8999. },
  9000. get: function(index, notSetValue) {
  9001. index = wrapIndex(this, index);
  9002. return (index < 0 || (this.size === Infinity ||
  9003. (this.size !== undefined && index > this.size))) ?
  9004. notSetValue :
  9005. this.find(function(_, key) {return key === index}, undefined, notSetValue);
  9006. },
  9007. has: function(index) {
  9008. index = wrapIndex(this, index);
  9009. return index >= 0 && (this.size !== undefined ?
  9010. this.size === Infinity || index < this.size :
  9011. this.indexOf(index) !== -1
  9012. );
  9013. },
  9014. interpose: function(separator) {
  9015. return reify(this, interposeFactory(this, separator));
  9016. },
  9017. interleave: function(/*...iterables*/) {
  9018. var iterables = [this].concat(arrCopy(arguments));
  9019. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  9020. var interleaved = zipped.flatten(true);
  9021. if (zipped.size) {
  9022. interleaved.size = zipped.size * iterables.length;
  9023. }
  9024. return reify(this, interleaved);
  9025. },
  9026. last: function() {
  9027. return this.get(-1);
  9028. },
  9029. skipWhile: function(predicate, context) {
  9030. return reify(this, skipWhileFactory(this, predicate, context, false));
  9031. },
  9032. zip: function(/*, ...iterables */) {
  9033. var iterables = [this].concat(arrCopy(arguments));
  9034. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  9035. },
  9036. zipWith: function(zipper/*, ...iterables */) {
  9037. var iterables = arrCopy(arguments);
  9038. iterables[0] = this;
  9039. return reify(this, zipWithFactory(this, zipper, iterables));
  9040. }
  9041. });
  9042. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  9043. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  9044. mixin(SetIterable, {
  9045. // ### ES6 Collection methods (ES6 Array and Map)
  9046. get: function(value, notSetValue) {
  9047. return this.has(value) ? value : notSetValue;
  9048. },
  9049. includes: function(value) {
  9050. return this.has(value);
  9051. },
  9052. // ### More sequential methods
  9053. keySeq: function() {
  9054. return this.valueSeq();
  9055. }
  9056. });
  9057. SetIterable.prototype.has = IterablePrototype.includes;
  9058. // Mixin subclasses
  9059. mixin(KeyedSeq, KeyedIterable.prototype);
  9060. mixin(IndexedSeq, IndexedIterable.prototype);
  9061. mixin(SetSeq, SetIterable.prototype);
  9062. mixin(KeyedCollection, KeyedIterable.prototype);
  9063. mixin(IndexedCollection, IndexedIterable.prototype);
  9064. mixin(SetCollection, SetIterable.prototype);
  9065. // #pragma Helper functions
  9066. function keyMapper(v, k) {
  9067. return k;
  9068. }
  9069. function entryMapper(v, k) {
  9070. return [k, v];
  9071. }
  9072. function not(predicate) {
  9073. return function() {
  9074. return !predicate.apply(this, arguments);
  9075. }
  9076. }
  9077. function neg(predicate) {
  9078. return function() {
  9079. return -predicate.apply(this, arguments);
  9080. }
  9081. }
  9082. function quoteString(value) {
  9083. return typeof value === 'string' ? JSON.stringify(value) : value;
  9084. }
  9085. function defaultZipper() {
  9086. return arrCopy(arguments);
  9087. }
  9088. function defaultNegComparator(a, b) {
  9089. return a < b ? 1 : a > b ? -1 : 0;
  9090. }
  9091. function hashIterable(iterable) {
  9092. if (iterable.size === Infinity) {
  9093. return 0;
  9094. }
  9095. var ordered = isOrdered(iterable);
  9096. var keyed = isKeyed(iterable);
  9097. var h = ordered ? 1 : 0;
  9098. var size = iterable.__iterate(
  9099. keyed ?
  9100. ordered ?
  9101. function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
  9102. function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
  9103. ordered ?
  9104. function(v ) { h = 31 * h + hash(v) | 0; } :
  9105. function(v ) { h = h + hash(v) | 0; }
  9106. );
  9107. return murmurHashOfSize(size, h);
  9108. }
  9109. function murmurHashOfSize(size, h) {
  9110. h = imul(h, 0xCC9E2D51);
  9111. h = imul(h << 15 | h >>> -15, 0x1B873593);
  9112. h = imul(h << 13 | h >>> -13, 5);
  9113. h = (h + 0xE6546B64 | 0) ^ size;
  9114. h = imul(h ^ h >>> 16, 0x85EBCA6B);
  9115. h = imul(h ^ h >>> 13, 0xC2B2AE35);
  9116. h = smi(h ^ h >>> 16);
  9117. return h;
  9118. }
  9119. function hashMerge(a, b) {
  9120. return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
  9121. }
  9122. var Immutable = {
  9123. Iterable: Iterable,
  9124. Seq: Seq,
  9125. Collection: Collection,
  9126. Map: Map,
  9127. OrderedMap: OrderedMap,
  9128. List: List,
  9129. Stack: Stack,
  9130. Set: Set,
  9131. OrderedSet: OrderedSet,
  9132. Record: Record,
  9133. Range: Range,
  9134. Repeat: Repeat,
  9135. is: is,
  9136. fromJS: fromJS
  9137. };
  9138. return Immutable;
  9139. }));
  9140. });
  9141. var parseHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  9142. Object.defineProperty(exports, "__esModule", {
  9143. value: true
  9144. });
  9145. exports["default"] = parseHTML;
  9146. var fallback = function fallback(html) {
  9147. var doc = document.implementation.createHTMLDocument('');
  9148. doc.documentElement.innerHTML = html;
  9149. return doc;
  9150. };
  9151. function parseHTML(html) {
  9152. var doc;
  9153. if (typeof DOMParser !== 'undefined') {
  9154. var parser = new DOMParser();
  9155. doc = parser.parseFromString(html, 'text/html');
  9156. if (doc === null || doc.body === null) {
  9157. doc = fallback(html);
  9158. }
  9159. } else {
  9160. doc = fallback(html);
  9161. }
  9162. return doc.body;
  9163. }
  9164. });
  9165. _commonjsHelpers.unwrapExports(parseHTML_1);
  9166. var convertFromHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  9167. Object.defineProperty(exports, "__esModule", {
  9168. value: true
  9169. });
  9170. exports["default"] = void 0;
  9171. var _parseHTML = interopRequireDefault(parseHTML_1);
  9172. var _rangeSort = interopRequireDefault(rangeSort);
  9173. /**
  9174. * Copyright (c) 2013-present, Facebook, Inc.
  9175. * All rights reserved.
  9176. *
  9177. * Copyright (c) 2013-present, Facebook, Inc.
  9178. * All rights reserved.
  9179. *
  9180. * This source code is licensed under the BSD-style license found in the
  9181. * LICENSE file in the /src directory of this source tree. An additional grant
  9182. * of patent rights can be found in the PATENTS file in the same directory.
  9183. */
  9184. var NBSP = '&nbsp;';
  9185. var SPACE = ' '; // Arbitrary max indent
  9186. var MAX_DEPTH = 4; // used for replacing characters in HTML
  9187. /* eslint-disable no-control-regex */
  9188. var REGEX_CR = new RegExp('\r', 'g');
  9189. var REGEX_LF = new RegExp('\n', 'g');
  9190. var REGEX_NBSP = new RegExp(NBSP, 'g');
  9191. var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
  9192. /* eslint-enable no-control-regex */
  9193. // Block tag flow is different because LIs do not have
  9194. // a deterministic style ;_;
  9195. var blockTags = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'blockquote', 'pre'];
  9196. var inlineTags = {
  9197. b: 'BOLD',
  9198. code: 'CODE',
  9199. del: 'STRIKETHROUGH',
  9200. em: 'ITALIC',
  9201. i: 'ITALIC',
  9202. s: 'STRIKETHROUGH',
  9203. strike: 'STRIKETHROUGH',
  9204. strong: 'BOLD',
  9205. u: 'UNDERLINE'
  9206. };
  9207. var handleMiddleware = function handleMiddleware(maybeMiddleware, base) {
  9208. if (maybeMiddleware && maybeMiddleware.__isMiddleware === true) {
  9209. return maybeMiddleware(base);
  9210. }
  9211. return maybeMiddleware;
  9212. };
  9213. var defaultHTMLToBlock = function defaultHTMLToBlock(nodeName, node, lastList) {
  9214. return undefined;
  9215. };
  9216. var defaultHTMLToStyle = function defaultHTMLToStyle(nodeName, node, currentStyle) {
  9217. return currentStyle;
  9218. };
  9219. var defaultHTMLToEntity = function defaultHTMLToEntity(nodeName, node) {
  9220. return undefined;
  9221. };
  9222. var defaultTextToEntity = function defaultTextToEntity(text) {
  9223. return [];
  9224. };
  9225. var nullthrows = function nullthrows(x) {
  9226. if (x != null) {
  9227. return x;
  9228. }
  9229. throw new Error('Got unexpected null or undefined');
  9230. };
  9231. var sanitizeDraftText = function sanitizeDraftText(input) {
  9232. return input.replace(REGEX_BLOCK_DELIMITER, '');
  9233. };
  9234. function getEmptyChunk() {
  9235. return {
  9236. text: '',
  9237. inlines: [],
  9238. entities: [],
  9239. blocks: []
  9240. };
  9241. }
  9242. function getWhitespaceChunk(inEntity) {
  9243. var entities = new Array(1);
  9244. if (inEntity) {
  9245. entities[0] = inEntity;
  9246. }
  9247. return {
  9248. text: SPACE,
  9249. inlines: [(0, immutable$1.OrderedSet)()],
  9250. entities: entities,
  9251. blocks: []
  9252. };
  9253. }
  9254. function getSoftNewlineChunk(block, depth) {
  9255. var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9256. var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : (0, immutable$1.Map)();
  9257. if (flat === true) {
  9258. return {
  9259. text: '\r',
  9260. inlines: [(0, immutable$1.OrderedSet)()],
  9261. entities: new Array(1),
  9262. blocks: [{
  9263. type: block,
  9264. data: data,
  9265. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  9266. }],
  9267. isNewline: true
  9268. };
  9269. }
  9270. return {
  9271. text: '\n',
  9272. inlines: [(0, immutable$1.OrderedSet)()],
  9273. entities: new Array(1),
  9274. blocks: []
  9275. };
  9276. }
  9277. function getBlockDividerChunk(block, depth) {
  9278. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$1.Map)();
  9279. return {
  9280. text: '\r',
  9281. inlines: [(0, immutable$1.OrderedSet)()],
  9282. entities: new Array(1),
  9283. blocks: [{
  9284. type: block,
  9285. data: data,
  9286. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  9287. }]
  9288. };
  9289. }
  9290. function getBlockTypeForTag(tag, lastList) {
  9291. switch (tag) {
  9292. case 'h1':
  9293. return 'header-one';
  9294. case 'h2':
  9295. return 'header-two';
  9296. case 'h3':
  9297. return 'header-three';
  9298. case 'h4':
  9299. return 'header-four';
  9300. case 'h5':
  9301. return 'header-five';
  9302. case 'h6':
  9303. return 'header-six';
  9304. case 'li':
  9305. if (lastList === 'ol') {
  9306. return 'ordered-list-item';
  9307. }
  9308. return 'unordered-list-item';
  9309. case 'blockquote':
  9310. return 'blockquote';
  9311. case 'pre':
  9312. return 'code-block';
  9313. case 'div':
  9314. case 'p':
  9315. return 'unstyled';
  9316. default:
  9317. return null;
  9318. }
  9319. }
  9320. function baseCheckBlockType(nodeName, node, lastList) {
  9321. return getBlockTypeForTag(nodeName, lastList);
  9322. }
  9323. function processInlineTag(tag, node, currentStyle) {
  9324. var styleToCheck = inlineTags[tag];
  9325. if (styleToCheck) {
  9326. currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
  9327. } else if (node instanceof HTMLElement) {
  9328. var htmlElement = node;
  9329. currentStyle = currentStyle.withMutations(function (style) {
  9330. if (htmlElement.style.fontWeight === 'bold') {
  9331. style.add('BOLD');
  9332. }
  9333. if (htmlElement.style.fontStyle === 'italic') {
  9334. style.add('ITALIC');
  9335. }
  9336. if (htmlElement.style.textDecoration === 'underline') {
  9337. style.add('UNDERLINE');
  9338. }
  9339. if (htmlElement.style.textDecoration === 'line-through') {
  9340. style.add('STRIKETHROUGH');
  9341. }
  9342. }).toOrderedSet();
  9343. }
  9344. return currentStyle;
  9345. }
  9346. function baseProcessInlineTag(tag, node) {
  9347. var inlineStyles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$1.OrderedSet)();
  9348. return processInlineTag(tag, node, inlineStyles);
  9349. }
  9350. function joinChunks(A, B) {
  9351. var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9352. // Sometimes two blocks will touch in the DOM and we need to strip the
  9353. // extra delimiter to preserve niceness.
  9354. var firstInB = B.text.slice(0, 1);
  9355. var lastInA = A.text.slice(-1);
  9356. var adjacentDividers = lastInA === '\r' && firstInB === '\r';
  9357. var isJoiningBlocks = A.text !== '\r' && B.text !== '\r'; // when joining two full blocks like this we want to pop one divider
  9358. var addingNewlineToEmptyBlock = A.text === '\r' && !A.isNewline && B.isNewline; // when joining a newline to an empty block we want to remove the newline
  9359. if (adjacentDividers && (isJoiningBlocks || addingNewlineToEmptyBlock)) {
  9360. A.text = A.text.slice(0, -1);
  9361. A.inlines.pop();
  9362. A.entities.pop();
  9363. A.blocks.pop();
  9364. } // Kill whitespace after blocks if flat mode is on
  9365. if (A.text.slice(-1) === '\r' && flat === true) {
  9366. if (B.text === SPACE || B.text === '\n') {
  9367. return A;
  9368. } else if (firstInB === SPACE || firstInB === '\n') {
  9369. B.text = B.text.slice(1);
  9370. B.inlines.shift();
  9371. B.entities.shift();
  9372. }
  9373. }
  9374. var isNewline = A.text.length === 0 && B.isNewline;
  9375. return {
  9376. text: A.text + B.text,
  9377. inlines: A.inlines.concat(B.inlines),
  9378. entities: A.entities.concat(B.entities),
  9379. blocks: A.blocks.concat(B.blocks),
  9380. isNewline: isNewline
  9381. };
  9382. }
  9383. /*
  9384. * Check to see if we have anything like <p> <blockquote> <h1>... to create
  9385. * block tags from. If we do, we can use those and ignore <div> tags. If we
  9386. * don't, we can treat <div> tags as meaningful (unstyled) blocks.
  9387. */
  9388. function containsSemanticBlockMarkup(html) {
  9389. return blockTags.some(function (tag) {
  9390. return html.indexOf("<".concat(tag)) !== -1;
  9391. });
  9392. }
  9393. function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, inEntity) {
  9394. var nodeName = node.nodeName.toLowerCase();
  9395. var newBlock = false;
  9396. var nextBlockType = 'unstyled'; // Base Case
  9397. if (nodeName === '#text') {
  9398. var text = node.textContent;
  9399. if (text.trim() === '' && inBlock === null) {
  9400. return getEmptyChunk();
  9401. }
  9402. if (text.trim() === '' && inBlock !== 'code-block') {
  9403. return getWhitespaceChunk(inEntity);
  9404. }
  9405. if (inBlock !== 'code-block') {
  9406. // Can't use empty string because MSWord
  9407. text = text.replace(REGEX_LF, SPACE);
  9408. }
  9409. var entities = Array(text.length).fill(inEntity);
  9410. var offsetChange = 0;
  9411. var textEntities = checkEntityText(text, createEntity, getEntity, mergeEntityData, replaceEntityData).sort(_rangeSort["default"]);
  9412. textEntities.forEach(function (_ref) {
  9413. var entity = _ref.entity,
  9414. offset = _ref.offset,
  9415. length = _ref.length,
  9416. result = _ref.result;
  9417. var adjustedOffset = offset + offsetChange;
  9418. if (result === null || result === undefined) {
  9419. result = text.substr(adjustedOffset, length);
  9420. }
  9421. var textArray = text.split('');
  9422. textArray.splice.bind(textArray, adjustedOffset, length).apply(textArray, result.split(''));
  9423. text = textArray.join('');
  9424. entities.splice.bind(entities, adjustedOffset, length).apply(entities, Array(result.length).fill(entity));
  9425. offsetChange += result.length - length;
  9426. });
  9427. return {
  9428. text: text,
  9429. inlines: Array(text.length).fill(inlineStyle),
  9430. entities: entities,
  9431. blocks: []
  9432. };
  9433. } // BR tags
  9434. if (nodeName === 'br') {
  9435. var _blockType = inBlock;
  9436. if (_blockType === null) {
  9437. // BR tag is at top level, treat it as an unstyled block
  9438. return getSoftNewlineChunk('unstyled', depth, true);
  9439. }
  9440. return getSoftNewlineChunk(_blockType || 'unstyled', depth, options.flat);
  9441. }
  9442. var chunk = getEmptyChunk();
  9443. var newChunk = null; // Inline tags
  9444. inlineStyle = processInlineTag(nodeName, node, inlineStyle);
  9445. inlineStyle = processCustomInlineStyles(nodeName, node, inlineStyle); // Handle lists
  9446. if (nodeName === 'ul' || nodeName === 'ol') {
  9447. if (lastList) {
  9448. depth += 1;
  9449. }
  9450. lastList = nodeName;
  9451. inBlock = null;
  9452. } // Block Tags
  9453. var blockInfo = checkBlockType(nodeName, node, lastList, inBlock);
  9454. var blockType;
  9455. var blockDataMap;
  9456. if (blockInfo === false) {
  9457. return getEmptyChunk();
  9458. }
  9459. blockInfo = blockInfo || {};
  9460. if (typeof blockInfo === 'string') {
  9461. blockType = blockInfo;
  9462. blockDataMap = (0, immutable$1.Map)();
  9463. } else {
  9464. blockType = typeof blockInfo === 'string' ? blockInfo : blockInfo.type;
  9465. blockDataMap = blockInfo.data ? (0, immutable$1.Map)(blockInfo.data) : (0, immutable$1.Map)();
  9466. }
  9467. if (!inBlock && (fragmentBlockTags.indexOf(nodeName) !== -1 || blockType)) {
  9468. chunk = getBlockDividerChunk(blockType || getBlockTypeForTag(nodeName, lastList), depth, blockDataMap);
  9469. inBlock = blockType || getBlockTypeForTag(nodeName, lastList);
  9470. newBlock = true;
  9471. } else if (lastList && (inBlock === 'ordered-list-item' || inBlock === 'unordered-list-item') && nodeName === 'li') {
  9472. var listItemBlockType = getBlockTypeForTag(nodeName, lastList);
  9473. chunk = getBlockDividerChunk(listItemBlockType, depth);
  9474. inBlock = listItemBlockType;
  9475. newBlock = true;
  9476. nextBlockType = lastList === 'ul' ? 'unordered-list-item' : 'ordered-list-item';
  9477. } else if (inBlock && inBlock !== 'atomic' && blockType === 'atomic') {
  9478. inBlock = blockType;
  9479. newBlock = true;
  9480. chunk = getSoftNewlineChunk(blockType, depth, true, // atomic blocks within non-atomic blocks must always be split out
  9481. blockDataMap);
  9482. } // Recurse through children
  9483. var child = node.firstChild; // hack to allow conversion of atomic blocks from HTML (e.g. <figure><img
  9484. // src="..." /></figure>). since metadata must be stored on an entity text
  9485. // must exist for the entity to apply to. the way chunks are joined strips
  9486. // whitespace at the end so it cannot be a space character.
  9487. if (child == null && inEntity && (blockType === 'atomic' || inBlock === 'atomic')) {
  9488. child = document.createTextNode('a');
  9489. }
  9490. if (child != null) {
  9491. nodeName = child.nodeName.toLowerCase();
  9492. }
  9493. var entityId = null;
  9494. while (child) {
  9495. entityId = checkEntityNode(nodeName, child, createEntity, getEntity, mergeEntityData, replaceEntityData);
  9496. newChunk = genFragment(child, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, entityId || inEntity);
  9497. chunk = joinChunks(chunk, newChunk, options.flat);
  9498. var sibling = child.nextSibling; // Put in a newline to break up blocks inside blocks
  9499. if (sibling && fragmentBlockTags.indexOf(nodeName) >= 0 && inBlock) {
  9500. var newBlockInfo = checkBlockType(nodeName, child, lastList, inBlock);
  9501. var newBlockType = void 0;
  9502. var newBlockData = void 0;
  9503. if (newBlockInfo !== false) {
  9504. newBlockInfo = newBlockInfo || {};
  9505. if (typeof newBlockInfo === 'string') {
  9506. newBlockType = newBlockInfo;
  9507. newBlockData = (0, immutable$1.Map)();
  9508. } else {
  9509. newBlockType = newBlockInfo.type || getBlockTypeForTag(nodeName, lastList);
  9510. newBlockData = newBlockInfo.data ? (0, immutable$1.Map)(newBlockInfo.data) : (0, immutable$1.Map)();
  9511. }
  9512. chunk = joinChunks(chunk, getSoftNewlineChunk(newBlockType, depth, options.flat, newBlockData), options.flat);
  9513. }
  9514. }
  9515. if (sibling) {
  9516. nodeName = sibling.nodeName.toLowerCase();
  9517. }
  9518. child = sibling;
  9519. }
  9520. if (newBlock) {
  9521. chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, (0, immutable$1.Map)()), options.flat);
  9522. }
  9523. return chunk;
  9524. }
  9525. function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder) {
  9526. html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE);
  9527. var safeBody = DOMBuilder(html);
  9528. if (!safeBody) {
  9529. return null;
  9530. } // Sometimes we aren't dealing with content that contains nice semantic
  9531. // tags. In this case, use divs to separate everything out into paragraphs
  9532. // and hope for the best.
  9533. var workingBlocks = containsSemanticBlockMarkup(html) ? blockTags.concat(['div']) : ['div']; // Start with -1 block depth to offset the fact that we are passing in a fake
  9534. // UL block to sta rt with.
  9535. var chunk = genFragment(safeBody, (0, immutable$1.OrderedSet)(), 'ul', null, workingBlocks, -1, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options); // join with previous block to prevent weirdness on paste
  9536. if (chunk.text.indexOf('\r') === 0) {
  9537. chunk = {
  9538. text: chunk.text.slice(1),
  9539. inlines: chunk.inlines.slice(1),
  9540. entities: chunk.entities.slice(1),
  9541. blocks: chunk.blocks
  9542. };
  9543. } // Kill block delimiter at the end
  9544. if (chunk.text.slice(-1) === '\r') {
  9545. chunk.text = chunk.text.slice(0, -1);
  9546. chunk.inlines = chunk.inlines.slice(0, -1);
  9547. chunk.entities = chunk.entities.slice(0, -1);
  9548. chunk.blocks.pop();
  9549. } // If we saw no block tags, put an unstyled one in
  9550. if (chunk.blocks.length === 0) {
  9551. chunk.blocks.push({
  9552. type: 'unstyled',
  9553. data: (0, immutable$1.Map)(),
  9554. depth: 0
  9555. });
  9556. } // Sometimes we start with text that isn't in a block, which is then
  9557. // followed by blocks. Need to fix up the blocks to add in
  9558. // an unstyled block for this content
  9559. if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
  9560. chunk.blocks.unshift({
  9561. type: 'unstyled',
  9562. data: (0, immutable$1.Map)(),
  9563. depth: 0
  9564. });
  9565. }
  9566. return chunk;
  9567. }
  9568. function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey) {
  9569. // Be ABSOLUTELY SURE that the dom builder you pass hare won't execute
  9570. // arbitrary code in whatever environment you're running this in. For an
  9571. // example of how we try to do this in-browser, see getSafeBodyFromHTML.
  9572. var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder);
  9573. if (chunk == null) {
  9574. return [];
  9575. }
  9576. var start = 0;
  9577. return chunk.text.split('\r').map(function (textBlock, blockIndex) {
  9578. // Make absolutely certain that our text is acceptable.
  9579. textBlock = sanitizeDraftText(textBlock);
  9580. var end = start + textBlock.length;
  9581. var inlines = nullthrows(chunk).inlines.slice(start, end);
  9582. var entities = nullthrows(chunk).entities.slice(start, end);
  9583. var characterList = (0, immutable$1.List)(inlines.map(function (style, entityIndex) {
  9584. var data = {
  9585. style: style,
  9586. entity: null
  9587. };
  9588. if (entities[entityIndex]) {
  9589. data.entity = entities[entityIndex];
  9590. }
  9591. return Draft.Draft.CharacterMetadata.create(data);
  9592. }));
  9593. start = end + 1;
  9594. return new Draft.Draft.ContentBlock({
  9595. key: generateKey(),
  9596. type: nullthrows(chunk).blocks[blockIndex].type,
  9597. data: nullthrows(chunk).blocks[blockIndex].data,
  9598. depth: nullthrows(chunk).blocks[blockIndex].depth,
  9599. text: textBlock,
  9600. characterList: characterList
  9601. });
  9602. });
  9603. }
  9604. var convertFromHTML = function convertFromHTML(_ref2) {
  9605. var _ref2$htmlToStyle = _ref2.htmlToStyle,
  9606. htmlToStyle = _ref2$htmlToStyle === void 0 ? defaultHTMLToStyle : _ref2$htmlToStyle,
  9607. _ref2$htmlToEntity = _ref2.htmlToEntity,
  9608. htmlToEntity = _ref2$htmlToEntity === void 0 ? defaultHTMLToEntity : _ref2$htmlToEntity,
  9609. _ref2$textToEntity = _ref2.textToEntity,
  9610. textToEntity = _ref2$textToEntity === void 0 ? defaultTextToEntity : _ref2$textToEntity,
  9611. _ref2$htmlToBlock = _ref2.htmlToBlock,
  9612. htmlToBlock = _ref2$htmlToBlock === void 0 ? defaultHTMLToBlock : _ref2$htmlToBlock;
  9613. return function (html) {
  9614. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  9615. flat: false
  9616. };
  9617. var DOMBuilder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _parseHTML["default"];
  9618. var generateKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Draft.Draft.genKey;
  9619. var contentState = Draft.Draft.ContentState.createFromText('');
  9620. var createEntityWithContentState = function createEntityWithContentState() {
  9621. if (contentState.createEntity) {
  9622. var _contentState;
  9623. contentState = (_contentState = contentState).createEntity.apply(_contentState, arguments);
  9624. return contentState.getLastCreatedEntityKey();
  9625. }
  9626. return Draft.Draft.Entity.create.apply(Draft.Draft.Entity, arguments);
  9627. };
  9628. var getEntityWithContentState = function getEntityWithContentState() {
  9629. if (contentState.getEntity) {
  9630. var _contentState2;
  9631. return (_contentState2 = contentState).getEntity.apply(_contentState2, arguments);
  9632. }
  9633. return Draft.Draft.Entity.get.apply(Draft.Draft.Entity, arguments);
  9634. };
  9635. var mergeEntityDataWithContentState = function mergeEntityDataWithContentState() {
  9636. if (contentState.mergeEntityData) {
  9637. var _contentState3;
  9638. contentState = (_contentState3 = contentState).mergeEntityData.apply(_contentState3, arguments);
  9639. return;
  9640. }
  9641. Draft.Draft.Entity.mergeData.apply(Draft.Draft.Entity, arguments);
  9642. };
  9643. var replaceEntityDataWithContentState = function replaceEntityDataWithContentState() {
  9644. if (contentState.replaceEntityData) {
  9645. var _contentState4;
  9646. contentState = (_contentState4 = contentState).replaceEntityData.apply(_contentState4, arguments);
  9647. return;
  9648. }
  9649. Draft.Draft.Entity.replaceData.apply(Draft.Draft.Entity, arguments);
  9650. };
  9651. var contentBlocks = convertFromHTMLtoContentBlocks(html, handleMiddleware(htmlToStyle, baseProcessInlineTag), handleMiddleware(htmlToEntity, defaultHTMLToEntity), handleMiddleware(textToEntity, defaultTextToEntity), handleMiddleware(htmlToBlock, baseCheckBlockType), createEntityWithContentState, getEntityWithContentState, mergeEntityDataWithContentState, replaceEntityDataWithContentState, options, DOMBuilder, generateKey);
  9652. var blockMap = Draft.Draft.BlockMapBuilder.createFromArray(contentBlocks);
  9653. var firstBlockKey = contentBlocks[0].getKey();
  9654. return contentState.merge({
  9655. blockMap: blockMap,
  9656. selectionBefore: Draft.Draft.SelectionState.createEmpty(firstBlockKey),
  9657. selectionAfter: Draft.Draft.SelectionState.createEmpty(firstBlockKey)
  9658. });
  9659. };
  9660. };
  9661. var _default = function _default() {
  9662. if (arguments.length >= 1 && typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'string') {
  9663. return convertFromHTML({}).apply(void 0, arguments);
  9664. }
  9665. return convertFromHTML.apply(void 0, arguments);
  9666. };
  9667. exports["default"] = _default;
  9668. });
  9669. _commonjsHelpers.unwrapExports(convertFromHTML_1);
  9670. var lib = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  9671. Object.defineProperty(exports, "__esModule", {
  9672. value: true
  9673. });
  9674. Object.defineProperty(exports, "convertToHTML", {
  9675. enumerable: true,
  9676. get: function get() {
  9677. return _convertToHTML["default"];
  9678. }
  9679. });
  9680. Object.defineProperty(exports, "convertFromHTML", {
  9681. enumerable: true,
  9682. get: function get() {
  9683. return _convertFromHTML["default"];
  9684. }
  9685. });
  9686. Object.defineProperty(exports, "parseHTML", {
  9687. enumerable: true,
  9688. get: function get() {
  9689. return _parseHTML["default"];
  9690. }
  9691. });
  9692. var _convertToHTML = interopRequireDefault(convertToHTML_1);
  9693. var _convertFromHTML = interopRequireDefault(convertFromHTML_1);
  9694. var _parseHTML = interopRequireDefault(parseHTML_1);
  9695. });
  9696. _commonjsHelpers.unwrapExports(lib);
  9697. var configs = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  9698. Object.defineProperty(exports, "__esModule", {
  9699. value: true
  9700. });
  9701. exports.getFromHTMLConfig = exports.getToHTMLConfig = exports.blocks = exports.getHexColor = exports.defaultFontFamilies = exports.namedColors = undefined;
  9702. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  9703. var _react2 = _interopRequireDefault(React__default);
  9704. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9705. function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
  9706. var namedColors = exports.namedColors = {
  9707. "aliceblue": "#f0f8ff",
  9708. "antiquewhite": "#faebd7",
  9709. "aqua": "#00ffff",
  9710. "aquamarine": "#7fffd4",
  9711. "azure": "#f0ffff",
  9712. "beige": "#f5f5dc",
  9713. "bisque": "#ffe4c4",
  9714. "black": "#000000",
  9715. "blanchedalmond": "#ffebcd",
  9716. "blue": "#0000ff",
  9717. "blueviolet": "#8a2be2",
  9718. "brown": "#a52a2a",
  9719. "burlywood": "#deb887",
  9720. "cadetblue": "#5f9ea0",
  9721. "chartreuse": "#7fff00",
  9722. "chocolate": "#d2691e",
  9723. "coral": "#ff7f50",
  9724. "cornflowerblue": "#6495ed",
  9725. "cornsilk": "#fff8dc",
  9726. "crimson": "#dc143c",
  9727. "cyan": "#00ffff",
  9728. "darkblue": "#00008b",
  9729. "darkcyan": "#008b8b",
  9730. "darkgoldenrod": "#b8860b",
  9731. "darkgray": "#a9a9a9",
  9732. "darkgreen": "#006400",
  9733. "darkkhaki": "#bdb76b",
  9734. "darkmagenta": "#8b008b",
  9735. "darkolivegreen": "#556b2f",
  9736. "darkorange": "#ff8c00",
  9737. "darkorchid": "#9932cc",
  9738. "darkred": "#8b0000",
  9739. "darksalmon": "#e9967a",
  9740. "darkseagreen": "#8fbc8f",
  9741. "darkslateblue": "#483d8b",
  9742. "darkslategray": "#2f4f4f",
  9743. "darkturquoise": "#00ced1",
  9744. "darkviolet": "#9400d3",
  9745. "deeppink": "#ff1493",
  9746. "deepskyblue": "#00bfff",
  9747. "dimgray": "#696969",
  9748. "dodgerblue": "#1e90ff",
  9749. "firebrick": "#b22222",
  9750. "floralwhite": "#fffaf0",
  9751. "forestgreen": "#228b22",
  9752. "fuchsia": "#ff00ff",
  9753. "gainsboro": "#dcdcdc",
  9754. "ghostwhite": "#f8f8ff",
  9755. "gold": "#ffd700",
  9756. "goldenrod": "#daa520",
  9757. "gray": "#808080",
  9758. "green": "#008000",
  9759. "greenyellow": "#adff2f",
  9760. "honeydew": "#f0fff0",
  9761. "hotpink": "#ff69b4",
  9762. "indianred ": "#cd5c5c",
  9763. "indigo": "#4b0082",
  9764. "ivory": "#fffff0",
  9765. "khaki": "#f0e68c",
  9766. "lavender": "#e6e6fa",
  9767. "lavenderblush": "#fff0f5",
  9768. "lawngreen": "#7cfc00",
  9769. "lemonchiffon": "#fffacd",
  9770. "lightblue": "#add8e6",
  9771. "lightcoral": "#f08080",
  9772. "lightcyan": "#e0ffff",
  9773. "lightgoldenrodyellow": "#fafad2",
  9774. "lightgrey": "#d3d3d3",
  9775. "lightgreen": "#90ee90",
  9776. "lightpink": "#ffb6c1",
  9777. "lightsalmon": "#ffa07a",
  9778. "lightseagreen": "#20b2aa",
  9779. "lightskyblue": "#87cefa",
  9780. "lightslategray": "#778899",
  9781. "lightsteelblue": "#b0c4de",
  9782. "lightyellow": "#ffffe0",
  9783. "lime": "#00ff00",
  9784. "limegreen": "#32cd32",
  9785. "linen": "#faf0e6",
  9786. "magenta": "#ff00ff",
  9787. "maroon": "#800000",
  9788. "mediumaquamarine": "#66cdaa",
  9789. "mediumblue": "#0000cd",
  9790. "mediumorchid": "#ba55d3",
  9791. "mediumpurple": "#9370d8",
  9792. "mediumseagreen": "#3cb371",
  9793. "mediumslateblue": "#7b68ee",
  9794. "mediumspringgreen": "#00fa9a",
  9795. "mediumturquoise": "#48d1cc",
  9796. "mediumvioletred": "#c71585",
  9797. "midnightblue": "#191970",
  9798. "mintcream": "#f5fffa",
  9799. "mistyrose": "#ffe4e1",
  9800. "moccasin": "#ffe4b5",
  9801. "navajowhite": "#ffdead",
  9802. "navy": "#000080",
  9803. "oldlace": "#fdf5e6",
  9804. "olive": "#808000",
  9805. "olivedrab": "#6b8e23",
  9806. "orange": "#ffa500",
  9807. "orangered": "#ff4500",
  9808. "orchid": "#da70d6",
  9809. "palegoldenrod": "#eee8aa",
  9810. "palegreen": "#98fb98",
  9811. "paleturquoise": "#afeeee",
  9812. "palevioletred": "#d87093",
  9813. "papayawhip": "#ffefd5",
  9814. "peachpuff": "#ffdab9",
  9815. "peru": "#cd853f",
  9816. "pink": "#ffc0cb",
  9817. "plum": "#dda0dd",
  9818. "powderblue": "#b0e0e6",
  9819. "purple": "#800080",
  9820. "rebeccapurple": "#663399",
  9821. "red": "#ff0000",
  9822. "rosybrown": "#bc8f8f",
  9823. "royalblue": "#4169e1",
  9824. "saddlebrown": "#8b4513",
  9825. "salmon": "#fa8072",
  9826. "sandybrown": "#f4a460",
  9827. "seagreen": "#2e8b57",
  9828. "seashell": "#fff5ee",
  9829. "sienna": "#a0522d",
  9830. "silver": "#c0c0c0",
  9831. "skyblue": "#87ceeb",
  9832. "slateblue": "#6a5acd",
  9833. "slategray": "#708090",
  9834. "snow": "#fffafa",
  9835. "springgreen": "#00ff7f",
  9836. "steelblue": "#4682b4",
  9837. "tan": "#d2b48c",
  9838. "teal": "#008080",
  9839. "thistle": "#d8bfd8",
  9840. "tomato": "#ff6347",
  9841. "turquoise": "#40e0d0",
  9842. "violet": "#ee82ee",
  9843. "wheat": "#f5deb3",
  9844. "white": "#ffffff",
  9845. "whitesmoke": "#f5f5f5",
  9846. "yellow": "#ffff00",
  9847. "yellowgreen": "#9acd32"
  9848. };
  9849. var getStyleValue = function getStyleValue(style) {
  9850. return style.split('-')[1];
  9851. };
  9852. var defaultUnitExportFn = function defaultUnitExportFn(unit) {
  9853. return unit + 'px';
  9854. };
  9855. var defaultUnitImportFn = function defaultUnitImportFn(unit) {
  9856. return unit.replace('px', '');
  9857. };
  9858. var ignoredNodeAttributes = ['style'];
  9859. var ignoredEntityNodeAttributes = ['style', 'href', 'target', 'alt', 'title', 'id', 'controls', 'autoplay', 'loop', 'poster'];
  9860. var spreadNodeAttributes = function spreadNodeAttributes(attributesObject) {
  9861. return Object.keys(attributesObject).reduce(function (attributeString, attributeName) {
  9862. return attributeString + " " + attributeName + "=\"" + attributesObject[attributeName] + "\"";
  9863. }, '').replace(/^\s$/, '');
  9864. };
  9865. var defaultFontFamilies = exports.defaultFontFamilies = [{
  9866. name: 'Araial',
  9867. family: 'Arial, Helvetica, sans-serif'
  9868. }, {
  9869. name: 'Georgia',
  9870. family: 'Georgia, serif'
  9871. }, {
  9872. name: 'Impact',
  9873. family: 'Impact, serif'
  9874. }, {
  9875. name: 'Monospace',
  9876. family: '"Courier New", Courier, monospace'
  9877. }, {
  9878. name: 'Tahoma',
  9879. family: "tahoma, arial, 'Hiragino Sans GB', 宋体, sans-serif"
  9880. }];
  9881. var getHexColor = exports.getHexColor = function getHexColor(color) {
  9882. color = color.replace('color:', '').replace(';', '').replace(' ', '');
  9883. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  9884. return color;
  9885. } else if (namedColors[color]) {
  9886. return namedColors[color];
  9887. } else if (color.indexOf('rgb') === 0) {
  9888. var rgbArray = color.split(',');
  9889. var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
  9890. var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
  9891. return hex.length === 1 ? '0' + hex : hex;
  9892. }).join('');
  9893. return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
  9894. );
  9895. } else {
  9896. return null;
  9897. }
  9898. };
  9899. var blocks = exports.blocks = {
  9900. 'header-one': 'h1',
  9901. 'header-two': 'h2',
  9902. 'header-three': 'h3',
  9903. 'header-four': 'h4',
  9904. 'header-five': 'h5',
  9905. 'header-six': 'h6',
  9906. 'unstyled': 'p',
  9907. 'blockquote': 'blockquote'
  9908. };
  9909. var blockTypes = Object.keys(blocks);
  9910. var blockNames = blockTypes.map(function (key) {
  9911. return blocks[key];
  9912. });
  9913. var convertAtomicBlock = function convertAtomicBlock(block, contentState, blockNodeAttributes) {
  9914. if (!block || !block.key) {
  9915. return _react2.default.createElement("p", null);
  9916. }
  9917. var contentBlock = contentState.getBlockForKey(block.key);
  9918. var className = blockNodeAttributes.class,
  9919. nodeAttrAsProps = _objectWithoutProperties(blockNodeAttributes, ["class"]);
  9920. nodeAttrAsProps.className = className;
  9921. if (!contentBlock) {
  9922. return _react2.default.createElement("p", null);
  9923. }
  9924. var entityKey = contentBlock.getEntityAt(0);
  9925. if (!entityKey) {
  9926. return _react2.default.createElement("p", null);
  9927. }
  9928. var entity = contentState.getEntity(entityKey);
  9929. var mediaType = entity.getType().toLowerCase();
  9930. var _block$data = block.data,
  9931. float = _block$data.float,
  9932. alignment = _block$data.alignment;
  9933. var _entity$getData = entity.getData(),
  9934. url = _entity$getData.url,
  9935. link = _entity$getData.link,
  9936. link_target = _entity$getData.link_target,
  9937. width = _entity$getData.width,
  9938. height = _entity$getData.height,
  9939. meta = _entity$getData.meta;
  9940. if (mediaType === 'image') {
  9941. var imageWrapStyle = {};
  9942. var styledClassName = '';
  9943. if (float) {
  9944. imageWrapStyle.float = float;
  9945. styledClassName += ' float-' + float;
  9946. } else if (alignment) {
  9947. imageWrapStyle.textAlign = alignment;
  9948. styledClassName += ' align-' + alignment;
  9949. }
  9950. if (link) {
  9951. return _react2.default.createElement(
  9952. "div",
  9953. { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
  9954. _react2.default.createElement(
  9955. "a",
  9956. { style: { display: 'inline-block' }, href: link, target: link_target },
  9957. _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
  9958. )
  9959. );
  9960. } else {
  9961. return _react2.default.createElement(
  9962. "div",
  9963. { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
  9964. _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
  9965. );
  9966. }
  9967. } else if (mediaType === 'audio') {
  9968. return _react2.default.createElement(
  9969. "div",
  9970. { className: "media-wrap audio-wrap" },
  9971. _react2.default.createElement("audio", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url }))
  9972. );
  9973. } else if (mediaType === 'video') {
  9974. return _react2.default.createElement(
  9975. "div",
  9976. { className: "media-wrap video-wrap" },
  9977. _react2.default.createElement("video", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url, width: width, height: height }))
  9978. );
  9979. } else if (mediaType === 'embed') {
  9980. return _react2.default.createElement(
  9981. "div",
  9982. { className: "media-wrap embed-wrap" },
  9983. _react2.default.createElement("div", { dangerouslySetInnerHTML: { __html: url } })
  9984. );
  9985. } else if (mediaType === 'hr') {
  9986. return _react2.default.createElement("hr", null);
  9987. } else {
  9988. return _react2.default.createElement("p", null);
  9989. }
  9990. };
  9991. var entityToHTML = function entityToHTML(options) {
  9992. return function (entity, originalText) {
  9993. var entityExportFn = options.entityExportFn;
  9994. var entityType = entity.type.toLowerCase();
  9995. if (entityExportFn) {
  9996. var customOutput = entityExportFn(entity, originalText);
  9997. if (customOutput) {
  9998. return customOutput;
  9999. }
  10000. }
  10001. if (entityType === 'link') {
  10002. var _ref = entity.data.nodeAttributes || {},
  10003. className = _ref.class,
  10004. nodeAttrAsProps = _objectWithoutProperties(_ref, ["class"]);
  10005. nodeAttrAsProps.className = className;
  10006. return _react2.default.createElement("a", _extends({ href: entity.data.href, target: entity.data.target }, nodeAttrAsProps));
  10007. }
  10008. };
  10009. };
  10010. var styleToHTML = function styleToHTML(options) {
  10011. return function (style) {
  10012. var unitExportFn = options.unitExportFn || defaultUnitExportFn;
  10013. if (options.styleExportFn) {
  10014. var customOutput = options.styleExportFn(style, options);
  10015. if (customOutput) {
  10016. return customOutput;
  10017. }
  10018. }
  10019. style = style.toLowerCase();
  10020. if (style === 'strikethrough') {
  10021. return _react2.default.createElement("span", { style: { textDecoration: 'line-through' } });
  10022. } else if (style === 'superscript') {
  10023. return _react2.default.createElement("sup", null);
  10024. } else if (style === 'subscript') {
  10025. return _react2.default.createElement("sub", null);
  10026. } else if (style.indexOf('color-') === 0) {
  10027. return _react2.default.createElement("span", { style: { color: '#' + getStyleValue(style) } });
  10028. } else if (style.indexOf('bgcolor-') === 0) {
  10029. return _react2.default.createElement("span", { style: { backgroundColor: '#' + getStyleValue(style) } });
  10030. } else if (style.indexOf('fontsize-') === 0) {
  10031. return _react2.default.createElement("span", { style: { fontSize: unitExportFn(getStyleValue(style), 'font-size', 'html') } });
  10032. } else if (style.indexOf('lineheight-') === 0) {
  10033. return _react2.default.createElement("span", { style: { lineHeight: unitExportFn(getStyleValue(style), 'line-height', 'html') } });
  10034. } else if (style.indexOf('letterspacing-') === 0) {
  10035. return _react2.default.createElement("span", { style: { letterSpacing: unitExportFn(getStyleValue(style), 'letter-spacing', 'html') } });
  10036. } else if (style.indexOf('fontfamily-') === 0) {
  10037. var fontFamily = options.fontFamilies.find(function (item) {
  10038. return item.name.toLowerCase() === getStyleValue(style);
  10039. });
  10040. if (!fontFamily) return;
  10041. return _react2.default.createElement("span", { style: { fontFamily: fontFamily.family } });
  10042. }
  10043. };
  10044. };
  10045. var blockToHTML = function blockToHTML(options) {
  10046. return function (block) {
  10047. var blockExportFn = options.blockExportFn,
  10048. contentState = options.contentState;
  10049. if (blockExportFn) {
  10050. var customOutput = blockExportFn(contentState, block);
  10051. if (customOutput) {
  10052. return customOutput;
  10053. }
  10054. }
  10055. var blockStyle = '';
  10056. var blockType = block.type.toLowerCase();
  10057. var _block$data2 = block.data,
  10058. textAlign = _block$data2.textAlign,
  10059. textIndent = _block$data2.textIndent,
  10060. _block$data2$nodeAttr = _block$data2.nodeAttributes,
  10061. nodeAttributes = _block$data2$nodeAttr === undefined ? {} : _block$data2$nodeAttr;
  10062. var attributeString = spreadNodeAttributes(nodeAttributes);
  10063. if (textAlign || textIndent) {
  10064. blockStyle = ' style="';
  10065. if (textAlign) {
  10066. blockStyle += "text-align:" + textAlign + ";";
  10067. }
  10068. if (textIndent && !isNaN(textIndent) && textIndent > 0) {
  10069. blockStyle += "text-indent:" + textIndent * 2 + "em;";
  10070. }
  10071. blockStyle += '"';
  10072. }
  10073. if (blockType === 'atomic') {
  10074. return convertAtomicBlock(block, contentState, nodeAttributes);
  10075. } else if (blockType === 'code-block') {
  10076. var previousBlock = contentState.getBlockBefore(block.key);
  10077. var nextBlock = contentState.getBlockAfter(block.key);
  10078. var previousBlockType = previousBlock && previousBlock.getType();
  10079. var nextBlockType = nextBlock && nextBlock.getType();
  10080. var start = '';
  10081. var end = '';
  10082. if (previousBlockType !== 'code-block') {
  10083. start = "<pre" + attributeString + "><code>";
  10084. } else {
  10085. start = '';
  10086. }
  10087. if (nextBlockType !== 'code-block') {
  10088. end = '</code></pre>';
  10089. } else {
  10090. end = '<br/>';
  10091. }
  10092. return { start: start, end: end };
  10093. } else if (blocks[blockType]) {
  10094. return {
  10095. start: "<" + blocks[blockType] + blockStyle + attributeString + ">",
  10096. end: "</" + blocks[blockType] + ">"
  10097. };
  10098. } else if (blockType === 'unordered-list-item') {
  10099. return {
  10100. start: "<li" + blockStyle + attributeString + ">",
  10101. end: '</li>',
  10102. nest: _react2.default.createElement("ul", null)
  10103. };
  10104. } else if (blockType === 'ordered-list-item') {
  10105. return {
  10106. start: "<li" + blockStyle + attributeString + ">",
  10107. end: '</li>',
  10108. nest: _react2.default.createElement("ol", null)
  10109. };
  10110. }
  10111. };
  10112. };
  10113. var htmlToStyle = function htmlToStyle(options, source) {
  10114. return function (nodeName, node, currentStyle) {
  10115. if (!node || !node.style) {
  10116. return currentStyle;
  10117. }
  10118. var unitImportFn = options.unitImportFn || defaultUnitImportFn;
  10119. var newStyle = currentStyle;
  10120. [].forEach.call(node.style, function (style) {
  10121. if (nodeName === 'span' && style === 'color') {
  10122. var color = getHexColor(node.style.color);
  10123. newStyle = color ? newStyle.add('COLOR-' + color.replace('#', '').toUpperCase()) : newStyle;
  10124. } else if (nodeName === 'span' && style === 'background-color') {
  10125. var _color = getHexColor(node.style.backgroundColor);
  10126. newStyle = _color ? newStyle.add('BGCOLOR-' + _color.replace('#', '').toUpperCase()) : newStyle;
  10127. } else if (nodeName === 'span' && style === 'font-size') {
  10128. newStyle = newStyle.add('FONTSIZE-' + unitImportFn(node.style.fontSize, 'font-size', source));
  10129. } else if (nodeName === 'span' && style === 'line-height' && !isNaN(parseFloat(node.style.lineHeight, 10))) {
  10130. newStyle = newStyle.add('LINEHEIGHT-' + unitImportFn(node.style.lineHeight, 'line-height', source));
  10131. } else if (nodeName === 'span' && style === 'letter-spacing' && !isNaN(parseFloat(node.style.letterSpacing, 10))) {
  10132. newStyle = newStyle.add('LETTERSPACING-' + unitImportFn(node.style.letterSpacing, 'letter-spacing', source));
  10133. } else if (nodeName === 'span' && style === 'text-decoration') {
  10134. if (node.style.textDecoration === 'line-through') {
  10135. newStyle = newStyle.add('STRIKETHROUGH');
  10136. } else if (node.style.textDecoration === 'underline') {
  10137. newStyle = newStyle.add('UNDERLINE');
  10138. }
  10139. } else if (nodeName === 'span' && style === 'font-family') {
  10140. var fontFamily = options.fontFamilies.find(function (item) {
  10141. return item.family.toLowerCase() === node.style.fontFamily.toLowerCase();
  10142. });
  10143. if (!fontFamily) return;
  10144. newStyle = newStyle.add('FONTFAMILY-' + fontFamily.name.toUpperCase());
  10145. }
  10146. });
  10147. if (nodeName === 'sup') {
  10148. newStyle = newStyle.add('SUPERSCRIPT');
  10149. } else if (nodeName === 'sub') {
  10150. newStyle = newStyle.add('SUBSCRIPT');
  10151. }
  10152. options.styleImportFn && (newStyle = options.styleImportFn(nodeName, node, newStyle, source) || newStyle);
  10153. return newStyle;
  10154. };
  10155. };
  10156. var htmlToEntity = function htmlToEntity(options, source) {
  10157. return function (nodeName, node, createEntity) {
  10158. if (options && options.entityImportFn) {
  10159. var customInput = options.entityImportFn(nodeName, node, createEntity, source);
  10160. if (customInput) {
  10161. return customInput;
  10162. }
  10163. }
  10164. nodeName = nodeName.toLowerCase();
  10165. var alt = node.alt,
  10166. title = node.title,
  10167. id = node.id,
  10168. controls = node.controls,
  10169. autoplay = node.autoplay,
  10170. loop = node.loop,
  10171. poster = node.poster;
  10172. var meta = {};
  10173. var nodeAttributes = {};
  10174. id && (meta.id = id);
  10175. alt && (meta.alt = alt);
  10176. title && (meta.title = title);
  10177. controls && (meta.controls = controls);
  10178. autoplay && (meta.autoPlay = autoplay);
  10179. loop && (meta.loop = loop);
  10180. poster && (meta.poster = poster);
  10181. node.attributes && Object.keys(node.attributes).forEach(function (key) {
  10182. var attr = node.attributes[key];
  10183. ignoredEntityNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
  10184. });
  10185. if (nodeName === 'a' && !node.querySelectorAll('img').length) {
  10186. var href = node.getAttribute('href');
  10187. var _target = node.getAttribute('target');
  10188. return createEntity('LINK', 'MUTABLE', { href: href, target: _target, nodeAttributes: nodeAttributes });
  10189. } else if (nodeName === 'audio') {
  10190. return createEntity('AUDIO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
  10191. } else if (nodeName === 'video') {
  10192. return createEntity('VIDEO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
  10193. } else if (nodeName === 'img') {
  10194. var parentNode = node.parentNode;
  10195. var entityData = { meta: meta };
  10196. var _node$style = node.style,
  10197. width = _node$style.width,
  10198. height = _node$style.height;
  10199. entityData.url = node.getAttribute('src');
  10200. width && (entityData.width = width);
  10201. height && (entityData.height = height);
  10202. if (parentNode.nodeName.toLowerCase() === 'a') {
  10203. entityData.link = parentNode.getAttribute('href');
  10204. entityData.link_target = parentNode.getAttribute('target');
  10205. }
  10206. return createEntity('IMAGE', 'IMMUTABLE', entityData);
  10207. } else if (nodeName === 'hr') {
  10208. return createEntity('HR', 'IMMUTABLE', {});
  10209. } else if (node.parentNode && node.parentNode.classList.contains('embed-wrap')) {
  10210. var embedContent = node.innerHTML || node.outerHTML;
  10211. if (embedContent) {
  10212. return createEntity('EMBED', 'IMMUTABLE', {
  10213. url: embedContent
  10214. });
  10215. }
  10216. }
  10217. };
  10218. };
  10219. var htmlToBlock = function htmlToBlock(options, source) {
  10220. return function (nodeName, node) {
  10221. if (options && options.blockImportFn) {
  10222. var customInput = options.blockImportFn(nodeName, node, source);
  10223. if (customInput) {
  10224. return customInput;
  10225. }
  10226. }
  10227. var nodeAttributes = {};
  10228. var nodeStyle = node.style || {};
  10229. node.attributes && Object.keys(node.attributes).forEach(function (key) {
  10230. var attr = node.attributes[key];
  10231. ignoredNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
  10232. });
  10233. if (node.classList && node.classList.contains('media-wrap')) {
  10234. return {
  10235. type: 'atomic',
  10236. data: {
  10237. nodeAttributes: nodeAttributes,
  10238. float: nodeStyle.float,
  10239. alignment: nodeStyle.textAlign
  10240. }
  10241. };
  10242. } else if (nodeName === 'img') {
  10243. return {
  10244. type: 'atomic',
  10245. data: {
  10246. nodeAttributes: nodeAttributes,
  10247. float: nodeStyle.float,
  10248. alignment: nodeStyle.textAlign
  10249. }
  10250. };
  10251. } else if (nodeName === 'hr') {
  10252. return {
  10253. type: 'atomic',
  10254. data: { nodeAttributes: nodeAttributes }
  10255. };
  10256. } else if (nodeName === 'pre') {
  10257. node.innerHTML = node.innerHTML.replace(/<code(.*?)>/g, '').replace(/<\/code>/g, '');
  10258. return {
  10259. type: 'code-block',
  10260. data: { nodeAttributes: nodeAttributes }
  10261. };
  10262. } else if (blockNames.indexOf(nodeName) !== -1) {
  10263. var blockData = { nodeAttributes: nodeAttributes };
  10264. if (nodeStyle.textAlign) {
  10265. blockData.textAlign = nodeStyle.textAlign;
  10266. }
  10267. if (nodeStyle.textIndent) {
  10268. blockData.textIndent = /^\d+em$/.test(nodeStyle.textIndent) ? Math.ceil(parseInt(nodeStyle.textIndent, 10) / 2) : 1;
  10269. }
  10270. return {
  10271. type: blockTypes[blockNames.indexOf(nodeName)],
  10272. data: blockData
  10273. };
  10274. }
  10275. };
  10276. };
  10277. var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(options) {
  10278. return {
  10279. styleToHTML: styleToHTML(options),
  10280. entityToHTML: entityToHTML(options),
  10281. blockToHTML: blockToHTML(options)
  10282. };
  10283. };
  10284. var getFromHTMLConfig = exports.getFromHTMLConfig = function getFromHTMLConfig(options) {
  10285. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unknow';
  10286. return {
  10287. htmlToStyle: htmlToStyle(options, source),
  10288. htmlToEntity: htmlToEntity(options, source),
  10289. htmlToBlock: htmlToBlock(options, source)
  10290. };
  10291. };
  10292. });
  10293. _commonjsHelpers.unwrapExports(configs);
  10294. var configs_1 = configs.getFromHTMLConfig;
  10295. var configs_2 = configs.getToHTMLConfig;
  10296. var configs_3 = configs.blocks;
  10297. var configs_4 = configs.getHexColor;
  10298. var configs_5 = configs.defaultFontFamilies;
  10299. var configs_6 = configs.namedColors;
  10300. var dist = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10301. Object.defineProperty(exports, "__esModule", {
  10302. value: true
  10303. });
  10304. exports.convertRawToEditorState = exports.convertEditorStateToRaw = exports.convertHTMLToEditorState = exports.convertEditorStateToHTML = exports.convertHTMLToRaw = exports.convertRawToHTML = undefined;
  10305. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  10306. var defaultConvertOptions = {
  10307. fontFamilies: configs.defaultFontFamilies
  10308. };
  10309. var convertRawToHTML = exports.convertRawToHTML = function convertRawToHTML(rawContent, options) {
  10310. options = _extends({}, defaultConvertOptions, options);
  10311. try {
  10312. var contentState = (0, Draft.Draft.convertFromRaw)(rawContent);
  10313. options.contentState = contentState;
  10314. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
  10315. } catch (error) {
  10316. console.warn(error);
  10317. return '';
  10318. }
  10319. };
  10320. var convertHTMLToRaw = exports.convertHTMLToRaw = function convertHTMLToRaw(HTMLString, options, source) {
  10321. options = _extends({}, defaultConvertOptions, options);
  10322. try {
  10323. var contentState = (0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString);
  10324. return (0, Draft.Draft.convertToRaw)(contentState);
  10325. } catch (error) {
  10326. console.warn(error);
  10327. return {};
  10328. }
  10329. };
  10330. var convertEditorStateToHTML = exports.convertEditorStateToHTML = function convertEditorStateToHTML(editorState, options) {
  10331. options = _extends({}, defaultConvertOptions, options);
  10332. try {
  10333. var contentState = editorState.getCurrentContent();
  10334. options.contentState = contentState;
  10335. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
  10336. } catch (error) {
  10337. console.warn(error);
  10338. return '';
  10339. }
  10340. };
  10341. var convertHTMLToEditorState = exports.convertHTMLToEditorState = function convertHTMLToEditorState(HTMLString, editorDecorators, options, source) {
  10342. options = _extends({}, defaultConvertOptions, options);
  10343. try {
  10344. return Draft.Draft.EditorState.createWithContent((0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString), editorDecorators);
  10345. } catch (error) {
  10346. console.warn(error);
  10347. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  10348. }
  10349. };
  10350. var convertEditorStateToRaw = exports.convertEditorStateToRaw = function convertEditorStateToRaw(editorState) {
  10351. return (0, Draft.Draft.convertToRaw)(editorState.getCurrentContent());
  10352. };
  10353. var convertRawToEditorState = exports.convertRawToEditorState = function convertRawToEditorState(rawContent, editorDecorators) {
  10354. try {
  10355. return Draft.Draft.EditorState.createWithContent((0, Draft.Draft.convertFromRaw)(rawContent), editorDecorators);
  10356. } catch (error) {
  10357. console.warn(error);
  10358. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  10359. }
  10360. };
  10361. });
  10362. _commonjsHelpers.unwrapExports(dist);
  10363. var dist_1 = dist.convertRawToEditorState;
  10364. var dist_2 = dist.convertEditorStateToRaw;
  10365. var dist_3 = dist.convertHTMLToEditorState;
  10366. var dist_4 = dist.convertEditorStateToHTML;
  10367. var dist_5 = dist.convertHTMLToRaw;
  10368. var dist_6 = dist.convertRawToHTML;
  10369. var content = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10370. Object.defineProperty(exports, "__esModule", {
  10371. value: true
  10372. });
  10373. exports.redo = exports.undo = exports.handleKeyCommand = exports.clear = exports.setMediaPosition = exports.removeMedia = exports.setMediaData = exports.insertMedias = exports.insertHorizontalLine = exports.insertAtomicBlock = exports.insertHTML = exports.insertText = exports.toggleSelectionLetterSpacing = exports.toggleSelectionFontFamily = exports.toggleSelectionLineHeight = exports.toggleSelectionFontSize = exports.toggleSelectionBackgroundColor = exports.toggleSelectionColor = exports.decreaseSelectionIndent = exports.increaseSelectionIndent = exports.toggleSelectionIndent = exports.toggleSelectionAlignment = exports.removeSelectionInlineStyles = exports.toggleSelectionInlineStyle = exports.selectionHasInlineStyle = exports.getSelectionInlineStyle = exports.toggleSelectionLink = exports.toggleSelectionEntity = exports.getSelectionEntityData = exports.getSelectionEntityType = exports.toggleSelectionBlockType = exports.getSelectionText = exports.getSelectionBlockType = exports.getSelectionBlockData = exports.setSelectionBlockData = exports.getSelectedBlocks = exports.updateEachCharacterOfSelection = exports.getSelectionBlock = exports.removeBlock = exports.selectNextBlock = exports.selectBlock = exports.selectionContainsStrictBlock = exports.selectionContainsBlockType = exports.isSelectionCollapsed = exports.createEditorState = exports.createEmptyEditorState = exports.isEditorState = exports.registerStrictBlockType = undefined;
  10374. var _immutable2 = _interopRequireDefault(immutable);
  10375. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10376. var strictBlockTypes = ['atomic'];
  10377. var registerStrictBlockType = exports.registerStrictBlockType = function registerStrictBlockType(blockType) {
  10378. strictBlockTypes.indexOf(blockType) === -1 && strictBlockTypes.push(blockType);
  10379. };
  10380. var isEditorState = exports.isEditorState = function isEditorState(editorState) {
  10381. return editorState instanceof Draft.Draft.EditorState;
  10382. };
  10383. var createEmptyEditorState = exports.createEmptyEditorState = function createEmptyEditorState(editorDecorators) {
  10384. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  10385. };
  10386. var createEditorState = exports.createEditorState = function createEditorState(contentState, editorDecorators) {
  10387. return Draft.Draft.EditorState.createWithContent(contentState, editorDecorators);
  10388. };
  10389. var isSelectionCollapsed = exports.isSelectionCollapsed = function isSelectionCollapsed(editorState) {
  10390. return editorState.getSelection().isCollapsed();
  10391. };
  10392. var selectionContainsBlockType = exports.selectionContainsBlockType = function selectionContainsBlockType(editorState, blockType) {
  10393. return getSelectedBlocks(editorState).find(function (block) {
  10394. return block.getType() === blockType;
  10395. });
  10396. };
  10397. var selectionContainsStrictBlock = exports.selectionContainsStrictBlock = function selectionContainsStrictBlock(editorState) {
  10398. return getSelectedBlocks(editorState).find(function (block) {
  10399. return ~strictBlockTypes.indexOf(block.getType());
  10400. });
  10401. };
  10402. var selectBlock = exports.selectBlock = function selectBlock(editorState, block) {
  10403. var blockKey = block.getKey();
  10404. return Draft.Draft.EditorState.forceSelection(editorState, new Draft.Draft.SelectionState({
  10405. anchorKey: blockKey,
  10406. anchorOffset: 0,
  10407. focusKey: blockKey,
  10408. focusOffset: block.getLength()
  10409. }));
  10410. };
  10411. var selectNextBlock = exports.selectNextBlock = function selectNextBlock(editorState, block) {
  10412. var nextBlock = editorState.getCurrentContent().getBlockAfter(block.getKey());
  10413. return nextBlock ? selectBlock(editorState, nextBlock) : editorState;
  10414. };
  10415. var removeBlock = exports.removeBlock = function removeBlock(editorState, block) {
  10416. var lastSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10417. var nextContentState = void 0,
  10418. nextEditorState = void 0;
  10419. var blockKey = block.getKey();
  10420. nextContentState = Draft.Draft.Modifier.removeRange(editorState.getCurrentContent(), new Draft.Draft.SelectionState({
  10421. anchorKey: blockKey,
  10422. anchorOffset: 0,
  10423. focusKey: blockKey,
  10424. focusOffset: block.getLength()
  10425. }), 'backward');
  10426. nextContentState = Draft.Draft.Modifier.setBlockType(nextContentState, nextContentState.getSelectionAfter(), 'unstyled');
  10427. nextEditorState = Draft.Draft.EditorState.push(editorState, nextContentState, 'remove-range');
  10428. return Draft.Draft.EditorState.forceSelection(nextEditorState, lastSelection || nextContentState.getSelectionAfter());
  10429. };
  10430. var getSelectionBlock = exports.getSelectionBlock = function getSelectionBlock(editorState) {
  10431. return editorState.getCurrentContent().getBlockForKey(editorState.getSelection().getAnchorKey());
  10432. };
  10433. var updateEachCharacterOfSelection = exports.updateEachCharacterOfSelection = function updateEachCharacterOfSelection(editorState, callback) {
  10434. var selectionState = editorState.getSelection();
  10435. var contentState = editorState.getCurrentContent();
  10436. var contentBlocks = contentState.getBlockMap();
  10437. var selectedBlocks = getSelectedBlocks(editorState);
  10438. if (selectedBlocks.length === 0) {
  10439. return editorState;
  10440. }
  10441. var startKey = selectionState.getStartKey();
  10442. var startOffset = selectionState.getStartOffset();
  10443. var endKey = selectionState.getEndKey();
  10444. var endOffset = selectionState.getEndOffset();
  10445. var nextContentBlocks = contentBlocks.map(function (block) {
  10446. if (selectedBlocks.indexOf(block) === -1) {
  10447. return block;
  10448. }
  10449. var blockKey = block.getKey();
  10450. var charactersList = block.getCharacterList();
  10451. var nextCharactersList = null;
  10452. if (blockKey === startKey && blockKey === endKey) {
  10453. nextCharactersList = charactersList.map(function (character, index) {
  10454. if (index >= startOffset && index < endOffset) {
  10455. return callback(character);
  10456. }
  10457. return character;
  10458. });
  10459. } else if (blockKey === startKey) {
  10460. nextCharactersList = charactersList.map(function (character, index) {
  10461. if (index >= startOffset) {
  10462. return callback(character);
  10463. }
  10464. return character;
  10465. });
  10466. } else if (blockKey === endKey) {
  10467. nextCharactersList = charactersList.map(function (character, index) {
  10468. if (index < endOffset) {
  10469. return callback(character);
  10470. }
  10471. return character;
  10472. });
  10473. } else {
  10474. nextCharactersList = charactersList.map(function (character) {
  10475. return callback(character);
  10476. });
  10477. }
  10478. return block.merge({
  10479. 'characterList': nextCharactersList
  10480. });
  10481. });
  10482. return Draft.Draft.EditorState.push(editorState, contentState.merge({
  10483. blockMap: nextContentBlocks,
  10484. selectionBefore: selectionState,
  10485. selectionAfter: selectionState
  10486. }), 'update-selection-character-list');
  10487. };
  10488. var getSelectedBlocks = exports.getSelectedBlocks = function getSelectedBlocks(editorState) {
  10489. var selectionState = editorState.getSelection();
  10490. var contentState = editorState.getCurrentContent();
  10491. var startKey = selectionState.getStartKey();
  10492. var endKey = selectionState.getEndKey();
  10493. var isSameBlock = startKey === endKey;
  10494. var startingBlock = contentState.getBlockForKey(startKey);
  10495. var selectedBlocks = [startingBlock];
  10496. if (!isSameBlock) {
  10497. var blockKey = startKey;
  10498. while (blockKey !== endKey) {
  10499. var nextBlock = contentState.getBlockAfter(blockKey);
  10500. selectedBlocks.push(nextBlock);
  10501. blockKey = nextBlock.getKey();
  10502. }
  10503. }
  10504. return selectedBlocks;
  10505. };
  10506. var setSelectionBlockData = exports.setSelectionBlockData = function setSelectionBlockData(editorState, blockData, override) {
  10507. var newBlockData = override ? blockData : Object.assign({}, getSelectionBlockData(editorState).toJS(), blockData);
  10508. Object.keys(newBlockData).forEach(function (key) {
  10509. if (newBlockData.hasOwnProperty(key) && newBlockData[key] === undefined) {
  10510. delete newBlockData[key];
  10511. }
  10512. });
  10513. return (0, draftjsUtils.setBlockData)(editorState, newBlockData);
  10514. };
  10515. var getSelectionBlockData = exports.getSelectionBlockData = function getSelectionBlockData(editorState, name) {
  10516. var blockData = getSelectionBlock(editorState).getData();
  10517. return name ? blockData.get(name) : blockData;
  10518. };
  10519. var getSelectionBlockType = exports.getSelectionBlockType = function getSelectionBlockType(editorState) {
  10520. return getSelectionBlock(editorState).getType();
  10521. };
  10522. var getSelectionText = exports.getSelectionText = function getSelectionText(editorState) {
  10523. var selectionState = editorState.getSelection();
  10524. var contentState = editorState.getCurrentContent();
  10525. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  10526. return '';
  10527. }
  10528. var anchorKey = selectionState.getAnchorKey();
  10529. var currentContentBlock = contentState.getBlockForKey(anchorKey);
  10530. var start = selectionState.getStartOffset();
  10531. var end = selectionState.getEndOffset();
  10532. return currentContentBlock.getText().slice(start, end);
  10533. };
  10534. var toggleSelectionBlockType = exports.toggleSelectionBlockType = function toggleSelectionBlockType(editorState, blockType) {
  10535. if (selectionContainsStrictBlock(editorState)) {
  10536. return editorState;
  10537. }
  10538. return Draft.Draft.RichUtils.toggleBlockType(editorState, blockType);
  10539. };
  10540. var getSelectionEntityType = exports.getSelectionEntityType = function getSelectionEntityType(editorState) {
  10541. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  10542. if (entityKey) {
  10543. var entity = editorState.getCurrentContent().getEntity(entityKey);
  10544. return entity ? entity.get('type') : null;
  10545. }
  10546. return null;
  10547. };
  10548. var getSelectionEntityData = exports.getSelectionEntityData = function getSelectionEntityData(editorState, type) {
  10549. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  10550. if (entityKey) {
  10551. var entity = editorState.getCurrentContent().getEntity(entityKey);
  10552. if (entity && entity.get('type') === type) {
  10553. return entity.getData();
  10554. } else {
  10555. return {};
  10556. }
  10557. } else {
  10558. return {};
  10559. }
  10560. };
  10561. var toggleSelectionEntity = exports.toggleSelectionEntity = function toggleSelectionEntity(editorState, entity) {
  10562. var contentState = editorState.getCurrentContent();
  10563. var selectionState = editorState.getSelection();
  10564. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  10565. return editorState;
  10566. }
  10567. if (!entity || !entity.type || getSelectionEntityType(editorState) === entity.type) {
  10568. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.applyEntity(contentState, selectionState, null), 'apply-entity');
  10569. }
  10570. try {
  10571. var nextContentState = contentState.createEntity(entity.type, entity.mutability, entity.data);
  10572. var entityKey = nextContentState.getLastCreatedEntityKey();
  10573. var nextEditorState = Draft.Draft.EditorState.set(editorState, {
  10574. currentContent: nextContentState
  10575. });
  10576. return Draft.Draft.EditorState.push(nextEditorState, Draft.Draft.Modifier.applyEntity(nextContentState, selectionState, entityKey), 'apply-entity');
  10577. } catch (error) {
  10578. console.warn(error);
  10579. return editorState;
  10580. }
  10581. };
  10582. var toggleSelectionLink = exports.toggleSelectionLink = function toggleSelectionLink(editorState, href, target) {
  10583. var contentState = editorState.getCurrentContent();
  10584. var selectionState = editorState.getSelection();
  10585. var entityData = { href: href, target: target };
  10586. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  10587. return editorState;
  10588. }
  10589. if (href === false) {
  10590. return Draft.Draft.RichUtils.toggleLink(editorState, selectionState, null);
  10591. }
  10592. if (href === null) {
  10593. delete entityData.href;
  10594. }
  10595. try {
  10596. var nextContentState = contentState.createEntity('LINK', 'MUTABLE', entityData);
  10597. var entityKey = nextContentState.getLastCreatedEntityKey();
  10598. var nextEditorState = Draft.Draft.EditorState.set(editorState, {
  10599. currentContent: nextContentState
  10600. });
  10601. nextEditorState = Draft.Draft.RichUtils.toggleLink(nextEditorState, selectionState, entityKey);
  10602. nextEditorState = Draft.Draft.EditorState.forceSelection(nextEditorState, selectionState.merge({
  10603. anchorOffset: selectionState.getEndOffset(),
  10604. focusOffset: selectionState.getEndOffset()
  10605. }));
  10606. nextEditorState = Draft.Draft.EditorState.push(nextEditorState, Draft.Draft.Modifier.insertText(nextEditorState.getCurrentContent(), nextEditorState.getSelection(), ''), 'insert-text');
  10607. return nextEditorState;
  10608. } catch (error) {
  10609. console.warn(error);
  10610. return editorState;
  10611. }
  10612. };
  10613. var getSelectionInlineStyle = exports.getSelectionInlineStyle = function getSelectionInlineStyle(editorState) {
  10614. return editorState.getCurrentInlineStyle();
  10615. };
  10616. var selectionHasInlineStyle = exports.selectionHasInlineStyle = function selectionHasInlineStyle(editorState, style) {
  10617. return getSelectionInlineStyle(editorState).has(style.toUpperCase());
  10618. };
  10619. var toggleSelectionInlineStyle = exports.toggleSelectionInlineStyle = function toggleSelectionInlineStyle(editorState, style) {
  10620. var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  10621. var nextEditorState = editorState;
  10622. style = prefix + style.toUpperCase();
  10623. if (prefix) {
  10624. nextEditorState = updateEachCharacterOfSelection(nextEditorState, function (characterMetadata) {
  10625. return characterMetadata.toJS().style.reduce(function (characterMetadata, characterStyle) {
  10626. if (characterStyle.indexOf(prefix) === 0 && style !== characterStyle) {
  10627. return Draft.Draft.CharacterMetadata.removeStyle(characterMetadata, characterStyle);
  10628. } else {
  10629. return characterMetadata;
  10630. }
  10631. }, characterMetadata);
  10632. });
  10633. }
  10634. return Draft.Draft.RichUtils.toggleInlineStyle(nextEditorState, style);
  10635. };
  10636. var removeSelectionInlineStyles = exports.removeSelectionInlineStyles = function removeSelectionInlineStyles(editorState) {
  10637. return updateEachCharacterOfSelection(editorState, function (characterMetadata) {
  10638. return characterMetadata.merge({
  10639. style: _immutable2.default.OrderedSet([])
  10640. });
  10641. });
  10642. };
  10643. var toggleSelectionAlignment = exports.toggleSelectionAlignment = function toggleSelectionAlignment(editorState, alignment) {
  10644. return setSelectionBlockData(editorState, {
  10645. textAlign: getSelectionBlockData(editorState, 'textAlign') !== alignment ? alignment : undefined
  10646. });
  10647. };
  10648. var toggleSelectionIndent = exports.toggleSelectionIndent = function toggleSelectionIndent(editorState, textIndent) {
  10649. var maxIndent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6;
  10650. return textIndent < 0 || textIndent > maxIndent || isNaN(textIndent) ? editorState : setSelectionBlockData(editorState, {
  10651. textIndent: textIndent || undefined
  10652. });
  10653. };
  10654. var increaseSelectionIndent = exports.increaseSelectionIndent = function increaseSelectionIndent(editorState) {
  10655. var maxIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
  10656. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  10657. return toggleSelectionIndent(editorState, currentIndent + 1, maxIndent);
  10658. };
  10659. var decreaseSelectionIndent = exports.decreaseSelectionIndent = function decreaseSelectionIndent(editorState) {
  10660. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  10661. return toggleSelectionIndent(editorState, currentIndent - 1);
  10662. };
  10663. var toggleSelectionColor = exports.toggleSelectionColor = function toggleSelectionColor(editorState, color) {
  10664. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'COLOR-');
  10665. };
  10666. var toggleSelectionBackgroundColor = exports.toggleSelectionBackgroundColor = function toggleSelectionBackgroundColor(editorState, color) {
  10667. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'BGCOLOR-');
  10668. };
  10669. var toggleSelectionFontSize = exports.toggleSelectionFontSize = function toggleSelectionFontSize(editorState, fontSize) {
  10670. return toggleSelectionInlineStyle(editorState, fontSize, 'FONTSIZE-');
  10671. };
  10672. var toggleSelectionLineHeight = exports.toggleSelectionLineHeight = function toggleSelectionLineHeight(editorState, lineHeight) {
  10673. return toggleSelectionInlineStyle(editorState, lineHeight, 'LINEHEIGHT-');
  10674. };
  10675. var toggleSelectionFontFamily = exports.toggleSelectionFontFamily = function toggleSelectionFontFamily(editorState, fontFamily) {
  10676. return toggleSelectionInlineStyle(editorState, fontFamily, 'FONTFAMILY-');
  10677. };
  10678. var toggleSelectionLetterSpacing = exports.toggleSelectionLetterSpacing = function toggleSelectionLetterSpacing(editorState, letterSpacing) {
  10679. return toggleSelectionInlineStyle(editorState, letterSpacing, 'LETTERSPACING-');
  10680. };
  10681. var insertText = exports.insertText = function insertText(editorState, text, inlineStyle, entity) {
  10682. var selectionState = editorState.getSelection();
  10683. var currentSelectedBlockType = getSelectionBlockType(editorState);
  10684. if (currentSelectedBlockType === 'atomic') {
  10685. return editorState;
  10686. }
  10687. var entityKey = void 0;
  10688. var contentState = editorState.getCurrentContent();
  10689. if (entity && entity.type) {
  10690. contentState = contentState.createEntity(entity.type, entity.mutability || 'MUTABLE', entity.data || entityData);
  10691. entityKey = contentState.getLastCreatedEntityKey();
  10692. }
  10693. if (!selectionState.isCollapsed()) {
  10694. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.replaceText(contentState, selectionState, text, inlineStyle, entityKey), 'replace-text');
  10695. } else {
  10696. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.insertText(contentState, selectionState, text, inlineStyle, entityKey), 'insert-text');
  10697. }
  10698. };
  10699. var insertHTML = exports.insertHTML = function insertHTML(editorState, htmlString, source) {
  10700. if (!htmlString) {
  10701. return editorState;
  10702. }
  10703. var selectionState = editorState.getSelection();
  10704. var contentState = editorState.getCurrentContent();
  10705. var options = editorState.convertOptions || {};
  10706. try {
  10707. var _convertFromRaw = (0, Draft.Draft.convertFromRaw)((0, dist.convertHTMLToRaw)(htmlString, options, source)),
  10708. blockMap = _convertFromRaw.blockMap;
  10709. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.replaceWithFragment(contentState, selectionState, blockMap), 'insert-fragment');
  10710. } catch (error) {
  10711. console.warn(error);
  10712. return editorState;
  10713. }
  10714. };
  10715. var insertAtomicBlock = exports.insertAtomicBlock = function insertAtomicBlock(editorState, type) {
  10716. var immutable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  10717. var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  10718. if (selectionContainsStrictBlock(editorState)) {
  10719. return insertAtomicBlock(selectNextBlock(editorState, getSelectionBlock(editorState)), type, immutable, data);
  10720. }
  10721. var selectionState = editorState.getSelection();
  10722. var contentState = editorState.getCurrentContent();
  10723. if (!selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  10724. return editorState;
  10725. }
  10726. var contentStateWithEntity = contentState.createEntity(type, immutable ? 'IMMUTABLE' : 'MUTABLE', data);
  10727. var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
  10728. var newEditorState = Draft.Draft.AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' ');
  10729. return newEditorState;
  10730. };
  10731. var insertHorizontalLine = exports.insertHorizontalLine = function insertHorizontalLine(editorState) {
  10732. return insertAtomicBlock(editorState, 'HR');
  10733. };
  10734. var insertMedias = exports.insertMedias = function insertMedias(editorState) {
  10735. var medias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  10736. if (!medias.length) {
  10737. return editorState;
  10738. }
  10739. return medias.reduce(function (editorState, media) {
  10740. var url = media.url,
  10741. link = media.link,
  10742. link_target = media.link_target,
  10743. name = media.name,
  10744. type = media.type,
  10745. width = media.width,
  10746. height = media.height,
  10747. meta = media.meta;
  10748. return insertAtomicBlock(editorState, type, true, { url: url, link: link, link_target: link_target, name: name, type: type, width: width, height: height, meta: meta });
  10749. }, editorState);
  10750. };
  10751. var setMediaData = exports.setMediaData = function setMediaData(editorState, entityKey, data) {
  10752. return Draft.Draft.EditorState.push(editorState, editorState.getCurrentContent().mergeEntityData(entityKey, data), 'change-block-data');
  10753. };
  10754. var removeMedia = exports.removeMedia = function removeMedia(editorState, mediaBlock) {
  10755. return removeBlock(editorState, mediaBlock);
  10756. };
  10757. var setMediaPosition = exports.setMediaPosition = function setMediaPosition(editorState, mediaBlock, position) {
  10758. var newPosition = {};
  10759. var float = position.float,
  10760. alignment = position.alignment;
  10761. if (typeof float !== 'undefined') {
  10762. newPosition.float = mediaBlock.getData().get('float') === float ? null : float;
  10763. }
  10764. if (typeof alignment !== 'undefined') {
  10765. newPosition.alignment = mediaBlock.getData().get('alignment') === alignment ? null : alignment;
  10766. }
  10767. return setSelectionBlockData(selectBlock(editorState, mediaBlock), newPosition);
  10768. };
  10769. var clear = exports.clear = function clear(editorState) {
  10770. var contentState = editorState.getCurrentContent();
  10771. var firstBlock = contentState.getFirstBlock();
  10772. var lastBlock = contentState.getLastBlock();
  10773. var allSelected = new Draft.Draft.SelectionState({
  10774. anchorKey: firstBlock.getKey(),
  10775. anchorOffset: 0,
  10776. focusKey: lastBlock.getKey(),
  10777. focusOffset: lastBlock.getLength(),
  10778. hasFocus: true
  10779. });
  10780. return Draft.Draft.RichUtils.toggleBlockType(Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.removeRange(contentState, allSelected, 'backward'), 'remove-range'), 'unstyled');
  10781. };
  10782. var handleKeyCommand = exports.handleKeyCommand = function handleKeyCommand(editorState, command) {
  10783. return Draft.Draft.RichUtils.handleKeyCommand(editorState, command);
  10784. };
  10785. var undo = exports.undo = function undo(editorState) {
  10786. return Draft.Draft.EditorState.undo(editorState);
  10787. };
  10788. var redo = exports.redo = function redo(editorState) {
  10789. return Draft.Draft.EditorState.redo(editorState);
  10790. };
  10791. });
  10792. _commonjsHelpers.unwrapExports(content);
  10793. var content_1 = content.redo;
  10794. var content_2 = content.undo;
  10795. var content_3 = content.handleKeyCommand;
  10796. var content_4 = content.clear;
  10797. var content_5 = content.setMediaPosition;
  10798. var content_6 = content.removeMedia;
  10799. var content_7 = content.setMediaData;
  10800. var content_8 = content.insertMedias;
  10801. var content_9 = content.insertHorizontalLine;
  10802. var content_10 = content.insertAtomicBlock;
  10803. var content_11 = content.insertHTML;
  10804. var content_12 = content.insertText;
  10805. var content_13 = content.toggleSelectionLetterSpacing;
  10806. var content_14 = content.toggleSelectionFontFamily;
  10807. var content_15 = content.toggleSelectionLineHeight;
  10808. var content_16 = content.toggleSelectionFontSize;
  10809. var content_17 = content.toggleSelectionBackgroundColor;
  10810. var content_18 = content.toggleSelectionColor;
  10811. var content_19 = content.decreaseSelectionIndent;
  10812. var content_20 = content.increaseSelectionIndent;
  10813. var content_21 = content.toggleSelectionIndent;
  10814. var content_22 = content.toggleSelectionAlignment;
  10815. var content_23 = content.removeSelectionInlineStyles;
  10816. var content_24 = content.toggleSelectionInlineStyle;
  10817. var content_25 = content.selectionHasInlineStyle;
  10818. var content_26 = content.getSelectionInlineStyle;
  10819. var content_27 = content.toggleSelectionLink;
  10820. var content_28 = content.toggleSelectionEntity;
  10821. var content_29 = content.getSelectionEntityData;
  10822. var content_30 = content.getSelectionEntityType;
  10823. var content_31 = content.toggleSelectionBlockType;
  10824. var content_32 = content.getSelectionText;
  10825. var content_33 = content.getSelectionBlockType;
  10826. var content_34 = content.getSelectionBlockData;
  10827. var content_35 = content.setSelectionBlockData;
  10828. var content_36 = content.getSelectedBlocks;
  10829. var content_37 = content.updateEachCharacterOfSelection;
  10830. var content_38 = content.getSelectionBlock;
  10831. var content_39 = content.removeBlock;
  10832. var content_40 = content.selectNextBlock;
  10833. var content_41 = content.selectBlock;
  10834. var content_42 = content.selectionContainsStrictBlock;
  10835. var content_43 = content.selectionContainsBlockType;
  10836. var content_44 = content.isSelectionCollapsed;
  10837. var content_45 = content.createEditorState;
  10838. var content_46 = content.createEmptyEditorState;
  10839. var content_47 = content.isEditorState;
  10840. var content_48 = content.registerStrictBlockType;
  10841. var base = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10842. Object.defineProperty(exports, "__esModule", {
  10843. value: true
  10844. });
  10845. var braftUniqueIndex = 0;
  10846. var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
  10847. return braftUniqueIndex += 1;
  10848. };
  10849. });
  10850. _commonjsHelpers.unwrapExports(base);
  10851. var base_1 = base.UniqueIndex;
  10852. var color = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10853. Object.defineProperty(exports, "__esModule", {
  10854. value: true
  10855. });
  10856. var _namedColors = {
  10857. "aliceblue": "#f0f8ff",
  10858. "antiquewhite": "#faebd7",
  10859. "aqua": "#00ffff",
  10860. "aquamarine": "#7fffd4",
  10861. "azure": "#f0ffff",
  10862. "beige": "#f5f5dc",
  10863. "bisque": "#ffe4c4",
  10864. "black": "#000000",
  10865. "blanchedalmond": "#ffebcd",
  10866. "blue": "#0000ff",
  10867. "blueviolet": "#8a2be2",
  10868. "brown": "#a52a2a",
  10869. "burlywood": "#deb887",
  10870. "cadetblue": "#5f9ea0",
  10871. "chartreuse": "#7fff00",
  10872. "chocolate": "#d2691e",
  10873. "coral": "#ff7f50",
  10874. "cornflowerblue": "#6495ed",
  10875. "cornsilk": "#fff8dc",
  10876. "crimson": "#dc143c",
  10877. "cyan": "#00ffff",
  10878. "darkblue": "#00008b",
  10879. "darkcyan": "#008b8b",
  10880. "darkgoldenrod": "#b8860b",
  10881. "darkgray": "#a9a9a9",
  10882. "darkgreen": "#006400",
  10883. "darkkhaki": "#bdb76b",
  10884. "darkmagenta": "#8b008b",
  10885. "darkolivegreen": "#556b2f",
  10886. "darkorange": "#ff8c00",
  10887. "darkorchid": "#9932cc",
  10888. "darkred": "#8b0000",
  10889. "darksalmon": "#e9967a",
  10890. "darkseagreen": "#8fbc8f",
  10891. "darkslateblue": "#483d8b",
  10892. "darkslategray": "#2f4f4f",
  10893. "darkturquoise": "#00ced1",
  10894. "darkviolet": "#9400d3",
  10895. "deeppink": "#ff1493",
  10896. "deepskyblue": "#00bfff",
  10897. "dimgray": "#696969",
  10898. "dodgerblue": "#1e90ff",
  10899. "firebrick": "#b22222",
  10900. "floralwhite": "#fffaf0",
  10901. "forestgreen": "#228b22",
  10902. "fuchsia": "#ff00ff",
  10903. "gainsboro": "#dcdcdc",
  10904. "ghostwhite": "#f8f8ff",
  10905. "gold": "#ffd700",
  10906. "goldenrod": "#daa520",
  10907. "gray": "#808080",
  10908. "green": "#008000",
  10909. "greenyellow": "#adff2f",
  10910. "honeydew": "#f0fff0",
  10911. "hotpink": "#ff69b4",
  10912. "indianred ": "#cd5c5c",
  10913. "indigo": "#4b0082",
  10914. "ivory": "#fffff0",
  10915. "khaki": "#f0e68c",
  10916. "lavender": "#e6e6fa",
  10917. "lavenderblush": "#fff0f5",
  10918. "lawngreen": "#7cfc00",
  10919. "lemonchiffon": "#fffacd",
  10920. "lightblue": "#add8e6",
  10921. "lightcoral": "#f08080",
  10922. "lightcyan": "#e0ffff",
  10923. "lightgoldenrodyellow": "#fafad2",
  10924. "lightgrey": "#d3d3d3",
  10925. "lightgreen": "#90ee90",
  10926. "lightpink": "#ffb6c1",
  10927. "lightsalmon": "#ffa07a",
  10928. "lightseagreen": "#20b2aa",
  10929. "lightskyblue": "#87cefa",
  10930. "lightslategray": "#778899",
  10931. "lightsteelblue": "#b0c4de",
  10932. "lightyellow": "#ffffe0",
  10933. "lime": "#00ff00",
  10934. "limegreen": "#32cd32",
  10935. "linen": "#faf0e6",
  10936. "magenta": "#ff00ff",
  10937. "maroon": "#800000",
  10938. "mediumaquamarine": "#66cdaa",
  10939. "mediumblue": "#0000cd",
  10940. "mediumorchid": "#ba55d3",
  10941. "mediumpurple": "#9370d8",
  10942. "mediumseagreen": "#3cb371",
  10943. "mediumslateblue": "#7b68ee",
  10944. "mediumspringgreen": "#00fa9a",
  10945. "mediumturquoise": "#48d1cc",
  10946. "mediumvioletred": "#c71585",
  10947. "midnightblue": "#191970",
  10948. "mintcream": "#f5fffa",
  10949. "mistyrose": "#ffe4e1",
  10950. "moccasin": "#ffe4b5",
  10951. "navajowhite": "#ffdead",
  10952. "navy": "#000080",
  10953. "oldlace": "#fdf5e6",
  10954. "olive": "#808000",
  10955. "olivedrab": "#6b8e23",
  10956. "orange": "#ffa500",
  10957. "orangered": "#ff4500",
  10958. "orchid": "#da70d6",
  10959. "palegoldenrod": "#eee8aa",
  10960. "palegreen": "#98fb98",
  10961. "paleturquoise": "#afeeee",
  10962. "palevioletred": "#d87093",
  10963. "papayawhip": "#ffefd5",
  10964. "peachpuff": "#ffdab9",
  10965. "peru": "#cd853f",
  10966. "pink": "#ffc0cb",
  10967. "plum": "#dda0dd",
  10968. "powderblue": "#b0e0e6",
  10969. "purple": "#800080",
  10970. "rebeccapurple": "#663399",
  10971. "red": "#ff0000",
  10972. "rosybrown": "#bc8f8f",
  10973. "royalblue": "#4169e1",
  10974. "saddlebrown": "#8b4513",
  10975. "salmon": "#fa8072",
  10976. "sandybrown": "#f4a460",
  10977. "seagreen": "#2e8b57",
  10978. "seashell": "#fff5ee",
  10979. "sienna": "#a0522d",
  10980. "silver": "#c0c0c0",
  10981. "skyblue": "#87ceeb",
  10982. "slateblue": "#6a5acd",
  10983. "slategray": "#708090",
  10984. "snow": "#fffafa",
  10985. "springgreen": "#00ff7f",
  10986. "steelblue": "#4682b4",
  10987. "tan": "#d2b48c",
  10988. "teal": "#008080",
  10989. "thistle": "#d8bfd8",
  10990. "tomato": "#ff6347",
  10991. "turquoise": "#40e0d0",
  10992. "violet": "#ee82ee",
  10993. "wheat": "#f5deb3",
  10994. "white": "#ffffff",
  10995. "whitesmoke": "#f5f5f5",
  10996. "yellow": "#ffff00",
  10997. "yellowgreen": "#9acd32"
  10998. };
  10999. var _getHexColor = function _getHexColor(color) {
  11000. color = color.replace('color:', '').replace(';', '').replace(' ', '');
  11001. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  11002. return color;
  11003. } else if (namedColors[color]) {
  11004. return namedColors[color];
  11005. } else if (color.indexOf('rgb') === 0) {
  11006. var rgbArray = color.split(',');
  11007. var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
  11008. var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
  11009. return hex.length === 1 ? '0' + hex : hex;
  11010. }).join('');
  11011. return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
  11012. );
  11013. } else {
  11014. return null;
  11015. }
  11016. };
  11017. var namedColors = exports.namedColors = _namedColors;
  11018. var getHexColor = exports.getHexColor = _getHexColor;
  11019. var detectColorsFromHTMLString = exports.detectColorsFromHTMLString = function detectColorsFromHTMLString(html) {
  11020. return typeof html !== 'string' ? [] : (html.match(/color:[^;]{3,24};/g) || []).map(getHexColor).filter(function (color) {
  11021. return color;
  11022. });
  11023. };
  11024. var detectColorsFromDraftState = exports.detectColorsFromDraftState = function detectColorsFromDraftState(draftState) {
  11025. var result = [];
  11026. if (!draftState || !draftState.blocks || !draftState.blocks.length) {
  11027. return result;
  11028. }
  11029. draftState.blocks.forEach(function (block) {
  11030. if (block && block.inlineStyleRanges && block.inlineStyleRanges.length) {
  11031. block.inlineStyleRanges.forEach(function (inlineStyle) {
  11032. if (inlineStyle.style && inlineStyle.style.indexOf('COLOR-') >= 0) {
  11033. result.push('#' + inlineStyle.style.split('COLOR-')[1]);
  11034. }
  11035. });
  11036. }
  11037. });
  11038. return result.filter(function (color) {
  11039. return color;
  11040. });
  11041. };
  11042. });
  11043. _commonjsHelpers.unwrapExports(color);
  11044. var color_1 = color.namedColors;
  11045. var color_2 = color.getHexColor;
  11046. var color_3 = color.detectColorsFromHTMLString;
  11047. var color_4 = color.detectColorsFromDraftState;
  11048. var dist$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11049. Object.defineProperty(exports, "__esModule", {
  11050. value: true
  11051. });
  11052. exports.ColorUtils = exports.BaseUtils = exports.ContentUtils = undefined;
  11053. var _ContentUtils = _interopRequireWildcard(content);
  11054. var _BaseUtils = _interopRequireWildcard(base);
  11055. var _ColorUtils = _interopRequireWildcard(color);
  11056. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  11057. var ContentUtils = exports.ContentUtils = _ContentUtils;
  11058. var BaseUtils = exports.BaseUtils = _BaseUtils;
  11059. var ColorUtils = exports.ColorUtils = _ColorUtils;
  11060. });
  11061. _commonjsHelpers.unwrapExports(dist$1);
  11062. var dist_1$1 = dist$1.ColorUtils;
  11063. var dist_2$1 = dist$1.BaseUtils;
  11064. var dist_3$1 = dist$1.ContentUtils;
  11065. var dist$2 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11066. (function webpackUniversalModuleDefinition(root, factory) {
  11067. module.exports = factory(React__default);
  11068. })(window, function(__WEBPACK_EXTERNAL_MODULE__2__) {
  11069. return /******/ (function(modules) { // webpackBootstrap
  11070. /******/ // The module cache
  11071. /******/ var installedModules = {};
  11072. /******/
  11073. /******/ // The require function
  11074. /******/ function __webpack_require__(moduleId) {
  11075. /******/
  11076. /******/ // Check if module is in cache
  11077. /******/ if(installedModules[moduleId]) {
  11078. /******/ return installedModules[moduleId].exports;
  11079. /******/ }
  11080. /******/ // Create a new module (and put it into the cache)
  11081. /******/ var module = installedModules[moduleId] = {
  11082. /******/ i: moduleId,
  11083. /******/ l: false,
  11084. /******/ exports: {}
  11085. /******/ };
  11086. /******/
  11087. /******/ // Execute the module function
  11088. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  11089. /******/
  11090. /******/ // Flag the module as loaded
  11091. /******/ module.l = true;
  11092. /******/
  11093. /******/ // Return the exports of the module
  11094. /******/ return module.exports;
  11095. /******/ }
  11096. /******/
  11097. /******/
  11098. /******/ // expose the modules object (__webpack_modules__)
  11099. /******/ __webpack_require__.m = modules;
  11100. /******/
  11101. /******/ // expose the module cache
  11102. /******/ __webpack_require__.c = installedModules;
  11103. /******/
  11104. /******/ // define getter function for harmony exports
  11105. /******/ __webpack_require__.d = function(exports, name, getter) {
  11106. /******/ if(!__webpack_require__.o(exports, name)) {
  11107. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  11108. /******/ }
  11109. /******/ };
  11110. /******/
  11111. /******/ // define __esModule on exports
  11112. /******/ __webpack_require__.r = function(exports) {
  11113. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  11114. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  11115. /******/ }
  11116. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  11117. /******/ };
  11118. /******/
  11119. /******/ // create a fake namespace object
  11120. /******/ // mode & 1: value is a module id, require it
  11121. /******/ // mode & 2: merge all properties of value into the ns
  11122. /******/ // mode & 4: return value when already ns object
  11123. /******/ // mode & 8|1: behave like require
  11124. /******/ __webpack_require__.t = function(value, mode) {
  11125. /******/ if(mode & 1) value = __webpack_require__(value);
  11126. /******/ if(mode & 8) return value;
  11127. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  11128. /******/ var ns = Object.create(null);
  11129. /******/ __webpack_require__.r(ns);
  11130. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  11131. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  11132. /******/ return ns;
  11133. /******/ };
  11134. /******/
  11135. /******/ // getDefaultExport function for compatibility with non-harmony modules
  11136. /******/ __webpack_require__.n = function(module) {
  11137. /******/ var getter = module && module.__esModule ?
  11138. /******/ function getDefault() { return module['default']; } :
  11139. /******/ function getModuleExports() { return module; };
  11140. /******/ __webpack_require__.d(getter, 'a', getter);
  11141. /******/ return getter;
  11142. /******/ };
  11143. /******/
  11144. /******/ // Object.prototype.hasOwnProperty.call
  11145. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  11146. /******/
  11147. /******/ // __webpack_public_path__
  11148. /******/ __webpack_require__.p = "/";
  11149. /******/
  11150. /******/
  11151. /******/ // Load entry module and return exports
  11152. /******/ return __webpack_require__(__webpack_require__.s = 20);
  11153. /******/ })
  11154. /************************************************************************/
  11155. /******/ ([
  11156. /* 0 */
  11157. /***/ (function(module, exports, __webpack_require__) {
  11158. Object.defineProperty(exports, "__esModule", {
  11159. value: true
  11160. });
  11161. var compressImage = exports.compressImage = function compressImage(url) {
  11162. var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1280;
  11163. var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 800;
  11164. return new Promise(function (resolve, reject) {
  11165. var image = new Image();
  11166. image.src = url;
  11167. image.onerror = function (error) {
  11168. reject(error);
  11169. };
  11170. image.onload = function () {
  11171. try {
  11172. var compressCanvas = document.createElement('canvas');
  11173. var scale = this.width > width || this.height > height ? this.width > this.height ? width / this.width : height / this.height : 1;
  11174. compressCanvas.width = this.width * scale;
  11175. compressCanvas.height = this.height * scale;
  11176. var canvasContext = compressCanvas.getContext('2d');
  11177. canvasContext.drawImage(this, 0, 0, compressCanvas.width, compressCanvas.height);
  11178. resolve({
  11179. url: compressCanvas.toDataURL('image/png', 1),
  11180. width: compressCanvas.width,
  11181. height: compressCanvas.height
  11182. });
  11183. } catch (error) {
  11184. reject(error);
  11185. }
  11186. };
  11187. });
  11188. };
  11189. /***/ }),
  11190. /* 1 */
  11191. /***/ (function(module, exports, __webpack_require__) {
  11192. Object.defineProperty(exports, "__esModule", {
  11193. value: true
  11194. });
  11195. var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
  11196. if (isNaN(window.__BRAFT_MM_UNIQUE_INDEX__)) {
  11197. window.__BRAFT_MM_UNIQUE_INDEX__ = 1;
  11198. } else {
  11199. window.__BRAFT_MM_UNIQUE_INDEX__ += 1;
  11200. }
  11201. return window.__BRAFT_MM_UNIQUE_INDEX__;
  11202. };
  11203. /***/ }),
  11204. /* 2 */
  11205. /***/ (function(module, exports) {
  11206. module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
  11207. /***/ }),
  11208. /* 3 */
  11209. /***/ (function(module, exports, __webpack_require__) {
  11210. Object.defineProperty(exports, "__esModule", {
  11211. value: true
  11212. });
  11213. exports.default = {
  11214. remove: 'Kaldır',
  11215. cancel: 'İptal',
  11216. confirm: 'Onayla',
  11217. insert: 'Seçilenleri ekle',
  11218. width: 'Genişlik',
  11219. height: 'Yükseklik',
  11220. image: 'Resim',
  11221. video: 'Görüntü',
  11222. audio: 'Ses',
  11223. embed: 'Nesne göm',
  11224. caption: 'Kitaplık',
  11225. dragTip: 'Tıkla ya da dosya sürükle',
  11226. dropTip: 'Yüklemek için sürükleyin',
  11227. selectAll: 'Tümünü seç',
  11228. deselect: 'Seçimi kaldır',
  11229. removeSelected: 'Seçilenleri kaldır',
  11230. externalInputPlaceHolder: 'Kaynak adı|Kaynak bağlantısı',
  11231. externalInputTip: 'Kaynak asını ve bağlantısını "|" ile ayırın ve Enter\' a basın.',
  11232. addLocalFile: 'Yerel\' den ekle',
  11233. addExternalSource: 'Harici kaynaktan ekle',
  11234. unnamedItem: 'Adlandırılmamış giriş',
  11235. confirmInsert: 'Seçilenleri ekle'
  11236. };
  11237. /***/ }),
  11238. /* 4 */
  11239. /***/ (function(module, exports, __webpack_require__) {
  11240. Object.defineProperty(exports, "__esModule", {
  11241. value: true
  11242. });
  11243. exports.default = {
  11244. remove: '削除する',
  11245. cancel: 'キャンセル',
  11246. confirm: '確認する',
  11247. insert: '選択したアイテムを挿入',
  11248. width: '幅',
  11249. height: '身長',
  11250. image: '絵',
  11251. video: 'ビデオ',
  11252. audio: '音声',
  11253. embed: '埋め込みメディア',
  11254. caption: 'メディアライブラリー',
  11255. dragTip: 'ファイルをこの位置までクリックまたはドラッグします',
  11256. dropTip: 'アップロードするマウスを放します',
  11257. selectAll: 'すべて選択',
  11258. deselect: '選択を解除',
  11259. removeSelected: '選択したアイテムを削除',
  11260. externalInputPlaceHolder: 'リソース名|リソースアドレス',
  11261. externalInputTip: 'リソース名とリソースアドレスは "|"で区切ります。',
  11262. addLocalFile: 'ローカルリソースを追加する',
  11263. addExternalSource: 'ネットワークリソースを追加する',
  11264. unnamedItem: '名前のないアイテム',
  11265. confirmInsert: '選択したアイテムを挿入'
  11266. };
  11267. /***/ }),
  11268. /* 5 */
  11269. /***/ (function(module, exports, __webpack_require__) {
  11270. Object.defineProperty(exports, "__esModule", {
  11271. value: true
  11272. });
  11273. exports.default = {
  11274. remove: '삭제',
  11275. cancel: '취소',
  11276. confirm: '확인',
  11277. insert: '선택한항목삽입',
  11278. width: '너비',
  11279. height: '높이',
  11280. image: '그림',
  11281. video: '비디오',
  11282. audio: '오디오',
  11283. embed: '임베디드미디어',
  11284. caption: '미디어라이브러리',
  11285. dragTip: '파일을 클릭하거나이 지점으로 드래그하십시오.',
  11286. dropTip: '업로드하려면마우스를놓으십시오.',
  11287. selectAll: '모두 선택',
  11288. deselect: '선택 취소',
  11289. removeSelected: '선택한 항목 삭제',
  11290. externalInputPlaceHolder: '리소스 이름 | 리소스 주소',
  11291. externalInputTip: '자원 이름과 자원 주소를 "|"',
  11292. addLocalFile: '로컬 리소스 추가',
  11293. addExternalSource: '네트워크 리소스 추가',
  11294. unnamedItem: '이름없는 항목',
  11295. confirmInsert: '선택한 항목 삽입'
  11296. };
  11297. /***/ }),
  11298. /* 6 */
  11299. /***/ (function(module, exports, __webpack_require__) {
  11300. Object.defineProperty(exports, "__esModule", {
  11301. value: true
  11302. });
  11303. exports.default = {
  11304. remove: 'Usuń',
  11305. cancel: 'Anuluj',
  11306. confirm: 'Potwierdź',
  11307. insert: 'Wstaw wybrane elementy',
  11308. width: 'Szerokość',
  11309. height: 'Wysokość',
  11310. image: 'Obraz',
  11311. video: 'Wideo',
  11312. audio: 'Dźwięk',
  11313. embed: 'Obiekt',
  11314. caption: 'Biblioteka mediów',
  11315. dragTip: 'Kliknij lub przenieś tu pliki',
  11316. dropTip: 'Upuść aby dodać plik',
  11317. selectAll: 'Zaznacz wszystko',
  11318. deselect: 'Odznacz',
  11319. removeSelected: 'Usuń wybrane',
  11320. externalInputPlaceHolder: 'Nazwa źródła|Adres URL',
  11321. externalInputTip: 'Oddziel nazwę i adres URL źródła z pomocą "|", Potwierdź Enter-em',
  11322. addLocalFile: 'Dodaj z komputera',
  11323. addExternalSource: 'Dodaj z Internetu',
  11324. unnamedItem: 'Bez nazwy',
  11325. confirmInsert: 'Dodaj wybrane elementy'
  11326. };
  11327. /***/ }),
  11328. /* 7 */
  11329. /***/ (function(module, exports, __webpack_require__) {
  11330. Object.defineProperty(exports, "__esModule", {
  11331. value: true
  11332. });
  11333. exports.default = {
  11334. remove: '删除',
  11335. cancel: '取消',
  11336. confirm: '确认',
  11337. insert: '插入所选项目',
  11338. width: '宽度',
  11339. height: '高度',
  11340. image: '图片',
  11341. video: '视频',
  11342. audio: '音频',
  11343. embed: '嵌入式媒体',
  11344. caption: '媒体库',
  11345. dragTip: '点击或拖动文件至此',
  11346. dropTip: '放开鼠标以上传',
  11347. selectAll: '选择全部',
  11348. deselect: '取消选择',
  11349. removeSelected: '删除选中项目',
  11350. externalInputPlaceHolder: '资源名称|资源地址',
  11351. externalInputTip: '使用“|”分隔资源名称和资源地址',
  11352. addLocalFile: '添加本地资源',
  11353. addExternalSource: '添加网络资源',
  11354. unnamedItem: '未命名项目',
  11355. confirmInsert: '插入选中项目'
  11356. };
  11357. /***/ }),
  11358. /* 8 */
  11359. /***/ (function(module, exports, __webpack_require__) {
  11360. Object.defineProperty(exports, "__esModule", {
  11361. value: true
  11362. });
  11363. exports.default = {
  11364. remove: '删除',
  11365. cancel: '取消',
  11366. confirm: '确认',
  11367. insert: '插入所选项目',
  11368. width: '宽度',
  11369. height: '高度',
  11370. image: '图片',
  11371. video: '视频',
  11372. audio: '音频',
  11373. embed: '嵌入式媒体',
  11374. caption: '媒体库',
  11375. dragTip: '点击或拖动文件至此',
  11376. dropTip: '放开鼠标以上传',
  11377. selectAll: '选择全部',
  11378. deselect: '取消选择',
  11379. removeSelected: '删除选中项目',
  11380. externalInputPlaceHolder: '资源名称|资源地址',
  11381. externalInputTip: '使用“|”分隔资源名称和资源地址',
  11382. addLocalFile: '添加本地资源',
  11383. addExternalSource: '添加网络资源',
  11384. unnamedItem: '未命名项目',
  11385. confirmInsert: '插入选中项目'
  11386. };
  11387. /***/ }),
  11388. /* 9 */
  11389. /***/ (function(module, exports, __webpack_require__) {
  11390. Object.defineProperty(exports, "__esModule", {
  11391. value: true
  11392. });
  11393. exports.default = {
  11394. remove: 'Remove',
  11395. cancel: 'Cancel',
  11396. confirm: 'Confirm',
  11397. insert: 'Insert Selected Items',
  11398. width: 'Width',
  11399. height: 'Height',
  11400. image: 'Image',
  11401. video: 'Video',
  11402. audio: 'Audio',
  11403. embed: 'Embed',
  11404. caption: 'Media Library',
  11405. dragTip: 'Click Or Drag Files Here',
  11406. dropTip: 'Drop To Upload',
  11407. selectAll: 'Select All',
  11408. deselect: 'Deselect',
  11409. removeSelected: 'Remove Selected Items',
  11410. externalInputPlaceHolder: 'Source Name|Source URL',
  11411. externalInputTip: 'Split source name and source URL with "|", confirm by hit Enter.',
  11412. addLocalFile: 'Add from local',
  11413. addExternalSource: 'Add from Internet',
  11414. unnamedItem: 'Unnamed Item',
  11415. confirmInsert: 'Insert selected items'
  11416. };
  11417. /***/ }),
  11418. /* 10 */
  11419. /***/ (function(module, exports, __webpack_require__) {
  11420. Object.defineProperty(exports, "__esModule", {
  11421. value: true
  11422. });
  11423. var _en = __webpack_require__(9);
  11424. var _en2 = _interopRequireDefault(_en);
  11425. var _zh = __webpack_require__(8);
  11426. var _zh2 = _interopRequireDefault(_zh);
  11427. var _zhHant = __webpack_require__(7);
  11428. var _zhHant2 = _interopRequireDefault(_zhHant);
  11429. var _pl = __webpack_require__(6);
  11430. var _pl2 = _interopRequireDefault(_pl);
  11431. var _kr = __webpack_require__(5);
  11432. var _kr2 = _interopRequireDefault(_kr);
  11433. var _jpn = __webpack_require__(4);
  11434. var _jpn2 = _interopRequireDefault(_jpn);
  11435. var _tr = __webpack_require__(3);
  11436. var _tr2 = _interopRequireDefault(_tr);
  11437. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11438. exports.default = {
  11439. "en": _en2.default,
  11440. "zh": _zh2.default,
  11441. "zh-hant": _zhHant2.default,
  11442. "pl": _pl2.default,
  11443. "kr": _kr2.default,
  11444. "jpn": _jpn2.default,
  11445. "tr": _tr2.default
  11446. };
  11447. /***/ }),
  11448. /* 11 */
  11449. /***/ (function(module, exports) {
  11450. /**
  11451. * When source maps are enabled, `style-loader` uses a link element with a data-uri to
  11452. * embed the css on the page. This breaks all relative urls because now they are relative to a
  11453. * bundle instead of the current page.
  11454. *
  11455. * One solution is to only use full urls, but that may be impossible.
  11456. *
  11457. * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
  11458. *
  11459. * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
  11460. *
  11461. */
  11462. module.exports = function (css) {
  11463. // get current location
  11464. var location = typeof window !== "undefined" && window.location;
  11465. if (!location) {
  11466. throw new Error("fixUrls requires window.location");
  11467. }
  11468. // blank or null?
  11469. if (!css || typeof css !== "string") {
  11470. return css;
  11471. }
  11472. var baseUrl = location.protocol + "//" + location.host;
  11473. var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
  11474. // convert each url(...)
  11475. /*
  11476. This regular expression is just a way to recursively match brackets within
  11477. a string.
  11478. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
  11479. ( = Start a capturing group
  11480. (?: = Start a non-capturing group
  11481. [^)(] = Match anything that isn't a parentheses
  11482. | = OR
  11483. \( = Match a start parentheses
  11484. (?: = Start another non-capturing groups
  11485. [^)(]+ = Match anything that isn't a parentheses
  11486. | = OR
  11487. \( = Match a start parentheses
  11488. [^)(]* = Match anything that isn't a parentheses
  11489. \) = Match a end parentheses
  11490. ) = End Group
  11491. *\) = Match anything and then a close parens
  11492. ) = Close non-capturing group
  11493. * = Match anything
  11494. ) = Close capturing group
  11495. \) = Match a close parens
  11496. /gi = Get all matches, not the first. Be case insensitive.
  11497. */
  11498. var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
  11499. // strip quotes (if they exist)
  11500. var unquotedOrigUrl = origUrl
  11501. .trim()
  11502. .replace(/^"(.*)"$/, function(o, $1){ return $1; })
  11503. .replace(/^'(.*)'$/, function(o, $1){ return $1; });
  11504. // already a full url? no change
  11505. if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
  11506. return fullMatch;
  11507. }
  11508. // convert the url to a full url
  11509. var newUrl;
  11510. if (unquotedOrigUrl.indexOf("//") === 0) {
  11511. //TODO: should we add protocol?
  11512. newUrl = unquotedOrigUrl;
  11513. } else if (unquotedOrigUrl.indexOf("/") === 0) {
  11514. // path should be relative to the base url
  11515. newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
  11516. } else {
  11517. // path should be relative to current directory
  11518. newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
  11519. }
  11520. // send back the fixed url(...)
  11521. return "url(" + JSON.stringify(newUrl) + ")";
  11522. });
  11523. // send back the fixed css
  11524. return fixedCss;
  11525. };
  11526. /***/ }),
  11527. /* 12 */
  11528. /***/ (function(module, exports, __webpack_require__) {
  11529. /*
  11530. MIT License http://www.opensource.org/licenses/mit-license.php
  11531. Author Tobias Koppers @sokra
  11532. */
  11533. var stylesInDom = {};
  11534. var memoize = function (fn) {
  11535. var memo;
  11536. return function () {
  11537. if (typeof memo === "undefined") memo = fn.apply(this, arguments);
  11538. return memo;
  11539. };
  11540. };
  11541. var isOldIE = memoize(function () {
  11542. // Test for IE <= 9 as proposed by Browserhacks
  11543. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  11544. // Tests for existence of standard globals is to allow style-loader
  11545. // to operate correctly into non-standard environments
  11546. // @see https://github.com/webpack-contrib/style-loader/issues/177
  11547. return window && document && document.all && !window.atob;
  11548. });
  11549. var getTarget = function (target) {
  11550. return document.querySelector(target);
  11551. };
  11552. var getElement = (function (fn) {
  11553. var memo = {};
  11554. return function(target) {
  11555. // If passing function in options, then use it for resolve "head" element.
  11556. // Useful for Shadow Root style i.e
  11557. // {
  11558. // insertInto: function () { return document.querySelector("#foo").shadowRoot }
  11559. // }
  11560. if (typeof target === 'function') {
  11561. return target();
  11562. }
  11563. if (typeof memo[target] === "undefined") {
  11564. var styleTarget = getTarget.call(this, target);
  11565. // Special case to return head of iframe instead of iframe itself
  11566. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  11567. try {
  11568. // This will throw an exception if access to iframe is blocked
  11569. // due to cross-origin restrictions
  11570. styleTarget = styleTarget.contentDocument.head;
  11571. } catch(e) {
  11572. styleTarget = null;
  11573. }
  11574. }
  11575. memo[target] = styleTarget;
  11576. }
  11577. return memo[target]
  11578. };
  11579. })();
  11580. var singleton = null;
  11581. var singletonCounter = 0;
  11582. var stylesInsertedAtTop = [];
  11583. var fixUrls = __webpack_require__(11);
  11584. module.exports = function(list, options) {
  11585. if (typeof DEBUG !== "undefined" && DEBUG) {
  11586. if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
  11587. }
  11588. options = options || {};
  11589. options.attrs = typeof options.attrs === "object" ? options.attrs : {};
  11590. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  11591. // tags it will allow on a page
  11592. if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();
  11593. // By default, add <style> tags to the <head> element
  11594. if (!options.insertInto) options.insertInto = "head";
  11595. // By default, add <style> tags to the bottom of the target
  11596. if (!options.insertAt) options.insertAt = "bottom";
  11597. var styles = listToStyles(list, options);
  11598. addStylesToDom(styles, options);
  11599. return function update (newList) {
  11600. var mayRemove = [];
  11601. for (var i = 0; i < styles.length; i++) {
  11602. var item = styles[i];
  11603. var domStyle = stylesInDom[item.id];
  11604. domStyle.refs--;
  11605. mayRemove.push(domStyle);
  11606. }
  11607. if(newList) {
  11608. var newStyles = listToStyles(newList, options);
  11609. addStylesToDom(newStyles, options);
  11610. }
  11611. for (var i = 0; i < mayRemove.length; i++) {
  11612. var domStyle = mayRemove[i];
  11613. if(domStyle.refs === 0) {
  11614. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
  11615. delete stylesInDom[domStyle.id];
  11616. }
  11617. }
  11618. };
  11619. };
  11620. function addStylesToDom (styles, options) {
  11621. for (var i = 0; i < styles.length; i++) {
  11622. var item = styles[i];
  11623. var domStyle = stylesInDom[item.id];
  11624. if(domStyle) {
  11625. domStyle.refs++;
  11626. for(var j = 0; j < domStyle.parts.length; j++) {
  11627. domStyle.parts[j](item.parts[j]);
  11628. }
  11629. for(; j < item.parts.length; j++) {
  11630. domStyle.parts.push(addStyle(item.parts[j], options));
  11631. }
  11632. } else {
  11633. var parts = [];
  11634. for(var j = 0; j < item.parts.length; j++) {
  11635. parts.push(addStyle(item.parts[j], options));
  11636. }
  11637. stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
  11638. }
  11639. }
  11640. }
  11641. function listToStyles (list, options) {
  11642. var styles = [];
  11643. var newStyles = {};
  11644. for (var i = 0; i < list.length; i++) {
  11645. var item = list[i];
  11646. var id = options.base ? item[0] + options.base : item[0];
  11647. var css = item[1];
  11648. var media = item[2];
  11649. var sourceMap = item[3];
  11650. var part = {css: css, media: media, sourceMap: sourceMap};
  11651. if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
  11652. else newStyles[id].parts.push(part);
  11653. }
  11654. return styles;
  11655. }
  11656. function insertStyleElement (options, style) {
  11657. var target = getElement(options.insertInto);
  11658. if (!target) {
  11659. throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
  11660. }
  11661. var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
  11662. if (options.insertAt === "top") {
  11663. if (!lastStyleElementInsertedAtTop) {
  11664. target.insertBefore(style, target.firstChild);
  11665. } else if (lastStyleElementInsertedAtTop.nextSibling) {
  11666. target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
  11667. } else {
  11668. target.appendChild(style);
  11669. }
  11670. stylesInsertedAtTop.push(style);
  11671. } else if (options.insertAt === "bottom") {
  11672. target.appendChild(style);
  11673. } else if (typeof options.insertAt === "object" && options.insertAt.before) {
  11674. var nextSibling = getElement(options.insertInto + " " + options.insertAt.before);
  11675. target.insertBefore(style, nextSibling);
  11676. } else {
  11677. throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
  11678. }
  11679. }
  11680. function removeStyleElement (style) {
  11681. if (style.parentNode === null) return false;
  11682. style.parentNode.removeChild(style);
  11683. var idx = stylesInsertedAtTop.indexOf(style);
  11684. if(idx >= 0) {
  11685. stylesInsertedAtTop.splice(idx, 1);
  11686. }
  11687. }
  11688. function createStyleElement (options) {
  11689. var style = document.createElement("style");
  11690. if(options.attrs.type === undefined) {
  11691. options.attrs.type = "text/css";
  11692. }
  11693. addAttrs(style, options.attrs);
  11694. insertStyleElement(options, style);
  11695. return style;
  11696. }
  11697. function createLinkElement (options) {
  11698. var link = document.createElement("link");
  11699. if(options.attrs.type === undefined) {
  11700. options.attrs.type = "text/css";
  11701. }
  11702. options.attrs.rel = "stylesheet";
  11703. addAttrs(link, options.attrs);
  11704. insertStyleElement(options, link);
  11705. return link;
  11706. }
  11707. function addAttrs (el, attrs) {
  11708. Object.keys(attrs).forEach(function (key) {
  11709. el.setAttribute(key, attrs[key]);
  11710. });
  11711. }
  11712. function addStyle (obj, options) {
  11713. var style, update, remove, result;
  11714. // If a transform function was defined, run it on the css
  11715. if (options.transform && obj.css) {
  11716. result = options.transform(obj.css);
  11717. if (result) {
  11718. // If transform returns a value, use that instead of the original css.
  11719. // This allows running runtime transformations on the css.
  11720. obj.css = result;
  11721. } else {
  11722. // If the transform function returns a falsy value, don't add this css.
  11723. // This allows conditional loading of css
  11724. return function() {
  11725. // noop
  11726. };
  11727. }
  11728. }
  11729. if (options.singleton) {
  11730. var styleIndex = singletonCounter++;
  11731. style = singleton || (singleton = createStyleElement(options));
  11732. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  11733. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  11734. } else if (
  11735. obj.sourceMap &&
  11736. typeof URL === "function" &&
  11737. typeof URL.createObjectURL === "function" &&
  11738. typeof URL.revokeObjectURL === "function" &&
  11739. typeof Blob === "function" &&
  11740. typeof btoa === "function"
  11741. ) {
  11742. style = createLinkElement(options);
  11743. update = updateLink.bind(null, style, options);
  11744. remove = function () {
  11745. removeStyleElement(style);
  11746. if(style.href) URL.revokeObjectURL(style.href);
  11747. };
  11748. } else {
  11749. style = createStyleElement(options);
  11750. update = applyToTag.bind(null, style);
  11751. remove = function () {
  11752. removeStyleElement(style);
  11753. };
  11754. }
  11755. update(obj);
  11756. return function updateStyle (newObj) {
  11757. if (newObj) {
  11758. if (
  11759. newObj.css === obj.css &&
  11760. newObj.media === obj.media &&
  11761. newObj.sourceMap === obj.sourceMap
  11762. ) {
  11763. return;
  11764. }
  11765. update(obj = newObj);
  11766. } else {
  11767. remove();
  11768. }
  11769. };
  11770. }
  11771. var replaceText = (function () {
  11772. var textStore = [];
  11773. return function (index, replacement) {
  11774. textStore[index] = replacement;
  11775. return textStore.filter(Boolean).join('\n');
  11776. };
  11777. })();
  11778. function applyToSingletonTag (style, index, remove, obj) {
  11779. var css = remove ? "" : obj.css;
  11780. if (style.styleSheet) {
  11781. style.styleSheet.cssText = replaceText(index, css);
  11782. } else {
  11783. var cssNode = document.createTextNode(css);
  11784. var childNodes = style.childNodes;
  11785. if (childNodes[index]) style.removeChild(childNodes[index]);
  11786. if (childNodes.length) {
  11787. style.insertBefore(cssNode, childNodes[index]);
  11788. } else {
  11789. style.appendChild(cssNode);
  11790. }
  11791. }
  11792. }
  11793. function applyToTag (style, obj) {
  11794. var css = obj.css;
  11795. var media = obj.media;
  11796. if(media) {
  11797. style.setAttribute("media", media);
  11798. }
  11799. if(style.styleSheet) {
  11800. style.styleSheet.cssText = css;
  11801. } else {
  11802. while(style.firstChild) {
  11803. style.removeChild(style.firstChild);
  11804. }
  11805. style.appendChild(document.createTextNode(css));
  11806. }
  11807. }
  11808. function updateLink (link, options, obj) {
  11809. var css = obj.css;
  11810. var sourceMap = obj.sourceMap;
  11811. /*
  11812. If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
  11813. and there is no publicPath defined then lets turn convertToAbsoluteUrls
  11814. on by default. Otherwise default to the convertToAbsoluteUrls option
  11815. directly
  11816. */
  11817. var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
  11818. if (options.convertToAbsoluteUrls || autoFixUrls) {
  11819. css = fixUrls(css);
  11820. }
  11821. if (sourceMap) {
  11822. // http://stackoverflow.com/a/26603875
  11823. css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
  11824. }
  11825. var blob = new Blob([css], { type: "text/css" });
  11826. var oldSrc = link.href;
  11827. link.href = URL.createObjectURL(blob);
  11828. if(oldSrc) URL.revokeObjectURL(oldSrc);
  11829. }
  11830. /***/ }),
  11831. /* 13 */
  11832. /***/ (function(module, exports) {
  11833. module.exports = "data:font/ttf;base64,AAEAAAALAIAAAwAwT1MvMg8SBsIAAAC8AAAAYGNtYXBWNv1DAAABHAAAANRnYXNwAAAAEAAAAfAAAAAIZ2x5ZtZLKCQAAAH4AAAPTGhlYWQT25ZrAAARRAAAADZoaGVhB8ID3gAAEXwAAAAkaG10eGoAC+sAABGgAAAAdGxvY2EqcC3wAAASFAAAADxtYXhwACcAewAAElAAAAAgbmFtZZlKCfsAABJwAAABhnBvc3QAAwAAAAAT+AAAACAAAwPsAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADprAPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAuAAAACoAIAAEAAoAAQAg4DTgN+BC4V3iQ+gN6Mno/ukD6QjpD+kT6RjpHOkm6YDprP/9//8AAAAAACDgNOA34ELhXeJD6A3oyej+6QHpB+kO6RHpFukc6SbpgOms//3//wAB/+Mf0B/OH8Qeqh3FF/wXQRcNFwsXCBcDFwIXABb9FvQWmxZwAAMAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAPAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAIBAACBAwAC1QADAAcAAAEzESMhETMRAlaqqv6qqgLV/awCVP2sAAABAVYAgQMqAtUAAgAACQIBVgHU/iwC1f7W/tYAAQCqACsDVgOBAC4AAAEyFx4BFxYVFAcOAQcGIyInLgEnJjUzFBceARcWMzI3PgE3NjU0Jy4BJyYjFSc3AgBGPz5dGxsbG10+PkdGPz5dGxtWFBRFLy81NS8vRRQUFBRFLy811tYC1RsbXD4+Rkc+Pl0bGxsbXT4+RzYuL0UUFBQURS8uNjUvLkYUFKzW1gAAAwBWAAEDqgNVABsANwA7AAAlMjc+ATc2NTQnLgEnJiMiBw4BBwYVFBceARcWEzIXHgEXFhUUBw4BBwYjIicuAScmNTQ3PgE3NgMhFSECAEY/Pl0bGxsbXT4+R0Y/Pl0bGxsbXT4+R1hOTnMiISEic05NWVhOTnMiISEic05NfQGs/lRVGxtdPj5HRj4/XRsbGxtdPz5GRz4+XRsbAwAiIXRNTlhZTU50ISEhIXROTVlYTk10ISL+gFQAAAABAKoAAQOAA1UAHwAAATMRIREUBisBIiY1ESE1IxUUBiMhIiY9ATQ2MyEyFhUDAID+qhgSVhIYAaoqGBL+ABIaGhICABIYAwH+qv6AEhgYEgHWqioSGhoSqhIYGBIAAAABAIAAAwOAA1UAMwAAJTIWFRQGIyImNTwBNyUOASMiJjU0NjMyFhclLgE1NDYzMhYVFAYjIiYnBR4BFRQGBwU+AQMAM0lJMzNJAv7SEiwaNExLNRktEgEsAQNLNTRMSzUZLRL+1AEDAgIBMBAs/UkzM0tLMwcPBrAREUs1NEwSEK4HDwg0TEw0NUsTEbAIDwcIDwewDxEAAAMAVgArA6oDVQACAAYAGgAALQI3FTM1FyERFAYjISImNREhNTQ2OwEyFhUBgAFA/sAqrFQBADAk/VQkMAEAMCSsJDCr1qrWVlZW/dYkMjIkAipWJDAwJAAEAIAAgQOAAtUAAwAHAAsADwAAEyEVIRU1IRUBNSEVJTUhFYADAP0AAwD9AAMA/QADAALVVKxWVv6sVFSqVlYABABVACIDqwN3AAQAIQA9AEIAACUzESMREyIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMRIicuAScmNTQ3PgE3NjMyFx4BFxYVFAcOAQcGAzM1IxUB1VZWK1hOTnQhIiIhdE5OWFhOTnQhIiIhdE5OWEc+Pl0aGxsaXT4+R0c+Pl0aGxsaXT4+clZW9wEA/wACgCEic05OWFlNTnQhIiIhdE5NWVhOTnMiIf0AGxtdPj5HRj8+XBsbGxtcPj9GRz4+XRsbAdZVVQAABABVACIDqwN3AAQAIQA9AFIAACUzNSMVEyIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMRIicuAScmNTQ3PgE3NjMyFx4BFxYVFAcOAQcGAyIGFTM0NjMyFhUUBhUzNDY1NCYjAdVWVitYTk50ISIiIXROTlhYTk50ISIiIXROTlhHPj5dGhsbGl0+PkdHPj5dGhsbGl0+PkdHZFYyIyMygFaAZEfNVVUCqiEic05OWFlNTnQhIiIhdE5NWVhOTnMiIf0AGxtdPj5HRj8+XBsbGxtcPj9GRz4+XRsbAlZkRyMyMiNALWhIPVBHZAAAAgBVAM0DqwLNAAUACwAAASc3JwkBJTcnNwkBAZHExDz/AAEAARrExDwBAP8AAQnExDz/AP8APMTEPP8A/wAAAAMAVQAiA6sDdwAcACsAOgAAASIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMBNDc+ATc2MzIWFwEuATUBIiYnAR4BFRQHDgEHBiMCAFhOTXQiIiIidE1OWFhOTXQiIiIidE1OWP6rGxtcPj9GOmot/iIjJQFVOmotAd4jJRsbXD4/RgN3ISJ0Tk1YWE5OdCEiIiF0Tk5YWE1OdCIh/lZGPj5dGxslI/4iLWo6/qomIwHeLWs5Rz4+XRsbAAAAAAMAgADNA4ACzQADAAcACwAANyE1ITUhNSE1FSE1gAMA/QADAP0AAwDNVYBV1lZWAAEAZAAlA1wDXABEAAABERQHBgcGBwYjIicmJyYnJjU0NzY3Njc2MzIXEQURFAcGBwYHBiMiJyYnJicmNTQ3Njc2NzYzMhcRNDc2NyU2MzIXFhUDXBERGhkaGRYXGRoZGhEREREaGRoZFzMr/oURERoZGhkXFhkaGRoRERERGhkaGRY0KwoJDwGbBggUDg4DLP3WGBQTCgsFBQUFCwoTFBgZExQKCwUFEwEKdv6iGRMTCwsFBQUFCwsTExkZExMLCgYFEwHeDw0MBX8CDg4UAAAEAHUAQgOJA1YALwA8AGIAeAAAAS4BBw4BJy4BJy4BBwYiJyYGBw4BJyYGBxQVHAEVFBUeATM2MzoBMzIzMjY3PAE1BSImNTQ2MzIWFRQGJyUqASM8ATU6ATMUFhUUFxwBFQYHFAYHDgEnLgE3PgE3OgEzPAE1BT4BNzoBMxQWBw4BJy4BNz4BNzoBMwKBARkZChUJCxcEFEMvBw8HHikMDCgdFyILCxgWNDM0ZzQzNBsaAf77L0FBMDBAQDEBtx8/IDRoNgEBAQENCxVFICIlBgc3JAcNCf7OAQICEyQTAwUFSiMmOAIBOiYHEAkCzhcaAQEBAwIJCC0fCAEBBhgbGxYGBBMVKCgpUCgoKQ8VARcaSpRK7T8uMEA/LzBAARchPyAKEgkzMjNmMjMzFCwRIBAOD0IjJjQDN2053QwUCi5dLSUsBgVEJig+BAAAAAAEAAAAAAQAA0AAGwAzAE8AUwAAARQXHgEXFjMyNz4BNzY1NCcuAScmIyIHDgEHBgEjLgEjISIGByMiBhURFBYzITI2NRE0JgEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYBIzUzATAQETgmJisrJiY4ERAQETgmJisrJiY4ERACkOAMJDD/ADAkDOAaJiYaA4AaJib+Jjs0M00XFhYXTTM0Ozs0M00XFhYXTTM0AYWAgAFgKyYmOBEQEBE4JiYrKyYmOBEQEBE4JiYBNTBQUDAmGv3AGiYmGgJAGib9hBYXTTM0Ozs0M00XFhYXTTM0Ozs0M00XFgG8QAABAJEAogOAAt4ABgAAAScHFwEnAQGAszzvAgA8/jwBGrM87wIAPP48AAAAAAEA4gCAAx4CyQAmAAABNzY0JyYiDwEnJiIHBhQfAQcGFBceATMyNj8BFx4BMzI2NzY0LwECPOINDQwkDOLiDCQMDQ3i4g0NBhAICBAG4uIGEAgIEAYNDeIBq+IMIw0MDOLiDAwNIwzi4g0jDAcGBgfh4QcGBgcMIw3iAAACAIAAYwNqA00AIgAvAAABIyc+ATU0Jy4BJyYjIgcOAQcGFRQXHgEXFjMyNjcXFRc3JyEiJjU0NjMyFhUUBiMClSEMHyQWFkszMjo5MzJLFhYWFksyMzk0XCUL1j/V/wBPcXFPUHBwUAF3DCRdMzoyM0sWFhYWSzMyOjkyM0sWFiQfDCLUP9VxT1BwcFBPcQACAGQAIgOcA3cATQBZAAABPgE1NCYnNz4BLwEuAQ8BLgEvAS4BKwEiBg8BDgEHJyYGDwEGFh8BDgEVFBYXBw4BHwEeAT8BHgEfAR4BOwEyNj8BPgE3FxY2PwE2JicFIiY1NDYzMhYVFAYDPQECAgFaBgMEVQQPB2oRJBQQAQwIqggMARAUJBFqBw8EVQQDBloBAgIBWgYDBFUEDwdqESQUEAEMCKoIDAEQFCQRagcPBFUEAwb+aT5XVz4+V1cBowoVCwsUC0YFDweUBwUDKgwVCHIHCgoHcggVDCoDBQeUBw8FRgsVCgsVCkYFEAeTBwUCKw0VCHEICgoIcQgVDSsDBgeTBxAFJlg+PldXPj5YAAEA1QCiAysC9wALAAABIREjESE1IREzESEDK/8AVv8AAQBWAQABov8AAQBVAQD/AAAAAAAJAAAAQAQAA0AAAwAHAAsADwATABcAGwAfACIAABMRIREBIzUzNSM1MzUjNTMBIREhEyM1MzUjNTM1IzUzBRElAAQA/MCAgICAgIACQP4AAgDAgICAgICA/cABAANA/QADAP1AgICAgID9gAKA/YCAgICAgID+gMAAAAAABgBA/8ADwAPAABkAIQA5AEcAVQBjAAABLgEnLgEnLgEjISIGFREUFjMhMjY1ETQmJyceARcjNR4BExQGIyEiJjURNDYzMDM6ATMyMRUUFjsBAyEiJjU0NjMhMhYVFAYnISImNTQ2MyEyFhUUBichIiY1NDYzITIWFRQGA5YRLRkaMxcnKQv+ECEvLyEC4CEvDhyFFyUNmhEphgkH/SAHCQkHTU66TU4TDeCg/kANExMNAcANExMN/kANExMNAcANExMN/kANExMNAcANExMC2xczGhktERwOLyH8oCEvLyECcAspJzYXKRGaDSX86AcJCQcDYAcJ4A0T/gATDQ0TEw0NE4ATDQ0TEw0NE4ATDQ0TEw0NEwAAAAcAAP/ABAADRgALABcAIwAvADsARwBTAAAlNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYlNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYlNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYBoDgoKDg4KCg4/mA4KCg4OCgoOANAOCgoODgoKDj9OjgoKDg4KCg4Akw4KCg4OCgoOP20OCgoODgoKDgCTDgoKDg4KCg4ICg4OCgoODgByCg4OCgoODgoKDg4KCg4OAFOKDg4KCg4OP3cKDg4KCg4OCgoODgoKDg4AnQoODgoKDg4AAUAfAAAA4QDVQAiAC0AOABGAFQAAAEjNTQmKwEiBh0BIyIGFRQWOwERFBYzITI2NREzMjY1NCYjJTQ2OwEyFh0BIzUBFAYjISImNREhEQEiBh0BFBYzMjY9ATQmMyIGHQEUFjMyNj0BNCYDXZtEMJwwRJsQFxcQJ0QwAYQwRCcQFxcQ/i8WEJwQFugBXRcQ/nwQFwHS/skQFhYQEBcXjBAXFxAQFhYCuicwREQwJxcQEBb+BzBERDAB+RYQEBcnEBcXECcn/ZMQFhYQAfn+BwGEFxDoEBcXEOgQFxcQ6BAXFxDoEBcAAAABAAAAAQAANAmLwV8PPPUACwQAAAAAANheKPcAAAAA2F4o9wAA/8AEAAPAAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAQAAAEAAAAAAAAAAAAAAAAAAAAdBAAAAAAAAAAAAAAAAgAAAAQAAQAEAAFWBAAAqgQAAFYEAACqBAAAgAQAAFYEAACABAAAVQQAAFUEAABVBAAAVQQAAIAEAABkBAAAdQQAAAAEAACRBAAA4gQAAIAEAABkBAAA1QQAAAAEAABABAAAAAQAAHwAAAAAAAoAFAAeADIAQACIAOYBFgFiAY4BrgIUAowCrAMMAyQDjAQ0BLIEyAUGBU4F1gXwBi4GugcyB6YAAQAAAB0AeQAJAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGljb21vb24AaQBjAG8AbQBvAG8AblZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGljb21vb24AaQBjAG8AbQBvAG8Abmljb21vb24AaQBjAG8AbQBvAG8AblJlZ3VsYXIAUgBlAGcAdQBsAGEAcmljb21vb24AaQBjAG8AbQBvAG8AbkZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
  11834. /***/ }),
  11835. /* 14 */
  11836. /***/ (function(module, exports) {
  11837. /*
  11838. MIT License http://www.opensource.org/licenses/mit-license.php
  11839. Author Tobias Koppers @sokra
  11840. */
  11841. // css base code, injected by the css-loader
  11842. module.exports = function(useSourceMap) {
  11843. var list = [];
  11844. // return the list of modules as css string
  11845. list.toString = function toString() {
  11846. return this.map(function (item) {
  11847. var content = cssWithMappingToString(item, useSourceMap);
  11848. if(item[2]) {
  11849. return "@media " + item[2] + "{" + content + "}";
  11850. } else {
  11851. return content;
  11852. }
  11853. }).join("");
  11854. };
  11855. // import a list of modules into the list
  11856. list.i = function(modules, mediaQuery) {
  11857. if(typeof modules === "string")
  11858. modules = [[null, modules, ""]];
  11859. var alreadyImportedModules = {};
  11860. for(var i = 0; i < this.length; i++) {
  11861. var id = this[i][0];
  11862. if(typeof id === "number")
  11863. alreadyImportedModules[id] = true;
  11864. }
  11865. for(i = 0; i < modules.length; i++) {
  11866. var item = modules[i];
  11867. // skip already imported module
  11868. // this implementation is not 100% perfect for weird media query combinations
  11869. // when a module is imported multiple times with different media queries.
  11870. // I hope this will never occur (Hey this way we have smaller bundles)
  11871. if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
  11872. if(mediaQuery && !item[2]) {
  11873. item[2] = mediaQuery;
  11874. } else if(mediaQuery) {
  11875. item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
  11876. }
  11877. list.push(item);
  11878. }
  11879. }
  11880. };
  11881. return list;
  11882. };
  11883. function cssWithMappingToString(item, useSourceMap) {
  11884. var content = item[1] || '';
  11885. var cssMapping = item[3];
  11886. if (!cssMapping) {
  11887. return content;
  11888. }
  11889. if (useSourceMap && typeof btoa === 'function') {
  11890. var sourceMapping = toComment(cssMapping);
  11891. var sourceURLs = cssMapping.sources.map(function (source) {
  11892. return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
  11893. });
  11894. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  11895. }
  11896. return [content].join('\n');
  11897. }
  11898. // Adapted from convert-source-map (MIT)
  11899. function toComment(sourceMap) {
  11900. // eslint-disable-next-line no-undef
  11901. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  11902. var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  11903. return '/*# ' + data + ' */';
  11904. }
  11905. /***/ }),
  11906. /* 15 */
  11907. /***/ (function(module, exports) {
  11908. module.exports = function escape(url) {
  11909. if (typeof url !== 'string') {
  11910. return url
  11911. }
  11912. // If url is already wrapped in quotes, remove them
  11913. if (/^['"].*['"]$/.test(url)) {
  11914. url = url.slice(1, -1);
  11915. }
  11916. // Should url be wrapped?
  11917. // See https://drafts.csswg.org/css-values-3/#urls
  11918. if (/["'() \t\n]/.test(url)) {
  11919. return '"' + url.replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"'
  11920. }
  11921. return url
  11922. };
  11923. /***/ }),
  11924. /* 16 */
  11925. /***/ (function(module, exports, __webpack_require__) {
  11926. var escape = __webpack_require__(15);
  11927. exports = module.exports = __webpack_require__(14)(false);
  11928. // imports
  11929. // module
  11930. exports.push([module.i, "@font-face {\n font-family: 'bf-icons';\n src: url(" + escape(__webpack_require__(13)) + ") format(\"truetype\");\n font-weight: normal;\n font-style: normal; }\n\n.braft-finder [class^=\"braft-icon-\"], .braft-finder [class*=\" braft-icon-\"] {\n /* use !important to prevent issues with browser extensions that change fonts */\n font-family: 'bf-icons' !important;\n font-style: normal;\n font-weight: normal;\n font-variant: normal;\n text-transform: none;\n /* Better Font Rendering =========== */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale; }\n\n.braft-finder .braft-icon-code:before {\n content: \"\\E903\"; }\n\n.braft-finder .braft-icon-pause:before {\n content: \"\\E034\"; }\n\n.braft-finder .braft-icon-play_arrow:before {\n content: \"\\E037\"; }\n\n.braft-finder .braft-icon-bin:before {\n content: \"\\E9AC\"; }\n\n.braft-finder .braft-icon-replay:before {\n content: \"\\E042\"; }\n\n.braft-finder .braft-icon-close:before {\n content: \"\\E913\"; }\n\n.braft-finder .braft-icon-music:before {\n content: \"\\E90E\"; }\n\n.braft-finder .braft-icon-camera:before {\n content: \"\\E911\"; }\n\n.braft-finder .braft-icon-file-text:before {\n content: \"\\E926\"; }\n\n.braft-finder .braft-icon-film:before {\n content: \"\\E91C\"; }\n\n.braft-finder .braft-icon-paste:before {\n content: \"\\E92D\"; }\n\n.braft-finder .braft-icon-spinner:before {\n content: \"\\E980\"; }\n\n.braft-finder .braft-icon-media:before {\n content: \"\\E90F\"; }\n\n.braft-finder .braft-icon-add:before {\n content: \"\\E918\"; }\n\n.braft-finder .braft-icon-done:before {\n content: \"\\E912\"; }\n\n.braft-finder .braft-icon-drop-down:before {\n content: \"\\E906\"; }\n\n.braft-finder .braft-icon-drop-up:before {\n content: \"\\E909\"; }\n\n.braft-finder .braft-icon-help:before {\n content: \"\\E902\"; }\n\n.braft-finder .braft-icon-info:before {\n content: \"\\E901\"; }\n\n.braft-finder .braft-icon-menu:before {\n content: \"\\E908\"; }\n\n.pull-left {\n float: left; }\n\n.pull-right {\n float: right; }\n\n.braft-finder .bf-uploader {\n position: relative;\n height: 370px;\n margin: 0; }\n .braft-finder .bf-uploader.draging .bf-list-wrap,\n .braft-finder .bf-uploader.draging .bf-add-external {\n pointer-events: none; }\n .braft-finder .bf-uploader input::-webkit-input-placeholder {\n color: #ccc; }\n .braft-finder .bf-uploader input::-moz-placeholder {\n color: #ccc; }\n .braft-finder .bf-uploader input::-ms-input-placeholder {\n color: #ccc; }\n\n.braft-finder .bf-list-wrap {\n position: relative;\n height: 370px; }\n\n.braft-finder .bf-list-tools {\n z-index: 1;\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n height: 20px;\n padding: 0 15px;\n background-color: #fff; }\n .braft-finder .bf-list-tools span {\n height: 26px;\n font-size: 12px;\n line-height: 20px;\n cursor: pointer;\n user-select: none; }\n .braft-finder .bf-list-tools span[disabled] {\n opacity: .3;\n pointer-events: none; }\n .braft-finder .bf-list-tools .bf-select-all,\n .braft-finder .bf-list-tools .bf-deselect-all {\n float: left;\n margin-right: 5px;\n color: #bbb; }\n .braft-finder .bf-list-tools .bf-select-all:hover,\n .braft-finder .bf-list-tools .bf-deselect-all:hover {\n color: #3498db; }\n .braft-finder .bf-list-tools .bf-remove-selected {\n float: right;\n color: #e74c3c; }\n .braft-finder .bf-list-tools .bf-remove-selected:hover {\n color: #c92e1e; }\n\n.braft-finder .bf-list {\n position: absolute;\n z-index: 1;\n top: 30px;\n right: 0;\n left: 0;\n bottom: 0;\n margin: 0;\n padding: 0 10px;\n list-style: none;\n overflow: auto; }\n .braft-finder .bf-list::-webkit-scrollbar {\n width: 5px;\n height: 5px;\n background-color: #fff; }\n .braft-finder .bf-list::-webkit-scrollbar-track {\n background-color: #fff; }\n .braft-finder .bf-list::-webkit-scrollbar-thumb {\n background-color: rgba(0, 0, 0, 0.1); }\n\n.braft-finder .bf-item,\n.braft-finder .bf-add-item {\n position: relative;\n display: block;\n float: left;\n width: 113px;\n height: 113px;\n margin: 5px;\n overflow: hidden;\n border-radius: 3px; }\n\n.braft-finder .bf-item.uploading {\n pointer-events: none; }\n\n.braft-finder .bf-item.error::before {\n display: block;\n content: \"\\E901\"; }\n\n.braft-finder .bf-item.error::after {\n position: absolute;\n z-index: 1;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(231, 76, 60, 0.8);\n content: ''; }\n\n.braft-finder .bf-item.error:hover::after {\n background-color: rgba(231, 76, 60, 0.9); }\n\n.braft-finder .bf-item.error .bf-item-uploading {\n display: none; }\n\n.braft-finder .bf-add-item {\n background-color: #ecedef;\n color: #999; }\n .braft-finder .bf-add-item:hover {\n background-color: #e1e2e3; }\n .braft-finder .bf-add-item i {\n display: block;\n width: 113px;\n height: 113px;\n font-size: 48px;\n line-height: 113px;\n text-align: center; }\n .braft-finder .bf-add-item input {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n opacity: 0;\n cursor: pointer; }\n\n.braft-finder .bf-item::before {\n display: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 113px;\n height: 113px;\n color: #fff;\n font-size: 48px;\n font-family: 'bf-icons';\n line-height: 113px;\n text-align: center; }\n\n.braft-finder .bf-item::after {\n position: absolute;\n z-index: 1;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(52, 152, 219, 0);\n content: ''; }\n\n.braft-finder .bf-item:hover::after {\n background-color: rgba(52, 152, 219, 0.3); }\n\n.braft-finder .bf-item:hover .bf-item-remove {\n display: block; }\n\n.braft-finder .bf-item.active::before {\n display: block;\n content: \"\\E912\"; }\n\n.braft-finder .bf-item.active::after {\n background-color: rgba(52, 152, 219, 0.6); }\n\n.braft-finder .bf-item.active:hover::after {\n background-color: rgba(52, 152, 219, 0.8); }\n\n.braft-finder .bf-item.active:hover .bf-item-remove {\n display: none; }\n\n.braft-finder .bf-item-uploading {\n box-sizing: border-box;\n position: absolute;\n z-index: 3;\n top: 52px;\n left: 10px;\n width: 93px;\n height: 10px;\n overflow: hidden;\n background-color: rgba(255, 255, 255, 0.3);\n border-radius: 5px;\n box-shadow: 0 0 0 100px rgba(0, 0, 0, 0.5); }\n\n.braft-finder .bf-item-uploading-bar {\n height: 10px;\n background-color: #3498db;\n border-radius: 0; }\n\n.braft-finder .bf-item-remove {\n display: none;\n position: absolute;\n z-index: 2;\n top: 0;\n right: 0;\n width: 28px;\n height: 28px;\n color: #fff;\n font-size: 18px;\n line-height: 28px;\n text-align: center;\n cursor: pointer; }\n .braft-finder .bf-item-remove:hover {\n color: #e74c3c; }\n\n.braft-finder .bf-item-title {\n display: none;\n box-sizing: border-box;\n position: absolute;\n z-index: 2;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 40px;\n padding: 0 5px;\n overflow: hidden;\n background-image: linear-gradient(rgba(0, 0, 0, 0), black);\n color: #fff;\n font-size: 12px;\n line-height: 55px;\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap; }\n\n.braft-finder .bf-image {\n width: 100%;\n height: 100%;\n background-color: #eee;\n user-select: none; }\n .braft-finder .bf-image img {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover; }\n\n.braft-finder .bf-video {\n background-color: #8e44ad; }\n\n.braft-finder .bf-audio {\n background-color: #f39c12; }\n\n.braft-finder .bf-embed {\n background-color: #f1c40f; }\n\n.braft-finder .bf-icon {\n display: block;\n width: 113px;\n height: 113px;\n overflow: hidden;\n color: #fff;\n text-align: center;\n text-decoration: none; }\n .braft-finder .bf-icon i, .braft-finder .bf-icon span {\n display: block; }\n .braft-finder .bf-icon i {\n margin-top: 35px;\n font-size: 24px; }\n .braft-finder .bf-icon span {\n width: 103px;\n margin: 10px auto;\n overflow: hidden;\n font-size: 12px;\n text-overflow: ellipsis;\n white-space: nowrap; }\n\n.braft-finder .bf-drag-uploader {\n box-sizing: border-box;\n position: absolute;\n z-index: 2;\n top: 0;\n right: 15px;\n left: 15px;\n height: 100%;\n background-color: #fff;\n border: dashed 1px #bbb;\n text-align: center;\n opacity: 0;\n pointer-events: none; }\n .braft-finder .bf-drag-uploader:hover, .braft-finder .bf-drag-uploader.draging {\n background-color: #f1f2f3; }\n .braft-finder .bf-drag-uploader.active {\n opacity: 1;\n pointer-events: auto; }\n\n.braft-finder .bf-uploader-buttons {\n height: 370px;\n margin: auto;\n text-align: center; }\n\n.braft-finder .bf-drag-tip {\n display: inline-block;\n margin-top: 150px;\n color: #ccc;\n text-align: center;\n font-size: 28px;\n font-weight: normal;\n line-height: 40px; }\n .braft-finder .bf-drag-tip input {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 100%;\n opacity: 0;\n color: #fff;\n text-indent: -100px;\n cursor: pointer; }\n\n.braft-finder .bf-manager-footer {\n height: 36px;\n margin: 10px 0;\n padding: 0 15px; }\n .braft-finder .bf-manager-footer .button {\n float: right;\n height: 36px;\n margin-left: 5px;\n padding: 0 35px;\n font-size: 12px;\n font-weight: 700;\n border: none;\n border-radius: 3px;\n cursor: pointer; }\n .braft-finder .bf-manager-footer .button-insert {\n color: #fff;\n background-color: #3498db; }\n .braft-finder .bf-manager-footer .button-insert:hover {\n background-color: #2084c7; }\n .braft-finder .bf-manager-footer .button-insert[disabled] {\n opacity: .3;\n pointer-events: none;\n filter: grayscale(0.4); }\n .braft-finder .bf-manager-footer .button-cancel {\n color: #999;\n background-color: #e8e8e9; }\n .braft-finder .bf-manager-footer .button-cancel:hover {\n background-color: #d8d8d9; }\n\n.braft-finder .bf-toggle-external-form {\n color: #666;\n font-size: 12px;\n line-height: 36px; }\n .braft-finder .bf-toggle-external-form span {\n color: #bbb;\n line-height: 16px;\n cursor: pointer;\n user-select: none; }\n .braft-finder .bf-toggle-external-form span:hover {\n color: #3498db; }\n .braft-finder .bf-toggle-external-form span i {\n position: relative;\n top: 2px;\n font-size: 16px; }\n\n.braft-finder .bf-add-external {\n position: absolute;\n z-index: 3;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: #fff; }\n .braft-finder .bf-add-external input {\n border: solid 1px rgba(0, 0, 0, 0.3);\n border: solid 0.5px rgba(0, 0, 0, 0.3);\n box-shadow: none; }\n .braft-finder .bf-add-external input:focus {\n border-color: #3498db;\n box-shadow: none; }\n\n.braft-finder .bf-external-form {\n width: 500px;\n max-width: 90%;\n margin: 91px auto 0 auto; }\n\n.braft-finder .bf-external-input {\n position: relative;\n width: 100%;\n height: 40px;\n margin-bottom: 10px; }\n .braft-finder .bf-external-input div {\n position: absolute;\n top: 0;\n right: 85px;\n left: 0;\n height: 40px; }\n .braft-finder .bf-external-input input,\n .braft-finder .bf-external-input textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n height: 40px;\n padding: 0 10px;\n border: none;\n border-radius: 3px;\n outline: none;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);\n color: #999;\n font-size: 18px; }\n .braft-finder .bf-external-input input:focus,\n .braft-finder .bf-external-input textarea:focus {\n box-shadow: inset 0 0 0 1px #3498db; }\n .braft-finder .bf-external-input textarea {\n height: 100px;\n font-size: 14px; }\n .braft-finder .bf-external-input button {\n position: absolute;\n top: 0;\n right: 0;\n width: 80px;\n height: 40px;\n background-color: #3498db;\n border: none;\n border-radius: 3px;\n color: #fff;\n font-size: 14px;\n font-weight: bold;\n cursor: pointer; }\n .braft-finder .bf-external-input button:disabled {\n opacity: .3;\n pointer-events: none;\n filter: grayscale(0.4); }\n .braft-finder .bf-external-input button:hover {\n background-color: #2084c7; }\n\n.braft-finder .bf-switch-external-type {\n overflow: hidden;\n text-align: center; }\n .braft-finder .bf-switch-external-type button {\n width: auto;\n height: 30px;\n margin: 10px 5px;\n padding: 0 10px;\n background-color: #e8e9ea;\n border: none;\n border-radius: 3px;\n color: #999;\n font-size: 12px;\n cursor: pointer; }\n .braft-finder .bf-switch-external-type button:hover {\n background-color: #d8d9da; }\n .braft-finder .bf-switch-external-type button:only-child {\n display: none; }\n .braft-finder .bf-switch-external-type[data-type=\"IMAGE\"] [data-type=\"IMAGE\"],\n .braft-finder .bf-switch-external-type[data-type=\"VIDEO\"] [data-type=\"VIDEO\"],\n .braft-finder .bf-switch-external-type[data-type=\"AUDIO\"] [data-type=\"AUDIO\"],\n .braft-finder .bf-switch-external-type[data-type=\"EMBED\"] [data-type=\"EMBED\"],\n .braft-finder .bf-switch-external-type[data-type=\"FILE\"] [data-type=\"FILE\"] {\n background-color: #3498db;\n color: #fff; }\n\n.braft-finder .bf-external-tip {\n display: block;\n margin-top: 15px;\n color: #ccc;\n font-size: 12px;\n text-align: center; }\n", ""]);
  11931. // exports
  11932. /***/ }),
  11933. /* 17 */
  11934. /***/ (function(module, exports, __webpack_require__) {
  11935. var content = __webpack_require__(16);
  11936. if(typeof content === 'string') content = [[module.i, content, '']];
  11937. var transform;
  11938. var options = {"hmr":true};
  11939. options.transform = transform;
  11940. options.insertInto = undefined;
  11941. var update = __webpack_require__(12)(content, options);
  11942. if(content.locals) module.exports = content.locals;
  11943. /***/ }),
  11944. /* 18 */
  11945. /***/ (function(module, exports, __webpack_require__) {
  11946. Object.defineProperty(exports, "__esModule", {
  11947. value: true
  11948. });
  11949. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  11950. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  11951. __webpack_require__(17);
  11952. var _react = __webpack_require__(2);
  11953. var _react2 = _interopRequireDefault(_react);
  11954. var _base = __webpack_require__(1);
  11955. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11956. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11957. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  11958. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  11959. var defaultAccepts = {
  11960. image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
  11961. video: 'video/mp4',
  11962. audio: 'audio/mp3'
  11963. };
  11964. var BraftFinderView = function (_React$Component) {
  11965. _inherits(BraftFinderView, _React$Component);
  11966. function BraftFinderView(props) {
  11967. _classCallCheck(this, BraftFinderView);
  11968. var _this = _possibleConstructorReturn(this, (BraftFinderView.__proto__ || Object.getPrototypeOf(BraftFinderView)).call(this, props));
  11969. _this.toggleSelectItem = function (event) {
  11970. var itemId = event.currentTarget.dataset.id;
  11971. var item = _this.controller.getMediaItem(itemId);
  11972. if (!item) {
  11973. return false;
  11974. }
  11975. if (item.selected) {
  11976. if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect([item], _this.controller.getItems()) !== false) {
  11977. _this.controller.deselectMediaItem(itemId);
  11978. _this.props.onDeselect && _this.props.onDeselect([item], _this.controller.getItems());
  11979. }
  11980. } else {
  11981. if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect([item], _this.controller.getItems()) !== false) {
  11982. _this.controller.selectMediaItem(itemId);
  11983. _this.props.onSelect && _this.props.onSelect([item], _this.controller.getItems());
  11984. }
  11985. }
  11986. };
  11987. _this.removeItem = function (event) {
  11988. var itemId = event.currentTarget.dataset.id;
  11989. var item = _this.controller.getMediaItem(itemId);
  11990. if (!item) {
  11991. return false;
  11992. }
  11993. if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove([item], _this.controller.getItems()) !== false) {
  11994. _this.controller.removeMediaItem(itemId);
  11995. _this.props.onRemove && _this.props.onRemove([item], _this.controller.getItems());
  11996. }
  11997. event.stopPropagation();
  11998. };
  11999. _this.selectAllItems = function () {
  12000. var allItems = _this.controller.getItems();
  12001. if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect(allItems, allItems) !== false) {
  12002. _this.controller.selectAllItems();
  12003. _this.props.onSelect && _this.props.onSelect(allItems, allItems);
  12004. }
  12005. };
  12006. _this.deselectAllItems = function () {
  12007. var allItems = _this.controller.getItems();
  12008. if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect(allItems, allItems) !== false) {
  12009. _this.controller.deselectAllItems();
  12010. _this.props.onDeselect && _this.props.onDeselect(allItems, allItems);
  12011. }
  12012. };
  12013. _this.removeSelectedItems = function () {
  12014. var selectedItems = _this.controller.getSelectedItems();
  12015. if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove(selectedItems, _this.controller.getItems()) !== false) {
  12016. _this.controller.removeSelectedItems();
  12017. _this.props.onRemove && _this.props.onRemove(selectedItems, _this.controller.getItems());
  12018. }
  12019. };
  12020. _this.handleDragLeave = function (event) {
  12021. event.preventDefault();
  12022. _this.dragCounter--;
  12023. _this.dragCounter === 0 && _this.setState({
  12024. draging: false
  12025. });
  12026. };
  12027. _this.handleDragDrop = function (event) {
  12028. event.preventDefault();
  12029. _this.dragCounter = 0;
  12030. _this.setState({ draging: false });
  12031. _this.reslovePickedFiles(event);
  12032. };
  12033. _this.handleDragEnter = function (event) {
  12034. event.preventDefault();
  12035. _this.dragCounter++;
  12036. _this.setState({ draging: true });
  12037. };
  12038. _this.reslovePickedFiles = function (event) {
  12039. event.persist();
  12040. var _ref = event.type === 'drop' ? event.dataTransfer : event.target,
  12041. files = _ref.files;
  12042. if (_this.props.onFileSelect) {
  12043. var result = _this.props.onFileSelect(files);
  12044. if (result === false) {
  12045. return false;
  12046. } else if (result instanceof FileList || result instanceof Array) {
  12047. files = result;
  12048. }
  12049. }
  12050. var accepts = _extends({}, defaultAccepts, _this.props.accepts);
  12051. _this.controller.resolveFiles({
  12052. files: files,
  12053. onItemReady: function onItemReady(_ref2) {
  12054. var id = _ref2.id;
  12055. return _this.controller.selectMediaItem(id);
  12056. },
  12057. onAllReady: function onAllReady() {
  12058. return event.target.value = null;
  12059. }
  12060. }, 0, accepts);
  12061. };
  12062. _this.inputExternal = function (event) {
  12063. _this.setState({
  12064. external: _extends({}, _this.state.external, {
  12065. url: event.target.value
  12066. })
  12067. });
  12068. };
  12069. _this.switchExternalType = function (event) {
  12070. _this.setState({
  12071. external: _extends({}, _this.state.external, { type: event.target.dataset.type })
  12072. });
  12073. };
  12074. _this.confirmAddExternal = function (event) {
  12075. if (event.target.nodeName.toLowerCase() === 'button' || event.keyCode === 13) {
  12076. var _this$state$external = _this.state.external,
  12077. url = _this$state$external.url,
  12078. type = _this$state$external.type;
  12079. url = url.split('|');
  12080. var name = url.length > 1 ? url[0] : _this.props.language.unnamedItem;
  12081. url = url.length > 1 ? url[1] : url[0];
  12082. var thumbnail = type === 'IMAGE' ? url : null;
  12083. _this.controller.addItems([{
  12084. thumbnail: thumbnail, url: url, name: name, type: type,
  12085. id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
  12086. uploading: false,
  12087. uploadProgress: 1,
  12088. selected: true
  12089. }]);
  12090. _this.setState({
  12091. showExternalForm: false,
  12092. external: {
  12093. url: '',
  12094. type: 'IMAGE'
  12095. }
  12096. });
  12097. }
  12098. };
  12099. _this.toggleExternalForm = function () {
  12100. _this.setState({
  12101. showExternalForm: !_this.state.showExternalForm
  12102. });
  12103. };
  12104. _this.cancelInsert = function () {
  12105. _this.props.onCancel && _this.props.onCancel();
  12106. };
  12107. _this.confirmInsert = function () {
  12108. var selectedItems = _this.controller.getSelectedItems();
  12109. if (_this.props.onBeforeInsert) {
  12110. var filteredItems = _this.props.onBeforeInsert(selectedItems);
  12111. if (filteredItems && filteredItems instanceof Array) {
  12112. _this.controller.deselectAllItems();
  12113. _this.props.onInsert && _this.props.onInsert(filteredItems);
  12114. } else if (filteredItems !== false) {
  12115. _this.controller.deselectAllItems();
  12116. _this.props.onInsert && _this.props.onInsert(selectedItems);
  12117. }
  12118. } else {
  12119. _this.controller.deselectAllItems();
  12120. _this.props.onInsert && _this.props.onInsert(selectedItems);
  12121. }
  12122. };
  12123. _this.dragCounter = 0;
  12124. _this.controller = _this.props.controller;
  12125. var initialItems = _this.controller.getItems();
  12126. _this.state = {
  12127. draging: false,
  12128. error: false,
  12129. confirmable: initialItems.find(function (_ref3) {
  12130. var selected = _ref3.selected;
  12131. return selected;
  12132. }),
  12133. external: {
  12134. url: '',
  12135. type: 'IMAGE'
  12136. },
  12137. fileAccept: '',
  12138. showExternalForm: false,
  12139. allowExternal: false,
  12140. items: initialItems
  12141. };
  12142. _this.changeListenerId = _this.controller.onChange(function (items) {
  12143. _this.setState({ items: items, confirmable: items.find(function (_ref4) {
  12144. var selected = _ref4.selected;
  12145. return selected;
  12146. }) });
  12147. _this.props.onChange && _this.props.onChange(items);
  12148. });
  12149. return _this;
  12150. }
  12151. _createClass(BraftFinderView, [{
  12152. key: 'mapPropsToState',
  12153. value: function mapPropsToState(props) {
  12154. var accepts = props.accepts,
  12155. externals = props.externals;
  12156. accepts = _extends({}, defaultAccepts, accepts);
  12157. var fileAccept = !accepts ? [defaultAccepts.image, defaultAccepts.video, defaultAccepts.audio].join(',') : [accepts.image, accepts.video, accepts.audio].filter(function (item) {
  12158. return item;
  12159. }).join(',');
  12160. var external = {
  12161. url: '',
  12162. type: externals.image ? 'IMAGE' : externals.audio ? 'AUDIO' : externals.video ? 'VIDEO' : externals.embed ? 'EMBED' : ''
  12163. };
  12164. return {
  12165. fileAccept: fileAccept,
  12166. external: external,
  12167. allowExternal: externals && (externals.image || externals.audio || externals.video || externals.embed)
  12168. };
  12169. }
  12170. }, {
  12171. key: 'componentDidMount',
  12172. value: function componentDidMount() {
  12173. this.setState(this.mapPropsToState(this.props));
  12174. }
  12175. }, {
  12176. key: 'componentWillReceiveProps',
  12177. value: function componentWillReceiveProps(nextProps) {
  12178. this.setState(this.mapPropsToState(nextProps));
  12179. }
  12180. }, {
  12181. key: 'componentWillUnmount',
  12182. value: function componentWillUnmount() {
  12183. this.controller.offChange(this.changeListenerId);
  12184. }
  12185. }, {
  12186. key: 'render',
  12187. value: function render() {
  12188. var _props = this.props,
  12189. language = _props.language,
  12190. externals = _props.externals;
  12191. var _state = this.state,
  12192. items = _state.items,
  12193. draging = _state.draging,
  12194. confirmable = _state.confirmable,
  12195. fileAccept = _state.fileAccept,
  12196. external = _state.external,
  12197. showExternalForm = _state.showExternalForm,
  12198. allowExternal = _state.allowExternal;
  12199. return _react2.default.createElement(
  12200. 'div',
  12201. { className: 'braft-finder' },
  12202. _react2.default.createElement(
  12203. 'div',
  12204. {
  12205. onDragEnter: this.handleDragEnter,
  12206. onDragOver: this.handleDragEnter,
  12207. onDragLeave: this.handleDragLeave,
  12208. onDrop: this.handleDragDrop,
  12209. className: 'bf-uploader'
  12210. },
  12211. _react2.default.createElement(
  12212. 'div',
  12213. { className: "bf-drag-uploader " + (draging || !items.length ? 'active ' : ' ') + (draging ? 'draging' : '') },
  12214. _react2.default.createElement(
  12215. 'span',
  12216. { className: 'bf-drag-tip' },
  12217. _react2.default.createElement('input', { accept: fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' }),
  12218. draging ? language.dropTip : language.dragTip
  12219. )
  12220. ),
  12221. items.length ? _react2.default.createElement(
  12222. 'div',
  12223. { className: 'bf-list-wrap' },
  12224. _react2.default.createElement(
  12225. 'div',
  12226. { className: 'bf-list-tools' },
  12227. _react2.default.createElement(
  12228. 'span',
  12229. { onClick: this.selectAllItems, className: 'bf-select-all' },
  12230. _react2.default.createElement('i', { className: 'braft-icon-done' }),
  12231. ' ',
  12232. language.selectAll
  12233. ),
  12234. _react2.default.createElement(
  12235. 'span',
  12236. { onClick: this.deselectAllItems, disabled: !confirmable, className: 'bf-deselect-all' },
  12237. _react2.default.createElement('i', { className: 'braft-icon-close' }),
  12238. ' ',
  12239. language.deselect
  12240. ),
  12241. _react2.default.createElement(
  12242. 'span',
  12243. { onClick: this.removeSelectedItems, disabled: !confirmable, className: 'bf-remove-selected' },
  12244. _react2.default.createElement('i', { className: 'braft-icon-bin' }),
  12245. ' ',
  12246. language.removeSelected
  12247. )
  12248. ),
  12249. this.buildItemList()
  12250. ) : null,
  12251. showExternalForm && allowExternal ? _react2.default.createElement(
  12252. 'div',
  12253. { className: 'bf-add-external' },
  12254. _react2.default.createElement(
  12255. 'div',
  12256. { className: 'bf-external-form' },
  12257. _react2.default.createElement(
  12258. 'div',
  12259. { className: 'bf-external-input' },
  12260. _react2.default.createElement(
  12261. 'div',
  12262. null,
  12263. _react2.default.createElement('input', { onKeyDown: this.confirmAddExternal, value: external.url, onChange: this.inputExternal, placeholder: language.externalInputPlaceHolder })
  12264. ),
  12265. _react2.default.createElement(
  12266. 'button',
  12267. { type: 'button', onClick: this.confirmAddExternal, disabled: !external.url.trim().length },
  12268. language.confirm
  12269. )
  12270. ),
  12271. _react2.default.createElement(
  12272. 'div',
  12273. { 'data-type': external.type, className: 'bf-switch-external-type' },
  12274. externals.image ? _react2.default.createElement(
  12275. 'button',
  12276. { type: 'button', onClick: this.switchExternalType, 'data-type': 'IMAGE' },
  12277. language.image
  12278. ) : null,
  12279. externals.audio ? _react2.default.createElement(
  12280. 'button',
  12281. { type: 'button', onClick: this.switchExternalType, 'data-type': 'AUDIO' },
  12282. language.audio
  12283. ) : null,
  12284. externals.video ? _react2.default.createElement(
  12285. 'button',
  12286. { type: 'button', onClick: this.switchExternalType, 'data-type': 'VIDEO' },
  12287. language.video
  12288. ) : null,
  12289. externals.embed ? _react2.default.createElement(
  12290. 'button',
  12291. { type: 'button', onClick: this.switchExternalType, 'data-type': 'EMBED' },
  12292. language.embed
  12293. ) : null
  12294. ),
  12295. _react2.default.createElement(
  12296. 'span',
  12297. { className: 'bf-external-tip' },
  12298. language.externalInputTip
  12299. )
  12300. )
  12301. ) : null
  12302. ),
  12303. _react2.default.createElement(
  12304. 'footer',
  12305. { className: 'bf-manager-footer' },
  12306. _react2.default.createElement(
  12307. 'div',
  12308. { className: 'pull-left' },
  12309. allowExternal ? _react2.default.createElement(
  12310. 'span',
  12311. {
  12312. onClick: this.toggleExternalForm,
  12313. className: 'bf-toggle-external-form'
  12314. },
  12315. showExternalForm ? _react2.default.createElement(
  12316. 'span',
  12317. { className: 'bf-bottom-text' },
  12318. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  12319. ' ',
  12320. language.addLocalFile
  12321. ) : _react2.default.createElement(
  12322. 'span',
  12323. { className: 'bf-bottom-text' },
  12324. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  12325. ' ',
  12326. language.addExternalSource
  12327. )
  12328. ) : null
  12329. ),
  12330. _react2.default.createElement(
  12331. 'div',
  12332. { className: 'pull-right' },
  12333. _react2.default.createElement(
  12334. 'button',
  12335. { onClick: this.confirmInsert, className: 'button button-insert', disabled: !confirmable },
  12336. language.insert
  12337. ),
  12338. _react2.default.createElement(
  12339. 'button',
  12340. { onClick: this.cancelInsert, className: 'button button-cancel' },
  12341. language.cancel
  12342. )
  12343. )
  12344. )
  12345. );
  12346. }
  12347. }, {
  12348. key: 'buildItemList',
  12349. value: function buildItemList() {
  12350. var _this2 = this;
  12351. return _react2.default.createElement(
  12352. 'ul',
  12353. { className: 'bf-list' },
  12354. _react2.default.createElement(
  12355. 'li',
  12356. { className: 'bf-add-item' },
  12357. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  12358. _react2.default.createElement('input', { accept: this.state.fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' })
  12359. ),
  12360. this.state.items.map(function (item, index) {
  12361. var previewerComponents = null;
  12362. var progressMarker = item.uploading && !_this2.props.hideProgress ? _react2.default.createElement(
  12363. 'div',
  12364. { className: 'bf-item-uploading' },
  12365. _react2.default.createElement('div', { className: 'bf-item-uploading-bar', style: { width: item.uploadProgress / 1 + '%' } })
  12366. ) : '';
  12367. switch (item.type) {
  12368. case 'IMAGE':
  12369. previewerComponents = _react2.default.createElement(
  12370. 'div',
  12371. { className: 'bf-image' },
  12372. progressMarker,
  12373. _react2.default.createElement('img', { src: item.thumbnail || item.url })
  12374. );
  12375. break;
  12376. case 'VIDEO':
  12377. previewerComponents = _react2.default.createElement(
  12378. 'div',
  12379. { className: 'bf-icon bf-video', title: item.url },
  12380. progressMarker,
  12381. _react2.default.createElement('i', { className: 'braft-icon-film' }),
  12382. _react2.default.createElement(
  12383. 'span',
  12384. null,
  12385. item.name || item.url
  12386. )
  12387. );
  12388. break;
  12389. case 'AUDIO':
  12390. previewerComponents = _react2.default.createElement(
  12391. 'div',
  12392. { className: 'bf-icon bf-audio', title: item.url },
  12393. progressMarker,
  12394. _react2.default.createElement('i', { className: 'braft-icon-music' }),
  12395. _react2.default.createElement(
  12396. 'span',
  12397. null,
  12398. item.name || item.url
  12399. )
  12400. );
  12401. break;
  12402. case 'EMBED':
  12403. previewerComponents = _react2.default.createElement(
  12404. 'div',
  12405. { className: 'bf-icon bf-embed', title: item.url },
  12406. progressMarker,
  12407. _react2.default.createElement('i', { className: 'braft-icon-code' }),
  12408. _react2.default.createElement(
  12409. 'span',
  12410. null,
  12411. item.name || _this2.props.language.embed
  12412. )
  12413. );
  12414. break;
  12415. default:
  12416. previewerComponents = _react2.default.createElement(
  12417. 'a',
  12418. { className: 'bf-icon bf-file', title: item.url, href: item.url },
  12419. progressMarker,
  12420. _react2.default.createElement('i', { className: 'braft-icon-file-text' }),
  12421. _react2.default.createElement(
  12422. 'span',
  12423. null,
  12424. item.name || item.url
  12425. )
  12426. );
  12427. break;
  12428. }
  12429. var className = ['bf-item'];
  12430. item.selected && className.push('active');
  12431. item.uploading && className.push('uploading');
  12432. item.error && className.push('error');
  12433. return _react2.default.createElement(
  12434. 'li',
  12435. {
  12436. key: index,
  12437. title: item.name,
  12438. 'data-id': item.id,
  12439. className: className.join(' '),
  12440. onClick: _this2.toggleSelectItem
  12441. },
  12442. previewerComponents,
  12443. _react2.default.createElement('span', { 'data-id': item.id, onClick: _this2.removeItem, className: 'bf-item-remove braft-icon-close' }),
  12444. _react2.default.createElement(
  12445. 'span',
  12446. { className: 'bf-item-title' },
  12447. item.name
  12448. )
  12449. );
  12450. })
  12451. );
  12452. }
  12453. }]);
  12454. return BraftFinderView;
  12455. }(_react2.default.Component);
  12456. BraftFinderView.defaultProps = {
  12457. accepts: defaultAccepts,
  12458. externals: {
  12459. image: true,
  12460. video: true,
  12461. audio: true,
  12462. embed: true
  12463. }
  12464. };
  12465. exports.default = BraftFinderView;
  12466. /***/ }),
  12467. /* 19 */
  12468. /***/ (function(module, exports, __webpack_require__) {
  12469. Object.defineProperty(exports, "__esModule", {
  12470. value: true
  12471. });
  12472. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  12473. var _base = __webpack_require__(1);
  12474. var _image = __webpack_require__(0);
  12475. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  12476. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12477. var defaultValidator = function defaultValidator() {
  12478. return true;
  12479. };
  12480. var BraftFinderController = function BraftFinderController() {
  12481. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12482. _classCallCheck(this, BraftFinderController);
  12483. _initialiseProps.call(this);
  12484. this.items = props.items || [];
  12485. this.uploadFn = props.uploader;
  12486. this.validateFn = props.validator || defaultValidator;
  12487. this.changeListeners = [];
  12488. }
  12489. // resolvePastedFiles ({ clipboardData }, callback) {
  12490. // if (clipboardData && clipboardData.items && clipboardData.items[0].type.indexOf('image') > -1) {
  12491. // this.uploadImage(clipboardData.items[0].getAsFile(), callback)
  12492. // }
  12493. // }
  12494. ;
  12495. var _initialiseProps = function _initialiseProps() {
  12496. var _this = this;
  12497. this.setProps = function () {
  12498. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12499. _this.items = props.items || _this.items || [];
  12500. _this.uploadFn = props.uploader;
  12501. _this.validateFn = props.validator || defaultValidator;
  12502. };
  12503. this.getMediaItem = function (id) {
  12504. return _this.items.find(function (item) {
  12505. return item.id === id;
  12506. });
  12507. };
  12508. this.getSelectedItems = function () {
  12509. return _this.items.filter(function (item) {
  12510. return item.selected;
  12511. });
  12512. };
  12513. this.getItems = function () {
  12514. return _this.items;
  12515. };
  12516. this.setItems = function (items) {
  12517. _this.items = items.map(function (item) {
  12518. return _extends({}, item, { id: item.id.toString() });
  12519. }) || [];
  12520. _this.applyChange();
  12521. _this.uploadItems();
  12522. };
  12523. this.addMediaItem = function (item) {
  12524. _this.addItems([item]);
  12525. };
  12526. this.addItems = function (items) {
  12527. _this.items = [].concat(_toConsumableArray(_this.items), _toConsumableArray(items.map(function (item) {
  12528. return _extends({}, item, { id: item.id.toString() });
  12529. })));
  12530. _this.applyChange();
  12531. _this.uploadItems();
  12532. };
  12533. this.selectMediaItem = function (id) {
  12534. var item = _this.getMediaItem(id);
  12535. if (item && (item.uploading || item.error)) {
  12536. return false;
  12537. }
  12538. _this.setMediaItemState(id, {
  12539. selected: true
  12540. });
  12541. };
  12542. this.selectAllItems = function () {
  12543. _this.items = _this.items.filter(function (item) {
  12544. return !item.error && !item.uploading;
  12545. }).map(function (item) {
  12546. return _extends({}, item, { selected: true });
  12547. });
  12548. _this.applyChange();
  12549. };
  12550. this.deselectMediaItem = function (id) {
  12551. _this.setMediaItemState(id, {
  12552. selected: false
  12553. });
  12554. };
  12555. this.deselectAllItems = function () {
  12556. _this.items = _this.items.map(function (item) {
  12557. return _extends({}, item, { selected: false });
  12558. });
  12559. _this.applyChange();
  12560. };
  12561. this.removeMediaItem = function (id) {
  12562. _this.items = _this.items.filter(function (item) {
  12563. return item.id !== id;
  12564. });
  12565. _this.applyChange();
  12566. };
  12567. this.removeItems = function () {
  12568. var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  12569. _this.items = _this.items.filter(function (item) {
  12570. return !ids.includes(item.id);
  12571. });
  12572. _this.applyChange();
  12573. };
  12574. this.removeSelectedItems = function () {
  12575. _this.items = _this.items.filter(function (item) {
  12576. return !item.selected;
  12577. });
  12578. _this.applyChange();
  12579. };
  12580. this.removeErrorItems = function () {
  12581. _this.items = _this.items.filter(function (item) {
  12582. return !item.error;
  12583. });
  12584. _this.applyChange();
  12585. };
  12586. this.removeAllItems = function () {
  12587. _this.items = [];
  12588. _this.applyChange();
  12589. };
  12590. this.setMediaItemState = function (id, state) {
  12591. _this.items = _this.items.map(function (item) {
  12592. return item.id === id ? _extends({}, item, state) : item;
  12593. });
  12594. _this.applyChange();
  12595. };
  12596. this.reuploadErrorItems = function () {
  12597. _this.uploadItems(true);
  12598. };
  12599. this.uploadItems = function () {
  12600. var ignoreError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12601. _this.items.forEach(function (item, index) {
  12602. if (item.uploading || item.url) {
  12603. return false;
  12604. }
  12605. if (!ignoreError && item.error) {
  12606. return false;
  12607. }
  12608. if (item.type === 'IMAGE') {
  12609. _this.createThumbnail(item);
  12610. _this.uploadFn = _this.uploadFn || _this.createInlineImage;
  12611. } else if (!_this.uploadFn) {
  12612. _this.setMediaItemState(item.id, { error: 1 });
  12613. return false;
  12614. }
  12615. _this.setMediaItemState(item.id, {
  12616. uploading: true,
  12617. uploadProgress: 0,
  12618. error: 0
  12619. });
  12620. _this.uploadFn({
  12621. id: item.id,
  12622. file: item.file,
  12623. success: function success(res) {
  12624. _this.handleUploadSuccess(item.id, res);
  12625. },
  12626. progress: function progress(_progress) {
  12627. _this.setMediaItemState(item.id, {
  12628. uploading: true,
  12629. uploadProgress: _progress
  12630. });
  12631. },
  12632. error: function error(_error) {
  12633. _this.setMediaItemState(item.id, {
  12634. uploading: false,
  12635. error: 2
  12636. });
  12637. }
  12638. });
  12639. });
  12640. };
  12641. this.createThumbnail = function (_ref) {
  12642. var id = _ref.id,
  12643. file = _ref.file;
  12644. (0, _image.compressImage)(URL.createObjectURL(file), 226, 226).then(function (result) {
  12645. _this.setMediaItemState(id, { thumbnail: result.url });
  12646. });
  12647. };
  12648. this.createInlineImage = function (param) {
  12649. (0, _image.compressImage)(URL.createObjectURL(param.file), 1280, 800).then(function (result) {
  12650. param.success({ url: result.url });
  12651. }).catch(function (error) {
  12652. param.error(error);
  12653. });
  12654. };
  12655. this.handleUploadSuccess = function (id, data) {
  12656. _this.setMediaItemState(id, _extends({}, data, {
  12657. file: null,
  12658. uploadProgress: 1,
  12659. uploading: false,
  12660. selected: false
  12661. }));
  12662. var item = _this.getMediaItem(data.id || id);
  12663. item.onReady && item.onReady(item);
  12664. };
  12665. this.applyChange = function () {
  12666. _this.changeListeners.forEach(function (_ref2) {
  12667. var callback = _ref2.callback;
  12668. return callback(_this.items);
  12669. });
  12670. };
  12671. this.uploadImage = function (file, callback) {
  12672. var fileId = new Date().getTime() + '_' + (0, _base.UniqueIndex)();
  12673. _this.addMediaItem({
  12674. type: 'IMAGE',
  12675. id: fileId,
  12676. file: file,
  12677. name: fileId,
  12678. size: file.size,
  12679. uploadProgress: 0,
  12680. uploading: false,
  12681. selected: false,
  12682. error: 0,
  12683. onReady: callback
  12684. });
  12685. };
  12686. this.uploadImageRecursively = function (files, callback) {
  12687. var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  12688. if (files[index] && files[index].type.indexOf('image') > -1) {
  12689. _this.uploadImage(files[index], function (image) {
  12690. callback && callback(image);
  12691. index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
  12692. });
  12693. } else {
  12694. index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
  12695. }
  12696. };
  12697. this.addResolvedFiles = function (param, index, accepts) {
  12698. var data = {
  12699. id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
  12700. file: param.files[index],
  12701. name: param.files[index].name,
  12702. size: param.files[index].size,
  12703. uploadProgress: 0,
  12704. uploading: false,
  12705. selected: false,
  12706. error: 0,
  12707. onReady: function onReady(item) {
  12708. param.onItemReady && param.onItemReady(item);
  12709. }
  12710. };
  12711. if (param.files[index].type.indexOf('image/') === 0 && accepts.image) {
  12712. data.type = 'IMAGE';
  12713. _this.addMediaItem(data);
  12714. } else if (param.files[index].type.indexOf('video/') === 0 && accepts.video) {
  12715. data.type = 'VIDEO';
  12716. _this.addMediaItem(data);
  12717. } else if (param.files[index].type.indexOf('audio/') === 0 && accepts.audio) {
  12718. data.type = 'AUDIO';
  12719. _this.addMediaItem(data);
  12720. }
  12721. setTimeout(function () {
  12722. _this.resolveFiles(param, index + 1, accepts);
  12723. }, 60);
  12724. };
  12725. this.resolveFiles = function (param, index, accepts) {
  12726. if (index < param.files.length) {
  12727. var validateResult = _this.validateFn(param.files[index]);
  12728. if (validateResult instanceof Promise) {
  12729. validateResult.then(function () {
  12730. _this.addResolvedFiles(param, index, accepts);
  12731. });
  12732. } else if (validateResult) {
  12733. _this.addResolvedFiles(param, index, accepts);
  12734. }
  12735. } else {
  12736. param.onAllReady && param.onAllReady();
  12737. }
  12738. };
  12739. this.onChange = function (callback) {
  12740. var listenerId = (0, _base.UniqueIndex)();
  12741. _this.changeListeners.push({
  12742. id: listenerId,
  12743. callback: callback
  12744. });
  12745. return listenerId;
  12746. };
  12747. this.offChange = function (listenerId) {
  12748. _this.changeListeners = _this.changeListeners.filter(function (_ref3) {
  12749. var id = _ref3.id;
  12750. return id !== listenerId;
  12751. });
  12752. };
  12753. };
  12754. exports.default = BraftFinderController;
  12755. /***/ }),
  12756. /* 20 */
  12757. /***/ (function(module, exports, __webpack_require__) {
  12758. Object.defineProperty(exports, "__esModule", {
  12759. value: true
  12760. });
  12761. exports.ImageUtils = undefined;
  12762. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  12763. var _react = __webpack_require__(2);
  12764. var _react2 = _interopRequireDefault(_react);
  12765. var _controller = __webpack_require__(19);
  12766. var _controller2 = _interopRequireDefault(_controller);
  12767. var _view = __webpack_require__(18);
  12768. var _view2 = _interopRequireDefault(_view);
  12769. var _languages = __webpack_require__(10);
  12770. var _languages2 = _interopRequireDefault(_languages);
  12771. var _image = __webpack_require__(0);
  12772. var ImageUtils = _interopRequireWildcard(_image);
  12773. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  12774. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12775. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12776. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  12777. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  12778. var BraftFinder = function (_FinderController) {
  12779. _inherits(BraftFinder, _FinderController);
  12780. function BraftFinder(props) {
  12781. _classCallCheck(this, BraftFinder);
  12782. var _this = _possibleConstructorReturn(this, (BraftFinder.__proto__ || Object.getPrototypeOf(BraftFinder)).call(this, props));
  12783. _initialiseProps.call(_this);
  12784. _this.superProps = props;
  12785. return _this;
  12786. }
  12787. return BraftFinder;
  12788. }(_controller2.default);
  12789. var _initialiseProps = function _initialiseProps() {
  12790. var _this2 = this;
  12791. this.ReactComponent = function () {
  12792. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12793. var componentProps = _extends({}, _this2.superProps, props);
  12794. var language = (typeof componentProps.language === 'function' ? componentProps.language(_languages2.default, 'braft-finder') : _languages2.default[componentProps.language]) || _languages2.default['zh'];
  12795. return _react2.default.createElement(_view2.default, _extends({}, componentProps, {
  12796. language: language,
  12797. controller: _this2
  12798. }));
  12799. };
  12800. };
  12801. exports.default = BraftFinder;
  12802. exports.ImageUtils = ImageUtils;
  12803. /***/ })
  12804. /******/ ]);
  12805. });
  12806. });
  12807. _commonjsHelpers.unwrapExports(dist$2);
  12808. var dist$3 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  12809. (function webpackUniversalModuleDefinition(root, factory) {
  12810. module.exports = factory(React__default, dist$1, Draft.Draft, immutable, dist, _reactDom_commonjsExternal.require$$3, dist$2, draftjsUtils);
  12811. })(window, function(__WEBPACK_EXTERNAL_MODULE__0__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__13__, __WEBPACK_EXTERNAL_MODULE__14__, __WEBPACK_EXTERNAL_MODULE__16__, __WEBPACK_EXTERNAL_MODULE__17__, __WEBPACK_EXTERNAL_MODULE__23__) {
  12812. return /******/ (function(modules) { // webpackBootstrap
  12813. /******/ // The module cache
  12814. /******/ var installedModules = {};
  12815. /******/
  12816. /******/ // The require function
  12817. /******/ function __webpack_require__(moduleId) {
  12818. /******/
  12819. /******/ // Check if module is in cache
  12820. /******/ if(installedModules[moduleId]) {
  12821. /******/ return installedModules[moduleId].exports;
  12822. /******/ }
  12823. /******/ // Create a new module (and put it into the cache)
  12824. /******/ var module = installedModules[moduleId] = {
  12825. /******/ i: moduleId,
  12826. /******/ l: false,
  12827. /******/ exports: {}
  12828. /******/ };
  12829. /******/
  12830. /******/ // Execute the module function
  12831. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  12832. /******/
  12833. /******/ // Flag the module as loaded
  12834. /******/ module.l = true;
  12835. /******/
  12836. /******/ // Return the exports of the module
  12837. /******/ return module.exports;
  12838. /******/ }
  12839. /******/
  12840. /******/
  12841. /******/ // expose the modules object (__webpack_modules__)
  12842. /******/ __webpack_require__.m = modules;
  12843. /******/
  12844. /******/ // expose the module cache
  12845. /******/ __webpack_require__.c = installedModules;
  12846. /******/
  12847. /******/ // define getter function for harmony exports
  12848. /******/ __webpack_require__.d = function(exports, name, getter) {
  12849. /******/ if(!__webpack_require__.o(exports, name)) {
  12850. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  12851. /******/ }
  12852. /******/ };
  12853. /******/
  12854. /******/ // define __esModule on exports
  12855. /******/ __webpack_require__.r = function(exports) {
  12856. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  12857. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  12858. /******/ }
  12859. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  12860. /******/ };
  12861. /******/
  12862. /******/ // create a fake namespace object
  12863. /******/ // mode & 1: value is a module id, require it
  12864. /******/ // mode & 2: merge all properties of value into the ns
  12865. /******/ // mode & 4: return value when already ns object
  12866. /******/ // mode & 8|1: behave like require
  12867. /******/ __webpack_require__.t = function(value, mode) {
  12868. /******/ if(mode & 1) value = __webpack_require__(value);
  12869. /******/ if(mode & 8) return value;
  12870. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  12871. /******/ var ns = Object.create(null);
  12872. /******/ __webpack_require__.r(ns);
  12873. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  12874. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  12875. /******/ return ns;
  12876. /******/ };
  12877. /******/
  12878. /******/ // getDefaultExport function for compatibility with non-harmony modules
  12879. /******/ __webpack_require__.n = function(module) {
  12880. /******/ var getter = module && module.__esModule ?
  12881. /******/ function getDefault() { return module['default']; } :
  12882. /******/ function getModuleExports() { return module; };
  12883. /******/ __webpack_require__.d(getter, 'a', getter);
  12884. /******/ return getter;
  12885. /******/ };
  12886. /******/
  12887. /******/ // Object.prototype.hasOwnProperty.call
  12888. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  12889. /******/
  12890. /******/ // __webpack_public_path__
  12891. /******/ __webpack_require__.p = "/";
  12892. /******/
  12893. /******/
  12894. /******/ // Load entry module and return exports
  12895. /******/ return __webpack_require__(__webpack_require__.s = 39);
  12896. /******/ })
  12897. /************************************************************************/
  12898. /******/ ([
  12899. /* 0 */
  12900. /***/ (function(module, exports) {
  12901. module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
  12902. /***/ }),
  12903. /* 1 */
  12904. /***/ (function(module, exports) {
  12905. function _assertThisInitialized(self) {
  12906. if (self === void 0) {
  12907. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  12908. }
  12909. return self;
  12910. }
  12911. module.exports = _assertThisInitialized;
  12912. /***/ }),
  12913. /* 2 */
  12914. /***/ (function(module, exports) {
  12915. function _defineProperty(obj, key, value) {
  12916. if (key in obj) {
  12917. Object.defineProperty(obj, key, {
  12918. value: value,
  12919. enumerable: true,
  12920. configurable: true,
  12921. writable: true
  12922. });
  12923. } else {
  12924. obj[key] = value;
  12925. }
  12926. return obj;
  12927. }
  12928. module.exports = _defineProperty;
  12929. /***/ }),
  12930. /* 3 */
  12931. /***/ (function(module, exports) {
  12932. module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
  12933. /***/ }),
  12934. /* 4 */
  12935. /***/ (function(module, exports) {
  12936. function _classCallCheck(instance, Constructor) {
  12937. if (!(instance instanceof Constructor)) {
  12938. throw new TypeError("Cannot call a class as a function");
  12939. }
  12940. }
  12941. module.exports = _classCallCheck;
  12942. /***/ }),
  12943. /* 5 */
  12944. /***/ (function(module, exports, __webpack_require__) {
  12945. var defineProperty = __webpack_require__(2);
  12946. function _objectSpread(target) {
  12947. for (var i = 1; i < arguments.length; i++) {
  12948. var source = arguments[i] != null ? arguments[i] : {};
  12949. var ownKeys = Object.keys(source);
  12950. if (typeof Object.getOwnPropertySymbols === 'function') {
  12951. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  12952. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  12953. }));
  12954. }
  12955. ownKeys.forEach(function (key) {
  12956. defineProperty(target, key, source[key]);
  12957. });
  12958. }
  12959. return target;
  12960. }
  12961. module.exports = _objectSpread;
  12962. /***/ }),
  12963. /* 6 */
  12964. /***/ (function(module, exports) {
  12965. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  12966. /***/ }),
  12967. /* 7 */
  12968. /***/ (function(module, exports) {
  12969. function _defineProperties(target, props) {
  12970. for (var i = 0; i < props.length; i++) {
  12971. var descriptor = props[i];
  12972. descriptor.enumerable = descriptor.enumerable || false;
  12973. descriptor.configurable = true;
  12974. if ("value" in descriptor) descriptor.writable = true;
  12975. Object.defineProperty(target, descriptor.key, descriptor);
  12976. }
  12977. }
  12978. function _createClass(Constructor, protoProps, staticProps) {
  12979. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12980. if (staticProps) _defineProperties(Constructor, staticProps);
  12981. return Constructor;
  12982. }
  12983. module.exports = _createClass;
  12984. /***/ }),
  12985. /* 8 */
  12986. /***/ (function(module, exports, __webpack_require__) {
  12987. var _typeof = __webpack_require__(15);
  12988. var assertThisInitialized = __webpack_require__(1);
  12989. function _possibleConstructorReturn(self, call) {
  12990. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  12991. return call;
  12992. }
  12993. return assertThisInitialized(self);
  12994. }
  12995. module.exports = _possibleConstructorReturn;
  12996. /***/ }),
  12997. /* 9 */
  12998. /***/ (function(module, exports) {
  12999. function _getPrototypeOf(o) {
  13000. module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  13001. return o.__proto__ || Object.getPrototypeOf(o);
  13002. };
  13003. return _getPrototypeOf(o);
  13004. }
  13005. module.exports = _getPrototypeOf;
  13006. /***/ }),
  13007. /* 10 */
  13008. /***/ (function(module, exports, __webpack_require__) {
  13009. var setPrototypeOf = __webpack_require__(26);
  13010. function _inherits(subClass, superClass) {
  13011. if (typeof superClass !== "function" && superClass !== null) {
  13012. throw new TypeError("Super expression must either be null or a function");
  13013. }
  13014. subClass.prototype = Object.create(superClass && superClass.prototype, {
  13015. constructor: {
  13016. value: subClass,
  13017. writable: true,
  13018. configurable: true
  13019. }
  13020. });
  13021. if (superClass) setPrototypeOf(subClass, superClass);
  13022. }
  13023. module.exports = _inherits;
  13024. /***/ }),
  13025. /* 11 */
  13026. /***/ (function(module, exports) {
  13027. function _extends() {
  13028. module.exports = _extends = Object.assign || function (target) {
  13029. for (var i = 1; i < arguments.length; i++) {
  13030. var source = arguments[i];
  13031. for (var key in source) {
  13032. if (Object.prototype.hasOwnProperty.call(source, key)) {
  13033. target[key] = source[key];
  13034. }
  13035. }
  13036. }
  13037. return target;
  13038. };
  13039. return _extends.apply(this, arguments);
  13040. }
  13041. module.exports = _extends;
  13042. /***/ }),
  13043. /* 12 */
  13044. /***/ (function(module, exports, __webpack_require__) {
  13045. var arrayWithoutHoles = __webpack_require__(27);
  13046. var iterableToArray = __webpack_require__(28);
  13047. var nonIterableSpread = __webpack_require__(29);
  13048. function _toConsumableArray(arr) {
  13049. return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
  13050. }
  13051. module.exports = _toConsumableArray;
  13052. /***/ }),
  13053. /* 13 */
  13054. /***/ (function(module, exports) {
  13055. module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
  13056. /***/ }),
  13057. /* 14 */
  13058. /***/ (function(module, exports) {
  13059. module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
  13060. /***/ }),
  13061. /* 15 */
  13062. /***/ (function(module, exports) {
  13063. function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
  13064. function _typeof(obj) {
  13065. if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
  13066. module.exports = _typeof = function _typeof(obj) {
  13067. return _typeof2(obj);
  13068. };
  13069. } else {
  13070. module.exports = _typeof = function _typeof(obj) {
  13071. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
  13072. };
  13073. }
  13074. return _typeof(obj);
  13075. }
  13076. module.exports = _typeof;
  13077. /***/ }),
  13078. /* 16 */
  13079. /***/ (function(module, exports) {
  13080. module.exports = __WEBPACK_EXTERNAL_MODULE__16__;
  13081. /***/ }),
  13082. /* 17 */
  13083. /***/ (function(module, exports) {
  13084. module.exports = __WEBPACK_EXTERNAL_MODULE__17__;
  13085. /***/ }),
  13086. /* 18 */
  13087. /***/ (function(module, exports, __webpack_require__) {
  13088. var Immutable = __webpack_require__(13);
  13089. var KEY_SEPARATOR = '-';
  13090. function MultiDecorator(decorators) {
  13091. this.decorators = Immutable.List(decorators);
  13092. }
  13093. /**
  13094. Return list of decoration IDs per character
  13095. @param {ContentBlock}
  13096. @return {List<String>}
  13097. */
  13098. MultiDecorator.prototype.getDecorations = function(block) {
  13099. var decorations = Array(block.getText().length).fill(null);
  13100. this.decorators.forEach(function(decorator, i) {
  13101. var _decorations = decorator.getDecorations(block);
  13102. _decorations.forEach(function(key, offset) {
  13103. if (!key) {
  13104. return;
  13105. }
  13106. key = i + KEY_SEPARATOR + key;
  13107. decorations[offset] = key;
  13108. });
  13109. });
  13110. return Immutable.List(decorations);
  13111. };
  13112. /**
  13113. Return component to render a decoration
  13114. @param {String}
  13115. @return {Function}
  13116. */
  13117. MultiDecorator.prototype.getComponentForKey = function(key) {
  13118. var decorator = this.getDecoratorForKey(key);
  13119. return decorator.getComponentForKey(
  13120. this.getInnerKey(key)
  13121. );
  13122. };
  13123. /**
  13124. Return props to render a decoration
  13125. @param {String}
  13126. @return {Object}
  13127. */
  13128. MultiDecorator.prototype.getPropsForKey = function(key) {
  13129. var decorator = this.getDecoratorForKey(key);
  13130. return decorator.getPropsForKey(
  13131. this.getInnerKey(key)
  13132. );
  13133. };
  13134. /**
  13135. Return a decorator for a specific key
  13136. @param {String}
  13137. @return {Decorator}
  13138. */
  13139. MultiDecorator.prototype.getDecoratorForKey = function(key) {
  13140. var parts = key.split(KEY_SEPARATOR);
  13141. var index = Number(parts[0]);
  13142. return this.decorators.get(index);
  13143. };
  13144. /**
  13145. Return inner key for a decorator
  13146. @param {String}
  13147. @return {String}
  13148. */
  13149. MultiDecorator.prototype.getInnerKey = function(key) {
  13150. var parts = key.split(KEY_SEPARATOR);
  13151. return parts.slice(1).join(KEY_SEPARATOR);
  13152. };
  13153. module.exports = MultiDecorator;
  13154. /***/ }),
  13155. /* 19 */
  13156. /***/ (function(module, exports, __webpack_require__) {
  13157. /**
  13158. * Copyright (c) 2013-present, Facebook, Inc.
  13159. * All rights reserved.
  13160. *
  13161. * This source code is licensed under the BSD-style license found in the
  13162. * LICENSE file in the root directory of this source tree. An additional grant
  13163. * of patent rights can be found in the PATENTS file in the same directory.
  13164. *
  13165. * @providesModule CharacterMetadata
  13166. * @format
  13167. *
  13168. */
  13169. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13170. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  13171. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  13172. var _require = __webpack_require__(13),
  13173. Map = _require.Map,
  13174. OrderedSet = _require.OrderedSet,
  13175. Record = _require.Record;
  13176. // Immutable.map is typed such that the value for every key in the map
  13177. // must be the same type
  13178. var EMPTY_SET = OrderedSet();
  13179. var defaultRecord = {
  13180. style: EMPTY_SET,
  13181. entity: null
  13182. };
  13183. var CharacterMetadataRecord = Record(defaultRecord);
  13184. var CharacterMetadata = function (_CharacterMetadataRec) {
  13185. _inherits(CharacterMetadata, _CharacterMetadataRec);
  13186. function CharacterMetadata() {
  13187. _classCallCheck(this, CharacterMetadata);
  13188. return _possibleConstructorReturn(this, _CharacterMetadataRec.apply(this, arguments));
  13189. }
  13190. CharacterMetadata.prototype.getStyle = function getStyle() {
  13191. return this.get('style');
  13192. };
  13193. CharacterMetadata.prototype.getEntity = function getEntity() {
  13194. return this.get('entity');
  13195. };
  13196. CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
  13197. return this.getStyle().includes(style);
  13198. };
  13199. CharacterMetadata.applyStyle = function applyStyle(record, style) {
  13200. var withStyle = record.set('style', record.getStyle().add(style));
  13201. return CharacterMetadata.create(withStyle);
  13202. };
  13203. CharacterMetadata.removeStyle = function removeStyle(record, style) {
  13204. var withoutStyle = record.set('style', record.getStyle().remove(style));
  13205. return CharacterMetadata.create(withoutStyle);
  13206. };
  13207. CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
  13208. var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
  13209. return CharacterMetadata.create(withEntity);
  13210. };
  13211. /**
  13212. * Use this function instead of the `CharacterMetadata` constructor.
  13213. * Since most content generally uses only a very small number of
  13214. * style/entity permutations, we can reuse these objects as often as
  13215. * possible.
  13216. */
  13217. CharacterMetadata.create = function create(config) {
  13218. if (!config) {
  13219. return EMPTY;
  13220. }
  13221. var defaultConfig = {
  13222. style: EMPTY_SET,
  13223. entity: null
  13224. };
  13225. // Fill in unspecified properties, if necessary.
  13226. var configMap = Map(defaultConfig).merge(config);
  13227. var existing = pool.get(configMap);
  13228. if (existing) {
  13229. return existing;
  13230. }
  13231. var newCharacter = new CharacterMetadata(configMap);
  13232. pool = pool.set(configMap, newCharacter);
  13233. return newCharacter;
  13234. };
  13235. return CharacterMetadata;
  13236. }(CharacterMetadataRecord);
  13237. var EMPTY = new CharacterMetadata();
  13238. var pool = Map([[Map(defaultRecord), EMPTY]]);
  13239. CharacterMetadata.EMPTY = EMPTY;
  13240. module.exports = CharacterMetadata;
  13241. /***/ }),
  13242. /* 20 */
  13243. /***/ (function(module, exports, __webpack_require__) {
  13244. /**
  13245. * Copyright (c) 2013-present, Facebook, Inc.
  13246. * All rights reserved.
  13247. *
  13248. * This source code is licensed under the BSD-style license found in the
  13249. * LICENSE file in the root directory of this source tree. An additional grant
  13250. * of patent rights can be found in the PATENTS file in the same directory.
  13251. *
  13252. * @providesModule findRangesImmutable
  13253. * @format
  13254. *
  13255. */
  13256. /**
  13257. * Search through an array to find contiguous stretches of elements that
  13258. * match a specified filter function.
  13259. *
  13260. * When ranges are found, execute a specified `found` function to supply
  13261. * the values to the caller.
  13262. */
  13263. function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
  13264. if (!haystack.size) {
  13265. return;
  13266. }
  13267. var cursor = 0;
  13268. haystack.reduce(function (value, nextValue, nextIndex) {
  13269. if (!areEqualFn(value, nextValue)) {
  13270. if (filterFn(value)) {
  13271. foundFn(cursor, nextIndex);
  13272. }
  13273. cursor = nextIndex;
  13274. }
  13275. return nextValue;
  13276. });
  13277. filterFn(haystack.last()) && foundFn(cursor, haystack.count());
  13278. }
  13279. module.exports = findRangesImmutable;
  13280. /***/ }),
  13281. /* 21 */
  13282. /***/ (function(module, exports, __webpack_require__) {
  13283. var objectWithoutPropertiesLoose = __webpack_require__(25);
  13284. function _objectWithoutProperties(source, excluded) {
  13285. if (source == null) return {};
  13286. var target = objectWithoutPropertiesLoose(source, excluded);
  13287. var key, i;
  13288. if (Object.getOwnPropertySymbols) {
  13289. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  13290. for (i = 0; i < sourceSymbolKeys.length; i++) {
  13291. key = sourceSymbolKeys[i];
  13292. if (excluded.indexOf(key) >= 0) continue;
  13293. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  13294. target[key] = source[key];
  13295. }
  13296. }
  13297. return target;
  13298. }
  13299. module.exports = _objectWithoutProperties;
  13300. /***/ }),
  13301. /* 22 */
  13302. /***/ (function(module, exports, __webpack_require__) {
  13303. /**
  13304. * Copyright (c) 2013-present, Facebook, Inc.
  13305. * All rights reserved.
  13306. *
  13307. * This source code is licensed under the BSD-style license found in the
  13308. * LICENSE file in the root directory of this source tree. An additional grant
  13309. * of patent rights can be found in the PATENTS file in the same directory.
  13310. *
  13311. * @providesModule getFragmentFromSelection
  13312. * @format
  13313. *
  13314. */
  13315. var getContentStateFragment = __webpack_require__(30);
  13316. function getFragmentFromSelection(editorState) {
  13317. var selectionState = editorState.getSelection();
  13318. if (selectionState.isCollapsed()) {
  13319. return null;
  13320. }
  13321. return getContentStateFragment(editorState.getCurrentContent(), selectionState);
  13322. }
  13323. module.exports = getFragmentFromSelection;
  13324. /***/ }),
  13325. /* 23 */
  13326. /***/ (function(module, exports) {
  13327. module.exports = __WEBPACK_EXTERNAL_MODULE__23__;
  13328. /***/ }),
  13329. /* 24 */
  13330. /***/ (function(module, exports, __webpack_require__) {
  13331. var arrayWithHoles = __webpack_require__(36);
  13332. var iterableToArrayLimit = __webpack_require__(37);
  13333. var nonIterableRest = __webpack_require__(38);
  13334. function _slicedToArray(arr, i) {
  13335. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();
  13336. }
  13337. module.exports = _slicedToArray;
  13338. /***/ }),
  13339. /* 25 */
  13340. /***/ (function(module, exports) {
  13341. function _objectWithoutPropertiesLoose(source, excluded) {
  13342. if (source == null) return {};
  13343. var target = {};
  13344. var sourceKeys = Object.keys(source);
  13345. var key, i;
  13346. for (i = 0; i < sourceKeys.length; i++) {
  13347. key = sourceKeys[i];
  13348. if (excluded.indexOf(key) >= 0) continue;
  13349. target[key] = source[key];
  13350. }
  13351. return target;
  13352. }
  13353. module.exports = _objectWithoutPropertiesLoose;
  13354. /***/ }),
  13355. /* 26 */
  13356. /***/ (function(module, exports) {
  13357. function _setPrototypeOf(o, p) {
  13358. module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  13359. o.__proto__ = p;
  13360. return o;
  13361. };
  13362. return _setPrototypeOf(o, p);
  13363. }
  13364. module.exports = _setPrototypeOf;
  13365. /***/ }),
  13366. /* 27 */
  13367. /***/ (function(module, exports) {
  13368. function _arrayWithoutHoles(arr) {
  13369. if (Array.isArray(arr)) {
  13370. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  13371. arr2[i] = arr[i];
  13372. }
  13373. return arr2;
  13374. }
  13375. }
  13376. module.exports = _arrayWithoutHoles;
  13377. /***/ }),
  13378. /* 28 */
  13379. /***/ (function(module, exports) {
  13380. function _iterableToArray(iter) {
  13381. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  13382. }
  13383. module.exports = _iterableToArray;
  13384. /***/ }),
  13385. /* 29 */
  13386. /***/ (function(module, exports) {
  13387. function _nonIterableSpread() {
  13388. throw new TypeError("Invalid attempt to spread non-iterable instance");
  13389. }
  13390. module.exports = _nonIterableSpread;
  13391. /***/ }),
  13392. /* 30 */
  13393. /***/ (function(module, exports, __webpack_require__) {
  13394. /**
  13395. * Copyright (c) 2013-present, Facebook, Inc.
  13396. * All rights reserved.
  13397. *
  13398. * This source code is licensed under the BSD-style license found in the
  13399. * LICENSE file in the root directory of this source tree. An additional grant
  13400. * of patent rights can be found in the PATENTS file in the same directory.
  13401. *
  13402. * @providesModule getContentStateFragment
  13403. * @format
  13404. *
  13405. */
  13406. var randomizeBlockMapKeys = __webpack_require__(31);
  13407. var removeEntitiesAtEdges = __webpack_require__(34);
  13408. var getContentStateFragment = function getContentStateFragment(contentState, selectionState) {
  13409. var startKey = selectionState.getStartKey();
  13410. var startOffset = selectionState.getStartOffset();
  13411. var endKey = selectionState.getEndKey();
  13412. var endOffset = selectionState.getEndOffset();
  13413. // Edge entities should be stripped to ensure that we don't preserve
  13414. // invalid partial entities when the fragment is reused. We do, however,
  13415. // preserve entities that are entirely within the selection range.
  13416. var contentWithoutEdgeEntities = removeEntitiesAtEdges(contentState, selectionState);
  13417. var blockMap = contentWithoutEdgeEntities.getBlockMap();
  13418. var blockKeys = blockMap.keySeq();
  13419. var startIndex = blockKeys.indexOf(startKey);
  13420. var endIndex = blockKeys.indexOf(endKey) + 1;
  13421. return randomizeBlockMapKeys(blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
  13422. var text = block.getText();
  13423. var chars = block.getCharacterList();
  13424. if (startKey === endKey) {
  13425. return block.merge({
  13426. text: text.slice(startOffset, endOffset),
  13427. characterList: chars.slice(startOffset, endOffset)
  13428. });
  13429. }
  13430. if (blockKey === startKey) {
  13431. return block.merge({
  13432. text: text.slice(startOffset),
  13433. characterList: chars.slice(startOffset)
  13434. });
  13435. }
  13436. if (blockKey === endKey) {
  13437. return block.merge({
  13438. text: text.slice(0, endOffset),
  13439. characterList: chars.slice(0, endOffset)
  13440. });
  13441. }
  13442. return block;
  13443. }));
  13444. };
  13445. module.exports = getContentStateFragment;
  13446. /***/ }),
  13447. /* 31 */
  13448. /***/ (function(module, exports, __webpack_require__) {
  13449. /**
  13450. * Copyright (c) 2013-present, Facebook, Inc.
  13451. * All rights reserved.
  13452. *
  13453. * This source code is licensed under the BSD-style license found in the
  13454. * LICENSE file in the root directory of this source tree. An additional grant
  13455. * of patent rights can be found in the PATENTS file in the same directory.
  13456. *
  13457. * @providesModule randomizeBlockMapKeys
  13458. * @format
  13459. *
  13460. */
  13461. var ContentBlockNode = __webpack_require__(32);
  13462. var Immutable = __webpack_require__(13);
  13463. var generateRandomKey = __webpack_require__(33);
  13464. var OrderedMap = Immutable.OrderedMap;
  13465. var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(blockMap) {
  13466. var newKeysRef = {};
  13467. // we keep track of root blocks in order to update subsequent sibling links
  13468. var lastRootBlock = void 0;
  13469. return OrderedMap(blockMap.withMutations(function (blockMapState) {
  13470. blockMapState.forEach(function (block, index) {
  13471. var oldKey = block.getKey();
  13472. var nextKey = block.getNextSiblingKey();
  13473. var prevKey = block.getPrevSiblingKey();
  13474. var childrenKeys = block.getChildKeys();
  13475. var parentKey = block.getParentKey();
  13476. // new key that we will use to build linking
  13477. var key = generateRandomKey();
  13478. // we will add it here to re-use it later
  13479. newKeysRef[oldKey] = key;
  13480. if (nextKey) {
  13481. var nextBlock = blockMapState.get(nextKey);
  13482. if (nextBlock) {
  13483. blockMapState.setIn([nextKey, 'prevSibling'], key);
  13484. } else {
  13485. // this can happen when generating random keys for fragments
  13486. blockMapState.setIn([oldKey, 'nextSibling'], null);
  13487. }
  13488. }
  13489. if (prevKey) {
  13490. var prevBlock = blockMapState.get(prevKey);
  13491. if (prevBlock) {
  13492. blockMapState.setIn([prevKey, 'nextSibling'], key);
  13493. } else {
  13494. // this can happen when generating random keys for fragments
  13495. blockMapState.setIn([oldKey, 'prevSibling'], null);
  13496. }
  13497. }
  13498. if (parentKey && blockMapState.get(parentKey)) {
  13499. var parentBlock = blockMapState.get(parentKey);
  13500. var parentChildrenList = parentBlock.getChildKeys();
  13501. blockMapState.setIn([parentKey, 'children'], parentChildrenList.set(parentChildrenList.indexOf(block.getKey()), key));
  13502. } else {
  13503. // blocks will then be treated as root block nodes
  13504. blockMapState.setIn([oldKey, 'parent'], null);
  13505. if (lastRootBlock) {
  13506. blockMapState.setIn([lastRootBlock.getKey(), 'nextSibling'], key);
  13507. blockMapState.setIn([oldKey, 'prevSibling'], newKeysRef[lastRootBlock.getKey()]);
  13508. }
  13509. lastRootBlock = blockMapState.get(oldKey);
  13510. }
  13511. childrenKeys.forEach(function (childKey) {
  13512. var childBlock = blockMapState.get(childKey);
  13513. if (childBlock) {
  13514. blockMapState.setIn([childKey, 'parent'], key);
  13515. } else {
  13516. blockMapState.setIn([oldKey, 'children'], block.getChildKeys().filter(function (child) {
  13517. return child !== childKey;
  13518. }));
  13519. }
  13520. });
  13521. });
  13522. }).toArray().map(function (block) {
  13523. return [newKeysRef[block.getKey()], block.set('key', newKeysRef[block.getKey()])];
  13524. }));
  13525. };
  13526. var randomizeContentBlockKeys = function randomizeContentBlockKeys(blockMap) {
  13527. return OrderedMap(blockMap.toArray().map(function (block) {
  13528. var key = generateRandomKey();
  13529. return [key, block.set('key', key)];
  13530. }));
  13531. };
  13532. var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
  13533. var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode;
  13534. if (!isTreeBasedBlockMap) {
  13535. return randomizeContentBlockKeys(blockMap);
  13536. }
  13537. return randomizeContentBlockNodeKeys(blockMap);
  13538. };
  13539. module.exports = randomizeBlockMapKeys;
  13540. /***/ }),
  13541. /* 32 */
  13542. /***/ (function(module, exports, __webpack_require__) {
  13543. /**
  13544. * Copyright (c) 2013-present, Facebook, Inc.
  13545. * All rights reserved.
  13546. *
  13547. * This source code is licensed under the BSD-style license found in the
  13548. * LICENSE file in the root directory of this source tree. An additional grant
  13549. * of patent rights can be found in the PATENTS file in the same directory.
  13550. *
  13551. * @providesModule ContentBlockNode
  13552. * @format
  13553. *
  13554. *
  13555. * This file is a fork of ContentBlock adding support for nesting references by
  13556. * providing links to children, parent, prevSibling, and nextSibling.
  13557. *
  13558. * This is unstable and not part of the public API and should not be used by
  13559. * production systems. This file may be update/removed without notice.
  13560. */
  13561. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13562. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  13563. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  13564. var CharacterMetadata = __webpack_require__(19);
  13565. var Immutable = __webpack_require__(13);
  13566. var findRangesImmutable = __webpack_require__(20);
  13567. var List = Immutable.List,
  13568. Map = Immutable.Map,
  13569. OrderedSet = Immutable.OrderedSet,
  13570. Record = Immutable.Record,
  13571. Repeat = Immutable.Repeat;
  13572. var EMPTY_SET = OrderedSet();
  13573. var defaultRecord = {
  13574. parent: null,
  13575. characterList: List(),
  13576. data: Map(),
  13577. depth: 0,
  13578. key: '',
  13579. text: '',
  13580. type: 'unstyled',
  13581. children: List(),
  13582. prevSibling: null,
  13583. nextSibling: null
  13584. };
  13585. var haveEqualStyle = function haveEqualStyle(charA, charB) {
  13586. return charA.getStyle() === charB.getStyle();
  13587. };
  13588. var haveEqualEntity = function haveEqualEntity(charA, charB) {
  13589. return charA.getEntity() === charB.getEntity();
  13590. };
  13591. var decorateCharacterList = function decorateCharacterList(config) {
  13592. if (!config) {
  13593. return config;
  13594. }
  13595. var characterList = config.characterList,
  13596. text = config.text;
  13597. if (text && !characterList) {
  13598. config.characterList = List(Repeat(CharacterMetadata.EMPTY, text.length));
  13599. }
  13600. return config;
  13601. };
  13602. var ContentBlockNode = function (_Record) {
  13603. _inherits(ContentBlockNode, _Record);
  13604. function ContentBlockNode() {
  13605. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRecord;
  13606. _classCallCheck(this, ContentBlockNode);
  13607. return _possibleConstructorReturn(this, _Record.call(this, decorateCharacterList(props)));
  13608. }
  13609. ContentBlockNode.prototype.getKey = function getKey() {
  13610. return this.get('key');
  13611. };
  13612. ContentBlockNode.prototype.getType = function getType() {
  13613. return this.get('type');
  13614. };
  13615. ContentBlockNode.prototype.getText = function getText() {
  13616. return this.get('text');
  13617. };
  13618. ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
  13619. return this.get('characterList');
  13620. };
  13621. ContentBlockNode.prototype.getLength = function getLength() {
  13622. return this.getText().length;
  13623. };
  13624. ContentBlockNode.prototype.getDepth = function getDepth() {
  13625. return this.get('depth');
  13626. };
  13627. ContentBlockNode.prototype.getData = function getData() {
  13628. return this.get('data');
  13629. };
  13630. ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
  13631. var character = this.getCharacterList().get(offset);
  13632. return character ? character.getStyle() : EMPTY_SET;
  13633. };
  13634. ContentBlockNode.prototype.getEntityAt = function getEntityAt(offset) {
  13635. var character = this.getCharacterList().get(offset);
  13636. return character ? character.getEntity() : null;
  13637. };
  13638. ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
  13639. return this.get('children');
  13640. };
  13641. ContentBlockNode.prototype.getParentKey = function getParentKey() {
  13642. return this.get('parent');
  13643. };
  13644. ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
  13645. return this.get('prevSibling');
  13646. };
  13647. ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
  13648. return this.get('nextSibling');
  13649. };
  13650. ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
  13651. findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
  13652. };
  13653. ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
  13654. findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
  13655. };
  13656. return ContentBlockNode;
  13657. }(Record(defaultRecord));
  13658. module.exports = ContentBlockNode;
  13659. /***/ }),
  13660. /* 33 */
  13661. /***/ (function(module, exports, __webpack_require__) {
  13662. /**
  13663. * Copyright (c) 2013-present, Facebook, Inc.
  13664. * All rights reserved.
  13665. *
  13666. * This source code is licensed under the BSD-style license found in the
  13667. * LICENSE file in the root directory of this source tree. An additional grant
  13668. * of patent rights can be found in the PATENTS file in the same directory.
  13669. *
  13670. * @providesModule generateRandomKey
  13671. * @format
  13672. *
  13673. */
  13674. var seenKeys = {};
  13675. var MULTIPLIER = Math.pow(2, 24);
  13676. function generateRandomKey() {
  13677. var key = void 0;
  13678. while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
  13679. key = Math.floor(Math.random() * MULTIPLIER).toString(32);
  13680. }
  13681. seenKeys[key] = true;
  13682. return key;
  13683. }
  13684. module.exports = generateRandomKey;
  13685. /***/ }),
  13686. /* 34 */
  13687. /***/ (function(module, exports, __webpack_require__) {
  13688. /**
  13689. * Copyright (c) 2013-present, Facebook, Inc.
  13690. * All rights reserved.
  13691. *
  13692. * This source code is licensed under the BSD-style license found in the
  13693. * LICENSE file in the root directory of this source tree. An additional grant
  13694. * of patent rights can be found in the PATENTS file in the same directory.
  13695. *
  13696. * @providesModule removeEntitiesAtEdges
  13697. * @format
  13698. *
  13699. */
  13700. var CharacterMetadata = __webpack_require__(19);
  13701. var findRangesImmutable = __webpack_require__(20);
  13702. var invariant = __webpack_require__(35);
  13703. function removeEntitiesAtEdges(contentState, selectionState) {
  13704. var blockMap = contentState.getBlockMap();
  13705. var entityMap = contentState.getEntityMap();
  13706. var updatedBlocks = {};
  13707. var startKey = selectionState.getStartKey();
  13708. var startOffset = selectionState.getStartOffset();
  13709. var startBlock = blockMap.get(startKey);
  13710. var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
  13711. if (updatedStart !== startBlock) {
  13712. updatedBlocks[startKey] = updatedStart;
  13713. }
  13714. var endKey = selectionState.getEndKey();
  13715. var endOffset = selectionState.getEndOffset();
  13716. var endBlock = blockMap.get(endKey);
  13717. if (startKey === endKey) {
  13718. endBlock = updatedStart;
  13719. }
  13720. var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
  13721. if (updatedEnd !== endBlock) {
  13722. updatedBlocks[endKey] = updatedEnd;
  13723. }
  13724. if (!Object.keys(updatedBlocks).length) {
  13725. return contentState.set('selectionAfter', selectionState);
  13726. }
  13727. return contentState.merge({
  13728. blockMap: blockMap.merge(updatedBlocks),
  13729. selectionAfter: selectionState
  13730. });
  13731. }
  13732. function getRemovalRange(characters, key, offset) {
  13733. var removalRange;
  13734. findRangesImmutable(characters, function (a, b) {
  13735. return a.getEntity() === b.getEntity();
  13736. }, function (element) {
  13737. return element.getEntity() === key;
  13738. }, function (start, end) {
  13739. if (start <= offset && end >= offset) {
  13740. removalRange = { start: start, end: end };
  13741. }
  13742. });
  13743. !(typeof removalRange === 'object') ? invariant(false) : void 0;
  13744. return removalRange;
  13745. }
  13746. function removeForBlock(entityMap, block, offset) {
  13747. var chars = block.getCharacterList();
  13748. var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
  13749. var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
  13750. var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
  13751. var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
  13752. if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
  13753. var entity = entityMap.__get(entityAfterCursor);
  13754. if (entity.getMutability() !== 'MUTABLE') {
  13755. var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset),
  13756. start = _getRemovalRange.start,
  13757. end = _getRemovalRange.end;
  13758. var current;
  13759. while (start < end) {
  13760. current = chars.get(start);
  13761. chars = chars.set(start, CharacterMetadata.applyEntity(current, null));
  13762. start++;
  13763. }
  13764. return block.set('characterList', chars);
  13765. }
  13766. }
  13767. return block;
  13768. }
  13769. module.exports = removeEntitiesAtEdges;
  13770. /***/ }),
  13771. /* 35 */
  13772. /***/ (function(module, exports, __webpack_require__) {
  13773. function invariant(condition, format, a, b, c, d, e, f) {
  13774. if (!condition) {
  13775. var error;
  13776. if (format === undefined) {
  13777. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  13778. } else {
  13779. var args = [a, b, c, d, e, f];
  13780. var argIndex = 0;
  13781. error = new Error(format.replace(/%s/g, function () {
  13782. return args[argIndex++];
  13783. }));
  13784. error.name = 'Invariant Violation';
  13785. }
  13786. error.framesToPop = 1; // we don't care about invariant's own frame
  13787. throw error;
  13788. }
  13789. }
  13790. module.exports = invariant;
  13791. /***/ }),
  13792. /* 36 */
  13793. /***/ (function(module, exports) {
  13794. function _arrayWithHoles(arr) {
  13795. if (Array.isArray(arr)) return arr;
  13796. }
  13797. module.exports = _arrayWithHoles;
  13798. /***/ }),
  13799. /* 37 */
  13800. /***/ (function(module, exports) {
  13801. function _iterableToArrayLimit(arr, i) {
  13802. var _arr = [];
  13803. var _n = true;
  13804. var _d = false;
  13805. var _e = undefined;
  13806. try {
  13807. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  13808. _arr.push(_s.value);
  13809. if (i && _arr.length === i) break;
  13810. }
  13811. } catch (err) {
  13812. _d = true;
  13813. _e = err;
  13814. } finally {
  13815. try {
  13816. if (!_n && _i["return"] != null) _i["return"]();
  13817. } finally {
  13818. if (_d) throw _e;
  13819. }
  13820. }
  13821. return _arr;
  13822. }
  13823. module.exports = _iterableToArrayLimit;
  13824. /***/ }),
  13825. /* 38 */
  13826. /***/ (function(module, exports) {
  13827. function _nonIterableRest() {
  13828. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  13829. }
  13830. module.exports = _nonIterableRest;
  13831. /***/ }),
  13832. /* 39 */
  13833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13834. __webpack_require__.r(__webpack_exports__);
  13835. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/typeof.js
  13836. var helpers_typeof = __webpack_require__(15);
  13837. var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);
  13838. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectSpread.js
  13839. var objectSpread = __webpack_require__(5);
  13840. var objectSpread_default = /*#__PURE__*/__webpack_require__.n(objectSpread);
  13841. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectWithoutProperties.js
  13842. var objectWithoutProperties = __webpack_require__(21);
  13843. var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
  13844. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/classCallCheck.js
  13845. var classCallCheck = __webpack_require__(4);
  13846. var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);
  13847. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/createClass.js
  13848. var createClass = __webpack_require__(7);
  13849. var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);
  13850. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
  13851. var possibleConstructorReturn = __webpack_require__(8);
  13852. var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn);
  13853. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/getPrototypeOf.js
  13854. var getPrototypeOf = __webpack_require__(9);
  13855. var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf);
  13856. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/inherits.js
  13857. var inherits = __webpack_require__(10);
  13858. var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);
  13859. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/assertThisInitialized.js
  13860. var assertThisInitialized = __webpack_require__(1);
  13861. var assertThisInitialized_default = /*#__PURE__*/__webpack_require__.n(assertThisInitialized);
  13862. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/defineProperty.js
  13863. var defineProperty = __webpack_require__(2);
  13864. var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
  13865. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/toConsumableArray.js
  13866. var toConsumableArray = __webpack_require__(12);
  13867. var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
  13868. // EXTERNAL MODULE: ../node_modules/draft-js/dist/Draft.css
  13869. var Draft = __webpack_require__(40);
  13870. // EXTERNAL MODULE: ./assets/scss/_base.scss
  13871. var _base = __webpack_require__(42);
  13872. // EXTERNAL MODULE: external "react"
  13873. var external_react_ = __webpack_require__(0);
  13874. var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
  13875. // CONCATENATED MODULE: ./languages/en.js
  13876. /* harmony default export */ var en = ({
  13877. base: {
  13878. remove: 'Remove',
  13879. cancel: 'Cancel',
  13880. confirm: 'Confirm',
  13881. inert: 'Insert',
  13882. width: 'Width',
  13883. height: 'Height'
  13884. },
  13885. controls: {
  13886. clear: 'Clear',
  13887. undo: 'Undo',
  13888. redo: 'Redo',
  13889. fontSize: 'Font Size',
  13890. color: 'Color',
  13891. textColor: 'Text',
  13892. tempColors: 'Temp Colors',
  13893. backgroundColor: 'Background',
  13894. bold: 'Bold',
  13895. lineHeight: 'Line Height',
  13896. letterSpacing: 'Letter Spacing',
  13897. textIndent: 'Text Indent',
  13898. increaseIndent: 'Increase Indent',
  13899. decreaseIndent: 'Decrease Indent',
  13900. italic: 'Italic',
  13901. underline: 'Underline',
  13902. strikeThrough: 'Strike Through',
  13903. fontFamily: 'Font Family',
  13904. textAlign: 'Text Alignment',
  13905. alignLeft: 'Left Alignment',
  13906. alignCenter: 'Center Alignment',
  13907. alignRight: 'Right Alignment',
  13908. alignJustify: 'Justify Alignment',
  13909. floatLeft: 'Left Float',
  13910. floatRight: 'Right Float',
  13911. superScript: 'Super Script',
  13912. subScript: 'Sub Script',
  13913. removeStyles: 'Remove Styles',
  13914. headings: 'Headings',
  13915. header: 'Header',
  13916. normal: 'Normal',
  13917. orderedList: 'Ordered List',
  13918. unorderedList: 'Unordered List',
  13919. blockQuote: 'Quote',
  13920. code: 'Code',
  13921. link: 'Link',
  13922. unlink: 'Unlink',
  13923. hr: 'Horizontal Line',
  13924. media: 'Media',
  13925. mediaLibirary: 'Media Library',
  13926. emoji: 'Emoji',
  13927. fullscreen: 'Fullscreen',
  13928. exitFullscreen: 'Exit Fullscreen'
  13929. },
  13930. linkEditor: {
  13931. textInputPlaceHolder: 'Input link text',
  13932. linkInputPlaceHolder: 'Input link URL',
  13933. inputWithEnterPlaceHolder: 'Input link URL and press Enter',
  13934. openInNewWindow: 'Open in new window',
  13935. removeLink: 'Remove Link'
  13936. },
  13937. audioPlayer: {
  13938. title: 'Play Audio'
  13939. },
  13940. videoPlayer: {
  13941. title: 'Play Video',
  13942. embedTitle: 'Embed Media'
  13943. },
  13944. media: {
  13945. image: 'Image',
  13946. video: 'Video',
  13947. audio: 'Audio',
  13948. embed: 'Embed'
  13949. }
  13950. });
  13951. // CONCATENATED MODULE: ./languages/zh.js
  13952. /* harmony default export */ var zh = ({
  13953. base: {
  13954. remove: '删除',
  13955. cancel: '取消',
  13956. confirm: '确定',
  13957. inert: '插入',
  13958. width: '宽度',
  13959. height: '高度'
  13960. },
  13961. controls: {
  13962. clear: '清除内容',
  13963. undo: '撤销',
  13964. redo: '重做',
  13965. fontSize: '字号',
  13966. lineHeight: '行高',
  13967. letterSpacing: '字间距',
  13968. textIndent: '段落缩进',
  13969. increaseIndent: '增加缩进',
  13970. decreaseIndent: '减少缩进',
  13971. border: '边框',
  13972. color: '颜色',
  13973. textColor: '文字颜色',
  13974. backgroundColor: '背景颜色',
  13975. tempColors: '临时颜色',
  13976. bold: '加粗',
  13977. italic: '斜体',
  13978. underline: '下划线',
  13979. strikeThrough: '删除线',
  13980. fontFamily: '字体',
  13981. textAlign: '文本对齐',
  13982. alignLeft: '居左',
  13983. alignCenter: '居中',
  13984. alignRight: '居右',
  13985. alignJustify: '两端',
  13986. floatLeft: '左浮动',
  13987. floatRight: '右浮动',
  13988. superScript: '上标',
  13989. subScript: '下标',
  13990. removeStyles: '清除样式',
  13991. headings: '标题',
  13992. header: '标题',
  13993. normal: '常规',
  13994. orderedList: '有序列表',
  13995. unorderedList: '无序列表',
  13996. blockQuote: '引用',
  13997. code: '代码',
  13998. link: '链接',
  13999. unlink: '清除链接',
  14000. hr: '水平线',
  14001. media: '媒体',
  14002. mediaLibirary: '媒体库',
  14003. emoji: '小表情',
  14004. fullscreen: '全屏',
  14005. exitFullscreen: '退出全屏'
  14006. },
  14007. linkEditor: {
  14008. textInputPlaceHolder: '输入链接文字',
  14009. linkInputPlaceHolder: '输入链接地址',
  14010. inputWithEnterPlaceHolder: '输入链接地址并回车',
  14011. openInNewWindow: '在新窗口打开',
  14012. removeLink: '移除链接'
  14013. },
  14014. audioPlayer: {
  14015. title: '播放音频文件'
  14016. },
  14017. videoPlayer: {
  14018. title: '播放视频文件',
  14019. embedTitle: '嵌入式媒体'
  14020. },
  14021. media: {
  14022. image: '图像',
  14023. video: '视频',
  14024. audio: '音频',
  14025. embed: '嵌入式媒体'
  14026. }
  14027. });
  14028. // CONCATENATED MODULE: ./languages/zh-hant.js
  14029. /* harmony default export */ var zh_hant = ({
  14030. base: {
  14031. remove: '刪除',
  14032. cancel: '取消',
  14033. confirm: '確定',
  14034. inert: '插入',
  14035. width: '宽度',
  14036. height: '高度'
  14037. },
  14038. controls: {
  14039. clear: '清除内容',
  14040. undo: '撤銷',
  14041. redo: '重做',
  14042. fontSize: '字號',
  14043. color: '顏色',
  14044. textColor: '文字顏色',
  14045. backgroundColor: '背景顏色',
  14046. tempColors: '臨時顏色',
  14047. bold: '加粗',
  14048. lineHeight: '行高',
  14049. letterSpacing: '字間距',
  14050. textIndent: '段落縮進',
  14051. increaseIndent: '增加縮進',
  14052. decreaseIndent: '减少縮進',
  14053. border: '邊框',
  14054. italic: '斜體',
  14055. underline: '下劃線',
  14056. strikeThrough: '刪除線',
  14057. fontFamily: '字體',
  14058. textAlign: '文本對齊',
  14059. alignLeft: '居左',
  14060. alignCenter: '居中',
  14061. alignRight: '居右',
  14062. alignJustify: '兩端對齊',
  14063. floatLeft: '左浮動',
  14064. floatRight: '右浮動',
  14065. superScript: '上標',
  14066. subScript: '下標',
  14067. removeStyles: '清除样式',
  14068. headings: '標題',
  14069. header: '標題',
  14070. normal: '常規',
  14071. orderedList: '有序列表',
  14072. unorderedList: '無序列表',
  14073. blockQuote: '引用',
  14074. code: '代碼',
  14075. link: '鏈接',
  14076. unlink: '清除鏈接',
  14077. hr: '水平线',
  14078. media: '媒體',
  14079. mediaLibirary: '媒體库',
  14080. emoji: '小表情',
  14081. fullscreen: '全熒幕',
  14082. exitFullscreen: '退出全熒幕'
  14083. },
  14084. linkEditor: {
  14085. textInputPlaceHolder: '輸入鏈接文字',
  14086. linkInputPlaceHolder: '輸入鏈接地址',
  14087. inputWithEnterPlaceHolder: '輸入鏈接地址並回車',
  14088. openInNewWindow: '在新窗口打開',
  14089. removeLink: '移除鏈接'
  14090. },
  14091. audioPlayer: {
  14092. title: '播放音頻文件'
  14093. },
  14094. videoPlayer: {
  14095. title: '播放視頻文件',
  14096. embedTitle: '嵌入式媒體'
  14097. },
  14098. media: {
  14099. image: '圖像',
  14100. video: '視頻',
  14101. audio: '音頻',
  14102. embed: '嵌入式媒體'
  14103. }
  14104. });
  14105. // CONCATENATED MODULE: ./languages/pl.js
  14106. /* harmony default export */ var pl = ({
  14107. base: {
  14108. remove: 'Usuń',
  14109. cancel: 'Anuluj',
  14110. confirm: 'Potwierdź',
  14111. inert: 'Wstaw',
  14112. width: 'Szerokość',
  14113. height: 'Wysokość'
  14114. },
  14115. controls: {
  14116. clear: 'Wyczyść',
  14117. undo: 'Cofnij',
  14118. redo: 'Przywróć',
  14119. fontSize: 'Wielkość',
  14120. color: 'Kolor',
  14121. textColor: 'Kolor tekstu',
  14122. tempColors: 'Kolory',
  14123. backgroundColor: 'Tło',
  14124. bold: 'Pogrubienie',
  14125. lineHeight: 'Wysokość linii',
  14126. letterSpacing: 'Odstęp znaków',
  14127. textIndent: 'Wcięcie tekstu',
  14128. increaseIndent: 'Zwiększ wcięcie',
  14129. decreaseIndent: 'Zmniejsz wcięcie',
  14130. italic: 'Italiki',
  14131. underline: 'Podkreślenie',
  14132. strikeThrough: 'Przekreślenie',
  14133. fontFamily: 'Czcionka',
  14134. textAlign: 'Wyrównanie tekstu',
  14135. alignLeft: 'Do lewej',
  14136. alignCenter: 'Wycentruj',
  14137. alignRight: 'Do prawej',
  14138. alignJustify: 'Wyjustuj',
  14139. floatLeft: 'Do lewej',
  14140. floatRight: 'Do prawej',
  14141. superScript: 'Superskrypt',
  14142. subScript: 'Subskrypt',
  14143. removeStyles: 'Usuń stylowanie',
  14144. headings: 'Nagłówki',
  14145. header: 'Nagłówek',
  14146. normal: 'Normalny',
  14147. orderedList: 'Lista uporządkowana',
  14148. unorderedList: 'Lista nieuporządkowana',
  14149. blockQuote: 'Cytat',
  14150. code: 'Kod',
  14151. link: 'Link',
  14152. unlink: 'Usuń link',
  14153. hr: 'Linia pozioma',
  14154. media: 'Media',
  14155. mediaLibirary: 'Biblioteka mediów',
  14156. emoji: 'Emoji'
  14157. },
  14158. linkEditor: {
  14159. textInputPlaceHolder: 'Wpisz tekst linku',
  14160. linkInputPlaceHolder: 'Wpisz Adres URL',
  14161. inputWithEnterPlaceHolder: 'Wpisz adres URL i naciśnij Enter',
  14162. openInNewWindow: 'Otwórz w nowym oknie',
  14163. removeLink: 'Usuń link'
  14164. },
  14165. audioPlayer: {
  14166. title: 'Odtwórz audio'
  14167. },
  14168. videoPlayer: {
  14169. title: 'Odtwórz wideo',
  14170. embedTitle: 'Tytuł'
  14171. },
  14172. media: {
  14173. image: 'Obraz',
  14174. video: 'Wideo',
  14175. audio: 'Audio',
  14176. embed: 'Obiekt osadzony'
  14177. }
  14178. });
  14179. // CONCATENATED MODULE: ./languages/kr.js
  14180. /* harmony default export */ var kr = ({
  14181. base: {
  14182. remove: '삭제',
  14183. cancel: '취소',
  14184. confirm: '결정',
  14185. inert: '삽입',
  14186. width: '너비',
  14187. height: '높이'
  14188. },
  14189. controls: {
  14190. clear: '콘텐츠지우기',
  14191. undo: '취소',
  14192. redo: '다시하기',
  14193. fontSize: '글자크기',
  14194. lineHeight: '행높이',
  14195. letterSpacing: '단어간격',
  14196. textIndent: '단락들여쓰기',
  14197. increaseIndent: '들여쓰기늘리기',
  14198. decreaseIndent: '들여쓰기줄이기',
  14199. border: '국경',
  14200. color: '색상',
  14201. textColor: '텍스트색상',
  14202. backgroundColor: '배경색상',
  14203. tempColors: '임시색',
  14204. bold: '굵게',
  14205. italic: '기울임꼴',
  14206. underline: '밑줄',
  14207. strikeThrough: '취소선',
  14208. fontFamily: '글꼴',
  14209. textAlign: '텍스트정렬',
  14210. alignLeft: '왼쪽',
  14211. alignCenter: '중심',
  14212. alignRight: '오른쪽',
  14213. alignJustify: '양쪽끝',
  14214. floatLeft: '떠다니기',
  14215. floatRight: '오른쪽부동',
  14216. superScript: '위첨자',
  14217. subScript: '첨자',
  14218. removeStyles: '스타일지우기',
  14219. headings: '제목',
  14220. header: '제목',
  14221. normal: '재래식',
  14222. orderedList: '순서가지정된목록',
  14223. unorderedList: '정렬되지않은목록',
  14224. blockQuote: '참고문헌',
  14225. code: '코드',
  14226. link: '링크',
  14227. unlink: '링크삭제',
  14228. hr: '수평선',
  14229. media: '미디어',
  14230. mediaLibirary: '미디어라이브러리',
  14231. emoji: '작은표현',
  14232. fullscreen: '전체화면',
  14233. exitFullscreen: '전체화면종료'
  14234. },
  14235. linkEditor: {
  14236. textInputPlaceHolder: '링크텍스트입력',
  14237. linkInputPlaceHolder: '링크주소입력',
  14238. inputWithEnterPlaceHolder: '링크주소입력.',
  14239. openInNewWindow: '새창열기',
  14240. removeLink: '링크삭제'
  14241. },
  14242. audioPlayer: {
  14243. title: '오디오파일재생'
  14244. },
  14245. videoPlayer: {
  14246. title: '비디오파일재생',
  14247. embedTitle: '임베디드미디어'
  14248. },
  14249. media: {
  14250. image: '이미지',
  14251. video: '비디오',
  14252. audio: '오디오',
  14253. embed: '임베디드미디어'
  14254. }
  14255. });
  14256. // CONCATENATED MODULE: ./languages/tr.js
  14257. /* harmony default export */ var tr = ({
  14258. base: {
  14259. remove: 'Kaldır',
  14260. cancel: 'İptal',
  14261. confirm: 'Onayla',
  14262. inert: 'Ekle',
  14263. width: 'Genişlik',
  14264. height: 'Yükseklik'
  14265. },
  14266. controls: {
  14267. clear: 'Temizle',
  14268. undo: 'Geri al',
  14269. redo: 'İleri al',
  14270. fontSize: 'Yazı boyutu',
  14271. color: 'Renk',
  14272. textColor: 'Yazı rengi',
  14273. tempColors: 'Geçici renkler',
  14274. backgroundColor: 'Arkaplan',
  14275. bold: 'Kalın',
  14276. lineHeight: 'Satır yüksekliği',
  14277. letterSpacing: 'Harf aralığı',
  14278. textIndent: 'Çentik aralığı',
  14279. increaseIndent: 'Çentiği genişlet',
  14280. decreaseIndent: 'Çentiği daralt',
  14281. italic: 'Eğik',
  14282. underline: 'Altı çizili',
  14283. strikeThrough: 'Üstü çizili',
  14284. fontFamily: 'Yazı tipi',
  14285. textAlign: 'Metin Hizalama',
  14286. alignLeft: 'Sola hizala',
  14287. alignCenter: 'Ortaya hizala',
  14288. alignRight: 'Sağa hizala',
  14289. alignJustify: 'Her iki tarafa hizala',
  14290. floatLeft: 'Sola yatır',
  14291. floatRight: 'Sağa yatır',
  14292. superScript: 'Ana kod',
  14293. subScript: 'Alt kod',
  14294. removeStyles: 'Stilleri kaldır',
  14295. headings: 'Başlıklar',
  14296. header: 'Başlık',
  14297. normal: 'Normal',
  14298. orderedList: 'Sıralı liste',
  14299. unorderedList: 'Sırasız liste',
  14300. blockQuote: 'Alıntı',
  14301. code: 'Kod',
  14302. link: 'Bağlantı',
  14303. unlink: 'Bağlantıyı kaldır',
  14304. hr: 'Yatay çizgi',
  14305. media: 'Medya',
  14306. mediaLibirary: 'Kütüphane',
  14307. emoji: 'İfade',
  14308. fullscreen: 'Tam ekran',
  14309. exitFullscreen: 'Tam ekrandan çık'
  14310. },
  14311. linkEditor: {
  14312. textInputPlaceHolder: 'Bağlantı metnini girin',
  14313. linkInputPlaceHolder: 'Bağlantı URL\' si girin',
  14314. inputWithEnterPlaceHolder: 'Bağlantı URL\'si girin ve Enter\' a basın',
  14315. openInNewWindow: 'Yeni pencerede aç',
  14316. removeLink: 'Bağlantıyı kaldır'
  14317. },
  14318. audioPlayer: {
  14319. title: 'Ses çal'
  14320. },
  14321. videoPlayer: {
  14322. title: 'Görüntü oynat',
  14323. embedTitle: 'Görüntüyü göm'
  14324. },
  14325. media: {
  14326. image: 'Resim',
  14327. video: 'Görüntü',
  14328. audio: 'Ses',
  14329. embed: 'Gömülü nesne'
  14330. }
  14331. });
  14332. // CONCATENATED MODULE: ./languages/jpn.js
  14333. /* harmony default export */ var jpn = ({
  14334. base: {
  14335. remove: '削除',
  14336. cancel: 'キャンセル',
  14337. confirm: '決定',
  14338. inert: '挿入',
  14339. width: '幅',
  14340. height: '高さ'
  14341. },
  14342. controls: {
  14343. clear: 'クリアコンテンツ',
  14344. undo: 'キャンセル',
  14345. redo: 'キャンセル',
  14346. fontSize: 'フォントサイズ',
  14347. lineHeight: 'フォントサイズ',
  14348. letterSpacing: 'ワード間隔',
  14349. textIndent: '段落のインデント',
  14350. increaseIndent: 'インデントを増やす',
  14351. decreaseIndent: 'インデントを減らす',
  14352. border: '国境',
  14353. color: '色',
  14354. textColor: 'テキストの色',
  14355. backgroundColor: '背景色',
  14356. tempColors: '仮色',
  14357. bold: '太字',
  14358. italic: 'イタリック体',
  14359. underline: '下線',
  14360. strikeThrough: '取り消し線',
  14361. fontFamily: 'フォント',
  14362. textAlign: 'テキストの配置',
  14363. alignLeft: '左',
  14364. alignCenter: '中央揃え',
  14365. alignRight: '右に立つ',
  14366. alignJustify: '両端',
  14367. floatLeft: '左フローティング',
  14368. floatRight: '右フローティング',
  14369. superScript: '上付き',
  14370. subScript: '下付き文字',
  14371. removeStyles: 'クリアスタイル',
  14372. headings: '役職',
  14373. header: '役職',
  14374. normal: '従来の',
  14375. orderedList: '順序付きリスト',
  14376. unorderedList: '番号なしリスト',
  14377. blockQuote: '参照',
  14378. code: 'コード',
  14379. link: 'リンク',
  14380. unlink: 'リンクを解除',
  14381. hr: '横線',
  14382. media: 'メディア',
  14383. mediaLibirary: 'メディアライブラリー',
  14384. emoji: '小さな表現',
  14385. fullscreen: '全画面',
  14386. exitFullscreen: '全画面を退く'
  14387. },
  14388. linkEditor: {
  14389. textInputPlaceHolder: 'リンクテキストを入力',
  14390. linkInputPlaceHolder: 'リンクアドレスを入力',
  14391. inputWithEnterPlaceHolder: 'リンクアドレスを入力して戻ります',
  14392. openInNewWindow: '新しいウィンドウで開く',
  14393. removeLink: '新しいウィンドウで開く'
  14394. },
  14395. audioPlayer: {
  14396. title: 'オーディオファイルを再生する'
  14397. },
  14398. videoPlayer: {
  14399. title: 'ビデオファイルを再生する',
  14400. embedTitle: '埋め込みメディア'
  14401. },
  14402. media: {
  14403. image: '画像',
  14404. video: 'ビデオ',
  14405. audio: '音声',
  14406. embed: '埋め込みメディア'
  14407. }
  14408. });
  14409. // CONCATENATED MODULE: ./languages/ru.js
  14410. /* harmony default export */ var ru = ({
  14411. base: {
  14412. remove: 'Удалить',
  14413. cancel: 'Отмена',
  14414. confirm: 'Подтвердить',
  14415. insert: 'Вставить',
  14416. width: 'Ширина',
  14417. height: 'Высота'
  14418. },
  14419. controls: {
  14420. clear: 'Очистить',
  14421. undo: 'Отменить',
  14422. redo: 'Повторить',
  14423. fontSize: 'Размер шрифта',
  14424. color: 'Цвет',
  14425. textColor: 'Цвет текста',
  14426. tempColors: 'Temp Colors',
  14427. backgroundColor: 'Цвет фона',
  14428. bold: 'Жирный',
  14429. lineHeight: 'Межстрочный интервал',
  14430. letterSpacing: 'Межбуквенный интервал',
  14431. textIndent: 'Отступ',
  14432. increaseIndent: 'Увеличить отступ',
  14433. decreaseIndent: 'Уменьшить отступ',
  14434. italic: 'Курсив',
  14435. underline: 'Подчеркнутый',
  14436. strikeThrough: 'Перечеркнутый',
  14437. fontFamily: 'Шрифт',
  14438. textAlign: 'Расположение текста',
  14439. alignLeft: 'По левому краю',
  14440. alignCenter: 'По центру',
  14441. alignRight: 'По правому краю',
  14442. alignJustify: 'По ширине',
  14443. floatLeft: 'Обтекание слева',
  14444. floatRight: 'Обтекание справа',
  14445. superScript: 'Надстрочный индекс',
  14446. subScript: 'Подстрочный индекс',
  14447. removeStyles: 'Убрать стили',
  14448. headings: 'Заголовки',
  14449. header: 'Заголовок',
  14450. normal: 'Обычный',
  14451. orderedList: 'Упорядоченный список',
  14452. unorderedList: 'Неупорядоченный список',
  14453. blockQuote: 'Цитата',
  14454. code: 'Код',
  14455. link: 'Вставить ссылку',
  14456. unlink: 'Убрать ссылку',
  14457. hr: 'Горизонтальная линия',
  14458. media: 'Медиа',
  14459. mediaLibirary: 'Медиа библиотека',
  14460. emoji: 'Emoji',
  14461. fullscreen: 'Полноэкранный режим',
  14462. exitFullscreen: 'Выйти из полноэкранного режима'
  14463. },
  14464. linkEditor: {
  14465. textInputPlaceHolder: 'Введите текст ссылки',
  14466. linkInputPlaceHolder: 'Вставить ссылку',
  14467. inputWithEnterPlaceHolder: 'Вставить ссылку и нажать Enter',
  14468. openInNewWindow: 'Открыть в новом окне',
  14469. removeLink: 'Убрать ссылку'
  14470. },
  14471. audioPlayer: {
  14472. title: 'Воспроизвести аудиофайл'
  14473. },
  14474. videoPlayer: {
  14475. title: 'Воспроизвести видеофайл',
  14476. embedTitle: 'Embed Media'
  14477. },
  14478. media: {
  14479. image: 'Картинка',
  14480. video: 'Видео',
  14481. audio: 'Аудио',
  14482. embed: 'Встроенное'
  14483. }
  14484. });
  14485. // CONCATENATED MODULE: ./languages/fr.js
  14486. /* harmony default export */ var fr = ({
  14487. base: {
  14488. remove: 'Supprimer',
  14489. cancel: 'Annuler',
  14490. confirm: 'Confirmer',
  14491. inert: 'Insérer',
  14492. width: 'Largeur',
  14493. height: 'Hauteur'
  14494. },
  14495. controls: {
  14496. clear: 'Effacer',
  14497. undo: 'Annuler',
  14498. redo: 'Refaire',
  14499. fontSize: 'Taille de police',
  14500. color: 'Couleur',
  14501. textColor: 'Texte',
  14502. tempColors: 'Couleurs temporaire',
  14503. backgroundColor: 'Couleur d\'arrière plan',
  14504. bold: 'Gras',
  14505. lineHeight: 'Hauteur de ligne',
  14506. letterSpacing: 'Espacement des lettres',
  14507. textIndent: 'Indentation du texte',
  14508. increaseIndent: 'Augmenter l\'indentation',
  14509. decreaseIndent: 'Réduire l\'indentation',
  14510. italic: 'Italique',
  14511. underline: 'Souligner',
  14512. strikeThrough: 'Barrer',
  14513. fontFamily: 'Police d\'écriture',
  14514. textAlign: 'Alignement du texte',
  14515. alignLeft: 'Aligner à gauche',
  14516. alignCenter: 'Aligner au centre',
  14517. alignRight: 'Aligner à droite',
  14518. alignJustify: 'Justifier',
  14519. floatLeft: 'Déplacer à gauche',
  14520. floatRight: 'Déplacer à droite',
  14521. superScript: 'Super-script',
  14522. subScript: 'Sous-script',
  14523. removeStyles: 'Supprimer les styles',
  14524. headings: 'Titres',
  14525. header: 'Entêtes',
  14526. normal: 'Normal',
  14527. orderedList: 'Liste ordonnée',
  14528. unorderedList: 'Liste non-ordonnée',
  14529. blockQuote: 'Citation',
  14530. code: 'Code',
  14531. link: 'Insérer un lien',
  14532. unlink: 'Supprimer le lien',
  14533. hr: 'Ligne horizontale',
  14534. media: 'Média',
  14535. mediaLibirary: 'Bibliothêque',
  14536. emoji: 'Emoji',
  14537. fullscreen: 'Plein écran',
  14538. exitFullscreen: 'Quitter le plein écran'
  14539. },
  14540. linkEditor: {
  14541. textInputPlaceHolder: 'Insérer le texte à afficher',
  14542. linkInputPlaceHolder: 'Insérer le lien URL',
  14543. inputWithEnterPlaceHolder: 'Insérer le lien URL puis appuyer sur Entrée',
  14544. openInNewWindow: 'Ouvrir dans une nouvelle fenêtre',
  14545. removeLink: 'Supprimer le lien'
  14546. },
  14547. audioPlayer: {
  14548. title: 'Lancer le son audio'
  14549. },
  14550. videoPlayer: {
  14551. title: 'Lancer la video',
  14552. embedTitle: 'Intégrer média'
  14553. },
  14554. media: {
  14555. image: 'Image',
  14556. video: 'Vidéo',
  14557. audio: 'Audio',
  14558. embed: 'Intégré'
  14559. }
  14560. });
  14561. // CONCATENATED MODULE: ./languages/pt-br.js
  14562. /* harmony default export */ var pt_br = ({
  14563. base: {
  14564. remove: 'Remover',
  14565. cancel: 'Cancelar',
  14566. confirm: 'Confirmar',
  14567. inert: 'Inserir',
  14568. width: 'Largura',
  14569. height: 'Altura'
  14570. },
  14571. controls: {
  14572. clear: 'Limpar',
  14573. undo: 'Desfazer',
  14574. redo: 'Refazer',
  14575. fontSize: 'Tamanho da Fonte',
  14576. color: 'Cor',
  14577. textColor: 'Texto',
  14578. tempColors: 'Temp Colors',
  14579. backgroundColor: 'Cor de Fundo',
  14580. bold: 'Negrito',
  14581. lineHeight: 'Altura da LinhaLine Height',
  14582. letterSpacing: 'Espaçamento entre Letras',
  14583. textIndent: 'Identação de Texto',
  14584. increaseIndent: 'Aumentar Identação',
  14585. decreaseIndent: 'Diminuir Identção',
  14586. italic: 'Itálico',
  14587. underline: 'Sublinhado',
  14588. strikeThrough: 'Riscado',
  14589. fontFamily: 'Família da Fonte',
  14590. textAlign: 'Alinhamento de Texto',
  14591. alignLeft: 'Alinhamento à Esquerda',
  14592. alignCenter: 'Alinhamento Centralizado',
  14593. alignRight: 'Alinhamento à Direita',
  14594. alignJustify: 'Alinhamento Justificado',
  14595. floatLeft: 'Flutuação à Esquerda',
  14596. floatRight: 'Flutuação à Direita',
  14597. superScript: 'Sobrescrito',
  14598. subScript: 'Subscrito',
  14599. removeStyles: 'Remover Estilos',
  14600. headings: 'Cabeçalhos',
  14601. header: 'Cabeçalho',
  14602. normal: 'Normal',
  14603. orderedList: 'Lista Ordenada',
  14604. unorderedList: 'Lista Não Ordenada',
  14605. blockQuote: 'Citação',
  14606. code: 'Código',
  14607. link: 'Link',
  14608. unlink: 'Remover Link',
  14609. hr: 'Linha Horizontal',
  14610. media: 'Mídia',
  14611. mediaLibirary: 'Biblioteca de Mídia',
  14612. emoji: 'Emoji',
  14613. fullscreen: 'Tela Cheia',
  14614. exitFullscreen: 'Sair de Tela Cheia'
  14615. },
  14616. linkEditor: {
  14617. textInputPlaceHolder: 'Insira o texto do link',
  14618. linkInputPlaceHolder: 'Insira a URL do link',
  14619. inputWithEnterPlaceHolder: 'Insira a URL do link e aperte Enter',
  14620. openInNewWindow: 'Abrir em nova janela',
  14621. removeLink: 'Remover Link'
  14622. },
  14623. audioPlayer: {
  14624. title: 'Tocar Áudio'
  14625. },
  14626. videoPlayer: {
  14627. title: 'Tocar Vídeo',
  14628. embedTitle: 'Mídia Embutida'
  14629. },
  14630. media: {
  14631. image: 'Imagem',
  14632. video: 'Vídeo',
  14633. audio: 'Áudio',
  14634. embed: 'Embutido'
  14635. }
  14636. });
  14637. // CONCATENATED MODULE: ./languages/index.js
  14638. /* harmony default export */ var languages = ({
  14639. 'en': en,
  14640. 'zh': zh,
  14641. 'zh-hant': zh_hant,
  14642. 'pl': pl,
  14643. 'kr': kr,
  14644. 'tr': tr,
  14645. 'jpn': jpn,
  14646. 'ru': ru,
  14647. 'fr': fr,
  14648. 'pt-br': pt_br
  14649. });
  14650. // EXTERNAL MODULE: external "braft-finder"
  14651. var external_braft_finder_ = __webpack_require__(17);
  14652. var external_braft_finder_default = /*#__PURE__*/__webpack_require__.n(external_braft_finder_);
  14653. // EXTERNAL MODULE: external "braft-utils"
  14654. var external_braft_utils_ = __webpack_require__(3);
  14655. // EXTERNAL MODULE: external "draft-js"
  14656. var external_draft_js_ = __webpack_require__(6);
  14657. // EXTERNAL MODULE: external "immutable"
  14658. var external_immutable_ = __webpack_require__(13);
  14659. var external_immutable_default = /*#__PURE__*/__webpack_require__.n(external_immutable_);
  14660. // CONCATENATED MODULE: ./configs/keybindings.js
  14661. // TODO
  14662. // 允许自定义的快捷键设置
  14663. /* harmony default export */ var keybindings = (function (customKeyBindingFn) {
  14664. return function (event) {
  14665. if (event.keyCode === 83 && (external_draft_js_["KeyBindingUtil"].hasCommandModifier(event) || external_draft_js_["KeyBindingUtil"].isCtrlKeyCommand(event))) {
  14666. return 'braft-save';
  14667. }
  14668. if (customKeyBindingFn) {
  14669. return customKeyBindingFn(event) || Object(external_draft_js_["getDefaultKeyBinding"])(event);
  14670. }
  14671. return Object(external_draft_js_["getDefaultKeyBinding"])(event);
  14672. };
  14673. });
  14674. // CONCATENATED MODULE: ./configs/props.js
  14675. /* harmony default export */ var configs_props = ({
  14676. language: 'zh',
  14677. controls: ['undo', 'redo', 'separator', 'font-size', 'line-height', 'letter-spacing', 'separator', 'text-color', 'bold', 'italic', 'underline', 'strike-through', 'separator', 'superscript', 'subscript', 'remove-styles', 'emoji', 'separator', 'text-indent', 'text-align', 'separator', 'headings', 'list-ul', 'list-ol', 'blockquote', 'code', 'separator', 'media', 'link', 'table', 'split', 'hr', 'separator', 'clear', 'separator', 'fullscreen'],
  14678. excludeControls: [],
  14679. extendControls: [],
  14680. extendAtomics: [],
  14681. componentBelowControlBar: null,
  14682. media: {
  14683. pasteImage: true,
  14684. imagePasteLimit: 5,
  14685. image: true,
  14686. video: true,
  14687. audio: true,
  14688. uploadFn: null,
  14689. validateFn: null,
  14690. onBeforeDeselect: null,
  14691. onDeselect: null,
  14692. onBeforeSelect: null,
  14693. onSelect: null,
  14694. onBeforeRemove: null,
  14695. onRemove: null,
  14696. onCancel: null,
  14697. onFileSelect: null,
  14698. onBeforeInsert: null,
  14699. onInsert: null,
  14700. onChange: null,
  14701. accepts: {
  14702. image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
  14703. video: 'video/mp4',
  14704. audio: 'audio/mp3'
  14705. },
  14706. externals: {
  14707. audio: true,
  14708. video: true,
  14709. image: true,
  14710. embed: true
  14711. }
  14712. },
  14713. imageControls: ['float-left', 'float-right', 'align-left', 'align-center', 'align-right', 'link', 'size', 'remove'],
  14714. imageResizable: true,
  14715. colors: ['#000000', '#333333', '#666666', '#999999', '#cccccc', '#ffffff', '#61a951', '#16a085', '#07a9fe', '#003ba5', '#8e44ad', '#f32784', '#c0392b', '#d35400', '#f39c12', '#fdda00'],
  14716. colorPicker: null,
  14717. colorPickerTheme: 'dark',
  14718. colorPickerAutoHide: true,
  14719. codeTabIndents: 2,
  14720. headings: ['header-one', 'header-two', 'header-three', 'header-four', 'header-five', 'header-six', 'unstyled'],
  14721. textAligns: ['left', 'center', 'right', 'justify'],
  14722. textBackgroundColor: true,
  14723. allowInsertLinkText: false,
  14724. defaultLinkTarget: '',
  14725. letterSpacings: [0, 1, 2, 3, 4, 5, 6],
  14726. lineHeights: [1, 1.2, 1.5, 1.75, 2, 2.5, 3, 4],
  14727. fontSizes: [12, 14, 16, 18, 20, 24, 28, 30, 32, 36, 40, 48, 56, 64, 72, 96, 120, 144],
  14728. fontFamilies: [{
  14729. name: 'Araial',
  14730. family: 'Arial, Helvetica, sans-serif'
  14731. }, {
  14732. name: 'Georgia',
  14733. family: 'Georgia, serif'
  14734. }, {
  14735. name: 'Impact',
  14736. family: 'Impact, serif'
  14737. }, {
  14738. name: 'Monospace',
  14739. family: '"Courier New", Courier, monospace'
  14740. }, {
  14741. name: 'Tahoma',
  14742. family: 'tahoma, arial, "Hiragino Sans GB", 宋体, sans-serif'
  14743. }],
  14744. converts: {
  14745. unitExportFn: function unitExportFn(value, type) {
  14746. return type === 'line-height' ? value : "".concat(value, "px");
  14747. }
  14748. },
  14749. emojis: ['🤣', '🙌', '💚', '💛', '👏', '😉', '💯', '💕', '💞', '💘', '💙', '💝', '🖤', '💜', '❤️', '😍', '😻', '💓', '💗', '😋', '😇', '😂', '😹', '😘', '💖', '😁', '😀', '🤞', '😲', '😄', '😊', '👍', '😌', '😃', '😅', '✌️', '🤗', '💋', '😗', '😽', '😚', '🤠', '😙', '😺', '👄', '😸', '😏', '😼', '👌', '😎', '😆', '😛', '🙏', '🤝', '🙂', '🤑', '😝', '😐', '😑', '🤤', '😤', '🙃', '🤡', '😶', '😪', '😴', '😵', '😓', '👊', '😦', '😷', '🤐', '😜', '🤓', '👻', '😥', '🙄', '🤔', '🤒', '🙁', '😔', '😯', '☹️', '☠️', '😰', '😩', '😖', '😕', '😒', '😣', '😢', '😮', '😿', '🤧', '😫', '🤥', '😞', '😬', '👎', '💀', '😳', '😨', '🤕', '🤢', '😱', '😭', '😠', '😈', '😧', '💔', '😟', '🙀', '💩', '👿', '😡', '😾', '🖕'],
  14750. stripPastedStyles: false,
  14751. triggerChangeOnMount: true,
  14752. className: '',
  14753. style: {},
  14754. controlBarClassName: '',
  14755. controlBarStyle: {},
  14756. contentClassName: '',
  14757. contentStyle: {},
  14758. draftProps: {},
  14759. hooks: {},
  14760. onChange: null,
  14761. onFocus: null,
  14762. onBlur: null,
  14763. onTab: null,
  14764. onDelete: null,
  14765. onSave: null,
  14766. fixPlaceholder: false
  14767. });
  14768. // EXTERNAL MODULE: ../node_modules/draft-js/lib/getFragmentFromSelection.js
  14769. var getFragmentFromSelection = __webpack_require__(22);
  14770. var getFragmentFromSelection_default = /*#__PURE__*/__webpack_require__.n(getFragmentFromSelection);
  14771. // EXTERNAL MODULE: external "draftjs-utils"
  14772. var external_draftjs_utils_ = __webpack_require__(23);
  14773. // CONCATENATED MODULE: ./configs/handlers.js
  14774. var handlers_keyCommandHandlers = function keyCommandHandlers(command, editorState, editor) {
  14775. if (editor.editorProps.handleKeyCommand && editor.editorProps.handleKeyCommand(command, editorState, editor) === 'handled') {
  14776. return 'handled';
  14777. }
  14778. if (command === 'braft-save') {
  14779. editor.editorProps.onSave && editor.editorProps.onSave(editorState);
  14780. return 'handled';
  14781. }
  14782. var _editor$editorProps = editor.editorProps,
  14783. controls = _editor$editorProps.controls,
  14784. excludeControls = _editor$editorProps.excludeControls;
  14785. var allowIndent = (controls.indexOf('text-indent') !== 0 || controls.find(function (item) {
  14786. return item.key === 'text-indent';
  14787. })) && excludeControls.indexOf('text-indent') === -1;
  14788. var cursorStart = editorState.getSelection().getStartOffset();
  14789. var cursorEnd = editorState.getSelection().getEndOffset();
  14790. var cursorIsAtFirst = cursorStart === 0 && cursorEnd === 0;
  14791. if (command === 'backspace') {
  14792. if (editor.editorProps.onDelete && editor.editorProps.onDelete(editorState) === false) {
  14793. return 'handled';
  14794. }
  14795. var blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  14796. if (allowIndent && cursorIsAtFirst && blockType !== 'code-block') {
  14797. editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(editorState));
  14798. }
  14799. }
  14800. if (command === 'tab') {
  14801. var _blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  14802. if (_blockType === 'code-block') {
  14803. editor.setValue(external_braft_utils_["ContentUtils"].insertText(editorState, ' '.repeat(editor.editorProps.codeTabIndents)));
  14804. return 'handled';
  14805. } else if (_blockType === 'ordered-list-item' || _blockType === 'unordered-list-item') {
  14806. var newEditorState = external_draft_js_["RichUtils"].onTab(event, editorState, 4);
  14807. if (newEditorState !== editorState) {
  14808. editor.setValue(newEditorState);
  14809. }
  14810. return 'handled';
  14811. } else if (_blockType !== 'atomic' && allowIndent && cursorIsAtFirst) {
  14812. editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(editorState));
  14813. return 'handled';
  14814. }
  14815. }
  14816. var nextEditorState = external_braft_utils_["ContentUtils"].handleKeyCommand(editorState, command);
  14817. if (nextEditorState) {
  14818. editor.setValue(nextEditorState);
  14819. return 'handled';
  14820. }
  14821. return 'not-handled';
  14822. };
  14823. var handlers_returnHandlers = function returnHandlers(event, editorState, editor) {
  14824. if (editor.editorProps.handleReturn && editor.editorProps.handleReturn(event, editorState, editor) === 'handled') {
  14825. return 'handled';
  14826. }
  14827. var currentBlock = external_braft_utils_["ContentUtils"].getSelectionBlock(editorState);
  14828. var currentBlockType = currentBlock.getType();
  14829. if (currentBlockType === 'unordered-list-item' || currentBlockType === 'ordered-list-item') {
  14830. if (currentBlock.getLength() === 0) {
  14831. editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
  14832. return 'handled';
  14833. }
  14834. return 'not-handled';
  14835. } else if (currentBlockType === 'code-block') {
  14836. if (event.which === 13 && (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control'))) {
  14837. editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
  14838. return 'handled';
  14839. }
  14840. return 'not-handled';
  14841. } else if (currentBlockType === 'blockquote') {
  14842. if (event.which === 13) {
  14843. if (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control')) {
  14844. event.which = 0;
  14845. } else {
  14846. editor.setValue(external_draft_js_["RichUtils"].insertSoftNewline(editorState));
  14847. return 'handled';
  14848. }
  14849. }
  14850. }
  14851. var nextEditorState = Object(external_draftjs_utils_["handleNewLine"])(editorState, event);
  14852. if (nextEditorState) {
  14853. editor.setValue(nextEditorState);
  14854. return 'handled';
  14855. }
  14856. return 'not-handled';
  14857. };
  14858. var beforeInputHandlers = function beforeInputHandlers(chars, editorState, editor) {
  14859. if (editor.editorProps.handleBeforeInput && editor.editorProps.handleBeforeInput(chars, editorState, editor) === 'handled') {
  14860. return 'handled';
  14861. }
  14862. return 'not-handled';
  14863. };
  14864. var handlers_compositionStartHandler = function compositionStartHandler(_, editor) {
  14865. var editorState = editor.state.editorState;
  14866. var selectedBlocks = external_braft_utils_["ContentUtils"].getSelectedBlocks(editorState);
  14867. if (selectedBlocks && selectedBlocks.length > 1) {
  14868. var nextEditorState = external_draft_js_["EditorState"].push(editorState, external_draft_js_["Modifier"].removeRange(editorState.getCurrentContent(), editorState.getSelection(), 'backward'), 'remove-range');
  14869. editor.setValue(nextEditorState);
  14870. }
  14871. };
  14872. var handlers_dropHandlers = function dropHandlers(selectionState, dataTransfer, editor) {
  14873. if (editor.editorProps.readOnly || editor.editorProps.disabled) {
  14874. return 'handled';
  14875. }
  14876. if (window && window.__BRAFT_DRAGING__IMAGE__) {
  14877. var nextEditorState = external_draft_js_["EditorState"].forceSelection(editor.state.editorState, selectionState);
  14878. nextEditorState = external_braft_utils_["ContentUtils"].insertMedias(nextEditorState, [window.__BRAFT_DRAGING__IMAGE__.mediaData]);
  14879. nextEditorState = external_braft_utils_["ContentUtils"].removeBlock(nextEditorState, window.__BRAFT_DRAGING__IMAGE__.block, nextEditorState.getSelection());
  14880. window.__BRAFT_DRAGING__IMAGE__ = null;
  14881. editor.lockOrUnlockEditor(true);
  14882. editor.setValue(nextEditorState);
  14883. return 'handled';
  14884. } else if (!dataTransfer || !dataTransfer.getText()) {
  14885. return 'handled';
  14886. }
  14887. return 'not-handled';
  14888. };
  14889. var handlers_handleFiles = function handleFiles(files, editor) {
  14890. var _editor$constructor$d = objectSpread_default()({}, editor.constructor.defaultProps.media, editor.editorProps.media),
  14891. pasteImage = _editor$constructor$d.pasteImage,
  14892. validateFn = _editor$constructor$d.validateFn,
  14893. imagePasteLimit = _editor$constructor$d.imagePasteLimit;
  14894. pasteImage && files.slice(0, imagePasteLimit).forEach(function (file) {
  14895. if (file && file.type.indexOf('image') > -1 && editor.braftFinder) {
  14896. var validateResult = validateFn ? validateFn(file) : true;
  14897. if (validateResult instanceof Promise) {
  14898. validateResult.then(function () {
  14899. editor.braftFinder.uploadImage(file, function (image) {
  14900. editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
  14901. });
  14902. });
  14903. } else if (validateResult) {
  14904. editor.braftFinder.uploadImage(file, function (image) {
  14905. editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
  14906. });
  14907. }
  14908. }
  14909. });
  14910. if (files[0] && files[0].type.indexOf('image') > -1 && pasteImage) {
  14911. return 'handled';
  14912. }
  14913. return 'not-handled';
  14914. };
  14915. var droppedFilesHandlers = function droppedFilesHandlers(selectionState, files, editor) {
  14916. if (editor.editorProps.handleDroppedFiles && editor.editorProps.handleDroppedFiles(selectionState, files, editor) === 'handled') {
  14917. return 'handled';
  14918. }
  14919. return handlers_handleFiles(files, editor);
  14920. };
  14921. var pastedFilesHandlers = function pastedFilesHandlers(files, editor) {
  14922. if (editor.editorProps.handlePastedFiles && editor.editorProps.handlePastedFiles(files, editor) === 'handled') {
  14923. return 'handled';
  14924. }
  14925. return handlers_handleFiles(files, editor);
  14926. };
  14927. var handlers_copyHandlers = function copyHandlers(event, editor) {
  14928. var blockMap = getFragmentFromSelection_default()(editor.state.editorState);
  14929. if (blockMap && blockMap.toArray) {
  14930. try {
  14931. var tempContentState = external_draft_js_["ContentState"].createFromBlockArray(blockMap.toArray());
  14932. var tempEditorState = external_draft_js_["EditorState"].createWithContent(tempContentState);
  14933. var clipboardData = event.clipboardData || window.clipboardData || event.originalEvent.clipboardData;
  14934. tempEditorState.setConvertOptions(editor.state.editorState.convertOptions);
  14935. clipboardData.setData('text/html', tempEditorState.toHTML());
  14936. clipboardData.setData('text/plain', tempEditorState.toText());
  14937. event.preventDefault();
  14938. } catch (error) {
  14939. console.warn(error);
  14940. }
  14941. }
  14942. };
  14943. var handlers_pastedTextHandlers = function pastedTextHandlers(text, html, editorState, editor) {
  14944. if (editor.editorProps.handlePastedText && editor.editorProps.handlePastedText(text, html, editorState, editor) === 'handled') {
  14945. return 'handled';
  14946. }
  14947. if (!html || editor.editorProps.stripPastedStyles) {
  14948. return false;
  14949. }
  14950. var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromHTMLString(html);
  14951. editor.setState({
  14952. tempColors: toConsumableArray_default()(editor.state.tempColors).concat(toConsumableArray_default()(tempColors)).filter(function (item) {
  14953. return editor.editorProps.colors.indexOf(item) === -1;
  14954. }).filter(function (item, index, array) {
  14955. return array.indexOf(item) === index;
  14956. })
  14957. }, function () {
  14958. editor.setValue(external_braft_utils_["ContentUtils"].insertHTML(editorState, html, 'paste'));
  14959. });
  14960. return 'handled';
  14961. };
  14962. // CONCATENATED MODULE: ./helpers/extension.js
  14963. // TODO
  14964. // - block-style和atomic类型的扩展支持
  14965. var extension_extensionControls = [];
  14966. var extension_extensionDecorators = [];
  14967. var extension_propInterceptors = [];
  14968. var extension_extensionBlockRenderMaps = [];
  14969. var extension_extensionBlockRendererFns = [];
  14970. var extensionInlineStyleMaps = [];
  14971. var extension_extensionInlineStyleFns = [];
  14972. var extensionEntities = [];
  14973. var inlineStyleImporters = [];
  14974. var inlineStyleExporters = [];
  14975. var blockImporters = [];
  14976. var blockExporters = [];
  14977. var filterByEditorId = function filterByEditorId(items, editorId) {
  14978. if (!editorId) {
  14979. return items.filter(function (item) {
  14980. return !item.includeEditors;
  14981. }).map(function (item) {
  14982. return item.data;
  14983. });
  14984. }
  14985. return items.map(function (item) {
  14986. if (!item.includeEditors && !item.excludeEditors) {
  14987. return item.data;
  14988. }
  14989. if (item.includeEditors) {
  14990. return item.includeEditors.indexOf(editorId) !== -1 ? item.data : false;
  14991. }
  14992. if (item.excludeEditors) {
  14993. return item.excludeEditors.indexOf(editorId) !== -1 ? false : item.data;
  14994. }
  14995. return false;
  14996. }).filter(function (item) {
  14997. return item;
  14998. });
  14999. };
  15000. var getPropInterceptors = function getPropInterceptors(editorId) {
  15001. return filterByEditorId(extension_propInterceptors, editorId);
  15002. };
  15003. var getExtensionControls = function getExtensionControls(editorId) {
  15004. return filterByEditorId(extension_extensionControls, editorId);
  15005. };
  15006. var getExtensionDecorators = function getExtensionDecorators(editorId) {
  15007. return filterByEditorId(extension_extensionDecorators, editorId);
  15008. };
  15009. var getExtensionBlockRenderMaps = function getExtensionBlockRenderMaps(editorId) {
  15010. return filterByEditorId(extension_extensionBlockRenderMaps, editorId);
  15011. };
  15012. var getExtensionBlockRendererFns = function getExtensionBlockRendererFns(editorId) {
  15013. return filterByEditorId(extension_extensionBlockRendererFns, editorId);
  15014. };
  15015. var getExtensionInlineStyleMap = function getExtensionInlineStyleMap(editorId) {
  15016. var inlineStyleMap = {};
  15017. filterByEditorId(extensionInlineStyleMaps, editorId).forEach(function (item) {
  15018. inlineStyleMap[item.inlineStyleName] = item.styleMap;
  15019. });
  15020. return inlineStyleMap;
  15021. };
  15022. var getExtensionInlineStyleFns = function getExtensionInlineStyleFns(editorId) {
  15023. return filterByEditorId(extension_extensionInlineStyleFns, editorId);
  15024. };
  15025. var compositeStyleImportFn = function compositeStyleImportFn(styleImportFn, editorId) {
  15026. return function (nodeName, node, style) {
  15027. filterByEditorId(inlineStyleImporters, editorId).forEach(function (styleImporter) {
  15028. if (styleImporter.importer && styleImporter.importer(nodeName, node)) {
  15029. style = style.add(styleImporter.inlineStyleName);
  15030. }
  15031. });
  15032. return styleImportFn ? styleImportFn(nodeName, node, style) : style;
  15033. };
  15034. };
  15035. var compositeStyleExportFn = function compositeStyleExportFn(styleExportFn, editorId) {
  15036. return function (style) {
  15037. style = style.toUpperCase();
  15038. var result = styleExportFn ? styleExportFn(style) : undefined;
  15039. if (result) {
  15040. return result;
  15041. }
  15042. filterByEditorId(inlineStyleExporters, editorId).find(function (item) {
  15043. if (item.inlineStyleName === style) {
  15044. result = item.exporter;
  15045. return true;
  15046. }
  15047. });
  15048. return result;
  15049. };
  15050. };
  15051. var compositeEntityImportFn = function compositeEntityImportFn(entityImportFn, editorId) {
  15052. return function (nodeName, node, createEntity, source) {
  15053. var result = entityImportFn ? entityImportFn(nodeName, node, createEntity, source) : null;
  15054. if (result) {
  15055. return result;
  15056. }
  15057. filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
  15058. var matched = entityItem.importer ? entityItem.importer(nodeName, node, source) : null;
  15059. matched && (result = createEntity(entityItem.entityType, matched.mutability || 'MUTABLE', matched.data || {}));
  15060. return !!matched;
  15061. });
  15062. return result;
  15063. };
  15064. };
  15065. var compositeEntityExportFn = function compositeEntityExportFn(entityExportFn, editorId) {
  15066. return function (entity, originalText) {
  15067. var result = entityExportFn ? entityExportFn(entity, originalText) : undefined;
  15068. if (result) {
  15069. return result;
  15070. }
  15071. var entityType = entity.type.toUpperCase();
  15072. filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
  15073. if (entityItem.entityType === entityType) {
  15074. result = entityItem.exporter ? entityItem.exporter(entity, originalText) : undefined;
  15075. return true;
  15076. }
  15077. });
  15078. return result;
  15079. };
  15080. };
  15081. var compositeBlockImportFn = function compositeBlockImportFn(blockImportFn, editorId) {
  15082. return function (nodeName, node, source) {
  15083. var result = blockImportFn ? blockImportFn(nodeName, node, source) : null;
  15084. if (result) {
  15085. return result;
  15086. }
  15087. filterByEditorId(blockImporters, editorId).find(function (blockImporter) {
  15088. var matched = blockImporter.importer ? blockImporter.importer(nodeName, node, source) : undefined;
  15089. matched && (result = matched);
  15090. return !!matched;
  15091. });
  15092. return result;
  15093. };
  15094. };
  15095. var compositeBlockExportFn = function compositeBlockExportFn(blockExportFn, editorId) {
  15096. return function (contentState, block) {
  15097. var result = blockExportFn ? blockExportFn(contentState, block) : null;
  15098. if (result) {
  15099. return result;
  15100. }
  15101. filterByEditorId(blockExporters, editorId).find(function (blockExporter) {
  15102. var matched = blockExporter.exporter ? blockExporter.exporter(contentState, block) : undefined;
  15103. matched && (result = matched);
  15104. return !!matched;
  15105. });
  15106. return result;
  15107. };
  15108. };
  15109. var extension_useExtension = function useExtension(extension) {
  15110. if (extension instanceof Array) {
  15111. extension.forEach(useExtension);
  15112. return false;
  15113. }
  15114. if (!extension || !extension.type || typeof extension.type !== 'string') {
  15115. return false;
  15116. }
  15117. var includeEditors = extension.includeEditors,
  15118. excludeEditors = extension.excludeEditors;
  15119. if (extension.type === 'control') {
  15120. extension_extensionControls.push({
  15121. includeEditors: includeEditors,
  15122. excludeEditors: excludeEditors,
  15123. data: extension.control
  15124. });
  15125. } else if (extension.type === 'inline-style') {
  15126. var inlineStyleName = extension.name.toUpperCase();
  15127. if (extension.control) {
  15128. extension_extensionControls.push({
  15129. includeEditors: includeEditors,
  15130. excludeEditors: excludeEditors,
  15131. data: objectSpread_default()({
  15132. key: inlineStyleName,
  15133. type: 'inline-style',
  15134. command: inlineStyleName
  15135. }, extension.control)
  15136. });
  15137. }
  15138. if (extension.style) {
  15139. extensionInlineStyleMaps.push({
  15140. includeEditors: includeEditors,
  15141. excludeEditors: excludeEditors,
  15142. data: {
  15143. inlineStyleName: inlineStyleName,
  15144. styleMap: extension.style
  15145. }
  15146. });
  15147. }
  15148. if (extension.styleFn) {
  15149. extension_extensionInlineStyleFns.push({
  15150. includeEditors: includeEditors,
  15151. excludeEditors: excludeEditors,
  15152. data: {
  15153. inlineStyleName: inlineStyleName,
  15154. styleFn: extension.styleFn
  15155. }
  15156. });
  15157. }
  15158. if (extension.importer) {
  15159. inlineStyleImporters.push({
  15160. includeEditors: includeEditors,
  15161. excludeEditors: excludeEditors,
  15162. data: {
  15163. inlineStyleName: inlineStyleName,
  15164. importer: extension.importer
  15165. }
  15166. });
  15167. }
  15168. inlineStyleExporters.push({
  15169. includeEditors: includeEditors,
  15170. excludeEditors: excludeEditors,
  15171. data: {
  15172. inlineStyleName: inlineStyleName,
  15173. exporter: extension.exporter ? extension.exporter(extension) : external_react_default.a.createElement("span", {
  15174. style: extension.style
  15175. })
  15176. }
  15177. });
  15178. } else if (extension.type === 'block-style') ; else if (extension.type === 'entity') {
  15179. var entityType = extension.name.toUpperCase();
  15180. if (extension.control) {
  15181. extension_extensionControls.push({
  15182. includeEditors: includeEditors,
  15183. excludeEditors: excludeEditors,
  15184. data: typeof extension.control === 'function' ? extension.control : objectSpread_default()({
  15185. key: entityType,
  15186. type: 'entity',
  15187. command: entityType,
  15188. data: {
  15189. mutability: extension.mutability || 'MUTABLE',
  15190. data: extension.data || {}
  15191. }
  15192. }, extension.control)
  15193. });
  15194. }
  15195. extensionEntities.push({
  15196. includeEditors: includeEditors,
  15197. excludeEditors: excludeEditors,
  15198. data: {
  15199. entityType: entityType,
  15200. importer: extension.importer,
  15201. exporter: extension.exporter
  15202. }
  15203. });
  15204. extension_extensionDecorators.push({
  15205. includeEditors: includeEditors,
  15206. excludeEditors: excludeEditors,
  15207. data: {
  15208. type: 'entity',
  15209. decorator: {
  15210. key: entityType,
  15211. component: extension.component
  15212. }
  15213. }
  15214. });
  15215. } else if (extension.type === 'block') {
  15216. var blockType = extension.name;
  15217. if (extension.renderMap) {
  15218. extension_extensionBlockRenderMaps.push({
  15219. includeEditors: includeEditors,
  15220. excludeEditors: excludeEditors,
  15221. data: {
  15222. blockType: blockType,
  15223. renderMap: extension.renderMap
  15224. }
  15225. });
  15226. }
  15227. if (extension.rendererFn) {
  15228. extension_extensionBlockRendererFns.push({
  15229. includeEditors: includeEditors,
  15230. excludeEditors: excludeEditors,
  15231. data: {
  15232. blockType: blockType,
  15233. rendererFn: extension.rendererFn
  15234. }
  15235. });
  15236. }
  15237. if (extension.importer) {
  15238. blockImporters.push({
  15239. includeEditors: includeEditors,
  15240. excludeEditors: excludeEditors,
  15241. data: {
  15242. blockType: blockType,
  15243. importer: extension.importer
  15244. }
  15245. });
  15246. }
  15247. if (extension.exporter) {
  15248. blockExporters.push({
  15249. includeEditors: includeEditors,
  15250. excludeEditors: excludeEditors,
  15251. data: {
  15252. blockType: blockType,
  15253. exporter: extension.exporter
  15254. }
  15255. });
  15256. }
  15257. } else if (extension.type === 'atomic') ; else if (extension.type === 'decorator') {
  15258. var decorator = extension.decorator;
  15259. if (decorator && decorator.strategy && decorator.component) {
  15260. extension_extensionDecorators.push({
  15261. includeEditors: includeEditors,
  15262. excludeEditors: excludeEditors,
  15263. data: {
  15264. type: 'strategy',
  15265. decorator: decorator
  15266. }
  15267. });
  15268. } else if (decorator && decorator.getDecorations) {
  15269. extension_extensionDecorators.push({
  15270. includeEditors: includeEditors,
  15271. excludeEditors: excludeEditors,
  15272. data: {
  15273. type: 'class',
  15274. decorator: decorator
  15275. }
  15276. });
  15277. }
  15278. } else if (extension.type === 'prop-interception') {
  15279. extension_propInterceptors.push({
  15280. includeEditors: includeEditors,
  15281. excludeEditors: excludeEditors,
  15282. data: extension.interceptor
  15283. });
  15284. }
  15285. };
  15286. var createExtensibleEditor = function createExtensibleEditor(BraftEditor) {
  15287. BraftEditor.use = extension_useExtension;
  15288. return BraftEditor;
  15289. };
  15290. // CONCATENATED MODULE: ./renderers/block/blockRenderMap.js
  15291. /* harmony default export */ var block_blockRenderMap = (function (props, blockRenderMap) {
  15292. var customBlockRenderMap = Object(external_immutable_["Map"])({
  15293. 'atomic': {
  15294. element: ''
  15295. },
  15296. 'code-block': {
  15297. element: 'code',
  15298. wrapper: external_react_default.a.createElement("pre", {
  15299. className: "braft-code-block"
  15300. })
  15301. }
  15302. });
  15303. try {
  15304. var extensionBlockRenderMaps = getExtensionBlockRenderMaps(props.editorId);
  15305. customBlockRenderMap = extensionBlockRenderMaps.reduce(function (customBlockRenderMap, item) {
  15306. return customBlockRenderMap.merge(typeof item.renderMap === 'function' ? item.renderMap(props) : item.renderMap);
  15307. }, customBlockRenderMap);
  15308. if (blockRenderMap) {
  15309. if (typeof blockRenderMap === 'function') {
  15310. customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap(props));
  15311. } else {
  15312. customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap);
  15313. }
  15314. }
  15315. customBlockRenderMap = external_draft_js_["DefaultDraftBlockRenderMap"].merge(customBlockRenderMap);
  15316. } catch (error) {
  15317. console.warn(error);
  15318. }
  15319. return customBlockRenderMap;
  15320. });
  15321. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/extends.js
  15322. var helpers_extends = __webpack_require__(11);
  15323. var extends_default = /*#__PURE__*/__webpack_require__.n(helpers_extends);
  15324. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/slicedToArray.js
  15325. var slicedToArray = __webpack_require__(24);
  15326. var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
  15327. // EXTERNAL MODULE: ./renderers/atomics/Image/style.scss
  15328. var Image_style = __webpack_require__(45);
  15329. // EXTERNAL MODULE: ./components/common/Switch/style.scss
  15330. var Switch_style = __webpack_require__(46);
  15331. // CONCATENATED MODULE: ./components/common/Switch/index.jsx
  15332. /* harmony default export */ var Switch = (function (props) {
  15333. var active = props.active,
  15334. _onClick = props.onClick,
  15335. className = props.className;
  15336. return external_react_default.a.createElement("div", {
  15337. onClick: function onClick() {
  15338. return _onClick();
  15339. },
  15340. className: 'bf-switch ' + className + (active ? ' active' : '')
  15341. });
  15342. });
  15343. // CONCATENATED MODULE: ./configs/controls.js
  15344. /* harmony default export */ var configs_controls = (function (lang, editor) {
  15345. return [{
  15346. key: 'undo',
  15347. title: lang.controls.undo,
  15348. text: external_react_default.a.createElement("i", {
  15349. className: "bfi-undo"
  15350. }),
  15351. type: 'editor-method',
  15352. command: 'undo'
  15353. }, {
  15354. key: 'redo',
  15355. title: lang.controls.redo,
  15356. text: external_react_default.a.createElement("i", {
  15357. className: "bfi-redo"
  15358. }),
  15359. type: 'editor-method',
  15360. command: 'redo'
  15361. }, {
  15362. key: 'remove-styles',
  15363. title: lang.controls.removeStyles,
  15364. text: external_react_default.a.createElement("i", {
  15365. className: "bfi-format_clear"
  15366. }),
  15367. type: 'editor-method',
  15368. command: 'removeSelectionInlineStyles'
  15369. }, {
  15370. key: 'hr',
  15371. title: lang.controls.hr,
  15372. text: external_react_default.a.createElement("i", {
  15373. className: "bfi-hr"
  15374. }),
  15375. type: 'editor-method',
  15376. command: 'insertHorizontalLine'
  15377. }, {
  15378. key: 'bold',
  15379. title: lang.controls.bold,
  15380. text: external_react_default.a.createElement("i", {
  15381. className: "bfi-bold"
  15382. }),
  15383. type: 'inline-style',
  15384. command: 'bold'
  15385. }, {
  15386. key: 'italic',
  15387. title: lang.controls.italic,
  15388. text: external_react_default.a.createElement("i", {
  15389. className: "bfi-italic"
  15390. }),
  15391. type: 'inline-style',
  15392. command: 'italic'
  15393. }, {
  15394. key: 'underline',
  15395. title: lang.controls.underline,
  15396. text: external_react_default.a.createElement("i", {
  15397. className: "bfi-underlined"
  15398. }),
  15399. type: 'inline-style',
  15400. command: 'underline'
  15401. }, {
  15402. key: 'strike-through',
  15403. title: lang.controls.strikeThrough,
  15404. text: external_react_default.a.createElement("i", {
  15405. className: "bfi-strikethrough"
  15406. }),
  15407. type: 'inline-style',
  15408. command: 'strikethrough'
  15409. }, {
  15410. key: 'superscript',
  15411. title: lang.controls.superScript,
  15412. text: external_react_default.a.createElement("i", {
  15413. className: "bfi-superscript"
  15414. }),
  15415. type: 'inline-style',
  15416. command: 'superscript'
  15417. }, {
  15418. key: 'subscript',
  15419. title: lang.controls.subScript,
  15420. text: external_react_default.a.createElement("i", {
  15421. className: "bfi-subscript"
  15422. }),
  15423. type: 'inline-style',
  15424. command: 'subscript'
  15425. }, {
  15426. key: 'headings',
  15427. title: lang.controls.headings,
  15428. type: 'headings'
  15429. }, {
  15430. key: 'blockquote',
  15431. title: lang.controls.blockQuote,
  15432. text: external_react_default.a.createElement("i", {
  15433. className: "bfi-quote"
  15434. }),
  15435. type: 'block-type',
  15436. command: 'blockquote'
  15437. }, {
  15438. key: 'code',
  15439. title: lang.controls.code,
  15440. text: external_react_default.a.createElement("i", {
  15441. className: "bfi-code"
  15442. }),
  15443. type: 'block-type',
  15444. command: 'code-block'
  15445. }, {
  15446. key: 'list-ul',
  15447. title: lang.controls.unorderedList,
  15448. text: external_react_default.a.createElement("i", {
  15449. className: "bfi-list"
  15450. }),
  15451. type: 'block-type',
  15452. command: 'unordered-list-item'
  15453. }, {
  15454. key: 'list-ol',
  15455. title: lang.controls.orderedList,
  15456. text: external_react_default.a.createElement("i", {
  15457. className: "bfi-list-numbered"
  15458. }),
  15459. type: 'block-type',
  15460. command: 'ordered-list-item'
  15461. }, {
  15462. key: 'link',
  15463. title: lang.controls.link,
  15464. type: 'link'
  15465. }, {
  15466. key: 'text-color',
  15467. title: lang.controls.color,
  15468. type: 'text-color'
  15469. }, {
  15470. key: 'line-height',
  15471. title: lang.controls.lineHeight,
  15472. type: 'line-height'
  15473. }, {
  15474. key: 'letter-spacing',
  15475. title: lang.controls.letterSpacing,
  15476. type: 'letter-spacing'
  15477. }, {
  15478. key: 'text-indent',
  15479. title: lang.controls.textIndent,
  15480. type: 'text-indent'
  15481. }, {
  15482. key: 'font-size',
  15483. title: lang.controls.fontSize,
  15484. type: 'font-size'
  15485. }, {
  15486. key: 'font-family',
  15487. title: lang.controls.fontFamily,
  15488. type: 'font-family'
  15489. }, {
  15490. key: 'text-align',
  15491. title: lang.controls.textAlign,
  15492. type: 'text-align'
  15493. }, {
  15494. key: 'media',
  15495. title: lang.controls.media,
  15496. text: external_react_default.a.createElement("i", {
  15497. className: "bfi-media"
  15498. }),
  15499. type: 'media'
  15500. }, {
  15501. key: 'emoji',
  15502. title: lang.controls.emoji,
  15503. text: external_react_default.a.createElement("i", {
  15504. className: "bfi-emoji"
  15505. }),
  15506. type: 'emoji'
  15507. }, {
  15508. key: 'clear',
  15509. title: lang.controls.clear,
  15510. text: external_react_default.a.createElement("i", {
  15511. className: "bfi-clear_all"
  15512. }),
  15513. type: 'editor-method',
  15514. command: 'clearEditorContent'
  15515. }, {
  15516. key: 'fullscreen',
  15517. title: editor.state.isFullscreen ? lang.controls.exitFullscreen : lang.controls.fullscreen,
  15518. text: external_react_default.a.createElement("i", {
  15519. className: editor.state.isFullscreen ? 'bfi-fullscreen-exit' : 'bfi-fullscreen'
  15520. }),
  15521. type: 'editor-method',
  15522. command: 'toggleFullscreen'
  15523. }, {
  15524. key: 'modal',
  15525. type: 'modal'
  15526. }, {
  15527. key: 'button',
  15528. type: 'button'
  15529. }, {
  15530. key: 'dropdown',
  15531. type: 'dropdown'
  15532. }, {
  15533. key: 'component',
  15534. type: 'component'
  15535. }];
  15536. });
  15537. var imageControlItems = {
  15538. 'float-left': {
  15539. text: external_react_default.a.createElement("span", {
  15540. "data-float": "left"
  15541. }, "\uE91E"),
  15542. command: 'setImageFloat|left'
  15543. },
  15544. 'float-right': {
  15545. text: external_react_default.a.createElement("span", {
  15546. "data-float": "right"
  15547. }, "\uE914"),
  15548. command: 'setImageFloat|right'
  15549. },
  15550. 'align-left': {
  15551. text: external_react_default.a.createElement("span", {
  15552. "data-align": "left"
  15553. }, "\uE027"),
  15554. command: 'setImageAlignment|left'
  15555. },
  15556. 'align-center': {
  15557. text: external_react_default.a.createElement("span", {
  15558. "data-align": "center"
  15559. }, "\uE028"),
  15560. command: 'setImageAlignment|center'
  15561. },
  15562. 'align-right': {
  15563. text: external_react_default.a.createElement("span", {
  15564. "data-align": "right"
  15565. }, "\uE029"),
  15566. command: 'setImageAlignment|right'
  15567. },
  15568. 'size': {
  15569. text: external_react_default.a.createElement("span", null, "\uE3C2"),
  15570. command: 'toggleSizeEditor'
  15571. },
  15572. 'link': {
  15573. text: external_react_default.a.createElement("span", null, "\uE91A"),
  15574. command: 'toggleLinkEditor'
  15575. },
  15576. 'remove': {
  15577. text: external_react_default.a.createElement("span", null, "\uE9AC"),
  15578. command: 'removeImage'
  15579. }
  15580. };
  15581. // CONCATENATED MODULE: ./renderers/atomics/Image/index.jsx
  15582. var Image_Image =
  15583. /*#__PURE__*/
  15584. function (_React$Component) {
  15585. inherits_default()(Image, _React$Component);
  15586. function Image() {
  15587. var _getPrototypeOf2;
  15588. var _this;
  15589. classCallCheck_default()(this, Image);
  15590. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  15591. args[_key] = arguments[_key];
  15592. }
  15593. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Image)).call.apply(_getPrototypeOf2, [this].concat(args)));
  15594. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  15595. toolbarVisible: false,
  15596. toolbarOffset: 0,
  15597. linkEditorVisible: false,
  15598. sizeEditorVisible: false,
  15599. tempLink: null,
  15600. tempWidth: null,
  15601. tempHeight: null
  15602. });
  15603. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialLeft", void 0);
  15604. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialTop", void 0);
  15605. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialWidth", void 0);
  15606. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialHeight", void 0);
  15607. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "reSizeType", void 0);
  15608. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "changeSize", function (e) {
  15609. var type = _this.reSizeType;
  15610. if (!_this.initialLeft) {
  15611. _this.initialLeft = e.screenX;
  15612. _this.initialTop = e.screenY;
  15613. }
  15614. if (type === 'rightbottom') {
  15615. _this.initialHeight += e.screenY - _this.initialTop;
  15616. _this.initialWidth += e.screenX - _this.initialLeft;
  15617. }
  15618. if (type === 'leftbottom') {
  15619. _this.initialHeight += e.screenY - _this.initialTop;
  15620. _this.initialWidth += -e.screenX + _this.initialLeft;
  15621. }
  15622. _this.initialLeft = e.screenX;
  15623. _this.initialTop = e.screenY;
  15624. });
  15625. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "moveImage", function (e) {
  15626. _this.changeSize(e);
  15627. _this.setState({
  15628. tempWidth: Math.abs(_this.initialWidth),
  15629. tempHeight: Math.abs(_this.initialHeight)
  15630. });
  15631. });
  15632. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "upImage", function () {
  15633. _this.confirmImageSize();
  15634. document.removeEventListener('mousemove', _this.moveImage);
  15635. document.removeEventListener('mouseup', _this.upImage);
  15636. });
  15637. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "repareChangeSize", function (type) {
  15638. return function (e) {
  15639. _this.reSizeType = type;
  15640. var imageRect = _this.imageElement.getBoundingClientRect();
  15641. _this.initialLeft = _this.initialTop = 0;
  15642. _this.initialWidth = imageRect.width;
  15643. _this.initialHeight = imageRect.height;
  15644. e.preventDefault();
  15645. document.addEventListener('mousemove', _this.moveImage);
  15646. document.addEventListener('mouseup', _this.upImage);
  15647. };
  15648. });
  15649. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "preventDragEvent", function (event) {
  15650. event.stopPropagation();
  15651. event.preventDefault();
  15652. });
  15653. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragStart", function () {
  15654. if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
  15655. return false;
  15656. }
  15657. window.__BRAFT_DRAGING__IMAGE__ = {
  15658. block: _this.props.block,
  15659. mediaData: objectSpread_default()({
  15660. type: 'IMAGE'
  15661. }, _this.props.mediaData)
  15662. };
  15663. _this.setState({
  15664. toolbarVisible: false
  15665. }, function () {
  15666. _this.unlockEditor();
  15667. });
  15668. return true;
  15669. });
  15670. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragEnd", function () {
  15671. window.__BRAFT_DRAGING__IMAGE__ = null;
  15672. return false;
  15673. });
  15674. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "executeCommand", function (command) {
  15675. if (typeof command === 'string') {
  15676. var _command$split = command.split('|'),
  15677. _command$split2 = slicedToArray_default()(_command$split, 2),
  15678. method = _command$split2[0],
  15679. param = _command$split2[1];
  15680. _this[method] && _this[method](param);
  15681. } else if (typeof command === 'function') {
  15682. command(_this.props.block, _this.props.mediaData, _this.props.editor.getValue());
  15683. }
  15684. });
  15685. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeImage", function () {
  15686. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editor.getValue(), _this.props.block));
  15687. _this.unlockEditor();
  15688. });
  15689. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleLinkEditor", function () {
  15690. _this.setState({
  15691. linkEditorVisible: !_this.state.linkEditorVisible,
  15692. sizeEditorVisible: false
  15693. });
  15694. });
  15695. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleSizeEditor", function () {
  15696. _this.setState({
  15697. linkEditorVisible: false,
  15698. sizeEditorVisible: !_this.state.sizeEditorVisible
  15699. });
  15700. });
  15701. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleLinkInputKeyDown", function (e) {
  15702. if (e.keyCode === 13) {
  15703. _this.confirmImageLink();
  15704. } else {
  15705. return;
  15706. }
  15707. });
  15708. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageLink", function (e) {
  15709. _this.setState({
  15710. tempLink: e.currentTarget.value
  15711. });
  15712. return;
  15713. });
  15714. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageLink", function () {
  15715. var link = _this.state.tempLink;
  15716. var hookReturns = _this.props.hooks('set-image-link', link)(link);
  15717. if (hookReturns === false) {
  15718. return false;
  15719. }
  15720. if (typeof hookReturns === 'string') {
  15721. link = hookReturns;
  15722. }
  15723. if (link !== null) {
  15724. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, {
  15725. link: link
  15726. }));
  15727. window.setImmediate(_this.props.editor.forceRender);
  15728. }
  15729. });
  15730. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleSizeInputKeyDown", function (e) {
  15731. if (e.keyCode === 13) {
  15732. _this.confirmImageSize();
  15733. } else {
  15734. return;
  15735. }
  15736. });
  15737. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageWidth", function (_ref) {
  15738. var currentTarget = _ref.currentTarget;
  15739. var value = currentTarget.value;
  15740. value && !isNaN(value) && (value = value + 'px');
  15741. _this.setState({
  15742. tempWidth: value
  15743. });
  15744. return;
  15745. });
  15746. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageHeight", function (_ref2) {
  15747. var currentTarget = _ref2.currentTarget;
  15748. var value = currentTarget.value;
  15749. value && !isNaN(value) && (value = value + 'px');
  15750. _this.setState({
  15751. tempHeight: value
  15752. });
  15753. return;
  15754. });
  15755. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageSize", function () {
  15756. var _this$state = _this.state,
  15757. width = _this$state.tempWidth,
  15758. height = _this$state.tempHeight;
  15759. var newImageSize = {};
  15760. width !== null && (newImageSize.width = width);
  15761. height !== null && (newImageSize.height = height);
  15762. var hookReturns = _this.props.hooks('set-image-size', newImageSize)(newImageSize);
  15763. if (hookReturns === false) {
  15764. return false;
  15765. }
  15766. if (hookReturns && (hookReturns.width || hookReturns.height)) {
  15767. newImageSize = hookReturns;
  15768. }
  15769. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, newImageSize));
  15770. window.setImmediate(_this.props.editor.forceRender);
  15771. });
  15772. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageFloat", function (float) {
  15773. var hookReturns = _this.props.hooks('set-image-float', float)(float);
  15774. if (hookReturns === false) {
  15775. return false;
  15776. }
  15777. if (typeof hookReturns === 'string') {
  15778. float = hookReturns;
  15779. }
  15780. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
  15781. float: float
  15782. }));
  15783. _this.unlockEditor();
  15784. });
  15785. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageAlignment", function (alignment) {
  15786. var hookReturns = _this.props.hooks('set-image-alignment', alignment)(alignment);
  15787. if (hookReturns === false) {
  15788. return false;
  15789. }
  15790. if (typeof hookReturns === 'string') {
  15791. alignment = hookReturns;
  15792. }
  15793. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
  15794. alignment: alignment
  15795. }));
  15796. _this.unlockEditor();
  15797. });
  15798. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "showToolbar", function (event) {
  15799. if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
  15800. return false;
  15801. }
  15802. event.preventDefault();
  15803. if (!_this.state.toolbarVisible) {
  15804. _this.setState({
  15805. toolbarVisible: true
  15806. }, function () {
  15807. _this.lockEditor();
  15808. _this.setState({
  15809. toolbarOffset: _this.calcToolbarOffset()
  15810. });
  15811. });
  15812. }
  15813. });
  15814. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hideToolbar", function (event) {
  15815. event.preventDefault();
  15816. _this.setState({
  15817. toolbarVisible: false
  15818. }, function () {
  15819. _this.unlockEditor(); // this.props.editor.requestFocus()
  15820. });
  15821. });
  15822. return _this;
  15823. }
  15824. createClass_default()(Image, [{
  15825. key: "render",
  15826. value: function render() {
  15827. var _this2 = this;
  15828. var _this$props = this.props,
  15829. mediaData = _this$props.mediaData,
  15830. language = _this$props.language,
  15831. imageControls = _this$props.imageControls,
  15832. imageResizable = _this$props.imageResizable;
  15833. var _this$state2 = this.state,
  15834. toolbarVisible = _this$state2.toolbarVisible,
  15835. toolbarOffset = _this$state2.toolbarOffset,
  15836. linkEditorVisible = _this$state2.linkEditorVisible,
  15837. sizeEditorVisible = _this$state2.sizeEditorVisible,
  15838. tempWidth = _this$state2.tempWidth,
  15839. tempHeight = _this$state2.tempHeight;
  15840. var blockData = this.props.block.getData();
  15841. var float = blockData.get('float');
  15842. var alignment = blockData.get('alignment');
  15843. var url = mediaData.url,
  15844. link = mediaData.link,
  15845. link_target = mediaData.link_target,
  15846. width = mediaData.width,
  15847. height = mediaData.height,
  15848. meta = mediaData.meta;
  15849. var imageStyles = {};
  15850. var clearFix = false;
  15851. if (float) {
  15852. alignment = null;
  15853. } else if (alignment === 'left') {
  15854. imageStyles.float = 'left';
  15855. clearFix = true;
  15856. } else if (alignment === 'right') {
  15857. imageStyles.float = 'right';
  15858. clearFix = true;
  15859. } else if (alignment === 'center') {
  15860. imageStyles.textAlign = 'center';
  15861. } else {
  15862. imageStyles.float = 'left';
  15863. clearFix = true;
  15864. }
  15865. var renderedControlItems = imageControls.map(function (item, index) {
  15866. if (typeof item === 'string' && imageControlItems[item]) {
  15867. return external_react_default.a.createElement("a", {
  15868. className: item === 'link' && link ? 'active' : '',
  15869. key: index,
  15870. onClick: function onClick() {
  15871. return _this2.executeCommand(imageControlItems[item].command);
  15872. }
  15873. }, imageControlItems[item].text);
  15874. } else if (item && (item.render || item.text)) {
  15875. return item.render ? item.render(mediaData, _this2.props.block) : external_react_default.a.createElement("a", {
  15876. key: index,
  15877. onClick: function onClick() {
  15878. return item.onClick && _this2.executeCommand(item.onClick);
  15879. }
  15880. }, item.text);
  15881. } else {
  15882. return null;
  15883. }
  15884. });
  15885. return external_react_default.a.createElement("div", {
  15886. className: "bf-media"
  15887. }, external_react_default.a.createElement("div", {
  15888. style: imageStyles,
  15889. draggable: true,
  15890. onMouseEnter: this.showToolbar,
  15891. onMouseMove: this.showToolbar,
  15892. onMouseLeave: this.hideToolbar,
  15893. onDragStart: this.handleDragStart,
  15894. onDragEnd: this.handleDragEnd,
  15895. ref: function ref(instance) {
  15896. return _this2.mediaEmbederInstance = instance;
  15897. },
  15898. className: "bf-image"
  15899. }, toolbarVisible ? external_react_default.a.createElement("div", {
  15900. style: {
  15901. marginLeft: toolbarOffset
  15902. },
  15903. ref: function ref(instance) {
  15904. return _this2.toolbarElement = instance;
  15905. },
  15906. "data-float": float,
  15907. "data-align": alignment,
  15908. className: "bf-media-toolbar"
  15909. }, linkEditorVisible ? external_react_default.a.createElement("div", {
  15910. className: "bf-image-link-editor"
  15911. }, external_react_default.a.createElement("div", {
  15912. className: "editor-input-group"
  15913. }, external_react_default.a.createElement("input", {
  15914. type: "text",
  15915. placeholder: language.linkEditor.inputWithEnterPlaceHolder,
  15916. onKeyDown: this.handleLinkInputKeyDown,
  15917. onChange: this.setImageLink,
  15918. defaultValue: link
  15919. }), external_react_default.a.createElement("button", {
  15920. type: "button",
  15921. onClick: this.confirmImageLink
  15922. }, language.base.confirm)), external_react_default.a.createElement("div", {
  15923. className: "switch-group"
  15924. }, external_react_default.a.createElement(Switch, {
  15925. active: link_target === '_blank',
  15926. onClick: function onClick() {
  15927. return _this2.setImageLinkTarget(link_target);
  15928. }
  15929. }), external_react_default.a.createElement("label", null, language.linkEditor.openInNewWindow))) : null, sizeEditorVisible ? external_react_default.a.createElement("div", {
  15930. className: "bf-image-size-editor"
  15931. }, external_react_default.a.createElement("div", {
  15932. className: "editor-input-group"
  15933. }, external_react_default.a.createElement("input", {
  15934. type: "text",
  15935. placeholder: language.base.width,
  15936. onKeyDown: this.handleSizeInputKeyDown,
  15937. onChange: this.setImageWidth,
  15938. defaultValue: width
  15939. }), external_react_default.a.createElement("input", {
  15940. type: "text",
  15941. placeholder: language.base.height,
  15942. onKeyDown: this.handleSizeInputKeyDown,
  15943. onChange: this.setImageHeight,
  15944. defaultValue: height
  15945. }), external_react_default.a.createElement("button", {
  15946. type: "button",
  15947. onClick: this.confirmImageSize
  15948. }, language.base.confirm))) : null, renderedControlItems, external_react_default.a.createElement("i", {
  15949. style: {
  15950. marginLeft: toolbarOffset * -1
  15951. },
  15952. className: "bf-media-toolbar-arrow"
  15953. })) : null, external_react_default.a.createElement("div", {
  15954. style: {
  15955. position: 'relative',
  15956. width: "".concat(width, "px"),
  15957. height: "".concat(height, "px"),
  15958. display: 'inline-block'
  15959. }
  15960. }, external_react_default.a.createElement("img", extends_default()({
  15961. ref: function ref(instance) {
  15962. return _this2.imageElement = instance;
  15963. },
  15964. src: url,
  15965. width: width,
  15966. height: height
  15967. }, meta)), toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
  15968. className: "bf-csize-icon right-bottom",
  15969. onMouseDown: this.repareChangeSize('rightbottom')
  15970. }) : null, toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
  15971. className: "bf-csize-icon left-bottom",
  15972. onMouseDown: this.repareChangeSize('leftbottom')
  15973. }) : null, external_react_default.a.createElement("div", {
  15974. className: "bf-pre-csize ".concat(this.reSizeType),
  15975. style: {
  15976. width: "".concat(tempWidth, "px"),
  15977. height: "".concat(tempHeight, "px")
  15978. }
  15979. }))), clearFix && external_react_default.a.createElement("div", {
  15980. className: "clearfix",
  15981. style: {
  15982. clear: 'both',
  15983. height: 0,
  15984. lineHeight: 0,
  15985. float: 'none'
  15986. }
  15987. }));
  15988. }
  15989. }, {
  15990. key: "lockEditor",
  15991. value: function lockEditor() {
  15992. this.props.editor.lockOrUnlockEditor(true);
  15993. }
  15994. }, {
  15995. key: "unlockEditor",
  15996. value: function unlockEditor() {
  15997. this.props.editor.lockOrUnlockEditor(false);
  15998. }
  15999. }, {
  16000. key: "calcToolbarOffset",
  16001. value: function calcToolbarOffset() {
  16002. var _this$props2 = this.props,
  16003. getContainerNode = _this$props2.getContainerNode,
  16004. containerNode = _this$props2.containerNode;
  16005. var container = getContainerNode ? getContainerNode() : containerNode;
  16006. if (!container) {
  16007. return 0;
  16008. }
  16009. var viewRect = container.querySelector('.bf-content').getBoundingClientRect();
  16010. var toolbarRect = this.toolbarElement.getBoundingClientRect();
  16011. var imageRect = this.imageElement.getBoundingClientRect();
  16012. var right = viewRect.right - (imageRect.right - imageRect.width / 2 + toolbarRect.width / 2);
  16013. var left = imageRect.left + imageRect.width / 2 - toolbarRect.width / 2 - viewRect.left;
  16014. if (right < 10) {
  16015. return right - 10;
  16016. } else if (left < 10) {
  16017. return left * -1 + 10;
  16018. } else {
  16019. return 0;
  16020. }
  16021. }
  16022. }, {
  16023. key: "setImageLinkTarget",
  16024. value: function setImageLinkTarget(link_target) {
  16025. var hookReturns = this.props.hooks('set-image-link-target', link_target)(link_target);
  16026. if (hookReturns === false) {
  16027. return false;
  16028. }
  16029. if (typeof hookReturns === 'string') {
  16030. link_target = hookReturns;
  16031. }
  16032. link_target = link_target === '_blank' ? '' : '_blank';
  16033. this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(this.props.editor.getValue(), this.props.entityKey, {
  16034. link_target: link_target
  16035. }));
  16036. window.setImmediate(this.props.editor.forceRender);
  16037. }
  16038. }]);
  16039. return Image;
  16040. }(external_react_default.a.Component);
  16041. // EXTERNAL MODULE: ./renderers/atomics/Video/style.scss
  16042. var Video_style = __webpack_require__(47);
  16043. // EXTERNAL MODULE: ./components/common/Modal/style.scss
  16044. var Modal_style = __webpack_require__(48);
  16045. // EXTERNAL MODULE: external "react-dom"
  16046. var external_react_dom_ = __webpack_require__(16);
  16047. var external_react_dom_default = /*#__PURE__*/__webpack_require__.n(external_react_dom_);
  16048. // CONCATENATED MODULE: ./components/common/Modal/index.jsx
  16049. var Modal_Modal =
  16050. /*#__PURE__*/
  16051. function (_React$Component) {
  16052. inherits_default()(Modal, _React$Component);
  16053. function Modal(props) {
  16054. var _this;
  16055. classCallCheck_default()(this, Modal);
  16056. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(Modal).call(this, props));
  16057. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTransitionEnd", function () {
  16058. if (!_this.rootElement || !_this.rootElement.classList) {
  16059. return false;
  16060. }
  16061. if (!_this.rootElement.classList.contains('active')) {
  16062. external_react_dom_default.a.unmountComponentAtNode(_this.rootElement) && _this.rootElement.parentNode.removeChild(_this.rootElement);
  16063. }
  16064. });
  16065. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMouseDown", function (event) {
  16066. var tagName = event.target.tagName.toLowerCase();
  16067. if (tagName === 'input' || tagName === 'textarea') {
  16068. return false;
  16069. }
  16070. event.preventDefault();
  16071. });
  16072. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
  16073. _this.props.closeOnCancel && _this.close();
  16074. _this.props.onCancel && _this.props.onCancel();
  16075. });
  16076. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
  16077. _this.props.closeOnConfirm && _this.close();
  16078. _this.props.onConfirm && _this.props.onConfirm();
  16079. });
  16080. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMaskClick", function () {
  16081. _this.props.closeOnBlur && _this.close();
  16082. _this.props.onBlue && _this.props.onBlue();
  16083. });
  16084. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "close", function () {
  16085. _this.unrenderComponent();
  16086. _this.props.onClose && _this.props.onClose();
  16087. });
  16088. _this.active = false;
  16089. _this.componentId = 'BRAFT-MODAL-' + external_braft_utils_["BaseUtils"].UniqueIndex();
  16090. return _this;
  16091. }
  16092. createClass_default()(Modal, [{
  16093. key: "componentDidMount",
  16094. value: function componentDidMount() {
  16095. if (this.props.visible) {
  16096. this.active = true;
  16097. this.renderComponent(this.props);
  16098. }
  16099. }
  16100. }, {
  16101. key: "componentWillReceiveProps",
  16102. value: function componentWillReceiveProps(next) {
  16103. if (this.props.visible && !next.visible) {
  16104. this.unrenderComponent();
  16105. } else if (this.props.visible || next.visible) {
  16106. this.active = true;
  16107. this.renderComponent(next);
  16108. }
  16109. }
  16110. }, {
  16111. key: "render",
  16112. value: function render() {
  16113. return null;
  16114. }
  16115. }, {
  16116. key: "unrenderComponent",
  16117. value: function unrenderComponent() {
  16118. this.active = false;
  16119. this.activeId && window.clearImmediate(this.activeId);
  16120. if (this.rootElement && this.rootElement.classList) {
  16121. this.rootElement.classList.remove('active');
  16122. }
  16123. }
  16124. }, {
  16125. key: "renderComponent",
  16126. value: function renderComponent(props) {
  16127. var _this2 = this;
  16128. if (!this.active) {
  16129. return false;
  16130. }
  16131. var title = props.title,
  16132. className = props.className,
  16133. width = props.width,
  16134. height = props.height,
  16135. children = props.children,
  16136. component = props.component,
  16137. confirmable = props.confirmable,
  16138. showFooter = props.showFooter,
  16139. showCancel = props.showCancel,
  16140. showConfirm = props.showConfirm,
  16141. showClose = props.showClose,
  16142. cancelText = props.cancelText,
  16143. confirmText = props.confirmText,
  16144. bottomText = props.bottomText,
  16145. language = props.language;
  16146. typeof showCancel === 'undefined' && (showCancel = true);
  16147. typeof showClose === 'undefined' && (showClose = true);
  16148. typeof showConfirm === 'undefined' && (showConfirm = true);
  16149. typeof showFooter === 'undefined' && (showFooter = true);
  16150. var childComponent = external_react_default.a.createElement("div", {
  16151. onMouseDown: this.handleMouseDown,
  16152. className: 'bf-modal ' + (className || '')
  16153. }, external_react_default.a.createElement("div", {
  16154. className: "bf-modal-mask",
  16155. onClick: this.handleMaskClick
  16156. }), external_react_default.a.createElement("div", {
  16157. onTransitionEnd: this.handleTransitionEnd,
  16158. style: {
  16159. width: width,
  16160. height: height
  16161. },
  16162. className: "bf-modal-content"
  16163. }, external_react_default.a.createElement("div", {
  16164. className: "bf-modal-header"
  16165. }, external_react_default.a.createElement("h3", {
  16166. className: "bf-modal-caption"
  16167. }, title), showClose && external_react_default.a.createElement("button", {
  16168. type: "button",
  16169. onClick: this.close,
  16170. className: "bf-modal-close-button"
  16171. }, external_react_default.a.createElement("i", {
  16172. className: "bfi-close"
  16173. }))), external_react_default.a.createElement("div", {
  16174. className: "bf-modal-body"
  16175. }, children || component), showFooter ? external_react_default.a.createElement("div", {
  16176. className: "bf-modal-footer"
  16177. }, external_react_default.a.createElement("div", {
  16178. className: "bf-modal-addon-text"
  16179. }, bottomText), external_react_default.a.createElement("div", {
  16180. className: "bf-modal-buttons"
  16181. }, showCancel && external_react_default.a.createElement("button", {
  16182. type: "button",
  16183. onClick: this.handleCancel,
  16184. className: "bf-modal-cancel"
  16185. }, cancelText || language.base.cancel), showConfirm && external_react_default.a.createElement("button", {
  16186. type: "button",
  16187. onClick: this.handleConfirm,
  16188. className: 'bf-modal-confirm ' + (!confirmable ? 'disabled' : '')
  16189. }, confirmText || language.base.confirm))) : null));
  16190. this.rootElement = document.querySelector('#' + this.componentId);
  16191. if (!this.rootElement) {
  16192. this.rootElement = document.createElement('div');
  16193. this.rootElement.id = this.componentId;
  16194. this.rootElement.className = 'bf-modal-root';
  16195. document.body.appendChild(this.rootElement);
  16196. }
  16197. external_react_dom_default.a.render(childComponent, this.rootElement);
  16198. this.activeId = window.setImmediate(function () {
  16199. _this2.rootElement.classList.add('active');
  16200. });
  16201. }
  16202. }]);
  16203. return Modal;
  16204. }(external_react_default.a.Component);
  16205. defineProperty_default()(Modal_Modal, "defaultProps", {
  16206. showFooter: true,
  16207. closeOnBlur: true
  16208. });
  16209. var Modal_showModal = function showModal(props) {
  16210. var hostNode = document.createElement('div');
  16211. hostNode.style.display = 'none';
  16212. document.body.appendChild(hostNode);
  16213. props = objectSpread_default()({
  16214. visible: true,
  16215. closeOnConfirm: true,
  16216. closeOnCancel: true
  16217. }, props);
  16218. var close = function close() {
  16219. external_react_dom_default.a.unmountComponentAtNode(hostNode) && hostNode.parentNode.removeChild(hostNode);
  16220. };
  16221. var onConfirm = function onConfirm() {
  16222. props.onConfirm && props.onConfirm();
  16223. };
  16224. var onCancel = function onCancel() {
  16225. props.onCancel && props.onCancel();
  16226. };
  16227. var onClose = function onClose() {
  16228. close();
  16229. props.onClose && props.onClose();
  16230. };
  16231. var modalInstance = external_react_dom_default.a.render(external_react_default.a.createElement(Modal_Modal, extends_default()({}, props, {
  16232. onConfirm: onConfirm,
  16233. onCancel: onCancel,
  16234. onClose: onClose
  16235. })), hostNode);
  16236. modalInstance.destroy = close;
  16237. modalInstance.update = modalInstance.renderComponent;
  16238. return modalInstance;
  16239. };
  16240. // EXTERNAL MODULE: ./components/business/PlayerModal/style.scss
  16241. var PlayerModal_style = __webpack_require__(49);
  16242. // CONCATENATED MODULE: ./components/business/PlayerModal/index.jsx
  16243. var PlayerModal_playViaModal = function playViaModal(title, component, language) {
  16244. return Modal_showModal({
  16245. title: title,
  16246. component: component,
  16247. language: language,
  16248. showFooter: false
  16249. });
  16250. };
  16251. var typeIconsMap = {
  16252. 'video': 'bfi-film',
  16253. 'audio': 'bfi-music',
  16254. 'embed': 'bfi-code'
  16255. };
  16256. /* harmony default export */ var PlayerModal = (function (_ref) {
  16257. var title = _ref.title,
  16258. type = _ref.type,
  16259. language = _ref.language,
  16260. name = _ref.name,
  16261. url = _ref.url,
  16262. poster = _ref.poster,
  16263. children = _ref.children,
  16264. onRemove = _ref.onRemove;
  16265. return external_react_default.a.createElement("div", {
  16266. className: "bf-player-holder ".concat(type)
  16267. }, external_react_default.a.createElement("div", {
  16268. className: "icon-badge"
  16269. }, external_react_default.a.createElement("i", {
  16270. className: typeIconsMap[type]
  16271. }), external_react_default.a.createElement("span", {
  16272. className: "text"
  16273. }, language.media[type])), external_react_default.a.createElement("button", {
  16274. onMouseDown: onRemove,
  16275. className: "button-remove"
  16276. }, external_react_default.a.createElement("i", {
  16277. className: "bfi-close"
  16278. })), external_react_default.a.createElement("button", {
  16279. onMouseDown: function onMouseDown() {
  16280. return PlayerModal_playViaModal(name ? "".concat(title, ":").concat(name) : title, children, language);
  16281. },
  16282. className: "button-play"
  16283. }, external_react_default.a.createElement("i", {
  16284. className: "bfi-play_arrow"
  16285. })), name ? external_react_default.a.createElement("h5", {
  16286. className: "bf-name"
  16287. }, name) : null, external_react_default.a.createElement("h6", {
  16288. className: "bf-url"
  16289. }, url), poster ? external_react_default.a.createElement("div", {
  16290. className: "bf-poster",
  16291. style: {
  16292. backgroundImage: "url(".concat(poster, ")")
  16293. }
  16294. }) : null);
  16295. });
  16296. // CONCATENATED MODULE: ./renderers/atomics/Video/index.jsx
  16297. var Video_Video =
  16298. /*#__PURE__*/
  16299. function (_React$Component) {
  16300. inherits_default()(Video, _React$Component);
  16301. function Video() {
  16302. var _getPrototypeOf2;
  16303. var _this;
  16304. classCallCheck_default()(this, Video);
  16305. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  16306. args[_key] = arguments[_key];
  16307. }
  16308. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Video)).call.apply(_getPrototypeOf2, [this].concat(args)));
  16309. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeVideo", function () {
  16310. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  16311. });
  16312. return _this;
  16313. }
  16314. createClass_default()(Video, [{
  16315. key: "render",
  16316. value: function render() {
  16317. var _this$props = this.props,
  16318. mediaData = _this$props.mediaData,
  16319. language = _this$props.language;
  16320. var url = mediaData.url,
  16321. name = mediaData.name,
  16322. meta = mediaData.meta;
  16323. return external_react_default.a.createElement("div", {
  16324. className: "bf-video-wrap"
  16325. }, external_react_default.a.createElement(PlayerModal, {
  16326. type: "video",
  16327. onRemove: this.removeVideo,
  16328. poster: meta ? meta.poster || '' : '',
  16329. language: language,
  16330. url: url,
  16331. name: name,
  16332. title: language.videoPlayer.title
  16333. }, external_react_default.a.createElement("div", {
  16334. className: "bf-video-player"
  16335. }, external_react_default.a.createElement("video", {
  16336. controls: true,
  16337. poster: meta ? meta.poster || '' : ''
  16338. }, external_react_default.a.createElement("source", {
  16339. src: url
  16340. })))));
  16341. }
  16342. }]);
  16343. return Video;
  16344. }(external_react_default.a.Component);
  16345. // EXTERNAL MODULE: ./renderers/atomics/Audio/style.scss
  16346. var Audio_style = __webpack_require__(50);
  16347. // CONCATENATED MODULE: ./renderers/atomics/Audio/index.jsx
  16348. var Audio_Audio =
  16349. /*#__PURE__*/
  16350. function (_React$Component) {
  16351. inherits_default()(Audio, _React$Component);
  16352. function Audio() {
  16353. var _getPrototypeOf2;
  16354. var _this;
  16355. classCallCheck_default()(this, Audio);
  16356. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  16357. args[_key] = arguments[_key];
  16358. }
  16359. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Audio)).call.apply(_getPrototypeOf2, [this].concat(args)));
  16360. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeAudio", function () {
  16361. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  16362. });
  16363. return _this;
  16364. }
  16365. createClass_default()(Audio, [{
  16366. key: "render",
  16367. value: function render() {
  16368. var _this$props = this.props,
  16369. mediaData = _this$props.mediaData,
  16370. language = _this$props.language;
  16371. var url = mediaData.url,
  16372. name = mediaData.name,
  16373. meta = mediaData.meta;
  16374. return external_react_default.a.createElement("div", {
  16375. className: "bf-audio-wrap"
  16376. }, external_react_default.a.createElement(PlayerModal, {
  16377. type: "audio",
  16378. onRemove: this.removeAudio,
  16379. poster: meta ? meta.poster || '' : '',
  16380. language: language,
  16381. url: url,
  16382. name: name,
  16383. title: language.audioPlayer.title
  16384. }, external_react_default.a.createElement("div", {
  16385. className: "bf-audio-player"
  16386. }, external_react_default.a.createElement("audio", {
  16387. controls: true,
  16388. src: url
  16389. }))));
  16390. }
  16391. }]);
  16392. return Audio;
  16393. }(external_react_default.a.Component);
  16394. // EXTERNAL MODULE: ./renderers/atomics/Embed/style.scss
  16395. var Embed_style = __webpack_require__(51);
  16396. // CONCATENATED MODULE: ./renderers/atomics/Embed/index.jsx
  16397. var Embed_Embed =
  16398. /*#__PURE__*/
  16399. function (_React$Component) {
  16400. inherits_default()(Embed, _React$Component);
  16401. function Embed() {
  16402. var _getPrototypeOf2;
  16403. var _this;
  16404. classCallCheck_default()(this, Embed);
  16405. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  16406. args[_key] = arguments[_key];
  16407. }
  16408. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Embed)).call.apply(_getPrototypeOf2, [this].concat(args)));
  16409. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeEmbed", function () {
  16410. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  16411. });
  16412. return _this;
  16413. }
  16414. createClass_default()(Embed, [{
  16415. key: "render",
  16416. value: function render() {
  16417. var _this$props = this.props,
  16418. mediaData = _this$props.mediaData,
  16419. language = _this$props.language;
  16420. var name = mediaData.name,
  16421. url = mediaData.url,
  16422. meta = mediaData.meta;
  16423. return external_react_default.a.createElement("div", {
  16424. className: "bf-embed-wrap"
  16425. }, external_react_default.a.createElement(PlayerModal, {
  16426. type: "embed",
  16427. onRemove: this.removeEmbed,
  16428. poster: meta ? meta.poster || '' : '',
  16429. language: language,
  16430. url: url,
  16431. name: name,
  16432. title: language.videoPlayer.embedTitle
  16433. }, external_react_default.a.createElement("div", {
  16434. className: "bf-embed-player",
  16435. dangerouslySetInnerHTML: {
  16436. __html: url
  16437. }
  16438. })));
  16439. }
  16440. }]);
  16441. return Embed;
  16442. }(external_react_default.a.Component);
  16443. // EXTERNAL MODULE: ./renderers/atomics/HorizontalLine/style.scss
  16444. var HorizontalLine_style = __webpack_require__(52);
  16445. // CONCATENATED MODULE: ./renderers/atomics/HorizontalLine/index.jsx
  16446. var HorizontalLine_HorizontalLine =
  16447. /*#__PURE__*/
  16448. function (_React$Component) {
  16449. inherits_default()(HorizontalLine, _React$Component);
  16450. function HorizontalLine() {
  16451. var _getPrototypeOf2;
  16452. var _this;
  16453. classCallCheck_default()(this, HorizontalLine);
  16454. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  16455. args[_key] = arguments[_key];
  16456. }
  16457. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(HorizontalLine)).call.apply(_getPrototypeOf2, [this].concat(args)));
  16458. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeHorizontalLine", function () {
  16459. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  16460. });
  16461. return _this;
  16462. }
  16463. createClass_default()(HorizontalLine, [{
  16464. key: "render",
  16465. value: function render() {
  16466. return external_react_default.a.createElement("div", {
  16467. className: "bf-hr"
  16468. }, external_react_default.a.createElement("div", {
  16469. className: "bf-media-toolbar"
  16470. }, external_react_default.a.createElement("a", {
  16471. onClick: this.removeHorizontalLine
  16472. }, "\uE9AC")));
  16473. }
  16474. }]);
  16475. return HorizontalLine;
  16476. }(external_react_default.a.Component);
  16477. // CONCATENATED MODULE: ./renderers/block/blockRendererFn.js
  16478. var blockRendererFn_BlockRenderFnContext = function BlockRenderFnContext() {
  16479. var _this = this;
  16480. classCallCheck_default()(this, BlockRenderFnContext);
  16481. defineProperty_default()(this, "superProps", void 0);
  16482. defineProperty_default()(this, "customBlockRendererFn", void 0);
  16483. defineProperty_default()(this, "getRenderFn", function (superProps, customBlockRendererFn) {
  16484. _this.superProps = superProps;
  16485. _this.customBlockRendererFn = customBlockRendererFn;
  16486. return _this.blockRendererFn;
  16487. });
  16488. defineProperty_default()(this, "renderAtomicBlock", function (props) {
  16489. var superProps = _this.superProps;
  16490. var entityKey = props.block.getEntityAt(0);
  16491. if (!entityKey) {
  16492. return null;
  16493. }
  16494. var entity = props.contentState.getEntity(entityKey);
  16495. var mediaData = entity.getData();
  16496. var mediaType = entity.getType();
  16497. var mediaProps = objectSpread_default()({}, superProps, {
  16498. block: props.block,
  16499. mediaData: mediaData,
  16500. entityKey: entityKey
  16501. });
  16502. if (mediaType === 'IMAGE') {
  16503. return external_react_default.a.createElement(Image_Image, mediaProps);
  16504. } else if (mediaType === 'AUDIO') {
  16505. return external_react_default.a.createElement(Audio_Audio, mediaProps);
  16506. } else if (mediaType === 'VIDEO') {
  16507. return external_react_default.a.createElement(Video_Video, mediaProps);
  16508. } else if (mediaType === 'EMBED') {
  16509. return external_react_default.a.createElement(Embed_Embed, mediaProps);
  16510. } else if (mediaType === 'HR') {
  16511. return external_react_default.a.createElement(HorizontalLine_HorizontalLine, mediaProps);
  16512. }
  16513. if (superProps.extendAtomics) {
  16514. var atomics = superProps.extendAtomics;
  16515. for (var i = 0; i < atomics.length; i++) {
  16516. if (mediaType === atomics[i].type) {
  16517. var Component = atomics[i].component;
  16518. return external_react_default.a.createElement(Component, mediaProps);
  16519. }
  16520. }
  16521. }
  16522. return null;
  16523. });
  16524. defineProperty_default()(this, "blockRendererFn", function (block) {
  16525. var customBlockRendererFn = _this.customBlockRendererFn,
  16526. superProps = _this.superProps;
  16527. var blockType = block.getType();
  16528. var blockRenderer = null;
  16529. if (customBlockRendererFn) {
  16530. blockRenderer = customBlockRendererFn(block, superProps) || null;
  16531. }
  16532. if (blockRenderer) {
  16533. return blockRenderer;
  16534. }
  16535. var extensionBlockRendererFns = getExtensionBlockRendererFns(superProps.editorId);
  16536. extensionBlockRendererFns.find(function (item) {
  16537. if (item.blockType === blockType || item.blockType instanceof RegExp && item.blockType.test(blockType)) {
  16538. blockRenderer = item.rendererFn ? item.rendererFn(superProps) : null;
  16539. return true;
  16540. }
  16541. });
  16542. if (blockRenderer) {
  16543. return blockRenderer;
  16544. }
  16545. if (blockType === 'atomic') {
  16546. blockRenderer = {
  16547. component: _this.renderAtomicBlock,
  16548. editable: false
  16549. };
  16550. }
  16551. return blockRenderer;
  16552. });
  16553. };
  16554. var blockRenderFnContext = new blockRendererFn_BlockRenderFnContext();
  16555. /* harmony default export */ var block_blockRendererFn = (blockRenderFnContext.getRenderFn);
  16556. // CONCATENATED MODULE: ./renderers/block/blockStyleFn.js
  16557. /* harmony default export */ var block_blockStyleFn = (function (customBlockStyleFn) {
  16558. return function (block) {
  16559. var blockAlignment = block.getData() && block.getData().get('textAlign');
  16560. var blockIndent = block.getData() && block.getData().get('textIndent');
  16561. var blockFloat = block.getData() && block.getData().get('float');
  16562. var result = '';
  16563. if (blockAlignment) {
  16564. result = "bfa-".concat(blockAlignment);
  16565. }
  16566. if (blockIndent && blockIndent !== 0) {
  16567. result += " bftd-".concat(blockIndent);
  16568. }
  16569. if (blockFloat) {
  16570. result += " bff-".concat(blockFloat);
  16571. }
  16572. if (customBlockStyleFn) {
  16573. result += customBlockStyleFn(block) || '';
  16574. }
  16575. return result;
  16576. };
  16577. });
  16578. // CONCATENATED MODULE: ./renderers/inline/inlineStyleMap.js
  16579. /* harmony default export */ var inlineStyleMap = (function (props) {
  16580. var customStyleMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  16581. var extensionInlineStyleMap = getExtensionInlineStyleMap(props.editorId);
  16582. return objectSpread_default()({
  16583. 'SUPERSCRIPT': {
  16584. position: 'relative',
  16585. top: '-8px',
  16586. fontSize: '11px'
  16587. },
  16588. 'SUBSCRIPT': {
  16589. position: 'relative',
  16590. bottom: '-8px',
  16591. fontSize: '11px'
  16592. }
  16593. }, extensionInlineStyleMap, customStyleMap);
  16594. });
  16595. // CONCATENATED MODULE: ./renderers/inline/inlineStyleFn.js
  16596. var getStyleValue = function getStyleValue(style) {
  16597. return style.split('-')[1];
  16598. };
  16599. /* harmony default export */ var inlineStyleFn = (function (props, options) {
  16600. return function (styles, block) {
  16601. var output = {};
  16602. var fontFamilies = options.fontFamilies,
  16603. unitExportFn = options.unitExportFn,
  16604. customStyleFn = options.customStyleFn;
  16605. var extensionInlineStyleFns = getExtensionInlineStyleFns(props.editorId);
  16606. extensionInlineStyleFns.forEach(function (item) {
  16607. output = item.styleFn ? item.styleFn(styles, block, output) : output;
  16608. });
  16609. output = customStyleFn ? customStyleFn(styles, block, output) : {};
  16610. styles.forEach(function (style) {
  16611. if (style.indexOf('COLOR-') === 0) {
  16612. output.color = '#' + getStyleValue(style);
  16613. } else if (style.indexOf('BGCOLOR-') === 0) {
  16614. output.backgroundColor = '#' + getStyleValue(style);
  16615. } else if (style.indexOf('FONTSIZE-') === 0) {
  16616. output.fontSize = unitExportFn(getStyleValue(style), 'font-size', 'editor');
  16617. } else if (style.indexOf('LINEHEIGHT-') === 0) {
  16618. output.lineHeight = unitExportFn(getStyleValue(style), 'line-height', 'editor');
  16619. } else if (style.indexOf('LETTERSPACING-') === 0) {
  16620. output.letterSpacing = unitExportFn(getStyleValue(style), 'letter-spacing', 'editor');
  16621. } else if (style.indexOf('TEXTINDENT-') === 0) {
  16622. output.textIndent = unitExportFn(getStyleValue(style), 'text-indent', 'editor');
  16623. } else if (style.indexOf('FONTFAMILY-') === 0) {
  16624. output.fontFamily = (fontFamilies.find(function (item) {
  16625. return item.name.toUpperCase() === getStyleValue(style);
  16626. }) || {}).family || '';
  16627. }
  16628. });
  16629. return output;
  16630. };
  16631. });
  16632. // EXTERNAL MODULE: ../node_modules/draft-js-multidecorators/index.js
  16633. var draft_js_multidecorators = __webpack_require__(18);
  16634. var draft_js_multidecorators_default = /*#__PURE__*/__webpack_require__.n(draft_js_multidecorators);
  16635. // CONCATENATED MODULE: ./renderers/decorators/Link/index.jsx
  16636. /* harmony default export */ var Link = (function (props) {
  16637. var children = props.children,
  16638. entityKey = props.entityKey,
  16639. contentState = props.contentState;
  16640. var _contentState$getEnti = contentState.getEntity(entityKey).getData(),
  16641. href = _contentState$getEnti.href,
  16642. target = _contentState$getEnti.target;
  16643. return external_react_default.a.createElement("span", {
  16644. className: "bf-link-wrap"
  16645. }, external_react_default.a.createElement("a", {
  16646. onClick: function onClick(event) {
  16647. return viewLink(event, href);
  16648. },
  16649. className: "bf-link",
  16650. href: href,
  16651. target: target
  16652. }, children));
  16653. });
  16654. var viewLink = function viewLink(event, link) {
  16655. // 当按下Ctrl/command键时,点击打开链接文字中的url
  16656. if (event.getModifierState('Control') || event.getModifierState('Meta')) {
  16657. var tempLink = document.createElement('a');
  16658. tempLink.href = link;
  16659. tempLink.target = event.currentTarget.target;
  16660. tempLink.click();
  16661. }
  16662. };
  16663. // CONCATENATED MODULE: ./renderers/decorators/index.js
  16664. var KEY_SEPARATOR = '-';
  16665. draft_js_multidecorators_default.a.prototype.getDecorations = function (block, contentState) {
  16666. var decorations = Array(block.getText().length).fill(null);
  16667. this.decorators.forEach(function (decorator, i) {
  16668. decorator.getDecorations(block, contentState).forEach(function (key, offset) {
  16669. if (!key) {
  16670. return;
  16671. }
  16672. key = i + KEY_SEPARATOR + key;
  16673. decorations[offset] = key;
  16674. });
  16675. });
  16676. return external_immutable_default.a.List(decorations);
  16677. };
  16678. var builtinDecorators = [{
  16679. type: 'entity',
  16680. decorator: {
  16681. key: 'LINK',
  16682. component: Link
  16683. }
  16684. }];
  16685. var createStrategy = function createStrategy(type) {
  16686. return function (block, callback, contentState) {
  16687. block.findEntityRanges(function (character) {
  16688. var entityKey = character.getEntity();
  16689. return entityKey !== null && contentState.getEntity(entityKey).getType() === type;
  16690. }, callback);
  16691. };
  16692. };
  16693. /* harmony default export */ var decorators = (function (editorId) {
  16694. var extensionDecorators = getExtensionDecorators(editorId);
  16695. var entityDecorators = builtinDecorators.concat(toConsumableArray_default()(extensionDecorators.filter(function (item) {
  16696. return item.type === 'entity';
  16697. })));
  16698. var strategyDecorators = extensionDecorators.filter(function (item) {
  16699. return item.type === 'strategy';
  16700. });
  16701. var classDecorators = extensionDecorators.filter(function (item) {
  16702. return item.type === 'class';
  16703. });
  16704. return new draft_js_multidecorators_default.a(toConsumableArray_default()(classDecorators.map(function (item) {
  16705. return item.decorator;
  16706. })).concat([// combine decorators created with strategy
  16707. new external_draft_js_["CompositeDecorator"](strategyDecorators.map(function (item) {
  16708. return item.decorator;
  16709. })), // combine decorators for entities
  16710. new external_draft_js_["CompositeDecorator"](entityDecorators.map(function (item) {
  16711. return {
  16712. strategy: createStrategy(item.decorator.key),
  16713. component: item.decorator.component
  16714. };
  16715. }))]));
  16716. });
  16717. // CONCATENATED MODULE: ./renderers/index.js
  16718. var getBlockRenderMap = block_blockRenderMap;
  16719. var getBlockRendererFn = block_blockRendererFn;
  16720. var getBlockStyleFn = block_blockStyleFn;
  16721. var getCustomStyleMap = inlineStyleMap;
  16722. var getCustomStyleFn = inlineStyleFn;
  16723. var getDecorators = decorators;
  16724. // EXTERNAL MODULE: ./components/business/ControlBar/style.scss
  16725. var ControlBar_style = __webpack_require__(53);
  16726. // EXTERNAL MODULE: ./components/business/LinkEditor/style.scss
  16727. var LinkEditor_style = __webpack_require__(54);
  16728. // EXTERNAL MODULE: ./components/common/DropDown/style.scss
  16729. var DropDown_style = __webpack_require__(55);
  16730. // CONCATENATED MODULE: ./helpers/responsive.js
  16731. var resizeEventHandlers = [];
  16732. var responsiveHelperInited = false;
  16733. var debouce = false;
  16734. /* harmony default export */ var responsive = ({
  16735. resolve: function resolve(eventHandler) {
  16736. var id = external_braft_utils_["BaseUtils"].UniqueIndex();
  16737. resizeEventHandlers.push({
  16738. id: id,
  16739. eventHandler: eventHandler
  16740. });
  16741. return id;
  16742. },
  16743. unresolve: function unresolve(id) {
  16744. resizeEventHandlers = resizeEventHandlers.filter(function (item) {
  16745. return item.id !== id;
  16746. });
  16747. }
  16748. });
  16749. if (!responsiveHelperInited && (typeof window === "undefined" ? "undefined" : typeof_default()(window)) === 'object') {
  16750. window.addEventListener('resize', function (event) {
  16751. clearTimeout(debouce);
  16752. debouce = setTimeout(function () {
  16753. resizeEventHandlers.map(function (item) {
  16754. typeof item.eventHandler === 'function' && item.eventHandler(event);
  16755. });
  16756. debouce = false;
  16757. }, 100);
  16758. });
  16759. responsiveHelperInited = true;
  16760. }
  16761. // CONCATENATED MODULE: ./components/common/DropDown/index.jsx
  16762. var DropDown_DropDown =
  16763. /*#__PURE__*/
  16764. function (_React$Component) {
  16765. inherits_default()(DropDown, _React$Component);
  16766. function DropDown() {
  16767. var _getPrototypeOf2;
  16768. var _this;
  16769. classCallCheck_default()(this, DropDown);
  16770. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  16771. args[_key] = arguments[_key];
  16772. }
  16773. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(DropDown)).call.apply(_getPrototypeOf2, [this].concat(args)));
  16774. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "responsiveResolveId", null);
  16775. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownHandlerElement", null);
  16776. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownContentElement", null);
  16777. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  16778. active: false,
  16779. offset: 0
  16780. });
  16781. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "fixDropDownPosition", function () {
  16782. var viewRect = _this.props.getContainerNode().getBoundingClientRect();
  16783. var handlerRect = _this.dropDownHandlerElement.getBoundingClientRect();
  16784. var contentRect = _this.dropDownContentElement.getBoundingClientRect();
  16785. var offset = 0;
  16786. var right = handlerRect.right - handlerRect.width / 2 + contentRect.width / 2;
  16787. var left = handlerRect.left + handlerRect.width / 2 - contentRect.width / 2;
  16788. right = viewRect.right - right;
  16789. left = left - viewRect.left;
  16790. if (right < 10) {
  16791. offset = right - 10;
  16792. } else if (left < 10) {
  16793. offset = left * -1 + 10;
  16794. }
  16795. if (offset !== _this.state.offset) {
  16796. _this.setState({
  16797. offset: offset
  16798. });
  16799. }
  16800. });
  16801. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "registerClickEvent", function (event) {
  16802. var autoHide = _this.props.autoHide;
  16803. var active = _this.state.active;
  16804. if (_this.dropDownContentElement.contains(event.target) || _this.dropDownHandlerElement.contains(event.target)) {
  16805. return false;
  16806. }
  16807. autoHide && active && _this.hide();
  16808. });
  16809. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggle", function () {
  16810. _this.setState({
  16811. active: !_this.state.active
  16812. });
  16813. });
  16814. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "show", function () {
  16815. _this.setState({
  16816. active: true
  16817. });
  16818. });
  16819. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hide", function () {
  16820. _this.setState({
  16821. active: false
  16822. });
  16823. });
  16824. return _this;
  16825. }
  16826. createClass_default()(DropDown, [{
  16827. key: "componentDidMount",
  16828. value: function componentDidMount() {
  16829. if (document) {
  16830. document.body.addEventListener('click', this.registerClickEvent);
  16831. this.responsiveResolveId = responsive.resolve(this.fixDropDownPosition);
  16832. }
  16833. }
  16834. }, {
  16835. key: "componentWillReceiveProps",
  16836. value: function componentWillReceiveProps(next) {
  16837. if (!this.props.disabled && next.disabled) {
  16838. this.hide();
  16839. }
  16840. }
  16841. }, {
  16842. key: "componentDidUpdate",
  16843. value: function componentDidUpdate(prevState) {
  16844. if (!prevState.active && this.state.active) {
  16845. this.fixDropDownPosition();
  16846. }
  16847. }
  16848. }, {
  16849. key: "componentWillUnmount",
  16850. value: function componentWillUnmount() {
  16851. if (document) {
  16852. document.body.removeEventListener('click', this.registerClickEvent);
  16853. responsive.unresolve(this.responsiveResolveId);
  16854. }
  16855. }
  16856. }, {
  16857. key: "render",
  16858. value: function render() {
  16859. var _this2 = this;
  16860. var _this$state = this.state,
  16861. active = _this$state.active,
  16862. offset = _this$state.offset;
  16863. var _this$props = this.props,
  16864. caption = _this$props.caption,
  16865. htmlCaption = _this$props.htmlCaption,
  16866. title = _this$props.title,
  16867. disabled = _this$props.disabled,
  16868. showArrow = _this$props.showArrow,
  16869. arrowActive = _this$props.arrowActive,
  16870. className = _this$props.className,
  16871. children = _this$props.children,
  16872. theme = _this$props.theme;
  16873. disabled && (active = false);
  16874. theme === 'light' && (className = ' light-theme ' + className);
  16875. return external_react_default.a.createElement("div", {
  16876. className: 'bf-dropdown ' + (active ? 'active ' : '') + (disabled ? 'disabled ' : '') + className
  16877. }, htmlCaption ? external_react_default.a.createElement("button", {
  16878. type: "button",
  16879. className: "dropdown-handler",
  16880. "data-title": title,
  16881. onClick: this.toggle,
  16882. dangerouslySetInnerHTML: htmlCaption ? {
  16883. __html: htmlCaption
  16884. } : null,
  16885. ref: function ref(instance) {
  16886. return _this2.dropDownHandlerElement = instance;
  16887. }
  16888. }) : external_react_default.a.createElement("button", {
  16889. type: "button",
  16890. className: "dropdown-handler",
  16891. "data-title": title,
  16892. onClick: this.toggle,
  16893. ref: function ref(instance) {
  16894. return _this2.dropDownHandlerElement = instance;
  16895. }
  16896. }, external_react_default.a.createElement("span", null, caption), showArrow !== false ? external_react_default.a.createElement("i", {
  16897. className: "bfi-drop-down"
  16898. }) : null), external_react_default.a.createElement("div", {
  16899. className: "dropdown-content",
  16900. style: {
  16901. marginLeft: offset
  16902. },
  16903. ref: function ref(instance) {
  16904. return _this2.dropDownContentElement = instance;
  16905. }
  16906. }, external_react_default.a.createElement("i", {
  16907. style: {
  16908. marginLeft: offset * -1
  16909. },
  16910. className: 'dropdown-arrow' + (arrowActive ? ' active' : '')
  16911. }), external_react_default.a.createElement("div", {
  16912. className: "dropdown-content-inner"
  16913. }, children)));
  16914. }
  16915. }]);
  16916. return DropDown;
  16917. }(external_react_default.a.Component);
  16918. // CONCATENATED MODULE: ./components/business/ControlGroup/index.jsx
  16919. /* harmony default export */ var ControlGroup = (function (props) {
  16920. if (external_react_default.a.Fragment) {
  16921. return external_react_default.a.createElement(external_react_default.a.Fragment, null, props.children);
  16922. } else {
  16923. return external_react_default.a.createElement("div", {
  16924. className: "control-item-group"
  16925. }, props.children);
  16926. }
  16927. });
  16928. // CONCATENATED MODULE: ./components/business/LinkEditor/index.jsx
  16929. var LinkEditor_LinkEditor =
  16930. /*#__PURE__*/
  16931. function (_React$Component) {
  16932. inherits_default()(LinkEditor, _React$Component);
  16933. function LinkEditor(props) {
  16934. var _this;
  16935. classCallCheck_default()(this, LinkEditor);
  16936. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(LinkEditor).call(this, props));
  16937. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownInstance", null);
  16938. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handeKeyDown", function (e) {
  16939. if (e.keyCode === 13) {
  16940. _this.handleConfirm();
  16941. e.preventDefault();
  16942. return false;
  16943. }
  16944. });
  16945. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTnputText", function (e) {
  16946. _this.setState({
  16947. text: e.currentTarget.value
  16948. });
  16949. });
  16950. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleInputLink", function (e) {
  16951. _this.setState({
  16952. href: e.currentTarget.value
  16953. });
  16954. });
  16955. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setTarget", function () {
  16956. _this.setState({
  16957. target: _this.state.target === '_blank' ? '' : '_blank'
  16958. });
  16959. });
  16960. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
  16961. _this.dropDownInstance.hide();
  16962. });
  16963. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleUnlink", function () {
  16964. _this.dropDownInstance.hide();
  16965. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
  16966. });
  16967. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
  16968. var _this$state = _this.state,
  16969. text = _this$state.text,
  16970. href = _this$state.href,
  16971. target = _this$state.target,
  16972. textSelected = _this$state.textSelected;
  16973. var hookReturns = _this.props.hooks('toggle-link', {
  16974. href: href,
  16975. target: target
  16976. })({
  16977. href: href,
  16978. target: target
  16979. });
  16980. _this.dropDownInstance.hide();
  16981. _this.props.editor.requestFocus();
  16982. if (hookReturns === false) {
  16983. return false;
  16984. }
  16985. if (hookReturns) {
  16986. typeof hookReturns.href === 'string' && (href = hookReturns.href);
  16987. typeof hookReturns.target === 'string' && (target = hookReturns.target);
  16988. }
  16989. if (textSelected) {
  16990. if (href) {
  16991. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, href, target));
  16992. } else {
  16993. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
  16994. }
  16995. } else {
  16996. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(_this.props.editorState, text || href, null, {
  16997. type: 'LINK',
  16998. data: {
  16999. href: href,
  17000. target: target
  17001. }
  17002. }));
  17003. }
  17004. });
  17005. _this.state = {
  17006. text: '',
  17007. href: '',
  17008. target: props.defaultLinkTarget || '',
  17009. textSelected: false
  17010. };
  17011. return _this;
  17012. }
  17013. createClass_default()(LinkEditor, [{
  17014. key: "componentWillReceiveProps",
  17015. value: function componentWillReceiveProps(nextProps) {
  17016. var _ContentUtils$getSele = external_braft_utils_["ContentUtils"].getSelectionEntityData(nextProps.editorState, 'LINK'),
  17017. href = _ContentUtils$getSele.href,
  17018. target = _ContentUtils$getSele.target;
  17019. var textSelected = !external_braft_utils_["ContentUtils"].isSelectionCollapsed(this.props.editorState) && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) !== 'atomic';
  17020. var selectedText = '';
  17021. if (textSelected) {
  17022. selectedText = external_braft_utils_["ContentUtils"].getSelectionText(this.props.editorState);
  17023. }
  17024. this.setState({
  17025. textSelected: textSelected,
  17026. text: selectedText,
  17027. href: href || '',
  17028. target: typeof target === 'undefined' ? nextProps.defaultLinkTarget || '' : target || ''
  17029. });
  17030. }
  17031. }, {
  17032. key: "render",
  17033. value: function render() {
  17034. var _this2 = this;
  17035. var allowInsertLinkText = this.props.allowInsertLinkText;
  17036. var _this$state2 = this.state,
  17037. text = _this$state2.text,
  17038. href = _this$state2.href,
  17039. target = _this$state2.target,
  17040. textSelected = _this$state2.textSelected;
  17041. var caption = external_react_default.a.createElement("i", {
  17042. className: "bfi-link"
  17043. });
  17044. return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement(DropDown_DropDown, {
  17045. key: 0,
  17046. caption: caption,
  17047. title: this.props.language.controls.link,
  17048. autoHide: true,
  17049. getContainerNode: this.props.getContainerNode,
  17050. showArrow: false,
  17051. ref: function ref(instance) {
  17052. return _this2.dropDownInstance = instance;
  17053. },
  17054. className: 'control-item dropdown link-editor-dropdown'
  17055. }, external_react_default.a.createElement("div", {
  17056. className: "bf-link-editor"
  17057. }, allowInsertLinkText ? external_react_default.a.createElement("div", {
  17058. className: "input-group"
  17059. }, external_react_default.a.createElement("input", {
  17060. type: "text",
  17061. value: text,
  17062. spellCheck: false,
  17063. disabled: textSelected,
  17064. placeholder: this.props.language.linkEditor.textInputPlaceHolder,
  17065. onKeyDown: this.handeKeyDown,
  17066. onChange: this.handleTnputText
  17067. })) : null, external_react_default.a.createElement("div", {
  17068. className: "input-group"
  17069. }, external_react_default.a.createElement("input", {
  17070. type: "text",
  17071. value: href,
  17072. spellCheck: false,
  17073. placeholder: this.props.language.linkEditor.linkInputPlaceHolder,
  17074. onKeyDown: this.handeKeyDown,
  17075. onChange: this.handleInputLink
  17076. })), external_react_default.a.createElement("div", {
  17077. className: "switch-group"
  17078. }, external_react_default.a.createElement(Switch, {
  17079. active: target === '_blank',
  17080. onClick: this.setTarget
  17081. }), external_react_default.a.createElement("label", null, this.props.language.linkEditor.openInNewWindow)), external_react_default.a.createElement("div", {
  17082. className: "buttons"
  17083. }, external_react_default.a.createElement("a", {
  17084. onClick: this.handleUnlink,
  17085. className: "primary button-remove-link pull-left"
  17086. }, external_react_default.a.createElement("i", {
  17087. className: "bfi-close"
  17088. }), external_react_default.a.createElement("span", null, this.props.language.linkEditor.removeLink)), external_react_default.a.createElement("button", {
  17089. type: "button",
  17090. onClick: this.handleConfirm,
  17091. className: "primary pull-right"
  17092. }, this.props.language.base.confirm), external_react_default.a.createElement("button", {
  17093. type: "button",
  17094. onClick: this.handleCancel,
  17095. className: "default pull-right"
  17096. }, this.props.language.base.cancel)))), external_react_default.a.createElement("button", {
  17097. key: 1,
  17098. type: "button",
  17099. "data-title": this.props.language.controls.unlink,
  17100. className: "control-item button",
  17101. onClick: this.handleUnlink,
  17102. disabled: !textSelected || !href
  17103. }, external_react_default.a.createElement("i", {
  17104. className: "bfi-link-off"
  17105. })));
  17106. }
  17107. }]);
  17108. return LinkEditor;
  17109. }(external_react_default.a.Component);
  17110. // EXTERNAL MODULE: ./components/business/Headings/style.scss
  17111. var Headings_style = __webpack_require__(56);
  17112. // CONCATENATED MODULE: ./configs/maps.js
  17113. var maps_getHeadings = function getHeadings(lang) {
  17114. return [{
  17115. key: 'header-one',
  17116. title: lang.controls.header + ' 1',
  17117. text: external_react_default.a.createElement("h1", null, lang.controls.header, " 1"),
  17118. type: 'block-type',
  17119. command: 'header-one'
  17120. }, {
  17121. key: 'header-two',
  17122. title: lang.controls.header + ' 2',
  17123. text: external_react_default.a.createElement("h2", null, lang.controls.header, " 2"),
  17124. type: 'block-type',
  17125. command: 'header-two'
  17126. }, {
  17127. key: 'header-three',
  17128. title: lang.controls.header + ' 3',
  17129. text: external_react_default.a.createElement("h3", null, lang.controls.header, " 3"),
  17130. type: 'block-type',
  17131. command: 'header-three'
  17132. }, {
  17133. key: 'header-four',
  17134. title: lang.controls.header + ' 4',
  17135. text: external_react_default.a.createElement("h4", null, lang.controls.header, " 4"),
  17136. type: 'block-type',
  17137. command: 'header-four'
  17138. }, {
  17139. key: 'header-five',
  17140. title: lang.controls.header + ' 5',
  17141. text: external_react_default.a.createElement("h5", null, lang.controls.header, " 5"),
  17142. type: 'block-type',
  17143. command: 'header-five'
  17144. }, {
  17145. key: 'header-six',
  17146. title: lang.controls.header + ' 6',
  17147. text: external_react_default.a.createElement("h6", null, lang.controls.header, " 6"),
  17148. type: 'block-type',
  17149. command: 'header-six'
  17150. }, {
  17151. key: 'unstyled',
  17152. title: lang.controls.normal,
  17153. text: lang.controls.normal,
  17154. type: 'block-type',
  17155. command: 'unstyled'
  17156. }];
  17157. };
  17158. // CONCATENATED MODULE: ./components/business/Headings/index.jsx
  17159. /* harmony default export */ var Headings = (function (props) {
  17160. var dropDownInstance = null;
  17161. var headings = maps_getHeadings(props.language).filter(function (item) {
  17162. return props.headings.indexOf(item.key) !== -1;
  17163. });
  17164. var currentHeadingIndex = headings.findIndex(function (item) {
  17165. return item.command === props.current;
  17166. });
  17167. var caption = headings[currentHeadingIndex] ? headings[currentHeadingIndex].title : props.language.controls.normal;
  17168. return external_react_default.a.createElement(DropDown_DropDown, {
  17169. caption: caption,
  17170. autoHide: true,
  17171. getContainerNode: props.getContainerNode,
  17172. title: props.language.controls.headings,
  17173. arrowActive: currentHeadingIndex === 0,
  17174. ref: function ref(instance) {
  17175. return dropDownInstance = instance;
  17176. },
  17177. className: 'control-item dropdown headings-dropdown'
  17178. }, external_react_default.a.createElement("ul", {
  17179. className: "menu"
  17180. }, headings.map(function (item, index) {
  17181. var isActive = props.current === item.command;
  17182. return external_react_default.a.createElement("li", {
  17183. key: index,
  17184. className: 'menu-item' + (isActive ? ' active' : ''),
  17185. onClick: function onClick() {
  17186. props.onChange(item.command, item.type), dropDownInstance.hide();
  17187. }
  17188. }, item.text);
  17189. })));
  17190. });
  17191. // EXTERNAL MODULE: ./components/business/TextColor/style.scss
  17192. var TextColor_style = __webpack_require__(57);
  17193. // EXTERNAL MODULE: ./components/common/ColorPicker/style.scss
  17194. var ColorPicker_style = __webpack_require__(58);
  17195. // CONCATENATED MODULE: ./components/common/ColorPicker/index.jsx
  17196. /* harmony default export */ var common_ColorPicker = (function (props) {
  17197. return external_react_default.a.createElement("div", {
  17198. className: "bf-colors-wrap"
  17199. }, external_react_default.a.createElement("ul", {
  17200. className: "bf-colors"
  17201. }, props.presetColors.map(function (item, index) {
  17202. var className = props.color && item.toLowerCase() === props.color.toLowerCase() ? 'color-item active' : 'color-item';
  17203. return external_react_default.a.createElement("li", {
  17204. key: index,
  17205. title: item,
  17206. className: className,
  17207. style: {
  17208. color: item
  17209. },
  17210. "data-color": item.replace('#', ''),
  17211. onClick: function onClick(e) {
  17212. props.onChange(e.currentTarget.dataset.color, true);
  17213. }
  17214. });
  17215. })));
  17216. });
  17217. // CONCATENATED MODULE: ./components/business/TextColor/index.jsx
  17218. var TextColor_TextColor =
  17219. /*#__PURE__*/
  17220. function (_React$Component) {
  17221. inherits_default()(TextColor, _React$Component);
  17222. function TextColor() {
  17223. var _getPrototypeOf2;
  17224. var _this;
  17225. classCallCheck_default()(this, TextColor);
  17226. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  17227. args[_key] = arguments[_key];
  17228. }
  17229. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextColor)).call.apply(_getPrototypeOf2, [this].concat(args)));
  17230. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  17231. colorType: 'color'
  17232. });
  17233. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "switchColorType", function (_ref) {
  17234. var currentTarget = _ref.currentTarget;
  17235. _this.setState({
  17236. colorType: currentTarget.dataset.type
  17237. });
  17238. });
  17239. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleColor", function (color, closePicker) {
  17240. if (color) {
  17241. var hookReturns = _this.props.hooks("toggle-text-".concat(_this.state.colorType), color)(color);
  17242. if (hookReturns === false) {
  17243. return false;
  17244. }
  17245. if (typeof hookReturns === 'string') {
  17246. color = hookReturns;
  17247. }
  17248. if (_this.state.colorType === 'color') {
  17249. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionColor(_this.props.editorState, color));
  17250. } else {
  17251. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBackgroundColor(_this.props.editorState, color));
  17252. }
  17253. }
  17254. if (closePicker) {
  17255. _this.dropDownInstance.hide();
  17256. _this.props.editor.requestFocus();
  17257. }
  17258. });
  17259. return _this;
  17260. }
  17261. createClass_default()(TextColor, [{
  17262. key: "render",
  17263. value: function render() {
  17264. var _this2 = this;
  17265. var captionStyle = {};
  17266. var currentColor = null;
  17267. var colorType = this.state.colorType;
  17268. var selectionStyles = this.props.editorState.getCurrentInlineStyle().toJS();
  17269. selectionStyles.forEach(function (style) {
  17270. if (style.indexOf('COLOR-') === 0) {
  17271. captionStyle.color = '#' + style.split('-')[1];
  17272. colorType === 'color' && (currentColor = captionStyle.color);
  17273. }
  17274. if (style.indexOf('BGCOLOR-') === 0) {
  17275. captionStyle.backgroundColor = '#' + style.split('-')[1];
  17276. colorType === 'background-color' && (currentColor = captionStyle.backgroundColor);
  17277. }
  17278. });
  17279. var caption = external_react_default.a.createElement("i", {
  17280. style: captionStyle,
  17281. className: "bfi-text-color"
  17282. }, external_react_default.a.createElement("span", {
  17283. className: "path1"
  17284. }), external_react_default.a.createElement("span", {
  17285. className: "path2"
  17286. }));
  17287. var ColorPicker = this.props.colorPicker || common_ColorPicker;
  17288. return external_react_default.a.createElement(DropDown_DropDown, {
  17289. caption: caption,
  17290. title: this.props.language.controls.color,
  17291. showArrow: false,
  17292. autoHide: this.props.autoHide,
  17293. theme: this.props.theme,
  17294. getContainerNode: this.props.getContainerNode,
  17295. ref: function ref(instance) {
  17296. return _this2.dropDownInstance = instance;
  17297. },
  17298. className: 'control-item dropdown text-color-dropdown'
  17299. }, external_react_default.a.createElement("div", {
  17300. className: "bf-text-color-picker-wrap"
  17301. }, external_react_default.a.createElement("div", {
  17302. className: "bf-color-switch-buttons",
  17303. style: this.props.enableBackgroundColor ? {} : {
  17304. display: 'none'
  17305. }
  17306. }, external_react_default.a.createElement("button", {
  17307. type: "button",
  17308. "data-type": "color",
  17309. className: colorType === 'color' ? 'active' : '',
  17310. onClick: this.switchColorType
  17311. }, this.props.language.controls.textColor), external_react_default.a.createElement("button", {
  17312. type: "button",
  17313. "data-type": "background-color",
  17314. className: colorType === 'background-color' ? 'active' : '',
  17315. onClick: this.switchColorType
  17316. }, this.props.language.controls.backgroundColor)), external_react_default.a.createElement(ColorPicker, {
  17317. width: 200,
  17318. color: currentColor,
  17319. disableAlpha: true,
  17320. presetColors: this.props.colors,
  17321. onChange: this.toggleColor
  17322. })));
  17323. }
  17324. }]);
  17325. return TextColor;
  17326. }(external_react_default.a.Component);
  17327. // EXTERNAL MODULE: ./components/business/FontSize/style.scss
  17328. var FontSize_style = __webpack_require__(59);
  17329. // CONCATENATED MODULE: ./components/business/FontSize/index.jsx
  17330. var FontSize_toggleFontSize = function toggleFontSize(event, props) {
  17331. var fontSize = event.currentTarget.dataset.size;
  17332. var hookReturns = props.hooks('toggle-font-size', fontSize)(fontSize);
  17333. if (hookReturns === false) {
  17334. return false;
  17335. }
  17336. if (!isNaN(fontSize)) {
  17337. fontSize = hookReturns;
  17338. }
  17339. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontSize(props.editorState, fontSize));
  17340. props.editor.requestFocus();
  17341. };
  17342. /* harmony default export */ var FontSize = (function (props) {
  17343. var caption = null;
  17344. var currentFontSize = null;
  17345. var dropDownInstance = null;
  17346. props.fontSizes.find(function (item) {
  17347. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTSIZE-' + item)) {
  17348. caption = item;
  17349. currentFontSize = item;
  17350. return true;
  17351. }
  17352. return false;
  17353. });
  17354. return external_react_default.a.createElement(DropDown_DropDown, {
  17355. autoHide: true,
  17356. caption: caption || props.defaultCaption,
  17357. getContainerNode: props.getContainerNode,
  17358. title: props.language.controls.fontSize,
  17359. ref: function ref(instance) {
  17360. return dropDownInstance = instance;
  17361. },
  17362. className: 'control-item dropdown bf-font-size-dropdown'
  17363. }, external_react_default.a.createElement("ul", {
  17364. className: "bf-font-sizes"
  17365. }, props.fontSizes.map(function (item, index) {
  17366. return external_react_default.a.createElement("li", {
  17367. key: index,
  17368. className: item === currentFontSize ? 'active' : null,
  17369. "data-size": item,
  17370. onClick: function onClick(event) {
  17371. FontSize_toggleFontSize(event, props), dropDownInstance.hide();
  17372. }
  17373. }, item);
  17374. })));
  17375. });
  17376. // EXTERNAL MODULE: ./components/business/LineHeight/style.scss
  17377. var LineHeight_style = __webpack_require__(60);
  17378. // CONCATENATED MODULE: ./components/business/LineHeight/index.jsx
  17379. var LineHeight_toggleLineHeight = function toggleLineHeight(event, props) {
  17380. var lineHeight = event.currentTarget.dataset.size;
  17381. var hookReturns = props.hooks('toggle-line-height', lineHeight)(lineHeight);
  17382. if (hookReturns === false) {
  17383. return false;
  17384. }
  17385. if (!isNaN(hookReturns)) {
  17386. lineHeight = hookReturns;
  17387. }
  17388. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLineHeight(props.editorState, lineHeight));
  17389. props.editor.requestFocus();
  17390. };
  17391. /* harmony default export */ var LineHeight = (function (props) {
  17392. var caption = null;
  17393. var currentLineHeight = null;
  17394. var dropDownInstance = null;
  17395. props.lineHeights.find(function (item) {
  17396. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LINEHEIGHT-' + item)) {
  17397. caption = item;
  17398. currentLineHeight = item;
  17399. return true;
  17400. }
  17401. return false;
  17402. });
  17403. return external_react_default.a.createElement(DropDown_DropDown, {
  17404. autoHide: true,
  17405. caption: caption || props.defaultCaption,
  17406. getContainerNode: props.getContainerNode,
  17407. title: props.language.controls.lineHeight,
  17408. ref: function ref(instance) {
  17409. return dropDownInstance = instance;
  17410. },
  17411. className: 'control-item dropdown bf-line-height-dropdown'
  17412. }, external_react_default.a.createElement("ul", {
  17413. className: "bf-line-heights"
  17414. }, props.lineHeights.map(function (item, index) {
  17415. return external_react_default.a.createElement("li", {
  17416. key: index,
  17417. className: item === currentLineHeight ? 'active' : null,
  17418. "data-size": item,
  17419. onClick: function onClick(event) {
  17420. LineHeight_toggleLineHeight(event, props), dropDownInstance.hide();
  17421. }
  17422. }, item);
  17423. })));
  17424. });
  17425. // EXTERNAL MODULE: ./components/business/FontFamily/style.scss
  17426. var FontFamily_style = __webpack_require__(61);
  17427. // CONCATENATED MODULE: ./components/business/FontFamily/index.jsx
  17428. var FontFamily_toggleFontFamily = function toggleFontFamily(event, props) {
  17429. var fontFamilyName = event.currentTarget.dataset.name;
  17430. var hookReturns = props.hooks('toggle-font-family', fontFamilyName)(fontFamilyName, props.fontFamilies);
  17431. if (hookReturns === false) {
  17432. return false;
  17433. }
  17434. if (typeof hookReturns === 'string') {
  17435. fontFamilyName = hookReturns;
  17436. }
  17437. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontFamily(props.editorState, fontFamilyName));
  17438. props.editor.requestFocus();
  17439. };
  17440. /* harmony default export */ var FontFamily = (function (props) {
  17441. var caption = null;
  17442. var currentIndex = null;
  17443. var dropDownInstance = null;
  17444. props.fontFamilies.find(function (item, index) {
  17445. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTFAMILY-' + item.name)) {
  17446. caption = item.name;
  17447. currentIndex = index;
  17448. return true;
  17449. }
  17450. return false;
  17451. });
  17452. return external_react_default.a.createElement(DropDown_DropDown, {
  17453. caption: caption || props.defaultCaption,
  17454. getContainerNode: props.getContainerNode,
  17455. title: props.language.controls.fontFamily,
  17456. autoHide: true,
  17457. arrowActive: currentIndex === 0,
  17458. ref: function ref(instance) {
  17459. return dropDownInstance = instance;
  17460. },
  17461. className: 'control-item dropdown font-family-dropdown'
  17462. }, external_react_default.a.createElement("ul", {
  17463. className: "menu"
  17464. }, props.fontFamilies.map(function (item, index) {
  17465. return external_react_default.a.createElement("li", {
  17466. key: index,
  17467. className: 'menu-item ' + (index === currentIndex ? 'active' : ''),
  17468. "data-name": item.name,
  17469. onClick: function onClick(event) {
  17470. FontFamily_toggleFontFamily(event, props), dropDownInstance.hide();
  17471. }
  17472. }, external_react_default.a.createElement("span", {
  17473. style: {
  17474. fontFamily: item.family
  17475. }
  17476. }, item.name));
  17477. })));
  17478. });
  17479. // CONCATENATED MODULE: ./components/business/TextAlign/index.jsx
  17480. var TextAlign_TextAlign =
  17481. /*#__PURE__*/
  17482. function (_React$Component) {
  17483. inherits_default()(TextAlign, _React$Component);
  17484. function TextAlign() {
  17485. var _getPrototypeOf2;
  17486. var _this;
  17487. classCallCheck_default()(this, TextAlign);
  17488. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  17489. args[_key] = arguments[_key];
  17490. }
  17491. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
  17492. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  17493. currentAlignment: undefined
  17494. });
  17495. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setAlignment", function (event) {
  17496. var alignment = event.currentTarget.dataset.alignment;
  17497. var hookReturns = _this.props.hooks('toggle-text-alignment', alignment)(alignment);
  17498. if (_this.props.textAligns.indexOf(hookReturns) > -1) {
  17499. alignment = hookReturns;
  17500. }
  17501. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionAlignment(_this.props.editorState, alignment));
  17502. _this.props.editor.requestFocus();
  17503. });
  17504. return _this;
  17505. }
  17506. createClass_default()(TextAlign, [{
  17507. key: "componentWillReceiveProps",
  17508. value: function componentWillReceiveProps(next) {
  17509. this.setState({
  17510. currentAlignment: external_braft_utils_["ContentUtils"].getSelectionBlockData(next.editorState, 'textAlign')
  17511. });
  17512. }
  17513. }, {
  17514. key: "render",
  17515. value: function render() {
  17516. var _this2 = this;
  17517. var textAlignmentTitles = [this.props.language.controls.alignLeft, this.props.language.controls.alignCenter, this.props.language.controls.alignRight, this.props.language.controls.alignJustify];
  17518. return external_react_default.a.createElement(ControlGroup, null, this.props.textAligns.map(function (item, index) {
  17519. return external_react_default.a.createElement("button", {
  17520. type: "button",
  17521. key: index,
  17522. "data-title": textAlignmentTitles[index],
  17523. "data-alignment": item,
  17524. className: 'control-item button ' + (item === _this2.state.currentAlignment ? 'active' : null),
  17525. onClick: _this2.setAlignment
  17526. }, external_react_default.a.createElement("i", {
  17527. className: 'bfi-align-' + item
  17528. }));
  17529. }));
  17530. }
  17531. }]);
  17532. return TextAlign;
  17533. }(external_react_default.a.Component);
  17534. // EXTERNAL MODULE: ./components/business/EmojiPicker/style.scss
  17535. var EmojiPicker_style = __webpack_require__(62);
  17536. // CONCATENATED MODULE: ./components/business/EmojiPicker/index.jsx
  17537. var EmojiPicker_insertEmoji = function insertEmoji(event, props) {
  17538. var emoji = event.currentTarget.dataset.emoji;
  17539. var hookReturns = props.hooks('insert-emoji', emoji)(emoji);
  17540. if (hookReturns === false) {
  17541. return false;
  17542. }
  17543. if (typeof hookReturns === 'string') {
  17544. emoji = hookReturns;
  17545. }
  17546. props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(props.editorState, emoji));
  17547. props.editor.requestFocus();
  17548. };
  17549. /* harmony default export */ var EmojiPicker = (function (props) {
  17550. return external_react_default.a.createElement(DropDown_DropDown, {
  17551. caption: props.defaultCaption,
  17552. autoHide: true,
  17553. showArrow: false,
  17554. getContainerNode: props.getContainerNode,
  17555. title: props.language.controls.emoji,
  17556. className: 'control-item dropdown bf-emoji-dropdown'
  17557. }, external_react_default.a.createElement("div", {
  17558. className: "bf-emojis-wrap"
  17559. }, external_react_default.a.createElement("ul", {
  17560. className: "bf-emojis"
  17561. }, props.emojis.map(function (item, index) {
  17562. return external_react_default.a.createElement("li", {
  17563. key: index,
  17564. "data-emoji": item,
  17565. onClick: function onClick(event) {
  17566. return EmojiPicker_insertEmoji(event, props);
  17567. }
  17568. }, item);
  17569. }))));
  17570. });
  17571. // EXTERNAL MODULE: ./components/business/LetterSpacing/style.scss
  17572. var LetterSpacing_style = __webpack_require__(63);
  17573. // CONCATENATED MODULE: ./components/business/LetterSpacing/index.jsx
  17574. var LetterSpacing_toggleLetterSpacing = function toggleLetterSpacing(event, props) {
  17575. var letterSpacing = event.currentTarget.dataset.size;
  17576. var hookReturns = props.hooks('toggle-letter-spacing', letterSpacing)(letterSpacing);
  17577. if (hookReturns === false) {
  17578. return false;
  17579. }
  17580. if (!isNaN(hookReturns)) {
  17581. letterSpacing = hookReturns;
  17582. }
  17583. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLetterSpacing(props.editorState, letterSpacing));
  17584. props.editor.requestFocus();
  17585. };
  17586. /* harmony default export */ var LetterSpacing = (function (props) {
  17587. var caption = null;
  17588. var currentLetterSpacing = null;
  17589. var dropDownInstance = null;
  17590. props.letterSpacings.find(function (item) {
  17591. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LETTERSPACING-' + item)) {
  17592. caption = item;
  17593. currentLetterSpacing = item;
  17594. return true;
  17595. }
  17596. return false;
  17597. });
  17598. return external_react_default.a.createElement(DropDown_DropDown, {
  17599. autoHide: true,
  17600. caption: caption || props.defaultCaption,
  17601. getContainerNode: props.getContainerNode,
  17602. title: props.language.controls.letterSpacing,
  17603. ref: function ref(instance) {
  17604. return dropDownInstance = instance;
  17605. },
  17606. className: 'control-item dropdown bf-letter-spacing-dropdown'
  17607. }, external_react_default.a.createElement("ul", {
  17608. className: "bf-letter-spacings"
  17609. }, props.letterSpacings.map(function (item, index) {
  17610. return external_react_default.a.createElement("li", {
  17611. key: index,
  17612. className: item === currentLetterSpacing ? 'active' : null,
  17613. "data-size": item,
  17614. onClick: function onClick(event) {
  17615. LetterSpacing_toggleLetterSpacing(event, props), dropDownInstance.hide();
  17616. }
  17617. }, item);
  17618. })));
  17619. });
  17620. // CONCATENATED MODULE: ./components/business/TextIndent/index.jsx
  17621. var TextIndent_TextAlign =
  17622. /*#__PURE__*/
  17623. function (_React$Component) {
  17624. inherits_default()(TextAlign, _React$Component);
  17625. function TextAlign() {
  17626. var _getPrototypeOf2;
  17627. var _this;
  17628. classCallCheck_default()(this, TextAlign);
  17629. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  17630. args[_key] = arguments[_key];
  17631. }
  17632. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
  17633. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  17634. currentIndent: 0
  17635. });
  17636. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "increaseIndent", function () {
  17637. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(_this.props.editorState));
  17638. _this.props.editor.requestFocus();
  17639. });
  17640. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "decreaseIndent", function () {
  17641. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(_this.props.editorState));
  17642. _this.props.editor.requestFocus();
  17643. });
  17644. return _this;
  17645. }
  17646. createClass_default()(TextAlign, [{
  17647. key: "componentWillReceiveProps",
  17648. value: function componentWillReceiveProps(nextProps) {
  17649. this.setState({
  17650. currentIndent: external_braft_utils_["ContentUtils"].getSelectionBlockData(nextProps.editorState, 'textIndent') || 0
  17651. });
  17652. }
  17653. }, {
  17654. key: "render",
  17655. value: function render() {
  17656. var currentIndent = this.state.currentIndent;
  17657. var language = this.props.language;
  17658. return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement("button", {
  17659. key: 0,
  17660. type: "button",
  17661. "data-title": language.controls.increaseIndent,
  17662. disabled: currentIndent >= 6,
  17663. className: "control-item button button-indent-increase".concat(currentIndent > 0 && currentIndent < 6 ? ' active' : ''),
  17664. onClick: this.increaseIndent
  17665. }, external_react_default.a.createElement("i", {
  17666. className: 'bfi-indent-increase'
  17667. })), external_react_default.a.createElement("button", {
  17668. key: 1,
  17669. type: "button",
  17670. "data-title": language.controls.decreaseIndent,
  17671. disabled: currentIndent <= 0,
  17672. className: "control-item button button-indent-decrease",
  17673. onClick: this.decreaseIndent
  17674. }, external_react_default.a.createElement("i", {
  17675. className: 'bfi-indent-decrease'
  17676. })));
  17677. }
  17678. }]);
  17679. return TextAlign;
  17680. }(external_react_default.a.Component);
  17681. // CONCATENATED MODULE: ./components/business/ControlBar/index.jsx
  17682. var commandHookMap = {
  17683. 'inline-style': 'toggle-inline-style',
  17684. 'block-type': 'change-block-type',
  17685. 'editor-method': 'exec-editor-command'
  17686. };
  17687. var exclusiveInlineStyles = {
  17688. 'superscript': 'subscript',
  17689. 'subscript': 'superscript'
  17690. };
  17691. var mergeControls = function mergeControls(commonProps, builtControls, extensionControls, extendControls) {
  17692. extensionControls = extensionControls.map(function (item) {
  17693. return typeof item === 'function' ? item(commonProps) : item;
  17694. });
  17695. extendControls = extendControls.map(function (item) {
  17696. return typeof item === 'function' ? item(commonProps) : item;
  17697. });
  17698. if (extensionControls.length === 0 && extendControls.length === 0) {
  17699. return builtControls;
  17700. }
  17701. return builtControls.map(function (item) {
  17702. return extendControls.find(function (subItem) {
  17703. return subItem.replace === (item.key || item);
  17704. }) || extensionControls.find(function (subItem) {
  17705. return subItem.replace === (item.key || item);
  17706. }) || item;
  17707. }).concat(extensionControls.length ? 'separator' : '').concat(extensionControls.filter(function (item) {
  17708. return !item.replace;
  17709. })).concat(extendControls.filter(function (item) {
  17710. return typeof item === 'string' || !item.replace;
  17711. }));
  17712. };
  17713. var ControlBar_ControlBar =
  17714. /*#__PURE__*/
  17715. function (_React$Component) {
  17716. inherits_default()(ControlBar, _React$Component);
  17717. function ControlBar() {
  17718. var _getPrototypeOf2;
  17719. var _this;
  17720. classCallCheck_default()(this, ControlBar);
  17721. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  17722. args[_key] = arguments[_key];
  17723. }
  17724. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(ControlBar)).call.apply(_getPrototypeOf2, [this].concat(args)));
  17725. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "allControls", []);
  17726. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "mediaLibiraryModal", null);
  17727. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "extendedModals", {});
  17728. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "openBraftFinder", function () {
  17729. if (!_this.props.braftFinder || !_this.props.braftFinder.ReactComponent) {
  17730. return false;
  17731. }
  17732. if (_this.props.hooks('open-braft-finder')() === false) {
  17733. return false;
  17734. }
  17735. var mediaProps = _this.props.media;
  17736. var MediaLibrary = _this.props.braftFinder.ReactComponent;
  17737. _this.mediaLibiraryModal = Modal_showModal({
  17738. title: _this.props.language.controls.mediaLibirary,
  17739. language: _this.props.language,
  17740. width: 640,
  17741. showFooter: false,
  17742. component: external_react_default.a.createElement(MediaLibrary, {
  17743. accepts: mediaProps.accepts,
  17744. onCancel: _this.closeBraftFinder,
  17745. onInsert: _this.insertMedias,
  17746. onChange: mediaProps.onChange,
  17747. externals: mediaProps.externals,
  17748. onBeforeSelect: _this.bindBraftFinderHook('select-medias'),
  17749. onBeforeDeselect: _this.bindBraftFinderHook('deselect-medias'),
  17750. onBeforeRemove: _this.bindBraftFinderHook('remove-medias'),
  17751. onBeforeInsert: _this.bindBraftFinderHook('insert-medias'),
  17752. onFileSelect: _this.bindBraftFinderHook('select-files')
  17753. })
  17754. });
  17755. });
  17756. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "bindBraftFinderHook", function (hookName) {
  17757. return function () {
  17758. return _this.props.hooks(hookName, arguments.length <= 0 ? undefined : arguments[0]).apply(void 0, arguments);
  17759. };
  17760. });
  17761. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertMedias", function (medias) {
  17762. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(_this.props.editorState, medias));
  17763. _this.props.editor.requestFocus();
  17764. _this.props.media.onInsert && _this.props.media.onInsert(medias);
  17765. _this.closeBraftFinder();
  17766. });
  17767. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "closeBraftFinder", function () {
  17768. _this.props.media.onCancel && _this.props.media.onCancel();
  17769. _this.mediaLibiraryModal && _this.mediaLibiraryModal.close();
  17770. });
  17771. return _this;
  17772. }
  17773. createClass_default()(ControlBar, [{
  17774. key: "componentDidUpdate",
  17775. value: function componentDidUpdate() {
  17776. var _this2 = this;
  17777. var language = this.props.language;
  17778. this.allControls.forEach(function (item) {
  17779. if (item.type === 'modal') {
  17780. if (item.modal && item.modal.id && _this2.extendedModals[item.modal.id]) {
  17781. _this2.extendedModals[item.modal.id].update(objectSpread_default()({}, item.modal, {
  17782. language: language
  17783. }));
  17784. }
  17785. }
  17786. });
  17787. }
  17788. }, {
  17789. key: "getControlItemClassName",
  17790. value: function getControlItemClassName(data) {
  17791. var className = 'control-item button';
  17792. var type = data.type,
  17793. command = data.command;
  17794. if (type === 'inline-style' && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(this.props.editorState, command)) {
  17795. className += ' active';
  17796. } else if (type === 'block-type' && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) === command) {
  17797. className += ' active';
  17798. } else if (type === 'entity' && external_braft_utils_["ContentUtils"].getSelectionEntityType(this.props.editorState) === command) {
  17799. className += ' active';
  17800. }
  17801. return className;
  17802. }
  17803. }, {
  17804. key: "applyControl",
  17805. value: function applyControl(command, type) {
  17806. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  17807. var hookReturns = this.props.hooks(commandHookMap[type] || type, command)(command);
  17808. var editorState = this.props.editorState;
  17809. if (hookReturns === false) {
  17810. return false;
  17811. }
  17812. if (typeof hookReturns === 'string') {
  17813. command = hookReturns;
  17814. }
  17815. if (type === 'inline-style') {
  17816. var exclusiveInlineStyle = exclusiveInlineStyles[command];
  17817. if (exclusiveInlineStyle && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(editorState, exclusiveInlineStyle)) {
  17818. editorState = external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, exclusiveInlineStyle);
  17819. }
  17820. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, command));
  17821. } else if (type === 'block-type') {
  17822. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, command));
  17823. } else if (type === 'entity') {
  17824. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionEntity(editorState, {
  17825. type: command,
  17826. mutability: data.mutability || 'MUTABLE',
  17827. data: data.data || {}
  17828. }));
  17829. } else if (type === 'editor-method') {
  17830. this.props.editor[command] && this.props.editor[command]();
  17831. }
  17832. }
  17833. }, {
  17834. key: "render",
  17835. value: function render() {
  17836. var _this3 = this;
  17837. var _this$props = this.props,
  17838. editor = _this$props.editor,
  17839. editorId = _this$props.editorId,
  17840. editorState = _this$props.editorState,
  17841. className = _this$props.className,
  17842. style = _this$props.style,
  17843. controls = _this$props.controls,
  17844. media = _this$props.media,
  17845. extendControls = _this$props.extendControls,
  17846. language = _this$props.language,
  17847. hooks = _this$props.hooks,
  17848. colors = _this$props.colors,
  17849. colorPicker = _this$props.colorPicker,
  17850. colorPickerTheme = _this$props.colorPickerTheme,
  17851. colorPickerAutoHide = _this$props.colorPickerAutoHide,
  17852. headings = _this$props.headings,
  17853. fontSizes = _this$props.fontSizes,
  17854. fontFamilies = _this$props.fontFamilies,
  17855. emojis = _this$props.emojis,
  17856. getContainerNode = _this$props.getContainerNode,
  17857. lineHeights = _this$props.lineHeights,
  17858. letterSpacings = _this$props.letterSpacings,
  17859. textAligns = _this$props.textAligns,
  17860. textBackgroundColor = _this$props.textBackgroundColor,
  17861. allowInsertLinkText = _this$props.allowInsertLinkText,
  17862. defaultLinkTarget = _this$props.defaultLinkTarget;
  17863. var currentBlockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  17864. var commonProps = {
  17865. editor: editor,
  17866. editorId: editorId,
  17867. editorState: editorState,
  17868. language: language,
  17869. getContainerNode: getContainerNode,
  17870. hooks: hooks
  17871. };
  17872. var renderedControls = [];
  17873. var editorControls = configs_controls(language, editor);
  17874. var extensionControls = getExtensionControls(editorId);
  17875. var allControls = mergeControls(commonProps, controls, extensionControls, extendControls);
  17876. this.allControls = allControls;
  17877. return external_react_default.a.createElement("div", {
  17878. className: "bf-controlbar ".concat(className || ''),
  17879. style: style,
  17880. onMouseDown: this.preventDefault
  17881. }, allControls.map(function (item, index) {
  17882. var itemKey = typeof item === 'string' ? item : item.key;
  17883. if (typeof itemKey !== 'string') {
  17884. return null;
  17885. }
  17886. if (renderedControls.indexOf(itemKey) > -1) {
  17887. return null;
  17888. }
  17889. if (itemKey.toLowerCase() === 'separator') {
  17890. return external_react_default.a.createElement("span", {
  17891. key: index,
  17892. className: "separator-line"
  17893. });
  17894. }
  17895. var controlItem = editorControls.find(function (subItem) {
  17896. return subItem.key.toLowerCase() === itemKey.toLowerCase();
  17897. });
  17898. if (typeof item !== 'string') {
  17899. controlItem = objectSpread_default()({}, controlItem, item);
  17900. }
  17901. if (!controlItem) {
  17902. return null;
  17903. }
  17904. renderedControls.push(itemKey);
  17905. if (controlItem.type === 'headings') {
  17906. return external_react_default.a.createElement(Headings, extends_default()({
  17907. key: index,
  17908. headings: headings,
  17909. current: currentBlockType,
  17910. onChange: function onChange(command) {
  17911. return _this3.applyControl(command, 'block-type');
  17912. }
  17913. }, commonProps));
  17914. } else if (controlItem.type === 'text-color') {
  17915. return external_react_default.a.createElement(TextColor_TextColor, extends_default()({
  17916. key: index,
  17917. colors: colors,
  17918. colorPicker: colorPicker,
  17919. theme: colorPickerTheme,
  17920. autoHide: colorPickerAutoHide,
  17921. enableBackgroundColor: textBackgroundColor
  17922. }, commonProps));
  17923. } else if (controlItem.type === 'font-size') {
  17924. return external_react_default.a.createElement(FontSize, extends_default()({
  17925. key: index,
  17926. fontSizes: fontSizes,
  17927. defaultCaption: controlItem.title
  17928. }, commonProps));
  17929. } else if (controlItem.type === 'line-height') {
  17930. return external_react_default.a.createElement(LineHeight, extends_default()({
  17931. key: index,
  17932. lineHeights: lineHeights,
  17933. defaultCaption: controlItem.title
  17934. }, commonProps));
  17935. } else if (controlItem.type === 'letter-spacing') {
  17936. return external_react_default.a.createElement(LetterSpacing, extends_default()({
  17937. key: index,
  17938. letterSpacings: letterSpacings,
  17939. defaultCaption: controlItem.title
  17940. }, commonProps));
  17941. } else if (controlItem.type === 'text-indent') {
  17942. return external_react_default.a.createElement(TextIndent_TextAlign, extends_default()({
  17943. key: index,
  17944. defaultCaption: controlItem.title
  17945. }, commonProps));
  17946. } else if (controlItem.type === 'font-family') {
  17947. return external_react_default.a.createElement(FontFamily, extends_default()({
  17948. key: index,
  17949. fontFamilies: fontFamilies,
  17950. defaultCaption: controlItem.title
  17951. }, commonProps));
  17952. } else if (controlItem.type === 'emoji') {
  17953. return external_react_default.a.createElement(EmojiPicker, extends_default()({
  17954. key: index,
  17955. emojis: emojis,
  17956. defaultCaption: controlItem.text
  17957. }, commonProps));
  17958. } else if (controlItem.type === 'link') {
  17959. return external_react_default.a.createElement(LinkEditor_LinkEditor, extends_default()({
  17960. key: index,
  17961. defaultLinkTarget: defaultLinkTarget,
  17962. allowInsertLinkText: allowInsertLinkText
  17963. }, commonProps));
  17964. } else if (controlItem.type === 'text-align') {
  17965. return external_react_default.a.createElement(TextAlign_TextAlign, extends_default()({
  17966. key: index,
  17967. textAligns: textAligns
  17968. }, commonProps));
  17969. } else if (controlItem.type === 'media') {
  17970. if (!media.image && !media.video && !media.audio) {
  17971. return null;
  17972. }
  17973. return external_react_default.a.createElement("button", {
  17974. type: "button",
  17975. key: index,
  17976. "data-title": controlItem.title,
  17977. disabled: controlItem.disabled,
  17978. className: "control-item media button",
  17979. onClick: _this3.openBraftFinder
  17980. }, controlItem.text);
  17981. } else if (controlItem.type === 'dropdown') {
  17982. return external_react_default.a.createElement(DropDown_DropDown, extends_default()({
  17983. key: index,
  17984. className: "control-item extend-control-item dropdown ".concat(controlItem.className || ''),
  17985. caption: controlItem.text,
  17986. htmlCaption: controlItem.html,
  17987. showArrow: controlItem.showArrow,
  17988. title: controlItem.title,
  17989. arrowActive: controlItem.arrowActive,
  17990. theme: controlItem.theme,
  17991. autoHide: controlItem.autoHide,
  17992. disabled: controlItem.disabled,
  17993. ref: controlItem.ref
  17994. }, commonProps), controlItem.component);
  17995. } else if (controlItem.type === 'modal') {
  17996. return external_react_default.a.createElement("button", {
  17997. type: "button",
  17998. key: index,
  17999. "data-title": controlItem.title,
  18000. disabled: controlItem.disabled,
  18001. className: "control-item extend-control-item button ".concat(controlItem.className || ''),
  18002. dangerouslySetInnerHTML: controlItem.html ? {
  18003. __html: controlItem.html
  18004. } : null,
  18005. onClick: function onClick(event) {
  18006. if (controlItem.modal && controlItem.modal.id) {
  18007. if (_this3.extendedModals[controlItem.modal.id]) {
  18008. _this3.extendedModals[controlItem.modal.id].active = true;
  18009. _this3.extendedModals[controlItem.modal.id].update(objectSpread_default()({}, controlItem.modal, {
  18010. language: language
  18011. }));
  18012. } else {
  18013. _this3.extendedModals[controlItem.modal.id] = Modal_showModal(objectSpread_default()({}, controlItem.modal, {
  18014. language: language
  18015. }));
  18016. controlItem.modal.onCreate && controlItem.modal.onCreate(_this3.extendedModals[controlItem.modal.id]);
  18017. }
  18018. }
  18019. controlItem.onClick && controlItem.onClick(event);
  18020. }
  18021. }, !controlItem.html ? controlItem.text : null);
  18022. } else if (controlItem.type === 'component') {
  18023. return external_react_default.a.createElement("div", {
  18024. key: index,
  18025. className: "component-wrapper ".concat(controlItem.className || '')
  18026. }, controlItem.component);
  18027. } else if (controlItem.type === 'button') {
  18028. return external_react_default.a.createElement("button", {
  18029. type: "button",
  18030. key: index,
  18031. "data-title": controlItem.title,
  18032. disabled: controlItem.disabled,
  18033. className: "control-item button ".concat(controlItem.className || ''),
  18034. dangerouslySetInnerHTML: controlItem.html ? {
  18035. __html: controlItem.html
  18036. } : null,
  18037. onClick: function onClick(event) {
  18038. return controlItem.onClick && controlItem.onClick(event);
  18039. }
  18040. }, !controlItem.html ? controlItem.text : null);
  18041. } else if (controlItem) {
  18042. var disabled = false;
  18043. if (controlItem.command === 'undo') {
  18044. disabled = editorState.getUndoStack().size === 0;
  18045. } else if (controlItem.command === 'redo') {
  18046. disabled = editorState.getRedoStack().size === 0;
  18047. }
  18048. return external_react_default.a.createElement("button", {
  18049. type: "button",
  18050. key: index,
  18051. disabled: disabled,
  18052. "data-title": controlItem.title,
  18053. className: _this3.getControlItemClassName({
  18054. type: controlItem.type,
  18055. command: controlItem.command
  18056. }),
  18057. onClick: function onClick() {
  18058. return _this3.applyControl(controlItem.command, controlItem.type, controlItem.data);
  18059. }
  18060. }, controlItem.text);
  18061. }
  18062. }));
  18063. }
  18064. }, {
  18065. key: "preventDefault",
  18066. value: function preventDefault(event) {
  18067. var tagName = event.target.tagName.toLowerCase();
  18068. if (tagName === 'input' || tagName === 'label') ; else {
  18069. event.preventDefault();
  18070. }
  18071. }
  18072. }]);
  18073. return ControlBar;
  18074. }(external_react_default.a.Component);
  18075. // CONCATENATED MODULE: ./editor/index.jsx
  18076. var buildHooks = function buildHooks(hooks) {
  18077. return function (hookName) {
  18078. var defaultReturns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  18079. return hooks[hookName] || function () {
  18080. return defaultReturns;
  18081. };
  18082. };
  18083. };
  18084. var filterColors = function filterColors(colors, colors2) {
  18085. return colors.filter(function (item) {
  18086. return !colors2.find(function (color) {
  18087. return color.toLowerCase() === item.toLowerCase();
  18088. });
  18089. }).filter(function (item, index, array) {
  18090. return array.indexOf(item) === index;
  18091. });
  18092. };
  18093. var editor_isControlEnabled = function isControlEnabled(props, controlName) {
  18094. return toConsumableArray_default()(props.controls).concat(toConsumableArray_default()(props.extendControls)).find(function (item) {
  18095. return item === controlName || item.key === controlName;
  18096. }) && props.excludeControls.indexOf(controlName) === -1;
  18097. };
  18098. var editor_getConvertOptions = function getConvertOptions(props) {
  18099. var editorId = props.editorId || props.id;
  18100. var convertOptions = objectSpread_default()({}, configs_props.converts, props.converts, {
  18101. fontFamilies: props.fontFamilies
  18102. });
  18103. convertOptions.styleImportFn = compositeStyleImportFn(convertOptions.styleImportFn, editorId);
  18104. convertOptions.styleExportFn = compositeStyleExportFn(convertOptions.styleExportFn, editorId);
  18105. convertOptions.entityImportFn = compositeEntityImportFn(convertOptions.entityImportFn, editorId);
  18106. convertOptions.entityExportFn = compositeEntityExportFn(convertOptions.entityExportFn, editorId);
  18107. convertOptions.blockImportFn = compositeBlockImportFn(convertOptions.blockImportFn, editorId);
  18108. convertOptions.blockExportFn = compositeBlockExportFn(convertOptions.blockExportFn, editorId);
  18109. return convertOptions;
  18110. };
  18111. var editor_BraftEditor =
  18112. /*#__PURE__*/
  18113. function (_React$Component) {
  18114. inherits_default()(BraftEditor, _React$Component);
  18115. function BraftEditor(props) {
  18116. var _this;
  18117. classCallCheck_default()(this, BraftEditor);
  18118. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(BraftEditor).call(this, props));
  18119. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onChange", function (editorState, callback) {
  18120. if (!(editorState instanceof external_draft_js_["EditorState"])) {
  18121. editorState = external_draft_js_["EditorState"].set(editorState, {
  18122. decorator: _this.editorDecorators
  18123. });
  18124. }
  18125. if (!editorState.convertOptions) {
  18126. editorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  18127. }
  18128. _this.setState({
  18129. editorState: editorState
  18130. }, function () {
  18131. _this.props.onChange && _this.props.onChange(editorState);
  18132. callback && callback(editorState);
  18133. });
  18134. });
  18135. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getDraftInstance", function () {
  18136. return _this.draftInstance;
  18137. });
  18138. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getFinderInstance", function () {
  18139. return _this.braftFinder;
  18140. });
  18141. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getValue", function () {
  18142. return _this.state.editorState;
  18143. });
  18144. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setValue", function (editorState, callback) {
  18145. return _this.onChange(editorState, callback);
  18146. });
  18147. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "forceRender", function () {
  18148. var selectionState = _this.state.editorState.getSelection();
  18149. _this.setValue(external_draft_js_["EditorState"].set(_this.state.editorState, {
  18150. decorator: _this.editorDecorators
  18151. }), function () {
  18152. _this.setValue(external_draft_js_["EditorState"].forceSelection(_this.state.editorState, selectionState));
  18153. });
  18154. });
  18155. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onTab", function (event) {
  18156. if (handlers_keyCommandHandlers('tab', _this.state.editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this))) === 'handled') {
  18157. event.preventDefault();
  18158. }
  18159. _this.editorProps.onTab && _this.editorProps.onTab(event);
  18160. });
  18161. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onFocus", function () {
  18162. _this.isFocused = true;
  18163. _this.editorProps.onFocus && _this.editorProps.onFocus(_this.state.editorState);
  18164. });
  18165. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onBlur", function () {
  18166. _this.isFocused = false;
  18167. _this.editorProps.onBlur && _this.editorProps.onBlur(_this.state.editorState);
  18168. });
  18169. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "requestFocus", function () {
  18170. setTimeout(function () {
  18171. return _this.draftInstance.focus();
  18172. }, 0);
  18173. });
  18174. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleKeyCommand", function (command, editorState) {
  18175. return handlers_keyCommandHandlers(command, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  18176. });
  18177. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleReturn", function (event, editorState) {
  18178. return handlers_returnHandlers(event, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  18179. });
  18180. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleBeforeInput", function (chars, editorState) {
  18181. return beforeInputHandlers(chars, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  18182. });
  18183. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDrop", function (selectionState, dataTransfer) {
  18184. return handlers_dropHandlers(selectionState, dataTransfer, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  18185. });
  18186. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDroppedFiles", function (selectionState, files) {
  18187. return droppedFilesHandlers(selectionState, files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  18188. });
  18189. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedFiles", function (files) {
  18190. return pastedFilesHandlers(files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  18191. });
  18192. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCopyContent", function (event) {
  18193. return handlers_copyHandlers(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  18194. });
  18195. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedText", function (text, html, editorState) {
  18196. return handlers_pastedTextHandlers(text, html, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  18197. });
  18198. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCompositionStart", function (event) {
  18199. return handlers_compositionStartHandler(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  18200. });
  18201. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "undo", function () {
  18202. _this.setValue(external_braft_utils_["ContentUtils"].undo(_this.state.editorState));
  18203. });
  18204. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "redo", function () {
  18205. _this.setValue(external_braft_utils_["ContentUtils"].redo(_this.state.editorState));
  18206. });
  18207. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeSelectionInlineStyles", function () {
  18208. _this.setValue(external_braft_utils_["ContentUtils"].removeSelectionInlineStyles(_this.state.editorState));
  18209. });
  18210. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertHorizontalLine", function () {
  18211. _this.setValue(external_braft_utils_["ContentUtils"].insertHorizontalLine(_this.state.editorState));
  18212. });
  18213. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "clearEditorContent", function () {
  18214. _this.setValue(external_braft_utils_["ContentUtils"].clear(_this.state.editorState), function (editorState) {
  18215. _this.setValue(external_braft_utils_["ContentUtils"].toggleSelectionIndent(editorState, 0));
  18216. });
  18217. });
  18218. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleFullscreen", function (fullscreen) {
  18219. _this.setState({
  18220. isFullscreen: typeof fullscreen !== 'undefined' ? fullscreen : !_this.state.isFullscreen
  18221. }, function () {
  18222. _this.editorProps.onFullscreen && _this.editorProps.onFullscreen(_this.state.isFullscreen);
  18223. });
  18224. });
  18225. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setEditorContainerNode", function (containerNode) {
  18226. _this.containerNode = containerNode;
  18227. });
  18228. _this.editorProps = _this.getEditorProps(props);
  18229. _this.editorDecorators = getDecorators(_this.editorProps.editorId || _this.editorProps.id);
  18230. _this.isFocused = false;
  18231. _this.isLiving = false;
  18232. _this.braftFinder = null;
  18233. _this.valueInitialized = !!(_this.props.defaultValue || _this.props.value);
  18234. var defaultEditorState = (_this.props.defaultValue || _this.props.value) instanceof external_draft_js_["EditorState"] ? _this.props.defaultValue || _this.props.value : external_draft_js_["EditorState"].createEmpty(_this.editorDecorators);
  18235. defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  18236. var tempColors = [];
  18237. if (external_braft_utils_["ContentUtils"].isEditorState(defaultEditorState)) {
  18238. var colors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(defaultEditorState.toRAW(true));
  18239. defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  18240. tempColors = filterColors(colors, _this.editorProps.colors);
  18241. }
  18242. _this.state = {
  18243. tempColors: tempColors,
  18244. editorState: defaultEditorState,
  18245. isFullscreen: false,
  18246. draftProps: {}
  18247. };
  18248. _this.containerNode = null;
  18249. return _this;
  18250. }
  18251. createClass_default()(BraftEditor, [{
  18252. key: "getEditorProps",
  18253. value: function getEditorProps(props) {
  18254. var _this2 = this;
  18255. props = props || this.props;
  18256. var _props = props,
  18257. value = _props.value,
  18258. defaultValue = _props.defaultValue,
  18259. onChange = _props.onChange,
  18260. restProps = objectWithoutProperties_default()(_props, ["value", "defaultValue", "onChange"]); // eslint-disable-line no-unused-vars
  18261. var propInterceptors = getPropInterceptors(restProps.editorId || restProps.id);
  18262. if (propInterceptors.length === 0) {
  18263. return restProps;
  18264. }
  18265. var porpsMap = Object(external_immutable_["Map"])(restProps);
  18266. propInterceptors.forEach(function (interceptor) {
  18267. porpsMap = porpsMap.merge(Object(external_immutable_["Map"])(interceptor(porpsMap.toJS(), _this2) || {}));
  18268. });
  18269. return porpsMap.toJS();
  18270. }
  18271. }, {
  18272. key: "componentWillMount",
  18273. value: function componentWillMount() {
  18274. if (editor_isControlEnabled(this.editorProps, 'media')) {
  18275. var _this$editorProps = this.editorProps,
  18276. language = _this$editorProps.language,
  18277. media = _this$editorProps.media;
  18278. var _defaultProps$media$m = objectSpread_default()({}, configs_props.media, media),
  18279. uploadFn = _defaultProps$media$m.uploadFn,
  18280. validateFn = _defaultProps$media$m.validateFn,
  18281. items = _defaultProps$media$m.items;
  18282. this.braftFinder = new external_braft_finder_default.a({
  18283. items: items,
  18284. language: language,
  18285. uploader: uploadFn,
  18286. validator: validateFn
  18287. });
  18288. this.forceUpdate();
  18289. }
  18290. }
  18291. }, {
  18292. key: "componentDidMount",
  18293. value: function componentDidMount() {
  18294. this.isLiving = true;
  18295. }
  18296. }, {
  18297. key: "componentDidUpdate",
  18298. value: function componentDidUpdate(_, prevState) {
  18299. if (prevState.editorState !== this.state.editorState) {
  18300. this.state.editorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
  18301. }
  18302. }
  18303. }, {
  18304. key: "componentWillReceiveProps",
  18305. value: function componentWillReceiveProps(props) {
  18306. var _this3 = this;
  18307. this.editorProps = this.getEditorProps(props);
  18308. var editorState = props.value;
  18309. var _this$editorProps2 = this.editorProps,
  18310. media = _this$editorProps2.media,
  18311. language = _this$editorProps2.language;
  18312. var currentProps = this.getEditorProps();
  18313. if (!editor_isControlEnabled(currentProps, 'media') && editor_isControlEnabled(this.editorProps, 'media') && !this.braftFinder) {
  18314. var _defaultProps$media$m2 = objectSpread_default()({}, configs_props.media, media),
  18315. uploadFn = _defaultProps$media$m2.uploadFn,
  18316. validateFn = _defaultProps$media$m2.validateFn,
  18317. items = _defaultProps$media$m2.items;
  18318. this.braftFinder = new external_braft_finder_default.a({
  18319. items: items,
  18320. language: language,
  18321. uploader: uploadFn,
  18322. validator: validateFn
  18323. });
  18324. this.forceUpdate();
  18325. }
  18326. if (media && media.items && this.braftFinder) {
  18327. this.braftFinder.setItems(media.items);
  18328. }
  18329. var nextEditorState;
  18330. if (!this.valueInitialized && typeof this.props.defaultValue === 'undefined' && external_braft_utils_["ContentUtils"].isEditorState(props.defaultValue)) {
  18331. nextEditorState = props.defaultValue;
  18332. } else if (external_braft_utils_["ContentUtils"].isEditorState(editorState)) {
  18333. nextEditorState = editorState;
  18334. }
  18335. if (nextEditorState) {
  18336. if (nextEditorState && nextEditorState !== this.state.editorState) {
  18337. var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(nextEditorState.toRAW(true));
  18338. nextEditorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
  18339. this.setState({
  18340. tempColors: filterColors(toConsumableArray_default()(this.state.tempColors).concat(toConsumableArray_default()(tempColors)), currentProps.colors),
  18341. editorState: nextEditorState
  18342. }, function () {
  18343. _this3.props.onChange && _this3.props.onChange(nextEditorState);
  18344. });
  18345. } else {
  18346. this.setState({
  18347. editorState: nextEditorState
  18348. });
  18349. }
  18350. }
  18351. }
  18352. }, {
  18353. key: "componentWillUnmount",
  18354. value: function componentWillUnmount() {
  18355. this.isLiving = false;
  18356. this.controlBarInstance && this.controlBarInstance.closeBraftFinder();
  18357. }
  18358. }, {
  18359. key: "lockOrUnlockEditor",
  18360. value: function lockOrUnlockEditor(editorLocked) {
  18361. this.setState({
  18362. editorLocked: editorLocked
  18363. });
  18364. }
  18365. }, {
  18366. key: "render",
  18367. value: function render() {
  18368. var _this4 = this;
  18369. var _this$editorProps3 = this.editorProps,
  18370. id = _this$editorProps3.id,
  18371. editorId = _this$editorProps3.editorId,
  18372. controls = _this$editorProps3.controls,
  18373. excludeControls = _this$editorProps3.excludeControls,
  18374. extendControls = _this$editorProps3.extendControls,
  18375. readOnly = _this$editorProps3.readOnly,
  18376. disabled = _this$editorProps3.disabled,
  18377. media = _this$editorProps3.media,
  18378. language = _this$editorProps3.language,
  18379. colors = _this$editorProps3.colors,
  18380. colorPicker = _this$editorProps3.colorPicker,
  18381. colorPickerTheme = _this$editorProps3.colorPickerTheme,
  18382. colorPickerAutoHide = _this$editorProps3.colorPickerAutoHide,
  18383. hooks = _this$editorProps3.hooks,
  18384. fontSizes = _this$editorProps3.fontSizes,
  18385. fontFamilies = _this$editorProps3.fontFamilies,
  18386. emojis = _this$editorProps3.emojis,
  18387. placeholder = _this$editorProps3.placeholder,
  18388. fixPlaceholder = _this$editorProps3.fixPlaceholder,
  18389. headings = _this$editorProps3.headings,
  18390. imageControls = _this$editorProps3.imageControls,
  18391. imageResizable = _this$editorProps3.imageResizable,
  18392. lineHeights = _this$editorProps3.lineHeights,
  18393. letterSpacings = _this$editorProps3.letterSpacings,
  18394. textAligns = _this$editorProps3.textAligns,
  18395. textBackgroundColor = _this$editorProps3.textBackgroundColor,
  18396. allowInsertLinkText = _this$editorProps3.allowInsertLinkText,
  18397. defaultLinkTarget = _this$editorProps3.defaultLinkTarget,
  18398. extendAtomics = _this$editorProps3.extendAtomics,
  18399. className = _this$editorProps3.className,
  18400. style = _this$editorProps3.style,
  18401. controlBarClassName = _this$editorProps3.controlBarClassName,
  18402. controlBarStyle = _this$editorProps3.controlBarStyle,
  18403. contentClassName = _this$editorProps3.contentClassName,
  18404. contentStyle = _this$editorProps3.contentStyle,
  18405. stripPastedStyles = _this$editorProps3.stripPastedStyles,
  18406. componentBelowControlBar = _this$editorProps3.componentBelowControlBar;
  18407. var _this$state = this.state,
  18408. isFullscreen = _this$state.isFullscreen,
  18409. editorState = _this$state.editorState;
  18410. editorId = editorId || id;
  18411. hooks = buildHooks(hooks);
  18412. controls = controls.filter(function (item) {
  18413. return excludeControls.indexOf(item) === -1;
  18414. });
  18415. language = (typeof language === 'function' ? language(languages, 'braft-editor') : languages[language]) || languages[configs_props.language];
  18416. var externalMedias = media && media.externals ? objectSpread_default()({}, configs_props.media.externals, media.externals) : configs_props.media.externals;
  18417. var accepts = media && media.accepts ? objectSpread_default()({}, configs_props.media.accepts, media.accepts) : configs_props.media.accepts;
  18418. media = objectSpread_default()({}, configs_props.media, media, {
  18419. externalMedias: externalMedias,
  18420. accepts: accepts
  18421. });
  18422. if (!media.uploadFn) {
  18423. media.video = false;
  18424. media.audio = false;
  18425. }
  18426. var controlBarProps = {
  18427. editor: this,
  18428. editorState: editorState,
  18429. braftFinder: this.braftFinder,
  18430. ref: function ref(instance) {
  18431. return _this4.controlBarInstance = instance;
  18432. },
  18433. getContainerNode: function getContainerNode() {
  18434. return _this4.containerNode;
  18435. },
  18436. className: controlBarClassName,
  18437. style: controlBarStyle,
  18438. colors: toConsumableArray_default()(colors).concat(toConsumableArray_default()(this.state.tempColors)),
  18439. colorPicker: colorPicker,
  18440. colorPickerTheme: colorPickerTheme,
  18441. colorPickerAutoHide: colorPickerAutoHide,
  18442. hooks: hooks,
  18443. editorId: editorId,
  18444. media: media,
  18445. controls: controls,
  18446. language: language,
  18447. extendControls: extendControls,
  18448. headings: headings,
  18449. fontSizes: fontSizes,
  18450. fontFamilies: fontFamilies,
  18451. emojis: emojis,
  18452. lineHeights: lineHeights,
  18453. letterSpacings: letterSpacings,
  18454. textAligns: textAligns,
  18455. textBackgroundColor: textBackgroundColor,
  18456. allowInsertLinkText: allowInsertLinkText,
  18457. defaultLinkTarget: defaultLinkTarget
  18458. };
  18459. var unitExportFn = editorState.convertOptions.unitExportFn;
  18460. var commonProps = {
  18461. editor: this,
  18462. editorId: editorId,
  18463. hooks: hooks,
  18464. editorState: editorState,
  18465. containerNode: this.containerNode,
  18466. imageControls: imageControls,
  18467. imageResizable: imageResizable,
  18468. language: language,
  18469. extendAtomics: extendAtomics
  18470. };
  18471. var blockRendererFn = getBlockRendererFn(commonProps, this.editorProps.blockRendererFn);
  18472. var blockRenderMap = getBlockRenderMap(commonProps, this.editorProps.blockRenderMap);
  18473. var blockStyleFn = getBlockStyleFn(this.editorProps.blockStyleFn);
  18474. var customStyleMap = getCustomStyleMap(commonProps, this.editorProps.customStyleMap);
  18475. var customStyleFn = getCustomStyleFn(commonProps, {
  18476. fontFamilies: fontFamilies,
  18477. unitExportFn: unitExportFn,
  18478. customStyleFn: this.editorProps.customStyleFn
  18479. });
  18480. var keyBindingFn = keybindings(this.editorProps.keyBindingFn);
  18481. var mixedProps = {};
  18482. if (this.state.editorLocked || this.editorProps.disabled || this.editorProps.readOnly || this.editorProps.draftProps.readOnly) {
  18483. mixedProps.readOnly = true;
  18484. }
  18485. if (placeholder && fixPlaceholder && editorState.isEmpty() && editorState.getCurrentContent().getFirstBlock().getType() !== 'unstyled') {
  18486. placeholder = '';
  18487. }
  18488. var draftProps = objectSpread_default()({
  18489. ref: function ref(instance) {
  18490. _this4.draftInstance = instance;
  18491. },
  18492. editorState: editorState,
  18493. handleKeyCommand: this.handleKeyCommand,
  18494. handleReturn: this.handleReturn,
  18495. handleBeforeInput: this.handleBeforeInput,
  18496. handleDrop: this.handleDrop,
  18497. handleDroppedFiles: this.handleDroppedFiles,
  18498. handlePastedText: this.handlePastedText,
  18499. handlePastedFiles: this.handlePastedFiles,
  18500. onChange: this.onChange,
  18501. onTab: this.onTab,
  18502. onFocus: this.onFocus,
  18503. onBlur: this.onBlur,
  18504. blockRenderMap: blockRenderMap,
  18505. blockRendererFn: blockRendererFn,
  18506. blockStyleFn: blockStyleFn,
  18507. customStyleMap: customStyleMap,
  18508. customStyleFn: customStyleFn,
  18509. keyBindingFn: keyBindingFn,
  18510. placeholder: placeholder,
  18511. stripPastedStyles: stripPastedStyles
  18512. }, this.editorProps.draftProps, mixedProps);
  18513. return external_react_default.a.createElement("div", {
  18514. style: style,
  18515. ref: this.setEditorContainerNode,
  18516. className: "bf-container ".concat(className).concat(disabled ? ' disabled' : '').concat(readOnly ? ' read-only' : '').concat(isFullscreen ? ' fullscreen' : '')
  18517. }, external_react_default.a.createElement(ControlBar_ControlBar, controlBarProps), componentBelowControlBar, external_react_default.a.createElement("div", {
  18518. onCompositionStart: this.handleCompositionStart,
  18519. className: "bf-content ".concat(contentClassName),
  18520. onCopy: this.handleCopyContent,
  18521. style: contentStyle
  18522. }, external_react_default.a.createElement(external_draft_js_["Editor"], draftProps)));
  18523. }
  18524. }]);
  18525. return BraftEditor;
  18526. }(external_react_default.a.Component);
  18527. defineProperty_default()(editor_BraftEditor, "defaultProps", configs_props);
  18528. // EXTERNAL MODULE: external "braft-convert"
  18529. var external_braft_convert_ = __webpack_require__(14);
  18530. // CONCATENATED MODULE: ./index.jsx
  18531. /* concated harmony reexport EditorState */__webpack_require__.d(__webpack_exports__, "EditorState", function() { return external_draft_js_["EditorState"]; });
  18532. /* concated harmony reexport getDecorators */__webpack_require__.d(__webpack_exports__, "getDecorators", function() { return getDecorators; });
  18533. external_draft_js_["EditorState"].prototype.setConvertOptions = function () {
  18534. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  18535. this.convertOptions = options;
  18536. };
  18537. external_draft_js_["EditorState"].prototype.toHTML = function () {
  18538. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  18539. var convertOptions = this.convertOptions || {};
  18540. return Object(external_braft_convert_["convertEditorStateToHTML"])(this, objectSpread_default()({}, convertOptions, options));
  18541. };
  18542. external_draft_js_["EditorState"].prototype.toRAW = function (noStringify) {
  18543. return noStringify ? Object(external_braft_convert_["convertEditorStateToRaw"])(this) : JSON.stringify(Object(external_braft_convert_["convertEditorStateToRaw"])(this));
  18544. };
  18545. external_draft_js_["EditorState"].prototype.toText = function () {
  18546. return this.getCurrentContent().getPlainText();
  18547. };
  18548. external_draft_js_["EditorState"].prototype.isEmpty = function () {
  18549. return !this.getCurrentContent().hasText();
  18550. };
  18551. editor_BraftEditor.createEditorState = external_draft_js_["EditorState"].createFrom = function (content) {
  18552. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  18553. options.unitExportFn = options.unitExportFn || editor_BraftEditor.defaultProps.converts.unitExportFn;
  18554. options.styleImportFn = compositeStyleImportFn(options.styleImportFn, options.editorId);
  18555. options.entityImportFn = compositeEntityImportFn(options.entityImportFn, options.editorId);
  18556. options.blockImportFn = compositeBlockImportFn(options.blockImportFn, options.editorId);
  18557. var editorState = null;
  18558. if (content instanceof external_draft_js_["EditorState"]) {
  18559. editorState = content;
  18560. } else if (typeof_default()(content) === 'object' && content && content.blocks && content.entityMap) {
  18561. editorState = Object(external_braft_convert_["convertRawToEditorState"])(content, getDecorators(options.editorId));
  18562. } else if (typeof content === 'string') {
  18563. try {
  18564. if (/^(-)?\d+$/.test(content)) {
  18565. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
  18566. } else {
  18567. editorState = external_draft_js_["EditorState"].createFrom(JSON.parse(content), options);
  18568. }
  18569. } catch (error) {
  18570. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
  18571. }
  18572. } else if (typeof content === 'number') {
  18573. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content.toLocaleString().replace(/,/g, ''), getDecorators(options.editorId), options, 'create');
  18574. } else {
  18575. editorState = external_draft_js_["EditorState"].createEmpty(getDecorators(options.editorId));
  18576. }
  18577. options.styleExportFn = compositeStyleExportFn(options.styleExportFn, options.editorId);
  18578. options.entityExportFn = compositeEntityExportFn(options.entityExportFn, options.editorId);
  18579. options.blockExportFn = compositeBlockExportFn(options.blockExportFn, options.editorId);
  18580. editorState.setConvertOptions(options);
  18581. return editorState;
  18582. };
  18583. /* harmony default export */ var index_0 = __webpack_exports__["default"] = (createExtensibleEditor(editor_BraftEditor));
  18584. // 2.1版本开发计划
  18585. // [ ]优化选中多行文字是插入链接报错的问题
  18586. // [ ]新增编辑器内图片删除hook
  18587. // 2.2版本开发计划
  18588. // [ ]表格功能
  18589. // [ ]美化UI,包括图标和界面风格
  18590. // 2.3版本开发计划
  18591. // [ ]初级md快捷输入支持
  18592. // [ ]图片裁切等简单的编辑功能
  18593. // [ ]允许自定义快捷键
  18594. /***/ }),
  18595. /* 40 */
  18596. /***/ (function(module, exports) {
  18597. // removed by extract-text-webpack-plugin
  18598. /***/ }),
  18599. /* 41 */,
  18600. /* 42 */
  18601. /***/ (function(module, exports) {
  18602. // removed by extract-text-webpack-plugin
  18603. /***/ }),
  18604. /* 43 */,
  18605. /* 44 */,
  18606. /* 45 */
  18607. /***/ (function(module, exports) {
  18608. // removed by extract-text-webpack-plugin
  18609. /***/ }),
  18610. /* 46 */
  18611. /***/ (function(module, exports) {
  18612. // removed by extract-text-webpack-plugin
  18613. /***/ }),
  18614. /* 47 */
  18615. /***/ (function(module, exports) {
  18616. // removed by extract-text-webpack-plugin
  18617. /***/ }),
  18618. /* 48 */
  18619. /***/ (function(module, exports) {
  18620. // removed by extract-text-webpack-plugin
  18621. /***/ }),
  18622. /* 49 */
  18623. /***/ (function(module, exports) {
  18624. // removed by extract-text-webpack-plugin
  18625. /***/ }),
  18626. /* 50 */
  18627. /***/ (function(module, exports) {
  18628. // removed by extract-text-webpack-plugin
  18629. /***/ }),
  18630. /* 51 */
  18631. /***/ (function(module, exports) {
  18632. // removed by extract-text-webpack-plugin
  18633. /***/ }),
  18634. /* 52 */
  18635. /***/ (function(module, exports) {
  18636. // removed by extract-text-webpack-plugin
  18637. /***/ }),
  18638. /* 53 */
  18639. /***/ (function(module, exports) {
  18640. // removed by extract-text-webpack-plugin
  18641. /***/ }),
  18642. /* 54 */
  18643. /***/ (function(module, exports) {
  18644. // removed by extract-text-webpack-plugin
  18645. /***/ }),
  18646. /* 55 */
  18647. /***/ (function(module, exports) {
  18648. // removed by extract-text-webpack-plugin
  18649. /***/ }),
  18650. /* 56 */
  18651. /***/ (function(module, exports) {
  18652. // removed by extract-text-webpack-plugin
  18653. /***/ }),
  18654. /* 57 */
  18655. /***/ (function(module, exports) {
  18656. // removed by extract-text-webpack-plugin
  18657. /***/ }),
  18658. /* 58 */
  18659. /***/ (function(module, exports) {
  18660. // removed by extract-text-webpack-plugin
  18661. /***/ }),
  18662. /* 59 */
  18663. /***/ (function(module, exports) {
  18664. // removed by extract-text-webpack-plugin
  18665. /***/ }),
  18666. /* 60 */
  18667. /***/ (function(module, exports) {
  18668. // removed by extract-text-webpack-plugin
  18669. /***/ }),
  18670. /* 61 */
  18671. /***/ (function(module, exports) {
  18672. // removed by extract-text-webpack-plugin
  18673. /***/ }),
  18674. /* 62 */
  18675. /***/ (function(module, exports) {
  18676. // removed by extract-text-webpack-plugin
  18677. /***/ }),
  18678. /* 63 */
  18679. /***/ (function(module, exports) {
  18680. // removed by extract-text-webpack-plugin
  18681. /***/ })
  18682. /******/ ]);
  18683. });
  18684. });
  18685. var BraftEditor = _commonjsHelpers.unwrapExports(dist$3);
  18686. var css = ".index_bf-controlbar__ej8fA{margin:0;padding:0 5px;box-shadow:inset 0 -1px 0 0 rgba(0,0,0,.2)}.index_bf-controlbar__ej8fA:after{display:block;content:\"\";clear:both}.index_bf-controlbar__ej8fA button{padding:0;outline:none}.index_bf-controlbar__ej8fA button[disabled]{pointer-events:none;opacity:.3}.index_bf-controlbar__ej8fA [data-title]{position:relative}.index_bf-controlbar__ej8fA [data-title]:after,.index_bf-controlbar__ej8fA [data-title]:before{position:absolute;z-index:10;top:100%;left:50%;pointer-events:none;opacity:0;transform:translateX(-50%) translateY(-5px);transition:opacity .3s,transform .3s}.index_bf-controlbar__ej8fA [data-title]:before{margin-top:3px;border:5px solid transparent;border-bottom-color:#21242a;content:\"\"}.index_bf-controlbar__ej8fA [data-title]:after{margin-top:12px;padding:5px;background-color:#21242a;border-radius:2px;box-shadow:0 5px 15px rgba(0,0,0,.2);color:#fff;font-size:12px;line-height:16px;white-space:nowrap;content:attr(data-title)}.index_bf-controlbar__ej8fA [data-title]:hover:after,.index_bf-controlbar__ej8fA [data-title]:hover:before{opacity:1;transform:translateX(-50%) translateY(0)}.index_bf-controlbar__ej8fA input{outline:none}.index_bf-controlbar__ej8fA .index_separator-line__3SV92{display:block;float:left;height:26px;width:1px;margin:10px;box-shadow:inset -1px 0 0 0 rgba(0,0,0,.1)}.index_bf-controlbar__ej8fA .index_separator-line__3SV92+.index_control-item__2E9Ul,.index_bf-controlbar__ej8fA .index_separator-line__3SV92+.index_control-item-group__2GENZ{margin-left:0}.index_bf-controlbar__ej8fA .index_separator-line__3SV92+.index_separator-line__3SV92,.index_bf-controlbar__ej8fA .index_separator-line__3SV92.index_first-child__2fRfM,.index_bf-controlbar__ej8fA .index_separator-line__3SV92.index_last-child__1d0yb{display:none}.index_bf-controlbar__ej8fA .index_control-item-group__2GENZ{float:left;height:36px;margin:5px 0 5px 3px}.index_bf-controlbar__ej8fA .index_control-item-group__2GENZ:first-child{margin-left:0}.index_bf-controlbar__ej8fA .index_control-item-group__2GENZ>.index_control-item__2E9Ul{margin-top:0;margin-bottom:0}.index_bf-controlbar__ej8fA .index_dropdown-handler__1xChS{border-radius:2px}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul{display:block;float:left;height:36px;margin:5px 0 5px 3px;border-radius:2px;cursor:pointer}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_component-wrapper__OLlmp{cursor:default}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul:first-child{margin-left:0}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw{box-sizing:border-box;min-width:36px;padding:0 8px;background-color:transparent;border:none;color:#6a6f7b;font-size:14px}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw:hover{background-color:rgba(0,0,0,.05)}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw.index_active__3_mlp{color:#3498db}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw i:before{display:block;height:36px;font-size:18px;line-height:36px}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw .index_bfi-redo__1Q-LG:before,.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw .index_bfi-undo___pDce:before{font-size:14px}.index_bf-controlbar__ej8fA .index_dropdown__1rkgF .index_control-item__2E9Ul{width:100%;float:none;margin:0}.index_DraftEditor-editorContainer__1FR0o,.index_DraftEditor-root__mlfOI,.index_public-DraftEditor-content__T2mZu{height:inherit;text-align:initial}.index_public-DraftEditor-content__T2mZu[contenteditable=true]{-webkit-user-modify:read-write-plaintext-only}.index_DraftEditor-root__mlfOI{position:relative}.index_DraftEditor-editorContainer__1FR0o{background-color:hsla(0,0%,100%,0);border-left:.1px solid transparent;position:relative;z-index:1}.index_public-DraftEditor-block__IOQ0s{position:relative}.index_DraftEditor-alignLeft__gR9_E .index_public-DraftStyleDefault-block__3m05I{text-align:left}.index_DraftEditor-alignLeft__gR9_E .index_public-DraftEditorPlaceholder-root__1T6lJ{left:0;text-align:left}.index_DraftEditor-alignCenter__3Fyko .index_public-DraftStyleDefault-block__3m05I{text-align:center}.index_DraftEditor-alignCenter__3Fyko .index_public-DraftEditorPlaceholder-root__1T6lJ{margin:0 auto;text-align:center;width:100%}.index_DraftEditor-alignRight__3ghf4 .index_public-DraftStyleDefault-block__3m05I{text-align:right}.index_DraftEditor-alignRight__3ghf4 .index_public-DraftEditorPlaceholder-root__1T6lJ{right:0;text-align:right}.index_public-DraftEditorPlaceholder-root__1T6lJ{color:#9197a3;position:absolute;z-index:1}.index_public-DraftEditorPlaceholder-hasFocus__kQoHC{color:#bdc1c9}.index_DraftEditorPlaceholder-hidden__22I_U{display:none}.index_public-DraftStyleDefault-block__3m05I{position:relative;white-space:pre-wrap}.index_public-DraftStyleDefault-ltr__3qMdW{direction:ltr;text-align:left}.index_public-DraftStyleDefault-rtl__2k3sG{direction:rtl;text-align:right}.index_public-DraftStyleDefault-listLTR__Mmamr{direction:ltr}.index_public-DraftStyleDefault-listRTL__2WhLE{direction:rtl}.index_public-DraftStyleDefault-ol__32plX,.index_public-DraftStyleDefault-ul__1_opE{margin:16px 0;padding:0}.index_public-DraftStyleDefault-depth0__2YvNJ.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:1.5em}.index_public-DraftStyleDefault-depth0__2YvNJ.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:1.5em}.index_public-DraftStyleDefault-depth1__3dbfg.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:3em}.index_public-DraftStyleDefault-depth1__3dbfg.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:3em}.index_public-DraftStyleDefault-depth2__2mADP.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:4.5em}.index_public-DraftStyleDefault-depth2__2mADP.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:4.5em}.index_public-DraftStyleDefault-depth3__1V80Q.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:6em}.index_public-DraftStyleDefault-depth3__1V80Q.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:6em}.index_public-DraftStyleDefault-depth4__9Zzf6.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:7.5em}.index_public-DraftStyleDefault-depth4__9Zzf6.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:7.5em}.index_public-DraftStyleDefault-unorderedListItem__fNkjl{list-style-type:square;position:relative}.index_public-DraftStyleDefault-unorderedListItem__fNkjl.index_public-DraftStyleDefault-depth0__2YvNJ{list-style-type:disc}.index_public-DraftStyleDefault-unorderedListItem__fNkjl.index_public-DraftStyleDefault-depth1__3dbfg{list-style-type:circle}.index_public-DraftStyleDefault-orderedListItem__3J0MZ{list-style-type:none;position:relative}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-listLTR__Mmamr:before{left:-36px;position:absolute;text-align:right;width:30px}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-listRTL__2WhLE:before{position:absolute;right:-36px;text-align:left;width:30px}.index_public-DraftStyleDefault-orderedListItem__3J0MZ:before{content:counter(a) \". \";counter-increment:a}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth1__3dbfg:before{content:counter(b) \". \";counter-increment:b}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth2__2mADP:before{content:counter(c) \". \";counter-increment:c}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth3__1V80Q:before{content:counter(d) \". \";counter-increment:d}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth4__9Zzf6:before{content:counter(e) \". \";counter-increment:e}.index_public-DraftStyleDefault-depth0__2YvNJ.index_public-DraftStyleDefault-reset__1awm7{counter-reset:a}.index_public-DraftStyleDefault-depth1__3dbfg.index_public-DraftStyleDefault-reset__1awm7{counter-reset:b}.index_public-DraftStyleDefault-depth2__2mADP.index_public-DraftStyleDefault-reset__1awm7{counter-reset:c}.index_public-DraftStyleDefault-depth3__1V80Q.index_public-DraftStyleDefault-reset__1awm7{counter-reset:d}.index_public-DraftStyleDefault-depth4__9Zzf6.index_public-DraftStyleDefault-reset__1awm7{counter-reset:e}.index_bf-switch__1LPr-{position:relative;width:32px;height:16px;background-color:hsla(0,0%,100%,.15);border-radius:8px;transition:background .3s}.index_bf-switch__1LPr-.index_active__3_mlp{background-color:#3498db}.index_bf-switch__1LPr-.index_active__3_mlp:before{left:16px}.index_bf-switch__1LPr-:before{position:absolute;left:0;display:block;width:16px;height:16px;border-radius:8px;background-color:#eee;content:\"\";transform:scale(1.2);transition:.3s}@font-face{font-family:braft-icons;src:url(data:application/font-woff;base64,d09GRgABAAAAACxUAAsAAAAALAgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABCAAAAGAAAABgDxIH02NtYXAAAAFoAAAA9AAAAPQXCcwWZ2FzcAAAAlwAAAAIAAAACAAAABBnbHlmAAACZAAAJggAACYI9aImY2hlYWQAAChsAAAANgAAADYTSfwFaGhlYQAAKKQAAAAkAAAAJAfCBAxobXR4AAAoyAAAASwAAAEsIgAgXGxvY2EAACn0AAAAmAAAAJhQxVqgbWF4cAAAKowAAAAgAAAAIABVAH1uYW1lAAAqrAAAAYYAAAGGmUoJ+3Bvc3QAACw0AAAAIAAAACAAAwAAAAMD+QGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAA6rADwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEANgAAAAyACAABAASAAEAIOAp4DTgN+BC4LjiKOI547jjwuQp6SbpMelG6WjpgOms6mjqbOpu6nXqsP/9//8AAAAAACDgJuA04DfgQuC44ijiOeO448LkKekA6SzpRuln6YDprOpo6mvqbupz6rD//f//AAH/4x/eH9Qf0h/IH1Md5B3UHFYcTRvnFxEXDBb4FtgWwRaWFdsV2RXYFdQVmgADAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAPAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAQAVQCAA6sC1QARACMANQBHAAATITIXFhUUBwYjISInJjU0NzYTITIXFhUUBwYjISInJjU0NzY3ITIXFhUUBwYjISInJjU0NzY3ITIXFhUUBwYjISInJjU0NzaAAwASDA0NDBL9ABIMDQ0MEgMAEgwNDQwS/QASDA0NDBIDABIMDQ0MEv0AEgwNDQwSAwASDA0NDBL9ABIMDQ0MAtUMDRESDQwMDRIRDQz+AAwNERINDAwNEhENDKsNDBIRDQwMDRESDA2rDQwSEgwNDQwSEgwNAAAABABVAIADqwLVABEAIwA1AEcAABMhMhcWFRQHBiMhIicmNTQ3NhMhMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NoADABIMDQ0MEv0AEgwNDQwSAlUSDA0MDRL9qxIMDQ0MEgMAEgwNDQwS/QASDA0NDBICVRIMDQwNEv2rEgwNDQwC1QwNERINDAwNEhENDP4ADA0REg0MDA0SEQ0Mqw0MEhENDAwNERIMDasNDBISDA0NDBISDA0AAAAEAFUAgAOrAtUAEQAkADYASQAAEyEyFxYVFAcGIyEiJyY1NDc2EyEyFxYVFAcGIyEiJyY1NDc2MychMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NjOAAwASDA0NDBL9ABIMDQ0MZwJWEQ0MDA0R/aoRDQwMDRFVAwASDA0NDBL9ABIMDQ0MZwJWEQ0MDA0R/aoRDQwMDREC1QwNERINDAwNEhENDP4ADA0REg0MDA0SEQ0Mqw0MEhENDAwNERIMDasNDBISDA0NDBISDA0AAAAEAFUAgAOrAtUAEQAkADYASQAAEyEyFxYVFAcGIyEiJyY1NDc2EyEyFxYVFAcGIyEiJyY1NDc2MychMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NjOAAwASDA0NDBL9ABIMDQ0MvQJVEgwNDQwS/asSDA0MDRKrAwASDA0NDBL9ABIMDQ0MvQJVEgwNDQwS/asSDA0MDRIC1QwNERINDAwNEhENDP4ADA0REg0MDA0SEQ0Mqw0MEhENDAwNERIMDasNDBISDA0NDBISDA0AAAACAQAAgQMAAtUAAwAHAAABMxEjIREzEQJWqqr+qqoC1f2sAlT9rAAAAQFWAIEDKgLVAAIAAAkCAVYB1P4sAtX+1v7WAAEAqgArA1YDgQAuAAABMhceARcWFRQHDgEHBiMiJy4BJyY1MxQXHgEXFjMyNz4BNzY1NCcuAScmIxUnNwIARj8+XRsbGxtdPj5HRj8+XRsbVhQURS8vNTUvL0UUFBQURS8vNdbWAtUbG1w+PkZHPj5dGxsbG10+Pkc2Li9FFBQUFEUvLjY1Ly5GFBSs1tYAAAMAMwCqA80CqwAEAAkADQAAEyEVITUDNSEVITc1IRX/As79MswCzv0yaALKAqtnZ/3/Z2fOZWUABQCAACsDgAMrAAMABwALAA8AEwAAAREhEQERIREDESERAREhEQMhESEDKv8AAQD/AFT/AAEA/wBWAwD9AAHVAQD/AP6sAQD/AAFUAQD/AP6sAQD/AAKq/QAAAAACAFYAKwNWAtUACAARAAABIRUjByc3IycnFwEHJwcjNwEBAAJW+ERaHmZ4dAwCaDbyQoBo/tgC1YCgWEh4CAr9ljbynPYBKAACAIAAKwN0Ax8AAwAWAAAlAScBAR4BDwEXBycBIzUBJzcXNzYyFwEoAVhS/qgCngwBDYZSPDz+gsoBfDw8UoYMJAyBAVhS/qgB6AwjDYZSPDz+hMoBfjw8UoYMDAAAAAAEAIAAKwOAAysACAARABoAIwAAATIWHQEjNSM1EzUzFRQGKwE1JRUzFSMiJj0BETQ2OwEVIxUjAyoiNFaqqlYzI6r+VqqqIjQzI6qqVgMrNCKqqlb9VqqqIzNWqqpWMyOqAaoiNFaqAAYAgAArA4ADKwAHAAsAEwAbAB8AIwAAAREzFTMVIxUXITUhJTMRIzUjNTMBIxEzFSEVIQEhFSERIRUhAoBWqqqq/lYBqv2qVlaqqgEAVFQBVv6q/lYBqv5WAQD/AAIrAQBWVFaqVFb/AFZU/lYBAFZUAlRU/lRUAAIAgABNA4ADTQATAB0AACUhESE1ISIGFREUFjMhMjY1ESMRAxUzARcBFTMRIQMr/aoBK/7VIzIyIwJWIzJV1pr+XDwBpFX+1aICVVYyJP2rIzIyIwEr/tUCq1b+XTwBo5kBKwAEAFUAIgOrA3cABAAhAD0AQgAAJTMRIxETIgcOAQcGFRQXHgEXFjMyNz4BNzY1NCcuAScmIxEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYDMzUjFQHVVlYrWE5OdCEiIiF0Tk5YWE5OdCEiIiF0Tk5YRz4+XRobGxpdPj5HRz4+XRobGxpdPj5yVlb3AQD/AAKAISJzTk5YWU1OdCEiIiF0Tk1ZWE5OcyIh/QAbG10+PkdGPz5cGxsbG1w+P0ZHPj5dGxsB1lVVAAAEAFUAIgOrA3cABAAhAD0AUgAAJTM1IxUTIgcOAQcGFRQXHgEXFjMyNz4BNzY1NCcuAScmIxEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYDIgYVMzQ2MzIWFRQGFTM0NjU0JiMB1VZWK1hOTnQhIiIhdE5OWFhOTnQhIiIhdE5OWEc+Pl0aGxsaXT4+R0c+Pl0aGxsaXT4+R0dkVjIjIzKAVoBkR81VVQKqISJzTk5YWU1OdCEiIiF0Tk1ZWE5OcyIh/QAbG10+PkdGPz5cGxsbG1w+P0ZHPj5dGxsCVmRHIzIyI0AtaEg9UEdkAAACAFUAzQOrAs0ABQALAAABJzcnCQElNyc3CQEBkcTEPP8AAQABGsTEPAEA/wABCcTEPP8A/wA8xMQ8/wD/AAAAAwErAM0C9QMiAA8AGQAiAAABPgE1NCYjIREhMjY1NCYnJzMyFhUUBisBNRMjNTMyFhUUBgKaHydjSP72ASxDWzIp74AaJiYagJWVlRslJQIAFkEgSWL9q19DME4TtyUbGiaA/oCAJRsaJgAAAQCAACYDgAN3ADQAAAEiBgclPgE1NCYnJR4BMzI2NTQmIyIGFRQWFwUuASMiBhUUFjMyNjcFDgEVFBYzMjY1NCYjAwAYKxH+0AICAgIBLREtGTVLSzU1SwIC/tMRLRk1S0s1GS0RATACAkk0NElJNAEfEg+xBw8IBw8IrxATSzU2Sko2Bw8HsBATSzU1SxIQsQcOBzNJSTM0SQAAAQErAU0C1QIiAAIAAAEXNwEr1dUCItXVAAAAAAMAVQAiA6sDdwAcACsAOgAAASIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMBNDc+ATc2MzIWFwEuATUBIiYnAR4BFRQHDgEHBiMCAFhOTXQiIiIidE1OWFhOTXQiIiIidE1OWP6rGxtcPj9GOmot/iIjJQFVOmotAd4jJRsbXD4/RgN3ISJ0Tk1YWE5OdCEiIiF0Tk5YWE1OdCIh/lZGPj5dGxslI/4iLWo6/qomIwHeLWs5Rz4+XRsbAAAAAAMAgADNA4ACzQADAAcACwAANyE1ITUhNSE1FSE1gAMA/QADAP0AAwDNVYBV1lZWAAEBKwF3AtUCTQACAAABNxcBK9XVAXfW1gAAAAADAasAdwJVAyIADAAYACQAAAEyNjU0JiMiBhUUFjMVIgYVFBYzMjY1NCYDIgYVFBYzMjY1NCYCACMyMiMjMjIjIzIyIyMyMiMjMjIjIzIyAnczIyMyMiMjM1UyIyMzMyMjMv8AMiMjMzMjIzIAAAAAAwCrAXcDVQIiAAwAGAAkAAABIgYVFBYzMjY1NCYjISIGFRQWMzI2NTQmISIGFRQWMzI2NTQmAQAjMjIjIzIyIwIAIzIyIyMyMv7dIzIyIyMyMgIiMiMjMzMjIzIyIyMzMyMjMjIjIzMzIyMyAAAAAAIAAP/ABAADgAApAC0AAAERIzU0JiMhIgYdARQWMyEyNj0BMxEhFSMiBhURFBY7ATI2NRE0JisBNQEhNSEEAMAmGv1AGiYmGgLAGiaA/cAgDRMTDYANExMNIAFA/UACwAGAAYBAGiYmGsAaJiYaQP8AgBMN/sANExMNAUANE0ABgEAAAAQA1QCiAysC9wAGAA0AEwAaAAATMxUzNSMVEyMVMzUjFQEzNTM1IxM1IxUzNSPVgFbWgIDWVgEAVoDWVlbWgAEigNVVAVVV1YD+K4BVAQCA1VUAAAEAZAAlA1wDXABEAAABERQHBgcGBwYjIicmJyYnJjU0NzY3Njc2MzIXEQURFAcGBwYHBiMiJyYnJicmNTQ3Njc2NzYzMhcRNDc2NyU2MzIXFhUDXBERGhkaGRYXGRoZGhEREREaGRoZFzMr/oURERoZGhkXFhkaGRoRERERGhkaGRY0KwoJDwGbBggUDg4DLP3WGBQTCgsFBQUFCwoTFBgZExQKCwUFEwEKdv6iGRMTCwsFBQUFCwsTExkZExMLCgYFEwHeDw0MBX8CDg4UAAAEAHUAQgOJA1YALwA8AGIAeAAAAS4BBw4BJy4BJy4BBwYiJyYGBw4BJyYGBxQVHAEVFBUeATM2MzoBMzIzMjY3PAE1BSImNTQ2MzIWFRQGJyUqASM8ATU6ATMUFhUUFxwBFQYHFAYHDgEnLgE3PgE3OgEzPAE1BT4BNzoBMxQWBw4BJy4BNz4BNzoBMwKBARkZChUJCxcEFEMvBw8HHikMDCgdFyILCxgWNDM0ZzQzNBsaAf77L0FBMDBAQDEBtx8/IDRoNgEBAQENCxVFICIlBgc3JAcNCf7OAQICEyQTAwUFSiMmOAIBOiYHEAkCzhcaAQEBAwIJCC0fCAEBBhgbGxYGBBMVKCgpUCgoKQ8VARcaSpRK7T8uMEA/LzBAARchPyAKEgkzMjNmMjMzFCwRIBAOD0IjJjQDN2053QwUCi5dLSUsBgVEJig+BAAAAAAEANUAogMrAvcABQALABEAFwAAASMVMzUjAzM1MzUjASMVMzUjAxUzFTM1AStW1oBWVoDWAgCA1laAgFYBd9VVASuAVf4AVdUBgFWA1QAAAAQAAAAABAADQAAbADMATwBTAAABFBceARcWMzI3PgE3NjU0Jy4BJyYjIgcOAQcGASMuASMhIgYHIyIGFREUFjMhMjY1ETQmASInLgEnJjU0Nz4BNzYzMhceARcWFRQHDgEHBgEjNTMBMBAROCYmKysmJjgREBAROCYmKysmJjgREAKQ4AwkMP8AMCQM4BomJhoDgBomJv4mOzQzTRcWFhdNMzQ7OzQzTRcWFhdNMzQBhYCAAWArJiY4ERAQETgmJisrJiY4ERAQETgmJgE1MFBQMCYa/cAaJiYaAkAaJv2EFhdNMzQ7OzQzTRcWFhdNMzQ7OzQzTRcWAbxAAAEAkQCiA4AC3gAGAAABJwcXAScBAYCzPO8CADz+PAEaszzvAgA8/jwAAAAAAQDiAIADHgLJACYAAAE3NjQnJiIPAScmIgcGFB8BBwYUFx4BMzI2PwEXHgEzMjY3NjQvAQI84g0NDCQM4uIMJAwNDeLiDQ0GEAgIEAbi4gYQCAgQBg0N4gGr4gwjDQwM4uIMDA0jDOLiDSMMBwYGB+HhBwYGBwwjDeIAAAUAVQCVA6sC6wAZACoARABeAHgAAAEhIgYHDgEVFBYXHgEzITI2Nz4BNTQmJy4BJTQmIyEiBh0BFBYzITI2PQEDISIGBw4BFRQWFx4BMyEyNjc+ATU0JicuAQMhIgYHDgEVFBYXHgEzITI2Nz4BNTQmJy4BBSEiBgcOARUUFhceATMhMjY3PgE1NCYnLgEB1f6rCQ8GBgcHBgYPCQFVCQ8GBwYGBwYPAc0ZEv8AEhkZEgEAEhkr/QAJDwYGBwcGBg8JAwAJDwYGBwcGBg8J/QAJDwYGBwcGBg8JAwAJDwYGBwcGBg/+TP6rCQ8GBgcHBgYPCQFVCQ8GBwYGBwYPAZUGBgYQCAkPBgcGBgcGDwkIEAYGBoERGRkRrBEZGRGs/tUHBgYPCQkPBgYHBwYGDwkJDwYGBwIABwYGDwkJDwYGBwcGBg8JCQ8GBgerBgcGDwkIEAYGBgYGBhAICQ8GBwYAAAAABABVAE0DqwNNAA4AEgAeACIAAAEhIgYVETMVITUzETQmIwMhNSE3IiY1NDYzMhYVFAYDIRUhAyv9qjVLqwIAq0s1gP6qAVaAEhkZEhEZGTz+AAIAAndKNv8AqqoBADZK/ivVVhkREhkZEhEZAYCrAAIAgABjA2oDTQAiAC8AAAEjJz4BNTQnLgEnJiMiBw4BBwYVFBceARcWMzI2NxcVFzcnISImNTQ2MzIWFRQGIwKVIQwfJBYWSzMyOjkzMksWFhYWSzIzOTRcJQvWP9X/AE9xcU9QcHBQAXcMJF0zOjIzSxYWFhZLMzI6OTIzSxYWJB8MItQ/1XFPUHBwUE9xAAIAZAAiA5wDdwBNAFkAAAE+ATU0Jic3PgEvAS4BDwEuAS8BLgErASIGDwEOAQcnJgYPAQYWHwEOARUUFhcHDgEfAR4BPwEeAR8BHgE7ATI2PwE+ATcXFjY/ATYmJwUiJjU0NjMyFhUUBgM9AQICAVoGAwRVBA8HahEkFBABDAiqCAwBEBQkEWoHDwRVBAMGWgECAgFaBgMEVQQPB2oRJBQQAQwIqggMARAUJBFqBw8EVQQDBv5pPldXPj5XVwGjChULCxQLRgUPB5QHBQMqDBUIcgcKCgdyCBUMKgMFB5QHDwVGCxUKCxUKRgUQB5MHBQIrDRUIcQgKCghxCBUNKwMGB5MHEAUmWD4+V1c+PlgAAQDVAKIDKwL3AAsAAAEhESMRITUhETMRIQMr/wBW/wABAFYBAAGi/wABAFUBAP8AAAAAAAQAVf/vA6sC7wAeADMAOAA9AAATNwEHJyM1JyM1Jw4BFRQWOwEVIyInLgEnJjU0NjcnBTIXHgEXFhUUBgcnPgE1NCYrATUzITMVIycFFSMnM1U3Ask2q0mMSmogJWdIgIA1Li9FFRQyKlwCVjUuL0UVFEc5PC88Z0iAgP6qgDZRAV0zVYgCuTb9NzerSYxKaxhIKklmURQURS8vNTpnIlwfFRRFLy41R3YhPRRWN0hnUVFR1lVVAAADAFUAmgOrApoAGgA1ADkAAAEjFTMyFhUUBisBFTMyNz4BNzY1NCcuAScmIwE0NjsBNSMiBw4BBwYVFBceARcWOwE1IyImNRchNSECq4CASGdnSICANS4vRRUUFBVFLy41/ftnSICANS4vRRUUFBVFLy41gIBIZ68BVv6qAppRZ0hJZlEUFEUvLzU1Li9FFRT/AEhnURUURS8uNTUvL0UUFFFmSStVAAAFAFUAIgOrA3cAHAA4AEQAUABYAAABIgcOAQcGFRQXHgEXFjMyNz4BNzY1NCcuAScmIxEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYTMjY1NCYjIgYVFBYhMjY1NCYjIgYVFBYTMjY3IR4BMwIAWU1OdCEiIiF0Tk1ZWE5OdCEiIiF0Tk5YRz4+XRsaGhtdPj5HRz4+XRsaGhtdPj5OGyUlGxomJv7wGiYmGhslJbBLdRr+TBp1SwN3ISJzTk5YWU1OdCEiIiF0Tk1ZWE5OcyIh/QAbG10+PkdHPj5dGhsbGl0+PkdHPj5dGxsBgCYaGyUlGxomJhobJSUbGib+61RBQVQAAAAJAAAAQAQAA0AAAwAHAAsADwATABcAGwAfACIAABMRIREBIzUzNSM1MzUjNTMBIREhEyM1MzUjNTM1IzUzBRElAAQA/MCAgICAgIACQP4AAgDAgICAgICA/cABAANA/QADAP1AgICAgID9gAKA/YCAgICAgID+gMAAAAAAAgDVAE0DKwNNABkAHgAAJTI3PgE3NjURIxEUBiMiJjURIxEUFx4BFxYHFSE1IQIANS8uRhQUa1c+PldrFBRGLi/2Alb9qvcVFEUvLzQBVv6qPVhYPQFW/qo0Ly9FFBVVVVUAAAUAVQCVA6sC6wAaACsARQBfAHoAAAEhMhYXHgEVFAYHDgEjISImJy4BNTQ2Nz4BMyU0NjMhMhYdARQGIyEiJj0BEyEyFhceARUUBgcOASMhIiYnLgE1NDY3PgETITIWFx4BFRQGBw4BIyEiJicuATU0Njc+AQUhMhYXHgEVFAYHDgEjISImJy4BNTQ2Nz4BMwIrAVUJDwYGBwcGBg8J/qsJDwYHBgYHBg8J/ioZEgEAEhkZEv8AEhkrAwAJDwYGBwcGBg8J/QAJDwYGBwcGBg8JAwAJDwYGBwcGBg8J/QAJDwYGBwcGBg8BtAFVCQ8GBgcHBgYPCf6rCQ8GBwYGBwYPCQGVBgYGEAgJDwYHBgYHBg8JCBAGBgaBERkZEawRGRkRrP7VBwYGDwkJDwYGBwcGBg8JCQ8GBgcCAAcGBg8JCQ8GBgcHBgYPCQkPBgYHqwYHBg8JCBAGBgYGBgYQCAkPBgcGAAAAAAMAgACiA4ADIgAEAA0AEQAAJTM1IxUDFTMVMzUzNSEDITUhAauqqtbWqtb9qlUDAP0AooCAAoCAgICA/lVWAAACAIAAogOrAyIACAARAAABFTMRMxEzNSEBMxEzETM1IRUBgNWA1v3V/wCAgID+gAMigP4AAgCA/qv+1QErgIAAAgDVAPcDKwKiAAYADQAAJTM3ESERMwUzNxEhETMBAIBV/wCAAQCAVv8AgPerAQD/AKurAQD/AAAGAFUAdwOAAyIACwASAB0AIgAnACwAADczFSMVMxUjFTM1IxMzNSMVMxUHMwcVMzUjNzUjFRMVITUhESE1IRURITUhFVVWKytWgIArK1YrK01NgExMgNYCVf2rAlX9qwJV/av3FSsVK6sBVasrgIBZJytaJisBAFVV/atVVQEAVVUAAAAGAGsAjQOAAw0ACwAXACMAKAAtADIAABMiBhUUFjMyNjU0JgMiBhUUFjMyNjU0JgMiBhUUFjMyNjU0JhchNSEVESE1IRURFSE1IasbJSUbGiYmGhslJRsaJiYaGyUlGxomJmYCVf2rAlX9qwJV/asCDSYaGyUlGxomAQAmGhslJRsaJv4AJhoaJiYaGiZrVVUBAFVVAVVVVQAAAAABAQAAzQMAAyIACwAAARUzAyMVITUjEzM1AatekncBVV6SdwMigP6rgIABVYAAAAABAAABawQAAesAAwAAEyEVIQAEAPwAAeuAAAAABgBA/8ADwAPAABkAIQA5AEcAVQBjAAABLgEnLgEnLgEjISIGFREUFjMhMjY1ETQmJyceARcjNR4BExQGIyEiJjURNDYzMDM6ATMyMRUUFjsBAyEiJjU0NjMhMhYVFAYnISImNTQ2MyEyFhUUBichIiY1NDYzITIWFRQGA5YRLRkaMxcnKQv+ECEvLyEC4CEvDhyFFyUNmhEphgkH/SAHCQkHTU66TU4TDeCg/kANExMNAcANExMN/kANExMNAcANExMN/kANExMNAcANExMC2xczGhktERwOLyH8oCEvLyECcAspJzYXKRGaDSX86AcJCQcDYAcJ4A0T/gATDQ0TEw0NE4ATDQ0TEw0NE4ATDQ0TEw0NEwAAAAUAAP/ABAADwAAIAAsAEwAWABwAAAERIQcRIREhESUVIwMRMzUhFQcRExUjASERMzUhAoD+QMABgAKA/MBlG8ABQMDAZQHl/gDAAUACwAEAwP3A/wADAKVl/gABwMDAwP8AAWVl/gABwMAAAAUAQP/ABAADwAANABgANAA3AD0AAAEjNTQmKwEiBh0BIxUhJyM1OAExMzgBMRUFNTQmKwEVMxUjBxEhETM1IyIGFREUFjMhFSERBRUjASERMzUhAsCAJhqAGiaAAgDAgIABQBMNQCDAwP8AIEANExMNASACgP5AZQHl/gDAAUADQEAaJiYaQICAQEDAoA0TQIDA/wACQEATDf2ADRPAAsBbZf5AAYDAAAYAgABNA4ADTQADAAcACwAPABMAFwAANyE1IRkBNycBITUhARUhNQEhNSERITUhgAMA/QCrqwFVAav+Vf6rAwD+VQGr/lUBq/5VTVUB1f6rq6r+gFYCAFZW/wBV/wBVAAYAgABNA4ADTQADAAcACwAPABMAFwAAJSE1ISUXEQcRITUhERUhNQEhNSERITUhAdUBq/5V/qurqwMA/QADAP5VAav+VQGr/lX3VoCrAVWq/oBVAqtWVv8AVf8AVQAAAAEAAP/NBAAAdwADAAA3IRUhAAQA/AB3qgAAAAACAOsA9wMVA00ACAAMAAABAzM3IRczAyMDGwEjAdXqYC8BCzBg6lY7ZmbMA039qoCAAlb+gAEO/vIAAAACAAD/wAQAA8AADgASAAABBxcDIxcBFTMBFzUlFzcFJzcXAiBgYODgsP7wJwFpsAEAYGD9wEDgQAPAYGD/ALD+lycBELDg4GBgQEDgQAAAAAEAQP/AA4oDwAARAAAFNjc2JicmBxUJARU2Fx4BBwYC+isTEzhVVqj+gAGAyXFyRignQE1bW5ozMgT+AYABgPgFTk7siokAAAEAdv/AA8ADwAASAAABNQkBNSYHDgEXFhcmJyY2NzYXAkABgP6AqFZVOBMTK2knKEZycckCyPj+gP6A/gQyM5pbW01yiYrsTk4FAAAHAAD/wAQAA0YACwAXACMALwA7AEcAUwAAJTQ2MzIWFRQGIyImATQ2MzIWFRQGIyImJTQ2MzIWFRQGIyImATQ2MzIWFRQGIyImATQ2MzIWFRQGIyImJTQ2MzIWFRQGIyImATQ2MzIWFRQGIyImAaA4KCg4OCgoOP5gOCgoODgoKDgDQDgoKDg4KCg4/To4KCg4OCgoOAJMOCgoODgoKDj9tDgoKDg4KCg4Akw4KCg4OCgoOCAoODgoKDg4AcgoODgoKDg4KCg4OCgoODgBTig4OCgoODj93Cg4OCgoODgoKDg4KCg4OAJ0KDg4KCg4OAAFAHwAAAOEA1UAIgAtADgARgBUAAABIzU0JisBIgYdASMiBhUUFjsBERQWMyEyNjURMzI2NTQmIyU0NjsBMhYdASM1ARQGIyEiJjURIREBIgYdARQWMzI2PQE0JjMiBh0BFBYzMjY9ATQmA12bRDCcMESbEBcXECdEMAGEMEQnEBcXEP4vFhCcEBboAV0XEP58EBcB0v7JEBYWEBAXF4wQFxcQEBYWAronMEREMCcXEBAW/gcwREQwAfkWEBAXJxAXFxAnJ/2TEBYWEAH5/gcBhBcQ6BAXFxDoEBcXEOgQFxcQ6BAXAAAABwAA/8AEAAPAAAMABwALAA8AEwAbACMAABMzFSM3MxUjJTMVIzczFSMlMxUjAxMhEzMTIRMBAyEDIwMhAwCAgMDAwAEAgIDAwMABAICAEBD9ABAgEAKAEP1AEAMAECAQ/YAQAcBAQEBAQEBAQEACQP5AAcD+gAGA/AABgP6AAUD+wAAABABQAIAEAAPAAAgADQAQAEAAAD8BIRczAyMDMxMzFyM3ARsBAyMiJjU0NjsBMjY1NCYrASIGFRQWFx4BOwEyFhUUBisBIgYVFBY7ATI2NTQmJy4BwjoBCDpywODAcppIOrw6AWSgoKBADRMTDYANExMNgCg4DQwNJRVADRMTDYANExMNgCg4DQwNJYDAwAKA/YACAMDA/gABAP8AAsATDQ0TEw0NEzgoEiENDxETDQ0TEw0NEzgoEiENDxEAAAAABABQ/8AEAAMAAAgADQAQAEAAAD8BIRczAyMDMxMzFyM3JQsBEyMiJjU0NjsBMjY1NCYrASIGFRQWFx4BOwEyFhUUBisBIgYVFBY7ATI2NTQmJy4BwjoBCDpywODAcppIOrw6AqSgoKBADRMTDYANExMNgCg4DQwNJRVADRMTDYANExMNgCg4DQwNJYDAwAKA/YACAMDAgP8AAQD9gBMNDRMTDQ0TOCgSIQ0PERMNDRMTDQ0TOCgSIQ0PEQAHAAD/wAQAA8AABwAPABMAFwAbAB8AIgAAAREhESMRIREFESERMxEhESUzFSMnMxUjJTMVIzczFSMlFwcBAAMAQP2AAsD9AEACgP5AgIDAgIABgICAwICA/IDAwAJAAYD+gAFA/sDA/kABwP6AAYCAQEBAQEBAQODAwAAAAQCA/8ADgAPAABcAAAEhFSMRIxEjESMRIicuAScmNTQ3PgE3NgGAAgCAgICANS8uRhQUFBRGLi8DwID8gAOA/IACABQURi4vNTUvLkYUFAACAAD/wAQAA8AAFwAaAAABIgcOAQcGFRQXHgEXFjMRMxEzETMRMzUJAgIANS8uRhQUFBRGLi81gICAgPwAAQD/AAPAFBRGLi81NS8uRhQU/gADgPyAA4CA/UABAAEAAAACAAD/wAQAA8AAFwAaAAABIgcOAQcGFRQXHgEXFjMRMxEzETMRMzUFCQEBADUvLkYUFBQURi4vNYCAgIABAP8AAQADwBQURi4vNTUvLkYUFP4AA4D8gAOAgMD/AP8AAAABAAD/zgQAA7MAYwAAASIHDgEHBhUUFx4BFxYXFjY1PAEnBiYxLgExJjYxHgExFjY3PgE3JicuAScmNTQ2Ny4BNzAWFz4BMzIWFz4BMRYGBx4BFRQHDgEHBgceARUUBhUUFjc2Nz4BNzY1NCcuAScmIwIAal1eiygoGhpdQUBMExABakISJyMnJigiXRYEEgsrKipCFBUcGQQMFUNKHkEhIUEeSkMVDAQZHBUUQyopKw4VARATTEFAXRoaKCiLXl1qA7MoKItdXmpUTU2ALy8ZBBIKCTYgF1QsHxgHAzI7BwoYIgoFDA04Ly9JKkUbCUk1AzEICQkIMQM1SQkbRSpKLy44DA0FCzAjNEwNChIEGS8wf01NVGpeXYsoKAAAAAABAAAAAQAAt9HlfV8PPPUACwQAAAAAANgVW8QAAAAA2BVbxAAA/8AEAAPAAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAQAAAEAAAAAAAAAAAAAAAAAAABLBAAAAAAAAAAAAAAAAgAAAAQAAFUEAABVBAAAVQQAAFUEAAEABAABVgQAAKoEAAAzBAAAgAQAAFYEAACABAAAgAQAAIAEAACABAAAVQQAAFUEAABVBAABKwQAAIAEAAErBAAAVQQAAIAEAAErBAABqwQAAKsEAAAABAAA1QQAAGQEAAB1BAAA1QQAAAAEAACRBAAA4gQAAFUEAABVBAAAgAQAAGQEAADVBAAAVQQAAFUEAABVBAAAAAQAANUEAABVBAAAgAQAAIAEAADVBAAAVQQAAGsEAAEABAAAAAQAAEAEAAAABAAAQAQAAIAEAACABAAAAAQAAOsEAAAABAAAQAQAAHYEAAAABAAAfAQAAAAEAABQBAAAUAQAAAAEAACABAAAAAQAAAAEAAAAAAAAAAAKABQAHgCIAPIBXgHKAd4B7AI0AlACfgKiAtIDBgNCA3QD2gRSBHIEqAT2BQQFZAV8BYoFwgX6BjwGZgbOB3YHnggcCDIIcAkiCVoJogoqCkQKoAr0C3gLtgvoDJwMvAzcDPgNOg2IDaANrg46DnAOxA70DyQPMg9QD3gPnA/CEDoQrhDwEVARrhHsEhQSRBJ0EwQAAQAAAEsAewAJAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGljb21vb24AaQBjAG8AbQBvAG8AblZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGljb21vb24AaQBjAG8AbQBvAG8Abmljb21vb24AaQBjAG8AbQBvAG8AblJlZ3VsYXIAUgBlAGcAdQBsAGEAcmljb21vb24AaQBjAG8AbQBvAG8AbkZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=);font-weight:400;font-style:normal}.index_bf-container__1HxhF [class*=\" bfi-\"],.index_bf-container__1HxhF [class^=bfi-],.index_bf-modal-root__1P_VQ [class*=\" bfi-\"],.index_bf-modal-root__1P_VQ [class^=bfi-]{font-family:braft-icons!important;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.index_bf-container__1HxhF .index_bfi-table__2fSIV:before,.index_bf-modal-root__1P_VQ .index_bfi-table__2fSIV:before{content:\"\\E228\"}.index_bf-container__1HxhF .index_bfi-clear_all__2OHjw:before,.index_bf-modal-root__1P_VQ .index_bfi-clear_all__2OHjw:before{content:\"\\E0B8\"}.index_bf-container__1HxhF .index_bfi-format_clear__2Z6-D:before,.index_bf-modal-root__1P_VQ .index_bfi-format_clear__2Z6-D:before{content:\"\\E239\"}.index_bf-container__1HxhF .index_bfi-hr__1-frF:before,.index_bf-modal-root__1P_VQ .index_bfi-hr__1-frF:before{content:\"\\E925\"}.index_bf-container__1HxhF .index_bfi-colorize__itEld:before,.index_bf-modal-root__1P_VQ .index_bfi-colorize__itEld:before{content:\"\\E3B8\"}.index_bf-container__1HxhF .index_bfi-crop_free__1UXYS:before,.index_bf-modal-root__1P_VQ .index_bfi-crop_free__1UXYS:before{content:\"\\E3C2\"}.index_bf-container__1HxhF .index_bfi-pause__1OwwZ:before,.index_bf-modal-root__1P_VQ .index_bfi-pause__1OwwZ:before{content:\"\\E034\"}.index_bf-container__1HxhF .index_bfi-play_arrow__1hL7J:before,.index_bf-modal-root__1P_VQ .index_bfi-play_arrow__1hL7J:before{content:\"\\E037\"}.index_bf-container__1HxhF .index_bfi-bin__h1RKN:before,.index_bf-modal-root__1P_VQ .index_bfi-bin__h1RKN:before{content:\"\\E9AC\"}.index_bf-container__1HxhF .index_bfi-replay__11NQk:before,.index_bf-modal-root__1P_VQ .index_bfi-replay__11NQk:before{content:\"\\E042\"}.index_bf-container__1HxhF .index_bfi-tune__axH8Q:before,.index_bf-modal-root__1P_VQ .index_bfi-tune__axH8Q:before{content:\"\\E429\"}.index_bf-container__1HxhF .index_bfi-close__3PhYm:before,.index_bf-modal-root__1P_VQ .index_bfi-close__3PhYm:before{content:\"\\E913\"}.index_bf-container__1HxhF .index_bfi-align-center__3WjMb:before,.index_bf-modal-root__1P_VQ .index_bfi-align-center__3WjMb:before{content:\"\\E028\"}.index_bf-container__1HxhF .index_bfi-align-justify__1QkRU:before,.index_bf-modal-root__1P_VQ .index_bfi-align-justify__1QkRU:before{content:\"\\E026\"}.index_bf-container__1HxhF .index_bfi-align-left__1oX7J:before,.index_bf-modal-root__1P_VQ .index_bfi-align-left__1oX7J:before{content:\"\\E027\"}.index_bf-container__1HxhF .index_bfi-align-right__1eM5M:before,.index_bf-modal-root__1P_VQ .index_bfi-align-right__1eM5M:before{content:\"\\E029\"}.index_bf-container__1HxhF .index_bfi-image-right__2H-ST:before,.index_bf-modal-root__1P_VQ .index_bfi-image-right__2H-ST:before{content:\"\\E914\"}.index_bf-container__1HxhF .index_bfi-image-left__zW8ok:before,.index_bf-modal-root__1P_VQ .index_bfi-image-left__zW8ok:before{content:\"\\E91E\"}.index_bf-container__1HxhF .index_bfi-music__1XtpY:before,.index_bf-modal-root__1P_VQ .index_bfi-music__1XtpY:before{content:\"\\E90E\"}.index_bf-container__1HxhF .index_bfi-camera__2X5Zb:before,.index_bf-modal-root__1P_VQ .index_bfi-camera__2X5Zb:before{content:\"\\E911\"}.index_bf-container__1HxhF .index_bfi-copy__16C-6:before,.index_bf-modal-root__1P_VQ .index_bfi-copy__16C-6:before{content:\"\\E92C\"}.index_bf-container__1HxhF .index_bfi-file-text__12Obf:before,.index_bf-modal-root__1P_VQ .index_bfi-file-text__12Obf:before{content:\"\\E926\"}.index_bf-container__1HxhF .index_bfi-film__2C48n:before,.index_bf-modal-root__1P_VQ .index_bfi-film__2C48n:before{content:\"\\E91C\"}.index_bf-container__1HxhF .index_bfi-github__3XePr:before,.index_bf-modal-root__1P_VQ .index_bfi-github__3XePr:before{content:\"\\EAB0\"}.index_bf-container__1HxhF .index_bfi-ltr__rDkrQ:before,.index_bf-modal-root__1P_VQ .index_bfi-ltr__rDkrQ:before{content:\"\\EA74\"}.index_bf-container__1HxhF .index_bfi-page-break__DhcNp:before,.index_bf-modal-root__1P_VQ .index_bfi-page-break__DhcNp:before{content:\"\\EA68\"}.index_bf-container__1HxhF .index_bfi-pagebreak__m3gAm:before,.index_bf-modal-root__1P_VQ .index_bfi-pagebreak__m3gAm:before{content:\"\\EA6E\"}.index_bf-container__1HxhF .index_bfi-paint-format__pjAiv:before,.index_bf-modal-root__1P_VQ .index_bfi-paint-format__pjAiv:before{content:\"\\E90C\"}.index_bf-container__1HxhF .index_bfi-paste__G7Hrh:before,.index_bf-modal-root__1P_VQ .index_bfi-paste__G7Hrh:before{content:\"\\E92D\"}.index_bf-container__1HxhF .index_bfi-pilcrow__4zJYM:before,.index_bf-modal-root__1P_VQ .index_bfi-pilcrow__4zJYM:before{content:\"\\EA73\"}.index_bf-container__1HxhF .index_bfi-pushpin__3PUoC:before,.index_bf-modal-root__1P_VQ .index_bfi-pushpin__3PUoC:before{content:\"\\E946\"}.index_bf-container__1HxhF .index_bfi-redo__1Q-LG:before,.index_bf-modal-root__1P_VQ .index_bfi-redo__1Q-LG:before{content:\"\\E968\"}.index_bf-container__1HxhF .index_bfi-rtl__sPVOR:before,.index_bf-modal-root__1P_VQ .index_bfi-rtl__sPVOR:before{content:\"\\EA75\"}.index_bf-container__1HxhF .index_bfi-spinner__Dek6M:before,.index_bf-modal-root__1P_VQ .index_bfi-spinner__Dek6M:before{content:\"\\E980\"}.index_bf-container__1HxhF .index_bfi-subscript__kYu6m:before,.index_bf-modal-root__1P_VQ .index_bfi-subscript__kYu6m:before{content:\"\\EA6C\"}.index_bf-container__1HxhF .index_bfi-superscript__3qvwy:before,.index_bf-modal-root__1P_VQ .index_bfi-superscript__3qvwy:before{content:\"\\EA6B\"}.index_bf-container__1HxhF .index_bfi-undo___pDce:before,.index_bf-modal-root__1P_VQ .index_bfi-undo___pDce:before{content:\"\\E967\"}.index_bf-container__1HxhF .index_bfi-media__3Ijxb:before,.index_bf-modal-root__1P_VQ .index_bfi-media__3Ijxb:before{content:\"\\E90F\"}.index_bf-container__1HxhF .index_bfi-add__LigZq:before,.index_bf-modal-root__1P_VQ .index_bfi-add__LigZq:before{content:\"\\E918\"}.index_bf-container__1HxhF .index_bfi-bold__dn9AC:before,.index_bf-modal-root__1P_VQ .index_bfi-bold__dn9AC:before{content:\"\\E904\"}.index_bf-container__1HxhF .index_bfi-code__3tDKj:before,.index_bf-modal-root__1P_VQ .index_bfi-code__3tDKj:before{content:\"\\E903\"}.index_bf-container__1HxhF .index_bfi-done__J_3zM:before,.index_bf-modal-root__1P_VQ .index_bfi-done__J_3zM:before{content:\"\\E912\"}.index_bf-container__1HxhF .index_bfi-drop-down__2-Azn:before,.index_bf-modal-root__1P_VQ .index_bfi-drop-down__2-Azn:before{content:\"\\E906\"}.index_bf-container__1HxhF .index_bfi-drop-up__f9cHI:before,.index_bf-modal-root__1P_VQ .index_bfi-drop-up__f9cHI:before{content:\"\\E909\"}.index_bf-container__1HxhF .index_bfi-emoji__37yM6:before,.index_bf-modal-root__1P_VQ .index_bfi-emoji__37yM6:before{content:\"\\E91B\"}.index_bf-container__1HxhF .index_bfi-font-size__1cbPf:before,.index_bf-modal-root__1P_VQ .index_bfi-font-size__1cbPf:before{content:\"\\E920\"}.index_bf-container__1HxhF .index_bfi-fullscreen__2txWy:before,.index_bf-modal-root__1P_VQ .index_bfi-fullscreen__2txWy:before{content:\"\\E910\"}.index_bf-container__1HxhF .index_bfi-fullscreen-exit__33svQ:before,.index_bf-modal-root__1P_VQ .index_bfi-fullscreen-exit__33svQ:before{content:\"\\E90D\"}.index_bf-container__1HxhF .index_bfi-help__xa9vi:before,.index_bf-modal-root__1P_VQ .index_bfi-help__xa9vi:before{content:\"\\E902\"}.index_bf-container__1HxhF .index_bfi-indent-decrease__1CtRw:before,.index_bf-modal-root__1P_VQ .index_bfi-indent-decrease__1CtRw:before{content:\"\\E92F\"}.index_bf-container__1HxhF .index_bfi-indent-increase__2kSOy:before,.index_bf-modal-root__1P_VQ .index_bfi-indent-increase__2kSOy:before{content:\"\\E92E\"}.index_bf-container__1HxhF .index_bfi-info__3gDtD:before,.index_bf-modal-root__1P_VQ .index_bfi-info__3gDtD:before{content:\"\\E901\"}.index_bf-container__1HxhF .index_bfi-italic__1ENXj:before,.index_bf-modal-root__1P_VQ .index_bfi-italic__1ENXj:before{content:\"\\E924\"}.index_bf-container__1HxhF .index_bfi-link__3-0Rp:before,.index_bf-modal-root__1P_VQ .index_bfi-link__3-0Rp:before{content:\"\\E91A\"}.index_bf-container__1HxhF .index_bfi-link-off__2xzYa:before,.index_bf-modal-root__1P_VQ .index_bfi-link-off__2xzYa:before{content:\"\\E919\"}.index_bf-container__1HxhF .index_bfi-list__3GI0k:before,.index_bf-modal-root__1P_VQ .index_bfi-list__3GI0k:before{content:\"\\E923\"}.index_bf-container__1HxhF .index_bfi-list-numbered__U2An6:before,.index_bf-modal-root__1P_VQ .index_bfi-list-numbered__U2An6:before{content:\"\\E922\"}.index_bf-container__1HxhF .index_bfi-menu__YEtEG:before,.index_bf-modal-root__1P_VQ .index_bfi-menu__YEtEG:before{content:\"\\E908\"}.index_bf-container__1HxhF .index_bfi-more-horiz__38Kqk:before,.index_bf-modal-root__1P_VQ .index_bfi-more-horiz__38Kqk:before{content:\"\\E90B\"}.index_bf-container__1HxhF .index_bfi-more-vert__1Xpoy:before,.index_bf-modal-root__1P_VQ .index_bfi-more-vert__1Xpoy:before{content:\"\\E90A\"}.index_bf-container__1HxhF .index_bfi-not-disturb__2wwfA:before,.index_bf-modal-root__1P_VQ .index_bfi-not-disturb__2wwfA:before{content:\"\\E907\"}.index_bf-container__1HxhF .index_bfi-print__1Vdsh:before,.index_bf-modal-root__1P_VQ .index_bfi-print__1Vdsh:before{content:\"\\E915\"}.index_bf-container__1HxhF .index_bfi-quote__1xD3O:before,.index_bf-modal-root__1P_VQ .index_bfi-quote__1xD3O:before{content:\"\\E921\"}.index_bf-container__1HxhF .index_bfi-search__2G21G:before,.index_bf-modal-root__1P_VQ .index_bfi-search__2G21G:before{content:\"\\E916\"}.index_bf-container__1HxhF .index_bfi-settingsx__5qqai:before,.index_bf-modal-root__1P_VQ .index_bfi-settingsx__5qqai:before{content:\"\\E917\"}.index_bf-container__1HxhF .index_bfi-share__LmF7D:before,.index_bf-modal-root__1P_VQ .index_bfi-share__LmF7D:before{content:\"\\E905\"}.index_bf-container__1HxhF .index_bfi-share-square__sA_aV:before,.index_bf-modal-root__1P_VQ .index_bfi-share-square__sA_aV:before{content:\"\\E900\"}.index_bf-container__1HxhF .index_bfi-strikethrough__3Oij6:before,.index_bf-modal-root__1P_VQ .index_bfi-strikethrough__3Oij6:before{content:\"\\E91F\"}.index_bf-container__1HxhF .index_bfi-text-color__1p69s .index_path1__1i_Zc:before,.index_bf-modal-root__1P_VQ .index_bfi-text-color__1p69s .index_path1__1i_Zc:before{font-family:braft-icons!important;content:\"\\E930\";opacity:.36}.index_bf-container__1HxhF .index_bfi-text-color__1p69s .index_path2__DFG_e:before,.index_bf-modal-root__1P_VQ .index_bfi-text-color__1p69s .index_path2__DFG_e:before{font-family:braft-icons!important;content:\"\\E931\";margin-left:-1em}.index_bf-container__1HxhF .index_bfi-underlined__oAOe6:before,.index_bf-modal-root__1P_VQ .index_bfi-underlined__oAOe6:before{content:\"\\E91D\"}.index_bf-content__5lf-j{height:500px;padding-bottom:10px;overflow:auto;font-size:16px}.index_bf-content__5lf-j img{-webkit-user-select:none;user-select:none}.index_bf-content__5lf-j *{line-height:normal}.index_bf-container__1HxhF{position:relative;height:100%;padding:0}.index_bf-container__1HxhF.index_disabled__KFBp_{pointer-events:none;opacity:.7;filter:grayscale(70%)}.index_bf-container__1HxhF.index_read-only__3HgNB .index_bf-controlbar__ej8fA{pointer-events:none}.index_bf-container__1HxhF.index_read-only__3HgNB .index_bf-image__1MXDI img:hover{outline:none}.index_bf-container__1HxhF.index_read-only__3HgNB .index_bf-hr__39L4E{pointer-events:none}.index_bf-container__1HxhF.index_fullscreen__2MrQv{position:fixed;display:flex;flex-direction:column;z-index:99999;top:0;right:0;bottom:0;left:0;background-color:#fff;height:100%!important}.index_bf-container__1HxhF.index_fullscreen__2MrQv .index_bf-content__5lf-j{flex-grow:1;height:auto}.index_bf-container__1HxhF .index_input-group__1Y0_d{display:block}.index_bf-container__1HxhF .index_input-group__1Y0_d input{box-sizing:border-box;width:100%;height:36px;padding:0 15px;font-size:14px}.index_bf-container__1HxhF .index_pull-left__33hHK{float:left}.index_bf-container__1HxhF .index_pull-right__22QW0{float:right}.index_bf-container__1HxhF button{line-height:normal}.index_bf-container__1HxhF button.index_default__11aE1,.index_bf-container__1HxhF button.index_ghost__q2A8s,.index_bf-container__1HxhF button.index_primary__1ex4f{height:32px;padding:0 20px;color:#fff;font-size:12px}.index_bf-container__1HxhF button.index_default__11aE1{background-color:hsla(0,0%,100%,.15);border:none}.index_bf-container__1HxhF button.index_default__11aE1:hover{background-color:hsla(0,0%,100%,.1)}.index_bf-container__1HxhF button.index_ghost__q2A8s{background-color:transparent;border:none;box-shadow:inset 0 0 0 .5px hsla(0,0%,100%,.5)}.index_bf-container__1HxhF button.index_ghost__q2A8s:hover{box-shadow:inset 0 0 0 .5px hsla(0,0%,100%,.7)}.index_bf-container__1HxhF button.index_primary__1ex4f{background-color:#3498db;border:none;color:#fff}.index_bf-container__1HxhF button.index_primary__1ex4f:hover{background-color:#2084c7}.index_bf-container__1HxhF .index_public-DraftEditorPlaceholder-root__1T6lJ{top:15px;left:15px;font-size:16px;pointer-events:none}.index_bf-container__1HxhF .index_DraftEditor-editorContainer__1FR0o{box-sizing:border-box;border:none}.index_bf-container__1HxhF .index_DraftEditor-root__mlfOI,.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu{height:100%}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu{box-sizing:border-box;padding:15px;word-wrap:break-word;word-break:break-all}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu>div{padding-bottom:20px}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu .index_braft-link__1ZeMr{color:#4078c0}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu blockquote{margin:0 0 10px;padding:15px 20px;background-color:#f1f2f3;border-left:5px solid #ccc;color:#666;font-style:italic}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu pre{max-width:100%;max-height:100%;margin:10px 0;padding:15px;overflow:auto;background-color:#f1f2f3;border-radius:3px;color:#666;font-family:monospace;font-size:14px;font-weight:400;line-height:16px;word-wrap:break-word;white-space:pre-wrap}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu pre pre{margin:0;padding:0}.index_bf-container__1HxhF .index_bfa-left__3CWAj,.index_bf-container__1HxhF .index_bfa-left__3CWAj .index_public-DraftStyleDefault-ltr__3qMdW{text-align:left}.index_bf-container__1HxhF .index_bfa-right__Sy5sn,.index_bf-container__1HxhF .index_bfa-right__Sy5sn .index_public-DraftStyleDefault-ltr__3qMdW{text-align:right}.index_bf-container__1HxhF .index_bfa-center__3iBxk,.index_bf-container__1HxhF .index_bfa-center__3iBxk .index_public-DraftStyleDefault-ltr__3qMdW{text-align:center}.index_bf-container__1HxhF .index_bfa-justify__C4cm4,.index_bf-container__1HxhF .index_bfa-justify__C4cm4 .index_public-DraftStyleDefault-ltr__3qMdW{text-align:justify}.index_bf-container__1HxhF .index_bfa-center__3iBxk>div,.index_bf-container__1HxhF .index_bfa-justify__C4cm4>div,.index_bf-container__1HxhF .index_bfa-left__3CWAj>div,.index_bf-container__1HxhF .index_bfa-right__Sy5sn>div{display:inline-block}.index_bf-container__1HxhF .index_bff-left__pCNho:hover,.index_bf-container__1HxhF .index_bff-right__vpxtc:hover{z-index:2}.index_bf-container__1HxhF .index_bff-left__pCNho{position:relative;z-index:1;float:left;margin:0 10px 0 0}.index_bf-container__1HxhF .index_bff-right__vpxtc{position:relative;z-index:1;float:right;margin:0 0 0 10px}.index_bf-container__1HxhF .index_bftd-1__382qR{text-indent:2em;display:initial}.index_bf-container__1HxhF .index_bftd-2__11te-{text-indent:4em;display:initial}.index_bf-container__1HxhF .index_bftd-3__2BZeG{text-indent:6em;display:initial}.index_bf-container__1HxhF .index_bftd-4__4c1Sw{text-indent:8em;display:initial}.index_bf-container__1HxhF .index_bftd-5__34mlP{text-indent:10em;display:initial}.index_bf-container__1HxhF .index_bftd-6__1bsox{text-indent:12em;display:initial}.index_bf-container__1HxhF .index_bf-image__1MXDI,.index_bf-container__1HxhF .index_bf-media__33Dic{position:relative}.index_bf-container__1HxhF .index_bf-image__1MXDI img{display:block;max-width:100%;font-size:0;resize:both;outline-offset:1px}.index_bf-container__1HxhF .index_bf-image__1MXDI img:hover{outline:1px solid #3498db}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5{position:absolute;z-index:3;bottom:15px;left:50%;width:auto;background-color:#21242a;border-radius:2px;font-weight:400;text-align:center;white-space:nowrap;transform:translateX(-50%);box-shadow:0 5px 15px rgba(0,0,0,.2);-webkit-user-select:none;user-select:none}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 .index_bf-media-toolbar-arrow__M3uMb,.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5:before{position:absolute;bottom:-10px;left:50%;display:block;border:5px solid transparent;border-top-color:#21242a;content:\"\";transform:translateX(-5px)}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a{display:inline-block;min-width:40px;height:40px;color:hsla(0,0%,100%,.5);font-family:braft-icons!important;font-size:18px;font-weight:400;line-height:40px;text-align:center;text-decoration:none;text-transform:uppercase;cursor:pointer}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a:hover{color:#fff}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a:first-child{border-radius:2px 0 0 2px}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a:last-child{border-radius:0 2px 2px 0}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a.index_active__3_mlp{color:#3498db}.index_bf-video-player__3Eqxs video{display:block;width:640px;max-width:80vw;height:auto;margin:0 10px 10px;object-fit:contain}.index_bf-audio-player__67sKu audio{width:480px;max-width:80vw;margin:0 10px 10px}.index_bf-player-holder__1k4R5{position:relative;height:240px;overflow:hidden;background-color:#21242a;border-radius:3px}.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN{position:absolute;z-index:2;top:0;left:0;height:30px;padding:0 15px;border-radius:0 0 3px 0;color:#fff;background-color:hsla(0,0%,100%,.1)}.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN i,.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN span{display:block;float:left;line-height:30px}.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN span{margin-left:5px;font-size:12px}.index_bf-player-holder__1k4R5 .index_button-remove__cTw4D{position:absolute;z-index:2;top:5px;right:5px;width:40px;height:40px;background-color:transparent;border:none;border-radius:50%;outline:none;color:#fff;font-size:24px;text-align:center;cursor:pointer}.index_bf-player-holder__1k4R5 .index_button-remove__cTw4D:hover{color:#e74c3c}.index_bf-player-holder__1k4R5 .index_button-play__1GpMM{position:relative;z-index:2;display:block;width:80px;height:80px;margin:40px auto 20px;background-color:rgba(0,0,0,.7);border:none;border-radius:50%;outline:none;color:#fff;font-size:48px;line-height:80px;text-align:center;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);cursor:pointer}.index_bf-player-holder__1k4R5 .index_button-play__1GpMM:hover{background-color:#3498db}.index_bf-player-holder__1k4R5 .index_bf-name__3FBAI{position:relative;z-index:2;margin:0;color:#fff;font-size:14px;font-weight:500;text-align:center}.index_bf-player-holder__1k4R5 .index_bf-url__1di3g{position:relative;z-index:2;width:70%;margin:10px auto;color:hsla(0,0%,100%,.5);font-size:12px;font-weight:400;text-align:center}.index_bf-player-holder__1k4R5 .index_bf-poster__drCvq{position:absolute;top:0;left:0;width:100%;height:100%;background-repeat:no-repeat;background-position:50% 50%;background-size:cover;opacity:.3}.index_bf-modal__23mEu{position:fixed;z-index:99999;top:0;left:0;width:100%;height:100%}.index_bf-modal__23mEu button{outline:none}.index_bf-modal-mask__3MKbg{position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.1);opacity:0;transition:opacity .2s}.index_bf-modal-content__1RScF{position:absolute;z-index:2;top:45%;left:50%;max-width:95%;background-color:#fff;border-radius:2px;box-shadow:0 15px 30px rgba(0,0,0,.1);opacity:0;transform:translate(-50%,-40%);transition:transform .2s,opacity .2s}.index_bf-modal-header__3jeX-{height:50px}.index_bf-modal-caption__2z9hD{float:left;margin:0;padding:0 15px;color:#999;font-size:14px;font-weight:400;line-height:50px}.index_bf-modal-close-button__13UMv{float:right;width:50px;height:50px;background-color:transparent;border:none;color:#ccc;font-size:18px;cursor:pointer}.index_bf-modal-close-button__13UMv:hover{color:#e74c3c}.index_bf-modal-body__3MjbZ{overflow:auto}.index_bf-modal-footer__3Pc0k{min-height:15px;padding:0 15px;overflow:hidden}.index_bf-modal-addon-text__3dQDG{float:left;color:#999;font-size:12px;line-height:60px}.index_bf-modal-buttons__2IuAO{float:right}.index_bf-modal-cancel__30ePe,.index_bf-modal-confirm__3woeJ{height:36px;margin:12px 0 12px 15px;padding:0 30px;border:none;border-radius:2px;font-size:12px;font-weight:700;cursor:pointer}.index_bf-modal-cancel__30ePe{background-color:#e8e9ea;color:#999}.index_bf-modal-cancel__30ePe:hover{background-color:#d8d9da}.index_bf-modal-confirm__3woeJ{background-color:#3498db;color:#fff}.index_bf-modal-confirm__3woeJ:hover{background-color:#2084c7}.index_bf-modal-confirm__3woeJ.index_disabled__KFBp_{opacity:.3;pointer-events:none;filter:grayscale(.4)}.index_bf-modal-root__1P_VQ.index_active__3_mlp .index_bf-modal-mask__3MKbg{opacity:1}.index_bf-modal-root__1P_VQ.index_active__3_mlp .index_bf-modal-content__1RScF{opacity:1;transform:translate(-50%,-50%)}.index_bf-content__5lf-j .index_bf-hr__39L4E{position:relative;box-sizing:content-box;height:15px;padding-top:15px;text-align:center}.index_bf-content__5lf-j .index_bf-hr__39L4E:before{display:block;height:1px;background-color:rgba(0,0,0,.1);content:\"\"}.index_bf-content__5lf-j .index_bf-hr__39L4E:hover:before{background-color:rgba(0,0,0,.3)}.index_bf-content__5lf-j .index_bf-hr__39L4E:hover .index_bf-media-toolbar__28qi5{display:block}.index_bf-content__5lf-j .index_bf-hr__39L4E .index_bf-media-toolbar__28qi5{display:none}.index_bf-image-link-editor__L5XLU,.index_bf-image-size-editor__3DAVi{padding-bottom:1px;overflow:hidden;border-radius:2px 2px 0 0;box-shadow:inset 0 -1px 0 0 hsla(0,0%,100%,.1)}.index_bf-image-link-editor__L5XLU .index_editor-input-group__1hcX3,.index_bf-image-size-editor__3DAVi .index_editor-input-group__1hcX3{width:300px;margin:8px 10px;overflow:hidden}.index_bf-image-link-editor__L5XLU input,.index_bf-image-size-editor__3DAVi input{display:block;float:left;box-sizing:content-box;height:32px;margin:0 5px 0 0;padding:0 10px;background-color:hsla(0,0%,100%,.1);border:none;border-radius:2px;outline:none;box-shadow:inset 0 0 0 1px hsla(0,0%,100%,.1);color:#fff;font-weight:700}.index_bf-image-link-editor__L5XLU input:hover,.index_bf-image-size-editor__3DAVi input:hover{box-shadow:inset 0 0 0 1px rgba(52,152,219,.5)}.index_bf-image-link-editor__L5XLU input:focus,.index_bf-image-size-editor__3DAVi input:focus{box-shadow:inset 0 0 0 1px #3498db}.index_bf-image-link-editor__L5XLU button,.index_bf-image-size-editor__3DAVi button{float:left;width:90px;height:32px;margin:0;padding:0 20px;background-color:#3498db;border:none;color:#fff;font-size:12px;border-radius:2px;cursor:pointer}.index_bf-image-link-editor__L5XLU button:hover,.index_bf-image-size-editor__3DAVi button:hover{background-color:#2084c7}.index_bf-image-size-editor__3DAVi input{width:80px}.index_bf-image-link-editor__L5XLU input{width:185px}.index_bf-image-link-editor__L5XLU .index_switch-group__3nsEF{height:16px;margin:10px}.index_bf-image-link-editor__L5XLU .index_switch-group__3nsEF .index_bf-switch__1LPr-{float:left}.index_bf-image-link-editor__L5XLU .index_switch-group__3nsEF label{float:left;margin-left:15px;color:#999;font-size:12px;line-height:16px}.index_bf-content__5lf-j .index_bf-image__1MXDI{position:relative}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-csize-icon__13EM-{position:absolute;z-index:2;width:10px;height:10px;background-color:rgba(52,152,219,.3)}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-csize-icon__13EM-.index_right-bottom__2jlUD{right:0;bottom:0;cursor:se-resize}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-csize-icon__13EM-.index_left-bottom__1H0sb{left:0;bottom:0;cursor:sw-resize}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-pre-csize__2lLOX{position:absolute;z-index:1;background:transparent}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-pre-csize__2lLOX.index_rightbottom__S1Zly{left:0;top:0;border:1px dashed #00bfff}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-pre-csize__2lLOX.index_leftbottom__wbQiO{right:0;top:0;border:1px dashed #00bfff}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5:before{visibility:hidden}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-align=center] [data-align=center],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-align=left] [data-align=left],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-align=right] [data-align=right],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-float=left] [data-float=left],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-float=right] [data-float=right]{color:#3498db}.index_headings-dropdown__1KzQP{min-width:110px}.index_headings-dropdown__1KzQP .index_menu__10kCt{width:200px;overflow:hidden}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov-{padding:15px 20px;text-align:left;line-height:normal}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h1,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h2,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h3,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h4,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h5,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h6{margin:0;padding:0;color:inherit}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h1{font-size:28px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h2{font-size:24px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h3{font-size:20px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h4{font-size:16px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h5{font-size:14px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h6{font-size:12px}.index_bf-link-editor__w7aBK{width:360px;padding-top:25px}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d{margin:0 15px 8px}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input{background-color:hsla(0,0%,100%,.07);border:none;border-radius:2px;box-shadow:inset 0 0 0 1px hsla(0,0%,100%,.1);color:#fff;font-weight:700}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input:hover{box-shadow:inset 0 0 0 1px rgba(52,152,219,.5)}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input:focus{box-shadow:inset 0 0 0 1px #3498db}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input:disabled{color:hsla(0,0%,100%,.7);box-shadow:none}.index_bf-link-editor__w7aBK .index_switch-group__3nsEF{height:16px;margin:15px}.index_bf-link-editor__w7aBK .index_switch-group__3nsEF .index_bf-switch__1LPr-{float:left}.index_bf-link-editor__w7aBK .index_switch-group__3nsEF label{float:left;margin-left:15px;color:#999;font-size:12px;line-height:16px}.index_bf-link-editor__w7aBK .index_buttons__3QT_I{box-sizing:content-box;height:32px;margin-top:20px;padding:15px;overflow:hidden;box-shadow:inset 0 1px 0 0 hsla(0,0%,100%,.1)}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W{color:#999;font-size:12px;line-height:32px;cursor:pointer}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W:hover{color:#e74c3c}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W i{margin-right:5px;font-size:16px}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W i,.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W span{display:block;float:left;line-height:32px}.index_bf-link-editor__w7aBK .index_buttons__3QT_I button{margin-left:10px;border-radius:2px;font-weight:700;cursor:pointer}.index_bf-dropdown__zgKp1{position:relative;width:auto;height:36px;margin:0}.index_bf-dropdown__zgKp1.index_disabled__KFBp_{pointer-events:none;opacity:.3}.index_bf-dropdown__zgKp1.index_light-theme__iYoel .index_dropdown-content__2HerW{border:1px solid #ccc}.index_bf-dropdown__zgKp1.index_light-theme__iYoel .index_dropdown-content__2HerW .index_dropdown-arrow__3KWgU{background-color:#fff;border:1px solid #ccc}.index_bf-dropdown__zgKp1.index_light-theme__iYoel .index_dropdown-content__2HerW .index_dropdown-content-inner__5r4YN{background-color:#fff}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW{box-sizing:content-box;position:absolute;z-index:10;top:100%;left:50%;visibility:hidden;float:left;width:auto;min-width:100%;margin-top:9px;border-radius:2px;box-shadow:0 5px 15px rgba(0,0,0,.2);opacity:0;cursor:default;transform:translate(-50%,20px);transition:.2s}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW ::-webkit-scrollbar-track{background-color:transparent}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW ::-webkit-scrollbar{width:4px;background-color:transparent;border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW ::-webkit-scrollbar-thumb{background-color:hsla(0,0%,100%,.3);border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_dropdown-arrow__3KWgU{position:absolute;z-index:1;top:-3px;left:50%;width:10px;height:10px;background-color:#21242a;transform:translateX(-50%) rotate(45deg);transition:margin .2s}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_dropdown-arrow__3KWgU.index_active__3_mlp{background-color:#3498db}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu__10kCt{list-style:none;margin:0;padding:0;overflow:hidden;border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-{display:block;list-style:none;margin:0;font-size:16px;cursor:pointer}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-:hover{background-color:rgba(0,0,0,.1)}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-.index_active__3_mlp{background-color:#3498db;color:#fff}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-:not(.index_active__3_mlp){color:hsla(0,0%,100%,.6);box-shadow:inset 0 -1px 0 0 hsla(0,0%,100%,.1)}.index_bf-dropdown__zgKp1 .index_dropdown-content-inner__5r4YN{position:relative;z-index:2;overflow:auto;background-color:#21242a;border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS{position:relative;display:block;width:100%;height:36px;background-color:transparent;border:none;color:#6a6f7b;cursor:pointer}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS:hover{background-color:rgba(0,0,0,.05)}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS *{display:inline;padding:0;font-size:inherit;font-weight:400}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS>span{float:left;padding:0 10px;font-size:14px;line-height:36px;pointer-events:none}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS>span i{display:block;height:36px;font-size:16px;line-height:36px;text-align:center}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS .index_bfi-drop-down__2-Azn{float:right;width:30px;height:36px;font-size:16px;line-height:36px;text-align:center;pointer-events:none}.index_bf-dropdown__zgKp1.index_active__3_mlp .index_dropdown-handler__1xChS{background-color:rgba(0,0,0,.05)}.index_bf-dropdown__zgKp1.index_active__3_mlp .index_dropdown-content__2HerW{visibility:visible;opacity:1;transform:translate(-50%)}.index_text-color-dropdown__pnJCI.index_light-theme__iYoel .index_bf-color-switch-buttons__R4l-y button{border-bottom:1px solid #ccc;color:#616569}.index_text-color-dropdown__pnJCI.index_light-theme__iYoel .index_bf-color-switch-buttons__R4l-y button.index_active__3_mlp{border-bottom-color:#3498db;color:#3498db}.index_text-color-dropdown__pnJCI button.index_dropdown-handler__1xChS span{width:36px;padding:0;overflow:hidden;border-radius:2px}.index_text-color-dropdown__pnJCI .index_bf-text-color-picker-wrap__2xWAh{overflow:hidden}.index_text-color-dropdown__pnJCI .index_bf-color-switch-buttons__R4l-y{height:36px}.index_text-color-dropdown__pnJCI .index_bf-color-switch-buttons__R4l-y button{float:left;width:50%;height:36px;background-color:transparent;border:none;border-bottom:1px solid hsla(0,0%,100%,.1);color:hsla(0,0%,100%,.5);font-size:12px;font-weight:400;text-transform:uppercase;cursor:pointer}.index_text-color-dropdown__pnJCI .index_bf-color-switch-buttons__R4l-y button.index_active__3_mlp{border-bottom-color:#3498db;color:#3498db}.index_bf-colors__2Jog3{box-sizing:content-box;list-style:none;width:240px;margin:0;padding:15px;overflow:hidden}.index_bf-colors__2Jog3 li{box-sizing:content-box;display:block;float:left;width:24px;height:24px;margin:5px;padding:0;background-color:currentColor;border:3px solid transparent;border-radius:50%;cursor:pointer;transition:transform .2s}.index_bf-colors__2Jog3 li:hover{transform:scale(1.3)}.index_bf-colors__2Jog3 li.index_active__3_mlp{box-shadow:0 0 0 2px #3498db}.index_bf-font-size-dropdown__38pES{min-width:95px}.index_bf-font-sizes__2rRGp{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-font-sizes__2rRGp li{display:block;float:left;width:60px;height:30px;background-color:hsla(0,0%,100%,.1);border-radius:2px;margin:5px;color:#fff;font-size:12px;line-height:30px;text-align:center;text-transform:uppercase;cursor:pointer}.index_bf-font-sizes__2rRGp li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-font-sizes__2rRGp li.index_active__3_mlp{background-color:#3498db}.index_font-family-dropdown__rYXD5{min-width:120px}.index_font-family-dropdown__rYXD5 .index_dropdown-content__2HerW{width:180px}.index_font-family-dropdown__rYXD5 .index_menu-item__2_Ov-{padding:12px 15px}.index_bf-line-height-dropdown__ee0Ld{min-width:95px}.index_bf-line-heights__2Oa0w{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-line-heights__2Oa0w li{display:block;float:left;width:60px;height:30px;background-color:hsla(0,0%,100%,.1);border-radius:2px;margin:5px;color:#fff;font-size:12px;line-height:30px;text-align:center;text-transform:uppercase;cursor:pointer}.index_bf-line-heights__2Oa0w li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-line-heights__2Oa0w li.index_active__3_mlp{background-color:#3498db}.index_bf-letter-spacing-dropdown__1t21I{min-width:95px}.index_bf-letter-spacings__MYcL5{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-letter-spacings__MYcL5 li{display:block;float:left;width:60px;height:30px;background-color:hsla(0,0%,100%,.1);border-radius:2px;margin:5px;color:#fff;font-size:12px;line-height:30px;text-align:center;text-transform:uppercase;cursor:pointer}.index_bf-letter-spacings__MYcL5 li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-letter-spacings__MYcL5 li.index_active__3_mlp{background-color:#3498db}.index_bf-emojis-wrap__3FqEM{position:relative;width:210px;height:220px;overflow:hidden}.index_bf-emojis-wrap__3FqEM:after,.index_bf-emojis-wrap__3FqEM:before{position:absolute;z-index:1;right:0;left:0;height:30px;border-radius:2px;content:\"\";pointer-events:none}.index_bf-emojis-wrap__3FqEM:before{top:0;background-image:linear-gradient(0deg,rgba(33,36,42,0),#21242a)}.index_bf-emojis-wrap__3FqEM:after{bottom:0;background-image:linear-gradient(rgba(33,36,42,0),#21242a)}.index_bf-emojis__3p4Ps{box-sizing:content-box;width:200px;height:195px;list-style:none;margin:0;padding:15px 15px 20px;overflow:auto}.index_bf-emojis__3p4Ps li{display:block;float:left;width:30px;height:30px;margin:0;padding:0;color:#fff;border-radius:2px;font-family:Apple Color Emoji,Segoe UI,Segoe UI Emoji,Segoe UI Symbol;font-size:18px;line-height:32px;text-align:center;cursor:pointer;-webkit-user-select:none;user-select:none;transition:transform .2s}.index_bf-emojis__3p4Ps li:hover{transform:scale(1.5)}";
  18687. styleInject_es.styleInject(css);
  18688. var css$1 = ".emoticon_braft-emoticon-picker__26_HU{box-sizing:border-box;width:210px;height:210px;overflow:hidden}.emoticon_braft-emoticon-picker__26_HU:after,.emoticon_braft-emoticon-picker__26_HU:before{position:absolute;z-index:1;right:0;left:0;height:30px;border-radius:2px;content:\"\";pointer-events:none}.emoticon_braft-emoticon-picker__26_HU:before{top:0;background-image:linear-gradient(0deg,rgba(33,36,42,0),#21242a)}.emoticon_braft-emoticon-picker__26_HU:after{bottom:0;background-image:linear-gradient(rgba(33,36,42,0),#21242a)}.emoticon_braft-emoticon-picker__26_HU .emoticon_braft-emoticons-list__P1AeK{box-sizing:content-box;width:200px;height:190px;margin:0;padding:15px 15px 20px;overflow:auto}.emoticon_braft-emoticon-picker__26_HU .emoticon_braft-emoticons-list__P1AeK img{display:block;box-sizing:content-box;float:left;width:20px;height:20px;margin:3px;padding:5px;border-radius:3px}.emoticon_braft-emoticon-picker__26_HU .emoticon_braft-emoticons-list__P1AeK img:hover{background-color:#3498db}.emoticon_braft-emoticon-in-editor__10cwl{position:relative;padding:0 2px;letter-spacing:12px}.emoticon_braft-emoticon-in-editor__10cwl img{position:absolute;top:0;left:2px;width:16px;height:16px}";
  18689. styleInject_es.styleInject(css$1);
  18690. var immutable$2 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  18691. /**
  18692. * Copyright (c) 2014-present, Facebook, Inc.
  18693. *
  18694. * This source code is licensed under the MIT license found in the
  18695. * LICENSE file in the root directory of this source tree.
  18696. */
  18697. (function (global, factory) {
  18698. factory(exports) ;
  18699. }(_commonjsHelpers.commonjsGlobal, (function (exports) {
  18700. // Used for setting prototype methods that IE8 chokes on.
  18701. var DELETE = 'delete';
  18702. // Constants describing the size of trie nodes.
  18703. var SHIFT = 5; // Resulted in best performance after ______?
  18704. var SIZE = 1 << SHIFT;
  18705. var MASK = SIZE - 1;
  18706. // A consistent shared value representing "not set" which equals nothing other
  18707. // than itself, and nothing that could be provided externally.
  18708. var NOT_SET = {};
  18709. // Boolean references, Rough equivalent of `bool &`.
  18710. function MakeRef() {
  18711. return { value: false };
  18712. }
  18713. function SetRef(ref) {
  18714. if (ref) {
  18715. ref.value = true;
  18716. }
  18717. }
  18718. // A function which returns a value representing an "owner" for transient writes
  18719. // to tries. The return value will only ever equal itself, and will not equal
  18720. // the return of any subsequent call of this function.
  18721. function OwnerID() {}
  18722. function ensureSize(iter) {
  18723. if (iter.size === undefined) {
  18724. iter.size = iter.__iterate(returnTrue);
  18725. }
  18726. return iter.size;
  18727. }
  18728. function wrapIndex(iter, index) {
  18729. // This implements "is array index" which the ECMAString spec defines as:
  18730. //
  18731. // A String property name P is an array index if and only if
  18732. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  18733. // to 2^32−1.
  18734. //
  18735. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  18736. if (typeof index !== 'number') {
  18737. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  18738. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  18739. return NaN;
  18740. }
  18741. index = uint32Index;
  18742. }
  18743. return index < 0 ? ensureSize(iter) + index : index;
  18744. }
  18745. function returnTrue() {
  18746. return true;
  18747. }
  18748. function wholeSlice(begin, end, size) {
  18749. return (
  18750. ((begin === 0 && !isNeg(begin)) ||
  18751. (size !== undefined && begin <= -size)) &&
  18752. (end === undefined || (size !== undefined && end >= size))
  18753. );
  18754. }
  18755. function resolveBegin(begin, size) {
  18756. return resolveIndex(begin, size, 0);
  18757. }
  18758. function resolveEnd(end, size) {
  18759. return resolveIndex(end, size, size);
  18760. }
  18761. function resolveIndex(index, size, defaultIndex) {
  18762. // Sanitize indices using this shorthand for ToInt32(argument)
  18763. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  18764. return index === undefined
  18765. ? defaultIndex
  18766. : isNeg(index)
  18767. ? size === Infinity
  18768. ? size
  18769. : Math.max(0, size + index) | 0
  18770. : size === undefined || size === index
  18771. ? index
  18772. : Math.min(size, index) | 0;
  18773. }
  18774. function isNeg(value) {
  18775. // Account for -0 which is negative, but not less than 0.
  18776. return value < 0 || (value === 0 && 1 / value === -Infinity);
  18777. }
  18778. // Note: value is unchanged to not break immutable-devtools.
  18779. var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
  18780. function isCollection(maybeCollection) {
  18781. return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
  18782. }
  18783. var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';
  18784. function isKeyed(maybeKeyed) {
  18785. return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
  18786. }
  18787. var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';
  18788. function isIndexed(maybeIndexed) {
  18789. return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
  18790. }
  18791. function isAssociative(maybeAssociative) {
  18792. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  18793. }
  18794. var Collection = function Collection(value) {
  18795. return isCollection(value) ? value : Seq(value);
  18796. };
  18797. var KeyedCollection = /*@__PURE__*/(function (Collection) {
  18798. function KeyedCollection(value) {
  18799. return isKeyed(value) ? value : KeyedSeq(value);
  18800. }
  18801. if ( Collection ) KeyedCollection.__proto__ = Collection;
  18802. KeyedCollection.prototype = Object.create( Collection && Collection.prototype );
  18803. KeyedCollection.prototype.constructor = KeyedCollection;
  18804. return KeyedCollection;
  18805. }(Collection));
  18806. var IndexedCollection = /*@__PURE__*/(function (Collection) {
  18807. function IndexedCollection(value) {
  18808. return isIndexed(value) ? value : IndexedSeq(value);
  18809. }
  18810. if ( Collection ) IndexedCollection.__proto__ = Collection;
  18811. IndexedCollection.prototype = Object.create( Collection && Collection.prototype );
  18812. IndexedCollection.prototype.constructor = IndexedCollection;
  18813. return IndexedCollection;
  18814. }(Collection));
  18815. var SetCollection = /*@__PURE__*/(function (Collection) {
  18816. function SetCollection(value) {
  18817. return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
  18818. }
  18819. if ( Collection ) SetCollection.__proto__ = Collection;
  18820. SetCollection.prototype = Object.create( Collection && Collection.prototype );
  18821. SetCollection.prototype.constructor = SetCollection;
  18822. return SetCollection;
  18823. }(Collection));
  18824. Collection.Keyed = KeyedCollection;
  18825. Collection.Indexed = IndexedCollection;
  18826. Collection.Set = SetCollection;
  18827. var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';
  18828. function isSeq(maybeSeq) {
  18829. return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
  18830. }
  18831. var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
  18832. function isRecord(maybeRecord) {
  18833. return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
  18834. }
  18835. function isImmutable(maybeImmutable) {
  18836. return isCollection(maybeImmutable) || isRecord(maybeImmutable);
  18837. }
  18838. var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';
  18839. function isOrdered(maybeOrdered) {
  18840. return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
  18841. }
  18842. var ITERATE_KEYS = 0;
  18843. var ITERATE_VALUES = 1;
  18844. var ITERATE_ENTRIES = 2;
  18845. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  18846. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  18847. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  18848. var Iterator = function Iterator(next) {
  18849. this.next = next;
  18850. };
  18851. Iterator.prototype.toString = function toString () {
  18852. return '[Iterator]';
  18853. };
  18854. Iterator.KEYS = ITERATE_KEYS;
  18855. Iterator.VALUES = ITERATE_VALUES;
  18856. Iterator.ENTRIES = ITERATE_ENTRIES;
  18857. Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
  18858. return this.toString();
  18859. };
  18860. Iterator.prototype[ITERATOR_SYMBOL] = function() {
  18861. return this;
  18862. };
  18863. function iteratorValue(type, k, v, iteratorResult) {
  18864. var value = type === 0 ? k : type === 1 ? v : [k, v];
  18865. iteratorResult
  18866. ? (iteratorResult.value = value)
  18867. : (iteratorResult = {
  18868. value: value,
  18869. done: false,
  18870. });
  18871. return iteratorResult;
  18872. }
  18873. function iteratorDone() {
  18874. return { value: undefined, done: true };
  18875. }
  18876. function hasIterator(maybeIterable) {
  18877. return !!getIteratorFn(maybeIterable);
  18878. }
  18879. function isIterator(maybeIterator) {
  18880. return maybeIterator && typeof maybeIterator.next === 'function';
  18881. }
  18882. function getIterator(iterable) {
  18883. var iteratorFn = getIteratorFn(iterable);
  18884. return iteratorFn && iteratorFn.call(iterable);
  18885. }
  18886. function getIteratorFn(iterable) {
  18887. var iteratorFn =
  18888. iterable &&
  18889. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  18890. iterable[FAUX_ITERATOR_SYMBOL]);
  18891. if (typeof iteratorFn === 'function') {
  18892. return iteratorFn;
  18893. }
  18894. }
  18895. var hasOwnProperty = Object.prototype.hasOwnProperty;
  18896. function isArrayLike(value) {
  18897. if (Array.isArray(value) || typeof value === 'string') {
  18898. return true;
  18899. }
  18900. return (
  18901. value &&
  18902. typeof value === 'object' &&
  18903. Number.isInteger(value.length) &&
  18904. value.length >= 0 &&
  18905. (value.length === 0
  18906. ? // Only {length: 0} is considered Array-like.
  18907. Object.keys(value).length === 1
  18908. : // An object is only Array-like if it has a property where the last value
  18909. // in the array-like may be found (which could be undefined).
  18910. value.hasOwnProperty(value.length - 1))
  18911. );
  18912. }
  18913. var Seq = /*@__PURE__*/(function (Collection$$1) {
  18914. function Seq(value) {
  18915. return value === null || value === undefined
  18916. ? emptySequence()
  18917. : isImmutable(value)
  18918. ? value.toSeq()
  18919. : seqFromValue(value);
  18920. }
  18921. if ( Collection$$1 ) Seq.__proto__ = Collection$$1;
  18922. Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype );
  18923. Seq.prototype.constructor = Seq;
  18924. Seq.prototype.toSeq = function toSeq () {
  18925. return this;
  18926. };
  18927. Seq.prototype.toString = function toString () {
  18928. return this.__toString('Seq {', '}');
  18929. };
  18930. Seq.prototype.cacheResult = function cacheResult () {
  18931. if (!this._cache && this.__iterateUncached) {
  18932. this._cache = this.entrySeq().toArray();
  18933. this.size = this._cache.length;
  18934. }
  18935. return this;
  18936. };
  18937. // abstract __iterateUncached(fn, reverse)
  18938. Seq.prototype.__iterate = function __iterate (fn, reverse) {
  18939. var cache = this._cache;
  18940. if (cache) {
  18941. var size = cache.length;
  18942. var i = 0;
  18943. while (i !== size) {
  18944. var entry = cache[reverse ? size - ++i : i++];
  18945. if (fn(entry[1], entry[0], this) === false) {
  18946. break;
  18947. }
  18948. }
  18949. return i;
  18950. }
  18951. return this.__iterateUncached(fn, reverse);
  18952. };
  18953. // abstract __iteratorUncached(type, reverse)
  18954. Seq.prototype.__iterator = function __iterator (type, reverse) {
  18955. var cache = this._cache;
  18956. if (cache) {
  18957. var size = cache.length;
  18958. var i = 0;
  18959. return new Iterator(function () {
  18960. if (i === size) {
  18961. return iteratorDone();
  18962. }
  18963. var entry = cache[reverse ? size - ++i : i++];
  18964. return iteratorValue(type, entry[0], entry[1]);
  18965. });
  18966. }
  18967. return this.__iteratorUncached(type, reverse);
  18968. };
  18969. return Seq;
  18970. }(Collection));
  18971. var KeyedSeq = /*@__PURE__*/(function (Seq) {
  18972. function KeyedSeq(value) {
  18973. return value === null || value === undefined
  18974. ? emptySequence().toKeyedSeq()
  18975. : isCollection(value)
  18976. ? isKeyed(value)
  18977. ? value.toSeq()
  18978. : value.fromEntrySeq()
  18979. : isRecord(value)
  18980. ? value.toSeq()
  18981. : keyedSeqFromValue(value);
  18982. }
  18983. if ( Seq ) KeyedSeq.__proto__ = Seq;
  18984. KeyedSeq.prototype = Object.create( Seq && Seq.prototype );
  18985. KeyedSeq.prototype.constructor = KeyedSeq;
  18986. KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () {
  18987. return this;
  18988. };
  18989. return KeyedSeq;
  18990. }(Seq));
  18991. var IndexedSeq = /*@__PURE__*/(function (Seq) {
  18992. function IndexedSeq(value) {
  18993. return value === null || value === undefined
  18994. ? emptySequence()
  18995. : isCollection(value)
  18996. ? isKeyed(value)
  18997. ? value.entrySeq()
  18998. : value.toIndexedSeq()
  18999. : isRecord(value)
  19000. ? value.toSeq().entrySeq()
  19001. : indexedSeqFromValue(value);
  19002. }
  19003. if ( Seq ) IndexedSeq.__proto__ = Seq;
  19004. IndexedSeq.prototype = Object.create( Seq && Seq.prototype );
  19005. IndexedSeq.prototype.constructor = IndexedSeq;
  19006. IndexedSeq.of = function of (/*...values*/) {
  19007. return IndexedSeq(arguments);
  19008. };
  19009. IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () {
  19010. return this;
  19011. };
  19012. IndexedSeq.prototype.toString = function toString () {
  19013. return this.__toString('Seq [', ']');
  19014. };
  19015. return IndexedSeq;
  19016. }(Seq));
  19017. var SetSeq = /*@__PURE__*/(function (Seq) {
  19018. function SetSeq(value) {
  19019. return (isCollection(value) && !isAssociative(value)
  19020. ? value
  19021. : IndexedSeq(value)
  19022. ).toSetSeq();
  19023. }
  19024. if ( Seq ) SetSeq.__proto__ = Seq;
  19025. SetSeq.prototype = Object.create( Seq && Seq.prototype );
  19026. SetSeq.prototype.constructor = SetSeq;
  19027. SetSeq.of = function of (/*...values*/) {
  19028. return SetSeq(arguments);
  19029. };
  19030. SetSeq.prototype.toSetSeq = function toSetSeq () {
  19031. return this;
  19032. };
  19033. return SetSeq;
  19034. }(Seq));
  19035. Seq.isSeq = isSeq;
  19036. Seq.Keyed = KeyedSeq;
  19037. Seq.Set = SetSeq;
  19038. Seq.Indexed = IndexedSeq;
  19039. Seq.prototype[IS_SEQ_SYMBOL] = true;
  19040. // #pragma Root Sequences
  19041. var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {
  19042. function ArraySeq(array) {
  19043. this._array = array;
  19044. this.size = array.length;
  19045. }
  19046. if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq;
  19047. ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  19048. ArraySeq.prototype.constructor = ArraySeq;
  19049. ArraySeq.prototype.get = function get (index, notSetValue) {
  19050. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  19051. };
  19052. ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {
  19053. var array = this._array;
  19054. var size = array.length;
  19055. var i = 0;
  19056. while (i !== size) {
  19057. var ii = reverse ? size - ++i : i++;
  19058. if (fn(array[ii], ii, this) === false) {
  19059. break;
  19060. }
  19061. }
  19062. return i;
  19063. };
  19064. ArraySeq.prototype.__iterator = function __iterator (type, reverse) {
  19065. var array = this._array;
  19066. var size = array.length;
  19067. var i = 0;
  19068. return new Iterator(function () {
  19069. if (i === size) {
  19070. return iteratorDone();
  19071. }
  19072. var ii = reverse ? size - ++i : i++;
  19073. return iteratorValue(type, ii, array[ii]);
  19074. });
  19075. };
  19076. return ArraySeq;
  19077. }(IndexedSeq));
  19078. var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {
  19079. function ObjectSeq(object) {
  19080. var keys = Object.keys(object);
  19081. this._object = object;
  19082. this._keys = keys;
  19083. this.size = keys.length;
  19084. }
  19085. if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq;
  19086. ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  19087. ObjectSeq.prototype.constructor = ObjectSeq;
  19088. ObjectSeq.prototype.get = function get (key, notSetValue) {
  19089. if (notSetValue !== undefined && !this.has(key)) {
  19090. return notSetValue;
  19091. }
  19092. return this._object[key];
  19093. };
  19094. ObjectSeq.prototype.has = function has (key) {
  19095. return hasOwnProperty.call(this._object, key);
  19096. };
  19097. ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
  19098. var object = this._object;
  19099. var keys = this._keys;
  19100. var size = keys.length;
  19101. var i = 0;
  19102. while (i !== size) {
  19103. var key = keys[reverse ? size - ++i : i++];
  19104. if (fn(object[key], key, this) === false) {
  19105. break;
  19106. }
  19107. }
  19108. return i;
  19109. };
  19110. ObjectSeq.prototype.__iterator = function __iterator (type, reverse) {
  19111. var object = this._object;
  19112. var keys = this._keys;
  19113. var size = keys.length;
  19114. var i = 0;
  19115. return new Iterator(function () {
  19116. if (i === size) {
  19117. return iteratorDone();
  19118. }
  19119. var key = keys[reverse ? size - ++i : i++];
  19120. return iteratorValue(type, key, object[key]);
  19121. });
  19122. };
  19123. return ObjectSeq;
  19124. }(KeyedSeq));
  19125. ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
  19126. var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {
  19127. function CollectionSeq(collection) {
  19128. this._collection = collection;
  19129. this.size = collection.length || collection.size;
  19130. }
  19131. if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq;
  19132. CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  19133. CollectionSeq.prototype.constructor = CollectionSeq;
  19134. CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
  19135. if (reverse) {
  19136. return this.cacheResult().__iterate(fn, reverse);
  19137. }
  19138. var collection = this._collection;
  19139. var iterator = getIterator(collection);
  19140. var iterations = 0;
  19141. if (isIterator(iterator)) {
  19142. var step;
  19143. while (!(step = iterator.next()).done) {
  19144. if (fn(step.value, iterations++, this) === false) {
  19145. break;
  19146. }
  19147. }
  19148. }
  19149. return iterations;
  19150. };
  19151. CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {
  19152. if (reverse) {
  19153. return this.cacheResult().__iterator(type, reverse);
  19154. }
  19155. var collection = this._collection;
  19156. var iterator = getIterator(collection);
  19157. if (!isIterator(iterator)) {
  19158. return new Iterator(iteratorDone);
  19159. }
  19160. var iterations = 0;
  19161. return new Iterator(function () {
  19162. var step = iterator.next();
  19163. return step.done ? step : iteratorValue(type, iterations++, step.value);
  19164. });
  19165. };
  19166. return CollectionSeq;
  19167. }(IndexedSeq));
  19168. // # pragma Helper functions
  19169. var EMPTY_SEQ;
  19170. function emptySequence() {
  19171. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  19172. }
  19173. function keyedSeqFromValue(value) {
  19174. var seq = Array.isArray(value)
  19175. ? new ArraySeq(value)
  19176. : hasIterator(value)
  19177. ? new CollectionSeq(value)
  19178. : undefined;
  19179. if (seq) {
  19180. return seq.fromEntrySeq();
  19181. }
  19182. if (typeof value === 'object') {
  19183. return new ObjectSeq(value);
  19184. }
  19185. throw new TypeError(
  19186. 'Expected Array or collection object of [k, v] entries, or keyed object: ' +
  19187. value
  19188. );
  19189. }
  19190. function indexedSeqFromValue(value) {
  19191. var seq = maybeIndexedSeqFromValue(value);
  19192. if (seq) {
  19193. return seq;
  19194. }
  19195. throw new TypeError(
  19196. 'Expected Array or collection object of values: ' + value
  19197. );
  19198. }
  19199. function seqFromValue(value) {
  19200. var seq = maybeIndexedSeqFromValue(value);
  19201. if (seq) {
  19202. return seq;
  19203. }
  19204. if (typeof value === 'object') {
  19205. return new ObjectSeq(value);
  19206. }
  19207. throw new TypeError(
  19208. 'Expected Array or collection object of values, or keyed object: ' + value
  19209. );
  19210. }
  19211. function maybeIndexedSeqFromValue(value) {
  19212. return isArrayLike(value)
  19213. ? new ArraySeq(value)
  19214. : hasIterator(value)
  19215. ? new CollectionSeq(value)
  19216. : undefined;
  19217. }
  19218. var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@';
  19219. function isMap(maybeMap) {
  19220. return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
  19221. }
  19222. function isOrderedMap(maybeOrderedMap) {
  19223. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  19224. }
  19225. function isValueObject(maybeValue) {
  19226. return Boolean(
  19227. maybeValue &&
  19228. typeof maybeValue.equals === 'function' &&
  19229. typeof maybeValue.hashCode === 'function'
  19230. );
  19231. }
  19232. /**
  19233. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  19234. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  19235. *
  19236. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  19237. * value, which is different from the algorithm described by
  19238. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  19239. *
  19240. * This is extended further to allow Objects to describe the values they
  19241. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  19242. *
  19243. * Note: because of this extension, the key equality of Immutable.Map and the
  19244. * value equality of Immutable.Set will differ from ES6 Map and Set.
  19245. *
  19246. * ### Defining custom values
  19247. *
  19248. * The easiest way to describe the value an object represents is by implementing
  19249. * `valueOf`. For example, `Date` represents a value by returning a unix
  19250. * timestamp for `valueOf`:
  19251. *
  19252. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  19253. * var date2 = new Date(1234567890000);
  19254. * date1.valueOf(); // 1234567890000
  19255. * assert( date1 !== date2 );
  19256. * assert( Immutable.is( date1, date2 ) );
  19257. *
  19258. * Note: overriding `valueOf` may have other implications if you use this object
  19259. * where JavaScript expects a primitive, such as implicit string coercion.
  19260. *
  19261. * For more complex types, especially collections, implementing `valueOf` may
  19262. * not be performant. An alternative is to implement `equals` and `hashCode`.
  19263. *
  19264. * `equals` takes another object, presumably of similar type, and returns true
  19265. * if it is equal. Equality is symmetrical, so the same result should be
  19266. * returned if this and the argument are flipped.
  19267. *
  19268. * assert( a.equals(b) === b.equals(a) );
  19269. *
  19270. * `hashCode` returns a 32bit integer number representing the object which will
  19271. * be used to determine how to store the value object in a Map or Set. You must
  19272. * provide both or neither methods, one must not exist without the other.
  19273. *
  19274. * Also, an important relationship between these methods must be upheld: if two
  19275. * values are equal, they *must* return the same hashCode. If the values are not
  19276. * equal, they might have the same hashCode; this is called a hash collision,
  19277. * and while undesirable for performance reasons, it is acceptable.
  19278. *
  19279. * if (a.equals(b)) {
  19280. * assert( a.hashCode() === b.hashCode() );
  19281. * }
  19282. *
  19283. * All Immutable collections are Value Objects: they implement `equals()`
  19284. * and `hashCode()`.
  19285. */
  19286. function is(valueA, valueB) {
  19287. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  19288. return true;
  19289. }
  19290. if (!valueA || !valueB) {
  19291. return false;
  19292. }
  19293. if (
  19294. typeof valueA.valueOf === 'function' &&
  19295. typeof valueB.valueOf === 'function'
  19296. ) {
  19297. valueA = valueA.valueOf();
  19298. valueB = valueB.valueOf();
  19299. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  19300. return true;
  19301. }
  19302. if (!valueA || !valueB) {
  19303. return false;
  19304. }
  19305. }
  19306. return !!(
  19307. isValueObject(valueA) &&
  19308. isValueObject(valueB) &&
  19309. valueA.equals(valueB)
  19310. );
  19311. }
  19312. var imul =
  19313. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2
  19314. ? Math.imul
  19315. : function imul(a, b) {
  19316. a |= 0; // int
  19317. b |= 0; // int
  19318. var c = a & 0xffff;
  19319. var d = b & 0xffff;
  19320. // Shift by 0 fixes the sign on the high part.
  19321. return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int
  19322. };
  19323. // v8 has an optimization for storing 31-bit signed numbers.
  19324. // Values which have either 00 or 11 as the high order bits qualify.
  19325. // This function drops the highest order bit in a signed number, maintaining
  19326. // the sign bit.
  19327. function smi(i32) {
  19328. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  19329. }
  19330. var defaultValueOf = Object.prototype.valueOf;
  19331. function hash(o) {
  19332. switch (typeof o) {
  19333. case 'boolean':
  19334. // The hash values for built-in constants are a 1 value for each 5-byte
  19335. // shift region expect for the first, which encodes the value. This
  19336. // reduces the odds of a hash collision for these common values.
  19337. return o ? 0x42108421 : 0x42108420;
  19338. case 'number':
  19339. return hashNumber(o);
  19340. case 'string':
  19341. return o.length > STRING_HASH_CACHE_MIN_STRLEN
  19342. ? cachedHashString(o)
  19343. : hashString(o);
  19344. case 'object':
  19345. case 'function':
  19346. if (o === null) {
  19347. return 0x42108422;
  19348. }
  19349. if (typeof o.hashCode === 'function') {
  19350. // Drop any high bits from accidentally long hash codes.
  19351. return smi(o.hashCode(o));
  19352. }
  19353. if (o.valueOf !== defaultValueOf && typeof o.valueOf === 'function') {
  19354. o = o.valueOf(o);
  19355. }
  19356. return hashJSObj(o);
  19357. case 'undefined':
  19358. return 0x42108423;
  19359. default:
  19360. if (typeof o.toString === 'function') {
  19361. return hashString(o.toString());
  19362. }
  19363. throw new Error('Value type ' + typeof o + ' cannot be hashed.');
  19364. }
  19365. }
  19366. // Compress arbitrarily large numbers into smi hashes.
  19367. function hashNumber(n) {
  19368. if (n !== n || n === Infinity) {
  19369. return 0;
  19370. }
  19371. var hash = n | 0;
  19372. if (hash !== n) {
  19373. hash ^= n * 0xffffffff;
  19374. }
  19375. while (n > 0xffffffff) {
  19376. n /= 0xffffffff;
  19377. hash ^= n;
  19378. }
  19379. return smi(hash);
  19380. }
  19381. function cachedHashString(string) {
  19382. var hashed = stringHashCache[string];
  19383. if (hashed === undefined) {
  19384. hashed = hashString(string);
  19385. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  19386. STRING_HASH_CACHE_SIZE = 0;
  19387. stringHashCache = {};
  19388. }
  19389. STRING_HASH_CACHE_SIZE++;
  19390. stringHashCache[string] = hashed;
  19391. }
  19392. return hashed;
  19393. }
  19394. // http://jsperf.com/hashing-strings
  19395. function hashString(string) {
  19396. // This is the hash from JVM
  19397. // The hash code for a string is computed as
  19398. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  19399. // where s[i] is the ith character of the string and n is the length of
  19400. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  19401. // (exclusive) by dropping high bits.
  19402. var hashed = 0;
  19403. for (var ii = 0; ii < string.length; ii++) {
  19404. hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
  19405. }
  19406. return smi(hashed);
  19407. }
  19408. function hashJSObj(obj) {
  19409. var hashed;
  19410. if (usingWeakMap) {
  19411. hashed = weakMap.get(obj);
  19412. if (hashed !== undefined) {
  19413. return hashed;
  19414. }
  19415. }
  19416. hashed = obj[UID_HASH_KEY];
  19417. if (hashed !== undefined) {
  19418. return hashed;
  19419. }
  19420. if (!canDefineProperty) {
  19421. hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  19422. if (hashed !== undefined) {
  19423. return hashed;
  19424. }
  19425. hashed = getIENodeHash(obj);
  19426. if (hashed !== undefined) {
  19427. return hashed;
  19428. }
  19429. }
  19430. hashed = ++objHashUID;
  19431. if (objHashUID & 0x40000000) {
  19432. objHashUID = 0;
  19433. }
  19434. if (usingWeakMap) {
  19435. weakMap.set(obj, hashed);
  19436. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  19437. throw new Error('Non-extensible objects are not allowed as keys.');
  19438. } else if (canDefineProperty) {
  19439. Object.defineProperty(obj, UID_HASH_KEY, {
  19440. enumerable: false,
  19441. configurable: false,
  19442. writable: false,
  19443. value: hashed,
  19444. });
  19445. } else if (
  19446. obj.propertyIsEnumerable !== undefined &&
  19447. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable
  19448. ) {
  19449. // Since we can't define a non-enumerable property on the object
  19450. // we'll hijack one of the less-used non-enumerable properties to
  19451. // save our hash on it. Since this is a function it will not show up in
  19452. // `JSON.stringify` which is what we want.
  19453. obj.propertyIsEnumerable = function() {
  19454. return this.constructor.prototype.propertyIsEnumerable.apply(
  19455. this,
  19456. arguments
  19457. );
  19458. };
  19459. obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
  19460. } else if (obj.nodeType !== undefined) {
  19461. // At this point we couldn't get the IE `uniqueID` to use as a hash
  19462. // and we couldn't use a non-enumerable property to exploit the
  19463. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  19464. // itself.
  19465. obj[UID_HASH_KEY] = hashed;
  19466. } else {
  19467. throw new Error('Unable to set a non-enumerable property on object.');
  19468. }
  19469. return hashed;
  19470. }
  19471. // Get references to ES5 object methods.
  19472. var isExtensible = Object.isExtensible;
  19473. // True if Object.defineProperty works as expected. IE8 fails this test.
  19474. var canDefineProperty = (function() {
  19475. try {
  19476. Object.defineProperty({}, '@', {});
  19477. return true;
  19478. } catch (e) {
  19479. return false;
  19480. }
  19481. })();
  19482. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  19483. // and avoid memory leaks from the IE cloneNode bug.
  19484. function getIENodeHash(node) {
  19485. if (node && node.nodeType > 0) {
  19486. switch (node.nodeType) {
  19487. case 1: // Element
  19488. return node.uniqueID;
  19489. case 9: // Document
  19490. return node.documentElement && node.documentElement.uniqueID;
  19491. }
  19492. }
  19493. }
  19494. // If possible, use a WeakMap.
  19495. var usingWeakMap = typeof WeakMap === 'function';
  19496. var weakMap;
  19497. if (usingWeakMap) {
  19498. weakMap = new WeakMap();
  19499. }
  19500. var objHashUID = 0;
  19501. var UID_HASH_KEY = '__immutablehash__';
  19502. if (typeof Symbol === 'function') {
  19503. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  19504. }
  19505. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  19506. var STRING_HASH_CACHE_MAX_SIZE = 255;
  19507. var STRING_HASH_CACHE_SIZE = 0;
  19508. var stringHashCache = {};
  19509. var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
  19510. function ToKeyedSequence(indexed, useKeys) {
  19511. this._iter = indexed;
  19512. this._useKeys = useKeys;
  19513. this.size = indexed.size;
  19514. }
  19515. if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1;
  19516. ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
  19517. ToKeyedSequence.prototype.constructor = ToKeyedSequence;
  19518. ToKeyedSequence.prototype.get = function get (key, notSetValue) {
  19519. return this._iter.get(key, notSetValue);
  19520. };
  19521. ToKeyedSequence.prototype.has = function has (key) {
  19522. return this._iter.has(key);
  19523. };
  19524. ToKeyedSequence.prototype.valueSeq = function valueSeq () {
  19525. return this._iter.valueSeq();
  19526. };
  19527. ToKeyedSequence.prototype.reverse = function reverse () {
  19528. var this$1 = this;
  19529. var reversedSequence = reverseFactory(this, true);
  19530. if (!this._useKeys) {
  19531. reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); };
  19532. }
  19533. return reversedSequence;
  19534. };
  19535. ToKeyedSequence.prototype.map = function map (mapper, context) {
  19536. var this$1 = this;
  19537. var mappedSequence = mapFactory(this, mapper, context);
  19538. if (!this._useKeys) {
  19539. mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); };
  19540. }
  19541. return mappedSequence;
  19542. };
  19543. ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  19544. var this$1 = this;
  19545. return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse);
  19546. };
  19547. ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {
  19548. return this._iter.__iterator(type, reverse);
  19549. };
  19550. return ToKeyedSequence;
  19551. }(KeyedSeq));
  19552. ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
  19553. var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq$$1) {
  19554. function ToIndexedSequence(iter) {
  19555. this._iter = iter;
  19556. this.size = iter.size;
  19557. }
  19558. if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1;
  19559. ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  19560. ToIndexedSequence.prototype.constructor = ToIndexedSequence;
  19561. ToIndexedSequence.prototype.includes = function includes (value) {
  19562. return this._iter.includes(value);
  19563. };
  19564. ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  19565. var this$1 = this;
  19566. var i = 0;
  19567. reverse && ensureSize(this);
  19568. return this._iter.__iterate(
  19569. function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); },
  19570. reverse
  19571. );
  19572. };
  19573. ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {
  19574. var this$1 = this;
  19575. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  19576. var i = 0;
  19577. reverse && ensureSize(this);
  19578. return new Iterator(function () {
  19579. var step = iterator.next();
  19580. return step.done
  19581. ? step
  19582. : iteratorValue(
  19583. type,
  19584. reverse ? this$1.size - ++i : i++,
  19585. step.value,
  19586. step
  19587. );
  19588. });
  19589. };
  19590. return ToIndexedSequence;
  19591. }(IndexedSeq));
  19592. var ToSetSequence = /*@__PURE__*/(function (SetSeq$$1) {
  19593. function ToSetSequence(iter) {
  19594. this._iter = iter;
  19595. this.size = iter.size;
  19596. }
  19597. if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1;
  19598. ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype );
  19599. ToSetSequence.prototype.constructor = ToSetSequence;
  19600. ToSetSequence.prototype.has = function has (key) {
  19601. return this._iter.includes(key);
  19602. };
  19603. ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {
  19604. var this$1 = this;
  19605. return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse);
  19606. };
  19607. ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {
  19608. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  19609. return new Iterator(function () {
  19610. var step = iterator.next();
  19611. return step.done
  19612. ? step
  19613. : iteratorValue(type, step.value, step.value, step);
  19614. });
  19615. };
  19616. return ToSetSequence;
  19617. }(SetSeq));
  19618. var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
  19619. function FromEntriesSequence(entries) {
  19620. this._iter = entries;
  19621. this.size = entries.size;
  19622. }
  19623. if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1;
  19624. FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
  19625. FromEntriesSequence.prototype.constructor = FromEntriesSequence;
  19626. FromEntriesSequence.prototype.entrySeq = function entrySeq () {
  19627. return this._iter.toSeq();
  19628. };
  19629. FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {
  19630. var this$1 = this;
  19631. return this._iter.__iterate(function (entry) {
  19632. // Check if entry exists first so array access doesn't throw for holes
  19633. // in the parent iteration.
  19634. if (entry) {
  19635. validateEntry(entry);
  19636. var indexedCollection = isCollection(entry);
  19637. return fn(
  19638. indexedCollection ? entry.get(1) : entry[1],
  19639. indexedCollection ? entry.get(0) : entry[0],
  19640. this$1
  19641. );
  19642. }
  19643. }, reverse);
  19644. };
  19645. FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) {
  19646. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  19647. return new Iterator(function () {
  19648. while (true) {
  19649. var step = iterator.next();
  19650. if (step.done) {
  19651. return step;
  19652. }
  19653. var entry = step.value;
  19654. // Check if entry exists first so array access doesn't throw for holes
  19655. // in the parent iteration.
  19656. if (entry) {
  19657. validateEntry(entry);
  19658. var indexedCollection = isCollection(entry);
  19659. return iteratorValue(
  19660. type,
  19661. indexedCollection ? entry.get(0) : entry[0],
  19662. indexedCollection ? entry.get(1) : entry[1],
  19663. step
  19664. );
  19665. }
  19666. }
  19667. });
  19668. };
  19669. return FromEntriesSequence;
  19670. }(KeyedSeq));
  19671. ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
  19672. function flipFactory(collection) {
  19673. var flipSequence = makeSequence(collection);
  19674. flipSequence._iter = collection;
  19675. flipSequence.size = collection.size;
  19676. flipSequence.flip = function () { return collection; };
  19677. flipSequence.reverse = function() {
  19678. var reversedSequence = collection.reverse.apply(this); // super.reverse()
  19679. reversedSequence.flip = function () { return collection.reverse(); };
  19680. return reversedSequence;
  19681. };
  19682. flipSequence.has = function (key) { return collection.includes(key); };
  19683. flipSequence.includes = function (key) { return collection.has(key); };
  19684. flipSequence.cacheResult = cacheResultThrough;
  19685. flipSequence.__iterateUncached = function(fn, reverse) {
  19686. var this$1 = this;
  19687. return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse);
  19688. };
  19689. flipSequence.__iteratorUncached = function(type, reverse) {
  19690. if (type === ITERATE_ENTRIES) {
  19691. var iterator = collection.__iterator(type, reverse);
  19692. return new Iterator(function () {
  19693. var step = iterator.next();
  19694. if (!step.done) {
  19695. var k = step.value[0];
  19696. step.value[0] = step.value[1];
  19697. step.value[1] = k;
  19698. }
  19699. return step;
  19700. });
  19701. }
  19702. return collection.__iterator(
  19703. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  19704. reverse
  19705. );
  19706. };
  19707. return flipSequence;
  19708. }
  19709. function mapFactory(collection, mapper, context) {
  19710. var mappedSequence = makeSequence(collection);
  19711. mappedSequence.size = collection.size;
  19712. mappedSequence.has = function (key) { return collection.has(key); };
  19713. mappedSequence.get = function (key, notSetValue) {
  19714. var v = collection.get(key, NOT_SET);
  19715. return v === NOT_SET
  19716. ? notSetValue
  19717. : mapper.call(context, v, key, collection);
  19718. };
  19719. mappedSequence.__iterateUncached = function(fn, reverse) {
  19720. var this$1 = this;
  19721. return collection.__iterate(
  19722. function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; },
  19723. reverse
  19724. );
  19725. };
  19726. mappedSequence.__iteratorUncached = function(type, reverse) {
  19727. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  19728. return new Iterator(function () {
  19729. var step = iterator.next();
  19730. if (step.done) {
  19731. return step;
  19732. }
  19733. var entry = step.value;
  19734. var key = entry[0];
  19735. return iteratorValue(
  19736. type,
  19737. key,
  19738. mapper.call(context, entry[1], key, collection),
  19739. step
  19740. );
  19741. });
  19742. };
  19743. return mappedSequence;
  19744. }
  19745. function reverseFactory(collection, useKeys) {
  19746. var this$1 = this;
  19747. var reversedSequence = makeSequence(collection);
  19748. reversedSequence._iter = collection;
  19749. reversedSequence.size = collection.size;
  19750. reversedSequence.reverse = function () { return collection; };
  19751. if (collection.flip) {
  19752. reversedSequence.flip = function() {
  19753. var flipSequence = flipFactory(collection);
  19754. flipSequence.reverse = function () { return collection.flip(); };
  19755. return flipSequence;
  19756. };
  19757. }
  19758. reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); };
  19759. reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); };
  19760. reversedSequence.includes = function (value) { return collection.includes(value); };
  19761. reversedSequence.cacheResult = cacheResultThrough;
  19762. reversedSequence.__iterate = function(fn, reverse) {
  19763. var this$1 = this;
  19764. var i = 0;
  19765. reverse && ensureSize(collection);
  19766. return collection.__iterate(
  19767. function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); },
  19768. !reverse
  19769. );
  19770. };
  19771. reversedSequence.__iterator = function (type, reverse) {
  19772. var i = 0;
  19773. reverse && ensureSize(collection);
  19774. var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse);
  19775. return new Iterator(function () {
  19776. var step = iterator.next();
  19777. if (step.done) {
  19778. return step;
  19779. }
  19780. var entry = step.value;
  19781. return iteratorValue(
  19782. type,
  19783. useKeys ? entry[0] : reverse ? this$1.size - ++i : i++,
  19784. entry[1],
  19785. step
  19786. );
  19787. });
  19788. };
  19789. return reversedSequence;
  19790. }
  19791. function filterFactory(collection, predicate, context, useKeys) {
  19792. var filterSequence = makeSequence(collection);
  19793. if (useKeys) {
  19794. filterSequence.has = function (key) {
  19795. var v = collection.get(key, NOT_SET);
  19796. return v !== NOT_SET && !!predicate.call(context, v, key, collection);
  19797. };
  19798. filterSequence.get = function (key, notSetValue) {
  19799. var v = collection.get(key, NOT_SET);
  19800. return v !== NOT_SET && predicate.call(context, v, key, collection)
  19801. ? v
  19802. : notSetValue;
  19803. };
  19804. }
  19805. filterSequence.__iterateUncached = function(fn, reverse) {
  19806. var this$1 = this;
  19807. var iterations = 0;
  19808. collection.__iterate(function (v, k, c) {
  19809. if (predicate.call(context, v, k, c)) {
  19810. iterations++;
  19811. return fn(v, useKeys ? k : iterations - 1, this$1);
  19812. }
  19813. }, reverse);
  19814. return iterations;
  19815. };
  19816. filterSequence.__iteratorUncached = function(type, reverse) {
  19817. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  19818. var iterations = 0;
  19819. return new Iterator(function () {
  19820. while (true) {
  19821. var step = iterator.next();
  19822. if (step.done) {
  19823. return step;
  19824. }
  19825. var entry = step.value;
  19826. var key = entry[0];
  19827. var value = entry[1];
  19828. if (predicate.call(context, value, key, collection)) {
  19829. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  19830. }
  19831. }
  19832. });
  19833. };
  19834. return filterSequence;
  19835. }
  19836. function countByFactory(collection, grouper, context) {
  19837. var groups = Map().asMutable();
  19838. collection.__iterate(function (v, k) {
  19839. groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; });
  19840. });
  19841. return groups.asImmutable();
  19842. }
  19843. function groupByFactory(collection, grouper, context) {
  19844. var isKeyedIter = isKeyed(collection);
  19845. var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable();
  19846. collection.__iterate(function (v, k) {
  19847. groups.update(
  19848. grouper.call(context, v, k, collection),
  19849. function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); }
  19850. );
  19851. });
  19852. var coerce = collectionClass(collection);
  19853. return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable();
  19854. }
  19855. function sliceFactory(collection, begin, end, useKeys) {
  19856. var originalSize = collection.size;
  19857. if (wholeSlice(begin, end, originalSize)) {
  19858. return collection;
  19859. }
  19860. var resolvedBegin = resolveBegin(begin, originalSize);
  19861. var resolvedEnd = resolveEnd(end, originalSize);
  19862. // begin or end will be NaN if they were provided as negative numbers and
  19863. // this collection's size is unknown. In that case, cache first so there is
  19864. // a known size and these do not resolve to NaN.
  19865. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  19866. return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys);
  19867. }
  19868. // Note: resolvedEnd is undefined when the original sequence's length is
  19869. // unknown and this slice did not supply an end and should contain all
  19870. // elements after resolvedBegin.
  19871. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  19872. var resolvedSize = resolvedEnd - resolvedBegin;
  19873. var sliceSize;
  19874. if (resolvedSize === resolvedSize) {
  19875. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  19876. }
  19877. var sliceSeq = makeSequence(collection);
  19878. // If collection.size is undefined, the size of the realized sliceSeq is
  19879. // unknown at this point unless the number of items to slice is 0
  19880. sliceSeq.size =
  19881. sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined;
  19882. if (!useKeys && isSeq(collection) && sliceSize >= 0) {
  19883. sliceSeq.get = function(index, notSetValue) {
  19884. index = wrapIndex(this, index);
  19885. return index >= 0 && index < sliceSize
  19886. ? collection.get(index + resolvedBegin, notSetValue)
  19887. : notSetValue;
  19888. };
  19889. }
  19890. sliceSeq.__iterateUncached = function(fn, reverse) {
  19891. var this$1 = this;
  19892. if (sliceSize === 0) {
  19893. return 0;
  19894. }
  19895. if (reverse) {
  19896. return this.cacheResult().__iterate(fn, reverse);
  19897. }
  19898. var skipped = 0;
  19899. var isSkipping = true;
  19900. var iterations = 0;
  19901. collection.__iterate(function (v, k) {
  19902. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  19903. iterations++;
  19904. return (
  19905. fn(v, useKeys ? k : iterations - 1, this$1) !== false &&
  19906. iterations !== sliceSize
  19907. );
  19908. }
  19909. });
  19910. return iterations;
  19911. };
  19912. sliceSeq.__iteratorUncached = function(type, reverse) {
  19913. if (sliceSize !== 0 && reverse) {
  19914. return this.cacheResult().__iterator(type, reverse);
  19915. }
  19916. // Don't bother instantiating parent iterator if taking 0.
  19917. if (sliceSize === 0) {
  19918. return new Iterator(iteratorDone);
  19919. }
  19920. var iterator = collection.__iterator(type, reverse);
  19921. var skipped = 0;
  19922. var iterations = 0;
  19923. return new Iterator(function () {
  19924. while (skipped++ < resolvedBegin) {
  19925. iterator.next();
  19926. }
  19927. if (++iterations > sliceSize) {
  19928. return iteratorDone();
  19929. }
  19930. var step = iterator.next();
  19931. if (useKeys || type === ITERATE_VALUES || step.done) {
  19932. return step;
  19933. }
  19934. if (type === ITERATE_KEYS) {
  19935. return iteratorValue(type, iterations - 1, undefined, step);
  19936. }
  19937. return iteratorValue(type, iterations - 1, step.value[1], step);
  19938. });
  19939. };
  19940. return sliceSeq;
  19941. }
  19942. function takeWhileFactory(collection, predicate, context) {
  19943. var takeSequence = makeSequence(collection);
  19944. takeSequence.__iterateUncached = function(fn, reverse) {
  19945. var this$1 = this;
  19946. if (reverse) {
  19947. return this.cacheResult().__iterate(fn, reverse);
  19948. }
  19949. var iterations = 0;
  19950. collection.__iterate(
  19951. function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); }
  19952. );
  19953. return iterations;
  19954. };
  19955. takeSequence.__iteratorUncached = function(type, reverse) {
  19956. var this$1 = this;
  19957. if (reverse) {
  19958. return this.cacheResult().__iterator(type, reverse);
  19959. }
  19960. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  19961. var iterating = true;
  19962. return new Iterator(function () {
  19963. if (!iterating) {
  19964. return iteratorDone();
  19965. }
  19966. var step = iterator.next();
  19967. if (step.done) {
  19968. return step;
  19969. }
  19970. var entry = step.value;
  19971. var k = entry[0];
  19972. var v = entry[1];
  19973. if (!predicate.call(context, v, k, this$1)) {
  19974. iterating = false;
  19975. return iteratorDone();
  19976. }
  19977. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  19978. });
  19979. };
  19980. return takeSequence;
  19981. }
  19982. function skipWhileFactory(collection, predicate, context, useKeys) {
  19983. var skipSequence = makeSequence(collection);
  19984. skipSequence.__iterateUncached = function(fn, reverse) {
  19985. var this$1 = this;
  19986. if (reverse) {
  19987. return this.cacheResult().__iterate(fn, reverse);
  19988. }
  19989. var isSkipping = true;
  19990. var iterations = 0;
  19991. collection.__iterate(function (v, k, c) {
  19992. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  19993. iterations++;
  19994. return fn(v, useKeys ? k : iterations - 1, this$1);
  19995. }
  19996. });
  19997. return iterations;
  19998. };
  19999. skipSequence.__iteratorUncached = function(type, reverse) {
  20000. var this$1 = this;
  20001. if (reverse) {
  20002. return this.cacheResult().__iterator(type, reverse);
  20003. }
  20004. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  20005. var skipping = true;
  20006. var iterations = 0;
  20007. return new Iterator(function () {
  20008. var step;
  20009. var k;
  20010. var v;
  20011. do {
  20012. step = iterator.next();
  20013. if (step.done) {
  20014. if (useKeys || type === ITERATE_VALUES) {
  20015. return step;
  20016. }
  20017. if (type === ITERATE_KEYS) {
  20018. return iteratorValue(type, iterations++, undefined, step);
  20019. }
  20020. return iteratorValue(type, iterations++, step.value[1], step);
  20021. }
  20022. var entry = step.value;
  20023. k = entry[0];
  20024. v = entry[1];
  20025. skipping && (skipping = predicate.call(context, v, k, this$1));
  20026. } while (skipping);
  20027. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  20028. });
  20029. };
  20030. return skipSequence;
  20031. }
  20032. function concatFactory(collection, values) {
  20033. var isKeyedCollection = isKeyed(collection);
  20034. var iters = [collection]
  20035. .concat(values)
  20036. .map(function (v) {
  20037. if (!isCollection(v)) {
  20038. v = isKeyedCollection
  20039. ? keyedSeqFromValue(v)
  20040. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  20041. } else if (isKeyedCollection) {
  20042. v = KeyedCollection(v);
  20043. }
  20044. return v;
  20045. })
  20046. .filter(function (v) { return v.size !== 0; });
  20047. if (iters.length === 0) {
  20048. return collection;
  20049. }
  20050. if (iters.length === 1) {
  20051. var singleton = iters[0];
  20052. if (
  20053. singleton === collection ||
  20054. (isKeyedCollection && isKeyed(singleton)) ||
  20055. (isIndexed(collection) && isIndexed(singleton))
  20056. ) {
  20057. return singleton;
  20058. }
  20059. }
  20060. var concatSeq = new ArraySeq(iters);
  20061. if (isKeyedCollection) {
  20062. concatSeq = concatSeq.toKeyedSeq();
  20063. } else if (!isIndexed(collection)) {
  20064. concatSeq = concatSeq.toSetSeq();
  20065. }
  20066. concatSeq = concatSeq.flatten(true);
  20067. concatSeq.size = iters.reduce(function (sum, seq) {
  20068. if (sum !== undefined) {
  20069. var size = seq.size;
  20070. if (size !== undefined) {
  20071. return sum + size;
  20072. }
  20073. }
  20074. }, 0);
  20075. return concatSeq;
  20076. }
  20077. function flattenFactory(collection, depth, useKeys) {
  20078. var flatSequence = makeSequence(collection);
  20079. flatSequence.__iterateUncached = function(fn, reverse) {
  20080. if (reverse) {
  20081. return this.cacheResult().__iterate(fn, reverse);
  20082. }
  20083. var iterations = 0;
  20084. var stopped = false;
  20085. function flatDeep(iter, currentDepth) {
  20086. iter.__iterate(function (v, k) {
  20087. if ((!depth || currentDepth < depth) && isCollection(v)) {
  20088. flatDeep(v, currentDepth + 1);
  20089. } else {
  20090. iterations++;
  20091. if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) {
  20092. stopped = true;
  20093. }
  20094. }
  20095. return !stopped;
  20096. }, reverse);
  20097. }
  20098. flatDeep(collection, 0);
  20099. return iterations;
  20100. };
  20101. flatSequence.__iteratorUncached = function(type, reverse) {
  20102. if (reverse) {
  20103. return this.cacheResult().__iterator(type, reverse);
  20104. }
  20105. var iterator = collection.__iterator(type, reverse);
  20106. var stack = [];
  20107. var iterations = 0;
  20108. return new Iterator(function () {
  20109. while (iterator) {
  20110. var step = iterator.next();
  20111. if (step.done !== false) {
  20112. iterator = stack.pop();
  20113. continue;
  20114. }
  20115. var v = step.value;
  20116. if (type === ITERATE_ENTRIES) {
  20117. v = v[1];
  20118. }
  20119. if ((!depth || stack.length < depth) && isCollection(v)) {
  20120. stack.push(iterator);
  20121. iterator = v.__iterator(type, reverse);
  20122. } else {
  20123. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  20124. }
  20125. }
  20126. return iteratorDone();
  20127. });
  20128. };
  20129. return flatSequence;
  20130. }
  20131. function flatMapFactory(collection, mapper, context) {
  20132. var coerce = collectionClass(collection);
  20133. return collection
  20134. .toSeq()
  20135. .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); })
  20136. .flatten(true);
  20137. }
  20138. function interposeFactory(collection, separator) {
  20139. var interposedSequence = makeSequence(collection);
  20140. interposedSequence.size = collection.size && collection.size * 2 - 1;
  20141. interposedSequence.__iterateUncached = function(fn, reverse) {
  20142. var this$1 = this;
  20143. var iterations = 0;
  20144. collection.__iterate(
  20145. function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) &&
  20146. fn(v, iterations++, this$1) !== false; },
  20147. reverse
  20148. );
  20149. return iterations;
  20150. };
  20151. interposedSequence.__iteratorUncached = function(type, reverse) {
  20152. var iterator = collection.__iterator(ITERATE_VALUES, reverse);
  20153. var iterations = 0;
  20154. var step;
  20155. return new Iterator(function () {
  20156. if (!step || iterations % 2) {
  20157. step = iterator.next();
  20158. if (step.done) {
  20159. return step;
  20160. }
  20161. }
  20162. return iterations % 2
  20163. ? iteratorValue(type, iterations++, separator)
  20164. : iteratorValue(type, iterations++, step.value, step);
  20165. });
  20166. };
  20167. return interposedSequence;
  20168. }
  20169. function sortFactory(collection, comparator, mapper) {
  20170. if (!comparator) {
  20171. comparator = defaultComparator;
  20172. }
  20173. var isKeyedCollection = isKeyed(collection);
  20174. var index = 0;
  20175. var entries = collection
  20176. .toSeq()
  20177. .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; })
  20178. .valueSeq()
  20179. .toArray();
  20180. entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach(
  20181. isKeyedCollection
  20182. ? function (v, i) {
  20183. entries[i].length = 2;
  20184. }
  20185. : function (v, i) {
  20186. entries[i] = v[1];
  20187. }
  20188. );
  20189. return isKeyedCollection
  20190. ? KeyedSeq(entries)
  20191. : isIndexed(collection)
  20192. ? IndexedSeq(entries)
  20193. : SetSeq(entries);
  20194. }
  20195. function maxFactory(collection, comparator, mapper) {
  20196. if (!comparator) {
  20197. comparator = defaultComparator;
  20198. }
  20199. if (mapper) {
  20200. var entry = collection
  20201. .toSeq()
  20202. .map(function (v, k) { return [v, mapper(v, k, collection)]; })
  20203. .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); });
  20204. return entry && entry[0];
  20205. }
  20206. return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); });
  20207. }
  20208. function maxCompare(comparator, a, b) {
  20209. var comp = comparator(b, a);
  20210. // b is considered the new max if the comparator declares them equal, but
  20211. // they are not equal and b is in fact a nullish value.
  20212. return (
  20213. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  20214. comp > 0
  20215. );
  20216. }
  20217. function zipWithFactory(keyIter, zipper, iters, zipAll) {
  20218. var zipSequence = makeSequence(keyIter);
  20219. var sizes = new ArraySeq(iters).map(function (i) { return i.size; });
  20220. zipSequence.size = zipAll ? sizes.max() : sizes.min();
  20221. // Note: this a generic base implementation of __iterate in terms of
  20222. // __iterator which may be more generically useful in the future.
  20223. zipSequence.__iterate = function(fn, reverse) {
  20224. /* generic:
  20225. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  20226. var step;
  20227. var iterations = 0;
  20228. while (!(step = iterator.next()).done) {
  20229. iterations++;
  20230. if (fn(step.value[1], step.value[0], this) === false) {
  20231. break;
  20232. }
  20233. }
  20234. return iterations;
  20235. */
  20236. // indexed:
  20237. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  20238. var step;
  20239. var iterations = 0;
  20240. while (!(step = iterator.next()).done) {
  20241. if (fn(step.value, iterations++, this) === false) {
  20242. break;
  20243. }
  20244. }
  20245. return iterations;
  20246. };
  20247. zipSequence.__iteratorUncached = function(type, reverse) {
  20248. var iterators = iters.map(
  20249. function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); }
  20250. );
  20251. var iterations = 0;
  20252. var isDone = false;
  20253. return new Iterator(function () {
  20254. var steps;
  20255. if (!isDone) {
  20256. steps = iterators.map(function (i) { return i.next(); });
  20257. isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; });
  20258. }
  20259. if (isDone) {
  20260. return iteratorDone();
  20261. }
  20262. return iteratorValue(
  20263. type,
  20264. iterations++,
  20265. zipper.apply(null, steps.map(function (s) { return s.value; }))
  20266. );
  20267. });
  20268. };
  20269. return zipSequence;
  20270. }
  20271. // #pragma Helper Functions
  20272. function reify(iter, seq) {
  20273. return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq);
  20274. }
  20275. function validateEntry(entry) {
  20276. if (entry !== Object(entry)) {
  20277. throw new TypeError('Expected [K, V] tuple: ' + entry);
  20278. }
  20279. }
  20280. function collectionClass(collection) {
  20281. return isKeyed(collection)
  20282. ? KeyedCollection
  20283. : isIndexed(collection)
  20284. ? IndexedCollection
  20285. : SetCollection;
  20286. }
  20287. function makeSequence(collection) {
  20288. return Object.create(
  20289. (isKeyed(collection)
  20290. ? KeyedSeq
  20291. : isIndexed(collection)
  20292. ? IndexedSeq
  20293. : SetSeq
  20294. ).prototype
  20295. );
  20296. }
  20297. function cacheResultThrough() {
  20298. if (this._iter.cacheResult) {
  20299. this._iter.cacheResult();
  20300. this.size = this._iter.size;
  20301. return this;
  20302. }
  20303. return Seq.prototype.cacheResult.call(this);
  20304. }
  20305. function defaultComparator(a, b) {
  20306. if (a === undefined && b === undefined) {
  20307. return 0;
  20308. }
  20309. if (a === undefined) {
  20310. return 1;
  20311. }
  20312. if (b === undefined) {
  20313. return -1;
  20314. }
  20315. return a > b ? 1 : a < b ? -1 : 0;
  20316. }
  20317. // http://jsperf.com/copy-array-inline
  20318. function arrCopy(arr, offset) {
  20319. offset = offset || 0;
  20320. var len = Math.max(0, arr.length - offset);
  20321. var newArr = new Array(len);
  20322. for (var ii = 0; ii < len; ii++) {
  20323. newArr[ii] = arr[ii + offset];
  20324. }
  20325. return newArr;
  20326. }
  20327. function invariant(condition, error) {
  20328. if (!condition) { throw new Error(error); }
  20329. }
  20330. function assertNotInfinite(size) {
  20331. invariant(
  20332. size !== Infinity,
  20333. 'Cannot perform this action with an infinite size.'
  20334. );
  20335. }
  20336. function coerceKeyPath(keyPath) {
  20337. if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
  20338. return keyPath;
  20339. }
  20340. if (isOrdered(keyPath)) {
  20341. return keyPath.toArray();
  20342. }
  20343. throw new TypeError(
  20344. 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath
  20345. );
  20346. }
  20347. function isPlainObj(value) {
  20348. return (
  20349. value &&
  20350. (typeof value.constructor !== 'function' ||
  20351. value.constructor.name === 'Object')
  20352. );
  20353. }
  20354. /**
  20355. * Returns true if the value is a potentially-persistent data structure, either
  20356. * provided by Immutable.js or a plain Array or Object.
  20357. */
  20358. function isDataStructure(value) {
  20359. return (
  20360. typeof value === 'object' &&
  20361. (isImmutable(value) || Array.isArray(value) || isPlainObj(value))
  20362. );
  20363. }
  20364. /**
  20365. * Converts a value to a string, adding quotes if a string was provided.
  20366. */
  20367. function quoteString(value) {
  20368. try {
  20369. return typeof value === 'string' ? JSON.stringify(value) : String(value);
  20370. } catch (_ignoreError) {
  20371. return JSON.stringify(value);
  20372. }
  20373. }
  20374. function has(collection, key) {
  20375. return isImmutable(collection)
  20376. ? collection.has(key)
  20377. : isDataStructure(collection) && hasOwnProperty.call(collection, key);
  20378. }
  20379. function get(collection, key, notSetValue) {
  20380. return isImmutable(collection)
  20381. ? collection.get(key, notSetValue)
  20382. : !has(collection, key)
  20383. ? notSetValue
  20384. : typeof collection.get === 'function'
  20385. ? collection.get(key)
  20386. : collection[key];
  20387. }
  20388. function shallowCopy(from) {
  20389. if (Array.isArray(from)) {
  20390. return arrCopy(from);
  20391. }
  20392. var to = {};
  20393. for (var key in from) {
  20394. if (hasOwnProperty.call(from, key)) {
  20395. to[key] = from[key];
  20396. }
  20397. }
  20398. return to;
  20399. }
  20400. function remove(collection, key) {
  20401. if (!isDataStructure(collection)) {
  20402. throw new TypeError(
  20403. 'Cannot update non-data-structure value: ' + collection
  20404. );
  20405. }
  20406. if (isImmutable(collection)) {
  20407. if (!collection.remove) {
  20408. throw new TypeError(
  20409. 'Cannot update immutable value without .remove() method: ' + collection
  20410. );
  20411. }
  20412. return collection.remove(key);
  20413. }
  20414. if (!hasOwnProperty.call(collection, key)) {
  20415. return collection;
  20416. }
  20417. var collectionCopy = shallowCopy(collection);
  20418. if (Array.isArray(collectionCopy)) {
  20419. collectionCopy.splice(key, 1);
  20420. } else {
  20421. delete collectionCopy[key];
  20422. }
  20423. return collectionCopy;
  20424. }
  20425. function set(collection, key, value) {
  20426. if (!isDataStructure(collection)) {
  20427. throw new TypeError(
  20428. 'Cannot update non-data-structure value: ' + collection
  20429. );
  20430. }
  20431. if (isImmutable(collection)) {
  20432. if (!collection.set) {
  20433. throw new TypeError(
  20434. 'Cannot update immutable value without .set() method: ' + collection
  20435. );
  20436. }
  20437. return collection.set(key, value);
  20438. }
  20439. if (hasOwnProperty.call(collection, key) && value === collection[key]) {
  20440. return collection;
  20441. }
  20442. var collectionCopy = shallowCopy(collection);
  20443. collectionCopy[key] = value;
  20444. return collectionCopy;
  20445. }
  20446. function updateIn(collection, keyPath, notSetValue, updater) {
  20447. if (!updater) {
  20448. updater = notSetValue;
  20449. notSetValue = undefined;
  20450. }
  20451. var updatedValue = updateInDeeply(
  20452. isImmutable(collection),
  20453. collection,
  20454. coerceKeyPath(keyPath),
  20455. 0,
  20456. notSetValue,
  20457. updater
  20458. );
  20459. return updatedValue === NOT_SET ? notSetValue : updatedValue;
  20460. }
  20461. function updateInDeeply(
  20462. inImmutable,
  20463. existing,
  20464. keyPath,
  20465. i,
  20466. notSetValue,
  20467. updater
  20468. ) {
  20469. var wasNotSet = existing === NOT_SET;
  20470. if (i === keyPath.length) {
  20471. var existingValue = wasNotSet ? notSetValue : existing;
  20472. var newValue = updater(existingValue);
  20473. return newValue === existingValue ? existing : newValue;
  20474. }
  20475. if (!wasNotSet && !isDataStructure(existing)) {
  20476. throw new TypeError(
  20477. 'Cannot update within non-data-structure value in path [' +
  20478. keyPath.slice(0, i).map(quoteString) +
  20479. ']: ' +
  20480. existing
  20481. );
  20482. }
  20483. var key = keyPath[i];
  20484. var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
  20485. var nextUpdated = updateInDeeply(
  20486. nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
  20487. nextExisting,
  20488. keyPath,
  20489. i + 1,
  20490. notSetValue,
  20491. updater
  20492. );
  20493. return nextUpdated === nextExisting
  20494. ? existing
  20495. : nextUpdated === NOT_SET
  20496. ? remove(existing, key)
  20497. : set(
  20498. wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
  20499. key,
  20500. nextUpdated
  20501. );
  20502. }
  20503. function setIn(collection, keyPath, value) {
  20504. return updateIn(collection, keyPath, NOT_SET, function () { return value; });
  20505. }
  20506. function setIn$1(keyPath, v) {
  20507. return setIn(this, keyPath, v);
  20508. }
  20509. function removeIn(collection, keyPath) {
  20510. return updateIn(collection, keyPath, function () { return NOT_SET; });
  20511. }
  20512. function deleteIn(keyPath) {
  20513. return removeIn(this, keyPath);
  20514. }
  20515. function update(collection, key, notSetValue, updater) {
  20516. return updateIn(collection, [key], notSetValue, updater);
  20517. }
  20518. function update$1(key, notSetValue, updater) {
  20519. return arguments.length === 1
  20520. ? key(this)
  20521. : update(this, key, notSetValue, updater);
  20522. }
  20523. function updateIn$1(keyPath, notSetValue, updater) {
  20524. return updateIn(this, keyPath, notSetValue, updater);
  20525. }
  20526. function merge() {
  20527. var iters = [], len = arguments.length;
  20528. while ( len-- ) iters[ len ] = arguments[ len ];
  20529. return mergeIntoKeyedWith(this, iters);
  20530. }
  20531. function mergeWith(merger) {
  20532. var iters = [], len = arguments.length - 1;
  20533. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  20534. if (typeof merger !== 'function') {
  20535. throw new TypeError('Invalid merger function: ' + merger);
  20536. }
  20537. return mergeIntoKeyedWith(this, iters, merger);
  20538. }
  20539. function mergeIntoKeyedWith(collection, collections, merger) {
  20540. var iters = [];
  20541. for (var ii = 0; ii < collections.length; ii++) {
  20542. var collection$1 = KeyedCollection(collections[ii]);
  20543. if (collection$1.size !== 0) {
  20544. iters.push(collection$1);
  20545. }
  20546. }
  20547. if (iters.length === 0) {
  20548. return collection;
  20549. }
  20550. if (
  20551. collection.toSeq().size === 0 &&
  20552. !collection.__ownerID &&
  20553. iters.length === 1
  20554. ) {
  20555. return collection.constructor(iters[0]);
  20556. }
  20557. return collection.withMutations(function (collection) {
  20558. var mergeIntoCollection = merger
  20559. ? function (value, key) {
  20560. update(
  20561. collection,
  20562. key,
  20563. NOT_SET,
  20564. function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
  20565. );
  20566. }
  20567. : function (value, key) {
  20568. collection.set(key, value);
  20569. };
  20570. for (var ii = 0; ii < iters.length; ii++) {
  20571. iters[ii].forEach(mergeIntoCollection);
  20572. }
  20573. });
  20574. }
  20575. function merge$1(collection) {
  20576. var sources = [], len = arguments.length - 1;
  20577. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  20578. return mergeWithSources(collection, sources);
  20579. }
  20580. function mergeWith$1(merger, collection) {
  20581. var sources = [], len = arguments.length - 2;
  20582. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  20583. return mergeWithSources(collection, sources, merger);
  20584. }
  20585. function mergeDeep(collection) {
  20586. var sources = [], len = arguments.length - 1;
  20587. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  20588. return mergeDeepWithSources(collection, sources);
  20589. }
  20590. function mergeDeepWith(merger, collection) {
  20591. var sources = [], len = arguments.length - 2;
  20592. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  20593. return mergeDeepWithSources(collection, sources, merger);
  20594. }
  20595. function mergeDeepWithSources(collection, sources, merger) {
  20596. return mergeWithSources(collection, sources, deepMergerWith(merger));
  20597. }
  20598. function mergeWithSources(collection, sources, merger) {
  20599. if (!isDataStructure(collection)) {
  20600. throw new TypeError(
  20601. 'Cannot merge into non-data-structure value: ' + collection
  20602. );
  20603. }
  20604. if (isImmutable(collection)) {
  20605. return typeof merger === 'function' && collection.mergeWith
  20606. ? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
  20607. : collection.merge
  20608. ? collection.merge.apply(collection, sources)
  20609. : collection.concat.apply(collection, sources);
  20610. }
  20611. var isArray = Array.isArray(collection);
  20612. var merged = collection;
  20613. var Collection$$1 = isArray ? IndexedCollection : KeyedCollection;
  20614. var mergeItem = isArray
  20615. ? function (value) {
  20616. // Copy on write
  20617. if (merged === collection) {
  20618. merged = shallowCopy(merged);
  20619. }
  20620. merged.push(value);
  20621. }
  20622. : function (value, key) {
  20623. var hasVal = hasOwnProperty.call(merged, key);
  20624. var nextVal =
  20625. hasVal && merger ? merger(merged[key], value, key) : value;
  20626. if (!hasVal || nextVal !== merged[key]) {
  20627. // Copy on write
  20628. if (merged === collection) {
  20629. merged = shallowCopy(merged);
  20630. }
  20631. merged[key] = nextVal;
  20632. }
  20633. };
  20634. for (var i = 0; i < sources.length; i++) {
  20635. Collection$$1(sources[i]).forEach(mergeItem);
  20636. }
  20637. return merged;
  20638. }
  20639. function deepMergerWith(merger) {
  20640. function deepMerger(oldValue, newValue, key) {
  20641. return isDataStructure(oldValue) && isDataStructure(newValue)
  20642. ? mergeWithSources(oldValue, [newValue], deepMerger)
  20643. : merger
  20644. ? merger(oldValue, newValue, key)
  20645. : newValue;
  20646. }
  20647. return deepMerger;
  20648. }
  20649. function mergeDeep$1() {
  20650. var iters = [], len = arguments.length;
  20651. while ( len-- ) iters[ len ] = arguments[ len ];
  20652. return mergeDeepWithSources(this, iters);
  20653. }
  20654. function mergeDeepWith$1(merger) {
  20655. var iters = [], len = arguments.length - 1;
  20656. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  20657. return mergeDeepWithSources(this, iters, merger);
  20658. }
  20659. function mergeIn(keyPath) {
  20660. var iters = [], len = arguments.length - 1;
  20661. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  20662. return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
  20663. }
  20664. function mergeDeepIn(keyPath) {
  20665. var iters = [], len = arguments.length - 1;
  20666. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  20667. return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
  20668. );
  20669. }
  20670. function withMutations(fn) {
  20671. var mutable = this.asMutable();
  20672. fn(mutable);
  20673. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  20674. }
  20675. function asMutable() {
  20676. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  20677. }
  20678. function asImmutable() {
  20679. return this.__ensureOwner();
  20680. }
  20681. function wasAltered() {
  20682. return this.__altered;
  20683. }
  20684. var Map = /*@__PURE__*/(function (KeyedCollection$$1) {
  20685. function Map(value) {
  20686. return value === null || value === undefined
  20687. ? emptyMap()
  20688. : isMap(value) && !isOrdered(value)
  20689. ? value
  20690. : emptyMap().withMutations(function (map) {
  20691. var iter = KeyedCollection$$1(value);
  20692. assertNotInfinite(iter.size);
  20693. iter.forEach(function (v, k) { return map.set(k, v); });
  20694. });
  20695. }
  20696. if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1;
  20697. Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype );
  20698. Map.prototype.constructor = Map;
  20699. Map.of = function of () {
  20700. var keyValues = [], len = arguments.length;
  20701. while ( len-- ) keyValues[ len ] = arguments[ len ];
  20702. return emptyMap().withMutations(function (map) {
  20703. for (var i = 0; i < keyValues.length; i += 2) {
  20704. if (i + 1 >= keyValues.length) {
  20705. throw new Error('Missing value for key: ' + keyValues[i]);
  20706. }
  20707. map.set(keyValues[i], keyValues[i + 1]);
  20708. }
  20709. });
  20710. };
  20711. Map.prototype.toString = function toString () {
  20712. return this.__toString('Map {', '}');
  20713. };
  20714. // @pragma Access
  20715. Map.prototype.get = function get (k, notSetValue) {
  20716. return this._root
  20717. ? this._root.get(0, undefined, k, notSetValue)
  20718. : notSetValue;
  20719. };
  20720. // @pragma Modification
  20721. Map.prototype.set = function set (k, v) {
  20722. return updateMap(this, k, v);
  20723. };
  20724. Map.prototype.remove = function remove (k) {
  20725. return updateMap(this, k, NOT_SET);
  20726. };
  20727. Map.prototype.deleteAll = function deleteAll (keys) {
  20728. var collection = Collection(keys);
  20729. if (collection.size === 0) {
  20730. return this;
  20731. }
  20732. return this.withMutations(function (map) {
  20733. collection.forEach(function (key) { return map.remove(key); });
  20734. });
  20735. };
  20736. Map.prototype.clear = function clear () {
  20737. if (this.size === 0) {
  20738. return this;
  20739. }
  20740. if (this.__ownerID) {
  20741. this.size = 0;
  20742. this._root = null;
  20743. this.__hash = undefined;
  20744. this.__altered = true;
  20745. return this;
  20746. }
  20747. return emptyMap();
  20748. };
  20749. // @pragma Composition
  20750. Map.prototype.sort = function sort (comparator) {
  20751. // Late binding
  20752. return OrderedMap(sortFactory(this, comparator));
  20753. };
  20754. Map.prototype.sortBy = function sortBy (mapper, comparator) {
  20755. // Late binding
  20756. return OrderedMap(sortFactory(this, comparator, mapper));
  20757. };
  20758. Map.prototype.map = function map (mapper, context) {
  20759. return this.withMutations(function (map) {
  20760. map.forEach(function (value, key) {
  20761. map.set(key, mapper.call(context, value, key, map));
  20762. });
  20763. });
  20764. };
  20765. // @pragma Mutability
  20766. Map.prototype.__iterator = function __iterator (type, reverse) {
  20767. return new MapIterator(this, type, reverse);
  20768. };
  20769. Map.prototype.__iterate = function __iterate (fn, reverse) {
  20770. var this$1 = this;
  20771. var iterations = 0;
  20772. this._root &&
  20773. this._root.iterate(function (entry) {
  20774. iterations++;
  20775. return fn(entry[1], entry[0], this$1);
  20776. }, reverse);
  20777. return iterations;
  20778. };
  20779. Map.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  20780. if (ownerID === this.__ownerID) {
  20781. return this;
  20782. }
  20783. if (!ownerID) {
  20784. if (this.size === 0) {
  20785. return emptyMap();
  20786. }
  20787. this.__ownerID = ownerID;
  20788. this.__altered = false;
  20789. return this;
  20790. }
  20791. return makeMap(this.size, this._root, ownerID, this.__hash);
  20792. };
  20793. return Map;
  20794. }(KeyedCollection));
  20795. Map.isMap = isMap;
  20796. var MapPrototype = Map.prototype;
  20797. MapPrototype[IS_MAP_SYMBOL] = true;
  20798. MapPrototype[DELETE] = MapPrototype.remove;
  20799. MapPrototype.removeAll = MapPrototype.deleteAll;
  20800. MapPrototype.setIn = setIn$1;
  20801. MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
  20802. MapPrototype.update = update$1;
  20803. MapPrototype.updateIn = updateIn$1;
  20804. MapPrototype.merge = MapPrototype.concat = merge;
  20805. MapPrototype.mergeWith = mergeWith;
  20806. MapPrototype.mergeDeep = mergeDeep$1;
  20807. MapPrototype.mergeDeepWith = mergeDeepWith$1;
  20808. MapPrototype.mergeIn = mergeIn;
  20809. MapPrototype.mergeDeepIn = mergeDeepIn;
  20810. MapPrototype.withMutations = withMutations;
  20811. MapPrototype.wasAltered = wasAltered;
  20812. MapPrototype.asImmutable = asImmutable;
  20813. MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
  20814. MapPrototype['@@transducer/step'] = function(result, arr) {
  20815. return result.set(arr[0], arr[1]);
  20816. };
  20817. MapPrototype['@@transducer/result'] = function(obj) {
  20818. return obj.asImmutable();
  20819. };
  20820. // #pragma Trie Nodes
  20821. var ArrayMapNode = function ArrayMapNode(ownerID, entries) {
  20822. this.ownerID = ownerID;
  20823. this.entries = entries;
  20824. };
  20825. ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  20826. var entries = this.entries;
  20827. for (var ii = 0, len = entries.length; ii < len; ii++) {
  20828. if (is(key, entries[ii][0])) {
  20829. return entries[ii][1];
  20830. }
  20831. }
  20832. return notSetValue;
  20833. };
  20834. ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  20835. var removed = value === NOT_SET;
  20836. var entries = this.entries;
  20837. var idx = 0;
  20838. var len = entries.length;
  20839. for (; idx < len; idx++) {
  20840. if (is(key, entries[idx][0])) {
  20841. break;
  20842. }
  20843. }
  20844. var exists = idx < len;
  20845. if (exists ? entries[idx][1] === value : removed) {
  20846. return this;
  20847. }
  20848. SetRef(didAlter);
  20849. (removed || !exists) && SetRef(didChangeSize);
  20850. if (removed && entries.length === 1) {
  20851. return; // undefined
  20852. }
  20853. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  20854. return createNodes(ownerID, entries, key, value);
  20855. }
  20856. var isEditable = ownerID && ownerID === this.ownerID;
  20857. var newEntries = isEditable ? entries : arrCopy(entries);
  20858. if (exists) {
  20859. if (removed) {
  20860. idx === len - 1
  20861. ? newEntries.pop()
  20862. : (newEntries[idx] = newEntries.pop());
  20863. } else {
  20864. newEntries[idx] = [key, value];
  20865. }
  20866. } else {
  20867. newEntries.push([key, value]);
  20868. }
  20869. if (isEditable) {
  20870. this.entries = newEntries;
  20871. return this;
  20872. }
  20873. return new ArrayMapNode(ownerID, newEntries);
  20874. };
  20875. var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) {
  20876. this.ownerID = ownerID;
  20877. this.bitmap = bitmap;
  20878. this.nodes = nodes;
  20879. };
  20880. BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  20881. if (keyHash === undefined) {
  20882. keyHash = hash(key);
  20883. }
  20884. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  20885. var bitmap = this.bitmap;
  20886. return (bitmap & bit) === 0
  20887. ? notSetValue
  20888. : this.nodes[popCount(bitmap & (bit - 1))].get(
  20889. shift + SHIFT,
  20890. keyHash,
  20891. key,
  20892. notSetValue
  20893. );
  20894. };
  20895. BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  20896. if (keyHash === undefined) {
  20897. keyHash = hash(key);
  20898. }
  20899. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  20900. var bit = 1 << keyHashFrag;
  20901. var bitmap = this.bitmap;
  20902. var exists = (bitmap & bit) !== 0;
  20903. if (!exists && value === NOT_SET) {
  20904. return this;
  20905. }
  20906. var idx = popCount(bitmap & (bit - 1));
  20907. var nodes = this.nodes;
  20908. var node = exists ? nodes[idx] : undefined;
  20909. var newNode = updateNode(
  20910. node,
  20911. ownerID,
  20912. shift + SHIFT,
  20913. keyHash,
  20914. key,
  20915. value,
  20916. didChangeSize,
  20917. didAlter
  20918. );
  20919. if (newNode === node) {
  20920. return this;
  20921. }
  20922. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  20923. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  20924. }
  20925. if (
  20926. exists &&
  20927. !newNode &&
  20928. nodes.length === 2 &&
  20929. isLeafNode(nodes[idx ^ 1])
  20930. ) {
  20931. return nodes[idx ^ 1];
  20932. }
  20933. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  20934. return newNode;
  20935. }
  20936. var isEditable = ownerID && ownerID === this.ownerID;
  20937. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  20938. var newNodes = exists
  20939. ? newNode
  20940. ? setAt(nodes, idx, newNode, isEditable)
  20941. : spliceOut(nodes, idx, isEditable)
  20942. : spliceIn(nodes, idx, newNode, isEditable);
  20943. if (isEditable) {
  20944. this.bitmap = newBitmap;
  20945. this.nodes = newNodes;
  20946. return this;
  20947. }
  20948. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  20949. };
  20950. var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) {
  20951. this.ownerID = ownerID;
  20952. this.count = count;
  20953. this.nodes = nodes;
  20954. };
  20955. HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  20956. if (keyHash === undefined) {
  20957. keyHash = hash(key);
  20958. }
  20959. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  20960. var node = this.nodes[idx];
  20961. return node
  20962. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  20963. : notSetValue;
  20964. };
  20965. HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  20966. if (keyHash === undefined) {
  20967. keyHash = hash(key);
  20968. }
  20969. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  20970. var removed = value === NOT_SET;
  20971. var nodes = this.nodes;
  20972. var node = nodes[idx];
  20973. if (removed && !node) {
  20974. return this;
  20975. }
  20976. var newNode = updateNode(
  20977. node,
  20978. ownerID,
  20979. shift + SHIFT,
  20980. keyHash,
  20981. key,
  20982. value,
  20983. didChangeSize,
  20984. didAlter
  20985. );
  20986. if (newNode === node) {
  20987. return this;
  20988. }
  20989. var newCount = this.count;
  20990. if (!node) {
  20991. newCount++;
  20992. } else if (!newNode) {
  20993. newCount--;
  20994. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  20995. return packNodes(ownerID, nodes, newCount, idx);
  20996. }
  20997. }
  20998. var isEditable = ownerID && ownerID === this.ownerID;
  20999. var newNodes = setAt(nodes, idx, newNode, isEditable);
  21000. if (isEditable) {
  21001. this.count = newCount;
  21002. this.nodes = newNodes;
  21003. return this;
  21004. }
  21005. return new HashArrayMapNode(ownerID, newCount, newNodes);
  21006. };
  21007. var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) {
  21008. this.ownerID = ownerID;
  21009. this.keyHash = keyHash;
  21010. this.entries = entries;
  21011. };
  21012. HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  21013. var entries = this.entries;
  21014. for (var ii = 0, len = entries.length; ii < len; ii++) {
  21015. if (is(key, entries[ii][0])) {
  21016. return entries[ii][1];
  21017. }
  21018. }
  21019. return notSetValue;
  21020. };
  21021. HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  21022. if (keyHash === undefined) {
  21023. keyHash = hash(key);
  21024. }
  21025. var removed = value === NOT_SET;
  21026. if (keyHash !== this.keyHash) {
  21027. if (removed) {
  21028. return this;
  21029. }
  21030. SetRef(didAlter);
  21031. SetRef(didChangeSize);
  21032. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  21033. }
  21034. var entries = this.entries;
  21035. var idx = 0;
  21036. var len = entries.length;
  21037. for (; idx < len; idx++) {
  21038. if (is(key, entries[idx][0])) {
  21039. break;
  21040. }
  21041. }
  21042. var exists = idx < len;
  21043. if (exists ? entries[idx][1] === value : removed) {
  21044. return this;
  21045. }
  21046. SetRef(didAlter);
  21047. (removed || !exists) && SetRef(didChangeSize);
  21048. if (removed && len === 2) {
  21049. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  21050. }
  21051. var isEditable = ownerID && ownerID === this.ownerID;
  21052. var newEntries = isEditable ? entries : arrCopy(entries);
  21053. if (exists) {
  21054. if (removed) {
  21055. idx === len - 1
  21056. ? newEntries.pop()
  21057. : (newEntries[idx] = newEntries.pop());
  21058. } else {
  21059. newEntries[idx] = [key, value];
  21060. }
  21061. } else {
  21062. newEntries.push([key, value]);
  21063. }
  21064. if (isEditable) {
  21065. this.entries = newEntries;
  21066. return this;
  21067. }
  21068. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  21069. };
  21070. var ValueNode = function ValueNode(ownerID, keyHash, entry) {
  21071. this.ownerID = ownerID;
  21072. this.keyHash = keyHash;
  21073. this.entry = entry;
  21074. };
  21075. ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  21076. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  21077. };
  21078. ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  21079. var removed = value === NOT_SET;
  21080. var keyMatch = is(key, this.entry[0]);
  21081. if (keyMatch ? value === this.entry[1] : removed) {
  21082. return this;
  21083. }
  21084. SetRef(didAlter);
  21085. if (removed) {
  21086. SetRef(didChangeSize);
  21087. return; // undefined
  21088. }
  21089. if (keyMatch) {
  21090. if (ownerID && ownerID === this.ownerID) {
  21091. this.entry[1] = value;
  21092. return this;
  21093. }
  21094. return new ValueNode(ownerID, this.keyHash, [key, value]);
  21095. }
  21096. SetRef(didChangeSize);
  21097. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  21098. };
  21099. // #pragma Iterators
  21100. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
  21101. fn,
  21102. reverse
  21103. ) {
  21104. var entries = this.entries;
  21105. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  21106. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  21107. return false;
  21108. }
  21109. }
  21110. };
  21111. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
  21112. fn,
  21113. reverse
  21114. ) {
  21115. var nodes = this.nodes;
  21116. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  21117. var node = nodes[reverse ? maxIndex - ii : ii];
  21118. if (node && node.iterate(fn, reverse) === false) {
  21119. return false;
  21120. }
  21121. }
  21122. };
  21123. // eslint-disable-next-line no-unused-vars
  21124. ValueNode.prototype.iterate = function(fn, reverse) {
  21125. return fn(this.entry);
  21126. };
  21127. var MapIterator = /*@__PURE__*/(function (Iterator$$1) {
  21128. function MapIterator(map, type, reverse) {
  21129. this._type = type;
  21130. this._reverse = reverse;
  21131. this._stack = map._root && mapIteratorFrame(map._root);
  21132. }
  21133. if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1;
  21134. MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype );
  21135. MapIterator.prototype.constructor = MapIterator;
  21136. MapIterator.prototype.next = function next () {
  21137. var type = this._type;
  21138. var stack = this._stack;
  21139. while (stack) {
  21140. var node = stack.node;
  21141. var index = stack.index++;
  21142. var maxIndex = (void 0);
  21143. if (node.entry) {
  21144. if (index === 0) {
  21145. return mapIteratorValue(type, node.entry);
  21146. }
  21147. } else if (node.entries) {
  21148. maxIndex = node.entries.length - 1;
  21149. if (index <= maxIndex) {
  21150. return mapIteratorValue(
  21151. type,
  21152. node.entries[this._reverse ? maxIndex - index : index]
  21153. );
  21154. }
  21155. } else {
  21156. maxIndex = node.nodes.length - 1;
  21157. if (index <= maxIndex) {
  21158. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  21159. if (subNode) {
  21160. if (subNode.entry) {
  21161. return mapIteratorValue(type, subNode.entry);
  21162. }
  21163. stack = this._stack = mapIteratorFrame(subNode, stack);
  21164. }
  21165. continue;
  21166. }
  21167. }
  21168. stack = this._stack = this._stack.__prev;
  21169. }
  21170. return iteratorDone();
  21171. };
  21172. return MapIterator;
  21173. }(Iterator));
  21174. function mapIteratorValue(type, entry) {
  21175. return iteratorValue(type, entry[0], entry[1]);
  21176. }
  21177. function mapIteratorFrame(node, prev) {
  21178. return {
  21179. node: node,
  21180. index: 0,
  21181. __prev: prev,
  21182. };
  21183. }
  21184. function makeMap(size, root, ownerID, hash$$1) {
  21185. var map = Object.create(MapPrototype);
  21186. map.size = size;
  21187. map._root = root;
  21188. map.__ownerID = ownerID;
  21189. map.__hash = hash$$1;
  21190. map.__altered = false;
  21191. return map;
  21192. }
  21193. var EMPTY_MAP;
  21194. function emptyMap() {
  21195. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  21196. }
  21197. function updateMap(map, k, v) {
  21198. var newRoot;
  21199. var newSize;
  21200. if (!map._root) {
  21201. if (v === NOT_SET) {
  21202. return map;
  21203. }
  21204. newSize = 1;
  21205. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  21206. } else {
  21207. var didChangeSize = MakeRef();
  21208. var didAlter = MakeRef();
  21209. newRoot = updateNode(
  21210. map._root,
  21211. map.__ownerID,
  21212. 0,
  21213. undefined,
  21214. k,
  21215. v,
  21216. didChangeSize,
  21217. didAlter
  21218. );
  21219. if (!didAlter.value) {
  21220. return map;
  21221. }
  21222. newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  21223. }
  21224. if (map.__ownerID) {
  21225. map.size = newSize;
  21226. map._root = newRoot;
  21227. map.__hash = undefined;
  21228. map.__altered = true;
  21229. return map;
  21230. }
  21231. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  21232. }
  21233. function updateNode(
  21234. node,
  21235. ownerID,
  21236. shift,
  21237. keyHash,
  21238. key,
  21239. value,
  21240. didChangeSize,
  21241. didAlter
  21242. ) {
  21243. if (!node) {
  21244. if (value === NOT_SET) {
  21245. return node;
  21246. }
  21247. SetRef(didAlter);
  21248. SetRef(didChangeSize);
  21249. return new ValueNode(ownerID, keyHash, [key, value]);
  21250. }
  21251. return node.update(
  21252. ownerID,
  21253. shift,
  21254. keyHash,
  21255. key,
  21256. value,
  21257. didChangeSize,
  21258. didAlter
  21259. );
  21260. }
  21261. function isLeafNode(node) {
  21262. return (
  21263. node.constructor === ValueNode || node.constructor === HashCollisionNode
  21264. );
  21265. }
  21266. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  21267. if (node.keyHash === keyHash) {
  21268. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  21269. }
  21270. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  21271. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  21272. var newNode;
  21273. var nodes =
  21274. idx1 === idx2
  21275. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  21276. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  21277. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  21278. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  21279. }
  21280. function createNodes(ownerID, entries, key, value) {
  21281. if (!ownerID) {
  21282. ownerID = new OwnerID();
  21283. }
  21284. var node = new ValueNode(ownerID, hash(key), [key, value]);
  21285. for (var ii = 0; ii < entries.length; ii++) {
  21286. var entry = entries[ii];
  21287. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  21288. }
  21289. return node;
  21290. }
  21291. function packNodes(ownerID, nodes, count, excluding) {
  21292. var bitmap = 0;
  21293. var packedII = 0;
  21294. var packedNodes = new Array(count);
  21295. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  21296. var node = nodes[ii];
  21297. if (node !== undefined && ii !== excluding) {
  21298. bitmap |= bit;
  21299. packedNodes[packedII++] = node;
  21300. }
  21301. }
  21302. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  21303. }
  21304. function expandNodes(ownerID, nodes, bitmap, including, node) {
  21305. var count = 0;
  21306. var expandedNodes = new Array(SIZE);
  21307. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  21308. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  21309. }
  21310. expandedNodes[including] = node;
  21311. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  21312. }
  21313. function popCount(x) {
  21314. x -= (x >> 1) & 0x55555555;
  21315. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  21316. x = (x + (x >> 4)) & 0x0f0f0f0f;
  21317. x += x >> 8;
  21318. x += x >> 16;
  21319. return x & 0x7f;
  21320. }
  21321. function setAt(array, idx, val, canEdit) {
  21322. var newArray = canEdit ? array : arrCopy(array);
  21323. newArray[idx] = val;
  21324. return newArray;
  21325. }
  21326. function spliceIn(array, idx, val, canEdit) {
  21327. var newLen = array.length + 1;
  21328. if (canEdit && idx + 1 === newLen) {
  21329. array[idx] = val;
  21330. return array;
  21331. }
  21332. var newArray = new Array(newLen);
  21333. var after = 0;
  21334. for (var ii = 0; ii < newLen; ii++) {
  21335. if (ii === idx) {
  21336. newArray[ii] = val;
  21337. after = -1;
  21338. } else {
  21339. newArray[ii] = array[ii + after];
  21340. }
  21341. }
  21342. return newArray;
  21343. }
  21344. function spliceOut(array, idx, canEdit) {
  21345. var newLen = array.length - 1;
  21346. if (canEdit && idx === newLen) {
  21347. array.pop();
  21348. return array;
  21349. }
  21350. var newArray = new Array(newLen);
  21351. var after = 0;
  21352. for (var ii = 0; ii < newLen; ii++) {
  21353. if (ii === idx) {
  21354. after = 1;
  21355. }
  21356. newArray[ii] = array[ii + after];
  21357. }
  21358. return newArray;
  21359. }
  21360. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  21361. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  21362. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  21363. var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@';
  21364. function isList(maybeList) {
  21365. return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
  21366. }
  21367. var List = /*@__PURE__*/(function (IndexedCollection$$1) {
  21368. function List(value) {
  21369. var empty = emptyList();
  21370. if (value === null || value === undefined) {
  21371. return empty;
  21372. }
  21373. if (isList(value)) {
  21374. return value;
  21375. }
  21376. var iter = IndexedCollection$$1(value);
  21377. var size = iter.size;
  21378. if (size === 0) {
  21379. return empty;
  21380. }
  21381. assertNotInfinite(size);
  21382. if (size > 0 && size < SIZE) {
  21383. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  21384. }
  21385. return empty.withMutations(function (list) {
  21386. list.setSize(size);
  21387. iter.forEach(function (v, i) { return list.set(i, v); });
  21388. });
  21389. }
  21390. if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1;
  21391. List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
  21392. List.prototype.constructor = List;
  21393. List.of = function of (/*...values*/) {
  21394. return this(arguments);
  21395. };
  21396. List.prototype.toString = function toString () {
  21397. return this.__toString('List [', ']');
  21398. };
  21399. // @pragma Access
  21400. List.prototype.get = function get (index, notSetValue) {
  21401. index = wrapIndex(this, index);
  21402. if (index >= 0 && index < this.size) {
  21403. index += this._origin;
  21404. var node = listNodeFor(this, index);
  21405. return node && node.array[index & MASK];
  21406. }
  21407. return notSetValue;
  21408. };
  21409. // @pragma Modification
  21410. List.prototype.set = function set (index, value) {
  21411. return updateList(this, index, value);
  21412. };
  21413. List.prototype.remove = function remove (index) {
  21414. return !this.has(index)
  21415. ? this
  21416. : index === 0
  21417. ? this.shift()
  21418. : index === this.size - 1
  21419. ? this.pop()
  21420. : this.splice(index, 1);
  21421. };
  21422. List.prototype.insert = function insert (index, value) {
  21423. return this.splice(index, 0, value);
  21424. };
  21425. List.prototype.clear = function clear () {
  21426. if (this.size === 0) {
  21427. return this;
  21428. }
  21429. if (this.__ownerID) {
  21430. this.size = this._origin = this._capacity = 0;
  21431. this._level = SHIFT;
  21432. this._root = this._tail = null;
  21433. this.__hash = undefined;
  21434. this.__altered = true;
  21435. return this;
  21436. }
  21437. return emptyList();
  21438. };
  21439. List.prototype.push = function push (/*...values*/) {
  21440. var values = arguments;
  21441. var oldSize = this.size;
  21442. return this.withMutations(function (list) {
  21443. setListBounds(list, 0, oldSize + values.length);
  21444. for (var ii = 0; ii < values.length; ii++) {
  21445. list.set(oldSize + ii, values[ii]);
  21446. }
  21447. });
  21448. };
  21449. List.prototype.pop = function pop () {
  21450. return setListBounds(this, 0, -1);
  21451. };
  21452. List.prototype.unshift = function unshift (/*...values*/) {
  21453. var values = arguments;
  21454. return this.withMutations(function (list) {
  21455. setListBounds(list, -values.length);
  21456. for (var ii = 0; ii < values.length; ii++) {
  21457. list.set(ii, values[ii]);
  21458. }
  21459. });
  21460. };
  21461. List.prototype.shift = function shift () {
  21462. return setListBounds(this, 1);
  21463. };
  21464. // @pragma Composition
  21465. List.prototype.concat = function concat (/*...collections*/) {
  21466. var arguments$1 = arguments;
  21467. var seqs = [];
  21468. for (var i = 0; i < arguments.length; i++) {
  21469. var argument = arguments$1[i];
  21470. var seq = IndexedCollection$$1(
  21471. typeof argument !== 'string' && hasIterator(argument)
  21472. ? argument
  21473. : [argument]
  21474. );
  21475. if (seq.size !== 0) {
  21476. seqs.push(seq);
  21477. }
  21478. }
  21479. if (seqs.length === 0) {
  21480. return this;
  21481. }
  21482. if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
  21483. return this.constructor(seqs[0]);
  21484. }
  21485. return this.withMutations(function (list) {
  21486. seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
  21487. });
  21488. };
  21489. List.prototype.setSize = function setSize (size) {
  21490. return setListBounds(this, 0, size);
  21491. };
  21492. List.prototype.map = function map (mapper, context) {
  21493. var this$1 = this;
  21494. return this.withMutations(function (list) {
  21495. for (var i = 0; i < this$1.size; i++) {
  21496. list.set(i, mapper.call(context, list.get(i), i, list));
  21497. }
  21498. });
  21499. };
  21500. // @pragma Iteration
  21501. List.prototype.slice = function slice (begin, end) {
  21502. var size = this.size;
  21503. if (wholeSlice(begin, end, size)) {
  21504. return this;
  21505. }
  21506. return setListBounds(
  21507. this,
  21508. resolveBegin(begin, size),
  21509. resolveEnd(end, size)
  21510. );
  21511. };
  21512. List.prototype.__iterator = function __iterator (type, reverse) {
  21513. var index = reverse ? this.size : 0;
  21514. var values = iterateList(this, reverse);
  21515. return new Iterator(function () {
  21516. var value = values();
  21517. return value === DONE
  21518. ? iteratorDone()
  21519. : iteratorValue(type, reverse ? --index : index++, value);
  21520. });
  21521. };
  21522. List.prototype.__iterate = function __iterate (fn, reverse) {
  21523. var index = reverse ? this.size : 0;
  21524. var values = iterateList(this, reverse);
  21525. var value;
  21526. while ((value = values()) !== DONE) {
  21527. if (fn(value, reverse ? --index : index++, this) === false) {
  21528. break;
  21529. }
  21530. }
  21531. return index;
  21532. };
  21533. List.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  21534. if (ownerID === this.__ownerID) {
  21535. return this;
  21536. }
  21537. if (!ownerID) {
  21538. if (this.size === 0) {
  21539. return emptyList();
  21540. }
  21541. this.__ownerID = ownerID;
  21542. this.__altered = false;
  21543. return this;
  21544. }
  21545. return makeList(
  21546. this._origin,
  21547. this._capacity,
  21548. this._level,
  21549. this._root,
  21550. this._tail,
  21551. ownerID,
  21552. this.__hash
  21553. );
  21554. };
  21555. return List;
  21556. }(IndexedCollection));
  21557. List.isList = isList;
  21558. var ListPrototype = List.prototype;
  21559. ListPrototype[IS_LIST_SYMBOL] = true;
  21560. ListPrototype[DELETE] = ListPrototype.remove;
  21561. ListPrototype.merge = ListPrototype.concat;
  21562. ListPrototype.setIn = setIn$1;
  21563. ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
  21564. ListPrototype.update = update$1;
  21565. ListPrototype.updateIn = updateIn$1;
  21566. ListPrototype.mergeIn = mergeIn;
  21567. ListPrototype.mergeDeepIn = mergeDeepIn;
  21568. ListPrototype.withMutations = withMutations;
  21569. ListPrototype.wasAltered = wasAltered;
  21570. ListPrototype.asImmutable = asImmutable;
  21571. ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
  21572. ListPrototype['@@transducer/step'] = function(result, arr) {
  21573. return result.push(arr);
  21574. };
  21575. ListPrototype['@@transducer/result'] = function(obj) {
  21576. return obj.asImmutable();
  21577. };
  21578. var VNode = function VNode(array, ownerID) {
  21579. this.array = array;
  21580. this.ownerID = ownerID;
  21581. };
  21582. // TODO: seems like these methods are very similar
  21583. VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) {
  21584. if (index === level ? 1 << level : this.array.length === 0) {
  21585. return this;
  21586. }
  21587. var originIndex = (index >>> level) & MASK;
  21588. if (originIndex >= this.array.length) {
  21589. return new VNode([], ownerID);
  21590. }
  21591. var removingFirst = originIndex === 0;
  21592. var newChild;
  21593. if (level > 0) {
  21594. var oldChild = this.array[originIndex];
  21595. newChild =
  21596. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  21597. if (newChild === oldChild && removingFirst) {
  21598. return this;
  21599. }
  21600. }
  21601. if (removingFirst && !newChild) {
  21602. return this;
  21603. }
  21604. var editable = editableVNode(this, ownerID);
  21605. if (!removingFirst) {
  21606. for (var ii = 0; ii < originIndex; ii++) {
  21607. editable.array[ii] = undefined;
  21608. }
  21609. }
  21610. if (newChild) {
  21611. editable.array[originIndex] = newChild;
  21612. }
  21613. return editable;
  21614. };
  21615. VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) {
  21616. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  21617. return this;
  21618. }
  21619. var sizeIndex = ((index - 1) >>> level) & MASK;
  21620. if (sizeIndex >= this.array.length) {
  21621. return this;
  21622. }
  21623. var newChild;
  21624. if (level > 0) {
  21625. var oldChild = this.array[sizeIndex];
  21626. newChild =
  21627. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  21628. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  21629. return this;
  21630. }
  21631. }
  21632. var editable = editableVNode(this, ownerID);
  21633. editable.array.splice(sizeIndex + 1);
  21634. if (newChild) {
  21635. editable.array[sizeIndex] = newChild;
  21636. }
  21637. return editable;
  21638. };
  21639. var DONE = {};
  21640. function iterateList(list, reverse) {
  21641. var left = list._origin;
  21642. var right = list._capacity;
  21643. var tailPos = getTailOffset(right);
  21644. var tail = list._tail;
  21645. return iterateNodeOrLeaf(list._root, list._level, 0);
  21646. function iterateNodeOrLeaf(node, level, offset) {
  21647. return level === 0
  21648. ? iterateLeaf(node, offset)
  21649. : iterateNode(node, level, offset);
  21650. }
  21651. function iterateLeaf(node, offset) {
  21652. var array = offset === tailPos ? tail && tail.array : node && node.array;
  21653. var from = offset > left ? 0 : left - offset;
  21654. var to = right - offset;
  21655. if (to > SIZE) {
  21656. to = SIZE;
  21657. }
  21658. return function () {
  21659. if (from === to) {
  21660. return DONE;
  21661. }
  21662. var idx = reverse ? --to : from++;
  21663. return array && array[idx];
  21664. };
  21665. }
  21666. function iterateNode(node, level, offset) {
  21667. var values;
  21668. var array = node && node.array;
  21669. var from = offset > left ? 0 : (left - offset) >> level;
  21670. var to = ((right - offset) >> level) + 1;
  21671. if (to > SIZE) {
  21672. to = SIZE;
  21673. }
  21674. return function () {
  21675. while (true) {
  21676. if (values) {
  21677. var value = values();
  21678. if (value !== DONE) {
  21679. return value;
  21680. }
  21681. values = null;
  21682. }
  21683. if (from === to) {
  21684. return DONE;
  21685. }
  21686. var idx = reverse ? --to : from++;
  21687. values = iterateNodeOrLeaf(
  21688. array && array[idx],
  21689. level - SHIFT,
  21690. offset + (idx << level)
  21691. );
  21692. }
  21693. };
  21694. }
  21695. }
  21696. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  21697. var list = Object.create(ListPrototype);
  21698. list.size = capacity - origin;
  21699. list._origin = origin;
  21700. list._capacity = capacity;
  21701. list._level = level;
  21702. list._root = root;
  21703. list._tail = tail;
  21704. list.__ownerID = ownerID;
  21705. list.__hash = hash;
  21706. list.__altered = false;
  21707. return list;
  21708. }
  21709. var EMPTY_LIST;
  21710. function emptyList() {
  21711. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  21712. }
  21713. function updateList(list, index, value) {
  21714. index = wrapIndex(list, index);
  21715. if (index !== index) {
  21716. return list;
  21717. }
  21718. if (index >= list.size || index < 0) {
  21719. return list.withMutations(function (list) {
  21720. index < 0
  21721. ? setListBounds(list, index).set(0, value)
  21722. : setListBounds(list, 0, index + 1).set(index, value);
  21723. });
  21724. }
  21725. index += list._origin;
  21726. var newTail = list._tail;
  21727. var newRoot = list._root;
  21728. var didAlter = MakeRef();
  21729. if (index >= getTailOffset(list._capacity)) {
  21730. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  21731. } else {
  21732. newRoot = updateVNode(
  21733. newRoot,
  21734. list.__ownerID,
  21735. list._level,
  21736. index,
  21737. value,
  21738. didAlter
  21739. );
  21740. }
  21741. if (!didAlter.value) {
  21742. return list;
  21743. }
  21744. if (list.__ownerID) {
  21745. list._root = newRoot;
  21746. list._tail = newTail;
  21747. list.__hash = undefined;
  21748. list.__altered = true;
  21749. return list;
  21750. }
  21751. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  21752. }
  21753. function updateVNode(node, ownerID, level, index, value, didAlter) {
  21754. var idx = (index >>> level) & MASK;
  21755. var nodeHas = node && idx < node.array.length;
  21756. if (!nodeHas && value === undefined) {
  21757. return node;
  21758. }
  21759. var newNode;
  21760. if (level > 0) {
  21761. var lowerNode = node && node.array[idx];
  21762. var newLowerNode = updateVNode(
  21763. lowerNode,
  21764. ownerID,
  21765. level - SHIFT,
  21766. index,
  21767. value,
  21768. didAlter
  21769. );
  21770. if (newLowerNode === lowerNode) {
  21771. return node;
  21772. }
  21773. newNode = editableVNode(node, ownerID);
  21774. newNode.array[idx] = newLowerNode;
  21775. return newNode;
  21776. }
  21777. if (nodeHas && node.array[idx] === value) {
  21778. return node;
  21779. }
  21780. if (didAlter) {
  21781. SetRef(didAlter);
  21782. }
  21783. newNode = editableVNode(node, ownerID);
  21784. if (value === undefined && idx === newNode.array.length - 1) {
  21785. newNode.array.pop();
  21786. } else {
  21787. newNode.array[idx] = value;
  21788. }
  21789. return newNode;
  21790. }
  21791. function editableVNode(node, ownerID) {
  21792. if (ownerID && node && ownerID === node.ownerID) {
  21793. return node;
  21794. }
  21795. return new VNode(node ? node.array.slice() : [], ownerID);
  21796. }
  21797. function listNodeFor(list, rawIndex) {
  21798. if (rawIndex >= getTailOffset(list._capacity)) {
  21799. return list._tail;
  21800. }
  21801. if (rawIndex < 1 << (list._level + SHIFT)) {
  21802. var node = list._root;
  21803. var level = list._level;
  21804. while (node && level > 0) {
  21805. node = node.array[(rawIndex >>> level) & MASK];
  21806. level -= SHIFT;
  21807. }
  21808. return node;
  21809. }
  21810. }
  21811. function setListBounds(list, begin, end) {
  21812. // Sanitize begin & end using this shorthand for ToInt32(argument)
  21813. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  21814. if (begin !== undefined) {
  21815. begin |= 0;
  21816. }
  21817. if (end !== undefined) {
  21818. end |= 0;
  21819. }
  21820. var owner = list.__ownerID || new OwnerID();
  21821. var oldOrigin = list._origin;
  21822. var oldCapacity = list._capacity;
  21823. var newOrigin = oldOrigin + begin;
  21824. var newCapacity =
  21825. end === undefined
  21826. ? oldCapacity
  21827. : end < 0
  21828. ? oldCapacity + end
  21829. : oldOrigin + end;
  21830. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  21831. return list;
  21832. }
  21833. // If it's going to end after it starts, it's empty.
  21834. if (newOrigin >= newCapacity) {
  21835. return list.clear();
  21836. }
  21837. var newLevel = list._level;
  21838. var newRoot = list._root;
  21839. // New origin might need creating a higher root.
  21840. var offsetShift = 0;
  21841. while (newOrigin + offsetShift < 0) {
  21842. newRoot = new VNode(
  21843. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  21844. owner
  21845. );
  21846. newLevel += SHIFT;
  21847. offsetShift += 1 << newLevel;
  21848. }
  21849. if (offsetShift) {
  21850. newOrigin += offsetShift;
  21851. oldOrigin += offsetShift;
  21852. newCapacity += offsetShift;
  21853. oldCapacity += offsetShift;
  21854. }
  21855. var oldTailOffset = getTailOffset(oldCapacity);
  21856. var newTailOffset = getTailOffset(newCapacity);
  21857. // New size might need creating a higher root.
  21858. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  21859. newRoot = new VNode(
  21860. newRoot && newRoot.array.length ? [newRoot] : [],
  21861. owner
  21862. );
  21863. newLevel += SHIFT;
  21864. }
  21865. // Locate or create the new tail.
  21866. var oldTail = list._tail;
  21867. var newTail =
  21868. newTailOffset < oldTailOffset
  21869. ? listNodeFor(list, newCapacity - 1)
  21870. : newTailOffset > oldTailOffset
  21871. ? new VNode([], owner)
  21872. : oldTail;
  21873. // Merge Tail into tree.
  21874. if (
  21875. oldTail &&
  21876. newTailOffset > oldTailOffset &&
  21877. newOrigin < oldCapacity &&
  21878. oldTail.array.length
  21879. ) {
  21880. newRoot = editableVNode(newRoot, owner);
  21881. var node = newRoot;
  21882. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  21883. var idx = (oldTailOffset >>> level) & MASK;
  21884. node = node.array[idx] = editableVNode(node.array[idx], owner);
  21885. }
  21886. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  21887. }
  21888. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  21889. if (newCapacity < oldCapacity) {
  21890. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  21891. }
  21892. // If the new origin is within the tail, then we do not need a root.
  21893. if (newOrigin >= newTailOffset) {
  21894. newOrigin -= newTailOffset;
  21895. newCapacity -= newTailOffset;
  21896. newLevel = SHIFT;
  21897. newRoot = null;
  21898. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  21899. // Otherwise, if the root has been trimmed, garbage collect.
  21900. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  21901. offsetShift = 0;
  21902. // Identify the new top root node of the subtree of the old root.
  21903. while (newRoot) {
  21904. var beginIndex = (newOrigin >>> newLevel) & MASK;
  21905. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  21906. break;
  21907. }
  21908. if (beginIndex) {
  21909. offsetShift += (1 << newLevel) * beginIndex;
  21910. }
  21911. newLevel -= SHIFT;
  21912. newRoot = newRoot.array[beginIndex];
  21913. }
  21914. // Trim the new sides of the new root.
  21915. if (newRoot && newOrigin > oldOrigin) {
  21916. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  21917. }
  21918. if (newRoot && newTailOffset < oldTailOffset) {
  21919. newRoot = newRoot.removeAfter(
  21920. owner,
  21921. newLevel,
  21922. newTailOffset - offsetShift
  21923. );
  21924. }
  21925. if (offsetShift) {
  21926. newOrigin -= offsetShift;
  21927. newCapacity -= offsetShift;
  21928. }
  21929. }
  21930. if (list.__ownerID) {
  21931. list.size = newCapacity - newOrigin;
  21932. list._origin = newOrigin;
  21933. list._capacity = newCapacity;
  21934. list._level = newLevel;
  21935. list._root = newRoot;
  21936. list._tail = newTail;
  21937. list.__hash = undefined;
  21938. list.__altered = true;
  21939. return list;
  21940. }
  21941. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  21942. }
  21943. function getTailOffset(size) {
  21944. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  21945. }
  21946. var OrderedMap = /*@__PURE__*/(function (Map$$1) {
  21947. function OrderedMap(value) {
  21948. return value === null || value === undefined
  21949. ? emptyOrderedMap()
  21950. : isOrderedMap(value)
  21951. ? value
  21952. : emptyOrderedMap().withMutations(function (map) {
  21953. var iter = KeyedCollection(value);
  21954. assertNotInfinite(iter.size);
  21955. iter.forEach(function (v, k) { return map.set(k, v); });
  21956. });
  21957. }
  21958. if ( Map$$1 ) OrderedMap.__proto__ = Map$$1;
  21959. OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype );
  21960. OrderedMap.prototype.constructor = OrderedMap;
  21961. OrderedMap.of = function of (/*...values*/) {
  21962. return this(arguments);
  21963. };
  21964. OrderedMap.prototype.toString = function toString () {
  21965. return this.__toString('OrderedMap {', '}');
  21966. };
  21967. // @pragma Access
  21968. OrderedMap.prototype.get = function get (k, notSetValue) {
  21969. var index = this._map.get(k);
  21970. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  21971. };
  21972. // @pragma Modification
  21973. OrderedMap.prototype.clear = function clear () {
  21974. if (this.size === 0) {
  21975. return this;
  21976. }
  21977. if (this.__ownerID) {
  21978. this.size = 0;
  21979. this._map.clear();
  21980. this._list.clear();
  21981. return this;
  21982. }
  21983. return emptyOrderedMap();
  21984. };
  21985. OrderedMap.prototype.set = function set (k, v) {
  21986. return updateOrderedMap(this, k, v);
  21987. };
  21988. OrderedMap.prototype.remove = function remove (k) {
  21989. return updateOrderedMap(this, k, NOT_SET);
  21990. };
  21991. OrderedMap.prototype.wasAltered = function wasAltered () {
  21992. return this._map.wasAltered() || this._list.wasAltered();
  21993. };
  21994. OrderedMap.prototype.__iterate = function __iterate (fn, reverse) {
  21995. var this$1 = this;
  21996. return this._list.__iterate(
  21997. function (entry) { return entry && fn(entry[1], entry[0], this$1); },
  21998. reverse
  21999. );
  22000. };
  22001. OrderedMap.prototype.__iterator = function __iterator (type, reverse) {
  22002. return this._list.fromEntrySeq().__iterator(type, reverse);
  22003. };
  22004. OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  22005. if (ownerID === this.__ownerID) {
  22006. return this;
  22007. }
  22008. var newMap = this._map.__ensureOwner(ownerID);
  22009. var newList = this._list.__ensureOwner(ownerID);
  22010. if (!ownerID) {
  22011. if (this.size === 0) {
  22012. return emptyOrderedMap();
  22013. }
  22014. this.__ownerID = ownerID;
  22015. this._map = newMap;
  22016. this._list = newList;
  22017. return this;
  22018. }
  22019. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  22020. };
  22021. return OrderedMap;
  22022. }(Map));
  22023. OrderedMap.isOrderedMap = isOrderedMap;
  22024. OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
  22025. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  22026. function makeOrderedMap(map, list, ownerID, hash) {
  22027. var omap = Object.create(OrderedMap.prototype);
  22028. omap.size = map ? map.size : 0;
  22029. omap._map = map;
  22030. omap._list = list;
  22031. omap.__ownerID = ownerID;
  22032. omap.__hash = hash;
  22033. return omap;
  22034. }
  22035. var EMPTY_ORDERED_MAP;
  22036. function emptyOrderedMap() {
  22037. return (
  22038. EMPTY_ORDERED_MAP ||
  22039. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  22040. );
  22041. }
  22042. function updateOrderedMap(omap, k, v) {
  22043. var map = omap._map;
  22044. var list = omap._list;
  22045. var i = map.get(k);
  22046. var has = i !== undefined;
  22047. var newMap;
  22048. var newList;
  22049. if (v === NOT_SET) {
  22050. // removed
  22051. if (!has) {
  22052. return omap;
  22053. }
  22054. if (list.size >= SIZE && list.size >= map.size * 2) {
  22055. newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; });
  22056. newMap = newList
  22057. .toKeyedSeq()
  22058. .map(function (entry) { return entry[0]; })
  22059. .flip()
  22060. .toMap();
  22061. if (omap.__ownerID) {
  22062. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  22063. }
  22064. } else {
  22065. newMap = map.remove(k);
  22066. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  22067. }
  22068. } else if (has) {
  22069. if (v === list.get(i)[1]) {
  22070. return omap;
  22071. }
  22072. newMap = map;
  22073. newList = list.set(i, [k, v]);
  22074. } else {
  22075. newMap = map.set(k, list.size);
  22076. newList = list.set(list.size, [k, v]);
  22077. }
  22078. if (omap.__ownerID) {
  22079. omap.size = newMap.size;
  22080. omap._map = newMap;
  22081. omap._list = newList;
  22082. omap.__hash = undefined;
  22083. return omap;
  22084. }
  22085. return makeOrderedMap(newMap, newList);
  22086. }
  22087. var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@';
  22088. function isStack(maybeStack) {
  22089. return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
  22090. }
  22091. var Stack = /*@__PURE__*/(function (IndexedCollection$$1) {
  22092. function Stack(value) {
  22093. return value === null || value === undefined
  22094. ? emptyStack()
  22095. : isStack(value)
  22096. ? value
  22097. : emptyStack().pushAll(value);
  22098. }
  22099. if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1;
  22100. Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
  22101. Stack.prototype.constructor = Stack;
  22102. Stack.of = function of (/*...values*/) {
  22103. return this(arguments);
  22104. };
  22105. Stack.prototype.toString = function toString () {
  22106. return this.__toString('Stack [', ']');
  22107. };
  22108. // @pragma Access
  22109. Stack.prototype.get = function get (index, notSetValue) {
  22110. var head = this._head;
  22111. index = wrapIndex(this, index);
  22112. while (head && index--) {
  22113. head = head.next;
  22114. }
  22115. return head ? head.value : notSetValue;
  22116. };
  22117. Stack.prototype.peek = function peek () {
  22118. return this._head && this._head.value;
  22119. };
  22120. // @pragma Modification
  22121. Stack.prototype.push = function push (/*...values*/) {
  22122. var arguments$1 = arguments;
  22123. if (arguments.length === 0) {
  22124. return this;
  22125. }
  22126. var newSize = this.size + arguments.length;
  22127. var head = this._head;
  22128. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  22129. head = {
  22130. value: arguments$1[ii],
  22131. next: head,
  22132. };
  22133. }
  22134. if (this.__ownerID) {
  22135. this.size = newSize;
  22136. this._head = head;
  22137. this.__hash = undefined;
  22138. this.__altered = true;
  22139. return this;
  22140. }
  22141. return makeStack(newSize, head);
  22142. };
  22143. Stack.prototype.pushAll = function pushAll (iter) {
  22144. iter = IndexedCollection$$1(iter);
  22145. if (iter.size === 0) {
  22146. return this;
  22147. }
  22148. if (this.size === 0 && isStack(iter)) {
  22149. return iter;
  22150. }
  22151. assertNotInfinite(iter.size);
  22152. var newSize = this.size;
  22153. var head = this._head;
  22154. iter.__iterate(function (value) {
  22155. newSize++;
  22156. head = {
  22157. value: value,
  22158. next: head,
  22159. };
  22160. }, /* reverse */ true);
  22161. if (this.__ownerID) {
  22162. this.size = newSize;
  22163. this._head = head;
  22164. this.__hash = undefined;
  22165. this.__altered = true;
  22166. return this;
  22167. }
  22168. return makeStack(newSize, head);
  22169. };
  22170. Stack.prototype.pop = function pop () {
  22171. return this.slice(1);
  22172. };
  22173. Stack.prototype.clear = function clear () {
  22174. if (this.size === 0) {
  22175. return this;
  22176. }
  22177. if (this.__ownerID) {
  22178. this.size = 0;
  22179. this._head = undefined;
  22180. this.__hash = undefined;
  22181. this.__altered = true;
  22182. return this;
  22183. }
  22184. return emptyStack();
  22185. };
  22186. Stack.prototype.slice = function slice (begin, end) {
  22187. if (wholeSlice(begin, end, this.size)) {
  22188. return this;
  22189. }
  22190. var resolvedBegin = resolveBegin(begin, this.size);
  22191. var resolvedEnd = resolveEnd(end, this.size);
  22192. if (resolvedEnd !== this.size) {
  22193. // super.slice(begin, end);
  22194. return IndexedCollection$$1.prototype.slice.call(this, begin, end);
  22195. }
  22196. var newSize = this.size - resolvedBegin;
  22197. var head = this._head;
  22198. while (resolvedBegin--) {
  22199. head = head.next;
  22200. }
  22201. if (this.__ownerID) {
  22202. this.size = newSize;
  22203. this._head = head;
  22204. this.__hash = undefined;
  22205. this.__altered = true;
  22206. return this;
  22207. }
  22208. return makeStack(newSize, head);
  22209. };
  22210. // @pragma Mutability
  22211. Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  22212. if (ownerID === this.__ownerID) {
  22213. return this;
  22214. }
  22215. if (!ownerID) {
  22216. if (this.size === 0) {
  22217. return emptyStack();
  22218. }
  22219. this.__ownerID = ownerID;
  22220. this.__altered = false;
  22221. return this;
  22222. }
  22223. return makeStack(this.size, this._head, ownerID, this.__hash);
  22224. };
  22225. // @pragma Iteration
  22226. Stack.prototype.__iterate = function __iterate (fn, reverse) {
  22227. var this$1 = this;
  22228. if (reverse) {
  22229. return new ArraySeq(this.toArray()).__iterate(
  22230. function (v, k) { return fn(v, k, this$1); },
  22231. reverse
  22232. );
  22233. }
  22234. var iterations = 0;
  22235. var node = this._head;
  22236. while (node) {
  22237. if (fn(node.value, iterations++, this) === false) {
  22238. break;
  22239. }
  22240. node = node.next;
  22241. }
  22242. return iterations;
  22243. };
  22244. Stack.prototype.__iterator = function __iterator (type, reverse) {
  22245. if (reverse) {
  22246. return new ArraySeq(this.toArray()).__iterator(type, reverse);
  22247. }
  22248. var iterations = 0;
  22249. var node = this._head;
  22250. return new Iterator(function () {
  22251. if (node) {
  22252. var value = node.value;
  22253. node = node.next;
  22254. return iteratorValue(type, iterations++, value);
  22255. }
  22256. return iteratorDone();
  22257. });
  22258. };
  22259. return Stack;
  22260. }(IndexedCollection));
  22261. Stack.isStack = isStack;
  22262. var StackPrototype = Stack.prototype;
  22263. StackPrototype[IS_STACK_SYMBOL] = true;
  22264. StackPrototype.shift = StackPrototype.pop;
  22265. StackPrototype.unshift = StackPrototype.push;
  22266. StackPrototype.unshiftAll = StackPrototype.pushAll;
  22267. StackPrototype.withMutations = withMutations;
  22268. StackPrototype.wasAltered = wasAltered;
  22269. StackPrototype.asImmutable = asImmutable;
  22270. StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
  22271. StackPrototype['@@transducer/step'] = function(result, arr) {
  22272. return result.unshift(arr);
  22273. };
  22274. StackPrototype['@@transducer/result'] = function(obj) {
  22275. return obj.asImmutable();
  22276. };
  22277. function makeStack(size, head, ownerID, hash) {
  22278. var map = Object.create(StackPrototype);
  22279. map.size = size;
  22280. map._head = head;
  22281. map.__ownerID = ownerID;
  22282. map.__hash = hash;
  22283. map.__altered = false;
  22284. return map;
  22285. }
  22286. var EMPTY_STACK;
  22287. function emptyStack() {
  22288. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  22289. }
  22290. var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@';
  22291. function isSet(maybeSet) {
  22292. return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
  22293. }
  22294. function isOrderedSet(maybeOrderedSet) {
  22295. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  22296. }
  22297. function deepEqual(a, b) {
  22298. if (a === b) {
  22299. return true;
  22300. }
  22301. if (
  22302. !isCollection(b) ||
  22303. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  22304. (a.__hash !== undefined &&
  22305. b.__hash !== undefined &&
  22306. a.__hash !== b.__hash) ||
  22307. isKeyed(a) !== isKeyed(b) ||
  22308. isIndexed(a) !== isIndexed(b) ||
  22309. isOrdered(a) !== isOrdered(b)
  22310. ) {
  22311. return false;
  22312. }
  22313. if (a.size === 0 && b.size === 0) {
  22314. return true;
  22315. }
  22316. var notAssociative = !isAssociative(a);
  22317. if (isOrdered(a)) {
  22318. var entries = a.entries();
  22319. return (
  22320. b.every(function (v, k) {
  22321. var entry = entries.next().value;
  22322. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  22323. }) && entries.next().done
  22324. );
  22325. }
  22326. var flipped = false;
  22327. if (a.size === undefined) {
  22328. if (b.size === undefined) {
  22329. if (typeof a.cacheResult === 'function') {
  22330. a.cacheResult();
  22331. }
  22332. } else {
  22333. flipped = true;
  22334. var _ = a;
  22335. a = b;
  22336. b = _;
  22337. }
  22338. }
  22339. var allEqual = true;
  22340. var bSize = b.__iterate(function (v, k) {
  22341. if (
  22342. notAssociative
  22343. ? !a.has(v)
  22344. : flipped
  22345. ? !is(v, a.get(k, NOT_SET))
  22346. : !is(a.get(k, NOT_SET), v)
  22347. ) {
  22348. allEqual = false;
  22349. return false;
  22350. }
  22351. });
  22352. return allEqual && a.size === bSize;
  22353. }
  22354. /**
  22355. * Contributes additional methods to a constructor
  22356. */
  22357. function mixin(ctor, methods) {
  22358. var keyCopier = function (key) {
  22359. ctor.prototype[key] = methods[key];
  22360. };
  22361. Object.keys(methods).forEach(keyCopier);
  22362. Object.getOwnPropertySymbols &&
  22363. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  22364. return ctor;
  22365. }
  22366. function toJS(value) {
  22367. if (!value || typeof value !== 'object') {
  22368. return value;
  22369. }
  22370. if (!isCollection(value)) {
  22371. if (!isDataStructure(value)) {
  22372. return value;
  22373. }
  22374. value = Seq(value);
  22375. }
  22376. if (isKeyed(value)) {
  22377. var result$1 = {};
  22378. value.__iterate(function (v, k) {
  22379. result$1[k] = toJS(v);
  22380. });
  22381. return result$1;
  22382. }
  22383. var result = [];
  22384. value.__iterate(function (v) {
  22385. result.push(toJS(v));
  22386. });
  22387. return result;
  22388. }
  22389. var Set = /*@__PURE__*/(function (SetCollection$$1) {
  22390. function Set(value) {
  22391. return value === null || value === undefined
  22392. ? emptySet()
  22393. : isSet(value) && !isOrdered(value)
  22394. ? value
  22395. : emptySet().withMutations(function (set) {
  22396. var iter = SetCollection$$1(value);
  22397. assertNotInfinite(iter.size);
  22398. iter.forEach(function (v) { return set.add(v); });
  22399. });
  22400. }
  22401. if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1;
  22402. Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype );
  22403. Set.prototype.constructor = Set;
  22404. Set.of = function of (/*...values*/) {
  22405. return this(arguments);
  22406. };
  22407. Set.fromKeys = function fromKeys (value) {
  22408. return this(KeyedCollection(value).keySeq());
  22409. };
  22410. Set.intersect = function intersect (sets) {
  22411. sets = Collection(sets).toArray();
  22412. return sets.length
  22413. ? SetPrototype.intersect.apply(Set(sets.pop()), sets)
  22414. : emptySet();
  22415. };
  22416. Set.union = function union (sets) {
  22417. sets = Collection(sets).toArray();
  22418. return sets.length
  22419. ? SetPrototype.union.apply(Set(sets.pop()), sets)
  22420. : emptySet();
  22421. };
  22422. Set.prototype.toString = function toString () {
  22423. return this.__toString('Set {', '}');
  22424. };
  22425. // @pragma Access
  22426. Set.prototype.has = function has (value) {
  22427. return this._map.has(value);
  22428. };
  22429. // @pragma Modification
  22430. Set.prototype.add = function add (value) {
  22431. return updateSet(this, this._map.set(value, value));
  22432. };
  22433. Set.prototype.remove = function remove (value) {
  22434. return updateSet(this, this._map.remove(value));
  22435. };
  22436. Set.prototype.clear = function clear () {
  22437. return updateSet(this, this._map.clear());
  22438. };
  22439. // @pragma Composition
  22440. Set.prototype.map = function map (mapper, context) {
  22441. var this$1 = this;
  22442. var removes = [];
  22443. var adds = [];
  22444. this.forEach(function (value) {
  22445. var mapped = mapper.call(context, value, value, this$1);
  22446. if (mapped !== value) {
  22447. removes.push(value);
  22448. adds.push(mapped);
  22449. }
  22450. });
  22451. return this.withMutations(function (set) {
  22452. removes.forEach(function (value) { return set.remove(value); });
  22453. adds.forEach(function (value) { return set.add(value); });
  22454. });
  22455. };
  22456. Set.prototype.union = function union () {
  22457. var iters = [], len = arguments.length;
  22458. while ( len-- ) iters[ len ] = arguments[ len ];
  22459. iters = iters.filter(function (x) { return x.size !== 0; });
  22460. if (iters.length === 0) {
  22461. return this;
  22462. }
  22463. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  22464. return this.constructor(iters[0]);
  22465. }
  22466. return this.withMutations(function (set) {
  22467. for (var ii = 0; ii < iters.length; ii++) {
  22468. SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); });
  22469. }
  22470. });
  22471. };
  22472. Set.prototype.intersect = function intersect () {
  22473. var iters = [], len = arguments.length;
  22474. while ( len-- ) iters[ len ] = arguments[ len ];
  22475. if (iters.length === 0) {
  22476. return this;
  22477. }
  22478. iters = iters.map(function (iter) { return SetCollection$$1(iter); });
  22479. var toRemove = [];
  22480. this.forEach(function (value) {
  22481. if (!iters.every(function (iter) { return iter.includes(value); })) {
  22482. toRemove.push(value);
  22483. }
  22484. });
  22485. return this.withMutations(function (set) {
  22486. toRemove.forEach(function (value) {
  22487. set.remove(value);
  22488. });
  22489. });
  22490. };
  22491. Set.prototype.subtract = function subtract () {
  22492. var iters = [], len = arguments.length;
  22493. while ( len-- ) iters[ len ] = arguments[ len ];
  22494. if (iters.length === 0) {
  22495. return this;
  22496. }
  22497. iters = iters.map(function (iter) { return SetCollection$$1(iter); });
  22498. var toRemove = [];
  22499. this.forEach(function (value) {
  22500. if (iters.some(function (iter) { return iter.includes(value); })) {
  22501. toRemove.push(value);
  22502. }
  22503. });
  22504. return this.withMutations(function (set) {
  22505. toRemove.forEach(function (value) {
  22506. set.remove(value);
  22507. });
  22508. });
  22509. };
  22510. Set.prototype.sort = function sort (comparator) {
  22511. // Late binding
  22512. return OrderedSet(sortFactory(this, comparator));
  22513. };
  22514. Set.prototype.sortBy = function sortBy (mapper, comparator) {
  22515. // Late binding
  22516. return OrderedSet(sortFactory(this, comparator, mapper));
  22517. };
  22518. Set.prototype.wasAltered = function wasAltered () {
  22519. return this._map.wasAltered();
  22520. };
  22521. Set.prototype.__iterate = function __iterate (fn, reverse) {
  22522. var this$1 = this;
  22523. return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse);
  22524. };
  22525. Set.prototype.__iterator = function __iterator (type, reverse) {
  22526. return this._map.__iterator(type, reverse);
  22527. };
  22528. Set.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  22529. if (ownerID === this.__ownerID) {
  22530. return this;
  22531. }
  22532. var newMap = this._map.__ensureOwner(ownerID);
  22533. if (!ownerID) {
  22534. if (this.size === 0) {
  22535. return this.__empty();
  22536. }
  22537. this.__ownerID = ownerID;
  22538. this._map = newMap;
  22539. return this;
  22540. }
  22541. return this.__make(newMap, ownerID);
  22542. };
  22543. return Set;
  22544. }(SetCollection));
  22545. Set.isSet = isSet;
  22546. var SetPrototype = Set.prototype;
  22547. SetPrototype[IS_SET_SYMBOL] = true;
  22548. SetPrototype[DELETE] = SetPrototype.remove;
  22549. SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
  22550. SetPrototype.withMutations = withMutations;
  22551. SetPrototype.asImmutable = asImmutable;
  22552. SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
  22553. SetPrototype['@@transducer/step'] = function(result, arr) {
  22554. return result.add(arr);
  22555. };
  22556. SetPrototype['@@transducer/result'] = function(obj) {
  22557. return obj.asImmutable();
  22558. };
  22559. SetPrototype.__empty = emptySet;
  22560. SetPrototype.__make = makeSet;
  22561. function updateSet(set, newMap) {
  22562. if (set.__ownerID) {
  22563. set.size = newMap.size;
  22564. set._map = newMap;
  22565. return set;
  22566. }
  22567. return newMap === set._map
  22568. ? set
  22569. : newMap.size === 0
  22570. ? set.__empty()
  22571. : set.__make(newMap);
  22572. }
  22573. function makeSet(map, ownerID) {
  22574. var set = Object.create(SetPrototype);
  22575. set.size = map ? map.size : 0;
  22576. set._map = map;
  22577. set.__ownerID = ownerID;
  22578. return set;
  22579. }
  22580. var EMPTY_SET;
  22581. function emptySet() {
  22582. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  22583. }
  22584. /**
  22585. * Returns a lazy seq of nums from start (inclusive) to end
  22586. * (exclusive), by step, where start defaults to 0, step to 1, and end to
  22587. * infinity. When start is equal to end, returns empty list.
  22588. */
  22589. var Range = /*@__PURE__*/(function (IndexedSeq$$1) {
  22590. function Range(start, end, step) {
  22591. if (!(this instanceof Range)) {
  22592. return new Range(start, end, step);
  22593. }
  22594. invariant(step !== 0, 'Cannot step a Range by 0');
  22595. start = start || 0;
  22596. if (end === undefined) {
  22597. end = Infinity;
  22598. }
  22599. step = step === undefined ? 1 : Math.abs(step);
  22600. if (end < start) {
  22601. step = -step;
  22602. }
  22603. this._start = start;
  22604. this._end = end;
  22605. this._step = step;
  22606. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  22607. if (this.size === 0) {
  22608. if (EMPTY_RANGE) {
  22609. return EMPTY_RANGE;
  22610. }
  22611. EMPTY_RANGE = this;
  22612. }
  22613. }
  22614. if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1;
  22615. Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  22616. Range.prototype.constructor = Range;
  22617. Range.prototype.toString = function toString () {
  22618. if (this.size === 0) {
  22619. return 'Range []';
  22620. }
  22621. return (
  22622. 'Range [ ' +
  22623. this._start +
  22624. '...' +
  22625. this._end +
  22626. (this._step !== 1 ? ' by ' + this._step : '') +
  22627. ' ]'
  22628. );
  22629. };
  22630. Range.prototype.get = function get (index, notSetValue) {
  22631. return this.has(index)
  22632. ? this._start + wrapIndex(this, index) * this._step
  22633. : notSetValue;
  22634. };
  22635. Range.prototype.includes = function includes (searchValue) {
  22636. var possibleIndex = (searchValue - this._start) / this._step;
  22637. return (
  22638. possibleIndex >= 0 &&
  22639. possibleIndex < this.size &&
  22640. possibleIndex === Math.floor(possibleIndex)
  22641. );
  22642. };
  22643. Range.prototype.slice = function slice (begin, end) {
  22644. if (wholeSlice(begin, end, this.size)) {
  22645. return this;
  22646. }
  22647. begin = resolveBegin(begin, this.size);
  22648. end = resolveEnd(end, this.size);
  22649. if (end <= begin) {
  22650. return new Range(0, 0);
  22651. }
  22652. return new Range(
  22653. this.get(begin, this._end),
  22654. this.get(end, this._end),
  22655. this._step
  22656. );
  22657. };
  22658. Range.prototype.indexOf = function indexOf (searchValue) {
  22659. var offsetValue = searchValue - this._start;
  22660. if (offsetValue % this._step === 0) {
  22661. var index = offsetValue / this._step;
  22662. if (index >= 0 && index < this.size) {
  22663. return index;
  22664. }
  22665. }
  22666. return -1;
  22667. };
  22668. Range.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  22669. return this.indexOf(searchValue);
  22670. };
  22671. Range.prototype.__iterate = function __iterate (fn, reverse) {
  22672. var size = this.size;
  22673. var step = this._step;
  22674. var value = reverse ? this._start + (size - 1) * step : this._start;
  22675. var i = 0;
  22676. while (i !== size) {
  22677. if (fn(value, reverse ? size - ++i : i++, this) === false) {
  22678. break;
  22679. }
  22680. value += reverse ? -step : step;
  22681. }
  22682. return i;
  22683. };
  22684. Range.prototype.__iterator = function __iterator (type, reverse) {
  22685. var size = this.size;
  22686. var step = this._step;
  22687. var value = reverse ? this._start + (size - 1) * step : this._start;
  22688. var i = 0;
  22689. return new Iterator(function () {
  22690. if (i === size) {
  22691. return iteratorDone();
  22692. }
  22693. var v = value;
  22694. value += reverse ? -step : step;
  22695. return iteratorValue(type, reverse ? size - ++i : i++, v);
  22696. });
  22697. };
  22698. Range.prototype.equals = function equals (other) {
  22699. return other instanceof Range
  22700. ? this._start === other._start &&
  22701. this._end === other._end &&
  22702. this._step === other._step
  22703. : deepEqual(this, other);
  22704. };
  22705. return Range;
  22706. }(IndexedSeq));
  22707. var EMPTY_RANGE;
  22708. function getIn(collection, searchKeyPath, notSetValue) {
  22709. var keyPath = coerceKeyPath(searchKeyPath);
  22710. var i = 0;
  22711. while (i !== keyPath.length) {
  22712. collection = get(collection, keyPath[i++], NOT_SET);
  22713. if (collection === NOT_SET) {
  22714. return notSetValue;
  22715. }
  22716. }
  22717. return collection;
  22718. }
  22719. function getIn$1(searchKeyPath, notSetValue) {
  22720. return getIn(this, searchKeyPath, notSetValue);
  22721. }
  22722. function hasIn(collection, keyPath) {
  22723. return getIn(collection, keyPath, NOT_SET) !== NOT_SET;
  22724. }
  22725. function hasIn$1(searchKeyPath) {
  22726. return hasIn(this, searchKeyPath);
  22727. }
  22728. function toObject() {
  22729. assertNotInfinite(this.size);
  22730. var object = {};
  22731. this.__iterate(function (v, k) {
  22732. object[k] = v;
  22733. });
  22734. return object;
  22735. }
  22736. // Note: all of these methods are deprecated.
  22737. Collection.isIterable = isCollection;
  22738. Collection.isKeyed = isKeyed;
  22739. Collection.isIndexed = isIndexed;
  22740. Collection.isAssociative = isAssociative;
  22741. Collection.isOrdered = isOrdered;
  22742. Collection.Iterator = Iterator;
  22743. mixin(Collection, {
  22744. // ### Conversion to other types
  22745. toArray: function toArray() {
  22746. assertNotInfinite(this.size);
  22747. var array = new Array(this.size || 0);
  22748. var useTuples = isKeyed(this);
  22749. var i = 0;
  22750. this.__iterate(function (v, k) {
  22751. // Keyed collections produce an array of tuples.
  22752. array[i++] = useTuples ? [k, v] : v;
  22753. });
  22754. return array;
  22755. },
  22756. toIndexedSeq: function toIndexedSeq() {
  22757. return new ToIndexedSequence(this);
  22758. },
  22759. toJS: function toJS$1() {
  22760. return toJS(this);
  22761. },
  22762. toKeyedSeq: function toKeyedSeq() {
  22763. return new ToKeyedSequence(this, true);
  22764. },
  22765. toMap: function toMap() {
  22766. // Use Late Binding here to solve the circular dependency.
  22767. return Map(this.toKeyedSeq());
  22768. },
  22769. toObject: toObject,
  22770. toOrderedMap: function toOrderedMap() {
  22771. // Use Late Binding here to solve the circular dependency.
  22772. return OrderedMap(this.toKeyedSeq());
  22773. },
  22774. toOrderedSet: function toOrderedSet() {
  22775. // Use Late Binding here to solve the circular dependency.
  22776. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  22777. },
  22778. toSet: function toSet() {
  22779. // Use Late Binding here to solve the circular dependency.
  22780. return Set(isKeyed(this) ? this.valueSeq() : this);
  22781. },
  22782. toSetSeq: function toSetSeq() {
  22783. return new ToSetSequence(this);
  22784. },
  22785. toSeq: function toSeq() {
  22786. return isIndexed(this)
  22787. ? this.toIndexedSeq()
  22788. : isKeyed(this)
  22789. ? this.toKeyedSeq()
  22790. : this.toSetSeq();
  22791. },
  22792. toStack: function toStack() {
  22793. // Use Late Binding here to solve the circular dependency.
  22794. return Stack(isKeyed(this) ? this.valueSeq() : this);
  22795. },
  22796. toList: function toList() {
  22797. // Use Late Binding here to solve the circular dependency.
  22798. return List(isKeyed(this) ? this.valueSeq() : this);
  22799. },
  22800. // ### Common JavaScript methods and properties
  22801. toString: function toString() {
  22802. return '[Collection]';
  22803. },
  22804. __toString: function __toString(head, tail) {
  22805. if (this.size === 0) {
  22806. return head + tail;
  22807. }
  22808. return (
  22809. head +
  22810. ' ' +
  22811. this.toSeq()
  22812. .map(this.__toStringMapper)
  22813. .join(', ') +
  22814. ' ' +
  22815. tail
  22816. );
  22817. },
  22818. // ### ES6 Collection methods (ES6 Array and Map)
  22819. concat: function concat() {
  22820. var values = [], len = arguments.length;
  22821. while ( len-- ) values[ len ] = arguments[ len ];
  22822. return reify(this, concatFactory(this, values));
  22823. },
  22824. includes: function includes(searchValue) {
  22825. return this.some(function (value) { return is(value, searchValue); });
  22826. },
  22827. entries: function entries() {
  22828. return this.__iterator(ITERATE_ENTRIES);
  22829. },
  22830. every: function every(predicate, context) {
  22831. assertNotInfinite(this.size);
  22832. var returnValue = true;
  22833. this.__iterate(function (v, k, c) {
  22834. if (!predicate.call(context, v, k, c)) {
  22835. returnValue = false;
  22836. return false;
  22837. }
  22838. });
  22839. return returnValue;
  22840. },
  22841. filter: function filter(predicate, context) {
  22842. return reify(this, filterFactory(this, predicate, context, true));
  22843. },
  22844. find: function find(predicate, context, notSetValue) {
  22845. var entry = this.findEntry(predicate, context);
  22846. return entry ? entry[1] : notSetValue;
  22847. },
  22848. forEach: function forEach(sideEffect, context) {
  22849. assertNotInfinite(this.size);
  22850. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  22851. },
  22852. join: function join(separator) {
  22853. assertNotInfinite(this.size);
  22854. separator = separator !== undefined ? '' + separator : ',';
  22855. var joined = '';
  22856. var isFirst = true;
  22857. this.__iterate(function (v) {
  22858. isFirst ? (isFirst = false) : (joined += separator);
  22859. joined += v !== null && v !== undefined ? v.toString() : '';
  22860. });
  22861. return joined;
  22862. },
  22863. keys: function keys() {
  22864. return this.__iterator(ITERATE_KEYS);
  22865. },
  22866. map: function map(mapper, context) {
  22867. return reify(this, mapFactory(this, mapper, context));
  22868. },
  22869. reduce: function reduce$1(reducer, initialReduction, context) {
  22870. return reduce(
  22871. this,
  22872. reducer,
  22873. initialReduction,
  22874. context,
  22875. arguments.length < 2,
  22876. false
  22877. );
  22878. },
  22879. reduceRight: function reduceRight(reducer, initialReduction, context) {
  22880. return reduce(
  22881. this,
  22882. reducer,
  22883. initialReduction,
  22884. context,
  22885. arguments.length < 2,
  22886. true
  22887. );
  22888. },
  22889. reverse: function reverse() {
  22890. return reify(this, reverseFactory(this, true));
  22891. },
  22892. slice: function slice(begin, end) {
  22893. return reify(this, sliceFactory(this, begin, end, true));
  22894. },
  22895. some: function some(predicate, context) {
  22896. return !this.every(not(predicate), context);
  22897. },
  22898. sort: function sort(comparator) {
  22899. return reify(this, sortFactory(this, comparator));
  22900. },
  22901. values: function values() {
  22902. return this.__iterator(ITERATE_VALUES);
  22903. },
  22904. // ### More sequential methods
  22905. butLast: function butLast() {
  22906. return this.slice(0, -1);
  22907. },
  22908. isEmpty: function isEmpty() {
  22909. return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; });
  22910. },
  22911. count: function count(predicate, context) {
  22912. return ensureSize(
  22913. predicate ? this.toSeq().filter(predicate, context) : this
  22914. );
  22915. },
  22916. countBy: function countBy(grouper, context) {
  22917. return countByFactory(this, grouper, context);
  22918. },
  22919. equals: function equals(other) {
  22920. return deepEqual(this, other);
  22921. },
  22922. entrySeq: function entrySeq() {
  22923. var collection = this;
  22924. if (collection._cache) {
  22925. // We cache as an entries array, so we can just return the cache!
  22926. return new ArraySeq(collection._cache);
  22927. }
  22928. var entriesSequence = collection
  22929. .toSeq()
  22930. .map(entryMapper)
  22931. .toIndexedSeq();
  22932. entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
  22933. return entriesSequence;
  22934. },
  22935. filterNot: function filterNot(predicate, context) {
  22936. return this.filter(not(predicate), context);
  22937. },
  22938. findEntry: function findEntry(predicate, context, notSetValue) {
  22939. var found = notSetValue;
  22940. this.__iterate(function (v, k, c) {
  22941. if (predicate.call(context, v, k, c)) {
  22942. found = [k, v];
  22943. return false;
  22944. }
  22945. });
  22946. return found;
  22947. },
  22948. findKey: function findKey(predicate, context) {
  22949. var entry = this.findEntry(predicate, context);
  22950. return entry && entry[0];
  22951. },
  22952. findLast: function findLast(predicate, context, notSetValue) {
  22953. return this.toKeyedSeq()
  22954. .reverse()
  22955. .find(predicate, context, notSetValue);
  22956. },
  22957. findLastEntry: function findLastEntry(predicate, context, notSetValue) {
  22958. return this.toKeyedSeq()
  22959. .reverse()
  22960. .findEntry(predicate, context, notSetValue);
  22961. },
  22962. findLastKey: function findLastKey(predicate, context) {
  22963. return this.toKeyedSeq()
  22964. .reverse()
  22965. .findKey(predicate, context);
  22966. },
  22967. first: function first(notSetValue) {
  22968. return this.find(returnTrue, null, notSetValue);
  22969. },
  22970. flatMap: function flatMap(mapper, context) {
  22971. return reify(this, flatMapFactory(this, mapper, context));
  22972. },
  22973. flatten: function flatten(depth) {
  22974. return reify(this, flattenFactory(this, depth, true));
  22975. },
  22976. fromEntrySeq: function fromEntrySeq() {
  22977. return new FromEntriesSequence(this);
  22978. },
  22979. get: function get(searchKey, notSetValue) {
  22980. return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
  22981. },
  22982. getIn: getIn$1,
  22983. groupBy: function groupBy(grouper, context) {
  22984. return groupByFactory(this, grouper, context);
  22985. },
  22986. has: function has(searchKey) {
  22987. return this.get(searchKey, NOT_SET) !== NOT_SET;
  22988. },
  22989. hasIn: hasIn$1,
  22990. isSubset: function isSubset(iter) {
  22991. iter = typeof iter.includes === 'function' ? iter : Collection(iter);
  22992. return this.every(function (value) { return iter.includes(value); });
  22993. },
  22994. isSuperset: function isSuperset(iter) {
  22995. iter = typeof iter.isSubset === 'function' ? iter : Collection(iter);
  22996. return iter.isSubset(this);
  22997. },
  22998. keyOf: function keyOf(searchValue) {
  22999. return this.findKey(function (value) { return is(value, searchValue); });
  23000. },
  23001. keySeq: function keySeq() {
  23002. return this.toSeq()
  23003. .map(keyMapper)
  23004. .toIndexedSeq();
  23005. },
  23006. last: function last(notSetValue) {
  23007. return this.toSeq()
  23008. .reverse()
  23009. .first(notSetValue);
  23010. },
  23011. lastKeyOf: function lastKeyOf(searchValue) {
  23012. return this.toKeyedSeq()
  23013. .reverse()
  23014. .keyOf(searchValue);
  23015. },
  23016. max: function max(comparator) {
  23017. return maxFactory(this, comparator);
  23018. },
  23019. maxBy: function maxBy(mapper, comparator) {
  23020. return maxFactory(this, comparator, mapper);
  23021. },
  23022. min: function min(comparator) {
  23023. return maxFactory(
  23024. this,
  23025. comparator ? neg(comparator) : defaultNegComparator
  23026. );
  23027. },
  23028. minBy: function minBy(mapper, comparator) {
  23029. return maxFactory(
  23030. this,
  23031. comparator ? neg(comparator) : defaultNegComparator,
  23032. mapper
  23033. );
  23034. },
  23035. rest: function rest() {
  23036. return this.slice(1);
  23037. },
  23038. skip: function skip(amount) {
  23039. return amount === 0 ? this : this.slice(Math.max(0, amount));
  23040. },
  23041. skipLast: function skipLast(amount) {
  23042. return amount === 0 ? this : this.slice(0, -Math.max(0, amount));
  23043. },
  23044. skipWhile: function skipWhile(predicate, context) {
  23045. return reify(this, skipWhileFactory(this, predicate, context, true));
  23046. },
  23047. skipUntil: function skipUntil(predicate, context) {
  23048. return this.skipWhile(not(predicate), context);
  23049. },
  23050. sortBy: function sortBy(mapper, comparator) {
  23051. return reify(this, sortFactory(this, comparator, mapper));
  23052. },
  23053. take: function take(amount) {
  23054. return this.slice(0, Math.max(0, amount));
  23055. },
  23056. takeLast: function takeLast(amount) {
  23057. return this.slice(-Math.max(0, amount));
  23058. },
  23059. takeWhile: function takeWhile(predicate, context) {
  23060. return reify(this, takeWhileFactory(this, predicate, context));
  23061. },
  23062. takeUntil: function takeUntil(predicate, context) {
  23063. return this.takeWhile(not(predicate), context);
  23064. },
  23065. update: function update(fn) {
  23066. return fn(this);
  23067. },
  23068. valueSeq: function valueSeq() {
  23069. return this.toIndexedSeq();
  23070. },
  23071. // ### Hashable Object
  23072. hashCode: function hashCode() {
  23073. return this.__hash || (this.__hash = hashCollection(this));
  23074. },
  23075. // ### Internal
  23076. // abstract __iterate(fn, reverse)
  23077. // abstract __iterator(type, reverse)
  23078. });
  23079. var CollectionPrototype = Collection.prototype;
  23080. CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
  23081. CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
  23082. CollectionPrototype.toJSON = CollectionPrototype.toArray;
  23083. CollectionPrototype.__toStringMapper = quoteString;
  23084. CollectionPrototype.inspect = CollectionPrototype.toSource = function() {
  23085. return this.toString();
  23086. };
  23087. CollectionPrototype.chain = CollectionPrototype.flatMap;
  23088. CollectionPrototype.contains = CollectionPrototype.includes;
  23089. mixin(KeyedCollection, {
  23090. // ### More sequential methods
  23091. flip: function flip() {
  23092. return reify(this, flipFactory(this));
  23093. },
  23094. mapEntries: function mapEntries(mapper, context) {
  23095. var this$1 = this;
  23096. var iterations = 0;
  23097. return reify(
  23098. this,
  23099. this.toSeq()
  23100. .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); })
  23101. .fromEntrySeq()
  23102. );
  23103. },
  23104. mapKeys: function mapKeys(mapper, context) {
  23105. var this$1 = this;
  23106. return reify(
  23107. this,
  23108. this.toSeq()
  23109. .flip()
  23110. .map(function (k, v) { return mapper.call(context, k, v, this$1); })
  23111. .flip()
  23112. );
  23113. },
  23114. });
  23115. var KeyedCollectionPrototype = KeyedCollection.prototype;
  23116. KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
  23117. KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
  23118. KeyedCollectionPrototype.toJSON = toObject;
  23119. KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
  23120. mixin(IndexedCollection, {
  23121. // ### Conversion to other types
  23122. toKeyedSeq: function toKeyedSeq() {
  23123. return new ToKeyedSequence(this, false);
  23124. },
  23125. // ### ES6 Collection methods (ES6 Array and Map)
  23126. filter: function filter(predicate, context) {
  23127. return reify(this, filterFactory(this, predicate, context, false));
  23128. },
  23129. findIndex: function findIndex(predicate, context) {
  23130. var entry = this.findEntry(predicate, context);
  23131. return entry ? entry[0] : -1;
  23132. },
  23133. indexOf: function indexOf(searchValue) {
  23134. var key = this.keyOf(searchValue);
  23135. return key === undefined ? -1 : key;
  23136. },
  23137. lastIndexOf: function lastIndexOf(searchValue) {
  23138. var key = this.lastKeyOf(searchValue);
  23139. return key === undefined ? -1 : key;
  23140. },
  23141. reverse: function reverse() {
  23142. return reify(this, reverseFactory(this, false));
  23143. },
  23144. slice: function slice(begin, end) {
  23145. return reify(this, sliceFactory(this, begin, end, false));
  23146. },
  23147. splice: function splice(index, removeNum /*, ...values*/) {
  23148. var numArgs = arguments.length;
  23149. removeNum = Math.max(removeNum || 0, 0);
  23150. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  23151. return this;
  23152. }
  23153. // If index is negative, it should resolve relative to the size of the
  23154. // collection. However size may be expensive to compute if not cached, so
  23155. // only call count() if the number is in fact negative.
  23156. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  23157. var spliced = this.slice(0, index);
  23158. return reify(
  23159. this,
  23160. numArgs === 1
  23161. ? spliced
  23162. : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  23163. );
  23164. },
  23165. // ### More collection methods
  23166. findLastIndex: function findLastIndex(predicate, context) {
  23167. var entry = this.findLastEntry(predicate, context);
  23168. return entry ? entry[0] : -1;
  23169. },
  23170. first: function first(notSetValue) {
  23171. return this.get(0, notSetValue);
  23172. },
  23173. flatten: function flatten(depth) {
  23174. return reify(this, flattenFactory(this, depth, false));
  23175. },
  23176. get: function get(index, notSetValue) {
  23177. index = wrapIndex(this, index);
  23178. return index < 0 ||
  23179. (this.size === Infinity || (this.size !== undefined && index > this.size))
  23180. ? notSetValue
  23181. : this.find(function (_, key) { return key === index; }, undefined, notSetValue);
  23182. },
  23183. has: function has(index) {
  23184. index = wrapIndex(this, index);
  23185. return (
  23186. index >= 0 &&
  23187. (this.size !== undefined
  23188. ? this.size === Infinity || index < this.size
  23189. : this.indexOf(index) !== -1)
  23190. );
  23191. },
  23192. interpose: function interpose(separator) {
  23193. return reify(this, interposeFactory(this, separator));
  23194. },
  23195. interleave: function interleave(/*...collections*/) {
  23196. var collections = [this].concat(arrCopy(arguments));
  23197. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections);
  23198. var interleaved = zipped.flatten(true);
  23199. if (zipped.size) {
  23200. interleaved.size = zipped.size * collections.length;
  23201. }
  23202. return reify(this, interleaved);
  23203. },
  23204. keySeq: function keySeq() {
  23205. return Range(0, this.size);
  23206. },
  23207. last: function last(notSetValue) {
  23208. return this.get(-1, notSetValue);
  23209. },
  23210. skipWhile: function skipWhile(predicate, context) {
  23211. return reify(this, skipWhileFactory(this, predicate, context, false));
  23212. },
  23213. zip: function zip(/*, ...collections */) {
  23214. var collections = [this].concat(arrCopy(arguments));
  23215. return reify(this, zipWithFactory(this, defaultZipper, collections));
  23216. },
  23217. zipAll: function zipAll(/*, ...collections */) {
  23218. var collections = [this].concat(arrCopy(arguments));
  23219. return reify(this, zipWithFactory(this, defaultZipper, collections, true));
  23220. },
  23221. zipWith: function zipWith(zipper /*, ...collections */) {
  23222. var collections = arrCopy(arguments);
  23223. collections[0] = this;
  23224. return reify(this, zipWithFactory(this, zipper, collections));
  23225. },
  23226. });
  23227. var IndexedCollectionPrototype = IndexedCollection.prototype;
  23228. IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
  23229. IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
  23230. mixin(SetCollection, {
  23231. // ### ES6 Collection methods (ES6 Array and Map)
  23232. get: function get(value, notSetValue) {
  23233. return this.has(value) ? value : notSetValue;
  23234. },
  23235. includes: function includes(value) {
  23236. return this.has(value);
  23237. },
  23238. // ### More sequential methods
  23239. keySeq: function keySeq() {
  23240. return this.valueSeq();
  23241. },
  23242. });
  23243. SetCollection.prototype.has = CollectionPrototype.includes;
  23244. SetCollection.prototype.contains = SetCollection.prototype.includes;
  23245. // Mixin subclasses
  23246. mixin(KeyedSeq, KeyedCollection.prototype);
  23247. mixin(IndexedSeq, IndexedCollection.prototype);
  23248. mixin(SetSeq, SetCollection.prototype);
  23249. // #pragma Helper functions
  23250. function reduce(collection, reducer, reduction, context, useFirst, reverse) {
  23251. assertNotInfinite(collection.size);
  23252. collection.__iterate(function (v, k, c) {
  23253. if (useFirst) {
  23254. useFirst = false;
  23255. reduction = v;
  23256. } else {
  23257. reduction = reducer.call(context, reduction, v, k, c);
  23258. }
  23259. }, reverse);
  23260. return reduction;
  23261. }
  23262. function keyMapper(v, k) {
  23263. return k;
  23264. }
  23265. function entryMapper(v, k) {
  23266. return [k, v];
  23267. }
  23268. function not(predicate) {
  23269. return function() {
  23270. return !predicate.apply(this, arguments);
  23271. };
  23272. }
  23273. function neg(predicate) {
  23274. return function() {
  23275. return -predicate.apply(this, arguments);
  23276. };
  23277. }
  23278. function defaultZipper() {
  23279. return arrCopy(arguments);
  23280. }
  23281. function defaultNegComparator(a, b) {
  23282. return a < b ? 1 : a > b ? -1 : 0;
  23283. }
  23284. function hashCollection(collection) {
  23285. if (collection.size === Infinity) {
  23286. return 0;
  23287. }
  23288. var ordered = isOrdered(collection);
  23289. var keyed = isKeyed(collection);
  23290. var h = ordered ? 1 : 0;
  23291. var size = collection.__iterate(
  23292. keyed
  23293. ? ordered
  23294. ? function (v, k) {
  23295. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  23296. }
  23297. : function (v, k) {
  23298. h = (h + hashMerge(hash(v), hash(k))) | 0;
  23299. }
  23300. : ordered
  23301. ? function (v) {
  23302. h = (31 * h + hash(v)) | 0;
  23303. }
  23304. : function (v) {
  23305. h = (h + hash(v)) | 0;
  23306. }
  23307. );
  23308. return murmurHashOfSize(size, h);
  23309. }
  23310. function murmurHashOfSize(size, h) {
  23311. h = imul(h, 0xcc9e2d51);
  23312. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  23313. h = imul((h << 13) | (h >>> -13), 5);
  23314. h = ((h + 0xe6546b64) | 0) ^ size;
  23315. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  23316. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  23317. h = smi(h ^ (h >>> 16));
  23318. return h;
  23319. }
  23320. function hashMerge(a, b) {
  23321. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  23322. }
  23323. var OrderedSet = /*@__PURE__*/(function (Set$$1) {
  23324. function OrderedSet(value) {
  23325. return value === null || value === undefined
  23326. ? emptyOrderedSet()
  23327. : isOrderedSet(value)
  23328. ? value
  23329. : emptyOrderedSet().withMutations(function (set) {
  23330. var iter = SetCollection(value);
  23331. assertNotInfinite(iter.size);
  23332. iter.forEach(function (v) { return set.add(v); });
  23333. });
  23334. }
  23335. if ( Set$$1 ) OrderedSet.__proto__ = Set$$1;
  23336. OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype );
  23337. OrderedSet.prototype.constructor = OrderedSet;
  23338. OrderedSet.of = function of (/*...values*/) {
  23339. return this(arguments);
  23340. };
  23341. OrderedSet.fromKeys = function fromKeys (value) {
  23342. return this(KeyedCollection(value).keySeq());
  23343. };
  23344. OrderedSet.prototype.toString = function toString () {
  23345. return this.__toString('OrderedSet {', '}');
  23346. };
  23347. return OrderedSet;
  23348. }(Set));
  23349. OrderedSet.isOrderedSet = isOrderedSet;
  23350. var OrderedSetPrototype = OrderedSet.prototype;
  23351. OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
  23352. OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
  23353. OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
  23354. OrderedSetPrototype.__empty = emptyOrderedSet;
  23355. OrderedSetPrototype.__make = makeOrderedSet;
  23356. function makeOrderedSet(map, ownerID) {
  23357. var set = Object.create(OrderedSetPrototype);
  23358. set.size = map ? map.size : 0;
  23359. set._map = map;
  23360. set.__ownerID = ownerID;
  23361. return set;
  23362. }
  23363. var EMPTY_ORDERED_SET;
  23364. function emptyOrderedSet() {
  23365. return (
  23366. EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  23367. );
  23368. }
  23369. var Record = function Record(defaultValues, name) {
  23370. var hasInitialized;
  23371. var RecordType = function Record(values) {
  23372. var this$1 = this;
  23373. if (values instanceof RecordType) {
  23374. return values;
  23375. }
  23376. if (!(this instanceof RecordType)) {
  23377. return new RecordType(values);
  23378. }
  23379. if (!hasInitialized) {
  23380. hasInitialized = true;
  23381. var keys = Object.keys(defaultValues);
  23382. var indices = (RecordTypePrototype._indices = {});
  23383. // Deprecated: left to attempt not to break any external code which
  23384. // relies on a ._name property existing on record instances.
  23385. // Use Record.getDescriptiveName() instead
  23386. RecordTypePrototype._name = name;
  23387. RecordTypePrototype._keys = keys;
  23388. RecordTypePrototype._defaultValues = defaultValues;
  23389. for (var i = 0; i < keys.length; i++) {
  23390. var propName = keys[i];
  23391. indices[propName] = i;
  23392. if (RecordTypePrototype[propName]) {
  23393. /* eslint-disable no-console */
  23394. typeof console === 'object' &&
  23395. console.warn &&
  23396. console.warn(
  23397. 'Cannot define ' +
  23398. recordName(this) +
  23399. ' with property "' +
  23400. propName +
  23401. '" since that property name is part of the Record API.'
  23402. );
  23403. /* eslint-enable no-console */
  23404. } else {
  23405. setProp(RecordTypePrototype, propName);
  23406. }
  23407. }
  23408. }
  23409. this.__ownerID = undefined;
  23410. this._values = List().withMutations(function (l) {
  23411. l.setSize(this$1._keys.length);
  23412. KeyedCollection(values).forEach(function (v, k) {
  23413. l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v);
  23414. });
  23415. });
  23416. };
  23417. var RecordTypePrototype = (RecordType.prototype = Object.create(
  23418. RecordPrototype
  23419. ));
  23420. RecordTypePrototype.constructor = RecordType;
  23421. if (name) {
  23422. RecordType.displayName = name;
  23423. }
  23424. return RecordType;
  23425. };
  23426. Record.prototype.toString = function toString () {
  23427. var str = recordName(this) + ' { ';
  23428. var keys = this._keys;
  23429. var k;
  23430. for (var i = 0, l = keys.length; i !== l; i++) {
  23431. k = keys[i];
  23432. str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k));
  23433. }
  23434. return str + ' }';
  23435. };
  23436. Record.prototype.equals = function equals (other) {
  23437. return (
  23438. this === other ||
  23439. (other &&
  23440. this._keys === other._keys &&
  23441. recordSeq(this).equals(recordSeq(other)))
  23442. );
  23443. };
  23444. Record.prototype.hashCode = function hashCode () {
  23445. return recordSeq(this).hashCode();
  23446. };
  23447. // @pragma Access
  23448. Record.prototype.has = function has (k) {
  23449. return this._indices.hasOwnProperty(k);
  23450. };
  23451. Record.prototype.get = function get (k, notSetValue) {
  23452. if (!this.has(k)) {
  23453. return notSetValue;
  23454. }
  23455. var index = this._indices[k];
  23456. var value = this._values.get(index);
  23457. return value === undefined ? this._defaultValues[k] : value;
  23458. };
  23459. // @pragma Modification
  23460. Record.prototype.set = function set (k, v) {
  23461. if (this.has(k)) {
  23462. var newValues = this._values.set(
  23463. this._indices[k],
  23464. v === this._defaultValues[k] ? undefined : v
  23465. );
  23466. if (newValues !== this._values && !this.__ownerID) {
  23467. return makeRecord(this, newValues);
  23468. }
  23469. }
  23470. return this;
  23471. };
  23472. Record.prototype.remove = function remove (k) {
  23473. return this.set(k);
  23474. };
  23475. Record.prototype.clear = function clear () {
  23476. var newValues = this._values.clear().setSize(this._keys.length);
  23477. return this.__ownerID ? this : makeRecord(this, newValues);
  23478. };
  23479. Record.prototype.wasAltered = function wasAltered () {
  23480. return this._values.wasAltered();
  23481. };
  23482. Record.prototype.toSeq = function toSeq () {
  23483. return recordSeq(this);
  23484. };
  23485. Record.prototype.toJS = function toJS$1 () {
  23486. return toJS(this);
  23487. };
  23488. Record.prototype.entries = function entries () {
  23489. return this.__iterator(ITERATE_ENTRIES);
  23490. };
  23491. Record.prototype.__iterator = function __iterator (type, reverse) {
  23492. return recordSeq(this).__iterator(type, reverse);
  23493. };
  23494. Record.prototype.__iterate = function __iterate (fn, reverse) {
  23495. return recordSeq(this).__iterate(fn, reverse);
  23496. };
  23497. Record.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  23498. if (ownerID === this.__ownerID) {
  23499. return this;
  23500. }
  23501. var newValues = this._values.__ensureOwner(ownerID);
  23502. if (!ownerID) {
  23503. this.__ownerID = ownerID;
  23504. this._values = newValues;
  23505. return this;
  23506. }
  23507. return makeRecord(this, newValues, ownerID);
  23508. };
  23509. Record.isRecord = isRecord;
  23510. Record.getDescriptiveName = recordName;
  23511. var RecordPrototype = Record.prototype;
  23512. RecordPrototype[IS_RECORD_SYMBOL] = true;
  23513. RecordPrototype[DELETE] = RecordPrototype.remove;
  23514. RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
  23515. RecordPrototype.getIn = getIn$1;
  23516. RecordPrototype.hasIn = CollectionPrototype.hasIn;
  23517. RecordPrototype.merge = merge;
  23518. RecordPrototype.mergeWith = mergeWith;
  23519. RecordPrototype.mergeIn = mergeIn;
  23520. RecordPrototype.mergeDeep = mergeDeep$1;
  23521. RecordPrototype.mergeDeepWith = mergeDeepWith$1;
  23522. RecordPrototype.mergeDeepIn = mergeDeepIn;
  23523. RecordPrototype.setIn = setIn$1;
  23524. RecordPrototype.update = update$1;
  23525. RecordPrototype.updateIn = updateIn$1;
  23526. RecordPrototype.withMutations = withMutations;
  23527. RecordPrototype.asMutable = asMutable;
  23528. RecordPrototype.asImmutable = asImmutable;
  23529. RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
  23530. RecordPrototype.toJSON = RecordPrototype.toObject =
  23531. CollectionPrototype.toObject;
  23532. RecordPrototype.inspect = RecordPrototype.toSource = function() {
  23533. return this.toString();
  23534. };
  23535. function makeRecord(likeRecord, values, ownerID) {
  23536. var record = Object.create(Object.getPrototypeOf(likeRecord));
  23537. record._values = values;
  23538. record.__ownerID = ownerID;
  23539. return record;
  23540. }
  23541. function recordName(record) {
  23542. return record.constructor.displayName || record.constructor.name || 'Record';
  23543. }
  23544. function recordSeq(record) {
  23545. return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; }));
  23546. }
  23547. function setProp(prototype, name) {
  23548. try {
  23549. Object.defineProperty(prototype, name, {
  23550. get: function() {
  23551. return this.get(name);
  23552. },
  23553. set: function(value) {
  23554. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  23555. this.set(name, value);
  23556. },
  23557. });
  23558. } catch (error) {
  23559. // Object.defineProperty failed. Probably IE8.
  23560. }
  23561. }
  23562. /**
  23563. * Returns a lazy Seq of `value` repeated `times` times. When `times` is
  23564. * undefined, returns an infinite sequence of `value`.
  23565. */
  23566. var Repeat = /*@__PURE__*/(function (IndexedSeq$$1) {
  23567. function Repeat(value, times) {
  23568. if (!(this instanceof Repeat)) {
  23569. return new Repeat(value, times);
  23570. }
  23571. this._value = value;
  23572. this.size = times === undefined ? Infinity : Math.max(0, times);
  23573. if (this.size === 0) {
  23574. if (EMPTY_REPEAT) {
  23575. return EMPTY_REPEAT;
  23576. }
  23577. EMPTY_REPEAT = this;
  23578. }
  23579. }
  23580. if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1;
  23581. Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  23582. Repeat.prototype.constructor = Repeat;
  23583. Repeat.prototype.toString = function toString () {
  23584. if (this.size === 0) {
  23585. return 'Repeat []';
  23586. }
  23587. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  23588. };
  23589. Repeat.prototype.get = function get (index, notSetValue) {
  23590. return this.has(index) ? this._value : notSetValue;
  23591. };
  23592. Repeat.prototype.includes = function includes (searchValue) {
  23593. return is(this._value, searchValue);
  23594. };
  23595. Repeat.prototype.slice = function slice (begin, end) {
  23596. var size = this.size;
  23597. return wholeSlice(begin, end, size)
  23598. ? this
  23599. : new Repeat(
  23600. this._value,
  23601. resolveEnd(end, size) - resolveBegin(begin, size)
  23602. );
  23603. };
  23604. Repeat.prototype.reverse = function reverse () {
  23605. return this;
  23606. };
  23607. Repeat.prototype.indexOf = function indexOf (searchValue) {
  23608. if (is(this._value, searchValue)) {
  23609. return 0;
  23610. }
  23611. return -1;
  23612. };
  23613. Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  23614. if (is(this._value, searchValue)) {
  23615. return this.size;
  23616. }
  23617. return -1;
  23618. };
  23619. Repeat.prototype.__iterate = function __iterate (fn, reverse) {
  23620. var size = this.size;
  23621. var i = 0;
  23622. while (i !== size) {
  23623. if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
  23624. break;
  23625. }
  23626. }
  23627. return i;
  23628. };
  23629. Repeat.prototype.__iterator = function __iterator (type, reverse) {
  23630. var this$1 = this;
  23631. var size = this.size;
  23632. var i = 0;
  23633. return new Iterator(
  23634. function () { return i === size
  23635. ? iteratorDone()
  23636. : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); }
  23637. );
  23638. };
  23639. Repeat.prototype.equals = function equals (other) {
  23640. return other instanceof Repeat
  23641. ? is(this._value, other._value)
  23642. : deepEqual(other);
  23643. };
  23644. return Repeat;
  23645. }(IndexedSeq));
  23646. var EMPTY_REPEAT;
  23647. function fromJS(value, converter) {
  23648. return fromJSWith(
  23649. [],
  23650. converter || defaultConverter,
  23651. value,
  23652. '',
  23653. converter && converter.length > 2 ? [] : undefined,
  23654. { '': value }
  23655. );
  23656. }
  23657. function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
  23658. var toSeq = Array.isArray(value)
  23659. ? IndexedSeq
  23660. : isPlainObj(value)
  23661. ? KeyedSeq
  23662. : null;
  23663. if (toSeq) {
  23664. if (~stack.indexOf(value)) {
  23665. throw new TypeError('Cannot convert circular structure to Immutable');
  23666. }
  23667. stack.push(value);
  23668. keyPath && key !== '' && keyPath.push(key);
  23669. var converted = converter.call(
  23670. parentValue,
  23671. key,
  23672. toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
  23673. ),
  23674. keyPath && keyPath.slice()
  23675. );
  23676. stack.pop();
  23677. keyPath && keyPath.pop();
  23678. return converted;
  23679. }
  23680. return value;
  23681. }
  23682. function defaultConverter(k, v) {
  23683. return isKeyed(v) ? v.toMap() : v.toList();
  23684. }
  23685. var version = "4.0.0-rc.11";
  23686. var Immutable = {
  23687. version: version,
  23688. Collection: Collection,
  23689. // Note: Iterable is deprecated
  23690. Iterable: Collection,
  23691. Seq: Seq,
  23692. Map: Map,
  23693. OrderedMap: OrderedMap,
  23694. List: List,
  23695. Stack: Stack,
  23696. Set: Set,
  23697. OrderedSet: OrderedSet,
  23698. Record: Record,
  23699. Range: Range,
  23700. Repeat: Repeat,
  23701. is: is,
  23702. fromJS: fromJS,
  23703. hash: hash,
  23704. isImmutable: isImmutable,
  23705. isCollection: isCollection,
  23706. isKeyed: isKeyed,
  23707. isIndexed: isIndexed,
  23708. isAssociative: isAssociative,
  23709. isOrdered: isOrdered,
  23710. isValueObject: isValueObject,
  23711. isSeq: isSeq,
  23712. isList: isList,
  23713. isMap: isMap,
  23714. isOrderedMap: isOrderedMap,
  23715. isStack: isStack,
  23716. isSet: isSet,
  23717. isOrderedSet: isOrderedSet,
  23718. isRecord: isRecord,
  23719. get: get,
  23720. getIn: getIn,
  23721. has: has,
  23722. hasIn: hasIn,
  23723. merge: merge$1,
  23724. mergeDeep: mergeDeep,
  23725. mergeWith: mergeWith$1,
  23726. mergeDeepWith: mergeDeepWith,
  23727. remove: remove,
  23728. removeIn: removeIn,
  23729. set: set,
  23730. setIn: setIn,
  23731. update: update,
  23732. updateIn: updateIn,
  23733. };
  23734. // Note: Iterable is deprecated
  23735. var Iterable = Collection;
  23736. exports.default = Immutable;
  23737. exports.version = version;
  23738. exports.Collection = Collection;
  23739. exports.Iterable = Iterable;
  23740. exports.Seq = Seq;
  23741. exports.Map = Map;
  23742. exports.OrderedMap = OrderedMap;
  23743. exports.List = List;
  23744. exports.Stack = Stack;
  23745. exports.Set = Set;
  23746. exports.OrderedSet = OrderedSet;
  23747. exports.Record = Record;
  23748. exports.Range = Range;
  23749. exports.Repeat = Repeat;
  23750. exports.is = is;
  23751. exports.fromJS = fromJS;
  23752. exports.hash = hash;
  23753. exports.isImmutable = isImmutable;
  23754. exports.isCollection = isCollection;
  23755. exports.isKeyed = isKeyed;
  23756. exports.isIndexed = isIndexed;
  23757. exports.isAssociative = isAssociative;
  23758. exports.isOrdered = isOrdered;
  23759. exports.isValueObject = isValueObject;
  23760. exports.get = get;
  23761. exports.getIn = getIn;
  23762. exports.has = has;
  23763. exports.hasIn = hasIn;
  23764. exports.merge = merge$1;
  23765. exports.mergeDeep = mergeDeep;
  23766. exports.mergeWith = mergeWith$1;
  23767. exports.mergeDeepWith = mergeDeepWith;
  23768. exports.remove = remove;
  23769. exports.removeIn = removeIn;
  23770. exports.set = set;
  23771. exports.setIn = setIn;
  23772. exports.update = update;
  23773. exports.updateIn = updateIn;
  23774. Object.defineProperty(exports, '__esModule', { value: true });
  23775. })));
  23776. });
  23777. _commonjsHelpers.unwrapExports(immutable$2);
  23778. var draftjsUtils$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  23779. !function(t,e){module.exports=e(Draft.Draft,immutable$2);}(window,function(n,r){return u={},o.m=i=[function(t,e){t.exports=n;},function(t,e){t.exports=r;},function(t,e,n){t.exports=n(3);},function(t,e,n){n.r(e);var C=n(0),i=n(1);function m(t){var e=t.getSelection(),n=t.getCurrentContent(),r=e.getStartKey(),o=e.getEndKey(),i=n.getBlockMap();return i.toSeq().skipUntil(function(t,e){return e===r}).takeUntil(function(t,e){return e===o}).concat([[o,i.get(o)]])}function a(t){return m(t).toList()}function f(t){if(t)return a(t).get(0)}function r(t){if(t){var n=f(t),e=t.getCurrentContent().getBlockMap().toSeq().toList(),r=0;if(e.forEach(function(t,e){t.get("key")===n.get("key")&&(r=e-1);}),-1<r)return e.get(r)}}function o(t){return t?t.getCurrentContent().getBlockMap().toList():new i.List}function u(t){var e=a(t);if(!e.some(function(t){return t.type!==e.get(0).type}))return e.get(0).type}function c(t){var e=C.RichUtils.tryToRemoveBlockStyle(t);return e?C.EditorState.push(t,e,"change-block-type"):t}function l(t){var e="",n=t.getSelection(),r=n.getAnchorOffset(),o=n.getFocusOffset(),i=a(t);if(0<i.size){if(n.getIsBackward()){var u=r;r=o,o=u;}for(var c=0;c<i.size;c+=1){var f=0===c?r:0,l=c===i.size-1?o:i.get(c).getText().length;e+=i.get(c).getText().slice(f,l);}}return e}function s(t){var e=t.getCurrentContent(),n=t.getSelection(),r=C.Modifier.removeRange(e,n,"forward"),o=r.getSelectionAfter(),i=r.getBlockForKey(o.getStartKey());return r=C.Modifier.insertText(r,o,"\n",i.getInlineStyleAt(o.getStartOffset()),null),C.EditorState.push(t,r,"insert-fragment")}function g(t){var e=C.Modifier.splitBlock(t.getCurrentContent(),t.getSelection());return c(C.EditorState.push(t,e,"split-block"))}function d(t){var e=t.getCurrentContent().getBlockMap().toList(),n=t.getSelection().merge({anchorKey:e.first().get("key"),anchorOffset:0,focusKey:e.last().get("key"),focusOffset:e.last().getLength()}),r=C.Modifier.removeRange(t.getCurrentContent(),n,"forward");return C.EditorState.push(t,r,"remove-range")}function S(t,e){var n=C.Modifier.setBlockData(t.getCurrentContent(),t.getSelection(),e);return C.EditorState.push(t,n,"change-block-data")}function p(t){var r=new i.Map({}),e=a(t);if(e&&0<e.size)for(var n=function(t){var n=e.get(t).getData();if(!n||0===n.size)return r=r.clear(),"break";if(0===t)r=n;else if(r.forEach(function(t,e){n.get(e)&&n.get(e)===t||(r=r.delete(e));}),0===r.size)return r=r.clear(),"break"},o=0;o<e.size;o+=1){if("break"===n(o))break}return r}var y=Object(i.Map)({code:{element:"pre"}}),v=C.DefaultDraftBlockRenderMap.merge(y);function b(t){if(t){var e=t.getType();return "unordered-list-item"===e||"ordered-list-item"===e}return !1}function h(t,e,n){var r,o=t.getSelection();r=o.getIsBackward()?o.getFocusKey():o.getAnchorKey();var i=t.getCurrentContent(),u=i.getBlockForKey(r),c=u.getType();if("unordered-list-item"!==c&&"ordered-list-item"!==c)return t;var f=i.getBlockBefore(r);if(!f)return t;if(f.getType()!==c)return t;var l=u.getDepth();if(1===e&&l===n)return t;var a,s,g,d,S,p,y,v=Math.min(f.getDepth()+1,n),b=(s=e,g=v,d=(a=t).getSelection(),S=a.getCurrentContent(),p=S.getBlockMap(),y=m(a).map(function(t){var e=t.getDepth()+s;return e=Math.max(0,Math.min(e,g)),t.set("depth",e)}),p=p.merge(y),S.merge({blockMap:p,selectionBefore:d,selectionAfter:d}));return C.EditorState.push(t,b,"adjust-depth")}function O(t,e){var n;return 13===(n=e).which&&(n.getModifierState("Shift")||n.getModifierState("Alt")||n.getModifierState("Control"))?t.getSelection().isCollapsed()?C.RichUtils.insertSoftNewline(t):s(t):function(t){var e=t.getSelection();if(e.isCollapsed()){var n=t.getCurrentContent(),r=e.getStartKey(),o=n.getBlockForKey(r);if(!b(o)&&"unstyled"!==o.getType()&&o.getLength()===e.getStartOffset())return g(t);if(b(o)&&0===o.getLength()){var i=o.getDepth();if(0===i)return c(t);if(0<i)return h(t,-1,i)}}}(t)}function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r);}return n}function E(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function I(t){return (I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function R(t){var e=t.getSelection();if(e.isCollapsed()){var n={},r=t.getCurrentInlineStyle().toList().toJS();if(r)return ["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){n[t]=0<=r.indexOf(t);}),n}var u=e.getStartOffset(),c=e.getEndOffset(),f=a(t);if(0<f.size){var o=function(){for(var n={BOLD:!0,ITALIC:!0,UNDERLINE:!0,STRIKETHROUGH:!0,CODE:!0,SUPERSCRIPT:!0,SUBSCRIPT:!0},r=0;r<f.size;r+=1){var t=0===r?u:0,e=r===f.size-1?c:f.get(r).getText().length;t===e&&0===t?(t=1,e=2):t===e&&--t;for(var o=function(t){var e=f.get(r).getInlineStyleAt(t);["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){n[t]=n[t]&&e.get(t)===t;});},i=t;i<e;i+=1)o(i);}return {v:n}}();if("object"===I(o))return o.v}return {}}function B(t){var e,n=t.getSelection(),r=n.getStartOffset(),o=n.getEndOffset();r===o&&0===r?o=1:r===o&&--r;for(var i=f(t),u=r;u<o;u+=1){var c=i.getEntityAt(u);if(!c){e=void 0;break}if(u===r)e=c;else if(e!==c){e=void 0;break}}return e}function T(t,e){var n,r=f(t);return r.findEntityRanges(function(t){return t.get("entity")===e},function(t,e){n={start:t,end:e,text:r.get("text").slice(t,e)};}),n}function P(t,e,n){x[t]["".concat(t.toLowerCase(),"-").concat(n)]=E({},"".concat(e),n);}function j(){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach(function(t){E(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e}({},x.color,{},x.bgcolor,{},x.fontSize,{},x.fontFamily,{CODE:x.CODE,SUPERSCRIPT:x.SUPERSCRIPT,SUBSCRIPT:x.SUBSCRIPT})}var x={color:{},bgcolor:{},fontSize:{},fontFamily:{},CODE:{fontFamily:"monospace",wordWrap:"break-word",background:"#f1f1f1",borderRadius:3,padding:"1px 3px"},SUPERSCRIPT:{fontSize:11,position:"relative",top:-8,display:"inline-flex"},SUBSCRIPT:{fontSize:11,position:"relative",bottom:-8,display:"inline-flex"}};function M(t,e,n){var r=t.getSelection(),o=Object.keys(x[e]).reduce(function(t,e){return C.Modifier.removeInlineStyle(t,r,e)},t.getCurrentContent()),i=C.EditorState.push(t,o,"changeinline-style"),u=t.getCurrentInlineStyle();if(r.isCollapsed()&&(i=u.reduce(function(t,e){return C.RichUtils.toggleInlineStyle(t,e)},i)),"SUPERSCRIPT"===e||"SUBSCRIPT"==e)u.has(n)||(i=C.RichUtils.toggleInlineStyle(i,n));else{var c="bgcolor"===e?"backgroundColor":e;u.has("".concat(c,"-").concat(n))||(i=C.RichUtils.toggleInlineStyle(i,"".concat(e.toLowerCase(),"-").concat(n)),P(e,c,n));}return i}function L(t){t&&t.getCurrentContent().getBlockMap().map(function(t){return t.get("characterList")}).toList().flatten().forEach(function(t){t&&0===t.indexOf("color-")?P("color","color",t.substr(6)):t&&0===t.indexOf("bgcolor-")?P("bgcolor","backgroundColor",t.substr(8)):t&&0===t.indexOf("fontsize-")?P("fontSize","fontSize",+t.substr(9)):t&&0===t.indexOf("fontfamily-")&&P("fontFamily","fontFamily",t.substr(11));});}function U(t,e,n){var r=t.getInlineStyleAt(n).toList().filter(function(t){return t.startsWith(e.toLowerCase())});if(r&&0<r.size)return r.get(0)}function w(r,l){if(r&&l&&0<l.length){var t=function(){var t=r.getSelection(),i={};if(t.isCollapsed())return l.forEach(function(t){i[t]=function(t,e){var n=t.getCurrentInlineStyle().toList().filter(function(t){return t.startsWith(e.toLowerCase())});if(n&&0<n.size)return n.get(0)}(r,t);}),{v:i};var u=t.getStartOffset(),c=t.getEndOffset(),f=a(r);if(0<f.size){for(var e=function(n){var t=0===n?u:0,e=n===f.size-1?c:f.get(n).getText().length;t===e&&0===t?(t=1,e=2):t===e&&--t;for(var r=function(e){e===t?l.forEach(function(t){i[t]=U(f.get(n),t,e);}):l.forEach(function(t){i[t]&&i[t]!==U(f.get(n),t,e)&&(i[t]=void 0);});},o=t;o<e;o+=1)r(o);},n=0;n<f.size;n+=1)e(n);return {v:i}}}();if("object"===I(t))return t.v}return {}}function D(e){var t=e.getCurrentInlineStyle(),n=e.getCurrentContent();return t.forEach(function(t){n=C.Modifier.removeInlineStyle(n,e.getSelection(),t);}),C.EditorState.push(e,n,"change-inline-style")}n.d(e,"isListBlock",function(){return b}),n.d(e,"changeDepth",function(){return h}),n.d(e,"handleNewLine",function(){return O}),n.d(e,"getEntityRange",function(){return T}),n.d(e,"getCustomStyleMap",function(){return j}),n.d(e,"toggleCustomInlineStyle",function(){return M}),n.d(e,"getSelectionEntity",function(){return B}),n.d(e,"extractInlineStyle",function(){return L}),n.d(e,"removeAllInlineStyles",function(){return D}),n.d(e,"getSelectionInlineStyle",function(){return R}),n.d(e,"getSelectionCustomInlineStyle",function(){return w}),n.d(e,"getSelectedBlocksMap",function(){return m}),n.d(e,"getSelectedBlocksList",function(){return a}),n.d(e,"getSelectedBlock",function(){return f}),n.d(e,"getBlockBeforeSelectedBlock",function(){return r}),n.d(e,"getAllBlocks",function(){return o}),n.d(e,"getSelectedBlocksType",function(){return u}),n.d(e,"removeSelectedBlocksStyle",function(){return c}),n.d(e,"getSelectionText",function(){return l}),n.d(e,"addLineBreakRemovingSelection",function(){return s}),n.d(e,"insertNewUnstyledBlock",function(){return g}),n.d(e,"clearEditorContent",function(){return d}),n.d(e,"setBlockData",function(){return S}),n.d(e,"getSelectedBlocksMetadata",function(){return p}),n.d(e,"blockRenderMap",function(){return v});}],o.c=u,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n});},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0});},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=2);function o(t){if(u[t])return u[t].exports;var e=u[t]={i:t,l:!1,exports:{}};return i[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}var i,u;});
  23780. });
  23781. _commonjsHelpers.unwrapExports(draftjsUtils$1);
  23782. var draftjsUtils_1$1 = draftjsUtils$1.draftjsUtils;
  23783. var content$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  23784. Object.defineProperty(exports, "__esModule", {
  23785. value: true
  23786. });
  23787. exports.redo = exports.undo = exports.handleKeyCommand = exports.clear = exports.setMediaPosition = exports.removeMedia = exports.setMediaData = exports.insertMedias = exports.insertHorizontalLine = exports.insertAtomicBlock = exports.insertHTML = exports.insertText = exports.toggleSelectionLetterSpacing = exports.toggleSelectionFontFamily = exports.toggleSelectionLineHeight = exports.toggleSelectionFontSize = exports.toggleSelectionBackgroundColor = exports.toggleSelectionColor = exports.decreaseSelectionIndent = exports.increaseSelectionIndent = exports.toggleSelectionIndent = exports.toggleSelectionAlignment = exports.removeSelectionInlineStyles = exports.toggleSelectionInlineStyle = exports.selectionHasInlineStyle = exports.getSelectionInlineStyle = exports.toggleSelectionLink = exports.toggleSelectionEntity = exports.getSelectionEntityData = exports.getSelectionEntityType = exports.toggleSelectionBlockType = exports.getSelectionText = exports.getSelectionBlockType = exports.getSelectionBlockData = exports.setSelectionBlockData = exports.getSelectedBlocks = exports.updateEachCharacterOfSelection = exports.getSelectionBlock = exports.removeBlock = exports.selectNextBlock = exports.selectBlock = exports.selectionContainsStrictBlock = exports.selectionContainsBlockType = exports.isSelectionCollapsed = exports.createEditorState = exports.createEmptyEditorState = exports.isEditorState = exports.registerStrictBlockType = undefined;
  23788. var _immutable2 = _interopRequireDefault(immutable$2);
  23789. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23790. var strictBlockTypes = ['atomic'];
  23791. var registerStrictBlockType = exports.registerStrictBlockType = function registerStrictBlockType(blockType) {
  23792. strictBlockTypes.indexOf(blockType) === -1 && strictBlockTypes.push(blockType);
  23793. };
  23794. var isEditorState = exports.isEditorState = function isEditorState(editorState) {
  23795. return editorState instanceof Draft.Draft.EditorState;
  23796. };
  23797. var createEmptyEditorState = exports.createEmptyEditorState = function createEmptyEditorState(editorDecorators) {
  23798. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  23799. };
  23800. var createEditorState = exports.createEditorState = function createEditorState(contentState, editorDecorators) {
  23801. return Draft.Draft.EditorState.createWithContent(contentState, editorDecorators);
  23802. };
  23803. var isSelectionCollapsed = exports.isSelectionCollapsed = function isSelectionCollapsed(editorState) {
  23804. return editorState.getSelection().isCollapsed();
  23805. };
  23806. var selectionContainsBlockType = exports.selectionContainsBlockType = function selectionContainsBlockType(editorState, blockType) {
  23807. return getSelectedBlocks(editorState).find(function (block) {
  23808. return block.getType() === blockType;
  23809. });
  23810. };
  23811. var selectionContainsStrictBlock = exports.selectionContainsStrictBlock = function selectionContainsStrictBlock(editorState) {
  23812. return getSelectedBlocks(editorState).find(function (block) {
  23813. return ~strictBlockTypes.indexOf(block.getType());
  23814. });
  23815. };
  23816. var selectBlock = exports.selectBlock = function selectBlock(editorState, block) {
  23817. var blockKey = block.getKey();
  23818. return Draft.Draft.EditorState.forceSelection(editorState, new Draft.Draft.SelectionState({
  23819. anchorKey: blockKey,
  23820. anchorOffset: 0,
  23821. focusKey: blockKey,
  23822. focusOffset: block.getLength()
  23823. }));
  23824. };
  23825. var selectNextBlock = exports.selectNextBlock = function selectNextBlock(editorState, block) {
  23826. var nextBlock = editorState.getCurrentContent().getBlockAfter(block.getKey());
  23827. return nextBlock ? selectBlock(editorState, nextBlock) : editorState;
  23828. };
  23829. var removeBlock = exports.removeBlock = function removeBlock(editorState, block) {
  23830. var lastSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  23831. var nextContentState = void 0,
  23832. nextEditorState = void 0;
  23833. var blockKey = block.getKey();
  23834. nextContentState = Draft.Draft.Modifier.removeRange(editorState.getCurrentContent(), new Draft.Draft.SelectionState({
  23835. anchorKey: blockKey,
  23836. anchorOffset: 0,
  23837. focusKey: blockKey,
  23838. focusOffset: block.getLength()
  23839. }), 'backward');
  23840. nextContentState = Draft.Draft.Modifier.setBlockType(nextContentState, nextContentState.getSelectionAfter(), 'unstyled');
  23841. nextEditorState = Draft.Draft.EditorState.push(editorState, nextContentState, 'remove-range');
  23842. return Draft.Draft.EditorState.forceSelection(nextEditorState, lastSelection || nextContentState.getSelectionAfter());
  23843. };
  23844. var getSelectionBlock = exports.getSelectionBlock = function getSelectionBlock(editorState) {
  23845. return editorState.getCurrentContent().getBlockForKey(editorState.getSelection().getAnchorKey());
  23846. };
  23847. var updateEachCharacterOfSelection = exports.updateEachCharacterOfSelection = function updateEachCharacterOfSelection(editorState, callback) {
  23848. var selectionState = editorState.getSelection();
  23849. var contentState = editorState.getCurrentContent();
  23850. var contentBlocks = contentState.getBlockMap();
  23851. var selectedBlocks = getSelectedBlocks(editorState);
  23852. if (selectedBlocks.length === 0) {
  23853. return editorState;
  23854. }
  23855. var startKey = selectionState.getStartKey();
  23856. var startOffset = selectionState.getStartOffset();
  23857. var endKey = selectionState.getEndKey();
  23858. var endOffset = selectionState.getEndOffset();
  23859. var nextContentBlocks = contentBlocks.map(function (block) {
  23860. if (selectedBlocks.indexOf(block) === -1) {
  23861. return block;
  23862. }
  23863. var blockKey = block.getKey();
  23864. var charactersList = block.getCharacterList();
  23865. var nextCharactersList = null;
  23866. if (blockKey === startKey && blockKey === endKey) {
  23867. nextCharactersList = charactersList.map(function (character, index) {
  23868. if (index >= startOffset && index < endOffset) {
  23869. return callback(character);
  23870. }
  23871. return character;
  23872. });
  23873. } else if (blockKey === startKey) {
  23874. nextCharactersList = charactersList.map(function (character, index) {
  23875. if (index >= startOffset) {
  23876. return callback(character);
  23877. }
  23878. return character;
  23879. });
  23880. } else if (blockKey === endKey) {
  23881. nextCharactersList = charactersList.map(function (character, index) {
  23882. if (index < endOffset) {
  23883. return callback(character);
  23884. }
  23885. return character;
  23886. });
  23887. } else {
  23888. nextCharactersList = charactersList.map(function (character) {
  23889. return callback(character);
  23890. });
  23891. }
  23892. return block.merge({
  23893. 'characterList': nextCharactersList
  23894. });
  23895. });
  23896. return Draft.Draft.EditorState.push(editorState, contentState.merge({
  23897. blockMap: nextContentBlocks,
  23898. selectionBefore: selectionState,
  23899. selectionAfter: selectionState
  23900. }), 'update-selection-character-list');
  23901. };
  23902. var getSelectedBlocks = exports.getSelectedBlocks = function getSelectedBlocks(editorState) {
  23903. var selectionState = editorState.getSelection();
  23904. var contentState = editorState.getCurrentContent();
  23905. var startKey = selectionState.getStartKey();
  23906. var endKey = selectionState.getEndKey();
  23907. var isSameBlock = startKey === endKey;
  23908. var startingBlock = contentState.getBlockForKey(startKey);
  23909. var selectedBlocks = [startingBlock];
  23910. if (!isSameBlock) {
  23911. var blockKey = startKey;
  23912. while (blockKey !== endKey) {
  23913. var nextBlock = contentState.getBlockAfter(blockKey);
  23914. selectedBlocks.push(nextBlock);
  23915. blockKey = nextBlock.getKey();
  23916. }
  23917. }
  23918. return selectedBlocks;
  23919. };
  23920. var setSelectionBlockData = exports.setSelectionBlockData = function setSelectionBlockData(editorState, blockData, override) {
  23921. var newBlockData = override ? blockData : Object.assign({}, getSelectionBlockData(editorState).toJS(), blockData);
  23922. Object.keys(newBlockData).forEach(function (key) {
  23923. if (newBlockData.hasOwnProperty(key) && newBlockData[key] === undefined) {
  23924. delete newBlockData[key];
  23925. }
  23926. });
  23927. return (0, draftjsUtils$1.setBlockData)(editorState, newBlockData);
  23928. };
  23929. var getSelectionBlockData = exports.getSelectionBlockData = function getSelectionBlockData(editorState, name) {
  23930. var blockData = getSelectionBlock(editorState).getData();
  23931. return name ? blockData.get(name) : blockData;
  23932. };
  23933. var getSelectionBlockType = exports.getSelectionBlockType = function getSelectionBlockType(editorState) {
  23934. return getSelectionBlock(editorState).getType();
  23935. };
  23936. var getSelectionText = exports.getSelectionText = function getSelectionText(editorState) {
  23937. var selectionState = editorState.getSelection();
  23938. var contentState = editorState.getCurrentContent();
  23939. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  23940. return '';
  23941. }
  23942. var anchorKey = selectionState.getAnchorKey();
  23943. var currentContentBlock = contentState.getBlockForKey(anchorKey);
  23944. var start = selectionState.getStartOffset();
  23945. var end = selectionState.getEndOffset();
  23946. return currentContentBlock.getText().slice(start, end);
  23947. };
  23948. var toggleSelectionBlockType = exports.toggleSelectionBlockType = function toggleSelectionBlockType(editorState, blockType) {
  23949. if (selectionContainsStrictBlock(editorState)) {
  23950. return editorState;
  23951. }
  23952. return Draft.Draft.RichUtils.toggleBlockType(editorState, blockType);
  23953. };
  23954. var getSelectionEntityType = exports.getSelectionEntityType = function getSelectionEntityType(editorState) {
  23955. var entityKey = (0, draftjsUtils$1.getSelectionEntity)(editorState);
  23956. if (entityKey) {
  23957. var entity = editorState.getCurrentContent().getEntity(entityKey);
  23958. return entity ? entity.get('type') : null;
  23959. }
  23960. return null;
  23961. };
  23962. var getSelectionEntityData = exports.getSelectionEntityData = function getSelectionEntityData(editorState, type) {
  23963. var entityKey = (0, draftjsUtils$1.getSelectionEntity)(editorState);
  23964. if (entityKey) {
  23965. var entity = editorState.getCurrentContent().getEntity(entityKey);
  23966. if (entity && entity.get('type') === type) {
  23967. return entity.getData();
  23968. } else {
  23969. return {};
  23970. }
  23971. } else {
  23972. return {};
  23973. }
  23974. };
  23975. var toggleSelectionEntity = exports.toggleSelectionEntity = function toggleSelectionEntity(editorState, entity) {
  23976. var contentState = editorState.getCurrentContent();
  23977. var selectionState = editorState.getSelection();
  23978. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  23979. return editorState;
  23980. }
  23981. if (!entity || !entity.type || getSelectionEntityType(editorState) === entity.type) {
  23982. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.applyEntity(contentState, selectionState, null), 'apply-entity');
  23983. }
  23984. try {
  23985. var nextContentState = contentState.createEntity(entity.type, entity.mutability, entity.data);
  23986. var entityKey = nextContentState.getLastCreatedEntityKey();
  23987. var nextEditorState = Draft.Draft.EditorState.set(editorState, {
  23988. currentContent: nextContentState
  23989. });
  23990. return Draft.Draft.EditorState.push(nextEditorState, Draft.Draft.Modifier.applyEntity(nextContentState, selectionState, entityKey), 'apply-entity');
  23991. } catch (error) {
  23992. console.warn(error);
  23993. return editorState;
  23994. }
  23995. };
  23996. var toggleSelectionLink = exports.toggleSelectionLink = function toggleSelectionLink(editorState, href, target) {
  23997. var contentState = editorState.getCurrentContent();
  23998. var selectionState = editorState.getSelection();
  23999. var entityData = { href: href, target: target };
  24000. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  24001. return editorState;
  24002. }
  24003. if (href === false) {
  24004. return Draft.Draft.RichUtils.toggleLink(editorState, selectionState, null);
  24005. }
  24006. if (href === null) {
  24007. delete entityData.href;
  24008. }
  24009. try {
  24010. var nextContentState = contentState.createEntity('LINK', 'MUTABLE', entityData);
  24011. var entityKey = nextContentState.getLastCreatedEntityKey();
  24012. var nextEditorState = Draft.Draft.EditorState.set(editorState, {
  24013. currentContent: nextContentState
  24014. });
  24015. nextEditorState = Draft.Draft.RichUtils.toggleLink(nextEditorState, selectionState, entityKey);
  24016. nextEditorState = Draft.Draft.EditorState.forceSelection(nextEditorState, selectionState.merge({
  24017. anchorOffset: selectionState.getEndOffset(),
  24018. focusOffset: selectionState.getEndOffset()
  24019. }));
  24020. nextEditorState = Draft.Draft.EditorState.push(nextEditorState, Draft.Draft.Modifier.insertText(nextEditorState.getCurrentContent(), nextEditorState.getSelection(), ''), 'insert-text');
  24021. return nextEditorState;
  24022. } catch (error) {
  24023. console.warn(error);
  24024. return editorState;
  24025. }
  24026. };
  24027. var getSelectionInlineStyle = exports.getSelectionInlineStyle = function getSelectionInlineStyle(editorState) {
  24028. return editorState.getCurrentInlineStyle();
  24029. };
  24030. var selectionHasInlineStyle = exports.selectionHasInlineStyle = function selectionHasInlineStyle(editorState, style) {
  24031. return getSelectionInlineStyle(editorState).has(style.toUpperCase());
  24032. };
  24033. var toggleSelectionInlineStyle = exports.toggleSelectionInlineStyle = function toggleSelectionInlineStyle(editorState, style) {
  24034. var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  24035. var nextEditorState = editorState;
  24036. style = prefix + style.toUpperCase();
  24037. if (prefix) {
  24038. nextEditorState = updateEachCharacterOfSelection(nextEditorState, function (characterMetadata) {
  24039. return characterMetadata.toJS().style.reduce(function (characterMetadata, characterStyle) {
  24040. if (characterStyle.indexOf(prefix) === 0 && style !== characterStyle) {
  24041. return Draft.Draft.CharacterMetadata.removeStyle(characterMetadata, characterStyle);
  24042. } else {
  24043. return characterMetadata;
  24044. }
  24045. }, characterMetadata);
  24046. });
  24047. }
  24048. return Draft.Draft.RichUtils.toggleInlineStyle(nextEditorState, style);
  24049. };
  24050. var removeSelectionInlineStyles = exports.removeSelectionInlineStyles = function removeSelectionInlineStyles(editorState) {
  24051. return updateEachCharacterOfSelection(editorState, function (characterMetadata) {
  24052. return characterMetadata.merge({
  24053. style: _immutable2.default.OrderedSet([])
  24054. });
  24055. });
  24056. };
  24057. var toggleSelectionAlignment = exports.toggleSelectionAlignment = function toggleSelectionAlignment(editorState, alignment) {
  24058. return setSelectionBlockData(editorState, {
  24059. textAlign: getSelectionBlockData(editorState, 'textAlign') !== alignment ? alignment : undefined
  24060. });
  24061. };
  24062. var toggleSelectionIndent = exports.toggleSelectionIndent = function toggleSelectionIndent(editorState, textIndent) {
  24063. var maxIndent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6;
  24064. return textIndent < 0 || textIndent > maxIndent || isNaN(textIndent) ? editorState : setSelectionBlockData(editorState, {
  24065. textIndent: textIndent || undefined
  24066. });
  24067. };
  24068. var increaseSelectionIndent = exports.increaseSelectionIndent = function increaseSelectionIndent(editorState) {
  24069. var maxIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
  24070. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  24071. return toggleSelectionIndent(editorState, currentIndent + 1, maxIndent);
  24072. };
  24073. var decreaseSelectionIndent = exports.decreaseSelectionIndent = function decreaseSelectionIndent(editorState) {
  24074. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  24075. return toggleSelectionIndent(editorState, currentIndent - 1);
  24076. };
  24077. var toggleSelectionColor = exports.toggleSelectionColor = function toggleSelectionColor(editorState, color) {
  24078. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'COLOR-');
  24079. };
  24080. var toggleSelectionBackgroundColor = exports.toggleSelectionBackgroundColor = function toggleSelectionBackgroundColor(editorState, color) {
  24081. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'BGCOLOR-');
  24082. };
  24083. var toggleSelectionFontSize = exports.toggleSelectionFontSize = function toggleSelectionFontSize(editorState, fontSize) {
  24084. return toggleSelectionInlineStyle(editorState, fontSize, 'FONTSIZE-');
  24085. };
  24086. var toggleSelectionLineHeight = exports.toggleSelectionLineHeight = function toggleSelectionLineHeight(editorState, lineHeight) {
  24087. return toggleSelectionInlineStyle(editorState, lineHeight, 'LINEHEIGHT-');
  24088. };
  24089. var toggleSelectionFontFamily = exports.toggleSelectionFontFamily = function toggleSelectionFontFamily(editorState, fontFamily) {
  24090. return toggleSelectionInlineStyle(editorState, fontFamily, 'FONTFAMILY-');
  24091. };
  24092. var toggleSelectionLetterSpacing = exports.toggleSelectionLetterSpacing = function toggleSelectionLetterSpacing(editorState, letterSpacing) {
  24093. return toggleSelectionInlineStyle(editorState, letterSpacing, 'LETTERSPACING-');
  24094. };
  24095. var insertText = exports.insertText = function insertText(editorState, text, inlineStyle, entity) {
  24096. var selectionState = editorState.getSelection();
  24097. var currentSelectedBlockType = getSelectionBlockType(editorState);
  24098. if (currentSelectedBlockType === 'atomic') {
  24099. return editorState;
  24100. }
  24101. var entityKey = void 0;
  24102. var contentState = editorState.getCurrentContent();
  24103. if (entity && entity.type) {
  24104. contentState = contentState.createEntity(entity.type, entity.mutability || 'MUTABLE', entity.data || entityData);
  24105. entityKey = contentState.getLastCreatedEntityKey();
  24106. }
  24107. if (!selectionState.isCollapsed()) {
  24108. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.replaceText(contentState, selectionState, text, inlineStyle, entityKey), 'replace-text');
  24109. } else {
  24110. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.insertText(contentState, selectionState, text, inlineStyle, entityKey), 'insert-text');
  24111. }
  24112. };
  24113. var insertHTML = exports.insertHTML = function insertHTML(editorState, htmlString, source) {
  24114. if (!htmlString) {
  24115. return editorState;
  24116. }
  24117. var selectionState = editorState.getSelection();
  24118. var contentState = editorState.getCurrentContent();
  24119. var options = editorState.convertOptions || {};
  24120. try {
  24121. var _convertFromRaw = (0, Draft.Draft.convertFromRaw)((0, dist.convertHTMLToRaw)(htmlString, options, source)),
  24122. blockMap = _convertFromRaw.blockMap;
  24123. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.replaceWithFragment(contentState, selectionState, blockMap), 'insert-fragment');
  24124. } catch (error) {
  24125. console.warn(error);
  24126. return editorState;
  24127. }
  24128. };
  24129. var insertAtomicBlock = exports.insertAtomicBlock = function insertAtomicBlock(editorState, type) {
  24130. var immutable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  24131. var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  24132. if (selectionContainsStrictBlock(editorState)) {
  24133. return insertAtomicBlock(selectNextBlock(editorState, getSelectionBlock(editorState)), type, immutable, data);
  24134. }
  24135. var selectionState = editorState.getSelection();
  24136. var contentState = editorState.getCurrentContent();
  24137. if (!selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  24138. return editorState;
  24139. }
  24140. var contentStateWithEntity = contentState.createEntity(type, immutable ? 'IMMUTABLE' : 'MUTABLE', data);
  24141. var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
  24142. var newEditorState = Draft.Draft.AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' ');
  24143. return newEditorState;
  24144. };
  24145. var insertHorizontalLine = exports.insertHorizontalLine = function insertHorizontalLine(editorState) {
  24146. return insertAtomicBlock(editorState, 'HR');
  24147. };
  24148. var insertMedias = exports.insertMedias = function insertMedias(editorState) {
  24149. var medias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  24150. if (!medias.length) {
  24151. return editorState;
  24152. }
  24153. return medias.reduce(function (editorState, media) {
  24154. var url = media.url,
  24155. link = media.link,
  24156. link_target = media.link_target,
  24157. name = media.name,
  24158. type = media.type,
  24159. width = media.width,
  24160. height = media.height,
  24161. meta = media.meta;
  24162. return insertAtomicBlock(editorState, type, true, { url: url, link: link, link_target: link_target, name: name, type: type, width: width, height: height, meta: meta });
  24163. }, editorState);
  24164. };
  24165. var setMediaData = exports.setMediaData = function setMediaData(editorState, entityKey, data) {
  24166. return Draft.Draft.EditorState.push(editorState, editorState.getCurrentContent().mergeEntityData(entityKey, data), 'change-block-data');
  24167. };
  24168. var removeMedia = exports.removeMedia = function removeMedia(editorState, mediaBlock) {
  24169. return removeBlock(editorState, mediaBlock);
  24170. };
  24171. var setMediaPosition = exports.setMediaPosition = function setMediaPosition(editorState, mediaBlock, position) {
  24172. var newPosition = {};
  24173. var float = position.float,
  24174. alignment = position.alignment;
  24175. if (typeof float !== 'undefined') {
  24176. newPosition.float = mediaBlock.getData().get('float') === float ? null : float;
  24177. }
  24178. if (typeof alignment !== 'undefined') {
  24179. newPosition.alignment = mediaBlock.getData().get('alignment') === alignment ? null : alignment;
  24180. }
  24181. return setSelectionBlockData(selectBlock(editorState, mediaBlock), newPosition);
  24182. };
  24183. var clear = exports.clear = function clear(editorState) {
  24184. var contentState = editorState.getCurrentContent();
  24185. var firstBlock = contentState.getFirstBlock();
  24186. var lastBlock = contentState.getLastBlock();
  24187. var allSelected = new Draft.Draft.SelectionState({
  24188. anchorKey: firstBlock.getKey(),
  24189. anchorOffset: 0,
  24190. focusKey: lastBlock.getKey(),
  24191. focusOffset: lastBlock.getLength(),
  24192. hasFocus: true
  24193. });
  24194. return Draft.Draft.RichUtils.toggleBlockType(Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.removeRange(contentState, allSelected, 'backward'), 'remove-range'), 'unstyled');
  24195. };
  24196. var handleKeyCommand = exports.handleKeyCommand = function handleKeyCommand(editorState, command) {
  24197. return Draft.Draft.RichUtils.handleKeyCommand(editorState, command);
  24198. };
  24199. var undo = exports.undo = function undo(editorState) {
  24200. return Draft.Draft.EditorState.undo(editorState);
  24201. };
  24202. var redo = exports.redo = function redo(editorState) {
  24203. return Draft.Draft.EditorState.redo(editorState);
  24204. };
  24205. });
  24206. _commonjsHelpers.unwrapExports(content$1);
  24207. var content_1$1 = content$1.redo;
  24208. var content_2$1 = content$1.undo;
  24209. var content_3$1 = content$1.handleKeyCommand;
  24210. var content_4$1 = content$1.clear;
  24211. var content_5$1 = content$1.setMediaPosition;
  24212. var content_6$1 = content$1.removeMedia;
  24213. var content_7$1 = content$1.setMediaData;
  24214. var content_8$1 = content$1.insertMedias;
  24215. var content_9$1 = content$1.insertHorizontalLine;
  24216. var content_10$1 = content$1.insertAtomicBlock;
  24217. var content_11$1 = content$1.insertHTML;
  24218. var content_12$1 = content$1.insertText;
  24219. var content_13$1 = content$1.toggleSelectionLetterSpacing;
  24220. var content_14$1 = content$1.toggleSelectionFontFamily;
  24221. var content_15$1 = content$1.toggleSelectionLineHeight;
  24222. var content_16$1 = content$1.toggleSelectionFontSize;
  24223. var content_17$1 = content$1.toggleSelectionBackgroundColor;
  24224. var content_18$1 = content$1.toggleSelectionColor;
  24225. var content_19$1 = content$1.decreaseSelectionIndent;
  24226. var content_20$1 = content$1.increaseSelectionIndent;
  24227. var content_21$1 = content$1.toggleSelectionIndent;
  24228. var content_22$1 = content$1.toggleSelectionAlignment;
  24229. var content_23$1 = content$1.removeSelectionInlineStyles;
  24230. var content_24$1 = content$1.toggleSelectionInlineStyle;
  24231. var content_25$1 = content$1.selectionHasInlineStyle;
  24232. var content_26$1 = content$1.getSelectionInlineStyle;
  24233. var content_27$1 = content$1.toggleSelectionLink;
  24234. var content_28$1 = content$1.toggleSelectionEntity;
  24235. var content_29$1 = content$1.getSelectionEntityData;
  24236. var content_30$1 = content$1.getSelectionEntityType;
  24237. var content_31$1 = content$1.toggleSelectionBlockType;
  24238. var content_32$1 = content$1.getSelectionText;
  24239. var content_33$1 = content$1.getSelectionBlockType;
  24240. var content_34$1 = content$1.getSelectionBlockData;
  24241. var content_35$1 = content$1.setSelectionBlockData;
  24242. var content_36$1 = content$1.getSelectedBlocks;
  24243. var content_37$1 = content$1.updateEachCharacterOfSelection;
  24244. var content_38$1 = content$1.getSelectionBlock;
  24245. var content_39$1 = content$1.removeBlock;
  24246. var content_40$1 = content$1.selectNextBlock;
  24247. var content_41$1 = content$1.selectBlock;
  24248. var content_42$1 = content$1.selectionContainsStrictBlock;
  24249. var content_43$1 = content$1.selectionContainsBlockType;
  24250. var content_44$1 = content$1.isSelectionCollapsed;
  24251. var content_45$1 = content$1.createEditorState;
  24252. var content_46$1 = content$1.createEmptyEditorState;
  24253. var content_47$1 = content$1.isEditorState;
  24254. var content_48$1 = content$1.registerStrictBlockType;
  24255. var base$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  24256. Object.defineProperty(exports, "__esModule", {
  24257. value: true
  24258. });
  24259. var braftUniqueIndex = 0;
  24260. var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
  24261. return braftUniqueIndex += 1;
  24262. };
  24263. });
  24264. _commonjsHelpers.unwrapExports(base$1);
  24265. var base_1$1 = base$1.UniqueIndex;
  24266. var color$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  24267. Object.defineProperty(exports, "__esModule", {
  24268. value: true
  24269. });
  24270. var _namedColors = {
  24271. "aliceblue": "#f0f8ff",
  24272. "antiquewhite": "#faebd7",
  24273. "aqua": "#00ffff",
  24274. "aquamarine": "#7fffd4",
  24275. "azure": "#f0ffff",
  24276. "beige": "#f5f5dc",
  24277. "bisque": "#ffe4c4",
  24278. "black": "#000000",
  24279. "blanchedalmond": "#ffebcd",
  24280. "blue": "#0000ff",
  24281. "blueviolet": "#8a2be2",
  24282. "brown": "#a52a2a",
  24283. "burlywood": "#deb887",
  24284. "cadetblue": "#5f9ea0",
  24285. "chartreuse": "#7fff00",
  24286. "chocolate": "#d2691e",
  24287. "coral": "#ff7f50",
  24288. "cornflowerblue": "#6495ed",
  24289. "cornsilk": "#fff8dc",
  24290. "crimson": "#dc143c",
  24291. "cyan": "#00ffff",
  24292. "darkblue": "#00008b",
  24293. "darkcyan": "#008b8b",
  24294. "darkgoldenrod": "#b8860b",
  24295. "darkgray": "#a9a9a9",
  24296. "darkgreen": "#006400",
  24297. "darkkhaki": "#bdb76b",
  24298. "darkmagenta": "#8b008b",
  24299. "darkolivegreen": "#556b2f",
  24300. "darkorange": "#ff8c00",
  24301. "darkorchid": "#9932cc",
  24302. "darkred": "#8b0000",
  24303. "darksalmon": "#e9967a",
  24304. "darkseagreen": "#8fbc8f",
  24305. "darkslateblue": "#483d8b",
  24306. "darkslategray": "#2f4f4f",
  24307. "darkturquoise": "#00ced1",
  24308. "darkviolet": "#9400d3",
  24309. "deeppink": "#ff1493",
  24310. "deepskyblue": "#00bfff",
  24311. "dimgray": "#696969",
  24312. "dodgerblue": "#1e90ff",
  24313. "firebrick": "#b22222",
  24314. "floralwhite": "#fffaf0",
  24315. "forestgreen": "#228b22",
  24316. "fuchsia": "#ff00ff",
  24317. "gainsboro": "#dcdcdc",
  24318. "ghostwhite": "#f8f8ff",
  24319. "gold": "#ffd700",
  24320. "goldenrod": "#daa520",
  24321. "gray": "#808080",
  24322. "green": "#008000",
  24323. "greenyellow": "#adff2f",
  24324. "honeydew": "#f0fff0",
  24325. "hotpink": "#ff69b4",
  24326. "indianred ": "#cd5c5c",
  24327. "indigo": "#4b0082",
  24328. "ivory": "#fffff0",
  24329. "khaki": "#f0e68c",
  24330. "lavender": "#e6e6fa",
  24331. "lavenderblush": "#fff0f5",
  24332. "lawngreen": "#7cfc00",
  24333. "lemonchiffon": "#fffacd",
  24334. "lightblue": "#add8e6",
  24335. "lightcoral": "#f08080",
  24336. "lightcyan": "#e0ffff",
  24337. "lightgoldenrodyellow": "#fafad2",
  24338. "lightgrey": "#d3d3d3",
  24339. "lightgreen": "#90ee90",
  24340. "lightpink": "#ffb6c1",
  24341. "lightsalmon": "#ffa07a",
  24342. "lightseagreen": "#20b2aa",
  24343. "lightskyblue": "#87cefa",
  24344. "lightslategray": "#778899",
  24345. "lightsteelblue": "#b0c4de",
  24346. "lightyellow": "#ffffe0",
  24347. "lime": "#00ff00",
  24348. "limegreen": "#32cd32",
  24349. "linen": "#faf0e6",
  24350. "magenta": "#ff00ff",
  24351. "maroon": "#800000",
  24352. "mediumaquamarine": "#66cdaa",
  24353. "mediumblue": "#0000cd",
  24354. "mediumorchid": "#ba55d3",
  24355. "mediumpurple": "#9370d8",
  24356. "mediumseagreen": "#3cb371",
  24357. "mediumslateblue": "#7b68ee",
  24358. "mediumspringgreen": "#00fa9a",
  24359. "mediumturquoise": "#48d1cc",
  24360. "mediumvioletred": "#c71585",
  24361. "midnightblue": "#191970",
  24362. "mintcream": "#f5fffa",
  24363. "mistyrose": "#ffe4e1",
  24364. "moccasin": "#ffe4b5",
  24365. "navajowhite": "#ffdead",
  24366. "navy": "#000080",
  24367. "oldlace": "#fdf5e6",
  24368. "olive": "#808000",
  24369. "olivedrab": "#6b8e23",
  24370. "orange": "#ffa500",
  24371. "orangered": "#ff4500",
  24372. "orchid": "#da70d6",
  24373. "palegoldenrod": "#eee8aa",
  24374. "palegreen": "#98fb98",
  24375. "paleturquoise": "#afeeee",
  24376. "palevioletred": "#d87093",
  24377. "papayawhip": "#ffefd5",
  24378. "peachpuff": "#ffdab9",
  24379. "peru": "#cd853f",
  24380. "pink": "#ffc0cb",
  24381. "plum": "#dda0dd",
  24382. "powderblue": "#b0e0e6",
  24383. "purple": "#800080",
  24384. "rebeccapurple": "#663399",
  24385. "red": "#ff0000",
  24386. "rosybrown": "#bc8f8f",
  24387. "royalblue": "#4169e1",
  24388. "saddlebrown": "#8b4513",
  24389. "salmon": "#fa8072",
  24390. "sandybrown": "#f4a460",
  24391. "seagreen": "#2e8b57",
  24392. "seashell": "#fff5ee",
  24393. "sienna": "#a0522d",
  24394. "silver": "#c0c0c0",
  24395. "skyblue": "#87ceeb",
  24396. "slateblue": "#6a5acd",
  24397. "slategray": "#708090",
  24398. "snow": "#fffafa",
  24399. "springgreen": "#00ff7f",
  24400. "steelblue": "#4682b4",
  24401. "tan": "#d2b48c",
  24402. "teal": "#008080",
  24403. "thistle": "#d8bfd8",
  24404. "tomato": "#ff6347",
  24405. "turquoise": "#40e0d0",
  24406. "violet": "#ee82ee",
  24407. "wheat": "#f5deb3",
  24408. "white": "#ffffff",
  24409. "whitesmoke": "#f5f5f5",
  24410. "yellow": "#ffff00",
  24411. "yellowgreen": "#9acd32"
  24412. };
  24413. var _getHexColor = function _getHexColor(color) {
  24414. color = color.replace('color:', '').replace(';', '').replace(' ', '');
  24415. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  24416. return color;
  24417. } else if (namedColors[color]) {
  24418. return namedColors[color];
  24419. } else if (color.indexOf('rgb') === 0) {
  24420. var rgbArray = color.split(',');
  24421. var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
  24422. var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
  24423. return hex.length === 1 ? '0' + hex : hex;
  24424. }).join('');
  24425. return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
  24426. );
  24427. } else {
  24428. return null;
  24429. }
  24430. };
  24431. var namedColors = exports.namedColors = _namedColors;
  24432. var getHexColor = exports.getHexColor = _getHexColor;
  24433. var detectColorsFromHTMLString = exports.detectColorsFromHTMLString = function detectColorsFromHTMLString(html) {
  24434. return typeof html !== 'string' ? [] : (html.match(/color:[^;]{3,24};/g) || []).map(getHexColor).filter(function (color) {
  24435. return color;
  24436. });
  24437. };
  24438. var detectColorsFromDraftState = exports.detectColorsFromDraftState = function detectColorsFromDraftState(draftState) {
  24439. var result = [];
  24440. if (!draftState || !draftState.blocks || !draftState.blocks.length) {
  24441. return result;
  24442. }
  24443. draftState.blocks.forEach(function (block) {
  24444. if (block && block.inlineStyleRanges && block.inlineStyleRanges.length) {
  24445. block.inlineStyleRanges.forEach(function (inlineStyle) {
  24446. if (inlineStyle.style && inlineStyle.style.indexOf('COLOR-') >= 0) {
  24447. result.push('#' + inlineStyle.style.split('COLOR-')[1]);
  24448. }
  24449. });
  24450. }
  24451. });
  24452. return result.filter(function (color) {
  24453. return color;
  24454. });
  24455. };
  24456. });
  24457. _commonjsHelpers.unwrapExports(color$1);
  24458. var color_1$1 = color$1.namedColors;
  24459. var color_2$1 = color$1.getHexColor;
  24460. var color_3$1 = color$1.detectColorsFromHTMLString;
  24461. var color_4$1 = color$1.detectColorsFromDraftState;
  24462. var dist$4 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  24463. Object.defineProperty(exports, "__esModule", {
  24464. value: true
  24465. });
  24466. exports.ColorUtils = exports.BaseUtils = exports.ContentUtils = undefined;
  24467. var _ContentUtils = _interopRequireWildcard(content$1);
  24468. var _BaseUtils = _interopRequireWildcard(base$1);
  24469. var _ColorUtils = _interopRequireWildcard(color$1);
  24470. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  24471. var ContentUtils = exports.ContentUtils = _ContentUtils;
  24472. var BaseUtils = exports.BaseUtils = _BaseUtils;
  24473. var ColorUtils = exports.ColorUtils = _ColorUtils;
  24474. });
  24475. _commonjsHelpers.unwrapExports(dist$4);
  24476. var dist_1$2 = dist$4.ColorUtils;
  24477. var dist_2$2 = dist$4.BaseUtils;
  24478. var dist_3$2 = dist$4.ContentUtils;
  24479. var emoticon = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  24480. (function webpackUniversalModuleDefinition(root, factory) {
  24481. module.exports = factory(React__default, dist$4);
  24482. })(window, function(__WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__6__) {
  24483. return /******/ (function(modules) { // webpackBootstrap
  24484. /******/ // The module cache
  24485. /******/ var installedModules = {};
  24486. /******/
  24487. /******/ // The require function
  24488. /******/ function __webpack_require__(moduleId) {
  24489. /******/
  24490. /******/ // Check if module is in cache
  24491. /******/ if(installedModules[moduleId]) {
  24492. /******/ return installedModules[moduleId].exports;
  24493. /******/ }
  24494. /******/ // Create a new module (and put it into the cache)
  24495. /******/ var module = installedModules[moduleId] = {
  24496. /******/ i: moduleId,
  24497. /******/ l: false,
  24498. /******/ exports: {}
  24499. /******/ };
  24500. /******/
  24501. /******/ // Execute the module function
  24502. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  24503. /******/
  24504. /******/ // Flag the module as loaded
  24505. /******/ module.l = true;
  24506. /******/
  24507. /******/ // Return the exports of the module
  24508. /******/ return module.exports;
  24509. /******/ }
  24510. /******/
  24511. /******/
  24512. /******/ // expose the modules object (__webpack_modules__)
  24513. /******/ __webpack_require__.m = modules;
  24514. /******/
  24515. /******/ // expose the module cache
  24516. /******/ __webpack_require__.c = installedModules;
  24517. /******/
  24518. /******/ // define getter function for harmony exports
  24519. /******/ __webpack_require__.d = function(exports, name, getter) {
  24520. /******/ if(!__webpack_require__.o(exports, name)) {
  24521. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  24522. /******/ }
  24523. /******/ };
  24524. /******/
  24525. /******/ // define __esModule on exports
  24526. /******/ __webpack_require__.r = function(exports) {
  24527. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  24528. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  24529. /******/ }
  24530. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  24531. /******/ };
  24532. /******/
  24533. /******/ // create a fake namespace object
  24534. /******/ // mode & 1: value is a module id, require it
  24535. /******/ // mode & 2: merge all properties of value into the ns
  24536. /******/ // mode & 4: return value when already ns object
  24537. /******/ // mode & 8|1: behave like require
  24538. /******/ __webpack_require__.t = function(value, mode) {
  24539. /******/ if(mode & 1) value = __webpack_require__(value);
  24540. /******/ if(mode & 8) return value;
  24541. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  24542. /******/ var ns = Object.create(null);
  24543. /******/ __webpack_require__.r(ns);
  24544. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  24545. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  24546. /******/ return ns;
  24547. /******/ };
  24548. /******/
  24549. /******/ // getDefaultExport function for compatibility with non-harmony modules
  24550. /******/ __webpack_require__.n = function(module) {
  24551. /******/ var getter = module && module.__esModule ?
  24552. /******/ function getDefault() { return module['default']; } :
  24553. /******/ function getModuleExports() { return module; };
  24554. /******/ __webpack_require__.d(getter, 'a', getter);
  24555. /******/ return getter;
  24556. /******/ };
  24557. /******/
  24558. /******/ // Object.prototype.hasOwnProperty.call
  24559. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  24560. /******/
  24561. /******/ // __webpack_public_path__
  24562. /******/ __webpack_require__.p = "/";
  24563. /******/
  24564. /******/
  24565. /******/ // Load entry module and return exports
  24566. /******/ return __webpack_require__(__webpack_require__.s = 33);
  24567. /******/ })
  24568. /************************************************************************/
  24569. /******/ ({
  24570. /***/ 1:
  24571. /***/ (function(module, exports) {
  24572. module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
  24573. /***/ }),
  24574. /***/ 2:
  24575. /***/ (function(module, exports) {
  24576. function _defineProperty(obj, key, value) {
  24577. if (key in obj) {
  24578. Object.defineProperty(obj, key, {
  24579. value: value,
  24580. enumerable: true,
  24581. configurable: true,
  24582. writable: true
  24583. });
  24584. } else {
  24585. obj[key] = value;
  24586. }
  24587. return obj;
  24588. }
  24589. module.exports = _defineProperty;
  24590. /***/ }),
  24591. /***/ 33:
  24592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24593. __webpack_require__.r(__webpack_exports__);
  24594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultEmoticons", function() { return defaultEmoticons; });
  24595. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
  24596. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
  24597. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
  24598. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  24599. /* harmony import */ var braft_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
  24600. /* harmony import */ var _styles_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(48);
  24601. // https://www.iconfinder.com/iconsets/emoji-18
  24602. var defaultEmoticons = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25].map(function (item) {
  24603. return "".concat(item, ".png");
  24604. });
  24605. var insertEmoticon = function insertEmoticon(editor, editorState, src) {
  24606. editor.setValue(braft_utils__WEBPACK_IMPORTED_MODULE_2__["ContentUtils"].insertText(editorState, ' ', null, {
  24607. type: 'EMOTICON',
  24608. mutability: 'IMMUTABLE',
  24609. data: {
  24610. src: src
  24611. }
  24612. }));
  24613. };
  24614. var controlRef = null;
  24615. var bindControlRef = function bindControlRef(ref) {
  24616. return controlRef = ref;
  24617. };
  24618. /* harmony default export */ __webpack_exports__["default"] = (function (options) {
  24619. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
  24620. emoticons: [],
  24621. closeOnSelect: false,
  24622. closeOnBlur: false
  24623. }, options);
  24624. var _options = options,
  24625. emoticons = _options.emoticons,
  24626. closeOnSelect = _options.closeOnSelect,
  24627. closeOnBlur = _options.closeOnBlur,
  24628. includeEditors = _options.includeEditors,
  24629. excludeEditors = _options.excludeEditors;
  24630. return {
  24631. type: 'entity',
  24632. includeEditors: includeEditors,
  24633. excludeEditors: excludeEditors,
  24634. name: 'EMOTICON',
  24635. control: function control(props) {
  24636. return {
  24637. key: 'EMOTICON',
  24638. replace: 'emoji',
  24639. type: 'dropdown',
  24640. text: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("i", {
  24641. className: "bfi-emoji"
  24642. }),
  24643. showArrow: false,
  24644. ref: bindControlRef,
  24645. autoHide: closeOnBlur,
  24646. component: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
  24647. className: "braft-emoticon-picker"
  24648. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
  24649. className: "braft-emoticons-list"
  24650. }, emoticons.map(function (item, index) {
  24651. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  24652. onClick: function onClick() {
  24653. insertEmoticon(props.editor, props.editorState, item);
  24654. closeOnSelect && controlRef && controlRef.hide();
  24655. },
  24656. key: index,
  24657. src: item
  24658. });
  24659. })))
  24660. };
  24661. },
  24662. mutability: 'IMMUTABLE',
  24663. component: function component(props) {
  24664. var entity = props.contentState.getEntity(props.entityKey);
  24665. var _entity$getData = entity.getData(),
  24666. src = _entity$getData.src;
  24667. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
  24668. className: "braft-emoticon-in-editor"
  24669. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  24670. src: src
  24671. }), props.children);
  24672. },
  24673. importer: function importer(nodeName, node) {
  24674. if (nodeName.toLowerCase() === 'span' && node.classList && node.classList.contains('braft-emoticon-wrap')) {
  24675. var imgNode = node.querySelector('img');
  24676. var src = imgNode.getAttribute('src'); // 移除img节点以避免生成atomic block
  24677. node.removeChild(imgNode);
  24678. return {
  24679. mutability: 'IMMUTABLE',
  24680. data: {
  24681. src: src
  24682. }
  24683. };
  24684. }
  24685. },
  24686. exporter: function exporter(entityObject, initialText) {
  24687. var src = entityObject.data.src;
  24688. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
  24689. className: "braft-emoticon-wrap"
  24690. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  24691. src: src
  24692. }), initialText);
  24693. }
  24694. };
  24695. });
  24696. /***/ }),
  24697. /***/ 48:
  24698. /***/ (function(module, exports) {
  24699. // removed by extract-text-webpack-plugin
  24700. /***/ }),
  24701. /***/ 5:
  24702. /***/ (function(module, exports, __webpack_require__) {
  24703. var defineProperty = __webpack_require__(2);
  24704. function _objectSpread(target) {
  24705. for (var i = 1; i < arguments.length; i++) {
  24706. var source = arguments[i] != null ? arguments[i] : {};
  24707. var ownKeys = Object.keys(source);
  24708. if (typeof Object.getOwnPropertySymbols === 'function') {
  24709. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  24710. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  24711. }));
  24712. }
  24713. ownKeys.forEach(function (key) {
  24714. defineProperty(target, key, source[key]);
  24715. });
  24716. }
  24717. return target;
  24718. }
  24719. module.exports = _objectSpread;
  24720. /***/ }),
  24721. /***/ 6:
  24722. /***/ (function(module, exports) {
  24723. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  24724. /***/ })
  24725. /******/ });
  24726. });
  24727. });
  24728. var Emoticon = _commonjsHelpers.unwrapExports(emoticon);
  24729. var emoticon_1 = emoticon.defaultEmoticons;
  24730. var maxLength = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  24731. (function webpackUniversalModuleDefinition(root, factory) {
  24732. module.exports = factory();
  24733. })(window, function() {
  24734. return /******/ (function(modules) { // webpackBootstrap
  24735. /******/ // The module cache
  24736. /******/ var installedModules = {};
  24737. /******/
  24738. /******/ // The require function
  24739. /******/ function __webpack_require__(moduleId) {
  24740. /******/
  24741. /******/ // Check if module is in cache
  24742. /******/ if(installedModules[moduleId]) {
  24743. /******/ return installedModules[moduleId].exports;
  24744. /******/ }
  24745. /******/ // Create a new module (and put it into the cache)
  24746. /******/ var module = installedModules[moduleId] = {
  24747. /******/ i: moduleId,
  24748. /******/ l: false,
  24749. /******/ exports: {}
  24750. /******/ };
  24751. /******/
  24752. /******/ // Execute the module function
  24753. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  24754. /******/
  24755. /******/ // Flag the module as loaded
  24756. /******/ module.l = true;
  24757. /******/
  24758. /******/ // Return the exports of the module
  24759. /******/ return module.exports;
  24760. /******/ }
  24761. /******/
  24762. /******/
  24763. /******/ // expose the modules object (__webpack_modules__)
  24764. /******/ __webpack_require__.m = modules;
  24765. /******/
  24766. /******/ // expose the module cache
  24767. /******/ __webpack_require__.c = installedModules;
  24768. /******/
  24769. /******/ // define getter function for harmony exports
  24770. /******/ __webpack_require__.d = function(exports, name, getter) {
  24771. /******/ if(!__webpack_require__.o(exports, name)) {
  24772. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  24773. /******/ }
  24774. /******/ };
  24775. /******/
  24776. /******/ // define __esModule on exports
  24777. /******/ __webpack_require__.r = function(exports) {
  24778. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  24779. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  24780. /******/ }
  24781. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  24782. /******/ };
  24783. /******/
  24784. /******/ // create a fake namespace object
  24785. /******/ // mode & 1: value is a module id, require it
  24786. /******/ // mode & 2: merge all properties of value into the ns
  24787. /******/ // mode & 4: return value when already ns object
  24788. /******/ // mode & 8|1: behave like require
  24789. /******/ __webpack_require__.t = function(value, mode) {
  24790. /******/ if(mode & 1) value = __webpack_require__(value);
  24791. /******/ if(mode & 8) return value;
  24792. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  24793. /******/ var ns = Object.create(null);
  24794. /******/ __webpack_require__.r(ns);
  24795. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  24796. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  24797. /******/ return ns;
  24798. /******/ };
  24799. /******/
  24800. /******/ // getDefaultExport function for compatibility with non-harmony modules
  24801. /******/ __webpack_require__.n = function(module) {
  24802. /******/ var getter = module && module.__esModule ?
  24803. /******/ function getDefault() { return module['default']; } :
  24804. /******/ function getModuleExports() { return module; };
  24805. /******/ __webpack_require__.d(getter, 'a', getter);
  24806. /******/ return getter;
  24807. /******/ };
  24808. /******/
  24809. /******/ // Object.prototype.hasOwnProperty.call
  24810. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  24811. /******/
  24812. /******/ // __webpack_public_path__
  24813. /******/ __webpack_require__.p = "/";
  24814. /******/
  24815. /******/
  24816. /******/ // Load entry module and return exports
  24817. /******/ return __webpack_require__(__webpack_require__.s = 34);
  24818. /******/ })
  24819. /************************************************************************/
  24820. /******/ ({
  24821. /***/ 2:
  24822. /***/ (function(module, exports) {
  24823. function _defineProperty(obj, key, value) {
  24824. if (key in obj) {
  24825. Object.defineProperty(obj, key, {
  24826. value: value,
  24827. enumerable: true,
  24828. configurable: true,
  24829. writable: true
  24830. });
  24831. } else {
  24832. obj[key] = value;
  24833. }
  24834. return obj;
  24835. }
  24836. module.exports = _defineProperty;
  24837. /***/ }),
  24838. /***/ 34:
  24839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24840. __webpack_require__.r(__webpack_exports__);
  24841. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
  24842. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
  24843. var getSelectedTextLength = function getSelectedTextLength(editorState) {
  24844. var currentSelection = editorState.getSelection();
  24845. var isCollapsed = currentSelection.isCollapsed();
  24846. var length = 0;
  24847. if (!isCollapsed) {
  24848. var currentContent = editorState.getCurrentContent();
  24849. var startKey = currentSelection.getStartKey();
  24850. var endKey = currentSelection.getEndKey();
  24851. var startBlock = currentContent.getBlockForKey(startKey);
  24852. var isStartAndEndBlockAreTheSame = startKey === endKey;
  24853. var startBlockTextLength = startBlock.getLength();
  24854. var startSelectedTextLength = startBlockTextLength - currentSelection.getStartOffset();
  24855. var endSelectedTextLength = currentSelection.getEndOffset();
  24856. var keyAfterEnd = currentContent.getKeyAfter(endKey);
  24857. if (isStartAndEndBlockAreTheSame) {
  24858. length += currentSelection.getEndOffset() - currentSelection.getStartOffset();
  24859. } else {
  24860. var currentKey = startKey;
  24861. while (currentKey && currentKey !== keyAfterEnd) {
  24862. if (currentKey === startKey) {
  24863. length += startSelectedTextLength + 1;
  24864. } else if (currentKey === endKey) {
  24865. length += endSelectedTextLength;
  24866. } else {
  24867. length += currentContent.getBlockForKey(currentKey).getLength() + 1;
  24868. }
  24869. currentKey = currentContent.getKeyAfter(currentKey);
  24870. }
  24871. }
  24872. }
  24873. return length;
  24874. };
  24875. /* harmony default export */ __webpack_exports__["default"] = (function (options) {
  24876. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
  24877. defaultValue: Infinity
  24878. }, options);
  24879. var _options = options,
  24880. includeEditors = _options.includeEditors,
  24881. excludeEditors = _options.excludeEditors,
  24882. defaultValue = _options.defaultValue;
  24883. return {
  24884. type: 'prop-interception',
  24885. includeEditors: includeEditors,
  24886. excludeEditors: excludeEditors,
  24887. interceptor: function interceptor(editorProps) {
  24888. var maxLength = editorProps.maxLength || defaultValue;
  24889. editorProps.handleBeforeInput = function (_, editorState) {
  24890. if (maxLength === Infinity) {
  24891. return 'not-handled';
  24892. }
  24893. var currentContentLength = editorState.toText().length;
  24894. var selectedTextLength = getSelectedTextLength(editorState);
  24895. if (currentContentLength - selectedTextLength > maxLength - 1) {
  24896. editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
  24897. return 'handled';
  24898. }
  24899. };
  24900. editorProps.handlePastedText = function (pastedText, _, editorState) {
  24901. if (maxLength === Infinity) {
  24902. return 'not-handled';
  24903. }
  24904. var currentContentLength = editorState.toText().length;
  24905. var selectedTextLength = getSelectedTextLength(editorState);
  24906. if (currentContentLength + pastedText.length - selectedTextLength > maxLength) {
  24907. editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
  24908. return 'handled';
  24909. }
  24910. };
  24911. return editorProps;
  24912. }
  24913. };
  24914. });
  24915. /***/ }),
  24916. /***/ 5:
  24917. /***/ (function(module, exports, __webpack_require__) {
  24918. var defineProperty = __webpack_require__(2);
  24919. function _objectSpread(target) {
  24920. for (var i = 1; i < arguments.length; i++) {
  24921. var source = arguments[i] != null ? arguments[i] : {};
  24922. var ownKeys = Object.keys(source);
  24923. if (typeof Object.getOwnPropertySymbols === 'function') {
  24924. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  24925. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  24926. }));
  24927. }
  24928. ownKeys.forEach(function (key) {
  24929. defineProperty(target, key, source[key]);
  24930. });
  24931. }
  24932. return target;
  24933. }
  24934. module.exports = _objectSpread;
  24935. /***/ })
  24936. /******/ });
  24937. });
  24938. });
  24939. var MaxLength = _commonjsHelpers.unwrapExports(maxLength);
  24940. var lengthOptions = {
  24941. defaultValue: 100
  24942. };
  24943. BraftEditor.use(MaxLength(lengthOptions));
  24944. var emoticons = emoticon_1.map(function (item) {
  24945. return require("braft-extensions/dist/assets/".concat(item));
  24946. });
  24947. var emotionOptions = {
  24948. emoticons: emoticons,
  24949. closeOnBlur: true,
  24950. closeOnSelect: false
  24951. };
  24952. BraftEditor.use(Emoticon(emotionOptions));
  24953. var BarftEditorPage = function BarftEditorPage(_ref) {
  24954. var value = _ref.value;
  24955. var controls = ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
  24956. var _useState = React.useState(BraftEditor.createEditorState(value || "<p>Hello <b>World!</b></p>")),
  24957. _useState2 = _rollupPluginBabelHelpers._slicedToArray(_useState, 2),
  24958. editorState = _useState2[0],
  24959. setEditorState = _useState2[1];
  24960. return React__default.createElement("div", {
  24961. className: "editor-wrapper"
  24962. }, React__default.createElement(BraftEditor, {
  24963. value: editorState,
  24964. onChange: setEditorState,
  24965. controls: controls,
  24966. contentStyle: {
  24967. boxShadow: "inset 0 1px 3px rgba(0,0,0,.1)"
  24968. }
  24969. }));
  24970. };
  24971. exports.BarftEditorPage = BarftEditorPage;
  24972. exports.default = BarftEditorPage;
  24973. //# sourceMappingURL=index.js.map